Title: Languages and Finite Automata
1Formal Languages Turing Machines Hinrich
Schütze IMS, Uni Stuttgart, WS 2007/08 Slides
based on RPI CSCI 2400 Thanks to Costas Busch
2A Turing Machine
Tape
......
......
Read-Write head
Control Unit
3The Tape
No boundaries -- infinite length
......
......
Read-Write head
The head moves Left or Right
4......
......
Read-Write head
The head at each time step 1.
Reads a symbol 2. Writes a
symbol 3. Moves Left or Right
5Example
Time 0
......
......
Time 1
......
......
1. Reads
2. Writes
3. Moves Left
6Time 1
......
......
Time 2
......
......
1. Reads
2. Writes
3. Moves Right
7The Input String
Input string
Blank symbol
......
......
head
Head starts at the leftmost position of the input
string
8Input string
Blank symbol
......
......
head
Remark the input string is never empty
9States Transitions
Write
Read
Move Left
Move Right
10Example
Time 1
......
......
current state
11Time 1
......
......
Time 2
......
......
12Example
Time 1
......
......
Time 2
......
......
13Example
Time 1
......
......
Time 2
......
......
14Determinism
Turing Machines are deterministic
Not Allowed
Allowed
No lambda transitions allowed
15Partial Transition Function
Example
......
......
Allowed
No transition for input symbol
16Halting
The machine halts if there are no possible
transitions to follow
17Example
......
......
No possible transition
HALT
18Final States
Allowed
Not Allowed
- Final states have no outgoing transitions
- In a final state the machine halts
19Acceptance
If machine halts in a final state
Accept Input
If machine halts in a non-final state
or If machine enters an infinite loop
Reject Input
20Turing Machine Example
Language?
21Turing Machine Example
A Turing machine that accepts the language
22Time 0
23Time 1
24Time 2
25Time 3
26Time 4
Halt Accept
27Rejection Example
Time 0
28Time 1
No possible Transition
Halt Reject
29Language?
30Infinite Loop Example
A Turing machine for language
31Time 0
32Time 1
33Time 2
34Time 2
Time 3
Infinite loop
Time 4
Time 5
35- Because of the infinite loop
- The final state cannot be reached
- The machine never halts
- The input is not accepted
36Another Turing Machine Example
Language?
37Another Turing Machine Example
Turing machine for the language
38Time 0
39Time 1
40Time 2
41Time 3
42Time 4
43Time 5
44Time 6
45Time 7
46Time 8
47Time 9
48Time 10
49Time 11
50Time 12
51Time 13
Halt Accept
52Observation
If we modify the machine for the language
we can easily construct a machine for the
language
53Formal Definitionsfor Turing Machines
54Transition Function
55Transition Function
56Turing Machine
Input alphabet
Tape alphabet
States
Transition function
Final states
Initial state
blank
57Configuration
Instantaneous description
58Time 4
Time 5
A Move
59Time 4
Time 5
Time 6
Time 7
60Equivalent notation
61Initial configuration
Input string
62The Accepted Language
For any Turing Machine
Initial state
Final state
63Standard Turing Machine
The machine we described is the standard
- Deterministic
- Infinite tape in both directions
- Tape is the input/output file
64Machine for L vvv in a,b ?
65Computing FunctionswithTuring Machines
66A function
has
Range
Domain
67A function may have many parameters
Example
Addition function
68Integer Domain
Decimal
5
Binary
101
Unary
11111
69Definition
A function is computable if there is
a Turing Machine such that
Initial configuration
Final configuration
final state
initial state
For all
Domain
70In other words
A function is computable if there is
a Turing Machine such that
Initial Configuration
Final Configuration
For all
Domain
71Example
is computable
The function
are integers
Turing Machine
Input string
unary
Output string
unary
72Start
initial state
The 0 is the delimiter that separates the two
numbers
73Start
initial state
Finish
final state
74The 0 helps when we use the result for other
operations
Finish
final state
75Turing machine for function
76Execution Example
Time 0
(2)
(2)
Final Result
77Time 0
78Time 1
79Time 2
80Time 3
81Time 4
82Time 5
83Time 6
84Time 7
85Time 8
86Time 9
87Time 10
88Time 11
89Time 12
HALT accept
90Another Example
is computable
The function
is integer
Turing Machine
Input string
unary
Output string
unary
91Start
initial state
Finish
final state
92Turing Machine for
93Turing Machine Pseudocode for
- Find rightmost , replace it with 1
- Go to right end, insert 1
Until no more remain
94Example
Start
Finish
95Another Example
if
The function
if
is computable
96Turing Machine for
if
if
Input
or
Output
97Turing Machine Pseudocode
Match a 1 from with a 1 from
Until all of or is matched
- If a 1 from is not matched
- erase tape, write 1
- else
- erase tape, write 0
98Combining Turing Machines
99Block Diagram
Turing Machine
input
output
100Example
if
if
Adder
Comparer
Eraser