def swap_w

lawful-arrays@0.1.0.0 · proof_shape.bend:122

import lawful-arrays@0.1.0.0/proof_shape.bend as ProofShape
import Base
import lawful-arrays@0.1.0.0/proof_base.bend as B

122def swap_w(-T: Type, a: Array<T>, +n: U32, +i: U32, v: T, +z: Bool, +d: Nat) -> SwapW(T, a, n, i, v, z, d):
123  match a z d:
124    case ALeaf{x} _ 0n:
125      (ALeaf{v}, x, {==}, {==})
126    case ALeaf{x} _ 1n+p:
127      (ALeaf{v}, x, {==}, {==})
128    case ANode{xs, ys} True{} _:
129      +h = U32.shr(n)
130      swap_w.lo(T, xs, ys, n, i, v, d, swap_w(T, xs, h, i, v, U32.is_lt(i, U32.shr(h)), B.pred(d)))
131    case ANode{xs, ys} False{} _:
132      +h = U32.shr(n)
133      +j = U32.sub(i, h)
134      swap_w.hi(T, xs, ys, n, i, v, d, swap_w(T, ys, h, j, v, U32.is_lt(j, U32.shr(h)), B.pred(d)))

Uses (12)

Used by (2)