Relations Definition Given sets A and B , R A B is a binary - - PowerPoint PPT Presentation

relations
SMART_READER_LITE
LIVE PREVIEW

Relations Definition Given sets A and B , R A B is a binary - - PowerPoint PPT Presentation

Relations 1 Myrto Arapinis School of Informatics University of Edinburgh September 25, 2014 1 Slides mainly borrowed from Richard Mayr 1 / 18 Relations Definition Given sets A and B , R A B is a binary relation from A to B , denoted R


slide-1
SLIDE 1

Relations1

Myrto Arapinis School of Informatics University of Edinburgh September 25, 2014

1Slides mainly borrowed from Richard Mayr 1 / 18

slide-2
SLIDE 2

Relations

Definition

Given sets A and B, R ⊆ A × B is a binary relation from A to B, denoted R : A → B

  • R is a set of ordered pairs, i.e. R ∈ P(A × B)
  • A is called the domain of R
  • B is called the codomain of R
  • We write aRb whenever (a, b) ∈ R
  • If B = A, R is called a relation on A

2 / 18

slide-3
SLIDE 3

Relations

Definition

Given sets A and B, R ⊆ A × B is a binary relation from A to B, denoted R : A → B

  • R is a set of ordered pairs, i.e. R ∈ P(A × B)
  • A is called the domain of R
  • B is called the codomain of R
  • We write aRb whenever (a, b) ∈ R
  • If B = A, R is called a relation on A

Definition

Given sets A1, . . . , An,a subset R ⊆ A1 × · · · × An is an n-ary relation

2 / 18

slide-4
SLIDE 4

Informal examples

  • Computation
  • Typing
  • Program equivalence
  • Networks
  • Databases

3 / 18

slide-5
SLIDE 5

Examples

Empty relation -

  • ∅ : A → B
  • ∀a ∈ A. ∀b ∈ B. ¬(a∅b)

4 / 18

slide-6
SLIDE 6

Examples

Empty relation -

  • ∅ : A → B
  • ∀a ∈ A. ∀b ∈ B. ¬(a∅b)

Full relation -

  • A × B : A → B
  • ∀a ∈ A. ∀b ∈ B. a(A × B)b

4 / 18

slide-7
SLIDE 7

Examples

Empty relation -

  • ∅ : A → B
  • ∀a ∈ A. ∀b ∈ B. ¬(a∅b)

Full relation -

  • A × B : A → B
  • ∀a ∈ A. ∀b ∈ B. a(A × B)b

Identity relation -

  • IA : A → A
  • IA = {(a, a) | a ∈ A}
  • ∀a1, a2 ∈ A. ((a1IAa2) ↔ (a1 = a2))

4 / 18

slide-8
SLIDE 8

Examples

Empty relation -

  • ∅ : A → B
  • ∀a ∈ A. ∀b ∈ B. ¬(a∅b)

Full relation -

  • A × B : A → B
  • ∀a ∈ A. ∀b ∈ B. a(A × B)b

Identity relation -

  • IA : A → A
  • IA = {(a, a) | a ∈ A}
  • ∀a1, a2 ∈ A. ((a1IAa2) ↔ (a1 = a2))

Divides relation -

  • |: Z+ → Z+
  • |= {(n, m) | ∃k ∈ Z+. m = kn}
  • ∀n, m ∈ Z+. ((n | m) ↔ (∃k ∈ Z+. m = kn))

4 / 18

slide-9
SLIDE 9

Properties of binary relations

A binary relation R : A → A is called

  • reflexive iff ∀x ∈ A. (x, x) ∈ R

Examples ≤, =, and | are reflexive, but < is not

5 / 18

slide-10
SLIDE 10

Properties of binary relations

A binary relation R : A → A is called

  • reflexive iff ∀x ∈ A. (x, x) ∈ R

Examples ≤, =, and | are reflexive, but < is not

  • symmetric iff ∀x, y ∈ A. ((x, y) ∈ R → (y, x) ∈ R)

Examples = is symmetric, but ≤, <, and | are not

5 / 18

slide-11
SLIDE 11

Properties of binary relations

A binary relation R : A → A is called

  • reflexive iff ∀x ∈ A. (x, x) ∈ R

Examples ≤, =, and | are reflexive, but < is not

  • symmetric iff ∀x, y ∈ A. ((x, y) ∈ R → (y, x) ∈ R)

