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

Generate a proper error in ground rule

parent 6e5f1718
Branches
Tags
No related merge requests found
...@@ -3,6 +3,7 @@ package synthesis ...@@ -3,6 +3,7 @@ package synthesis
import purescala.Common._ import purescala.Common._
import purescala.Trees._ import purescala.Trees._
import purescala.TypeTrees._
object Rules { object Rules {
def all(synth: Synthesizer) = List( def all(synth: Synthesizer) = List(
...@@ -65,16 +66,19 @@ class OnePoint(synth: Synthesizer) extends Rule("One-point", synth) { ...@@ -65,16 +66,19 @@ class OnePoint(synth: Synthesizer) extends Rule("One-point", synth) {
class Ground(synth: Synthesizer) extends Rule("Ground", synth) { class Ground(synth: Synthesizer) extends Rule("Ground", synth) {
def isApplicable(p: Problem, parent: Task): List[Task] = { def isApplicable(p: Problem, parent: Task): List[Task] = {
if (p.as.isEmpty) { if (p.as.isEmpty) {
val tpe = TupleType(p.xs.map(_.getType))
synth.solveSAT(p.phi) match { synth.solveSAT(p.phi) match {
case (Some(true), model) => case (Some(true), model) =>
val onSuccess: List[Solution] => Solution = { val onSuccess: List[Solution] => Solution = {
case Nil => Solution(BooleanLiteral(true), Tuple(p.xs.map(model))) case Nil => Solution(BooleanLiteral(true), Tuple(p.xs.map(model)).setType(tpe))
} }
List(new Task(synth, parent, this, p, Nil, onSuccess, 200)) List(new Task(synth, parent, this, p, Nil, onSuccess, 200))
case (Some(false), model) => case (Some(false), model) =>
val onSuccess: List[Solution] => Solution = { val onSuccess: List[Solution] => Solution = {
case Nil => Solution(BooleanLiteral(false), BooleanLiteral(false)) case Nil => Solution(BooleanLiteral(false), Error(p.phi+" is UNSAT!").setType(tpe))
} }
List(new Task(synth, parent, this, p, Nil, onSuccess, 200)) List(new Task(synth, parent, this, p, Nil, onSuccess, 200))
......
...@@ -3,6 +3,7 @@ import leon.Utils._ ...@@ -3,6 +3,7 @@ import leon.Utils._
object ChooseTest { object ChooseTest {
def c0(): Int = choose{ (x1: Int) => x1 > 13 } def c0(): Int = choose{ (x1: Int) => x1 > 13 }
def b0(): Int = choose{ (x1: Int) => x1 > 13 && x1 < 2 }
def c1(a: Int): Int = choose{ (x1: Int) => x1 > a } def c1(a: Int): Int = choose{ (x1: Int) => x1 > a }
def c2(a: Int): (Int, Int) = choose{ (x1: Int, x2: Int) => x1 > a && x2 > a } def c2(a: Int): (Int, Int) = choose{ (x1: Int, x2: Int) => x1 > a && x2 > a }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment