Correctness of Program Transformations: Automating Diagram-Based Proofs
David Sabel†
Goethe-University Frankfurt am Main, Germany
†Research supported by the Deutsche Forschungsgemeinschaft (DFG) under grant SA 2908/3-1.
Correctness of Program Transformations: Automating Diagram-Based - - PowerPoint PPT Presentation
Correctness of Program Transformations: Automating Diagram-Based Proofs David Sabel Goethe-University Frankfurt am Main, Germany Research supported by the Deutsche Forschungsgemeinschaft (DFG) under grant SA 2908/3-1. Motivation reasoning
†Research supported by the Deutsche Forschungsgemeinschaft (DFG) under grant SA 2908/3-1.
2/43
for (X:=1, X < n, X++) { Z := Z + X; } X:=1 while X < n { Z := Z + X; X++; }
3/43
for (X:=1, X < n, X++) { Z := Z + X; } X:=1 while X < n { Z := Z + X; X++; }
3/43
sr,∗
sr
sr,∗
sr
4/43
successful successful program transformation standard reduction steps standard reduction steps
5/43
successful
program transformation
6/43
successful
program transformation
successful standard reduction steps
6/43
successful
program transformation
successful standard reduction steps
program transformation standard reduction
6/43
successful
program transformation
successful standard reduction steps
program transformation standard reduction
standard reduction steps program transformation steps
6/43
successful
program transformation
successful standard reduction steps
program transformation standard reduction
standard reduction steps program transformation steps
successful
6/43
successful
program transformation
successful standard reduction steps
program transformation standard reduction
standard reduction steps program transformation steps
successful
6/43
successful
program transformation
successful standard reduction steps
program transformation standard reduction
standard reduction steps program transformation steps
succ. by the induction hypothesis
successful
6/43
successful
program transformation
successful standard reduction steps
program transformation standard reduction
standard reduction steps program transformation steps
succ.
successful
successful
6/43
7/43
7/43
8/43
9/43
10/43
10/43
i=1 , xn=An, Env, in A[x1]
11/43
i=1 , xn=An, Env, in A[x1]
i=1
11/43
i=1 , xn=An, Env, in A[x1]
i=1
11/43
i=1 , xn=An, Env, in A[x1]
i=1
11/43
i=1 , xn=An, Env, in A[x1]
i=1
11/43
Ch[x, s] represents chains x=C1[var x1]; x1=C2[var x2]; . . . ; xn=Cn[s] where Ci are contexts of class cl(Ch)
12/43
13/43
13/43
13/43
13/43
14/43
14/43
15/43
16/43
program transformation standard reduction
17/43
18/43
19/43
20/43
20/43
21/43
22/43
(Sol ◦ σ, Γ · ∪{x = t . = y = D[s], env1 . = env2}, ∆σ)
∪{x = t . = y = D[var Y ], env1 . = Ch2[Y, s]; env2}, ∆σ)
∪{x = t . = Y1 = D[var Y2], env1 . = Ch1[y, var Y1]; Ch2[Y2, s]; env2}, ∆σ)
(Sol ◦ σ, Γ · ∪{x = t . = Y1 = D[s], env1 . = Ch2[y, var Y1]; env2, ∆σ})
23/43
24/43
25/43
26/43
program transformation standard reduction
27/43
28/43
T,gc
SR,lbeta
T,gc
T,gc
SR,cp
T,gc
T,gc
SR,lll
T,gc
T,gc
T,gc
T,gc
29/43
30/43
30/43
30/43
30/43
letrec x=z in letrec y=1 in letrec z=2 in 3 letrec x=z in letrec y=1; z=2 in 3 letrec x=z; y=1 in letrec z=2 in 3 letrec x=z; y=1; z=2 in 3 SR,llet T,llet SR,llet T,llet
31/43
letrec x=z in letrec y=1 in letrec z=2 in 3 letrec x=z in letrec y=1; z=2 in 3 letrec x=z; y=1 in letrec z=2 in 3 letrec x1=z; y1=1; z1=2 in 3 letrec x1=z; y1=1 in letrec z1=2 in 3 α T,llet letrec x2=z in letrec y2=1; z2=2 in 3 letrec x2=z; y2=1; z2=2 in 3
α SR,llet SR,llet T,llet
31/43
32/43
(variable meta-variable)
(concrete variable)
(expression meta-variable)
(context meta-variable)
(environment meta-variable)
(fresh renaming of variable x)
(restriction of αE,i on LetVars(E))
(restriction of αD,i on CapVars(D))
33/43
34/43
35/43
36/43
T,gc SR,lbeta
SR,lbeta
T,gc
37/43
T,gc SR,lbeta
SR,lbeta
T,gc
37/43
T,gc SR,lbeta
SR,lbeta
T,gc
∗
1), . . . , (SR, a′ m), Answer
37/43
T,gc
SR,lbeta
T,gc
T,gc
SR,cp
T,gc
T,gc
SR,lll
T,gc
T,gc
T,gc
T,gc
38/43
39/43
39/43
39/43
SR,lbeta
T,gc
SR,lbeta
T,gc
40/43
need (17 SR rules, 18 transformations, 2 answers)
41/43
42/43
43/43