Skip to content
Snippets Groups Projects
Commit 07fcf25b authored by Philippe Suter's avatar Philippe Suter
Browse files

No commit message

No commit message
parent f3e437f2
No related branches found
No related tags found
No related merge requests found
...@@ -23,18 +23,18 @@ class DefaultTactic(reporter: Reporter) extends Tactic(reporter) { ...@@ -23,18 +23,18 @@ class DefaultTactic(reporter: Reporter) extends Tactic(reporter) {
assert(functionDefinition.body.isDefined) assert(functionDefinition.body.isDefined)
val prec = functionDefinition.precondition val prec = functionDefinition.precondition
val post = functionDefinition.postcondition val post = functionDefinition.postcondition
val body = functionDefinition.body.get val body = matchToIfThenElse(functionDefinition.body.get)
if(post.isEmpty) { if(post.isEmpty) {
Seq.empty Seq.empty
} else { } else {
val theExpr = { val theExpr = {
val resFresh = FreshIdentifier("result", true).setType(body.getType) val resFresh = FreshIdentifier("result", true).setType(body.getType)
val bodyAndPost = Let(resFresh, body, replace(Map(ResultVariable() -> Variable(resFresh)), post.get)) val bodyAndPost = Let(resFresh, body, replace(Map(ResultVariable() -> Variable(resFresh)), matchToIfThenElse(post.get)))
val withPrec = if(prec.isEmpty) { val withPrec = if(prec.isEmpty) {
bodyAndPost bodyAndPost
} else { } else {
Implies(prec.get, bodyAndPost) Implies(matchToIfThenElse(prec.get), bodyAndPost)
} }
import Analysis._ import Analysis._
...@@ -69,19 +69,7 @@ class DefaultTactic(reporter: Reporter) extends Tactic(reporter) { ...@@ -69,19 +69,7 @@ class DefaultTactic(reporter: Reporter) extends Tactic(reporter) {
reporter.info("Contract'ed, expanded:") reporter.info("Contract'ed, expanded:")
reporter.info(expandLets(expr2)) reporter.info(expandLets(expr2))
} }
reporter.info(" - converting pattern-matching...") expr2
val expr3 = if(Settings.useNewPatternMatchingTranslator) {
matchToIfThenElse(expr2)
} else {
rewriteSimplePatternMatching(expr2)
}
if(Settings.experimental) {
reporter.info("Pattern'ed:")
reporter.info(expr3)
reporter.info("Pattern'ed, expanded:")
reporter.info(expandLets(expr3))
}
expr3
} }
Seq(new VerificationCondition(theExpr, functionDefinition, VCKind.Postcondition, this)) Seq(new VerificationCondition(theExpr, functionDefinition, VCKind.Postcondition, this))
} }
......
...@@ -95,8 +95,8 @@ object BinarySearchTree { ...@@ -95,8 +95,8 @@ object BinarySearchTree {
def cleanInsert(tree: Tree, value: Int) : Tree = (tree match { def cleanInsert(tree: Tree, value: Int) : Tree = (tree match {
case Leaf() => Node(Leaf(), value, Leaf()) case Leaf() => Node(Leaf(), value, Leaf())
case Node(l, v, r) if v < value => Node(l, v, insert(r, value)) case Node(l, v, r) if v < value => Node(l, v, cleanInsert(r, value))
case Node(l, v, r) if v > value => Node(insert(l, value), v, r) case Node(l, v, r) if v > value => Node(cleanInsert(l, value), v, r)
case n @ Node(l, v, r) if v == value => n case n @ Node(l, v, r) if v == value => n
}) ensuring(contents(_) == contents(tree) ++ Set(value)) }) ensuring(contents(_) == contents(tree) ++ Set(value))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment