@@ -20,7 +20,10 @@ case class ListSet[T](toList: List[T]) {
2020 def ++ (other : ListSet [T ]): ListSet [T ] = {
2121 val union = ListSetSpecs .removeDuplicates(this .toList ++ other.toList)
2222 ListSet (union)
23- }.ensuring(res ⇒ forall((elem : T ) ⇒ (this .contains(elem) || other.contains(elem)) == res.contains(elem)))
23+ }.ensuring(res ⇒
24+ this .toList.forall(res.contains) &&
25+ other.toList.forall(res.contains) &&
26+ res.toList.forall(value => contains(value) || other.contains(value)))
2427
2528 def - (elem : T ): ListSet [T ] = {
2629 ListSetSpecs .removingFromASetResultsInASet(elem, toList)
@@ -32,7 +35,6 @@ case class ListSet[T](toList: List[T]) {
3235 ListSpecs .restOfSetIsSubset(toList, other.toList)
3336 ListSet (toList -- other.toList)
3437 }.ensuring(res ⇒
35- forall((elem : T ) ⇒ (this .contains(elem) && ! other.contains(elem)) == res.contains(elem)) &&
3638 (res & other).isEmpty &&
3739 res.subsetOf(this ))
3840
@@ -41,7 +43,7 @@ case class ListSet[T](toList: List[T]) {
4143 ListSpecs .listIntersectionLemma(toList, other.toList)
4244 ListSet (toList & other.toList)
4345 }.ensuring(res ⇒
44- forall(( elem : T ) ⇒ ( this .contains(elem ) && other.contains(elem)) == res.contains(elem )) &&
46+ res.toList. forall(value => this .contains(value ) && other.contains(value )) &&
4547 res.subsetOf(this ) &&
4648 res.subsetOf(other))
4749
@@ -184,7 +186,7 @@ object ListSetSpecs {
184186 case Cons (h, t) ⇒ if (t.contains(h)) removeDuplicates(t) else h :: removeDuplicates(t)
185187 case Nil () ⇒ Nil [T ]()
186188 }
187- }.ensuring(res ⇒ ListOps .noDuplicate(res) && forall(( elem : T ) ⇒ list .contains(elem) == res.contains(elem) ))
189+ }.ensuring(res ⇒ ListOps .noDuplicate(res) && list. forall(res .contains) && res.forall(list.contains ))
188190
189191 @ opaque
190192 def listSetDiff [T ](@ induct first : List [T ], second : List [T ]): Unit = {
0 commit comments