MTMS main
Modern Turing Machine Simulator
Loading...
Searching...
No Matches
Transition Class Reference

Represents a multi-tape transition rule (δ: Q × Γ^k → Q × Γ^k × {L, R}^k). More...

#include <transition.hpp>

Collaboration diagram for Transition:

Public Member Functions

const Stateget_current_state () const noexcept
 Retrieves the source state required to trigger this transition.
 
const std::vector< Direction > & get_directions () const noexcept
 Retrieves the directions in which each parallel tape head must shift.
 
std::size_t get_id () const noexcept
 Retrieves the unique identifier of this transition rule.
 
const Stateget_next_state () const noexcept
 Retrieves the target state the machine will enter after executing this rule.
 
const std::vector< Symbol > & get_read_symbols () const noexcept
 Retrieves the collection of symbols that must be present under the tape heads.
 
const std::vector< Symbol > & get_write_symbols () const noexcept
 Retrieves the new symbols that will overwrite the current parallel tape cells.
 
auto operator<=> (const Transition &other) const noexcept
 Lexicographical ordering of transitions for container storage.
 
bool operator== (const Transition &other) const noexcept
 Checks equality of transitions based on their semantic identity.
 
void set_direction_at (std::size_t tape_idx, const Direction &dir) noexcept(false)
 Allows granular modification of a specific tape cell.
 
void set_directions (std::vector< Direction > dir) noexcept
 Modifies the heads' movement direction.
 
void set_next_state (State next) noexcept
 Modifies the transition's destination state.
 
void set_read_symbol_at (std::size_t tape_idx, const Symbol &sym) noexcept(false)
 Allows granular modification of a specific tape cell.
 
void set_read_symbols (std::vector< Symbol > read) noexcept
 Modifies the whole reading symbols block (k-tapes).
 
void set_write_symbol_at (std::size_t tape_idx, const Symbol &sym) noexcept(false)
 Allows granular modification of a specific tape cell.
 
void set_write_symbols (std::vector< Symbol > write) noexcept
 Modifies the whole writing symbols block (k-tapes).
 
 Transition ()=default
 Default constructor.
 
 Transition (std::size_t id, State current, State next, std::vector< Symbol > read, std::vector< Symbol > write, std::vector< Direction > dir) noexcept
 Explicit constructor to define a complete multi-tape transition rule.
 

Private Attributes

State current_state_
 Source state for the transition rule.
 
std::vector< Directiondir_vectors_
 Structural head shift directions vector.
 
std::size_t id_ {0}
 Unique runtime identifier for UI and graph edge tracking.
 
State next_state_
 Destination state after execution.
 
std::vector< Symbolread_symbols_
 Expected vector array of symbols on the tracks.
 
std::vector< Symbolwrite_symbols_
 New vector array of symbols to write.
 

Detailed Description

Represents a multi-tape transition rule (δ: Q × Γ^k → Q × Γ^k × {L, R}^k).

Defines the synchronized actions to take across all k parallel tapes when the Turing Machine is in a specific state.

Definition at line 28 of file transition.hpp.

Constructor & Destructor Documentation

◆ Transition() [1/2]

Transition::Transition ( )
default

Default constructor.

Initializes an empty transition shifting LEFT.

◆ Transition() [2/2]

Transition::Transition ( std::size_t  id,
State  current,
State  next,
std::vector< Symbol read,
std::vector< Symbol write,
std::vector< Direction dir 
)
inlineexplicitnoexcept

Explicit constructor to define a complete multi-tape transition rule.

Parameters
idUnique runtime identifier for UI and graph edge tracking.
currentThe required state to trigger this transition.
nextThe target state the machine will transition into.
readThe collection of symbols expected under each parallel tape head.
writeThe collection of new symbols to overwrite onto each tape track.
dirThe collection of displacement directions for each tape head.

Definition at line 45 of file transition.hpp.

Member Function Documentation

◆ get_current_state()

const State & Transition::get_current_state ( ) const
inlinenoexcept

Retrieves the source state required to trigger this transition.

Returns
const State& A read-only reference to the current execution state.

Definition at line 68 of file transition.hpp.

References current_state_.

◆ get_directions()

const std::vector< Direction > & Transition::get_directions ( ) const
inlinenoexcept

Retrieves the directions in which each parallel tape head must shift.

Returns
const std::vector<Direction>& A read-only reference to the head movement vectors.

Definition at line 98 of file transition.hpp.

References dir_vectors_.

Referenced by TuringMachine::step().

◆ get_id()

std::size_t Transition::get_id ( ) const
inlinenoexcept

Retrieves the unique identifier of this transition rule.

Useful for persistent mapping in GUI elements, undo/redo stacks, and graph edge binding.

Definition at line 62 of file transition.hpp.

References id_.

◆ get_next_state()

