theoremdisjoint_of_first_difference {r : ℝ} (hr : 0 < r) (digit : S→ℝ)
(hd₀ : ∀ a, 0≤ digit a) (hd₁ : ∀ a, r * (digit a + 1) ≤1)
(p u v : ListS) (a b : S) (hab : digit a + 1 < digit b) :
Disjoint (interval r digit (p ++ a :: u)) (interval r digit (p ++ b :: v)) :=by
proof · 6
lines
apply Set.disjoint_left.mpr
intro x hx hy
have hh := prefix_gap hr digit hd₀ hd₁ p u v a b hx hy
havehp : 0 < r ^ (p.length + 1) * (digit b - digit a - 1) :=
mul_pos (pow_pos hr _) (by linarith)
linarith
theoremfirst_difference {u v : ListS} (hu : ¬ u.IsPrefix v) (hv : ¬ v.IsPrefix u) :
∃ p a b u' v', u = p ++ a :: u' ∧ v = p ++ b :: v' ∧ a ≠ b :=by
proof · 18
lines
classical
induction u generalizing v with
| nil => exact False.elim (hu ⟨v, by simp⟩)
| cons a u ih =>
cases v with
| nil => exact False.elim (hv ⟨a :: u, by simp⟩)
| cons b v =>by_cases hab : a = b
· subst b
havehu' : ¬u.IsPrefix v :=by
rintro ⟨w, hw⟩
exact hu ⟨w, by simpa using congrArg (List.cons a) hw⟩
havehv' : ¬v.IsPrefix u :=by
rintro ⟨w, hw⟩
exact hv ⟨w, by simpa using congrArg (List.cons a) hw⟩
obtain ⟨p, b, c, u', v', hu'', hv'', hbc⟩ := ih hu' hv'
exact ⟨a :: p, b, c, u', v', by simp [hu''], by simp [hv''], hbc⟩
· exact ⟨[], a, b, u, v, rfl, rfl, hab⟩
theoremincompatible_intervals_disjoint {r : ℝ} (hr : 0 < r) (digit : S→ℝ)
(hd₀ : ∀ a, 0≤ digit a) (hd₁ : ∀ a, r * (digit a + 1) ≤1)
(hgap : ∀ a b, a ≠ b → digit a + 1 < digit b ∨ digit b + 1 < digit a)
{u v : ListS} (hu : ¬u.IsPrefix v) (hv : ¬v.IsPrefix u) :
Disjoint (interval r digit u) (interval r digit v) :=by
proof · 4
lines
obtain ⟨p, a, b, u', v', rfl, rfl, hab⟩ := first_difference hu hv
rcases hgap a b hab with hab' | hba'
· exact disjoint_of_first_difference hr digit hd₀ hd₁ p u' v' a b hab'
· exact (disjoint_of_first_difference hr digit hd₀ hd₁ p v' u' b a hba').symm
theoremcomparable_of_intersection {r : ℝ} (hr : 0 < r) (digit : S→ℝ)
(hd₀ : ∀ a, 0≤ digit a) (hd₁ : ∀ a, r * (digit a + 1) ≤1)
(hgap : ∀ a b, a ≠ b → digit a + 1 < digit b ∨ digit b + 1 < digit a)
{u v : ListS} {x : ℝ} (hu : x ∈ interval r digit u) (hv : x ∈ interval r digit v) :
u.IsPrefix v ∨ v.IsPrefix u :=by
proof · 4
lines
by_contra h
push Not at h
exact Set.disjoint_left.mp (incompatible_intervals_disjoint hr digit hd₀ hd₁ hgap h.1 h.2)
hu hv
theoremboxMap_image {r : ℝ} (hr : 0 < r) (digit : S→ℝ)
(o o' : Space) (u v : Fin3→ListS) :
boxMap r digit o o' u v '' box r digit o u = box r digit o' v :=by
proof · 21
lines
ext y
constructor
· rintro ⟨x, hx, rfl⟩ i
havehi : replacement r digit (u i) (v i) (x i - o i) ∈ interval r digit (v i) :=by
rw [← replacement_interval hr digit (u i) (v i)]
exact ⟨x i - o i, hx i, rfl⟩
simpa only [boxMap, add_sub_cancel_left] using hi
· intro hy
havehex : ∀ i, ∃z : ℝ, z ∈ interval r digit (u i) ∧
replacement r digit (u i) (v i) z = y i - o' i :=by
intro i
have hi := hy i
rw [← replacement_interval hr digit (u i) (v i)] at hi
exact hi
choose z hz he using hex
refine ⟨fun i => o i + z i, ?_, ?_⟩
· intro i
simpa only [add_sub_cancel_left] using hz i
· funext i
simp only [boxMap, add_sub_cancel_left, he]
ring
theoremboxMap_sub (r : ℝ) (digit : S→ℝ) (o o' : Space)
(u v : Fin3→ListS) (x y : Space) (i : Fin3) :
boxMap r digit o o' u v x i - boxMap r digit o o' u v y i =
scales r u v i * (x i - y i) :=by
theoremcodedPoint_mem_box {B : ℕ} (digit : S→FinB) (o : Space)
(u : Fin3→ListS) (s : Fin3→Stream'S) :
codedPoint digit o (fun i => u i ++ₛ s i) ∈
box (B : ℝ)⁻¹ (fun a => (digit a : ℝ)) o u :=by
proof · 3
lines
intro i
simpa only [codedPoint, add_sub_cancel_left] using
stream_append_mem_interval digit (u i) (s i)
theoremboxMap_codedPoint {B : ℕ} (hB : B≠0) (digit : S→FinB) (o o' : Space)
(u v : Fin3→ListS) (s : Fin3→Stream'S) :
boxMap (B : ℝ)⁻¹ (fun a => (digit a : ℝ)) o o' u v
(codedPoint digit o (fun i => u i ++ₛ s i)) =
codedPoint digit o' (fun i => v i ++ₛ s i) :=by
proof · 3
lines
funext i
simp only [boxMap, codedPoint, add_sub_cancel_left]
rw [replacement_stream hB]
theorembox_compact (r : ℝ) (digit : S→ℝ) (o : Space) (u : Fin3→ListS) :
IsCompact (box r digit o u) :=by
proof · 9
lines
havehe : box r digit o u = Set.pi Set.univ
(fun i =>Set.Icc (o i + word r digit (u i))
(o i + word r digit (u i) + r ^ (u i).length)) :=by
ext x
simp only [box, Set.mem_ofPred_eq, Set.mem_univ_pi, interval, Set.mem_Icc]
congr! 1with i
constructor <;> rintro ⟨h₁, h₂⟩ <;> constructor <;> linarith
rw [he]
exact isCompact_univ_pi (fun _ => isCompact_Icc)
intro s t h
by_cases hs : s = .ready M.halt <;> by_cases ht : t = .ready M.halt
· exact hs.trans ht.symm
· simp [placement, hs, ht] at h
· simp [placement, hs, ht] at h
· simp only [placement, hs, ht, ↓reduceIte, Nat.add_right_cancel_iff] at h
exact (Fintype.equivFin (ControlQ)).injective (Fin.ext h)
theoremtarget_boxes_disjoint (M : MachineQ Γ)
{r : ℝ} (hr : 0 < r) (digit : LetterQ Γ →ℝ)
(hd₀ : ∀ a, 0≤ digit a) (hd₁ : ∀ a, r * (digit a + 1) ≤1)
(hgap : ∀ a b, a ≠ b → digit a + 1 < digit b ∨ digit b + 1 < digit a)
(id : ControlQ→ℕ) (hid : Function.Injective id)
{a b : RowQ Γ} (hab : a ≠ b) :
Disjoint ((a.instruction M).targetBox r digit id)
((b.instruction M).targetBox r digit id) :=by
proof · 19
lines
apply Set.disjoint_left.mpr
intro x hx hy
havehcontrol : (a.instruction M).targetControl = (b.instruction M).targetControl :=
hid (Coding.control_eq_of_box_intersection hr digit hd₀ hd₁ hx hy)
havehi : ∀i : Fin3,
((a.instruction M).targetPrefixes i).IsPrefix ((b.instruction M).targetPrefixes i) ∨
((b.instruction M).targetPrefixes i).IsPrefix ((a.instruction M).targetPrefixes i) :=by
intro i
apply Coding.comparable_of_intersection hr digit hd₀ hd₁ hgap (hx i)
simpa only [Instruction.targetBox, hcontrol] using hy i
choose s t he usingfun i =>Coding.common_extensions (Letter.boundary : LetterQ Γ) (hi i)
haveheq : (a.instruction M).target ⟨s 0, s 1, s 2⟩ =
(b.instruction M).target ⟨t 0, t 1, t 2⟩ :=by
dsimp [Instruction.target]
congr 1
· exact he 0
· exact he 1
· exact he 2
exact hab (target_separation M heq).1