def round_with
stelliferous@0.0.2.0 · proofs/traversal_cells_refinement.bend:24
import stelliferous@0.0.2.0/proofs/traversal_cells_refinement.bend as TraversalCellsRefinement
import Base
import stelliferous@0.0.2.0/traversal_cells.bend as Cells
import stelliferous@0.0.2.0/proofs/storage_tree_model.bend as Tree
24def round_with(~Owner: Type,~Cell: Data,~Context: Data,~gather: Owner -> U32 -> Context -> Owner & Cell,
25 ~scatter: Owner -> U32 -> Cell -> Owner,~width: U32,
26 -values: Owner,+scratch: Tree.Tree<Cell>,+position: U32,+slot: U32,+context: Context,+cell: Cell,-result: Owner,
27 gathered: {gather(values,position,context) == (values,cell) : Owner & Cell},
28 scattered: {scatter(values,position,cell) == result : Owner}) ->
29 {Cells.step(~Owner,~Cell,~Context,~gather,~scatter,~width,Cells.State{values,Tree.pack(Cell,scratch),position,slot,context}) ==
30 Cells.State{result,Tree.pack(Cell,Tree.write(Cell,scratch,slot,cell)),(position + width : U32),U32.and((slot + 1 : U32),63),context} :
31 Cells.State<Owner,Cell,Context>}:
32 +written = Tree.write(Cell,scratch,slot,cell)
33 %Equal.sym(Owner & Cell,gather(values,position,context),(values,cell),gathered) :
34 {Cells.stored(~Owner,~Cell,~Context,~scatter,~width,position,slot,context,Tree.pack(Cell,scratch),_) ==
35 Cells.State{result,Tree.pack(Cell,written),(position + width : U32),U32.and((slot + 1 : U32),63),context} : Cells.State<Owner,Cell,Context>}
36 %Equal.sym(Array<Cell> & Cell,Array.get(Cell,Array.set(Cell,Tree.pack(Cell,scratch),slot,cell),slot),(Tree.pack(Cell,written),cell),scratch_readback(~Cell,scratch,slot,cell)) :
37 {Cells.scattered(~Owner,~Cell,~Context,~scatter,~width,position,slot,context,values,_) ==
38 Cells.State{result,Tree.pack(Cell,written),(position + width : U32),U32.and((slot + 1 : U32),63),context} : Cells.State<Owner,Cell,Context>}
39 %Equal.sym(Owner,scatter(values,position,cell),result,scattered) :
40 {Cells.State{_,Tree.pack(Cell,written),(position + width : U32),U32.and((slot + 1 : U32),63),context} ==
41 Cells.State{result,Tree.pack(Cell,written),(position + width : U32),U32.and((slot + 1 : U32),63),context} : Cells.State<Owner,Cell,Context>}
42 {==}