Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 58

Chapter 1.

Logic and proofs 1

Chapter 2:Relations
Sets Section
Chapter 2: Relations
1. Logic and proofs 2

Definition 1: A set is an unordered collection of distinct objects, called elements


or members of the set. A set is said to contain its elements. We write to denote
that a is an element of the set A. The notation denotes that a is not an element of
the set A.
 It is common for sets to be denoted using uppercase letters, and lowercase letters
are usually used to denote elements of sets.
Describing a set: Roster Method Section
Chapter 2: Relations
1. Logic and proofs 3

 The way to describe a set:roster method:all members are listed between braces.
S = {a,b,c,d}
 Order not important
S = {a,b,c,d}={b,c,a,d}
 Each distinct object is either a member or not; listing more than once does not change the set.
S = {a,b,c,d} = {a,b,c,b,c,d}
 Elipses (…) may be used to describe a set without listing all of the members when the pattern
is clear.
 S = {a,b,c,d, ……,z }
 Set of all positive integers less than 100:S = {1,2,3,……..,99}
 Set of all integers less than 0:
S = {…., -3,-2,-1}
Some important sets Section
Chapter 2: Relations
1. Logic and proofs 4

N = {0,1,2,3….}, the set of all natural numbers


Z = {…,-3,-2,-1,0,1,2,3,…}, the set of integers
Z⁺ = {1,2,3,…..}, the set of all positive integers
R = set of all real numbers
R+ = set of all positive real numbers
C = set of all complex numbers.
Q = set of all rational numbers
Describing a set: set build notation Section
Chapter 2: Relations
1. Logic and proofs 5

Specify the property or properties that all members must satisfy.


the genral form of this notation is {x| x has property P} and is read” the set of all x such
that x has property P”.
S = {x | x is a positive integer less than 100}
O = {x | x is an odd positive integer less than 10}
O = {x ∈ Z⁺ | x is odd and x < 10}
We often use this type of notation to describe sets when it is impossible to list all the
members of the set.
T={x|x is a real number and x>10}
Q+ = {x ∈ R | x = p/q, for some positive integers p,q}
Describing a set: Venn diagram Section
Chapter 2: Relations
1. Logic and proofs 6

 Universal set U,which contains all the objects under consideration, is represented
by a rectangle.
Note: the univeral set varies depending on which objects are of interest

Let U be the set of all lowercase letter,


V={a,e,i,o,u}

 The empty set is the set with no elements,and is denoted by but {} are also used.
A=
Question: What are the difference between ?
Section
Chapter 2: Relations
1. Logic and proofs 7

 Sets can have other sets as members


A={1,a,{a},{1,a}}

Definition 2: Two sets are equal if and only if they have the same elements.
Therefore, if A and B are sets, then A and B are equal if and only if . We write
A=B if A and B are equal sets

 Example:A={1,3,5},B={1,3,3,5},C={3,1,5}
Subsets Section
Chapter 2: Relations
1. Logic and proofs 8

Definition 3: The set A is a subset of B, and B is a superset of A, if and only if


every element of A is also an element of B. We use the notation to indicate that
A is a subset of the set B. If, instead, we want to stress that B is a superset of A,
we use the equivalent notation .(So and are equivalent statements)

A ⊆ B holds if and only if is true


Section
Chapter 2: Relations
1. Logic and proofs 9

 Showing a Set is or is not a Subset of Another Set


Showing that A is a Subset of B: To show that A ⊆ B, show that if x belongs to A, then x
also belongs to B.
Showing that A is not a Subset of B: To show that A is not a subset of B, A ⊈ B, find an
element x ∈ A with x ∉ B. (Such an x is a counterexample to the claim that x ∈ A implies x ∈
B.)
 Examples:
1. The set of all computer science majors at your school is a subset of all students at your
school.
2. The set of integers with squares less than 100 is not a subset of the set of nonnegative
integers.
3. the set of all people in China is a subset of the set of all people in China.
Section
Chapter 2: Relations
1. Logic and proofs 10

Recall that two sets A and B are equal, denoted by A = B, iff

x  x  A  x  B 
Using logical equivalences we have that A = B iff
x  x  A  x  B    x  B  x  A 
This is equivalent to A ⊆ B and B ⊆ A
Subsets Section
Chapter 2: Relations
1. Logic and proofs 11

Theorem 1: For every set S,

 set A is a subset of a set B but , we write and say that A is a proper subset of B.
 A is a proper suyset of B if and only if

∀ 𝑥(𝑥∈ 𝐴→ 𝑥 ∈ 𝐵)∧∃ 𝑥 (𝑥∈ 𝐴∧ 𝑥 ∉ 𝐵)


Venn Diagram
The size of a set Section
Chapter 2: Relations
1. Logic and proofs 12

Definition 4: Let S be a set. If there are exactly n distinct elements in S where n


is a nonnegative integer. We say that S is a finite set and n is the cardinality of S.
The cardinality of S is denoted by |S|. A set is said to be infinite if it is not finite.

 Example:
1. Let A be the set of odd positive integers less than 10. Then |A|=5
2. ||= 0
3.|{ø}| = 0
4. |{1,a,{1},{1,a}}|= 4
5. The set of positive integers is infinite.
Section
Chapter 2: Relations
1. Logic and proofs 13

Definition 5: Given a set S. the power set of S is the set of all subsets of the set
S. The power set of S is denoted by P(S).

 Example:
1.What is the power set of the set {1,2,3}?
2.What is the power set of the set ?
3.What is the power set of the set ?
Remark: If a set has n elements, then its power set has elements
Section
Chapter 2: Relations
1. Logic and proofs 14
Section
Chapter 2: Relations
1. Logic and proofs 15

Exercise:
Make sure whether they are true or false
(1) 
(2) 
(3) {}
(4) {}
(5) { a, b }  { a, b, c, {a, b, c}}
(6) { a, b } { a, b, c, {a, b}}
(7) { a, b}  { a, b, {{a, b}}}
(8) { a, b} { a, b, {{a,b}}}
Cartesian products Section
Chapter 2: Relations
1. Logic and proofs 16

Definition 6: The ordered n-tuple is the ordered collection that has as its first
element,as its second element,...,as its nth element.

 Two n-tuples are equal if and only if their corresponding elements are equal.
= if and only if = for i=1,2,...,n.
 2-tuples are called ordered pairs.
The ordered pairs (a,b) and (c,d) are equal if and only if a = c and b = d.
Example: If (x+y,4)=(5,2x-y), then what are the values of x and y, respectively?
Section
Chapter 2: Relations
1. Logic and proofs 17

Definition 7: Let A and B be sets. The Cartesian product of A and B, denoted by, is
the set of all ordered pairs(x,y), where . Hence

𝐴× 𝐵≠ 𝐵× 𝐴
 Example:
A = {a,b} B = {1,2,3}
A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)}
How about ?
 Example: Let A represent the set of all students at a university, and B represent the set of
all courses offered at the university. What is the Cartesian product and how can it be
used?
Section
Chapter 2: Relations
1. Logic and proofs 18

Definition 8: The Cartesian product of the sets denoted by is the set of ordered n-
tuples where belong to for i=1,2,...,n. In other words,

Example: What is A × B × C where A = {0,1}, B = {1,2} and C = {0,1,2}


Solution: A × B × C = {(0,1,0), (0,1,1), (0,1,2),(0,2,0), (0,2,1), (0,2,2),(1,1,0),
(1,1,1), (1,1,2), (1,2,0), (1,2,1), (1,2,2)}
? Section
Chapter 2: Relations
1. Logic and proofs 19

Remark : We use the notation to denote , the cartesian product of set A with
itself.

Example : Suppose that A={1,2}, it follows that . How about ?

A subset R of the Cartesian product is called a relation from the set A to set B. The
elements of R are ordered pairs, where the first element belongs to A, the second
element belongs to B
Example:
1.Suppose A={1,2}, B={a,b,c}, what about .
2. What are the ordered pairs in the less than or equal to relation, which contains
(a,b) if , on the set {1,2,3}
Set Operation Section
Chapter 2: Relations
1. Logic and proofs 20

Definition: Let A and B be sets. The union of the sets A and B, denoted
by A ∪ B, is the set that contains those elements that are either in A or in
B, or in both.
𝐴∪ 𝐵={𝑥∨𝑥∈ 𝐴∨ 𝑥∈ 𝐵}
Venn Diagram for A ∪ B
Example: Suppose A={1,3,5} and B={1,2,3}.
Then
Section
Chapter 2: Relations
1. Logic and proofs 21

