![Page 1: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/1.jpg)
A Practical Overview of Deductive Program Synthesis
Alexander D. Weinert
RWTH Aachen University
Spring School on Program SynthesisPapenburg 2012
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 1 / 40
![Page 2: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/2.jpg)
Another Point of View
Traditional Programming
Specify how to do something
Program Synthesis
Specify what to do
Our task
Define methods for
Specification
Transformation of specification to program
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 2 / 40
![Page 3: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/3.jpg)
Specification
Prerequisite
Only consider side-effect-free programs◮ No GUI, no persistence, . . .
Criteria
User-oriented Tool-oriented
Easy to write
Oriented on well-knownlanguages
Unambiguous
⇒ Logic
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 3 / 40
![Page 4: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/4.jpg)
Specifications in Logic
Natural formulation
Find a program prog(x) with output y, such that post(x,y) holds.I assure that pre(x) holds.
Mathematical notation
prog(x) ⇐ Find y, such that post(x,y),where pre(x)
Background theories
Integers, Strings, Sets, . . .
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 4 / 40
![Page 5: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/5.jpg)
Expressions in logic
Basic propositions: true, false, a|b, char(x), a ∈ X , . . .
Basic functions: gcd(x,y), head(a), union(X,Y), . . .
Equality: x=y, last(a)=head(b), union(X,Y)=union(A,B), . . .
Boolean connectives: ¬ϕ1, ϕ1 ∧ ϕ2, ϕ1 ∨ ϕ2, ϕ1 →↑ϕ2
“if, then”
Quantifiers: ∃↑y .ϕ(y)
“there exists”
, ∀↑y .ϕ(y)
“for all”
,
Valid formula
pre(X) := ∀n.Int(n)→ n ∈ X
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 5 / 40
![Page 6: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/6.jpg)
Specification of a square root program
Square root
sqrt(x,ǫ) ⇐ Find y, such thaty2 ≤ x ∧ x < (y + ǫ)2,where ǫ > 0
post(x,ǫ,y) := y2 ≤ x ∧ x < (y + ǫ)2
pre(x,ǫ) := ǫ > 0
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 6 / 40
![Page 7: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/7.jpg)
Front and last element of lists
Front and last element
〈front(s), last(s)〉 ⇐ Find 〈y , z〉, such thatchar(z) ∧ s = y · z ,where ¬(s = ǫ)
post(s,y,z) := (char(z) ∧ s = y · z)pre(s) := s 6= ǫ
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 7 / 40
![Page 8: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/8.jpg)
The method
General idea
We want to show: There exists a program fulfilling the specification
Proof has to be “sufficiently constructive”
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 8 / 40
![Page 9: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/9.jpg)
Reminder
prog(x) ⇐ Find y, such that post(x,y),where pre(x)
To Show
If pre(x) holds, then post(x,y) holds for some y.
Tableau notation
Assertions Goals Outputs
pre(x)
post(x,y) y
Output some y that fulfills the postcondition
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 9 / 40
![Page 10: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/10.jpg)
General tableaux
Assertions Goals Outputs
Ac,1(x) tc,1(x)
Ac,2(x) tc,2(x)...
...
Ac,m(x) tc,m(x)
Gc,1(x) tc,m+1(x)
Gc,2(x) tc,m+2(x)...
...
Gc,n(x) tc,m+n(x)
Associated Sentence
If for all x :then there exists some x :
Ac,1(x) and Ac,2(x) and . . .Ac,m(x)Gc,1(x) or Gc,2(x) or . . .Gc,n(x)
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 10 / 40
![Page 11: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/11.jpg)
Steps of Deduction
Assertions Goals Outputs
pre(x)
post(x,y) y
⇐ Deduction Rules
Assertions Goals Outputs
true . . . ← generated program
or
Assertions Goals Outputs
false . . . ← generated program
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 11 / 40
![Page 12: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/12.jpg)
General Form
Prerequisite
Assertions Goals Outputs
Ac,1(x) tc,1(x)...
...
Ac,m(x) tc,m(x)
Gc,1(x) tc,m+1(x)...
...
Gc,n(x) tc,m+n(x)
Deduction
Assertions Goals Outputs
A′c,1(x) t ′
c,1(x)...
...
A′c,m
′(x) t ′c,m
′(x)
G ′c,1(x) t ′
c,m′+1(x)
......
G ′c,n
′(x) t ′c,m
′+n′(x)
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 12 / 40
![Page 13: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/13.jpg)
Duality
Duality
Assertions Goals Outputs
¬ϕ t
Assertions Goals Outputs
ϕ t
· · · ∧ ∀x .¬ϕ(x)
⇔ · · · ∧ ¬∃x .ϕ(x)
⇔ · · · ∨ ∃x .ϕ(x)
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 13 / 40
![Page 14: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/14.jpg)
Duality: Example
Assertions Goals Outputs
s 6= ǫ
Assertions Goals Outputs
s 6= ǫ
s = ǫ
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 14 / 40
![Page 15: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/15.jpg)
Splitting Rules
AND-Splitting
Assertions Goals Outputs
ϕ ∧ ψ t
Assertions Goals Outputs
ϕ t
ψ t
OR-Splitting
Assertions Goals Outputs
ϕ ∨ ψ t
Assertions Goals Outputs
ϕ t
ψ t
Recall:If for all x all assertions hold,
then there exists some x , such that some goals hold.
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 15 / 40
![Page 16: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/16.jpg)
Splitting Rules
IF-Splitting
Assertions Goals Outputs
If ϕ, then ψ t
Assertions Goals Outputs
¬ϕ ∨ ψ t
Assertions Goals Outputs
ϕ t
ψ t
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 16 / 40
![Page 17: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/17.jpg)
Splitting: Example
Assertions Goals Outputs
if s 6= ǫ, then s = t1 · t2
Disprove this →
Assertions Goals Outputs
if s 6= ǫ, then s = t1 · t2s 6= ǫ
s = t1 · t2
or show← this
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 17 / 40
![Page 18: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/18.jpg)
Simplification
Let ϕ ≡ ψ
Assertions Goals Outputs
ϕ t
Assertions Goals Outputs
ψ t
Example
Assertions Goals Outputs
¬(a ∧ b) a
Assertions Goals Outputs
¬a ∨ ¬b a
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 18 / 40
![Page 19: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/19.jpg)
Equality
Assertions Goals Outputs
φ(τ = σ) s
ψ(τ) t
Assertions Goals Outputs
φ(false) if(τ = σ)∨ then t
ψ(σ) else s
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 19 / 40
![Page 20: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/20.jpg)
Equality: Example
Assertions Goals Outputs
x = 5 ∧ y = 2
x · y = 10
Assertions Goals Outputs
false ∧ y = 2
5 · y = 10
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 20 / 40
![Page 21: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/21.jpg)
Resolution
GG-Resolution
Assertions Goals Outputs
ϕ(τ) s
ψ(τ) t
Assertions Goals Outputs
if τϕ(true) ∧ ψ(false) then s
else t
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 21 / 40
![Page 22: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/22.jpg)
Resolution
AA-Resolution
Assertions Goals Outputs
ϕ(τ) s
ψ(τ) t
Assertions Goals Outputs
if τϕ(true) ∨ ψ(false) then s
else t
Also: AG-Resolution, GA-Resolution
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 22 / 40
![Page 23: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/23.jpg)
Resolution: Example
Assertions Goals Outputs
Integer(x) true
¬ Integer(x) false
Assertions Goals Outputs
if Integer(x),true then true
else false
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 23 / 40
![Page 24: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/24.jpg)
Conditional Substitution
r ⇒ s if C
Example
n|0⇒ true if integer(n) ∧ n 6= 0
Assertions Goals Outputs
ϕ(r) t(r)
Assertions Goals Outputs
if C then ϕ(s) t(s)
Assertions Goals Outputs
ϕ(r) t(r)
Assertions Goals Outputs
C ∧ ϕ(s) t(s)
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 24 / 40
![Page 25: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/25.jpg)
Conditional Substitution: Example
Assertions Goals Outputs
(1 < x ∧ x < 2) ∨ (x |0) x
Example
n|0⇒ true if integer(n) ∧ n 6= 0
Assertions Goals Outputs
(1 < x ∧ x < 2) ∨ (integer(n) ∧ x 6= 0 ∧ true) x
(1 < x ∧ x < 2) ∨ (integer(n) ∧ x 6= 0) x
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 25 / 40
![Page 26: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/26.jpg)
Induction ↔ Recursion
Mathematical Induction
Start of induction
Induction Hypothesis
Induction step
Recursion
Ground case
Recursive call
Use of recursive result
Observation
Induction =̂ Recursion
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 26 / 40
![Page 27: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/27.jpg)
Recursion rule
Assumption
< is a well-founded relation
Assertions Goals f(in)
pre(in)
post(in,out) out
Assertions Goals f(in)
If z < in,then if pre(z),
then post(z,f(z))
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 27 / 40
![Page 28: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/28.jpg)
Recursion: Example
Assertions Goals last(s)
s 6= ǫ
char(t2) ∧ s = t1 · t2 t2
Assertions Goals Outputs
if s ′ < s ∧ s ′ 6= ǫ,then char(last(s’))∧s ′ = t ′1 · last(s’)
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 28 / 40
![Page 29: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/29.jpg)
Derivation of Front and Last
Basic proposition: char(x)Basic functions: Concatenation (·), head(x), tail(x)
〈front(s),last(s)〉 ⇐ Find 〈t1, t2〉, such thatchar(t2) ∧ s = t1 · t2,where ¬(s = ǫ)
No. Assertions Goals front(s) last(s)
1. ¬(s = ǫ)
2. char(t2) ∧ s = t1 · t2 t1 t2
Variables: t1, t2Constants: s
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 29 / 40
![Page 30: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/30.jpg)
No. Assertions Goals front(s) last(s)
1. ¬(s = ǫ)
2. char(t2) ∧ s = t1 · t2 t1 t2
Target
Recursive program◮ Base case: only one character◮ Recursive case: more than one character
No. Assertions Goals front(s) last(s)
3. char(t2) ∧ s = t2 ǫ t2
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 30 / 40
![Page 31: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/31.jpg)
Resolution
No. Assertions Goals front(s) last(s)
1. ¬(s = ǫ)
2. char(t2) ∧ s = t1 · t2 t1 t23. char(t2) ∧ s = t2 ǫ t2
x = x
¬(x = x)
char(t2) ∧ s = t2 ¬(x = x)
↓ t2 := s ↓ x := s
char(s) ∧ s = s ¬( s = s )
char(s) ∧ true ∧ ¬( false )
⇒ char(s)
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 31 / 40
![Page 32: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/32.jpg)
Recursion
No. Assertions Goals front(s) last(s)
1. ¬(s = ǫ)
2. char(t2) ∧ s = t1 · t2 t1 t24. char(s) ǫ s
5. char(u) ∧ char(t2)∧s = u · t1 · t2 u · t1 t2
Induction Hypothesis
If x < s , then
if ¬(x = ǫ) , then
char(last(x)) ∧ x = front(x) · last(x)
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 32 / 40
![Page 33: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/33.jpg)
Recursion (cont.)
No. Assertions Goals front(s) last(s)
5. char(u) ∧ char(t2)∧s = u · t1 · t2 u · t1 t2
Induction Hypothesis
If x < s ∧ ¬(x = ǫ), then char(last(x)) ∧ x = front(x) · last(x)
t1 := front(x), t2 := last(x)
No. Assertions Goals front(s) last(s)
5. x < s ∧ ¬(x = ǫ)char(u) ∧ char(last(x)) u·front(x) last(x)
∧s = u · x
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 33 / 40
![Page 34: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/34.jpg)
Recursion (simplification)
Induction Hypothesis
If x < s ∧ ¬(x = ǫ), then char(last(x)) ∧ x = front(x) · last(x)
No. Assertions Goals front(s) last(s)
5. x < s ∧ ¬(x = ǫ)
char(u)∧ char(last(x)) u·front(x) last(x)
∧s = u · x
No. Assertions Goals front(s) last(s)
5. x < s ∧ ¬(x = ǫ)char(u) ∧ s = u · x u·front(x) last(x)
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 34 / 40
![Page 35: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/35.jpg)
Recursion (simplification cont.)
No. Assertions Goals front(s) last(s)
5. x < s ∧ ¬(x = ǫ)char(u) ∧ s = u · x u·front(x) last(x)
Decomposition Lemma
If ¬(y = ǫ), then y = head(y) · tail(y)
y := s, u := head(y), x := tail(y)
No. Assertions Goals front(s) last(s)
5. tail(s) < s∧ head(s)· last(¬(tail(s) = ǫ)∧ front( tail(s)char(head(s))∧ tail(y) )¬(s = ǫ) )
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 35 / 40
![Page 36: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/36.jpg)
Recursion (simplification cont.)
No. Assertions Goals front(s) last(s)
5. tail(s) < s∧ head(s)· last(¬(tail(s) = ǫ)∧ front( tail(s)char(head(s))∧ tail(y)) )¬(s = ǫ)
Resolution
Domain knowledge: ¬(s = ǫ)→ char(head(s)) and¬(head(s) = ǫ)→ tail(s) < s.
Formally: Resolution
No. Assertions Goals front(s) last(s)
5. ¬(tail(s) = ǫ)∧ head(s)· last(¬(s = ǫ) front(tail(y)) tail(s))
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 36 / 40
![Page 37: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/37.jpg)
Simplification
No. Assertions Goals front(s) last(s)
5. ¬(tail(s) = ǫ) ∧ head(s)· last(
¬(s = ǫ) front(tail(y)) tail(s))
Trichotomy property
Domain Knowledge:
y = ǫ ∨ char(y) ∨ ¬(tail(y) = ǫ)
No. Assertions Goals front(s) last(s)
5. ¬(s = ǫ)∧ head(s)· last(¬(char(s)) front(tail(y)) tail(s))
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 37 / 40
![Page 38: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/38.jpg)
Final steps
No. Assertions Goals front(s) last(s)
5. ¬(s = ǫ)∧ head(s)· last(¬(char(s)) front(tail(y)) tail(s))
1. ¬(s = ǫ)
¬(char(s)) head(s)· last(front(tail(y)) tail(s))
4. char(s) ǫ s
true if char(s), if char(s)),then ǫ, else then s, elsehead(s)· last(
front(tail(y)) tail(s))
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 38 / 40
![Page 39: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/39.jpg)
Final remarks
Very good result in this case
Efficient choice of rules by humans
Not clear which axioms have to be used
Result might not always be understandable
No specification of performance
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 39 / 40
![Page 40: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/40.jpg)
Thank you for your attention
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 40 / 40
![Page 41: A Practical Overview of Deductive Program Synthesis€¦ · A Practical Overview of Deductive Program Synthesis Alexander D. Weinert RWTHAachenUniversity Spring School on Program](https://reader036.vdocuments.site/reader036/viewer/2022070912/5fb39d427ab04453ea09f818/html5/thumbnails/41.jpg)
Manna, Z. and Waldinger, R. (1980).A Deductive Approach to Program Synthesis.IEEE Transactions on Programming Languages and Systems,2(1):90–121.
Manna, Z. and Waldinger, R. (1992).Fundamentals of Deductive Program Synthesis.IEEE Transactions on Software Engineering, 18(8):674–702.
A. D. Weinert (RWTH Aachen) Deductive Program Synthesis Papenburg 2012 40 / 40