Zulip Chat Archive
Stream: new members
Topic: how to formalize this theorem in Lean4?
Zihao Zhang (Apr 03 2025 at 06:10):
Notification Bot (Apr 03 2025 at 06:14):
This topic was moved here from #general > how to formalize this theorem in Lean4? by Johan Commelin.
Johan Commelin (Apr 03 2025 at 06:15):
What have you tried so far?
Zihao Zhang (Apr 03 2025 at 06:20):
@Johan Commelin I just wrote this:
import Mathlib.Probability.Notation
import Mathlib.Probability.Integration
import Mathlib.Probability.Variance
import Mathlib.MeasureTheory.Function.L2Space
open MeasureTheory Filter Finset ProbabilityTheory
noncomputable section
open scoped MeasureTheory ProbabilityTheory ENNReal NNReal
variable {Ω : Type*} {m : MeasurableSpace Ω} {X : Ω → ℝ} {μ : Measure Ω}
variable [MeasureSpace Ω]
I don't know how to define Rademacher random variable in Lean4
Rémy Degenne (Apr 03 2025 at 08:35):
You can state your problem like this:
import Mathlib
open MeasureTheory Finset ProbabilityTheory Measure Real
open scoped ENNReal
variable {Ω : Type*} {m : MeasurableSpace Ω} {P : Measure Ω} -- a measurable space and a measure
{X : ℕ → Ω → ℝ} -- ℕ-indexed real-valued random variables
lemma concentration_inequality
(hX : ∀ n, P.map (X n) = (2 : ℝ≥0∞)⁻¹ • dirac (-1) + (2 : ℝ≥0∞)⁻¹ • dirac 1) -- Rademacher law
(h_indep : iIndepFun X P) -- independence
{ε : ℝ} (hε : 0 ≤ ε) (n : ℕ) :
(P {ω | ε ≤ (∑ i ∈ range n, X i ω) / n}).toReal ≤ exp (n * ε ^ 2 / 2) := by
sorry
Zihao Zhang (Apr 03 2025 at 08:38):
@Rémy Degenne Thank you so much!
Rémy Degenne (Apr 03 2025 at 08:39):
Do you know how the proof should proceed? If you describe a math proof, I could point you to relevant lean statements or files.
Zihao Zhang (Apr 03 2025 at 08:53):
@Rémy Degenne This is the proof.
Rémy Degenne (Apr 03 2025 at 08:59):
In that proof, you prove that a Rademacher random variable is sub-Gaussian in the sense of ProbabilityTheory.HasSubgaussianMGF (click the "source" link: the doc entry is surprisingly unreadable).
And then you can use the result ProbabilityTheory.HasSubgaussianMGF.measure_sum_range_ge_le_of_iIndepFun . Again, look at the source code. I don't know what is happening with the docs.
Zihao Zhang (Apr 03 2025 at 09:01):
Rémy Degenne said:
You can state your problem like this:
import Mathlib open MeasureTheory Finset ProbabilityTheory Measure Real open scoped ENNReal variable {Ω : Type*} {m : MeasurableSpace Ω} {P : Measure Ω} -- a measurable space and a measure {X : ℕ → Ω → ℝ} -- ℕ-indexed real-valued random variables lemma concentration_inequality (hX : ∀ n, P.map (X n) = (2 : ℝ≥0∞)⁻¹ • dirac (-1) + (2 : ℝ≥0∞)⁻¹ • dirac 1) -- Rademacher law (h_indep : iIndepFun X P) -- independence {ε : ℝ} (hε : 0 ≤ ε) (n : ℕ) : (P {ω | ε ≤ (∑ i ∈ range n, X i ω) / n}).toReal ≤ exp (n * ε ^ 2 / 2) := by sorry
It reported an error
image.png
image.png
Kevin Buzzard (Apr 03 2025 at 09:02):
I would recommend that you read and understand the error. Lean is saying "you gave the wrong input to a function" and it's telling you exactly which function and which input.
Rémy Degenne (Apr 03 2025 at 09:06):
iIndepFun
changed recently (it had an explicit argument for the sigma-algebra before). If you open my code in the web editor, you will see it works there. Your Mathlib must be slightly older. Either update or adapt the code to your version.
Zihao Zhang (Apr 03 2025 at 09:06):
OK
Last updated: May 02 2025 at 03:31 UTC