Skip to content

Import the separation of KL and Martin–Löf randomness - #1051

Merged
Vilin97 merged 1 commit into
mainfrom
feature/kl-randomness-20261127
Nov 27, 2026
Merged

Vilin97 merged 1 commit into
mainfrom
feature/kl-randomness-20261127

Conversation

@Vilin97

@Vilin97 Vilin97 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Bjørn Kjos-Hanssen directed the development and supplied mathematical feedback. AI agents wrote the Lean proofs. The Apache-2.0 source is pinned to 81f5fef2de3142aad714624033a5aa4f12031a6b. Source · License · Provenance
  • The separation is the total-strategy result in §2 and Theorem 1 of Liu–Meng, arXiv:2611.31004v1. The production proof was merged on 2026-11-26 at 18:55:05 UTC and Palomar published the registration at 20:24:16 UTC. The base-four extension followed at 23:30:27 UTC. Paper · Palomar · Base-four proof
  • The scheduler follows the parity totalization for the rational-wager model. The even/odd splitting proof used by the base-four example is the specialization of Merkle, Miller, Nies, Reimann and Stephan, Theorem 12. Miller–Nies, §6 · Bienvenu, Remark 1.7.7 · Splitting theorem
  • The 147 upstream source modules are the union of the Separation and BaseInvariance dependency 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.KLRandomness measurements. 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. StageReconstruction took 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, and Quot.sound. Whole-pool checks run in Lean Action CI.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict.

The checked code has no blocking finding; duplicated stage proofs are a non-blocking maintenance concern.RetriggerView in Greptile

