Which language does this klmn-grammar generate?

  • Context: MHB 
  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Language
Click For Summary

Discussion Overview

The discussion revolves around the language generated by a specific grammar involving the symbols k, l, m, and n. Participants explore the strings that can be derived from the grammar and attempt to characterize the language it generates, including potential complexities and variations in the output.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants propose that the grammar generates specific strings such as kknn, llnn, kkmm, and llmm, but question whether this is correct.
  • Others argue that certain strings cannot be produced due to the absence of specific production rules, leading to confusion about the correct application of the grammar.
  • A later reply suggests that the grammar generates strings of the form k^i l^j m^i n^j, but this is met with skepticism regarding its accuracy.
  • Participants explore the implications of different paths through the grammar, leading to the identification of multiple possible word sets, including k^p l^{q+r} m^r n^{p+q} and k^{p+q} l^r m^{r+q} n^p.
  • There is discussion about whether a single formula can encompass both identified language sets or if they should be presented separately.

Areas of Agreement / Disagreement

Participants express differing views on the correctness of the strings generated by the grammar and the overall characterization of the language. Multiple competing interpretations of the grammar's output remain unresolved.

Contextual Notes

Some participants note potential misunderstandings of the grammar rules, leading to varied interpretations of the language generated. The discussion highlights the complexity of defining the language due to the multiple paths and conditions present in the grammar.

Who May Find This Useful

This discussion may be useful for those interested in formal language theory, grammar analysis, and the generation of strings from context-free grammars.

evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Also,to see if I understood it,I tried an other example.
The grammar that is given is this:

w\epsilon \left \{ k,l,m,n \right \}^{*}:I\rightarrow I_{kn},I_{kn}\rightarrow kI_{kn}n|I_{ln}|I_{km},I_{ln}\rightarrow lI_{ln}n|I_{lm},I_{km}\rightarrow kI_{km}m|I_{lm},I_{lm}\rightarrow lI_{lm}m|\O ,

and I found that it generates the following strings:

I\rightarrow I_{kn}\rightarrow k I_{kn} n \rightarrow kknn
I\rightarrow I_{ln}\rightarrow l I_{kn} n \rightarrow llnn
I\rightarrow I_{km}\rightarrow k I_{km} m \rightarrow kkmm
I\rightarrow I_{lm}\rightarrow l I_{kn} m \rightarrow llmm

Is this right?? :confused:
 
Technology news on Phys.org
Re: How to find a language generated by a given grammar

evinda said:
Also,to see if I understood it,I tried an other example.
The grammar that is given is this:

w\epsilon \left \{ k,l,m,n \right \}^{*}:I\rightarrow I_{kn},I_{kn}\rightarrow kI_{kn}n|I_{ln}|I_{km},I_{ln}\rightarrow lI_{ln}n|I_{lm},I_{km}\rightarrow kI_{km}m|I_{lm},I_{lm}\rightarrow lI_{lm}m|\O ,

and I found that it generates the following strings:

I\rightarrow I_{kn}\rightarrow k I_{kn} n \rightarrow kknn
I\rightarrow I_{ln}\rightarrow l I_{kn} n \rightarrow llnn
I\rightarrow I_{km}\rightarrow k I_{km} m \rightarrow kkmm
I\rightarrow I_{lm}\rightarrow l I_{kn} m \rightarrow llmm

Is this right?? :confused:

If it is right,how can I find the language it generates?It is more difficult than the previous one,isn't it? :o
 
Re: How to find a language generated by a given grammar

evinda said:
Also,to see if I understood it,I tried an other example.
The grammar that is given is this:

w\epsilon \left \{ k,l,m,n \right \}^{*}:I\rightarrow I_{kn},I_{kn}\rightarrow kI_{kn}n|I_{ln}|I_{km},I_{ln}\rightarrow lI_{ln}n|I_{lm},I_{km}\rightarrow kI_{km}m|I_{lm},I_{lm}\rightarrow lI_{lm}m|\varnothing ,

and I found that it generates the following strings:

I\rightarrow I_{kn}\rightarrow k I_{kn} n \rightarrow kknn
I\rightarrow I_{ln}\rightarrow l I_{kn} n \rightarrow llnn
I\rightarrow I_{km}\rightarrow k I_{km} m \rightarrow kkmm
I\rightarrow I_{lm}\rightarrow l I_{kn} m \rightarrow llmm

