package fsml
Module Fsml.FsmSource
Finite State Machines
type t = {id : string;(*Name
*)states : (State.t * Valuation.t) list;inps : (string * Types.t) list;(*Inputs
*)outps : (string * Types.t) list;(*Outputs
*)vars : (string * Types.t) list;(*Local variables
*)trans : Transition.t list;itrans : State.t * Action.t list;(*Initial transition
*)
}The static description of a FSM
Transformation functions
mealy_outps os m returns the FSM obtained by moving the assignation of outputs listed in outps from states to all incoming transitions. When the outps parameter is empty or omitted, the transformation is applied to all outputs occuring in each state. Raises Unknown_output if outps contains a symbol not declared as output.
moore_outps os m is the dual function of mealy_outps. For each output o listed in in outps, whenever all transitions leading to a state s carry the same action o:=v, it removes these actions and adds the assignation o=v to state s. The transformation is not applied if
- the corresponding action does not occur on all transitions leading to state
s, - the value assigned to output
ois not a constant, - not all actions assign the same value to
oIfoutpsis omitted ot empty, the transformation is applied to all outputs. RaisesUnknown_outputifoutpscontains a symbol not declared as output.
defactorize vars m returns an equivalent FSM obtained by removing variable listed in vars from m and introducing new states accordingly. The value attached to each variable is used to select the initial state in the defactorized FSM. Unreachable states are removed from the resulting automata unlesse the optional argument clean is set to false. Raises Unknown_var if vars contains a symbol not declared as variable. Raises Illegal_var_type if the specified var(s) do(es) not have an enumerable type (i.e. have not been declared with a range).
JSON export/import
to_string m writes a representation of FSM m as a string using the Yojson library.
from_string s returns the FSM m stored in string s using the Yojson library
to_file f writes a representation of FSM m in file f using the Yojson library.