Download Set Theory - NYU Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Discrete Mathematics
Lecture 5
Alexander Bukharovich
New York University
Basics of Set Theory
• Set and element are undefined notions in the set theory
and are taken for granted
• Set notation: {1, 2, 3}, {{1, 2}, {3}, {1, 2, 3}}, {1, 2,
3, …}, , {x  R | -3 < x < 6}
• Set A is called a subset of set B, written as A  B, when
x, x  A  x  B
• A is a proper subset of B, when A is a subset of B and
x  B and x  A
• Visual representation of the sets
• Distinction between  and 
Set Operations
• Set a equals set B, iff every element of set A is in
set B and vice versa
• Proof technique for showing sets equality
• Union of two sets is a set of all elements that
belong to at least one of the sets
• Intersection of two sets is a set of all elements that
belong to both sets
• Difference of two sets is a set of elements in one
set, but not the other
• Complement of a set is a difference between
universal set and a given set
Cartesian Products
• Ordered n-tuple is a set of ordered n
elements. Equality of n-tuples
• Cartesian product of n sets is a set of ntuples, where each element in the n-tuple
belongs to the respective set participating in
the product
Formal Languages
• Alphabet : set of characters used to construct
strings
• String over alphabet : either empty string of ntuple of elements from , for any n
• Length of a string is value n
• Language is a subset of all strings over 
• n is a set of strings with length n over 
• * is a set of all strings of finite length over 
• Notation for arithmetic expressions: prefix, infix,
postfix
Subset Check Algorithm
• Let two sets be represented as arrays A and B
m = size of A, n = size of B
i = 1, answer = “yes”;
while (i  m && answer == “yes”) {
j = 1, found = “no”;
while (j  n && found == “no”) {
if (a[i] == b[j]) found = “yes”;
j++;
}
if (found == “no”) answer = “no”;
i++;
}
Set Properties
• Inclusion of Intersection:
– A  B  A and A  B  B
• Inclusion in Union:
– A  A  B and B  A  B
• Transitivity of Inclusion:
– (A  B  B  C)  A  C
• Set Definitions:
–
–
–
–
–
xXYxXyY
xXYxXyY
xX–YxXyY
x  Xc  x  X
(x, y)  X  Y  x  X  y  Y
Set Identities
• Commutative Laws: A  B = A  B and A  B = B  A
• Associative Laws: (A  B)  C = A  (B  C) and (A  B)  C = A  (B  C)
• Distributive Laws:
A  (B  C) = (A  B)  (A  C) and A  (B  C) = (A  B)  (A  C)
• Intersection and Union with universal set: A  U = A and A  U = U
• Double Complement Law: (Ac)c = A
• Idempotent Laws: A  A = A and A  A = A
• De Morgan’s Laws: (A  B)c = Ac  Bc and (A  B)c = Ac  Bc
• Absorption Laws: A  (A  B) = A and A  (A  B) = A
• Alternate Representation for Difference: A – B = A  Bc
• Intersection and Union with a subset: if A  B, then A  B = A and A  B = B
Exercises
•
•
•
•
Is is true that (A – B)  (B – C) = A – C?
Show that (A  B) – C = (A – C)  (B – C)
Is it true that A – (B – C) = (A – B) – C?
Is it true that (A – B)  (A  B) = A?
Empty Set
•
•
•
•
•
•
S = {x  R, x2 = -1}
X = {1, 3}, Y = {2, 4}, C = X  Y
Empty set has no elements 
Empty set is a subset of any set
There is exactly one empty set
Properties of empty set:
– A   = A, A   = 
– A  Ac = , A  Ac = U
– Uc = , c = U
Set Partitioning
• Two sets are called disjoint if they have no
elements in common
• Theorem: A – B and B are disjoint
• A collection of sets A1, A2, …, An is called
mutually disjoint when any pair of sets from this
collection is disjoint
• A collection of non-empty sets {A1, A2, …, An} is
called a partition of a set A when the union of
these sets is A and this collection consists of
mutually disjoint sets
Power Set
• Power set of A is the set of all subsets of A
• Theorem: if A  B, then P(A)  P(B)
• Theorem: If set X has n elements, then P(X)
has 2n elements
Boolean Algebra
• Boolean Algebra is a set of elements together
with two operations denoted as + and * and
satisfying the following properties:
a + b = b + a, a * b = b * a
(a + b) + c = a + (b + c), (a * b) *c = a * (b * c)
a + (b * c) = (a + b) * (a + c), a * (b + c) = (a * b) + (a * c)
a + 0 = a, a * 1 = a for some distinct unique 0 and 1
a + ã = 1, a * ã = 0
Exercises
•
•
•
•
•
•
Simplify: A  ((B  Ac)  Bc)
Symmetric Difference: A  B = (A – B)  (B – A)
Show that symmetric difference is associative
Are A – B and B – C necessarily disjoint?
Are A – B and C – B necessarily disjoint?
Let S = {2, 3, …, n}. For each Si  S, let Pi be the
product of elements in Si. Show that:
Pi = (n + 1)! / 2 – 1
Russell’s Paradox
•
•
•
•
Set of all integers, set of all abstract ideas
Consider S = {A, A is a set and A  A}
Is S an element of S?
Barber puzzle: a male barber shaves all
those men who do not shave themselves.
Does the barber shave himself?
• Consider S = {A  U, A  A}. Is S  S?
Halting Problem
• There is no computer algorithm that will
accept any algorithm X and data set D as
input and then will output “halts” or “loops
forever” to indicate whether X terminates in
a finite number of steps when X is run with
data set D.
Related documents