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

slightly better

parent 651f12e2
Branches
Tags
No related merge requests found
package leon package leon
package synthesis package synthesis
import purescala.Common._
import purescala.Trees._ import purescala.Trees._
object Rules { object Rules {
...@@ -12,6 +13,9 @@ object Rules { ...@@ -12,6 +13,9 @@ object Rules {
abstract class Rule(val name: String) { abstract class Rule(val name: String) {
def isApplicable(p: Problem, parent: Task): List[Task] def isApplicable(p: Problem, parent: Task): List[Task]
def subst(what: Tuple2[Identifier, Expr], in: Expr): Expr = replace(Map(Variable(what._1) -> what._2), in)
} }
object OnePoint extends Rule("One-point") { object OnePoint extends Rule("One-point") {
...@@ -32,14 +36,14 @@ object OnePoint extends Rule("One-point") { ...@@ -32,14 +36,14 @@ object OnePoint extends Rule("One-point") {
val others = exprs.filter(_ != eq) val others = exprs.filter(_ != eq)
val oxs = p.xs.filter(_ != x) val oxs = p.xs.filter(_ != x)
val newProblem = Problem(p.as, replace(Map(Variable(x) -> e), And(others)), oxs) val newProblem = Problem(p.as, subst(x -> e, And(others)), oxs)
val onSuccess: List[Solution] => Solution = { val onSuccess: List[Solution] => Solution = {
case List(Solution(pre, term)) => case List(Solution(pre, term)) =>
if (oxs.isEmpty) { if (oxs.isEmpty) {
Solution(pre, e) Solution(pre, e)
} else { } else {
Solution(pre, LetTuple(oxs, term, replace(Map(Variable(x) -> e), Tuple(p.xs.map(Variable(_))))) ) Solution(pre, LetTuple(oxs, term, subst(x -> e, Tuple(p.xs.map(Variable(_))))) )
} }
case _ => Solution.none case _ => Solution.none
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment