Skip to content

Commit

Permalink
Remove some forAlls and simplify configuration. (#92)
Browse files Browse the repository at this point in the history
* Remove some forAlls and simplify configuration.

* Fix config.
  • Loading branch information
OStevan authored Aug 21, 2020
1 parent 55992d0 commit 91ed4a6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ object BlockchainSystem {
validatorSet.values.forall(_.votingPower.value == 1) &&
maxPower.isPositive &&
nextValidatorSet.keys.subsetOf(validatorSet.keys) &&
faultChecker.isCorrect(nextValidatorSet, ListSet.empty) && initialCommit.forBlock.isEmpty)
faultChecker.isCorrect(nextValidatorSet, ListSet.empty) &&
initialCommit.forBlock.isEmpty)

val noFaulty = ListSet.empty[Address]

Expand Down
1 change: 1 addition & 0 deletions light-client-core/src/main/scala/utils/ListMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ case class ListMap[A, B](toList: List[(A, B)]) {
object ListMap {
def empty[A, B]: ListMap[A, B] = ListMap(List.empty[(A, B)])

@library
object lemmas {

@opaque
Expand Down
10 changes: 5 additions & 5 deletions light-client-core/src/main/scala/utils/ListSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,23 @@ case class ListSet[T](toList: List[T]) {
ListUtils.restOfSetIsSubset(toList, other.toList)
ListSet(toList -- other.toList)
}.ensuring(res
forall((elem: T) (this.contains(elem) && !other.contains(elem)) == res.contains(elem)) &&
(res & other).isEmpty &&
(res & other).isEmpty &&
res.subsetOf(this))

def &(other: ListSet[T]): ListSet[T] = {
ListSetUtils.listSetIntersection(toList, other.toList)
ListUtils.listIntersectionLemma(toList, other.toList)
ListSet(toList & other.toList)
}.ensuring(res
forall((elem: T) (this.contains(elem) && other.contains(elem)) == res.contains(elem)) &&
res.subsetOf(this) &&
res.subsetOf(this) &&
res.subsetOf(other))

@opaque
def filter(predicate: T Boolean): ListSet[T] = {
ListSetUtils.filteringPreservesPredicate(toList, predicate)
ListSetUtils.filteringMakesSubset(toList, predicate)
ListSet(toList.filter(predicate))
}.ensuring(res res.subsetOf(this))
}.ensuring(res res.subsetOf(this) && res.toList.forall(predicate))

def size: BigInt = toList.size
def isEmpty: Boolean = toList.isEmpty
Expand All @@ -65,6 +64,7 @@ case class ListSet[T](toList: List[T]) {
object ListSet {
def empty[T]: ListSet[T] = ListSet(List.empty[T])

@library
object lemmas {

@opaque
Expand Down
3 changes: 1 addition & 2 deletions light-client-core/src/main/scala/utils/ListUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ object ListUtils {
}.ensuring { _ =>
val intersection = first & second
intersection.forall(first.contains) &&
intersection.forall(second.contains) &&
forall((elem: T) => intersection.contains(elem) == (first.contains(elem) && second.contains(elem)))
intersection.forall(second.contains)
}

@opaque
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

stainless-scalac "$@" --batched --watch --solvers=smt-z3 \
stainless-scalac "$@" --watch \
light-client-core/src/main/scala/ch/epfl/ognjanovic/stevan/tendermint/verified/integration/ModelIntegration.scala \
light-client-core/src/main/scala/ch/epfl/ognjanovic/stevan/tendermint/verified/types/*.scala \
light-client-core/src/main/scala/ch/epfl/ognjanovic/stevan/tendermint/verified/light/*.scala \
Expand Down
5 changes: 2 additions & 3 deletions stainless.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
vc-cache = false
timeout = 300
solvers = [smt-z3]
check-models = true
print-ids = false
//debug = [verification]
batched = true
no-colors = false
fail-invalid = false
infer-measures = true
check-measures = true
type-checker = true
//functions = [setIntersectionLemma]
type-checker = true

0 comments on commit 91ed4a6

Please sign in to comment.