Definition: The intersection of sets A and B, denoted by A ∩ B, is the set containing


those elements in both A and B.

𝐴 ∩ 𝐵 ={𝑥∨ 𝑥 ∈ 𝐴 ∧ 𝑥 ∈ 𝐵 }
Example: What is {1,2,3} ∩ {3,4,5} ? Venn Diagram for A ∩B
Solution: {3}
Example:What is {1,2,3} ∩ {4,5,6} ?
Solution: ∅
Section
Chapter 2: Relations
1. Logic and proofs 22

Definition: Two sets are called disjoint if their intersection is the empty set.

Definition: Let A and B be sets. The difference of A and B, denoted by A – B, is the


set containing those elements that are in A but not in B. The difference of A and B is
also called the complement of B with respect to A.
𝐴 − 𝐵={𝑥∨ 𝑥 ∈ 𝐴 ∧ 𝑥 ∉ 𝐵 }
Venn Diagram for A − B
Example: Suppose that A={1,2,3}, B={1,4},
C={0,5}. What is A-B, A-C?
Section
Chapter 2: Relations
1. Logic and proofs 23

Definition: Let U be the universal set. The complement of the set A, denoted by , is
the complement of A with respect to U. Therefore, the complement of the set A is U-
A.

𝐴={𝑥∨ 𝑥 ∈ 𝑈 ∧ 𝑥 ∉ 𝐴 }

Example: Let A={0,1,2,3}, U={x|x<10}. Then what is


The Cardinality of the Union of Two Sets Section
Chapter 2: Relations
1. Logic and proofs 24

Inclusion-Exclusion : |A ∪ B| = |A| + | B| − |A ∩ B|
Example: Let A be the math majors in your class and B be the CS majors. To count the
number of students who are either math majors or CS majors, add the number of math
majors and the number of CS majors, and subtract the number of joint CS/math majors.

Venn Diagram for A, B, A ∩ B, A ∪ B


Section
Chapter 2: Relations
1. Logic and proofs 25

Definition: The symmetric difference of A and B, denoted by is the set

Example: Venn Diagram


U = {0,1,2,3,4,5,6,7,8,9,10}
A = {1,2,3,4,5} B ={4,5,6,7,8}
What is ?

Solution: {1,2,3,6,7,8}
Section
Chapter 2: Relations
1. Logic and proofs 26

Exercise: U = {0,1,2,3,4,5,6,7,8,9,10} A = {1,2,3,4,5}, B ={4,5,6,7,8}, What are the


results of A ∪ B , A ∩ B , Ā ,, A – B , B – A , respectively.
Solution: A ∪ B={1,2,3,4,5,6,7,8}
A ∩ B = {4,5}
Ā = {0,6,7,8,9,10}
={0,1,2,3,9,10}
A – B = {1,2,3}
B – A ={6,7,8}
Section
Chapter 2: Relations
1. Logic and proofs 27

Exercise:
1. Let } , . Find

2. Make sure whether the following are true or false


( 1 ) AB = A  B=
( 2 ) A(BC) = (AB)(AC)
( 3 ) AA = A
( 4 ) If AB = B , then A = U.
( 5 ) Let A = {x}x , then xA and x  A.
3. Find the set A and set B if A-B={1,5,7,8},B-A={2,10}, and AB={3,6,9}.
Identity Name
Set Identities Section
Chapter
Identity laws 2: Relations
1. Logic and proofs 28

Domination laws
Idempotent laws
Complementation law
Commutative laws
Associative laws

Distributive laws

De Morgan’s laws
Absorption laws
Complement laws
Proving Set Identities Section
Chapter 2: Relations
1. Logic and proofs 29

 Different ways to prove set identities:


1. Prove that each set (side of the identity) is a subset of the other.
2. Use set builder notation and propositional logic.
Section
Chapter 2: Relations
1. Logic and proofs 30

Example : Prove that


Solution: We prove this identity by showing that:
1 A  B  A  B and
2 A  B  A  B
Set-Builder Notation
Section
Chapter 2: Relations
1. Logic and proofs 31