Is this right?? :confused:

It doesn't look right to me.
There is no rule $I_{kn} \to kn$ so you cannot produce the first string like that.
 
Re: How to find a language generated by a given grammar

I like Serena said:
It doesn't look right to me.
There is no rule $I_{kn} \to kn$ so you cannot produce the first string like that.

I used the rules: I_{kn} \rightarrow kI_{kn}n and I_{kn} \rightarrow \varnothing
:confused: How else can I do this?
 
Re: How to find a language generated by a given grammar

evinda said:
I used the rules: I_{kn} \rightarrow kI_{kn}n and I_{kn} \rightarrow \varnothing
:confused: How else can I do this?

Am I misunderstanding?
Then perhaps you can clarify?

Let me expand your ruleset:
\begin{array}{}
I&\rightarrow &I_{kn} \\
I_{kn}&\rightarrow& kI_{kn}n&|&I_{ln}&|&I_{km} \\
I_{ln}&\rightarrow& lI_{ln}n&|&I_{lm} \\
I_{km}&\rightarrow& kI_{km}m&|&I_{lm} \\
I_{lm}&\rightarrow& lI_{lm}m&|&\varnothing \\
\end{array}

Where is $I_{kn} \rightarrow \varnothing$?

I only see $I_{lm} \rightarrow \varnothing$.
 
Re: How to find a language generated by a given grammar

I like Serena said:
Am I misunderstanding?
Then perhaps you can clarify?

Let me expand your ruleset:
\begin{array}{}
I&\rightarrow &I_{kn} \\
I_{kn}&\rightarrow& kI_{kn}n&|&I_{ln}&|&I_{km} \\
I_{ln}&\rightarrow& lI_{ln}n&|&I_{lm} \\
I_{km}&\rightarrow& kI_{km}m&|&I_{lm} \\
I_{lm}&\rightarrow& lI_{lm}m&|&\varnothing \\
\end{array}

Where is $I_{kn} \rightarrow \varnothing$?

I only see $I_{lm} \rightarrow \varnothing$.

Oh I think I misunderstood the rules.
Now I found that the grammar generates the following strings:
I\rightarrow I_{kn}\rightarrow kI_{kn}n\rightarrow kI_{ln}n\rightarrow klI_{ln}nn\rightarrow klI_{lm}nn\rightarrow kllI_{lm}mnn\rightarrow kllmnn
I\rightarrow _{kn}\rightarrow kI_{kn}n\rightarrow kI_{km}n\rightarrow kkI_{km}mn\rightarrow kkI_{lm}mn\rightarrow kklI_{lm}mmn\rightarrow kklmmn
So is the language \{k^il^jm^in^j\}? :confused:
 
Re: How to find a language generated by a given grammar

evinda said:
Oh I think I misunderstood the rules.
Now I found that the grammar generates the following strings:
I\rightarrow I_{kn}\rightarrow kI_{kn}n\rightarrow kI_{ln}n\rightarrow klI_{ln}nn\rightarrow klI_{lm}nn\rightarrow kllI_{lm}mnn\rightarrow kllmnn
I\rightarrow _{kn}\rightarrow kI_{kn}n\rightarrow kI_{km}n\rightarrow kkI_{km}mn\rightarrow kkI_{lm}mn\rightarrow kklI_{lm}mmn\rightarrow kklmmn
So is the language \{k^il^jm^in^j\}? :confused:

Those look like correct words. ;)
But I don't think that is the language.

Let's try to visualize it:

View attachment 1808

Does that perhaps give you a clue what the words will look like?
 

Attachments

  • Grammar_klmn.png
    Grammar_klmn.png
    5.1 KB · Views: 119
Re: How to find a language generated by a given grammar

I like Serena said:
Those look like correct words. ;)
But I don't think that is the language.

Let's try to visualize it:

https://www.physicsforums.com/attachments/1808

Does that perhaps give you a clue what the words will look like?

Is it maybe \{k^il^jm^in^j:i,j>0\} or is it something else? :confused:
 
Last edited:
Re: How to find a language generated by a given grammar

