05 - relations
DESCRIPTION
I used this set of slides for the lecture on Relations I gave at the University of Zurich for the 1st year students following the course of Formale Grundlagen der Informatik.TRANSCRIPT
Wax on … wax off … these are the basics
http://www.youtube.com/watch?v=3PycZtfns_U
computerinformation information
computation
SetA set is a group of objects.
SetA set is a group of objects.
{10, 23, 32}
N = {0, 1, 2, … }
Z = {… , -2, -1, 0, 1, 2, … }
Ø
U
empty set
universe
SetA set is a group of objects.
{10, 23, 32}
N = {0, 1, 2, … }
Z = {… , -2, -1, 0, 1, 2, … }
10 ∈ {10, 23, 32}
-1 ∉ N
Ø
U
empty set
universe
Membershipa is a member of set A
Subset A⊆B
∀x:: x∈A ⇒ x∈B
Every member of A is also an element of B.
Subset A⊆B
∀x:: x∈A ⇒ x∈B
∅ ⊆ A.A ⊆ A.A = B ⇔ A ⊆ B ∧ B ⊆ A.
Every member of A is also an element of B.
Subset A⊆B
∀x:: x∈A ⇒ x∈B
∅ ⊆ A.A ⊆ A.A = B ⇔ A ⊆ B ∧ B ⊆ A.
Proper subset A⊂B
∀x:: A⊆B ∧ A≠B
A is a subset of B and not equal to B.
Every member of A is also an element of B.
Union A∪B
∀x:: x∈A ∨ x∈BA∪B={ x | x∈A or x∈B }
Union A∪B
∀x:: x∈A ∨ x∈BA∪B={ x | x∈A or x∈B }
Union A∪B
∀x:: x∈A ∨ x∈BA∪B={ x | x∈A or x∈B }
A ∪ B = B ∪ A.A ∪ (B ∪ C) = (A ∪ B) ∪ C.A ⊆ (A ∪ B).A ∪ A = A.A ∪ ∅ = A.A ⊆ B ⇔ A ∪ B = B.
Intersection A∩B
∀x:: x∈A ∧ x∈BA∩B={ x | x∈A and x∈B }
Intersection A∩B
∀x:: x∈A ∧ x∈BA∩B={ x | x∈A and x∈B }
Intersection A∩B
∀x:: x∈A ∧ x∈BA∩B={ x | x∈A and x∈B }
A ∩ B = B ∩ A.A ∩ (B ∩ C) = (A ∩ B) ∩ C.A ∩ B ⊆ A.A ∩ A = A.A ∩ ∅ = ∅.A ⊆ B ⇔ A ∩ B = A.
Complements A\B, A’
∀x:: x∈A ∧ x∉BA\B={ x | x∈A and x∉B }
Complements A\B, A’
∀x:: x∈A ∧ x∉BA\B={ x | x∈A and x∉B }
A \ B ≠ B \ A.A ∪ A′ = U.A ∩ A′ = ∅.(A′)′ = A.A \ A = ∅.U′ = ∅.∅′ = U.A \ B = A ∩ B′.
A ∩ U = AA ∪ ∅ = A
Neutral elements
A ∩ U = AA ∪ ∅ = A
Neutral elements
A ∩ ∅ = ∅
A ∪ U = U
Zero elements
A ∩ U = AA ∪ ∅ = A
Neutral elements
A ∩ ∅ = ∅
A ∪ U = U
Zero elements
A ∩ A = AA ∪ A = A
Idempotence
A ∩ U = AA ∪ ∅ = A
Neutral elements
A ∩ ∅ = ∅
A ∪ U = U
Zero elements
A ∩ A = AA ∪ A = A
Idempotence
A ∪ B = B ∪ AA ∩ B = B ∩ A
Commutativity
A ∩ U = AA ∪ ∅ = A
Neutral elements
A ∩ ∅ = ∅
A ∪ U = U
Zero elements
A ∩ A = AA ∪ A = A
Idempotence
A ∪ B = B ∪ AA ∩ B = B ∩ A
Commutativity
A ∩ (B ∩ C) = (A ∩ B) ∩ CA ∪ (B ∪ C) = (A ∪ B) ∪ C
Associativity
A ∩ U = AA ∪ ∅ = A
Neutral elements
A ∩ ∅ = ∅
A ∪ U = U
Zero elements
A ∩ A = AA ∪ A = A
Idempotence
A ∪ B = B ∪ AA ∩ B = B ∩ A
Commutativity
A ∩ (B ∩ C) = (A ∩ B) ∩ CA ∪ (B ∪ C) = (A ∪ B) ∪ C
Associativity
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
Distributivity
A ∩ U = AA ∪ ∅ = A
Neutral elements
A ∩ ∅ = ∅
A ∪ U = U
Zero elements
A ∩ A = AA ∪ A = A
Idempotence
A ∩ A’ = ∅
A ∪ A’ = U
Complement
A ∪ B = B ∪ AA ∩ B = B ∩ A
Commutativity
A ∩ (B ∩ C) = (A ∩ B) ∩ CA ∪ (B ∪ C) = (A ∪ B) ∪ C
Associativity
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
Distributivity
Similar to boolean algebra
a ∧ 1 = aa ∨ 0 = a
Neutral elements
a ∧ 0 = 0a ∨ 1 = 1
Zero elements
a ∧ a = aa ∨ a = a
Idempotence
a ∧ ¬ a = 0a ∨ ¬ a = 1
Negation
a ∨ b = b ∨ aa ∧ b = b ∧ a
Commutativity
a ∧ (b ∧ c) = (a ∧ b) ∧ ca ∨ (b ∨ c) = (a ∨ b) ∨ c
Associativity
a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c)a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c)
Distributivity
A ∩ U = AA ∪ ∅ = A
Neutral elements
A ∩ ∅ = ∅
A ∪ U = U
Zero elements
A ∩ A = AA ∪ A = A
Idempotence
A ∩ A’ = ∅
A ∪ A’ = U
Complement
A ∪ B = B ∪ AA ∩ B = B ∩ A
Commutativity
A ∩ (B ∩ C) = (A ∩ B) ∩ CA ∪ (B ∪ C) = (A ∪ B) ∪ C
Associativity
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
Distributivity
A ∩ U = A A ∪ B = B ∪ AA ∪ ∅ = A
A ∩ ∅ = ∅
A ∪ U = U
A ∩ A = AA ∪ A = A
A ∩ A’ = ∅
A ∪ A’ = U
Neutral elements
Zero elements
Idempotence
Complement
A ∩ (B ∩ C) = (A ∩ B) ∩ C
A ∩ B = B ∩ A
A ∪ (B ∪ C) = (A ∪ B) ∪ C
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
(A ∩ B)’ = (A’) ∪ (B’)(A ∪ B)’ = (A’) ∩ (B’)
Commutativity
Associativity
Distributivity
DeMorgan’s
A ⊆ A.
A ⊆ B ∧ B ⊆ A ⇔ A = B.
A ⊆ B ∧ B ⊆ C ⇔ A ⊆ C
Reflexivity
Anti-symmetry
Transitivity
Scissors
Paper
Stone
Scissors
Paper
Stone
beats
beats
beats
Scissors
Paper
Stone
beats
beats
beats
beats Scissors Paper StoneScissors FALSE TRUE FALSEPaper FALSE FALSE TRUEStone TRUE FALSE FALSE
beats Scissors Paper StoneScissors FALSE TRUE FALSEPaper FALSE FALSE TRUEStone TRUE FALSE FALSE
beats = {(Scissors, Paper), (Paper, Stone), (Stone, Scissors)}
beats Scissors Paper StoneScissors FALSE TRUE FALSEPaper FALSE FALSE TRUEStone TRUE FALSE FALSE
beats = {(Scissors, Paper), (Paper, Stone), (Stone, Scissors)}
beats ⊆ {Scissor, Paper, Stone} x {Scissor, Paper, Stone}
Cartesian product AxB
AxB={ (a,b) | a∈A and b∈B }
Cartesian product AxB
AxB={ (a,b) | a∈A and b∈B }
A × ∅ = ∅.A × (B ∪ C) = (A × B) ∪ (A × C).(A ∪ B) × C = (A × C) ∪ (B × C).
N-ary Relation
A1, A2, ..., AnR ⊆ A1 x A2 x...x An
Binary Relation
A1, A2R ⊆ A1 x A2
(a,b) ∈ RaRb
Binary Relation
A1, A2R ⊆ A1 x A2
(a,b) ∈ RaRb
Binary Relation
A1, A2R ⊆ A1 x A2
(a,b) ∈ RaRb
dom R = {a⏐∃b :: (a,b) ∈ R}range R = {b⏐∃a :: (a,b) ∈ R}
Reflexive relationevery element x of A is in relation R with itself
∀x: x∈A: xRx
Reflexive relationevery element x of A is in relation R with itself
Symmetric relationif there is a relation between x and y, then there is a relation between y and x
∀x: x∈A: xRx
Reflexive relationevery element x of A is in relation R with itself
Symmetric relationif there is a relation between x and y, then there is a relation between y and x
∀x: x∈A: xRx
∀x,y: x,y∈A: xRy ⇒ yRx
Reflexive relationevery element x of A is in relation R with itself
Transitive relation...
Symmetric relationif there is a relation between x and y, then there is a relation between y and x
∀x: x∈A: xRx
∀x,y: x,y∈A: xRy ⇒ yRx
Reflexive relationevery element x of A is in relation R with itself
Transitive relation...
Symmetric relationif there is a relation between x and y, then there is a relation between y and x
∀x: x∈A: xRx
∀x,y: x,y∈A: xRy ⇒ yRx
∀x,y,z: x,y,z∈A: (xRy ∧ yRz) ⇒ xRz
Reflexive relationevery element x of A is in relation R with itself
Transitive relation...
Symmetric relationif there is a relation between x and y, then there is a relation between y and x
Eq
uiva
lent
rel
atio
n
∀x: x∈A: xRx
∀x,y: x,y∈A: xRy ⇒ yRx
∀x,y,z: x,y,z∈A: (xRy ∧ yRz) ⇒ xRz
Reflexive relationevery element x of A is in relation R with itself
Examples
=>, <≥, ≤beats
Examples
=>, <≥, ≤beats
reflexive, symmetric, transitive
transitive
reflexive, transitive
-
[x]R= {y | xRy}Equivalence class
[x]R= {y | xRy}Equivalence class
[1]= =
[x]R= {y | xRy}Equivalence class
[1]= = {1}
Example
Consider the relation ≡5 over the integer numbers Z defined as x≡5y if and only if x-y is a multiple of 5 (where x,y∈Z).Is ≡5 an equivalence relation?
Example
Consider the relation ≡5 over the integer numbers Z defined as x≡5y if and only if x-y is a multiple of 5 (where x,y∈Z).Is ≡5 an equivalence relation?
What is [1]≡5 ?
R ⊆ AxA{(a,b), (b,c), (c,d)}
a b c dR ⊆ AxA{(a,b), (b,c), (c,d)}
a b c dR ⊆ AxA{(a,b), (b,c), (c,d)}
a b c dR ⊆ AxA{(a,b), (b,c), (c,d)}
a b c dR ⊆ AxA{(a,b), (b,c), (c,d)}
a b c dR ⊆ AxA{(a,b), (b,c), (c,d)}
R1 = R;∀i:i>1:Ri = Ri-1 ∪ {(a,b) | ∃c:: (a,c)∈Ri-1 ∧ (c,b)∈Ri-1}.Rt = ∪i≥1Ri = R1 ∪ R2 ∪ R3 ∪ ...
Transitive closure
Irreflexive relationno element x of A is in relation R with itself
∀x: x∈A: ¬(xRx)
Irreflexive relationno element x of A is in relation R with itself
Antisymmetric relationif there is a relation between x and y and one between y and x, then x equals y
∀x: x∈A: ¬(xRx)
Irreflexive relationno element x of A is in relation R with itself
Antisymmetric relationif there is a relation between x and y and one between y and x, then x equals y
∀x: x∈A: ¬(xRx)
∀x,y: x,y∈A: (xRy ∧ yRx) ⇒ x=y
Irreflexive relationno element x of A is in relation R with itself
Asymmetric relationxRy and yRx cannot hold at the same time
Antisymmetric relationif there is a relation between x and y and one between y and x, then x equals y
∀x: x∈A: ¬(xRx)
∀x,y: x,y∈A: (xRy ∧ yRx) ⇒ x=y
Irreflexive relationno element x of A is in relation R with itself
Asymmetric relationxRy and yRx cannot hold at the same time
Antisymmetric relationif there is a relation between x and y and one between y and x, then x equals y
∀x: x∈A: ¬(xRx)
∀x,y: x,y∈A: (xRy ∧ yRx) ⇒ x=y
∀x,y: x,y∈A: xRy ⇒ ¬(yRx)
Irreflexive relationno element x of A is in relation R with itself
Examples
=>, <≥, ≤beats
Examples
=>, <≥, ≤beats
antisymmetric
irreflexive, asymmetric
antisymmetric
irreflexive
Non-symmetric relationa relation that is not symmetric
∀x,y: x,y∈A: (xRy) ∧ ¬(yRx)
Non-symmetric relationa relation that is not symmetric
∀x,y: x,y∈A: (xRy) ∧ ¬(yRx)
Non-symmetric relationa relation that is not symmetric
Total relationR is defined on the entire A.
∀x,y: x,y∈A: (xRy) ∧ ¬(yRx)
Non-symmetric relationa relation that is not symmetric
∀x,y: x,y∈A: xRy ∨ yRx
Total relationR is defined on the entire A.
Examples
=>, <≥, ≤beats
Examples
=>, <≥, ≤beats
-
non-symmetric
non-symmetric, total
-
Acyclic relationthere are no elements with transitive closure to themselves
Acyclic relationthere are no elements with transitive closure to themselves
∀n: n∈N:( ¬(∃x1, x2, ...,xn: x1, x2, ...,xn∈A: x1Rx2 ∧ x2Rx3 ∧ ... ∧ xn-1Rxn ∧ xnRx1 ) )
Acyclic relationthere are no elements with transitive closure to themselves
∀n: n∈N:( ¬(∃x1, x2, ...,xn: x1, x2, ...,xn∈A: x1Rx2 ∧ x2Rx3 ∧ ... ∧ xn-1Rxn ∧ xnRx1 ) )
>, <
Acyclic relationthere are no elements with transitive closure to themselves
∀n: n∈N:( ¬(∃x1, x2, ...,xn: x1, x2, ...,xn∈A: x1Rx2 ∧ x2Rx3 ∧ ... ∧ xn-1Rxn ∧ xnRx1 ) )
>, < acyclic
R is partial order;R is total relation.
Total order
R is reflexive;R is transitive;R is antisymmetric.
Partial order
R is reflexive;R is transitive.
Strict partial order
A, BF ⊆ A x B(a,b)∈F ∧ (a,c)∈F ⇒ b=cdomF = A
F:A -> B
Function
A, BF ⊆ A x B(a,b)∈F ∧ (a,c)∈F ⇒ b=cdomF = A
F:A -> B
Function
FºG(x) = F(G(x))Function composition
Tudor Gîrbawww.tudorgirba.com
creativecommons.org/licenses/by/3.0/