I need some help with deciding if a given language is regular, context-free or not context-free. A brief, informal explanation is sufficient in the answer, hence no need to use pumping lemma.
Lets say I have the following lanugages:
L1 = { w ∈ {a, b, c, d}* | #a(w) is even, #b(w) = 1 mod 3, w does not have
a substring abc }
L2 = { w ∈ {a, b, c, d}* | #a(w) is even, #b(w) < #c(w) }
L3 = { w ∈ {a, b, c, d}* | #a(w) < #b(w) < #c(w) }
This is my solution:
L1 = L2 ∩ L3 ∩ L4 where
L2 = #a(w) is even
L3 = #b(w) = 1 mod 3
L4 = w does not have a substring abc
A DFA can be constructed for L2, becuse L2 does not need infinite memory, so L2 is regular. For L3 the same reasoning as above. And for L4 we can construct a DFA that simply does not accept "abc", hence regular.
L1 is regular because regular languages are closed under ∩ .
For L2 we can divide the language into:
L2 = L3 ∩ L4 where
L3 = #a(w) is even
L4 = #b(w) < #c(w)
We know that a DFA can be constructed for L3, hence L3 is regular. L4 is context-free because we can construct a PDA where a stack is used to count the number of a:s and b:s.
L2 is hence context-free because the ∩ of a regular language and a context-free language result in a context-free language.
For L3 we can see that it's non context-free because we are limitied to 1 stack, and to do more than 1 comparison we need more stacks.
Is my reasonings rights ? I have a exam soon and need to know if I have got the idea behind this.
Thanks in advance