Lecture 13 Grammars - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Lecture 13 Grammars

Description:

Unix Shell 'regular expressions' Examples of Sets of ... Reference 'Bumping the Pumping Lemma' L = {0n1m | n m} L = {0n1m | n 100, m 100} ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 24
Provided by: mantonm5
Category:

less

Transcript and Presenter's Notes

Title: Lecture 13 Grammars


1
Lecture 13Grammars
CSCE 355 Foundations of Computation
  • Topics
  • Context Free Grammars
  • Parses, derivations, parse trees
  • Language generated by a grammar

October 13, 2008
2
  • Last Time Readings section 3.1,3.2(skip DFA?
    RE), 3.3
  • Ruby Matching in files (fileArgv.rb)
  • Unix Shell regular expressions
  • Examples of Sets of indistinguishable prefixes
  • Pumping Lemma
  • New
  • If L is regular is the Reversal LR regular?

3
Homework
  • 1. Modify fileArgv.rb to substitute xxx-xxxx
    for every occurrence of phone number in every
    file in a directory
  • 4.4.2 minimization problem

0 1
?A B E
B C F
C D H
E F I
F G B
G H B
H I C
I A E
4
Minimization of DFA
  • First eliminate states not reachable from the
    start state
  • Partition the states into sets of
    indistinguishable states (equivalence classes)
  • Figure 4.12 Minimum state DFA equivalent to DFA
    in figure 4.8 (slide 10)

5
Proofs Languages are not Regular
  • Show L is not regular
  • Sets of distinguishable prefixes S S1, S2,
    Sn
  • S gtn means any DFA for L would need at least n
    states
  • So if we can construct a set of distinguishable
    prefixes of arbitrary size (unbounded)
  • Examples
  • L 0n1n n gt 1
  • S 0, 02, 03, 0n
  • For i ! j, 0i is distinguished for L from 0j
    by the string 1i
  • Thus there can be a DFA that recognizes L
  • L is not regular

6
Example L 0n1n n gt 1
  • L 0n1n n gt 1
  • S 0, 02, 03, 0n
  • For i ! j, 0i is distinguished for L from 0j
    by the string 1i
  • Thus there can be a DFA (with n states) that
    recognizes L
  • L is not regular

7
Example L 0n n is power of 2
  • S ________________________
  • For i ! j,
  • ____ is distinguished by L from ___ by the
    string
  • Thus there can be a DFA (with n states) that
    recognizes L
  • L is not regular

8
Languages Regular or Not
  • Reference Bumping the Pumping Lemma
  • L 0n1m n gt m
  • L 0n1m n gt 100, m lt 100
  • L 0m m k2
  • L ww w in a,b
  • Trick question L uww u,w in a,b
  • L w in a,b w viewed as binary is
    divisible by 7
  • Trick question L uww u,w in a,b

9
(No Transcript)
10
Pumping Lemma Theorem 4.1
  • Let L be a regular language. Then there exists a
    constant n (which depends on n, i.e. number of
    states in a DFA) such that for every string w e L
    such that w gt n, we can break into three
    strings,
  • w xyz, such that
  • y ! e
  • xy lt n
  • For all k gt 0, the string xyiz is also in L.

11
Proof of the Pumping Lemma
12
(No Transcript)
13
(No Transcript)
14
Pumping Lemma as Adversarial Game
  1. Player 1 picks the language L to be proved
    nonregular.
  2. Player 2 picks n, but does not reveal it.
  3. Player 1 picks w, which may depend on n which
    will w gtn
  4. Player 2 divides w into x, y and z obeying 1,2,
    and 3 satisfying constraints (does not tell
    specific x, y and z)
  5. Player 1 wins by picking k, which may be a
    function of n, x, y and z such that xykz is not
    in L.

15
Chapter 5 Grammars
  • Grammar for Palindromes
  • P ? e
  • P ? 0
  • P ? 1
  • P ? 0 P 0
  • P ? 1 P 1

16
Definitions G (N, T, P, S)
  • G (N, T, P, S)
  • N set of nonterminal symbols
  • T set of terminals (or sometime tokens)
  • S start symbol (a nonterminal)
  • P a set of Productions, rewrite rules of the
    form
  • X ? a1 a2 an-1 an
  • Where each ai is from N U T

17
Derivations
  • a ? ß
  • a ? ß derives in zero or more steps

18
Parse Trees
19
Grammar for Expressions
20
(No Transcript)
21
(No Transcript)
22
(No Transcript)
23
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com