Set Theory - Definitions - Computer Science

Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Theory
Definitions
E. Wenderholm
Department of Computer Science
SUNY Oswego
c 2016 Elaine Wenderholm All rights Reserved
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Outline
1
2
3
4
5
6
Definition
Denotation
Operations
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Special Sets
Set Operations that Create New Sets
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Tuples
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Definition
A Set is a collection of entities (things).
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Definition
A Set is a collection of entities (things).
The entities in a set are called its members, or elements.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Definition
A Set is a collection of entities (things).
The entities in a set are called its members, or elements.
Example: A set can be a collection of 4 letters.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Multiset Definition
A Set that contains duplicate elements.
We use multisets only if we want to keep multiple instances of
of identical elements in the set.
Example: {1, 3, 5, 5, 7} is a multiset.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Multiset Definition
A Set that contains duplicate elements.
We use multisets only if we want to keep multiple instances of
of identical elements in the set.
Example: {1, 3, 5, 5, 7} is a multiset.
If we have a multiset, and want to view it as a set, we simply
ignore the duplicate elements.
Example: {1, 3, 5, 5, 7} =
6 {1, 3, 5, 7} as multisets, but they are
equal as sets.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Multiset Definition
A Set that contains duplicate elements.
We use multisets only if we want to keep multiple instances of
of identical elements in the set.
Example: {1, 3, 5, 5, 7} is a multiset.
If we have a multiset, and want to view it as a set, we simply
ignore the duplicate elements.
Example: {1, 3, 5, 5, 7} =
6 {1, 3, 5, 7} as multisets, but they are
equal as sets.
We will only use sets in this class. If we generate a multiset,
we will rewrite it as a set.
Example: {20, 20} becomes {20}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Multiset Definition
A Set that contains duplicate elements.
We use multisets only if we want to keep multiple instances of
of identical elements in the set.
Example: {1, 3, 5, 5, 7} is a multiset.
If we have a multiset, and want to view it as a set, we simply
ignore the duplicate elements.
Example: {1, 3, 5, 5, 7} =
6 {1, 3, 5, 7} as multisets, but they are
equal as sets.
We will only use sets in this class. If we generate a multiset,
we will rewrite it as a set.
Example: {20, 20} becomes {20}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Denotation
How do we define the elements in a set?
A set has a name. By convention we use an upper-case letter.
S=
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Denotation
How do we define the elements in a set?
A set has a name. By convention we use an upper-case letter.
S=
“Curly braces”, { and }, are used to delimit the elements.
S ={
}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Denotation
How do we define the elements in a set?
A set has a name. By convention we use an upper-case letter.
S=
“Curly braces”, { and }, are used to delimit the elements.
S ={
}
The elements are listed, separated by commas (for a finite
set).
S = {a, b, c, d}
This statement says that a set named S contains the letters a,
b, c, and d.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Denotation
How do we define the elements in a set?
A set has a name. By convention we use an upper-case letter.
S=
“Curly braces”, { and }, are used to delimit the elements.
S ={
}
The elements are listed, separated by commas (for a finite
set).
S = {a, b, c, d}
This statement says that a set named S contains the letters a,
b, c, and d.
A set may also be drawn as a picture, known as a Venn
Diagram.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Venn Diagrams
A Venn Diagram provides a visual depiction of sets and set
operations.
Here is a web link for learning about Venn Diagrams.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Denotation
Implicit definitions of sets
We use an Ellipsis (a comma and three dots) to denote
“missing” elements in a set when the number of elements is
too numerous to list. The reader fills in the blanks.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Denotation
Implicit definitions of sets
We use an Ellipsis (a comma and three dots) to denote
“missing” elements in a set when the number of elements is
too numerous to list. The reader fills in the blanks.
Here is the set of the natural (counting) numbers
N = {1, 2, 3, . . .}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Denotation
Implicit definitions of sets
We use an Ellipsis (a comma and three dots) to denote
“missing” elements in a set when the number of elements is
too numerous to list. The reader fills in the blanks.
Here is the set of the natural (counting) numbers
N = {1, 2, 3, . . .}
and the integers
Z = {. . . , −2, −1, 0, 1, 2, . . .}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Denotation
Implicit definitions of sets
We use an Ellipsis (a comma and three dots) to denote
“missing” elements in a set when the number of elements is
too numerous to list. The reader fills in the blanks.
Here is the set of the natural (counting) numbers
N = {1, 2, 3, . . .}
and the integers
Z = {. . . , −2, −1, 0, 1, 2, . . .}
Notice we do not use this notation for R, the Real numbers.
Ellipsis are shorthand for finite sets
C = {2, 4, 6, . . . , 100}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Using rules to define the elements of a set
A rule is some property that is true for all the elements in
the set.
S = {n | a rule about n}
n is a “variable name”, sort of like a formal parameter. It is
used to refer to all the elements in the set.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Using rules to define the elements of a set
A rule is some property that is true for all the elements in
the set.
S = {n | a rule about n}
n is a “variable name”, sort of like a formal parameter. It is
used to refer to all the elements in the set.
The notation “P(x)” is often used, meaning “some property
of x”
S = {n | P(n)}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Using rules to define the elements of a set
A rule is some property that is true for all the elements in
the set.
S = {n | a rule about n}
n is a “variable name”, sort of like a formal parameter. It is
used to refer to all the elements in the set.
The notation “P(x)” is often used, meaning “some property
of x”
S = {n | P(n)}
Example: E = {n|n = 2 × m, m ∈ N }
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Using rules to define the elements of a set
A rule is some property that is true for all the elements in
the set.
S = {n | a rule about n}
n is a “variable name”, sort of like a formal parameter. It is
used to refer to all the elements in the set.
The notation “P(x)” is often used, meaning “some property
of x”
S = {n | P(n)}
Example: E = {n|n = 2 × m, m ∈ N }
We read “E = {n | ” as
“E is the set of all elements n, where”
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Using rules to define the elements of a set
A rule is some property that is true for all the elements in
the set.
S = {n | a rule about n}
n is a “variable name”, sort of like a formal parameter. It is
used to refer to all the elements in the set.
The notation “P(x)” is often used, meaning “some property
of x”
S = {n | P(n)}
Example: E = {n|n = 2 × m, m ∈ N }
We read “E = {n | ” as
“E is the set of all elements n, where”
n and m are variable names (like in a “for” statement) and
are used to refer to elements in the set.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Operations, Operators, Operands
What ARE these??
Example: 3 + 5
operation : addition
operator (symbol) : +
operands : 3 and 5; left operand 3, right operand 5.
operator type : binary (2 operands) and infix (written
in-between the operands)
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Operations, Operators, Operands
What ARE these??
Example: 3 + 5
operation : addition
operator (symbol) : +
operands : 3 and 5; left operand 3, right operand 5.
operator type : binary (2 operands) and infix (written
in-between the operands)
Example: −45 “-” operator is the prefix (unary) minus
operator.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Operations, Operators, Operands
What ARE these??
Example: 3 + 5
operation : addition
operator (symbol) : +
operands : 3 and 5; left operand 3, right operand 5.
operator type : binary (2 operands) and infix (written
in-between the operands)
Example: −45 “-” operator is the prefix (unary) minus
operator.
Any arithmetic expression can be written in postfix notation.
The benefit: parentheses are NOT needed! Postfix was used
in the first HP calculators (They didn’t have parentheses.)
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Basic Operations on Sets
Set Equality and Set Membership
Set Equality.
Two sets S and T are equal, S = T if and only if they contain
the same elements. Otherwise they are unequal, S 6= T .
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Basic Operations on Sets
Set Equality and Set Membership
Set Equality.
Two sets S and T are equal, S = T if and only if they contain
the same elements. Otherwise they are unequal, S 6= T .
Set Membership.
p is a member of (an element of) a set S (or, that set S
contains p) is denoted p ∈ S.
p is not an element of S is denoted p 6∈ S.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Basic Operations on Sets
Set Equality and Set Membership
Set Equality.
Two sets S and T are equal, S = T if and only if they contain
the same elements. Otherwise they are unequal, S 6= T .
Set Membership.
p is a member of (an element of) a set S (or, that set S
contains p) is denoted p ∈ S.
p is not an element of S is denoted p 6∈ S.
Notice that ∈ is a infix operator. The left operand is of type
element. The right operand is of type set.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Some Properties of Sets
The order of elements in a set is unimportant.
{a, b, c, d} = {d, a, b, c}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Some Properties of Sets
The order of elements in a set is unimportant.
{a, b, c, d} = {d, a, b, c}
We can define (or test) sets for equality or inequality.
{a, b} =
6 {b}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Some Properties of Sets
The order of elements in a set is unimportant.
{a, b, c, d} = {d, a, b, c}
We can define (or test) sets for equality or inequality.
{a, b} =
6 {b}
We can define (or test) for membership with the ∈ operator
4 ∈ {2, 4, 6, 8}
1 6∈ {a, b}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Some Properties of Sets
The order of elements in a set is unimportant.
{a, b, c, d} = {d, a, b, c}
We can define (or test) sets for equality or inequality.
{a, b} =
6 {b}
We can define (or test) for membership with the ∈ operator
4 ∈ {2, 4, 6, 8}
1 6∈ {a, b}
The elements of a set need not be the same “type”, but they
often are.
T = {1, sally , red, r }
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Some Properties of Sets
The order of elements in a set is unimportant.
{a, b, c, d} = {d, a, b, c}
We can define (or test) sets for equality or inequality.
{a, b} =
6 {b}
We can define (or test) for membership with the ∈ operator
4 ∈ {2, 4, 6, 8}
1 6∈ {a, b}
The elements of a set need not be the same “type”, but they
often are.
T = {1, sally , red, r }
We can count the number of elements in a finite set. It is
denoted with vertical bars | |
|S |=4
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Some Properties of Sets
The order of elements in a set is unimportant.
{a, b, c, d} = {d, a, b, c}
We can define (or test) sets for equality or inequality.
{a, b} =
6 {b}
We can define (or test) for membership with the ∈ operator
4 ∈ {2, 4, 6, 8}
1 6∈ {a, b}
The elements of a set need not be the same “type”, but they
often are.
T = {1, sally , red, r }
We can count the number of elements in a finite set. It is
denoted with vertical bars | |
|S |=4
A set may be an element of (a member of) another set!
{1, {sam, july }, {{ocean}}}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Subset Operator
Assume we have two sets A and B.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Subset Operator
Assume we have two sets A and B.
We say that A is a subset of B, written as A ⊆ B, if every
member of A is also a member of B.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Subset Operator
Assume we have two sets A and B.
We say that A is a subset of B, written as A ⊆ B, if every
member of A is also a member of B.
We can also write this as A ⊆ B ≡ {a | a ∈ A → a ∈ B}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
What are operations?
Set Equality and Set Membership
Testing Set Properties
Subsets
Subset Operator
Assume we have two sets A and B.
We say that A is a subset of B, written as A ⊆ B, if every
member of A is also a member of B.
We can also write this as A ⊆ B ≡ {a | a ∈ A → a ∈ B}
A is a proper subset of B, written A ⊂ B, if A ⊆ B and
A 6= B.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
The Empty Set
contains no elements
The empty set is a unique set.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
The Empty Set
contains no elements
The empty set is a unique set.
The empty set contains no elements.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
The Empty Set
contains no elements
The empty set is a unique set.
The empty set contains no elements.
The empty set is denoted ∅, or sometimes as {}.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
The Empty Set
contains no elements
The empty set is a unique set.
The empty set contains no elements.
The empty set is denoted ∅, or sometimes as {}.
|∅|=0
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
The Universal Set
The Universal Set U is a set that contains all elements.
This set is often called the Domain of Discourse.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
Creating new sets from existing sets
A ∪ B, A union B (all the elements)
A ∪ B = {x | x ∈ A or x ∈ B}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
Creating new sets from existing sets
A ∪ B, A union B (all the elements)
A ∪ B = {x | x ∈ A or x ∈ B}
A ∩ B, A intersect B (only the elements in common)
A ∩ B = {y | y ∈ A and y ∈ B}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
Creating new sets from existing sets
A ∪ B, A union B (all the elements)
A ∪ B = {x | x ∈ A or x ∈ B}
A ∩ B, A intersect B (only the elements in common)
A ∩ B = {y | y ∈ A and y ∈ B}
A, complement of A (with respect to some Universe A ⊆ U)
A = {z k z 6∈ A and z ∈ U}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
The Power Set of a Set
The Power Set of a finite set A consists of all the subsets of
A.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
The Power Set of a Set
The Power Set of a finite set A consists of all the subsets of
A.
It is denoted as either P(A) or 2A
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
The Power Set of a Set
The Power Set of a finite set A consists of all the subsets of
A.
It is denoted as either P(A) or 2A
P(A) = {S | S ⊆ A}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
The Power Set of a Set
The Power Set of a finite set A consists of all the subsets of
A.
It is denoted as either P(A) or 2A
P(A) = {S | S ⊆ A}
Example : B = {a, b, c}
P(B) = {∅, {a}, {b}, {c}, {a, b}, {b, c}, {a, c}, B}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
The Power Set of a Set
The Power Set of a finite set A consists of all the subsets of
A.
It is denoted as either P(A) or 2A
P(A) = {S | S ⊆ A}
Example : B = {a, b, c}
P(B) = {∅, {a}, {b}, {c}, {a, b}, {b, c}, {a, c}, B}
The empty set and the set itself are always elements of the
power set, and so |P(A)| = 2|A| (A is finite).
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
Cartesian Product of 2 Sets
Cartesian product of two sets, A and B, written as A × B, is
the set of all ordered pairs (a, b), where the first element a is
from set A, and the second element b is from the set B.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
Cartesian Product of 2 Sets
Cartesian product of two sets, A and B, written as A × B, is
the set of all ordered pairs (a, b), where the first element a is
from set A, and the second element b is from the set B.
The Cartesian product is also called the cross product.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
Cartesian Product of 2 Sets
Cartesian product of two sets, A and B, written as A × B, is
the set of all ordered pairs (a, b), where the first element a is
from set A, and the second element b is from the set B.
The Cartesian product is also called the cross product.
Question: How would you write this definition using formal set
notation?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Operations
Cartesian Product of 2 Sets
Cartesian product of two sets, A and B, written as A × B, is
the set of all ordered pairs (a, b), where the first element a is
from set A, and the second element b is from the set B.
The Cartesian product is also called the cross product.
Question: How would you write this definition using formal set
notation? Answer: A × B = {(a, b) | a ∈ A, b ∈ B}
Example: A = {4, 5}, B = {x, y , z}
A × B = {(4, x), (4, y ), (4, z), (5, x), (5, y ), (5, z)}
Why do you think it’s called “Cartesian”?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Partition
Example
S is a deck (a set) of playing cards.
How many different ways can they be sorted into “piles” (or
“bins”)?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Partition
Example
S is a deck (a set) of playing cards.
How many different ways can they be sorted into “piles” (or
“bins”)?
Whare are the properties of these bins, regardless of how we
sort the cards?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Partition
Example
S is a deck (a set) of playing cards.
How many different ways can they be sorted into “piles” (or
“bins”)?
Whare are the properties of these bins, regardless of how we
sort the cards?
We have a certain number (≥ 1) of bins. The elements in
each bin all share the same common property.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Partition
Example
S is a deck (a set) of playing cards.
How many different ways can they be sorted into “piles” (or
“bins”)?
Whare are the properties of these bins, regardless of how we
sort the cards?
We have a certain number (≥ 1) of bins. The elements in
each bin all share the same common property.
Each bin is a subset of the original deck.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Partition
Example
S is a deck (a set) of playing cards.
How many different ways can they be sorted into “piles” (or
“bins”)?
Whare are the properties of these bins, regardless of how we
sort the cards?
We have a certain number (≥ 1) of bins. The elements in
each bin all share the same common property.
Each bin is a subset of the original deck.
No card can be in more than one bin.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Partition
Example
S is a deck (a set) of playing cards.
How many different ways can they be sorted into “piles” (or
“bins”)?
Whare are the properties of these bins, regardless of how we
sort the cards?
We have a certain number (≥ 1) of bins. The elements in
each bin all share the same common property.
Each bin is a subset of the original deck.
No card can be in more than one bin.
No cards get left out of the sort.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Set Union, Intersection, Complement
Power Set
Cartesian Product
Partition of a Set
Set Partition
Definition
A is a nonempty set. Π(A) is called a partition A1 , A2 . . . An of A,
provided each of the following is true:
i.) Ai 6= ∅, 1 ≤ i ≤ n (all subsets are nonempty)
ii.) Ai ∩ Aj = ∅, 1 ≤ i 6= j ≤ n (all subsets are disjoint)
S
iii.) ni=1 Ai = A (no elements from A are left out)
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Sequences: just like in programming
A sequence of entities is a list of these entities in some order.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Sequences: just like in programming
A sequence of entities is a list of these entities in some order.
The sequence of numbers 7, 85, 22 is typically written by
enclosing the sequence in parentheses: (7, 85, 22)
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Sequences: just like in programming
A sequence of entities is a list of these entities in some order.
The sequence of numbers 7, 85, 22 is typically written by
enclosing the sequence in parentheses: (7, 85, 22)
Order matters in a sequence (7, 85, 22) 6= (22, 7, 85)
but not in a set!
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Sequences: just like in programming
A sequence of entities is a list of these entities in some order.
The sequence of numbers 7, 85, 22 is typically written by
enclosing the sequence in parentheses: (7, 85, 22)
Order matters in a sequence (7, 85, 22) 6= (22, 7, 85)
but not in a set!
Where have you used parentheses before?
arguments to functions
formal and actual parameters in programming languages
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Tuples: a way to refer to sequences
A sequence may be finite or infinite (just like sets).
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Tuples: a way to refer to sequences
A sequence may be finite or infinite (just like sets).
A finite sequence is called a tuple.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Tuples: a way to refer to sequences
A sequence may be finite or infinite (just like sets).
A finite sequence is called a tuple.
A finite sequence with k elements is called a k-tuple.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Tuples: a way to refer to sequences
A sequence may be finite or infinite (just like sets).
A finite sequence is called a tuple.
A finite sequence with k elements is called a k-tuple.
An ordered pair is actually a 2-tuple.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Tuples: a way to refer to sequences
A sequence may be finite or infinite (just like sets).
A finite sequence is called a tuple.
A finite sequence with k elements is called a k-tuple.
An ordered pair is actually a 2-tuple.
Example: (a, b, c, d) is a 4-tuple.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Operations on more than two sets.
Superscripts on set names can simplify the same operation on
many (more than 2) sets.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Operations on more than two sets.
Superscripts on set names can simplify the same operation on
many (more than 2) sets.
Use superscript to indicate the “number of times”
k times
z
}|
{
Cartesian product: A × A × . . . × A= Ak
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Operations on more than two sets.
Superscripts on set names can simplify the same operation on
many (more than 2) sets.
Use superscript to indicate the “number of times”
k times
z
}|
{
Cartesian product: A × A × . . . × A= Ak
Same operation on different sets. Give sets the same name
and add subscripts.
Sets S1 , S2 , . . . , Sn
Sn
S = S1 ∪ S2 ∪ . . . ∪ Sn is abbreviated as S = i=1 Si
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Sequences and Tuples
Operations on more than two sets.
Superscripts on set names can simplify the same operation on
many (more than 2) sets.
Use superscript to indicate the “number of times”
k times
z
}|
{
Cartesian product: A × A × . . . × A= Ak
Same operation on different sets. Give sets the same name
and add subscripts.
Sets S1 , S2 , . . . , Sn
Sn
S = S1 ∪ S2 ∪ . . . ∪ Sn is abbreviated as S = i=1 Si
Lower limit doesn’t have to be 1, upper limit doesn’t have to
be “n” it can be finite number, say 12, or infinite, ∞.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
DeMorgan’s Laws
In Set Theory
A and B are sets.
A∪B =A∩B
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
DeMorgan’s Laws
In Set Theory
A and B are sets.
A∪B =A∩B
A∩B =A∪B
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
DeMorgan’s Laws
In Set Theory
A and B are sets.
A∪B =A∩B
A∩B =A∪B
The same rules apply to programming! ∪ is logical “or”, and
∩ is logical “and”.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
DeMorgan’s Laws
In Set Theory
A and B are sets.
A∪B =A∩B
A∩B =A∪B
The same rules apply to programming! ∪ is logical “or”, and
∩ is logical “and”.
How we can show this using Venn Diagrams?...
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 1
{1} = 1 ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 1
{1} = 1 ? false
| {1, {sam, july }, {{ocean}}} | = ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 1
{1} = 1 ? false
| {1, {sam, july }, {{ocean}}} | = ? 3
| {∅} | = ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 1
{1} = 1 ? false
| {1, {sam, july }, {{ocean}}} | = ? 3
| {∅} | = ? 1
3 ∈ {1, {3}, {{5}}} ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 1
{1} = 1 ? false
| {1, {sam, july }, {{ocean}}} | = ? 3
| {∅} | = ? 1
3 ∈ {1, {3}, {{5}}} ? false
{3} ∈ {1, {3}, {{5}}}
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 1
{1} = 1 ? false
| {1, {sam, july }, {{ocean}}} | = ? 3
| {∅} | = ? 1
3 ∈ {1, {3}, {{5}}} ? false
{3} ∈ {1, {3}, {{5}}} true
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 2
What are the elements of S = {i | 5 ≤ i ≤ 20} ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 2
What are the elements of S = {i | 5 ≤ i ≤ 20} ?
{5, 6, . . . , 19, 20}
S = {a, b} ⊂ {a, b} ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 2
What are the elements of S = {i | 5 ≤ i ≤ 20} ?
{5, 6, . . . , 19, 20}
S = {a, b} ⊂ {a, b} ? false
b ⊆ {b} ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 2
What are the elements of S = {i | 5 ≤ i ≤ 20} ?
{5, 6, . . . , 19, 20}
S = {a, b} ⊂ {a, b} ? false
b ⊆ {b} ? false
For any set S, ∅ ⊆ S ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 2
What are the elements of S = {i | 5 ≤ i ≤ 20} ?
{5, 6, . . . , 19, 20}
S = {a, b} ⊂ {a, b} ? false
b ⊆ {b} ? false
For any set S, ∅ ⊆ S ? true (!!!)
∅ ⊂ P(∅) ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 2
What are the elements of S = {i | 5 ≤ i ≤ 20} ?
{5, 6, . . . , 19, 20}
S = {a, b} ⊂ {a, b} ? false
b ⊆ {b} ? false
For any set S, ∅ ⊆ S ? true (!!!)
∅ ⊂ P(∅) ? true
P(∅) = ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 2
What are the elements of S = {i | 5 ≤ i ≤ 20} ?
{5, 6, . . . , 19, 20}
S = {a, b} ⊂ {a, b} ? false
b ⊆ {b} ? false
For any set S, ∅ ⊆ S ? true (!!!)
∅ ⊂ P(∅) ? true
P(∅) = ? ...answer...?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 3
Let A = {1, 2} and B = {3, 4}. Does A × B = B × A ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 3
Let A = {1, 2} and B = {3, 4}. Does A × B = B × A ? no
How S
many sets are operated on?
T = 1≤i≤20 Si
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 3
Let A = {1, 2} and B = {3, 4}. Does A × B = B × A ? no
How S
many sets are operated on?
T = 1≤i≤20 Si 20
S
If we define U = j=20
j=1 Sj , does T = U ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Your turn.
Answer these, Part 3
Let A = {1, 2} and B = {3, 4}. Does A × B = B × A ? no
How S
many sets are operated on?
T = 1≤i≤20 Si 20
S
If we define U = j=20
j=1 Sj , does T = U ? yes
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Same Operations, Different Viewpoint
A and B are sets, p and q are propositions, and x and y are
boolean variables.
Set Theory
Logic
Software
Hardware
A ∪ B (union)
p ∨ q (or)
x || y (or)
p + q (or)
A ∩ B (intersection) p ∧ q (and) x && y (and) p · q (and)
A (complement)
¬p (not)
!x (not)
p (not)
Note: in h/w, p · q is typically written as pq.
Why do we have the same operator names in Logic and Software and
(digital) Hardware ?
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Same Operations, Different Viewpoint
A and B are sets, p and q are propositions, and x and y are
boolean variables.
Set Theory
Logic
Software
Hardware
A ∪ B (union)
p ∨ q (or)
x || y (or)
p + q (or)
A ∩ B (intersection) p ∧ q (and) x && y (and) p · q (and)
A (complement)
¬p (not)
!x (not)
p (not)
Note: in h/w, p · q is typically written as pq.
Why do we have the same operator names in Logic and Software and
(digital) Hardware ?
Because they are equivalent. All are derived from Set Theory. It just
depends on your point of view.
E. Wenderholm
Set Theory
Definition
Denotation
Operations
Special Sets
Set Operations that Create New Sets
Tuples
DeMorgan’s Laws
Your Turn
Same Operations, Different Viewpoint
A and B are sets, p and q are propositions, and x and y are
boolean variables.
Set Theory
Logic
Software
Hardware
A ∪ B (union)
p ∨ q (or)
x || y (or)
p + q (or)
A ∩ B (intersection) p ∧ q (and) x && y (and) p · q (and)
A (complement)
¬p (not)
!x (not)
p (not)
Note: in h/w, p · q is typically written as pq.
Why do we have the same operator names in Logic and Software and
(digital) Hardware ?
Because they are equivalent. All are derived from Set Theory. It just
depends on your point of view. Specifically, hardware and software are
equivalent. (Embedded) systems engineers decide what to implement in
hardware and in software. It’s a design tradeoff.
E. Wenderholm
Set Theory