def and_self

bend-collections-laws-crypto@1.0.0.0 · proofs/math/random/lemire.bend:484

import bend-collections-laws-crypto@1.0.0.0/proofs/math/random/lemire.bend as Lemire
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/random/rand.bend as SR
import bend-collections-laws-crypto@1.0.0.0/proofs/math/typed/width.bend as WI

484# x & x is the low w bits of x
485def and_self(+w: Nat, +x: Nat) -> {SR.and_bits(w, x, x) == C.low(w, x) : Nat}:
486  match w:
487    case 0n:
488      {==}
489    case 1n+v:
490      %Equal.sym(Nat, Nat.mul(C.bit(x), C.bit(x)), C.bit(x), bitsq_b(C.bit(x), WI.bit_le1(x))) : {Nat.add(_, Nat.double(SR.and_bits(v, C.half(x), C.half(x)))) == Nat.add(C.bit(x), Nat.double(C.low(v, C.half(x)))) : Nat}
491      Equal.cong(Nat, Nat, z => Nat.add(C.bit(x), Nat.double(z)), SR.and_bits(v, C.half(x), C.half(x)), C.low(v, C.half(x)), and_self(v, C.half(x)))

Uses (12)

Used by (1)