diff --git a/frontends/common/src/it/scala/stainless/verification/SatPrecondVerificationSuite.scala b/frontends/common/src/it/scala/stainless/verification/SatPrecondVerificationSuite.scala index e1dc44ca1..62aea8d9a 100644 --- a/frontends/common/src/it/scala/stainless/verification/SatPrecondVerificationSuite.scala +++ b/frontends/common/src/it/scala/stainless/verification/SatPrecondVerificationSuite.scala @@ -19,7 +19,7 @@ class SatPrecondVerificationSuite extends VerificationComponentTestSuite { Set() private val ignorePrincess: Set[String] = ignoreCommon ++ - Set() + Set("sat-precondition/valid/SATPrecond4") private val ignoreCodegen: Set[String] = Set() @@ -46,7 +46,9 @@ class SatPrecondVerificationSuite extends VerificationComponentTestSuite { inox.optSelectedSolvers(Set(solver)), inox.solvers.optCheckModels(true), evaluators.optCodeGen(codeGen), + inox.optTimeout(3.seconds), inox.solvers.unrolling.optFeelingLucky(codeGen)) ++ seq + } } yield conf } diff --git a/frontends/library/stainless/lang/Set.scala b/frontends/library/stainless/lang/Set.scala index a299eecf7..6ec686ba3 100644 --- a/frontends/library/stainless/lang/Set.scala +++ b/frontends/library/stainless/lang/Set.scala @@ -23,68 +23,89 @@ object Set { new Set(set) } - @extern @pure @library - def mkString[A](set: Set[A], infix: String)(format: A => String): String = { - set.theSet.map(format).toList.sorted.mkString(infix) - } + // @extern @pure @library + // def mkString[A](set: Set[A], infix: String)(format: A => String): String = { + // set.theSet.map(format).toList.sorted.mkString(infix) + // } + + extension[A](set: Set[A]) { - @library - implicit class SetOps[A](val set: Set[A]) extends AnyVal { + @library @extern @pure + def exists(p: A => Boolean): Boolean = { + set.theSet.exists(p) + } + + @library @extern @pure + def forall(p: A => Boolean): Boolean = { + set.theSet.forall(p) + } - @extern @pure + @library @extern @pure def map[B](f: A => B): Set[B] = { new Set(set.theSet.map(f)) } - @extern @pure + @library @extern @pure def mapPost1[B](f: A => B)(a: A): Unit = { () - }.ensuring { _ => + }.ensuring { _ => !set.contains(a) || map[B](f).contains(f(a)) } - @extern @pure + @library @extern @pure def mapPost2[B](f: A => B)(b: B): A = { require(map[B](f).contains(b)) (??? : A) - }.ensuring { (a:A) => + }.ensuring { (a:A) => b == f(a) && set.contains(a) } - @extern @pure + @library @extern @pure + def flatMap[B](f: A => Set[B]): Set[B] = { + new Set(set.theSet.flatMap(f(_).theSet)) + } + + @library @extern @pure + def flatMapPost[B](f: A => Set[B])(b: B) = { + (??? : A) + }.ensuring { _ => + set.flatMap(f).contains(b) == set.exists(a => f(a).contains(b)) + } + + @library @extern @pure def filter(p: A => Boolean): Set[A] = { new Set(set.theSet.filter(p)) } - @extern @pure + @library @extern @pure def filterPost(p: A => Boolean)(a: A): Unit = { () }.ensuring (_ => filter(p).contains(a) == (p(a) && set.contains(a))) - @extern @pure + @library @extern @pure def withFilter(p: A => Boolean): Set[A] = { new Set(set.theSet.filter(p)) } - @extern @pure + @library @extern @pure def withFilterPost(p: A => Boolean)(a: A): Unit = { () }.ensuring(_ => withFilter(p).contains(a) == (p(a) && set.contains(a))) - @extern @pure + @library @extern @pure def toList: List[A] = { List.fromScala(set.theSet.toList) }.ensuring(res => ListOps.noDuplicate(res) && res.content == set) - @extern @pure + @library @extern @pure def toListPost(a:A): Unit = { () }.ensuring(_ => toList.contains(a) == set.contains(a)) - @extern @pure + @library @extern @pure def toScala: ScalaSet[A] = set.theSet - @extern @pure + @library @extern @pure def mkString(infix: String)(format: A => String): String = { set.theSet.map(format).toList.sorted.mkString(infix) }