Discrete Mathematics -- Chapter 7: Relations: The Ch t 7 R l ti - - PowerPoint PPT Presentation

discrete mathematics
SMART_READER_LITE
LIVE PREVIEW

Discrete Mathematics -- Chapter 7: Relations: The Ch t 7 R l ti - - PowerPoint PPT Presentation

Discrete Mathematics -- Chapter 7: Relations: The Ch t 7 R l ti Th Second Time Round Hung-Yu Kao ( ) Department of Computer Science and Information Engineering, N National Cheng Kung University l Ch K U Outline Relations


slide-1
SLIDE 1

Discrete Mathematics

Ch t 7 R l ti Th

  • - Chapter 7: Relations: The

Second Time Round

Hung-Yu Kao (高宏宇) Department of Computer Science and Information Engineering, N l Ch K U National Cheng Kung University

slide-2
SLIDE 2

Outline

Relations Revisited: Properties of Relations Computer Recognition: Zero-One Matrices and

Computer Recognition: Zero One Matrices and Directed Graphs

Partial Orders: Hasse Diagrams Partial Orders: Hasse Diagrams Equivalence Relations and Partitions

Fi it St t M hi Th Mi i i ti P

Finite State Machine: The Minimization Process

Application of equivalence relation Minimization process: find a machine with the same

function but fewer internal states

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

2

slide-3
SLIDE 3

7.1 Relations Revisited: Properties of p Relations

  • Definition 7.1: For sets A, B, any subset of A × B is called a (binary)

relation from A to B. Any subset of A × A is called a (binary) relation

  • n A
  • n A .
  • Ex 7.1

D fi th l ti ℜ th t Z b ℜb if ≤ b

  • Define the relation ℜ on the set Z by aℜb, if a ≤ b.
  • For x, y∈Z and n∈Z+, the modulo n relation ℜ is defined by xℜy if

x - y is a multiple of n, e.g., with n=7, 9ℜ2, -3ℜ11, but 3 ℜ 7

  • Ex 7.2 : Language A ⊆ Σ∗. For x, y∈A, define xℜy if x is a prefix of y.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

3

slide-4
SLIDE 4

Relations Revisited: Properties of p Relations

  • Finite state machine M = (S, I, O, v, w)
  • Reachability
  • s1ℜs2 if v(s1, x) = s2, x∈I. ℜ denotes the first level of

reachability.

  • s1ℜs2 if v(s1, x1x2) = s2, x1x2 ∈I2. ℜ denotes the second level of

1 2

( 1,

1 2) 2, 1 2

reachability.

  • Equivalence

1 i l l ti E if ( ) ( ) f I

  • 1-equivalence relation: s1E1s2 if w(s1, x) = w(s2, x) for x∈I.
  • k-equivalence relation: s1Eks2 if w(s1, y) = w(s2, y) for y∈Ik.
  • If two states are k-equivalent for all k ∈Z+, they are called

q

, y equivalent.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

4

slide-5
SLIDE 5

Reflexive

  • Definition 7.2: A relation ℜ on a set A is called reflexive if (x,

x)∈ℜ, for all x∈A.

  • Ex 7 4 : For A = {1 2 3 4} a relation ℜ ⊆ A×A will be reflexive
  • Ex 7.4 : For A = {1, 2, 3, 4}, a relation ℜ ⊆ A×A will be reflexive

if and only if ℜ ⊇ {(1, 1), (2, 2), (3, 3), (4, 4)}. But ℜ1 = {(1, 1), (2, 2), (3, 3)} is not reflexive, ℜ2 = {(x, y)| x ≤ y, x, y∈A} is reflexive reflexive.

  • Ex 7.5 : Given a finite set A with |A| = n, we have |A×A| = n2, so

there are relations on A. Among them are reflexive.

2

2n

) (

2

2

n n −

there are relations on A. Among them are reflexive.

  • A = {a1, a2,…, an}
  • A×A = {(ai, aj)|1 ≤ i, j≤ n} = A1∪A2

2

A A 一定要留著

{( i

j)|

j }

1 2

  • A1 = {(ai, ai)|1 ≤ i ≤ n}
  • A2 = {(ai, aj)|i ≠ j, 1 ≤ i, j≤ n}

A1 (n) A2 (n2-n) A×A

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

5

(n2)

slide-6
SLIDE 6

Symmetric

  • Definition 7.3: A relation ℜ on a set A is called symmetric if for

all x, y∈A, (x, y)∈ℜ ⇒ (y, x)∈ℜ .

  • Ex 7.6 : A = {1, 2, 3}
  • ℜ1 = {(1, 2), (2, 1), (1, 3), (3, 1)}, symmetric, but not reflexive.
  • ℜ2 = {(1, 1), (2, 2), (3, 3), (2, 3)}, reflexive, but not symmetric.
  • ℜ3 = {(1, 1), (2, 2), (3, 3)} and ℜ4 = {(1, 1), (2, 2), (3, 3), (2, 3),

(3, 2)}, both reflexive and symmetric. (3, 2)}, both reflexive and symmetric.

  • ℜ5 = {(1, 1), (2, 3), (3, 3)}, neither reflexive nor symmetric.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

6

slide-7
SLIDE 7

Symmetric

