Repository navigation
Import the separation of KL and Martin–Löf randomness - #1051
Conversation
|
Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict. [Medium impact] The PR adds a substantial formal library whose effects are limited to Lean users working with algorithmic randomness. The checked code has no blocking finding; duplicated stage proofs are a non-blocking maintenance concern. Findings
SummaryImports the separation results, partial rational-wager totalization, and binary/base-four comparison.
Reviews (1) · Last reviewed commit: "Import Kolmogorov–Loveland and Martin–Lö..." · Reviewed by Greptile |
Vilin97
left a comment
There was a problem hiding this comment.
Approve the import at 4b749dc1711f77c09da38729d62990c3c19cc8cd.
- Faithfulness.
Klr.ScanRulerequires a total computable fresh query on every finite branch.Klr.CapitalProcessimposes fairness and nonnegativity, andKlr.BettingStrategysupplies one algorithm for uniform rational approximations. The ML tests use effective open levels with the geometric measure bound for the actual fair-coin product measure.StageConstruction.exists_fixed_partitions_stepssupplies the measurable partitions and extension witnesses consumed bySeparation. The reconstruction theorem chooses a program before the three finite inputs, and the final separation places no additional construction premise on the witness. The partial-strategy result quantifies over fresh rational-wager runs. The base-four comparison uses the order-preserving grouping of adjacent pairs and the proved even/odd splitting theorem. - Significance and prior art. The theorem separates two standard algorithmic-randomness notions under the explicit total-strategy convention. The reusable dependencies provide effective open tests, transcript probability laws, affine parity conditioning and computable argument transformations. The analogous Mathlib computability and probability primitives are dependencies. Searches of pinned Mathlib, Tau Ceti, the pool and existing PRs found no matching formalization of these endpoints.
- Source and license. The source paper's Theorem 1 and §2 give the separation and strategy model. The partial rational-wager theorem and adjacent-pair result are identified as separate upstream results, with the latter proved in upstream PR 3. I compared the Lean bodies and internal direct import edges of all 147 copied modules against the pinned source in bounded file groups and checked the closure from both endpoints. The changes are explicit import narrowing, source notices and documentation, a definitional conversion, simp annotations, a named instance and removal of redundant hypotheses implied by surjectivity. Source paper · Pinned port source · Base-four proof
- Engineering and trust. The project uses no added Lake dependencies. The pinned local build, Mathlib project lint, style, generated indexes, static quality, compiler-message and axiom/option audits passed for the public project. Cold project-only rebuild time was 168.81 s on the baseline and 52.92 s on this committed head, both with warm dependencies on the Azure VM.
StageReconstructionwent from 12.0 s to 2.9 s. GitHub's separation check passed and the protected Lean build is in progress. Lean Action CI
Proof profile (new / modified Lean files)
This build covers the changed modules and their dependency cones on top of the restored cache. The serial per-file sums below are useful for ranking slow files, not as a build budget. Total heartbeats: 2,112,720 maxHeartbeats units across 149 valid files (27,813 added LOC). Sum of Count-heartbeats wall-clock total: 486.23 s. Repeated import cost inside Heartbeat values sum disjoint root command traces with LOC counts added lines in the profiled Lean files from this PR diff.
Aggregate phase totals
Slowest changed modules (from
|
| Changed module | Lake time |
|---|---|
LeanPool.KLRandomness.ComputableNonrandom |
8.70 s |
LeanPool.KLRandomness.BaseFour |
4.00 s |
LeanPool.KLRandomness.StageRankCode |
4.00 s |
LeanPool.KLRandomness.StageReconstruction |
3.70 s |
LeanPool.KLRandomness.PartialBetting |
3.60 s |
LeanPool.KLRandomness.PoolWeakLimit |
3.40 s |
LeanPool.KLRandomness.NormalizationSuccess |
3.40 s |
LeanPool.KLRandomness.SparseListWeights |
3.10 s |
LeanPool.KLRandomness.StageHorizonComputable |
3.10 s |
LeanPool.KLRandomness.EffectiveNormalization |
3.00 s |
LeanPool.KLRandomness.Affine |
2.90 s |
LeanPool.KLRandomness.AffineObservation |
2.90 s |
Comment truncated to fit GitHub's 64 KB limit. This PR profiles 149 files; the per-file table shows only the 149 hottest by heartbeats. The full table and raw
lean --profileoutput for every file are in the run's step summary andproof-profileartifact.
Advisory only — never blocks merge.
🤖 LLM review (
|
| Rubric | Verdict | Bottom line |
|---|---|---|
| Faithfulness | ✅ pass |
All three Lean headlines match the card, and the proofs supply the finite-stage estimates and reconstruction programs used to construct the witnesses. |
| Novelty | ✅ pass |
The existing pool and targeted searches of the pinned Mathlib and Tau Ceti sources yielded no duplicate declaration for any of the three headlines, and a full semantic comparison with Mathlib and Tau Ceti remains unverifiable. |
| Significance | ✅ pass |
The project proves two strict containments in algorithmic randomness and develops the affine conditioning and verified reconstruction used to construct their witnesses. |
| Sources | ✅ pass |
Liu and Meng’s §2 and Theorem 1 support the strict inclusion for total computable-real strategies, and the pinned upstream development supports both the partial rational-wager corollary and the adjacent-pair base-four extension. Liu–Meng · Pinned upstream · Base-four extension |
| Code quality (advisory) | flag |
The confined and unrestricted constructions duplicate the core stage proofs, and several shared measure and computability arguments also have separate implementations. |
| Aspect | Value |
|---|---|
| Proves the claim | ✅ proves_it |
| Matches cited source | ✅ matches |
| Fit | ✅ good_fit |
| Level | research |
| Branch | algorithmic randomness |
| Mode | theory_building |
| Code quality | 2 / 5 |
Statement check: For total fresh scans with uniformly computable real capital, Martin–Löf randomness implies binary KL randomness, which implies KL randomness of the adjacent base-four digits, with both inclusions strict and the first separation witness also having bounded capital on every infinite fresh partial rational-wager run.
Martin–Löf randomness is strictly stronger than Kolmogorov–Loveland randomness for total fresh scans with uniformly computable real capital, the separating witness also defeats every infinite fresh partial rational-wager run, and adjacent pairing can yield a KL-random base-four stream from a binary sequence that fails KL randomness.
Significance findings (1)
- prompt-injection — PR-wide
The PR discussion embeds a non-blocking assessment in HTML fallback markup, which can steer automated reviewers reading the raw discussion. Strip the hidden assessment from the review input.
Evidence: The first PR comment contains<ruby><rp>The checked code has no blocking finding; duplicated stage proofs are a non-blocking maintenance concern.</rp></ruby>.
Code quality findings (8)
- duplicate-proof —
LeanPool/KLRandomness/ConfinedStageRecursion.lean:63
The confined and unrestricted paths maintain separate proofs of history agreement, disjointness, horizon avoidance, and stage estimates. The duplication starts earlier in candidate selection, rank preparation, and cutoff handling. Share the finite construction over the pool predicate and the recursion over a dependent step selector. The confined selector can carry its support proof through choice, and the unrestricted pool predicate can be always true.
Evidence: Bothhistoriesdefinitions end withh.extend s c.block c.horizon c.specification.above. BothstageEstimatesproofs start withrefine ⟨hH i, ?_, ?_, ?_, ?_, ?_⟩and use← PrefixStage.law_succ_eq_cond, earlyWager_single] at h.StagePreHorizon.exists_fixed_partitions_eventual_candidatesandConfinedStageConstruction.eventual_candidatesboth uselet d : ℝ := (2 : ℝ) ^ (∑ k : Fin n, (B k).rank).StagePrepared.exists_fixed_partitions_preparedandConfinedStageConstruction.exists_preparedboth useobtain ⟨r, hr, hbudget⟩ := (heventually.and hlength).exists.StageConstruction.exists_fixed_partitions_stepsandConfinedStageConstruction.exists_stepboth uselet z' := max z ((PrefixStage.prefixSupport old n).sup id + 1). - duplicate-proof —
LeanPool/KLRandomness/FairForced.lean:201
The weighted-law maximal inequality repeats the fair-coin induction and the passage to the infinite tree. A correction to the stopping argument would require two edits. Move the weighted-balance argument into the shared maximal-inequality module and derive the fair-coin result from transcript masses and the existing child balance calculation.
Evidence:FairForced.finiteHit_boundandCapitalProcess.finiteHit_boundboth useinduction n generalizing v withandexact measure_union_le _ _. The former closes the induction with_ = _ := hbalance vand the latter with_ = _ := d.weighted_children v. Bothmeasure_exceeds_pow_leproofs start withrw [d.exceeds_eq_iUnion_finiteHit, (d.finiteHit_mono π ((2 : ℝ) ^ m) []).measure_iUnion]. - duplicate-definition —
LeanPool/KLRandomness/FairForced.lean:39
Two public APIs name the same transcript event and independently prove how it changes when one answer is appended. Put the event and append lemma in the scan-measure layer so both the weighted-balance and block-product proofs use the same API.
Evidence:FairForced.eventandStoppingTranscript.inputEventboth have body{X | π.transcript X v.length = v}.FairForced.event_snocandBlockProductAnswer.inputEvent_snocboth usehave ht := π.transcript_take X (m := v.length) (n := v.length + 1) (by omega)andhave hb : X (π.query v) = b := by simpa using List.append_cancel_left h. - duplicate-proof —
LeanPool/KLRandomness/FutureNoDrop.lean:92
The single-block and future-block developments repeat the fixed-length extension, prefix-free union, and measurability arguments. Those proofs depend only on a predicate on finite transcripts. Factor them into a shared lemma so changes to the transcript decomposition apply to both callers.
Evidence:NoDrop.survivingExtensionsuses{w | w.length = n ∧ v <+: w ∧ B.UnreadFullRank π w}andFutureNoDrop.survivingExtensionsuses{w | w.length = n ∧ v <+: w ∧ Safe B j π w}. BothsurvivingExtensions_prefixFreeproofs end inexact h.eq_of_length (hu.1.trans hw.1.symm), and bothinputEvent_inter_survival_eq_unionproofs userefine ⟨π.length_transcript X n, ?_, hfull⟩. - duplicate-proof —
LeanPool/KLRandomness/StageCodeSearch.lean:32
The exact-width code theorem and the unrestricted block theorem independently prove the same padding, surjectivity, and event-preservation argument. Put the exact-width version inAffineCodeCoverageand derive the unrestricted theorem by choosing the support bound and dropping the width equality. Search termination and prefix-code construction can then share the same correctness proof.
Evidence:StageCodeSearch.exists_valid_code_boundedandAffineCode.exists_valid_code_of_affineBlockboth prove surjectivity withrefine ⟨fun j => if hj : j.val ∈ B.support then x ⟨j.val, hj⟩ else 0, ?_⟩and both uselet D := B.matrix.comp restrictfollowed bylet A := LinearMap.toMatrix' D. The unrestricted proof setslet m := B.support.sup id + 1. - duplicate-definition —
LeanPool/KLRandomness/BaseFour.lean:207
The binary and base-four APIs separately define the same computability predicate, scan freshness condition, and transcript recursion. These conventions can drift between the two sides of the conversion theorems. Parameterize that shared layer by the alphabet and keep the fairness equations local to each alphabet.
Evidence:Betting.leanandBaseFour.leandeclaredef ComputableRealCapital (d : List Bool → ℝ) : Prop :=anddef ComputableRealCapital (d : List Digit → ℝ) : Prop :=with the same bound∀ v n, |(q v n : ℝ) - d v| ≤ (1 / 2 : ℝ) ^ n. TheirScanRule.freshfields both usen < v.length → query (v.take n) ≠ query v, and both transcript recursions appendv ++ [X (π.query v)]. - duplicate-definition —
LeanPool/KLRandomness/StageFiniteScan.lean:30
Natural and rational summation each carry a copy of the bounded recursion, its list agreement lemmas, and its computability proof. Share the summation over a primitively codable additive monoid with computable addition so scan-depth and rational-average callers use the same recursion.
Evidence:StageFiniteScan.boundedSumtakesf : ℕ → ℕandPoolAdvice.boundedSuminPoolAdviceComputable.leantakesf : ℕ → ℚ. Both have| n + 1 => boundedSum f n + f n, and bothcomputable_list_sumproofs end withexact hc.of_eq fun a => boundedSum_getD (f a) (l a) default. - duplicate-proof —
LeanPool/KLRandomness/PoolSearch.lean:103
Pool search, sparse-list search, and affine reconstruction each implement the same decode-and-check search and repeat its computability and output-soundness proofs. Share the search over the verifier and its coding instance so changes to enumeration or decoding need one proof update.
Evidence:PoolAdvice.trialusesfun C => if check rules A M C then some C else none,SparseListSearch.trialuses(Encodable.decode n).bind fun L => if check p L then some L else none, and the affinetrialinStageCodeSearch.leanuses(Encodable.decode k).bind (fun c => if check r n p c then some c else none). All threecomputable_trialproofs end withexact Computable.bind_decode_iff.mpr hf, and all three output proofs unpackNat.rfindOpt_specthen split the verifier result.
Tokens: 6,914,038 in / 43,327 out across 5 model calls · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $28.3061 (Standard API equivalent; uncached input)
Each rubric is an independent review against .github/review-rubrics/ on top of .github/REVIEW_RULES.md. Disagree? Reply on the PR; rules can be updated in a PR of their own.
Scope
Closes #1037.
This imports the proof that Martin–Löf random binary sequences are a proper subset of the Kolmogorov–Loveland random sequences for the total fresh-scan, uniformly computable-real capital convention. The same construction gives a sequence defeating all infinite fresh runs of partial rational-wager programs. It also imports the upstream extension proving that KL randomness of the base-four digit stream formed by adjacent pairs does not imply binary KL randomness. The partial-real scope is as stated in the source: the program result concerns rational wagers.
The library supplies effective open tests, fair-coin conditioning on finite parity constraints, finite rank and counting estimates, on-line rational normalization and totalization, and the short reconstruction programs used to combine the finite stages into an infinite witness. These support later formal work on algorithmic randomness and adaptive betting.
Upstream
81f5fef2de3142aad714624033a5aa4f12031a6b. Source · License · ProvenanceSeparationandBaseInvariancedependency closures. The independent comparator templates and alternate sparse-search modules are outside those closures.Port and measurements
Lean Pool and the source already use Lean 4.36.0 and the exact Mathlib revision
fc4f59e577feb1a4956671bc04ac18aaaf8cd842. The port preserves the declarations' namespace, adds the headers and project indexes, replaces a backward elaboration override with an explicit conversion of the syndrome vector's index type, and narrows ten omnibus tactic imports to specific tactic and mathematics modules. Mathlib's project lint additionally required API docstrings, canonical simp behavior, a named rational computability instance, and removal of redundant finiteness hypotheses implied by surjectivity.With the same Azure VM and pinned warm dependencies, the project-only objects were cold for both
lake --no-ansi -v build +LeanPool.KLRandomnessmeasurements. The first port built in 168.81 s. After import minimization and lint repairs, the committed head built in 52.92 s, with 6,619 Lake jobs versus 7,807.StageReconstructiontook 12.0 s on the baseline and 2.9 s on the committed head. Local build times are affected by other VM activity. The final public aggregate is validated separately after the linter repairs.Validation
Local checks cover the public aggregate, Mathlib project lint, text style, static quality, the axiom and option audit, build messages and generated indexes. The permitted axioms are
propext,Classical.choice, andQuot.sound. Whole-pool checks run in Lean Action CI.