def h.gp_other

bend-kit-collections@0.1.4.1 · PROOF.bend:3195

import bend-kit-collections@0.1.4.1/PROOF.bend as PROOF
import Base
import bend-mathlib@0.7.4.0/bool.bend as MBool
import bend-kit-collections@0.1.4.1/LAWS.bend as Laws
import bend-kit-collections@0.1.4.1/hmap.bend as M

3195def h.gp_other(
3196  ~K: Data, ~V: Data, ~hash: K -> U32, ~eq: K -> K -> Bool,
3197  ~sound: @x: K -> @y: K -> {eq(x, y) == True{} : Bool} -> {x == y : K},
3198  n: Nat, +mask: U32, m: M.HMap<K, V>, +h2: U32, +k2: K, +k: K, +v: V,
3199  +wf: {h.WF(~K, ~V, ~hash, ~eq, n, m) == True{} : Bool}, +nk: {eq(k, k2) == False{} : Bool}
3200) -> {h.G(~K, ~V, ~eq, n, mask, h.P(~K, ~V, ~eq, n, mask, m, h2, k2, v), hash(k), k)
3201      == h.G(~K, ~V, ~eq, n, mask, m, hash(k), k) : Maybe<&2, V>}:
3202  match n:
3203    case 0n:
3204      match m:
3205        case M.HNil{}:
3206          h.eg_put_other(~K, ~V, ~eq, ~sound, Nil{}, k2, k, v, nk)
3207        case M.HLeaf{o, es}:
3208          h.eg_put_other(~K, ~V, ~eq, ~sound, es, k2, k, v, nk)
3209        case M.HBranch{lo, hi}:
3210          {==}
3211    case 1n+(+p):
3212      match m:
3213        case M.HNil{}:
3214          h.bool_none(V, U32.is_eq(h2, hash(k)), h.EG(~K, ~V, ~eq, [M.Entry{k2, v}], k),
3215            h.eg_put_other(~K, ~V, ~eq, ~sound, Nil{}, k2, k, v, nk))
3216        case M.HLeaf{+o, +es}:
3217          h.gp_other.lf(~K, ~V, ~hash, ~eq, ~sound, p, mask, o, es, h2, k2, k, v, nk, U32.is_eq(o, h2),
3218            h.split_other(~K, ~V, ~hash, ~eq, ~sound, 1n+p, mask, o, es, h2, k2, k, v,
3219              MBool.eq_true_of_and_left(Laws.hmap_hashed(~K, ~V, ~hash, es, o), Laws.hmap_distinct(~K, ~V, ~eq, es), wf), nk))
3220        case M.HBranch{+lo, +hi}:
3221          h.gp_other.br(~K, ~V, ~eq, p, mask, lo, hi, h2, k2, hash(k), k, v, U32.is_eq((h2 .&. mask : U32), 0),
3222            h.gp_other(~K, ~V, ~hash, ~eq, ~sound, p, (mask << 1n : U32), lo, h2, k2, k, v,
3223              MBool.eq_true_of_and_left(h.WF(~K, ~V, ~hash, ~eq, p, lo), h.WF(~K, ~V, ~hash, ~eq, p, hi), wf), nk),
3224            h.gp_other(~K, ~V, ~hash, ~eq, ~sound, p, (mask << 1n : U32), hi, h2, k2, k, v,
3225              MBool.eq_true_of_and_right(h.WF(~K, ~V, ~hash, ~eq, p, lo), h.WF(~K, ~V, ~hash, ~eq, p, hi), wf), nk))

Uses (23)

Used by (2)