Erik Jonsson School of Engineering and Computer Science FEARLESS Engineering CS 4384 – 001 Automata Theory Thursday: Context-Free.

Slides:



Advertisements
Similar presentations
Lecture 11 Context-Free Grammar. Definition A context-free grammar (CFG) G is a quadruple (V, Σ, R, S) where V: a set of non-terminal symbols Σ: a set.
Advertisements

Erik Jonsson School of Engineering and Computer Science FEARLESS Engineering CS 5349 – 001 CS 4384 – 001 Automata Theory
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
4.5 Inherently Ambiguous Context-free Language For some context-free languages, such as arithmetic expressions, may have many different CFG’s to generate.
Chapter 5 Pushdown Automata
Lecture # 8 Chapter # 4: Syntax Analysis. Practice Context Free Grammars a) CFG generating alternating sequence of 0’s and 1’s b) CFG in which no consecutive.
Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
Closure Properties of CFL's
Erik Jonsson School of Engineering and Computer Science FEARLESS Engineeringwww.utdallas.edu/~pervin CS CS 4384 – HON001 Automata Theory
Context-Free Grammars Sipser 2.1 (pages 99 – 109).
Decidable languages Sipser 4.1 (pages ). CS 311 Mount Holyoke College 2 Hierarchy of languages All languages Turing-recognizable Turing-decidable.
Context-Free Grammars Sipser 2.1 (pages 99 – 109).
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 11, 2006.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
1 CSC 3130: Automata theory and formal languages Tutorial 4 KN Hung Office: SHB 1026 Department of Computer Science & Engineering.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Normal forms for Context-Free Grammars
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Lecture 9UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 9.
Context-Free Grammars Chapter 3. 2 Context-Free Grammars and Languages n Defn A context-free grammar is a quadruple (V, , P, S), where  V is.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
Context-free Grammars Example : S   Shortened notation : S  aSaS   | aSa | bSb S  bSb Which strings can be generated from S ? [Section 6.1]
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
Context-free Grammars [Section 2.1] - more powerful than regular languages - originally developed by linguists - important for compilation of programming.
CSCI 2670 Introduction to Theory of Computing September 15, 2005.
CS 3240: Languages and Computation Context-Free Languages.
Computability Construct TMs. Decidability. Preview: next class: diagonalization and Halting theorem.
Complexity and Computability Theory I Lecture #9 Instructor: Rina Zviel-Girshin Lea Epstein.
Midterm 1 Breakdown >79 3 >29 7 >69 5 >19 5 >59 7 >49 9 >39 7.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Grammars CS 130: Theory of Computation HMU textbook, Chap 5.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Lecture 8 Context-Free Grammar- Cont.
Introduction Finite Automata accept all regular languages and only regular languages Even very simple languages are non regular (  = {a,b}): - {a n b.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
CSCI 2670 Introduction to Theory of Computing September 14, 2005.
Transparency No. 1 Formal Language and Automata Theory Homework 5.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Dept. of Computer Science & IT, FUUAST Theory of Computation 2 Regular Expressions Regular Expression.
CSE 311 Foundations of Computing I Lecture 19 Recursive Definitions: Context-Free Grammars and Languages Spring
CSE 311 Foundations of Computing I Lecture 20 Context-Free Grammars and Languages Autumn 2012 CSE
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Context-Free Grammars: an overview
Formal Language & Automata Theory
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
CSE 105 theory of computation
CS314 – Section 5 Recitation 3
Non-Context-Free Languages Sections: 2.3 page 123 October 17, 2008
Context Free Languages
Context-free Languages
CHAPTER 2 Context-Free Languages
Context-Free Grammars
Context-Free Languages
فصل دوم Context-Free Languages
Department of Computer Science & Engineering
Chapter 2 Context-Free Language - 01
Theory of Computation Lecture #
Context-Free Grammars
Sub: Theoretical Foundations of Computer Sciences
Context Free Grammars-II
Presentation transcript:

Erik Jonsson School of Engineering and Computer Science FEARLESS Engineering CS 4384 – 001 Automata Theory Thursday: Context-Free Languages Sections Tuesday

EXAMINATION ANSWERS Regular Languages 2 ANSWERS

Distinguished States 3

4

Context-free Languages Chapter Three 5Tuesday 2-25

Definition A context-free grammar (CFG) G is a quadruple (V, Σ, R, S) where V: a set of non-terminal symbols (Variables) Σ: a set of terminals (V ∩ Σ = Ǿ) (Alphabet) R: a set of rules (R: V → (V U Σ)*) S: a start symbol (a variable)

How do we use rules? If R: A → B, then xAy xBy and we say that xBy is derived from xAy using rule R. If s ··· t, then we write s * t. A string x in Σ* is generated by G=(V,Σ,R,S) if S * x. L(G) = { x in Σ* | S * x}.

Example G = ({S}, {0,1}. {S → 0S1 | ε }, S) ε in L(G) because S ε. 01 in L(G) because S 0S in L(G) because S 0S1 00S in L(G) because S * 0 1. L(G) = {0 1 | n > 0} n n nn n n

Context-free A context-free grammar is “context-free’’ because we can use a rule R no matter what the context. E.g., (M&S P.89, Def ) from the rule R: A -> w, we can derive from the string uAv in one step the string uwv, no matter what the context (that is, for any strings u and v). 9

10

11

12 Palindromes

13 Any positive even number of a’s with any number of b’s anywhere

14

15

16

17

18

19

Parsing Expressions G = (V, ∑, R, E) V = {E, T, F} ∑= {x, 1, 2, +, *, (, )} R = { E -> E + T | T; T -> T * F | F; F -> (E) | x1 | x2 } Expressions, Terms, Factors 20

21

22Parse Tree

Closure Properties 23

24

25

26

Theorem For every regular language L, there exists a CFG G (in fact a Regular Grammar) such that L=L(G). 27

Theorem For every regular language L, there exists a CFG G such that L=L(G). Proof.Let L=L(M) for a DFA M=(Q, Σ, δ, s, F). Construct a CFG G=(V, Σ, R, S) as follows. V = Q, Σ = Σ, R = { q → ap | δ(q, a) = p } U { f → ε | f in F}, S = q0. sq1q1 f=q n x1x1 xnxn S x 1 q 1 x 1 x 2 q 2 ··· x 1 …x n f x 1 …x n 28

29

Regular Grammars 30Note: A -> a is unnecessary

31What's wrong with (ab)*a*?

32

Simplified and Normal Forms 33