0% found this document useful (0 votes)
16 views2 pages

Assignment 3

The document provides instructions for an assignment on formal languages and automata theory. It consists of 5 tasks: 1) construct context-free grammars for 5 languages; 2) determine the language generated by a context-free grammar; 3) show that 2 context-free grammars are ambiguous; 4) construct finite automata using Kleene's theorem; 5) prove a language is generated by a context-free grammar.

Uploaded by

javeriasahar865
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Assignment 3

The document provides instructions for an assignment on formal languages and automata theory. It consists of 5 tasks: 1) construct context-free grammars for 5 languages; 2) determine the language generated by a context-free grammar; 3) show that 2 context-free grammars are ambiguous; 4) construct finite automata using Kleene's theorem; 5) prove a language is generated by a context-free grammar.

Uploaded by

javeriasahar865
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

FL&TA CS224 PAGE 1

FORMAL LANGUAGES AND AUTOMATA THEORY


ASSIGNMENT # 3
NAME: ___________________________ REG#: _____________________________________

COURSE CODE: CS224 INSTRUCTOR: MUHAMMAD SAJID ALI

TOTAL MARKS: 82
--------------------------------------------------------------------------------------------------------------------------------------------------------------

Instructions

• You are free to consult each other for verbal help. However, copying or sharing the soft/hard copy with each
other will not only result into the cancellation of the current assignment, but it may also impact your grade
in all the future assignments and exams as well.
• List your collaborators on the last page of your assignment. Collaborators are any people you discussed this
assignment with. This is an individual assignment, so be aware of the course's collaboration policy.
• You must attach this assignment at the top of your solution.

Tasks

Solve the following problems. The solutions may or may not be available online. If they are available, try to understand
them before re-phrasing them in your own words.

Task 1: Construct the context-free grammar for each of the following languages. (30 Marks)

1. {w ∈ {0 1} * | w contains at least three 1s} (05 Marks)


2. {w ∈ {0 1} * | w = wR and |w| is even} (05 Marks)
3. {w ∈ {0 1} * | the length of w is odd, and the middle symbol is 0} (06 Marks)
4. {ai bj ck | i j k >= 0, and i = j or i = k} (10 Marks)
5. {a bn a c a bn a | n >= 0} (04 Marks)

Task 2: What is the language generated by the following CFG (5 Marks)

S → aX
X → aX | bX | Λ

Task 3: Show that the following CFGs are ambiguous by finding a word with two distinct syntax trees.

1. S → SaSaS | b (5 Marks)
2. S → aSb | Sb | Sa | a (5 Marks)

Task 4: Using the algorithm of Kleene’s theorem, Part 3, Rule 2, construct FAs for the following languages

FA1 FA2
FL&TA CS224 PAGE 2

1. FA1 + FA2 (12 Marks)


2. (FA2) ( FA1) (10 Marks)
3. (FA2)* (10 Marks)

Task 5: Consider the following CFG and prove that this generates the language defined by the regular expression a* bb (5
Marks)

S → aS | bb

You might also like