Api.model: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/storage/api.bend as Api Lines 362-402 of bendtorch-core@0.1.0.0/src/storage/api.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&start_line=362&end_line=402 import Base 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/clone.bend as Clone import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage import bendtorch-core@0.1.0.0/src/storage/frame.bend as Frame # Every in-bounds index has its own route, so the array after the effects # answers each read with the last value written there, or the fill. def model(+history: List<&2, Effect>, +d: Nat, +n: Nat, +fill: F32, +j: U32, +fits: {Storage.bounds(d, n) == True{} : Bool}, +inside: {Nat.is_lt(U32.to_nat(j), n) == True{} : Bool}, valid: Valid(n, history)) -> {Some{current(history, j, fill)} == Model.observe(F32, d, arr(history, d, fill), Refinement.route(d, j)) : Maybe<&2, F32>}: match history: case Nil{}: observe_new(d, fill, Refinement.route(d, j)) case +effect <> +past: match effect: case Wrote{+i, +w}: (inside_i, rest) = valid %Equal.sym(Maybe<&2, F32>, Model.observe(F32, d, Array.set(F32, arr(past, d, fill), i, w), Refinement.route(d, j)), Model.select(F32, Model.same(d, Refinement.route(d, i), Refinement.route(d, j)), w, Model.observe(F32, d, arr(past, d, fill), Refinement.route(d, j))), Frame.primitive_update_frame(F32, d, arr(past, d, fill), i, Refinement.route(d, j), w, bal(past, d, fill))) : {Some{current(Wrote{i, w} <> past, j, fill)} == _ : Maybe<&2, F32>} %route_same(d, n, i, j, fits, inside_i, inside) : {Some{current(Wrote{i, w} <> past, j, fill)} == Model.select(F32, _, w, Model.observe(F32, d, arr(past, d, fill), Refinement.route(d, j))) : Maybe<&2, F32>} %model(past, d, n, fill, j, fits, inside, rest) : {Some{current(Wrote{i, w} <> past, j, fill)} == Model.select(F32, Nat.is_eq(U32.to_nat(i), U32.to_nat(j)), w, _) : Maybe<&2, F32>} select_pick(Nat.is_eq(U32.to_nat(i), U32.to_nat(j)), w, current(past, j, fill)) case Kept{+i}: %Equal.sym(Array, Refinement.first(F32, Array.get(F32, arr(past, d, fill), i)), arr(past, d, fill), Refinement.law_get_retains(F32, d, arr(past, d, fill), i, bal(past, d, fill))) : {Some{current(past, j, fill)} == Model.observe(F32, d, _, Refinement.route(d, j)) : Maybe<&2, F32>} model(past, d, n, fill, j, fits, inside, valid) case Left{}: %Equal.sym(Array, Pair.fst(Array, Array, Array.clone(F32, arr(past, d, fill))), arr(past, d, fill), Clone.first_equal(F32, d, arr(past, d, fill), Clone.certify(F32, d, arr(past, d, fill), bal(past, d, fill)))) : {Some{current(past, j, fill)} == Model.observe(F32, d, _, Refinement.route(d, j)) : Maybe<&2, F32>} model(past, d, n, fill, j, fits, inside, valid) case Right{}: %Equal.sym(Array, Pair.snd(Array, Array, Array.clone(F32, arr(past, d, fill))), arr(past, d, fill), Clone.second_equal(F32, d, arr(past, d, fill), Clone.certify(F32, d, arr(past, d, fill), bal(past, d, fill)))) : {Some{current(past, j, fill)} == Model.observe(F32, d, _, Refinement.route(d, j)) : Maybe<&2, F32>} model(past, d, n, fill, j, fits, inside, valid) Uses (36): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.clone https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.get https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.set https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.sym https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List 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_eq 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=Pair.fst https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair.snd https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&name=Effect https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&name=Valid https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&name=arr https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&name=bal https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&name=current https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&name=observe_new https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&name=route_same https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/api.bend&name=select_pick https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/clone.bend&name=certify https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/clone.bend&name=first_equal https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/clone.bend&name=second_equal https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/frame.bend&name=primitive_update_frame https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/main.bend&name=bounds https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/model.bend&name=observe https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/model.bend&name=same https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/model.bend&name=select https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/refinement.bend&name=first https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/refinement.bend&name=law_get_retains https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/storage/refinement.bend&name=route