How can I check if the grammar is regular?

  • Context: MHB 
  • Thread starter Thread starter mathmari
  • Start date Start date
  • Tags Tags
    Regular
Click For Summary
SUMMARY

This discussion focuses on determining the regularity of three grammars: G1, G2, and G3. G1 is confirmed to be a regular grammar due to its adherence to the rules of regular grammars, while G2 and G3 are identified as non-regular because they contain rules that do not fit the required forms. The participants clarify that a regular grammar must have production rules of the form K → aK' or K → ∅, and emphasize the equivalence between regular grammars and the languages they generate.

PREREQUISITES
  • Understanding of formal grammar concepts
  • Familiarity with regular languages
  • Knowledge of grammar production rules
  • Basic comprehension of left and right regular grammars
NEXT STEPS
  • Study the properties of regular languages and their grammars
  • Learn about the Chomsky hierarchy of grammars
  • Explore methods for converting context-free grammars to regular grammars
  • Investigate the Pumping Lemma for regular languages
USEFUL FOR

Students and professionals in computer science, linguistics, and anyone involved in formal language theory or automata theory.

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 13 ·
Replies
13
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 24 ·
Replies
24
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 30 ·
2
Replies
30
Views
2K