Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data-structures/amortized-queue1/AmortizedQueue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import stainless.equations._

abstract class Queue[A] {

def enqueue(a: A): Queue[A] = (??? : Queue[A])
def enqueue(a: A): Queue[A] = AbstractMethodBody[Queue[A]]()
.ensuring(res =>
res.toList == this.toList ++ List(a))

def dequeue: Option[(A, Queue[A])] = (??? : Option[(A, Queue[A])])
def dequeue: Option[(A, Queue[A])] = AbstractMethodBody[Option[(A, Queue[A])]]()
.ensuring(res => res match {
case None() => this.toList == Nil[A]()
case Some((a, q)) => this.toList == a :: q.toList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,37 @@ object MutableMapInterface{
@pure
def abstractMap: ListLongMap[V] = {
require(valid)
??? : ListLongMap[V]
AbstractMethodBody[ListLongMap[V]]()
}

@pure
def size: Int
@pure
def isEmpty: Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}

@pure
def contains(key: Long): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (res == abstractMap.contains(key)))

@pure
def apply(key: Long): V = {
require(valid)
??? : V
AbstractMethodBody[V]()
}.ensuring(res => valid && (if (contains(key)) then abstractMap.get(key).isDefined && res == abstractMap.get(key).get else res == defaultEntry(key)))

def update(key: Long, v: V): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (if (res) then abstractMap.contains(key) && (abstractMap == old(this).abstractMap + (key, v)) else abstractMap == old(this).abstractMap))

def remove(key: Long): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (if (res) then abstractMap == old(this).abstractMap - key else abstractMap == old(this).abstractMap))
}

Expand All @@ -102,37 +102,37 @@ object MutableMapInterface{
@pure
def abstractMap: ListMap[K, V] = {
require(valid)
??? : ListMap[K, V]
AbstractMethodBody[ListMap[K, V]]()
}

@pure
def size: Int
@pure
def isEmpty: Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}

@pure
def contains(key: K): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (res == abstractMap.contains(key)))

@pure
def apply(key: K): V = {
require(valid)
??? : V
AbstractMethodBody[V]()
}.ensuring(res => valid && (if (contains(key)) then abstractMap.get(key).isDefined && res == abstractMap.get(key).get else res == defaultEntry(key)))

def update(key: K, v: V): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (if (res) then abstractMap.contains(key) && (abstractMap.eq(old(this).abstractMap + (key, v))) else abstractMap.eq(old(this).abstractMap)))

def remove(key: K): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (if (res) then abstractMap.eq(old(this).abstractMap - key) else abstractMap.eq(old(this).abstractMap)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object MutableSetInterface{
@pure
def abstractSet: Set[V] = {
require(valid)
??? : Set[V]
AbstractMethodBody[Set[V]]()
}

@pure
Expand All @@ -35,23 +35,23 @@ object MutableSetInterface{
@pure
def isEmpty: Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}

@pure
def contains(v: V): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (res == abstractSet.contains(v)))

def update(v: V): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (if (res) then abstractSet.contains(v) && (abstractSet == old(this).abstractSet + v) else abstractSet == old(this).abstractSet))

def remove(v: V): Boolean = {
require(valid)
??? : Boolean
AbstractMethodBody[Boolean]()
}.ensuring(res => valid && (if (res) then abstractSet == old(this).abstractSet - v else abstractSet == old(this).abstractSet))
}
}
24 changes: 12 additions & 12 deletions fp-principles/object-oriented-sets/TweetSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ sealed abstract class TweetSet {
// Helper method for `filter` that propagates accumulated tweets
def filterAcc(p: Tweet => Boolean, acc: TweetSet): TweetSet = {
decreases((size, 1))
(??? : TweetSet)
AbstractMethodBody[TweetSet]()
}

// A new `TweetSet` that is the union of `this` and `that`
def union(that: TweetSet): TweetSet = {
decreases((this, 1))
(??? : TweetSet)
AbstractMethodBody[TweetSet]()
}

// Tweet from `this` set with greatest retweet count
Expand All @@ -58,7 +58,7 @@ sealed abstract class TweetSet {
// Auxiliary function for `mostRetweeted`
def mostRetweetedAcc(acc: Tweet): Tweet = {
decreases((this, 1))
(??? : Tweet)
AbstractMethodBody[Tweet]()
}

/**
Expand All @@ -69,7 +69,7 @@ sealed abstract class TweetSet {
def descendingByRetweet: TweetList = {
require(isSearchTree)
decreases((size, 1))
(??? : TweetList)
AbstractMethodBody[TweetList]()
}

/**
Expand All @@ -80,63 +80,63 @@ sealed abstract class TweetSet {
*/
def incl(tweet: Tweet): TweetSet = {
decreases((this, 1))
(??? : TweetSet)
AbstractMethodBody[TweetSet]()
}

/**
* Returns a new `TweetSet` which excludes `tweet`.
*/
def remove(tweet: Tweet): TweetSet = {
decreases((this, 1))
(??? : TweetSet)
AbstractMethodBody[TweetSet]()
}

/**
* Tests if `tweet` exists in this `TweetSet`.
*/
def contains(tweet: Tweet): Boolean = {
decreases((this, 1))
(??? : Boolean)
AbstractMethodBody[Boolean]()
}

/**
* Tests (slower) if `tweet` exists in this `TweetSet`.
*/
def slowContains(tweet: Tweet): Boolean = {
decreases((this, 1))
(??? : Boolean)
AbstractMethodBody[Boolean]()
}

/**
* This method takes a function and applies it to every element in the set.
*/
def foreach(f: Tweet => Unit): Unit = {
decreases((this, 1))
(??? : Unit)
AbstractMethodBody[Unit]()
}

/**
* This method checks that a predicate .holds for every element in the set.
*/
def forall(f: Tweet => Boolean): Boolean = {
decreases((this, 1))
(??? : Boolean)
AbstractMethodBody[Boolean]()
}

/**
* The size of the set
*/
def size: BigInt = {
decreases((this, 1))
(??? : BigInt)
AbstractMethodBody[BigInt]()
}

/**
* Returns true if the tree is actually a binary search tree
*/
def isSearchTree: Boolean = {
decreases((this, 1))
(??? : Boolean)
AbstractMethodBody[Boolean]()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ trait LexerInterface {
*/
def withSeparatorToken[C: ClassTag](v: Sequence[Token[C]], separatorToken: Token[C]): Sequence[Token[C]] = {
require(separatorToken.rule.isSeparator)
??? : Sequence[Token[C]]
AbstractMethodBody[Sequence[Token[C]]]()
}.ensuring(res => print(res).list == printWithSeparatorToken(v, separatorToken).list)


Expand Down
3 changes: 2 additions & 1 deletion modularity/MiniMutableSetInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package modularity
import stainless.annotation.mutable
import stainless.annotation.pure
import stainless.annotation.law
import stainless.lang.AbstractMethodBody



Expand All @@ -12,7 +13,7 @@ object MiniMutableSetInterface:
trait iMiniMutableSet[V]:
@pure def contains(v: V): Boolean
def add(v: V): Unit = {
??? : Unit
AbstractMethodBody[Unit]()
}.ensuring(_ => contains(v))

// @law @pure @ghost def addContains(v: V): Boolean = {
Expand Down
2 changes: 1 addition & 1 deletion tutorials/const-fold/ConstFold.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object ConstFold:

abstract class SoundSimplifier:
def apply(e: Expr, anyCtx: Env): Expr = {
(??? : Expr)
AbstractMethodBody[Expr]()
}.ensuring(evaluate(anyCtx,_) == evaluate(anyCtx,e))

val mirSimp = new SoundSimplifier:
Expand Down
Loading