@@ -5,8 +5,11 @@ Authors: Ching-Tsun Chou
55-/
66
77import Cslib.Computability.Automata.DABuchi
8+ import Cslib.Computability.Automata.NABuchiEquiv
9+ import Cslib.Computability.Automata.Sum
810import Cslib.Computability.Languages.ExampleEventuallyZero
911import Cslib.Computability.Languages.RegularLanguage
12+ import Mathlib.Data.Finite.Sigma
1013
1114/-!
1215# ω-Regular languages
@@ -17,14 +20,31 @@ This file defines ω-regular languages and proves some properties of them.
1720open Set Function Filter Cslib.ωSequence Cslib.Automata ωAcceptor
1821open scoped Computability
1922
23+ universe u v
24+
2025namespace Cslib.ωLanguage
2126
22- variable {Symbol : Type * }
27+ variable {Symbol : Type u }
2328
2429/-- An ω-language is ω-regular iff it is accepted by a
2530finite-state nondeterministic Buchi automaton. -/
2631def IsRegular (p : ωLanguage Symbol) :=
27- ∃ State : Type , ∃ _ : Finite State, ∃ na : NA.Buchi State Symbol, language na = p
32+ ∃ (State : Type ) (_ : Finite State) (na : NA.Buchi State Symbol), language na = p
33+
34+ /-- Helper lemma for `isRegular_iff` below. -/
35+ private lemma isRegular_iff.helper. {v'} {Symbol : Type u} {p : ωLanguage Symbol}
36+ (h : ∃ (σ : Type v) (_ : Finite σ) (na : NA.Buchi σ Symbol), language na = p) :
37+ ∃ (σ' : Type v') (_ : Finite σ') (na : NA.Buchi σ' Symbol), language na = p := by
38+ have ⟨σ, _, na, h_na⟩ := h
39+ have ⟨σ', ⟨f⟩⟩ := Small.equiv_small.{v', v} (α := σ)
40+ use σ', Finite.of_equiv σ f, na.reindex f
41+ rwa [NA.Buchi.reindex_language_eq]
42+
43+ /-- The state space of the accepting finite-state nondeterministic Buchi automaton
44+ can in fact be universe-polymorphic. -/
45+ theorem isRegular_iff {p : ωLanguage Symbol} :
46+ p.IsRegular ↔ ∃ (σ : Type v) (_ : Finite σ) (na : NA.Buchi σ Symbol), language na = p :=
47+ ⟨isRegular_iff.helper, isRegular_iff.helper⟩
2848
2949/-- The ω-language accepted by a finite-state deterministic Buchi automaton is ω-regular. -/
3050theorem IsRegular.of_da_buchi {State : Type } [Finite State] (da : DA.Buchi State Symbol) :
@@ -34,8 +54,8 @@ theorem IsRegular.of_da_buchi {State : Type} [Finite State] (da : DA.Buchi State
3454/-- There is an ω-regular language that is not accepted by any deterministic Buchi automaton,
3555where the automaton is not even required to be finite-state. -/
3656theorem IsRegular.not_da_buchi :
37- ∃ Symbol : Type , ∃ p : ωLanguage Symbol, p.IsRegular ∧
38- ¬ ∃ State : Type , ∃ da : DA.Buchi State Symbol, language da = p := by
57+ ∃ ( Symbol : Type ) ( p : ωLanguage Symbol) , p.IsRegular ∧
58+ ¬ ∃ ( State : Type ) ( da : DA.Buchi State Symbol) , language da = p := by
3959 refine ⟨Fin 2 , Example.eventually_zero, ?_, ?_⟩
4060 · use Fin 2 , inferInstance, Example.eventually_zero_na,
4161 Example.eventually_zero_accepted_by_na_buchi
@@ -44,14 +64,59 @@ theorem IsRegular.not_da_buchi :
4464 grind [DA.buchi_eq_finAcc_omegaLim]
4565
4666/-- The ω-limit of a regular language is ω-regular. -/
67+ @[simp]
4768theorem IsRegular.regular_omegaLim {l : Language Symbol}
4869 (h : l.IsRegular) : (l↗ω).IsRegular := by
4970 obtain ⟨State, _, ⟨da, acc⟩, rfl⟩ := Language.IsRegular.iff_cslib_dfa.mp h
5071 grind [IsRegular.of_da_buchi, =_ DA.buchi_eq_finAcc_omegaLim]
5172
73+ /-- The empty language is ω-regular. -/
74+ @[simp]
75+ theorem IsRegular.bot : (⊥ : ωLanguage Symbol).IsRegular := by
76+ let na : NA.Buchi Unit Symbol := {
77+ Tr _ _ _ := False
78+ start := ∅
79+ accept := ∅ }
80+ use Unit, inferInstance, na
81+ ext xs
82+ simp [na]
83+
84+ /-- The union of two ω-regular languages is ω-regular. -/
85+ @[simp]
86+ theorem IsRegular.sup {p1 p2 : ωLanguage Symbol}
87+ (h1 : p1.IsRegular) (h2 : p2.IsRegular) : (p1 ⊔ p2).IsRegular := by
88+ obtain ⟨State1, h_fin1, ⟨na1, acc1⟩, rfl⟩ := h1
89+ obtain ⟨State2, h_fin1, ⟨na2, acc2⟩, rfl⟩ := h2
90+ let State : Fin 2 → Type
91+ | 0 => State1 | 1 => State2
92+ let na : (i : Fin 2 ) → NA (State i) Symbol
93+ | 0 => na1 | 1 => na2
94+ let acc : (i : Fin 2 ) → Set (State i)
95+ | 0 => acc1 | 1 => acc2
96+ have : ∀ i, Finite (State i) := by grind
97+ use (Σ i : Fin 2 , State i), inferInstance, ⟨(NA.iSum na), (⋃ i, Sigma.mk i '' (acc i))⟩
98+ ext xs
99+ simp only [NA.Buchi.iSum_language_eq, mem_sup, mem_language]
100+ rw [mem_iUnion, Fin.exists_fin_two]
101+ grind
102+
103+ /-- The union of any finite number of ω-regular languages is ω-regular. -/
104+ @[simp]
105+ theorem IsRegular.iSup {I : Type *} [Finite I] {s : Set I} {p : I → ωLanguage Symbol}
106+ (h : ∀ i ∈ s, (p i).IsRegular) : (⨆ i ∈ s, p i).IsRegular := by
107+ generalize h_n : s.ncard = n
108+ induction n generalizing s
109+ case zero =>
110+ have := ncard_eq_zero (s := s)
111+ grind [IsRegular.bot, iSup_bot]
112+ case succ n h_ind =>
113+ obtain ⟨i, t, h_i, rfl, rfl⟩ := (ncard_eq_succ (s := s)).mp h_n
114+ rw [iSup_insert]
115+ grind [IsRegular.sup]
116+
52117/-- McNaughton's Theorem. -/
53118proof_wanted IsRegular.iff_da_muller {p : ωLanguage Symbol} :
54119 p.IsRegular ↔
55- ∃ State : Type , ∃ _ : Finite State, ∃ da : DA.Muller State Symbol, language da = p
120+ ∃ ( State : Type ) ( _ : Finite State) ( da : DA.Muller State Symbol) , language da = p
56121
57122end Cslib.ωLanguage
0 commit comments