congruence closure with free variables (work in progress) · 2017. 9. 27. · haniel barbosa...

23
Congruence Closure with Free Variables (Work in Progress) Haniel Barbosa, Pascal Fontaine INRIA Nancy – VeriDis Universit´ e de Lorraine UFRN 2015–08–24 Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 1 / 11

Upload: others

Post on 11-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Congruence Closure with Free Variables(Work in Progress)

Haniel Barbosa, Pascal Fontaine

INRIA Nancy – VeriDisUniversite de Lorraine

UFRN

2015–08–24

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 1 / 11

Page 2: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Outline

• SMT solving

• Congruence Closure with Free Variables

• Extensions and next tasks

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 2 / 11

Page 3: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

SMT solving

First-order logic modulo theories:

ϕ =

{f(c) ≈ a ∨ c ≈ d, f(a) ≈ b, f(b) 6≈ f(a),∀x1, x2. f(x1) 6≈ a ∨ f(x2) ≈ b

}

Through SAT solving one may obtain that L ∪Q |= ϕ, for

L = {f(c) ≈ a, f(a) ≈ b, f(b) 6≈ f(a)}Q = {∀x1, x2. (f(x1) 6≈ a ∨ f(x2) ≈ b)}

Through ground reasoning, L is shown satisfiable.

What about Q?

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 3 / 11

Page 4: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

SMT solving

First-order logic modulo theories:

ϕ =

{f(c) ≈ a ∨ c ≈ d, f(a) ≈ b, f(b) 6≈ f(a),∀x1, x2. f(x1) 6≈ a ∨ f(x2) ≈ b

}

Through SAT solving one may obtain that L ∪Q |= ϕ, for

L = {f(c) ≈ a, f(a) ≈ b, f(b) 6≈ f(a)}Q = {∀x1, x2. (f(x1) 6≈ a ∨ f(x2) ≈ b)}

Through ground reasoning, L is shown satisfiable.

What about Q?

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 3 / 11

Page 5: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

SMT solving

First-order logic modulo theories:

ϕ =

{f(c) ≈ a ∨ c ≈ d, f(a) ≈ b, f(b) 6≈ f(a),∀x1, x2. f(x1) 6≈ a ∨ f(x2) ≈ b

}

Through SAT solving one may obtain that L ∪Q |= ϕ, for

L = {f(c) ≈ a, f(a) ≈ b, f(b) 6≈ f(a)}Q = {∀x1, x2. (f(x1) 6≈ a ∨ f(x2) ≈ b)}

Through ground reasoning, L is shown satisfiable.

What about Q?

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 3 / 11

Page 6: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

SMT solving

How to handle quantified formulas in the SMT context?

FOL with equality is semi-decidable, but considering theoriesfrequently leads to undecidability.

Reasoning through incomplete techniques relying on decidablefragments — instantiation.

SMT formula

SMT solver

SAT solver

Boolean Model

Theoryreasoner

Conflict clause

Quantifier-free SMT solver

Model

Instantiationmodule

Instance

Model UNSAT (proof/core)

With too many instances available, their selection becomes crucial.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 4 / 11

Page 7: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

SMT solving

How to handle quantified formulas in the SMT context?

FOL with equality is semi-decidable, but considering theoriesfrequently leads to undecidability.

Reasoning through incomplete techniques relying on decidablefragments — instantiation.

SMT formula

SMT solver

SAT solver

Boolean Model

Theoryreasoner

Conflict clause

Quantifier-free SMT solver

With too many instances available, their selection becomes crucial.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 4 / 11

Page 8: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

SMT solving

How to handle quantified formulas in the SMT context?

FOL with equality is semi-decidable, but considering theoriesfrequently leads to undecidability.

Reasoning through incomplete techniques relying on decidablefragments — instantiation.

SMT formula

SMT solver

SAT solver

Boolean Model

Theoryreasoner

Conflict clause

Quantifier-free SMT solver

Model

Instantiationmodule

Instance

With too many instances available, their selection becomes crucial.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 4 / 11

Page 9: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

SMT solving

How to handle quantified formulas in the SMT context?

FOL with equality is semi-decidable, but considering theoriesfrequently leads to undecidability.

Reasoning through incomplete techniques relying on decidablefragments — instantiation.

SMT formula

SMT solver

SAT solver

Boolean Model

Theoryreasoner

Conflict clause

Quantifier-free SMT solver

Model

Instantiationmodule

Instance

Model UNSAT (proof/core)

With too many instances available, their selection becomes crucial.Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 4 / 11

Page 10: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Ground conflicting instances generation

Context (ground model)

Given a formula ϕ and a theory T , SMT solver derives, if any,groundly T -satisfiable sets of literals L and Q s.t. L ∪Q |= ϕ.

L is a set of ground literals.

Q is a set of quantified formulas.

