src/tensor/contracts/binary_storage_proof.bend checks
raw source on the hub · import bendtorch-core@0.1.0.0/src/tensor/contracts/binary_storage_proof.bend as Binary_storage_proof
10 imports
import Base import ../../storage/model.bend as Model import ../../storage/main.bend as Storage import ../../storage/LAWS.bend as StorageLaws import ../../storage/array.bend as ArrayCore import ../../storage/refinement.bend as Refinement import ../../storage/certificates.bend as Certificates import ../../storage/api.bend as Api import ../../storage/arith.bend as Arith import ./binary_build_proof.bend as Build
Definitions
def pair_eq source · line 18 · raw
@-A:Type -> @-B:Type -> @-a:A -> @-b:A -> @-c:B -> @-e:B -> @x:{a == b : A} -> @y:{c == e : B} -> {(a, c) == (b, e) : Pair(A, B)}
def balanced_unique source · line 23 · raw
@+d:Nat -> @array:Array<F32> -> @p:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/model.Balanced(F32, d, array) -> @q:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/model.Balanced(F32, d, array) -> {p == q : 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/model.Balanced(F32, d, array)}
def owned_eq source · line 40 · raw
@+d:Nat -> @+n:Nat -> @array:Array<F32> -> @-other:Array<F32> -> @e:{array == other : Array<F32>} -> @p:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/model.Balanced(F32, d, array) -> @-f:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> @q:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/model.Balanced(F32, d, other) -> {0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Owned{d, n, array, p, f} == 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Owned{d, n, other, q, f} : 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Storage}
def norm source · line 49 · raw
@+n:Nat -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+history:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.Effect> -> List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.Effect>
The effects a list of storage operations leaves on an owned storage of
length n, newest first: a write or read below n lands, the clone halves
are kept, and the rest leave the array as it is.
def norm_current source · line 66 · raw
@+n:Nat -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+history:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.Effect> -> @+j:U32 -> @+fill:F32 -> @hit:Bool -> @+dhit:{hit == 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.hit_of(n, ops) : Bool} -> {0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.current(norm(n, ops, history), j, fill) == 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.expected(ops, n, j, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.current(history, j, fill)) : F32}
def norm_written source · line 101 · raw
@+n:Nat -> @+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+history:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.Effect> -> @hit:Bool -> @+dhit:{hit == 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.hit_of(n, ops) : Bool} -> @+all:{0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/binary_build_proof.written(n, history) == True{} : Bool} -> {0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/contracts/binary_build_proof.written(n, norm(n, ops, history)) == True{} : Bool}
def replay_lift source · line 135 · raw
@+rest:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> @+d:Nat -> @+n:Nat -> @+fill:F32 -> @+history:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.Effect> -> @hit:Bool -> @+dhit:{hit == 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.hit_of(n, rest) : Bool} -> @-b:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/model.Balanced(F32, d, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.arr(history, d, fill)) -> @-f:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> @+fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> @-Q:(@_:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Storage -> Type) -> @h:(@-c:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/model.Balanced(F32, d, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.arr(norm(n, rest, history), d, fill)) -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Owned{d, n, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.arr(norm(n, rest, history), d, fill), c, f})) -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.replay(rest, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Owned{d, n, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/api.arr(history, d, fill), b, f}))A replayed owned storage is the owned storage whose array is arr of the
normalized history, with some certificate.
def replay_empty source · line 227 · raw
@+ops:List<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.Op> -> {0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.replay(ops, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Empty{}) == 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Empty{} : 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Storage}
def created_alloc source · line 244 · raw
@+d:Nat -> @+n:Nat -> @+fill:F32 -> @valid:Bool -> @-decision:{valid == 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) : Bool} -> @+yes:{True{} == valid : Bool} -> @+fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> @-Q:(@_:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Storage -> Type) -> @owned:(@+d:Nat -> @+fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> @-f:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Owned{d, n, Array.new(F32, d, fill), 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/array.new_balanced(F32, d, fill), f})) -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.created.of(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.allocate(d, n, fill, valid, decision)))
def created_meta source · line 255 · raw
@+n:Nat -> @+fill:F32 -> @metadata:Pair(Nat, Nat) -> @+fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(Pair.fst(Nat, Nat, metadata), n) == True{} : Bool} -> @-Q:(@_:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Storage -> Type) -> @owned:(@+d:Nat -> @+fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> @-f:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Owned{d, n, Array.new(F32, d, fill), 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/array.new_balanced(F32, d, fill), f})) -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.created.of(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.allocate_at(n, fill, metadata)))
def created_checked source · line 263 · raw
@+n:Nat -> @+fill:F32 -> @allowed:Bool -> @+yes:{True{} == allowed : Bool} -> @+limit:{Nat.is_le(n, 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/model.capacity(20n)) == True{} : Bool} -> @-Q:(@_:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Storage -> Type) -> @empty:(@zero:{n == 0n : Nat} -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Empty{})) -> @owned:(@+d:Nat -> @+fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> @-f:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, n) == True{} : Bool} -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Owned{d, n, Array.new(F32, d, fill), 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/array.new_balanced(F32, d, fill), f})) -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.created.of(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.new_checked(n, fill, allowed)))
def created_lift source · line 281 · raw
@+c:U32 -> @+fill:F32 -> @+within:{U32.is_le(c, 1048576) == True{} : Bool} -> @-Q:(@_:0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Storage -> Type) -> @empty:(@zero:{U32.to_nat(c) == 0n : Nat} -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Empty{})) -> @owned:(@+d:Nat -> @+fits:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, U32.to_nat(c)) == True{} : Bool} -> @-f:{0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.bounds(d, U32.to_nat(c)) == True{} : Bool} -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/main.Owned{d, U32.to_nat(c), Array.new(F32, d, fill), 0x1689e5deb278c16abd3bd45eac101ef3/src/storage/array.new_balanced(F32, d, fill), f})) -> Q(0x1689e5deb278c16abd3bd45eac101ef3/src/storage/LAWS.created(c, fill))created(c, fill) is empty for a zero count and otherwise the owned
storage that holds Array.new at some depth.