Documentation

Cslib.Semantics.Lts.Basic

Labelled Transition System (LTS) #

A Labelled Transition System (Lts) models the observable behaviour of the possible states of a system. They are particularly popular in the fields of concurrency theory, logic, and programming languages.

Main definitions #

Main statements #

References #

structure Lts (State : Type u) (Label : Type v) :
Type (max u v)

A Labelled Transition System (Lts) consists of a type of states (State), a type of transition labels (Label), and a labelled transition relation (Tr).

  • Tr : StateLabelStateProp

    The transition relation.

Instances For

    Multi-step transitions #

    inductive Lts.MTr {State : Type u} {Label : Type v} (lts : Lts State Label) :
    StateList LabelStateProp

    Definition of a multi-step transition.

    (Implementation note: compared to [Mon23], we choose stepL instead of stepR as fundamental rule. This makes working with lists of labels more convenient, because we follow the same construction. It is also similar to what is done in the SimpleGraph library in mathlib.)

    • refl {State : Type u} {Label : Type v} {lts : Lts State Label} {s : State} : lts.MTr s [] s
    • stepL {State : Type u} {Label : Type v} {lts : Lts State Label} {s1 : State} {μ : Label} {s2 : State} {μs : List Label} {s3 : State} : lts.Tr s1 μ s2lts.MTr s2 μs s3lts.MTr s1 (μ :: μs) s3
    Instances For
      theorem Lts.MTr.single {State : Type u} {Label : Type v} (lts : Lts State Label) {s1 : State} {μ : Label} {s2 : State} :
      lts.Tr s1 μ s2lts.MTr s1 [μ] s2

      Any transition is also a multi-step transition.

      theorem Lts.MTr.stepR {State : Type u} {Label : Type v} (lts : Lts State Label) {s1 : State} {μs : List Label} {s2 : State} {μ : Label} {s3 : State} :
      lts.MTr s1 μs s2lts.Tr s2 μ s3lts.MTr s1 (μs ++ [μ]) s3

      Any multi-step transition can be extended by adding a transition.

      theorem Lts.MTr.comp {State : Type u} {Label : Type v} (lts : Lts State Label) {s1 : State} {μs1 : List Label} {s2 : State} {μs2 : List Label} {s3 : State} :
      lts.MTr s1 μs1 s2lts.MTr s2 μs2 s3lts.MTr s1 (μs1 ++ μs2) s3

      Multi-step transitions can be composed.

      theorem Lts.MTr.single_invert {State : Type u} {Label : Type v} (lts : Lts State Label) (s1 : State) (μ : Label) (s2 : State) :
      lts.MTr s1 [μ] s2lts.Tr s1 μ s2

      Any 1-sized multi-step transition implies a transition with the same states and label.

      theorem Lts.MTr.nil_eq {State : Type u} {Label : Type v} (lts : Lts State Label) {s1 s2 : State} (h : lts.MTr s1 [] s2) :
      s1 = s2

      In any zero-steps multi-step transition, the origin and the derivative are the same.

      def Lts.CanReach {State : Type u} {Label : Type v} (lts : Lts State Label) (s1 s2 : State) :

      A state s1 can reach a state s2 if there exists a multi-step transition from s1 to s2.

      Equations
      Instances For
        theorem Lts.CanReach.refl {State : Type u} {Label : Type v} (lts : Lts State Label) (s : State) :
        lts.CanReach s s

        Any state can reach itself.

        def Lts.generatedBy {State : Type u} {Label : Type v} (lts : Lts State Label) (s : State) :
        Lts { s' : State // lts.CanReach s s' } Label

        The Lts generated by a state s is the Lts given by all the states reachable from s.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Definitions about termination #

          def Lts.MayTerminate {State : Type u_1} {Label : Type u_2} (lts : Lts State Label) {Terminated : StateProp} (s : State) :

          A state 'may terminate' if it can reach a terminated state. The definition of Terminated is a parameter.

          Equations
          Instances For
            def Lts.Stuck {State : Type u_1} {Label : Type u_2} (lts : Lts State Label) {Terminated : StateProp} (s : State) :

            A state 'is stuck' if it is not terminated and cannot go forward. The definition of Terminated is a parameter.

            Equations
            • lts.Stuck s = (¬Terminated s ¬∃ (μ : Label) (s' : State), lts.Tr s μ s')
            Instances For

              Definitions for the unions of Ltss #

              Note: there is a nontrivial balance between ergonomics and generality here. These definitions might change in the future.

              def Lts.unionSubtype {State : Type u} {Label : Type v} {S1 : StateProp} {L1 : LabelProp} {S2 : StateProp} {L2 : LabelProp} [DecidablePred S1] [DecidablePred L1] [DecidablePred S2] [DecidablePred L2] (lts1 : Lts (Subtype S1) (Subtype L1)) (lts2 : Lts (Subtype S2) (Subtype L2)) :
              Lts State Label

              The union of two Ltss that have common supertypes for states and labels.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Sum.isLeftP {α : Type u_1} {β : Type u_2} (x : α β) :

                TODO: move this to Sum?

                Equations
                Instances For
                  def Sum.isRightP {α : Type u_1} {β : Type u_2} (x : α β) :

                  TODO: move this to Sum?

                  Equations
                  Instances For
                    def Lts.inl {State : Type u} {Label : Type v} {State' : Type u_1} (lts : Lts State Label) :

                    Lifting of an Lts State Label to Lts (State ⊕ State') Label.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def Lts.inr {State : Type u} {Label : Type v} {State' : Type u_1} (lts : Lts State Label) :

                      Lifting of an Lts State Label to Lts (State' ⊕ State) Label.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def Lts.unionSum {Label : Type v} {State1 : Type u_1} {State2 : Type u_2} (lts1 : Lts State1 Label) (lts2 : Lts State2 Label) :
                        Lts (State1 State2) Label

                        Union of two Ltss with the same Label type. The result combines the original respective state types State1 and State2 into (State1 ⊕ State2).

                        Equations
                        Instances For

                          Classes of Ltss #

                          def Lts.Deterministic {State : Type u} {Label : Type v} (lts : Lts State Label) :

                          An lts is deterministic if a state cannot reach different states with the same transition label.

                          Equations
                          • lts.Deterministic = ∀ (s1 : State) (μ : Label) (s2 s3 : State), lts.Tr s1 μ s2lts.Tr s1 μ s3s2 = s3
                          Instances For
                            def Lts.Image {State : Type u} {Label : Type v} (lts : Lts State Label) (s : State) (μ : Label) :
                            Set State

                            The μ-image of a state s is the set of all μ-derivatives of s.

                            Equations
                            Instances For
                              def Lts.ImageFinite {State : Type u} {Label : Type v} (lts : Lts State Label) :

                              An lts is image-finite if all images of its states are finite.

                              Equations
                              Instances For
                                theorem Lts.deterministic_not_lto {State : Type u} {Label : Type v} (lts : Lts State Label) (hDet : lts.Deterministic) (s : State) (μ : Label) (s' s'' : State) :
                                s' s''lts.Tr s μ s'¬lts.Tr s μ s''

                                In a deterministic Lts, if a state has a μ-derivative, then it can have no other μ-derivative.

                                theorem Lts.deterministic_image_char {State : Type u} {Label : Type v} (lts : Lts State Label) (hDet : lts.Deterministic) (s : State) (μ : Label) :
                                (∃ (s' : State), lts.Image s μ = {s'}) lts.Image s μ =

                                In a deterministic Lts, any image is either a singleton or the empty set.

                                theorem Lts.deterministic_imageFinite {State : Type u} {Label : Type v} (lts : Lts State Label) :

                                Every deterministic Lts is also image-finite.

                                def Lts.HasOutLabel {State : Type u} {Label : Type v} (lts : Lts State Label) (s : State) (μ : Label) :

                                A state has an outgoing label μ if it has a μ-derivative.

                                Equations
                                Instances For
                                  def Lts.OutgoingLabels {State : Type u} {Label : Type v} (lts : Lts State Label) (s : State) :
                                  Set Label

                                  The set of outgoing labels of a state.

                                  Equations
                                  Instances For
                                    def Lts.FinitelyBranching {State : Type u} {Label : Type v} (lts : Lts State Label) :

                                    An Lts is finitely branching if it is image-finite and all states have finite sets of outgoing labels.

                                    Equations
                                    Instances For
                                      def Lts.FiniteState {State : Type u} {Label : Type v} :
                                      Lts State LabelProp

                                      An Lts is finite-state if it has a finite State type.

                                      Equations
                                      Instances For
                                        theorem Lts.finiteState_imageFinite {State : Type u} {Label : Type v} (lts : Lts State Label) (hFinite : lts.FiniteState) :

                                        Every finite-state Lts is also image-finite.

                                        theorem Lts.finiteState_finitelyBranching {State : Type u} {Label : Type v} (lts : Lts State Label) (hFiniteLabel : _root_.Finite Label) (hFiniteState : lts.FiniteState) :

                                        Every Lts with finite types for states and labels is also finitely branching.

                                        def Lts.Acyclic {State : Type u} {Label : Type v} (lts : Lts State Label) :

                                        An Lts is acyclic if there are no infinite multi-step transitions.

                                        Equations
                                        Instances For
                                          def Lts.Finite {State : Type u} {Label : Type v} (lts : Lts State Label) :

                                          An Lts is finite if it is finite-state and acyclic.

                                          Equations
                                          Instances For

                                            Weak transitions (single- and multi-step) #

                                            class HasTau (Label : Type v) :

                                            A type of transition labels that includes a special 'internal' transition τ.

                                            • τ : Label
                                            Instances
                                              inductive Lts.STr {Label : Type u_1} {State : Type u_2} [HasTau Label] (lts : Lts State Label) :
                                              StateLabelStateProp

                                              Saturated transition relation.

                                              Instances For
                                                def Lts.saturate {Label : Type u_1} {State : Type u_2} [HasTau Label] (lts : Lts State Label) :
                                                Lts State Label

                                                The Lts obtained by saturating the transition relation in lts.

                                                Equations
                                                Instances For
                                                  theorem Lts.STr.single {Label : Type u_1} {State : Type u_2} {s : State} {μ : Label} {s' : State} [HasTau Label] (lts : Lts State Label) :
                                                  lts.Tr s μ s'lts.STr s μ s'

                                                  Any transition is also a saturated transition.

                                                  inductive Lts.strN {Label : Type u_1} {State : Type u_2} [HasTau Label] (lts : Lts State Label) :
                                                  StateLabelStateProp

                                                  As Lts.str, but counts the number of τ-transitions. This is convenient as induction metric.

                                                  Instances For
                                                    theorem Lts.str_strN {Label : Type u_1} {State : Type u_2} {s1 : State} {μ : Label} {s2 : State} [HasTau Label] (lts : Lts State Label) :
                                                    lts.STr s1 μ s2 ∃ (n : ), lts.strN n s1 μ s2

                                                    Lts.str and Lts.strN are equivalent.

                                                    @[irreducible]
                                                    theorem Lts.strN.trans_τ {Label : Type u_1} {State : Type u_2} {n : } {s1 s2 : State} {m : } {s3 : State} [HasTau Label] (lts : Lts State Label) (h1 : lts.strN n s1 HasTau.τ s2) (h2 : lts.strN m s2 HasTau.τ s3) :
                                                    lts.strN (n + m) s1 HasTau.τ s3

                                                    Saturated transitions labelled by τ can be composed (weighted version).

                                                    theorem Lts.STr.trans_τ {Label : Type u_1} {State : Type u_2} {s1 s2 s3 : State} [HasTau Label] (lts : Lts State Label) (h1 : lts.STr s1 HasTau.τ s2) (h2 : lts.STr s2 HasTau.τ s3) :
                                                    lts.STr s1 HasTau.τ s3

                                                    Saturated transitions labelled by τ can be composed.

                                                    theorem Lts.strN.append {Label : Type u_1} {State : Type u_2} {n1 : } {s1 : State} {μ : Label} {s2 : State} {n2 : } {s3 : State} [HasTau Label] (lts : Lts State Label) (h1 : lts.strN n1 s1 μ s2) (h2 : lts.strN n2 s2 HasTau.τ s3) :
                                                    lts.strN (n1 + n2) s1 μ s3

                                                    Saturated transitions can be appended with τ-transitions (weighted version).

                                                    theorem Lts.strN.comp {Label : Type u_1} {State : Type u_2} {n1 : } {s1 s2 : State} {n2 : } {μ : Label} {s3 : State} {n3 : } {s4 : State} [HasTau Label] (lts : Lts State Label) (h1 : lts.strN n1 s1 HasTau.τ s2) (h2 : lts.strN n2 s2 μ s3) (h3 : lts.strN n3 s3 HasTau.τ s4) :
                                                    lts.strN (n1 + n2 + n3) s1 μ s4

                                                    Saturated transitions can be composed (weighted version).

                                                    theorem Lts.STr.comp {Label : Type u_1} {State : Type u_2} {s1 s2 : State} {μ : Label} {s3 s4 : State} [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

                                                    Saturated transitions can be composed.

                                                    Divergence #

                                                    def Lts.DivergentExecution {Label : Type u_1} {State : Type u_2} [HasTau Label] (lts : Lts State Label) (stream : Stream' State) :

                                                    A divergent execution is a stream of states where each state is the anti-τ-derivative of the next.

                                                    Equations
                                                    Instances For
                                                      def Lts.Divergent {Label : Type u_1} {State : Type u_2} [HasTau Label] (lts : Lts State Label) (s : State) :

                                                      A state is divergent if there is a divergent execution from it.

                                                      Equations
                                                      Instances For
                                                        theorem Lts.divergent_drop {Label : Type u_1} {State : Type u_2} [HasTau Label] (lts : Lts State Label) (stream : Stream' State) (h : lts.DivergentExecution stream) (n : ) :

                                                        If a stream is a divergent execution, then any 'suffix' is also a divergent execution.

                                                        def Lts.DivergenceFree {Label : Type u_1} {State : Type u_2} [HasTau Label] (lts : Lts State Label) :

                                                        An Lts is divergence-free if it has no divergent state.

                                                        Equations
                                                        Instances For
                                                          def Lts.Tr.toRelation {State : Type u_1} {Label : Type u_2} (lts : Lts State Label) (μ : Label) :
                                                          StateStateProp

                                                          Returns the relation that relates all states s1 and s2 via a fixed transition label μ.

                                                          Equations
                                                          Instances For
                                                            def Lts.MTr.toRelation {State : Type u_1} {Label : Type u_2} (lts : Lts State Label) (μs : List Label) :
                                                            StateStateProp

                                                            Returns the relation that relates all states s1 and s2 via a fixed list of transition labels μs.

                                                            Equations
                                                            Instances For
                                                              def Relation.toLts {Label : Type u_1} {State : Type u_2} [DecidableEq Label] (r : StateStateProp) (μ : Label) :
                                                              Lts State Label

                                                              Any homogeneous relation can be seen as an Lts where all transitions have the same label.

                                                              Equations
                                                              Instances For

                                                                Support for the calc tactic #

                                                                instance instTransToRelationToRelationConsNil {State : Type u_1} {Label : Type u_2} {μ1 μ2 : Label} (lts : Lts State Label) :

                                                                Transitions can be chained.

                                                                Equations
                                                                instance instTransToRelationToRelationCons {State : Type u_1} {Label : Type u_2} {μ : Label} {μs : List Label} (lts : Lts State Label) :

                                                                Transitions can be chained with multi-step transitions.

                                                                Equations
                                                                instance instTransToRelationToRelationHAppendListConsNil {State : Type u_1} {Label : Type u_2} {μs : List Label} {μ : Label} (lts : Lts State Label) :

                                                                Multi-step transitions can be chained with transitions.

                                                                Equations
                                                                instance instTransToRelationHAppendList {State : Type u_1} {Label : Type u_2} {μs1 μs2 : List Label} (lts : Lts State Label) :
                                                                Trans (Lts.MTr.toRelation lts μs1) (Lts.MTr.toRelation lts μs2) (Lts.MTr.toRelation lts (μs1 ++ μs2))

                                                                Multi-step transitions can be chained.

                                                                Equations

                                                                A command to create an Lts from a labelled transition α → β → α → Prop, robust to use of variable

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For

                                                                  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 if you have also used this as a constructor name, you will need quotes to access corresponding cases, e.g. «β» in the above example.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For

                                                                    This attribute calls the lts_transition_notation command for the annotated declaration.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For