Package tulip :: Package transys :: Module machines
[frames] | no frames]

Module machines

Finite State Machines Module

Classes
  Transducer
Sequential Transducer, i.e., a letter-to-letter function.
  MooreMachine
Moore machine.
  MealyMachine
Mealy machine.
Functions
 
is_valuation(ports, valuations)
 
create_machine_ports(spc_vars)
Create proper port domains of valuations, given port types.
(states, output_sequences) where:
  • states is a list of states excluding from_state
  • output_sequences is a dict of lists
guided_run(mealy, from_state=None, input_sequences=None)
Run deterministic machine reacting to given inputs.
 
random_run(mealy, from_state=None, N=10)
Return run from given state for N random inputs.
 
interactive_run(mealy, from_state=None)
Run input-deterministic Mealy machine using user input.
MealyMachine
moore2mealy(moore)
Convert Moore machine to equivalent Mealy machine.
MooreMachine
mealy2moore(mealy)
Convert Mealy machine to almost equivalent Moore machine.
 
project_dict(x, y)
 
trim_dict(x, y)
 
strip_ports(mealy, names)
Remove ports in names.
Variables
  pure = set(['absent', 'present'])
  __package__ = None
hash(x)
Function Details

create_machine_ports(spc_vars)

 

Create proper port domains of valuations, given port types.

Parameters:
  • spc_vars - port names and types inside tulip. For arbitrary finite types the type can be a list of strings, instead of a range of integers. These are as originally defined by the user or synth.

guided_run(mealy, from_state=None, input_sequences=None)

 

Run deterministic machine reacting to given inputs.

Parameters:
  • from_state - start simulation
  • mealy (MealyMachine) - input-deterministic Mealy machine
  • from_state - start simulation at this state. If None, then use the unique initial state Sinit.
  • input_sequences (dict of lists) - one sequence of values for each input port
Returns: (states, output_sequences) where:
  • states is a list of states excluding from_state
  • output_sequences is a dict of lists
sequence of states and sequence of output valuations

random_run(mealy, from_state=None, N=10)

 

Return run from given state for N random inputs.

Inputs selected randomly in a way that does not block the machine So they are not arbitrarily random. If the machine is a valid synthesis solution, then all safe environment inputs can be generated this way.

Randomly generated inputs may violate liveness assumption on environment.

Parameters:
  • mealy (MealyMachine) - input-deterministic Mealy machine
  • N (int) - number of reactions (inputs)
Returns:
same as guided_run

interactive_run(mealy, from_state=None)

 

Run input-deterministic Mealy machine using user input.

Parameters:

moore2mealy(moore)

 

Convert Moore machine to equivalent Mealy machine.

Reference

[LS11]

Parameters:
Returns: MealyMachine

mealy2moore(mealy)

 

Convert Mealy machine to almost equivalent Moore machine.

A Mealy machine cannot be transformed to an equivalent Moore machine. It can be converted to a Moore machine with an arbitrary initial output, which outputs the Mealy output at its next reaction.

Reference

[LS11]

Parameters:
Returns: MooreMachine

strip_ports(mealy, names)

 

Remove ports in names.

For example, to remove the atomic propositions labeling the transition system ts used (so they are dependent variables), call it as:

>>> strip_ports(mealy, ts.atomic_propositions)
Parameters: