31
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic

Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic

Embed Size (px)

Citation preview

Daniel Kroening and Ofer Strichman 1

Decision Procedures in First Order Logic

Decision Procedures forEquality Logic

Decision Procedures An algorithmic point of view 2

Part III – Decision Procedures for Equality Logic and Uninterpreted Functions

Algorithm I – From Equality to Propositional Logic Adding transitivity constraints Making the graph chordal An improved procedure: consider polarity

Algorithm II – Range-Allocation What is the small-model property? Finding a small adequate range (domain) to each variable Reducing to Propositional Logic

Decision Procedures An algorithmic point of view 3

We will first investigate methods that solve Equality Logic. Uninterpreted functions are eliminated with one of the reduction schemes.

Our starting point: the E-Graph GE(E)

Recall: GE(E) represents an abstraction of E:

It represents ALL equality formulas with the same set of equality predicates as E

Decision Procedures for Equality Logic

Decision Procedures An algorithmic point of view 4

From Equality to Propositional LogicBryant & Velev 2000: the Sparse method

E = x1 = x2 Æ x2 = x3 Æ x1 x3

enc = e1 Æ e2 Æ :e3

Encode all edges with Boolean variables (note: for now, ignore polarity) This is an abstraction Transitivity of equality is lost! Must add transitivity constraints!

e 3

e2

e1

Decision Procedures An algorithmic point of view 5

From Equality to Propositional Logic

E = x1 = x2 Æ x2 = x3 Æ x1 x3

enc = e1 Æ e2 Æ :e3

For each cycle add a transitivity constrainttrans = (e1 Æ e2 ! e3) Æ

(e1 Æ e3 ! e2) Æ

(e3 Æ e2 ! e1)

Check: enc Æ trans

e 3

e2

e1

Decision Procedures An algorithmic point of view 6

From Equality to Propositional Logic

There can be an exponential number of cycles, so let’s try to make it better.

Thm: it is sufficient to constrain simple cycles only

e1

e2 e3

e4

e5e6

T

T T

TT

F

Decision Procedures An algorithmic point of view 7

From Equality to Propositional Logic

Still, there is an exponential number of simple cycles. Thm [Bryant & Velev]: It is sufficient to constrain

chord-free simple cycles

e1

e2

e3

e4

e5

T

TF

T

F

T

Decision Procedures An algorithmic point of view 8

Still, there can be an exponential number of chord-free simple cycles…

Solution: make the graph ‘chordal’ by adding edges.

….

From Equality to Propositional Logic

Decision Procedures An algorithmic point of view 9

From Equality to Propositional Logic

Dfn: A graph is chordal iff every cycle of size 4 or more has a chord.

How to make a graph chordal ? eliminate vertices one at a time, and connect their neighbors.

Decision Procedures An algorithmic point of view 10

From Equality to Propositional Logic

Once the graph is chordal, we can constrain only the triangles.

Note that this procedure adds not more than a polynomial # of edges, and results in a polynomial no. of constraints.

T

T

TT

F

TTContradiction!

Decision Procedures An algorithmic point of view 11

Improvement

So far we did not consider the polarity of the edges.

Claim: in the following graph trans = e3 Æ e2 ! e1 is sufficient

This is only true because of monotonicity of NNF

e1

e2

e3

Decision Procedures An algorithmic point of view 12

Definitions Dfn: A contradictory Cycle C is constrained under

T if T does not allow this assignment

C =

F

T

T T

T

Decision Procedures An algorithmic point of view 13

Main theorem

If

T R constrains all simple contradictory cycles,

and

For every assignment S, S ² T S ! S ² T R

then E is satisfiable iff B Æ T R is satisfiable

The Equality Formula

From the Sparse method

Decision Procedures An algorithmic point of view 14

Transitivity: 5 constraintsRTC: 0 constraints

Transitivity: 5 constraintsRTC: 1 constraint

F

T

T

T

T

