On the Quest for an Acyclic Graph s Janota 1 Radu Grigore 2 Vasco - - PowerPoint PPT Presentation

on the quest for an acyclic graph
SMART_READER_LITE
LIVE PREVIEW

On the Quest for an Acyclic Graph s Janota 1 Radu Grigore 2 Vasco - - PowerPoint PPT Presentation

On the Quest for an Acyclic Graph s Janota 1 Radu Grigore 2 Vasco Manquinho 1 Mikol a RCRA 2017, Bari 1 INESC-ID/IST, University of Lisbon, Portugal 2 School of Computing, University of Kent, UK Janota et al On the Quest for an Acyclic


slide-1
SLIDE 1

On the Quest for an Acyclic Graph

Mikol´ aˇ s Janota1 Radu Grigore2 Vasco Manquinho1 RCRA 2017, Bari

1 INESC-ID/IST, University of Lisbon, Portugal 2 School of Computing, University of Kent, UK Janota et al On the Quest for an Acyclic Graph 1 / 16

slide-2
SLIDE 2

Introduction

  • We wish to reason over directed graphs in SAT/QBF/SMT.

Janota et al On the Quest for an Acyclic Graph 2 / 16

slide-3
SLIDE 3

Introduction

  • We wish to reason over directed graphs in SAT/QBF/SMT.
  • Each graph corresponds to a binary relation.

Janota et al On the Quest for an Acyclic Graph 2 / 16

slide-4
SLIDE 4

Introduction

  • We wish to reason over directed graphs in SAT/QBF/SMT.
  • Each graph corresponds to a binary relation.
  • Graphs are model with Boolean variables representing edges.

Janota et al On the Quest for an Acyclic Graph 2 / 16

slide-5
SLIDE 5

Introduction

  • We wish to reason over directed graphs in SAT/QBF/SMT.
  • Each graph corresponds to a binary relation.
  • Graphs are model with Boolean variables representing edges.
  • A variable eij is true iff there is an edge from i to j in the

considered graph.

Janota et al On the Quest for an Acyclic Graph 2 / 16

slide-6
SLIDE 6

Introduction

  • We wish to reason over directed graphs in SAT/QBF/SMT.
  • Each graph corresponds to a binary relation.
  • Graphs are model with Boolean variables representing edges.
  • A variable eij is true iff there is an edge from i to j in the

considered graph. Example (e12 ∨ e13) ∧ (¬e12 ∨ ¬e13) ∧ e23 ∧ ¬e32 ∧ ¬e21 1 2 3 1 2 3 1 2 3 1 2 3

Janota et al On the Quest for an Acyclic Graph 2 / 16

slide-7
SLIDE 7

Objective: Avoid Cycles

  • Given a formula ϕ determining a set of graphs

generate a formula ϕ′ that only considers those of in ϕ but with no cycles.

Janota et al On the Quest for an Acyclic Graph 3 / 16

slide-8
SLIDE 8

Objective: Avoid Cycles

  • Given a formula ϕ determining a set of graphs

generate a formula ϕ′ that only considers those of in ϕ but with no cycles.

  • Modular approach: devise a checker formula ψ s.t. ϕ′ = ϕ ∧ ψ.

Janota et al On the Quest for an Acyclic Graph 3 / 16

slide-9
SLIDE 9

Example: Memory Models

s t a r t s t a t e : r1=r2=x=y=0 thread 1: x := 1 r1 := y thread 2: y := 1 r0 := x

  • Question: Is state r1=r2=0 possible at the end?

Janota et al On the Quest for an Acyclic Graph 4 / 16

slide-10
SLIDE 10

Example: Memory Models

s t a r t s t a t e : r1=r2=x=y=0 thread 1: x := 1 r1 := y thread 2: y := 1 r0 := x

  • Question: Is state r1=r2=0 possible at the end?
  • Answer: NO with interleavings, but

YES with many relaxed/weak memory models.

Janota et al On the Quest for an Acyclic Graph 4 / 16

slide-11
SLIDE 11

