Question text is in black, answers in blue.
Yes.
Let's see, each of the four arrows can go to either of two places, so there are 24=16 DFA's, right?
Look at the solution to Exercise 14.1.3 (in the back of the book) again. You're right about the arrows, but you also have to pick final states. Each state could be final or non-final, so there are four DFA's for every set of arrows, or 4*16 = 64 total.
But if there's no final state, how could the DFA accept any strings?
It can't, but it's still a valid DFA. As I said, there are many cases you can do easily -- the 16 DFA's with no final state, for example, all have the same language.
Maybe. If there is no DFA for the language of palindromes, the proof would go like the proof for the Paren example -- you would need to find an infinite set of pairwise indistinguishable strings. But if there is a DFA, the proof would be different from the Paren example.
Look at the solutions for HW#5, handed out in class. I suggest you start by considering when two strings would be L-equivalent for this language. Try to find strings u and v such that u ≠ v but such that for any string w, the strings uw and vw are either both panalphabetic or both not panalphebetic. Having found an example, you should be able to see the property of u and v that makes this true, and thus be able to classify all strings into equivalence classes.
Note added 7 December: If 26 letters are too confusing, look at the similar problem where there are only two letters in the alphabet, so that "panalphabetic" means "having both an a and a b". Then adapt what you've figured out to the case of 26 letters.
Start by looking at particular small values of k -- figure out the NFA's for k=0, k=1, and k=2 and you can then describe what the NFA for an arbitrary k looks like. If a state has a transition to itself, it is still just one state.
Yes. The language {ab} is the set consisting of the string "ab" and no other strings. That language is denoted by the regular expression "ab".
RegExp
and DFA
.
Do you want us to write a new pseudo-Java class for λ-NFA's?
No, I should have given you that class, my bad.
Here is the class LambdaNFA
-- you need to write a method
toLambdaNFA()
for the RegExp
class that returns a
LambdaNFA
object that is equivalent to the calling
RegExp
object.
public class LambdaNFA
{// represents lambda-NFA's with input alphabet {0, 1}
public final static natural LAMBDA = 2;
public natural states; // how many states
// no "letters" as in DFA class since alphabet is {0, 1}
public natural start; // start state, is < "states"
public boolean [] isFinal = new boolean [states];
// isFinal[i] means i is a final state
public boolean [] [] [] arrow = new boolean [states] [3] [states];
// arrow [p,i,q] means we have an arrow from p to q
// labeled "i", where i is 0, 1, or LAMBDA
// no methods as we would only convert this to an NFA
// and then a DFA -- there is no way to "run" it
}
I did Problem 14.10.4 in lecture on Thursday 2 December. The regular expression is (L(L(LR)*R)*R)*.
LambdaNFA
objects in my
toLambdaNFA
method, I'm going to
need a constructor. Do I have to write one myself?
No, I'll give you one, though if you would prefer your
own go ahead and write it. This takes a parameter
size
, the number of states in the λ-NFA you are
constructing. You get to pick the state numbering, so I suggest that in the
λ-NFA's you construct, you always have the start state be state 0 and
have the one final state be state size - 1
.
public LambdaNFA (natural size)
{// creates LNFA with "size" states, start state 0, final state "size - 1",
// no transitions
states = size;
start = 0;
for (natural i=0; i < size - 1; i++)
isFinal[i] = false;
isFinal[size - 1] = true;
for (natural p=0; p < states; p++)
for (natural a=0; a < 3; a++)
for (natural q=0; q < states; q++)
arrow [p, a, q] = false;
}
Any clear and correct description is ok. There are some of the languages where the regular expression is clearly the simplest way to describe the language, and others where it might not be.
No, I'm talking about a separate language for each k. For k = 0 this is the set of strings ending in "a", for k = 1 it is the strings whose next-to-last letter is "a", for k = 2 it is the strings whose third-to-last letter is "a", and so forth. Each value of k has its own NFA and its own DFA. You need to tell me what all of these NFA's look like, as a function of k. As I said for Question 6.4 above, it may be useful to look at particular small values of k first.
You are right, since λ is a string and L(M) is a language, it is a type error as written. That's because it is written wrong -- it should say "λ ∉ L(M)", that λ is not an element of L(M). You certainly should be confused by what is written there -- my thanks and apologies.
Last modified 8 December 2010