[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

  1. P2 Stage proofs need duplicate repairs ▶

Summary

Imports the separation results, partial rational-wager totalization, and binary/base-four comparison.

  • Some binary sequences defeat every total KL bettor but fail Martin-Löf tests.
  • KL-random sequences also defeat infinite partial rational betting runs.
  • Paired base-four randomness can hold when binary KL randomness fails.

Reviews (1) · Last reviewed commit: "Import Kolmogorov–Loveland and Martin–Lö..." · Reviewed by Greptile

@Vilin97 Vilin97 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve the import at 4b749dc1711f77c09da38729d62990c3c19cc8cd.

  • Faithfulness. Klr.ScanRule requires a total computable fresh query on every finite branch. Klr.CapitalProcess imposes fairness and nonnegativity, and Klr.BettingStrategy supplies 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_steps supplies the measurable partitions and extension witnesses consumed by Separation. 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. StageReconstruction went from 12.0 s to 2.9 s. GitHub's separation check passed and the protected Lean build is in progress. Lean Action CI

@github-actions

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

lake build wall time (changed modules): 100.78 s (= 1.68 min) — user 273.54 s, sys 42.82 s.

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 lean --profile: 211916.2 ms (= 211.92 s) across 149 valid files. Import-excluded time: 116346.2 ms (= 116.35 s).

Count-heartbeats wall-clock total: 486.23 s. Repeated import cost inside lean --profile: 95570.0 ms (= 95.57 s).

Heartbeat values sum disjoint root command traces with trace.profiler.useHeartbeats and synchronous elaboration, converted from raw allocations to maxHeartbeats units by dividing by 1000. They include command elaboration and kernel checking, exclude imports, and include profiler overhead; they are not comparable to the deprecated linter's totals. Per-file wall clocks are measured under parallel load and are noisier than heartbeats.

LOC counts added lines in the profiled Lean files from this PR diff.

File LOC Heartbeats (maxHB) Count wall (s) lean --profile (s) Without import (s) Import (s) Commands Errors
LeanPool/KLRandomness/ComputableNonrandom.lean 83 171,132 19.89 4.69 4.05 0.64 20 0
LeanPool/KLRandomness/StageReconstruction.lean 162 166,539 17.57 3.52 2.83 0.69 25 0
LeanPool/KLRandomness/StageRankCode.lean 198 120,195 13.97 3.79 3.08 0.71 26 0
LeanPool/KLRandomness/PartialBetting.lean 491 54,821 8.22 3.23 2.59 0.64 57 0
LeanPool/KLRandomness/StageHorizonComputable.lean 167 54,237 7.17 1.63 0.97 0.66 20 0
LeanPool/KLRandomness/UniformSupportCount.lean 132 51,574 5.08 2.33 1.94 0.39 17 0
LeanPool/KLRandomness/NormalizationSuccess.lean 421 45,228 7.56 3.60 3.07 0.53 46 0
LeanPool/KLRandomness/AffineObservation.lean 253 42,272 5.64 2.12 1.64 0.47 30 0
LeanPool/KLRandomness/BaseFour.lean 521 38,751 6.38 2.95 2.29 0.66 82 0
LeanPool/KLRandomness/SparseListWeights.lean 158 32,642 4.54 1.97 1.26 0.71 17 0
LeanPool/KLRandomness/RandomMatrix.lean 265 31,409 5.01 2.11 1.60 0.51 45 0
LeanPool/KLRandomness/EffectiveNormalization.lean 329 29,772 4.45 2.87 2.22 0.65 63 0
LeanPool/KLRandomness/StagePreHorizon.lean 217 28,425 4.63 1.87 1.21 0.66 18 0
LeanPool/KLRandomness/FiniteMeasure.lean 202 27,450 4.35 1.84 1.19 0.65 28 0
LeanPool/KLRandomness/UniformSupport.lean 194 26,492 3.60 1.76 1.37 0.39 22 0
LeanPool/KLRandomness/SampleConcentration.lean 193 25,578 4.02 1.90 1.35 0.55 14 0
LeanPool/KLRandomness/PoolWeakLimit.lean 170 25,463 4.25 1.69 1.04 0.65 40 0
LeanPool/KLRandomness/ConfinedStageConstruction.lean 205 25,389 5.15 1.74 1.08 0.66 13 0
LeanPool/KLRandomness/AffineProgramLength.lean 157 25,306 4.02 2.01 1.38 0.63 18 0
LeanPool/KLRandomness/SparseCandidateWeights.lean 147 25,090 4.41 1.56 0.97 0.59 16 0
LeanPool/KLRandomness/PoolSelection.lean 176 23,845 4.60 1.82 1.18 0.64 12 0
LeanPool/KLRandomness/AffineAnswerMeasure.lean 154 22,365 3.76 1.58 0.93 0.65 21 0
LeanPool/KLRandomness/SplittingReserve.lean 251 21,873 3.98 2.33 1.68 0.65 39 0
LeanPool/KLRandomness/PoolParameters.lean 275 21,633 4.34 2.04 1.39 0.65 27 0
LeanPool/KLRandomness/PoolApproximationFunction.lean 245 21,601 4.30 2.06 1.42 0.65 18 0
LeanPool/KLRandomness/PoolSoundness.lean 226 20,780 3.49 1.76 1.11 0.66 41 0
LeanPool/KLRandomness/RandomMatrixAlgebra.lean 116 20,155 3.22 1.19 0.69 0.49 33 0
LeanPool/KLRandomness/FairForced.lean 374 19,898 4.54 2.05 1.40 0.65 53 0
LeanPool/KLRandomness/StageWeights.lean 378 19,678 4.30 1.92 1.24 0.67 35 0
LeanPool/KLRandomness/StageRankAverage.lean 148 18,925 3.31 1.38 0.72 0.66 16 0
LeanPool/KLRandomness/Affine.lean 189 18,156 3.50 1.33 0.86 0.47 22 0
LeanPool/KLRandomness/SparseParameters.lean 160 16,764 3.54 1.54 1.00 0.55 22 0
LeanPool/KLRandomness/AffineAnswer.lean 313 16,428 3.78 1.51 0.85 0.66 36 0
LeanPool/KLRandomness/SplittingClopen.lean 265 16,382 3.16 1.78 1.11 0.67 28 0
LeanPool/KLRandomness/SplittingScheduler.lean 412 15,922 3.98 1.98 1.31 0.67 40 0
LeanPool/KLRandomness/FiniteProbability.lean 180 15,742 3.12 1.16 0.81 0.35 40 0
LeanPool/KLRandomness/ParityDescription.lean 362 15,246 4.08 1.74 1.08 0.65 46 0
LeanPool/KLRandomness/EffectiveNormalizationStrategy.lean 347 15,211 3.12 1.76 1.13 0.63 92 0
LeanPool/KLRandomness/ParityPools.lean 268 15,020 2.96 1.83 1.16 0.67 24 0
LeanPool/KLRandomness/ComputableRational.lean 387 15,014 3.15 1.97 1.33 0.63 72 0
LeanPool/KLRandomness/StageRank.lean 262 14,883 3.53 1.53 0.87 0.67 30 0
LeanPool/KLRandomness/PoolWitness.lean 133 14,491 2.96 1.34 0.66 0.68 16 0
LeanPool/KLRandomness/AffineBlock.lean 243 14,486 3.63 1.52 0.86 0.66 37 0
LeanPool/KLRandomness/StageChoice.lean 299 14,151 3.49 1.66 1.00 0.66 26 0
LeanPool/KLRandomness/SparseSearchMask.lean 148 14,113 3.60 1.44 0.78 0.66 21 0
LeanPool/KLRandomness/Normalization.lean 133 13,987 2.67 1.26 0.81 0.45 17 0
LeanPool/KLRandomness/StoppingTranscript.lean 366 13,658 3.44 1.53 0.90 0.63 42 0
LeanPool/KLRandomness/AffineAnswerAlgebra.lean 153 13,381 3.00 1.47 0.82 0.65 20 0
LeanPool/KLRandomness/SparseCandidate.lean 149 13,342 3.25 1.11 0.61 0.51 21 0
LeanPool/KLRandomness/PartialBettingCapital.lean 400 13,303 3.75 1.66 1.05 0.62 57 0
LeanPool/KLRandomness/Sparse.lean 116 12,653 3.17 1.21 0.65 0.56 13 0
LeanPool/KLRandomness/PoolQueryLimit.lean 205 12,146 3.21 1.39 0.76 0.63 24 0
LeanPool/KLRandomness/NoDrop.lean 445 11,710 3.28 1.53 0.87 0.66 52 0
LeanPool/KLRandomness/StageSyndrome.lean 117 11,294 2.89 1.28 0.59 0.69 16 0
LeanPool/KLRandomness/PoolAdviceMeasure.lean 249 11,242 3.14 1.40 0.76 0.64 30 0
LeanPool/KLRandomness/BlockProductAnswer.lean 294 11,123 3.20 1.30 0.67 0.63 31 0
LeanPool/KLRandomness/EarlyLateWagers.lean 349 11,111 3.61 1.50 0.87 0.63 35 0
LeanPool/KLRandomness/PoolWeighted.lean 268 11,108 3.19 1.75 1.07 0.68 47 0
LeanPool/KLRandomness/StageErrorBudget.lean 135 11,061 2.73 1.46 0.80 0.65 21 0
LeanPool/KLRandomness/RemainingRank.lean 220 11,035 2.92 1.47 0.80 0.67 30 0
LeanPool/KLRandomness/AffineFamily.lean 109 10,855 3.18 1.21 0.57 0.64 14 0
LeanPool/KLRandomness/DescriptionBudget.lean 128 10,675 2.41 1.22 0.57 0.65 14 0
LeanPool/KLRandomness/StageFiniteProbability.lean 163 10,493 2.57 1.28 0.63 0.65 22 0
LeanPool/KLRandomness/PoolPartition.lean 168 10,437 3.00 1.42 0.77 0.65 29 0
LeanPool/KLRandomness/StageHorizonChoice.lean 201 9,745 2.75 1.39 0.69 0.69 24 0
LeanPool/KLRandomness/SparseSearchRank.lean 200 9,661 2.99 1.43 0.76 0.67 23 0
LeanPool/KLRandomness/AffineCode.lean 237 9,502 3.16 1.41 0.75 0.65 39 0
LeanPool/KLRandomness/MaximalInequality.lean 173 9,134 3.14 1.45 0.81 0.64 16 0
LeanPool/KLRandomness/PoolQuery.lean 209 8,965 3.04 1.41 0.77 0.64 37 0
LeanPool/KLRandomness/SparseCandidateList.lean 132 8,764 2.38 1.07 0.51 0.56 11 0
LeanPool/KLRandomness/PrefixStage.lean 236 8,761 2.78 1.39 0.72 0.67 34 0
LeanPool/KLRandomness/FutureNoDrop.lean 362 8,547 3.08 1.38 0.75 0.63 39 0
LeanPool/KLRandomness/PoolSearch.lean 223 8,432 2.77 1.24 0.60 0.64 29 0
LeanPool/KLRandomness/SplittingWitness.lean 240 8,316 2.98 1.34 0.66 0.67 27 0
LeanPool/KLRandomness/SparseListSearchComputable.lean 222 8,195 2.88 1.32 0.66 0.67 26 0
LeanPool/KLRandomness/StageSyndromeObjective.lean 202 7,964 3.01 1.22 0.53 0.68 24 0
LeanPool/KLRandomness/PoolAdviceComputable.lean 219 7,646 2.60 1.28 0.63 0.65 24 0
LeanPool/KLRandomness/Betting.lean 208 7,462 2.89 1.46 0.83 0.63 41 0
LeanPool/KLRandomness/SparseCandidateCode.lean 136 7,411 2.13 1.21 0.53 0.68 20 0
LeanPool/KLRandomness/StageCandidateCode.lean 173 7,269 2.73 1.19 0.55 0.64 27 0
LeanPool/KLRandomness/StageHorizon.lean 144 7,179 2.12 1.05 0.59 0.46 17 0
LeanPool/KLRandomness/PairRespecting.lean 123 7,102 2.23 1.21 0.57 0.64 35 0
LeanPool/KLRandomness/PoolAcceptance.lean 153 7,064 2.13 1.13 0.49 0.64 14 0
LeanPool/KLRandomness/StageHorizonChoiceBounds.lean 229 6,964 2.83 1.26 0.57 0.68 21 0
LeanPool/KLRandomness/StageRankLimitMeasure.lean 206 6,944 2.45 1.33 0.65 0.67 26 0
LeanPool/KLRandomness/FiniteStage.lean 177 6,867 2.37 1.09 0.47 0.62 22 0
LeanPool/KLRandomness/PoolPartitionRepresentative.lean 154 6,589 2.22 1.24 0.59 0.65 32 0
LeanPool/KLRandomness/AffineDescription.lean 265 6,379 2.77 1.24 0.61 0.63 41 0
LeanPool/KLRandomness/LateDropBound.lean 257 6,328 2.61 1.24 0.59 0.64 24 0
LeanPool/KLRandomness/MLImpliesKL.lean 105 6,317 2.07 0.98 0.34 0.65 18 0
LeanPool/KLRandomness/StageFiniteWager.lean 230 6,229 2.79 1.24 0.59 0.65 30 0
LeanPool/KLRandomness/PoolCoverage.lean 132 6,196 2.80 1.19 0.54 0.66 28 0
LeanPool/KLRandomness/StageCodeSearch.lean 171 6,181 2.13 1.13 0.49 0.65 17 0
LeanPool/KLRandomness/Cantor.lean 93 5,935 2.05 1.10 0.46 0.64 21 0
LeanPool/KLRandomness/StageRankLimit.lean 195 5,896 2.79 1.21 0.52 0.68 23 0
LeanPool/KLRandomness/ConfinedStageRecursion.lean 213 5,472 2.64 1.14 0.51 0.64 32 0
LeanPool/KLRandomness/BlockProduct.lean 229 5,395 2.01 1.16 0.52 0.64 31 0
LeanPool/KLRandomness/StageFiniteScan.lean 204 5,313 2.62 1.21 0.56 0.65 28 0
LeanPool/KLRandomness/StageCandidate.lean 148 5,305 2.47 1.17 0.49 0.68 26 0
LeanPool/KLRandomness/ScanMeasure.lean 118 5,295 2.30 1.09 0.42 0.68 15 0
LeanPool/KLRandomness/SparseListCodeBridge.lean 114 5,206 2.05 1.10 0.43 0.66 15 0
LeanPool/KLRandomness/AffineCodeCoverage.lean 142 5,194 2.15 1.07 0.42 0.65 18 0
LeanPool/KLRandomness/StageRecursion.lean 218 4,956 2.51 1.18 0.50 0.68 37 0
LeanPool/KLRandomness/MartinLof.lean 121 4,852 2.44 1.06 0.41 0.65 25 0
LeanPool/KLRandomness/StrategyCountability.lean 135 4,844 2.38 1.03 0.41 0.62 22 0
LeanPool/KLRandomness/StageFiniteCondition.lean 71 4,772 2.29 0.99 0.35 0.64 12 0
LeanPool/KLRandomness/StageRankZero.lean 112 4,606 2.34 1.09 0.40 0.69 14 0
LeanPool/KLRandomness/PoolPartitionQuery.lean 165 4,548 2.23 1.16 0.50 0.66 37 0
LeanPool/KLRandomness/StageOneStepDefs.lean 137 4,454 2.34 1.03 0.38 0.65 17 0
LeanPool/KLRandomness/SparseCodeCount.lean 93 4,341 2.18 0.89 0.37 0.52 17 0
LeanPool/KLRandomness/SparseListSearch.lean 161 4,286 2.04 1.10 0.44 0.67 42 0
LeanPool/KLRandomness/StageSyndromeComputable.lean 122 4,211 2.27 1.15 0.49 0.67 16 0
LeanPool/KLRandomness/StageRankProbability.lean 216 4,211 1.98 1.19 0.49 0.70 26 0
LeanPool/KLRandomness/StageOneStep.lean 160 4,207 1.89 1.07 0.38 0.69 17 0
LeanPool/KLRandomness/EffectiveScan.lean 161 3,715 2.36 1.05 0.43 0.62 18 0
LeanPool/KLRandomness/EffectiveOpen.lean 107 3,597 2.38 1.00 0.36 0.64 33 0
LeanPool/KLRandomness/StageCandidateBridge.lean 203 3,552 1.91 1.16 0.46 0.70 25 0
LeanPool/KLRandomness/StageRecursionData.lean 160 3,507 2.38 1.08 0.42 0.66 24 0
LeanPool/KLRandomness/PoolAdvice.lean 152 3,452 2.03 1.05 0.41 0.64 27 0
LeanPool/KLRandomness/StagePrepared.lean 130 3,283 2.17 1.06 0.40 0.67 12 0
LeanPool/KLRandomness/StageEstimates.lean 136 3,140 2.20 1.03 0.36 0.68 16 0
LeanPool/KLRandomness/HorizonAvoidance.lean 166 3,135 1.98 1.08 0.43 0.65 28 0
LeanPool/KLRandomness/StageOneStepBounds.lean 115 2,938 2.13 1.02 0.34 0.69 10 0
LeanPool/KLRandomness/AffineCodePrefix.lean 142 2,919 2.26 1.02 0.38 0.64 18 0
LeanPool/KLRandomness/StageProgramLength.lean 55 2,881 2.24 0.99 0.32 0.67 8 0
LeanPool/KLRandomness/StageConditionalScan.lean 98 2,874 2.13 0.95 0.29 0.66 12 0
LeanPool/KLRandomness/StageStep.lean 59 2,816 2.05 0.90 0.25 0.65 8 0
LeanPool/KLRandomness/StageOneStepHorizon.lean 128 2,701 2.35 0.98 0.32 0.66 11 0
LeanPool/KLRandomness/PoolAdviceTables.lean 131 2,541 1.98 0.98 0.34 0.64 12 0
LeanPool/KLRandomness/HorizonLaw.lean 203 2,481 2.22 1.05 0.40 0.65 22 0
LeanPool/KLRandomness/DropEvents.lean 126 2,349 2.26 0.99 0.35 0.64 17 0
LeanPool/KLRandomness/SparseListSearchEffective.lean 109 2,272 2.13 1.00 0.33 0.68 19 0
LeanPool/KLRandomness/BlockRandomness.lean 139 2,182 2.23 0.95 0.31 0.64 16 0
LeanPool/KLRandomness/ParityConstruction.lean 106 2,146 2.23 0.95 0.28 0.67 10 0
LeanPool/KLRandomness/StageRationalError.lean 47 2,082 1.93 0.98 0.29 0.69 11 0
LeanPool/KLRandomness/PoolApproximation.lean 140 2,019 2.14 0.98 0.36 0.63 24 0
LeanPool/KLRandomness/PoolConstruction.lean 129 1,917 1.93 1.02 0.35 0.67 16 0
LeanPool/KLRandomness/EffectiveSearch.lean 55 1,696 1.65 0.87 0.23 0.64 6 0
LeanPool/KLRandomness/SparseListConstruction.lean 86 1,325 1.99 0.93 0.27 0.66 15 0
LeanPool/KLRandomness/StageEnumeration.lean 48 1,161 1.83 0.86 0.23 0.63 7 0
LeanPool/KLRandomness/Splitting.lean 83 870 1.93 0.92 0.24 0.68 10 0
LeanPool/KLRandomness/StageConstruction.lean 73 783 1.94 0.89 0.23 0.66 9 0
LeanPool/KLRandomness/StagePrefixCode.lean 105 661 1.67 0.94 0.27 0.67 21 0
LeanPool/KLRandomness/AffineDescriptionSeparation.lean 61 508 1.59 0.84 0.20 0.64 7 0
LeanPool/KLRandomness/Separation.lean 65 259 1.90 0.91 0.22 0.69 9 0
LeanPool/KLRandomness/StagePreparedIndex.lean 37 248 1.88 0.88 0.20 0.67 8 0
LeanPool/KLRandomness/BaseInvariance.lean 48 157 1.80 0.86 0.19 0.67 7 0
LeanPool/KLRandomness.lean 25 0 1.98 1.37 0.17 1.20 2 0
LeanPool/KLRandomness/Imports.lean 156 0 1.69 0.83 0.16 0.67 1 0
Total 27,813 2,112,720 486.23 211.92 116.35 95.57 3755 0

Aggregate phase totals

Phase Time
import 95570.0 ms (= 95.57 s)
interpretation 36495.0 ms (= 36.49 s)
tactic execution 20276.0 ms (= 20.28 s)
typeclass inference 19704.8 ms (= 19.70 s)
elaboration 8929.2 ms (= 8.93 s)
simp 7980.3 ms (= 7.98 s)
type checking 5432.6 ms (= 5.43 s)
initialization 4300.5 ms (= 4.30 s)
linting 2273.3 ms (= 2.27 s)
blocked (unaccounted) 1992.4 ms (= 1.99 s)
norm_num 1764.5 ms (= 1.76 s)
parsing 1298.5 ms (= 1.30 s)

Slowest changed modules (from lake build)

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 --profile output for every file are in the run's step summary and proof-profile artifact.

Advisory only — never blocks merge.

@Vilin97

Vilin97 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 LLM review (gpt-6.2-sol, 5 rubrics)

Reviewed head: 4b749dc1711f77c09da38729d62990c3c19cc8cd

Verdict: ✅ approve — computed from the rubric verdicts below, not chosen by a model.

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: Both histories definitions end with h.extend s c.block c.horizon c.specification.above. Both stageEstimates proofs start with refine ⟨hH i, ?_, ?_, ?_, ?_, ?_⟩ and use ← PrefixStage.law_succ_eq_cond, earlyWager_single] at h. StagePreHorizon.exists_fixed_partitions_eventual_candidates and ConfinedStageConstruction.eventual_candidates both use let d : ℝ := (2 : ℝ) ^ (∑ k : Fin n, (B k).rank). StagePrepared.exists_fixed_partitions_prepared and ConfinedStageConstruction.exists_prepared both use obtain ⟨r, hr, hbudget⟩ := (heventually.and hlength).exists. StageConstruction.exists_fixed_partitions_steps and ConfinedStageConstruction.exists_step both use let 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_bound and CapitalProcess.finiteHit_bound both use induction n generalizing v with and exact measure_union_le _ _. The former closes the induction with _ = _ := hbalance v and the latter with _ = _ := d.weighted_children v. Both measure_exceeds_pow_le proofs start with rw [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.event and StoppingTranscript.inputEvent both have body {X | π.transcript X v.length = v}. FairForced.event_snoc and BlockProductAnswer.inputEvent_snoc both use have ht := π.transcript_take X (m := v.length) (n := v.length + 1) (by omega) and have 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.survivingExtensions uses {w | w.length = n ∧ v <+: w ∧ B.UnreadFullRank π w} and FutureNoDrop.survivingExtensions uses {w | w.length = n ∧ v <+: w ∧ Safe B j π w}. Both survivingExtensions_prefixFree proofs end in exact h.eq_of_length (hu.1.trans hw.1.symm), and both inputEvent_inter_survival_eq_union proofs use refine ⟨π.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 in AffineCodeCoverage and 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_bounded and AffineCode.exists_valid_code_of_affineBlock both prove surjectivity with refine ⟨fun j => if hj : j.val ∈ B.support then x ⟨j.val, hj⟩ else 0, ?_⟩ and both use let D := B.matrix.comp restrict followed by let A := LinearMap.toMatrix' D. The unrestricted proof sets let 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.lean and BaseFour.lean declare def ComputableRealCapital (d : List Bool → ℝ) : Prop := and def ComputableRealCapital (d : List Digit → ℝ) : Prop := with the same bound ∀ v n, |(q v n : ℝ) - d v| ≤ (1 / 2 : ℝ) ^ n. Their ScanRule.fresh fields both use n < v.length → query (v.take n) ≠ query v, and both transcript recursions append v ++ [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.boundedSum takes f : ℕ → ℕ and PoolAdvice.boundedSum in PoolAdviceComputable.lean takes f : ℕ → ℚ. Both have | n + 1 => boundedSum f n + f n, and both computable_list_sum proofs end with exact 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.trial uses fun C => if check rules A M C then some C else none, SparseListSearch.trial uses (Encodable.decode n).bind fun L => if check p L then some L else none, and the affine trial in StageCodeSearch.lean uses (Encodable.decode k).bind (fun c => if check r n p c then some c else none). All three computable_trial proofs end with exact Computable.bind_decode_iff.mpr hf, and all three output proofs unpack Nat.rfindOpt_spec then 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.

@Vilin97
Vilin97 added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit a157db8 Nov 27, 2026
27 checks passed
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.

Proposed project: KL-randomness

1 participant