Example of a Turing-Computable Function

THE CONVENTIONS
2 simple rules:
• Rule # 1:
R “move to the right until you find “
R “move to the right until you find a symbol other than “
Note: first check. Then move (think of a “while”)
• Rule # 2:
“Never forget Rule # 1”
(Mr Miogi, The Karate Kid)
Input and Output of Turing Machines
When constructing Turing machines we have to establish
conventions:
For example, the Turing machine ( = {
, a, b, •
, }):
…
Does the following: when starting with a configuration of
the form (s, w), where w  ( - {, •
,
})* then the final
configuration is (h, ww).
Acceptance in Previous Machines
Machine
Configuration
Acceptance if
Finite automata
(q,w)
q: final state, w = e
Pushdown automata
(q,w,)
q: final state, w =e
=e
(q,w,)
w =e,  = e
Pushdown automata
accepting by empty
stack
These machines are used to compute if a word belongs to a language
Input and Output of Turing Machines (2)
Idea:
Input:
 a a b … a 
state: s
( - {, •
})*
Output:
 b a a … b 
( - {, •
})*
0
state: h
Functions (Again)
Definition. A function, f, from A to B is a relation such that for
every a  A there is one and only one b  A with f(a) = b
This definition says that 2 things should happen:
First, that “no one (in A) is left
behind”
A
a
d
B
Second, that each element
in A has a unique
representative in B
A
a
d
Example: transitions in Turing machines
B
Functions (Again – Part 2)
From the two restrictions, the first can be easily overcome:
A
Dom(f) = {a  A : there is a b  B with f(a) = b}
One can restrict f to be from Dom(f) to B. In this situation
one speaks of a partial function
Example: f from Real to Real defined as f(x) = 1/x.
Dom(f) = Real - {0} (Thus f is a partial function)
Input and Output of Turing Machines (3)
Definition. Let:
•M = (S, , , s, H) be a Turing machine
•0 =  - {, •
}
•Suppose that M starts with (s,w) with w  0*
If the machine ends in a configuration (h,u•
) with u  0*
and h  H, then:
•u is referred to as the output of M and write M(w) = u
•We can view M as a function f (from 0* into 0*), with
f(w) = u. We say that M computes f.
•If M does not end for a w’  0*, then we write M(w’)
Turing-Computable Functions
Definition. A function f: 0*  0* is said to be Turing
computable if there exists a Turing machine M that computes it
(i.e., for each w  dom(f), f(w)=M(w)) and dom(f) = 0*.
If dom(f) is an strict subset of 0* (i.e., dom(f)  0* and dom(f) 
0*), we say that f is partial Turing computable
Example of a Turing-Computable
Function
f(w) = wa where a is a fixed character in 0 and w  0*
Example of a Turing-Computable
Function (2)
f(w) = ww where and w  0*
Let M be the machine that terminates in the configuration
(h, ww) when starting with (s, w) (see Slide # 2)
M
…
Computing (Deciding) Languages
Definition. Let L be a language in 0* we define the
characteristic function, L, as follows:
• L(w) = 1, if w  L
• L(w) = 0, otherwise
Definition. A language L is Turing-computable or
decidable if its characteristic function, L, is Turingcomputable
Regular Languages are TuringComputable (1)
Steps to obtain a Turing machine accepting a regular language:
•Let L be a regular language on alphabet {a,b}
•Let A be a deterministic automata accepting L
•It is easy to simulate A with a Turing machine ML:
((p,a),q)
((p,a),(q,))
For every favorable state f in A, add the transition:
((f,),(h,1))
Regular Languages are TuringComputable (2)
Use the machine ML as follows:
1
M1
ML
1
M0
This Turing machine recognizes the language L
Every regular language is Turing-computable (decidable)
Homework
• 4.9, 4.10, See slide # 10