~/bend-docscommunity

proofs/window_history.bend checks

raw source on the hub · import bend-ta@0.1.0.0/proofs/window_history.bend as Window_history

7 imports
import Base
import bend-mathlib@0.8.1.0/nat.bend as MNat
import bend-mathlib@0.8.1.0/u32.bend as MU32
import ../src/core/window.bend as Window
import ./window_storage.bend as Storage
import ./window_geometry.bend as Geometry
import ./window_indices.bend as Indices

Laws

law filled_array provedsource · line 58 · raw

@-A:Data -> @+d:Nat -> @+fill:A -> {0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.array(A, filled(A, d, fill)) == Array.new(A, d, fill) : Array<A>}

law init_state provedsource · line 72 · raw

@-A:Data -> @+period:U32 -> @d:Nat -> @fill:A -> {state(A, initialized(A, period, d, fill)) == 0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.init(A, period, d, fill) : 0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>}

law push_state provedsource · line 83 · raw

@-A:Data -> @+m:Model<A> -> @+value:A -> {(state(A, push(A, m, value)), eviction(A, m)) == 0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.push(A, state(A, m), value) : Pair(0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>, Maybe<&2, A>)}

law lag_state_check provedsource · line 95 · raw

@-A:Data -> @+buffer:0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.Tree<A> -> @+period:U32 -> @+size:U32 -> @+pos:U32 -> @+age:U32 -> @valid:Bool -> {(state(A, Model{buffer, period, size, pos}), Bool.pick(Maybe<&2, A>, valid, Some{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.cell(A, buffer, index(period, pos, age))}, None{})) == 0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.lag.check(A, period, size, pos, 0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.array(A, buffer), age, valid) : Pair(0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>, Maybe<&2, A>)}

law lag_state provedsource · line 113 · raw

@-A:Data -> @+m:Model<A> -> @+age:U32 -> {(state(A, m), observed(A, m, age)) == 0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.lag(A, state(A, m), age) : Pair(0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>, Maybe<&2, A>)}

law filled_balanced provedsource · line 124 · raw

@-A:Data -> @+d:Nat -> @+fill:A -> {0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_geometry.balanced(A, d, filled(A, d, fill)) == True{} : Bool}

law replay_state provedsource · line 156 · raw

@-A:Data -> @+period:U32 -> @+d:Nat -> @+fill:A -> @+history:List<&2, A> -> {state(A, initialized_history(A, period, d, fill, history)) == replay(A, period, d, fill, history) : 0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>}

law initialized_invariant provedsource · line 191 · raw

@-A:Data -> @+period:U32 -> @+d:Nat -> @+fill:A -> @config:Configuration<period, d> -> Invariant(A, d, initialized(A, period, d, fill), [])

law min_increment provedsource · line 205 · raw

@+n:Nat -> @+p:Nat -> {Nat.min(1n+Nat.min(n, p), p) == Nat.min(1n+n, p) : Nat}

law positive_predecessor provedsource · line 220 · raw

@+n:Nat -> @h:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(0n, n) -> {n == 1n+Nat.sub(n, 1n) : Nat}

law push_cells_check provedsource · line 253 · raw

@-A:Data -> @+d:Nat -> @+buffer:0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.Tree<A> -> @+period:U32 -> @+size:U32 -> @+pos:U32 -> @+value:A -> @+history:List<&2, A> -> @+q:Nat -> @+ep:{U32.to_nat(period) == 1n+q : Nat} -> @+hmax:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, 30n)) -> @+hd:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(d, 32n) -> @+hc:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, d)) -> @+shape:{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_geometry.balanced(A, d, buffer) == True{} : Bool} -> @+hs:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(size), U32.to_nat(period)) -> @+hp:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(pos), U32.to_nat(period)) -> @cells:(@+a:U32 -> @available:{U32.is_lt(a, size) == True{} : Bool} -> {Some{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.cell(A, buffer, index(period, pos, a))} == lookup(A, history, a) : Maybe<&2, A>}) -> @+age:U32 -> @zero:Bool -> @+ez:{U32.is_zero(age) == zero : Bool} -> @+ha:{U32.is_lt(age, U32.min(U32.add(size, 1), period)) == True{} : Bool} -> {Some{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.cell(A, 0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.put(A, buffer, pos, value), index(period, 0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_indices.next(period, pos), age))} == lookup(A, value <> history, age) : Maybe<&2, A>}

