Docstoc

ch4

Document Sample
ch4 Powered By Docstoc
					4.1 Decidable languages
   Decidable problems concerning regular languages:

    Let ADFA = {B,w | B is a DFA that accepts input
                 string w}.
    The problem of testing whether a DFA B accepts
    an input w is the same as the problem of testing
    whether B,w ADFA.
   Theorem 4.1
    ADFA is a decidable language.

M = “On B,w, whether 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 it ends in a nonaccepting state,
        reject.”
ANFA = {B,w | B is a NFA that accepts input string w}.


   Theorem 4.2
    ANFA is a decidable language.

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 given in
        Theorem 1.19.
     2. Run TM M from Theorem 4.1 on input C,w.
     3. If M accepts, accept; otherwise reject.”
Let AREX = {R,w | R is a regular expression that
            generates string w}.

   Theorem 4.3
    AREX is a decidable language.

PROOF The following TM P decides AREX.
P =“On input R,w where R is a regular expression
    and w is a string:
    1. Convert regular expression R to an equivalent
       DFA A by using the procedure for this
       conversion given in Theorem 1.28.
     2. Run TM M on input A,w.
     3. If M accepts, accept; if M rejects, reject.”
EDFA = {A | A is a DFA and L(A)=}.

   Theorem 4.4
    EDFA is a decidable language.

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.”
EQDFA = {A,B | A and B are DFAs and L(A) = L(B)}.


   Theorem 4.5
    EQDFA is a decidable language.
                              
         L(C )  L( A)  L( B )  L( A)  L( B )   



 F = “On input A, B, where A and B are DFAs:
     1. Construct DFA C as described.
     2. Run TM T from Theorem 4.4 on input C.
     3. If T accepts, accept. If T rejects, reject.”
DECIDABLE PROBLEMS CONCERNING
CONTEXT-FREE LANGUAGE
ACFG = {G,w | G is a CFG that generates string w}.


   Theorem 4.6
    ACFG is a decidable language.

Proof The TM S for ACFG follows.
S = “On input G,w, where G is a CFG and w is a string:
       1. Concert G to an equivalent grammar in Chomsky
          normal form.
       2. List all derivations with 2n-1 steps, where n is the
          length of w.
       3. If any of these derivations generate w, accept; if not,
          reject.”
ECFG = {G | G is a CFG and L(G) = }.

   Theorem 4.7
    ECFG is a decidable language.

PROOF
R = “On input G, where G is a CFG:
     1. Mark all terminal symbols in G.
     2. Repeat until no new variables get marked:
     3. Mark any variable A where G has a rule
            AU1U2…Uk and each symbol U1,…,Uk has
            already been marked.
     4. If the start symbol is not marked, accept;
                otherwise reject.”
   Theorem 4.8
    Every context-free language is decidable.

Proof Let G be a CFG for A and design a TM MG
  that decides A. We build a copy of G into MG. It
  works as follows.
MG = “On input w:
      1. Run TM S on input G, w, where S is a
         Turing machine design in Theorem 4.6.
      2. If this machine accepts, accept; if it rejects,
         reject.”
FIGURE 4.2
The relationship among classes of languages.
4.2 The Halting Problem
1.   ATM = {M, w | M is a TM and M accepts w}
     The following Turing machine U recognizes ATM.
     U =“On input M, w, where M is a TM and w is a
          string:
          1. Simulate M on input w.
          2. If M ever enter its accept state, accept; If
             M ever enters its reject state, reject.”
     ATM is sometimes called the halting problem.

2.   The proof of the undecidability of the halting
     problem uses a technique called “diagonalization”,
     discovered by mathematician Georg Cantor in 1873.
3.    Assume that we have two sets A and B and a
      function f: AB
     –   f is one-to-one if f(a)f(b) whenever ab.
     –   f is onto if for every bB there is an aA s.t. f(a)=b.
     –   A and B are the same size if there is a one-to-one, onto
         function f: AB.
     –   A function that is both one-to-one and onto is called a
         correspondence.
     Ex. Let N be the set of natural numbers {1, 2, 3, …}and let 
         be the set of even natural numbers {2, 4, 6, …}. Using
         Cantor’s definition, N and  have the same size.
          f(n)=2n:
4.   A set S is countable if either it is finite or it has the
     same size as N.
     Ex.
       Let Q be the set of positive rational numbers,
                  m
       i.e. Q  { m, n  N }, Q is countable.
                   n
5.   For some infinite sets no correspondence with N
     exists, such sets are called uncountable.
   Theorem 4.14     R is uncountable.
    需證明 no correspondence exists between N and R.
    The proof is by induction:
    1. 假設存在一種 correspondence f between N and
       R (每個 element in N 有唯一之 element in
       R 與其對應).
    2. 我們只要找出一 xR 使得 x 不包含在此對應
       關係即可證明. 如何找?以下列範例說明:




          永遠可以找到一 x 不存在 f 之中!
    Corollary 4.15
     Some language are not Turing-recognizable.

1.   觀察一:the set of all string * is countable, for
                any alphabet .
     觀察二:the set of all Turing machines is countable
                because each Turing machine M has an
                encoding into a string M.
      The set of all Turing machines is countable.
2.   Let B be the set of all infinite binary sequences.
     B is uncountable.
3.   Let L be the set of all languages over .
     Let * = {s1, s2, s3, …}. Each language AL has
     unique sequence A in B:
     The ith bit of that sequence is a “1” if siA and is a
     “0” if siA.
     例: * = { , 0, 1, 00, 01, 10, 11, 000, 001, …};
          A ={       0, 00, 01,           000, 001, …};
          A = 0 1 0 1 1 0 0 1                   1 … .
     The function f: LB, where f(A) equals the characteristic
     sequence of A, is one-to-one and onto and hence a
     correspondence.
     B is uncountableL is uncountable.


     Some languages are not recognized by any
      Turing machine.
   The Halting Problem is Undecidable
    Now we are ready to prove Theorem 4.9, the
    undecidability of the language
    ATM = {M,w| M is a TM and M accepts w}.

Proof:
  Assume ATM is decidable and obtain a contradiction.
  1. Suppose that H is a decider for ATM.
     H(M,w) =    accept if M accepts w.
                   reject if M does not accept w.
2. Now we construct a new Turing machine D with H
   as a subroutine.
    D = “On input M, where M is a TM:
           1. Run H on input M, M.
           2. Output the opposite of what H outputs;
                     that is, if H accepts, reject and if
H                    rejects, accept.”
3. D(M) =      accept if M does not accept M.
                 reject if M accepts M.

   D(D) =      accept if D does not accept D.
                 reject if D accepts D.
 Figure 4.4    Entry i,j is accept if Mi accepts Mj




Figure 4.5 Entry i,j is the value of H on input Mi , Mj 
FIGURE 4.6
If D is in the figure, a contradiction occures at “?”
   Theorem 4.16
    A language is decidable if and only if it is
    both Turing-recognizable and co-Turing-
    recognizable.
    In other words, a language is decidable if and
    only if both it and its complement are Turing-
    recognizable.

Pf:
  1. 証 Easy
  2. 証 
  2. 証 
     If both A and A are Turing-recognizable,
     we let M1 be the recognizer for A and M2
     be the recognizer for A. The following
     Turing machine M is a decider for A:
     M = “On input w:
           1. Run both M1 and M2 on input w in
              parallel.
           2. If M1 accepts, accept; if M2
              accepts, reject.”
 Corollary 4.17
  ATM is not Turing-recognizable.
習題
4.3
4.5
4.8
4.11
4.12

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:4
posted:2/12/2012
language:
pages:24