1 / 7

Chapter 8 Properties of CFL

Chapter 8 Properties of CFL. 8.2: Closure Properties for CFL (1). A set is closed under some operation if performing that operation on members of the set always produces a member of that set. Assume that L 1 , L 2 are context-free languages

shamus
Download Presentation

Chapter 8 Properties of CFL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8 Properties of CFL

  2. 8.2: Closure Properties for CFL (1) A set is closed under some operation if performing that operation on members of the set always produces a member of that set. Assume that L1, L2 are context-free languages CFG for L1is G1 = (NT1 , 1, P1, S1} CFG for L2is G2 = (NT2 , 2, P2, S2} R is a regular language CFLs are closed under the operations of Union, concatenation, Kleene closure CFLs are not closed under Intersection, complementation

  3. 8.2: Closure Properties for CFL (2) UnionL = L1L2 G = ({S}  NT1  NT2, 1  2, P1  P2  {SS1| S2}, S) Concatenation L = L1L2 G = ({S}  NT1  NT2, 1  2, P1 P2  {SS1S2}, S) Closure L = L1* G = ({S}  NT1, 1, P1 {S | S1S}, S) Assumes Non-terminl names distinct in NT1 and NT2. Otherwise, can rename consistently.

  4. 8.2: Closure Properties for CFL (3) Intersection L = L1L2 L not necessarily context-free. CFLs are not closed under intersection! Can’t simulate two stacks by one stack. L1 = {anbncm | n, m 0} is CFL L2 = {anbmcm | n, m 0} is CFL L = L1L2 = {akbkck | k 0} is NOT CFL

  5. 8.2: Closure Properties for CFL (4) __ Complementation L = L1 L not necessarily context-free. CFLs are not closed under complementation! By DeMorgan’s Law, since union closed, if complementation closed, so is intersection. (contradiction)

  6. 8.2: Closure Properties for CFL (5) Intersection with RL L = L1R L is context-free. Intuition: Only one stack to simulate, so OK. Example: show that L = {anbn: n ≥ 0, n ≠ 100} is context-free L1= {anbn: n ≥ 0} is context-free L2= {a100b100} is finite, so it is regular __ L2 is regular (regular languages closed under complementation) __ L = L1L2 is context-free

  7. 8.2: Closure Properties for CFL (6) For any context free grammar, we can decide: membership (can the grammar generate a given string) if it is empty (the grammar does not generate any strings) if it is infinite (the grammar generates and infinite number of strings) However, there is no algorithm for deciding whether two context-free grammars generate the same language!

More Related