-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBytecode.lean
More file actions
83 lines (70 loc) · 2.1 KB
/
Bytecode.lean
File metadata and controls
83 lines (70 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module
public import Ix.Aiur.Goldilocks
public section
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
| eqZero : ValIdx → Op
| call : FunIdx → Array ValIdx → (outputSize : Nat) → Op
| store : Array ValIdx → Op
| load : (size : Nat) → ValIdx → Op
| assertEq : Array ValIdx → Array ValIdx → Op
| ioGetInfo : Array ValIdx → Op
| ioSetInfo : Array ValIdx → ValIdx → ValIdx → Op
| ioRead : ValIdx → Nat → Op
| ioWrite : Array ValIdx → Op
| u8BitDecomposition : ValIdx → Op
| u8ShiftLeft : ValIdx → Op
| u8ShiftRight : ValIdx → Op
| u8Xor : ValIdx → ValIdx → Op
| u8Add : ValIdx → ValIdx → Op
| u8Sub : ValIdx → ValIdx → Op
| u8And : ValIdx → ValIdx → Op
| u8Or : ValIdx → ValIdx → Op
| u8LessThan : ValIdx → ValIdx → Op
| debug : String → Option (Array 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 FunctionLayout where
inputSize : Nat
/-- 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
/-- Lookups can be shared across calls, stores, loads and returns from
different paths. -/
lookups : Nat
deriving Inhabited, Repr
structure Function where
body : Block
layout: FunctionLayout
unconstrained : Bool
deriving Inhabited, Repr
structure Toplevel where
functions : Array Function
memorySizes : Array Nat
deriving Repr
end Bytecode
end Aiur
end