1 / 53

關係 : 第二回

Chapter 7. 關係 : 第二回. Equivalence Classes. 7.1 Relations Revisited: Properties of Relations. Ex. 7.3 考慮一個有限狀態機 M =( S , I , O , v , w ). (a) 對 s 1 , s 2 ∈ S , 定義 s 1 R s 2 若 v ( s 1 , x )= s 2 對某些 x ∈ I . 關係 R 建立第一層可達性 (b) 對 S , 第二層可達性的關係亦可被給。 這裡 s 1 R s 2

Télécharger la présentation

關係 : 第二回

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 7 關係:第二回 Equivalence Classes

  2. 7.1 Relations Revisited: Properties of Relations Ex. 7.3 考慮一個有限狀態機M=(S,I,O,v,w). (a) 對s1,s2∈S, 定義s1Rs2若v(s1,x)=s2對某些x∈I. 關係 R建立第一層可達性 (b)對S,第二層可達性的關係亦可被給。這裡 s1Rs2 若v(s1,x1x2)=s2對某些x1x2∈I2. 這個可被擴大到較高層次 ,若需要出現。對一般的可達性,還有v(s1,y)=s2 對某些y∈I*. (c)給s1,s2∈ S, 1-等價的關係,表為s1E1s2, 被定義為當 w(s1,x)=w(s2,x) 對所有x є I. 這個概念可被擴大至狀態是 k-等價,其中我們寫s1Eks2若 w(s1,y)=w(s2,y) 對所有y є Ik. 若兩個狀態是 k-等價,對所有k∈ Z+, 則他們被稱為平價.

  3. 7.1 Relations Revisited: Properties of Relations Def7.2 一個集合A上的關係被稱是反身性(reflexive)的,若對所有x∈ A, (x,x) ∈ R.

  4. 7.1 Relations Revisited: Properties of Relations Ex. 7.6 以A={1,2,3}, 我們有: (a) R1={(1,2),(2,1),(1,3),(3,1)},是A上一個對稱但沒有反身的關係; (b) R2={(1,1),(2,2),(3,3),(2,3)}, 是A上一個反身的但非對稱的關係; (c) R3={(1,1),(2,2),(3,3)}, R4={(1,1),(2,2),(3,3),(2,3),(3,2)}, 是A上兩個既反身且對稱的關係; (d) R5={(1,1),(2,3),(3,3)}, 是A上既不反身也不對稱的關係

  5. 7.1 Relations Revisited: Properties of Relations

  6. 7.1 Relations Revisited: Properties of Relations 例題. 7.8 定義集合Z+上的關係R為aRb,若a為整除b. 則R是遞移的、反身的,但非對稱(例如2R6,但不是 6R2)

  7. 7.1 Relations Revisited: Properties of Relations

  8. 7.1 Relations Revisited: Properties of Relations 定義. 7.6 集合A 上的關係 R被稱為是一個偏序(partial order), 或是一個偏序關係,若R是反身的、反對稱的及遞移的. (若在A上任何a,b的全序(total order) , 任何一個a Rb 或bRa). Ex. 7.15. 定義 R 的關係在 Z+上,且aRb若a恰恰好整除 b. R 是一個偏序. Def. 7.7集合A上的一個等價關係R是一個反身的、對稱的及遞移 的關係 例如: aRb if a mod n=b mod n 這個相等關係(equality relation){(ai,ai)|ai in A}是一個偏序且 全等的關係(equivalence relation)

  9. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs (Note the different ordering with function composition.) Ex. 7.17 A={1,2,3,4}, B={w,x,y,z}, 及C={5,6,7}. 考慮 R1={(1,x),(2,x),(3,y),(3,z)}, 一個由A到B的關係, 且 R2= {(w,5),(x,6)}, 一個由B到C的關係. 則 R1 R2={(1,6),(2,6)} 是一個由A到C 的關係.

  10. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs

  11. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs Ex. 7.21 A={1,2,3,4}, B={w,x,y,z}, 及 C={5,6,7}. R1={(1,x),(2,x),(3,y),(3,z)}, A到B的關係且 R2= {(w,5),(x,6)}, B到C的關係. 矩陣關係

  12. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs 令A的集合,|A|=n且A上的一個關係 R. 若M(R) 是一個 R的 關係矩陣, 則 (a) M(R)=0 (所有為元素為0的矩陣) 若且唯若R= Ø (b) M(R)=1 (所有元素為1的矩陣) 若且唯若 R=AA (c) M(Rm)=[M(R)}m, 對m∈ Z+.

  13. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs

  14. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs

  15. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs

  16. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs Def. 7.14 有向圖G=(V,E) (Digraph) Ex. 7.25 一個迴圈 V={1,2,3,4,5} E={(1,1),(1,2),(1,4),(3,2)} 2 1 4 3 5 孤立點(node) 1 .2是連接的 . 2 .1是連接的. 無向圖:沒有方向的邊

  17. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs Ex. 7.26 作一個有向圖G=(V,E), 令 V={s1, s2, s3, s4, s5, s6, s7, s8}且(si, sj)在E裡 若si必須在sj前先執行. (s1) b:=3; (s2) c:=b+2; (s3) a:=1; s5 s7 (s4) d:=a*b+5; 程序圖 (precedence graph( (s5) e:=d-1; (s6) f:=7; s4 s2 s8 (s7) e:=c+d; (s8) g:=b*f; s3 s1 s6 前驅 constraint scheduling 一般, n任務, m處理程序: NP-complete m=2:多項的 m=3:開放問題 3 處理程序: 3時間組件 2 處理程序: 4時間組件

  18. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs Ex. 7.27 relations and digraphs A={1,2,3,4}, R={(1,1),(1,2),(2,3),(3,2),(3,3),(3,4),(4,2)} 連接圖:在任兩個點之間 有一條路徑( path) 2 2 1 1 3 3 path: 不重複的邊 4 4 有向圖 組合的無向圖 cycle: 一個封閉的路徑(起點 和終點是一樣的) Def. 7.15強連通(有向圖) 在任意兩點之間必有一個有向路徑 上圖不是強連通. (在3到1之間沒有有向路徑)

  19. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs Ex. 7.28分量( Components) 1 1 2 2 3 3 4 4 一個分量 兩個分量 Ex. 7.29 完全圖: Kn (n個點有 n(n-1)/2 個邊) K5 K1 K2 K3 K4

  20. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs 有向圖 關係 相鄰矩陣 關係矩陣 Ex. 7.30 若 R 是集合A 上的有限關係, 則 R是反身性的,唯若 且若這個有向圖包含一個迴路在每個 Ex. 7.31 A 關係R在有限集合A上是對稱的,為若且若有向圖只包 函迴圈和無向圖 Ex. 7.31 A 關係R在集合A上的有限關係是有遞移性的,為若且若 在有向圖若由 x到 y有路徑,則(x,y) 是一個邊. 關係 R 在集合A上的有限關係是反對稱的,為若且若,除了自己 迴圈外沒有無向邊.

  21. 7.2 Computer Recognition: Zero-One Matrices and Directed Graphs Ex. 7.33 A 關係在有限集合A上是一個全等關係,為若且若 組合的 (無向的) 邊是一個完全圖且增加迴圈在點或 每個頂點有迴圈由不相交的完全圖聯集 (disjoint union of complete graphs) 反身性(reflexive): 在每個點上的迴圈 對稱性(symmetric): 無向邊 遞移性(transitive):若由 x到 y有路徑,則(x,y) 是一個邊.

  22. 7.3 Partial Orders: Hasse Diagrams 自然數 : N x+5=2 : Z 2x+3=4 : Q x2-2=0 : R x2+1=0 : C 當我們要從R到C ,有些事被遺忘. 我們忘記了如何去“order”(序) 這個元素 在C上. L令A唯一個集合且 R 是A上的關係. 這個序對(A,R) 被稱為 偏序集(partially order set), 或poset, 若關係 R 是一個偏序集. Ex. 7.34 令A為某學校開設的課程. 定義AR為xRy若x,y 為相同課程或x為y的先修課程. 即R 使 A成為一個偏序集

  23. 7.3 Partial Orders: Hasse Diagrams Ex. 7.36 效能評估技術 PERT (Performance Evaluation and Review Technique) A poset J4 J3 J7 J1 J6 J5 J2 找出每個工作最早的開始時間和最晚的開始時間 這些工作早相等於晚是關鍵的. 所有關鍵工作從關鍵路徑而來

  24. 7.3 Partial Orders: Hasse Diagrams 不是偏序 2 1 2 3 1 不是反對稱的 不是遞移關係或不是反對稱的 Ex. 7.37 Hasse diagram Read bottom up. reflexivity and transitive links are not shown. 4 4 2 3 2 3 一個偏序 1 1 corresponding Hasse diagram

  25. 7.3 Partial Orders: Hasse Diagrams Ex. 7.38 {1,2,3} 相等關係 385 8 12 {1,2} {1,3} {2,3} 35 4 6 2 3 5 7 {1} {2} {3} 2 3 5 11 2 7 1 恰好整除關係 子集合關係

  26. 7.3 Partial Orders: Hasse Diagrams Def. 7.16 若 (A,R) 是一個偏序, 我們可以構造A是一個全序,若 對所有x,y∈AxRy或yRx. 滿足這些條件的 R 被稱為全序. For example, <,> 是N,Z,Q,R的全序. 但C是偏序. 但是我們可以用一些方法列出偏序集嗎? 全序集合排序(sorting for a totally ordered set)

  27. 7.3 Partial Orders: Hasse Diagrams 對偏序集的拓樸排序(topological sorting) F G D 不會違背偏序原則下, 在一定時間上如何執行個工作上的排序? C A For example, BEACGFD, EBACFGD, ... B E Hasse diagram for a set of tasks

  28. 7.3 Partial Orders: Hasse Diagrams 拓樸分類順序 (線性伸展) d c a^bc^d: 2 jumps a^bd^c: 2 jumps b^ac^d: 2 jumps b^a^d^c: 3 jumps bd^ ac: 1 jumps 找出現性伸展 與最小的跳躍. b a (an NP-complete problem)

  29. 7.3 Partial Orders: Hasse Diagrams

  30. 7.3 Partial Orders: Hasse Diagrams Ex.7.43 {1,2,3}max max 385 8 max 12 {1,2} {1,3} {2,3} max and min 35 4 6 2 3 5 7 {1} {2} {3} 2 3 5 11 2 7 min 1 min min unique max and min

  31. 7.3 Partial Orders: Hasse Diagrams 在拓樸分類, 每個時間我們發現一個極大元 或每個時間我們發現一個極小元.

  32. 7.3 Partial Orders: Hasse Diagrams

  33. 7.3 Partial Orders: Hasse Diagrams Theorem 7.4 如果偏序集 (A,R) 有一個最大(最小)元素則 是獨一無二的. Proof: 假定x,y在A而且也是最大元素. 即 (x,y) 且(y,x) 都是在 R 裡. 因 R 是反對稱的,所以 x=y.既最大元素唯一,同理最小元是唯一,證明相似

  34. Ex. 7.46 令U={1,2,3,4}, 具有A=P(U), 令 R 為 A 上的 子集合關係. 若B={{1},{2},{1,2}}, 則 {1,2}, {1,2,3}, {1,2,4}, {1,2,3,4} 均為B的上界(在A裡) ,而 {1,2} 是一個最小上界(在B裡). 同時, B的最大下界是Ø, 且Ø 不在B裡. 7.3 Partial Orders: Hasse Diagrams

  35. 7.3 Partial Orders: Hasse Diagrams Ex. 7.47 令R是 “小於或等於”關係偏序集 (A,R). (a) 若 A=R且B=[0,1] 或 [1,0) 或 (0,1] 或 (0,1), 即B有glb 0 和 lub 1. (b) 若A=R, B={q in Q|q2<2}. 即B = 當lub 和- as glb, 且也不在B 裡. (c) A=Q, 且B為(b)的一部分. 則B沒有 lub 或 glb.

  36. 7.3 Partial Orders: Hasse Diagrams

  37. 7.3 Partial Orders: 各定義比較

  38. 7.4 Equivalence Relations and Partitions

  39. 7.4 Equivalence Relations and Partitions

  40. 7.4 Equivalence Relations and Partitions

  41. 7.4 Equivalence Relations and Partitions Ex. 7.58 若 R是A上的一個等價關係={1,2,3,4,5,6,7} 歸納 出分割 ? R是什麼? Theorem 7.7 若A是一個集合, 則 (a)A上的任一個等價 R 引出A 個一個分割, 且 (b) A 的任意分割給出A 上的一個等價關係R.. Theorem 7.8 對任意集合A, 則存在一個一對一應介於A上的等價 關係集合及A的分割集合之間.

  42. 7.4 Equivalence Relations and Partitions

  43. 7.5 Finite State Machines: The Minimization Process s1,s2 i ∈S, 這個狀態稱為1-等價, 定義S上的關係, E1為 s1E1s2, 是被定義成當w(s1,x)=w(s2,x) 對所有x在I裡. 對每個k∈Z, 我們說狀態s1,s2為k-等價為, where s1Eks2 if w(s1,y)=w(s2,y) for all y in Ik. 若兩個狀態是k-等價,對於所有的k∈ Z+, 則被稱為等價的 , 表示為s1Es2. Hence 我們客觀的決定 S的分割,並對每個 等價關係 E 挑選一個狀態,則我們將有一個以隻機器極 小話認知.

  44. 7.5 Finite State Machines: The Minimization Process observations: (1) 若機器裡的兩個狀態不是2-等價, 他們可能為 3-等價嗎? 一般來說, 欲求 (k+1)-等價, 我們會觀察k-等價的狀態

  45. 7.5 Finite State Machines: The Minimization Process observations:

  46. 7.5 Finite State Machines: The Minimization Process Ex. 7.60 step 1: 對定義1-等價狀態詢問 輸出 v w 0 1 0 1 P1: {s1},{s2,s5,s6},{s3,s4} s1s4s3 0 1 s2s5s2 1 0 s3s2s4 0 0 s4s5s3 0 0 s5s2s5 1 0 s6s1s6 1 0 A B input 0 C s5 s2 s1 s2 s5 P2: {s1},{s2,s5},{s6},{s3,s4} D input 1 s2 s5 s4 s3 P3=P2, 這個過程4 個狀態是完全的.

  47. 7.5 Finite State Machines: The Minimization Process 能夠做出P3=P2, 但P3=P4嗎?

  48. 7.5 Finite State Machines: The Minimization Process

More Related