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
264
leanexplore_declaration
leanexplore:387524
leanexplore_sqlite
leanexplore_declarations
theorem IsWeakBisimulation.isSwBisimulation [HasTau Label] {lts₁ : LTS State₁ Label} {lts₂ : LTS State₂ Label} {r : State₁ → State₂ → Prop} (h : IsWeakBisimulation lts₁ lts₂ r) : IsSWBisimulation lts₁ lts₂ r := isWeakBisimulation_iff_isSWBisimulation.1 h
264
leanexplore_declaration
leanexplore:387525
leanexplore_sqlite
leanexplore_declarations
theorem IsSWBisimulation.isWeakBisimulation [HasTau Label] {lts₁ : LTS State₁ Label} {lts₂ : LTS State₂ Label} {r : State₁ → State₂ → Prop} (h : IsSWBisimulation lts₁ lts₂ r) : IsWeakBisimulation lts₁ lts₂ r := isWeakBisimulation_iff_isSWBisimulation.2 h
457
leanexplore_declaration
leanexplore:387526
leanexplore_sqlite
leanexplore_declarations
/-- Weak bisimilarity can also be characterized through sw-bisimulations. -/ @[scoped grind =] theorem WeakBisimilarity.weakBisim_eq_swBisim [HasTau Label] (lts₁ : LTS State₁ Label) (lts₂ : LTS State₂ Label) : WeakBisimilarity lts₁ lts₂ = fun s₁ s₂ => ∃ r : State₁ → State₂ → Prop, r s₁ s₂ ∧ IsSWBisimulati...
295
leanexplore_declaration
leanexplore:387527
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous weak bisimilarity is reflexive. -/ theorem HomWeakBisimilarity.refl [HasTau Label] {lts : LTS State Label} (s : State) : s ≈[lts] s := by simp only [HomWeakBisimilarity] rw [WeakBisimilarity.weakBisim_eq_swBisim lts lts] exists Eq grind [IsSWBisimulation, STr.single]
398
leanexplore_declaration
leanexplore:387528
leanexplore_sqlite
leanexplore_declarations
/-- The inverse of a weak bisimulation is a weak bisimulation. -/ theorem IsWeakBisimulation.inv [HasTau Label] {lts₁ : LTS State₁ Label} {lts₂ : LTS State₂ Label} (r : State₁ → State₂ → Prop) (h : IsWeakBisimulation lts₁ lts₂ r) : IsWeakBisimulation lts₂ lts₁ (flip r) := by grind [IsWeakBisimulation.isSw...
275
leanexplore_declaration
leanexplore:387529
leanexplore_sqlite
leanexplore_declarations
/-- Weak bisimilarity is symmetric. -/ theorem WeakBisimilarity.symm [HasTau Label] {lts₁ : LTS State₁ Label} {lts₂ : LTS State₂ Label} (h : s₁ ≈[lts₁,lts₂] s₂) : s₂ ≈[lts₂,lts₁] s₁ := by obtain ⟨r, hr, hrh⟩ := h exists (flip r) grind [IsWeakBisimulation.inv, flip]
402
leanexplore_declaration
leanexplore:387530
leanexplore_sqlite
leanexplore_declarations
/-- The composition of two weak bisimulations is a weak bisimulation. -/ theorem IsWeakBisimulation.comp [HasTau Label] {lts₁ : LTS State₁ Label} {lts₂ : LTS State₂ Label} {lts₃ : LTS State₃ Label} (h1 : IsWeakBisimulation lts₁ lts₂ r1) (h2 : IsWeakBisimulation lts₂ lts₃ r2) : IsWeakBisimulation lts₁ lts₃ (...
436
leanexplore_declaration
leanexplore:387531
leanexplore_sqlite
leanexplore_declarations
/-- The composition of two sw-bisimulations is an sw-bisimulation. -/ theorem IsSWBisimulation.comp [HasTau Label] {lts₁ : LTS State₁ Label} {lts₂ : LTS State₂ Label} {lts₃ : LTS State₃ Label} (h1 : IsSWBisimulation lts₁ lts₂ r1) (h2 : IsSWBisimulation lts₂ lts₃ r2) : IsSWBisimulation lts₁ lts₃ (Relation.Co...
444
leanexplore_declaration
leanexplore:387532
leanexplore_sqlite
leanexplore_declarations
/-- Weak bisimilarity is transitive. -/ theorem WeakBisimilarity.trans [HasTau Label] {lts₁ : LTS State₁ Label} {lts₂ : LTS State₂ Label} {lts₃ : LTS State₃ Label} (h1 : s₁ ≈[lts₁,lts₂] s₂) (h2 : s₂ ≈[lts₂,lts₃] s₃) : s₁ ≈[lts₁,lts₃] s₃ := by obtain ⟨r1, hr1, hr1b⟩ := h1 obtain ⟨r2, hr2, hr2b⟩ := h2 exist...
286
leanexplore_declaration
leanexplore:387533
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous weak bisimilarity is an equivalence relation. -/ theorem HomWeakBisimilarity.eqv [HasTau Label] {lts : LTS State Label} : Equivalence (HomWeakBisimilarity lts) where refl := HomWeakBisimilarity.refl symm := WeakBisimilarity.symm trans := WeakBisimilarity.trans
149
leanexplore_declaration
leanexplore:387534
leanexplore_sqlite
leanexplore_declarations
/-- An infinite trace is divergent if every label within it is τ. -/ def DivergentTrace [HasTau Label] (μs : ωSequence Label) := ∀ i, μs i = HasTau.τ
212
leanexplore_declaration
leanexplore:387535
leanexplore_sqlite
leanexplore_declarations
/-- A state is divergent if there is a divergent execution from it. -/ def Divergent [HasTau Label] (lts : LTS State Label) (s : State) : Prop := ∃ ss μs, lts.OmegaExecution ss μs ∧ ss 0 = s ∧ DivergentTrace μs
331
leanexplore_declaration
leanexplore:387536
leanexplore_sqlite
leanexplore_declarations
/-- If a trace is divergent, then any 'suffix' is also divergent. -/ @[scoped grind ⇒] theorem divergentTrace_drop [HasTau Label] {μs : ωSequence Label} (h : DivergentTrace μs) (n : ℕ) : DivergentTrace (μs.drop n) := by intro m simp only [DivergentTrace] at h simp only [ωSequence.get_fun, ωSequence.dr...
170
leanexplore_declaration
leanexplore:387537
leanexplore_sqlite
leanexplore_declarations
/-- An LTS is divergence-free if it has no divergent state. -/ class DivergenceFree [HasTau Label] (lts : LTS State Label) where divergence_free : ¬∃ s, lts.Divergent s
359
leanexplore_declaration
leanexplore:387538
leanexplore_sqlite
leanexplore_declarations
/-- `Execution` extends `MTr` by providing the intermediate states of a multistep transition. -/ @[scoped grind =] def Execution (lts : LTS State Label) (s1 : State) (μs : List Label) (s2 : State) (ss : List State) : Prop := ∃ _ : ss.length = μs.length + 1, ss[0] = s1 ∧ ss[ss.length - 1] = s2 ∧ ∀ k, {_ : k < μs...
169
leanexplore_declaration
leanexplore:387539
leanexplore_sqlite
leanexplore_declarations
/-- Every execution has at least one intermediate state. -/ @[scoped grind →] theorem Execution.nonEmpty_states (h : lts.Execution s1 μs s2 ss) : ss ≠ [] := by grind
190
leanexplore_declaration
leanexplore:387540
leanexplore_sqlite
leanexplore_declarations
/-- Every state has an execution of zero steps terminating in itself. -/ @[scoped grind ⇒] theorem Execution.refl (lts : LTS State Label) (s : State) : lts.Execution s [] s [s] := by grind
214
leanexplore_declaration
leanexplore:387541
leanexplore_sqlite
leanexplore_declarations
/-- Equivalent of `MTr.stepL` for executions. -/ theorem Execution.stepL {lts : LTS State Label} (htr : lts.Tr s1 μ s2) (hexec : lts.Execution s2 μs s3 ss) : lts.Execution s1 (μ :: μs) s3 (s1 :: ss) := by grind
318
leanexplore_declaration
leanexplore:387542
leanexplore_sqlite
leanexplore_declarations
/-- Deconstruction of executions with `List.cons`. -/ theorem Execution.cons_invert (h : lts.Execution s1 (μ :: μs) s2 (s1 :: ss)) : lts.Execution (ss[0]'(by grind)) μs s2 ss := by obtain ⟨_, _, _, h4⟩ := h exists (by grind) constructorm* _∧_ · rfl · grind · intro k valid specialize h4 k <;> grind
412
leanexplore_declaration
leanexplore:387543
leanexplore_sqlite
leanexplore_declarations
/-- A multistep transition implies the existence of an execution. -/ @[scoped grind →] theorem Execution.of_mTr {lts : LTS State Label} {s1 : State} {μs : List Label} {s2 : State} (h : lts.MTr s1 μs s2) : ∃ ss : List State, lts.Execution s1 μs s2 ss := by induction h case refl t => use [t] grind c...
613
leanexplore_declaration
leanexplore:387544
leanexplore_sqlite
leanexplore_declarations
/-- Converts an execution into a multistep transition. -/ @[scoped grind →] theorem Execution.to_mTr (hexec : lts.Execution s1 μs s2 ss) : lts.MTr s1 μs s2 := by induction ss generalizing s1 μs case nil => grind case cons s1' ss ih => let ⟨hlen, hstart, hfinal, hexec'⟩ := hexec have : s1' = s1 := by g...
190
leanexplore_declaration
leanexplore:387545
leanexplore_sqlite
leanexplore_declarations
/-- Correspondence of multistep transitions and executions. -/ @[scoped grind =] theorem mTr_iff_execution : lts.MTr s1 μs s2 ↔ ∃ ss : List State, lts.Execution s1 μs s2 ss := by grind
738
leanexplore_declaration
leanexplore:387546
leanexplore_sqlite
leanexplore_declarations
/-- The composition of two executions is an execution. -/ theorem Execution.comp {lts : LTS State Label} {s r t : State} {μs1 μs2 : List Label} {ss1 ss2 : List State} (h1 : lts.Execution s μs1 r ss1) (h2 : lts.Execution r μs2 t ss2) : lts.Execution s (μs1 ++ μs2) t (ss1 ++ ss2.tail) := by have h0 : (ss1 +...
475
leanexplore_declaration
leanexplore:387547
leanexplore_sqlite
leanexplore_declarations
/-- An execution can be split at any intermediate state into two executions. -/ theorem Execution.split {lts : LTS State Label} {s t : State} {μs : List Label} {ss : List State} (he : lts.Execution s μs t ss) (n : ℕ) (hn : n ≤ μs.length) : lts.Execution s (μs.take n) (ss[n]'(by grind)) (ss.take (n + 1)) ∧ ...
367
leanexplore_declaration
leanexplore:387548
leanexplore_sqlite
leanexplore_declarations
/-- A multistep transition over a concatenation can be split into two multistep transitions. -/ theorem MTr.split {lts : LTS State Label} {s0 : State} {μs1 μs2 : List Label} {s2 : State} (h : lts.MTr s0 (μs1 ++ μs2) s2) : ∃ s1, lts.MTr s0 μs1 s1 ∧ lts.MTr s1 μs2 s2 := by obtain ⟨ss, h_ss⟩ := Execution.of_mTr h ...
190
leanexplore_declaration
leanexplore:387549
leanexplore_sqlite
leanexplore_declarations
/-- A type of transition labels that includes a special 'internal' transition `τ`. -/ class HasTau (Label : Type v) where /-- The internal transition label, also known as τ. -/ τ : Label
166
leanexplore_declaration
leanexplore:387550
leanexplore_sqlite
leanexplore_declarations
/-- Saturated τ-transition relation. -/ def τSTr [HasTau Label] (lts : LTS State Label) : State → State → Prop := Relation.ReflTransGen (Tr.toRelation lts HasTau.τ)
231
leanexplore_declaration
leanexplore:387551
leanexplore_sqlite
leanexplore_declarations
/-- Saturated transition relation. -/ inductive STr [HasTau Label] (lts : LTS State Label) : State → Label → State → Prop where | refl : lts.STr s HasTau.τ s | tr : lts.τSTr s1 s2 → lts.Tr s2 μ s3 → lts.τSTr s3 s4 → lts.STr s1 μ s4
73
leanexplore_declaration
leanexplore:387553
leanexplore_sqlite
leanexplore_declarations
| tr : lts.τSTr s1 s2 → lts.Tr s2 μ s3 → lts.τSTr s3 s4 → lts.STr s1 μ s4
183
leanexplore_declaration
leanexplore:387554
leanexplore_sqlite
leanexplore_declarations
/-- The `LTS` obtained by saturating the transition relation in `lts`. -/ @[scoped grind =] def saturate [HasTau Label] (lts : LTS State Label) : LTS State Label where Tr := lts.STr
122
leanexplore_declaration
leanexplore:387555
leanexplore_sqlite
leanexplore_declarations
@[scoped grind _=_] theorem saturate_tr_sTr [HasTau Label] {lts : LTS State Label} : lts.saturate.Tr = lts.STr := by rfl
193
leanexplore_declaration
leanexplore:387556
leanexplore_sqlite
leanexplore_declarations
/-- Any transition is also a saturated transition. -/ theorem STr.single [HasTau Label] (lts : LTS State Label) : lts.Tr s μ s' → lts.STr s μ s' := by intro h apply STr.tr .refl h .refl
438
leanexplore_declaration
leanexplore:387557
leanexplore_sqlite
leanexplore_declarations
/-- STr transitions labeled by HasTau.τ are exactly the τSTr transitions. -/ theorem sTr_τSTr [HasTau Label] (lts : LTS State Label) : lts.STr s HasTau.τ s' ↔ lts.τSTr s s' := by apply Iff.intro <;> intro h case mp => cases h case refl => exact .refl case tr _ _ h1 h2 h3 => exact (.trans h1 (.he...
576
leanexplore_declaration
leanexplore:387558
leanexplore_sqlite
leanexplore_declarations
/-- In a saturated LTS, the transition and saturated transition relations are the same. -/ theorem saturate_τSTr_τSTr [hHasTau : HasTau Label] (lts : LTS State Label) : lts.saturate.τSTr s = lts.τSTr s := by ext s'' apply Iff.intro <;> intro h case mp => induction h case refl => constructor case tai...
320
leanexplore_declaration
leanexplore:387559
leanexplore_sqlite
leanexplore_declarations
/-- Saturated transitions labelled by τ can be composed. -/ @[scoped grind .] theorem STr.trans_τ [HasTau Label] (lts : LTS State Label) (h1 : lts.STr s1 HasTau.τ s2) (h2 : lts.STr s2 HasTau.τ s3) : lts.STr s1 HasTau.τ s3 := by rw [sTr_τSTr _] at h1 h2 rw [sTr_τSTr _] apply Relation.ReflTransGen.trans h1 h2
459
leanexplore_declaration
leanexplore:387560
leanexplore_sqlite
leanexplore_declarations
/-- Saturated transitions can be composed. -/ theorem STr.comp [HasTau Label] (lts : LTS State Label) (h1 : lts.STr s1 HasTau.τ s2) (h2 : lts.STr s2 μ s3) (h3 : lts.STr s3 HasTau.τ s4) : lts.STr s1 μ s4 := by rw [sTr_τSTr _] at h1 h3 cases h2 case refl => rw [sTr_τSTr _] apply Relation.ReflTrans...
644
leanexplore_declaration
leanexplore:387561
leanexplore_sqlite
leanexplore_declarations
/-- In a saturated LTS, the transition and saturated transition relations are the same. -/ theorem saturate_tr_saturate_sTr [hHasTau : HasTau Label] (lts : LTS State Label) (hμ : μ = hHasTau.τ) : lts.saturate.Tr s μ = lts.saturate.STr s μ := by ext s' apply Iff.intro <;> intro h case mp => cases h case ...
193
leanexplore_declaration
leanexplore:387562
leanexplore_sqlite
leanexplore_declarations
/-- In a saturated LTS, every state is in its τ-image. -/ @[scoped grind .] theorem mem_saturate_image_τ [HasTau Label] (lts : LTS State Label) : s ∈ lts.saturate.image s HasTau.τ := STr.refl
250
leanexplore_declaration
leanexplore:387563
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. -/ def τClosure [HasTau Label] (lts : LTS State Label) (S : Set State) : Set State := lts.saturate.setImage S HasTau.τ
252
leanexplore_declaration
leanexplore:387564
leanexplore_sqlite
leanexplore_declarations
/-- We first define what is denoted Tran* in [WinskelNielsen1995]: the extension of a transition relation with idle transitions. -/ def LTS.withIdle (lts : LTS State Label) : LTS State (Option Label) := ⟨fun s l s' => l.elim (s = s') (lts.Tr s · s')⟩
356
leanexplore_declaration
leanexplore:387565
leanexplore_sqlite
leanexplore_declarations
/-- The definition of labelled transition system (with the type of states and the type of labels as part of the structure). -/ @[nolint checkUnivs] structure LTSCat : Type (max u v + 1) where /-- Type of states of an LTS -/ State : Type u /-- Type of labels of an LTS -/ Label : Type v /-- Transition relation ...
638
leanexplore_declaration
leanexplore:387566
leanexplore_sqlite
leanexplore_declarations
/-- A morphism between two labelled transition systems consists of (1) a function on states, (2) a partial function on labels, and a proof that (1) preserves each transition along (2). -/ structure LTS.Morphism (lts₁ lts₂ : LTSCat) : Type where /-- Mapping of states of `lts₁` to states of `lts₂` -/ stateMap : lts₁....
173
leanexplore_declaration
leanexplore:387567
leanexplore_sqlite
leanexplore_declarations
/-- The identity LTS morphism. -/ def LTS.Morphism.id (lts : LTSCat) : LTS.Morphism lts lts where stateMap := _root_.id labelMap := pure labelMap_tr _ _ _ := _root_.id
491
leanexplore_declaration
leanexplore:387568
leanexplore_sqlite
leanexplore_declarations
/-- Composition of LTS morphisms. We use Kleisli composition to define this. -/ def LTS.Morphism.comp {lts₁ lts₂ lts₃} (f : LTS.Morphism lts₁ lts₂) (g : LTS.Morphism lts₂ lts₃) : LTS.Morphism lts₁ lts₃ where stateMap := g.stateMap ∘ f.stateMap labelMap := f.labelMap >=> g.labelMap labelMap_tr s s' l h := by ...
360
leanexplore_declaration
leanexplore:387569
leanexplore_sqlite
leanexplore_declarations
/-- Finally, we prove that these form a category. -/ instance : CategoryTheory.Category LTSCat where Hom := LTS.Morphism id := LTS.Morphism.id comp := LTS.Morphism.comp comp_id _ := by simp only [LTS.Morphism.comp, LTS.Morphism.id] congr 1 rw [fish_pure] assoc _ _ _ := by simp only [LTS.Morphi...
1,301
leanexplore_declaration
leanexplore:387570
leanexplore_sqlite
leanexplore_declarations
/-- A command to create an `LTS` from a labelled transition `α → β → α → Prop`, robust to use of `variable `-/ elab "create_lts" lt:ident name:ident : command => do liftTermElabM do let lt ← realizeGlobalConstNoOverloadWithInfo lt let (declName, _) ← mkDeclName (← getCurrNamespace) default name.getId let ...
523
leanexplore_declaration
leanexplore:387571
leanexplore_sqlite
leanexplore_declarations
/-- This command adds transition notations for an `LTS`. This should not usually be called directly, but from the `lts` attribute. As an example `lts_transition_notation foo "β"` will add the notations "[⬝]⭢β" and "[⬝]↠β" Note that the string used will afterwards be registered as a notation. This means that i...
156
leanexplore_declaration
leanexplore:387572
leanexplore_sqlite
leanexplore_declarations
/-- This attribute calls the `lts_transition_notation` command for the annotated declaration. -/ syntax (name := lts_attr) "lts" ident (ppSpace str)? : attr
339
leanexplore_declaration
leanexplore:387573
leanexplore_sqlite
leanexplore_declarations
/-- An infinite execution is conceptually an infinite sequence of transitions. But it is technically more convenient to separate the states and the labels into two ω-sequences. -/ @[scoped grind] def OmegaExecution (lts : LTS State Label) (ss : ωSequence State) (μs : ωSequence Label) : Prop := ∀ i, lts.Tr (ss i) ...
262
leanexplore_declaration
leanexplore:387574
leanexplore_sqlite
leanexplore_declarations
/-- Any finite execution extracted from an infinite execution is valid. -/ theorem OmegaExecution.extract_execution (h : lts.OmegaExecution ss μs) {n m : ℕ} (hnm : n ≤ m) : lts.Execution (ss n) (μs.extract n m) (ss m) (ss.extract n (m + 1)) := by grind
272
leanexplore_declaration
leanexplore:387575
leanexplore_sqlite
leanexplore_declarations
/-- Any multistep transition extracted from an infinite execution is valid. -/ theorem OmegaExecution.extract_mTr (h : lts.OmegaExecution ss μs) {n m : ℕ} (hnm : n ≤ m) : lts.MTr (ss n) (μs.extract n m) (ss m) := by grind [OmegaExecution.extract_execution h hnm]
246
leanexplore_declaration
leanexplore:387576
leanexplore_sqlite
leanexplore_declarations
/-- Prepends an infinite execution with a transition. -/ theorem OmegaExecution.cons (htr : lts.Tr s μ t) (hωtr : lts.OmegaExecution ss μs) (hm : ss 0 = t) : lts.OmegaExecution (s ::ω ss) (μ ::ω μs) := by intro i induction i <;> grind
685
leanexplore_declaration
leanexplore:387577
leanexplore_sqlite
leanexplore_declarations
/-- Prepends an infinite execution with a finite execution. -/ theorem OmegaExecution.append (hmtr : lts.MTr s μl t) (hωtr : lts.OmegaExecution ss μs) (hm : ss 0 = t) : ∃ ss', lts.OmegaExecution ss' (μl ++ω μs) ∧ ss' 0 = s ∧ ss' μl.length = t ∧ ss'.drop μl.length = ss := by obtain ⟨sl, _, _, _, _⟩ := Ex...
1,892
leanexplore_declaration
leanexplore:387578
leanexplore_sqlite
leanexplore_declarations
/-- Concatenating an infinite sequence of finite executions. -/ theorem OmegaExecution.flatten_execution [Inhabited Label] {ts : ωSequence State} {μls : ωSequence (List Label)} {sls : ωSequence (List State)} (hexec : ∀ k, lts.Execution (ts k) (μls k) (ts (k + 1)) (sls k)) (hpos : ∀ k, (μls k).length > 0) : ...
633
leanexplore_declaration
leanexplore:387579
leanexplore_sqlite
leanexplore_declarations
/-- Concatenating an infinite sequence of multistep transitions. -/ theorem OmegaExecution.flatten_mTr [Inhabited Label] {ts : ωSequence State} {μls : ωSequence (List Label)} (hmtr : ∀ k, lts.MTr (ts k) (μls k) (ts (k + 1))) (hpos : ∀ k, (μls k).length > 0) : ∃ ss, lts.OmegaExecution ss μls.flatten ∧ ∀ k, s...
209
leanexplore_declaration
leanexplore:387580
leanexplore_sqlite
leanexplore_declarations
/-- Returns the relation that relates all states `s1` and `s2` via a fixed transition label `μ`. -/ def Tr.toRelation (lts : LTS State Label) (μ : Label) : State → State → Prop := fun s1 s2 => lts.Tr s1 μ s2
258
leanexplore_declaration
leanexplore:387581
leanexplore_sqlite
leanexplore_declarations
/-- Any homogeneous relation can be seen as an LTS where all transitions have the same label. -/ def Relation.toLTS [DecidableEq Label] (r : State → State → Prop) (μ : Label) : LTS State Label where Tr := fun s1 μ' s2 => if μ' = μ then r s1 s2 else False
228
leanexplore_declaration
leanexplore:387582
leanexplore_sqlite
leanexplore_declarations
/-- Returns the relation that relates all states `s1` and `s2` via a fixed list of transition labels `μs`. -/ def MTr.toRelation (lts : LTS State Label) (μs : List Label) : State → State → Prop := fun s1 s2 => lts.MTr s1 μs s2
305
leanexplore_declaration
leanexplore:387583
leanexplore_sqlite
leanexplore_declarations
/-- Transitions can be chained. -/ instance (lts : LTS State Label) : Trans (Tr.toRelation lts μ1) (Tr.toRelation lts μ2) (MTr.toRelation lts [μ1, μ2]) where trans := by intro s1 s2 s3 htr1 htr2 apply MTr.single at htr1 apply MTr.single at htr2 apply MTr.comp lts htr1 htr2
307
leanexplore_declaration
leanexplore:387584
leanexplore_sqlite
leanexplore_declarations
/-- Transitions can be chained with multi-step transitions. -/ instance (lts : LTS State Label) : Trans (Tr.toRelation lts μ) (MTr.toRelation lts μs) (MTr.toRelation lts (μ :: μs)) where trans := by intro s1 s2 s3 htr1 hmtr2 apply MTr.single at htr1 apply MTr.comp lts htr1 hmtr2
309
leanexplore_declaration
leanexplore:387585
leanexplore_sqlite
leanexplore_declarations
/-- Multi-step transitions can be chained with transitions. -/ instance (lts : LTS State Label) : Trans (MTr.toRelation lts μs) (Tr.toRelation lts μ) (MTr.toRelation lts (μs ++ [μ])) where trans := by intro s1 s2 s3 hmtr1 htr2 apply MTr.single at htr2 apply MTr.comp lts hmtr1 htr2
270
leanexplore_declaration
leanexplore:387586
leanexplore_sqlite
leanexplore_declarations
/-- Multi-step transitions can be chained. -/ instance (lts : LTS State Label) : Trans (MTr.toRelation lts μs1) (MTr.toRelation lts μs2) (MTr.toRelation lts (μs1 ++ μs2)) where trans := by intro s1 s2 s3 hmtr1 hmtr2 apply MTr.comp lts hmtr1 hmtr2
426
leanexplore_declaration
leanexplore:387587
leanexplore_sqlite
leanexplore_declarations
/-- A relation is a simulation if, whenever it relates two states in an lts, any transition originating from the first state is mimicked by a transition from the second state and the reached derivatives are themselves related. -/ def IsSimulation (lts₁ : LTS State₁ Label) (lts₂ : LTS State₂ Label) (r : State₁ → State₂ ...
158
leanexplore_declaration
leanexplore:387588
leanexplore_sqlite
leanexplore_declarations
/-- A homogeneous simulation is a simulation where the underlying LTSs are the same. -/ abbrev IsHomSimulation (lts : LTS State Label) := IsSimulation lts lts
248
leanexplore_declaration
leanexplore:387589
leanexplore_sqlite
leanexplore_declarations
/-- Two states are similar if they are related by some simulation. -/ def Similarity (lts₁ : LTS State₁ Label) (lts₂ : LTS State₂ Label) : State₁ → State₂ → Prop := fun s₁ s2 => ∃ r : State₁ → State₂ → Prop, r s₁ s2 ∧ IsSimulation lts₁ lts₂ r
217
leanexplore_declaration
leanexplore:387590
leanexplore_sqlite
leanexplore_declarations
/-- Notation for similarity. Differently from standard pen-and-paper presentations, we require the lts to be mentioned explicitly. -/ scoped notation s:max " ≤[" lts₁ "," lts₂ "] " s':max => Similarity lts₁ lts₂ s s'
150
leanexplore_declaration
leanexplore:387591
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous similarity is similarity where the underlying LTSs are the same. -/ abbrev HomSimilarity (lts : LTS State Label) := Similarity lts lts
113
leanexplore_declaration
leanexplore:387592
leanexplore_sqlite
leanexplore_declarations
/-- Notation for homogeneous similarity. -/ scoped notation s:max " ≤[" lts "] " s':max => HomSimilarity lts s s'
136
leanexplore_declaration
leanexplore:387593
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous similarity is reflexive. -/ theorem HomSimilarity.refl (s : State) : s ≤[lts] s := by exists Eq grind [IsSimulation]
610
leanexplore_declaration
leanexplore:387594
leanexplore_sqlite
leanexplore_declarations
/-- The composition of two simulations is a simulation. -/ theorem IsSimulation.comp (r1 : State₁ → State₂ → Prop) (r2 : State₂ → State₃ → Prop) (h1 : IsSimulation lts₁ lts₂ r1) (h2 : IsSimulation lts₂ lts₃ r2) : IsSimulation lts₁ lts₃ (Relation.Comp r1 r2) := by simp_all only [IsSimulation] intro s...
334
leanexplore_declaration
leanexplore:387595
leanexplore_sqlite
leanexplore_declarations
/-- Similarity is transitive. -/ theorem Similarity.trans (h1 : s₁ ≤[lts₁,lts₂] s2) (h2 : s2 ≤[lts₂,lts₃] s₃) : s₁ ≤[lts₁,lts₃] s₃ := by obtain ⟨r1, hr1, hr1s⟩ := h1 obtain ⟨r2, hr2, hr2s⟩ := h2 exists Relation.Comp r1 r2 constructor case left => exists s2 case right => apply IsSimulation.comp r...
284
leanexplore_declaration
leanexplore:387596
leanexplore_sqlite
leanexplore_declarations
/-- Simulation equivalence relates all states `s₁` and `s2` such that `s₁ ≤[lts₁ lts₂] s2` and `s2 ≤[lts₂ lts₁] s₁`. -/ def SimulationEquiv (lts₁ : LTS State₁ Label) (lts₂ : LTS State₂ Label) : State₁ → State₂ → Prop := fun s₁ s2 => s₁ ≤[lts₁, lts₂] s2 ∧ s2 ≤[lts₂, lts₁] s₁
132
leanexplore_declaration
leanexplore:387597
leanexplore_sqlite
leanexplore_declarations
/-- Notation for simulation equivalence. -/ scoped notation s:max " ≤≥[" lts₁ "," lts₂ "] " s':max => SimulationEquiv lts₁ lts₂ s s'
119
leanexplore_declaration
leanexplore:387598
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous simulation equivalence. -/ abbrev HomSimulationEquiv (lts : LTS State Label) := SimulationEquiv lts lts
131
leanexplore_declaration
leanexplore:387599
leanexplore_sqlite
leanexplore_declarations
/-- Notation for homogeneous simulation equivalence. -/ scoped notation s:max " ≤≥[" lts "] " s':max => HomSimulationEquiv lts s s'
165
leanexplore_declaration
leanexplore:387600
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous simulation equivalence is reflexive. -/ theorem HomSimulationEquiv.refl (s : State) : s ≤≥[lts] s := by grind [SimulationEquiv, HomSimilarity.refl]
169
leanexplore_declaration
leanexplore:387601
leanexplore_sqlite
leanexplore_declarations
/-- Simulation equivalence is symmetric. -/ theorem SimulationEquiv.symm {s₁ s2 : State} (h : s₁ ≤≥[lts₁,lts₂] s2) : s2 ≤≥[lts₂, lts₁] s₁ := by grind [SimulationEquiv]
204
leanexplore_declaration
leanexplore:387602
leanexplore_sqlite
leanexplore_declarations
/-- Simulation equivalence is transitive. -/ theorem SimulationEquiv.trans (h1 : s₁ ≤≥[lts₁,lts₂] s2) (h2 : s2 ≤≥[lts₂,lts₃] s₃) : s₁ ≤≥[lts₁,lts₃] s₃ := by grind [SimulationEquiv, Similarity.trans]
232
leanexplore_declaration
leanexplore:387603
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous simulation equivalence is an equivalence relation. -/ theorem HomSimulationEquiv.eqv : Equivalence (· ≤≥[lts] ·) where refl := HomSimulationEquiv.refl symm := SimulationEquiv.symm trans := SimulationEquiv.trans
203
leanexplore_declaration
leanexplore:387604
leanexplore_sqlite
leanexplore_declarations
/-- `calc` support for simulation equivalence. -/ instance : Trans (SimulationEquiv lts₁ lts₂) (SimulationEquiv lts₂ lts₃) (SimulationEquiv lts₁ lts₃) where trans := SimulationEquiv.trans
192
leanexplore_declaration
leanexplore:387605
leanexplore_sqlite
leanexplore_declarations
/-- A state 'may terminate' if it can reach a terminated state. The definition of `Terminated` is a parameter. -/ def MayTerminate (s : State) : Prop := ∃ s', Terminated s' ∧ lts.CanReach s s'
192
leanexplore_declaration
leanexplore:387606
leanexplore_sqlite
leanexplore_declarations
/-- A state 'is stuck' if it is not terminated and cannot go forward. The definition of `Terminated` is a parameter. -/ def Stuck (s : State) : Prop := ¬Terminated s ∧ ¬∃ μ s', lts.Tr s μ s'
195
leanexplore_declaration
leanexplore:387607
leanexplore_sqlite
leanexplore_declarations
/-- An LTS is total iff every state has a `μ`-derivative for every label `μ`. -/ class Total (lts : LTS State Label) where /-- The condition of being total. -/ total s μ : ∃ s', lts.Tr s μ s'
195
leanexplore_declaration
leanexplore:387608
leanexplore_sqlite
leanexplore_declarations
/-- Choose an FLTS that is a "sub-LTS" of a total LTS. -/ noncomputable def chooseFLTS (lts : LTS State Label) [h : lts.Total] : FLTS State Label where tr s μ := Classical.choose <| h.total s μ
245
leanexplore_declaration
leanexplore:387609
leanexplore_sqlite
leanexplore_declarations
/-- The FLTS chosen by `chooseFLTS` always provides legal transitions. -/ theorem Total.chooseFLTS (lts : LTS State Label) [h : lts.Total] (s : State) (μ : Label) : lts.Tr s μ (lts.chooseFLTS.tr s μ) := Classical.choose_spec <| h.total s μ
348
leanexplore_declaration
leanexplore:387610
leanexplore_sqlite
leanexplore_declarations
/-- `chooseOmegaExecution` builds an infinite execution of a total LTS from any starting state and over any infinite sequence of labels. -/ noncomputable def chooseOmegaExecution (lts : LTS State Label) [lts.Total] (s : State) (μs : ωSequence Label) : ℕ → State | 0 => s | n + 1 => lts.chooseFLTS.tr (lts.chooseO...
357
leanexplore_declaration
leanexplore:387611
leanexplore_sqlite
leanexplore_declarations
/-- If a LTS is total, then there exists an infinite execution from any starting state and over any infinite sequence of labels. -/ theorem Total.omegaExecution_exists [h : lts.Total] (s : State) (μs : ωSequence Label) : ∃ ss, lts.OmegaExecution ss μs ∧ ss 0 = s := by use lts.chooseOmegaExecution s μs grind [ch...
505
leanexplore_declaration
leanexplore:387612
leanexplore_sqlite
leanexplore_declarations
/-- If a LTS is total, then any finite execution can be extended to an infinite execution, provided that the label type is inbabited. -/ theorem Total.extend_omegaExecution [Inhabited Label] [ht : lts.Total] {μl : List Label} {s t : State} (hm : lts.MTr s μl t) : ∃ μs ss, lts.OmegaExecution ss (μl ++ω μs) ∧ ss ...
295
leanexplore_declaration
leanexplore:387613
leanexplore_sqlite
leanexplore_declarations
/-- `totalize` constructs a total LTS from any given LTS by adding a sink state. -/ def totalize (lts : LTS State Label) : LTS (State ⊕ Unit) Label where Tr s' μ t' := match s', t' with | Sum.inl s, Sum.inl t => lts.Tr s μ t | _, Sum.inr () => True | Sum.inr (), Sum.inl _ => False
151
leanexplore_declaration
leanexplore:387614
leanexplore_sqlite
leanexplore_declarations
/-- The LTS constructed by `totalize` is indeed total. -/ instance (lts : LTS State Label) : lts.totalize.Total where total _ _ := by simp [totalize]
387
leanexplore_declaration
leanexplore:387615
leanexplore_sqlite
leanexplore_declarations
/-- In `totalize`, there is no finite execution from the sink state to any non-sink state. -/ theorem totalize.no_sink_to_nonsink {μs : List Label} {t : State} : ¬ lts.totalize.MTr (Sum.inr ()) μs (Sum.inl t) := by intro h generalize h_s : (Sum.inr () : State ⊕ Unit) = s' generalize h_t : (Sum.inl t : State ⊕...
273
leanexplore_declaration
leanexplore:387616
leanexplore_sqlite
leanexplore_declarations
/-- In `totalize`, the transitions between non-sink states correspond exactly to the transitions in the original LTS. -/ @[simp] theorem totalize.nonsink_tr_iff {μ : Label} {s t : State} : lts.totalize.Tr (Sum.inl s) μ (Sum.inl t) ↔ lts.Tr s μ t := by simp [totalize]
868
leanexplore_declaration
leanexplore:387617
leanexplore_sqlite
leanexplore_declarations
/-- In `totalize`, the multistep transitions between non-sink states correspond exactly to the multistep transitions in the original LTS. -/ @[simp] theorem totalize.nonsink_mtr_iff {μs : List Label} {s t : State} : lts.totalize.MTr (Sum.inl s) μs (Sum.inl t) ↔ lts.MTr s μs t := by constructor <;> intro h · gen...
247
leanexplore_declaration
leanexplore:387618
leanexplore_sqlite
leanexplore_declarations
/-- The traces of a state `s` is the set of all lists of labels `μs` such that there is a multi-step transition labelled by `μs` originating from `s`. -/ def traces (lts : LTS State Label) (s : State) := { μs : List Label | ∃ s', lts.MTr s μs s' }
204
leanexplore_declaration
leanexplore:387619
leanexplore_sqlite
leanexplore_declarations
/-- If there is a multi-step transition from `s` labelled by `μs`, then `μs` is in the traces of `s`. -/ theorem traces_in {lts : LTS State Label} (h : lts.MTr s μs s') : μs ∈ lts.traces s := by exists s'
208
leanexplore_declaration
leanexplore:387620
leanexplore_sqlite
leanexplore_declarations
/-- Two states are trace equivalent if they have the same set of traces. -/ def TraceEq (lts₁ : LTS State₁ Label) (lts₂ : LTS State₂ Label) (s₁ : State₁) (s₂ : State₂) := lts₁.traces s₁ = lts₂.traces s₂
216
leanexplore_declaration
leanexplore:387621
leanexplore_sqlite
leanexplore_declarations
/-- Notation for trace equivalence. Differently from standard pen-and-paper presentations, we require the LTSs to be mentioned explicitly. -/ scoped notation s " ~tr[" lts₁ "," lts₂ "] " s' => TraceEq lts₁ lts₂ s s'
130
leanexplore_declaration
leanexplore:387622
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous trace equivalence compares states on the same LTS. -/ abbrev HomTraceEq (lts : LTS State Label) := TraceEq lts lts
119
leanexplore_declaration
leanexplore:387623
leanexplore_sqlite
leanexplore_declarations
/-- Notation for homogeneous trace equivalence. -/ scoped notation s:max " ~tr[" lts "] " s':max => HomTraceEq lts s s'
129
leanexplore_declaration
leanexplore:387624
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous trace equivalence is reflexive. -/ theorem HomTraceEq.refl (s : State) : s ~tr[lts] s := by simp only [TraceEq]