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

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

Lecture 6 Regular Grammars

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

Context-Free Grammars and Languages

Closure Properties of Regular Languages

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

Automata and Languages

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

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

Non-deterministic Finite Automata

CS375: Logic and Theory of Computing

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

1.4 Nonregular Languages

Finite Automata-cont d

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

First Midterm Examination

FABER Formal Languages, Automata and Models of Computation

CS 275 Automata and Formal Language Theory

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

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.

Worked out examples Finite Automata

First Midterm Examination

CS 275 Automata and Formal Language Theory

Thoery of Automata CS402

CS 330 Formal Methods and Models

Convert the NFA into DFA

1.3 Regular Expressions

CS375: Logic and Theory of Computing

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

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

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

CS 275 Automata and Formal Language Theory

CSC 311 Theory of Computation

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Formal Languages Simplifications of CFGs

Formal languages, automata, and theory of computation

Recursively Enumerable and Recursive. Languages

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

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

Chapter 1, Part 1. Regular Languages. CSC527, Chapter 1, Part 1 c 2012 Mitsunori Ogihara 1

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

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

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

Non-deterministic Finite Automata

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

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

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Minimal DFA. minimal DFA for L starting from any other

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

Theory of Computation Regular Languages

Let's start with an example:

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

CHAPTER 1 Regular Languages. Contents

Lexical Analysis Finite Automate

CMSC 330: Organization of Programming Languages

CS 330 Formal Methods and Models

Language Processors F29LP2, Lecture 5

Harvard University Computer Science 121 Midterm October 23, 2012

Normal Forms for Context-free Grammars

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

1 Nondeterministic Finite Automata

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Some Theory of Computation Exercises Week 1

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

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

SWEN 224 Formal Foundations of Programming WITH ANSWERS

CISC 4090 Theory of Computation

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

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

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

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

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

Fundamentals of Computer Science

Homework 3 Solutions

Java II Finite Automata I

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

a b b a pop push read unread

Finite state automata

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

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

Revision Sheet. (a) Give a regular expression for each of the following languages:

Lecture 08: Feb. 08, 2019

State Minimization for DFAs

Non-Deterministic Finite Automata

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

THEOTY OF COMPUTATION

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CSCI FOUNDATIONS OF COMPUTER SCIENCE

Parse trees, ambiguity, and Chomsky normal form

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

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

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

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

NFAs continued, Closure Properties of Regular Languages

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Transcription:

CI 3104 /Winter 2011: Introduction to Forml Lnguges Chter 13: Grmmticl Formt Chter 13: Grmmticl Formt I. Theory of Automt II. Theory of Forml Lnguges III. Theory of Turing Mchines Dr. Neji Zgui CI3104-W11 1 Chter 13: Grmmticl Formt Theorem. All regulr lnguges re context-free lnguges. Proof. We show tht for ny FA, there is CFG such tht the lnguge generted y the grmmr is the sme s the lnguge cceted y the FA. By constructive lgorithm. Inut: finite utomton. Outut: CF grmmr. Dr. Neji Zgui CI3104-W11 2 Chter 13: Grmmticl Formt The lhet of terminls is the lhet of the FA. Nonterminls re the stte nmes. (The strt stte is renmed.) For every edge, crete roduction: For every finl stte, crete roduction: Λ Dr. Neji Zgui CI3104-W11 3 1

Chter 13: Grmmticl Formt Exmle: M / M F/ F F/ F/ Λ M M F F F M F M M F F F, Dr. Neji Zgui CI3104-W11 4 Chter 13: Grmmticl Formt Definition: A semiword is sequence of terminls (ossily none) followed y exctly one nonterminl. (terminl)(terminl) (terminl)(nonterminl) Definition: A CFG is regulr grmmr if ll of its roductions hve the form: Nonterminl semiword or Nonterminl word ( sequence of terminls or Λ) Dr. Neji Zgui CI3104-W11 5 Chter 13: Grmmticl Formt Theorem. All lnguges generted y regulr grmmrs re regulr. Proof. By constructive lgorithm. We uild trnsition grh. The lhet of the trnsition grh is the set of terminls. One stte for ech nonterminl. The stte nmed is the strt stte. We dd one finl stte. Trnsitions: N x w y N z N w q N x w y N N w q z Dr. Neji Zgui CI3104-W11 6 2

Chter 13: Grmmticl Formt Exmle: L L ()* Alterntive Algorithm: 1. N wq whenever wq is not Λ 2. For ech trnsition of the form N Λ, we mrk the stte for N with.. Dr. Neji Zgui CI3104-W11 7 N w q Chter 13: Grmmticl Formt Exmle / / / / Λ / / / L,, EVEN-EVEN Dr. Neji Zgui CI3104-W11 8 Chter 13: Grmmticl Formt If the emty word is in the lnguge, roduction of the form N Λ (clled Λ-roduction) is necessry. The existence of roduction of the form N Λ des not necessrily men tht Λ is rt of the lnguge. Λ Theorem. Let L e lnguge generted y CFG. There exists CFG without roductions of the form Λ such tht: 1. If L L, L is generted y the new grmmr. 2. If L L, ll words of L excet for L re generted y the new grmmr. Dr. Neji Zgui CI3104-W11 9 3

Chter 13: Grmmticl Formt Definition. A roduction of the form: Nonterminl one Nonterminl is clled unit roduction. Theorem. Let L e lnguge generted y CFG tht hs no Λ- roductions. Then there is nother CFG without Λ - roductions nd without unit roductions tht genertes L. Theorem. Let L e lnguge generted y CFG. The there exists nother CFG tht genertes ll words of L (excet Λ) such tht ll the roductions re of the form: Nonterminl sequence of Nonterminls Nonterminl one terminl Dr. Neji Zgui CI3104-W11 10 Chter 13: Grmmticl Formt Definition. A CFG in is sid to e in Chomsky Norml Form (CNF) if ll the roductions hve the form: Nonterminl (Nonterminl)(Nonterminl) Nonterminl terminl Theorem. Let L e lnguge generted y CFG. There there is nother grmmr which is in CNF tht genertes ll the words of L (excet Λ). Dr. Neji Zgui CI3104-W11 11 Chter 13: Grmmticl Formt Definition. In sequence of terminls nd nonterminls in derivtion (clled working string), if there is t lest one nonterminl, then the first one is clled the leftmost nonterminl. Definition. A leftmost derivtion is derivtion where t ech ste, roduction is lied to the leftmost nonterminl in the working string. Exmle. Dr. Neji Zgui CI3104-W11 12 4

Chter 13: Grmmticl Formt Exmle Derivtion I Derivtion II Dr. Neji Zgui CI3104-W11 13 Chter 13: Grmmticl Formt Dr. Neji Zgui CI3104-W11 14 Chter 13: Grmmticl Formt Dr. Neji Zgui CI3104-W11 15 5

Chter 13: Grmmticl Formt Theorem. Any word tht is in the lnguge generted y CFG hs leftmost derivtion. ( ) Exmle. () ~ q () ( ) ( ) ( ()) ( ( )) ( (~ )) ( (~ )) ( (~ q)) ( ) ~ q Dr. Neji Zgui CI3104-W11 16 6