program transformation and constraint based verification
play

Program Transformation and Constraint-based Verification Valerio - PowerPoint PPT Presentation

Program Transformation and Constraint-based Verification Valerio Senni Department of Computer Science, Systems and Production University of Rome Tor Vergata, Italy joint work with E. De Angelis, F . Fioravanti, A. Pettorossi, M.


  1. Program Transformation and Constraint-based Verification Valerio Senni Department of Computer Science, Systems and Production University of Rome ‘Tor Vergata’, Italy joint work with E. De Angelis, F . Fioravanti, A. Pettorossi, M. Proietti CPmeetsCAV 2012, Turunç 1 / 99

  2. Introduction Rule-Based Program Transformation - Origins rule-based �− → . . . �− → initial P 0 P n final model-preserving M ( P 0 ) = . . . = M ( P n ) (local) rewriting An approach to developing correct & efficient programs [Burstall-Darlington 77] → ∗ P 0 �− P n ’easy-to-prove-correct’ correct & efficient M ( P 0 ) = M ( P n ) → ∗ �− ≡ optimization Separate correctness concerns from efficiency concerns → ∗ constructed according to a strategy �− 2 / 99

  3. Introduction Constraint Logic Programming Programs as sets of rules (clauses) of the form: H ← c ∧ B (meaning, H holds if c is satisfiable in T and B holds) ∧ Example: ordered([]) ordered([ x ]) ordered([ x 1 , x 2 | L ]) ← x 1 ≤ x 2 ordered([ x 2 | L ]) ∧ ∧ � �� � � �� � solver for T resolution Query evaluation: ⇒ k d ∧ ∧ G = c 1 ∧ ∧ . . . ∧ ∧ c n ∧ c n T -satisfiable) (with c 1 ∧ ∧ . . . ∧ ρ (and ρ = ϑ 1 · . . . · ϑ k ) 1. d ∧ ∧ G = d ∧ ∧ A ∧ ∧ R current goal ⇒ 1 = is 2. ( A = H ) ϑ find unifying head ϑ 3. ( d ∧ ∧ c ∧ ∧ B ∧ ∧ R ) ϑ rewrite 3 / 99

  4. Introduction Transformation of Constraint Logic Programs A program as a first order theory: theory transformation (changing the axioms of a theory, while preserving the model) Syntax Semantics logic programs least Herbrand model + negation perfect model, stable models + constraints least/perfect D -model 4 / 99

  5. Introduction Rules Definition Introduction �− → newp ( x ) ← c ( x ) ∧ p 1 ( x ) ∧ . . . ∧ p n ( x ) Unfolding p ( x ) ← d 1 ∧ B 1 H ← c ∧ d 1 ∧ B 1 ∧ R . . . . H ← c ∧ p ( x ) ∧ R �− → . . p ( x ) ← d n ∧ B n H ← c ∧ d n ∧ B n ∧ R Folding c ⊑ d p ( x ) ← d ∧ B H ← c ∧ B ∧ R �− → H ← c ∧ p ( x ) ∧ R Clause Removal 1. H ← c ∧ B �− → H ← d if c ⊑ d ( c entails d ) H ← d 2. H ← c ∧ B �− → ∅ if c is unsatisfiable Rearrangement, Addition/Deletion, Constraint Rewriting 5 / 99

  6. Introduction An Introductory Example 6 / 99

  7. Introduction An Introductory Example 7 / 99

  8. Introduction An Introductory Example 8 / 99

  9. Introduction An Introductory Example 9 / 99

  10. Introduction An Introductory Example 10 / 99

  11. Introduction An Introductory Example 11 / 99

  12. Introduction An Introductory Example 12 / 99

  13. Introduction An Introductory Example 13 / 99

  14. Introduction An Introductory Example 14 / 99

  15. Introduction An Introductory Example 15 / 99

  16. Introduction An Introductory Example 16 / 99

  17. Introduction An Introductory Example 17 / 99

  18. Introduction An Introductory Example 18 / 99

  19. Introduction Transformation Strategies Directed by syntactic features of programs: Specializing programs to the context of use (pre-computing) snm(S) ← near_match( [2,0] , 2 ,S) Avoiding the computation of unnecessary values ,K,S) ← a( L ,T,S) ∧ near_match(P ∧ a(Q,R,T) ∧ ∧ near(P ,K,Q) Avoding multiple visits of data structures and repeated computations near_match(P ,K,S) ← a(L, T ,S) ∧ ∧ a( Q ,R, T ) ∧ ∧ near(P ,K, Q ) Reducing nondeterminism (avoid multiple matchings per call-pattern) snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ a(Q,R,S) ∧ ∧ n([0],2,Q) snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ a(L,T,S) ∧ ∧ a(Q,R,T) ∧ ∧ near([2,0],2,Q) ⇓ snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ new1(S) 19 / 99

  20. Introduction Transformation Strategies Directed by syntactic features of programs: Specializing programs to the context of use (pre-computing) snm(S) ← near_match( [2,0] , 2 ,S) Avoiding the computation of unnecessary values ,K,S) ← a( L ,T,S) ∧ near_match(P ∧ a(Q,R,T) ∧ ∧ near(P ,K,Q) Avoding multiple visits of data structures and repeated computations near_match(P ,K,S) ← a(L, T ,S) ∧ ∧ a( Q ,R, T ) ∧ ∧ near(P ,K, Q ) Reducing nondeterminism (avoid multiple matchings per call-pattern) snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ a(Q,R,S) ∧ ∧ n([0],2,Q) snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ a(L,T,S) ∧ ∧ a(Q,R,T) ∧ ∧ near([2,0],2,Q) ⇓ snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ new1(S) 20 / 99

  21. Introduction Transformation Strategies Directed by syntactic features of programs: Specializing programs to the context of use (pre-computing) snm(S) ← near_match( [2,0] , 2 ,S) Avoiding the computation of unnecessary values ,K,S) ← a( L ,T,S) ∧ near_match(P ∧ a(Q,R,T) ∧ ∧ near(P ,K,Q) Avoding multiple visits of data structures and repeated computations near_match(P ,K,S) ← a(L, T ,S) ∧ ∧ a( Q ,R, T ) ∧ ∧ near(P ,K, Q ) Reducing nondeterminism (avoid multiple matchings per call-pattern) snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ a(Q,R,S) ∧ ∧ n([0],2,Q) snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ a(L,T,S) ∧ ∧ a(Q,R,T) ∧ ∧ near([2,0],2,Q) ⇓ snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ new1(S) 21 / 99

  22. Introduction Transformation Strategies Directed by syntactic features of programs: Specializing programs to the context of use (pre-computing) snm(S) ← near_match( [2,0] , 2 ,S) Avoiding the computation of unnecessary values ,K,S) ← a( L ,T,S) ∧ near_match(P ∧ a(Q,R,T) ∧ ∧ near(P ,K,Q) Avoding multiple visits of data structures and repeated computations near_match(P ,K,S) ← a(L, T ,S) ∧ ∧ a( Q ,R, T ) ∧ ∧ near(P ,K, Q ) Reducing nondeterminism (avoid multiple matchings per call-pattern) snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ a(Q,R,S) ∧ ∧ n([0],2,Q) snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ a(L,T,S) ∧ ∧ a(Q,R,T) ∧ ∧ near([2,0],2,Q) ⇓ snm([X|S]) ← 0 ≤ X ≤ 4 ∧ ∧ new1(S) 22 / 99

  23. Introduction Rule-Based Program Transformation - More P 0 �− → . . . �− → P n What do we preserve? M ( P 0 ) = . . . = M ( P n ) a model A ∈ M ( P 0 ) A ∈ M ( P n ) iff . . . iff selected predicates M ( P 0 ) � ϕ iff . . . iff M ( P n ) � ϕ a class of formulas → ∗ ≡ deduction �− Depending on the choice of the set of rules and the transformation strategy 23 / 99

  24. Introduction Applications Theorem Proving [Kott,P ,P ,Roychoudhury,Seki] → ∗ S ∪ { p ←} T ∪ { p ← ϕ } �− Program Verification [Albert,Gallagher,Puebla] → ∗ Q ∪ { p ←} ] ∪ { p ← ϕ } �− [ [ P ] where [ [ P ] ] is an encoding of the program semantics (e.g., an interpreter) Program Synthesis [Darlington,Deville,Flener,Hogger,Lau,Manna,Waldinger] → ∗ P T ∪ { p ( x ) ← ϕ ( x ) } �− s.t. T | = ϕ ( a ) iff p ( a ) ∈ M ( P ) 24 / 99

  25. Improving Infinite-state and Software Model Checking Improving Infinite-state Systems Model Checking 25 / 99

  26. Improving Infinite-state and Software Model Checking Specialization-based Model Checking Program Specialization P : I 1 × I 2 − → O By partial evaluation P 1 : I 2 − → O A faster residual program Take advantage of static knowledge Specialization-based Symbolic Model Checking CTL : TS × ϕ × Parameters − → yes/no By partial evaluation MC ϕ − → yes/no TS : Parameters An ad-hoc model checker 26 / 99

  27. Improving Infinite-state and Software Model Checking Specialization-based Model Checking Program Specialization P : I 1 × I 2 − → O By partial evaluation P 1 : I 2 − → O A faster residual program Take advantage of static knowledge Specialization-based Symbolic Model Checking CTL : TS × ϕ × Parameters − → yes/no By partial evaluation MC ϕ − → yes/no TS : Parameters An ad-hoc model checker 27 / 99

  28. Improving Infinite-state and Software Model Checking Specialization Strategy Input : P and a clause δ 0 : p sp ( x ) ← c ( x ) ∧ p ( x ) p sp ( z ) ∈ M ( P ∪ { δ 0 } ) iff p sp ( z ) ∈ M ( SpecP ) Output : SpecP s.t. SpecP := ∅ ; Defs := { δ 0 } ; while ∃ δ ∈ Defs do Γ := Unfold δ ∆ := Simplify Γ (Φ , NewDefs ) := Generalize & Fold ∆ := ( Defs − { δ } ) ∪ NewDefs Defs := SpecP ∪ Φ SpecP od Test 28 / 99

  29. Improving Infinite-state and Software Model Checking Specialization Strategy Input : P and a clause δ 0 : p sp ( x ) ← c ( x ) ∧ p ( x ) p sp ( z ) ∈ M ( P ∪ { δ 0 } ) iff p sp ( z ) ∈ M ( SpecP ) Output : SpecP s.t. SpecP := ∅ ; Defs := { δ 0 } ; while ∃ δ ∈ Defs do Γ := Unfold δ ∆ := Simplify Γ (Φ , NewDefs ) := Generalize & Fold ∆ := ( Defs − { δ } ) ∪ NewDefs Defs := SpecP ∪ Φ SpecP od Test 29 / 99

  30. Improving Infinite-state and Software Model Checking Specialization Strategy Input : P and a clause δ 0 : p sp ( x ) ← c ( x ) ∧ p ( x ) p sp ( z ) ∈ M ( P ∪ { δ 0 } ) iff p sp ( z ) ∈ M ( SpecP ) Output : SpecP s.t. SpecP := ∅ ; Defs := { δ 0 } ; while ∃ δ ∈ Defs do Γ := Unfold δ (Propagate Context) ∆ := Simplify Γ (Φ , NewDefs ) := Generalize & Fold ∆ (Apply Induction) := ( Defs − { δ } ) ∪ NewDefs Defs := SpecP ∪ Φ SpecP od Test 30 / 99

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