Formal verification of the S-two AIR
StarkWare's S-two prover encodes Cairo virtual machine execution as an algebraic intermediate representation (AIR) over a finite field. Trust in blockchain certificates requires that the AIR encoding is sound, meaning its satisfiability implies the claimed computation actually ran to completion.
The authors formally verify soundness of the S-two AIR using Lean 4 and Mathlib. The formalization models the constraint-generating code and logup communication constraints between AIR components in Lean, proving that satisfying the AIR implies the existence of a valid Cairo execution trace. A key challenge addressed is that the AIR uses constraints over a 31-bit Felt prime to establish claims about 252-bit Felt252 computations, representing each Felt252 as a tuple of 28 range-checked 9-bit values. The logup mechanism is formalized via a lemma on rational function sums that establishes subset or equal-counts relations between component tuples.
The verification uncovered an instance where additional range checks were needed for soundness, and insufficient security bounds in the logup protocol led StarkWare to increase the number of security bits. The soundness theorem is proved against the same Cairo virtual machine semantics previously used for the Stone AIR verification.
