preprocessing for first-order clausificationhunt/fmcad/fmcad12/s2_p2.pdf · preprocessing for...

46
Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin , Andrei Voronkov Univeristy of Manchester Zurab Khasidashvili Intel Israel Development Center, Haifa 1 Preprocessing for First-Order

Upload: hoangtruc

Post on 26-Nov-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

Preprocessing for first-order clausification

Krystof Hoder, Konstantin Korovin, Andrei VoronkovUniveristy of Manchester

Zurab KhasidashviliIntel Israel Development Center, Haifa

1

Preprocessing for First-Order

Page 2: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

2

Outline

• EPR-based BMC• EPR-preserving clausification• Definition inlining• Equivalence discovery using SAT sweeping• Quantified AIGs (QAIGs) and QBDDs• QAIGs + QBDDs• Evaluation

Preprocessing for First-Order

Page 3: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

3

Bounded model checking

c

ab

g

d

Symbolic representation:

I = (a0 ↔ ¬c0) ∧ (c0 → b0)(g0 ↔ a0 ∧ b0) ∧ (d0 ↔ ¬g0 ∧ ¬c0)

T =a′ ↔ a ∧b′ ↔ b ∧g′ ↔ a′ ∧ b′ ∧c′ ↔ d ∧d′ ↔ ¬c′ ∧ ¬g′

P = (d ↔ ¬g)

Preprocessing for First-Order

Page 4: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

4

Bounded model checking (Unrolling)

I0 . . .

a0

b0

c0

g0

d0

a1

b1

c1

g1

d1

ak

bk

ck

gk

dk ¬Pk

The system is unsafe if and only if

I0 ∧ T<1,2> ∧ . . . ∧ T<k−1,k> ∧ ¬Pk

is satisfiable for some k.

Biere, Cimatti, Clarke, Zhu

Preprocessing for First-Order

Page 5: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

5

First-order encoding of BMC

First-order encoding:• s0, . . . , sk constants denoting states at unrolling bounds• first-order formulas I(S),P(S),T(S, S′)• next state predicate Next(S, S′)

BMC can be encoded

I(s0);¬P(sk); initial and final states

∀S, S′(Next(S, S′)→ T(S, S′)); transition relation

Next(s0, s1);Next(s1, s2); . . .Next(sk−1, sk); next state relation

• FOL encoding provides succinct representation• Reasoning can be done at higher level

Navarro-Perez, Voronkov

Preprocessing for First-Order

Page 6: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

6

Word level

==wraddr[5:0]

rdaddr[5:0]

cacheline[63:0]

memory

mux

wrdata[63:0]

circuit

rden

wrenclock

sel

outp[63:0]

rddata[63:0]

∀S,S’(Next(S,S’)→ // write is enabled∀y(Assocwraddr(S’, y)→∀A(clock(S’) ∧ wren(S’) ∧ A = y→∀B(range[0,63](B)→ (mem(S’,A,B)↔ wrdata(S,B)))))).

Memories and bit-vectors are represented by first-order predicates:mem(S,A,B),wrdata(S,B).

Emmer, Korovin, Khasidashvili, Sticksel, Voronkov;

relevant complexity resutls: Kovasznai, Frohlich, Biere

Preprocessing for First-Order

Page 7: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

7

Effectively Propositional Fragment (EPR)

EPR: ∃y∀xF(x, y), where F is function-free.

Skolemized: ∀xF(c, x)

EPR∀S,B(mem(S,rdaddr,B)↔ rddata(S,B))

represents propositional:

(mem(s1,rdaddr, i1)↔ rddata(s1, i1))(mem(s1,rdaddr, i2)↔ rddata(s1, i2))(mem(s2,rdaddr, i3)↔ rddata(s2, i3))

· · ·

Efficient solvers for EPR: iProver, Darwin, Equinox

CASC competition: EPR division

Preprocessing for First-Order

Page 8: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

8

EPR-preserving Skolemization

Most formulas obtained from hardware designs are definitions.

Skolemization of definitions can introduce functions!

prop(S)↔ ∀B(range[0:63](B)→ (outp(S,B)↔ cacheline(S,B)))

prop(S)← (range[0:63](f (S))→ (outp(S, f (S))↔ cacheline(S, f (S)))

Note: only← is problematic.

Remove: ← if all occurrences of prop are positive

Inline all negative occurrences of prop:

¬prop(sk)∃B(range[0:63](B) ∧ ¬(outp(sK ,B)↔ cacheline(sk,B)))(range[0:63](sk) ∧ ¬(outp(sK , sk)↔ cacheline(sk, sk)))

After inlining:1) obtain an EPR formula and2) we can remove← from the definition.

Preprocessing for First-Order

Page 9: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

8

EPR-preserving Skolemization

Most formulas obtained from hardware designs are definitions.

Skolemization of definitions can introduce functions!

prop(S) ←→ ∀B(range[0:63](B)→ (outp(S,B)↔ cacheline(S,B)))

prop(S)← (range[0:63](f (S))→ (outp(S, f (S))↔ cacheline(S, f (S)))

Note: only← is problematic.

Remove: ← if all occurrences of prop are positive

Inline all negative occurrences of prop:

¬prop(sk)∃B(range[0:63](B) ∧ ¬(outp(sK ,B)↔ cacheline(sk,B)))(range[0:63](sk) ∧ ¬(outp(sK , sk)↔ cacheline(sk, sk)))

After inlining:1) obtain an EPR formula and2) we can remove← from the definition.

Preprocessing for First-Order

Page 10: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

8

EPR-preserving Skolemization

Most formulas obtained from hardware designs are definitions.

Skolemization of definitions can introduce functions!

prop(S) ←→ ∀B(range[0:63](B)→ (outp(S,B)↔ cacheline(S,B)))

prop(S)← (range[0:63](f (S))→ (outp(S, f (S))↔ cacheline(S, f (S)))

Note: only← is problematic.

Remove: ← if all occurrences of prop are positive

Inline all negative occurrences of prop:

¬prop(sk)∃B(range[0:63](B) ∧ ¬(outp(sK ,B)↔ cacheline(sk,B)))(range[0:63](sk) ∧ ¬(outp(sK , sk)↔ cacheline(sk, sk)))

After inlining:1) obtain an EPR formula and2) we can remove← from the definition.

Preprocessing for First-Order

Page 11: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

8

EPR-preserving Skolemization

Most formulas obtained from hardware designs are definitions.

Skolemization of definitions can introduce functions!

prop(S) ←→ ∀B(range[0:63](B)→ (outp(S,B)↔ cacheline(S,B)))

prop(S)← (range[0:63](f (S))→ (outp(S, f (S))↔ cacheline(S, f (S)))

Note: only← is problematic.

Remove: ← if all occurrences of prop are positive

Inline all negative occurrences of prop:

¬prop(sk)∃B(range[0:63](B) ∧ ¬(outp(sK ,B)↔ cacheline(sk,B)))(range[0:63](sk) ∧ ¬(outp(sK , sk)↔ cacheline(sk, sk)))

After inlining:1) obtain an EPR formula and2) we can remove← from the definition.

Preprocessing for First-Order

Page 12: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

8

EPR-preserving Skolemization

Most formulas obtained from hardware designs are definitions.

Skolemization of definitions can introduce functions!

prop(S) ←→ ∀B(range[0:63](B)→ (outp(S,B)↔ cacheline(S,B)))

prop(S)← (range[0:63](f (S))→ (outp(S, f (S))↔ cacheline(S, f (S)))

Note: only← is problematic.

Remove: ← if all occurrences of prop are positive

Inline all negative occurrences of prop:

¬prop(sk)

∃B(range[0:63](B) ∧ ¬(outp(sK ,B)↔ cacheline(sk,B)))(range[0:63](sk) ∧ ¬(outp(sK , sk)↔ cacheline(sk, sk)))

After inlining:1) obtain an EPR formula and2) we can remove← from the definition.

Preprocessing for First-Order

Page 13: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

8

EPR-preserving Skolemization

Most formulas obtained from hardware designs are definitions.

Skolemization of definitions can introduce functions!

prop(S) ←→ ∀B(range[0:63](B)→ (outp(S,B)↔ cacheline(S,B)))

prop(S)← (range[0:63](f (S))→ (outp(S, f (S))↔ cacheline(S, f (S)))

Note: only← is problematic.

Remove: ← if all occurrences of prop are positive

Inline all negative occurrences of prop:

¬prop(sk)∃B(range[0:63](B) ∧ ¬(outp(sK ,B)↔ cacheline(sk,B)))

(range[0:63](sk) ∧ ¬(outp(sK , sk)↔ cacheline(sk, sk)))

After inlining:1) obtain an EPR formula and2) we can remove← from the definition.