To count the symmetric relations on A = {a1, a2,…, an}.

  • A×A = A1∪A2, A1 = {(ai, ai)|1 ≤ i ≤ n}, A2 = {(ai, aj)|i ≠ j, 1 ≤ i, j ≤ n}
  • A contains n pairs and A contains n2 n pairs
  • A1 contains n pairs, and A2 contains n2-n pairs.
  • A2 contains (n2-n)/2 subsets Si,j of the form {(ai, aj), (aj, ai)⎪i < j}.
  • So, we have totally symmetric relations on A.

) )( 2 / 1 (

2

2 2

n n n −

×

If the relations are both reflexive and symmetric, we have

choices

) )( 2 / 1 (

2

2

n n −

choices.

A1 (n) A2 (n2-n) 1 A×A (n2)

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

7

slide-8
SLIDE 8

Transitive

Definition 7.4: A relation ℜ on a set A is called transitive

if (x, y), (y, z)∈ℜ ⇒ (x, z)∈ℜ for all x, y, z∈A.

Ex 7.8 : Define the relation ℜ on the set Z+ by aℜb if a

divides b. This is a transitive and reflexive relation but not symmetric.

Ex 7.9 : Define the relation ℜ on the set Z by aℜb if

a×b≥0. What properties do they have?

Reflexive, symmetric Not transitive, e.g., (3,0),(0,-7) ∈ℜ, but (3,-7) not

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

8

slide-9
SLIDE 9

Antisymmetric

Definition 7.5: A relation ℜ on a set A is called antisymmetric if (x,

y)∈ℜ and (y, x)∈ℜ ⇒ x = y for all x, y∈A.

  • Both a related to b and b related to a if a and b are one and the same
  • Both a related to b and b related to a if a and b are one and the same

element from A E 7 11 D fi

th l ti (A B) ℜ if A B Th it i ti

  • Ex 7.11 : Define the relation (A, B)∈ℜ if A⊆B. Then it is an anti-

symmetric relation.

Note that “not symmetric” is different from anti-symmetric.

  • Ex 7.12 : A = {1, 2, 3}, what properties do the following relations on A

have? have?

  • ℜ={(1, 2), (2, 1), (2, 3)} (not symmetric, not antisymmetric)
  • ℜ={(1, 1), (2, 2)} (symmetric and antisymmetric)

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

9

slide-10
SLIDE 10

Antisymmetric

To count the antisymmetric relations on A = {a1, a2,…, an}.

  • A×A = A1∪A2, A1 = {(ai, ai)|1 ≤ i ≤ n}, A2 = {(ai, aj)|i ≠ j, 1 ≤ i, j ≤ n}
  • A1 contains n pairs, and A2 contains n2-n pairs.

1 co ta s n pa s, a d 2 co ta s n n pa s.

  • A2 contains (n2-n)/2 subsets Si,j of the form {(ai, aj), (aj, ai)⎪i < j}.
  • Each element in A1 can be selected or not.
  • Each element in S can be selected in three alternatives: either (a a )
  • Each element in Si,j can be selected in three alternatives: either (ai, aj),
  • r (aj, ai), or none.
  • So, we have totally anti-symmetric relations on A.

) )( 2 / 1 (

2

3 2

n n n −

×

A1 (n) A2 (n2-n) (n) (n -n) A×A (n2)

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

10

slide-11
SLIDE 11

Antisymmetric

  • Ex 7.13 : Define the relation ℜ on the functions by f ℜ g if f is dominated

by g (or f∈ O(g)). What are their properties?

Reflexive Transitive not symmetric (e.g., g=n, f =n2, g=O(f), but f ≠O(g)) not antisymmetric (e.g., g(n)= n, f(n) = n+5, fℜg and gℜf, but

f ≠g)

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

11

slide-12
SLIDE 12

Partial Order

Definition 7.6: A relation ℜ is called a partial order

(partial ordering relation), if ℜ is reflexive, anti-symmetric d t iti and transitive.

(A,R) is a partially ordered set / poset if R is a partial

  • rdering on A. Typical notation: (A,≤); think “no loops”.

If a≤b or b≤a, the elements a and b are comparable. If all pairs are comparable, ≤ is a total ordering or chain.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

12

slide-13
SLIDE 13

Partial Order

  • Ex 7.15 : Let A be the set of positive integers divisors of n, the

relation ℜ on A by aℜb if a divides b, it defines a partial order. How many ordered pairs does it occur in ℜ. many ordered pairs does it occur in ℜ.

  • E.g. A = {1, 2, 3, 4, 6, 12}, ℜ = {(1, 1), (1, 2), (1, 3), (1, 4), (1, 6), (1, 12), (2, 2),

(2, 4), (2, 6), (2, 12), (3, 3), (3, 6), (3, 12), (4, 4), (4, 12), (6, 6), (6, 12), (12, 12)}

  • If (a, b) ∈ ℜ, then a = 2m.3n and b = 2p.3q with 0 ≤ m ≤ p ≤ 2, 0 ≤ n ≤ q ≤ 1.
  • Selection of size 2 from a set of size 3, with repetition.

( ) ( ) ( ) ( )

pairs

  • rdered

18 3 6 total , for 3 ; , for 6

2 3 2 1 2 2 2 4 2 1 2 3

= ⋅ = ∴ = = = =

− + − +

q n p m

  • For

pairs

  • rdered

18 3 6 total = = ∴

( ) ( )

∏ ∏

+ = − + + ⋅ ⋅ ⋅

= ⇒ =

k e k e p p p

i i k e k e e

n

2 2 2 1 2 ) 1 (

pairs

  • rdered
  • f

number the

2 2 1 1

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

13

= = i i 1 1

Maximal element

slide-14
SLIDE 14

Equivalence relation

  • Definition 7.7. A relation ℜ is called an equivalence relation, if ℜ is

reflexive, symmetric and transitive.

Given an equivalence relation R on A, for each a∈A the equivalence

class [a] is defined by {x | (x,a)∈R }.

  • E.g., Modulo 3 equivalences on Z , such that

g , q , [0] = {…,–6,–3,0,3,6,…} and [1] = {…,–5,–2,1,4,7,…}

  • Ex 7.16 (b): If A = {1, 2, 3}, the following are all equivalence relations

Ex 7.16 (b): If A {1, 2, 3}, the following are all equivalence relations

ℜ1 = {(1, 1), (2, 2), (3, 3)} ℜ2 = {(1, 1), (2, 2), (3, 3), (2, 3), (3,2)}

ℜ {(1 1) (1 3) (2 2) (3 1) (3 3)}

ℜ3 = {(1, 1), (1, 3), (2, 2), (3, 1), (3, 3)} ℜ4 = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

14

slide-15
SLIDE 15

Examples

  • Ex 7.16 (c): For a finite set A, A×A is the largest equivalence relation on A.

If A = {a1, a2, …, an}, then the equality relation ℜ = {(ai, ai)|1 ≤ i ≤ n} is the smallest equivalence relation on A.

  • Ex 7.16 (d): Let A = {1, 2, 3, 4, 5, 6, 7}, B = {x, y, z}, and f : A → B be the
  • nto function. f = {(1, x), (2, z), (3, x), (4, y), (5, z), (6, y), (7, x)}.

Define the relation ℜ on A by aℜb if f(a) = f(b) Define the relation ℜ on A by aℜb if f(a) = f(b). ℜ is reflexive, symmetric, and transitive, so it is an equivalence relation. (e.g., f(a)=f(b), f(b)=f(c)=> f(a)=f(c))

  • Ex 7.16 (e): If ℜ is a relation on A, then ℜ is both an equivalence relation

and a partial order relation iff ℜ is the equality relation on A.

  • equality relation {(ai ai)| ai ∈A}
  • equality relation {(ai, ai)| ai ∈A}

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

15

slide-16
SLIDE 16

7.2 Computer Recognition: Zero-One p g Matrices and Directed Graphs

  • Definition 7.8: Let relations ℜ1⊆A×B and ℜ2⊆B×C. The composite relation

ℜ1°ℜ2 is a relation defined by ℜ1°ℜ2 = {(x, z)| ∃y ∈B such that (x, y)∈ℜ1 and (y z)∈ℜ2 and (y, z)∈ℜ2.

(Note the different ordering with function composition.) f : A B, g : B C, g。f : A C

  • Ex 7.17 : Consider ℜ1={(1, x), (2, x), (3, y), (3, z)} and ℜ2={(w, 5), (x, 6)},

d ℜ {( 5) ( 6)} ℜ ℜ {(1 6) (2 6)} d ℜ ℜ ? ∅ and ℜ3={(w, 5), (w, 6)}. ℜ1°ℜ2 = {(1, 6), (2, 6)}, and ℜ1°ℜ3 = ?

  • Ex 7.18 : Let A be the set of employees {L. Alldredge,…} at a computer

center, while B denotes a set of programming language {C++, Java,…},

p g g g g { } and C is a set of projects {p1, p2,…}, consider ℜ1⊆A×B, ℜ2⊆B×C. What is the means of ℜ1°ℜ2 ?

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

16

slide-17
SLIDE 17

Composite Relation

  • Theorem 7.1: ℜ1⊆A×B, ℜ2⊆B×C, and ℜ3⊆C×D ⇒ ℜ1° (ℜ2°ℜ3) = (ℜ1°ℜ2)

°ℜ3

  • Definition 7 9 We define the powers of relation ℜ by (a) ℜ1 ℜ; (b)
  • Definition 7.9. We define the powers of relation ℜ by (a) ℜ1=ℜ; (b)

ℜn+1=ℜ°ℜn.

  • Ex 7.19 : If ℜ = {(1, 2), (1, 3), (2, 4), (3, 2)}, then ℜ2 = {(1, 4), (1, 2), (3,

4)}, ℜ3 = ? and ℜ4 = ?

ℜ3 = {(1,4)} {( , )} and for n ≥ 4, ℜn=∅

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

17

slide-18
SLIDE 18

Relation Matrix

  • Definition 7.10: An m×n zero-one matrix E = (eij)m×n is a rectangular array of

numbers arranged in m rows and n columns, where each eij denotes the entry in the ith row and jth column of E, and each such entry is 0 or 1.

  • Relation matrix: A relation can be represented by an m×n zero one matrix
  • Relation matrix: A relation can be represented by an m×n zero-one matrix.
  • Ex 7.21 : Consider ℜ1= {(1, x), (2, x), (3, y), (3, z)}, ℜ2= {(w, 5), (x, 6)}, and

ℜ1°ℜ2 to be represented by relation matrices?

1 2

p y

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

18

Boolean addition’ with 1+1=1

slide-19
SLIDE 19

Relation Matrix

Ex 7.22: If ℜ={(1, 2), (1, 3), (2, 4), (3, 2)}, then what are the

relation matrices of ℜ2, ℜ3 and ℜ4?

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

19

slide-20
SLIDE 20

Relation Matrix

  • Let A be a set with⏐A⏐= n and ℜ be a relation on A. If M(ℜ) is the relation

matrix for ℜ, then

M(ℜ) = 0 if and only if ℜ = φ M(ℜ) 0 if and only if ℜ

φ.

M(ℜ) = 1 if and only if ℜ = A×A. M(ℜm) = [M(ℜ)]m

( ) [ ( )]

  • Definition 7.11: Let E =(eij)m×n, F =(fij)m×n be two mxn ero-one matrices.

We say that E precedes, or is less than, F, written as E ≤ F, if eij ≤ fij for all i, j.

  • Ex 7.23 : E ≤ F. How many zero-one matrices G do have the results of E ≤

G? G? ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = 1 1 1 E ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = 1 1 1 1 F

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

20

23=8

slide-21
SLIDE 21

Relation Matrix

Definition 7.12: In = (δij)n×n is the n×n zero-one matrix, where

⎩ ⎨ ⎧ ≠ = = , if , , if , 1 j i j i

ij

δ

Definition 7.13: A = (aij)m×n is a zero-one matrix, the transpose of

A, written Atr, is the matrix (a*ji)n×m where a*ji = aij

⎩ , , j

  • Ex 7.24 :

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = 1 1 1

tr

A

⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ = 1 1 1 A Theorem 7.2: If M denote the relation matrix for ℜ on A, then

(A) ℜ is reflexive if and only if In ≤ M.

⎥ ⎦ ⎢ ⎣ 1 1

( ) y

n

(B) ℜ is symmetric if and only if M = Mtr. (C) ℜ is transitive if and only if M2 ≤ M. (D) ℜ is anti-symmetric if and only if M∩Mtr ≤ In.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

21

(D) ℜ is anti symmetric if and only if M∩M ≤ In.

slide-22
SLIDE 22

Directed Graph

  • Definition 7.14. A directed graph can be denoted as G = (V, E), where V is

the vertex set and E is the edge set.

  • (a b): if a b∈ V (a b)∈E then there is a edge from a to b Vertex a is called
  • (a, b): if a, b∈ V (a, b)∈E, then there is a edge from a to b. Vertex a is called

source (origin) of the edge, and b is terminating vertex.

  • (a, a): is called a loop.
  • V = {1, 2, 3, 4, 5}, E = {(1, 1), (1, 2), (1, 4), (3, 2)}
  • Isolated vertex: vertex 5 in Fig. 7.1.
  • Single undirected edge {a, b} = {b, a} in Fig. 7.2 (b) is used to represent
  • Single undirected edge {a, b} {b, a} in Fig. 7.2 (b) is used to represent

the two directed edges shown in Fig. 7.2 (a).

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

22

slide-23
SLIDE 23

Directed Graph

Ex 7.26 precedence graph

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

23

slide-24
SLIDE 24

Directed Graph

  • Ex 7 27 : R = {(1 1) (1 2) (2 3) (3 2) (3 3) (3 4) (4 2)}
  • Ex 7.27 : R = {(1,1),(1,2),(2,3),(3,2),(3,3),(3,4),(4,2)}
  • directed graph in Fig. 7.4 (a)
  • (associated) undirected graph in Fig. 7.4 (b)
  • path: In the connected graph any two vertices x y with x ≠ y there is a path
  • path: In the connected graph, any two vertices x, y, with x ≠ y, there is a path

starting at x and ending at y.

  • cycle: a closed path starts and terminates at the same vertex, containing at

least three edges.

  • E.g.: {3, 4}, {4, 2}, and {2, 3}

No repeated vertex

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

24

slide-25
SLIDE 25

Directed Graph

  • Definition 7.15: A directed graph G on V is called strongly connected, if

for all x, y ∈ V, where x ≠ y, there is a path (in G) of directed edges from x to y.

Fi 7 5

  • e.g., Fig. 7.5
  • Disconnected graph: is the union of two connected pieces called the

components of the graph.

Fi 7 6

  • e.g., Fig. 7.6

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

25

slide-26
SLIDE 26

Directed Graph

Complete graph: the graphs of ndirected graphs that are loop free and

  • Complete graph: the graphs of undirected graphs that are loop-free and

have an edge for every pair of distinct vertices, which are denoted by Kn.

  • e.g., Fig. 7.7

K K

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

26

K1 K2 K3 K4 K5

slide-27
SLIDE 27

Directed Graph

  • Ex 7.30 : ℜ is reflexive if and only if its directed graph contains a loop at

each vertex.

  • e.g., Fig 7.8, A = {1, 2, 3} and ℜ = {(1,1), (1, 2), (2, 2), (3, 3), (3, 1)}

e.g., Fig 7.8, A {1, 2, 3} and ℜ {(1,1), (1, 2), (2, 2), (3, 3), (3, 1)}

  • Ex 7.31 : ℜ is symmetric if and only if its directed graph may be drawn
  • nly by loops and undirected edges.
  • e g Fig 7 9 A = {1 2 3} and ℜ = {(1 1) (1 2) (2 1) (2 3) (3 2)}
  • e.g., Fig 7.9, A = {1, 2, 3} and ℜ = {(1,1), (1, 2), (2, 1), (2, 3), (3, 2)}
  • Ex 7.32 : ℜ is anti-symmetric if and only if for any x ≠ y the graph

contains at most one of the edges (x, y) or (y, x)

Fi 7 10 A {1 2 3} d ℜ {(1 1) (1 2) (2 3) (1 3)}

  • e.g., Fig 7.10, A = {1, 2, 3} and ℜ = {(1,1), (1, 2), (2, 3), (1, 3)}

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

27

slide-28
SLIDE 28

Directed Graph

  • Ex 7.32 : ℜ is transitive if and only if for all x, y ∈ A, if there is a path

from x to y in the associated graph, then there is an edge (x, y) also.

  • e.g., Fig 7.10, A = {1, 2, 3} and ℜ = {(1, 1), (1, 2), (2, 3), (1, 3)}

e.g., Fig 7.10, A {1, 2, 3} and ℜ {(1, 1), (1, 2), (2, 3), (1, 3)}

  • Ex 7.33 : Fig 7.11, a relation is an equivalence relation if and only if its

graph is one complete graph augmented by loops at every vertex or consists of disjoint union of complete graphs augmented by loops at each consists of disjoint union of complete graphs augmented by loops at each vertex.

  • e.g., Fig 7.11, A = {1, 2, 3, 4, 5} and ℜ1 = {(1,1), (1, 2), (2, 1), (2, 2), (3, 3), (3,

4), (4, 3), (4, 4), (5, 5)}, ℜ2 = {(1,1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 4), (4, 3), (4, 4), (5, 5)}, ℜ2 {(1,1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3), (4, 4), (4, 5), (5, 4) (5, 5)}.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

28

slide-29
SLIDE 29

Directed Graph

reflexive: loop on each vertex symmetric: undirected edge + loops transitive: two paths equivalence: disjoint union of complete graphs + directed graphs relations loops at every vertex directed graphs relations adjacency matrices relation matrices

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

29

slide-30
SLIDE 30

7.3 Partial Orders: Hasse Diagrams

Definition: Let A be a set with ℜ a relation on A. The pair (A,

ℜ) is called a partially ordered set, or poset, if relation ℜ on A is partially ordered A is partially ordered.

  • If A is called a poset, we understand that there is a partially order ℜ on

A that makes A into this set.

natural counting: N x+5 2 : Z Something was lost when we went x+5=2 : Z 2x+3=4 : Q x2-2=0 : R Something was lost when we went from R to C. We have lost the ability to "order" the elements in C. x 2 0 : R x2+1=0 : C 2+i < 1+2i ?

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

30

slide-31
SLIDE 31

7.3 Partial Orders: Hasse Diagrams

Ex 7.34 : Let A be the set of courses offered at a college. Define

the relation ℜ on A by xℜy if x, y are the same course or if x is a prerequisite for y. a p e equ s te o y.

Ex 7.35 : Define ℜ on A = {1, 2, 3, 4} by xℜy if x divide y.

Then ℜ = {(1 1) (2 2) (3 3) (4 4) (1 2) (1 3) (1 4) (2 Then ℜ = {(1, 1), (2, 2), (3, 3), (4, 4), (1, 2), (1, 3), (1, 4), (2, 4)} is a partial order, and (A, ℜ) is a poset.

Ex 7.36 : PERT (Program Evaluation and Review Technique)

network is first used by U.S. Navy in 1950.

E.g., Let A be the set of tasks that must be performed to build a

g , p

  • house. Define the relation ℜ on A by xℜy if x, y are the same task
  • r if x must be performed before y.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

31

slide-32
SLIDE 32

Partial Orders: Hasse Diagrams

Ex 7.37 : Figure 7.17 (b) illustrates a simpler diagram for

(a), called the Hasse diagram. The directions are assumed to go from the bottom to the top assumed to go from the bottom to the top.

X

not partial order 1 2 1 3

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

32

slide-33
SLIDE 33

Hasse Diagram g

If (A, ℜ) is a poset, we construct a Hasse diagram for ℜ on A

by drawing a line segment from x up to y, if

  • xℜy
  • there is no other z such that xℜz and zℜy. (in between x and y)
  • Ex 7.38 : In Fig. 7.18 we have the Hasse diagrams for the

following four posets following four posets.

  • (a) ℜ is the subset relation on A is the power set of Ų with Ų = {1, 2, 3}
  • (b), (c), and (d) are the divide relations.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

33

slide-34
SLIDE 34

Totally Ordered

  • Definition 7.16. If (A, ℜ) is a poset, we say that A is totally
  • rdered (linearly ordered) if for all x, y ∈A either xℜy or yℜx.

In this case ℜ is called a total order In this case, ℜ is called a total order.

  • Ex 7.40

a)

On the set N, the relation ℜ defined by xℜy if x ≤ y is a total order.

b)

The subset relation is a partial

)

p

  • rder but not total order,

e.g., {1, 2}, {1, 3} ∈ A, but {1, 2} ⊄ {1, 3}

  • r {1, 3} ⊄ {1, 2}.

c)

Fig 7.19 is a total order.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

34

slide-35
SLIDE 35

Topological Sorting

Given a Hasse diagram for a partial order relation ℜ, how to

find a total order ℑ for which ℜ⊆ℑ.

N 12

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

35

Not unique, 12 answers

slide-36
SLIDE 36

Topological Sorting

For a partial order ℜ on a set A with |A| = n

Step 1: Set k = 1. Let H1 be the Hasse diagram of the partial order. Step 2: Select a vertex vk in Hk such that no edge in Hk starts at vk. Step 3: If k = n, the process is completed and we have a total

  • rder
  • rder

ℑ : vn < vn-1 < … < v1 that contains ℜ. If k < th f H th t d ll d f H

If k < n, then remove from Hk the vertex vk and all edges of Hk

that terminate at vk. Call the result Hk+1. Increase k by 1 and return to step (2).

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

36

slide-37
SLIDE 37

EX: Dressing in the morning

Topological Sort

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

37

slide-38
SLIDE 38

DFS sequence

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

38

slide-39
SLIDE 39

Maximal and Minimal

Definition 7.17: If (A, ℜ) is a poset, then x is a maximal element of

A if for all a∈A, a ≠ x ⇒ x

  • a. Similarly, y is a minimal element of

A if for all b∈A b ≠ y ⇒ b y

ℜ / ℜ /

A if for all b∈A, b ≠ y ⇒ b y.

Ex 7.42 : Ų = {1, 2, 3}, A = P(Ų).

For the poset (A, ⊆), Ų is the maximal and

ℜ /

φ is the minimal.

Let B be the proper subsets of {1, 2, 3}.

Then we have multiple maximal elements Then we have multiple maximal elements {1, 2}, {1, 3}, and {2, 3} for the poset (B, ⊆), and φ is still the only minimal element.

E 7 43 F

th t (Z ≤) h ith i l

Ex 7.43 : For the poset (Z, ≤), we have neither a maximal nor a

minimal element. The poset (N, ≤), has no maximal element but a minimal element 0.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

39

slide-40
SLIDE 40

Maximal and Minimal

E 7 44 H

b h i (b) ( ) d (d) f Fi 7 18? D

Ex 7.44 : How about the poset in (b), (c), and (d) of Fig. 7.18? Do

they have maximal or minimal elements?

Theorem 7.3: If (A, ℜ) is a poset and A is finite, then A has both a

( , ) p , maximal and a minimal element.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

40

slide-41
SLIDE 41

Least and Greatest

D fi iti 7 18 If (A ℜ) i t th i l t l t f A if f

Definition 7.18: If (A, ℜ) is a poset, then x is a least element of A if for

all a∈A, xℜa. Similarly, y is a greatest element of A if for all a∈A, aℜy.

Ex 7.45 : Ų = {1, 2, 3}, A = P(Ų).

Ų { , , }, (Ų)

  • For the poset (A, ⊆), Ų is the greatest and φ is the least.
  • Let B be the nonempty subsets of Ų. Then we have Ų as the greatest

element and three minimal elements for the poset (B ⊆) but no least element and three minimal elements for the poset (B, ⊆), but no least element.

Theorem 7.4: If poset (A, ℜ) has a greatest or a least element, then that

l t i i element is unique.

  • Proof: Assume x and y are both greatest elements.

Since x is a greatest element, yℜx. Likewise, xℜy while y is a greatest element. As ℜ is antisymmetric, it follows x = y.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

41

slide-42
SLIDE 42

Lower and Upper Bound

Definition 7.19: If (A, ℜ) is a poset with

B⊆A, then

  • x∈A is called a lower bound of B if xℜb for all
  • x∈A is called a lower bound of B if xℜb for all

b∈B

  • y∈A is called an upper bound of B if bℜy for

all b∈B

A

upper bond

ub ub

An element x′∈A is called a greatest lower

bound (glb) of B if for all other lower bounds x″

lub lub

ub ub ub ub

(g )

  • f B we have x″ℜx′. Similarly, an element x′∈A

is called a least upper bound (lub) of B if for all

  • ther upper bounds x″ of B we have x′ℜx″.

B

Theorem 7.5: If (A, ℜ) is a poset and B⊆A, then

B has at most one lub (glb).

lower bond

glb glb

lb lb lb lb lb lb

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

42

(g )

lower bond

slide-43
SLIDE 43

Lower and Upper Bound

Ex 7.47 : Let U ={1, 2, 3, 4} with A = P(U ) and let ℜ be the subset

relation on B. If B = {{1}, {2}, {1, 2}}, then what are the upper bounds of B, lower bounds of B, the greatest lower bound and the least upper bound?

Upper bounds: {1, 2}, {1, 2, 3}, {1, 2, 4}, and {1, 2, 3, 4} lub: {1 2} lub: {1, 2} glb = φ

{2, 3, 4} is not.

Ex 7.48 : Let ℜ be the “≤” relation on A. What are the results for the

following cases?

A = R and B = [0, 1] => lub:1, glb:0

A R and B [0, 1] lub:1, glb:0

A = R and B = {q∈Q⏐q2<2} => A = Q and B = {q∈Q⏐q2<2} => ?

2

  • :

glb , 2 : lub

No lub and glb

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

43

slide-44
SLIDE 44

Lattice

  • Definition 7.20. The poset (A, ℜ) is called a lattice if for all x, y∈A the

elements lub{x, y} and glb{x, y} both exist in A.

  • Ex 7.49 : For A = N and x, y∈N, define xℜy by x ≤ y. Then lub{x, y} =

max{x, y}, glb{x, y} = min{x, y}, and (N, ≤) is a lattice.

  • Ex 7.50 : For the poset (P(U ), ⊆), if S, T⊆U , we have lub{S, T} = S∪T

and glb{S, T} = S∩T and it is a lattice.

  • Ex 7.51: consider the poset in Example 7.38(d). Here we find that lub{2, 3}

= 6 exists, but there is no glb for the elements 2 and 3.

  • This partial order is not a lattice.

Lattice Total order

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

44

OK

slide-45
SLIDE 45

7.4 Equivalence q Relations and Partitions

For any set A ≠ φ, the relation of equality is an

equivalence relation on A.

Let the relation on Z defined by xℜy if x-y is a multiple of

Let the relation on Z defined by xℜy if x y is a multiple of 2, then ℜ is an equivalence relation on Z, where all even integers are related, as are all odd integers. g g

The above relation splits Z into two subsets:

{…, -3, -1, 1, 3,…} ∪ {…, -4, -2, 0, 2, 4,…}

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

45

slide-46
SLIDE 46

Partition

Definition 7.21. Given a set A and index set I, let φ ≠ Ai ⊆

A for i∈I.

Then {Ai}i∈I is a partition of A if (a) A = ∪i∈IAi and (b) Ai∩Aj = φ

for i ≠ j.

Each subset Ai is called a cell (block) of the partition. Each subset Ai is called a cell (block) of the partition.

Ex 7.52 : A = {1, 2,…,10}

Ex 7.52 : A {1, 2,…,10}

A1 = {1, 2, 3, 4, 5}, A2 = {6, 7, 8, 9, 10}. Ai = {i, i+5}, 1 ≤ i ≤ 5.

Ex 7.53 : Let A = R, for each i∈Z,

let Ai = [i, i+1). Then {Ai}i∈Z is a partition of R.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

46

slide-47
SLIDE 47

Equivalence Class

  • Definition 7.22: Let ℜ be an equivalence relation on a set A. For each x∈A,

the equivalence class of x, denoted [x], is defined by [x] = {y∈A⏐yℜx}

  • Ex 7.54 : Define the relation ℜ on Z by xℜy if 4⏐(x-y).

[0] = {…, -8, -4, 0, 4, …} = {4k|k ∈ Z}

xℜy?

[0] {…, 8, 4, 0, 4, …} {4k|k ∈ Z} [1] = {…, -7, -3, 1, 5, …} = {4k+1|k ∈ Z} [2] = {…, -6, -2, 2, 6, …} = {4k+2|k ∈ Z}

[ ] { , , , , , } { | }

[3] = {…, -5, -1, 3, 7, …} = {4k+3|k ∈ Z}

  • Ex 7.55 : Define the relation ℜ on Z by aℜb if a2=b2, ℜ is an equivalence

relation.

  • [n] = [-n] = {-n, n}

}) { ( } { n n Z − ∪ ∪ =

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

47

}) , { ( } { n n Z

Z n∪

∪ =

+

slide-48
SLIDE 48

Equivalence Class

  • Theorem 7.6: If ℜ is an equivalence relation on a set A and x, y∈A, then
  • (a) x∈[x]
  • (b) xℜy if and only if [x] = [y]
  • (c) [x] = [y] or [x]∩[y]=φ. (identical or disjoint)
  • Ex 7.56 :
  • Ex 7.56 :
  • Let A = {1, 2, 3, 4, 5}, ℜ={(1, 1), (2, 2), (2, 3), (3, 2), (3, 3), (4, 4), (4, 5), (5, 4),

(5, 5)}. [1] = {1}, [2] = {2, 3}=[3], [4] = {4, 5} = [5]. Then, we have A=[1]∪[2]∪[4]. C id f i f A B f({1 3 7}) f({4 6}) f({2 5})

  • Consider an onto function f: A→B. f({1, 3, 7}) = x; f({4, 6}) = y; f({2, 5}) = z.

The relation ℜ defined on A by aℜb if f(a) = f(b).

  • A = [1]∪[4]∪[2] = f--1(x) ∪ f--1(y) ∪ f--1(z).
  • Ex 7.58 : If an equivalence relation ℜ on A = {1, 2, 3, 4, 5, 6, 7} induces the

partition A = {1, 2}∪ {3}∪{4, 5, 7}∪{6}, what is ℜ?

  • [1] = {1, 2} = [2] = {(1, 1), (2, 2), (1, 2), (2, 1)}

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

48

[ ] { , } [ ] {( , ), ( , ), ( , ), ( , )}

  • ℜ=({1,2}x{1,2}) ∪ ({3} x{3}}∪({4, 5, 7}x{4, 5, 7})∪({6}x{6})

{(1,1), (2,2)} v.s. {1,2}x{1,2}

slide-49
SLIDE 49

Equivalence and Partition

  • Theorem 7.7: If A is a set, then
  • (a) any equivalence relation ℜ on A induces a partition of A; and
  • (b) an partition of A gi es rise to an eq i alence relation ℜ on A
  • (b) any partition of A gives rise to an equivalence relation ℜ on A.
  • Theorem 7.8: For any set A, there is one-to-one correspondence between

the set of equivalence relations on A and the set of partitions of A.

Ex 7.59 :

( ) f { } h l i i l l i

  • (a) If A= {1, 2, 3, 4, 5, 6}, how many relations on A are equivalence relations?

(identical containers)

  • a partition of A: a distribution of the (distinct) elements of A into identical

h l f

6

containers with no container left empty

  • (b) How many of the equivalence relations in part (a) satisfy 1, 2 ∈ [4]?

∑ =

=

6 1

203 ) , 6 (

i

i S

4

15 ) 4 ( i S

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

49

∑ =

=

1

15 ) , 4 (

i

i S

slide-50
SLIDE 50

Equivalence and Partition

n1 n2 n3 nk

A k2 A 22 (k 2)2 X

n1 n2 n3 nk

A 22+(k-2)2 r partitions?

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

50

slide-51
SLIDE 51

7.5 Finite State Machines: The Minimization Process

Two finite state machines of the same function may have

different number of internal states.

Some of these states are redundant.

A process of transforming a given machine into one that

has no redundant internal states is called the minimization process.

Rely on the concepts of equivalence relation and partition.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

51

slide-52
SLIDE 52

Finite State Machines: The Minimization Process

1-Equivlence: Given the finite state machine M = {S,

I, O, v, w}, we define the relation E1 on S by s1E1s2 if ( ) ( ) f ll I if w(s1, x) = w(s2, x) for all x∈I.

The relation E1 is an equivalence relation on S, and

it partitions S into subsets such that two states are in it partitions S into subsets such that two states are in the same subset if they produce the same output for each x∈I.

Here s1 and s2 are called 1-equivlent.

1 2

q

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

52

slide-53
SLIDE 53

Finite State Machines: The Minimization Process

For the states S, we define the k-equivalence relation Ek

  • n S by s1Eks2 if w(s1, x) = w(s2, x) for all x∈Ik.

The relation Ek is an equivalence relation on S, and it

partitions S into subsets such that two states are in the same subset if they produce the same output for each x∈Ik.

We call two states s1 and s2 equivalent if they are k-

equivalent for all k ≥ 1. q

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

53

slide-54
SLIDE 54

Finite State Machines: The Minimization Process

Goal: Determine the partition of S induced by E and

select one state for each equivalent class.

Observations:

If two states are not 2-equivalent, they can not be 3-equivalent.

q y q

For s1, s2∈S, where s1Eks2, we find that s1Ek+1s2 if and only if v(s1,

x)Ekv(s2, x) for all x∈I.

Ik x∈Ik S1 x∈Ik-1 I x∈I x∈Ik x∈I S2 x∈I

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

54

x∈Ik x∈Ik

slide-55
SLIDE 55

An Algorithm for the Minimization of a Finite State Machine

1.

Set k = 1. s1E1s2 when s1 and s2 have the same output

  • rows. (Pi be the partitions of S induced by Ei)

2.

Having determined Pk, we want to obtain Pk+1. Determine the states that are (k+1)-equivalent. Note that if s1Eks2, then s1Ek+1s2 if and only if v(s1, x)Ekv(s2, x) for all x∈I.

3.

If Pk+1 = Pk, the process is completed. If Pk+1 ≠ Pk, k = k+1, goto step 2.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

55

slide-56
SLIDE 56

Minimization of a Finite State Machine

Ex 7.60 : M is given by the state table shown in Table 7.1.

  • Looking at the output rows: which states are 1-equivalent?

P titi S P { } { } { }

  • P1 partitions S as P1:{s1}, {s2, s5, s6}, {s3, s4}
  • P2: {s1}, {s2, s5}, {s6}, {s3, s4} (Table 7.2), P2 ≠ P1, continue
  • P3: {s1}, {s2, s5}, {s6}, {s3, s4}, P3 = P2, stop

3 { 1}, { 2, 5}, { 6}, { 3, 4}, 3 2,

p

0,1 s6 1 s2,s5 , s1 0 1 s3,s4 1 0,1

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

56

1

See also 15.2 Karnaugh Maps, a similar idea

slide-57
SLIDE 57

More Minimization example

I E 6 20 C

t t hi th t i h f

  • In Ex 6.20 : Construct a machine that recognizes each occurrence of

the sequence 111.

v w

0, 0 1, 0 1, 1 1, 0

v w 1 1

s0 s1 s2

Start 1, 0 1, 0 0, 0 0 0

s0 s0 s1 s1 s0 s2

0, 0

s2 s0 s3 1 s3 s0 s3 1 s3 s0 s3 1

P1: {s0, s1}, {s2, s3} P : {s } {s } {s s }

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

57

P2: {s0}, {s1}, {s2, s3} P3: {s0}, {s1}, {s2, s3}

slide-58
SLIDE 58

Refinement

Definition 7.23: If P1 and P2 are partitions of set A,

then P2 is called a refinement of P1, denoted as P2

2 1 2

≤ P1, if every cell of P2 is contained in a cell of P1. When P2 ≤ P1 and P2 ≠ P1, we write P2 < P1.

In Example 7.60, P3 = P2 < P1

Theorem 7.9: In the minimization process, if Pk+1

= Pk, then P +1 = P for all r ≥ k+1. Pk, then Pr+1 Pr for all r ≥ k+1.

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

58

slide-59
SLIDE 59

Distinguishing String

If s1Eks2 but s1Ek+1s2, then we have a string x =

x1x2…xkxk+1∈Ik+1 such that w(s1, x) ≠ w(s2, x) but x1x2…xkxk+1∈I such that w(s1, x) ≠ w(s2, x) but w(s1, x1x2…xk) = w(s2, x1x2…xk). We call this string x as distinguishing string string x as distinguishing string.

s1Ek+1s2 ⇒ ∃x1∈I [v(s1, x1) Ek v(s2, x1)]

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

59

slide-60
SLIDE 60

Distinguishing String

Ex 7.61 : From Example 7.60, s2E1s6 but s2E2s6, so we seek a

distinguishing string of length 2.

x = 00 is the minimal distinguishing string for s2 and s6 w(s2, 00) =11≠ 10 = w(s6, 00)

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

60

slide-61
SLIDE 61

Distinguishing String

Ex 7.62 : s1 and s4 are 2-equivalent but are not 3-equivalent.

x = 111 is the minimal distinguishing string for s1 and s4

w(s1, 111) =100 ≠ 101 = w(s4, 111)

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

61

slide-62
SLIDE 62

Exercise

7-1: 10, 12, 14 7 2: 20 22 7-2: 20, 22 7-3: 14, 18, 28(a) 7-4: 12 7-5: 1(c) 3 (1 3兩題都要寫過程) 7 5: 1(c), 3 (1,3兩題都要寫過程)

Discrete Mathematics Discrete Mathematics – – CH7 CH7 2009 Spring 2009 Spring

62