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

add some counter-examples as well

parent 6562b9f3
No related branches found
No related tags found
No related merge requests found
object NestedFunState1 {
def simpleSideEffect(n: BigInt): BigInt = {
require(n > 0)
var a = BigInt(0)
def incA(prevA: BigInt): Unit = {
require(prevA == a)
a += 1
} ensuring(_ => a == prevA + 1)
incA(a)
incA(a)
incA(a)
incA(a)
a
} ensuring(_ == 5)
}
/* Copyright 2009-2015 EPFL, Lausanne */
object NestedFunState2 {
def sum(n: BigInt): BigInt = {
require(n > 0)
var i = BigInt(0)
var res = BigInt(0)
def iter(): Unit = {
require(res >= i && i >= 0)
if(i < n) {
i += 1
res += i
iter()
}
}
iter()
res
} ensuring(_ < 0)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment