diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf deleted file mode 100644 index 51fdc6c2c4717c3f40ec017b385bc57af417884a..0000000000000000000000000000000000000000 --- a/src/main/resources/application.conf +++ /dev/null @@ -1,3 +0,0 @@ -akka { - "log-dead-letters-during-shutdown": false -} diff --git a/src/main/resources/leon/scalac-plugin.xml b/src/main/resources/leon/scalac-plugin.xml deleted file mode 100644 index 9295807e55edbee1a3bf1d098f418193c679986b..0000000000000000000000000000000000000000 --- a/src/main/resources/leon/scalac-plugin.xml +++ /dev/null @@ -1,4 +0,0 @@ -<plugin> - <name>leon</name> - <classname>leon.plugin.LeonPlugin</classname> -</plugin> diff --git a/src/main/resources/slf4j-impl-helper b/src/main/resources/slf4j-impl-helper deleted file mode 100644 index 4dda6f88ac85b4d0e91df3611ea0d2b043515316..0000000000000000000000000000000000000000 --- a/src/main/resources/slf4j-impl-helper +++ /dev/null @@ -1 +0,0 @@ -leon.solvers.isabelle.LeonLoggerFactory diff --git a/src/test/resources/regression/frontends/error/simple/ArrayEquals1.scala b/src/test/resources/regression/frontends/error/simple/ArrayEquals1.scala deleted file mode 100644 index a0c3bd956eadb23512fc87597070dd7ca4fb65ba..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/error/simple/ArrayEquals1.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package leon.lang._ - -object ArrayEqual1 { - - def f: Boolean = { - Array(1,2,3) == Array(1,2,3) - } ensuring(res => res) - -} - diff --git a/src/test/resources/regression/frontends/error/simple/ArrayEquals2.scala b/src/test/resources/regression/frontends/error/simple/ArrayEquals2.scala deleted file mode 100644 index 15557c92b23f77780b803894aa5e7c9b90483f59..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/error/simple/ArrayEquals2.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package leon.lang._ - -object ArrayEqual2 { - - def f: Boolean = { - Array(1,2,3) != Array(1,2,3) - } ensuring(res => !res) - -} - diff --git a/src/test/resources/regression/frontends/error/simple/ConvertBigInt.scala b/src/test/resources/regression/frontends/error/simple/ConvertBigInt.scala deleted file mode 100644 index b55bfc3f52bab931981fc1b8f811f01d2dd2b767..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/error/simple/ConvertBigInt.scala +++ /dev/null @@ -1,7 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object ConvertBigInt { - - def safeInt(x: Int): BigInt = x - -} diff --git a/src/test/resources/regression/frontends/error/simple/InstanceOf1.scala b/src/test/resources/regression/frontends/error/simple/InstanceOf1.scala deleted file mode 100644 index 3136bcc0ba8f59701c99d2695cc16777791148f6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/error/simple/InstanceOf1.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object InstanceOf1 { - - abstract class A - case class B(i: Int) extends A - case class C(i: Int) extends A - - abstract class Z - case class Y(i: Int) extends Z - - def foo(): Int = { - //require(3.isInstanceOf[Int]) - val b: A = B(2) - if(b.isInstanceOf[Y]) - 0 - else - -1 - } ensuring(_ == 0) - - def bar(): Int = foo() - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/frontends/error/simple/LiteralBigInt.scala b/src/test/resources/regression/frontends/error/simple/LiteralBigInt.scala deleted file mode 100644 index 68c1232f409e281da9d2a91cda921227fb417e70..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/error/simple/LiteralBigInt.scala +++ /dev/null @@ -1,7 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object LiteralBigInt { - - def safeInt(x: Int): BigInt = BigInt(x) - -} diff --git a/src/test/resources/regression/frontends/error/simple/NotEquals.scala b/src/test/resources/regression/frontends/error/simple/NotEquals.scala deleted file mode 100644 index 497e7d553a72a331be14541c03db6ddd8cdec75c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/error/simple/NotEquals.scala +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object NotEquals { - - //should not pass front-end - def isDifferent(x: Int, s: String): Boolean = x != s - -} diff --git a/src/test/resources/regression/frontends/passing/ClassFields.scala b/src/test/resources/regression/frontends/passing/ClassFields.scala deleted file mode 100644 index f9253cc99750395ecd93cd4352a1c0391f144bbf..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/passing/ClassFields.scala +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ClassFields { - case class Foo(f : Option[Foo]) -} - diff --git a/src/test/resources/regression/frontends/passing/Fields.scala b/src/test/resources/regression/frontends/passing/Fields.scala deleted file mode 100644 index f6c83deb4ffb5c740c7859d80984b4ce1d81e8d0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/passing/Fields.scala +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.lang._ - -object Fields { - case class Cl(x : Int) { - lazy val lzy = x + 1 - - val eager = x + 2 - - def apply(y : Int) : Int = { - eager + lzy + y - } ensuring { _ == (2 * x + 3) + y } - - } - - def foo() : Int = { - 42 - } - - lazy val ox = 42 - - val oy = ox + 12 - - def lemma(cl : Cl) : Boolean = { - cl.eager + cl.lzy > 2 * cl.x - } holds -} - - diff --git a/src/test/resources/regression/frontends/passing/ImplicitDefs.scala b/src/test/resources/regression/frontends/passing/ImplicitDefs.scala deleted file mode 100644 index 848aeb42831eec68a3f2bd5a625294be92707668..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/passing/ImplicitDefs.scala +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import scala.language.implicitConversions - -object Preamble { - case class BoolOps(b: Boolean) { - def <==>(o: Boolean) = { - (!b || o) && (!o || b) - } - } - - implicit def bTobOps(b: Boolean): BoolOps = BoolOps(b) - def bTobOps2(b: Boolean): BoolOps = BoolOps(b) -} - -object Foo { - import Preamble._ - - def f(b: Boolean) = BoolOps(b) - - def test0(a: BigInt) = { - f((a > 1)).<==>(a > 0) - }.holds - - def test1(a: BigInt) = { - bTobOps2(a > 1).<==>(a > 0) - }.holds - - def test2(a: BigInt) = { - bTobOps(a > 1).<==>(a > 0) - }.holds -} diff --git a/src/test/resources/regression/frontends/passing/ImplicitDefs2.scala b/src/test/resources/regression/frontends/passing/ImplicitDefs2.scala deleted file mode 100644 index d9b07c4bad8ca087a59799782af6a119e98dded3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/passing/ImplicitDefs2.scala +++ /dev/null @@ -1,590 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package leon.blup - -import leon._ -import leon.lang._ -import leon.annotation._ -//import leon.proof._ - -// FIXME: the following should go into the leon.proof package object. -import scala.language.implicitConversions -object proof { - - sealed case class ProofOps(val property: Boolean) { - def because(proof: Boolean): Boolean = property && proof - } - - implicit def boolean2ProofOps(property: Boolean): ProofOps = - ProofOps(property) - - // @ignore - def trivial: Boolean = true - - // @ignore - def by(proof: Boolean)(cont: Boolean): Boolean = - proof && cont - - @ignore - sealed class EqReasoning[A](val x: A) { - def ==:(proof: Boolean)(y: A): A = { - x == y && proof - y - } - def qed: A = x - } - - @ignore - implicit def any2EqReasoning[A](x: A): EqReasoning[A] = - new EqReasoning(x) -} - -import proof._ - -sealed abstract class List[T] { - - def size: BigInt = (this match { - case Nil() => BigInt(0) - case Cons(h, t) => 1 + t.size - }) ensuring (_ >= 0) - - def content: Set[T] = this match { - case Nil() => Set() - case Cons(h, t) => Set(h) ++ t.content - } - - def contains(v: T): Boolean = (this match { - case Cons(h, t) if h == v => true - case Cons(_, t) => t.contains(v) - case Nil() => false - }) ensuring { res => res == (content contains v) } - - def ++(that: List[T]): List[T] = (this match { - case Nil() => that - case Cons(x, xs) => Cons(x, xs ++ that) - }) ensuring { res => - (res.content == this.content ++ that.content) && - (res.size == this.size + that.size) - } - - def head: T = { - require(this != Nil[T]()) - val Cons(h, _) = this - h - } - - def tail: List[T] = { - require(this != Nil[T]()) - val Cons(_, t) = this - t - } - - def apply(index: BigInt): T = { - require(0 <= index && index < size) - if (index == BigInt(0)) { - head - } else { - tail(index-1) - } - } - - def ::(t:T): List[T] = Cons(t, this) - - def :+(t:T): List[T] = { - this match { - case Nil() => Cons(t, this) - case Cons(x, xs) => Cons(x, xs :+ (t)) - } - } ensuring(res => (res.size == size + 1) && (res.content == content ++ Set(t))) - - def reverse: List[T] = { - this match { - case Nil() => this - case Cons(x,xs) => xs.reverse :+ x - } - } ensuring (res => (res.size == size) && (res.content == content)) - - def take(i: BigInt): List[T] = { (this, i) match { - case (Nil(), _) => Nil[T]() - case (Cons(h, t), i) => - if (i <= BigInt(0)) { - Nil[T]() - } else { - Cons(h, t.take(i-1)) - } - }} ensuring { _.size == ( - if (i <= 0) BigInt(0) - else if (i >= this.size) this.size - else i - )} - - def drop(i: BigInt): List[T] = { (this, i) match { - case (Nil(), _) => Nil[T]() - case (Cons(h, t), i) => - if (i <= BigInt(0)) { - Cons(h, t) - } else { - t.drop(i-1) - } - }} ensuring { _.size == ( - if (i <= 0) this.size - else if (i >= this.size) BigInt(0) - else this.size - i - )} - - def slice(from: BigInt, to: BigInt): List[T] = { - require(0 <= from && from <= to && to <= size) - drop(from).take(to-from) - } - - def replace(from: T, to: T): List[T] = { this match { - case Nil() => Nil[T]() - case Cons(h, t) => - val r = t.replace(from, to) - if (h == from) { - Cons(to, r) - } else { - Cons(h, r) - } - }} ensuring { res => - res.size == this.size && - res.content == ( - (this.content -- Set(from)) ++ - (if (this.content contains from) Set(to) else Set[T]()) - ) - } - - private def chunk0(s: BigInt, l: List[T], acc: List[T], res: List[List[T]], s0: BigInt): List[List[T]] = l match { - case Nil() => - if (acc.size > 0) { - res :+ acc - } else { - res - } - case Cons(h, t) => - if (s0 == BigInt(0)) { - chunk0(s, l, Nil(), res :+ acc, s) - } else { - chunk0(s, t, acc :+ h, res, s0-1) - } - } - - def chunks(s: BigInt): List[List[T]] = { - require(s > 0) - - chunk0(s, this, Nil(), Nil(), s) - } - - def zip[B](that: List[B]): List[(T, B)] = { (this, that) match { - case (Cons(h1, t1), Cons(h2, t2)) => - Cons((h1, h2), t1.zip(t2)) - case (_) => - Nil[(T, B)]() - }} ensuring { _.size == ( - if (this.size <= that.size) this.size else that.size - )} - - def -(e: T): List[T] = { this match { - case Cons(h, t) => - if (e == h) { - t - e - } else { - Cons(h, t - e) - } - case Nil() => - Nil[T]() - }} ensuring { _.content == this.content -- Set(e) } - - def --(that: List[T]): List[T] = { this match { - case Cons(h, t) => - if (that.contains(h)) { - t -- that - } else { - Cons(h, t -- that) - } - case Nil() => - Nil[T]() - }} ensuring { _.content == this.content -- that.content } - - def &(that: List[T]): List[T] = { this match { - case Cons(h, t) => - if (that.contains(h)) { - Cons(h, t & that) - } else { - t & that - } - case Nil() => - Nil[T]() - }} ensuring { _.content == (this.content & that.content) } - - def pad(s: BigInt, e: T): List[T] = (this, s) match { - case (_, s) if s <= 0 => - this - case (Nil(), s) => - Cons(e, Nil().pad(s-1, e)) - case (Cons(h, t), s) => - Cons(h, t.pad(s-1, e)) - } - - def find(e: T): Option[BigInt] = { this match { - case Nil() => None[BigInt]() - case Cons(h, t) => - if (h == e) { - Some[BigInt](0) - } else { - t.find(e) match { - case None() => None[BigInt]() - case Some(i) => Some(i+1) - } - } - }} ensuring { _.isDefined == this.contains(e) } - - def init: List[T] = (this match { - case Cons(h, Nil()) => - Nil[T]() - case Cons(h, t) => - Cons[T](h, t.init) - case Nil() => - Nil[T]() - }) ensuring ( (r: List[T]) => ((r.size < this.size) || (this.size == BigInt(0))) ) - - def last: T = { - require(!isEmpty) - this match { - case Cons(h, Nil()) => h - case Cons(_, t) => t.last - } - } - - def lastOption: Option[T] = this match { - case Cons(h, t) => - t.lastOption.orElse(Some(h)) - case Nil() => - None() - } - - def firstOption: Option[T] = this match { - case Cons(h, t) => - Some(h) - case Nil() => - None() - } - - def unique: List[T] = this match { - case Nil() => Nil() - case Cons(h, t) => - Cons(h, t.unique - h) - } - - def splitAt(e: T): List[List[T]] = split(Cons(e, Nil())) - - def split(seps: List[T]): List[List[T]] = this match { - case Cons(h, t) => - if (seps.contains(h)) { - Cons(Nil(), t.split(seps)) - } else { - val r = t.split(seps) - Cons(Cons(h, r.head), r.tail) - } - case Nil() => - Cons(Nil(), Nil()) - } - - def count(e: T): BigInt = this match { - case Cons(h, t) => - if (h == e) { - 1 + t.count(e) - } else { - t.count(e) - } - case Nil() => - BigInt(0) - } - - def evenSplit: (List[T], List[T]) = { - val c = size/2 - (take(c), drop(c)) - } - - def insertAt(pos: BigInt, l: List[T]): List[T] = { - if(pos < 0) { - insertAt(size + pos, l) - } else if(pos == BigInt(0)) { - l ++ this - } else { - this match { - case Cons(h, t) => - Cons(h, t.insertAt(pos-1, l)) - case Nil() => - l - } - } - } - - def replaceAt(pos: BigInt, l: List[T]): List[T] = { - if(pos < 0) { - replaceAt(size + pos, l) - } else if(pos == BigInt(0)) { - l ++ this.drop(l.size) - } else { - this match { - case Cons(h, t) => - Cons(h, t.replaceAt(pos-1, l)) - case Nil() => - l - } - } - } - - def rotate(s: BigInt): List[T] = { - if (s < 0) { - rotate(size+s) - } else { - val s2 = s % size - drop(s2) ++ take(s2) - } - } - - def isEmpty = this match { - case Nil() => true - case _ => false - } - - // Higher-order API - def map[R](f: T => R): List[R] = { this match { - case Nil() => Nil[R]() - case Cons(h, t) => f(h) :: t.map(f) - }} ensuring { _.size == this.size} - - def foldLeft[R](z: R)(f: (R,T) => R): R = this match { - case Nil() => z - case Cons(h,t) => t.foldLeft(f(z,h))(f) - } - - def foldRight[R](f: (T,R) => R)(z: R): R = this match { - case Nil() => z - case Cons(h, t) => f(h, t.foldRight(f)(z)) - } - - def scanLeft[R](z: R)(f: (R,T) => R): List[R] = this match { - case Nil() => z :: Nil[R]() - case Cons(h,t) => z :: t.scanLeft(f(z,h))(f) - } - - def scanRight[R](f: (T,R) => R)(z: R): List[R] = { this match { - case Nil() => z :: Nil[R]() - case Cons(h, t) => - val rest@Cons(h1,_) = t.scanRight(f)(z) - f(h, h1) :: rest - }} ensuring { !_.isEmpty } - - def flatMap[R](f: T => List[R]): List[R] = - ListOps.flatten(this map f) - - def filter(p: T => Boolean): List[T] = { this match { - case Nil() => Nil[T]() - case Cons(h, t) if p(h) => Cons(h, t.filter(p)) - case Cons(_, t) => t.filter(p) - }} ensuring { res => res.size <= this.size && res.forall(p) } - - // In case we implement for-comprehensions - def withFilter(p: T => Boolean) = filter(p) - - def forall(p: T => Boolean): Boolean = this match { - case Nil() => true - case Cons(h, t) => p(h) && t.forall(p) - } - - def exists(p: T => Boolean) = !forall(!p(_)) - - def find(p: T => Boolean): Option[T] = { this match { - case Nil() => None[T]() - case Cons(h, t) if p(h) => Some(h) - case Cons(_, t) => t.find(p) - }} ensuring { _.isDefined == exists(p) } - - // FIXME: I keep getting these weird type errors - //def groupBy[R](f: T => R): Map[R, List[T]] = this match { - // case Nil() => Map.empty[R, List[T]] - // case Cons(h, t) => - // val key: R = f(h) - // val rest: Map[R, List[T]] = t.groupBy(f) - // val prev: List[T] = if (rest isDefinedAt key) rest(key) else Nil[T]() - // (rest ++ Map((key, h :: prev))) : Map[R, List[T]] - //} - - def takeWhile(p: T => Boolean): List[T] = { this match { - case Cons(h,t) if p(h) => Cons(h, t.takeWhile(p)) - case _ => Nil[T]() - }} ensuring { _ forall p } -} - -@ignore -object List { - def apply[T](elems: T*): List[T] = ??? -} - -@library -object ListOps { - def flatten[T](ls: List[List[T]]): List[T] = ls match { - case Cons(h, t) => h ++ flatten(t) - case Nil() => Nil[T]() - } - - def isSorted(ls: List[BigInt]): Boolean = ls match { - case Nil() => true - case Cons(_, Nil()) => true - case Cons(h1, Cons(h2, _)) if(h1 > h2) => false - case Cons(_, t) => isSorted(t) - } - - def sorted(ls: List[BigInt]): List[BigInt] = ls match { - case Cons(h, t) => insSort(sorted(t), h) - case Nil() => Nil() - } - - def insSort(ls: List[BigInt], v: BigInt): List[BigInt] = ls match { - case Nil() => Cons(v, Nil()) - case Cons(h, t) => - if (v <= h) { - Cons(v, t) - } else { - Cons(h, insSort(t, v)) - } - } -} - -case class Cons[T](h: T, t: List[T]) extends List[T] -case class Nil[T]() extends List[T] - -@library -object ListSpecs { - def snocIndex[T](l : List[T], t : T, i : BigInt) : Boolean = { - require(0 <= i && i < l.size + 1) - // proof: - (l match { - case Nil() => true - case Cons(x, xs) => if (i > 0) snocIndex[T](xs, t, i-1) else true - }) && - // claim: - ((l :+ t).apply(i) == (if (i < l.size) l(i) else t)) - }.holds - - def reverseIndex[T](l : List[T], i : BigInt) : Boolean = { - require(0 <= i && i < l.size) - (l match { - case Nil() => true - case Cons(x,xs) => snocIndex(l, x, i) && reverseIndex[T](l,i) - }) && - (l.reverse.apply(i) == l.apply(l.size - 1 - i)) - }.holds - - def appendIndex[T](l1 : List[T], l2 : List[T], i : BigInt) : Boolean = { - require(0 <= i && i < l1.size + l2.size) - (l1 match { - case Nil() => true - case Cons(x,xs) => if (i==BigInt(0)) true else appendIndex[T](xs,l2,i-1) - }) && - ((l1 ++ l2).apply(i) == (if (i < l1.size) l1(i) else l2(i - l1.size))) - }.holds - - def appendAssoc[T](l1 : List[T], l2 : List[T], l3 : List[T]) : Boolean = { - (l1 match { - case Nil() => true - case Cons(x,xs) => appendAssoc(xs,l2,l3) - }) && - (((l1 ++ l2) ++ l3) == (l1 ++ (l2 ++ l3))) - }.holds - - def rightIdAppend[T](l1 : List[T]) : Boolean = { - (l1 match { - case Nil() => true - case Cons(x, xs) => rightIdAppend(xs) - }) && - ((l1 ++ Nil()) == l1) - }.holds - - - def snocIsAppend[T](l : List[T], t : T) : Boolean = { - (l match { - case Nil() => true - case Cons(x,xs) => snocIsAppend(xs,t) - }) && - ((l :+ t) == l ++ Cons[T](t, Nil())) - }.holds - - def snocAfterAppend[T](l1 : List[T], l2 : List[T], t : T) : Boolean = { - (l1 match { - case Nil() => true - case Cons(x,xs) => snocAfterAppend(xs,l2,t) - }) && - ((l1 ++ l2) :+ t == (l1 ++ (l2 :+ t))) - }.holds - - def snocReverse[T](l : List[T], t : T) : Boolean = { - (l match { - case Nil() => true - case Cons(x,xs) => snocReverse(xs,t) - }) && - ((l :+ t).reverse == Cons(t, l.reverse)) - }.holds - - def reverseReverse[T](l : List[T]) : Boolean = { - (l match { - case Nil() => true - case Cons(x,xs) => reverseReverse[T](xs) && snocReverse[T](xs.reverse, x) - }) && - (l.reverse.reverse == l) - }.holds - - def reverseAppend[T](l1 : List[T], l2 : List[T]) : Boolean = { - ((l1 ++ l2).reverse == (l2.reverse ++ l1.reverse)) because { - l1 match { - case Nil() => { - ((Nil() ++ l2).reverse == l2.reverse) && trivial && by { - rightIdAppend(l2.reverse) - } (l2.reverse ++ Nil() == l2.reverse ++ Nil().reverse) - } - case Cons(x, xs) => { - ((l1 ++ l2).reverse == ((x :: xs) ++ l2).reverse) && - (((x :: xs) ++ l2).reverse == (x :: (xs ++ l2)).reverse) && - ((x :: xs) ++ l2) == (x :: (xs ++ l2)) && - ((x :: (xs ++ l2)).reverse == (xs ++ l2).reverse :+ x) && - ((xs ++ l2).reverse :+ x == (l2.reverse ++ xs.reverse) :+ x) && - ((xs ++ l2).reverse == (l2.reverse ++ xs.reverse)) && - reverseAppend(xs, l2) && - ((l2.reverse ++ xs.reverse) :+ x == l2.reverse ++ (xs.reverse :+ x)) && - snocAfterAppend[T](l2.reverse, xs.reverse, x) && - ((xs.reverse :+ x) == l1.reverse) && - (l2.reverse ++ (xs.reverse :+ x) == l2.reverse ++ l1.reverse) - // (x :: xs.reverse) == xs.reverse :+ x - // (x :: xs) ++ that => x :: (xs ++ that) - //((l1 ++ l2).reverse == (l2.reverse ++ l1.reverse)) - } - } - } - }.holds - - //@induct - //def folds[T,R](l : List[T], z : R, f : (R,T) => R) = { - // { l match { - // case Nil() => true - // case Cons(h,t) => snocReverse[T](t, h) - // }} && - // l.foldLeft(z)(f) == l.reverse.foldRight((x:T,y:R) => f(y,x))(z) - //}.holds - // - - //Can't prove this - //@induct - //def scanVsFoldLeft[A,B](l : List[A], z: B, f: (B,A) => B): Boolean = { - // l.scanLeft(z)(f).last == l.foldLeft(z)(f) - //}.holds - - @induct - def scanVsFoldRight[A,B](l: List[A], z: B, f: (A,B) => B): Boolean = { - l.scanRight(f)(z).head == l.foldRight(f)(z) - }.holds - -} - diff --git a/src/test/resources/regression/frontends/passing/Operators.scala b/src/test/resources/regression/frontends/passing/Operators.scala deleted file mode 100644 index ac539056d20d87f64c7775e588e79e43bffe60ca..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/passing/Operators.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Operators { - - case class HasOps(i : Int){ - def + (j : HasOps) = this.i + j.i - } - - def x = HasOps(12) + HasOps(30) - -} \ No newline at end of file diff --git a/src/test/resources/regression/frontends/passing/OptParams.scala b/src/test/resources/regression/frontends/passing/OptParams.scala deleted file mode 100644 index 567cb842d0a1c466f9cd40fb5cbdc3795c5a55a2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/passing/OptParams.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object OptParams { - - def foo( x : Int, y : Int = 12 ) = x + y - - def bar = foo(42) - def baz = foo(1,2) - - - - abstract class Opt { - def opt( o : Opt = OptChild(), i : Int = 0) : Int = i + 1 - def opt2 = opt() - } - case class OptChild() extends Opt -} diff --git a/src/test/resources/regression/frontends/passing/Overrides.scala b/src/test/resources/regression/frontends/passing/Overrides.scala deleted file mode 100644 index 38342ce6ae266c61c97cbeff7a08c71cacbb0239..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/passing/Overrides.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Overrides { - - abstract class A[T] { - def x[A](a: A): (A,T) - } - - abstract class B[R] extends A[R] { - def x[B](b: B) = x(b) - } - - case class C[W](c: W) extends B[W] { - override def x[C](f: C) = (f,c) - } - - case class D[Z]() extends B[Z] -} diff --git a/src/test/resources/regression/frontends/passing/bigintExtr.scala b/src/test/resources/regression/frontends/passing/bigintExtr.scala deleted file mode 100644 index 349b75ec305b9e07908d7a0dcd563b1cb2a98ed1..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/frontends/passing/bigintExtr.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ - -object Test { - def b(b: List[BigInt]) = b match { - case Cons(BigInt(42), Nil()) => true - case _ => false - } -} diff --git a/src/test/resources/regression/genc/invalid/AbsFun.scala b/src/test/resources/regression/genc/invalid/AbsFun.scala deleted file mode 100644 index db7a92312b6ddb52ade465a0b3d03cec6da24805..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/invalid/AbsFun.scala +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object AbsFun { - - - def isPositive(a : Array[Int], size : Int) : Boolean = { - require(a.length >= 0 && size <= a.length) - rec(0, a, size) - } - - def rec(i: Int, a: Array[Int], size: Int) : Boolean = { - require(a.length >= 0 && size <= a.length && i >= 0) - - if(i >= size) true - else { - if (a(i) < 0) - false - else - rec(i + 1, a, size) - } - } - - // Returning Arrays is not supported by GenC - def abs(tab: Array[Int]): Array[Int] = { - require(tab.length >= 0) - val t = while0(Array.fill(tab.length)(0), 0, tab) - t._1 - } ensuring(res => isPositive(res, res.length)) - - - def while0(t: Array[Int], k: Int, tab: Array[Int]): (Array[Int], Int) = { - require(tab.length >= 0 && - t.length == tab.length && - k >= 0 && - k <= tab.length && - isPositive(t, k)) - - if(k < tab.length) { - val nt = if(tab(k) < 0) { - t.updated(k, -tab(k)) - } else { - t.updated(k, tab(k)) - } - while0(nt, k+1, tab) - } else { - (t, k) - } - } ensuring(res => - res._2 >= tab.length && - res._1.length == tab.length && - res._2 >= 0 && - res._2 <= tab.length && - isPositive(res._1, res._2)) - - def property(t: Array[Int], k: Int): Boolean = { - require(isPositive(t, k) && t.length >= 0 && k >= 0) - if(k < t.length) { - val nt = if(t(k) < 0) { - t.updated(k, -t(k)) - } else { - t.updated(k, t(k)) - } - isPositive(nt, k+1) - } else true - } holds -} diff --git a/src/test/resources/regression/genc/invalid/LinearSearch.scala b/src/test/resources/regression/genc/invalid/LinearSearch.scala deleted file mode 100644 index 60e5befe7eba9071cc869799ca488130d3575a11..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/invalid/LinearSearch.scala +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -/* The calculus of Computation textbook */ - -object LinearSearch { - - def linearSearch(a: Array[Int], c: Int): Boolean = ({ - require(a.length >= 0) - var i = 0 - var found = false - (while(i < a.length) { - if(a(i) == c) - found = true - i = i + 1 - }) invariant( - i <= a.length && - i >= 0 && - (if(found) contains(a, i, c) else !contains(a, i, c)) - ) - found - }) ensuring(res => if(res) contains(a, a.length, c) else !contains(a, a.length, c)) - - def contains(a: Array[Int], size: Int, c: Int): Boolean = { - require(a.length >= 0 && size >= 0 && size <= a.length) - content(a, size).contains(c) - } - - // Set not supported by GenC - def content(a: Array[Int], size: Int): Set[Int] = { - require(a.length >= 0 && size >= 0 && size <= a.length) - var set = Set.empty[Int] - var i = 0 - (while(i < size) { - set = set ++ Set(a(i)) - i = i + 1 - }) invariant(i >= 0 && i <= size) - set - } - -} diff --git a/src/test/resources/regression/genc/unverified/BinarySearch.scala b/src/test/resources/regression/genc/unverified/BinarySearch.scala deleted file mode 100644 index 666b98c4e621099bfa9b8ef23485b9764522034b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/unverified/BinarySearch.scala +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -/* VSTTE 2008 - Dafny paper */ - -object BinarySearch { - - def binarySearch(a: Array[Int], key: Int): Int = ({ - require(a.length > 0 && sorted(a, 0, a.length - 1)) - var low = 0 - var high = a.length - 1 - var res = -1 - - (while(low <= high && res == -1) { - //val i = (high + low) / 2 - val i = low + ((high - low) / 2) - val v = a(i) - - if(v == key) - res = i - - if(v > key) - high = i - 1 - else if(v < key) - low = i + 1 - }) invariant( - res >= -1 && - res < a.length && - 0 <= low && - low <= high + 1 && - high >= -1 && - high < a.length && - (if (res >= 0) - a(res) == key else - (!occurs(a, 0, low, key) && !occurs(a, high + 1, a.length, key)) - ) - ) - res - }) ensuring(res => - res >= -1 && - res < a.length && - (if(res >= 0) a(res) == key else !occurs(a, 0, a.length, key))) - - - def occurs(a: Array[Int], from: Int, to: Int, key: Int): Boolean = { - require(a.length >= 0 && to <= a.length && from >= 0) - def rec(i: Int): Boolean = { - require(i >= 0) - if(i >= to) - false - else { - if(a(i) == key) true else rec(i+1) - } - } - if(from >= to) - false - else - rec(from) - } - - - def sorted(a: Array[Int], l: Int, u: Int) : Boolean = { - require(a.length >= 0 && l >= 0 && l <= u && u < a.length) - val t = sortedWhile(true, l, l, u, a) - t._1 - } - - def sortedWhile(isSorted: Boolean, k: Int, l: Int, u: Int, a: Array[Int]): (Boolean, Int) = { - require(a.length >= 0 && l >= 0 && l <= u && u < a.length && k >= l && k <= u) - if(k < u) { - sortedWhile(if(a(k) > a(k + 1)) false else isSorted, k + 1, l, u, a) - } else (isSorted, k) - } - - - def main = { - val a = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - val i = binarySearch(a, 2) - i - 2 // i should be 2 - } - -} - diff --git a/src/test/resources/regression/genc/unverified/BinarySearchFun.scala b/src/test/resources/regression/genc/unverified/BinarySearchFun.scala deleted file mode 100644 index 2e9e95760ccfb213d5f81db13f31a3fd234f45df..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/unverified/BinarySearchFun.scala +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object BinarySearchFun { - - def binarySearch(a: Array[Int], key: Int, low: Int, high: Int): Int = ({ - require(a.length > 0 && sorted(a, low, high) && - 0 <= low && low <= high + 1 && high < a.length - ) - - if (low <= high) { - //val i = (high + low) / 2 - val i = low + (high - low) / 2 - - val v = a(i) - - if (v == key) i - else if (v > key) binarySearch(a, key, low, i - 1) - else binarySearch(a, key, i + 1, high) - } else -1 - }) ensuring(res => - res >= -1 && - res < a.length && ( - if (res >= 0) - a(res) == key - else - (high < 0 || (!occurs(a, low, low + (high - low) / 2, key) && - !occurs(a, low + (high - low) / 2, high, key))) - ) - ) - - - def occurs(a: Array[Int], from: Int, to: Int, key: Int): Boolean = { - require(a.length >= 0 && to <= a.length && from >= 0) - def rec(i: Int): Boolean = { - require(i >= 0) - if (i >= to) - false - else { - if (a(i) == key) true else rec(i+1) - } - } - if (from >= to) - false - else - rec(from) - } - - - def sorted(a: Array[Int], l: Int, u: Int) : Boolean = { - require(a.length >= 0 && l >= 0 && l <= u + 1 && u < a.length) - val t = sortedWhile(true, l, l, u, a) - t._1 - } - - def sortedWhile(isSorted: Boolean, k: Int, l: Int, u: Int, a: Array[Int]): (Boolean, Int) = { - require(a.length >= 0 && l >= 0 && l <= u+1 && u < a.length && k >= l && k <= u + 1) - if(k < u) { - sortedWhile(if(a(k) > a(k + 1)) false else isSorted, k + 1, l, u, a) - } else (isSorted, k) - } - - def main = { - val a = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - val i = binarySearch(a, 2, 0, a.length - 1) // should be 2 - val j = binarySearch(a, 11, 0, a.length - 1) // should be -1 - - (i - 2) + (j + 1) // == 0 - } -} - diff --git a/src/test/resources/regression/genc/unverified/MaxSum.scala b/src/test/resources/regression/genc/unverified/MaxSum.scala deleted file mode 100644 index ce1072948c737555ee78c46ee830372e8f4a8514..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/unverified/MaxSum.scala +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -/* VSTTE 2010 challenge 1 */ - -object MaxSum { - - def maxSum(a: Array[Int]): (Int, Int) = ({ - require(a.length >= 0 && isPositive(a)) - var sum = 0 - var max = 0 - var i = 0 - (while(i < a.length) { - if(max < a(i)) - max = a(i) - sum = sum + a(i) - i = i + 1 - }) invariant (sum <= i * max && i >= 0 && i <= a.length) - (sum, max) - }) ensuring(res => res._1 <= a.length * res._2) - - - def isPositive(a: Array[Int]): Boolean = { - require(a.length >= 0) - def rec(i: Int): Boolean = { - require(i >= 0) - if(i >= a.length) - true - else { - if(a(i) < 0) - false - else - rec(i+1) - } - } - rec(0) - } - - def summ(to : Int): Int = ({ - require(to >= 0) - var i = 0 - var s = 0 - (while (i < to) { - s = s + i - i = i + 1 - }) invariant (s >= 0 && i >= 0 && s == i*(i-1)/2 && i <= to) - s - }) ensuring(res => res >= 0 && res == to*(to-1)/2) - - - def sumsq(to : Int): Int = ({ - require(to >= 0) - var i = 0 - var s = 0 - (while (i < to) { - s = s + i*i - i = i + 1 - }) invariant (s >= 0 && i >= 0 && s == (i-1)*i*(2*i-1)/6 && i <= to) - s - }) ensuring(res => res >= 0 && res == (to-1)*to*(2*to-1)/6) - - def main = { - val a = Array(1, 4, 6, 0, 234, 999) - val sm = maxSum(a) - val sum = sm._1 - val max = sm._2 - if (sum == 1244 && max == 999) 0 - else -1 - } ensuring { _ == 0 } - -} - diff --git a/src/test/resources/regression/genc/valid/AbsArray.scala b/src/test/resources/regression/genc/valid/AbsArray.scala deleted file mode 100644 index a7f25b3bb831ce808d0e97516486aed1d050bfd7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/valid/AbsArray.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object AbsArray { - def main = { - val a = Array(0, -1, 2, -3) - - def abs() { - require(a.length < 10000) - - var i = 0; - (while (i < a.length && i < 10000) { - a(i) = if (a(i) < 0) -a(i) else a(i) - i = i + 1 - }) invariant (i >= 0 && i <= 10000) - } - - abs() - - a(0) + a(1) - 1 + a(2) - 2 + a(3) - 3 // == 0 - } ensuring { _ == 0 } -} - - diff --git a/src/test/resources/regression/genc/valid/CaseClass.scala b/src/test/resources/regression/genc/valid/CaseClass.scala deleted file mode 100644 index 4731fca052e3771c6f8a5b8fe3f0f7e2a8db4b80..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/valid/CaseClass.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object CaseClass { - - case class Color(r: Int, g: Int, b: Int) - - def red = Color(0, 255, 0) - def cyan = Color(0, 255, 255) - - def sub(c: Color, d: Color) = Color(c.r - d.r, c.g - d.g, c.b - d.b) - - def main = { - val c = red - val d = cyan - val z = sub(c, d).g - z - } ensuring { _ == 0 } - -} - diff --git a/src/test/resources/regression/genc/valid/ExpressionOrder.scala b/src/test/resources/regression/genc/valid/ExpressionOrder.scala deleted file mode 100644 index ec81d038a8a1ee8797e7fa09252dc05871e77c59..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/valid/ExpressionOrder.scala +++ /dev/null @@ -1,155 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ExpressionOrder { - case class Pixel(rgb: Int) - case class Matrix(data: Array[Int], w: Int, h: Int) - - def void = () - - def fun = 0xffffff - def foo = 4 - def bar(i: Int) = i * 2 - def baz(i: Int, j: Int) = bar(i) - bar(j) - - def syntaxCheck(i: Int) { - val p = Pixel(fun) - val m = Matrix(Array(0, 1, 2, 3), 2, 2) - - val z = baz(foo, bar(foo)) - val a = Array(0, 1, foo / 2, 3, bar(2), z / 1) - - val t = (true, foo, bar(a(0))) - - val a2 = Array.fill(4)(2) - val a3 = Array.fill(if (i <= 0) 1 else i)(bar(i)) - val b = Array(1, 2, 0) - b(1) = if (bar(b(1)) % 2 == 0) 42 else 58 - - def f1 = (if (i < 0) a else b)(0) - def f2 = (if (i < 0) a else b).length - - //def f3 = (if (i < 0) a else b)(0) = 0 // <- not supported - - val c = (0, true, 2) - val d = (if (i > 0) i else -i, false, 0) - - def f4 = (if (i < 0) d else c)._2 // expression result unused - } - - def main = { - bool2int(test0(false), 1) + - bool2int(test1(42), 2) + - bool2int(test2(58), 4) + - bool2int(test3(false), 8) + - bool2int(test4(false), 16) + - bool2int(test6, 32) + - bool2int(test7, 64) + - bool2int(test8, 128) - } ensuring { _ == 0 } - - def test0(b: Boolean) = { - val f = b && !b // == false - - var c = 0 - - val x = f && { c = 1; true } - - c == 0 - }.holds - - def test1(i: Int) = { - require(i > 0) - - val j = i / i * 3 // == 3 - - var c = 0 - val x = { c = c + 3; j } + { c = c + 1; j } * { c = c * 2; j } - - c == 8 && j == 3 && x == 12 - }.holds - - def test2(i: Int) = { - var c = 0; - val x = if (i < 0) { c = 1; -i } else { c = 2; i } - - if (i < 0) c == 1 - else c == 2 - }.holds - - def test3(b: Boolean) = { - val f = b && !b // == false - - var c = 0 - val x = f || { c = 1; true } || { c = 2; false } - - c == 1 - }.holds - - def test4(b: Boolean) = { - var i = 10 - var c = 0 - - val f = b && !b // == false - val t = b || !b // == true - - // The following condition is executed 11 times, - // and only during the last execution is the last - // operand evaluated - while ({ c = c + 1; t } && i > 0 || { c = c * 2; f }) { - i = i - 1 - } - - i == 0 && c == 22 - }.holds - - def test5(b: Boolean) = { - val f = b && !b // == false - - var c = if (f) 0 else -1 - - c = c + (if (f) 0 else 1) - - c == 0 - }.holds - - def test6 = { - val a = Array(0, 1, 2, 3, 4) - - def rec(b: Boolean, i: Int): Boolean = { - require(i >= 0 && i < 2147483647) // 2^31 - 1 - - if (i + 1 < a.length) rec(if (a(i) < a(i + 1)) b else false, i + 1) - else b - } - - rec(true, 0) - }.holds - - def test7 = { - var c = 1 - - val a = Array(0, 1, 2, 3, 4) - - a(if(a(0) == 0) { c = c + 1; 0 } else { c = c + 2; 1 }) = { c = c * 2; -1 } - - c == 4 - }.holds - - def test8 = { - var x = 0 - - def bar(y: Int) = { - def fun(z: Int) = 1 * x * (y + z) - - fun(3) - } - - bar(2) == 0 - }.holds - - def bool2int(b: Boolean, f: Int) = if (b) 0 else f; -} - - diff --git a/src/test/resources/regression/genc/valid/IntegralColor.scala b/src/test/resources/regression/genc/valid/IntegralColor.scala deleted file mode 100644 index 8c42a620e42d12b6daf85625239dc9074ba67868..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/valid/IntegralColor.scala +++ /dev/null @@ -1,177 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object IntegralColor { - - def isValidComponent(x: Int) = x >= 0 && x <= 255 - - def getRed(rgb: Int): Int = { - (rgb & 0x00FF0000) >> 16 - } ensuring isValidComponent _ - - def getGreen(rgb: Int): Int = { - (rgb & 0x0000FF00) >> 8 - } ensuring isValidComponent _ - - def getBlue(rgb: Int): Int = { - rgb & 0x000000FF - } ensuring isValidComponent _ - - def getGray(rgb: Int): Int = { - (getRed(rgb) + getGreen(rgb) + getBlue(rgb)) / 3 - } ensuring isValidComponent _ - - def testColorSinglePixel: Boolean = { - val color = 0x20C0FF - - 32 == getRed(color) && 192 == getGreen(color) && - 255 == getBlue(color) && 159 == getGray(color) - }.holds - - case class Color(r: Int, g: Int, b: Int) - - def getColor(rgb: Int) = Color(getRed(rgb), getGreen(rgb), getBlue(rgb)) - - /* - *case class Image(width: Int, height: Int, buffer: Array[Int]) { - * // currently not enforced: - * require(width <= 1000 && height <= 1000 && buffer.length == width * height) - *} - */ - - def matches(value: Array[Int], expected: Array[Int]): Boolean = { - require(value.length == expected.length) - - var test = true - var idx = 0 - (while (idx < value.length) { - test = test && value(idx) == expected(idx) - idx = idx + 1 - }) invariant { idx >= 0 && idx <= value.length } - - test - } - - def testColorWholeImage: Boolean = { - val WIDTH = 2 - val HEIGHT = 2 - - /* - *val source = Image(WIDTH, HEIGHT, Array(0x20c0ff, 0x123456, 0xffffff, 0x000000)) - *val expected = Image(WIDTH, HEIGHT, Array(159, 52, 255, 0)) // gray convertion - *val gray = Image(WIDTH, HEIGHT, Array.fill(4)(0)) - */ - - val source = Array(0x20c0ff, 0x123456, 0xffffff, 0x000000) - val expected = Array(159, 52, 255, 0) // gray convertion - val gray = Array.fill(4)(0) - - // NOTE: Cannot define a toGray function as XLang doesn't allow mutating - // arguments and GenC doesn't allow returning arrays - - var idx = 0 - (while (idx < WIDTH * HEIGHT) { - gray(idx) = getGray(source(idx)) - idx = idx + 1 - }) invariant { idx >= 0 && idx <= WIDTH * HEIGHT && gray.length == WIDTH * HEIGHT } - // NB: the last invariant is very important -- without it the verification times out - - matches(gray, expected) - }.holds - - // Only for square kernels - case class Kernel(size: Int, buffer: Array[Int]) - - def isKernelValid(kernel: Kernel): Boolean = - kernel.size > 0 && kernel.size < 1000 && kernel.size % 2 == 1 && - kernel.buffer.length == kernel.size * kernel.size - - def applyFilter(gray: Array[Int], size: Int, idx: Int, kernel: Kernel): Int = { - require(size > 0 && size < 1000 && - gray.length == size * size && - idx >= 0 && idx < gray.length && - isKernelValid(kernel)) - - def up(x: Int): Int = { - if (x < 0) 0 else x - } ensuring { _ >= 0 } - - def down(x: Int): Int = { - if (x >= size) size - 1 else x - } ensuring { _ < size } - - def fix(x: Int): Int = { - down(up(x)) - } ensuring { res => res >= 0 && res < size } - - def at(row: Int, col: Int): Int = { - val r = fix(row) - val c = fix(col) - - gray(r * size + c) - } - - val mid = kernel.size / 2 - - val i = idx / size - val j = idx % size - - var res = 0 - var p = -mid - (while (p <= mid) { - var q = -mid - - (while (q <= mid) { - val krow = p + mid - val kcol = q + mid - - assert(krow >= 0 && krow < kernel.size) - assert(kcol >= 0 && kcol < kernel.size) - - val kidx = krow * kernel.size + kcol - - res += at(i + p, j + q) * kernel.buffer(kidx) - - q = q + 1 - }) invariant { q >= -mid && q <= mid + 1 } - - p = p + 1 - }) invariant { p >= -mid && p <= mid + 1 } - - res - } - - def testFilterConvolutionSmooth: Boolean = { - val gray = Array(127, 255, 51, 0) - val expected = Array(124, 158, 76, 73) - val size = 2 // grey is size x size - - // NOTE: Cannot define a `smoothed` function as XLang doesn't allow mutating - // arguments and GenC doesn't allow returning arrays - - val kernel = Kernel(3, Array(1, 1, 1, - 1, 2, 1, - 1, 1, 1)) - - val smoothed = Array.fill(gray.length)(0) - assert(smoothed.length == expected.length) - - var idx = 0; - (while (idx < smoothed.length) { - smoothed(idx) = applyFilter(gray, size, idx, kernel) / 10 - idx = idx + 1 - }) invariant { idx >= 0 && idx <= smoothed.length && smoothed.length == gray.length } - - matches(smoothed, expected) - }.holds - - - def main: Int = { - if (testColorSinglePixel && testColorWholeImage && testFilterConvolutionSmooth) 0 - else 1 - } ensuring { _ == 0 } - -} - - diff --git a/src/test/resources/regression/genc/valid/RecursionAndNestedFunctions.scala b/src/test/resources/regression/genc/valid/RecursionAndNestedFunctions.scala deleted file mode 100644 index 0202fae1eaea30d0a550a4a9679e5d6b6f5b8902..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/valid/RecursionAndNestedFunctions.scala +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object RecursionAndNestedFunctions { - - // Complex way to return i - def zzz(i: Int): Int = { - val x = 0 - - def rec(j: Int): Int = { - if (i - x == j) i - else if (j > i) rec(j - 1) - else rec(j + 1) - } ensuring { _ == i } - - rec(4) - } ensuring { _ == i } - - - // Complex way to compute 100 + 2 * i - def foo(i: Int) = { - var j = i - def bar(x: Int) = { - //j = j - 1 <- not supported by leon - val y = x + i - def baz(z: Int) = z + y + i - //j = j + 1 <- not supported by leon - baz(42) - } - bar(58) + j - i - } ensuring { _ == 100 + 2 * i } - - def main() = { - foo(2) - zzz(104) - } ensuring { _ == 0 } - -} - diff --git a/src/test/resources/regression/genc/valid/TupleArray.scala b/src/test/resources/regression/genc/valid/TupleArray.scala deleted file mode 100644 index c5ad57f1bb43ec9a42fc09a69895d5461994c20e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/genc/valid/TupleArray.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object TupleArray { - def exists(av: (Array[Int], Int)): Boolean = { - require(av._1.length < 10000) - - var i = 0 - var found = false - (while (!found && i < av._1.length) { - found = av._1(i) == av._2 - i = i + 1 - }) invariant (i >= 0 && i < 10000) - found - } - - def main = { - val a = Array(0, 1, 5, -5, 9) - val e1 = exists((a, 0)) - val e2 = exists((a, -1)) - if (e1 && !e2) 0 - else -1 - } ensuring { _ == 0 } - -} - diff --git a/src/test/resources/regression/orb/combined/InsertionSort.scala b/src/test/resources/regression/orb/combined/InsertionSort.scala deleted file mode 100644 index 8f0d34367af1e60a78e20e20e6f8bf271f98aaf7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/combined/InsertionSort.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ -import leon.instrumentation._ - -object InsertionSort { - sealed abstract class List - case class Cons(head: BigInt, tail:List) extends List - case class Nil() extends List - - def size(l : List) : BigInt = (l match { - case Cons(_, xs) => 1 + size(xs) - case _ => 0 - }) - - def sortedIns(e: BigInt, l: List): List = { - l match { - case Cons(x,xs) => if (x <= e) Cons(x,sortedIns(e, xs)) else Cons(e, l) - case _ => Cons(e,Nil()) - } - } ensuring(res => size(res) == size(l) + 1 && tmpl((a,b) => time <= a*size(l) +b && depth <= a*size(l) +b)) - - def sort(l: List): List = (l match { - case Cons(x,xs) => sortedIns(x, sort(xs)) - case _ => Nil() - - }) ensuring(res => size(res) == size(l) && tmpl((a,b) => time <= a*(size(l)*size(l)) +b && rec <= a*size(l) + b)) -} diff --git a/src/test/resources/regression/orb/depth/BinaryTrie.scala b/src/test/resources/regression/orb/depth/BinaryTrie.scala deleted file mode 100644 index c71939f3b1bacb7c2ab1d735082d7236cfa6f22f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/depth/BinaryTrie.scala +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.instrumentation._ -import leon.invariant._ - -import scala.collection.immutable.Set - -object ParallelBinaryTrie { - sealed abstract class Tree - case class Leaf() extends Tree - case class Node(nvalue: BigInt, left: Tree, right: Tree) extends Tree - - sealed abstract class IList - case class Cons(head: BigInt, tail: IList) extends IList - case class Nil() extends IList - - def listSize(l: IList): BigInt = (l match { - case Nil() => 0 - case Cons(x, xs) => 1 + listSize(xs) - }) - - def height(t: Tree): BigInt = { - t match { - case Leaf() => 0 - case Node(x, l, r) => { - val hl = height(l) - val hr = height(r) - if (hl > hr) hl + 1 else hr + 1 - } - } - } - - def find(inp: IList, t: Tree): Tree = { - inp match { - case Nil() => t - case Cons(x, Nil()) => t - case Cons(x, xs @ Cons(y, _)) => { - t match { - case Leaf() => t - case Node(v, l, r) => { - if (y > 0) find(xs, l) else find(xs, r) - } - } - } - case _ => t - } - } ensuring (res => true && tmpl ((a, c) => depth <= a * listSize(inp) + c)) - - def insert(inp: IList, t: Tree): Tree = { - t match { - case Leaf() => { - inp match { - case Nil() => t - case Cons(x, xs) => { - val newch = insert(xs, Leaf()) - newch match { - case Leaf() => Node(x, Leaf(), Leaf()) - case Node(y, _, _) => if (y > 0) Node(x, newch, Leaf()) else Node(y, Leaf(), newch) - } - } - } - - } - case Node(v, l, r) => { - inp match { - case Nil() => t - case Cons(x, Nil()) => t - case Cons(x, xs @ Cons(y, _)) => { - val ch = if (y > 0) l else r - if (y > 0) - Node(v, insert(xs, ch), r) - else - Node(v, l, insert(xs, ch)) - } - case _ => t - } - } - } - } ensuring (res => true && tmpl ((a, c) => depth <= a * listSize(inp) + c)) - - def create(inp: IList): Tree = { - insert(inp, Leaf()) - } ensuring (res => true && tmpl ((a, c) => depth <= a * listSize(inp) + c)) - - def delete(inp: IList, t: Tree): Tree = { - t match { - case Leaf() => { - inp match { - case Nil() => Leaf() - case Cons(x ,xs) => { - //the input is not in the tree, so do nothing - Leaf() - } - } - } - case Node(v, l, r) => { - inp match { - case Nil() => { - //the tree has extensions of the input list so do nothing - t - } - case Cons(x, Nil()) => { - //if "l" and "r" are nil, remove the node - if(l == Leaf() && r == Leaf()) Leaf() - else t - } - case Cons(x ,xs@Cons(y, _)) => { - val ch = if(y > 0) l else r - val newch = delete(xs, ch) - if(newch == Leaf() && ((y > 0 && r == Leaf()) || (y <= 0 && l == Leaf()))) Leaf() - else { - if(y > 0) - Node(v, newch, r) - else - Node(v, l, newch) - } - } - case _ => t - } - } - } - } ensuring (res => true && tmpl ((a, c) => depth <= a * listSize(inp) + c)) -} diff --git a/src/test/resources/regression/orb/depth/Folds.scala b/src/test/resources/regression/orb/depth/Folds.scala deleted file mode 100644 index b80235514595a6d08fbaff427493a434d5e32749..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/depth/Folds.scala +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.instrumentation._ -import leon.invariant._ - - -object TreeMaps { - - sealed abstract class Tree - case class Node(left: Tree, value: BigInt, right: Tree) extends Tree - case class Leaf() extends Tree - - def height(t: Tree): BigInt = { - t match { - case Leaf() => 0 - case Node(l, x, r) => { - val hl = height(l) - val hr = height(r) - if (hl > hr) hl + 1 else hr + 1 - } - } - } - - def parallelSearch(elem : BigInt, t : Tree) : Boolean = { - t match { - case Leaf() => false - case Node(l, x, r) => - if(x == elem) true - else { - val r1 = parallelSearch(elem, r) - val r2 = parallelSearch(elem, l) - if(r1 || r2) true - else false - } - } - } ensuring(res => true && tmpl((a,b) => depth <= a*height(t) + b)) - - - def squareMap(t : Tree) : Tree = { - t match { - case Leaf() => t - case Node(l, x, r) => - val nl = squareMap(l) - val nr = squareMap(r) - Node(nl, x*x, nr) - } - } ensuring (res => true && tmpl((a,b) => depth <= a*height(t) + b)) - - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def size(l: List): BigInt = (l match { - case Nil() => 0 - case Cons(_, t) => 1 + size(t) - }) - - def fact(n : BigInt) : BigInt = { - require(n >= 0) - - if(n == 1 || n == 0) BigInt(1) - else n * fact(n-1) - - } ensuring(res => tmpl((a,b) => depth <= a*n + b)) - - def descending(l: List, k: BigInt) : Boolean = { - l match { - case Nil() => true - case Cons(x, t) => x > 0 && x <= k && descending(t, x-1) - } - } - - def factMap(l: List, k: BigInt): List = { - require(descending(l, k) && k >= 0) - - l match { - case Nil() => Nil() - case Cons(x, t) => { - val f = fact(x) - Cons(f, factMap(t, x-1)) - } - - }} ensuring(res => true && tmpl((a,b) => depth <= a*k + b)) -} \ No newline at end of file diff --git a/src/test/resources/regression/orb/depth/ListOperations.scala b/src/test/resources/regression/orb/depth/ListOperations.scala deleted file mode 100644 index b9c9418de08ff0fa4d5b740d71d825aade3129dc..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/depth/ListOperations.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.instrumentation._ -import leon.invariant._ -import leon.annotation._ - -object ListOperations { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def size(l: List): BigInt = (l match { - case Nil() => 0 - case Cons(_, t) => 1 + size(t) - }) - - def append(l1: List, l2: List): List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => Cons(x, append(xs, l2)) - - }) ensuring (res => size(l1) + size(l2) == size(res) && tmpl((a,b) => depth <= a*size(l1) + b)) - - def reverseRec(l1: List, l2: List): List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => reverseRec(xs, Cons(x, l2)) - - }) ensuring (res => size(l1) + size(l2) == size(res) && tmpl((a,b) => depth <= a*size(l1) + b)) - - def reverse(l: List): List = { - reverseRec(l, Nil()) - - } ensuring (res => size(l) == size(res) && tmpl((a,b) => depth <= a*size(l) + b)) - - def remove(elem: BigInt, l: List): List = { - l match { - case Nil() => Nil() - case Cons(hd, tl) => if (hd == elem) remove(elem, tl) else Cons(hd, remove(elem, tl)) - } - } ensuring (res => size(l) >= size(res) && tmpl((a,b) => depth <= a*size(l) + b)) - - def contains(list: List, elem: BigInt): Boolean = (list match { - case Nil() => false - case Cons(x, xs) => x == elem || contains(xs, elem) - - }) ensuring (res => true && tmpl((a,b) => depth <= a*size(list) + b)) -} diff --git a/src/test/resources/regression/orb/depth/PropLogicDepth.scala b/src/test/resources/regression/orb/depth/PropLogicDepth.scala deleted file mode 100644 index 8470737ba091be527a12d9cbf7f0a71e12e78475..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/depth/PropLogicDepth.scala +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import scala.collection.immutable.Set -import leon.instrumentation._ -import leon.invariant._ -import leon.annotation._ - -object PropLogicDepth { - - sealed abstract class Formula - case class And(lhs: Formula, rhs: Formula) extends Formula - case class Or(lhs: Formula, rhs: Formula) extends Formula - case class Implies(lhs: Formula, rhs: Formula) extends Formula - case class Not(f: Formula) extends Formula - case class Literal(id: BigInt) extends Formula - case class True() extends Formula - case class False() extends Formula - - def max(x: BigInt,y: BigInt) = if (x >= y) x else y - - def nestingDepth(f: Formula) : BigInt = (f match { - case And(lhs, rhs) => max(nestingDepth(lhs),nestingDepth(rhs)) + 1 - case Or(lhs, rhs) => max(nestingDepth(lhs),nestingDepth(rhs)) + 1 - case Implies(lhs, rhs) => max(nestingDepth(lhs),nestingDepth(rhs)) + 1 - case Not(f) => nestingDepth(f) + 1 - case _ => 1 - }) - - def removeImplies(f: Formula): Formula = (f match { - case And(lhs, rhs) => And(removeImplies(lhs), removeImplies(rhs)) - case Or(lhs, rhs) => Or(removeImplies(lhs), removeImplies(rhs)) - case Implies(lhs, rhs) => Or(Not(removeImplies(lhs)),removeImplies(rhs)) - case Not(f) => Not(removeImplies(f)) - case _ => f - - }) ensuring((res) => true && tmpl((a,b) => depth <= a*nestingDepth(f) + b)) - - def nnf(formula: Formula): Formula = (formula match { - case And(lhs, rhs) => And(nnf(lhs), nnf(rhs)) - case Or(lhs, rhs) => Or(nnf(lhs), nnf(rhs)) - case Implies(lhs, rhs) => Implies(nnf(lhs), nnf(rhs)) - case Not(And(lhs, rhs)) => Or(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Or(lhs, rhs)) => And(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Implies(lhs, rhs)) => And(nnf(lhs), nnf(Not(rhs))) - case Not(Not(f)) => nnf(f) - case Not(Literal(_)) => formula - case Literal(_) => formula - case Not(True()) => False() - case Not(False()) => True() - case _ => formula - }) ensuring((res) => true && tmpl((a,b) => depth <= a*nestingDepth(formula) + b)) - - def isNNF(f: Formula): Boolean = { f match { - case And(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Or(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Implies(lhs, rhs) => false - case Not(Literal(_)) => true - case Not(_) => false - case _ => true - }} ensuring((res) => true && tmpl((a,b) => depth <= a*nestingDepth(f) + b)) - - def simplify(f: Formula): Formula = (f match { - case And(lhs, rhs) => { - val sl = simplify(lhs) - val sr = simplify(rhs) - - //if lhs or rhs is false, return false - //if lhs is true return rhs - //if rhs is true return lhs - (sl,sr) match { - case (False(), _) => False() - case (_, False()) => False() - case (True(), _) => sr - case (_, True()) => sl - case _ => And(sl, sr) - } - } - case Or(lhs, rhs) => { - val sl = simplify(lhs) - val sr = simplify(rhs) - - //if lhs or rhs is true, return true - //if lhs is false return rhs - //if rhs is false return lhs - (sl,sr) match { - case (True(), _) => True() - case (_, True()) => True() - case (False(), _) => sr - case (_, False()) => sl - case _ => Or(sl, sr) - } - } - case Implies(lhs, rhs) => { - val sl = simplify(lhs) - val sr = simplify(rhs) - - //if lhs is false return true - //if rhs is true return true - //if lhs is true return rhs - //if rhs is false return Not(rhs) - (sl,sr) match { - case (False(), _) => True() - case (_, True()) => True() - case (True(), _) => sr - case (_, False()) => Not(sl) - case _ => Implies(sl, sr) - } - } - case Not(True()) => False() - case Not(False()) => True() - case _ => f - - }) ensuring((res) => true && tmpl((a,b) => depth <= a*nestingDepth(f) + b)) -} \ No newline at end of file diff --git a/src/test/resources/regression/orb/lazy/withconst/SortingnConcat.scala b/src/test/resources/regression/orb/lazy/withconst/SortingnConcat.scala deleted file mode 100644 index 1899c30b673fa05b6529f141f5bad58d81e2613c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/lazy/withconst/SortingnConcat.scala +++ /dev/null @@ -1,82 +0,0 @@ -import leon._ -import lazyeval._ -import lang._ -import annotation._ -import instrumentation._ - -object SortingnConcat { - - sealed abstract class LList { - def size: BigInt = { - this match { - case SNil() => BigInt(0) - case SCons(x, t) => 1 + ssize(t) - } - } ensuring (_ >= 0) - } - case class SCons(x: BigInt, tail: Lazy[LList]) extends LList - case class SNil() extends LList - def ssize(l: Lazy[LList]): BigInt = (l*).size - - sealed abstract class List { - def size: BigInt = this match { - case Cons(_, xs) => 1 + xs.size - case _ => BigInt(0) - } - } - case class Cons(x: BigInt, tail: List) extends List - case class Nil() extends List - - def pullMin(l: List): List = { - l match { - case Nil() => l - case Cons(x, xs) => - pullMin(xs) match { - case Nil() => Cons(x, Nil()) - case nxs @ Cons(y, ys) => - if (x <= y) Cons(x, nxs) - else Cons(y, Cons(x, ys)) - } - } - } ensuring (res => res.size == l.size && time <= 15 * l.size + 2) - - def sort(l: List): LList = { - pullMin(l) match { - case Cons(x, xs) => - // here, x is the minimum - SCons(x, $(sort(xs))) // sorts lazily only if needed - case _ => - SNil() - } - } ensuring (res => res.size == l.size && time <= 15 * l.size + 20) - - def concat(l1: List, l2: LList) : LList = { - l1 match { - case Cons(x, xs) => SCons(x, $(concat(xs, l2))) - case Nil() => SNil() - } - } ensuring(res => time <= 15) - - def secondMin(l: Lazy[LList]) : BigInt = { - l.value match { - case SCons(x, xs) => - xs.value match { - case SCons(y, ys) => y - case SNil() => x - } - case SNil() => BigInt(0) - } - } ensuring (_ => time <= 30 * ssize(l) + 40) - - /* Orb can prove this - * def kthMin(l: Lazy[LList], k: BigInt): BigInt = { - require(k >= 1) - l.value match { - case SCons(x, xs) => - if (k == 1) x - else - kthMin(xs, k - 1) - case SNil() => BigInt(0) // None[BigInt] - } - } ensuring (_ => time <= 15 * k * ssize(l) + 20 * k + 20)*/ -} diff --git a/src/test/resources/regression/orb/lazy/withconst/WeightedScheduling.scala b/src/test/resources/regression/orb/lazy/withconst/WeightedScheduling.scala deleted file mode 100644 index e640bd79e7fa7950e5b3dd01389c4bd84f734045..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/lazy/withconst/WeightedScheduling.scala +++ /dev/null @@ -1,104 +0,0 @@ -import leon._ -import leon.mem._ -import leon.lang._ -import leon.annotation._ -import leon.instrumentation._ -//import leon.invariant._ - -object WeightedSched { - sealed abstract class IList { - def size: BigInt = { - this match { - case Cons(_, tail) => 1 + tail.size - case Nil() => BigInt(0) - } - } ensuring(_ >= 0) - } - case class Cons(x: BigInt, tail: IList) extends IList - case class Nil() extends IList - - /** - * array of jobs - * (a) each job has a start time, finish time, and weight - * (b) Jobs are sorted in ascending order of finish times - */ - @ignore - var jobs = Array[(BigInt, BigInt, BigInt)]() - - /** - * A precomputed mapping from each job i to the previous job j it is compatible with. - */ - @ignore - var p = Array[Int]() - - @extern - def jobInfo(i: BigInt) = { - jobs(i.toInt) - } ensuring(_ => time <= 1) - - @extern - def prevCompatibleJob(i: BigInt) = { - BigInt(p(i.toInt)) - } ensuring(res => res >=0 && res < i && time <= 1) - - @inline - def max(x: BigInt, y: BigInt) = if (x >= y) x else y - - def depsEval(i: BigInt) = i == 0 || (i > 0 && allEval(i-1)) - - def allEval(i: BigInt): Boolean = { - require(i >= 0) - sched(i).isCached && - (if (i == 0) true - else allEval(i - 1)) - } - - @traceInduct - def evalMono(i: BigInt, st1: Set[Mem[BigInt]], st2: Set[Mem[BigInt]]) = { - require(i >= 0) - (st1.subsetOf(st2) && (allEval(i) withState st1)) ==> (allEval(i) withState st2) - } holds - - @traceInduct - def evalLem(x: BigInt, y: BigInt) = { - require(x >= 0 && y >= 0) - (x <= y && allEval(y)) ==> allEval(x) - } holds - - @invstate - @memoize - def sched(jobIndex: BigInt): BigInt = { - require(depsEval(jobIndex) && - (jobIndex == 0 || evalLem(prevCompatibleJob(jobIndex), jobIndex-1))) - val (st, fn, w) = jobInfo(jobIndex) - if(jobIndex == 0) w - else { - // we may either include the head job or not: - // if we include the head job, we have to skip every job that overlaps with it - val tailValue = sched(jobIndex - 1) - val prevCompatVal = sched(prevCompatibleJob(jobIndex)) - max(w + prevCompatVal, tailValue) - } - } ensuring(_ => time <= 100) - - def invoke(jobIndex: BigInt) = { - require(depsEval(jobIndex)) - sched(jobIndex) - } ensuring (res => { - val in = inState[BigInt] - val out = outState[BigInt] - (jobIndex == 0 || evalMono(jobIndex-1, in, out)) && - time <= 150 - }) - - def schedBU(jobi: BigInt): IList = { - require(jobi >= 0) - if(jobi == 0) { - Cons(invoke(jobi), Nil()) - } else { - val tailRes = schedBU(jobi-1) - Cons(invoke(jobi), tailRes) - } - } ensuring(_ => allEval(jobi) && - time <= 200 * (jobi + 1)) -} diff --git a/src/test/resources/regression/orb/lazy/withorb/Concat.scala b/src/test/resources/regression/orb/lazy/withorb/Concat.scala deleted file mode 100644 index b9653b5224a19298684e39bb6e3de401815cb40b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/lazy/withorb/Concat.scala +++ /dev/null @@ -1,77 +0,0 @@ -package withOrb - -import leon._ -import lazyeval._ -import lazyeval.Lazy._ -import lang._ -import annotation._ -import instrumentation._ -import collection._ -import invariant._ - -object Concat { - sealed abstract class LList[T] { - def size: BigInt = { - this match { - case SNil() => BigInt(0) - case SCons(x, t) => 1 + ssize(t) - } - } ensuring (_ >= 0) - } - case class SCons[T](x: T, tail: Lazy[LList[T]]) extends LList[T] - case class SNil[T]() extends LList[T] - def ssize[T](l: Lazy[LList[T]]): BigInt = (l*).size - - def concat[T](l1: List[T], l2: List[T]): LList[T] = { - l1 match { - case Cons(x, xs) => SCons(x, $(concat(xs, l2))) - case Nil() => SNil[T]() - } - } ensuring { _ => time <= ? } - - def kthElem[T](l: Lazy[LList[T]], k: BigInt): Option[T] = { - require(k >= 0) - l.value match { - case SCons(x, xs) => - if (k == 0) Some(x) - else - kthElem(xs, k - 1) - case SNil() => None[T] - } - } ensuring (_ => time <= ? * k + ?) - - def concatnSelect[T](l1: List[T], l2: List[T], k: BigInt): Option[T] = { - require(k >= 0) - kthElem($(concat(l1, l2)), k) - } ensuring (_ => time <= ? * k + ?) - - @ignore - def main(args: Array[String]) = { - import stats._ - println("Running concat test...") - val length = 1000000 - val k = 10 - val iterCount = 10 - val l1 = (0 until length).foldRight(List[BigInt]()) { - case (i, acc) => i :: acc - } - val l2 = (0 until length).foldRight(List[BigInt]()) { - case (i, acc) => 2 * i :: acc - } - println("Created inputs, starting operations...") - def iterate[T](op: => BigInt) = { - var res = BigInt(0) - var i = iterCount - while (i > 0) { - res = op - i -= 1 - } - res - } - val elem1 = timed { iterate((l1 ++ l2)(k)) } { t => println(s"Eager Concat completed in ${t / 1000.0} sec") } - println(s"$k th element of concatenated list: $elem1") - val elem2 = timed { iterate(concatnSelect(l1, l2, k).get) } { t => println(s"Lazy ConcatnSelect completed in ${t / 1000.0} sec") } - println(s"$k th element of concatenated list: $elem2") - assert(elem1 == elem2) - } -} diff --git a/src/test/resources/regression/orb/lazy/withorb/SortingnConcat.scala b/src/test/resources/regression/orb/lazy/withorb/SortingnConcat.scala deleted file mode 100644 index 0f4c1151b72c4559be6a11c29aa7d854d881a28c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/lazy/withorb/SortingnConcat.scala +++ /dev/null @@ -1,74 +0,0 @@ -package withOrb - -import leon._ -import lazyeval._ -import lang._ -import annotation._ -import instrumentation._ -import invariant._ - -object SortingnConcat { - - // TODO: making this parametric will break many things. Fix them - sealed abstract class LList { - def size: BigInt = { - this match { - case SNil() => BigInt(0) - case SCons(x, t) => 1 + ssize(t) - } - } ensuring (_ >= 0) - } - case class SCons(x: BigInt, tail: Lazy[LList]) extends LList - case class SNil() extends LList - def ssize(l: Lazy[LList]): BigInt = (l*).size - - sealed abstract class List { - def size: BigInt = this match { - case Cons(_, xs) => 1 + xs.size - case _ => BigInt(0) - } - } - case class Cons(x: BigInt, tail: List) extends List - case class Nil() extends List - - def pullMin(l: List): List = { - l match { - case Nil() => l - case Cons(x, xs) => - pullMin(xs) match { - case Nil() => Cons(x, Nil()) - case nxs @ Cons(y, ys) => - if (x <= y) Cons(x, nxs) - else Cons(y, Cons(x, ys)) - } - } - } ensuring (res => res.size == l.size && time <= ? * l.size + ?) - - def sort(l: List): LList = { - pullMin(l) match { - case Cons(x, xs) => - // here, x is the minimum - SCons(x, $(sort(xs))) // sorts lazily only if needed - case _ => - SNil() - } - } ensuring (res => res.size == l.size && time <= ? * l.size + ?) - - def concat(l1: List, l2: LList) : LList = { - l1 match { - case Cons(x, xs) => SCons(x, $(concat(xs, l2))) - case Nil() => SNil() - } - } ensuring(res => time <= ?) - - def kthMin(l: Lazy[LList], k: BigInt): BigInt = { - require(k >= 1) - l.value match { - case SCons(x, xs) => - if (k == 1) x - else - kthMin(xs, k - 1) - case SNil() => BigInt(0) - } - } ensuring (_ => time <= ? * (k * ssize(l)) + ? * k + ?) -} diff --git a/src/test/resources/regression/orb/lazy/withorb/WeightedScheduling.scala b/src/test/resources/regression/orb/lazy/withorb/WeightedScheduling.scala deleted file mode 100644 index fc254279b27b8e7c0596deb1a4a3c276341a9333..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/lazy/withorb/WeightedScheduling.scala +++ /dev/null @@ -1,133 +0,0 @@ -package orb - -import leon._ -import mem._ -import lang._ -import annotation._ -import instrumentation._ -import invariant._ - -object WeightedSched { - sealed abstract class IList { - def size: BigInt = { - this match { - case Cons(_, tail) => 1 + tail.size - case Nil() => BigInt(0) - } - } ensuring (_ >= 0) - } - case class Cons(x: BigInt, tail: IList) extends IList - case class Nil() extends IList - - /** - * array of jobs - * (a) each job has a start time, finish time, and weight - * (b) Jobs are sorted in ascending order of finish times - * The first job should be (0,0,0) so that it acts as sentinel of every other job - */ - @ignore - var jobs = Array[(BigInt, BigInt, BigInt)]() - - /** - * A precomputed mapping from each job i to the previous job j it is compatible with. - * The value of the first index could be anything. - */ - @ignore - var p = Array[Int]() - - @extern - def jobInfo(i: BigInt) = { - jobs(i.toInt) - } ensuring (_ => time <= 1) - - @extern - def prevCompatibleJob(i: BigInt) = { - BigInt(p(i.toInt)) - } ensuring (res => res >= 0 && res < i && time <= 1) - - @inline - def max(x: BigInt, y: BigInt) = if (x >= y) x else y - - def depsEval(i: BigInt) = i == 0 || (i > 0 && allEval(i - 1)) - - def allEval(i: BigInt): Boolean = { - require(i >= 0) - sched(i).isCached && - (if (i == 0) true - else allEval(i - 1)) - } - - @traceInduct - def evalMono(i: BigInt, st1: Set[Mem[BigInt]], st2: Set[Mem[BigInt]]) = { - require(i >= 0) - (st1.subsetOf(st2) && (allEval(i) withState st1)) ==> (allEval(i) withState st2) - } holds - - @traceInduct - def evalLem(x: BigInt, y: BigInt) = { - require(x >= 0 && y >= 0) - (x <= y && allEval(y)) ==> allEval(x) - } holds - - @invisibleBody - @invstate - @memoize - def sched(jobIndex: BigInt): BigInt = { - require(depsEval(jobIndex) && - (jobIndex == 0 || evalLem(prevCompatibleJob(jobIndex), jobIndex - 1))) - val (st, fn, w) = jobInfo(jobIndex) - if (jobIndex == 0) w - else { - // we may either include the head job or not: - // if we include the head job, we have to skip every job that overlaps with it - val tailValue = sched(jobIndex - 1) - val prevCompatVal = sched(prevCompatibleJob(jobIndex)) - max(w + prevCompatVal, tailValue) - } - } ensuring (_ => time <= ?) - - @invisibleBody - def invoke(jobIndex: BigInt) = { - require(depsEval(jobIndex)) - sched(jobIndex) - } ensuring (res => { - val in = inState[BigInt] - val out = outState[BigInt] - (jobIndex == 0 || evalMono(jobIndex - 1, in, out)) && - time <= ? - }) - - @invisibleBody - def schedBU(jobi: BigInt): IList = { - require(jobi >= 0) - if (jobi == 0) { - Cons(invoke(jobi), Nil()) - } else { - val tailRes = schedBU(jobi - 1) - Cons(invoke(jobi), tailRes) - } - } ensuring (_ => allEval(jobi) && - time <= ? * (jobi + 1)) - - @ignore - def main(args: Array[String]) { - // note: we can run only one test in each run as the cache needs to be cleared between the tests, - // which is not currently supported by the api's (note: the methods access a mutable field) - test1() - //test2() - } - - @ignore - def test1() { - jobs = Array((0, 0, 0), (1, 2, 5), (3, 4, 2), (3, 8, 5), (6, 7, 10), (8, 11, 11), (10, 13, 20)) - p = Array(0 /* anything */ , 0, 1, 1, 2, 4, 4) - println("Schedule for 5 jobs of set 1: " + schedBU(6)) - } - - @ignore - def test2() { - jobs = Array((0, 0, 0), (1, 3, 5), (3, 4, 2), (3, 8, 5), (6, 7, 10), (8, 11, 11), (10, 13, 20)) - p = Array(0 /* anything */ , 0, 0, 0, 2, 4, 4) - println("Schedule for 5 jobs of set 2: " + schedBU(6)) - } -} diff --git a/src/test/resources/regression/orb/numerical/ConcatVariationsAbs.scala b/src/test/resources/regression/orb/numerical/ConcatVariationsAbs.scala deleted file mode 100644 index 4c8c16722378c8f1e44aa3148aa83cbb33abdea3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/numerical/ConcatVariationsAbs.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ - -object ConcatVariationsAbs { - def genL(n: BigInt): BigInt = { - require(n >= 0) - if (n == 0) - BigInt(2) - else - 4 + genL(n - 1) - } ensuring (res => tmpl((a, b) => res <= a * n + b)) - - def append(l1: BigInt, l2: BigInt): BigInt = { - require(l1 >= 0 && l2 >= 0) - if (l1 == 0) - BigInt(3) - else - append(l1 - 1, l2 + 1) + 5 - } ensuring (res => tmpl((a, b) => res <= a * l1 + b)) - - def f_good(m: BigInt, n: BigInt): BigInt = { - require(0 <= m && 0 <= n) - if (m == 0) BigInt(2) - else { - val t1 = genL(n) - val t2 = f_good(m - 1, n) - val t3 = append(n, n * (m - 1)) - (t1 + t2 + t3 + 6) - } - - } ensuring (res => tmpl((a, b, c, d) => res <= a * (n * m) + b * n + c * m + d)) - - def f_worst(m: BigInt, n: BigInt): BigInt = { - require(0 <= m && 0 <= n) - if (m == 0) BigInt(2) - else { - val t1 = genL(n) - val t2 = f_worst(m - 1, n) - val t3 = append(n * (m - 1), n) - (t1 + t2 + t3 + 6) - } - - } ensuring (res => tmpl((a, c, d, e, f) => res <= a * ((n * m) * m) + c * (n * m) + d * n + e * m + f)) -} diff --git a/src/test/resources/regression/orb/numerical/QueueAbs.scala b/src/test/resources/regression/orb/numerical/QueueAbs.scala deleted file mode 100644 index caaae2d1df0174a965cdc70480c1a83e088a4aa2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/numerical/QueueAbs.scala +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ - -object AmortizedQueue { - def concat(l1: BigInt, l2: BigInt): BigInt = { - require(l1 >= 0 && l2 >= 0) - if (l1 == 0) - BigInt(3) - else - concat(l1 - 1, l2 + 1) + 5 - } ensuring (res => tmpl((a, b) => res <= a * l1 + b)) - - def reverseRec(l1: BigInt, l2: BigInt): BigInt = { - require(l1 >= 0 && l2 >= 0) - if (l1 == 0) - BigInt(3) - else { - reverseRec(l1 - 1, l2 + 1) + 6 - } - } ensuring (res => tmpl((a, b) => res <= a * l1 + b)) - - def reverse(l: BigInt): BigInt = { - require(l >= 0) - reverseRec(l, 0) + 1 - } ensuring (res => tmpl((a, b) => res <= a * l + b)) - - def create(front: BigInt, rear: BigInt): BigInt = { - require(front >= 0 && rear >= 0) - if (rear <= front) - BigInt(4) - else { - val t1 = reverse(rear) - val t2 = concat(front, rear) - t1 + t2 + 7 - } - } - - def enqueue(q: BigInt, front: BigInt, rear: BigInt): BigInt = { - require(q == front + rear && q >= 0 && front >= 0 && rear >= 0) - create(front, rear) + 5 - } ensuring (res => tmpl((a, b) => res <= a * q + b)) - - def dequeue(q: BigInt, front: BigInt, rear: BigInt): BigInt = { - require(q == front + rear && q >= 1 && front >= rear && rear >= 0) - if (front >= 1) { - create(front - 1, rear) + 4 - } else { - //since front should be greater than rear, here rear should be 0 as well - BigInt(5) - } - } ensuring (res => tmpl((a, b) => res <= a * q + b)) - - def removeLast(l: BigInt): BigInt = { - require(l >= 1) - if (l == 1) { - BigInt(4) - } else { - removeLast(l - 1) + 6 - } - } ensuring (res => tmpl((a, b) => res <= a * l + b)) - - def pop(q: BigInt, front: BigInt, rear: BigInt): BigInt = { - require(q == front + rear && q >= 1 && front >= rear && rear >= 0) - if (rear >= 1) { - BigInt(3) - } else { - val t1 = removeLast(front) - t1 + 5 - } - } ensuring (res => tmpl((a, b) => res <= a * q + b)) -} diff --git a/src/test/resources/regression/orb/numerical/SimpleLoop.scala b/src/test/resources/regression/orb/numerical/SimpleLoop.scala deleted file mode 100644 index 741d242bbf980de4848b5c461e291be37f0f650b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/numerical/SimpleLoop.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object SimpleLoop -{ - def s(x: BigInt) : BigInt = { - if(x < 0) - BigInt(0) - else - s(x-1) + 1 - } ensuring(res => res != -1) -} \ No newline at end of file diff --git a/src/test/resources/regression/orb/numerical/see-saw.scala b/src/test/resources/regression/orb/numerical/see-saw.scala deleted file mode 100644 index fe3c8dc6318633d7e8035620d8c2fce03bf9c487..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/numerical/see-saw.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object SeeSaw { - def s(x: BigInt, y: BigInt, z: BigInt): BigInt = { - require(y >= 0) - - if (x >= 100) { - y - } else if (x <= z) { //some condition - s(x + 1, y + 2, z) - } else if (x <= z + 9) { //some condition - s(x + 1, y + 3, z) - } else { - s(x + 2, y + 1, z) - } - } ensuring (res => (100 - x <= 2 * res)) -} \ No newline at end of file diff --git a/src/test/resources/regression/orb/stack/BinaryTrie.scala b/src/test/resources/regression/orb/stack/BinaryTrie.scala deleted file mode 100644 index 21b7e7c895c64242e86981dfda72cf2abb13441c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/stack/BinaryTrie.scala +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ -import leon.instrumentation._ -//import scala.collection.immutable.Set - -object BinaryTrie { - sealed abstract class Tree - case class Leaf() extends Tree - case class Node(nvalue: BigInt, left: Tree, right: Tree) extends Tree - - sealed abstract class IList - case class Cons(head: BigInt, tail: IList) extends IList - case class Nil() extends IList - - def listSize(l: IList): BigInt = (l match { - case Nil() => 0 - case Cons(x, xs) => 1 + listSize(xs) - }) - - def height(t: Tree): BigInt = { - t match { - case Leaf() => 0 - case Node(x, l, r) => { - val hl = height(l) - val hr = height(r) - if (hl > hr) hl + 1 else hr + 1 - } - } - } - - def find(inp: IList, t: Tree): Tree = { - inp match { - case Nil() => t - case Cons(x, Nil()) => t - case Cons(x, xs @ Cons(y, _)) => { - t match { - case Leaf() => t - case Node(v, l, r) => { - if (y > 0) find(xs, l) else find(xs, r) - } - } - } - case _ => t - } - } ensuring (_ => stack <= ? * listSize(inp) + ?) - - def insert(inp: IList, t: Tree): Tree = { - t match { - case Leaf() => { - inp match { - case Nil() => t - case Cons(x, xs) => { - val newch = insert(xs, Leaf()) - newch match { - case Leaf() => Node(x, Leaf(), Leaf()) - case Node(y, _, _) => if (y > 0) Node(x, newch, Leaf()) else Node(y, Leaf(), newch) - } - } - } - - } - case Node(v, l, r) => { - inp match { - case Nil() => t - case Cons(x, Nil()) => t - case Cons(x, xs @ Cons(y, _)) => { - val ch = if (y > 0) l else r - if (y > 0) - Node(v, insert(xs, ch), r) - else - Node(v, l, insert(xs, ch)) - } - case _ => t - } - } - } - } ensuring (_ => stack <= ? * listSize(inp) + ?) - - def create(inp: IList): Tree = { - insert(inp, Leaf()) - } ensuring (_ => stack <= ? * listSize(inp) + ?) - - def delete(inp: IList, t: Tree): Tree = { - t match { - case Leaf() => { - inp match { - case Nil() => Leaf() - case Cons(x ,xs) => { - //the input is not in the tree, so do nothing - Leaf() - } - } - } - case Node(v, l, r) => { - inp match { - case Nil() => { - //the tree has extensions of the input list so do nothing - t - } - case Cons(x, Nil()) => { - //if "l" and "r" are nil, remove the node - if(l == Leaf() && r == Leaf()) Leaf() - else t - } - case Cons(x ,xs@Cons(y, _)) => { - val ch = if(y > 0) l else r - val newch = delete(xs, ch) - if(newch == Leaf() && ((y > 0 && r == Leaf()) || (y <= 0 && l == Leaf()))) Leaf() - else { - if(y > 0) - Node(v, newch, r) - else - Node(v, l, newch) - } - } - case _ => t - } - } - } - } ensuring (_ => stack <= ? * listSize(inp) + ?) -} diff --git a/src/test/resources/regression/orb/stack/ListOperations.scala b/src/test/resources/regression/orb/stack/ListOperations.scala deleted file mode 100644 index 7323f1a3e0ffe2b1c1c0d5b1d46cab915a8a1759..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/stack/ListOperations.scala +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ -import leon.instrumentation._ - -object ListOperations { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def size(l: List): BigInt = (l match { - case Nil() => 0 - case Cons(_, t) => 1 + size(t) - }) - - def reverseRec(l1: List, l2: List): List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => reverseRec(xs, Cons(x, l2)) - - }) ensuring (res => size(l1) + size(l2) == size(res) && tmpl((a,b) => stack <= a*size(l1) + b)) - - def contains(list: List, elem: BigInt): Boolean = (list match { - case Nil() => false - case Cons(x, xs) => x == elem || contains(xs, elem) - - }) ensuring (res => tmpl((a,b) => stack <= a*size(list) + b)) - - def distinct(l: List): List = ( - l match { - case Nil() => Nil() - case Cons(x, xs) => { - val newl = distinct(xs) - if (contains(newl, x)) newl - else Cons(x, newl) - } - }) ensuring (res => size(l) >= size(res) && tmpl((a,b) => stack <= a*size(l) + b)) -} diff --git a/src/test/resources/regression/orb/stack/SpeedBenchmarks.scala b/src/test/resources/regression/orb/stack/SpeedBenchmarks.scala deleted file mode 100644 index 8a65f13812fc0edc59528a6e63823a11512a7dc9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/stack/SpeedBenchmarks.scala +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ -import leon.instrumentation._ -import leon.math._ - -object SpeedBenchmarks { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def size(l: List): BigInt = (l match { - case Nil() => 0 - case Cons(_, t) => 1 + size(t) - }) - - sealed abstract class StringBuffer - case class Chunk(str: List, next: StringBuffer) extends StringBuffer - case class Empty() extends StringBuffer - - def length(sb: StringBuffer) : BigInt = sb match { - case Chunk(_, next) => 1 + length(next) - case _ => 0 - } - - def sizeBound(sb: StringBuffer, k: BigInt) : Boolean ={ - sb match { - case Chunk(str, next) => size(str) <= k && sizeBound(next, k) - case _ => 0 <= k - } - } - - def sizeBuffer(sb: StringBuffer): BigInt = { - sb match { - case Chunk(str, next) => size(str) + sizeBuffer(sb) - case Empty() => 0 - } - } - - /** - * Fig. 1 of SPEED, POPL'09: The functional version of the implementation. - * Equality check of two string buffers - */ - def Equals(str1: List, str2: List, s1: StringBuffer, s2: StringBuffer, k: BigInt) : Boolean = { - require(sizeBound(s1, k) && sizeBound(s2, k) && size(str1) <= k && size(str2) <= k && k >= 0) - - (str1, str2) match { - case (Cons(h1,t1), Cons(h2,t2)) => { - if(h1 != h2) false - else Equals(t1,t2, s1,s2, k) - } - case (Cons(_,_), Nil()) => { - //load from s2 - s2 match { - case Chunk(str, next) => Equals(str1, str, s1, next, k) - case Empty() => false - } - } - case (Nil(), Cons(_,_)) => { - //load from s1 - s1 match { - case Chunk(str, next) => Equals(str, str2, next, s2, k) - case Empty() => false - } - } - case _ =>{ - //load from both - (s1,s2) match { - case (Chunk(nstr1, next1),Chunk(nstr2, next2)) => Equals(nstr1, nstr2, next1, next2, k) - case (Empty(),Chunk(nstr2, next2)) => Equals(str1, nstr2, s1, next2, k) - case (Chunk(nstr1, next1), Empty()) => Equals(nstr1, str2, next1, s2, k) - case _ => true - } - } - } - } ensuring(res => tmpl((a,b,c,d,e) => stack <= a*max(sizeBuffer(s1), sizeBuffer(s2)) + c*(k+1) + e)) -} diff --git a/src/test/resources/regression/orb/timing/BinaryTrie.scala b/src/test/resources/regression/orb/timing/BinaryTrie.scala deleted file mode 100644 index 431551014df1c9130d376065413324462523b2a1..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/timing/BinaryTrie.scala +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ -import leon.instrumentation._ - -object BinaryTrie { - sealed abstract class Tree - case class Leaf() extends Tree - case class Node(nvalue: BigInt, left: Tree, right: Tree) extends Tree - - sealed abstract class IList - case class Cons(head: BigInt, tail: IList) extends IList - case class Nil() extends IList - - def listSize(l: IList): BigInt = (l match { - case Nil() => 0 - case Cons(x, xs) => 1 + listSize(xs) - }) - - def height(t: Tree): BigInt = { - t match { - case Leaf() => 0 - case Node(x, l, r) => { - val hl = height(l) - val hr = height(r) - if (hl > hr) hl + 1 else hr + 1 - } - } - } - - def find(inp: IList, t: Tree): Tree = { - inp match { - case Nil() => t - case Cons(x, Nil()) => t - case Cons(x, xs @ Cons(y, _)) => { - t match { - case Leaf() => t - case Node(v, l, r) => { - if (y > 0) find(xs, l) else find(xs, r) - } - } - } - case _ => t - } - } ensuring (_ => time <= ? * listSize(inp) + ?) - - def insert(inp: IList, t: Tree): Tree = { - t match { - case Leaf() => { - inp match { - case Nil() => t - case Cons(x, xs) => { - val newch = insert(xs, Leaf()) - newch match { - case Leaf() => Node(x, Leaf(), Leaf()) - case Node(y, _, _) => if (y > 0) Node(x, newch, Leaf()) else Node(y, Leaf(), newch) - } - } - } - - } - case Node(v, l, r) => { - inp match { - case Nil() => t - case Cons(x, Nil()) => t - case Cons(x, xs @ Cons(y, _)) => { - val ch = if (y > 0) l else r - if (y > 0) - Node(v, insert(xs, ch), r) - else - Node(v, l, insert(xs, ch)) - } - case _ => t - } - } - } - } ensuring (_ => time <= ? * listSize(inp) + ?) - - def create(inp: IList): Tree = { - insert(inp, Leaf()) - } ensuring (res => true && tmpl((a, c) => time <= a * listSize(inp) + c)) - - def delete(inp: IList, t: Tree): Tree = { - t match { - case Leaf() => { - inp match { - case Nil() => Leaf() - case Cons(x ,xs) => { - //the input is not in the tree, so do nothing - Leaf() - } - } - } - case Node(v, l, r) => { - inp match { - case Nil() => { - //the tree has extensions of the input list so do nothing - t - } - case Cons(x, Nil()) => { - //if "l" and "r" are nil, remove the node - if(l == Leaf() && r == Leaf()) Leaf() - else t - } - case Cons(x ,xs@Cons(y, _)) => { - val ch = if(y > 0) l else r - val newch = delete(xs, ch) - if(newch == Leaf() && ((y > 0 && r == Leaf()) || (y <= 0 && l == Leaf()))) Leaf() - else { - if(y > 0) - Node(v, newch, r) - else - Node(v, l, newch) - } - } - case _ => t - } - } - } - } ensuring (_ => time <= ? * listSize(inp) + ?) -} diff --git a/src/test/resources/regression/orb/timing/ConcatVariations.scala b/src/test/resources/regression/orb/timing/ConcatVariations.scala deleted file mode 100644 index 519cef287a7c9b4d8d58a4b75817301ea6391dd1..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/timing/ConcatVariations.scala +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ -import leon.instrumentation._ - - -object ConcatVariations { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def size(l: List): BigInt = (l match { - case Nil() => 0 - case Cons(_, t) => 1 + size(t) - }) - - def genL(n: BigInt): List = { - require(n >= 0) - if (n == 0) Nil() - else - Cons(n, genL(n - 1)) - } ensuring (res => size(res) == n && tmpl((a,b) => time <= a*n + b)) - - def append(l1: List, l2: List): List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => Cons(x, append(xs, l2)) - - }) ensuring (res => size(l1) + size(l2) == size(res) && tmpl((a,b) => time <= a*size(l1) + b)) - - def f_good(m: BigInt, n: BigInt): List = { - require(0 <= m && 0 <= n) - if (m == 0) Nil() - else append(genL(n), f_good(m - 1, n)) - - } ensuring(res => size(res) == n*m && tmpl((a,b,c,d) => time <= a*(n*m) + b*n + c*m +d)) - - def f_worst(m: BigInt, n: BigInt): List = { - require(0 <= m && 0 <= n) - - if (m == 0) Nil() - else append(f_worst(m - 1, n), genL(n)) - - } ensuring(res => size(res) == n*m && tmpl((a,c,d,e,f) => time <= a*((n*m)*m)+c*(n*m)+d*n+e*m+f)) -} diff --git a/src/test/resources/regression/orb/timing/ListOperations.scala b/src/test/resources/regression/orb/timing/ListOperations.scala deleted file mode 100644 index e4c486dcdd76fd281f21d602243d3a64b25330b3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/timing/ListOperations.scala +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.invariant._ -import leon.instrumentation._ - -object ListOperations { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def size(l: List): BigInt = (l match { - case Nil() => 0 - case Cons(_, t) => 1 + size(t) - }) - - def append(l1: List, l2: List): List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => Cons(x, append(xs, l2)) - }) ensuring (res => size(l1) + size(l2) == size(res) && tmpl((a,b) => time <= a*size(l1) + b)) - - def remove(elem: BigInt, l: List): List = { - l match { - case Nil() => Nil() - case Cons(hd, tl) => if (hd == elem) remove(elem, tl) else Cons(hd, remove(elem, tl)) - } - } ensuring (res => size(l) >= size(res) && tmpl((a,b) => time <= a*size(l) + b)) - - def contains(list: List, elem: BigInt): Boolean = (list match { - case Nil() => false - case Cons(x, xs) => x == elem || contains(xs, elem) - }) ensuring (res => true && tmpl((a,b) => time <= a*size(list) + b)) - - def distinct(l: List): List = ( - l match { - case Nil() => Nil() - case Cons(x, xs) => { - val newl = distinct(xs) - if (contains(newl, x)) newl - else Cons(x, newl) - } - }) ensuring (res => size(l) >= size(res) && tmpl((a,b) => time <= a*(size(l)*size(l)) + b)) -} diff --git a/src/test/resources/regression/orb/timing/PropositionalLogic.scala b/src/test/resources/regression/orb/timing/PropositionalLogic.scala deleted file mode 100644 index e7ed2b10a82fbe770d7d5734e015d30440d59b2f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/timing/PropositionalLogic.scala +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import scala.collection.immutable.Set -import leon.invariant._ -import leon.instrumentation._ - -object PropositionalLogic { - - sealed abstract class Formula - case class And(lhs: Formula, rhs: Formula) extends Formula - case class Or(lhs: Formula, rhs: Formula) extends Formula - case class Implies(lhs: Formula, rhs: Formula) extends Formula - case class Not(f: Formula) extends Formula - case class Literal(id: BigInt) extends Formula - case class True() extends Formula - case class False() extends Formula - - case class Pair(f: Formula, b: Boolean) - - sealed abstract class List - case class Cons(x: Pair, xs: List) extends List - case class Nil() extends List - - def size(f : Formula) : BigInt = (f match { - case And(lhs, rhs) => size(lhs) + size(rhs) + 1 - case Or(lhs, rhs) => size(lhs) + size(rhs) + 1 - case Implies(lhs, rhs) => size(lhs) + size(rhs) + 1 - case Not(f) => size(f) + 1 - case _ => 1 - }) - - def removeImplies(f: Formula): Formula = (f match { - case And(lhs, rhs) => And(removeImplies(lhs), removeImplies(rhs)) - case Or(lhs, rhs) => Or(removeImplies(lhs), removeImplies(rhs)) - case Implies(lhs, rhs) => Or(Not(removeImplies(lhs)),removeImplies(rhs)) - case Not(f) => Not(removeImplies(f)) - case _ => f - - }) ensuring(_ => time <= ? * size(f) + ?) - - def nnf(formula: Formula): Formula = (formula match { - case And(lhs, rhs) => And(nnf(lhs), nnf(rhs)) - case Or(lhs, rhs) => Or(nnf(lhs), nnf(rhs)) - case Implies(lhs, rhs) => Implies(nnf(lhs), nnf(rhs)) - case Not(And(lhs, rhs)) => Or(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Or(lhs, rhs)) => And(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Implies(lhs, rhs)) => And(nnf(lhs), nnf(Not(rhs))) - case Not(Not(f)) => nnf(f) - case Not(Literal(_)) => formula - case Literal(_) => formula - case Not(True()) => False() - case Not(False()) => True() - case _ => formula - }) ensuring(_ => time <= ? * size(formula) + ?) - - def isNNF(f: Formula): Boolean = { f match { - case And(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Or(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Implies(lhs, rhs) => false - case Not(Literal(_)) => true - case Not(_) => false - case _ => true - }} ensuring(_ => time <= ? * size(f) + ?) - - def simplify(f: Formula): Formula = (f match { - case And(lhs, rhs) => { - val sl = simplify(lhs) - val sr = simplify(rhs) - - //if lhs or rhs is false, return false - //if lhs is true return rhs - //if rhs is true return lhs - (sl,sr) match { - case (False(), _) => False() - case (_, False()) => False() - case (True(), _) => sr - case (_, True()) => sl - case _ => And(sl, sr) - } - } - case Or(lhs, rhs) => { - val sl = simplify(lhs) - val sr = simplify(rhs) - - //if lhs or rhs is true, return true - //if lhs is false return rhs - //if rhs is false return lhs - (sl,sr) match { - case (True(), _) => True() - case (_, True()) => True() - case (False(), _) => sr - case (_, False()) => sl - case _ => Or(sl, sr) - } - } - case Implies(lhs, rhs) => { - val sl = simplify(lhs) - val sr = simplify(rhs) - - //if lhs is false return true - //if rhs is true return true - //if lhs is true return rhs - //if rhs is false return Not(rhs) - (sl,sr) match { - case (False(), _) => True() - case (_, True()) => True() - case (True(), _) => sr - case (_, False()) => Not(sl) - case _ => Implies(sl, sr) - } - } - case Not(True()) => False() - case Not(False()) => True() - case _ => f - - }) ensuring(_ => time <= ? *size(f) + ?) -} diff --git a/src/test/resources/regression/orb/timing/SimpleMap.scala b/src/test/resources/regression/orb/timing/SimpleMap.scala deleted file mode 100644 index 3b347be92167b43bfa7d215303f4b8d40ae5f584..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/orb/timing/SimpleMap.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.instrumentation._ -import leon.invariant._ - -object SimpleMap { - sealed abstract class List - case class Cons(head: (BigInt, BigInt), tail: List) extends List - case class Nil() extends List - - def size(l : List) : BigInt = (l match { - case Cons(_, xs) => 1 + size(xs) - case _ => 0 - }) - - def insert(l: List, key: BigInt, value: BigInt): List = { - Cons((key, value), l) - } ensuring(res => tmpl((a) => time <= a)) - - def getOrElse(l: List, key: BigInt, elseValue: BigInt): BigInt = { - l match { - case Nil() => elseValue - case Cons((currKey, currValue), _) if (currKey == key) => currValue - case Cons(_, tail) => getOrElse(tail, key, elseValue) - } - } ensuring(res => tmpl((a, b) => time <= a*size(l) + b)) -} \ No newline at end of file diff --git a/src/test/resources/regression/performance/cegis/Add.scala b/src/test/resources/regression/performance/cegis/Add.scala deleted file mode 100644 index 81cde689f4f14a6915a1deca21a3da09f03208ed..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/performance/cegis/Add.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Numerals { - sealed abstract class Num - case object Z extends Num - case class S(pred: Num) extends Num - - def value(n: Num): BigInt = { - n match { - case Z => 0 - case S(p) => 1 + value(p) - } - } ensuring (_ >= 0) - - def add(x: Num, y: Num): Num = { - choose { (r: Num) => - value(r) == value(x) + value(y) - } - } -} diff --git a/src/test/resources/regression/performance/cegis/Distinct.scala b/src/test/resources/regression/performance/cegis/Distinct.scala deleted file mode 100644 index e47af67df2dbf4b6287d66f711ad0916af552e49..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/performance/cegis/Distinct.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Numerals { - sealed abstract class Num - case object Z extends Num - case class S(pred: Num) extends Num - - def value(n: Num): BigInt = { - n match { - case Z => 0 - case S(p) => 1 + value(p) - } - } ensuring (_ >= 0) - - def add(x: Num, y: Num): Num = (x match { - case Z => y - case S(p) => add(p, S(y)) - }) ensuring (value(_) == value(x) + value(y)) - - def distinct(x: Num, y: Num): Num = { - choose { (r : Num) => - r != x && r != y - } - } -} diff --git a/src/test/resources/regression/performance/cegis/Hole1.scala b/src/test/resources/regression/performance/cegis/Hole1.scala deleted file mode 100644 index ce983abae037c19a9fdf57f23d2da612d15269d0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/performance/cegis/Hole1.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon.lang.synthesis._ - -object Holes { - def abs3(a: Int) = { - if (?(a > 0, a < 0)) { - a - } else { - -a - } - } ensuring { - _ >= 0 - } -} diff --git a/src/test/resources/regression/performance/cegis/Length.scala b/src/test/resources/regression/performance/cegis/Length.scala deleted file mode 100644 index 04462a0b877f2a92bbaa23a88281455e060671bf..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/performance/cegis/Length.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.collection._ -import leon.lang._ -import leon.lang.synthesis._ - -object Length { - - def foo(l : List[Int]) : Int = - choose { res:Int => (l, res) passes { - case Nil() => 0 - case Cons(a, Nil()) => 2 - case Cons(_, Cons(_, Cons(_, Cons(_, Nil())))) => 8 - }} - -} diff --git a/src/test/resources/regression/performance/cegis/Mult.scala b/src/test/resources/regression/performance/cegis/Mult.scala deleted file mode 100644 index 3b3b9b80da7904b9af7694f0e2354109586056b9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/performance/cegis/Mult.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Numerals { - sealed abstract class Num - case object Z extends Num - case class S(pred: Num) extends Num - - def value(n: Num): BigInt = { - n match { - case Z => 0 - case S(p) => 1 + value(p) - } - } ensuring (_ >= 0) - - def add(x: Num, y: Num): Num = (x match { - case Z => y - case S(p) => add(p, S(y)) - }) ensuring (value(_) == value(x) + value(y)) - - def mult(x: Num, y: Num): Num = { - choose { (r: Num) => - value(r) == value(x) * value(y) - } - } -} diff --git a/src/test/resources/regression/performance/cegis/Squared.scala b/src/test/resources/regression/performance/cegis/Squared.scala deleted file mode 100644 index 1e2e6d27de60bb1d1fa0e6cea73e37f4b861f2f4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/performance/cegis/Squared.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Numerals { - sealed abstract class Num - case object Z extends Num - case class S(pred: Num) extends Num - - def value(n:Num) : BigInt = { - n match { - case Z => 0 - case S(p) => 1 + value(p) - } - } ensuring (_ >= 0) - - def add(x: Num, y: Num): Num = (x match { - case Z => y - case S(p) => add(p, S(y)) - }) ensuring (value(_) == value(x) + value(y)) - - def mult(x: Num, y: Num): Num = (y match { - case S(p) => - add(mult(x, p), x) - case Z => - Z - }) ensuring { value(_) == value(x) * value(y) } - - def squared(x: Num): Num = { - choose { (r: Num) => - value(r) == value(x) * value(x) - } - } -} diff --git a/src/test/resources/regression/repair/Compiler1.scala b/src/test/resources/regression/repair/Compiler1.scala deleted file mode 100644 index ffd0bdaee24a0b1f4c32b820bab023f49539e975..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/repair/Compiler1.scala +++ /dev/null @@ -1,178 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ -import leon.collection._ -import leon._ - -object Trees { - abstract class Expr - case class Plus(lhs: Expr, rhs: Expr) extends Expr - case class Minus(lhs: Expr, rhs: Expr) extends Expr - case class LessThan(lhs: Expr, rhs: Expr) extends Expr - case class And(lhs: Expr, rhs: Expr) extends Expr - case class Or(lhs: Expr, rhs: Expr) extends Expr - case class Not(e : Expr) extends Expr - case class Eq(lhs: Expr, rhs: Expr) extends Expr - case class Ite(cond: Expr, thn: Expr, els: Expr) extends Expr - case class IntLiteral(v: BigInt) extends Expr - case class BoolLiteral(b : Boolean) extends Expr -} - -object Types { - abstract class Type - case object IntType extends Type - case object BoolType extends Type -} - - -object TypeChecker { - import Trees._ - import Types._ - - def typeOf(e :Expr) : Option[Type] = e match { - case Plus(l,r) => (typeOf(l), typeOf(r)) match { - case (Some(IntType), Some(IntType)) => Some(IntType) - case _ => None() - } - case Minus(l,r) => (typeOf(l), typeOf(r)) match { - case (Some(IntType), Some(IntType)) => Some(IntType) - case _ => None() - } - case LessThan(l,r) => ( typeOf(l), typeOf(r)) match { - case (Some(IntType), Some(IntType)) => Some(BoolType) - case _ => None() - } - case And(l,r) => ( typeOf(l), typeOf(r)) match { - case (Some(BoolType), Some(BoolType)) => Some(BoolType) - case _ => None() - } - case Or(l,r) => ( typeOf(l), typeOf(r)) match { - case (Some(BoolType), Some(BoolType)) => Some(BoolType) - case _ => None() - } - case Not(e) => typeOf(e) match { - case Some(BoolType) => Some(BoolType) - case _ => None() - } - case Eq(lhs, rhs) => (typeOf(lhs), typeOf(rhs)) match { - case (Some(t1), Some(t2)) if t1 == t2 => Some(BoolType) - case _ => None() - } - case Ite(c, th, el) => (typeOf(c), typeOf(th), typeOf(el)) match { - case (Some(BoolType), Some(t1), Some(t2)) if t1 == t2 => Some(t1) - case _ => None() - } - case IntLiteral(_) => Some(IntType) - case BoolLiteral(_) => Some(BoolType) - } - - def typeChecks(e : Expr) = typeOf(e).isDefined -} - - -object Semantics { - import Trees._ - import Types._ - import TypeChecker._ - - def semI(t : Expr) : BigInt = { - require( typeOf(t) == ( Some(IntType) : Option[Type] )) - t match { - case Plus(lhs , rhs) => semI(lhs) + semI(rhs) - case Minus(lhs , rhs) => semI(lhs) - semI(rhs) - case Ite(cond, thn, els) => - if (semB(cond)) semI(thn) else semI(els) - case IntLiteral(v) => v - } - } - - def semB(t : Expr) : Boolean = { - require( (Some(BoolType): Option[Type]) == typeOf(t)) - t match { - case And(lhs, rhs ) => semB(lhs) && semB(rhs) - case Or(lhs , rhs ) => semB(lhs) || semB(rhs) - case Not(e) => !semB(e) - case LessThan(lhs, rhs) => semI(lhs) < semI(rhs) - case Ite(cond, thn, els) => - if (semB(cond)) semB(thn) else semB(els) - case Eq(lhs, rhs) => (typeOf(lhs), typeOf(rhs)) match { - case ( Some(IntType), Some(IntType) ) => semI(lhs) == semI(rhs) - case ( Some(BoolType), Some(BoolType) ) => semB(lhs) == semB(rhs) - } - case BoolLiteral(b) => b - } - } - - def b2i(b : Boolean): BigInt = if (b) 1 else 0 - - @induct - def semUntyped(t : Expr): BigInt = { t match { - case Plus (lhs, rhs) => semUntyped(lhs) + semUntyped(rhs) - case Minus(lhs, rhs) => semUntyped(lhs) - semUntyped(rhs) - case And (lhs, rhs) => if (semUntyped(lhs)!=0) semUntyped(rhs) else BigInt(0) - case Or(lhs, rhs ) => - if (semUntyped(lhs) == 0) semUntyped(rhs) else BigInt(1) - case Not(e) => - b2i(semUntyped(e) == 0) - case LessThan(lhs, rhs) => - b2i(semUntyped(lhs) < semUntyped(rhs)) - case Eq(lhs, rhs) => - b2i(semUntyped(lhs) == semUntyped(rhs)) - case Ite(cond, thn, els) => - if (semUntyped(cond) == 0) semUntyped(els) else semUntyped(thn) - case IntLiteral(v) => v - case BoolLiteral(b) => b2i(b) - }} ensuring { res => typeOf(t) match { - case Some(IntType) => res == semI(t) - case Some(BoolType) => res == b2i(semB(t)) - case None() => true - }} - -} - - -object Desugar { - import Types._ - import TypeChecker._ - import Semantics.b2i - - abstract class SimpleE - case class Plus(lhs : SimpleE, rhs : SimpleE) extends SimpleE - case class Neg(arg : SimpleE) extends SimpleE - case class Ite(cond : SimpleE, thn : SimpleE, els : SimpleE) extends SimpleE - case class Eq(lhs : SimpleE, rhs : SimpleE) extends SimpleE - case class LessThan(lhs : SimpleE, rhs : SimpleE) extends SimpleE - case class Literal(i : BigInt) extends SimpleE - - @induct - def desugar(e : Trees.Expr) : SimpleE = { e match { - case Trees.Plus (lhs, rhs) => Neg(desugar(lhs)) // FIXME: Complete nonsense. Leon can't disprove it, uses example... - case Trees.Minus(lhs, rhs) => Plus(desugar(lhs), Neg(desugar(rhs))) - case Trees.LessThan(lhs, rhs) => LessThan(desugar(lhs), desugar(rhs)) - case Trees.And (lhs, rhs) => Ite(desugar(lhs), desugar(rhs), Literal(0)) - case Trees.Or (lhs, rhs) => Ite(desugar(lhs), Literal(1), desugar(rhs)) - case Trees.Not(e) => Ite(desugar(e), Literal(0), Literal(1)) - case Trees.Eq(lhs, rhs) => - Eq(desugar(lhs), desugar(rhs)) - case Trees.Ite(cond, thn, els) => Ite(desugar(cond), desugar(thn), desugar(els)) - case Trees.IntLiteral(v) => Literal(v) - case Trees.BoolLiteral(b) => Literal(b2i(b)) - }} ensuring { res => - ((e, res) passes { - case Trees.Plus(Trees.IntLiteral(i), Trees.Minus(Trees.IntLiteral(j), Trees.IntLiteral(BigInt(42)))) => - Plus(Literal(i), Plus(Literal(j), Neg(Literal(42)))) - }) && - sem(res) == Semantics.semUntyped(e) - } - - def sem(e: SimpleE): BigInt = e match { - case Plus (lhs, rhs) => sem(lhs) + sem(rhs) - case Ite(cond, thn, els) => if (sem(cond) != 0) sem(thn) else sem(els) - case Neg(arg) => -sem(arg) - case Eq(lhs,rhs) => b2i(sem(lhs) == sem(rhs)) - case LessThan(lhs, rhs) => b2i(sem(lhs) < sem(rhs)) - case Literal(i) => i - } - -} diff --git a/src/test/resources/regression/repair/Heap3.scala b/src/test/resources/regression/repair/Heap3.scala deleted file mode 100644 index 7d788a3a082ee28f3b7d746003970ea8497bf83f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/repair/Heap3.scala +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -/** Author: Ravi - * Date: 20.11.2013 - **/ - -import leon.lang._ -import leon.collection._ - -object Heaps { - - sealed abstract class Heap { - val rank : BigInt = this match { - case Leaf() => 0 - case Node(_, l, r) => - 1 + max(l.rank, r.rank) - } - def content : Set[BigInt] = this match { - case Leaf() => Set[BigInt]() - case Node(v,l,r) => l.content ++ Set(v) ++ r.content - } - } - case class Leaf() extends Heap - case class Node(value:BigInt, left: Heap, right: Heap) extends Heap - - def max(i1 : BigInt, i2 : BigInt) = if (i1 >= i2) i1 else i2 - - def hasHeapProperty(h : Heap) : Boolean = h match { - case Leaf() => true - case Node(v, l, r) => - ( l match { - case Leaf() => true - case n@Node(v2,_,_) => v >= v2 && hasHeapProperty(n) - }) && - ( r match { - case Leaf() => true - case n@Node(v2,_,_) => v >= v2 && hasHeapProperty(n) - }) - } - - def hasLeftistProperty(h: Heap) : Boolean = h match { - case Leaf() => true - case Node(_,l,r) => - hasLeftistProperty(l) && - hasLeftistProperty(r) && - l.rank >= r.rank - } - - def heapSize(t: Heap): BigInt = { t match { - case Leaf() => BigInt(0) - case Node(v, l, r) => heapSize(l) + 1 + heapSize(r) - }} ensuring(_ >= 0) - - private def merge(h1: Heap, h2: Heap) : Heap = { - require( - hasLeftistProperty(h1) && hasLeftistProperty(h2) && - hasHeapProperty(h1) && hasHeapProperty(h2) - ) - (h1,h2) match { - case (Leaf(), _) => h2 - case (_, Leaf()) => h1 - case (Node(v1, l1, r1), Node(v2, l2, r2)) => - if(v1 >= v2) // FIXME swapped the branches - makeN(v2, l2, merge(h1, r2)) - else - makeN(v1, l1, merge(r1, h2)) - } - } ensuring { res => - hasLeftistProperty(res) && hasHeapProperty(res) && - heapSize(h1) + heapSize(h2) == heapSize(res) && - h1.content ++ h2.content == res.content - } - - private def makeN(value: BigInt, left: Heap, right: Heap) : Heap = { - require( - hasLeftistProperty(left) && hasLeftistProperty(right) - ) - if(left.rank >= right.rank) - Node(value, left, right) - else - Node(value, right, left) - } ensuring { res => - hasLeftistProperty(res) } - - def insert(element: BigInt, heap: Heap) : Heap = { - require(hasLeftistProperty(heap) && hasHeapProperty(heap)) - - merge(Node(element, Leaf(), Leaf()), heap) - - } ensuring { res => - hasLeftistProperty(res) && hasHeapProperty(res) && - heapSize(res) == heapSize(heap) + 1 && - res.content == heap.content ++ Set(element) - } - - def findMax(h: Heap) : Option[BigInt] = { - h match { - case Node(m,_,_) => Some(m) - case Leaf() => None() - } - } - - def removeMax(h: Heap) : Heap = { - require(hasLeftistProperty(h) && hasHeapProperty(h)) - h match { - case Node(_,l,r) => merge(l, r) - case l => l - } - } ensuring { res => - hasLeftistProperty(res) && hasHeapProperty(res) - } - -} diff --git a/src/test/resources/regression/repair/Heap4.scala b/src/test/resources/regression/repair/Heap4.scala deleted file mode 100644 index ad09821eebde5471f3b663967178ba8251992ebf..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/repair/Heap4.scala +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -/* Author: Ravi - * Date: 20.11.2013 - */ - -import leon._ -import leon.lang._ -import leon.collection._ - -object HeapSort { - - sealed abstract class Heap { - val rank : BigInt = this match { - case Leaf() => 0 - case Node(_, l, r) => - 1 + max(l.rank, r.rank) - } - def content : Set[BigInt] = this match { - case Leaf() => Set[BigInt]() - case Node(v,l,r) => l.content ++ Set(v) ++ r.content - } - } - case class Leaf() extends Heap - case class Node(value:BigInt, left: Heap, right: Heap) extends Heap - - def max(i1 : BigInt, i2 : BigInt) = if (i1 >= i2) i1 else i2 - - def hasHeapProperty(h : Heap) : Boolean = h match { - case Leaf() => true - case Node(v, l, r) => - ( l match { - case Leaf() => true - case n@Node(v2,_,_) => v >= v2 && hasHeapProperty(n) - }) && - ( r match { - case Leaf() => true - case n@Node(v2,_,_) => v >= v2 && hasHeapProperty(n) - }) - } - - def hasLeftistProperty(h: Heap) : Boolean = h match { - case Leaf() => true - case Node(_,l,r) => - hasLeftistProperty(l) && - hasLeftistProperty(r) && - l.rank >= r.rank - } - - def heapSize(t: Heap): BigInt = { t match { - case Leaf() => BigInt(0) - case Node(v, l, r) => heapSize(l) + 1 + heapSize(r) - }} ensuring(_ >= 0) - - private def merge(h1: Heap, h2: Heap) : Heap = { - require( - hasLeftistProperty(h1) && hasLeftistProperty(h2) && - hasHeapProperty(h1) && hasHeapProperty(h2) - ) - (h1,h2) match { - case (Leaf(), _) => h2 - case (_, Leaf()) => h2 // FIXME h2 instead of h1 - case (Node(v1, l1, r1), Node(v2, l2, r2)) => - if(v1 >= v2) - makeN(v1, l1, merge(r1, h2)) - else - makeN(v2, l2, merge(h1, r2)) - } - } ensuring { res => - hasLeftistProperty(res) && hasHeapProperty(res) && - heapSize(h1) + heapSize(h2) == heapSize(res) && - h1.content ++ h2.content == res.content - } - - private def makeN(value: BigInt, left: Heap, right: Heap) : Heap = { - require( - hasLeftistProperty(left) && hasLeftistProperty(right) - ) - if(left.rank >= right.rank) - Node(value, left, right) - else - Node(value, right, left) - } ensuring { res => - hasLeftistProperty(res) } - - def insert(element: BigInt, heap: Heap) : Heap = { - require(hasLeftistProperty(heap) && hasHeapProperty(heap)) - - merge(Node(element, Leaf(), Leaf()), heap) - - } ensuring { res => - hasLeftistProperty(res) && hasHeapProperty(res) && - heapSize(res) == heapSize(heap) + 1 && - res.content == heap.content ++ Set(element) - } - - def findMax(h: Heap) : Option[BigInt] = { - h match { - case Node(m,_,_) => Some(m) - case Leaf() => None() - } - } - - def removeMax(h: Heap) : Heap = { - require(hasLeftistProperty(h) && hasHeapProperty(h)) - h match { - case Node(_,l,r) => merge(l, r) - case l => l - } - } ensuring { res => - hasLeftistProperty(res) && hasHeapProperty(res) - } - -} diff --git a/src/test/resources/regression/repair/List1.scala b/src/test/resources/regression/repair/List1.scala deleted file mode 100644 index 4031f652fe3c38c3ba5d0ca8993a0aacd24a91a4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/repair/List1.scala +++ /dev/null @@ -1,421 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package leon.custom - -import leon._ -import leon.lang._ -import leon.annotation._ -import leon.collection._ - -sealed abstract class List0[T] { - def size: BigInt = (this match { - case Nil0() => BigInt(0) - case Cons0(h, t) => BigInt(1) + t.size - }) ensuring (_ >= 0) - - def content: Set[T] = this match { - case Nil0() => Set() - case Cons0(h, t) => Set(h) ++ t.content - } - - def contains(v: T): Boolean = (this match { - case Cons0(h, t) if h == v => true - case Cons0(_, t) => t.contains(v) - case Nil0() => false - }) ensuring { res => res == (content contains v) } - - def ++(that: List0[T]): List0[T] = (this match { - case Nil0() => that - case Cons0(x, xs) => Cons0(x, xs ++ that) - }) ensuring { res => (res.content == this.content ++ that.content) && (res.size == this.size + that.size)} - - def head: T = { - require(this != Nil0[T]()) - this match { - case Cons0(h, t) => h - } - } - - def tail: List0[T] = { - require(this != Nil0[T]()) - this match { - case Cons0(h, t) => t - } - } - - def apply(index: BigInt): T = { - require(0 <= index && index < size) - if (index == 0) { - head - } else { - tail(index-1) - } - } - - def ::(t:T): List0[T] = Cons0(t, this) - - def :+(t:T): List0[T] = { - this match { - case Nil0() => Cons0(t, this) - case Cons0(x, xs) => Cons0(x, xs :+ (t)) - } - } ensuring(res => (res.size == size + 1) && (res.content == content ++ Set(t))) - - def reverse: List0[T] = { - this match { - case Nil0() => this - case Cons0(x,xs) => xs.reverse :+ x - } - } ensuring (res => (res.size == size) && (res.content == content)) - - def take(i: BigInt): List0[T] = (this, i) match { - case (Nil0(), _) => Nil0() - case (Cons0(h, t), i) => - if (i == 0) { - Nil0() - } else { - Cons0(h, t.take(i-1)) - } - } - - def drop(i: BigInt): List0[T] = (this, i) match { - case (Nil0(), _) => Nil0() - case (Cons0(h, t), i) => - if (i == 0) { - Cons0(h, t) - } else { - t.drop(i-1) - } - } - - def slice(from: BigInt, to: BigInt): List0[T] = { - require(from < to && to < size && from >= 0) - drop(from).take(to-from) - } - - def replace(from: T, to: T): List0[T] = this match { - case Nil0() => Nil0() - case Cons0(h, t) => - val r = t.replace(from, to) - if (h == from) { - Cons0(to, r) - } else { - Cons0(h, r) - } - } - - private def chunk0(s: BigInt, l: List0[T], acc: List0[T], res: List0[List0[T]], s0: BigInt): List0[List0[T]] = l match { - case Nil0() => - if (acc.size > 0) { - res :+ acc - } else { - res - } - case Cons0(h, t) => - if (s0 == 0) { - chunk0(s, l, Nil0(), res :+ acc, s) - } else { - chunk0(s, t, acc :+ h, res, s0-1) - } - } - - def chunks(s: BigInt): List0[List0[T]] = { - require(s > 0) - - chunk0(s, this, Nil0(), Nil0(), s) - } - - def zip[B](that: List0[B]): List0[(T, B)] = (this, that) match { - case (Cons0(h1, t1), Cons0(h2, t2)) => - Cons0((h1, h2), t1.zip(t2)) - case (_) => - Nil0() - } - - def -(e: T): List0[T] = this match { - case Cons0(h, t) => - if (e == h) { - t - e - } else { - Cons0(h, t - e) - } - case Nil0() => - Nil0() - } - - def --(that: List0[T]): List0[T] = this match { - case Cons0(h, t) => - if (that.contains(h)) { - t -- that - } else { - Cons0(h, t -- that) - } - case Nil0() => - Nil0() - } - - def &(that: List0[T]): List0[T] = this match { - case Cons0(h, t) => - if (that.contains(h)) { - Cons0(h, t & that) - } else { - t & that - } - case Nil0() => - Nil0() - } - - def pad(s: BigInt, e: T): List0[T] = { (this, s) match { - case (_, s) if s <= 0 => - this - case (Nil0(), s) => - Cons0(e, Nil0().pad(s-1, e)) - case (Cons0(h, t), s) => - Cons0(h, t.pad(s-1, e)) // FIXME should be s - }} ensuring { res => - ((this,s,e), res) passes { - case (Cons0(a,Nil0()), BigInt(2), x) => Cons0(a, Cons0(x, Cons0(x, Nil0()))) - } - } - - def find(e: T): Option[BigInt] = this match { - case Nil0() => None() - case Cons0(h, t) => - if (h == e) { - Some(0) - } else { - t.find(e) match { - case None() => None() - case Some(i) => Some(i+1) - } - } - } - - def init: List0[T] = (this match { - case Cons0(h, Nil0()) => - Nil0[T]() - case Cons0(h, t) => - Cons0[T](h, t.init) - case Nil0() => - Nil0[T]() - }) ensuring ( (r: List0[T]) => ((r.size < this.size) || (this.size == 0)) ) - - def lastOption: Option[T] = this match { - case Cons0(h, t) => - t.lastOption.orElse(Some(h)) - case Nil0() => - None() - } - - def firstOption: Option[T] = this match { - case Cons0(h, t) => - Some(h) - case Nil0() => - None() - } - - def unique: List0[T] = this match { - case Nil0() => Nil0() - case Cons0(h, t) => - Cons0(h, t.unique - h) - } - - def splitAt(e: T): List0[List0[T]] = split(Cons0(e, Nil0())) - - def split(seps: List0[T]): List0[List0[T]] = this match { - case Cons0(h, t) => - if (seps.contains(h)) { - Cons0(Nil0(), t.split(seps)) - } else { - val r = t.split(seps) - Cons0(Cons0(h, r.head), r.tail) - } - case Nil0() => - Cons0(Nil0(), Nil0()) - } - - def count(e: T): BigInt = this match { - case Cons0(h, t) => - if (h == e) { - 1 + t.count(e) - } else { - t.count(e) - } - case Nil0() => - 0 - } - - def evenSplit: (List0[T], List0[T]) = { - val c = size/2 - (take(c), drop(c)) - } - - def insertAt(pos: BigInt, l: List0[T]): List0[T] = { - if(pos < 0) { - insertAt(size + pos, l) - } else if(pos == 0) { - l ++ this - } else { - this match { - case Cons0(h, t) => - Cons0(h, t.insertAt(pos-1, l)) - case Nil0() => - l - } - } - } - - def replaceAt(pos: BigInt, l: List0[T]): List0[T] = { - if(pos < 0) { - replaceAt(size + pos, l) - } else if(pos == 0) { - l ++ this.drop(l.size) - } else { - this match { - case Cons0(h, t) => - Cons0(h, t.replaceAt(pos-1, l)) - case Nil0() => - l - } - } - } - - def rotate(s: BigInt): List0[T] = { - if (s < 0) { - rotate(size+s) - } else { - val s2 = s % size - drop(s2) ++ take(s2) - } - } - - def isEmpty = this match { - case Nil0() => true - case _ => false - } - -} - -@ignore -object List0 { - def apply[T](elems: T*): List0[T] = ??? -} - -@library -object List0Ops { - def flatten[T](ls: List0[List0[T]]): List0[T] = ls match { - case Cons0(h, t) => h ++ flatten(t) - case Nil0() => Nil0() - } - - def isSorted(ls: List0[BigInt]): Boolean = ls match { - case Nil0() => true - case Cons0(_, Nil0()) => true - case Cons0(h1, Cons0(h2, _)) if(h1 > h2) => false - case Cons0(_, t) => isSorted(t) - } - - def sorted(ls: List0[BigInt]): List0[BigInt] = ls match { - case Cons0(h, t) => insSort(sorted(t), h) - case Nil0() => Nil0() - } - - def insSort(ls: List0[BigInt], v: BigInt): List0[BigInt] = ls match { - case Nil0() => Cons0(v, Nil0()) - case Cons0(h, t) => - if (v <= h) { - Cons0(v, t) - } else { - Cons0(h, insSort(t, v)) - } - } -} - - -case class Cons0[T](h: T, t: List0[T]) extends List0[T] -case class Nil0[T]() extends List0[T] - -@library -object List0Specs { - def snocIndex[T](l : List0[T], t : T, i : BigInt) : Boolean = { - require(0 <= i && i < l.size + 1) - // proof: - (l match { - case Nil0() => true - case Cons0(x, xs) => if (i > 0) snocIndex[T](xs, t, i-1) else true - }) && - // claim: - ((l :+ t).apply(i) == (if (i < l.size) l(i) else t)) - }.holds - - def reverseIndex[T](l : List0[T], i : BigInt) : Boolean = { - require(0 <= i && i < l.size) - (l match { - case Nil0() => true - case Cons0(x,xs) => snocIndex(l, x, i) && reverseIndex[T](l,i) - }) && - (l.reverse.apply(i) == l.apply(l.size - 1 - i)) - }.holds - - def appendIndex[T](l1 : List0[T], l2 : List0[T], i : BigInt) : Boolean = { - require(0 <= i && i < l1.size + l2.size) - (l1 match { - case Nil0() => true - case Cons0(x,xs) => if (i==0) true else appendIndex[T](xs,l2,i-1) - }) && - ((l1 ++ l2).apply(i) == (if (i < l1.size) l1(i) else l2(i - l1.size))) - }.holds - - def appendAssoc[T](l1 : List0[T], l2 : List0[T], l3 : List0[T]) : Boolean = { - (l1 match { - case Nil0() => true - case Cons0(x,xs) => appendAssoc(xs,l2,l3) - }) && - (((l1 ++ l2) ++ l3) == (l1 ++ (l2 ++ l3))) - }.holds - - def snocIsAppend[T](l : List0[T], t : T) : Boolean = { - (l match { - case Nil0() => true - case Cons0(x,xs) => snocIsAppend(xs,t) - }) && - ((l :+ t) == l ++ Cons0[T](t, Nil0())) - }.holds - - def snocAfterAppend[T](l1 : List0[T], l2 : List0[T], t : T) : Boolean = { - (l1 match { - case Nil0() => true - case Cons0(x,xs) => snocAfterAppend(xs,l2,t) - }) && - ((l1 ++ l2) :+ t == (l1 ++ (l2 :+ t))) - }.holds - - def snocReverse[T](l : List0[T], t : T) : Boolean = { - (l match { - case Nil0() => true - case Cons0(x,xs) => snocReverse(xs,t) - }) && - ((l :+ t).reverse == Cons0(t, l.reverse)) - }.holds - - def reverseReverse[T](l : List0[T]) : Boolean = { - (l match { - case Nil0() => true - case Cons0(x,xs) => reverseReverse[T](xs) && snocReverse[T](xs.reverse, x) - }) && - (l.reverse.reverse == l) - }.holds - - //// my hand calculation shows this should work, but it does not seem to be found - //def reverseAppend[T](l1 : List0[T], l2 : List0[T]) : Boolean = { - // (l1 match { - // case Nil0() => true - // case Cons0(x,xs) => { - // reverseAppend(xs,l2) && - // snocAfterAppend[T](l2.reverse, xs.reverse, x) && - // l1.reverse == (xs.reverse :+ x) - // } - // }) && - // ((l1 ++ l2).reverse == (l2.reverse ++ l1.reverse)) - //}.holds -} diff --git a/src/test/resources/regression/repair/ListEasy.scala b/src/test/resources/regression/repair/ListEasy.scala deleted file mode 100644 index d22286dce124b611bd11e9c490a33c9afe87e75d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/repair/ListEasy.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package leon.custom - -import leon._ -import leon.lang._ -import leon.annotation._ -import leon.collection._ - -sealed abstract class List0[T] { - def size: BigInt = (this match { - case Nil0() => BigInt(0) - case Cons0(h, t) => BigInt(1) + t.size - }) ensuring (_ >= 0) - - def content: Set[T] = this match { - case Nil0() => Set() - case Cons0(h, t) => Set(h) ++ t.content - } - - def contains(v: T): Boolean = (this match { - case Cons0(h, t) if h == v => true - case Cons0(_, t) => t.contains(v) - case Nil0() => false - }) ensuring { res => res == (content contains v) } - - - def pad(s: BigInt, e: T): List0[T] = { (this, s) match { - case (_, s) if s <= 0 => - this - case (Nil0(), s) => - Cons0(e, Nil0().pad(s-1, e)) - case (Cons0(h, t), s) => - Cons0(h, t.pad(s-1, e)) // FIXME should be s - }} ensuring { res => - ((this,s,e), res) passes { - case (Cons0(a,Nil0()), BigInt(2), x) => Cons0(a, Cons0(x, Cons0(x, Nil0()))) - } - } -} - -case class Cons0[T](h: T, t: List0[T]) extends List0[T] -case class Nil0[T]() extends List0[T] diff --git a/src/test/resources/regression/repair/MergeSort2.scala b/src/test/resources/regression/repair/MergeSort2.scala deleted file mode 100644 index 9435d1e3164baea46820779a3c3654ddae11345c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/repair/MergeSort2.scala +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ - -object MergeSort { - - def split(l : List[BigInt]) : (List[BigInt],List[BigInt]) = { l match { - case Cons(a, Cons(b, t)) => - val (rec1, rec2) = split(t) - (Cons(a, rec1), Cons(b, rec2)) - case other => (other, Nil[BigInt]()) - }} ensuring { res => - val (l1, l2) = res - l1.size >= l2.size && - l1.size <= l2.size + 1 && - l1.size + l2.size == l.size && - l1.content ++ l2.content == l.content - } - - def isSorted(l : List[BigInt]) : Boolean = l match { - case Cons(x, t@Cons(y, _)) => x <= y && isSorted(t) - case _ => true - } - - def merge(l1 : List[BigInt], l2 : List[BigInt]) : List[BigInt] = { - require(isSorted(l1) && isSorted(l2)) - (l1, l2) match { - case (Cons(h1, t1), Cons(h2,t2)) => - if (h1 <= h2) - Cons(h1, merge(t1, l2)) - else - Cons(h1, merge(l1, t2)) // FIXME h1 instead of h2 - case (Nil(), _) => l2 - case (_, Nil()) => l1 - } - } ensuring { res => - isSorted(res) && - res.size == l1.size + l2.size && - res.content == l1.content ++ l2.content - } - - def mergeSort(l : List[BigInt]) : List[BigInt] = { l match { - case Nil() => l - case Cons(_, Nil()) => l - case other => - val (l1, l2) = split(other) - merge(mergeSort(l1), mergeSort(l2)) - }} ensuring { res => - isSorted(res) && - res.content == l.content && - res.size == l.size - } -} - - - diff --git a/src/test/resources/regression/synthesis/Church/Add.scala b/src/test/resources/regression/synthesis/Church/Add.scala deleted file mode 100644 index 460e1651e37fc66fe4752d3d2c6e38b87184be3d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Church/Add.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Numerals { - sealed abstract class Num - case object Z extends Num - case class S(pred: Num) extends Num - - def value(n: Num): BigInt = { - n match { - case Z => BigInt(0) - case S(p) => BigInt(1) + value(p) - } - } ensuring (_ >= 0) - - def add(x: Num, y: Num): Num = { - choose { (r: Num) => - value(r) == value(x) + value(y) - } - } -} diff --git a/src/test/resources/regression/synthesis/Church/Distinct.scala b/src/test/resources/regression/synthesis/Church/Distinct.scala deleted file mode 100644 index 53379f02cbb42f2fa727f850b41f97c0b9c9bc79..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Church/Distinct.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Numerals { - sealed abstract class Num - case object Z extends Num - case class S(pred: Num) extends Num - - def value(n: Num): BigInt = { - n match { - case Z => BigInt(0) - case S(p) => BigInt(1) + value(p) - } - } ensuring (_ >= 0) - - def add(x: Num, y: Num): Num = (x match { - case Z => y - case S(p) => add(p, S(y)) - }) ensuring (value(_) == value(x) + value(y)) - - def distinct(x: Num, y: Num): Num = { - choose { (r : Num) => - r != x && r != y - } - } -} diff --git a/src/test/resources/regression/synthesis/Church/Mult.scala b/src/test/resources/regression/synthesis/Church/Mult.scala deleted file mode 100644 index 6c8e0f088d34373832ff5ce3462f15e2182cb044..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Church/Mult.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Numerals { - sealed abstract class Num - case object Z extends Num - case class S(pred: Num) extends Num - - def value(n: Num): BigInt = { - n match { - case Z => BigInt(0) - case S(p) => BigInt(1) + value(p) - } - } ensuring (_ >= 0) - - def add(x: Num, y: Num): Num = (x match { - case Z => y - case S(p) => add(p, S(y)) - }) ensuring (value(_) == value(x) + value(y)) - - def mult(x: Num, y: Num): Num = { - choose { (r: Num) => - value(r) == value(x) * value(y) - } - } -} diff --git a/src/test/resources/regression/synthesis/Church/Squared.scala b/src/test/resources/regression/synthesis/Church/Squared.scala deleted file mode 100644 index 9c7f042332a035a4a684fb299e215deebc7b1680..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Church/Squared.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Numerals { - sealed abstract class Num - case object Z extends Num - case class S(pred: Num) extends Num - - def value(n:Num) : BigInt = { - n match { - case Z => BigInt(0) - case S(p) => BigInt(1) + value(p) - } - } ensuring (_ >= 0) - - def add(x: Num, y: Num): Num = (x match { - case Z => y - case S(p) => add(p, S(y)) - }) ensuring (value(_) == value(x) + value(y)) - - def mult(x: Num, y: Num): Num = (y match { - case S(p) => - add(mult(x, p), x) - case Z => - Z - }) ensuring { value(_) == value(x) * value(y) } - - def squared(x: Num): Num = { - choose { (r: Num) => - value(r) == value(x) * value(x) - } - } -} diff --git a/src/test/resources/regression/synthesis/Examples/Length.scala b/src/test/resources/regression/synthesis/Examples/Length.scala deleted file mode 100644 index 04462a0b877f2a92bbaa23a88281455e060671bf..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Examples/Length.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.collection._ -import leon.lang._ -import leon.lang.synthesis._ - -object Length { - - def foo(l : List[Int]) : Int = - choose { res:Int => (l, res) passes { - case Nil() => 0 - case Cons(a, Nil()) => 2 - case Cons(_, Cons(_, Cons(_, Cons(_, Nil())))) => 8 - }} - -} diff --git a/src/test/resources/regression/synthesis/Holes/Hole1.scala b/src/test/resources/regression/synthesis/Holes/Hole1.scala deleted file mode 100644 index 37990792d8b83a2ea1ebbfac0c628487153a5053..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Holes/Hole1.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon.lang.synthesis._ - -object Holes { - def abs3(a: BigInt) = { - if (?(a > 0, a < 0)) { - a - } else { - -a - } - } ensuring { - _ >= 0 - } -} diff --git a/src/test/resources/regression/synthesis/List/Delete.scala b/src/test/resources/regression/synthesis/List/Delete.scala deleted file mode 100644 index 15d6163694f3f2759de218b92119e6a5109f4458..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/List/Delete.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Delete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => BigInt(0) - case Cons(_, t) => BigInt(1) + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def delete(in1: List, v: BigInt) = { - choose { (out : List) => - content(out) == content(in1) -- Set(v) - } - } -} diff --git a/src/test/resources/regression/synthesis/List/Diff.scala b/src/test/resources/regression/synthesis/List/Diff.scala deleted file mode 100644 index 2e1136aeaf74d216be3a097306a352ffd5665501..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/List/Diff.scala +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Diff { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => BigInt(0) - case Cons(_, t) => BigInt(1) + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def delete(in1: List, v: BigInt): List = { - in1 match { - case Cons(h,t) => - if (h == v) { - delete(t, v) - } else { - Cons(h, delete(t, v)) - } - case Nil => - Nil - } - } ensuring { content(_) == content(in1) -- Set(v) } - - def diff(in1: List, in2: List) = { - choose { (out : List) => - content(out) == content(in1) -- content(in2) - } - } -} diff --git a/src/test/resources/regression/synthesis/List/Insert.scala b/src/test/resources/regression/synthesis/List/Insert.scala deleted file mode 100644 index 831fa6815a4e3b041305479f0744d2e7d7361db1..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/List/Insert.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Insert { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => BigInt(0) - case Cons(_, t) => BigInt(1) + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def insert(in1: List, v: BigInt) = { - choose { (out : List) => - content(out) == content(in1) ++ Set(v) - } - } -} diff --git a/src/test/resources/regression/synthesis/List/Split1.scala b/src/test/resources/regression/synthesis/List/Split1.scala deleted file mode 100644 index 91b089a36e5e2a66899eeb1a5b533d07a9f08409..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/List/Split1.scala +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object List { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => BigInt(0) - case Cons(_, t) => BigInt(1) + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def abs(i: BigInt) : BigInt = { - if(i < 0) -i else i - } ensuring(_ >= 0) - - def split(list: List): (List, List) = { - choose { (res: (List, List)) => - (content(res._1) ++ content(res._2) == content(list)) - } - } - -} diff --git a/src/test/resources/regression/synthesis/List/Split2.scala b/src/test/resources/regression/synthesis/List/Split2.scala deleted file mode 100644 index 1bcfacd85f52ddc21231339e0c86b67ef3f44c35..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/List/Split2.scala +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object List { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => BigInt(0) - case Cons(_, t) => BigInt(1) + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def abs(i: BigInt) : BigInt = { - if(i < 0) -i else i - } ensuring(_ >= 0) - - def split(list: List): (List, List) = { - choose { (res : (List, List)) => - (content(res._1) ++ content(res._2) == content(list)) && - (abs(size(res._1) - size(res._2)) <= 1) - } - } - -} diff --git a/src/test/resources/regression/synthesis/List/Split3.scala b/src/test/resources/regression/synthesis/List/Split3.scala deleted file mode 100644 index 35fe12e7e045fa21733d16c53f45e939b3fdc2b4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/List/Split3.scala +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object List { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => BigInt(0) - case Cons(_, t) => BigInt(1) + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def abs(i: BigInt): BigInt = { - if(i < 0) -i else i - } ensuring(_ >= 0) - - def tcons(h1: BigInt, h2: BigInt, tl: (List, List)) = { - (Cons(h1, tl._1), Cons(h2, tl._2)) - } - - def split(list : List): (List,List) = { - choose { (res: (List,List)) => - (content(res._1) ++ content(res._2) == content(list)) && - (abs(size(res._1) - size(res._2)) <= 1) && - (size(res._1) + size(res._2) == size(list)) - } - } - -} diff --git a/src/test/resources/regression/synthesis/List/Union.scala b/src/test/resources/regression/synthesis/List/Union.scala deleted file mode 100644 index 8c4a4e71d21d1ab3dfb70024abd7ee5411d8b57b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/List/Union.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Union { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => BigInt(0) - case Cons(_, t) => BigInt(1) + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def union(in1: List, in2: List) = { - choose { (out : List) => - content(out) == content(in1) ++ content(in2) - } - } -} diff --git a/src/test/resources/regression/synthesis/Misc/HolesBug.scala b/src/test/resources/regression/synthesis/Misc/HolesBug.scala deleted file mode 100644 index 4a7ccb5680a1a9b1dd3a618e1e427c38a32a9aa9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Misc/HolesBug.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object HolesBug { - def plop(a: BigInt, b: BigInt): BigInt = { - if (a < b) { - ???[BigInt] - } else { - ???[BigInt] - } - } ensuring { res => - res > 0 - } -} - diff --git a/src/test/resources/regression/synthesis/Misc/RunLength.scala b/src/test/resources/regression/synthesis/Misc/RunLength.scala deleted file mode 100644 index 1969220be8bee9ad7fed57ff7070b1560d32ebe9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Misc/RunLength.scala +++ /dev/null @@ -1,50 +0,0 @@ -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ -import leon.collection._ - -object RunLength { - - def decode[A](l: List[(BigInt, A)]): List[A] = { - def fill[A](i: BigInt, a: A): List[A] = { - if (i > 0) a :: fill(i - 1, a) - else Nil[A]() - } - l match { - case Nil() => Nil[A]() - case Cons((i, x), xs) => - fill(i, x) ++ decode(xs) - } - } - - def legal[A](l: List[(BigInt, A)]): Boolean = l match { - case Nil() => true - case Cons((i, _), Nil()) => i > 0 - case Cons((i, x), tl@Cons((_, y), _)) => - i > 0 && x != y && legal(tl) - } - - def encode[A](l: List[A]): List[(BigInt, A)] = { - // Solution - /*l match { - case Nil() => Nil[(BigInt, A)]() - case Cons(x, xs) => - val rec = encode(xs) - rec match { - case Nil() => - Cons( (BigInt(1), x), Nil[(BigInt,A)]()) - case Cons( (recC, recEl), recTl) => - if (x == recEl) { - Cons( (1+recC, x), recTl) - } else { - Cons( (BigInt(1), x), rec ) - } - } - }*/ - ???[List[(BigInt, A)]] - } ensuring { - (res: List[(BigInt, A)]) => - legal(res) && decode(res) == l - } - -} diff --git a/src/test/resources/regression/synthesis/Misc/Unapply.scala b/src/test/resources/regression/synthesis/Misc/Unapply.scala deleted file mode 100644 index f7f2c232d390a03f2d60e09ea0f3ae6408e7c148..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/Misc/Unapply.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ - -object Unap { - def unapply[A, B](i: (Int, B, A)): Option[(A, B)] = - if (i._1 == 0) None() else Some((i._3, i._2)) -} - -object Unapply { - def bar(i: Int, b: Boolean): Boolean = (i, b, ()) match { - case Unap(_, b) if b => b - case Unap((), b) => - choose( (b1: Boolean) => b == b1 == i < 0 ) - } - -} diff --git a/src/test/resources/regression/synthesis/SortedList/Delete.scala b/src/test/resources/regression/synthesis/SortedList/Delete.scala deleted file mode 100644 index ca2886154cd1501e972bb24bc481e045bd8e0c12..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/SortedList/Delete.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Complete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 > x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def delete(in1: List, v: BigInt) = { - require(isSorted(in1)) - choose { (out: List) => - (content(out) == content(in1) -- Set(v)) && isSorted(out) - } - } -} diff --git a/src/test/resources/regression/synthesis/SortedList/Diff.scala b/src/test/resources/regression/synthesis/SortedList/Diff.scala deleted file mode 100644 index 99813b1971717aec406853e95edb7157023f3712..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/SortedList/Diff.scala +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Complete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 > x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def delete(in1: List, v: BigInt): List = { - require(isSorted(in1)) - in1 match { - case Cons(h,t) => - if (h < v) { - Cons(h, delete(t, v)) - } else if (h == v) { - delete(t, v) - } else { - in1 - } - case Nil => - Nil - } - } ensuring { res => content(res) == content(in1) -- Set(v) && isSorted(res) } - - def diff(in1: List, in2: List) = { - require(isSorted(in1) && isSorted(in2)) - choose { (out: List) => - (content(out) == content(in1) -- content(in2)) && isSorted(out) - } - } - -} diff --git a/src/test/resources/regression/synthesis/SortedList/Insert1.scala b/src/test/resources/regression/synthesis/SortedList/Insert1.scala deleted file mode 100644 index 3aac75ecde19dcfcfe314a90421a88abd7d9e588..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/SortedList/Insert1.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Complete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 > x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def insert(in1: List, v: BigInt) = { - require(isSorted(in1)) - choose { (out: List) => - (content(out) == content(in1) ++ Set(v)) && isSorted(out) - } - } - -} diff --git a/src/test/resources/regression/synthesis/SortedList/Insert2.scala b/src/test/resources/regression/synthesis/SortedList/Insert2.scala deleted file mode 100644 index 7327dafaf0c247bbd2ec345d4219aa606bfdc310..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/SortedList/Insert2.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Complete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 > x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def insert(in1: List, v: BigInt) = { - require(isSorted(in1)) - choose { (out: List) => - (content(out) == content(in1) ++ Set(v)) && isSorted(out) && size(out) == size(in1) + 1 - } - } - -} diff --git a/src/test/resources/regression/synthesis/SortedList/InsertSort.scala b/src/test/resources/regression/synthesis/SortedList/InsertSort.scala deleted file mode 100644 index 4e319f35773e9c93869277fd3b0c1bc1bdc6111c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/SortedList/InsertSort.scala +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Complete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 > x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def insert(in1: List, v: BigInt): List = { - require(isSorted(in1)) - in1 match { - case Cons(h, t) => - if (v < h) { - Cons(v, in1) - } else if (v == h) { - in1 - } else { - Cons(h, insert(t, v)) - } - case Nil => - Cons(v, Nil) - } - - } ensuring { res => (content(res) == content(in1) ++ Set(v)) && isSorted(res) } - - def sort(list: List): List = { - choose { (res: List) => - isSorted(res) && - content(list) == content(res) - } - } - -} diff --git a/src/test/resources/regression/synthesis/SortedList/Union.scala b/src/test/resources/regression/synthesis/SortedList/Union.scala deleted file mode 100644 index 7df087b857e8ae3c2a99e130bc95bf6d1f8046c9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/SortedList/Union.scala +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Complete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 > x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def insert(in1: List, v: BigInt): List = { - require(isSorted(in1)) - in1 match { - case Cons(h, t) => - if (v < h) { - Cons(v, in1) - } else if (v == h) { - in1 - } else { - Cons(h, insert(t, v)) - } - case Nil => - Cons(v, Nil) - } - - } ensuring { res => (content(res) == content(in1) ++ Set(v)) && isSorted(res) } - - def union(in1: List, in2: List) = { - require(isSorted(in1) && isSorted(in2)) - choose { (out: List) => - (content(out) == content(in1) ++ content(in2)) && isSorted(out) - } - } -} diff --git a/src/test/resources/regression/synthesis/StrictSortedList/Delete.scala b/src/test/resources/regression/synthesis/StrictSortedList/Delete.scala deleted file mode 100644 index 6e75398bfc53cf911cf20665bb47f2f76111732e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/StrictSortedList/Delete.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Delete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 >= x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def delete(in1: List, v: BigInt) = { - require(isSorted(in1)) - choose { (out : List) => - (content(out) == content(in1) -- Set(v)) && isSorted(out) - } - } -} diff --git a/src/test/resources/regression/synthesis/StrictSortedList/Insert.scala b/src/test/resources/regression/synthesis/StrictSortedList/Insert.scala deleted file mode 100644 index 4f9e644f8a83813d46e44e68373a9409a4e791ff..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/StrictSortedList/Insert.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Complete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 >= x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def insert(in1: List, v: BigInt) = { - require(isSorted(in1)) - choose { (out : List) => - (content(out) == content(in1) ++ Set(v)) && isSorted(out) - } - } - -} diff --git a/src/test/resources/regression/synthesis/StrictSortedList/Union.scala b/src/test/resources/regression/synthesis/StrictSortedList/Union.scala deleted file mode 100644 index 3765c92eb096d0463b262ad0aab5ce97897c6f92..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/synthesis/StrictSortedList/Union.scala +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.annotation._ - -object Complete { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case object Nil extends List - - def size(l: List) : BigInt = (l match { - case Nil => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List): Set[BigInt] = l match { - case Nil => Set.empty[BigInt] - case Cons(i, t) => Set(i) ++ content(t) - } - - def isSorted(list : List) : Boolean = list match { - case Nil => true - case Cons(_, Nil) => true - case Cons(x1, Cons(x2, _)) if(x1 >= x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def insert(in1: List, v: BigInt): List = { - require(isSorted(in1)) - in1 match { - case Cons(h, t) => - if (v < h) { - Cons(v, in1) - } else if (v == h) { - in1 - } else { - Cons(h, insert(t, v)) - } - case Nil => - Cons(v, Nil) - } - - } ensuring { res => (content(res) == content(in1) ++ Set(v)) && isSorted(res) } - - def union(in1: List, in2: List) = { - require(isSorted(in1) && isSorted(in2)) - choose { (out : List) => - (content(out) == content(in1) ++ content(in2)) && isSorted(out) - } - } -} diff --git a/src/test/resources/regression/termination/looping/LambdaCalculus.scala b/src/test/resources/regression/termination/looping/LambdaCalculus.scala deleted file mode 100644 index 16026eed830a1eff0e2ec0b581d24c0e041cfb0b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/LambdaCalculus.scala +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object LambdaCalculus { - abstract class Term - case class Var(x: BigInt) extends Term - case class Abs(x: BigInt, body: Term) extends Term - case class App(func: Term, arg: Term) extends Term - - def fv(t: Term): Set[BigInt] = t match { - case Var(x) => Set(x) - case Abs(x, body) => fv(body) ++ Set(x) - case App(func, arg) => fv(func) ++ fv(arg) - } - - // [x->u]t - def subst(x: BigInt, u: Term, t: Term): Term = t match { - case Var(y) => if (x == y) u else t - case Abs(y, body) => if (x == y) t else Abs(y, subst(x, u, body)) - case App(f, a) => App(subst(x, u, f), subst(x, u, a)) - } - - /* Termination checker (LoopProcessor) says: - ✗ Non-terminating for call: looping_eval(App(Abs(0, App(Var(0), Var(0))), Abs(0, App(Var(0), Var(0))))) - i.e. - (λx. x x)(λx. x x) - This is the well-known "omega". - */ - // big step call-by-value looping_evaluation - def looping_eval(t: Term): Option[Term] = (t match { - case App(t1, t2) => looping_eval(t1) match { - case Some(Abs(x, body)) => looping_eval(t2) match { - case Some(v2) => looping_eval(subst(x, v2, body)) - case None() => None[Term]() - } - case _ => None[Term]() // stuck - } - case _ => Some(t) // Abs or Var, already a value - }) ensuring { res => res match { - case Some(t) => isValue(t) - case None() => true - }} - - def isValue(t: Term): Boolean = t match { - case Var(x) => true - case Abs(x, body) => true - case App(f, a) => false - } - -} diff --git a/src/test/resources/regression/termination/looping/Numeric1.scala b/src/test/resources/regression/termination/looping/Numeric1.scala deleted file mode 100644 index aa5ecb6781cd92fb839d7628c045c486364b78ce..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/Numeric1.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Numeric { - // division by 0 loops - def looping(x: Int, y: Int): Int = { - if (x < y) 0 - else 1 + looping(x - y, y) - } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/termination/looping/Numeric2.scala b/src/test/resources/regression/termination/looping/Numeric2.scala deleted file mode 100644 index 0ce10f19818fe5f3b5878b42d83b86a4bd88b297..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/Numeric2.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Numeric { - def looping1(x: Int): Int = looping2(x - 1) - - def looping2(x: Int): Int = looping3(x - 1) - - def looping3(x: Int): Int = looping4(x - 1) - - def looping4(x: Int): Int = looping1(x + 3) -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/termination/looping/Numeric3.scala b/src/test/resources/regression/termination/looping/Numeric3.scala deleted file mode 100644 index adf5dbea6cac2f53771fed4633a5ae59a15b1c8f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/Numeric3.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Numeric3 { - def looping(x: Int) : Int = if (x > 0) looping(x - 1) else looping(5) -} - - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/termination/looping/OddEven.scala b/src/test/resources/regression/termination/looping/OddEven.scala deleted file mode 100644 index 1a2497777b389d881879f4cfe0e79715abdd7249..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/OddEven.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -object Test { - - def looping_isOdd(n: BigInt): Boolean = { - looping_isEven(n-1) - } ensuring { res => (n % 2 == 1) == res } - - def looping_isEven(n: BigInt): Boolean = { - looping_isOdd(n-1) - } ensuring { res => (n % 2 == 0) == res } - - -} \ No newline at end of file diff --git a/src/test/resources/regression/termination/looping/Queue.scala b/src/test/resources/regression/termination/looping/Queue.scala deleted file mode 100644 index 7685817f075f330062c2dfb6deb503ebc9ecd258..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/Queue.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -import leon._ -import leon.lang._ -import leon.collection._ - -sealed abstract class Queue[T] { - - def looping_1: BigInt = { - this match { - case QEmpty() => BigInt(0) - case QCons(f, r) => f.size + r.size - } - } ensuring (res => res == this.looping_2.size && res >= 0) - - def looping_2: List[T] = (this match { - case QEmpty() => Nil[T]() - case QCons(f, r) => f ++ r.reverse - }) ensuring (resOne => this.looping_3 == resOne.content && resOne.size == this.looping_1 && resOne.size >= 0) - - - def looping_3: Set[T] = (this match { - case QEmpty() => Set[T]() - case QCons(f, r) => f.content ++ r.content - }) ensuring (res => res == this.looping_2.content) -} - -case class QCons[T](f : List[T], r: List[T]) extends Queue[T] -case class QEmpty[T]() extends Queue[T] diff --git a/src/test/resources/regression/termination/looping/Term.scala b/src/test/resources/regression/termination/looping/Term.scala deleted file mode 100644 index c6c79d797bc124dc8fb7dabf42b6598911407d6b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/Term.scala +++ /dev/null @@ -1,31 +0,0 @@ -import leon.collection._ -import leon.lang._ -import leon.annotation._ - -import scala.language.postfixOps - -object Termination { - - case class Task(tick: BigInt) { - require(tick >= 0) - } - - case class Core(tasks: Task, current: Option[BigInt]) - - - def insertBack(): Core = Core(Task(0), None()) - - - def looping(c: Core): Core = { - c.current match { - case Some(_) => looping(c) - case None() => insertBack() - } - } - - @ignore - def main(args: Array[String]) { - looping(Core(Task(0), Some(0))) - } - -} diff --git a/src/test/resources/regression/termination/looping/Termination_failling1.scala b/src/test/resources/regression/termination/looping/Termination_failling1.scala deleted file mode 100644 index ecadd0e62ad62dad9cac6e5693d25e6857f79cae..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/Termination_failling1.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Termination { - abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - def looping1(list: List) : Int = looping2(list) - - def looping2(list: List) : Int = looping1(list) - - def calling1(list: List, b: Boolean) : Int = if(b) calling2(list) else looping1(list) - - def calling2(list: List) : Int = list match { - case Cons(head, tail) => calling1(tail, true) - case Nil() => 0 - } - - def ok(list: List) : Int = 0 -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/termination/looping/UniversalEquality.scala b/src/test/resources/regression/termination/looping/UniversalEquality.scala deleted file mode 100644 index 15d8ec7e9c9bc3345e4ceb9e66bc4385cfc075e5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/UniversalEquality.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object test { - - def universalEquality(e1: BigInt, e2: BigInt): Boolean = { - val b = looping_proveEquality(e1, e2) - e1 == e2 - }.holds - - def looping_proveEquality(a: BigInt, b: BigInt): Boolean = { - looping_proveEquality(a, b) - } ensuring { res => res == (a == b) && res } - -} diff --git a/src/test/resources/regression/termination/looping/WrongFibonacci.scala b/src/test/resources/regression/termination/looping/WrongFibonacci.scala deleted file mode 100644 index 7e9b4938bd2ff018c49aae301c09e492bd86f52f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/looping/WrongFibonacci.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -object Test { - - def looping_fib(n: BigInt): BigInt = { - looping_fib(n-1) + looping_fib(n-2) - } ensuring {res => res == (5*n + 1)*(5*n - 1)} - -} diff --git a/src/test/resources/regression/termination/valid/Ackermann.scala b/src/test/resources/regression/termination/valid/Ackermann.scala deleted file mode 100644 index 11ea76bee4ae9ae9c8225642d413d0f9054691f1..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/Ackermann.scala +++ /dev/null @@ -1,10 +0,0 @@ -import leon.lang._ - -object Ackermann { - def ackermann(m: BigInt, n: BigInt): BigInt = { - require(m >= 0 && n >= 0) - if (m == 0) n + 1 - else if (n == 0) ackermann(m - 1, 1) - else ackermann(m - 1, ackermann(m, n - 1)) - } -} diff --git a/src/test/resources/regression/termination/valid/CountTowardsZero.scala b/src/test/resources/regression/termination/valid/CountTowardsZero.scala deleted file mode 100644 index 46163dbd0fd2bbb42805b9cf8989eb29d11585b5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/CountTowardsZero.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -object Test { - def f(x: BigInt): BigInt = { - if (x == 0) { - BigInt(0) - } else if (x > 0) { - f(x-1)+2 - } else if (x < 0) { - f(x+1)-2 - } else { - BigInt(33) - } - } ensuring (_ == x*2) -} diff --git a/src/test/resources/regression/termination/valid/Fibonacci.scala b/src/test/resources/regression/termination/valid/Fibonacci.scala deleted file mode 100644 index 8ea5571565a071b8d7646ed35aa0d15a7db046fe..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/Fibonacci.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Fibonacci { - def fib(x: BigInt) : BigInt = { - require(x >= 0) - if(x < 2) { - x - } else { - fib(x - 1) + fib(x - 2) - } - } - - // requires that fib is universally quantified to work... - def check() : Boolean = { - fib(5) == BigInt(5) - } ensuring(_ == true) -} diff --git a/src/test/resources/regression/termination/valid/HOTermination.scala b/src/test/resources/regression/termination/valid/HOTermination.scala deleted file mode 100644 index 8947a89ca7aebf72027ce925ca488e2503ad4575..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/HOTermination.scala +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -import leon.lang._ - -object HOTermination { - abstract class List[T] - case class Cons[T](head: T, tail: List[T]) extends List[T] - case class Nil[T]() extends List[T] - - abstract class Option[T] - case class Some[T](value: T) extends Option[T] - case class None[T]() extends Option[T] - - def map[A,B](list: List[A], f: A => B): List[B] = list match { - case Cons(head, tail) => Cons(f(head), map(tail, f)) - case Nil() => Nil() - } - - abstract class Expr - case class Invocation(e: Expr, args: List[Expr]) extends Expr - case class Addition(e1: Expr, e2: Expr) extends Expr - case class Variable(i: Int) extends Expr - - def transform(e: Expr, f: Expr => Option[Expr]): Expr = { - f(e) match { - case Some(newExpr) => newExpr - case None() => e match { - case Invocation(c, args) => - val newC = transform(c, f) - val newArgs = map(args, (x: Expr) => transform(x, f)) - Invocation(newC, newArgs) - case Addition(e1, e2) => - Addition(transform(e1, f), transform(e2, f)) - case Variable(i) => e - } - } - } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/termination/valid/ListWithSize.scala b/src/test/resources/regression/termination/valid/ListWithSize.scala deleted file mode 100644 index b432e65542d73614888710b4f28a6d95dc343bbe..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/ListWithSize.scala +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object ListWithSize { - sealed abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - sealed abstract class IntPairList - case class IPCons(head: IntPair, tail: IntPairList) extends IntPairList - case class IPNil() extends IntPairList - - sealed abstract class IntPair - case class IP(fst: Int, snd: Int) extends IntPair - - // proved with unrolling=0 - def size(l: List) : Int = (l match { - case Nil() => 0 - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def iplSize(l: IntPairList) : Int = (l match { - case IPNil() => 0 - case IPCons(_, xs) => 1 + iplSize(xs) - }) ensuring(_ >= 0) - - def zip(l1: List, l2: List) : IntPairList = { - // try to comment this and see how pattern-matching becomes - // non-exhaustive and post-condition fails - require(size(l1) == size(l2)) - - l1 match { - case Nil() => IPNil() - case Cons(x, xs) => l2 match { - case Cons(y, ys) => IPCons(IP(x, y), zip(xs, ys)) - } - } - } ensuring(iplSize(_) == size(l1)) - - def sizeTailRec(l: List) : Int = sizeTailRecAcc(l, 0) - def sizeTailRecAcc(l: List, acc: Int) : Int = { - require(acc >= 0) - l match { - case Nil() => acc - case Cons(_, xs) => sizeTailRecAcc(xs, acc+1) - } - } ensuring(res => res == size(l) + acc) - - def sizesAreEquiv(l: List) : Boolean = { - size(l) == sizeTailRec(l) - }.holds - - def content(l: List) : Set[Int] = l match { - case Nil() => Set.empty[Int] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def sizeAndContent(l: List) : Boolean = { - size(l) == 0 || content(l) != Set.empty[Int] - }.holds - - def drunk(l : List) : List = (l match { - case Nil() => Nil() - case Cons(x,l1) => Cons(x,Cons(x,drunk(l1))) - }) ensuring (size(_) == 2 * size(l)) - - // proved with unrolling=1 - def funnyCons(x: Int, l: List) : List = (l match { - case Nil() => Cons(x, Nil()) - case c @ Cons(_,_) => Cons(x, c) - }) ensuring(size(_) > 0) - - // proved with unrolling=2 - def reverse(l: List) : List = reverse0(l, Nil()) ensuring(content(_) == content(l)) - def reverse0(l1: List, l2: List) : List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => reverse0(xs, Cons(x, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - def append(l1 : List, l2 : List) : List = (l1 match { - case Nil() => l2 - case Cons(x,xs) => Cons(x, append(xs, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def nilAppend(l : List) : Boolean = (append(l, Nil()) == l).holds - - // unclear if we needed this--it was meant to force folding - //def appendFold(x : Int, xs : List, ys : List) : Boolean = { - // true - //} ensuring (res => res && Cons(x,append(xs, ys)) == append(Cons(x,xs), ys)) - - @induct - def appendAssoc(xs : List, ys : List, zs : List) : Boolean = - (append(append(xs, ys), zs) == append(xs, append(ys, zs))).holds - - def revAuxBroken(l1 : List, e : Int, l2 : List) : Boolean = { - (append(reverse(l1), Cons(e,l2)) == reverse0(l1, l2)) - } // holds - - @induct - def reverse0exposed(l1 : List, l2 : List) : Boolean = { - (reverse0(l1, l2) == append(reverse(l1), l2)) - } // holds - - @induct - def sizeAppend(l1 : List, l2 : List) : Boolean = - (size(append(l1, l2)) == size(l1) + size(l2)).holds - - // proved with unrolling=4 - @induct - def concat(l1: List, l2: List) : List = - concat0(l1, l2, Nil()) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def concat0(l1: List, l2: List, l3: List) : List = (l1 match { - case Nil() => l2 match { - case Nil() => reverse(l3) - case Cons(y, ys) => { - concat0(Nil(), ys, Cons(y, l3)) - } - } - case Cons(x, xs) => concat0(xs, l2, Cons(x, l3)) - }) ensuring(content(_) == content(l1) ++ content(l2) ++ content(l3)) - - def reverseConcat0(l1: List, l2: List) : Boolean = { - reverse(concat(l1, l2)) == concat(reverse(l2), reverse(l1)) - } // holds - - // proved with unrolling=2 ??? - def reverseConcat(l1: List, l2: List) : Boolean = { - reverse(concat(l1, l2)) == concat(reverse(l2), reverse(l1)) - } // holds -} diff --git a/src/test/resources/regression/termination/valid/NNF.scala b/src/test/resources/regression/termination/valid/NNF.scala deleted file mode 100644 index 32ecd1916f33e3eec5fbcd52a9de2c2342792565..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/NNF.scala +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object PropositionalLogic { - - sealed abstract class Formula - case class And(lhs: Formula, rhs: Formula) extends Formula - case class Or(lhs: Formula, rhs: Formula) extends Formula - case class Implies(lhs: Formula, rhs: Formula) extends Formula - case class Not(f: Formula) extends Formula - case class Literal(id: BigInt) extends Formula - - def simplify(f: Formula): Formula = (f match { - case And(lhs, rhs) => And(simplify(lhs), simplify(rhs)) - case Or(lhs, rhs) => Or(simplify(lhs), simplify(rhs)) - case Implies(lhs, rhs) => Or(Not(simplify(lhs)), simplify(rhs)) - case Not(f) => Not(simplify(f)) - case Literal(_) => f - }) ensuring(isSimplified(_)) - - def isSimplified(f: Formula): Boolean = f match { - case And(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Or(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Implies(_,_) => false - case Not(f) => isSimplified(f) - case Literal(_) => true - } - - def nnf(formula: Formula): Formula = (formula match { - case And(lhs, rhs) => And(nnf(lhs), nnf(rhs)) - case Or(lhs, rhs) => Or(nnf(lhs), nnf(rhs)) - case Implies(lhs, rhs) => nnf(Or(Not(lhs), rhs)) - case Not(And(lhs, rhs)) => Or(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Or(lhs, rhs)) => And(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Implies(lhs, rhs)) => And(nnf(lhs), nnf(Not(rhs))) - case Not(Not(f)) => nnf(f) - case Not(Literal(_)) => formula - case Literal(_) => formula - }) ensuring(isNNF(_)) - - def isNNF(f: Formula): Boolean = f match { - case And(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Or(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Implies(lhs, rhs) => false - case Not(Literal(_)) => true - case Not(_) => false - case Literal(_) => true - } - - def evalLit(id : BigInt) : Boolean = (id == 42) // could be any function - def eval(f: Formula) : Boolean = f match { - case And(lhs, rhs) => eval(lhs) && eval(rhs) - case Or(lhs, rhs) => eval(lhs) || eval(rhs) - case Implies(lhs, rhs) => !eval(lhs) || eval(rhs) - case Not(f) => !eval(f) - case Literal(id) => evalLit(id) - } - - @induct - def simplifySemantics(f: Formula) : Boolean = { - eval(f) == eval(simplify(f)) - } holds - - // Note that matching is exhaustive due to precondition. - def vars(f: Formula): Set[BigInt] = { - require(isNNF(f)) - f match { - case And(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Or(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Not(Literal(i)) => Set[BigInt](i) - case Literal(i) => Set[BigInt](i) - } - } - - def fv(f : Formula) = { vars(nnf(f)) } - - @induct - def wrongCommutative(f: Formula) : Boolean = { - nnf(simplify(f)) == simplify(nnf(f)) - } holds - - @induct - def simplifyPreservesNNF(f: Formula) : Boolean = { - require(isNNF(f)) - isNNF(simplify(f)) - } holds - - @induct - def nnfIsStable(f: Formula) : Boolean = { - require(isNNF(f)) - nnf(f) == f - } holds - - @induct - def simplifyIsStable(f: Formula) : Boolean = { - require(isSimplified(f)) - simplify(f) == f - } holds -} diff --git a/src/test/resources/regression/termination/valid/Numeric1.scala b/src/test/resources/regression/termination/valid/Numeric1.scala deleted file mode 100644 index 684aeb4035cc7552665e1743c71566a061f58a1d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/Numeric1.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Numeric { - - def f1(x: BigInt): BigInt = f2(x - 2) - - def f2(x: BigInt): BigInt = if (x < 0) 0 else f1(x + 1) -} diff --git a/src/test/resources/regression/termination/valid/Queue.scala b/src/test/resources/regression/termination/valid/Queue.scala deleted file mode 100644 index 742bc19824de9f7885d74a37676df7915be6d568..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/Queue.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -import leon._ -import leon.lang._ -import leon.collection._ - -sealed abstract class Queue[T] { - - def size: BigInt = { - this match { - case QEmpty() => BigInt(0) - case QCons(f, r) => f.size + r.size - } - } ensuring (res => res == this.toList.size && res >= 0) - - def toList: List[T] = (this match { - case QEmpty() => Nil[T]() - case QCons(f, r) => f ++ r.reverse - }) ensuring (resOne => this.content == resOne.content && resOne.size >= 0) - - def content: Set[T] = this match { - case QEmpty() => Set() - case QCons(f, r) => f.content ++ r.content - } -} - -case class QCons[T](f : List[T], r: List[T]) extends Queue[T] -case class QEmpty[T]() extends Queue[T] diff --git a/src/test/resources/regression/termination/valid/QuickSort.scala b/src/test/resources/regression/termination/valid/QuickSort.scala deleted file mode 100644 index ca3396ab83b0fb3f605eb5bde6c6528f31e6998e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/QuickSort.scala +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object QuickSort { - sealed abstract class List - case class Cons(head:Int,tail:List) extends List - case class Nil() extends List - - def contents(l: List): Set[Int] = l match { - case Nil() => Set.empty - case Cons(x,xs) => contents(xs) ++ Set(x) - } - - def is_sorted(l: List): Boolean = l match { - case Nil() => true - case Cons(x,Nil()) => true - case Cons(x,Cons(y,xs)) => x<=y && is_sorted(Cons(y,xs)) - } - - def rev_append(aList:List,bList:List): List = aList match { - case Nil() => bList - case Cons(x,xs) => rev_append(xs,Cons(x,bList)) - } - - def reverse(list:List): List = rev_append(list,Nil()) - - def append(aList:List,bList:List): List = aList match { - case Nil() => bList - case _ => rev_append(reverse(aList),bList) - } - - def greater(n:Int,list:List) : List = list match { - case Nil() => Nil() - case Cons(x,xs) => if (n < x) Cons(x,greater(n,xs)) else greater(n,xs) - } - - def smaller(n:Int,list:List) : List = list match { - case Nil() => Nil() - case Cons(x,xs) => if (n>x) Cons(x,smaller(n,xs)) else smaller(n,xs) - } - - def equals(n:Int,list:List) : List = list match { - case Nil() => Nil() - case Cons(x,xs) => if (n==x) Cons(x,equals(n,xs)) else equals(n,xs) - } - - def quickSort(list:List): List = (list match { - case Nil() => Nil() - case Cons(x,Nil()) => list - case Cons(x,xs) => append(append(quickSort(smaller(x,xs)),Cons(x,equals(x,xs))),quickSort(greater(x,xs))) - }) ensuring(res => contents(res) == contents(list)) // && is_sorted(res)) - - @ignore - def main(args: Array[String]): Unit = { - val ls: List = Cons(5, Cons(2, Cons(4, Cons(5, Cons(1, Cons(8,Nil())))))) - - println(ls) - println(quickSort(ls)) - } -} diff --git a/src/test/resources/regression/termination/valid/RedBlackTree.scala b/src/test/resources/regression/termination/valid/RedBlackTree.scala deleted file mode 100644 index 9990cdc09f2a5880ba80d5a11bdf3174bdce3d2e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/RedBlackTree.scala +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object RedBlackTree { - sealed abstract class Color - case class Red() extends Color - case class Black() extends Color - - sealed abstract class Tree - case class Empty() extends Tree - case class Node(color: Color, left: Tree, value: Int, right: Tree) extends Tree - - def content(t : Tree) : Set[Int] = t match { - case Empty() => Set.empty - case Node(_, l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def size(t : Tree) : Int = t match { - case Empty() => 0 - case Node(_, l, v, r) => size(l) + 1 + size(r) - } - - def ins(x : Int, t: Tree): Tree = (t match { - case Empty() => Node(Red(),Empty(),x,Empty()) - case Node(c,a,y,b) => - if (x < y) balance(c, ins(x, a), y, b) - else if (x == y) Node(c,a,y,b) - else balance(c,a,y,ins(x, b)) - }) ensuring (res => ( - (content(res) == content(t) ++ Set(x)) - && (size(t) <= size(res) && size(res) < size(t) + 2) - )) - - def add(x: Int, t: Tree): Tree = { - makeBlack(ins(x, t)) - } ensuring (content(_) == content(t) ++ Set(x)) - - def balance(c: Color, a: Tree, x: Int, b: Tree): Tree = (Node(c,a,x,b) match { - case Node(Black(),Node(Red(),Node(Red(),a,xV,b),yV,c),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),Node(Red(),a,xV,Node(Red(),b,yV,c)),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),Node(Red(),b,yV,c),zV,d)) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),b,yV,Node(Red(),c,zV,d))) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(c,a,xV,b) => Node(c,a,xV,b) - }) ensuring (res => content(res) == content(Node(c,a,x,b))) - - def makeBlack(n: Tree): Tree = n match { - case Node(Red(),l,v,r) => Node(Black(),l,v,r) - case _ => n - } - - def flip(t : Tree) : Tree = t match { - case Empty() => Empty() - case Node(color,l,e,r) => Node(color,flip(r),e,flip(l)) - } -} diff --git a/src/test/resources/regression/termination/valid/SimpInterpret.scala b/src/test/resources/regression/termination/valid/SimpInterpret.scala deleted file mode 100644 index dc9b5d5f96437a9d83c2c8bf3e4dbcfcb6d497a5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/SimpInterpret.scala +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Interpret { - abstract class BoolTree - case class Eq(t1 : IntTree, t2 : IntTree) extends BoolTree - case class And(t1 : BoolTree, t2 : BoolTree) extends BoolTree - case class Not(t : BoolTree) extends BoolTree - - abstract class IntTree - case class Const(c:Int) extends IntTree - case class Var() extends IntTree - case class Plus(t1 : IntTree, t2 : IntTree) extends IntTree - case class Minus(t1 : IntTree, t2 : IntTree) extends IntTree - case class Less(t1 : IntTree, t2 : IntTree) extends BoolTree - case class If(cond : BoolTree, t : IntTree, e : IntTree) extends IntTree - - def repOk(t : IntTree) : Boolean = { - true - } - - def beval(t:BoolTree, x0 : Int) : Boolean = { - t match { - case Less(t1, t2) => ieval(t1,x0) < ieval(t2,x0) - case Eq(t1, t2) => ieval(t1,x0) == ieval(t2,x0) - case And(t1, t2) => beval(t1,x0) && beval(t2,x0) - case Not(t1) => !beval(t1,x0) - } - } - - def ieval(t:IntTree, x0 : Int) : Int = { - t match { - case Const(c) => c - case Var() => x0 - case Plus(t1,t2) => ieval(t1,x0) + ieval(t2,x0) - case Minus(t1, t2) => ieval(t1,x0) - ieval(t2,x0) - case If(c,t1,t2) => if (beval(c,x0)) ieval(t1,x0) else ieval(t2,x0) - } - } - def computesPositive(t : IntTree) : Boolean = { - ieval(t,0) >= 0 && - ieval(t,1) >= 0 && - ieval(t,-1) >= 0 && - ieval(t,-2) >= 0 && - ieval(t,2) >= 0 - } - def identityForPositive(t : IntTree) : Boolean = { - ieval(t, 5) == 5 && - ieval(t, 33) == 33 && - ieval(t, 0) == 0 && - ieval(t, -1) == 1 && - ieval(t, -2) == 2 - } - - def treeBad(t : IntTree) : Boolean = { - !(repOk(t) && computesPositive(t) && identityForPositive(t)) - }.holds - - def thereIsGoodTree() : Boolean = { - !treeBad(If(Less(Const(0),Var()), Var(), Minus(Const(0),Var()))) - }.holds - - @ignore - def main(args : Array[String]) { - thereIsGoodTree() - } -} diff --git a/src/test/resources/regression/termination/valid/Termination_passing1.scala b/src/test/resources/regression/termination/valid/Termination_passing1.scala deleted file mode 100644 index 389e60a5f3f4230577441d1286c76dac88f9e2bd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/termination/valid/Termination_passing1.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Termination { - abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - def f1(list: List) : Int = f2(list) - - def f2(list: List) : Int = list match { - case Cons(head, tail) => f1(tail) - case Nil() => 0 - } - - def f3(list: List, b: Boolean) : Int = if(b) f4(list) else f1(list) - - def f4(list: List) : Int = list match { - case Cons(head, tail) => f3(tail, true) - case Nil() => 0 - } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/transformations/SimplifyLets.scala b/src/test/resources/regression/transformations/SimplifyLets.scala deleted file mode 100644 index 62fd3f7a4fa2578bee363a87d93ecfc30db7ef6c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/transformations/SimplifyLets.scala +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Transform { - sealed abstract class List - case class Cons(head: Int, tail: List) extends List - case object Nil extends List - - def input01(a: Int): Int = { - val b = 42 - a + b + b - } - - def output01(a: Int): Int = { - a + 42 + 42 - } - - def input02(a: Int): Int = { - val b = 42+a - a + b - } - - def output02(a: Int): Int = { - a + (42 + a) - } - - def input03(a: Int): Int = { - val b = 42 - val c = 43 - - a + c - } - - def output03(a: Int): Int = { - a + 43 - } - - def input04(a: Int): Int = { - val c = 43 + a - - a + c + c - } - - def output04(a: Int): Int = { - val c = 43 + a - - a + c + c - } -} diff --git a/src/test/resources/regression/transformations/SimplifyPaths.scala b/src/test/resources/regression/transformations/SimplifyPaths.scala deleted file mode 100644 index 17d3a80b62ac947a7df09aa5e760a3d431339ba0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/transformations/SimplifyPaths.scala +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ -import leon.collection._ - -object Transform { - - - def input01(a: Int): Int = { - if(true) 1 else 2 - } - - def output01(a: Int): Int = { - 1 - } - - def input02(a: Boolean, b : Boolean, c : Boolean): Boolean = { - (a && !b) == !(!a || b) match { - case x@true => x && c - case false => !c - } - } - - def output02(a: Boolean, b : Boolean, c : Boolean): Boolean = { - c - } - - def input03(a: List[Int]): Int = { - a match { - case Nil() => 0 - //case n if n.isEmpty => 1 - case Cons(x, y) => 1 - case Cons(x, Cons(y,z)) => 2 - } - } - - def output03(a: List[Int]): Int = { - a match { - case Nil() => 0 - case Cons(x,y) => 1 - } - } - - def input04(a: Int): Int = { - a match { - case 0 => 0 - case x if x >= 42 => x+42 - case y if y > 42 => y-42 - case z if z > 0 => z +100 - case w if w < 0 => w -100 - case other => 1000 - } - } - def output04(a: Int): Int = { - a match { - case 0 => 0 - case x if x >= 42 => x + 42 - case z if z > 0 => z+100 - case w => w-100 - } - } - - def input05(a : Int) : Int = { - a match { - case x@_ => x - } - } - - def output05(a : Int) : Int = { - a - } - - def input06(a : (Int, Int)) : Int = { - a match { - case (x,y) => x - } - } - - def output06(a : (Int,Int)) : Int = { - a._1 - } - - def input07(l : List[Int]) : Int = l match { - case Nil() if false => 42 - case Cons(h,t) => h - } - - def output07(l : List[Int]) : Int = l match { - case Cons(h,t) => h - } - -} diff --git a/src/test/resources/regression/verification/isabelle/error/FunctionsWrong.scala b/src/test/resources/regression/verification/isabelle/error/FunctionsWrong.scala deleted file mode 100644 index bd1a65c53ff9311df11d4fb1bf5907b0fec76da7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/error/FunctionsWrong.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object FunctionsWrong { - - def zero: BigInt = 0 - - // unsupported by Isabelle - // should report a 'fatal error' (not an 'internal error') - - def length[A]: List[A] => BigInt = { - case Nil() => zero - case Cons(_, xs) => BigInt(1) + length(xs) - } - - def test[A](xs: List[A]) = (length(xs) >= zero) holds - -} diff --git a/src/test/resources/regression/verification/isabelle/error/MutualWrong.scala b/src/test/resources/regression/verification/isabelle/error/MutualWrong.scala deleted file mode 100644 index 5a006fa7f997a7872f46c96f9292f4d887b463eb..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/error/MutualWrong.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object MutualWrong { - - // unsupported by Isabelle - // should report a 'fatal error' (not an 'internal error') - - sealed abstract class List1[A] - case class Cons1[A](head: A, tail: List2[A, A]) extends List1[A] - - sealed abstract class List2[A, B] - case class Cons2[A, B](head: A, tail: List1[B]) extends List2[A, B] - case class Nil2[A, B]() extends List2[A, B] - - def truth = true holds - -} diff --git a/src/test/resources/regression/verification/isabelle/error/TypesWrong.scala b/src/test/resources/regression/verification/isabelle/error/TypesWrong.scala deleted file mode 100644 index 505e23d8600a7b16419fbe16f0118ada92ea665f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/error/TypesWrong.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.collection._ -import leon.lang._ - -object TypesWrong { - - case class Data(xs: Array[Int]) - - def truth = true holds - -} diff --git a/src/test/resources/regression/verification/isabelle/unknown/Casts.scala b/src/test/resources/regression/verification/isabelle/unknown/Casts.scala deleted file mode 100644 index 2d0ef020ed7ef7ff8f4c406d55f1271a35debc47..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/unknown/Casts.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object Casts { - - def check1[A](xs: List[A]) = - ((xs.size >= 1) || xs.asInstanceOf[Cons[A]].t == Nil[A]()).holds - - def check2[A](xs: List[A]) = - ((xs.size != 1) || xs.asInstanceOf[Cons[A]].t == Nil[A]()).holds - -} diff --git a/src/test/resources/regression/verification/isabelle/unknown/Mutual.scala b/src/test/resources/regression/verification/isabelle/unknown/Mutual.scala deleted file mode 100644 index 3f25ef9b2784956859e79c9ebec33e4aa0489f1c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/unknown/Mutual.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Mutual { - - sealed abstract class List1[A] - case class Cons1[A](head: A, tail: List2[A]) extends List1[A] - - sealed abstract class List2[B] - case class Cons2[B](head: B, tail: List1[B]) extends List2[B] - case class Nil2[B]() extends List2[B] - - def size1[A](list: List1[A]): BigInt = (list match { - case Cons1(_, t) => 1 + size2(t) - }) ensuring { _ >= BigInt(0) } - - def size2[A](list: List2[A]): BigInt = (list match { - case Nil2() => BigInt(0) - case Cons2(_, t) => 1 + size1(t) - }) ensuring { _ >= BigInt(0) } - -} diff --git a/src/test/resources/regression/verification/isabelle/valid/Datatypes.scala b/src/test/resources/regression/verification/isabelle/valid/Datatypes.scala deleted file mode 100644 index feea22f60e16168d1bbf4c281e4baacb9feca818..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/valid/Datatypes.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Datatypes { - - sealed abstract class Foo[A] - sealed abstract class Bar[C] extends Foo[C] - case class Baz[B](underlying: B, rest: Baz[B]) extends Bar[B] - case class FooNil[D]() extends Foo[D] - - def dest[B](baz1: Baz[B], baz2: Baz[B]) = { - require(baz1 == baz2) - baz1.underlying == baz2.underlying - } holds - - def intro_dest[B](baz1: Baz[B], baz2: Baz[B], b1: B, b2: B) = { - require(b1 == b2) - val x1 = Baz(b1, baz1) - val x2 = Baz(b2, baz2) - x1.underlying == x2.underlying - } holds - - def pm[A](foo: Foo[A]) = (foo match { - case Baz(x, y) => true - case FooNil() => true - }) holds - - def pm2[A](foo: Foo[A]) = (foo match { - case Baz(x, y) => true - case z: FooNil[A] => true - }) holds - - def pm3[A](int: BigInt) = (int match { - case BigInt(0) => true - case n => true - }) holds - - def pm4[A](int: BigInt) = (int match { - case BigInt(0) => true - case n if false => true - case n => true - }) holds - -} diff --git a/src/test/resources/regression/verification/isabelle/valid/Lists.scala b/src/test/resources/regression/verification/isabelle/valid/Lists.scala deleted file mode 100644 index 0eaeafc81babf173df3e5b2e91cb0f7bbd37e4df..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/valid/Lists.scala +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object Lists { - - @isabelle.script( - name = "Safe_Head", - source = """ - fun safe_head where - "safe_head [] = None" | - "safe_head (x # _) = Some x" - - lemma safe_head_eq_head[simp]: - assumes "~ List.null xs" - shows "safe_head xs = Some (hd xs)" - using assms - by (cases xs) auto - """ - ) - @isabelle.function(term = "Safe_Head.safe_head") - def safeHead[A](xs: List[A]): Option[A] = xs match { - case Nil() => None() - case Cons(x, _) => Some(x) - } - - def lemma1[A](xs: List[A]) = - (xs.isEmpty || safeHead(xs) == Some(xs.asInstanceOf[Cons[A]].h)).holds - - def lemma2[A](xs: List[A]) = { - require(!xs.isEmpty) - (xs.size > 0) - }.holds - - def lemma3[A](xs: List[A], ys: List[A], zs: List[A]) = - ((xs ++ ys) ++ zs == xs ++ (ys ++ zs)).holds - - def lemma4[A](xs: List[A], ys: List[A]) = - ((xs ++ ys).content == (ys ++ xs).content).holds - - def lemma5[A](x: A, xs: List[A]) = - ((x :: xs).content == xs.content ++ Set(x)).holds - - def lemma6[A](xs: List[A]) = - (xs.reverse.reverse == xs).holds - - def lemma7[A, B](xs: List[A]) = - (xs.zip(Nil[B]()) == Nil[(A, B)]()).holds - - def lemma7_check = - (lemma7[Int, Int](Nil())).holds - - def lemma8[A](xs: List[A], x: A) = - ((xs - x).content == xs.content -- Set(x)).holds - - def lemma9[A, B, C](xs: List[A], f: A => B, g: B => C) = - (xs.map(f).map(g) == xs.map(x => g(f(x)))).holds - - @isabelle.function(term = "Fun.id") - def identity[A](x: A) = x - - def lemma10[A](xs: List[A]) = - (xs.map(identity) == xs).holds - - @isabelle.proof(method = """(induct "<var xs>", auto)""") - def lemma11[A, B, C](xs: List[A], f: A => List[B], g: B => List[C]) = - (xs.flatMap(f).flatMap(g) == xs.flatMap(x => f(x).flatMap(g))).holds - - def safeHead2[A](xs: List[A]): A = { - require(xs.size > 0) - xs.asInstanceOf[Cons[A]].h - } - - def lemma12[A](xs: List[A]) = - (xs.isEmpty || safeHead2(xs) == xs.asInstanceOf[Cons[A]].h).holds - - def lemma13[A](xs: List[A], x: A) = - ((x :: xs).apply(0) == x).holds - - def lenTailrec[T](xs: List[T], n: BigInt): BigInt = xs match { - case Nil() => n - case Cons(_, xs) => lenTailrec(xs, 1 + n) - } - - @isabelle.proof(method = """(induct "<var xs>" "<var n>" rule: [[leon_induct lenTailrec]], auto)""") - def lemma14[A](xs: List[A], n: BigInt) = - (lenTailrec(xs, n) >= n).holds - -} diff --git a/src/test/resources/regression/verification/isabelle/valid/Nats.scala b/src/test/resources/regression/verification/isabelle/valid/Nats.scala deleted file mode 100644 index f679173dddc467d53e474d4aa6e26cf6b56cf74a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/valid/Nats.scala +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -@isabelle.typ(name = "Nat.nat") -sealed abstract class Nat { - - @isabelle.function(term = "op <=") - def <=(that: Nat): Boolean = this match { - case Zero() => true - case Succ(p) => - that match { - case Zero() => false - case Succ(q) => p <= q - } - } - - @isabelle.function(term = "op +") - def +(that: Nat): Nat = (this match { - case Zero() => that - case Succ(pred) => Succ(pred + that) - }) ensuring { res => - this <= res && that <= res - } - - @isabelle.function(term = "op *") - def *(that: Nat): Nat = this match { - case Zero() => Zero() - case Succ(pred) => that + pred * that - } - -} - -@isabelle.constructor(name = "Groups.zero_class.zero") -case class Zero() extends Nat - -@isabelle.constructor(name = "Nat.Suc") -case class Succ(pred: Nat) extends Nat - -object Nats { - - @isabelle.function(term = "Groups_List.monoid_add_class.listsum") - def listSum(xs: List[Nat]): Nat = xs match { - case Nil() => Zero() - case Cons(x, xs) => x + listSum(xs) - } - - @isabelle.function(term = "length") - def length[A](xs: List[A]): Nat = xs match { - case Nil() => Zero() - case Cons(x, xs) => Succ(length(xs)) - } - - @isabelle.script( - name = "Map_Fst_Zip", - source = "declare map_fst_zip[simp del]" - ) - @isabelle.proof(method = """(clarsimp, induct rule: list_induct2, auto)""") - def mapFstZip[A, B](xs: List[A], ys: List[B]) = { - require(length(xs) == length(ys)) - xs.zip(ys).map(_._1) - } ensuring { _ == xs } - - def addCommute(x: Nat, y: Nat) = - (x + y == y + x).holds - - def sumReverse(xs: List[Nat]) = - (listSum(xs) == listSum(xs.reverse)).holds - - def sumZero[A](xs: List[A]) = - (listSum(xs.map(_ => Zero())) == Zero()).holds - - @isabelle.proof(method = """(induct "<var xs>", auto)""") - def sumConstant[A](xs: List[A], k: Nat) = - (listSum(xs.map(_ => k)) == length(xs) * k).holds - -} diff --git a/src/test/resources/regression/verification/isabelle/valid/Overlapping.scala b/src/test/resources/regression/verification/isabelle/valid/Overlapping.scala deleted file mode 100644 index 8c9d606f0e78d45d8a34998b5ec9126dc4e8b712..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/valid/Overlapping.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object Overlapping { - - def overlapped[A](xs: List[A]) = { - require { xs.isInstanceOf[Cons[A]] } - - xs match { - case Cons(x1, Cons(x2, xs)) => true - case Cons(x1, xs) => true - case _ => false - } - }.holds - -} diff --git a/src/test/resources/regression/verification/isabelle/valid/Quantifiers.scala b/src/test/resources/regression/verification/isabelle/valid/Quantifiers.scala deleted file mode 100644 index ba950b23976384159ade2cf5f072051a2dbb03d6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/valid/Quantifiers.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Quantifiers { - - def swapping[A, B](p: (A, B) => Boolean) = { - require(forall((x: A, y: B) => p(x, y))) - forall((y: B, x: A) => p(x, y)) - }.holds - - def swapping_curry[A, B](p: A => B => Boolean) = { - require(forall((x: A) => forall((y: B) => p(x)(y)))) - forall((y: B) => forall((x: A) => p(x)(y))) - }.holds - - def inst[A](p: A => Boolean, a: A) = { - require(forall((x: A) => p(a))) - p(a) - }.holds - - def exists[A](p: A => Boolean) = - !forall((x: A) => !p(x)) - - def drinkersPrinciple[A](d: A => Boolean) = - exists((x: A) => d(x) ==> forall((y: A) => d(y))).holds - -} diff --git a/src/test/resources/regression/verification/isabelle/valid/Reals.scala b/src/test/resources/regression/verification/isabelle/valid/Reals.scala deleted file mode 100644 index c7f370bab038ff75e7074514ae0ab7b51a5e6dc7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/valid/Reals.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.lang._ -import leon.annotation._ - -object Reals { - - def comm(x: Real, y: Real) = - (x + y == y + x).holds - - def assoc(x: Real, y: Real, z: Real) = - ((x * y) * z == x * (y * z)).holds - -} diff --git a/src/test/resources/regression/verification/isabelle/valid/Unapply.scala b/src/test/resources/regression/verification/isabelle/valid/Unapply.scala deleted file mode 100644 index 6569f180c34f26357d15985dd0f7e1c4ef55b22e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/isabelle/valid/Unapply.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object Unapply { - - @isabelle.proof(method = """(cases "<var xs>", auto)""") - def check[A](xs: List[A]) = { - xs match { - case Nil() => true - case _ :: _ => true - } - }.holds - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Acc.scala b/src/test/resources/regression/verification/newsolvers/invalid/Acc.scala deleted file mode 100644 index 2005a7d0310fabcaa611c5e71d7d3653b77b27d3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Acc.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Acc { - - case class Acc(checking : Int, savings : Int) - - def putAside(x: Int, a: Acc): Acc = { - require (x > 0 && notRed(a) && a.checking >= x) - Acc(a.checking - x, a.savings + x) - } ensuring { - r => notRed(r) && sameTotal(a, r) - } - - - def sameTotal(a1: Acc, a2: Acc): Boolean = { - a1.checking + a1.savings == a2.checking + a2.savings - } - - def notRed(a: Acc) : Boolean = { - a.checking >= 0 && a.savings >= 0 - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/AddingNegativeNumbers.scala b/src/test/resources/regression/verification/newsolvers/invalid/AddingNegativeNumbers.scala deleted file mode 100644 index 98f5de2e248eb40fb6d4cbb6565093d725a2745e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/AddingNegativeNumbers.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package test.resources.regression.verification.purescala.invalid - -object AddingNegativeNumbers { - - def additionOverflow(x: Int, y: Int): Int = { - require(x <= 0 && y <= 0) - x + y - } ensuring(_ <= 0) - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/AddingPositiveNumbers.scala b/src/test/resources/regression/verification/newsolvers/invalid/AddingPositiveNumbers.scala deleted file mode 100644 index 6bebade9591e59f844fae5180d6b85401dc186ba..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/AddingPositiveNumbers.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object AddingPositiveNumbers { - - //this should overflow with bit vectors - def additionOverflow(x: Int, y: Int): Int = { - require(x >= 0 && y >= 0) - x + y - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Array1.scala b/src/test/resources/regression/verification/newsolvers/invalid/Array1.scala deleted file mode 100644 index 3707c62e6bc3a00c8f4cdcdde471c04b086a1476..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Array1.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array1 { - - def foo(a: Array[Int]): Int = { - a(2) - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Array2.scala b/src/test/resources/regression/verification/newsolvers/invalid/Array2.scala deleted file mode 100644 index b241dc8cbfd74991dd8ecec9f1c43cd165120942..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Array2.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array2 { - - def foo(a: Array[Int]): Int = { - require(a.length > 2) - a(2) - } ensuring(_ == 0) - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Array3.scala b/src/test/resources/regression/verification/newsolvers/invalid/Array3.scala deleted file mode 100644 index 4307c3982dad5c88608091f5891ea5d227881819..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Array3.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array3 { - def find(c: Array[Int], i: Int): Int = { - require(i >= 0) - if(c(i) == i) - 42 - else - 12 - } ensuring(_ > 0) - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Array4.scala b/src/test/resources/regression/verification/newsolvers/invalid/Array4.scala deleted file mode 100644 index 35a6479b9e11d8d1917a554a0e36017af556f804..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Array4.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array4 { - - def foo(a: Array[Int]): Int = { - val tmp = a.updated(0, 0) - tmp(0) - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Asserts1.scala b/src/test/resources/regression/verification/newsolvers/invalid/Asserts1.scala deleted file mode 100644 index 73ec19af59f350a196970bc7249395e5df5a2288..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Asserts1.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ -import leon._ - -object Asserts1 { - - def foo(a: BigInt): BigInt = { - require(a > 0) - val b = a - assert(b > 0, "Hey now") - b + bar(1) - } ensuring { res => - res > a && res < 2 - } - - def bar(a: BigInt): BigInt = { - require(a > 0) - val b = a - assert(b > 0, "Hey now") - b + 2 - } ensuring { res => - res > a && res > 2 - } -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/BVDivision.scala b/src/test/resources/regression/verification/newsolvers/invalid/BVDivision.scala deleted file mode 100644 index bbd8bb508ba9e01c5f96d56b8ed459adf605de59..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/BVDivision.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object BVDivision { - - def divByZero(x: Int): Boolean = { - (x / 0 == 10) - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/BVDivision2.scala b/src/test/resources/regression/verification/newsolvers/invalid/BVDivision2.scala deleted file mode 100644 index ab320c8c3bc9a90a83c85c253b58a4b9e048ad1e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/BVDivision2.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object BVDivision2 { - - def division(x: Int, y: Int): Int = { - x / y - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/BigArray.scala b/src/test/resources/regression/verification/newsolvers/invalid/BigArray.scala deleted file mode 100644 index a4a4a6a05c0836b19ec55ad4538bd264c2742799..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/BigArray.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object BigArray { - - def big(a: Array[Int]): Int = { - require(a.length >= 10 && a(7) == 42) - a.length - } ensuring(_ <= 1000000000) - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Division.scala b/src/test/resources/regression/verification/newsolvers/invalid/Division.scala deleted file mode 100644 index 1678d2db8644d1560162c01a6b5a275a7151e7b1..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Division.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object Division { - - def divByZero(x: BigInt): Boolean = { - (x / BigInt(0) == BigInt(10)) - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/EnsuringBoolean.scala b/src/test/resources/regression/verification/newsolvers/invalid/EnsuringBoolean.scala deleted file mode 100644 index 32b47ae9c2d1f4adbc58d63a410e9177816bf848..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/EnsuringBoolean.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.lang._ -import leon.annotation._ -import scala.language.postfixOps -object EnsuringBoolean { - def congR(x: BigInt)(implicit mod: BigInt): Unit = { - require(mod >= 1); - () - } ensuring(false) -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/FiniteSort.scala b/src/test/resources/regression/verification/newsolvers/invalid/FiniteSort.scala deleted file mode 100644 index 17af7c45eab3dc211d85ecefd480e61a9387a775..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/FiniteSort.scala +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object FiniteSort { - - // These finite sorting functions essentially implement insertion sort. - def sort2(x : Int, y : Int) : (Int,Int) = { - if(x < y) (x, y) else (y, x) - } - - def sort3(x1 : Int, x2 : Int, x3 : Int) : (Int, Int, Int) = { - val (x1s, x2s) = sort2(x1, x2) - - if(x2s <= x3) { - (x1s, x2s, x3) - } else if(x1s <= x3) { - (x1s, x3, x2s) - } else { - (x3, x1s, x2s) - } - } - - def sort4(x1 : Int, x2 : Int, x3 : Int, x4 : Int) : (Int, Int, Int, Int) = { - val (x1s, x2s, x3s) = sort3(x1, x2, x3) - - if(x3s <= x4) { - (x1s, x2s, x3s, x4) - } else if(x2s <= x4) { - (x1s, x2s, x4, x3s) - } else if(x1s <= x4) { - (x1s, x4, x2s, x3s) - } else { - (x4, x1s, x2s, x3s) - } - } - - def sort5WrongSpec(x1 : Int, x2 : Int, x3 : Int, x4 : Int, x5 : Int) : (Int, Int, Int, Int, Int) = { - val (x1s, x2s, x3s, x4s) = sort4(x1, x2, x3, x4) - - if(x4s <= x5) { - (x1s, x2s, x3s, x4s, x5) - } else if(x3s <= x5) { - (x1s, x2s, x3s, x5, x4s) - } else if(x2s <= x5) { - (x1s, x2s, x5, x3s, x4s) - } else if(x1s <= x5) { - (x1s, x5, x2s, x3s, x4s) - } else { - (x5, x1s, x2s, x3s, x4s) - } - - } ensuring (_ match { - case (a, b, c, d, e) => a <= b && b <= c && c <= d && d <= e && Set(a,b,c,d,e) == Set(x1,x2,x3,x4,x4) // last one should be x5 - }) -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Generics.scala b/src/test/resources/regression/verification/newsolvers/invalid/Generics.scala deleted file mode 100644 index 991b948d948b909badfabd9935d58e865b03995f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Generics.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Generics { - abstract class List[T] - case class Cons[A](head: A, tail: List[A]) extends List[A] - case class Nil[B]() extends List[B] - - def size[T](l: List[T]): BigInt = (l match { - case Nil() => BigInt(0) - case Cons(h, t) => 1+size(t) - })ensuring { _ > 0 } - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Generics2.scala b/src/test/resources/regression/verification/newsolvers/invalid/Generics2.scala deleted file mode 100644 index 0c95c311e09c0c67c16bf510090723afb41b5768..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Generics2.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Generics2 { - abstract class List[T] - case class Cons[A](head: A, tail: List[A]) extends List[A] - case class Nil[B]() extends List[B] - - def size[T](l: List[T]): BigInt = (l match { - case Nil() => BigInt(0) - case Cons(h, t) => 1+size(t) - })ensuring { _ >= 0 } - - def foo[T](l: List[T]): List[T] = { - require(size(l) < 2) - - l - } - - def bar(l: List[Int]) = { - foo(l) - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/InsertionSort.scala b/src/test/resources/regression/verification/newsolvers/invalid/InsertionSort.scala deleted file mode 100644 index ddf73528201ad5a07cbe61bc1afe440bcfc58f8d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/InsertionSort.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object InsertionSort { - sealed abstract class List - case class Cons(head:Int,tail:List) extends List - case class Nil() extends List - - sealed abstract class OptInt - case class Some(value: Int) extends OptInt - case class None() extends OptInt - - def size(l : List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def contents(l: List): Set[Int] = l match { - case Nil() => Set.empty - case Cons(x,xs) => contents(xs) ++ Set(x) - } - - def isSorted(l: List): Boolean = l match { - case Nil() => true - case Cons(x, Nil()) => true - case Cons(x, Cons(y, ys)) => x <= y && isSorted(Cons(y, ys)) - } - - /* Inserting element 'e' into a sorted list 'l' produces a sorted list with - * the expected content and size */ - def buggySortedIns(e: Int, l: List): List = { - // require(isSorted(l)) - l match { - case Nil() => Cons(e,Nil()) - case Cons(x,xs) => if (x <= e) Cons(x,buggySortedIns(e, xs)) else Cons(e, l) - } - } ensuring(res => contents(res) == contents(l) ++ Set(e) - && isSorted(res) - && size(res) == size(l) + 1 - ) -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/ListOperations.scala b/src/test/resources/regression/verification/newsolvers/invalid/ListOperations.scala deleted file mode 100644 index cd801dc9ef23a1f43ef6a793a3102266af239bac..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/ListOperations.scala +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object ListOperations { - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - sealed abstract class BigIntPairList - case class IPCons(head: BigIntPair, tail: BigIntPairList) extends BigIntPairList - case class IPNil() extends BigIntPairList - - sealed abstract class BigIntPair - case class IP(fst: BigInt, snd: BigInt) extends BigIntPair - - def size(l: List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def iplSize(l: BigIntPairList) : BigInt = (l match { - case IPNil() => BigInt(0) - case IPCons(_, xs) => 1 + iplSize(xs) - }) ensuring(_ >= 0) - - def zip(l1: List, l2: List) : BigIntPairList = { - // try to comment this and see how pattern-matching becomes - // non-exhaustive and post-condition fails - require(size(l1) == size(l2)) - - l1 match { - case Nil() => IPNil() - case Cons(x, xs) => l2 match { - case Cons(y, ys) => IPCons(IP(x, y), zip(xs, ys)) - } - } - } ensuring(iplSize(_) == size(l1)) - - def sizeTailRec(l: List) : BigInt = sizeTailRecAcc(l, 0) - def sizeTailRecAcc(l: List, acc: BigInt) : BigInt = { - require(acc >= 0) - l match { - case Nil() => acc - case Cons(_, xs) => sizeTailRecAcc(xs, acc+1) - } - } ensuring(res => res == size(l) + acc) - - def sizesAreEquiv(l: List) : Boolean = { - size(l) == sizeTailRec(l) - }.holds - - def content(l: List) : Set[BigInt] = l match { - case Nil() => Set.empty[BigInt] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def sizeAndContent(l: List) : Boolean = { - size(l) == BigInt(0) || content(l) != Set.empty[BigInt] - }.holds - - def drunk(l : List) : List = (l match { - case Nil() => Nil() - case Cons(x,l1) => Cons(x,Cons(x,drunk(l1))) - }) ensuring (size(_) == 2 * size(l)) - - def reverse(l: List) : List = reverse0(l, Nil()) ensuring(content(_) == content(l)) - def reverse0(l1: List, l2: List) : List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => reverse0(xs, Cons(x, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - def append(l1 : List, l2 : List) : List = (l1 match { - case Nil() => l2 - case Cons(x,xs) => Cons(x, append(xs, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def nilAppend(l : List) : Boolean = (append(l, Nil()) == l).holds - - @induct - def appendAssoc(xs : List, ys : List, zs : List) : Boolean = - (append(append(xs, ys), zs) == append(xs, append(ys, zs))).holds - - def revAuxBroken(l1 : List, e : BigInt, l2 : List) : Boolean = { - (append(reverse(l1), Cons(e,l2)) == reverse0(l1, l2)) - }.holds - - @induct - def sizeAppend(l1 : List, l2 : List) : Boolean = - (size(append(l1, l2)) == size(l1) + size(l2)).holds - - @induct - def concat(l1: List, l2: List) : List = - concat0(l1, l2, Nil()) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def concat0(l1: List, l2: List, l3: List) : List = (l1 match { - case Nil() => l2 match { - case Nil() => reverse(l3) - case Cons(y, ys) => { - concat0(Nil(), ys, Cons(y, l3)) - } - } - case Cons(x, xs) => concat0(xs, l2, Cons(x, l3)) - }) ensuring(content(_) == content(l1) ++ content(l2) ++ content(l3)) -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/MyTuple1.scala b/src/test/resources/regression/verification/newsolvers/invalid/MyTuple1.scala deleted file mode 100644 index 394e2cd9fb8815514c7788481af2c0376af8e560..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/MyTuple1.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple1 { - - def foo(): Int = { - val t = (1, true, 3) - val a1 = t._1 - val a2 = t._2 - val a3 = t._3 - a3 - } ensuring( _ == 1) - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/MyTuple2.scala b/src/test/resources/regression/verification/newsolvers/invalid/MyTuple2.scala deleted file mode 100644 index 76b8e64cf243789f9eece4cf8dfc7131efb6ca82..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/MyTuple2.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple2 { - - abstract class A - case class B(i: Int) extends A - case class C(a: A) extends A - - def foo(): Int = { - val t = (B(2), C(B(3))) - t match { - case (B(x), C(y)) => x - } - } ensuring( _ == 3) - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/MyTuple3.scala b/src/test/resources/regression/verification/newsolvers/invalid/MyTuple3.scala deleted file mode 100644 index abc0ffba3e654b80b3ac27450be7421496b9d53c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/MyTuple3.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple3 { - - def foo(t: (Int, Int)): (Int, Int) = { - t - } ensuring(res => res._1 > 0 && res._2 > 1) - -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/PositiveMap.scala b/src/test/resources/regression/verification/newsolvers/invalid/PositiveMap.scala deleted file mode 100644 index eaf345dd92979d9a754d2157611b2bf8f58266db..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/PositiveMap.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object PositiveMap { - - abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - def positive(list: List): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def positiveMap_failling_1(f: (Int) => Int, list: List): List = { - list match { - case Cons(head, tail) => - val fh = f(head) - val nh = if (fh < -1) 0 else fh - Cons(nh, positiveMap_failling_1(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/newsolvers/invalid/PropositionalLogic.scala b/src/test/resources/regression/verification/newsolvers/invalid/PropositionalLogic.scala deleted file mode 100644 index 18b36ebf0b748488dc27ea88ce64626e04c064e5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/PropositionalLogic.scala +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object PropositionalLogic { - - sealed abstract class Formula - case class And(lhs: Formula, rhs: Formula) extends Formula - case class Or(lhs: Formula, rhs: Formula) extends Formula - case class Implies(lhs: Formula, rhs: Formula) extends Formula - case class Not(f: Formula) extends Formula - case class Literal(id: Int) extends Formula - - def simplify(f: Formula): Formula = (f match { - case And(lhs, rhs) => And(simplify(lhs), simplify(rhs)) - case Or(lhs, rhs) => Or(simplify(lhs), simplify(rhs)) - case Implies(lhs, rhs) => Or(Not(simplify(lhs)), simplify(rhs)) - case Not(f) => Not(simplify(f)) - case Literal(_) => f - }) ensuring(isSimplified(_)) - - def isSimplified(f: Formula): Boolean = f match { - case And(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Or(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Implies(_,_) => false - case Not(f) => isSimplified(f) - case Literal(_) => true - } - - def nnf(formula: Formula): Formula = (formula match { - case And(lhs, rhs) => And(nnf(lhs), nnf(rhs)) - case Or(lhs, rhs) => Or(nnf(lhs), nnf(rhs)) - case Implies(lhs, rhs) => Implies(nnf(lhs), nnf(rhs)) - case Not(And(lhs, rhs)) => Or(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Or(lhs, rhs)) => And(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Implies(lhs, rhs)) => And(nnf(lhs), nnf(Not(rhs))) - case Not(Not(f)) => nnf(f) - case Not(Literal(_)) => formula - case Literal(_) => formula - }) ensuring(isNNF(_)) - - def isNNF(f: Formula): Boolean = f match { - case And(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Or(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Implies(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Not(Literal(_)) => true - case Not(_) => false - case Literal(_) => true - } - - def vars(f: Formula): Set[Int] = { - require(isNNF(f)) - f match { - case And(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Or(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Implies(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Not(Literal(i)) => Set[Int](i) - case Literal(i) => Set[Int](i) - } - } - - def fv(f : Formula) = { vars(nnf(f)) } - - // @induct - // def wrongCommutative(f: Formula) : Boolean = { - // nnf(simplify(f)) == simplify(nnf(f)) - // }.holds - - @induct - def simplifyBreaksNNF(f: Formula) : Boolean = { - require(isNNF(f)) - isNNF(simplify(f)) - }.holds - - @induct - def nnfIsStable(f: Formula) : Boolean = { - require(isNNF(f)) - nnf(f) == f - }.holds - - @induct - def simplifyIsStable(f: Formula) : Boolean = { - require(isSimplified(f)) - simplify(f) == f - }.holds -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/README b/src/test/resources/regression/verification/newsolvers/invalid/README deleted file mode 100644 index 3b276ff545f799f5335938c7ca4788ef72234e3d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/README +++ /dev/null @@ -1,2 +0,0 @@ -This particular directory contains PureScala programs that have *at least* one -failing verification condition. diff --git a/src/test/resources/regression/verification/newsolvers/invalid/RedBlackTree.scala b/src/test/resources/regression/verification/newsolvers/invalid/RedBlackTree.scala deleted file mode 100644 index 7ac05413c0a958f4132393c4a4ffe4cba7142af5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/RedBlackTree.scala +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object RedBlackTree { - sealed abstract class Color - case class Red() extends Color - case class Black() extends Color - - sealed abstract class Tree - case class Empty() extends Tree - case class Node(color: Color, left: Tree, value: BigInt, right: Tree) extends Tree - - sealed abstract class OptionBigInt - case class Some(v : BigInt) extends OptionBigInt - case class None() extends OptionBigInt - - def content(t: Tree) : Set[BigInt] = t match { - case Empty() => Set.empty - case Node(_, l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def size(t: Tree) : BigInt = (t match { - case Empty() => BigInt(0) - case Node(_, l, v, r) => size(l) + 1 + size(r) - }) ensuring(_ >= 0) - - def isBlack(t: Tree) : Boolean = t match { - case Empty() => true - case Node(Black(),_,_,_) => true - case _ => false - } - - def redNodesHaveBlackChildren(t: Tree) : Boolean = t match { - case Empty() => true - case Node(Black(), l, _, r) => redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - case Node(Red(), l, _, r) => isBlack(l) && isBlack(r) && redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - } - - def redDescHaveBlackChildren(t: Tree) : Boolean = t match { - case Empty() => true - case Node(_,l,_,r) => redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - } - - def blackBalanced(t : Tree) : Boolean = t match { - case Node(_,l,_,r) => blackBalanced(l) && blackBalanced(r) && blackHeight(l) == blackHeight(r) - case Empty() => true - } - - def blackHeight(t : Tree) : BigInt = t match { - case Empty() => 1 - case Node(Black(), l, _, _) => blackHeight(l) + 1 - case Node(Red(), l, _, _) => blackHeight(l) - } - - def ins(x: BigInt, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t) && blackBalanced(t)) - t match { - case Empty() => Node(Red(),Empty(),x,Empty()) - case Node(c,a,y,b) => - if (x < y) balance(c, ins(x, a), y, b) - else if (x == y) Node(c,a,y,b) - else balance(c,a,y,ins(x, b)) - } - } ensuring (res => content(res) == content(t) ++ Set(x) - && size(t) <= size(res) && size(res) <= size(t) + 1 - && redDescHaveBlackChildren(res) - && blackBalanced(res)) - - def balance(c: Color, a: Tree, x: BigInt, b: Tree): Tree = { - Node(c,a,x,b) match { - case Node(Black(),Node(Red(),Node(Red(),a,xV,b),yV,c),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),Node(Red(),a,xV,Node(Red(),b,yV,c)),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),Node(Red(),b,yV,c),zV,d)) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),b,yV,Node(Red(),c,zV,d))) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(c,a,xV,b) => Node(c,a,xV,b) - } - } ensuring (res => content(res) == content(Node(c,a,x,b)))// && redDescHaveBlackChildren(res)) - - def buggyAdd(x: BigInt, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t)) - ins(x, t) - } ensuring (res => content(res) == content(t) ++ Set(x) && redNodesHaveBlackChildren(res)) - - def buggyBalance(c: Color, a: Tree, x: BigInt, b: Tree): Tree = { - Node(c,a,x,b) match { - case Node(Black(),Node(Red(),Node(Red(),a,xV,b),yV,c),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),Node(Red(),a,xV,Node(Red(),b,yV,c)),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),Node(Red(),b,yV,c),zV,d)) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),b,yV,Node(Red(),c,zV,d))) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - // case Node(c,a,xV,b) => Node(c,a,xV,b) - } - } ensuring (res => content(res) == content(Node(c,a,x,b))) -} diff --git a/src/test/resources/regression/verification/newsolvers/invalid/Unit1.scala b/src/test/resources/regression/verification/newsolvers/invalid/Unit1.scala deleted file mode 100644 index f937daaa922bc3039ca565d978905db3c23531fd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/invalid/Unit1.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Unit1 { - - def foo(u: Unit): Unit = ({ - u - }) ensuring(res => false) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Acc.scala b/src/test/resources/regression/verification/newsolvers/valid/Acc.scala deleted file mode 100644 index 6f93027c9fc03fded4a86923e54d3d8d0bf65a6f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Acc.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Acc { - - case class Acc(checking : BigInt, savings : BigInt) - - def putAside(x: BigInt, a: Acc): Acc = { - require (x > 0 && notRed(a) && a.checking >= x) - Acc(a.checking - x, a.savings + x) - } ensuring { - r => notRed(r) && sameTotal(a, r) - } - - - def sameTotal(a1: Acc, a2: Acc): Boolean = { - a1.checking + a1.savings == a2.checking + a2.savings - } - - def notRed(a: Acc) : Boolean = { - a.checking >= 0 && a.savings >= 0 - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/AddingPositiveNumbers.scala b/src/test/resources/regression/verification/newsolvers/valid/AddingPositiveNumbers.scala deleted file mode 100644 index 84fca5dc63b3fb69504c65b2c38162879c8ec607..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/AddingPositiveNumbers.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object AddingPositiveNumbers { - - //this should not overflow - def additionSound(x: BigInt, y: BigInt): BigInt = { - require(x >= 0 && y >= 0) - x + y - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/AmortizedQueue.scala b/src/test/resources/regression/verification/newsolvers/valid/AmortizedQueue.scala deleted file mode 100644 index 5d60e67bfedfc3af133774abc73ed594bff24929..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/AmortizedQueue.scala +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object AmortizedQueue { - sealed abstract class List - case class Cons(head : BigInt, tail : List) extends List - case class Nil() extends List - - sealed abstract class AbsQueue - case class Queue(front : List, rear : List) extends AbsQueue - - def size(list : List) : BigInt = (list match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def content(l: List) : Set[BigInt] = l match { - case Nil() => Set.empty[BigInt] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def asList(queue : AbsQueue) : List = queue match { - case Queue(front, rear) => concat(front, reverse(rear)) - } - - def concat(l1 : List, l2 : List) : List = (l1 match { - case Nil() => l2 - case Cons(x,xs) => Cons(x, concat(xs, l2)) - }) ensuring (res => size(res) == size(l1) + size(l2) && content(res) == content(l1) ++ content(l2)) - - def isAmortized(queue : AbsQueue) : Boolean = queue match { - case Queue(front, rear) => size(front) >= size(rear) - } - - def isEmpty(queue : AbsQueue) : Boolean = queue match { - case Queue(Nil(), Nil()) => true - case _ => false - } - - def reverse(l : List) : List = (l match { - case Nil() => Nil() - case Cons(x, xs) => concat(reverse(xs), Cons(x, Nil())) - }) ensuring (content(_) == content(l)) - - def amortizedQueue(front : List, rear : List) : AbsQueue = { - if (size(rear) <= size(front)) - Queue(front, rear) - else - Queue(concat(front, reverse(rear)), Nil()) - } ensuring(isAmortized(_)) - - def enqueue(queue : AbsQueue, elem : BigInt) : AbsQueue = (queue match { - case Queue(front, rear) => amortizedQueue(front, Cons(elem, rear)) - }) ensuring(isAmortized(_)) - - def tail(queue : AbsQueue) : AbsQueue = { - require(isAmortized(queue) && !isEmpty(queue)) - queue match { - case Queue(Cons(f, fs), rear) => amortizedQueue(fs, rear) - } - } ensuring (isAmortized(_)) - - def front(queue : AbsQueue) : BigInt = { - require(isAmortized(queue) && !isEmpty(queue)) - queue match { - case Queue(Cons(f, _), _) => f - } - } - - // @induct - // def propEnqueue(rear : List, front : List, list : List, elem : BigInt) : Boolean = { - // require(isAmortized(Queue(front, rear))) - // val queue = Queue(front, rear) - // if (asList(queue) == list) { - // asList(enqueue(queue, elem)) == concat(list, Cons(elem, Nil())) - // } else - // true - // }.holds - - @induct - def propFront(queue : AbsQueue, list : List, elem : BigInt) : Boolean = { - require(!isEmpty(queue) && isAmortized(queue)) - if (asList(queue) == list) { - list match { - case Cons(x, _) => front(queue) == x - } - } else - true - }.holds - - @induct - def propTail(rear : List, front : List, list : List, elem : BigInt) : Boolean = { - require(!isEmpty(Queue(front, rear)) && isAmortized(Queue(front, rear))) - if (asList(Queue(front, rear)) == list) { - list match { - case Cons(_, xs) => asList(tail(Queue(front, rear))) == xs - } - } else - true - } //.holds - - def enqueueAndFront(queue : AbsQueue, elem : BigInt) : Boolean = { - if (isEmpty(queue)) - front(enqueue(queue, elem)) == elem - else - true - }.holds - - def enqueueDequeueThrice(queue : AbsQueue, e1 : BigInt, e2 : BigInt, e3 : BigInt) : Boolean = { - if (isEmpty(queue)) { - val q1 = enqueue(queue, e1) - val q2 = enqueue(q1, e2) - val q3 = enqueue(q2, e3) - val e1prime = front(q3) - val q4 = tail(q3) - val e2prime = front(q4) - val q5 = tail(q4) - val e3prime = front(q5) - e1 == e1prime && e2 == e2prime && e3 == e3prime - } else - true - }.holds -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/ArrayLiterals.scala b/src/test/resources/regression/verification/newsolvers/valid/ArrayLiterals.scala deleted file mode 100644 index 450a07a7e65f5eea0bcadfe9cdf7d71574b9abfb..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/ArrayLiterals.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -object ArrayLiterals { - def foo(): Int = { - val b : Array[Int] = Array[Int](1,2,3) - val a : Array[Int] = Array(1,2,3) - a.length - } ensuring { _ > 0 } -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/ArrayUpdated.scala b/src/test/resources/regression/verification/newsolvers/valid/ArrayUpdated.scala deleted file mode 100644 index d501089cf77bb3c5dd30dea7ac6dfce557508f13..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/ArrayUpdated.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ArrayUpdated { - - def test(a: Array[Int]): Int = { - require(a.length > 0) - val a2 = a.updated(0, 2) - a2(0) - } ensuring(res => res == 2) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Asserts1.scala b/src/test/resources/regression/verification/newsolvers/valid/Asserts1.scala deleted file mode 100644 index aadcfde990f31b4106f9e741457d0e04f6634e7b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Asserts1.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ -import leon._ - -object Asserts1 { - - def foo(a: BigInt): BigInt = { - require(a > 0) - - { - val b = a - assert(b > 0, "Hey now") - b + bar(1) - } ensuring { _ > 2 } - - } ensuring { - _ > a - } - - def bar(a: BigInt): BigInt = { - require(a > 0) - - { - val b = a - assert(b > 0, "Hey now") - b + 2 - } ensuring { _ > 2 } - - } ensuring { - _ > a - } -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/AssociativeList.scala b/src/test/resources/regression/verification/newsolvers/valid/AssociativeList.scala deleted file mode 100644 index bbc4edf5d8cd23e6b8ff37966bf2620e93acfde9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/AssociativeList.scala +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object AssociativeList { - sealed abstract class KeyValuePairAbs - case class KeyValuePair(key: Int, value: Int) extends KeyValuePairAbs - - sealed abstract class List - case class Cons(head: KeyValuePairAbs, tail: List) extends List - case class Nil() extends List - - sealed abstract class OptionInt - case class Some(i: Int) extends OptionInt - case class None() extends OptionInt - - def domain(l: List): Set[Int] = l match { - case Nil() => Set.empty[Int] - case Cons(KeyValuePair(k,_), xs) => Set(k) ++ domain(xs) - } - - def find(l: List, e: Int): OptionInt = l match { - case Nil() => None() - case Cons(KeyValuePair(k, v), xs) => if (k == e) Some(v) else find(xs, e) - } - - def noDuplicates(l: List): Boolean = l match { - case Nil() => true - case Cons(KeyValuePair(k, v), xs) => find(xs, k) == None() && noDuplicates(xs) - } - - def updateAll(l1: List, l2: List): List = (l2 match { - case Nil() => l1 - case Cons(x, xs) => updateAll(updateElem(l1, x), xs) - }) ensuring(domain(_) == domain(l1) ++ domain(l2)) - - def updateElem(l: List, e: KeyValuePairAbs): List = (l match { - case Nil() => Cons(e, Nil()) - case Cons(KeyValuePair(k, v), xs) => e match { - case KeyValuePair(ek, ev) => if (ek == k) Cons(KeyValuePair(ek, ev), xs) else Cons(KeyValuePair(k, v), updateElem(xs, e)) - } - }) ensuring(res => e match { - case KeyValuePair(k, v) => domain(res) == domain(l) ++ Set[Int](k) - }) - - @induct - def readOverWrite(l: List, k1: Int, k2: Int, e: Int) : Boolean = { - find(updateElem(l, KeyValuePair(k2,e)), k1) == (if (k1 == k2) Some(e) else find(l, k1)) - }.holds -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/BestRealTypes.scala b/src/test/resources/regression/verification/newsolvers/valid/BestRealTypes.scala deleted file mode 100644 index b40aac4f8d6b6342db76e21272dfa427c7d64c30..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/BestRealTypes.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -/** This benchmarks tests some potential issues with the legacy "bestRealType" function, which was original introduced to work around - * Scala's well-too-precise-for-Leon type inference. */ -object BestRealTypes { - sealed abstract class Num - case class Zero() extends Num - case class Succ(pred : Num) extends Num - - case class Wrapper(num : Num) - - def boolToNum(b : Boolean) : Num = if(b) { - Zero() - } else { - Succ(Zero()) - } - - // This requires computing the "bestRealTypes" of w1 and w2. - def zipWrap(w1 : Wrapper, w2 : Wrapper) : (Wrapper,Wrapper) = (w1, w2) - - def somethingToProve(b : Boolean) : Boolean = { - val (z1,z2) = zipWrap(Wrapper(boolToNum(b)), Wrapper(boolToNum(!b))) - z1.num == Zero() || z2.num == Zero() - }.holds -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/BitsTricks.scala b/src/test/resources/regression/verification/newsolvers/valid/BitsTricks.scala deleted file mode 100644 index 6475d9117efb1d9dd152a03f234cf8119f7cf58f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/BitsTricks.scala +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object BitsTricks { - - def bitAt(x: Int, n: Int): Boolean = { - require(n >= 0 && n < 32) - ((x >> n) & 1) == 1 - } - - def isEven(x: Int): Boolean = { - (x & 1) == 0 - } ensuring(res => res == (x % 2 == 0)) - - def isNegative(x: Int): Boolean = { - (x >>> 31) == 1 - } ensuring(b => b == x < 0) - - def isBitNSet(x: Int, n: Int): Int = { - require(n >= 0 && n < 32) - (x & (1 << n)) - } - - def testBitSet1(): Int = { - isBitNSet(122, 3) - } ensuring(_ != 0) - def testBitSet2(): Int = { - isBitNSet(-33, 5) - } ensuring(_ == 0) - - def setBitN(x: Int, n: Int): Int = { - require(n >= 0 && n < 32) - x | (1 << n) - } ensuring(res => isBitNSet(res, n) != 0) - - def toggleBitN(x: Int, n: Int): Int = { - require(n >= 0 && n < 32) - x ^ (1 << n) - } ensuring(res => - if(isBitNSet(x, n) != 0) isBitNSet(res, n) == 0 - else isBitNSet(res, n) != 0) - - - def checkDoubleXor(x: Int, y: Int): Int = { - x ^ y ^ x - } ensuring(res => res == y) - - - def turnOffRightmostOneRec(x: Int, index: Int): Int = { - require(index >= 0 && index < 32) - if(bitAt(x, index)) toggleBitN(x, index)//(x ^ (1 << index)) - else if(index == 31) x - else turnOffRightmostOneRec(x, index + 1) - } - - /* - * loops forever on the proof - */ - def turnOffRightmostOne(x: Int): Int = { - x & (x - 1) - } //ensuring(_ == turnOffRightmostOneRec(x, 0)) - - // 010100 -> 010111 - def rightPropagateRightmostOne(x: Int): Int = { - x | (x - 1) - } - - def property1(x: Int): Boolean = { - val y = rightPropagateRightmostOne(x) - y == rightPropagateRightmostOne(y) - } ensuring(b => b) - - def isRotationLeft(x: Int, y: Int, n: Int, i: Int): Boolean = { - require(i >= 0 && i <= 32 && n >= 0 && n < 32) - if(i == 32) - true - else bitAt(x, i) == bitAt(y, (i + n) % 32) && isRotationLeft(x, y, n, i+1) - } - - //rotateLeft proves in 1 minute (on very powerful computer) - def rotateLeft(x: Int, n: Int): Int = { - require(n >= 0 && n < 32) - val front = x >>> (32 - n) - (x << n) | front - } //ensuring(res => isRotationLeft(x, res, n, 0)) - - //careful with overflows, case definition, truncated - def safeMean(x: Int, y: Int): Int = { - if(x >= 0 && y <= 0 || x <= 0 && y >= 0) (x + y)/2 - else if(x >= 0 && x <= y) x + (y - x)/2 - else if(x >= 0 && y <= x) y + (x - y)/2 - else if(x <= 0 && x <= y) y + (x - y)/2 - else x + (y - x)/2 - } - - //proves in 45 seconds - def magicMean(x: Int, y: Int): Int = { - val t = (x&y)+((x^y) >> 1) - t + ((t >>> 31) & (x ^ y)) - } //ensuring(res => res == safeMean(x, y)) - - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/CaseObject1.scala b/src/test/resources/regression/verification/newsolvers/valid/CaseObject1.scala deleted file mode 100644 index 318af66807102bb5727b365aa9fa4b6f2139d366..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/CaseObject1.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object CaseObject1 { - - abstract sealed class A - case class B(size: Int) extends A - case object C extends A - - def foo(): A = { - C - } - - def foo1(a: A): A = a match { - case C => a - case B(s) => a - } - - def foo2(a: A): A = a match { - case c @ C => c - case B(s) => a - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Field1.scala b/src/test/resources/regression/verification/newsolvers/valid/Field1.scala deleted file mode 100644 index 8c410b3d9ab93b3cb2dc6502a8b355b4722fcef4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Field1.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Field1 { - - abstract sealed class A - case class B(size: Int) extends A - - def foo(): Int = { - val b = B(3) - b.size - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Field2.scala b/src/test/resources/regression/verification/newsolvers/valid/Field2.scala deleted file mode 100644 index db42516e5abc5dabad55ad1decb220e7bc5227f2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Field2.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Field2 { - - abstract sealed class A - case class B(length: Int) extends A - - def foo(): Int = { - val b = B(3) - b.length - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/FiniteSort.scala b/src/test/resources/regression/verification/newsolvers/valid/FiniteSort.scala deleted file mode 100644 index ab85023cb615b25ee57bd575b27ec847e4304ed2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/FiniteSort.scala +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object FiniteSort { - - // These finite sorting functions essentially implement insertion sort. - def sort2(x : BigInt, y : BigInt) : (BigInt,BigInt) = { - if(x < y) (x, y) else (y, x) - } ensuring (_ match { - case (a, b) => a <= b && Set(a,b) == Set(x,y) - }) - - def sort3(x1 : BigInt, x2 : BigInt, x3 : BigInt) : (BigInt, BigInt, BigInt) = { - val (x1s, x2s) = sort2(x1, x2) - - if(x2s <= x3) { - (x1s, x2s, x3) - } else if(x1s <= x3) { - (x1s, x3, x2s) - } else { - (x3, x1s, x2s) - } - } ensuring (_ match { - case (a, b, c) => a <= b && b <= c && Set(a,b,c) == Set(x1,x2,x3) - }) - - def sort4(x1 : BigInt, x2 : BigInt, x3 : BigInt, x4 : BigInt) : (BigInt, BigInt, BigInt, BigInt) = { - val (x1s, x2s, x3s) = sort3(x1, x2, x3) - - if(x3s <= x4) { - (x1s, x2s, x3s, x4) - } else if(x2s <= x4) { - (x1s, x2s, x4, x3s) - } else if(x1s <= x4) { - (x1s, x4, x2s, x3s) - } else { - (x4, x1s, x2s, x3s) - } - } ensuring (_ match { - case (a, b, c, d) => a <= b && b <= c && c <= d && Set(a,b,c,d) == Set(x1,x2,x3,x4) - }) - - def sort5(x1 : BigInt, x2 : BigInt, x3 : BigInt, x4 : BigInt, x5 : BigInt) : (BigInt, BigInt, BigInt, BigInt, BigInt) = { - val (x1s, x2s, x3s, x4s) = sort4(x1, x2, x3, x4) - - if(x4s <= x5) { - (x1s, x2s, x3s, x4s, x5) - } else if(x3s <= x5) { - (x1s, x2s, x3s, x5, x4s) - } else if(x2s <= x5) { - (x1s, x2s, x5, x3s, x4s) - } else if(x1s <= x5) { - (x1s, x5, x2s, x3s, x4s) - } else { - (x5, x1s, x2s, x3s, x4s) - } - } ensuring (_ match { - case (a, b, c, d, e) => a <= b && b <= c && c <= d && d <= e && Set(a,b,c,d,e) == Set(x1,x2,x3,x4,x5) - }) -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/FoolProofAdder.scala b/src/test/resources/regression/verification/newsolvers/valid/FoolProofAdder.scala deleted file mode 100644 index dfc11de525aa88f8cc613fd8a78cd8a57cba9d03..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/FoolProofAdder.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object FoolProofAdder { - - def foolProofAdder(x: BigInt): BigInt = { - require(x > 0) - x + BigInt(999999) + BigInt("999999999999999") - } ensuring(_ > 0) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Generics.scala b/src/test/resources/regression/verification/newsolvers/valid/Generics.scala deleted file mode 100644 index 86ee9d50c2fb06b03d117ab205f659ebd9e569b7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Generics.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Generics { - abstract class List[T] - case class Cons[A](head: A, tail: List[A]) extends List[A] - case class Nil[B]() extends List[B] - - def size[T](l: List[T]): BigInt = (l match { - case Nil() => BigInt(0) - case Cons(h, t) => 1+size(t) - })ensuring { _ >= 0 } - - def content[T](l: List[T]): Set[T] = l match { - case Nil() => Set() - case Cons(h, t) => Set(h) ++ content(t) - } - - def insert[T](a: T, l: List[T]): List[T] = { - Cons(a, l) - } ensuring { res => (size(res) == size(l) + 1) && (content(res) == content(l) ++ Set(a))} -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Generics1.scala b/src/test/resources/regression/verification/newsolvers/valid/Generics1.scala deleted file mode 100644 index e054b629fbd05c17dc0aed5fe9bb6e713f8a8f01..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Generics1.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Generics1 { - abstract class List[T] - case class Cons[A](head: A, tail: List[A]) extends List[A] - case class Nil[B]() extends List[B] - - def size[T](l: List[T]): BigInt = (l match { - case Nil() => BigInt(0) - case Cons(h, t) => size(t) + BigInt(1) - }) ensuring((res: BigInt) => res >= BigInt(0)) - - def content[T](l: List[T]): Set[T] = l match { - case Nil() => Set() - case Cons(h, t) => Set(h) ++ content(t) - } - - def insert[T](a: T, l: List[T]): List[T] = { - Cons(a, l) - } ensuring { res => (size(res) == size(l) + 1) && (content(res) == content(l) ++ Set(a))} - - def insertInt(a: BigInt, l: List[BigInt]): List[BigInt] = { - insert(a,l) - } ensuring { res => (size(res) == size(l) + 1) && (content(res) == content(l) ++ Set(a))} -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Heaps.scala b/src/test/resources/regression/verification/newsolvers/valid/Heaps.scala deleted file mode 100644 index 0e2ca340513497fe107d50d2526b7bee92a448ab..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Heaps.scala +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Heaps { - /*~~~~~~~~~~~~~~~~~~~~~~~*/ - /* Data type definitions */ - /*~~~~~~~~~~~~~~~~~~~~~~~*/ - private case class Node(rank : BigInt, elem : BigInt, nodes : Heap) - - sealed abstract class Heap - private case class Nodes(head : Node, tail : Heap) extends Heap - private case object Empty extends Heap - - sealed abstract class OptInt - case class Some(value : BigInt) extends OptInt - case object None extends OptInt - - /*~~~~~~~~~~~~~~~~~~~~~~~*/ - /* Abstraction functions */ - /*~~~~~~~~~~~~~~~~~~~~~~~*/ - def heapContent(h : Heap) : Set[BigInt] = h match { - case Empty => Set.empty[BigInt] - case Nodes(n, ns) => nodeContent(n) ++ heapContent(ns) - } - - def nodeContent(n : Node) : Set[BigInt] = n match { - case Node(_, e, h) => Set(e) ++ heapContent(h) - } - - /*~~~~~~~~~~~~~~~~~~~~~~~~*/ - /* Helper/local functions */ - /*~~~~~~~~~~~~~~~~~~~~~~~~*/ - private def reverse(h : Heap) : Heap = reverse0(h, Empty) - private def reverse0(h : Heap, acc : Heap) : Heap = (h match { - case Empty => acc - case Nodes(n, ns) => reverse0(ns, Nodes(n, acc)) - }) ensuring(res => heapContent(res) == heapContent(h) ++ heapContent(acc)) - - private def link(t1 : Node, t2 : Node) = (t1, t2) match { - case (Node(r, e1, ns1), Node(_, e2, ns2)) => - if(e1 <= e2) { - Node(r + 1, e1, Nodes(t2, ns1)) - } else { - Node(r + 1, e2, Nodes(t1, ns2)) - } - } - - private def insertNode(t : Node, h : Heap) : Heap = (h match { - case Empty => Nodes(t, Empty) - case Nodes(t2, h2) => - if(t.rank < t2.rank) { - Nodes(t, h) - } else { - insertNode(link(t, t2), h2) - } - }) ensuring(res => heapContent(res) == nodeContent(t) ++ heapContent(h)) - - private def getMin(h : Heap) : (Node, Heap) = { - require(h != Empty) - h match { - case Nodes(t, Empty) => (t, Empty) - case Nodes(t, ts) => - val (t0, ts0) = getMin(ts) - if(t.elem < t0.elem) { - (t, ts) - } else { - (t0, Nodes(t, ts0)) - } - } - } ensuring(_ match { - case (n,h2) => nodeContent(n) ++ heapContent(h2) == heapContent(h) - }) - - /*~~~~~~~~~~~~~~~~*/ - /* Heap Interface */ - /*~~~~~~~~~~~~~~~~*/ - def empty() : Heap = { - Empty - } ensuring(res => heapContent(res) == Set.empty[BigInt]) - - def isEmpty(h : Heap) : Boolean = { - (h == Empty) - } ensuring(res => res == (heapContent(h) == Set.empty[BigInt])) - - def insert(e : BigInt, h : Heap) : Heap = { - insertNode(Node(0, e, Empty), h) - } ensuring(res => heapContent(res) == heapContent(h) ++ Set(e)) - - def merge(h1 : Heap, h2 : Heap) : Heap = ((h1,h2) match { - case (_, Empty) => h1 - case (Empty, _) => h2 - case (Nodes(t1, ts1), Nodes(t2, ts2)) => - if(t1.rank < t2.rank) { - Nodes(t1, merge(ts1, h2)) - } else if(t2.rank < t1.rank) { - Nodes(t2, merge(h1, ts2)) - } else { - insertNode(link(t1, t2), merge(ts1, ts2)) - } - }) ensuring(res => heapContent(res) == heapContent(h1) ++ heapContent(h2)) - - def findMin(h : Heap) : OptInt = (h match { - case Empty => None - case Nodes(Node(_, e, _), ns) => - findMin(ns) match { - case None => Some(e) - case Some(e2) => Some(if(e < e2) e else e2) - } - }) ensuring(_ match { - case None => isEmpty(h) - case Some(v) => heapContent(h).contains(v) - }) - - def deleteMin(h : Heap) : Heap = (h match { - case Empty => Empty - case ts : Nodes => - val (Node(_, e, ns1), ns2) = getMin(ts) - merge(reverse(ns1), ns2) - }) ensuring(res => heapContent(res).subsetOf(heapContent(h))) - - def sanity0() : Boolean = { - val h0 : Heap = Empty - val h1 = insert(42, h0) - val h2 = insert(72, h1) - val h3 = insert(0, h2) - findMin(h0) == None && - findMin(h1) == Some(42) && - findMin(h2) == Some(42) && - findMin(h3) == Some(0) - }.holds - - def sanity1() : Boolean = { - val h0 = insert(42, Empty) - val h1 = insert(0, Empty) - val h2 = merge(h0, h1) - findMin(h2) == Some(0) - }.holds - - def sanity3() : Boolean = { - val h0 = insert(42, insert(0, insert(12, Empty))) - val h1 = deleteMin(h0) - findMin(h1) == Some(12) - }.holds -} - diff --git a/src/test/resources/regression/verification/newsolvers/valid/InsertionSort.scala b/src/test/resources/regression/verification/newsolvers/valid/InsertionSort.scala deleted file mode 100644 index 655f84797c93e61dbe863e516c3b8204f5b4e133..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/InsertionSort.scala +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object InsertionSort { - sealed abstract class List - case class Cons(head:BigInt,tail:List) extends List - case class Nil() extends List - - sealed abstract class OptInt - case class Some(value: BigInt) extends OptInt - case class None() extends OptInt - - def size(l : List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def contents(l: List): Set[BigInt] = l match { - case Nil() => Set.empty - case Cons(x,xs) => contents(xs) ++ Set(x) - } - - def min(l : List) : OptInt = l match { - case Nil() => None() - case Cons(x, xs) => min(xs) match { - case None() => Some(x) - case Some(x2) => if(x < x2) Some(x) else Some(x2) - } - } - - def isSorted(l: List): Boolean = l match { - case Nil() => true - case Cons(x, Nil()) => true - case Cons(x, Cons(y, ys)) => x <= y && isSorted(Cons(y, ys)) - } - - /* Inserting element 'e' into a sorted list 'l' produces a sorted list with - * the expected content and size */ - def sortedIns(e: BigInt, l: List): List = { - require(isSorted(l)) - l match { - case Nil() => Cons(e,Nil()) - case Cons(x,xs) => if (x <= e) Cons(x,sortedIns(e, xs)) else Cons(e, l) - } - } ensuring(res => contents(res) == contents(l) ++ Set(e) - && isSorted(res) - && size(res) == size(l) + 1 - ) - - /* Insertion sort yields a sorted list of same size and content as the input - * list */ - def sort(l: List): List = (l match { - case Nil() => Nil() - case Cons(x,xs) => sortedIns(x, sort(xs)) - }) ensuring(res => contents(res) == contents(l) - && isSorted(res) - && size(res) == size(l) - ) - - @ignore - def main(args: Array[String]): Unit = { - val ls: List = Cons(5, Cons(2, Cons(4, Cons(5, Cons(1, Cons(8,Nil())))))) - - println(ls) - println(sort(ls)) - } -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/InstanceOf1.scala b/src/test/resources/regression/verification/newsolvers/valid/InstanceOf1.scala deleted file mode 100644 index 6901da6c8d3cb85afe16343513cabebaa1fc59a0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/InstanceOf1.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object InstanceOf1 { - - abstract class A - case class B(i: Int) extends A - case class C(i: Int) extends A - - def foo(): Int = { - require(C(3).isInstanceOf[C]) - val b: A = B(2) - if(b.isInstanceOf[B]) - 0 - else - -1 - } ensuring(_ == 0) - - def bar(): Int = foo() - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/ListOperations.scala b/src/test/resources/regression/verification/newsolvers/valid/ListOperations.scala deleted file mode 100644 index 47283ef72c3862258c2800f83595812ad1a5cc40..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/ListOperations.scala +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ -import leon.collection._ - -object ListOperations { - - def size[A](l: List[A]) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, t) => BigInt(1) + size(t) - }) ensuring(res => res >= 0) - - def content[A](l: List[A]) : Set[A] = l match { - case Nil() => Set[A]() - case Cons(h, t) => content(t) ++ Set[A](h) - } - - def zip[A,B](l1: List[A], l2: List[B]): List[(A, B)] = { - // try to comment this and see how pattern-matching becomes - // non-exhaustive and post-condition fails - require(size(l1) == size(l2)) - (l1, l2) match { - case (Nil(), Nil()) => - Nil[(A, B)]() - case (Cons(x, xs), Cons(y, ys)) => - Cons( (x,y), zip(xs, ys) ) - } - } ensuring(size(_) == size(l1)) - - def sizeTailRec[A](l: List[A]) : BigInt = sizeTailRecAcc(l, 0) - - def sizeTailRecAcc[A](l: List[A], acc: BigInt) : BigInt = { - require(acc >= 0) - l match { - case Nil() => acc - case Cons(_, xs) => sizeTailRecAcc(xs, acc+1) - } - } ensuring(res => res == size(l) + acc) - - def sizesAreEquiv[A](l: List[A]) : Boolean = { - size(l) == sizeTailRec(l) - }.holds - - def sizeAndContent[A](l: List[A]) : Boolean = { - size(l) == BigInt(0) || content(l) != Set.empty[A] - }.holds - - def drunk[A](l : List[A]) : List[A] = (l match { - case Nil() => Nil[A]() - case Cons(x,l1) => Cons(x,Cons(x,drunk(l1))) - }) ensuring (size(_) == 2 * size(l)) - - def reverse[A](l: List[A]) : List[A] = reverse0(l, Nil[A]()) ensuring(content(_) == content(l)) - def reverse0[A](l1: List[A], l2: List[A]) : List[A] = (l1 match { - case Nil() => l2 - case Cons(x, xs) => reverse0(xs, Cons[A](x, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - def append[A](l1 : List[A], l2 : List[A]) : List[A] = (l1 match { - case Nil() => l2 - case Cons(x,xs) => Cons[A](x, append(xs, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def nilAppend[A](l : List[A]) : Boolean = (append(l, Nil[A]()) == l).holds - - @induct - def appendAssoc[A](xs : List[A], ys : List[A], zs : List[A]) : Boolean = - (append(append(xs, ys), zs) == append(xs, append(ys, zs))).holds - - @induct - def sizeAppend[A](l1 : List[A], l2 : List[A]) : Boolean = - (size(append(l1, l2)) == size(l1) + size(l2)).holds - - @induct - def concat[A](l1: List[A], l2: List[A]) : List[A] = - concat0(l1, l2, Nil[A]()) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def concat0[A](l1: List[A], l2: List[A], l3: List[A]) : List[A] = (l1 match { - case Nil() => l2 match { - case Nil() => reverse(l3) - case Cons(y, ys) => { - concat0(Nil[A](), ys, Cons(y, l3)) - } - } - case Cons(x, xs) => concat0(xs, l2, Cons(x, l3)) - }) ensuring(content(_) == content(l1) ++ content(l2) ++ content(l3)) -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/LiteralMaps.scala b/src/test/resources/regression/verification/newsolvers/valid/LiteralMaps.scala deleted file mode 100644 index a0f2d22f389c81856a02a7e34ae57aaf2e13cfd9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/LiteralMaps.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -object LiteralMaps { - def test(): Map[Int, Int] = { - Map(1 -> 2, 3 -> 4, (5, 6)) - } - - def test2(): (Int, Int) = { - 1 -> 2 - } - - def test3(): Map[Int, Int] = { - Map[Int, Int]() - } - - def test4(): Map[Int, Int] = { - Map.empty[Int, Int] - } - - def test5(): Map[Int, Int] = { - Map.empty[Int, Int] - } -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MergeSort.scala b/src/test/resources/regression/verification/newsolvers/valid/MergeSort.scala deleted file mode 100644 index 99681add4516588b33dc62ddd255a0520598a299..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MergeSort.scala +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object MergeSort { - // Data types - sealed abstract class List - case class Cons(head : BigInt, tail : List) extends List - case class Nil() extends List - - sealed abstract class LList - case class LCons(head : List, tail : LList) extends LList - case class LNil() extends LList - - def content(list : List) : Set[BigInt] = list match { - case Nil() => Set.empty[BigInt] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def lContent(llist : LList) : Set[BigInt] = llist match { - case LNil() => Set.empty[BigInt] - case LCons(x, xs) => content(x) ++ lContent(xs) - } - - def size(list : List) : BigInt = (list match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def isSorted(list : List) : Boolean = list match { - case Nil() => true - case Cons(_, Nil()) => true - case Cons(x1, Cons(x2, _)) if(x1 > x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def lIsSorted(llist : LList) : Boolean = llist match { - case LNil() => true - case LCons(x, xs) => isSorted(x) && lIsSorted(xs) - } - - def abs(i : BigInt) : BigInt = { - if(i < 0) -i else i - } ensuring(_ >= 0) - - def mergeSpec(list1 : List, list2 : List, res : List) : Boolean = { - isSorted(res) && content(res) == content(list1) ++ content(list2) - } - - def mergeFast(list1 : List, list2 : List) : List = { - require(isSorted(list1) && isSorted(list2)) - - (list1, list2) match { - case (_, Nil()) => list1 - case (Nil(), _) => list2 - case (Cons(x, xs), Cons(y, ys)) => - if(x <= y) { - Cons(x, mergeFast(xs, list2)) - } else { - Cons(y, mergeFast(list1, ys)) - } - } - } ensuring(res => mergeSpec(list1, list2, res)) - - def splitSpec(list : List, res : (List,List)) : Boolean = { - val s1 = size(res._1) - val s2 = size(res._2) - abs(s1 - s2) <= 1 && s1 + s2 == size(list) && - content(res._1) ++ content(res._2) == content(list) - } - - def split(list : List) : (List,List) = (list match { - case Nil() => (Nil(), Nil()) - case Cons(x, Nil()) => (Cons(x, Nil()), Nil()) - case Cons(x1, Cons(x2, xs)) => - val (s1,s2) = split(xs) - (Cons(x1, s1), Cons(x2, s2)) - }) ensuring(res => splitSpec(list, res)) - - def sortSpec(in : List, out : List) : Boolean = { - content(out) == content(in) && isSorted(out) - } - - // Not really quicksort, neither mergesort. - def weirdSort(in : List) : List = (in match { - case Nil() => Nil() - case Cons(x, Nil()) => Cons(x, Nil()) - case _ => - val (s1,s2) = split(in) - mergeFast(weirdSort(s1), weirdSort(s2)) - }) ensuring(res => sortSpec(in, res)) - - def toLList(list : List) : LList = (list match { - case Nil() => LNil() - case Cons(x, xs) => LCons(Cons(x, Nil()), toLList(xs)) - }) ensuring(res => lContent(res) == content(list) && lIsSorted(res)) - - def mergeMap(llist : LList) : LList = { - require(lIsSorted(llist)) - - llist match { - case LNil() => LNil() - case o @ LCons(x, LNil()) => o - case LCons(x, LCons(y, ys)) => LCons(mergeFast(x, y), mergeMap(ys)) - } - } ensuring(res => lContent(res) == lContent(llist) && lIsSorted(res)) - - def mergeReduce(llist : LList) : List = { - require(lIsSorted(llist)) - - llist match { - case LNil() => Nil() - case LCons(x, LNil()) => x - case _ => mergeReduce(mergeMap(llist)) - } - } ensuring(res => content(res) == lContent(llist) && isSorted(res)) - - def mergeSort(in : List) : List = { - mergeReduce(toLList(in)) - } ensuring(res => sortSpec(in, res)) -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MyMap.scala b/src/test/resources/regression/verification/newsolvers/valid/MyMap.scala deleted file mode 100644 index 9cb5fa4b3f557670ef746a25b90f992acdd0bbf0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MyMap.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object MyMap { - - def map1(): Int = { - val m = Map(1 -> 2, 2 -> 3, 3 -> 4) - m(2) - } ensuring(_ == 3) - - def map2(): Boolean = { - val m1 = Map[Int, Int]() - val m2 = Map.empty[Int, Int] - m1 == m2 - }.holds - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MySet.scala b/src/test/resources/regression/verification/newsolvers/valid/MySet.scala deleted file mode 100644 index 13efa589eba329e820726b7b8a0ba9f42907358c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MySet.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object MySet { - - def set1(): Boolean = { - val s = Set(1, 2, 3, 4) - s.contains(3) - }.holds - - def set2(): Boolean = { - val s1 = Set[Int]() - val s2 = Set.empty[Int] - s1 == s2 - }.holds - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MyTuple1.scala b/src/test/resources/regression/verification/newsolvers/valid/MyTuple1.scala deleted file mode 100644 index 55ba48e8e56c4a2b755d759851bb88568a87f0eb..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MyTuple1.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple1 { - - def foo(): Int = { - val t = (1, true, 3) - val a1 = t._1 - val a2 = t._2 - val a3 = t._3 - a3 - } ensuring( _ == 3) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MyTuple2.scala b/src/test/resources/regression/verification/newsolvers/valid/MyTuple2.scala deleted file mode 100644 index 8683adcdeeee636ed68e4e13f5d164f09c60688c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MyTuple2.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple2 { - - abstract class A - case class B(i: Int) extends A - case class C(a: A) extends A - - def foo(): Int = { - val t = (B(2), C(B(3))) - t match { - case (B(x), C(y)) => x - } - } ensuring(_ == 2) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MyTuple3.scala b/src/test/resources/regression/verification/newsolvers/valid/MyTuple3.scala deleted file mode 100644 index db4f82411b9e62b3a3a34cc57347a9b2c83247dd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MyTuple3.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple3 { - - def foo(): Int = { - val t = ((2, 3), true) - t._1._2 - } ensuring( _ == 3) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MyTuple4.scala b/src/test/resources/regression/verification/newsolvers/valid/MyTuple4.scala deleted file mode 100644 index 6dd4d3c1c6e04d7662de02a0d956fdc7d95b9547..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MyTuple4.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -object MyTuple4 { - - abstract class A - case class B(i: Int) extends A - case class C(a: A) extends A - - def foo(): Int = { - val t = (1, (C(B(4)), 2), 3) - val (a1, (C(B(x)), a2), a3) = t - x - } ensuring( _ == 4) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MyTuple5.scala b/src/test/resources/regression/verification/newsolvers/valid/MyTuple5.scala deleted file mode 100644 index d8fff88781251281e0c56c494a7f8e4d9b81bd5b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MyTuple5.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple5 { - - abstract class A - case class B(t: (Int, Int)) extends A - case class C(a: A) extends A - - def foo(): Int = { - val t: (Int, (A, Int), Int) = (1, (C(B((4, 5))), 2), 3) - t match { - case (_, (B((x, y)), _), _) => x - case (_, (C(B((_, x))), _), y) => x - case (_, _, x) => x - } - } ensuring( _ == 5) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/MyTuple6.scala b/src/test/resources/regression/verification/newsolvers/valid/MyTuple6.scala deleted file mode 100644 index f8cc1b42393ae8bdb66f92b22061bff99c5a2cc2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/MyTuple6.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple6 { - - def foo(t: (Int, Int)): (Int, Int) = { - require(t._1 > 0 && t._2 > 1) - t - } ensuring(res => res._1 > 0 && res._2 > 1) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Nat.scala b/src/test/resources/regression/verification/newsolvers/valid/Nat.scala deleted file mode 100644 index b766230abd988de18b696266e8156ba1c48e6dae..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Nat.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Nat { - sealed abstract class Nat - case class Zero() extends Nat - case class Succ(num: Nat) extends Nat - - def plus(a: Nat, b: Nat): Nat = a match { - case Zero() => b - case Succ(a1) => Succ(plus(a1, b)) - } - - def nat2Int(n: Nat): Int = n match { - case Zero() => 0 - case Succ(n1) => 1 + nat2Int(n1) - } - - def int2Nat(n: Int): Nat = if (n == 0) Zero() else Succ(int2Nat(n-1)) - - def sum_lemma(): Boolean = { - 3 == nat2Int(plus(int2Nat(1), int2Nat(2))) - }.holds -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/NotEquals.scala b/src/test/resources/regression/verification/newsolvers/valid/NotEquals.scala deleted file mode 100644 index 31a4bc763600ac9a8e0b5d0cc4bec308cc110955..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/NotEquals.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object NotEquals { - - // Represents n/d - case class Q(n: BigInt, d: BigInt) - - def op(a: Q, b: Q) = { - require(isRational(a) && isRational(b)) - - Q(a.n + b.n, a.d) - } ensuring { - isRational(_) - } - - //def isRational(a: Q) = a.d != 0 - def isRational(a: Q) = a.d != 0 - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/PositiveMap.scala b/src/test/resources/regression/verification/newsolvers/valid/PositiveMap.scala deleted file mode 100644 index a9a07c9850de6d9e9c7de498996d9f1b16d6d532..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/PositiveMap.scala +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object PositiveMap { - - abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def positive(list: List): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def positiveMap_passing_1(f: (BigInt) => BigInt, list: List): List = { - list match { - case Cons(head, tail) => - val fh = f(head) - val nh = if (fh <= 0) -fh else fh - Cons(nh, positiveMap_passing_1(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } - - def positiveMap_passing_2(f: (BigInt) => BigInt, list: List): List = { - list match { - case Cons(head, tail) => - val fh = f(head) - val nh = if (fh < 0) -fh else fh - Cons(nh, positiveMap_passing_2(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/newsolvers/valid/PropositionalLogic.scala b/src/test/resources/regression/verification/newsolvers/valid/PropositionalLogic.scala deleted file mode 100644 index fa7c0cf487cca517f1b134b0acb7ba02a93ebe3d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/PropositionalLogic.scala +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object PropositionalLogic { - - sealed abstract class Formula - case class And(lhs: Formula, rhs: Formula) extends Formula - case class Or(lhs: Formula, rhs: Formula) extends Formula - case class Implies(lhs: Formula, rhs: Formula) extends Formula - case class Not(f: Formula) extends Formula - case class Literal(id: Int) extends Formula - - def simplify(f: Formula): Formula = (f match { - case And(lhs, rhs) => And(simplify(lhs), simplify(rhs)) - case Or(lhs, rhs) => Or(simplify(lhs), simplify(rhs)) - case Implies(lhs, rhs) => Or(Not(simplify(lhs)), simplify(rhs)) - case Not(f) => Not(simplify(f)) - case Literal(_) => f - }) ensuring(isSimplified(_)) - - def isSimplified(f: Formula): Boolean = f match { - case And(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Or(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Implies(_,_) => false - case Not(f) => isSimplified(f) - case Literal(_) => true - } - - def nnf(formula: Formula): Formula = (formula match { - case And(lhs, rhs) => And(nnf(lhs), nnf(rhs)) - case Or(lhs, rhs) => Or(nnf(lhs), nnf(rhs)) - case Implies(lhs, rhs) => Implies(nnf(lhs), nnf(rhs)) - case Not(And(lhs, rhs)) => Or(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Or(lhs, rhs)) => And(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Implies(lhs, rhs)) => And(nnf(lhs), nnf(Not(rhs))) - case Not(Not(f)) => nnf(f) - case Not(Literal(_)) => formula - case Literal(_) => formula - }) ensuring(isNNF(_)) - - def isNNF(f: Formula): Boolean = f match { - case And(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Or(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Implies(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Not(Literal(_)) => true - case Not(_) => false - case Literal(_) => true - } - - def vars(f: Formula): Set[Int] = { - require(isNNF(f)) - f match { - case And(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Or(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Implies(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Not(Literal(i)) => Set[Int](i) - case Literal(i) => Set[Int](i) - } - } - - def fv(f : Formula) = { vars(nnf(f)) } - - @induct - def nnfIsStable(f: Formula) : Boolean = { - require(isNNF(f)) - nnf(f) == f - }.holds - - @induct - def simplifyIsStable(f: Formula) : Boolean = { - require(isSimplified(f)) - simplify(f) == f - }.holds -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/README b/src/test/resources/regression/verification/newsolvers/valid/README deleted file mode 100644 index 2bb01d5fdbd6b59970c0c84f2c10db1ead6097a2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/README +++ /dev/null @@ -1,2 +0,0 @@ -This particular directory contains PureScala programs that can be entirely -proved correct by Leon. diff --git a/src/test/resources/regression/verification/newsolvers/valid/RedBlackTree.scala b/src/test/resources/regression/verification/newsolvers/valid/RedBlackTree.scala deleted file mode 100644 index a40068e7081dc594d7419e38f436cbca3751f8da..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/RedBlackTree.scala +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object RedBlackTree { - sealed abstract class Color - case class Red() extends Color - case class Black() extends Color - - sealed abstract class Tree - case class Empty() extends Tree - case class Node(color: Color, left: Tree, value: BigInt, right: Tree) extends Tree - - sealed abstract class OptionInt - case class Some(v : BigInt) extends OptionInt - case class None() extends OptionInt - - def content(t: Tree) : Set[BigInt] = t match { - case Empty() => Set.empty - case Node(_, l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def size(t: Tree) : BigInt = (t match { - case Empty() => BigInt(0) - case Node(_, l, v, r) => size(l) + 1 + size(r) - }) ensuring(_ >= 0) - - /* We consider leaves to be black by definition */ - def isBlack(t: Tree) : Boolean = t match { - case Empty() => true - case Node(Black(),_,_,_) => true - case _ => false - } - - def redNodesHaveBlackChildren(t: Tree) : Boolean = t match { - case Empty() => true - case Node(Black(), l, _, r) => redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - case Node(Red(), l, _, r) => isBlack(l) && isBlack(r) && redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - } - - def redDescHaveBlackChildren(t: Tree) : Boolean = t match { - case Empty() => true - case Node(_,l,_,r) => redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - } - - def blackBalanced(t : Tree) : Boolean = t match { - case Node(_,l,_,r) => blackBalanced(l) && blackBalanced(r) && blackHeight(l) == blackHeight(r) - case Empty() => true - } - - def blackHeight(t : Tree) : BigInt = t match { - case Empty() => 1 - case Node(Black(), l, _, _) => blackHeight(l) + 1 - case Node(Red(), l, _, _) => blackHeight(l) - } - - // <<insert element x into the tree t>> - def ins(x: BigInt, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t) && blackBalanced(t)) - t match { - case Empty() => Node(Red(),Empty(),x,Empty()) - case Node(c,a,y,b) => - if (x < y) balance(c, ins(x, a), y, b) - else if (x == y) Node(c,a,y,b) - else balance(c,a,y,ins(x, b)) - } - } ensuring (res => content(res) == content(t) ++ Set(x) - && size(t) <= size(res) && size(res) <= size(t) + 1 - && redDescHaveBlackChildren(res) - && blackBalanced(res)) - - def makeBlack(n: Tree): Tree = { - require(redDescHaveBlackChildren(n) && blackBalanced(n)) - n match { - case Node(Red(),l,v,r) => Node(Black(),l,v,r) - case _ => n - } - } ensuring(res => redNodesHaveBlackChildren(res) && blackBalanced(res)) - - def add(x: BigInt, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t) && blackBalanced(t)) - makeBlack(ins(x, t)) - } ensuring (res => content(res) == content(t) ++ Set(x) && redNodesHaveBlackChildren(res) && blackBalanced(res)) - - def balance(c: Color, a: Tree, x: BigInt, b: Tree): Tree = { - Node(c,a,x,b) match { - case Node(Black(),Node(Red(),Node(Red(),a,xV,b),yV,c),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),Node(Red(),a,xV,Node(Red(),b,yV,c)),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),Node(Red(),b,yV,c),zV,d)) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),b,yV,Node(Red(),c,zV,d))) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(c,a,xV,b) => Node(c,a,xV,b) - } - } ensuring (res => content(res) == content(Node(c,a,x,b)))// && redDescHaveBlackChildren(res)) -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/SearchLinkedList.scala b/src/test/resources/regression/verification/newsolvers/valid/SearchLinkedList.scala deleted file mode 100644 index 49fad86821600124f2d336cc894f23ff76a1db2e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/SearchLinkedList.scala +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object SearchLinkedList { - sealed abstract class List - case class Cons(head : BigInt, tail : List) extends List - case class Nil() extends List - - def size(list : List) : BigInt = (list match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def contains(list : List, elem : BigInt) : Boolean = (list match { - case Nil() => false - case Cons(x, xs) => x == elem || contains(xs, elem) - }) - - def firstZero(list : List) : BigInt = (list match { - case Nil() => BigInt(0) - case Cons(x, xs) => if (x == 0) BigInt(0) else firstZero(xs) + 1 - }) ensuring (res => - res >= 0 && (if (contains(list, 0)) { - firstZeroAtPos(list, res) - } else { - res == size(list) - })) - - def firstZeroAtPos(list : List, pos : BigInt) : Boolean = { - list match { - case Nil() => false - case Cons(x, xs) => if (pos == BigInt(0)) x == 0 else x != 0 && firstZeroAtPos(xs, pos - 1) - } - } - - def goal(list : List, i : BigInt) : Boolean = { - if(firstZero(list) == i) { - if(contains(list, 0)) { - firstZeroAtPos(list, i) - } else { - i == size(list) - } - } else { - true - } - }.holds -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Subtyping1.scala b/src/test/resources/regression/verification/newsolvers/valid/Subtyping1.scala deleted file mode 100644 index f971d2a596e3b0af47453c5ffbf89a4766e1ea44..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Subtyping1.scala +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Subtyping1 { - - sealed abstract class Tree - case class Leaf() extends Tree - case class Node(left: Tree, value: Int, right: Tree) extends Tree - - def content(t: Tree) : Set[Int] = t match { - case Leaf() => Set.empty - case Node(l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def treeMax(tree: Node): Int = { - tree.right match { - case Leaf() => tree.value - case n:Node => treeMax(n) - } - } ensuring(content(tree).contains(_)) - - def f2(tree: Node): Int = { - require(treeMax(tree) > 0) - tree.right match { - case Leaf() => tree.value - case n:Node => f2(n) - } - } ensuring(content(tree).contains(_)) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Subtyping2.scala b/src/test/resources/regression/verification/newsolvers/valid/Subtyping2.scala deleted file mode 100644 index bbb436b6a134a427e97aab1527fbaaeea49a16c9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Subtyping2.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Subtyping2 { - - abstract class List - case class Nil() extends List - case class Cons(head: Int, tail: List) extends List - - def test(x: List): Nil = { - x match { - case Cons(_, tail) => test(tail) - case Nil() => Nil() - } - } ensuring((res: Nil) => isEmpty(res)) - - def isEmpty(x: List): Boolean = x match { - case Nil() => true - case _ => false - } - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Unit1.scala b/src/test/resources/regression/verification/newsolvers/valid/Unit1.scala deleted file mode 100644 index 596f7cc319bddcf495fd281e820a0f5bc7f1144f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Unit1.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Unit1 { - - def foo(): Unit = ({ - () - }) ensuring(r => true) - -} diff --git a/src/test/resources/regression/verification/newsolvers/valid/Unit2.scala b/src/test/resources/regression/verification/newsolvers/valid/Unit2.scala deleted file mode 100644 index 1aa3cf55bdd9de42855d7a7311a73f47256c917a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/newsolvers/valid/Unit2.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Unit2 { - - def foo(u: Unit): Unit = { - u - } ensuring(res => true) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/ADTWithArray1.scala b/src/test/resources/regression/verification/purescala/invalid/ADTWithArray1.scala deleted file mode 100644 index aad1782e1d09f64a92400cc653e5dc3e0dc1400b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/ADTWithArray1.scala +++ /dev/null @@ -1,14 +0,0 @@ -object ADTWithArray1 { - - case class A(x: Int) - - case class B(content: Array[A]) { - require(content.length > 0) - - def contains(y: Int): Boolean = { - require(content.length > 0) - content(0).x == y - } ensuring(res => res) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/ADTWithArray2.scala b/src/test/resources/regression/verification/purescala/invalid/ADTWithArray2.scala deleted file mode 100644 index 952f183d43bb18cacd7ebab86a763678d1814c4e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/ADTWithArray2.scala +++ /dev/null @@ -1,13 +0,0 @@ -import leon.collection._ - -object ADTWithArray2 { - - case class B(content: Array[List[BigInt]]) { - require(content.length > 0 && content.length < 100) - - def contains(y: BigInt): Boolean = { - y >= 0 - } ensuring(res => res == content(0).contains(y)) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/AbstractRefinementMap.scala b/src/test/resources/regression/verification/purescala/invalid/AbstractRefinementMap.scala deleted file mode 100644 index 30acb0f91be22b7c53eac47ee5e1e4df05b9872e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/AbstractRefinementMap.scala +++ /dev/null @@ -1,22 +0,0 @@ -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object AbstractRefinementMap { - - case class ~>[A,B](private val f: A => B, pre: A => Boolean, ens: B => Boolean) { - def apply(x: A): B = { - require(pre(x)) - f(x) - } ensuring(ens) - } - - def map[A, B](l: List[A], f: A ~> B): List[B] = { - require(forall((x:A) => l.contains(x) ==> f.pre(x))) - l match { - case Cons(x, xs) => Cons[B](f(x), map(xs, f)) - case Nil() => Nil[B]() - } - } ensuring { res => forall((x: B) => res.contains(x) ==> f.ens(x)) } -} - diff --git a/src/test/resources/regression/verification/purescala/invalid/AbstractRefinementMap2.scala b/src/test/resources/regression/verification/purescala/invalid/AbstractRefinementMap2.scala deleted file mode 100644 index f0cb1841376bf5b107da22f755d34bb33cc82fde..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/AbstractRefinementMap2.scala +++ /dev/null @@ -1,24 +0,0 @@ -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object AbstractRefinementMap2 { - - case class ~>[A,B](private val f: A => B, pre: A => Boolean, ens: B => Boolean) { - require(forall((x: A) => pre(x) ==> ens(f(x)))) - - def apply(x: A): B = { - require(pre(x)) - f(x) - } ensuring(ens) - } - - def map[A, B](l: List[A], f: A ~> B): List[B] = { - require(forall((x:A) => l.contains(x) ==> f.pre(x))) - l match { - case Cons(x, xs) => Cons[B](f(x), map(xs, f)) - case Nil() => Nil[B]() - } - } ensuring { res => forall((x: B) => /* res.contains(x) ==> */ f.ens(x)) } -} - diff --git a/src/test/resources/regression/verification/purescala/invalid/Acc.scala b/src/test/resources/regression/verification/purescala/invalid/Acc.scala deleted file mode 100644 index 2005a7d0310fabcaa611c5e71d7d3653b77b27d3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Acc.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Acc { - - case class Acc(checking : Int, savings : Int) - - def putAside(x: Int, a: Acc): Acc = { - require (x > 0 && notRed(a) && a.checking >= x) - Acc(a.checking - x, a.savings + x) - } ensuring { - r => notRed(r) && sameTotal(a, r) - } - - - def sameTotal(a1: Acc, a2: Acc): Boolean = { - a1.checking + a1.savings == a2.checking + a2.savings - } - - def notRed(a: Acc) : Boolean = { - a.checking >= 0 && a.savings >= 0 - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/AddingNegativeNumbers.scala b/src/test/resources/regression/verification/purescala/invalid/AddingNegativeNumbers.scala deleted file mode 100644 index 98f5de2e248eb40fb6d4cbb6565093d725a2745e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/AddingNegativeNumbers.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package test.resources.regression.verification.purescala.invalid - -object AddingNegativeNumbers { - - def additionOverflow(x: Int, y: Int): Int = { - require(x <= 0 && y <= 0) - x + y - } ensuring(_ <= 0) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/AddingPositiveNumbers.scala b/src/test/resources/regression/verification/purescala/invalid/AddingPositiveNumbers.scala deleted file mode 100644 index 6bebade9591e59f844fae5180d6b85401dc186ba..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/AddingPositiveNumbers.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object AddingPositiveNumbers { - - //this should overflow with bit vectors - def additionOverflow(x: Int, y: Int): Int = { - require(x >= 0 && y >= 0) - x + y - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Array1.scala b/src/test/resources/regression/verification/purescala/invalid/Array1.scala deleted file mode 100644 index 3707c62e6bc3a00c8f4cdcdde471c04b086a1476..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Array1.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array1 { - - def foo(a: Array[Int]): Int = { - a(2) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Array2.scala b/src/test/resources/regression/verification/purescala/invalid/Array2.scala deleted file mode 100644 index b241dc8cbfd74991dd8ecec9f1c43cd165120942..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Array2.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array2 { - - def foo(a: Array[Int]): Int = { - require(a.length > 2) - a(2) - } ensuring(_ == 0) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Array3.scala b/src/test/resources/regression/verification/purescala/invalid/Array3.scala deleted file mode 100644 index 4307c3982dad5c88608091f5891ea5d227881819..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Array3.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array3 { - def find(c: Array[Int], i: Int): Int = { - require(i >= 0) - if(c(i) == i) - 42 - else - 12 - } ensuring(_ > 0) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Array4.scala b/src/test/resources/regression/verification/purescala/invalid/Array4.scala deleted file mode 100644 index 35a6479b9e11d8d1917a554a0e36017af556f804..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Array4.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array4 { - - def foo(a: Array[Int]): Int = { - val tmp = a.updated(0, 0) - tmp(0) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Array5.scala b/src/test/resources/regression/verification/purescala/invalid/Array5.scala deleted file mode 100644 index d988169400fc6d7db67a9595b54142935c2eba81..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Array5.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array5 { - - def foo(a: Array[Int]): Int = { - a(2) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Array6.scala b/src/test/resources/regression/verification/purescala/invalid/Array6.scala deleted file mode 100644 index d856d9e9e29584e34ef348ea8469393bf8f7309b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Array6.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array6 { - - def foo(a: Array[Int]): Int = { - require(a.length > 2) - a(2) - } ensuring(_ == 0) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Array7.scala b/src/test/resources/regression/verification/purescala/invalid/Array7.scala deleted file mode 100644 index 9c2c788f7a90c787a44944c4b0e3fa14c89dcd1d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Array7.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array7 { - - def foo(a: Array[Int]): Int = { - require(a.length > 0) - val a2 = a.updated(1, 2) - a2(0) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Asserts1.scala b/src/test/resources/regression/verification/purescala/invalid/Asserts1.scala deleted file mode 100644 index 38c7eb435a6bab2b3cc77b340cf0bb910cb891e4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Asserts1.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ -import leon._ - -object Asserts1 { - - def foo(a: Int): Int = { - require(a > 0) - val b = a - assert(b > 0, "Hey now") - b + bar(1) - } ensuring { res => - res > a && res < 2 - } - - def bar(a: Int): Int = { - require(a > 0) - val b = a - assert(b > 0, "Hey now") - b + 2 - } ensuring { res => - res > a && res > 2 - } -} diff --git a/src/test/resources/regression/verification/purescala/invalid/AssociativityProperties.scala b/src/test/resources/regression/verification/purescala/invalid/AssociativityProperties.scala deleted file mode 100644 index b143816e8d5a28437701567b2459511882a805dd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/AssociativityProperties.scala +++ /dev/null @@ -1,26 +0,0 @@ -import leon.lang._ - -object AssociativityProperties { - - def isAssociative[A](f: (A,A) => A): Boolean = { - forall((x: A, y: A, z: A) => f(f(x, y), z) == f(x, f(y, z))) - } - - def isCommutative[A](f: (A,A) => A): Boolean = { - forall((x: A, y: A) => f(x, y) == f(y, x)) - } - - def isRotate[A](f: (A,A) => A): Boolean = { - forall((x: A, y: A, z: A) => f(f(x, y), z) == f(f(y, z), x)) - } - - def assocNotCommutative[A](f: (A,A) => A): Boolean = { - require(isAssociative(f)) - isCommutative(f) - }.holds - - def commNotAssociative[A](f: (A,A) => A): Boolean = { - require(isCommutative(f)) - isAssociative(f) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/invalid/BVDivision2.scala b/src/test/resources/regression/verification/purescala/invalid/BVDivision2.scala deleted file mode 100644 index ab320c8c3bc9a90a83c85c253b58a4b9e048ad1e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/BVDivision2.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object BVDivision2 { - - def division(x: Int, y: Int): Int = { - x / y - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/BVDivisionByZero.scala b/src/test/resources/regression/verification/purescala/invalid/BVDivisionByZero.scala deleted file mode 100644 index 632a7f423a9d2678ab2aa2f7de830e8b1738bb4c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/BVDivisionByZero.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object BVDivisionByZero { - - def divByZero(x: Int): Boolean = { - (x / 0 == 10) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/BVRemainderByZero.scala b/src/test/resources/regression/verification/purescala/invalid/BVRemainderByZero.scala deleted file mode 100644 index 2bec1b715434c9cbedf7328406e873a738a4299b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/BVRemainderByZero.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object BVRemainderByZero { - - def remByZero(x: Int): Boolean = { - (x % 0 == 10) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/BigArray.scala b/src/test/resources/regression/verification/purescala/invalid/BigArray.scala deleted file mode 100644 index a4a4a6a05c0836b19ec55ad4538bd264c2742799..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/BigArray.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object BigArray { - - def big(a: Array[Int]): Int = { - require(a.length >= 10 && a(7) == 42) - a.length - } ensuring(_ <= 1000000000) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/BinarySearchTreeQuant.scala b/src/test/resources/regression/verification/purescala/invalid/BinarySearchTreeQuant.scala deleted file mode 100644 index 260d33ad2e7d6757e0b0af784e9631138f95cb61..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/BinarySearchTreeQuant.scala +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ - -object BSTSimpler { - sealed abstract class Tree - case class Node(left: Tree, value: BigInt, right: Tree) extends Tree - case class Leaf() extends Tree - - def content(tree: Tree): Set[BigInt] = tree match { - case Leaf() => Set.empty[BigInt] - case Node(l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def isBST(tree: Tree) : Boolean = tree match { - case Leaf() => true - case Node(left, v, right) => { - isBST(left) && isBST(right) && - forall((x:BigInt) => (content(left).contains(x) ==> x < v - 10)) && - forall((x:BigInt) => (content(right).contains(x) ==> v < x)) - } - } - - def emptySet(): Tree = Leaf() - - def insert(tree: Tree, value: BigInt): Node = { - require(isBST(tree)) - tree match { - case Leaf() => Node(Leaf(), value, Leaf()) - case Node(l, v, r) => (if (v < value) { - Node(l, v, insert(r, value)) - } else if (v > value) { - Node(insert(l, value), v, r) - } else { - Node(l, v, r) - }) - } - } ensuring(res => isBST(res) && content(res) == content(tree) ++ Set(value)) - - def createRoot(v: BigInt): Node = { - Node(Leaf(), v, Leaf()) - } ensuring (content(_) == Set(v)) -} diff --git a/src/test/resources/regression/verification/purescala/invalid/BraunTree.scala b/src/test/resources/regression/verification/purescala/invalid/BraunTree.scala deleted file mode 100644 index ff2144d1c3b07b3d295239703136b6d017abd6ef..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/BraunTree.scala +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object BraunTree { - abstract class Tree - case class Node(value: Int, left: Tree, right: Tree) extends Tree - case class Leaf() extends Tree - - def insert(tree: Tree, x: Int): Tree = { - require(isBraun(tree)) - tree match { - case Node(value, left, right) => - Node(value, insert(left, x), right) - case Leaf() => Node(x, Leaf(), Leaf()) - } - } ensuring { res => isBraun(res) } - - def height(tree: Tree): Int = { - tree match { - case Node(value, left, right) => - val l = height(left) - val r = height(right) - val max = if (l > r) l else r - 1 + max - case Leaf() => 0 - } - } - - def isBraun(tree: Tree): Boolean = { - tree match { - case Node(value, left, right) => - isBraun(left) && isBraun(right) && { - val l = height(left) - val r = height(right) - l == r || l == r + 1 - } - case Leaf() => true - } - } -} diff --git a/src/test/resources/regression/verification/purescala/invalid/CallByName1.scala b/src/test/resources/regression/verification/purescala/invalid/CallByName1.scala deleted file mode 100644 index 7aef4f08bdc980fb4f5a5db35f383309ebc4aa7b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/CallByName1.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object CallByName1 { - def byName1(i: Int, a: => Int): Int = { - if (i > 0) a + 1 - else 0 - } - - def byName2(i: Int, a: => Int): Int = { - if (i > 0) byName1(i - 1, a) + 2 - else 0 - } - - def test(): Boolean = { - byName1(1, byName2(3, 0)) == 0 && byName1(1, byName2(3, 0)) == 1 - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/invalid/CharCompare.scala b/src/test/resources/regression/verification/purescala/invalid/CharCompare.scala deleted file mode 100644 index f92657c784cc2ea96d2300d0d154aac151c5eac7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/CharCompare.scala +++ /dev/null @@ -1,7 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object CharCompare { - def cmp(c1: Char, c2: Char): Boolean = { c1 < c2 }.holds -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Choose1.scala b/src/test/resources/regression/verification/purescala/invalid/Choose1.scala deleted file mode 100644 index ac9922ed779b88cc0b83ce2ef7f07465432263be..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Choose1.scala +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang.synthesis._ -import leon.lang._ - -object Choose1 { - sealed abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - def size(l: List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List) : Set[Int] = l match { - case Nil() => Set.empty[Int] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def listOfSize(i: BigInt): List = { - require(i >= 0) - - if (i == BigInt(0)) { - Nil() - } else { - choose { (res: List) => size(res) == i-1 } - } - } ensuring ( size(_) == i ) - - - def listOfSize2(i: BigInt): List = { - require(i >= 0) - - if (i > 0) { - Cons(0, listOfSize(i-1)) - } else { - Nil() - } - } ensuring ( size(_) == i ) -} diff --git a/src/test/resources/regression/verification/purescala/invalid/DivisionByZero.scala b/src/test/resources/regression/verification/purescala/invalid/DivisionByZero.scala deleted file mode 100644 index 95f435727d4691dd1c72b0ba2004385372dad297..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/DivisionByZero.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object DivisionByZero { - - def divByZero(x: BigInt): Boolean = { - (x / BigInt(0) == BigInt(10)) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/EnsuringBoolean.scala b/src/test/resources/regression/verification/purescala/invalid/EnsuringBoolean.scala deleted file mode 100644 index 32b47ae9c2d1f4adbc58d63a410e9177816bf848..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/EnsuringBoolean.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.lang._ -import leon.annotation._ -import scala.language.postfixOps -object EnsuringBoolean { - def congR(x: BigInt)(implicit mod: BigInt): Unit = { - require(mod >= 1); - () - } ensuring(false) -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Existentials.scala b/src/test/resources/regression/verification/purescala/invalid/Existentials.scala deleted file mode 100644 index 4f3d358c772d273a306e55868fc8f960298b5381..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Existentials.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Existentials { - - def exists[A](p: A => Boolean): Boolean = !forall((x: A) => !p(x)) - - def check1(y: BigInt, p: BigInt => Boolean) : Boolean = { - p(y) == exists((y1:BigInt) => p(y1)) - }.holds - - /* - def check2(y: BigInt, p: BigInt => Boolean) : Boolean = { - p(y) ==> exists((y1:BigInt) => p(y1)) - }.holds - */ -} diff --git a/src/test/resources/regression/verification/purescala/invalid/FieldInheritance.scala b/src/test/resources/regression/verification/purescala/invalid/FieldInheritance.scala deleted file mode 100644 index e183b615ad6fa3dea6d3eef63fe079198b9110d9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/FieldInheritance.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object FieldInheritance { - - abstract class Foo[B] { - val thisIsIt: BigInt = 1 - val y: BigInt - val weird: B - } - - case class Bar[X](override val thisIsIt: BigInt, weird: X) extends Foo[X] { - val y = thisIsIt - } - - case class Baz[X](weird: X) extends Foo[X] { - val y = thisIsIt + 1 - } - - - def foo[A](f: Foo[A]) = (f.thisIsIt == 1).holds - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/FiniteSort.scala b/src/test/resources/regression/verification/purescala/invalid/FiniteSort.scala deleted file mode 100644 index 17af7c45eab3dc211d85ecefd480e61a9387a775..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/FiniteSort.scala +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object FiniteSort { - - // These finite sorting functions essentially implement insertion sort. - def sort2(x : Int, y : Int) : (Int,Int) = { - if(x < y) (x, y) else (y, x) - } - - def sort3(x1 : Int, x2 : Int, x3 : Int) : (Int, Int, Int) = { - val (x1s, x2s) = sort2(x1, x2) - - if(x2s <= x3) { - (x1s, x2s, x3) - } else if(x1s <= x3) { - (x1s, x3, x2s) - } else { - (x3, x1s, x2s) - } - } - - def sort4(x1 : Int, x2 : Int, x3 : Int, x4 : Int) : (Int, Int, Int, Int) = { - val (x1s, x2s, x3s) = sort3(x1, x2, x3) - - if(x3s <= x4) { - (x1s, x2s, x3s, x4) - } else if(x2s <= x4) { - (x1s, x2s, x4, x3s) - } else if(x1s <= x4) { - (x1s, x4, x2s, x3s) - } else { - (x4, x1s, x2s, x3s) - } - } - - def sort5WrongSpec(x1 : Int, x2 : Int, x3 : Int, x4 : Int, x5 : Int) : (Int, Int, Int, Int, Int) = { - val (x1s, x2s, x3s, x4s) = sort4(x1, x2, x3, x4) - - if(x4s <= x5) { - (x1s, x2s, x3s, x4s, x5) - } else if(x3s <= x5) { - (x1s, x2s, x3s, x5, x4s) - } else if(x2s <= x5) { - (x1s, x2s, x5, x3s, x4s) - } else if(x1s <= x5) { - (x1s, x5, x2s, x3s, x4s) - } else { - (x5, x1s, x2s, x3s, x4s) - } - - } ensuring (_ match { - case (a, b, c, d, e) => a <= b && b <= c && c <= d && d <= e && Set(a,b,c,d,e) == Set(x1,x2,x3,x4,x4) // last one should be x5 - }) -} diff --git a/src/test/resources/regression/verification/purescala/invalid/ForallAssoc.scala b/src/test/resources/regression/verification/purescala/invalid/ForallAssoc.scala deleted file mode 100644 index dcd837a69dd6d2d78439def449d21815f3bffba5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/ForallAssoc.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ForallAssoc { - - /* - def test3(f: (BigInt, BigInt) => BigInt): Boolean = { - require(forall((x: BigInt, y: BigInt, z: BigInt) => f(x, f(y, z)) == f(f(x, y), z))) - f(1, f(2, f(3, f(4, 5)))) == f(f(f(f(1, 2), 3), 4), 4) - }.holds - */ - - def test4(f: (BigInt, BigInt) => BigInt): Boolean = { - require(forall((x: BigInt, y: BigInt, z: BigInt) => f(x, f(y, z)) == f(f(x, y), z))) - f(1, f(2, f(3, 4))) == 0 - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Generics.scala b/src/test/resources/regression/verification/purescala/invalid/Generics.scala deleted file mode 100644 index 991b948d948b909badfabd9935d58e865b03995f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Generics.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Generics { - abstract class List[T] - case class Cons[A](head: A, tail: List[A]) extends List[A] - case class Nil[B]() extends List[B] - - def size[T](l: List[T]): BigInt = (l match { - case Nil() => BigInt(0) - case Cons(h, t) => 1+size(t) - })ensuring { _ > 0 } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Generics2.scala b/src/test/resources/regression/verification/purescala/invalid/Generics2.scala deleted file mode 100644 index 0c95c311e09c0c67c16bf510090723afb41b5768..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Generics2.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Generics2 { - abstract class List[T] - case class Cons[A](head: A, tail: List[A]) extends List[A] - case class Nil[B]() extends List[B] - - def size[T](l: List[T]): BigInt = (l match { - case Nil() => BigInt(0) - case Cons(h, t) => 1+size(t) - })ensuring { _ >= 0 } - - def foo[T](l: List[T]): List[T] = { - require(size(l) < 2) - - l - } - - def bar(l: List[Int]) = { - foo(l) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/HOInvocations.scala b/src/test/resources/regression/verification/purescala/invalid/HOInvocations.scala deleted file mode 100644 index c44cd759d15f36d17b346c700927e9c1a7885929..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/HOInvocations.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object HOInvocations { - def switch(x: Int, f: (Int) => Int, g: (Int) => Int) = if(x > 0) f else g - - def failling_1(f: (Int) => Int) = { - switch(-10, (x: Int) => x + 1, f)(2) - } ensuring { res => res > 0 } - - def failling_2(x: Int, f: (Int) => Int, g: (Int) => Int) = { - require(x > 0) - switch(1, switch(x, f, g), g)(1) - } ensuring { res => res != f(1) } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/invalid/HOInvocations2.scala b/src/test/resources/regression/verification/purescala/invalid/HOInvocations2.scala deleted file mode 100644 index ba7c88c9cde4edd5c2bdc48c1da47f66a5e1f06c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/HOInvocations2.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object HOInvocations2 { - def switch(x: BigInt, f: (BigInt) => BigInt, g: (BigInt) => BigInt) = if(x > 0) f else g - - def failling_1(f: (BigInt) => BigInt) = { - switch(-10, (x: BigInt) => x + 1, f)(2) - } ensuring { res => res > 0 } - - def failling_2(x: BigInt, f: (BigInt) => BigInt, g: (BigInt) => BigInt) = { - require(x > 0 && forall((a: BigInt) => a > 0 ==> f(a) > 0)) - switch(1, switch(x, f, g), g)(0) - } ensuring { res => res > 0 } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/invalid/InsertionSort.scala b/src/test/resources/regression/verification/purescala/invalid/InsertionSort.scala deleted file mode 100644 index ddf73528201ad5a07cbe61bc1afe440bcfc58f8d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/InsertionSort.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object InsertionSort { - sealed abstract class List - case class Cons(head:Int,tail:List) extends List - case class Nil() extends List - - sealed abstract class OptInt - case class Some(value: Int) extends OptInt - case class None() extends OptInt - - def size(l : List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def contents(l: List): Set[Int] = l match { - case Nil() => Set.empty - case Cons(x,xs) => contents(xs) ++ Set(x) - } - - def isSorted(l: List): Boolean = l match { - case Nil() => true - case Cons(x, Nil()) => true - case Cons(x, Cons(y, ys)) => x <= y && isSorted(Cons(y, ys)) - } - - /* Inserting element 'e' into a sorted list 'l' produces a sorted list with - * the expected content and size */ - def buggySortedIns(e: Int, l: List): List = { - // require(isSorted(l)) - l match { - case Nil() => Cons(e,Nil()) - case Cons(x,xs) => if (x <= e) Cons(x,buggySortedIns(e, xs)) else Cons(e, l) - } - } ensuring(res => contents(res) == contents(l) ++ Set(e) - && isSorted(res) - && size(res) == size(l) + 1 - ) -} diff --git a/src/test/resources/regression/verification/purescala/invalid/ListOperations.scala b/src/test/resources/regression/verification/purescala/invalid/ListOperations.scala deleted file mode 100644 index 82f4648a2d568d4b50d19c7a2a953cced7775cef..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/ListOperations.scala +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object ListOperations { - sealed abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - sealed abstract class IntPairList - case class IPCons(head: IntPair, tail: IntPairList) extends IntPairList - case class IPNil() extends IntPairList - - sealed abstract class IntPair - case class IP(fst: Int, snd: Int) extends IntPair - - def size(l: List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def iplSize(l: IntPairList) : BigInt = (l match { - case IPNil() => BigInt(0) - case IPCons(_, xs) => 1 + iplSize(xs) - }) ensuring(_ >= 0) - - def zip(l1: List, l2: List) : IntPairList = { - // try to comment this and see how pattern-matching becomes - // non-exhaustive and post-condition fails - require(size(l1) == size(l2)) - - l1 match { - case Nil() => IPNil() - case Cons(x, xs) => l2 match { - case Cons(y, ys) => IPCons(IP(x, y), zip(xs, ys)) - } - } - } ensuring(iplSize(_) == size(l1)) - - def sizeTailRec(l: List) : BigInt = sizeTailRecAcc(l, 0) - def sizeTailRecAcc(l: List, acc: BigInt) : BigInt = { - require(acc >= 0) - l match { - case Nil() => acc - case Cons(_, xs) => sizeTailRecAcc(xs, acc+1) - } - } ensuring(res => res == size(l) + acc) - - def sizesAreEquiv(l: List) : Boolean = { - size(l) == sizeTailRec(l) - }.holds - - def content(l: List) : Set[Int] = l match { - case Nil() => Set.empty[Int] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def sizeAndContent(l: List) : Boolean = { - size(l) == BigInt(0) || content(l) != Set.empty[Int] - }.holds - - def drunk(l : List) : List = (l match { - case Nil() => Nil() - case Cons(x,l1) => Cons(x,Cons(x,drunk(l1))) - }) ensuring (size(_) == 2 * size(l)) - - def reverse(l: List) : List = reverse0(l, Nil()) ensuring(content(_) == content(l)) - def reverse0(l1: List, l2: List) : List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => reverse0(xs, Cons(x, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - def append(l1 : List, l2 : List) : List = (l1 match { - case Nil() => l2 - case Cons(x,xs) => Cons(x, append(xs, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def nilAppend(l : List) : Boolean = (append(l, Nil()) == l).holds - - @induct - def appendAssoc(xs : List, ys : List, zs : List) : Boolean = - (append(append(xs, ys), zs) == append(xs, append(ys, zs))).holds - - def revAuxBroken(l1 : List, e : Int, l2 : List) : Boolean = { - (append(reverse(l1), Cons(e,l2)) == reverse0(l1, l2)) - }.holds - - @induct - def sizeAppend(l1 : List, l2 : List) : Boolean = - (size(append(l1, l2)) == size(l1) + size(l2)).holds - - @induct - def concat(l1: List, l2: List) : List = - concat0(l1, l2, Nil()) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def concat0(l1: List, l2: List, l3: List) : List = (l1 match { - case Nil() => l2 match { - case Nil() => reverse(l3) - case Cons(y, ys) => { - concat0(Nil(), ys, Cons(y, l3)) - } - } - case Cons(x, xs) => concat0(xs, l2, Cons(x, l3)) - }) ensuring(content(_) == content(l1) ++ content(l2) ++ content(l3)) -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Lists.scala b/src/test/resources/regression/verification/purescala/invalid/Lists.scala deleted file mode 100644 index c9594195d8a7e189007ca14852837334a5a7f07b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Lists.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Lists { - abstract class List[T] - case class Cons[T](head: T, tail: List[T]) extends List[T] - case class Nil[T]() extends List[T] - - def forall[T](list: List[T], f: T => Boolean): Boolean = list match { - case Cons(head, tail) => f(head) && forall(tail, f) - case Nil() => true - } - - def positive(list: List[Int]): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def gt(i: Int): Int => Boolean = x => x > i - - def positive_lemma(list: List[Int]): Boolean = { - positive(list) == forall(list, gt(0)) - } - - def failling_1(list: List[Int]): Boolean = { - list match { - case Nil() => positive_lemma(list) - case Cons(head, tail) => positive_lemma(list) && failling_1(tail) - } - }.holds -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/invalid/MatchExh.scala b/src/test/resources/regression/verification/purescala/invalid/MatchExh.scala deleted file mode 100644 index e5260ae1f147c71b2b8156c80b979be63220442d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/MatchExh.scala +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ - -object MatchExh { - - def exh1(i: Int) = i match { - case 1 => 2 - case 0 => 2 - case _ => 2 - } - - def exh2[A](l: List[A]) = l match { - case Nil() => 0 - case Cons(a, Nil()) => 1 - case Cons(a, _) => 2 - } - - def err1(i: Int) = i match { - case 1 => 2 - case 0 => 42 - } - - def err2[A](l: List[A]) = l match { - case Nil() => 0 - case Cons(a, Nil()) => 1 - case Cons(a, Cons(b, _)) if a == b => 2 - } - - def err3(l: List[BigInt]) = l match { - case Nil() => 0 - case Cons(BigInt(0), Nil()) => 0 - case Cons(_, Cons(_, _)) => 1 - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Mean.scala b/src/test/resources/regression/verification/purescala/invalid/Mean.scala deleted file mode 100644 index aa691fa159b313c9f5edc3196b69c1c731aa4c04..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Mean.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Mean { - - def meanOverflow(x: Int, y: Int): Int = { - require(x <= y && x >= 0 && y >= 0) - (x + y)/2 - } ensuring(m => m >= x && m <= y) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/ModuloByZero.scala b/src/test/resources/regression/verification/purescala/invalid/ModuloByZero.scala deleted file mode 100644 index 114eb998bca464d637100307fa078da5fd1ce0b5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/ModuloByZero.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object ModuloByZero { - - def modByZero(x: BigInt): Boolean = { - (x mod BigInt(0)) == BigInt(10) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Monotonic.scala b/src/test/resources/regression/verification/purescala/invalid/Monotonic.scala deleted file mode 100644 index ddb17ff3e015e196fa046a86aa189e37629ac467..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Monotonic.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Monotonic { - def failling_1(f: BigInt => BigInt, g: BigInt => BigInt): BigInt => BigInt = { - require(forall((a: BigInt, b: BigInt) => (a > b ==> f(a) > f(b)))) - (x: BigInt) => f(g(x)) - } ensuring { res => forall((a: BigInt, b: BigInt) => a > b ==> res(a) > res(b)) } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/invalid/MyTuple1.scala b/src/test/resources/regression/verification/purescala/invalid/MyTuple1.scala deleted file mode 100644 index 394e2cd9fb8815514c7788481af2c0376af8e560..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/MyTuple1.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple1 { - - def foo(): Int = { - val t = (1, true, 3) - val a1 = t._1 - val a2 = t._2 - val a3 = t._3 - a3 - } ensuring( _ == 1) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/MyTuple2.scala b/src/test/resources/regression/verification/purescala/invalid/MyTuple2.scala deleted file mode 100644 index 76b8e64cf243789f9eece4cf8dfc7131efb6ca82..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/MyTuple2.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple2 { - - abstract class A - case class B(i: Int) extends A - case class C(a: A) extends A - - def foo(): Int = { - val t = (B(2), C(B(3))) - t match { - case (B(x), C(y)) => x - } - } ensuring( _ == 3) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/MyTuple3.scala b/src/test/resources/regression/verification/purescala/invalid/MyTuple3.scala deleted file mode 100644 index abc0ffba3e654b80b3ac27450be7421496b9d53c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/MyTuple3.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple3 { - - def foo(t: (Int, Int)): (Int, Int) = { - t - } ensuring(res => res._1 > 0 && res._2 > 1) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Nested15.scala b/src/test/resources/regression/verification/purescala/invalid/Nested15.scala deleted file mode 100644 index d604082f6787cc0483fd210943b41d941acfde8f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Nested15.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.collection._ - -object Nested15 { - - def foo[A](i: List[A]): BigInt = { - val n = i - def rec1[B](j: List[B]) = j ++ j - def rec2[C](l: List[C], j: BigInt) = { - require(l.nonEmpty) - def rec3(k: C) = k :: rec1[C](l) - rec3(l.head).size + j + n.size + i.size - } - rec2(List(1,2,3), 2) - } ensuring(_ == i.size + 9) // Should be 2* size - -} - diff --git a/src/test/resources/regression/verification/purescala/invalid/Overrides.scala b/src/test/resources/regression/verification/purescala/invalid/Overrides.scala deleted file mode 100644 index 28c6e9dbc96407b6f63fd49baefc36ac74473c55..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Overrides.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Overrides { - abstract class A { - def x(a: Int): Int - } - - abstract class B extends A { - def x(a: Int) = { - require(a > 0) - 42 - } ensuring { _ >= 0 } - } - - case class C(c: Int) extends B { - override def x(i: Int) = { - require(i >= 0) - if (i == 0) 0 - else c + x(i-1) - } ensuring ( _ != c * i ) - } - - case class D() extends B -} diff --git a/src/test/resources/regression/verification/purescala/invalid/PositiveMap.scala b/src/test/resources/regression/verification/purescala/invalid/PositiveMap.scala deleted file mode 100644 index eaf345dd92979d9a754d2157611b2bf8f58266db..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/PositiveMap.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object PositiveMap { - - abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - def positive(list: List): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def positiveMap_failling_1(f: (Int) => Int, list: List): List = { - list match { - case Cons(head, tail) => - val fh = f(head) - val nh = if (fh < -1) 0 else fh - Cons(nh, positiveMap_failling_1(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/invalid/PositiveMap2.scala b/src/test/resources/regression/verification/purescala/invalid/PositiveMap2.scala deleted file mode 100644 index c7cc782c632d463943dfaaa2e5c454cd2c759307..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/PositiveMap2.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object PositiveMap2 { - - abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def positive(list: List): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def positiveMap_failling_1(f: (BigInt) => BigInt, list: List): List = { - require(forall((a: BigInt) => f(a) > -2)) - list match { - case Cons(head, tail) => Cons(f(head), positiveMap_failling_1(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/invalid/Postcondition.scala b/src/test/resources/regression/verification/purescala/invalid/Postcondition.scala deleted file mode 100644 index be95028c0d80ed848c07bab072fba381a421e546..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Postcondition.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Postconditions { - def failling_1(f: BigInt => BigInt) = { - require(forall((a: BigInt) => a > 0 ==> f(a) > 0)) - f(10) - } ensuring { res => forall((a: BigInt) => res > f(a)) } - - def failling_2(f: BigInt => BigInt, x: BigInt) = { - require(x >= 0 && forall((a: BigInt) => a > 0 ==> f(a) < 0)) - x - } ensuring { res => forall((a: BigInt) => res > f(a)) } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/PreInSpecs.scala b/src/test/resources/regression/verification/purescala/invalid/PreInSpecs.scala deleted file mode 100644 index 03c795e336b25572e90703782dc8c7eb7088a7d5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/PreInSpecs.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object PreInSpecs { - - def f(i : BigInt): Boolean = { - require(i >= 0) - i > 0 - } - - def g(i : BigInt): Boolean = { - require(i >= 0) - i >= -1 - } holds - - def invoke(i : BigInt): BigInt = { - require(i == 0 || i > 0 && f(i - 1)) - i + 1 - } ensuring(res => g(i - 1)) - - def invoke2(i: BigInt): BigInt = { - require(g(i)) - 0 - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/PropositionalLogic.scala b/src/test/resources/regression/verification/purescala/invalid/PropositionalLogic.scala deleted file mode 100644 index 31790c96033bc72570a9cdc64393c8035b3cc25e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/PropositionalLogic.scala +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object PropositionalLogic { - - sealed abstract class Formula - case class And(lhs: Formula, rhs: Formula) extends Formula - case class Or(lhs: Formula, rhs: Formula) extends Formula - case class Implies(lhs: Formula, rhs: Formula) extends Formula - case class Not(f: Formula) extends Formula - case class Literal(id: BigInt) extends Formula - - def simplify(f: Formula): Formula = (f match { - case Implies(lhs, rhs) => Or(Not(simplify(lhs)), simplify(rhs)) - case _ => f - }) ensuring(isSimplified(_)) - - def isSimplified(f: Formula): Boolean = f match { - case And(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Or(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Implies(_,_) => false - case Not(f) => isSimplified(f) - case Literal(_) => true - } - - def isNNF(f: Formula): Boolean = f match { - case And(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Or(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Implies(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Not(Literal(_)) => true - case Not(_) => false - case Literal(_) => true - } - - - // @induct - // def wrongCommutative(f: Formula) : Boolean = { - // nnf(simplify(f)) == simplify(nnf(f)) - // }.holds - - def simplifyBreaksNNF(f: Formula) : Boolean = { - require(isNNF(f)) - isNNF(simplify(f)) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/invalid/README b/src/test/resources/regression/verification/purescala/invalid/README deleted file mode 100644 index 3b276ff545f799f5335938c7ca4788ef72234e3d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/README +++ /dev/null @@ -1,2 +0,0 @@ -This particular directory contains PureScala programs that have *at least* one -failing verification condition. diff --git a/src/test/resources/regression/verification/purescala/invalid/RealDivisionByZero.scala b/src/test/resources/regression/verification/purescala/invalid/RealDivisionByZero.scala deleted file mode 100644 index efa3c4e0e0628bd2d46a330f174e28fdab92a65f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/RealDivisionByZero.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object RealDivisionByZero { - - def divByZero(x: Real): Boolean = { - (x / Real(0) == Real(10)) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/RealNonDiscrete.scala b/src/test/resources/regression/verification/purescala/invalid/RealNonDiscrete.scala deleted file mode 100644 index 65e7a655b4c3043a9add4710e8481843ceead172..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/RealNonDiscrete.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object RealNonDiscrete { - - def nonDiscrete(x: Real): Boolean = { - require(x > Real(1) && x < Real(3)) - x == Real(2) - } holds - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/RedBlackTree.scala b/src/test/resources/regression/verification/purescala/invalid/RedBlackTree.scala deleted file mode 100644 index 05004448d00a5a376cd81c8d4da084049b09ddb3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/RedBlackTree.scala +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object RedBlackTree { - sealed abstract class Color - case class Red() extends Color - case class Black() extends Color - - sealed abstract class Tree - case class Empty() extends Tree - case class Node(color: Color, left: Tree, value: Int, right: Tree) extends Tree - - sealed abstract class OptionInt - case class Some(v : Int) extends OptionInt - case class None() extends OptionInt - - def content(t: Tree) : Set[Int] = t match { - case Empty() => Set.empty - case Node(_, l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def size(t: Tree) : BigInt = (t match { - case Empty() => BigInt(0) - case Node(_, l, v, r) => size(l) + 1 + size(r) - }) ensuring(_ >= 0) - - def isBlack(t: Tree) : Boolean = t match { - case Empty() => true - case Node(Black(),_,_,_) => true - case _ => false - } - - def redNodesHaveBlackChildren(t: Tree) : Boolean = t match { - case Empty() => true - case Node(Black(), l, _, r) => redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - case Node(Red(), l, _, r) => isBlack(l) && isBlack(r) && redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - } - - def redDescHaveBlackChildren(t: Tree) : Boolean = t match { - case Empty() => true - case Node(_,l,_,r) => redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - } - - def blackBalanced(t : Tree) : Boolean = t match { - case Node(_,l,_,r) => blackBalanced(l) && blackBalanced(r) && blackHeight(l) == blackHeight(r) - case Empty() => true - } - - def blackHeight(t : Tree) : Int = t match { - case Empty() => 1 - case Node(Black(), l, _, _) => blackHeight(l) + 1 - case Node(Red(), l, _, _) => blackHeight(l) - } - - def ins(x: Int, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t) && blackBalanced(t)) - t match { - case Empty() => Node(Red(),Empty(),x,Empty()) - case Node(c,a,y,b) => - if (x < y) balance(c, ins(x, a), y, b) - else if (x == y) Node(c,a,y,b) - else balance(c,a,y,ins(x, b)) - } - } ensuring (res => content(res) == content(t) ++ Set(x) - && size(t) <= size(res) && size(res) <= size(t) + 1 - && redDescHaveBlackChildren(res) - && blackBalanced(res)) - - def balance(c: Color, a: Tree, x: Int, b: Tree): Tree = { - Node(c,a,x,b) match { - case Node(Black(),Node(Red(),Node(Red(),a,xV,b),yV,c),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),Node(Red(),a,xV,Node(Red(),b,yV,c)),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),Node(Red(),b,yV,c),zV,d)) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),b,yV,Node(Red(),c,zV,d))) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(c,a,xV,b) => Node(c,a,xV,b) - } - } ensuring (res => content(res) == content(Node(c,a,x,b)))// && redDescHaveBlackChildren(res)) - - def buggyAdd(x: Int, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t)) - ins(x, t) - } ensuring (res => content(res) == content(t) ++ Set(x) && redNodesHaveBlackChildren(res)) - - def buggyBalance(c: Color, a: Tree, x: Int, b: Tree): Tree = { - Node(c,a,x,b) match { - case Node(Black(),Node(Red(),Node(Red(),a,xV,b),yV,c),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),Node(Red(),a,xV,Node(Red(),b,yV,c)),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),Node(Red(),b,yV,c),zV,d)) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),b,yV,Node(Red(),c,zV,d))) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - // case Node(c,a,xV,b) => Node(c,a,xV,b) - } - } ensuring (res => content(res) == content(Node(c,a,x,b))) -} diff --git a/src/test/resources/regression/verification/purescala/invalid/RemainderByZero.scala b/src/test/resources/regression/verification/purescala/invalid/RemainderByZero.scala deleted file mode 100644 index c3b9e96f029376e18a2b4a6fb91f931c5245d64c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/RemainderByZero.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object RemainderByZero { - - def remByZero(x: BigInt): Boolean = { - (x % BigInt(0) == BigInt(10)) - } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/SimpleQuantification.scala b/src/test/resources/regression/verification/purescala/invalid/SimpleQuantification.scala deleted file mode 100644 index b020f413c779d2239ec723d41985f8ab7900bd86..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/SimpleQuantification.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Simple { - - def failling_1(f: BigInt => BigInt) = { - require(forall((a: BigInt) => a > 0 ==> f(a) > 0)) - f(-1) - } ensuring { res => res > 0 } - - def failling_2(f: BigInt => BigInt) = { - require(forall((a: BigInt) => a > 0 ==> f(a) > 1)) - f(1) + f(2) - } ensuring { res => res > 4 } - - def failling_4(f: BigInt => BigInt, g: BigInt => BigInt, x: BigInt) = { - require(forall((a: BigInt, b: BigInt) => f(a) + g(a) > 0)) - if(x < 0) f(x) + g(x) - else x - } ensuring { res => res > 0 } -} diff --git a/src/test/resources/regression/verification/purescala/invalid/SpecWithExtern.scala b/src/test/resources/regression/verification/purescala/invalid/SpecWithExtern.scala deleted file mode 100644 index d164fee8f28c2b39f718d0e69608336c19dac360..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/SpecWithExtern.scala +++ /dev/null @@ -1,22 +0,0 @@ -import leon.annotation._ - -object SpecWithExtern { - - - //random between returns any value between l and h. - //For execution via scalac, we pick one valid implementation, but - //we would like the program to be verified versus any possible - //implementation, which should happen thanks to @extern - @extern - def randomBetween(l: Int, h: Int): Int = { - require(l <= h) - l - } ensuring(res => (res >= l && res <= h)) - - //postcondition is wrong, but if leon considers - //actual body of randomBetween it would be correct - def wrongProp(): Int = { - randomBetween(0, 10) - } ensuring(res => res >= 0 && res < 10) - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/TestLazinessOfAnd.scala b/src/test/resources/regression/verification/purescala/invalid/TestLazinessOfAnd.scala deleted file mode 100644 index 66ccb8f2eda1de78a0783795541e0525b43c9e58..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/TestLazinessOfAnd.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object AndTest { - - def nonterm(x: BigInt) : BigInt = { - nonterm(x + 1) - } ensuring(res => false) - - def precond(y : BigInt) = y < 0 - - /** - * Leon should find a counter-example here. - **/ - def foo(y: BigInt) : Boolean = { - require(precond(y)) - y >= 0 && (nonterm(0) == 0) - } holds -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Unapply1.scala b/src/test/resources/regression/verification/purescala/invalid/Unapply1.scala deleted file mode 100644 index cd78d47989f1007fffccdeccb0e94d8ef6764ce9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Unapply1.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Unap1 { - def unapply[A, B](i: (Int, B, A)): Option[(A, B)] = - if (i._1 == 0) None() else Some((i._3, i._2)) -} - -object Unapply1 { - - sealed abstract class Bool - case class True() extends Bool - case class False() extends Bool - - def bar: Bool = { (42, False().asInstanceOf[Bool], ()) match { - case Unap1(_, b) if b == True() => b - case Unap1((), b) => b - }} ensuring { res => res == True() } - -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Unapply2.scala b/src/test/resources/regression/verification/purescala/invalid/Unapply2.scala deleted file mode 100644 index 152f1445b97aaad91d008a62937b34d88ca658ea..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Unapply2.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -object Unap2 { - def unapply[A, B](i: (Int, B, A)): Option[(A, B)] = - if (i._1 == 0) None() else Some((i._3, i._2)) -} - -object Unapply { - - sealed abstract class Bool - case class True() extends Bool - case class False() extends Bool - - def bar: Bool = { (42, False().asInstanceOf[Bool], ()) match { - case Unap2(_, b) if b == True() => b - }} ensuring { res => res == True() } -} diff --git a/src/test/resources/regression/verification/purescala/invalid/Unit1.scala b/src/test/resources/regression/verification/purescala/invalid/Unit1.scala deleted file mode 100644 index f937daaa922bc3039ca565d978905db3c23531fd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/invalid/Unit1.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Unit1 { - - def foo(u: Unit): Unit = ({ - u - }) ensuring(res => false) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTInvariants1.scala b/src/test/resources/regression/verification/purescala/valid/ADTInvariants1.scala deleted file mode 100644 index 7e4eb0028ba551146308a3cdf997d2bb59e2c7d8..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTInvariants1.scala +++ /dev/null @@ -1,11 +0,0 @@ - -object ADTInvariants1 { - - case class Positive(i: BigInt) { - require(i > 0) - } - - def theorem(f: Positive => Positive) = { - f(Positive(1)) - } ensuring(res => res.i > 0) -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTInvariants2.scala b/src/test/resources/regression/verification/purescala/valid/ADTInvariants2.scala deleted file mode 100644 index e024d5f2f537547b099b6496237036dd3b69bc0a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTInvariants2.scala +++ /dev/null @@ -1,21 +0,0 @@ -import leon.lang._ - -object ADTInvariants2 { - case class Pos(i: BigInt) { - require(i > 0) - } - - def test(p: Pos): Boolean = { - Pos(p.i + 1).i > 0 - }.holds - - sealed abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - case class C(l: Cons) - - def test3(c: C): Boolean = { - c.l.isInstanceOf[Cons] - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTInvariants3.scala b/src/test/resources/regression/verification/purescala/valid/ADTInvariants3.scala deleted file mode 100644 index 317f0230c506f03e7b4668d7fba2bab2caa89d5e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTInvariants3.scala +++ /dev/null @@ -1,27 +0,0 @@ -import leon.lang._ - -object ADTInvariants3 { - - sealed abstract class A - sealed abstract class B extends A { - require(this match { - case Cons(h, t) => h == size - case Nil(_) => true - }) - - def size: BigInt = (this match { - case Cons(h, t) => 1 + t.size - case Nil(_) => BigInt(0) - }) ensuring ((i: BigInt) => i >= 0) - } - - case class Cons(head: BigInt, tail: B) extends B - case class Nil(i: BigInt) extends B { - require(i >= 0) - } - - def sum(a: A): BigInt = (a match { - case Cons(head, tail) => head + sum(tail) - case Nil(i) => i - }) ensuring ((i: BigInt) => i >= 0) -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTWithArray1.scala b/src/test/resources/regression/verification/purescala/valid/ADTWithArray1.scala deleted file mode 100644 index 62eeb2b109247287a039dc064299cc3f3c3c2f60..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTWithArray1.scala +++ /dev/null @@ -1,14 +0,0 @@ -import leon.collection._ - -object ADTWithArray1 { - - case class A1(x: Int) - - case class B(t: Array[A1]) - - def test(b: B): A1 = { - require(b.t.length > 0 && b.t(0).x > 0) - b.t(0) - } ensuring(a => a.x >= 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTWithArray2.scala b/src/test/resources/regression/verification/purescala/valid/ADTWithArray2.scala deleted file mode 100644 index 89a89a3f9a0bfa8458e465f429415708c94b9bf1..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTWithArray2.scala +++ /dev/null @@ -1,14 +0,0 @@ -import leon.collection._ - -object ADTWithArray2 { - - case class A1(x: Int) - - case class B(t: Array[A1]) - - def test(b: B): Int = { - require(b.t.length > 2) - b.t.length - } ensuring(a => a > 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTWithArray3.scala b/src/test/resources/regression/verification/purescala/valid/ADTWithArray3.scala deleted file mode 100644 index d5c7c3f8a7924850a2f50de643212405ee78ef03..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTWithArray3.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -/* - * Not sure what is wrong there, but the ArrayEncoding used to - * crash on this specific combination of nested function with - * transitive requirements to length of buffer in Kernel. - */ -object ADTWithArray3 { - - case class Kernel(size: Int, buffer: Array[Int]) - - def isKernelValid(kernel: Kernel): Boolean = kernel.buffer.length == kernel.size * kernel.size - - def applyFilter(kernel: Kernel): Int = { - require(isKernelValid(kernel)) - 12 - } - - def testFilterConvolutionSmooth: Boolean = { - val smoothed = Array(124, 158, 76, 73) - val kernel = Kernel(3, Array(1, 1, 1, - 1, 2, 1, - 1, 1, 1)) - - def nested(): Unit = { - require(smoothed.length > 0) - smoothed(0) = applyFilter(kernel) - } - nested() - - smoothed(0) >= 0 - } -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTWithArray4.scala b/src/test/resources/regression/verification/purescala/valid/ADTWithArray4.scala deleted file mode 100644 index 5911743df2ecb1ec32d2ea3506ee0eb8fc597718..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTWithArray4.scala +++ /dev/null @@ -1,16 +0,0 @@ -object ADTWithArray4 { - - case class A(x: Int) - case class B(a: Array[A]) - - def foo(b: B): Int = { - require(b.a.length > 0) - b.a(0).x - } - - def test(): Int = { - val b = B(Array(A(1),A(2),A(3))) - foo(b) - } ensuring(_ == 1) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTWithArray5.scala b/src/test/resources/regression/verification/purescala/valid/ADTWithArray5.scala deleted file mode 100644 index be861a9e243c100aa63b9a61cb8ec0643b04b01e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTWithArray5.scala +++ /dev/null @@ -1,14 +0,0 @@ -import leon.collection._ - -object ADTWithArray5 { - - case class HashTable(table: Array[BigInt]) { - require(table.length > 0) - - def apply(index: Int): BigInt = { - require(index >= 0 && index < table.length) - table(index) - } - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/ADTWithArray6.scala b/src/test/resources/regression/verification/purescala/valid/ADTWithArray6.scala deleted file mode 100644 index 886e4dc4f79606b76794a161f65018f41f15741f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ADTWithArray6.scala +++ /dev/null @@ -1,13 +0,0 @@ -object ADTWithArray6 { - - case class A(x: Int) - - case class B(content: Array[A]) { - require(content.length > 0) - - def update(y: Int): B = { - B(Array(A(y))) - } ensuring(res => res.content(0).x == y) - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/AbstractRefinementMap.scala b/src/test/resources/regression/verification/purescala/valid/AbstractRefinementMap.scala deleted file mode 100644 index c42579dce65454c7111bfc1a3f8c1b5a61204d62..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/AbstractRefinementMap.scala +++ /dev/null @@ -1,24 +0,0 @@ -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object AbstractRefinementMap { - - case class ~>[A,B](private val f: A => B, pre: A => Boolean, ens: B => Boolean) { - require(forall((x: A) => pre(x) ==> ens(f(x)))) - - def apply(x: A): B = { - require(pre(x)) - f(x) - } ensuring(ens) - } - - def map[A, B](l: List[A], f: A ~> B): List[B] = { - require(forall((x:A) => l.contains(x) ==> f.pre(x))) - l match { - case Cons(x, xs) => Cons[B](f(x), map(xs, f)) - case Nil() => Nil[B]() - } - } ensuring { res => forall((x: B) => res.contains(x) ==> f.ens(x)) } -} - diff --git a/src/test/resources/regression/verification/purescala/valid/Acc.scala b/src/test/resources/regression/verification/purescala/valid/Acc.scala deleted file mode 100644 index 6f93027c9fc03fded4a86923e54d3d8d0bf65a6f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Acc.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Acc { - - case class Acc(checking : BigInt, savings : BigInt) - - def putAside(x: BigInt, a: Acc): Acc = { - require (x > 0 && notRed(a) && a.checking >= x) - Acc(a.checking - x, a.savings + x) - } ensuring { - r => notRed(r) && sameTotal(a, r) - } - - - def sameTotal(a1: Acc, a2: Acc): Boolean = { - a1.checking + a1.savings == a2.checking + a2.savings - } - - def notRed(a: Acc) : Boolean = { - a.checking >= 0 && a.savings >= 0 - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/AddingPositiveNumbers.scala b/src/test/resources/regression/verification/purescala/valid/AddingPositiveNumbers.scala deleted file mode 100644 index 84fca5dc63b3fb69504c65b2c38162879c8ec607..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/AddingPositiveNumbers.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object AddingPositiveNumbers { - - //this should not overflow - def additionSound(x: BigInt, y: BigInt): BigInt = { - require(x >= 0 && y >= 0) - x + y - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/AmortizedQueue.scala b/src/test/resources/regression/verification/purescala/valid/AmortizedQueue.scala deleted file mode 100644 index dfb302cb9d7a98c7103d059a9cc4f5abb74cdc6f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/AmortizedQueue.scala +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object AmortizedQueue { - sealed abstract class List - case class Cons(head : Int, tail : List) extends List - case class Nil() extends List - - sealed abstract class AbsQueue - case class Queue(front : List, rear : List) extends AbsQueue - - def size(list : List) : BigInt = (list match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def content(l: List) : Set[Int] = l match { - case Nil() => Set.empty[Int] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def asList(queue : AbsQueue) : List = queue match { - case Queue(front, rear) => concat(front, reverse(rear)) - } - - def concat(l1 : List, l2 : List) : List = (l1 match { - case Nil() => l2 - case Cons(x,xs) => Cons(x, concat(xs, l2)) - }) ensuring (res => size(res) == size(l1) + size(l2) && content(res) == content(l1) ++ content(l2)) - - def isAmortized(queue : AbsQueue) : Boolean = queue match { - case Queue(front, rear) => size(front) >= size(rear) - } - - def isEmpty(queue : AbsQueue) : Boolean = queue match { - case Queue(Nil(), Nil()) => true - case _ => false - } - - def reverse(l : List) : List = (l match { - case Nil() => Nil() - case Cons(x, xs) => concat(reverse(xs), Cons(x, Nil())) - }) ensuring (content(_) == content(l)) - - def amortizedQueue(front : List, rear : List) : AbsQueue = { - if (size(rear) <= size(front)) - Queue(front, rear) - else - Queue(concat(front, reverse(rear)), Nil()) - } ensuring(isAmortized(_)) - - def enqueue(queue : AbsQueue, elem : Int) : AbsQueue = (queue match { - case Queue(front, rear) => amortizedQueue(front, Cons(elem, rear)) - }) ensuring(isAmortized(_)) - - def tail(queue : AbsQueue) : AbsQueue = { - require(isAmortized(queue) && !isEmpty(queue)) - queue match { - case Queue(Cons(f, fs), rear) => amortizedQueue(fs, rear) - } - } ensuring (isAmortized(_)) - - def front(queue : AbsQueue) : Int = { - require(isAmortized(queue) && !isEmpty(queue)) - queue match { - case Queue(Cons(f, _), _) => f - } - } - - // @induct - // def propEnqueue(rear : List, front : List, list : List, elem : Int) : Boolean = { - // require(isAmortized(Queue(front, rear))) - // val queue = Queue(front, rear) - // if (asList(queue) == list) { - // asList(enqueue(queue, elem)) == concat(list, Cons(elem, Nil())) - // } else - // true - // }.holds - - @induct - def propFront(queue : AbsQueue, list : List, elem : Int) : Boolean = { - require(!isEmpty(queue) && isAmortized(queue)) - if (asList(queue) == list) { - list match { - case Cons(x, _) => front(queue) == x - } - } else - true - }.holds - - @induct - def propTail(rear : List, front : List, list : List, elem : Int) : Boolean = { - require(!isEmpty(Queue(front, rear)) && isAmortized(Queue(front, rear))) - if (asList(Queue(front, rear)) == list) { - list match { - case Cons(_, xs) => asList(tail(Queue(front, rear))) == xs - } - } else - true - } //.holds - - def enqueueAndFront(queue : AbsQueue, elem : Int) : Boolean = { - if (isEmpty(queue)) - front(enqueue(queue, elem)) == elem - else - true - }.holds - - def enqueueDequeueThrice(queue : AbsQueue, e1 : Int, e2 : Int, e3 : Int) : Boolean = { - if (isEmpty(queue)) { - val q1 = enqueue(queue, e1) - val q2 = enqueue(q1, e2) - val q3 = enqueue(q2, e3) - val e1prime = front(q3) - val q4 = tail(q3) - val e2prime = front(q4) - val q5 = tail(q4) - val e3prime = front(q5) - e1 == e1prime && e2 == e2prime && e3 == e3prime - } else - true - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Anonymous.scala b/src/test/resources/regression/verification/purescala/valid/Anonymous.scala deleted file mode 100644 index 2239fb9a67c2d5636629e5f26fd8a6337a158ed9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Anonymous.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Anonymous { - def test(x: BigInt) = { - require(x > 0) - val i = (a: BigInt) => a + 1 - i(x) + i(2) - } ensuring { res => res > 0 } -} diff --git a/src/test/resources/regression/verification/purescala/valid/Array1.scala b/src/test/resources/regression/verification/purescala/valid/Array1.scala deleted file mode 100644 index f1978f170bcbc74610a2dbf9e0b037ba9fae1f1a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Array1.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array1 { - - def foo(a: Array[Int]): Int = { - require(a.length > 2 && a(2) == 5) - a(2) - } ensuring(_ == 5) - - def bar(): Int = { - val a = Array.fill(5)(5) - foo(a) - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Array2.scala b/src/test/resources/regression/verification/purescala/valid/Array2.scala deleted file mode 100644 index 40b96f740074ac0a8025e73f18422d451395338d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Array2.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Array2 { - - def foo(a: Array[Int]): Array[Int] = { - require(a.length >= 2) - a.updated(1, 3) - } ensuring(res => res.length == a.length && res(1) == 3) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Array3.scala b/src/test/resources/regression/verification/purescala/valid/Array3.scala deleted file mode 100644 index a9f98167f23e1117d407bd20440be47d32bc89f3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Array3.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Array3 { - - def foo(i: Int): Array[Int] = { - require(i > 0) - val a = Array.fill(i)(0) - a - } ensuring(res => res.length == i) - - def bar(i: Int): Int = { - require(i > 0) - val b = foo(i) - b(0) - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Array4.scala b/src/test/resources/regression/verification/purescala/valid/Array4.scala deleted file mode 100644 index 71f708e1d3dde39bbaabd6d671f1b14c947b5674..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Array4.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array4 { - - def foo(x: Int): Int = { - require(x >= 0) - val a = Array(0,0,x,0,0) - a(2) - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Array5.scala b/src/test/resources/regression/verification/purescala/valid/Array5.scala deleted file mode 100644 index 5f3e4afe81496f2bf1296b0d49b79f5db7c9f3b9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Array5.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array5 { - - def foo(): Int = { - val x = 10 - val a = Array(0,0,x,0,0) - a(2) - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/ArrayLiterals.scala b/src/test/resources/regression/verification/purescala/valid/ArrayLiterals.scala deleted file mode 100644 index 4921b5e3661a178d5cc73e27d5792b402bde43f4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ArrayLiterals.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ArrayLiterals { - def foo(): Int = { - val b : Array[Int] = Array[Int](1,2,3) - val a : Array[Int] = Array(1,2,3) - a.length - } ensuring { _ > 0 } -} diff --git a/src/test/resources/regression/verification/purescala/valid/ArrayUpdated.scala b/src/test/resources/regression/verification/purescala/valid/ArrayUpdated.scala deleted file mode 100644 index d501089cf77bb3c5dd30dea7ac6dfce557508f13..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ArrayUpdated.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ArrayUpdated { - - def test(a: Array[Int]): Int = { - require(a.length > 0) - val a2 = a.updated(0, 2) - a2(0) - } ensuring(res => res == 2) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Asserts1.scala b/src/test/resources/regression/verification/purescala/valid/Asserts1.scala deleted file mode 100644 index aadcfde990f31b4106f9e741457d0e04f6634e7b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Asserts1.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ -import leon._ - -object Asserts1 { - - def foo(a: BigInt): BigInt = { - require(a > 0) - - { - val b = a - assert(b > 0, "Hey now") - b + bar(1) - } ensuring { _ > 2 } - - } ensuring { - _ > a - } - - def bar(a: BigInt): BigInt = { - require(a > 0) - - { - val b = a - assert(b > 0, "Hey now") - b + 2 - } ensuring { _ > 2 } - - } ensuring { - _ > a - } -} diff --git a/src/test/resources/regression/verification/purescala/valid/AssociativeList.scala b/src/test/resources/regression/verification/purescala/valid/AssociativeList.scala deleted file mode 100644 index bbc4edf5d8cd23e6b8ff37966bf2620e93acfde9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/AssociativeList.scala +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object AssociativeList { - sealed abstract class KeyValuePairAbs - case class KeyValuePair(key: Int, value: Int) extends KeyValuePairAbs - - sealed abstract class List - case class Cons(head: KeyValuePairAbs, tail: List) extends List - case class Nil() extends List - - sealed abstract class OptionInt - case class Some(i: Int) extends OptionInt - case class None() extends OptionInt - - def domain(l: List): Set[Int] = l match { - case Nil() => Set.empty[Int] - case Cons(KeyValuePair(k,_), xs) => Set(k) ++ domain(xs) - } - - def find(l: List, e: Int): OptionInt = l match { - case Nil() => None() - case Cons(KeyValuePair(k, v), xs) => if (k == e) Some(v) else find(xs, e) - } - - def noDuplicates(l: List): Boolean = l match { - case Nil() => true - case Cons(KeyValuePair(k, v), xs) => find(xs, k) == None() && noDuplicates(xs) - } - - def updateAll(l1: List, l2: List): List = (l2 match { - case Nil() => l1 - case Cons(x, xs) => updateAll(updateElem(l1, x), xs) - }) ensuring(domain(_) == domain(l1) ++ domain(l2)) - - def updateElem(l: List, e: KeyValuePairAbs): List = (l match { - case Nil() => Cons(e, Nil()) - case Cons(KeyValuePair(k, v), xs) => e match { - case KeyValuePair(ek, ev) => if (ek == k) Cons(KeyValuePair(ek, ev), xs) else Cons(KeyValuePair(k, v), updateElem(xs, e)) - } - }) ensuring(res => e match { - case KeyValuePair(k, v) => domain(res) == domain(l) ++ Set[Int](k) - }) - - @induct - def readOverWrite(l: List, k1: Int, k2: Int, e: Int) : Boolean = { - find(updateElem(l, KeyValuePair(k2,e)), k1) == (if (k1 == k2) Some(e) else find(l, k1)) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/AssociativityProperties.scala b/src/test/resources/regression/verification/purescala/valid/AssociativityProperties.scala deleted file mode 100644 index 5c8530615dff1cdc15868be54a2b0019acba1844..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/AssociativityProperties.scala +++ /dev/null @@ -1,33 +0,0 @@ -import leon.lang._ - -object AssociativityProperties { - - def isAssociative[A](f: (A,A) => A): Boolean = { - forall((x: A, y: A, z: A) => f(f(x, y), z) == f(x, f(y, z))) - } - - def isCommutative[A](f: (A,A) => A): Boolean = { - forall((x: A, y: A) => f(x, y) == f(y, x)) - } - - def isRotate[A](f: (A,A) => A): Boolean = { - forall((x: A, y: A, z: A) => f(f(x, y), z) == f(f(y, z), x)) - } - - def assocPairs[A,B](f1: (A,A) => A, f2: (B,B) => B) = { - require(isAssociative(f1) && isAssociative(f2)) - val fp = ((p1: (A,B), p2: (A,B)) => (f1(p1._1, p2._1), f2(p1._2, p2._2))) - isAssociative(fp) - }.holds - - def assocRotate[A](f: (A,A) => A): Boolean = { - require(isCommutative(f) && isRotate(f)) - isAssociative(f) - }.holds - - def assocRotateInt(f: (BigInt, BigInt) => BigInt): Boolean = { - require(isCommutative(f) && isRotate(f)) - isAssociative(f) - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/BVDivSemantics.scala b/src/test/resources/regression/verification/purescala/valid/BVDivSemantics.scala deleted file mode 100644 index 29459bfca5fd7bb64b5fb060e6bc83aedcf37b9a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/BVDivSemantics.scala +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object BVDivSemantics { - - def identity2(x: Int): Boolean = { - require(x != -2147483648) - -(x / 2) == -x/2 - } ensuring(res => res) - - def identity3(x: Int): Boolean = { - -(x / 2) == x / -2 - } ensuring(res => res) - - //def identity4(x: Int, y: Int): Boolean = { - // require(y > 0) - // - (x % y) == (-x)%y - //} ensuring(res => res) - - def identity5(x: Int): Boolean = { - x % 2 == x % -2 - } ensuring(res => res) - - def identity6(x: Int): Boolean = { - require(x != 0) - 5 % x == 5 % -x - } ensuring(res => res) - - - def basic1(): Boolean = { - -3 / 2 == -1 - } ensuring(res => res) - def basic2(): Boolean = { - -3 / -2 == 1 - } ensuring(res => res) - def basic3(): Boolean = { - 3 / -2 == -1 - } ensuring(res => res) - def basic4(): Boolean = { - 3 % -2 == 1 - } ensuring(res => res) - def basic5(): Boolean = { - -3 % -2 == -1 - } ensuring(res => res) - def basic6(): Boolean = { - -3 % 2 == -1 - } ensuring(res => res) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/BVDivisionByZero.scala b/src/test/resources/regression/verification/purescala/valid/BVDivisionByZero.scala deleted file mode 100644 index 74a77460131bde77220a6c82d206d96b4e83a3e8..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/BVDivisionByZero.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object BVDivisionByZero { - - def noDivByZero(x: Int): Boolean = { - (x / 10 == 10) - } - - def noRemByZero(x: BigInt): Boolean = { - (x % 10 == 10) - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/BVDivisionByZero2.scala b/src/test/resources/regression/verification/purescala/valid/BVDivisionByZero2.scala deleted file mode 100644 index 78510863ce905ccf6f86acb50bf56bb9896635e9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/BVDivisionByZero2.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object BVDivisionByZero2 { - - def division(x: Int, y: Int): Int = { - require(y != 0) - x / y - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/BasicReal.scala b/src/test/resources/regression/verification/purescala/valid/BasicReal.scala deleted file mode 100644 index fb8342da7e528679bfbd4265bf82891c647d6c94..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/BasicReal.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object BasicReal { - - def plusOfPositiveNumbers(x: Real, y: Real): Real = { - require(x >= Real(0) && y >= Real(0)) - x + y - } ensuring(_ >= Real(0)) - - - def max(x: Real, y: Real): Real = { - if(x >= y) x else y - } ensuring(res => (res == x || res == y) && res >= x && res >= y) - - - def divBy2(x: Real): Boolean = { - x/Real(2) == x*Real(1,2) - }.holds - - def twice(x: Real): Real = { - require(x > Real(0)) - Real(2)*x - } ensuring(res => res > x) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/BestRealTypes.scala b/src/test/resources/regression/verification/purescala/valid/BestRealTypes.scala deleted file mode 100644 index b40aac4f8d6b6342db76e21272dfa427c7d64c30..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/BestRealTypes.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -/** This benchmarks tests some potential issues with the legacy "bestRealType" function, which was original introduced to work around - * Scala's well-too-precise-for-Leon type inference. */ -object BestRealTypes { - sealed abstract class Num - case class Zero() extends Num - case class Succ(pred : Num) extends Num - - case class Wrapper(num : Num) - - def boolToNum(b : Boolean) : Num = if(b) { - Zero() - } else { - Succ(Zero()) - } - - // This requires computing the "bestRealTypes" of w1 and w2. - def zipWrap(w1 : Wrapper, w2 : Wrapper) : (Wrapper,Wrapper) = (w1, w2) - - def somethingToProve(b : Boolean) : Boolean = { - val (z1,z2) = zipWrap(Wrapper(boolToNum(b)), Wrapper(boolToNum(!b))) - z1.num == Zero() || z2.num == Zero() - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/BinarySearchTreeQuant.scala b/src/test/resources/regression/verification/purescala/valid/BinarySearchTreeQuant.scala deleted file mode 100644 index 4676dcd6a8faf5768dceeebe9f0f2293ae106ffd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/BinarySearchTreeQuant.scala +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ - -object BSTSimpler { - sealed abstract class Tree - case class Node(left: Tree, value: BigInt, right: Tree) extends Tree - case class Leaf() extends Tree - - def content(tree: Tree): Set[BigInt] = tree match { - case Leaf() => Set.empty[BigInt] - case Node(l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def isBST(tree: Tree) : Boolean = tree match { - case Leaf() => true - case Node(left, v, right) => { - isBST(left) && isBST(right) && - forall((x:BigInt) => (content(left).contains(x) ==> x < v)) && - forall((x:BigInt) => (content(right).contains(x) ==> v < x)) - } - } - - def emptySet(): Tree = Leaf() - - def insert(tree: Tree, value: BigInt): Node = { - require(isBST(tree)) - tree match { - case Leaf() => Node(Leaf(), value, Leaf()) - case Node(l, v, r) => (if (v < value) { - Node(l, v, insert(r, value)) - } else if (v > value) { - Node(insert(l, value), v, r) - } else { - Node(l, v, r) - }) - } - } ensuring(res => isBST(res) && content(res) == content(tree) ++ Set(value)) - - def createRoot(v: BigInt): Node = { - Node(Leaf(), v, Leaf()) - } ensuring (content(_) == Set(v)) -} diff --git a/src/test/resources/regression/verification/purescala/valid/BinarySearchTreeQuant2.scala b/src/test/resources/regression/verification/purescala/valid/BinarySearchTreeQuant2.scala deleted file mode 100644 index 46fb2bbeb826db7c7f9eef124b7e6ca27a61630d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/BinarySearchTreeQuant2.scala +++ /dev/null @@ -1,35 +0,0 @@ -import leon.lang._ -import leon.collection._ - -object BSTSimpler2 { - - sealed abstract class Tree { - def content: Set[BigInt] = this match { - case Leaf() => Set.empty[BigInt] - case Node(l, v, r) => l.content ++ Set(v) ++ r.content - } - } - - case class Node(left: Tree, value: BigInt, right: Tree) extends Tree { - require(forall((x:BigInt) => (left.content.contains(x) ==> x < value)) && - forall((x:BigInt) => (right.content.contains(x) ==> value < x))) - } - - case class Leaf() extends Tree - - def emptySet(): Tree = Leaf() - - def insert(tree: Tree, value: BigInt): Node = { - tree match { - case Leaf() => Node(Leaf(), value, Leaf()) - case Node(l, v, r) => (if (v < value) { - Node(l, v, insert(r, value)) - } else if (v > value) { - Node(insert(l, value), v, r) - } else { - Node(l, v, r) - }) - } - } ensuring(res => res.content == tree.content ++ Set(value)) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/BitsTricks.scala b/src/test/resources/regression/verification/purescala/valid/BitsTricks.scala deleted file mode 100644 index 23cbe32a4d3a33609e9ad83f095d335a6e43fa9f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/BitsTricks.scala +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object BitsTricks { - - def bitAt(x: Int, n: Int): Boolean = { - require(n >= 0 && n < 32) - ((x >> n) & 1) == 1 - } - - def isEven(x: Int): Boolean = { - (x & 1) == 0 - } ensuring(res => res == (x % 2 == 0)) - - def isNegative(x: Int): Boolean = { - (x >>> 31) == 1 - } ensuring(b => b == x < 0) - - def isBitNSet(x: Int, n: Int): Int = { - require(n >= 0 && n < 32) - (x & (1 << n)) - } - - def testBitSet1(): Int = { - isBitNSet(122, 3) - } ensuring(_ != 0) - def testBitSet2(): Int = { - isBitNSet(-33, 5) - } ensuring(_ == 0) - - def setBitN(x: Int, n: Int): Int = { - require(n >= 0 && n < 32) - x | (1 << n) - } ensuring(res => isBitNSet(res, n) != 0) - - def toggleBitN(x: Int, n: Int): Int = { - require(n >= 0 && n < 32) - x ^ (1 << n) - } ensuring(res => - if(isBitNSet(x, n) != 0) isBitNSet(res, n) == 0 - else isBitNSet(res, n) != 0) - - - def checkDoubleXor(x: Int, y: Int): Int = { - x ^ y ^ x - } ensuring(res => res == y) - - def turnOffRightmostOneRec(x: Int, indexFromLeft: Int): Int = { - require(0 <= indexFromLeft && indexFromLeft < 32) - if(bitAt(x, 31 - indexFromLeft)) toggleBitN(x, 31 - indexFromLeft)//(x ^ (1 << (31 - indexFromLeft))) - else if(indexFromLeft == 0) x - else turnOffRightmostOneRec(x, indexFromLeft - 1) - } - - // proves in 10s - def turnOffRightmostOne(x: Int): Int = { - x & (x - 1) - } //ensuring(_ == turnOffRightmostOneRec(x, 31)) - - // 010100 -> 010111 - def rightPropagateRightmostOne(x: Int): Int = { - x | (x - 1) - } - - def property1(x: Int): Boolean = { - val y = rightPropagateRightmostOne(x) - y == rightPropagateRightmostOne(y) - } ensuring(b => b) - - def isRotationLeft(x: Int, y: Int, n: Int, i: Int): Boolean = { - require(0 <= i && i < 32 && 0 <= n && n < 32) - val isOk = bitAt(x, i) == bitAt(y, (i + n) % 32) - if (i == 0) isOk else isOk && isRotationLeft(x, y, n, i-1) - } - - //rotateLeft proves in 1 minute (on very powerful computer) - def rotateLeft(x: Int, n: Int): Int = { - require(n >= 0 && n < 32) - val front = x >>> (32 - n) - (x << n) | front - } //ensuring(res => isRotationLeft(x, res, n, 31)) - - //careful with overflows, case definition, truncated - def safeMean(x: Int, y: Int): Int = { - if(x >= 0 && y <= 0 || x <= 0 && y >= 0) (x + y)/2 - else if(x >= 0 && x <= y) x + (y - x)/2 - else if(x >= 0 && y <= x) y + (x - y)/2 - else if(x <= 0 && x <= y) y + (x - y)/2 - else x + (y - x)/2 - } - - //proves in 45 seconds - def magicMean(x: Int, y: Int): Int = { - val t = (x&y)+((x^y) >> 1) - t + ((t >>> 31) & (x ^ y)) - } //ensuring(res => res == safeMean(x, y)) - - -} diff --git a/src/test/resources/regression/verification/purescala/valid/CallByName1.scala b/src/test/resources/regression/verification/purescala/valid/CallByName1.scala deleted file mode 100644 index 07247e0478aacfb2d3018f040948c212ac83f622..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/CallByName1.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object CallByName1 { - def add(a: => Int, b: => Int): Int = a + b - - def test(): Int = { - add(1,2) - } ensuring (_ == 3) -} diff --git a/src/test/resources/regression/verification/purescala/valid/CaseObject1.scala b/src/test/resources/regression/verification/purescala/valid/CaseObject1.scala deleted file mode 100644 index 318af66807102bb5727b365aa9fa4b6f2139d366..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/CaseObject1.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object CaseObject1 { - - abstract sealed class A - case class B(size: Int) extends A - case object C extends A - - def foo(): A = { - C - } - - def foo1(a: A): A = a match { - case C => a - case B(s) => a - } - - def foo2(a: A): A = a match { - case c @ C => c - case B(s) => a - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Choose1.scala b/src/test/resources/regression/verification/purescala/valid/Choose1.scala deleted file mode 100644 index ee36ea5061a54664bc43e63b80695ae3354f8a3b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Choose1.scala +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang.synthesis._ -import leon.lang._ - -object Choose1 { - sealed abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - def size(l: List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def content(l: List) : Set[Int] = l match { - case Nil() => Set.empty[Int] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def listOfSize(i: BigInt): List = { - require(i >= 0) - - if (i == BigInt(0)) { - Nil() - } else { - choose { (res: List) => size(res) == i } - } - } ensuring ( size(_) == i ) - - - def listOfSize2(i: BigInt): List = { - require(i >= 0) - - if (i > 0) { - Cons(0, listOfSize(i-1)) - } else { - Nil() - } - } ensuring ( size(_) == i ) -} diff --git a/src/test/resources/regression/verification/purescala/valid/Choose2.scala b/src/test/resources/regression/verification/purescala/valid/Choose2.scala deleted file mode 100644 index 15a2e0c03ed8559a5bb3fae3d6594e0f17d0999f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Choose2.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ - -object Choose2 { - - def test(x: Int): Int = { - - choose((y: Int) => { - val z = y + 2 - z == y - }) - - } ensuring(_ == x + 2) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Client.scala b/src/test/resources/regression/verification/purescala/valid/Client.scala deleted file mode 100644 index e58a05c99ed28f10c7f4f5142e2678bf0a737097..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Client.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.collection._ -import leon.lang._ - -object Minimal { - - case class Client(f: Int => List[Int]) - - val client = Client(x => List(1)) - - // def f(x: Int) = List(1) - // val client = Client(f) - - def theorem() = { - client.f(0).size != BigInt(0) - } holds - -} - diff --git a/src/test/resources/regression/verification/purescala/valid/Closures.scala b/src/test/resources/regression/verification/purescala/valid/Closures.scala deleted file mode 100644 index 47aed6f0b5cc8a2a8f4522d5ac8c720e115c9d71..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Closures.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Closures { - def addX(x: Int): Int => Int = { - (a: Int) => a + x - } - - def test(x: Int): Boolean = { - val add1 = addX(1) - val add2 = addX(2) - add1(add2(1)) == 4 - }.holds -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Closures2.scala b/src/test/resources/regression/verification/purescala/valid/Closures2.scala deleted file mode 100644 index f77ae2dd3f93dd8095635824ecfbfbcb2fcd8684..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Closures2.scala +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Closures2 { - def set(i: Int): Int => Boolean = x => x == i - - def union(s1: Int => Boolean, s2: Int => Boolean): Int => Boolean = x => s1(x) || s2(x) - - def intersection(s1: Int => Boolean, s2: Int => Boolean): Int => Boolean = x => s1(x) && s2(x) - - def diff(s1: Int => Boolean, s2: Int => Boolean): Int => Boolean = x => s1(x) && !s2(x) - - def set123(): Int => Boolean = union(set(1), union(set(2), set(3))) - - def test1(): Boolean = { - val s1 = set123() - val s2 = union(s1, set(4)) - s2(1) && s2(2) && s2(3) && s2(4) - }.holds - - def test2(): Boolean = { - val s1 = set123() - val s2 = intersection(s1, union(set(1), set(3))) - val s3 = diff(s1, s2) - s3(2) && !s3(1) && !s3(3) - }.holds - - def test3(): Boolean = { - val s1 = set123() - val s2 = set123() - val s3 = union(s1, s2) - s3(1) && s3(2) && s3(3) - }.holds -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Composition.scala b/src/test/resources/regression/verification/purescala/valid/Composition.scala deleted file mode 100644 index 64ac207269f38da7a67c72a90440e2bc357908aa..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Composition.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -import leon.lang._ - -object Composition { - def passing_1(f: (Int) => Int, g: (Int) => Int, x: Int): Int = { - require(g(1) == 2 && forall((a: Int) => f(g(a)) == a)) - val a = g(x) - if(x == 1) - f(g(a)) - else 2 - } ensuring { _ == 2 } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/DivisionByZero.scala b/src/test/resources/regression/verification/purescala/valid/DivisionByZero.scala deleted file mode 100644 index 9ce813efee8c277b7880d04e20005b60522fc9f4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/DivisionByZero.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object DivisionByZero { - - def noDivByZero(x: BigInt): Boolean = { - (x / BigInt(10) == BigInt(10)) - } - - def noRemByZero(x: BigInt): Boolean = { - (x % BigInt(10) == BigInt(10)) - } - - def noModByZero(x: BigInt): Boolean = { - (x mod BigInt(10)) == BigInt(10) - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Existentials.scala b/src/test/resources/regression/verification/purescala/valid/Existentials.scala deleted file mode 100644 index 471e4846363be5c06c5c86b0cabee9bf21c7f3a8..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Existentials.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Existentials { - - def exists[A](p: A => Boolean): Boolean = !forall((x: A) => !p(x)) - - /* - def check1(y: BigInt, p: BigInt => Boolean) : Boolean = { - p(y) == exists((y1:BigInt) => p(y1)) - }.holds - */ - - def check2(y: BigInt, p: BigInt => Boolean) : Boolean = { - p(y) ==> exists((y1:BigInt) => p(y1)) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Extern1.scala b/src/test/resources/regression/verification/purescala/valid/Extern1.scala deleted file mode 100644 index f0eb8963440eac66b053bbfb165b61b4abc96bb7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Extern1.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object Extern1 { - @extern - def plop(a: BigInt): BigInt = { - require(a > 0) - a + scala.math.abs(-3) - } ensuring { - _ > 0 - } - - def test(b: BigInt): BigInt = { - plop(if (b <= 0) -b+1 else b) - } ensuring { - _ > 0 - } - - def test2 = test(42) - def test3 = test(-2) -} diff --git a/src/test/resources/regression/verification/purescala/valid/Extern2.scala b/src/test/resources/regression/verification/purescala/valid/Extern2.scala deleted file mode 100644 index aac01ec11e18b902523178422669df00e5970cce..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Extern2.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object Extern2 { - @extern - def plop(a: BigInt): BigInt = { - a + scala.math.abs(-3) - } ensuring { - _ > 0 - } - - def test(b: BigInt): BigInt = { - plop(if (b <= 0) -b+1 else b) - } ensuring { - _ > 0 - } - - def test2 = test(42) - def test3 = test(-2) -} diff --git a/src/test/resources/regression/verification/purescala/valid/Field1.scala b/src/test/resources/regression/verification/purescala/valid/Field1.scala deleted file mode 100644 index 8c410b3d9ab93b3cb2dc6502a8b355b4722fcef4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Field1.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Field1 { - - abstract sealed class A - case class B(size: Int) extends A - - def foo(): Int = { - val b = B(3) - b.size - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Field2.scala b/src/test/resources/regression/verification/purescala/valid/Field2.scala deleted file mode 100644 index db42516e5abc5dabad55ad1decb220e7bc5227f2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Field2.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Field2 { - - abstract sealed class A - case class B(length: Int) extends A - - def foo(): Int = { - val b = B(3) - b.length - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/FieldInheritance.scala b/src/test/resources/regression/verification/purescala/valid/FieldInheritance.scala deleted file mode 100644 index 68f7f4961ea9207dd757afaedad846a95b61255f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/FieldInheritance.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object FieldInheritance { - - abstract class Foo[B] { - val thisIsIt: BigInt = 1 - val y: BigInt - val weird: B - } - - case class Bar[X](override val thisIsIt: BigInt, weird: X) extends Foo[X] { - val y = thisIsIt - } - - case class Baz[X](weird: X) extends Foo[X] { - val y = thisIsIt + 1 - } - - - def foo[A](f: Foo[A]) = { f match { - case Bar(t, _) => f.thisIsIt == t - case _ => true - }}.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/FiniteSort.scala b/src/test/resources/regression/verification/purescala/valid/FiniteSort.scala deleted file mode 100644 index add622294d94640397d3f1ccb16595c3cea49c33..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/FiniteSort.scala +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object FiniteSort { - - // These finite sorting functions essentially implement insertion sort. - def sort2(x : Int, y : Int) : (Int,Int) = { - if(x < y) (x, y) else (y, x) - } ensuring (_ match { - case (a, b) => a <= b && Set(a,b) == Set(x,y) - }) - - def sort3(x1 : Int, x2 : Int, x3 : Int) : (Int, Int, Int) = { - val (x1s, x2s) = sort2(x1, x2) - - if(x2s <= x3) { - (x1s, x2s, x3) - } else if(x1s <= x3) { - (x1s, x3, x2s) - } else { - (x3, x1s, x2s) - } - } ensuring (_ match { - case (a, b, c) => a <= b && b <= c && Set(a,b,c) == Set(x1,x2,x3) - }) - - def sort4(x1 : Int, x2 : Int, x3 : Int, x4 : Int) : (Int, Int, Int, Int) = { - val (x1s, x2s, x3s) = sort3(x1, x2, x3) - - if(x3s <= x4) { - (x1s, x2s, x3s, x4) - } else if(x2s <= x4) { - (x1s, x2s, x4, x3s) - } else if(x1s <= x4) { - (x1s, x4, x2s, x3s) - } else { - (x4, x1s, x2s, x3s) - } - } ensuring (_ match { - case (a, b, c, d) => a <= b && b <= c && c <= d && Set(a,b,c,d) == Set(x1,x2,x3,x4) - }) - - def sort5(x1 : Int, x2 : Int, x3 : Int, x4 : Int, x5 : Int) : (Int, Int, Int, Int, Int) = { - val (x1s, x2s, x3s, x4s) = sort4(x1, x2, x3, x4) - - if(x4s <= x5) { - (x1s, x2s, x3s, x4s, x5) - } else if(x3s <= x5) { - (x1s, x2s, x3s, x5, x4s) - } else if(x2s <= x5) { - (x1s, x2s, x5, x3s, x4s) - } else if(x1s <= x5) { - (x1s, x5, x2s, x3s, x4s) - } else { - (x5, x1s, x2s, x3s, x4s) - } - } ensuring (_ match { - case (a, b, c, d, e) => a <= b && b <= c && c <= d && d <= e && Set(a,b,c,d,e) == Set(x1,x2,x3,x4,x5) - }) -} diff --git a/src/test/resources/regression/verification/purescala/valid/FlatMap.scala b/src/test/resources/regression/verification/purescala/valid/FlatMap.scala deleted file mode 100644 index 9ff0308e474ec9e679f5fa9a3c3504ae732f9da7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/FlatMap.scala +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.proof._ -import leon.collection._ - -object FlatMap { - - def append[T](l1: List[T], l2: List[T]): List[T] = l1 match { - case Cons(head, tail) => Cons(head, append(tail, l2)) - case Nil() => l2 - } - - def associative_append_lemma[T](l1: List[T], l2: List[T], l3: List[T]): Boolean = { - append(append(l1, l2), l3) == append(l1, append(l2, l3)) - } - - def associative_append_lemma_induct[T](l1: List[T], l2: List[T], l3: List[T]): Boolean = { - l1 match { - case Nil() => associative_append_lemma(l1, l2, l3) - case Cons(head, tail) => associative_append_lemma(l1, l2, l3) because associative_append_lemma_induct(tail, l2, l3) - } - }.holds - - def flatMap[T,U](list: List[T], f: T => List[U]): List[U] = list match { - case Cons(head, tail) => append(f(head), flatMap(tail, f)) - case Nil() => Nil() - } - - def associative_lemma[T,U,V](list: List[T], f: T => List[U], g: U => List[V]): Boolean = { - flatMap(flatMap(list, f), g) == flatMap(list, (x: T) => flatMap(f(x), g)) - } - - def associative_lemma_induct[T,U,V](list: List[T], flist: List[U], glist: List[V], f: T => List[U], g: U => List[V]): Boolean = { - associative_lemma(list, f, g) because { - append(glist, flatMap(append(flist, flatMap(list, f)), g)) == append(append(glist, flatMap(flist, g)), flatMap(list, (x: T) => flatMap(f(x), g))) because - (glist match { - case Cons(ghead, gtail) => - associative_lemma_induct(list, flist, gtail, f, g) - case Nil() => flist match { - case Cons(fhead, ftail) => - associative_lemma_induct(list, ftail, g(fhead), f, g) - case Nil() => list match { - case Cons(head, tail) => associative_lemma_induct(tail, f(head), Nil(), f, g) - case Nil() => true - } - } - }) - } - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/FoldAssociative.scala b/src/test/resources/regression/verification/purescala/valid/FoldAssociative.scala deleted file mode 100644 index f333c936fcc990e54e4b021fb3507ec585c68545..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/FoldAssociative.scala +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.lang._ -import leon.proof._ - -object FoldAssociative { - - sealed abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - sealed abstract class Option - case class Some(x: Int) extends Option - case class None() extends Option - - def foldRight[A](list: List, state: A, f: (Int, A) => A): A = list match { - case Cons(head, tail) => - val tailState = foldRight(tail, state, f) - f(head, tailState) - case Nil() => state - } - - def take(list: List, count: Int): List = { - require(count >= 0) - list match { - case Cons(head, tail) if count > 0 => Cons(head, take(tail, count - 1)) - case _ => Nil() - } - } - - def drop(list: List, count: Int): List = { - require(count >= 0) - list match { - case Cons(head, tail) if count > 0 => drop(tail, count - 1) - case _ => list - } - } - - def append(l1: List, l2: List): List = { - l1 match { - case Cons(head, tail) => Cons(head, append(tail, l2)) - case Nil() => l2 - } - } - - def lemma_split(list: List, x: Int): Boolean = { - require(x >= 0) - val f = (x: Int, s: Int) => x + s - val l1 = take(list, x) - val l2 = drop(list, x) - foldRight(list, 0, f) == foldRight(l1, foldRight(l2, 0, f), f) - } - - def lemma_split_induct(list: List, x: Int): Boolean = { - require(x >= 0) - val f = (x: Int, s: Int) => x + s - val l1 = take(list, x) - val l2 = drop(list, x) - lemma_split(list, x) because (list match { - case Cons(head, tail) if x > 0 => - lemma_split_induct(tail, x - 1) - case _ => true - }) - }.holds - - def lemma_reassociative(list: List, x: Int): Boolean = { - require(x >= 0) - val f = (x: Int, s: Int) => x + s - val l1 = take(list, x) - val l2 = drop(list, x) - - foldRight(list, 0, f) == foldRight(l1, 0, f) + foldRight(l2, 0, f) - } - - def lemma_reassociative_induct(list: List, x: Int): Boolean = { - require(x >= 0) - val f = (x: Int, s: Int) => x + s - val l1 = take(list, x) - val l2 = drop(list, x) - lemma_reassociative(list, x) because (list match { - case Cons(head, tail) if x > 0 => - lemma_reassociative_induct(tail, x - 1) - case _ => true - }) - }.holds - - def lemma_reassociative_presplit(l1: List, l2: List): Boolean = { - val f = (x: Int, s: Int) => x + s - val list = append(l1, l2) - foldRight(list, 0, f) == foldRight(l1, 0, f) + foldRight(l2, 0, f) - } - - def lemma_reassociative_presplit_induct(l1: List, l2: List): Boolean = { - val f = (x: Int, s: Int) => x + s - val list = append(l1, l2) - lemma_reassociative_presplit(l1, l2) because (l1 match { - case Cons(head, tail) => - lemma_reassociative_presplit_induct(tail, l2) - case Nil() => true - }) - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/FoolProofAdder.scala b/src/test/resources/regression/verification/purescala/valid/FoolProofAdder.scala deleted file mode 100644 index dfc11de525aa88f8cc613fd8a78cd8a57cba9d03..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/FoolProofAdder.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object FoolProofAdder { - - def foolProofAdder(x: BigInt): BigInt = { - require(x > 0) - x + BigInt(999999) + BigInt("999999999999999") - } ensuring(_ > 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/ForallAssoc.scala b/src/test/resources/regression/verification/purescala/valid/ForallAssoc.scala deleted file mode 100644 index f001bc43563f9082a335210844f5eebdb9d8930f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ForallAssoc.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ForallAssoc { - - def ex[A](x1: A, x2: A, x3: A, x4: A, x5: A, f: (A, A) => A) = { - require(forall { - (x: A, y: A, z: A) => f(x, f(y, z)) == f(f(x, y), z) - }) - - f(x1, f(x2, f(x3, f(x4, x5)))) == f(f(x1, f(x2, f(x3, x4))), x5) - }.holds - - def test1(f: (BigInt, BigInt) => BigInt): Boolean = { - require(forall((x: BigInt, y: BigInt, z: BigInt) => f(x, f(y, z)) == f(f(x, y), z))) - f(1, f(2, f(3, 4))) == f(f(f(1, 2), 3), 4) - }.holds - - def test2(f: (BigInt, BigInt) => BigInt): Boolean = { - require(forall((x: BigInt, y: BigInt, z: BigInt) => f(x, f(y, z)) == f(f(x, y), z))) - f(1, f(2, f(3, f(4, 5)))) == f(f(f(f(1, 2), 3), 4), 5) - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Formulas.scala b/src/test/resources/regression/verification/purescala/valid/Formulas.scala deleted file mode 100644 index 6a1529187b1c30deaf572ce18e822d636914597d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Formulas.scala +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon._ - -object Formulas { - abstract class Expr - case class And(lhs: Expr, rhs: Expr) extends Expr - case class Or(lhs: Expr, rhs: Expr) extends Expr - case class Implies(lhs: Expr, rhs: Expr) extends Expr - case class Not(e : Expr) extends Expr - case class BoolLiteral(i: BigInt) extends Expr - - def exists(e: Expr, f: Expr => Boolean): Boolean = { - f(e) || (e match { - case And(lhs, rhs) => exists(lhs, f) || exists(rhs, f) - case Or(lhs, rhs) => exists(lhs, f) || exists(rhs, f) - case Implies(lhs, rhs) => exists(lhs, f) || exists(rhs, f) - case Not(e) => exists(e, f) - case _ => false - }) - } - - def existsImplies(e: Expr): Boolean = { - e.isInstanceOf[Implies] || (e match { - case And(lhs, rhs) => existsImplies(lhs) || existsImplies(rhs) - case Or(lhs, rhs) => existsImplies(lhs) || existsImplies(rhs) - case Implies(lhs, rhs) => existsImplies(lhs) || existsImplies(rhs) - case Not(e) => existsImplies(e) - case _ => false - }) - } - - abstract class Value - case class BoolValue(b: Boolean) extends Value - case class IntValue(i: BigInt) extends Value - case object Error extends Value - - def desugar(e: Expr): Expr = { - e match { - case And(lhs, rhs) => And(desugar(lhs), desugar(rhs)) - case Or(lhs, rhs) => Or(desugar(lhs), desugar(rhs)) - case Implies(lhs, rhs) => - Or(Not(desugar(lhs)), desugar(rhs)) - case Not(e) => Not(desugar(e)) - case e => e - } - } ensuring { out => - !existsImplies(out) && - !exists(out, f => f.isInstanceOf[Implies]) - } -} diff --git a/src/test/resources/regression/verification/purescala/valid/Generics.scala b/src/test/resources/regression/verification/purescala/valid/Generics.scala deleted file mode 100644 index 86ee9d50c2fb06b03d117ab205f659ebd9e569b7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Generics.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Generics { - abstract class List[T] - case class Cons[A](head: A, tail: List[A]) extends List[A] - case class Nil[B]() extends List[B] - - def size[T](l: List[T]): BigInt = (l match { - case Nil() => BigInt(0) - case Cons(h, t) => 1+size(t) - })ensuring { _ >= 0 } - - def content[T](l: List[T]): Set[T] = l match { - case Nil() => Set() - case Cons(h, t) => Set(h) ++ content(t) - } - - def insert[T](a: T, l: List[T]): List[T] = { - Cons(a, l) - } ensuring { res => (size(res) == size(l) + 1) && (content(res) == content(l) ++ Set(a))} -} diff --git a/src/test/resources/regression/verification/purescala/valid/Generics1.scala b/src/test/resources/regression/verification/purescala/valid/Generics1.scala deleted file mode 100644 index e054b629fbd05c17dc0aed5fe9bb6e713f8a8f01..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Generics1.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Generics1 { - abstract class List[T] - case class Cons[A](head: A, tail: List[A]) extends List[A] - case class Nil[B]() extends List[B] - - def size[T](l: List[T]): BigInt = (l match { - case Nil() => BigInt(0) - case Cons(h, t) => size(t) + BigInt(1) - }) ensuring((res: BigInt) => res >= BigInt(0)) - - def content[T](l: List[T]): Set[T] = l match { - case Nil() => Set() - case Cons(h, t) => Set(h) ++ content(t) - } - - def insert[T](a: T, l: List[T]): List[T] = { - Cons(a, l) - } ensuring { res => (size(res) == size(l) + 1) && (content(res) == content(l) ++ Set(a))} - - def insertInt(a: BigInt, l: List[BigInt]): List[BigInt] = { - insert(a,l) - } ensuring { res => (size(res) == size(l) + 1) && (content(res) == content(l) ++ Set(a))} -} diff --git a/src/test/resources/regression/verification/purescala/valid/HOInvocations.scala b/src/test/resources/regression/verification/purescala/valid/HOInvocations.scala deleted file mode 100644 index 81fab89f9a09640347923dafdf9ef252a3176429..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/HOInvocations.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object HOInvocations { - def switch(x: Int, f: (Int) => Int, g: (Int) => Int) = if(x > 0) f else g - - def passing_1(f: (Int) => Int) = { - switch(10, (x: Int) => x + 1, f)(2) - } ensuring { res => res > 0 } - - def passing_2(x: Int, f: (Int) => Int, g: (Int) => Int) = { - require(x > 0) - switch(1, switch(x, f, g), g)(1) - } ensuring { res => res == f(1) } - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/HOInvocations2.scala b/src/test/resources/regression/verification/purescala/valid/HOInvocations2.scala deleted file mode 100644 index 550da0cf20c0320640afbe121c8179d673b66e24..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/HOInvocations2.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object HOInvocations2 { - def switch(x: Int, f: (Int) => Int, g: (Int) => Int) = if(x > 0) f else g - - def passing_1(f: (Int) => Int) = { - switch(10, (x: Int) => x + 1, f)(2) - } ensuring { res => res > 0 } - - def passing_2(x: Int, f: (Int) => Int, g: (Int) => Int) = { - require(x > 0 && forall((a: Int) => a > 0 ==> f(a) > 0)) - switch(1, switch(x, f, g), g)(1) - } ensuring { res => res > 0 } - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Heaps.scala b/src/test/resources/regression/verification/purescala/valid/Heaps.scala deleted file mode 100644 index 7379ad87db0455c162c24bd601c3d18695598b77..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Heaps.scala +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Heaps { - /*~~~~~~~~~~~~~~~~~~~~~~~*/ - /* Data type definitions */ - /*~~~~~~~~~~~~~~~~~~~~~~~*/ - private case class Node(rank : BigInt, elem : Int, nodes : Heap) - - sealed abstract class Heap - private case class Nodes(head : Node, tail : Heap) extends Heap - private case object Empty extends Heap - - sealed abstract class OptInt - case class Some(value : Int) extends OptInt - case object None extends OptInt - - /*~~~~~~~~~~~~~~~~~~~~~~~*/ - /* Abstraction functions */ - /*~~~~~~~~~~~~~~~~~~~~~~~*/ - def heapContent(h : Heap) : Set[Int] = h match { - case Empty => Set.empty[Int] - case Nodes(n, ns) => nodeContent(n) ++ heapContent(ns) - } - - def nodeContent(n : Node) : Set[Int] = n match { - case Node(_, e, h) => Set(e) ++ heapContent(h) - } - - /*~~~~~~~~~~~~~~~~~~~~~~~~*/ - /* Helper/local functions */ - /*~~~~~~~~~~~~~~~~~~~~~~~~*/ - private def reverse(h : Heap) : Heap = reverse0(h, Empty) - private def reverse0(h : Heap, acc : Heap) : Heap = (h match { - case Empty => acc - case Nodes(n, ns) => reverse0(ns, Nodes(n, acc)) - }) ensuring(res => heapContent(res) == heapContent(h) ++ heapContent(acc)) - - private def link(t1 : Node, t2 : Node) = (t1, t2) match { - case (Node(r, e1, ns1), Node(_, e2, ns2)) => - if(e1 <= e2) { - Node(r + 1, e1, Nodes(t2, ns1)) - } else { - Node(r + 1, e2, Nodes(t1, ns2)) - } - } - - private def insertNode(t : Node, h : Heap) : Heap = (h match { - case Empty => Nodes(t, Empty) - case Nodes(t2, h2) => - if(t.rank < t2.rank) { - Nodes(t, h) - } else { - insertNode(link(t, t2), h2) - } - }) ensuring(res => heapContent(res) == nodeContent(t) ++ heapContent(h)) - - private def getMin(h : Heap) : (Node, Heap) = { - require(h != Empty) - h match { - case Nodes(t, Empty) => (t, Empty) - case Nodes(t, ts) => - val (t0, ts0) = getMin(ts) - if(t.elem < t0.elem) { - (t, ts) - } else { - (t0, Nodes(t, ts0)) - } - } - } ensuring(_ match { - case (n,h2) => nodeContent(n) ++ heapContent(h2) == heapContent(h) - }) - - /*~~~~~~~~~~~~~~~~*/ - /* Heap interface */ - /*~~~~~~~~~~~~~~~~*/ - def empty() : Heap = { - Empty - } ensuring(res => heapContent(res) == Set.empty[Int]) - - def isEmpty(h : Heap) : Boolean = { - (h == Empty) - } ensuring(res => res == (heapContent(h) == Set.empty[Int])) - - def insert(e : Int, h : Heap) : Heap = { - insertNode(Node(0, e, Empty), h) - } ensuring(res => heapContent(res) == heapContent(h) ++ Set(e)) - - def merge(h1 : Heap, h2 : Heap) : Heap = ((h1,h2) match { - case (_, Empty) => h1 - case (Empty, _) => h2 - case (Nodes(t1, ts1), Nodes(t2, ts2)) => - if(t1.rank < t2.rank) { - Nodes(t1, merge(ts1, h2)) - } else if(t2.rank < t1.rank) { - Nodes(t2, merge(h1, ts2)) - } else { - insertNode(link(t1, t2), merge(ts1, ts2)) - } - }) ensuring(res => heapContent(res) == heapContent(h1) ++ heapContent(h2)) - - def findMin(h : Heap) : OptInt = (h match { - case Empty => None - case Nodes(Node(_, e, _), ns) => - findMin(ns) match { - case None => Some(e) - case Some(e2) => Some(if(e < e2) e else e2) - } - }) ensuring(_ match { - case None => isEmpty(h) - case Some(v) => heapContent(h).contains(v) - }) - - def deleteMin(h : Heap) : Heap = (h match { - case Empty => Empty - case ts : Nodes => - val (Node(_, e, ns1), ns2) = getMin(ts) - merge(reverse(ns1), ns2) - }) ensuring(res => heapContent(res).subsetOf(heapContent(h))) - - def sanity0() : Boolean = { - val h0 : Heap = Empty - val h1 = insert(42, h0) - val h2 = insert(72, h1) - val h3 = insert(0, h2) - findMin(h0) == None && - findMin(h1) == Some(42) && - findMin(h2) == Some(42) && - findMin(h3) == Some(0) - }.holds - - def sanity1() : Boolean = { - val h0 = insert(42, Empty) - val h1 = insert(0, Empty) - val h2 = merge(h0, h1) - findMin(h2) == Some(0) - }.holds - - def sanity3() : Boolean = { - val h0 = insert(42, insert(0, insert(12, Empty))) - val h1 = deleteMin(h0) - findMin(h1) == Some(12) - }.holds -} - diff --git a/src/test/resources/regression/verification/purescala/valid/InsertionSort.scala b/src/test/resources/regression/verification/purescala/valid/InsertionSort.scala deleted file mode 100644 index 157e3394e9e102dee74c377eea3340c69b41cdce..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/InsertionSort.scala +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object InsertionSort { - sealed abstract class List - case class Cons(head:Int,tail:List) extends List - case class Nil() extends List - - sealed abstract class OptInt - case class Some(value: Int) extends OptInt - case class None() extends OptInt - - def size(l : List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def contents(l: List): Set[Int] = l match { - case Nil() => Set.empty - case Cons(x,xs) => contents(xs) ++ Set(x) - } - - def min(l : List) : OptInt = l match { - case Nil() => None() - case Cons(x, xs) => min(xs) match { - case None() => Some(x) - case Some(x2) => if(x < x2) Some(x) else Some(x2) - } - } - - def isSorted(l: List): Boolean = l match { - case Nil() => true - case Cons(x, Nil()) => true - case Cons(x, Cons(y, ys)) => x <= y && isSorted(Cons(y, ys)) - } - - /* Inserting element 'e' into a sorted list 'l' produces a sorted list with - * the expected content and size */ - def sortedIns(e: Int, l: List): List = { - require(isSorted(l)) - l match { - case Nil() => Cons(e,Nil()) - case Cons(x,xs) => if (x <= e) Cons(x,sortedIns(e, xs)) else Cons(e, l) - } - } ensuring(res => contents(res) == contents(l) ++ Set(e) - && isSorted(res) - && size(res) == size(l) + 1 - ) - - /* Insertion sort yields a sorted list of same size and content as the input - * list */ - def sort(l: List): List = (l match { - case Nil() => Nil() - case Cons(x,xs) => sortedIns(x, sort(xs)) - }) ensuring(res => contents(res) == contents(l) - && isSorted(res) - && size(res) == size(l) - ) - - @ignore - def main(args: Array[String]): Unit = { - val ls: List = Cons(5, Cons(2, Cons(4, Cons(5, Cons(1, Cons(8,Nil())))))) - - println(ls) - println(sort(ls)) - } -} diff --git a/src/test/resources/regression/verification/purescala/valid/InstanceOf1.scala b/src/test/resources/regression/verification/purescala/valid/InstanceOf1.scala deleted file mode 100644 index 6901da6c8d3cb85afe16343513cabebaa1fc59a0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/InstanceOf1.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object InstanceOf1 { - - abstract class A - case class B(i: Int) extends A - case class C(i: Int) extends A - - def foo(): Int = { - require(C(3).isInstanceOf[C]) - val b: A = B(2) - if(b.isInstanceOf[B]) - 0 - else - -1 - } ensuring(_ == 0) - - def bar(): Int = foo() - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Justify.scala b/src/test/resources/regression/verification/purescala/valid/Justify.scala deleted file mode 100644 index b7517052c8e12650b468656df67825ea86029d7a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Justify.scala +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.synthesis._ -import leon.collection._ - -object Justify { - /* - * The Science of Programming from David Gries Section 20.1 - - * The goal is to justify a text. We are given a list of indices corresponding - * to the columns of the starting point of each word. Each words are already - * separated by one space. The parameter s is the additional number of spaces - * at the end of the line that we will need to add between words. We - * want the number of space on the same line to differ by at most one. - * - * If we denote by p and q the two number of spaces between words (p and q differ - * only by 1), then we want to only switch once the number of space between words - * on the line. This means that we first separate words using p, then we do it using - * q until the end of the line. - * - * z is the line number, the rule is for odd line number to have more spaces on the right (q=p+1) - * and for even line number to have more spaces on the left (p=q+1). We do not want trailing - * spaces. - * - * n is the number of words on the line. - * - * If we apply this justify to each line of a text separately, this should lead to a good looking - * justified text. - - * Here is an example: - * - * justifying lines by - * inserting extra blanks is - * one task of a text editor. - * - * results in: - * - * justifying lines by - * inserting extra blanks is - * one task of a text editor. - */ - - def addSpaces(words: List[BigInt], p: BigInt, q: BigInt, t: BigInt, n: BigInt, i: BigInt): List[BigInt] = words match { - case Nil() => Nil() - case Cons(head, tail) => - if(i <= t) Cons(head + p*(i-1), addSpaces(tail, p, q, t, n, i+1)) - else if(i > t && i <= n) Cons(head + p*(t-1) + q*(i-t), addSpaces(tail, p, q, t, n, i+1)) - else Nil() //this should never happen - } - - //this version implements the computation of parameters - def justifyParamsImpl(n: BigInt, z: BigInt, s: BigInt): (BigInt, BigInt, BigInt) = { - require(n >= 2 && s >= 0 && z >= 1) - val (q, t, p) = if(z % 2 == 0) { - val tmp = s / (n-1) - (tmp, 1 + (s % (n - 1)), tmp + 1) - } else { - val tmp = s / (n-1) - (tmp + 1, n - (s % (n - 1)), tmp) - } - (q, t, p) - } - - def justifyImpl(n: BigInt, z: BigInt, s: BigInt, words: List[BigInt]): (BigInt, BigInt, BigInt, List[BigInt]) = { - require(n >= 2 && s >= 0 && z >= 1) - val (q, t, p) = if(z % 2 == 0) { - val tmp = s / (n-1) - (tmp, 1 + (s % (n - 1)), tmp + 1) - } else { - val tmp = s / (n-1) - (tmp + 1, n - (s % (n - 1)), tmp) - } - (q, t, p, addSpaces(words, p, q, t, n, 0)) - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/LambdaEquality.scala b/src/test/resources/regression/verification/purescala/valid/LambdaEquality.scala deleted file mode 100644 index bf72524cf229b733c6e3746a2f5ceaf4d4234952..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/LambdaEquality.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -import leon.lang._ -import leon.annotation._ -import leon.collection._ - -object LambdaEquality { - def app[A, B](x: A)(f: A => B): B = f(x) - - @induct - def mapId[A](xs: List[A]): Boolean = { - xs.map(id) == xs && { - xs match { - case Nil() => true - case Cons(x, xs) => - mapId(xs) && - id(x) :: xs.map(id) == x :: xs && - true - } - } - }.holds - - def id[A](a: A): A = a - - def mapEquality1[A, B](xs: List[A])(f: A => B): Boolean = { - xs.map(f) == xs.map(f) - }.holds - - def mapEquality2[A, B](xs: List[A])(f: A => B): Boolean = { - xs.map(id) == xs.map(id) - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Lambdas.scala b/src/test/resources/regression/verification/purescala/valid/Lambdas.scala deleted file mode 100644 index b39d2c8037299e3b405721c1f553294e0d3278ce..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Lambdas.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Lambdas { - def gen(x: Int): (Int) => Int = { - val f = (x: Int) => x + 1 - val g = (x: Int) => x + 2 - if (x > 0) g else f - } - - def test(x: Int): Boolean = { - require(x > 0) - val f = gen(x) - f(x) == x + 2 - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Lambdas2.scala b/src/test/resources/regression/verification/purescala/valid/Lambdas2.scala deleted file mode 100644 index 05574dd64b7da9c8cf542360e24244989d8ef869..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Lambdas2.scala +++ /dev/null @@ -1,29 +0,0 @@ -import leon.lang._ - -object Lambdas2 { - - val init_messages = (i: BigInt) => BigInt(0) - - - def smallNumbers(n: BigInt, messages: BigInt => BigInt)(i: BigInt, j: BigInt) = { - i < n && j < n - } - - def intForAll2(n: BigInt, m: BigInt, p: (BigInt, BigInt) => Boolean): Boolean = { -// forall ((i: BigInt, j: BigInt) => (0 <= i && i < n && 0 <= j && j < n) ==> p(i,j)) - - if (n <= 0 || m <= 0) true - else p(n-1,m-1) && intForAll2(n-1, m, p) && intForAll2(n, m-1, p) - } - - def invariant(n: BigInt, messages: BigInt => BigInt) = { - intForAll2(n, n, smallNumbers(n, messages)) - } - - def theorem(n: BigInt) = { - require(intForAll2(n, n, smallNumbers(n, init_messages))) - - invariant(n, init_messages) - } holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/ListOperations.scala b/src/test/resources/regression/verification/purescala/valid/ListOperations.scala deleted file mode 100644 index e711c9682ccf0f4ba08910999b5e781f977a5336..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ListOperations.scala +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object ListOperations { - sealed abstract class List - case class Cons(head: Int, tail: List) extends List - case class Nil() extends List - - sealed abstract class IntPairList - case class IPCons(head: IntPair, tail: IntPairList) extends IntPairList - case class IPNil() extends IntPairList - - sealed abstract class IntPair - case class IP(fst: Int, snd: Int) extends IntPair - - def size(l: List) : BigInt = (l match { - case Nil() => BigInt(0) - case Cons(_, t) => 1 + size(t) - }) ensuring(res => res >= 0) - - def iplSize(l: IntPairList) : BigInt = (l match { - case IPNil() => BigInt(0) - case IPCons(_, xs) => 1 + iplSize(xs) - }) ensuring(_ >= 0) - - def zip(l1: List, l2: List) : IntPairList = { - // try to comment this and see how pattern-matching becomes - // non-exhaustive and post-condition fails - require(size(l1) == size(l2)) - - l1 match { - case Nil() => IPNil() - case Cons(x, xs) => l2 match { - case Cons(y, ys) => IPCons(IP(x, y), zip(xs, ys)) - } - } - } ensuring(iplSize(_) == size(l1)) - - def sizeTailRec(l: List) : BigInt = sizeTailRecAcc(l, 0) - def sizeTailRecAcc(l: List, acc: BigInt) : BigInt = { - require(acc >= 0) - l match { - case Nil() => acc - case Cons(_, xs) => sizeTailRecAcc(xs, acc+1) - } - } ensuring(res => res == size(l) + acc) - - def sizesAreEquiv(l: List) : Boolean = { - size(l) == sizeTailRec(l) - }.holds - - def content(l: List) : Set[Int] = l match { - case Nil() => Set.empty[Int] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def sizeAndContent(l: List) : Boolean = { - size(l) == BigInt(0) || content(l) != Set.empty[Int] - }.holds - - def drunk(l : List) : List = (l match { - case Nil() => Nil() - case Cons(x,l1) => Cons(x,Cons(x,drunk(l1))) - }) ensuring (size(_) == 2 * size(l)) - - def reverse(l: List) : List = reverse0(l, Nil()) ensuring(content(_) == content(l)) - def reverse0(l1: List, l2: List) : List = (l1 match { - case Nil() => l2 - case Cons(x, xs) => reverse0(xs, Cons(x, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - def append(l1 : List, l2 : List) : List = (l1 match { - case Nil() => l2 - case Cons(x,xs) => Cons(x, append(xs, l2)) - }) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def nilAppend(l : List) : Boolean = (append(l, Nil()) == l).holds - - @induct - def appendAssoc(xs : List, ys : List, zs : List) : Boolean = - (append(append(xs, ys), zs) == append(xs, append(ys, zs))).holds - - @induct - def sizeAppend(l1 : List, l2 : List) : Boolean = - (size(append(l1, l2)) == size(l1) + size(l2)).holds - - @induct - def concat(l1: List, l2: List) : List = - concat0(l1, l2, Nil()) ensuring(content(_) == content(l1) ++ content(l2)) - - @induct - def concat0(l1: List, l2: List, l3: List) : List = (l1 match { - case Nil() => l2 match { - case Nil() => reverse(l3) - case Cons(y, ys) => { - concat0(Nil(), ys, Cons(y, l3)) - } - } - case Cons(x, xs) => concat0(xs, l2, Cons(x, l3)) - }) ensuring(content(_) == content(l1) ++ content(l2) ++ content(l3)) -} diff --git a/src/test/resources/regression/verification/purescala/valid/Lists1.scala b/src/test/resources/regression/verification/purescala/valid/Lists1.scala deleted file mode 100644 index c946a4823151c9371a4c353b01e256e33d484593..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Lists1.scala +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.proof._ -import leon.collection._ -import leon.annotation._ - -object Lists1 { - - def exists[T](list: List[T], f: T => Boolean): Boolean = list match { - case Cons(head, tail) => f(head) || exists(tail, f) - case Nil() => false - } - - def forall[T](list: List[T], f: T => Boolean): Boolean = list match { - case Cons(head, tail) => f(head) && forall(tail, f) - case Nil() => true - } - - def exists_lemma[T](list: List[T], f: T => Boolean): Boolean = { - exists(list, f) == !forall(list, (x: T) => !f(x)) - } - - def exists_lemma_induct[T](list: List[T], f: T => Boolean): Boolean = { - exists_lemma(list, f) because (list match { - case Nil() => true - case Cons(head, tail) => exists_lemma_induct(tail, f) - }) - }.holds - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Lists2.scala b/src/test/resources/regression/verification/purescala/valid/Lists2.scala deleted file mode 100644 index 4edd2d1e1ec473cbec3ba5629bc59063fd485d67..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Lists2.scala +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.proof._ - -object Lists2 { - abstract class List[T] - case class Cons[T](head: T, tail: List[T]) extends List[T] - case class Nil[T]() extends List[T] - - def forall[T](list: List[T], f: T => Boolean): Boolean = list match { - case Cons(head, tail) => f(head) && forall(tail, f) - case Nil() => true - } - - def positive(list: List[Int]): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def positive_lemma(list: List[Int]): Boolean = { - positive(list) == forall(list, (x: Int) => x >= 0) - } - - def positive_lemma_induct(list: List[Int]): Boolean = { - positive_lemma(list) because (list match { - case Nil() => true - case Cons(head, tail) => positive_lemma_induct(tail) - }) - }.holds - - def remove[T](list: List[T], e: T) : List[T] = { - list match { - case Nil() => Nil() - case Cons(x, xs) if x == e => remove(xs, e) - case Cons(x, xs) => Cons(x, remove(xs, e)) - } - } //ensuring { (res: List[T]) => forall(res, (x : T) => x != e) } - - def remove_lemma[T](list: List[T], e: T): Boolean = { - forall(remove(list, e), (x : T) => x != e) - } - - def remove_lemma_induct[T](list: List[T], e: T): Boolean = { - remove_lemma(list, e) because (list match { - case Nil() => true - case Cons(head, tail) => remove_lemma_induct(tail, e) - }) - }.holds -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Lists3.scala b/src/test/resources/regression/verification/purescala/valid/Lists3.scala deleted file mode 100644 index 01fe747dff8b29c200c9bf84f152c62fa4d7d5f5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Lists3.scala +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.proof._ - -object Lists3 { - abstract class List[T] - case class Cons[T](head: T, tail: List[T]) extends List[T] - case class Nil[T]() extends List[T] - - def forall[T](list: List[T], f: T => Boolean): Boolean = list match { - case Cons(head, tail) => f(head) && forall(tail, f) - case Nil() => true - } - - def positive(list: List[Int]): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def gt(i: Int): Int => Boolean = x => x > i - - def gte(i: Int): Int => Boolean = x => gt(i)(x) || x == i - - def positive_lemma(list: List[Int]): Boolean = { - positive(list) == forall(list, gte(0)) - } - - def positive_lemma_induct(list: List[Int]): Boolean = { - positive_lemma(list) because (list match { - case Nil() => true - case Cons(head, tail) => positive_lemma_induct(tail) - }) - }.holds -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Lists4.scala b/src/test/resources/regression/verification/purescala/valid/Lists4.scala deleted file mode 100644 index 1afde3867a14b3f766be00597db2e6f15a4f15dd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Lists4.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.proof._ - -object Lists4 { - abstract class List[T] - case class Cons[T](head: T, tail: List[T]) extends List[T] - case class Nil[T]() extends List[T] - - def map[F,T](list: List[F], f: F => T): List[T] = list match { - case Cons(head, tail) => Cons(f(head), map(tail, f)) - case Nil() => Nil() - } - - def map_lemma[A,B,C](list: List[A], f: A => B, g: B => C): Boolean = { - map(list, (x: A) => g(f(x))) == map(map(list, f), g) - } - - def map_lemma_induct[D,E,F](list: List[D], f: D => E, g: E => F): Boolean = { - map_lemma(list, f, g) because (list match { - case Nil() => true - case Cons(head, tail) => map_lemma_induct(tail, f, g) - }) - }.holds - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Lists5.scala b/src/test/resources/regression/verification/purescala/valid/Lists5.scala deleted file mode 100644 index 627fdb9ed3ef0a1bde9886e9de849df0da0d98bc..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Lists5.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.proof._ -import leon.collection._ - -object Lists5 { - abstract class Option[T] - case class Some[T](value: T) extends Option[T] - case class None[T]() extends Option[T] - - def find[T](f: T => Boolean, list: List[T]): Option[T] = list match { - case Cons(head, tail) => if (f(head)) Some(head) else find(f, tail) - case Nil() => None() - } - - def exists[T](f: T => Boolean, list: List[T]): Boolean = list match { - case Cons(head, tail) => f(head) || exists(f, tail) - case Nil() => false - } - - def equivalence_lemma[T](f: T => Boolean, list: List[T]): Boolean = { - find(f, list) match { - case Some(e) => exists(f, list) - case None() => !exists(f, list) - } - } - - def equivalence_lemma_induct[T](f: T => Boolean, list: List[T]): Boolean = { - equivalence_lemma(f, list) because (list match { - case Cons(head, tail) => equivalence_lemma_induct(f, tail) - case Nil() => true - }) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Lists6.scala b/src/test/resources/regression/verification/purescala/valid/Lists6.scala deleted file mode 100644 index 13bd154b5fc69c2347d8b2b57052f26f97d88662..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Lists6.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.proof._ -import leon.collection._ - -object Lists6 { - def exists[T](list: List[T], f: T => Boolean): Boolean = { - list match { - case Cons(head, tail) => f(head) || exists(tail, f) - case Nil() => false - } - } - - def associative_lemma[T](list: List[T], f: T => Boolean, g: T => Boolean): Boolean = { - exists(list, (x: T) => f(x) || g(x)) == (exists(list, f) || exists(list, g)) - } - - def associative_lemma_induct[T](list: List[T], f: T => Boolean, g: T => Boolean): Boolean = { - associative_lemma(list, f, g) because (list match { - case Cons(head, tail) => associative_lemma_induct(tail, f, g) - case Nil() => true - }) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/LiteralMaps.scala b/src/test/resources/regression/verification/purescala/valid/LiteralMaps.scala deleted file mode 100644 index 6f03046d117c651ca00fd40dea64d46a15746f77..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/LiteralMaps.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object LiteralMaps { - def test(): Map[Int, Int] = { - Map(1 -> 2, 3 -> 4, (5, 6)) - } - - def test2(): (Int, Int) = { - 1 -> 2 - } - - def test3(): Map[Int, Int] = { - Map[Int, Int]() - } - - def test4(): Map[Int, Int] = { - Map.empty[Int, Int] - } - - def test5(): Map[Int, Int] = { - Map.empty[Int, Int] - } -} diff --git a/src/test/resources/regression/verification/purescala/valid/MapGetOrElse2.scala b/src/test/resources/regression/verification/purescala/valid/MapGetOrElse2.scala deleted file mode 100644 index 737432e7bdfe608e7065f9bb2589a422521321c0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MapGetOrElse2.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object MapGetOrElse2 { - def test1(a: Map[BigInt, BigInt]) = { - require(!(a contains 0)) - a.get(0) - } ensuring { - _ == None[BigInt]() - } - - def test2(a: Map[BigInt, BigInt]) = { - require(!(a contains 0)) - a.getOrElse(0, 0) - } ensuring { - _ == 0 - } -} diff --git a/src/test/resources/regression/verification/purescala/valid/MapGetPlus.scala b/src/test/resources/regression/verification/purescala/valid/MapGetPlus.scala deleted file mode 100644 index 79a1a287ca839e82ad75e5651f78b91f9dbcc11d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MapGetPlus.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object MapGetPlus { - def test1(a: Map[BigInt, BigInt]) = { - require(!(a contains 0)) - val b = a + (0, 1) - val c = a + (BigInt(0) -> BigInt(1)) - b(0) == c(0) - }.holds - - def test2(a: Map[BigInt, BigInt]) = { - require(!(a contains 0)) - val t = (BigInt(0) -> BigInt(1)) - val b = a + (0, 1) - val c = a + t - b(0) == c(0) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/MatchExh.scala b/src/test/resources/regression/verification/purescala/valid/MatchExh.scala deleted file mode 100644 index e05c97de96670365bc36e342429f0daaf1282590..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MatchExh.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ - -object MatchExh { - - def exh1(i: Int) = i match { - case 1 => 2 - case 0 => 2 - case _ => 2 - } - - def exh2[A](l: List[A]) = l match { - case Nil() => 0 - case Cons(a, Nil()) => 1 - case Cons(a, _) => 2 - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Mean.scala b/src/test/resources/regression/verification/purescala/valid/Mean.scala deleted file mode 100644 index 9bdce687eec24155a127c2ef12018833c5fcb648..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Mean.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Mean { - - def mean(x: Int, y: Int): Int = { - require(x <= y && x >= 0 && y >= 0) - x + (y - x)/2 - } ensuring(m => m >= x && m <= y) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/MergeSort.scala b/src/test/resources/regression/verification/purescala/valid/MergeSort.scala deleted file mode 100644 index 5ebcc74cb5af4e42a6f034fa2c174e371bdc4e33..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MergeSort.scala +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object MergeSort { - // Data types - sealed abstract class List - case class Cons(head : Int, tail : List) extends List - case class Nil() extends List - - sealed abstract class LList - case class LCons(head : List, tail : LList) extends LList - case class LNil() extends LList - - def content(list : List) : Set[Int] = list match { - case Nil() => Set.empty[Int] - case Cons(x, xs) => Set(x) ++ content(xs) - } - - def lContent(llist : LList) : Set[Int] = llist match { - case LNil() => Set.empty[Int] - case LCons(x, xs) => content(x) ++ lContent(xs) - } - - def size(list : List) : BigInt = (list match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def isSorted(list : List) : Boolean = list match { - case Nil() => true - case Cons(_, Nil()) => true - case Cons(x1, Cons(x2, _)) if(x1 > x2) => false - case Cons(_, xs) => isSorted(xs) - } - - def lIsSorted(llist : LList) : Boolean = llist match { - case LNil() => true - case LCons(x, xs) => isSorted(x) && lIsSorted(xs) - } - - def abs(i : BigInt) : BigInt = { - if(i < 0) -i else i - } ensuring(_ >= 0) - - def mergeSpec(list1 : List, list2 : List, res : List) : Boolean = { - isSorted(res) && content(res) == content(list1) ++ content(list2) - } - - def mergeFast(list1 : List, list2 : List) : List = { - require(isSorted(list1) && isSorted(list2)) - - (list1, list2) match { - case (_, Nil()) => list1 - case (Nil(), _) => list2 - case (Cons(x, xs), Cons(y, ys)) => - if(x <= y) { - Cons(x, mergeFast(xs, list2)) - } else { - Cons(y, mergeFast(list1, ys)) - } - } - } ensuring(res => mergeSpec(list1, list2, res)) - - def splitSpec(list : List, res : (List,List)) : Boolean = { - val s1 = size(res._1) - val s2 = size(res._2) - abs(s1 - s2) <= 1 && s1 + s2 == size(list) && - content(res._1) ++ content(res._2) == content(list) - } - - def split(list : List) : (List,List) = (list match { - case Nil() => (Nil(), Nil()) - case Cons(x, Nil()) => (Cons(x, Nil()), Nil()) - case Cons(x1, Cons(x2, xs)) => - val (s1,s2) = split(xs) - (Cons(x1, s1), Cons(x2, s2)) - }) ensuring(res => splitSpec(list, res)) - - def sortSpec(in : List, out : List) : Boolean = { - content(out) == content(in) && isSorted(out) - } - - // Not really quicksort, neither mergesort. - // Note: the `s` argument is just a witness for termination (always decreases), - // and not needed for functionality. Any decent optimizer will remove it ;-) - def weirdSort(s: BigInt, in : List) : List = { - require(s == size(in)) - in match { - case Nil() => Nil() - case Cons(x, Nil()) => Cons(x, Nil()) - case _ => - val (s1,s2) = split(in) - mergeFast(weirdSort(size(s1), s1), weirdSort(size(s2), s2)) - } - } ensuring(res => sortSpec(in, res)) - - def toLList(list : List) : LList = (list match { - case Nil() => LNil() - case Cons(x, xs) => LCons(Cons(x, Nil()), toLList(xs)) - }) ensuring(res => lContent(res) == content(list) && lIsSorted(res)) - - def mergeMap(llist : LList) : LList = { - require(lIsSorted(llist)) - - llist match { - case LNil() => LNil() - case o @ LCons(x, LNil()) => o - case LCons(x, LCons(y, ys)) => LCons(mergeFast(x, y), mergeMap(ys)) - } - } ensuring(res => lContent(res) == lContent(llist) && lIsSorted(res)) - - def mergeReduce(llist : LList) : List = { - require(lIsSorted(llist)) - - llist match { - case LNil() => Nil() - case LCons(x, LNil()) => x - case _ => mergeReduce(mergeMap(llist)) - } - } ensuring(res => content(res) == lContent(llist) && isSorted(res)) - - def mergeSort(in : List) : List = { - mergeReduce(toLList(in)) - } ensuring(res => sortSpec(in, res)) -} diff --git a/src/test/resources/regression/verification/purescala/valid/MergeSort2.scala b/src/test/resources/regression/verification/purescala/valid/MergeSort2.scala deleted file mode 100644 index 0bd0ab35ecaef991f618c0938f8446051eabf00e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MergeSort2.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.collection._ -import leon.lang._ - -object MergeSort2 { - - def bag[T](list: List[T]): Bag[T] = list match { - case Nil() => Bag.empty[T] - case Cons(x, xs) => bag(xs) + x - } - - def isSorted(list: List[BigInt]): Boolean = list match { - case Cons(x1, tail @ Cons(x2, _)) => x1 <= x2 && isSorted(tail) - case _ => true - } - - def merge(l1: List[BigInt], l2: List[BigInt]): List[BigInt] = { - require(isSorted(l1) && isSorted(l2)) - - (l1, l2) match { - case (Cons(x, xs), Cons(y, ys)) => - if (x <= y) Cons(x, merge(xs, l2)) - else Cons(y, merge(l1, ys)) - case _ => l1 ++ l2 - } - } ensuring (res => isSorted(res) && bag(res) == bag(l1) ++ bag(l2)) - - def split(list: List[BigInt]): (List[BigInt], List[BigInt]) = (list match { - case Cons(x1, Cons(x2, xs)) => - val (s1, s2) = split(xs) - (Cons(x1, s1), Cons(x2, s2)) - case _ => (list, Nil[BigInt]()) - }) ensuring (res => bag(res._1) ++ bag(res._2) == bag(list)) - - def mergeSort(list: List[BigInt]): List[BigInt] = (list match { - case Cons(_, Cons(_, _)) => - val (s1, s2) = split(list) - merge(mergeSort(s1), mergeSort(s2)) - case _ => list - }) ensuring (res => isSorted(res) && bag(res) == bag(list)) -} diff --git a/src/test/resources/regression/verification/purescala/valid/Methods.scala b/src/test/resources/regression/verification/purescala/valid/Methods.scala deleted file mode 100644 index a2dac3cf4709c7ca5848a9fe1303a89b7de4a507..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Methods.scala +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Methods { - abstract class A - - abstract class B extends A { - def foo(i: BigInt) = { - require(i > 0) - i + 1 - } ensuring ( _ >= 0 ) - } - - case class C(x: BigInt) extends B { - val y = BigInt(42) - override def foo(i: BigInt) = { - x + y + (if (i>0) i else -i) - } ensuring ( _ >= x ) - } - - case class E() extends B - - case class D() extends A - - def f1 = { - val c = C(42) - (if (c.foo(0) + c.x > 0) c else D()).isInstanceOf[B] - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Monads1.scala b/src/test/resources/regression/verification/purescala/valid/Monads1.scala deleted file mode 100644 index bfaee154a03a13dbb91518a7a54b4ddb7603b863..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Monads1.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Monads1 { - abstract class Try[T] - case class Success[T](value: T) extends Try[T] - case class Failure[T](error: Int) extends Try[T] - - def flatMap[T,U](t: Try[T], f: T => Try[U]): Try[U] = t match { - case Success(value) => f(value) - case fail @ Failure(error) => Failure(error) - } - - def associative_law[T,U,V](t: Try[T], f: T => Try[U], g: U => Try[V]): Boolean = { - flatMap(flatMap(t, f), g) == flatMap(t, (x: T) => flatMap(f(x), g)) - }.holds - - def left_unit_law[T,U](x: T, f: T => Try[U]): Boolean = { - flatMap(Success(x), f) == f(x) - }.holds - - def right_unit_law[T,U](t: Try[T]): Boolean = { - flatMap(t, (x: T) => Success(x)) == t - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Monads2.scala b/src/test/resources/regression/verification/purescala/valid/Monads2.scala deleted file mode 100644 index 5d344032c38b223c7b4eb8388db6a9c526b15635..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Monads2.scala +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Monads2 { - abstract class Option[T] - case class Some[T](t: T) extends Option[T] - case class None[T]() extends Option[T] - - def flatMap[T,U](opt: Option[T], f: T => Option[U]): Option[U] = opt match { - case Some(x) => f(x) - case None() => None() - } - - def add[T](o1: Option[T], o2: Option[T]): Option[T] = o1 match { - case Some(x) => o1 - case None() => o2 - } - - def associative_law[T,U,V](opt: Option[T], f: T => Option[U], g: U => Option[V]): Boolean = { - flatMap(flatMap(opt, f), g) == flatMap(opt, (x: T) => flatMap(f(x), g)) - }.holds - - def left_unit_law[T,U](x: T, f: T => Option[U]): Boolean = { - flatMap(Some(x), f) == f(x) - }.holds - - def right_unit_law[T,U](opt: Option[T]): Boolean = { - flatMap(opt, (x: T) => Some(x)) == opt - }.holds - - def flatMap_zero_law[T,U](none: None[T], f: T => Option[U]): Boolean = { - flatMap(none, f) == None[U]() - }.holds - - def flatMap_to_zero_law[T,U](opt: Option[T]): Boolean = { - flatMap(opt, (x: T) => None[U]()) == None[U]() - }.holds - - def add_zero_law[T](opt: Option[T]): Boolean = { - add(opt, None[T]()) == opt - }.holds - - def zero_add_law[T](opt: Option[T]): Boolean = { - add(None[T](), opt) == opt - }.holds -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Monads3.scala b/src/test/resources/regression/verification/purescala/valid/Monads3.scala deleted file mode 100644 index 0f0e3c914b78f2762b6e098327e539f4a6a03602..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Monads3.scala +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.proof._ -import leon.collection._ - -object Monads3 { - - def append[T](l1: List[T], l2: List[T]): List[T] = { - l1 match { - case Cons(head, tail) => Cons(head, append(tail, l2)) - case Nil() => l2 - } - } ensuring { res => (res == l1) || (l2 != Nil[T]()) } - - def flatMap[T,U](list: List[T], f: T => List[U]): List[U] = list match { - case Cons(head, tail) => append(f(head), flatMap(tail, f)) - case Nil() => Nil() - } - - def associative_lemma[T,U,V](list: List[T], f: T => List[U], g: U => List[V]): Boolean = { - flatMap(flatMap(list, f), g) == flatMap(list, (x: T) => flatMap(f(x), g)) - } - - def associative_lemma_induct[T,U,V](list: List[T], flist: List[U], glist: List[V], f: T => List[U], g: U => List[V]): Boolean = { - associative_lemma(list, f, g) because { - append(glist, flatMap(append(flist, flatMap(list, f)), g)) == append(append(glist, flatMap(flist, g)), flatMap(list, (x: T) => flatMap(f(x), g))) because - (glist match { - case Cons(ghead, gtail) => - associative_lemma_induct(list, flist, gtail, f, g) - case Nil() => flist match { - case Cons(fhead, ftail) => - associative_lemma_induct(list, ftail, g(fhead), f, g) - case Nil() => list match { - case Cons(head, tail) => associative_lemma_induct(tail, f(head), Nil(), f, g) - case Nil() => true - } - } - }) - } - }.holds - - def left_unit_law[T,U](x: T, f: T => List[U]): Boolean = { - flatMap(Cons(x, Nil()), f) == f(x) - }.holds - - def right_unit_law[T](list: List[T]): Boolean = { - flatMap(list, (x: T) => Cons(x, Nil())) == list - } - - def right_unit_induct[T,U](list: List[T]): Boolean = { - right_unit_law(list) because (list match { - case Cons(head, tail) => right_unit_induct(tail) - case Nil() => true - }) - }.holds - - def flatMap_zero_law[T,U](f: T => List[U]): Boolean = { - flatMap(Nil[T](), f) == Nil[U]() - }.holds - - def flatMap_to_zero_law[T](list: List[T]): Boolean = { - flatMap(list, (x: T) => Nil[T]()) == Nil[T]() - } - - def flatMap_to_zero_induct[T,U](list: List[T]): Boolean = { - flatMap_to_zero_law(list) because (list match { - case Cons(head, tail) => flatMap_to_zero_induct(tail) - case Nil() => true - }) - }.holds - - def add_zero_law[T](list: List[T]): Boolean = { - append(list, Nil()) == list - }.holds - - def zero_add_law[T](list: List[T]): Boolean = { - append(Nil(), list) == list - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Monotonic.scala b/src/test/resources/regression/verification/purescala/valid/Monotonic.scala deleted file mode 100644 index 6a07df7d6ff35d264a85e564c41d5037f9f5fd44..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Monotonic.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Monotonic { - def composeMonotonic(f: BigInt => BigInt, g: BigInt => BigInt): BigInt => BigInt = { - require(forall((a: BigInt, b: BigInt) => (a > b ==> f(a) > f(b)) && (a > b ==> g(a) > g(b)))) - (x: BigInt) => f(g(x)) - } ensuring { res => forall((a: BigInt, b: BigInt) => a > b ==> res(a) > res(b)) } -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/MyMap.scala b/src/test/resources/regression/verification/purescala/valid/MyMap.scala deleted file mode 100644 index f9b88ef2419cb481ee0408baa6ccbd1786b30676..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MyMap.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object MyMap { - - def map1(): Int = { - val m = Map(1 -> 2, 2 -> 3, 3 -> 4) - m(2) - } ensuring(_ == 3) - - // Empty maps are not well supported in CVC4, because of lack of quantifiers - //def map2(): Boolean = { - // val m1 = Map[Int, Int]() - // val m2 = Map.empty[Int, Int] - // m1 == m2 - //}.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/MySet.scala b/src/test/resources/regression/verification/purescala/valid/MySet.scala deleted file mode 100644 index 13efa589eba329e820726b7b8a0ba9f42907358c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MySet.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object MySet { - - def set1(): Boolean = { - val s = Set(1, 2, 3, 4) - s.contains(3) - }.holds - - def set2(): Boolean = { - val s1 = Set[Int]() - val s2 = Set.empty[Int] - s1 == s2 - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/MyTuple1.scala b/src/test/resources/regression/verification/purescala/valid/MyTuple1.scala deleted file mode 100644 index 55ba48e8e56c4a2b755d759851bb88568a87f0eb..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MyTuple1.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple1 { - - def foo(): Int = { - val t = (1, true, 3) - val a1 = t._1 - val a2 = t._2 - val a3 = t._3 - a3 - } ensuring( _ == 3) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/MyTuple2.scala b/src/test/resources/regression/verification/purescala/valid/MyTuple2.scala deleted file mode 100644 index 8683adcdeeee636ed68e4e13f5d164f09c60688c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MyTuple2.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple2 { - - abstract class A - case class B(i: Int) extends A - case class C(a: A) extends A - - def foo(): Int = { - val t = (B(2), C(B(3))) - t match { - case (B(x), C(y)) => x - } - } ensuring(_ == 2) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/MyTuple3.scala b/src/test/resources/regression/verification/purescala/valid/MyTuple3.scala deleted file mode 100644 index db4f82411b9e62b3a3a34cc57347a9b2c83247dd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MyTuple3.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple3 { - - def foo(): Int = { - val t = ((2, 3), true) - t._1._2 - } ensuring( _ == 3) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/MyTuple4.scala b/src/test/resources/regression/verification/purescala/valid/MyTuple4.scala deleted file mode 100644 index 6dd4d3c1c6e04d7662de02a0d956fdc7d95b9547..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MyTuple4.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -object MyTuple4 { - - abstract class A - case class B(i: Int) extends A - case class C(a: A) extends A - - def foo(): Int = { - val t = (1, (C(B(4)), 2), 3) - val (a1, (C(B(x)), a2), a3) = t - x - } ensuring( _ == 4) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/MyTuple5.scala b/src/test/resources/regression/verification/purescala/valid/MyTuple5.scala deleted file mode 100644 index d8fff88781251281e0c56c494a7f8e4d9b81bd5b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MyTuple5.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple5 { - - abstract class A - case class B(t: (Int, Int)) extends A - case class C(a: A) extends A - - def foo(): Int = { - val t: (Int, (A, Int), Int) = (1, (C(B((4, 5))), 2), 3) - t match { - case (_, (B((x, y)), _), _) => x - case (_, (C(B((_, x))), _), y) => x - case (_, _, x) => x - } - } ensuring( _ == 5) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/MyTuple6.scala b/src/test/resources/regression/verification/purescala/valid/MyTuple6.scala deleted file mode 100644 index f8cc1b42393ae8bdb66f92b22061bff99c5a2cc2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/MyTuple6.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object MyTuple6 { - - def foo(t: (Int, Int)): (Int, Int) = { - require(t._1 > 0 && t._2 > 1) - t - } ensuring(res => res._1 > 0 && res._2 > 1) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nat.scala b/src/test/resources/regression/verification/purescala/valid/Nat.scala deleted file mode 100644 index 41b58248fe768b0498443806eab2e9616bf68c0b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nat.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Nat { - sealed abstract class Nat - case class Zero() extends Nat - case class Succ(num: Nat) extends Nat - - def plus(a: Nat, b: Nat): Nat = a match { - case Zero() => b - case Succ(a1) => Succ(plus(a1, b)) - } - - def nat2Int(n: Nat): Int = n match { - case Zero() => 0 - case Succ(n1) => 1 + nat2Int(n1) - } - - def int2Nat(n: Int): Nat = { - require(n >= 0) - if (n == 0) Zero() else Succ(int2Nat(n-1)) - } - - def sum_lemma(): Boolean = { - 3 == nat2Int(plus(int2Nat(1), int2Nat(2))) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested1.scala b/src/test/resources/regression/verification/purescala/valid/Nested1.scala deleted file mode 100644 index 165e42474eeb6f91ec83a285d6d59af89f91ba09..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested1.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested1 { - - def foo(i: Int): Int = { - val n = i - def rec1(j: Int) = i + j + n - def rec2(j: Int) = { - def rec3(k: Int) = k + j + i - rec3(5) - } - rec2(2) - } ensuring(i + 7 == _) - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Nested10.scala b/src/test/resources/regression/verification/purescala/valid/Nested10.scala deleted file mode 100644 index d129c5313559a83ea5f730312c917afac040fac8..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested10.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested10 { - - def foo(i: Int): Int = { - val n = 2 - def rec1(j: Int) = { - i + j + n - } - def rec2(j: Int) = { - rec1(j) - } - rec2(2) - } ensuring(i + 4 == _) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested11.scala b/src/test/resources/regression/verification/purescala/valid/Nested11.scala deleted file mode 100644 index 3982c342357df366a20502e58c71fd128ad2cc11..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested11.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested11 { - - abstract class A - case class B(b: Int) extends A - - def foo(i: Int): Int = { - val b: A = B(3) - def rec1(j: Int) = b match { - case B(b) => i + j + b - } - rec1(2) - } ensuring(i + 5 == _) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested12.scala b/src/test/resources/regression/verification/purescala/valid/Nested12.scala deleted file mode 100644 index 2961a5b4ca88fba570ce9b82648a5e0a53a36df0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested12.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested12 { - - abstract class A - case class B(b: Int) extends A - - def foo(i: Int): Int = { - val b: A = B(3) - def rec1(a: A, j: Int, j2: Int) = a match { - case B(b) => i + j + j2 + b - } - def rec2(a: A, k: Int) = a match { - case B(b) => rec1(a, b, k) - } - rec2(b, 2) - } ensuring(i + 8 == _) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested13.scala b/src/test/resources/regression/verification/purescala/valid/Nested13.scala deleted file mode 100644 index f4dc50e44b2def6bffe2350f26416ff49636db7a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested13.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested13 { - - abstract class D - case class E(e: Int) extends D - case class F(d: D, f: Int) extends D - - def foo(a : Int): Int = { - - def rec1(d: D, j: Int): Int = d match { - case E(e) => j + e + a - case F(dNext, f) => f + rec1(dNext, j) - } - - def rec2(d: D, i : Int) : Int = d match { - case E(e) => e - case F(dNext, f) => rec1(d, i) - } - - rec2(F(E(2), 3), 0) - } ensuring(a + 5 == _) -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested14.scala b/src/test/resources/regression/verification/purescala/valid/Nested14.scala deleted file mode 100644 index 39e668aa208f1eeefd8257b359b3b5a5be51b39f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested14.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested14 { - - def foo(i: Int): Int = { - def rec1(j: Int): Int = { - require(j >= 0) - def rec2(k: Int): Int = { - require(j > 0 || j == k) - if(k == 0) 0 else rec1(j-1) - } - rec2(j) - } - rec1(3) - } ensuring(0 == _) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested15.scala b/src/test/resources/regression/verification/purescala/valid/Nested15.scala deleted file mode 100644 index 4ece21eaf45b35c0d37ef525f645a988576c6177..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested15.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.collection._ - -object Nested15 { - - def foo[A](i: List[A]): BigInt = { - val n = i - def rec1[B](j: List[B]) = j ++ j - def rec2[C](l: List[C], j: BigInt) = { - require(l.nonEmpty) - def rec3(k: C) = k :: rec1[C](l) - rec3(l.head).size + j + n.size + i.size - } - rec2(List(1, 2, 3), 2) - } ensuring(_ == 2 * i.size + 9) - -} - diff --git a/src/test/resources/regression/verification/purescala/valid/Nested16.scala b/src/test/resources/regression/verification/purescala/valid/Nested16.scala deleted file mode 100644 index 411e4a27f0fb918eba1cd5b8d31131f734d0142b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested16.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested16 { - - def foo(i: BigInt): BigInt = { - def rec1(j: BigInt): BigInt = { - require(j >= 0) - def rec2(k: BigInt): BigInt = { - require(j > 0 || j == k) - if(k == 0) 0 else rec1(j-1) - } - rec2(j) - } - rec1(3) - } ensuring(0 == _) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested17.scala b/src/test/resources/regression/verification/purescala/valid/Nested17.scala deleted file mode 100644 index 70eb6e252f8c4a09cf1de0d545d64bbb94cf4e6e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested17.scala +++ /dev/null @@ -1,23 +0,0 @@ -package test.resources.regression.verification.purescala.valid - -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested17 { - - def test(y: Int) = { - - def g() = y - - //this will be in the path condition of h with a function call to g - val b = g() - - //the tricky part is to capture the free variables of g since the - //path condition contains a function invocation to g - def h(): Unit = { - () - } ensuring(res => true) - - h() - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested18.scala b/src/test/resources/regression/verification/purescala/valid/Nested18.scala deleted file mode 100644 index a35c2f4b9722ee9e663637d9d26f40570623ed94..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested18.scala +++ /dev/null @@ -1,15 +0,0 @@ -object Nested18 { - - def test(a: BigInt): BigInt = { - require(a > 0) - def f(b: BigInt): BigInt = { - def g(c: BigInt): BigInt = { - require(a > 0) - c - } - g(b) - } - f(12) - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested2.scala b/src/test/resources/regression/verification/purescala/valid/Nested2.scala deleted file mode 100644 index 7b70916c4e330433cc8edd2d14041baebca4baac..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested2.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested2 { - - def foo(a: BigInt): BigInt = { - require(a >= 0) - val b = a + 2 - def rec1(c: BigInt): BigInt = { - require(c >= 0) - b + c - } - rec1(2) - } ensuring(_ > 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested3.scala b/src/test/resources/regression/verification/purescala/valid/Nested3.scala deleted file mode 100644 index 28ff445f84622f3dd619545296190f7b8bc05f06..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested3.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested3 { - - def foo(a: BigInt): BigInt = { - require(a >= 0 && a <= 50) - val b = a + 2 - val c = a + b - def rec1(d: BigInt): BigInt = { - require(d >= 0 && d <= 50) - val e = d + b + c - e - } - rec1(2) - } ensuring(_ > 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested4.scala b/src/test/resources/regression/verification/purescala/valid/Nested4.scala deleted file mode 100644 index 397dd7484c3fc05feeaf024ee500360e88841088..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested4.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested4 { - - def foo(a: BigInt, a2: BigInt): BigInt = { - require(a >= 0 && a <= 50) - val b = a + 2 - val c = a + b - if(a2 > a) { - def rec1(d: BigInt): BigInt = { - require(d >= 0 && d <= 50) - val e = d + b + c + a2 - e - } ensuring(_ > 0) - rec1(2) - } else { - BigInt(5) - } - } ensuring(x => x > 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested5.scala b/src/test/resources/regression/verification/purescala/valid/Nested5.scala deleted file mode 100644 index 736c0f6bf7fb3932e8531e7eca1e4777ea450a89..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested5.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested5 { - - def foo(a: Int): Int = { - require(a >= 0) - def bar(b: Int): Int = { - require(b > 0) - b + 3 - } ensuring(a >= 0 && _ == b + 3) - bar(2) - } ensuring(a >= 0 && _ == 5) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested6.scala b/src/test/resources/regression/verification/purescala/valid/Nested6.scala deleted file mode 100644 index 6d6df90a40251625459f79efa7e9a5fa31493790..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested6.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested6 { - - def foo(a: BigInt): BigInt = { - require(a >= 0) - def bar(b: BigInt): BigInt = { - require(b > 0) - b + 3 - } ensuring(prop(a, b) && a >= 0 && _ == b + 3) - bar(2) - } ensuring(a >= 0 && _ == BigInt(5)) - - def prop(x: BigInt, y: BigInt): Boolean = x + y > 0 - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested7.scala b/src/test/resources/regression/verification/purescala/valid/Nested7.scala deleted file mode 100644 index b9e986311ced8eba6b505e449d1ffaaab49be016..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested7.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested7 { - - def foo(a: BigInt): BigInt = { - require(a >= 0) - val b = a + 2 - def rec1(c: BigInt): BigInt = { - require(c >= 0) - b + c + bar(a) + bar(b) + bar(c) - } - rec1(2) + bar(a) - } ensuring(_ > 0) - - - def bar(x: BigInt): BigInt = { - require(x >= 0) - x - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested8.scala b/src/test/resources/regression/verification/purescala/valid/Nested8.scala deleted file mode 100644 index 67c81f414d9a8a95443c2b0e6cc01049a9e9e4c0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested8.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Nested8 { - - def foo(a: BigInt): BigInt = { - require(a > 0) - - def bar(b: BigInt): BigInt = { - if(a < b) { - def rec(c: BigInt): BigInt = { - require(c > 0) - c + b - } ensuring(_ > 0) - rec(2) - } else 3 - } - bar(1) - } ensuring(_ > 0) - - /* - def partitioned(a: Map[Int, Int], size: Int, l1: Int, u1: Int, l2: Int, u2: Int): Boolean = { - require(l1 >= 0 && u1 < l2 && u2 < size) - if(l2 > u2 || l1 > u1) - true - else { - var i = l1 - var j = l2 - var isPartitionned = true - (while(i <= u1) { - j = l2 - (while(j <= u2) { - if(a(i) > a(j)) - isPartitionned = false - j = j + 1 - }) invariant(j >= l2 && i <= u1) - i = i + 1 - }) invariant(i >= l1) - isPartitionned - } - } - */ - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Nested9.scala b/src/test/resources/regression/verification/purescala/valid/Nested9.scala deleted file mode 100644 index ae029ad6804015161a952998a7700d5fd39e6d89..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Nested9.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Nested9 { - - def foo(a: BigInt, a2: BigInt): BigInt = { - require(a >= 0 && a <= 50) - val b = a + 2 - val c = a + b - if(a2 > a) { - def rec1(d: BigInt): BigInt = { - require(d >= 0 && d <= 50) - val e = d + b + c + a2 - def rec2(f: BigInt): BigInt = { - require(f >= c) - f + e - } ensuring(_ > 0) - rec2(c+1) - } ensuring(_ > 0) - rec1(2) - } else { - BigInt(5) - } - } ensuring(_ > 0) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/NotEquals.scala b/src/test/resources/regression/verification/purescala/valid/NotEquals.scala deleted file mode 100644 index 31a4bc763600ac9a8e0b5d0cc4bec308cc110955..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/NotEquals.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object NotEquals { - - // Represents n/d - case class Q(n: BigInt, d: BigInt) - - def op(a: Q, b: Q) = { - require(isRational(a) && isRational(b)) - - Q(a.n + b.n, a.d) - } ensuring { - isRational(_) - } - - //def isRational(a: Q) = a.d != 0 - def isRational(a: Q) = a.d != 0 - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Overrides.scala b/src/test/resources/regression/verification/purescala/valid/Overrides.scala deleted file mode 100644 index 749fec7e04f03a76bdb8d806ac245cf3d26ead83..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Overrides.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Overrides { - abstract class A { - def x(a: Int): Int - } - - abstract class B extends A { - def x(a: Int) = { - require(a > 0) - 42 - } ensuring { _ >= 0 } - } - - case class C(c: Int) extends B { - override def x(i: Int) = { - require(i >= 0) - if (i == 0) 0 - else c + x(i-1) - } ensuring ( _ == c * i ) - } - - case class D() extends B -} diff --git a/src/test/resources/regression/verification/purescala/valid/ParBalance.scala b/src/test/resources/regression/verification/purescala/valid/ParBalance.scala deleted file mode 100644 index a1e5ea1edd578cfd59ddb81723acdb2fdb2d8dea..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/ParBalance.scala +++ /dev/null @@ -1,225 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon._ -import leon.lang._ -import leon.proof._ - -object ParBalance { - - sealed abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - sealed abstract class Option - case class Some(x: BigInt) extends Option - case class None() extends Option - - val openPar : BigInt = BigInt(1) - val closePar : BigInt = BigInt(2) - - def balanced(list: List, counter: BigInt): Boolean = { - if (counter < 0) false else list match { - case Cons(head, tail) => - val c = if (head == openPar) counter + 1 - else if (head == closePar) counter - 1 - else counter - balanced(tail, c) - case Nil() => counter == 0 - } - } - - def balanced_nonEarly(list: List, counter: BigInt): Boolean = { - list match { - case Cons(head, tail) => - if (counter < 0) balanced_nonEarly(tail, counter) else { - val c = if (head == openPar) counter + 1 - else if (head == closePar) counter - 1 - else counter - balanced_nonEarly(tail, c) - } - case Nil() => counter == 0 - } - } ensuring { res => res == balanced(list, counter) } - - def balanced_withFailure(list: List, counter: BigInt, failed: Boolean): Boolean = { - require(counter >= 0 || failed) - list match { - case Cons(head, tail) => - val c = if (head == openPar) counter + 1 - else if (head == closePar) counter - 1 - else counter - balanced_withFailure(tail, c, failed || c < 0) - case Nil() => !failed && counter == 0 - } - } ensuring { res => - if (failed) { - res == balanced_nonEarly(list, -1) - } else { - res == balanced_nonEarly(list, counter) - } - } - - def balanced_withReduce(list: List, p: (BigInt, BigInt)): Boolean = { - require(p._1 >= 0 && p._2 >= 0) - list match { - case Cons(head, tail) => - val p2 = reduce(p, parPair(head)) - balanced_withReduce(tail, p2) - case Nil() => - p._1 == 0 && p._2 == 0 - } - } ensuring { res => res == balanced_withFailure(list, p._1 - p._2, p._2 > 0) } - - def balanced_foldLeft_equivalence(list: List, p: (BigInt, BigInt)): Boolean = { - require(p._1 >= 0 && p._2 >= 0) - val f = (s: (BigInt, BigInt), x: BigInt) => reduce(s, parPair(x)) - (foldLeft(list, p, f) == (BigInt(0), BigInt(0))) == balanced_withReduce(list, p) because (list match { - case Cons(head, tail) => - val p2 = f(p, head) - balanced_foldLeft_equivalence(tail, p2) - case Nil() => true - }) - }.holds - - def foldRight[A](list: List, state: A, f: (BigInt, A) => A): A = list match { - case Cons(head, tail) => - val tailState = foldRight(tail, state, f) - f(head, tailState) - case Nil() => state - } - - def foldLeft[A](list: List, state: A, f: (A, BigInt) => A): A = list match { - case Cons(head, tail) => - val nextState = f(state, head) - foldLeft(tail, nextState, f) - case Nil() => state - } - - def reduce(p1: (BigInt, BigInt), p2: (BigInt, BigInt)): (BigInt, BigInt) = { - if (p1._1 >= p2._2) { - (p1._1 - p2._2 + p2._1, p1._2) - } else { - (p2._1, p2._2 - p1._1 + p1._2) - } - } - - def reduce_associative(p1: (BigInt, BigInt), p2: (BigInt, BigInt), p3: (BigInt, BigInt)): Boolean = { - reduce(p1, reduce(p2, p3)) == reduce(reduce(p1, p2), p3) - }.holds - - def swap(p: (BigInt, BigInt)): (BigInt, BigInt) = (p._2, p._1) - - def reduce_inverse(p1: (BigInt, BigInt), p2: (BigInt, BigInt)): Boolean = { - reduce(p1, p2) == swap(reduce(swap(p2), swap(p1))) - }.holds - - def reduce_associative_inverse(p1: (BigInt, BigInt), p2: (BigInt, BigInt), p3: (BigInt, BigInt)): Boolean = { - reduce(p1, reduce(p2, p3)) == swap(reduce(reduce(swap(p3), swap(p2)), swap(p1))) - }.holds - - def reduce_associative_inverse2(p1: (BigInt, BigInt), p2: (BigInt, BigInt), p3: (BigInt, BigInt)): Boolean = { - reduce(reduce(p1, p2), p3) == swap(reduce(swap(p3), reduce(swap(p2), swap(p1)))) - }.holds - - def parPair(x: BigInt): (BigInt, BigInt) = { - if (x == openPar) (1, 0) else if (x == closePar) (0, 1) else (0, 0) - } - - def headOption(list: List): Option = list match { - case Cons(head, tail) => Some(head) - case Nil() => None() - } - - def lastOption(list: List): Option = list match { - case Cons(head, Nil()) => Some(head) - case Cons(head, tail) => lastOption(tail) - case Nil() => None() - } - - def init(list: List): List = list match { - case Cons(head, Nil()) => Nil() - case Cons(head, tail) => Cons(head, init(tail)) - case Nil() => Nil() - } - - def tail(list: List): List = list match { - case Cons(head, tail) => tail - case Nil() => Nil() - } - - def size(list: List): BigInt = (list match { - case Nil() => BigInt(0) - case Cons(h, t) => BigInt(1) + size(t) - }) ensuring (_ >= 0) - - def addLast(list: List, x: BigInt): List = { - list match { - case Cons(head, tail) => Cons(head, addLast(tail, x)) - case Nil() => Cons(x, Nil()) - } - } ensuring { res => - lastOption(res) == Some(x) && - init(res) == list && - size(list) + 1 == size(res) - } - - def reverse(list: List): List = { - list match { - case Cons(head, tail) => addLast(reverse(tail), head) - case Nil() => Nil() - } - } ensuring { res => - lastOption(res) == headOption(list) && - lastOption(list) == headOption(res) && - size(res) == size(list) - } - - def reverse_tail_equivalence(list: List): Boolean = { - reverse(tail(list)) == init(reverse(list)) - }.holds - - def reverse_init_equivalence(list: List): Boolean = { - reverse(init(list)) == tail(reverse(list)) because (list match { - case Cons(head, tail) => reverse_init_equivalence(tail) - case Nil() => true - }) - }.holds - - def reverse_equality_equivalence(l1: List, l2: List): Boolean = { - (l1 == l2) == (reverse(l1) == reverse(l2)) because ((l1, l2) match { - case (Cons(h1, t1), Cons(h2, t2)) => reverse_equality_equivalence(t1, t2) - case _ => true - }) - }.holds - - // In order to prove that this function terminates, we cannot just say - // "it always calls itself with a sub-list of `list`", because `t2` is - // the tail of `reverse(list)`, not the tail of `list` directly. - // So we add another argument `s`, whose only purpose is to be - // always decreasing, so that the termination checker can prove termination. - def reverse_reverse_equivalence(s: BigInt, list: List): Boolean = { - require(size(list) == s) - reverse(reverse(list)) == list because ((list, reverse(list)) match { - case (Cons(h1, t1), Cons(h2, t2)) => - reverse_reverse_equivalence(size(t1), t1) && reverse_reverse_equivalence(size(t2), t2) - case _ => true - }) - }.holds - - /* - def fold_equivalence(list: List): Boolean = { - val s = (0, 0) - val fl = (s: (BigInt, BigInt), x: BigInt) => reduce(s, parPair(x)) - val fr = (x: BigInt, s: (BigInt, BigInt)) => reduce(parPair(x), s) - - foldLeft(list, s, fl) == foldRight(list, s, fr) - }.holds - - def lemma(list: List): Boolean = { - val f = (x: BigInt, s: (BigInt, BigInt)) => reduce(parPair(x), s) - fold_equivalence(list) && balanced_foldLeft_equivalence(list, (0, 0)) && - (foldRight(list, (0, 0), f) == (0, 0)) == balanced(list, 0) - }.holds - */ - -} diff --git a/src/test/resources/regression/verification/purescala/valid/PositiveMap.scala b/src/test/resources/regression/verification/purescala/valid/PositiveMap.scala deleted file mode 100644 index a9a07c9850de6d9e9c7de498996d9f1b16d6d532..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/PositiveMap.scala +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object PositiveMap { - - abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def positive(list: List): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def positiveMap_passing_1(f: (BigInt) => BigInt, list: List): List = { - list match { - case Cons(head, tail) => - val fh = f(head) - val nh = if (fh <= 0) -fh else fh - Cons(nh, positiveMap_passing_1(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } - - def positiveMap_passing_2(f: (BigInt) => BigInt, list: List): List = { - list match { - case Cons(head, tail) => - val fh = f(head) - val nh = if (fh < 0) -fh else fh - Cons(nh, positiveMap_passing_2(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/PositiveMap2.scala b/src/test/resources/regression/verification/purescala/valid/PositiveMap2.scala deleted file mode 100644 index ea8ccbdf51ccde121fa76070123a49a9cd0f08c5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/PositiveMap2.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - - -import leon.lang._ - -object PositiveMap2 { - - abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - def positive(list: List): Boolean = list match { - case Cons(head, tail) => if (head < 0) false else positive(tail) - case Nil() => true - } - - def positiveMap_passing_1(f: (BigInt) => BigInt, list: List): List = { - require(forall((a: BigInt) => f(a) > 0)) - list match { - case Cons(head, tail) => Cons(f(head), positiveMap_passing_1(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } - - def positiveMap_passing_2(f: (BigInt) => BigInt, list: List): List = { - require(forall((a: BigInt) => f(a) > -1)) - list match { - case Cons(head, tail) => Cons(f(head), positiveMap_passing_2(f, tail)) - case Nil() => Nil() - } - } ensuring { res => positive(res) } - -} - -// vim: set ts=4 sw=4 et: diff --git a/src/test/resources/regression/verification/purescala/valid/Postcondition.scala b/src/test/resources/regression/verification/purescala/valid/Postcondition.scala deleted file mode 100644 index d4303a79914c81743758fa049e1926032f2057f7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Postcondition.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Postconditions { - - def passing_1(f: BigInt => BigInt, x: BigInt) = { - require(x >= 0 && forall((a: BigInt) => f(a) < 0)) - x - } ensuring { res => forall((a: BigInt) => res > f(a)) } - - def passing_2(f: BigInt => BigInt, x: BigInt) = { - require(x >= 0 && forall((a: BigInt) => a > 0 ==> f(a) < 0)) - x - } ensuring { res => forall((a: BigInt) => a > 0 ==> res > f(a)) } - - def passing_3(f: BigInt => BigInt) = { - require(forall((a: BigInt) => f(a) > 0)) - f - } ensuring { res => forall((a: BigInt) => res(a) > 0) } - - def passing_4() = { - (x: BigInt) => x + 1 - } ensuring { res => forall((a: BigInt) => res(a) > a) } -} diff --git a/src/test/resources/regression/verification/purescala/valid/PreInSpecs.scala b/src/test/resources/regression/verification/purescala/valid/PreInSpecs.scala deleted file mode 100644 index 314c2c5878937839a0a746d694c15556989a323f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/PreInSpecs.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object PreInSpecs { - - def f(i : BigInt): Boolean = { - require(i >= 0) - i > 0 - } - - def g(i : BigInt): Boolean = { - require(i > 0) - i >= -1 - } holds - - def invoke(i : BigInt): BigInt = { - require(i == 0 || i > 0 && f(i - 1)) - i + 1 - } ensuring(res => g(i + 1)) - - def invoke2(i: BigInt): BigInt = { - require(i > 0 && g(i)) - 0 - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Predicate.scala b/src/test/resources/regression/verification/purescala/valid/Predicate.scala deleted file mode 100644 index 684df8dc4a5540ba9f321b001139f3626576b5a7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Predicate.scala +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package leon.monads.predicate - -import leon.collection._ -import leon.lang._ -import leon.annotation._ - -object Predicate { - - def exists[A](p: A => Boolean): Boolean = !forall((a: A) => !p(a)) - - // Monadic bind - @inline - def flatMap[A,B](p: A => Boolean, f: A => (B => Boolean)): B => Boolean = { - (b: B) => exists[A](a => p(a) && f(a)(b)) - } - - // All monads are also functors, and they define the map function - @inline - def map[A,B](p: A => Boolean, f: A => B): B => Boolean = { - (b: B) => exists[A](a => p(a) && f(a) == b) - } - - /* - @inline - def >>=[B](f: A => Predicate[B]): Predicate[B] = flatMap(f) - - @inline - def >>[B](that: Predicate[B]) = >>= ( _ => that ) - - @inline - def withFilter(f: A => Boolean): Predicate[A] = { - Predicate { a => p(a) && f(a) } - } - */ - - def equals[A](p: A => Boolean, that: A => Boolean): Boolean = { - forall[A](a => p(a) == that(a)) - } - - def test[A,B,C](p: A => Boolean, f: A => B, g: B => C): Boolean = { - equals(map(map(p, f), g), map(p, (a: A) => g(f(a)))) - }.holds - - /* Disabled - * Nested quantification is not really a supported feature anyway... - def testInt(p: BigInt => Boolean, f: BigInt => BigInt, g: BigInt => BigInt): Boolean = { - equals(map(map(p, f), g), map(p, (x: BigInt) => g(f(x)))) - }.holds - */ -} - diff --git a/src/test/resources/regression/verification/purescala/valid/PropositionalLogic.scala b/src/test/resources/regression/verification/purescala/valid/PropositionalLogic.scala deleted file mode 100644 index fa7c0cf487cca517f1b134b0acb7ba02a93ebe3d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/PropositionalLogic.scala +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object PropositionalLogic { - - sealed abstract class Formula - case class And(lhs: Formula, rhs: Formula) extends Formula - case class Or(lhs: Formula, rhs: Formula) extends Formula - case class Implies(lhs: Formula, rhs: Formula) extends Formula - case class Not(f: Formula) extends Formula - case class Literal(id: Int) extends Formula - - def simplify(f: Formula): Formula = (f match { - case And(lhs, rhs) => And(simplify(lhs), simplify(rhs)) - case Or(lhs, rhs) => Or(simplify(lhs), simplify(rhs)) - case Implies(lhs, rhs) => Or(Not(simplify(lhs)), simplify(rhs)) - case Not(f) => Not(simplify(f)) - case Literal(_) => f - }) ensuring(isSimplified(_)) - - def isSimplified(f: Formula): Boolean = f match { - case And(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Or(lhs, rhs) => isSimplified(lhs) && isSimplified(rhs) - case Implies(_,_) => false - case Not(f) => isSimplified(f) - case Literal(_) => true - } - - def nnf(formula: Formula): Formula = (formula match { - case And(lhs, rhs) => And(nnf(lhs), nnf(rhs)) - case Or(lhs, rhs) => Or(nnf(lhs), nnf(rhs)) - case Implies(lhs, rhs) => Implies(nnf(lhs), nnf(rhs)) - case Not(And(lhs, rhs)) => Or(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Or(lhs, rhs)) => And(nnf(Not(lhs)), nnf(Not(rhs))) - case Not(Implies(lhs, rhs)) => And(nnf(lhs), nnf(Not(rhs))) - case Not(Not(f)) => nnf(f) - case Not(Literal(_)) => formula - case Literal(_) => formula - }) ensuring(isNNF(_)) - - def isNNF(f: Formula): Boolean = f match { - case And(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Or(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Implies(lhs, rhs) => isNNF(lhs) && isNNF(rhs) - case Not(Literal(_)) => true - case Not(_) => false - case Literal(_) => true - } - - def vars(f: Formula): Set[Int] = { - require(isNNF(f)) - f match { - case And(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Or(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Implies(lhs, rhs) => vars(lhs) ++ vars(rhs) - case Not(Literal(i)) => Set[Int](i) - case Literal(i) => Set[Int](i) - } - } - - def fv(f : Formula) = { vars(nnf(f)) } - - @induct - def nnfIsStable(f: Formula) : Boolean = { - require(isNNF(f)) - nnf(f) == f - }.holds - - @induct - def simplifyIsStable(f: Formula) : Boolean = { - require(isSimplified(f)) - simplify(f) == f - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/README b/src/test/resources/regression/verification/purescala/valid/README deleted file mode 100644 index 2bb01d5fdbd6b59970c0c84f2c10db1ead6097a2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/README +++ /dev/null @@ -1,2 +0,0 @@ -This particular directory contains PureScala programs that can be entirely -proved correct by Leon. diff --git a/src/test/resources/regression/verification/purescala/valid/RealDivisionByZero.scala b/src/test/resources/regression/verification/purescala/valid/RealDivisionByZero.scala deleted file mode 100644 index c6d44938e0cd2aab612cc679dd2aa6a4b59e0277..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/RealDivisionByZero.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object RealDivisionByZero { - - def noDivByZero(x: Real): Boolean = { - (x / Real(10) == Real(10)) - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/RedBlackTree.scala b/src/test/resources/regression/verification/purescala/valid/RedBlackTree.scala deleted file mode 100644 index a40068e7081dc594d7419e38f436cbca3751f8da..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/RedBlackTree.scala +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object RedBlackTree { - sealed abstract class Color - case class Red() extends Color - case class Black() extends Color - - sealed abstract class Tree - case class Empty() extends Tree - case class Node(color: Color, left: Tree, value: BigInt, right: Tree) extends Tree - - sealed abstract class OptionInt - case class Some(v : BigInt) extends OptionInt - case class None() extends OptionInt - - def content(t: Tree) : Set[BigInt] = t match { - case Empty() => Set.empty - case Node(_, l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def size(t: Tree) : BigInt = (t match { - case Empty() => BigInt(0) - case Node(_, l, v, r) => size(l) + 1 + size(r) - }) ensuring(_ >= 0) - - /* We consider leaves to be black by definition */ - def isBlack(t: Tree) : Boolean = t match { - case Empty() => true - case Node(Black(),_,_,_) => true - case _ => false - } - - def redNodesHaveBlackChildren(t: Tree) : Boolean = t match { - case Empty() => true - case Node(Black(), l, _, r) => redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - case Node(Red(), l, _, r) => isBlack(l) && isBlack(r) && redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - } - - def redDescHaveBlackChildren(t: Tree) : Boolean = t match { - case Empty() => true - case Node(_,l,_,r) => redNodesHaveBlackChildren(l) && redNodesHaveBlackChildren(r) - } - - def blackBalanced(t : Tree) : Boolean = t match { - case Node(_,l,_,r) => blackBalanced(l) && blackBalanced(r) && blackHeight(l) == blackHeight(r) - case Empty() => true - } - - def blackHeight(t : Tree) : BigInt = t match { - case Empty() => 1 - case Node(Black(), l, _, _) => blackHeight(l) + 1 - case Node(Red(), l, _, _) => blackHeight(l) - } - - // <<insert element x into the tree t>> - def ins(x: BigInt, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t) && blackBalanced(t)) - t match { - case Empty() => Node(Red(),Empty(),x,Empty()) - case Node(c,a,y,b) => - if (x < y) balance(c, ins(x, a), y, b) - else if (x == y) Node(c,a,y,b) - else balance(c,a,y,ins(x, b)) - } - } ensuring (res => content(res) == content(t) ++ Set(x) - && size(t) <= size(res) && size(res) <= size(t) + 1 - && redDescHaveBlackChildren(res) - && blackBalanced(res)) - - def makeBlack(n: Tree): Tree = { - require(redDescHaveBlackChildren(n) && blackBalanced(n)) - n match { - case Node(Red(),l,v,r) => Node(Black(),l,v,r) - case _ => n - } - } ensuring(res => redNodesHaveBlackChildren(res) && blackBalanced(res)) - - def add(x: BigInt, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t) && blackBalanced(t)) - makeBlack(ins(x, t)) - } ensuring (res => content(res) == content(t) ++ Set(x) && redNodesHaveBlackChildren(res) && blackBalanced(res)) - - def balance(c: Color, a: Tree, x: BigInt, b: Tree): Tree = { - Node(c,a,x,b) match { - case Node(Black(),Node(Red(),Node(Red(),a,xV,b),yV,c),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),Node(Red(),a,xV,Node(Red(),b,yV,c)),zV,d) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),Node(Red(),b,yV,c),zV,d)) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(Black(),a,xV,Node(Red(),b,yV,Node(Red(),c,zV,d))) => - Node(Red(),Node(Black(),a,xV,b),yV,Node(Black(),c,zV,d)) - case Node(c,a,xV,b) => Node(c,a,xV,b) - } - } ensuring (res => content(res) == content(Node(c,a,x,b)))// && redDescHaveBlackChildren(res)) -} diff --git a/src/test/resources/regression/verification/purescala/valid/SearchLinkedList.scala b/src/test/resources/regression/verification/purescala/valid/SearchLinkedList.scala deleted file mode 100644 index e35e6bc0e96ba7aaa322705f4cfe569a1bb1bf6a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/SearchLinkedList.scala +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.annotation._ - -object SearchLinkedList { - sealed abstract class List - case class Cons(head : Int, tail : List) extends List - case class Nil() extends List - - def size(list : List) : BigInt = (list match { - case Nil() => BigInt(0) - case Cons(_, xs) => 1 + size(xs) - }) ensuring(_ >= 0) - - def contains(list : List, elem : Int) : Boolean = (list match { - case Nil() => false - case Cons(x, xs) => x == elem || contains(xs, elem) - }) - - def firstZero(list : List) : BigInt = (list match { - case Nil() => BigInt(0) - case Cons(x, xs) => if (x == 0) BigInt(0) else firstZero(xs) + 1 - }) ensuring (res => - res >= 0 && (if (contains(list, 0)) { - firstZeroAtPos(list, res) - } else { - res == size(list) - })) - - def firstZeroAtPos(list : List, pos : BigInt) : Boolean = { - list match { - case Nil() => false - case Cons(x, xs) => if (pos == BigInt(0)) x == 0 else x != 0 && firstZeroAtPos(xs, pos - 1) - } - } - - def goal(list : List, i : BigInt) : Boolean = { - if(firstZero(list) == i) { - if(contains(list, 0)) { - firstZeroAtPos(list, i) - } else { - i == size(list) - } - } else { - true - } - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Sets1.scala b/src/test/resources/regression/verification/purescala/valid/Sets1.scala deleted file mode 100644 index ff0d0421b0a344b248f445743dbfcd09bb101d06..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Sets1.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Sets1 { - def set(i: Int): Int => Boolean = x => x == i - - def complement(s: Int => Boolean): Int => Boolean = x => !s(x) - - def union(s1: Int => Boolean, s2: Int => Boolean): Int => Boolean = x => s1(x) || s2(x) - - def intersection(s1: Int => Boolean, s2: Int => Boolean): Int => Boolean = x => s1(x) && s2(x) - - def de_morgan_1(s1: Int => Boolean, s2: Int => Boolean, x: Int): Boolean = { - val u1 = union(s1, s2) - val u2 = complement(intersection(complement(s1), complement(s2))) - u1(x) == u2(x) - }.holds - - def de_morgan_2(s1: Int => Boolean, s2: Int => Boolean, x: Int): Boolean = { - val u1 = intersection(s1, s2) - val u2 = complement(union(complement(s1), complement(s2))) - u1(x) == u2(x) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Sets2.scala b/src/test/resources/regression/verification/purescala/valid/Sets2.scala deleted file mode 100644 index 1ea7ca0238f5b01e5e18c77f677ddabec9831f0d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Sets2.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Sets2 { - def set(i: Int): Int => Boolean = x => x == i - - def complement(s: Int => Boolean): Int => Boolean = x => !s(x) - - def union(s1: Int => Boolean, s2: Int => Boolean): Int => Boolean = x => s1(x) || s2(x) - - def intersection(s1: Int => Boolean, s2: Int => Boolean): Int => Boolean = x => s1(x) && s2(x) - - def union_associativity(sa1: Int => Boolean, sa2: Int => Boolean, sa3: Int => Boolean, x: Int): Boolean = { - val u1 = union(union(sa1, sa2), sa3) - val u2 = union(sa1, union(sa2, sa3)) - u1(x) == u2(x) - }.holds - - def intersection_associativity(sa1: Int => Boolean, sa2: Int => Boolean, sa3: Int => Boolean, x: Int): Boolean = { - val u1 = intersection(intersection(sa1, sa2), sa3) - val u2 = intersection(sa1, intersection(sa2, sa3)) - u1(x) == u2(x) - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/SimpleQuantification.scala b/src/test/resources/regression/verification/purescala/valid/SimpleQuantification.scala deleted file mode 100644 index 4784d2c1786f5dbcd4ddd5f058f71ab8aa7c78d9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/SimpleQuantification.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Simple { - - def passing_1(f: BigInt => BigInt) = { - require(forall((a: BigInt) => a > 0 ==> f(a) > 0)) - f(10) - } ensuring { res => res > 0 } - - def passing_2(f: BigInt => BigInt) = { - require(forall((a: BigInt) => a > 0 ==> f(a) > 1)) - f(1) + f(2) - } ensuring { res => res > 2 } - - def passing_3(f: BigInt => BigInt) = { - require(forall((a: BigInt) => f(a) > 0 || f(a) < 0)) - f(8) - } ensuring { res => res != 0 } - - def passing_4(f: BigInt => BigInt, g: BigInt => BigInt, x: BigInt) = { - require(forall((a: BigInt, b: BigInt) => f(a) + f(b) > 0)) - if(x <= 0) f(x) + f(x) - else x - } ensuring { res => res > 0 } - - def passing_5(f: BigInt => BigInt, g: BigInt => Boolean): BigInt = { - require(forall((a: BigInt) => if(g(a)) { f(a) > 0 || f(a) < 0 } else { f(a) == 0 })) - if(g(8)) f(8) - else BigInt(1) - } ensuring { res => res != 0 } - - def passing_6(f: BigInt => BigInt, x: BigInt) = { - require(x > 0 && forall((a: BigInt) => a > 0 ==> f(a) > 0)) - if(x > 0) f(1) - else f(-1) - } ensuring { res => res > 0 } - - def passing_7(f: BigInt => BigInt) = { - require(forall((a: BigInt) => a > 0 ==> f(a) > 0)) - val a = f(-1) - f(2) - } ensuring { res => res > 0 } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Subtyping1.scala b/src/test/resources/regression/verification/purescala/valid/Subtyping1.scala deleted file mode 100644 index 8b5d7e4b5ec0e55fffbabd949b7e6081827553a2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Subtyping1.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Subtyping1 { - - sealed abstract class Tree - case class Leaf() extends Tree - case class Node(left: Tree, value: Int, right: Tree) extends Tree - - def content(t: Tree) : Set[Int] = t match { - case Leaf() => Set.empty - case Node(l, v, r) => content(l) ++ Set(v) ++ content(r) - } - - def treeMax(tree: Node): Int = { - tree match { - case Node(_, v, right) => right match { - case Leaf() => v - case Node(l, v, r) => treeMax(Node(l, v, r)) - } - } - } ensuring(content(tree).contains(_)) - - def f2(tree: Node): Int = { - require(treeMax(tree) > 0) - tree match { - case Node(_, v, right) => right match { - case Leaf() => v - case Node(l, v, r) => treeMax(Node(l, v, r)) - } - } - } ensuring(content(tree).contains(_)) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Subtyping2.scala b/src/test/resources/regression/verification/purescala/valid/Subtyping2.scala deleted file mode 100644 index bbb436b6a134a427e97aab1527fbaaeea49a16c9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Subtyping2.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Subtyping2 { - - abstract class List - case class Nil() extends List - case class Cons(head: Int, tail: List) extends List - - def test(x: List): Nil = { - x match { - case Cons(_, tail) => test(tail) - case Nil() => Nil() - } - } ensuring((res: Nil) => isEmpty(res)) - - def isEmpty(x: List): Boolean = x match { - case Nil() => true - case _ => false - } - -} diff --git a/src/test/resources/regression/verification/purescala/valid/TraceInductTacticTest.scala b/src/test/resources/regression/verification/purescala/valid/TraceInductTacticTest.scala deleted file mode 100644 index 46a2bdecae4dbfc0f3446dfe5335ed1055b4f6dd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/TraceInductTacticTest.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon.annotation._ - -object TraceInductTacticTest { - - def contains(l: List[BigInt], set: Set[BigInt]): Boolean = { - l match { - case Cons(x, xs) => set.contains(x) && contains(xs, set) - case Nil() => true - } - } - - @traceInduct - def monotonicity(l: List[BigInt], set1: Set[BigInt], set2: Set[BigInt]): Boolean = { - (contains(l, set1) && set1.subsetOf(set2)) ==> contains(l, set2) - } holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/TransitiveQuantification.scala b/src/test/resources/regression/verification/purescala/valid/TransitiveQuantification.scala deleted file mode 100644 index c622bc13921401d7d1dd7e4b5074e111bcbfffac..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/TransitiveQuantification.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Transitive { - - def multiAssoc(f: (Int, Int, Int) => Int): Boolean = { - require(forall { (a: Int, b: Int, c: Int, d: Int, e: Int) => - f(f(a,b,c),d,e) == f(a,f(b,c,d),e) && f(a,f(b,c,d),e) == f(a,b,f(c,d,e)) - }) - f(f(1,2,3),4,5) == f(1,2,f(3,4,5)) - }.holds - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Trees1.scala b/src/test/resources/regression/verification/purescala/valid/Trees1.scala deleted file mode 100644 index cb0b02900ae77bdce3043fe0b901ab055bcfee1e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Trees1.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Trees1 { - abstract class Tree[T] - case class Node[T](left: Tree[T], right: Tree[T]) extends Tree[T] - case class Leaf[T](value: T) extends Tree[T] - - def map[T,U](tree: Tree[T], f: T => U): Tree[U] = tree match { - case Node(left, right) => Node(map(left, f), map(right, f)) - case Leaf(value) => Leaf(f(value)) - } - - def associative_lemma[T,U,V](tree: Tree[T], f: T => U, g: U => V): Boolean = { - map(map(tree, f), g) == map(tree, (x: T) => g(f(x))) - } - - def associative_lemma_induct[T,U,V](tree: Tree[T], f: T => U, g: U => V): Boolean = { - tree match { - case Node(left, right) => associative_lemma_induct(left, f, g) && associative_lemma_induct(right, f, g) && associative_lemma(tree, f, g) - case Leaf(value) => associative_lemma(tree, f, g) - } - }.holds -} diff --git a/src/test/resources/regression/verification/purescala/valid/Unapply.scala b/src/test/resources/regression/verification/purescala/valid/Unapply.scala deleted file mode 100644 index 0113f68d7e4ea324407feffbcf3b5293001ab7f4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Unapply.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -object Unap { - def unapply[A, B](i: (Int, B, A)): Option[(A, B)] = - if (i._1 == 0) None() else Some((i._3, i._2)) -} - -object Unapply { - - sealed abstract class Bool - case class True() extends Bool - case class False() extends Bool - - def not(b: Bool): Bool = b match { - case True() => False() - case False() => True() - } - - def bar: Bool = { (42, True().asInstanceOf[Bool], ()) match { - case Unap(_, b) if b == True() => b - case Unap((), b) => not(b) - }} ensuring { res => res == True() } -} diff --git a/src/test/resources/regression/verification/purescala/valid/Unit1.scala b/src/test/resources/regression/verification/purescala/valid/Unit1.scala deleted file mode 100644 index 596f7cc319bddcf495fd281e820a0f5bc7f1144f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Unit1.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Unit1 { - - def foo(): Unit = ({ - () - }) ensuring(r => true) - -} diff --git a/src/test/resources/regression/verification/purescala/valid/Unit2.scala b/src/test/resources/regression/verification/purescala/valid/Unit2.scala deleted file mode 100644 index 1aa3cf55bdd9de42855d7a7311a73f47256c917a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/purescala/valid/Unit2.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Unit2 { - - def foo(u: Unit): Unit = { - u - } ensuring(res => true) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Array1.scala b/src/test/resources/regression/verification/xlang/invalid/Array1.scala deleted file mode 100644 index b1e032aaafe435589e44f01c61fc7ec7d00defeb..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Array1.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Array1 { - - def foo(): Int = { - val a = Array.fill(5)(0) - a(2) = 3 - a(2) - } ensuring(_ == 0) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Array2.scala b/src/test/resources/regression/verification/xlang/invalid/Array2.scala deleted file mode 100644 index 2785ca22853f1c597f7ab227c5bcb15999beb420..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Array2.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Array2 { - - def foo(): Int = { - val a = Array.fill(5)(0) - a(2) = 3 - a.length - } ensuring(_ == 4) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Array3.scala b/src/test/resources/regression/verification/xlang/invalid/Array3.scala deleted file mode 100644 index 4d785c176ecc84380919e2ee9eea6bd8a36bcbde..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Array3.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array3 { - - def foo(): Int = { - val a = Array.fill(5)(3) - var i = 0 - var sum = 0 - (while(i <= a.length) { - sum = sum + a(i) - i = i + 1 - }) invariant(i >= 0) - sum - } ensuring(_ == 15) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Assert1.scala b/src/test/resources/regression/verification/xlang/invalid/Assert1.scala deleted file mode 100644 index 8febd5aa3e3c1e4cc6fc119a8fa1265b9b59cb8f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Assert1.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -/* Copyright 2009-2015 EPFL, Lausanne */ - -object Assert1 { - - def foo(): Int = { - var a = 0 - a += 1 - assert(a == 0) - a - } - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Assert2.scala b/src/test/resources/regression/verification/xlang/invalid/Assert2.scala deleted file mode 100644 index 1dee8a90f7ce907c033e0f469c01e4255e7328fd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Assert2.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Assert2 { - - def foo(): Int = { - var a = 0 - assert(a == 1) - a += 1 - a - } - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Asserts2.scala b/src/test/resources/regression/verification/xlang/invalid/Asserts2.scala deleted file mode 100644 index eddca00e467923aa6ad2a49239862aeb17053c62..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Asserts2.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Asserts2 { - - def assert1(i: BigInt): BigInt = { // we might define assert like so - require(i >= 0) - i - } - - def sum(to: BigInt): BigInt = { - assert1(to) - to - } -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon1.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon1.scala deleted file mode 100644 index c35318dfed394f4b6110d53406655144253a13fa..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon1.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon1 { - - def rand2(x: Int): Int = epsilon((y: Int) => true) - - //this should not hold - def property2(x: Int): Boolean = { - rand2(x) == rand2(x+1) - }.holds - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon2.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon2.scala deleted file mode 100644 index a7e89366e08778fdfe562299034520c5d1127d3e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon2.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon2 { - - def rand3(x: Int): Int = epsilon((y: Int) => x == x) - - //this should not hold - def property3(x: Int): Boolean = { - rand3(x) == rand3(x+1) - }.holds -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon3.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon3.scala deleted file mode 100644 index d32c1ba84081174d2aa499002ff6c59bcfad3585..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon3.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon3 { - - def posWrong(): Int = { - epsilon((y: Int) => y >= 0) - } ensuring(_ > 0) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon4.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon4.scala deleted file mode 100644 index 1fc7ebcd9a2efff9698d06c113e1350638f06cd6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon4.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon4 { - - sealed abstract class MyList - case class MyCons(head: Int, tail: MyList) extends MyList - case class MyNil() extends MyList - - def size(lst: MyList): Int = (lst match { - case MyNil() => 0 - case MyCons(_, xs) => 1 + size(xs) - }) - - def toSet(lst: MyList): Set[Int] = lst match { - case MyCons(x, xs) => toSet(xs) ++ Set(x) - case MyNil() => Set[Int]() - } - - def toList(set: Set[Int]): MyList = if(set == Set.empty[Int]) MyNil() else { - val elem = epsilon((x : Int) => set contains x) - MyCons(elem, toList(set -- Set[Int](elem))) - } - - - def wrongProperty0(lst: MyList): Boolean = (size(toList(toSet(lst))) == size(lst)).holds - //def wrongProperty1(lst: MyList): Boolean = (toList(toSet(lst)) == lst).holds -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon5.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon5.scala deleted file mode 100644 index 0ba2717472bfb71fa423c76afc435d33199ce077..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon5.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon5 { - - def fooWrong(x: Int, y: Int): Int = { - epsilon((z: Int) => z >= x && z <= y) - } ensuring(_ > x) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon6.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon6.scala deleted file mode 100644 index c2144cce492d8ea1babc2aca2006246234c530b0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon6.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon6 { - - def greaterWrong(x: Int): Int = { - epsilon((y: Int) => y >= x) - } ensuring(_ > x) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon7.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon7.scala deleted file mode 100644 index 3bbfde20d909d3a8832b9e441d2e5f0edb9f118b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon7.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon7 { - - def rand(): Int = epsilon((x: Int) => true) - - //this used to be VALID until the introduction - //of a global state that can tracks epsilon calls - //and ensure each epsilon is invoked with a different - //seed value - def wrongProperty1(): Boolean = { - rand() == rand() - }.holds - - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon8.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon8.scala deleted file mode 100644 index a95ff4ea79db3f7e0109017e8fc4646a0a4bc8d0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon8.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon8 { - - def wrongProp: Boolean = { - epsilon((y: Int) => true) == epsilon((y: Int) => true) - } holds - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/Epsilon9.scala b/src/test/resources/regression/verification/xlang/invalid/Epsilon9.scala deleted file mode 100644 index c21e5333e8240e624fe3290441453c65f766e7f5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/Epsilon9.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon9 { - - def random(): BigInt = epsilon((x: BigInt) => true) - - /* - * The implementation relies on a potential bug in random(), when - * two calls of random with the same args (0 here) will return - * the same value. If that's the case, then we can prove the - * postcondition. Epsilon should behave really randomly, so that - * postcondition should be invalid. - */ - def findPositive(): BigInt = { - val x = random() - if(x < 0) { - -random() - } else { - x - } - } ensuring(res => res >= 0) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/FunctionCaching.scala b/src/test/resources/regression/verification/xlang/invalid/FunctionCaching.scala deleted file mode 100644 index 1ba4c5b2855f504cc8b0e669678dfd3ba47edbba..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/FunctionCaching.scala +++ /dev/null @@ -1,33 +0,0 @@ -import leon.lang._ -import leon.collection._ - -object FunctionCaching { - - case class FunCache(var cached: Map[BigInt, BigInt]) - - def fun(x: BigInt)(implicit funCache: FunCache): BigInt = { - funCache.cached.get(x) match { - case None() => - val res = 2*x + 42 - funCache.cached = funCache.cached.updated(x, res) - res - case Some(cached) => - cached + 1 - } - } - - def funWronglyCached(x: BigInt, trash: List[BigInt]): Boolean = { - implicit val cache = FunCache(Map()) - val res1 = fun(x) - multipleCalls(trash) - val res2 = fun(x) - res1 == res2 - } holds - - - def multipleCalls(args: List[BigInt])(implicit funCache: FunCache): Unit = args match { - case Nil() => () - case x::xs => fun(x); multipleCalls(xs) - } - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/IfExpr1.scala b/src/test/resources/regression/verification/xlang/invalid/IfExpr1.scala deleted file mode 100644 index 7ddaac162c1e9d02caac2c9e1028c188492ad3be..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/IfExpr1.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object IfExpr1 { - - def foo(): Int = { - var a = 1 - var b = 2 - if({a = a + 1; a != b}) - a = a + 3 - else - b = a + b - a - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/IfExpr2.scala b/src/test/resources/regression/verification/xlang/invalid/IfExpr2.scala deleted file mode 100644 index 4126d6636083f1f3a4bd374fa4572a67dc6089dd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/IfExpr2.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object IfExpr2 { - - def foo(): Int = { - var a = 1 - var b = 2 - if(a < b) { - a = a + 3 - b = b + 2 - a = a + b - } - a - } ensuring(_ == 0) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/NestedFunState1.scala b/src/test/resources/regression/verification/xlang/invalid/NestedFunState1.scala deleted file mode 100644 index abd623d29ec40f2b3a85f6ebfe77dc9ad4425309..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/NestedFunState1.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -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) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/NestedFunState2.scala b/src/test/resources/regression/verification/xlang/invalid/NestedFunState2.scala deleted file mode 100644 index 394feb4469cb4003074f1250ab36358eae62bc54..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/NestedFunState2.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 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) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/StdIn1.scala b/src/test/resources/regression/verification/xlang/invalid/StdIn1.scala deleted file mode 100644 index aa3a326ff377c805eef18dadd06f7b2fed8d1e0f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/StdIn1.scala +++ /dev/null @@ -1,10 +0,0 @@ -import leon.io._ - -object StdIn1 { - - def alwaysPos: Int = { - implicit val state = StdIn.newState - StdIn.readInt - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/StdIn2.scala b/src/test/resources/regression/verification/xlang/invalid/StdIn2.scala deleted file mode 100644 index f9a24021251f5b2328e0531faa8722871d718053..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/StdIn2.scala +++ /dev/null @@ -1,13 +0,0 @@ -import leon.io._ - -object StdIn2 { - - def anyTwoNumbers: Boolean = { - implicit val state = StdIn.newState - val n1 = StdIn.readInt - val n2 = StdIn.readInt - - n1 == n2 - } ensuring(res => res) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/StdIn3.scala b/src/test/resources/regression/verification/xlang/invalid/StdIn3.scala deleted file mode 100644 index 9511b21fd5dfa5b93d0272e4319bc246ffa85f1b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/StdIn3.scala +++ /dev/null @@ -1,12 +0,0 @@ -import leon.io._ - -object StdIn3 { - - //should be invalid because of MinInt - def abs: Int = { - implicit val state = StdIn.newState - val n = StdIn.readInt - if(n < 0) -n else n - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/xlang/invalid/StdIn4.scala b/src/test/resources/regression/verification/xlang/invalid/StdIn4.scala deleted file mode 100644 index 79c357b1d3165bb3303f4d70b578c0d9d731f8d7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/invalid/StdIn4.scala +++ /dev/null @@ -1,10 +0,0 @@ -import leon.io._ - -object StdIn4 { - - def readBoolCanBeFalse: Boolean = { - implicit val state = StdIn.newState - StdIn.readBoolean - } ensuring(res => res) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ADTWithArray1.scala b/src/test/resources/regression/verification/xlang/valid/ADTWithArray1.scala deleted file mode 100644 index 696f4a1b85d3390cf4e0c84b729c9c6294527fbc..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ADTWithArray1.scala +++ /dev/null @@ -1,16 +0,0 @@ -object ADTWithArray1 { - - case class A(a: Array[Int]) - - def foo(a: A): Unit = { - require(a.a.length > 0) - a.a(0) = 10 - } - - def test(): Int = { - val a = A(Array(1,2,3)) - foo(a) - a.a(0) - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ADTWithArray2.scala b/src/test/resources/regression/verification/xlang/valid/ADTWithArray2.scala deleted file mode 100644 index dbe834b4f705f4303f533897b8a7d2dd65c47212..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ADTWithArray2.scala +++ /dev/null @@ -1,16 +0,0 @@ -object ADTWithArray2 { - - case class A(a: Array[Int], size: Int) - - def foo(a: A): Unit = { - require(a.a.length > 0 && a.a.length == a.size) - a.a(0) = 10 - } - - def test(): Int = { - val a = A(Array(1,2,3), 3) - foo(a) - a.a(0) - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ADTWithArray3.scala b/src/test/resources/regression/verification/xlang/valid/ADTWithArray3.scala deleted file mode 100644 index e894929700a0008846308e491d47881e84e70e8a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ADTWithArray3.scala +++ /dev/null @@ -1,17 +0,0 @@ -object ADTWithArray3 { - - case class A(var x: Int) - case class B(a: Array[A]) - - def foo(b: B): Unit = { - require(b.a.length > 0) - b.a(0).x = 12 - } - - def test(): B = { - val b = B(Array(A(1),A(2),A(3))) - foo(b) - b - } ensuring(b => b.a(0).x == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Arithmetic.scala b/src/test/resources/regression/verification/xlang/valid/Arithmetic.scala deleted file mode 100644 index 7febf126c5dccd96f856aba9730b82e34c3fd8d4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Arithmetic.scala +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Arithmetic { - - /* VSTTE 2008 - Dafny paper */ - def mult(x : BigInt, y : BigInt): BigInt = ({ - var r: BigInt = 0 - if(y < 0) { - var n = y - (while(n != BigInt(0)) { - r = r - x - n = n + 1 - }) invariant(r == x * (y - n) && 0 <= -n) - } else { - var n = y - (while(n != BigInt(0)) { - r = r + x - n = n - 1 - }) invariant(r == x * (y - n) && 0 <= n) - } - r - }) ensuring(_ == x*y) - - /* VSTTE 2008 - Dafny paper */ - def add(x : BigInt, y : BigInt): BigInt = ({ - var r = x - if(y < 0) { - var n = y - (while(n != BigInt(0)) { - r = r - 1 - n = n + 1 - }) invariant(r == x + y - n && 0 <= -n) - } else { - var n = y - (while(n != BigInt(0)) { - r = r + 1 - n = n - 1 - }) invariant(r == x + y - n && 0 <= n) - } - r - }) ensuring(_ == x+y) - - - def sum(n: BigInt): BigInt = { - require(n >= 0) - var r = BigInt(0) - var i = BigInt(0) - (while(i < n) { - i = i + 1 - r = r + i - }) invariant(r >= i && i >= 0 && r >= 0) - r - } ensuring(_ >= n) - - def divide(x: BigInt, y: BigInt): (BigInt, BigInt) = { - require(x >= 0 && y > 0) - var r = x - var q = BigInt(0) - (while(r >= y) { - r = r - y - q = q + 1 - }) invariant(x == y*q + r && r >= 0) - (q, r) - } ensuring(res => x == y*res._1 + res._2 && res._2 >= 0 && res._2 < y) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Array1.scala b/src/test/resources/regression/verification/xlang/valid/Array1.scala deleted file mode 100644 index 09379018f760c6d3ddcc2ed11d7d877ebe4a1a42..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Array1.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Array1 { - - def foo(): Int = { - val a = Array.fill(5)(0) - a(2) = 3 - a(2) - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Array2.scala b/src/test/resources/regression/verification/xlang/valid/Array2.scala deleted file mode 100644 index b5e23aa7affa9ba0e3afc60c9d84a5c6519cb002..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Array2.scala +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Array2 { - - def foo(): Int = { - val a = Array.fill(5)(0) - a(2) = 3 - a.length - } ensuring(_ == 5) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Array3.scala b/src/test/resources/regression/verification/xlang/valid/Array3.scala deleted file mode 100644 index ece86335b47ac18e6ba99ddf893e626542b0b17e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Array3.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array3 { - - def foo(): Int = { - val a = Array.fill(5)(3) - var i = 0 - var sum = 0 - (while(i < a.length) { - sum = sum + a(i) - i = i + 1 - }) invariant(i >= 0) - sum - } ensuring(_ == 15) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Array4.scala b/src/test/resources/regression/verification/xlang/valid/Array4.scala deleted file mode 100644 index 0b7374d6ecb2bbdee85c58a451eff80a04141c3a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Array4.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array4 { - - def foo(a: Array[Int]): Int = { - var i = 0 - var sum = 0 - (while(i < a.length) { - sum = sum + a(i) - i = i + 1 - }) invariant(i >= 0) - sum - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Array5.scala b/src/test/resources/regression/verification/xlang/valid/Array5.scala deleted file mode 100644 index 7cdc2173775c6c2a5b91b2b262e6356e2cc8ea0b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Array5.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array5 { - - def foo(a: Array[Int]): Int = { - var i = 0 - var sum = 0 - (while(i < a.length) { - sum = sum + a(i) - i = i + 1 - }) invariant(i >= 0) - sum - } - - def bar(): Int = { - val a = Array.fill(5)(5) - foo(a) - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Array6.scala b/src/test/resources/regression/verification/xlang/valid/Array6.scala deleted file mode 100644 index 7c16ca9aed73fefbe21daa674d8757395639ceb8..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Array6.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array6 { - - def test(): Int = { - var c = 1 - val a = Array(0,1,2,3) - a({ - if(a(0) == 0) { c = c+1; 1} - else { c = c+2; 2} - }) = { c = c*2; -1} - c - } ensuring(res => res == 4) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Array7.scala b/src/test/resources/regression/verification/xlang/valid/Array7.scala deleted file mode 100644 index 0efc14e8fd74a08dac9d43c07aa3b801f98e59ed..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Array7.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Array7 { - - def foo(a: Array[Int]): Array[Int] = { - require(a.length > 0) - val a2 = Array.fill(a.length)(0) - var i = 0 - (while(i < a.length) { - a2(i) = a(i) - i = i + 1 - }) invariant(a.length == a2.length && i >= 0 && (if(i > 0) a2(0) == a(0) else true)) - a2 - } ensuring(_(0) == a(0)) - - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayNested1.scala b/src/test/resources/regression/verification/xlang/valid/ArrayNested1.scala deleted file mode 100644 index f698242c17eed2338fb73625a344c1c0d1de651d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayNested1.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ArrayNested1 { - - def test(): Int = { - - var a = Array(1, 2, 0) - - def nested(): Unit = { - require(a.length == 3) - a = a.updated(1, 5) - } - - nested() - a(1) - - } ensuring(_ == 5) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayNested2.scala b/src/test/resources/regression/verification/xlang/valid/ArrayNested2.scala deleted file mode 100644 index 5b2407b57138ff2b8fd20c27b47bf8026f3f120d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayNested2.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object ArrayNested2 { - - def test(): Int = { - - val a = Array(1, 2, 0) - - def nested(): Unit = { - require(a.length == 3) - a(2) = 5 - } - - nested() - a(2) - - } ensuring(_ == 5) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation1.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation1.scala deleted file mode 100644 index f0e622c66c31e4fe01ff8be5c1b08e17d4d330eb..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation1.scala +++ /dev/null @@ -1,16 +0,0 @@ -import leon.lang._ - -object ArrayParamMutation1 { - - def update(a: Array[BigInt]): Unit = { - require(a.length > 0) - a(0) = 10 - } - - def f(): BigInt = { - val a = Array.fill(10)(BigInt(0)) - update(a) - a(0) - } ensuring(res => res == 10) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation2.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation2.scala deleted file mode 100644 index 801b35e0cc545f160fc8061e34fd0ee06b7c3f73..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation2.scala +++ /dev/null @@ -1,16 +0,0 @@ -import leon.lang._ - -object ArrayParamMutation2 { - - def rec(a: Array[BigInt]): BigInt = { - require(a.length > 1 && a(0) >= 0) - if(a(0) == 0) - a(1) - else { - a(0) = a(0) - 1 - a(1) = a(1) + a(0) - rec(a) - } - } ensuring(res => a(0) == 0) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation3.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation3.scala deleted file mode 100644 index f575167444f839c0ee900a35de5e4e822624dc21..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation3.scala +++ /dev/null @@ -1,23 +0,0 @@ -import leon.lang._ - -object ArrayParamMutation3 { - - def odd(a: Array[BigInt]): Boolean = { - require(a.length > 0 && a(0) >= 0) - if(a(0) == 0) false - else { - a(0) = a(0) - 1 - even(a) - } - } ensuring(res => a(0) == 0) - - def even(a: Array[BigInt]): Boolean = { - require(a.length > 0 && a(0) >= 0) - if(a(0) == 0) true - else { - a(0) = a(0) - 1 - odd(a) - } - } ensuring(res => a(0) == 0) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation4.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation4.scala deleted file mode 100644 index 31af4cd5885ea66a2d11e9387ba7e306423ec4d7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation4.scala +++ /dev/null @@ -1,23 +0,0 @@ -import leon.lang._ - -object ArrayParamMutation4 { - - def multipleArgs(a1: Array[BigInt], a2: Array[BigInt]): Unit = { - require(a1.length > 0 && a2.length > 0) - if(a1(0) == 10) - a2(0) = 13 - else - a2(0) = a1(0) + 1 - } - - def transitiveEffects(a1: Array[BigInt], a2: Array[BigInt]): Unit = { - require(a1.length > 0 && a2.length > 0) - multipleArgs(a1, a2) - } ensuring(_ => a2(0) >= a1(0)) - - def transitiveReverseEffects(a1: Array[BigInt], a2: Array[BigInt]): Unit = { - require(a1.length > 0 && a2.length > 0) - multipleArgs(a2, a1) - } ensuring(_ => a1(0) >= a2(0)) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation5.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation5.scala deleted file mode 100644 index 249a79d1f3b7d8df8c941ab3121c4eafed149e03..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation5.scala +++ /dev/null @@ -1,21 +0,0 @@ - -import leon.lang._ - -object ArrayParamMutation5 { - - def mutuallyRec1(a1: Array[BigInt], a2: Array[BigInt]): Unit = { - require(a1.length > 0 && a1(0) > 0 && a2.length > 0) - if(a1(0) == 10) { - () - } else { - mutuallyRec2(a1, a2) - } - } ensuring(res => a1(0) == 10) - - def mutuallyRec2(a1: Array[BigInt], a2: Array[BigInt]): Unit = { - require(a1.length > 0 && a2.length > 0 && a1(0) > 0) - a1(0) = 10 - mutuallyRec1(a1, a2) - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation6.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation6.scala deleted file mode 100644 index 29ded427fa6546a103d8da6f98cefc1415f389a6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation6.scala +++ /dev/null @@ -1,16 +0,0 @@ -import leon.lang._ - -object ArrayParamMutation6 { - - def multipleEffects(a1: Array[BigInt], a2: Array[BigInt]): Unit = { - require(a1.length > 0 && a2.length > 0) - a1(0) = 11 - a2(0) = 12 - } ensuring(_ => a1(0) != a2(0)) - - def f(a1: Array[BigInt], a2: Array[BigInt]): Unit = { - require(a1.length > 0 && a2.length > 0) - multipleEffects(a1, a2) - } ensuring(_ => a1(0) == 11 && a2(0) == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation7.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation7.scala deleted file mode 100644 index 53d67729fd57723d1693c564e99cd3d66ee095ef..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation7.scala +++ /dev/null @@ -1,29 +0,0 @@ -import leon.lang._ - -object ArrayParamMutation7 { - - def f(i: BigInt)(implicit world: Array[BigInt]): BigInt = { - require(world.length == 3) - - world(1) += 1 //global counter of f - - val res = i*i - world(0) = res - res - } - - def mainProgram(): Unit = { - - implicit val world: Array[BigInt] = Array(0,0,0) - - f(1) - assert(world(0) == 1) - f(2) - assert(world(0) == 4) - f(4) - assert(world(0) == 16) - - assert(world(1) == 3) - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation8.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation8.scala deleted file mode 100644 index 68aa737eb42e6e51073dac27b799e06bde928400..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation8.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2009-2015 EPFL, Lausanne */ - -import leon.lang._ - -object ArrayParamMutation8 { - - def odd(a: Array[BigInt]): Boolean = { - require(a.length > 0 && a(0) >= 0) - if(a(0) == 0) false - else { - a(0) = a(0) - 1 - even(a) - } - } ensuring(res => if(old(a)(0) % 2 == 1) res else !res) - - def even(a: Array[BigInt]): Boolean = { - require(a.length > 0 && a(0) >= 0) - if(a(0) == 0) true - else { - a(0) = a(0) - 1 - odd(a) - } - } ensuring(res => if(old(a)(0) % 2 == 0) res else !res) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation9.scala b/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation9.scala deleted file mode 100644 index f5046b6cf3b40382ccc5d989d81d73bc577da9f7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ArrayParamMutation9.scala +++ /dev/null @@ -1,22 +0,0 @@ -import leon.lang._ - -object ArrayParamMutation9 { - def abs(a: Array[Int]) { - require(a.length > 0) - var i = 0; - (while (i < a.length) { - a(i) = if (a(i) < 0) -a(i) else a(i) // <-- this makes Leon crash - i = i + 1 - }) invariant(i >= 0) - } - - - def main = { - val a = Array(0, -1, 2, -3) - - abs(a) - - a(0) + a(1) - 1 + a(2) - 2 + a(3) - 3 // == 0 - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Assert1.scala b/src/test/resources/regression/verification/xlang/valid/Assert1.scala deleted file mode 100644 index 8f2199ad224d7224df85a9addd82e1be7279462d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Assert1.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Assert1 { - - def foo(): Int = { - var a = 0 - a += 1 - assert(a == 1) - a - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Assert2.scala b/src/test/resources/regression/verification/xlang/valid/Assert2.scala deleted file mode 100644 index 64002e2cf37d54d0ead83c643b69a1b0306c3677..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Assert2.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Assert2 { - - def foo(): Int = { - var a = 0 - assert(a == 0) - a += 1 - a - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Assert3.scala b/src/test/resources/regression/verification/xlang/valid/Assert3.scala deleted file mode 100644 index bd29aae41f726ddf700865cbb7d0782abf17c7f7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Assert3.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object Assert3 { - - def test(i: Int): Int = { - var j = i - - assert(j == i) - j += 1 - assert(j == i + 1) - j += 2 - assert(j == i + 3) - - j - - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Assign1.scala b/src/test/resources/regression/verification/xlang/valid/Assign1.scala deleted file mode 100644 index 2f812d48a08e64eaf6161bae80b3aca75c12c5b6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Assign1.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Assign1 { - - def foo(): Int = { - var a = 0 - val tmp = a + 1 - a = a + 2 - a = a + tmp - a = a + 4 - a - } ensuring(_ == 7) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Blocks1.scala b/src/test/resources/regression/verification/xlang/valid/Blocks1.scala deleted file mode 100644 index a2266bcc6229c4a9fe91440f6738b3e6ea78de28..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Blocks1.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Blocks1 { - - //this used to crash as we would simplify away the final Unit, and get a typing - //error during the solving part - def test(a: BigInt): Unit = { - 42 - () - } ensuring(_ => a == (a + a - a)) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Epsilon1.scala b/src/test/resources/regression/verification/xlang/valid/Epsilon1.scala deleted file mode 100644 index 8c91e3f7ffa5dc81ce87bfdc7f9540d92c5add1c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Epsilon1.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon1 { - - def greater(x: Int): Int = { - epsilon((y: Int) => y > x) - } ensuring(_ >= x) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Epsilon3.scala b/src/test/resources/regression/verification/xlang/valid/Epsilon3.scala deleted file mode 100644 index e1103e2f1166c7b1cc2b4d10c900af06a12405d0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Epsilon3.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon3 { - - def pos(): Int = { - epsilon((y: Int) => y > 0) - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Epsilon4.scala b/src/test/resources/regression/verification/xlang/valid/Epsilon4.scala deleted file mode 100644 index 248bf0f1d562ed3dc1b72bbbed9b7180d8c2912c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Epsilon4.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon4 { - - sealed abstract class MyList - case class MyCons(head: Int, tail: MyList) extends MyList - case class MyNil() extends MyList - - def size(lst: MyList): Int = (lst match { - case MyNil() => 0 - case MyCons(_, xs) => 1 + size(xs) - }) - - def toSet(lst: MyList): Set[Int] = lst match { - case MyCons(x, xs) => toSet(xs) ++ Set(x) - case MyNil() => Set[Int]() - } - - def toList(set: Set[Int]): MyList = if(set == Set.empty[Int]) MyNil() else { - val elem = epsilon((x : Int) => set contains x) - MyCons(elem, toList(set -- Set[Int](elem))) - } - - //timeout, but this probably means that it is valid as expected - //def property(lst: MyList): Boolean = (size(toList(toSet(lst))) <= size(lst)).holds - - def propertyBase(lst: MyList): Boolean = ({ - require(lst match { case MyNil() => true case _ => false}) - size(toList(toSet(lst))) <= size(lst) - }).holds - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Epsilon5.scala b/src/test/resources/regression/verification/xlang/valid/Epsilon5.scala deleted file mode 100644 index 80cbb2bc9c79c02867d1c64af1b38ca81e2fb0e2..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Epsilon5.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.lang.xlang._ - -object Epsilon5 { - - def foo(x: Int, y: Int): Int = { - epsilon((z: Int) => z > x && z < y) - } ensuring(_ >= x) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ExpressionOrder1.scala b/src/test/resources/regression/verification/xlang/valid/ExpressionOrder1.scala deleted file mode 100644 index c34d2057e3c945283cf8548393c1ad97e4c11886..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ExpressionOrder1.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object NestedFunState8 { - - def test1 = { - var x = 0 - - def bar(y: Int) = { - def fun(z: Int) = 1 * x * (y + z) - - fun(3) - } - - bar(2) == 0 - }.holds - -} diff --git a/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder1.scala b/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder1.scala deleted file mode 100644 index 23576c1fcdef0717d35ba362bb6043a4e3a86c24..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder1.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object FunInvocEvaluationOrder1 { - - def test(): Int = { - - var res = 10 - justAddingStuff({ - res += 1 - res - }, { - res *= 2 - res - }, { - res += 10 - res - }) - - res - } ensuring(_ == 32) - - def justAddingStuff(x: Int, y: Int, z: Int): Int = x + y + z - -} diff --git a/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder2.scala b/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder2.scala deleted file mode 100644 index c37ab1045eec87938624f573ec2ea4b0a99f0c8a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder2.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object FunInvocEvaluationOrder2 { - - def leftToRight(n: BigInt): BigInt = { - require(n > 0) - - var a = BigInt(0) - - def nested(x: BigInt, y: BigInt): BigInt = { - require(y >= x) - x + y - } - - nested({a += 10; a}, {a *= 2; a}) - - } ensuring(_ == 30) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder3.scala b/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder3.scala deleted file mode 100644 index e6c1b37ddff3a50f728d66b1855689175e2e1d01..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/FunInvocEvaluationOrder3.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object FunInvocEvaluationOrder3 { - - def leftToRight(n: BigInt): BigInt = { - require(n > 0) - - var a = BigInt(0) - - def nested(x: BigInt, y: BigInt): Unit = { - a = x + y - } - - nested({a += 10; a}, {a *= 2; a}) - a - - } ensuring(_ == 30) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/FunctionCaching.scala b/src/test/resources/regression/verification/xlang/valid/FunctionCaching.scala deleted file mode 100644 index 322cb592ee44a65add6f1eed42ba8fea7fba4155..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/FunctionCaching.scala +++ /dev/null @@ -1,40 +0,0 @@ -import leon.lang._ -import leon.collection._ - -object FunctionCaching { - - case class FunCache(var cached: Map[BigInt, BigInt]) - - def fun(x: BigInt)(implicit funCache: FunCache): BigInt = { - funCache.cached.get(x) match { - case None() => - val res = 2*x + 42 - funCache.cached = funCache.cached.updated(x, res) - res - case Some(cached) => - cached - } - } ensuring(res => old(funCache).cached.get(x) match { - case None() => true - case Some(v) => v == res - }) - - def funProperlyCached(x: BigInt, trash: List[BigInt]): Boolean = { - implicit val cache = FunCache(Map()) - val res1 = fun(x) - multipleCalls(trash, x) - val res2 = fun(x) - res1 == res2 - } holds - - def multipleCalls(args: List[BigInt], x: BigInt)(implicit funCache: FunCache): Unit = { - require(funCache.cached.get(x).forall(_ == 2*x + 42)) - args match { - case Nil() => () - case y::ys => - fun(y) - multipleCalls(ys, x) - } - } ensuring(_ => funCache.cached.get(x).forall(_ == 2*x + 42)) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/GuessNumber.scala b/src/test/resources/regression/verification/xlang/valid/GuessNumber.scala deleted file mode 100644 index 806948060f944a1e91061e1305bf84c4290faf78..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/GuessNumber.scala +++ /dev/null @@ -1,32 +0,0 @@ -import leon.lang._ -import leon.lang.xlang._ - -object GuessNumber { - - def random(min: Int, max: Int): Int = epsilon((x: Int) => x >= min && x <= max) - - def main(): Unit = { - val choice = random(0, 10) - - var guess = random(0, 10) - var top = 10 - var bot = 0 - - (while(bot < top) { - if(isGreater(guess, choice)) { - top = guess-1 - guess = random(bot, top) - } else if(isSmaller(guess, choice)) { - bot = guess+1 - guess = random(bot, top) - } - }) invariant(guess >= bot && guess <= top && bot >= 0 && top <= 10 && bot <= top && choice >= bot && choice <= top && - true) - val answer = bot - assert(answer == choice) - } - - def isGreater(guess: Int, choice: Int): Boolean = guess > choice - def isSmaller(guess: Int, choice: Int): Boolean = guess < choice - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams1.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams1.scala deleted file mode 100644 index 4ea4032fbde38d50fdb39ac3163a04ada685440e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams1.scala +++ /dev/null @@ -1,24 +0,0 @@ -object HigherOrderFunctionsMutableParams1 { - - case class A(var x: BigInt) - - def app(f: (A) => Unit, a: A): Unit = { - f(a) - } - - def fImpl(a: A): Unit = { - a.x += 1 - } - - - def test(): BigInt = { - val a = A(0) - app(fImpl, a) - assert(a.x == 1) - app(fImpl, a) - assert(a.x == 2) - app(fImpl, a) - a.x - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams10.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams10.scala deleted file mode 100644 index 9d2dea7f36b12eedc12273c13dcc6a9cdc65fec3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams10.scala +++ /dev/null @@ -1,28 +0,0 @@ -import leon.lang._ -import leon.lang.xlang._ - -object HigherOrderFunctionsMutableParams10 { - - case class A(var x: Int) - - case class FunctionWrapper(f: (A) => Int) - case class WrapWrapper(fw: FunctionWrapper) - - def app(ww: WrapWrapper, a: A): Int = ww match { - case WrapWrapper(fw) => fw.f(a) - } - - def fImpl(a: A): Int = { - a.x += 1 - a.x - } - - def test(): Int = { - val a = A(0) - val wrap = WrapWrapper(FunctionWrapper(fImpl)) - app(wrap, a) - app(wrap, a) - a.x - } ensuring(_ == 2) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams11.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams11.scala deleted file mode 100644 index 9f6a1c8620b22e7ab21e6f3a21c722ae627ca1e9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams11.scala +++ /dev/null @@ -1,28 +0,0 @@ -import leon.lang._ -import leon.lang.xlang._ - -object HigherOrderFunctionsMutableParams11 { - - case class A(var x: Int) - - case class FunctionWrapper(f: (A) => Int) - case class WrapWrapper(fw: FunctionWrapper) - - def app(fw: FunctionWrapper, a: A): Int = fw match { - case FunctionWrapper(f) => f(a) - } - - def fImpl(a: A): Int = { - a.x += 1 - a.x - } - - def test(): Int = { - val a = A(0) - val wrap = FunctionWrapper(fImpl) - app(wrap, a) - app(wrap, a) - a.x - } ensuring(_ == 2) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams12.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams12.scala deleted file mode 100644 index 799ce940df37f33b453fa1a1e8abf8d0c40023cf..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams12.scala +++ /dev/null @@ -1,26 +0,0 @@ -object HigherOrderFunctionsMutableParams12 { - - case class A(var x: BigInt) - - case class B(closure: (A) => BigInt) { - - def execute(a: A): BigInt = { - closure(a) - } - - } - - def test(): BigInt = { - val a = A(3) - val b = B((capturedA: A) => { - capturedA.x = capturedA.x + 1 - capturedA.x - }) - - b.execute(a) - b.execute(a) - b.execute(a) - } ensuring(_ == 6) - -} - diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams13.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams13.scala deleted file mode 100644 index ca18fff62705c0a7220f62a20158f9a7a8f53d42..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams13.scala +++ /dev/null @@ -1,24 +0,0 @@ -object HigherOrderFunctionsMutableParams13 { - - case class A(var x: BigInt) - - case class B(closure: (A) => BigInt) { - - def execute(a: A): BigInt = { - a.x = a.x + 1 - closure(a) - } - - } - - def test(): BigInt = { - val a = A(3) - val b = B((capturedA: A) => capturedA.x) - - b.execute(a) - b.execute(a) - b.execute(a) - } ensuring(_ == 6) - -} - diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams14.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams14.scala deleted file mode 100644 index aba611cb4cd97b99379ef2b26165f01e8d470a87..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams14.scala +++ /dev/null @@ -1,27 +0,0 @@ -object HigherOrderFunctionsMutableParams14 { - - case class A(var x: BigInt) - - case class B(closure: (A) => BigInt, var a: A) { - - def execute(): BigInt = { - closure(a) - } - - } - - def closure(a: A): BigInt = { - a.x = a.x + 1 - a.x - } - - def test(): BigInt = { - val b = B(closure _, A(3)) - - b.execute() - b.execute() - b.execute() - } ensuring(_ == 6) - -} - diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams15.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams15.scala deleted file mode 100644 index 160d764b91ba6acba694aedf59d4134cb2ce7521..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams15.scala +++ /dev/null @@ -1,19 +0,0 @@ -object HigherOrderFunctionsMutableParams15 { - - case class A(var x: BigInt) - case class B(f: (A) => Unit, a: A) - - def app(b: B): Unit = { - b.f(b.a) - } - - def test(): BigInt = { - val b = B((x: A) => { - x.x = x.x + 1 - }, A(0)) - app(b) - app(b) - b.a.x - } ensuring(_ == 2) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams16.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams16.scala deleted file mode 100644 index afdf498359ac66084b743e2f928fc3c5e4d359cf..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams16.scala +++ /dev/null @@ -1,20 +0,0 @@ -object HigherOrderFunctionsMutableParams16 { - - case class A(var x: BigInt) - case class B(a: A) - - def app(f: (A) => Unit, b: B): Unit = { - f(b.a) - } - - def test(): BigInt = { - val f: (A => Unit) = ((x: A) => { - x.x = x.x + 1 - }) - val b = B(A(0)) - app(f, b) - app(f, b) - b.a.x - } ensuring(_ == 2) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams2.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams2.scala deleted file mode 100644 index dbf3413855bc65f12f5380c49e58c5e7bd463933..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams2.scala +++ /dev/null @@ -1,22 +0,0 @@ -object HigherOrderFunctionsMutableParams2 { - - case class A(var x: BigInt) - - def app(f: (A) => BigInt, a: A): BigInt = { - f(a) - } - - def fImpl(a: A): BigInt = { - a.x += 1 - a.x - } - - - def test(): BigInt = { - val a = A(0) - app(fImpl, a) - app(fImpl, a) - app(fImpl, a) - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams3.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams3.scala deleted file mode 100644 index c8dfc83bb1b9447d434dd1273b266247940ebcb5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams3.scala +++ /dev/null @@ -1,26 +0,0 @@ -object HigherOrderFunctionsMutableParams3 { - - case class A(var x: BigInt) - - def app(f: (A) => BigInt, a: A): BigInt = { - f(a) - } - - def fImpl1(a: A): BigInt = { - a.x += 1 - a.x - } - def fImpl2(a: A): BigInt = { - a.x += 10 - a.x - } - - - def test(): BigInt = { - val a = A(0) - app(fImpl1, a) - app(fImpl2, a) - app(fImpl1, a) - } ensuring(_ == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams4.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams4.scala deleted file mode 100644 index e379dfef4dd524b4955deaadfc071098033d467f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams4.scala +++ /dev/null @@ -1,25 +0,0 @@ -object HigherOrderFunctionsMutableParams4 { - - case class A(var x: BigInt) - - def app(f: (A) => BigInt, a: A): BigInt = { - f(a) - } - - def test(): BigInt = { - val a = A(0) - app((a2: A) => { - a2.x += 1 - a2.x - }, a) - app((a2: A) => { - a2.x += 10 - a2.x - }, a) - app((a2: A) => { - a2.x += 1 - a2.x - }, a) - } ensuring(_ == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams5.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams5.scala deleted file mode 100644 index 64829e949d71fdfc93d82c4da88bb3fa3b54d4a8..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams5.scala +++ /dev/null @@ -1,23 +0,0 @@ -object HigherOrderFunctionsMutableParams5 { - - case class A(var x: BigInt) - - def repeat(f: (A, BigInt) => Unit, n: BigInt, a: A): Unit = { - require(n >= 0) - if(n > 0) { - f(a, n) - repeat(f, n-1, a) - } - } - - def fImpl(a: A, n: BigInt): Unit = { - a.x += 1 - } - - def test(): BigInt = { - val a = A(0) - repeat(fImpl, 3, a) - a.x - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams6.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams6.scala deleted file mode 100644 index fcdc822b1cb9786d715051e61d3cf4b4c1acbb35..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams6.scala +++ /dev/null @@ -1,31 +0,0 @@ -object HigherOrderFunctionsMutableParams6 { - - abstract class List - case class Cons(head: BigInt, tail: List) extends List - case class Nil() extends List - - case class A(var x: BigInt) - - def map(ls: List, f: (BigInt, A) => BigInt, a: A): List = ls match { - case Cons(head, tail) => - Cons(f(head, a), map(tail, f, a)) - - case Nil() => Nil() - } - - def fImpl(el: BigInt, a: A): BigInt = { - val last = a.x - a.x = el - last - } - - def shift(ls: List): List = { - val a = A(0) - map(ls, fImpl, a) - } - - def test(): List = { - val l = Cons(2, Cons(4, Cons(6, Nil()))) - shift(l) - } ensuring(res => res == Cons(0, Cons(2, Cons(4, Nil())))) -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams7.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams7.scala deleted file mode 100644 index b32043f0095c52189fadb8765ea744ab746f8d0a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams7.scala +++ /dev/null @@ -1,19 +0,0 @@ -object HigherOrderFunctionsMutableParams7 { - /* - * this test catches an error that happened in - * xlang when renaming higher order functions parameter - * even though the function had a pure signature (Int => Int) - */ - - def app(f: (Int) => Int, x: Int): Int = { - f(x) - } - - def id(x: Int) = x - - def test(): Int = { - val x = 12 - app(id, 12) - } ensuring(_ == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams8.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams8.scala deleted file mode 100644 index 67978a7076343314774d3e6037ce2cf5877be1b4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams8.scala +++ /dev/null @@ -1,28 +0,0 @@ -import leon.lang._ -import leon.lang.xlang._ - -object HigherOrderFunctionsMutableParams8 { - - case class A(var x: Int) - - case class FunctionWrapper(f: (A) => Int) - - def app(wrap: FunctionWrapper, a: A): Int = { - wrap.f(a) - } - - def fImpl(a: A): Int = { - a.x += 1 - a.x - } - - def test(): Int = { - val a = A(0) - val wrap = FunctionWrapper(fImpl) - app(wrap, a) - app(wrap, a) - a.x - } ensuring(_ == 2) - - -} diff --git a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams9.scala b/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams9.scala deleted file mode 100644 index 05994acb658747673264b1b637367fa8db625947..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/HigherOrderFunctionsMutableParams9.scala +++ /dev/null @@ -1,28 +0,0 @@ -import leon.lang._ -import leon.lang.xlang._ - -object HigherOrderFunctionsMutableParams9 { - - case class A(var x: Int) - - case class FunctionWrapper(f: (A) => Int) - case class WrapWrapper(fw: FunctionWrapper) - - def app(ww: WrapWrapper, a: A): Int = { - ww.fw.f(a) - } - - def fImpl(a: A): Int = { - a.x += 1 - a.x - } - - def test(): Int = { - val a = A(0) - val wrap = WrapWrapper(FunctionWrapper(fImpl)) - app(wrap, a) - app(wrap, a) - a.x - } ensuring(_ == 2) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/IfExpr1.scala b/src/test/resources/regression/verification/xlang/valid/IfExpr1.scala deleted file mode 100644 index a9ffdabcc84f9f8d2cd7a1e8ce715fa5ae09ec9d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/IfExpr1.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object IfExpr1 { - - def foo(): Int = { - var a = 1 - var b = 2 - if({a = a + 1; a != b}) - a = a + 3 - else - b = a + b - a - } ensuring(_ == 2) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/IfExpr2.scala b/src/test/resources/regression/verification/xlang/valid/IfExpr2.scala deleted file mode 100644 index c439ea5938b428b396f115d59ee584a82d025f4b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/IfExpr2.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object IfExpr2 { - - def foo(): Int = { - var a = 1 - var b = 2 - if(a < b) { - a = a + 3 - b = b + 2 - a = a + b - } - a - } ensuring(_ == 8) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/IfExpr3.scala b/src/test/resources/regression/verification/xlang/valid/IfExpr3.scala deleted file mode 100644 index f71fb9cbaa32266074940a44c507a00e8ccfb30e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/IfExpr3.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object IfExpr3 { - - def foo(a: Int): Int = { - - if(a > 0) { - var a = 1 - var b = 2 - a = 3 - a + b - } else { - 5 - //var a = 3 - //var b = 1 - //b = b + 1 - //a + b - } - } ensuring(_ == 5) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/IfExpr4.scala b/src/test/resources/regression/verification/xlang/valid/IfExpr4.scala deleted file mode 100644 index e0335300ec0c4dbd56e8ce75837c7f08252127b1..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/IfExpr4.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object IfExpr4 { - - def foo(a: Int): Int = { - - if(a > 0) { - var a = 1 - var b = 2 - a = 3 - a + b - } else { - var a = 3 - var b = 1 - b = b + 1 - a + b - } - } ensuring(_ == 5) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Lambda1.scala b/src/test/resources/regression/verification/xlang/valid/Lambda1.scala deleted file mode 100644 index b228f96f7c861d0b1fb020c7f65d4e84ea8b7ab9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Lambda1.scala +++ /dev/null @@ -1,13 +0,0 @@ -object Lambda1 { - - def test(): Int = { - val x = 2 - val cl = ((y: Int) => { - var z = y - z = z + x - z - }) - cl(4) - } ensuring(_ == 6) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation1.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation1.scala deleted file mode 100644 index a7250a7bcfd572c49584110d213f9e9991a10c9f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation1.scala +++ /dev/null @@ -1,16 +0,0 @@ -import leon.lang._ - -object NestedFunParamsMutation1 { - - def f(): Int = { - def g(a: Array[Int]): Unit = { - require(a.length > 0) - a(0) = 10 - } - - val a = Array(1,2,3,4) - g(a) - a(0) - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation2.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation2.scala deleted file mode 100644 index 799a87c6e9e70bf6ef89bfc1fb7a6e116adb7feb..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation2.scala +++ /dev/null @@ -1,21 +0,0 @@ -import leon.lang._ - -object NestedFunParamsMutation2 { - - def f(): Int = { - def g(a: Array[Int]): Unit = { - require(a.length > 0) - a(0) = 10 - } - - def h(a: Array[Int]): Unit = { - require(a.length > 0) - g(a) - } - - val a = Array(1,2,3,4) - h(a) - a(0) - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation3.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation3.scala deleted file mode 100644 index e4f149333b03687a0532ab0d5d88e51b0cd8d5bf..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunParamsMutation3.scala +++ /dev/null @@ -1,20 +0,0 @@ -object NestedFunParamsMutation3 { - - case class Counter(var i: BigInt) { - def reset() = { - i = 0 - } - } - - - def main(c: Counter): Unit = { - - def sub(): Unit = { - c.reset() - } - sub() - assert(c.i == 0) - } - -} - diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunState1.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunState1.scala deleted file mode 100644 index cb649ef1cbc11be29b3249128744dbc7665447da..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunState1.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object NestedFunState1 { - - 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() - } - } ensuring(_ => res >= n) - - iter() - res - } ensuring(_ >= n) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunState2.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunState2.scala deleted file mode 100644 index d42eb0d59f8b4b1cf74823504013d73e555ae812..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunState2.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object NestedFunState2 { - - def countConst(): Int = { - - var counter = 0 - - def inc(): Unit = { - counter += 1 - } - - inc() - inc() - inc() - counter - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunState3.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunState3.scala deleted file mode 100644 index 3a796c0d10f236c09663d50b4d6a28a6d48f28c3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunState3.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object NestedFunState3 { - - - def counterN(n: Int): Int = { - require(n > 0) - - var counter = 0 - - def inc(): Unit = { - counter += 1 - } - - var i = 0 - (while(i < n) { - inc() - i += 1 - }) invariant(i >= 0 && counter == i && i <= n) - - counter - } ensuring(_ == n) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunState4.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunState4.scala deleted file mode 100644 index 4838242de9b983a1ab3d105fa67cfe9ef134237f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunState4.scala +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object NestedFunState4 { - - def deep(n: BigInt): BigInt = { - require(n > 0) - - var a = BigInt(0) - - def iter(): Unit = { - require(a >= 0) - - var b = BigInt(0) - - def nestedIter(): Unit = { - b += 1 - } - - var i = BigInt(0) - (while(i < n) { - i += 1 - nestedIter() - }) invariant(i >= 0 && i <= n && b == i) - - a += b - - } ensuring(_ => a >= n) - - var i = BigInt(0) - (while(i < n) { - i += 1 - iter() - }) invariant(i >= 0 && i <= n && a >= i) - - a - } ensuring(_ >= n) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunState5.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunState5.scala deleted file mode 100644 index e60ff32cd6263f8978868b004d4c7e1437e56f81..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunState5.scala +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object NestedFunState5 { - - def deep(n: BigInt): BigInt = { - require(n > 0) - - var a = BigInt(0) - - def iter(prevA: BigInt): Unit = { - require(prevA == a) - def nestedIter(): Unit = { - a += 1 - } - - nestedIter() - nestedIter() - - } ensuring(_ => a == prevA + 2) - - var i = BigInt(0) - (while(i < n) { - i += 1 - iter(a) - }) invariant(i >= 0 && i <= n && a >= 2*i) - - a - } ensuring(_ >= 2*n) -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunState6.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunState6.scala deleted file mode 100644 index 15d2e75eb1373b7c369b2255c8b6d6ab2bcff480..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunState6.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object NestedFunState6 { - - 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(_ == 4) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedFunState7.scala b/src/test/resources/regression/verification/xlang/valid/NestedFunState7.scala deleted file mode 100644 index e4d07f4ad1ee361a17243c2e0b475ae68a89b6e0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedFunState7.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object NestedFunState7 { - - def test(x: BigInt): BigInt = { - - var a = BigInt(0) - - def defCase(): Unit = { - a = 100 - } - - if(x >= 0) { - a = 2*x - if(a < 100) { - a = 100 - a - } else { - defCase() - } - } else { - defCase() - } - - a - } ensuring(res => res >= 0 && res <= 100) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedOld1.scala b/src/test/resources/regression/verification/xlang/valid/NestedOld1.scala deleted file mode 100644 index d93276e0ed432ce015a927ab5231bf6be17efb5b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedOld1.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object NestedOld1 { - - def test(): Int = { - var counter = 0 - - def inc(): Unit = { - counter += 1 - } ensuring(_ => counter == old(counter) + 1) - - inc() - counter - } ensuring(_ == 1) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedOld2.scala b/src/test/resources/regression/verification/xlang/valid/NestedOld2.scala deleted file mode 100644 index 3bd75e35ca84ea7e0893ea552875410132623c6c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedOld2.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object NestedOld2 { - - def test(): Int = { - var counterPrev = 0 - var counterNext = 1 - - def step(): Unit = { - require(counterNext == counterPrev + 1) - counterPrev = counterNext - counterNext = counterNext+1 - } ensuring(_ => { - counterPrev == old(counterNext) && - counterNext == old(counterNext) + 1 && - counterPrev == old(counterPrev) + 1 - }) - - step() - step() - counterNext - } ensuring(_ == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/NestedVar.scala b/src/test/resources/regression/verification/xlang/valid/NestedVar.scala deleted file mode 100644 index a9b864cb4830a888feec4a8db82f7582752a5008..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/NestedVar.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object NestedVar { - - def foo(): Int = { - val a = 3 - def rec(x: Int): Int = { - var b = 3 - var c = 3 - if(x > 0) - b = 2 - else - c = 2 - c+b - } - rec(a) - } ensuring(_ == 5) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation1.scala b/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation1.scala deleted file mode 100644 index 52e7083346486740d2915835ea584a7fcb020f06..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation1.scala +++ /dev/null @@ -1,13 +0,0 @@ -import leon.lang._ - -object ObjectHierarchyMutation1 { - - case class A(var y: Int) - case class B(a: A) - - def update(b: B): Int = { - b.a.y = 17 - b.a.y - } ensuring(res => res == 17) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation2.scala b/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation2.scala deleted file mode 100644 index 1d1df5dc47dc202cb502e252614dfd3293f8d2d3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation2.scala +++ /dev/null @@ -1,19 +0,0 @@ -import leon.lang._ - -object ObjectHierarchyMutation2 { - - case class A(var y: Int) - case class B(a: A) - - def update(b: B): Int = { - b.a.y = 17 - b.a.y - } - - def f(): Int = { - val b = B(A(10)) - update(b) - b.a.y - } ensuring(res => res == 17) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation3.scala b/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation3.scala deleted file mode 100644 index 67df97f0467312148b013569aede16c9c52f0480..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation3.scala +++ /dev/null @@ -1,19 +0,0 @@ -import leon.lang._ - -object ObjectHierarchyMutation3 { - - case class A(var x: Int, var y: Int, var z: Int) - case class B(a1: A, a2: A, a3: A) - - def update(b: B): Int = { - b.a2.y = 17 - b.a2.y - } ensuring(res => res == 17) - - def f(): Int = { - val b = B(A(10, 11, 12), A(11, 12, 13), A(13, 14, 15)) - update(b) - b.a2.y - } ensuring(res => res == 17) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation4.scala b/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation4.scala deleted file mode 100644 index 807142699cf8fbf85b200759936a612379fad7ac..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation4.scala +++ /dev/null @@ -1,27 +0,0 @@ -import leon.lang._ - -object ObjectHierarchyMutation4 { - - case class A(var x: Int, var y: Int) - case class B(a1: A, a2: A) - case class C(b1: B, b2: B) - - def update(c: C): Int = { - c.b1.a2.y = 17 - c.b1.a2.y - } ensuring(res => res == 17) - - def f(): Int = { - val c = C(B(A(10, 10), A(12, 13)), B(A(10, 10), A(14, 15))) - update(c) - c.b1.a2.y - } ensuring(res => res == 17) - - def multipleUpdate(c: C): Unit = { - c.b1.a2.y = 13 - c.b1.a2.x = 10 - c.b1.a1.x = 15 - c.b2.a1.y = 22 - } ensuring(_ => c.b1.a2.y == 13 && c.b1.a2.x == 10 && c.b1.a1.x == 15 && c.b2.a1.y == 22 && c.b2.a2.y == old(c).b2.a2.y) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation5.scala b/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation5.scala deleted file mode 100644 index ab237ab281d60effcf078bd0c536dacd0edb8aad..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation5.scala +++ /dev/null @@ -1,18 +0,0 @@ -import leon.lang._ - -object ObjectHierarchyMutation5 { - - case class A(var x: Int) - case class B(a: A) - case class C(b: B) - - def updateA(a: A): Unit = { - a.x = 43 - } - - def update(c: C): Int = { - updateA(c.b.a) - c.b.a.x - } ensuring(res => res == 43) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation6.scala b/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation6.scala deleted file mode 100644 index 7361adf0068fbad093382620c18c6aed40f9802e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation6.scala +++ /dev/null @@ -1,18 +0,0 @@ -import leon.lang._ - -object ObjectHierarchyMutation6 { - - case class A(var x: Int, var y: Int) - case class B(a1: A, a2: A) - case class C(b1: B, b2: B) - - def updateA(a: A): Unit = { - a.x = 43 - } - - def update(c: C): Int = { - updateA(c.b2.a1) - c.b2.a1.x - } ensuring(res => res == 43) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation7.scala b/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation7.scala deleted file mode 100644 index f9c7a9198dfb90cf3545e28beabdfe2489480983..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectHierarchyMutation7.scala +++ /dev/null @@ -1,18 +0,0 @@ -import leon.lang._ - -object ObjectHierarchyMutation7 { - - case class A(var x: Int, var y: Int) - case class B(a1: A, a2: A) - case class C(b1: B, b2: B) - - def updateB(b: B): Unit = { - b.a1.x = 43 - } - - def update(c: C): Int = { - updateB(c.b2) - c.b2.a1.x - } ensuring(res => res == 43) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation1.scala b/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation1.scala deleted file mode 100644 index b36fd6f1a3a59864c5cca195f17264b382b6652e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation1.scala +++ /dev/null @@ -1,18 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation1 { - - case class A(var y: Int) - - def update(a: A): Int = { - a.y = 12 - a.y - } ensuring(res => res == 12) - - def f(): Int = { - val a = A(10) - update(a) - a.y - } ensuring(res => res == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation2.scala b/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation2.scala deleted file mode 100644 index 7a7590eb3644633ac479de81e3a046109aa48b4c..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation2.scala +++ /dev/null @@ -1,17 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation2 { - - case class A(var y: Int) - - def update(a: A): Unit = { - a.y = 12 - } ensuring(_ => a.y == 12) - - def f(): Int = { - val a = A(10) - update(a) - a.y - } ensuring(res => res == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation3.scala b/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation3.scala deleted file mode 100644 index 95c88cb571e52e434155c052f0dba750a4fc81a6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation3.scala +++ /dev/null @@ -1,17 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation3 { - - case class A(var y: Int) - - def update(a: A): Unit = { - a.y = a.y + 3 - } ensuring(_ => a.y == old(a).y + 3) - - def f(): Int = { - val a = A(10) - update(a) - a.y - } ensuring(res => res == 13) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation4.scala b/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation4.scala deleted file mode 100644 index 5b50ddb63a9be4ee36cfb39a71ea19b766da9d70..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation4.scala +++ /dev/null @@ -1,22 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation4 { - - case class A(var y: Int) - - def swapY(a1: A, a2: A): Unit = { - val tmp = a1.y - a1.y = a2.y - a2.y = tmp - } ensuring(_ => a1.y == old(a2).y && a2.y == old(a1).y) - - def f(): (Int, Int) = { - val a1 = A(10) - val a2 = A(10) - a1.y = 12 - a2.y = 42 - swapY(a1, a2) - (a1.y, a2.y) - } ensuring(res => res._1 == 42 && res._2 == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation5.scala b/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation5.scala deleted file mode 100644 index 38580345d6540ab92625ba199da2f11b536ae3be..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation5.scala +++ /dev/null @@ -1,19 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation5 { - - case class A(var x: Int, var y: Int) - - def swap(a: A): Unit = { - val tmp = a.x - a.x = a.y - a.y = tmp - } ensuring(_ => a.x == old(a).y && a.y == old(a).x) - - def f(): A = { - val a = A(10, 13) - swap(a) - a - } ensuring(res => res.x == 13 && res.y == 10) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation6.scala b/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation6.scala deleted file mode 100644 index 6c917ff1b4c85e6deabf41cfbadfd0097138c315..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation6.scala +++ /dev/null @@ -1,17 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation6 { - - case class A(var x: BigInt) - - def inc(a: A): Unit = { - a.x += 1 - } ensuring(_ => a.x == old(a).x + 1) - - def f(): BigInt = { - val a = A(0) - inc(a); inc(a); inc(a) - a.x - } ensuring(res => res == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation7.scala b/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation7.scala deleted file mode 100644 index 9f664837e3cc56cdd78a9daab7b3587f907e9798..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation7.scala +++ /dev/null @@ -1,20 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation7 { - - case class A(a: Int, var x: BigInt, var y: BigInt, var z: BigInt) - - def inc(a: A): Unit = { - require(a.x >= 0 && a.y >= 0 && a.z >= 0) - a.x += 1 - a.y += 1 - a.z += 1 - } ensuring(_ => a.x == old(a).x + 1 && a.y == old(a).y + 1 && a.z == old(a).z + 1) - - def f(): A = { - val a = A(0, 0, 0, 0) - inc(a); inc(a); inc(a) - a - } ensuring(res => res.x == res.y && res.y == res.z && res.z == 3) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation8.scala b/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation8.scala deleted file mode 100644 index eb1d157c4d0936c8f28f37b8b69065e34d811253..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ObjectParamMutation8.scala +++ /dev/null @@ -1,18 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation8 { - - case class A[B](var y: B) - - def update[B](a: A[B], b: B): B = { - a.y = b - a.y - } ensuring(res => res == b) - - def f(): Int = { - val a = A(10) - update(a, 12) - a.y - } ensuring(res => res == 12) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/OldThis1.scala b/src/test/resources/regression/verification/xlang/valid/OldThis1.scala deleted file mode 100644 index 11151fda7d53ba80d07ee11f120dd794c2002cf4..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/OldThis1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import leon.lang._ - -object OldThis1 { - - case class A(var x: Int) { - def foo(y: Int): Unit = { - x += y - } ensuring(_ => x == old(this).x + y) - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/OldThis2.scala b/src/test/resources/regression/verification/xlang/valid/OldThis2.scala deleted file mode 100644 index e0febe010faa0091df0b8658ac5307a69781841b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/OldThis2.scala +++ /dev/null @@ -1,13 +0,0 @@ -import leon.lang._ - -object OldThis2 { - - case class B(var x: Int) - - case class A(b: B) { - def foo(y: Int): Unit = { - b.x += y - } ensuring(_ => b.x == old(this).b.x + y) - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation1.scala b/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation1.scala deleted file mode 100644 index 136752a4e3d0aa84366489fa3553d83500f2f867..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation1.scala +++ /dev/null @@ -1,17 +0,0 @@ -object PatternMatchingAliasingMutation1 { - - abstract class A - case class B(var x: Int) extends A - case class C(var y: Int) extends A - - def updateValue(a: A, newVal: Int): Unit = a match { - case (b: B) => b.x = newVal - case (c: C) => c.y = newVal - } - - def f(): Int = { - val b = B(10) - updateValue(b, 15) - b.x - } ensuring(_ == 15) -} diff --git a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation2.scala b/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation2.scala deleted file mode 100644 index fd8f16bd032660ffa5c484c120e81e8b7aba1280..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation2.scala +++ /dev/null @@ -1,17 +0,0 @@ -object PatternMatchingAliasingMutation2 { - - abstract class A - case class B(var x: Int) extends A - case class C(var y: Int) extends A - - def updateValue(a: A, newVal: Int): Unit = a match { - case b@B(_) => b.x = newVal - case c@C(_) => c.y = newVal - } - - def f(): Int = { - val b = B(10) - updateValue(b, 15) - b.x - } ensuring(_ == 15) -} diff --git a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation3.scala b/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation3.scala deleted file mode 100644 index 17cf06b14105289792afba610189f02966bee360..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation3.scala +++ /dev/null @@ -1,19 +0,0 @@ -object PatternMatchingAliasingMutation3 { - - case class MutableObject(var x: Int) - - abstract class A - case class B(m: MutableObject) extends A - case class C(m: MutableObject) extends A - - def updateValue(a: A, newVal: Int): Unit = a match { - case B(m) => m.x = newVal - case C(m) => m.x = newVal - } - - def f(): Int = { - val b = B(MutableObject(10)) - updateValue(b, 15) - b.m.x - } ensuring(_ == 15) -} diff --git a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation4.scala b/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation4.scala deleted file mode 100644 index 1829b5c51f1570ff528efb3cd05aafddcb2dee6f..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation4.scala +++ /dev/null @@ -1,28 +0,0 @@ -object PatternMatchingAliasingMutation4 { - - case class A(var x: Int) - - abstract class List - case class Cons(a: A, tail: List) extends List - case class Nil() extends List - - def rec(l: List): Unit = (l match { - case Cons(a, as) => - a.x = 0 - rec(as) - case Nil() => - () - }) ensuring(_ => allZero(l)) - - def allZero(l: List): Boolean = l match { - case Cons(a, tail) => a.x == 0 && allZero(tail) - case Nil() => true - } - - def test(): List = { - val l = Cons(A(2), Cons(A(1), Cons(A(0), Nil()))) - rec(l) - l - } ensuring(l => allZero(l)) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation5.scala b/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation5.scala deleted file mode 100644 index 0d415a3fa4adcbd2d67781d6d6f1eab565e6161a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/PatternMatchingAliasingMutation5.scala +++ /dev/null @@ -1,31 +0,0 @@ -object PatternMatchingAliasingMutation5 { - - case class A(var x: Int) - - abstract class List - case class Cons(a: A, tail: List) extends List - case class Nil() extends List - - def rec(l: List, i: BigInt): Unit = { - require(allZero(l) && i >= 0) - l match { - case Cons(a, as) => - if(i % 2 == 0) - a.x = 1 - rec(as, i + 1) - case Nil() => - () - } - } ensuring(_ => allZeroOrOne(l)) - - def allZeroOrOne(l: List): Boolean = l match { - case Cons(a, tail) => (a.x == 0 || a.x == 1) && allZeroOrOne(tail) - case Nil() => true - } - - def allZero(l: List): Boolean = l match { - case Cons(a, tail) => a.x == 0 && allZero(tail) - case Nil() => true - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Sequencing1.scala b/src/test/resources/regression/verification/xlang/valid/Sequencing1.scala deleted file mode 100644 index 238b9273e2ca866942869c4d8b47812ee85154c5..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Sequencing1.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Sequencing1 { - - def test(): Int = { - var x = 0 - x += 1 - x *= 2 - x - } ensuring(x => x == 2) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Sequencing2.scala b/src/test/resources/regression/verification/xlang/valid/Sequencing2.scala deleted file mode 100644 index f8f774fee1524f78a4d0beba5462bd11518ba473..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Sequencing2.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Sequencing2 { - - def test(): Int = { - var x = 0 - x += 5 - x *= 10 - x - } ensuring(x => x == 50) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Sequencing3.scala b/src/test/resources/regression/verification/xlang/valid/Sequencing3.scala deleted file mode 100644 index 937938bc72ffcbdf823d60d7d5c29ff3d14474cc..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Sequencing3.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Sequencing3 { - - def f(x: Int): Int = { - require(x < 10) - x - } - - def test(): Int = { - var x = 0 - f(x) - x += 5 - f(x) - x += 5 - - x - } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Sequencing4.scala b/src/test/resources/regression/verification/xlang/valid/Sequencing4.scala deleted file mode 100644 index ef870c612d7adef244df84885ba96ab0c2718cf9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Sequencing4.scala +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Sequencing4 { - - def test(): Int = { - var x = 5 - - {x = x + 1; x} + {x = x * 2; x} - - } ensuring(res => res == 18) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Sequencing5.scala b/src/test/resources/regression/verification/xlang/valid/Sequencing5.scala deleted file mode 100644 index 7c904de5fe1e244cf91d4d9b6d1a4a895b7689c3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Sequencing5.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Sequencing5 { - - - def test(): (Int, Int, Int) = { - var x = 5 - - ( - {x = x + 1; x}, - {x = x * 2; x}, - {x = x - 1; x} - ) - - } ensuring(res => res._1 == 6 && res._2 == 12 && res._3 == 11) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Sequencing6.scala b/src/test/resources/regression/verification/xlang/valid/Sequencing6.scala deleted file mode 100644 index 7822e71484d53dc524969a4bcc9da0ef56d58291..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Sequencing6.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Sequencing6 { - - def f(x1: Int, x2: Int, x3: Int): Int = { - require(x1 == 6 && x2 == 12 && x3 == 11) - x3 - } - - def test(): Int = { - var x = 5 - - f( - {x = x + 1; x}, - {x = x * 2; x}, - {x = x - 1; x} - ) - - x - - } ensuring(res => res == 11) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Sequencing7.scala b/src/test/resources/regression/verification/xlang/valid/Sequencing7.scala deleted file mode 100644 index 1c028d617bed8f4362301ababad157f89eccebb6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Sequencing7.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -package test.resources.regression.verification.xlang.valid - -object Sequencing7 { - - - def test(): Int = { - var x = 5 - - {x = x + 1; x} - {x = x * 2; x} - {x = x - 1; x} - - x - - } ensuring(res => res == 11) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/Sequencing8.scala b/src/test/resources/regression/verification/xlang/valid/Sequencing8.scala deleted file mode 100644 index b4db8fcf24d3eabcdf92a2d2070dd43c0f924d63..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/Sequencing8.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Sequencing8 { - - def test(): Int = { - var x = 5 - - (x = x + 1, (x = x * 2, (x = x - 1, x = x * 2))) - - x - } ensuring(res => res == 22) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/ShortCircuit.scala b/src/test/resources/regression/verification/xlang/valid/ShortCircuit.scala deleted file mode 100644 index b3df2c796856ea1b096fdfdf81adc9e15b4a663b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/ShortCircuit.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -object ShortCircuit { - - def negate(a: Boolean) = { - var b = true - a && { b = false; true } - b - } ensuring { res => res != a } - - def negateOr(a: Boolean) = { - var b = false - a || { b = true; true } - b - } ensuring { res => res != a } - -} diff --git a/src/test/resources/regression/verification/xlang/valid/StdIn1.scala b/src/test/resources/regression/verification/xlang/valid/StdIn1.scala deleted file mode 100644 index 1fad9efd665b9660d82585519e6c2de30b786947..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/StdIn1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import leon.io._ - -object StdIn1 { - - def abs: BigInt = { - implicit val state = StdIn.newState - val n = StdIn.readBigInt - if(n < 0) -n else n - } ensuring(_ >= 0) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/While1.scala b/src/test/resources/regression/verification/xlang/valid/While1.scala deleted file mode 100644 index 6cff049de628c82de6986aff35cf464670d8f891..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/While1.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object While1 { - - def foo(): Int = { - var a = 0 - var i = 0 - while(i < 10) { - a = a + 1 - i = i + 1 - } - a - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/While2.scala b/src/test/resources/regression/verification/xlang/valid/While2.scala deleted file mode 100644 index 93a56017752bec41d0b95d88d288001a258a7e2b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/While2.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object While2 { - - def foo(): Int = { - var a = 0 - var i = 0 - while(i < 10) { - a = a + i - i = i + 1 - } - a - } ensuring(_ == 45) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/While3.scala b/src/test/resources/regression/verification/xlang/valid/While3.scala deleted file mode 100644 index e3283cfe2ad59f1fc097a03da433498831cc9f1b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/While3.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object While3 { - - def foo(): Int = { - var a = 0 - var i = 0 - while({i = i+2; i <= 10}) { - a = a + i - i = i - 1 - } - a - } ensuring(_ == 54) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/WhileAsFun1.scala b/src/test/resources/regression/verification/xlang/valid/WhileAsFun1.scala deleted file mode 100644 index 60a7e9737bbe6dbae8328937dff1b530000085f8..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/WhileAsFun1.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object WhileAsFun1 { - - - def counterN(n: Int): Int = { - require(n > 0) - - var i = 0 - def rec(): Unit = { - require(i >= 0 && i <= n) - if(i < n) { - i += 1 - rec() - } else { - () - } - } ensuring(_ => i >= 0 && i <= n && i >= n) - rec() - - i - } ensuring(_ == n) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/WhileAsFun2.scala b/src/test/resources/regression/verification/xlang/valid/WhileAsFun2.scala deleted file mode 100644 index 01d0ea6350b33fb8373678c5e607f5327b93b12e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/WhileAsFun2.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ - -object WhileAsFun2 { - - - def counterN(n: Int): Int = { - require(n > 0) - - var counter = 0 - - def inc(): Unit = { - counter += 1 - } - - var i = 0 - def rec(): Unit = { - require(i >= 0 && counter == i && i <= n) - if(i < n) { - inc() - i += 1 - rec() - } else { - () - } - } ensuring(_ => i >= 0 && counter == i && i <= n && i >= n) - rec() - - - counter - } ensuring(_ == n) - -} diff --git a/src/test/resources/regression/verification/xlang/valid/WhileConditionSubexpression.scala b/src/test/resources/regression/verification/xlang/valid/WhileConditionSubexpression.scala deleted file mode 100644 index d53d4d2bc76f809f6469eb767f7a2364f8517dbd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/verification/xlang/valid/WhileConditionSubexpression.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.lang._ -import leon.collection._ -import leon._ - -import leon.lang._ - -object WhileConditionSubexpression { - - def test(x: Int): Boolean = { - var b = false - var i = 0 - while(!b && i < 10) { - if(i == x) - b = true - i += 1 - } - b - } ensuring(res => res || (x != 0 && x != 1 && x != 2)) - -} diff --git a/src/test/resources/regression/xlang/error/Array1.scala b/src/test/resources/regression/xlang/error/Array1.scala deleted file mode 100644 index 4f1f6a6ff8b922a8222effba67bed3b1c1adb847..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/Array1.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object Array1 { - - def foo(): Int = { - (Array.fill(5)(5))(2) = 3 - 0 - } - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing1.scala b/src/test/resources/regression/xlang/error/ArrayAliasing1.scala deleted file mode 100644 index 30b1652dac16f1f8a9c7b36d83d9a0a52811e3c6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing1.scala +++ /dev/null @@ -1,13 +0,0 @@ -import leon.lang._ - -object ArrayAliasing1 { - - def f1(): BigInt = { - val a = Array.fill(10)(BigInt(0)) - val b = a - b(0) = 10 - a(0) - } ensuring(_ == 10) - -} - diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing10.scala b/src/test/resources/regression/xlang/error/ArrayAliasing10.scala deleted file mode 100644 index 05737b03d9816be72cf52f4913f57a482abf76dd..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing10.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2009-2015 EPFL, Lausanne */ - -object ArrayAliasing10 { - - def foo(): Int = { - val a = Array.fill(5)(0) - - def rec(): Array[Int] = { - - def nestedRec(): Array[Int] = { - a - } - nestedRec() - } - val b = rec() - b(0) - } - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing2.scala b/src/test/resources/regression/xlang/error/ArrayAliasing2.scala deleted file mode 100644 index 4e906865a8848aaa00150c67de16f6b32136c64a..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing2.scala +++ /dev/null @@ -1,11 +0,0 @@ -import leon.lang._ - -object ArrayAliasing2 { - - def f1(a: Array[BigInt]): BigInt = { - val b = a - b(0) = 10 - a(0) - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing3.scala b/src/test/resources/regression/xlang/error/ArrayAliasing3.scala deleted file mode 100644 index 0398fc37b9dc2028e1535878ec377bef1620dd88..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing3.scala +++ /dev/null @@ -1,11 +0,0 @@ -import leon.lang._ - -object ArrayAliasing3 { - - def f1(a: Array[BigInt], b: Boolean): BigInt = { - val c = if(b) a else Array[BigInt](1,2,3,4,5) - c(0) = 10 - a(0) - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing4.scala b/src/test/resources/regression/xlang/error/ArrayAliasing4.scala deleted file mode 100644 index 2632782c39e853744744b66309ef10342bee386b..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing4.scala +++ /dev/null @@ -1,11 +0,0 @@ -import leon.lang._ - -object ArrayAliasing4 { - - def f1(a: Array[BigInt]): Array[BigInt] = { - require(a.length > 0) - a(0) = 10 - a - } ensuring(res => res(0) == 10) - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing5.scala b/src/test/resources/regression/xlang/error/ArrayAliasing5.scala deleted file mode 100644 index b9363d1ab5a627df29e6a0f0018c73850dcbb529..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing5.scala +++ /dev/null @@ -1,18 +0,0 @@ -import leon.lang._ - -object ArrayAliasing5 { - - - def f1(a: Array[BigInt], b: Array[BigInt]): Unit = { - require(a.length > 0 && b.length > 0) - a(0) = 10 - b(0) = 20 - } ensuring(_ => a(0) == 10 && b(0) == 20) - - - def callWithAliases(): Unit = { - val a = Array[BigInt](0,0,0,0) - f1(a, a) - } - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing6.scala b/src/test/resources/regression/xlang/error/ArrayAliasing6.scala deleted file mode 100644 index 660c98f3c4d0433c3e5889cadefab7233847b0d3..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing6.scala +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object ArrayAliasing6 { - - def foo(a: Array[Int]): Array[Int] = { - a - } - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing7.scala b/src/test/resources/regression/xlang/error/ArrayAliasing7.scala deleted file mode 100644 index 21bc94502327b334f2e4e5887d4a7286731c78b7..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing7.scala +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2009-2015 EPFL, Lausanne */ - -object ArrayAliasing7 { - - def foo(a: Array[Int]): Array[Int] = { - val b = a - b - } - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing8.scala b/src/test/resources/regression/xlang/error/ArrayAliasing8.scala deleted file mode 100644 index c466d456457e3c3eada4087286e964a965dc6c01..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing8.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object ArrayAliasing8 { - - def foo(a: Array[Int]): Int = { - def rec(): Array[Int] = { - a - } - val b = rec() - b(0) - } - -} diff --git a/src/test/resources/regression/xlang/error/ArrayAliasing9.scala b/src/test/resources/regression/xlang/error/ArrayAliasing9.scala deleted file mode 100644 index 72d26d87a8a0732d131acc07182b8ed44ac4d4a9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayAliasing9.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -object ArrayAliasing9 { - - def foo(): Int = { - val a = Array.fill(5)(0) - def rec(): Array[Int] = { - a - } - val b = rec() - b(0) - } - -} diff --git a/src/test/resources/regression/xlang/error/ArrayConstructor1.scala b/src/test/resources/regression/xlang/error/ArrayConstructor1.scala deleted file mode 100644 index 2d050baf494278ce8242d635895e535bca626844..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ArrayConstructor1.scala +++ /dev/null @@ -1,17 +0,0 @@ -object ArrayConstructor1 { - - case class A(var x: BigInt) - - def foo(table: Array[A], a: A): Unit = { - a.x = 10 - } - - def test(): Unit = { - val a = A(0) - val t = Array(a, A(0), A(0)) - foo(t, a) - assert(t(0).x == a.x) - } - - -} diff --git a/src/test/resources/regression/xlang/error/GlobalMutableField1.scala b/src/test/resources/regression/xlang/error/GlobalMutableField1.scala deleted file mode 100644 index d1d7154b1beebb075d737e4f6946c9be2514ef01..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/GlobalMutableField1.scala +++ /dev/null @@ -1,15 +0,0 @@ -import leon.lang._ -import leon.util.Random - -object GlobalMutableField1 { - - case class A(var x: BigInt) - - val a: A = A(10) - - - def update(): Unit = { - a.x = a.x + 1 - } - -} diff --git a/src/test/resources/regression/xlang/error/GlobalMutableField2.scala b/src/test/resources/regression/xlang/error/GlobalMutableField2.scala deleted file mode 100644 index 353c54ff2b86760c1e3f4e203fc6a37f2fd07792..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/GlobalMutableField2.scala +++ /dev/null @@ -1,14 +0,0 @@ -import leon.lang._ -import leon.util.Random - -object GlobalMutableField2 { - - val seed: Random.State = Random.State(0) - - val t = T(Random.nextBigInt(seed)) - - case class T(n:BigInt) { - require(n >= 0) - } - -} diff --git a/src/test/resources/regression/xlang/error/MutableFieldAliasing1.scala b/src/test/resources/regression/xlang/error/MutableFieldAliasing1.scala deleted file mode 100644 index 1d3e7ed03fdf778f52b12912521e9436c0d88e2e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/MutableFieldAliasing1.scala +++ /dev/null @@ -1,22 +0,0 @@ -import leon.lang._ - -object MutableFieldAliasing1 { - - case class A(var x: Int) - case class B(a: A) - - def f1(): Int = { - val b1 = B(A(10)) - val b2 = b1 - b2.a.x = 15 - b1.a.x - } ensuring(_ == 15) - - - def build(x: Int): B = { - val a = A(x) - B(a) - } - -} - diff --git a/src/test/resources/regression/xlang/error/MutableFieldAliasing2.scala b/src/test/resources/regression/xlang/error/MutableFieldAliasing2.scala deleted file mode 100644 index af5e7e24ceda8efcbe2f35e5d3d22bd1eacc3dc9..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/MutableFieldAliasing2.scala +++ /dev/null @@ -1,17 +0,0 @@ -object MutableFieldAliasing2 { - - case class A(var x: BigInt) - case class B(a: A) - - def foo(a: A, b: B): Unit = { - a.x = 10 - } - - def test(): Unit = { - val a = A(0) - val b = B(a) //shouldn't be allowed, create a shared reference - foo(a, b) //showcase the issue created by the above, foo get two objects that share some data - assert(a.x == b.a.x) //Leon concludes this is INVALID, but due to reference this should be VALID - } - -} diff --git a/src/test/resources/regression/xlang/error/MutableFieldAliasing3.scala b/src/test/resources/regression/xlang/error/MutableFieldAliasing3.scala deleted file mode 100644 index cf95cae86ad300e88c4436a13f575ac02f3c50aa..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/MutableFieldAliasing3.scala +++ /dev/null @@ -1,17 +0,0 @@ -object MutableFieldAliasing3 { - - case class A(var x: BigInt) - case class B(a: A, y: BigInt) - - def foo(a: A, b: B): Unit = { - a.x = 10 - } - - def test(): Unit = { - val a = A(0) - val b = B(a, 0) //shouldn't be allowed, create a shared reference - foo(a, b) //showcase the issue created by the above, foo get two objects that share some data - assert(a.x == b.a.x) //Leon concludes this is INVALID, but due to reference this should be VALID - } - -} diff --git a/src/test/resources/regression/xlang/error/MutableFieldAliasing4.scala b/src/test/resources/regression/xlang/error/MutableFieldAliasing4.scala deleted file mode 100644 index 9d2b7af5a1e06c89354614e8562b3e009aadfd12..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/MutableFieldAliasing4.scala +++ /dev/null @@ -1,17 +0,0 @@ -object MutableFieldAliasing4 { - - case class A(var x: BigInt) - case class B(a: A, f: (A) => BigInt) - - def foo(a: A, b: B): Unit = { - a.x = 10 - } - - def test(): Unit = { - val a = A(0) - val b = B(a, (x: A) => { x.x += 1; x.x }) - foo(a, b) - assert(a.x == b.a.x) - } - -} diff --git a/src/test/resources/regression/xlang/error/NestedFunctionAliasing1.scala b/src/test/resources/regression/xlang/error/NestedFunctionAliasing1.scala deleted file mode 100644 index 12feace5413c23e688ac194192482120793b4e24..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/NestedFunctionAliasing1.scala +++ /dev/null @@ -1,17 +0,0 @@ -import leon.lang._ - -object NestedFunctinAliasing1 { - - def f(): Int = { - val a = Array(1,2,3,4) - - def g(b: Array[Int]): Unit = { - require(b.length > 0 && a.length > 0) - b(0) = 10 - a(0) = 17 - } ensuring(_ => b(0) == 10) - - g(a) - a(0) - } ensuring(_ == 10) -} diff --git a/src/test/resources/regression/xlang/error/NestedFunctionAliasing2.scala b/src/test/resources/regression/xlang/error/NestedFunctionAliasing2.scala deleted file mode 100644 index 81a9b82b39fb47af105ef2e3122fe86a8b10dbb6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/NestedFunctionAliasing2.scala +++ /dev/null @@ -1,17 +0,0 @@ -import leon.lang._ - -object NestedFunctinAliasing1 { - - def f(a: Array(1,2,3,4)): Int = { - - def g(b: Array[Int]): Unit = { - require(b.length > 0 && a.length > 0) - b(0) = 10 - a(0) = 17 - } ensuring(_ => b(0) == 10) - - g(a) - a(0) - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/xlang/error/ObjectAliasing1.scala b/src/test/resources/regression/xlang/error/ObjectAliasing1.scala deleted file mode 100644 index 7634e1071e032719cbe6179300bc9dea50f11fc6..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ObjectAliasing1.scala +++ /dev/null @@ -1,15 +0,0 @@ -import leon.lang._ - -object ObjectAliasing1 { - - case class A(var x: Int) - - def f1(): Int = { - val a = A(10) - val b = a - b.x = 15 - a.x - } ensuring(_ == 15) - -} - diff --git a/src/test/resources/regression/xlang/error/ObjectAliasing2.scala b/src/test/resources/regression/xlang/error/ObjectAliasing2.scala deleted file mode 100644 index af39dba1e7612f64c0f1926d39f2fe601b2b36ae..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ObjectAliasing2.scala +++ /dev/null @@ -1,13 +0,0 @@ -import leon.lang._ - -object ObjectAliasing2 { - - case class A(var x: Int) - - def f1(a: A): Int = { - val b = a - b.x = 10 - a.x - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/xlang/error/ObjectAliasing3.scala b/src/test/resources/regression/xlang/error/ObjectAliasing3.scala deleted file mode 100644 index 9d419ea95e6e84d5f7b63f81cb2df5359ebe1711..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ObjectAliasing3.scala +++ /dev/null @@ -1,13 +0,0 @@ -import leon.lang._ - -object ObjectAliasing3 { - - case class A(var x: Int) - - def f1(a: A, b: Boolean): Int = { - val c = if(b) a else A(42) - c.x = 10 - a.x - } ensuring(_ == 10) - -} diff --git a/src/test/resources/regression/xlang/error/ObjectAliasing4.scala b/src/test/resources/regression/xlang/error/ObjectAliasing4.scala deleted file mode 100644 index 81cabf97be708e715245a27fb735e1a88ee00e82..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ObjectAliasing4.scala +++ /dev/null @@ -1,12 +0,0 @@ -import leon.lang._ - -object ObjectAliasing4 { - - case class A(var x: Int) - - def f1(a: A): A = { - a.x = 10 - a - } ensuring(res => res.x == 10) - -} diff --git a/src/test/resources/regression/xlang/error/ObjectAliasing5.scala b/src/test/resources/regression/xlang/error/ObjectAliasing5.scala deleted file mode 100644 index c94656fdb9fba7d52b8eef76a7acb547682a2cdc..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ObjectAliasing5.scala +++ /dev/null @@ -1,12 +0,0 @@ -import leon.lang._ - -object ObjectAliasing5 { - - case class A(var x: Int) - case class B(a: A) - - def f1(b: B): A = { - b.a - } - -} diff --git a/src/test/resources/regression/xlang/error/ObjectAliasing6.scala b/src/test/resources/regression/xlang/error/ObjectAliasing6.scala deleted file mode 100644 index 793b9815d35635ae7539268e9b2d8878bc6a985d..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ObjectAliasing6.scala +++ /dev/null @@ -1,14 +0,0 @@ -import leon.lang._ - -object ObjectAliasing6 { - - case class A(var x: Int) - case class B(a: A) - - def f1(b: B): Int = { - val a = b.a - a.x = 12 - b.a.x - } ensuring(_ == 12) - -} diff --git a/src/test/resources/regression/xlang/error/ObjectAliasing7.scala b/src/test/resources/regression/xlang/error/ObjectAliasing7.scala deleted file mode 100644 index ea28fa5bb2e01970d64c0259fc4c8d97a6878584..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/error/ObjectAliasing7.scala +++ /dev/null @@ -1,22 +0,0 @@ -package test.resources.regression.xlang.error - -import leon.lang._ - -object ObjectAliasing7 { - - case class A(var x: Int) - case class B(a: A) - - def f1(a1: A, a2: A): Int = { - val tmp = a1.x - a2.x = a1.x - a1.x = tmp - a1.x + a2.x - } - - def f(): Int = { - val b = B(A(10)) - f1(b.a, b.a) - } ensuring(_ == 20) - -} diff --git a/src/test/resources/regression/xlang/passing/ArrayMutableElements1.scala b/src/test/resources/regression/xlang/passing/ArrayMutableElements1.scala deleted file mode 100644 index cbc3aeb5d338fca374af9a59dc917f6639a1cce0..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/passing/ArrayMutableElements1.scala +++ /dev/null @@ -1,17 +0,0 @@ -object ArrayMutableElements1 { - - case class A(var x: BigInt) - - def foo(table: Array[A], a: A): Unit = { - a.x = 10 - } - - def test(): Unit = { - val a = A(0) - val t = Array(A(0), A(0), A(0)) - foo(t, a) - assert(t(0).x != a.x) - } - - -} diff --git a/src/test/resources/regression/xlang/passing/Datatypes.scala b/src/test/resources/regression/xlang/passing/Datatypes.scala deleted file mode 100644 index feea22f60e16168d1bbf4c281e4baacb9feca818..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/passing/Datatypes.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2009-2016 EPFL, Lausanne */ - -import leon.annotation._ -import leon.lang._ - -object Datatypes { - - sealed abstract class Foo[A] - sealed abstract class Bar[C] extends Foo[C] - case class Baz[B](underlying: B, rest: Baz[B]) extends Bar[B] - case class FooNil[D]() extends Foo[D] - - def dest[B](baz1: Baz[B], baz2: Baz[B]) = { - require(baz1 == baz2) - baz1.underlying == baz2.underlying - } holds - - def intro_dest[B](baz1: Baz[B], baz2: Baz[B], b1: B, b2: B) = { - require(b1 == b2) - val x1 = Baz(b1, baz1) - val x2 = Baz(b2, baz2) - x1.underlying == x2.underlying - } holds - - def pm[A](foo: Foo[A]) = (foo match { - case Baz(x, y) => true - case FooNil() => true - }) holds - - def pm2[A](foo: Foo[A]) = (foo match { - case Baz(x, y) => true - case z: FooNil[A] => true - }) holds - - def pm3[A](int: BigInt) = (int match { - case BigInt(0) => true - case n => true - }) holds - - def pm4[A](int: BigInt) = (int match { - case BigInt(0) => true - case n if false => true - case n => true - }) holds - -} diff --git a/src/test/resources/regression/xlang/passing/FunctionCaching.scala b/src/test/resources/regression/xlang/passing/FunctionCaching.scala deleted file mode 100644 index 322cb592ee44a65add6f1eed42ba8fea7fba4155..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/passing/FunctionCaching.scala +++ /dev/null @@ -1,40 +0,0 @@ -import leon.lang._ -import leon.collection._ - -object FunctionCaching { - - case class FunCache(var cached: Map[BigInt, BigInt]) - - def fun(x: BigInt)(implicit funCache: FunCache): BigInt = { - funCache.cached.get(x) match { - case None() => - val res = 2*x + 42 - funCache.cached = funCache.cached.updated(x, res) - res - case Some(cached) => - cached - } - } ensuring(res => old(funCache).cached.get(x) match { - case None() => true - case Some(v) => v == res - }) - - def funProperlyCached(x: BigInt, trash: List[BigInt]): Boolean = { - implicit val cache = FunCache(Map()) - val res1 = fun(x) - multipleCalls(trash, x) - val res2 = fun(x) - res1 == res2 - } holds - - def multipleCalls(args: List[BigInt], x: BigInt)(implicit funCache: FunCache): Unit = { - require(funCache.cached.get(x).forall(_ == 2*x + 42)) - args match { - case Nil() => () - case y::ys => - fun(y) - multipleCalls(ys, x) - } - } ensuring(_ => funCache.cached.get(x).forall(_ == 2*x + 42)) - -} diff --git a/src/test/resources/regression/xlang/passing/FunctionCachingInvalid.scala b/src/test/resources/regression/xlang/passing/FunctionCachingInvalid.scala deleted file mode 100644 index 07a889f780cd1ab911fc072a92d5508f17de2579..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/passing/FunctionCachingInvalid.scala +++ /dev/null @@ -1,33 +0,0 @@ -import leon.lang._ -import leon.collection._ - -object FunctionCachingInvalid { - - case class FunCache(var cached: Map[BigInt, BigInt]) - - def fun(x: BigInt)(implicit funCache: FunCache): BigInt = { - funCache.cached.get(x) match { - case None() => - val res = 2*x + 42 - funCache.cached = funCache.cached.updated(x, res) - res - case Some(cached) => - cached + 1 - } - } - - def funWronglyCached(x: BigInt, trash: List[BigInt]): Boolean = { - implicit val cache = FunCache(Map()) - val res1 = fun(x) - multipleCalls(trash) - val res2 = fun(x) - res1 == res2 - } holds - - - def multipleCalls(args: List[BigInt])(implicit funCache: FunCache): Unit = args match { - case Nil() => () - case x::xs => fun(x); multipleCalls(xs) - } - -} diff --git a/src/test/resources/regression/xlang/passing/ObjectParamMutation1.scala b/src/test/resources/regression/xlang/passing/ObjectParamMutation1.scala deleted file mode 100644 index b36fd6f1a3a59864c5cca195f17264b382b6652e..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/passing/ObjectParamMutation1.scala +++ /dev/null @@ -1,18 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation1 { - - case class A(var y: Int) - - def update(a: A): Int = { - a.y = 12 - a.y - } ensuring(res => res == 12) - - def f(): Int = { - val a = A(10) - update(a) - a.y - } ensuring(res => res == 12) - -} diff --git a/src/test/resources/regression/xlang/passing/ObjectParamMutation7.scala b/src/test/resources/regression/xlang/passing/ObjectParamMutation7.scala deleted file mode 100644 index 9f664837e3cc56cdd78a9daab7b3587f907e9798..0000000000000000000000000000000000000000 --- a/src/test/resources/regression/xlang/passing/ObjectParamMutation7.scala +++ /dev/null @@ -1,20 +0,0 @@ -import leon.lang._ - -object ObjectParamMutation7 { - - case class A(a: Int, var x: BigInt, var y: BigInt, var z: BigInt) - - def inc(a: A): Unit = { - require(a.x >= 0 && a.y >= 0 && a.z >= 0) - a.x += 1 - a.y += 1 - a.z += 1 - } ensuring(_ => a.x == old(a).x + 1 && a.y == old(a).y + 1 && a.z == old(a).z + 1) - - def f(): A = { - val a = A(0, 0, 0, 0) - inc(a); inc(a); inc(a) - a - } ensuring(res => res.x == res.y && res.y == res.z && res.z == 3) - -}