law push_invariant_fields provedsource · line 303 · raw

@-A:Data -> @+d:Nat -> @+buffer:0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.Tree<A> -> @+period:U32 -> @+size:U32 -> @+pos:U32 -> @+value:A -> @+history:List<&2, A> -> @+q:Nat -> @+ep:{U32.to_nat(period) == 1n+q : Nat} -> @+positive:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(0n, U32.to_nat(period)) -> @+hmax:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, 30n)) -> @+hd:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(d, 32n) -> @+hc:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, d)) -> @+shape:{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_geometry.balanced(A, d, buffer) == True{} : Bool} -> @+hs:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(size), U32.to_nat(period)) -> @+hp:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(pos), U32.to_nat(period)) -> @length:{U32.to_nat(size) == Nat.min(List.length(&2, A, history), U32.to_nat(period)) : Nat} -> @cells:(@+a:U32 -> @available:{U32.is_lt(a, size) == True{} : Bool} -> {Some{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.cell(A, buffer, index(period, pos, a))} == lookup(A, history, a) : Maybe<&2, A>}) -> Invariant(A, d, push(A, Model{buffer, period, size, pos}, value), value <> history)

law push_invariant_config provedsource · line 332 · raw

@-A:Data -> @+d:Nat -> @+buffer:0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.Tree<A> -> @+period:U32 -> @+size:U32 -> @+pos:U32 -> @+value:A -> @+history:List<&2, A> -> @config:Configuration<period, d> -> @shape:{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_geometry.balanced(A, d, buffer) == True{} : Bool} -> @hs:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(size), U32.to_nat(period)) -> @hp:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(pos), U32.to_nat(period)) -> @length:{U32.to_nat(size) == Nat.min(List.length(&2, A, history), U32.to_nat(period)) : Nat} -> @cells:(@+a:U32 -> @available:{U32.is_lt(a, size) == True{} : Bool} -> {Some{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.cell(A, buffer, index(period, pos, a))} == lookup(A, history, a) : Maybe<&2, A>}) -> Invariant(A, d, push(A, Model{buffer, period, size, pos}, value), value <> history)

law push_invariant provedsource · line 354 · raw

@-A:Data -> @+d:Nat -> @+m:Model<A> -> @+value:A -> @+history:List<&2, A> -> @invariant:Invariant(A, d, m, history) -> Invariant(A, d, push(A, m, value), value <> history)

law history_invariant provedsource · line 370 · raw

@-A:Data -> @+period:U32 -> @+d:Nat -> @+fill:A -> @+history:List<&2, A> -> @config:Configuration<period, d> -> Invariant(A, d, initialized_history(A, period, d, fill, history), history)

law observed_visible provedsource · line 396 · raw

@-A:Data -> @+d:Nat -> @+m:Model<A> -> @+history:List<&2, A> -> @+age:U32 -> @invariant:Invariant(A, d, m, history) -> {observed(A, m, age) == visible(A, model_period(A, m), history, age) : Maybe<&2, A>}

law push_period provedsource · line 414 · raw

@-A:Data -> @+m:Model<A> -> @value:A -> {model_period(A, push(A, m, value)) == model_period(A, m) : U32}

law history_period provedsource · line 425 · raw

@-A:Data -> @+period:U32 -> @+d:Nat -> @+fill:A -> @+history:List<&2, A> -> {model_period(A, initialized_history(A, period, d, fill, history)) == period : U32}

law lag_history provedsource · line 441 · raw

@-A:Data -> @+period:U32 -> @+d:Nat -> @+fill:A -> @+history:List<&2, A> -> @+age:U32 -> @config:Configuration<period, d> -> {0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.lag(A, replay(A, period, d, fill, history), age) == (replay(A, period, d, fill, history), visible(A, period, history, age)) : Pair(0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>, Maybe<&2, A>)}

law min_full provedsource · line 458 · raw

