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

Check precondition against phi

parent 50b03820
No related branches found
No related tags found
No related merge requests found
...@@ -23,18 +23,20 @@ trait Heuristic { ...@@ -23,18 +23,20 @@ trait Heuristic {
} }
object HeuristicStep { object HeuristicStep {
def verifyPre(synth: Synthesizer)(s: Solution): (Solution, Boolean) = { def verifyPre(synth: Synthesizer, problem: Problem)(s: Solution): (Solution, Boolean) = {
synth.solver.solveSAT(And(Not(s.pre), s.fullTerm)) match { synth.solver.solveSAT(And(Not(s.pre), problem.phi)) match {
case (Some(true), model) => case (Some(true), model) =>
synth.reporter.warning("Heuristic failed to produce strongest precondition for solution: \n"+s.toExpr) synth.reporter.warning("Heuristic failed to produce strongest precondition:")
synth.reporter.warning(" - problem: "+problem)
synth.reporter.warning(" - precondition: "+s.pre)
(s, false) (s, false)
case _ => case _ =>
(s, true) (s, true)
} }
} }
def apply(synth: Synthesizer, subProblems: List[Problem], onSuccess: List[Solution] => Solution) = { def apply(synth: Synthesizer, problem: Problem, subProblems: List[Problem], onSuccess: List[Solution] => Solution) = {
RuleMultiSteps(subProblems, Nil, onSuccess.andThen(verifyPre(synth))) RuleMultiSteps(subProblems, Nil, onSuccess.andThen(verifyPre(synth, problem)))
} }
} }
...@@ -86,7 +88,7 @@ class IntInduction(synth: Synthesizer) extends Rule("Int Induction", synth, 80) ...@@ -86,7 +88,7 @@ class IntInduction(synth: Synthesizer) extends Rule("Int Induction", synth, 80)
Solution.none Solution.none
} }
RuleStep(List(subBase, subGT, subLT), onSuccess) HeuristicStep(synth, p, List(subBase, subGT, subLT), onSuccess)
case _ => case _ =>
RuleInapplicable RuleInapplicable
} }
...@@ -122,7 +124,7 @@ class OptimisticInjection(synth: Synthesizer) extends Rule("Opt. Injection", syn ...@@ -122,7 +124,7 @@ class OptimisticInjection(synth: Synthesizer) extends Rule("Opt. Injection", syn
val sub = p.copy(phi = And(newExprs)) val sub = p.copy(phi = And(newExprs))
RuleStep(List(sub), forward) HeuristicStep(synth, p, List(sub), forward)
} else { } else {
RuleInapplicable RuleInapplicable
} }
...@@ -158,7 +160,7 @@ class SelectiveInlining(synth: Synthesizer) extends Rule("Sel. Inlining", synth, ...@@ -158,7 +160,7 @@ class SelectiveInlining(synth: Synthesizer) extends Rule("Sel. Inlining", synth,
val sub = p.copy(phi = And(newExprs)) val sub = p.copy(phi = And(newExprs))
RuleStep(List(sub), forward) HeuristicStep(synth, p, List(sub), forward)
} else { } else {
RuleInapplicable RuleInapplicable
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment