This project has been developed as part of the "Algoritmi e Principi dell'Informatica" course at Politecnico di Milano.
Yet another C program that simulates a single-strip nondeterministic Turing Machine.
The program expects its input from stdio with the following format.
The transitions block starts with the tr
keyword and a list of
state transitions follow (one per line).
Each transition has the following format:
<in_state> <in_char> <out_char> <move> <next_state>
where:
- states are represented by integers
- chars are ASCII characters,
_
representing the special blank charachter - move can be any of
L
,S
orR
for left, stop or right
The accepting states block starts with the acc
keyword.
Accepting states are written one per line.
The number written under max
sets the maximum number of steps
the machine can perform on each branch of the computation tree
before giving up.
The run
section contains the strings on which to simulate the
machine, one per line.
Example of the input stream:
tr
1 a a R 1
2 _ _ R 0
0 _ _ L 3
3 b b L 3
3 a b L 4
acc
4
max
5000
run
ba
ab
aaaabb
bbaa
aaaabbbbbb
The output is written to stdout.
Each line contains exactly a symbol between
0
: string not accepted1
: string acceptedU
: undetermined, reached max steps.
Example of the output stream:
0
1
U
0
U
Just run make
The program can be compiled with the -DDEBUG
flag to turn on debug
prints on stdout.
These will print the transitions and the strip at every transition,
plus some more useful events.