80 likes | 282 Views
CSC 4170 Theory of Computation. Decidable languages. Section 4.1. 4.1.a. Decidable: {1,3,5} {x | x is even} {x | x is a perfect square} {x | x 2 -10x = 0} {x | x=y * z for some integers y,z>1 (i.e. x is not prime)} {x | x is a prime (i.e. x is not divisible by anything except 1 and
E N D
CSC 4170 Theory of Computation Decidable languages Section 4.1
4.1.a • Decidable: • {1,3,5} • • {x | x is even} • {x | x is a perfect square} • {x | x2-10x = 0} • {x | x=y*z for some integers y,z>1 (i.e. x is not prime)} • {x | x is a prime (i.e. x is not divisible by anything except 1 and • itself)} • {<G> | G is a connected graph} • {<P> | P is a one-variable polynomial expression with an integral root} Examples of decidable languages • Undecidable: • {<P> | P is a two-variable polynomial expression with an integral root}
4.1.b The acceptance problem for DFAs is decidable Let ADFA = {<B,w> | B is a DFA that accepts input string w} Theorem 4.1:ADFA is a decidable language. Proof idea: Here is a Turing machine M that decides ADFA: M = “On input <B,w>, where B is a DFA and w is a string: 1. Simulate B on input w. 2. If the simulation ends in an accept state, accept. If the simulation ends in a nonaccept state, reject.”
4.1.c The acceptance problem for NFAs is decidable Let ANFA = {<B,w> | B is an NFA that accepts input string w} Theorem 4.2:ANFA is a decidable language. Proof idea: Here is a Turing machine N that decides ANFA: N = “On input <B,w>, where B is an NFA and w is a string: 1. Convert NFA B to an equivalent DFA C using the procedure for this conversion that we learned. 2. Run TM M from Theorem 4.1 on input <C,w>. 3. If M accepts, accept. If M rejects, reject.”
4.1.d The string generation problem for REs is decidable Let AREX = {<R,w> | R is a regular expression that generates string w} Theorem 4.3:AREX is a decidable language. Proof idea: Here is a Turing machine P that decides AREX: P = “On input <R,w>, where R is a regular expression and w is a string: 1. Convert R to an equivalent NFA B using the procedure for this conversion that we learned. 2. Run TM N from Theorem 4.2 on input <B,w>. 3. If N accepts, accept. If N rejects, reject.”
4.1.e The emptiness problem for the language of a DFA is decidable Let EDFA = {<A> | A is a DFA and L(A)=} Theorem 4.4:EDFA is a decidable language. Proof idea: Here is a Turing machine T that decides EDFA: T = “On input <A>, where A is a DFA: 1. Mark the start state of A. 2. Repeat until no new states get marked: 3. Mark any state that has a transition coming into it from any state that is already marked. 4. If no accept state is marked, accept; otherwise reject.”
4.1.f Other decidable problems from the language theory Each the following languages are also decidable: EQDFA = {<A,B> | A and B are DFAs and L(A)=L(B)} ACFG = {<G,w> | G is a CFG that generates string w} Theorem 4.9:Every context-free language is decidable. Proof idea: Suppose L is a context-free language. Let G be the CFG that generates L, and S be a TM that decides ACFG. Here is a Turing machine H that decides L: H = “On input w: 1. Run S on input <G,w>. 2. If the machine accepts, accept; if it rejects, reject.”