StorageRefinement.sequence_element: def of stelliferous@0.0.2.0 Import: import stelliferous@0.0.2.0/proofs/storage_refinement.bend as StorageRefinement Lines 262-282 of stelliferous@0.0.2.0/proofs/storage_refinement.bend: https://jend.leeeet.dev/read.txt?path=stelliferous@0.0.2.0/proofs/storage_refinement.bend&start_line=262&end_line=282 import Base import stelliferous@0.0.2.0/proofs/storage_tree_model.bend as Tree import stelliferous@0.0.2.0/proofs/loop_projection.bend as Projection import stelliferous@0.0.2.0/proofs/bounded_u32_arithmetic.bend as Arithmetic import stelliferous@0.0.2.0/proofs/word_encoding.bend as WordEncoding # An observed logical prefix has the actual stored element at every valid index. # Capacity need not equal count; address overflow remains explicitly modular. def sequence_element(~Element: Data,+count: Nat,+offset: U32,+tree: Tree.Tree,+index: Nat, inside: {Nat.is_lt(index,count) == True{} : Bool}) -> {List.get(&2,Element,Tree.read_sequence(~Element,count,offset,tree),index) == Some{Tree.read(Element,tree,(offset + U32.from_nat(index) : U32))} : Maybe<&2,Element>}: match count index: case 0n 0n: Empty.absurd({None{} == Some{Tree.read(Element,tree,(offset + 0 : U32))} : Maybe<&2,Element>},WordEncoding.false_true(inside)) case 0n 1n+previous: Empty.absurd({None{} == Some{Tree.read(Element,tree,(offset + U32.from_nat(1n+previous) : U32))} : Maybe<&2,Element>},WordEncoding.false_true(inside)) case 1n+rest 0n: %Equal.sym(U32,(offset + 0 : U32),offset,Arithmetic.add_zero(offset)) : {Some{Tree.read(Element,tree,offset)} == Some{Tree.read(Element,tree,_)} : Maybe<&2,Element>} {==} case 1n+ +rest 1n+ +previous: %Equal.sym(U32,(offset + U32.from_nat(1n+previous) : U32),((offset + 1 : U32) + U32.from_nat(previous) : U32), Projection.indexed_successor(offset,previous)) : {List.get(&2,Element,Tree.read_sequence(~Element,rest,(offset + 1 : U32),tree),previous) == Some{Tree.read(Element,tree,_)} : Maybe<&2,Element>} sequence_element(~Element,rest,(offset + 1 : U32),tree,previous,inside) Uses (16): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Empty.absurd https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.sym https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.get https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/proofs/bounded_u32_arithmetic.bend&name=add_zero https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/proofs/loop_projection.bend&name=indexed_successor https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/proofs/storage_tree_model.bend&name=Tree https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/proofs/storage_tree_model.bend&name=read https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/proofs/storage_tree_model.bend&name=read_sequence https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/proofs/word_encoding.bend&name=false_true