Skip to content

Conversation

@ledwards2225
Copy link
Contributor

@ledwards2225 ledwards2225 commented Jan 16, 2026

Primary changes:

  • Replace methods of the form get_*_gate_connected_component with GatePattern structs that specify the conditions under which each wire is constrained for each gate type
  • Test correctness of GatePattern's by perturbing relation inputs to empirically check which wires are constrained (gate_patterns.test.cpp)

Cleanup:

  • Replace use of block_idx with reference to block in several places for improved clarity

ledwards2225 and others added 6 commits January 15, 2026 19:06
Introduces a pattern-based approach for extracting gate variables in the
static analyzer. Key changes:

- Add gate_patterns.hpp with declarative patterns for all gate types:
  ARITHMETIC, ELLIPTIC, DELTA_RANGE, LOOKUP, POSEIDON2_INTERNAL/EXTERNAL,
  NON_NATIVE_FIELD, MEMORY, DATABUS, and ECC_OP

- Add extract_gate_variables() template method that uses patterns to
  extract wire indices based on selector conditions

- Convert most gate extraction methods to use pattern-based extraction:
  - ARITHMETIC: Uses pattern with special handling for fix_witness gates
  - ELLIPTIC, DELTA_RANGE, LOOKUP, POSEIDON2, NON_NATIVE_FIELD, DATABUS:
    Fully converted to pattern-based extraction
  - MEMORY: Uses pattern for non-access gates; access gates still handled
    by transcript-based methods due to tau-tag constraints

- Add perturbation tests (gate_patterns.test.cpp) that verify patterns
  match actual relation constraints by checking that perturbing constrained
  wires changes relation output

All 82 existing tests pass. The pattern-based approach provides:
- Automated verification via perturbation testing
- Self-documenting constraint specifications
- Easier maintenance when relations change

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants