Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Public Types | Public Member Functions | Friends
automaton::OneTapeDTM< SymbolTypeT, StateTypeT > Class Template Referencefinal

Deterministic single tape turing machine. Accepts recursive languages. More...

#include <OneTapeDTM.h>

Inheritance diagram for automaton::OneTapeDTM< SymbolTypeT, StateTypeT >:
[legend]
Collaboration diagram for automaton::OneTapeDTM< SymbolTypeT, StateTypeT >:
[legend]

Public Types

typedef SymbolTypeT SymbolType
 
typedef StateTypeT StateType
 

Public Member Functions

 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, blank symbol, input alphabet, initial state, and a set of final states. More...
 
 OneTapeDTM (StateType initial, SymbolType blank)
 Creates a new instance of the automaton with a concrete initial state and blank symbol. More...
 
const StateTypegetInitialState () const &
 
StateType && getInitialState () &&
 
bool setInitialState (StateType state)
 
const ext::set< StateType > & getStates () const &
 
ext::set< StateType > && getStates () &&
 
bool addState (StateType state)
 
void setStates (ext::set< StateType > states)
 
void removeState (const StateType &state)
 
const ext::set< StateType > & getFinalStates () const &
 
ext::set< StateType > && getFinalStates () &&
 
bool addFinalState (StateType state)
 
void setFinalStates (ext::set< StateType > states)
 
void removeFinalState (const StateType &state)
 
const ext::set< SymbolType > & getInputAlphabet () const &
 
ext::set< SymbolType > && getInputAlphabet () &&
 
bool addInputSymbol (SymbolType symbol)
 
void addInputSymbols (ext::set< SymbolType > symbols)
 
void setInputAlphabet (ext::set< SymbolType > symbols)
 
void removeInputSymbol (const SymbolType &symbol)
 
const ext::set< SymbolType > & getTapeAlphabet () const &
 
ext::set< SymbolType > && getTapeAlphabet () &&
 
bool addTapeSymbol (SymbolType symbol)
 
void addTapeSymbols (ext::set< SymbolType > symbols)
 
void setTapeAlphabet (ext::set< SymbolType > symbols)
 
void removeTapeSymbol (const SymbolType &symbol)
 
const SymbolTypegetBlankSymbol () const &
 
SymbolType && getBlankSymbol () &&
 
bool setBlankSymbol (SymbolType state)
 
bool addTransition (StateType from, SymbolType input, StateType to, SymbolType output, Shift shift)
 Add a transition to the automaton. More...
 
bool removeTransition (const StateType &from, const SymbolType &input, const StateType &to, const SymbolType &output, const Shift &shift)
 Removes a transition from the automaton. More...
 
const ext::map< ext::pair< StateType, SymbolType >, ext::tuple< StateType, SymbolType, Shift > > & getTransitions () const &
 
ext::map< ext::pair< StateType, SymbolType >, ext::tuple< StateType, SymbolType, Shift > > && getTransitions () &&
 
auto operator<=> (const OneTapeDTM &other) const
 
bool operator== (const OneTapeDTM &other) const
 
- Public Member Functions inherited from core::Components< OneTapeDTM< DefaultSymbolType, DefaultStateType >, ext::set< DefaultSymbolType >, component::Set, std::tuple< TapeAlphabet, InputAlphabet >, DefaultSymbolType, component::Value, BlankSymbol, ext::set< DefaultStateType >, component::Set, std::tuple< States, FinalStates >, DefaultStateType, component::Value, InitialState >
void accessComponent ()
 

Friends

ext::ostreamoperator<< (ext::ostream &out, const OneTapeDTM &instance)
 

Additional Inherited Members

- Static Public Member Functions inherited from core::Components< OneTapeDTM< DefaultSymbolType, DefaultStateType >, ext::set< DefaultSymbolType >, component::Set, std::tuple< TapeAlphabet, InputAlphabet >, DefaultSymbolType, component::Value, BlankSymbol, ext::set< DefaultStateType >, component::Set, std::tuple< States, FinalStates >, DefaultStateType, component::Value, InitialState >
static void registerComponent ()
 
static void unregisterComponent ()
 

Detailed Description

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
class automaton::OneTapeDTM< SymbolTypeT, StateTypeT >

Deterministic single tape turing machine. Accepts recursive languages.

Definition is classical definition of finite automata. A = (Q, T, G, \delta, I, B, F), Q (States) = nonempty finite set of states, T (TerminalAlphabet) = finite set of terminal symbols - having this empty won't let automaton do much though, G (TapeAlphabet) = finite work alphabet \delta = transition function of the form A \times a -> B \times b \times {-1, 0, 1}, where A, B \in Q \ F and a, b \in G, I (InitialState) = initial state, B (BlankSymbol) = blank symbol F (FinalStates) = set of final states

Template Parameters
SymbolTypeTused for the terminal alphabet
StateTypeTused to the states, and the initial state of the automaton.

