3

I know how to draw a DFA, but I have problems with this specific one:

${L = \{ w \in \{a,b,c\}^* \mid \ |w|_a \equiv |w|_b - 2|w|_c \mod \ 5 \} }$

This language is regular and there has to exist a DFA (It would be great if someone could leave a comment WHY a language like this one is regular). Finally, I got a solution, but I'm not really satisfied with my solution. How can I present the DFA in a more clearly way? (is it possible to draw a "Planar graph" of it?)

DFA

Raphael
  • 72,336
  • 29
  • 179
  • 389
jannnik
  • 85
  • 1
  • 5
  • 1
    Since there are a finite number of equivalence classes for each $|w|_x$ mod 7, maybe trying making these the states. – Louis Apr 11 '15 at 10:04
  • I think there are equivalence classes for the number of a's: 0, 1, 2, 3, 4. But how to solve the problem with "|w|b−2|w|c"? – jannnik Apr 11 '15 at 10:18
  • 1
    Elaborating on @Louis's hint, as a general approach to DFA construction for languages like this, start by writing down the things you have to keep track of: the number of $a$s mod 7 seen so far, the number of $b$s minus twice the number of $c$s mod 7 seen so far, and whether they're equal. You can make a state for each configuration of these three things (e.g. [4 $a$s, 2 $b$s minus 2 times 1 $c$ (so the "zero" case) , and these two aren't equal] would be one state). This gives you quite a lot of states, but some careful thought about better ways of keeping track of the info. makes it smaller. – Luke Mathieson Apr 11 '15 at 10:18
  • 2
    @jannnik The whole thing is mod 7, so there's 7 equivalence classes on both side (0,...,6), the fact that the right hand side is an equation doesn't change this. What the equation does is affect which equivalence class you move to when you see a $b$ or $c$ in a slightly more complex way that with the $a$s. – Luke Mathieson Apr 11 '15 at 10:20
  • 2
    What have you tried? Where did you get stuck? We do not want to just do your (home-)work for you; we want you to gain understanding. However, as it is we do not know what your underlying problem is, so we can not begin to help. See here for a relevant discussion. If you are uncertain how to improve your question, why not ask around in [chat]? You may also want to check out our reference questions. – Raphael Apr 11 '15 at 12:22
  • Hi, I added my current solution. This is no homework, it's an exercise for exam preparation. I asked the question to understand how to create a DFA for languages like this one, and the answers to the reference question "How to prove a language is regular?" don't provide enough detail for my question. – jannnik Apr 13 '15 at 21:39
  • 2
    Make your life easy first: put 0 on one side of the equation, and all the rest on the other side. Then you can work with 5 states, which is a lot more comfortable. Somtimes you can save a lot of energy by thinling a bit first about the way you should transform the problem. – babou Apr 13 '15 at 23:26
  • 1
    To give a short answer, with the hope that the question gets reopened: (1) it is regular because you can draw a DFA, but a more general observation is that you only need to keep track of a constant amount of information (the modulo values of the three quantities at worst), so three numbers, (2) there is a much smaller DFA, a la babou's comment (the trick is you can use the equation so you only have to keep track of one number) and (3) no, there's no planar drawing, but the smaller one is only just not planar (unless there's a clever solution I haven't thought of, which is quite possible). – Luke Mathieson Apr 14 '15 at 01:29
  • 2
    Thanks for your answers. Finally I have a much simpler DFA with 5 states. I put 0 on the left side of the equation, this was a really good idea. The DFA looks a bit like a K5 graph with double edges on the circle (one edge direction for the a's and one for the b's) and the crossing edges in the center of the circle for the c's. – jannnik Apr 14 '15 at 10:13
  • General note: if you have some NFA, there are simple algorithms that give you a minimal DFA. – Raphael Dec 04 '16 at 02:05

1 Answers1

3

Here is the minimal DFA. It keeps track of $|w|_a-|w|_b+2|w|_c\bmod 5$.

DFA

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503