Ground conflicting instances [Reynolds et al., 2014]

Derive, for some ∀x.ψ ∈ Q, ground substitutions σ s.t. L |= ¬ψσ.

As instances ∀x.ψ → ψσ refute L∪Q, their addition to ϕ require thederivation of a new ground model, if any.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 5 / 11

Page 11: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Congruence Closure with Free Variables

Finding ground conflicting instances is equivalent to solving anon-simultaneous E-unification problem (NP-complete).

[Tiwari et al., 2000]

It has also been shown to be amenable to the use of congruenceclosure procedures.

Algorithm CCFV: extends congruence closure decision procedure,being able to perform unification on free variables.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 6 / 11

Page 12: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

CCFV

Finding substitutions

It computes, if any, a sequence of substitutions σ0, . . . , σk such that, for¬ψ = l1 ∧ · · · ∧ lk,

σ0 = ∅; σi−1 ⊆ σi and L |= liσi

which guarantees that L |= ¬ψσk.

Unification

Adapts the recursive descent E-unification algorithm in [Baader et al., 2001].

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 7 / 11

Page 13: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Example

ϕ =

{f(c) ≈ a ∨ c ≈ d, f(a) ≈ b, f(b) 6≈ f(a),∀x1, x2. f(x1) 6≈ a ∨ f(x2) ≈ b

}L = {f(c) ≈ a, f(a) ≈ b, f(b) 6≈ f(a)}

¬ψ = (f(x1) ≈ a ∧ f(x2) 6≈ b)

1 Evaluates f(x1) ≈ a:

since f(c) ∈ [a], unifies 〈f(x1), f(c)〉.leads to the substitution σ1 = {x1 7→ c}, such thatL |= (f(x1) ≈ a)σ1.

2 Evaluates f(x2) 6≈ b:since f(a) ∈ [b], if the pair 〈f(x2), f(b)〉 is unifiable then the resultingσ is conflicting.leads to the substitution σ2 = {x1 7→ c, x2 7→ b} such thatL |= (f(x2) 6≈ b)σ2.

CCFV returns σ = {x1 7→ c, x2 7→ b}, which is a ground conflictingsubstitution, since L ∧ ψσ is groundly unsatisfiable.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 8 / 11

Page 14: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Example

ϕ =

{f(c) ≈ a ∨ c ≈ d, f(a) ≈ b, f(b) 6≈ f(a),∀x1, x2. f(x1) 6≈ a ∨ f(x2) ≈ b

}L = {f(c) ≈ a, f(a) ≈ b, f(b) 6≈ f(a)}¬ψ = (f(x1) ≈ a ∧ f(x2) 6≈ b)

1 Evaluates f(x1) ≈ a:

since f(c) ∈ [a], unifies 〈f(x1), f(c)〉.leads to the substitution σ1 = {x1 7→ c}, such thatL |= (f(x1) ≈ a)σ1.

2 Evaluates f(x2) 6≈ b:since f(a) ∈ [b], if the pair 〈f(x2), f(b)〉 is unifiable then the resultingσ is conflicting.leads to the substitution σ2 = {x1 7→ c, x2 7→ b} such thatL |= (f(x2) 6≈ b)σ2.

CCFV returns σ = {x1 7→ c, x2 7→ b}, which is a ground conflictingsubstitution, since L ∧ ψσ is groundly unsatisfiable.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 8 / 11

Page 15: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Example

ϕ =

{f(c) ≈ a ∨ c ≈ d, f(a) ≈ b, f(b) 6≈ f(a),∀x1, x2. f(x1) 6≈ a ∨ f(x2) ≈ b

}L = {f(c) ≈ a, f(a) ≈ b, f(b) 6≈ f(a)}¬ψ = (f(x1) ≈ a ∧ f(x2) 6≈ b)

1 Evaluates f(x1) ≈ a:

since f(c) ∈ [a], unifies 〈f(x1), f(c)〉.leads to the substitution σ1 = {x1 7→ c}, such thatL |= (f(x1) ≈ a)σ1.

2 Evaluates f(x2) 6≈ b:since f(a) ∈ [b], if the pair 〈f(x2), f(b)〉 is unifiable then the resultingσ is conflicting.leads to the substitution σ2 = {x1 7→ c, x2 7→ b} such thatL |= (f(x2) 6≈ b)σ2.

CCFV returns σ = {x1 7→ c, x2 7→ b}, which is a ground conflictingsubstitution, since L ∧ ψσ is groundly unsatisfiable.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 8 / 11

Page 16: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Example

ϕ =

{f(c) ≈ a ∨ c ≈ d, f(a) ≈ b, f(b) 6≈ f(a),∀x1, x2. f(x1) 6≈ a ∨ f(x2) ≈ b

}L = {f(c) ≈ a, f(a) ≈ b, f(b) 6≈ f(a)}¬ψ = (f(x1) ≈ a ∧ f(x2) 6≈ b)

