-
Notifications
You must be signed in to change notification settings - Fork 93
Define the category of LTSs #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
99efff2
ec7b48e
28840c2
33d6785
528040d
691b443
3a7993f
dc216e3
2d068c3
487c4f3
c942d95
dc6ba49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /- | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Ayberk Tosun | ||
| -/ | ||
|
|
||
| module | ||
|
|
||
| public import Cslib.Foundations.Semantics.LTS.Basic | ||
| public import Mathlib.CategoryTheory.Category.Basic | ||
| open Cslib | ||
|
|
||
| universe u v | ||
|
|
||
| @[expose] public section | ||
|
|
||
| variable {State Label : Type} | ||
|
|
||
| /-! | ||
| # Category of Labelled Transition Systems | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to add a reference. |
||
| -/ | ||
|
|
||
| /-! ## LTSs and LTS morphisms form a category -/ | ||
|
|
||
| /-- The notion of labelled transition system -/ | ||
| structure BundledLTS where | ||
| State : Type u | ||
| Label : Type v | ||
| lts : LTS State Label | ||
|
|
||
| /- Remark: I do not like the name 'bundled LTS'; and LTS is already the bundled notion. The name | ||
| `LTS` for the transition relation on a fixed set of states and labels is what is confusing here. | ||
| I propose to change that to `LTS-Structure` and call the above `LTS`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope not.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rest assured we will not change this name. As I say above, in alignment with Mathlib it should be
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also
makes me think we have a mismatch in terminology that might be a Lean colloquialism. Could you clarify what you mean by this @ayberkt? |
||
| -/ | ||
|
|
||
| /-! ## Definition of LTS morphism -/ | ||
|
|
||
| /-- | ||
| A morphism between two labelled transition systems consists of a function on | ||
| states, a function on labels, and a proof that transitions are preserved. | ||
| -/ | ||
| structure LTS.Morphism (lts₁ lts₂ : BundledLTS) : Type where | ||
| toFun : lts₁.State → lts₂.State | ||
| labelMap : lts₁.Label → lts₂.Label | ||
| fun_preserves_transitions : (s s' : lts₁.State) | ||
| → (l : lts₁.Label) | ||
| → lts₁.lts.Tr s l s' | ||
| → lts₂.lts.Tr (toFun s) (labelMap l) (toFun s') | ||
|
|
||
| /-- The identity LTS morphism. -/ | ||
| def LTS.Morphism.id (lts : BundledLTS) : LTS.Morphism lts lts := | ||
| { toFun := _root_.id | ||
| , labelMap := _root_.id | ||
| , fun_preserves_transitions := fun _ _ _ h => h | ||
| } | ||
|
|
||
| /-- Composition of LTS morphisms. -/ | ||
| def LTS.Morphism.comp {lts₁ lts₂ lts₃ : BundledLTS} : | ||
| LTS.Morphism lts₁ lts₂ → LTS.Morphism lts₂ lts₃ → LTS.Morphism lts₁ lts₃ := | ||
| fun ⟨f, μ, p⟩ ⟨g, ν, q⟩ => | ||
| let r := by intros _ _ _ h | ||
| apply q | ||
| apply p | ||
| exact h | ||
| ⟨g ∘ f, ν ∘ μ, r⟩ | ||
|
|
||
| /-- `LTS.Morphism` provides a category structure on bundled LTSs. -/ | ||
| instance : CategoryTheory.CategoryStruct BundledLTS where | ||
| Hom lts₁ lts₂ := LTS.Morphism lts₁ lts₂ | ||
| id lts := LTS.Morphism.id lts | ||
| comp {lts₁} {lts₂} {lts₃} f g := @LTS.Morphism.comp lts₁ lts₂ lts₃ f g | ||
|
|
||
| /-- Proof that the above structure actually forms a category. -/ | ||
| instance : CategoryTheory.Category BundledLTS where | ||
| id_comp := by intro _ _ f | ||
| cases f | ||
| rfl | ||
| comp_id := by intro _ _ f | ||
| cases f | ||
| rfl | ||
| assoc := by intro _ _ _ _ f g h | ||
| cases f | ||
| cases g | ||
| cases h | ||
| rfl | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I see below, you don't need these lts variables that much? Consider removing them maybe?