def i32_p
bend-collections-laws-math@1.0.0.0 · proofs/math/random/wrappers.bend:93
import bend-collections-laws-math@1.0.0.0/proofs/math/random/wrappers.bend as Wrappers
import Base
import bend-collections-laws-math@1.0.0.0/spec/lib/common.bend as C
import bend-collections-laws-math@1.0.0.0/spec/math/w64.bend as SW
import bend-collections-laws-math@1.0.0.0/spec/math/random/source.bend as SRC
import bend-collections-laws-math@1.0.0.0/src/math/u64.bend as W
import bend-collections-laws-math@1.0.0.0/src/math/random/rand.bend as R
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/width.bend as WW
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/u32laws.bend as LW
93def i32_p(-S: Data, p: W.U64 & S) -> {U32.to_nat(R.fst(U32, S, R.top31(S, p))) == C.high(33n, SW.value(SRC.fst64(S, p))) : Nat}:
94 match p:
95 case Tuple{x, s}:
96 match x:
97 case W.U64{+l, +h}:
98 Equal.trans(Nat, v(U32.shr(h)), C.half(v(h)), C.high(33n, val(l, h)),
99 shr_half(h),
100 Equal.sym(Nat, C.high(33n, val(l, h)), C.half(v(h)),
101 Equal.trans(Nat, C.high(Nat.add(32n, 1n), val(l, h)), C.high(1n, C.high(32n, val(l, h))), C.half(v(h)),
102 WW.high_comp(1n, 32n, val(l, h)),
103 Equal.cong(Nat, Nat, z => C.high(1n, z), C.high(32n, val(l, h)), v(h), WW.high_u(32n, v(l), v(h), LW.vb(l))))))