A Turing machine is a mathematical model of computation that defines an abstract machine, manipulates symbols on a strip of tape to a table of rules. (see. Wikipedia)
mvn clean installThe latest binary files are on the release section.
java -jar turingmachine-1.0-SNAPSHOT-uber.jarCURRENT_STATE READ_SYMBOLS -> SYMBOLS_TO_BE_WRITTEN NEXT_STATE MOVEMENTS
Example:
S1 a -> b S2 R
Explanation: On state S1 when a was read, write b and then shift the head to the right R and go to state S2.
| Reserved Syntax | Meaning |
|---|---|
-> |
Transition to next state |
# |
Blank |
| Reserved states | Meaning |
|---|---|
START |
Start state |
END |
End state |
| Head Movement | Meaning |
|---|---|
R |
Shift the head to the right on the next transition |
L |
Shift the head to the left on the next transition |
N |
Don't shift the head on the next transition |
Currently limited up to 7 tapes.
To be processed input: >aaa###<
START > -> > S1 R
S1 a -> a S1 R
S1 # -> b S2 R
S2 # -> b S2 R
S2 < -> < END Nresult: >aaabbb<
Given a context-free language
L(G) = { a^n -> a^2*n | n ∈ ℕ and n ≥ 1 }
START a -> § S1 R
S1 a -> a S1 R
S1 # -> b S2 L
S1 b -> b S1 R
S2 b -> b S2 L
S2 § -> § S4 N
S2 a -> a S3 L
S3 a -> a S3 L
S3 § -> § START R
S4 § -> b S4 L
S4 # -> # S5 R
S5 b -> a S5 R
S5 # -> # END N Given a context-sensitive language
L(G) = { a^n b^n c^n | n ∈ ℕ and n ≥ 0}
Code for the decidable of the given language:
START a # # -> a # # START R N N
START # # # -> $ $ $ END N N N
START b # # -> b # # S1 N N N
S1 b # # -> b b # S1 R R N
S1 c # # -> c # c S2 R N R
S2 c # # -> c # c S2 R N R
S2 # # # -> ### S3 L L L
S3 c b c -> c b c S3 L N N
S3 b b c -> b b c S3 L N N
S3 a b c -> a b c S4 L L L
S4 a b c -> a b c S4 L L L
S4 # # # -> $ $ $ END N N Nfor input: aaabbbccc -> Accepted!
for input: aabccc -> Declined!
MIT license © Lam