def later_writes
bendtorch-core@0.1.0.0 · src/tensor/from_values_contract.bend:97
import bendtorch-core@0.1.0.0/src/tensor/from_values_contract.bend as FromValuesContract
import Base
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/storage/api.bend as Api
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
97def later_writes(+values: List<&2, F32>, +cursor: Nat, +limit: U32, +index: U32, +base: F32,
98 room: {Nat.is_le(Nat.add(cursor, List.length(&2, F32, values)), U32.to_nat(limit)) == True{} : Bool},
99 earlier: {Nat.is_lt(U32.to_nat(index), cursor) == True{} : Bool}) ->
100 {StorageLaws.expected(writes(values, cursor), U32.to_nat(limit), index, base) == base : F32}:
101 match values:
102 case Nil{}:
103 {==}
104 case +value <> +rest:
105 +room = room
106 +earlier = earlier
107 Equal.trans(F32,
108 StorageLaws.expected(writes(rest, 1n+cursor), U32.to_nat(limit), index,
109 StorageLaws.latest(U32.to_nat(limit), StorageLaws.Write{U32.from_nat(cursor), value}, index, base)),
110 StorageLaws.latest(U32.to_nat(limit), StorageLaws.Write{U32.from_nat(cursor), value}, index, base), base,
111 later_writes(rest, 1n+cursor, limit, index,
112 StorageLaws.latest(U32.to_nat(limit), StorageLaws.Write{U32.from_nat(cursor), value}, index, base),
113 room_next(cursor, List.length(&2, F32, rest), U32.to_nat(limit), room),
114 Arith.lt_le_trans(U32.to_nat(index), cursor, 1n+cursor, earlier, Arith.le_succ(cursor, cursor, Api.le_refl(cursor)))),
115 missed(cursor, List.length(&2, F32, rest), limit, index, value, base, room, earlier))