math / data /lean /OAI /Dynamics /EntropyCounterexample /ClockPrediction.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
6.59 kB
import Mathlib
namespace OAI
noncomputable section
open Filter Set
namespace Problem340
theorem clock_readings_separated {t : β„• β†’ ℝ} (ht : Monotone t)
{i j : β„•} (hij : i < j) (hstep : t (i + 1) = t i + 1) :
t i + 1 ≀ t j := by
rw [← hstep]
exact ht (Nat.succ_le_of_lt hij)
theorem clock_readout_unique {t : β„• β†’ ℝ} {Ξ² : ℝ β†’ ℝ} {a b : ℝ}
(ht : Monotone t) (hwidth : b - a < 1)
(hsupport : βˆ€ x, Ξ² x β‰  0 β†’ a < x ∧ x < b)
(hstep : βˆ€ n, Ξ² (t n) β‰  0 β†’ t (n + 1) = t n + 1)
{i j : β„•} (hi : Ξ² (t i) β‰  0) (hj : Ξ² (t j) β‰  0) : i = j := by
obtain hij | hij | hij := lt_trichotomy i j
Β· have hsep := clock_readings_separated ht hij (hstep i hi)
have hi' := hsupport (t i) hi
have hj' := hsupport (t j) hj
linarith
Β· exact hij
Β· have hsep := clock_readings_separated ht hij (hstep j hj)
have hi' := hsupport (t i) hi
have hj' := hsupport (t j) hj
linarith
theorem clock_readout_support_subsingleton {t : β„• β†’ ℝ} {Ξ² : ℝ β†’ ℝ} {a b : ℝ}
(ht : Monotone t) (hwidth : b - a < 1)
(hsupport : βˆ€ x, Ξ² x β‰  0 β†’ a < x ∧ x < b)
(hstep : βˆ€ n, Ξ² (t n) β‰  0 β†’ t (n + 1) = t n + 1) :
Set.Subsingleton {n : β„• | Ξ² (t n) β‰  0} := by
intro i hi j hj
exact clock_readout_unique ht hwidth hsupport hstep hi hj
theorem tsum_clock_readout_eq_single {E : Type*} [NormedAddCommGroup E]
[NormedSpace ℝ E] {t : β„• β†’ ℝ} {Ξ² : ℝ β†’ ℝ} {a b : ℝ}
(ht : Monotone t) (hwidth : b - a < 1)
(hsupport : βˆ€ x, Ξ² x β‰  0 β†’ a < x ∧ x < b)
(hstep : βˆ€ n, Ξ² (t n) β‰  0 β†’ t (n + 1) = t n + 1)
(v : β„• β†’ E) {j : β„•} (hj : Ξ² (t j) β‰  0) :
(βˆ‘' n, Ξ² (t n) β€’ v n) = Ξ² (t j) β€’ v j := by
apply tsum_eq_single j
intro n hnj
have hn : Ξ² (t n) = 0 := by
by_contra hn
exact hnj (clock_readout_unique ht hwidth hsupport hstep hn hj)
simp [hn]
theorem tsum_clock_readout_eq_zero {E : Type*} [NormedAddCommGroup E]
[NormedSpace ℝ E] {t : β„• β†’ ℝ} {Ξ² : ℝ β†’ ℝ}
(v : β„• β†’ E) (hzero : βˆ€ n, Ξ² (t n) = 0) :
(βˆ‘' n, Ξ² (t n) β€’ v n) = 0 := by
simp [hzero]
theorem clock_unit_speed_add {t : β„• β†’ ℝ} {a b : ℝ}
(ht : Monotone t)
(hstep : βˆ€ n, a ≀ t n β†’ t n ≀ b β†’ t (n + 1) = t n + 1)
(i d : β„•) (ha : a ≀ t i) (hb : t (i + d) ≀ b) :
t (i + d) = t i + (d : ℝ) := by
induction d with
| zero => simp
| succ d ih =>
have hd : t (i + d) ≀ b := (ht (by omega)).trans hb
have hlo : a ≀ t (i + d) := ha.trans (ht (by omega))
have heq := hstep (i + d) hlo hd
have hprev := ih hd
simpa [Nat.succ_eq_add_one, Nat.add_assoc, Nat.cast_add, Nat.cast_one,
hprev, add_assoc] using heq
theorem clock_preparation_card_le_five {t : β„• β†’ ℝ}
(ht : Monotone t)
(hstep : βˆ€ n, 8 ≀ t n β†’ t n ≀ 12 β†’ t (n + 1) = t n + 1)
(I : Finset β„•) (hI : βˆ€ i ∈ I, 8 < t i ∧ t i < 12) : I.card ≀ 5 := by
classical
by_cases hne : I.Nonempty
Β· let i := I.min' hne
have hi : i ∈ I := Finset.min'_mem I hne
have hsub : I βŠ† Finset.Icc i (i + 4) := by
intro j hj
have hij : i ≀ j := Finset.min'_le I j hj
have hadd : i + (j - i) = j := Nat.add_sub_of_le hij
have htime := clock_unit_speed_add ht hstep i (j - i)
(hI i hi).1.le (by simpa [hadd] using (hI j hj).2.le)
rw [hadd] at htime
have hgap : (j - i : ℝ) < 4 := by
have hi' := (hI i hi).1
have hj' := (hI j hj).2
have hcast : ((j - i : β„•) : ℝ) = (j : ℝ) - (i : ℝ) :=
Nat.cast_sub hij
rw [hcast] at htime
linarith
have hgap' : j - i < 4 := by
have : ((j - i : β„•) : ℝ) < (4 : β„•) := by
simpa [Nat.cast_sub hij] using hgap
exact_mod_cast this
exact Finset.mem_Icc.mpr ⟨hij, by omega⟩
have hc := Finset.card_le_card hsub
simp only [Nat.card_Icc] at hc
omega
Β· simp [Finset.not_nonempty_iff_eq_empty.mp hne]
theorem clock_prediction_agreement {X : Type*} {x y : β„• β†’ X}
{clock : X β†’ ℝ} {a b : ℝ} {N : β„•}
(hzero : x 0 = y 0)
(hbefore : βˆ€ n < N, x n = y n β†’ clock (x n) < a β†’ x (n + 1) = y (n + 1))
(hxstep : βˆ€ n < N, a ≀ clock (x n) β†’ clock (x n) ≀ b β†’
clock (x (n + 1)) = clock (x n) + 1)
(hystep : βˆ€ n < N, a ≀ clock (y n) β†’ clock (y n) ≀ b β†’
clock (y (n + 1)) = clock (y n) + 1)
(hbound : βˆ€ n < N, clock (x n) ≀ b) :
βˆ€ n ≀ N, clock (x n) = clock (y n) := by
have hfast (n : β„•) (hn : n < N) (heq : clock (x n) = clock (y n))
(ha : a ≀ clock (x n)) :
clock (x (n + 1)) = clock (y (n + 1)) ∧ a ≀ clock (x (n + 1)) := by
have hx := hxstep n hn ha (hbound n hn)
have hy := hystep n hn (heq β–Έ ha) (heq β–Έ hbound n hn)
constructor
Β· rw [hx, hy, heq]
Β· linarith
have hinv : βˆ€ n ≀ N,
x n = y n ∨ (clock (x n) = clock (y n) ∧ a ≀ clock (x n)) := by
intro n
induction n with
| zero => intro _; exact Or.inl hzero
| succ n ih =>
intro hn
have hn' : n < N := by omega
rcases ih (by omega) with heq | ⟨heq, ha⟩
Β· by_cases ha : clock (x n) < a
Β· exact Or.inl (hbefore n hn' heq ha)
Β· exact Or.inr (hfast n hn' (congrArg clock heq) (le_of_not_gt ha))
Β· exact Or.inr (hfast n hn' heq ha)
intro n hn
rcases hinv n hn with heq | ⟨heq, _⟩
Β· exact congrArg clock heq
Β· exact heq
theorem clock_readout_values_agree {s t : β„• β†’ ℝ} {Ξ² : ℝ β†’ ℝ} {b : ℝ}
(hs : Monotone s) (ht : Monotone t)
(hsupport : βˆ€ r, b ≀ r β†’ Ξ² r = 0)
(N : β„•) (hN : b ≀ s N) (hagree : βˆ€ n ≀ N, s n = t n) :
βˆ€ n, Ξ² (s n) = Ξ² (t n) := by
intro n
by_cases hn : n ≀ N
Β· rw [hagree n hn]
Β· have hNn : N ≀ n := by omega
have hsN : b ≀ s n := hN.trans (hs hNn)
have htN : b ≀ t n := (hagree N le_rfl β–Έ hN).trans (ht hNn)
rw [hsupport _ hsN, hsupport _ htN]
theorem clock_prediction_single_hit {s t : β„• β†’ ℝ} {Ξ² : ℝ β†’ ℝ} {a b : ℝ}
(hs : Monotone s) (hwidth : b - a < 1)
(hsupport : βˆ€ r, Ξ² r β‰  0 β†’ a < r ∧ r < b)
(hstep : βˆ€ n, Ξ² (s n) β‰  0 β†’ s (n + 1) = s n + 1)
(hagree : βˆ€ n, Ξ² (s n) = Ξ² (t n))
{j : β„•} (hj : Ξ² (s j) β‰  0) (n : β„•) :
Ξ² (t n) = if n = j then Ξ² (s j) else 0 := by
rw [← hagree n]
split_ifs with hnj
Β· subst n; rfl
Β· by_contra hn
exact hnj (clock_readout_unique hs hwidth hsupport hstep hn hj)
end Problem340
end
end OAI