Member Typedef Documentation

◆ StateType

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
typedef StateTypeT automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::StateType

◆ SymbolType

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
typedef SymbolTypeT automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::SymbolType

Constructor & Destructor Documentation

◆ OneTapeDTM() [1/2]

template<class SymbolType , class StateType >
automaton::OneTapeDTM< SymbolType, StateType >::OneTapeDTM ( ext::set< StateType states,
ext::set< SymbolType tapeAlphabet,
SymbolType  blankSymbol,
ext::set< SymbolType inputAlphabet,
StateType  initialState,
ext::set< StateType finalStates 
)
explicit

Creates a new instance of the automaton with a concrete set of states, tape alphabet, blank symbol, input alphabet, initial state, and a set of final states.

Parameters
statesthe initial set of states of the automaton
tapeAlphabetthe initial tape alphabet of the automaton
blankSymbolthe initial blank symbol of the automaton
inputAlphabetthe initial input alphabet of the automaton
initialStatethe initial state of the automaton
finalStatesthe initial set of final states of the automaton

◆ OneTapeDTM() [2/2]

template<class SymbolType , class StateType >
automaton::OneTapeDTM< SymbolType, StateType >::OneTapeDTM ( StateType  initial,
SymbolType  blank 
)
explicit

Creates a new instance of the automaton with a concrete initial state and blank symbol.

Parameters
initialStatethe initial state of the automaton
blankSymbolthe initial blank symbol of the automaton

Member Function Documentation

◆ addFinalState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::addFinalState ( StateType  state)
inline

Adder of a final state.

Parameters
statethe new state to be added to a set of final states
Returns
true if the state was indeed added

◆ addInputSymbol()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::addInputSymbol ( SymbolType  symbol)
inline

Adder of a input symbol.

Parameters
symbolthe new symbol to be added to an input alphabet
Returns
true if the symbol was indeed added

◆ addInputSymbols()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::addInputSymbols ( ext::set< SymbolType symbols)
inline

Adder of input symbols.

Parameters
symbolsnew symbols to be added to an input alphabet

◆ addState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::addState ( StateType  state)
inline

Adder of a state.

Parameters
statethe new state to be added to a set of states
Returns
true if the state was indeed added

◆ addTapeSymbol()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::addTapeSymbol ( SymbolType  symbol)
inline

Adder of a tape symbol.

Parameters
symbolthe new symbol to be added to a tape alphabet
Returns
true if the symbol was indeed added

◆ addTapeSymbols()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::addTapeSymbols ( ext::set< SymbolType symbols)
inline

Adder of tape symbols.

Parameters
symbolsnew symbols to be added to an tape alphabet

◆ addTransition()

template<class SymbolType , class StateType >
bool automaton::OneTapeDTM< SymbolType, StateType >::addTransition ( StateType  from,
SymbolType  input,
StateType  to,
SymbolType  output,
Shift  shift 
)

Add a transition to the automaton.

The transition is in a form A \times a -> B \times b \times {-1, 0, 1}, where A, B \in Q and a, b \in G

Parameters
currentthe source state (A)
inputthe tape symbol (a)
nextthe target state (B)
outputthe tape symbol (b)
shiftthe direction of change on the tape
Exceptions
AutomatonExceptionwhen transition contains state or symbol not present in the automaton components
Returns
true if the transition was indeed added
Here is the call graph for this function:

◆ getBlankSymbol() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
SymbolType && automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getBlankSymbol ( ) &&
inline

Getter of the blank symbol.

Returns
the blank symbol of the automaton
Here is the call graph for this function:

◆ getBlankSymbol() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const SymbolType & automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getBlankSymbol ( ) const &
inline

Getter of the blank symbol.

Returns
the blank symbol of the automaton
Here is the caller graph for this function:

◆ getFinalStates() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::set< StateType > && automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getFinalStates ( ) &&
inline

Getter of final states.

Returns
the final states of the automaton
Here is the call graph for this function:

◆ getFinalStates() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::set< StateType > & automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getFinalStates ( ) const &
inline

Getter of final states.

Returns
the final states of the automaton
Here is the caller graph for this function:

◆ getInitialState() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
StateType && automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getInitialState ( ) &&
inline

Getter of the initial state.

Returns
the initial state of the automaton
Here is the call graph for this function:

◆ getInitialState() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const StateType & automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getInitialState ( ) const &
inline

Getter of the initial state.

Returns
the initial state of the automaton
Here is the caller graph for this function:

◆ getInputAlphabet() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::set< SymbolType > && automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getInputAlphabet ( ) &&
inline

Getter of the input alphabet.

Returns
the input alphabet of the automaton
Here is the call graph for this function:

◆ getInputAlphabet() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::set< SymbolType > & automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getInputAlphabet ( ) const &
inline

Getter of the input alphabet.