Decision Procedures An algorithmic point of view 15

Proof of the main theorem

() E is satisfiable BÆT S is satisfiable BÆT R is satisfiable

() Proof strategy: Let R be a satisfying assignment to B Æ T R We will construct S that satisfies B Æ T S

From this we will conclude that E is satisfiable

Skip proof

Decision Procedures An algorithmic point of view 16

Definitions for the proof…

A Violating cycle under an assignment R

This assignment violates T S but not necessarily T R

eF

eT2

eT1

T

TF

Either dashed or

solid

Decision Procedures An algorithmic point of view 17

More definitions for the proof… An edge e = (vi,vj) is equal under an assignment iff

there is an equality path between vi and vj all assigned T under Denote:

T

TF

TTv1 v2

v3

Decision Procedures An algorithmic point of view 18

More definitions for the proof… An edge e = (vi,vj) is disequal under an assignment iff

there is a disequality path between vi and vj in which the solid edge is the only one assigned false by Denote:

T

TF

TTv1 v2

v3

Decision Procedures An algorithmic point of view 19

Proof… Observation 1:

The combinationis impossible if = R

(recall: R ² T R)

Observation 2: if (v1,v3) is solid, then

FT

Tv1 v2

v3

Decision Procedures An algorithmic point of view 20

ReConstructing S

Type 1:

It is not the case that

Assign S (e23) = F

Type 2:

Otherwise it is not the case that

Assign (e13) = T

FT

T

In all other cases S = R

FT

T

F T

v1 v2

v3

v1 v2

v3

Decision Procedures An algorithmic point of view 21

ReConstructing S

Starting from R, repeat until convergence: (eT) := F in all Type 1 cycles

(eF) := T in all Type 2 cycles

All Type 1 and Type 2 triangles now satisfy T S B is still satisfied (monotonicity of NNF) Left to prove: all contradictory cycles are still

satisfied

Decision Procedures An algorithmic point of view 22

Proof…

Invariant: contradictory cycles are not violating throughout the reconstruction.

contradicts the precondition to make this assignment…

FT

Tv1 v2

v3

F

T

T

Decision Procedures An algorithmic point of view 23

Proof…

Invariant: contradictory cycles are not violating throughout the reconstruction.

contradicts the precondition to make this assignment…

FT

Tv1 v2

v3

TT

F

Decision Procedures An algorithmic point of view 24

Applying RTC

How can we use the theorem without enumerating contradictory cycles ?

Answer: Consider the chordal graph. Constrain triangles if they are part of a (simple)

contradictory cycle How?

Decision Procedures An algorithmic point of view 26

•Should we constrain this triangle?•In which direction ?

•Is this constraint necessary ?

Decision Procedures An algorithmic point of view 27

Decomposing the graph

Focus on Bi-connected dashed components built on top of a solid edge Includes all contradictory cycles involving this edge

Decision Procedures An algorithmic point of view 28

Make the component chordal Chordal-ity guarantees: every cycle contains a simplicial

vertex, i.e. a vertex that its neighbors are connected.

Decision Procedures An algorithmic point of view 29

The RTC algorithm Constraints cache:

e2 Æ e3 ! e1

e4 Æ e7 ! e2

e5 Æ e8 ! e4

1

23

4

5

6

8

9

1211

7

Decision Procedures An algorithmic point of view 30

Constrains all contradictory cycles Constraints cache:

e2 Æ e3 ! e1

e4 Æ e7 ! e2

e6Æ e3 ! e4

1

23

4

5

6

8

9

1211

7

Decision Procedures An algorithmic point of view 31

Results – random graphs

0

50000

100000

150000

200000

250000

300000

350000

400000

01:1001:0501:0201:0102:0105:0110:01

Solid : Dashed

# c

on

str

ain

ts

Sparse

RTC

V=200, E=800, 16 random topologies

Decision Procedures An algorithmic point of view 32

Random graphs (Satisfiable)