70template <
class SymbolTypeT = DefaultSymbolType,
class StateTypeT = DefaultStateType >
71class OneTapeDTM final :
public core::Components < OneTapeDTM < SymbolTypeT, StateTypeT >, ext::set < SymbolTypeT >, component::Set, std::tuple < TapeAlphabet, InputAlphabet >, SymbolTypeT, component::Value, BlankSymbol, ext::set < StateTypeT >, component::Set, std::tuple < States, FinalStates >, StateTypeT, component::Value, InitialState > {
109 return this->
template accessComponent < InitialState > ( ).get ( );
118 return std::move ( this->
template accessComponent < InitialState > ( ).
get ( ) );
129 return this->
template accessComponent < InitialState > ( ).set ( std::move ( state ) );
138 return this->
template accessComponent < States > ( ).get ( );
147 return std::move ( this->
template accessComponent < States > ( ).
get ( ) );
158 return this->
template accessComponent < States > ( ).add ( std::move ( state ) );
167 this->
template accessComponent < States > ( ).set ( std::move ( states ) );
178 this->
template accessComponent < States > ( ).remove ( state );
187 return this->
template accessComponent < FinalStates > ( ).get ( );
196 return std::move ( this->
template accessComponent < FinalStates > ( ).
get ( ) );
207 return this->
template accessComponent < FinalStates > ( ).add ( std::move ( state ) );
216 this->
template accessComponent < FinalStates > ( ).set ( std::move ( states ) );
227 this->
template accessComponent < FinalStates > ( ).remove ( state );
236 return this->
template accessComponent < InputAlphabet > ( ).get ( );
245 return std::move ( this->
template accessComponent < InputAlphabet > ( ).
get ( ) );
256 return this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbol ) );
265 this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbols ) );
274 this->
template accessComponent < InputAlphabet > ( ).set ( std::move ( symbols ) );
285 this->
template accessComponent < InputAlphabet > ( ).remove ( symbol );
294 return this->
template accessComponent < TapeAlphabet > ( ).get ( );
303 return std::move ( this->
template accessComponent < TapeAlphabet > ( ).
get ( ) );
314 return this->
template accessComponent < TapeAlphabet > ( ).add ( std::move ( symbol ) );
323 this->
template accessComponent < TapeAlphabet > ( ).add ( std::move ( symbols ) );
332 this->
template accessComponent < TapeAlphabet > ( ).set ( std::move ( symbols ) );
343 this->
template accessComponent < TapeAlphabet > ( ).remove ( symbol );
352 return this->
template accessComponent < BlankSymbol > ( ).get ( );
361 return std::move ( this->
template accessComponent < BlankSymbol > ( ).
get ( ) );
372 return this->
template accessComponent < BlankSymbol > ( ).set ( std::move ( state ) );
429 return std::tie(
getStates(),
getInputAlphabet(),
getInitialState(),
getFinalStates(),
getTapeAlphabet(),
getBlankSymbol(), transitions) <=>
std::tie(other.getStates(), other.getInputAlphabet(), other.getInitialState(), other.getFinalStates(), other.getTapeAlphabet(), other.getBlankSymbol(), other.transitions);
440 return std::tie(
getStates(),
getInputAlphabet(),
getInitialState(),
getFinalStates(),
getTapeAlphabet(),
getBlankSymbol(), transitions) ==
std::tie(other.
getStates(), other.
getInputAlphabet(), other.
getInitialState(), other.
getFinalStates(), other.
getTapeAlphabet(), other.
getBlankSymbol(), other.transitions);
452 return out <<
"(OneTapeDTM"
453 <<
" states = " << instance.
getStates ( )
464template<
class SymbolType,
class StateType >
465OneTapeDTM<SymbolType, StateType>::OneTapeDTM (
ext::set < StateType > states,
ext::set < SymbolType > tapeAlphabet,
SymbolType blankSymbol,
ext::set< SymbolType > inputAlphabet,
StateType initialState,
ext::set < StateType > finalStates ) :
core::Components <
OneTapeDTM,
ext::set <
SymbolType >,
component::Set,
std::tuple < TapeAlphabet, InputAlphabet >,
SymbolType,
component::Value, BlankSymbol,
ext::set <
StateType>,
component::Set,
std::tuple < States, FinalStates >,
StateType,
component::Value, InitialState > (
std::move ( tapeAlphabet ),
std::move ( inputAlphabet ),
std::move ( blankSymbol ),
std::move ( states ),
std::move ( finalStates ),
std::move ( initialState ) ) {
469template<
class SymbolType,
class StateType >
474template<
class SymbolType,
class StateType >
476 if (!getStates().count(from)) {
480 if ( getFinalStates().count ( from ) )
483 if (!getTapeAlphabet().count(input)) {
487 if (!getStates().count(to)) {
491 if (!getTapeAlphabet().count(output)) {
499 if (transitions.find(key) != transitions.end()) {
500 if(transitions.find(key)->second == value)
506 transitions.insert ( std::move(key), std::move(value) );
510template<
class SymbolType,
class StateType >
514 if (transitions.find(key) == transitions.end())
518 if(transitions.find(key)->second != value)
521 transitions.erase(key);
525template<
class SymbolType,
class StateType >
530template<
class SymbolType,
class StateType >
532 return std::move ( transitions );
545template<
class SymbolType,
class StateType >
557 if (
automaton.getBlankSymbol ( ) == symbol )
560 if (
automaton.getInputAlphabet().count(symbol))
564 if (symbol == transition.first.second || symbol == std::get<1>(transition.second))
599template<
class SymbolType,
class StateType >
623 return automaton.getTapeAlphabet ( ).count ( symbol );
633 if (symbol ==
automaton.getBlankSymbol())
644template<
class SymbolType,
class StateType >
656 return automaton.getTapeAlphabet ( ).count ( symbol );
666 if (
automaton.getInputAlphabet().count( symbol ))
677template<
class SymbolType,
class StateType >
689 if (
automaton.getInitialState ( ) == state )
692 if (
automaton.getFinalStates ( ).count ( state ) )
696 if ( state == transition.first.first || state == std::get < 0 > ( transition.second ) )
730template<
class SymbolType,
class StateType >
754 return automaton.getStates ( ).count ( state );
765 if ( state == transition.first.first )
776template<
class SymbolType,
class StateType >
788 return automaton.getStates ( ).count ( state );
806template<
class SymbolType,
class StateType >
816 automaton::OneTapeDTM < > res ( std::move ( states ), std::move ( tapeAlphabet ), std::move ( blankSymbol ), std::move (
alphabet ), std::move ( initialState ), std::move ( finalStates ) );
824 res.addTransition ( std::move ( from ), std::move ( input ), std::move ( to ), std::move ( output ), std::get < 2 > ( transition.second ) );
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 single tape turing machine. Accepts recursive languages.
Definition: OneTapeDTM.h:71
const StateType & getInitialState() const &
Definition: OneTapeDTM.h:108
const ext::set< StateType > & getFinalStates() const &
Definition: OneTapeDTM.h:186
const ext::set< SymbolType > & getTapeAlphabet() const &
Definition: OneTapeDTM.h:293
bool removeTransition(const StateType &from, const SymbolType &input, const StateType &to, const SymbolType &output, const Shift &shift)
Removes a transition from the automaton.
Definition: OneTapeDTM.h:511
const ext::map< ext::pair< StateType, SymbolType >, ext::tuple< StateType, SymbolType, Shift > > & getTransitions() const &
Definition: OneTapeDTM.h:526
void removeFinalState(const StateType &state)
Definition: OneTapeDTM.h:226
OneTapeDTM(ext::set< StateType > states, ext::set< SymbolType > tapeAlphabet, SymbolType blankSymbol, ext::set< SymbolType > inputAlphabet, StateType initialState, ext::set< StateType > finalStates)
Creates a new instance of the automaton with a concrete set of states, tape alphabet,...
Definition: OneTapeDTM.h:465
const SymbolType & getBlankSymbol() const &
Definition: OneTapeDTM.h:351
ext::set< SymbolType > && getTapeAlphabet() &&
Definition: OneTapeDTM.h:302
bool setInitialState(StateType state)
Definition: OneTapeDTM.h:128
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: OneTapeDTM.h:235
SymbolTypeT SymbolType
Definition: OneTapeDTM.h:73
bool addInputSymbol(SymbolType symbol)
Definition: OneTapeDTM.h:255
bool addFinalState(StateType state)
Definition: OneTapeDTM.h:206
StateType && getInitialState() &&
Definition: OneTapeDTM.h:117
bool setBlankSymbol(SymbolType state)
Definition: OneTapeDTM.h:371
void setInputAlphabet(ext::set< SymbolType > symbols)
Definition: OneTapeDTM.h:273
void removeState(const StateType &state)
Definition: OneTapeDTM.h:177
void removeInputSymbol(const SymbolType &symbol)
Definition: OneTapeDTM.h:284
bool operator==(const OneTapeDTM &other) const
Definition: OneTapeDTM.h:439
StateTypeT StateType
Definition: OneTapeDTM.h:74
bool addTapeSymbol(SymbolType symbol)
Definition: OneTapeDTM.h:313
ext::set< StateType > && getStates() &&
Definition: OneTapeDTM.h:146
void setFinalStates(ext::set< StateType > states)
Definition: OneTapeDTM.h:215
void addTapeSymbols(ext::set< SymbolType > symbols)
Definition: OneTapeDTM.h:322
bool addState(StateType state)
Definition: OneTapeDTM.h:157
const ext::set< StateType > & getStates() const &
Definition: OneTapeDTM.h:137
void setStates(ext::set< StateType > states)
Definition: OneTapeDTM.h:166
bool addTransition(StateType from, SymbolType input, StateType to, SymbolType output, Shift shift)
Add a transition to the automaton.
Definition: OneTapeDTM.h:475
SymbolType && getBlankSymbol() &&
Definition: OneTapeDTM.h:360
void removeTapeSymbol(const SymbolType &symbol)
Definition: OneTapeDTM.h:342
void setTapeAlphabet(ext::set< SymbolType > symbols)
Definition: OneTapeDTM.h:331
void addInputSymbols(ext::set< SymbolType > symbols)
Definition: OneTapeDTM.h:264
ext::set< StateType > && getFinalStates() &&
Definition: OneTapeDTM.h:195
friend ext::ostream & operator<<(ext::ostream &out, const OneTapeDTM &instance)
Definition: OneTapeDTM.h:451
ext::set< SymbolType > && getInputAlphabet() &&
Definition: OneTapeDTM.h:244
Definition: components.hpp:181
static void valid(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: OneTapeDTM.h:665
static bool available(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: OneTapeDTM.h:655
static void valid(const automaton::OneTapeDTM< SymbolType, StateType > &, const StateType &)
Definition: OneTapeDTM.h:797
static bool available(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const StateType &state)
Definition: OneTapeDTM.h:787
Definition: components.hpp:25
static bool available(const automaton::OneTapeDTM< SymbolType, StateType > &, const SymbolType &)
Definition: OneTapeDTM.h:579
static bool used(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: OneTapeDTM.h:556
static void valid(const automaton::OneTapeDTM< SymbolType, StateType > &, const SymbolType &)
Definition: OneTapeDTM.h:589
static bool available(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: OneTapeDTM.h:622
static void valid(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: OneTapeDTM.h:632
static bool used(const automaton::OneTapeDTM< SymbolType, StateType > &, const SymbolType &)
Definition: OneTapeDTM.h:610
static bool available(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const StateType &state)
Definition: OneTapeDTM.h:753
static void valid(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const StateType &state)
Definition: OneTapeDTM.h:763
static bool used(const automaton::OneTapeDTM< SymbolType, StateType > &, const StateType &)
Definition: OneTapeDTM.h:741
static bool available(const automaton::OneTapeDTM< SymbolType, StateType > &, const StateType &)
Definition: OneTapeDTM.h:710
static void valid(const automaton::OneTapeDTM< SymbolType, StateType > &, const StateType &)
Definition: OneTapeDTM.h:720
static bool used(const automaton::OneTapeDTM< SymbolType, StateType > &automaton, const StateType &state)
Definition: OneTapeDTM.h:688
Definition: setComponents.hpp:26
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Class extending the tuple class from the standard library. Original reason is to allow printing of th...
Definition: tuple.hpp:42
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
Shift
Definition: Shift.h:15
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
std::string to_string(const T &value)
To string method designated for objects that can be casted to string.
Definition: string.hpp:131
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::OneTapeDTM< > eval(automaton::OneTapeDTM< SymbolType, StateType > &&value)
Definition: OneTapeDTM.h:808
Definition: normalize.hpp:13