def replay_size_owned

bendtorch-core@0.1.0.0 · src/storage/api.bend:475

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

475def replay_size_owned(+rest: List<&2, Laws.Op>, +d: Nat, +n: Nat, +fill: F32, +history: List<&2, Effect>,
476  hit: Bool, +dhit: {hit == hit_of(n, rest) : Bool},
477  -b: Model.Balanced(F32, d, arr(history, d, fill)), -f: {Storage.bounds(d, n) == True{} : Bool},
478  +fits: {Storage.bounds(d, n) == True{} : Bool}) ->
479  {Laws.size(Laws.replay(rest, Storage.Owned{d, n, arr(history, d, fill), b, f})) == n : Nat}:
480  match rest:
481    case Nil{}:
482      {==}
483    case +op <> +later:
484      match op:
485        case Laws.Write{+i, +w}:
486          match hit:
487            case True{}:
488              +inside_i = Equal.sym(Bool, True{}, Nat.is_lt(U32.to_nat(i), n), dhit)
489              %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)) :
490                {Laws.size(Laws.replay(later, Laws.owner(Result<&2, &2, Storage.Error, Unit>, _))) == n : Nat}
491              replay_size_owned(later, d, n, fill, Wrote{i, w} <> history, 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)
492            case False{}:
493              %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)) :
494                {Laws.size(Laws.replay(later, Laws.owner(Result<&2, &2, Storage.Error, Unit>, _))) == n : Nat}
495              replay_size_owned(later, d, n, fill, history, hit_of(n, later), {==}, b, f, fits)
496        case Laws.Read{+i}:
497          match hit:
498            case True{}:
499              +inside_i = Equal.sym(Bool, True{}, Nat.is_lt(U32.to_nat(i), n), dhit)
500              %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)) :
501                {Laws.size(Laws.replay(later, Laws.owner(Result<&2, &2, Storage.Error, F32>, _))) == n : Nat}
502              replay_size_owned(later, d, n, fill, Kept{i} <> history, 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)
503            case False{}:
504              %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)) :
505                {Laws.size(Laws.replay(later, Laws.owner(Result<&2, &2, Storage.Error, F32>, _))) == n : Nat}
506              replay_size_owned(later, d, n, fill, history, hit_of(n, later), {==}, b, f, fits)
507        case Laws.First{}:
508          %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)) :
509            {Laws.size(Laws.replay(later, Laws.owner(Storage.Storage, _))) == n : Nat}
510          replay_size_owned(later, d, n, fill, Left{} <> history, hit_of(n, later), {==}, Certificates.clone_first(F32, d, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b), f, fits)
511        case Laws.Second{}:
512          %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)) :
513            {Laws.size(Laws.replay(later, Laws.outcome(Storage.Storage, _))) == n : Nat}
514          replay_size_owned(later, d, n, fill, Right{} <> history, hit_of(n, later), {==}, Certificates.clone_second(F32, d, arr(history, d, fill), Array.clone(F32, arr(history, d, fill)), {==}, b), f, fits)
515        case Laws.Length{}:
516          replay_size_owned(later, d, n, fill, history, hit_of(n, later), {==}, b, f, fits)

Uses (43)

Used by (1)