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

2 sat
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

2-SAT

Group Aha

slide-2
SLIDE 2

CONTENTS

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

slide-3
SLIDE 3

Part I 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.

Party Problem

slide-4
SLIDE 4

Part I Party Problem

  • 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?

Example:

slide-5
SLIDE 5

Part II Model

  • 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
  • Yang Zhuolin⟶ Y

Variable

  • C = 1 means Car will go to the party
  • C = 0 means Car won’t go to the party
slide-6
SLIDE 6

Part II Model

relationship ->disjunctive normal form

Xu ⟶ Yang 𝑌 ∨ Y ¬𝑌 ⟹ 𝑍 ¬𝑍 ⟹ 𝑌 Yang ⟶ Car ¬𝑍 ∨ ¬𝐷 𝑍 ⟹ ¬𝐷 𝐷 ⟹ ¬𝑍 Car ⟶ Xu 𝐷 ∨ ¬𝑌 𝐷 ⟹ 𝑌 ¬𝑌 ⟹ ¬𝐷

slide-7
SLIDE 7

Part II Model

  • So our aim is give each variable a value(0 or 1) to make the expression

equals 1

Relationship

(C∨¬X)∧(Q∨¬T)∧(T∨¬Q)∧(Q∨¬F)∧(S∨¬T)∧(X∨Y)∧(S∨Q)∧(¬Y∨¬C)∧(¬Y∨¬T)

  • Car⟶ Xu,Qiu ⟶Tan,Tam ⟶Qiu,Qiu ⟶Fang,Su ⟶Tan
  • Xu ⟶Yang,Su ⟶Qiu
  • Yang ⟶Car,Yang ⟶Tan
slide-8
SLIDE 8

Part II Model

  • C = 1
  • F = 0
  • Q = 1
  • S = 1
  • T = 1
  • X = 1
  • Y = 0
  • R = True

Example

  • C = 0
  • F = 1
  • Q = 1
  • S = 1
  • T = 1
  • X = 0
  • Y = 0
  • R = False

R = (C∨¬X)∧(Q∨¬T)∧(T∨¬Q)∧(Q∨¬F)∧(S∨¬T)∧(X∨Y)∧(S∨Q)∧(¬Y∨¬C)∧(¬Y∨¬T)

slide-9
SLIDE 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.

slide-10
SLIDE 10

Part II Model

𝐷𝑏𝑠

𝐷 ¬𝐷

>1 𝑢𝑝 𝑕𝑝 0 𝑜𝑝𝑢 𝑢𝑝 𝑕𝑝 >1 𝑜𝑝𝑢 𝑢𝑝 𝑕𝑝 0 𝑢𝑝 𝑕𝑝

𝑄 𝑅

1 𝑄 = 1 ⟹ 𝑅 = 1

slide-11
SLIDE 11

Part II Model

Friend

Car ⟶ Xu 𝐷 ∨ ¬𝑌 𝐷 ⟹ 𝑌 ¬𝑌 ⟹ ¬𝐷

slide-12
SLIDE 12

Part II Model

Friend

Qiu ⟶ Tan

slide-13
SLIDE 13

Part II Model

Friend

Tan ⟶ Qiu

slide-14
SLIDE 14

Part II Model

Friend

Qiu ⟶ Fang

slide-15
SLIDE 15

Part II Model

Friend

Su ⟶ Tan

slide-16
SLIDE 16

Part II Model

Pair

Xu ⟶ Yang 𝑌 ∨ Y ¬𝑌 ⟹ 𝑍 ¬𝑍 ⟹ 𝑌

slide-17
SLIDE 17

Part II Model

Pair

Su ⟶ Qiu

slide-18
SLIDE 18

Part II Model

Contradiction

Yang ⟶ Car ¬𝑍 ∨ ¬𝐷 𝑍 ⟹ ¬𝐷 𝐷 ⟹ ¬𝑍

slide-19
SLIDE 19

Part II Model

Contradiction

Yang ⟶ Tan

slide-20
SLIDE 20

Part II Model

Obs1 :

𝑣

⋯⋯

𝑥

1

⋯⋯

𝑣 𝑤L 𝑤M 𝑥

⋯⋯

slide-21
SLIDE 21

Part II Model

Obs2 :

  • 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.

SCC(strongly connected component)

slide-22
SLIDE 22

Part II Model

Obs3 : 𝑣 ⋯ ⋯

𝑣 = 0

𝑣 = 1 ⟹ 𝑣 N = 1

¬𝑣

slide-23
SLIDE 23

Part II Model

Obs4 : 𝑣 ⋯ ⋯ ¬𝑣 ⋯ ⋯

slide-24
SLIDE 24

Part III 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.

Algorithm

slide-25
SLIDE 25

Part III Algorithm

slide-26
SLIDE 26

Part III Algorithm

slide-27
SLIDE 27

Part III Algorithm

slide-28
SLIDE 28

Part III 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.

Algorithm

slide-29
SLIDE 29

Part III Algorithm

1 1 1 1 1 1

slide-30
SLIDE 30

Part III 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.

Algorithm

slide-31
SLIDE 31

Part IV Existence of possible solution

slide-32
SLIDE 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.

𝑣 𝑤 𝑥 ¬𝑣 ¬𝑤 ¬𝑥

slide-33
SLIDE 33

Part IV Existence of possible solution

slide-34
SLIDE 34

Part IV Existence of possible solution

slide-35
SLIDE 35

Part IV Existence of possible solution

slide-36
SLIDE 36

Part III 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.

Algorithm

slide-37
SLIDE 37

Part V Find a possible solution 1

¬F F

slide-38
SLIDE 38

Part V Find a possible solution 1

¬F F ¬A A

slide-39
SLIDE 39

Part V Find a possible solution 1

¬F F ¬A A S ¬S

slide-40
SLIDE 40

Part V Find a possible solution 1

¬F F ¬A A S ¬S B ¬B

slide-41
SLIDE 41

Part V Find a possible solution

  • C = 1
  • F = 0
  • Q = 1
  • S = 1
  • T = 1
  • X = 1
  • Y = 0

A ¬A B ¬B

1

¬F F ¬A A S ¬S B ¬B

slide-42
SLIDE 42

THANK YOU FOR LISTENING

Group Aha