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

Propagate IntInduction's precondition

parent c9f0f7de
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,13 @@ class IntInduction(synth: Synthesizer) extends Rule("Int Induction", synth, 80) ...@@ -55,7 +55,13 @@ class IntInduction(synth: Synthesizer) extends Rule("Int Induction", synth, 80)
, LetTuple(postXs, FunctionInvocation(newFun, Seq(Plus(Variable(inductOn), IntLiteral(1)))), lt.toExpr))) , LetTuple(postXs, FunctionInvocation(newFun, Seq(Plus(Variable(inductOn), IntLiteral(1)))), lt.toExpr)))
) )
Solution(BooleanLiteral(true), LetDef(newFun, FunctionInvocation(newFun, Seq(Variable(origId))))) val pre =
subst( inductOn -> Variable(origId),
Or(Seq(And(Equals(Variable(inductOn), IntLiteral(0)), base.pre),
And(GreaterThan(Variable(inductOn), IntLiteral(0)), gt.pre),
And(LessThan(Variable(inductOn), IntLiteral(0)), lt.pre))))
Solution(pre, LetDef(newFun, FunctionInvocation(newFun, Seq(Variable(origId)))))
case _ => case _ =>
Solution.none Solution.none
} }
......
...@@ -80,8 +80,8 @@ class Task(synth: Synthesizer, ...@@ -80,8 +80,8 @@ class Task(synth: Synthesizer,
parent.partlySolvedBy(this, solution) parent.partlySolvedBy(this, solution)
val prefix = "[%-20s] ".format(Option(rule).map(_.toString).getOrElse("root")) val prefix = "[%-20s] ".format(Option(rule).map(_.toString).getOrElse("root"))
println(prefix+"Got: "+problem) synth.reporter.info(prefix+"Got: "+problem)
println(prefix+"Solved with: "+solution) synth.reporter.info(prefix+"Solved with: "+solution)
Nil Nil
case RuleMultiSteps(subProblems, interSteps, onSuccess) => case RuleMultiSteps(subProblems, interSteps, onSuccess) =>
...@@ -96,10 +96,10 @@ class Task(synth: Synthesizer, ...@@ -96,10 +96,10 @@ class Task(synth: Synthesizer,
val simplestSolution = onSuccess(simplestSubSolutions) val simplestSolution = onSuccess(simplestSubSolutions)
minComplexity = new FixedSolComplexity(parent.minComplexity.value + simplestSolution.complexity.value) minComplexity = new FixedSolComplexity(parent.minComplexity.value + simplestSolution.complexity.value)
val prefix = "[%-20s] ".format(Option(rule).map(_.toString).getOrElse("root")) val prefix = "[%-20s] ".format(Option(rule).map(_.toString).getOrElse("root"))
println(prefix+"Got: "+problem) synth.reporter.info(prefix+"Got: "+problem)
println(prefix+"Decomposed into:") synth.reporter.info(prefix+"Decomposed into:")
for(p <- subProblems) { for(p <- subProblems) {
println(prefix+" - "+p) synth.reporter.info(prefix+" - "+p)
} }
subProblems subProblems
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment