














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















TOC is an extension of MCS , and as such extends on the topics originally covered in MCS, such as: Inductive proofs and definitions (also covered in ICM) Finite automata Kleene's Theorem Non-deterministic finite automata Grammars Regular grammars Context-free grammars Pushdown automata Chomsky hierarchy Level Grammars/Languages Grammar Productions Machines 0 Unrestricted/recursively enumerable α → β [α ∈ ( V ∪ Σ )+, β ∈ ( V ∪ Σ )] Turing Machine 1 Context-sensitive α → β [α, β ∈ ( V ∪ Σ )+, |α| ≤ |β|] Linear-bounded automaton 2 Context-free A → β [A ∈ V , β ∈ ( V ∪ Σ )] Pushdown automaton 3 Regular A → a, A → aB, A → Λ [A, B ∈ V , a ∈ Σ ] Finite automaton We could also consider a level 2.5, which is a deterministic context free grammars.
A grammar is context sensitive if α → β satisfies |α| ≤ |β|, with the possible exception of S → Λ. If S → Λ is present, then S must not occur in any right-hand side. The length restrictions here mean that you can generate all strings in a language up to a certain length (derivation trees). Context-sensitive grammars generate context-sensitive languages, and every context free language is context sensitive.
A linear bounded automata (LBA) is defined like a nondeterministic Turing machine (see next section), M, except that the initial config for input w has the form (q 0 ,
An equivalent definition allows inital configurations of the form (q 0 , <wΔ n >), where n = cM|w|, for some constant cM ≥ 0. This allows to have multi-track machines, where cM represents the number of tracks. Theorem: A language L is context sensitive if and only if L is accepted by some LBA. Open research problem: Are deterministic linear bound automata as powerful as non- deterministic LBAs? Turing Machines Turing machines were introduced by Alan Turing in "On Computable Numbers with an Application to the Entscheidungsproblem" (The Entscheidungsproblem is whether or not a procedure of algorithm exists for a general problem). A Turing Machine is an automata with consits of a 5-tuple (Q, Σ, Γ, q 0 , δ) Q is a finite set of states including ha and hr (the halting accept and reject states) Σ - the alphabet of input symbols Γ - the alphabet of tape symbols, including the blank symbol Δ, such that Σ ⊆ Γ - {Δ} q 0 - the initial state, such that q 0 ∈ Q δ - the transition function such that δ : (Q - {ha, hr}) × Γ → Q × Γ × {L, R, S} Intuitively, a Turing machine has a potentially infinite set of squares and a head moving on a type when reading character a whilst in state q, δ(q, a) = (r, b, D), which denotes a new state r, a is overwritten with b and the head either moves to the left (D = L), right (D = R), or remains stationary (D = S).
A configuration is a pair (q, uav) where q ∈ Q, a ∈ Γ and u, v ∈ Γ. This configuration is considered to be the same as (q, uavΔ) - the rightmost blanks can be ignored. A transition (q, uav) ├ (r, xby) describes a single move of a Turing machine, and we can write (q, uav) ├ (r, xby) for a sequence of transitions. This can be represented diagramatically as: Convention also dictates that if there is no transition for what you want to do, a transition to hr is implied.
A language L is decidable (or recursive) if it is accepted by some Turing machine M, that on every inputs eventually reaches a halting state (ha or hr), i.e., it does not get stuck and loop. We say that M decides L. To decide whether w ∈ Σ* is in L, we run M on w until M reaches a halting configuration, then w ∈ L if and only if M is in state ha. Theorem:
Intuitively, L(M) = L and L(M) = L. For a string w, w ∈ L ∨ w ∈ L - so at least one of those machines will accept the string. If the two machines are run in parallel and terminate as soon as one reaches an accept state, then it is impossible to get into a loop. This can be accomplished on a two-tape machine. The string is copied to tape 2 in the first instance, and then M is run on tape 1 and M is run on tape 2. We can express this formally as: Let M = (Q, Σ, Γ, q 0 , δ) and M = (Q, Σ, Γ, q 0 , δ) be Turing machines that accept L and L respectively. Without a loss of generality, we can assume that M and M cannot crash at the left end of the tape. We can construct a two-tape Turing machine M′ that decides L by copying its input to tape 2 and simulating M and M in parallel. Let Q′ ⊇ Q × Q (we need additional states for initial copying, which are Q′
For whatever Turing machine we encounter, we want to encode the Turing machine into a string that represents the Turing machine. If we let Q = {q 1 , q 2 , ...} and S = {a 1 , a 2 , ...}, such that for every Turing machine (Q, Σ, Γ, q, δ), Q ⊆ Q and Γ ⊆ S , then we can define: s(Δ) = 0 s(a i ) = 0 i^ + 1, for i ≥ 1 s(ha) = 0 s(hr) = 00 s(q i ) = 0 i^ + 2 s(S) = 0 s(L) = 00
This is done by contradiction (indirect proof), or reducio ad absurdum and relies on the principle of tertium non dafur. If we suppose that NSA is recursively enumerable, then there is a Turing machine that accepts NSA (for Turing machine M, L(M) = NSA). If we consider the code e(M), then we have two cases:
The universal Turing machine is basically a Turing machine interpreter. It takes inputs of the form e(M)e(w), where M is a Turing machine and w is a string over Σ(M)*. The universal Turing machine will run machine M on input w, and accepts e(M)e(w) if w ∈ L(M) (M accepts w), rejects e(M)e(w) if w ∉ L(M) (M rejects w) and e(M)e(w) loops when M loops on w.
A set S is countably infinite is there exists a bijective function N → S and is countable if it is countably infinite or finite. e.g., countable sets, N , Z , N × N and uncountable sets: R , 2 N Cantor said that if you plot a matrix of pairs of numbers, and move diagonally you can represent any number with a bijective function, so pairs of numbers are countably infinite, as long as the base number is.
Lemmas:
A Turing machine M = (Q, Σ, Γ, q 0 , δ) computes the partial function ƒm(x) = {y if (q 0 , Δx) ├* (ha, Δy), undefined otherwise} - which says that ƒm(x) = the resulting string on the tape if it halts, otherwise it is undefined. We can generally change this unary function into a k-ary function by saying that M computes for every k ≥ 1. The k-ary partial function ƒm : (Σ)k^ → Σ is defined by ƒm(x 1 , ..., xk) = {y, if (q 0 , Δx 1 Δs 2 ...Δxk) ├* (ha, Δy), undefined otherwise}.
A decision problem is a set of questions, each of which has the answer yes or no. We can say that these questions are instances of the decision problem; depending on their answers, they are either 'yes'-instances or 'no'-instances. To solve decision problems by Turing machines, instances are encoded as strings. A decision problem P is decidable, or solvable, if its language of encoded 'yes'-instances is decidable. Otherwise, P is undecidable or unsolvable. A decision problem P is semi-decidable if its language of encoded 'yes'-instances is recursively enumerable. The Membership Problem for Regular Languages Input: A regular expression r and w ∈ Σ* Question: Is w ∈ L( r ) Problem: {( r , w ) | r is a regular expression, w ∈ Σ} 'Yes'-instances: {( r , w ) | r is a regular expression and w ∈ L( r ) Encoded 'Yes'-instances: {encode( r )encode( w ) | r is a regular expression and w ∈ L( r )} This problem is decidable, as it can be turned into an automata. The Self-Accepting Problem Input: A Turing machine M Question: Does M accept e(M)? Problem: {M | M is a Turing machine} 'Yes'-instances: {M | M is a Turing machine and e(M) ∈ L(M)} Encoded 'Yes'-instances: {e(M) | M is a Turing machine and e(M) ∈ L(M)} The encoded 'Yes'-instances is the language SA, which is recursively enumerable (L(SA) can be enumerated), but not decidable, therefore this problem is semi-decidable. The Membership Problem for Recursively Enumerable Languages Input: A Turing machine M and w ∈ Σ Question: Is w ∈ L(M)? Problem: {(M, w ) | M is a Turing machine and w ∈ Σ*} 'Yes'-instances: {(M, w ) | M is a Turing machine and w ∈ L(M)} Encoded 'Yes'-instances: {e(M)e( w ) | M is a Turing machine and w ∈ L(M)} The encoded 'Yes'-instances is MP, the membership problem.
Theorem: The membership problem for recursively enumerable languages is undecidable, but semi-decidable. Proof: We reduce the self accepting problem (SA) to the membership problem for recursively enumerable languages (MP). That is, we show that if MP is decidable, then SA is also decidable. Since SA was proved to be undecidable, MP must be undecidable too. Suppose that MP is decidable. Then L(MP) is decidable, i.e., there is a Turing machine T that terminates for all inputs and accepts MP. We can construct a Turing machine T′ that decides SA as follows: T′ transforms its input e(M) into e(M)e(e(M)) (where e(M) = w and is placed in e(M)e( w )). T then starts on this string. This can be represented diagramatically: T′ terminates for all inputs because T always terminates. Moreover, T′ accepts e(M) if and only if T accepts e(M)e(e(M)), that is, T′ accepts e(M) if and only if e(M) ∈ L(M). Hence, T′ decides SA, therefore, if we can solve MP, we can solve SA. But, as SA was proved to be undecidable, this is a contradiction. Hence, our assumption that MP is decidable is false, i.e., MP is undecidable. We can summarise this as: reduction of SA to MP - "If we can solve MP, we can also solve SA" ⇔ "SA is not more difficult than MP" ⇔ "MP is at least as difficult as SA"
Let L 1 , L 2 ⊆ Σ* be languages. L 1 is reducible to L 2 if there is a computable total function (i.e., there exists a Turing machine) ƒ : Σ* → Σ* such that for all x ∈ Σ*, x ∈ L 1 if and only if ƒ( x ) ∈ L 2. Let P 1 , P 2 be decision problems and e(P 1 ), e(P 2 ) be the associated languages of the encoded 'Yes'- instances. We say that P 1 is reducible to P 2 if e(P 1 ) is reducible to e(P 2 ). Theorem 1: Let L 1 , L 2 be languages such that L 1 is reducible to L 2. If L 2 is decidable, so is L 1.
Note that if Thalt outputs 'yes' then U will terminate on e(M)e(w) with either Yes or No. Hence, T′ solves MP. Since MP is undecidable, our assumption that HP is decidable must be false. Accept# Theorem: The following problem (Accept#) is undecidable. Input: A Turing machine M such that # ∈ Σ Question: Is # ∈ L(M) Proof: We reduce MP to Accept#. Suppose Accept# is decidable, then there is a Turing machine that halts on all inputs, accepting input e(M) if and only if # ∈ L(M). We can construct a Turing machine T′ as follows: Where C is a Turing machine that transforms e(M)e( w ) into the output e(Mw), where Mw is a Turing machine that ignores its input and runs M on input w. Now, T′ solves MP. We can consider two cases:
Case 1: w ∈ L(M). Then, by construction of Mw, Mw accepts every input and hence # ∈ L(Mw), thus T# accepts e(Mw) and T′ accepts e(M)e(w). Case 2: w ∉ L(M). Then, by construction of Mw, Mw accepts no input and hence # ∉ L(Mw), this T# rejects e(Mw) and T′ rejects e(M)e(w). Since MP is undecidable, Accept# must be undecidable as well. More Undecidable Problems These can all be proved by reduction. Input: A Turing machine M. Question: Does M accept no input ("Is L(M) = ∅")? Input: Two Turing machines M 1 and M 2. Question: Do M 1 and M 2 accept the same inputs ("Is L(M 1 ) = L(M 2 )")? Input: A Turing machine M Question: Is L(M) finite? Input: A Turing machine M Question: Is L(M) regular? Input: A Turing machine M Question: Is L(M) decidable?
Let C be a proper, non-empty subset of all recursively enumerable languages. Then, the following problem is undecidable: Input: A Turing machine M Question: Is L(M) ∈ C? In other words, every nontrivial property of recursively enumerable languages is undecidable. A property is nontrivial if it is satisfied by a proper, nonempty subset C of the class of all recursively enumerable languages. e.g., for the problem "Is L(M) finite?" C = {L = Σ* | L is finite} Beware, Rice's theorem is about the languages accepted by Turing machines, not about the machines themselves.
Input: A context free grammar G Question: Is L(G) = Σ* Input: Two context free grammars G 1 and G 2 Question: Is L(G 1 ) = L(G 2 )
Given a function f , g : N → N , f is of order g , written as f = Ο( g ), or f ∈ Ο( g ), if there is c , n 0 such that ƒ( n ) ≤ c. g ( n ) ∀ n ≥ n 0. Theorem, for a , b , r ∈ N with a , b > 1
Theorem - multiple tapes vs. one tape: For every k -tape Turing machine M there is Turing machine M′ such that L(M′) = L(M) and τM′ = Ο(τM^2 ). Theorem - there are aribtrarily complex languages. Let ƒ be a total computable function. Then there is a decidable language L such that for every Turing machine M accepting L, τM is not bounded by ƒ.
Theorem - there need not exist a best Turing machine. There is a decidable language L such that for every Turing machine M accepting L, there is a Turing machine M′ such that L(M′) = L(M) and τM′ = Ο(log(τM)).
A language L is recognisable in polynomial time if there is a deterministic Turing machine M accepting L such that τM = Ο( nr ) for some r ∈ N. The class of all languages recognisable in polynomial time is denoted by P. A language L is recognisable in polynomial space if there is a deterministic Turing machine M accepting L such that sM = Ο( nr ) for some r ∈ N. The class of all languages recognisable in polynomial space is denoted by PSpace. A decision problem is said to be in P resp. PSpace if its language of encoded 'yes'-instances is in P resp. PSpace.
A language L is recognisable in nondeterministic polynomial time if there is a nondeterministic Turing machine N accepting L such that ΤN = Ο( nr ), for some r ∈ N. The class of all languages recognisable in nondeterministic polynomial time is denoted by NP. A language L is recognisable in nondeterministic polynomial space if there is a nondeterministic Turing machine N accepting L such that sN = Ο( nr ) for some r ∈ N. The class of all languages recognisable in nondeterministic polynomial space is denoted by NPSpace. A decision problem is said to be in NP resp. NPSpace if its language of encoded 'yes'-instances is in NP resp. NPSpace.
A graph G = (V, E) consists of a finite set, V, of vertices (or nodes) and a finite set, E, of edges such that each edge is an unordered pair of nodes. A path is a sequence of nodes connected by edges. A complete graph (or clique) is a graph where each two nodes are connected by an edge. The path problem has input of a graph G and nodes s and t in G and the question does G have a path from s to t? The theorem is that the path problem is in P, and the proof for this is the following algorithm which solves the path problem: On input (G, s , t ) where G = (V, E) is a graph with nodes s and t :
(Only P ≠ ExpTime is known, but it is not known whether the other subsets above are proper or not) Inclusions P ⊆ NP and PSpace ⊆ NPSpace, as every deterministic Turing machine can be represented by a nondeterministic Turing machine. Inclusions P ⊆ PSpace and NP ⊆ NPSpace, as every Turing machine (deterministic or nondeterministic) satisfies sM( n ) ≤ τM( n ) + 1, as we can not visit more squares than we can do transitions. Hence τM = Ο( nr ) implies sM = Ο( nr ). Inclusions NPSpace ⊆ PSpace. This can be proved using Savitch's Theorem (which is nontrivial), which states that for every nondeterministic Turing machine N there is a Turing machine M such that L(M) = L(N) and sM = sN^2 , and a polynomial squared is still a polynomial. Inclusions PSpace ⊆ ExpTime. For an input of length n each configuration of the Turing machine M can be written as follows: (q, a 0 ...a i ...asM( n )). For each part, there are |Q| possible states, sM( n ) possible tape head positons and |Γ|sM( n )^ possible tape content configurations. Hence, the maximum number of configurations is |Q| × sm( n ) × |Γ|sM( n )^ = Ο(Γ|sM. A Turing machine computation that halts does not repeat any configurations. Hence τM = Ο( k sM for some k , and it follows our inclusion, hence PSpace ⊆ ExpTime (for k ≤ 2 m^ we have knr^ ≤ (2 m ) nr^ = 2 mnr^ = 2 nm^ +^ r ).
A function ƒ is polynomial-time computable if there is a Turing machine M with τM = Ο( nr ) that computes ƒ. Let L 1 , L 2 ⊆ Σ* be languages. L 1 is polynomial-time reducible to L 2 if there is a polynomial-time computable total function ƒ : Σ* → Σ* such that for all x ∈ Σ, x ∈ L 1 if and only if ƒ( x ) ∈ L 2. Theorem: Let L 1 be polynomial-time reducible to L 2. Then: L 2 ∈ P implies L 1 ∈ P; L 2 ∈ NP implies L 1 ∈ NP. Proof Since L 2 ∈ P there is a Turing machine M 2 with polynomial time complexity that decides L 2. Moreover, since L 1 is polynomial-time reducible to L 2 , there is a Turing machine M with polynomial-time complexity such that ƒM : Σ → Σ* satisfies for all x ∈ Σ*, x ∈ L 1 if and only if ƒM( x ) ∈ L 2. Let M 1 be the composite Turing machine MM 2 which first runs M and then runs M 2 on the output of M, then L(M 1 ) = L 1. Since |ƒM( x )| can not exceed max(τM(| x |), |x|), the number of transitions of M 1 is bounded by the sum of the following estimates of the seperate computations: (a) τM1( n ) ≤ τM( n ) + τM2(max(τM( n ), n )) Let τM = Ο( nr ), then there are constants c and n 0 with τM( n ) ≤ c. nr^ ∀ n ≥ n 0. Let τM2 = Ο( nt ), then there are constants c 2 and n 2 with τM2( n ) ≤ c 2. nt^ ∀ n ≥ n 2. Hence τM2( n ) ≤ c 2. nt^ + d 2 , ∀ n ≥ 0, where d 2 = {τM2( k ) | k < n 2 }. It follows τM2(τM( n )) ≤ c 2. (τM( n )) t^ + d 2 , for all n ≥ 0, and hence τM2(τM( n )) ≤ c 2. ( c. nr ) t^ + d 2 , for all n ≥ 0 So, τM2(τM( n )) ≤ c 2 c t^. nrt^ + d 2 ∀ n ≥ 0. Thus, by formula (a) above, τM1 = Ο( nrt ), hence L 1 ∈ P ( r and t are constants, therefore nrt^ ∈ P)
If L 1 is polynomial-time reducible to L 2 , then L 1 is no harder than L 2. Equivalently, L 2 is at least as hard as L 1. A language L is NP-hard if every language in NP is polynomial-time reducible to L; A NP-hard language is at least as hard to decide as every language in NP. Equivalently, no language in NP is harder to decide than any NP-hard language.