@n:Nat -> @p:Nat -> {Nat.is_eq(Nat.min(n, p), p) == Nat.is_le(p, n) : Bool}

law eviction_check provedsource · line 487 · raw

@-A:Data -> @+buffer:0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.Tree<A> -> @+period:U32 -> @+size:U32 -> @+pos:U32 -> @+history:List<&2, A> -> @+q:Nat -> @+ep:{U32.to_nat(period) == 1n+q : Nat} -> @hp:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(pos), U32.to_nat(period)) -> @hmax:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, 30n)) -> @cells:(@+a:U32 -> @available:{U32.is_lt(a, size) == True{} : Bool} -> {Some{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.cell(A, buffer, index(period, pos, a))} == lookup(A, history, a) : Maybe<&2, A>}) -> @full:Bool -> @efull:{U32.is_eq(size, period) == full : Bool} -> {Bool.pick(Maybe<&2, A>, full, Some{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.cell(A, buffer, pos)}, None{}) == Bool.pick(Maybe<&2, A>, full, lookup(A, history, U32.sub(period, 1)), None{}) : Maybe<&2, A>}

law eviction_fields provedsource · line 511 · raw

@-A:Data -> @+d:Nat -> @+buffer:0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.Tree<A> -> @+period:U32 -> @+size:U32 -> @+pos:U32 -> @+history:List<&2, A> -> @config:Configuration<period, d> -> @hp:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(pos), U32.to_nat(period)) -> @cells:(@+a:U32 -> @available:{U32.is_lt(a, size) == True{} : Bool} -> {Some{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.cell(A, buffer, index(period, pos, a))} == lookup(A, history, a) : Maybe<&2, A>}) -> {eviction(A, Model{buffer, period, size, pos}) == Bool.pick(Maybe<&2, A>, U32.is_eq(size, period), lookup(A, history, U32.sub(period, 1)), None{}) : Maybe<&2, A>}

law eviction_visible provedsource · line 529 · raw

@-A:Data -> @+d:Nat -> @+m:Model<A> -> @+history:List<&2, A> -> @invariant:Invariant(A, d, m, history) -> {eviction(A, m) == expelled(A, model_period(A, m), history) : Maybe<&2, A>}

law push_history provedsource · line 547 · raw

@-A:Data -> @+period:U32 -> @+d:Nat -> @+fill:A -> @+history:List<&2, A> -> @+value:A -> @config:Configuration<period, d> -> {0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.push(A, replay(A, period, d, fill, history), value) == (replay(A, period, d, fill, value <> history), expelled(A, period, history)) : Pair(0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>, Maybe<&2, A>)}

Types

type Model source · line 9 · raw

@-A:Data -> Data

type Configuration source · line 173 · raw

@-period:U32 -> @-d:Nat -> Type

Definitions

def index source · line 43 · raw

@+period:U32 -> @pos:U32 -> @age:U32 -> U32

def zero_equal source · line 233 · raw

@+age:U32 -> @h:{U32.is_zero(age) == True{} : Bool} -> {age == 0 : U32}

def next_size_bound source · line 237 · raw

@+period:U32 -> @+size:U32 -> @+q:Nat -> @ep:{U32.to_nat(period) == 1n+q : Nat} -> @hs:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(size), U32.to_nat(period)) -> @hmax:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, 30n)) -> 0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(U32.min(U32.add(size, 1), period)), U32.to_nat(period))

def next_available_period source · line 241 · raw

@+period:U32 -> @+size:U32 -> @+age:U32 -> @+q:Nat -> @ep:{U32.to_nat(period) == 1n+q : Nat} -> @hs:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(size), U32.to_nat(period)) -> @hmax:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, 30n)) -> @ha:{U32.is_lt(age, U32.min(U32.add(size, 1), period)) == True{} : Bool} -> 0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(age), U32.to_nat(period))

def previous_lt_q source · line 244 · raw

@+period:U32 -> @+age:U32 -> @+q:Nat -> @ep:{U32.to_nat(period) == 1n+q : Nat} -> @hz:{U32.is_zero(age) == False{} : Bool} -> @ha:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(age), U32.to_nat(period)) -> 0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(U32.sub(age, 1)), q)

