Homework 2

Transcription

Homework 2
CS138: Automata and Formal Languages
Lecturer: Stefano Tessaro
UC Santa Barbara
Fall 2014
Homework 2
Posted: Friday, Oct 10, 2014 – 11:59pm
Due: Tuesday, Oct 21, 2014 – 12pm (HFH 2108) or 12:30pm (in class)
Task 1 – DFAs
(6 points)
Consider the DFA M defined by the following transition graph:
a) Represent the DFA as a tuple M = (Q, Σ, δ, q0 , F ).
b) What is δ ∗ (q0 , ab)? What is δ ∗ (q0 , abaabbb)? What is δ ∗ (q0 , abbbba)?
c) Describe the language L(M ) accepted by M .
Hint: It will be easier to represent L(M ) as L1 ∪ L2 , for appropriate L1 and L2 .
Task 2 – Regular Languages
(9 points)
Show that each of the following languages with alphabet Σ = {a, b} is regular. Concretely, give corresponding DFAs accepting them, and justify (in words, but as precisely
as possible) why your DFAs accept the corresponding languages.
a) L1 := {a2 b3 ai : i ≥ 2}.
b) L2 := {w ∈ Σ∗ : |w| is even}.
c) L3 := {abw : w ∈ Σ∗ , w does not contain two consecutive a’s}
1
Task 3 – Two-state DFAs
(7 points)
Consider the DFA with alphabet Σ = {0, 1} defined by the following transition graph:
a) Find a language L ⊆ {0, 1}∗ such that L(M ) = L∗ .
b) How many different DFAs with states Q = {q0 , q1 }, initial state q0 , and alphabet Σ =
{0, 1} are there?
Hint: Here, different means with different structure, i.e., two different DFAs may well
accept the same language and be equivalent.
Task 4 – Finite Languages
(8 points)
The goal of this task is to convince yourself that finite languages (i.e., languages L that
only contain a finite number of sentences), are regular.
a) Let L1 = {010} be a language with one single sentence, and alphabet Σ = {0, 1}. Show
that L1 is regular by giving a corresponding DFA.
b) Let L2 = {010, 011, 100}. Show that L2 is regular by giving a corresponding DFA.
c) Show that every finite language L over an alphabet Σ is regular by giving a method to
construct the corresponding DFA for any finite language
2