Documentation

VerifiedMBSE.Behavior.StateMachine

State Machine: Dependently Typed Behavioral Model #

Defines Transition (with invariant preservation embedded as a type-level proof), StateMachine, the inductive proposition Reachable, and the safety theorem Reachable.inv_holds.

Key Design Decision #

Embedding invariant preservation in Transition.preserves makes transitions that violate the invariant unconstructible (type error).

structure VerifiedMBSE.Behavior.Transition (S D : Type) (inv : SDProp) :

Transition: transition defined over control state S and data type D. The preserves field guarantees invariant preservation at the type level.

  • source : S

    Source control state

  • target : S

    Target control state

  • guard : DProp

    Guard condition

  • effect : DD

    Effect (data transformation)

  • preserves (d : D) : self.guard dinv self.source dinv self.target (self.effect d)

    Type-level contract for invariant preservation

Instances For
    structure VerifiedMBSE.Behavior.StateMachine (S D : Type) (inv : SDProp) :

    StateMachine: state machine consisting of an initial state and a list of transitions.

    • initialState : S

      Initial control state

    • transitions : List (Transition S D inv)

      List of transitions

    Instances For
      def VerifiedMBSE.Behavior.StateMachine.WellFormed {S D : Type} {inv : SDProp} (sm : StateMachine S D inv) :

      Well-formedness of StateMachine: data satisfying the invariant exists in the initial state.

      Equations
      Instances For
        inductive VerifiedMBSE.Behavior.Reachable {S D : Type} {inv : SDProp} (sm : StateMachine S D inv) :
        SDProp

        Reachable: inductive proposition for reachable (control state, data value) pairs. Tracking both enables induction for inv_holds.

        Instances For
          theorem VerifiedMBSE.Behavior.Reachable.inv_holds {S D : Type} {inv : SDProp} {sm : StateMachine S D inv} {s : S} {d : D} (h : Reachable sm s d) :
          inv s d

          Safety theorem: all reachable pairs satisfy the invariant. Directly provable by induction since Transition.preserves is embedded in the type.

          theorem VerifiedMBSE.Behavior.StateMachine.initial_inv_holds {S D : Type} {inv : SDProp} {sm : StateMachine S D inv} (hwf : sm.WellFormed) :
          (d : D), inv sm.initialState d

          The initial state of a WellFormed state machine has data satisfying the invariant.