synthesis by quantifier
play

Synthesis by Quantifier Instantiation in CVC4 Andrew Reynolds May - PowerPoint PPT Presentation

Synthesis by Quantifier Instantiation in CVC4 Andrew Reynolds May 4, 2015 Overview SMT solvers : how they work Synthesis Problem : f. x. P( f, x ) There exists a function f such that for all x, P( f, x ) New approaches for


  1. Synthesis by Quantifier Instantiation in CVC4 Andrew Reynolds May 4, 2015

  2. Overview • SMT solvers : how they work • Synthesis Problem :  f.  x. P( f, x ) There exists a function f such that for all x, P( f, x ) • New approaches for synthesis problems in an SMT solver [CAV 15] • Implemented in the SMT solver CVC4 • Evaluation

  3. SMT solvers • Are powerful tools used in many formal methods applications: • Software and Hardware verification • Automated Theorem Proving • Scheduling and Planning • Software synthesis • Reason about Boolean combinations of theory constraints: • Linear arithmetic : 2*a+1>0 • Bitvectors : bvsgt(a,#bin0001) • Arrays : select(store(a,5,b),c)=5 • Datatypes : tail(cons(a,b))=b • ….

  4. SMT Solver for Theory T SMT Solver Decision SAT DPLL(T) Procedure Solver for T • Combines: • Off the shelf SAT solver • (Possibly combined) decision procedure for decidable theory T • Components communicate via DPLL(T) framework

  5. SMT Solver for Theory T F SMT Solver Decision SAT DPLL(T) Procedure Solver for T unsat sat • Determines if set of formulas F is T-satisfiable

  6. SMT Solver for Theory T f(a)>0  f(a)<4 SMT Solver Decision SAT DPLL(T) Procedure Solver for T • Model, for example f(a)=1 unsat sat

  7. SMT Solver for Theory T f(a)>0  f(a)<-1 SMT Solver Decision SAT DPLL(T) Procedure Solver for T • No model unsat sat

  8. SMT Solver for Theory T f(a)>0  f(a)<-1 SMT Solver Decision SAT DPLL(T) Procedure Solver for T unsat sat • For decidable theories (e.g. here T is T UF +T LIA ) • Solver is terminating �ith either � unsat � or �sat�

  9. SMT Solver + Quantified Formulas SMT solver Ground solver Quantifiers Decision SAT DPLL(T) Procedure Module Solver for T • SMT solvers have limited support for (first-order) quantified formulas 

  10. SMT Solver + Quantified Formulas  x.f(x)<0 f(a)>0 Ground solver Quantifiers Decision SAT DPLL(T) Procedure Module Solver for T • For input f(a)>0   x.f(x)<0 • Ground solver maintains a set of ground (variable-free) constraints : f(a)>0 • Quantifiers Module maintains a set of axioms :  x.f(x)<0

  11. SMT Solver + Quantified Formulas  x.f(x)<0 f(a)>0 Ground solver Quantifiers Decision SAT DPLL(T) Procedure Module Solver for T

  12. SMT Solver + Quantified Formulas  x.f(x)<0 f(a)>0 Ground solver Quantifiers Decision SAT DPLL(T) Procedure Module Solver for T sat unsat • Ground solver checks T-satisfiability of current set of constraints

  13. SMT Solver + Quantified Formulas  x.f(x)<0 f(a)>0, f(a)<0,f(b)<0 ,… Ground solver instances Quantifiers Decision SAT DPLL(T) Procedure Module Solver for T • Quantifiers Module adds instances of axioms • Goal : add i�sta�ces u�til grou�d sol�er ca� a�s�er � unsat �

  14. SMT Solver + Quantified Formulas  x.f(x)<0 f(a)>0,f(a)<0 ,f(b)<0,… Ground solver Quantifiers Decision SAT DPLL(T) Procedure Module Solver for T • Since f(a)>0 and f(a)<0 unsat

  15. SMT Solver + Quantified Formulas F,Q[t 1 ],Q[t 2 ],… Q[x] Ground solver instances of Q Quantifiers Decision SAT DPLL(T) Procedure Module Solver for T  sat sat unsat sat • Generally, a sound but incomplete procedure • Difficult to answer sat (when have we added enough instances of Q[x] ?)

  16. Approaches for Quantifiers in SMT • Heuristic instantiation �good for � unsat ��: • E-matching [Detlefs et al 2003, Ge et al 2007, de Moura/Bjorner 2007] • Complete approaches ��ay a�s�er �sat��: • Local theory extensions [Sofronie-Stokkermans 2005] • Array fragments [Bradley et al 2006, Alberti et al 2014] • Complete instantiation [Ge/de Moura 2009] • Finite model finding [Reynolds et al 2013]  Each limited to a particular fragment

  17. The Synthesis problem  f.  x .P(f, x ) such that for all x , property P holds There exists a function f • Most existing approaches for synthesis • E.g. [Solar-Lezama et al 2006, Udupa et al 2013, Milicevic et al 2014] • Rely on specialized solver that makes subcalls to an SMT Solver • Approach for synthesis in this talk: • Instrument an approach for synthesis entirely inside SMT solver

  18. Running Example : Max of Two Integers  f.  xy.(f(x,y )≥x  f(x,y) ≥y  (f(x,y)=x  f(x,y)=y)) • Specifies that f computes the maximum of integers x and y • Solution: f := l xy.ite(x>y,x,y)

  19. How does an SMT solver handle Max example?  f.  xy.(f(x,y )≥x  f(x,y) ≥y  (f(x,y)=x  f(x,y)=y))

  20. How does an SMT solver handle Max example? f : Int  Int  Int  xy.(f(x,y )≥x  f(x,y) ≥y  (f(x,y)=x  f(x,y)=y)) • Straightforward approach: • Treat f as an uninterpreted function • Succeed if SMT solver can find correct interpretation of f , a�s�er �sat�  However, this is challenging • SMT solvers have limited ability to find models when  are present • It is difficult to directly synthesize interpretation l xy.ite(x>y,x,y)

  21. Refutation-Based Synthesis  f.  x .P(f, x ) • “i�ce “MT sol�ers are li�ited at a�s�eri�g �sat� �he�  are present,  Can we instead use a refutation-based approach for synthesis?

  22. What if we negate the synthesis conjecture?   f.  x .P(f, x ) • Negate the synthesis conjecture • If we are in a satisfaction-complete theory T (e.g. linear arithmetic, bitvectors): • F is T-satisfiable if and only if  F is T-unsatisfiable • In such cases: • If SMT solver can establish  f.  x .P(f, x ) is unsatisfiable • Then we know that  f.  x .P(f, x ) is satisfiable ( f has a solution)

  23. Challenge: Second-Order Quantification   f.  x .P(f, x ) negate  f.  x .  P(f, x ) • Want to show negated formula is unsatisfiable • Challenge: outermost quantification  f over function f • No SMT solvers directly support second-order quantification • However, we can avoid this quantification using two approaches: 1. When property P is single invocation for f 2. When f is given syntactic restrictions

  24. Challenge: Second-Order Quantification   f.  x .P(f, x ) negate  f.  x .  P(f, x ) • Want to show negated formula is unsatisfiable • Challenge: outermost quantification  f over function f • No SMT solvers directly support second-order quantification • However, we can avoid this quantification using two approaches: 1. When property P is single invocation for f  Focus of this talk 2. When f is given syntactic restrictions

  25. Single Invocation Property : Max Example  f.  xy.(f(x,y)<x  f(x,y)<y  (f(x,y )≠x  f(x,y )≠y))

  26. Single Invocation Property : Max Example  f.  xy.(f(x,y)<x  f(x,y)<y  (f(x,y) ≠x  f(x,y) ≠y)) • Single invocation properties • Are properties such that: • All occurrences of f are of a particular form, e.g. f(x,y) above • Are a common class of properties useful for: • Software Synthesis (post-conditions describing the result of a function) • Examples of properties that are not single invocation: •  c.  xy.c(x,y)=c(y,x) , e.g. c is commutative

  27. Single Invocation Property : Max Example  f.  xy.(f(x,y)<x  f(x,y)<y  (f(x,y) ≠x  f(x,y) ≠y)) Push quantification downwards  xy.  g.(g<x  g<y  (g ≠x  g ≠y )) • Occurrences of f(x,y) are replaced with integer variable g • Resulting formula is equisatisfiable, and first-order

  28. Single Invocation Property : Max Example  f.  xy.(f(x,y)<x  f(x,y)<y  (f(x,y )≠x  f(x,y )≠y)) Push quantification downwards  xy.  g.(g<x  g<y  (g ≠x  g ≠y )) Skolemize, for fresh a and b  g.(g<a  g<b  (g ≠ a  g ≠ b))

  29. Solving Max Example  g.(g<a  g<b  (g ≠a  g ≠b ))

  30. Solving Max Example  g.(g<a  g<b  (g ≠a  g ≠b )) Quantifiers Ground Module solver

  31. Solving Max Example ( a <a  a <b  ( a ≠a  a ≠b ))   g.(g<a  g<b  (g ≠a  g ≠b )) ( b <a  b <b  ( b ≠ a  b ≠ b))  Quantifiers instances Ground a /g, b /g Module solver

  32. Solving Max Example a<b   g.(g<a  g<b  (g ≠a  g ≠b )) simplify b<a  Quantifiers Ground Module solver

  33. Solving Max Example a<b   g.(g<a  g<b  (g ≠a  g ≠b )) b<a  Quantifiers Ground Module solver   g.(g<a  g<b  ( g≠a  g≠b )) is unsatisfable, unsat implies original synthesis conjecture has a solution

  34.  f.  x .P(f( x ), x ) How do we get solutions? Quantifiers Ground Module solver • Given refutation-based approach for synthesis conjecture  f.  x .P(f( x ), x )  Solution for f can be extracted from unsatisfiable core of instantiations

  35.  f.  x .P(f( x ), x ) How do we get solutions? negate, translate to FO  g.  P(g, k ) Quantifiers Ground Module solver

  36.  f.  x .P(f( x ), x ) How do we get solutions? negate, translate to FO  P(t 1 , k ),…,  P(t n , k )  g.  P(g, k ) Quantifiers instances Ground Module solver

Recommend


More recommend