Download lean/OAI/MeasureTheory/SelfSimilar/Coding.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 6.27 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/MeasureTheory/SelfSimilar/Coding.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/MeasureTheory/SelfSimilar/Coding.lean
-
curl -L -o Coding.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/MeasureTheory/SelfSimilar/Coding.lean
6.27 kB
Lean 4 · 22
declarations statementsfull
def shift (ω : ℕ → ι) (n : ℕ) : ι := ω (n+1) def slope (S : System ι) (ω : ℕ → ι) (n : ℕ) : ℝ := body · 1 line
∏ j ∈ Finset.range n, S.ratio (ω j)def term (S : System ι) (ω : ℕ → ι) (n : ℕ) : ℝ := body · 1 line
slope S ω n * S.offset (ω n)noncomputable def point (S : System ι) (ω : ℕ → ι) : ℝ := ∑' n, term S ω n theorem slope_zero (S : System ι) (ω : ℕ → ι) : slope S ω 0 = 1 := by simp [slope] theorem slope_succ (S : System ι) (ω : ℕ → ι) (n : ℕ) :
slope S ω (n+1) = slope S ω n * S.ratio (ω n) := by proof · 1 line
simp [slope, Finset.prod_range_succ]theorem slope_shift (S : System ι) (ω : ℕ → ι) (n : ℕ) :
slope S ω (n+1) = S.ratio (ω 0) * slope S (shift ω) n := by proof · 2 lines
simp only [slope, Finset.prod_range_succ', shift]
ringtheorem abs_slope_le (S : System ι) (ω : ℕ → ι) {c : ℝ}
(hc : 0 ≤ c) (hr : ∀ i, |S.ratio i| ≤ c) (n : ℕ) :
|slope S ω n| ≤ c^n := by proof · 5 lines
induction n with
| zero => simp [slope_zero]
| succ n ih =>
rw [slope_succ, abs_mul, pow_succ]
exact mul_le_mul ih (hr _) (abs_nonneg _) (pow_nonneg hc _)theorem abs_term_le (S : System ι) (ω : ℕ → ι) {c T : ℝ}
(hc : 0 ≤ c) (_hT : 0 ≤ T) (hr : ∀ i, |S.ratio i| ≤ c)
(ht : ∀ i, |S.offset i| ≤ T) (n : ℕ) : |term S ω n| ≤ c^n*T := by proof · 2 lines
rw [term, abs_mul]
exact mul_le_mul (abs_slope_le S ω hc hr n) (ht _) (abs_nonneg _) (pow_nonneg hc n)theorem term_summable (S : System ι) (ω : ℕ → ι) : Summable (term S ω) := by proof · 4 lines
obtain ⟨c,T,hc,hc1,hT,hr,ht⟩ := S.exists_uniform_bounds
apply Summable.of_norm_bounded ((summable_geometric_of_lt_one hc.le hc1).mul_right T)
intro n
simpa only [Real.norm_eq_abs] using abs_term_le S ω hc.le hT hr ht ntheorem point_shift (S : System ι) (ω : ℕ → ι) :
point S ω = S.affine (ω 0) (point S (shift ω)) := by proof · 8 lines
rw [point, (term_summable S ω).tsum_eq_zero_add]
have he : (fun n => term S ω (n+1)) = fun n => S.ratio (ω 0)*term S (shift ω) n := by
funext n
simp only [term, slope_shift, shift]
ring
rw [he, tsum_mul_left]
simp only [term, slope_zero, one_mul, System.affine, point]
ringtheorem slope_measurable (S : System ι) (n : ℕ) : Measurable (fun ω => slope S ω n) := by proof · 3 lines
apply Finset.measurable_prod
intro j hj
exact (measurable_of_finite _).comp (measurable_pi_apply j)theorem term_measurable (S : System ι) (n : ℕ) : Measurable (fun ω => term S ω n) := proof · 1 line
(slope_measurable S n).mul ((measurable_of_finite _).comp (measurable_pi_apply n))theorem point_measurable (S : System ι) : Measurable (point S) := by proof · 5 lines
apply measurable_of_tendsto_metrizable
(fun n => Finset.measurable_sum (s := Finset.range n) (fun j _ => term_measurable S j))
apply tendsto_pi_nhds.mpr
intro ω
exact (term_summable S ω).hasSum.tendsto_sum_natnoncomputable def symbolMeasure (S : System ι) : Measure ι := body · 1 line
∑ i, ENNReal.ofReal (S.weight i) • Measure.dirac iinstance symbolMeasure_probability (S : System ι) : IsProbabilityMeasure (symbolMeasure S) where body · 5 lines
measure_univ := by
simp only [symbolMeasure, Measure.finsetSum_apply, Measure.smul_apply,
Measure.dirac_apply_of_mem (Set.mem_univ _), smul_eq_mul, mul_one]
rw [← ENNReal.ofReal_sum_of_nonneg (fun i _ => S.weight_nonneg i), S.weight_sum]
simpnoncomputable def addressMeasure (S : System ι) : Measure (ℕ → ι) := body · 1 line
Measure.infinitePi fun _ : ℕ => symbolMeasure Sinstance addressMeasure_probability (S : System ι) : IsProbabilityMeasure (addressMeasure S) := body · 1 line
inferInstanceAs (IsProbabilityMeasure (Measure.infinitePi fun _ : ℕ => symbolMeasure S))noncomputable def law (S : System ι) : Measure ℝ := (addressMeasure S).map (point S) instance law_probability (S : System ι) : IsProbabilityMeasure (law S) := body · 1 line
(Measure.isProbabilityMeasure_map_iff (point_measurable S).aemeasurable).2 inferInstancetheorem head_tail_point_law (S : System ι) :
(addressMeasure S).map (fun ω => (ω 0,point S (shift ω))) =
(symbolMeasure S).prod (law S) := by proof · 6 lines
have h := congrArg (Measure.map (Prod.map id (point S)))
(Bernoulli.head_tail_law (symbolMeasure S))
rw [Measure.map_map (measurable_id.prodMap (point_measurable S))
((measurable_pi_apply 0).prodMk Bernoulli.shift_measurable)] at h
rw [← Measure.map_prod_map _ _ measurable_id (point_measurable S), Measure.map_id] at h
exact htheorem law_selfSimilar (S : System ι) : S.SelfSimilar (law S) := by proof · 23 lines
classical
let f : ι × ℝ → ℝ := fun z => S.affine z.1 z.2
have hf : Measurable f := by
exact ((measurable_of_finite S.ratio).comp measurable_fst).mul measurable_snd |>.add
((measurable_of_finite S.offset).comp measurable_fst)
have hh := congrArg (Measure.map f) (head_tail_point_law S)
have hp : Measurable (fun ω : ℕ → ι => (ω 0,point S (shift ω))) :=
(measurable_pi_apply 0).prodMk ((point_measurable S).comp Bernoulli.shift_measurable)
rw [Measure.map_map hf hp] at hh
have he : f ∘ (fun ω => (ω 0,point S (shift ω))) = point S :=
funext fun ω => (point_shift S ω).symm
rw [he] at hh
change law S = _ at hh
change law S = _
conv_lhs => rw [hh]
change ((∑ i, ENNReal.ofReal (S.weight i) • Measure.dirac i).prod (law S)).map f = _
rw [← Measure.sum_fintype, Measure.prod_sum_left, Measure.sum_fintype,
Measure.map_finset_sum hf.aemeasurable]
apply Finset.sum_congr rfl
intro i hi
rw [Measure.prod_smul_left, Measure.map_smul _ hf.aemeasurable, Measure.dirac_prod,
Measure.map_map hf measurable_prodMk_left]
rflOutline
- def
shift21 - def
slope23 - def
term26 - def
point29 - theorem
slope_zero32 - theorem
slope_succ35 - theorem
slope_shift40 - theorem
abs_slope_le46 - theorem
abs_term_le56 - theorem
term_summable62 - theorem
point_shift68 - theorem
slope_measurable82 - theorem
term_measurable88 - theorem
point_measurable91 - def
symbolMeasure98 - instance
symbolMeasure_probability101 - def
addressMeasure108 - instance
addressMeasure_probability111 - def
law114 - instance
law_probability116 - theorem
head_tail_point_law119 - theorem
law_selfSimilar129