|
TuringSim
C++ framework to simulate abstract computing models
|
3 #include <symbol/simpleSymbolPattern.h>
4 #include <state/simpleStatePattern.h>
5 #include <transition/Turing/oneStepTuringMachineTransition.h>
22 bool hasHalfTape =
false>
31 typedef std::monostate ApplyHelperType_;
41 static_assert(std::is_same_v<StateType_, StateType>);
42 static_assert(std::is_same_v<SymbolType_, SymbolType>);
44 static_assert(std::is_same_v<ApplyHelperType, std::monostate>);
68 postSymbol(postSymbol),
92 if(preSymbol.
match(symbol) && preState.
match(conf)) {
93 return std::optional<std::monostate>(std::monostate());
95 return std::optional<std::monostate>();
106 return {postState, postSymbol, movement};
130 if(preState < other.preState) {
133 if(other.preState < preState) {
136 if(preSymbol < other.preSymbol) {
139 if(other.preSymbol < preSymbol) {
142 if(postState < other.postState) {
145 if(other.postState < postState) {
148 if(postSymbol < other.postSymbol) {
151 if(other.postSymbol < postSymbol) {
154 if(movement < other.movement) {
157 if(other.movement < movement) {
virtual std::tuple< StateType, SymbolType, Movement > getPostElements(const StateType &, const SymbolType &, std::monostate &&) const override final
get the new state, the new symbol and the movement to execute.
virtual std::optional< std::monostate > matchFromCurrentCell(const StateType &conf, const SymbolType &symbol) const override final
Test whether the transition matches a configuration. Returned optional is empty iff the transition do...
virtual bool match(const T &letter) const noexcept override
Test if a symbol matches the symbol.
SimpleTuringMachineTransition(const StateType &preState, const SymbolType &preSymbol, const StateType &postState, const SymbolType &postSymbol, const Movement &movement)
The straightforward constructor: we specify each component of the transition separately.
std::conditional_t< isHalfTape, HalfTape::HalfTape< SymbolType >, Tape::Tape< SymbolType > > TapeLike
Transitions for Turing machines.
virtual ~SimpleTuringMachineTransition() override=default
The default virtual destructor.
const T & getLetter() const
Get the accepted letter, for optimized containers.
StateType_ StateType
The type of states.
SimpleTuringMachineTransition & operator=(const SimpleTuringMachineTransition &)=default
The default copy assignment operator.
ApplyHelperType_ ApplyHelperType
The type of apply helpers.
const StateType & getPreState() const
Get the only accepted state. Useful to store SimpleTuringMachineTransition into std::map,...
SymbolType_ SymbolType
The type of symbols on the tape.
constexpr const T & getState() const
get the accepting state
Turing machine transitions that reads only the current symbol, writes a symbol, performs a simple mov...
virtual std::optional< MatcherType > match(const T &state) const noexcept override
Test if a state matches.
StorageType_::Movement Movement
The type of movement on the tape.
SimpleTuringMachineTransition(SimpleTuringMachineTransition &&)=default
The default move constructor.
bool operator<(const SimpleTuringMachineTransition &other) const
A strong total order.
SimpleTuringMachineTransition & operator=(SimpleTuringMachineTransition &&)=default
The default move assignment operator.
SimpleTuringMachineTransition()=delete
An SimpleTuringMachineTransition makes no sense.
SymbolType_ SymbolType
The type of symbols on the tape.
std::integral_constant< bool, hasHalfTape > HasHalfTape
Whether the tape is a half-tape or a full tape.
StorageType_ StorageType
The type of storage.
StorageType_::Movement Movement
The type of movement on the tape.
Turing machine transition where the state pattern is a TuringSim::State::SimpleStatePattern and the s...
SimpleTuringMachineTransition(const SimpleTuringMachineTransition &)=default
The default copy constructor.
const SymbolType & getPreSymbol() const
Get the only accepted symbol. Useful to store SimpleTuringMachineTransition into std::map,...
Memory::TapeLike< hasHalfTape, SymbolType_ > StorageType
The type of storage.
std::tuple< StateType, SymbolType, Movement > getPostElementsTrivially() const
Get the new state, the new symbol and the movement.