diff --git a/.github/workflows/formal.yml b/.github/workflows/formal.yml new file mode 100644 index 000000000..ed9c77570 --- /dev/null +++ b/.github/workflows/formal.yml @@ -0,0 +1,69 @@ +name: Formal model + +on: + push: + branches: ["main"] + paths: ["formal/**", ".github/workflows/formal.yml"] + pull_request: + paths: ["formal/**", ".github/workflows/formal.yml"] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lean: + name: Lean build and export check + runs-on: ubuntu-latest + timeout-minutes: 120 + defaults: + run: + working-directory: formal + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install elan + env: + ELAN_VERSION: v4.2.4 + ELAN_SHA256: 42b94d4244e8353142c456ec0e4ca6528fd898a6c604d4059f494e706e431f63 + run: | + cd "$(mktemp -d)" + curl -sSfL "https://github.com/leanprover/elan/releases/download/${ELAN_VERSION}/elan-x86_64-unknown-linux-gnu.tar.gz" -o elan.tar.gz + echo "${ELAN_SHA256} elan.tar.gz" | sha256sum -c - + tar xzf elan.tar.gz + ./elan-init -y --default-toolchain none + echo "$HOME/.elan/bin" >> "$GITHUB_PATH" + + # Clean and CompPoly are compiled from source; Mathlib and its dependencies come from + # `lake exe cache get`. One entry per toolchain and manifest, holding the source-built + # packages and the LambdaVM build only (a directory in `path` is archived whole, so an + # exclusion under it has no effect). + - name: Cache Lake builds + uses: actions/cache@v4 + with: + path: | + formal/.lake/build + formal/.lake/packages/Clean + formal/.lake/packages/CompPoly + key: lake-src-${{ hashFiles('formal/lean-toolchain', 'formal/lake-manifest.json') }} + + - name: Fetch Mathlib binaries + run: lake exe cache get + + - name: Build + run: lake build + + - name: Export is up to date + run: | + lake env lean --run LambdaVM/Export.lean + git diff --exit-code -- export + untracked=$(git ls-files --others --exclude-standard -- export) + if [ -n "$untracked" ]; then + echo "export files not committed:" + echo "$untracked" + exit 1 + fi diff --git a/Cargo.lock b/Cargo.lock index 56cf0e6a4..8687484d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -814,6 +814,7 @@ dependencies = [ "math-cuda", "rayon", "rkyv", + "serde_json", "stark", "sysinfo", "tikv-jemalloc-ctl", diff --git a/crypto/stark/src/constraint_ir/interp.rs b/crypto/stark/src/constraint_ir/interp.rs index a03044066..efccf46af 100644 --- a/crypto/stark/src/constraint_ir/interp.rs +++ b/crypto/stark/src/constraint_ir/interp.rs @@ -160,6 +160,36 @@ where values[root as usize].as_base() } +/// Evaluate every root of `prog` on one base-field main row, with the LogUp +/// challenges and alpha powers given, each root promoted to the extension. For +/// the differential tests: no aux columns, no table offset, row 0 only. +pub fn eval_program_roots( + prog: &ConstraintProgram, + main_row: &[FieldElement], + challenges: &[FieldElement], + alpha_powers: &[FieldElement], +) -> Vec> +where + F: IsSubFieldOf, + E: IsField, +{ + let values = run( + prog, + |main, _offset, row, col| { + assert!(main, "aux leaves are not part of a main-row program"); + assert_eq!(row, 0, "a main-row program reads row 0 only"); + Value::Base(main_row[col as usize].clone()) + }, + |idx| challenges[idx as usize].clone(), + |idx| alpha_powers[idx as usize].clone(), + || panic!("table_offset leaves are not part of a main-row program"), + ); + prog.roots + .iter() + .map(|&root| values[root as usize].to_ext()) + .collect() +} + /// Full prover entry point: evaluate every constraint in `prog` against `ctx` /// (must be [`TransitionEvaluationContext::Prover`]), writing base-field /// ([`Dim::Base`]-rooted) constraints into `base_evals` and extension-field diff --git a/crypto/stark/src/constraint_ir/mod.rs b/crypto/stark/src/constraint_ir/mod.rs index 380f32d86..be116bfa1 100644 --- a/crypto/stark/src/constraint_ir/mod.rs +++ b/crypto/stark/src/constraint_ir/mod.rs @@ -37,5 +37,5 @@ mod tests; pub use builder::{Expr, IrBuilder}; pub use device::{DeviceNode, DeviceProgram, eval_device_program}; -pub use interp::{eval_program, eval_program_base, eval_program_verifier}; +pub use interp::{eval_program, eval_program_base, eval_program_roots, eval_program_verifier}; pub use ir::{ConstraintProgram, Dim, Op}; diff --git a/crypto/stark/src/lookup.rs b/crypto/stark/src/lookup.rs index ceda5417a..886220b78 100644 --- a/crypto/stark/src/lookup.rs +++ b/crypto/stark/src/lookup.rs @@ -1413,6 +1413,8 @@ pub enum Multiplicity { impl Multiplicity { /// Evaluate the multiplicity expression to a field element. `get_col(i)` /// must return the value of main column `i` at the row being evaluated. + /// + /// Public so the prover's `lean_diff` test can evaluate multiplicities on a row. #[inline] fn evaluate_with(&self, get_col: G) -> FieldElement where @@ -1970,7 +1972,8 @@ impl LogUpLayout { /// Capture a [`Multiplicity`] as a base-field expression, mirroring /// [`Multiplicity::evaluate_with`]. -fn emit_multiplicity(b: &B, multiplicity: &Multiplicity, offset: usize) -> B::Expr +/// An interaction's multiplicity as the expression the verifier evaluates. +pub fn emit_multiplicity(b: &B, multiplicity: &Multiplicity, offset: usize) -> B::Expr where F: IsField, E: IsField, @@ -2159,7 +2162,7 @@ where /// accumulator. The prover folder runs this body once per LDE row, where /// collecting the terms in a `Vec` costs a heap allocation per fingerprint /// per row. -fn emit_fingerprint(b: &B, interaction: &BusInteraction, offset: usize) -> B::ExprE +pub fn emit_fingerprint(b: &B, interaction: &BusInteraction, offset: usize) -> B::ExprE where F: IsField, E: IsField, diff --git a/formal/.gitignore b/formal/.gitignore new file mode 100644 index 000000000..01f8cdb63 --- /dev/null +++ b/formal/.gitignore @@ -0,0 +1 @@ +.lake/ diff --git a/formal/LambdaVM.lean b/formal/LambdaVM.lean new file mode 100644 index 000000000..298ab5036 --- /dev/null +++ b/formal/LambdaVM.lean @@ -0,0 +1,15 @@ +module + +public import LambdaVM.Field +public import LambdaVM.AluOp +public import LambdaVM.StaticLookup +public import LambdaVM.Templates.IsBit +public import LambdaVM.Templates.Add +public import LambdaVM.Tables.Bitwise +public import LambdaVM.Templates.IsByte +public import LambdaVM.Buses.Alu +public import LambdaVM.Tables.Lt +public import LambdaVM.Tables.Eq +public import LambdaVM.Tables.Shift +public import LambdaVM.Ensembles.EqLookup +public import LambdaVM.Channels.Counted diff --git a/formal/LambdaVM/AluOp.lean b/formal/LambdaVM/AluOp.lean new file mode 100644 index 000000000..0a5dd048a --- /dev/null +++ b/formal/LambdaVM/AluOp.lean @@ -0,0 +1,23 @@ +module + +public import LambdaVM.Field + +@[expose] public section + +/-! +# `alu_op` descriptors (`prover/src/tables/types.rs`) + +One enumeration serves two places: the `opsel` of the `BYTE_ALU` lookup (AND, OR, XOR) and the +low bits of the flag byte on the `ALU` bus (EQ, LT, SHIFT). +-/ + +namespace LambdaVM + +def opselAND : ℕ := 0 +def opselOR : ℕ := 1 +def opselXOR : ℕ := 2 +def opselEQ : ℕ := 3 +def opselLT : ℕ := 4 +def opselSHIFT : ℕ := 5 + +end LambdaVM diff --git a/formal/LambdaVM/Buses/Alu.lean b/formal/LambdaVM/Buses/Alu.lean new file mode 100644 index 000000000..dd1a162f0 --- /dev/null +++ b/formal/LambdaVM/Buses/Alu.lean @@ -0,0 +1,99 @@ +module + +public import LambdaVM.Field +public import LambdaVM.AluOp + +@[expose] public section + +/-! +# ALU bus (`BusId::Alu`) + +`ALU[out; in1, in2, flags]`: operands and result travel as `(lo32, hi32)` pairs, `flags` +carries the `alu_op` descriptor plus per-chip flag bits. Every ALU chip pushes to this +channel; the CPU pulls. Each chip adds the clause of `Guarantees` for its own `opsel`. +-/ + +namespace LambdaVM.Alu + +structure Msg (F : Type) where + in1Lo : F + in1Hi : F + in2Lo : F + in2Hi : F + flags : F + outLo : F + outHi : F +deriving ProvableStruct + +/-- `lhs < rhs` on 64-bit values, signed (two's complement) or unsigned, as a bit. -/ +def ltRaw (signed L R : ℕ) : ℕ := + if signed = 1 then (if (BitVec.ofNat 64 L).slt (BitVec.ofNat 64 R) then 1 else 0) + else (if (BitVec.ofNat 64 L).ult (BitVec.ofNat 64 R) then 1 else 0) + +/-- The two comparisons on values below `2⁶⁴`, read on naturals. -/ +lemma ult_ofNat_iff {L R : ℕ} (hL : L < 2^64) (hR : R < 2^64) : + (BitVec.ofNat 64 L).ult (BitVec.ofNat 64 R) = true ↔ L < R := by + simp only [BitVec.ult_eq_decide, decide_eq_true_eq, BitVec.toNat_ofNat, Nat.mod_eq_of_lt hL, + Nat.mod_eq_of_lt hR] + +lemma slt_ofNat_iff {L R : ℕ} (hL : L < 2^64) (hR : R < 2^64) : + (BitVec.ofNat 64 L).slt (BitVec.ofNat 64 R) = true ↔ + (if L < 2^63 then (L : ℤ) else (L : ℤ) - 2^64) < + (if R < 2^63 then (R : ℤ) else (R : ℤ) - 2^64) := by + simp only [BitVec.slt_eq_decide, decide_eq_true_eq, BitVec.toInt_eq_toNat_cond, BitVec.toNat_ofNat, + Nat.mod_eq_of_lt hL, Nat.mod_eq_of_lt hR] + split_ifs <;> omega + +/-- LT result: `(lhs < rhs) xor invert`. -/ +def ltBit (signed invert L R : ℕ) : ℕ := + if ltRaw signed L R = invert then 0 else 1 + +/-- EQ result: `(a = b) xor invert`. -/ +def eqBit (invert A B : ℕ) : ℕ := + if (if A = B then 1 else 0) = invert then 0 else 1 + +/-- Arithmetic right shift of a 64-bit value: sign-extend to 128 bits, shift, truncate. -/ +def sra64 (x k : ℕ) : ℕ := + if x < 2^63 then x >>> k else ((x + (2^128 - 2^64)) >>> k) % 2^64 + +/-- `SHIFT` result (spec/src/shift.toml): the shift amount is reduced mod 32 for word instructions +and mod 64 otherwise; `direction` picks left (0) or right (1); `signed` picks the arithmetic +right shift. Word results are not sign-extended here (the CPU does that). For `word = 1` the +shift still acts on all 64 bits of `x`, so for a right shift the caller must pass `x` with its +high word already zero-extended (logical) or sign-extended (arithmetic); otherwise bits of the +high word shift into the low 32 bits of the result. -/ +def shiftResult (word signed direction x s : ℕ) : ℕ := + let k := s % (if word = 1 then 32 else 64) + if direction = 0 then (x <<< k) % 2^64 + else if signed = 0 then x >>> k + else sra64 x k + +/-- What a puller learns. One clause per `opsel`, selected by the flag byte read as a natural. +Each clause takes as hypotheses exactly the `[[assumptions]]` of its chip's spec: the words the +caller must have range-checked. The words a chip range-checks itself need no hypothesis. -/ +def Guarantees (m : Msg (F p)) : Prop := + -- LT (spec/src/lt.toml): flags = opsel(LT) + 32·signed + 64·invert, out = [res, 0]; + -- assumes `IS_WORD[lhs[0]]`, `IS_WORD[rhs[0]]` (LT range-checks the high halves) + (∀ s i : ℕ, s < 2 → i < 2 → m.flags.val = opselLT + 32 * s + 64 * i → + m.in1Lo.val < 2^32 → m.in2Lo.val < 2^32 → + m.outHi = 0 ∧ + m.outLo = ((ltBit s i (dword m.in1Lo m.in1Hi) (dword m.in2Lo m.in2Hi) : ℕ) : F p)) ∧ + -- EQ (spec/src/eq.toml): flags = opsel(EQ) + 64·invert, out = [res, 0]; + -- assumes `IS_WORD[a[i]]`, `IS_WORD[b[i]]` + (∀ i : ℕ, i < 2 → m.flags.val = opselEQ + 64 * i → + m.in1Lo.val < 2^32 → m.in1Hi.val < 2^32 → m.in2Lo.val < 2^32 → m.in2Hi.val < 2^32 → + m.outHi = 0 ∧ + m.outLo = ((eqBit i (dword m.in1Lo m.in1Hi) (dword m.in2Lo m.in2Hi) : ℕ) : F p)) ∧ + -- SHIFT (spec/src/shift.toml): flags = opsel(SHIFT) + word_instr + 32·signed + 64·direction; + -- no assumptions (SHIFT range-checks `in` and the low bytes of the shift amount itself), + -- only the low byte of the shift amount matters + (∀ w s d : ℕ, w < 2 → s < 2 → d < 2 → + m.flags.val = opselSHIFT + w + 32 * s + 64 * d → + m.outLo.val < 2^32 ∧ m.outHi.val < 2^32 ∧ + dword m.outLo m.outHi = shiftResult w s d (dword m.in1Lo m.in1Hi) (m.in2Lo.val % 256)) + +def channel : Channel (F p) Msg where + name := "ALU" + Guarantees m _ := Guarantees m + +end LambdaVM.Alu diff --git a/formal/LambdaVM/Channels/Counted.lean b/formal/LambdaVM/Channels/Counted.lean new file mode 100644 index 000000000..6f28b4c11 --- /dev/null +++ b/formal/LambdaVM/Channels/Counted.lean @@ -0,0 +1,326 @@ +module + +public import Clean.Air.Balance +public import LambdaVM.Tables.Bitwise +public import Mathlib.Tactic.LinearCombination + +@[expose] public section + +/-! +# Counted pulls + +A deduplicated row pulls its range checks with multiplicity `μ ∈ [0, 255]` (`MU_MAX`, PR #1016). +Clean's typed channels give the guarantee only to a pull of multiplicity `1`, and require every +pull to have multiplicity `0` or `1`. `counted N channel` is the raw channel that gives the +guarantee to a pull of multiplicity `1, …, N` and charges every other nonzero interaction with +the requirement, as a push. + +The price is in the balance premise. `exists_push_of_pull` needs `N · length < char F`. Clean's +`BalancedInteractions` only matches pulls of multiplicity `1`, and counts a pull of any other +nonzero multiplicity as a push; `not_consistent` shows the gap is real: over Goldilocks, for +`2 ≤ N ≤ 255` and a channel with some message whose guarantee is false, the counted channel is +not `Consistent`, so it cannot be finished in a `SoundEnsemble` until that premise carries the +bound. With `N = 1` the counted channel is `Normal`, hence `Consistent`; it is still a channel of +its own, not `channel.toRaw`. +-/ + +namespace LambdaVM.Counted + +variable {F : Type} [FiniteField F] [DecidableEq F] +variable {Message : TypeMap} [ProvableType Message] + +/-- `mult = k` for a count `1 ≤ k ≤ N`. -/ +def IsPull (N : ℕ) (mult : F) : Prop := ∃ k : ℕ, 1 ≤ k ∧ k ≤ N ∧ mult = (k : F) + +/-- `channel` with pulls allowed to carry a count up to `N`. -/ +def counted (N : ℕ) (channel : Channel F Message) : RawChannel F where + name := channel.name + arity := size Message + Guarantees mult message data := + IsPull N mult → channel.Guarantees (fromElements message) data + Requirements direction mult message data := + match direction with + | .push => mult ≠ 0 → channel.Guarantees (fromElements message) data + | .pull => mult ≠ 0 → ¬ IsPull N mult → channel.Guarantees (fromElements message) data + +/-- Pull `msg` `count` times. -/ +@[circuit_norm] +def pullIf (N : ℕ) (channel : Channel F Message) (count : Expression F) + (msg : Message (Expression F)) : Circuit F Unit := fun _ => + ((), [.interact ⟨counted N channel, .pull, count, toElements msg⟩]) + +/-- The provider side: emit `msg` with multiplicity `mult`. -/ +@[circuit_norm] +def emit (N : ℕ) (channel : Channel F Message) (mult : Expression F) + (msg : Message (Expression F)) : Circuit F Unit := fun _ => + ((), [.interact ⟨counted N channel, .push, mult, toElements msg⟩]) + +instance {N : ℕ} {channel : Channel F Message} {count : Expression F} : + ExplicitCircuits (F := F) (pullIf N channel count) where + output _ _ := () + localLength _ _ := 0 + operations msg _ := [.interact ⟨counted N channel, .pull, count, toElements msg⟩] + channelsWithGuarantees _ _ := [counted N channel] + +instance {N : ℕ} {channel : Channel F Message} {mult : Expression F} : + ExplicitCircuits (F := F) (emit N channel mult) where + output _ _ := () + localLength _ _ := 0 + operations msg _ := [.interact ⟨counted N channel, .push, mult, toElements msg⟩] + channelsWithGuarantees _ _ := [] + +attribute [explicit_circuit_no_unfold] pullIf emit + +/-- An interaction that acts as a push of its message: an active push, or a pull whose +multiplicity is not a count. -/ +def PushLike (N : ℕ) (i : Interaction F) : Prop := + i.mult ≠ 0 ∧ (i.direction = .pull → ¬ IsPull N i.mult) + +/-- `RawChannel.Normal` with the pull multiplicity `1` widened to `1, …, N`. -/ +class Normal (N : ℕ) (channel : RawChannel F) : Prop where + grts_of_reqs : ∀ (msg : Vector F channel.arity) (direction : Channel.Direction) (mult : F) data, + mult ≠ 0 → (direction = .pull → ¬ IsPull N mult) → + channel.Requirements direction mult msg data → + ∀ mult', IsPull N mult' → channel.Guarantees mult' msg data + grts_of_not_pull : ∀ (msg : Vector F channel.arity) (mult : F) data, ¬ IsPull N mult → + channel.Guarantees mult msg data + +instance (N : ℕ) (channel : Channel F Message) : Normal N (counted N channel) where + grts_of_reqs := by + intro msg direction mult data h0 hnp reqs mult' hp + cases direction <;> simp only [counted] at reqs ⊢ + · exact fun _ => reqs h0 + · exact fun _ => reqs h0 (hnp rfl) + grts_of_not_pull := by + intro msg mult data hnp + simp only [counted] + exact fun hp => absurd hp hnp + +/-- On a message whose nonzero multiplicities are all counted pulls, the balance is minus a +natural number bounded by `N` per interaction, and positive as soon as one pull is active. -/ +lemma balanceOf_counted (N : ℕ) (msg : Array F) : + ∀ (l : List (Interaction F)), + (∀ i ∈ l, i.msg = msg → i.mult ≠ 0 → i.direction = .pull ∧ IsPull N i.mult) → + ∃ s : ℕ, s ≤ N * l.length ∧ balanceOf l msg = -(s : F) ∧ + (∀ a ∈ l, a.msg = msg → a.mult ≠ 0 → 1 ≤ s) + | [], _ => ⟨0, by simp, by simp [balanceOf], by simp⟩ + | i :: l, h => by + obtain ⟨s, hs, hb, ha⟩ := + balanceOf_counted N msg l (fun j hj => h j (List.mem_cons_of_mem _ hj)) + rw [balanceOf_cons] + simp only [List.length_cons, Nat.mul_succ] + by_cases hm : i.msg = msg + · by_cases h0 : i.mult = 0 + · refine ⟨s, by omega, ?_, ?_⟩ + · have hsigned : i.signedMult = 0 := by + cases hd : i.direction <;> simp [Interaction.signedMult, hd, h0] + rw [ite_eq_left hm, hsigned, hb, zero_add] + · intro a ha' ham ha0 + rcases List.mem_cons.mp ha' with rfl | ha' + · exact absurd h0 ha0 + · exact ha a ha' ham ha0 + · obtain ⟨hd, k, hk1, hkN, hk⟩ := h i (by simp) hm h0 + refine ⟨k + s, by omega, ?_, ?_⟩ + · rw [ite_eq_left hm, hb] + simp only [Interaction.signedMult, hd, hk] + push_cast; ring + · intro a _ _ _; omega + · refine ⟨s, by omega, ?_, ?_⟩ + · rw [ite_eq_right hm, hb, zero_add] + · intro a ha' ham ha0 + rcases List.mem_cons.mp ha' with rfl | ha' + · exact absurd ham hm + · exact ha a ha' ham ha0 + +/-- `exists_push_of_pull` for counted pulls. The balance premise must bound the total count, +`N * length`, by the characteristic; Clean's `BalancedInteractions` only matches pulls of +multiplicity `1`. -/ +theorem exists_push_of_pull (N : ℕ) (interactions : List (Interaction F)) + (bound : N * interactions.length < ringChar F ∨ ringChar F = 0) + (balance : ∀ msg, balanceOf interactions msg = 0) : + ∀ a ∈ interactions, a.direction = .pull → IsPull N a.mult → + ∃ b ∈ interactions, b.msg = a.msg ∧ PushLike N b := by + intro a ha hdir hpull + by_contra! hno + have hno' : ∀ i ∈ interactions, i.msg = a.msg → i.mult ≠ 0 → + i.direction = .pull ∧ IsPull N i.mult := by + intro i hi hm h0 + by_contra hc + exact hno i hi hm ⟨h0, fun hd hp => hc ⟨hd, hp⟩⟩ + obtain ⟨s, hs, hb, h1⟩ := balanceOf_counted N a.msg interactions hno' + have hlen : 0 < interactions.length := List.length_pos_of_mem ha + have hNlen : N ≤ N * interactions.length := Nat.le_mul_of_pos_right N hlen + have ha0 : a.mult ≠ 0 := by + obtain ⟨k, hk1, hkN, hk⟩ := hpull + rw [hk] + rcases bound with bound | hchar + · intro hk0 + rw [Lean.Grind.IsCharP.natCast_eq_zero_iff_of_lt _ (by omega)] at hk0 + omega + · rw [CharP.ringChar_zero_iff_CharZero] at hchar + exact Nat.cast_ne_zero.mpr (by omega) + have hs1 := h1 a ha rfl ha0 + have hzero := balance a.msg + rw [hb, neg_eq_zero] at hzero + rcases bound with bound | hchar + · rw [Lean.Grind.IsCharP.natCast_eq_zero_iff_of_lt _ (by omega)] at hzero + omega + · rw [CharP.ringChar_zero_iff_CharZero] at hchar + rw [Nat.cast_eq_zero] at hzero + omega + +/-- `RawChannel.Consistent` for a counted channel, under the stronger balance premise. -/ +theorem consistent (N : ℕ) (channel : RawChannel F) [Normal N channel] + (interactions : List (Interaction F)) (data : ProverData F) + (bound : N * interactions.length < ringChar F ∨ ringChar F = 0) + (balance : ∀ msg, balanceOf interactions msg = 0) + (reqs : ∀ i ∈ interactions, i.channel = channel ∧ i.Requirements data) : + ∀ i ∈ interactions, i.Guarantees data := by + intro a a_mem + simp only [Interaction.Guarantees, Interaction.Requirements, Interaction.msgVector] at reqs ⊢ + intro hdir + have a_channel_eq := (reqs a a_mem).1 + have a_msg_size : a.msg.size = channel.arity := by rw [a.same_size, a_channel_eq] + suffices channel.Guarantees a.mult ⟨a.msg, a_msg_size⟩ data by convert this + by_cases a_pull : IsPull N a.mult + case neg => exact Normal.grts_of_not_pull ⟨a.msg, a_msg_size⟩ a.mult data a_pull + obtain ⟨b, b_mem, b_msg_eq, b_ne_zero, b_not_pull⟩ := + exists_push_of_pull N interactions bound balance a a_mem hdir a_pull + apply Normal.grts_of_reqs ⟨a.msg, a_msg_size⟩ b.direction b.mult data b_ne_zero b_not_pull _ + a.mult a_pull + have ⟨b_channel_eq, b_reqs⟩ := reqs _ b_mem + symm at b_channel_eq + simp only [b_msg_eq] at b_reqs + convert b_reqs + +/-! ## `N = 1` is Clean's normal channel -/ + +omit [DecidableEq F] in +lemma isPull_one_iff (mult : F) : IsPull 1 mult ↔ mult = 1 := by + constructor + · rintro ⟨k, hk1, hk, rfl⟩ + have : k = 1 := by omega + subst this; simp + · rintro rfl; exact ⟨1, le_rfl, le_rfl, by simp⟩ + +instance (channel : Channel F Message) : (counted 1 channel).Normal where + guarantees_of_requirements := by + rintro ⟨_, a_direction, a_mult, a_msg, a_size⟩ ⟨_, b_direction, b_mult, b_msg, b_size⟩ + data rfl rfl (rfl : a_msg = b_msg) a_pull ⟨b_ne_zero, b_not_one⟩ b_reqs + cases b_direction <;> + simp only [Interaction.Guarantees, Interaction.Requirements, Interaction.msgVector, counted, + isPull_one_iff] at b_reqs ⊢ + · exact fun _ _ => b_reqs b_ne_zero + · exact fun _ _ => b_reqs b_ne_zero (b_not_one rfl) + guarantees_of_not_pull := by + rintro ⟨_, direction, mult, msg, size⟩ data rfl not_pull + simp only [Interaction.Pull, not_and] at not_pull + simp only [Interaction.Guarantees, counted, isPull_one_iff] + exact fun h_direction h_mult => absurd h_mult (not_pull h_direction) + +example (channel : Channel F Message) : (counted 1 channel).Consistent := inferInstance + +end LambdaVM.Counted + +/-! ## `2 ≤ N ≤ 255` is not `Consistent` under Clean's balance premise (over Goldilocks) -/ + +namespace LambdaVM.Counted +variable {Message : TypeMap} [ProvableType Message] + +/-- The witness `BalancedInteractions` admits but the counted channel cannot survive: one pull of +`N` and one pull of `1` on a message that is not in the table, nothing pushed. Clean counts the +pull of `N` as a push of the message, so the pull of `1` is matched; the counted channel reads +both as pulls, and the guarantee of the second is false. -/ +theorem not_consistent (N : ℕ) (hN : 2 ≤ N) (hN' : N ≤ 255) + (channel : Channel (F p) Message) (m : Message (F p)) (data : ProverData (F p)) + (hm : ¬ channel.Guarantees m data) : ¬ (counted N channel).Consistent := by + rintro ⟨hc⟩ + let mk : F p → Interaction (F p) := fun mult => + ⟨counted N channel, .pull, mult, (toElements m).toArray, by simp [counted]⟩ + let l := [mk (N : F p), mk 1] + have hval : ((N : ℕ) : F p).val = N := ZMod.val_natCast_of_lt (lt_p_of_lt_two_pow_40 (by omega)) + have hN0 : (N : F p) ≠ 0 := by + intro h; have := congrArg ZMod.val h; rw [hval, ZMod.val_zero] at this; omega + have hN1 : (N : F p) ≠ 1 := by + intro h; have := congrArg ZMod.val h; rw [hval, ZMod.val_one] at this; omega + have hbal : BalancedInteractions l := by + constructor + · -- the pull of `1` is matched by the pull of `N`, which Clean reads as a push + intro a ha _ + refine ⟨mk (N : F p), by simp [l], ?_, hN0, fun _ => hN1⟩ + simp only [l, List.mem_cons, List.not_mem_nil, or_false] at ha + rcases ha with rfl | rfl <;> rfl + · -- the multiplicity `N` is not `0` or `1`, so only messages with no interaction qualify + intro msg is_bool + by_cases hmsg : (toElements m).toArray = msg + · exfalso + rcases is_bool (mk (N : F p)) (by simp [l]) hmsg with h | h + · exact hN0 h + · exact hN1 h + · simp [activeCount, l, mk, hmsg] + have hreqs : ∀ i ∈ l, i.channel = counted N channel ∧ i.Requirements data := by + intro i hi + simp only [l, List.mem_cons, List.not_mem_nil, or_false] at hi + rcases hi with rfl | rfl + · refine ⟨rfl, ?_⟩ + simp only [Interaction.Requirements, mk, counted, Interaction.msgVector] + intro _ hnp + exact absurd ⟨N, by omega, le_rfl, rfl⟩ hnp + · refine ⟨rfl, ?_⟩ + simp only [Interaction.Requirements, mk, counted, Interaction.msgVector] + intro _ hnp + exact absurd ⟨1, le_rfl, by omega, by simp⟩ hnp + have hg := hc l data hbal hreqs (mk 1) (by simp [l]) + simp only [Interaction.Guarantees, mk, counted, Interaction.msgVector] at hg + apply hm + have h := hg trivial ⟨1, le_rfl, by omega, by simp⟩ + convert h + simp [ProvableType.fromElements_toElements] + +end LambdaVM.Counted + +/-! ## A deduplicated row + +`μ` is range-checked as a byte through `ARE_BYTES` and `x` is pulled from `IS_HALF` with +multiplicity `μ`: the shape of every dedup chip after PR #1016. The counted channel is listed +under `channelsWithRequirements` because the requirement on an out-of-range `μ` is only +discharged by the byte guarantee, which lawfulness cannot see; soundness can. -/ + +namespace LambdaVM.Counted.Demo +open LambdaVM Bitwise + +structure Row (F : Type) where + mu : F + x : F +deriving ProvableStruct + +def main (r : Var Row (F p)) : Circuit (F p) Unit := do + AreBytes.pull (r.mu, 0) + pullIf 255 IsHalf r.mu r.x + +def circuit : GeneralFormalCircuit (F p) Row unit where + main + Spec r _ _ := r.mu ≠ 0 → r.x.val < 65536 + ProverAssumptions r _ _ := r.mu.val < 256 ∧ r.x.val < 65536 + channelsWithRequirements := [counted 255 IsHalf] + requirementsChannelsLawful input_var i₀ := by + obtain ⟨mu, x⟩ := input_var + simp only [circuit_norm, main, pullIf, areBytesTable] + grind + soundness := by + circuit_proof_start [main, pullIf, counted, areBytesTable, isHalfTable] + simp only [AbstractInteraction.Guarantees, AbstractInteraction.Requirements, circuit_norm, + h_input] at h_holds ⊢ + obtain ⟨⟨h_mu, _⟩, h_x⟩ := h_holds + -- an active row pulls with the count `μ.val ∈ [1, 255]` + have key : input_mu ≠ 0 → IsPull 255 input_mu := fun h0 => + ⟨input_mu.val, by have := (ZMod.val_ne_zero _).mpr h0; omega, by omega, + by rw [ZMod.natCast_zmod_val]⟩ + refine ⟨fun h0 => h_x (key h0), fun h0 hnp => absurd (key ?_) hnp⟩ + exact h0 + completeness := by + circuit_proof_start [main, pullIf, counted, areBytesTable, isHalfTable] + simp only [AbstractInteraction.Guarantees, circuit_norm, h_input] + exact ⟨⟨h_assumptions.1, by rw [ZMod.val_zero]; norm_num⟩, fun _ => h_assumptions.2⟩ + +end LambdaVM.Counted.Demo diff --git a/formal/LambdaVM/Ensembles/EqLookup.lean b/formal/LambdaVM/Ensembles/EqLookup.lean new file mode 100644 index 000000000..bfae312fd --- /dev/null +++ b/formal/LambdaVM/Ensembles/EqLookup.lean @@ -0,0 +1,154 @@ +module + +public import LambdaVM.Tables.Eq +public import Clean.Air.OrderedChannel + +@[expose] public section + +/-! +# The first ensemble: BITWISE lookups feeding the EQ chip + +Three components and three channels, in dependency order: the provider of `IS_HALF`, the +provider of `ZERO`, the EQ chip. Every channel is finished before the next table that pulls +from it, so Clean's ordered-channel soundness applies: in any witness whose constraints hold +and whose channels balance, every EQ row with `μ = 1` and range-checked operands computes the +equality bit. + +BITWISE is idealized by `pushStatic`: one provider row whose columns are the multiplicities of +every table entry. Nothing pulls from ALU yet (the CPU is not modelled), so balance on the ALU +channel forces `μ = 0` on every EQ row and `eq_rows_correct` is trivially true. That the chain +composes is shown by `eqLookup` type-checking as a `SoundEnsemble`, not by the theorem; the +theorem constrains active rows once a component pulls from ALU. +-/ + +namespace LambdaVM.Ensembles +open Air.Flat + +/-- The provider side of a static lookup channel: one circuit that emits every entry of the +table with the prover's multiplicity for it. Its row is the vector of multiplicities, the +role the `μ` columns of BITWISE play. -/ +def pushStatic {Message : TypeMap} [ProvableType Message] (slc : StaticLookupChannel (F p) Message) + [NeZero slc.table.length] : GeneralFormalCircuit (F p) (fields slc.table.length) unit where + name := slc.name + main mults := do + let _ ← Circuit.mapFinRange slc.table.length fun i => + slc.toChannel.emit mults[i] (const slc.table[i]) + channelsWithRequirements := [slc.toChannel.toRaw] + Spec _ _ _ := True + soundness := by + circuit_proof_start + intro i _ + exact (slc.guarantees_iff _).mpr (List.getElem_mem _) + completeness := by circuit_proof_start + +/-- The provider has no pulls, and requires only its own channel. -/ +@[circuit_norm] +lemma pushStatic_channelsWithGuarantees {Message : TypeMap} [ProvableType Message] + (slc : StaticLookupChannel (F p) Message) [NeZero slc.table.length] : + (pushStatic slc).channelsWithGuarantees = [] := by + simp [circuit_norm, pushStatic] + +@[circuit_norm] +lemma pushStatic_channelsWithRequirements {Message : TypeMap} [ProvableType Message] + (slc : StaticLookupChannel (F p) Message) [NeZero slc.table.length] : + (pushStatic slc).channelsWithRequirements = [slc.toChannel.toRaw] := rfl + +/-- The provider as a component. Clean asks every component for a witness generation; this one +is a placeholder that fills every column with the demand's multiplicity, not a valid row. Only +the circuit is used here. -/ +def pushStaticComponent {Message : TypeMap} [ProvableType Message] + (slc : StaticLookupChannel (F p) Message) [NeZero slc.table.length] : Component (F p) where + circuit := pushStatic slc + generation := .demand { + channel := slc.toChannel + trigger := .pull + input _ := pure (fromElements (Vector.replicate slc.table.length .multiplicity)) } + +/-- The EQ chip as a component. EQ pushes its result, so the demand it answers is a pull: +`Demand.direction` is `.pull` when a message was pulled more often than pushed. The generation +is the same placeholder as in `pushStaticComponent`. -/ +def eqComponent : Component (F p) where + circuit := EQ.circuit + generation := .demand { + channel := Alu.channel + trigger := .pull + input _ := pure (fromElements (Vector.replicate (size EQ.Row) .multiplicity)) } + +@[circuit_norm] lemma pushStaticComponent_circuit {Message : TypeMap} [ProvableType Message] + (slc : StaticLookupChannel (F p) Message) [NeZero slc.table.length] : + (pushStaticComponent slc).circuit = pushStatic slc := rfl +@[circuit_norm] lemma pushStatic_name {Message : TypeMap} [ProvableType Message] + (slc : StaticLookupChannel (F p) Message) [NeZero slc.table.length] : + (pushStatic slc).name = slc.name := rfl +@[circuit_norm] lemma eqComponent_circuit : eqComponent.circuit = EQ.circuit := rfl +@[circuit_norm] lemma pushStaticComponent_channelsWithGuarantees {Message : TypeMap} + [ProvableType Message] (slc : StaticLookupChannel (F p) Message) [NeZero slc.table.length] : + (pushStaticComponent slc).circuit.channelsWithGuarantees = [] := + pushStatic_channelsWithGuarantees slc +@[circuit_norm] lemma pushStaticComponent_channelsWithRequirements {Message : TypeMap} + [ProvableType Message] (slc : StaticLookupChannel (F p) Message) [NeZero slc.table.length] : + (pushStaticComponent slc).circuit.channelsWithRequirements = [slc.toChannel.toRaw] := rfl +@[circuit_norm] lemma eq_name : EQ.circuit.name = "EQ" := rfl +@[circuit_norm] lemma isHalfTable_name : Bitwise.isHalfTable.name = "IS_HALF" := rfl +@[circuit_norm] lemma zeroTable_name : Bitwise.zeroTable.name = "ZERO" := rfl +@[circuit_norm] lemma alu_name : Alu.channel.name = "ALU" := rfl +@[circuit_norm] lemma eqComponent_channelsWithGuarantees : + eqComponent.circuit.channelsWithGuarantees = [Bitwise.IsHalf.toRaw, Bitwise.IsHalf.toRaw, + Bitwise.IsHalf.toRaw, Bitwise.IsHalf.toRaw, Bitwise.Zero.toRaw] := rfl +@[circuit_norm] lemma eqComponent_channelsWithRequirements : + eqComponent.circuit.channelsWithRequirements = [Alu.channel.toRaw] := rfl + +instance : NeZero Bitwise.isHalfTable.table.length := + ⟨by simp [Bitwise.isHalfTable, Bitwise.rows, Bitwise.numRows]⟩ +instance : NeZero Bitwise.zeroTable.table.length := + ⟨by simp [Bitwise.zeroTable, Bitwise.rows, Bitwise.numRows]⟩ + +def eqLookup (balance : Balance (F p)) : SoundEnsemble (F p) unit balance := + SoundEnsemble.empty (F p) unit balance + |>.addChannel Bitwise.IsHalf.toRaw + |>.addTable (pushStaticComponent Bitwise.isHalfTable) + (by rw [pushStaticComponent_channelsWithGuarantees]; exact List.nil_subset _) + (by rw [pushStaticComponent_channelsWithRequirements]; simp [circuit_norm]) + |>.markFinished Bitwise.IsHalf.toRaw + |>.addChannel Bitwise.Zero.toRaw + |>.addTable (pushStaticComponent Bitwise.zeroTable) + (by rw [pushStaticComponent_channelsWithGuarantees]; exact List.nil_subset _) + (by rw [pushStaticComponent_channelsWithRequirements]; simp [circuit_norm]) + |>.markFinished Bitwise.Zero.toRaw + |>.addChannel Alu.channel.toRaw + |>.addTable eqComponent + (by rw [eqComponent_channelsWithGuarantees]; simp [circuit_norm]) + (by rw [eqComponent_channelsWithRequirements]; simp [circuit_norm]) + |>.markFinished Alu.channel.toRaw + +/-- Lookup soundness, concretely: if the constraints of every table hold, every channel has few +enough interactions for the balance check, and every channel balances, then every EQ row with +`μ = 1` and range-checked operands carries the equality bit. Without an ALU consumer in the +ensemble no such row exists (see the module header), so the statement is trivially true for now. -/ +theorem eq_rows_correct {balance : Balance (F p)} + (witness : EnsembleWitness (eqLookup balance).ensemble) + (hc : witness.Constraints) (hfit : witness.InteractionsFit balance) + (hb : witness.Balanced balance) : + ∀ table ∈ witness.tables, table.component = eqComponent → + ∀ row ∈ table.table, EQ.RowSpec (valueFromOffset EQ.Row 0 (table.environment row)) := by + have hsound : (eqLookup balance).ensemble.TableSoundness balance := + Ensemble.tableSoundness_of_soundChannels + ⟨(eqLookup balance).finished, (eqLookup balance).finished_subset, + (eqLookup balance).soundChannels⟩ + -- no component assumes anything + have hassume : witness.Assumptions := by + intro table htable row _ + have hmem := witness.component_mem_tables_of_mem htable + simp only [eqLookup, circuit_norm, List.mem_cons, List.not_mem_nil, or_false] at hmem + obtain ⟨comp, tbl, data, uw, ll, frm, dc⟩ := table + simp only at hmem + rcases hmem with rfl | rfl | rfl <;> trivial + have hspec := (hsound witness hassume hc hfit hb).2 + intro table htable hcomp row hrow + have := hspec table htable row hrow + obtain ⟨comp, tbl, data, uw, ll, frm, dc⟩ := table + simp only at hcomp + subst hcomp + exact this + +end LambdaVM.Ensembles diff --git a/formal/LambdaVM/Export.lean b/formal/LambdaVM/Export.lean new file mode 100644 index 000000000..b565a1c8f --- /dev/null +++ b/formal/LambdaVM/Export.lean @@ -0,0 +1,70 @@ +module + +public meta import LambdaVM +public meta import Clean.Circuit.Json + +/-! +Exports the operations of each modeled chip as JSON, for the differential check against the +Rust prover (`prover/src/tests/lean_diff.rs`). Variables are numbered in `Row` field order, +which is the Rust column order. + +BITWISE has no row circuit: its export is the table size, the size of every static lookup +channel, and a sample of the table: the precomputed columns of `Bitwise.row i` and the message +every channel serves at row `i`. +-/ + +open Lean LambdaVM + +meta def exportCircuit (name : String) {Row : TypeMap} [ProvableType Row] + (main : Var Row (F p) → Circuit (F p) Unit) : IO Unit := do + let ops := (main (varFromOffset Row 0)).operations 0 + let json := Json.mkObj [("name", name), ("columns", size Row), ("operations", toJson ops)] + IO.FS.writeFile s!"export/{name}.json" (json.pretty 100) + IO.println s!"wrote export/{name}.json" + +/-- BITWISE rows to sample: every `z` with edge bytes for `x` and `y` (the last row +included), and pseudo-random rows. -/ +meta def bitwiseIndices : List ℕ := + let edge := [0, 1, 0x7F, 0x80, 0xFF] + let grid := (List.range 16).flatMap fun z => + edge.flatMap fun y => edge.map fun x => Bitwise.index x y z + let random := (List.range 256).map fun k => (k * 2654435761 + 12345) % Bitwise.numRows + grid ++ random + +meta def rowJson (r : Bitwise.Row) : Json := + toJson [r.x, r.y, r.z, r.and, r.or, r.xor, r.msb8, r.msb16, r.zero, r.sll, r.sllc] + +/-- The messages a static lookup channel serves at each sampled row: `perRow` consecutive +entries of its table per BITWISE row (BYTE_ALU serves three, one per `opsel`). -/ +meta def channelJson {M : TypeMap} [ProvableType M] (slc : StaticLookupChannel (F p) M) + (perRow : ℕ) (indices : List ℕ) : IO Json := do + let table := slc.table.toArray + let messages ← indices.mapM fun i => (List.range perRow).mapM fun k => do + let some m := table[perRow * i + k]? + | throw <| IO.userError s!"{slc.name}: no entry {perRow * i + k} in a table of {table.size}" + pure ((toElements m).toList.map fun e : F p => e.val) + pure <| Json.mkObj [("channel", slc.name), ("size", table.size), ("messages", toJson messages)] + +meta def exportBitwise : IO Unit := do + let indices := bitwiseIndices + let channels ← [ + channelJson Bitwise.areBytesTable 1 indices, + channelJson Bitwise.isHalfTable 1 indices, + channelJson Bitwise.isB20Table 1 indices, + channelJson Bitwise.msb8Table 1 indices, + channelJson Bitwise.msb16Table 1 indices, + channelJson Bitwise.zeroTable 1 indices, + channelJson Bitwise.hwslTable 1 indices, + channelJson Bitwise.byteAluTable 3 indices].mapM id + let json := Json.mkObj [("name", "bitwise"), ("numRows", Bitwise.numRows), + ("indices", toJson indices), + ("rows", Json.arr (indices.map (rowJson ∘ Bitwise.row)).toArray), + ("channels", Json.arr channels.toArray)] + IO.FS.writeFile "export/bitwise.json" json.compress + IO.println "wrote export/bitwise.json" + +public meta def main : IO Unit := do + exportCircuit "lt" LT.main + exportCircuit "eq" EQ.main + exportCircuit "shift" SHIFT.main + exportBitwise diff --git a/formal/LambdaVM/Field.lean b/formal/LambdaVM/Field.lean new file mode 100644 index 000000000..2fd41f968 --- /dev/null +++ b/formal/LambdaVM/Field.lean @@ -0,0 +1,138 @@ +module + +public import Clean.Circuit +public import CompPoly.Fields.Goldilocks + +@[expose] public section + +namespace LambdaVM + +/-- Goldilocks, the base field of the Lambda VM prover: `2^64 - 2^32 + 1`. -/ +abbrev p : ℕ := Goldilocks.fieldSize + +instance : Fact p.Prime := ⟨Goldilocks.is_prime⟩ + +-- Size facts that Clean's gadgets ask for. +instance : Fact (p > 512) := by decide +instance : Fact (p > 2^16 + 2^8) := by decide +instance : Fact (p > 2^32) := by decide + +example : FiniteField (F p) := inferInstance + +/-! ## Lifting field identities on small naturals back to `ℕ` -/ + +lemma lt_p_of_lt_two_pow_40 {n : ℕ} (h : n < 2^40) : n < p := lt_trans h (by decide) + +lemma val_natCast_of_lt_two_pow_40 {n : ℕ} (h : n < 2^40) : ((n : F p)).val = n := + ZMod.val_natCast_of_lt (lt_p_of_lt_two_pow_40 h) + +/-- Casting naturals below `p` into the field is injective. -/ +lemma natCast_inj_of_lt {a b : ℕ} (ha : a < p) (hb : b < p) (h : (a : F p) = (b : F p)) : a = b := by + rw [ZMod.natCast_eq_natCast_iff', Nat.mod_eq_of_lt ha, Nat.mod_eq_of_lt hb] at h + exact h + +/-- `x.val = n` once `x` is known to be the cast of a small `n`. -/ +lemma val_eq_of_eq_natCast {x : F p} {n : ℕ} (h : x = (n : F p)) (hn : n < 2^40) : x.val = n := by + rw [h]; exact val_natCast_of_lt_two_pow_40 hn + +/-- 64-bit value of a `(lo32, hi32)` pair. -/ +def dword (lo hi : F p) : ℕ := lo.val + 2^32 * hi.val + +lemma mul_one_sub_eq_zero_iff {x : F p} : x * (1 - x) = 0 ↔ IsBool x := by + rw [mul_eq_zero, sub_eq_zero, IsBool, eq_comm (a := (1 : F p))] + +lemma isBool_of_val_lt_two {x : F p} (h : x.val < 2) : IsBool x := by + have hx : x = (x.val : F p) := (ZMod.natCast_zmod_val x).symm + rcases Nat.lt_succ_iff.mp h |>.lt_or_eq with h0 | h1 + · left; rw [hx, Nat.lt_one_iff.mp h0]; simp + · right; rw [hx, h1]; simp + +/-- `2⁻³²`, the constant `INV_SHIFT_32` of the prover's constraint templates. -/ +def inv32 : F p := ((2 : F p)^32)⁻¹ + +lemma two_pow_32_ne_zero : (2 : F p)^32 ≠ 0 := by + have h : ((2^32 : ℕ) : F p) ≠ 0 := by + intro h0 + have := congrArg ZMod.val h0 + rw [val_natCast_of_lt_two_pow_40 (by norm_num), ZMod.val_zero] at this + norm_num at this + push_cast at h + exact h + +lemma inv32_mul_two_pow : inv32 * (2 : F p)^32 = 1 := inv_mul_cancel₀ two_pow_32_ne_zero +lemma two_pow_mul_inv32 : (2 : F p)^32 * inv32 = 1 := mul_inv_cancel₀ two_pow_32_ne_zero + +/-- A carry constraint `c = (a − b)·2⁻³²` with `c` boolean and `a, b` small lifts to +`a = b + c·2³²` on naturals. -/ +lemma carry_lift {a b c : F p} (ha : a.val < 2^36) (hb : b.val < 2^36) (hc : IsBool c) + (hdef : c = (a - b) * inv32) : a.val = b.val + c.val * 2^32 := by + have hab : a = b + c * 2^32 := by + rw [hdef, mul_assoc, inv32_mul_two_pow, mul_one]; ring + have hcast : ((a.val : ℕ) : F p) = ((b.val + c.val * 2^32 : ℕ) : F p) := by + push_cast + simp only [ZMod.natCast_zmod_val] + exact hab + have hc2 := IsBool.val_lt_two hc + exact natCast_inj_of_lt (lt_p_of_lt_two_pow_40 (by omega)) (lt_p_of_lt_two_pow_40 (by omega)) hcast + +/-- A field element with value below 2 is `0` or `1`, together with its value. -/ +lemma eq_zero_or_one_of_val {x : F p} (h : x.val < 2) : + (x = 0 ∧ x.val = 0) ∨ (x = 1 ∧ x.val = 1) := by + rcases isBool_of_val_lt_two h with rfl | rfl + · left; exact ⟨rfl, ZMod.val_zero⟩ + · right; refine ⟨rfl, ?_⟩ + rw [← Nat.cast_one]; exact val_natCast_of_lt_two_pow_40 (by norm_num) + +lemma val_one_eq : (1 : F p).val = 1 := by + rw [← Nat.cast_one]; exact val_natCast_of_lt_two_pow_40 (by norm_num) + +lemma val_ofNat (n : ℕ) [n.AtLeastTwo] (h : n < 2^40) : (OfNat.ofNat n : F p).val = n := by + rw [← Nat.cast_ofNat]; exact val_natCast_of_lt_two_pow_40 h + +lemma three_lt_p : 3 < p := by decide + +/-- A field difference of two small naturals is small only if it does not wrap. -/ +lemma val_sub_of_val_lt {a b : ℕ} (ha : a < 2^40) (hb : b < 2^40) + (h : ((a : F p) - (b : F p)).val < 2^40) : b ≤ a ∧ ((a : F p) - (b : F p)).val = a - b := by + by_cases hab : b ≤ a + · refine ⟨hab, ?_⟩ + rw [← Nat.cast_sub hab] + exact val_natCast_of_lt_two_pow_40 (by omega) + · exfalso + have hlt : a < b := by omega + have h1 : ((a : F p) - (b : F p)) = -(((b - a : ℕ) : F p)) := by + rw [Nat.cast_sub hlt.le]; ring + rw [h1, ZMod.neg_val] at h + have hne : ((b - a : ℕ) : F p) ≠ 0 := by + intro h0 + have := congrArg ZMod.val h0 + rw [val_natCast_of_lt_two_pow_40 (by omega), ZMod.val_zero] at this + omega + rw [ite_eq_right hne, val_natCast_of_lt_two_pow_40 (by omega)] at h + have hp : 2^41 < p := by decide + omega + +lemma val_neg_two : (-2 : F p).val = p - 2 := by + have h2 : (2 : F p) ≠ 0 := by + intro h + have := congrArg ZMod.val h + rw [val_ofNat 2 (by norm_num), ZMod.val_zero] at this + omega + rw [ZMod.neg_val, ite_eq_right h2, val_ofNat 2 (by norm_num)] + +/-- Three bits whose complement `1 − l0 − l1 − l2` is also a bit are at most one-hot. -/ +lemma onehot_of_isBool {l0 l1 l2 : F p} (h0 : IsBool l0) (h1 : IsBool l1) (h2 : IsBool l2) + (h3 : IsBool (1 - l0 - l1 - l2)) : l0.val + l1.val + l2.val ≤ 1 := by + have hp := three_lt_p + have h3' := IsBool.val_lt_two h3 + rcases h0 with rfl | rfl <;> rcases h1 with rfl | rfl <;> rcases h2 with rfl | rfl + all_goals simp only [ZMod.val_zero, val_one_eq] + all_goals try omega + all_goals first + | (norm_num at h3'; done) + | (norm_num at h3'; simp only [val_neg_two] at h3'; omega) + +lemma eq_natCast_of_val {x : F p} {n : ℕ} (h : x.val = n) : x = (n : F p) := by + rw [← h, ZMod.natCast_zmod_val] + +end LambdaVM diff --git a/formal/LambdaVM/StaticLookup.lean b/formal/LambdaVM/StaticLookup.lean new file mode 100644 index 000000000..04301bb1b --- /dev/null +++ b/formal/LambdaVM/StaticLookup.lean @@ -0,0 +1,31 @@ +module + +public import Clean.Circuit.Channel + +@[expose] public section + +/-! +# Static lookup channels + +A table the verifier knows, given as a list of rows, read through a channel whose guarantee is +the semantic reading of a row. Clean main replaced its `StaticLookupChannel` by `Air.Flat.Lookup`, +whose rows are witness programs of the row index. The formal model keeps its tables as lists, with +`guarantees_iff` relating each list to its reading, so the structure lives here. +-/ + +namespace LambdaVM + +structure StaticLookupChannel (F : Type) [Field F] (Message : TypeMap) [ProvableType Message] where + name : String + table : List (Message F) + Guarantees : Message F → Prop + guarantees_iff : ∀ msg, Guarantees msg ↔ msg ∈ table + +/-- The channel through which other components read the table. -/ +@[circuit_norm] +def StaticLookupChannel.toChannel {F : Type} [Field F] {Message : TypeMap} [ProvableType Message] + (slc : StaticLookupChannel F Message) : Channel F Message where + name := slc.name + Guarantees msg _ := slc.Guarantees msg + +end LambdaVM diff --git a/formal/LambdaVM/Tables/Bitwise.lean b/formal/LambdaVM/Tables/Bitwise.lean new file mode 100644 index 000000000..402b9bd7c --- /dev/null +++ b/formal/LambdaVM/Tables/Bitwise.lean @@ -0,0 +1,364 @@ +module + +public import LambdaVM.Field +public import LambdaVM.AluOp +public import LambdaVM.StaticLookup + +@[expose] public section + +/-! +# BITWISE (spec/src/bitwise.toml) + +Preprocessed table with one row per `(X, Y, Z) ∈ Byte × Byte × B4`, indexed by +`i = X + 2^8·Y + 2^16·Z`, exactly as `generate_bitwise_row` in `prover/src/tables/bitwise.rs`. +Each bus the table serves is a static lookup channel whose rows are a projection of `row i`; +the channel's `Guarantees` is the semantic reading of that projection, and `guarantees_iff` +proves the two agree. Bus names follow `BusId` in `prover/src/tables/types.rs`. +-/ + +namespace LambdaVM.Bitwise + +/-- The eleven precomputed columns of one row, as naturals. -/ +structure Row where + x : ℕ + y : ℕ + z : ℕ + and : ℕ + or : ℕ + xor : ℕ + msb8 : ℕ + msb16 : ℕ + zero : ℕ + sll : ℕ + sllc : ℕ + +def numRows : ℕ := 2^20 + +/-- Row index of `(x, y, z)`. -/ +def index (x y z : ℕ) : ℕ := x + 2^8 * y + 2^16 * z + +/-- `SLL`: `h` shifted left by `z`, kept to 16 bits. -/ +def sll (h z : ℕ) : ℕ := if z = 0 then h else (h <<< z) % 2^16 + +/-- `SLLC`: the bits `SLL` drops, `h` shifted right by `16 − z`. -/ +def sllc (h z : ℕ) : ℕ := if z = 0 then 0 else h >>> (16 - z) + +/-- On a 16-bit `h` the two shifts are the spec's formulas, with no case on `z`. -/ +lemma sll_eq {h z : ℕ} (hh : h < 2^16) : sll h z = (h <<< z) % 2^16 := by + unfold sll; split_ifs with hz + · rw [hz, Nat.shiftLeft_zero, Nat.mod_eq_of_lt hh] + · rfl + +lemma sllc_eq {h z : ℕ} (hh : h < 2^16) : sllc h z = h >>> (16 - z) := by + unfold sllc; split_ifs with hz + · rw [hz, Nat.sub_zero, Nat.shiftRight_eq_div_pow, Nat.div_eq_of_lt hh] + · rfl + +lemma sll_of_eq {x h z : ℕ} (hh : h < 2^16) (hx : x = (h <<< z) % 2^16) : x = sll h z := by + rw [hx, sll_eq hh] + +lemma sllc_of_eq {x h z : ℕ} (hh : h < 2^16) (hx : x = h >>> (16 - z)) : x = sllc h z := by + rw [hx, sllc_eq hh] + +/-- The precomputed columns of `(x, y, z)`: `generate_bitwise_row`. -/ +def rowOf (x y z : ℕ) : Row := + let halfword := x + 2^8 * y + { x, y, z + and := x &&& y + or := x ||| y + xor := x ^^^ y + msb8 := x / 2^7 + msb16 := halfword / 2^15 + zero := if x = 0 ∧ y = 0 ∧ z = 0 then 1 else 0 + sll := sll halfword z + sllc := sllc halfword z } + +/-- Row `i` of the table, with `/` and `%` where Rust masks and shifts the index. -/ +def row (i : ℕ) : Row := rowOf (i % 2^8) (i / 2^8 % 2^8) (i / 2^16 % 16) + +def rows : List Row := (List.range numRows).map row + +lemma mem_rows_iff {r : Row} : r ∈ rows ↔ ∃ i < numRows, row i = r := by + simp [rows, List.mem_map, List.mem_range] + +lemma index_lt {x y z : ℕ} (hx : x < 2^8) (hy : y < 2^8) (hz : z < 16) : + index x y z < numRows := by + unfold index numRows; omega + +lemma row_x_lt (i : ℕ) : (row i).x < 2^8 := Nat.mod_lt _ (by norm_num) +lemma row_y_lt (i : ℕ) : (row i).y < 2^8 := Nat.mod_lt _ (by norm_num) +lemma row_z_lt (i : ℕ) : (row i).z < 16 := Nat.mod_lt _ (by norm_num) + +lemma row_index {x y z : ℕ} (hx : x < 2^8) (hy : y < 2^8) (hz : z < 16) : + row (index x y z) = rowOf x y z := by + have h1 : index x y z % 2^8 = x := by unfold index; omega + have h2 : index x y z / 2^8 % 2^8 = y := by unfold index; omega + have h3 : index x y z / 2^16 % 16 = z := by unfold index; omega + simp only [row, h1, h2, h3] + +/-! ## Range-check channels -/ + +/-- `ARE_BYTES[X, Y]` (`BusId::AreBytes`): both values are bytes. -/ +def areBytesTable : StaticLookupChannel (F p) fieldPair where + name := "ARE_BYTES" + table := rows.map fun r => ((r.x : F p), (r.y : F p)) + Guarantees | (x, y) => x.val < 2^8 ∧ y.val < 2^8 + guarantees_iff := by + rintro ⟨x, y⟩ + simp only [List.mem_map, mem_rows_iff, Prod.mk.injEq] + constructor + · rintro ⟨hx, hy⟩ + refine ⟨row (index x.val y.val 0), ⟨_, index_lt hx hy (by norm_num), rfl⟩, ?_, ?_⟩ + · rw [row_index hx hy (by norm_num)]; exact ZMod.natCast_zmod_val x + · rw [row_index hx hy (by norm_num)]; exact ZMod.natCast_zmod_val y + · rintro ⟨r, ⟨i, _, rfl⟩, rfl, rfl⟩ + exact ⟨by rw [val_natCast_of_lt_two_pow_40 (by linarith [row_x_lt i])]; exact row_x_lt i, + by rw [val_natCast_of_lt_two_pow_40 (by linarith [row_y_lt i])]; exact row_y_lt i⟩ + +abbrev AreBytes : Channel (F p) fieldPair := areBytesTable.toChannel + +/-- `IS_HALF[X + 2^8·Y]` (`BusId::IsHalfword`): the value is a halfword. -/ +def isHalfTable : StaticLookupChannel (F p) field where + name := "IS_HALF" + table := rows.map fun r => ((r.x + 2^8 * r.y : ℕ) : F p) + Guarantees h := h.val < 2^16 + guarantees_iff := by + intro h + simp only [List.mem_map, mem_rows_iff] + constructor + · intro hh + refine ⟨row (index (h.val % 2^8) (h.val / 2^8) 0), + ⟨_, index_lt (by omega) (by omega) (by norm_num), rfl⟩, ?_⟩ + rw [row_index (by omega) (by omega) (by norm_num)] + simp only [rowOf] + rw [show h.val % 2^8 + 2^8 * (h.val / 2^8) = h.val by omega] + exact ZMod.natCast_zmod_val h + · rintro ⟨r, ⟨i, _, rfl⟩, rfl⟩ + have := row_x_lt i; have := row_y_lt i + rw [val_natCast_of_lt_two_pow_40 (by omega)]; omega + +abbrev IsHalf : Channel (F p) field := isHalfTable.toChannel + +/-- `IS_B20[X + 2^8·Y + 2^16·Z]` (`BusId::IsB20`): the value is below `2^20`. -/ +def isB20Table : StaticLookupChannel (F p) field where + name := "IS_B20" + table := rows.map fun r => ((r.x + 2^8 * r.y + 2^16 * r.z : ℕ) : F p) + Guarantees v := v.val < 2^20 + guarantees_iff := by + intro v + simp only [List.mem_map, mem_rows_iff] + constructor + · intro hv + refine ⟨row (index (v.val % 2^8) (v.val / 2^8 % 2^8) (v.val / 2^16)), + ⟨_, index_lt (by omega) (by omega) (by omega), rfl⟩, ?_⟩ + rw [row_index (by omega) (by omega) (by omega)] + simp only [rowOf] + rw [show v.val % 2^8 + 2^8 * (v.val / 2^8 % 2^8) + 2^16 * (v.val / 2^16) = v.val by omega] + exact ZMod.natCast_zmod_val v + · rintro ⟨r, ⟨i, _, rfl⟩, rfl⟩ + have := row_x_lt i; have := row_y_lt i; have := row_z_lt i + rw [val_natCast_of_lt_two_pow_40 (by omega)]; omega + +abbrev IsB20 : Channel (F p) field := isB20Table.toChannel + +/-! ## Bit-extraction channels -/ + +lemma row_msb8 (i : ℕ) : (row i).msb8 = (row i).x / 2^7 := rfl +lemma row_msb16 (i : ℕ) : (row i).msb16 = ((row i).x + 2^8 * (row i).y) / 2^15 := rfl +lemma row_zero (i : ℕ) : + (row i).zero = if (row i).x = 0 ∧ (row i).y = 0 ∧ (row i).z = 0 then 1 else 0 := rfl + +/-- `MSB8[X] -> MSB8` (`BusId::Msb8`): `X` is a byte and the output is its top bit. -/ +def msb8Table : StaticLookupChannel (F p) fieldPair where + name := "MSB8" + table := rows.map fun r => ((r.x : F p), (r.msb8 : F p)) + Guarantees | (x, m) => x.val < 2^8 ∧ m.val = x.val / 2^7 + guarantees_iff := by + rintro ⟨x, m⟩ + simp only [List.mem_map, mem_rows_iff, Prod.mk.injEq] + constructor + · rintro ⟨hx, hm⟩ + refine ⟨row (index x.val 0 0), ⟨_, index_lt hx (by norm_num) (by norm_num), rfl⟩, ?_, ?_⟩ + · rw [row_index hx (by norm_num) (by norm_num)]; exact ZMod.natCast_zmod_val x + · rw [row_index hx (by norm_num) (by norm_num)] + simp only [rowOf] + rw [← hm]; exact ZMod.natCast_zmod_val m + · rintro ⟨r, ⟨i, _, rfl⟩, rfl, rfl⟩ + have := row_x_lt i + rw [val_natCast_of_lt_two_pow_40 (by omega), val_natCast_of_lt_two_pow_40 (by rw [row_msb8]; omega), + row_msb8] + exact ⟨this, rfl⟩ + +abbrev Msb8 : Channel (F p) fieldPair := msb8Table.toChannel + +/-- `MSB16[X + 2^8·Y] -> MSB16` (`BusId::Msb16`): a halfword and its top bit. -/ +def msb16Table : StaticLookupChannel (F p) fieldPair where + name := "MSB16" + table := rows.map fun r => (((r.x + 2^8 * r.y : ℕ) : F p), (r.msb16 : F p)) + Guarantees | (h, m) => h.val < 2^16 ∧ m.val = h.val / 2^15 + guarantees_iff := by + rintro ⟨h, m⟩ + simp only [List.mem_map, mem_rows_iff, Prod.mk.injEq] + constructor + · rintro ⟨hh, hm⟩ + refine ⟨row (index (h.val % 2^8) (h.val / 2^8) 0), + ⟨_, index_lt (by omega) (by omega) (by norm_num), rfl⟩, ?_, ?_⟩ + · rw [row_index (by omega) (by omega) (by norm_num)] + simp only [rowOf] + rw [show h.val % 2^8 + 2^8 * (h.val / 2^8) = h.val by omega] + exact ZMod.natCast_zmod_val h + · rw [row_index (by omega) (by omega) (by norm_num)] + simp only [rowOf] + rw [show h.val % 2^8 + 2^8 * (h.val / 2^8) = h.val by omega, ← hm] + exact ZMod.natCast_zmod_val m + · rintro ⟨r, ⟨i, _, rfl⟩, rfl, rfl⟩ + have := row_x_lt i; have := row_y_lt i + rw [val_natCast_of_lt_two_pow_40 (by omega), val_natCast_of_lt_two_pow_40 (by rw [row_msb16]; omega), + row_msb16] + exact ⟨by omega, rfl⟩ + +abbrev Msb16 : Channel (F p) fieldPair := msb16Table.toChannel + +/-- `ZERO[X + 2^8·Y + 2^16·Z] -> ZERO` (`BusId::Zero`): a 20-bit value and its zero flag. -/ +def zeroTable : StaticLookupChannel (F p) fieldPair where + name := "ZERO" + table := rows.map fun r => (((r.x + 2^8 * r.y + 2^16 * r.z : ℕ) : F p), (r.zero : F p)) + Guarantees | (v, z) => v.val < 2^20 ∧ z = if v = 0 then 1 else 0 + guarantees_iff := by + rintro ⟨v, z⟩ + simp only [List.mem_map, mem_rows_iff, Prod.mk.injEq] + constructor + · rintro ⟨hv, hz⟩ + refine ⟨row (index (v.val % 2^8) (v.val / 2^8 % 2^8) (v.val / 2^16)), + ⟨_, index_lt (by omega) (by omega) (by omega), rfl⟩, ?_, ?_⟩ + · rw [row_index (by omega) (by omega) (by omega)] + simp only [rowOf] + rw [show v.val % 2^8 + 2^8 * (v.val / 2^8 % 2^8) + 2^16 * (v.val / 2^16) = v.val by omega] + exact ZMod.natCast_zmod_val v + · rw [row_index (by omega) (by omega) (by omega)] + simp only [rowOf] + have hiff : (v.val % 2^8 = 0 ∧ v.val / 2^8 % 2^8 = 0 ∧ v.val / 2^16 = 0) ↔ v = 0 := by + rw [← ZMod.val_eq_zero]; omega + rw [hz] + simp only [hiff] + split_ifs <;> simp + · rintro ⟨r, ⟨i, _, rfl⟩, rfl, rfl⟩ + have := row_x_lt i; have := row_y_lt i; have := row_z_lt i + rw [val_natCast_of_lt_two_pow_40 (by omega), row_zero] + refine ⟨by omega, ?_⟩ + have hn : (((row i).x + 2^8 * (row i).y + 2^16 * (row i).z : ℕ) : F p) = 0 ↔ + ((row i).x = 0 ∧ (row i).y = 0 ∧ (row i).z = 0) := by + rw [← ZMod.val_eq_zero, val_natCast_of_lt_two_pow_40 (by omega)]; omega + simp only [hn] + split_ifs <;> simp + +abbrev Zero : Channel (F p) fieldPair := zeroTable.toChannel + +/-! ## Byte ALU and halfword shift channels -/ + +/-- Message of `BYTE_ALU[opsel, X, Y] -> out` (`BusId::ByteAlu`), `opsel` = AND 0 / OR 1 / XOR 2. -/ +structure ByteAluMsg (F : Type) where + opsel : F + x : F + y : F + out : F +deriving ProvableStruct + +lemma row_and (i : ℕ) : (row i).and = (row i).x &&& (row i).y := rfl +lemma row_or (i : ℕ) : (row i).or = (row i).x ||| (row i).y := rfl +lemma row_xor (i : ℕ) : (row i).xor = (row i).x ^^^ (row i).y := rfl + +lemma and_lt_256 {x y : ℕ} (hy : y < 2^8) : x &&& y < 2^8 := Nat.and_le_right.trans_lt hy +lemma or_lt_256 {x y : ℕ} (hx : x < 2^8) (hy : y < 2^8) : x ||| y < 2^8 := by + have := Nat.or_lt_two_pow (n := 8) (by norm_num; exact hx) (by norm_num; exact hy) + norm_num at this; exact this +lemma xor_lt_256 {x y : ℕ} (hx : x < 2^8) (hy : y < 2^8) : x ^^^ y < 2^8 := by + have := Nat.xor_lt_two_pow (n := 8) (by norm_num; exact hx) (by norm_num; exact hy) + norm_num at this; exact this + +def byteAluTable : StaticLookupChannel (F p) ByteAluMsg where + name := "BYTE_ALU" + table := rows.flatMap fun r => + [ ⟨opselAND, r.x, r.y, r.and⟩, ⟨opselOR, r.x, r.y, r.or⟩, ⟨opselXOR, r.x, r.y, r.xor⟩ ] + Guarantees + | { opsel, x, y, out } => + x.val < 2^8 ∧ y.val < 2^8 ∧ + ((opsel = opselAND ∧ out.val = x.val &&& y.val) ∨ + (opsel = opselOR ∧ out.val = x.val ||| y.val) ∨ + (opsel = opselXOR ∧ out.val = x.val ^^^ y.val)) + guarantees_iff := by + rintro ⟨opsel, x, y, out⟩ + simp only [List.mem_flatMap, mem_rows_iff, List.mem_cons, + List.not_mem_nil, or_false, ByteAluMsg.mk.injEq] + constructor + · rintro ⟨hx, hy, hop⟩ + refine ⟨row (index x.val y.val 0), ⟨_, index_lt hx hy (by norm_num), rfl⟩, ?_⟩ + rw [row_index hx hy (by norm_num)] + simp only [rowOf] + rcases hop with ⟨rfl, hout⟩ | ⟨rfl, hout⟩ | ⟨rfl, hout⟩ + · left; refine ⟨by simp, (ZMod.natCast_zmod_val x).symm, (ZMod.natCast_zmod_val y).symm, ?_⟩ + rw [← hout]; exact (ZMod.natCast_zmod_val out).symm + · right; left; refine ⟨by simp, (ZMod.natCast_zmod_val x).symm, (ZMod.natCast_zmod_val y).symm, ?_⟩ + rw [← hout]; exact (ZMod.natCast_zmod_val out).symm + · right; right; refine ⟨by simp, (ZMod.natCast_zmod_val x).symm, (ZMod.natCast_zmod_val y).symm, ?_⟩ + rw [← hout]; exact (ZMod.natCast_zmod_val out).symm + · rintro ⟨r, ⟨i, _, rfl⟩, ⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩⟩ + all_goals + have hx := row_x_lt i; have hy := row_y_lt i + rw [val_natCast_of_lt_two_pow_40 (by omega), val_natCast_of_lt_two_pow_40 (by omega)] + refine ⟨hx, hy, ?_⟩ + · left; rw [row_and, val_natCast_of_lt_two_pow_40 (by linarith [and_lt_256 (x := (row i).x) hy])] + simp + · right; left; rw [row_or, val_natCast_of_lt_two_pow_40 (by linarith [or_lt_256 hx hy])] + simp + · right; right; rw [row_xor, val_natCast_of_lt_two_pow_40 (by linarith [xor_lt_256 hx hy])] + simp + +abbrev ByteAlu : Channel (F p) ByteAluMsg := byteAluTable.toChannel + +/-- Message of `HWSL[X + 2^8·Y, Z] -> [SLL, SLLC]` (`BusId::Hwsl`). -/ +structure HwslMsg (F : Type) where + h : F + z : F + sll : F + sllc : F +deriving ProvableStruct + +lemma row_sll (i : ℕ) : (row i).sll = sll ((row i).x + 2^8 * (row i).y) (row i).z := rfl +lemma row_sllc (i : ℕ) : (row i).sllc = sllc ((row i).x + 2^8 * (row i).y) (row i).z := rfl + +def hwslTable : StaticLookupChannel (F p) HwslMsg where + name := "HWSL" + table := rows.map fun r => ⟨((r.x + 2^8 * r.y : ℕ) : F p), r.z, r.sll, r.sllc⟩ + Guarantees + | { h, z, sll, sllc } => + h.val < 2^16 ∧ z.val < 16 ∧ + sll.val = (h.val <<< z.val) % 2^16 ∧ sllc.val = h.val >>> (16 - z.val) + guarantees_iff := by + rintro ⟨h, z, sll, sllc⟩ + simp only [List.mem_map, mem_rows_iff, HwslMsg.mk.injEq] + constructor + · rintro ⟨hh, hz, hsll, hsllc⟩ + refine ⟨row (index (h.val % 2^8) (h.val / 2^8) z.val), + ⟨_, index_lt (by omega) (by omega) hz, rfl⟩, ?_⟩ + rw [row_index (by omega) (by omega) hz] + simp only [rowOf] + rw [show h.val % 2^8 + 2^8 * (h.val / 2^8) = h.val by omega, sll_eq hh, sllc_eq hh] + refine ⟨ZMod.natCast_zmod_val h, ZMod.natCast_zmod_val z, ?_, ?_⟩ + · rw [← hsll]; exact ZMod.natCast_zmod_val sll + · rw [← hsllc]; exact ZMod.natCast_zmod_val sllc + · rintro ⟨r, ⟨i, _, rfl⟩, rfl, rfl, rfl, rfl⟩ + have hx := row_x_lt i; have hy := row_y_lt i; have hz := row_z_lt i + have hh : (row i).x + 2^8 * (row i).y < 2^16 := by omega + have hsll_lt : (row i).sll < 2^16 := by + rw [row_sll, sll_eq hh]; exact Nat.mod_lt _ (by norm_num) + have hsllc_lt : (row i).sllc < 2^16 := by + rw [row_sllc, sllc_eq hh]; exact (Nat.shiftRight_le _ _).trans_lt hh + rw [val_natCast_of_lt_two_pow_40 (by omega), val_natCast_of_lt_two_pow_40 (by omega), + val_natCast_of_lt_two_pow_40 (by omega), val_natCast_of_lt_two_pow_40 (by omega), + row_sll, row_sllc, sll_eq hh, sllc_eq hh] + exact ⟨hh, hz, rfl, rfl⟩ + +abbrev Hwsl : Channel (F p) HwslMsg := hwslTable.toChannel + +end LambdaVM.Bitwise diff --git a/formal/LambdaVM/Tables/Eq.lean b/formal/LambdaVM/Tables/Eq.lean new file mode 100644 index 000000000..ea1d51179 --- /dev/null +++ b/formal/LambdaVM/Tables/Eq.lean @@ -0,0 +1,237 @@ +module + +public import LambdaVM.Tables.Bitwise +public import LambdaVM.Buses.Alu +public import LambdaVM.Templates.IsBit +public import LambdaVM.Templates.Add +public import Mathlib.Tactic.LinearCombination + +@[expose] public section + +/-! +# EQ (spec/src/eq.toml) + +One row per equality test `res = (a = b) xor invert`. Columns follow `prover/src/tables/eq.rs`: +`a`, `b` as `DWordWL` (two words), `diff = a − b` as four halves, the `eq` bit, `res`, `μ`. + +`diff` is enforced with the SUB template (the ADD carries of `b + diff = a`), its halves are +range-checked, and `eq` is the ZERO lookup of their sum: four halves sum to zero iff all are +zero iff `a = b`. +-/ + +namespace LambdaVM.EQ +open Alu (eqBit) + +/-- One EQ row, fields in the column order of `eq.rs` and named as in `spec/src/eq.toml`: +`a`, `b` as `DWordWL` words, `diff = a − b` as `DWordHL` halves. -/ +structure Row (F : Type) where + a0 : F + a1 : F + b0 : F + b1 : F + invert : F + res : F + diff0 : F + diff1 : F + diff2 : F + diff3 : F + eq : F + mu : F +deriving ProvableStruct + +/-- The chip's arithmetic on naturals: with `b + diff = a (mod 2⁶⁴)` and everything in range, +the halves of `diff` sum to zero exactly when `a = b`. -/ +theorem core {a0 a1 b0 b1 d0 d1 d2 d3 c0 c1 : ℕ} + (ha0 : a0 < 2^32) (ha1 : a1 < 2^32) (hb0 : b0 < 2^32) (hb1 : b1 < 2^32) + (hd0 : d0 < 2^16) (hd1 : d1 < 2^16) (hd2 : d2 < 2^16) (hd3 : d3 < 2^16) + (hc0 : c0 < 2) (hc1 : c1 < 2) + (e0 : b0 + (d0 + 65536 * d1) = a0 + c0 * 2^32) + (e1 : b1 + (d2 + 65536 * d3) + c0 = a1 + c1 * 2^32) : + d0 + d1 + d2 + d3 = 0 ↔ a0 + 2^32 * a1 = b0 + 2^32 * b1 := by + have h64 : b0 + 2^32 * b1 + (d0 + 65536 * d1 + 2^32 * (d2 + 65536 * d3)) + = a0 + 2^32 * a1 + c1 * 2^64 := by omega + rcases (by omega : c1 = 0 ∨ c1 = 1) with rfl | rfl + · constructor <;> intro h <;> omega + · constructor <;> intro h <;> omega + +def main (r : Var Row (F p)) : Circuit (F p) Unit := do + -- IS_HALF[diff[i]], IS_BIT + Bitwise.IsHalf.pullIf r.mu r.diff0 + Bitwise.IsHalf.pullIf r.mu r.diff1 + Bitwise.IsHalf.pullIf r.mu r.diff2 + Bitwise.IsHalf.pullIf r.mu r.diff3 + isBit r.invert + -- SUB: the carries of b + diff = a are bits + let diffLo := r.diff0 + 65536 * r.diff1 + let diffHi := r.diff2 + 65536 * r.diff3 + sub ⟨r.a0, r.a1⟩ ⟨r.b0, r.b1⟩ ⟨diffLo, diffHi⟩ + -- ZERO[Σ diff[i]] -> eq + Bitwise.Zero.pullIf r.mu (r.diff0 + r.diff1 + r.diff2 + r.diff3, r.eq) + -- res = eq xor invert + assertZero (r.res + 2 * r.eq * r.invert - r.eq - r.invert) + -- μ : Bit (no deduplication) + isBit r.mu + -- output: ALU[a, b, opsel(EQ) + 64·invert] -> [res, 0] + Alu.channel.pushIf r.mu ⟨r.a0, r.a1, r.b0, r.b1, 3 + 64 * r.invert, r.res, 0⟩ + +/-- The honest prover's row, as `generate_eq_trace` fills it. -/ +def Honest (r : Row (F p)) : Prop := + IsBool r.mu ∧ IsBool r.invert ∧ + r.a0.val < 2^32 ∧ r.a1.val < 2^32 ∧ r.b0.val < 2^32 ∧ r.b1.val < 2^32 ∧ + r.diff0.val < 2^16 ∧ r.diff1.val < 2^16 ∧ r.diff2.val < 2^16 ∧ r.diff3.val < 2^16 ∧ + -- diff = a − b (mod 2⁶⁴) + (dword r.b0 r.b1 + + (r.diff0.val + 65536 * r.diff1.val + 2^32 * (r.diff2.val + 65536 * r.diff3.val))) % 2^64 + = dword r.a0 r.a1 ∧ + r.eq.val = (if dword r.a0 r.a1 = dword r.b0 r.b1 then 1 else 0) ∧ + r.res.val = eqBit r.invert.val (dword r.a0 r.a1) (dword r.b0 r.b1) + +/-- A padding row of `generate_eq_trace`: every column zero. -/ +def Padding (r : Row (F p)) : Prop := + r.a0 = 0 ∧ r.a1 = 0 ∧ r.b0 = 0 ∧ r.b1 = 0 ∧ r.invert = 0 ∧ r.res = 0 ∧ + r.diff0 = 0 ∧ r.diff1 = 0 ∧ r.diff2 = 0 ∧ r.diff3 = 0 ∧ r.eq = 0 ∧ r.mu = 0 + +/-- What an active row establishes: with range-checked operands, `res` is the equality bit. -/ +def RowSpec (r : Row (F p)) : Prop := + r.mu = 1 → r.a0.val < 2^32 → r.a1.val < 2^32 → r.b0.val < 2^32 → r.b1.val < 2^32 → + r.res = ((eqBit r.invert.val (dword r.a0 r.a1) (dword r.b0 r.b1) : ℕ) : F p) + +def circuit : GeneralFormalCircuit (F p) Row unit where + name := "EQ" + main + Spec r _ _ := RowSpec r + channelsWithRequirements := [Alu.channel.toRaw] + requirementsChannelsLawful input_var i₀ := by + obtain ⟨a0, a1, b0, b1, invert, res, diff0, diff1, diff2, diff3, eq, mu⟩ := input_var + simp only [circuit_norm, main, isBit, sub, add, Add.carry0, Add.carry1, Alu.channel, + Bitwise.isHalfTable, Bitwise.zeroTable] + constructor + · intro channel h; tauto + · intro env h + -- each pull owes a multiplicity of 0 or 1: μ is a bit + exact mul_one_sub_eq_zero_iff.mp h.2.2.2.2 + + soundness := by + circuit_proof_start [main, isBit, sub, add, Add.carry0, Add.carry1, RowSpec, dword, Alu.channel, + Alu.Guarantees, Bitwise.isHalfTable, Bitwise.zeroTable] + obtain ⟨h_d0, h_d1, h_d2, h_d3, h_i, h_c0, h_c1, h_z, h_res, h_mu⟩ := h_holds + rcases mul_one_sub_eq_zero_iff.mp h_mu with h0 | h1 + · subst h0; simp + subst h1 + have hib : IsBool input_invert := mul_one_sub_eq_zero_iff.mp h_i + have hi_2 := IsBool.val_lt_two hib + have hd0 := h_d0 rfl + have hd1 := h_d1 rfl + have hd2 := h_d2 rfl + have hd3 := h_d3 rfl + obtain ⟨-, heq⟩ := h_z rfl + -- the equality bit, from the pulled guarantees and the SUB carries + have key : input_a0.val < 2^32 → input_a1.val < 2^32 → input_b0.val < 2^32 → + input_b1.val < 2^32 → + input_res = ((eqBit input_invert.val (input_a0.val + 2^32 * input_a1.val) + (input_b0.val + 2^32 * input_b1.val) : ℕ) : F p) := by + intro ha0 ha1 hb0 hb1 + set c0 := (input_b0 + (input_diff0 + 65536 * input_diff1) - input_a0) * inv32 with hc0 + set c1 := (input_b1 + (input_diff2 + 65536 * input_diff3) + c0 - input_a1) * inv32 with hc1 + have hc0b : IsBool c0 := mul_one_sub_eq_zero_iff.mp h_c0 + have hc1b : IsBool c1 := mul_one_sub_eq_zero_iff.mp h_c1 + -- the halves of diff as words + have hval_lo : (input_diff0 + 65536 * input_diff1).val + = input_diff0.val + 65536 * input_diff1.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hval_hi : (input_diff2 + 65536 * input_diff3).val + = input_diff2.val + 65536 * input_diff3.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + -- the carry identities, on naturals + obtain ⟨e0, e1⟩ := Add.carries_lift hb0 hb1 (by omega) (by omega) ha0 ha1 hc0 hc1 hc0b hc1b + rw [hval_lo] at e0 + rw [hval_hi] at e1 + have hcore := core ha0 ha1 hb0 hb1 hd0 hd1 hd2 hd3 (IsBool.val_lt_two hc0b) + (IsBool.val_lt_two hc1b) e0 e1 + have hval_sum : (input_diff0 + input_diff1 + input_diff2 + input_diff3).val + = input_diff0.val + input_diff1.val + input_diff2.val + input_diff3.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hz : input_diff0 + input_diff1 + input_diff2 + input_diff3 = 0 ↔ + input_a0.val + 2^32 * input_a1.val = input_b0.val + 2^32 * input_b1.val := by + rw [← ZMod.val_eq_zero, hval_sum]; exact hcore + have heq_cast : input_eq = ((if input_a0.val + 2^32 * input_a1.val + = input_b0.val + 2^32 * input_b1.val then 1 else 0 : ℕ) : F p) := by + rw [heq] + simp only [hz] + split_ifs <;> simp + have hres' : input_res = input_eq + input_invert - 2 * input_eq * input_invert := by + linear_combination h_res + rcases eq_zero_or_one_of_val hi_2 with ⟨rfl, hiv⟩ | ⟨rfl, hiv⟩ <;> + rw [hres', heq_cast, hiv] <;> + simp only [eqBit] <;> + split_ifs <;> (try norm_num) <;> omega + refine ⟨fun _ => key, by simp, by simp, by simp, by simp, by simp, ?_⟩ + intro _ + -- the flag byte, read as a natural + have hflagsV : (3 + 64 * input_invert : F p).val = 3 + 64 * input_invert.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + refine ⟨?_, ?_, ?_⟩ + · -- the LT clause does not apply: opsel(EQ) + 64·i ≠ opsel(LT) + 32·s + 64·i' + intro s i hs hi hflags + exfalso; rw [hflagsV] at hflags; simp only [opselLT] at hflags; omega + swap + · -- nor the SHIFT clause + intro w s d hw hs hd hflags + exfalso; rw [hflagsV] at hflags; simp only [opselSHIFT] at hflags; omega + intro i hi hflags ha0 ha1 hb0 hb1 + rw [hflagsV] at hflags; simp only [opselEQ] at hflags + rw [key ha0 ha1 hb0 hb1, show input_invert.val = i by omega] + + ProverAssumptions r _ _ := Honest r ∨ Padding r + + completeness := by + circuit_proof_start [main, isBit, sub, add, Add.carry0, Add.carry1, Alu.channel, Alu.Guarantees, + Bitwise.isHalfTable, Bitwise.zeroTable, Honest, Padding, dword] + rcases h_assumptions with ⟨hmu, hib, ha0, ha1, hb0, hb1, hd0, hd1, hd2, hd3, hsum, heq, hres⟩ | + ⟨ha0, ha1, hb0, hb1, hi, hr, hd0, hd1, hd2, hd3, he, hmu⟩ + swap + · -- a padding row: μ = 0 switches off every pull and the push + subst ha0 ha1 hb0 hb1 hi hr hd0 hd1 hd2 hd3 he hmu + simp [circuit_norm] + -- an active row; the halves of diff as words + have hval_lo : (input_diff0 + 65536 * input_diff1).val + = input_diff0.val + 65536 * input_diff1.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hval_hi : (input_diff2 + 65536 * input_diff3).val + = input_diff2.val + 65536 * input_diff3.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + -- the honest carries + have hr0 : (input_diff0 + 65536 * input_diff1).val < 2^32 := by omega + have hr1 : (input_diff2 + 65536 * input_diff3).val < 2^32 := by omega + obtain ⟨k0, k1, hk0, hk1, e0, e1, hc0k, hc1k⟩ := + Add.carries_of_sum hb0 hb1 hr0 hr1 ha0 ha1 (by simp only [dword, hval_lo, hval_hi]; omega) + rw [hval_lo] at e0 + rw [hval_hi] at e1 + have hval_sum : (input_diff0 + input_diff1 + input_diff2 + input_diff3).val + = input_diff0.val + input_diff1.val + input_diff2.val + input_diff3.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hcore := core ha0 ha1 hb0 hb1 hd0 hd1 hd2 hd3 hk0 hk1 e0 e1 + have hz : input_diff0 + input_diff1 + input_diff2 + input_diff3 = 0 ↔ + input_a0.val + 2^32 * input_a1.val = input_b0.val + 2^32 * input_b1.val := by + rw [← ZMod.val_eq_zero, hval_sum]; exact hcore + have heq_cast : input_eq = ((if input_a0.val + 2^32 * input_a1.val + = input_b0.val + 2^32 * input_b1.val then 1 else 0 : ℕ) : F p) := + (ZMod.natCast_zmod_val input_eq).symm.trans (congrArg (Nat.cast : ℕ → F p) heq) + have hres_cast : input_res = ((eqBit input_invert.val (input_a0.val + 2^32 * input_a1.val) + (input_b0.val + 2^32 * input_b1.val) : ℕ) : F p) := by + rw [← hres, ZMod.natCast_zmod_val] + refine ⟨fun _ => by omega, fun _ => by omega, fun _ => by omega, fun _ => by omega, + mul_one_sub_eq_zero_iff.mpr hib, ?_, ?_, fun _ => ⟨by rw [hval_sum]; omega, ?_⟩, ?_, + mul_one_sub_eq_zero_iff.mpr hmu⟩ + · rw [hc0k]; rcases (by omega : k0 = 0 ∨ k0 = 1) with rfl | rfl <;> simp + · rw [hc1k]; rcases (by omega : k1 = 0 ∨ k1 = 1) with rfl | rfl <;> simp + · rw [heq_cast] + simp only [hz] + split_ifs <;> simp + · rw [hres_cast, heq_cast] + rcases eq_zero_or_one_of_val (IsBool.val_lt_two hib) with ⟨rfl, hiv⟩ | ⟨rfl, hiv⟩ <;> + rw [hiv] <;> + simp only [eqBit] <;> + split_ifs <;> (try norm_num) <;> omega + +end LambdaVM.EQ diff --git a/formal/LambdaVM/Tables/Lt.lean b/formal/LambdaVM/Tables/Lt.lean new file mode 100644 index 000000000..44b5fbf89 --- /dev/null +++ b/formal/LambdaVM/Tables/Lt.lean @@ -0,0 +1,334 @@ +module + +public import LambdaVM.Tables.Bitwise +public import LambdaVM.Buses.Alu +public import LambdaVM.Templates.IsBit +public import LambdaVM.Templates.Add +public import Mathlib.Tactic.LinearCombination + +@[expose] public section + +/-! +# LT (spec/src/lt.toml) + +One row per `(lhs, rhs, signed, invert)` comparison. Columns follow `prover/src/tables/lt.rs`: +`lhs`/`rhs` as `DWordHHW` limbs (word, half, half), `lhs_sub_rhs` as four halves, the two +sign bits, `lt`, `res = lt xor invert` and the multiplicity `μ`. + +The carries of `rhs + lhs_sub_rhs = lhs (mod 2⁶⁴)` are virtual: `carry = (…)·2⁻³²`. +-/ + +namespace LambdaVM.LT +open Alu (ltRaw ltBit) + +/-- One LT row, fields in the column order of `lt.rs` and named as in `spec/src/lt.toml`: +`lhs`, `rhs` as `DWordHHW` limbs (`lhs0` a word, `lhs1`, `lhs2` halves), `lhs_sub_rhs` as +`DWordHL` halves. -/ +structure Row (F : Type) where + lhs0 : F + lhs1 : F + lhs2 : F + rhs0 : F + rhs1 : F + rhs2 : F + signed : F + lt : F + lhsSubRhs0 : F + lhsSubRhs1 : F + lhsSubRhs2 : F + lhsSubRhs3 : F + lhsMsb : F + rhsMsb : F + invert : F + res : F + mu : F +deriving ProvableStruct + +/-- The operands as 64-bit values. -/ +def Row.lhsVal (r : Row (F p)) : ℕ := r.lhs0.val + 2^32 * (r.lhs1.val + 65536 * r.lhs2.val) +def Row.rhsVal (r : Row (F p)) : ℕ := r.rhs0.val + 2^32 * (r.rhs1.val + 65536 * r.rhs2.val) + +/-- The LT chip's arithmetic on naturals: the carries of the limb-wise identity +`rhs + (lhs − rhs mod 2⁶⁴) = lhs + c₁·2⁶⁴` decide `lhs < rhs`, and the top halves decide the signs. -/ +theorem core + {l0 l1 l2 r0 r1 r2 s0 s1 s2 s3 c0 c1 A B : ℕ} + (hl0 : l0 < 2^32) (hl1 : l1 < 2^16) (hl2 : l2 < 2^16) + (hr0 : r0 < 2^32) (hr1 : r1 < 2^16) (hr2 : r2 < 2^16) + (hs0 : s0 < 2^16) (hs1 : s1 < 2^16) (hs2 : s2 < 2^16) (hs3 : s3 < 2^16) + (hc0 : c0 < 2) (hc1 : c1 < 2) + (hA : A = l2 / 32768) (hB : B = r2 / 32768) + (e0 : r0 + (s0 + 65536 * s1) = l0 + c0 * 2^32) + (e1 : r1 + 65536 * r2 + (s2 + 65536 * s3) + c0 = l1 + 65536 * l2 + c1 * 2^32) : + let L := l0 + 2^32 * (l1 + 65536 * l2) + let R := r0 + 2^32 * (r1 + 65536 * r2) + (c1 = 1 ↔ L < R) ∧ (A = 1 ↔ 2^63 ≤ L) ∧ (B = 1 ↔ 2^63 ≤ R) ∧ A < 2 ∧ B < 2 ∧ + ((BitVec.ofNat 64 L).slt (BitVec.ofNat 64 R) = true ↔ ((A = 1 ∧ B = 0) ∨ (A = B ∧ L < R))) ∧ + ((BitVec.ofNat 64 L).ult (BitVec.ofNat 64 R) = true ↔ L < R) := by + intro L R + subst hA hB + refine ⟨by omega, by omega, by omega, by omega, by omega, ?_, Alu.ult_ofNat_iff (by omega) (by omega)⟩ + rw [Alu.slt_ofNat_iff (by omega) (by omega)] + split_ifs <;> omega + +def main (r : Var Row (F p)) : Circuit (F p) Unit := do + -- μ : Bit here; the spec and lt.rs range-check it as a byte (see README). + isBit r.mu + -- range: IS_HALF[lhs[1]], IS_HALF[rhs[1]], IS_BIT, IS_BIT + Bitwise.IsHalf.pullIf r.mu r.lhs1 + Bitwise.IsHalf.pullIf r.mu r.rhs1 + isBit r.signed + isBit r.invert + -- defs: MSB16[lhs[2]] -> lhs_msb, MSB16[rhs[2]] -> rhs_msb + Bitwise.Msb16.pullIf r.mu (r.lhs2, r.lhsMsb) + Bitwise.Msb16.pullIf r.mu (r.rhs2, r.rhsMsb) + let lhsHi := r.lhs1 + 65536 * r.lhs2 + let rhsHi := r.rhs1 + 65536 * r.rhs2 + let subLo := r.lhsSubRhs0 + 65536 * r.lhsSubRhs1 + let subHi := r.lhsSubRhs2 + 65536 * r.lhsSubRhs3 + -- virtual: carry = the ADD carries of rhs + lhs_sub_rhs = lhs, unsigned_lt = carry[1] + let unsignedLt := Add.carry1 ⟨r.rhs0, rhsHi⟩ ⟨subLo, subHi⟩ ⟨r.lhs0, lhsHi⟩ + -- lt = signed·(A(1−B) + A·C + (1−B)·C) + (1−signed)·C, with C = unsigned_lt + assertZero (r.lt - (r.signed * (r.lhsMsb * (1 - r.rhsMsb) + r.lhsMsb * unsignedLt + + (1 - r.rhsMsb) * unsignedLt) + (1 - r.signed) * unsignedLt)) + -- res = lt xor invert + assertZero (r.res + 2 * r.lt * r.invert - r.lt - r.invert) + -- sub: IS_BIT, IS_HALF[lhs_sub_rhs[i]] + sub ⟨r.lhs0, lhsHi⟩ ⟨r.rhs0, rhsHi⟩ ⟨subLo, subHi⟩ + Bitwise.IsHalf.pullIf r.mu r.lhsSubRhs0 + Bitwise.IsHalf.pullIf r.mu r.lhsSubRhs1 + Bitwise.IsHalf.pullIf r.mu r.lhsSubRhs2 + Bitwise.IsHalf.pullIf r.mu r.lhsSubRhs3 + -- output: ALU[lhs, rhs, opsel(LT) + 32·signed + 64·invert] -> [res, 0] + Alu.channel.pushIf r.mu + ⟨r.lhs0, lhsHi, r.rhs0, rhsHi, 4 + 32 * r.signed + 64 * r.invert, r.res, 0⟩ + +lemma ltRaw_lt_two {s L R : ℕ} : ltRaw s L R < 2 := by + unfold ltRaw; split_ifs <;> omega + +/-- On an honest row the `lt` bit is the chip's polynomial `s·Q(A, B, C) + (1 − s)·C`. -/ +lemma ltRaw_eq_poly {s A B k1 L R : ℕ} (hs : s < 2) (hA2 : A < 2) (hB2 : B < 2) (hk : k1 < 2) + (hC : k1 = 1 ↔ L < R) (hA : A = 1 ↔ 2^63 ≤ L) (hB : B = 1 ↔ 2^63 ≤ R) + (hS : (BitVec.ofNat 64 L).slt (BitVec.ofNat 64 R) = true ↔ ((A = 1 ∧ B = 0) ∨ (A = B ∧ L < R))) + (hU : (BitVec.ofNat 64 L).ult (BitVec.ofNat 64 R) = true ↔ L < R) : + ltRaw s L R = s * (A * (1 - B) + A * k1 + (1 - B) * k1) + (1 - s) * k1 := by + unfold ltRaw + simp only [hS, hU] + rcases (by omega : s = 0 ∨ s = 1) with rfl | rfl <;> + rcases (by omega : A = 0 ∨ A = 1) with rfl | rfl <;> + rcases (by omega : B = 0 ∨ B = 1) with rfl | rfl <;> + rcases (by omega : k1 = 0 ∨ k1 = 1) with rfl | rfl <;> + norm_num at hC hA hB ⊢ <;> omega + +lemma ltBit_eq {s i L R : ℕ} (hi : i < 2) : + ltBit s i L R = ltRaw s L R + i - 2 * ltRaw s L R * i := by + unfold ltBit + have := ltRaw_lt_two (s := s) (L := L) (R := R) + rcases (by omega : ltRaw s L R = 0 ∨ ltRaw s L R = 1) with h | h <;> + rcases (by omega : i = 0 ∨ i = 1) with rfl | rfl <;> simp [h] + +/-- The `lt` constraint, from the natural-number identity. -/ +lemma lt_constraint {signed A B k1 lt : F p} {sv Av Bv kv : ℕ} + (hs : signed = (sv : F p)) (hA : A = (Av : F p)) (hB : B = (Bv : F p)) (hk : k1 = (kv : F p)) + (hs2 : sv < 2) (hB2 : Bv < 2) + (hlt : lt = ((sv * (Av * (1 - Bv) + Av * kv + (1 - Bv) * kv) + (1 - sv) * kv : ℕ) : F p)) : + lt - (signed * (A * (1 - B) + A * k1 + (1 - B) * k1) + (1 - signed) * k1) = 0 := by + subst hs hA hB hk hlt + push_cast [Nat.cast_sub (by omega : Bv ≤ 1), Nat.cast_sub (by omega : sv ≤ 1)] + ring + +/-- The `res = lt xor invert` constraint, from the natural-number identity. -/ +lemma res_constraint {lt invert res : F p} {ltv iv : ℕ} + (hlt : lt = (ltv : F p)) (hi : invert = (iv : F p)) (hltv : ltv < 2) (hiv : iv < 2) + (hres : res = ((ltv + iv - 2 * ltv * iv : ℕ) : F p)) : + res + 2 * lt * invert - lt - invert = 0 := by + subst hlt hi hres + rcases (by omega : ltv = 0 ∨ ltv = 1) with rfl | rfl <;> + rcases (by omega : iv = 0 ∨ iv = 1) with rfl | rfl <;> norm_num + +/-- The honest prover's row, as `generate_lt_trace` fills it when no operation repeats +(`μ ∈ {0, 1}`); a deduplicated row with `μ ≥ 2` is outside this model (see README). -/ +def Honest (r : Row (F p)) : Prop := + IsBool r.mu ∧ IsBool r.signed ∧ IsBool r.invert ∧ + r.lhs0.val < 2^32 ∧ r.lhs1.val < 2^16 ∧ r.lhs2.val < 2^16 ∧ + r.rhs0.val < 2^32 ∧ r.rhs1.val < 2^16 ∧ r.rhs2.val < 2^16 ∧ + r.lhsSubRhs0.val < 2^16 ∧ r.lhsSubRhs1.val < 2^16 ∧ r.lhsSubRhs2.val < 2^16 ∧ r.lhsSubRhs3.val < 2^16 ∧ + -- lhs_sub_rhs = lhs − rhs (mod 2⁶⁴) + (r.rhsVal + (r.lhsSubRhs0.val + 65536 * r.lhsSubRhs1.val + + 2^32 * (r.lhsSubRhs2.val + 65536 * r.lhsSubRhs3.val))) % 2^64 = r.lhsVal ∧ + r.lhsMsb.val = r.lhs2.val / 32768 ∧ r.rhsMsb.val = r.rhs2.val / 32768 ∧ + r.lt.val = ltRaw r.signed.val r.lhsVal r.rhsVal ∧ + r.res.val = ltBit r.signed.val r.invert.val r.lhsVal r.rhsVal + +/-- What an active row establishes: with range-checked low words, `res` is the comparison bit. -/ +def RowSpec (r : Row (F p)) : Prop := + r.mu = 1 → r.lhs0.val < 2^32 → r.rhs0.val < 2^32 → + r.res = ((ltBit r.signed.val r.invert.val r.lhsVal r.rhsVal : ℕ) : F p) + +/-- The LT row with `μ ∈ {0, 1}`: soundness and completeness below do not cover the +deduplicated rows (`μ ≥ 2`) that `lt.rs` produces; see README, "Known differences". -/ +def circuit : GeneralFormalCircuit (F p) Row unit where + name := "LT" + main + Spec r _ _ := RowSpec r + channelsWithRequirements := [Alu.channel.toRaw] + requirementsChannelsLawful input_var i₀ := by + obtain ⟨lhs0, lhs1, lhs2, rhs0, rhs1, rhs2, signed, lt, lhsSubRhs0, lhsSubRhs1, lhsSubRhs2, lhsSubRhs3, + lhsMsb, rhsMsb, invert, res, mu⟩ := input_var + simp only [circuit_norm, main, isBit, sub, add, Add.carry0, Add.carry1, Alu.channel, + Bitwise.isHalfTable, Bitwise.msb16Table] + constructor + · intro channel h; tauto + · intro env h + -- each pull owes a multiplicity of 0 or 1: μ is a bit + exact mul_one_sub_eq_zero_iff.mp h.1 + + soundness := by + circuit_proof_start [main, isBit, sub, add, Add.carry0, Add.carry1, RowSpec, Row.lhsVal, Row.rhsVal, + dword, Alu.channel, Alu.Guarantees, Bitwise.isHalfTable, Bitwise.msb16Table] + obtain ⟨h_mu, h_l1, h_r1, h_s, h_i, h_lm, h_rm, h_lt, h_res, h_c0, h_c1, h_s0, h_s1, h_s2, h_s3⟩ := + h_holds + -- μ ∈ {0, 1}; with μ = 0 every requirement is vacuous + rcases mul_one_sub_eq_zero_iff.mp h_mu with h0 | h1 + · subst h0; simp + subst h1 + have hsb : IsBool input_signed := mul_one_sub_eq_zero_iff.mp h_s + have hib : IsBool input_invert := mul_one_sub_eq_zero_iff.mp h_i + have hs_2 := IsBool.val_lt_two hsb + have hi_2 := IsBool.val_lt_two hib + -- the pulled guarantees are now unconditional + have hl1 := h_l1 rfl + have hr1 := h_r1 rfl + obtain ⟨hl2, hlm⟩ := h_lm rfl + obtain ⟨hr2, hrm⟩ := h_rm rfl + have hs0 := h_s0 rfl + have hs1 := h_s1 rfl + have hs2 := h_s2 rfl + have hs3 := h_s3 rfl + -- values of the composite limbs + have hval_lhsHi : (input_lhs1 + 65536 * input_lhs2).val = input_lhs1.val + 65536 * input_lhs2.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hval_rhsHi : (input_rhs1 + 65536 * input_rhs2).val = input_rhs1.val + 65536 * input_rhs2.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + -- the comparison bit, from the pulled guarantees and the SUB carries + have key : ∀ s i : ℕ, input_signed.val = s → input_invert.val = i → + input_lhs0.val < 2^32 → input_rhs0.val < 2^32 → + input_res = ((ltBit s i (input_lhs0.val + 2^32 * (input_lhs1.val + 65536 * input_lhs2.val)) + (input_rhs0.val + 2^32 * (input_rhs1.val + 65536 * input_rhs2.val)) : ℕ) : F p) := by + intro s i hsv hiv hl0 hr0 + -- the virtual carries + set c0 := (input_rhs0 + (input_lhsSubRhs0 + 65536 * input_lhsSubRhs1) - input_lhs0) * inv32 + with hc0 + set c1 := (input_rhs1 + 65536 * input_rhs2 + (input_lhsSubRhs2 + 65536 * input_lhsSubRhs3) + c0 + - (input_lhs1 + 65536 * input_lhs2)) * inv32 with hc1 + have hc0b : IsBool c0 := mul_one_sub_eq_zero_iff.mp h_c0 + have hc1b : IsBool c1 := mul_one_sub_eq_zero_iff.mp h_c1 + have hc0_2 := IsBool.val_lt_two hc0b + have hc1_2 := IsBool.val_lt_two hc1b + -- the halves of lhs_sub_rhs as words + have hval_subLo : (input_lhsSubRhs0 + 65536 * input_lhsSubRhs1).val + = input_lhsSubRhs0.val + 65536 * input_lhsSubRhs1.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hval_subHi : (input_lhsSubRhs2 + 65536 * input_lhsSubRhs3).val + = input_lhsSubRhs2.val + 65536 * input_lhsSubRhs3.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + -- the carry identities, on naturals + obtain ⟨e0, e1⟩ := Add.carries_lift hr0 (by omega) (by omega) (by omega) hl0 (by omega) + hc0 hc1 hc0b hc1b + rw [hval_subLo] at e0 + rw [hval_rhsHi, hval_subHi, hval_lhsHi] at e1 + obtain ⟨hC, hA, hB, hA2, hB2, hS, hU⟩ := + core hl0 hl1 hl2 hr0 hr1 hr2 hs0 hs1 hs2 hs3 hc0_2 hc1_2 hlm hrm e0 e1 + -- lt and res as field identities in the boolean values + have hlt' : input_lt = input_signed * (input_lhsMsb * (1 - input_rhsMsb) + input_lhsMsb * c1 + + (1 - input_rhsMsb) * c1) + (1 - input_signed) * c1 := by + rw [← sub_eq_zero]; exact h_lt + have hres' : input_res = input_lt + input_invert - 2 * input_lt * input_invert := by + linear_combination h_res + rw [← ZMod.natCast_zmod_val input_signed, ← ZMod.natCast_zmod_val input_lhsMsb, + ← ZMod.natCast_zmod_val input_rhsMsb, ← ZMod.natCast_zmod_val c1, hsv] at hlt' + rw [← ZMod.natCast_zmod_val input_invert, hiv] at hres' + -- the comparisons, on naturals + simp only [ltBit, ltRaw, hS, hU] + rcases (by omega : s = 0 ∨ s = 1) with rfl | rfl <;> + rcases (by omega : i = 0 ∨ i = 1) with rfl | rfl <;> + rcases (by omega : input_lhsMsb.val = 0 ∨ input_lhsMsb.val = 1) with hAv | hAv <;> + rcases (by omega : input_rhsMsb.val = 0 ∨ input_rhsMsb.val = 1) with hBv | hBv <;> + rcases (by omega : c1.val = 0 ∨ c1.val = 1) with hcv | hcv <;> + simp only [hAv, hBv, hcv, Nat.cast_zero, Nat.cast_one] at hlt' hA hB hC <;> + norm_num at hlt' hA hB hC <;> + first + | (exfalso; omega) + | (subst hlt'; norm_num at hres'; simp [hAv, hBv, hC, hres']) + refine ⟨fun _ hl0 hr0 => key _ _ rfl rfl hl0 hr0, by simp, by simp, by simp, by simp, by simp, + by simp, by simp, by simp, ?_⟩ + intro _ + -- the flag byte, read as a natural + have hflagsV : (4 + 32 * input_signed + 64 * input_invert : F p).val + = 4 + 32 * input_signed.val + 64 * input_invert.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + refine ⟨?_, ?_, ?_⟩ + · intro s i hs hi hflags hl0 hr0 + rw [hflagsV] at hflags; simp only [opselLT] at hflags + rw [key s i (by omega) (by omega) hl0 hr0, hval_lhsHi, hval_rhsHi] + · -- the EQ clause does not apply: opsel(LT) + 32·s + 64·i ≠ opsel(EQ) + 64·i' + intro i hi hflags + exfalso; rw [hflagsV] at hflags; simp only [opselEQ] at hflags; omega + · -- nor the SHIFT clause: opsel(SHIFT) + w + 32·s + 64·d ≡ 5 or 6 (mod 32) + intro w s d hw hs hd hflags + exfalso; rw [hflagsV] at hflags; simp only [opselSHIFT] at hflags; omega + + + ProverAssumptions r _ _ := Honest r + + completeness := by + circuit_proof_start [main, isBit, sub, add, Add.carry0, Add.carry1, Alu.channel, Alu.Guarantees, + Bitwise.isHalfTable, Bitwise.msb16Table, Honest, Row.lhsVal, Row.rhsVal] + obtain ⟨hmu, hsb, hib, hl0, hl1, hl2, hr0, hr1, hr2, hs0, hs1, hs2, hs3, hsum, hlm, hrm, hlt, hres⟩ := + h_assumptions + set L := input_lhs0.val + 2^32 * (input_lhs1.val + 65536 * input_lhs2.val) with hL + set R := input_rhs0.val + 2^32 * (input_rhs1.val + 65536 * input_rhs2.val) with hR + -- the composite limbs as words + have hval_lhsHi : (input_lhs1 + 65536 * input_lhs2).val = input_lhs1.val + 65536 * input_lhs2.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hval_rhsHi : (input_rhs1 + 65536 * input_rhs2).val = input_rhs1.val + 65536 * input_rhs2.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hval_subLo : (input_lhsSubRhs0 + 65536 * input_lhsSubRhs1).val + = input_lhsSubRhs0.val + 65536 * input_lhsSubRhs1.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hval_subHi : (input_lhsSubRhs2 + 65536 * input_lhsSubRhs3).val + = input_lhsSubRhs2.val + 65536 * input_lhsSubRhs3.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + -- the honest carries + have hl1' : (input_rhs1 + 65536 * input_rhs2).val < 2^32 := by omega + have hr0' : (input_lhsSubRhs0 + 65536 * input_lhsSubRhs1).val < 2^32 := by omega + have hr1' : (input_lhsSubRhs2 + 65536 * input_lhsSubRhs3).val < 2^32 := by omega + have hs1' : (input_lhs1 + 65536 * input_lhs2).val < 2^32 := by omega + obtain ⟨k0, k1, hk0, hk1, e0, e1, hc0k, hc1k⟩ := + Add.carries_of_sum hr0 hl1' hr0' hr1' hl0 hs1' + (by simp only [dword, hval_lhsHi, hval_rhsHi, hval_subLo, hval_subHi]; omega) + rw [hval_subLo] at e0 + rw [hval_rhsHi, hval_subHi, hval_lhsHi] at e1 + have hA2 : input_lhsMsb.val < 2 := by omega + have hB2 : input_rhsMsb.val < 2 := by omega + obtain ⟨hC, hA, hB, -, -, hS, hU⟩ := + core hl0 hl1 hl2 hr0 hr1 hr2 hs0 hs1 hs2 hs3 hk0 hk1 hlm hrm e0 e1 + have hpoly := ltRaw_eq_poly (IsBool.val_lt_two hsb) hA2 hB2 hk1 hC hA hB hS hU + have hlt_raw : input_lt = ((ltRaw input_signed.val L R : ℕ) : F p) := by + rw [← hlt, ZMod.natCast_zmod_val] + have hres_cast : input_res = ((ltRaw input_signed.val L R + input_invert.val + - 2 * ltRaw input_signed.val L R * input_invert.val : ℕ) : F p) := by + rw [← ltBit_eq (IsBool.val_lt_two hib), ← hres, ZMod.natCast_zmod_val] + refine ⟨mul_one_sub_eq_zero_iff.mpr hmu, fun _ => by omega, fun _ => by omega, + mul_one_sub_eq_zero_iff.mpr hsb, mul_one_sub_eq_zero_iff.mpr hib, + fun _ => ⟨by omega, hlm⟩, fun _ => ⟨by omega, hrm⟩, ?_, ?_, ?_, ?_, + fun _ => by omega, fun _ => by omega, fun _ => by omega, fun _ => by omega⟩ + · exact lt_constraint (ZMod.natCast_zmod_val input_signed).symm + (ZMod.natCast_zmod_val input_lhsMsb).symm (ZMod.natCast_zmod_val input_rhsMsb).symm hc1k + (IsBool.val_lt_two hsb) hB2 (by rw [hlt_raw, hpoly]) + · exact res_constraint hlt_raw (ZMod.natCast_zmod_val input_invert).symm ltRaw_lt_two + (IsBool.val_lt_two hib) hres_cast + · rw [hc0k]; rcases (by omega : k0 = 0 ∨ k0 = 1) with rfl | rfl <;> simp + · rw [hc1k]; rcases (by omega : k1 = 0 ∨ k1 = 1) with rfl | rfl <;> simp + + +end LambdaVM.LT diff --git a/formal/LambdaVM/Tables/Shift.lean b/formal/LambdaVM/Tables/Shift.lean new file mode 100644 index 000000000..9ff1cbc28 --- /dev/null +++ b/formal/LambdaVM/Tables/Shift.lean @@ -0,0 +1,798 @@ +module + +public import LambdaVM.Tables.Bitwise +public import LambdaVM.Buses.Alu +public import LambdaVM.Templates.IsBit +public import LambdaVM.Tables.ShiftCore +public import Mathlib.Tactic.LinearCombination + +@[expose] public section + +/-! +# SHIFT (spec/src/shift.toml) + +One row per shift. Columns follow `prover/src/tables/shift.rs`: `in` as four halves, the low +byte of the shift amount plus its upper limbs for the ALU bus, the three flags, `out` as two +words, and the scratch of the two-phase design: `bit_shift = shift mod 16` (or its complement +when shifting right), `zbs = [bit_shift = 0]`, the HWSL outputs `X[i], Y[i]`, the one-hot +`limb_shift`, and the sign bit. +-/ + +namespace LambdaVM.SHIFT +open Alu (shiftResult) +open ShiftCore (limbs) +open Bitwise (sll sllc sll_eq sllc_eq sll_of_eq sllc_of_eq) + +/-- One SHIFT row, fields in the column order of `shift.rs` and named as in `spec/src/shift.toml`: +`in` as four halves, `shiftAmount`, `shiftB1`, `shiftH1`, `shiftHigh` the bytes, half and high +word of the shift operand, `ls` the stored one-hot `limb_shift`. -/ +structure Row (F : Type) where + in0 : F + in1 : F + in2 : F + in3 : F + shiftAmount : F + direction : F + signed : F + wordInstr : F + out0 : F + out1 : F + isNegative : F + bitShift : F + zbs : F + x0 : F + x1 : F + x2 : F + x3 : F + x4 : F + y0 : F + y1 : F + y2 : F + y3 : F + ls0 : F + ls1 : F + ls2 : F + mu : F + shiftB1 : F + shiftH1 : F + shiftHigh : F +deriving ProvableStruct + +/-- The `shifted` limbs of the spec as one polynomial, over expressions or over field values: +`mu`, `d` (direction), the stored one-hot `l0 l1 l2`, the extension limb `e`, and the HWSL +outputs `x0..x4`, `y0..y3`. Kept folded during circuit proofs; `eval_shiftedPoly` pushes +evaluation inside. -/ +def shiftedPoly {R : Type} [Add R] [Mul R] [Sub R] [OfNat R 1] + (mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3 : R) : R × R × R × R := + let l3 := 1 - l0 - l1 - l2 + let left := mu - d + let right := d + let il0 := x0 + let il1 := x1 + y0 + let il2 := x2 + y1 + let il3 := x3 + y2 + let ir0 := y0 + x1 + let ir1 := y1 + x2 + let ir2 := y2 + x3 + let ir3 := y3 + x4 + (left * (l0 * il0) + right * (l0 * ir0 + l1 * ir1 + l2 * ir2 + l3 * ir3), + left * (l0 * il1 + l1 * il0) + right * (l0 * ir1 + l1 * ir2 + l2 * ir3 + e * l3), + left * (l0 * il2 + l1 * il1 + l2 * il0) + right * (l0 * ir2 + l1 * ir3 + e * (l2 + l3)), + left * (l0 * il3 + l1 * il2 + l2 * il1 + l3 * il0) + right * (l0 * ir3 + e * (l1 + l2 + l3))) + +def main (r : Var Row (F p)) : Circuit (F p) Unit := do + let left := r.mu - r.direction + let right := r.direction + let extension := 65535 * r.isNegative + let ls3 := 1 - r.ls0 - r.ls1 - r.ls2 + let sh := shiftedPoly r.mu r.direction r.ls0 r.ls1 r.ls2 extension + r.x0 r.x1 r.x2 r.x3 r.x4 r.y0 r.y1 r.y2 r.y3 + -- constraints, in the order of `ShiftConstraints::eval` + assertZero (r.direction * (1 - r.mu)) + assertZero (r.zbs * (r.x0 - r.in0 * left)) + assertZero (r.zbs * (r.x1 - r.in1 * left)) + assertZero (r.zbs * (r.x2 - r.in2 * left)) + assertZero (r.zbs * (r.x3 - r.in3 * left)) + assertZero (r.zbs * r.x4) + assertZero (r.zbs * (r.y0 - r.in0 * right)) + assertZero (r.zbs * (r.y1 - r.in1 * right)) + assertZero (r.zbs * (r.y2 - r.in2 * right)) + assertZero (r.zbs * (r.y3 - r.in3 * right)) + isBit r.ls0 + isBit r.ls1 + isBit r.ls2 + isBit ls3 + assertZero (r.out0 - sh.1 - sh.2.1 * 65536) + assertZero (r.out1 - sh.2.2.1 - sh.2.2.2 * 65536) + isBit r.direction + isBit r.signed + isBit r.wordInstr + isBit r.zbs + isBit r.mu + assertZero ((1 - r.signed) * r.isNegative) + -- interactions, in the order of `bus_interactions` + Bitwise.Msb16.pullIf r.signed (r.in3, r.isNegative) + Bitwise.ByteAlu.pullIf left ⟨(opselAND : F p), r.shiftAmount, 15, r.bitShift⟩ + Bitwise.ByteAlu.pullIf right ⟨(opselAND : F p), 256 - 16 * r.zbs - r.shiftAmount, 15, r.bitShift⟩ + Bitwise.Zero.pullIf r.mu (r.bitShift, r.zbs) + Bitwise.Hwsl.pullIf (1 - r.zbs) ⟨r.in0, r.bitShift, r.x0, r.y0⟩ + Bitwise.Hwsl.pullIf (1 - r.zbs) ⟨r.in1, r.bitShift, r.x1, r.y1⟩ + Bitwise.Hwsl.pullIf (1 - r.zbs) ⟨r.in2, r.bitShift, r.x2, r.y2⟩ + Bitwise.Hwsl.pullIf (1 - r.zbs) ⟨r.in3, r.bitShift, r.x3, r.y3⟩ + Bitwise.Hwsl.pullIf (1 - r.zbs) ⟨extension, r.bitShift, r.x4, extension - r.x4⟩ + Bitwise.ByteAlu.pullIf r.mu + ⟨(opselAND : F p), r.shiftAmount, 48 - 32 * r.wordInstr, 48 - 48 * r.ls0 - 32 * r.ls1 - 16 * r.ls2⟩ + Alu.channel.pushIf r.mu + ⟨r.in0 + 65536 * r.in1, r.in2 + 65536 * r.in3, + r.shiftAmount + 256 * r.shiftB1 + 65536 * r.shiftH1, r.shiftHigh, + 5 + r.wordInstr + 32 * r.signed + 64 * r.direction, r.out0, r.out1⟩ + Bitwise.AreBytes.pull (r.shiftAmount, r.shiftB1) + Bitwise.IsHalf.pullIf r.mu r.shiftH1 + Bitwise.IsHalf.pullIf r.mu r.in0 + Bitwise.IsHalf.pullIf r.mu r.in1 + Bitwise.IsHalf.pullIf r.mu r.in2 + Bitwise.IsHalf.pullIf r.mu r.in3 + +lemma eval_shiftedPoly_1 (env : Environment (F p)) + (mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3 : Expression (F p)) : + Expression.eval env (shiftedPoly mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3).1 + = (shiftedPoly (env mu) (env d) (env l0) (env l1) (env l2) (env e) (env x0) (env x1) (env x2) + (env x3) (env x4) (env y0) (env y1) (env y2) (env y3)).1 := by + simp only [shiftedPoly, circuit_norm] +lemma eval_shiftedPoly_2 (env : Environment (F p)) + (mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3 : Expression (F p)) : + Expression.eval env (shiftedPoly mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3).2.1 + = (shiftedPoly (env mu) (env d) (env l0) (env l1) (env l2) (env e) (env x0) (env x1) (env x2) + (env x3) (env x4) (env y0) (env y1) (env y2) (env y3)).2.1 := by + simp only [shiftedPoly, circuit_norm] +lemma eval_shiftedPoly_3 (env : Environment (F p)) + (mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3 : Expression (F p)) : + Expression.eval env (shiftedPoly mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3).2.2.1 + = (shiftedPoly (env mu) (env d) (env l0) (env l1) (env l2) (env e) (env x0) (env x1) (env x2) + (env x3) (env x4) (env y0) (env y1) (env y2) (env y3)).2.2.1 := by + simp only [shiftedPoly, circuit_norm] +lemma eval_shiftedPoly_4 (env : Environment (F p)) + (mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3 : Expression (F p)) : + Expression.eval env (shiftedPoly mu d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3).2.2.2 + = (shiftedPoly (env mu) (env d) (env l0) (env l1) (env l2) (env e) (env x0) (env x1) (env x2) + (env x3) (env x4) (env y0) (env y1) (env y2) (env y3)).2.2.2 := by + simp only [shiftedPoly, circuit_norm] + +/-- Over field values that are casts of naturals (with `μ = 1`), `shiftedPoly` is the cast of +`ShiftCore.shifted`. -/ +lemma shiftedPoly_cast {d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3 : ℕ} (hd : d ≤ 1) + (hl : l0 + l1 + l2 ≤ 1) : + let shF := shiftedPoly (1 : F p) (d : F p) (l0 : F p) (l1 : F p) (l2 : F p) (e : F p) + (x0 : F p) (x1 : F p) (x2 : F p) (x3 : F p) (x4 : F p) (y0 : F p) (y1 : F p) (y2 : F p) (y3 : F p) + let sh := ShiftCore.shifted d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3 + shF.1 = (sh.1 : F p) ∧ shF.2.1 = (sh.2.1 : F p) ∧ shF.2.2.1 = (sh.2.2.1 : F p) ∧ + shF.2.2.2 = (sh.2.2.2 : F p) := by + intro shF sh + have h1 : l0 ≤ 1 := by omega + have h2 : l1 ≤ 1 - l0 := by omega + have h3 : l2 ≤ 1 - l0 - l1 := by omega + simp only [shF, sh, shiftedPoly, ShiftCore.shifted] + push_cast [Nat.cast_sub hd, Nat.cast_sub h1, Nat.cast_sub h2, Nat.cast_sub h3] + refine ⟨by ring, by ring, by ring, by ring⟩ + +/-- The `limb_shift` mask `48 − 32·w` on a boolean `w`, as a natural. -/ +lemma mask_val {w : F p} (hw : w = 0 ∨ w = 1) : (48 - 32 * w).val = 48 - 32 * w.val := by + rcases hw with rfl | rfl + · simp only [mul_zero, sub_zero, ZMod.val_zero]; exact val_ofNat 48 (by norm_num) + · norm_num; exact val_ofNat 16 (by norm_num) + +/-- What an active row establishes: `out` is `in` shifted by the low byte of the amount. -/ +def RowSpec (r : Row (F p)) : Prop := + r.mu = 1 → + r.out0.val < 2^32 ∧ r.out1.val < 2^32 ∧ + r.out0.val + 2^32 * r.out1.val + = shiftResult r.wordInstr.val r.signed.val r.direction.val + (ShiftCore.limbs r.in0.val r.in1.val r.in2.val r.in3.val) r.shiftAmount.val + +/-- The `shifted` limbs of a row, on naturals. -/ +def shiftedOf (r : Row (F p)) : ℕ × ℕ × ℕ × ℕ := + ShiftCore.shifted r.direction.val r.ls0.val r.ls1.val r.ls2.val (65535 * r.isNegative.val) + r.x0.val r.x1.val r.x2.val r.x3.val r.x4.val r.y0.val r.y1.val r.y2.val r.y3.val + +/-- The honest prover's active row, as `generate_shift_trace` fills it (`compute_aux`). -/ +def Honest (r : Row (F p)) : Prop := + r.mu = 1 ∧ IsBool r.direction ∧ IsBool r.signed ∧ IsBool r.wordInstr ∧ + r.in0.val < 65536 ∧ r.in1.val < 65536 ∧ r.in2.val < 65536 ∧ r.in3.val < 65536 ∧ + r.shiftAmount.val < 256 ∧ r.shiftB1.val < 256 ∧ r.shiftH1.val < 65536 ∧ + r.isNegative.val = (if r.signed.val = 1 then r.in3.val / 32768 else 0) ∧ + r.bitShift.val = (if r.direction.val = 0 then r.shiftAmount.val % 16 + else (16 - r.shiftAmount.val % 16) % 16) ∧ + r.zbs = (if r.bitShift = 0 then 1 else 0) ∧ + (r.x0.val = if r.bitShift.val = 0 then (if r.direction.val = 0 then r.in0.val else 0) + else sll r.in0.val r.bitShift.val) ∧ + (r.x1.val = if r.bitShift.val = 0 then (if r.direction.val = 0 then r.in1.val else 0) + else sll r.in1.val r.bitShift.val) ∧ + (r.x2.val = if r.bitShift.val = 0 then (if r.direction.val = 0 then r.in2.val else 0) + else sll r.in2.val r.bitShift.val) ∧ + (r.x3.val = if r.bitShift.val = 0 then (if r.direction.val = 0 then r.in3.val else 0) + else sll r.in3.val r.bitShift.val) ∧ + (r.x4.val = if r.bitShift.val = 0 then 0 else sll (65535 * r.isNegative.val) r.bitShift.val) ∧ + (r.y0.val = if r.bitShift.val = 0 then (if r.direction.val = 0 then 0 else r.in0.val) + else sllc r.in0.val r.bitShift.val) ∧ + (r.y1.val = if r.bitShift.val = 0 then (if r.direction.val = 0 then 0 else r.in1.val) + else sllc r.in1.val r.bitShift.val) ∧ + (r.y2.val = if r.bitShift.val = 0 then (if r.direction.val = 0 then 0 else r.in2.val) + else sllc r.in2.val r.bitShift.val) ∧ + (r.y3.val = if r.bitShift.val = 0 then (if r.direction.val = 0 then 0 else r.in3.val) + else sllc r.in3.val r.bitShift.val) ∧ + -- limb_shift: one-hot at (shift / 16) mod (4 or 2) + (r.ls0.val = if r.shiftAmount.val / 16 % (4 - 2 * r.wordInstr.val) = 0 then 1 else 0) ∧ + (r.ls1.val = if r.shiftAmount.val / 16 % (4 - 2 * r.wordInstr.val) = 1 then 1 else 0) ∧ + (r.ls2.val = if r.shiftAmount.val / 16 % (4 - 2 * r.wordInstr.val) = 2 then 1 else 0) ∧ + -- out = shifted, as two words + r.out0.val = (shiftedOf r).1 + 65536 * (shiftedOf r).2.1 ∧ + r.out1.val = (shiftedOf r).2.2.1 + 65536 * (shiftedOf r).2.2.2 + +/-- A padding row as `generate_shift_trace` pads: `zbs = 1` and the columns below zero. `in`, +`bitShift`, `shiftH1` and `shiftHigh` are left free, so this covers more rows than the Rust +padding row. An all-zero row is not one of them: it pulls `HWSL` with multiplicity `1 − zbs`. -/ +def Padding (r : Row (F p)) : Prop := + r.mu = 0 ∧ r.direction = 0 ∧ r.signed = 0 ∧ r.wordInstr = 0 ∧ r.zbs = 1 ∧ + r.isNegative = 0 ∧ r.x0 = 0 ∧ r.x1 = 0 ∧ r.x2 = 0 ∧ r.x3 = 0 ∧ r.x4 = 0 ∧ + r.y0 = 0 ∧ r.y1 = 0 ∧ r.y2 = 0 ∧ r.y3 = 0 ∧ r.ls0 = 0 ∧ r.ls1 = 0 ∧ r.ls2 = 0 ∧ + r.out0 = 0 ∧ r.out1 = 0 ∧ r.shiftAmount = 0 ∧ r.shiftB1 = 0 + +/-- `HWSL[e, b]`'s second output for an extension limb: `e − sll e b` is `sllc e b`. -/ +lemma ext_sllc {e b : ℕ} (he : e = 0 ∨ e = 65535) (hb : b < 16) : + sll e b ≤ e ∧ e - sll e b = sllc e b := by + rcases he with rfl | rfl <;> interval_cases b <;> simp [sll, sllc] + +/-- The `zbs` override of an `X` scratch cell holds on an honest row. -/ +lemma override_x {zbs x i d : F p} {b : ℕ} (hzb : IsBool zbs) (hdb : IsBool d) + (hiff : zbs = 1 → b = 0) + (hx : x.val = if b = 0 then (if d.val = 0 then i.val else 0) else sll i.val b) : + zbs * (x - i * (1 - d)) = 0 := by + rcases hzb with hz | hz + · rw [hz, zero_mul] + · rw [ite_eq_left (hiff hz)] at hx + rw [hz, one_mul, sub_eq_zero] + rcases hdb with hd | hd + · rw [hd] at hx ⊢ + simp only [ZMod.val_zero, ite_true] at hx + rw [ZMod.val_injective _ hx]; ring + · rw [hd] at hx ⊢ + simp only [val_one_eq, one_ne_zero, ite_false] at hx + rw [(ZMod.val_eq_zero _).mp hx]; ring + +/-- The `zbs` override of a `Y` scratch cell holds on an honest row. -/ +lemma override_y {zbs y i d : F p} {b : ℕ} (hzb : IsBool zbs) (hdb : IsBool d) + (hiff : zbs = 1 → b = 0) + (hy : y.val = if b = 0 then (if d.val = 0 then 0 else i.val) else sllc i.val b) : + zbs * (y - i * d) = 0 := by + rcases hzb with hz | hz + · rw [hz, zero_mul] + · rw [ite_eq_left (hiff hz)] at hy + rw [hz, one_mul, sub_eq_zero] + rcases hdb with hd | hd + · rw [hd] at hy ⊢ + simp only [ZMod.val_zero, ite_true] at hy + rw [(ZMod.val_eq_zero _).mp hy]; ring + · rw [hd] at hy ⊢ + simp only [val_one_eq, one_ne_zero, ite_false] at hy + rw [ZMod.val_injective _ hy]; ring + +@[reducible] +instance elaborated : ElaboratedCircuit (F p) Row unit main := by elaborate_circuit + +theorem soundness : + GeneralFormalCircuit.Soundness (F p) (Input := Row) (Output := unit) main (fun _ _ => True) + (fun r _ _ => RowSpec r) := by + circuit_proof_start [main, isBit, RowSpec, Alu.channel, Alu.Guarantees, Bitwise.isHalfTable, + Bitwise.msb16Table, Bitwise.byteAluTable, opselAND, opselOR, opselXOR, Bitwise.zeroTable, Bitwise.hwslTable, + Bitwise.areBytesTable] + obtain ⟨h_dm, h_zx0, h_zx1, h_zx2, h_zx3, h_zx4, h_zy0, h_zy1, h_zy2, h_zy3, + h_ls0, h_ls1, h_ls2, h_ls3, h_out0, h_out1, h_dir, h_sg, h_w, h_zbs, h_mu, h_neg, + h_msb, h_balL, h_balR, h_zero, h_hw0, h_hw1, h_hw2, h_hw3, h_hw4, h_lsb, + h_ab, h_h1, h_in0, h_in1, h_in2, h_in3⟩ := h_holds + have hdb := mul_one_sub_eq_zero_iff.mp h_dir + have hsb := mul_one_sub_eq_zero_iff.mp h_sg + have hwb := mul_one_sub_eq_zero_iff.mp h_w + have hzb := mul_one_sub_eq_zero_iff.mp h_zbs + have hmb := mul_one_sub_eq_zero_iff.mp h_mu + have hl0b := mul_one_sub_eq_zero_iff.mp h_ls0 + have hl1b := mul_one_sub_eq_zero_iff.mp h_ls1 + have hl2b := mul_one_sub_eq_zero_iff.mp h_ls2 + have hl3b := mul_one_sub_eq_zero_iff.mp h_ls3 + have hleft : IsBool (input_mu - input_direction) := by + rcases hmb with h | h <;> rcases hdb with h' | h' <;> simp_all [IsBool] + have hzb' : IsBool (1 - input_zbs) := by + rcases hzb with h | h <;> simp [h, IsBool] + rcases hmb with hmu0 | hmu1 + · -- μ = 0: nothing is required of the row + rw [hmu0] at hleft ⊢ + -- each pull owes a multiplicity of 0 or 1, and the inactive push owes nothing + constructorm* _ ∧ _ + all_goals first + | exact hsb + | exact hleft + | exact hdb + | exact hzb' + | (left; rfl) + | (intro h; exact absurd rfl h) + | (intro h; exact absurd h (by norm_num)) + subst hmu1 + -- the facts every active row has + have hd2 := IsBool.val_lt_two hdb + have hs2 := IsBool.val_lt_two hsb + have hw2 := IsBool.val_lt_two hwb + have hz2 := IsBool.val_lt_two hzb + have hl0 := IsBool.val_lt_two hl0b + have hl1 := IsBool.val_lt_two hl1b + have hl2 := IsBool.val_lt_two hl2b + have honehot := onehot_of_isBool hl0b hl1b hl2b hl3b + obtain ⟨hsA, hB1⟩ := h_ab + obtain ⟨-, hzbs_eq⟩ := h_zero rfl + have hH1 := h_h1 rfl + have hi0 := h_in0 rfl + have hi1 := h_in1 rfl + have hi2 := h_in2 rfl + have hi3 := h_in3 rfl + have h15 : (15 : F p).val = 15 := val_ofNat 15 (by norm_num) + have h02ne : (0 : F p) ≠ 2 := by + intro h + have := congrArg ZMod.val h + rw [ZMod.val_zero, val_ofNat 2 (by norm_num)] at this + omega + -- zbs is the zero flag of bit_shift + have hzb_iff : input_zbs.val = 1 ↔ input_bitShift.val = 0 := by + by_cases hb0 : input_bitShift = 0 + · rw [hzbs_eq, ite_eq_left hb0, val_one_eq, hb0, ZMod.val_zero]; simp + · rw [hzbs_eq, ite_eq_right hb0, ZMod.val_zero] + have : input_bitShift.val ≠ 0 := by rwa [Ne, ZMod.val_eq_zero] + omega + -- bit_shift from the BYTE_ALU lookups + have hb : input_bitShift.val = if input_direction.val = 0 then input_shiftAmount.val % 16 + else (16 - input_shiftAmount.val % 16) % 16 := by + rcases hdb with hd0 | hd1 + · rw [hd0]; simp only [ZMod.val_zero, ite_true] + obtain ⟨-, -, hand | ⟨h02, -⟩⟩ := h_balL (by rw [hd0]; norm_num) + · rw [hand, h15, ShiftCore.and15] + · exact absurd h02 h02ne + · rw [hd1]; simp only [val_one_eq, one_ne_zero, ite_false] + obtain ⟨hx, -, hand | ⟨h02, -⟩⟩ := h_balR (by rw [hd1]) + · rw [h15, ShiftCore.and15] at hand + rw [← ZMod.natCast_zmod_val input_shiftAmount] at hx hand + rcases hzb with hz0 | hz1 + · rw [hz0] at hx hand + simp only [mul_zero, sub_zero] at hx hand + rw [show (256 : F p) = ((256 : ℕ) : F p) by norm_num] at hx hand + obtain ⟨hle, hval⟩ := val_sub_of_val_lt (by norm_num) (by omega) (lt_trans hx (by norm_num)) + rw [hval] at hand + omega + · rw [hz1] at hx hand + rw [show (256 : F p) - 16 * 1 = ((240 : ℕ) : F p) by norm_num] at hx hand + obtain ⟨hle, hval⟩ := val_sub_of_val_lt (by norm_num) (by omega) (lt_trans hx (by norm_num)) + rw [hval] at hand + omega + · exact absurd h02 h02ne + -- the sign bit + have hn : input_isNegative.val = if input_signed.val = 1 then input_in3.val / 32768 else 0 := by + rcases hsb with hs0 | hs1 + · rw [hs0] at h_neg ⊢ + simp only [ZMod.val_zero, zero_ne_one, ite_false] + have : input_isNegative = 0 := by simpa using h_neg + rw [this, ZMod.val_zero] + · rw [hs1]; simp only [val_one_eq, ite_true] + exact (h_msb (by rw [hs1])).2 + have hn2 : input_isNegative.val < 2 := by rw [hn]; split_ifs <;> omega + have hext : (65535 * input_isNegative).val = 65535 * input_isNegative.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + -- the HWSL outputs, or their overrides when bit_shift = 0 + have hxy : (input_x0.val = if input_bitShift.val = 0 then (if input_direction.val = 0 then input_in0.val else 0) + else sll input_in0.val input_bitShift.val) ∧ + (input_x1.val = if input_bitShift.val = 0 then (if input_direction.val = 0 then input_in1.val else 0) + else sll input_in1.val input_bitShift.val) ∧ + (input_x2.val = if input_bitShift.val = 0 then (if input_direction.val = 0 then input_in2.val else 0) + else sll input_in2.val input_bitShift.val) ∧ + (input_x3.val = if input_bitShift.val = 0 then (if input_direction.val = 0 then input_in3.val else 0) + else sll input_in3.val input_bitShift.val) ∧ + (input_x4.val = if input_bitShift.val = 0 then 0 + else sll (65535 * input_isNegative.val) input_bitShift.val) ∧ + (input_y0.val = if input_bitShift.val = 0 then (if input_direction.val = 0 then 0 else input_in0.val) + else sllc input_in0.val input_bitShift.val) ∧ + (input_y1.val = if input_bitShift.val = 0 then (if input_direction.val = 0 then 0 else input_in1.val) + else sllc input_in1.val input_bitShift.val) ∧ + (input_y2.val = if input_bitShift.val = 0 then (if input_direction.val = 0 then 0 else input_in2.val) + else sllc input_in2.val input_bitShift.val) ∧ + (input_y3.val = if input_bitShift.val = 0 then (if input_direction.val = 0 then 0 else input_in3.val) + else sllc input_in3.val input_bitShift.val) := by + rcases hzb with hz0 | hz1 + · -- bit_shift ≠ 0: the lookups fix X and Y + have hbne : input_bitShift.val ≠ 0 := by + intro h; have := hzb_iff.mpr h; rw [hz0, ZMod.val_zero] at this; omega + obtain ⟨hi0', -, hx0v, hy0v⟩ := h_hw0 (by rw [hz0]; norm_num) + obtain ⟨hi1', -, hx1v, hy1v⟩ := h_hw1 (by rw [hz0]; norm_num) + obtain ⟨hi2', -, hx2v, hy2v⟩ := h_hw2 (by rw [hz0]; norm_num) + obtain ⟨hi3', -, hx3v, hy3v⟩ := h_hw3 (by rw [hz0]; norm_num) + obtain ⟨hi4', -, hx4v, -⟩ := h_hw4 (by rw [hz0]; norm_num) + rw [hext] at hx4v hi4' + simp only [ite_eq_right hbne] + exact ⟨sll_of_eq hi0' hx0v, sll_of_eq hi1' hx1v, sll_of_eq hi2' hx2v, sll_of_eq hi3' hx3v, + sll_of_eq hi4' hx4v, sllc_of_eq hi0' hy0v, sllc_of_eq hi1' hy1v, sllc_of_eq hi2' hy2v, + sllc_of_eq hi3' hy3v⟩ + · -- bit_shift = 0: the overrides + have hb0 : input_bitShift.val = 0 := hzb_iff.mp (by rw [hz1, val_one_eq]) + rw [hz1] at h_zx0 h_zx1 h_zx2 h_zx3 h_zx4 h_zy0 h_zy1 h_zy2 h_zy3 + simp only [one_mul, sub_eq_zero] at h_zx0 h_zx1 h_zx2 h_zx3 h_zx4 h_zy0 h_zy1 h_zy2 h_zy3 + simp only [ite_eq_left hb0] + rcases hdb with hd0 | hd1 + · rw [hd0] at h_zx0 h_zx1 h_zx2 h_zx3 h_zy0 h_zy1 h_zy2 h_zy3 ⊢ + simp only [sub_zero, mul_one, mul_zero] at h_zx0 h_zx1 h_zx2 h_zx3 h_zy0 h_zy1 h_zy2 h_zy3 + simp only [ZMod.val_zero, ite_true, h_zx0, h_zx1, h_zx2, h_zx3, h_zy0, h_zy1, h_zy2, h_zy3, + h_zx4, and_self] + · rw [hd1] at h_zx0 h_zx1 h_zx2 h_zx3 h_zy0 h_zy1 h_zy2 h_zy3 ⊢ + simp only [sub_self, mul_one, mul_zero] at h_zx0 h_zx1 h_zx2 h_zx3 h_zy0 h_zy1 h_zy2 h_zy3 + simp only [val_one_eq, one_ne_zero, ite_false, h_zx0, h_zx1, h_zx2, h_zx3, h_zy0, h_zy1, + h_zy2, h_zy3, h_zx4, ZMod.val_zero, and_self] + obtain ⟨hx0, hx1, hx2, hx3, hx4, hy0, hy1, hy2, hy3⟩ := hxy + -- the one-hot limb index from the BYTE_ALU lookup + have hL : 16 * (input_ls1.val + 2 * input_ls2.val + + 3 * (1 - input_ls0.val - input_ls1.val - input_ls2.val)) + = input_shiftAmount.val &&& (48 - 32 * input_wordInstr.val) := by + obtain ⟨-, -, hand | ⟨h02, -⟩⟩ := h_lsb rfl + · have hmask := mask_val hwb + have henc : (48 - 48 * input_ls0 - 32 * input_ls1 - 16 * input_ls2).val + = 48 - 48 * input_ls0.val - 32 * input_ls1.val - 16 * input_ls2.val := by + rcases hl0b with h0 | h0 <;> rcases hl1b with h1 | h1 <;> rcases hl2b with h2 | h2 <;> + · rw [h0, h1, h2] + simp only [h0, h1, h2, ZMod.val_zero, val_one_eq] at honehot ⊢ + first + | omega + | (norm_num; done) + | (norm_num; exact val_ofNat _ (by norm_num)) + rw [henc, hmask] at hand + omega + · exact absurd h02 h02ne + -- the arithmetic + have hcore := ShiftCore.main hd2 hs2 hw2 hsA hi0 hi1 hi2 hi3 hl0 hl1 hl2 honehot hL hb hn + hx0 hx1 hx2 hx3 hx4 hy0 hy1 hy2 hy3 + simp only at hcore + obtain ⟨hsh0, hsh1, hsh2, hsh3, hres⟩ := hcore + -- the output words + have hcast := shiftedPoly_cast (e := 65535 * input_isNegative.val) + (x0 := input_x0.val) (x1 := input_x1.val) (x2 := input_x2.val) (x3 := input_x3.val) + (x4 := input_x4.val) (y0 := input_y0.val) (y1 := input_y1.val) (y2 := input_y2.val) + (y3 := input_y3.val) (by omega : input_direction.val ≤ 1) honehot + simp only at hcast + obtain ⟨hc1, hc2, hc3, hc4⟩ := hcast + rw [eval_shiftedPoly_1, eval_shiftedPoly_2] at h_out0 + rw [eval_shiftedPoly_3, eval_shiftedPoly_4] at h_out1 + simp only [circuit_norm, h_input] at h_out0 h_out1 + rw [← ZMod.natCast_zmod_val input_direction, ← ZMod.natCast_zmod_val input_ls0, + ← ZMod.natCast_zmod_val input_ls1, ← ZMod.natCast_zmod_val input_ls2, + ← ZMod.natCast_zmod_val input_isNegative, ← ZMod.natCast_zmod_val input_x0, + ← ZMod.natCast_zmod_val input_x1, ← ZMod.natCast_zmod_val input_x2, + ← ZMod.natCast_zmod_val input_x3, ← ZMod.natCast_zmod_val input_x4, + ← ZMod.natCast_zmod_val input_y0, ← ZMod.natCast_zmod_val input_y1, + ← ZMod.natCast_zmod_val input_y2, ← ZMod.natCast_zmod_val input_y3, + show (65535 : F p) * ((input_isNegative.val : ℕ) : F p) + = ((65535 * input_isNegative.val : ℕ) : F p) by push_cast; ring] at h_out0 h_out1 + rw [hc1, hc2] at h_out0 + rw [hc3, hc4] at h_out1 + have hout0 : input_out0.val = (ShiftCore.shifted input_direction.val input_ls0.val input_ls1.val + input_ls2.val (65535 * input_isNegative.val) input_x0.val input_x1.val input_x2.val + input_x3.val input_x4.val input_y0.val input_y1.val input_y2.val input_y3.val).1 + + 65536 * (ShiftCore.shifted input_direction.val input_ls0.val input_ls1.val + input_ls2.val (65535 * input_isNegative.val) input_x0.val input_x1.val input_x2.val + input_x3.val input_x4.val input_y0.val input_y1.val input_y2.val input_y3.val).2.1 := + val_eq_of_eq_natCast (by push_cast; linear_combination h_out0) (by omega) + have hout1 : input_out1.val = (ShiftCore.shifted input_direction.val input_ls0.val input_ls1.val + input_ls2.val (65535 * input_isNegative.val) input_x0.val input_x1.val input_x2.val + input_x3.val input_x4.val input_y0.val input_y1.val input_y2.val input_y3.val).2.2.1 + + 65536 * (ShiftCore.shifted input_direction.val input_ls0.val input_ls1.val + input_ls2.val (65535 * input_isNegative.val) input_x0.val input_x1.val input_x2.val + input_x3.val input_x4.val input_y0.val input_y1.val input_y2.val input_y3.val).2.2.2 := + val_eq_of_eq_natCast (by push_cast; linear_combination h_out1) (by omega) + have key : input_out0.val < 2^32 ∧ input_out1.val < 2^32 ∧ + input_out0.val + 2^32 * input_out1.val + = shiftResult input_wordInstr.val input_signed.val input_direction.val + (limbs input_in0.val input_in1.val input_in2.val input_in3.val) + input_shiftAmount.val := by + refine ⟨by omega, by omega, ?_⟩ + rw [← hres, hout0, hout1] + simp only [limbs] + omega + -- the row spec and the bus requirements + refine ⟨fun _ => key, ?_⟩ + -- each pull owes a multiplicity of 0 or 1 + constructorm* _ ∧ _ + all_goals try first + | exact hsb + | exact hleft + | exact hdb + | exact hzb' + | (right; rfl) + -- what remains is the ALU push + intro _ + -- the flag byte, read as a natural + have hflagsV : (5 + input_wordInstr + 32 * input_signed + 64 * input_direction : F p).val + = 5 + input_wordInstr.val + 32 * input_signed.val + 64 * input_direction.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + refine ⟨?_, ?_, ?_⟩ + · -- not LT: 5 + w + 32 s + 64 d ≠ 4 + 32 s' + 64 i (mod 32) + intro s i hs hi hflags + exfalso; rw [hflagsV] at hflags; simp only [opselLT] at hflags; omega + · -- not EQ + intro i hi hflags + exfalso; rw [hflagsV] at hflags; simp only [opselEQ] at hflags; omega + · intro w s d hw hs hd hflags + rw [hflagsV] at hflags; simp only [opselSHIFT] at hflags + obtain ⟨rfl, rfl, rfl⟩ : input_wordInstr.val = w ∧ input_signed.val = s ∧ + input_direction.val = d := by omega + have hv1 : (input_in0 + 65536 * input_in1).val = input_in0.val + 65536 * input_in1.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hv2 : (input_in2 + 65536 * input_in3).val = input_in2.val + 65536 * input_in3.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hin1 : dword (input_in0 + 65536 * input_in1) (input_in2 + 65536 * input_in3) + = limbs input_in0.val input_in1.val input_in2.val input_in3.val := by + simp only [dword, limbs, hv1, hv2]; omega + have hv3 : (input_shiftAmount + 256 * input_shiftB1 + 65536 * input_shiftH1).val + = input_shiftAmount.val + 256 * input_shiftB1.val + 65536 * input_shiftH1.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hin2 : (input_shiftAmount + 256 * input_shiftB1 + 65536 * input_shiftH1).val % 256 + = input_shiftAmount.val := by + rw [hv3]; omega + rw [hin1, hin2] + exact ⟨key.1, key.2.1, key.2.2⟩ + + +theorem completeness : + GeneralFormalCircuit.Completeness (F p) (Input := Row) (Output := unit) main + (fun r _ _ => Honest r ∨ Padding r) (fun _ _ _ => True) := by + circuit_proof_start [main, isBit, Alu.channel, Alu.Guarantees, Bitwise.isHalfTable, Bitwise.msb16Table, + Bitwise.byteAluTable, opselAND, opselOR, opselXOR, Bitwise.zeroTable, Bitwise.hwslTable, Bitwise.areBytesTable, Honest, + Padding, shiftedOf] + rcases h_assumptions with + ⟨hmu, hdb, hsb, hwb, hi0, hi1, hi2, hi3, hsA, hB1, hH1, hn, hb, hzbs, hx0, hx1, hx2, hx3, hx4, + hy0, hy1, hy2, hy3, hl0, hl1, hl2, hout0, hout1⟩ | + ⟨hmu, hd, hs, hw, hz, hneg, hx0, hx1, hx2, hx3, hx4, hy0, hy1, hy2, hy3, hl0, hl1, hl2, + hout0, hout1, hsA, hB1⟩ + · -- an active row + subst hmu + have hd2 := IsBool.val_lt_two hdb + have hs2 := IsBool.val_lt_two hsb + have hw2 := IsBool.val_lt_two hwb + have h15 : (15 : F p).val = 15 := val_ofNat 15 (by norm_num) + have hn2 : input_isNegative.val < 2 := by rw [hn]; split_ifs <;> omega + have hb16 : input_bitShift.val < 16 := by rw [hb]; split_ifs <;> omega + have hL4 : input_shiftAmount.val / 16 % (4 - 2 * input_wordInstr.val) < 4 := by + rcases (by omega : input_wordInstr.val = 0 ∨ input_wordInstr.val = 1) with h | h <;> + rw [h] <;> omega + -- the bits as field values + have hl0b : IsBool input_ls0 := isBool_of_val_lt_two (by rw [hl0]; split_ifs <;> omega) + have hl1b : IsBool input_ls1 := isBool_of_val_lt_two (by rw [hl1]; split_ifs <;> omega) + have hl2b : IsBool input_ls2 := isBool_of_val_lt_two (by rw [hl2]; split_ifs <;> omega) + have honehot : input_ls0.val + input_ls1.val + input_ls2.val ≤ 1 := by + rw [hl0, hl1, hl2]; split_ifs <;> omega + have hnb : IsBool input_isNegative := isBool_of_val_lt_two hn2 + have hzb : IsBool input_zbs := by rw [hzbs]; split_ifs <;> simp [IsBool] + have hzb_iff : input_zbs = 1 ↔ input_bitShift.val = 0 := by + rw [hzbs] + by_cases hb0 : input_bitShift = 0 + · rw [ite_eq_left hb0, hb0, ZMod.val_zero]; simp + · rw [ite_eq_right hb0] + have hne : input_bitShift.val ≠ 0 := by rwa [Ne, ZMod.val_eq_zero] + constructor + · intro h; exact absurd h zero_ne_one + · intro h; exact absurd h hne + have hext : (65535 * input_isNegative).val = 65535 * input_isNegative.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + -- the arithmetic core and the output words + have hL : 16 * (input_ls1.val + 2 * input_ls2.val + + 3 * (1 - input_ls0.val - input_ls1.val - input_ls2.val)) + = input_shiftAmount.val &&& (48 - 32 * input_wordInstr.val) := by + rcases (by omega : input_wordInstr.val = 0 ∨ input_wordInstr.val = 1) with h | h + · rw [h] at hl0 hl1 hl2 ⊢; rw [ShiftCore.and48 hsA, hl0, hl1, hl2]; split_ifs <;> omega + · rw [h] at hl0 hl1 hl2 ⊢; rw [ShiftCore.and16 hsA, hl0, hl1, hl2]; split_ifs <;> omega + have hcore := ShiftCore.main hd2 hs2 hw2 hsA hi0 hi1 hi2 hi3 + (by rw [hl0]; split_ifs <;> omega) (by rw [hl1]; split_ifs <;> omega) + (by rw [hl2]; split_ifs <;> omega) honehot hL hb hn hx0 hx1 hx2 hx3 hx4 hy0 hy1 hy2 hy3 + simp only at hcore + obtain ⟨hsh0, hsh1, hsh2, hsh3, -⟩ := hcore + have hcast := shiftedPoly_cast (e := 65535 * input_isNegative.val) + (x0 := input_x0.val) (x1 := input_x1.val) (x2 := input_x2.val) (x3 := input_x3.val) + (x4 := input_x4.val) (y0 := input_y0.val) (y1 := input_y1.val) (y2 := input_y2.val) + (y3 := input_y3.val) (by omega : input_direction.val ≤ 1) honehot + simp only at hcast + obtain ⟨hc1, hc2, hc3, hc4⟩ := hcast + have hout0' : input_out0 = (((ShiftCore.shifted input_direction.val input_ls0.val input_ls1.val + input_ls2.val (65535 * input_isNegative.val) input_x0.val input_x1.val input_x2.val + input_x3.val input_x4.val input_y0.val input_y1.val input_y2.val input_y3.val).1 + + 65536 * (ShiftCore.shifted input_direction.val input_ls0.val input_ls1.val + input_ls2.val (65535 * input_isNegative.val) input_x0.val input_x1.val input_x2.val + input_x3.val input_x4.val input_y0.val input_y1.val input_y2.val input_y3.val).2.1 : ℕ) : F p) := by + rw [← hout0, ZMod.natCast_zmod_val] + have hout1' : input_out1 = (((ShiftCore.shifted input_direction.val input_ls0.val input_ls1.val + input_ls2.val (65535 * input_isNegative.val) input_x0.val input_x1.val input_x2.val + input_x3.val input_x4.val input_y0.val input_y1.val input_y2.val input_y3.val).2.2.1 + + 65536 * (ShiftCore.shifted input_direction.val input_ls0.val input_ls1.val + input_ls2.val (65535 * input_isNegative.val) input_x0.val input_x1.val input_x2.val + input_x3.val input_x4.val input_y0.val input_y1.val input_y2.val input_y3.val).2.2.2 : ℕ) : F p) := by + rw [← hout1, ZMod.natCast_zmod_val] + -- field forms of the naturals + have hdc := (ZMod.natCast_zmod_val input_direction).symm + have hl0c := (ZMod.natCast_zmod_val input_ls0).symm + have hl1c := (ZMod.natCast_zmod_val input_ls1).symm + have hl2c := (ZMod.natCast_zmod_val input_ls2).symm + have hnc := (ZMod.natCast_zmod_val input_isNegative).symm + have hx0c := (ZMod.natCast_zmod_val input_x0).symm + have hx1c := (ZMod.natCast_zmod_val input_x1).symm + have hx2c := (ZMod.natCast_zmod_val input_x2).symm + have hx3c := (ZMod.natCast_zmod_val input_x3).symm + have hx4c := (ZMod.natCast_zmod_val input_x4).symm + have hy0c := (ZMod.natCast_zmod_val input_y0).symm + have hy1c := (ZMod.natCast_zmod_val input_y1).symm + have hy2c := (ZMod.natCast_zmod_val input_y2).symm + have hy3c := (ZMod.natCast_zmod_val input_y3).symm + have hiff : input_zbs = 1 → input_bitShift.val = 0 := hzb_iff.mp + have hl3b : IsBool (1 - input_ls0 - input_ls1 - input_ls2) := by + rcases hl0b with h0 | h0 <;> rcases hl1b with h1 | h1 <;> rcases hl2b with h2 | h2 <;> + simp only [h0, h1, h2, ZMod.val_zero, val_one_eq] at honehot ⊢ <;> + first | omega | norm_num [IsBool] + refine ⟨by simp, override_x hzb hdb hiff hx0, override_x hzb hdb hiff hx1, + override_x hzb hdb hiff hx2, override_x hzb hdb hiff hx3, ?_, + override_y hzb hdb hiff hy0, override_y hzb hdb hiff hy1, override_y hzb hdb hiff hy2, + override_y hzb hdb hiff hy3, mul_one_sub_eq_zero_iff.mpr hl0b, + mul_one_sub_eq_zero_iff.mpr hl1b, mul_one_sub_eq_zero_iff.mpr hl2b, mul_one_sub_eq_zero_iff.mpr hl3b, ?_, ?_, + mul_one_sub_eq_zero_iff.mpr hdb, mul_one_sub_eq_zero_iff.mpr hsb, mul_one_sub_eq_zero_iff.mpr hwb, + mul_one_sub_eq_zero_iff.mpr hzb, by simp, ?_, + ?_, ?_, ?_, fun _ => ⟨by omega, hzbs⟩, ?_, ?_, ?_, ?_, ?_, ?_, ⟨hsA, hB1⟩, fun _ => hH1, + fun _ => hi0, fun _ => hi1, fun _ => hi2, fun _ => hi3⟩ + · -- zbs · X[4] = 0 + rcases hzb with hz | hz + · rw [hz, zero_mul] + · rw [ite_eq_left (hiff hz)] at hx4 + rw [hz, one_mul, (ZMod.val_eq_zero _).mp hx4] + · -- out[0] + rw [eval_shiftedPoly_1, eval_shiftedPoly_2] + simp only [circuit_norm, h_input] + rw [hdc, hl0c, hl1c, hl2c, hnc, hx0c, hx1c, hx2c, hx3c, hx4c, hy0c, hy1c, hy2c, hy3c, + show (65535 : F p) * ((input_isNegative.val : ℕ) : F p) + = ((65535 * input_isNegative.val : ℕ) : F p) by push_cast; ring, hc1, hc2, hout0'] + push_cast; ring + · -- out[1] + rw [eval_shiftedPoly_3, eval_shiftedPoly_4] + simp only [circuit_norm, h_input] + rw [hdc, hl0c, hl1c, hl2c, hnc, hx0c, hx1c, hx2c, hx3c, hx4c, hy0c, hy1c, hy2c, hy3c, + show (65535 : F p) * ((input_isNegative.val : ℕ) : F p) + = ((65535 * input_isNegative.val : ℕ) : F p) by push_cast; ring, hc3, hc4, hout1'] + push_cast; ring + · -- (1 − signed) · is_negative = 0 + rcases hsb with hs | hs + · rw [hs] at hn ⊢ + simp only [ZMod.val_zero, zero_ne_one, ite_false] at hn + rw [(ZMod.val_eq_zero _).mp hn]; ring + · rw [hs]; ring + · -- MSB16[in[3]] when signed + intro hs1 + rw [hs1, val_one_eq, ite_eq_left rfl] at hn + exact ⟨hi3, hn⟩ + · -- BYTE_ALU[AND, shift, 15] when left + intro h + have hd0 : input_direction = 0 := by linear_combination -h + rw [hd0, ZMod.val_zero, ite_eq_left rfl] at hb + refine ⟨hsA, by rw [h15]; norm_num, Or.inl ?_⟩ + rw [h15, ShiftCore.and15, hb] + · -- BYTE_ALU[AND, 256 − 16·zbs − shift, 15] when right + intro hd1 + rw [hd1, val_one_eq, ite_eq_right one_ne_zero] at hb + rcases hzb with hz | hz + · have hbne : input_bitShift.val ≠ 0 := fun h0 => by + rw [hzbs, ite_eq_left ((ZMod.val_eq_zero _).mp h0)] at hz; exact one_ne_zero hz + have hs1 : 1 ≤ input_shiftAmount.val := by omega + have hcast : (256 : F p) - 16 * input_zbs - input_shiftAmount + = ((256 - input_shiftAmount.val : ℕ) : F p) := by + rw [hz, Nat.cast_sub (by omega)]; push_cast + rw [ZMod.natCast_zmod_val input_shiftAmount]; ring + rw [hcast, val_natCast_of_lt_two_pow_40 (by omega), h15, ShiftCore.and15, hb] + exact ⟨by omega, by norm_num, Or.inl (by omega)⟩ + · have hb0 : input_bitShift.val = 0 := hiff hz + have hle : input_shiftAmount.val ≤ 240 := by omega + have hcast : (256 : F p) - 16 * input_zbs - input_shiftAmount + = ((240 - input_shiftAmount.val : ℕ) : F p) := by + rw [hz, Nat.cast_sub hle]; push_cast + rw [ZMod.natCast_zmod_val input_shiftAmount]; ring + rw [hcast, val_natCast_of_lt_two_pow_40 (by omega), h15, ShiftCore.and15, hb0] + exact ⟨by omega, by norm_num, Or.inl (by omega)⟩ + · -- HWSL[in[0], bit_shift] + intro h + have hbne : input_bitShift.val ≠ 0 := fun h0 => by + have := hzb_iff.mpr h0 + rw [this] at h; norm_num at h + rw [ite_eq_right hbne] at hx0 hy0 + exact ⟨hi0, hb16, by rw [hx0]; exact sll_eq hi0, by rw [hy0]; exact sllc_eq hi0⟩ + · intro h + have hbne : input_bitShift.val ≠ 0 := fun h0 => by + have := hzb_iff.mpr h0 + rw [this] at h; norm_num at h + rw [ite_eq_right hbne] at hx1 hy1 + exact ⟨hi1, hb16, by rw [hx1]; exact sll_eq hi1, by rw [hy1]; exact sllc_eq hi1⟩ + · intro h + have hbne : input_bitShift.val ≠ 0 := fun h0 => by + have := hzb_iff.mpr h0 + rw [this] at h; norm_num at h + rw [ite_eq_right hbne] at hx2 hy2 + exact ⟨hi2, hb16, by rw [hx2]; exact sll_eq hi2, by rw [hy2]; exact sllc_eq hi2⟩ + · intro h + have hbne : input_bitShift.val ≠ 0 := fun h0 => by + have := hzb_iff.mpr h0 + rw [this] at h; norm_num at h + rw [ite_eq_right hbne] at hx3 hy3 + exact ⟨hi3, hb16, by rw [hx3]; exact sll_eq hi3, by rw [hy3]; exact sllc_eq hi3⟩ + · -- HWSL[extension, bit_shift] + intro h + have hbne : input_bitShift.val ≠ 0 := fun h0 => by + have := hzb_iff.mpr h0 + rw [this] at h; norm_num at h + rw [ite_eq_right hbne] at hx4 + have he : 65535 * input_isNegative.val = 0 ∨ 65535 * input_isNegative.val = 65535 := by omega + obtain ⟨hle, hsub⟩ := ext_sllc he hb16 + have hdiff : (65535 * input_isNegative - input_x4).val + = 65535 * input_isNegative.val - input_x4.val := by + rw [← hx4] at hle + rw [show (65535 : F p) * input_isNegative - input_x4 + = ((65535 * input_isNegative.val - input_x4.val : ℕ) : F p) by + rw [Nat.cast_sub hle]; push_cast + rw [ZMod.natCast_zmod_val input_isNegative, ZMod.natCast_zmod_val input_x4]] + exact val_natCast_of_lt_two_pow_40 (by omega) + refine ⟨by rw [hext]; omega, hb16, ?_, ?_⟩ + · rw [hext, hx4]; exact sll_eq (by omega) + · rw [hdiff, hext, hx4, hsub]; exact sllc_eq (by omega) + · -- BYTE_ALU[AND, shift, mask] + intro _ + have hmask := mask_val hwb + refine ⟨hsA, by rw [hmask]; omega, Or.inl ?_⟩ + rw [hmask] + rw [ShiftCore.and_mask (w := input_wordInstr.val) hsA (by omega)] + rw [eq_natCast_of_val hl0, eq_natCast_of_val hl1, eq_natCast_of_val hl2] + rcases (by omega : input_shiftAmount.val / 16 % (4 - 2 * input_wordInstr.val) = 0 ∨ + input_shiftAmount.val / 16 % (4 - 2 * input_wordInstr.val) = 1 ∨ + input_shiftAmount.val / 16 % (4 - 2 * input_wordInstr.val) = 2 ∨ + input_shiftAmount.val / 16 % (4 - 2 * input_wordInstr.val) = 3) with hLv | hLv | hLv | hLv + · rw [hLv]; norm_num + · rw [hLv]; norm_num; exact val_ofNat 16 (by norm_num) + · rw [hLv]; norm_num; exact val_ofNat 32 (by norm_num) + · rw [hLv]; norm_num; exact val_ofNat 48 (by norm_num) + · -- a padding row + subst hmu hd hs hw hz hneg hx0 hx1 hx2 hx3 hx4 hy0 hy1 hy2 hy3 hl0 hl1 hl2 hout0 hout1 hsA hB1 + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> + · try simp only [eval_shiftedPoly_1, eval_shiftedPoly_2, eval_shiftedPoly_3, eval_shiftedPoly_4] + simp [circuit_norm, h_input, shiftedPoly] + + +def circuit : GeneralFormalCircuit (F p) Row unit where + name := "SHIFT" + main + elaborated + Spec r _ _ := RowSpec r + channelsWithRequirements := [Alu.channel.toRaw] + requirementsChannelsLawful input_var i₀ := by + obtain ⟨in0, in1, in2, in3, shiftAmount, direction, signed, wordInstr, out0, out1, isNegative, + bitShift, zbs, x0, x1, x2, x3, x4, y0, y1, y2, y3, ls0, ls1, ls2, mu, shiftB1, shiftH1, + shiftHigh⟩ := input_var + simp only [circuit_norm, main, isBit, Alu.channel, Bitwise.isHalfTable, Bitwise.msb16Table, + Bitwise.byteAluTable, opselAND, opselOR, opselXOR, Bitwise.zeroTable, Bitwise.hwslTable, Bitwise.areBytesTable] + constructor + · intro channel h; tauto + · intro env h + obtain ⟨h_dm, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, h_dir, h_sg, -, h_zbs, h_mu, -⟩ := h + have hdb := mul_one_sub_eq_zero_iff.mp h_dir + have hsb := mul_one_sub_eq_zero_iff.mp h_sg + have hzb := mul_one_sub_eq_zero_iff.mp h_zbs + have hmb := mul_one_sub_eq_zero_iff.mp h_mu + -- each pull owes a multiplicity of 0 or 1 + constructorm* _ ∧ _ <;> + rcases hmb with hm | hm <;> rcases hdb with hd | hd <;> rcases hzb with hz | hz <;> + rcases hsb with hs | hs <;> simp_all + + soundness := soundness + ProverAssumptions r _ _ := Honest r ∨ Padding r + + completeness := completeness + +end LambdaVM.SHIFT diff --git a/formal/LambdaVM/Tables/ShiftCore.lean b/formal/LambdaVM/Tables/ShiftCore.lean new file mode 100644 index 000000000..ee5adab07 --- /dev/null +++ b/formal/LambdaVM/Tables/ShiftCore.lean @@ -0,0 +1,216 @@ +module + +public import LambdaVM.Buses.Alu +public import LambdaVM.Tables.Bitwise + +@[expose] public section + +/-! +# The arithmetic of the SHIFT chip, on naturals + +`spec/src/shift.toml` shifts in two phases: by `bit_shift < 16` bits inside each 16-bit limb using +the `HWSL` lookup, then by whole limbs using the one-hot `limb_shift`. These lemmas prove that +the limb recombination the chip constrains equals the shift of the 64-bit value. +-/ + +namespace LambdaVM.ShiftCore +open Alu (shiftResult sra64) +open Bitwise (sll sllc) + +/-- The 64-bit value of four 16-bit limbs. -/ +def limbs (a0 a1 a2 a3 : ℕ) : ℕ := a0 + 65536 * a1 + 2^32 * a2 + 2^48 * a3 + +theorem and15 (s : ℕ) : s &&& 15 = s % 16 := by + have := Nat.and_two_pow_sub_one_eq_mod s 4 + norm_num at this + exact this + +theorem and48 {s : ℕ} (hs : s < 256) : s &&& 48 = 16 * (s / 16 % 4) := by + interval_cases s <;> decide + +theorem and16 {s : ℕ} (hs : s < 256) : s &&& 16 = 16 * (s / 16 % 2) := by + interval_cases s <;> decide + +/-- The `limb_shift` mask `48 − 32·w` picks the limb index of the shift amount. -/ +theorem and_mask {s w : ℕ} (hs : s < 256) (hw : w < 2) : + s &&& (48 - 32 * w) = 16 * (s / 16 % (4 - 2 * w)) := by + rcases (by omega : w = 0 ∨ w = 1) with rfl | rfl + · simpa using and48 hs + · simpa using and16 hs + +/-- The shift amount reduced mod 32 or 64, split into limb index and bit shift. -/ +theorem mod_word {s w : ℕ} (hw : w < 2) : + s % (if w = 1 then 32 else 64) = 16 * (s / 16 % (4 - 2 * w)) + s % 16 := by + rcases (by omega : w = 0 ∨ w = 1) with rfl | rfl <;> simp <;> omega + +/-- Left shift: phase 1 (`bit_shift = b`) and phase 2 (`limb_shift = L`) together. -/ +theorem leftShift {i0 i1 i2 i3 b L : ℕ} + (h0 : i0 < 65536) (h1 : i1 < 65536) (h2 : i2 < 65536) (h3 : i3 < 65536) + (hb : b < 16) (hL : L < 4) : + let il0 := sll i0 b + let il1 := sll i1 b + sllc i0 b + let il2 := sll i2 b + sllc i1 b + let il3 := sll i3 b + sllc i2 b + let sh0 := if L = 0 then il0 else 0 + let sh1 := if L = 0 then il1 else if L = 1 then il0 else 0 + let sh2 := if L = 0 then il2 else if L = 1 then il1 else if L = 2 then il0 else 0 + let sh3 := if L = 0 then il3 else if L = 1 then il2 else if L = 2 then il1 else il0 + sh0 < 65536 ∧ sh1 < 65536 ∧ sh2 < 65536 ∧ sh3 < 65536 ∧ + limbs sh0 sh1 sh2 sh3 = (limbs i0 i1 i2 i3 <<< (16 * L + b)) % 2^64 := by + intro il0 il1 il2 il3 sh0 sh1 sh2 sh3 + simp only [il0, il1, il2, il3, sh0, sh1, sh2, sh3, limbs, sll, sllc, Nat.shiftLeft_eq, + Nat.shiftRight_eq_div_pow] + interval_cases b <;> interval_cases L <;> norm_num <;> omega + +/-- Right shift, phase 1: `bit_shift = b = (16 − r) mod 16` turns the limbs of `in` (plus one +extension limb `e` above) into the limbs of `in >> r`. -/ +theorem rightIntra {i0 i1 i2 i3 r b e : ℕ} + (h0 : i0 < 65536) (h1 : i1 < 65536) (h2 : i2 < 65536) (h3 : i3 < 65536) + (hr : r < 16) (hb : b = (16 - r) % 16) (he : e = 0 ∨ e = 65535) : + let xi (h : ℕ) := if b = 0 then 0 else sll h b + let yi (h : ℕ) := if b = 0 then h else sllc h b + let x4 := if b = 0 then 0 else sll e b + let ir0 := yi i0 + xi i1 + let ir1 := yi i1 + xi i2 + let ir2 := yi i2 + xi i3 + let ir3 := yi i3 + x4 + ir0 < 65536 ∧ ir1 < 65536 ∧ ir2 < 65536 ∧ ir3 < 65536 ∧ + limbs ir0 ir1 ir2 ir3 = ((limbs i0 i1 i2 i3 + e * 2^64) >>> r) % 2^64 := by + intro xi yi x4 ir0 ir1 ir2 ir3 + simp only [xi, yi, x4, ir0, ir1, ir2, ir3, limbs, sll, sllc, Nat.shiftLeft_eq, + Nat.shiftRight_eq_div_pow] + rcases he with rfl | rfl <;> interval_cases r <;> norm_num at hb <;> subst hb <;> norm_num <;> omega + +/-- Right shift, phase 2: `limb_shift = L` moves whole limbs, filling with `e`. -/ +theorem rightLimb {a0 a1 a2 a3 L e : ℕ} + (h0 : a0 < 65536) (h1 : a1 < 65536) (h2 : a2 < 65536) (h3 : a3 < 65536) + (hL : L < 4) (he : e = 0 ∨ e = 65535) : + let sh0 := if L = 0 then a0 else if L = 1 then a1 else if L = 2 then a2 else a3 + let sh1 := if L = 0 then a1 else if L = 1 then a2 else if L = 2 then a3 else e + let sh2 := if L = 0 then a2 else if L = 1 then a3 else e + let sh3 := if L = 0 then a3 else e + sh0 < 65536 ∧ sh1 < 65536 ∧ sh2 < 65536 ∧ sh3 < 65536 ∧ + limbs sh0 sh1 sh2 sh3 + = ((limbs a0 a1 a2 a3 + e * (2^64 + 2^80 + 2^96)) >>> (16 * L)) % 2^64 := by + intro sh0 sh1 sh2 sh3 + simp only [sh0, sh1, sh2, sh3, limbs, Nat.shiftRight_eq_div_pow] + rcases he with rfl | rfl <;> interval_cases L <;> norm_num <;> omega + +/-- The two phases compose into one shift of a 128-bit sign-extended value. -/ +theorem rightCompose {X r L e : ℕ} (hX : X < 2^64) (hr : r < 16) (hL : L < 4) + (he : e = 0 ∨ e = 65535) : + ((((X + e * 2^64) >>> r) % 2^64 + e * (2^64 + 2^80 + 2^96)) >>> (16 * L)) % 2^64 + = ((X + e * (2^64 + 2^80 + 2^96 + 2^112)) >>> (16 * L + r)) % 2^64 := by + simp only [Nat.shiftRight_eq_div_pow] + rcases he with rfl | rfl <;> interval_cases r <;> interval_cases L <;> norm_num <;> omega + +/-- The `shifted` limbs exactly as the row polynomial reads them, on naturals: +`d` is `direction`, `l0 l1 l2` the stored one-hot limbs, `e` the extension limb. -/ +def shifted (d l0 l1 l2 e x0 x1 x2 x3 x4 y0 y1 y2 y3 : ℕ) : ℕ × ℕ × ℕ × ℕ := + let l3 := 1 - l0 - l1 - l2 + let left := 1 - d + let right := d + let il0 := x0 + let il1 := x1 + y0 + let il2 := x2 + y1 + let il3 := x3 + y2 + let ir0 := y0 + x1 + let ir1 := y1 + x2 + let ir2 := y2 + x3 + let ir3 := y3 + x4 + (left * (l0 * il0) + right * (l0 * ir0 + l1 * ir1 + l2 * ir2 + l3 * ir3), + left * (l0 * il1 + l1 * il0) + right * (l0 * ir1 + l1 * ir2 + l2 * ir3 + e * l3), + left * (l0 * il2 + l1 * il1 + l2 * il0) + right * (l0 * ir2 + l1 * ir3 + e * (l2 + l3)), + left * (l0 * il3 + l1 * il2 + l2 * il1 + l3 * il0) + right * (l0 * ir3 + e * (l1 + l2 + l3))) + +/-- The chip's arithmetic: from the decoded `bit_shift`, the one-hot `limb_shift`, the sign bit +and the HWSL outputs (or their `zbs` overrides), the recombined limbs are the shift result. -/ +theorem main {d sg w s i0 i1 i2 i3 l0 l1 l2 b n x0 x1 x2 x3 x4 y0 y1 y2 y3 : ℕ} + (hd : d < 2) (hsg : sg < 2) (hw : w < 2) (hs : s < 256) + (h0 : i0 < 65536) (h1 : i1 < 65536) (h2 : i2 < 65536) (h3 : i3 < 65536) + (hl0 : l0 < 2) (hl1 : l1 < 2) (hl2 : l2 < 2) (hl : l0 + l1 + l2 ≤ 1) + (hL : 16 * (l1 + 2 * l2 + 3 * (1 - l0 - l1 - l2)) = s &&& (48 - 32 * w)) + (hb : b = if d = 0 then s % 16 else (16 - s % 16) % 16) + (hn : n = if sg = 1 then i3 / 32768 else 0) + (hx0 : x0 = if b = 0 then (if d = 0 then i0 else 0) else sll i0 b) + (hx1 : x1 = if b = 0 then (if d = 0 then i1 else 0) else sll i1 b) + (hx2 : x2 = if b = 0 then (if d = 0 then i2 else 0) else sll i2 b) + (hx3 : x3 = if b = 0 then (if d = 0 then i3 else 0) else sll i3 b) + (hx4 : x4 = if b = 0 then 0 else sll (65535 * n) b) + (hy0 : y0 = if b = 0 then (if d = 0 then 0 else i0) else sllc i0 b) + (hy1 : y1 = if b = 0 then (if d = 0 then 0 else i1) else sllc i1 b) + (hy2 : y2 = if b = 0 then (if d = 0 then 0 else i2) else sllc i2 b) + (hy3 : y3 = if b = 0 then (if d = 0 then 0 else i3) else sllc i3 b) : + let sh := shifted d l0 l1 l2 (65535 * n) x0 x1 x2 x3 x4 y0 y1 y2 y3 + sh.1 < 65536 ∧ sh.2.1 < 65536 ∧ sh.2.2.1 < 65536 ∧ sh.2.2.2 < 65536 ∧ + limbs sh.1 sh.2.1 sh.2.2.1 sh.2.2.2 = shiftResult w sg d (limbs i0 i1 i2 i3) s := by + intro sh + -- the one-hot index and the shift amount + rw [and_mask hs hw] at hL + have hn2 : n < 2 := by rw [hn]; split_ifs <;> omega + have he : 65535 * n = 0 ∨ 65535 * n = 65535 := by omega + have hX : limbs i0 i1 i2 i3 < 2^64 := by unfold limbs; omega + rcases (by omega : d = 0 ∨ d = 1) with rfl | rfl + · -- left shift: `shifted` is the if-form of `leftShift` with `L` the one-hot index + simp only [ite_true] at hb + subst hb + have hb16 : s % 16 < 16 := Nat.mod_lt _ (by norm_num) + have core := leftShift h0 h1 h2 h3 hb16 (L := l1 + 2 * l2 + 3 * (1 - l0 - l1 - l2)) (by omega) + simp only at core + have hk := mod_word (s := s) hw + have hLv : s / 16 % (4 - 2 * w) = l1 + 2 * l2 + 3 * (1 - l0 - l1 - l2) := by omega + rcases (by omega : (l0 = 1 ∧ l1 = 0 ∧ l2 = 0) ∨ (l0 = 0 ∧ l1 = 1 ∧ l2 = 0) ∨ + (l0 = 0 ∧ l1 = 0 ∧ l2 = 1) ∨ (l0 = 0 ∧ l1 = 0 ∧ l2 = 0)) with + ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl⟩ <;> + · simp only [shifted, sh, hx0, hx1, hx2, hx3, hx4, hy0, hy1, hy2, hy3] + norm_num at core hLv ⊢ + simp only [shiftResult, ite_true] + rw [hk, hLv] + norm_num at core ⊢ + by_cases hz : s % 16 = 0 + · simpa [sll, sllc, hz] using core + · simpa [sll, sllc, hz] using core + · -- right shift: phase 1, phase 2, and their composition + simp only [one_ne_zero, ite_false] at hb + have hr : s % 16 < 16 := Nat.mod_lt _ (by norm_num) + have p1 := rightIntra h0 h1 h2 h3 hr hb he + simp only at p1 + obtain ⟨hr0, hr1, hr2, hr3, hir⟩ := p1 + have p2 := rightLimb hr0 hr1 hr2 hr3 (L := l1 + 2 * l2 + 3 * (1 - l0 - l1 - l2)) (by omega) he + simp only at p2 + obtain ⟨hs0, hs1, hs2, hs3, hsh⟩ := p2 + rw [hir, rightCompose hX hr (by omega) he] at hsh + have hk := mod_word (s := s) hw + -- the result as the shift of the sign-extended value + have hres : shiftResult w sg 1 (limbs i0 i1 i2 i3) s + = ((limbs i0 i1 i2 i3 + 65535 * n * (2^64 + 2^80 + 2^96 + 2^112)) + >>> (16 * (s / 16 % (4 - 2 * w)) + s % 16)) % 2^64 := by + simp only [shiftResult, one_ne_zero, ite_false] + rw [hk] + have hX63 : limbs i0 i1 i2 i3 < 2^63 ↔ i3 < 32768 := by unfold limbs; omega + rcases (by omega : sg = 0 ∨ sg = 1) with rfl | rfl + · simp only [ite_true, zero_ne_one, ite_false] at hn ⊢ + subst hn + simp only [mul_zero, zero_mul, add_zero] + rw [Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.shiftRight_le _ _) hX)] + · simp only [ite_true, one_ne_zero, ite_false] at hn ⊢ + subst hn + rcases (by omega : i3 / 32768 = 0 ∨ i3 / 32768 = 1) with h | h + · have hlt : limbs i0 i1 i2 i3 < 2^63 := hX63.mpr (by omega) + rw [h]; simp only [mul_zero, zero_mul, add_zero, sra64, ite_eq_left hlt] + rw [Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.shiftRight_le _ _) hX)] + · have hge : ¬ limbs i0 i1 i2 i3 < 2^63 := by rw [hX63]; omega + rw [h]; simp only [sra64, ite_eq_right hge] + norm_num + rw [hres] + have hLv : s / 16 % (4 - 2 * w) = l1 + 2 * l2 + 3 * (1 - l0 - l1 - l2) := by omega + rw [hLv] + rcases (by omega : (l0 = 1 ∧ l1 = 0 ∧ l2 = 0) ∨ (l0 = 0 ∧ l1 = 1 ∧ l2 = 0) ∨ + (l0 = 0 ∧ l1 = 0 ∧ l2 = 1) ∨ (l0 = 0 ∧ l1 = 0 ∧ l2 = 0)) with + ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl⟩ <;> + · simp only [shifted, sh, hx0, hx1, hx2, hx3, hx4, hy0, hy1, hy2, hy3] + norm_num at hs0 hs1 hs2 hs3 hsh + refine ⟨?_, ?_, ?_, ?_, ?_⟩ <;> + first | (norm_num; done) | (norm_num; assumption) + +end LambdaVM.ShiftCore diff --git a/formal/LambdaVM/Templates/Add.lean b/formal/LambdaVM/Templates/Add.lean new file mode 100644 index 000000000..64d981d52 --- /dev/null +++ b/formal/LambdaVM/Templates/Add.lean @@ -0,0 +1,162 @@ +module + +public import LambdaVM.Templates.IsBit +public import Mathlib.Tactic.LinearCombination + +@[expose] public section + +/-! +# ADD and SUB (spec/src/add.toml) + +Constraint templates on `DWordWL` operands. `ADD = sum` has two virtual +carries, `carry[0] = 2⁻³²·(lhs[0] + rhs[0] − sum[0])` and +`carry[1] = 2⁻³²·(lhs[1] + rhs[1] + carry[0] − sum[1])`, and applies `IS_BIT` to both. +`SUB = diff` is `ADD = lhs`. Chips use the unconditional forms +`add` and `sub` (`emit_add_pair` in the prover) and read the carries on naturals through +`Add.carries_lift` and `Add.carries_of_sum`; `Add.circuit` is the general template with its +meaning proven. +-/ + +namespace LambdaVM + +/-- A 64-bit operand as `(lo, hi)` 32-bit words. -/ +structure DWordWL (F : Type) where + lo : F + hi : F +deriving ProvableStruct + +namespace Add + +variable (lhs rhs sum : DWordWL (Expression (F p))) + +/-- `carry[0]` of `lhs + rhs = sum`. -/ +def carry0 : Expression (F p) := (lhs.lo + rhs.lo - sum.lo) * inv32 + +/-- `carry[1]` of `lhs + rhs = sum`. -/ +def carry1 : Expression (F p) := (lhs.hi + rhs.hi + carry0 lhs rhs sum - sum.hi) * inv32 + +end Add + +/-- `ADD<1; lhs, rhs> = sum`: both carries are bits. -/ +@[circuit_norm] +def add (lhs rhs sum : DWordWL (Expression (F p))) : Circuit (F p) Unit := do + isBit (Add.carry0 lhs rhs sum) + isBit (Add.carry1 lhs rhs sum) + +/-- `SUB<1; lhs, rhs> = diff`, as `ADD<1; rhs, diff> = lhs`. -/ +@[circuit_norm] +def sub (lhs rhs diff : DWordWL (Expression (F p))) : Circuit (F p) Unit := add rhs diff lhs + +-- Circuit inference does not unfold user wrappers; bridge them to their bodies. +instance (lhs rhs sum : DWordWL (Expression (F p))) : ExplicitCircuit (add lhs rhs sum) := + .of_eq (circuit' := do isBit (Add.carry0 lhs rhs sum); isBit (Add.carry1 lhs rhs sum)) rfl + (by infer_explicit_circuit) + +instance (lhs rhs diff : DWordWL (Expression (F p))) : ExplicitCircuit (sub lhs rhs diff) := + inferInstanceAs (ExplicitCircuit (add rhs diff lhs)) + +namespace Add + +/-! ## The carries, read on naturals -/ + +/-- Both carry constraints lifted: with every word in range and both carries bits, +`lhs + rhs = sum` limb by limb. `c₀`, `c₁` are the carry expressions evaluated on a row. -/ +lemma carries_lift {l0 l1 r0 r1 s0 s1 c0 c1 : F p} + (hl0 : l0.val < 2^32) (hl1 : l1.val < 2^32) (hr0 : r0.val < 2^32) (hr1 : r1.val < 2^32) + (hs0 : s0.val < 2^32) (hs1 : s1.val < 2^32) + (hc0 : c0 = (l0 + r0 - s0) * inv32) (hc1 : c1 = (l1 + r1 + c0 - s1) * inv32) + (hb0 : IsBool c0) (hb1 : IsBool c1) : + l0.val + r0.val = s0.val + c0.val * 2^32 ∧ + l1.val + r1.val + c0.val = s1.val + c1.val * 2^32 := by + have hc0_2 := IsBool.val_lt_two hb0 + have hval_lo : (l0 + r0).val = l0.val + r0.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have hval_hi : (l1 + r1 + c0).val = l1.val + r1.val + c0.val := + val_eq_of_eq_natCast (by push_cast; simp only [ZMod.natCast_zmod_val]) (by omega) + have e0 := carry_lift (by omega) (by omega) hb0 hc0 + have e1 := carry_lift (by omega) (by omega) hb1 hc1 + rw [hval_lo] at e0 + rw [hval_hi] at e1 + exact ⟨e0, e1⟩ + +/-- The honest carries: when `lhs + rhs = sum (mod 2⁶⁴)` on words in range, the carry +expressions are the bits `k₀`, `k₁` of the limb-wise addition. -/ +lemma carries_of_sum {l0 l1 r0 r1 s0 s1 : F p} + (hl0 : l0.val < 2^32) (hl1 : l1.val < 2^32) (hr0 : r0.val < 2^32) (hr1 : r1.val < 2^32) + (hs0 : s0.val < 2^32) (hs1 : s1.val < 2^32) + (hsum : (dword l0 l1 + dword r0 r1) % 2^64 = dword s0 s1) : + ∃ k0 k1 : ℕ, k0 < 2 ∧ k1 < 2 ∧ + l0.val + r0.val = s0.val + k0 * 2^32 ∧ l1.val + r1.val + k0 = s1.val + k1 * 2^32 ∧ + (l0 + r0 - s0) * inv32 = (k0 : F p) ∧ + (l1 + r1 + (l0 + r0 - s0) * inv32 - s1) * inv32 = (k1 : F p) := by + simp only [dword] at hsum + obtain ⟨k0, hk0, e0⟩ : ∃ k0, k0 < 2 ∧ l0.val + r0.val = s0.val + k0 * 2^32 := + ⟨(l0.val + r0.val) / 2^32, by omega, by omega⟩ + obtain ⟨k1, hk1, e1⟩ : ∃ k1, k1 < 2 ∧ l1.val + r1.val + k0 = s1.val + k1 * 2^32 := + ⟨(l1.val + r1.val + k0) / 2^32, by omega, by omega⟩ + have hc0k : (l0 + r0 - s0) * inv32 = (k0 : F p) := by + have h := congrArg (fun n : ℕ => (n : F p)) e0 + push_cast at h + simp only [ZMod.natCast_zmod_val] at h + have h' : l0 + r0 - s0 = (k0 : F p) * 2^32 := by linear_combination h + rw [h', mul_assoc, two_pow_mul_inv32, mul_one] + have hc1k : (l1 + r1 + (l0 + r0 - s0) * inv32 - s1) * inv32 = (k1 : F p) := by + have h := congrArg (fun n : ℕ => (n : F p)) e1 + push_cast at h + simp only [ZMod.natCast_zmod_val] at h + have h' : l1 + r1 + (l0 + r0 - s0) * inv32 - s1 = (k1 : F p) * 2^32 := by + rw [hc0k]; linear_combination h + rw [h', mul_assoc, two_pow_mul_inv32, mul_one] + exact ⟨k0, k1, hk0, hk1, e0, e1, hc0k, hc1k⟩ + +/-! ## The template with its condition -/ + +structure Inputs (F : Type) where + cond : F + lhs : DWordWL F + rhs : DWordWL F + sum : DWordWL F +deriving ProvableStruct + +/-- `IS_BIT` for both carries. -/ +def main (i : Var Inputs (F p)) : Circuit (F p) Unit := do + IsBit.main ⟨i.cond, carry0 i.lhs i.rhs i.sum⟩ + IsBit.main ⟨i.cond, carry1 i.lhs i.rhs i.sum⟩ + +/-- `ADD = sum` on words in range: when `cond ≠ 0`, `sum = lhs + rhs (mod 2⁶⁴)`. -/ +def circuit : FormalAssertion (F p) Inputs where + main + + Assumptions i := + i.lhs.lo.val < 2^32 ∧ i.lhs.hi.val < 2^32 ∧ i.rhs.lo.val < 2^32 ∧ i.rhs.hi.val < 2^32 ∧ + i.sum.lo.val < 2^32 ∧ i.sum.hi.val < 2^32 + + Spec i := + i.cond ≠ 0 → dword i.sum.lo i.sum.hi = (dword i.lhs.lo i.lhs.hi + dword i.rhs.lo i.rhs.hi) % 2^64 + + soundness := by + circuit_proof_start [main, IsBit.main, carry0, carry1, dword] + obtain ⟨hl0, hl1, hr0, hr1, hs0, hs1⟩ := h_assumptions + obtain ⟨h0, h1⟩ := h_holds + intro hcond + rw [mul_assoc, mul_eq_zero] at h0 h1 + have hb0 := mul_one_sub_eq_zero_iff.mp (h0.resolve_left hcond) + have hb1 := mul_one_sub_eq_zero_iff.mp (h1.resolve_left hcond) + obtain ⟨e0, e1⟩ := carries_lift hl0 hl1 hr0 hr1 hs0 hs1 rfl rfl hb0 hb1 + have := IsBool.val_lt_two hb1 + omega + + completeness := by + circuit_proof_start [main, IsBit.main, carry0, carry1, dword] + obtain ⟨hl0, hl1, hr0, hr1, hs0, hs1⟩ := h_assumptions + by_cases hcond : input_cond = 0 + · simp [hcond] + obtain ⟨k0, k1, hk0, hk1, -, -, hc0k, hc1k⟩ := + carries_of_sum hl0 hl1 hr0 hr1 hs0 hs1 (h_spec hcond).symm + refine ⟨?_, ?_⟩ + · rw [hc0k]; rcases (by omega : k0 = 0 ∨ k0 = 1) with rfl | rfl <;> simp + · rw [hc1k]; rcases (by omega : k1 = 0 ∨ k1 = 1) with rfl | rfl <;> simp + +end Add + +end LambdaVM diff --git a/formal/LambdaVM/Templates/IsBit.lean b/formal/LambdaVM/Templates/IsBit.lean new file mode 100644 index 000000000..ad7a47195 --- /dev/null +++ b/formal/LambdaVM/Templates/IsBit.lean @@ -0,0 +1,60 @@ +module + +public import LambdaVM.Field +public import Clean.Gadgets.Boolean + +@[expose] public section + +/-! +# IS_BIT (spec/src/is_bit.toml) + +Constraint template: when `cond ≠ 0`, `X` must lie in `{0, 1}`. +Single constraint: `cond · X · (1 − X) = 0`. Chips use the unconditional form `isBit` +on their flags; `IsBit.circuit` is the general template with its meaning proven. +-/ + +namespace LambdaVM + +/-- `IS_BIT<1, X>`: `x` is a bit. -/ +@[circuit_norm] +def isBit (x : Expression (F p)) : Circuit (F p) Unit := + assertZero (x * (1 - x)) + +-- Circuit inference does not unfold user wrappers; bridge it to its body. +instance (x : Expression (F p)) : ExplicitCircuit (isBit x) := + .of_eq (circuit' := assertZero (x * (1 - x))) rfl (by infer_explicit_circuit) + +namespace IsBit + +structure Inputs (F : Type) where + cond : F + x : F +deriving ProvableStruct + +def main (inputs : Var Inputs (F p)) : Circuit (F p) Unit := + assertZero (inputs.cond * inputs.x * (1 - inputs.x)) + +instance (inputs : Var Inputs (F p)) : ExplicitCircuit (main inputs) := + .of_eq (circuit' := assertZero (inputs.cond * inputs.x * (1 - inputs.x))) rfl + (by infer_explicit_circuit) + +def circuit : FormalAssertion (F p) Inputs where + main + + Spec := fun { cond, x } => cond ≠ 0 → IsBool x + + soundness := by + circuit_proof_start + intro h_cond + rw [mul_assoc, mul_eq_zero] at h_holds + exact mul_one_sub_eq_zero_iff.mp (h_holds.resolve_left h_cond) + + completeness := by + circuit_proof_start + by_cases h_cond : input_cond = 0 + · simp [h_cond] + · rw [mul_assoc, mul_one_sub_eq_zero_iff.mpr (h_spec h_cond), mul_zero] + +end IsBit + +end LambdaVM diff --git a/formal/LambdaVM/Templates/IsByte.lean b/formal/LambdaVM/Templates/IsByte.lean new file mode 100644 index 000000000..234e294a1 --- /dev/null +++ b/formal/LambdaVM/Templates/IsByte.lean @@ -0,0 +1,94 @@ +module + +public import LambdaVM.Tables.Bitwise +public import LambdaVM.Templates.IsBit + +@[expose] public section + +/-! +# IS_BYTE / ARE_BYTES (spec/src/is_byte.toml) + +`IS_BYTE` is one interaction `ARE_BYTES[X, 0]` with multiplicity `cond` (the spec +writes `[0, X]`; the prover's single-byte checks send `[X, 0]`, and this follows the prover); +`ARE_BYTES` is the unconditional two-byte form (the CPU sends it on every row). +Both are helpers a chip expands inline: `cond` is a flag that the chip itself constrains to be +boolean, and a conditional interaction needs that constraint in the same circuit to be lawful. +No chip of this model calls them yet: SHIFT pulls `ARE_BYTES` directly. +-/ + +namespace LambdaVM + +open Bitwise (AreBytes areBytesTable) + +/-- `ARE_BYTES`: both `x` and `y` are bytes. -/ +@[circuit_norm] +def areBytes (x y : Expression (F p)) : Circuit (F p) Unit := + AreBytes.pull (x, y) + +/-- `IS_BYTE`: `x` is a byte whenever `cond = 1`. -/ +@[circuit_norm] +def isByte (cond x : Expression (F p)) : Circuit (F p) Unit := + AreBytes.pullIf cond (x, 0) + +-- Circuit inference does not unfold user wrappers; bridge each one to its body. +instance (x y : Expression (F p)) : ExplicitCircuit (areBytes x y) := + .of_eq (circuit' := AreBytes.pull (x, y)) rfl (by infer_explicit_circuit) +instance (cond x : Expression (F p)) : ExplicitCircuit (isByte cond x) := + .of_eq (circuit' := AreBytes.pullIf cond (x, 0)) rfl (by infer_explicit_circuit) + +/-! The two templates as stand-alone assertions, to pin down their meaning. -/ + +namespace AreBytesCheck + +def circuit : FormalAssertion (F p) fieldPair where + main input := do areBytes input.1 input.2 + Spec | (x, y) => x.val < 256 ∧ y.val < 256 + soundness := by + circuit_proof_start [areBytes, areBytesTable] + exact h_holds + completeness := by + circuit_proof_start [areBytes, areBytesTable] + exact h_spec + +end AreBytesCheck + +namespace IsByteCheck + +structure Inputs (F : Type) where + cond : F + x : F +deriving ProvableStruct + +def circuit : FormalAssertion (F p) Inputs where + main inputs := do + -- IS_BIT<1, cond>: in a chip this is one of the chip's own flag constraints + isBit inputs.cond + isByte inputs.cond inputs.x + + Assumptions := fun { cond, .. } => IsBool cond + Spec := fun { cond, x } => cond = 1 → x.val < 256 + + requirementsChannelsLawful input_var i₀ := by + obtain ⟨cond, x⟩ := input_var + simp only [circuit_norm, isByte, isBit, areBytesTable] + intro _ h + rcases mul_eq_zero.mp h with h0 | h1 + · exact Or.inl h0 + · exact Or.inr (sub_eq_zero.mp h1).symm + + soundness := by + circuit_proof_start [isByte, isBit, areBytesTable] + obtain ⟨h_bool, h_pull⟩ := h_holds + rw [mul_eq_zero, sub_eq_zero] at h_bool + rcases h_bool with rfl | h1 + · simp + · subst h1 + simp_all + + completeness := by + circuit_proof_start [isByte, isBit, areBytesTable] + rcases h_assumptions with rfl | rfl <;> simp_all + +end IsByteCheck + +end LambdaVM diff --git a/formal/README.md b/formal/README.md new file mode 100644 index 000000000..b49d7ae71 --- /dev/null +++ b/formal/README.md @@ -0,0 +1,245 @@ +# Lambda VM formal model (Clean / Lean 4) + +Lean 4 project that models the Lambda VM arithmetization in +[Clean](https://github.com/Verified-zkEVM/clean) and proves it against `spec/`. + +What it covers: the AIR tables, the LogUp buses (Clean "channels") and the +semantic specification of each table. What it does not cover: the STARK / +FRI / WHIR prover, the LogUp argument itself, the executor, GPU code. + +## Layout + +- `LambdaVM/Field.lean` — Goldilocks as the base field (`F p`), with the size + facts Clean's gadgets ask for. Primality comes from CompPoly's Pratt certificate. +- `LambdaVM/Templates/` — the constraint templates of the spec as helpers + (`isBit`, `isByte`, `areBytes`, `add`, `sub`), each with a `FormalAssertion` + whose `Spec` is the template's meaning taken from `spec/src/*.toml`: + `IsBit.circuit`, `IsByteCheck.circuit`, `AreBytesCheck.circuit`, `Add.circuit`. + The chips call `isBit`, `add` and `sub`; no chip calls `isByte` or `areBytes` + yet (SHIFT pulls `ARE_BYTES` directly). +- `LambdaVM/AluOp.lean` — the `alu_op` descriptors of `types.rs`, one enumeration + for the `opsel` of BYTE_ALU and the low bits of the ALU flag byte. +- `LambdaVM/StaticLookup.lean` — `StaticLookupChannel`: a table the verifier + knows, given as a list of rows, with `guarantees_iff` relating the list to the + semantic reading of a row, and `toChannel` for the components that read it. + Clean main replaced its own `StaticLookupChannel` by `Air.Flat.Lookup`, whose + rows are witness programs of the row index, so the structure lives here. +- `LambdaVM/Buses/` — the buses that are not static tables. `Alu.lean` is the + unified ALU bus: message layout as in `BusId::Alu` and one `Guarantees` clause + per `opsel` (LT, EQ and SHIFT), each taking as hypotheses the `IS_WORD` + assumptions of its chip's spec (LT: the low words; EQ: all four words; SHIFT: + none). The flag byte is read as a natural, so a chip + pushing with one `opsel` discharges the other clauses by `omega`. +- `LambdaVM/Tables/` — one file per chip. `Bitwise.lean` transcribes the + precomputed row function of `prover/src/tables/bitwise.rs` and defines each bus + the table serves as a `StaticLookupChannel` (read through `toChannel`), with + the semantic `Guarantees` proven equivalent to table membership. `Lt.lean` is + the LT chip: the row circuit has the constraints and interactions of `lt.rs` + (in the spec's order, except the `μ` delta below), `core` is the + arithmetic argument of `spec/src/lt.toml` on naturals, `Honest` is the row + `generate_lt_trace` produces, `RowSpec` is what an active row establishes, and + the `GeneralFormalCircuit` proves that a row that pulls its range checks + satisfies `RowSpec` and pushes a correct ALU result (soundness) and that an + honest row satisfies everything (completeness), for rows with `μ ∈ {0, 1}` + only (see "Known differences"). `Eq.lean` is the EQ chip in the + same shape: the `sub` template, four IS_HALF pulls, a ZERO pull on the sum of + the halves, `res = eq xor invert`; its `μ` is a bit, as in the spec and `eq.rs`. Completeness covers + the honest row and the all-zero padding row. + +- `LambdaVM/Ensembles/` — tables wired together through their channels. + `EqLookup.lean` is the first one: `pushStatic` is the provider side of any + static lookup channel (its row is the vector of multiplicities, the role of + the `μ` columns of BITWISE), and `eqLookup` chains the IS_HALF provider, the + ZERO provider and the EQ chip in dependency order. `eq_rows_correct` states + that, for any witness whose constraints hold and whose channels balance, + every EQ row with `μ = 1` and range-checked operands carries the equality + bit. The ensemble has no ALU consumer yet (the CPU is not modelled), so + balance on the ALU channel forces `μ = 0` on every EQ row and the theorem is + trivially true. That IS_HALF → ZERO → EQ compose is shown by `eqLookup` + itself, which only type-checks as a `SoundEnsemble` because every channel is + finished before the tables that pull from it; the theorem says something + about active rows once a component pulls from ALU. +- `LambdaVM/Tables/ShiftCore.lean` and `Shift.lean` — the SHIFT chip. `ShiftCore` + is the two-phase shift argument of `spec/src/shift.toml` on naturals (HWSL + per limb, then whole limbs, left and right, logical and arithmetic), ending in + `ShiftCore.main`, which takes exactly the facts the row gives (decoded + `bit_shift`, one-hot `limb_shift`, sign bit, HWSL outputs or their `zbs` + overrides) and concludes `shiftResult`. `Shift.lean` mirrors the 22 constraints + and 17 interactions of `shift.rs` and proves soundness and completeness, the + latter for both the honest active row and the padding row. + +## Lessons for big chips (from SHIFT) + +- Precompute the `ElaboratedCircuit` instance (`instance elaborated := by + elaborate_circuit`) and pass it explicitly; without it every proof of a + 39-operation circuit times out at elaboration. +- Keep large row polynomials folded behind a definition (`shiftedPoly`) with a + lemma that pushes `Expression.eval` inside, and bridge to the natural-number + version with one cast lemma. +- State `soundness` and `completeness` as standalone theorems and reference + them from the structure; the structure itself otherwise exceeds the heartbeat + budget while abstracting the proof terms. +- `rw ... at h` closes goals by `rfl`; a following `simp`/`ring` then fails with + "no goals". Guard with `try` where the rewrite may already close the goal. + +## Differential check against the Rust prover + +The Lean circuits are hand transcriptions of `prover/src/tables/*.rs`. The check +that they are the same polynomials and the same bus interactions is mechanical: + +1. `lake env lean --run LambdaVM/Export.lean` writes `export/{lt,eq,shift}.json`: + every `assert` as an expression tree and every `interact` with its channel, + direction, multiplicity and message, variables numbered in Rust column order. + Multiplicities are nonnegative; the direction carries the sign. It also writes + `export/bitwise.json`: the size of the BITWISE table and of every static + lookup channel, and a sample of the table (every `z` with edge bytes, which + includes the last row, and 256 pseudo-random rows) with the precomputed + columns of each row and the message every channel serves there. +2. `prover/src/tests/lean_diff.rs` is the prover test that reads them: + `cargo test -p lambda-vm-prover lean_diff -- --nocapture`. + +For each table the test evaluates the Lean asserts and the Rust `ConstraintSet` +on 64 random rows and matches them as multisets of functions, does the same for +the interactions, and checks that every Lean constraint vanishes on honest +traces from `generate_*_trace`, padding rows included; the Lean-only +constraints of the documented deltas are skipped there. The Rust side of an +interaction is what the verifier enforces: the multiplicity and the LogUp +fingerprint `z − (bus + α·e₀ + α²·e₁ + …)` as `emit_multiplicity` and +`emit_fingerprint` emit them, captured like the constraints and evaluated at +fixed `z` and `α`; the Lean side folds the exported message the same way. +Direction (a Rust sender is Clean's pull), multiplicity and fingerprint are +matched separately. For BITWISE the test checks the table and channel sizes, +compares the sampled rows with `generate_bitwise_row` and each channel's +messages with the fingerprints of the receivers of +`bitwise::bus_interactions()` on the same bus, and checks all 2^20 rows of +`generate_bitwise_row` against a Rust transcription of `Bitwise.row` that the +sampled rows pin to the Lean export. + +The models follow the multiplicity constraints of PR #1016. What `lean_diff` +enforces, on every PR: + +- EQ: 5 constraints and 6 interactions, exact match. +- SHIFT: 22 constraints and 17 interactions, exact match. +- LT: exact match except the two documented deltas: `μ·(1 − μ) = 0` exists + only in Lean, `ARE_BYTES[μ, 0]` with multiplicity one exists only in Rust. + The test pins both by content, and its trace has deduplicated rows (`μ ≥ 2`), + where the Lean-only constraint fails as expected. +- BITWISE: same size, all 2^20 rows, 656 sampled rows and 8 channels (10 Rust + receivers), exact match. + +The check compares polynomials, not zero sets: it caught `μ·(μ − 1)` versus +`μ·(1 − μ)` in EQ, which is why the Lean bit constraints use the spec's form. + +`export/` is a committed artifact; `.github/workflows/formal.yml` builds +`formal/`, re-runs the export and fails if it differs, on every PR that touches +`formal/`. + +## Counted pulls (`μ ∈ [0, 255]`) + +After PR #1016 a deduplicated row pulls its range checks with multiplicity `μ`, +`μ` a byte. Clean's typed channel grants the guarantee to a pull of multiplicity +`1` only, and requires every pull to carry `0` or `1`; any other nonzero +multiplicity is a requirement the row cannot meet. +`LambdaVM/Channels/Counted.lean` is the generalisation: + +- `counted N channel` grants the guarantee to a pull of `1, …, N` and charges + every other nonzero interaction, mirroring `Channel.toRaw`. `pullIf`/`emit` + are the circuit operations, with `ExplicitCircuits` instances so elaboration + works. +- `exists_push_of_pull` and `consistent` are Clean's lemmas for this channel. + Their balance premise is `N · length < char F`. Clean's `BalancedInteractions` + carries no length bound of its own: the bound is the `fits` of the `Balance` + the ensemble is checked against, and reaches soundness as the + `InteractionsFit` premise of `TableSoundness`. For `Balance.logUp`, `fits` is + `count < char F`. +- `not_consistent` shows that Clean's `BalancedInteractions` is too weak a + premise for a counted channel (the field-sum premise of `consistent` cannot be + replaced by it): for `2 ≤ N ≤ 255` + over Goldilocks, one pull of `N` and one pull of `1` on a message outside the + table satisfy `BalancedInteractions` — Clean counts the pull of `N` as a push + of the message, so the pull of `1` is matched — while the counted channel + reads both as pulls and the guarantee of the second is false. So + `RawChannel.Consistent` is false and the channel cannot be finished in a + `SoundEnsemble`. With `N = 1` the channel is `Normal`, as in Clean. +- `Demo.circuit` is the shape of a dedup row: `ARE_BYTES[μ, 0]` then a counted + `IS_HALF` pull with multiplicity `μ`. The counted channel sits in + `channelsWithRequirements`: an out-of-range `μ` is only ruled out by the byte + guarantee, which lawfulness does not see but soundness does. + +What upstream Clean needs for an end-to-end LT theorem with byte `μ`: + +1. A `Balance` for counted pulls: `BalancedInteractions` matching a pull of + `1, …, N`, and a `fits` that bounds `N * count` rather than `count` by the + characteristic. +2. Either a dependency-aware `OrderedChannel` (a table may hold guarantees and + requirements on the same channel when the requirements depend only on + channels finished earlier), or the range check of `μ` as a static `lookup`, + which is a local constraint and makes the requirement vacuous at lawfulness. + +Until then LT keeps `μ ∈ {0, 1}` (see below). + +## What is intentionally not proven + +Scope limits, not bugs. Each is also noted where it applies. + +- **The lookups a row makes are assumed, not proven.** Every chip theorem is + about one row, given that each range check or lookup the row pulls is + answered correctly. Nothing discharges that for the whole system: the only + ensemble theorem, `eq_rows_correct`, is trivially true because no ALU + consumer is modelled, and LT and SHIFT have no ensemble. A negative + multiplicity in an unmodelled table that shares `IS_HALF` (the bug PR #1016 + fixed) leaves every theorem and `lean_diff` green. +- **LT is proven for `μ ∈ {0, 1}` only.** The deduplicated rows `lt.rs` + produces (`μ = 2…255`, present on every real block) are covered by neither + soundness nor completeness. See "Counted pulls" and the next section. +- **The Lean BITWISE table is compared with Rust on 656 sampled rows.** The + loop over all 2^20 rows compares `generate_bitwise_row` with a Rust + transcription of `Bitwise.row`, not with Lean. +- **The meaning side is not checked.** The ALU guarantee has no consumer, + since the CPU is not modelled. "Proved against the spec" means + `spec/main@2eaf1f080`, not the `spec/` copy in this repository. + +## Known differences from the Rust prover + +- `LT` constrains `μ·(1 − μ) = 0`. The spec types `μ` as `Byte` with + `IS_BYTE[μ]` and `lt.rs` sends `ARE_BYTES[μ, 0]`, because LT deduplicates + rows and `μ` is a count. Clean only grants a channel guarantee to a pull with + multiplicity exactly 1, so until the counted pulls above land upstream the + model keeps `μ` a bit. Every chip whose `μ` the spec types as `Byte` (MUL, + DVRM, BRANCH, BYTEWISE) will need the same treatment. +- `isByte` sends `ARE_BYTES[X, 0]`, as every single-byte check in the prover + does; `spec/src/is_byte.toml` writes `[0, X]`. +- The `spec/` copy in this repository lags the `spec/main` branch; the spec the + models follow is that branch at `2eaf1f080` (EQ's `μ` is `Bit` with + `IS_BIT[μ]` there). Constraints are cited from `spec/src/*.toml`, which the + `.typ` pages render. + +## Building + +```sh +# once: Lean toolchain manager +curl https://elan.lean-lang.org/elan-init.sh -sSf | sh + +cd formal +lake exe cache get # clones the pinned dependencies, fetches Mathlib's prebuilt binaries +lake build # also compiles the export script +``` + +Clean itself is compiled from source; only the modules we import are built. + +## Conventions + +- Files use Clean's module header: `module` / `public import ...` / + `@[expose] public section`. +- One table or template per file. `Spec` states the meaning of the rows in + terms of the spec's variables; `Assumptions` are the preconditions the + caller table must establish. +- Proofs start with `circuit_proof_start` (or `circuit_proof_all` when it + closes the goal). See Clean's `AGENTS.md` and `doc/proving-guide.md`. +- Clean's circuit inference does not unfold user-defined `Circuit` helpers. A + helper used inside a `main` needs an `ExplicitCircuit` instance, bridged to + its body with `ExplicitCircuit.of_eq rfl (by infer_explicit_circuit)`. +- A conditional interaction (`pullIf cond`) is only lawful when the same circuit + constrains `cond` to be boolean: Clean requires every pull to carry + multiplicity `0` or `1`, and a pull outside `{0, 1}` is a requirement the + circuit cannot discharge at lawfulness. diff --git a/formal/export/bitwise.json b/formal/export/bitwise.json new file mode 100644 index 000000000..72745d6a5 --- /dev/null +++ b/formal/export/bitwise.json @@ -0,0 +1 @@ +{"channels":[{"channel":"ARE_BYTES","messages":[[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[0,1]],[[1,1]],[[127,1]],[[128,1]],[[255,1]],[[0,127]],[[1,127]],[[127,127]],[[128,127]],[[255,127]],[[0,128]],[[1,128]],[[127,128]],[[128,128]],[[255,128]],[[0,255]],[[1,255]],[[127,255]],[[128,255]],[[255,255]],[[57,48]],[[234,169]],[[155,35]],[[76,157]],[[253,22]],[[174,144]],[[95,10]],[[16,132]],[[193,253]],[[114,119]],[[35,241]],[[212,106]],[[133,228]],[[54,94]],[[231,215]],[[152,81]],[[73,203]],[[250,68]],[[171,190]],[[92,56]],[[13,178]],[[190,43]],[[111,165]],[[32,31]],[[209,152]],[[130,18]],[[51,140]],[[228,5]],[[149,127]],[[70,249]],[[247,114]],[[168,236]],[[89,102]],[[10,224]],[[187,89]],[[108,211]],[[29,77]],[[206,198]],[[127,64]],[[48,186]],[[225,51]],[[146,173]],[[67,39]],[[244,160]],[[165,26]],[[86,148]],[[7,14]],[[184,135]],[[105,1]],[[26,123]],[[203,244]],[[124,110]],[[45,232]],[[222,97]],[[143,219]],[[64,85]],[[241,206]],[[162,72]],[[83,194]],[[4,60]],[[181,181]],[[102,47]],[[23,169]],[[200,34]],[[121,156]],[[42,22]],[[219,143]],[[140,9]],[[61,131]],[[238,252]],[[159,118]],[[80,240]],[[1,106]],[[178,227]],[[99,93]],[[20,215]],[[197,80]],[[118,202]],[[39,68]],[[216,189]],[[137,55]],[[58,177]],[[235,42]],[[156,164]],[[77,30]],[[254,151]],[[175,17]],[[96,139]],[[17,5]],[[194,126]],[[115,248]],[[36,114]],[[213,235]],[[134,101]],[[55,223]],[[232,88]],[[153,210]],[[74,76]],[[251,197]],[[172,63]],[[93,185]],[[14,51]],[[191,172]],[[112,38]],[[33,160]],[[210,25]],[[131,147]],[[52,13]],[[229,134]],[[150,0]],[[71,122]],[[248,243]],[[169,109]],[[90,231]],[[11,97]],[[188,218]],[[109,84]],[[30,206]],[[207,71]],[[128,193]],[[49,59]],[[226,180]],[[147,46]],[[68,168]],[[245,33]],[[166,155]],[[87,21]],[[8,143]],[[185,8]],[[106,130]],[[27,252]],[[204,117]],[[125,239]],[[46,105]],[[223,226]],[[144,92]],[[65,214]],[[242,79]],[[163,201]],[[84,67]],[[5,189]],[[182,54]],[[103,176]],[[24,42]],[[201,163]],[[122,29]],[[43,151]],[[220,16]],[[141,138]],[[62,4]],[[239,125]],[[160,247]],[[81,113]],[[2,235]],[[179,100]],[[100,222]],[[21,88]],[[198,209]],[[119,75]],[[40,197]],[[217,62]],[[138,184]],[[59,50]],[[236,171]],[[157,37]],[[78,159]],[[255,24]],[[176,146]],[[97,12]],[[18,134]],[[195,255]],[[116,121]],[[37,243]],[[214,108]],[[135,230]],[[56,96]],[[233,217]],[[154,83]],[[75,205]],[[252,70]],[[173,192]],[[94,58]],[[15,180]],[[192,45]],[[113,167]],[[34,33]],[[211,154]],[[132,20]],[[53,142]],[[230,7]],[[151,129]],[[72,251]],[[249,116]],[[170,238]],[[91,104]],[[12,226]],[[189,91]],[[110,213]],[[31,79]],[[208,200]],[[129,66]],[[50,188]],[[227,53]],[[148,175]],[[69,41]],[[246,162]],[[167,28]],[[88,150]],[[9,16]],[[186,137]],[[107,3]],[[28,125]],[[205,246]],[[126,112]],[[47,234]],[[224,99]],[[145,221]],[[66,87]],[[243,208]],[[164,74]],[[85,196]],[[6,62]],[[183,183]],[[104,49]],[[25,171]],[[202,36]],[[123,158]],[[44,24]],[[221,145]],[[142,11]],[[63,133]],[[240,254]],[[161,120]],[[82,242]],[[3,108]],[[180,229]],[[101,95]],[[22,217]],[[199,82]],[[120,204]],[[41,70]],[[218,191]],[[139,57]],[[60,179]],[[237,44]],[[158,166]],[[79,32]],[[0,154]],[[177,19]],[[98,141]],[[19,7]],[[196,128]],[[117,250]],[[38,116]],[[215,237]],[[136,103]]],"size":1048576},{"channel":"IS_HALF","messages":[[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[12345]],[[43498]],[[9115]],[[40268]],[[5885]],[[37038]],[[2655]],[[33808]],[[64961]],[[30578]],[[61731]],[[27348]],[[58501]],[[24118]],[[55271]],[[20888]],[[52041]],[[17658]],[[48811]],[[14428]],[[45581]],[[11198]],[[42351]],[[7968]],[[39121]],[[4738]],[[35891]],[[1508]],[[32661]],[[63814]],[[29431]],[[60584]],[[26201]],[[57354]],[[22971]],[[54124]],[[19741]],[[50894]],[[16511]],[[47664]],[[13281]],[[44434]],[[10051]],[[41204]],[[6821]],[[37974]],[[3591]],[[34744]],[[361]],[[31514]],[[62667]],[[28284]],[[59437]],[[25054]],[[56207]],[[21824]],[[52977]],[[18594]],[[49747]],[[15364]],[[46517]],[[12134]],[[43287]],[[8904]],[[40057]],[[5674]],[[36827]],[[2444]],[[33597]],[[64750]],[[30367]],[[61520]],[[27137]],[[58290]],[[23907]],[[55060]],[[20677]],[[51830]],[[17447]],[[48600]],[[14217]],[[45370]],[[10987]],[[42140]],[[7757]],[[38910]],[[4527]],[[35680]],[[1297]],[[32450]],[[63603]],[[29220]],[[60373]],[[25990]],[[57143]],[[22760]],[[53913]],[[19530]],[[50683]],[[16300]],[[47453]],[[13070]],[[44223]],[[9840]],[[40993]],[[6610]],[[37763]],[[3380]],[[34533]],[[150]],[[31303]],[[62456]],[[28073]],[[59226]],[[24843]],[[55996]],[[21613]],[[52766]],[[18383]],[[49536]],[[15153]],[[46306]],[[11923]],[[43076]],[[8693]],[[39846]],[[5463]],[[36616]],[[2233]],[[33386]],[[64539]],[[30156]],[[61309]],[[26926]],[[58079]],[[23696]],[[54849]],[[20466]],[[51619]],[[17236]],[[48389]],[[14006]],[[45159]],[[10776]],[[41929]],[[7546]],[[38699]],[[4316]],[[35469]],[[1086]],[[32239]],[[63392]],[[29009]],[[60162]],[[25779]],[[56932]],[[22549]],[[53702]],[[19319]],[[50472]],[[16089]],[[47242]],[[12859]],[[44012]],[[9629]],[[40782]],[[6399]],[[37552]],[[3169]],[[34322]],[[65475]],[[31092]],[[62245]],[[27862]],[[59015]],[[24632]],[[55785]],[[21402]],[[52555]],[[18172]],[[49325]],[[14942]],[[46095]],[[11712]],[[42865]],[[8482]],[[39635]],[[5252]],[[36405]],[[2022]],[[33175]],[[64328]],[[29945]],[[61098]],[[26715]],[[57868]],[[23485]],[[54638]],[[20255]],[[51408]],[[17025]],[[48178]],[[13795]],[[44948]],[[10565]],[[41718]],[[7335]],[[38488]],[[4105]],[[35258]],[[875]],[[32028]],[[63181]],[[28798]],[[59951]],[[25568]],[[56721]],[[22338]],[[53491]],[[19108]],[[50261]],[[15878]],[[47031]],[[12648]],[[43801]],[[9418]],[[40571]],[[6188]],[[37341]],[[2958]],[[34111]],[[65264]],[[30881]],[[62034]],[[27651]],[[58804]],[[24421]],[[55574]],[[21191]],[[52344]],[[17961]],[[49114]],[[14731]],[[45884]],[[11501]],[[42654]],[[8271]],[[39424]],[[5041]],[[36194]],[[1811]],[[32964]],[[64117]],[[29734]],[[60887]],[[26504]]],"size":1048576},{"channel":"IS_B20","messages":[[[0]],[[1]],[[127]],[[128]],[[255]],[[256]],[[257]],[[383]],[[384]],[[511]],[[32512]],[[32513]],[[32639]],[[32640]],[[32767]],[[32768]],[[32769]],[[32895]],[[32896]],[[33023]],[[65280]],[[65281]],[[65407]],[[65408]],[[65535]],[[65536]],[[65537]],[[65663]],[[65664]],[[65791]],[[65792]],[[65793]],[[65919]],[[65920]],[[66047]],[[98048]],[[98049]],[[98175]],[[98176]],[[98303]],[[98304]],[[98305]],[[98431]],[[98432]],[[98559]],[[130816]],[[130817]],[[130943]],[[130944]],[[131071]],[[131072]],[[131073]],[[131199]],[[131200]],[[131327]],[[131328]],[[131329]],[[131455]],[[131456]],[[131583]],[[163584]],[[163585]],[[163711]],[[163712]],[[163839]],[[163840]],[[163841]],[[163967]],[[163968]],[[164095]],[[196352]],[[196353]],[[196479]],[[196480]],[[196607]],[[196608]],[[196609]],[[196735]],[[196736]],[[196863]],[[196864]],[[196865]],[[196991]],[[196992]],[[197119]],[[229120]],[[229121]],[[229247]],[[229248]],[[229375]],[[229376]],[[229377]],[[229503]],[[229504]],[[229631]],[[261888]],[[261889]],[[262015]],[[262016]],[[262143]],[[262144]],[[262145]],[[262271]],[[262272]],[[262399]],[[262400]],[[262401]],[[262527]],[[262528]],[[262655]],[[294656]],[[294657]],[[294783]],[[294784]],[[294911]],[[294912]],[[294913]],[[295039]],[[295040]],[[295167]],[[327424]],[[327425]],[[327551]],[[327552]],[[327679]],[[327680]],[[327681]],[[327807]],[[327808]],[[327935]],[[327936]],[[327937]],[[328063]],[[328064]],[[328191]],[[360192]],[[360193]],[[360319]],[[360320]],[[360447]],[[360448]],[[360449]],[[360575]],[[360576]],[[360703]],[[392960]],[[392961]],[[393087]],[[393088]],[[393215]],[[393216]],[[393217]],[[393343]],[[393344]],[[393471]],[[393472]],[[393473]],[[393599]],[[393600]],[[393727]],[[425728]],[[425729]],[[425855]],[[425856]],[[425983]],[[425984]],[[425985]],[[426111]],[[426112]],[[426239]],[[458496]],[[458497]],[[458623]],[[458624]],[[458751]],[[458752]],[[458753]],[[458879]],[[458880]],[[459007]],[[459008]],[[459009]],[[459135]],[[459136]],[[459263]],[[491264]],[[491265]],[[491391]],[[491392]],[[491519]],[[491520]],[[491521]],[[491647]],[[491648]],[[491775]],[[524032]],[[524033]],[[524159]],[[524160]],[[524287]],[[524288]],[[524289]],[[524415]],[[524416]],[[524543]],[[524544]],[[524545]],[[524671]],[[524672]],[[524799]],[[556800]],[[556801]],[[556927]],[[556928]],[[557055]],[[557056]],[[557057]],[[557183]],[[557184]],[[557311]],[[589568]],[[589569]],[[589695]],[[589696]],[[589823]],[[589824]],[[589825]],[[589951]],[[589952]],[[590079]],[[590080]],[[590081]],[[590207]],[[590208]],[[590335]],[[622336]],[[622337]],[[622463]],[[622464]],[[622591]],[[622592]],[[622593]],[[622719]],[[622720]],[[622847]],[[655104]],[[655105]],[[655231]],[[655232]],[[655359]],[[655360]],[[655361]],[[655487]],[[655488]],[[655615]],[[655616]],[[655617]],[[655743]],[[655744]],[[655871]],[[687872]],[[687873]],[[687999]],[[688000]],[[688127]],[[688128]],[[688129]],[[688255]],[[688256]],[[688383]],[[720640]],[[720641]],[[720767]],[[720768]],[[720895]],[[720896]],[[720897]],[[721023]],[[721024]],[[721151]],[[721152]],[[721153]],[[721279]],[[721280]],[[721407]],[[753408]],[[753409]],[[753535]],[[753536]],[[753663]],[[753664]],[[753665]],[[753791]],[[753792]],[[753919]],[[786176]],[[786177]],[[786303]],[[786304]],[[786431]],[[786432]],[[786433]],[[786559]],[[786560]],[[786687]],[[786688]],[[786689]],[[786815]],[[786816]],[[786943]],[[818944]],[[818945]],[[819071]],[[819072]],[[819199]],[[819200]],[[819201]],[[819327]],[[819328]],[[819455]],[[851712]],[[851713]],[[851839]],[[851840]],[[851967]],[[851968]],[[851969]],[[852095]],[[852096]],[[852223]],[[852224]],[[852225]],[[852351]],[[852352]],[[852479]],[[884480]],[[884481]],[[884607]],[[884608]],[[884735]],[[884736]],[[884737]],[[884863]],[[884864]],[[884991]],[[917248]],[[917249]],[[917375]],[[917376]],[[917503]],[[917504]],[[917505]],[[917631]],[[917632]],[[917759]],[[917760]],[[917761]],[[917887]],[[917888]],[[918015]],[[950016]],[[950017]],[[950143]],[[950144]],[[950271]],[[950272]],[[950273]],[[950399]],[[950400]],[[950527]],[[982784]],[[982785]],[[982911]],[[982912]],[[983039]],[[983040]],[[983041]],[[983167]],[[983168]],[[983295]],[[983296]],[[983297]],[[983423]],[[983424]],[[983551]],[[1015552]],[[1015553]],[[1015679]],[[1015680]],[[1015807]],[[1015808]],[[1015809]],[[1015935]],[[1015936]],[[1016063]],[[1048320]],[[1048321]],[[1048447]],[[1048448]],[[1048575]],[[12345]],[[502250]],[[992155]],[[433484]],[[923389]],[[364718]],[[854623]],[[295952]],[[785857]],[[227186]],[[717091]],[[158420]],[[648325]],[[89654]],[[579559]],[[20888]],[[510793]],[[1000698]],[[442027]],[[931932]],[[373261]],[[863166]],[[304495]],[[794400]],[[235729]],[[725634]],[[166963]],[[656868]],[[98197]],[[588102]],[[29431]],[[519336]],[[1009241]],[[450570]],[[940475]],[[381804]],[[871709]],[[313038]],[[802943]],[[244272]],[[734177]],[[175506]],[[665411]],[[106740]],[[596645]],[[37974]],[[527879]],[[1017784]],[[459113]],[[949018]],[[390347]],[[880252]],[[321581]],[[811486]],[[252815]],[[742720]],[[184049]],[[673954]],[[115283]],[[605188]],[[46517]],[[536422]],[[1026327]],[[467656]],[[957561]],[[398890]],[[888795]],[[330124]],[[820029]],[[261358]],[[751263]],[[192592]],[[682497]],[[123826]],[[613731]],[[55060]],[[544965]],[[1034870]],[[476199]],[[966104]],[[407433]],[[897338]],[[338667]],[[828572]],[[269901]],[[759806]],[[201135]],[[691040]],[[132369]],[[622274]],[[63603]],[[553508]],[[1043413]],[[484742]],[[974647]],[[415976]],[[905881]],[[347210]],[[837115]],[[278444]],[[768349]],[[209678]],[[699583]],[[140912]],[[630817]],[[72146]],[[562051]],[[3380]],[[493285]],[[983190]],[[424519]],[[914424]],[[355753]],[[845658]],[[286987]],[[776892]],[[218221]],[[708126]],[[149455]],[[639360]],[[80689]],[[570594]],[[11923]],[[501828]],[[991733]],[[433062]],[[922967]],[[364296]],[[854201]],[[295530]],[[785435]],[[226764]],[[716669]],[[157998]],[[647903]],[[89232]],[[579137]],[[20466]],[[510371]],[[1000276]],[[441605]],[[931510]],[[372839]],[[862744]],[[304073]],[[793978]],[[235307]],[[725212]],[[166541]],[[656446]],[[97775]],[[587680]],[[29009]],[[518914]],[[1008819]],[[450148]],[[940053]],[[381382]],[[871287]],[[312616]],[[802521]],[[243850]],[[733755]],[[175084]],[[664989]],[[106318]],[[596223]],[[37552]],[[527457]],[[1017362]],[[458691]],[[948596]],[[389925]],[[879830]],[[321159]],[[811064]],[[252393]],[[742298]],[[183627]],[[673532]],[[114861]],[[604766]],[[46095]],[[536000]],[[1025905]],[[467234]],[[957139]],[[398468]],[[888373]],[[329702]],[[819607]],[[260936]],[[750841]],[[192170]],[[682075]],[[123404]],[[613309]],[[54638]],[[544543]],[[1034448]],[[475777]],[[965682]],[[407011]],[[896916]],[[338245]],[[828150]],[[269479]],[[759384]],[[200713]],[[690618]],[[131947]],[[621852]],[[63181]],[[553086]],[[1042991]],[[484320]],[[974225]],[[415554]],[[905459]],[[346788]],[[836693]],[[278022]],[[767927]],[[209256]],[[699161]],[[140490]],[[630395]],[[71724]],[[561629]],[[2958]],[[492863]],[[982768]],[[424097]],[[914002]],[[355331]],[[845236]],[[286565]],[[776470]],[[217799]],[[707704]],[[149033]],[[638938]],[[80267]],[[570172]],[[11501]],[[501406]],[[991311]],[[432640]],[[922545]],[[363874]],[[853779]],[[295108]],[[785013]],[[226342]],[[716247]],[[157576]]],"size":1048576},{"channel":"MSB8","messages":[[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[0,0]],[[1,0]],[[127,0]],[[128,1]],[[255,1]],[[57,0]],[[234,1]],[[155,1]],[[76,0]],[[253,1]],[[174,1]],[[95,0]],[[16,0]],[[193,1]],[[114,0]],[[35,0]],[[212,1]],[[133,1]],[[54,0]],[[231,1]],[[152,1]],[[73,0]],[[250,1]],[[171,1]],[[92,0]],[[13,0]],[[190,1]],[[111,0]],[[32,0]],[[209,1]],[[130,1]],[[51,0]],[[228,1]],[[149,1]],[[70,0]],[[247,1]],[[168,1]],[[89,0]],[[10,0]],[[187,1]],[[108,0]],[[29,0]],[[206,1]],[[127,0]],[[48,0]],[[225,1]],[[146,1]],[[67,0]],[[244,1]],[[165,1]],[[86,0]],[[7,0]],[[184,1]],[[105,0]],[[26,0]],[[203,1]],[[124,0]],[[45,0]],[[222,1]],[[143,1]],[[64,0]],[[241,1]],[[162,1]],[[83,0]],[[4,0]],[[181,1]],[[102,0]],[[23,0]],[[200,1]],[[121,0]],[[42,0]],[[219,1]],[[140,1]],[[61,0]],[[238,1]],[[159,1]],[[80,0]],[[1,0]],[[178,1]],[[99,0]],[[20,0]],[[197,1]],[[118,0]],[[39,0]],[[216,1]],[[137,1]],[[58,0]],[[235,1]],[[156,1]],[[77,0]],[[254,1]],[[175,1]],[[96,0]],[[17,0]],[[194,1]],[[115,0]],[[36,0]],[[213,1]],[[134,1]],[[55,0]],[[232,1]],[[153,1]],[[74,0]],[[251,1]],[[172,1]],[[93,0]],[[14,0]],[[191,1]],[[112,0]],[[33,0]],[[210,1]],[[131,1]],[[52,0]],[[229,1]],[[150,1]],[[71,0]],[[248,1]],[[169,1]],[[90,0]],[[11,0]],[[188,1]],[[109,0]],[[30,0]],[[207,1]],[[128,1]],[[49,0]],[[226,1]],[[147,1]],[[68,0]],[[245,1]],[[166,1]],[[87,0]],[[8,0]],[[185,1]],[[106,0]],[[27,0]],[[204,1]],[[125,0]],[[46,0]],[[223,1]],[[144,1]],[[65,0]],[[242,1]],[[163,1]],[[84,0]],[[5,0]],[[182,1]],[[103,0]],[[24,0]],[[201,1]],[[122,0]],[[43,0]],[[220,1]],[[141,1]],[[62,0]],[[239,1]],[[160,1]],[[81,0]],[[2,0]],[[179,1]],[[100,0]],[[21,0]],[[198,1]],[[119,0]],[[40,0]],[[217,1]],[[138,1]],[[59,0]],[[236,1]],[[157,1]],[[78,0]],[[255,1]],[[176,1]],[[97,0]],[[18,0]],[[195,1]],[[116,0]],[[37,0]],[[214,1]],[[135,1]],[[56,0]],[[233,1]],[[154,1]],[[75,0]],[[252,1]],[[173,1]],[[94,0]],[[15,0]],[[192,1]],[[113,0]],[[34,0]],[[211,1]],[[132,1]],[[53,0]],[[230,1]],[[151,1]],[[72,0]],[[249,1]],[[170,1]],[[91,0]],[[12,0]],[[189,1]],[[110,0]],[[31,0]],[[208,1]],[[129,1]],[[50,0]],[[227,1]],[[148,1]],[[69,0]],[[246,1]],[[167,1]],[[88,0]],[[9,0]],[[186,1]],[[107,0]],[[28,0]],[[205,1]],[[126,0]],[[47,0]],[[224,1]],[[145,1]],[[66,0]],[[243,1]],[[164,1]],[[85,0]],[[6,0]],[[183,1]],[[104,0]],[[25,0]],[[202,1]],[[123,0]],[[44,0]],[[221,1]],[[142,1]],[[63,0]],[[240,1]],[[161,1]],[[82,0]],[[3,0]],[[180,1]],[[101,0]],[[22,0]],[[199,1]],[[120,0]],[[41,0]],[[218,1]],[[139,1]],[[60,0]],[[237,1]],[[158,1]],[[79,0]],[[0,0]],[[177,1]],[[98,0]],[[19,0]],[[196,1]],[[117,0]],[[38,0]],[[215,1]],[[136,1]]],"size":1048576},{"channel":"MSB16","messages":[[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[0,0]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,1]],[[32769,1]],[[32895,1]],[[32896,1]],[[33023,1]],[[65280,1]],[[65281,1]],[[65407,1]],[[65408,1]],[[65535,1]],[[12345,0]],[[43498,1]],[[9115,0]],[[40268,1]],[[5885,0]],[[37038,1]],[[2655,0]],[[33808,1]],[[64961,1]],[[30578,0]],[[61731,1]],[[27348,0]],[[58501,1]],[[24118,0]],[[55271,1]],[[20888,0]],[[52041,1]],[[17658,0]],[[48811,1]],[[14428,0]],[[45581,1]],[[11198,0]],[[42351,1]],[[7968,0]],[[39121,1]],[[4738,0]],[[35891,1]],[[1508,0]],[[32661,0]],[[63814,1]],[[29431,0]],[[60584,1]],[[26201,0]],[[57354,1]],[[22971,0]],[[54124,1]],[[19741,0]],[[50894,1]],[[16511,0]],[[47664,1]],[[13281,0]],[[44434,1]],[[10051,0]],[[41204,1]],[[6821,0]],[[37974,1]],[[3591,0]],[[34744,1]],[[361,0]],[[31514,0]],[[62667,1]],[[28284,0]],[[59437,1]],[[25054,0]],[[56207,1]],[[21824,0]],[[52977,1]],[[18594,0]],[[49747,1]],[[15364,0]],[[46517,1]],[[12134,0]],[[43287,1]],[[8904,0]],[[40057,1]],[[5674,0]],[[36827,1]],[[2444,0]],[[33597,1]],[[64750,1]],[[30367,0]],[[61520,1]],[[27137,0]],[[58290,1]],[[23907,0]],[[55060,1]],[[20677,0]],[[51830,1]],[[17447,0]],[[48600,1]],[[14217,0]],[[45370,1]],[[10987,0]],[[42140,1]],[[7757,0]],[[38910,1]],[[4527,0]],[[35680,1]],[[1297,0]],[[32450,0]],[[63603,1]],[[29220,0]],[[60373,1]],[[25990,0]],[[57143,1]],[[22760,0]],[[53913,1]],[[19530,0]],[[50683,1]],[[16300,0]],[[47453,1]],[[13070,0]],[[44223,1]],[[9840,0]],[[40993,1]],[[6610,0]],[[37763,1]],[[3380,0]],[[34533,1]],[[150,0]],[[31303,0]],[[62456,1]],[[28073,0]],[[59226,1]],[[24843,0]],[[55996,1]],[[21613,0]],[[52766,1]],[[18383,0]],[[49536,1]],[[15153,0]],[[46306,1]],[[11923,0]],[[43076,1]],[[8693,0]],[[39846,1]],[[5463,0]],[[36616,1]],[[2233,0]],[[33386,1]],[[64539,1]],[[30156,0]],[[61309,1]],[[26926,0]],[[58079,1]],[[23696,0]],[[54849,1]],[[20466,0]],[[51619,1]],[[17236,0]],[[48389,1]],[[14006,0]],[[45159,1]],[[10776,0]],[[41929,1]],[[7546,0]],[[38699,1]],[[4316,0]],[[35469,1]],[[1086,0]],[[32239,0]],[[63392,1]],[[29009,0]],[[60162,1]],[[25779,0]],[[56932,1]],[[22549,0]],[[53702,1]],[[19319,0]],[[50472,1]],[[16089,0]],[[47242,1]],[[12859,0]],[[44012,1]],[[9629,0]],[[40782,1]],[[6399,0]],[[37552,1]],[[3169,0]],[[34322,1]],[[65475,1]],[[31092,0]],[[62245,1]],[[27862,0]],[[59015,1]],[[24632,0]],[[55785,1]],[[21402,0]],[[52555,1]],[[18172,0]],[[49325,1]],[[14942,0]],[[46095,1]],[[11712,0]],[[42865,1]],[[8482,0]],[[39635,1]],[[5252,0]],[[36405,1]],[[2022,0]],[[33175,1]],[[64328,1]],[[29945,0]],[[61098,1]],[[26715,0]],[[57868,1]],[[23485,0]],[[54638,1]],[[20255,0]],[[51408,1]],[[17025,0]],[[48178,1]],[[13795,0]],[[44948,1]],[[10565,0]],[[41718,1]],[[7335,0]],[[38488,1]],[[4105,0]],[[35258,1]],[[875,0]],[[32028,0]],[[63181,1]],[[28798,0]],[[59951,1]],[[25568,0]],[[56721,1]],[[22338,0]],[[53491,1]],[[19108,0]],[[50261,1]],[[15878,0]],[[47031,1]],[[12648,0]],[[43801,1]],[[9418,0]],[[40571,1]],[[6188,0]],[[37341,1]],[[2958,0]],[[34111,1]],[[65264,1]],[[30881,0]],[[62034,1]],[[27651,0]],[[58804,1]],[[24421,0]],[[55574,1]],[[21191,0]],[[52344,1]],[[17961,0]],[[49114,1]],[[14731,0]],[[45884,1]],[[11501,0]],[[42654,1]],[[8271,0]],[[39424,1]],[[5041,0]],[[36194,1]],[[1811,0]],[[32964,1]],[[64117,1]],[[29734,0]],[[60887,1]],[[26504,0]]],"size":1048576},{"channel":"ZERO","messages":[[[0,1]],[[1,0]],[[127,0]],[[128,0]],[[255,0]],[[256,0]],[[257,0]],[[383,0]],[[384,0]],[[511,0]],[[32512,0]],[[32513,0]],[[32639,0]],[[32640,0]],[[32767,0]],[[32768,0]],[[32769,0]],[[32895,0]],[[32896,0]],[[33023,0]],[[65280,0]],[[65281,0]],[[65407,0]],[[65408,0]],[[65535,0]],[[65536,0]],[[65537,0]],[[65663,0]],[[65664,0]],[[65791,0]],[[65792,0]],[[65793,0]],[[65919,0]],[[65920,0]],[[66047,0]],[[98048,0]],[[98049,0]],[[98175,0]],[[98176,0]],[[98303,0]],[[98304,0]],[[98305,0]],[[98431,0]],[[98432,0]],[[98559,0]],[[130816,0]],[[130817,0]],[[130943,0]],[[130944,0]],[[131071,0]],[[131072,0]],[[131073,0]],[[131199,0]],[[131200,0]],[[131327,0]],[[131328,0]],[[131329,0]],[[131455,0]],[[131456,0]],[[131583,0]],[[163584,0]],[[163585,0]],[[163711,0]],[[163712,0]],[[163839,0]],[[163840,0]],[[163841,0]],[[163967,0]],[[163968,0]],[[164095,0]],[[196352,0]],[[196353,0]],[[196479,0]],[[196480,0]],[[196607,0]],[[196608,0]],[[196609,0]],[[196735,0]],[[196736,0]],[[196863,0]],[[196864,0]],[[196865,0]],[[196991,0]],[[196992,0]],[[197119,0]],[[229120,0]],[[229121,0]],[[229247,0]],[[229248,0]],[[229375,0]],[[229376,0]],[[229377,0]],[[229503,0]],[[229504,0]],[[229631,0]],[[261888,0]],[[261889,0]],[[262015,0]],[[262016,0]],[[262143,0]],[[262144,0]],[[262145,0]],[[262271,0]],[[262272,0]],[[262399,0]],[[262400,0]],[[262401,0]],[[262527,0]],[[262528,0]],[[262655,0]],[[294656,0]],[[294657,0]],[[294783,0]],[[294784,0]],[[294911,0]],[[294912,0]],[[294913,0]],[[295039,0]],[[295040,0]],[[295167,0]],[[327424,0]],[[327425,0]],[[327551,0]],[[327552,0]],[[327679,0]],[[327680,0]],[[327681,0]],[[327807,0]],[[327808,0]],[[327935,0]],[[327936,0]],[[327937,0]],[[328063,0]],[[328064,0]],[[328191,0]],[[360192,0]],[[360193,0]],[[360319,0]],[[360320,0]],[[360447,0]],[[360448,0]],[[360449,0]],[[360575,0]],[[360576,0]],[[360703,0]],[[392960,0]],[[392961,0]],[[393087,0]],[[393088,0]],[[393215,0]],[[393216,0]],[[393217,0]],[[393343,0]],[[393344,0]],[[393471,0]],[[393472,0]],[[393473,0]],[[393599,0]],[[393600,0]],[[393727,0]],[[425728,0]],[[425729,0]],[[425855,0]],[[425856,0]],[[425983,0]],[[425984,0]],[[425985,0]],[[426111,0]],[[426112,0]],[[426239,0]],[[458496,0]],[[458497,0]],[[458623,0]],[[458624,0]],[[458751,0]],[[458752,0]],[[458753,0]],[[458879,0]],[[458880,0]],[[459007,0]],[[459008,0]],[[459009,0]],[[459135,0]],[[459136,0]],[[459263,0]],[[491264,0]],[[491265,0]],[[491391,0]],[[491392,0]],[[491519,0]],[[491520,0]],[[491521,0]],[[491647,0]],[[491648,0]],[[491775,0]],[[524032,0]],[[524033,0]],[[524159,0]],[[524160,0]],[[524287,0]],[[524288,0]],[[524289,0]],[[524415,0]],[[524416,0]],[[524543,0]],[[524544,0]],[[524545,0]],[[524671,0]],[[524672,0]],[[524799,0]],[[556800,0]],[[556801,0]],[[556927,0]],[[556928,0]],[[557055,0]],[[557056,0]],[[557057,0]],[[557183,0]],[[557184,0]],[[557311,0]],[[589568,0]],[[589569,0]],[[589695,0]],[[589696,0]],[[589823,0]],[[589824,0]],[[589825,0]],[[589951,0]],[[589952,0]],[[590079,0]],[[590080,0]],[[590081,0]],[[590207,0]],[[590208,0]],[[590335,0]],[[622336,0]],[[622337,0]],[[622463,0]],[[622464,0]],[[622591,0]],[[622592,0]],[[622593,0]],[[622719,0]],[[622720,0]],[[622847,0]],[[655104,0]],[[655105,0]],[[655231,0]],[[655232,0]],[[655359,0]],[[655360,0]],[[655361,0]],[[655487,0]],[[655488,0]],[[655615,0]],[[655616,0]],[[655617,0]],[[655743,0]],[[655744,0]],[[655871,0]],[[687872,0]],[[687873,0]],[[687999,0]],[[688000,0]],[[688127,0]],[[688128,0]],[[688129,0]],[[688255,0]],[[688256,0]],[[688383,0]],[[720640,0]],[[720641,0]],[[720767,0]],[[720768,0]],[[720895,0]],[[720896,0]],[[720897,0]],[[721023,0]],[[721024,0]],[[721151,0]],[[721152,0]],[[721153,0]],[[721279,0]],[[721280,0]],[[721407,0]],[[753408,0]],[[753409,0]],[[753535,0]],[[753536,0]],[[753663,0]],[[753664,0]],[[753665,0]],[[753791,0]],[[753792,0]],[[753919,0]],[[786176,0]],[[786177,0]],[[786303,0]],[[786304,0]],[[786431,0]],[[786432,0]],[[786433,0]],[[786559,0]],[[786560,0]],[[786687,0]],[[786688,0]],[[786689,0]],[[786815,0]],[[786816,0]],[[786943,0]],[[818944,0]],[[818945,0]],[[819071,0]],[[819072,0]],[[819199,0]],[[819200,0]],[[819201,0]],[[819327,0]],[[819328,0]],[[819455,0]],[[851712,0]],[[851713,0]],[[851839,0]],[[851840,0]],[[851967,0]],[[851968,0]],[[851969,0]],[[852095,0]],[[852096,0]],[[852223,0]],[[852224,0]],[[852225,0]],[[852351,0]],[[852352,0]],[[852479,0]],[[884480,0]],[[884481,0]],[[884607,0]],[[884608,0]],[[884735,0]],[[884736,0]],[[884737,0]],[[884863,0]],[[884864,0]],[[884991,0]],[[917248,0]],[[917249,0]],[[917375,0]],[[917376,0]],[[917503,0]],[[917504,0]],[[917505,0]],[[917631,0]],[[917632,0]],[[917759,0]],[[917760,0]],[[917761,0]],[[917887,0]],[[917888,0]],[[918015,0]],[[950016,0]],[[950017,0]],[[950143,0]],[[950144,0]],[[950271,0]],[[950272,0]],[[950273,0]],[[950399,0]],[[950400,0]],[[950527,0]],[[982784,0]],[[982785,0]],[[982911,0]],[[982912,0]],[[983039,0]],[[983040,0]],[[983041,0]],[[983167,0]],[[983168,0]],[[983295,0]],[[983296,0]],[[983297,0]],[[983423,0]],[[983424,0]],[[983551,0]],[[1015552,0]],[[1015553,0]],[[1015679,0]],[[1015680,0]],[[1015807,0]],[[1015808,0]],[[1015809,0]],[[1015935,0]],[[1015936,0]],[[1016063,0]],[[1048320,0]],[[1048321,0]],[[1048447,0]],[[1048448,0]],[[1048575,0]],[[12345,0]],[[502250,0]],[[992155,0]],[[433484,0]],[[923389,0]],[[364718,0]],[[854623,0]],[[295952,0]],[[785857,0]],[[227186,0]],[[717091,0]],[[158420,0]],[[648325,0]],[[89654,0]],[[579559,0]],[[20888,0]],[[510793,0]],[[1000698,0]],[[442027,0]],[[931932,0]],[[373261,0]],[[863166,0]],[[304495,0]],[[794400,0]],[[235729,0]],[[725634,0]],[[166963,0]],[[656868,0]],[[98197,0]],[[588102,0]],[[29431,0]],[[519336,0]],[[1009241,0]],[[450570,0]],[[940475,0]],[[381804,0]],[[871709,0]],[[313038,0]],[[802943,0]],[[244272,0]],[[734177,0]],[[175506,0]],[[665411,0]],[[106740,0]],[[596645,0]],[[37974,0]],[[527879,0]],[[1017784,0]],[[459113,0]],[[949018,0]],[[390347,0]],[[880252,0]],[[321581,0]],[[811486,0]],[[252815,0]],[[742720,0]],[[184049,0]],[[673954,0]],[[115283,0]],[[605188,0]],[[46517,0]],[[536422,0]],[[1026327,0]],[[467656,0]],[[957561,0]],[[398890,0]],[[888795,0]],[[330124,0]],[[820029,0]],[[261358,0]],[[751263,0]],[[192592,0]],[[682497,0]],[[123826,0]],[[613731,0]],[[55060,0]],[[544965,0]],[[1034870,0]],[[476199,0]],[[966104,0]],[[407433,0]],[[897338,0]],[[338667,0]],[[828572,0]],[[269901,0]],[[759806,0]],[[201135,0]],[[691040,0]],[[132369,0]],[[622274,0]],[[63603,0]],[[553508,0]],[[1043413,0]],[[484742,0]],[[974647,0]],[[415976,0]],[[905881,0]],[[347210,0]],[[837115,0]],[[278444,0]],[[768349,0]],[[209678,0]],[[699583,0]],[[140912,0]],[[630817,0]],[[72146,0]],[[562051,0]],[[3380,0]],[[493285,0]],[[983190,0]],[[424519,0]],[[914424,0]],[[355753,0]],[[845658,0]],[[286987,0]],[[776892,0]],[[218221,0]],[[708126,0]],[[149455,0]],[[639360,0]],[[80689,0]],[[570594,0]],[[11923,0]],[[501828,0]],[[991733,0]],[[433062,0]],[[922967,0]],[[364296,0]],[[854201,0]],[[295530,0]],[[785435,0]],[[226764,0]],[[716669,0]],[[157998,0]],[[647903,0]],[[89232,0]],[[579137,0]],[[20466,0]],[[510371,0]],[[1000276,0]],[[441605,0]],[[931510,0]],[[372839,0]],[[862744,0]],[[304073,0]],[[793978,0]],[[235307,0]],[[725212,0]],[[166541,0]],[[656446,0]],[[97775,0]],[[587680,0]],[[29009,0]],[[518914,0]],[[1008819,0]],[[450148,0]],[[940053,0]],[[381382,0]],[[871287,0]],[[312616,0]],[[802521,0]],[[243850,0]],[[733755,0]],[[175084,0]],[[664989,0]],[[106318,0]],[[596223,0]],[[37552,0]],[[527457,0]],[[1017362,0]],[[458691,0]],[[948596,0]],[[389925,0]],[[879830,0]],[[321159,0]],[[811064,0]],[[252393,0]],[[742298,0]],[[183627,0]],[[673532,0]],[[114861,0]],[[604766,0]],[[46095,0]],[[536000,0]],[[1025905,0]],[[467234,0]],[[957139,0]],[[398468,0]],[[888373,0]],[[329702,0]],[[819607,0]],[[260936,0]],[[750841,0]],[[192170,0]],[[682075,0]],[[123404,0]],[[613309,0]],[[54638,0]],[[544543,0]],[[1034448,0]],[[475777,0]],[[965682,0]],[[407011,0]],[[896916,0]],[[338245,0]],[[828150,0]],[[269479,0]],[[759384,0]],[[200713,0]],[[690618,0]],[[131947,0]],[[621852,0]],[[63181,0]],[[553086,0]],[[1042991,0]],[[484320,0]],[[974225,0]],[[415554,0]],[[905459,0]],[[346788,0]],[[836693,0]],[[278022,0]],[[767927,0]],[[209256,0]],[[699161,0]],[[140490,0]],[[630395,0]],[[71724,0]],[[561629,0]],[[2958,0]],[[492863,0]],[[982768,0]],[[424097,0]],[[914002,0]],[[355331,0]],[[845236,0]],[[286565,0]],[[776470,0]],[[217799,0]],[[707704,0]],[[149033,0]],[[638938,0]],[[80267,0]],[[570172,0]],[[11501,0]],[[501406,0]],[[991311,0]],[[432640,0]],[[922545,0]],[[363874,0]],[[853779,0]],[[295108,0]],[[785013,0]],[[226342,0]],[[716247,0]],[[157576,0]]],"size":1048576},{"channel":"HWSL","messages":[[[0,0,0,0]],[[1,0,1,0]],[[127,0,127,0]],[[128,0,128,0]],[[255,0,255,0]],[[256,0,256,0]],[[257,0,257,0]],[[383,0,383,0]],[[384,0,384,0]],[[511,0,511,0]],[[32512,0,32512,0]],[[32513,0,32513,0]],[[32639,0,32639,0]],[[32640,0,32640,0]],[[32767,0,32767,0]],[[32768,0,32768,0]],[[32769,0,32769,0]],[[32895,0,32895,0]],[[32896,0,32896,0]],[[33023,0,33023,0]],[[65280,0,65280,0]],[[65281,0,65281,0]],[[65407,0,65407,0]],[[65408,0,65408,0]],[[65535,0,65535,0]],[[0,1,0,0]],[[1,1,2,0]],[[127,1,254,0]],[[128,1,256,0]],[[255,1,510,0]],[[256,1,512,0]],[[257,1,514,0]],[[383,1,766,0]],[[384,1,768,0]],[[511,1,1022,0]],[[32512,1,65024,0]],[[32513,1,65026,0]],[[32639,1,65278,0]],[[32640,1,65280,0]],[[32767,1,65534,0]],[[32768,1,0,1]],[[32769,1,2,1]],[[32895,1,254,1]],[[32896,1,256,1]],[[33023,1,510,1]],[[65280,1,65024,1]],[[65281,1,65026,1]],[[65407,1,65278,1]],[[65408,1,65280,1]],[[65535,1,65534,1]],[[0,2,0,0]],[[1,2,4,0]],[[127,2,508,0]],[[128,2,512,0]],[[255,2,1020,0]],[[256,2,1024,0]],[[257,2,1028,0]],[[383,2,1532,0]],[[384,2,1536,0]],[[511,2,2044,0]],[[32512,2,64512,1]],[[32513,2,64516,1]],[[32639,2,65020,1]],[[32640,2,65024,1]],[[32767,2,65532,1]],[[32768,2,0,2]],[[32769,2,4,2]],[[32895,2,508,2]],[[32896,2,512,2]],[[33023,2,1020,2]],[[65280,2,64512,3]],[[65281,2,64516,3]],[[65407,2,65020,3]],[[65408,2,65024,3]],[[65535,2,65532,3]],[[0,3,0,0]],[[1,3,8,0]],[[127,3,1016,0]],[[128,3,1024,0]],[[255,3,2040,0]],[[256,3,2048,0]],[[257,3,2056,0]],[[383,3,3064,0]],[[384,3,3072,0]],[[511,3,4088,0]],[[32512,3,63488,3]],[[32513,3,63496,3]],[[32639,3,64504,3]],[[32640,3,64512,3]],[[32767,3,65528,3]],[[32768,3,0,4]],[[32769,3,8,4]],[[32895,3,1016,4]],[[32896,3,1024,4]],[[33023,3,2040,4]],[[65280,3,63488,7]],[[65281,3,63496,7]],[[65407,3,64504,7]],[[65408,3,64512,7]],[[65535,3,65528,7]],[[0,4,0,0]],[[1,4,16,0]],[[127,4,2032,0]],[[128,4,2048,0]],[[255,4,4080,0]],[[256,4,4096,0]],[[257,4,4112,0]],[[383,4,6128,0]],[[384,4,6144,0]],[[511,4,8176,0]],[[32512,4,61440,7]],[[32513,4,61456,7]],[[32639,4,63472,7]],[[32640,4,63488,7]],[[32767,4,65520,7]],[[32768,4,0,8]],[[32769,4,16,8]],[[32895,4,2032,8]],[[32896,4,2048,8]],[[33023,4,4080,8]],[[65280,4,61440,15]],[[65281,4,61456,15]],[[65407,4,63472,15]],[[65408,4,63488,15]],[[65535,4,65520,15]],[[0,5,0,0]],[[1,5,32,0]],[[127,5,4064,0]],[[128,5,4096,0]],[[255,5,8160,0]],[[256,5,8192,0]],[[257,5,8224,0]],[[383,5,12256,0]],[[384,5,12288,0]],[[511,5,16352,0]],[[32512,5,57344,15]],[[32513,5,57376,15]],[[32639,5,61408,15]],[[32640,5,61440,15]],[[32767,5,65504,15]],[[32768,5,0,16]],[[32769,5,32,16]],[[32895,5,4064,16]],[[32896,5,4096,16]],[[33023,5,8160,16]],[[65280,5,57344,31]],[[65281,5,57376,31]],[[65407,5,61408,31]],[[65408,5,61440,31]],[[65535,5,65504,31]],[[0,6,0,0]],[[1,6,64,0]],[[127,6,8128,0]],[[128,6,8192,0]],[[255,6,16320,0]],[[256,6,16384,0]],[[257,6,16448,0]],[[383,6,24512,0]],[[384,6,24576,0]],[[511,6,32704,0]],[[32512,6,49152,31]],[[32513,6,49216,31]],[[32639,6,57280,31]],[[32640,6,57344,31]],[[32767,6,65472,31]],[[32768,6,0,32]],[[32769,6,64,32]],[[32895,6,8128,32]],[[32896,6,8192,32]],[[33023,6,16320,32]],[[65280,6,49152,63]],[[65281,6,49216,63]],[[65407,6,57280,63]],[[65408,6,57344,63]],[[65535,6,65472,63]],[[0,7,0,0]],[[1,7,128,0]],[[127,7,16256,0]],[[128,7,16384,0]],[[255,7,32640,0]],[[256,7,32768,0]],[[257,7,32896,0]],[[383,7,49024,0]],[[384,7,49152,0]],[[511,7,65408,0]],[[32512,7,32768,63]],[[32513,7,32896,63]],[[32639,7,49024,63]],[[32640,7,49152,63]],[[32767,7,65408,63]],[[32768,7,0,64]],[[32769,7,128,64]],[[32895,7,16256,64]],[[32896,7,16384,64]],[[33023,7,32640,64]],[[65280,7,32768,127]],[[65281,7,32896,127]],[[65407,7,49024,127]],[[65408,7,49152,127]],[[65535,7,65408,127]],[[0,8,0,0]],[[1,8,256,0]],[[127,8,32512,0]],[[128,8,32768,0]],[[255,8,65280,0]],[[256,8,0,1]],[[257,8,256,1]],[[383,8,32512,1]],[[384,8,32768,1]],[[511,8,65280,1]],[[32512,8,0,127]],[[32513,8,256,127]],[[32639,8,32512,127]],[[32640,8,32768,127]],[[32767,8,65280,127]],[[32768,8,0,128]],[[32769,8,256,128]],[[32895,8,32512,128]],[[32896,8,32768,128]],[[33023,8,65280,128]],[[65280,8,0,255]],[[65281,8,256,255]],[[65407,8,32512,255]],[[65408,8,32768,255]],[[65535,8,65280,255]],[[0,9,0,0]],[[1,9,512,0]],[[127,9,65024,0]],[[128,9,0,1]],[[255,9,65024,1]],[[256,9,0,2]],[[257,9,512,2]],[[383,9,65024,2]],[[384,9,0,3]],[[511,9,65024,3]],[[32512,9,0,254]],[[32513,9,512,254]],[[32639,9,65024,254]],[[32640,9,0,255]],[[32767,9,65024,255]],[[32768,9,0,256]],[[32769,9,512,256]],[[32895,9,65024,256]],[[32896,9,0,257]],[[33023,9,65024,257]],[[65280,9,0,510]],[[65281,9,512,510]],[[65407,9,65024,510]],[[65408,9,0,511]],[[65535,9,65024,511]],[[0,10,0,0]],[[1,10,1024,0]],[[127,10,64512,1]],[[128,10,0,2]],[[255,10,64512,3]],[[256,10,0,4]],[[257,10,1024,4]],[[383,10,64512,5]],[[384,10,0,6]],[[511,10,64512,7]],[[32512,10,0,508]],[[32513,10,1024,508]],[[32639,10,64512,509]],[[32640,10,0,510]],[[32767,10,64512,511]],[[32768,10,0,512]],[[32769,10,1024,512]],[[32895,10,64512,513]],[[32896,10,0,514]],[[33023,10,64512,515]],[[65280,10,0,1020]],[[65281,10,1024,1020]],[[65407,10,64512,1021]],[[65408,10,0,1022]],[[65535,10,64512,1023]],[[0,11,0,0]],[[1,11,2048,0]],[[127,11,63488,3]],[[128,11,0,4]],[[255,11,63488,7]],[[256,11,0,8]],[[257,11,2048,8]],[[383,11,63488,11]],[[384,11,0,12]],[[511,11,63488,15]],[[32512,11,0,1016]],[[32513,11,2048,1016]],[[32639,11,63488,1019]],[[32640,11,0,1020]],[[32767,11,63488,1023]],[[32768,11,0,1024]],[[32769,11,2048,1024]],[[32895,11,63488,1027]],[[32896,11,0,1028]],[[33023,11,63488,1031]],[[65280,11,0,2040]],[[65281,11,2048,2040]],[[65407,11,63488,2043]],[[65408,11,0,2044]],[[65535,11,63488,2047]],[[0,12,0,0]],[[1,12,4096,0]],[[127,12,61440,7]],[[128,12,0,8]],[[255,12,61440,15]],[[256,12,0,16]],[[257,12,4096,16]],[[383,12,61440,23]],[[384,12,0,24]],[[511,12,61440,31]],[[32512,12,0,2032]],[[32513,12,4096,2032]],[[32639,12,61440,2039]],[[32640,12,0,2040]],[[32767,12,61440,2047]],[[32768,12,0,2048]],[[32769,12,4096,2048]],[[32895,12,61440,2055]],[[32896,12,0,2056]],[[33023,12,61440,2063]],[[65280,12,0,4080]],[[65281,12,4096,4080]],[[65407,12,61440,4087]],[[65408,12,0,4088]],[[65535,12,61440,4095]],[[0,13,0,0]],[[1,13,8192,0]],[[127,13,57344,15]],[[128,13,0,16]],[[255,13,57344,31]],[[256,13,0,32]],[[257,13,8192,32]],[[383,13,57344,47]],[[384,13,0,48]],[[511,13,57344,63]],[[32512,13,0,4064]],[[32513,13,8192,4064]],[[32639,13,57344,4079]],[[32640,13,0,4080]],[[32767,13,57344,4095]],[[32768,13,0,4096]],[[32769,13,8192,4096]],[[32895,13,57344,4111]],[[32896,13,0,4112]],[[33023,13,57344,4127]],[[65280,13,0,8160]],[[65281,13,8192,8160]],[[65407,13,57344,8175]],[[65408,13,0,8176]],[[65535,13,57344,8191]],[[0,14,0,0]],[[1,14,16384,0]],[[127,14,49152,31]],[[128,14,0,32]],[[255,14,49152,63]],[[256,14,0,64]],[[257,14,16384,64]],[[383,14,49152,95]],[[384,14,0,96]],[[511,14,49152,127]],[[32512,14,0,8128]],[[32513,14,16384,8128]],[[32639,14,49152,8159]],[[32640,14,0,8160]],[[32767,14,49152,8191]],[[32768,14,0,8192]],[[32769,14,16384,8192]],[[32895,14,49152,8223]],[[32896,14,0,8224]],[[33023,14,49152,8255]],[[65280,14,0,16320]],[[65281,14,16384,16320]],[[65407,14,49152,16351]],[[65408,14,0,16352]],[[65535,14,49152,16383]],[[0,15,0,0]],[[1,15,32768,0]],[[127,15,32768,63]],[[128,15,0,64]],[[255,15,32768,127]],[[256,15,0,128]],[[257,15,32768,128]],[[383,15,32768,191]],[[384,15,0,192]],[[511,15,32768,255]],[[32512,15,0,16256]],[[32513,15,32768,16256]],[[32639,15,32768,16319]],[[32640,15,0,16320]],[[32767,15,32768,16383]],[[32768,15,0,16384]],[[32769,15,32768,16384]],[[32895,15,32768,16447]],[[32896,15,0,16448]],[[33023,15,32768,16511]],[[65280,15,0,32640]],[[65281,15,32768,32640]],[[65407,15,32768,32703]],[[65408,15,0,32704]],[[65535,15,32768,32767]],[[12345,0,12345,0]],[[43498,7,62720,84]],[[9115,15,32768,4557]],[[40268,6,21248,39]],[[5885,14,16384,1471]],[[37038,5,5568,18]],[[2655,13,57344,331]],[[33808,4,16640,8]],[[64961,11,2048,2030]],[[30578,3,48016,3]],[[61731,10,35840,964]],[[27348,2,43856,1]],[[58501,9,2560,457]],[[24118,1,48236,0]],[[55271,8,59136,215]],[[20888,0,20888,0]],[[52041,7,42112,101]],[[17658,15,0,8829]],[[48811,6,43712,47]],[[14428,14,0,3607]],[[45581,5,16800,22]],[[11198,13,49152,1399]],[[42351,4,22256,10]],[[7968,12,0,498]],[[39121,3,50824,4]],[[4738,11,4096,148]],[[35891,2,12492,2]],[[1508,10,36864,23]],[[32661,1,65322,0]],[[63814,8,17920,249]],[[29431,0,29431,0]],[[60584,7,21504,118]],[[26201,15,32768,13100]],[[57354,6,640,56]],[[22971,14,49152,5742]],[[54124,5,28032,26]],[[19741,13,40960,2467]],[[50894,4,27872,12]],[[16511,12,61440,1031]],[[47664,3,53632,5]],[[13281,11,2048,415]],[[44434,2,46664,2]],[[10051,10,3072,157]],[[41204,1,16872,1]],[[6821,9,18944,53]],[[37974,0,37974,0]],[[3591,8,1792,14]],[[34744,15,0,17372]],[[361,7,46208,0]],[[31514,14,32768,7878]],[[62667,5,39264,30]],[[28284,13,32768,3535]],[[59437,4,33488,14]],[[25054,12,57344,1565]],[[56207,3,56440,6]],[[21824,11,0,682]],[[52977,2,15300,3]],[[18594,10,34816,290]],[[49747,1,33958,1]],[[15364,9,2048,120]],[[46517,0,46517,0]],[[12134,8,26112,47]],[[43287,15,32768,21643]],[[8904,7,25600,17]],[[40057,14,16384,10014]],[[5674,6,35456,5]],[[36827,13,24576,4603]],[[2444,5,12672,1]],[[33597,12,53248,2099]],[[64750,3,59248,7]],[[30367,11,63488,948]],[[61520,2,49472,3]],[[27137,10,1024,424]],[[58290,1,51044,1]],[[23907,9,50688,186]],[[55060,0,55060,0]],[[20677,8,50432,80]],[[51830,15,0,25915]],[[17447,7,4992,34]],[[48600,14,0,12150]],[[14217,6,57920,13]],[[45370,13,16384,5671]],[[10987,5,23904,5]],[[42140,12,49152,2633]],[[7757,4,58576,1]],[[38910,11,61440,1215]],[[4527,3,36216,0]],[[35680,10,32768,557]],[[1297,2,5188,0]],[[32450,9,33792,253]],[[63603,0,63603,0]],[[29220,8,9216,114]],[[60373,15,32768,30186]],[[25990,7,49920,50]],[[57143,14,49152,14285]],[[22760,6,14848,22]],[[53913,13,8192,6739]],[[19530,5,35136,9]],[[50683,12,45056,3167]],[[16300,4,64192,3]],[[47453,11,59392,1482]],[[13070,3,39024,1]],[[44223,10,64512,690]],[[9840,2,39360,0]],[[40993,9,16896,320]],[[6610,1,13220,0]],[[37763,8,33536,147]],[[3380,0,3380,0]],[[34533,7,29312,67]],[[150,15,0,75]],[[31303,6,37312,30]],[[62456,13,0,7807]],[[28073,5,46368,13]],[[59226,12,40960,3701]],[[24843,4,4272,6]],[[55996,11,57344,1749]],[[21613,3,41832,2]],[[52766,10,30720,824]],[[18383,2,7996,1]],[[49536,9,0,387]],[[15153,1,30306,0]],[[46306,8,57856,180]],[[11923,0,11923,0]],[[43076,7,8704,84]],[[8693,15,32768,4346]],[[39846,6,59776,38]],[[5463,14,49152,1365]],[[36616,5,57600,17]],[[2233,13,8192,279]],[[33386,4,9888,8]],[[64539,11,55296,2016]],[[30156,3,44640,3]],[[61309,10,62464,957]],[[26926,2,42168,1]],[[58079,9,48640,453]],[[23696,1,47392,0]],[[54849,8,16640,214]],[[20466,0,20466,0]],[[51619,7,53632,100]],[[17236,15,0,8618]],[[48389,6,16704,47]],[[14006,14,32768,3501]],[[45159,5,3296,22]],[[10776,13,0,1347]],[[41929,4,15504,10]],[[7546,12,40960,471]],[[38699,3,47448,4]],[[4316,11,57344,134]],[[35469,2,10804,2]],[[1086,10,63488,16]],[[32239,1,64478,0]],[[63392,8,40960,247]],[[29009,0,29009,0]],[[60162,7,33024,117]],[[25779,15,32768,12889]],[[56932,6,39168,55]],[[22549,14,16384,5637]],[[53702,5,14528,26]],[[19319,13,57344,2414]],[[50472,4,21120,12]],[[16089,12,36864,1005]],[[47242,3,50256,5]],[[12859,11,55296,401]],[[44012,2,44976,2]],[[9629,10,29696,150]],[[40782,1,16028,1]],[[6399,9,65024,49]],[[37552,0,37552,0]],[[3169,8,24832,12]],[[34322,15,0,17161]],[[65475,6,61632,63]],[[31092,14,0,7773]],[[62245,5,25760,30]],[[27862,13,49152,3482]],[[59015,4,26736,14]],[[24632,12,32768,1539]],[[55785,3,53064,6]],[[21402,11,53248,668]],[[52555,2,13612,3]],[[18172,10,61440,283]],[[49325,1,33114,1]],[[14942,9,48128,116]],[[46095,0,46095,0]],[[11712,8,49152,45]],[[42865,15,32768,21432]],[[8482,7,37120,16]],[[39635,14,49152,9908]],[[5252,6,8448,5]],[[36405,13,40960,4550]],[[2022,5,64704,0]],[[33175,12,28672,2073]],[[64328,3,55872,7]],[[29945,11,51200,935]],[[61098,2,47784,3]],[[26715,10,27648,417]],[[57868,1,50200,1]],[[23485,9,31232,183]],[[54638,0,54638,0]],[[20255,8,7936,79]],[[51408,15,0,25704]],[[17025,7,16512,33]],[[48178,14,32768,12044]],[[13795,6,30912,13]],[[44948,13,32768,5618]],[[10565,5,10400,5]],[[41718,12,24576,2607]],[[7335,4,51824,1]],[[38488,11,49152,1202]],[[4105,3,32840,0]],[[35258,10,59392,550]],[[875,2,3500,0]],[[32028,9,14336,250]],[[63181,0,63181,0]],[[28798,8,32256,112]],[[59951,15,32768,29975]],[[25568,7,61440,49]],[[56721,14,16384,14180]],[[22338,6,53376,21]],[[53491,13,24576,6686]],[[19108,5,21632,9]],[[50261,12,20480,3141]],[[15878,4,57440,3]],[[47031,11,47104,1469]],[[12648,3,35648,1]],[[43801,10,25600,684]],[[9418,2,37672,0]],[[40571,9,62976,316]],[[6188,1,12376,0]],[[37341,8,56576,145]],[[2958,0,2958,0]],[[34111,7,40832,66]],[[65264,14,0,16316]],[[30881,6,10304,30]],[[62034,13,16384,7754]],[[27651,5,32864,13]],[[58804,12,16384,3675]],[[24421,4,63056,5]],[[55574,11,45056,1736]],[[21191,3,38456,2]],[[52344,10,57344,817]],[[17961,2,6308,1]],[[49114,9,46080,383]],[[14731,1,29462,0]],[[45884,8,15360,179]],[[11501,0,11501,0]],[[42654,7,20224,83]],[[8271,15,32768,4135]],[[39424,6,32768,38]],[[5041,14,16384,1260]],[[36194,5,44096,17]],[[1811,13,24576,226]],[[32964,4,3136,8]],[[64117,11,43008,2003]],[[29734,3,41264,3]],[[60887,10,23552,951]],[[26504,2,40480,1]]],"size":1048576},{"channel":"BYTE_ALU","messages":[[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,0,0,0],[1,0,0,0],[2,0,0,0]],[[0,1,0,0],[1,1,0,1],[2,1,0,1]],[[0,127,0,0],[1,127,0,127],[2,127,0,127]],[[0,128,0,0],[1,128,0,128],[2,128,0,128]],[[0,255,0,0],[1,255,0,255],[2,255,0,255]],[[0,0,1,0],[1,0,1,1],[2,0,1,1]],[[0,1,1,1],[1,1,1,1],[2,1,1,0]],[[0,127,1,1],[1,127,1,127],[2,127,1,126]],[[0,128,1,0],[1,128,1,129],[2,128,1,129]],[[0,255,1,1],[1,255,1,255],[2,255,1,254]],[[0,0,127,0],[1,0,127,127],[2,0,127,127]],[[0,1,127,1],[1,1,127,127],[2,1,127,126]],[[0,127,127,127],[1,127,127,127],[2,127,127,0]],[[0,128,127,0],[1,128,127,255],[2,128,127,255]],[[0,255,127,127],[1,255,127,255],[2,255,127,128]],[[0,0,128,0],[1,0,128,128],[2,0,128,128]],[[0,1,128,0],[1,1,128,129],[2,1,128,129]],[[0,127,128,0],[1,127,128,255],[2,127,128,255]],[[0,128,128,128],[1,128,128,128],[2,128,128,0]],[[0,255,128,128],[1,255,128,255],[2,255,128,127]],[[0,0,255,0],[1,0,255,255],[2,0,255,255]],[[0,1,255,1],[1,1,255,255],[2,1,255,254]],[[0,127,255,127],[1,127,255,255],[2,127,255,128]],[[0,128,255,128],[1,128,255,255],[2,128,255,127]],[[0,255,255,255],[1,255,255,255],[2,255,255,0]],[[0,57,48,48],[1,57,48,57],[2,57,48,9]],[[0,234,169,168],[1,234,169,235],[2,234,169,67]],[[0,155,35,3],[1,155,35,187],[2,155,35,184]],[[0,76,157,12],[1,76,157,221],[2,76,157,209]],[[0,253,22,20],[1,253,22,255],[2,253,22,235]],[[0,174,144,128],[1,174,144,190],[2,174,144,62]],[[0,95,10,10],[1,95,10,95],[2,95,10,85]],[[0,16,132,0],[1,16,132,148],[2,16,132,148]],[[0,193,253,193],[1,193,253,253],[2,193,253,60]],[[0,114,119,114],[1,114,119,119],[2,114,119,5]],[[0,35,241,33],[1,35,241,243],[2,35,241,210]],[[0,212,106,64],[1,212,106,254],[2,212,106,190]],[[0,133,228,132],[1,133,228,229],[2,133,228,97]],[[0,54,94,22],[1,54,94,126],[2,54,94,104]],[[0,231,215,199],[1,231,215,247],[2,231,215,48]],[[0,152,81,16],[1,152,81,217],[2,152,81,201]],[[0,73,203,73],[1,73,203,203],[2,73,203,130]],[[0,250,68,64],[1,250,68,254],[2,250,68,190]],[[0,171,190,170],[1,171,190,191],[2,171,190,21]],[[0,92,56,24],[1,92,56,124],[2,92,56,100]],[[0,13,178,0],[1,13,178,191],[2,13,178,191]],[[0,190,43,42],[1,190,43,191],[2,190,43,149]],[[0,111,165,37],[1,111,165,239],[2,111,165,202]],[[0,32,31,0],[1,32,31,63],[2,32,31,63]],[[0,209,152,144],[1,209,152,217],[2,209,152,73]],[[0,130,18,2],[1,130,18,146],[2,130,18,144]],[[0,51,140,0],[1,51,140,191],[2,51,140,191]],[[0,228,5,4],[1,228,5,229],[2,228,5,225]],[[0,149,127,21],[1,149,127,255],[2,149,127,234]],[[0,70,249,64],[1,70,249,255],[2,70,249,191]],[[0,247,114,114],[1,247,114,247],[2,247,114,133]],[[0,168,236,168],[1,168,236,236],[2,168,236,68]],[[0,89,102,64],[1,89,102,127],[2,89,102,63]],[[0,10,224,0],[1,10,224,234],[2,10,224,234]],[[0,187,89,25],[1,187,89,251],[2,187,89,226]],[[0,108,211,64],[1,108,211,255],[2,108,211,191]],[[0,29,77,13],[1,29,77,93],[2,29,77,80]],[[0,206,198,198],[1,206,198,206],[2,206,198,8]],[[0,127,64,64],[1,127,64,127],[2,127,64,63]],[[0,48,186,48],[1,48,186,186],[2,48,186,138]],[[0,225,51,33],[1,225,51,243],[2,225,51,210]],[[0,146,173,128],[1,146,173,191],[2,146,173,63]],[[0,67,39,3],[1,67,39,103],[2,67,39,100]],[[0,244,160,160],[1,244,160,244],[2,244,160,84]],[[0,165,26,0],[1,165,26,191],[2,165,26,191]],[[0,86,148,20],[1,86,148,214],[2,86,148,194]],[[0,7,14,6],[1,7,14,15],[2,7,14,9]],[[0,184,135,128],[1,184,135,191],[2,184,135,63]],[[0,105,1,1],[1,105,1,105],[2,105,1,104]],[[0,26,123,26],[1,26,123,123],[2,26,123,97]],[[0,203,244,192],[1,203,244,255],[2,203,244,63]],[[0,124,110,108],[1,124,110,126],[2,124,110,18]],[[0,45,232,40],[1,45,232,237],[2,45,232,197]],[[0,222,97,64],[1,222,97,255],[2,222,97,191]],[[0,143,219,139],[1,143,219,223],[2,143,219,84]],[[0,64,85,64],[1,64,85,85],[2,64,85,21]],[[0,241,206,192],[1,241,206,255],[2,241,206,63]],[[0,162,72,0],[1,162,72,234],[2,162,72,234]],[[0,83,194,66],[1,83,194,211],[2,83,194,145]],[[0,4,60,4],[1,4,60,60],[2,4,60,56]],[[0,181,181,181],[1,181,181,181],[2,181,181,0]],[[0,102,47,38],[1,102,47,111],[2,102,47,73]],[[0,23,169,1],[1,23,169,191],[2,23,169,190]],[[0,200,34,0],[1,200,34,234],[2,200,34,234]],[[0,121,156,24],[1,121,156,253],[2,121,156,229]],[[0,42,22,2],[1,42,22,62],[2,42,22,60]],[[0,219,143,139],[1,219,143,223],[2,219,143,84]],[[0,140,9,8],[1,140,9,141],[2,140,9,133]],[[0,61,131,1],[1,61,131,191],[2,61,131,190]],[[0,238,252,236],[1,238,252,254],[2,238,252,18]],[[0,159,118,22],[1,159,118,255],[2,159,118,233]],[[0,80,240,80],[1,80,240,240],[2,80,240,160]],[[0,1,106,0],[1,1,106,107],[2,1,106,107]],[[0,178,227,162],[1,178,227,243],[2,178,227,81]],[[0,99,93,65],[1,99,93,127],[2,99,93,62]],[[0,20,215,20],[1,20,215,215],[2,20,215,195]],[[0,197,80,64],[1,197,80,213],[2,197,80,149]],[[0,118,202,66],[1,118,202,254],[2,118,202,188]],[[0,39,68,4],[1,39,68,103],[2,39,68,99]],[[0,216,189,152],[1,216,189,253],[2,216,189,101]],[[0,137,55,1],[1,137,55,191],[2,137,55,190]],[[0,58,177,48],[1,58,177,187],[2,58,177,139]],[[0,235,42,42],[1,235,42,235],[2,235,42,193]],[[0,156,164,132],[1,156,164,188],[2,156,164,56]],[[0,77,30,12],[1,77,30,95],[2,77,30,83]],[[0,254,151,150],[1,254,151,255],[2,254,151,105]],[[0,175,17,1],[1,175,17,191],[2,175,17,190]],[[0,96,139,0],[1,96,139,235],[2,96,139,235]],[[0,17,5,1],[1,17,5,21],[2,17,5,20]],[[0,194,126,66],[1,194,126,254],[2,194,126,188]],[[0,115,248,112],[1,115,248,251],[2,115,248,139]],[[0,36,114,32],[1,36,114,118],[2,36,114,86]],[[0,213,235,193],[1,213,235,255],[2,213,235,62]],[[0,134,101,4],[1,134,101,231],[2,134,101,227]],[[0,55,223,23],[1,55,223,255],[2,55,223,232]],[[0,232,88,72],[1,232,88,248],[2,232,88,176]],[[0,153,210,144],[1,153,210,219],[2,153,210,75]],[[0,74,76,72],[1,74,76,78],[2,74,76,6]],[[0,251,197,193],[1,251,197,255],[2,251,197,62]],[[0,172,63,44],[1,172,63,191],[2,172,63,147]],[[0,93,185,25],[1,93,185,253],[2,93,185,228]],[[0,14,51,2],[1,14,51,63],[2,14,51,61]],[[0,191,172,172],[1,191,172,191],[2,191,172,19]],[[0,112,38,32],[1,112,38,118],[2,112,38,86]],[[0,33,160,32],[1,33,160,161],[2,33,160,129]],[[0,210,25,16],[1,210,25,219],[2,210,25,203]],[[0,131,147,131],[1,131,147,147],[2,131,147,16]],[[0,52,13,4],[1,52,13,61],[2,52,13,57]],[[0,229,134,132],[1,229,134,231],[2,229,134,99]],[[0,150,0,0],[1,150,0,150],[2,150,0,150]],[[0,71,122,66],[1,71,122,127],[2,71,122,61]],[[0,248,243,240],[1,248,243,251],[2,248,243,11]],[[0,169,109,41],[1,169,109,237],[2,169,109,196]],[[0,90,231,66],[1,90,231,255],[2,90,231,189]],[[0,11,97,1],[1,11,97,107],[2,11,97,106]],[[0,188,218,152],[1,188,218,254],[2,188,218,102]],[[0,109,84,68],[1,109,84,125],[2,109,84,57]],[[0,30,206,14],[1,30,206,222],[2,30,206,208]],[[0,207,71,71],[1,207,71,207],[2,207,71,136]],[[0,128,193,128],[1,128,193,193],[2,128,193,65]],[[0,49,59,49],[1,49,59,59],[2,49,59,10]],[[0,226,180,160],[1,226,180,246],[2,226,180,86]],[[0,147,46,2],[1,147,46,191],[2,147,46,189]],[[0,68,168,0],[1,68,168,236],[2,68,168,236]],[[0,245,33,33],[1,245,33,245],[2,245,33,212]],[[0,166,155,130],[1,166,155,191],[2,166,155,61]],[[0,87,21,21],[1,87,21,87],[2,87,21,66]],[[0,8,143,8],[1,8,143,143],[2,8,143,135]],[[0,185,8,8],[1,185,8,185],[2,185,8,177]],[[0,106,130,2],[1,106,130,234],[2,106,130,232]],[[0,27,252,24],[1,27,252,255],[2,27,252,231]],[[0,204,117,68],[1,204,117,253],[2,204,117,185]],[[0,125,239,109],[1,125,239,255],[2,125,239,146]],[[0,46,105,40],[1,46,105,111],[2,46,105,71]],[[0,223,226,194],[1,223,226,255],[2,223,226,61]],[[0,144,92,16],[1,144,92,220],[2,144,92,204]],[[0,65,214,64],[1,65,214,215],[2,65,214,151]],[[0,242,79,66],[1,242,79,255],[2,242,79,189]],[[0,163,201,129],[1,163,201,235],[2,163,201,106]],[[0,84,67,64],[1,84,67,87],[2,84,67,23]],[[0,5,189,5],[1,5,189,189],[2,5,189,184]],[[0,182,54,54],[1,182,54,182],[2,182,54,128]],[[0,103,176,32],[1,103,176,247],[2,103,176,215]],[[0,24,42,8],[1,24,42,58],[2,24,42,50]],[[0,201,163,129],[1,201,163,235],[2,201,163,106]],[[0,122,29,24],[1,122,29,127],[2,122,29,103]],[[0,43,151,3],[1,43,151,191],[2,43,151,188]],[[0,220,16,16],[1,220,16,220],[2,220,16,204]],[[0,141,138,136],[1,141,138,143],[2,141,138,7]],[[0,62,4,4],[1,62,4,62],[2,62,4,58]],[[0,239,125,109],[1,239,125,255],[2,239,125,146]],[[0,160,247,160],[1,160,247,247],[2,160,247,87]],[[0,81,113,81],[1,81,113,113],[2,81,113,32]],[[0,2,235,2],[1,2,235,235],[2,2,235,233]],[[0,179,100,32],[1,179,100,247],[2,179,100,215]],[[0,100,222,68],[1,100,222,254],[2,100,222,186]],[[0,21,88,16],[1,21,88,93],[2,21,88,77]],[[0,198,209,192],[1,198,209,215],[2,198,209,23]],[[0,119,75,67],[1,119,75,127],[2,119,75,60]],[[0,40,197,0],[1,40,197,237],[2,40,197,237]],[[0,217,62,24],[1,217,62,255],[2,217,62,231]],[[0,138,184,136],[1,138,184,186],[2,138,184,50]],[[0,59,50,50],[1,59,50,59],[2,59,50,9]],[[0,236,171,168],[1,236,171,239],[2,236,171,71]],[[0,157,37,5],[1,157,37,189],[2,157,37,184]],[[0,78,159,14],[1,78,159,223],[2,78,159,209]],[[0,255,24,24],[1,255,24,255],[2,255,24,231]],[[0,176,146,144],[1,176,146,178],[2,176,146,34]],[[0,97,12,0],[1,97,12,109],[2,97,12,109]],[[0,18,134,2],[1,18,134,150],[2,18,134,148]],[[0,195,255,195],[1,195,255,255],[2,195,255,60]],[[0,116,121,112],[1,116,121,125],[2,116,121,13]],[[0,37,243,33],[1,37,243,247],[2,37,243,214]],[[0,214,108,68],[1,214,108,254],[2,214,108,186]],[[0,135,230,134],[1,135,230,231],[2,135,230,97]],[[0,56,96,32],[1,56,96,120],[2,56,96,88]],[[0,233,217,201],[1,233,217,249],[2,233,217,48]],[[0,154,83,18],[1,154,83,219],[2,154,83,201]],[[0,75,205,73],[1,75,205,207],[2,75,205,134]],[[0,252,70,68],[1,252,70,254],[2,252,70,186]],[[0,173,192,128],[1,173,192,237],[2,173,192,109]],[[0,94,58,26],[1,94,58,126],[2,94,58,100]],[[0,15,180,4],[1,15,180,191],[2,15,180,187]],[[0,192,45,0],[1,192,45,237],[2,192,45,237]],[[0,113,167,33],[1,113,167,247],[2,113,167,214]],[[0,34,33,32],[1,34,33,35],[2,34,33,3]],[[0,211,154,146],[1,211,154,219],[2,211,154,73]],[[0,132,20,4],[1,132,20,148],[2,132,20,144]],[[0,53,142,4],[1,53,142,191],[2,53,142,187]],[[0,230,7,6],[1,230,7,231],[2,230,7,225]],[[0,151,129,129],[1,151,129,151],[2,151,129,22]],[[0,72,251,72],[1,72,251,251],[2,72,251,179]],[[0,249,116,112],[1,249,116,253],[2,249,116,141]],[[0,170,238,170],[1,170,238,238],[2,170,238,68]],[[0,91,104,72],[1,91,104,123],[2,91,104,51]],[[0,12,226,0],[1,12,226,238],[2,12,226,238]],[[0,189,91,25],[1,189,91,255],[2,189,91,230]],[[0,110,213,68],[1,110,213,255],[2,110,213,187]],[[0,31,79,15],[1,31,79,95],[2,31,79,80]],[[0,208,200,192],[1,208,200,216],[2,208,200,24]],[[0,129,66,0],[1,129,66,195],[2,129,66,195]],[[0,50,188,48],[1,50,188,190],[2,50,188,142]],[[0,227,53,33],[1,227,53,247],[2,227,53,214]],[[0,148,175,132],[1,148,175,191],[2,148,175,59]],[[0,69,41,1],[1,69,41,109],[2,69,41,108]],[[0,246,162,162],[1,246,162,246],[2,246,162,84]],[[0,167,28,4],[1,167,28,191],[2,167,28,187]],[[0,88,150,16],[1,88,150,222],[2,88,150,206]],[[0,9,16,0],[1,9,16,25],[2,9,16,25]],[[0,186,137,136],[1,186,137,187],[2,186,137,51]],[[0,107,3,3],[1,107,3,107],[2,107,3,104]],[[0,28,125,28],[1,28,125,125],[2,28,125,97]],[[0,205,246,196],[1,205,246,255],[2,205,246,59]],[[0,126,112,112],[1,126,112,126],[2,126,112,14]],[[0,47,234,42],[1,47,234,239],[2,47,234,197]],[[0,224,99,96],[1,224,99,227],[2,224,99,131]],[[0,145,221,145],[1,145,221,221],[2,145,221,76]],[[0,66,87,66],[1,66,87,87],[2,66,87,21]],[[0,243,208,208],[1,243,208,243],[2,243,208,35]],[[0,164,74,0],[1,164,74,238],[2,164,74,238]],[[0,85,196,68],[1,85,196,213],[2,85,196,145]],[[0,6,62,6],[1,6,62,62],[2,6,62,56]],[[0,183,183,183],[1,183,183,183],[2,183,183,0]],[[0,104,49,32],[1,104,49,121],[2,104,49,89]],[[0,25,171,9],[1,25,171,187],[2,25,171,178]],[[0,202,36,0],[1,202,36,238],[2,202,36,238]],[[0,123,158,26],[1,123,158,255],[2,123,158,229]],[[0,44,24,8],[1,44,24,60],[2,44,24,52]],[[0,221,145,145],[1,221,145,221],[2,221,145,76]],[[0,142,11,10],[1,142,11,143],[2,142,11,133]],[[0,63,133,5],[1,63,133,191],[2,63,133,186]],[[0,240,254,240],[1,240,254,254],[2,240,254,14]],[[0,161,120,32],[1,161,120,249],[2,161,120,217]],[[0,82,242,82],[1,82,242,242],[2,82,242,160]],[[0,3,108,0],[1,3,108,111],[2,3,108,111]],[[0,180,229,164],[1,180,229,245],[2,180,229,81]],[[0,101,95,69],[1,101,95,127],[2,101,95,58]],[[0,22,217,16],[1,22,217,223],[2,22,217,207]],[[0,199,82,66],[1,199,82,215],[2,199,82,149]],[[0,120,204,72],[1,120,204,252],[2,120,204,180]],[[0,41,70,0],[1,41,70,111],[2,41,70,111]],[[0,218,191,154],[1,218,191,255],[2,218,191,101]],[[0,139,57,9],[1,139,57,187],[2,139,57,178]],[[0,60,179,48],[1,60,179,191],[2,60,179,143]],[[0,237,44,44],[1,237,44,237],[2,237,44,193]],[[0,158,166,134],[1,158,166,190],[2,158,166,56]],[[0,79,32,0],[1,79,32,111],[2,79,32,111]],[[0,0,154,0],[1,0,154,154],[2,0,154,154]],[[0,177,19,17],[1,177,19,179],[2,177,19,162]],[[0,98,141,0],[1,98,141,239],[2,98,141,239]],[[0,19,7,3],[1,19,7,23],[2,19,7,20]],[[0,196,128,128],[1,196,128,196],[2,196,128,68]],[[0,117,250,112],[1,117,250,255],[2,117,250,143]],[[0,38,116,36],[1,38,116,118],[2,38,116,82]],[[0,215,237,197],[1,215,237,255],[2,215,237,58]],[[0,136,103,0],[1,136,103,239],[2,136,103,239]]],"size":3145728}],"indices":[0,1,127,128,255,256,257,383,384,511,32512,32513,32639,32640,32767,32768,32769,32895,32896,33023,65280,65281,65407,65408,65535,65536,65537,65663,65664,65791,65792,65793,65919,65920,66047,98048,98049,98175,98176,98303,98304,98305,98431,98432,98559,130816,130817,130943,130944,131071,131072,131073,131199,131200,131327,131328,131329,131455,131456,131583,163584,163585,163711,163712,163839,163840,163841,163967,163968,164095,196352,196353,196479,196480,196607,196608,196609,196735,196736,196863,196864,196865,196991,196992,197119,229120,229121,229247,229248,229375,229376,229377,229503,229504,229631,261888,261889,262015,262016,262143,262144,262145,262271,262272,262399,262400,262401,262527,262528,262655,294656,294657,294783,294784,294911,294912,294913,295039,295040,295167,327424,327425,327551,327552,327679,327680,327681,327807,327808,327935,327936,327937,328063,328064,328191,360192,360193,360319,360320,360447,360448,360449,360575,360576,360703,392960,392961,393087,393088,393215,393216,393217,393343,393344,393471,393472,393473,393599,393600,393727,425728,425729,425855,425856,425983,425984,425985,426111,426112,426239,458496,458497,458623,458624,458751,458752,458753,458879,458880,459007,459008,459009,459135,459136,459263,491264,491265,491391,491392,491519,491520,491521,491647,491648,491775,524032,524033,524159,524160,524287,524288,524289,524415,524416,524543,524544,524545,524671,524672,524799,556800,556801,556927,556928,557055,557056,557057,557183,557184,557311,589568,589569,589695,589696,589823,589824,589825,589951,589952,590079,590080,590081,590207,590208,590335,622336,622337,622463,622464,622591,622592,622593,622719,622720,622847,655104,655105,655231,655232,655359,655360,655361,655487,655488,655615,655616,655617,655743,655744,655871,687872,687873,687999,688000,688127,688128,688129,688255,688256,688383,720640,720641,720767,720768,720895,720896,720897,721023,721024,721151,721152,721153,721279,721280,721407,753408,753409,753535,753536,753663,753664,753665,753791,753792,753919,786176,786177,786303,786304,786431,786432,786433,786559,786560,786687,786688,786689,786815,786816,786943,818944,818945,819071,819072,819199,819200,819201,819327,819328,819455,851712,851713,851839,851840,851967,851968,851969,852095,852096,852223,852224,852225,852351,852352,852479,884480,884481,884607,884608,884735,884736,884737,884863,884864,884991,917248,917249,917375,917376,917503,917504,917505,917631,917632,917759,917760,917761,917887,917888,918015,950016,950017,950143,950144,950271,950272,950273,950399,950400,950527,982784,982785,982911,982912,983039,983040,983041,983167,983168,983295,983296,983297,983423,983424,983551,1015552,1015553,1015679,1015680,1015807,1015808,1015809,1015935,1015936,1016063,1048320,1048321,1048447,1048448,1048575,12345,502250,992155,433484,923389,364718,854623,295952,785857,227186,717091,158420,648325,89654,579559,20888,510793,1000698,442027,931932,373261,863166,304495,794400,235729,725634,166963,656868,98197,588102,29431,519336,1009241,450570,940475,381804,871709,313038,802943,244272,734177,175506,665411,106740,596645,37974,527879,1017784,459113,949018,390347,880252,321581,811486,252815,742720,184049,673954,115283,605188,46517,536422,1026327,467656,957561,398890,888795,330124,820029,261358,751263,192592,682497,123826,613731,55060,544965,1034870,476199,966104,407433,897338,338667,828572,269901,759806,201135,691040,132369,622274,63603,553508,1043413,484742,974647,415976,905881,347210,837115,278444,768349,209678,699583,140912,630817,72146,562051,3380,493285,983190,424519,914424,355753,845658,286987,776892,218221,708126,149455,639360,80689,570594,11923,501828,991733,433062,922967,364296,854201,295530,785435,226764,716669,157998,647903,89232,579137,20466,510371,1000276,441605,931510,372839,862744,304073,793978,235307,725212,166541,656446,97775,587680,29009,518914,1008819,450148,940053,381382,871287,312616,802521,243850,733755,175084,664989,106318,596223,37552,527457,1017362,458691,948596,389925,879830,321159,811064,252393,742298,183627,673532,114861,604766,46095,536000,1025905,467234,957139,398468,888373,329702,819607,260936,750841,192170,682075,123404,613309,54638,544543,1034448,475777,965682,407011,896916,338245,828150,269479,759384,200713,690618,131947,621852,63181,553086,1042991,484320,974225,415554,905459,346788,836693,278022,767927,209256,699161,140490,630395,71724,561629,2958,492863,982768,424097,914002,355331,845236,286565,776470,217799,707704,149033,638938,80267,570172,11501,501406,991311,432640,922545,363874,853779,295108,785013,226342,716247,157576],"name":"bitwise","numRows":1048576,"rows":[[0,0,0,0,0,0,0,0,1,0,0],[1,0,0,0,1,1,0,0,0,1,0],[127,0,0,0,127,127,0,0,0,127,0],[128,0,0,0,128,128,1,0,0,128,0],[255,0,0,0,255,255,1,0,0,255,0],[0,1,0,0,1,1,0,0,0,256,0],[1,1,0,1,1,0,0,0,0,257,0],[127,1,0,1,127,126,0,0,0,383,0],[128,1,0,0,129,129,1,0,0,384,0],[255,1,0,1,255,254,1,0,0,511,0],[0,127,0,0,127,127,0,0,0,32512,0],[1,127,0,1,127,126,0,0,0,32513,0],[127,127,0,127,127,0,0,0,0,32639,0],[128,127,0,0,255,255,1,0,0,32640,0],[255,127,0,127,255,128,1,0,0,32767,0],[0,128,0,0,128,128,0,1,0,32768,0],[1,128,0,0,129,129,0,1,0,32769,0],[127,128,0,0,255,255,0,1,0,32895,0],[128,128,0,128,128,0,1,1,0,32896,0],[255,128,0,128,255,127,1,1,0,33023,0],[0,255,0,0,255,255,0,1,0,65280,0],[1,255,0,1,255,254,0,1,0,65281,0],[127,255,0,127,255,128,0,1,0,65407,0],[128,255,0,128,255,127,1,1,0,65408,0],[255,255,0,255,255,0,1,1,0,65535,0],[0,0,1,0,0,0,0,0,0,0,0],[1,0,1,0,1,1,0,0,0,2,0],[127,0,1,0,127,127,0,0,0,254,0],[128,0,1,0,128,128,1,0,0,256,0],[255,0,1,0,255,255,1,0,0,510,0],[0,1,1,0,1,1,0,0,0,512,0],[1,1,1,1,1,0,0,0,0,514,0],[127,1,1,1,127,126,0,0,0,766,0],[128,1,1,0,129,129,1,0,0,768,0],[255,1,1,1,255,254,1,0,0,1022,0],[0,127,1,0,127,127,0,0,0,65024,0],[1,127,1,1,127,126,0,0,0,65026,0],[127,127,1,127,127,0,0,0,0,65278,0],[128,127,1,0,255,255,1,0,0,65280,0],[255,127,1,127,255,128,1,0,0,65534,0],[0,128,1,0,128,128,0,1,0,0,1],[1,128,1,0,129,129,0,1,0,2,1],[127,128,1,0,255,255,0,1,0,254,1],[128,128,1,128,128,0,1,1,0,256,1],[255,128,1,128,255,127,1,1,0,510,1],[0,255,1,0,255,255,0,1,0,65024,1],[1,255,1,1,255,254,0,1,0,65026,1],[127,255,1,127,255,128,0,1,0,65278,1],[128,255,1,128,255,127,1,1,0,65280,1],[255,255,1,255,255,0,1,1,0,65534,1],[0,0,2,0,0,0,0,0,0,0,0],[1,0,2,0,1,1,0,0,0,4,0],[127,0,2,0,127,127,0,0,0,508,0],[128,0,2,0,128,128,1,0,0,512,0],[255,0,2,0,255,255,1,0,0,1020,0],[0,1,2,0,1,1,0,0,0,1024,0],[1,1,2,1,1,0,0,0,0,1028,0],[127,1,2,1,127,126,0,0,0,1532,0],[128,1,2,0,129,129,1,0,0,1536,0],[255,1,2,1,255,254,1,0,0,2044,0],[0,127,2,0,127,127,0,0,0,64512,1],[1,127,2,1,127,126,0,0,0,64516,1],[127,127,2,127,127,0,0,0,0,65020,1],[128,127,2,0,255,255,1,0,0,65024,1],[255,127,2,127,255,128,1,0,0,65532,1],[0,128,2,0,128,128,0,1,0,0,2],[1,128,2,0,129,129,0,1,0,4,2],[127,128,2,0,255,255,0,1,0,508,2],[128,128,2,128,128,0,1,1,0,512,2],[255,128,2,128,255,127,1,1,0,1020,2],[0,255,2,0,255,255,0,1,0,64512,3],[1,255,2,1,255,254,0,1,0,64516,3],[127,255,2,127,255,128,0,1,0,65020,3],[128,255,2,128,255,127,1,1,0,65024,3],[255,255,2,255,255,0,1,1,0,65532,3],[0,0,3,0,0,0,0,0,0,0,0],[1,0,3,0,1,1,0,0,0,8,0],[127,0,3,0,127,127,0,0,0,1016,0],[128,0,3,0,128,128,1,0,0,1024,0],[255,0,3,0,255,255,1,0,0,2040,0],[0,1,3,0,1,1,0,0,0,2048,0],[1,1,3,1,1,0,0,0,0,2056,0],[127,1,3,1,127,126,0,0,0,3064,0],[128,1,3,0,129,129,1,0,0,3072,0],[255,1,3,1,255,254,1,0,0,4088,0],[0,127,3,0,127,127,0,0,0,63488,3],[1,127,3,1,127,126,0,0,0,63496,3],[127,127,3,127,127,0,0,0,0,64504,3],[128,127,3,0,255,255,1,0,0,64512,3],[255,127,3,127,255,128,1,0,0,65528,3],[0,128,3,0,128,128,0,1,0,0,4],[1,128,3,0,129,129,0,1,0,8,4],[127,128,3,0,255,255,0,1,0,1016,4],[128,128,3,128,128,0,1,1,0,1024,4],[255,128,3,128,255,127,1,1,0,2040,4],[0,255,3,0,255,255,0,1,0,63488,7],[1,255,3,1,255,254,0,1,0,63496,7],[127,255,3,127,255,128,0,1,0,64504,7],[128,255,3,128,255,127,1,1,0,64512,7],[255,255,3,255,255,0,1,1,0,65528,7],[0,0,4,0,0,0,0,0,0,0,0],[1,0,4,0,1,1,0,0,0,16,0],[127,0,4,0,127,127,0,0,0,2032,0],[128,0,4,0,128,128,1,0,0,2048,0],[255,0,4,0,255,255,1,0,0,4080,0],[0,1,4,0,1,1,0,0,0,4096,0],[1,1,4,1,1,0,0,0,0,4112,0],[127,1,4,1,127,126,0,0,0,6128,0],[128,1,4,0,129,129,1,0,0,6144,0],[255,1,4,1,255,254,1,0,0,8176,0],[0,127,4,0,127,127,0,0,0,61440,7],[1,127,4,1,127,126,0,0,0,61456,7],[127,127,4,127,127,0,0,0,0,63472,7],[128,127,4,0,255,255,1,0,0,63488,7],[255,127,4,127,255,128,1,0,0,65520,7],[0,128,4,0,128,128,0,1,0,0,8],[1,128,4,0,129,129,0,1,0,16,8],[127,128,4,0,255,255,0,1,0,2032,8],[128,128,4,128,128,0,1,1,0,2048,8],[255,128,4,128,255,127,1,1,0,4080,8],[0,255,4,0,255,255,0,1,0,61440,15],[1,255,4,1,255,254,0,1,0,61456,15],[127,255,4,127,255,128,0,1,0,63472,15],[128,255,4,128,255,127,1,1,0,63488,15],[255,255,4,255,255,0,1,1,0,65520,15],[0,0,5,0,0,0,0,0,0,0,0],[1,0,5,0,1,1,0,0,0,32,0],[127,0,5,0,127,127,0,0,0,4064,0],[128,0,5,0,128,128,1,0,0,4096,0],[255,0,5,0,255,255,1,0,0,8160,0],[0,1,5,0,1,1,0,0,0,8192,0],[1,1,5,1,1,0,0,0,0,8224,0],[127,1,5,1,127,126,0,0,0,12256,0],[128,1,5,0,129,129,1,0,0,12288,0],[255,1,5,1,255,254,1,0,0,16352,0],[0,127,5,0,127,127,0,0,0,57344,15],[1,127,5,1,127,126,0,0,0,57376,15],[127,127,5,127,127,0,0,0,0,61408,15],[128,127,5,0,255,255,1,0,0,61440,15],[255,127,5,127,255,128,1,0,0,65504,15],[0,128,5,0,128,128,0,1,0,0,16],[1,128,5,0,129,129,0,1,0,32,16],[127,128,5,0,255,255,0,1,0,4064,16],[128,128,5,128,128,0,1,1,0,4096,16],[255,128,5,128,255,127,1,1,0,8160,16],[0,255,5,0,255,255,0,1,0,57344,31],[1,255,5,1,255,254,0,1,0,57376,31],[127,255,5,127,255,128,0,1,0,61408,31],[128,255,5,128,255,127,1,1,0,61440,31],[255,255,5,255,255,0,1,1,0,65504,31],[0,0,6,0,0,0,0,0,0,0,0],[1,0,6,0,1,1,0,0,0,64,0],[127,0,6,0,127,127,0,0,0,8128,0],[128,0,6,0,128,128,1,0,0,8192,0],[255,0,6,0,255,255,1,0,0,16320,0],[0,1,6,0,1,1,0,0,0,16384,0],[1,1,6,1,1,0,0,0,0,16448,0],[127,1,6,1,127,126,0,0,0,24512,0],[128,1,6,0,129,129,1,0,0,24576,0],[255,1,6,1,255,254,1,0,0,32704,0],[0,127,6,0,127,127,0,0,0,49152,31],[1,127,6,1,127,126,0,0,0,49216,31],[127,127,6,127,127,0,0,0,0,57280,31],[128,127,6,0,255,255,1,0,0,57344,31],[255,127,6,127,255,128,1,0,0,65472,31],[0,128,6,0,128,128,0,1,0,0,32],[1,128,6,0,129,129,0,1,0,64,32],[127,128,6,0,255,255,0,1,0,8128,32],[128,128,6,128,128,0,1,1,0,8192,32],[255,128,6,128,255,127,1,1,0,16320,32],[0,255,6,0,255,255,0,1,0,49152,63],[1,255,6,1,255,254,0,1,0,49216,63],[127,255,6,127,255,128,0,1,0,57280,63],[128,255,6,128,255,127,1,1,0,57344,63],[255,255,6,255,255,0,1,1,0,65472,63],[0,0,7,0,0,0,0,0,0,0,0],[1,0,7,0,1,1,0,0,0,128,0],[127,0,7,0,127,127,0,0,0,16256,0],[128,0,7,0,128,128,1,0,0,16384,0],[255,0,7,0,255,255,1,0,0,32640,0],[0,1,7,0,1,1,0,0,0,32768,0],[1,1,7,1,1,0,0,0,0,32896,0],[127,1,7,1,127,126,0,0,0,49024,0],[128,1,7,0,129,129,1,0,0,49152,0],[255,1,7,1,255,254,1,0,0,65408,0],[0,127,7,0,127,127,0,0,0,32768,63],[1,127,7,1,127,126,0,0,0,32896,63],[127,127,7,127,127,0,0,0,0,49024,63],[128,127,7,0,255,255,1,0,0,49152,63],[255,127,7,127,255,128,1,0,0,65408,63],[0,128,7,0,128,128,0,1,0,0,64],[1,128,7,0,129,129,0,1,0,128,64],[127,128,7,0,255,255,0,1,0,16256,64],[128,128,7,128,128,0,1,1,0,16384,64],[255,128,7,128,255,127,1,1,0,32640,64],[0,255,7,0,255,255,0,1,0,32768,127],[1,255,7,1,255,254,0,1,0,32896,127],[127,255,7,127,255,128,0,1,0,49024,127],[128,255,7,128,255,127,1,1,0,49152,127],[255,255,7,255,255,0,1,1,0,65408,127],[0,0,8,0,0,0,0,0,0,0,0],[1,0,8,0,1,1,0,0,0,256,0],[127,0,8,0,127,127,0,0,0,32512,0],[128,0,8,0,128,128,1,0,0,32768,0],[255,0,8,0,255,255,1,0,0,65280,0],[0,1,8,0,1,1,0,0,0,0,1],[1,1,8,1,1,0,0,0,0,256,1],[127,1,8,1,127,126,0,0,0,32512,1],[128,1,8,0,129,129,1,0,0,32768,1],[255,1,8,1,255,254,1,0,0,65280,1],[0,127,8,0,127,127,0,0,0,0,127],[1,127,8,1,127,126,0,0,0,256,127],[127,127,8,127,127,0,0,0,0,32512,127],[128,127,8,0,255,255,1,0,0,32768,127],[255,127,8,127,255,128,1,0,0,65280,127],[0,128,8,0,128,128,0,1,0,0,128],[1,128,8,0,129,129,0,1,0,256,128],[127,128,8,0,255,255,0,1,0,32512,128],[128,128,8,128,128,0,1,1,0,32768,128],[255,128,8,128,255,127,1,1,0,65280,128],[0,255,8,0,255,255,0,1,0,0,255],[1,255,8,1,255,254,0,1,0,256,255],[127,255,8,127,255,128,0,1,0,32512,255],[128,255,8,128,255,127,1,1,0,32768,255],[255,255,8,255,255,0,1,1,0,65280,255],[0,0,9,0,0,0,0,0,0,0,0],[1,0,9,0,1,1,0,0,0,512,0],[127,0,9,0,127,127,0,0,0,65024,0],[128,0,9,0,128,128,1,0,0,0,1],[255,0,9,0,255,255,1,0,0,65024,1],[0,1,9,0,1,1,0,0,0,0,2],[1,1,9,1,1,0,0,0,0,512,2],[127,1,9,1,127,126,0,0,0,65024,2],[128,1,9,0,129,129,1,0,0,0,3],[255,1,9,1,255,254,1,0,0,65024,3],[0,127,9,0,127,127,0,0,0,0,254],[1,127,9,1,127,126,0,0,0,512,254],[127,127,9,127,127,0,0,0,0,65024,254],[128,127,9,0,255,255,1,0,0,0,255],[255,127,9,127,255,128,1,0,0,65024,255],[0,128,9,0,128,128,0,1,0,0,256],[1,128,9,0,129,129,0,1,0,512,256],[127,128,9,0,255,255,0,1,0,65024,256],[128,128,9,128,128,0,1,1,0,0,257],[255,128,9,128,255,127,1,1,0,65024,257],[0,255,9,0,255,255,0,1,0,0,510],[1,255,9,1,255,254,0,1,0,512,510],[127,255,9,127,255,128,0,1,0,65024,510],[128,255,9,128,255,127,1,1,0,0,511],[255,255,9,255,255,0,1,1,0,65024,511],[0,0,10,0,0,0,0,0,0,0,0],[1,0,10,0,1,1,0,0,0,1024,0],[127,0,10,0,127,127,0,0,0,64512,1],[128,0,10,0,128,128,1,0,0,0,2],[255,0,10,0,255,255,1,0,0,64512,3],[0,1,10,0,1,1,0,0,0,0,4],[1,1,10,1,1,0,0,0,0,1024,4],[127,1,10,1,127,126,0,0,0,64512,5],[128,1,10,0,129,129,1,0,0,0,6],[255,1,10,1,255,254,1,0,0,64512,7],[0,127,10,0,127,127,0,0,0,0,508],[1,127,10,1,127,126,0,0,0,1024,508],[127,127,10,127,127,0,0,0,0,64512,509],[128,127,10,0,255,255,1,0,0,0,510],[255,127,10,127,255,128,1,0,0,64512,511],[0,128,10,0,128,128,0,1,0,0,512],[1,128,10,0,129,129,0,1,0,1024,512],[127,128,10,0,255,255,0,1,0,64512,513],[128,128,10,128,128,0,1,1,0,0,514],[255,128,10,128,255,127,1,1,0,64512,515],[0,255,10,0,255,255,0,1,0,0,1020],[1,255,10,1,255,254,0,1,0,1024,1020],[127,255,10,127,255,128,0,1,0,64512,1021],[128,255,10,128,255,127,1,1,0,0,1022],[255,255,10,255,255,0,1,1,0,64512,1023],[0,0,11,0,0,0,0,0,0,0,0],[1,0,11,0,1,1,0,0,0,2048,0],[127,0,11,0,127,127,0,0,0,63488,3],[128,0,11,0,128,128,1,0,0,0,4],[255,0,11,0,255,255,1,0,0,63488,7],[0,1,11,0,1,1,0,0,0,0,8],[1,1,11,1,1,0,0,0,0,2048,8],[127,1,11,1,127,126,0,0,0,63488,11],[128,1,11,0,129,129,1,0,0,0,12],[255,1,11,1,255,254,1,0,0,63488,15],[0,127,11,0,127,127,0,0,0,0,1016],[1,127,11,1,127,126,0,0,0,2048,1016],[127,127,11,127,127,0,0,0,0,63488,1019],[128,127,11,0,255,255,1,0,0,0,1020],[255,127,11,127,255,128,1,0,0,63488,1023],[0,128,11,0,128,128,0,1,0,0,1024],[1,128,11,0,129,129,0,1,0,2048,1024],[127,128,11,0,255,255,0,1,0,63488,1027],[128,128,11,128,128,0,1,1,0,0,1028],[255,128,11,128,255,127,1,1,0,63488,1031],[0,255,11,0,255,255,0,1,0,0,2040],[1,255,11,1,255,254,0,1,0,2048,2040],[127,255,11,127,255,128,0,1,0,63488,2043],[128,255,11,128,255,127,1,1,0,0,2044],[255,255,11,255,255,0,1,1,0,63488,2047],[0,0,12,0,0,0,0,0,0,0,0],[1,0,12,0,1,1,0,0,0,4096,0],[127,0,12,0,127,127,0,0,0,61440,7],[128,0,12,0,128,128,1,0,0,0,8],[255,0,12,0,255,255,1,0,0,61440,15],[0,1,12,0,1,1,0,0,0,0,16],[1,1,12,1,1,0,0,0,0,4096,16],[127,1,12,1,127,126,0,0,0,61440,23],[128,1,12,0,129,129,1,0,0,0,24],[255,1,12,1,255,254,1,0,0,61440,31],[0,127,12,0,127,127,0,0,0,0,2032],[1,127,12,1,127,126,0,0,0,4096,2032],[127,127,12,127,127,0,0,0,0,61440,2039],[128,127,12,0,255,255,1,0,0,0,2040],[255,127,12,127,255,128,1,0,0,61440,2047],[0,128,12,0,128,128,0,1,0,0,2048],[1,128,12,0,129,129,0,1,0,4096,2048],[127,128,12,0,255,255,0,1,0,61440,2055],[128,128,12,128,128,0,1,1,0,0,2056],[255,128,12,128,255,127,1,1,0,61440,2063],[0,255,12,0,255,255,0,1,0,0,4080],[1,255,12,1,255,254,0,1,0,4096,4080],[127,255,12,127,255,128,0,1,0,61440,4087],[128,255,12,128,255,127,1,1,0,0,4088],[255,255,12,255,255,0,1,1,0,61440,4095],[0,0,13,0,0,0,0,0,0,0,0],[1,0,13,0,1,1,0,0,0,8192,0],[127,0,13,0,127,127,0,0,0,57344,15],[128,0,13,0,128,128,1,0,0,0,16],[255,0,13,0,255,255,1,0,0,57344,31],[0,1,13,0,1,1,0,0,0,0,32],[1,1,13,1,1,0,0,0,0,8192,32],[127,1,13,1,127,126,0,0,0,57344,47],[128,1,13,0,129,129,1,0,0,0,48],[255,1,13,1,255,254,1,0,0,57344,63],[0,127,13,0,127,127,0,0,0,0,4064],[1,127,13,1,127,126,0,0,0,8192,4064],[127,127,13,127,127,0,0,0,0,57344,4079],[128,127,13,0,255,255,1,0,0,0,4080],[255,127,13,127,255,128,1,0,0,57344,4095],[0,128,13,0,128,128,0,1,0,0,4096],[1,128,13,0,129,129,0,1,0,8192,4096],[127,128,13,0,255,255,0,1,0,57344,4111],[128,128,13,128,128,0,1,1,0,0,4112],[255,128,13,128,255,127,1,1,0,57344,4127],[0,255,13,0,255,255,0,1,0,0,8160],[1,255,13,1,255,254,0,1,0,8192,8160],[127,255,13,127,255,128,0,1,0,57344,8175],[128,255,13,128,255,127,1,1,0,0,8176],[255,255,13,255,255,0,1,1,0,57344,8191],[0,0,14,0,0,0,0,0,0,0,0],[1,0,14,0,1,1,0,0,0,16384,0],[127,0,14,0,127,127,0,0,0,49152,31],[128,0,14,0,128,128,1,0,0,0,32],[255,0,14,0,255,255,1,0,0,49152,63],[0,1,14,0,1,1,0,0,0,0,64],[1,1,14,1,1,0,0,0,0,16384,64],[127,1,14,1,127,126,0,0,0,49152,95],[128,1,14,0,129,129,1,0,0,0,96],[255,1,14,1,255,254,1,0,0,49152,127],[0,127,14,0,127,127,0,0,0,0,8128],[1,127,14,1,127,126,0,0,0,16384,8128],[127,127,14,127,127,0,0,0,0,49152,8159],[128,127,14,0,255,255,1,0,0,0,8160],[255,127,14,127,255,128,1,0,0,49152,8191],[0,128,14,0,128,128,0,1,0,0,8192],[1,128,14,0,129,129,0,1,0,16384,8192],[127,128,14,0,255,255,0,1,0,49152,8223],[128,128,14,128,128,0,1,1,0,0,8224],[255,128,14,128,255,127,1,1,0,49152,8255],[0,255,14,0,255,255,0,1,0,0,16320],[1,255,14,1,255,254,0,1,0,16384,16320],[127,255,14,127,255,128,0,1,0,49152,16351],[128,255,14,128,255,127,1,1,0,0,16352],[255,255,14,255,255,0,1,1,0,49152,16383],[0,0,15,0,0,0,0,0,0,0,0],[1,0,15,0,1,1,0,0,0,32768,0],[127,0,15,0,127,127,0,0,0,32768,63],[128,0,15,0,128,128,1,0,0,0,64],[255,0,15,0,255,255,1,0,0,32768,127],[0,1,15,0,1,1,0,0,0,0,128],[1,1,15,1,1,0,0,0,0,32768,128],[127,1,15,1,127,126,0,0,0,32768,191],[128,1,15,0,129,129,1,0,0,0,192],[255,1,15,1,255,254,1,0,0,32768,255],[0,127,15,0,127,127,0,0,0,0,16256],[1,127,15,1,127,126,0,0,0,32768,16256],[127,127,15,127,127,0,0,0,0,32768,16319],[128,127,15,0,255,255,1,0,0,0,16320],[255,127,15,127,255,128,1,0,0,32768,16383],[0,128,15,0,128,128,0,1,0,0,16384],[1,128,15,0,129,129,0,1,0,32768,16384],[127,128,15,0,255,255,0,1,0,32768,16447],[128,128,15,128,128,0,1,1,0,0,16448],[255,128,15,128,255,127,1,1,0,32768,16511],[0,255,15,0,255,255,0,1,0,0,32640],[1,255,15,1,255,254,0,1,0,32768,32640],[127,255,15,127,255,128,0,1,0,32768,32703],[128,255,15,128,255,127,1,1,0,0,32704],[255,255,15,255,255,0,1,1,0,32768,32767],[57,48,0,48,57,9,0,0,0,12345,0],[234,169,7,168,235,67,1,1,0,62720,84],[155,35,15,3,187,184,1,0,0,32768,4557],[76,157,6,12,221,209,0,1,0,21248,39],[253,22,14,20,255,235,1,0,0,16384,1471],[174,144,5,128,190,62,1,1,0,5568,18],[95,10,13,10,95,85,0,0,0,57344,331],[16,132,4,0,148,148,0,1,0,16640,8],[193,253,11,193,253,60,1,1,0,2048,2030],[114,119,3,114,119,5,0,0,0,48016,3],[35,241,10,33,243,210,0,1,0,35840,964],[212,106,2,64,254,190,1,0,0,43856,1],[133,228,9,132,229,97,1,1,0,2560,457],[54,94,1,22,126,104,0,0,0,48236,0],[231,215,8,199,247,48,1,1,0,59136,215],[152,81,0,16,217,201,1,0,0,20888,0],[73,203,7,73,203,130,0,1,0,42112,101],[250,68,15,64,254,190,1,0,0,0,8829],[171,190,6,170,191,21,1,1,0,43712,47],[92,56,14,24,124,100,0,0,0,0,3607],[13,178,5,0,191,191,0,1,0,16800,22],[190,43,13,42,191,149,1,0,0,49152,1399],[111,165,4,37,239,202,0,1,0,22256,10],[32,31,12,0,63,63,0,0,0,0,498],[209,152,3,144,217,73,1,1,0,50824,4],[130,18,11,2,146,144,1,0,0,4096,148],[51,140,2,0,191,191,0,1,0,12492,2],[228,5,10,4,229,225,1,0,0,36864,23],[149,127,1,21,255,234,1,0,0,65322,0],[70,249,8,64,255,191,0,1,0,17920,249],[247,114,0,114,247,133,1,0,0,29431,0],[168,236,7,168,236,68,1,1,0,21504,118],[89,102,15,64,127,63,0,0,0,32768,13100],[10,224,6,0,234,234,0,1,0,640,56],[187,89,14,25,251,226,1,0,0,49152,5742],[108,211,5,64,255,191,0,1,0,28032,26],[29,77,13,13,93,80,0,0,0,40960,2467],[206,198,4,198,206,8,1,1,0,27872,12],[127,64,12,64,127,63,0,0,0,61440,1031],[48,186,3,48,186,138,0,1,0,53632,5],[225,51,11,33,243,210,1,0,0,2048,415],[146,173,2,128,191,63,1,1,0,46664,2],[67,39,10,3,103,100,0,0,0,3072,157],[244,160,1,160,244,84,1,1,0,16872,1],[165,26,9,0,191,191,1,0,0,18944,53],[86,148,0,20,214,194,0,1,0,37974,0],[7,14,8,6,15,9,0,0,0,1792,14],[184,135,15,128,191,63,1,1,0,0,17372],[105,1,7,1,105,104,0,0,0,46208,0],[26,123,14,26,123,97,0,0,0,32768,7878],[203,244,5,192,255,63,1,1,0,39264,30],[124,110,13,108,126,18,0,0,0,32768,3535],[45,232,4,40,237,197,0,1,0,33488,14],[222,97,12,64,255,191,1,0,0,57344,1565],[143,219,3,139,223,84,1,1,0,56440,6],[64,85,11,64,85,21,0,0,0,0,682],[241,206,2,192,255,63,1,1,0,15300,3],[162,72,10,0,234,234,1,0,0,34816,290],[83,194,1,66,211,145,0,1,0,33958,1],[4,60,9,4,60,56,0,0,0,2048,120],[181,181,0,181,181,0,1,1,0,46517,0],[102,47,8,38,111,73,0,0,0,26112,47],[23,169,15,1,191,190,0,1,0,32768,21643],[200,34,7,0,234,234,1,0,0,25600,17],[121,156,14,24,253,229,0,1,0,16384,10014],[42,22,6,2,62,60,0,0,0,35456,5],[219,143,13,139,223,84,1,1,0,24576,4603],[140,9,5,8,141,133,1,0,0,12672,1],[61,131,12,1,191,190,0,1,0,53248,2099],[238,252,3,236,254,18,1,1,0,59248,7],[159,118,11,22,255,233,1,0,0,63488,948],[80,240,2,80,240,160,0,1,0,49472,3],[1,106,10,0,107,107,0,0,0,1024,424],[178,227,1,162,243,81,1,1,0,51044,1],[99,93,9,65,127,62,0,0,0,50688,186],[20,215,0,20,215,195,0,1,0,55060,0],[197,80,8,64,213,149,1,0,0,50432,80],[118,202,15,66,254,188,0,1,0,0,25915],[39,68,7,4,103,99,0,0,0,4992,34],[216,189,14,152,253,101,1,1,0,0,12150],[137,55,6,1,191,190,1,0,0,57920,13],[58,177,13,48,187,139,0,1,0,16384,5671],[235,42,5,42,235,193,1,0,0,23904,5],[156,164,12,132,188,56,1,1,0,49152,2633],[77,30,4,12,95,83,0,0,0,58576,1],[254,151,11,150,255,105,1,1,0,61440,1215],[175,17,3,1,191,190,1,0,0,36216,0],[96,139,10,0,235,235,0,1,0,32768,557],[17,5,2,1,21,20,0,0,0,5188,0],[194,126,9,66,254,188,1,0,0,33792,253],[115,248,0,112,251,139,0,1,0,63603,0],[36,114,8,32,118,86,0,0,0,9216,114],[213,235,15,193,255,62,1,1,0,32768,30186],[134,101,7,4,231,227,1,0,0,49920,50],[55,223,14,23,255,232,0,1,0,49152,14285],[232,88,6,72,248,176,1,0,0,14848,22],[153,210,13,144,219,75,1,1,0,8192,6739],[74,76,5,72,78,6,0,0,0,35136,9],[251,197,12,193,255,62,1,1,0,45056,3167],[172,63,4,44,191,147,1,0,0,64192,3],[93,185,11,25,253,228,0,1,0,59392,1482],[14,51,3,2,63,61,0,0,0,39024,1],[191,172,10,172,191,19,1,1,0,64512,690],[112,38,2,32,118,86,0,0,0,39360,0],[33,160,9,32,161,129,0,1,0,16896,320],[210,25,1,16,219,203,1,0,0,13220,0],[131,147,8,131,147,16,1,1,0,33536,147],[52,13,0,4,61,57,0,0,0,3380,0],[229,134,7,132,231,99,1,1,0,29312,67],[150,0,15,0,150,150,1,0,0,0,75],[71,122,6,66,127,61,0,0,0,37312,30],[248,243,13,240,251,11,1,1,0,0,7807],[169,109,5,41,237,196,1,0,0,46368,13],[90,231,12,66,255,189,0,1,0,40960,3701],[11,97,4,1,107,106,0,0,0,4272,6],[188,218,11,152,254,102,1,1,0,57344,1749],[109,84,3,68,125,57,0,0,0,41832,2],[30,206,10,14,222,208,0,1,0,30720,824],[207,71,2,71,207,136,1,0,0,7996,1],[128,193,9,128,193,65,1,1,0,0,387],[49,59,1,49,59,10,0,0,0,30306,0],[226,180,8,160,246,86,1,1,0,57856,180],[147,46,0,2,191,189,1,0,0,11923,0],[68,168,7,0,236,236,0,1,0,8704,84],[245,33,15,33,245,212,1,0,0,32768,4346],[166,155,6,130,191,61,1,1,0,59776,38],[87,21,14,21,87,66,0,0,0,49152,1365],[8,143,5,8,143,135,0,1,0,57600,17],[185,8,13,8,185,177,1,0,0,8192,279],[106,130,4,2,234,232,0,1,0,9888,8],[27,252,11,24,255,231,0,1,0,55296,2016],[204,117,3,68,253,185,1,0,0,44640,3],[125,239,10,109,255,146,0,1,0,62464,957],[46,105,2,40,111,71,0,0,0,42168,1],[223,226,9,194,255,61,1,1,0,48640,453],[144,92,1,16,220,204,1,0,0,47392,0],[65,214,8,64,215,151,0,1,0,16640,214],[242,79,0,66,255,189,1,0,0,20466,0],[163,201,7,129,235,106,1,1,0,53632,100],[84,67,15,64,87,23,0,0,0,0,8618],[5,189,6,5,189,184,0,1,0,16704,47],[182,54,14,54,182,128,1,0,0,32768,3501],[103,176,5,32,247,215,0,1,0,3296,22],[24,42,13,8,58,50,0,0,0,0,1347],[201,163,4,129,235,106,1,1,0,15504,10],[122,29,12,24,127,103,0,0,0,40960,471],[43,151,3,3,191,188,0,1,0,47448,4],[220,16,11,16,220,204,1,0,0,57344,134],[141,138,2,136,143,7,1,1,0,10804,2],[62,4,10,4,62,58,0,0,0,63488,16],[239,125,1,109,255,146,1,0,0,64478,0],[160,247,8,160,247,87,1,1,0,40960,247],[81,113,0,81,113,32,0,0,0,29009,0],[2,235,7,2,235,233,0,1,0,33024,117],[179,100,15,32,247,215,1,0,0,32768,12889],[100,222,6,68,254,186,0,1,0,39168,55],[21,88,14,16,93,77,0,0,0,16384,5637],[198,209,5,192,215,23,1,1,0,14528,26],[119,75,13,67,127,60,0,0,0,57344,2414],[40,197,4,0,237,237,0,1,0,21120,12],[217,62,12,24,255,231,1,0,0,36864,1005],[138,184,3,136,186,50,1,1,0,50256,5],[59,50,11,50,59,9,0,0,0,55296,401],[236,171,2,168,239,71,1,1,0,44976,2],[157,37,10,5,189,184,1,0,0,29696,150],[78,159,1,14,223,209,0,1,0,16028,1],[255,24,9,24,255,231,1,0,0,65024,49],[176,146,0,144,178,34,1,1,0,37552,0],[97,12,8,0,109,109,0,0,0,24832,12],[18,134,15,2,150,148,0,1,0,0,17161],[195,255,6,195,255,60,1,1,0,61632,63],[116,121,14,112,125,13,0,0,0,0,7773],[37,243,5,33,247,214,0,1,0,25760,30],[214,108,13,68,254,186,1,0,0,49152,3482],[135,230,4,134,231,97,1,1,0,26736,14],[56,96,12,32,120,88,0,0,0,32768,1539],[233,217,3,201,249,48,1,1,0,53064,6],[154,83,11,18,219,201,1,0,0,53248,668],[75,205,2,73,207,134,0,1,0,13612,3],[252,70,10,68,254,186,1,0,0,61440,283],[173,192,1,128,237,109,1,1,0,33114,1],[94,58,9,26,126,100,0,0,0,48128,116],[15,180,0,4,191,187,0,1,0,46095,0],[192,45,8,0,237,237,1,0,0,49152,45],[113,167,15,33,247,214,0,1,0,32768,21432],[34,33,7,32,35,3,0,0,0,37120,16],[211,154,14,146,219,73,1,1,0,49152,9908],[132,20,6,4,148,144,1,0,0,8448,5],[53,142,13,4,191,187,0,1,0,40960,4550],[230,7,5,6,231,225,1,0,0,64704,0],[151,129,12,129,151,22,1,1,0,28672,2073],[72,251,3,72,251,179,0,1,0,55872,7],[249,116,11,112,253,141,1,0,0,51200,935],[170,238,2,170,238,68,1,1,0,47784,3],[91,104,10,72,123,51,0,0,0,27648,417],[12,226,1,0,238,238,0,1,0,50200,1],[189,91,9,25,255,230,1,0,0,31232,183],[110,213,0,68,255,187,0,1,0,54638,0],[31,79,8,15,95,80,0,0,0,7936,79],[208,200,15,192,216,24,1,1,0,0,25704],[129,66,7,0,195,195,1,0,0,16512,33],[50,188,14,48,190,142,0,1,0,32768,12044],[227,53,6,33,247,214,1,0,0,30912,13],[148,175,13,132,191,59,1,1,0,32768,5618],[69,41,5,1,109,108,0,0,0,10400,5],[246,162,12,162,246,84,1,1,0,24576,2607],[167,28,4,4,191,187,1,0,0,51824,1],[88,150,11,16,222,206,0,1,0,49152,1202],[9,16,3,0,25,25,0,0,0,32840,0],[186,137,10,136,187,51,1,1,0,59392,550],[107,3,2,3,107,104,0,0,0,3500,0],[28,125,9,28,125,97,0,0,0,14336,250],[205,246,0,196,255,59,1,1,0,63181,0],[126,112,8,112,126,14,0,0,0,32256,112],[47,234,15,42,239,197,0,1,0,32768,29975],[224,99,7,96,227,131,1,0,0,61440,49],[145,221,14,145,221,76,1,1,0,16384,14180],[66,87,6,66,87,21,0,0,0,53376,21],[243,208,13,208,243,35,1,1,0,24576,6686],[164,74,5,0,238,238,1,0,0,21632,9],[85,196,12,68,213,145,0,1,0,20480,3141],[6,62,4,6,62,56,0,0,0,57440,3],[183,183,11,183,183,0,1,1,0,47104,1469],[104,49,3,32,121,89,0,0,0,35648,1],[25,171,10,9,187,178,0,1,0,25600,684],[202,36,2,0,238,238,1,0,0,37672,0],[123,158,9,26,255,229,0,1,0,62976,316],[44,24,1,8,60,52,0,0,0,12376,0],[221,145,8,145,221,76,1,1,0,56576,145],[142,11,0,10,143,133,1,0,0,2958,0],[63,133,7,5,191,186,0,1,0,40832,66],[240,254,14,240,254,14,1,1,0,0,16316],[161,120,6,32,249,217,1,0,0,10304,30],[82,242,13,82,242,160,0,1,0,16384,7754],[3,108,5,0,111,111,0,0,0,32864,13],[180,229,12,164,245,81,1,1,0,16384,3675],[101,95,4,69,127,58,0,0,0,63056,5],[22,217,11,16,223,207,0,1,0,45056,1736],[199,82,3,66,215,149,1,0,0,38456,2],[120,204,10,72,252,180,0,1,0,57344,817],[41,70,2,0,111,111,0,0,0,6308,1],[218,191,9,154,255,101,1,1,0,46080,383],[139,57,1,9,187,178,1,0,0,29462,0],[60,179,8,48,191,143,0,1,0,15360,179],[237,44,0,44,237,193,1,0,0,11501,0],[158,166,7,134,190,56,1,1,0,20224,83],[79,32,15,0,111,111,0,0,0,32768,4135],[0,154,6,0,154,154,0,1,0,32768,38],[177,19,14,17,179,162,1,0,0,16384,1260],[98,141,5,0,239,239,0,1,0,44096,17],[19,7,13,3,23,20,0,0,0,24576,226],[196,128,4,128,196,68,1,1,0,3136,8],[117,250,11,112,255,143,0,1,0,43008,2003],[38,116,3,36,118,82,0,0,0,41264,3],[215,237,10,197,255,58,1,1,0,23552,951],[136,103,2,0,239,239,1,0,0,40480,1]]} \ No newline at end of file diff --git a/formal/export/eq.json b/formal/export/eq.json new file mode 100644 index 000000000..7a6ec8d5b --- /dev/null +++ b/formal/export/eq.json @@ -0,0 +1,225 @@ +{"operations": + [{"interact": + {"multiplicity": {"type": "var", "index": 11}, + "message": [{"type": "var", "index": 6}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 11}, + "message": [{"type": "var", "index": 7}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 11}, + "message": [{"type": "var", "index": 8}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 11}, + "message": [{"type": "var", "index": 9}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 4}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 4}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 7}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 6}}, + "lhs": {"type": "var", "index": 2}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 7}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 6}}, + "lhs": {"type": "var", "index": 2}}}}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 1}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 7}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 6}}, + "lhs": {"type": "var", "index": 2}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 1}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 7}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 6}}, + "lhs": {"type": "var", "index": 2}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}}}}, + {"interact": + {"multiplicity": {"type": "var", "index": 11}, + "message": + [{"type": "add", + "rhs": {"type": "var", "index": 9}, + "lhs": + {"type": "add", + "rhs": {"type": "var", "index": 8}, + "lhs": + {"type": "add", "rhs": {"type": "var", "index": 7}, "lhs": {"type": "var", "index": 6}}}}, + {"type": "var", "index": 10}], + "direction": "pull", + "channel": "ZERO"}}, + {"assert": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 4}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 10}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 4}, + "lhs": + {"type": "mul", "rhs": {"type": "var", "index": 10}, "lhs": {"value": 2, "type": "const"}}}, + "lhs": {"type": "var", "index": 5}}}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 11}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 11}}}, + {"interact": + {"multiplicity": {"type": "var", "index": 11}, + "message": + [{"type": "var", "index": 0}, + {"type": "var", "index": 1}, + {"type": "var", "index": 2}, + {"type": "var", "index": 3}, + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 4}, "lhs": {"value": 64, "type": "const"}}, + "lhs": {"value": 3, "type": "const"}}, + {"type": "var", "index": 5}, + {"value": 0, "type": "const"}], + "direction": "push", + "channel": "ALU"}}], + "name": "eq", + "columns": 12} \ No newline at end of file diff --git a/formal/export/lt.json b/formal/export/lt.json new file mode 100644 index 000000000..800c9d42d --- /dev/null +++ b/formal/export/lt.json @@ -0,0 +1,478 @@ +{"operations": + [{"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 16}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 16}}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": [{"type": "var", "index": 1}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": [{"type": "var", "index": 4}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 6}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 6}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 14}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 14}}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": [{"type": "var", "index": 2}, {"type": "var", "index": 12}], + "direction": "pull", + "channel": "MSB16"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": [{"type": "var", "index": 5}, {"type": "var", "index": 13}], + "direction": "pull", + "channel": "MSB16"}}, + {"assert": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 2}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 1}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 11}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 10}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 4}}}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 6}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 2}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 1}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 11}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 10}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 4}}}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 13}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 2}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 1}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 11}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 10}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 4}}}}}}, + "lhs": {"type": "var", "index": 12}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 13}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 12}}}}, + "lhs": {"type": "var", "index": 6}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 7}}}, + {"assert": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 14}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 7}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 14}, + "lhs": + {"type": "mul", "rhs": {"type": "var", "index": 7}, "lhs": {"value": 2, "type": "const"}}}, + "lhs": {"type": "var", "index": 15}}}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 2}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 1}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 11}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 10}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 4}}}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 2}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 1}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"value": 18446744065119617026, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 0}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 9}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}, + "lhs": {"type": "var", "index": 3}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 11}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 10}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 4}}}}}}}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": [{"type": "var", "index": 8}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": [{"type": "var", "index": 9}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": [{"type": "var", "index": 10}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": [{"type": "var", "index": 11}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 16}, + "message": + [{"type": "var", "index": 0}, + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 2}, "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 1}}, + {"type": "var", "index": 3}, + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 5}, "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 4}}, + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 14}, "lhs": {"value": 64, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 6}, "lhs": {"value": 32, "type": "const"}}, + "lhs": {"value": 4, "type": "const"}}}, + {"type": "var", "index": 15}, + {"value": 0, "type": "const"}], + "direction": "push", + "channel": "ALU"}}], + "name": "lt", + "columns": 17} \ No newline at end of file diff --git a/formal/export/shift.json b/formal/export/shift.json new file mode 100644 index 000000000..13f556ca7 --- /dev/null +++ b/formal/export/shift.json @@ -0,0 +1,852 @@ +{"operations": + [{"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 25}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 5}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}, + "lhs": {"type": "var", "index": 0}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 13}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}, + "lhs": {"type": "var", "index": 1}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 14}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}, + "lhs": {"type": "var", "index": 2}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 15}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}, + "lhs": {"type": "var", "index": 3}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 16}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", "rhs": {"type": "var", "index": 17}, "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 5}, "lhs": {"type": "var", "index": 0}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 18}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 5}, "lhs": {"type": "var", "index": 1}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 19}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 5}, "lhs": {"type": "var", "index": 2}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 20}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 5}, "lhs": {"type": "var", "index": 3}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 21}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 22}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 23}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 23}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 24}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 24}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 24}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 23}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 24}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 23}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}}}}, + {"assert": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 65536, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 24}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 23}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}}, + "lhs": + {"type": "mul", + "rhs": {"type": "var", "index": 10}, + "lhs": {"value": 65535, "type": "const"}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 17}, + "lhs": {"type": "var", "index": 21}}, + "lhs": {"type": "var", "index": 24}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 16}, + "lhs": {"type": "var", "index": 20}}, + "lhs": {"type": "var", "index": 23}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 15}, + "lhs": {"type": "var", "index": 19}}, + "lhs": {"type": "var", "index": 22}}}}}, + "lhs": {"type": "var", "index": 5}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 13}, "lhs": {"type": "var", "index": 23}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", "rhs": {"type": "var", "index": 18}, "lhs": {"type": "var", "index": 14}}, + "lhs": {"type": "var", "index": 22}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", "rhs": {"type": "var", "index": 17}, "lhs": {"type": "var", "index": 21}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 24}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 23}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 16}, + "lhs": {"type": "var", "index": 20}}, + "lhs": {"type": "var", "index": 24}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 15}, + "lhs": {"type": "var", "index": 19}}, + "lhs": {"type": "var", "index": 23}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 14}, + "lhs": {"type": "var", "index": 18}}, + "lhs": {"type": "var", "index": 22}}}}}, + "lhs": {"type": "var", "index": 5}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 13}, "lhs": {"type": "var", "index": 22}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 8}}}}, + {"assert": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"value": 65536, "type": "const"}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 24}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 23}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}}, + "lhs": + {"type": "add", + "rhs": {"type": "var", "index": 24}, + "lhs": {"type": "var", "index": 23}}}, + "lhs": + {"type": "mul", + "rhs": {"type": "var", "index": 10}, + "lhs": {"value": 65535, "type": "const"}}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", "rhs": {"type": "var", "index": 17}, "lhs": {"type": "var", "index": 21}}, + "lhs": {"type": "var", "index": 22}}}, + "lhs": {"type": "var", "index": 5}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 13}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 24}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 23}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 18}, + "lhs": {"type": "var", "index": 14}}, + "lhs": {"type": "var", "index": 24}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 19}, + "lhs": {"type": "var", "index": 15}}, + "lhs": {"type": "var", "index": 23}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 20}, + "lhs": {"type": "var", "index": 16}}, + "lhs": {"type": "var", "index": 22}}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 24}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 23}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}}, + "lhs": {"type": "var", "index": 24}}, + "lhs": + {"type": "mul", + "rhs": {"type": "var", "index": 10}, + "lhs": {"value": 65535, "type": "const"}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 17}, + "lhs": {"type": "var", "index": 21}}, + "lhs": {"type": "var", "index": 23}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 16}, + "lhs": {"type": "var", "index": 20}}, + "lhs": {"type": "var", "index": 22}}}}, + "lhs": {"type": "var", "index": 5}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 13}, "lhs": {"type": "var", "index": 24}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 18}, + "lhs": {"type": "var", "index": 14}}, + "lhs": {"type": "var", "index": 23}}, + "lhs": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": {"type": "var", "index": 19}, + "lhs": {"type": "var", "index": 15}}, + "lhs": {"type": "var", "index": 22}}}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 9}}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 5}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 6}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 6}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 7}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 7}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 12}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 12}}}, + {"assert": + {"type": "mul", + "rhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 25}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}}, + {"assert": + {"type": "mul", + "rhs": {"type": "var", "index": 10}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 6}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}}}, + {"interact": + {"multiplicity": {"type": "var", "index": 6}, + "message": [{"type": "var", "index": 3}, {"type": "var", "index": 10}], + "direction": "pull", + "channel": "MSB16"}}, + {"interact": + {"multiplicity": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 5}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"type": "var", "index": 25}}, + "message": + [{"value": 0, "type": "const"}, + {"type": "var", "index": 4}, + {"value": 15, "type": "const"}, + {"type": "var", "index": 11}], + "direction": "pull", + "channel": "BYTE_ALU"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 5}, + "message": + [{"value": 0, "type": "const"}, + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 4}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 12}, "lhs": {"value": 16, "type": "const"}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 256, "type": "const"}}}, + {"value": 15, "type": "const"}, + {"type": "var", "index": 11}], + "direction": "pull", + "channel": "BYTE_ALU"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 25}, + "message": [{"type": "var", "index": 11}, {"type": "var", "index": 12}], + "direction": "pull", + "channel": "ZERO"}}, + {"interact": + {"multiplicity": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 12}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "message": + [{"type": "var", "index": 0}, + {"type": "var", "index": 11}, + {"type": "var", "index": 13}, + {"type": "var", "index": 18}], + "direction": "pull", + "channel": "HWSL"}}, + {"interact": + {"multiplicity": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 12}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "message": + [{"type": "var", "index": 1}, + {"type": "var", "index": 11}, + {"type": "var", "index": 14}, + {"type": "var", "index": 19}], + "direction": "pull", + "channel": "HWSL"}}, + {"interact": + {"multiplicity": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 12}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "message": + [{"type": "var", "index": 2}, + {"type": "var", "index": 11}, + {"type": "var", "index": 15}, + {"type": "var", "index": 20}], + "direction": "pull", + "channel": "HWSL"}}, + {"interact": + {"multiplicity": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 12}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "message": + [{"type": "var", "index": 3}, + {"type": "var", "index": 11}, + {"type": "var", "index": 16}, + {"type": "var", "index": 21}], + "direction": "pull", + "channel": "HWSL"}}, + {"interact": + {"multiplicity": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 12}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 1, "type": "const"}}, + "message": + [{"type": "mul", "rhs": {"type": "var", "index": 10}, "lhs": {"value": 65535, "type": "const"}}, + {"type": "var", "index": 11}, + {"type": "var", "index": 17}, + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 17}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "mul", + "rhs": {"type": "var", "index": 10}, + "lhs": {"value": 65535, "type": "const"}}}], + "direction": "pull", + "channel": "HWSL"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 25}, + "message": + [{"value": 0, "type": "const"}, + {"type": "var", "index": 4}, + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 7}, "lhs": {"value": 32, "type": "const"}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 48, "type": "const"}}, + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 24}, "lhs": {"value": 16, "type": "const"}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 23}, "lhs": {"value": 32, "type": "const"}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 22}, + "lhs": {"value": 48, "type": "const"}}, + "lhs": {"value": 18446744069414584320, "type": "const"}}, + "lhs": {"value": 48, "type": "const"}}}}], + "direction": "pull", + "channel": "BYTE_ALU"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 25}, + "message": + [{"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 1}, "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 0}}, + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 3}, "lhs": {"value": 65536, "type": "const"}}, + "lhs": {"type": "var", "index": 2}}, + {"type": "add", + "rhs": + {"type": "mul", + "rhs": {"type": "var", "index": 27}, + "lhs": {"value": 65536, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 26}, "lhs": {"value": 256, "type": "const"}}, + "lhs": {"type": "var", "index": 4}}}, + {"type": "var", "index": 28}, + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 5}, "lhs": {"value": 64, "type": "const"}}, + "lhs": + {"type": "add", + "rhs": + {"type": "mul", "rhs": {"type": "var", "index": 6}, "lhs": {"value": 32, "type": "const"}}, + "lhs": + {"type": "add", "rhs": {"type": "var", "index": 7}, "lhs": {"value": 5, "type": "const"}}}}, + {"type": "var", "index": 8}, + {"type": "var", "index": 9}], + "direction": "push", + "channel": "ALU"}}, + {"interact": + {"multiplicity": {"value": 1, "type": "const"}, + "message": [{"type": "var", "index": 4}, {"type": "var", "index": 26}], + "direction": "pull", + "channel": "ARE_BYTES"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 25}, + "message": [{"type": "var", "index": 27}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 25}, + "message": [{"type": "var", "index": 0}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 25}, + "message": [{"type": "var", "index": 1}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 25}, + "message": [{"type": "var", "index": 2}], + "direction": "pull", + "channel": "IS_HALF"}}, + {"interact": + {"multiplicity": {"type": "var", "index": 25}, + "message": [{"type": "var", "index": 3}], + "direction": "pull", + "channel": "IS_HALF"}}], + "name": "shift", + "columns": 29} \ No newline at end of file diff --git a/formal/lake-manifest.json b/formal/lake-manifest.json new file mode 100644 index 000000000..ca5842997 --- /dev/null +++ b/formal/lake-manifest.json @@ -0,0 +1,116 @@ +{"version": "1.3.0", + "packagesDir": ".lake/packages", + "packages": + [{"url": "https://github.com/Verified-zkEVM/clean", + "type": "git", + "subDir": null, + "scope": "", + "rev": "f3abad7c099e49f847836c1883dd9e7c539f06f9", + "name": "Clean", + "manifestFile": "lake-manifest.json", + "inputRev": "f3abad7c099e49f847836c1883dd9e7c539f06f9", + "inherited": false, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/Verified-zkEVM/CompPoly.git", + "type": "git", + "subDir": null, + "scope": "", + "rev": "06686e4c70939af82203af21516f8ab8a21a8051", + "name": "CompPoly", + "manifestFile": "lake-manifest.json", + "inputRev": "v4.35.0", + "inherited": true, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/leanprover-community/mathlib4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "56a005855ea17e0b0958f73ec801ae140b0a1679", + "name": "mathlib", + "manifestFile": "lake-manifest.json", + "inputRev": "v4.35.0", + "inherited": true, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/leanprover-community/plausible", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "dfa4f38190d07c37e315953e08b90fe2d95b3c24", + "name": "plausible", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/LeanSearchClient", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "d6b4c7be5be75ec4917c873ac50c756dc1436372", + "name": "LeanSearchClient", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/import-graph", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "a41f0e9a4dea23188ea9cc1c41ac9f8bbafe0b93", + "name": "importGraph", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/ProofWidgets4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "df72b022e558978a1c50264cfc4d7fec86fa8e04", + "name": "proofwidgets", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/leanprover-community/aesop", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "4a174c490d8707121c4a9290800489f105d85e07", + "name": "aesop", + "manifestFile": "lake-manifest.json", + "inputRev": "master", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/quote4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "dce0ad79c486cb1fb504af04f953c3466b0c6db8", + "name": "Qq", + "manifestFile": "lake-manifest.json", + "inputRev": "master", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/batteries", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "66e469188fe07963e5cf666c7d4433f45b8131c5", + "name": "batteries", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover/lean4-cli", + "type": "git", + "subDir": null, + "scope": "leanprover", + "rev": "c24fe6078c630e89b489bffe59b3e20ac30d12c8", + "name": "Cli", + "manifestFile": "lake-manifest.json", + "inputRev": "v4.35.0", + "inherited": true, + "configFile": "lakefile.toml"}], + "name": "«lambda-vm-formal»", + "lakeDir": ".lake", + "fixedToolchain": false} diff --git a/formal/lakefile.toml b/formal/lakefile.toml new file mode 100644 index 000000000..8c801fdea --- /dev/null +++ b/formal/lakefile.toml @@ -0,0 +1,20 @@ +name = "lambda-vm-formal" +defaultTargets = ["LambdaVM", "LambdaVMExport"] + +[leanOptions] +autoImplicit = false +relaxedAutoImplicit = false + +# Clean pinned to a revision; Mathlib and CompPoly come in through Clean's manifest. +[[require]] +name = "Clean" +git = "https://github.com/Verified-zkEVM/clean" +rev = "f3abad7c099e49f847836c1883dd9e7c539f06f9" + +[[lean_lib]] +name = "LambdaVM" + +# The export script, so that `lake build` also compiles its dependency `Clean.Circuit.Json`. +[[lean_lib]] +name = "LambdaVMExport" +roots = ["LambdaVM.Export"] diff --git a/formal/lean-toolchain b/formal/lean-toolchain new file mode 100644 index 000000000..a6aff065d --- /dev/null +++ b/formal/lean-toolchain @@ -0,0 +1 @@ +leanprover/lean4:v4.35.0 diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 7401485cf..06f462567 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -33,6 +33,7 @@ digest = "0.10.7" rkyv = { version = "0.8.10", default-features = false, features = ["alloc", "bytecheck", "aligned", "pointer_width_64"] } [dev-dependencies] +serde_json = "1" env_logger = "*" criterion = { version = "0.5", default-features = false } tikv-jemallocator = "0.6" diff --git a/prover/src/tests/constraint_emit_tests.rs b/prover/src/tests/constraint_emit_tests.rs index 095ea2af7..e8962d77f 100644 --- a/prover/src/tests/constraint_emit_tests.rs +++ b/prover/src/tests/constraint_emit_tests.rs @@ -19,6 +19,7 @@ use stark::frame::Frame; use stark::table::TableView; use stark::traits::TransitionEvaluationContext; +use super::test_rng::SplitMix64; use crate::constraints::cpu::{ emit_arg2, emit_arg2_exclusive, emit_branch_cond, emit_branch_rvd_pair, emit_mem_flags_bit, emit_next_pc_add_pair, emit_product_zero, emit_reg_not_read_is_zero, emit_rvd_eq_res, @@ -34,18 +35,6 @@ type Fp3 = FieldElement; const TRIALS: usize = 1000; const NUM_COLS: usize = cols::NUM_COLUMNS; -/// Deterministic SplitMix64. -struct SplitMix64(u64); -impl SplitMix64 { - fn next_u64(&mut self) -> u64 { - self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); - z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); - z ^ (z >> 31) - } -} - /// An emit body under test: emits `n` base constraints at indices `0..n`. trait EmitBody { fn n(&self) -> usize; diff --git a/prover/src/tests/constraint_program_device_tests.rs b/prover/src/tests/constraint_program_device_tests.rs index c41f02493..a8bd71e09 100644 --- a/prover/src/tests/constraint_program_device_tests.rs +++ b/prover/src/tests/constraint_program_device_tests.rs @@ -23,6 +23,7 @@ use stark::proof::options::GoldilocksCubicProofOptions; use stark::table::TableView; use stark::traits::{AIR, TransitionEvaluationContext}; +use super::test_rng::SplitMix64; use crate::tables::types::{GoldilocksExtension, GoldilocksField}; use crate::test_utils::*; @@ -33,23 +34,12 @@ type Fp3 = FieldElement; const TRIALS: usize = 200; -/// Deterministic SplitMix64 (no `rand` dependency). -struct SplitMix64(u64); -impl SplitMix64 { - fn next_u64(&mut self) -> u64 { - self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); - z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); - z ^ (z >> 31) - } - fn fp3(&mut self) -> Fp3 { - Fp3::new([ - Fp::from(self.next_u64()), - Fp::from(self.next_u64()), - Fp::from(self.next_u64()), - ]) - } +fn fp3(rng: &mut SplitMix64) -> Fp3 { + Fp3::new([ + Fp::from(rng.next_u64()), + Fp::from(rng.next_u64()), + Fp::from(rng.next_u64()), + ]) } /// Extension element → raw `[u64; 3]` limbs (the device representation). @@ -81,13 +71,15 @@ fn check_air_device( for trial in 0..TRIALS { let mk_step = |rng: &mut SplitMix64| { let main: Vec = (0..n_main).map(|_| Fp::from(rng.next_u64())).collect(); - let aux: Vec = (0..n_aux).map(|_| rng.fp3()).collect(); + let aux: Vec = (0..n_aux).map(|_| fp3(rng)).collect(); TableView::new(vec![main], vec![aux]) }; let frame = Frame::::new(vec![mk_step(&mut rng), mk_step(&mut rng)]); - let challenges = vec![rng.fp3(), rng.fp3()]; // [z, alpha] - let alphas: Vec = (0..air.max_bus_elements() + 2).map(|_| rng.fp3()).collect(); - let offset = rng.fp3(); + let challenges = vec![fp3(&mut rng), fp3(&mut rng)]; // [z, alpha] + let alphas: Vec = (0..air.max_bus_elements() + 2) + .map(|_| fp3(&mut rng)) + .collect(); + let offset = fp3(&mut rng); // Raw-limb inputs for the device walk, extracted from the frame. let main_raw: Vec> = (0..2) diff --git a/prover/src/tests/constraint_program_tests.rs b/prover/src/tests/constraint_program_tests.rs index 2bd7bbe92..c1805d4bd 100644 --- a/prover/src/tests/constraint_program_tests.rs +++ b/prover/src/tests/constraint_program_tests.rs @@ -23,6 +23,7 @@ use stark::proof::options::GoldilocksCubicProofOptions; use stark::table::TableView; use stark::traits::{AIR, TransitionEvaluationContext}; +use super::test_rng::SplitMix64; use crate::tables::types::{GoldilocksExtension, GoldilocksField}; use crate::test_utils::*; @@ -33,23 +34,12 @@ type Fp3 = FieldElement; const TRIALS: usize = 200; -/// Deterministic SplitMix64 (no `rand` dependency). -struct SplitMix64(u64); -impl SplitMix64 { - fn next_u64(&mut self) -> u64 { - self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); - z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); - z ^ (z >> 31) - } - fn fp3(&mut self) -> Fp3 { - Fp3::new([ - Fp::from(self.next_u64()), - Fp::from(self.next_u64()), - Fp::from(self.next_u64()), - ]) - } +fn fp3(rng: &mut SplitMix64) -> Fp3 { + Fp3::new([ + Fp::from(rng.next_u64()), + Fp::from(rng.next_u64()), + Fp::from(rng.next_u64()), + ]) } /// The differential for one production AIR: capture the combined program @@ -79,13 +69,15 @@ fn check_air(air: &dyn AIR // Random two-step prover frame shaped like this table. let mk_step = |rng: &mut SplitMix64| { let main: Vec = (0..n_main).map(|_| Fp::from(rng.next_u64())).collect(); - let aux: Vec = (0..n_aux).map(|_| rng.fp3()).collect(); + let aux: Vec = (0..n_aux).map(|_| fp3(rng)).collect(); TableView::new(vec![main], vec![aux]) }; let frame = Frame::::new(vec![mk_step(&mut rng), mk_step(&mut rng)]); - let challenges = vec![rng.fp3(), rng.fp3()]; // [z, alpha] - let alphas: Vec = (0..air.max_bus_elements() + 2).map(|_| rng.fp3()).collect(); - let offset = rng.fp3(); + let challenges = vec![fp3(&mut rng), fp3(&mut rng)]; // [z, alpha] + let alphas: Vec = (0..air.max_bus_elements() + 2) + .map(|_| fp3(&mut rng)) + .collect(); + let offset = fp3(&mut rng); let ctx = TransitionEvaluationContext::new_prover( frame.as_row_frame(), diff --git a/prover/src/tests/constraint_set_tests_a.rs b/prover/src/tests/constraint_set_tests_a.rs index 571ae2da3..98e51083b 100644 --- a/prover/src/tests/constraint_set_tests_a.rs +++ b/prover/src/tests/constraint_set_tests_a.rs @@ -20,6 +20,7 @@ use stark::frame::Frame; use stark::table::TableView; use stark::traits::TransitionEvaluationContext; +use super::test_rng::SplitMix64; use crate::tables::types::{FE, GoldilocksExtension, GoldilocksField}; type Gl = GoldilocksField; @@ -28,18 +29,6 @@ type Fp3 = FieldElement; const TRIALS: usize = 1000; -/// Deterministic SplitMix64. -struct SplitMix64(u64); -impl SplitMix64 { - fn next_u64(&mut self) -> u64 { - self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); - z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); - z ^ (z >> 31) - } -} - /// Folder-vs-capture-interpret regression check for one table's /// [`ConstraintSet`]. The single body is run three ways (prover folder, verifier /// folder, captured-IR interpreter) and asserted to agree on random off-trace diff --git a/prover/src/tests/constraint_set_tests_b.rs b/prover/src/tests/constraint_set_tests_b.rs index 6a19dbb25..8726f41e1 100644 --- a/prover/src/tests/constraint_set_tests_b.rs +++ b/prover/src/tests/constraint_set_tests_b.rs @@ -24,6 +24,7 @@ use stark::frame::Frame; use stark::table::TableView; use stark::traits::TransitionEvaluationContext; +use super::test_rng::SplitMix64; use crate::tables::types::{FE, GoldilocksExtension, GoldilocksField}; type Gl = GoldilocksField; @@ -32,18 +33,6 @@ type Fp3 = FieldElement; const TRIALS: usize = 1000; -/// Deterministic SplitMix64. -struct SplitMix64(u64); -impl SplitMix64 { - fn next_u64(&mut self) -> u64 { - self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15); - let mut z = self.0; - z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); - z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); - z ^ (z >> 31) - } -} - /// Run the folder-vs-capture-interpret differential + meta invariants for one /// table's [`ConstraintSet`]. All three interpretations derive from the ONE /// single-source body, so agreement across them (on random off-trace rows) is a diff --git a/prover/src/tests/lean_diff.rs b/prover/src/tests/lean_diff.rs new file mode 100644 index 000000000..e2eb473e0 --- /dev/null +++ b/prover/src/tests/lean_diff.rs @@ -0,0 +1,814 @@ +//! Differential check of the Lean models in `formal/` against the Rust tables. +//! +//! `formal/export/.json` holds the operations of each Lean row circuit: +//! the constraint polynomials (`assert`) and the bus interactions (`interact`), +//! with variables numbered in Rust column order. For each of LT, EQ and SHIFT +//! this test evaluates them on random rows next to what the verifier enforces, +//! the captured Rust `ConstraintSet` program and, per interaction of +//! `bus_interactions()`, the multiplicity and LogUp fingerprint expressions of +//! `emit_multiplicity` and `emit_fingerprint` at fixed challenges, and matches +//! them as multisets of functions (Schwartz–Zippel over [`TRIALS`] rows). +//! Direction, multiplicity and fingerprint are matched separately. It also +//! checks that the Lean constraints vanish on honest Rust traces, padding rows +//! included. The three tables read the current row only; a constraint on +//! another row or an aux column fails in `eval_program_roots`, it is not +//! skipped. +//! +//! `formal/export/bitwise.json` holds the size of the Lean BITWISE table and of +//! each static lookup channel, and a sample of the table: the precomputed +//! columns of sampled rows and the message each channel serves there, checked +//! against `generate_bitwise_row` and the fingerprints of the receivers of +//! `bitwise::bus_interactions()`. Every one of the 2^20 rows is also checked +//! against a transcription of the Lean row function, pinned to the Lean export +//! on the sampled rows. +//! +//! Run with `cargo test -p lambda-vm-prover lean_diff -- --nocapture`. + +use std::collections::HashMap; + +use serde_json::Value; +use stark::constraint_ir::{ConstraintProgram, eval_program_roots}; +use stark::constraints::builder::{ + CaptureBuilder, ConstraintBuilder, ConstraintSet, num_base_from_meta, +}; +use stark::lookup::{BusInteraction, Multiplicity, emit_fingerprint, emit_multiplicity}; + +use super::test_rng::SplitMix64; +use crate::tables::types::{BusId, FE, FEE, GoldilocksExtension, GoldilocksField}; + +type Gl = GoldilocksField; +type Gl3 = GoldilocksExtension; + +const TRIALS: usize = 64; +/// More alpha powers than any interaction has bus elements. +const MAX_BUS_ELEMENTS: usize = 64; + +// ============================================================================= +// Lean side: the exported operations +// ============================================================================= + +enum Expr { + Var(usize), + Const(u64), + Add(Box, Box), + Mul(Box, Box), +} + +fn parse_expr(v: &Value) -> Expr { + match v["type"].as_str().expect("expr type") { + "var" => Expr::Var(v["index"].as_u64().expect("var index") as usize), + "const" => Expr::Const(v["value"].as_u64().expect("const value")), + "add" => Expr::Add( + Box::new(parse_expr(&v["lhs"])), + Box::new(parse_expr(&v["rhs"])), + ), + "mul" => Expr::Mul( + Box::new(parse_expr(&v["lhs"])), + Box::new(parse_expr(&v["rhs"])), + ), + other => panic!("unknown expression node {other}"), + } +} + +fn eval(e: &Expr, row: &[FE]) -> FE { + match e { + Expr::Var(i) => row[*i], + Expr::Const(c) => FE::from(*c), + Expr::Add(a, b) => eval(a, row) + eval(b, row), + Expr::Mul(a, b) => eval(a, row) * eval(b, row), + } +} + +struct LeanInteract { + channel: String, + /// Clean's direction: a pull takes the message from the channel, a push adds it. + pull: bool, + mult: Expr, + msg: Vec, +} + +struct LeanCircuit { + columns: usize, + asserts: Vec, + interacts: Vec, +} + +fn load_export(name: &str) -> Value { + let path = format!( + "{}/../formal/export/{name}.json", + env!("CARGO_MANIFEST_DIR") + ); + let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{path}: {e}")); + serde_json::from_str(&text).expect("json") +} + +fn load_lean(name: &str) -> LeanCircuit { + let json = load_export(name); + let columns = json["columns"].as_u64().expect("columns") as usize; + let mut asserts = Vec::new(); + let mut interacts = Vec::new(); + for op in json["operations"].as_array().expect("operations") { + if let Some(a) = op.get("assert") { + asserts.push(parse_expr(a)); + } else if let Some(i) = op.get("interact") { + interacts.push(LeanInteract { + channel: i["channel"].as_str().expect("channel").to_string(), + pull: match i["direction"].as_str().expect("direction") { + "pull" => true, + "push" => false, + other => panic!("unknown direction {other}"), + }, + mult: parse_expr(&i["multiplicity"]), + msg: i["message"] + .as_array() + .expect("message") + .iter() + .map(parse_expr) + .collect(), + }); + } else { + panic!("unexpected operation {op}"); + } + } + LeanCircuit { + columns, + asserts, + interacts, + } +} + +/// Clean channel name → Lambda VM `BusId` (see `tables/types.rs`). +fn bus_id_of(channel: &str) -> u64 { + let bus = match channel { + "ARE_BYTES" => BusId::AreBytes, + "IS_HALF" => BusId::IsHalfword, + "IS_B20" => BusId::IsB20, + "MSB8" => BusId::Msb8, + "MSB16" => BusId::Msb16, + "ZERO" => BusId::Zero, + "HWSL" => BusId::Hwsl, + "BYTE_ALU" => BusId::ByteAlu, + "ALU" => BusId::Alu, + other => panic!("unknown channel {other}"), + }; + bus as u64 +} + +/// Padding rows are the rows with `μ = 0`; the honest-row checks cover them only if the +/// trace has some. +fn assert_has_padding(label: &str, honest: &[Vec], mu: usize) { + assert!( + honest.iter().any(|r| r[mu] == FE::zero()), + "[{label}] the trace has padding rows" + ); +} + +// ============================================================================= +// Rust side: constraints and interactions as the verifier evaluates them +// ============================================================================= + +/// The LogUp challenges the fingerprints are taken at: `z` and the powers of `α`. +struct Challenges { + z: FEE, + alphas: Vec, +} + +fn random_fee(rng: &mut SplitMix64) -> FEE { + FEE::new([ + FE::from(rng.next_u64()), + FE::from(rng.next_u64()), + FE::from(rng.next_u64()), + ]) +} + +impl Challenges { + fn random(rng: &mut SplitMix64) -> Self { + let z = random_fee(rng); + let alpha = random_fee(rng); + let alphas = (0..=MAX_BUS_ELEMENTS as u64) + .map(|k| alpha.pow(k)) + .collect(); + Challenges { z, alphas } + } + + /// `z − (bus + α·e₀ + α²·e₁ + …)`, the fingerprint `emit_fingerprint` folds. + fn fingerprint(&self, bus: u64, elements: &[FE]) -> FEE { + let terms = elements + .iter() + .enumerate() + .fold(FEE::zero(), |acc, (j, e)| { + acc + e.to_extension::() * self.alphas[j + 1] + }); + self.z - FEE::from(bus) - terms + } +} + +/// The multiplicity (root 0) and fingerprint (root 1) of a Rust interaction, captured from the +/// expressions the verifier evaluates. +fn capture_interaction(i: &BusInteraction) -> ConstraintProgram { + let mut cb = CaptureBuilder::::new(); + let m = emit_multiplicity::(&cb, &i.multiplicity, 0); + cb.emit_base(0, m); + let fp = emit_fingerprint::(&cb, i, 0); + cb.emit_ext(1, fp); + cb.finish(1).0 +} + +/// `(multiplicity, fingerprint)` of a captured interaction on a row. +fn rust_interaction_at( + prog: &ConstraintProgram, + row: &[FE], + ch: &Challenges, +) -> (FEE, FEE) { + let v = eval_program_roots(prog, row, std::slice::from_ref(&ch.z), &ch.alphas); + (v[0], v[1]) +} + +/// `(multiplicity, fingerprint)` of a Lean interaction on a row, the message folded as +/// `emit_fingerprint` folds the Rust bus elements. +fn lean_interaction_at(i: &LeanInteract, row: &[FE], ch: &Challenges) -> (FEE, FEE) { + let msg: Vec = i.msg.iter().map(|e| eval(e, row)).collect(); + ( + eval(&i.mult, row).to_extension::(), + ch.fingerprint(bus_id_of(&i.channel), &msg), + ) +} + +// ============================================================================= +// Matching +// ============================================================================= + +/// FNV-1a of the label: a seed that differs between tables. +fn seed_of(label: &str) -> u64 { + label.bytes().fold(0xCBF2_9CE4_8422_2325, |h, b| { + (h ^ u64::from(b)).wrapping_mul(0x0100_0000_01B3) + }) +} + +fn random_rows(num_cols: usize, rng: &mut SplitMix64) -> Vec> { + (0..TRIALS) + .map(|_| (0..num_cols).map(|_| FE::from(rng.next_u64())).collect()) + .collect() +} + +/// Greedy multiset matching of fingerprints; returns the unmatched indices on each side. +fn unmatched(lean: &[K], rust: &[K]) -> (Vec, Vec) { + let mut pool: HashMap> = HashMap::new(); + for (j, k) in rust.iter().enumerate() { + pool.entry(k.clone()).or_default().push(j); + } + let mut lean_unmatched = Vec::new(); + for (i, k) in lean.iter().enumerate() { + match pool.get_mut(k).and_then(|v| v.pop()) { + Some(_) => {} + None => lean_unmatched.push(i), + } + } + let rust_unmatched: Vec = pool.into_values().flatten().collect(); + (lean_unmatched, rust_unmatched) +} + +/// A field element as a hashable key; a base value is its embedding. +fn fp(x: &FEE) -> [u64; 3] { + let v = x.value(); + [ + v[0].canonical_u64(), + v[1].canonical_u64(), + v[2].canonical_u64(), + ] +} + +fn fp_base(x: &FE) -> [u64; 3] { + fp(&x.to_extension::()) +} + +/// An interaction over the random rows: bus, direction (`true` for a Rust sender, Clean's +/// pull), multiplicity per row, LogUp fingerprint per row. +type InteractionKey = (u64, bool, Vec<[u64; 3]>, Vec<[u64; 3]>); + +struct Report { + lean_asserts_unmatched: Vec, + rust_constraints_unmatched: Vec, + lean_interacts_unmatched: Vec, + /// Indices into the Rust interactions. + rust_interacts_unmatched: Vec, + /// The random rows and challenges the fingerprints were taken at. + random_rows: Vec>, + challenges: Challenges, +} + +fn compare>( + label: &str, + lean: &LeanCircuit, + set: &CS, + interactions: &[BusInteraction], + num_cols: usize, + honest_rows: &[Vec], +) -> Report { + assert_eq!(lean.columns, num_cols, "[{label}] column count"); + + // The Rust constraints as the program the verifier evaluates. + let meta = set.meta(); + let n = meta.len(); + let mut cb = CaptureBuilder::::new(); + set.eval(&mut cb); + let (prog, _) = cb.finish(num_base_from_meta(&meta)); + let rust_roots = |row: &[FE]| eval_program_roots(&prog, row, &[], &[]); + + // Fingerprints over random rows. + let mut rng = SplitMix64(seed_of(label)); + let rows = random_rows(num_cols, &mut rng); + let ch = Challenges::random(&mut rng); + let lean_fp: Vec> = lean + .asserts + .iter() + .map(|e| rows.iter().map(|r| fp_base(&eval(e, r))).collect()) + .collect(); + let rust_by_row: Vec> = rows.iter().map(|r| rust_roots(r)).collect(); + let rust_fp: Vec> = (0..n) + .map(|i| rust_by_row.iter().map(|roots| fp(&roots[i])).collect()) + .collect(); + let (lean_asserts_unmatched, rust_constraints_unmatched) = unmatched(&lean_fp, &rust_fp); + + let lean_ifp: Vec = lean + .interacts + .iter() + .map(|i| { + let evals: Vec<_> = rows + .iter() + .map(|r| lean_interaction_at(i, r, &ch)) + .collect(); + ( + bus_id_of(&i.channel), + i.pull, + evals.iter().map(|e| fp(&e.0)).collect(), + evals.iter().map(|e| fp(&e.1)).collect(), + ) + }) + .collect(); + let rust_ifp: Vec = interactions + .iter() + .map(|i| { + let prog = capture_interaction(i); + let evals: Vec<_> = rows + .iter() + .map(|r| rust_interaction_at(&prog, r, &ch)) + .collect(); + ( + i.bus_id, + i.is_sender, + evals.iter().map(|e| fp(&e.0)).collect(), + evals.iter().map(|e| fp(&e.1)).collect(), + ) + }) + .collect(); + let (li, ri) = unmatched(&lean_ifp, &rust_ifp); + let lean_interacts_unmatched = li + .iter() + .map(|&i| lean.interacts[i].channel.clone()) + .collect(); + let mut rust_interacts_unmatched = ri; + rust_interacts_unmatched.sort_unstable(); + + // Every Lean constraint with a Rust counterpart vanishes on the honest trace. The + // Lean-only ones are the documented deltas (LT's `μ·(1 − μ)` does not hold on a + // deduplicated Rust row with `μ > 1`). + for (r, row) in honest_rows.iter().enumerate() { + for (i, e) in lean.asserts.iter().enumerate() { + if lean_asserts_unmatched.contains(&i) { + continue; + } + assert_eq!( + eval(e, row), + FE::zero(), + "[{label}] Lean assert {i} on honest row {r}" + ); + } + for (i, v) in rust_roots(row).iter().enumerate() { + assert_eq!( + *v, + FEE::zero(), + "[{label}] Rust constraint {i} on honest row {r}" + ); + } + } + + println!( + "[{label}] Lean: {} asserts, {} interactions | Rust: {} constraints, {} interactions", + lean.asserts.len(), + lean.interacts.len(), + n, + interactions.len() + ); + println!( + "[{label}] unmatched Lean asserts {:?}, unmatched Rust constraints {:?}, unmatched Lean interactions {:?}, unmatched Rust interactions (bus ids) {:?}", + lean_asserts_unmatched, + rust_constraints_unmatched, + lean_interacts_unmatched, + rust_interacts_unmatched + .iter() + .map(|&j| interactions[j].bus_id) + .collect::>() + ); + Report { + lean_asserts_unmatched, + rust_constraints_unmatched, + lean_interacts_unmatched, + rust_interacts_unmatched, + random_rows: rows, + challenges: ch, + } +} + +fn rows_of(trace: &stark::trace::TraceTable, num_cols: usize) -> Vec> { + (0..trace.num_rows()) + .map(|r| trace.main_table.get_row(r)[..num_cols].to_vec()) + .collect() +} + +const EDGE: [u64; 8] = [ + 0, + 1, + 0xFF, + 0xFFFF, + 0x7FFF_FFFF_FFFF_FFFF, + 0x8000_0000_0000_0000, + u64::MAX - 1, + u64::MAX, +]; + +// ============================================================================= +// Tables +// ============================================================================= + +#[test] +fn lean_diff_lt() { + use crate::tables::lt::{ + LtConstraints, LtOperation, bus_interactions, cols, generate_lt_trace, + }; + let mut rng = SplitMix64(0x17); + let mut ops = Vec::new(); + for &a in &EDGE { + for &b in &EDGE { + for signed in [false, true] { + for invert in [false, true] { + ops.push(LtOperation::new_with_invert(a, b, signed, invert)); + } + } + } + } + for _ in 0..255 { + ops.push(LtOperation::new_with_invert( + rng.next_u64(), + rng.next_u64(), + rng.next_u64() & 1 == 1, + rng.next_u64() & 1 == 1, + )); + } + // Repeated operations: deduplicated rows with μ = 3, and one op split into μ = MU_MAX and + // μ = 2 rows. 514 distinct rows pad to 1024, so padding rows are checked too. + for _ in 0..3 { + ops.push(LtOperation::new_with_invert(5, 7, false, false)); + } + for _ in 0..crate::tables::types::MU_MAX + 2 { + ops.push(LtOperation::new_with_invert(1, 2, true, true)); + } + let trace = generate_lt_trace(&ops); + let lean = load_lean("lt"); + let interactions = bus_interactions(); + let honest = rows_of(&trace, cols::NUM_COLUMNS); + assert_has_padding("LT", &honest, cols::MU); + let report = compare( + "LT", + &lean, + &LtConstraints, + &interactions, + cols::NUM_COLUMNS, + &honest, + ); + // Known deltas: the Lean model keeps `μ·(1 − μ) = 0`, the Rust chip bounds `μ` with the + // `ARE_BYTES[μ, 0]` send instead. Both are found by content, not position. + let &[mu_assert] = report.lean_asserts_unmatched.as_slice() else { + panic!( + "[LT] only the μ bit constraint should be Lean-only, got {:?}", + report.lean_asserts_unmatched + ) + }; + let mu_bit = |r: &[FE]| r[cols::MU] * (FE::one() - r[cols::MU]); + for r in &report.random_rows { + assert_eq!( + eval(&lean.asserts[mu_assert], r), + mu_bit(r), + "[LT] Lean-only assert is μ·(1 − μ)" + ); + } + // The delta is real on honest rows: it fails exactly on the deduplicated rows. + let mut dedup_rows = 0; + for r in &honest { + let mu = r[cols::MU].canonical_u64(); + assert_eq!( + eval(&lean.asserts[mu_assert], r) == FE::zero(), + mu <= 1, + "[LT] μ = {mu}" + ); + dedup_rows += usize::from(mu > 1); + } + assert!(dedup_rows >= 2, "[LT] the trace has deduplicated rows"); + assert!( + report.rust_constraints_unmatched.is_empty(), + "[LT] Rust-only constraints" + ); + assert!( + report.lean_interacts_unmatched.is_empty(), + "[LT] Lean-only interactions" + ); + let &[are_bytes] = report.rust_interacts_unmatched.as_slice() else { + panic!( + "[LT] only ARE_BYTES[μ, 0] should be Rust-only, got {:?}", + report.rust_interacts_unmatched + ) + }; + let are_bytes = &interactions[are_bytes]; + assert!( + are_bytes.is_sender && matches!(are_bytes.multiplicity, Multiplicity::One), + "[LT] the μ bound is sent with multiplicity One" + ); + let prog = capture_interaction(are_bytes); + for r in &report.random_rows { + assert_eq!( + rust_interaction_at(&prog, r, &report.challenges), + ( + FEE::one(), + report + .challenges + .fingerprint(BusId::AreBytes as u64, &[r[cols::MU], FE::zero()]) + ), + "[LT] the Rust-only interaction is ARE_BYTES[μ, 0]" + ); + } +} + +#[test] +fn lean_diff_eq() { + use crate::tables::eq::{ + EqConstraints, EqOperation, bus_interactions, cols, generate_eq_trace, + }; + let mut rng = SplitMix64(0xE0); + let mut ops = Vec::new(); + for &a in &EDGE { + for &b in &EDGE { + for invert in [false, true] { + ops.push(EqOperation::new(a, b, invert)); + } + } + } + for _ in 0..256 { + let a = rng.next_u64(); + let b = if rng.next_u64() & 1 == 1 { + a + } else { + rng.next_u64() + }; + ops.push(EqOperation::new(a, b, rng.next_u64() & 1 == 1)); + } + let trace = generate_eq_trace(&ops); + let honest = rows_of(&trace, cols::NUM_COLUMNS); + assert_has_padding("EQ", &honest, cols::MU); + let report = compare( + "EQ", + &load_lean("eq"), + &EqConstraints, + &bus_interactions(), + cols::NUM_COLUMNS, + &honest, + ); + assert!( + report.lean_asserts_unmatched.is_empty() && report.rust_constraints_unmatched.is_empty(), + "[EQ] constraints differ" + ); + assert!( + report.lean_interacts_unmatched.is_empty() && report.rust_interacts_unmatched.is_empty(), + "[EQ] interactions differ" + ); +} + +#[test] +fn lean_diff_shift() { + use crate::tables::shift::{ + ShiftConstraints, ShiftOperation, bus_interactions, cols, generate_shift_trace, + }; + let mut rng = SplitMix64(0x5F); + let mut ops = Vec::new(); + for &v in &EDGE { + for s in [ + 0u64, + 1, + 15, + 16, + 17, + 31, + 32, + 33, + 47, + 48, + 63, + 64, + 65, + 255, + 256, + u64::MAX, + ] { + for direction in [false, true] { + for signed in [false, true] { + for word in [false, true] { + ops.push(ShiftOperation::new(v, s, direction, signed, word)); + } + } + } + } + } + for _ in 0..512 { + ops.push(ShiftOperation::new( + rng.next_u64(), + rng.next_u64(), + rng.next_u64() & 1 == 1, + rng.next_u64() & 1 == 1, + rng.next_u64() & 1 == 1, + )); + } + let trace = generate_shift_trace(&ops); + let honest = rows_of(&trace, cols::NUM_COLUMNS); + assert_has_padding("SHIFT", &honest, cols::MU); + let report = compare( + "SHIFT", + &load_lean("shift"), + &ShiftConstraints, + &bus_interactions(), + cols::NUM_COLUMNS, + &honest, + ); + assert!( + report.lean_asserts_unmatched.is_empty() && report.rust_constraints_unmatched.is_empty(), + "[SHIFT] constraints differ" + ); + assert!( + report.lean_interacts_unmatched.is_empty() && report.rust_interacts_unmatched.is_empty(), + "[SHIFT] interactions differ" + ); +} + +/// `Bitwise.row i` of `formal/LambdaVM/Tables/Bitwise.lean`, transcribed: `rowOf` on +/// `i % 2^8`, `i / 2^8 % 2^8`, `i / 2^16 % 16`, with the Lean `sll`/`sllc` and their `z = 0` case. +fn lean_bitwise_row(i: usize) -> [u64; 11] { + let (x, y, z) = ( + (i % (1 << 8)) as u64, + (i / (1 << 8) % (1 << 8)) as u64, + (i / (1 << 16) % 16) as u64, + ); + let h = x + (1 << 8) * y; + let sll = if z == 0 { h } else { (h << z) % (1 << 16) }; + let sllc = if z == 0 { 0 } else { h >> (16 - z) }; + let zero = u64::from(x == 0 && y == 0 && z == 0); + [ + x, + y, + z, + x & y, + x | y, + x ^ y, + x / (1 << 7), + h / (1 << 15), + zero, + sll, + sllc, + ] +} + +#[test] +fn lean_diff_bitwise() { + use crate::tables::bitwise::{ + NUM_PRECOMPUTED_COLS, NUM_ROWS, bus_interactions, cols, generate_bitwise_row, + }; + let json = load_export("bitwise"); + let challenges = Challenges::random(&mut SplitMix64(seed_of("BITWISE"))); + let as_u64s = |v: &Value| -> Vec { + v.as_array() + .expect("array") + .iter() + .map(|x| x.as_u64().expect("number")) + .collect() + }; + let indices: Vec = as_u64s(&json["indices"]) + .into_iter() + .map(|i| i as usize) + .collect(); + let lean_rows = json["rows"].as_array().expect("rows"); + assert_eq!( + lean_rows.len(), + indices.len(), + "[BITWISE] one row per index" + ); + assert_eq!( + json["numRows"].as_u64().expect("numRows") as usize, + NUM_ROWS, + "[BITWISE] table size" + ); + + // All 2^20 rows: Rust against the transcribed Lean row function, which the sampled + // rows below pin to the Lean export. + for i in 0..NUM_ROWS { + assert_eq!( + generate_bitwise_row(i), + lean_bitwise_row(i), + "[BITWISE] row {i}" + ); + } + + // The precomputed columns of every sampled row. + let rust_rows: Vec> = indices + .iter() + .zip(lean_rows) + .map(|(&i, lean)| { + let rust = generate_bitwise_row(i); + assert_eq!(as_u64s(lean), rust.to_vec(), "[BITWISE] row {i}"); + assert_eq!( + as_u64s(lean), + lean_bitwise_row(i).to_vec(), + "[BITWISE] transcription of the Lean row function, row {i}" + ); + let mut row = vec![FE::zero(); cols::NUM_COLUMNS]; + for (c, v) in rust.iter().enumerate().take(NUM_PRECOMPUTED_COLS) { + row[c] = FE::from(*v); + } + row + }) + .collect(); + + // Every Lean channel is a bus with BITWISE receivers serving the same messages, and + // every BITWISE receiver belongs to a Lean channel. + let interactions = bus_interactions(); + let mut receivers: HashMap> = HashMap::new(); + for i in &interactions { + assert!(!i.is_sender, "[BITWISE] only receives"); + receivers.entry(i.bus_id).or_default().push(i); + } + let channels = json["channels"].as_array().expect("channels"); + let mut seen: Vec = Vec::new(); + for ch in channels { + let name = ch["channel"].as_str().expect("channel"); + let bus = bus_id_of(name); + assert!( + !seen.contains(&bus), + "[BITWISE] channel {name} exported twice" + ); + seen.push(bus); + let rust = receivers + .get(&bus) + .unwrap_or_else(|| panic!("[BITWISE] no Rust receiver for {name}")); + // One table entry per row and receiver: BYTE_ALU serves three per row. + assert_eq!( + ch["size"].as_u64().expect("size") as usize, + NUM_ROWS * rust.len(), + "[BITWISE] size of {name}" + ); + let messages = ch["messages"].as_array().expect("messages"); + assert_eq!( + messages.len(), + indices.len(), + "[BITWISE] {name}: one message list per sampled row" + ); + // The messages as the LogUp fingerprints the receivers emit. + let progs: Vec<_> = rust.iter().map(|&r| capture_interaction(r)).collect(); + for ((&i, row), lean) in indices.iter().zip(&rust_rows).zip(messages) { + let mut lean: Vec<[u64; 3]> = lean + .as_array() + .expect("messages of a row") + .iter() + .map(|m| { + let elements: Vec = as_u64s(m).into_iter().map(FE::from).collect(); + fp(&challenges.fingerprint(bus, &elements)) + }) + .collect(); + let mut rust: Vec<[u64; 3]> = progs + .iter() + .map(|p| fp(&rust_interaction_at(p, row, &challenges).1)) + .collect(); + lean.sort_unstable(); + rust.sort_unstable(); + assert_eq!(lean, rust, "[BITWISE] {name} at row {i}"); + } + } + let mut rust_buses: Vec = receivers.keys().copied().collect(); + rust_buses.sort_unstable(); + seen.sort_unstable(); + assert_eq!( + seen, rust_buses, + "[BITWISE] Lean channels vs Rust receivers" + ); + println!( + "[BITWISE] {NUM_ROWS} rows against the row function, {} sampled rows, {} channels, {} receivers: exact match", + indices.len(), + seen.len(), + interactions.len() + ); +} diff --git a/prover/src/tests/mod.rs b/prover/src/tests/mod.rs index f2f40ad5c..f0c7c5112 100644 --- a/prover/src/tests/mod.rs +++ b/prover/src/tests/mod.rs @@ -107,6 +107,8 @@ pub mod register_tests; #[cfg(test)] pub mod shift_tests; +#[cfg(test)] +pub mod lean_diff; #[cfg(test)] pub mod skip_empty_tables_tests; #[cfg(test)] @@ -118,6 +120,8 @@ pub mod store_tests; #[cfg(test)] pub mod templates_tests; #[cfg(test)] +pub mod test_rng; +#[cfg(test)] pub mod trace_builder_tests; #[cfg(test)] pub mod trace_test_helpers; diff --git a/prover/src/tests/test_rng.rs b/prover/src/tests/test_rng.rs new file mode 100644 index 000000000..0db81576c --- /dev/null +++ b/prover/src/tests/test_rng.rs @@ -0,0 +1,14 @@ +//! Deterministic SplitMix64 for tests that draw random field elements without a +//! `rand` dependency. + +pub struct SplitMix64(pub u64); + +impl SplitMix64 { + pub fn next_u64(&mut self) -> u64 { + self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15); + let mut z = self.0; + z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); + z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); + z ^ (z >> 31) + } +} diff --git a/spec/tooling/chip.py b/spec/tooling/chip.py index 44cbbed83..071564639 100644 --- a/spec/tooling/chip.py +++ b/spec/tooling/chip.py @@ -786,7 +786,7 @@ class Assumption: def __init__(self, config: Config, data: dict): assert_no_unexpected( - data, set(self.__annotations__.keys()) | {"iter", "iters", "ref"} + data, set(type(self).__annotations__.keys()) | {"iter", "iters", "ref"} ) self.desc = data["desc"] self.iters = iters_of(data, config) @@ -801,7 +801,7 @@ class ArithConstraint: def __init__(self, config: Config, data: dict): assert_no_unexpected( - data, set(self.__annotations__.keys()) | {"kind", "ref", "iter", "iters"} + data, set(type(self).__annotations__.keys()) | {"kind", "ref", "iter", "iters"} ) assert data["kind"] == "arith" self.constraint = data["constraint"]