Skip to content

Instantly share code, notes, and snippets.

@jad-hamza
Created September 8, 2020 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jad-hamza/3301e30a36f9c84107897007e9fb9926 to your computer and use it in GitHub Desktop.
Save jad-hamza/3301e30a36f9c84107897007e9fb9926 to your computer and use it in GitHub Desktop.
import stainless.annotation._
object Demo {
def f(x: BigInt, y: BigInt): BigInt = {
require(x >= 0 && y >= 1)
x * y
}.ensuring(res =>
res >= x
)
def g(z: BigInt): Unit = {
require(z >= 10)
val r1 = f(z, z)
val r2 = f(10, 5)
val r3 = f(z, 3)
assert(r3 >= 3)
assert(r2 == 50)
}
@extern
def main(args: Array[String]): Unit = {
println(f(100, 20))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment