def shr_half

bend-collections-laws-math@1.0.0.0 · proofs/math/random/wrappers.bend:83

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/proofs/lib/u32.bend as U
import bend-collections-laws-math@1.0.0.0/proofs/lib/lemmas/spec/numeric.bend as S
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/width.bend as WW

83# x >> 1 is half of x
84def shr_half(+x: U32) -> {v(U32.shr(x)) == C.half(v(x)) : Nat}:
85  +b = S.bit_value(U.low_bit(x))
86  +y = v(U32.shr(x))
87  Equal.sym(Nat, C.half(v(x)), y,
88    Equal.trans(Nat, C.half(v(x)), C.half(Nat.add(b, Nat.double(y))), y,
89      Equal.cong(Nat, Nat, z => C.half(z), v(x), Nat.add(b, Nat.double(y)), U.shr_split(x)),
90      Equal.trans(Nat, C.half(Nat.add(b, Nat.double(y))), Nat.add(C.half(b), y), y, WW.half_dbl(b, y),
91        Equal.cong(Nat, Nat, z => Nat.add(z, y), C.half(b), 0n, half_bv(U.low_bit(x))))))

Uses (15)

Used by (1)