Returns
the input alphabet of the automaton
Here is the caller graph for this function:

◆ getStates() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::set< StateType > && automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getStates ( ) &&
inline

Getter of states.

Returns
the states of the automaton
Here is the call graph for this function:

◆ getStates() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::set< StateType > & automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getStates ( ) const &
inline

Getter of states.

Returns
the states of the automaton
Here is the caller graph for this function:

◆ getTapeAlphabet() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::set< SymbolType > && automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getTapeAlphabet ( ) &&
inline

Getter of the tape alphabet.

Returns
the tape alphabet of the automaton
Here is the call graph for this function:

◆ getTapeAlphabet() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::set< SymbolType > & automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::getTapeAlphabet ( ) const &
inline

Getter of the tape alphabet.

Returns
the tape alphabet of the automaton
Here is the caller graph for this function:

◆ getTransitions() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::map< ext::pair< StateType, SymbolType >, ext::tuple< StateType, SymbolType, Shift > > && automaton::OneTapeDTM< SymbolType, StateType >::getTransitions ( ) &&

Get the transition function of the automaton in its natural form.

Returns
transition function of the automaton

◆ getTransitions() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::map< ext::pair< StateType, SymbolType >, ext::tuple< StateType, SymbolType, Shift > > & automaton::OneTapeDTM< SymbolType, StateType >::getTransitions ( ) const &

Get the transition function of the automaton in its natural form.

Returns
transition function of the automaton
Here is the caller graph for this function:

◆ operator<=>()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
auto automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::operator<=> ( const OneTapeDTM< SymbolTypeT, StateTypeT > &  other) const
inline

The three way comparison implementation

Parameters
otherthe other instance
Returns
the ordering between this object and the other.
Here is the call graph for this function:

◆ operator==()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::operator== ( const OneTapeDTM< SymbolTypeT, StateTypeT > &  other) const
inline

The equality comparison implementation.

Parameters
otherthe other object to compare with.
Returns
true if this and other objects are equal, false othervise
Here is the call graph for this function:

◆ removeFinalState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::removeFinalState ( const StateType state)
inline

Remover of a final state.

Parameters
statea state to be removed from a set of final states
Returns
true if the state was indeed removed

◆ removeInputSymbol()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::removeInputSymbol ( const SymbolType symbol)
inline

Remover of an input symbol.

Parameters
symbola symbol to be removed from an input alphabet
Returns
true if the symbol was indeed removed

◆ removeState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::removeState ( const StateType state)
inline

Remover of a state.

Parameters
statea state to be removed from a set of states
Returns
true if the state was indeed removed

◆ removeTapeSymbol()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::removeTapeSymbol ( const SymbolType symbol)
inline

Remover of a tape symbol.

Parameters
symbola symbol to be removed from a tape alphabet
Returns
true if the symbol was indeed removed

◆ removeTransition()

template<class SymbolType , class StateType >
bool automaton::OneTapeDTM< SymbolType, StateType >::removeTransition ( const StateType from,
const SymbolType input,
const StateType to,
const SymbolType output,
const Shift shift 
)

Removes a transition from the automaton.

The transition is in a form A \times a -> B \times b \times {-1, 0, 1}, where A, B \in Q and a, b \in G

Parameters
currentthe source state (A)
inputthe tape symbol (a)
nextthe target state (B)
outputthe tape symbol (b)
shiftthe direction of change on the tape
Returns
true if the transition was indeed removed
Here is the call graph for this function:

◆ setBlankSymbol()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::setBlankSymbol ( SymbolType  state)
inline

Setter of the blank symbol.

Parameters
statenew blank symbol of the automaton
Returns
true if the blank symbol was indeed changed

◆ setFinalStates()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::setFinalStates ( ext::set< StateType states)
inline

Setter of final states.

Parameters
statescompletely new set of final states

◆ setInitialState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::setInitialState ( StateType  state)
inline

Setter of the initial state.

Parameters
statenew initial state of the automaton
Returns
true if the initial state was indeed changed

◆ setInputAlphabet()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::setInputAlphabet ( ext::set< SymbolType symbols)
inline

Setter of input alphabet.

Parameters
symbolscompletely new input alphabet

◆ setStates()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::setStates ( ext::set< StateType states)
inline

Setter of states.

Parameters
statescompletely new set of states

◆ setTapeAlphabet()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::OneTapeDTM< SymbolTypeT, StateTypeT >::setTapeAlphabet ( ext::set< SymbolType symbols)
inline

Setter of tape alphabet.

Parameters
symbolscompletely new tape alphabet

Friends And Related Function Documentation

◆ operator<<

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::ostream & operator<< ( ext::ostream out,
const OneTapeDTM< SymbolTypeT, StateTypeT > &  instance 
)
friend

Print this object as raw representation to ostream.

Parameters
outostream where to print
instanceobject to print
Returns
modified output stream

The documentation for this class was generated from the following file: