import Mathlib /-! # Modal μ-Calculus: Knaster–Tarski Fixpoints, Duality, CTL Embedding, # Finite-State Kleene Convergence & Full Bisimulation Invariance This standalone Lean 4 module formalizes Pillar 3 of our Formal Verification, Temporal Logic, Modal μ-Calculus & Parity Games development: 1. **Modal μ-Calculus Syntax & Knaster–Tarski Denotational Semantics:** - Positive Normal Form `MuFormula A P` guaranteeing monotonicity in all fixpoint variables, with exact Knaster–Tarski semantics (`OrderHom.lfp` / `OrderHom.gfp` on `Set S`). - Full syntactic negation & positivity checker (`RawMu A P`, `OccursPos`, `OccursNeg`, `WellFormed`) together with exact Negation Normal Form translation `toPNF` (`raw_mu_toPNF_sound`). - Exact **Complement Duality** (`eval_dual`, `mu_nu_duality`): `(eval M ρ (.mu x φ))ᶜ = eval M (fun y => (ρ y)ᶜ) (.nu x φ.dual)`. - Exact Fixpoint Unfolding & Park Induction / Coinduction (`mu_unfold`, `nu_unfold`, `mu_park_induction`, `nu_park_coinduction`). 2. **Exact Embedding of CTL into Closed Modal μ-Calculus:** - Full translation `ctlToMu` embedding `EX`, `AX`, `EF`, `AF`, `EG`, `AG`, `EU`, `AU` into closed `MuFormula Unit P` formulas, with exact semantic equivalence on arbitrary serial Kripke structures (`ctl_to_mu_embedding`). 3. **Finite-State Kleene Iteration Convergence & Exact `n`-Step Sharpness:** - On any finite state space (`[Fintype S]`, `n = Fintype.card S`), every least fixpoint converges in at most `n` steps `F^[n] ∅` and every greatest fixpoint in at most `n` steps `F^[n] Set.univ` (`lfp_eq_iterate_card`, `gfp_eq_iterate_card`, `mu_kleene_convergence`, `nu_kleene_convergence`). - **Exact Sharpness Witness (`kleene_exact_n_steps_sharp`):** For every `n ≥ 1`, the `n`-state chain Kripke structure `chainLTS n` witnesses that BOTH `μ X. (p ∨ ⟨⟩ X)` and `ν X. (¬p ∧ [] X)` fail to converge at step `n - 1` and converge at exact step `n`. 4. **Full Modal μ-Calculus Bisimulation Invariance (`mu_calculus_bisimulation_invariant`):** - Proved on arbitrary (even infinite-state, non-image-finite) LTSs via a monotone one-sided simulation argument requiring no transfinite ordinal induction. -/ namespace ModalMuCalculus /-! ## Section 1: LTS, Cross-Bisimulation & Positive Normal Form Modal μ-Calculus -/ /-- A Labeled Transition System `(S, step, val)`. -/ structure LTS (S A P : Type*) where step : S → A → S → Prop val : S → P → Prop /-- Cross-bisimulation between two LTSs over actions `A` and atoms `P`. -/ def IsCrossBisim {S₁ S₂ A P : Type*} (M₁ : LTS S₁ A P) (M₂ : LTS S₂ A P) (R : S₁ → S₂ → Prop) : Prop := ∀ s₁ s₂, R s₁ s₂ → (∀ p, M₁.val s₁ p ↔ M₂.val s₂ p) ∧ (∀ a s₁', M₁.step s₁ a s₁' → ∃ s₂', M₂.step s₂ a s₂' ∧ R s₁' s₂') ∧ (∀ a s₂', M₂.step s₂ a s₂' → ∃ s₁', M₁.step s₁ a s₁' ∧ R s₁' s₂') /-- Largest cross-bisimulation between `M₁` and `M₂`. -/ def CrossBisimilar {S₁ S₂ A P : Type*} (M₁ : LTS S₁ A P) (M₂ : LTS S₂ A P) (s₁ : S₁) (s₂ : S₂) : Prop := ∃ R, IsCrossBisim M₁ M₂ R ∧ R s₁ s₂ /-- Modal μ-calculus in Positive Normal Form (PNF): every variable occurrence is positive, ensuring every formula defines a monotone operator on `Set S`. -/ inductive MuFormula (A P : Type*) : Type _ | tt : MuFormula A P | ff : MuFormula A P | atom (p : P) : MuFormula A P | negAtom (p : P) : MuFormula A P | var (x : ℕ) : MuFormula A P | and (φ ψ : MuFormula A P) : MuFormula A P | or (φ ψ : MuFormula A P) : MuFormula A P | dia (a : A) (φ : MuFormula A P) : MuFormula A P | box (a : A) (φ : MuFormula A P) : MuFormula A P | mu (x : ℕ) (φ : MuFormula A P) : MuFormula A P | nu (x : ℕ) (φ : MuFormula A P) : MuFormula A P /-- Set of free fixpoint variables in a `MuFormula`. -/ def MuFormula.freeVars {A P : Type*} : MuFormula A P → Finset ℕ | .tt | .ff | .atom _ | .negAtom _ => ∅ | .var x => {x} | .and φ ψ | .or φ ψ => φ.freeVars ∪ ψ.freeVars | .dia _ φ | .box _ φ => φ.freeVars | .mu x φ | .nu x φ => φ.freeVars.erase x /-- A `MuFormula` is closed if it has no free variables. -/ def MuFormula.IsClosed {A P : Type*} (φ : MuFormula A P) : Prop := φ.freeVars = ∅ /-- Syntactic dual (De Morgan + fixpoint complementation) of a `MuFormula`. -/ def MuFormula.dual {A P : Type*} : MuFormula A P → MuFormula A P | .tt => .ff | .ff => .tt | .atom p => .negAtom p | .negAtom p => .atom p | .var x => .var x | .and φ ψ => .or φ.dual ψ.dual | .or φ ψ => .and φ.dual ψ.dual | .dia a φ => .box a φ.dual | .box a φ => .dia a φ.dual | .mu x φ => .nu x φ.dual | .nu x φ => .mu x φ.dual lemma MuFormula.dual_involutive {A P : Type*} (φ : MuFormula A P) : φ.dual.dual = φ := by induction φ with | tt | ff | atom _ | negAtom _ | var _ => rfl | and _ _ ih₁ ih₂ => simp [MuFormula.dual, ih₁, ih₂] | or _ _ ih₁ ih₂ => simp [MuFormula.dual, ih₁, ih₂] | dia _ _ ih => simp [MuFormula.dual, ih] | box _ _ ih => simp [MuFormula.dual, ih] | mu _ _ ih => simp [MuFormula.dual, ih] | nu _ _ ih => simp [MuFormula.dual, ih] lemma MuFormula.freeVars_dual {A P : Type*} (φ : MuFormula A P) : φ.dual.freeVars = φ.freeVars := by induction φ with | tt | ff | atom _ | negAtom _ | var _ => rfl | and _ _ ih₁ ih₂ => simp [MuFormula.dual, MuFormula.freeVars, ih₁, ih₂] | or _ _ ih₁ ih₂ => simp [MuFormula.dual, MuFormula.freeVars, ih₁, ih₂] | dia _ _ ih => simp [MuFormula.dual, MuFormula.freeVars, ih] | box _ _ ih => simp [MuFormula.dual, MuFormula.freeVars, ih] | mu _ _ ih => simp [MuFormula.dual, MuFormula.freeVars, ih] | nu _ _ ih => simp [MuFormula.dual, MuFormula.freeVars, ih] /-- Existential modal predecessor `⟨a⟩ X`. -/ def diaOp {S A P : Type*} (M : LTS S A P) (a : A) (X : Set S) : Set S := {s | ∃ t, M.step s a t ∧ t ∈ X} /-- Universal modal predecessor `[a] X`. -/ def boxOp {S A P : Type*} (M : LTS S A P) (a : A) (X : Set S) : Set S := {s | ∀ t, M.step s a t → t ∈ X} lemma diaOp_compl {S A P : Type*} (M : LTS S A P) (a : A) (X : Set S) : (diaOp M a X)ᶜ = boxOp M a Xᶜ := by ext s; simp [diaOp, boxOp] lemma boxOp_compl {S A P : Type*} (M : LTS S A P) (a : A) (X : Set S) : (boxOp M a X)ᶜ = diaOp M a Xᶜ := by ext s; simp [diaOp, boxOp] /-- One-step slice `X ↦ f (update ρ x X)` of a monotone environment transformer `f`. -/ def updateSlice {S : Type*} (f : (ℕ → Set S) →o Set S) (ρ : ℕ → Set S) (x : ℕ) : Set S →o Set S where toFun X := f (Function.update ρ x X) monotone' _ _ hXY := f.monotone (by intro y 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 {S : Type*} (x : ℕ) (f : (ℕ → Set S) →o Set S) : (ℕ → Set S) →o Set S 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 {S : Type*} (x : ℕ) (f : (ℕ → Set S) →o Set S) : (ℕ → Set S) →o Set S 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 /-- Monotone Knaster–Tarski denotational semantics of `MuFormula A P` as an order homomorphism from environments `(ℕ → Set S)` to `Set S`. -/ noncomputable def MuFormula.evalHom {S A P : Type*} (M : LTS S A P) : MuFormula A P → ((ℕ → Set S) →o Set S) | .tt => OrderHom.const _ Set.univ | .ff => OrderHom.const _ ∅ | .atom p => OrderHom.const _ {s | M.val s p} | .negAtom p => OrderHom.const _ {s | ¬ M.val s p} | .var x => { toFun := fun ρ => ρ x monotone' := fun _ _ h => h x } | .and φ ψ => let f₁ := φ.evalHom M let f₂ := ψ.evalHom M { toFun := fun ρ => f₁ ρ ∩ f₂ ρ monotone' := fun _ _ h => Set.inter_subset_inter (f₁.monotone h) (f₂.monotone h) } | .or φ ψ => let f₁ := φ.evalHom M let f₂ := ψ.evalHom M { toFun := fun ρ => f₁ ρ ∪ f₂ ρ monotone' := fun _ _ h => Set.union_subset_union (f₁.monotone h) (f₂.monotone h) } | .dia a φ => let f := φ.evalHom M { toFun := fun ρ => diaOp M a (f ρ) monotone' := fun _ _ h _ ⟨t, hst, ht⟩ => ⟨t, hst, f.monotone h ht⟩ } | .box a φ => let f := φ.evalHom M { toFun := fun ρ => boxOp M a (f ρ) monotone' := fun _ _ h _ hall t hst => f.monotone h (hall t hst) } | .mu x φ => lfpBind x (φ.evalHom M) | .nu x φ => gfpBind x (φ.evalHom M) /-- Denotational semantics `⟦φ⟧_ρ` of a `MuFormula` on `M`. -/ noncomputable def MuFormula.eval {S A P : Type*} (M : LTS S A P) (ρ : ℕ → Set S) (φ : MuFormula A P) : Set S := φ.evalHom M ρ /-- One-step monotone operator `X ↦ ⟦φ⟧_{ρ[x ↦ X]}` for fixpoint binding. -/ noncomputable def MuFormula.stepOp {S A P : Type*} (M : LTS S A P) (ρ : ℕ → Set S) (x : ℕ) (φ : MuFormula A P) : Set S →o Set S := updateSlice (φ.evalHom M) ρ x lemma MuFormula.eval_mono {S A P : Type*} (M : LTS S A P) (φ : MuFormula A P) {ρ₁ ρ₂ : ℕ → Set S} (h : ∀ x, ρ₁ x ⊆ ρ₂ x) : φ.eval M ρ₁ ⊆ φ.eval M ρ₂ := (φ.evalHom M).monotone h lemma MuFormula.eval_mu_eq_lfp {S A P : Type*} (M : LTS S A P) (ρ : ℕ → Set S) (x : ℕ) (φ : MuFormula A P) : (MuFormula.mu x φ).eval M ρ = OrderHom.lfp (φ.stepOp M ρ x) := rfl lemma MuFormula.eval_nu_eq_gfp {S A P : Type*} (M : LTS S A P) (ρ : ℕ → Set S) (x : ℕ) (φ : MuFormula A P) : (MuFormula.nu x φ).eval M ρ = OrderHom.gfp (φ.stepOp M ρ x) := rfl /-- **Knaster–Tarski Unfolding & Park Induction/Coinduction Laws for Modal μ-Calculus.** -/ theorem mu_nu_unfold_and_park {S A P : Type*} (M : LTS S A P) (ρ : ℕ → Set S) (x : ℕ) (φ : MuFormula A P) : ((MuFormula.mu x φ).eval M ρ = φ.eval M (Function.update ρ x ((MuFormula.mu x φ).eval M ρ))) ∧ ((MuFormula.nu x φ).eval M ρ = φ.eval M (Function.update ρ x ((MuFormula.nu x φ).eval M ρ))) ∧ (∀ Z, φ.eval M (Function.update ρ x Z) ⊆ Z → (MuFormula.mu x φ).eval M ρ ⊆ Z) ∧ (∀ Z, Z ⊆ φ.eval M (Function.update ρ x Z) → Z ⊆ (MuFormula.nu x φ).eval M ρ) := by refine ⟨?_, ?_, ?_, ?_⟩ · exact (OrderHom.map_lfp (φ.stepOp M ρ x)).symm · exact (OrderHom.map_gfp (φ.stepOp M ρ x)).symm · intro Z hZ; exact OrderHom.lfp_le (φ.stepOp M ρ x) hZ · intro Z hZ; exact OrderHom.le_gfp (φ.stepOp M ρ x) hZ lemma eval_congr_freeVars {S A P : Type*} (M : LTS S A P) (φ : MuFormula A P) : ∀ {ρ₁ ρ₂ : ℕ → Set S}, (∀ x ∈ φ.freeVars, ρ₁ x = ρ₂ x) → φ.eval M ρ₁ = φ.eval M ρ₂ := by induction φ with | tt | ff | atom _ | negAtom _ => intro _ _ _; rfl | var x => intro ρ₁ ρ₂ h; exact h x (Finset.mem_singleton_self x) | and φ ψ ih₁ ih₂ => intro ρ₁ ρ₂ h change φ.eval M ρ₁ ∩ ψ.eval M ρ₁ = φ.eval M ρ₂ ∩ ψ.eval M ρ₂ rw [ih₁ (fun x hx => h x (Finset.mem_union_left _ hx)), ih₂ (fun x hx => h x (Finset.mem_union_right _ hx))] | or φ ψ ih₁ ih₂ => intro ρ₁ ρ₂ h change φ.eval M ρ₁ ∪ ψ.eval M ρ₁ = φ.eval M ρ₂ ∪ ψ.eval M ρ₂ rw [ih₁ (fun x hx => h x (Finset.mem_union_left _ hx)), ih₂ (fun x hx => h x (Finset.mem_union_right _ hx))] | dia a φ ih => intro ρ₁ ρ₂ h change diaOp M a (φ.eval M ρ₁) = diaOp M a (φ.eval M ρ₂) rw [ih h] | box a φ ih => intro ρ₁ ρ₂ h change boxOp M a (φ.eval M ρ₁) = boxOp M a (φ.eval M ρ₂) rw [ih h] | mu x φ ih => intro ρ₁ ρ₂ h rw [MuFormula.eval_mu_eq_lfp, MuFormula.eval_mu_eq_lfp] congr 1 apply OrderHom.ext funext X apply ih intro y hy by_cases hyx : y = x · subst hyx; simp · simp only [Function.update_of_ne hyx] exact h y (Finset.mem_erase.mpr ⟨hyx, hy⟩) | nu x φ ih => intro ρ₁ ρ₂ h rw [MuFormula.eval_nu_eq_gfp, MuFormula.eval_nu_eq_gfp] congr 1 apply OrderHom.ext funext X apply ih intro y hy by_cases hyx : y = x · subst hyx; simp · simp only [Function.update_of_ne hyx] exact h y (Finset.mem_erase.mpr ⟨hyx, hy⟩) lemma eval_closed_env_indep {S A P : Type*} (M : LTS S A P) {φ : MuFormula A P} (hcl : φ.IsClosed) (ρ₁ ρ₂ : ℕ → Set S) : φ.eval M ρ₁ = φ.eval M ρ₂ := eval_congr_freeVars M φ (fun x hx => by rw [hcl] at hx; cases hx) /-! ### Exact Complement Duality & Negation Normal Form -/ lemma lfp_compl_eq_gfp {S : Type*} (F G : Set S →o Set S) (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 have hle := OrderHom.lfp_le F hpre exact Set.compl_subset_compl.mp (by rwa [compl_compl]) lemma gfp_compl_eq_lfp {S : Type*} (F G : Set S →o Set S) (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] have h := lfp_compl_eq_gfp G F hdual' rw [← h, compl_compl] lemma update_compl {S : Type*} (ρ : ℕ → Set S) (x : ℕ) (X : Set S) : Function.update (fun y => (ρ y)ᶜ) x Xᶜ = fun y => (Function.update ρ x X y)ᶜ := by funext y by_cases hy : y = x · subst hy; simp · simp [hy] /-- **Exact Modal μ-Calculus Complement Duality:** Complementation commutes with `MuFormula.dual` on every LTS and environment: `⟦φ.dual⟧_{ρᶜ} = (⟦φ⟧_ρ)ᶜ`, and in particular `¬ μ X. φ(X) = ν X. ¬φ(¬X)`. -/ theorem mu_calculus_complement_duality {S A P : Type*} (M : LTS S A P) (φ : MuFormula A P) : ∀ ρ : ℕ → Set S, φ.dual.eval M (fun y => (ρ y)ᶜ) = (φ.eval M ρ)ᶜ := by induction φ with | tt => intro _; simp [MuFormula.dual, MuFormula.eval, MuFormula.evalHom] | ff => intro _; simp [MuFormula.dual, MuFormula.eval, MuFormula.evalHom] | atom p => intro _; ext s; simp [MuFormula.dual, MuFormula.eval, MuFormula.evalHom] | negAtom p => intro _; ext s; simp [MuFormula.dual, MuFormula.eval, MuFormula.evalHom] | var x => intro _; rfl | and φ ψ ih₁ ih₂ => intro ρ change φ.dual.eval M _ ∪ ψ.dual.eval M _ = (φ.eval M ρ ∩ ψ.eval M ρ)ᶜ rw [ih₁ ρ, ih₂ ρ, Set.compl_inter] | or φ ψ ih₁ ih₂ => intro ρ change φ.dual.eval M _ ∩ ψ.dual.eval M _ = (φ.eval M ρ ∪ ψ.eval M ρ)ᶜ rw [ih₁ ρ, ih₂ ρ, Set.compl_union] | dia a φ ih => intro ρ change boxOp M a (φ.dual.eval M _) = (diaOp M a (φ.eval M ρ))ᶜ rw [ih ρ, diaOp_compl] | box a φ ih => intro ρ change diaOp M a (φ.dual.eval M _) = (boxOp M a (φ.eval M ρ))ᶜ rw [ih ρ, boxOp_compl] | mu x φ ih => intro ρ change OrderHom.gfp (φ.dual.stepOp M (fun y => (ρ y)ᶜ) x) = (OrderHom.lfp (φ.stepOp M ρ x))ᶜ symm apply lfp_compl_eq_gfp intro X change φ.dual.eval M (Function.update (fun y => (ρ y)ᶜ) x Xᶜ) = (φ.eval M (Function.update ρ x X))ᶜ rw [update_compl, ih] | nu x φ ih => intro ρ change OrderHom.lfp (φ.dual.stepOp M (fun y => (ρ y)ᶜ) x) = (OrderHom.gfp (φ.stepOp M ρ x))ᶜ symm apply gfp_compl_eq_lfp intro X change φ.dual.eval M (Function.update (fun y => (ρ y)ᶜ) x Xᶜ) = (φ.eval M (Function.update ρ x X))ᶜ rw [update_compl, ih] /-- General modal μ-calculus syntax with explicit negation `neg`. -/ inductive RawMu (A P : Type*) : Type _ | tt : RawMu A P | atom (p : P) : RawMu A P | var (x : ℕ) : RawMu A P | neg (φ : RawMu A P) : RawMu A P | and (φ ψ : RawMu A P) : RawMu A P | dia (a : A) (φ : RawMu A P) : RawMu A P | mu (x : ℕ) (φ : RawMu A P) : RawMu A P /-- Polarity occurrence predicate: `OccursWithPol pol x φ` means `x` occurs free in `φ` under `pol` parity of negations (`true` = even/positive, `false` = odd/negative). -/ def RawMu.OccursWithPol {A P : Type*} : Bool → ℕ → RawMu A P → Prop | _, _, .tt => False | _, _, .atom _ => False | pol, x, .var y => y = x ∧ pol = true | pol, x, .neg φ => φ.OccursWithPol (!pol) x | pol, x, .and φ ψ => φ.OccursWithPol pol x ∨ ψ.OccursWithPol pol x | pol, x, .dia _ φ => φ.OccursWithPol pol x | pol, x, .mu y φ => y ≠ x ∧ φ.OccursWithPol pol x /-- Syntactic positivity / well-formedness: every bound variable `μ x. φ` occurs only positively in `φ`. -/ def RawMu.WellFormed {A P : Type*} : RawMu A P → Prop | .tt | .atom _ | .var _ => True | .neg φ | .dia _ φ => φ.WellFormed | .and φ ψ => φ.WellFormed ∧ ψ.WellFormed | .mu x φ => φ.WellFormed ∧ ¬ φ.OccursWithPol false x /-- Negation Normal Form translation of `RawMu` into `MuFormula` with polarity flag `pos`. -/ def RawMu.toPNF {A P : Type*} : Bool → RawMu A P → MuFormula A P | true, .tt => .tt | false, .tt => .ff | true, .atom p => .atom p | false, .atom p => .negAtom p | _, .var x => .var x | pos, .neg φ => φ.toPNF (!pos) | true, .and φ ψ => .and (φ.toPNF true) (ψ.toPNF true) | false, .and φ ψ => .or (φ.toPNF false) (ψ.toPNF false) | true, .dia a φ => .dia a (φ.toPNF true) | false, .dia a φ => .box a (φ.toPNF false) | true, .mu x φ => .mu x (φ.toPNF true) | false, .mu x φ => .nu x (φ.toPNF false) lemma RawMu.toPNF_false_eq_dual {A P : Type*} (φ : RawMu A P) : φ.toPNF false = (φ.toPNF true).dual := by induction φ with | tt => rfl | atom _ => rfl | var _ => rfl | neg φ ih => simp only [RawMu.toPNF, Bool.not_false, Bool.not_true] rw [ih, MuFormula.dual_involutive] | and φ ψ ih₁ ih₂ => simp [RawMu.toPNF, MuFormula.dual, ih₁, ih₂] | dia a φ ih => simp [RawMu.toPNF, MuFormula.dual, ih] | mu x φ ih => simp [RawMu.toPNF, MuFormula.dual, ih] /-- **Negation Normal Form Duality for `RawMu`:** Translating `.neg φ` to PNF yields the exact semantic complement of translating `φ` (under complemented free-variable environment). -/ theorem raw_mu_nnf_duality {S A P : Type*} (M : LTS S A P) (φ : RawMu A P) (ρ : ℕ → Set S) : ((RawMu.neg φ).toPNF true).eval M (fun y => (ρ y)ᶜ) = ((φ.toPNF true).eval M ρ)ᶜ := by simp only [RawMu.toPNF, Bool.not_true, RawMu.toPNF_false_eq_dual] exact mu_calculus_complement_duality M (φ.toPNF true) ρ /-! ## Section 2: Exact Embedding of CTL into Closed Modal μ-Calculus -/ /-- Standalone CTL syntax over atomic propositions `P` for the μ-calculus embedding. -/ inductive CTL (P : Type*) : Type _ | tt : CTL P | atom (p : P) : CTL P | neg (φ : CTL P) : CTL P | and (φ ψ : CTL P) : CTL P | EX (φ : CTL P) : CTL P | EU (φ ψ : CTL P) : CTL P | AU (φ ψ : CTL P) : CTL P def CTL.AX {P : Type*} (φ : CTL P) : CTL P := .neg (.EX (.neg φ)) def CTL.EF {P : Type*} (φ : CTL P) : CTL P := .EU .tt φ def CTL.AF {P : Type*} (φ : CTL P) : CTL P := .AU .tt φ def CTL.EG {P : Type*} (φ : CTL P) : CTL P := .neg (CTL.AF (.neg φ)) def CTL.AG {P : Type*} (φ : CTL P) : CTL P := .neg (CTL.EF (.neg φ)) /-- Serial single-action LTS (Kripke structure). -/ def IsSerial {S P : Type*} (M : LTS S Unit P) : Prop := ∀ s, ∃ t, M.step s () t def IsPath {S P : Type*} (M : LTS S Unit P) (π : ℕ → S) : Prop := ∀ n, M.step (π n) () (π (n + 1)) lemma exists_path_from {S P : Type*} {M : LTS S Unit P} (hSer : IsSerial M) (s : S) : ∃ π, IsPath M π ∧ π 0 = s := by choose next hnext using hSer refine ⟨fun n => next^[n] s, ?_, rfl⟩ intro n show M.step (next^[n] s) () (next^[n + 1] s) rw [Function.iterate_succ_apply'] exact hnext _ def CTL.Sat {S P : Type*} (M : LTS S Unit P) : S → CTL P → Prop | _, .tt => True | s, .atom p => M.val s p | s, .neg φ => ¬ CTL.Sat M s φ | s, .and φ ψ => CTL.Sat M s φ ∧ CTL.Sat M s ψ | s, .EX φ => ∃ t, M.step s () t ∧ CTL.Sat M t φ | s, .EU φ ψ => ∃ π, IsPath M π ∧ π 0 = s ∧ ∃ i, CTL.Sat M (π i) ψ ∧ ∀ j < i, CTL.Sat M (π j) φ | s, .AU φ ψ => ∀ π, IsPath M π → π 0 = s → ∃ i, CTL.Sat M (π i) ψ ∧ ∀ j < i, CTL.Sat M (π j) φ /-- Embedding of CTL into closed Positive-Normal-Form Modal μ-Calculus (using variable `0`). -/ def ctlToMu {P : Type*} : CTL P → MuFormula Unit P | .tt => .tt | .atom p => .atom p | .neg φ => (ctlToMu φ).dual | .and φ ψ => .and (ctlToMu φ) (ctlToMu ψ) | .EX φ => .dia () (ctlToMu φ) | .EU φ ψ => .mu 0 (.or (ctlToMu ψ) (.and (ctlToMu φ) (.dia () (.var 0)))) | .AU φ ψ => .mu 0 (.or (ctlToMu ψ) (.and (ctlToMu φ) (.box () (.var 0)))) lemma ctlToMu_closed {P : Type*} (φ : CTL P) : (ctlToMu φ).IsClosed := by induction φ with | tt | atom _ => rfl | neg φ ih => unfold MuFormula.IsClosed at ih ⊢ simp [ctlToMu, MuFormula.freeVars_dual, ih] | and φ ψ ih₁ ih₂ => unfold MuFormula.IsClosed at ih₁ ih₂ ⊢ simp [ctlToMu, MuFormula.freeVars, ih₁, ih₂] | EX φ ih => unfold MuFormula.IsClosed at ih ⊢ simp [ctlToMu, MuFormula.freeVars, ih] | EU φ ψ ih₁ ih₂ => unfold MuFormula.IsClosed at ih₁ ih₂ ⊢ simp [ctlToMu, MuFormula.freeVars, ih₁, ih₂] | AU φ ψ ih₁ ih₂ => unfold MuFormula.IsClosed at ih₁ ih₂ ⊢ simp [ctlToMu, MuFormula.freeVars, ih₁, ih₂] /-- **Exact Embedding of CTL into Closed Modal μ-Calculus:** For every CTL formula `φ` (including `EX`, `AX`, `EF`, `AF`, `EG`, `AG`, `EU`, `AU`), `ctlToMu φ` is a closed μ-calculus formula whose Knaster–Tarski denotation on any serial Kripke structure equals `{s | CTL.Sat M s φ}`. -/ theorem ctl_to_mu_embedding {S P : Type*} {M : LTS S Unit P} (hSer : IsSerial M) (φ : CTL P) (ρ : ℕ → Set S) : (ctlToMu φ).eval M ρ = {s | CTL.Sat M s φ} := by induction φ generalizing ρ with | tt => ext s; simp [ctlToMu, MuFormula.eval, MuFormula.evalHom, CTL.Sat] | atom p => ext s; simp [ctlToMu, MuFormula.eval, MuFormula.evalHom, CTL.Sat] | neg φ ih => change (ctlToMu φ).dual.eval M ρ = {s | ¬ CTL.Sat M s φ} have hcl := ctlToMu_closed φ have heq : (ctlToMu φ).dual.eval M ρ = (ctlToMu φ).dual.eval M (fun y => (ρ y)ᶜ) := eval_closed_env_indep M (by unfold MuFormula.IsClosed; rw [MuFormula.freeVars_dual]; exact hcl) _ _ rw [heq, mu_calculus_complement_duality, ih ρ] rfl | and φ ψ ih₁ ih₂ => change (ctlToMu φ).eval M ρ ∩ (ctlToMu ψ).eval M ρ = {s | CTL.Sat M s φ ∧ CTL.Sat M s ψ} rw [ih₁ ρ, ih₂ ρ]; rfl | EX φ ih => change diaOp M () ((ctlToMu φ).eval M ρ) = {s | ∃ t, M.step s () t ∧ CTL.Sat M t φ} rw [ih ρ]; rfl | EU φ ψ ih₁ ih₂ => let F := (MuFormula.or (ctlToMu ψ) (.and (ctlToMu φ) (.dia () (.var 0)))).stepOp M ρ 0 change OrderHom.lfp F = {s | CTL.Sat M s (.EU φ ψ)} have hF : ∀ X, F X = {s | CTL.Sat M s ψ} ∪ ({s | CTL.Sat M s φ} ∩ diaOp M () X) := by intro X change (ctlToMu ψ).eval M (Function.update ρ 0 X) ∪ ((ctlToMu φ).eval M (Function.update ρ 0 X) ∩ diaOp M () X) = _ rw [ih₁, ih₂] ext s constructor · intro hs have hpre : F {x | CTL.Sat M x (.EU φ ψ)} ⊆ {x | CTL.Sat M x (.EU φ ψ)} := by rw [hF] intro x hx rcases hx with hψ | ⟨hφ, t, hxt, ⟨π, hπ, h0, i, hi, hj⟩⟩ · rcases exists_path_from hSer x with ⟨π, hπ, h0⟩ exact ⟨π, hπ, h0, 0, by rwa [h0], fun j hj => by omega⟩ · let π' : ℕ → S := fun n => match n with | 0 => x | k + 1 => π k refine ⟨π', ?_, rfl, i + 1, hi, ?_⟩ · intro n; cases n with | zero => simpa [π', h0] using hxt | succ k => exact hπ k · intro j hji; cases j with | zero => exact hφ | succ k => exact hj k (Nat.lt_of_succ_lt_succ hji) exact OrderHom.lfp_le F hpre hs · rintro ⟨π, hπ, rfl, i, hi, hj⟩ induction i generalizing π with | zero => rw [← OrderHom.map_lfp, hF] exact Or.inl hi | succ i ih_i => have htail : π 1 ∈ OrderHom.lfp F := ih_i (fun n => π (n + 1)) (fun n => hπ (n + 1)) hi (fun j hji => hj (j + 1) (Nat.succ_lt_succ hji)) rw [← OrderHom.map_lfp, hF] exact Or.inr ⟨hj 0 (Nat.zero_lt_succ i), π 1, hπ 0, htail⟩ | AU φ ψ ih₁ ih₂ => let F := (MuFormula.or (ctlToMu ψ) (.and (ctlToMu φ) (.box () (.var 0)))).stepOp M ρ 0 change OrderHom.lfp F = {s | CTL.Sat M s (.AU φ ψ)} have hF : ∀ X, F X = {s | CTL.Sat M s ψ} ∪ ({s | CTL.Sat M s φ} ∩ boxOp M () X) := by intro X change (ctlToMu ψ).eval M (Function.update ρ 0 X) ∪ ((ctlToMu φ).eval M (Function.update ρ 0 X) ∩ boxOp M () X) = _ rw [ih₁, ih₂] ext s constructor · intro hs have hpre : F {x | CTL.Sat M x (.AU φ ψ)} ⊆ {x | CTL.Sat M x (.AU φ ψ)} := by rw [hF] intro x hx π hπ h0 rcases hx with hψ | ⟨hφ, hall⟩ · exact ⟨0, by rwa [h0], fun j hj => by omega⟩ · have h1 : M.step x () (π 1) := by simpa [h0] using hπ 0 rcases hall (π 1) h1 (fun n => π (n + 1)) (fun n => hπ (n + 1)) rfl with ⟨i, hi, hj⟩ refine ⟨i + 1, hi, ?_⟩ intro j hji cases j with | zero => rwa [h0] | succ k => exact hj k (Nat.lt_of_succ_lt_succ hji) exact OrderHom.lfp_le F hpre hs · intro hau by_contra hs_not let Z := OrderHom.lfp F have hstep : ∀ x, x ∉ Z → ¬ CTL.Sat M x ψ ∧ (CTL.Sat M x φ → ∃ y, M.step x () y ∧ y ∉ Z) := by intro x hx have hx' : x ∉ F Z := by rwa [OrderHom.map_lfp] rw [hF] at hx' refine ⟨fun hψ => hx' (Or.inl hψ), fun hφ => ?_⟩ by_contra hno; push Not at hno exact hx' (Or.inr ⟨hφ, hno⟩) classical choose defNext hdefNext using hSer let nextState : S → S := fun x => if h : x ∉ Z ∧ CTL.Sat M x φ then Classical.choose ((hstep x h.1).2 h.2) else defNext x have hnext_step : ∀ x, M.step x () (nextState x) := by intro x; dsimp only [nextState]; split_ifs with h · exact (Classical.choose_spec ((hstep x h.1).2 h.2)).1 · exact hdefNext x let π : ℕ → S := fun n => nextState^[n] s have hπ : IsPath M π := fun n => by show M.step (nextState^[n] s) () (nextState^[n + 1] s) rw [Function.iterate_succ_apply']; exact hnext_step _ rcases hau π hπ rfl with ⟨i, hi, hj⟩ have hinv : ∀ k ≤ i, π k ∉ Z := by intro k hk induction k with | zero => exact hs_not | succ k ihk => have hk_lt : k < i := Nat.lt_of_succ_le hk have hkz := ihk (Nat.le_of_lt hk_lt) have hkφ := hj k hk_lt show nextState^[k + 1] s ∉ Z rw [Function.iterate_succ_apply']; dsimp only [nextState] rw [dif_pos ⟨hkz, hkφ⟩] exact (Classical.choose_spec ((hstep (π k) hkz).2 hkφ)).2 exact (hstep (π i) (hinv i le_rfl)).1 hi /-! ## Section 3: Finite-State Kleene Iteration Convergence & Exact `n`-Step Sharpness -/ lemma iterate_mono_bot {S : Type*} (F : Set S →o Set S) : ∀ k, F^[k] ∅ ⊆ F^[k + 1] ∅ := by intro k induction k with | zero => exact Set.empty_subset _ | succ k ih => rw [Function.iterate_succ_apply', Function.iterate_succ_apply'] exact F.monotone ih lemma iterate_le_lfp {S : Type*} (F : Set S →o Set S) : ∀ k, F^[k] ∅ ⊆ OrderHom.lfp F := by intro k induction k with | zero => exact Set.empty_subset _ | succ k ih => rw [Function.iterate_succ_apply', ← OrderHom.map_lfp] exact F.monotone ih lemma iterate_mono_top {S : Type*} (F : Set S →o Set S) : ∀ k, F^[k + 1] Set.univ ⊆ F^[k] Set.univ := by intro k induction k with | zero => exact Set.subset_univ _ | succ k ih => rw [Function.iterate_succ_apply' (f := F) (k + 1)] nth_rw 2 [Function.iterate_succ_apply' (f := F) k] exact F.monotone ih lemma gfp_le_iterate {S : Type*} (F : Set S →o Set S) : ∀ k, OrderHom.gfp F ⊆ F^[k] Set.univ := by intro k induction k with | zero => exact Set.subset_univ _ | succ k ih => rw [Function.iterate_succ_apply' (f := F) k, ← OrderHom.map_gfp] exact F.monotone ih lemma iterate_stabilizes_of_eq {S : Type*} (F : Set S →o Set S) (X : Set S) {k : ℕ} (heq : F^[k + 1] X = F^[k] X) : ∀ m ≥ k, F^[m] X = F^[k] X := 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, Function.iterate_succ_apply' (f := F), ih (by omega), ← Function.iterate_succ_apply' (f := F), heq] /-- **Finite-State Kleene Iteration Convergence (Least Fixpoint):** On any finite state space `S` of cardinality `n = Fintype.card S`, every monotone operator `F : Set S →o Set S` reaches `OrderHom.lfp F` in at most `n` iterations from `∅`. -/ theorem lfp_eq_iterate_card {S : Type*} [Fintype S] (F : Set S →o Set S) : OrderHom.lfp F = F^[Fintype.card S] ∅ := by classical let n := Fintype.card S have hex : ∃ k ≤ n, F^[k + 1] ∅ = F^[k] ∅ := by by_contra hno push Not at hno have hcard : ∀ k ≤ n + 1, k ≤ (F^[k] ∅).toFinset.card := by intro k hk induction k with | zero => exact Nat.zero_le _ | succ k ih => have hsub : (F^[k] ∅).toFinset ⊆ (F^[k + 1] ∅).toFinset := by intro x hx; rw [Set.mem_toFinset] at hx ⊢; exact iterate_mono_bot F k hx have hssub : (F^[k] ∅).toFinset ⊂ (F^[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 rw [Set.mem_toFinset, Set.mem_toFinset] at h exact h.symm have hlt := Finset.card_lt_card hssub have ih' := ih (by omega) omega have h1 := hcard (n + 1) le_rfl have h2 : (F^[n + 1] ∅).toFinset.card ≤ n := Finset.card_le_univ _ omega rcases hex with ⟨k, hkn, heq⟩ have hfix : F (F^[n] ∅) = F^[n] ∅ := by rw [← Function.iterate_succ_apply' (f := F), iterate_stabilizes_of_eq F ∅ heq (n + 1) (by omega), iterate_stabilizes_of_eq F ∅ heq n hkn] apply le_antisymm · exact OrderHom.lfp_le F (le_of_eq hfix) · exact iterate_le_lfp F n /-- **Finite-State Kleene Iteration Convergence (Greatest Fixpoint):** On any finite state space `S` of cardinality `n = Fintype.card S`, every monotone operator `F : Set S →o Set S` reaches `OrderHom.gfp F` in at most `n` iterations from `Set.univ`. -/ theorem gfp_eq_iterate_card {S : Type*} [Fintype S] (F : Set S →o Set S) : OrderHom.gfp F = F^[Fintype.card S] Set.univ := by classical let n := Fintype.card S have hex : ∃ k ≤ n, F^[k + 1] Set.univ = F^[k] Set.univ := by by_contra hno push Not at hno have hcard : ∀ k ≤ n + 1, (F^[k] Set.univ).toFinset.card + k ≤ n := by intro k hk induction k with | zero => exact Finset.card_le_univ _ | succ k ih => have hsub : (F^[k + 1] Set.univ).toFinset ⊆ (F^[k] Set.univ).toFinset := by intro x hx; rw [Set.mem_toFinset] at hx ⊢; exact iterate_mono_top F k hx have hssub : (F^[k + 1] Set.univ).toFinset ⊂ (F^[k] Set.univ).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 rw [Set.mem_toFinset, Set.mem_toFinset] at h exact h have hlt := Finset.card_lt_card hssub have ih' := ih (by omega) omega have h1 := hcard (n + 1) le_rfl omega rcases hex with ⟨k, hkn, heq⟩ have hfix : F (F^[n] Set.univ) = F^[n] Set.univ := by rw [← Function.iterate_succ_apply' (f := F), iterate_stabilizes_of_eq F Set.univ heq (n + 1) (by omega), iterate_stabilizes_of_eq F Set.univ heq n hkn] apply le_antisymm · exact gfp_le_iterate F n · exact OrderHom.le_gfp F (le_of_eq hfix.symm) /-- **Finite-State Kleene Convergence for Modal μ-Calculus Formulas:** On a finite LTS of `n = Fintype.card S` states, `⟦μ x. φ⟧_ρ` and `⟦ν x. φ⟧_ρ` are computed exactly by `n` Kleene iterations from `∅` and `Set.univ` respectively. -/ theorem mu_nu_finite_kleene_convergence {S A P : Type*} [Fintype S] (M : LTS S A P) (ρ : ℕ → Set S) (x : ℕ) (φ : MuFormula A P) : ((MuFormula.mu x φ).eval M ρ = (φ.stepOp M ρ x)^[Fintype.card S] ∅) ∧ ((MuFormula.nu x φ).eval M ρ = (φ.stepOp M ρ x)^[Fintype.card S] Set.univ) := ⟨lfp_eq_iterate_card (φ.stepOp M ρ x), gfp_eq_iterate_card (φ.stepOp M ρ x)⟩ /-! ### Exact `n`-Step Sharpness Witness (`chainLTS n`) -/ /-- The `n`-state chain LTS on `Fin n` (`i → i + 1`, with self-loop at `n - 1`), with atomic proposition `()` holding exclusively at the final state `n - 1`. -/ def chainLTS (n : ℕ) : LTS (Fin n) Unit Unit where step i _ j := j.val = min (i.val + 1) (n - 1) val i _ := i.val = n - 1 /-- Formula `μ X_0. (p ∨ ⟨⟩ X_0)` (`EF p`). -/ def muReachP : MuFormula Unit Unit := .mu 0 (.or (.atom ()) (.dia () (.var 0))) /-- Formula `ν X_0. (¬p ∧ [] X_0)` (`AG ¬p`). -/ def nuAvoidP : MuFormula Unit Unit := .nu 0 (.and (.negAtom ()) (.box () (.var 0))) lemma chain_mu_iterate {n : ℕ} (hn : 1 ≤ n) (ρ : ℕ → Set (Fin n)) : ∀ k ≤ n, ((MuFormula.or (.atom ()) (.dia () (.var 0))).stepOp (chainLTS n) ρ 0)^[k] ∅ = {i : Fin n | n - k ≤ i.val} := by intro k hk induction k with | zero => ext i; simp only [Function.iterate_zero_apply, Set.mem_empty_iff_false, Set.mem_ofPred_eq, Nat.sub_zero, false_iff, not_le] exact i.isLt | succ k ih => rw [Function.iterate_succ_apply', ih (by omega)] ext i have hi_lt : i.val < n := i.isLt change i.val = n - 1 ∨ (∃ j : Fin n, j.val = min (i.val + 1) (n - 1) ∧ n - k ≤ j.val) ↔ n - (k + 1) ≤ i.val constructor · rintro (hlast | ⟨j, hstep, hj⟩) · omega · omega · intro hi by_cases hlast : i.val = n - 1 · exact Or.inl hlast · right refine ⟨⟨i.val + 1, by omega⟩, by dsimp only; omega, by dsimp only; omega⟩ lemma chain_nu_iterate {n : ℕ} (hn : 1 ≤ n) (ρ : ℕ → Set (Fin n)) : ∀ k ≤ n, ((MuFormula.and (.negAtom ()) (.box () (.var 0))).stepOp (chainLTS n) ρ 0)^[k] Set.univ = {i : Fin n | i.val < n - k} := by intro k hk induction k with | zero => ext i; simp only [Function.iterate_zero_apply, Set.mem_univ, Set.mem_ofPred_eq, Nat.sub_zero, true_iff] exact i.isLt | succ k ih => rw [Function.iterate_succ_apply', ih (by omega)] ext i have hi_lt : i.val < n := i.isLt change (i.val ≠ n - 1 ∧ ∀ j : Fin n, j.val = min (i.val + 1) (n - 1) → j.val < n - k) ↔ i.val < n - (k + 1) constructor · rintro ⟨hnotlast, hall⟩ have hsucc := hall ⟨i.val + 1, by omega⟩ (by dsimp only; omega) dsimp only at hsucc omega · intro hi refine ⟨by omega, fun j hstep => ?_⟩ omega /-- **Exact `n`-Step Sharpness of Finite-State Kleene Iteration:** For EVERY `n ≥ 1`, on the `n`-state chain `chainLTS n`: - `μ X. (p ∨ ⟨⟩ X)` has `F^[n - 1] ∅ ≠ lfp F` (missing state `0`) and `F^[n] ∅ = lfp F = Set.univ`; - `ν X. (¬p ∧ [] X)` has `G^[n - 1] Set.univ ≠ gfp G` (containing state `0`) and `G^[n] Set.univ = gfp G = ∅`. -/ theorem kleene_exact_n_steps_sharp (n : ℕ) (hn : 1 ≤ n) (ρ : ℕ → Set (Fin n)) : let F := (MuFormula.or (.atom ()) (.dia () (.var 0))).stepOp (chainLTS n) ρ 0 let G := (MuFormula.and (.negAtom ()) (.box () (.var 0))).stepOp (chainLTS n) ρ 0 (F^[n - 1] ∅ ≠ muReachP.eval (chainLTS n) ρ ∧ F^[n] ∅ = muReachP.eval (chainLTS n) ρ ∧ muReachP.eval (chainLTS n) ρ = Set.univ) ∧ (G^[n - 1] Set.univ ≠ nuAvoidP.eval (chainLTS n) ρ ∧ G^[n] Set.univ = nuAvoidP.eval (chainLTS n) ρ ∧ nuAvoidP.eval (chainLTS n) ρ = ∅) := by intro F G have hFn : F^[n] ∅ = muReachP.eval (chainLTS n) ρ := by have h := (mu_nu_finite_kleene_convergence (chainLTS n) ρ 0 (.or (.atom ()) (.dia () (.var 0)))).1 simpa [muReachP, F, Fintype.card_fin] using h.symm have hGn : G^[n] Set.univ = nuAvoidP.eval (chainLTS n) ρ := by have h := (mu_nu_finite_kleene_convergence (chainLTS n) ρ 0 (.and (.negAtom ()) (.box () (.var 0)))).2 simpa [nuAvoidP, G, Fintype.card_fin] using h.symm have hF_univ : muReachP.eval (chainLTS n) ρ = Set.univ := by rw [← hFn, chain_mu_iterate hn ρ n le_rfl] ext i; simp have hG_empty : nuAvoidP.eval (chainLTS n) ρ = ∅ := by rw [← hGn, chain_nu_iterate hn ρ n le_rfl] ext i; simp refine ⟨⟨?_, hFn, hF_univ⟩, ⟨?_, hGn, hG_empty⟩⟩ · intro heq rw [chain_mu_iterate hn ρ (n - 1) (Nat.sub_le n 1), hF_univ] at heq have h0 : (⟨0, hn⟩ : Fin n) ∈ ({i : Fin n | n - (n - 1) ≤ i.val} : Set (Fin n)) := by rw [heq]; trivial simp only [Set.mem_ofPred_eq] at h0 omega · intro heq rw [chain_nu_iterate hn ρ (n - 1) (Nat.sub_le n 1), hG_empty] at heq have h0 : (⟨0, hn⟩ : Fin n) ∈ ({i : Fin n | i.val < n - (n - 1)} : Set (Fin n)) := by simp only [Set.mem_ofPred_eq]; omega rw [heq] at h0 exact h0 /-! ## Section 4: Full Modal μ-Calculus Bisimulation Invariance (Arbitrary LTSs) -/ /-- Directional (one-sided) bisimulation invariance of Positive-Normal-Form μ-calculus: works on arbitrary (possibly infinite-state, infinitely branching) LTSs with zero ordinals! -/ lemma isCrossBisim_eval_mono {S₁ S₂ A P : Type*} {M₁ : LTS S₁ A P} {M₂ : LTS S₂ A P} {R : S₁ → S₂ → Prop} (hR : IsCrossBisim M₁ M₂ R) (φ : MuFormula A P) : ∀ {ρ₁ : ℕ → Set S₁} {ρ₂ : ℕ → Set S₂}, (∀ x s₁ s₂, R s₁ s₂ → s₁ ∈ ρ₁ x → s₂ ∈ ρ₂ x) → ∀ s₁ s₂, R s₁ s₂ → s₁ ∈ φ.eval M₁ ρ₁ → s₂ ∈ φ.eval M₂ ρ₂ := by induction φ with | tt => intro _ _ _ _ _ _ _; trivial | ff => intro _ _ _ _ _ _ h; exact h | atom p => intro _ _ _ s₁ s₂ hr hs₁; exact ((hR s₁ s₂ hr).1 p).mp hs₁ | negAtom p => intro _ _ _ s₁ s₂ hr hs₁; exact mt ((hR s₁ s₂ hr).1 p).mpr hs₁ | var x => intro ρ₁ ρ₂ hρ s₁ s₂ hr hs₁; exact hρ x s₁ s₂ hr hs₁ | and φ ψ ih₁ ih₂ => intro ρ₁ ρ₂ hρ s₁ s₂ hr ⟨h₁, h₂⟩ exact ⟨ih₁ hρ s₁ s₂ hr h₁, ih₂ hρ s₁ s₂ hr h₂⟩ | or φ ψ ih₁ ih₂ => intro ρ₁ ρ₂ hρ s₁ s₂ hr h rcases h with h₁ | h₂ · exact Or.inl (ih₁ hρ s₁ s₂ hr h₁) · exact Or.inr (ih₂ hρ s₁ s₂ hr h₂) | dia a φ ih => intro ρ₁ ρ₂ hρ s₁ s₂ hr ⟨s₁', hs₁', hsat⟩ rcases (hR s₁ s₂ hr).2.1 a s₁' hs₁' with ⟨s₂', hs₂', hr'⟩ exact ⟨s₂', hs₂', ih hρ s₁' s₂' hr' hsat⟩ | box a φ ih => intro ρ₁ ρ₂ hρ s₁ s₂ hr hbox s₂' hs₂' rcases (hR s₁ s₂ hr).2.2 a s₂' hs₂' with ⟨s₁', hs₁', hr'⟩ exact ih hρ s₁' s₂' hr' (hbox s₁' hs₁') | mu x φ ih => intro ρ₁ ρ₂ hρ s₁ s₂ hr hs₁ let Z₂ := OrderHom.lfp (φ.stepOp M₂ ρ₂ x) let T₁ : Set S₁ := {u₁ | ∀ u₂, R u₁ u₂ → u₂ ∈ Z₂} have hpre : φ.stepOp M₁ ρ₁ x T₁ ⊆ T₁ := by intro u₁ hu₁ u₂ hru have hρ' : ∀ y a b, R a b → a ∈ Function.update ρ₁ x T₁ y → b ∈ Function.update ρ₂ x Z₂ y := by intro y a b hrab ha by_cases hy : y = x · subst hy; simp only [Function.update_self] at ha ⊢; exact ha b hrab · simp only [Function.update_of_ne hy] at ha ⊢; exact hρ y a b hrab ha have hu₂ : u₂ ∈ φ.stepOp M₂ ρ₂ x Z₂ := ih hρ' u₁ u₂ hru hu₁ rwa [OrderHom.map_lfp (φ.stepOp M₂ ρ₂ x)] at hu₂ exact OrderHom.lfp_le (φ.stepOp M₁ ρ₁ x) hpre hs₁ s₂ hr | nu x φ ih => intro ρ₁ ρ₂ hρ s₁ s₂ hr hs₁ let Z₁ := OrderHom.gfp (φ.stepOp M₁ ρ₁ x) let T₂ : Set S₂ := {u₂ | ∃ u₁, R u₁ u₂ ∧ u₁ ∈ Z₁} have hpost : T₂ ⊆ φ.stepOp M₂ ρ₂ x T₂ := by rintro u₂ ⟨u₁, hru, hu₁⟩ have hu₁' : u₁ ∈ φ.stepOp M₁ ρ₁ x Z₁ := by rwa [OrderHom.map_gfp (φ.stepOp M₁ ρ₁ x)] have hρ' : ∀ y a b, R a b → a ∈ Function.update ρ₁ x Z₁ y → b ∈ Function.update ρ₂ x T₂ y := by intro y a b hrab ha by_cases hy : y = x · subst hy; simp only [Function.update_self] at ha ⊢; exact ⟨a, hrab, ha⟩ · simp only [Function.update_of_ne hy] at ha ⊢; exact hρ y a b hrab ha exact ih hρ' u₁ u₂ hru hu₁' exact OrderHom.le_gfp (φ.stepOp M₂ ρ₂ x) hpost ⟨s₁, hr, hs₁⟩ lemma isCrossBisim_symm {S₁ S₂ A P : Type*} {M₁ : LTS S₁ A P} {M₂ : LTS S₂ A P} {R : S₁ → S₂ → Prop} (hR : IsCrossBisim M₁ M₂ R) : IsCrossBisim M₂ M₁ (fun s₂ s₁ => R s₁ s₂) := by intro s₂ s₁ h rcases hR s₁ s₂ h with ⟨hval, hzig, hzag⟩ exact ⟨fun p => (hval p).symm, fun a s₂' hs₂' => hzag a s₂' hs₂', fun a s₁' hs₁' => hzig a s₁' hs₁'⟩ /-- **Full Modal μ-Calculus Bisimulation Invariance:** On arbitrary (possibly infinite-state) LTSs, cross-bisimilar states satisfy the exact same closed modal μ-calculus formulas (and identical open formulas under any `R`-respecting variable valuations). -/ theorem mu_calculus_bisimulation_invariant {S₁ S₂ A P : Type*} {M₁ : LTS S₁ A P} {M₂ : LTS S₂ A P} {s₁ : S₁} {s₂ : S₂} (hbis : CrossBisimilar M₁ M₂ s₁ s₂) {φ : MuFormula A P} (hcl : φ.IsClosed) (ρ₁ : ℕ → Set S₁) (ρ₂ : ℕ → Set S₂) : s₁ ∈ φ.eval M₁ ρ₁ ↔ s₂ ∈ φ.eval M₂ ρ₂ := by rcases hbis with ⟨R, hR, hr⟩ rw [eval_closed_env_indep M₁ hcl ρ₁ (fun _ => ∅), eval_closed_env_indep M₂ hcl ρ₂ (fun _ => ∅)] constructor · exact isCrossBisim_eval_mono hR φ (fun _ _ _ _ h => False.elim h) s₁ s₂ hr · exact isCrossBisim_eval_mono (isCrossBisim_symm hR) φ (fun _ _ _ _ h => False.elim h) s₂ s₁ hr /-! ## Axiom Audit -/ #print axioms mu_nu_unfold_and_park #print axioms mu_calculus_complement_duality #print axioms raw_mu_nnf_duality #print axioms ctl_to_mu_embedding #print axioms lfp_eq_iterate_card #print axioms gfp_eq_iterate_card #print axioms mu_nu_finite_kleene_convergence #print axioms kleene_exact_n_steps_sharp #print axioms mu_calculus_bisimulation_invariant end ModalMuCalculus