CSC 473 Automata, Grammars & Languages 11/9/10

Similar documents
CSCI FOUNDATIONS OF COMPUTER SCIENCE

Recursively Enumerable and Recursive. Languages

Closure Properties of Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Convert the NFA into DFA

First Midterm Examination

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

First Midterm Examination

Formal languages, automata, and theory of computation

Decidability. Models of Computation 1

1.4 Nonregular Languages

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CS5371 Theory of Computation. Lecture 20: Complexity V (Polynomial-Time Reducibility)

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir

Automata and Languages

CS 275 Automata and Formal Language Theory

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

CS 275 Automata and Formal Language Theory

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

CS 275 Automata and Formal Language Theory

CSC 311 Theory of Computation

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Lecture 6 Regular Grammars

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Minimal DFA. minimal DFA for L starting from any other

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

More on automata. Michael George. March 24 April 7, 2014

FABER Formal Languages, Automata and Models of Computation

THEOTY OF COMPUTATION

Finite Automata-cont d

Part 5 out of 5. Automata & languages. A primer on the Theory of Computation. Last week was all about. a superset of Regular Languages

Theory of Computation Regular Languages

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

This lecture covers Chapter 8 of HMU: Properties of CFLs

Homework 3 Solutions

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Formal Languages Simplifications of CFGs

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

State Minimization for DFAs

Chapter 2 Finite Automata

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

CS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power

Context-Free Grammars and Languages

Non-deterministic Finite Automata

1.3 Regular Expressions

Strong Bisimulation. Overview. References. Actions Labeled transition system Transition semantics Simulation Bisimulation

Turing Machines Part One

CS375: Logic and Theory of Computing

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

a b b a pop push read unread

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

CISC 4090 Theory of Computation

Formal Languages and Automata

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

CS375: Logic and Theory of Computing

Lexical Analysis Part III

TREE AUTOMATA AND TREE GRAMMARS

CS 314 Principles of Programming Languages

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines

Myhill-Nerode Theorem

NFAs continued, Closure Properties of Regular Languages

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Introduction to ω-autamata

Parse trees, ambiguity, and Chomsky normal form

PESIT SOUTHCAMPUS QUESTION BANK. Chapter 1 & 2 : Introduction to theory of computation and finite automata

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

NFAs continued, Closure Properties of Regular Languages

Harvard University Computer Science 121 Midterm October 23, 2012

Regular expressions, Finite Automata, transition graphs are all the same!!

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

Deterministic Finite-State Automata

Languages & Automata

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Handout: Natural deduction for first order logic

Turing Machines Part One

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Lexical Analysis Finite Automate

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

SWEN 224 Formal Foundations of Programming WITH ANSWERS

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Normal Forms for Context-free Grammars

CMSC 330: Organization of Programming Languages

Nondeterminism and Nodeterministic Automata

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

1 Nondeterministic Finite Automata

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Transcription:

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