def tupd

bend-collections-laws-crypto@1.0.0.0 · proofs/lib/array.bend:63

import bend-collections-laws-crypto@1.0.0.0/proofs/lib/array.bend as Array
import Base
import bend-collections-laws-crypto@1.0.0.0/spec/lib/common.bend as SC

63def tupd(-T: Data, d: Nat, t: Tree<T>, +j: Nat, +v: T, left: Bool) -> Tree<T>:
64  match d t left:
65    case 0n TLeaf{x} _:
66      TLeaf{v}
67    case 0n TNode{l, r} _:
68      TNode{l, r}
69    case 1n+p TLeaf{x} _:
70      TLeaf{x}
71    case 1n+ +p TNode{l, r} True{}:
72      TNode{tupd(T, p, l, j, v, ndec(p, j)), r}
73    case 1n+ +p TNode{l, r} False{}:
74      TNode{l, tupd(T, p, r, Nat.sub(j, SC.pow2(p)), v, ndec(p, Nat.sub(j, SC.pow2(p))))}

Uses (6)

Used by (4)