def replay_status
bendtorch-core@0.1.0.0 · src/storage/api.bend:546
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/certificates.bend as Certificates
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as Laws
546def replay_status(+rest: List<&2, Laws.Op>, +d: Nat, +n: Nat, +fill: F32, +history: List<&2, Effect>, +j: U32, +v: F32,
547 hit: Bool, +dhit: {hit == hit_of(n, rest) : Bool},
548 -b: Model.Balanced(F32, d, arr(history, d, fill)), -f: {Storage.bounds(d, n) == True{} : Bool},
549 +fits: {Storage.bounds(d, n) == True{} : Bool}, +inside: {Nat.is_lt(U32.to_nat(j), n) == True{} : Bool}) ->
550 {Laws.status(Laws.replay(rest, Storage.Owned{d, n, arr(history, d, fill), b, f}), j, v) == Done{Unit{}} : Result<&2, &2, Storage.Error, Unit>}:
551 match rest:
552 case Nil{}:
553 status_hit(d, n, arr(history, d, fill), b, f, fits, j, v, inside)
554 case +op <> +later:
555 match op:
556 case Laws.Write{+i, +w}:
557 match hit:
558 case True{}:
559 +inside_i = Equal.sym(Bool, True{}, Nat.is_lt(U32.to_nat(i), n), dhit)
560 %Equal.sym(Storage.Storage & Result<&2, &2, Storage.Error, Unit>, Storage.set_checked(d, n, arr(history, d, fill), i, w, Nat.is_lt(U32.to_nat(i), n), {==}, b, f), (Storage.Owned{d, n, Array.set(F32, arr(history, d, fill), i, w), Certificates.set_result(F32, d, arr(history, d, fill), i, w, Array.set(F32, arr(history, d, fill), i, w), {==}, b), f}, Done{Unit{}}), set_checked_hit(d, n, arr(history, d, fill), i, w, Nat.is_lt(U32.to_nat(i), n), {==}, b, f, dhit, fits, inside_i)) :
561 {Laws.status(Laws.replay(later, Laws.owner(Result<&2, &2, Storage.Error, Unit>, _)), j, v) == Done{Unit{}} : Result<&2, &2, Storage.Error, Unit>}
562 replay_status(later, d, n, fill, Wrote{i, w} <> history, j, v, hit_of(n, later), {==}, Certificates.set_result(F32, d, arr(history, d, fill), i, w, Array.set(F32, arr(history, d, fill), i, w), {==}, b), f, fits, inside)
563 case False{}:
564 %Equal.sym(Storage.Storage & Result<&2, &2, Storage.Error, Unit>, Storage.set_checked(d, n, arr(history, d, fill), i, w, Nat.is_lt(U32.to_nat(i), n), {==}, b, f), (Storage.Owned{d, n, arr(history, d, fill), b, f}, Fail{Storage.OutOfBounds{}}), set_checked_miss(d, n, arr(history, d, fill), i, w, Nat.is_lt(U32.to_nat(i), n), {==}, b, f, dhit)) :
565 {Laws.status(Laws.replay(later, Laws.owner(Result<&2, &2, Storage.Error, Unit>, _)), j, v) == Done{Unit{}} : Result<&2, &2, Storage.Error, Unit>}
566 replay_status(later, d, n, fill, history, j, v, hit_of(n, later), {==}, b, f, fits, inside)
567 case Laws.Read{+i}:
568 match hit:
569 case True{}:
570 +inside_i = Equal.sym(Bool, True{}, Nat.is_lt(U32.to_nat(i), n), dhit)
571 %Equal.sym(Storage.Storage & Result<&2, &2, Storage.Error, F32>, Storage.get_checked(d, n, arr(history, d, fill), i, Nat.is_lt(U32.to_nat(i), n), {==}, b, f), (Storage.Owned{d, n, Refinement.first(F32, Array.get(F32, arr(history, d, fill), i)), Certificates.get_result(F32, d, arr(history, d, fill), i, Array.get(F32, arr(history, d, fill), i), {==}, b), f}, Done{Refinement.second(F32, Array.get(F32, arr(history, d, fill), i))}), get_checked_keep(d, n, arr(history, d, fill), i, Nat.is_lt(U32.to_nat(i), n), {==}, b, f, dhit, fits, inside_i)) :
572 {Laws.status(Laws.replay(later, Laws.owner(Result<&2, &2, Storage.Error, F32>, _)), j, v) == Done{Unit{}} : Result<&2, &2, Storage.Error, Unit>}
573 replay_status(later, d, n, fill, Kept{i} <> history, j, v, hit_of(n, later), {==}, Certificates.get_result(F32, d, arr(history, d, fill), i, Array.get(F32, arr(history, d, fill), i), {==}, b), f, fits, inside)
574 case False{}:
575 %Equal.sym(Storage.Storage & Result<&2, &2, Storage.Error, F32>, Storage.get_checked(d, n, arr(history, d, fill), i, Nat.is_lt(U32.to_nat(i), n), {==}, b, f), (Storage.Owned{d, n, arr(history, d, fill), b, f}, Fail{Storage.OutOfBounds{}}), get_checked_stay(d, n, arr(history, d, fill), i, Nat.is_lt(U32.to_nat(i), n), {==}, b, f, dhit)) :
576 {Laws.status(Laws.replay(later, Laws.owner(Result<&2, &2, Storage.Error, F32>, _)), j, v) == Done{Unit{}} : Result<&2, &2, Storage.Error, Unit>}
577 replay_status(later, d, n, fill, history, j, v, hit_of(n, later), {==}, b, f, fits, inside)
578 case Laws.First{}:
579 %Equal.sym(Storage.Storage & Storage.Storage, Storage.finish_clone(d, n, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b, f), (Storage.Owned{d, n, Pair.fst(Array<F32>, Array<F32>, Array.clone(F32, arr(history, d, fill))), Certificates.clone_first(F32, d, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b), f}, Storage.Owned{d, n, Pair.snd(Array<F32>, Array<F32>, Array.clone(F32, arr(history, d, fill))), Certificates.clone_second(F32, d, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b), f}), finish_pair(d, n, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b, f)) :
580 {Laws.status(Laws.replay(later, Laws.owner(Storage.Storage, _)), j, v) == Done{Unit{}} : Result<&2, &2, Storage.Error, Unit>}
581 replay_status(later, d, n, fill, Left{} <> history, j, v, hit_of(n, later), {==}, Certificates.clone_first(F32, d, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b), f, fits, inside)
582 case Laws.Second{}:
583 %Equal.sym(Storage.Storage & Storage.Storage, Storage.finish_clone(d, n, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b, f), (Storage.Owned{d, n, Pair.fst(Array<F32>, Array<F32>, Array.clone(F32, arr(history, d, fill))), Certificates.clone_first(F32, d, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b), f}, Storage.Owned{d, n, Pair.snd(Array<F32>, Array<F32>, Array.clone(F32, arr(history, d, fill))), Certificates.clone_second(F32, d, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b), f}), finish_pair(d, n, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b, f)) :
584 {Laws.status(Laws.replay(later, Laws.outcome(Storage.Storage, _)), j, v) == Done{Unit{}} : Result<&2, &2, Storage.Error, Unit>}
585 replay_status(later, d, n, fill, Right{} <> history, j, v, hit_of(n, later), {==}, Certificates.clone_second(F32, d, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b), f, fits, inside)
586 case Laws.Length{}:
587 replay_status(later, d, n, fill, history, j, v, hit_of(n, later), {==}, b, f, fits, inside)