Skip to content

Commit 7fc2afd

Browse files
authored
chore: rename definitions and theorems about LTS.Execution and LTS.OmegaExecution (#449)
This PR renames `LTS.IsExecution` and `LTS.ωTs` to `LTS.Execution` and `LTS.OmegaExecution`, respectively, and some theorems about them. It also rewrites some related comments. Hopefully the new names are more rational and systematic.
1 parent c76f85f commit 7fc2afd

9 files changed

Lines changed: 115 additions & 101 deletions

File tree

Cslib/Computability/Automata/NA/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ variable {State Symbol : Type*}
4747
/-- Infinite run. -/
4848
structure Run (na : NA State Symbol) (xs : ωSequence Symbol) (ss : ωSequence State) where
4949
start : ss 0 ∈ na.start
50-
trans : na.ωTr ss xs
50+
trans : na.OmegaExecution ss xs
5151

5252
/-- A nondeterministic automaton that accepts finite strings (lists of symbols). -/
5353
structure FinAcc (State Symbol : Type*) extends NA State Symbol where

Cslib/Computability/Automata/NA/Concat.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ theorem concat_run_exists {xs1 : List Symbol} {xs2 : ωSequence Symbol} {ss2 :
9797
∃ ss, (concat na1 na2).Run (xs1 ++ω xs2) ss ∧ ss.drop xs1.length = ss2.map inr := by
9898
by_cases h_xs1 : xs1.length = 0
9999
· obtain ⟨rfl⟩ : xs1 = [] := List.eq_nil_iff_length_eq_zero.mpr h_xs1
100-
refine ⟨ss2.map inr, by simp only [concat]; grind [Run, LTS.ωTr], by simp⟩
100+
refine ⟨ss2.map inr, by simp only [concat]; grind [Run, LTS.OmegaExecution], by simp⟩
101101
· obtain ⟨s0, _, _, _, h_mtr⟩ := h1
102-
obtain ⟨ss1, _, _, _, _⟩ := LTS.mTr_extract_isExecution h_mtr
102+
obtain ⟨ss1, _, _, _, _⟩ := LTS.execution_of_mTr h_mtr
103103
let ss := (ss1.map inl).take xs1.length ++ω ss2.map inr
104104
refine ⟨ss, Run.mk ?_ ?_, ?_⟩
105105
· grind [concat, get_append_left]
106106
· have (k) (h_k : ¬ k < xs1.length) : k + 1 - xs1.length = k - xs1.length + 1 := by grind
107107
simp only [concat]
108-
grind [Run, LTS.ωTr, get_append_right', get_append_left, LTS.IsExecution]
108+
grind [Run, LTS.OmegaExecution, get_append_right', get_append_left, LTS.Execution]
109109
· grind [drop_append_of_le_length]
110110

111111
namespace Buchi
@@ -156,7 +156,7 @@ theorem finConcat_language_eq [Inhabited Symbol] :
156156
ext xl
157157
constructor
158158
· rintro ⟨s, _, t, h_acc, h_mtr⟩
159-
obtain ⟨xs, ss, h_ωtr, rfl, rfl⟩ := LTS.Total.mTr_ωTr h_mtr
159+
obtain ⟨xs, ss, h_ωtr, rfl, rfl⟩ := LTS.Total.mTr_omegaExecution h_mtr
160160
have hc : (finConcat na1 na2).Run (xl ++ω xs) ss := by grind [Run]
161161
have hr : (ss xl.length).isRight := by grind
162162
obtain ⟨n, _⟩ := concat_run_proj hc hr
@@ -173,7 +173,7 @@ theorem finConcat_language_eq [Inhabited Symbol] :
173173
grind [
174174
finConcat, List.length_append, take_append_of_le_length,
175175
extract_eq_drop_take, =_ append_append_ωSequence, get_drop xl2.length xl1.length ss,
176-
LTS.ωTr_mTr h_ωtr (zero_le (xl1.length + xl2.length))
176+
LTS.OmegaExecution.extract_mTr h_ωtr (zero_le (xl1.length + xl2.length))
177177
]
178178

179179
end FinAcc

Cslib/Computability/Automata/NA/Loop.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ theorem loop_fin_run_exists {xl : List Symbol} (h : xl ∈ language na) :
9999
sl[0] = inl () ∧ sl[xl.length] = inl () ∧
100100
∀ k, (_ : k < xl.length) → na.loop.Tr sl[k] xl[k] sl[k + 1] := by
101101
obtain ⟨_, _, _, _, h_mtr⟩ := h
102-
obtain ⟨sl, _, _, _, _⟩ := LTS.mTr_extract_isExecution h_mtr
102+
obtain ⟨sl, _, _, _, _⟩ := LTS.execution_of_mTr h_mtr
103103
by_cases xl.length = 0
104104
· use [inl ()]
105105
grind
@@ -128,7 +128,7 @@ theorem loop_run_exists [Inhabited Symbol] {xls : ωSequence (List Symbol)}
128128
let ts := ωSequence.const (inl () : Unit ⊕ State)
129129
have h_mtr (k : ℕ) : na.loop.MTr (ts k) (xls k) (ts (k + 1)) := by grind [loop_fin_run_mtr]
130130
have h_pos (k : ℕ) : (xls k).length > 0 := by grind
131-
obtain ⟨ss, _, _⟩ := LTS.ωTr.flatten h_mtr h_pos
131+
obtain ⟨ss, _, _⟩ := LTS.OmegaExecution.flatten_mTr h_mtr h_pos
132132
use ss
133133
grind [Run.mk, FinAcc.loop, cumLen_zero (ls := xls)]
134134

@@ -186,7 +186,7 @@ theorem loop_language_eq [Inhabited Symbol] (h : ¬ language na = 0) :
186186
· have : Nonempty na.start := by
187187
obtain ⟨_, s0, _, _⟩ := nonempty_iff_ne_empty.mpr h
188188
use s0
189-
obtain ⟨xs, ss, h_ωtr, rfl, rfl⟩ := LTS.Total.mTr_ωTr h_mtr
189+
obtain ⟨xs, ss, h_ωtr, rfl, rfl⟩ := LTS.Total.mTr_omegaExecution h_mtr
190190
have h_run : na.finLoop.Run (xl ++ω xs) ss := by grind [Run]
191191
obtain ⟨h1, h2⟩ : 0 < xl.length ∧ (ss xl.length).isLeft := by
192192
simp only [mem_singleton_iff] at h_acc
@@ -195,7 +195,7 @@ theorem loop_language_eq [Inhabited Symbol] (h : ¬ language na = 0) :
195195
left; refine ⟨xl.take n, ?_, xl.drop n, ?_, ?_⟩
196196
· grind [totalize_language_eq, take_append_of_le_length]
197197
· refine ⟨ss n, by grind, ss xl.length, by grind, ?_⟩
198-
have := LTS.ωTr_mTr h_ωtr' (show 0 ≤ xl.length - n by grind)
198+
have := LTS.OmegaExecution.extract_mTr h_ωtr' (show 0 ≤ xl.length - n by grind)
199199
have : n + (xl.length - n) = xl.length := by grind
200200
have : ((xl ++ω xs).drop n).extract 0 (xl.length - n) = xl.drop n := by
201201
grind [extract_eq_take, drop_append_of_le_length, take_append_of_le_length]

Cslib/Computability/Automata/NA/Pair.lean

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ theorem language_eq_fin_iSup_hmul_omegaPow
112112
use ss 0, by grind [NA.Run], t, h_acc
113113
obtain ⟨f, h_mono, h_f⟩ := frequently_iff_strictMono.mp h_t
114114
refine ⟨xs.take (f 0), ?_, xs.drop (f 0), ?_, by grind⟩
115-
· have : na.MTr (ss 0) (xs.extract 0 (f 0)) (ss (f 0)) := by grind [LTS.ωTr_mTr, NA.Run]
115+
· have : na.MTr (ss 0) (xs.extract 0 (f 0)) (ss (f 0)) := by
116+
grind [LTS.OmegaExecution.extract_mTr, NA.Run]
116117
grind [extract_eq_drop_take]
117118
· simp only [omegaPow_seq_prop, LTS.mem_pairLang]
118119
use (f · - f 0)
@@ -121,17 +122,19 @@ theorem language_eq_fin_iSup_hmul_omegaPow
121122
· simp
122123
· intro n
123124
have mono_f (k : ℕ) : f 0 ≤ f (n + k) := h_mono.monotone (by grind)
124-
grind [extract_drop, mono_f 0, LTS.ωTr_mTr h_run.trans <| h_mono.monotone (?_ : n ≤ n + 1)]
125+
grind [extract_drop, mono_f 0,
126+
LTS.OmegaExecution.extract_mTr h_run.trans <| h_mono.monotone (?_ : n ≤ n + 1)]
125127
· rintro ⟨s, _, t, _, yl, h_yl, zs, h_zs, rfl⟩
126128
obtain ⟨zls, rfl, h_zls⟩ := mem_omegaPow.mp h_zs
127129
let ts := ωSequence.const t
128130
have h_mtr (n : ℕ) : na.MTr (ts n) (zls n) (ts (n + 1)) := by
129131
grind [Language.mem_sub_one, LTS.mem_pairLang]
130132
have h_pos (n : ℕ) : (zls n).length > 0 := by
131133
grind [Language.mem_sub_one, List.eq_nil_iff_length_eq_zero]
132-
obtain ⟨zss, h_zss, _⟩ := LTS.ωTr.flatten h_mtr h_pos
134+
obtain ⟨zss, h_zss, _⟩ := LTS.OmegaExecution.flatten_mTr h_mtr h_pos
133135
have (n : ℕ) : zss (zls.cumLen n) = t := by grind
134-
obtain ⟨xss, _, _, _, _⟩ := LTS.ωTr.append h_yl h_zss (by grind [cumLen_zero (ls := zls)])
136+
obtain ⟨xss, _, _, _, _⟩ := LTS.OmegaExecution.append h_yl h_zss
137+
(by grind [cumLen_zero (ls := zls)])
135138
use xss, by grind [NA.Run]
136139
apply (drop_frequently_iff_frequently yl.length).mp
137140
apply frequently_iff_strictMono.mpr

Cslib/Computability/Automata/NA/Sum.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ theorem iSum_run_iff {na : (i : I) → NA (State i) Symbol}
5151
constructor
5252
· simp only [iSum, get_map, mem_iUnion]
5353
grind [NA.Run]
54-
· simp only [LTS.ωTr]
54+
· simp only [LTS.OmegaExecution]
5555
grind [NA.Run]
5656

5757
namespace Buchi

Cslib/Computability/Automata/NA/Total.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ theorem totalize_run_mtr {xs : ωSequence Symbol} {ss : ωSequence (State ⊕ Un
3838
refine ⟨?_, by grind⟩
3939
-- TODO: `grind` does not use congruence relations with `na.totalize.MTr`
4040
rw [← LTS.totalize.mtr_left_iff, ← extract_eq_take, eq₁, ← eq₂]
41-
exact LTS.ωTr_mTr h.trans (by grind)
41+
exact LTS.OmegaExecution.extract_mTr h.trans (by grind)
4242

4343
/-- Any finite execution of the original NA can be extended to an infinite execution of
4444
`NA.totalize`, provided that the alphabet is inbabited. -/
4545
theorem totalize_mtr_run [Inhabited Symbol] {xl : List Symbol} {s t : State}
4646
(hs : s ∈ na.start) (hm : na.MTr s xl t) :
4747
∃ xs ss, na.totalize.Run (xl ++ω xs) ss ∧ ss 0 = inl s ∧ ss xl.length = inl t := by
48-
grind [totalize, Run, LTS.Total.mTr_ωTr <| LTS.totalize.mtr_left_iff.mpr hm]
48+
grind [totalize, Run, LTS.Total.mTr_omegaExecution <| LTS.totalize.mtr_left_iff.mpr hm]
4949

5050
namespace FinAcc
5151

Cslib/Computability/Languages/Congruences/BuchiCongruence.lean

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ if `xl` makes `na` go through an accepting state of `na`, then so can `yl`. -/
8181
lemma buchiCongruence_transfer
8282
{a : Quotient na.BuchiCongruence.eq} {xl yl : List Symbol} {s t : State}
8383
(hc : xl ∈ na.BuchiCongruence.eqvCls a) (hc' : yl ∈ na.BuchiCongruence.eqvCls a)
84-
(hp : xl ∈ na.pairLang s t) : ∃ sl, na.IsExecution s yl t sl ∧
84+
(hp : xl ∈ na.pairLang s t) : ∃ sl, na.Execution s yl t sl ∧
8585
( xl ∈ na.pairViaLang na.accept s t → ∃ r ∈ na.accept, r ∈ sl ) := by
8686
have h_eq : na.BuchiCongruence.eq xl yl := by
8787
apply Quotient.exact
8888
grind
8989
have := h_eq s t
9090
have h_yl : yl ∈ na.pairLang s t := by grind
91-
have := LTS.mTr_extract_isExecution h_yl
92-
grind [LTS.mem_pairViaLang, LTS.IsExecution, → LTS.IsExecution.comp,
93-
→ LTS.mTr_extract_isExecution]
91+
have := LTS.execution_of_mTr h_yl
92+
grind [LTS.mem_pairViaLang, LTS.Execution, → LTS.Execution.comp,
93+
→ LTS.execution_of_mTr]
9494

9595
/-- `na.buchiFamily` is a family of ω-languages indexed by a pair of equivalence classes
9696
of `na.BuchiCongruence` which will turn out to saturate the ω-language accepted by `na`
@@ -110,7 +110,8 @@ theorem mem_buchiFamily [Inhabited Symbol]
110110
-- because that proof was too big and kept exceeding the default `maxHeartbeats`.
111111
private lemma frequently_via_accept [Inhabited Symbol]
112112
{xl : List Symbol} {xls : ωSequence (List Symbol)} {ss : ωSequence State}
113-
(h_acc : ∃ᶠ (k : ℕ) in atTop, ss k ∈ na.accept) (h_exec : na.ωTr ss (xl ++ω xls.flatten))
113+
(h_acc : ∃ᶠ (k : ℕ) in atTop, ss k ∈ na.accept)
114+
(h_exec : na.OmegaExecution ss (xl ++ω xls.flatten))
114115
(h_xls_p : ∀ (k : ℕ), (xls k).length > 0)
115116
(f : ℕ → ℕ) (h_f : f = fun k => xl.length + xls.cumLen k)
116117
(ts : ωSequence State) (h_ts : ts = ωSequence.mk (fun k ↦ ss (f k))) :
@@ -121,7 +122,8 @@ private lemma frequently_via_accept [Inhabited Symbol]
121122
apply LTS.mem_pairViaLang.mpr
122123
use ss (f n + k), by grind, (xls n).take k, (xls n).drop k
123124
have := extract_flatten h_xls_p n
124-
have exec {m n} (h : m ≤ n) := LTS.isExecution_mTr na.toLTS <| LTS.ωTr_isExecution h_exec h
125+
have exec {m n} (h : m ≤ n) :=
126+
LTS.mTr_of_execution na.toLTS <| LTS.OmegaExecution.extract_execution h_exec h
125127
split_ands
126128
· have h : f n ≤ f n + k := by lia
127129
specialize exec h
@@ -141,24 +143,25 @@ theorem buchiFamily_saturation [Inhabited Symbol] : Saturates na.buchiFamily (la
141143
let ts := ωSequence.mk (fun k ↦ ss (f k))
142144
have h_xls_p (k : ℕ) : (xls k).length > 0 := by grind [Language.mem_sub_one]
143145
have h_xls_e (k : ℕ) : xls k ∈ na.pairLang (ts k) (ts (k + 1)) := by
144-
grind [LTS.ωTr_mTr h_exec (?_ : f k ≤ f (k + 1)), LTS.mem_pairLang, extract_append_right_right,
145-
add_tsub_cancel_left]
146+
grind [LTS.OmegaExecution.extract_mTr h_exec (?_ : f k ≤ f (k + 1)), LTS.mem_pairLang,
147+
extract_append_right_right, add_tsub_cancel_left]
146148
have h_yls (k : ℕ) := buchiCongruence_transfer ((h_xls_c k).left) ((h_yls_c k).left) (h_xls_e k)
147149
choose sls h_yls_e h_yls_a using h_yls
148150
have h_yls_p (k : ℕ) : (yls k).length > 0 := by grind [Language.mem_sub_one]
149-
obtain ⟨ss1, h_ss1_run, h_ss1_seg⟩ := LTS.IsExecution.flatten h_yls_e h_yls_p
151+
obtain ⟨ss1, h_ss1_run, h_ss1_seg⟩ := LTS.OmegaExecution.flatten_execution h_yls_e h_yls_p
150152
suffices ∃ᶠ (k : ℕ) in atTop, ss1 k ∈ na.accept by
151153
have h_xl_e : xl ∈ na.pairLang (ss 0) (ts 0) := by
152-
grind [LTS.ωTr_mTr h_exec (?_ : 0 ≤ xl.length), extract_append_zero_right, LTS.mem_pairLang]
154+
grind [LTS.OmegaExecution.extract_mTr h_exec (?_ : 0 ≤ xl.length),
155+
extract_append_zero_right, LTS.mem_pairLang]
153156
have h_yl_e : yl ∈ na.pairLang (ss 0) (ts 0) := by
154-
grind [buchiCongruence_transfer h_xl_c h_yl_c h_xl_e, LTS.mem_pairLang, LTS.isExecution_mTr]
157+
grind [buchiCongruence_transfer h_xl_c h_yl_c h_xl_e, LTS.mem_pairLang, LTS.mTr_of_execution]
155158
have h_ss1_ts : ss1 0 = ts 0 := by
156159
have h : 0 < yls.cumLen 1 - yls.cumLen 0 := by grind
157160
have : 0 < (sls 0).length := by grind
158161
have : ss1 0 = (sls 0)[0] := by grind [get_extract (xs := ss1) h]
159162
have : (sls 0)[0] = ts 0 := h_yls_e 0 |>.choose_spec |>.1
160163
grind
161-
obtain ⟨ss2, _, _, _, _⟩ := LTS.ωTr.append h_yl_e h_ss1_run h_ss1_ts
164+
obtain ⟨ss2, _, _, _, _⟩ := LTS.OmegaExecution.append h_yl_e h_ss1_run h_ss1_ts
162165
use ss2
163166
have := @drop_frequently_iff_frequently _ ss2 na.accept yl.length
164167
grind [Run.mk]

0 commit comments

Comments
 (0)