Preprocessing for First-Order

Page 14: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

8

EPR-preserving Skolemization

Most formulas obtained from hardware designs are definitions.

Skolemization of definitions can introduce functions!

prop(S) ←→ ∀B(range[0:63](B)→ (outp(S,B)↔ cacheline(S,B)))

prop(S)← (range[0:63](f (S))→ (outp(S, f (S))↔ cacheline(S, f (S)))

Note: only← is problematic.

Remove: ← if all occurrences of prop are positive

Inline all negative occurrences of prop:

¬prop(sk)∃B(range[0:63](B) ∧ ¬(outp(sK ,B)↔ cacheline(sk,B)))(range[0:63](sk) ∧ ¬(outp(sK , sk)↔ cacheline(sk, sk)))

After inlining:1) obtain an EPR formula and2) we can remove← from the definition.

Preprocessing for First-Order

Page 15: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

9

Conditional Inlining

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B)↔ mem1(S,wraddr,B)))).

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

∀S(reach(S)→∀B(range[0:63](B)

(mem1(S,wraddr,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

(Conditional) inlining:• EPR - preserving Skolemization• definition elimination• non-growing inlining

Preprocessing for First-Order

Page 16: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

9

Conditional Inlining

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B)↔ mem1(S,wraddr,B)))).

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

∀S(reach(S)→∀B(range[0:63](B)

(mem1(S,wraddr,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

(Conditional) inlining:• EPR - preserving Skolemization• definition elimination• non-growing inlining

Preprocessing for First-Order

Page 17: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

9

Conditional Inlining

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B)↔ mem1(S,wraddr,B)))).

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

∀S(reach(S)→∀B(range[0:63](B)

(mem1(S,wraddr,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

(Conditional) inlining:• EPR - preserving Skolemization• definition elimination• non-growing inlining

Preprocessing for First-Order

Page 18: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

9

Conditional Inlining

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B)↔ mem1(S,wraddr,B)))).

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

∀S(reach(S)→∀B(range[0:63](B)

(mem1(S,wraddr,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

(Conditional) inlining:• EPR - preserving Skolemization• definition elimination• non-growing inlining

Preprocessing for First-Order

Page 19: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

9

Conditional Inlining

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B)↔ mem1(S,wraddr,B)))).

