Skip to content

feat(machines): explicit Boolean block-counting networks (#1833 H3) - #1877

Merged
SamuelSchlesinger merged 12 commits into
mainfrom
claude/hpv-explicit-network
Oct 31, 2026
Merged

SamuelSchlesinger merged 12 commits into
mainfrom
claude/hpv-explicit-network

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Change

H3, explicit form of the block-counting networks for #1833 (Lemma 2.2 of Samuel's note), by worker-claude-e6cf7b0d-hpv-h3b (Claude Code, Opus).

Stacked on #1872 (claude/hpv-block-network, head e84e94885), which carries #1866, #1858, #1851, #1841 and #1844. Review only the last commit until those land.

What is proved. explicitBlockNetwork machine input b σ e writes the semantic network blockNetwork of #1872 out as an ExplicitTensorNetwork ℕ. It binarizes by a concrete letter code, subdivides by equality tensors, and numbers the old vertices first.

  • sum_contraction_explicitBlockNetwork (hq : 0 < q): summed over the schedules σ : Schedule k q, the explicit contractions equal machine.acceptCount input (q * b). It follows from contraction_toExplicit, contraction_subdivide and contraction_binarize.
  • Size: numEdges = 2 * (q * (3k+1) * m) with m = letterBits k s b = (s + k + 4) * b; vertices.length = q(3k+2) + q(3k+1)m; maxDegree ≤ 2(3k+1)m.
  • isRowsFirstBipartite_explicitBlockNetwork: the first q * (3k+2) vertices (intervals and sinks) are the rows.
  • Tables have length 2 ^ (number of ports), and every entry is at most 2 ^ b.
  • admissible_explicitBlockNetwork: if b ≤ 3 ⌊log₂ t⌋ and q * b ≤ 2t, the network is rows-first bipartite with at most C·t edges and maximum degree at most C·⌊log₂ t⌋, where C = 6(3k+1)(s+k+4). This is the shape of E1's intended Admissible (feat(Classes/CountingSimulation): conditional assembly of the counting simulation (#1833 E1) #1865). Nat.clog_two_add_two_le_three_mul_log_two (⌈log₂ (t+2)⌉ ≤ 3⌊log₂ t⌋ for t ≥ 2) gives the first hypothesis at E1's blockLength, and E1's paddedTime_add_one_le (in feat(Classes/CountingSimulation): conditional assembly of the counting simulation (#1833 E1) #1865, not on this branch) gives the second.

Conventions.

  • The letter code (letterCode e) is the m low binary digits of letterEquiv e, a numbering built only from finProdFinEquiv, finSumFinEquiv, finSuccEquiv, finFunctionFinEquiv and ZMod.finEquiv. It is computable, so the polynomial-time twin (the next H3 milestone) can reproduce it exactly. Fintype.equivFin would not allow this, because it is chosen noncomputably.
  • States are numbered by a parameter e : State ≃ Fin s. The network family will fix one with Finite.equivFin.
  • Edges and vertices are numbered by explicit equivalences (blockEdgeEquiv, explicitVertexEquiv, explicitEdgeEquiv).

Generic additions (TensorNetwork/Explicit.lean, from #1844):

  • ExplicitTensorNetwork.IsRowsFirstBipartite r, which is decidable: every port names an edge, and every edge is a port of the first r vertices exactly once and of the rest exactly once. This is the first condition of the T2 contract guard (Formalize Appendix D: recursive tensor contraction and the sharper Theorem 1.1 bound for #k-SAT #1538), and E1 can use it in Admissible.
  • length_explicitPorts (ports are the incident edges), count_explicitPorts, maxDegree_toExplicit_le, isRowsFirstBipartite_toExplicit, length_table_toExplicit and exists_tensor_of_mem_toExplicit.

Limits.

Existing notions considered.

  • Fintype.equivFin was rejected for the code because it is noncomputable, as above.
  • TensorNetwork.binarize/subdivide/toExplicit and Multigraph.IsBipartite are reused.
  • Multigraph.IsBipartite is the semantic notion. IsRowsFirstBipartite is its explicit, decidable counterpart with the sides fixed by position, which is what the contraction algorithm reads.
  • No existing OutputTrack ≃ Fin 3 or ZMod b ≃ Fin b wrapper was found beyond ZMod.finEquiv, which zmodEquiv wraps.

Abstract impact. None.

Validation

  • scripts/check.sh --quick fell back to all six gates (the stack's base diff includes references.bib). All six pass locally at the PR head.
  • Tests:
    • ComplexityTests/HPVExplicitBlockNetwork.lean (on the existing tiny machines emitCoin and walk): letterEquiv and letterCode on concrete letters by decide (numbers 44 and 34, and a 14-bit code); the counting identity, giving 2 and 8 accepting strings; size, degree, bipartition and tables at concrete parameters; and admissibility at t = 2.
    • ComplexityTests/Computability/Circuit/Frontier/TensorNetwork.lean: IsRowsFirstBipartite by decide, positive and negative cases (both vertices as rows, rows not first, a port naming no edge); on a subdivided network written out, the general lemmas agree with evaluation.

AI assistance

Claude Code (Opus) wrote the code, proofs, tests and this description. It needs outside-fleet review.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

SamuelSchlesinger and others added 11 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
…H1)

Define the accepting count of a closed fair-coin table, the number of
choice strings of a given length on which it emits [true], and relate it
to the existing semantics: the probability of output [true] is the count
divided by 2^τ; a nondeterministic decider's choice table has a positive
count exactly on members; a bounded-error decider has a strict-majority
count exactly on members, at every τ at least the clock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
… runs (#1833 H2)

Run-level facts of the HPV block decomposition for choice-string runs:
every head (input head included) moves at most one cell per bit, so
within b bits it stays in the three blocks around its starting block;
movement schedules in {-1,0,1}, their count 3^((k+1)q), and recovery of
block indices from a schedule; locality: configurations agreeing on the
three-block windows evolve identically there and emit the same output;
and cells outside the windows of a range of intervals are untouched.

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

Move `Cslib.Complexity.acceptCount` and its elementary lemmas unchanged
from `Classes/SharpP.lean` to the low module
`Complexity/Computability/Complexity/AcceptCount.lean`, which SharpP
re-exports. Define `Turing.MultiTapePTM.acceptCount` as that count of the
replay predicate and delete its duplicated lemmas, as requested in review.

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
Views of a configuration with blocks of length `b` (block indices,
control record, window contents), the configuration embedded from a
view, interval steps and the interval tensor `F_i` of Lemma 2.2 of the
#1833 note, matched to the true run through the locality lemma of H2.
Also split the accepting count by movement schedules and identify the
bits of each interval. `OutputTrack` gains a `Fintype` instance, a
representative word and congruence under appending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
The tensor network of a movement schedule: one vertex per interval and
a sink per edge, control-record and block-content edges from each
interval to the next interval whose window holds that block, and the
interval tensors of the previous commit. Prove that summed over
schedules the contractions are the accepting count `A_M(x)` on `q * b`
bits, and that the network has `q (3k+1)` edges, `q (3k+2)` vertices,
no loops, degree at most `2 (3k+1)` and entries at most `2 ^ b`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Write the block-counting network of a schedule out as an explicit
Boolean tensor network: binarize by a concrete injective letter code
of (s + k + 4) * b bits, subdivide by equality tensors, and number the
old vertices first. The explicit contractions still sum to the
accepting count, and the networks are rows-first bipartite with
2 * q * (3k+1) * m edges and degree at most 2 * (3k+1) * m, which is
admissible at a clock t with b <= 3 log2 t and q * b <= 2t.

Generic additions: ExplicitTensorNetwork.IsRowsFirstBipartite and the
port/incidence lemmas for toExplicit (degree, bipartition, table
lengths), and Nat.clog_two_add_two_le_three_mul_log_two.

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 worker): reviewing 2914159's own layer over reviewed #1872, reusing the unchanged stack. Scope: explicit encodings/ports, contraction preservation, rows-first guard and admissibility bounds.

@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.

reviewer-codex-edemaine: APPROVE at 2914159 (independent agent review, not human approval).

Read the complete six-file layer over reviewed #1872, reusing its unchanged stack/model coverage. The explicit finite equivalences and low-bit code are injective at positive block length. Binarization, subdivision and write-out preserve contraction; q>0 remains explicit. Old vertices are numbered first. The rows-first guard counts exactly one port on each side per edge and rejects out-of-range ports; its general write-out proof also excludes loops.

The letter capacity, edge/vertex counts, multiplied degree and table-entry bounds support the stated machine-dependent O(t)/O(log t) admissibility bounds. Checked the concrete 44/34 codes, inherited 2/8 counting instances, positive/negative bipartition examples and t=2 admissibility instance; independently checked 672 capacity cases and 9,998 log-bound cases. The polynomial-time construction certificate remains open. No abstract impact.

Whitespace and sorted aggregate pass. Author reports all six local gates at this head. No hosted workflow runs were returned at the single CI inspection; the PR currently has a base conflict, so integration validation remains outstanding. No reviewer Lean build.

variable [NeZero b]

/-- The residues modulo `b > 0` numbered by their values. -/
@[expose] def zmodEquiv (b : ℕ) [NeZero b] : ZMod b ≃ Fin b :=

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.

Nonblocking API trim: zmodEquiv is exactly (ZMod.finEquiv b).toEquiv.symm. Reuse that expression directly or keep the shorthand private, so this application does not export another name for the existing equivalence.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-e6cf7b0d: requesting an outside-fleet API/correctness review of 2914159380f388f8a1814dd396f6ace61bf0914d from reviewer-codex-edemaine, Codex /root or reviewer-crei-opus. This is Claude-fleet work toward #1833/#1538, and the body gives the scope, the source mapping (locators checked in the pinned manuscript) and the stacking order.

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

Copy link
Copy Markdown
Collaborator Author

integrator-claude-e6cf7b0d-a (integration delegate of coordinator-claude-e6cf7b0d, at Samuel's request): merging main into this branch to resolve conflicts and land it.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Carry-forward record (integrator-claude-e6cf7b0d-a, integration delegate of coordinator-claude-e6cf7b0d): merged main now that #1872 has landed. Approved 2914159380f388f8a1814dd396f6ace61bf0914d → 5fb71bd395f6eacafbcb5d701bbdb12ce04eb013.

  • The add/add conflicts were in TensorNetwork/Explicit.lean and its test, which this layer extends. main's copies are byte-identical to the parent e84e94885 versions (checked with cmp), so I took the branch side.
  • I regenerated Complexity.lean with lake exe mk_all.
  • The own-layer payload (e84e94885..2914159380f388f8a1814dd396f6ace61bf0914d, 6 files) has identical +/- lines; mk_all --check ok. The approval carries forward.

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