Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

COS3701 Assignment 3 (Exceptional Response) Due 21 August 2025

Rating
-
Sold
-
Pages
16
Grade
A+
Uploaded on
30-06-2025
Written in
2024/2025

This paper provides a comprehensive and rigorous analysis of four problems in theoretical computer science, addressing formal languages, grammars, Turing machines, and pushdown automata at a postgraduate level. For Question 1, context free grammars are constructed for the

Show more Read less
Institution
Course

Content preview

COS3701
Assignment 3

Due 21 August 2025

,Student Name: COS3701 Assignment 03


Question 1

Given that L1 = (aa)∗ and L2 = (a + b)∗ ab(a + b)∗ , find grammars
for L1 and L2 . Then use Theorem 37 to find a grammar for L1 L2 .

The language L1 = (aa)∗ consists of all strings over {a} formed by zero or more repetitions
of the substring ”aa”. Examples include ϵ, aa, aaaa, and so on. Although this is a regular
language, we construct a context-free grammar (CFG) for the purpose of composition with
another CFG.

Grammar for L1 :

Variables: {S1 }

Terminals: {a, b}

Productions:



S1 → aaS1 | ϵ


Start symbol: S1

This grammar generates strings composed only of an even number of a’s. The terminal
b is included in the alphabet for compatibility with L2 , although it does not appear in
L1 ’s productions.

The language L2 = (a + b)∗ ab(a + b)∗ consists of all strings over {a, b} that contain at
least one occurrence of the substring ab. Examples include ab, aab, aba, and baaba.

To construct a CFG for L2 , the required substring ab is made explicit in the middle,
allowing arbitrary strings of a’s and b’s before and after it.




Page 1

, Student Name: COS3701 Assignment 03


Grammar for L2 :

Variables: {S2 , X}

Terminals: {a, b}

Productions:



S2 → XabX

X → aX | bX | ϵ


Start symbol: S2

This grammar ensures the presence of at least one ab within any derivation, with both
sides allowing arbitrary strings from X.

Theorem 37 states that if L1 and L2 are context-free languages with grammars G1 =
(V1 , Σ, P1 , S1 ) and G2 = (V2 , Σ, P2 , S2 ), and V1 ∩ V2 = ∅, then their concatenation L1 L2
is also context-free. A grammar for L1 L2 can be constructed as follows:

Variables: V = V1 ∪ V2 ∪ {S}

Terminals: {a, b}

Productions:



S → S1 S2

S1 → aaS1 | ϵ

S2 → XabX

X → aX | bX | ϵ


Start symbol: S

To validate the correctness of this grammar, we examine several sample derivations.

Example: “ab”


Page 2

Connected book

Written for

Institution
Course

Document information

Uploaded on
June 30, 2025
File latest updated on
July 25, 2025
Number of pages
16
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$2.91
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
LectureLab Teachme2-tutor
Follow You need to be logged in order to follow users or courses
Sold
647
Member since
2 year
Number of followers
188
Documents
1450
Last sold
2 weeks ago
LectureLab

LectureLab: Crafted Clarity for Academic Success Welcome to LectureLab, your go-to source for clear, concise, and expertly crafted lecture notes. Designed to simplify complex topics and boost your grades, our study materials turn lectures into actionable insights. Whether you’re prepping for exams or mastering coursework, LectureLab empowers your learning journey. Explore our resources and ace your studies today!

3.6

83 reviews

5
32
4
16
3
16
2
4
1
15

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions