@@ -57,6 +57,15 @@ structure LTS (State : Type u) (Label : Type v) where
5757 /-- The transition relation. -/
5858 Tr : State → Label → State → Prop
5959
60+ /-- Returns the relation that relates all states `s1` and `s2` via a fixed transition label `μ`. -/
61+ def LTS.Tr.toRelation (lts : LTS State Label) (μ : Label) : State → State → Prop :=
62+ fun s1 s2 => lts.Tr s1 μ s2
63+
64+ /-- Any homogeneous relation can be seen as an LTS where all transitions have the same label. -/
65+ def Relation.toLTS [DecidableEq Label] (r : State → State → Prop ) (μ : Label) :
66+ LTS State Label where
67+ Tr := fun s1 μ' s2 => if μ' = μ then r s1 s2 else False
68+
6069section MultiStep
6170
6271/-! ## Multi-step transitions -/
@@ -158,6 +167,57 @@ theorem LTS.CanReach.refl (s : State) : lts.CanReach s s := by
158167def LTS.generatedBy (s : State) : LTS {s' : State // lts.CanReach s s'} Label where
159168 Tr := fun s1 μ s2 => lts.CanReach s s1 ∧ lts.CanReach s s2 ∧ lts.Tr s1 μ s2
160169
170+ /-- Returns the relation that relates all states `s1` and `s2` via a fixed list of transition
171+ labels `μs`. -/
172+ def LTS.MTr.toRelation (lts : LTS State Label) (μs : List Label) : State → State → Prop :=
173+ fun s1 s2 => lts.MTr s1 μs s2
174+
175+ /-! ### Calc tactic support for MTr -/
176+
177+ /-- Transitions can be chained. -/
178+ instance (lts : LTS State Label) :
179+ Trans
180+ (LTS.Tr.toRelation lts μ1 )
181+ (LTS.Tr.toRelation lts μ2 )
182+ (LTS.MTr.toRelation lts [μ1 , μ2 ]) where
183+ trans := by
184+ intro s1 s2 s3 htr1 htr2
185+ apply LTS.MTr.single at htr1
186+ apply LTS.MTr.single at htr2
187+ apply LTS.MTr.comp lts htr1 htr2
188+
189+ /-- Transitions can be chained with multi-step transitions. -/
190+ instance (lts : LTS State Label) :
191+ Trans
192+ (LTS.Tr.toRelation lts μ)
193+ (LTS.MTr.toRelation lts μs)
194+ (LTS.MTr.toRelation lts (μ :: μs)) where
195+ trans := by
196+ intro s1 s2 s3 htr1 hmtr2
197+ apply LTS.MTr.single at htr1
198+ apply LTS.MTr.comp lts htr1 hmtr2
199+
200+ /-- Multi-step transitions can be chained with transitions. -/
201+ instance (lts : LTS State Label) :
202+ Trans
203+ (LTS.MTr.toRelation lts μs)
204+ (LTS.Tr.toRelation lts μ)
205+ (LTS.MTr.toRelation lts (μs ++ [μ])) where
206+ trans := by
207+ intro s1 s2 s3 hmtr1 htr2
208+ apply LTS.MTr.single at htr2
209+ apply LTS.MTr.comp lts hmtr1 htr2
210+
211+ /-- Multi-step transitions can be chained. -/
212+ instance (lts : LTS State Label) :
213+ Trans
214+ (LTS.MTr.toRelation lts μs1)
215+ (LTS.MTr.toRelation lts μs2)
216+ (LTS.MTr.toRelation lts (μs1 ++ μs2)) where
217+ trans := by
218+ intro s1 s2 s3 hmtr1 hmtr2
219+ apply LTS.MTr.comp lts hmtr1 hmtr2
220+
161221end MultiStep
162222
163223section Termination
@@ -580,74 +640,6 @@ class LTS.DivergenceFree [HasTau Label] (lts : LTS State Label) where
580640
581641end Divergence
582642
583- section Relation
584-
585- /-- Returns the relation that relates all states `s1` and `s2` via a fixed transition label `μ`. -/
586- def LTS.Tr.toRelation (lts : LTS State Label) (μ : Label) : State → State → Prop :=
587- fun s1 s2 => lts.Tr s1 μ s2
588-
589- /-- Returns the relation that relates all states `s1` and `s2` via a fixed list of transition
590- labels `μs`. -/
591- def LTS.MTr.toRelation (lts : LTS State Label) (μs : List Label) : State → State → Prop :=
592- fun s1 s2 => lts.MTr s1 μs s2
593-
594- /-- Any homogeneous relation can be seen as an LTS where all transitions have the same label. -/
595- def Relation.toLTS [DecidableEq Label] (r : State → State → Prop ) (μ : Label) :
596- LTS State Label where
597- Tr := fun s1 μ' s2 => if μ' = μ then r s1 s2 else False
598-
599- end Relation
600-
601- section Trans
602-
603- /-! ## Support for the calc tactic -/
604-
605- /-- Transitions can be chained. -/
606- instance (lts : LTS State Label) :
607- Trans
608- (LTS.Tr.toRelation lts μ1 )
609- (LTS.Tr.toRelation lts μ2 )
610- (LTS.MTr.toRelation lts [μ1 , μ2 ]) where
611- trans := by
612- intro s1 s2 s3 htr1 htr2
613- apply LTS.MTr.single at htr1
614- apply LTS.MTr.single at htr2
615- apply LTS.MTr.comp lts htr1 htr2
616-
617- /-- Transitions can be chained with multi-step transitions. -/
618- instance (lts : LTS State Label) :
619- Trans
620- (LTS.Tr.toRelation lts μ)
621- (LTS.MTr.toRelation lts μs)
622- (LTS.MTr.toRelation lts (μ :: μs)) where
623- trans := by
624- intro s1 s2 s3 htr1 hmtr2
625- apply LTS.MTr.single at htr1
626- apply LTS.MTr.comp lts htr1 hmtr2
627-
628- /-- Multi-step transitions can be chained with transitions. -/
629- instance (lts : LTS State Label) :
630- Trans
631- (LTS.MTr.toRelation lts μs)
632- (LTS.Tr.toRelation lts μ)
633- (LTS.MTr.toRelation lts (μs ++ [μ])) where
634- trans := by
635- intro s1 s2 s3 hmtr1 htr2
636- apply LTS.MTr.single at htr2
637- apply LTS.MTr.comp lts hmtr1 htr2
638-
639- /-- Multi-step transitions can be chained. -/
640- instance (lts : LTS State Label) :
641- Trans
642- (LTS.MTr.toRelation lts μs1)
643- (LTS.MTr.toRelation lts μs2)
644- (LTS.MTr.toRelation lts (μs1 ++ μs2)) where
645- trans := by
646- intro s1 s2 s3 hmtr1 hmtr2
647- apply LTS.MTr.comp lts hmtr1 hmtr2
648-
649- end Trans
650-
651643open Lean Elab Meta Command Term
652644
653645/-- A command to create an `LTS` from a labelled transition `α → β → α → Prop`, robust to use of
0 commit comments