Is This Language Regular or not? - regular-language

I have the language {4^(w⋅g)34^(g)|w,g∈NAT} over the alphabet {0,1}.
I need to find out if this language is recognizable, decidable, context free, regular or none of these.
How would i go about doing that or knowing?
Thanks

Consider any string of the form 4^a 3 4^b. Can we find w, g for our a, b? Well, we know that g must equal b, and then we can choose w = a + g. Since a, b and g are natural numbers, so too must be w; the answer is that, yes, for any string of the form 4^a 3 4^b, we have a string in your language.
The language of all strings of the form 4^a 3 4^b is described by the regular expression 4* 3 4* and, as such, your language is regular, context free, decidable and recognizable.
Suppose your language weren't regular; how could you tell? You could use the Myhill-Nerode theorem or the Pumping Lemma for regular languages to derive a contradiction from assuming the language were regular.
Suppose your language weren't context-free. You could use the Pumping Lemma for context-free languages to derive a contradiction from assuming the language were context-free.
Of course, if your language weren't decidable or recognizable, you could prove that in various ways as well.

Related

Prove regular language and automata

This is a grammar and I wan to check if this language is regular or not.
L → ε | aLcLc | LL
For example the result of this grammar is:
acc, accacc ..., aacccc, acaccc, accacc, aaacccccc, ...
I know that is not a regular language but how to prove it? Is building an automata the right way to prove it? What is the resulting automata. I don't see pattern to use it for build the automata.
Thank you for any help!
First, let me quickly demonstrate that you cannot deduce the language of a grammar is irregular based solely on the grammar's being irregular. To see this, consider the unrestricted grammar:
S -> SSaSS | aS | e
SaS -> aSa
aaS -> SSa
This is clearly not a regular grammar but you should be able to verify it generates the infinite regular language of all strings of a.
That said, how should we proceed? We will need to figure out what language your grammar generates, and then argue that particular language cannot be regular. We notice that the only rule that introduces terminal symbols always introduces twice as many c as it does a. Furthermore, it's not hard to see the language must be infinite. We can use the Myhill-Nerode theorem to show that these observations imply the language must be irregular.
Consider the prefix a^n of a hypothetical string in the language of this grammar. The shortest string which can be appended to the end of this prefix to give us a string generated by this grammar is c^(2n). No shorter string will work, and that string always works. Imagine now that we were looking at a correct deterministic finite automaton for the language of the grammar. Then, whatever state processing the prefix a^n left us in, we'd need the shortest path from there to an accepting state in the automaton to have length 2n. But a DFA must have finitely many states, and n is an arbitrary natural number. Our DFA cannot work for all possible n (it would need to have arbitrarily many states). This is a contradiction, so there can be no correct DFA for the language of the grammar. Since all regular languages have DFAs, that means the language of this grammar cannot be regular.

How do you determine if a language is regular, context free but not regular, or not context free?

I have a homework problem that requires you to prove if a language is one of the three:
A Regular Language
Context-Free but Not Regular
Not Comtext-Free
How would you prove each one? I know Pumping Lemma can verify if a language is Not Regular or Not Context-Free, but that’s it.
The example to help me understand better is the following:
{ a^(2n+1)b^(3n+2) | n ∈ N }, alphabet { a, b } where N is all natural numbers.
The pumping lemma for regular languages can tell you that a language is not regular; however, it cannot tell you that a language is regular. To tell that a language is regular, you must do the equivalent of producing a finite automaton, regular grammar or regular expression and then proving it's correct for your language.
The pumping lemma for context-free languages tells you whether the language is or is not context free. That is, if a language satisfies the pumping lemma for context-free languages, it is context free; and if it does not, then it is not. However, you can certainly use it in the same way you'd use the pumping lemma for regular languages and go ahead and find a pushdown automaton or context-free grammar instead.
In your case, we can first choose the string a^(2p+1) b^(3p+2) to show that the language is not regular by the pumping lemma for regular languages. We can show the language is context-free by arguing that for any string of the form a^(2k+1) b^(3k+2) where 2k+1 and 3k+2 are sufficiently large, we can always choose v to contain 2 a's and y to contain three b's, so that pumping maintains the required property. Alternatively, we can just give a CFG for it based on the same insight:
S -> aaSbbb | abb
Then we should show the grammar is correct, which is left as an exercise.

