Download - Tihomir Gvero, Ruzica Piskac, Viktor Kuncak
![Page 1: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/1.jpg)
Tihomir Gvero, Ruzica Piskac, Viktor Kuncak
![Page 2: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/2.jpg)
Search for method composition in large and complex libraries Substantial effort Obstructing
Auto Complete in IDE Predicting a symbol that the user wants to type No need to read source code and doc.
Code Synthesis – Synthesizes code from specification
![Page 3: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/3.jpg)
Search for method composition in large and complex libraries Substantial effort Obstructing
Auto Complete in IDE Predicting a symbol that the user wants to type No need to read source code and doc.
Code Synthesis – Synthesizes code from specification
Can we combine Auto Complete with Code Synthesis?
![Page 4: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/4.jpg)
Search for method composition in large and complex libraries Substantial effort Obstructing
Auto Complete in IDE Predicting a symbol that the user wants to type No need to read source code and doc.
Code Synthesis – Synthesizes code from specification
Can we combine Auto Complete with Code Synthesis? YES
![Page 5: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/5.jpg)
Search for method composition in large and complex libraries Substantial effort Obstructing
Auto Complete in IDE Predicting a symbol that the user wants to type No need to read source code and doc
Code Synthesis – Synthesizes code from specification
iSynth - a tool that suggests multiple meaningfulexpressions at a given program point
![Page 6: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/6.jpg)
Implemented for Scala language Input: Partial Scala program – visible declarations Program point – desired type
Output: Code snippets – expression with desired type
Runs synthesis algorithm based on resolution to find candidate snippets
Handles simple and generic (parametric) types
Type Information
![Page 7: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/7.jpg)
def fopen(name:String):File = { ... }def fread(f:File, p:Int):Data = { ... }var currentPos : Int = 0var fname : String= null...def getData():Data = ?
![Page 8: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/8.jpg)
def fopen(name:String):File = { ... }def fread(f:File, p:Int):Data = { ... }var currentPos : Int = 0var fname : String= null...def getData():Data = ?
DEMO
![Page 9: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/9.jpg)
def map[A,B](f: A=>B, l:List[A]):List[B] = { ... }def stringConcat(lst : List[String]) :String = { ... }...def printInts(intList: List[Int], fun:Int=>String):String = ?
![Page 10: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/10.jpg)
def map[A,B](f: A=>B, l:List[A]):List[B] = { ... }def stringConcat(lst : List[String]) :String = { ... }...def printInts(intList: List[Int], fun:Int=>String):String = ?
DEMO
![Page 11: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/11.jpg)
object Calendar {private val events:List[Event] = { … }
def reserve(user:User, date:Date):Event = { ... }def getEvent(user:User, date:Date):Event = { ... }def remove(user:User, date:Date):Event = ?
}
![Page 12: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/12.jpg)
object Calendar {private val events:List[Event] = { … }
def reserve(user:User, date:Date):Event = { ... }def getEvent(user:User, date:Date):Event = { ... }def remove(user:User, date:Date):Event = ?
}
DEMO
![Page 13: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/13.jpg)
Program point
Max steps
…………………………………………………………………………………………………………………………………………………………………………………………………………………………………
![Page 14: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/14.jpg)
Program point
Max steps
Find all visible symbols
…………………………………………………………………………………………………………………………………………………………………………………………………………………………………
![Page 15: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/15.jpg)
Program point
Max steps
Create clauses:- encode in FOL - assign weights
Find all visible symbols
…………………………………………………………………………………………………………………………………………………………………………………………………………………………………
![Page 16: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/16.jpg)
Program point
Max steps
Create clauses:- encode in FOL - assign weights
Find all visible symbols
Resolution algorithm with weights
…………………………………………………………………………………………………………………………………………………………………………………………………………………………………
![Page 17: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/17.jpg)
Program point
Max steps
Create clauses:- encode in FOL - assign weights
Find all visible symbols
Resolution algorithm with weights
…………………………………………………………………………………………………………………………………………………………………………………………………………………………………
Code snippets
![Page 18: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/18.jpg)
def m1():Int
![Page 19: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/19.jpg)
def m1():Int
hasType(m1, Int)
![Page 20: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/20.jpg)
def m1():Int
hasType(m1, Int)
Predicate
![Page 21: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/21.jpg)
def m1():Int
hasType(m1, Int)
def m2(a1:Int):Boolean
Predicate
![Page 22: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/22.jpg)
def m1():Int
hasType(m1, Int)
def m2(a1:Int):Boolean
hasType(m2, Arrow(Int, Boolean)))
Predicate
![Page 23: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/23.jpg)
def m1():Int
hasType(m1, Int)
def m2(a1:Int):Boolean
hasType(m2, Arrow(Int, Boolean)))
Predicate
Function Symbol
![Page 24: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/24.jpg)
def m3(a1: Int, a2:Boolean):String
![Page 25: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/25.jpg)
def m3(a1: Int, a2:Boolean):String
hasType(m3, Arrow(Int, Arrow(Boolean, String)))
![Page 26: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/26.jpg)
def m3(a1: Int, a2:Boolean):String
hasType(m3, Arrow(Int, Arrow(Boolean, String)))
def m4(fun:Int=> Boolean):String
![Page 27: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/27.jpg)
def m3(a1: Int, a2:Boolean):String
hasType(m3, Arrow(Int, Arrow(Boolean, String)))
def m4(fun:Int=>Boolean):String
hasType(m4, Arrow(Arrow(Int,Boolean),String))
![Page 28: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/28.jpg)
def m5[A](lst :A) :String
![Page 29: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/29.jpg)
def m5[A](lst :A) :String
hasType(m5, Arrow(A, String))
![Page 30: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/30.jpg)
def m5[A](lst :A) :String
hasType(m5, Arrow(A, String))
Univ. quan.Variable
![Page 31: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/31.jpg)
def m5[A](lst :A) :String
hasType(m5, Arrow(A, String))
def m6():String = ?
Univ. quan.Variable
![Page 32: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/32.jpg)
def m5[A](lst :A) :String
hasType(m5, Arrow(A, String))
def m6():String = ?
query(String)
Univ. quan.Variable
![Page 33: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/33.jpg)
def m5[A](lst :A) :String
hasType(m5, Arrow(A, String))
def m6():String = ?
query(String)
Univ. quan.Variable
Predicate
![Page 34: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/34.jpg)
Forward Reasoning:
hasType(f, Arrow(T1, T2)) hasType(a, T1)hasType(f(a), T2)
Example:
def f(arg:T1):T2 var a:T1f(a): T2
![Page 35: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/35.jpg)
Backward Reasoning:
hasType(f, Arrow(T1, T2)) query(T2)query(T1)
Example:
def f(arg:T1):T2 var a:T2 = ?arg: T1 = ?
![Page 36: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/36.jpg)
Deriving empty clause:
hasType(x, T1) query(T1)
Example:
def f():T1 var a:T1 = ?f()
![Page 37: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/37.jpg)
Symbol weights
User preferred
Local symbols
Method and field symbolsAPI symbols
Term weights Knuth-Bendix ordering Recalculate weight of terms with user preferred symbols
Clause weights Sum of all terms’ weight in clause
Arrow
Low High
![Page 38: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/38.jpg)
Program # Loaded Declarations
# Methods in Synthesized Snippets
Time [s]
FileReader 5 4 0.001Map 3 3 < 0.001
FileManager 7 3 0.001Calendar 29 3 0.001FileWriter 442 6 0.72
SwingBorder 161 2 0.02TcpService 112 3 0.62
![Page 39: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/39.jpg)
iSynth - the first interactively deployed synthesis tool: Parameterized types Weights indicating preferences
Based on a variation of an ordered resolution calculus
We have found to be fast enough and helpful in synthesizing meaningful code fragments
Future work: Weights mining
![Page 40: Tihomir Gvero, Ruzica Piskac, Viktor Kuncak](https://reader030.vdocuments.us/reader030/viewer/2022012019/616877aed394e9041f6fc45e/html5/thumbnails/40.jpg)
Thank you