TuringSim
C++ framework to simulate abstract computing models
localTuringMachineTransition.h
1 #pragma once
2 
3 #include <symbol/symbolPattern.h>
4 #include <transition/Turing/turingMachineTransition.h>
5 
7 
17  template<
18  typename StateType_,
19  typename SymbolType_,
20  typename ApplyHelperType_,
21  bool hasHalfTape = false
22  >
23  class LocalTuringMachineTransition : public TuringMachineTransition<StateType_, SymbolType_, ApplyHelperType_, hasHalfTape> {
25  public:
32 
33  static_assert(std::is_same_v<SymbolType, SymbolType_>);
34  static_assert(std::is_same_v<StorageType, Memory::TapeLike<hasHalfTape, SymbolType_>>);
35  static_assert(std::is_same_v<StateType, StateType_>);
36 
39 
42 
45 
50 
55 
57  virtual ~LocalTuringMachineTransition() override = default;
58 
66  virtual std::optional<ApplyHelperType> match(const StateType& state, const StorageType& tape) const override final {
67  return this->matchFromCurrentCell(state, tape.read());
68  }
69 
77  virtual std::optional<ApplyHelperType> matchFromCurrentCell(const StateType& state, const SymbolType& symbol) const = 0;
78  };
79 }
TuringSim::Transition::Turing::LocalTuringMachineTransition::LocalTuringMachineTransition
LocalTuringMachineTransition(LocalTuringMachineTransition &&)=default
The default move constructor.
TuringSim::Transition::Turing::LocalTuringMachineTransition::~LocalTuringMachineTransition
virtual ~LocalTuringMachineTransition() override=default
The default virtual destructor.
TuringSim::Memory::TapeLike
std::conditional_t< isHalfTape, HalfTape::HalfTape< SymbolType >, Tape::Tape< SymbolType > > TapeLike
Definition: tapeLike.h:12
TuringSim::Transition::Turing
Transitions for Turing machines.
Definition: localTuringMachineTransition.h:6
TuringSim::Transition::Transition< std::shared_ptr< const State::MConfiguration::MConfiguration< std::string > >, Memory::TapeLike< hasHalfTape, std::string >, MConfigurationTuringMachineTransitionApplyHelper< std::string > >::StateType
std::shared_ptr< const State::MConfiguration::MConfiguration< std::string > > StateType
The type of states.
Definition: transition.h:72
TuringSim::Transition::Turing::LocalTuringMachineTransition::operator=
LocalTuringMachineTransition & operator=(const LocalTuringMachineTransition &)=default
The default copy assignment operator.
TuringSim::Transition::Turing::TuringMachineTransition::StateType
StateType_ StateType
The type of states.
Definition: transition.h:72
TuringSim::Transition::Turing::TuringMachineTransition::ApplyHelperType
ApplyHelperType_ ApplyHelperType
The type of apply helpers.
Definition: transition.h:82
TuringSim::Transition::Turing::LocalTuringMachineTransition::LocalTuringMachineTransition
LocalTuringMachineTransition(const LocalTuringMachineTransition &)=default
The default copy constructor.
TuringSim::Transition::Turing::LocalTuringMachineTransition::operator=
LocalTuringMachineTransition & operator=(LocalTuringMachineTransition &&)=default
The default move assignment operator.
TuringSim::Transition::Turing::LocalTuringMachineTransition::LocalTuringMachineTransition
LocalTuringMachineTransition()=default
The default constructor.
TuringSim::Transition::Turing::LocalTuringMachineTransition::match
virtual std::optional< ApplyHelperType > match(const StateType &state, const StorageType &tape) const override final
Test whether the transition matches a configuration. Returned optional is empty iff the transition do...
Definition: localTuringMachineTransition.h:66
TuringSim::Transition::Turing::LocalTuringMachineTransition::matchFromCurrentCell
virtual std::optional< ApplyHelperType > matchFromCurrentCell(const StateType &state, const SymbolType &symbol) const =0
Test whether the transition matches a configuration. Returned optional is empty iff the transition do...
TuringSim::Transition::Turing::LocalTuringMachineTransition< std::shared_ptr< const State::MConfiguration::MConfiguration< std::string > >, std::string, MConfigurationTuringMachineTransitionApplyHelper< std::string >, hasHalfTape >::SymbolType
std::string SymbolType
The type of symbols on the tape.
Definition: turingMachineTransition.h:37
TuringSim::Transition::Turing::TuringMachineTransition::StorageType
StorageType_ StorageType
The type of storage.
Definition: transition.h:77
TuringSim::Transition::Turing::TuringMachineTransition
Base class for Turing machine transitions.
Definition: turingMachineTransition.h:26
TuringSim::Transition::Turing::TuringMachineTransition::HasHalfTape
std::integral_constant< bool, hasHalfTape > HasHalfTape
Whether the tape is a half-tape or a full tape.
Definition: turingMachineTransition.h:49
TuringSim::Transition::Turing::TuringMachineTransition::SymbolType
SymbolType_ SymbolType
The type of symbols on the tape.
Definition: turingMachineTransition.h:37
TuringSim::Transition::Transition< StateType_, Memory::TapeLike< hasHalfTape, SymbolType_ >, ApplyHelperType_ >::StorageType
Memory::TapeLike< hasHalfTape, SymbolType_ > StorageType
The type of storage.
Definition: transition.h:77
TuringSim::Transition::Turing::LocalTuringMachineTransition
Base class for Turing machine transitions that only reads the current symbol on the tape to decide if...
Definition: localTuringMachineTransition.h:23
TuringSim::Transition::Turing::TuringMachineTransition::Movement
StorageType_::Movement Movement
The type of movement on the tape.
Definition: turingMachineTransition.h:42