DFA¶
API Reference¶
masa.common.ltl.DFA ¶
Deterministic finite automaton with propositional guards on edges.
Each edge from a parent state to a child state is labelled with a guard
Formula. A transition is taken when its guard is satisfied by the
current label set.
Attributes:
| Name | Type | Description |
|---|---|---|
states |
List of automaton states. |
|
initial |
Initial automaton state. |
|
accepting |
List of accepting (final) states. |
|
edges |
Transition structure mapping |
|
state |
Current automaton state used by |
Notes
The transition relation is deterministic by convention: if multiple outgoing guards from a state are simultaneously satisfied, the first one encountered in iteration order is taken. For strict determinism, ensure guards are mutually exclusive.
Creates a DFA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
states
|
List[int]
|
List of automaton states (typically integers). |
required |
initial
|
int
|
Initial state. |
required |
accepting
|
List[int]
|
Accepting (final) states. |
required |
Source code in masa/common/ltl.py
num_automaton_states
property
¶
Returns the number of states in the automaton.
Returns:
| Type | Description |
|---|---|
|
|
automaton_state
property
¶
Returns the number of states in the automaton.
Returns:
| Type | Description |
|---|---|
|
|
add_edge ¶
Adds a guarded transition parent -> child.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
int
|
Source state. |
required |
child
|
int
|
Destination state. |
required |
condition
|
Formula
|
Guard formula enabling this transition when satisfied. |
required |
Notes
This overwrites any existing edge guard between the same parent/child pair.
Source code in masa/common/ltl.py
reset ¶
Resets the DFA to the initial state.
Returns:
| Type | Description |
|---|---|
int
|
The reset state (i.e., |
has_edge ¶
Checks whether there is an edge state_1 -> state_2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_1
|
int
|
Source state. |
required |
state_2
|
int
|
Destination state. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in masa/common/ltl.py
check ¶
Checks whether a trace is accepted by the DFA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
Iterable[Iterable[str]]
|
Sequence of label sets, one per time step. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
|
Source code in masa/common/ltl.py
transition ¶
Computes the next automaton state given the current state and labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
int
|
Current DFA state. |
required |
labels
|
Iterable[str]
|
Iterable of atomic proposition names holding at the current step. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Next DFA state. If no outgoing edge guard is satisfied, returns the |
int
|
original |
Source code in masa/common/ltl.py
step ¶
Advances the DFA by one step using the provided labels.
This updates the internal state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Iterable[str]
|
Iterable of atomic proposition names holding at the current step. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
A pair |
int
|
the new state is in |
Tuple[bool, int]
|
automaton state. |