Skip to content

Channels#328

Draft
mitschabaude wants to merge 324 commits intomainfrom
multiset-with-env-tables
Draft

Channels#328
mitschabaude wants to merge 324 commits intomainfrom
multiset-with-env-tables

Conversation

@mitschabaude
Copy link
Copy Markdown
Collaborator

this PR is an attempt to

  • introduce Channels as an abstraction similar to Tables, that model all cross-table interactions
  • figure out a good e2e UX for using channels in various ways, and in particular for multi-table ensembles
  • enable proving soundness and completeness at the multi-table level, in a modular way that makes use of local constraints to establish local channel "guarantees"

started on top of #309 but heavily refactoring its contributions

The working example for Channels is 8-bit Fibonacci which we implement using 3 different channels that represent 3 prominent ways channels are used:

  • for static lookup tables
  • for looking up into an "ALU chip", to outsource constraints from one table to another
  • for state transitions within one table (here: fibonacci), replacing the classic "next-row" constraint

pirapira and others added 30 commits November 28, 2025 09:25
Extract five helper lemmas for better modularity:
- countOutgoing_le_length: countOutgoing bounded by vector length
- countIncoming_le_length: countIncoming bounded by vector length
- totalOutgoing_le_totalCapacity: totalOutgoing bounded by totalCapacity
- totalIncoming_le_totalCapacity: totalIncoming bounded by totalCapacity
- totalFlow_bound: combined bound for field-to-integer lifting

This makes balanced_adds_implies_netFlow more readable by removing
deeply nested have statements. The extracted lemmas are reusable
and have clear, documented purposes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Extract field_sub_eq_neg_one_implies_swap_eq_one: In a field, a - b = -1 implies b - a = 1
- Extract finRange_map_getElem_eq_toList_map: Mapping over finRange with indexed access equals mapping over toList
- Extract countTransitionInPath_first_pos: The first transition in a path has count > 0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Use rfl instead of congr 1 in Loops.lean
- Remove guard_hyp debugging from Subcircuit.lean
- Use apply instead of exact, simplify proofs in Subcircuit.lean
- Rename decodeInstructionSpec/Main/Elaborated/Circuit to decodeInstruction.Spec/main/elaborated/circuit

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fill sorry in IsZero.lean localAdds_eq using collectAdds_foldlRange'
- Fill sorry in AbsorbBlock.lean localAdds_eq using new helper lemma
- Add collectAdds_mapFinRange' lemma in Loops.lean for .2 syntax matching

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add weakenSpec to StructuralLemmas.lean analogous to FormalCircuit.weakenSpec
- Add weakenSpec_assumptions simp lemma
- Create circuitWithExecutionExistenceSpec using weakenSpec in TraceExecution.lean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replace FormalAssertionChangingMultiset.weakenSpec (which had a sorry in
completeness) with GeneralFormalCircuitChangingMultiset.weakenSpec which
doesn't need a sorry because GeneralFormalCircuit.Completeness doesn't
depend on Spec.

Add FormalAssertionChangingMultiset.toGeneralCircuit conversion to bridge
between the two types. The conversion has a sorry in completeness because
FormalAssertion.CompletenessChangingMultiset requires Spec to hold, but
GeneralFormalCircuit.Completeness doesn't - this is an inherent type mismatch.

Update circuitWithExecutionExistenceSpec to use the new pattern.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove FormalAssertionChangingMultiset.toGeneralCircuit and instead construct
circuitWithExecutionExistenceSpec directly as a GeneralFormalCircuitChangingMultiset.

When converting between formal circuit types is needed, it's better to use the
appropriate FormalSomething type directly rather than having conversions with
sorries.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Change ExecutionBundle.circuit from FormalAssertionChangingMultiset to
  GeneralFormalCircuitChangingMultiset so weakenSpec can be applied
- Simplify circuitWithExecutionExistenceSpec to use weakenSpec directly
- Remove unnecessary comment from StructuralLemmas.lean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The circuit_soundness theorem is now fully proved using:
- circuit_proof_start to set up the proof context
- Extract and rewrite eval equalities from h_input
- Apply bundle specs with their corresponding assumptions
- InteractionDelta.add_eq_append to convert ++ to +
- add_assoc to handle associativity differences

Completeness proof remains sorry as it depends on bundle
completeness proofs which are also currently sorry.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- FemtoCairo.lean: Use decodeInstruction.circuit instead of
  decodeInstructionCircuit and unfold decodeInstruction.Spec in simp
- ExecutionBundle.lean: Remove redundant rfl and add State.eval_*
  lemmas to normalize Expression.eval to (eval ...).field form

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <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