COS Assignment 1.
COURSE: THEORETICAL COMPUTER SCIENCE III COURSE CODE: COS3701 SEMESTER: 2021 01 ASSIGNMENT: 01 UNIQUE NUMBER: DUE DATE: 15 TH MAY 2021 COS3701 REG. NO UNIQUE NO: Page 1 of 10 1. Problem 3(ii) on page 255. Consider the CFG S → XaXaX X → aX|bX|Λ What is the language this CFG generates? This CFG can generate (a+b)*a(a+b)*a(a+b)*. We can thus verify the language as follows: ▪ The CFG S → XaXaX only generates words that contain as, therefore the grammar only generates words in L. ▪ We select any word in L and write it down as y1ay2ay3 where yi(1 ≤ i ≤ 3) can be a string in as and bs. Taking S → XaXaX, we indicate the right side by X1aX2aX3 and then confirm if the first letter of yi(1 ≤ i ≤ 3) is an a. We can now confirm the production Xi → aXi and if the first letter is a b, then apply production Xi → bXi. We then apply the same to the successive letters until we finally apply Xi → Ʌ to remove X. This is applied to y1, y2 and y3 to get the word y1ay2ay3. Given that this is a word in L, it therefore indicates that the grammar can generate all words in L. 2. Problem 8(v) on page 256. Find CFGs for the following languages over the alphabet ∑ = {a b}: v. All words that have different first and last letters: {ab ba aab abb baa bba . . .}
Información del documento
- Subido en
- 13 de noviembre de 2021
- Número de páginas
- 11
- Escrito en
- 2021/2022
- Tipo
- Examen
- Contiene
- Preguntas y respuestas