Download data/lean/OAI/MathematicalPhysics/AlternatingFlow/Profiles.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.96 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/AlternatingFlow/Profiles.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MathematicalPhysics/AlternatingFlow/Profiles.lean
-
curl -L -o Profiles.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/AlternatingFlow/Profiles.lean
6.96 kB
| import OAI.MathematicalPhysics.AlternatingFlow.Encoding | |
| namespace OAI | |
| open scoped BigOperators ENNReal NNReal Topology ContDiff | |
| open MeasureTheory | |
| namespace AlternatingNS | |
| namespace Profiles | |
| noncomputable def clock (t : β) : β := | |
| letI := twoAtLeastTwo | |
| Real.smoothTransition (2 * t - 1 / 2) | |
| lemma clock_smooth : ContDiff β β clock := by | |
| unfold clock | |
| fun_prop | |
| lemma clock_mem (t : β) : clock t β Set.Icc (0 : β) 1 := | |
| β¨Real.smoothTransition.nonneg _, Real.smoothTransition.le_one _β© | |
| lemma clock_zero (t : β) (ht : t β€ 1 / 4) : clock t = 0 := by | |
| apply Real.smoothTransition.zero_of_nonpos | |
| linarith | |
| lemma clock_one (t : β) (ht : 3 / 4 β€ t) : clock t = 1 := by | |
| apply Real.smoothTransition.one_of_one_le | |
| linarith | |
| lemma clock_monotone : Monotone clock := by | |
| intro a b hab | |
| apply Real.smoothTransition.monotone | |
| linarith | |
| noncomputable def periodizer (a c x : β) : β := | |
| Int.fract x - Real.smoothTransition ((Int.fract x - a) / (c - a)) | |
| lemma periodizer_periodic (a c : β) : Function.Periodic (periodizer a c) 1 := by | |
| intro x | |
| simp only [periodizer, Int.fract_add_one] | |
| lemma periodizer_int_add (a c : β) (k : β€) (x : β) : | |
| periodizer a c ((k : β) + x) = periodizer a c x := by | |
| simp only [periodizer, Int.fract_intCast_add] | |
| lemma periodizer_self (a c x : β) (hac : a < c) (ha : a < 1) | |
| (hx : x β Set.Icc 0 a) : periodizer a c x = x := by | |
| have hf : Int.fract x = x := Int.fract_eq_self.2 β¨hx.1, hx.2.trans_lt haβ© | |
| rw [periodizer, hf, Real.smoothTransition.zero_of_nonpos] | |
| Β· ring | |
| Β· exact div_nonpos_of_nonpos_of_nonneg (sub_nonpos.mpr hx.2) (sub_pos.mpr hac).le | |
| lemma periodizer_near_zero (a c : β) (ha : 0 < a) (hac : a < c) (hc : c < 1) | |
| (x : β) (hx : x β Set.Ioo (c - 1) a) : periodizer a c x = x := by | |
| by_cases hx0 : 0 β€ x | |
| Β· exact periodizer_self a c x hac (hac.trans hc) β¨hx0, hx.2.leβ© | |
| Β· have hn : βxβ = (-1 : β€) := Int.floor_eq_iff.2 (by norm_num; constructor <;> linarith [hx.1]) | |
| have hf : Int.fract x = x + 1 := by rw [Int.fract, hn]; norm_num | |
| have hh : 1 β€ (x + 1 - a) / (c - a) := | |
| (le_div_iffβ (sub_pos.mpr hac)).2 (by linarith [hx.1]) | |
| rw [periodizer, hf, Real.smoothTransition.one_of_one_le hh] | |
| ring | |
| lemma periodizer_smooth (a c : β) (ha : 0 < a) (hac : a < c) (hc : c < 1) : | |
| ContDiff β β (periodizer a c) := by | |
| rw [contDiff_iff_contDiffAt] | |
| intro x | |
| by_cases hx : x = (βxβ : β) | |
| Β· have hg : ContDiff β β (fun y : β => y - (βxβ : β)) := by fun_prop | |
| apply hg.contDiffAt.congr_of_eventuallyEq | |
| have hlo : (βxβ : β) + (c - 1) < x := by linarith | |
| have hhi : x < (βxβ : β) + a := by linarith | |
| filter_upwards [Ioo_mem_nhds hlo hhi] with y hy | |
| have hy' : y - (βxβ : β) β Set.Ioo (c - 1) a := by | |
| constructor <;> linarith [hy.1, hy.2] | |
| calc | |
| periodizer a c y = periodizer a c ((βxβ : β) + (y - (βxβ : β))) := by congr 1; ring | |
| _ = periodizer a c (y - (βxβ : β)) := periodizer_int_add a c _ _ | |
| _ = y - (βxβ : β) := periodizer_near_zero a c ha hac hc _ hy' | |
| Β· have hg : ContDiff β β (fun y : β => (y - (βxβ : β)) - | |
| Real.smoothTransition (((y - (βxβ : β)) - a) / (c - a))) := by fun_prop | |
| apply hg.contDiffAt.congr_of_eventuallyEq | |
| have hlo : (βxβ : β) < x := (Int.floor_le x).lt_of_ne (Ne.symm hx) | |
| filter_upwards [Ioo_mem_nhds hlo (Int.lt_floor_add_one x)] with y hy | |
| have hy' : βyβ = βxβ := Int.floor_eq_iff.2 β¨hy.1.le, hy.2β© | |
| simp only [periodizer, Int.fract, hy'] | |
| noncomputable def decoder (b : β) : β β β := | |
| letI := twoAtLeastTwo | |
| letI := threeAtLeastTwo | |
| periodizer ((2 * Encoding.tailMax b + 1) / 3) ((Encoding.tailMax b + 2) / 3) | |
| lemma decoder_law (b : β) (hb : 2 β€ b) : Encoding.DecoderLaw b (decoder b) := by | |
| have hm := Encoding.tailMax_lt_one b hb | |
| refine β¨periodizer_periodic _ _, ?_β© | |
| intro x hx | |
| apply periodizer_self | |
| Β· linarith | |
| Β· linarith | |
| Β· exact β¨hx.1, by linarith [hx.2]β© | |
| lemma decoder_smooth (b : β) (hb : 2 β€ b) : ContDiff β β (decoder b) := by | |
| have hm0 := Encoding.tailMax_nonneg b hb | |
| have hm1 := Encoding.tailMax_lt_one b hb | |
| apply periodizer_smooth <;> linarith | |
| lemma iteratedDeriv_periodic (f : β β β) (hf : Function.Periodic f 1) (r : β) : | |
| Function.Periodic (iteratedDeriv r f) 1 := by | |
| have heq : (fun x => f (x + 1)) = f := funext hf | |
| have h := iteratedDeriv_comp_add_const r f 1 | |
| rw [heq] at h | |
| exact fun x => (congr_fun h x).symm | |
| lemma periodic_derivatives_bounded (f : β β β) (hf : Function.Periodic f 1) | |
| (hs : ContDiff β β f) (r : β) : β C : β, 0 β€ C β§ β x, |iteratedDeriv r f x| β€ C := by | |
| have hcont : Continuous (fun x => |iteratedDeriv r f x|) := | |
| (hs.continuous_iteratedDeriv r (WithTop.coe_le_coe.mpr le_top)).abs | |
| obtain β¨C, hCβ© := isCompact_Icc.bddAbove_image (hcont.continuousOn (s := Set.Icc 0 1)) | |
| refine β¨max 0 C, le_max_left _ _, ?_β© | |
| intro x | |
| obtain β¨y, hy, hxyβ© := (iteratedDeriv_periodic f hf r).exists_mem_Ico (by norm_num) x 0 | |
| rw [hxy] | |
| apply le_trans _ (le_max_right _ _) | |
| apply hC | |
| exact β¨y, β¨hy.1, by simpa using hy.2.leβ©, rflβ© | |
| lemma decoder_derivatives_bounded (b : β) (hb : 2 β€ b) (r : β) : | |
| β C : β, 0 β€ C β§ β x, |iteratedDeriv r (decoder b) x| β€ C := | |
| periodic_derivatives_bounded (decoder b) (decoder_law b hb).1 (decoder_smooth b hb) r | |
| end Profiles | |
| namespace Encoding | |
| lemma read_donor_configuration (b N n : β) (hb : 2 β€ b) | |
| (g : β β β) (L R : β β List β) | |
| (hL : β j, (L j).length = Scales.K N j) | |
| (hR : β j, (R j).length = Scales.K N j) | |
| (hd : β j, β d β g j :: (L j ++ R j), d + 2 β€ b) : | |
| let C := fun j => code b (g j :: (L j ++ R j)) | |
| let D := donor b N C n | |
| Profiles.decoder b ((b : β) ^ Scales.s N n * D) = C n β§ | |
| Profiles.decoder b ((b : β) ^ (Scales.s N n + 1 + Scales.K N n) * D) = | |
| code b (R n) β§ | |
| Profiles.decoder b ((b : β) ^ (Scales.s N n + 1) * D) - | |
| ((b : β) ^ Scales.K N n)β»ΒΉ * | |
| Profiles.decoder b ((b : β) ^ (Scales.s N n + 1 + Scales.K N n) * D) = | |
| code b (L n) := by | |
| dsimp only | |
| have hC : β j, β a : β€, | |
| (b : β) ^ (1 + 2 * Scales.K N j) * code b (g j :: (L j ++ R j)) = a := by | |
| intro j | |
| obtain β¨a, haβ© := code_denominator b (by omega) (g j :: (L j ++ R j)) | |
| refine β¨a, ?_β© | |
| simp only [List.length_cons, List.length_append, hL, hR] at ha | |
| have he : 1 + 2 * Scales.K N j = Scales.K N j + Scales.K N j + 1 := by omega | |
| simpa only [he, Int.cast_natCast] using ha | |
| have h := read_configuration b (Scales.s N n) (g n) hb (L n) (R n) | |
| (donor b N (fun j => code b (g j :: (L j ++ R j))) n) | |
| (donor_integer_add b N n (by omega) _ hC) (hd n) | |
| (Profiles.decoder b) (Profiles.decoder_law b hb) | |
| simpa only [hL] using h | |
| end Encoding | |
| end AlternatingNS | |
| end OAI | |