use miden_crypto::stark::air::AirBuilder;
use crate::{CoreCols, MidenAirBuilder};
const STACK_DEPTH: usize = 16;
const TAIL_LEN: usize = STACK_DEPTH + STACK_DEPTH + 4;
pub fn enforce_main<AB>(builder: &mut AB, local: &CoreCols<AB::Var>)
where
AB: MidenAirBuilder,
{
let pv = builder.public_values();
let n = pv.len();
assert!(n >= TAIL_LEN, "public values too short: {n} < {TAIL_LEN}");
let si: [AB::PublicVar; STACK_DEPTH] = core::array::from_fn(|i| pv[n - TAIL_LEN + i]);
let so: [AB::PublicVar; STACK_DEPTH] =
core::array::from_fn(|i| pv[n - TAIL_LEN + STACK_DEPTH + i]);
{
let builder = &mut builder.when_first_row();
#[expect(
clippy::needless_range_loop,
reason = "index-based loop keeps the stack input slot mapping explicit"
)]
for i in 0..STACK_DEPTH {
builder.assert_eq(local.stack.get(i), si[i]);
}
}
{
let builder = &mut builder.when_last_row();
#[expect(
clippy::needless_range_loop,
reason = "index-based loop keeps the stack output slot mapping explicit"
)]
for i in 0..STACK_DEPTH {
builder.assert_eq(local.stack.get(i), so[i]);
}
}
}