Set Theory
Overview
A set is basically a grouping of unique (ie. no duplicate) things (called members, or elements)
- ex. numbers, fruit, other sets, functions.
- ex. The deck of cards is a set, whose elements are the cards
Sets can be finite or infinite. For example, {1, 2, 5, 6} is a finite set. The set of all the natural numbers is an infinite set.
ordering and duplication of elements is irrelevant
- ex. and represent the same set.
Sets correspond to general.lang.types (Private) in programming languages very well. For example:
- number type can be looked at as a set of all possible numbers
- string type is a set of all possible strings
'a' | 'b' | 'c'
type corresponds to the{'a', 'b', 'c'}
set- null type is a singleton type with only one element, the null value (which happens to have the same name)
- undefined type is a singleton type with only one element, the undefined value (which happens to have the same name)
If is a set and is an element of , we write
The number of elements of a set is denoted by .
- ex. a set with 7 elements can be written: = 7; and its elements can be listed like so:
- here, we say "set has a cardinality of 7"
We can specify a set by a property that filters out some elements from a large universe (e.g. out of all real numbers, integers that are greater than 0)
- ex. , which means " is part of the set of integers and is also greater than ".
Predetermined sets
For mathematics, various sets of numbers are important:
- the set of real numbers, denoted by ;
- the set of rational numbers, denoted by ;
- the set of integers, denote by ;
- the set of non-negative integers, denoted by ;
- the set of positive integers (ie. natural numbers), denoted by .
- the empty set, the set with no elements is another important (although not very interesting) set; it is denoted by .
Operations
In set theory, union and intersection are names of operations on sets.
- ex. The union of two sets is a set that contains all elements that appear in either set (ie. if the element appears in either set, then it's part of the union set).
- ex. The intersection of two sets is a set that only contains elements that are present in both sets.
Subset ()
Set is called a subset of a set if every element of is also an element of .
- denoted .
the empty set () is a subset of every set, and among the predetermined sets (above), we can say:
The number of subsets in a set is a power of 2: if the set has elements, the result is
- ex. with a set with 2 elements , we can have 4 subsets(): , , ,
- ex. with a set with 3 elements , we can have 8 subsets(): , , , , , , ,
We read this figure as follows. We want to select a subset called S. We start from the circle on the top (called a node). The node contains a question: is a1 an element of S? The two arrows going out of this node are labeled with the two possible answers to this question (Yes and No). We make a decision and follow the appropriate arrow (also called an edge) to the the node at the other end. This node contains the next question: is a2 an element of S? Follow the arrow corresponding to your answer to the next node, which contains the third (and in this case last) question you have to answer to determine the subset: is a3 an element of S? Giving an answer and following the appropriate arrow we get to a node, which contains a listing of the elements of S. Thus to select a subset corresponds to walking down this diagram from the top to the bottom. There are just as many subsets of our set as there are nodes on the last level.