CSE 291 - Program Synthesis

Paper Notes

Lecture 1 - Intro

Intro to Program Synthesis

Overall program synthesis comes from a high-level specification, and turns it into a program - synthesis is different from compilation because there is a search space to find the right program.

Course structure

Lecture 2

Synthesis from Examples

Syntax-Guided Synthesis

L ::= sort(L) |
      L[N..N] |
      L + L   |
      [N]     |
      x
N ::= find(L, N) |
      0

CFG

E ::= x | E @ E

For a given syntax tree of depth \(N\), the number of programs that can be generated for a given depth is \(N(d-1)^2 + 1\)

Size explodes as complexity of program increases. For more complex grammars it is even larger

Given a grammar: \((\lt T, N, R, S\gt, [i \rightarrow o])\)

bank := [t | A ::= t in R]
while (true)
 for all (p in bank)
    if (p([i]) = [o])
        return p
  bank += grow(bank)

grow(bank) {
    bank' := []
    forall (A ::= rhs in R)
        bank' += [rhs[B -> p] | p in bank, B -> *p]
    return bank
}

Lecture 3

Enumerative Search – Cont’d

def topDown(<T, N, R, S>, [i --> o]) {
    wl := [S]
    while (wl != []) {
        p := wl.dequeue();
        if (ground(p) && p([i]) = [o]) {
            return p;
        }
        wl.enqueue(unroll(p));
    }
}

def unroll(p) {
    wl' := []
    A := left-most non-terminal in p
    forall (A ::= rhs in R) {
        wl' += p[A --> rhs]
    }
    return wl'
}

Search Space Pruning

Lecture 4

eusolver discussion:

Lecture 5

Lecture 6

Lecture 7

Lecture 8

example:

N ::= id(V) | N + T | N * T
T ::= 2 | 3
V ::= x

spec:
1 -> 9

Lecture 9

Lecture 10

Lecture 11

Lecture 12

Lecture 13

Lecture 14

Lecture 15

The imp language:

e ::= n | x |
      e + e | e - e | e * e |
      e = e | e < e | e > e | !e | e && e
+ assignment/if/then/while logic

Hoare triples

Lecture 16

Precondition: {x -> A * y -> B} Postcondition: {x -> B * y -> A}

Lecture 17

Lecture 18

Lecture 19

-

CSE 291 - Program Synthesis - zac blanco