1 Evaluates f(x1) ≈ a:

since f(c) ∈ [a], unifies 〈f(x1), f(c)〉.leads to the substitution σ1 = {x1 7→ c}, such thatL |= (f(x1) ≈ a)σ1.

2 Evaluates f(x2) 6≈ b:since f(a) ∈ [b], if the pair 〈f(x2), f(b)〉 is unifiable then the resultingσ is conflicting.leads to the substitution σ2 = {x1 7→ c, x2 7→ b} such thatL |= (f(x2) 6≈ b)σ2.

CCFV returns σ = {x1 7→ c, x2 7→ b}, which is a ground conflictingsubstitution, since L ∧ ψσ is groundly unsatisfiable.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 8 / 11

Page 17: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Example

ϕ =

{f(c) ≈ a ∨ c ≈ d, f(a) ≈ b, f(b) 6≈ f(a),∀x1, x2. f(x1) 6≈ a ∨ f(x2) ≈ b

}L = {f(c) ≈ a, f(a) ≈ b, f(b) 6≈ f(a)}¬ψ = (f(x1) ≈ a ∧ f(x2) 6≈ b)

1 Evaluates f(x1) ≈ a:

since f(c) ∈ [a], unifies 〈f(x1), f(c)〉.leads to the substitution σ1 = {x1 7→ c}, such thatL |= (f(x1) ≈ a)σ1.

2 Evaluates f(x2) 6≈ b:since f(a) ∈ [b], if the pair 〈f(x2), f(b)〉 is unifiable then the resultingσ is conflicting.leads to the substitution σ2 = {x1 7→ c, x2 7→ b} such thatL |= (f(x2) 6≈ b)σ2.

CCFV returns σ = {x1 7→ c, x2 7→ b}, which is a ground conflictingsubstitution, since L ∧ ψσ is groundly unsatisfiable.

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 8 / 11

Page 18: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Algorithm

proc CCFV(L, ψ)

C ← {s ≈ t | s ≈ t ∈ L}; D← {s 6≈ t | s 6≈ t ∈ L}; ∆x ← ∅ // Init

foreach l ∈ ¬ψ doif not(Handle(C,D,∆x, l)) then

∆x ← ∆x ∪ {{x 7→ sel(x) | x ∈ x}}if ∅ ∈ ∆x then return ∅ // No σ s.t. L |= ¬ψσReset(C,D,¬ψ) // Backtracking

return {x 7→ sel(x) | x ∈ x} // L |= ¬ψσproc Handle(C,D,∆x, l)

match l :u ≈ v :

if C ∪D |= u 6≈ v then return ⊥ // Checks consistency

C ← C ∪ {u ≈ v} // Updates C ∪Du 6≈ v : ...

Λ← (Unify δ l) \C ∆x // L |= lσ, for every σ ∈ Λif Λ 6= ∅ then

let σ ∈ Λ inC← C ∪

⋃x∈dom(σ){x ≈ xσ}

return >return ⊥

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11

Page 19: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Extensions

CCFV only works in very restricted scenarios.

Basis for broader procedures.

E-matching

MBQI

Simultaneous (Bounded) Rigid E-Unification [Backeman et al., 2015]

Saturation based procedures (Inst-Gen-Eq, Hierarchic Superposition, ...)

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 10 / 11

Page 20: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Extensions

CCFV only works in very restricted scenarios.

Basis for broader procedures.

E-matching

MBQI

Simultaneous (Bounded) Rigid E-Unification [Backeman et al., 2015]

Saturation based procedures (Inst-Gen-Eq, Hierarchic Superposition, ...)

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 10 / 11

Page 21: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Extensions

CCFV only works in very restricted scenarios.

Basis for broader procedures.

E-matching

MBQI

Simultaneous (Bounded) Rigid E-Unification [Backeman et al., 2015]

Saturation based procedures (Inst-Gen-Eq, Hierarchic Superposition, ...)

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 10 / 11

Page 22: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Extensions

CCFV only works in very restricted scenarios.

Basis for broader procedures.

E-matching

MBQI

Simultaneous (Bounded) Rigid E-Unification [Backeman et al., 2015]

Saturation based procedures (Inst-Gen-Eq, Hierarchic Superposition, ...)

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 10 / 11

Page 23: Congruence Closure with Free Variables (Work in Progress) · 2017. 9. 27. · Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 9 / 11. Extensions CCFV only

Next tasks

Continue implementation.

Integrating extensions into general framework.

Handling arithmetic reasoning together with conflict driveninstantiation.

More details in the paper: http://www.loria.fr/∼hbarbosa/quantify2015.pdf

Haniel Barbosa (INRIA) Congruence Closure with Free Variables QUANTIFY 2015 11 / 11