Examples = is symmetric, but ≤, <, and | are not

  • antisymmetric iff

∀x, y ∈ A. (((x, y) ∈ R ∧ (y, x) ∈ R) → x = y) Examples ≤, =, <, and | are antisymmetric

5 / 18

slide-12
SLIDE 12

Properties of binary relations

A binary relation R : A → A is called

  • reflexive iff ∀x ∈ A. (x, x) ∈ R

Examples ≤, =, and | are reflexive, but < is not

  • symmetric iff ∀x, y ∈ A. ((x, y) ∈ R → (y, x) ∈ R)

Examples = is symmetric, but ≤, <, and | are not

  • antisymmetric iff

∀x, y ∈ A. (((x, y) ∈ R ∧ (y, x) ∈ R) → x = y) Examples ≤, =, <, and | are antisymmetric

  • transitive iff

∀x, y, z ∈ A. (((x, y) ∈ R ∧ (y, z) ∈ R) → (x, z) ∈ R) Examples ≤, =, <, and | are transitive

5 / 18

slide-13
SLIDE 13

Combining relations

Since relations are sets, they can be combined with normal set

  • perations, e.g. < ∪ = is equal to ≤, and ≤ ∩ ≥ is equal to =.

Moreover, relations can be composed.

Definition

Let R1 : A → B and R2 : B → C.Then R1 is composable with R2. The composition is defined by R1 ◦ R2

def

= {(x, z) ∈ A × C | ∃y ∈ B. ((x, y) ∈ R1 ∧ (y, z) ∈ R2)}

6 / 18

slide-14
SLIDE 14

Combining relations

Since relations are sets, they can be combined with normal set

  • perations, e.g. < ∪ = is equal to ≤, and ≤ ∩ ≥ is equal to =.

Moreover, relations can be composed.

Definition

Let R1 : A → B and R2 : B → C.Then R1 is composable with R2. The composition is defined by R1 ◦ R2

def

= {(x, z) ∈ A × C | ∃y ∈ B. ((x, y) ∈ R1 ∧ (y, z) ∈ R2)} Example If A = B = C = Z, then > ◦ > =

6 / 18

slide-15
SLIDE 15

Combining relations

Since relations are sets, they can be combined with normal set

  • perations, e.g. < ∪ = is equal to ≤, and ≤ ∩ ≥ is equal to =.

Moreover, relations can be composed.

Definition

Let R1 : A → B and R2 : B → C.Then R1 is composable with R2. The composition is defined by R1 ◦ R2

def

= {(x, z) ∈ A × C | ∃y ∈ B. ((x, y) ∈ R1 ∧ (y, z) ∈ R2)} Example If A = B = C = Z, then > ◦ > = {(x, y) ∈ Z × Z | x ≥ y + 2}

6 / 18

slide-16
SLIDE 16

Combining relations

Since relations are sets, they can be combined with normal set

  • perations, e.g. < ∪ = is equal to ≤, and ≤ ∩ ≥ is equal to =.

Moreover, relations can be composed.

Definition

Let R1 : A → B and R2 : B → C.Then R1 is composable with R2. The composition is defined by R1 ◦ R2

def

= {(x, z) ∈ A × C | ∃y ∈ B. ((x, y) ∈ R1 ∧ (y, z) ∈ R2)} Example If A = B = C = Z, then > ◦ > = {(x, y) ∈ Z × Z | x ≥ y + 2} Example If A = B = C = R, then > ◦ > =

6 / 18

slide-17
SLIDE 17

Combining relations

Since relations are sets, they can be combined with normal set

  • perations, e.g. < ∪ = is equal to ≤, and ≤ ∩ ≥ is equal to =.

Moreover, relations can be composed.

Definition

Let R1 : A → B and R2 : B → C.Then R1 is composable with R2. The composition is defined by R1 ◦ R2

def

= {(x, z) ∈ A × C | ∃y ∈ B. ((x, y) ∈ R1 ∧ (y, z) ∈ R2)} Example If A = B = C = Z, then > ◦ > = {(x, y) ∈ Z × Z | x ≥ y + 2} Example If A = B = C = R, then > ◦ > = >

6 / 18

slide-18
SLIDE 18

Theorem

Relational composition is associative and has the identity relation as neutral element

  • Associativity -

(proof on the board) ∀R : A → B, S : B → C, T : C → D, (T ◦S)◦R = T ◦(S◦R)

  • Neutral element -

