DR. Torng - PowerPoint PPT Presentation

About This Presentation
Title:

DR. Torng

Description:

DR. Torng Closure Properties for CFL s Kleene Closure Union Concatenation CFL s versus regular languages regular languages subset of CFL * * * Closure Properties ... – PowerPoint PPT presentation

Number of Views:121
Avg rating:3.0/5.0
Slides: 18
Provided by: EricT67
Learn more at: http://www.cse.msu.edu
Category:
Tags: torng

less

Transcript and Presenter's Notes

Title: DR. Torng


1
DR. Torng
  • Closure Properties for CFLs
  • Kleene Closure
  • Union
  • Concatenation
  • CFLs versus regular languages
  • regular languages subset of CFL

2
Closure Properties for CFLs
  • Kleene Closure

3
CFL closed under Kleene Closure
  • Let L be an arbitrary CFL
  • Let G1 be a CFG s.t. L(G1) L
  • G1 exists by definition of L1 in CFL
  • Construct CFG G2 from CFG G1
  • Argue L(G2) L
  • There exists CFG G2 s.t. L(G2) L
  • L is a CFL

4
Visualization
  • Let L be an arbitrary CFL
  • Let G1 be a CFG s.t. L(G1) L
  • G1 exists by definition of L1 in CFL
  • Construct CFG G2 from CFG G1
  • Argue L(G2) L
  • There exists CFG G2 s.t. L(G2) L
  • L is a CFL

CFL
5
Algorithm Specification
  • Input
  • CFG G1
  • Output
  • CFG G2 such that L(G2)

CFG G1
CFG G2
6
Construction
  • Input
  • CFG G1 (V1, S, S1, P1)
  • Output
  • CFG G2 (V2, S, S2, P2)
  • V2 V1 union T
  • T is a new symbol not in V1 or S
  • S2 T
  • P2 P1 union ??

7
Closure Properties for CFLs
  • Kleene Closure Examples

8
Example 1
V2 V1 union T T is a new symbol not in
V1 or SS2 TP2 P1 union T ? ST l
  • Input grammar
  • V S
  • S a,b
  • S S
  • P
  • S ? aa ab ba bb
  • Output grammar
  • V
  • S a,b
  • Start symbol is
  • P

9
Example 2
V2 V1 union T T is a new symbol not in
V1 or SS2 TP2 P1 union T ? ST l
  • Input grammar
  • V S, T
  • S a,b
  • Start symbol is T
  • P
  • T ? ST l
  • S ? aa ab ba bb
  • Output grammar
  • V
  • S a,b
  • Start symbol is
  • P

10
Construction for Set Union
  • Input
  • CFG G1 (V1, S, S1, P1)
  • CFG G2 (V2, S, S2, P2)
  • Output
  • CFG G3 (V3, S, S3, P3)
  • V3 V1 union V2 union T
  • Variable renaming to insure no names shared
    between V1 and V2
  • T is a new symbol not in V1 or V2 or S
  • S3 T
  • P3

11
Construction for Set Concatenation
  • Input
  • CFG G1 (V1, S, S1, P1)
  • CFG G2 (V2, S, S2, P2)
  • Output
  • CFG G3 (V3, S, S3, P3)
  • V3 V1 union V2 union T
  • Variable renaming to insure no names shared
    between V1 and V2
  • T is a new symbol not in V1 or V2 or S
  • S3 T
  • P3

12
CFLs and regular languages
13
CFL Closure Properties
  • What have we just proven
  • CFLs are closed under Kleene closure
  • CFLs are closed under set union
  • CFLs are closed under set concatenation
  • What can we conclude from these 3 results?
  • It follows that regular languages are a subset of
    CFLs

14
Regular languages subset of CFL
  • Similar to reg-exp to NFA-? construction from
    module 22
  • Base Case
  • , l, a, b are regular languages over
    a,b
  • P, PS ? l, PS ? a, PS ? b
  • Inductive Case
  • If L1 and L2 are are regular languages, then L1,
    L1L2, L1 union L2 are regular languages
  • Use previous constructions to see that these
    resulting languages are also context-free

15
Other CFL Closure Properties
  • We will show that CFLs are NOT closed under many
    other set operations
  • Examples include
  • set complement
  • set intersection
  • set difference

16
Language class hierarchy
REG
17
Nested language examples
  • Prove the following languages are CFLs
  • anbncmdm m,n 0
  • anbmcmdn m,n 0
  • amnbmcn m,n 0
  • What happens if we change bounds above to 1
    instead of 0?
Write a Comment
User Comments (0)
About PowerShow.com