70template <
class SymbolTypeT = DefaultSymbolType,
class StateTypeT = DefaultStateType >
71class DFA final :
public core::Components < DFA < SymbolTypeT, StateTypeT >, ext::set < SymbolTypeT >, component::Set, InputAlphabet, ext::set < StateTypeT >, component::Set, std::tuple < States, FinalStates >, StateTypeT, component::Value, InitialState > {
106 return this->
template accessComponent < InitialState > ( ).get ( );
115 return std::move ( this->
template accessComponent < InitialState > ( ).
get ( ) );
126 return this->
template accessComponent < InitialState > ( ).set ( std::move ( state ) );
135 return this->
template accessComponent < States > ( ).get ( );
144 return std::move ( this->
template accessComponent < States > ( ).
get ( ) );
155 return this->
template accessComponent < States > ( ).add ( std::move ( state ) );
164 this->
template accessComponent < States > ( ).set ( std::move ( states ) );
175 this->
template accessComponent < States > ( ).remove ( state );
184 return this->
template accessComponent < FinalStates > ( ).get ( );
193 return std::move ( this->
template accessComponent < FinalStates > ( ).
get ( ) );
204 return this->
template accessComponent < FinalStates > ( ).add ( std::move ( state ) );
213 this->
template accessComponent < FinalStates > ( ).set ( std::move ( states ) );
224 this->
template accessComponent < FinalStates > ( ).remove ( state );
233 return this->
template accessComponent < InputAlphabet > ( ).get ( );
242 return std::move ( this->
template accessComponent < InputAlphabet > ( ).
get ( ) );
253 return this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbol ) );
262 this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbols ) );
271 this->
template accessComponent < InputAlphabet > ( ).set ( std::move ( symbols ) );
282 this->
template accessComponent < InputAlphabet > ( ).remove ( symbol );
362 auto operator <=> ( const
DFA & other )
const {
387 <<
" states = " << instance.
getStates ( )
412template <
class SymbolType,
class StateType >
423template<
class SymbolType,
class StateType >
424DFA<SymbolType, StateType>::DFA (
ext::set < StateType > states,
ext::set < SymbolType > inputAlphabet,
StateType initialState,
ext::set < StateType > finalStates ) :
core::Components <
DFA,
ext::set <
SymbolType >,
component::Set, InputAlphabet,
ext::set <
StateType >,
component::Set,
std::tuple < States, FinalStates >,
StateType,
component::Value, InitialState > (
std::move ( inputAlphabet ),
std::move ( states ),
std::move ( finalStates ),
std::move ( initialState ) ) {
427template<
class SymbolType,
class StateType >
431template<
class SymbolType,
class StateType >
433 if ( ! getStates ( ).
contains ( from ) )
436 if ( ! getInputAlphabet ( ).
contains ( input ) )
439 if ( ! getStates ( ).
contains ( to ) )
443 auto iter = transitions.find ( key );
445 if ( iter != transitions.end ( ) ) {
446 if ( iter->second == to )
452 transitions.insert ( std::move ( key ), std::move ( to ) );
456template<
class SymbolType,
class StateType >
460 auto iter = transitions.find ( key );
462 if ( iter == transitions.end ( ) )
465 if ( iter->second != to )
468 transitions.erase ( iter );
472template<
class SymbolType,
class StateType >
477template<
class SymbolType,
class StateType >
479 return std::move ( transitions );
482template<
class SymbolType,
class StateType >
484 if ( ! getStates ( ).
contains ( from ) )
493template<
class SymbolType,
class StateType >
495 if ( ! getStates ( ).
contains ( to ) )
501 if ( transition.second == to )
502 transitionsToState.
insert ( transition );
504 return transitionsToState;
507template<
class SymbolType,
class StateType >
509 return transitions.size ( ) == getInputAlphabet ( ).size ( ) * getStates ( ).size ( );
522template<
class SymbolType,
class StateType >
535 if ( transition.first.second == symbol )
570template<
class SymbolType,
class StateType >
582 if (
automaton.getInitialState ( ) == state )
585 if (
automaton.getFinalStates ( ).contains ( state ) )
589 if ( ( t.first.first == state ) || ( t.second == state ) )
624template<
class SymbolType,
class StateType >
648 return automaton.getStates ( ).contains ( state );
668template<
class SymbolType,
class StateType >
680 return automaton.getStates ( ).contains ( state );
699template <
class SymbolType,
class StateType >
714 res.addTransition ( std::move ( from ), std::move ( input ), std::move ( to ) );
static ext::set< DefaultSymbolType > normalizeAlphabet(ext::set< SymbolType > &&symbols)
Definition: SymbolNormalize.h:50
static DefaultSymbolType normalizeSymbol(SymbolType &&symbol)
Definition: SymbolNormalize.h:68
Definition: AutomatonException.h:15
static DefaultStateType normalizeState(StateType &&state)
Definition: AutomatonNormalize.h:76
static ext::multiset< DefaultStateType > normalizeStates(ext::multiset< StateType > &&states)
Definition: AutomatonNormalize.h:49
Deterministic finite automaton. Accepts regular languages.
Definition: DFA.h:71
const ext::set< StateType > & getFinalStates() const &
Definition: DFA.h:183
bool setInitialState(StateType state)
Definition: DFA.h:125
bool removeTransition(const StateType &from, const SymbolType &input, const StateType &to)
Removes a transition from the automaton.
Definition: DFA.h:457
const ext::map< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: DFA.h:473
void removeInputSymbol(const SymbolType &symbol)
Definition: DFA.h:281
void setFinalStates(ext::set< StateType > states)
Definition: DFA.h:212
friend ext::ostream & operator<<(ext::ostream &out, const DFA &instance)
Definition: DFA.h:385
StateTypeT StateType
Definition: DFA.h:74
bool addFinalState(StateType state)
Definition: DFA.h:203
const StateType & getInitialState() const &
Definition: DFA.h:105
bool operator==(const DFA &other) const
Definition: DFA.h:373
bool addInputSymbol(SymbolType symbol)
Definition: DFA.h:252
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: DFA.h:232
ext::set< StateType > && getFinalStates() &&
Definition: DFA.h:192
DFA(StateType initialState)
Creates a new instance of the automaton with a concrete initial state.
Definition: DFA.h:428
ext::set< SymbolType > && getInputAlphabet() &&
Definition: DFA.h:241
bool isTotal() const
Determines whether the automaton is total.
Definition: DFA.h:508
const ext::set< StateType > & getStates() const &
Definition: DFA.h:134
bool addTransition(StateType from, SymbolType input, StateType to)
Add a transition to the automaton.
Definition: DFA.h:432
SymbolTypeT SymbolType
Definition: DFA.h:73
void removeState(const StateType &state)
Definition: DFA.h:174
void addInputSymbols(ext::set< SymbolType > symbols)
Definition: DFA.h:261
bool addState(StateType state)
Definition: DFA.h:154
ext::map< ext::pair< StateType, SymbolType >, StateType > getTransitionsToState(const StateType &to) const
Definition: DFA.h:494
ext::set< StateType > && getStates() &&
Definition: DFA.h:143
void setInputAlphabet(ext::set< SymbolType > symbols)
Definition: DFA.h:270
StateType && getInitialState() &&
Definition: DFA.h:114
void setStates(ext::set< StateType > states)
Definition: DFA.h:163
void removeFinalState(const StateType &state)
Definition: DFA.h:223
ext::iterator_range< typename ext::map< ext::pair< StateType, SymbolType >, StateType >::const_iterator > getTransitionsFromState(const StateType &from) const
Definition: DFA.h:483
Definition: components.hpp:181
static bool available(const automaton::DFA< SymbolType, StateType > &automaton, const StateType &state)
Definition: DFA.h:679
static void valid(const automaton::DFA< SymbolType, StateType > &, const StateType &)
Definition: DFA.h:689
Definition: components.hpp:25
static bool available(const automaton::DFA< SymbolType, StateType > &, const StateType &)
Definition: DFA.h:603
static bool used(const automaton::DFA< SymbolType, StateType > &automaton, const StateType &state)
Definition: DFA.h:581
static void valid(const automaton::DFA< SymbolType, StateType > &, const StateType &)
Definition: DFA.h:613
static bool used(const automaton::DFA< SymbolType, StateType > &, const StateType &)
Definition: DFA.h:635
static void valid(const automaton::DFA< SymbolType, StateType > &, const StateType &)
Definition: DFA.h:657
static bool available(const automaton::DFA< SymbolType, StateType > &automaton, const StateType &state)
Definition: DFA.h:647
static bool used(const automaton::DFA< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: DFA.h:533
static void valid(const automaton::DFA< SymbolType, StateType > &, const SymbolType &)
Definition: DFA.h:559
static bool available(const automaton::DFA< SymbolType, StateType > &, const SymbolType &)
Definition: DFA.h:549
Definition: setComponents.hpp:26
Implementation of iterator_range, i.e. pair of iterators. The class provides most notably begin and e...
Definition: range.hpp:24
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
std::pair< iterator, bool > insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: map.hpp:118
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Definition: BarSymbol.cpp:12
typename T::StateType StateType
Definition: ToGrammarLeftRG.h:64
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
return res
Definition: MinimizeByPartitioning.h:145
Definition: ToGrammar.h:31
constexpr bool isDFA
Definition: DFA.h:421
Definition: components.hpp:13
Definition: normalize.hpp:10
Definition: sigHandler.cpp:20
constexpr tuple< Elements &... > tie(Elements &... args) noexcept
Helper of extended tuple of references construction. The tuple is constructed to reffer to values in ...
Definition: tuple.hpp:218
reference_mover< T > make_mover(T ¶m)
Move adaptor construction function specialized to lvalue reference parameter.
Definition: iterator.hpp:468
SliceComp< Ts ... > slice_comp(const Ts &... inst)
Definition: functional.hpp:95
bool contains(InputIt first, InputIt last, const Element &elem)
Linear version of search in a range of values.
Definition: algorithm.hpp:170
std::string to_string(const T &value)
To string method designated for objects that can be casted to string.
Definition: string.hpp:131
iterator_range< Iter > make_iterator_range(Iter begin, Iter end)
Helper to create iterator_range from two iterators.
Definition: range.hpp:235
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: FordFulkerson.hpp:16
auto & get(ext::ptr_array< Type, N > &tpl)
Specialisation of get function for pointer arrays.
Definition: ptr_array.hpp:693
static automaton::DFA< > eval(automaton::DFA< SymbolType, StateType > &&value)
Definition: DFA.h:701
Definition: normalize.hpp:13