From d74e10a9f1fac2723767069b8d9dd4af30aef9a5 Mon Sep 17 00:00:00 2001 From: Jan Ferdinand Sauer Date: Fri, 7 Jun 2024 15:46:05 +0200 Subject: [PATCH] perf: Combine constraints of illegal `num_words` The constraints prohibiting an illegal value for `NumberOfWords` are mutually exclusive. More importantly, the set of all the constraints has Hamming weight 1. This implies they can safely (and soundly) be summed. --- specification/src/arithmetization-overview.md | 10 +++++----- triton-vm/src/table/processor_table.rs | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/specification/src/arithmetization-overview.md b/specification/src/arithmetization-overview.md index d9e1b0d2f..f05b23470 100644 --- a/specification/src/arithmetization-overview.md +++ b/specification/src/arithmetization-overview.md @@ -34,7 +34,7 @@ Before automatic degree lowering: | table name | #initial | #consistency | #transition | #terminal | max degree | |:-----------------------------------------------|---------:|-------------:|------------:|----------:|-----------:| | [ProgramTable](program-table.md) | 6 | 4 | 10 | 2 | 4 | -| [ProcessorTable](processor-table.md) | 29 | 10 | 49 | 1 | 19 | +| [ProcessorTable](processor-table.md) | 29 | 10 | 41 | 1 | 19 | | [OpStackTable](operational-stack-table.md) | 3 | 0 | 5 | 0 | 4 | | [RamTable](random-access-memory-table.md) | 7 | 0 | 12 | 1 | 5 | | [JumpStackTable](jump-stack-table.md) | 6 | 0 | 6 | 0 | 4 | @@ -43,14 +43,14 @@ Before automatic degree lowering: | [LookupTable](lookup-table.md) | 3 | 1 | 4 | 1 | 3 | | [U32Table](u32-table.md) | 1 | 15 | 22 | 2 | 12 | | [Grand Cross-Table Argument](table-linking.md) | 0 | 0 | 0 | 14 | 1 | -| **TOTAL** | **79** | **76** | **158** | **23** | **19** | +| **TOTAL** | **79** | **76** | **150** | **23** | **19** | After automatically lowering degree to 4: | table name | #initial | #consistency | #transition | #terminal | |:-----------------------------------------------|---------:|-------------:|------------:|----------:| | [ProgramTable](program-table.md) | 6 | 4 | 10 | 2 | -| [ProcessorTable](processor-table.md) | 31 | 10 | 227 | 1 | +| [ProcessorTable](processor-table.md) | 31 | 10 | 219 | 1 | | [OpStackTable](operational-stack-table.md) | 3 | 0 | 5 | 0 | | [RamTable](random-access-memory-table.md) | 7 | 0 | 13 | 1 | | [JumpStackTable](jump-stack-table.md) | 6 | 0 | 6 | 0 | @@ -59,7 +59,7 @@ After automatically lowering degree to 4: | [LookupTable](lookup-table.md) | 3 | 1 | 4 | 1 | | [U32Table](u32-table.md) | 1 | 26 | 34 | 2 | | [Grand Cross-Table Argument](table-linking.md) | 0 | 0 | 0 | 14 | -| **TOTAL** | **81** | **94** | **386** | **23** | +| **TOTAL** | **81** | **94** | **378** | **23** | @@ -71,5 +71,5 @@ In order to gauge the runtime cost for this step, the following table provides e | Processor | Op Stack | RAM | |----------:|---------:|------:| -| 35689 | 66327 | 23592 | +| 35207 | 65377 | 23220 | diff --git a/triton-vm/src/table/processor_table.rs b/triton-vm/src/table/processor_table.rs index d78452c9e..5bcee24c3 100644 --- a/triton-vm/src/table/processor_table.rs +++ b/triton-vm/src/table/processor_table.rs @@ -2720,9 +2720,10 @@ impl ExtProcessorTable { fn prohibit_any_illegal_number_of_words( circuit_builder: &ConstraintCircuitBuilder, ) -> Vec> { - NumberOfWords::illegal_values() + vec![NumberOfWords::illegal_values() .map(|n| Self::indicator_polynomial(circuit_builder, n)) - .to_vec() + .into_iter() + .sum()] } fn log_derivative_accumulates_clk_next(