Download Introduction to Database Systems

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
Ch. 5 Sets (Review)
Today we will review sections 5.1, 5.2, 5.3
Instructor: Hayk Melikyan
[email protected]
Melikyan/DM/Fall09
1
What is a set?
A collection of elements:
Order is irrelevant
No repetitions
Can be infinite
Can be empty
Examples:
{Angela, Belinda, Jean}
{0,1,2,3,…}
Melikyan/DM/Fall09
2
Operations on sets
S is a set Membership:
xS
x is an element of S
Angela{Angela, Belinda, Jean}
Subset
S1  S
– Set S1 is a subset of set S
– All elements of S1 are elements of S
– {Angela,Belinda}  {Angela, Belinda, Jean}
Proper subset S1 S
Melikyan/DM/Fall09
3
Operations on sets
If S, S1 are sets
Intersection: S  S1
– is a set of all elements that belong to both
{Ang, Bel, Jea}  {Ang, Dan} = {Ang}
Union: S  S1
– is a set of all elements that belong to either
– {Ang, Bel, Jea}  {Ang, Dan} = {Ang, Bel, Jea, Dan}
Melikyan/DM/Fall09
4
Operations on sets
Let S, S1 be 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
{Ang, Bel, Jea} \ {Ang, Dan} = {Bel, Jea}
Melikyan/DM/Fall09
5
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}
Melikyan/DM/Fall09
6
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
Melikyan/DM/Fall09
7
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}}
?
?
?
?
?
?
How about set A such that {2} is a subset of it and
A is an element of it?
– A={1,2,{1},{2}}
Melikyan/DM/Fall09
8
Universal Set
If we are dealing with sets which are all subsets of
a larger set U then we call it a universal set U
All of your sets will be subsets of U
When does such a U exist?
Always, for we can set U to the union of all sets
involved ???????
Melikyan/DM/Fall09
9
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:
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
What is the complement of U?
What set has U as its complement?
Melikyan/DM/Fall09
UC = Ø
ØC=U
10
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
– AB
– AB
Melikyan/DM/Fall09
iff x( xA  xB)
iff x (xA  xB)
iff x (xA  xB) & not A=B
11
Symmetric Difference
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))]
If A={1,2}, B={2,3}
then A  B={1,3}
In general: A  A = {}
Melikyan/DM/Fall09
12
Exercise 2
Intersection of two sets is contained in their union:
AB [ (A  B)  (A  B) ]
Proof:
Melikyan/DM/Fall09
13
Exercise 3
Union is commutative
AB [ A  B = B  A ]
Intersection is commutative
AB [ A  B = B  A ]
Intersection distributes over union:
ABC [ A  (B  C) =(A  B)  (A  C) ]
Melikyan/DM/Fall09
14
Exercise
In Exercise #5 we proved:
– ABC [ A  (B  C) =(A  B)  (A  C) ]
using the fact that A&(BvC) = (A&B)v(A&C)
Given the statement just proved
Av(B&C) = (AvB) & (AvC)
what can we now prove in terms of sets?
Union distributes over intersection:
ABC [ A  (B  C) =(A  B)  (A  C) ]
Melikyan/DM/Fall09
15
Proof :
Melikyan/DM/Fall09
16
Logic
-
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)
Melikyan/DM/Fall09
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)
17
Cartesian Products
Intuition first:
Suppose I have a function that takes two numbers x
and y and returns x/y
What is the set of valid inputs?
Is it just R?
– No -- cannot divide by 0
Is it R\{0}?
– No -- can happily have 0 as x
Melikyan/DM/Fall09
18
Combinations
Suppose I have:
• two independent attributes:
sky conditions and temperature
two values for the sky conditions
S={sunny, overcast};
three values for the precipitation:
P={snow, rain, nothing}.
How many combinations can I have?
<sunny, rain> , <sunny, snow> . <sunny, nothing>.
<overcast, rain>. <overcast, snow>, <overcast, nothing>
Melikyan/DM/Fall09
19
Cartesian Product
Set C is a Cartesian Product of set A and set B iff it is a set of all
ordered pairs such that the 1st element belongs to A and the
2nd element belongs to B
C=A  B iff ab (<a, b>C  (aA & bB))]
Melikyan/DM/Fall09
20
Examples
A={0,1}, B={Ang, Bel}
AB = {<0,Ang>, <0,Bel>, <1,Ang>, <1, Bel>}
A={0,1}, B={Ang, Bel}
BA = {<Ang, 0>, <Bel, 0>, <Ang, 1>, <Bel,1>}
A={0}, B={a,b}, C={1,2}
ABC={<0, a, 1>,<0, b, 1>, <0, a, 2>,<0, b, 2>}
Melikyan/DM/Fall09
21
More examples
A=B=C=D=R (set of all real numbers)
ABCD=R4 (time-space continuum)
What is the cardinality of Cartesian Product?
|A1  …  An|=|A1| · … · |An| for finite sets
How about { }  {1,2}?
– {}  {1,2}={}
Melikyan/DM/Fall09
22
Related documents