Download Problem Session 3

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1
CSE2001, Fall 2006
Problem Session 3
Problem 1
Prove that εk = ε for all k ≥ 0.
Proof:
First, remember the definition: w k = ε if k = 0, w k = w
. . w} if k > 0. Also, we will need
| .{z
k times
the following: wε = εw = w (definition of concatenation).
We prove the claim by induction on k.
• Base case: if k = 0, εk = ε0 = ε by the definition above.
• Induction hypothesis: assume that the claim is true for k = i, i.e. εi = ε.
• Induction step: prove that the claim is true for k = i + 1, i.e. εi+1 = ε.
We have:
εi+1 = ε| .{z
. . ε}
(i+1) times
= ε| .{z
. . ε} ε
i times
= εε
=ε
by the Induction Hypothesis
by the definition of concatenation.
Problem 2
Prove that for every language L, (L∗ )∗ = L∗ .
Proof:
First, remember the definition: A∗ is a language in which each string is a concatenation of
0 or more strings from A. Formally,
A∗ = {w | w = ε, or w = x1 . . . xk for k ≥ 1, and xi ∈ A}.
Note that, automatically, we get A ⊂ A∗ .
Since this statement is the language equality statement, we need to do a proof in two
directions.
• Easy direction: L∗ ⊂ (L∗ )∗ , by the definition of star closure.
2
CSE2001, Fall 2006
• Harder direction: let w ∈ (L∗ )∗ , need to prove w ∈ L∗ .
If w = ε, then w ∈ L∗ , because ε ∈ L∗ , by the definition of star closure.
Assume w 6= ε. Then we can write w = x1 . . . xk for some k ≥ 1, and all xi ∈ L∗ . So,
we can rephrase our goal as follows: show that for any k ≥ 1, if w = x1 . . . xk , where
all xi ∈ L∗ , then w ∈ L∗ .
Proof by induction on k.
– Base case: k = 1. w = x1 , where x1 ∈ L∗ , so w ∈ L∗ .
– Induction hypothesis: assume that the claim holds for k = i, i.e. if w = x1 . . . xi ,
where all xj ∈ L∗ , then w ∈ L∗ .
– Induction step: prove that the claim is true for k = i + 1. Let w = x1 . . . xi xi+1 ,
where all xj ∈ L∗ . Then, by the definition of concatenation, w = yxi+1 , where
y = x1 . . . xi .
To proceed, we need the following: if x ∈ L∗ and y ∈ L∗ , then xy ∈ L∗ .
Exercise: prove the lemma, using induction (on ?).
From the lemma, since by the induction hypothesis, y ∈ L∗ , and xi+1 ∈ L∗ , we
conclude w = yxi+1 ∈ L∗ .
Problem 3
Let Σ = {1, 3}. Let L be the set of non-empty strings over Σ whose characters sum up to a
multiple of 5 (E.g. 133111 ∈ L, because 1 + 3 + 3 + 1 + 1 + 1 = 10, but 13 ∈
/ L). Draw the
transition diagram for L. Explain the meaning of the states.
Solution:
Run a couple of examples first. The main point – all the DFA should care for is the
remainder of the division by 5 of the sum of the characters it seen so far. So, define the
states as follows: qi – the remainder of the division by 5 of the sum we’ve seen so far is i.
qstart
3
1
3
q0
1
q1
3
1
3
q2
3
1
1
q3
3
1
q4
CSE2001, Fall 2006
Problem 4
Design a DFA for the language L = {w | w ends with 0 and does not contain 11}.
(a) Using the DFA product construct.
(b) By constructing an NFA, and converting it into DFA.
(c) For fun: is your DFA the smallest possible ?
3
Related documents