Will L = {a*b*} be classified as a regular language?

Will L = {a*b*} be classified as a regular language?
I am confused because I know that L = {a^n b^n} is not regular. What difference does the kleene star make?
Well it is makes difference when you have a L = {a^n b^n} and a L = {a*b*}.
When you have a a^n b^n language it is a language where you must have the same number of a's and b's example:{aaabbb, ab, aabb, etc}. As you said this is not a regular expression.
But when we talk about L = {a*b*} it is a bit different here you can have any number of a followed by any numbers of b (including 0). Some example are:
{a, b, aaab, aabbb, aabbbb, etc}
As you can see it is different from the {a^n b^n} language where you needed to have the same numbers of a's and b's.
And yes a*b* is regular by its nature. If you want a good explanation why it is regular you can check this How to prove a language is regular they might have a better explanation then me (:
I hope it helped you
The language described by the regular expression ab is regular by definition. These expressions cannot describe any non-regular language and are indeed one of the ways of defining the regular languages.
{a^n b^n: n>0} (this would be a formally complete way of describing it) on the other hand, cannot be described by a regular expression. Intuitively, when reaching the border between a and b you need to remember n. Since it is not bounded, no finite-memory device can do that. In ab you only need to remember that from now on only b should appear; this is very finite. The two stars in some sense are not related; each expands its block independently of the other.

Isn't every language regular, according to formal definition of it?

This is the definition of regular languages from Wikipedia's article:
The collection of regular languages over an alphabet Σ is defined recursively as follows:
The empty language Ø is a regular language.
For each a ∈ Σ (a belongs to Σ), the singleton language {a} is a regular language.
If A and B are regular languages, then A ∪ B (union), A • B (concatenation), and A* (Kleene star) are regular languages.
No other languages over Σ are regular.
Now think about aⁿbⁿ which we know is not regular, but doesn't it pass the above rules?
{a} is regular, so is {b} and also their concatenation and thus the mentioned lang!
it feels like I'm mistaking set of languages which is, in other words, set of sets; for set of words which is, the language?
You are mistaken in your statement that you can form this specific language from the rules. Formally, this follows from the Pumping Lemma. To address the reasoning in your question, though:
{a} is regular, so by repeated concatenation, {a^m} is regular
{b} is regular, so by repeated concatenation, {b^n} is regular
so their concatenation, which is anything of the form {a^m b^n} is regular as well, but it is precisely the constraint m == n that you cannot formulate via this family.
aⁿbⁿ is a language that contains only the strings with nx as followed by nxbs.
You can create a regular language that is a superset of this language, but not this language itself.
You're right, {a} is regular and {b} is regular. Thus, by the rules you mentioned, their concatenation is regular as well. However, the concatenation of two languages is defined as {vw | v in L_1, w in L_2}. Since both L_1 and L_2 only contain a single word (a and b, respectively), this definition is equivalent to {vw | v = a, w = b}, which is the set {ab}.
Thus, the concatenation of the two languages is the set {ab}, not a^n b^n.

Proving a Language to be regular

Pumping Lemma is used to prove a language to be not regular. But How a language can be
proved to be regular ? In particular,
Let L be a language. Define half(L) to be
{ x | for some y such that |x| = |y|, xy is in L}.
Prove for each regular L that half(L) is regular.
Is there any trick or general procedure to tackle such kind of questions ?
If you can correctly describe your language L by an NFA or DFA, then it will be regular.
There is a well known equality of NFAs, DFAs, regular grammars and regular expressions, so a representation of L in any of these formalisms should do.
Provide a regular grammar or a finite automaton that matches the language. For the full list of properties you can prove to show a language is regular, see the first lines of the Wikipedia Article on regular languages.

Resources