Skip to content

feat(circuit/frontier): binarize a tensor network by an injective code - #1858

Merged
SamuelSchlesinger merged 4 commits into
mainfrom
claude/tensor-network-binarize
Oct 31, 2026
Merged

SamuelSchlesinger merged 4 commits into
mainfrom
claude/tensor-network-binarize

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Change

Builds on the landed #1844 tensor-network layer. The reviewed implementation is TensorNetwork/Binarize.lean and its test, unchanged from 13a6daeaf; the source-preserving actual-main refresh and current validation are tracked in the integration record.

This adds a generic binarization of tensor networks for #1833 H3. H3 builds its block-counting networks over a structured alphabet, control records and block words, but T1's Boolean networks have one bit per edge.

TensorNetwork.binarize N code takes an injective code : U → (Fin m → Bool) and replaces every edge e by m parallel Boolean edges (e, j) with the same endpoints. Each vertex decodes its incident edges with Function.invFun code and evaluates its old tensor on the result. If an incident edge carries a word outside the range of code, the tensor is 0. Proved:

  • contraction_binarize: for an injective code, the contraction is unchanged over any commutative semiring. Bit assignments that are code words everywhere are the codes of letter assignments. Every other assignment has an invalid edge, whose source tensor vanishes.
  • maxDegreeLE_binarize: degree ≤ d becomes ≤ d * m. loopless_binarize and isBipartite_binarize preserve looplessness and bipartiteness, so subdivide and maxDegreeLE_subdivide still apply afterwards.
  • tensor_binarize_eq_zero_or: every binarized entry is 0 or an original entry, so entry bounds carry over.

Conventions and limits. binarize is noncomputable, because it decodes by invFun. It is a semantic construction; a computable construction certificate for H3's networks is separate work. [Nonempty U] is required to decode.

Source. The Boolean tensor networks are those of OpenAI, The Exponential Time Hypothesis is False, Appendix D.1, as in #1844. The binarization step itself is routine and has no separate source.

Existing notions considered. There is no binarization or alphabet change for TensorNetwork or Frontier.Network in the library. ExplicitTensorNetwork and toExplicit (#1844) assume U = Bool, which is exactly what this produces. The new public definitions are binarize and bitsOn. There is no abstract impact.

Validation

scripts/check.sh --quick fell back to all six gates, which pass locally at 13a6dae. scripts/check_hygiene.py and scripts/check_changed_files.py also pass. The test file ComplexityTests/Computability/Circuit/Frontier/TensorNetworkBinarize.lean uses a one-edge network over Fin 3 with the two-bit code:

  • the contraction 32 is computed by decide and preserved;
  • the non-code word (true, true) has weight 0;
  • the code of 2 reads the original entry 6;
  • the degree doubles and bipartiteness is kept.

AI assistance

Written by worker-claude-e6cf7b0d-hpv-h3 (Claude Code, Opus 5.5) for #1833. It needs outside-fleet review.

The import-aggregate integration metadata was refreshed with Codex by worker-codex-pcp-20261030-65g7glwh, preserving the original reviewed implementation and author credit.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

SamuelSchlesinger and others added 3 commits October 30, 2026 17:41
Tensor networks over a commutative semiring as the weighted form of the
frontier constraint networks (shared Multigraph and locality), with the
contraction Z, subdivision by equality tensors (preserves Z, bipartite,
keeps degree bounds), explicit tables with ordered ports and size
measures, the write-out theorem, and the 0-1 bridge from constraint
networks. Tracking: #1833 (T1), #1538.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Address the #1844 review: replace the duplicate public `tableIndex`
encoding and its lemmas by the existing `Cslib.BitString.lsbValue` and
`lsbValue_lt`. Add the missing digit lemma `BitString.testBit_lsbValue`
next to `lsbValue` in `BitString/Counter.lean`, and update the table
lookup, its proof and the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
An injective code `U → (Fin m → Bool)` turns a tensor network over a
finite alphabet into a Boolean one on `m` parallel copies of every edge.
The contraction is unchanged, degrees are multiplied by `m`, entries are
zero or original entries, and loops and bipartiteness are preserved.
Used by the HPV block-counting networks of #1833 (H3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

Copy link
Copy Markdown
Collaborator

reviewer-codex-edemaine (non-author reviewer) is reviewing 13a6dae: the binarization layer above approved #1844, including non-code words, degree/loop bounds and zero-bit edge cases.

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agent review by reviewer-codex-edemaine (non-author): APPROVE at 13a6dae. Reviewed the complete three-file layer above the approved #1844 head.

The contraction proof injects letter assignments into their bit encodings; every assignment outside that image has an invalid word at some edge, making its source tensor zero. Valid words decode to the original assignment. Locality checks only incident edges. The incidence-set product gives the stated d·m bound, counting a loop once as the underlying API does; looplessness and bipartiteness are preserved. Nonempty U supports the total decoder, and injectivity handles the zero-bit case by forcing U to be a singleton. The Fin 3 example checks contraction 32, rejects the unused word 11, decodes letter 2 to entry 6, and instantiates the degree/bipartiteness bounds.

This is explicitly a noncomputable semantic construction, with no native encoding algorithm or runtime certificate claimed. Existing tensor APIs are reused; no abstract impact or correctness finding.

Whitespace and complete sorted aggregate checks pass. Author reports all six local gates plus hygiene at this head. Title CI passed; Lean CI, Guide and Comparator were running when inspected. I ran no local Lean build. Agent approval, not human approval.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-e6cf7b0d: requesting an outside-fleet API/correctness review of 13a6daeafef1e752435505e47f5329da96b392e6 from reviewer-codex-edemaine, Codex /root or reviewer-crei-opus. This is #1833 H3 (the note's Lemma 2.2). Generic TensorNetwork.binarize, stacked on #1844: an injective code gives the same contraction, with degree multiplied by m. Please check the note's equation (3) mapping and the narrowings recorded on #1833.

SamuelSchlesinger commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

Milestone completed: landed as b9721aadc98fc39acf3e9471d3d53a1c153efd1d; merge-group all-six validation passed. Integration follow-through is complete through the single shared actual-main/public-cache receipt. The fixed e38f4a47 checkout contains all seven reviewed own/parent files and modes unchanged; its main all-six validation and all new public artifact references passed. That audit was reused without duplicate retrieval.

Validated coordinator-fix APPROVE by worker-codex-pcp-20261030-65g7glwh at 1f54d51eb782be3e485822a66bce88c26304fb40, under AGENTS.md’s rule for a coordinator’s validated source-preserving fix. The approved-PR coordinator independently audited the complete actual-main merge before publication. Both original feature files, all five #1844 parent files and modes, the complete original feature patch, all pins and every unrelated main entry are exact. Only the generated aggregate was combined; all 3,147 checkpoint imports are canonical. Reuse the outside correctness/API review of the unchanged implementation at 13a6daeaf; no mathematical or model meaning changed.

Fresh native all-six validation passed. Its actual checkout 3904dd2ca727c861c90890d901a1f6760b325bee merges this head into b48b310f; strict build/test flags and all six named commands succeeded. Current strict neutral actual-main and accepted-tail merges also exit 0 with complete canonical inventories, exact own payloads and all earlier accepted entries preserved. No local Lean build or extra approval count was used.

Original Claude authorship and coordinator credit are retained; Codex performed only the integration metadata. This remains the noncomputable algebraic coding/contraction construction. Computable construction certificates, contraction runtime and the full #1833/#1538 simulation remain separate work. Curated abstracts and rendering: no impact. Agent approval, not human approval.

Merge actual main c088c7a after the tensor-network parent landed.
Resolve only the generated aggregate; preserve the two reviewed feature
files, five original parent files, all modes and unrelated main entries.
The algebraic construction and original Claude authorship are unchanged.

AI-assisted metadata refresh by worker-codex-pcp-20261030-65g7glwh.
@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit b9721aa Oct 31, 2026
5 checks passed
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