evinda said:
Is it maybe \{k^il^jm^in^j:i,j>0\} or is it something else? :confused:

I'm afraid it's something else.
For starters, there are 2 paths through the graph, so you will get 2 possibilities.

Let's try the upper path.
When we leave state $I_{kn}$ we have $k^p I_{ln} n^p$, where $p$ could be $0$.
When leaving state $I_{ln}$, we have made it to $k^p l^q I_{lm} n^q n^p$.
When we finally leave $I_{lm}$ with $\varnothing$, we have $k^p l^q l^r m^r n^q n^p$.

So one of the 2 possible word sets is $\{ k^p l^{q+r} m^r n^{p+q} : p,q,r \in \mathbb Z_{\ge 0} \}$.
 
  • #10
Re: How to find a language generated by a given grammar

I like Serena said:
I'm afraid it's something else.
For starters, there are 2 paths through the graph, so you will get 2 possibilities.

Let's try the upper path.
When we leave state $I_{kn}$ we have $k^p I_{ln} n^p$, where $p$ could be $0$.
When leaving state $I_{ln}$, we have made it to $k^p l^q I_{lm} n^q n^p$.
When we finally leave $I_{lm}$ with $\varnothing$, we have $k^p l^q l^r m^r n^q n^p$.

So one of the 2 possible word sets is $\{ k^p l^{q+r} m^r n^{p+q} : p,q,r \in \mathbb Z_{\ge 0} \}$.

So,the other possible word set is: \{k^{p+q}l^{r}m^{r+q}n^{p}: p,q,r \in \mathbb Z_{\ge 0} \} ?
 
  • #11
Re: How to find a language generated by a given grammar

evinda said:
So,the other possible word set is: \{k^{p+q}l^{r}m^{r+q}n^{p}: p,q,r \in \mathbb Z_{\ge 0} \} ?

Yep! :D
 
  • #12
Re: How to find a language generated by a given grammar

I like Serena said:
Yep! :D

Nice :) so,if I want to write the general language,do I have to write both cases?

Or can we find one formula that satisfies both cases? :confused:
 
Last edited:
  • #13
Re: How to find a language generated by a given grammar

evinda said:
Nice :) so,if I want to write the general language,do I have to write both cases?

Or can we find one formula that satisfies both cases? :confused:

So,is the answer the languages \{k^{p+q}l^{r}m^{r+q}n^{p}: p,q,r \in \mathbb Z_{\ge 0} \} and $\{ k^p l^{q+r} m^r n^{p+q} : p,q,r \in \mathbb Z_{\ge 0} \}$ ?
 
  • #14
Re: How to find a language generated by a given grammar

evinda said:
So,is the answer the languages \{k^{p+q}l^{r}m^{r+q}n^{p}: p,q,r \in \mathbb Z_{\ge 0} \} and $\{ k^p l^{q+r} m^r n^{p+q} : p,q,r \in \mathbb Z_{\ge 0} \}$ ?

The language is the combination of the two:
$$\{k^{p+q}l^{r}m^{r+q}n^{p}: p,q,r \in \mathbb Z_{\ge 0} \} \cup \{ k^p l^{q+r} m^r n^{p+q} : p,q,r \in \mathbb Z_{\ge 0} \}$$
Or for short:
$$\{k^{p+q}l^{r}m^{r+q}n^{p},\quad k^p l^{q+r} m^r n^{p+q}\ :\ p,q,r \in \mathbb Z_{\ge 0} \}$$
 
  • #15
Re: How to find a language generated by a given grammar

I like Serena said:
The language is the combination of the two:
$$\{k^{p+q}l^{r}m^{r+q}n^{p}: p,q,r \in \mathbb Z_{\ge 0} \} \cup \{ k^p l^{q+r} m^r n^{p+q} : p,q,r \in \mathbb Z_{\ge 0} \}$$
Or for short:
$$\{k^{p+q}l^{r}m^{r+q}n^{p},\quad k^p l^{q+r} m^r n^{p+q}\ :\ p,q,r \in \mathbb Z_{\ge 0} \}$$

Great!Thank you very much! (Clapping)
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
14K
  • · Replies 6 ·
Replies
6
Views
8K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
32
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
5
Views
2K