Exercise: Prove that


generalized unions and intersections Section
Chapter 2: Relations
1. Logic and proofs 32

Definition: The union of a collection of sets is the set that contains those elements
that are members of at least one set in the collection.
The intersection of a collection of sets is the set that contains those elements that are
members of all the sets in the collection.
n

A  A  A
i 1
i 1 2    An
n

A  A  A
i 1
i 1 2    An
Example: For i = 1,2,…, let Ai = {i, i + 1, i + 2, ….}. Then,
n n

A  i, i  1, i  2,  1, 2,3,


i 1
i
i 1
n n

A i, i  1, i  2,  n, n  1, n  2,  A


i 1
i
i 1
n
Relations and Their Properties Section
Chapter 2: Relations
1. Logic and proofs 33

Definition: Let A and B be sets, A binary relation R from A to B is a subset of


,

We use the notation to denote that , and to denote that . When , is said to be
related to by . In the following, we will omit the word binary.
Section
Chapter 2: Relations
1. Logic and proofs 34

Example:
Let A = {0,1,2} and B = {a,b}, then R={(0, a), (0, b), (1,a) , (2, b)} is a relation
from A to B.
Question: How many relations are there from set A to set B, if |A|=n, |B|=m?
Section
Chapter 2: Relations
1. Logic and proofs 35

Definition: A relation R on a set is a relation from to .

 Example:
1. Suppose that A = {a,b,c}. Then R = {(a,a),(a,b), (a,c)} is a relation on A.
2. Let A = {1, 2, 3, 4}. The ordered pairs in the relation R = {(a,b) | a divides b}.
Then R= {(1,1), (1, 2), (1,3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.
Section
Chapter 2: Relations
1. Logic and proofs 36

Question: How many relations are there on a set A, if |A|=n?


Solution: Because a relation on A is the same thing as a subset of A × A, we
count the subsets of A × A. Since A × A has n2 elements when A has n
elements, and a set with n elements has 2n subsets, there are subsets of A × A.
Therefore, there are relations on a set A.
Section
Chapter 2: Relations
1. Logic and proofs 37

Example: Consider these relations on the set of integers:


R1   a, b a  b , R4   a, b a  b ,
R2   a, b a  b , R5   a, b a  b  1 ,
R3   a, b a  b or a  b , R6   a, b a  b  3 .
Note that these relations are on an infinite set and each of these relations is an infinite set.
Which of these relations contain each of the pairs (1,1), (1, 2), (2, 1), (1, −1), and (2,
2)?
Solution: Checking the conditions that define each relation, we see that the pair (1,1)
is in R1, R3, R4 , and R6: (1,2) is in R1 and R6: (2,1) is in R2, R5, and R6: (1, −1) is in R2, R3,
and R6 : (2,2) is in R1, R3, and R4.
Section
Chapter 2: Relations
1. Logic and proofs 38

Exercise:
List the ordered pairs in the relation from to ,where if and only if
1)
2)
3)
Representing Relations Using Matrices Section
Chapter 2: Relations
1. Logic and proofs 39

 A relation between finite sets can be represented using a zero-one matrix.


 Suppose R is a relation from A = {a1, a2, …, am} to B = {b1, b2, …, bn}.
– The elements of the two sets can be listed in any particular arbitrary order.
When A = B, we use the same ordering.
 The relation R is represented by the matrix MR = [mij], where
 
1 if ai , b j  R,

mij  
 
0 if ai , b j  R.

The matrix representing R has a 1 as when ai is related to bj and a 0 if ai is not


related to bj.
Section
Chapter 2: Relations
1. Logic and proofs 40

 Example : Suppose that A = {1,2,3} and B = {1,2}. Let R be the relation from A to B
containing (a,b) if a ∈ A, b ∈ B, and a > b. What is the matrix representing R
(assuming the ordering of elements is the same as the increasing numerical order)?
 Solution: Because R = {(2,1), (3,1),(3,2)}, the matrix is

0 0
 
MR  1 0
 

1 1

Section
Chapter 2: Relations
1. Logic and proofs 41

 Example: Let A = {a1,a2, a3} and B = {b1,b2, b3,b4, b5}. Which ordered pairs
are in the relation R represented by the matrix
0 1 0 0 0 
 
