feat(polytime): non-vacuous PPT/IsPolyTime over the DynComputation carrier, sorry-free - #500
feat(polytime): non-vacuous PPT/IsPolyTime over the DynComputation carrier, sorry-free#500dtumad wants to merge 6 commits into
Conversation
…ib/cslib Port the Turing-machine complexity layer from the closed reference draft #481, with the machine-counting cruxes proven (from #487): - Encoding: bundled PackedEncoding (Mathlib unbundled Encoding's alphabet on 2026-05-07; the poly-time layer needs Sigma-packaged alphabets before boolify normalizes them to Bool), FinEnum/option/sigma/pair/sum/BitVec combinators with length lemmas. - CslibPolyTime: EncPolyTime over cslib's PolyTimeComputable, retargeted to the restructured Cslib.Turing.SingleTapeTM namespace. - PolyTimeTM, BitEncoding: description-size accounting and binary encodings. - MachineCounting: state-relabeling normalization and the counting bounds, including the exists_tmTable_of_card_le and realizable-covering proofs contributed in #487, adjusted for Mathlib's new ReflTransGen.lift signature. Co-authored-by: Elias Judin <ejudin@gmail.com> Co-authored-by: Aristotle (Harmonic) <aristotle-harmonic@harmonic.fun> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ation carrier Rebuild the TM-grounded polynomial-time adversary core on the merged machine layer: - The TM-facing step maps (expose, updateFlat, output, stepD) are total functions derived from the machine's one-step view, spelled with Sum combinators so they transport definitionally to machines sharing the same dynamics; the readout-stability field is gone (returns are absorbing by construction), and resolution within the round budget is a theorem (PolyTimeWitness.resolvesIn), handler-free via ResolvesIn. - MachineAdversary/PolyTimeWitness/IsPolyTime retarget runK to runWith and the fuelled Implements to DynComputation.ImplementsWithin; the master transfer equation and the no-mass-on-fuel-exhaustion lemma are inherited readings of the upstream run theory. - Closure combinators simplify: replacing init leaves runs unchanged via unroll_setInit (upstream candidate), output post-composition is upstream mapResult with unroll_mapResult, and the precomposition implements-proofs reduce to input reindexing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…te, sorry-free Complete the PPT re-extraction with the remaining machine-facing files: - CoinFold: the bounded coin-fold machine via a new generic OracleMachine.ofStep; the old simulation-relation and steadiness developments collapse to one direct unroll induction, since returns are absorbing by construction. - PolyTimeConstructions: unchanged content over the new carrier. - PolyTimeNontrivial: the isPolyTime_coin certificate and both headline non-triviality theorems, with the three formerly-open cruxes closed by the proofs contributed in #487, ported to the new machine API through runWith_eq_output_iterate_stepD (the unconditional deterministic- trajectory readout that replaces the stability-conditioned lemma). - Asymptotics/PolyTime: secureAgainstPolyTime and the per-query-loss former. No literal sorry remains in the polynomial-time layer. Co-authored-by: Elias Judin <ejudin@gmail.com> Co-authored-by: Aristotle (Harmonic) <aristotle-harmonic@harmonic.fun> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🤖 PR Summary
overview of the pr Statistics
Lean Declarations ✏️ Added: 243 declaration(s)
…and 93 more not listed.
📋 **Additional Analysis**No findings. 📄 **Per-File Summaries**
Last updated: 2026-08-01 20:11 UTC. |
Build Timing Report
Incremental Rebuild Signal
This compares a clean project build against an incremental rebuild in the same CI job; it is a lightweight variability signal, not a full cross-run benchmark. Slowest Current Clean-Build FilesShowing 20 slowest current targets, with comparison against the selected baseline when available.
|
- Charge the final readout in `detTotalTime`: the run's answer is `output (stepD^[steps] s)`, so the readout at the budget state is a real evaluation; `detTotalTime_le` and `exists_polynomial_detTotalTime_le` gain the matching term (closes the remaining #460 accounting bullet). - Derive `PolyTimeWitness.queryBound` as a theorem instead of a field: `ImplementsWithin` is the fuel-k unroll equality, whose bounded half is the total query bound (`implementsWithin_iff_implements_and_bound`; `IsTotalQueryBound` is definitionally `IsTotalRollBound`). All witness constructions shed the redundant proof obligation. - Pin `PolyTimeComputable.size` to the `Bool` alphabet: a bare state count only measures description size over a fixed alphabet, and only `Bool` is counted by `B`. - Drop the unused `PackedEncoding`/`boolify` layer (`Encoding.lean`) and the docstrings presenting it as the model's encoding source; import `Mathlib.Data.Nat.Bitwise` directly where its transitive import was load-bearing. - Generalize `exists_tmTable_of_card_le` to any `SingleTapeTM Bool`; add a real `OracleMachine.setInit` behind the `*_setInit` lemmas. - Refresh stale docstrings: retired names (`PolyTimeAdversary`, dead lemma references), sorry-era prose in `PolyTimeNontrivial`, nonexistent module references; state non-uniformity (P/poly) on `IsPolyTime`; warn against polynomial-depth `comp` iteration; credit Elias Judin in the headers of the two re-extracted #487 files. Co-authored-by: Elias Judin <ejudin@gmail.com> Co-authored-by: Aristotle (Harmonic) <aristotle-harmonic@harmonic.fun> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds docs/agents/polytime-model.md — the model in one paragraph, file ownership map, canonicity-as-discipline rules, proven-vs-deferred status, semantics notes, cslib positioning with the upstream collision watch, and the statement-site checklist — and indexes the layer from AGENTS.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Motivation
Re-extraction of the Turing-machine-grounded polynomial-time layer from the closed reference
draft #481, onto current main: Lean v4.32, current Mathlib/cslib, and the merged
DynComputation-based machine layer (#498/#499) in place of the retiredPointedMachineAPI. Includes the closure of all three non-triviality
sorrys contributed in #487.The model is unchanged from #481 (and from the design agreed in the #460 review): non-uniform
P/poly relative to pinned canonical boundary encodings, with a single polynomial bounding both
per-step running time and machine description size uniformly across the security parameter —
the description-size bound is what closes the truth-table/unbounded-advice escape. The model
and its statement-site discipline are now documented in
docs/agents/polytime-model.md.What moved under the port
ToMathlib/Computability/+ToMathlib/Data/BitVec.lean— the TM toolkit on currentMathlib/cslib. Encodings are raw injective
List Boolfamilies (BitEncFam/StrEncFam)from the start — no intermediate alphabet layer. cslib's restructure
(
SingleTapeTuring.Basic→Turing/SingleTape/Deterministic, namespaceCslib.Turing.SingleTapeTM) is a pure rename — zero proof changes. Per the repo decision(recorded in the new design doc), nothing here is aimed at upstream Mathlib/cslib PRs; it
stays in
ToMathlib/.MachineCounting.leanand the non-triviality closure (from #487). The counting cruxes(
exists_tmTable_of_card_le, the realizable-covering surjection) and the B-factor argumentport with only signature-level adjustments (
ReflTransGen.liftis now a≤-statement; thetrajectory argument reads through the new run lemma below). Credit: Elias Judin, with the
proofs generated by Aristotle (Harmonic); co-author trailers on the porting commits and
co-authorship in the two files' headers.
Coinductive/PolyTime.lean—MachineAdversary/PolyTimeWitness/OracleComp.IsPolyTimeover theDynComputationcarrier. The TM-facing step maps (expose,updateFlat,output,stepD) are total functions derived from the machine's one-stepview, spelled withSumcombinators so they transport definitionally between machinessharing the same dynamics. Three fields of the old bundle are gone as theorems, not
hypotheses: readout stability (returns are absorbing by construction), steadiness
(
PolyTimeWitness.resolvesIn, handler-free viaResolvesIn), and the syntactic query bound(
PolyTimeWitness.queryBound, from the bounded half ofImplementsWithinviaimplementsWithin_iff_implements_and_bound—IsTotalQueryBoundis definitionallyIsTotalRollBound).Coinductive/PolyTimeClosure.lean— closure under input precomposition and output maps.Much thinner: replacing
initis a realOracleMachine.setInitwhose runs are unchanged(
unroll_setInit), output post-composition is upstreammapResult(unroll_mapResult), andthe precomposition implements-proofs reduce to input reindexing.
Coinductive/CoinFold.lean— the reusable bounded-coin-fold combinator. The machine isbuilt by a new generic
OracleMachine.ofStep(one-step transition + initialization) andimplements the fold program by one direct
unrollinduction.Asymptotics/PolyTime.lean—SecurityGame.secureAgainstPolyTimeand theper-query-loss former, consuming the derived
PolyTimeWitness.queryBound.Semantic-audit pass (post-extraction)
A full audit of the layer (definitions vs. the #460 review record, cslib upstream direction,
axiom footprint) produced the following fixes, all in this PR:
detTotalTimecharges the final readout — the run's answer isoutput (stepD^[steps] s), so the readout at the budget state is a real evaluation; theaccounting and both bounding theorems gained the matching term. This closes the last open
feat(OracleComp): oracle strategies as dynamical systems, oracle machines, and TM-grounded poly-time adversaries #460 accounting bullet (the off-by-one).
PolyTimeWitness.queryBoundis a derived theorem, not a field (see above); everywitness construction site shed the redundant obligation.
PolyTimeComputable.sizeis pinned to theBoolalphabet — a bare state count onlymeasures description size over a fixed alphabet; the restriction is now in the type rather
than in prose.
PackedEncoding/boolifylayer is dropped (Encoding.lean, 337 lines ofdead code that two docstrings mispresented as the model's encoding source).
exists_tmTable_of_card_legeneralized to anySingleTapeTM Bool; stale docstringsrefreshed throughout (retired names, sorry-era prose, dangling module references);
IsPolyTimenow states its non-uniformity (P/poly) explicitly.Status of the #460 checklist
descBound; non-triviality certified below);ResolvesInquantifies over every typed answer path;
StrEncFam.len_leover all states);BitEncFam.widBoundis intrinsic —detTotalTime_leandexists_polynomial_detTotalTime_leare hypothesis-free);Still deliberately out of scope (documented in
docs/agents/polytime-model.md): theend-to-end compiled single-machine theorem (#460 item 7's "second tier"),
bindclosure,and a uniform variant.
secureAgainstPolyTimeaccordingly remains unused by any concretesecurity statement this cycle.
Validation
lake buildgreen;scripts/check-extern-isolation.sh,scripts/check-interop-isolation.sh,scripts/check-agent-docs.pysorryanywhere in the added files; headline theorems(
exists_not_isPolyTime_pure,exists_not_implements_pure_of_steps_eq_zero,secureAgainstPolyTime_of_advantage_le_mul_totalQueries,PolyTimeWitness.queryBound,exists_polynomial_detTotalTime_le) all check at exactly[propext, Classical.choice, Quot.sound]ToMathliblayer builds independently of the machine layerOn merge
🤖 Generated with Claude Code