13 #include <unordered_set> 124 return lhs.get() == rhs.get();
nfa build()
Builds the NFA, as defined by previous operations.
static nfa::builder complement(nfa const &n)
Creates a builder for an NFA accepting the complement of the language of an NFA.
std::string getShortestUtf8Word() const
Same as above for a UTF-8-encoded word.
size_t getNumberOfSymbols() const
Counts this NFA's alphabet symbols.
Represents nondeterministic finite automata with ε-moves.
std::vector< char32_t > const & getAlphabet() const
Fetches this NFA's set of processable symbols.
std::string const & getLabelOf(size_t q) const
Puts a name to an index.
Represents deterministic finite automata.
std::vector< std::string > const & getUtf8Alphabet() const
Fetches this NFA's set of processable symbols as UTF-8-encoded strings.
Constructs NFAs step by step.
bool operator==(nfa const &n) const
Tests whether this NFA accepts exactly the same language as another one.
static nfa::builder intersect(nfa const &n1, nfa const &n2)
Creates a builder for an NFA accepting the intersection of the languages of two NFAs.
size_t operator()(std::reference_wrapper< std::string const > const &ref) const
Delegates hashing to referenced objects.
builder & unite(nfa const &other)
Makes the prospective NFA also accept every word of another NFA's language.
nfa & operator=(nfa const &n)
Copy-assigns this NFA by copying another one's private implementation object.
std::valarray< bool > encodeSet(state_set const &qs) const
Translates a set of states from set to bool representation.
bool operator!=(nfa const &n) const
Tests whether this NFA doesn't accept the same language as another one.
builder & addSymbol(char32_t symbol)
Adds a symbol to the prospective NFA's alphabet.
Provides std::unordered_set::key_eq for state_set.
state_set getStatesSet() const
Fetches this NFA's set of states as a set of (references to) strings.
builder & setAccepting(std::string const &state, bool accept)
Sets whether or not a state will be accepting within the prospective NFA.
builder & normalizeStateNames(std::string const &prefix)
Reduces the prospective NFA's state names to consecutive numbers, prefixed with a given string...
Provides std::unordered_set::hash_function for state_set.
state_set decodeSet(std::valarray< bool > const &qs) const
Translates a set of states from bool to set representation.
bool isAccepting(size_t qi) const
Tests whether a state is an accept state within this NFA.
std::u32string getShortestWord() const
Searches the shortest UTF-32-encoded word accepted by this NFA.
static nfa::builder unite(nfa const &n1, nfa const &n2)
Creates a builder for an NFA accepting the union of the languages of two NFAs.
std::unordered_set< std::reference_wrapper< std::string const >, hash_reference_string_const, equal_to_reference_string_const > state_set
Nicer name for sets of names of states. Should store references to names in getStates.
builder & makeInitial(std::string const &state)
Resets the initial state for the prospective NFA.
builder & intersect(nfa const &other)
Makes the prospective NFA accept only words accepted also by another NFA.
Private implementation details of NFA builders.
size_t getNumberOfStates() const
Counts this NFA's states.
static nfa::builder subtract(nfa const &n1, nfa const &n2)
Creates a builder for an NFA accepting the set difference of the languages of two NFAs...
std::valarray< bool > getStatesBools() const
Fetches this NFA's set of states encoded as an array of bools.
std::valarray< bool > deltaHat(size_t qi, std::u32string const &word) const
Computes this NFA's transition function recursively for a string of symbols, starting in a state spec...
bool hasAccepting(std::valarray< bool > const &qs) const
Tests whether a set of states contains an accept state within this NFA.
Where this library lives.
nfa()
Constructs an NFA accepting the empty language ∅.
string findShortestUtf8Word(dfa const &d)
Same as above for a UTF-8-encoded word.
builder & operator=(builder const &b)
Copy-assigns a builder by copying another one's private implementation object.
std::string const & getInitialState() const
Names this NFA's initial state.
u32string findShortestWord(dfa const &d)
Searches the shortest UTF-32-encoded word accepted by a given DFA.
builder & addTransition(std::string const &from, std::string const &to, char32_t symbol)
Adds a transition for the prospective NFA.
std::valarray< bool > const & delta(size_t qi, size_t si) const
Computes this NFA's transition function for a state index and a symbol index.
std::valarray< bool > const & epsilonClosure(size_t qi) const
Computes a state's ε-closure.
std::vector< std::string > const & getStates() const
Fetches this NFA's set of states in order of internal representation.
bool operator()(std::reference_wrapper< std::string const > const &lhs, std::reference_wrapper< std::string const > const &rhs) const
Delegates equality check to referenced objects.
builder()
Constructs a blank builder object.