def h.gd_same

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

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

3263def h.gd_same(
3264  ~K: Data, ~V: Data, ~hash: K -> U32, ~eq: K -> K -> Bool,
3265  ~sound: @x: K -> @y: K -> {eq(x, y) == True{} : Bool} -> {x == y : K},
3266  n: Nat, +mask: U32, m: M.HMap<K, V>, +hk: U32, +k: K,
3267  +wf: {h.WF(~K, ~V, ~hash, ~eq, n, m) == True{} : Bool}
3268) -> {h.G(~K, ~V, ~eq, n, mask, h.D(~K, ~V, ~eq, n, mask, m, hk, k), hk, k) == None{} : Maybe<&2, V>}:
3269  match n:
3270    case 0n:
3271      match m:
3272        case M.HNil{}:
3273          {==}
3274        case M.HLeaf{+o, +es}:
3275          %h.get_leaf(~K, ~V, ~eq, 0n, mask, o, M.HMap.entries.del(~K, ~V, ~eq, es, k), hk, k) : {_ == None{} : Maybe<&2, V>}
3276          h.eg_del_same(~K, ~V, ~eq, ~sound, es, k, wf)
3277        case M.HBranch{lo, hi}:
3278          {==}
3279    case 1n+(+p):
3280      match m:
3281        case M.HNil{}:
3282          {==}
3283        case M.HLeaf{+o, +es}:
3284          h.gd_same.lf(~K, ~V, ~eq, p, mask, o, es, hk, k, U32.is_eq(o, hk), {==},
3285            h.eg_del_same(~K, ~V, ~eq, ~sound, es, k,
3286              MBool.eq_true_of_and_right(Laws.hmap_hashed(~K, ~V, ~hash, es, o), Laws.hmap_distinct(~K, ~V, ~eq, es), wf)))
3287        case M.HBranch{+lo, +hi}:
3288          h.gd_same.br(~K, ~V, ~eq, p, mask, lo, hi, hk, k, U32.is_eq((hk .&. mask : U32), 0), {==},
3289            h.gd_same(~K, ~V, ~hash, ~eq, ~sound, p, (mask << 1n : U32), lo, hk, k,
3290              MBool.eq_true_of_and_left(h.WF(~K, ~V, ~hash, ~eq, p, lo), h.WF(~K, ~V, ~hash, ~eq, p, hi), wf)),
3291            h.gd_same(~K, ~V, ~hash, ~eq, ~sound, p, (mask << 1n : U32), hi, hk, k,
3292              MBool.eq_true_of_and_right(h.WF(~K, ~V, ~hash, ~eq, p, lo), h.WF(~K, ~V, ~hash, ~eq, p, hi), wf)))

Uses (20)

Used by (1)