Skip to content
Snippets Groups Projects
Commit 7d353945 authored by Regis Blanc's avatar Regis Blanc
Browse files

generate vc for division by zero

parent a1f0bcda
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,7 @@ class DefaultTactic(vctx: VerificationContext) extends Tactic(vctx) {
case e @ Error(_, "Match is non-exhaustive") =>
(e, VCKinds.ExhaustiveMatch, BooleanLiteral(false))
case e @ Error(_, _) =>
(e, VCKinds.Assert, BooleanLiteral(false))
......@@ -57,6 +58,8 @@ class DefaultTactic(vctx: VerificationContext) extends Tactic(vctx) {
VCKinds.MapUsage
} else if (err.startsWith("Array ")) {
VCKinds.ArrayUsage
} else if (err.startsWith("Division ")) {
VCKinds.DivisionByZero
} else {
VCKinds.Assert
}
......
......@@ -30,6 +30,18 @@ object InjectAsserts extends LeonPhase[Program, Program] {
Some(Assert(indexUpTo(i, ArrayLength(a)), Some("Array index out of range"), e).setPos(e))
case e @ MapGet(m,k) =>
Some(Assert(MapIsDefinedAt(m, k), Some("Map undefined at this index"), e).setPos(e))
case e @ Division(_, d) =>
Some(Assert(Not(Equals(d, InfiniteIntegerLiteral(0))),
Some("Division by zero"),
e
).setPos(e))
case e @ BVDivision(_, d) =>
Some(Assert(Not(Equals(d, IntLiteral(0))),
Some("Division by zero"),
e
).setPos(e))
case _ =>
None
})
......
......@@ -34,6 +34,7 @@ object VCKinds {
case object ExhaustiveMatch extends VCKind("match exhaustiveness", "match.")
case object MapUsage extends VCKind("map usage", "map use")
case object ArrayUsage extends VCKind("array usage", "arr. use")
case object DivisionByZero extends VCKind("division by zero", "div 0")
}
case class VCResult(status: VCStatus, solvedWith: Option[Solver], timeMs: Option[Long]) {
......
import leon.lang._
import leon.collection._
import leon._
object BVDivision {
def divByZero(x: Int): Boolean = {
(x / 0 == 10)
}
}
import leon.lang._
import leon.collection._
import leon._
object Division {
def divByZero(x: BigInt): Boolean = {
(x / BigInt(0) == BigInt(10))
}
}
import leon.lang._
import leon.collection._
import leon._
object BVDivision {
def noDivByZero(x: Int): Boolean = {
(x / 10 == 10)
}
}
import leon.lang._
import leon.collection._
import leon._
object Division {
def noDivByZero(x: BigInt): Boolean = {
(x / BigInt(10) == BigInt(10))
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment