Skip to content

Commit

Permalink
Update bonsai to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
manoskouk committed Jan 26, 2016
1 parent ca2a7b6 commit 542dea5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 16 deletions.
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ fork in IsabelleTest := true

def ghProject(repo: String, version: String) = RootProject(uri(s"${repo}#${version}"))

lazy val bonsai = ghProject("git://github.com/colder/bonsai.git", "0fec9f97f4220fa94b1f3f305f2e8b76a3cd1539")

lazy val bonsai = ghProject("git://github.com/colder/bonsai.git", "10eaaee4ea0ff6567f4f866922cb871bae2da0ac")
lazy val scalaSmtLib = ghProject("git://github.com/regb/scala-smtlib.git", "372bb14d0c84953acc17f9a7e1592087adb0a3e1")

lazy val root = (project in file(".")).
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/leon/datagen/GrammarDataGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GrammarDataGen(evaluator: Evaluator, grammar: ExpressionGrammar[TypeTree]
implicit val ctx = evaluator.context

def generate(tpe: TypeTree): Iterator[Expr] = {
val enum = new MemoizedEnumerator[TypeTree, Expr](grammar.getProductions)
val enum = new MemoizedEnumerator[TypeTree, Expr, Generator[TypeTree, Expr]](grammar.getProductions)
enum.iterator(tpe)
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/leon/grammars/ExpressionGrammar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
package leon
package grammars

import bonsai._

import purescala.Expressions._
import purescala.Types._
import purescala.Common._
Expand Down
16 changes: 16 additions & 0 deletions src/main/scala/leon/grammars/Generator.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Copyright 2009-2015 EPFL, Lausanne */

package leon
package grammars

import bonsai.{Generator => Gen}

object GrammarTag extends Enumeration {
val Top = Value
}
import GrammarTag._

class Generator[T, R](subTrees: Seq[T], builder: Seq[R] => R, tag: Value) extends Gen[T,R](subTrees, builder)
object Generator {
def apply[T, R](subTrees: Seq[T], builder: Seq[R] => R, tag: Value = Top) = new Generator(subTrees, builder, tag)
}
2 changes: 1 addition & 1 deletion src/main/scala/leon/repair/Repairman.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class Repairman(ctx0: LeonContext, initProgram: Program, fd: FunDef, verifTimeou
val maxValid = 400

val evaluator = new CodeGenEvaluator(ctx, program, CodeGenParams.default)
val enum = new MemoizedEnumerator[TypeTree, Expr](ValueGrammar.getProductions)
val enum = new MemoizedEnumerator[TypeTree, Expr, Generator[TypeTree, Expr]](ValueGrammar.getProductions)

val inputs = enum.iterator(tupleTypeWrap(fd.params map { _.getType})).map(unwrapTuple(_, fd.params.size))

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/leon/synthesis/ExamplesFinder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class ExamplesFinder(ctx0: LeonContext, program: Program) {
}) getOrElse {
// If the input contains free variables, it does not provide concrete examples.
// We will instantiate them according to a simple grammar to get them.
val enum = new MemoizedEnumerator[TypeTree, Expr](ValueGrammar.getProductions)
val enum = new MemoizedEnumerator[TypeTree, Expr, Generator[TypeTree, Expr]](ValueGrammar.getProductions)
val values = enum.iterator(tupleTypeWrap(freeVars.map { _.getType }))
val instantiations = values.map {
v => freeVars.zip(unwrapTuple(v, freeVars.size)).toMap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package leon
package synthesis.disambiguation

import synthesis.RuleClosed
import synthesis.Solution
import evaluators.DefaultEvaluator
import purescala.Expressions._
Expand All @@ -14,10 +13,9 @@ import purescala.Definitions.Program
import purescala.DefOps
import grammars.ValueGrammar
import bonsai.enumerators.MemoizedEnumerator
import solvers.Model
import solvers.ModelBuilder
import scala.collection.mutable.ListBuffer
import leon.grammars.ExpressionGrammar
import grammars._

object QuestionBuilder {
/** Sort methods for questions. You can build your own */
Expand Down Expand Up @@ -142,7 +140,7 @@ class QuestionBuilder[T <: Expr](
def result(): List[Question[T]] = {
if(solutions.isEmpty) return Nil

val enum = new MemoizedEnumerator[TypeTree, Expr](value_enumerator.getProductions)
val enum = new MemoizedEnumerator[TypeTree, Expr, Generator[TypeTree,Expr]](value_enumerator.getProductions)
val values = enum.iterator(tupleTypeWrap(_argTypes))
val instantiations = values.map {
v => input.zip(unwrapTuple(v, input.size))
Expand Down
6 changes: 2 additions & 4 deletions src/main/scala/leon/synthesis/rules/BottomUpTegis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import purescala.Expressions._
import purescala.Common._
import purescala.Types._
import purescala.Constructors._
import purescala.Quantification._
import evaluators._
import codegen.CodeGenParams

import utils._
import grammars._

import bonsai._
import bonsai.enumerators._
import bonsai.{Generator => Gen}

case object BottomUpTEGIS extends BottomUpTEGISLike[TypeTree]("BU TEGIS") {
def getGrammar(sctx: SynthesisContext, p: Problem) = {
Expand Down Expand Up @@ -110,7 +108,7 @@ abstract class BottomUpTEGISLike[T <: Typed](name: String) extends Rule(name) {
val targetType = tupleTypeWrap(p.xs.map(_.getType))
val wrappedTests = tests.map { case (is, os) => (is, tupleWrap(os))}

val enum = new BottomUpEnumerator[T, Expr, Expr](
val enum = new BottomUpEnumerator[T, Expr, Expr, Generator[T, Expr]](
grammar.getProductions,
wrappedTests,
{ (vecs, gen) =>
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/leon/synthesis/rules/TEGISLike.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ abstract class TEGISLike[T <: Typed](name: String) extends Rule(name) {
val evalParams = CodeGenParams.default.copy(maxFunctionInvocations = 2000)
val evaluator = new DualEvaluator(sctx.context, sctx.program, evalParams)

val enum = new MemoizedEnumerator[T, Expr](grammar.getProductions)
val enum = new MemoizedEnumerator[T, Expr, Generator[T, Expr]](grammar.getProductions)

val targetType = tupleTypeWrap(p.xs.map(_.getType))

Expand Down

0 comments on commit 542dea5

Please sign in to comment.