2 sat
play

2-SAT Group Aha 01 Party problem CONTENTS 02 Model 03 Algorithm 04 - PowerPoint PPT Presentation

2-SAT Group Aha 01 Party problem CONTENTS 02 Model 03 Algorithm 04 Existence of possible solution 05 Find a possible solution Part I Party Problem Party Problem There is a party to be held in ACM class. There are three types of


  1. 2-SAT Group Aha

  2. 01 Party problem CONTENTS 02 Model 03 Algorithm 04 Existence of possible solution 05 Find a possible solution

  3. Part I Party Problem Party Problem • There is a party to be held in ACM class. • There are three types of relationship between them. • Friend 𝐵 ⟶ 𝐶 • A think B is his/her friend. So if B go to the party, A will go with B. • Pair 𝐵 ⟶ 𝐶 • A and B are in a same pair, so at least one of them will go to the party. • Contradiction 𝐵 ⟶ 𝐶 • A and B dislike each other, so at most one of the will go the party.

  4. Part I Party Problem Example: • 7 students: • Car(Yang Jiacheng) , Fang Bohui , QiuWenda , Su Yufeng , Tan Bowen , Xu Zhenjia , Yang Zhuolin • Car ⟶ Xu , Qiu ⟶ Tan , Tam ⟶ Qiu , Qiu ⟶ Fang , Su ⟶ Tan • Xu ⟶ Yang , Su ⟶ Qiu • Yang ⟶ Car , Yang ⟶ Tan Do we have an approach to satisfy all the relationships?

  5. Part II Model Variable • Every variable has a value 0 or 1 • Car(Yang Jiacheng) ⟶ C • Fang Bohui ⟶ F • Qiu Wenda ⟶ Q • Su Yufeng ⟶ S • Tan Bowen ⟶ T • Xu Zhenjia ⟶ X • C = 1 means Car will go to the party • Yang Zhuolin ⟶ Y • C = 0 means Car won’t go to the party

  6. Part II Model relationship ->disjunctive normal form Car ⟶ Xu Yang ⟶ Car Xu ⟶ Yang 𝐷 ∨ ¬𝑌 ¬𝑍 ∨ ¬𝐷 𝑌 ∨ Y 𝑍 ⟹ ¬𝐷 𝐷 ⟹ 𝑌 ¬𝑌 ⟹ 𝑍 ¬𝑌 ⟹ ¬𝐷 𝐷 ⟹ ¬𝑍 ¬𝑍 ⟹ 𝑌

  7. Part II Model Relationship • Car ⟶ Xu , Qiu ⟶ Tan , Tam ⟶ Qiu , Qiu ⟶ Fang , Su ⟶ Tan • Xu ⟶ Yang , Su ⟶ Qiu • Yang ⟶ Car , Yang ⟶ Tan (C∨¬X)∧(Q∨¬T)∧(T∨¬Q)∧(Q∨¬F)∧(S∨¬T)∧(X∨Y)∧(S∨Q)∧(¬Y∨¬C)∧(¬Y∨¬T) • So our aim is give each variable a value(0 or 1) to make the expression equals 1

  8. Part II Model Example R = (C∨¬X)∧(Q∨¬T)∧(T∨¬Q)∧(Q∨¬F)∧(S∨¬T)∧(X∨Y)∧(S∨Q)∧(¬Y∨¬C)∧(¬Y∨¬T) • C = 0 • C = 1 • F = 1 • F = 0 • Q = 1 • Q = 1 • S = 1 • S = 1 • T = 1 • T = 1 • X = 0 • X = 1 • Y = 0 • Y = 0 • R = False • R = True

  9. Part III 2-Sat 2-satisfability • In computer science, 2-satisfiability is a computational problem of assigning values to variables, each of which has two possible values, in order to satisfy a system of constraints on pairs of variables.

  10. Part II Model >1 𝑢𝑝 𝑕𝑝 𝐷 0 𝑜𝑝𝑢 𝑢𝑝 𝑕𝑝 𝐷𝑏𝑠 >1 𝑜𝑝𝑢 𝑢𝑝 𝑕𝑝 ¬𝐷 0 𝑢𝑝 𝑕𝑝 1 𝑄 𝑅 𝑄 = 1 ⟹ 𝑅 = 1

  11. Part II Model Friend Car ⟶ Xu 𝐷 ∨ ¬𝑌 𝐷 ⟹ 𝑌 ¬𝑌 ⟹ ¬𝐷

  12. Part II Model Friend Qiu ⟶ Tan

  13. Part II Model Friend Tan ⟶ Qiu

  14. Part II Model Friend Qiu ⟶ Fang

  15. Part II Model Friend Su ⟶ Tan

  16. Part II Model Pair Xu ⟶ Yang 𝑌 ∨ Y ¬𝑌 ⟹ 𝑍 ¬𝑍 ⟹ 𝑌

  17. Part II Model Pair Su ⟶ Qiu

  18. Part II Model Contradiction Yang ⟶ Car ¬𝑍 ∨ ¬𝐷 𝑍 ⟹ ¬𝐷 𝐷 ⟹ ¬𝑍

  19. Part II Model Contradiction Yang ⟶ Tan

  20. Part II Model Obs1 : 𝑣 𝑤 L 𝑤 M 𝑥 ⋯⋯ 1 𝑣 𝑥 ⋯⋯ ⋯⋯ 0

  21. Part II Model Obs2 : SCC(strongly connected component) • In the graph theory, a graph is said to be strongly connected if every vertex is reachable from every other vertex. The strongly connected components of an arbitrary directed graph form a partition into subgraphs that are themselves strongly connected.

  22. Part II Model Obs3 : ¬𝑣 𝑣 ⋯ ⋯ 𝑣 = 0 𝑣 = 1 ⟹ 𝑣 N = 1

  23. Part II Model Obs4 : ⋯ ⋯ 𝑣 ¬𝑣 ⋯ ⋯

  24. Part III Algorithm Algorithm • 1.Construct graph. Find Strongly Connected Components(SCC) of it. • Time complexity: O(m) • 2. Construct the condensation of the implication graph. • 3.Check whether any SCC contains a variable and its negation. • 3.1 if true: Sad. We can’t find a perfect plan. Halt. • 3.2 else: Happy! We can find a perfect plan. • 4. Topologically order the vertices. • 5. Based on the lemma proved before, we can select them from bottom and make a perfect plan.

  25. Part III Algorithm

  26. Part III Algorithm

  27. Part III Algorithm

  28. Part III Algorithm Algorithm • 1.Construct graph. Find Strongly Connected Components(SCC) of it. • Time complexity: O(m) • 2. Construct the condensation of the implication graph. • 3.Check whether any SCC contains a variable and its negation. • 3.1 if true: Sad. We can’t find a perfect plan. Halt. • 3.2 else: Happy! We can find a perfect plan. • 4. Topologically order the vertices. • 5. Based on the lemma proved before, we can select them from bottom and make a perfect plan.

  29. Part III Algorithm 1 1 1 1 1 1

  30. Part III Algorithm Algorithm • 1.Construct graph. Find Strongly Connected Components(SCC) of it. • Time complexity: O(m) • 2. Construct the condensation of the implication graph. • 3.Check whether any SCC contains a variable and its negation. • 3.1 if true: Sad. We can’t find a perfect plan. Halt. • 3.2 else: Happy! We can find a perfect plan. • 4. Topologically order the vertices. • 5. Based on the lemma proved before, we can select them from bottom and make a perfect plan.

  31. Part IV Existence of possible solution

  32. Part IV Existence of possible solution WHY? • Lemma: If X is at the bottom of a graph, its negation must be on the top. 𝑤 𝑣 𝑥 ¬𝑥 ¬𝑤 ¬𝑣

  33. Part IV Existence of possible solution

  34. Part IV Existence of possible solution

  35. Part IV Existence of possible solution

  36. Part III Algorithm Algorithm • 1.Construct graph. Find Strongly Connected Components(SCC) of it. • Time complexity: O(m) • 2. Construct the condensation of the implication graph. • 3.Check whether any SCC contains a variable and its negation. • 3.1 if true: Sad. We can’t find a perfect plan. Halt. • 3.2 else: Happy! We can find a perfect plan. • 4. Topologically order the vertices. • 5. Based on the lemma proved before, we can select them from bottom and make a perfect plan.

  37. Part V Find a possible solution 0 1 F ¬F

  38. Part V Find a possible solution 0 1 F ¬F ¬A A

  39. Part V Find a possible solution 0 1 F ¬F ¬A A ¬S S

  40. Part V Find a possible solution 0 1 F ¬F ¬A A ¬S S B ¬B

  41. Part V Find a possible solution • C = 1 A 0 1 • F = 0 F ¬F B ¬B • Q = 1 ¬A A • S = 1 • T = 1 ¬S S ¬A • X = 1 B ¬B • Y = 0

  42. THANK YOU FOR LISTENING Group Aha

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend