Skip to content
Snippets Groups Projects
Commit edfc397d authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Generate multiple derivation graphs, output more info

parent 864bdc4a
No related branches found
No related tags found
No related merge requests found
...@@ -58,10 +58,10 @@ object SynthesisPhase extends LeonPhase[Program, Program] { ...@@ -58,10 +58,10 @@ object SynthesisPhase extends LeonPhase[Program, Program] {
case _ => case _ =>
} }
def synthesizeAll(program: Program): Map[Choose, Solution] = { def synthesizeAll(program: Program): Map[Choose, (FunDef, Solution)] = {
def noop(u:Expr, u2: Expr) = u def noop(u:Expr, u2: Expr) = u
var solutions = Map[Choose, Solution]() var solutions = Map[Choose, (FunDef, Solution)]()
def actOnChoose(f: FunDef)(e: Expr, a: Expr): Expr = e match { def actOnChoose(f: FunDef)(e: Expr, a: Expr): Expr = e match {
case ch @ Choose(vars, pred) => case ch @ Choose(vars, pred) =>
...@@ -78,7 +78,7 @@ object SynthesisPhase extends LeonPhase[Program, Program] { ...@@ -78,7 +78,7 @@ object SynthesisPhase extends LeonPhase[Program, Program] {
timeoutMs) timeoutMs)
val sol = synth.synthesize() val sol = synth.synthesize()
solutions += ch -> sol solutions += ch -> (f, sol)
a a
case _ => case _ =>
...@@ -110,16 +110,16 @@ object SynthesisPhase extends LeonPhase[Program, Program] { ...@@ -110,16 +110,16 @@ object SynthesisPhase extends LeonPhase[Program, Program] {
def simplify(e: Expr): Expr = simplifiers.foldLeft(e){ (x, sim) => sim(x) } def simplify(e: Expr): Expr = simplifiers.foldLeft(e){ (x, sim) => sim(x) }
val chooseToExprs = solutions.map { val chooseToExprs = solutions.map {
case (ch, sol) => (ch, simplify(sol.toExpr)) case (ch, (fd, sol)) => (ch, (fd, simplify(sol.toExpr)))
} }
if (inPlace) { if (inPlace) {
for (file <- ctx.files) { for (file <- ctx.files) {
new FileInterface(ctx.reporter, file).updateFile(chooseToExprs) new FileInterface(ctx.reporter, file).updateFile(chooseToExprs.mapValues(_._2))
} }
} else { } else {
for ((chs, ex) <- chooseToExprs) { for ((chs, (fd, ex)) <- chooseToExprs) {
ctx.reporter.info("-"*32+" Synthesis of: "+"-"*32) ctx.reporter.info("-"*32+" In "+fd.id.toString+", synthesis of: "+"-"*32)
ctx.reporter.info(chs) ctx.reporter.info(chs)
ctx.reporter.info("-"*35+" Result: "+"-"*35) ctx.reporter.info("-"*35+" Result: "+"-"*35)
ctx.reporter.info(ScalaPrinter(ex)) ctx.reporter.info(ScalaPrinter(ex))
......
...@@ -61,7 +61,7 @@ class Synthesizer(val context : LeonContext, ...@@ -61,7 +61,7 @@ class Synthesizer(val context : LeonContext,
reporter.info("Finished in "+diff+"ms") reporter.info("Finished in "+diff+"ms")
if (generateDerivationTrees) { if (generateDerivationTrees) {
new AndOrGraphDotConverter(search.g, firstOnly).writeFile("derivation.dot") new AndOrGraphDotConverter(search.g, firstOnly).writeFile("derivation"+AndOrGraphDotConverterCounter.next()+".dot")
} }
res match { res match {
......
package leon.synthesis.search package leon.synthesis.search
class AndOrGraphDotConverter[AT <: AOAndTask[S], class AndOrGraphDotConverter[AT <: AOAndTask[S],
OT <: AOOrTask[S], OT <: AOOrTask[S],
S <: AOSolution](val g: AndOrGraph[AT, OT, S], firstOnly: Boolean) { S <: AOSolution](val g: AndOrGraph[AT, OT, S], firstOnly: Boolean) {
...@@ -116,3 +115,13 @@ class AndOrGraphDotConverter[AT <: AOAndTask[S], ...@@ -116,3 +115,13 @@ class AndOrGraphDotConverter[AT <: AOAndTask[S],
out.close() out.close()
} }
} }
object AndOrGraphDotConverterCounter {
private var nextId = 0;
def next() = {
nextId += 1
nextId
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment