Repository navigation
feat(FineGrained): exact MAX-SAT and polynomial-bit weighted counting - #2100
Open
SamuelSchlesinger wants to merge 28 commits into
Open
SamuelSchlesinger wants to merge 28 commits into
SamuelSchlesinger wants to merge 28 commits into
Conversation
…aluation and interpolation Correctness half of #1538 milestone E2. Defines the contraction of a described network in B_{P,ℓ} = (ℤ/2^P)[V]/(V^ℓ) (`truncContraction`) and reduces it to contractions over A_P = (ℤ/2^P)[U]/(f) of the network specialized at binary-digit points, followed by Lagrange interpolation (`interpContract`, `interpContract_eq`). No resource bounds yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…d of take The zero-padded cut `cutCoeffs` is a map over `List.range`, which has a plain polynomial-time rule; `List.take` does not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
… reduction Stacked on the correctness layer (#2037), for #1538 milestone E2. `engineCertificate` runs `interpContract` as one native machine around any certificate of a contraction over A_P, streaming over the digit points with `IndexFold`. `truncDirectCertificate` instantiates it with direct summation at `FastContraction.modulus n`, a native machine for `truncContraction` on every input. No time or space bound of the loop yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…res (#1538 E1) Theorem D.1 of the ETH manuscript (p. 53) contracts networks whose entries are computed by procedures rather than listed in tables. This adds the interface the contraction algorithm provides for them: `EntryAdmissible` (Theorem D.1's hypotheses with one constant, degree at most `ceilNineTenths s`), `EntryContractionAlgorithm` (A_P-valued output, correct at the modulus `FastContraction.modulus m`, ContractionAlgorithm-shaped bounds), and direct summation with an entry procedure with its correctness and resources on every input and on admissible inputs. The input format matches the truncation-order reduction's `encCore`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…neTenths_iff Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…reduction `engineCertificate_le` bounds the native machine of the truncation-order reduction by its calls: if each of the N + 1 charged calls takes time at most R, space at most Q and outputs at most Yb bits, the machine takes time (N + 1) (K (n + Yb + 1) ^ K + R) and space K (n + Yb + 1) ^ K + Q. `length_encCore_coreInput_le` bounds each call's input by 9 (n + 1) ^ 2, and `specEntryCertificate_le` bounds specialized entries by the original entry plus a polynomial. The certificates of `TruncatedPolyTime.lean` are exposed so that their resources can be bounded downstream, and its `PolyTime.List`/`PolyTime.Nat` imports become public because the exposed bodies use them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
… specialized networks `directCoreCertificate_le` and `truncDirectCertificate_le` bound direct summation over a specialized network, and the truncated contraction by direct summation: with the entry certificate within time E and space ES on the vertices of a network with m edges, both take time K (n + ES + 1) ^ K 2 ^ m (E + 1) and space K (n + ES + 1) ^ K. This is the cost of the fallback branch of the truncation-order assembly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…a contraction over A_P `TruncatedContractionAlgorithm` states Theorem D.1 at truncation order ℓ for described networks, in the shape of `ContractionAlgorithm`. `TruncatedContractionAlgorithm.ofCore` assembles it from a contraction over A_P of the specialized networks that is correct at the modulus of the number of edges and meets the interface's bound (the planned E1 interface of #1538): it branches on `truncGuard`, whether the modulus has enough residues for the interpolation points, to the reduction around the contraction or to direct summation. `truncGuard_of_le` shows that admissible inputs take the first branch once s ≥ 4 (C D + 1). A test instance for networks with boundedly many edges shows that the interface is not vacuous. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…ric in the root descriptor type `VertexDesc T := T ⊕ PacketDesc`, read through an entry procedure `ev : T → List Bool → List ℕ`, and `Call T`, `scheme ev mk`, `value ev mk`, `StepCorrect ev mk WF` and the polynomial-time and size modules over any `T`. Explicit tables are `T = List ℕ` with `tableEntry`; the leaf machine and `CountingSimulation.Fast*` stay at tables, so `fastContractionAlgorithm` and the #1995 containments keep their statements. First PR of #1538 milestone E1.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
… entry procedure `VertexDesc.entryCertificate ce` evaluates every descriptor from a native certificate `ce` of the roots' entry procedure (option on `getLeft?`), and `entryCertificate_le` adds the root's time and space. `leafCertificate ce`, `leafCertificate_le ce` (time `K (n + R + ES + 1) ^ K 2 ^ M ((R + 2) ^ Λ + E)`) and `leafCertificate_le_of_packetShape ce` follow; tables are `tableEntryCertificate`, whose polynomial cost gives back the previous table bound. Second PR of #1538 milestone E1.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
… reduced-list helper Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
… claude/e1-entry-instance
…entry procedures Drops the copies of tableEntry and its certificate from EntryContraction.lean (VertexDesc.lean's win) and adds the guarded entry machine: the guard and its polynomial-time test, the root call and clock, the result and its correctness at the modulus of the number of edges, and the native certificate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Root descriptors keep their number of ports along the native recursion, so the entry bounds of admissibility apply at every reached leaf; the leaf bound with entry costs; polynomial sizes from guarded roots; the leaf bounds on admissible inputs. Generalizes Reach.wf_packetShape and Reach.edges_le_two_mul_scale to any descriptor type and adds packetShape_of_net_eq_rootNet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
The resource analysis of the entry machine on admissible inputs, the machine within the interface's bounds (exists_fastCore_le), and the instance entryContractionAlgorithm ce : EntryContractionAlgorithm encT entry (EntryAdmissible ce), with tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…hedule; tidy exposure Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…laude/d1-of-entry
… procedures `TruncatedContractionAlgorithm.ofEntry` instantiates `ofCore` with a contraction algorithm for the specialized entries and discharges its hypotheses: specialization keeps networks admissible (`exists_entryAdmissible_specNet`), entries fit `poly(L) 2 ^ O(s)` (`exists_entry_le_of_entryAdmissible`), and the shape comes from `TruncEntryAdmissible`, which adds the vertex bound `k ≤ C s` to `EntryAdmissible`. `CountingSimulation.truncEntryContractionAlgorithm ce` applies it to `entryContractionAlgorithm (specEntryCertificate entry ce)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…ce for the entry interface Address the two findings of the review of #2042 at 5cd05f4, whose layer this branch carries: - Bind `(P, fl, _, G)` by name in `sumInput_polyTime` and in the result function of `directCore`, and state `directCore_time`, `directCore_space` and `directCore_le` over `P fl r G` instead of reaching into `x.2.2.2`. Definitional behavior is unchanged (`directCore_time`/`_space` remain `rfl`, and `fastCore`'s `congr` proof is untouched). - Test that the instance `tableAlgorithm : EntryContractionAlgorithm ..` satisfies its `bound` on an admissible input (two parallel edges at size 2), and point to it from the interface's test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…laude/d1-of-entry Bring in the named-component and nonvacuity fixes of #2042's layer on #2060. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
#2045 landed. Every conflicted file on main is byte-identical to #2045's approved head 9a2232e, so take this branch's side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Address the review of #2047 at 21015c2: `rootInput_polyTime` and the body of `entryCertificate` bind `((_, bs), t)` by name instead of reaching into `p.1.2`. Both forms are definitionally equal, so the certificate, its `congr` proofs and the resource bound are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…ude/e1-entry-instance
… and leaf factor Address the review of #2060 at 48ee919: - Named components (#1764). `EntryContraction.guard`, `rootCall` and `clock` match on `(P, fl, r, G)`; `coreValue` on `x@(P, fl, _, G)` and the returned value `(tag, coeffs)`; `valueTag_polyTime`, `valueList_polyTime` and `fastCore_time`/`_space` bind `(tag, coeffs)`; and `CountingSimulation.length_parts_le_encInput` is stated over `P fl r G`. All are definitionally equal to the projection forms. - One rows-first test. `DescribedNetwork.rowsFirst_polyTime` moves to the new module `Frontier/TensorNetwork/RowsFirstPolyTime.lean`, and `CountingSimulation.fastGuard_polyTime` uses it in place of its own copy. `ContractionSchedule.degreeBound_mono` moves to `Schedule.lean`. - One leaf factor. `FastContraction.exists_leafFactor_le` bounds `2 ^ M (A p + 2) ^ A` once; `exists_leafCertificate_le` (tables) and `exists_leafCertificate_le_of_entry` both use it. - Frontier facts out of `CountingSimulation`: `NativeChild.exists_mem_of_mem_nativeChild_inl` moves to `NativeChild.lean`, `FastContraction.Reach.exists_root_of_inl` to `FastContractionShape.lean`, `FastContraction.exists_leafCertificate_le_of_entry` to `FastContractionLeaf.lean`, and `EntryContraction.packetShape_rootCall` to `EntryContractionMachine.lean`. Their names and statements are unchanged. The elaborated types of #1995's six theorems and of `fastContractionAlgorithm` are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…laude/d1-of-entry
Retarget after #2060 squash-merged; regenerate Complexity.lean with mk_all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Certify native threshold counts, score histograms, and optimum values for MAX-SAT, including the sparse fixed-width variable bound. Extend the contraction clock to logarithmic precision overhead and polynomial truncation order, then recover natural weighted tensor and CSP counts through binary-digit polynomials. Includes the entry-procedure truncation interface from #2067; its original authorship and commit ancestry are preserved. Developed with ChatGPT/Codex and parallel implementation agents, with separate non-authoring agent review.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This establishes the exact MAX-SAT and natural weighted-counting milestone from the counting roadmap, with ordinary native Turing-machine time and space certificates.
For an input of encoded length
L, the new endpoints use polynomial space and timepoly(L) · 2^{O(N / sqrt(log(N + 2)))}:Nis literal occurrences plus clauses. For fixed widthkand at mostc(n+1)clauses, the sparse endpoints give2^{O_{k,c}(n / sqrt(log(n+2)))} poly(L). Counts range over all declared assignments, including unused variables, and preserve repeated and empty clauses. The declared variable count is unary, literal indices are binary, and output counts are binary.Nis the occurrence count; bounded occurrence gives the variable-count rate. The counter checks its scope and bit-budget promises, so the resource theorem holds on every encoded input.The main entry points are
MaxSAT.exists_histogram_algorithm,MaxSAT.exists_optimum_algorithm, their sparse variants, andBinaryWeightedCounting.exists_partitionFunctionCounter_of_weightBits/BinaryWeightedCounting.exists_partitionFunctionCounter_boundedDegree_of_weightBits.Mathematics and native implementation
The weighted endpoint needs more than the previously stated linear precision and truncation ranges. This extends the contraction analysis to
1 ≤ P ≤ D·s·(log₂ s + 1)and1 ≤ ℓ ≤ D·(s+1)^d, still with a linear vertex bound. The normalized-precision clock, polynomial interpolation overhead, and fixed small-size fallback preserve the contraction exponent. Resource constants are chosen before the input.A natural weight is replaced by its binary-digit polynomial. Exact coefficient recovery followed by evaluation at 2 reconstructs the weighted count; the bit budget, degree, precision, entry evaluation, and output decoding are all proved and charged. MAX-SAT uses linear-size population-count/threshold circuits and a native polynomial-query/postprocessing closure.
These enlarged parameter ranges extend Theorem D.1 of the pinned OpenAI2026ETH manuscript. The module documentation distinguishes the paper's stated ranges from the extensions proved here and records the source mapping.
Scope and dependencies
This is a completed milestone for optimum values, score distributions, and natural weights. Native optimizing-assignment extraction, signed/rational weight interfaces, a variable-count bound for dense exact MAX-SAT, and the full D.2 application in #1538 remain open. ROADMAP.md preserves these gaps. No selected formal abstract or catalogue claim changes.
The branch includes the entry-procedure truncation interface from #2067 (head
cfa776be) and preserves its author credit and ancestry. The general truncation assembly from #2044 is already on the base branch. The new result is separate from closing #1538 or superseding #2067's review.Validation and independent review
Validated and reviewed source revision:
1e618125.All six required project gates passed in Lean Action CI run 41242903927, which checked this head merged with current main:
lake build --wfail --iofaillake exe mk_all --checklake test --wfail --iofaillake lintlake exe lint-stylelake exe checkInitImportsThe entire CI job, including source hygiene, changed-file documentation, registry references, and the tidy-statement checks, succeeded. The Guide build and PR-title check also passed.
Local strict build, aggregate check, hygiene, and focused endpoint tests passed. The duplicate local full-test run was stopped after hosted CI passed the full tests; that interrupted local run is not counted as a pass. Hosted CI supplies the complete validation record.
Independent, non-authoring reviewer
/root/independent_reviewapproves correctness and API for the revision above, with no open findings. The review covered the actual definitions, encodings, native reductions, quantitative bounds, parameter order, edge cases, and pinned-paper mapping. The public tuple-projection and stale-roadmap findings were fixed, and the general table-bit bound was moved beside its definition. The reviewer independently checked the successful CI metadata and logs.The review covers this development and the relevant changed interfaces; it relies on the existing library for unchanged underlying theorems.
Ownership and AI assistance
Task owner: ChatGPT/Codex coordinator session, branch
feat/maxsat-weighted-counting-20261031; this PR records the requested milestone and remaining scope. Parallel agents developed the MAX-SAT, precision, and weighted-counting components. ChatGPT/Codex generated and revised proofs, tests, and documentation; a separate non-authoring agent reviewed the source/API, source mapping, quantitative bounds, and edge cases. This is agent review, not human approval. The inherited #2067 implementation was written with Claude Code (Opus), as disclosed there. Handoff: awaiting maintainer review.