Recursive Program Synthesis
Aws Albarghouthi (UToronto), Sumit Gulwani (MSR), and Zachary Kincaid (UToronto)
CAV 2013Saint Petersburg, Russia
Program Synthesis
2
MagicSpecification Program
Program Synthesis
2
MagicSpecification Program
What are your Dreams?
3
MagicSpecification Program
What are your Dreams?
3
MagicSpecification ProgramFirst-order Logic
What are your Dreams?
3
MagicSpecification ProgramFirst-order Logic
Temporal Logic
What are your Dreams?
3
Magic ProgramFirst-order Logic
Temporal LogicI/O Examples
Why Synthesis from I/O?
I/O examples are easy to specify
4
Why Synthesis from I/O?
I/O examples are easy to specify
Non-expert users can specify I/O behaviour
• See, e.g., FlashFill for Excel, Smartphone scripts, etc.
• Desired programs are usually simple
4
Contribution
5
EscherI/O Examples RecursiveProgram
Contribution
5
EscherI/O Examples RecursiveProgram
User
Contribution
5
EscherI/O Examples RecursiveProgram
Parameterized by a set of building blocks (operations)integers, lists, trees, etc.
User
Contribution
5
EscherI/O Examples RecursiveProgram
Parameterized by a set of building blocks (operations)
Novel search-based synthesis techniqueintegers, lists, trees, etc.
User
Contribution
5
EscherI/O Examples RecursiveProgram
Parameterized by a set of building blocks (operations)
Novel search-based synthesis techniqueintegers, lists, trees, etc.
User
No templates required
High Level View
6
Forward Search
High Level View
6
Forward Search
I1 In. . .
High Level View
6
Forward Search
I1 In. . .
O1. . .On
High Level View
6
Forward Search
I1 In. . .
O1. . .On
P1 Pn. . .
High Level View
6
Forward Search Conditional Inference
I1 In. . .
O1. . .On
P1 Pn. . .
I1
O1
+
I2
O2
P1 P2
High Level View
6
Forward Search Conditional Inference
I1 In. . .
O1. . .On
P1 Pn. . .
I1
O1
+
I2
O2
P1 P2 =
if ( )
else
CP1
P2
High Level View
6
Forward Search Conditional Inference
I1 In. . .
O1. . .On
P1 Pn. . .
I1
O1
+
I2
O2
P1 P2 =
if ( )
else
CP1
P2
High Level View
6
Forward Search Conditional Inference
I1 In. . .
O1. . .On
P1 Pn. . .
I1
O1
+
I2
O2
P1 P2 =
if ( )
else
CP1
P2
Recursive call synthesisReuse I/O as recursive call specification or query user
Example
Synthesize list length from examples:
7
Example
Synthesize list length from examples:
7
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Inputs:
Example
Synthesize list length from examples:
7
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Inputs:
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Outputs:
Ex: Forward Search
8
Components: inc, isEmpty, tail, zero
Ex: Forward Search
8
Components: inc, isEmpty, tail, zero
Programs of size 1:
Ex: Forward Search
8
Components: inc, isEmpty, tail, zero
Programs of size 1:
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Ex: Forward Search
8
Components: inc, isEmpty, tail, zero
Programs of size 1:
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Ex: Forward Search
8
Components: inc, isEmpty, tail, zero
Programs of size 1:
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
matches output for first inputRecall outputs
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Ex: Conditional Inference
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Outputs:
Ex: Conditional Inference
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Outputs:
Ex: Conditional Inference
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Goal Graph (GG):
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Outputs:
Ex: Conditional Inference
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Goal Graph (GG):
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Outputs:
Ex: Conditional Inference
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
AND node
Goal Graph (GG):
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Outputs:
Ex: Conditional Inference
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
AND node
Goal Graph (GG):
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Outputs:
“Backward” search
Ex: Forward Search 2
10
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Programs of size 1:
Ex: Forward Search 2
10
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Programs of size 1:
Programs of size 2:
Ex: Forward Search 2
10
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Programs of size 1:
Programs of size 2:
Ex: Forward Search 2
10
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Programs of size 1:
Programs of size 2:
Ex: Forward Search 2
10
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Programs of size 1:
Programs of size 2:
Ex: Forward Search 2
10
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Programs of size 1:
Programs of size 2:
Ex: Forward Search 2
10
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Programs of size 1:
Programs of size 2:
Satisfies one of our goals
Ex: Conditional Inference 2
11
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Ex: Conditional Inference 2
11
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Ex: Conditional Inference 2
11
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
if ( )
else
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Ex: Forward Search 3
12
Programs of size 2
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Ex: Forward Search 3
12
Programs of size 2
Programs of size 3
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Ex: Forward Search 3
12
Programs of size 2
Programs of size 3
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Use I/O values to simulate recursive call
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Ex: Forward Search 3
12
Programs of size 2
Programs of size 3
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Use I/O values to simulate recursive call
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Ex: Forward Search 3
12
Programs of size 2
Programs of size 3
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Use I/O values to simulate recursive call
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Ex: Forward Search 3
12
Programs of size 2
Programs of size 3
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Use I/O values to simulate recursive call
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Ex: Forward Search 3
12
Programs of size 2
Programs of size 3
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Use I/O values to simulate recursive call
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Only allow calls satisfying well-founded relation
Ex: Forward Search 3
12
Programs of size 2
Programs of size 3
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Use I/O values to simulate recursive call
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
...
Only allow calls satisfying well-founded relation
But what if there isn’t such an I/O pair?
Query the user for new examples!
(too long for 15 min talk)
Ex: Conditional Inference
13
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
One iteration later:
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Ex: Conditional Inference
13
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
One iteration later:
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Ex: Conditional Inference
13
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
One iteration later:
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Recursive Program Synthesis 937
h Program Pi
1P1 = i ! "[],[2],[1,2]#P2 = zero ! "0,0,0#
2P3 = tail(P1) ! "err,[],[2]#P4 = inc(P2) ! "1,1,1#P5 = isEmpty(P1) ! "T,F,F#
3P6 = length(P3) ! "err,0,1#P7 = tail(P3) ! "err,err,[]#
4 P8 = inc(P7) ! "err,1,2#
Fig. 1. Synthesized programs Pi organized by heuristic value h
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5 P8
Pr
!0,1,2"
!T,F,F" !?,1,2"!0,?,?"cond then else
goal
P2P5
if isEmpty(i)then 0else inc(length(tail(i)))
(a) (b) (c)
P5
P8P2
Fig. 2. Goal graph after (a) first, (b) second and third, and (c) final alternations
employed by Escher that specifies how to reach the goal !0,1,2" by synthe-sizing a program Pr. Specifically, we need a program Pcond that returns !T,F,F"for inputs ![],[2],[1,2]", and a program Pelse that returns !?,1,2" for inputs![],[2],[1,2]", where ‘?’ denotes a “don’t care” value, since the first input []will not enter the else branch. Note that the then branch is already solvableusing P2, and is therefore annotated with it.
Second Alternation. The forward search now synthesizes programs by apply-ing components to programs found for the heuristic value 1. Note that Eschercan apply length (the recursive call) on the input values (program P1), butthis obviously results in a non-terminating program (namely, the program letlength(i) = length(i)). Escher employs a termination argument that de-tects and discards non-terminating programs. Next, by applying tail to P1, weget the program P3 that computes !err,[],[2]", where err is a special symbolrepresenting an error value, since tail is undefined on the empty list. Program P4results from applying inc to P2 and generates the value vector !1,1,1". ProgramP5 is generated by applying isEmpty to P1, resulting in the value vector !T,F,F".Now, the conditional inference phase discovers that P5 solves the !T,F,F" subgoalin the goal graph, and annotates it with P5 (see Figure 2(b)).
In the third alternation, new programs are generated, but none of our goalsare solved.
Synthesized program:
Escher: RecapForward Search
• Apply component to all synthesized programs
• Heuristic-based search
14
Escher: RecapForward Search
• Apply component to all synthesized programs
• Heuristic-based search
Conditional Inference• Uses goal graph to synthesize conditionals
• Conditionals synthesized on demand
14
Escher: RecapForward Search
• Apply component to all synthesized programs
• Heuristic-based search
Conditional Inference• Uses goal graph to synthesize conditionals
• Conditionals synthesized on demand
Recursive call synthesis• Use I/O specification
• Query user for more output values if needed14
Implementation
Prototype implementation of Escher
• Pluggable components
Experimented with:
• integer, list, and tree manipulating programs
15
Experiments
16
Escher w/o ObsEquiv
w/o GoalGraph
w/o OE+GG
collect_leaves 0.04 0.09 68.9 81.8
count_leaves 0.06 0.2 9.3 12.3
hbal_tree 1.5 MEM TIME MEM
nodes_at_level 10.74 MEM TIME MEM
(tree manipulating programs)
Time in seconds
Experiments
17
(#components sensitivity: mult)
Escher: 0.7swith all components
Experiments
17
(#components sensitivity: mult)
0
10
20
30
40
0 1 2 3 4 5
Sketch sensitivtySAT-based synthesis [ASPLOS’06]
NUMBER OF EXTRA COMPONENTS
TIM
E (S
)
Escher: 0.7swith all components
Experiments
17
(#components sensitivity: mult)
0
10
20
30
40
0 1 2 3 4 5
Sketch sensitivtySAT-based synthesis [ASPLOS’06]
NUMBER OF EXTRA COMPONENTS
TIM
E (S
)
Had to supply Sketch with high-level conditional
Escher: 0.7swith all components
Conclusion
18
EscherI/O Examples RecursiveProgram
User
Conclusion
18
EscherI/O Examples RecursiveProgram
User
Interactive
Conclusion
18
EscherI/O Examples RecursiveProgram
User
InteractiveHighly-customizable
Conclusion
18
EscherI/O Examples RecursiveProgram
User
InteractiveHighly-customizable
Novel synthesis techniques
Questions?
How can we synthesize loops?
19
Questions?
How can we synthesize loops?
Integration with SMT-based search
19
Questions?
How can we synthesize loops?
Integration with SMT-based search
Applications of Escher in eduction
• e.g., for interacting with students
19
Questions?
How can we synthesize loops?
Integration with SMT-based search
Applications of Escher in eduction
• e.g., for interacting with students
Theoretical under-pinnings
• e.g., see Madhusudan [CSL’11]
19
Thank You