def cl_w
bend-collections-laws-crypto@1.0.0.0 · proofs/math/typed/w64est.bend:104
import bend-collections-laws-crypto@1.0.0.0/proofs/math/typed/w64est.bend as W64est
import Base
import bend-collections-laws-crypto@1.0.0.0/spec/lib/common.bend as C
import bend-collections-laws-crypto@1.0.0.0/spec/math/w64.bend as SW
import bend-collections-laws-crypto@1.0.0.0/src/math/w64.bend as X
import bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend as WU
import bend-collections-laws-crypto@1.0.0.0/proofs/lib/logic.bend as L
import bend-collections-laws-crypto@1.0.0.0/proofs/lib/word.bend as WD
104
105
106
107def cl_w(+one: Nat, +h1: {one == 1n : Nat}, +m: U32, +pm: {m == U32{WD.mask(32n, 32n)} : U32}, +hm: {4294967295 == m : U32}, +x: Nat, +bv: Nat, +q: WU.U64, +c: Bool, +hc: {U32.is_zero(X.hi(q)) == c : Bool}, +w: U32, +hw: {X.q_clamp_z(X.lo(q), c) == w : U32}, +hq: {Nat.is_lt(x, Nat.mul(1n+SW.value(q), bv)) == True{} : Bool}, +hX: {Nat.is_lt(x, Nat.mul(C.shift(32n, one), bv)) == True{} : Bool}) -> {Nat.is_lt(x, Nat.mul(1n+v(w), bv)) == True{} : Bool}:
108 match c:
109 case True{}:
110 +hl = L.subst(Nat, z => {Nat.is_lt(x, Nat.mul(1n+z, bv)) == True{} : Bool}, SW.value(q), v(X.lo(q)), Equal.sym(Nat, v(X.lo(q)), SW.value(q), lo_hi0(q, hc)), hq)
111 L.subst(U32, z => {Nat.is_lt(x, Nat.mul(1n+v(z), bv)) == True{} : Bool}, X.lo(q), w, hw, hl)
112 case False{}:
113 +hm1 = L.subst(Nat, z => {Nat.is_lt(x, Nat.mul(z, bv)) == True{} : Bool}, C.shift(32n, one), 1n+v(m), Equal.sym(Nat, 1n+v(m), C.shift(32n, one), m32(one, h1, m, pm)), hX)
114 L.subst(U32, z => {Nat.is_lt(x, Nat.mul(1n+v(z), bv)) == True{} : Bool}, m, w, Equal.trans(U32, m, 4294967295, w, Equal.sym(U32, 4294967295, m, hm), hw), hm1)