chore(aiur): Migrate Aiur to new pipeline#392
Merged
arthurpaulino merged 1 commit intomainfrom Apr 22, 2026
Merged
Conversation
Replace old Aiur implementation with a new staged pipeline. The new pipeline has explicit IRs per stage (Source, Typed, Simple, Concrete, Bytecode) under `Ix/Aiur/Stages/` and dedicated compiler passes under `Ix/Aiur/Compiler/` (Check, Match, Simple, Concretize, Layout, Lower, Dedup). Highlights: - `Ix/Aiur/Goldilocks.lean` centralizes `G` arithmetic — Add/Sub/Mul instances, u8/u32 gadget semantics, eqZero, BitDecomposition, commutativity lemmas — removing duplicated `gPrime`/`mkG`/`addG`/ `subG`/`mulG` helpers from per-file evaluators. - `Ix/Aiur/Meta.lean` is the DSL elaborator. The `⟦ ... ⟧` surface parses the same programs as before (including `fold(i..j, init, |acc, @v| body)`, range slices `trm[i..j]`, and indexed access/set via `@v`), with the fold construct unrolled at elaboration time. - Polymorphic constructor patterns in nested matches now mangle correctly: the match compiler threads the per-switch scrutinee type through `Decision.switch`, so concretize's `rewritePattern` sees the right `tArgs` and rewrites `List.Nil` → `List_G.Nil` (etc.). - `Ix/Aiur/Interpret.lean` is the `partial` debug interpreter — `callCache`, call-stack-trace errors, `dbg_trace` on `.debug` ops, plus two semantic refinements (`ioSetInfo` errors on existing key, `ioRead` errors on OOB). - `Ix/Aiur/Semantics/` keeps the reference evaluators needed by the cross-agreement tests: `SourceEval` (on `Source.Term`) and `BytecodeEval` (Lean-native bytecode evaluator), plus `Flatten` and `BytecodeFfi`. Proof-only evaluators (`TypedEval`, `ConcreteEval`) and the full proofs layer are excluded from this PR. - `Tests/Aiur/Cross.lean` compares source-eval and bytecode-eval outputs on every surface-language program. - `Ix/Aiur/Statistics.lean` ports the circuit-size reporter used by `kernel`. - `Ix/Lib.lean` gathers generic List/Array/HashMap lemmas. - `lakefile.lean`: `precompileModules := true` on the `Ix` lib to enable `native_decide` in `G.one_ne_zero`. Consumers (IxVM, Kernel, Benchmarks, Tests/Aiur prover suite) migrated to the new API. `lake test`, `lake test -- --ignored aiur ixvm`, and `lake exe kernel Nat.add_comm` all pass with circuit widths/FFT cost identical to main.
7b5b0a0 to
96d98df
Compare
gabriel-barrett
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace old Aiur implementation with a new staged pipeline. The new pipeline has explicit IRs per stage (Source, Typed, Simple, Concrete, Bytecode) under
Ix/Aiur/Stages/and dedicated compiler passes underIx/Aiur/Compiler/(Check, Match, Simple, Concretize, Layout, Lower, Dedup).Highlights:
Ix/Aiur/Goldilocks.leancentralizesGarithmetic — Add/Sub/Mul instances, u8/u32 gadget semantics, eqZero, BitDecomposition, commutativity lemmas — removing duplicatedgPrime/mkG/addG/subG/mulGhelpers from per-file evaluators.Ix/Aiur/Meta.leanis the DSL elaborator. The⟦ ... ⟧surface parses the same programs as before (includingfold(i..j, init, |acc, @v| body), range slicestrm[i..j], and indexed access/set via@v), with the fold construct unrolled at elaboration time.Decision.switch, so concretize'srewritePatternsees the righttArgsand rewritesList.Nil→List_G.Nil(etc.).Ix/Aiur/Interpret.leanis thepartialdebug interpreter —callCache, call-stack-trace errors,dbg_traceon.debugops, plus two semantic refinements (ioSetInfoerrors on existing key,ioReaderrors on OOB).Ix/Aiur/Semantics/keeps the reference evaluators needed by the cross-agreement tests:SourceEval(onSource.Term) andBytecodeEval(Lean-native bytecode evaluator), plusFlattenandBytecodeFfi. Proof-only evaluators (TypedEval,ConcreteEval) and the full proofs layer are excluded from this PR.Tests/Aiur/Cross.leancompares source-eval and bytecode-eval outputs on every surface-language program.Ix/Aiur/Statistics.leanports the circuit-size reporter used bykernel.Ix/Lib.leangathers generic List/Array/HashMap lemmas.lakefile.lean:precompileModules := trueon theIxlib to enablenative_decideinG.one_ne_zero.Consumers (IxVM, Kernel, Benchmarks, Tests/Aiur prover suite) migrated to the new API.
lake test,lake test -- --ignored aiur ixvm, andlake exe kernel Nat.add_commall pass with circuit widths/FFT cost identical to main.