SLIDE 1 Automatic Programming: How Far Can Machines Go?
Hila Peleg Technion
SLIDE 2
SLIDE 3
Laziness
SLIDE 4
Laziness Impatience
SLIDE 5
Laziness Impatience Hubris
SLIDE 6 Automatic Programming
Clean up my spreadsheet! Right away, boss!
SLIDE 7
Program synthesis to the rescue
SLIDE 8
Program Synthesis
⇒ ⇒
SLIDE 9 What we really want
⇒ ⇒
This is what I want
SLIDE 10 What if we have automatic programming?
- Hyper-intelligent program generation for your every need
SLIDE 11 What if we have automatic programming?
- Hyper-intelligent program generation for your every need
- Self-aware, self-augmenting AI
SLIDE 12 What if we have automatic programming?
- Hyper-intelligent program generation for your every need
- Self-aware, self-augmenting AI
- The singularity
SLIDE 13 What if we have automatic programming?
- Hyper-intelligent program generation for your every need
- Self-aware, self-augmenting AI
- The singularity
- ???
SLIDE 14 What if we have automatic programming?
- Hyper-intelligent program generation for your every need
- Self-aware, self-augmenting AI
- The singularity
- ???
- THE ROBOT APOCALYPSE
SLIDE 15
The Robot Apocalypse
SLIDE 16
But it’s ok!
SLIDE 17
But it’s ok!
Understand users Build a program
SLIDE 18
But it’s ok!
Generalizing partial intent is hard Understand users Build a program
SLIDE 19
But it’s ok!
Generalizing partial intent is hard Solving HALT is hard* Understand users Build a program
SLIDE 20
SLIDE 21 User intent is hard
Clean up my spreadsheet! Right away, boss!
SLIDE 22 User intent is hard
Clean up my spreadsheet! Right away, boss! What’s “clean”? Is this right? What am I doing with my life?
SLIDE 23
Intent via examples
SLIDE 24
Intent via examples
SLIDE 25
Intent via examples
SLIDE 26
Intent via examples
SLIDE 27 Query knowledge about (some kind of) code
I want to apply foo() to requests to my http server
SLIDE 28 Query knowledge about (some kind of) code
I want to apply foo() to requests to my http server
val routes : Route = ??? val bindingFuture = Http(). bindAndHandle(routes, "localhost", 8080)
SLIDE 29 Commit Strip said it best…
http://www.commitstrip.com/en/2016/08/25/a-very-comprehensive-and-precise-spec/
SLIDE 30 Commit Strip said it best…
http://www.commitstrip.com/en/2016/08/25/a-very-comprehensive-and-precise-spec/
SLIDE 31 Commit Strip said it best…
http://www.commitstrip.com/en/2016/08/25/a-very-comprehensive-and-precise-spec/
SLIDE 32 Commit Strip said it best…
http://www.commitstrip.com/en/2016/08/25/a-very-comprehensive-and-precise-spec/
SLIDE 33 Building a program is also hard*
Get me a program that takes a program and an input and tells me if that program stops on that input.
SLIDE 34 Building a program is also hard*
Get me a program that takes a program and an input and tells me if that program stops on that input. (i.e., the halting problem)
SLIDE 35 Adjusting our expectations
Here’s a grammar of 20 functions and 10 constants, get me a program that I’m certain is in this space.
SLIDE 36 Adjusting our expectations
Here’s a grammar of 20 functions and 10 constants, get me a program that I’m certain is in this space.
SLIDE 37 Adjusting our expectations
Here’s a grammar of 20 functions and 10 constants, get me a program that I’m certain is in this space.
SLIDE 38
What does this all mean?
SLIDE 39 What does this all mean?
- Generally, “find me a program that—” cannot be solved
SLIDE 40 What does this all mean?
- Generally, “find me a program that—” cannot be solved
- Still, we’re not giving up
SLIDE 41 What does this all mean?
- Generally, “find me a program that—” cannot be solved
- Still, we’re not giving up
- Realistic expectations for realistic program synthesis
SLIDE 42 Realistic expectations for realistic synthesis
We still want
- Partial specifications
- To not have to know
everything
But we’ll have to live without
program
- Fully automatic solution
- Single-step solution
SLIDE 43 Realistic expectations for realistic synthesis
We still want
- Partial specifications
- To not have to know
everything
But we’ll have to live without
program
- Fully automatic solution
- Single-step solution
Synthesis Engine Interaction Model
SLIDE 44 The synthesis engine
- Predicts code for intent
- Draws its understanding
from language syntax
- and/or crowd wisdom
- and/or semantic
specifications
programs seen
SLIDE 45 Reducing equivalent programs
- We’ve seen x+y, so we don’t
want y+x
SLIDE 46 Reducing equivalent programs
- We’ve seen x+y, so we don’t
want y+x
- But how do we know they’re the
same?
SLIDE 47 Reducing equivalent programs
- We’ve seen x+y, so we don’t
want y+x
- But how do we know they’re the
same?
SLIDE 48 Reducing equivalent programs
- We’ve seen x+y, so we don’t
want y+x
- But how do we know they’re the
same?
- 1. Heuristics
- 2. Solvers (e.g., Z3)
SLIDE 49 Reducing equivalent programs
- We’ve seen x+y, so we don’t
want y+x
- But how do we know they’re the
same?
- 1. Heuristics
- 2. Solvers (e.g., Z3)
- 3. Observational Equivalence
SLIDE 50 Reducing equivalent programs
- We’ve seen x+y, so we don’t
want y+x
- But how do we know they’re the
same?
- 1. Heuristics
- 2. Solvers (e.g., Z3)
- 3. Observational Equivalence
Equivalence: 𝑞1 ≡ 𝑞2 i.f.f. for every possible input 𝑗 ever, 𝑞1 𝑗 = 𝑞2 (𝑗)
SLIDE 51 Reducing equivalent programs
- We’ve seen x+y, so we don’t
want y+x
- But how do we know they’re the
same?
- 1. Heuristics
- 2. Solvers (e.g., Z3)
- 3. Observational Equivalence
Observational equivalence: 𝑞1 ≡𝑃𝐹 𝑞2 i.f.f. for every input 𝑗 the user cares about, 𝑞1 𝑗 = 𝑞2 (𝑗) Equivalence: 𝑞1 ≡ 𝑞2 i.f.f. for every possible input 𝑗 ever, 𝑞1 𝑗 = 𝑞2 (𝑗)
SLIDE 52 Trying a different strategy altogether
- Use knowledge bases instead of
the language grammar
- They no longer contain every
program (neither limited grammars)
- Searchable via graph algorithms
- r probability equations
SLIDE 53 The Interaction Model
- Aimed at programmers
- Specify intent
- Express yourself
- Think like a programmer
SLIDE 54 Specifying (and re-specifying) intent
Task: find the median of a list User: examples!
- 1. [1,2,3]→2
- 2. [7,8,7,3]→7
Synthesis engine:
input[input.length/2]
User:
SLIDE 55 Specifying (and re-specifying) intent
Task: find the median of a list User: examples!
- 1. [1,2,3]→2
- 2. [7,8,7,3]→7
Synthesis engine:
input[input.length/2]
User:
It managed to find a single formula, let’s make a counterexample
SLIDE 56 Specifying (and re-specifying) intent
Task: find the median of a list User: examples!
- 1. [1,2,3]→2
- 2. [7,8,7,3]→7
Synthesis engine:
input[input.length/2]
User:
It managed to find a single formula, let’s make a counterexample
Principle #1: Cost of communicating intent + consuming result << cost of manually performing the task
SLIDE 57 Programming Not Only by Example
input[input.length/2] [] input / . 2 input length
the level of the program
- Read debug info
- Reason about subtrees or
sequences of methods
- Even rewrite the program
- But also give examples, if
those happen to be easier
SLIDE 58 Programming Not Only by Example
input[input.length/2] [] input / . 2 input length
the level of the program
- Read debug info
- Reason about subtrees or
sequences of methods
- Even rewrite the program
- But also give examples, if
those happen to be easier
Retain Exclude
SLIDE 59 Programming Not Only by Example
input[input.length/2] [] input / . 2 input length
the level of the program
- Read debug info
- Reason about subtrees or
sequences of methods
- Even rewrite the program
- But also give examples, if
those happen to be easier Principle #2: Let developers be developers
Retain Exclude
SLIDE 60
When models “out-think” the programmer
def counts(l : List[String]) : Map[String,Int]= l.
SLIDE 61
When models “out-think” the programmer
def counts(l : List[String]) : Map[String,Int]= l. groupBy( map( fold(
SLIDE 62
When models “out-think” the programmer
def counts(l : List[String]) : Map[String,Int]= l.groupBy( identity) x => x.length) x => x[0])
SLIDE 63
When models “out-think” the programmer
def counts(l : List[String]) : Map[String,Int]= l.groupBy(identity) . map(x => x._1 -> x._2 x => x.length) x => x[0])
SLIDE 64
When models “out-think” the programmer
def counts(l : List[String]) : Map[String,Int]= l.groupBy(identity) . map(x => x._1 -> x._2. filter(y => y.startsWith( x._2.length x._2[0])
SLIDE 65
When models “out-think” the programmer
def counts(l : List[String]) : Map[String,Int]= l.groupBy(identity) . map(x => x._1 -> x._2. filter(y => y.startsWith(
SLIDE 66
When models “out-think” the programmer
def counts(l : List[String]) : Map[String,Int]= l.groupBy(identity) . map(x => x._1 -> x._2. filter(y => y.startsWith(
SLIDE 67 Keep understanding what’s going on
??
SLIDE 68 Keep understanding what’s going on
??
SLIDE 69 Keep understanding what’s going on
??
Principle #3: Results must be explainable
SLIDE 70 Programmers aren’t as good as they think
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
histogram
most frequent word
% correct answer
PBE Only new operations All operations
SLIDE 71
Read-Eval-Synth Loops
SLIDE 72 What if we have automatic programming?
- Hyper-intelligent program generation for your every need
- Self-aware, self-augmenting AI
- The singularity
- ???
- THE ROBOT APOCALYPSE