CSE 105
THEORY OF COMPUTATION
Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/
CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation
CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ Today's learning goals Sipser Ch 3 Trace the computation of a Turing machine using its transition function and configurations. Recognize when a
Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/
function and configurations.
explain why they are equally expressive.
enumerators) used in constructions
sets.
Context-free languages Regular languages
qreject ≠ qaccept
u q v current state is q current tape contents are uv (and then all blanks) current head location is first symbol of v
Start configuration on w: q0 w Accepting configuration: u qacc v Rejecting configuration: u qrej v Halting configuration: any configuration that is either rejecting or halting.
q0 w w is input, read/write head over the leftmost symbol of w u q v u' q' v' q' = δ(q, v1) How does uv compare to u'v'?
L(M) = { w | M accepts w} = { w | there is a sequence of configurations of M where C1 is start configuration of M on input w, each Ci yields Ci+1 and Ck is accepting configuration} "The language of M" "The language recognized by M"
recognizes it.
decider recognizes it.
L = { w#w | w is in {0,1}* } We already know that L is
We will prove that L is Turing-decidable and therefore also Turing-recognizable
L = { w#w | w is in {0,1}* } Idea for Turing machine
'#' to check whether these positions agree. If they do not, or if there is no '#', reject. If they do, cross them off.
any symbols to the right of '#': if there are any, reject; if there aren't, accept.
L = { w#w | w is in {0,1}* } Idea for Turing machine
'#' to check whether these positions agree. If they do not, or if there is no '#', reject. If they do, cross them off.
any symbols to the right of '#': if there are any, reject; if there aren't, accept.
Is this machine a decider?
matter what the input is.
Idea for Turing machine Zig-zag across tape to corresponding positions on either side of '#' to check whether these positions agree. If they do not, or if there is no '#', reject. If they do, cross them off. Once all symbols to the left of the '#' are crossed off, check for any symbols to the right of '#': if there are any, reject; if there aren't, accept.
q1 0 à ?, ? 1 à ?, ? # à ?, ? __ à ?, ?
Q = Σ = Γ = Fig 3.10 in Sipser *Some transitions omitted for readability*
alphabet, transition function, state state, accept state, reject state.
describe Turing machine head movements relative to contents of tape.
implementation details of machine. As part of this description, can "call" and run another TM as a subroutine.
"If the input string is finite, then at some point, the TM has to be able to finish reading it. Therefore, infinite looping can
(which is infinitely long)."
Which of the following is an implementation-level description of a TM which decides the empty set? M = "On input w:
Then, reject."
Then, reject."
Theorem: The class of decidable languages over fixed alphabet Σ is closed under union. Proof: Let … WTS …
Theorem: The class of decidable languages over fixed alphabet Σ is closed under union. Proof: Let L1 and L2 be languages and suppose M1 and M2 are TMs deciding these languages. We will define a new TM, M, via a high-level description. We will then show that L(M) = L1 U L2
Theorem: The class of decidable languages over fixed alphabet Σ is closed under union. Proof: Let L1 and L2 be languages and suppose M1 and M2 are TMs deciding these languages. Construct the TM M as "On input w,
1.
Run M1 on input w. If M1 accepts w, accept. Otherwise, go to 2.
2.
Run M2 on input w. If M2 accepts w, accept. Otherwise, reject." Proof of correctness soon, but first …
Theorem: The class of decidable languages over fixed alphabet Σ is closed under union. Proof: Let L1 and L2 be languages and suppose M1 and M2 are TMs deciding these languages. Construct the TM M as "On input w,
1.
Run M1 on input w. If M1 accepts w, accept. Otherwise, go to 2.
2.
Run M2 on input w. If M2 accepts w, accept. Otherwise, reject."
Could the same construction give us a proof that the class of recognizable languages is closed under union?
Theorem: The class of decidable languages over fixed alphabet Σ is closed under union. Proof: Let L1 and L2 be languages and suppose M1 and M2 are TMs deciding these languages. Construct the TM M as "On input w,
1.
Run M1 on input w. If M1 accepts w, accept. Otherwise, go to 2.
2.
Run M2 on input w. If M2 accepts w, accept. Otherwise, reject." Correctness of construction: WTS L(M) = L1 U L2 and M is a decider.
Multiple tapes
Nondeterminism
Enumerators
Model 1 is equally expressive as Model 2 iff
1 is recognizable by some machine in Model 2, and
2 is recognizable by some machine in Model 1.
Model 1 Model 2
Q x Γk à Q x Γk x {L,R}k Sketch of proof of equivalence: A. Given TM, build multitape TM recognizing same language. B. Given k-tape TM, build (1- tape) TM recognizing same language.
Q x Γ à P(Q x Γ x {L,R}) Sketch of proof of equivalence: A. Given TM, build nondeterminstic TM recognizing same language. B. Given nondeterministic TM, build (deterministic) TM recognizing same language. Idea: Try all possible branches of nondeterministic
tape, tape tracking nondeterministic braching.
accept input?
Finite State Control a b a b …. Unlimited tape Computation proceeds according to transition function. At any point, machine may "send" a string to printer. L(E) = { w | E eventually, in finite time, prints w}
accept input?
Finite State Control a b a b …. Unlimited tape Computation proceeds according to transition function. At any point, machine may "send" a string to printer. L(E) = { w | E eventually, in finite time, prints w} Can L(E) be infinite?
"For each Σ, there is an enumerator whose language is the set of all strings over Σ."
"For each Σ, there is an enumerator whose language is the set of all strings over Σ."
Lexicographic
strings first by length, then dictionary order. (p. 14)
Theorem: A language L is Turing-recognizable iff some enumerator enumerates L. Proof:
enumerator enumerates it.
is Turing-recognizable.
A.
Assume L is Turing-recognizable. WTS some enumerator enumerates it. Let M be a TM that recognizes L. We'll use M in a subroutine for high- level description of enumerator E. Let s1, s2, … be a list of all possible strings of Σ*. Define E as follows: E = "On input w, ignore input and repeat the following for each value of i=1,2,3…
1.
Run M for i steps on each input s1, …, si
2.
If any of the i computations of M accepts, print out the accepted string. Correctness?
recognizable. We'll use E in a subroutine for high-level description of Turing machine M that will recognize L. Define M as follows: M = "On input w,
1.
Run E. Every time E prints a string, compare it to w.
2.
If w ever appears as the output of E, accept. Correctness?
Multiple tapes
Nondeterminism
Enumerators
Also: wildly different models
Multiple tapes
Nondeterminism
Enumerators
Also: wildly different models
All these models are equally expressive!
Regular Context- Free Decidable Turing- Recognizable
be performed"
precise instructions for performing a computation or for solving a problem."
Church-Turing thesis Each algorithm can be implemented by some Turing machine.
Examples of algorithms / algorithmic problems:
Examples of algorithms / algorithmic problems:
Which of the following is true?
"On input w …
1.
..
2.
..
3.
… For inputs that aren't strings, we have to encode the object (represent it as a string) first Notation: <O> is the string that represents (encodes) the
<O1, …, On> is the single string that represents the tuple of objects O1, …, On
e.g. "Recognize whether a string is a palindrome." { w | w in {0,1}* and w = wR } e.g. "Recognize Pythagorean triples." { <a,b,c> | a,b,c integers and a2 + b2 = c2 } e.g. "Check whether a string is accepted by a DFA." { <B,w> | B is a DFA over Σ, w in Σ*, and w is in L(B) } e.g. "Check whether the language of a PDA is infinite." { <A> | A is a PDA and L(A) is infinite}