Download Topic

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
Topic
• Sets (5.1, 5.2, 5.3)
1
Original author of the slides:
Vadim Bulitko
University of Alberta
http://www.cs.ualberta.ca/~bulitko/W04
Modified by T. Andrew Yang
([email protected])
2
Sneak-preview : Sets
• What is a set?
• A collection of elements:
–
–
–
–
Order is irrelevant
No repetitions
Can be infinite
Can be empty
• Examples:
{A, B, C}
{0,1,2,3,…}
N, Z, Q, R
3
Operations on sets
• S is a set
• Membership:
xS
x is an element of S
• Subset:
S1  S
Set S1 is a subset of set S
All elements of S1 are elements of S
S S
• Proper subset S1  S
4
Operations on sets
• S, S1 are sets
• Equality: S = S1
iff they have the same elements
• Difference: S - S1
is a set of all elements that belong to S but NOT to S1
{A,B,C} - {A,B,X,Y} = {C}
{A,B,X,Y} – {A,B,C} = {X,Y}
5
Operations on sets
• S, S1 are sets
• Intersection: S  S1
is a set of all elements that belong to both S and S1
{A,B,C}  {A,B,X,Y} = {A,B}
• Union: S  S1
is a set of all elements that belong to either S or S1
{A,B,C}  {A,B,X,Y} = {A,B,C,X,Y}
6
Interesting Properties of Sets
• S, S1 are sets
Then
S – S1 = S – (S  S1)
S = S1  S – S1 = Φ
(S  S1) – S1 = S – S1
• Use a Venn diagram to see more properties
S1  S  S1 - S = ?
S1  S  S1  S = ?
S1  S  S1  S = ?
(S1 – S)  (S - S1) = ?
Is S – (S1  S) = (S –S1)  S ?
Is (S  S1) – S1 = S  (S1 – S1) ?
7
More notation
• In mathematics, sets are often specified
with a predicate and an enveloping set as
follows:
S={xA | P(x)}
S is the set of all elements of A that satisfy
predicate P
• Example:
Q={xR | a,bZ b0 & x=a/b}
8
Set Equality
• Two sets are equal iff they have the same
elements
• Theorem: for any sets A and B, A=B iff
AB & BA
• Proof
9
Subset and Membership
• Book example 5.1.5
2{1,2,3}
{2}{1,2,3}
2{1,2,3}
{2}{1,2,3}
{2}{{1},{2}}
{2}{{1},{2}}
?
?
?
?
?
?
• Given a set A, the power set of A, P (A),
is the set of all subsets of A.
10
Universal Set
• If we are dealing with sets S1, S2, …, Sn which are all
subsets of a larger set U, then U is called the universal
set of S1, S2, …, Sn.
• All of S1, S2, …, Sn are subsets of U
• When does such a U exist?
Always, for we can set U to be the union of all sets involved
e.g., Given sets A, B, and C: U = A  B  C ...
e.g., A = all students taking math3331 in summer 2008, B = all
students taking csci3134 in summer 2008, C = all students
taking cinf3132 in summer 2008:
What could be the universal set (or the universe of discourse)?
Another example?
11
Complement
• So if I am dealing with set A which is a
subset of the universal set U then:
• I can define complement of A as:
AC = U - A
• That is the set of all elements (of U) that
are not in A
• Often “of U” is dropped and people say
that AC is the set of everything that is not
in A
12
Quick questions
• What is the complement of U?
UC = Ø
• What set has U as its complement?
ØC = U
13
Sets & Predicate Logic
• All of the set operations and relations
above can be defined in terms of Boolean
connectives:
AB={x | xA v xB}
AB={x | xA & xB}
A-B={x | xA & not xB}
AC={x | not xA}
A=B iff x xA  xB
AB iff x xA  xB
AB iff (x xA  xB) & not A=B
14
Symmetric Difference
• C=A  B
Set C is the symmetric difference of sets A
and B iff every element of C belongs to A
or B but not both
ABC [C=A  B 
a (aC  (aA xor aB))]
15
Examples
• A={1,2}, B={2,3}
• A  B={1,3}
• A={Clinton,Reagan}, B={Gorbachov,Bregnev}
• A  B={Clinton,Reagan,Gorbachov,Bregnev}
• A={CMPUT272 students}, B={CMPUT272 students}
• A  B = {}
• A  A = {}
16
Exercise 2
• Intersection of two sets is contained in their union:
AB [ (A  B)  (A  B) ]
• Proof:
17
Exercise 3
• Union is commutative
AB [ A  B = B  A ]
18
Exercise 4
• Intersection is commutative
AB [ A  B = B  A ]
• Proof: very similar to the one we just did.
Try it yourself.
19
Exercise 5
• Intersection distributes over union:
ABC [ A  (B  C) =(A  B)  (A  C) ]
• Note:
There is an analogy between logical operations v
and & and arithmetic operations:
v feels like +
& feels like *
So A & (B v C) = A & B v A & C
[just like A*(B+C) = A*B + A*C]
How about A+(B*C) --- is it (A+B)*(A+C)?
NO
So what about A v (B & C) = (A v B) & (A v C)?
20
The Analogy
• The analogy is incomplete:
– Arithmetic:
– Logic:
A+(B*C)  (A+B)*(A+C)
A v B&C = (A v B) & (A v C)
• Proof of the latter:
21
Exercise 6
• In Exercise #5 we proved:
ABC [ A  (B  C) =(A  B)  (A  C) ]
using the fact that A&(B v C)=A&B v A&C
• Given the statement just proved
A v B&C = (A v B) & (A v C)
• What can we now prove in terms of sets?
• Union distributes over intersection:
ABC [ A  (B  C) =(A  B)  (A  C) ]
22
Proof of Exercise 6
23
More Identities
• See Theorem 5.2.2 (set identities) in the
book, p.272
– An identity is an equation that is universally
true for all elements in some set.
• The proofs can often be done using:
– the logical definitions of set operations
– logical identities we have proven before
• Do some of them as an exercise
24
Boolean Algebra
• Are the similarities between set identities
and logical identities incidental?
• It turns out that both systems are
examples of a more general construct
called Boolean algebra
25
Boolean Algebra
• Boolean algebra is given by a set S and two operations: + and * defined
over it such that the following identities hold (here a and b are arbitrary
elements of S):
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)
• There exist distinct 0,1 in S:
a+0 = a
a*1 = a
• For each a from S there exists a complement a’ such that:
a+a’ = 1
a*a’ = 0
26
Boolean Algebra
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
S
+
*
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)
0
1
a+0=a
a*1=a
complement (a’)
a+a’=1
a*a’=0
Logic
{true,false}
v
&
avb=bva
a&b=b&a
(avb)vc=av(bvc)
(a&b)&c=a&(b&c)
a&(bvc)=(a&b)v(a&c)
av(b&c)=(avb) & (avc)
false
true
a v false = a
a & true = a
~a
a v ~a = true
a & ~a = false
Sets
P(U) (i.e., all sets)


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)
Ø
U
aØ=a
aU=a
aC
a  aC = U
a  aC = Ø
27
Questions?
28
Related documents