use libm::log2;
use crate::error::ErrorBits;
use crate::shape::{InstanceShape, StarkAirParams};
pub fn deep_ali_error(air: &StarkAirParams, shape: &InstanceShape, list_size: f64) -> ErrorBits {
if shape.modulus_bits == 0 || !list_size.is_finite() || list_size <= 0.0 {
return ErrorBits::from_log2(0.0);
}
let k = (1u64 << shape.log_trace_length) as f64;
let max_deg = air.max_constraint_degree.max(1) as f64;
let combo = air.max_combo as f64;
let factor = (max_deg * (k + combo - 1.0) + (k - 1.0)).max(1.0);
let bits = shape.modulus_bits as f64 - log2(list_size) - log2(factor);
ErrorBits::from_log2(bits.max(0.0))
}