def frame_checked_mapping
bendtorch-core@0.1.0.0 · src/tensor/core_PROOF.bend:248
import bendtorch-core@0.1.0.0/src/tensor/core_PROOF.bend as CorePROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/storage/model.bend as Model
import bendtorch-core@0.1.0.0/src/storage/refinement.bend as Refinement
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/core_LAWS.bend as Laws
248def frame_checked_mapping(-shape: Shape.Shape, +d: Nat, +n: Nat, array: Array<F32>, +i: U32, +other: U32, +value: F32,
249 balanced: Model.Balanced(F32, d, array), -valid: {Storage.bounds(d, n) == True{} : Bool},
250 -exact: {n == Shape.logical_numel(Shape.dimensions(shape)) : Nat}, allowed: Bool,
251 -decision: {allowed == Nat.is_lt(U32.to_nat(i), n) : Bool},
252 -same: {Storage.set_checked(d, n, array, i, value, allowed, decision, balanced, valid) ==
253 Storage.set(Storage.Owned{d, n, array, balanced, valid}, i, value) : Storage.Storage & Result<&2, &2, Storage.Error, Unit>},
254 accepted: {allowed == True{} : Bool},
255 index_checked: {Storage.index_matches(d, n, i) == True{} : Bool},
256 other_checked: {Storage.index_matches(d, n, other) == True{} : Bool},
257 different: {Nat.is_eq(U32.to_nat(i), U32.to_nat(other)) == False{} : Bool}) ->
258 {Core.write_observe(shape, Core.write_result(shape, Storage.Owned{d, n, array, balanced, valid}, exact, i, value,
259 Storage.set_checked(d, n, array, i, value, allowed, decision, balanced, valid), same), other) ==
260 Model.observe(F32, d, array, Refinement.route(d, other)) : Maybe<&2, F32>}:
261 match allowed:
262 case False{}:
263 Empty.absurd({Core.write_observe(shape, Core.write_result(shape, Storage.Owned{d, n, array, balanced, valid}, exact, i, value,
264 Storage.set_checked(d, n, array, i, value, False{}, decision, balanced, valid), same), other) ==
265 Model.observe(F32, d, array, Refinement.route(d, other)) : Maybe<&2, F32>},
266 Lifecycle.false_true(Equal.sym(Bool, False{}, True{}, accepted)))
267 case True{}:
268 %Laws.checked_route_separation(d, n, i, other, index_checked, other_checked, different) :
269 {Model.observe(F32, d, Array.set(F32, array, i, value), Refinement.route(d, other)) ==
270 Model.select(F32, _, value, Model.observe(F32, d, array, Refinement.route(d, other))) : Maybe<&2, F32>}
271 StorageLaws.primitive_update_frame(F32, d, array, i, Refinement.route(d, other), value, balanced)