1 import Base 2 import ../../shape/core.bend as Shape 3 import ../../storage/LAWS.bend as StorageLaws 4 import ./replayed.bend as Replayed 5 import ./pointwise.bend as Pointwise 6 import ./pointwise_proof.bend as PointwiseProof 7 import ./LAWS.bend as Laws 8 9 # A word appended to two equal word lists, equal words, gives equal lists. 10 def words_snoc(+shape: Shape.Shape, +fill: F32, +ops: List<&2, StorageLaws.Op>, +previous: Nat, +word: F32, +other: F32, 11 +before: List<&2, F32>, rest: {Laws.words(shape, fill, ops, previous) == before : List<&2, F32>}, 12 last: {word == other : F32}) -> 13 {List.append(&2, F32, Laws.words(shape, fill, ops, previous), [word]) == List.append(&2, F32, before, [other]) : List<&2, F32>}: 14 %rest : 15 {List.append(&2, F32, Laws.words(shape, fill, ops, previous), [word]) == List.append(&2, F32, _, [other]) : List<&2, F32>} 16 %last : 17 {List.append(&2, F32, Laws.words(shape, fill, ops, previous), [word]) == List.append(&2, F32, Laws.words(shape, fill, ops, previous), [_]) : List<&2, F32>} 18 {==} 19 20 # Reads appended to a history list the same words. 21 def words_reads(~P: Data, ~map: P -> Nat -> Nat, +plan: P, +reads: Nat, +shape: Shape.Shape, +fill: F32, +ops: List<&2, StorageLaws.Op>, 22 +count: Nat) -> 23 {Laws.words(shape, fill, List.append(&2, StorageLaws.Op, ops, Pointwise.reads(~P, ~map, plan, reads)), count) == 24 Laws.words(shape, fill, ops, count) : List<&2, F32>}: 25 match count: 26 case 0n: 27 {==} 28 case 1n+previous: 29 +position = U32.from_nat(previous) 30 +seen = List.append(&2, StorageLaws.Op, ops, Pointwise.reads(~P, ~map, plan, reads)) 31 words_snoc(shape, fill, seen, previous, Replayed.value(shape, fill, seen, position), Replayed.value(shape, fill, ops, position), 32 Laws.words(shape, fill, ops, previous), words_reads(~P, ~map, plan, reads, shape, fill, ops, previous), 33 PointwiseProof.value_reads(~P, ~map, plan, reads, shape, fill, ops, position)) 34 35 # Equal lists with equal words appended are equal. 36 def snoc_equal(+before: List<&2, F32>, +after: List<&2, F32>, +word: F32, +other: F32, 37 rest: {before == after : List<&2, F32>}, last: {word == other : F32}) -> 38 {List.append(&2, F32, before, [word]) == List.append(&2, F32, after, [other]) : List<&2, F32>}: 39 %rest : {List.append(&2, F32, before, [word]) == List.append(&2, F32, _, [other]) : List<&2, F32>} 40 %last : {List.append(&2, F32, before, [word]) == List.append(&2, F32, before, [_]) : List<&2, F32>} 41 {==}