COMBINING PARTIAL EVALUATION AND SYMBOLIC EXECUTION
Reiner Hähnle & Richard Bubel
Chalmers University
Symposium’09
Speyer
COMBINING PARTIAL EVALUATION AND SYMBOLIC EXECUTION Reiner Hhnle - - PowerPoint PPT Presentation
COMBINING PARTIAL EVALUATION AND SYMBOLIC EXECUTION Reiner Hhnle & Richard Bubel Chalmers University Symposium09 Speyer CONTROL CIRCUIT y = 80; threshold = 100; if (y > threshold) { decrease = true; } else { decrease = false;
COMBINING PARTIAL EVALUATION AND SYMBOLIC EXECUTION
Reiner Hähnle & Richard Bubel
Chalmers University
Symposium’09
Speyer
y = 80; threshold = 100; if (y > threshold) { decrease = true; } else { decrease = false; } while (|y-threshold| > eps) { y = decrease ? y-1 : y+1; }
y = 80; threshold = 100; if (y > threshold) { decrease = true; } else { decrease = false; } while (|y-threshold| > eps) { y = decrease ? y-1 : y+1; }
decrease ?
|y-threshold| > eps ?
threshold=100 decrease = true; y=y+1; decrease = false; y=y-1; y = 80 y>threshold ?
|y-100| > eps ? |y-threshold| > eps ?
false decrease ? y>threshold ? 80>100 ? threshold=100 decrease = true; y=y+1; decrease = false; y=y-1; y = 80
evaluation
safe dereferencing etc.
false
Evaluator Evaluator y 80 threshold 100 decrease false Evaluator Evaluator y
100 decrease false
Static information propagated along CFG
decrease ?
A Bit More Realistic
|y-threshold| > eps ?
y>threshold ? threshold=100 decrease = true; y=y+1; decrease = false; y=y-1; y = 80 decrease ?
|y-100| > eps ?
y>100 ? threshold=100 decrease = true; y=y+1; decrease = false; y=y-1;
decrease ?
|y-threshold| > eps ?
y>threshold ? threshold=100 decrease = true; y=y+1; decrease = false; y=y-1;
decrease ?
|y-threshold| > eps ?y>threshold ? threshold=100 decrease = true; y=y+1; decrease = false; y=y-1;
threshold=100 y>threshold ? decrease = true; decrease=false;
|y-threshold| > eps ? |y-threshold| > eps ?
decrease ? decrease ? y=y-1; y=y+1; y=y-1; y=y+1;
|y-threshold| > eps ?decrease ? y=y-1; y=y+1; |y-threshold| > eps ? decrease ? y=y-1; y=y+1;
|y-threshold| > eps ?decrease ? y=y-1; y=y+1;
|y-threshold| > eps ?decrease ? y=y-1; y=y+1;
Symbolic Execution
interleave partial evaluation and symbolic execution
|y-100| > eps ? |y-100| > eps ?
|y-100| > eps ? |y-100| > eps ? |y-100| > eps ? |y-threshold| > eps ? |y-threshold| > eps ? |y-threshold| > eps ? decrease ? |y-threshold| > eps ? y>threshold ? threshold=100 decrease = true; y=y+1; decrease = false; y=y-1;|y-threshold| > eps ? |y-threshold| > eps ?
y>threshold ?
decrease ?true
decrease ?decrease ?
decrease ? decrease ?decrease ?
false false true
false
true
y>100 ?
threshold=100 decrease=true; decrease=false; y=y-1; y=y+1; y=y-1; y=y+1;
y=y-1; y=y+1; y=y-1; y=y+1; y=y-1; y=y+1; y=y-1; y=y+1;
|y-100| > eps ? |y-100| > eps ?
decrease ? |y-threshold| > eps ? y>threshold ? threshold=100 decrease = true; y=y+1; decrease = false; y=y-1;true false
false
true
threshold=100 decrease=true; decrease=false; y=y-1; y=y+1;
y=y-1; y=y+1;
y>100 ?
Simple OO-Programming Language
termination
Programming Language
Syntax
p ↓ ( U , ϕ ) denotes a program equivalent to if is executed in a state s satisfying and coinciding on ϕ U p p
Dynamic Logic with Updates:
↓: PrgEl × Upd × For → PrgEl
PrgEl = Statement ˙ ∪ Expression
where Specialisation operator (as usual) Examples:
x =(y)↓(y := 3, true)+3;
Notions Program variables and attributes are modelled as non-rigid constants and unary function symbols Signature Σ: States : s ∈ S interpretes program variables and attributes
predicate symbols
I
D First-order structure(D, I):
Signature Extension
p ↓Σ′⊇Σ (U, ϕ)
where
(D, I)Σ′ ⊇ (D, I)Σ sΣ′ ⊇ sΣ βΣ′ ⊇ βΣ and and Partial Evaluation may extend the signature (temporary variables, anonymous updates )
Soundness Condition on the Specialisation Operator
p ↓Σ′⊇Σ (U, ϕ)
p↓(U, ϕ)ψ →
=
ψ For all formulas
, :
if(b){p}else{q}↓(U, ϕ)
U(ϕ → b . = true)
@(o.a)↓(U, ϕ)
= null))
p↓(U, ϕ); q↓(U′, ϕ′)
⊢ respModStrong(p, mod)
U′ := UVmod
(D, I) | = {U}{Vmod}ϕ′ ⇒ (D, I) | = {U}pϕ
Rewrite Action Correctness Requirement Dead-Code Elimination Safe Field Access Partial Evaluator Propagation
Partial Evaluation Rules
Γ ⊢ U!(o . = null), ∆ Γ ⊢ U{o.a := t}q ↓ (o.a := t, !o . = null)φ, ∆ Γ ⊢ Uo.a = t; qφ, ∆
Partial Evaluator Introduction Rules and several others
Type Inference Rules res = o.m(a1, . . . , an)↓(ϕ, U)
⊢ U(ϕ → o! . = null & C :: instance(o)) res = @((C)o′).m(a1 ↓(ϕ, U), . . . , an ↓(ϕ, U))
Type Inference Rules
equals(Obj) equals(Obj) equals(Obj) equals(Obj) equals(Obj) equals(Obj) equals(Obj) equals(Obj) equals(Obj) equals(Obj) equals(Obj) equals(Obj)
A
A a = ...; boolean eq = a.equals(c);
C
a is an instance of C
B
Evaluator ...
Application Engineering
Model Driven Architecture
Platform Independent Model Platform Specific Model Platform Definition Model
Application Engineering
Feature Configuration Application Productline Artefacts
Partial Evaluation
Program
p ↓ ( U , ϕ )
(U, ϕ) p
(for the moment)
replaced proof search by computation
⊢ ↓
y = 80; threshold = 100; if (y > threshold) { decrease = true; } else { decrease = false; } while (y-threshold > eps) { y = decrease ? y-1 : y+1; }computation linear in number of locs
↓
partial eval. as generalisation of β-reduction in Hoare/VCG