Creates the components of the type system Turing machine.

no subtypes hierarchy

Initializer
TuringMachineCreator(Set<String> states, Set<Character> symbols, Set<Character> inputSymbols, String initialState, Set<String> acceptingStates, String? stateDescription(String state) = null, String? symbolDescription(Character symbol) = null)
Parameters:
  • states

    The set of states in which the turing machine can be.

  • symbols

    The set of symbols that can be written onto the tape (excluding the blank symbol).

  • inputSymbols

    The set of symbols that can be on the tape initially. Must be a subset of symbols.

  • initialState

    The initial state. Must be an element of states.

  • acceptingStates

    The accepting states. Must be a subset of states.

  • stateDescription = null

    Optionally: Descriptions for the states.

  • symbolDescription = null

    Optionally: Descriptions for the symbols.

Attributes
acceptDefinitionshared TypeAliasDefinition acceptDefinition

The definition of the Accept alias, a Box (see boxDefinition) around all accepting states (and any stack).

boxDefinitionshared InterfaceDefinition boxDefinition

The definition of the Box interface:

"Box around three types."
shared interface Box<out First, out Second, out Third> {
    shared formal First first;
    shared formal Second second;
    shared formal Third third;
}
buildFunctionDefinitionshared FunctionDefinition buildFunctionDefinition

The definition of the b function that can be used to build a stack:

shared RightStackHead<First, Rest> b<First, Rest>(First first, Rest rest)
        given First satisfies Symbol
        given Rest of RightStackHead<Symbol, Stack> | RightStackEnd
                 satisfies RightStack {
    return nothing;
}    
endFunctionDefinitionshared FunctionDefinition endFunctionDefinition

The definition of the e function that can be used to obtain an empty stack:

shared RightStackEnd e() {
    return nothing;
}
initialFunctionDefinitionshared FunctionDefinition initialFunctionDefinition

The definition of the initial function that can be used to turn an initial stack into an initial state + tape:

shared Box<State_${initialState}, LeftStackEnd, Input> initial<Input>(Input input)
        given Input satisfies RightSideStack {
    return nothing;
}
inputDefinitionsshared {ClassDefinition|ObjectDefinition*} inputDefinitions

The definitions for the input: One enumerated class Input_${symbol} satisfying Symbol_${symbol} (see symbolDefinitions) and one object input_${symbol} per input symbol.

stackDefinitionsshared {InterfaceDefinition*} stackDefinitions

The definition of the stack interfaces:

shared interface ${side}SideStack
        of ${side}StackHead<Symbol, Stack> | ${side}StackEnd 
    shared formal Symbol first;
    shared formal ${side}SideStack rest;
}
shared interface ${side}StackHead<out Element, out Rest>
        satisfies ${side}SideStack
        given Element satisfies Symbol
        given Rest satisfies ${side}SideStack {
    shared actual formal Element first;
    shared actual formal Rest rest;
}
shared interface ${side}StackEnd
        satisfies ${side}SideStack {
    shared actual formal Nothing first;
    shared actual formal Nothing rest;
}

for side in “Left”, “Right”.

(We need two non-disjoint stack interfaces in order to be able to peek left and right simultaneously and independently.)

stateDefinitionsshared {InterfaceDefinition*} stateDefinitions

The definitions for the states: One enumerated State interface with one case type State_${state} per state, along with the definitions of those state interfaces.

symbolDefinitionsshared {InterfaceDefinition*} symbolDefinitions

The definitions for the data tape: One enumerated Symbol interface, with one case type Symbol_${symbol} per symbol, along with the definitions of those tape symbol interfaces.

Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
transitionFunctionDefinitionshared FunctionDefinition transitionFunctionDefinition([String, Character, Movement] transition(String state, Character symbol))
Parameters:
  • transition

    The transition function.

    Returns:

    1. next state,
    2. symbol to write (_ for blank),
    3. movement
Throws
Inherited Methods
Methods inherited from: Object
equals