M R  1 0 1 1 0  ?
 
1 0 1 0 1 
Solution: Because R consists of those ordered pairs (ai,bj) with mij = 1, it follows that:

R a , b  , a , b  , a , b  , a , b  , a , b  , a , b  , a , b .
1 2 2 1 2 3 2 4 3 1 3 3 3 5
Section
Chapter 2: Relations
1. Logic and proofs 42

 Definition: A directed graph, or digraph, consists of a set V of vertices (or nodes)


together with a set E of ordered pairs of elements of V called edges (or arcs). The
vertex a is called the initial vertex of the edge (a,b), and the vertex b is called the
terminal vertex of this edge.
– An edge of the form (a,a) is called a loop.
 Example : A drawing of the directed graph with vertices a, b, c, and d, and edges (a,
b), (a, d), (b, b), (b, d), (c, a), (c, b), and (d, b) is shown here.

R={(a, b), (a, d), (b, b), (b, d),


(c, a), (c, b), (d, b)}
Section
Chapter 2: Relations
1. Logic and proofs 43

Example : What are the ordered pairs in the relation represented


by this directed graph?

Solution: The ordered pairs in the relation is R={(1, 3), (1, 4), (2, 1), (2, 2), (2, 3),
(3, 1), (3, 3),(4, 1), (4, 3)}
Properties of Relations Section
Chapter 2: Relations
1. Logic and proofs 44

Definition: R is reflexive if (a,a) ∊R for every element a ∊A.


Written symbolically, R is reflexive if (x)((x∈A)→(<x,x>∈R))
Example: The following relations on the integers are reflexive:
R1   a, b a  b ,  If A = ∅ then the empty relation is
R3   a, b a  b or a  b ,
reflexive vacuously. That is the
R4   a, b a  b .
empty relation on an empty set is
The following relations are not reflexive:
reflexive!
 
R2   a, b a  b  note that 3  3 ,
R5   a, b a  b  1  note that 3  3  1 ,
R6   a, b a  b  3  note that 4  4 ’ 3 .
Section
Chapter 2: Relations
1. Logic and proofs 45

Exercise: The following relation on A={1,2,3} , determine whether they are


reflexive.
( 1 ) R={<1,1>,<1,2>,<2,2>,<3,3>} ;
( 2 ) S={<1,2>,<2,3>,<3,1>} ;
( 3 ) T={<1,1>,<1,2>,<1,3>,<3,1>,<3,3>} 。
Section
Chapter 2: Relations
1. Logic and proofs 46

Definition: R is symmetric if (b,a) ∊ R whenever (a,b) ∊ R for all a,b ∊ A.


xy(x∈A∧y∈A∧<x,y>∈R→<y,x>∈R)

Example: Determine the following relations on the integers are symmetric:


R3   a, b a  b or a  b ,
R4   a, b a  b ,
R6   a, b a  b  3 .
The following are not symmetric:
 
R1   a, b a  b  note that 3  4, but 4 ’ 3 ,
R2   a, b a  b  note that 4  3, but 3  4 ,
R5   a, b a  b  1  note that 4  3  1, but 3  4  1 .
Section
Chapter 2: Relations
1. Logic and proofs 47

Definition: A relation R on a set A such that for all a,b ∊ A if (a,b) ∊ R and (b,a) ∊ R,
then a = b is called antisymmetric.
y(x∈A∧y∈A∧(<x,y>∈R∧<y,x>∈R)→x=y)

Example: The following relations on the integers are antisymmetric:

R1   a, b a  b , For any integer, if a a ≤ b and a ≤ b , then a = b.


R2   a, b a  b ,
R4   a, b a  b ,
R5   a, b a  b  1 .
The following relations are notantisymmetric:

R3   a, b a  b or a  b 
 note that both 1, 1 and  1,1 belongs to R  ,
3

R6   a, b a  b  3  note that both 1, 2 and  2,1 belongs to R  .


6
Section
Chapter 2: Relations
1. Logic and proofs 48

Definition: A relation R on a set A is called transitive if whenever (a,b) ∊ R and (b,c) ∊


R, then (a,c) ∊ R, for all a,b,c ∊ A.

Example: The following relations on the integers are transitive:

R1   a, b a  b , For every integer, a ≤ b and b ≤ c, then b ≤ c.


