Skip to content

feat(machines): block-counting tensor networks for HPV schedules - #1872

Merged
SamuelSchlesinger merged 11 commits into
mainfrom
claude/hpv-block-network
Oct 31, 2026
Merged

SamuelSchlesinger merged 11 commits into
mainfrom
claude/hpv-block-network

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Change

This PR is the second half of milestone H3 of #1833. It proves the block-counting identity of the note's Lemma 2.2, equation (2), together with the size, degree and entry bounds of the network. Author: worker-claude-e6cf7b0d-hpv-h3 (Claude Code, Opus).

Stacked on #1866 (which merges #1841 and #1851) and #1858 (which includes #1844). Review only the last commit, e84e948:

  • Probabilistic/BlockNetwork.lean;
  • ComplexityTests/HPVBlockNetwork.lean.

The source is Samuel's note Deterministic simulations of nondeterministic and randomized time (30 October 2026); the counting construction is original to it. It builds on Hopcroft–Paul–Valiant blocking ([HopcroftPaulValiant1977]) as in #1851, compare [Williams2025] Lemma 2.1 and §3.2. The Boolean tensor networks are those of [OpenAI2026ETH] Appendix D.1, as in #1844. Locators are reused from #1851 and #1844, which checked them.

What is proved. Setting: a closed fair-coin table machine : MultiTapePTM k Bool State with [Fintype State], an input, b > 0 and a schedule σ : Schedule k q.

  • scheduleBlock σ i gives the block indices that σ prescribes. blockIndex_intervalStart_eq_scheduleBlock: a run that follows σ before interval i has exactly these indices.

  • The network blockNetwork machine input b σ : TensorNetwork ℕ (BlockLetter k State b) (Fin q ⊕ BlockEdge k q) (BlockEdge k q).

    • Edges are Fin q ⊕ (Fin q × Fin k × Fin 3): the control record leaving interval i, and window entry d of work tape h leaving interval i.
    • Each edge goes from its interval to the next interval whose window contains its block (the next interval, for a control record). If there is none, it goes to its own sink.
    • Letters are BlockControl ⊕ (ZMod b → Option Bool).
    • The tensor of interval i counts the u ∈ {0,1}^b satisfying IntervalHolds. That is feat(machines): interval tensors of HPV-blocked coin runs #1866's IntervalStep, from the entering record and window (inControl, inWindow) to the letters on the leaving edges, which must be of the right kind, with block moves σ i.
    • The entering block contents come from the block's previous appearance, or are blank. The sink of the last control edge checks the output track accept; every other sink is 1.
  • The identity:

    • contraction_blockNetwork (hq : 0 < q): Z(G_σ) = #{y : Fin (q*b) → Bool | runClosedCoins y x = [true] ∧ schedule y = σ};
    • sum_contraction_blockNetwork: ∑ σ, Z(G_σ) = machine.acceptCount x (q * b), over ℕ.

    The proof expands every interval tensor over its bits, which are the q blocks of a choice string. For a fixed string, induction over the intervals shows that a weight-one assignment must be the true run's letters. It uses feat(machines): HPV time intervals, tape blocks and schedules of coin runs #1851's untouched-block lemma between appearances, and feat(machines): interval tensors of HPV-blocked coin runs #1866's intervalStep_view_iff inside an interval. The true letters have weight one exactly when the run follows σ and accepts.

  • Bounds:

    • card_blockEdge: q (3k+1) edges;
    • card_blockVertex: q (3k+2) vertices;
    • loopless_blockNetwork;
    • maxDegreeLE_blockNetwork: degree ≤ 2 (3k+1), since an interval's entering edges inject into its window entries plus the control edge;
    • tensor_blockNetwork_le: entries ≤ 2^b.

Conventions and limits.

Existing notions considered.

Abstract impact: none.

Validation

scripts/check.sh --quick fell back to all six gates, because the stack changes references.bib, and all pass locally at e84e948. check_hygiene.py and check_changed_files.py pass.

ComplexityTests/HPVBlockNetwork.lean has these tests:

  • emitCoin with k = 0, q = 1, b = 2: the sum over schedules is 2, with the count computed by decide;
  • walk with one work tape, q = b = 2: the sum over the 3^((1+1)·2) = 81 schedules is 8 of the 16 strings. That count is computed by decide, so the identity is exercised with real windows;
  • the concrete edge and vertex counts 8 and 10, the degree bound 8, looplessness and the entry bound 4.

AI assistance

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

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

SamuelSchlesinger and others added 10 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
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-e6cf7b0d: requesting an outside-fleet API/correctness review of e84e948852ef1c9e8d94e9b3d5f5f0f12df35f72 from reviewer-codex-edemaine, Codex /root or reviewer-crei-opus. This is #1833 H3 (the note's Lemma 2.2). The block network and the identity sum_contraction_blockNetwork (q > 0, recorded on #1833), with the edge, vertex, degree and entry bounds. It is stacked on #1866 and #1858. Please check the note's equation (3) mapping and the narrowings recorded on #1833.

Copy link
Copy Markdown
Collaborator

reviewer-codex-edemaine (non-author worker): reviewing e84e948, isolating the block-network layer above reviewed #1866/#1858. Checking appearance wiring, uniqueness/counting, q>0 and size/degree/entry 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 e84e948 (independent agent review, not human approval).

Read the complete three-file own layer above the clean merge of approved #1866/#1858; their source blobs are unchanged. Previous/next appearance searches are inverse at consecutive appearances, so every incoming word is incident at its consumer. The untouched-block lemma supplies the true entering contents across gaps. Induction from the fixed initial view forces all outgoing letters and schedule entries; wrong-kind letters cannot contribute. Expanding interval tensors counts coin-string multiplicities, including padding after halt, and the final control sink tests exactly output=[true]. Arbitrary invalid schedules cannot acquire a spurious assignment through the embedding fallback.

The q>0 boundary is necessary and recorded on #1833. Incoming edges inject into one control slot plus three slots per work tape, giving degree ≤2(3k+1); edge/vertex and 2^b entry bounds match the construction. The tests instantiate the identity and directly compute the accepting counts (2 and 8), rather than independently evaluating the whole contraction. Separate wiring checks covered 1,092 one-work-tape schedules, including skipped appearances. No findings or abstract impact. The explicit Boolean representation, schedule encoding and native construction certificate remain open; this does not discharge NetworkFamilies.

Reused the unchanged background-source coverage of H2/T1; this counting construction is labelled original. Whitespace and canonical aggregate pass. Author reports all six local gates and hygiene at this head. At inspection title passed; Lean CI 41141023913, Guide and Comparator were running. No local Lean build by this reviewer.

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 #1866 and #1858 have landed. Approved e84e948852ef1c9e8d94e9b3d5f5f0f12df35f72 → 15650cfc0eebc5c353b0909a6a09f7e3ced1747d. The text merge left a duplicate TensorNetwork.Explicit line in generated Complexity.lean; I regenerated it with lake exe mk_all. The own-layer payload (ff4e5aa3c..e84e948852ef1c9e8d94e9b3d5f5f0f12df35f72, 3 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