Skip to content

Add transition using the alphabet member keys #587

@Adda0

Description

@Adda0

If an Nfa has some alphabet, it would also be nice to be able to write something like aut.delta.add(2, "my_symbol", 3) instead of aut.delta.add(2, aut.alphabet->translate_symb("my_symbol"), 3). However, this would require delta to also store the alphabet. An alternative would be to have a function aut.delta_add, but this would make things inconsistent.

By @bruderjakob17 in #584.

Options:

  1. We should add template <typename SymbolName>Nfa::add_transition(State source, SymbolName symbol, State target, Alphabet* alphabet = nullptr) which calls the member alphabet this->alphabet->translate_symbol(symbol), unless the parameter alphabet is not nullptr at which point this alphabet instance is preferred.
    This is consistent with the Nft::add_transition() which is the more high-level approach to adding complex automata-level transitions, disregarding the technical details of the Mata implementation of the transition relation.
  2. The only question is whether this should be more explicitly named, something like Nfa::add_transition_with_symbol_name() (and however shorter this can be made) to distinguish from the same high-level approach, but without the alphabet.
  3. Alternatively, the template is not even necessary, and we will just use a std::string. I think only Nfa::add_transtiion(..., Symbol, ...) and Nfa::add_transition(..., SymbolName symbol_name, ...) would be sufficient.

Metadata

Metadata

Assignees

No one assigned

    Labels

    For:libraryThe issue is related to library (c++ implementation)Module:nfaThe issue is related to Nondeterministic Finite AutomataType:suggestionA suggestion for feature/change that is not necessary at this moment

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions