CSC 473 utomt, Grmmrs & Lnguges 11/9/10 utomt, Grmmrs nd Lnguges Discourse 06 Decidbility nd Undecidbility Decidble Problems for Regulr Lnguges Theorem 4.1: (embership/cceptnce Prob. for DFs) = {, w is DF nd w! L( ) } is DF Pf: decider for the lnguge is: = On input <,w>: Simulte on w. If the simultion reches n stte, hlt nd. If it ends (jms) in non- stte, hlt nd. 2 Theorem 4.2: (embership/cceptnce Prob. for NFs) = { N, w N is n NF nd w! L( N) } is NF Pf: decider for the lnguge is: = On input <N,w>: Use the Rbin-Scott lgorithm to convert N to DF Run the Theorem 4.1 lgorithm with input <,w>. If tht lgorithm s, then ; otherwise. 3 1
CSC 473 utomt, Grmmrs & Lnguges 11/9/10 Theorem 4.3: (embership Prob. for RegExʼs) = { R, w R is regulr expression nd w! L( R) } is REX Pf: Use the lgorithm to convert R to n equivlent NF N nd use the lgorithm of Theorem 4.2 with input <N,w> 4 Theorem 4.4: (Emptiness Problem for DFs) E = { is DF nd L( ) =!} is DF Pf: decider for the lnguge is: T = On input <>: S!{ q0} repet { " S S " #{ q ( $ )( $ p % )! ( p, ) = q} } until ( S = ) if F! = " ; otherwise. 5 Theorem 4.5: (Equivlence Problem for DFs) EQ = {, B, B re DF nd L( ) = L( B)} DF Pf: Observe tht L( ) = L( B)! L( ) " L( B) = # where L( ) " L( B) = ( L( ) $ L( B)) % ( L( ) $ L( B)) is Becuse of closure properties, there is n lgorithm to construct DF C from, B tht s L( )! L( B) Use Theorem 4.4 with <C> to test whether L( C) =!. If tht lgorithm s, then ; otherwise,. 6 2
CSC 473 utomt, Grmmrs & Lnguges 11/9/10 Decidble Problems for CFLs Theorem 4.7: (embership/cceptnce Prob. for CFGs) = { G, w G is CFG nd w! L( G) } is CFG Pf: Chomsky Norml Form prse trees look like: 2n! 1 ' s Pure Binry Tree w/ n leves hs n-1 internl nodes. dd n terminting rules for prse tree. n terminls 7 Decidble Problems CFLs (contʼd) S = On input <G,w>: Convert G to CNF If w >0 try ll derivtions with 2 w -1 steps. If w =0 try the 1-1 step derivtion S " G!. If ny derivtion genertes w, ; else. Corollry (Text Theorem 4.9). Every CFL is decidble lnguge. Pf: Let be CFL. We wnt decider for it. Let G be CFG generting. On input w, run the S bove on <G,w> to or w. 8 Decidble CFLs (contʼd) Theorem 4.8: (Emptiness Problem for CFGs) E = { G G is CFG nd L( G) =!} CFG is Pf: vrible in CFG is productive (or corechble) iff (" w#$ ) % So iff the!! G w. L( G )! " strt vrible S is productive. See Homework 4, Problem 2 for n lgorithm to decide whether vrible is productive. ll bove problems lso decidble for PDs: just convert to CFGs. Wht bout the Equivlence Problem for CFGs? EQ = { G, H G, H re CFGs nd L( G) = L( H )} CFG We will show (lter) tht this problem is UNdecidble. 9 3
CSC 473 utomt, Grmmrs & Lnguges 11/9/10 The Hlting Problem lthough the following lnguge is -recognizble, we will show it is not decidble. = {, w is nd w! L( )} This is clled the embership Problem for s, nd by some uthors the Hlting Problem for s: given nd string w, does w? Why clled Hlting Problem? Given, cn lwys lter it to n equivlent such tht: hlts on w iff s w (iff s w). Pf: For ech undefined trnsition δ(q,) in, will trnsition to stte qloop nd loop forever; lso q goes to the sme loop stte Thus nce cn be mde synonymous with hlting 10 The Hlting Problem (contʼd) Thm: = {, w is nd w! L( )} is Turing-recognizble. Pf: Let U be U. recognizer for is: R, w U yes no yes no, w! L( R) ", w! L( U ) " w! L( ) ", w!! 11 The Hlting Problem (contʼd) Thm: = {, w is nd w! L( )} is undecidble. Pf: Proof by contrdiction. ssume tht is decidble. Then it hs decider; cll it H. H behves s follows:, w H { if s w } { if does not w } Construct D tht clls H s subroutine. On input, D runs H on,. Tht is, D determines if s or s its own description s input. If s, then D s; If s, then D s. Here is the picture of how D behves: 12 4
CSC 473 utomt, Grmmrs & Lnguges 11/9/10 The Hlting Problem (contʼd) D, H { if s } { if does not }! L( D) " # L( ) { if does not } { if s } Wht hppens if we run D on its own description D? Set = D in the bove. Then D! L( D) " D # L( D). This contrdiction shows tht decider H cnnot exist. 13 Digonliztion Why clled? Encodings D computes the opposite of the digonl entries D( ) =! ( ) = i i i s 1 2 3 ( ) ( ) ( ) 1 1 1 2 1 3 1 ( ) ( ) ( ) 2 1 2 2 2 3 2 ( ) ( ) ( ) 3 1 3 2 3 3 3!!! " D D( D ) is D( D ) = or? D( D ) =! D( D ) = D 14 Decidble vs Recognizble Sets: Bsics Theorem: L decidble! L decidble Proof: If L is decidble, it hs decider. The decider hlts for every input in either the ing hlt stte or in the ing hlt stte q. Construct from s follows: mke the ing hlt stte the ing stte nd the ing hlt stte the ing stte. Then w # L( ) " w! L( ), tht is, L ( ) = L( ). q 15 5
CSC 473 utomt, Grmmrs & Lnguges 11/9/10 Decidble vs Recognizble: Bsics (Cont.) Theorem 4.22: L is decidble iff both L & L re Turingrecognizble. Proof: ( ) Previous theorem. ( ) Suppose both re recognizble. Let, be recognizers for L, L. Construct * to simulte lternte steps in ech recognizer: * ( w! L) w switch ( w! L) Given w it is eventully ed by one or the other, so * must hlt nd either or ; it is decider. 16 Non--Recognizble Set Corollry 4.23: (the complement of ) is not Turing-recognizble. Pf: By contrdiction. We know tht is Turingrecognizble. Suppose is Turing-recognizble. By Theorem 4.22, it follows tht is decidble. Since we know tht is not decidble by Theorem 4.11, this contrdiction estblishes the result. Note: Wht does look like? = {, w is nd w! L( )} " J where!! J = (0 + 1),(0 + 1), which re ll the junk strings tht cnnot be of the form Coded mchine, coded input. Note tht J is regulr lnguge. 17 6