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 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.
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?
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
Part II Model relationship ->disjunctive normal form Car ⟶ Xu Yang ⟶ Car Xu ⟶ Yang 𝐷 ∨ ¬𝑌 ¬𝑍 ∨ ¬𝐷 𝑌 ∨ Y 𝑍 ⟹ ¬𝐷 𝐷 ⟹ 𝑌 ¬𝑌 ⟹ 𝑍 ¬𝑌 ⟹ ¬𝐷 𝐷 ⟹ ¬𝑍 ¬𝑍 ⟹ 𝑌
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
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
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.
Part II Model >1 𝑢𝑝 𝑝 𝐷 0 𝑜𝑝𝑢 𝑢𝑝 𝑝 𝐷𝑏𝑠 >1 𝑜𝑝𝑢 𝑢𝑝 𝑝 ¬𝐷 0 𝑢𝑝 𝑝 1 𝑄 𝑅 𝑄 = 1 ⟹ 𝑅 = 1
Part II Model Friend Car ⟶ Xu 𝐷 ∨ ¬𝑌 𝐷 ⟹ 𝑌 ¬𝑌 ⟹ ¬𝐷
Part II Model Friend Qiu ⟶ Tan
Part II Model Friend Tan ⟶ Qiu
Part II Model Friend Qiu ⟶ Fang
Part II Model Friend Su ⟶ Tan
Part II Model Pair Xu ⟶ Yang 𝑌 ∨ Y ¬𝑌 ⟹ 𝑍 ¬𝑍 ⟹ 𝑌
Part II Model Pair Su ⟶ Qiu
Part II Model Contradiction Yang ⟶ Car ¬𝑍 ∨ ¬𝐷 𝑍 ⟹ ¬𝐷 𝐷 ⟹ ¬𝑍
Part II Model Contradiction Yang ⟶ Tan
Part II Model Obs1 : 𝑣 𝑤 L 𝑤 M 𝑥 ⋯⋯ 1 𝑣 𝑥 ⋯⋯ ⋯⋯ 0
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.
Part II Model Obs3 : ¬𝑣 𝑣 ⋯ ⋯ 𝑣 = 0 𝑣 = 1 ⟹ 𝑣 N = 1
Part II Model Obs4 : ⋯ ⋯ 𝑣 ¬𝑣 ⋯ ⋯
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.
Part III Algorithm
Part III Algorithm
Part III Algorithm
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.
Part III Algorithm 1 1 1 1 1 1
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.
Part IV Existence of possible solution
Part IV Existence of possible solution WHY? • Lemma: If X is at the bottom of a graph, its negation must be on the top. 𝑤 𝑣 𝑥 ¬𝑥 ¬𝑤 ¬𝑣
Part IV Existence of possible solution
Part IV Existence of possible solution
Part IV Existence of possible solution
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.
Part V Find a possible solution 0 1 F ¬F
Part V Find a possible solution 0 1 F ¬F ¬A A
Part V Find a possible solution 0 1 F ¬F ¬A A ¬S S
Part V Find a possible solution 0 1 F ¬F ¬A A ¬S S B ¬B
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
THANK YOU FOR LISTENING Group Aha
Recommend
More recommend