solving exists forall problems with yices
play

Solving Exists/Forall Problems With Yices Bruno Dutertre (with Dejan - PowerPoint PPT Presentation

Computer Science Laboratory, SRI International Solving Exists/Forall Problems With Yices Bruno Dutertre (with Dejan Jovanovi c and Ian Mason) SRI International SMT Workshop 2015 Computer Science Laboratory, SRI International Exists/Forall


  1. Computer Science Laboratory, SRI International Solving Exists/Forall Problems With Yices Bruno Dutertre (with Dejan Jovanovi´ c and Ian Mason) SRI International SMT Workshop 2015

  2. Computer Science Laboratory, SRI International Exists/Forall Problems Example Synthesis Problem ◦ Find a function f such that ∀ y : Φ( y, f ( y )) ( Φ specifies the properties we want for f ) Parameterization ◦ Look at a collection of functions f x defined by a template parameterized by variables x . Example: linear functions f a,b,c ( y 1 , y 2 ) = a + by 1 + cy 2 ◦ The synthesis problem is now: find parameters x such that ∀ y : Φ( y, f x ( y )) This is an exists/forall problem: check the satisfiability of ∃ x : ∀ y : Φ( y, f x ( y )) 1

  3. Computer Science Laboratory, SRI International Example Application: Invariant Synthesis Safety Property ◦ Given a state-transition system, we want to show that all reachable states satisfy a property P ( x ) ◦ We can try to find an inductive invariant Q ( x ) : ∀ x : I ( x ) ⇒ Q ( x ) ∀ x, x ′ : Q ( x ) ∧ T ( x, x ′ ) ⇒ Q ( x ′ ) ∀ x : Q ( x ) ⇒ P ( x ) Template-Based Method ◦ Postulate that Q ( x ) is of the form F a,b,... for some unknown parameters a, b, . . . ◦ Search for a solution to the following exists/forall problem: ∃ a, b, . . . : ∀ x, x ′ : ( I ( x ) ⇒ F a,b,... ( x )) ∧ ( F a,b,... ( x ) ∧ T ( x, x ′ ) ⇒ F a,b,... ( x ′ )) ∧ ( F a,b,... ( x ) ⇒ P ( x )) 2

  4. Computer Science Laboratory, SRI International More Examples Template-based Synthesis ◦ loop-free programs (Jha et al., 2011, Jha et al. 2010) ◦ switching logic for hybrid systems (Taly et al., 2011) ◦ controller synthesis (Cheng et al., 2013, Sturm and Tiwari, 2013) Template-based Verification ◦ Lyapunov Functions: to show stability of dynamical systems ◦ Barrier Certificates for Hybrid Systems: (Prajna, 2003, . . . ) 3

  5. Computer Science Laboratory, SRI International How to Solve It? ∃ x : ∀ y : Φ( x, y ) Quantifier-Elimination Methods ◦ Rewrite ∀ y : Φ( x, y ) into an equivalent quantifier-free formula Φ ′ ( x ) ◦ Search for x that satisfies Φ ′ ( x ) Two-Solver Approach ◦ E-solver: search for candidates x ◦ F-solver: given a candidate x 0 , try to show it’s not good: search for y such that ¬ Φ( x 0 , y ) ◦ Repeat until we find a good candidate or we have exhausted all candidates 4

  6. Computer Science Laboratory, SRI International Comparison/Tradeoffs Quantifier Elimination ◦ Applicable to real arithmetic (linear and non-linear), Boolean problems, etc. ◦ Does more than we need: Φ ′ ( x ) characterizes all solutions, we just need one ◦ Typically very expensive (huge blowup in formula size) ◦ Requires specialized tools (e.g., CAD algorithm) Two Solvers ◦ Existing SMT or SAT solvers can be used ◦ Other approaches are applicable: random sampling, numerical methods ◦ Potentially more scalable than quantifier elimination (no immediate blow up) ◦ Issues – How to efficiently combine the two solvers? – How to guarantee termination? 5

  7. Computer Science Laboratory, SRI International EF-Solver Algorithm i := 0 C 0 ( x ) := initial constraints on x repeat find x i that satisfies C i ( x ) [E-Solver] if no x i is found, return unsat search for y i that satisfies ¬ Φ( x i , y ) [F-Solver] if no y i is found, then x i is a solution; return sat generalize from y i : compute a constraint G ( x ) such that 1) G ( x i ) is true 2) G ( x ) ⇒ ( ∃ y : ¬ Φ( x, y )) C i +1 ( x ) := C i ( x ) ∧ ¬ G ( x ) i := i + 1 end 6

  8. Computer Science Laboratory, SRI International Key Procedure: Generalization Three Methods Implemented in Yices ◦ baseline: just remove x i : G ( x ) := ( x = x i ) ◦ generalize by substitution: G ( x ) := ¬ Φ( x, y i ) ◦ better: local quantifier elimination – find an implicant J ( x, y ) for ¬ Φ( x, y ) using x i and y i : - J ( x, y ) is a conjunction of literals - J ( x, y ) ⇒ ¬ Φ( x, y ) holds - J ( x i , y i ) is true – construct G ( x ) by eliminating the y variables from J ( x, y ) 7

  9. Computer Science Laboratory, SRI International Convergence Termination Guarantees ◦ obvious if the x variables have a finite domain ◦ otherwise, termination depends on the generalization procedure – if the y variables have a finite domain, then generalization by substitution ensures termination – for infinite domains: some form of quantifier elimination is required Example: in linear arithmetic ∃ x ∈ R : ∀ y ∈ R : x < y This is unsat but EF-solving using generalization by substitution doesn’t converge. 8

  10. Computer Science Laboratory, SRI International Implicant Construction Goal ◦ given a formula Φ and a model M of Φ , construct a conjunction of literals I such that I ⇒ Φ and M | = I Procedure ◦ Top-down traversal of Φ , using M to guide the search. ◦ This relies on the fact that we can evaluate formulas in M . ◦ Example: to find an implicant for ( φ 1 ∨ . . . ∨ φ n ) , – search for φ i that’s true in M – then recursively compute an implicant of φ 9

  11. Computer Science Laboratory, SRI International (Simplified) Implicant Construction Imp + ( l ) := l Imp + ( f 1 ∨ f 2 ) Imp + ( f 1 ) := if f 1 is true in M Imp + ( f 2 ) := otherwise Imp + ( f 1 ∧ f 2 ) Imp + ( f 1 ) ∧ Imp + ( f 2 ) := Imp + ( ¬ f ) := Imp − ( f ) Imp − ( t = 0) := ( t > 0) if t has a positive value in M := ¬ ( t � 0) if t has a negative value in M Imp − ( t > 0) := ¬ ( t > 0) Imp − ( t � 0) := ¬ ( t � 0) Imp − ( f 1 ∨ f 2 ) := Imp − ( f 1 ) ∧ Imp − ( f 2 ) Imp − ( f 1 ∧ f 2 ) := Imp − ( f 1 ) if f 1 is false in M := Imp − ( f 2 ) otherwise Imp + ( f ) Imp − ( ¬ f ) := 10

  12. Computer Science Laboratory, SRI International Real Implicant Construction If-then-else ◦ Implicant for 1 + ( ite c x y ) � 0 can be either c ∧ 1 + x � 0 or ¬ c ∧ 1 + y � 0 . Distinct atoms ◦ ( distinct t 1 . . . t n ) is converted to a conjunction of inequalities if t 1 , . . . , t n are arithmetic terms. ◦ This is done by sorting t 1 , . . . , t n according to their values in the model. Boolean terms ◦ In some contexts, we treat Booleans as terms, in other contexts we treat them as formulas. ◦ Example: – ( x = u ) is treated as an atom if x is a Boolean variable – ( t = u ) is treated as ( t ∧ u ) ∨ ( ¬ t ∧ ¬ u ) if t and u are not variables 11

  13. Computer Science Laboratory, SRI International Variable Elimination Goal ◦ We have an implicant J ( x, y ) that is true in a model M ◦ We want to eliminate the variables y from J ( x, y ) ◦ We could try to construct a G ( x ) that’s equivalent to ∃ y : J ( x, y ) ◦ In our context, it is enough to obtain an under-approximation: G ( x ) ⇒ ∃ y : J ( x, y ) such that M | = G ( x ) For linear (and non-linear) arithmetic, we can do this efficiently using Model-Guided Virtual Term Substitution 12

  14. Computer Science Laboratory, SRI International Virtual Term Substitution for Linear Arithmetic Weispfenning, 1988, Loos & Weispfenning, 1993 ◦ To eliminate y from a linear arithmetic formula ∃ y : φ ( x, y ) , construct an elimination set for y in φ ( x, y ) ◦ An elimination set is a finite set T of terms that do not contain y and such that � ( ∃ y : φ ( x, y )) ⇔ φ ( x, t ) t ∈ T ◦ T can be constructed syntactically from the atoms of φ Example ◦ For ( ∃ y : 3 x + 1 < y ∧ y < x + 2) , Weispfenning’s procedure gives � 3 x, 3 x + 1 , 3 x + 2 , x + 1 , x + 2 , x + 3 , (3 x + 1) + ( x + 2) � T = 2 13

  15. Computer Science Laboratory, SRI International Model-Guided Virtual Term Substitution Idea ◦ We start from an elimination set T such that � ( ∃ y : φ ( x, y )) ⇔ φ ( x, t ) t ∈ T ◦ Since we can under-approximate, it’s enough for us to pick a single term t 0 in T φ ( x, t 0 ) ⇒ ( ∃ y : φ ( x, y )) ◦ We also have a model M of φ ( x, y ) so we use M to find a suitable t 0 14

  16. Computer Science Laboratory, SRI International Example ∃ y : 3 x + 1 < y ∧ y < x + 2 � � 3 x, 3 x + 1 , 3 x + 2 , x + 1 , x + 2 , x + 3 , (3 x + 1) + ( x + 2) T = 2 Model: x �→ 0 and y �→ 1 . 5 ◦ We pick t 0 = (3 x + 1) + ( x + 2) 2 then φ ( x, t 0 ) reduces to x < 1 / 2 15

  17. Computer Science Laboratory, SRI International Variable Elimination as Implemented in Yices Input ◦ The implicant construction produces a conjuction of arithmeitc inequalities and equalities Hybrid Approach ◦ eliminate variables that occur in equalities (Gaussian elimination) ◦ use Fourier-Motzkin if it’s cheap ◦ use virtual-term subsitution as a last step. 16

  18. Computer Science Laboratory, SRI International Other Tricks Preprocessing ◦ rewrite the problem to the following form: ∃ x : A ( x ) ∧ ( ∀ y 1 : B 1 ( y 1 ) ⇒ φ 1 ( x, y 1 )) . . . ∧ ( ∀ y n : B n ( y n ) ⇒ φ n ( x, y n )) ◦ this tends to give smaller problem instances to the F-solver ◦ this helps learning the initial constraints on x : (i.e., we search for y i that satisfies B i ( y i ) ) Sampling Approach ◦ to find “diverse” y i , we use a bounded variant of all-SAT 17

  19. Computer Science Laboratory, SRI International Implementation Status EF Solver ◦ Part of Yices since version 2.3. ◦ Available at http://yices.csl.sri.com/ – The EF solver supports linear real arithmetic, bitvector, and Boolean constraints – The input must be given in the Yices language – Generalization and implicant construction are in the API 18

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend