No history yet

Set Theory

What is a Set?

In mathematics, a set is simply a collection of distinct objects. These objects, called elements or members, can be anything: numbers, letters, people, or even other sets. The key is that each element is unique, and the order of elements doesn't matter.

Think of it like a grocery list. The set of items you need to buy is {milk, eggs, bread}. The order you write them in doesn't change what's in the set. And you wouldn't write "eggs" twice; each item is distinct.

We usually write sets by listing their elements inside curly braces {}. For example, if we have a set AA containing the first five positive integers, we would write it like this:

A={1,2,3,4,5}A = \{1, 2, 3, 4, 5\}

To say that 3 is an element of set AA, we use the symbol \in. So, we can write 3A3 \in A. To say that 6 is not an element of AA, we write 6A6 \notin A.

Types of Sets

Sets can be big or small. A finite set is one where you can count all the elements, even if the number is very large. The set of students in a classroom is a finite set. An infinite set, as you might guess, has an unlimited number of elements. The set of all integers is infinite because you can keep counting forever.

Sometimes, one set is completely contained within another. This is called a subset. If every element of set BB is also an element of set AA, then BB is a subset of AA. We use the symbol \subseteq to show this relationship.

BAB \subseteq A

For example, if A={1,2,3,4,5}A = \{1, 2, 3, 4, 5\} and B={2,4}B = \{2, 4\}, then BB is a subset of AA because both 2 and 4 are in AA.

Lesson image

There's also a special set called the empty set, which contains no elements at all. It's represented by the symbol \emptyset or just {}. The empty set is a subset of every set.

Set Operations

Just like we can add or subtract numbers, we can perform operations on sets to combine them or find out what they have in common. These operations are fundamental in fields like database queries and computer logic.

Union

noun

The union of two sets contains all the elements that are in either set (or both).

The symbol for union is \cup. If we have set A={1,2,3}A = \{1, 2, 3\} and set B={3,4,5}B = \{3, 4, 5\}, their union is:

AB={1,2,3,4,5}A \cup B = \{1, 2, 3, 4, 5\}

Notice that the element 3, which is in both sets, appears only once in the union. Remember, sets only contain distinct elements.

Intersection

noun

The intersection of two sets contains only the elements that are in both sets.

The symbol for intersection is \cap. Using the same sets AA and BB from before:

AB={3}A \cap B = \{3\}

The only element they share is 3.

Next up is the difference. The difference of set AA and set BB, written ABA - B, is the set of elements that are in AA but not in BB. Think of it as taking everything in AA and removing whatever is also in BB.

AB={1,2}A - B = \{1, 2\}

The order matters here! The difference BAB - A would be the elements in BB but not in AA:

BA={4,5}B - A = \{4, 5\}

Finally, we have the complement. The complement of a set AA, written as AA', contains everything that is not in AA. To define this, we need to know the universal set (UU), which is the set of all possible elements for the context we are considering. For example, if we're talking about numbers, the universal set might be all integers.

If our universal set is U={1,2,3,4,5,6}U = \{1, 2, 3, 4, 5, 6\} and A={1,2,3}A = \{1, 2, 3\}, then the complement of AA is:

A={4,5,6}A' = \{4, 5, 6\}

Cartesian Products

The last concept we'll cover is the Cartesian product. This operation creates a new set from two existing sets by forming all possible ordered pairs. The first element of the pair comes from the first set, and the second element comes from the second set.

Imagine a restaurant menu. Set MM has main courses: {Steak, Pasta}. Set SS has side dishes: {Fries, Salad}. The Cartesian product gives you all possible meal combinations.

The symbol for the Cartesian product is ×\times. Let's take set A={1,2}A = \{1, 2\} and set B={a,b,c}B = \{a, b, c\}. Their Cartesian product is:

A×B={(1,a),(1,b),(1,c),(2,a),(2,b),(2,c)}A \times B = \{(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)\}

The result is a set of ordered pairs. Unlike elements within a set, the order inside these pairs matters. The pair (1,a)(1, a) is different from (a,1)(a, 1). This concept is crucial for understanding relationships and functions in mathematics and computer science.

Set ASet BA × B (Cartesian Product)
1a(1, a)
b(1, b)
c(1, c)
2a(2, a)
b(2, b)
c(2, c)

Now that you have the basics of sets, let's test your knowledge.

Quiz Questions 1/5

What is the defining characteristic of a mathematical set?

Quiz Questions 2/5

Let A={1,3,5,7}A = \{1, 3, 5, 7\} and B={2,3,4,5}B = \{2, 3, 4, 5\}. What is the intersection of A and B, denoted ABA \cap B?

These building blocks, from simple collections to complex operations, form a language that helps describe the logical structures at the heart of computer science and mathematics.