R2   a, b a  b ,
R3   a, b a  b or a  b ,
R4   a, b a  b .
The following are not transitive:
R5   a, b a  b  1  note that both 3, 2 and 4,3 belongs to R , but not 3,3 ,
5

R6   a, b a  b  3  note that both  2,1 and 1, 2  belongs to R , but not  2, 2 .
6
Section
Chapter 2: Relations
1. Logic and proofs 49

 If R is a reflexive relation, all the elements on the main diagonal of MR are equal to 1.

 R is a symmetric relation, if and only if mij = 1 whenever mji = 1. R is an


antisymmetric relation, if and only if mij = 0 or mji = 0 when i≠ j.
Section
Chapter 2: Relations
1. Logic and proofs 50

Example: Suppose that the relation R on a set is represented by the matrix

1 1 0 
 
M R  1 1 1  .
 
0 1 1 
 Is R reflexive, symmetric, and/or antisymmetric?
 Solution: Because all the diagonal elements are equal to 1, R is
reflexive. Because MR is symmetric, R is symmetric and not
antisymmetric because both m1,2 and m2,1 are 1.
Section
Chapter 2: Relations
1. Logic and proofs 51

 Definition: A directed graph, or digraph, consists of a set V of vertices (or nodes)


together with a set E of ordered pairs of elements of V called edges (or arcs). The
vertex a is called the initial vertex of the edge (a,b), and the vertex b is called the
terminal vertex of this edge.
– An edge of the form (a,a) is called a loop.
 Example: A drawing of the directed graph of relation R={ (a, b), (a, d), (b, b), (b,
d), (c, a), (c, b), (d, b)} on set A={ a, b, c, d}
Section
Chapter 2: Relations
1. Logic and proofs 52

 Example: What is the relation R represented by this directed graph?

Solution:
The relation R={(1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (3, 1), (3, 3),(4, 1), (4, 3)}
Section
Chapter 2: Relations
1. Logic and proofs 53

Determining which Properties a Relation has from its Digraph


 Reflexivity: A loop must be present at all vertices in the graph.
 Symmetry: If (x,y) is an edge, then so is (y,x).
 Antisymmetry: If (x,y) with x ≠ y is an edge, then (y,x) is not an edge.
 Transitivity: If (x,y) and (y,z) are edges, then so is (x,z).
Section
Chapter 2: Relations
1. Logic and proofs 54

Example: Determine what properties R have as shown in the following.

 Reflexive? No, not every vertex has a loop


 Symmetric?
Yes, there is no edge from one vertex to another
 Antisymmetric?
Yes, there is no edge from one vertex to another
 Transitive?
Yes, there is no edge from one vertex to another
Section
Chapter 2: Relations
1. Logic and proofs 55

Example: Determine what properties R have as shown in the following.

 Reflexive? No, there are no loops


 Symmetric? No, there is an edge from a to b, but not from b to a
 Antisymmetric?
No, there is an edge from d to b and b to d
 Transitive?
No, there are edges from a to c and from c to b, but there is no edge
from a to d
Section
Chapter 2: Relations
1. Logic and proofs 56

Example: Determine what properties R have as shown in the following.

 Reflexive? No, there are no loops


 Symmetric?
No, for example, there is no edge from c to a
 Antisymmetric?
Yes, whenever there is an edge from one vertex to another, there is
 Transitive?
not one going back
Yes.
Combining relation Section
Chapter 2: Relations
1. Logic and proofs 57

Exercise: Let R={(1,1),(2,2),(3,3)},S={(1,1),(1,2),(1,3),(1,4)} be relations on set


A={1,2,3,4}. Find
Section
Chapter 2: Relations
1. Logic and proofs 58

Definition : Let R be a relation from a set A to a set B, and S be a relation from B to a


set C.The composite of R and S is a relation consisting of ordered pairs (a,c), where ,
and for which there exits an element such that and . We denote the composite of R and
S by .
Example: Let A={a,b,c,d} , B={b,c,d} , C={a,b,d} ,
R={<a,b>,<b,b>,<c,d>,<d,c>}is a relation from set A to B , S={<b,d>,<d,a>,<d,b>}is
a relation from set B to C. Find RS 。

You might also like