Example: Memory Models

s t a r t s t a t e : r1=r2=x=y=0 thread 1: x := 1 r1 := y thread 2: y := 1 r0 := x

  • Question: Is state r1=r2=0 possible at the end?
  • Answer: NO with interleavings, but

YES with many relaxed/weak memory models.

  • We are using a QBF solver in this application, acyclic relations

are required.

Janota et al On the Quest for an Acyclic Graph 4 / 16

slide-12
SLIDE 12

Example: No-Sink Family

  • A well-ordered set must have a greatest element.

Janota et al On the Quest for an Acyclic Graph 5 / 16

slide-13
SLIDE 13

Example: No-Sink Family

  • A well-ordered set must have a greatest element.
  • If each node as at least one outgoing edge,

there must be a cycle.

Janota et al On the Quest for an Acyclic Graph 5 / 16

slide-14
SLIDE 14

Example: No-Sink Family

  • A well-ordered set must have a greatest element.
  • If each node as at least one outgoing edge,

there must be a cycle.

  • Together with acyclicity, the following is UNSAT:
  • i∈[n]
  • j∈[n]

eij

Janota et al On the Quest for an Acyclic Graph 5 / 16

slide-15
SLIDE 15

Example: The Supervisor Problem

  • Consider n employees;

Janota et al On the Quest for an Acyclic Graph 6 / 16

slide-16
SLIDE 16

Example: The Supervisor Problem

  • Consider n employees;
  • . . . employee i can supervise at most ui other employees;

Janota et al On the Quest for an Acyclic Graph 6 / 16

slide-17
SLIDE 17

Example: The Supervisor Problem

  • Consider n employees;
  • . . . employee i can supervise at most ui other employees;
  • . . . employee i is supervised by at least li other employees;

Janota et al On the Quest for an Acyclic Graph 6 / 16

slide-18
SLIDE 18

Example: The Supervisor Problem

  • Consider n employees;
  • . . . employee i can supervise at most ui other employees;
  • . . . employee i is supervised by at least li other employees;
  • . . . there may be no cycles in the supervision relation.

Janota et al On the Quest for an Acyclic Graph 6 / 16

slide-19
SLIDE 19

Example: The Supervisor Problem

  • Consider n employees;
  • . . . employee i can supervise at most ui other employees;
  • . . . employee i is supervised by at least li other employees;
  • . . . there may be no cycles in the supervision relation.
  • NP-complete [Hartung and Nichterlein, 2015]

Janota et al On the Quest for an Acyclic Graph 6 / 16

slide-20
SLIDE 20

Example: The Supervisor Problem

  • Consider n employees;
  • . . . employee i can supervise at most ui other employees;
  • . . . employee i is supervised by at least li other employees;
  • . . . there may be no cycles in the supervision relation.
  • NP-complete [Hartung and Nichterlein, 2015]
  • Note: no-sink is special case. There is no solution if everyone

is to have at least one supervisor.

Janota et al On the Quest for an Acyclic Graph 6 / 16

slide-21
SLIDE 21

Encoding: Transitive Closure

  • Idea: Generate a transitive closure of the edge relation and

disable self-loops.

Janota et al On the Quest for an Acyclic Graph 7 / 16

slide-22
SLIDE 22

Encoding: Transitive Closure

  • Idea: Generate a transitive closure of the edge relation and

disable self-loops.

  • Transitive closure I

ψn( e, y ) :=

  • i∈[n]

¬yii ∧

  • i,j,k∈[n]

(yij ∧ yjk ⇒ yik) ∧

  • i,j∈[n]

(eij ⇒ yij)

Janota et al On the Quest for an Acyclic Graph 7 / 16

slide-23
SLIDE 23

Encoding: Transitive Closure

  • Idea: Generate a transitive closure of the edge relation and

disable self-loops.

  • Transitive closure I

ψn( e, y ) :=

  • i∈[n]

¬yii ∧

  • i,j,k∈[n]

(yij ∧ yjk ⇒ yik) ∧

  • i,j∈[n]

