MHB How can I check if the grammar is regular?

  • Thread starter Thread starter mathmari
  • Start date Start date
  • Tags Tags
    Regular
AI Thread Summary
To determine if the given grammars are regular, it's essential to understand the definition of regular grammars, which have rules that typically take the form K → aK' or K → ε. In this discussion, it is concluded that Grammar G2 (I → KL) and Grammar G3 (I → II) do not conform to this structure, thus they are not regular grammars. Grammar G1 is suggested to be regular based on its adherence to the defined rules. Additionally, the conversation highlights that the languages generated by these grammars may still be regular, but this requires further analysis of the specific languages produced by each grammar. The approach to verifying the regularity of the languages involves identifying the languages generated by the grammars and then checking their regularity.
mathmari
Gold Member
MHB
Messages
4,984
Reaction score
7
I have the following grammars and I have to check if they are regular. Could you tell me how I can check this?

$G_1:$$$ I \to aK|bL$$
$$K \to bL| \varnothing$$
$$L \to dL|cK| \varnothing$$

$G_2:$$$ I \to KL$$
$$K \to aK|bK| \varnothing$$
$$L \to cL| dL| \varnothing$$

$G_3:$$$I \to II|(I)| \varnothing$$
 
Technology news on Phys.org
mathmari said:
I have the following grammars and I have to check if they are regular. Could you tell me how I can check this?

$G_1:$$$ I \to aK|bL$$
$$K \to bL| \varnothing$$
$$L \to dL|cK| \varnothing$$

$G_2:$$$ I \to KL$$
$$K \to aK|bK| \varnothing$$
$$L \to cL| dL| \varnothing$$

$G_3:$$$I \to II|(I)| \varnothing$$

Hey! :o

What is the definition of a regular grammar?
 
I like Serena said:
Hey! :o

What is the definition of a regular grammar?

The rules of a regular grammar are of the form:
$$ K \to \varnothing $$
$$ K \to aK' $$

At the second rule can it be $ K \to a K $ ?

At $G_2$ we have the rule $I \to KL$, that isn't of the form of one of the above rules, so $G_2$ is not a regular grammar, is it?

And $G_3$ for the same reason ($ I \to II$ ) is not a regular grammar.
 
mathmari said:
The rules of a regular grammar are of the form:
$$ K \to \varnothing $$
$$ K \to aK' $$

At the second rule can it be $ K \to a K $ ?

Yes.
If you read the context of the definition of a "right regular grammar", it should say that a rule of the second type has a single non-terminal on the left side, and a terminal followed by a non-terminal on the right hand side.
Note that a regular grammar is a left regular grammar or a right regular grammar.
At $G_2$ we have the rule $I \to KL$, that isn't of the form of one of the above rules, so $G_2$ is not a regular grammar, is it?

And $G_3$ for the same reason ($ I \to II$ ) is not a regular grammar.

Correct. ;)
 
I like Serena said:
Yes.
If you read the context of the definition of a "right regular grammar", it should say that a rule of the second type has a single non-terminal on the left side, and a terminal followed by a non-terminal on the right hand side.
Note that a regular grammar is a left regular grammar or a right regular grammar.

Correct. ;)

Great! Thanks! :o

And how can I check if the languages that these grammars generate are regular?
 
mathmari said:
Great! Thanks! :o

And how can I check if the languages that these grammars generate are regular?

From wiki: a regular grammar is a formal grammar that describes a regular language.

More specifically, they are the same!
Or formally: the definitions are equivalent.
 
I like Serena said:
From wiki: a regular grammar is a formal grammar that describes a regular language.

More specifically, they are the same!
Or formally: the definitions are equivalent.

So only the language that is generated from the first grammar is regular?
 
mathmari said:
So only the language that is generated from the first grammar is regular?

Eh... not exactly.
The languages generated by those other grammars might have another grammar that is regular.
 
I like Serena said:
Eh... not exactly.
The languages generated by those other grammars might have another grammar that is regular.

So do I have to find the languages that these grammars generate and then check if they are regular?
 
  • #10
mathmari said:
So do I have to find the languages that these grammars generate and then check if they are regular?

That would be a good way to go! (Angel)
 
  • #11
I like Serena said:
That would be a good way to go! (Angel)

Ok! Thanks! :o
 

Similar threads

Replies
8
Views
3K
Replies
24
Views
4K
Replies
12
Views
2K
Replies
1
Views
3K
Replies
8
Views
2K
Replies
13
Views
2K
Replies
2
Views
2K
Replies
15
Views
4K
Back
Top