import Mathlib /-! # Parity Games: Zielonka's Positional Determinacy Theorem & Exact Emerson–Jutla # Correspondence with Nested Modal μ-Calculus Fixpoints This standalone Lean 4 module formalizes Pillar 4 of our Formal Verification, Temporal Logic, Modal μ-Calculus & Parity Games development: 1. **Parity Games, Plays, Positional Strategies & Finite-Step Attractors:** - Parity games `(V, owner, edge, prio)` with infinite plays (`IsPlay`), positional (memoryless) strategies `σ : V → V`, and max-priority parity winning condition (`Wins`). - Exact finite-step attractors `attrFinset G A p U`, trap closure (`sdiff_attrFinset_total`), and explicit memoryless attractor strategies (`attrStrat`) with strictly decreasing step-rank guaranteeing finite-time reachability into `U` (`attrStrat_reaches_U`). 2. **Zielonka's Theorem — Positional (Memoryless) Determinacy of Parity Games:** - Complete proof of **Zielonka's Theorem** (`zielonka_subgame`, `zielonka_positional_determinacy`) by outer induction on the priority bound `d` and inner strong induction on subgame cardinality `|A|`: every finite deadlock-free parity game partitions `V = W_even ⊔ W_odd` into disjoint winning regions with explicit memoryless winning strategies `σ_even` and `σ_odd`. - Uniqueness & exact characterization of the winning region (`winning_region_unique`). 3. **Exact Emerson–Jutla Correspondence (Parity Games ↔ Nested Modal μ-Calculus):** - Parameterized alternating nested Knaster–Tarski fixpoint `ejEval G p d ρ` over priorities `0, ..., d` (`ν` for priorities of parity `p`, `μ` for priorities of parity `p.opp`) with exact complement duality (`ejEval_compl_eq_opp`). - Direct positional-strategy-to-fixpoint soundness proof (`closedWin_subset_ejEval`), combined with Zielonka's positional determinacy and complement duality to prove the exact **Emerson–Jutla Correspondence** (`emerson_jutla_correspondence`): `W_even(G) = ejEval G .even d ρ`. - Explicit syntactic closed Modal μ-Calculus formula `ejMuFormula d` evaluated on the parity-game Kripke structure `parityToLTS G`, proving exact equality `W_even(G) = (ejMuFormula d).eval (parityToLTS G) ρ` (`emerson_jutla_syntactic_mu_calculus`). 4. **Non-Trivial 3-Priority Concrete Parity Game Witness (`threePrioGame_exact_partition`):** - An explicit 4-vertex parity game with priorities `{0, 1, 2}` where both players have non-empty winning regions (`W_even = {v0, v1}`, `W_odd = {v2, v3}`), verified with explicit memoryless winning strategies and Emerson–Jutla evaluation. -/ namespace ParityGames /-! ## Section 1: Parity Games, Plays & Max-Priority Winning Condition -/ /-- The two players of a parity game: `even` (Player 0) and `odd` (Player 1). -/ inductive Player : Type | even : Player | odd : Player deriving DecidableEq /-- Opponent player involution. -/ def Player.opp : Player → Player | .even => .odd | .odd => .even lemma Player.opp_opp (p : Player) : p.opp.opp = p := by cases p <;> rfl lemma Player.opp_ne (p : Player) : p.opp ≠ p := by cases p <;> decide lemma Player.eq_or_eq_opp (p q : Player) : q = p ∨ q = p.opp := by cases p <;> cases q <;> simp [Player.opp] /-- Player favored by priority `k`: Even if `Even k`, Odd otherwise. -/ noncomputable def parityPlayer (k : ℕ) : Player := if Even k then .even else .odd /-- A parity game `(V, owner, edge, prio)`. -/ structure ParityGame (V : Type*) where owner : V → Player edge : V → V → Prop prio : V → ℕ /-- Totality (no deadlocks) on a finite subgame `A ⊆ V`. -/ def IsTotalOn {V : Type*} (G : ParityGame V) (A : Finset V) : Prop := ∀ v ∈ A, ∃ w ∈ A, G.edge v w /-- Global totality (no deadlocks anywhere in `V`). -/ def IsTotal {V : Type*} (G : ParityGame V) : Prop := ∀ v, ∃ w, G.edge v w /-- An infinite play staying inside subgame `A`. -/ def IsPlayOn {V : Type*} (G : ParityGame V) (A : Finset V) (π : ℕ → V) : Prop := (∀ n, π n ∈ A) ∧ (∀ n, G.edge (π n) (π (n + 1))) /-- A global infinite play in `G`. -/ def IsPlay {V : Type*} (G : ParityGame V) (π : ℕ → V) : Prop := ∀ n, G.edge (π n) (π (n + 1)) /-- Play `π` follows positional strategy `σ` for player `p`. -/ def Follows {V : Type*} (G : ParityGame V) (p : Player) (σ : V → V) (π : ℕ → V) : Prop := ∀ n, G.owner (π n) = p → π (n + 1) = σ (π n) /-- Property `P` holds infinitely often along `ℕ`. -/ def InfOften (P : ℕ → Prop) : Prop := ∀ N, ∃ n ≥ N, P n /-- Max-priority parity winning condition: the maximum priority occurring infinitely often along `π` exists and belongs to player `p`. -/ def Wins {V : Type*} (G : ParityGame V) (p : Player) (π : ℕ → V) : Prop := ∃ k, parityPlayer k = p ∧ InfOften (fun n => G.prio (π n) = k) ∧ ∃ N, ∀ n ≥ N, G.prio (π n) ≤ k lemma infOften_shift {P : ℕ → Prop} (m : ℕ) : InfOften (fun n => P (n + m)) ↔ InfOften P := by constructor · intro h N rcases h N with ⟨n, hn, hpn⟩ exact ⟨n + m, by omega, hpn⟩ · intro h N rcases h (N + m) with ⟨n, hn, hpn⟩ refine ⟨n - m, by omega, ?_⟩ dsimp only rwa [Nat.sub_add_cancel (by omega)] /-- Prefix-invariance of the parity winning condition. -/ lemma wins_shift {V : Type*} (G : ParityGame V) (p : Player) (π : ℕ → V) (m : ℕ) : Wins G p (fun n => π (n + m)) ↔ Wins G p π := by constructor · rintro ⟨k, hpk, hio, N, hN⟩ refine ⟨k, hpk, (infOften_shift m).mp hio, N + m, fun n hn => ?_⟩ have h := hN (n - m) (by omega) dsimp only at h rwa [Nat.sub_add_cancel (by omega)] at h · rintro ⟨k, hpk, hio, N, hN⟩ exact ⟨k, hpk, (infOften_shift m).mpr hio, N, fun n hn => hN (n + m) (by omega)⟩ /-- No play can be won by both Even and Odd. -/ lemma wins_disjoint {V : Type*} {G : ParityGame V} {p : Player} {π : ℕ → V} (h1 : Wins G p π) (h2 : Wins G p.opp π) : False := by rcases h1 with ⟨k₁, hp₁, hio₁, N₁, hN₁⟩ rcases h2 with ⟨k₂, hp₂, hio₂, N₂, hN₂⟩ have hle12 : k₁ ≤ k₂ := by rcases hio₁ N₂ with ⟨n, hn, hkn⟩ rw [← hkn]; exact hN₂ n hn have hle21 : k₂ ≤ k₁ := by rcases hio₂ N₁ with ⟨n, hn, hkn⟩ rw [← hkn]; exact hN₁ n hn have heq : k₁ = k₂ := le_antisymm hle12 hle21 subst heq rw [hp₁] at hp₂ exact Player.opp_ne p hp₂.symm /-- Every play with bounded priorities is won by either Even or Odd. -/ lemma wins_total_of_bounded {V : Type*} (G : ParityGame V) : ∀ d, ∀ π : ℕ → V, (∀ n, G.prio (π n) ≤ d) → Wins G .even π ∨ Wins G .odd π := by intro d induction d with | zero => intro π hle left refine ⟨0, by simp [parityPlayer], fun N => ⟨N, le_rfl, Nat.le_zero.mp (hle N)⟩, 0, fun n _ => hle n⟩ | succ d ih => intro π hle by_cases hio : InfOften (fun n => G.prio (π n) = d + 1) · cases hp : parityPlayer (d + 1) with | even => left; exact ⟨d + 1, hp, hio, 0, fun n _ => hle n⟩ | odd => right; exact ⟨d + 1, hp, hio, 0, fun n _ => hle n⟩ · unfold InfOften at hio push Not at hio rcases hio with ⟨N, hN⟩ have hbd : ∀ n, G.prio (π (n + N)) ≤ d := by intro n have h1 := hle (n + N) have h2 := hN (n + N) (Nat.le_add_left N n) omega rcases ih (fun n => π (n + N)) hbd with he | ho · left; exact (wins_shift G .even π N).mp he · right; exact (wins_shift G .odd π N).mp ho lemma wins_iff_not_opp_of_bounded {V : Type*} {G : ParityGame V} {π : ℕ → V} {p : Player} (hbd : ∃ d, ∀ n, G.prio (π n) ≤ d) : Wins G p π ↔ ¬ Wins G p.opp π := by constructor · exact wins_disjoint · intro hnot rcases hbd with ⟨d, hd⟩ rcases wins_total_of_bounded G d π hd with he | ho · cases p with | even => exact he | odd => exact absurd he hnot · cases p with | even => exact absurd ho hnot | odd => exact ho /-! ## Section 2: Finite-Step Attractors & Memoryless Attractor Strategies -/ /-- One-step attractor operator inside subgame `A` for player `p`. -/ def attrStep {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (X : Set V) : Set V := X ∪ {v | v ∈ A ∧ ((G.owner v = p ∧ ∃ w ∈ A, G.edge v w ∧ w ∈ X) ∨ (G.owner v ≠ p ∧ ∀ w ∈ A, G.edge v w → w ∈ X))} /-- `n`-step attractor `Attr_p^n(U)` inside subgame `A`. -/ def attrN {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) : ℕ → Set V | 0 => U ∩ (A : Set V) | n + 1 => attrStep G A p (attrN G A p U n) /-- Full attractor `Attr_p(U) = ⋃ n, Attr_p^n(U)` inside subgame `A`. -/ def attrSet {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) : Set V := ⋃ n, attrN G A p U n lemma attrN_subset_A {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) : ∀ n, attrN G A p U n ⊆ (A : Set V) := by intro n induction n with | zero => exact Set.inter_subset_right | succ n ih => intro v hv rcases hv with h1 | ⟨hA, _⟩ · exact ih h1 · exact hA lemma attrN_mono {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) {m n : ℕ} (hmn : m ≤ n) : attrN G A p U m ⊆ attrN G A p U n := by induction hmn with | refl => exact Set.Subset.refl _ | @step k _ ih => exact Set.Subset.trans ih Set.subset_union_left lemma attrSet_subset_A {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) : attrSet G A p U ⊆ (A : Set V) := by intro v hv rcases Set.mem_iUnion.mp hv with ⟨n, hn⟩ exact attrN_subset_A G A p U n hn /-- Finite-set attractor `Attr_p(U)` inside finite subgame `A`. -/ noncomputable def attrFinset {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (A : Finset V) (p : Player) (U : Finset V) : Finset V := by classical exact (attrSet G A p (U : Set V)).toFinset lemma mem_attrFinset {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (A : Finset V) (p : Player) (U : Finset V) {v : V} : v ∈ attrFinset G A p U ↔ v ∈ attrSet G A p (U : Set V) := by classical exact Set.mem_toFinset lemma attrFinset_subset {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (A : Finset V) (p : Player) (U : Finset V) : attrFinset G A p U ⊆ A := by intro v hv rw [mem_attrFinset] at hv exact attrSet_subset_A G A p (U : Set V) hv lemma subset_attrFinset {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (A : Finset V) (p : Player) {U : Finset V} (hUA : U ⊆ A) : U ⊆ attrFinset G A p U := by intro v hv rw [mem_attrFinset] exact Set.mem_iUnion.mpr ⟨0, hv, hUA hv⟩ /-- On a finite subgame `A`, `attrN` stabilizes at `A.card`, so `attrSet` is closed under `attrStep`. -/ lemma attrN_stabilizes {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) : ∃ k ≤ A.card, attrN G A p U (k + 1) = attrN G A p U k := by classical by_contra hno push Not at hno have hcard : ∀ k ≤ A.card + 1, k ≤ (attrN G A p U k).toFinset.card := by intro k hk induction k with | zero => exact Nat.zero_le _ | succ k ih => have hsub : (attrN G A p U k).toFinset ⊆ (attrN G A p U (k + 1)).toFinset := by intro x hx; rw [Set.mem_toFinset] at hx ⊢; exact attrN_mono G A p U (Nat.le_succ k) hx have hssub : (attrN G A p U k).toFinset ⊂ (attrN G A p U (k + 1)).toFinset := by rw [Finset.ssubset_iff_subset_ne] refine ⟨hsub, fun heq => hno k (by omega) ?_⟩ ext x have h := Finset.ext_iff.mp heq x simpa [Set.mem_toFinset] using h.symm have hlt := Finset.card_lt_card hssub have ih' := ih (by omega) omega have hsubA : (attrN G A p U (A.card + 1)).toFinset ⊆ A := by intro x hx; rw [Set.mem_toFinset] at hx; exact attrN_subset_A G A p U _ hx have h1 := hcard (A.card + 1) le_rfl have h2 := Finset.card_le_card hsubA omega lemma attrSet_eq_attrN_card {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) : attrSet G A p U = attrN G A p U A.card := by rcases attrN_stabilizes G A p U with ⟨k, hkA, hstab⟩ have hconst : ∀ m ≥ k, attrN G A p U m = attrN G A p U k := by intro m hm obtain ⟨r, rfl⟩ := Nat.exists_eq_add_of_le hm induction r with | zero => simp | succ r ih => rw [← Nat.add_assoc] change attrStep G A p (attrN G A p U (k + r)) = attrN G A p U k rw [ih (by omega)] exact hstab ext v constructor · intro hv rcases Set.mem_iUnion.mp hv with ⟨n, hn⟩ rw [hconst A.card hkA] by_cases hnk : n ≤ k · exact attrN_mono G A p U hnk hn · rwa [hconst n (by omega)] at hn · intro hv exact Set.mem_iUnion.mpr ⟨A.card, hv⟩ /-- Trap closure of `A \ Attr_p(U)`: player `p` has NO edge from `A \ Attr_p(U)` into `Attr_p(U)`. -/ lemma sdiff_attrFinset_own_trap {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (A : Finset V) (p : Player) (U : Finset V) {v : V} (hv : v ∈ A \ attrFinset G A p U) (hown : G.owner v = p) {w : V} (hwA : w ∈ A) (hedge : G.edge v w) : w ∉ attrFinset G A p U := by intro hwX rw [Finset.mem_sdiff] at hv rw [mem_attrFinset] at hwX rcases Set.mem_iUnion.mp hwX with ⟨n, hn⟩ have hvX : v ∈ attrFinset G A p U := by rw [mem_attrFinset] exact Set.mem_iUnion.mpr ⟨n + 1, Or.inr ⟨hv.1, Or.inl ⟨hown, w, hwA, hedge, hn⟩⟩⟩ exact hv.2 hvX /-- From every opponent vertex in `A \ Attr_p(U)`, there exists an edge staying in `A \ Attr_p(U)`. -/ lemma sdiff_attrFinset_opp_stay {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (A : Finset V) (p : Player) (U : Finset V) {v : V} (hv : v ∈ A \ attrFinset G A p U) (hopp : G.owner v ≠ p) : ∃ w ∈ A \ attrFinset G A p U, G.edge v w := by rw [Finset.mem_sdiff] at hv by_contra hno push Not at hno have hall : ∀ w ∈ A, G.edge v w → w ∈ attrN G A p (U : Set V) A.card := by intro w hwA hedge have hwX : w ∈ attrFinset G A p U := by by_contra hnot exact hno w (Finset.mem_sdiff.mpr ⟨hwA, hnot⟩) hedge rw [mem_attrFinset, attrSet_eq_attrN_card] at hwX exact hwX have hvX : v ∈ attrFinset G A p U := by rw [mem_attrFinset] exact Set.mem_iUnion.mpr ⟨A.card + 1, Or.inr ⟨hv.1, Or.inr ⟨hopp, hall⟩⟩⟩ exact hv.2 hvX /-- Removing any attractor from a total subgame yields a total subgame. -/ lemma sdiff_attrFinset_total {V : Type*} [Fintype V] [DecidableEq V] {G : ParityGame V} {A : Finset V} (hTot : IsTotalOn G A) (p : Player) (U : Finset V) : IsTotalOn G (A \ attrFinset G A p U) := by intro v hv by_cases hown : G.owner v = p · rcases hTot v (Finset.mem_sdiff.mp hv).1 with ⟨w, hwA, hedge⟩ exact ⟨w, Finset.mem_sdiff.mpr ⟨hwA, sdiff_attrFinset_own_trap G A p U hv hown hwA hedge⟩, hedge⟩ · exact sdiff_attrFinset_opp_stay G A p U hv hown /-- Minimal step-rank of `v ∈ attrSet G A p U`. -/ noncomputable def attrRank {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) (v : V) : ℕ := by classical exact if h : ∃ n, v ∈ attrN G A p U n then Nat.find h else 0 lemma attrRank_spec {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) {v : V} (hv : v ∈ attrSet G A p U) : v ∈ attrN G A p U (attrRank G A p U v) := by classical have hex : ∃ n, v ∈ attrN G A p U n := Set.mem_iUnion.mp hv simp only [attrRank, dif_pos hex] exact Nat.find_spec hex lemma attrRank_min {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) {v : V} {m : ℕ} (hm : v ∈ attrN G A p U m) : attrRank G A p U v ≤ m := by classical have hex : ∃ n, v ∈ attrN G A p U n := ⟨m, hm⟩ simp only [attrRank, dif_pos hex] exact Nat.find_min' hex hm lemma attrRank_pos_of_not_mem {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) {v : V} (hv : v ∈ attrSet G A p U) (hnotU : v ∉ U) : 0 < attrRank G A p U v := by by_contra h0 have hr : attrRank G A p U v = 0 := by omega have hmem := attrRank_spec G A p U hv rw [hr] at hmem exact hnotU hmem.1 /-- Explicit memoryless attractor strategy `attrStrat`: at every `p`-vertex in `Attr_p(U) \ U`, moves to an `A`-successor of strictly smaller `attrRank`. -/ noncomputable def attrStrat {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) (v : V) : V := by classical exact if h : v ∈ attrSet G A p U ∧ v ∉ U ∧ G.owner v = p then let r := attrRank G A p U v have hr : ∃ w ∈ A, G.edge v w ∧ w ∈ attrN G A p U (r - 1) := by have hpos := attrRank_pos_of_not_mem G A p U h.1 h.2.1 have hspec := attrRank_spec G A p U h.1 have hreq : attrRank G A p U v = (r - 1) + 1 := by omega rw [hreq] at hspec rcases hspec with hprev | ⟨_, hown_case | hopp_case⟩ · have hle := attrRank_min G A p U hprev omega · exact hown_case.2 · exact absurd h.2.2 hopp_case.1 Classical.choose hr else v lemma attrStrat_own_step {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) {v : V} (hv : v ∈ attrSet G A p U) (hnotU : v ∉ U) (hown : G.owner v = p) : let w := attrStrat G A p U v w ∈ A ∧ G.edge v w ∧ w ∈ attrSet G A p U ∧ attrRank G A p U w < attrRank G A p U v := by classical have hcond : v ∈ attrSet G A p U ∧ v ∉ U ∧ G.owner v = p := ⟨hv, hnotU, hown⟩ have hpos := attrRank_pos_of_not_mem G A p U hv hnotU dsimp only [attrStrat] rw [dif_pos hcond] have hspec := Classical.choose_spec (show ∃ w ∈ A, G.edge v w ∧ w ∈ attrN G A p U (attrRank G A p U v - 1) by have hsp := attrRank_spec G A p U hv have hreq : attrRank G A p U v = (attrRank G A p U v - 1) + 1 := by omega rw [hreq] at hsp rcases hsp with hprev | ⟨_, hown_c | hopp_c⟩ · have hle := attrRank_min G A p U hprev; omega · exact hown_c.2 · exact absurd hown hopp_c.1) rcases hspec with ⟨hwA, hedge, hwN⟩ refine ⟨hwA, hedge, Set.mem_iUnion.mpr ⟨_, hwN⟩, ?_⟩ have hle := attrRank_min G A p U hwN omega lemma attrStrat_opp_step {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) {v : V} (hv : v ∈ attrSet G A p U) (hnotU : v ∉ U) (hopp : G.owner v ≠ p) {w : V} (hwA : w ∈ A) (hedge : G.edge v w) : w ∈ attrSet G A p U ∧ attrRank G A p U w < attrRank G A p U v := by have hpos := attrRank_pos_of_not_mem G A p U hv hnotU have hsp := attrRank_spec G A p U hv have hreq : attrRank G A p U v = (attrRank G A p U v - 1) + 1 := by omega rw [hreq] at hsp rcases hsp with hprev | ⟨_, hown_c | hopp_c⟩ · have hle := attrRank_min G A p U hprev; omega · exact absurd hown_c.1 hopp · have hwN := hopp_c.2 w hwA hedge exact ⟨Set.mem_iUnion.mpr ⟨_, hwN⟩, by have := attrRank_min G A p U hwN; omega⟩ /-- Every play in `A` starting in `Attr_p(U)` that follows `attrStrat` on `Attr_p(U) \ U` must reach `U` within finitely many steps, staying inside `Attr_p(U)` throughout. -/ lemma attrStrat_reaches_U {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (U : Set V) {σ : V → V} (hσ : ∀ v, v ∈ attrSet G A p U → v ∉ U → G.owner v = p → σ v = attrStrat G A p U v) {π : ℕ → V} (hπ : IsPlayOn G A π) (hfol : Follows G p σ π) : ∀ k, ∀ n, π n ∈ attrSet G A p U → attrRank G A p U (π n) ≤ k → ∃ m ≥ n, π m ∈ U ∧ ∀ j, n ≤ j → j ≤ m → π j ∈ attrSet G A p U := by intro k induction k with | zero => intro n hn hrk have hr0 : attrRank G A p U (π n) = 0 := Nat.le_zero.mp hrk have hmemU : π n ∈ U := by have hsp := attrRank_spec G A p U hn rw [hr0] at hsp exact hsp.1 exact ⟨n, le_rfl, hmemU, fun j hj1 hj2 => by have hjn : j = n := (by omega); rw [hjn]; exact hn⟩ | succ k ih => intro n hn hrk by_cases hU : π n ∈ U · exact ⟨n, le_rfl, hU, fun j hj1 hj2 => by have hjn : j = n := (by omega); rw [hjn]; exact hn⟩ · have hnext : π (n + 1) ∈ attrSet G A p U ∧ attrRank G A p U (π (n + 1)) ≤ k := by by_cases hown : G.owner (π n) = p · have hstep := attrStrat_own_step G A p U hn hU hown have heq : π (n + 1) = attrStrat G A p U (π n) := by rw [hfol n hown, hσ (π n) hn hU hown] rw [heq] exact ⟨hstep.2.2.1, by omega⟩ · have hstep := attrStrat_opp_step G A p U hn hU hown (hπ.1 (n + 1)) (hπ.2 n) exact ⟨hstep.1, by omega⟩ rcases ih (n + 1) hnext.1 hnext.2 with ⟨m, hm, hmU, hstay⟩ refine ⟨m, by omega, hmU, fun j hj1 hj2 => ?_⟩ by_cases hjn : j = n · rwa [hjn] · exact hstay j (by omega) hj2 /-! ## Section 3: Zielonka's Theorem — Positional Determinacy of Parity Games -/ /-- A closed positional winning region `W ⊆ A` with memoryless winning strategy `σ` for player `p` inside subgame `A`. -/ def IsClosedWin {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) (W : Finset V) (σ : V → V) : Prop := W ⊆ A ∧ (∀ v ∈ W, G.owner v = p → G.edge v (σ v) ∧ σ v ∈ W) ∧ (∀ v ∈ W, G.owner v ≠ p → ∀ w ∈ A, G.edge v w → w ∈ W) ∧ (∀ π, IsPlayOn G A π → π 0 ∈ W → Follows G p σ π → Wins G p π) lemma isClosedWin_empty {V : Type*} (G : ParityGame V) (A : Finset V) (p : Player) : IsClosedWin G A p ∅ id := by refine ⟨Finset.empty_subset A, ?_, ?_, ?_⟩ · intro _ h; cases h · intro _ h; cases h · intro _ _ h; cases h lemma isClosedWin_stay {V : Type*} {G : ParityGame V} {A : Finset V} {p : Player} {W : Finset V} {σ : V → V} (hW : IsClosedWin G A p W σ) {π : ℕ → V} (hπ : IsPlayOn G A π) (h0 : π 0 ∈ W) (hfol : Follows G p σ π) : ∀ n, π n ∈ W := by intro n induction n with | zero => exact h0 | succ n ih => by_cases hown : G.owner (π n) = p · rw [hfol n hown] exact (hW.2.1 (π n) ih hown).2 · exact hW.2.2.1 (π n) ih hown (π (n + 1)) (hπ.1 (n + 1)) (hπ.2 n) /-- Helper to select between Even and Odd components according to `p : Player`. -/ def pickPlayer {α : Type*} (p : Player) (e o : α) : α := match p with | .even => e | .odd => o /-- Core inductive step of Zielonka's Theorem, parameterized uniformly by `p = parityPlayer d`. -/ lemma zielonka_subgame_player {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) : ∀ d, ∀ (A : Finset V), IsTotalOn G A → (∀ v ∈ A, G.prio v ≤ d) → ∃ W₀ W₁ σ₀ σ₁, W₀ ∪ W₁ = A ∧ Disjoint W₀ W₁ ∧ IsClosedWin G A .even W₀ σ₀ ∧ IsClosedWin G A .odd W₁ σ₁ := by intro d induction d with | zero => intro A hTot hPrio classical let σ₀ : V → V := fun v => if h : v ∈ A then Classical.choose (hTot v h) else v refine ⟨A, ∅, σ₀, id, Finset.union_empty A, Finset.disjoint_empty_right A, ?_, isClosedWin_empty G A .odd⟩ refine ⟨Finset.Subset.refl A, ?_, fun _ _ _ w hwA _ => hwA, ?_⟩ · intro v hv _ dsimp only [σ₀]; rw [dif_pos hv] have hsp := Classical.choose_spec (hTot v hv) exact ⟨hsp.2, hsp.1⟩ · intro π hπ _ _ refine ⟨0, by simp [parityPlayer], fun N => ⟨N, le_rfl, Nat.le_zero.mp (hPrio (π N) (hπ.1 N))⟩, 0, fun n _ => hPrio (π n) (hπ.1 n)⟩ | succ d ih_d => intro A -- Inner strong induction on `A.card` suffices hstrong : ∀ m, ∀ A : Finset V, A.card = m → IsTotalOn G A → (∀ v ∈ A, G.prio v ≤ d + 1) → ∃ W₀ W₁ σ₀ σ₁, W₀ ∪ W₁ = A ∧ Disjoint W₀ W₁ ∧ IsClosedWin G A .even W₀ σ₀ ∧ IsClosedWin G A .odd W₁ σ₁ from hstrong A.card A rfl intro m induction m using Nat.strong_induction_on with | h m ih_m => intro A hcard hTot hPrio classical let p : Player := parityPlayer (d + 1) let q : Player := p.opp let U : Finset V := A.filter (fun v => G.prio v = d + 1) let X : Finset V := attrFinset G A p U let A₁ : Finset V := A \ X have hUA : U ⊆ A := Finset.filter_subset _ A have hXA : X ⊆ A := attrFinset_subset G A p U have hUX : U ⊆ X := subset_attrFinset G A p hUA have hTot₁ : IsTotalOn G A₁ := sdiff_attrFinset_total hTot p U have hPrio₁ : ∀ v ∈ A₁, G.prio v ≤ d := by intro v hv rw [Finset.mem_sdiff] at hv have hle := hPrio v hv.1 have hne : G.prio v ≠ d + 1 := by intro heq exact hv.2 (hUX (Finset.mem_filter.mpr ⟨hv.1, heq⟩)) omega rcases ih_d A₁ hTot₁ hPrio₁ with ⟨W₁e, W₁o, S₁e, S₁o, hU₁, hD₁, hCe₁, hCo₁⟩ let W₁p : Finset V := pickPlayer p W₁e W₁o let W₁q : Finset V := pickPlayer p W₁o W₁e let S₁p : V → V := pickPlayer p S₁e S₁o let S₁q : V → V := pickPlayer p S₁o S₁e have hU₁pq : W₁p ∪ W₁q = A₁ := by dsimp only [W₁p, W₁q] cases p with | even => exact hU₁ | odd => rw [Finset.union_comm]; exact hU₁ have hC₁p : IsClosedWin G A₁ p W₁p S₁p := by dsimp only [W₁p, S₁p] cases p with | even => exact hCe₁ | odd => exact hCo₁ have hC₁q : IsClosedWin G A₁ q W₁q S₁q := by dsimp only [W₁q, S₁q, q] cases p with | even => exact hCo₁ | odd => exact hCe₁ have hOrient : ∀ (Wp Wq : Finset V) (Sp Sq : V → V), Wp ∪ Wq = A → Disjoint Wp Wq → IsClosedWin G A p Wp Sp → IsClosedWin G A q Wq Sq → ∃ W₀ W₁ σ₀ σ₁, W₀ ∪ W₁ = A ∧ Disjoint W₀ W₁ ∧ IsClosedWin G A .even W₀ σ₀ ∧ IsClosedWin G A .odd W₁ σ₁ := by intro Wp Wq Sp Sq hUn hDj hCp hCq cases hp : p with | even => refine ⟨Wp, Wq, Sp, Sq, hUn, hDj, ?_, ?_⟩ · rwa [hp] at hCp · simpa [q, hp, Player.opp] using hCq | odd => refine ⟨Wq, Wp, Sq, Sp, by rw [Finset.union_comm]; exact hUn, hDj.symm, ?_, ?_⟩ · simpa [q, hp, Player.opp] using hCq · rwa [hp] at hCp by_cases hEmpty : W₁q = ∅ · -- Case 1: `W₁q = ∅`, so `W₁p = A₁` and player `p` wins ALL of `A`! have hW₁p_eq : W₁p = A₁ := by rw [← hU₁pq, hEmpty, Finset.union_empty] let σp : V → V := fun v => if v ∈ A₁ then S₁p v else if v ∈ X \ U then attrStrat G A p (U : Set V) v else if h : v ∈ A then Classical.choose (hTot v h) else v apply hOrient A ∅ σp id (Finset.union_empty A) (Finset.disjoint_empty_right A) _ (isClosedWin_empty G A q) refine ⟨Finset.Subset.refl A, ?_, fun _ _ _ w hwA _ => hwA, ?_⟩ · intro v hv hown dsimp only [σp] by_cases hv₁ : v ∈ A₁ · rw [if_pos hv₁] have hstep := hC₁p.2.1 v (by rwa [hW₁p_eq]) hown exact ⟨hstep.1, Finset.sdiff_subset (hC₁p.1 hstep.2)⟩ · rw [if_neg hv₁] by_cases hvXU : v ∈ X \ U · rw [if_pos hvXU] rw [Finset.mem_sdiff] at hvXU have hstep := attrStrat_own_step G A p (U : Set V) ((mem_attrFinset G A p U).mp hvXU.1) hvXU.2 hown exact ⟨hstep.2.1, hstep.1⟩ · rw [if_neg hvXU, dif_pos hv] have hsp := Classical.choose_spec (hTot v hv) exact ⟨hsp.2, hsp.1⟩ · intro π hπ _ hfol by_cases hioU : InfOften (fun n => π n ∈ U) · refine ⟨d + 1, rfl, ?_, 0, fun n _ => hPrio (π n) (hπ.1 n)⟩ intro N rcases hioU N with ⟨n, hn, hnU⟩ exact ⟨n, hn, (Finset.mem_filter.mp hnU).2⟩ · unfold InfOften at hioU push Not at hioU rcases hioU with ⟨N, hN⟩ have hstayA₁ : ∀ n ≥ N, π n ∈ A₁ := by intro n hn by_contra hnotA₁ have hnX : π n ∈ X := by have hA := hπ.1 n by_contra hnotX exact hnotA₁ (Finset.mem_sdiff.mpr ⟨hA, hnotX⟩) have hσ_attr : ∀ v, v ∈ attrSet G A p (U : Set V) → v ∉ (U : Set V) → G.owner v = p → σp v = attrStrat G A p (U : Set V) v := by intro v hvX hvU _ have hvX' : v ∈ X := (mem_attrFinset G A p U).mpr hvX have hvnotA₁ : v ∉ A₁ := fun h => (Finset.mem_sdiff.mp h).2 hvX' dsimp only [σp] rw [if_neg hvnotA₁, if_pos (Finset.mem_sdiff.mpr ⟨hvX', hvU⟩)] rcases attrStrat_reaches_U G A p (U : Set V) hσ_attr hπ hfol (attrRank G A p (U : Set V) (π n)) n ((mem_attrFinset G A p U).mp hnX) le_rfl with ⟨m, hmn, hmU, _⟩ exact hN m (le_trans hn hmn) hmU let π' : ℕ → V := fun n => π (n + N) have hπ' : IsPlayOn G A₁ π' := ⟨fun n => hstayA₁ (n + N) (Nat.le_add_left N n), fun n => by dsimp only [π']; rw [Nat.add_right_comm]; exact hπ.2 (n + N)⟩ have hfol' : Follows G p S₁p π' := by intro n hown have h1 := hfol (n + N) hown have hmemA₁ := hstayA₁ (n + N) (Nat.le_add_left N n) dsimp only [σp] at h1 rw [if_pos hmemA₁] at h1 dsimp only [π']; rw [Nat.add_right_comm]; exact h1 have hwin' : Wins G p π' := hC₁p.2.2.2 π' hπ' (by dsimp only [π']; rw [Nat.zero_add, hW₁p_eq]; exact hstayA₁ N le_rfl) hfol' exact (wins_shift G p π N).mp hwin' · -- Case 2: `W₁q.Nonempty`! Let `Y := Attr_q(W₁q)` in `A`, solve `A₂ := A \ Y` by inner IH! have hne_W₁q : W₁q.Nonempty := Finset.nonempty_iff_ne_empty.mpr hEmpty have hW₁q_A : W₁q ⊆ A := Finset.Subset.trans hC₁q.1 Finset.sdiff_subset let Y : Finset V := attrFinset G A q W₁q have hYA : Y ⊆ A := attrFinset_subset G A q W₁q have hW₁q_Y : W₁q ⊆ Y := subset_attrFinset G A q hW₁q_A let A₂ : Finset V := A \ Y have hTot₂ : IsTotalOn G A₂ := sdiff_attrFinset_total hTot q W₁q have hPrio₂ : ∀ v ∈ A₂, G.prio v ≤ d + 1 := fun v hv => hPrio v (Finset.sdiff_subset hv) have hlt_card : A₂.card < m := by rw [← hcard] apply Finset.card_lt_card rw [Finset.ssubset_iff_subset_ne] refine ⟨Finset.sdiff_subset, fun heq => ?_⟩ rcases hne_W₁q with ⟨v, hv⟩ have hvY : v ∈ Y := hW₁q_Y hv have hvA : v ∈ A := hW₁q_A hv rw [← heq] at hvA exact (Finset.mem_sdiff.mp hvA).2 hvY rcases ih_m A₂.card hlt_card A₂ rfl hTot₂ hPrio₂ with ⟨W₂e, W₂o, S₂e, S₂o, hU₂, hD₂, hCe₂, hCo₂⟩ let W₂p : Finset V := pickPlayer p W₂e W₂o let W₂q : Finset V := pickPlayer p W₂o W₂e let S₂p : V → V := pickPlayer p S₂e S₂o let S₂q : V → V := pickPlayer p S₂o S₂e have hU₂pq : W₂p ∪ W₂q = A₂ := by dsimp only [W₂p, W₂q] cases p with | even => exact hU₂ | odd => rw [Finset.union_comm]; exact hU₂ have hD₂pq : Disjoint W₂p W₂q := by dsimp only [W₂p, W₂q] cases p with | even => exact hD₂ | odd => exact hD₂.symm have hC₂p : IsClosedWin G A₂ p W₂p S₂p := by dsimp only [W₂p, S₂p] cases p with | even => exact hCe₂ | odd => exact hCo₂ have hC₂q : IsClosedWin G A₂ q W₂q S₂q := by dsimp only [W₂q, S₂q, q] cases p with | even => exact hCo₂ | odd => exact hCe₂ -- Combined winning regions: `Wp := W₂p`, `Wq := Y ∪ W₂q` let Wq : Finset V := Y ∪ W₂q let Sq : V → V := fun v => if v ∈ W₁q then S₁q v else if v ∈ Y then attrStrat G A q (W₁q : Set V) v else S₂q v have hUn : W₂p ∪ Wq = A := by ext v simp only [Wq, Finset.mem_union] constructor · rintro (h | h | h) · exact Finset.sdiff_subset (hC₂p.1 h) · exact hYA h · exact Finset.sdiff_subset (hC₂q.1 h) · intro hvA by_cases hvY : v ∈ Y · exact Or.inr (Or.inl hvY) · have hv₂ : v ∈ A₂ := Finset.mem_sdiff.mpr ⟨hvA, hvY⟩ rw [← hU₂pq, Finset.mem_union] at hv₂ rcases hv₂ with h | h · exact Or.inl h · exact Or.inr (Or.inr h) have hDj : Disjoint W₂p Wq := by rw [Finset.disjoint_left] intro v hv1 hv2 rw [Finset.mem_union] at hv2 rcases hv2 with hvY | hv2q · exact (Finset.mem_sdiff.mp (hC₂p.1 hv1)).2 hvY · exact Finset.disjoint_left.mp hD₂pq hv1 hv2q -- Prove `IsClosedWin G A p W₂p S₂p` have hWinP : IsClosedWin G A p W₂p S₂p := by refine ⟨Finset.Subset.trans hC₂p.1 Finset.sdiff_subset, hC₂p.2.1, ?_, ?_⟩ · intro v hv hopp w hwA hedge have hown_q : G.owner v = q := by rcases Player.eq_or_eq_opp p (G.owner v) with h | h · exact absurd h hopp · exact h have hwNotY : w ∉ Y := sdiff_attrFinset_own_trap G A q W₁q (hC₂p.1 hv) hown_q hwA hedge exact hC₂p.2.2.1 v hv hopp w (Finset.mem_sdiff.mpr ⟨hwA, hwNotY⟩) hedge · intro π hπ h0 hfol have hstay : ∀ n, π n ∈ W₂p := by intro n induction n with | zero => exact h0 | succ n ih => by_cases hown : G.owner (π n) = p · rw [hfol n hown]; exact (hC₂p.2.1 (π n) ih hown).2 · have hown_q : G.owner (π n) = q := by rcases Player.eq_or_eq_opp p (G.owner (π n)) with h | h · exact absurd h hown · exact h have hwNotY : π (n + 1) ∉ Y := sdiff_attrFinset_own_trap G A q W₁q (hC₂p.1 ih) hown_q (hπ.1 (n + 1)) (hπ.2 n) exact hC₂p.2.2.1 (π n) ih hown (π (n + 1)) (Finset.mem_sdiff.mpr ⟨hπ.1 (n + 1), hwNotY⟩) (hπ.2 n) exact hC₂p.2.2.2 π ⟨fun n => hC₂p.1 (hstay n), hπ.2⟩ h0 hfol -- Prove `W₁q` is closed for `q` under `Sq` have hW₁q_closed_A : ∀ v ∈ W₁q, (G.owner v = q → G.edge v (Sq v) ∧ Sq v ∈ W₁q) ∧ (G.owner v ≠ q → ∀ w ∈ A, G.edge v w → w ∈ W₁q) := by intro v hv refine ⟨fun hown => ?_, fun hopp w hwA hedge => ?_⟩ · dsimp only [Sq]; rw [if_pos hv]; exact hC₁q.2.1 v hv hown · have hown_p : G.owner v = p := by rcases Player.eq_or_eq_opp q (G.owner v) with h | h · exact absurd h hopp · simpa [q, Player.opp_opp] using h have hwNotX : w ∉ X := sdiff_attrFinset_own_trap G A p U (hC₁q.1 hv) hown_p hwA hedge exact hC₁q.2.2.1 v hv hopp w (Finset.mem_sdiff.mpr ⟨hwA, hwNotX⟩) hedge -- Prove `IsClosedWin G A q Wq Sq` have hWinQ : IsClosedWin G A q Wq Sq := by refine ⟨Finset.union_subset hYA (Finset.Subset.trans hC₂q.1 Finset.sdiff_subset), ?_, ?_, ?_⟩ · intro v hv hown dsimp only [Sq] by_cases hv1 : v ∈ W₁q · rw [if_pos hv1] have hstep := hC₁q.2.1 v hv1 hown exact ⟨hstep.1, Finset.mem_union_left _ (hW₁q_Y hstep.2)⟩ · rw [if_neg hv1] by_cases hvY : v ∈ Y · rw [if_pos hvY] have hstep := attrStrat_own_step G A q (W₁q : Set V) ((mem_attrFinset G A q W₁q).mp hvY) hv1 hown exact ⟨hstep.2.1, Finset.mem_union_left _ ((mem_attrFinset G A q W₁q).mpr hstep.2.2.1)⟩ · rw [if_neg hvY] have hv2 : v ∈ W₂q := by rw [Finset.mem_union] at hv exact hv.resolve_left hvY have hstep := hC₂q.2.1 v hv2 hown exact ⟨hstep.1, Finset.mem_union_right _ hstep.2⟩ · intro v hv hopp w hwA hedge by_cases hv1 : v ∈ W₁q · exact Finset.mem_union_left _ (hW₁q_Y ((hW₁q_closed_A v hv1).2 hopp w hwA hedge)) · by_cases hvY : v ∈ Y · have hstep := attrStrat_opp_step G A q (W₁q : Set V) ((mem_attrFinset G A q W₁q).mp hvY) hv1 hopp hwA hedge exact Finset.mem_union_left _ ((mem_attrFinset G A q W₁q).mpr hstep.1) · by_cases hwY : w ∈ Y · exact Finset.mem_union_left _ hwY · have hv2 : v ∈ W₂q := (Finset.mem_union.mp hv).resolve_left hvY exact Finset.mem_union_right _ (hC₂q.2.2.1 v hv2 hopp w (Finset.mem_sdiff.mpr ⟨hwA, hwY⟩) hedge) · intro π hπ h0 hfol by_cases hhitY : ∃ n, π n ∈ Y · rcases hhitY with ⟨n₀, hn₀Y⟩ have hσ_attr : ∀ v, v ∈ attrSet G A q (W₁q : Set V) → v ∉ (W₁q : Set V) → G.owner v = q → Sq v = attrStrat G A q (W₁q : Set V) v := by intro v hvY hv1 _ have hv1' : v ∉ W₁q := hv1 dsimp only [Sq] rw [if_neg hv1', if_pos ((mem_attrFinset G A q W₁q).mpr hvY)] rcases attrStrat_reaches_U G A q (W₁q : Set V) hσ_attr hπ hfol (attrRank G A q (W₁q : Set V) (π n₀)) n₀ ((mem_attrFinset G A q W₁q).mp hn₀Y) le_rfl with ⟨n₁, _, hn₁W₁q, _⟩ have hstay₁ : ∀ k, π (n₁ + k) ∈ W₁q := by intro k induction k with | zero => simpa using hn₁W₁q | succ k ihk => have hcur := ihk rw [← Nat.add_assoc] by_cases hown : G.owner (π (n₁ + k)) = q · rw [hfol (n₁ + k) hown] exact ((hW₁q_closed_A (π (n₁ + k)) hcur).1 hown).2 · exact (hW₁q_closed_A (π (n₁ + k)) hcur).2 hown (π (n₁ + k + 1)) (hπ.1 _) (hπ.2 _) let π' : ℕ → V := fun k => π (k + n₁) have hπ' : IsPlayOn G A₁ π' := ⟨fun k => hC₁q.1 (by simpa [π', Nat.add_comm] using hstay₁ k), fun k => by dsimp only [π']; rw [Nat.add_right_comm]; exact hπ.2 (k + n₁)⟩ have hfol' : Follows G q S₁q π' := by intro k hown have h1 := hfol (k + n₁) hown have hmem : π (k + n₁) ∈ W₁q := by simpa [Nat.add_comm] using hstay₁ k dsimp only [Sq] at h1 rw [if_pos hmem] at h1 dsimp only [π']; rw [Nat.add_right_comm]; exact h1 have hwin' : Wins G q π' := hC₁q.2.2.2 π' hπ' (by simpa [π'] using hn₁W₁q) hfol' exact (wins_shift G q π n₁).mp hwin' · push Not at hhitY -- Never enters `Y`, so stays in `W₂q ⊆ A₂` forever following `S₂q`! have hstay₂ : ∀ n, π n ∈ W₂q := by intro n induction n with | zero => exact (Finset.mem_union.mp h0).resolve_left (hhitY 0) | succ n ih => by_cases hown : G.owner (π n) = q · have h1 := hfol n hown have hnotY := hhitY n have hnot1 : π n ∉ W₁q := fun h => hnotY (hW₁q_Y h) dsimp only [Sq] at h1 rw [if_neg hnot1, if_neg hnotY] at h1 rw [h1] exact (hC₂q.2.1 (π n) ih hown).2 · exact hC₂q.2.2.1 (π n) ih hown (π (n + 1)) (Finset.mem_sdiff.mpr ⟨hπ.1 (n + 1), hhitY (n + 1)⟩) (hπ.2 n) have hfol₂ : Follows G q S₂q π := by intro n hown have h1 := hfol n hown have hnotY := hhitY n have hnot1 : π n ∉ W₁q := fun h => hnotY (hW₁q_Y h) dsimp only [Sq] at h1 rw [if_neg hnot1, if_neg hnotY] at h1 exact h1 exact hC₂q.2.2.2 π ⟨fun n => hC₂q.1 (hstay₂ n), hπ.2⟩ (hstay₂ 0) hfol₂ exact hOrient W₂p Wq S₂p Sq hUn hDj hWinP hWinQ /-- Global closed positional winning region on the full vertex set `V`. -/ def IsGlobalPositionalWin {V : Type*} (G : ParityGame V) (p : Player) (W : Set V) (σ : V → V) : Prop := (∀ v ∈ W, G.owner v = p → G.edge v (σ v) ∧ σ v ∈ W) ∧ (∀ v ∈ W, G.owner v ≠ p → ∀ w, G.edge v w → w ∈ W) ∧ (∀ π, IsPlay G π → π 0 ∈ W → Follows G p σ π → Wins G p π) /-- **Zielonka's Theorem (Positional / Memoryless Determinacy of Finite Parity Games):** For every finite deadlock-free parity game `G` on `V`, the vertex set partitions into two disjoint regions `V = W₀ ⊔ W₁` with explicit positional (memoryless) winning strategies `σ₀ : V → V` for Even on `W₀` and `σ₁ : V → V` for Odd on `W₁`. -/ theorem zielonka_positional_determinacy {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (hTot : IsTotal G) : ∃ (W₀ W₁ : Set V) (σ₀ σ₁ : V → V), W₀ ∪ W₁ = Set.univ ∧ Disjoint W₀ W₁ ∧ IsGlobalPositionalWin G .even W₀ σ₀ ∧ IsGlobalPositionalWin G .odd W₁ σ₁ := by let d := Finset.univ.sup G.prio have hPrio : ∀ v ∈ (Finset.univ : Finset V), G.prio v ≤ d := fun v hv => Finset.le_sup hv have hTotA : IsTotalOn G Finset.univ := fun v _ => by rcases hTot v with ⟨w, hw⟩; exact ⟨w, Finset.mem_univ w, hw⟩ rcases zielonka_subgame_player G d Finset.univ hTotA hPrio with ⟨W₀, W₁, σ₀, σ₁, hUn, hDj, hC₀, hC₁⟩ refine ⟨(W₀ : Set V), (W₁ : Set V), σ₀, σ₁, ?_, ?_, ?_, ?_⟩ · ext v; simp only [Set.mem_union, Finset.mem_coe, Set.mem_univ, iff_true] rw [← Finset.mem_union, hUn]; exact Finset.mem_univ v · rw [Set.disjoint_iff] intro v ⟨h0, h1⟩ exact Finset.disjoint_left.mp hDj h0 h1 · refine ⟨hC₀.2.1, fun v hv hopp w hedge => hC₀.2.2.1 v hv hopp w (Finset.mem_univ w) hedge, ?_⟩ intro π hπ h0 hfol exact hC₀.2.2.2 π ⟨fun _ => Finset.mem_univ _, hπ⟩ h0 hfol · refine ⟨hC₁.2.1, fun v hv hopp w hedge => hC₁.2.2.1 v hv hopp w (Finset.mem_univ w) hedge, ?_⟩ intro π hπ h0 hfol exact hC₁.2.2.2 π ⟨fun _ => Finset.mem_univ _, hπ⟩ h0 hfol /-- The canonical Even winning region: vertices from which Even has a valid positional winning strategy. -/ def EvenWinRegion {V : Type*} (G : ParityGame V) : Set V := {v | ∃ σ : V → V, (∀ u, G.owner u = .even → G.edge u (σ u)) ∧ ∀ π, IsPlay G π → π 0 = v → Follows G .even σ π → Wins G .even π} /-- Helper: play induced by two competing positional strategies `σ₀` (Even) and `σ₁` (Odd). -/ def combinedStep {V : Type*} (G : ParityGame V) (σ₀ σ₁ : V → V) (v : V) : V := match G.owner v with | .even => σ₀ v | .odd => σ₁ v /-- **Uniqueness of the Zielonka Partition:** Any Zielonka partition `(W₀, W₁)` equals `(EvenWinRegion G, (EvenWinRegion G)ᶜ)` uniquely. -/ theorem winning_region_unique {V : Type*} (G : ParityGame V) (hTot : IsTotal G) {W₀ W₁ : Set V} {σ₀ σ₁ : V → V} (hUn : W₀ ∪ W₁ = Set.univ) (hDj : Disjoint W₀ W₁) (hW₀ : IsGlobalPositionalWin G .even W₀ σ₀) (hW₁ : IsGlobalPositionalWin G .odd W₁ σ₁) : W₀ = EvenWinRegion G ∧ W₁ = (EvenWinRegion G)ᶜ := by classical choose defNext hdefNext using hTot have hW₀_eq : W₀ = EvenWinRegion G := by ext v constructor · intro hv let σ₀' : V → V := fun u => if u ∈ W₀ then σ₀ u else defNext u refine ⟨σ₀', ?_, ?_⟩ · intro u hown dsimp only [σ₀']; split_ifs with hu · exact (hW₀.1 u hu hown).1 · exact hdefNext u · intro π hπ h0 hfol have hstay : ∀ n, π n ∈ W₀ := by intro n induction n with | zero => rwa [h0] | succ n ih => by_cases hown : G.owner (π n) = .even · have h1 := hfol n hown dsimp only [σ₀'] at h1 rw [if_pos ih] at h1 rw [h1] exact (hW₀.1 (π n) ih hown).2 · exact hW₀.2.1 (π n) ih hown (π (n + 1)) (hπ n) have hfol₀ : Follows G .even σ₀ π := by intro n hown have h1 := hfol n hown dsimp only [σ₀'] at h1 rw [if_pos (hstay n)] at h1 exact h1 exact hW₀.2.2 π hπ (by rwa [h0]) hfol₀ · rintro ⟨τ, hτ_valid, hτ_win⟩ by_contra hv0 have hv1 : v ∈ W₁ := by have huniv : v ∈ W₀ ∪ W₁ := by rw [hUn]; trivial exact huniv.resolve_left hv0 let step := combinedStep G τ σ₁ let π : ℕ → V := fun n => step^[n] v have hstay1 : ∀ n, π n ∈ W₁ := by intro n induction n with | zero => exact hv1 | succ n ih => show step^[n + 1] v ∈ W₁ rw [Function.iterate_succ_apply'] dsimp only [step, combinedStep] cases hown : G.owner (π n) with | even => exact hW₁.2.1 (π n) ih (by rw [hown]; decide) (τ (π n)) (hτ_valid (π n) hown) | odd => exact (hW₁.1 (π n) ih hown).2 have hπ : IsPlay G π := by intro n show G.edge (π n) (step^[n + 1] v) rw [Function.iterate_succ_apply'] dsimp only [step, combinedStep] cases hown : G.owner (π n) with | even => exact hτ_valid (π n) hown | odd => exact (hW₁.1 (π n) (hstay1 n) hown).1 have hfol0 : Follows G .even τ π := by intro n hown show step^[n + 1] v = τ (π n) rw [Function.iterate_succ_apply'] dsimp only [step, combinedStep] have hcur : (combinedStep G τ σ₁)^[n] v = π n := rfl rw [hcur, hown] have hfol1 : Follows G .odd σ₁ π := by intro n hown show step^[n + 1] v = σ₁ (π n) rw [Function.iterate_succ_apply'] dsimp only [step, combinedStep] have hcur : (combinedStep G τ σ₁)^[n] v = π n := rfl rw [hcur, hown] exact wins_disjoint (hτ_win π hπ rfl hfol0) (hW₁.2.2 π hπ hv1 hfol1) refine ⟨hW₀_eq, ?_⟩ rw [← hW₀_eq] ext v constructor · intro hv1 hv0; exact Set.disjoint_left.mp hDj hv0 hv1 · intro hv0 have huniv : v ∈ W₀ ∪ W₁ := by rw [hUn]; trivial exact huniv.resolve_left hv0 /-! ## Section 4: Exact Emerson–Jutla Correspondence (Parity Games ↔ Modal μ-Calculus) -/ /-- Controllable predecessor `CPre_p(Z)` for player `p` in parity game `G`. -/ def cpre {V : Type*} (G : ParityGame V) (p : Player) (Z : Set V) : Set V := {v | (G.owner v = p ∧ ∃ w, G.edge v w ∧ w ∈ Z) ∨ (G.owner v ≠ p ∧ ∀ w, G.edge v w → w ∈ Z)} lemma cpre_mono {V : Type*} (G : ParityGame V) (p : Player) {Z₁ Z₂ : Set V} (h : Z₁ ⊆ Z₂) : cpre G p Z₁ ⊆ cpre G p Z₂ := by intro v hv rcases hv with ⟨hown, w, hedge, hw⟩ | ⟨hopp, hall⟩ · exact Or.inl ⟨hown, w, hedge, h hw⟩ · exact Or.inr ⟨hopp, fun w hedge => h (hall w hedge)⟩ lemma cpre_compl {V : Type*} {G : ParityGame V} (_hTot : IsTotal G) (p : Player) (Z : Set V) : (cpre G p Z)ᶜ = cpre G p.opp Zᶜ := by ext v cases hown : G.owner v <;> cases p <;> simp [cpre, Player.opp, hown] /-- Inner body of the Emerson–Jutla formula: `v ∈ CPre_p(ρ(prio v))`. -/ def ejStep {V : Type*} (G : ParityGame V) (p : Player) : (ℕ → Set V) →o Set V where toFun ρ := {v | v ∈ cpre G p (ρ (G.prio v))} monotone' _ _ hρ _ hv := cpre_mono G p (hρ _) hv /-- One-step environment slice `X ↦ f (update ρ x X)`. -/ def updateSlice {V : Type*} (f : (ℕ → Set V) →o Set V) (ρ : ℕ → Set V) (x : ℕ) : Set V →o Set V where toFun X := f (Function.update ρ x X) monotone' _ _ hXY := f.monotone (fun y => by by_cases hy : y = x · subst hy; simpa using hXY · simp [hy]) /-- Monotone least-fixpoint binder `ρ ↦ lfp (X ↦ f (update ρ x X))`. -/ noncomputable def lfpBind {V : Type*} (x : ℕ) (f : (ℕ → Set V) →o Set V) : (ℕ → Set V) →o Set V where toFun ρ := OrderHom.lfp (updateSlice f ρ x) monotone' ρ₁ ρ₂ hρ := by apply OrderHom.lfp_le (updateSlice f ρ₁ x) have hstep : f (Function.update ρ₁ x (OrderHom.lfp (updateSlice f ρ₂ x))) ≤ f (Function.update ρ₂ x (OrderHom.lfp (updateSlice f ρ₂ x))) := f.monotone (fun y => by by_cases hy : y = x · subst hy; simp · simp [hy]; exact hρ y) exact le_trans hstep (le_of_eq (OrderHom.map_lfp (updateSlice f ρ₂ x))) /-- Monotone greatest-fixpoint binder `ρ ↦ gfp (X ↦ f (update ρ x X))`. -/ noncomputable def gfpBind {V : Type*} (x : ℕ) (f : (ℕ → Set V) →o Set V) : (ℕ → Set V) →o Set V where toFun ρ := OrderHom.gfp (updateSlice f ρ x) monotone' ρ₁ ρ₂ hρ := by apply OrderHom.le_gfp (updateSlice f ρ₂ x) have hstep : f (Function.update ρ₁ x (OrderHom.gfp (updateSlice f ρ₁ x))) ≤ f (Function.update ρ₂ x (OrderHom.gfp (updateSlice f ρ₁ x))) := f.monotone (fun y => by by_cases hy : y = x · subst hy; simp · simp [hy]; exact hρ y) exact le_trans (le_of_eq (OrderHom.map_gfp (updateSlice f ρ₁ x)).symm) hstep /-- Nested Knaster–Tarski Emerson–Jutla fixpoint `η_d X_d. ... η_0 X_0. CPre_p(X_{prio(v)})` as a monotone operator in the remaining free environment `ρ : ℕ → Set V`, where `η_k = ν` (`gfp`) if `parityPlayer k = p`, and `η_k = μ` (`lfp`) if `parityPlayer k ≠ p`. -/ noncomputable def ejEvalHom {V : Type*} (G : ParityGame V) (p : Player) : ℕ → ((ℕ → Set V) →o Set V) | 0 => if parityPlayer 0 = p then gfpBind 0 (ejStep G p) else lfpBind 0 (ejStep G p) | d + 1 => let prev := ejEvalHom G p d if parityPlayer (d + 1) = p then gfpBind (d + 1) prev else lfpBind (d + 1) prev /-- Convenience wrapper `ejEval G p d ρ`. -/ noncomputable def ejEval {V : Type*} (G : ParityGame V) (p : Player) (d : ℕ) (ρ : ℕ → Set V) : Set V := ejEvalHom G p d ρ lemma lfp_compl_eq_gfp {V : Type*} (F G : Set V →o Set V) (hdual : ∀ X, G Xᶜ = (F X)ᶜ) : (OrderHom.lfp F)ᶜ = OrderHom.gfp G := by apply le_antisymm · apply OrderHom.le_gfp have h1 := hdual (OrderHom.lfp F) rw [OrderHom.map_lfp] at h1 exact le_of_eq h1.symm · have hpre : F (OrderHom.gfp G)ᶜ ⊆ (OrderHom.gfp G)ᶜ := by have h1 := hdual (OrderHom.gfp G)ᶜ rw [compl_compl, OrderHom.map_gfp] at h1 have h2 : F (OrderHom.gfp G)ᶜ = (OrderHom.gfp G)ᶜ := by rw [← compl_compl (F (OrderHom.gfp G)ᶜ), ← h1] exact le_of_eq h2 exact Set.compl_subset_compl.mp (by rw [compl_compl]; exact OrderHom.lfp_le F hpre) lemma gfp_compl_eq_lfp {V : Type*} (F G : Set V →o Set V) (hdual : ∀ X, G Xᶜ = (F X)ᶜ) : (OrderHom.gfp F)ᶜ = OrderHom.lfp G := by have hdual' : ∀ X, F Xᶜ = (G X)ᶜ := by intro X; have h1 := hdual Xᶜ; rw [compl_compl] at h1; rw [h1, compl_compl] rw [← lfp_compl_eq_gfp G F hdual', compl_compl] lemma update_compl {V : Type*} (ρ : ℕ → Set V) (x : ℕ) (X : Set V) : Function.update (fun y => (ρ y)ᶜ) x Xᶜ = fun y => (Function.update ρ x X y)ᶜ := by funext y; by_cases hy : y = x <;> simp [hy] /-- **Exact Complement Duality of the Emerson–Jutla Nested Fixpoint:** `(ejEval G p d ρ)ᶜ = ejEval G p.opp d (fun k => (ρ k)ᶜ)` on every deadlock-free parity game. -/ lemma ejEval_compl_eq_opp {V : Type*} {G : ParityGame V} (hTot : IsTotal G) (p : Player) : ∀ d, ∀ ρ : ℕ → Set V, (ejEval G p d ρ)ᶜ = ejEval G p.opp d (fun k => (ρ k)ᶜ) := by intro d induction d with | zero => intro ρ have hstep_dual : ∀ X : Set V, ejStep G p.opp (Function.update (fun k => (ρ k)ᶜ) 0 Xᶜ) = (ejStep G p (Function.update ρ 0 X))ᶜ := by intro X rw [update_compl] ext v show v ∈ cpre G p.opp (Function.update ρ 0 X (G.prio v))ᶜ ↔ v ∈ (cpre G p (Function.update ρ 0 X (G.prio v)))ᶜ rw [cpre_compl hTot p] dsimp only [ejEval, ejEvalHom, OrderHom.coe_mk] by_cases hp0 : parityPlayer 0 = p · have hp0' : ¬ parityPlayer 0 = p.opp := by rw [hp0]; exact (Player.opp_ne p).symm rw [if_pos hp0, if_neg hp0'] exact gfp_compl_eq_lfp _ _ hstep_dual · have hp0' : parityPlayer 0 = p.opp := (Player.eq_or_eq_opp p (parityPlayer 0)).resolve_left hp0 rw [if_neg hp0, if_pos hp0'] exact lfp_compl_eq_gfp _ _ hstep_dual | succ d ih => intro ρ have hstep_dual : ∀ X : Set V, ejEval G p.opp d (Function.update (fun k => (ρ k)ᶜ) (d + 1) Xᶜ) = (ejEval G p d (Function.update ρ (d + 1) X))ᶜ := by intro X rw [update_compl, ih] dsimp only [ejEval, ejEvalHom, OrderHom.coe_mk] by_cases hpd : parityPlayer (d + 1) = p · have hpd' : ¬ parityPlayer (d + 1) = p.opp := by rw [hpd]; exact (Player.opp_ne p).symm rw [if_pos hpd, if_neg hpd'] exact gfp_compl_eq_lfp _ _ hstep_dual · have hpd' : parityPlayer (d + 1) = p.opp := (Player.eq_or_eq_opp p (parityPlayer (d + 1))).resolve_left hpd rw [if_neg hpd, if_pos hpd'] exact lfp_compl_eq_gfp _ _ hstep_dual /-- One step consistent with positional strategy `σ` for player `p`. -/ def NextUnder {V : Type*} (G : ParityGame V) (p : Player) (σ : V → V) (v w : V) : Prop := G.edge v w ∧ (G.owner v = p → w = σ v) /-- Reachability via a finite path staying inside `{u ∈ U | G.prio u ≤ d}` under `σ`. -/ inductive ReachUnder {V : Type*} (G : ParityGame V) (p : Player) (σ : V → V) (U : Set V) (d : ℕ) : V → V → Prop | refl {v} : v ∈ U → ReachUnder G p σ U d v v | step {v w z} : v ∈ U → G.prio v ≤ d → NextUnder G p σ v w → ReachUnder G p σ U d w z → ReachUnder G p σ U d v z /-- Extract a concrete finite sequence from a `ReachUnder` derivation. -/ lemma reachUnder_right_mem {V : Type*} {G : ParityGame V} {p : Player} {σ : V → V} {U : Set V} {d : ℕ} {v z : V} (h : ReachUnder G p σ U d v z) : z ∈ U := by induction h with | refl hv => exact hv | step _ _ _ _ ih => exact ih lemma reachUnder_to_seq {V : Type*} {G : ParityGame V} {p : Player} {σ : V → V} {U : Set V} {d : ℕ} {v z : V} (h : ReachUnder G p σ U d v z) : ∃ (len : ℕ) (f : ℕ → V), f 0 = v ∧ f len = z ∧ (∀ i < len, f i ∈ U ∧ G.prio (f i) ≤ d ∧ NextUnder G p σ (f i) (f (i + 1))) := by induction h with | refl hv => exact ⟨0, fun _ => _, rfl, rfl, fun i hi => by omega⟩ | @step v w z hv hd hnext _ ih => rcases ih with ⟨len, f, hf0, hflen, hsteps⟩ let f' : ℕ → V := fun i => match i with | 0 => v | k + 1 => f k refine ⟨len + 1, f', rfl, hflen, ?_⟩ intro i hi cases i with | zero => exact ⟨hv, hd, by simpa [f', hf0] using hnext⟩ | succ k => exact hsteps k (Nat.lt_of_succ_lt_succ hi) /-- **Core Positional-Strategy-to-Fixpoint Soundness Lemma (Arbitrary Graphs!):** If `σ` is a positional strategy for player `p` on `U` that keeps `(prio ≤ d)`-steps in `U`, sends `(prio > d)`-steps to `ρ(prio v)`, and wins every infinite play staying in `{v ∈ U | prio v ≤ d}`, then `U ⊆ ejEval G p d ρ`. -/ lemma positional_win_subset_ejEval {V : Type*} (G : ParityGame V) (p : Player) : ∀ d, ∀ (U : Set V) (σ : V → V) (ρ : ℕ → Set V), (∀ v ∈ U, G.owner v = p → G.edge v (σ v)) → (∀ v ∈ U, ∀ w, NextUnder G p σ v w → if G.prio v ≤ d then w ∈ U else w ∈ ρ (G.prio v)) → (∀ π, IsPlay G π → (∀ n, π n ∈ U ∧ G.prio (π n) ≤ d) → Follows G p σ π → Wins G p π) → U ⊆ ejEval G p d ρ := by intro d induction d with | zero => intro U σ ρ hvalid hstep hwin have hpost_step : U ⊆ ejStep G p (Function.update ρ 0 U) := by intro v hv show v ∈ cpre G p (Function.update ρ 0 U (G.prio v)) by_cases hown : G.owner v = p · left refine ⟨hown, σ v, hvalid v hv hown, ?_⟩ have hs := hstep v hv (σ v) ⟨hvalid v hv hown, fun _ => rfl⟩ by_cases h0 : G.prio v = 0 · rw [h0] at hs ⊢; simpa using hs · have hgt : ¬ G.prio v ≤ 0 := by omega rw [if_neg hgt] at hs simpa [h0] using hs · right refine ⟨hown, fun w hedge => ?_⟩ have hs := hstep v hv w ⟨hedge, fun h => absurd h hown⟩ by_cases h0 : G.prio v = 0 · rw [h0] at hs ⊢; simpa using hs · have hgt : ¬ G.prio v ≤ 0 := by omega rw [if_neg hgt] at hs simpa [h0] using hs dsimp only [ejEval, ejEvalHom, OrderHom.coe_mk] by_cases hp0 : parityPlayer 0 = p · rw [if_pos hp0] exact OrderHom.le_gfp _ hpost_step · -- Priority 0 is NOT owned by `p` (so `p = .odd`), hence NO infinite play stays in `{prio = 0}`! rw [if_neg hp0] let Z := OrderHom.lfp (updateSlice (ejStep G p) ρ 0) intro v₀ hv₀ by_contra hv₀Z have hbad : ∀ v ∈ U, v ∉ Z → G.prio v = 0 ∧ ∃ w ∈ U, NextUnder G p σ v w ∧ w ∉ Z := by intro v hv hvZ have hnotstep : v ∉ ejStep G p (Function.update ρ 0 Z) := by change v ∉ updateSlice (ejStep G p) ρ 0 Z rwa [OrderHom.map_lfp] by_cases h0 : G.prio v = 0 · refine ⟨h0, ?_⟩ by_cases hown : G.owner v = p · have hvalid_v := hvalid v hv hown have hwU : σ v ∈ U := by have hs := hstep v hv (σ v) ⟨hvalid_v, fun _ => rfl⟩ rw [h0] at hs; simpa using hs have hwZ : σ v ∉ Z := by intro hmem exact hnotstep (Or.inl ⟨hown, σ v, hvalid_v, by simpa [h0] using hmem⟩) exact ⟨σ v, hwU, ⟨hvalid_v, fun _ => rfl⟩, hwZ⟩ · have hex : ∃ w, G.edge v w ∧ w ∉ Z := by by_contra hno; push Not at hno exact hnotstep (Or.inr ⟨hown, fun w hedge => by simpa [h0] using hno w hedge⟩) rcases hex with ⟨w, hedge, hwZ⟩ have hwU : w ∈ U := by have hs := hstep v hv w ⟨hedge, fun h => absurd h hown⟩ rw [h0] at hs; simpa using hs exact ⟨w, hwU, ⟨hedge, fun h => absurd h hown⟩, hwZ⟩ · exfalso apply hnotstep have hgt : ¬ G.prio v ≤ 0 := by omega by_cases hown : G.owner v = p · left refine ⟨hown, σ v, hvalid v hv hown, ?_⟩ have hs := hstep v hv (σ v) ⟨hvalid v hv hown, fun _ => rfl⟩ rw [if_neg hgt] at hs; simpa [h0] using hs · right refine ⟨hown, fun w hedge => ?_⟩ have hs := hstep v hv w ⟨hedge, fun h => absurd h hown⟩ rw [if_neg hgt] at hs; simpa [h0] using hs -- Build an infinite play staying in `{v ∈ U | prio v = 0}` under `σ`, contradicting `hwin`! let Bad := {v : V // v ∈ U ∧ v ∉ Z} have hnext : ∀ x : Bad, ∃ y : Bad, NextUnder G p σ x.1 y.1 := by intro ⟨v, hvU, hvZ⟩ rcases (hbad v hvU hvZ).2 with ⟨w, hwU, hnw, hwZ⟩ exact ⟨⟨w, hwU, hwZ⟩, hnw⟩ choose f hf using hnext let seq : ℕ → Bad := fun n => f^[n] ⟨v₀, hv₀, hv₀Z⟩ let π : ℕ → V := fun n => (seq n).1 have hπ_play : IsPlay G π := fun n => by show G.edge (f^[n] _).1 (f^[n + 1] _).1 rw [Function.iterate_succ_apply']; exact (hf _).1 have hπ_in : ∀ n, π n ∈ U ∧ G.prio (π n) ≤ 0 := fun n => ⟨(seq n).2.1, le_of_eq (hbad _ (seq n).2.1 (seq n).2.2).1⟩ have hπ_fol : Follows G p σ π := fun n hown => by show (f^[n + 1] _).1 = σ (f^[n] _).1 rw [Function.iterate_succ_apply']; exact (hf _).2 hown have hw : Wins G p π := hwin π hπ_play hπ_in hπ_fol have hw0 : Wins G (parityPlayer 0) π := ⟨0, rfl, fun N => ⟨N, le_rfl, Nat.le_zero.mp (hπ_in N).2⟩, 0, fun n _ => (hπ_in n).2⟩ have hopp : parityPlayer 0 = p.opp := (Player.eq_or_eq_opp p (parityPlayer 0)).resolve_left hp0 rw [hopp] at hw0 exact wins_disjoint hw hw0 | succ d ih => intro U σ ρ hvalid hstep hwin dsimp only [ejEval, ejEvalHom, OrderHom.coe_mk] by_cases hpd : parityPlayer (d + 1) = p · -- Even-to-`p` priority `d + 1`: `gfp` (`ν X_{d+1}`) — immediate 4-line coinduction! rw [if_pos hpd] apply OrderHom.le_gfp apply ih U σ (Function.update ρ (d + 1) U) hvalid · intro v hv w hnw have hs := hstep v hv w hnw by_cases hle : G.prio v ≤ d · rw [if_pos hle] rw [if_pos (by omega)] at hs exact hs · rw [if_neg hle] by_cases heq : G.prio v = d + 1 · rw [heq, Function.update_self] rw [if_pos (by omega)] at hs exact hs · rw [Function.update_of_ne heq] rw [if_neg (by omega)] at hs exact hs · intro π hπ hin hfol exact hwin π hπ (fun n => ⟨(hin n).1, Nat.le_succ_of_le (hin n).2⟩) hfol · -- Odd-to-`p` priority `d + 1`: `lfp` (`μ X_{d+1}`) — via closed safe set `W` & infinite play! rw [if_neg hpd] let op : Set V →o Set V := updateSlice (ejEvalHom G p d) ρ (d + 1) let Z : Set V := OrderHom.lfp op have hFZ : ejEval G p d (Function.update ρ (d + 1) Z) = Z := OrderHom.map_lfp op let W : Set V := {v | v ∈ U ∧ ∀ x, ReachUnder G p σ U d v x → G.prio x = d + 1 → ∀ w, NextUnder G p σ x w → w ∈ Z} have hWZ : W ⊆ Z := by rw [← hFZ] apply ih W σ (Function.update ρ (d + 1) Z) · intro v hv hown; exact hvalid v hv.1 hown · intro v hv w hnw by_cases hle : G.prio v ≤ d · rw [if_pos hle] have hwU : w ∈ U := by have hs := hstep v hv.1 w hnw rwa [if_pos (Nat.le_succ_of_le hle)] at hs refine ⟨hwU, fun x hreach hpx y hny => ?_⟩ exact hv.2 x (ReachUnder.step hv.1 hle hnw hreach) hpx y hny · rw [if_neg hle] by_cases heq : G.prio v = d + 1 · rw [heq, Function.update_self] exact hv.2 v (ReachUnder.refl hv.1) heq w hnw · rw [Function.update_of_ne heq] have hs := hstep v hv.1 w hnw rwa [if_neg (by omega)] at hs · intro π hπ hin hfol exact hwin π hπ (fun n => ⟨(hin n).1.1, Nat.le_succ_of_le (hin n).2⟩) hfol intro v₀ hv₀ by_contra hv₀Z classical -- Every `v ∈ U \ Z` is outside `W`, so it reaches some `x` (`prio x = d + 1`) that steps to `v' ∈ U \ Z`! have hjump : ∀ v ∈ U, v ∉ Z → ∃ (len : ℕ) (f : ℕ → V), f 0 = v ∧ f (len + 1) ∈ U ∧ f (len + 1) ∉ Z ∧ G.prio (f len) = d + 1 ∧ (∀ i ≤ len, f i ∈ U ∧ G.prio (f i) ≤ d + 1 ∧ NextUnder G p σ (f i) (f (i + 1))) := by intro v hvU hvZ have hvW : v ∉ W := fun h => hvZ (hWZ h) simp only [W, Set.mem_ofPred_eq, not_and, not_forall] at hvW rcases hvW hvU with ⟨x, hreach, hpx, w, hnw, hwZ⟩ have hxU : x ∈ U := reachUnder_right_mem hreach have hwU : w ∈ U := by have hs := hstep x hxU w hnw rwa [if_pos (le_of_eq hpx)] at hs rcases reachUnder_to_seq hreach with ⟨len, f, hf0, hflen, hsteps⟩ let f' : ℕ → V := fun i => if i ≤ len then f i else w refine ⟨len, f', by simp [f', hf0], by simp [f']; exact hwU, by simp [f']; exact hwZ, by simp [f', hflen, hpx], ?_⟩ intro i hi by_cases hilt : i < len · have hst := hsteps i hilt refine ⟨by simp [f', hi]; exact hst.1, by simp [f', hi]; omega, ?_⟩ simp only [f', if_pos hi, if_pos (Nat.succ_le_of_lt hilt)] exact hst.2.2 · have hieq : i = len := by omega rw [hieq] refine ⟨by simp [f', hflen, hxU], by simp [f', hflen, hpx], ?_⟩ simp only [f', if_pos le_rfl, if_neg (Nat.not_succ_le_self len), hflen] exact hnw -- Concatenate these finite jumps into an infinite play visiting priority `d + 1` infinitely often! let Bad := {v : V // v ∈ U ∧ v ∉ Z} choose segLen segF seg0 segEndU segEndZ segPrio segSteps using fun (b : Bad) => hjump b.1 b.2.1 b.2.2 let nextBad : Bad → Bad := fun b => ⟨segF b (segLen b + 1), segEndU b, segEndZ b⟩ let badSeq : ℕ → Bad := fun k => nextBad^[k] ⟨v₀, hv₀, hv₀Z⟩ let cumStart : ℕ → ℕ := Nat.rec 0 (fun k acc => acc + (segLen (badSeq k) + 1)) have hcum_strict : ∀ k, cumStart k < cumStart (k + 1) := fun k => by change cumStart k < cumStart k + (segLen (badSeq k) + 1); omega have hcum_mono : StrictMono cumStart := strictMono_nat_of_lt_succ hcum_strict have hfind_seg : ∀ n, ∃ k, cumStart k ≤ n ∧ n < cumStart (k + 1) := by intro n induction n with | zero => exact ⟨0, le_rfl, hcum_strict 0⟩ | succ n ih => rcases ih with ⟨k, hk1, hk2⟩ by_cases hlt : n + 1 < cumStart (k + 1) · exact ⟨k, by omega, hlt⟩ · have heq : n + 1 = cumStart (k + 1) := by omega exact ⟨k + 1, le_of_eq heq.symm, by rw [heq]; exact hcum_strict (k + 1)⟩ let segIdx : ℕ → ℕ := fun n => Classical.choose (hfind_seg n) have hseg_spec : ∀ n, cumStart (segIdx n) ≤ n ∧ n < cumStart (segIdx n + 1) := fun n => Classical.choose_spec (hfind_seg n) have hseg_unique : ∀ n k, cumStart k ≤ n → n < cumStart (k + 1) → segIdx n = k := by intro n k hk1 hk2 have hsp := hseg_spec n by_contra hne rcases Nat.lt_or_gt_of_ne hne with hlt | hgt · have hle : cumStart (segIdx n + 1) ≤ cumStart k := hcum_mono.monotone (Nat.succ_le_of_lt hlt) omega · have hle : cumStart (k + 1) ≤ cumStart (segIdx n) := hcum_mono.monotone (Nat.succ_le_of_lt hgt) omega let π : ℕ → V := fun n => segF (badSeq (segIdx n)) (n - cumStart (segIdx n)) have hπ_step : ∀ n, π n ∈ U ∧ G.prio (π n) ≤ d + 1 ∧ NextUnder G p σ (π n) (π (n + 1)) := by intro n let k := segIdx n have hk : cumStart k ≤ n ∧ n < cumStart (k + 1) := hseg_spec n let off := n - cumStart k have hcum_eq : cumStart (k + 1) = cumStart k + (segLen (badSeq k) + 1) := rfl have hoff_le : off ≤ segLen (badSeq k) := by omega have hst := segSteps (badSeq k) off hoff_le have hnext_eq : π (n + 1) = segF (badSeq k) (off + 1) := by by_cases hlt : n + 1 < cumStart (k + 1) · have hk1 : segIdx (n + 1) = k := hseg_unique (n + 1) k (by omega) hlt dsimp only [π] rw [hk1] congr 1; omega · have heq : n + 1 = cumStart (k + 1) := by omega have hk1 : segIdx (n + 1) = k + 1 := hseg_unique (n + 1) (k + 1) (le_of_eq heq.symm) (by rw [heq]; exact hcum_strict (k + 1)) dsimp only [π] rw [hk1, heq, Nat.sub_self, seg0] have hbk : badSeq (k + 1) = nextBad (badSeq k) := Function.iterate_succ_apply' nextBad k _ rw [hbk] have hoff_eq : off + 1 = segLen (badSeq k) + 1 := by omega rw [hoff_eq] rw [hnext_eq] exact hst have hwin_p : Wins G p π := hwin π (fun n => (hπ_step n).2.2.1) (fun n => ⟨(hπ_step n).1, (hπ_step n).2.1⟩) (fun n hown => (hπ_step n).2.2.2 hown) have hio_d1 : InfOften (fun n => G.prio (π n) = d + 1) := by intro N let k := N let n := cumStart k + segLen (badSeq k) have hn_ge : N ≤ n := by have hk_le : k ≤ cumStart k := hcum_mono.id_le k omega have hseg_n : segIdx n = k := by apply hseg_unique n k (Nat.le_add_right _ _) change cumStart k + segLen (badSeq k) < cumStart k + (segLen (badSeq k) + 1) omega refine ⟨n, hn_ge, ?_⟩ dsimp only [π] rw [hseg_n] have hsub : n - cumStart k = segLen (badSeq k) := Nat.add_sub_cancel_left _ _ rw [hsub] exact segPrio (badSeq k) have hwin_d1 : Wins G (parityPlayer (d + 1)) π := ⟨d + 1, rfl, hio_d1, 0, fun n _ => (hπ_step n).2.1⟩ have hopp : parityPlayer (d + 1) = p.opp := (Player.eq_or_eq_opp p (parityPlayer (d + 1))).resolve_left hpd rw [hopp] at hwin_d1 exact wins_disjoint hwin_p hwin_d1 /-- **Emerson–Jutla Correspondence (Parity Games ↔ Nested Knaster–Tarski μ/ν Fixpoints):** For every finite deadlock-free parity game `G` with priorities bounded by `d`, the Even winning region equals the canonical alternating nested fixpoint `ejEval G .even d ρ` (for ANY environment `ρ`). -/ theorem emerson_jutla_correspondence {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (hTot : IsTotal G) {d : ℕ} (hPrio : ∀ v, G.prio v ≤ d) (ρ : ℕ → Set V) : EvenWinRegion G = ejEval G .even d ρ := by rcases zielonka_positional_determinacy G hTot with ⟨W₀, W₁, σ₀, σ₁, hUn, hDj, hW₀, hW₁⟩ have hEq := winning_region_unique G hTot hUn hDj hW₀ hW₁ rw [← hEq.1] apply le_antisymm · apply positional_win_subset_ejEval G .even d W₀ σ₀ ρ · intro v hv hown; exact (hW₀.1 v hv hown).1 · intro v hv w ⟨hedge, hfol⟩ rw [if_pos (hPrio v)] by_cases hown : G.owner v = .even · rw [hfol hown]; exact (hW₀.1 v hv hown).2 · exact hW₀.2.1 v hv hown w hedge · intro π hπ hin hfol; exact hW₀.2.2 π hπ (hin 0).1 hfol · have hW₁_sub : W₁ ⊆ ejEval G .odd d (fun k => (ρ k)ᶜ) := by apply positional_win_subset_ejEval G .odd d W₁ σ₁ (fun k => (ρ k)ᶜ) · intro v hv hown; exact (hW₁.1 v hv hown).1 · intro v hv w ⟨hedge, hfol⟩ rw [if_pos (hPrio v)] by_cases hown : G.owner v = .odd · rw [hfol hown]; exact (hW₁.1 v hv hown).2 · exact hW₁.2.1 v hv hown w hedge · intro π hπ hin hfol; exact hW₁.2.2 π hπ (hin 0).1 hfol have hcompl : (ejEval G .even d ρ)ᶜ = ejEval G .odd d (fun k => (ρ k)ᶜ) := ejEval_compl_eq_opp hTot .even d ρ rw [← hcompl] at hW₁_sub intro v hv have hv1 : v ∉ W₁ := fun h => hW₁_sub h hv have huniv : v ∈ W₀ ∪ W₁ := by rw [hUn]; trivial exact huniv.resolve_right hv1 /-! ## Section 5: Syntactic Modal μ-Calculus Formula for Parity Games -/ /-- Atomic propositions encoding a parity game as a Kripke structure. -/ inductive ParityAtom : Type | isEvenOwner : ParityAtom | hasPrio (k : ℕ) : ParityAtom deriving DecidableEq /-- Standalone Positive-Normal-Form Modal μ-Calculus over unlabeled Kripke structures. -/ inductive MuFormula (P : Type*) : Type _ | tt : MuFormula P | ff : MuFormula P | atom (p : P) : MuFormula P | negAtom (p : P) : MuFormula P | var (x : ℕ) : MuFormula P | and (φ ψ : MuFormula P) : MuFormula P | or (φ ψ : MuFormula P) : MuFormula P | dia (φ : MuFormula P) : MuFormula P | box (φ : MuFormula P) : MuFormula P | mu (x : ℕ) (φ : MuFormula P) : MuFormula P | nu (x : ℕ) (φ : MuFormula P) : MuFormula P /-- Free variables of a `MuFormula`. -/ def MuFormula.freeVars {P : Type*} : MuFormula P → Finset ℕ | .tt | .ff | .atom _ | .negAtom _ => ∅ | .var x => {x} | .and φ ψ | .or φ ψ => φ.freeVars ∪ ψ.freeVars | .dia φ | .box φ => φ.freeVars | .mu x φ | .nu x φ => φ.freeVars.erase x /-- Knaster–Tarski semantics of `MuFormula ParityAtom` directly on a parity game `G`. -/ noncomputable def MuFormula.evalOnGame {V : Type*} (G : ParityGame V) : MuFormula ParityAtom → ((ℕ → Set V) →o Set V) | .tt => OrderHom.const _ Set.univ | .ff => OrderHom.const _ ∅ | .atom .isEvenOwner => OrderHom.const _ {v | G.owner v = .even} | .atom (.hasPrio k) => OrderHom.const _ {v | G.prio v = k} | .negAtom .isEvenOwner => OrderHom.const _ {v | G.owner v ≠ .even} | .negAtom (.hasPrio k) => OrderHom.const _ {v | G.prio v ≠ k} | .var x => { toFun := fun ρ => ρ x, monotone' := fun _ _ h => h x } | .and φ ψ => let f₁ := φ.evalOnGame G let f₂ := ψ.evalOnGame G { toFun := fun ρ => f₁ ρ ∩ f₂ ρ monotone' := fun _ _ h => Set.inter_subset_inter (f₁.monotone h) (f₂.monotone h) } | .or φ ψ => let f₁ := φ.evalOnGame G let f₂ := ψ.evalOnGame G { toFun := fun ρ => f₁ ρ ∪ f₂ ρ monotone' := fun _ _ h => Set.union_subset_union (f₁.monotone h) (f₂.monotone h) } | .dia φ => let f := φ.evalOnGame G { toFun := fun ρ => {v | ∃ w, G.edge v w ∧ w ∈ f ρ} monotone' := fun _ _ h _ ⟨w, hvw, hw⟩ => ⟨w, hvw, f.monotone h hw⟩ } | .box φ => let f := φ.evalOnGame G { toFun := fun ρ => {v | ∀ w, G.edge v w → w ∈ f ρ} monotone' := fun _ _ h _ hall w hvw => f.monotone h (hall w hvw) } | .mu x φ => lfpBind x (φ.evalOnGame G) | .nu x φ => gfpBind x (φ.evalOnGame G) /-- Syntactic controllable predecessor `(isEvenOwner ∧ ◇ X_k) ∨ (¬isEvenOwner ∧ □ X_k)`. -/ def cpreMu (k : ℕ) : MuFormula ParityAtom := .or (.and (.atom .isEvenOwner) (.dia (.var k))) (.and (.negAtom .isEvenOwner) (.box (.var k))) /-- Syntactic body `⋁_{k=0}^d (hasPrio k ∧ CPre(X_k))` of the Emerson–Jutla μ-calculus formula. -/ def ejMuBody : ℕ → MuFormula ParityAtom | 0 => .and (.atom (.hasPrio 0)) (cpreMu 0) | d + 1 => .or (ejMuBody d) (.and (.atom (.hasPrio (d + 1))) (cpreMu (d + 1))) /-- Wrap a body `φ` in alternating binders `η_d X_d. ... η_0 X_0. φ` (`ν` for even `k`, `μ` for odd `k`). -/ def ejWrapBinders : ℕ → MuFormula ParityAtom → MuFormula ParityAtom | 0, φ => .nu 0 φ | d + 1, φ => if Even (d + 1) then .nu (d + 1) (ejWrapBinders d φ) else .mu (d + 1) (ejWrapBinders d φ) /-- The canonical closed syntactic Emerson–Jutla modal μ-calculus formula for priorities `0..d`. -/ def ejMuFormula (d : ℕ) : MuFormula ParityAtom := ejWrapBinders d (ejMuBody d) lemma ejMuBody_freeVars (d : ℕ) : ∀ x ∈ (ejMuBody d).freeVars, x ≤ d := by induction d with | zero => intro x hx simp [ejMuBody, cpreMu, MuFormula.freeVars] at hx omega | succ d ih => intro x hx simp only [ejMuBody, cpreMu, MuFormula.freeVars, Finset.mem_union, Finset.mem_singleton, Finset.notMem_empty, false_or] at hx rcases hx with h1 | h2 | h3 · exact Nat.le_succ_of_le (ih x h1) · omega · omega lemma ejWrapBinders_freeVars (d : ℕ) (φ : MuFormula ParityAtom) : ∀ x ∈ (ejWrapBinders d φ).freeVars, x ∈ φ.freeVars ∧ d < x := by induction d with | zero => intro x hx simp only [ejWrapBinders, MuFormula.freeVars, Finset.mem_erase] at hx exact ⟨hx.2, Nat.pos_of_ne_zero hx.1⟩ | succ d ih => intro x hx dsimp only [ejWrapBinders] at hx split_ifs at hx <;> (simp only [MuFormula.freeVars, Finset.mem_erase] at hx; rcases ih x hx.2 with ⟨hmem, hgt⟩; exact ⟨hmem, by omega⟩) lemma ejMuFormula_closed (d : ℕ) : (ejMuFormula d).freeVars = ∅ := by rw [Finset.eq_empty_iff_forall_notMem] intro x hx rcases ejWrapBinders_freeVars d (ejMuBody d) x hx with ⟨hmem, hgt⟩ have hle := ejMuBody_freeVars d x hmem omega lemma ejMuBody_eval {V : Type*} (G : ParityGame V) (d : ℕ) (hPrio : ∀ v, G.prio v ≤ d) (ρ : ℕ → Set V) : (ejMuBody d).evalOnGame G ρ = ejStep G .even ρ := by have hbody : ∀ m, (ejMuBody m).evalOnGame G ρ = {v | G.prio v ≤ m ∧ v ∈ cpre G .even (ρ (G.prio v))} := by intro m induction m with | zero => ext v simp only [ejMuBody, cpreMu, MuFormula.evalOnGame, OrderHom.coe_mk, OrderHom.const_coe_coe, Set.mem_inter_iff, Set.mem_union, Set.mem_ofPred_eq, cpre, Nat.le_zero] constructor · rintro ⟨h0, h⟩; exact ⟨h0, by rwa [h0]⟩ · rintro ⟨h0, h⟩; exact ⟨h0, by rwa [← h0]⟩ | succ m ih => ext v change v ∈ (ejMuBody m).evalOnGame G ρ ∪ ({u | G.prio u = m + 1} ∩ (cpreMu (m + 1)).evalOnGame G ρ) ↔ _ rw [ih] simp only [cpreMu, MuFormula.evalOnGame, OrderHom.coe_mk, OrderHom.const_coe_coe, Set.mem_union, Set.mem_inter_iff, Set.mem_ofPred_eq, cpre] constructor · rintro (⟨hm, hc⟩ | ⟨heq, hc⟩) · exact ⟨Nat.le_succ_of_le hm, hc⟩ · exact ⟨le_of_eq heq, by rwa [heq]⟩ · rintro ⟨hle, hc⟩ by_cases heq : G.prio v = m + 1 · exact Or.inr ⟨heq, by rwa [← heq]⟩ · exact Or.inl ⟨by omega, hc⟩ rw [hbody d] ext v simp only [ejStep, Set.mem_ofPred_eq, hPrio v, true_and] rfl lemma ejWrapBinders_eval {V : Type*} (G : ParityGame V) (d₀ : ℕ) (hPrio : ∀ v, G.prio v ≤ d₀) : ∀ d, ∀ ρ : ℕ → Set V, (ejWrapBinders d (ejMuBody d₀)).evalOnGame G ρ = ejEval G .even d ρ := by intro d induction d with | zero => intro ρ dsimp only [ejWrapBinders, MuFormula.evalOnGame, ejEval, ejEvalHom] rw [if_pos (by simp [parityPlayer])] dsimp only [gfpBind, OrderHom.coe_mk] apply congrArg OrderHom.gfp apply OrderHom.ext; funext X exact ejMuBody_eval G d₀ hPrio _ | succ d ih => intro ρ dsimp only [ejWrapBinders] by_cases hev : Even (d + 1) · rw [if_pos hev] dsimp only [MuFormula.evalOnGame, ejEval, ejEvalHom] rw [if_pos (by simp [parityPlayer, hev])] dsimp only [gfpBind, OrderHom.coe_mk] apply congrArg OrderHom.gfp apply OrderHom.ext; funext X exact ih _ · rw [if_neg hev] dsimp only [MuFormula.evalOnGame, ejEval, ejEvalHom] rw [if_neg (by simp [parityPlayer, hev])] dsimp only [lfpBind, OrderHom.coe_mk] apply congrArg OrderHom.lfp apply OrderHom.ext; funext X exact ih _ /-- **Syntactic Emerson–Jutla Modal μ-Calculus Model-Checking Equivalence:** For every finite deadlock-free parity game `G` with priorities `≤ d`, `ejMuFormula d` is a closed syntactic modal μ-calculus formula whose Knaster–Tarski semantics on `G` equals the exact Even winning region `EvenWinRegion G`. -/ theorem emerson_jutla_syntactic_mu_calculus {V : Type*} [Fintype V] [DecidableEq V] (G : ParityGame V) (hTot : IsTotal G) {d : ℕ} (hPrio : ∀ v, G.prio v ≤ d) (ρ : ℕ → Set V) : (ejMuFormula d).freeVars = ∅ ∧ EvenWinRegion G = (ejMuFormula d).evalOnGame G ρ := by refine ⟨ejMuFormula_closed d, ?_⟩ rw [ejMuFormula, ejWrapBinders_eval G d hPrio d ρ] exact emerson_jutla_correspondence G hTot hPrio ρ /-! ## Section 6: Concrete 4-Vertex 3-Priority Parity Game Witness -/ /-- A concrete 4-vertex parity game with priorities `{0, 1, 2}`: - `0` (Even, prio `1`): edges to `1` and `2` - `1` (Odd, prio `2`): edges to `0` and `1` - `2` (Even, prio `1`): edges to `2` and `3` - `3` (Odd, prio `0`): edge to `2` Even wins `{0, 1}` (moving `0 → 1` forces prio `2` i.o.); Odd wins `{2, 3}` (moving `3 → 2` forces prio `1` i.o.). -/ def sampleGame : ParityGame (Fin 4) where owner v := match v.val with | 0 | 2 => .even | _ => .odd edge v w := match v.val, w.val with | 0, 1 | 0, 2 => True | 1, 0 | 1, 1 => True | 2, 2 | 2, 3 => True | 3, 2 => True | _, _ => False prio v := match v.val with | 0 => 1 | 1 => 2 | 2 => 1 | _ => 0 lemma sampleGame_total : IsTotal sampleGame := by intro v; fin_cases v · exact ⟨1, trivial⟩ · exact ⟨1, trivial⟩ · exact ⟨2, trivial⟩ · exact ⟨2, trivial⟩ /-- **Concrete 3-Priority Parity Game Partition Witness:** On `sampleGame`, `EvenWinRegion sampleGame = {0, 1}` (matching `(ejMuFormula 2).evalOnGame`), while `{2, 3}` is Odd's winning region, demonstrating a non-trivial mixed-priority split. -/ theorem sampleGame_exact_winning_regions (ρ : ℕ → Set (Fin 4)) : EvenWinRegion sampleGame = {0, 1} ∧ (ejMuFormula 2).evalOnGame sampleGame ρ = {0, 1} := by let W₀ : Set (Fin 4) := {0, 1} let W₁ : Set (Fin 4) := {2, 3} let σ₀ : Fin 4 → Fin 4 := fun _ => 1 let σ₁ : Fin 4 → Fin 4 := fun _ => 2 have hUn : W₀ ∪ W₁ = Set.univ := by ext v; fin_cases v <;> simp [W₀, W₁] have hDj : Disjoint W₀ W₁ := by rw [Set.disjoint_iff]; intro v ⟨h0, h1⟩; fin_cases v <;> simp [W₀, W₁] at h0 h1 have hW₀ : IsGlobalPositionalWin sampleGame .even W₀ σ₀ := by refine ⟨?_, ?_, ?_⟩ · intro v hv hown; fin_cases v <;> simp [W₀, σ₀, sampleGame] at hv hown ⊢ · intro v hv hopp w hw; fin_cases v <;> fin_cases w <;> simp [W₀, sampleGame] at hv hopp hw ⊢ · intro π hπ h0 hfol have hstay : ∀ n, π n ∈ W₀ := by intro n induction n with | zero => exact h0 | succ n ih => rcases ih with h | h · have h1 := hfol n (by rw [h]; rfl) rw [h1]; exact Or.inr rfl · rw [Set.mem_singleton_iff] at h have he := hπ n; rw [h] at he generalize π (n + 1) = w at he ⊢ fin_cases w <;> simp [W₀, sampleGame] at he ⊢ refine ⟨2, by simp [parityPlayer], ?_, 0, fun n _ => ?_⟩ · intro N rcases hstay N with hN0 | hN1 · refine ⟨N + 1, Nat.le_succ N, ?_⟩ have h1 := hfol N (by rw [hN0]; rfl) dsimp only; rw [h1]; rfl · rw [Set.mem_singleton_iff] at hN1 exact ⟨N, le_rfl, by dsimp only; rw [hN1]; rfl⟩ · generalize π n = w fin_cases w <;> decide have hW₁ : IsGlobalPositionalWin sampleGame .odd W₁ σ₁ := by refine ⟨?_, ?_, ?_⟩ · intro v hv hown; fin_cases v <;> simp [W₁, σ₁, sampleGame] at hv hown ⊢ · intro v hv hopp w hw; fin_cases v <;> fin_cases w <;> simp [W₁, sampleGame] at hv hopp hw ⊢ · intro π hπ h0 hfol have hstay : ∀ n, π n ∈ W₁ := by intro n induction n with | zero => exact h0 | succ n ih => rcases ih with h | h · have he := hπ n; rw [h] at he generalize π (n + 1) = w at he ⊢ fin_cases w <;> simp [W₁, sampleGame] at he ⊢ · rw [Set.mem_singleton_iff] at h have h1 := hfol n (by rw [h]; rfl) rw [h1]; exact Or.inl rfl refine ⟨1, by simp [parityPlayer], ?_, 0, fun n _ => ?_⟩ · intro N rcases hstay N with hN2 | hN3 · exact ⟨N, le_rfl, by dsimp only; rw [hN2]; rfl⟩ · rw [Set.mem_singleton_iff] at hN3 refine ⟨N + 1, Nat.le_succ N, ?_⟩ have h1 := hfol N (by rw [hN3]; rfl) dsimp only; rw [h1]; rfl · rcases hstay n with h | h · rw [h]; decide · rw [Set.mem_singleton_iff] at h; rw [h]; decide have huniq := (winning_region_unique sampleGame sampleGame_total hUn hDj hW₀ hW₁).1 have hej := (emerson_jutla_syntactic_mu_calculus sampleGame sampleGame_total (d := 2) (fun v => by fin_cases v <;> decide) ρ).2 exact ⟨huniq.symm, by rw [← hej, ← huniq]⟩ /-! ## Axiom Audit -/ #print axioms zielonka_positional_determinacy #print axioms winning_region_unique #print axioms emerson_jutla_correspondence #print axioms emerson_jutla_syntactic_mu_calculus #print axioms sampleGame_exact_winning_regions end ParityGames