(proof on the board) ∀R : A → B, R ◦ IA = R = IB ◦ R

7 / 18

slide-19
SLIDE 19

Theorem

Relational composition is associative and has the identity relation as neutral element

  • Associativity -

(proof on the board) ∀R : A → B, S : B → C, T : C → D, (T ◦S)◦R = T ◦(S◦R)

  • Neutral element -

(proof on the board) ∀R : A → B, R ◦ IA = R = IB ◦ R

Corollary

For every set A, the structure (P(A × A), IA, ◦) is a monoid

7 / 18

slide-20
SLIDE 20

Powers of a relation

Definition

Given a relation R ⊆ A × A on A, its powers are defined inductively by Base step: R0 = IA Induction step: Rn+1 = Rn ◦ R

8 / 18

slide-21
SLIDE 21

Powers of a relation

Definition

Given a relation R ⊆ A × A on A, its powers are defined inductively by Base step: R0 = IA Induction step: Rn+1 = Rn ◦ R If R is a transitive relation, then its powers are contained in R

  • itself. Moreover, the reverse implication also holds.

Theorem

A relation R on a set A is transitive iff Rn ⊆ R for all n = 1, 2, . . .

8 / 18

slide-22
SLIDE 22

Equivalence relations

Definition

A relation R on a set A is called an equivalence relation iff it is reflexive, symmetric and transitive

9 / 18

slide-23
SLIDE 23

Equivalence relations

Definition

A relation R on a set A is called an equivalence relation iff it is reflexive, symmetric and transitive Example Let Σ∗ be the set of strings over alphabet Σ. Let R ⊆ Σ∗ × Σ∗ be a relation on strings defined as follows R = {(s, t) ∈ Σ∗ × Σ∗ | |s| = |t|}. R is an equivalence relation (proof on the board)

9 / 18

slide-24
SLIDE 24

Equivalence relations

Definition

A relation R on a set A is called an equivalence relation iff it is reflexive, symmetric and transitive Example Let Σ∗ be the set of strings over alphabet Σ. Let R ⊆ Σ∗ × Σ∗ be a relation on strings defined as follows R = {(s, t) ∈ Σ∗ × Σ∗ | |s| = |t|}. R is an equivalence relation (proof on the board) Example Let R = {(n, m) ∈ Z+ × Z+ | n | m}. R is not an equivalence relation (proof on the board)

9 / 18

slide-25
SLIDE 25

Congruence modulo m

Let m > 1 be an integer, and R = {(a, b) | a = b (mod m)}. R is an equivalence on the set of integers

10 / 18

slide-26
SLIDE 26

Equivalence classes

Definition

Let R be an equivalence relation on a set A and a ∈ A. Let [a]R = {s | (a, s) ∈ R} be the equivalence class of a w.r.t. R, i.e. all elements of A that are R-equivalent to a If b ∈ [a]R then b is called a representative of the equivalence

  • class. Every member of the class can be a representative

11 / 18

slide-27
SLIDE 27

Theorem

Theorem

Let R be an equivalence on A and a, b ∈ A. The following three statements are equivalent

  • 1. aRb
  • 2. [a]R = [b]R
  • 3. [a]R ∩ [b]R = ∅

(proof on the board)

12 / 18

slide-28
SLIDE 28

Partitions of a set

Definition

A partition of a set A is a collection of disjoint, nonempty subsets that have A as their union. In other words, the collection of subsets Ai ⊆ A with i ∈ I (where I is an index set) forms a partition of A iff

  • 1. Ai = ∅ for all i ∈ I
  • 2. Ai ∩ Aj = ∅ for all i = j ∈ I

3.

i∈I Ai = A

13 / 18

slide-29
SLIDE 29

Theorem

Theorem

  • 1. If R is an equivalence on A, then the equivalence classes of R

form a partition of A

  • 2. Conversely, given a partition {Ai | i ∈ I} of A there exists an

equivalence relation R that has exactly the sets Ai, iI, as its equivalence classes (proof on the board)

14 / 18

slide-30
SLIDE 30

Partial orders

Definition

A relation R on a set A is called a partial order iff it is reflexive, antisymmetric and transitive. If R is a partial order, we call (A, R) a partially ordered set, or poset.

15 / 18

slide-31
SLIDE 31

Partial orders

Definition

