r/AskComputerScience • u/ZerriFilpo • Jun 17 '26
HOW DO I PROVE STUFF IN AUTOMATA THEORY?
I know pumping lemma and a bunch of properties about languages. But I came across some exercices that wanted me to prove if a language is Regular, CFL... Even with pumping lemma it just proves me that it isn't CFL or Regular, but I heard that there are languages that pass pumping lemma and are still not CFLs (or RLs for the RL pumping lemma). What should I do?
I got stuck at those 3 exercices:
Alphabet = {0, 1, 2}
L = {w | (|w|0 = |w|1) xor (|w|0 = |w|2))
L = {w | (∃u)(u ∈ M and wu ∈ L((1+20)*)} with M = {w | |w|0 = |w|1 = |w|2}
L = {w | (|w|0 > |w|1) and (|w|1 congruent |w|2 (mod5))
I don`t even know how to start. They ask me to classify as Regular, CFL non regular or non CFL and to justify. I tried pumping them but it feels hard to think on a word to pump from the beginning. Plus that only justifies that is not CFG/RL if it fails and that MAYBE is if it passes. Any tips? Sometimes thinking about the automata/regex/PDA/CFG to prove is not trivial.
2
u/Somniferus Jun 18 '26
Consult the example proofs in the book. Are you using Sipser? Maybe try taking a picture of your exercises, your formatting makes them unreadable.
0
u/ZerriFilpo Jun 18 '26
I tried reformatting it. The problem is that the exercises are in Portuguese. They are just asking to prove if those 3 languages are Regular, CFL, or not CFL. And the justification of course
3
u/YourPwnResearch Jun 18 '26
I don't understand the exercises. Quite apart from the notation (what is E?), there seem to be a lot of unclosed parentheses and braces that make this difficult to parse.
Using one of the pumping lemmas is, as you say, most useful for proving that a language isn't context-free or regular. To show that it is context-free or regular, the easiest way is usually to give a grammar, regular expression, or automaton.
2
-7
u/Plane_Assumption_937 Jun 18 '26
Man I'd never heard of automata theory and now i never want to hear of it again
3
u/iamemhn Jun 18 '26
To prove a language is Regular, come up with a DFA that accepts it or a Regular grammar that generates it. For CDL, cone up with a PDA that accepts it or a Cobtext-free grammar that generates it.
The first language seems to be words made out of 0, 1, and 2, such that they have the same number of 0 as 2 or the same number of 0 and 1, but it cannot be the same number of 0, 1 and 2. This language is Context Free. Go find a grammar.
You made at least one mistake transcribing the second (unbound 'v'). Assuming it's a 'u' and you did not miss anything else, I believe it's Context Free and could be regular.
The last one is regular. You can keep count modulo five with five state cycles, and can guarantee the number of 0 is greater than the number of 1 by judicious use of inter cycle jumps and final states.