Recursive marked intervals with grouped exact and flat descriptions
OpenFixedMachinePrec.recursive_marks_and_qualifier_groupsConstruct the working-frame intervals, their marks, and the qualifier groups of the annotated hierarchy. Describe the exact qualifier union as an initial block (budget , including any switch companion) followed by two-leaf injections. Describe a flat carry by an initial two-leaf block followed by one-leaf blocks; same-direction mark cutoffs subtract that carry from a boundary predicate. Descriptions may use either frame. For the number of blocks give the geometric charging data of the spare-endpoint argument, or exhibit a single block in root, switch, or terminal cases. A charged list uses groups disjoint on the parent, whose child witnesses have successors in the endpoint and cannot precede its spare job. Empty unions may be represented by a single empty block. The exterior-to-actual common-cutoff promotion with a spare endpoint is supplied.
import Mathlib import Definitions.Def_FixedMachinePrec_Formula import Definitions.Def_FixedMachinePrec_Hierarchy import Definitions.Def_FixedMachinePrec_Separator
namespace FixedMachinePrec
theorem recursive_marks_and_qualifier_groups {N : ℕ} (m : ℕ) (prec : Fin N → Fin N → Prop) [DecidableRel prec] (hm : 3 ≤ m) (hp : IsStrictOrder' prec) (rank : Fin N → ℕ) (hr : IsTopoRank prec rank)
(hf : ∃ S, IsFullSchedule prec m Finset.univ S)
(walk : ∀ (p : Fin N → Fin N → Prop) [DecidableRel p], IsStrictOrder' p → ∀ U pri S,
IsPriorityList p U pri → IsNormalized p m U pri S → ∀ k s, k < U.card → ∀ ext : Finset (Fin N),
(∀ x ∈ ext, ∀ y ∈ U, p x y → y ∈ ext) →
let sep := fun L r => if r=0 then L ⊆ ext else Separates p S L r
sep (priorityPrefix pri k) s → ∃ t ≥ s, sep (priorityPrefix pri k) t ∧ sep (priorityPrefix pri (k+1)) t ∧
(s < t → ∃ e ∈ S.getD (t-1) ∅, ∀ y ∈ U \ priorityPrefix pri k, ¬p y e)) :
let F := family prec rank m
let layer := fun k => F k ∪ family (fun x y => prec y x) (fun x => N+1-rank x) m k
let charged := fun (g : ℕ) => g ≤ 1 ∨ ∃ (p : Fin N → Fin N → Prop) (W L V Z : Finset (Fin N)) (G : Fin g → Finset (Fin N)),
Z.card = m ∧ Z ⊆ W ∧ V ⊆ W ∧ (∀ i, ∃ x ∈ V, x ∈ G i ∧ x ∉ L) ∧
(∀ x ∈ V \ L, ∃ y ∈ Z, p x y) ∧ (∀ i x, x ∈ G i → ∀ y, p x y → y ∈ G i) ∧
(∀ i j, i ≠ j → Disjoint (G i ∩ W) (G j ∩ W)) ∧ (∃ e ∈ Z, ∀ x ∈ W \ L, ¬p x e)
let grouped := fun h c (X : Finset (Fin N)) => ∃ head ∈ layer h, ∃ tail : List (Finset (Fin N)),
charged (tail.length+1) ∧ (∀ A ∈ tail, A ∈ layer c) ∧ X = tail.foldl (· ∪ ·) head
let atom := layer 1
∃ D : Finset (Finset (Fin N)), (m < N → Finset.univ ∈ D) ∧
(∀ V ∈ D, V = Finset.univ ∨ ∃ (τ : Fin N → ℕ) (a p q b : ℕ) (L : Finset (Fin N)),
a ≤ p ∧ p < q ∧ q ≤ b ∧ (∀ x, x ∈ V ↔ p < τ x ∧ τ x < q) ∧
∃ Q, grouped (m+4) 2 Q ∧ ∃ P ∈ atom, ∃ B ∈ atom,
(∀ x ∈ V, x ∈ Q ↔ x ∉ L) ∧ (∀ x ∈ V \ L, x ∈ P) ∧ (∀ x ∈ P, τ x < q) ∧
(∀ x ∈ B, τ x ≤ p) ∧ (∀ x ∈ Q, τ x ≤ p → x ∈ B) ∧
∃ X ∈ atom, ∃ Y ∈ atom, ∃ Z ∈ atom,
(∀ x ∈ V ∩ L, x ∈ X ∩ Y) ∧ (∀ x ∈ X, p < τ x) ∧ (∀ x ∈ Y, τ x < b) ∧
(∀ x ∈ Z, q ≤ τ x) ∧
((∃ H, grouped 2 1 H ∧ (∀ x, a < τ x → τ x < b → (x ∈ L ↔ x ∈ Y ∧ x ∉ H)) ∧
(∀ x ∈ L, q ≤ τ x → x ∈ Z)) ∨
∃ A ∈ atom, ∃ R ∈ atom, ∃ C ∈ atom, ∃ v, q ≤ v ∧
(∀ x, a < τ x → τ x < b → (x ∈ L ↔ x ∉ A ∧ x ∈ R)) ∧
(∀ x ∈ C, v ≤ τ x) ∧ (∀ x ∈ L, v ≤ τ x → x ∈ C) ∧
(∀ x ∈ L, q ≤ τ x → τ x < v → x ∈ Z))) ∧
∀ W ∈ D, m < W.card → ∃ S marks, IsFullSchedule prec m W S ∧ marks ≠ [] ∧
marks.Pairwise (· < ·) ∧ (∀ t ∈ marks, 1 ≤ t ∧ t ≤ S.length) ∧
(∀ t ∈ marks, ∃ (τ : Fin N → ℕ) (q : ℕ),
((∀ x, x ∈ slotsBetween S 0 t ↔ x ∈ W ∧ τ x < q) ∨
(∀ x, x ∈ slotsBetween S 0 t ↔ x ∈ W ∧ q < τ x)) ∧
∃ P ∈ atom, ∃ Dq ∈ atom, ∃ wP ∈ atom, ∃ wD ∈ atom,
(∀ x ∈ W, x ∈ P → τ x < q) ∧ (∀ x ∈ W, x ∈ Dq → q < τ x) ∧
(∀ x ∈ W, x ∈ wP ↔ x ∈ P ∨ τ x = q) ∧ (∀ x ∈ W, x ∈ wD ↔ x ∈ Dq ∨ τ x = q) ∧
((∃ H, (∃ P ∈ atom, ∃ carry, grouped 2 1 carry ∧ H = P \ carry) ∧ (∀ x ∈ W, τ x < q → x ∉ H → x ∈ P) ∧
(∀ x ∈ W, q < τ x → x ∈ H → x ∈ Dq)) ∨
∃ H₀ ∈ atom, ∃ R ∈ atom, ∃ wV ∈ atom, ∃ v, q < v ∧
(∀ x ∈ W, x ∈ wV → v ≤ τ x) ∧ (∀ x ∈ W, v ≤ τ x → x ∈ H₀ → x ∈ wV) ∧
(∀ x ∈ W, τ x < q → x ∉ H₀ ∩ R → x ∈ P) ∧
(∀ x ∈ W, q < τ x → τ x < v → x ∈ H₀ ∩ R → x ∈ Dq))) ∧
∀ A ∈ gaps S marks, A.Nonempty → (A ∈ D ∧ m < A.card ∧ A.card < W.card) ∨
(A.card = m ∧ IsAntichainSet prec A) := by sorry
end FixedMachinePrec