E-Matching with Free Variables Philipp Rmmer Uppsala University - - PowerPoint PPT Presentation

e matching with free variables
SMART_READER_LITE
LIVE PREVIEW

E-Matching with Free Variables Philipp Rmmer Uppsala University - - PowerPoint PPT Presentation

E-Matching with Free Variables Philipp Rmmer Uppsala University Sweden FATPA Workshop Belgrade February 3rd 2012 1 / 25 Context: reasoning in first-order logic (FOL) First-order provers SMT solvers Resolution, superposition, DPLL(T) ,


slide-1
SLIDE 1

E-Matching with Free Variables

Philipp Rümmer Uppsala University Sweden FATPA Workshop Belgrade February 3rd 2012

1 / 25

slide-2
SLIDE 2

Context: reasoning in first-order logic (FOL)

First-order provers SMT solvers Resolution, superposition, tableaux, etc. DPLL(T), Nelson-Oppen (Free) variables, unification E-matching, heuristics Complete for FOL Complete on ground fragment Many built-in theories Great for algebra, not so much for verification Fast, but incomplete on quantified problems

2 / 25

slide-3
SLIDE 3

How about putting things together?

This is possible. Here: KE-tableau/DPLL FOL Theory procedures Arithmetic E-matching Axiomatisation of theories Free variables + constraints Quantifiers Interesting completeness results Experimental implementation: PRINCESS In some domains: Performance comparable to SMT solvers Some features that are rather unique

3 / 25

slide-4
SLIDE 4

How about putting things together?

This is possible. Here: KE-tableau/DPLL FOL Theory procedures Arithmetic E-matching Axiomatisation of theories Free variables + constraints Quantifiers Interesting completeness results Experimental implementation: PRINCESS In some domains: Performance comparable to SMT solvers Some features that are rather unique

3 / 25

slide-5
SLIDE 5

Outline

The base logic + calculus: Linear integer arithmetic + uninterpreted predicates Positive Unit Hyper-Resolution (PUHR) Uninterpreted functions: Encoding + Axioms E-matching Experimental results More details: paper at LPAR 2012

4 / 25

slide-6
SLIDE 6

The base logic [LPAR’08]

Linear integer arithmetic + uninterpreted predicates: t ::= α | | x | | c | | αt + · · · + αt φ ::= φ ∧ φ | | φ ∨ φ | | ¬φ | | ∀x.φ | | ∃x.φ | | t . = 0 | | t

.

≥ 0 | | t

.

≤ 0 | | α | t | | p(t, . . . , t) t . . . terms φ . . . formulae x . . . variables c . . . constants p . . . uninterpreted predicates (fixed arity) α . . . integer literals (❩)

5 / 25

slide-7
SLIDE 7

The base logic [LPAR’08]

Linear integer arithmetic + uninterpreted predicates: t ::= α | | x | | c | | αt + · · · + αt φ ::= φ ∧ φ | | φ ∨ φ | | ¬φ | | ∀x.φ | | ∃x.φ | | t . = 0 | | t

.

≥ 0 | | t

.

≤ 0 | | α | t | | p(t, . . . , t) No functions! (more later) Subsumes FOL and Presburger arithmetic (PA) Valid formulae are not enumerable [Halpern, 1991]

5 / 25

slide-8
SLIDE 8

Example formula: optimisation

\forall int x, y; ( p(x, y) <-> (2*x + y <= 18 & 2*x + 3*y <= 42 & 3*x + y <= 24 & x >= 0 & y >= 0) )

  • >

\exists int x, y; ( p(x, y) & \forall int x2, y2; ( p(x2, y2) -> 3*x + 2*y >= 3*x2 + 2*y2) )

6 / 25

slide-9
SLIDE 9

Abstract calculus

Input formula (with preds.): φ

7 / 25

slide-10
SLIDE 10

Abstract calculus

Input formula (with preds.): φ ⇑ Compute PA approximation: C0

7 / 25

slide-11
SLIDE 11

Abstract calculus

Input formula (with preds.): φ ⇑ Compute PA approximation: C0 C0 is valid = ⇒ φ is valid

7 / 25

slide-12
SLIDE 12

Abstract calculus

Input formula (with preds.): φ ⇑ Compute PA approximation: C0 C0 is invalid . . . refine approximation

7 / 25

slide-13
SLIDE 13

Abstract calculus

Input formula (with preds.): φ ⇑ ⇑ Compute PA approximation: C0 ⇒ C1 C0 is invalid . . . refine approximation

7 / 25

slide-14
SLIDE 14

Abstract calculus

Input formula (with preds.): φ ⇑ ⇑ Compute PA approximation: C0 ⇒ C1 ⇒ C2 · · · C0 is invalid . . . refine approximation

7 / 25

slide-15
SLIDE 15

Abstract calculus

Input formula (with preds.): φ ⇑ ⇑ Compute PA approximation: C0 ⇒ C1 ⇒ C2 · · · C0 is invalid . . . refine approximation Any Ci is valid = ⇒ φ is valid

7 / 25

slide-16
SLIDE 16

Approximation? Constrained sequents!

Notation used here: Γ ⊢ ∆

Antecedent, Succedent (sets of formulae)

⇓ C

  • Constraint/approximation

(formula)

Definition Γ ⊢ ∆ ⇓ C is valid if the formula C → Γ → ∆ is valid.

8 / 25

slide-17
SLIDE 17

Iterative proof construction

Γ ⊢ ∆ ⇓ ?

9 / 25

slide-18
SLIDE 18

Iterative proof construction

analytic reasoning about input formula

  Γ ⊢ ∆ ⇓ ?

9 / 25

slide-19
SLIDE 19

Iterative proof construction

analytic reasoning about input formula

  Γ1 ⊢ ∆1 ⇓ ? . . . . Γ ⊢ ∆ ⇓ ?

9 / 25

slide-20
SLIDE 20

Iterative proof construction

analytic reasoning about input formula

  Γ2 ⊢ ∆2 ⇓ ? Γ1 ⊢ ∆1 ⇓ ? . . . . Γ ⊢ ∆ ⇓ ?

9 / 25

slide-21
SLIDE 21

Iterative proof construction

analytic reasoning about input formula

  Γ3 ⊢ ∆3 ⇓ ? Γ2 ⊢ ∆2 ⇓ ? Γ1 ⊢ ∆1 ⇓ ? . . . . Γ ⊢ ∆ ⇓ ?

9 / 25

slide-22
SLIDE 22

Iterative proof construction

analytic reasoning about input formula

  ∗ . . . . Γ3 ⊢ ∆3 ⇓ ? Γ2 ⊢ ∆2 ⇓ ? Γ1 ⊢ ∆1 ⇓ ? . . . . Γ ⊢ ∆ ⇓ ?

9 / 25

slide-23
SLIDE 23

Iterative proof construction

analytic reasoning about input formula

  ∗ . . . . Γ3 ⊢ ∆3 ⇓ ? Γ2 ⊢ ∆2 ⇓ ? Γ1 ⊢ ∆1 ⇓ ? . . . . Γ ⊢ ∆ ⇓ ?   

  • propagation
  • f constraints

9 / 25

slide-24
SLIDE 24

Iterative proof construction

analytic reasoning about input formula

  ∗ . . . . Γ3 ⊢ ∆3 ⇓ C1 Γ2 ⊢ ∆2 ⇓ ? Γ1 ⊢ ∆1 ⇓ ? . . . . Γ ⊢ ∆ ⇓ ?   

  • propagation
  • f constraints

9 / 25

slide-25
SLIDE 25

Iterative proof construction

analytic reasoning about input formula

  ∗ . . . . Γ3 ⊢ ∆3 ⇓ C1 Γ2 ⊢ ∆2 ⇓ C2 Γ1 ⊢ ∆1 ⇓ ? . . . . Γ ⊢ ∆ ⇓ ?   

  • propagation
  • f constraints

9 / 25

slide-26
SLIDE 26

Iterative proof construction

analytic reasoning about input formula

  ∗ . . . . Γ3 ⊢ ∆3 ⇓ C1 Γ2 ⊢ ∆2 ⇓ C2 Γ1 ⊢ ∆1 ⇓ C3 . . . . Γ ⊢ ∆ ⇓ ?   

  • propagation
  • f constraints

9 / 25

slide-27
SLIDE 27

Iterative proof construction

analytic reasoning about input formula

  ∗ . . . . Γ3 ⊢ ∆3 ⇓ C1 Γ2 ⊢ ∆2 ⇓ C2 Γ1 ⊢ ∆1 ⇓ C3 . . . . Γ ⊢ ∆ ⇓ C   

  • propagation
  • f constraints

9 / 25

slide-28
SLIDE 28

Iterative proof construction

analytic reasoning about input formula

  ∗ . . . . Γ3 ⊢ ∆3 ⇓ C1 Γ2 ⊢ ∆2 ⇓ C2 Γ1 ⊢ ∆1 ⇓ C3 . . . . Γ ⊢ ∆ ⇓ C   

  • propagation
  • f constraints

Constraints are simplified during propagation If C is valid, then so is Γ ⊢ ∆ If C is satisfiable, it describes a solution for Γ ⊢ ∆ If C is unsatisfiable, expand the proof tree further . . .

9 / 25

slide-29
SLIDE 29

A few proof rules

Γ ⊢ φ, ∆ ⇓ C Γ ⊢ ψ, ∆ ⇓ D Γ ⊢ φ ∧ ψ, ∆ ⇓ C ∧ D

AND-RIGHT

Γ, [x/c]φ, ∀x.φ ⊢ ∆ ⇓ [x/c]C Γ, ∀x.φ ⊢ ∆ ⇓ ∃x.C

ALL-LEFT

(c is fresh) Γ, p(¯ s) ⊢ p(¯ t), ¯ s . = ¯ t , ∆ ⇓ C Γ, p(¯ s) ⊢ p(¯ t), ∆ ⇓ C

PRED-UNIFY

∗ Γ, φ1, . . . , φn ⊢ ψ1, . . . , ψm, ∆ ⇓ ¬φ1 ∨ · · · ∨ ¬φn ∨ ψ1 ∨ · · · ∨ ψm

CLOSE

(selected formulae are predicate-free)

10 / 25

slide-30
SLIDE 30

Correctness

Lemma (Soundness) It’s sound! Lemma (Completeness) Complete for fragments: FOL PA Purely existential formulae Purely universal formulae Universal formulae with finite parametrisation (same as ME(LIA))

11 / 25

slide-31
SLIDE 31

Practicality

12 / 25

slide-32
SLIDE 32

Practicality

So far: quantifier instantiation is always delayed: . . . . . . , p(¯ s) ⊢ p(¯ t), ¯ s . = ¯ t, . . . . . . , p(¯ s) ⊢ p(¯ t), . . .

PRED-UNIFY

. . . Γ, [x/c]φ, ∀x.φ ⊢ ∆ Γ, ∀x.φ ⊢ ∆

ALL-LEFT

. . .

12 / 25

slide-33
SLIDE 33

Practicality

So far: quantifier instantiation is always delayed: . . . . . . , p(¯ s) ⊢ p(¯ t), ¯ s . = ¯ t, . . . . . . , p(¯ s) ⊢ p(¯ t), . . .

PRED-UNIFY

. . . Γ, [x/c]φ, ∀x.φ ⊢ ∆ Γ, ∀x.φ ⊢ ∆

ALL-LEFT

. . . This corresponds to . . . Free variables + Unification Standard approach in FOL provers

12 / 25

slide-34
SLIDE 34

Alternative: E-Matching, standard in SMT solvers

Matching of triggers (modulo equations): Γ, ∀¯ x.φ[t[¯ x]], [¯ x/¯ s]φ[t[¯ x]] ⊢ ψ[t[¯ s]], ∆ Γ, ∀¯ x.φ[t[¯ x]] ⊢ ψ[t[¯ s]], ∆

13 / 25

slide-35
SLIDE 35

Alternative: E-Matching, standard in SMT solvers

Matching of triggers (modulo equations): Γ, ∀¯ x.φ[t[¯ x]], [¯ x/¯ s]φ[t[¯ x]] ⊢ ψ[t[¯ s]], ∆ Γ, ∀¯ x.φ[t[¯ x]] ⊢ ψ[t[¯ s]], ∆ \forall int a, i, v; select(store(a, i, v), i) = v \forall int a, i1, i2, v; (i1 != i2 -> select(store(a, i1, v), i2) = select(a, i2))

13 / 25

slide-36
SLIDE 36

Alternative: E-Matching, standard in SMT solvers

Matching of triggers (modulo equations): Γ, ∀¯ x.φ[t[¯ x]], [¯ x/¯ s]φ[t[¯ x]] ⊢ ψ[t[¯ s]], ∆ Γ, ∀¯ x.φ[t[¯ x]] ⊢ ψ[t[¯ s]], ∆ \forall int a, i, v; select(store(a, i, v), i) = v \forall int a, i1, i2, v; (i1 != i2 -> select(store(a, i1, v), i2) = select(a, i2))

13 / 25

slide-37
SLIDE 37

Comparison

E-Matching Free variables + unification Heuristic → incomplete Systematic Good for “simple” instances Can find “difficult” instances User guidance possible → Triggers Quite fast Quite expensive → Only ground formulae → Very nondeterministic

14 / 25

slide-38
SLIDE 38

Comparison

E-Matching Free variables + unification Heuristic → incomplete Systematic Good for “simple” instances Can find “difficult” instances User guidance possible → Triggers Quite fast Quite expensive → Only ground formulae → Very nondeterministic Combination?

14 / 25

slide-39
SLIDE 39

Comparison

E-Matching Free variables + unification Heuristic → incomplete Systematic Good for “simple” instances Can find “difficult” instances User guidance possible → Triggers Quite fast Quite expensive → Only ground formulae → Very nondeterministic Combination!

1

For predicates: Positive unit hyper-resolution (PUHR)

2

Lifted to functions using encoding

14 / 25

slide-40
SLIDE 40

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms)

15 / 25

slide-41
SLIDE 41

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-42
SLIDE 42

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-43
SLIDE 43

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) . . . , p(X) ⊢ ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-44
SLIDE 44

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) . . . , p(X) ⊢ ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-45
SLIDE 45

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) q(X) ∨ r(X + 1) ⊢ . . . , p(X) ⊢ ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-46
SLIDE 46

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) q(X) ⊢ r(X + 1) ⊢ q(X) ∨ r(X + 1) ⊢ . . . , p(X) ⊢ ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-47
SLIDE 47

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) q(X) ⊢ r(X + 1) ⊢ q(X) ∨ r(X + 1) ⊢ . . . , p(X) ⊢ ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-48
SLIDE 48

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) q(X) ⊢ ∗ false ⊢ r(X + 1) ⊢ q(X) ∨ r(X + 1) ⊢ . . . , p(X) ⊢ ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-49
SLIDE 49

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) q(X) ⊢ ∗ false ⊢ r(X + 1) ⊢ q(X) ∨ r(X + 1) ⊢ . . . , p(X) ⊢ ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-50
SLIDE 50

Positive Unit Hyper-Resolution [Manthey, Bry]

Directed instantiation of formulae: Formulae with negative literals: ⇒ Discharge with unit resolution Formulae without negative literals: ⇒ Instantiate with free variables (or: enumerate ground terms) ∗ q(X) ⊢ ⇓ X . = a ∗ false ⊢ r(X + 1) ⊢ q(X) ∨ r(X + 1) ⊢ . . . , p(X) ⊢ ∀x.p(x), ∀x.

  • p(x) → q(x) ∨ r(x + 1)
  • , ∀x.¬r(x) ⊢ q(a)

15 / 25

slide-51
SLIDE 51

PUHR in our calculus

Theorem (Completeness) Suppose Γ ⊢ ∆ ⇓ C is provable in the calculus without PUHR, where C is valid. Then there is a valid constraint C′ so that the calculus with PUHR can prove Γ ⊢ ∆ ⇓ C′. In PRINCESS: PUHR normally yields drastic speed-up (but not always)

16 / 25

slide-52
SLIDE 52

Lifting to functions

17 / 25

slide-53
SLIDE 53

Lifting to functions

Functions almost like in SMT: Terms are always flattened n-ary function f becomes (n + 1)-ary predicate fp E.g. g(f(x), a)

  • f(x) = c ∧ g(c, a) = d
  • fp(x, c) ∧ gp(c, a, d)

17 / 25

slide-54
SLIDE 54

Lifting to functions

Functions almost like in SMT: Terms are always flattened n-ary function f becomes (n + 1)-ary predicate fp E.g. g(f(x), a)

  • f(x) = c ∧ g(c, a) = d
  • fp(x, c) ∧ gp(c, a, d)

Axioms necessary: Totality + Functionality ∀¯ x.∃y. fp(¯ x, y) ∀¯ x, y1, y2. (fp(¯ x, y1) → fp(¯ x, y2) → y1 . = y2)

17 / 25

slide-55
SLIDE 55

Lifting to functions

Functions almost like in SMT: Terms are always flattened n-ary function f becomes (n + 1)-ary predicate fp E.g. g(f(x), a)

  • f(x) = c ∧ g(c, a) = d
  • fp(x, c) ∧ gp(c, a, d)

Axioms necessary: Totality + Functionality ∀¯ x.∃y. fp(¯ x, y) ∀¯ x, y1, y2. (fp(¯ x, y1) → fp(¯ x, y2) → y1 . = y2) Very closely resembles congruence closure

17 / 25

slide-56
SLIDE 56

E-Matching through PUHR

Two ways to encode function applications: φ[f(¯ t)]

  • ∀y.(¬fp(¯

t, y) ∨ φ[y]) (negative)

  • ∃y.(fp(¯

t, y) ∧ φ[y]) (positive)

18 / 25

slide-57
SLIDE 57

E-Matching through PUHR

Two ways to encode function applications: φ[f(¯ t)]

  • ∀y.(¬fp(¯

t, y) ∨ φ[y]) (negative)

  • ∃y.(fp(¯

t, y) ∧ φ[y]) (positive) ⇒ Useful: PUHR only matches on negative literals

18 / 25

slide-58
SLIDE 58

E-Matching through PUHR

Two ways to encode function applications: φ[f(¯ t)]

  • ∀y.(¬fp(¯

t, y) ∨ φ[y]) (negative)

  • ∃y.(fp(¯

t, y) ∧ φ[y]) (positive) ⇒ Useful: PUHR only matches on negative literals ∀¯ x.φ[t[¯ x]] negative encoding for trigger t[¯ x] positive encoding for other functions

18 / 25

slide-59
SLIDE 59

Example

∀x. f(x) ≥ 0 If f(x) is trigger: ∀x, y.

  • ¬fp(x, y) ∨ y ≥ 0
  • If f(x) is not trigger:

∀x.∃y.

  • fp(x, y) ∧ y ≥ 0
  • 19 / 25
slide-60
SLIDE 60

The highlight: relative completeness

In SMT solvers: Choice of triggers determines provability Bad triggers → bad luck In the PUHR calculus: Choice of triggers determines performance Regardless of triggers, the same formulae are provable E-matching is complemented by free variables + unification

20 / 25

slide-61
SLIDE 61

Where are we? Experimental evaluation

AUFLIA+p (193) AUFLIA-p (193) Z3 191 191 PRINCESS 145 137 CVC3 132 128 Implementation of our calculus in PRINCESS Unsatisfiable AUFLIA benchmarks from SMT-comp 2011 Intel Core i5 2-core, 3.2GHz, timeout 1200s, 4Gb

http://www.philipp.ruemmer.org/princess.shtml

21 / 25

slide-62
SLIDE 62

Conclusion

E-Matching = Relational function encoding + PUHR Overall goal: Tools that provide the performance of SMT solvers, but completeness as common in FOL provers Presented work is one step on this way There is more to say, e.g.: Connection to constraint programming Theory of arrays, sets Handling of bit-vectors Craig interpolation

22 / 25

slide-63
SLIDE 63

Thanks for your attention!

23 / 25

slide-64
SLIDE 64

Related work

ME(LIA): model evolution modulo linear integer arithmetic, [Baumgartner, Tinelli, Fuchs, 08] SPASS+T [Prevosto, Waldmann, ESCoR’06] DPLL(SP) [de Moura, Bjørner, IJCAR’08] Various approaches to integrate theories in saturation calculi, e.g. [Stickel, JAR’85], [Bürchert, CADE’90], [Korovin, Voronkov, CSL ’07] Constraint logic programming Various SMT solvers

24 / 25

slide-65
SLIDE 65

Open PhD Position at Uppsala University

I’m looking to hire a PhD student: Subject areas: SMT, floating-point arithmetic, Craig interpolation; Application in embedded systems analysis Contact me for more information Pass on to students that might be interested

25 / 25