Skip to main content

next_mle_eval

Function next_mle_eval 

Source
pub fn next_mle_eval<R: Semiring>(u: &[R], v: &[R], zero: R, one: R) -> R
Expand description

Evaluates the next MLE in O(n), by reusing suffix equality and prefix carry products across carry positions.

Improved from O(n²) approach here: https://github.com/TomWambsgans/Whirlaway/blob/9e3592b/crates/air/src/utils.rs#L92

next_mle(u, v) = 1 iff Val(v) = Val(u) + 1 and Val(u) < 2^n - 1.

§Arguments

  • u: first n-bit vector (LE convention: index 0 = LSB).
  • v: second n-bit vector. Must have v.len() == u.len().

§Algorithm

Uses prefix/suffix products for O(n) evaluation: next_mle(u, v) = sum_{j=0}^{n-1} [prod_{i<j} u_i * (1 - v_i)] -- bits below j: were 1, flip to 0 * (1 - u_j) * v_j -- bit j: 0 → 1 * [prod_{i>j} eq(u_i, v_i)] – bits above j: unchanged

§Panics

Panics if u.len() != v.len().