74
Recursive Program Synthesis Aws Albarghouthi (UToronto), Sumit Gulwani (MSR), and Zachary Kincaid (UToronto) CAV 2013 Saint Petersburg, Russia

Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Recursive Program Synthesis

Aws Albarghouthi (UToronto), Sumit Gulwani (MSR), and Zachary Kincaid (UToronto)

CAV 2013Saint Petersburg, Russia

Page 2: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Program Synthesis

2

MagicSpecification Program

Page 3: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Program Synthesis

2

MagicSpecification Program

Page 4: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

What are your Dreams?

3

MagicSpecification Program

Page 5: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

What are your Dreams?

3

MagicSpecification ProgramFirst-order Logic

Page 6: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

What are your Dreams?

3

MagicSpecification ProgramFirst-order Logic

Temporal Logic

Page 7: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

What are your Dreams?

3

Magic ProgramFirst-order Logic

Temporal LogicI/O Examples

Page 8: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Why Synthesis from I/O?

I/O examples are easy to specify

4

Page 9: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 10: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Contribution

5

EscherI/O Examples RecursiveProgram

Page 11: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Contribution

5

EscherI/O Examples RecursiveProgram

User

Page 12: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Contribution

5

EscherI/O Examples RecursiveProgram

Parameterized by a set of building blocks (operations)integers, lists, trees, etc.

User

Page 13: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Contribution

5

EscherI/O Examples RecursiveProgram

Parameterized by a set of building blocks (operations)

Novel search-based synthesis techniqueintegers, lists, trees, etc.

User

Page 14: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 15: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

High Level View

6

Forward Search

Page 16: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

High Level View

6

Forward Search

I1 In. . .

Page 17: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

High Level View

6

Forward Search

I1 In. . .

O1. . .On

Page 18: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

High Level View

6

Forward Search

I1 In. . .

O1. . .On

P1 Pn. . .

Page 19: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

High Level View

6

Forward Search Conditional Inference

I1 In. . .

O1. . .On

P1 Pn. . .

I1

O1

+

I2

O2

P1 P2

Page 20: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

High Level View

6

Forward Search Conditional Inference

I1 In. . .

O1. . .On

P1 Pn. . .

I1

O1

+

I2

O2

P1 P2 =

if ( )

else

CP1

P2

Page 21: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

High Level View

6

Forward Search Conditional Inference

I1 In. . .

O1. . .On

P1 Pn. . .

I1

O1

+

I2

O2

P1 P2 =

if ( )

else

CP1

P2

Page 22: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 23: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Example

Synthesize list length from examples:

7

Page 24: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 25: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 26: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Ex: Forward Search

8

Components: inc, isEmpty, tail, zero

Page 27: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Ex: Forward Search

8

Components: inc, isEmpty, tail, zero

Programs of size 1:

Page 28: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

Page 29: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

Page 30: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

Page 31: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 32: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 33: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 34: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 35: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 36: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 37: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 38: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 39: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 40: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 41: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 42: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 43: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 44: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

Page 45: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

Page 46: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

...

Page 47: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

...

Page 48: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

...

Page 49: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

...

Page 50: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

...

Page 51: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

...

Page 52: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

...

Page 53: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 54: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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)

Page 55: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

Page 56: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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.

Page 57: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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:

Page 58: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Escher: RecapForward Search

• Apply component to all synthesized programs

• Heuristic-based search

14

Page 59: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 60: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 61: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Implementation

Prototype implementation of Escher

• Pluggable components

Experimented with:

• integer, list, and tree manipulating programs

15

Page 62: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 63: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Experiments

17

(#components sensitivity: mult)

Escher: 0.7swith all components

Page 64: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 65: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 66: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Conclusion

18

EscherI/O Examples RecursiveProgram

User

Page 67: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Conclusion

18

EscherI/O Examples RecursiveProgram

User

Interactive

Page 68: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Conclusion

18

EscherI/O Examples RecursiveProgram

User

InteractiveHighly-customizable

Page 69: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Conclusion

18

EscherI/O Examples RecursiveProgram

User

InteractiveHighly-customizable

Novel synthesis techniques

Page 70: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Questions?

How can we synthesize loops?

19

Page 71: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Questions?

How can we synthesize loops?

Integration with SMT-based search

19

Page 72: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Questions?

How can we synthesize loops?

Integration with SMT-based search

Applications of Escher in eduction

• e.g., for interacting with students

19

Page 73: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

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

Page 74: Recursive Program Synthesis€¦ · can apply length (the recursive call) on the input values (program P 1), but this obviously results in a non-terminating program (namely, the program

Thank You