def cm2

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

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/math/random/rand.bend as SR

365# the same count taken over the pairs 2y, 2y + 1 with y < N
366def cm2(+w: Nat, +m: Nat, +k: Nat, N: Nat) -> Nat:
367  match N:
368    case 0n:
369      0n
370    case 1n+ +y:
371      Nat.add(cm2(w, m, k, y), Nat.add(b2n(Nat.is_eq(SR.and_bits(w, Nat.double(y), m), k)), b2n(Nat.is_eq(SR.and_bits(w, 1n+Nat.double(y), m), k))))

Uses (6)

Used by (3)