chars int64 40 24k | content_type stringclasses 9
values | id stringlengths 13 64 | source stringclasses 5
values | subset stringclasses 31
values | text stringlengths 40 24k |
|---|---|---|---|---|---|
183 | leanexplore_declaration | leanexplore:386502 | leanexplore_sqlite | leanexplore_declarations | @[simp, grind =] theorem time_map {α β} (f : α → β) (x : TimeM T α) : (f <$> x).time = x.time := rfl
@[simp] theorem time_seqRight {α} [Add T] (x : TimeM T α) (y : Unit → TimeM T β) : |
227 | leanexplore_declaration | leanexplore:386503 | leanexplore_sqlite | leanexplore_declarations | @[simp] theorem time_seqRight {α} [Add T] (x : TimeM T α) (y : Unit → TimeM T β) :
(SeqRight.seqRight x y).time = x.time + (y ()).time := rfl
@[simp] theorem time_seqLeft {α} [Add T] (x : TimeM T α) (y : Unit → TimeM T β) : |
228 | leanexplore_declaration | leanexplore:386504 | leanexplore_sqlite | leanexplore_declarations | @[simp] theorem time_seqLeft {α} [Add T] (x : TimeM T α) (y : Unit → TimeM T β) :
(SeqLeft.seqLeft x y).time = x.time + (y ()).time := rfl
@[simp] theorem time_seq {α β} [Add T] (f : TimeM T (α → β)) (x : Unit → TimeM T α) : |
138 | leanexplore_declaration | leanexplore:386505 | leanexplore_sqlite | leanexplore_declarations | @[simp] theorem time_seq {α β} [Add T] (f : TimeM T (α → β)) (x : Unit → TimeM T α) :
(Seq.seq f x).time = f.time + (x ()).time := rfl |
368 | leanexplore_declaration | leanexplore:386506 | leanexplore_sqlite | leanexplore_declarations | /-- `TimeM` is lawful so long as addition in the cost is associative and absorbs zero. -/
instance [AddMonoid T] : LawfulMonad (TimeM T) := .mk'
(id_map := fun x => rfl)
(pure_bind := fun _ _ => by ext <;> simp)
(bind_assoc := fun _ _ _ => by ext <;> simp [add_assoc])
(seqLeft_eq := fun _ _ => by ext <;> simp)
... |
101 | leanexplore_declaration | leanexplore:386507 | leanexplore_sqlite | leanexplore_declarations | /-- Creates a `TimeM` computation with a time cost. -/
def tick (c : T) : TimeM T PUnit := ⟨.unit, c⟩ |
138 | leanexplore_declaration | leanexplore:386508 | leanexplore_sqlite | leanexplore_declarations | @[simp, grind =] theorem ret_tick (c : T) : (tick c).ret = () := rfl
@[simp, grind =] theorem time_tick (c : T) : (tick c).time = c := rfl |
69 | leanexplore_declaration | leanexplore:386509 | leanexplore_sqlite | leanexplore_declarations | @[simp, grind =] theorem time_tick (c : T) : (tick c).time = c := rfl |
87 | leanexplore_declaration | leanexplore:386510 | leanexplore_sqlite | leanexplore_declarations | macro "✓[" c:term "]" body:doElem : doElem => `(doElem| do TimeM.tick $c; $body:doElem) |
55 | leanexplore_declaration | leanexplore:386511 | leanexplore_sqlite | leanexplore_declarations | macro "✓" body:doElem : doElem => `(doElem| ✓[1] $body) |
131 | leanexplore_declaration | leanexplore:386512 | leanexplore_sqlite | leanexplore_declarations | /-- Notation for extracting the return value from a `TimeM` computation: `⟪tm⟫` -/
scoped notation:max "⟪" tm "⟫" => (TimeM.ret tm) |
270 | leanexplore_declaration | leanexplore:386513 | leanexplore_sqlite | leanexplore_declarations | /-- An `Acceptor` is a machine that recognises strings (lists of symbols in an alphabet). -/
class Acceptor (A : Type u) (Symbol : outParam (Type v)) where
/-- Predicate that establishes whether a string `xs` is accepted. -/
Accepts (a : A) (xs : List Symbol) : Prop |
176 | leanexplore_declaration | leanexplore:386514 | leanexplore_sqlite | leanexplore_declarations | /-- The language of an `Acceptor` is the set of strings it `Accepts`. -/
@[scoped grind .]
def language [Acceptor A Symbol] (a : A) : Language Symbol :=
{ xs | Accepts a xs } |
216 | leanexplore_declaration | leanexplore:386515 | leanexplore_sqlite | leanexplore_declarations | /-- A string is in the language of an acceptor iff the acceptor accepts it. -/
@[simp, scoped grind =]
theorem mem_language [Acceptor A Symbol] (a : A) (xs : List Symbol) :
xs ∈ language a ↔ Accepts a xs := Iff.rfl |
265 | leanexplore_declaration | leanexplore:386516 | leanexplore_sqlite | leanexplore_declarations | /-- An `ωAcceptor` is a machine that recognises infinite sequences of symbols. -/
class ωAcceptor (A : Type u) (Symbol : outParam (Type v)) where
/-- Predicate that establishes whether a string `xs` is accepted. -/
Accepts (a : A) (xs : ωSequence Symbol) : Prop |
181 | leanexplore_declaration | leanexplore:386517 | leanexplore_sqlite | leanexplore_declarations | /-- The language of an `ωAcceptor` is the set of sequences it `Accepts`. -/
@[scoped grind .]
def language [ωAcceptor A Symbol] (a : A) : ωLanguage Symbol :=
{ xs | Accepts a xs } |
222 | leanexplore_declaration | leanexplore:386518 | leanexplore_sqlite | leanexplore_declarations | /-- A string is in the language of an acceptor iff the acceptor accepts it. -/
@[simp, scoped grind =]
theorem mem_language [ωAcceptor A Symbol] (a : A) (xs : ωSequence Symbol) :
xs ∈ language a ↔ Accepts a xs := Iff.rfl |
207 | leanexplore_declaration | leanexplore:386519 | leanexplore_sqlite | leanexplore_declarations | /-- A deterministic automaton extends a `FLTS` with a unique initial state. -/
structure DA (State Symbol : Type*) extends FLTS State Symbol where
/-- The initial state of the automaton. -/
start : State |
193 | leanexplore_declaration | leanexplore:386520 | leanexplore_sqlite | leanexplore_declarations | /-- Helper function for defining `run` below. -/
@[scoped grind =]
def run' (da : DA State Symbol) (xs : ωSequence Symbol) : ℕ → State
| 0 => da.start
| n + 1 => da.tr (run' da xs n) (xs n) |
125 | leanexplore_declaration | leanexplore:386521 | leanexplore_sqlite | leanexplore_declarations | /-- Infinite run. -/
@[scoped grind =]
def run (da : DA State Symbol) (xs : ωSequence Symbol) : ωSequence State := da.run' xs |
125 | leanexplore_declaration | leanexplore:386522 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem run_zero {da : DA State Symbol} {xs : ωSequence Symbol} :
da.run xs 0 = da.start :=
rfl |
160 | leanexplore_declaration | leanexplore:386523 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem run_succ {da : DA State Symbol} {xs : ωSequence Symbol} {n : ℕ} :
da.run xs (n + 1) = da.tr (da.run xs n) (xs n) := by
rfl |
226 | leanexplore_declaration | leanexplore:386524 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem mtr_extract_eq_run {da : DA State Symbol} {xs : ωSequence Symbol} {n : ℕ} :
da.mtr da.start (xs.extract 0 n) = da.run xs n := by
induction n
case zero => rfl
case succ n h_ind => grind |
209 | leanexplore_declaration | leanexplore:386525 | leanexplore_sqlite | leanexplore_declarations | /-- A deterministic automaton that accepts finite strings (lists of symbols). -/
structure FinAcc (State Symbol : Type*) extends DA State Symbol where
/-- The set of accepting states. -/
accept : Set State |
383 | leanexplore_declaration | leanexplore:386526 | leanexplore_sqlite | leanexplore_declarations | /-- A `DA.FinAcc` accepts a string if its multistep transition function maps the start state and
the string to an accept state.
This is the standard string recognition performed by DFAs in the literature. -/
@[simp, scoped grind =]
instance : Acceptor (DA.FinAcc State Symbol) Symbol where
Accepts (a : DA.FinAcc Stat... |
165 | leanexplore_declaration | leanexplore:386527 | leanexplore_sqlite | leanexplore_declarations | /-- Deterministic Buchi automaton. -/
structure Buchi (State Symbol : Type*) extends DA State Symbol where
/-- The set of accepting states. -/
accept : Set State |
267 | leanexplore_declaration | leanexplore:386528 | leanexplore_sqlite | leanexplore_declarations | /-- An infinite run is accepting iff accepting states occur infinitely many times. -/
@[simp, scoped grind =]
instance : ωAcceptor (Buchi State Symbol) Symbol where
Accepts (a : Buchi State Symbol) (xs : ωSequence Symbol) :=
∃ᶠ k in atTop, a.run xs k ∈ a.accept |
181 | leanexplore_declaration | leanexplore:386529 | leanexplore_sqlite | leanexplore_declarations | /-- Deterministic Muller automaton. -/
structure Muller (State Symbol : Type*) extends DA State Symbol where
/-- The set of sets of accepting states. -/
accept : Set (Set State) |
298 | leanexplore_declaration | leanexplore:386530 | leanexplore_sqlite | leanexplore_declarations | /-- An infinite run is accepting iff the set of states that occur infinitely many times
is one of the sets in `accept`. -/
@[simp, scoped grind =]
instance : ωAcceptor (Muller State Symbol) Symbol where
Accepts (a : Muller State Symbol) (xs : ωSequence Symbol) :=
(a.run xs).infOcc ∈ a.accept |
320 | leanexplore_declaration | leanexplore:386531 | leanexplore_sqlite | leanexplore_declarations | /-- The ω-language accepted by a deterministic Buchi automaton is the ω-limit
of the language accepted by the same automaton.
-/
@[scoped grind =]
theorem buchi_eq_finAcc_omegaLim {da : DA State Symbol} {acc : Set State} :
language (Buchi.mk da acc) = (language (FinAcc.mk da acc))↗ω := by
ext xs
simp +instances |
593 | leanexplore_declaration | leanexplore:386532 | leanexplore_sqlite | leanexplore_declarations | /-- Every right congruence gives rise to a DA whose states are the equivalence classes of
the right congruence, whose start state is the empty word, and whose transition functiuon
is concatenation on the right of the input symbol. Note that the transition function is
well-defined only because `c` is a right congruence.... |
504 | leanexplore_declaration | leanexplore:386533 | leanexplore_sqlite | leanexplore_declarations | /-- After consuming a finite word `xs`, `c.toDA` reaches the state `⟦ xs ⟧` which is
the equivalence class of `xs`. -/
@[simp, scoped grind =]
theorem congr_mtr_eq {xs : List Symbol} :
c.toDA.mtr c.toDA.start xs = ⟦ xs ⟧ := by
generalize h_rev : xs.reverse = ys
induction ys generalizing xs
case nil => grind [... |
425 | leanexplore_declaration | leanexplore:386534 | leanexplore_sqlite | leanexplore_declarations | /-- The language of `c.toDA` with a single accepting state `s` is exactly
the equivalence class corresponding to `s`. -/
@[simp]
theorem congr_language_eq {a : Quotient c.eq} : language (FinAcc.mk c.toDA {a}) = eqvCls a := by
ext
#adaptation_note
/-- A grind regression found moving to nightly-2026-03-31 (changes ... |
235 | leanexplore_declaration | leanexplore:386535 | leanexplore_sqlite | leanexplore_declarations | /-- The product of two deterministic automata. -/
@[scoped grind =]
def prod (da1 : DA State1 Symbol) (da2 : DA State2 Symbol) : DA (State1 × State2) Symbol where
toFLTS := da1.toFLTS.prod da2.toFLTS
start := (da1.start, da2.start) |
382 | leanexplore_declaration | leanexplore:386536 | leanexplore_sqlite | leanexplore_declarations | /-- A state is reachable by the product automaton iff its components are reachable by
the respective automaton components. -/
@[simp, scoped grind =]
theorem prod_mtr_eq (da1 : DA State1 Symbol) (da2 : DA State2 Symbol)
(s : State1 × State2) (xs : List Symbol) :
(da1.prod da2).mtr s xs = (da1.mtr s.fst xs, da2.... |
146 | leanexplore_declaration | leanexplore:386537 | leanexplore_sqlite | leanexplore_declarations | /-- `DA` is a special case of `NA`. -/
@[scoped grind =]
def toNA (a : DA State Symbol) : NA State Symbol :=
{ a.toLTS with start := {a.start} } |
70 | leanexplore_declaration | leanexplore:386538 | leanexplore_sqlite | leanexplore_declarations | instance : Coe (DA State Symbol) (NA State Symbol) where
coe := toNA |
245 | leanexplore_declaration | leanexplore:386539 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem toNA_run {a : DA State Symbol} {xs : ωSequence Symbol} {ss : ωSequence State} :
a.toNA.Run xs ss ↔ a.run xs = ss := by
constructor
· rintro _
ext n
induction n <;> grind [NA.Run]
· grind [NA.Run] |
179 | leanexplore_declaration | leanexplore:386540 | leanexplore_sqlite | leanexplore_declarations | /-- `DA.FinAcc` is a special case of `NA.FinAcc`. -/
@[scoped grind =]
def toNAFinAcc (a : DA.FinAcc State Symbol) : NA.FinAcc State Symbol :=
{ a.toNA with accept := a.accept } |
501 | leanexplore_declaration | leanexplore:386541 | leanexplore_sqlite | leanexplore_declarations | /-- The `NA.FinAcc` constructed from a `DA.FinAcc` has the same language. -/
@[simp, scoped grind _=_]
theorem toNAFinAcc_language_eq {a : DA.FinAcc State Symbol} :
language a.toNAFinAcc = language a := by
ext xs
#adaptation_note
/-- A grind regression found moving to nightly-2026-03-31 (changes from lean#131... |
174 | leanexplore_declaration | leanexplore:386542 | leanexplore_sqlite | leanexplore_declarations | /-- `DA.Buchi` is a special case of `NA.Buchi`. -/
@[scoped grind =]
def toNABuchi (a : DA.Buchi State Symbol) : NA.Buchi State Symbol :=
{ a.toNA with accept := a.accept } |
477 | leanexplore_declaration | leanexplore:386543 | leanexplore_sqlite | leanexplore_declarations | /-- The `NA.Buchi` constructed from a `DA.Buchi` has the same ω-language. -/
@[simp, scoped grind _=_]
theorem toNABuchi_language_eq {a : DA.Buchi State Symbol} :
language a.toNABuchi = language a := by
ext xs; constructor
#adaptation_note
/-- A grind regression found moving to nightly-2026-03-31 (changes fro... |
446 | leanexplore_declaration | leanexplore:386544 | leanexplore_sqlite | leanexplore_declarations | /-- A nondeterministic finite automaton with ε-transitions (`εNA`) is an `NA` with an `Option`
symbol type. The special symbol ε is represented by the `Option.none` case.
Internally, ε (`Option.none`) is treated as the `τ` label of the underlying transition system,
allowing for reusing the definitions and results on s... |
56 | leanexplore_declaration | leanexplore:386545 | leanexplore_sqlite | leanexplore_declarations | @[local grind =]
instance : HasTau (Option α) := ⟨.none⟩ |
285 | leanexplore_declaration | leanexplore:386546 | leanexplore_sqlite | leanexplore_declarations | /-- The `ε`-closure of a set of states `S` is the set of states reachable by any state in `S`
by performing only `ε`-transitions. We use `LTS.τClosure` since `ε` (`Option.none`) is an instance
of `HasTau.τ`. -/
abbrev εNA.εClosure (a : εNA State Symbol) (S : Set State) := a.τClosure S |
215 | leanexplore_declaration | leanexplore:386547 | leanexplore_sqlite | leanexplore_declarations | /-- The finite-word acceptance condition of an `εNA` is a set of accepting states. -/
structure FinAcc (State Symbol : Type*) extends εNA State Symbol where
/-- The set of accepting states. -/
accept : Set State |
352 | leanexplore_declaration | leanexplore:386548 | leanexplore_sqlite | leanexplore_declarations | /-- An `εNA.FinAcc` accepts a string if there is a saturated multistep accepting derivative with
that trace from the start state. -/
@[scoped grind =]
instance : Acceptor (FinAcc State Symbol) Symbol where
Accepts (a : FinAcc State Symbol) (xs : List Symbol) :=
∃ s ∈ a.εClosure a.start, ∃ s' ∈ a.accept,
a.sat... |
237 | leanexplore_declaration | leanexplore:386549 | leanexplore_sqlite | leanexplore_declarations | /-- Converts an `LTS` with Option labels into an `LTS` on the carried label type, by removing all
ε-transitions. -/
@[local grind =]
def LTS.noε (lts : LTS State (Option Label)) : LTS State Label where
Tr s μ s' := lts.Tr s (some μ) s' |
216 | leanexplore_declaration | leanexplore:386550 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind =]
lemma LTS.noε_saturate_mTr {lts : LTS State (Option Label)} :
lts.saturate.MTr s (μs.map some) = lts.saturate.noε.MTr s μs := by
ext s'
induction μs generalizing s <;> grind [<= LTS.MTr.stepL] |
262 | leanexplore_declaration | leanexplore:386551 | leanexplore_sqlite | leanexplore_declarations | /-- Any `εNA.FinAcc` can be converted into an `NA.FinAcc` that does not use ε-transitions. -/
@[scoped grind]
def toNAFinAcc (a : εNA.FinAcc State Symbol) : NA.FinAcc State Symbol where
start := a.εClosure a.start
accept := a.accept
Tr := a.saturate.noε.Tr |
426 | leanexplore_declaration | leanexplore:386552 | leanexplore_sqlite | leanexplore_declarations | /-- Correctness of `toNAFinAcc`. -/
@[scoped grind _=_]
theorem toNAFinAcc_language_eq {ena : εNA.FinAcc State Symbol} :
language ena.toNAFinAcc = language ena := by
ext xs
have : ∀ s s', ena.saturate.MTr s (xs.map some) s' = ena.saturate.noε.MTr s xs s' := by
simp [LTS.noε_saturate_mTr]
#adaptation_note
... |
221 | leanexplore_declaration | leanexplore:386553 | leanexplore_sqlite | leanexplore_declarations | /-- A nondeterministic automaton extends a `LTS` with a set of initial states. -/
structure NA (State Symbol : Type*) extends LTS State Symbol where
/-- The set of initial states of the automaton. -/
start : Set State |
170 | leanexplore_declaration | leanexplore:386554 | leanexplore_sqlite | leanexplore_declarations | /-- Infinite run. -/
structure Run (na : NA State Symbol) (xs : ωSequence Symbol) (ss : ωSequence State) where
start : ss 0 ∈ na.start
trans : na.OmegaExecution ss xs |
212 | leanexplore_declaration | leanexplore:386555 | leanexplore_sqlite | leanexplore_declarations | /-- A nondeterministic automaton that accepts finite strings (lists of symbols). -/
structure FinAcc (State Symbol : Type*) extends NA State Symbol where
/-- The set of accepting states. -/
accept : Set State |
377 | leanexplore_declaration | leanexplore:386556 | leanexplore_sqlite | leanexplore_declarations | /-- An `NA.FinAcc` accepts a string if there is a multistep transition from a start state to an
accept state.
This is the standard string recognition performed by NFAs in the literature. -/
@[simp, scoped grind =]
instance : Acceptor (FinAcc State Symbol) Symbol where
Accepts (a : FinAcc State Symbol) (xs : List Sym... |
168 | leanexplore_declaration | leanexplore:386557 | leanexplore_sqlite | leanexplore_declarations | /-- Nondeterministic Buchi automaton. -/
structure Buchi (State Symbol : Type*) extends NA State Symbol where
/-- The set of accepting states. -/
accept : Set State |
281 | leanexplore_declaration | leanexplore:386558 | leanexplore_sqlite | leanexplore_declarations | /-- An infinite run is accepting iff accepting states occur infinitely many times. -/
@[simp, scoped grind =]
instance : ωAcceptor (Buchi State Symbol) Symbol where
Accepts (a : Buchi State Symbol) (xs : ωSequence Symbol) :=
∃ ss, a.Run xs ss ∧ ∃ᶠ k in atTop, ss k ∈ a.accept |
184 | leanexplore_declaration | leanexplore:386559 | leanexplore_sqlite | leanexplore_declarations | /-- Nondeterministic Muller automaton. -/
structure Muller (State Symbol : Type*) extends NA State Symbol where
/-- The set of sets of accepting states. -/
accept : Set (Set State) |
310 | leanexplore_declaration | leanexplore:386560 | leanexplore_sqlite | leanexplore_declarations | /-- An infinite run is accepting iff the set of states that occur infinitely many times
is one of the sets in `accept`. -/
@[simp, scoped grind =]
instance : ωAcceptor (Muller State Symbol) Symbol where
Accepts (a : Muller State Symbol) (xs : ωSequence Symbol) :=
∃ ss, a.Run xs ss ∧ ss.infOcc ∈ a.accept |
477 | leanexplore_declaration | leanexplore:386561 | leanexplore_sqlite | leanexplore_declarations | /-- Lifts an equivalence on states to an equivalence on NBAs. -/
@[scoped grind =]
def reindex (f : State ≃ State') : Buchi State Symbol ≃ Buchi State' Symbol where
toFun nba := {
Tr s x t := nba.Tr (f.symm s) x (f.symm t)
start := f '' nba.start
accept := f.symm ⁻¹' nba.accept
}
invFun nba' := {
... |
377 | leanexplore_declaration | leanexplore:386562 | leanexplore_sqlite | leanexplore_declarations | theorem reindex_run_iff {f : State ≃ State'} {nba : Buchi State Symbol}
{xs : ωSequence Symbol} {ss' : ωSequence State'} :
(nba.reindex f).Run xs ss' ↔ nba.Run xs (ss'.map f.symm) := by
constructor
· rintro ⟨h_init, h_next⟩
exact ⟨mem_image_equiv.mp h_init, fun n ↦ h_next n⟩
· rintro ⟨h_init, h_next⟩... |
218 | leanexplore_declaration | leanexplore:386563 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem reindex_run_iff' {f : State ≃ State'} {nba : Buchi State Symbol}
{xs : ωSequence Symbol} {ss : ωSequence State} :
(nba.reindex f).Run xs (ss.map f) ↔ nba.Run xs ss := by
simp [reindex_run_iff] |
522 | leanexplore_declaration | leanexplore:386564 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem reindex_language_eq {f : State ≃ State'} {nba : Buchi State Symbol} :
language (nba.reindex f) = language nba := by
ext xs
constructor
· rintro ⟨ss', h_run', h_acc'⟩
#adaptation_note
/-- A grind regression found moving to nightly-2026-03-31 (changes from lean#13166) -/
... |
124 | leanexplore_declaration | leanexplore:386565 | leanexplore_sqlite | leanexplore_declarations | /-- The initial history state. -/
@[scoped grind =, nolint unusedArguments]
def histStart (_ : Π i, State i) : Bool := false |
211 | leanexplore_declaration | leanexplore:386566 | leanexplore_sqlite | leanexplore_declarations | /-- The two accepting conditions of the intersection automaton. -/
@[scoped grind =]
def interAcc (j : Bool) (acc : (i : Bool) → Set (State i)) : Set ((Π i, State i) × Bool) :=
{ (s, h) | s j ∈ acc j ∧ h = j } |
323 | leanexplore_declaration | leanexplore:386567 | leanexplore_sqlite | leanexplore_declarations | /-- The transition function of the history state. -/
@[scoped grind =, nolint unusedArguments]
noncomputable def histTrans (acc : (i : Bool) → Set (State i))
(s : (Π i, State i) × Bool) (_ : Symbol) (_ : Π i, State i) : Bool :=
if s ∈ interAcc false acc then true else
if s ∈ interAcc true acc then false else s.... |
243 | leanexplore_declaration | leanexplore:386568 | leanexplore_sqlite | leanexplore_declarations | /-- The intersection automaton. -/
@[scoped grind =]
noncomputable def interNA (na : (i : Bool) → NA (State i) Symbol)
(acc : (i : Bool) → Set (State i)) : NA ((Π i, State i) × Bool) Symbol :=
(iProd na).addHist histStart (histTrans acc) |
211 | leanexplore_declaration | leanexplore:386569 | leanexplore_sqlite | leanexplore_declarations | /-- The overall accepting conditon of the intersection automaton. -/
@[scoped grind =]
def interAccept (acc : (i : Bool) → Set (State i)) : Set ((Π i, State i) × Bool) :=
interAcc false acc ∪ interAcc true acc |
667 | leanexplore_declaration | leanexplore:386570 | leanexplore_sqlite | leanexplore_declarations | /-- If the intersection automaton sees one accepting condtion infinitely many times,
then it sees the other accepting condition infinitely many times as well. -/
lemma inter_freq_acc_freq_acc {xs : ωSequence Symbol} {ss : ωSequence ((Π i, State i) × Bool)}
{i : Bool} (h_run : (interNA na acc).Run xs ss) (h_inf : ∃ᶠ... |
969 | leanexplore_declaration | leanexplore:386571 | leanexplore_sqlite | leanexplore_declarations | /-- If the intersection automaton sees the accepting condtions of both component automata
infinitely many times, then its own accepting condition also happens infinitely many times. -/
lemma inter_freq_comp_acc_freq_acc {xs : ωSequence Symbol} {ss : ωSequence ((Π i, State i) × Bool)}
(h_run : (interNA na acc).Run x... |
1,385 | leanexplore_declaration | leanexplore:386572 | leanexplore_sqlite | leanexplore_declarations | /-- The language accepted by the intersection automaton is the intersection of
the languages accepted by the two component automata. -/
@[simp, scoped grind =]
theorem inter_language_eq :
language (Buchi.mk (interNA na acc) (interAccept acc)) =
⋂ i, language (Buchi.mk (na i) (acc i)) := by
ext xs
rw [mem_iI... |
722 | leanexplore_declaration | leanexplore:386573 | leanexplore_sqlite | leanexplore_declarations | /-- `concat na1 na2` starts by running `na1` and then nondeterministically switches to `na2`
by identifying an accepting state of `na1` with an initial state of `na2`. If `na1` accepts the
empty word, it may also start running `na2` from the beginning. Once it starts running `na2`,
it cannot go back to `na1`. -/
def co... |
196 | leanexplore_declaration | leanexplore:386574 | leanexplore_sqlite | leanexplore_declarations | lemma concat_start_right {xs : ωSequence Symbol} {ss : ωSequence (State1 ⊕ State2)}
(hc : (concat na1 na2).Run xs ss) (hr : (ss 0).isRight) : [] ∈ language na1 := by
grind [concat, hc.start] |
627 | leanexplore_declaration | leanexplore:386575 | leanexplore_sqlite | leanexplore_declarations | lemma concat_run_left {xs : ωSequence Symbol} {ss : ωSequence (State1 ⊕ State2)}
(hc : (concat na1 na2).Run xs ss) (n : ℕ) (hl : ∀ k ≤ n, (ss k).isLeft) :
∃ s1 t1, na1.MTr s1 (xs.take n) t1 ∧ s1 ∈ na1.start ∧ ss 0 = inl s1 ∧ ss n = inl t1 := by
obtain ⟨s1, _⟩ : ∃ s1, s1 ∈ na1.start ∧ ss 0 = inl s1 := by grind... |
506 | leanexplore_declaration | leanexplore:386576 | leanexplore_sqlite | leanexplore_declarations | lemma concat_run_left_right {xs : ωSequence Symbol} {ss : ωSequence (State1 ⊕ State2)}
(hc : (concat na1 na2).Run xs ss) (n : ℕ) (hn : 0 < n)
(hl : ∀ k < n, (ss k).isLeft) (hr : (ss n).isRight) : (xs.take n) ∈ language na1 := by
obtain ⟨s1, t1, h_mtr, _⟩ := concat_run_left hc (n - 1) (by grind)
obtain ⟨t1',... |
619 | leanexplore_declaration | leanexplore:386577 | leanexplore_sqlite | leanexplore_declarations | lemma concat_run_right {xs : ωSequence Symbol} {ss : ωSequence (State1 ⊕ State2)}
(hc : (concat na1 na2).Run xs ss) (n : ℕ) (hl : ∀ k < n, (ss k).isLeft) (hr : (ss n).isRight) :
∃ ss2, na2.Run (xs.drop n) ss2 ∧ ss.drop n = ss2.map inr := by
have h2 k : ∃ s2, ss (n + k) = inr s2 := by
induction k
cas... |
736 | leanexplore_declaration | leanexplore:386578 | leanexplore_sqlite | leanexplore_declarations | /-- A run of `concat na1 na2` containing at least one `na2` state is the concatenation of
an accepting finite run of `na1` followed by a run of `na2`. -/
theorem concat_run_proj {xs : ωSequence Symbol} {ss : ωSequence (State1 ⊕ State2)} {k : ℕ}
(hc : (concat na1 na2).Run xs ss) (hr : (ss k).isRight) :
∃ n, n ≤ ... |
1,059 | leanexplore_declaration | leanexplore:386579 | leanexplore_sqlite | leanexplore_declarations | /-- Given an accepting finite run of `na1` and a run of `na2`, there exists a run of
`concat na1 na2` that is the concatenation of the two runs. -/
theorem concat_run_exists {xs1 : List Symbol} {xs2 : ωSequence Symbol} {ss2 : ωSequence State2}
(h1 : xs1 ∈ language na1) (h2 : na2.Run xs2 ss2) :
∃ ss, (concat na1... |
868 | leanexplore_declaration | leanexplore:386580 | leanexplore_sqlite | leanexplore_declarations | /-- The Buchi automaton formed from `concat na1 na2` accepts the ω-language that is
the concatenation of the language of `na1` and the ω-language of `na2`. -/
@[simp]
theorem concat_language_eq {acc2 : Set State2} :
language (Buchi.mk (concat na1 na2) (inr '' acc2)) =
language na1 * language (Buchi.mk na2 acc2)... |
276 | leanexplore_declaration | leanexplore:386581 | leanexplore_sqlite | leanexplore_declarations | /-- `finConcat na1 na2` is the concatenation of the "totalized" versions of `na1` and `na2`. -/
def finConcat (na1 : FinAcc State1 Symbol) (na2 : FinAcc State2 Symbol)
: NA ((State1 ⊕ Unit) ⊕ (State2 ⊕ Unit)) Symbol :=
concat ⟨na1.totalize, inl '' na1.accept⟩ na2.totalize |
281 | leanexplore_declaration | leanexplore:386582 | leanexplore_sqlite | leanexplore_declarations | /-- `finConcat na1 na2` is total. -/
instance : (finConcat na1 na2).Total where
total s x := match s with
| inl _ => ⟨inl (inr ()), by grind [finConcat, concat, NA.totalize, LTS.totalize]⟩
| inr _ => ⟨inr (inr ()), by grind [finConcat, concat, NA.totalize, LTS.totalize]⟩ |
2,037 | leanexplore_declaration | leanexplore:386583 | leanexplore_sqlite | leanexplore_declarations | /-- `finConcat na1 na2` accepts the concatenation of the languages of `na1` and `na2`. -/
theorem finConcat_language_eq [Inhabited Symbol] :
language (FinAcc.mk (finConcat na1 na2) (inr '' (inl '' na2.accept))) =
language na1 * language na2 := by
ext xl
constructor
· rintro ⟨s, _, t, h_acc, h_mtr⟩
obt... |
544 | leanexplore_declaration | leanexplore:386584 | leanexplore_sqlite | leanexplore_declarations | /-- The construction of adding a history state. Note that `start'` can depend on the initial
value of the original state and `tr'` can depend on the new value of the original state.
So there is no loss of generality in their being functions, rather than relations. -/
@[scoped grind =]
def addHist (na : NA State Symbol... |
329 | leanexplore_declaration | leanexplore:386585 | leanexplore_sqlite | leanexplore_declarations | /-- Every run of the history automaton projects onto a run of the original automaton. -/
theorem hist_run_proj {xs : ωSequence Symbol} {ss : ωSequence (State × Hist)}
(h_run : (na.addHist start' tr').Run xs ss) : na.Run xs (ss.map fst) := by
obtain ⟨h_start, h_trans⟩ := h_run
simp only [addHist] at h_trans
gr... |
349 | leanexplore_declaration | leanexplore:386586 | leanexplore_sqlite | leanexplore_declarations | /-- Given a run of the original automaton, `makeHist` builds a run of the history state. -/
@[scoped grind =]
def makeHist (start' : State → Hist) (tr' : State × Hist → Symbol → State → Hist)
(xs : ωSequence Symbol) (ss : ωSequence State) : ℕ → Hist
| 0 => start' (ss 0)
| n + 1 => tr' (ss n, makeHist start' tr'... |
416 | leanexplore_declaration | leanexplore:386587 | leanexplore_sqlite | leanexplore_declarations | /-- For every run `ss` of the original automaton, there exists a run `ss'` of the history automaton
which projects back onto `ss`. -/
theorem hist_run_exists {xs : ωSequence Symbol} {ss : ωSequence State}
(h_run : na.Run xs ss) : ∃ ss', (na.addHist start' tr').Run xs ss' ∧ ss'.map fst = ss := by
use ⟨fun n ↦ (ss ... |
650 | leanexplore_declaration | leanexplore:386588 | leanexplore_sqlite | leanexplore_declarations | /-- `na.loop` mimics `na`, but can nondeterministically decide to "loop back" by identifing
an accepting state of `na` with a starting state of `na`. This identification is achieved
via a new dummy state `()`, which is the sole starting state and the sole accepting state
of `na.loop`. -/
def FinAcc.loop (na : FinAcc S... |
419 | leanexplore_declaration | leanexplore:386589 | leanexplore_sqlite | leanexplore_declarations | lemma loop_run_left_left {xs : ωSequence Symbol} {ss : ωSequence (Unit ⊕ State)}
(h : na.loop.Run xs ss) (h1 : (ss 1).isLeft) : [xs 0] ∈ language na := by
have h_init := h.start
simp only [FinAcc.loop, Set.mem_singleton_iff] at h_init
have h_step := h.trans 0
obtain ⟨t, h_t⟩ := isLeft_iff.mp h1
simp only ... |
796 | leanexplore_declaration | leanexplore:386590 | leanexplore_sqlite | leanexplore_declarations | lemma loop_run_left_right {xs : ωSequence Symbol} {ss : ωSequence (Unit ⊕ State)}
(h : na.loop.Run xs ss) (n : ℕ) (h1 : 0 < n) (h2 : ∀ k, 0 < k → k ≤ n → (ss k).isRight) :
∃ s t, na.MTr s (xs.take n) t ∧ s ∈ na.start ∧ ss n = inr t := by
obtain ⟨m, rfl⟩ := Nat.exists_eq_add_one.mpr h1
induction m
case zer... |
557 | leanexplore_declaration | leanexplore:386591 | leanexplore_sqlite | leanexplore_declarations | lemma loop_run_left_right_left {xs : ωSequence Symbol} {ss : ωSequence (Unit ⊕ State)}
(h : na.loop.Run xs ss) (n : ℕ) (h1 : 0 < n ∧ (ss n).isLeft)
(h2 : ∀ k, 0 < k → k < n → (ss k).isRight) : xs.take n ∈ language na := by
by_cases n = 1
· grind [loop_run_left_left]
· obtain ⟨s, t, h_mtr, _⟩ := loop_run_l... |
275 | leanexplore_declaration | leanexplore:386592 | leanexplore_sqlite | leanexplore_declarations | lemma loop_run_from_left {xs : ωSequence Symbol} {ss : ωSequence (Unit ⊕ State)}
(h : na.loop.Run xs ss) (n : ℕ) (h1 : (ss n).isLeft) :
na.loop.Run (xs.drop n) (ss.drop n) := by
apply Run.mk
· grind [FinAcc.loop, isLeft_iff.mp h1]
· grind [FinAcc.loop, h.trans] |
811 | leanexplore_declaration | leanexplore:386593 | leanexplore_sqlite | leanexplore_declarations | /-- A run of `na.loop` containing at least one non-initial `()` state is the concatenation
of a nonempty finite run of `na` followed by a run of `na.loop`. -/
theorem loop_run_one_iter {xs : ωSequence Symbol} {ss : ωSequence (Unit ⊕ State)} {k : ℕ}
(h : na.loop.Run xs ss) (h1 : 0 < k) (h2 : (ss k).isLeft) :
∃ n... |
898 | leanexplore_declaration | leanexplore:386594 | leanexplore_sqlite | leanexplore_declarations | /-- For any finite word in `language na`, there is a corresponding finite run of `na.loop`. -/
theorem loop_fin_run_exists {xl : List Symbol} (h : xl ∈ language na) :
∃ sl : List (Unit ⊕ State), ∃ _ : sl.length = xl.length + 1,
sl[0] = inl () ∧ sl[xl.length] = inl () ∧
∀ k, (_ : k < xl.length) → na.loop.Tr ... |
426 | leanexplore_declaration | leanexplore:386595 | leanexplore_sqlite | leanexplore_declarations | /-- For any finite word in `language na`, there is a corresponding multistep transition
of `na.loop`. -/
theorem loop_fin_run_mtr {xl : List Symbol} (h : xl ∈ language na) :
na.loop.MTr (inl ()) xl (inl ()) := by
obtain ⟨sl, _, _, _, h_run⟩ := loop_fin_run_exists h
suffices ∀ k, (_ : k ≤ xl.length) → na.loop.MT... |
757 | leanexplore_declaration | leanexplore:386596 | leanexplore_sqlite | leanexplore_declarations | /-- For any infinite sequence `xls` of nonempty finite words from `language na`,
there is an infinite run of `na.loop` corresponding to `xls.flatten` in which
the state `()` marks the boundaries between the finite words in `xls`. -/
theorem loop_run_exists [Inhabited Symbol] {xls : ωSequence (List Symbol)}
(h : ∀ k... |
999 | leanexplore_declaration | leanexplore:386597 | leanexplore_sqlite | leanexplore_declarations | /-- The Buchi ω-language accepted by `na.loop` is the ω-power of the language accepted by `na`. -/
@[simp]
theorem loop_language_eq [Inhabited Symbol] :
language (Buchi.mk na.loop {inl ()}) = (language na)^ω := by
apply le_antisymm
· apply omegaPow_coind
rintro xs ⟨ss, h_run, h_acc⟩
obtain ⟨k, h1, h2⟩ :... |
212 | leanexplore_declaration | leanexplore:386598 | leanexplore_sqlite | leanexplore_declarations | /-- `finLoop na` is the loop construction applied to the "totalized" version of `na`. -/
def finLoop (na : FinAcc State Symbol) : NA (Unit ⊕ (State ⊕ Unit)) Symbol :=
FinAcc.loop ⟨na.totalize, inl '' na.accept⟩ |
338 | leanexplore_declaration | leanexplore:386599 | leanexplore_sqlite | leanexplore_declarations | /-- `finLoop na` is total, assuming that `na` has at least one start state. -/
instance [h : Nonempty na.start] : na.finLoop.Total where
total s x := match s with
| inl _ => ⟨inr (inr ()), by simpa [finLoop, loop, NA.totalize, LTS.totalize] using h⟩
| inr _ => ⟨inr (inr ()), by grind [finLoop, loop, NA.totali... |
2,123 | leanexplore_declaration | leanexplore:386600 | leanexplore_sqlite | leanexplore_declarations | /-- `finLoop na` accepts the Kleene star of the language of `na`, assuming that
the latter is nonempty. -/
theorem loop_language_eq [Inhabited Symbol] (h : ¬ language na = 0) :
language (FinAcc.mk na.finLoop {inl ()}) = (language na)∗ := by
rw [Language.kstar_iff_mul_add]
ext xl; constructor
· rintro ⟨s, _, t... |
211 | leanexplore_declaration | leanexplore:386601 | leanexplore_sqlite | leanexplore_declarations | /-- `LTS.pairLang s t` is the language of finite words that can take the LTS
from state `s` to state `t`. -/
def LTS.pairLang (lts : LTS State Symbol) (s t : State) : Language Symbol :=
{ xs | lts.MTr s xs t } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.