(eij ⇒ yij)

  • Transitive closure II

ψn( e, y ) :=

  • i∈[n]

¬yii ∧

  • i,j,k∈[n]

(yij ∧ ejk ⇒ yik) ∧

  • i,j∈[n]

(eij ⇒ yij)

Janota et al On the Quest for an Acyclic Graph 7 / 16

slide-24
SLIDE 24

Encoding: Unary/Binary labeling

  • Idea: Any DAG can be topologically sorted.

Janota et al On the Quest for an Acyclic Graph 8 / 16

slide-25
SLIDE 25

Encoding: Unary/Binary labeling

  • Idea: Any DAG can be topologically sorted.
  • Label each node with a number l ∈ 1..|V | such that it is

connected only to nodes with a greater label. ψn( e, y1, . . . , yn) :=

  • i,j∈[n]
  • eij ⇒ less(

yi, yj)

  • Janota et al

On the Quest for an Acyclic Graph 8 / 16

slide-26
SLIDE 26

Encoding: Unary/Binary labeling (Cont.)

  • Comparison for binary encoding (n⌈log2 n⌉ variables).

lex0() := 0 lexb( yy, zz) := (¬y ∧ z) ∨

  • (¬y ∨ z) ∧ lexb−1(

y, z )

  • Janota et al

On the Quest for an Acyclic Graph 9 / 16

slide-27
SLIDE 27

Encoding: Unary/Binary labeling (Cont.)

  • Comparison for binary encoding (n⌈log2 n⌉ variables).

lex0() := 0 lexb( yy, zz) := (¬y ∧ z) ∨

  • (¬y ∨ z) ∧ lexb−1(

y, z )

  • Comparison for unary encoding (n2 variables):

lessunr( y, z, u ) :=

n−1

  • i=1
  • (¬yi ∨ ¬ui) ∧ (zi ∨ ¬ui)

n−1

  • i=1

ui unary( y ) :=

n−1

  • i=2

(yi−1 ⇒ yi)

Janota et al On the Quest for an Acyclic Graph 9 / 16

slide-28
SLIDE 28

Encoding: Warshall algorithm Based

Idea: Perform an “unrolling” of the Floyd-Warshall. Warshall 1 for k ∈ [n] 2 for i ∈ [n] 3 for j ∈ [n] 4 aij := Or(aij, And(aik, akj))

Janota et al On the Quest for an Acyclic Graph 10 / 16

slide-29
SLIDE 29

Encoding: Warshall algorithm Based

Idea: Perform an “unrolling” of the Floyd-Warshall. Warshall 1 for k ∈ [n] 2 for i ∈ [n] 3 for j ∈ [n] 4 aij := Or(aij, And(aik, akj)) ψn( x, y) :=

  • i∈[n]

¬yiin ∧

  • i,j∈[n]

(xij ⇒ yij0) ∧

  • i,j,k∈[n]

(yij(k−1) ⇒ yijk) ∧

  • i,j,k∈[n]

(yik(k−1) ∧ ykj(k−1) ⇒ yijk)

Janota et al On the Quest for an Acyclic Graph 10 / 16

slide-30
SLIDE 30

Encoding: Matrix Multiplication

  • Idea: Simulate matrix multiplication

Janota et al On the Quest for an Acyclic Graph 11 / 16

slide-31
SLIDE 31

Encoding: Matrix Multiplication

  • Idea: Simulate matrix multiplication
  • Strassen algorithm permits less than cubic multiplication

Janota et al On the Quest for an Acyclic Graph 11 / 16

slide-32
SLIDE 32

Encoding: Matrix Multiplication

  • Idea: Simulate matrix multiplication
  • Strassen algorithm permits less than cubic multiplication
  • Hard to efficiently encode into circuits.

Janota et al On the Quest for an Acyclic Graph 11 / 16

slide-33
SLIDE 33

Sizes of Encodings

100 101 102 103 104 105 106 107 108 109 1 10 100 acyclicity checker formula size graph vertex count tc1 tc2 bin unr fw mm ss

