diff --git a/testcases/verification/PropositionalLogic.scala b/testcases/verification/PropositionalLogic.scala index ececf099804ff93410df1753a27963a6aa8bbfa8..e0acdb6fe543af05befad45198a551779e7b7d51 100644 --- a/testcases/verification/PropositionalLogic.scala +++ b/testcases/verification/PropositionalLogic.scala @@ -1,8 +1,7 @@ -import scala.collection.immutable.Set import leon.lang._ import leon.annotation._ -object PropositionalLogic { +object PropositionalLogic { sealed abstract class Formula case class And(lhs: Formula, rhs: Formula) extends Formula @@ -11,12 +10,12 @@ object PropositionalLogic { case class Not(f: Formula) extends Formula case class Literal(id: Int) extends Formula - def size(f : Formula) : Int = (f match { + 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 + case _ => BigInt(1) }) def simplify(f: Formula): Formula = (f match { @@ -24,10 +23,16 @@ object PropositionalLogic { 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 _ => 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)) @@ -39,21 +44,50 @@ object PropositionalLogic { case Not(Not(f)) => nnf(f) case Not(Literal(_)) => formula case Literal(_) => formula - case _ => formula - }) ensuring((res) => size(res) <= 2*size(formula) - 1) - - def nnfSimplify(f: Formula): Formula = { - simplify(nnf(f)) - } //ensuring((res) => size(res) <= 2*size(f) - 1) - -// 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) -// } -// } + }) ensuring(res => isNNF(res) && size(res) <= 2*size(formula) - 1) + + 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/testcases/verification/scala2013/Sorting.scala b/testcases/verification/algorithms/Sorting.scala similarity index 100% rename from testcases/verification/scala2013/Sorting.scala rename to testcases/verification/algorithms/Sorting.scala diff --git a/testcases/verification/scala2013/AssociativeList.scala b/testcases/verification/datastructures/AssociativeList.scala similarity index 75% rename from testcases/verification/scala2013/AssociativeList.scala rename to testcases/verification/datastructures/AssociativeList.scala index 3b4e954a87a07a7bfb128427d20454d36d4435eb..36ec44a27c38329d56a9c5f02362d43a6ce2343e 100644 --- a/testcases/verification/scala2013/AssociativeList.scala +++ b/testcases/verification/datastructures/AssociativeList.scala @@ -3,22 +3,22 @@ import leon.annotation._ object AssociativeList { sealed abstract class KeyValuePairAbs - case class KeyValuePair(key: Int, value: Int) extends KeyValuePairAbs + case class KeyValuePair(key: BigInt, value: BigInt) 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 Some(i: BigInt) extends OptionInt case class None() extends OptionInt - def domain(l: List): Set[Int] = l match { - case Nil() => Set.empty[Int] + def domain(l: List): Set[BigInt] = l match { + case Nil() => Set.empty[BigInt] case Cons(KeyValuePair(k,_), xs) => Set(k) ++ domain(xs) } - def find(l: List, e: Int): OptionInt = l match { + def find(l: List, e: BigInt): OptionInt = l match { case Nil() => None() case Cons(KeyValuePair(k, v), xs) => if (k == e) Some(v) else find(xs, e) } @@ -39,11 +39,11 @@ object AssociativeList { 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) + case KeyValuePair(k, v) => domain(res) == domain(l) ++ Set[BigInt](k) }) @induct - def readOverWrite(l: List, k1: Int, k2: Int, e: Int) : Boolean = { + def readOverWrite(l: List, k1: BigInt, k2: BigInt, e: BigInt) : Boolean = { find(updateElem(l, KeyValuePair(k2,e)), k1) == (if (k1 == k2) Some(e) else find(l, k1)) } holds } diff --git a/testcases/verification/scala2013/SearchLinkedList.scala b/testcases/verification/datastructures/SearchLinkedList.scala similarity index 100% rename from testcases/verification/scala2013/SearchLinkedList.scala rename to testcases/verification/datastructures/SearchLinkedList.scala diff --git a/testcases/verification/scala2013/AmortizedQueue.scala b/testcases/verification/scala2013/AmortizedQueue.scala deleted file mode 100644 index 467a39d4865c7433c9ecf92704a09e1400ecd71d..0000000000000000000000000000000000000000 --- a/testcases/verification/scala2013/AmortizedQueue.scala +++ /dev/null @@ -1,123 +0,0 @@ -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) : Int = (list match { - case Nil() => 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/testcases/verification/scala2013/ListOperations.scala b/testcases/verification/scala2013/ListOperations.scala deleted file mode 100644 index 157c6b978eb4c2b1f5c2f9e7091f81b081d0fb01..0000000000000000000000000000000000000000 --- a/testcases/verification/scala2013/ListOperations.scala +++ /dev/null @@ -1,106 +0,0 @@ -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) : 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)) - - 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/testcases/verification/scala2013/PropositionalLogic.scala b/testcases/verification/scala2013/PropositionalLogic.scala deleted file mode 100644 index efc8f8f87b468b9b7a1283e3476a901e1cb32a2a..0000000000000000000000000000000000000000 --- a/testcases/verification/scala2013/PropositionalLogic.scala +++ /dev/null @@ -1,85 +0,0 @@ -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/testcases/verification/scala2013/RedBlackTree.scala b/testcases/verification/scala2013/RedBlackTree.scala deleted file mode 100644 index a65cc1f0fac091ba639cdca983c3ccaeb2540ed8..0000000000000000000000000000000000000000 --- a/testcases/verification/scala2013/RedBlackTree.scala +++ /dev/null @@ -1,116 +0,0 @@ -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) : Int = (t match { - case Empty() => 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) : Int = 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: 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 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: Int, 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 buggyAdd(x: Int, t: Tree): Tree = { - require(redNodesHaveBlackChildren(t)) - ins(x, t) - } ensuring (res => content(res) == content(t) ++ Set(x) && redNodesHaveBlackChildren(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 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)))// && redDescHaveBlackChildren(res)) -} diff --git a/testcases/verification/scala2013/SumAndMaxImp.scala b/testcases/verification/scala2013/SumAndMaxImp.scala deleted file mode 100644 index 37765f620200fe87abe0b7fc1d6e0cd015098a7b..0000000000000000000000000000000000000000 --- a/testcases/verification/scala2013/SumAndMaxImp.scala +++ /dev/null @@ -1,36 +0,0 @@ -import leon.lang._ - -object SumAndMaxImp { - - def isPositive(a: Array[Int], size: Int): Boolean = { - require(a.length >= 0 && size <= a.length) - def rec(i: Int): Boolean = { - require(i >= 0) - if(i >= size) - true - else { - if(a(i) < 0) - false - else - rec(i+1) - } - } - rec(0) - } - - /* VSTTE 2010 challenge 1 */ - def maxSum(a: Array[Int]): (Int, Int) = { - require(a.length >= 0 && isPositive(a, a.length)) - 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) - -} diff --git a/testcases/verification/scala2013/AmortizedQueueImp.scala b/testcases/verification/xlang/AmortizedQueue.scala similarity index 100% rename from testcases/verification/scala2013/AmortizedQueueImp.scala rename to testcases/verification/xlang/AmortizedQueue.scala diff --git a/testcases/verification/scala2013/Arithmetic.scala b/testcases/verification/xlang/Arithmetic.scala similarity index 100% rename from testcases/verification/scala2013/Arithmetic.scala rename to testcases/verification/xlang/Arithmetic.scala diff --git a/testcases/verification/scala2013/AssociativeListImp.scala b/testcases/verification/xlang/AssociativeList.scala similarity index 100% rename from testcases/verification/scala2013/AssociativeListImp.scala rename to testcases/verification/xlang/AssociativeList.scala diff --git a/testcases/verification/scala2013/ListOperationsImp.scala b/testcases/verification/xlang/ListOperations.scala similarity index 100% rename from testcases/verification/scala2013/ListOperationsImp.scala rename to testcases/verification/xlang/ListOperations.scala