Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

🔀nexus_policy::automaton

Struct DeterministicAutomaton

Deterministic automaton with states State and alphabet Symbol.

The structure mirrors the mathematical definition:

  • states: ordered basis of states used to compute stable indices.

  • alphabet: ordered basis of symbols.

  • transition: |States| × |Alphabet| matrix of successor state indices.

  • accepting: bitmap marking accepting states inside the basis.

  • start: index of the distinguished start state.

Fields

states: sui::table_vec::TableVec<State>alphabet: sui::table_vec::TableVec<Symbol>transition: sui::table_vec::TableVec<sui::table_vec::TableVec<u64>>accepting: sui::table_vec::TableVec<bool>start: u64

Struct ConfiguredAutomaton

DFA bundled with transition scoped metadata stored as dynamic fields.

Callers can attach arbitrary Config payloads keyed by (state, symbol, Config) and fetch them later when evaluating transitions.

Fields

id: sui::object::UIDdfa: nexus_policy::automaton::DeterministicAutomaton<State, Symbol>

Struct TransitionKey

Key for transition metadata. state = none() denotes a wildcard over all states for the given symbol.

Fields

state: std::option::Option<State>symbol: Symbol

Struct TransitionConfigKey

Key for a specific transition metadata type.

Fields

transition: nexus_policy::automaton::TransitionKey<State, Symbol>config: std::type_name::TypeName

Constants

Error: DFA must contain at least one state.

Error: referenced state is not in the basis.

Error: referenced symbol is not in the alphabet.

Error: states must be unique.

Error: symbols must be unique.

Error: transition rows or columns do not match the expected matrix shape.

Error: supplied transitions have a different length than the automaton basis.

Error: attempted to register a state already present in the basis.

Error: attempted to register a symbol already present in the alphabet.

Error: duplicate metadata registration for a transition/config pair.

Error: expected metadata for a transition/config pair is missing.

Function new

Build the automaton from its canonical data (states, alphabet, transition, start, accepting).

transitions[i][j] represents δ(states[i], alphabet[j]) as a state value. The accepting set is provided as a list (duplicates are ignored). Inputs are normalized into index based matrices and bitmaps to avoid repeated lookups later.

Function states

Underlying basis States.

Function alphabet

Alphabet Symbols.

Function start_state

Distinguished start state.

Function start_index

Distinguished start state index inside the basis.

Function state_at

Borrow the state value located at a basis index.

Function delta

Evaluate transition function on a single symbol using values.

Aborts if either the state or symbol is outside the basis.

Function delta_indexed

Evaluate transition function using basis indices.

Function run

Extend transition function to words starting from the start state.

Example:

Function run_from

Extend transition function to words from an arbitrary starting state.

Function is_accepting

Membership in the accepting set Accepting.

Function accepts

Decide whether a word is accepted.

Function set_transition

Mutate transition function on a single (state, symbol) pair.

The successor is stored canonically as an index.

Function set_transition_indexed

Mutate transition function using basis indices.

Function add_symbol

Extend the alphabet with a new symbol and associated transitions.

Function add_state

Register a new state together with its outgoing transitions and acceptance flag.

Function set_accepting_state

Update whether a state is accepting.

Function symbol_index_of

Locate the index of a symbol inside the alphabet.

Function expect_symbol_index_of

Resolve the index of a symbol or abort if it is not part of the alphabet.

Function expect_state_index_of

Resolve the index of a state or abort if it is not part of the basis.

Function new_configured

Configure a DFA with transition metadata keyed by (state, symbol).

Function borrow_core

Borrow the underlying DFA.

Function borrow_core_mut

Borrow the underlying DFA mutably.

Function register_symbol_config

Register a config for the wildcard (*, symbol) transition.

Function register_transition_config

Register a config scoped to (state, symbol).

Function borrow_transition_config

Borrow a config for (state, symbol), falling back to wildcard.

Function borrow_mut_transition_config

Borrow a mutable config for (state, symbol), falling back to wildcard.

Function has_symbol_config

Returns true if a wildcard config exists for symbol.

Function borrow_symbol_config

Borrow the wildcard config for (*, symbol).

Function borrow_mut_symbol_config

Borrow the wildcard config for (*, symbol) mutably.

Function remove_symbol_config

Removes metadata for every state transition on one symbol.

Function remove_transition_config

Removes metadata for one state and symbol transition.

Last updated