Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ghost annotation to toList method of Set in library #1601

Merged
merged 2 commits into from
Nov 6, 2024
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
12 changes: 6 additions & 6 deletions frontends/benchmarks/verification/valid/Iterables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import stainless.annotation._
import stainless.proof._

object Iterables {

@ghost
def test_setToList(set: Set[BigInt]) = {
require(set.contains(1) && set.contains(2) && !set.contains(3))

Expand All @@ -17,7 +17,7 @@ object Iterables {
set.toListPost(3)
assert(!res.contains(3))
}

@ghost
def test_setMap(set: Set[BigInt]) = {
require(set.contains(1) && set.contains(2) && !set.contains(3))

Expand All @@ -37,7 +37,7 @@ object Iterables {
}

val oneToSix = Set[BigInt](1,2,3,4,5,6)

@ghost
def test_setFilter(set: Set[BigInt]) = {
require((set & oneToSix) == oneToSix)

Expand All @@ -56,7 +56,7 @@ object Iterables {
set.filterPost(p)(6)
assert(!res.contains(6))
}

@ghost
def test_mapKeys(map: Map[Int, String]) = {
require(map.contains(1) && map.contains(2) && !map.contains(3))

Expand All @@ -69,7 +69,7 @@ object Iterables {
map.keysPost(3)
assert(!res.contains(3))
}

@ghost
def test_mapValues(map: Map[Int, String]) = {
require(map.get(1) == Some("foo") && map.get(2) == Some("bar"))

Expand All @@ -80,7 +80,7 @@ object Iterables {
map.valuesPost1(2)
assert(res.contains("bar"))
}

@ghost
def test_mapToList(map: Map[Int, String]) = {
require(map.get(1) == Some("foo") && map.get(2) == Some("bar"))

Expand Down
2 changes: 1 addition & 1 deletion frontends/library/stainless/lang/Set.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object Set {
()
}.ensuring(_ => withFilter(p).contains(a) == (p(a) && set.contains(a)))

@library @extern @pure
@library @extern @pure @ghost
def toList: List[A] = {
List.fromScala(set.theSet.toList)
}.ensuring(res => ListOps.noDuplicate(res) && res.content == set)
Expand Down
Loading