Skip to content

Commit

Permalink
Use inlineOnce instead of inline for opaque functions (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-bucev authored Nov 15, 2022
1 parent 3f4df34 commit 7e487c5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion WIP/SLOW/longmap/StrictlyOrderedLongListMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ object TupleListOps {

@opaque
def lemmaAddExistingKeyPreservesSize[B](l: List[(Long, B)], key: Long, value: B): Unit = {
decreases(l)
require(invariantList(l))
require(containsKey(l, key))

Expand Down Expand Up @@ -679,7 +680,7 @@ object ListMapLongKeyLemmas {
}.ensuring(_ => (lm + (a -> b))(a0) == lm(a0))

@opaque
@inline
@inlineOnce
def addStillContains[B](lm: ListMapLongKey[B], a: Long, b: B, a0: Long): Unit = {
require(lm.contains(a0))

Expand Down
5 changes: 3 additions & 2 deletions WIP/SLOW/longmap/stainless.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# options listed by `stainless --help`

vc-cache = true
debug = [] #["verification"]
#debug = ["verification"]
timeout = 20
check-models = false
print-ids = false
Expand All @@ -15,4 +15,5 @@ strict-arithmetic = false
# solvers = "smt-z3,no-inc:smt-z3:z3-master tactic.default_tactic=smt sat.euf=true"
solvers = "smt-cvc4,smt-z3,no-inc:smt-z3:z3 tactic.default_tactic=smt sat.euf=true"
check-measures = yes
infer-measures = true
infer-measures = false
no-colors = true
2 changes: 1 addition & 1 deletion data-structures/sorted-array/SortedArray.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ object SortedArray {
isSortedRange(array, order, i2, j2)
)

@pure @opaque @ghostAnnot @inline
@pure @opaque @ghostAnnot @inlineOnce
def arrayGetSameIndex2[@mutable T](array: Array[T], i: Int, j: Int): Unit = {
require(0 <= i && i < array.length - 1 && i == j)

Expand Down
3 changes: 2 additions & 1 deletion qoi/stainless.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ timeout = 300
strict-arithmetic = false
batched = true
solvers = "smt-cvc4,smt-z3,no-inc:smt-z3:z3 tactic.default_tactic=smt sat.euf=true"
infer-measures = false
infer-measures = false
no-colors = true
2 changes: 1 addition & 1 deletion qoi/verified/common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ object common {
@opaque
@inlineOnce
def arraysEqAtIndex[T](arr1: Array[T], arr2: Array[T], from: Long, until: Long, at: Long): Unit = {
decreases(until - at)
decreases(until - from)
require(arr1.length == arr2.length)
require(0 <= from && from <= until && until <= arr1.length)
require(arraysEq(arr1, arr2, from, until))
Expand Down
10 changes: 8 additions & 2 deletions qoi/verified/encoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ object encoder {
assert(decoded1.pxPos + chan <= decoded1.pixels.length)
assert(outPos1 < outPos2 && outPos2 <= bytes.length - Padding)
assert(pixels.length == w * h * chan)
assert(pxPos % chan == 0)
assert(decoder.pxPosInv(decoded1.pxPos))
val (ix2, pix2, decIter2) = decoder.decodeLoopPure(decoded1.index, decoded1.pixels, decIter1.px, outPos1, outPos2, decoded1.pxPos)
assert(decIter2.pxPos == decoded2.pxPos)
Expand Down Expand Up @@ -782,11 +783,16 @@ object encoder {
assert(pxPosInv(pxPos))
unfold(pxPosInv(pxPos))
check(pxPos % chan == 0)
check(pixels.length % chan == 0) // Slow (~75)

modMultLemma(w, h, chan)
assert((w * h * chan) % chan == 0)
assert(pixels.length == w * h * chan)
check(pixels.length % chan == 0)

check(samePixels(pixels, px, pxPos, chan))
check(arraysEq(bytesPre, bytes, 0, outPos0))
check(rangesInv(index.length, bytes.length, run1, outPos2, pxPos))
check(positionsIneqInv(run1, outPos2, pxPos + chan)) // Slow (~45s)
check(positionsIneqInv(run1, outPos2, pxPos + chan))
check(pxPosInv(decoded.pxPos))
check(newDecoded.pxPos + chan * run1 == pxPos + chan)
check((outPos0 == outPos2) ==> (decoded == newDecoded && run1 == run0 + 1 && px == pxPrev))
Expand Down

0 comments on commit 7e487c5

Please sign in to comment.