Janota et al On the Quest for an Acyclic Graph 12 / 16

slide-34
SLIDE 34

Experiments

No sink (49): solver/checker tc I unr bin fw tc II lingeling 49 48 10 38 11 glucose 32 37 14 15 11 minisat 25 49 12 12 11 minisat-prepro 26 49 11 19 11 Supervisor (441): solver/checker tc I unr bin fw tc II lingeling 436 429 426 435 435 glucose 437 434 427 437 437 minisat 435 425 424 435 435 minisat-prepro 435 426 422 435 435

Janota et al On the Quest for an Acyclic Graph 13 / 16

slide-35
SLIDE 35

Experiments (Cont.)

50 100 150 200 250 300 350 400 450 500 5 10 15 20 25 30 35 40 45 50 CPU time (s) instances glucose-bin glucose-fw glucose-tc2 glucose-unr glucose-tc1 lingeling-fw lingeling-tc2 lingeling-tc1 lingeling-bin minisat-prepro-fw minisat-prepro-tc2 lingeling-unr minisat-prepro-tc1 minisat-prepro-bin minisat-prepro-unr minisat-bin minisat-fw minisat-tc2 minisat-unr minisat-tc1

Janota et al On the Quest for an Acyclic Graph 14 / 16

slide-36
SLIDE 36

Summary

  • Studied encoding for graph acyclicity.

Janota et al On the Quest for an Acyclic Graph 15 / 16

slide-37
SLIDE 37

Summary

  • Studied encoding for graph acyclicity.
  • In our work eager, advantage that SAT/QBF/SMT is agnostic
  • f acyclicity.

Janota et al On the Quest for an Acyclic Graph 15 / 16

slide-38
SLIDE 38

Summary

  • Studied encoding for graph acyclicity.
  • In our work eager, advantage that SAT/QBF/SMT is agnostic
  • f acyclicity.
  • Number of encodings developed and evaluated.

Janota et al On the Quest for an Acyclic Graph 15 / 16

slide-39
SLIDE 39

Summary

  • Studied encoding for graph acyclicity.
  • In our work eager, advantage that SAT/QBF/SMT is agnostic
  • f acyclicity.
  • Number of encodings developed and evaluated.
  • Performance varies across encodings and solvers.

Janota et al On the Quest for an Acyclic Graph 15 / 16

slide-40
SLIDE 40

Summary

  • Studied encoding for graph acyclicity.
  • In our work eager, advantage that SAT/QBF/SMT is agnostic
  • f acyclicity.
  • Number of encodings developed and evaluated.
  • Performance varies across encodings and solvers.
  • More experiments.

Janota et al On the Quest for an Acyclic Graph 15 / 16

slide-41
SLIDE 41

Summary

  • Studied encoding for graph acyclicity.
  • In our work eager, advantage that SAT/QBF/SMT is agnostic
  • f acyclicity.
  • Number of encodings developed and evaluated.
  • Performance varies across encodings and solvers.
  • More experiments.
  • When is eager better than lazy and the other way around?

Janota et al On the Quest for an Acyclic Graph 15 / 16

slide-42
SLIDE 42

Summary

  • Studied encoding for graph acyclicity.
  • In our work eager, advantage that SAT/QBF/SMT is agnostic
  • f acyclicity.
  • Number of encodings developed and evaluated.
  • Performance varies across encodings and solvers.
  • More experiments.
  • When is eager better than lazy and the other way around?
  • Can we get less-than cubic but practical?

Janota et al On the Quest for an Acyclic Graph 15 / 16

slide-43
SLIDE 43

Thank You for Your Attention! Questions?

Janota et al On the Quest for an Acyclic Graph 16 / 16

slide-44
SLIDE 44

Hartung, S. and Nichterlein, A. (2015). NP-hardness and fixed-parameter tractability of realizing degree sequences with directed acyclic graphs. SIAM Journal on Discrete Mathematics, 29(4):1931–1960.

Janota et al On the Quest for an Acyclic Graph 16 / 16