software synthesis n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Software Synthesis PowerPoint Presentation
Download Presentation
Software Synthesis

Loading in 2 Seconds...

play fullscreen
1 / 20

Software Synthesis - PowerPoint PPT Presentation


  • 59 Views
  • Uploaded on

Software Synthesis. Ruzica Piskac Max Planck Institute for Software Systems, Germany. What is a Program?. Program = a sequence of commands describing what needs to be done. val bigSet = .... val ( setA , setB ) = choose ((a: Set, b: Set) ) =>

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Software Synthesis' - hans


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
software synthesis

Software Synthesis

RuzicaPiskac

Max Planck Institute for Software Systems, Germany

what is a program
What is a Program?
  • Program = a sequence of commands describing what needs to be done

valbigSet = ....

val (setA, setB) = choose((a: Set, b: Set) ) =>

( a.size == b.size && a union b == bigSet && a intersect b == empty))

Code

val n = bigSet.size/2

valsetA = take(n, bigSet)

valsetB = bigSet −− setA

what is a program1
What is a Program?
  • Program = a sequence of commands describing what needs to be done

val bigSet = ....

val (setA, setB) = choose((a: Set, b: Set) ) =>

( a.size == b.size && a union b == bigSet && a intersect b == empty))

Code

assert (bigSet.sizeis an even number)

val n = bigSet.size/2

valsetA = take(n, bigSet)

valsetB = bigSet −− setA

sorting algorith m
Sorting algorithm
  • Why should we sort data?
  • Practical exercise:
    • Form a line, where you are sorted by your first name, from Aaron to Zoe
arrays
Arrays
  • Data structure:
  • A[0] = 23, A[1]=4, A[2]=6, A[3]=15, A[4]=5, A[5]=7
specification
Specification
  • Array a2 is a sorted version of array a1
  • Define the counting function

and

automated reasoning
Automated Reasoning
  • decision procedure answers whether the input formula is satisfiable or not
    • formula is satisfiable for x=0, y=1
    • formula is unsatisfiable

satisfiable(model)

theorem prover

based on DECISION PROCEDURES

formula in some logic

unsatisfiable (proof)

synthesis for linear integer arithmetic
Synthesis for Linear Integer Arithmetic

choose((h: Int, m: Int, s: Int) ⇒ (

h * 3600 + m * 60 + s == totalSeconds

&& h ≥ 0

&& m ≥ 0 && m < 60

&& s ≥ 0 && s < 60 ))

Returned code:

assert (totalSeconds ≥ 0)

val h = totalSecondsdiv 3600

valtemp = totalSeconds + (-3600) * h

valm = min(temp div60, 59)

vals = totalSeconds + (-3600) * h + (-60) * m

linear integer arithmetic equalities
Linear Integer Arithmetic - Equalities

h * 3600 + m * 60 + s == totalSeconds

Code:

<further code will come here>

valh = lambda

valm = mu

valvals = totalSeconds + (-3600) * lambda + (-60) * mu

linear integer arithmetic equalities1
Linear Integer Arithmetic - Equalities

h * 3600 + m * 60 + s == totalSeconds

Resulting formula (new specifications):

0 ≤ λ, 0 ≤ μ, μ ≤ 59, 0 ≤ totalSeconds – 3600λ - 60μ,

totalSeconds – 3600λ - 60μ ≤ 59

10

linear integer arithmetic inequalities
Linear Integer Arithmetic - Inequalities

0 ≤ λ, 0 ≤ μ, μ ≤ 59, 0 ≤ totalSeconds – 3600λ - 60μ,

totalSeconds – 3600λ - 60μ ≤ 59

expressing constraints as bounds on μ

0 ≤ λ, 0 ≤ μ, μ ≤ 59, μ ≤ ⌊(totalSeconds – 3600λ)/60⌋ ,

⌈(totalSeconds – 3600λ – 59)/60⌉ ≤ μ

Code:

valmu = min(59, (totalSeconds -3600* lambda) div 60)

linear integer arithmetic inequalities1
Linear Integer Arithmetic - Inequalities

0 ≤ λ, 0 ≤ μ, μ ≤ 59, μ ≤ ⌊(totalSeconds – 3600λ)/60⌋ ,

⌈(totalSeconds – 3600λ – 59)/60⌉ ≤ μ

combine each lower and upper bound

0 ≤ λ, 0 ≤ 59, 0 ≤ ⌊(totalSeconds – 3600λ)/60⌋ ,

⌈(totalSeconds – 3600λ – 59)/60⌉ ≤ ⌊(totalSeconds – 3600λ)/60⌋ ,

⌈(totalSeconds – 3600λ – 59)/60⌉ ≤ 59

basic simplifications

Code:

vallambda = totalSecondsdiv 3600

Preconditions: 0 ≤ totalSeconds

0 ≤ λ, 60λ ≤ ⌊totalSeconds/60⌋,

⌈(totalSeconds –59)/60⌉ – 59 ≤ 60λ

synthesis for sets
Synthesis for Sets
  • Observation:
    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size && a union b == bigSet && a intersect b == empty

a

b

bigSet

synthesis for sets1
Synthesis for Sets
  • Observation:
    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size && a union b == bigSet && a intersect b == empty

a

b

bigSet

synthesis for sets2
Synthesis for Sets
  • Observation:
    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size && a union b == bigSet && a intersect b == empty

a

b

bigSet

synthesis for sets3
Synthesis for Sets
  • Observation:
    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size&& a union b == bigSet && a intersect b == empty

New specification:

kA = kB

a

b

bigSet

synthesis for sets4
Synthesis for Sets
  • Observation:
    • Reasoning about collections reduces to reasoning about linear integer arithmetic!

a.size == b.size && a union b == bigSet && a intersect b == empty

New specification:

kA = kB && kA +kB = |bigSet|

a

b

bigSet

synthesis applications
Synthesis: Applications
  • Automatic code completion
  • Flash Fill feature in the new Microsoft Excell (video!)
    • Available at: http://research.microsoft.com/en-us/um/people/sumitg/flashfillextensions.wmv
insynth
InSynth
  • InSynth – a tool for synthesis of code fragments (snippets)
    • interactive
      • getting results in a short amount of time
      • multiple solutions – a user needs to select
    • component based
      • assemble program from given components (local values, API)
    • partial specification
      • hard constraints – type constraints
      • soft constraints - use of components “most likely” to be useful