A Lean 4 / Mathlib formalization of the theorem on the flashlight transformation of copulas from
A. Onken, S. Grünewälder, M. H. J. Munk, K. Obermayer (2009). Analyzing Short-Term Noise Dependencies of Spike-Counts in Macaque Prefrontal Cortex Using Copulas and the Flashlight Transformation. PLoS Computational Biology 5(11): e1000577. https://doi.org/10.1371/journal.pcbi.1000577
The informal proof is given in the supplementary Text S1.
Let C be a d-copula that is the distribution function of a random vector U on [0,1]^d,
and let S ⊆ {1, …, d}. Then the flashlight transformation
C^F_S(u) := P((⋂_{i ∈ S} {U_i > 1 - u_i}) ∩ (⋂_{i ∉ S} {U_i ≤ u_i}))
is again a copula, and
C^F_S(u) = ∑_{A ⊆ S} (-1)^|A| C(κ_{S,A}(1, u), …, κ_{S,A}(d, u)),
where κ_{S,A}(i, u) is 1 - u_i for i ∈ A, 1 for i ∈ S \ A, and u_i for i ∉ S.
In Lean, this is Flashlight.flashlight, stated in Challenge.lean:
theorem flashlight (μ : Measure (ι → ℝ)) [IsProbabilityMeasure μ]
{C : (ι → ℝ) → ℝ} (hC : IsCopula C)
(hμ : ∀ u ∈ unitCube ι, C u = μ.real {x | ∀ i, x i ≤ u i}) (S : Finset ι) :
IsCopula (flashlightMeasure μ S) ∧
∀ u ∈ unitCube ι,
flashlightMeasure μ S u = ∑ A ∈ S.powerset, (-1) ^ #A * C (kappa S A u)The index set {1, …, d} is modeled by an arbitrary finite type ι. IsCopula requires the
function to satisfy C(1, …, 1) = 1, to be grounded, to have uniform marginal distributions and
to be d-increasing on [0,1]^ι.
The repository follows the challenge/solution layout checked by lake comparator:
| File | Contents |
|---|---|
Challenge.lean |
the definitions used in the statement (unitCube, boxVolume, IsCopula, kappa, flashlightMeasure) and the statement of the theorem, proved by sorry; imports only Mathlib |
Flashlight/Defs.lean |
the same definitions, for the library |
Flashlight.lean |
the proof |
Solution.lean |
the solution module for lake comparator, which imports Flashlight |
comparator.json |
the theorem to compare and the permitted axioms |
formalization.yaml |
metadata in the formalization.yaml v0.4 format: sources, status, fidelity, review |
To trust the result, it suffices to read Challenge.lean, which contains no proofs.
lake comparator checks in a sandbox that Solution.lean proves exactly the statement in
Challenge.lean with identical definitions, that the Lean kernel accepts the proof, and that it
uses no axioms beyond propext, Classical.choice and Quot.sound. CI runs this check on every
push and pull request.
The formalization follows the proof in Text S1:
- Lemma (
restrictMeasure):P^A := P(• ∩ A)is a measure. - Flashlight formula (
flashlightMeasure_eq_flashlightSum): acalcchain. - Copula properties (
isCopula_flashlightSum): normalization, groundedness, uniform marginal distributions andd-increasing property.
One step of the original proof is made explicit. Identifying
P_U((⋂_{i ∈ A} {U_i ≤ 1 - u_i}) ∩ (⋂_{i ∈ S̄} {U_i ≤ u_i})) with C(κ_{S,A}(1, u), …)
replaces the events {U_i ≤ 1}, i ∈ S \ A, by the whole space. This is justified in
measure_compl_le_one_eq_zero and measureReal_eq_kappa: since C(1, …, 1) = 1, the event
⋂_i {U_i ≤ 1} has probability one.
Install Lean via elan, then run:
git clone https://github.com/asnelt/flashlight.git
cd flashlight
lake exe cache get
lake buildTo check the proof against the challenge, install
bubblewrap (e.g. apt install bubblewrap) and run:
lake comparatorThe API documentation is generated by CI and published at https://asnelt.github.io/flashlight/docs.
If you use this formalization, please cite the original paper (see CITATION.cff).