25 std::set<State> states,
27 std::size_t tape_count
29 : input_alphabet_(std::move(input_alpha)), tape_alphabet_(std::move(tape_alpha)),
30 states_(std::move(states)), start_state_(initial_state),
31 current_state_(std::move(initial_state)), tape_count_(tape_count)
34 this->tapes_.resize(this->tape_count_);
49 this->tapes_.assign(this->tape_count_,
Tape());
50 this->tapes_[0] =
Tape(str);
51 this->current_state_ = this->start_state_;
69 std::vector<Symbol> current_read;
71 for (
const auto &tape : this->
tapes_)
73 current_read.push_back(tape.read());
81 transition.get_read_symbols() == current_read)
83 next_step_rule = &transition;
89 if (next_step_rule ==
nullptr)
113 int step_counter = 0;
120 "[-] Execution forced-halted. Exceeded max security step limit ({} cycles).",
Represents the formal alphabet ( or ) of a Turing Machine.
Represents a single state in the finite set of states (Q) of the Turing Machine.
bool is_accept() const noexcept
Checks if this state is an accepting (final) state.
Represents a formal string (w) consisting of a finite sequence of Symbols.
bool is_valid_for(const Alphabet &alphabet) const noexcept
Validates if all symbols within this string belong to a specific formal Alphabet.
Simulates the bilateral infinite tape layout of a Turing Machine.
Represents a multi-tape transition rule (δ: Q × Γ^k → Q × Γ^k × {L, R}^k).
const std::vector< Direction > & get_directions() const noexcept
Retrieves the directions in which each parallel tape head must shift.
const std::vector< Symbol > & get_write_symbols() const noexcept
Retrieves the new symbols that will overwrite the current parallel tape cells.
const State & get_next_state() const noexcept
Retrieves the target state the machine will enter after executing this rule.
bool step() noexcept(false)
Executes a single computational transition step across all parallel tapes.
bool load_input(std::string_view input) noexcept(false)
Validates an input word against the input alphabet and loads it onto Tape 0.
void run() noexcept(false)
Loops execution triggers calling step() continuously until a halting condition occurs or the safety s...
std::vector< Tape > tapes_
Collection of k dynamic memory layouts.
State current_state_
Active contextual processing marker.
TuringMachine() noexcept
Default constructor.
std::size_t tape_count_
Cardinality multiplier tracking active tapes (k).
std::unordered_map< std::size_t, Transition > transitions_
Lookup table for transitions by ID.
String class representing a formal string (sequence of symbols) over an alphabet.