def next_size_length source · line 298 · raw

@+period:U32 -> @+size:U32 -> @+length:Nat -> @+q:Nat -> @ep:{U32.to_nat(period) == 1n+q : Nat} -> @hs:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(size), U32.to_nat(period)) -> @hmax:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, 30n)) -> @e:{U32.to_nat(size) == Nat.min(length, U32.to_nat(period)) : Nat} -> {U32.to_nat(U32.min(U32.add(size, 1), period)) == Nat.min(1n+length, U32.to_nat(period)) : Nat}

def equal_u32 source · line 477 · raw

@+a:U32 -> @+b:U32 -> @h:{U32.is_eq(a, b) == True{} : Bool} -> {a == b : U32}

def oldest_available source · line 480 · raw

@+period:U32 -> @+size:U32 -> @+q:Nat -> @+ep:{U32.to_nat(period) == 1n+q : Nat} -> @full:{U32.is_eq(size, period) == True{} : Bool} -> {U32.is_lt(U32.sub(period, 1), size) == True{} : Bool}

Templates

template model_period source · line 12 · raw

@-A:Data -> @m:Model<A> -> U32

template state source · line 17 · raw

@-A:Data -> @m:Model<A> -> 0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>

template filled source · line 22 · raw

@-A:Data -> @d:Nat -> @+fill:A -> 0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.Tree<A>

template initialized source · line 30 · raw

@-A:Data -> @period:U32 -> @d:Nat -> @fill:A -> Model<A>

template push source · line 33 · raw

@-A:Data -> @m:Model<A> -> @+value:A -> Model<A>

template eviction source · line 38 · raw

@-A:Data -> @m:Model<A> -> Maybe<&2, A>

template observed source · line 46 · raw

@-A:Data -> @m:Model<A> -> @+age:U32 -> Maybe<&2, A>

template lookup source · line 51 · raw

@-A:Data -> @history:List<&2, A> -> @+age:U32 -> Maybe<&2, A>

template initialized_history source · line 138 · raw

@-A:Data -> @+period:U32 -> @+d:Nat -> @+fill:A -> @history:List<&2, A> -> Model<A>

template first source · line 145 · raw

@-A:Type -> @-B:Type -> @result:Pair(A, B) -> A

template replay source · line 149 · raw

@-A:Data -> @+period:U32 -> @+d:Nat -> @+fill:A -> @history:List<&2, A> -> 0xbb55196063fb99add8900a97dfe6ee2d/src/core/window.State<A>

template Invariant source · line 180 · raw

@-A:Data -> @+d:Nat -> @m:Model<A> -> @+history:List<&2, A> -> Type

template physical_bound source · line 249 · raw

@-A:Data -> @+d:Nat -> @+buffer:0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.Tree<A> -> @+period:U32 -> @+i:U32 -> @hd:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(d, 32n) -> @shape:{0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_geometry.balanced(A, d, buffer) == True{} : Bool} -> @hc:0x8ae61ec3a6615abd35f196c07232ad28/nat.le(U32.to_nat(period), Nat.pow(2n, d)) -> @hi:0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(i), U32.to_nat(period)) -> 0x8ae61ec3a6615abd35f196c07232ad28/nat.lt(U32.to_nat(i), U32.to_nat(0xbb55196063fb99add8900a97dfe6ee2d/proofs/window_storage.capacity(A, buffer)))

template visible source · line 386 · raw

@-A:Data -> @period:U32 -> @+history:List<&2, A> -> @+age:U32 -> Maybe<&2, A>

template observation_check source · line 389 · raw

@-A:Data -> @flag:Bool -> @+value:Maybe<&2, A> -> @+wanted:Maybe<&2, A> -> @proof:(@_:{flag == True{} : Bool} -> {value == wanted : Maybe<&2, A>}) -> {Bool.pick(Maybe<&2, A>, flag, value, None{}) == Bool.pick(Maybe<&2, A>, flag, wanted, None{}) : Maybe<&2, A>}

template expelled source · line 474 · raw

@-A:Data -> @+period:U32 -> @+history:List<&2, A> -> Maybe<&2, A>