use crate::proof::algebra::checker::support::{
boundary_grid_u32, call_binary, engine_failure_violation, simple_rng, violation,
ZERO_PRODUCT_COUNTEREXAMPLES,
};
use crate::spec::law::{AlgebraicLaw, LawViolation};
use super::witnessed::*;
fn check_commutative_exhaustive(
op_id: &str,
f: fn(&[u8]) -> Vec<u8>,
) -> Result<(u64, Option<LawViolation>), LawViolation> {
let mut cases = 0u64;
for a in 0u32..256 {
for b in 0u32..256 {
let ab = call_binary(f, a, b).map_err(|e| engine_failure_violation(op_id, e))?;
let ba = call_binary(f, b, a).map_err(|e| engine_failure_violation(op_id, e))?;
cases += 1;
if ab != ba {
return Ok((
cases,
Some(violation(op_id, "commutative", a, b, 0, ab, ba)),
));
}
}
}
Ok((cases, None))
}