Skip to content

Initializing Aiur2 #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ binius_utils = { git = "https://github.com/IrreducibleOSS/binius.git", rev = "23
bumpalo = "3"
groestl_crypto = { package = "groestl", version = "0.10.1" }
proptest = "1"
p3-goldilocks = "0.3.0"
p3-field = "0.3.0"
rayon = "1"
rand = "0.9.1"
rustc-hash = "2"
Expand Down
1 change: 0 additions & 1 deletion Ix/Aiur/Simple.lean
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def checkAndSimplifyToplevel (toplevel : Toplevel) : Except CheckError TypedDecl
| .constructor d c => pure $ typedDecls.insert name (.constructor d c)
| .dataType d => pure $ typedDecls.insert name (.dataType d)
| .function f => do
let _ ← (checkFunction f) (getFunctionContext f decls)
let f ← (checkFunction f) (getFunctionContext f decls)
pure $ typedDecls.insert name (.function f)
| .gadget g => pure $ typedDecls.insert name (.gadget g)
Expand Down
69 changes: 69 additions & 0 deletions Ix/Aiur2/Bytecode.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import Ix.Aiur2.Goldilocks

namespace Aiur

namespace Bytecode

abbrev FunIdx := Nat
abbrev ValIdx := Nat
abbrev SelIdx := Nat

inductive Op
| const : G → Op
| add : ValIdx → ValIdx → Op
| sub : ValIdx → ValIdx → Op
| mul : ValIdx → ValIdx → Op
| call : FunIdx → Array ValIdx → Op
| store : Array ValIdx → Op
| load : (width : Nat) → ValIdx → Op
deriving Repr

mutual
inductive Ctrl where
| match : ValIdx → Array (G × Block) → Option Block → Ctrl
| return : SelIdx → Array ValIdx → Ctrl
deriving Inhabited, Repr

structure Block where
ops : Array Op
ctrl : Ctrl
minSelIncluded: SelIdx
maxSelExcluded: SelIdx
deriving Inhabited, Repr
end

/-- The circuit layout of a function -/
structure CircuitLayout where
/-- Bit values that identify which path the computation took.
Exactly one selector must be set. -/
selectors : Nat
/-- Represent registers that hold temporary values and can be shared by
different circuit paths, since they never overlap. -/
auxiliaries : Nat
/-- Constraint slots that can be shared in different paths of the circuit. -/
sharedConstraints : Nat
deriving Inhabited, Repr

structure Function where
inputSize : Nat
outputSize : Nat
body : Block
circuitLayout: CircuitLayout
deriving Inhabited, Repr

structure Toplevel where
functions : Array Function
memoryWidths : Array Nat
deriving Repr

@[extern "c_rs_toplevel_execute_test"]
private opaque Toplevel.executeTest' :
@& Toplevel → @& FunIdx → @& Array G → USize → Array G

def Toplevel.executeTest (toplevel : Toplevel) (funIdx : FunIdx) (args : Array G) : Array G :=
let function := toplevel.functions[funIdx]!
toplevel.executeTest' funIdx args function.outputSize.toUSize

end Bytecode

end Aiur
Loading