Assignment 2
Due July 2025
, COS3701
Assignment 2 2025
Due July 2025
Question 1: CFG for All Strings Over Σ = { a,b} That Do Not Contain the
Substring ”aba”
Context
Construct a context-free grammar (CFG) that generates all strings over Σ = { a,b} such that
the forbidden substring “aba” does not appear.
CFG Definition
• Non-terminals: S,A,B
• Terminals: a,b
• Start Symbol: S
• Productions:
S → aA | bS | ε
A → aA | bB | ε
B → aB | bS | ε
Explanation
The rule B→ a...is omitted to block the construction of “aba”. This ensures that no
derivation path can form the substring “aba”.