∀S(reach(S)→∀B(range[0:63](B)→

(bv1(S,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

∀S(reach(S)→∀B(range[0:63](B)

(mem1(S,wraddr,B) ∨ (¬mem2(S,rdaddr,B) ∧ bv2(S,B))))).

(Conditional) inlining:• EPR - preserving Skolemization• definition elimination• non-growing inlining

Preprocessing for First-Order

Page 20: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

10

Equivalence discovery with SAT sweepingGiven a first-order formula F which literals in F are equivalent?

SAT sweeping:• clausify F• abstract first-order literals to propositional variables• use SAT-based techniques for equivalence checking

First-order F:

p(x) ∨ ¬q(x, c) ∨ ¬r(x) ∧q(x, c) ∨ r(x) ∧

q(x, c) ∨ ¬r(x) ∧¬p(x) ∨ ¬q(x, c) ∨ r(x)

Propositional abstraction S:

vp(x) ∨ ¬vq(x,c) ∨ ¬vr(x) ∧vq(x,c) ∨ vr(x) ∧

vq(x,c) ∨ ¬vr(x) ∧¬vp(x) ∨ ¬vq(x,c) ∨ vr(x)

If S |= vp(x) ↔ vr(x) then F |= ∀x (p(x)↔ r(x)).

If S ∪ {vp(x),¬vr(x)} |= ⊥ and S ∪ {¬vp(x), vr(x)} |= ⊥ thenS |= vp(x) ↔ vr(x) and therefore F |= ∀x (p(x)↔ r(x)).

Eliminate equivalent literals

Extension: equivalences of subformulas(simultaneous prop. equivalence checking: Khasidashvili, Nadel)

Preprocessing for First-Order

Page 21: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

10

Equivalence discovery with SAT sweepingGiven a first-order formula F which literals in F are equivalent?

SAT sweeping:• clausify F• abstract first-order literals to propositional variables• use SAT-based techniques for equivalence checking

First-order F:

p(x) ∨ ¬q(x, c) ∨ ¬r(x) ∧q(x, c) ∨ r(x) ∧

q(x, c) ∨ ¬r(x) ∧¬p(x) ∨ ¬q(x, c) ∨ r(x)

Propositional abstraction S:

vp(x) ∨ ¬vq(x,c) ∨ ¬vr(x) ∧vq(x,c) ∨ vr(x) ∧

vq(x,c) ∨ ¬vr(x) ∧¬vp(x) ∨ ¬vq(x,c) ∨ vr(x)

If S |= vp(x) ↔ vr(x) then F |= ∀x (p(x)↔ r(x)).

If S ∪ {vp(x),¬vr(x)} |= ⊥ and S ∪ {¬vp(x), vr(x)} |= ⊥ thenS |= vp(x) ↔ vr(x) and therefore F |= ∀x (p(x)↔ r(x)).

Eliminate equivalent literals

Extension: equivalences of subformulas(simultaneous prop. equivalence checking: Khasidashvili, Nadel)

Preprocessing for First-Order

Page 22: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

10

Equivalence discovery with SAT sweepingGiven a first-order formula F which literals in F are equivalent?

SAT sweeping:• clausify F• abstract first-order literals to propositional variables• use SAT-based techniques for equivalence checking

First-order F:

p(x) ∨ ¬q(x, c) ∨ ¬r(x) ∧q(x, c) ∨ r(x) ∧

q(x, c) ∨ ¬r(x) ∧¬p(x) ∨ ¬q(x, c) ∨ r(x)

Propositional abstraction S:

vp(x) ∨ ¬vq(x,c) ∨ ¬vr(x) ∧vq(x,c) ∨ vr(x) ∧

vq(x,c) ∨ ¬vr(x) ∧¬vp(x) ∨ ¬vq(x,c) ∨ vr(x)

If S |= vp(x) ↔ vr(x) then F |= ∀x (p(x)↔ r(x)).

If S ∪ {vp(x),¬vr(x)} |= ⊥ and S ∪ {¬vp(x), vr(x)} |= ⊥ thenS |= vp(x) ↔ vr(x) and therefore F |= ∀x (p(x)↔ r(x)).

Eliminate equivalent literals

Extension: equivalences of subformulas(simultaneous prop. equivalence checking: Khasidashvili, Nadel)

Preprocessing for First-Order

Page 23: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

10

Equivalence discovery with SAT sweepingGiven a first-order formula F which literals in F are equivalent?

SAT sweeping:• clausify F• abstract first-order literals to propositional variables• use SAT-based techniques for equivalence checking

First-order F:

p(x) ∨ ¬q(x, c) ∨ ¬r(x) ∧q(x, c) ∨ r(x) ∧

q(x, c) ∨ ¬r(x) ∧¬p(x) ∨ ¬q(x, c) ∨ r(x)

Propositional abstraction S:

vp(x) ∨ ¬vq(x,c) ∨ ¬vr(x) ∧vq(x,c) ∨ vr(x) ∧

vq(x,c) ∨ ¬vr(x) ∧¬vp(x) ∨ ¬vq(x,c) ∨ vr(x)

If S |= vp(x) ↔ vr(x) then F |= ∀x (p(x)↔ r(x)).

If S ∪ {vp(x),¬vr(x)} |= ⊥ and S ∪ {¬vp(x), vr(x)} |= ⊥ thenS |= vp(x) ↔ vr(x) and therefore F |= ∀x (p(x)↔ r(x)).

Eliminate equivalent literals

Extension: equivalences of subformulas(simultaneous prop. equivalence checking: Khasidashvili, Nadel)

Preprocessing for First-Order

Page 24: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

10

Equivalence discovery with SAT sweepingGiven a first-order formula F which literals in F are equivalent?

SAT sweeping:• clausify F• abstract first-order literals to propositional variables• use SAT-based techniques for equivalence checking

First-order F:

p(x) ∨ ¬q(x, c) ∨ ¬r(x) ∧q(x, c) ∨ r(x) ∧

q(x, c) ∨ ¬r(x) ∧¬p(x) ∨ ¬q(x, c) ∨ r(x)

Propositional abstraction S:

vp(x) ∨ ¬vq(x,c) ∨ ¬vr(x) ∧vq(x,c) ∨ vr(x) ∧

vq(x,c) ∨ ¬vr(x) ∧¬vp(x) ∨ ¬vq(x,c) ∨ vr(x)

If S |= vp(x) ↔ vr(x) then F |= ∀x (p(x)↔ r(x)).

If S ∪ {vp(x),¬vr(x)} |= ⊥ and S ∪ {¬vp(x), vr(x)} |= ⊥ thenS |= vp(x) ↔ vr(x) and therefore F |= ∀x (p(x)↔ r(x)).

Eliminate equivalent literals

Extension: equivalences of subformulas(simultaneous prop. equivalence checking: Khasidashvili, Nadel)

Preprocessing for First-Order

Page 25: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

10

Equivalence discovery with SAT sweepingGiven a first-order formula F which literals in F are equivalent?

SAT sweeping:• clausify F• abstract first-order literals to propositional variables• use SAT-based techniques for equivalence checking

First-order F:

p(x) ∨ ¬q(x, c) ∨ ¬r(x) ∧q(x, c) ∨ r(x) ∧

q(x, c) ∨ ¬r(x) ∧¬p(x) ∨ ¬q(x, c) ∨ r(x)

Propositional abstraction S:

vp(x) ∨ ¬vq(x,c) ∨ ¬vr(x) ∧vq(x,c) ∨ vr(x) ∧

vq(x,c) ∨ ¬vr(x) ∧¬vp(x) ∨ ¬vq(x,c) ∨ vr(x)

If S |= vp(x) ↔ vr(x) then F |= ∀x (p(x)↔ r(x)).

If S ∪ {vp(x),¬vr(x)} |= ⊥ and S ∪ {¬vp(x), vr(x)} |= ⊥ thenS |= vp(x) ↔ vr(x) and therefore F |= ∀x (p(x)↔ r(x)).

Eliminate equivalent literals

Extension: equivalences of subformulas(simultaneous prop. equivalence checking: Khasidashvili, Nadel)

Preprocessing for First-Order

Page 26: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

10

Equivalence discovery with SAT sweepingGiven a first-order formula F which literals in F are equivalent?

SAT sweeping:• clausify F• abstract first-order literals to propositional variables• use SAT-based techniques for equivalence checking

First-order F:

p(x) ∨ ¬q(x, c) ∨ ¬r(x) ∧q(x, c) ∨ r(x) ∧

q(x, c) ∨ ¬r(x) ∧¬p(x) ∨ ¬q(x, c) ∨ r(x)

Propositional abstraction S:

vp(x) ∨ ¬vq(x,c) ∨ ¬vr(x) ∧vq(x,c) ∨ vr(x) ∧

vq(x,c) ∨ ¬vr(x) ∧¬vp(x) ∨ ¬vq(x,c) ∨ vr(x)

If S |= vp(x) ↔ vr(x) then F |= ∀x (p(x)↔ r(x)).

If S ∪ {vp(x),¬vr(x)} |= ⊥ and S ∪ {¬vp(x), vr(x)} |= ⊥ thenS |= vp(x) ↔ vr(x) and therefore F |= ∀x (p(x)↔ r(x)).

Eliminate equivalent literals

Extension: equivalences of subformulas(simultaneous prop. equivalence checking: Khasidashvili, Nadel)

Preprocessing for First-Order

Page 27: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

11

And-Inverter Graphs (AIG)

And-Inverter graphs for propositional formula representation.

Only two nodes: ∧ and ¬

p q

¬(¬p ∧ q) ∧ q

¬p ∧ q

AIGs:• compact representation• sharing structurally

isomorphic subformulas• simplifications

Preprocessing for First-Order

Page 28: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

12

Quantified AIGs

Quantified AIGs for first-order formula representation.

Three nodes: ∧, ¬ and ∀

p(x, y) q(y)

∀x

∀y

¬∀x(p(x, y) ∧ ¬q(y)) ∧ ∀yq(y)

¬p(x, y) ∧ q(y)

QAIGs:• compact representation of FO

formulas• definition inlining on QAIGs• variable instantiations

Shortcomings: (Q)AIGs are notcanonical even for simplepropositional cases.

Preprocessing for First-Order

Page 29: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

12

Quantified AIGs

Quantified AIGs for first-order formula representation.

Three nodes: ∧, ¬ and ∀

p(x, y) q(y)

∀x

∀y

¬∀x(p(x, y) ∧ ¬q(y)) ∧ ∀yq(y)

¬p(x, y) ∧ q(y)

QAIGs:• compact representation of FO

formulas• definition inlining on QAIGs• variable instantiations

Shortcomings: (Q)AIGs are notcanonical even for simplepropositional cases.

Preprocessing for First-Order

Page 30: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDsMain idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

∀x[(p(x, y) ∨ ¬∃xq(x)) ∧ (∃xq(x) ∨ p(x, y)) ∧ q(y)] ∧ ¬∀x(p(x, y) ∧ q(y))

level 0: vp(x,y), vq(x), vq(y)level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.

Preprocessing for First-Order

Page 31: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDsMain idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

∀x[(p(x, y) ∨ ¬∃xq(x)) ∧ (∃xq(x) ∨ p(x, y)) ∧ q(y)] ∧ ¬∀x(p(x, y) ∧ q(y))

level 0: vp(x,y), vq(x), vq(y)

level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.

Preprocessing for First-Order

Page 32: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDsMain idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

∀x[(p(x, y) ∨ ¬∃xq(x)) ∧ (∃xq(x) ∨ p(x, y)) ∧ q(y)] ∧ ¬∀x(p(x, y) ∧ q(y))

level 0: vp(x,y), vq(x), vq(y)level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.

Preprocessing for First-Order

Page 33: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDsMain idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

∀x[(p(x, y) ∨ ¬∃xq(x)) ∧ (∃xq(x) ∨ p(x, y)) ∧ q(y)] ∧ ¬∀x(p(x, y) ∧ q(y))

level 0: vp(x,y), vq(x), vq(y)level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.

Preprocessing for First-Order

Page 34: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDs

Main idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

∀x(p(x, y) ∧ q(y)) ∧ ¬∀x(p(x, y) ∧ q(y))

level 0: vp(x,y), vq(x), vq(y)level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.

Preprocessing for First-Order

Page 35: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDs

Main idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

∀x(p(x, y) ∧ q(y)) ∧ ¬∀x(p(x, y) ∧ q(y))

level 0: vp(x,y), vq(x), vq(y)level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.

Preprocessing for First-Order

Page 36: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDs

Main idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

⊥level 0: vp(x,y), vq(x), vq(y)level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.

Preprocessing for First-Order

Page 37: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDsMain idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

∀x[(p(x, y) ∨ ¬∃xq(x)) ∧ (∃xq(x) ∨ p(x, y)) ∧ q(y)] ∧ ¬∀x(p(x, y) ∧ q(y))

level 0: vp(x,y), vq(x), vq(y)level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.

Preprocessing for First-Order

Page 38: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

13

Quantified BDDsMain idea: abstract quantified formulas by propositional variables.

atb(atom(a)) = bddvar(atom(a))atb((∀x, q)) = bddvar((∀x, atb(q)))atb(neg(q)) = bddneg(atb(q))atb(and(q1, q2)) = bddand(atb(q1), atb(q2))

Example:

∀x[(p(x, y) ∨ ¬∃xq(x)) ∧ (∃xq(x) ∨ p(x, y)) ∧ q(y)] ∧ ¬∀x(p(x, y) ∧ q(y))

level 0: vp(x,y), vq(x), vq(y)level 1: v∃x〈q(x)〉, v∀x〈p(x,y)∧q(y)〉

QBDD reduction

Applying QBDD simplifies this formula to ⊥.

QBDDs: Canonical wrt. Boolean structure.

Shortcomings: BDDs can be exponential in size.Preprocessing for First-Order

Page 39: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

14

QAIGs+QBDDsCombination QAIGs+QBDDs.

For each node in QAIG we try to build QBDD.If QBDD is larger than a threshold then replace QBDD with QAIG.

QAIG

QBDD QBDD QBDD

Combined structure: balance between size and Boolean canonicity.

QAIGs+QBDDs:• subformula simplification• discover new equivalences• definition elimination

Optimization: When| AIG |<| QBDD |• keep QBDD for canonicity;• use AIG as the normal form.

(related in prop. case: Andersen, Hulgaard; Bjesse, Boralv; Kuehlmann, Krohm)

Preprocessing for First-Order

Page 40: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

14

QAIGs+QBDDsCombination QAIGs+QBDDs.

For each node in QAIG we try to build QBDD.If QBDD is larger than a threshold then replace QBDD with QAIG.

QAIG

QBDD QBDD QBDD

Combined structure: balance between size and Boolean canonicity.

QAIGs+QBDDs:• subformula simplification• discover new equivalences• definition elimination

Optimization: When| AIG |<| QBDD |• keep QBDD for canonicity;• use AIG as the normal form.

(related in prop. case: Andersen, Hulgaard; Bjesse, Boralv; Kuehlmann, Krohm)

Preprocessing for First-Order

Page 41: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

14

QAIGs+QBDDsCombination QAIGs+QBDDs.

For each node in QAIG we try to build QBDD.If QBDD is larger than a threshold then replace QBDD with QAIG.

QAIG

QBDD QBDD QBDD

Combined structure: balance between size and Boolean canonicity.

QAIGs+QBDDs:• subformula simplification• discover new equivalences• definition elimination

Optimization: When| AIG |<| QBDD |• keep QBDD for canonicity;• use AIG as the normal form.

(related in prop. case: Andersen, Hulgaard; Bjesse, Boralv; Kuehlmann, Krohm)

Preprocessing for First-Order

Page 42: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

14

QAIGs+QBDDsCombination QAIGs+QBDDs.

For each node in QAIG we try to build QBDD.If QBDD is larger than a threshold then replace QBDD with QAIG.

QAIG

QBDD QBDD QBDD

Combined structure: balance between size and Boolean canonicity.

QAIGs+QBDDs:• subformula simplification• discover new equivalences• definition elimination

Optimization: When| AIG |<| QBDD |• keep QBDD for canonicity;• use AIG as the normal form.

(related in prop. case: Andersen, Hulgaard; Bjesse, Boralv; Kuehlmann, Krohm)

Preprocessing for First-Order

Page 43: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

15

Evaluation (EPR-BMC)Intel industrial hardware benchmarks:

Design FOF Bound CNF sizeblock size Base Prep Base Prep

BPB2 913 7 9 1977 2921DCC1 1093 4 4 3209 1615DCC2 431 7 10 861 370DCI1 4678 0 1 15899 9852PMS1 574 5 7 1295 1016ROB2 713 5 7 1717 1157SCD1 736 8 9 1908 1328SCD2 267 8 15 755 524TOTAL 9404 44 62 27621 18783

Table : BMC1 results on industrial benchmarks.

iProver was used for the EPR solving.

Preprocessing for First-Order

Page 44: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

16

Evaluation TPTP/SMT

ACR – AIGs conditional rewritingACR(ERI) – AIGs conditional rewriting restricted to EPR-restoring

Base+ACR Prep Prep+ACR Prep+ACR(ERI)≥ 2x faster 100 10 74 122> 1x faster 4890 1527 4847 4941≥ 2x slower 36 33 36 36

Table : QA UF SMT problems

Z3 was used for SMT solving.

Prep only Base onlyiProver 482 83

Vampire 276 76

Table : TPTP first-order problems

Preprocessing for First-Order

Page 45: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

16

Evaluation TPTP/SMT

ACR – AIGs conditional rewritingACR(ERI) – AIGs conditional rewriting restricted to EPR-restoring

Base+ACR Prep Prep+ACR Prep+ACR(ERI)≥ 2x faster 100 10 74 122> 1x faster 4890 1527 4847 4941≥ 2x slower 36 33 36 36

Table : QA UF SMT problems

Z3 was used for SMT solving.

Prep only Base onlyiProver 482 83

Vampire 276 76

Table : TPTP first-order problems

Preprocessing for First-Order

Page 46: Preprocessing for first-order clausificationhunt/FMCAD/FMCAD12/s2_p2.pdf · Preprocessing for first-order clausification Krystof Hoder, Konstantin Korovin, Andrei Voronkov Univeristy

17

Summary

First-order preprocessing techniques:

• Definition inlining• Equivalence discovery using SAT sweeping• Quantified AIGs• Quantified BDDs• QAIGs + QBDDs

Preprocessing for First-Order