Transcript slides

CSE 20
DISCRETE MATH
Prof. Shachar Lovett
http://cseweb.ucsd.edu/classes/wi15/cse20-a/
Clicker
frequency:
CA
Todays topics
• Equivalence relations
• Section 6.2 in Jenkyns, Stephenson
(Binary) Relations
• Model a relation between two families of objects
• Formally:
• U universe set
• Relation: 𝑅 ⊆ 𝑈 × 𝑈
• For 𝑥, 𝑦 ∈ 𝑈 we write: 𝑥𝑅𝑦 as a shorthand for "(𝑥, 𝑦) ∈ 𝑅“
• Example 1: x<y, formally…
• U=N
• “𝑥 < 𝑦” represents the relation 𝑅 =
𝑥, 𝑦 : 𝑥, 𝑦 ∈ 𝑁, 𝑥 < 𝑦
• Example 1: x<y, formally…
• U = P(N)
• “𝑥 ⊂ 𝑦” represents the relation 𝑅 = { 𝑥, 𝑦 : 𝑥, 𝑦 ∈ 𝑃(𝑁), 𝑥 ⊂ 𝑦}
Three important properties of relations
• There are several important properties of relations
• We will focus on the most important three
• A relation R is symmetric if ∀𝑥, 𝑦, 𝑥𝑅𝑦 ⇔ 𝑦𝑅𝑥
• A relation R is reflexive if ∀𝑥, 𝑥𝑅𝑥
• A relation R is transitive if ∀𝑥, 𝑦, 𝑧,
𝑥𝑅𝑦 ∧ 𝑦𝑅𝑧 → 𝑥𝑅𝑧
• An equivalence relation is a relation which satisfies all of
them
Examples of equivalence relations
• U=Z (integers)
• xRy = “x=y”
Prove that R is an equivalence relation
Examples of equivalence relations
• U=Z (integers)
• xRy = “|x|=|y|” (absolute value of x = absolute value of y)
Prove that R is an equivalence relation
Examples of equivalence relations
• U=“all students in this class”
• xRy = “x and y have the same birthday”
Prove that R is an equivalence relation
Examples of equivalence relations
• U=Z (integers)
• xRy = “x+y is even”
Prove that R is an equivalence relation
What is so special about equivalence
relations?
• Equivalence relations describe a partition of the universe
U to equivalence classes
Equivalence classes
• Let 𝑃1 , 𝑃2 , … , 𝑃𝑛 be a partition of U
• For 𝑥 ∈ 𝑈, define 𝐶𝑙𝑎𝑠𝑠 𝑥 to be the (unique!) part that x
belongs to
• Equivalently, define 𝐶𝑙𝑎𝑠𝑠: 𝑈 → {1, … , 𝑛} and equivalence
classes are defined by all elements with same image
𝑃𝑖 = {𝑥 ∈ 𝑈: 𝐶𝑙𝑎𝑠𝑠 𝑥 = 𝑖}
• Theorem: let 𝑅 ⊆ 𝑈 × 𝑈 be an equivalence relation. Then
there is a mapping 𝐶𝑙𝑎𝑠𝑠: 𝑈 → 𝐶 such that
∀𝑥, 𝑦 ∈ 𝑈, 𝑥𝑅𝑦 ⇔ 𝐶𝑙𝑎𝑠𝑠 𝑥 = 𝐶𝑙𝑎𝑠𝑠(𝑦)
Equivalence classes: example 1
• U=Z (integers)
• xRy = “x=y”
Class(x)=
A. x
B. y
C. U
D. “x=y”
E. Other
Equivalence classes: example 2
• U=Z (integers)
• xRy = “|x|=|y|”
Class(x)=
A. x
B. |x|
C. “x=y”
D. “|x|=|y|”
E. Other
Equivalence classes: example 3
• U=“all students in this class”
• xRy = “x and y have the same birthday”
Class(x)=
A. x
B. Birthday of x
C. “x=y”
D. “|x|=|y|”
E. Other
Equivalence classes: example 4
• U=Z (integers)
• xRy = “x+y is even”
Class(x)=???
Figure this out in your groups
Equivalence classes: proof
• Theorem: let 𝑅 ⊆ 𝑈 × 𝑈 be an equivalence relation. Then
there is a mapping 𝐶𝑙𝑎𝑠𝑠: 𝑈 → 𝐶 such that
∀𝑥, 𝑦 ∈ 𝑈, 𝑥𝑅𝑦 ⇔ 𝐶𝑙𝑎𝑠𝑠 𝑥 = 𝐶𝑙𝑎𝑠𝑠(𝑦)
Proof:
For each 𝑥 ∈ 𝑈, define: Class 𝑥 = {𝑦 ∈ 𝑈: 𝑥𝑅𝑦}
(and so 𝐶 = 𝐶𝑙𝑎𝑠𝑠 𝑥 : 𝑥 ∈ 𝑈 ⊂ 𝑃(𝑈) )
We need to show that
∀𝑥, 𝑦 ∈ 𝑈, 𝑥𝑅𝑦 ⇔ 𝐶𝑙𝑎𝑠𝑠 𝑥 = 𝐶𝑙𝑎𝑠𝑠(𝑦)
Equivalence classes: proof (contd)
For each 𝑥 ∈ 𝑈, define: Class 𝑥 = {𝑦 ∈ 𝑈: 𝑥𝑅𝑦}
(⇐) Assume Class 𝑥 = 𝐶𝑙𝑎𝑠𝑠(𝑦). We will show xRy.
By definition: we need to show 𝑦 ∈ 𝐶𝑙𝑎𝑠𝑠(𝑥).
But 𝑦 ∈ 𝐶𝑙𝑎𝑠𝑠 𝑦 since R is reflexive (and so 𝑦𝑅𝑦)) and
since we assume Class 𝑥 = 𝐶𝑙𝑎𝑠𝑠(𝑦) then also 𝑦 ∈
𝐶𝑙𝑎𝑠𝑠(𝑥).
Equivalence classes: proof (contd)
For each 𝑥 ∈ 𝑈, define: Class 𝑥 = {𝑦 ∈ 𝑈: 𝑥𝑅𝑦}
(⇒) Assume xRy. We need to show Class 𝑥 = 𝐶𝑙𝑎𝑠𝑠(𝑦).
We will first show 𝐶𝑙𝑎𝑠𝑠 𝑦 ⊆ 𝐶𝑙𝑎𝑠𝑠(𝑥). Let 𝑧 ∈ 𝐶𝑙𝑎𝑠𝑠 𝑦 .
Then y𝑅𝑧. Since R is transitive, 𝑥𝑅𝑦 ∧ 𝑦𝑅𝑧 imply that x𝑅𝑧.
So 𝑧 ∈ 𝐶𝑙𝑎𝑠𝑠(𝑥).
Since R is symmetric, we also have yRx. The same
argument as above (with the roles of x,y reversed) then
implies that 𝐶𝑙𝑎𝑠𝑠 𝑥 ⊆ 𝐶𝑙𝑎𝑠𝑠(𝑦). So: 𝐶𝑙𝑎𝑠𝑠 𝑥 = 𝐶𝑙𝑎𝑠𝑠(𝑦).
Next class
• Modular arithmetic
• Section 6.2 in Jenkyns, Stephenson
• Review session for midterm 2