math / data /lean /OAI /Dynamics /EntropyCounterexample /ClockDynamics.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
8.76 kB
import Mathlib
namespace OAI
open Filter Set
open scoped Topology
namespace Problem340.ClockDynamics
theorem bounded_clock_limit {t : β„• β†’ ℝ}
(hmono : Monotone t) (hbounded : BddAbove (Set.range t)) :
βˆƒ T : ℝ, Tendsto t atTop (𝓝 T) ∧
Tendsto (fun n => t (n + 1) - t n) atTop (𝓝 0) := by
have hlimit : Tendsto t atTop (𝓝 (⨆ n, t n)) :=
tendsto_atTop_ciSup hmono hbounded
refine βŸ¨β¨† n, t n, hlimit, ?_⟩
have hnext : Tendsto (fun n => t (n + 1)) atTop (𝓝 (⨆ n, t n)) :=
hlimit.comp (tendsto_add_atTop_nat 1)
simpa using hnext.sub hlimit
theorem bounded_clock_limit_barrier {t : β„• β†’ ℝ} {b : ℝ β†’ ℝ}
(hmono : Monotone t) (hbounded : BddAbove (Set.range t))
(hb : Continuous b) (hb_nonneg : βˆ€ x, 0 ≀ b x)
(hstep : βˆ€ n, b (t n) ≀ t (n + 1) - t n) :
βˆƒ T : ℝ, Tendsto t atTop (𝓝 T) ∧ b T = 0 := by
obtain ⟨T, hlimit, hdiff⟩ := bounded_clock_limit hmono hbounded
refine ⟨T, hlimit, ?_⟩
have hzero : Tendsto (fun n => b (t n)) atTop (𝓝 0) :=
squeeze_zero (fun n => hb_nonneg (t n)) hstep hdiff
exact tendsto_nhds_unique (hb.tendsto T |>.comp hlimit) hzero
theorem bounded_clock_limit_lattice {t : β„• β†’ ℝ} {b : ℝ β†’ ℝ}
(hmono : Monotone t) (hbounded : BddAbove (Set.range t))
(hb : Continuous b) (hb_nonneg : βˆ€ x, 0 ≀ b x)
(hstep : βˆ€ n, b (t n) ≀ t (n + 1) - t n)
(hzeros : βˆ€ x, b x = 0 β†’ βˆƒ k : β„€, x = 50 + 100 * (k : ℝ)) :
βˆƒ k : β„€, Tendsto t atTop (𝓝 (50 + 100 * (k : ℝ))) := by
obtain ⟨T, hlimit, hzero⟩ :=
bounded_clock_limit_barrier hmono hbounded hb hb_nonneg hstep
obtain ⟨k, rfl⟩ := hzeros T hzero
exact ⟨k, hlimit⟩
theorem monotone_of_nonneg_increments {t : β„• β†’ ℝ}
(hstep : βˆ€ n, 0 ≀ t (n + 1) - t n) : Monotone t := by
apply monotone_nat_of_le_succ
intro n
linarith [hstep n]
theorem barrier_trapping {t r : β„• β†’ ℝ} {a T R : ℝ} {N : β„•}
(htN : a ≀ t N ∧ t N ≀ T) (hrN : r N ≀ R)
(hstep : βˆ€ n, N ≀ n β†’ a ≀ t n β†’ t n ≀ T β†’ r n ≀ R β†’
(a ≀ t (n + 1) ∧ t (n + 1) ≀ T) ∧ r (n + 1) ≀ R) :
βˆ€ n, N ≀ n β†’ (a ≀ t n ∧ t n ≀ T) ∧ r n ≀ R := by
intro n hn
induction n, hn using Nat.le_induction with
| base => exact ⟨htN, hrN⟩
| succ n hn ih => exact hstep n hn ih.1.1 ih.1.2 ih.2
theorem exists_first_crossing {t : β„• β†’ ℝ} {a : ℝ}
(hstart : t 0 < a) (hstep : βˆ€ n, t (n + 1) - t n ≀ 1)
(hevent : βˆƒ n, a ≀ t n) :
βˆƒ n, a ≀ t n ∧ t n < a + 1 ∧ βˆ€ m, m < n β†’ t m < a := by
classical
let n := Nat.find hevent
have hn : a ≀ t n := Nat.find_spec hevent
have hbefore : βˆ€ m, m < n β†’ t m < a := by
intro m hm
exact lt_of_not_ge (Nat.find_min hevent hm)
have hnpos : 0 < n := by
by_contra h
have hnzero : n = 0 := by omega
rw [hnzero] at hn
linarith
refine ⟨n, hn, ?_, hbefore⟩
have hp : t (n - 1) < a := hbefore (n - 1) (by omega)
have hs := hstep (n - 1)
have heq : n - 1 + 1 = n := by omega
rw [heq] at hs
linarith
theorem single_visit_short_interval {t : β„• β†’ ℝ} {a b : ℝ}
(hmono : Monotone t) (hwidth : b - a ≀ 1)
(hstep : βˆ€ n, a < t n β†’ t n < b β†’ t (n + 1) = t n + 1)
{i j : β„•} (hi : a < t i ∧ t i < b) (hj : a < t j ∧ t j < b) : i = j := by
have hnotlt : βˆ€ i j, a < t i ∧ t i < b β†’ a < t j ∧ t j < b β†’ Β¬ i < j := by
intro i j hi hj hij
have hle := hmono (Nat.succ_le_of_lt hij)
rw [hstep i hi.1 hi.2] at hle
linarith
exact Nat.le_antisymm (Nat.le_of_not_gt (hnotlt j i hj hi))
(Nat.le_of_not_gt (hnotlt i j hi hj))
theorem squaring_tendsto_zero {R : Type*} [SeminormedRing R] {z : β„• β†’ R}
(hstep : βˆ€ n, z (n + 1) = z n ^ 2) (hsmall : β€–z 0β€– < 1) :
Tendsto z atTop (𝓝 0) := by
have hformula : βˆ€ n, z n = z 0 ^ (2 ^ n) := by
intro n
induction n with
| zero => simp
| succ n ih => rw [hstep, ih, ← pow_mul, Nat.pow_succ]
have hpower := (tendsto_pow_atTop_nhds_zero_of_norm_lt_one hsmall).comp
(tendsto_pow_atTop_atTop_of_one_lt (by norm_num : 1 < (2 : β„•)))
exact hpower.congr (fun n => (hformula n).symm)
theorem eventually_squaring_tendsto_zero {R : Type*} [SeminormedRing R]
{z : β„• β†’ R} (hstep : βˆ€αΆ  n in atTop, z (n + 1) = z n ^ 2)
(hsmall : βˆ€αΆ  n in atTop, β€–z nβ€– < 1) : Tendsto z atTop (𝓝 0) := by
obtain ⟨N, hN⟩ := eventually_atTop.mp (hstep.and hsmall)
apply (tendsto_add_atTop_iff_nat N).mp
apply squaring_tendsto_zero
Β· intro n
have h := (hN (n + N) (by omega)).1
convert h using 1
congr 1
omega
Β· simpa using (hN N le_rfl).2
theorem eventually_small_of_bounded_clock {t r : β„• β†’ ℝ} {R c : ℝ}
(hmono : Monotone t) (hbounded : BddAbove (Set.range t)) (hc : 0 < c)
(hfast : βˆ€ n, R ≀ r n β†’ c ≀ t (n + 1) - t n) :
βˆ€αΆ  n in atTop, r n < R := by
obtain ⟨T, hlimit, hdiff⟩ := bounded_clock_limit hmono hbounded
have hsmall := hdiff.eventually (gt_mem_nhds hc)
filter_upwards [hsmall] with n hn
by_contra h
exact (not_le_of_gt hn) (hfast n (le_of_not_gt h))
theorem bounded_clock_eventually_squaring_tendsto_zero
{R : Type*} [SeminormedRing R] {t : β„• β†’ ℝ} {z : β„• β†’ R} {r c : ℝ}
(hmono : Monotone t) (hbounded : BddAbove (Set.range t))
(hc : 0 < c) (hr : r ≀ 1)
(hfast : βˆ€ n, r ≀ β€–z nβ€– β†’ c ≀ t (n + 1) - t n)
(hstep : βˆ€αΆ  n in atTop, z (n + 1) = z n ^ 2) :
Tendsto z atTop (𝓝 0) := by
apply eventually_squaring_tendsto_zero hstep
filter_upwards [eventually_small_of_bounded_clock hmono hbounded hc hfast] with n hn
exact hn.trans_le hr
theorem preparation_norm_gt_half {t : β„• β†’ ℝ} {z : β„• β†’ β„‚} {N : β„•}
(hmono : Monotone t) (hunbounded : Β¬ BddAbove (Set.range t))
(hstart : 8 ≀ t N ∧ t N ≀ 50)
(htrap : βˆ€ n, N ≀ n β†’ 8 ≀ t n β†’ t n ≀ 50 β†’ β€–z nβ€– ≀ 1 / 2 β†’
t (n + 1) ≀ 50 ∧ z (n + 1) = z n ^ 2) :
1 / 2 < β€–z Nβ€– := by
by_contra h
have hsmall : β€–z Nβ€– ≀ 1 / 2 := le_of_not_gt h
have hinvariant : βˆ€ n, N ≀ n β†’ (8 ≀ t n ∧ t n ≀ 50) ∧ β€–z nβ€– ≀ 1 / 2 := by
apply barrier_trapping hstart hsmall
intro n hn hlow hhigh hz
obtain ⟨hclock, hsquare⟩ := htrap n hn hlow hhigh hz
refine ⟨⟨hlow.trans (hmono (Nat.le_succ n)), hclock⟩, ?_⟩
rw [hsquare, norm_pow]
nlinarith [norm_nonneg (z n)]
apply hunbounded
refine ⟨50, ?_⟩
rintro x ⟨n, rfl⟩
by_cases hn : N ≀ n
Β· exact (hinvariant n hn).1.2
Β· exact (hmono (le_of_not_ge hn)).trans hstart.2
theorem exists_crossing_after {t : β„• β†’ ℝ} {N : β„•} {a : ℝ}
(hmono : Monotone t) (hunbounded : Β¬ BddAbove (Set.range t))
(hstart : t N < a) (hstep : βˆ€ n, t (n + 1) - t n ≀ 1) :
βˆƒ n, N ≀ n ∧ a ≀ t n ∧ t n < a + 1 := by
have hevent : βˆƒ n, a ≀ t (n + N) := by
obtain ⟨x, ⟨m, rfl⟩, hm⟩ := not_bddAbove_iff.mp hunbounded a
exact ⟨m, hm.le.trans (hmono (by omega))⟩
have hstep' : βˆ€ n, t ((n + 1) + N) - t (n + N) ≀ 1 := by
intro n
simpa only [Nat.add_right_comm] using hstep (n + N)
obtain ⟨n, hlow, hhigh, _⟩ :=
exists_first_crossing (t := fun n => t (n + N)) (by simpa using hstart) hstep' hevent
exact ⟨n + N, by omega, hlow, hhigh⟩
theorem exists_later_periodic_reset {t : β„• β†’ ℝ} (hmono : Monotone t)
(hunbounded : Β¬ BddAbove (Set.range t))
(hstep : βˆ€ n, t (n + 1) - t n ≀ 1) (N : β„•) :
βˆƒ n β‰₯ N, βˆƒ k : β„€, 2 + 100 * (k : ℝ) ≀ t n ∧ t n < 3 + 100 * (k : ℝ) := by
obtain ⟨k, hk⟩ := exists_int_gt ((t N - 2) / 100)
have hstart : t N < 2 + 100 * (k : ℝ) := by linarith
obtain ⟨n, hn, hlow, hhigh⟩ := exists_crossing_after hmono hunbounded hstart hstep
refine ⟨n, hn, k, hlow, ?_⟩
linarith
theorem eventually_zero_after_periodic_reset {V : Type*} [Zero V]
{t : β„• β†’ ℝ} {v : β„• β†’ V} (hmono : Monotone t)
(hunbounded : Β¬ BddAbove (Set.range t))
(hstep : βˆ€ n, t (n + 1) - t n ≀ 1)
(hstay : βˆ€αΆ  n in atTop, v n = 0 β†’ v (n + 1) = 0)
(hreset : βˆ€ n (k : β„€), 2 + 100 * (k : ℝ) ≀ t n β†’
t n ≀ 5 + 100 * (k : ℝ) β†’ v (n + 1) = 0) :
βˆ€αΆ  n in atTop, v n = 0 := by
obtain ⟨N, hN⟩ := eventually_atTop.mp hstay
obtain ⟨n, hn, k, hlow, hhigh⟩ := exists_later_periodic_reset hmono hunbounded hstep N
have hzero : v (n + 1) = 0 := hreset n k hlow (by linarith)
apply eventually_atTop.mpr
refine ⟨n + 1, ?_⟩
intro m hm
induction m, hm using Nat.le_induction with
| base => exact hzero
| succ m hm ih => exact hN m (by omega) ih
end Problem340.ClockDynamics
end OAI