Skip to content
Snippets Groups Projects
Commit a3c07ab7 authored by Mikaël Mayer's avatar Mikaël Mayer
Browse files

Question builder will now try to instantiate always different terminal values...

Question builder will now try to instantiate always different terminal values for better comparison.
Corrected benchmark out of order to not depend on each other;
parent 9a4cd91a
No related branches found
No related tags found
No related merge requests found
...@@ -144,18 +144,33 @@ class QuestionBuilder[T <: Expr]( ...@@ -144,18 +144,33 @@ class QuestionBuilder[T <: Expr](
/** Make all generic values unique. /** Make all generic values unique.
* Duplicate generic values are not suitable for disambiguating questions since they remove an order. */ * Duplicate generic values are not suitable for disambiguating questions since they remove an order. */
def makeGenericValuesUnique(a: Expr): Expr = { def makeGenericValuesUnique(a: Expr): Expr = {
var genVals = Set[GenericValue]() var genVals = Set[Expr with Terminal]()
@tailrec @inline def freshGenericValue(g: GenericValue): GenericValue = { def freshenValue(g: Expr with Terminal): Option[Expr with Terminal] = g match {
if(genVals contains g) case g: GenericValue => Some(GenericValue(g.tp, g.id + 1))
freshGenericValue(GenericValue(g.tp, g.id + 1)) case StringLiteral(s) =>
else { val i = s.lastIndexWhere { c => c < '0' || c > '9' }
genVals += g val prefix = s.take(i+1)
g val suffix = s.drop(i+1)
} Some(StringLiteral(prefix + (if(suffix == "") "0" else (suffix.toInt + 1).toString)))
case InfiniteIntegerLiteral(i) => Some(InfiniteIntegerLiteral(i+1))
case IntLiteral(i) => if(i == Integer.MAX_VALUE) None else Some(IntLiteral(i+1))
case CharLiteral(c) => if(c == Char.MaxValue) None else Some(CharLiteral((c+1).toChar))
case otherLiteral => None
}
@tailrec @inline def freshValue(g: Expr with Terminal): Expr with Terminal = {
if(genVals contains g)
freshenValue(g) match {
case None => g
case Some(v) => freshValue(v)
}
else {
genVals += g
g
}
} }
ExprOps.postMap{ e => e match { ExprOps.postMap{ e => e match {
case g@GenericValue(tpe, i) => case g:Expr with Terminal =>
Some(freshGenericValue(g)) Some(freshValue(g))
case _ => None case _ => None
}}(a) }}(a)
} }
......
...@@ -5,13 +5,13 @@ import leon.collection.ListOps._ ...@@ -5,13 +5,13 @@ import leon.collection.ListOps._
import leon.lang.synthesis._ import leon.lang.synthesis._
object OutOfOrderToString { object OutOfOrderToString {
def argumentsToString(i: Int, j: Int): String = { def arguments(i: Int, j: Int): String = {
??? ???
} ensuring { (res: String) => ((i, j), res) passes { } ensuring { (res: String) => ((i, j), res) passes {
case (1, 2) => "2, 1" case (1, 2) => "2, 1"
} } } }
def tupleToString(i: (Int, Int)): String = { def tuple(i: (Int, Int)): String = {
??? ???
} ensuring { (res: String) => (i, res) passes { } ensuring { (res: String) => (i, res) passes {
case (1, 2) => "2, 1" case (1, 2) => "2, 1"
...@@ -27,7 +27,7 @@ object OutOfOrderToString { ...@@ -27,7 +27,7 @@ object OutOfOrderToString {
} }
} }
def listPairToString(l : List[(Int, Int)]): String = { def listPair(l : List[(Int, Int)]): String = {
???[String] ???[String]
} ensuring { } ensuring {
(res : String) => (l, res) passes { (res : String) => (l, res) passes {
...@@ -36,7 +36,7 @@ object OutOfOrderToString { ...@@ -36,7 +36,7 @@ object OutOfOrderToString {
} }
} }
def reverselistPairToString(l: List[(Int, Int)]): String = { def reverselistPair(l: List[(Int, Int)]): String = {
??? ???
} ensuring { (res: String) => (l, res) passes { } ensuring { (res: String) => (l, res) passes {
case Cons((1, 2), Cons((3,4), Nil())) => "4 -> 3, 2 -> 1" case Cons((1, 2), Cons((3,4), Nil())) => "4 -> 3, 2 -> 1"
...@@ -44,7 +44,7 @@ object OutOfOrderToString { ...@@ -44,7 +44,7 @@ object OutOfOrderToString {
case class Rule(input: Int, applied: Option[Int]) case class Rule(input: Int, applied: Option[Int])
def ruleToString(r : Rule): String = { def rule(r : Rule): String = {
??? ???
} ensuring { } ensuring {
(res : String) => (r, res) passes { (res : String) => (r, res) passes {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment