def model
bendtorch-core@0.1.0.0 · src/storage/api.bend:362
import bendtorch-core@0.1.0.0/src/storage/api.bend as Api
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
362
363
364def model(+history: List<&2, Effect>, +d: Nat, +n: Nat, +fill: F32, +j: U32,
365 +fits: {Storage.bounds(d, n) == True{} : Bool}, +inside: {Nat.is_lt(U32.to_nat(j), n) == True{} : Bool},
366 valid: Valid(n, history)) ->
367 {Some{current(history, j, fill)} == Model.observe(F32, d, arr(history, d, fill), Refinement.route(d, j)) : Maybe<&2, F32>}:
368 match history:
369 case Nil{}:
370 observe_new(d, fill, Refinement.route(d, j))
371 case +effect <> +past:
372 match effect:
373 case Wrote{+i, +w}:
374 (inside_i, rest) = valid
375 %Equal.sym(Maybe<&2, F32>,
376 Model.observe(F32, d, Array.set(F32, arr(past, d, fill), i, w), Refinement.route(d, j)),
377 Model.select(F32, Model.same(d, Refinement.route(d, i), Refinement.route(d, j)), w,
378 Model.observe(F32, d, arr(past, d, fill), Refinement.route(d, j))),
379 Frame.primitive_update_frame(F32, d, arr(past, d, fill), i, Refinement.route(d, j), w, bal(past, d, fill))) :
380 {Some{current(Wrote{i, w} <> past, j, fill)} == _ : Maybe<&2, F32>}
381 %route_same(d, n, i, j, fits, inside_i, inside) :
382 {Some{current(Wrote{i, w} <> past, j, fill)} ==
383 Model.select(F32, _, w, Model.observe(F32, d, arr(past, d, fill), Refinement.route(d, j))) : Maybe<&2, F32>}
384 %model(past, d, n, fill, j, fits, inside, rest) :
385 {Some{current(Wrote{i, w} <> past, j, fill)} ==
386 Model.select(F32, Nat.is_eq(U32.to_nat(i), U32.to_nat(j)), w, _) : Maybe<&2, F32>}
387 select_pick(Nat.is_eq(U32.to_nat(i), U32.to_nat(j)), w, current(past, j, fill))
388 case Kept{+i}:
389 %Equal.sym(Array<F32>, Refinement.first(F32, Array.get(F32, arr(past, d, fill), i)), arr(past, d, fill),
390 Refinement.law_get_retains(F32, d, arr(past, d, fill), i, bal(past, d, fill))) :
391 {Some{current(past, j, fill)} == Model.observe(F32, d, _, Refinement.route(d, j)) : Maybe<&2, F32>}
392 model(past, d, n, fill, j, fits, inside, valid)
393 case Left{}:
394 %Equal.sym(Array<F32>, Pair.fst(Array<F32>, Array<F32>, Array.clone(F32, arr(past, d, fill))), arr(past, d, fill),
395 Clone.first_equal(F32, d, arr(past, d, fill), Clone.certify(F32, d, arr(past, d, fill), bal(past, d, fill)))) :
396 {Some{current(past, j, fill)} == Model.observe(F32, d, _, Refinement.route(d, j)) : Maybe<&2, F32>}
397 model(past, d, n, fill, j, fits, inside, valid)
398 case Right{}:
399 %Equal.sym(Array<F32>, Pair.snd(Array<F32>, Array<F32>, Array.clone(F32, arr(past, d, fill))), arr(past, d, fill),
400 Clone.second_equal(F32, d, arr(past, d, fill), Clone.certify(F32, d, arr(past, d, fill), bal(past, d, fill)))) :
401 {Some{current(past, j, fill)} == Model.observe(F32, d, _, Refinement.route(d, j)) : Maybe<&2, F32>}
402 model(past, d, n, fill, j, fits, inside, valid)