Professional Documents
Culture Documents
• Sets
• Defining sets
• Set operations
• Types of sets
Recap: Types of Sets
• https://kahoot.it/
Overview
Preliminary
• Ordered pairs
• Cartesian product
Binary and n-ary relations
• Definitions
• Equality of relations
• Operations on relations
• Representing relations
• Properties of relations
Objectives
• Example: takes
course1
John
Helen
Jim Mary course2
course3
John takes course1, Jim takes course1, Mary takes course3, Helen takes course2
and course3
• sets of related objects <John, course1>
• order matters <John, course1> ≠ <course1, John>
Cartesian Product <Helen, course 1>
<Helen, course 2>
• S = {Helen, Jim, John, Mary} <Helen, course 3>
• C = {course1, course2, course 3} <Jim, course 1>
• 4 * 3 elements = 12 pairs <Jim, course 2>
<Jim, course 3>
<John, course 1>
<John, course 2>
<John, course 3>
< Mary, course 1>
<Mary, course 2>
<Mary, course 3>
Associations <Helen, course 1>
<Helen, course 2>
takes
<Helen, course 3>
course1
John <Jim, course 1>
Helen
Jim Mary course2 <Jim, course 2>
course3
<Jim, course 3>
<John, course 1>
• John takes course1 <John, course 2>
• Jim takes course1 <John, course 3>
• Mary takes course3 < Mary, course 1>
• Helen takes course2 and course3 <Mary, course 2>
<Mary, course 3>
Binary Relation: Definition
Binary relation is defined from one set to another (over 2 sets)
A x B = { <0, 0>, <0, 1>, <0, 2>, <0, 3>, <0, 4>,
<1, 0>, <1, 1>, <1, 2>, <1, 3>, <1, 4>,
<2, 0>, <2, 1>, <2, 2>, <2, 3>, <2, 4>,
<3, 0>, <3, 1>, <3, 2>, <3, 3>, <3, 4>}
Binary Relation: Exercise
• Let A = {0, 1, 2, 3} and B = {0, 1, 2, 3, 4}.
• A x B gives us a pool of possible answers
• 4 * 5 elements = 20 ordered pairs
• <a, b> = <a, a +1>
A x B = { <0, 0>, <0, 1>, <0, 2>, <0, 3>, <0, 4>,
<1, 0>, <1, 1>, <1, 2>, <1, 3>, <1, 4>,
<2, 0>, <2, 1>, <2, 2> ,<2, 3>, <2, 4>,
<3, 0>, <3, 1>, <3, 2>, <3, 3>, <3, 4>}
Thus, R = {<0, 1>, <1, 2>, <2, 3>, <3, 4>}. <a, b> R if b =a + 1
Equality of Binary Relations
Binary relations:
• R1 A1 x A2 and R2 B1 x B2
R1 = R2 if
• set {1, 2} = {a, b}, and
• {<1, 2> , <2, 2>} = {<a, b> , <b, b>}
Equality of Binary Relations
• R1 = {<1, 2> , <2, 2>} {1, 2} x {1, 2} ,
R2 = {<a, b> , <b, b>} {a, b} x {a, b} .
R1 = R2 if
• set {1, 2} = {a, b}, and
• {<1, 2> , <2, 2>} = {<a, b> , <b, b>}
So a = 1; and b = 2
Equality of Binary Relations: Exercise
I P Q =?
1 <3, 4> <3, 4> yes
2 <4, 5> <4, 5> yes
3 <5, 6> <5, 6> yes
Equality of Binary Relations: Exercise
John 65
41
Jim course 1
course 2 55
Helen
course 3 72
Mary
63
S C M
Cartesian Product of 3 Sets: Example
• S ={John, Jim, Helen, Mary}
• C = {course1, course2, course3}
• M = {65, 41, 55, 72, 63}
A x B x C = {<John,course1,65>,<John,course1,41>, <John,course1,55>,<John,course1,72>,<John,course1,63>,
<John,course2,65>,<John,course2,41>, <John,course2,55>,John,course2,72>,<John,course2,63>,
<John,course3,65>,John, course3,41>, <John,course3,55>,<John, course3,72>,<John,course3,63>,
<Jim,course1,65>,<Jim,course1,41>, <Jim,course1,55>,<Jim,course1,72>,<Jim,course1,63>,
<Jim,course2,65>,<Jim,course2,41>, <Jim,course2,55>,<Jim,course2,72>,<Jim,course2,63>,
<Jim,course3,65>,<Jim, course3,41>, <Jim,course3,55>,<Jim, course3,72>,<Jim,course3,63>,
<Helen,course1,65>,<Helen,course1,41>,<Helen,course1,55>, <Helen,course1,72>,<Helen,course1,63>,
<Helen,course2,65>,<Helen,course2,41>,<Helen,course2,55>, <Helen,course2,72>,<Helen,course2,63>,
<Helen,course3,65>,<Helen,course3,41>,<Helen,course3,55>, <Helen,course3,72>,<Helen,course3,63>,
<Mary,course1,65>,< Mary,course1,41>,<Mary,course1,55>, < Mary,course1,72>,<Mary,course1,63>,
<Mary,course2,65>,<Mary,course2,41>,<Mary,course2,55>, <Mary,course2,72>,<Mary,course2,63>,
<Mary,course3,65>,<Mary,course3,41>,<May,course3,55>, <Mary,course3,72>,<Mary,course3,63>}
n-ary Relation: Definition
• A binary relation involves 2 sets and can be described by a set of pairs
• A ternary relation involves 3 sets and can be described by a set of triples
• …
• An n-ary relation involves n sets and can be described by a set of n-tuples
A x A x A = { <0, 0, 0>, <0, 0, 1 >, <0, 0, 2>, <0, 0, 3>, <0, 0, 4>,
<0, 1, 0>, <0, 1, 1 >, <0, 1, 2>, <0, 1, 3>, <0, 1, 4>,
<0, 2, 0>, <0, 2, 1 >, <0, 2, 2>, <0, 2, 3>, <0, 2, 4>,
<0, 3, 0>, <0, 3, 1 >, <0, 3, 2>, <0, 3, 3>, <0, 3, 4>,
<0, 4, 0>, <0, 4, 1 >, <0, 4, 2>, <0, 4, 3>, <0, 4, 4>,…
<4, 4, 0>, <4, 4, 1>, <4, 4, 2>, <4, 4, 3>, <4, 4, 4>}
n-ary Relation: Example
• A = {0, 1, 2, 3, 4}; A x A x A gives us a pool of possible answers
• 5 * 5 * 5 elements = 125 ordered pairs <a, b, c> such that a <b < c
A x A x A = { <0, 0, 0>, <0, 0, 1 >, <0, 0, 2>, <0, 0, 3>, <0, 0, 4>,
<0, 1, 0>, <0, 1, 1 >, <0, 1, 2>, <0, 1, 3>, <0, 1, 4>,
<0, 2, 0>, <0, 2, 1 >, <0, 2, 2>, <0, 2, 3>, <0, 2, 4>,
<0, 3, 0>, <0, 3, 1 >, <0, 3, 2>, <0, 3, 3>, <0, 3, 4>,
<0, 4, 0>, <0, 4, 1 >, <0, 4, 2>, <0, 4, 3>, <0, 4, 4>,…
<4, 4, 0>, <4, 4, 1>, <4, 4, 2>, <4, 4, 3>, <4, 4, 4>}
R = {<0, 1, 2>, <0, 1, 3>, <0, 1, 4>, <0, 2, 3>, <0, 2, 4>, <0, 3, 4>,
<1, 2, 3>, <1, 2, 4>, <1, 3, 4>}
n-ary Relations: Equality
• n-ary relation R1 A1 x ... x An
• m-ary relation R2 B1 x ... x Bm
• R1 = R2 if
• m=n
• Ai = Bi for each i, 1 ≤ i ≤ n,
• R1 = R2 as a set of ordered n-tuples
n-ary Relations Equality: Example
• R1 and R2 on A x A x A, with A = {1, 2, 3}
• R1 = {<1, 2, 3>, <1, 2, 2>, <2, 2, 2>}
• R2 = {<2, 2, 2>, <1, 2, 3>, <1, 2, 2>}
• R1 = R2, because both sets contains the same 3 ordered n-tuples