import OAI.Computability.StarHeight.OriginBounds namespace OAI namespace GeneralizedStarHeight universe u universe uAlphabet uM uV uK uP uC uAlphabet2 uM2 universe uV2 uK2 uP2 uC2 uAlphabet3 uAlphabet4 uT uP3 universe uC3 uAlphabet5 uM3 uV3 uK3 uC4 uP4 namespace SourceSchedule.Early open SplitMetadata WordIntervals LocalMarkers BoundarySnapshot open scoped Classical BigOperators variable {Alphabet : Type uAlphabet} {M : Type uM} {V : Type uV} {K : Type uK} {P : Type uP} {C : Type uC} [Monoid M] [Field K] [AddCommGroup V] [Module K V] [Fintype M] [Fintype V] [Fintype P] [Fintype C] {g g' B : ℕ} {clock : RobustClock.Specification (Tag M V g B) P C} {label : P → Fin g'} {reserved : P → ℤ} (S : Early (Alphabet := Alphabet) clock B (Fintype.card M) label reserved) (L : Late Alphabet B S.diameter (S.sweepWidth g) (S.envelope g) (S.β (Fin.last g'))) (hB : 0 hpos (.inl j) a ha) (fun j a _ i hi => S.main_prefix_visible g L hB he j a i hi u) (fun j a ha a' ha' i hi => S.main_suffix_visible g L hB he j a a' ha ha' i hi u) hvis hp x exact ⟨.inl tag,k,hx,hpre,hsuf,hout⟩ · push Not at hp obtain ⟨j,hj⟩ := hp let z := t+S.inner.boundary j.val have hboundary : 0 ≤ S.inner.boundary j.val := by exact mul_nonneg (Int.natCast_nonneg _) (by have := S.inner.gap_pos;omega) have hs : s ≤ z+innerD S.p (B*S.R) := by have hl := L.lag_pos have hd : (0:ℤ) ≤ innerD S.p (B*S.R) := Int.natCast_nonneg _ dsimp [z,t] omega have hnomarker : ∀ y, z ≤ y → y ≤ z+S.inner.H u+S.inner.extension → y∉S.rule.markers f := A.not_failed_absent hn j hj obtain ⟨p,hp,hpd,hprogress⟩ := PeriodicCuts.progression S.inner S.rule (innerD_ge S.p (B*S.R)) (by omega) (by have := S.rule.radius_ge;omega) hB S.period_pos T f s z u hs hnomarker have hcop : Nat.Coprime (p*(Fintype.card M).factorial*B) S.period := by apply PeriodicClock.progression_coprime S.denominator S.prime hp hpd (Nat.factorial_pos _) hB intro c have hh := S.den_large c exact ⟨(le_max_left _ _).trans_lt ((le_max_right _ _).trans_lt hh), (le_max_right _ _).trans_lt ((le_max_right _ _).trans_lt hh), (le_max_left _ _).trans_lt hh⟩ have hprog : ∀ a : ℕ, a hpos (.inr (j,u)) a ha) (fun j a _ => S.periodic_prefix_visible g L hB he j u a) j hj S.period_pos (PeriodicClock.period S.denominator S.numerator (fun c => (S.prime c).pos)) hcop hprog x exact ⟨.inr tag,k,hx,hpre,hsuf,hout⟩ end SourceSchedule.Early namespace InnerStream open WordIntervals SplitMetadata LocalMarkers variable {Alphabet : Type uAlphabet2} {M : Type uM2} {V : Type uV2} {K : Type uK2} {P : Type uP2} {C : Type uC2} [Monoid M] [Field K] [AddCommGroup V] [Module K V] [Fintype M] [Fintype V] [Fintype K] [Fintype P] [Fintype C] {g g' μ : ℕ} (A : ExceptionalOrigins.Parameters Alphabet (Fin (g+1)) C) (clock : RobustClock.Specification (Tag M V g A.B) P C) (T : FreeMonoid Alphabet →* M) (ρ : M → (V →ₗ[K] V)) (β : M → M → (Fin g → M) → V) (early : Fin (g'+1) → ℤ) (γ : (M → (V × K →ₗ[K] V × K)) → (Fin g' → M) → V × K) (p : Roster M (V × K) K g' μ → ℤ) (lag : ℤ) lemma available (hγ : ∀ ψ, ShiftTableProperty g' (ObservedInner.table ψ) (γ ψ)) {s b H : ℤ} {f : ℤ → Alphabet} (reference : Roster M (V × K) K g' μ) (hbad : (A.bad p f (s+lag) (b-A.endRule.tail)).card < μ) (hvis : ∀ a i, A.Visible (s+p a) b (s+lag+(p a-p i)) (A.anchor f (b-A.endRule.tail) (s+lag+(p a-p i)))) (hnear : ∀ i j, |p i-p j| ≤ H) (hnest : (A.endRule.d : ℤ)+(A.endRule.B-1)*A.endRule.S+H ≤ 3*A.endRule.d) (hover : (A.endRule.d : ℤ)^2 ≤ A.endRule.K-H) (hover' : H s+early i) ψ x (hγ ψ) obtain ⟨copy,hcopy⟩ := SuffixDecoder.available_copy A p lag s b H f reference kind hbad hvis hnear hnest hover hover' hend hfailed let slot : Roster M (V × K) K g' μ := (kind,copy) have hs : s+p slot-p slot=s := by ring refine ⟨slot,s+p slot,hx,⟨rfl,hp⟩,⟨hcopy,?_⟩,hout⟩ simpa only [hs] using hq end InnerStream namespace SourceSchedule.Late variable {Alphabet : Type uAlphabet3} {B : ℕ} {h w E earlyLast : ℤ} (L : Late Alphabet B h w E earlyLast) lemma count_margins (hB : 0 nlinarith lemma decoder_margins (hB : 0 nlinarith [sq_nonneg (L.endRule.d:ℤ)] end SourceSchedule.Late namespace SourceSchedule.Early open scoped Classical variable {Alphabet : Type uAlphabet4} {T : Type uT} {P : Type uP3} {C : Type uC3} [Fintype T] [Fintype P] [Fintype C] {g' B size : ℕ} {clock : RobustClock.Specification T P C} {label : P → Fin g'} {reserved : P → ℤ} (S : Early (Alphabet := Alphabet) clock B size label reserved) (g : ℕ) (L : Late Alphabet B S.diameter (S.sweepWidth g) (S.envelope g) (S.β (Fin.last g'))) (hB : 0 difference_bound S.p i j) hmod' S.separated (Int.natCast_nonneg _) hgap₀ hinner hwidth hmar.1 hmar.2.1 hmar.2.2 μ (by simpa only [Fintype.card_fin,Nat.cast_add,Nat.cast_one] using hμ) f t q₀ end SourceSchedule.Early namespace SourceSchedule.Early open WordIntervals SplitMetadata LocalMarkers variable {Alphabet : Type uAlphabet5} {M : Type uM3} {V : Type uV3} {K : Type uK3} {C : Type uC4} [Monoid M] [Field K] [AddCommGroup V] [Module K V] [Fintype M] [Fintype V] [Fintype K] [Fintype C] {g g' μ B : ℕ} {clock : RobustClock.Specification (Tag M V g B) (Roster M (V × K) K g' μ) C} {reserved : Roster M (V × K) K g' μ → ℤ} (S : Early (Alphabet := Alphabet) clock B (Fintype.card M) (fun i => i.1.j) reserved) (L : Late Alphabet B S.diameter (S.sweepWidth g) (S.envelope g) (S.β (Fin.last g'))) (hB : 0