import YM.Analysis.Polydisc import YM.Bid.Corners set_option autoImplicit false noncomputable section namespace YM.Work.C02 open Set Function OS OS.Ground OS.Semigroup Word Boundary Boundary.Small Bid open scoped NNReal InnerProductSpace variable {G : Gauge} {L : Register G} {S T : Table L} {V : Chamber T timeAxis} variable {A : Spread V} {P : DiffPlan S} {B : Small S V} {n : ℕ} private lemma basis_time (t : ℝ) : t • basis timeAxis = position 0 t := by ext i refine Fin.lastCases ?_ (fun j => ?_) i · rw [show position (0 : Space3) t (Fin.last 3) = t from time_position _ _] change t * basis timeAxis timeAxis = t simp · rw [show position (0 : Space3) t j.castSucc = (0 : ℝ) from congrArg (fun x : Space3 => x j) (spatial_position (0 : Space3) t)] simp [show j.castSucc ≠ timeAxis from j.castSucc_ne_last] private lemma pos_add (x x' : Space3) (t t' : ℝ) : position x t + position x' t' = position (x+x') (t+t') := by ext i refine Fin.lastCases ?_ (fun j => ?_) i · change time (position x t) + time (position x' t') = time (position (x+x') (t+t')) simp · simp [position] private lemma neg_pos (x : Space3) (t : ℝ) : -position x t = position (-x) (-t) := by ext i refine Fin.lastCases ?_ (fun j => ?_) i · change -time (position x t) = time (position (-x) (-t)) simp · simp [position] private def glyph (v : S.Tag) : L.Token := ⟨v.1, S.representative v.1 v.2⟩ private def born (p : ℝ≥0) (v : S.Tag) : L.Word := [(position 0 p, glyph v)] private lemma cradle {p : ℝ≥0} (hp : 0 < p) (v : S.Tag) : Slab timeAxis (p+p) (born p v) := by refine ⟨add_pos hp hp, ⟨locations.mpr (by simp [born]), ?_⟩, ?_⟩ <;> (intro x hx; rw [born, List.mem_singleton] at hx; subst x) · change 0 < time (position 0 p) simpa using (show 0 < (p:ℝ) from hp) change time (position 0 p) < ((p+p:ℝ≥0):ℝ) simpa using (show 0 < (p:ℝ) from hp) private def script (x : SpacePoints n) (y : Heights n) (v : Fin n → S.Tag) : L.Word := realize (glyph ∘ v) (place x y) private lemma script_cons (x : SpacePoints (n+1)) (y : Heights (n+1)) (v : Fin (n+1) → S.Tag) : script x y v = (position (x 0) (y 0), glyph (v 0)) :: script (Fin.tail x) (Fin.tail y) (Fin.tail v) := List.ofFn_succ private lemma enters {x : SpacePoints (n+1)} {y : Heights (n+1)} {v : Fin (n+1) → S.Tag} {p : ℝ≥0} (hp : 0
hy.2.2 i.succ j.succ (Fin.succ_lt_succ_iff.mpr hij)⟩
private lemma train_pure (hB : B.concretized A) {p : ℝ≥0}
(x : SpacePoints n) (y : Heights n) (v : Fin n → S.Tag) (X : Space3) (Y : ℝ)
(h : enough y p) (hp : ∀ i, 4*(p:ℝ) rfl
| succ n =>
rw [Small.matrix, Small.matrix, pad_bar H hB hp]
simp only [ContinuousLinearMap.comp_apply]
rw [train_pad H hB hp hu _ _ _ _ _ (show lit (Fin.tail z) _ from enough_tail hz)
(fun j => hz.2.2 0 j.succ j.succ_pos), ← V.flow.swing,
show V.flow.E u V.omega=V.omega from (V.flow.fixed _).1 V.omega0.property u]
theorem answer : YM.Bid.C02 := by
intro G L S T V P A B H hB
refine ⟨hB, fun p y x v hy hp => root H.adopted hB.bits x y v hy hp, ?_⟩
intro n z x p q l _ hq hl
obtain h|h|h := lt_trichotomy q l
· obtain ⟨u,rfl⟩ := exists_add_of_le h.le
exact (matrix_pad H hB hq.1 (by simpa using h) z x p hl).symm
· rw [h]
obtain ⟨u,rfl⟩ := exists_add_of_le h.le
exact matrix_pad H hB hl.1 (by simpa using h) z x p hq
end YM.Work.C02