const State & Transition::get_next_state ( ) const
inlinenoexcept

Retrieves the target state the machine will enter after executing this rule.

Returns
const State& A read-only reference to the next execution state.

Definition at line 74 of file transition.hpp.

References next_state_.

Referenced by TuringMachine::step().

◆ get_read_symbols()

const std::vector< Symbol > & Transition::get_read_symbols ( ) const
inlinenoexcept

Retrieves the collection of symbols that must be present under the tape heads.

Returns
const std::vector<Symbol>& A read-only reference to the expected symbols vector.

Definition at line 80 of file transition.hpp.

References read_symbols_.

◆ get_write_symbols()

const std::vector< Symbol > & Transition::get_write_symbols ( ) const
inlinenoexcept

Retrieves the new symbols that will overwrite the current parallel tape cells.

Returns
const std::vector<Symbol>& A read-only reference to the symbols to be written.

Definition at line 89 of file transition.hpp.

References write_symbols_.

Referenced by TuringMachine::step().

◆ operator<=>()

auto Transition::operator<=> ( const Transition other) const
inlinenoexcept

Lexicographical ordering of transitions for container storage.

Warning
This ordering is purely structural and does NOT represent mathematical equivalence of transitions in the Turing Machine definition.

Definition at line 124 of file transition.hpp.

◆ operator==()

bool Transition::operator== ( const Transition other) const
inlinenoexcept

Checks equality of transitions based on their semantic identity.

This definition allows detecting non-determinism in the Turing Machine by treating transitions with identical (state, read_symbols) as conflicts.

Parameters
otherThe transition to compare against.
Returns
true if both transitions represent the same input condition.

Definition at line 112 of file transition.hpp.

References current_state_, and read_symbols_.

◆ set_direction_at()

void Transition::set_direction_at ( std::size_t  tape_idx,
const Direction dir 
)
inline

Allows granular modification of a specific tape cell.

Exceptions
std::out_of_rangeIf the tape index is invalid.

Definition at line 192 of file transition.hpp.

References dir_vectors_.

◆ set_directions()

void Transition::set_directions ( std::vector< Direction dir)
inlinenoexcept

Modifies the heads' movement direction.

Definition at line 157 of file transition.hpp.

References dir_vectors_.

◆ set_next_state()

void Transition::set_next_state ( State  next)
inlinenoexcept

Modifies the transition's destination state.

Definition at line 136 of file transition.hpp.

References next_state_.

◆ set_read_symbol_at()

void Transition::set_read_symbol_at ( std::size_t  tape_idx,
const Symbol sym 
)
inline

Allows granular modification of a specific tape cell.

Exceptions
std::out_of_rangeIf the tape index is invalid.

Definition at line 166 of file transition.hpp.

References read_symbols_.

◆ set_read_symbols()

void Transition::set_read_symbols ( std::vector< Symbol read)
inlinenoexcept

Modifies the whole reading symbols block (k-tapes).

Definition at line 141 of file transition.hpp.

References read_symbols_.

◆ set_write_symbol_at()

void Transition::set_write_symbol_at ( std::size_t  tape_idx,
const Symbol sym 
)
inline

Allows granular modification of a specific tape cell.

Exceptions
std::out_of_rangeIf the tape index is invalid.

Definition at line 179 of file transition.hpp.

References write_symbols_.

◆ set_write_symbols()

void Transition::set_write_symbols ( std::vector< Symbol write)
inlinenoexcept

Modifies the whole writing symbols block (k-tapes).

Definition at line 149 of file transition.hpp.

References write_symbols_.

Member Data Documentation

◆ current_state_

State Transition::current_state_
private

Source state for the transition rule.

Definition at line 203 of file transition.hpp.

Referenced by get_current_state(), and operator==().

◆ dir_vectors_

std::vector<Direction> Transition::dir_vectors_
private

Structural head shift directions vector.

Definition at line 207 of file transition.hpp.

Referenced by get_directions(), set_direction_at(), and set_directions().

◆ id_

std::size_t Transition::id_ {0}
private

Unique runtime identifier for UI and graph edge tracking.

Definition at line 202 of file transition.hpp.

Referenced by get_id().

◆ next_state_

State Transition::next_state_
private

Destination state after execution.

Definition at line 204 of file transition.hpp.

Referenced by get_next_state(), and set_next_state().

◆ read_symbols_

std::vector<Symbol> Transition::read_symbols_
private

Expected vector array of symbols on the tracks.

Definition at line 205 of file transition.hpp.

Referenced by get_read_symbols(), operator==(), set_read_symbol_at(), and set_read_symbols().

◆ write_symbols_

std::vector<Symbol> Transition::write_symbols_
private

New vector array of symbols to write.

Definition at line 206 of file transition.hpp.

Referenced by get_write_symbols(), set_write_symbol_at(), and set_write_symbols().


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