A relation R on a set A is called a partial order iff it is reflexive, antisymmetric and transitive. If R is a partial order, we call (A, R) a partially ordered set, or poset. Example ≤ is a partial order, but < is not (since it is not reflexive)

15 / 18

slide-32
SLIDE 32

Partial orders

Definition

A relation R on a set A is called a partial order iff it is reflexive, antisymmetric and transitive. If R is a partial order, we call (A, R) a partially ordered set, or poset. Example ≤ is a partial order, but < is not (since it is not reflexive) Example The relation | is a partial order, i.e. (Z+, |) is a poset

15 / 18

slide-33
SLIDE 33

Partial orders

Definition

A relation R on a set A is called a partial order iff it is reflexive, antisymmetric and transitive. If R is a partial order, we call (A, R) a partially ordered set, or poset. Example ≤ is a partial order, but < is not (since it is not reflexive) Example The relation | is a partial order, i.e. (Z+, |) is a poset Example Set inclusion ⊆ is partial order, i.e. (2A, ⊆) is a poset

15 / 18

slide-34
SLIDE 34

Comparability and total orders

Definition

Two elements a and b of a poset (S, R) are called comparable iff aRb or bRa holds. Otherwise they are called incomparable

Definition

If (S, R) is a poset where every two elements are comparable, then S is called a totally ordered or linearly ordered set and the relation R is called a total order or linear order

16 / 18

slide-35
SLIDE 35

Extending orders to tuples: Standard

Let (S, ) be a poset and Sn = S × S × . . . × S (n times) The standard extension of the partial order to tuples in Sn is defined by (x1, . . . , xn) (y1, . . . , yn) ↔ ∀i ∈ {1, . . . , n}. xi yi

17 / 18

slide-36
SLIDE 36

Extending orders to tuples: Standard

Let (S, ) be a poset and Sn = S × S × . . . × S (n times) The standard extension of the partial order to tuples in Sn is defined by (x1, . . . , xn) (y1, . . . , yn) ↔ ∀i ∈ {1, . . . , n}. xi yi Exercise Prove that this defines a partial order.

17 / 18

slide-37
SLIDE 37

Extending orders to tuples: Standard

Let (S, ) be a poset and Sn = S × S × . . . × S (n times) The standard extension of the partial order to tuples in Sn is defined by (x1, . . . , xn) (y1, . . . , yn) ↔ ∀i ∈ {1, . . . , n}. xi yi Exercise Prove that this defines a partial order. Note Even if (S, ) is totally ordered, the extension to Sn is not necessarily a total order. Consider (N, ≤).

17 / 18

slide-38
SLIDE 38

Extending orders to tuples: Standard

Let (S, ) be a poset and Sn = S × S × . . . × S (n times) The standard extension of the partial order to tuples in Sn is defined by (x1, . . . , xn) (y1, . . . , yn) ↔ ∀i ∈ {1, . . . , n}. xi yi Exercise Prove that this defines a partial order. Note Even if (S, ) is totally ordered, the extension to Sn is not necessarily a total order. Consider (N, ≤). Then (2, 1) ≤ (1, 2) ≤ (2, 1)

17 / 18

slide-39
SLIDE 39

Extending orders to tuples: Lexicographic

Let (S, ) be a poset and Sn = S × S × . . . × S (n times). The lexicographic order on tuples in Sn is defined by (x1, . . . , xn) ≺lex (y1, . . . , yn) ↔ ∃i ∈ {1, . . . , n}. ∀k < i. xk = yk∧xi ≺ yi (x1, . . . , xn) lex (y1, . . . , yn) iff (x1, . . . , xn) ≺lex (y1, . . . , yn) or (x1, . . . , xn) = (y1, . . . , yn)

18 / 18

slide-40
SLIDE 40

Extending orders to tuples: Lexicographic

Let (S, ) be a poset and Sn = S × S × . . . × S (n times). The lexicographic order on tuples in Sn is defined by (x1, . . . , xn) ≺lex (y1, . . . , yn) ↔ ∃i ∈ {1, . . . , n}. ∀k < i. xk = yk∧xi ≺ yi (x1, . . . , xn) lex (y1, . . . , yn) iff (x1, . . . , xn) ≺lex (y1, . . . , yn) or (x1, . . . , xn) = (y1, . . . , yn)

Lemma

If (S, ) is totally ordered then (Sn, lex) is totally ordered

18 / 18