Exercise set 5 - NTNU · PDF fileExercise set 5 September 16, 2008 Part I - Regular and...

1

Click here to load reader

Transcript of Exercise set 5 - NTNU · PDF fileExercise set 5 September 16, 2008 Part I - Regular and...

Page 1: Exercise set 5 - NTNU · PDF fileExercise set 5 September 16, 2008 Part I - Regular and nonregular languages (chapters 2.2-2.3) Prove or disprove the following statement: If L 1and

Exercise set 5

September 16, 2008

Part I - Regular and nonregular languages (chapters 2.2-2.3)

Prove or disprove the following statement: If L1and L2 are nonregular languages, then L1 ∪L2 is alsononregular.

Part II - Context-free grammars (chapters 3.1-3.2)

Task 1. Section 3.1: 3.1.1 page 120

Task 2. (More or less from the �nal exam 2001) Consider the context-free grammar G = {V, Σ, R, S}given by

Σ = {∨,∧, (, ), x}V − Σ = {S, A,B}

R = {S → S ∨A

S → A

A→ A ∧B

A→ B

B → (S)B → x}

Let L(G) be the language generated by G.a) Describe L(G).b) How many words of length 1 is in L(G)? Give arguments.c) Draw a parse tree for the word x ∧ x ∨ x ∨ x ∧ (x ∨ x).

Task 3. (Final exam 2006). An unambiguous context-free grammar for regular expressions over{a, b}, with or withouth redundant parenthesis, is given by

Terminals = {a, b, ∅, (, ),∗ ,∪}Nonterminals = {R,F, T}Start symbol = R

Rules = {R→ R ∪ F | FF → FT | TT → (R) | T ∗ | a | b | ∅}

Draw parse trees for the regular expressions a ∪ b ∪ ∅∗ and (aa∗a ∪ bb∗b)∗.

Task 4. Construct a Context-Free Grammar generating the compliment of the language L ={anbn|n ≥ 0} over Σ = {a, b}.

1