Circular definition grammar in programming? [closed]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I was set some homework, and got stuck on one of the questions, in fact I cant see how I am wrong. I was hoping someone could explain?



If the only rule we have for making words is
word -> counter-word
how many words can we make, starting with word?


Options are



None
1
2
Infinitely Many


I guessed Infinitely Many as I can think of millions of words I can make, just looping the process of appending counter- before the word.



Apparently its None, how can it be none? He says its none because its a circular definition, but I don't understand this? Can someone explain.



He says that we can never stop. So if we can never stop surely it can't be none? Heres a video on YouTube talking about it.










share|improve this question







New contributor




Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











closed as primarily opinion-based by Jason Bassford, Mitch, sumelic, JJJ, TrevorD Apr 2 at 14:15


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.



















  • The rule will never terminate. It starts constructing the first word and the just goes on for ever and ever. So it never finishes constructing even the first word, i.e. it forms 0 words. A crucial aspect that must be included though is that “word” is a non-terminal in that grammar.

    – Richard Z
    Apr 1 at 18:21








  • 1





    It depends on if it's talking about unique words. You can keep making the same words, but they won't be unique. Also, it depends on how many words you have to start with. If it's only is talking about unique words, and the existing set of words do not include any that their counter, then you can only double what you started with. (This also presume that you cannot have counter-counter-word.) The question, as it stands, is flawed, because there are too many unstated assumptions.

    – Jason Bassford
    Apr 1 at 18:47








  • 1





    Ask your teacher. We don't know what they intended. Also, this is a question for computer science or programming concepts and their technical labels, not about English.

    – Mitch
    Apr 1 at 21:45











  • Where does the first word come from? It takes a word to make a word. The seed had to come first (from some other rule) in order to apply this rule- But it has been stipulated that this is the only rule.

    – Jim
    Apr 1 at 21:56











  • I'm voting to close this question as off-topic because it is about formal languages, not about English.

    – sumelic
    Apr 2 at 5:38


















0















I was set some homework, and got stuck on one of the questions, in fact I cant see how I am wrong. I was hoping someone could explain?



If the only rule we have for making words is
word -> counter-word
how many words can we make, starting with word?


Options are



None
1
2
Infinitely Many


I guessed Infinitely Many as I can think of millions of words I can make, just looping the process of appending counter- before the word.



Apparently its None, how can it be none? He says its none because its a circular definition, but I don't understand this? Can someone explain.



He says that we can never stop. So if we can never stop surely it can't be none? Heres a video on YouTube talking about it.










share|improve this question







New contributor




Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











closed as primarily opinion-based by Jason Bassford, Mitch, sumelic, JJJ, TrevorD Apr 2 at 14:15


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.



















  • The rule will never terminate. It starts constructing the first word and the just goes on for ever and ever. So it never finishes constructing even the first word, i.e. it forms 0 words. A crucial aspect that must be included though is that “word” is a non-terminal in that grammar.

    – Richard Z
    Apr 1 at 18:21








  • 1





    It depends on if it's talking about unique words. You can keep making the same words, but they won't be unique. Also, it depends on how many words you have to start with. If it's only is talking about unique words, and the existing set of words do not include any that their counter, then you can only double what you started with. (This also presume that you cannot have counter-counter-word.) The question, as it stands, is flawed, because there are too many unstated assumptions.

    – Jason Bassford
    Apr 1 at 18:47








  • 1





    Ask your teacher. We don't know what they intended. Also, this is a question for computer science or programming concepts and their technical labels, not about English.

    – Mitch
    Apr 1 at 21:45











  • Where does the first word come from? It takes a word to make a word. The seed had to come first (from some other rule) in order to apply this rule- But it has been stipulated that this is the only rule.

    – Jim
    Apr 1 at 21:56











  • I'm voting to close this question as off-topic because it is about formal languages, not about English.

    – sumelic
    Apr 2 at 5:38














0












0








0


1






I was set some homework, and got stuck on one of the questions, in fact I cant see how I am wrong. I was hoping someone could explain?



If the only rule we have for making words is
word -> counter-word
how many words can we make, starting with word?


Options are



None
1
2
Infinitely Many


I guessed Infinitely Many as I can think of millions of words I can make, just looping the process of appending counter- before the word.



Apparently its None, how can it be none? He says its none because its a circular definition, but I don't understand this? Can someone explain.



He says that we can never stop. So if we can never stop surely it can't be none? Heres a video on YouTube talking about it.










share|improve this question







New contributor




Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I was set some homework, and got stuck on one of the questions, in fact I cant see how I am wrong. I was hoping someone could explain?



If the only rule we have for making words is
word -> counter-word
how many words can we make, starting with word?


Options are



None
1
2
Infinitely Many


I guessed Infinitely Many as I can think of millions of words I can make, just looping the process of appending counter- before the word.



Apparently its None, how can it be none? He says its none because its a circular definition, but I don't understand this? Can someone explain.



He says that we can never stop. So if we can never stop surely it can't be none? Heres a video on YouTube talking about it.







british-english programming






share|improve this question







New contributor




Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 1 at 18:01









Adam GAdam G

1




1




New contributor




Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Adam G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




closed as primarily opinion-based by Jason Bassford, Mitch, sumelic, JJJ, TrevorD Apr 2 at 14:15


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as primarily opinion-based by Jason Bassford, Mitch, sumelic, JJJ, TrevorD Apr 2 at 14:15


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.















  • The rule will never terminate. It starts constructing the first word and the just goes on for ever and ever. So it never finishes constructing even the first word, i.e. it forms 0 words. A crucial aspect that must be included though is that “word” is a non-terminal in that grammar.

    – Richard Z
    Apr 1 at 18:21








  • 1





    It depends on if it's talking about unique words. You can keep making the same words, but they won't be unique. Also, it depends on how many words you have to start with. If it's only is talking about unique words, and the existing set of words do not include any that their counter, then you can only double what you started with. (This also presume that you cannot have counter-counter-word.) The question, as it stands, is flawed, because there are too many unstated assumptions.

    – Jason Bassford
    Apr 1 at 18:47








  • 1





    Ask your teacher. We don't know what they intended. Also, this is a question for computer science or programming concepts and their technical labels, not about English.

    – Mitch
    Apr 1 at 21:45











  • Where does the first word come from? It takes a word to make a word. The seed had to come first (from some other rule) in order to apply this rule- But it has been stipulated that this is the only rule.

    – Jim
    Apr 1 at 21:56











  • I'm voting to close this question as off-topic because it is about formal languages, not about English.

    – sumelic
    Apr 2 at 5:38



















  • The rule will never terminate. It starts constructing the first word and the just goes on for ever and ever. So it never finishes constructing even the first word, i.e. it forms 0 words. A crucial aspect that must be included though is that “word” is a non-terminal in that grammar.

    – Richard Z
    Apr 1 at 18:21








  • 1





    It depends on if it's talking about unique words. You can keep making the same words, but they won't be unique. Also, it depends on how many words you have to start with. If it's only is talking about unique words, and the existing set of words do not include any that their counter, then you can only double what you started with. (This also presume that you cannot have counter-counter-word.) The question, as it stands, is flawed, because there are too many unstated assumptions.

    – Jason Bassford
    Apr 1 at 18:47








  • 1





    Ask your teacher. We don't know what they intended. Also, this is a question for computer science or programming concepts and their technical labels, not about English.

    – Mitch
    Apr 1 at 21:45











  • Where does the first word come from? It takes a word to make a word. The seed had to come first (from some other rule) in order to apply this rule- But it has been stipulated that this is the only rule.

    – Jim
    Apr 1 at 21:56











  • I'm voting to close this question as off-topic because it is about formal languages, not about English.

    – sumelic
    Apr 2 at 5:38

















The rule will never terminate. It starts constructing the first word and the just goes on for ever and ever. So it never finishes constructing even the first word, i.e. it forms 0 words. A crucial aspect that must be included though is that “word” is a non-terminal in that grammar.

– Richard Z
Apr 1 at 18:21







The rule will never terminate. It starts constructing the first word and the just goes on for ever and ever. So it never finishes constructing even the first word, i.e. it forms 0 words. A crucial aspect that must be included though is that “word” is a non-terminal in that grammar.

– Richard Z
Apr 1 at 18:21






1




1





It depends on if it's talking about unique words. You can keep making the same words, but they won't be unique. Also, it depends on how many words you have to start with. If it's only is talking about unique words, and the existing set of words do not include any that their counter, then you can only double what you started with. (This also presume that you cannot have counter-counter-word.) The question, as it stands, is flawed, because there are too many unstated assumptions.

– Jason Bassford
Apr 1 at 18:47







It depends on if it's talking about unique words. You can keep making the same words, but they won't be unique. Also, it depends on how many words you have to start with. If it's only is talking about unique words, and the existing set of words do not include any that their counter, then you can only double what you started with. (This also presume that you cannot have counter-counter-word.) The question, as it stands, is flawed, because there are too many unstated assumptions.

– Jason Bassford
Apr 1 at 18:47






1




1





Ask your teacher. We don't know what they intended. Also, this is a question for computer science or programming concepts and their technical labels, not about English.

– Mitch
Apr 1 at 21:45





Ask your teacher. We don't know what they intended. Also, this is a question for computer science or programming concepts and their technical labels, not about English.

– Mitch
Apr 1 at 21:45













Where does the first word come from? It takes a word to make a word. The seed had to come first (from some other rule) in order to apply this rule- But it has been stipulated that this is the only rule.

– Jim
Apr 1 at 21:56





Where does the first word come from? It takes a word to make a word. The seed had to come first (from some other rule) in order to apply this rule- But it has been stipulated that this is the only rule.

– Jim
Apr 1 at 21:56













I'm voting to close this question as off-topic because it is about formal languages, not about English.

– sumelic
Apr 2 at 5:38





I'm voting to close this question as off-topic because it is about formal languages, not about English.

– sumelic
Apr 2 at 5:38










2 Answers
2






active

oldest

votes


















0














* Quick Explanation*
Rule: "Word ----> counter-word"
Question: How many words can we generate?
Answer: If Word --> counter-word = true
then
word = counter - word
and
word = x
where x = "Any other word not equal to "counter-word"
then print("Keep reading cause this dont make no sense ;)



The opposite of hot is cold, so "Word" -> "Counter-word" in that example is "hot" -> "cold" , another example would be "stop" -> "go" , "left" -> "right" and on and on until the amount of possible pairs is exhausted.
Now, "word" has no opposite except "counter-word, non-word, etc" But the reason no other answer id accepted is because this is a logical primer meant to teach you to take syntax very literally and to pay close attention to the semantics if you will.
Computer science and language run hand in hand and logic is the staple of computer science ;).






share|improve this answer








New contributor




user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • This is very unclear. The question is about a context free grammar where “counter” is a terminal and “word” a non-terminal symbol. They are not variables to be substituted with natural language words like cold, go or right. You’re mischaracterizing the core of the question.

    – Richard Z
    Apr 1 at 19:46











  • what exactly do you mean?

    – user342390
    Apr 1 at 21:49











  • “"Counter-word" in that example is "hot" -> "cold" ” - that’s not what the question is about. “Counter” can be any symbol. Say “a” or “foo” or “blupp”. It is NOT intended as a short form for “opposite.” Are you familiar with Context Free Grammar?

    – Richard Z
    Apr 1 at 22:14



















0














None is correct and it is because of his reason. If the grammar never terminates, the 'words' it generates are never actually formed because the grammar just keeps appending more and more symbols. For example:




Grammar:

S -> aS



Generation:

aS > aaS > aaaS > aaaaS > ...




This grammar will just keep appending a's forever. Because of this, it will never be able to output any finished words because the string will always contain a non-terminal and will continue processing them indefinitely.



Another phrase to describe this is that the grammar is recursive and non-terminating.



If we add another rule,




Grammar:
S -> aS | a




We can now generate any length of a's because the S will eventually be replaced with a terminal, giving us a string consisting of only terminals (i.e. a finished word).






share|improve this answer


























  • Change “keeps appending more and more rules” to “more and more symbols”. There is only one rule in this grammar.

    – Richard Z
    Apr 1 at 19:47











  • @RichardZ Yeah, that's a much better way to phrase it. Thanks

    – Veskah
    Apr 1 at 19:49


















2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














* Quick Explanation*
Rule: "Word ----> counter-word"
Question: How many words can we generate?
Answer: If Word --> counter-word = true
then
word = counter - word
and
word = x
where x = "Any other word not equal to "counter-word"
then print("Keep reading cause this dont make no sense ;)



The opposite of hot is cold, so "Word" -> "Counter-word" in that example is "hot" -> "cold" , another example would be "stop" -> "go" , "left" -> "right" and on and on until the amount of possible pairs is exhausted.
Now, "word" has no opposite except "counter-word, non-word, etc" But the reason no other answer id accepted is because this is a logical primer meant to teach you to take syntax very literally and to pay close attention to the semantics if you will.
Computer science and language run hand in hand and logic is the staple of computer science ;).






share|improve this answer








New contributor




user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • This is very unclear. The question is about a context free grammar where “counter” is a terminal and “word” a non-terminal symbol. They are not variables to be substituted with natural language words like cold, go or right. You’re mischaracterizing the core of the question.

    – Richard Z
    Apr 1 at 19:46











  • what exactly do you mean?

    – user342390
    Apr 1 at 21:49











  • “"Counter-word" in that example is "hot" -> "cold" ” - that’s not what the question is about. “Counter” can be any symbol. Say “a” or “foo” or “blupp”. It is NOT intended as a short form for “opposite.” Are you familiar with Context Free Grammar?

    – Richard Z
    Apr 1 at 22:14
















0














* Quick Explanation*
Rule: "Word ----> counter-word"
Question: How many words can we generate?
Answer: If Word --> counter-word = true
then
word = counter - word
and
word = x
where x = "Any other word not equal to "counter-word"
then print("Keep reading cause this dont make no sense ;)



The opposite of hot is cold, so "Word" -> "Counter-word" in that example is "hot" -> "cold" , another example would be "stop" -> "go" , "left" -> "right" and on and on until the amount of possible pairs is exhausted.
Now, "word" has no opposite except "counter-word, non-word, etc" But the reason no other answer id accepted is because this is a logical primer meant to teach you to take syntax very literally and to pay close attention to the semantics if you will.
Computer science and language run hand in hand and logic is the staple of computer science ;).






share|improve this answer








New contributor




user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • This is very unclear. The question is about a context free grammar where “counter” is a terminal and “word” a non-terminal symbol. They are not variables to be substituted with natural language words like cold, go or right. You’re mischaracterizing the core of the question.

    – Richard Z
    Apr 1 at 19:46











  • what exactly do you mean?

    – user342390
    Apr 1 at 21:49











  • “"Counter-word" in that example is "hot" -> "cold" ” - that’s not what the question is about. “Counter” can be any symbol. Say “a” or “foo” or “blupp”. It is NOT intended as a short form for “opposite.” Are you familiar with Context Free Grammar?

    – Richard Z
    Apr 1 at 22:14














0












0








0







* Quick Explanation*
Rule: "Word ----> counter-word"
Question: How many words can we generate?
Answer: If Word --> counter-word = true
then
word = counter - word
and
word = x
where x = "Any other word not equal to "counter-word"
then print("Keep reading cause this dont make no sense ;)



The opposite of hot is cold, so "Word" -> "Counter-word" in that example is "hot" -> "cold" , another example would be "stop" -> "go" , "left" -> "right" and on and on until the amount of possible pairs is exhausted.
Now, "word" has no opposite except "counter-word, non-word, etc" But the reason no other answer id accepted is because this is a logical primer meant to teach you to take syntax very literally and to pay close attention to the semantics if you will.
Computer science and language run hand in hand and logic is the staple of computer science ;).






share|improve this answer








New contributor




user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










* Quick Explanation*
Rule: "Word ----> counter-word"
Question: How many words can we generate?
Answer: If Word --> counter-word = true
then
word = counter - word
and
word = x
where x = "Any other word not equal to "counter-word"
then print("Keep reading cause this dont make no sense ;)



The opposite of hot is cold, so "Word" -> "Counter-word" in that example is "hot" -> "cold" , another example would be "stop" -> "go" , "left" -> "right" and on and on until the amount of possible pairs is exhausted.
Now, "word" has no opposite except "counter-word, non-word, etc" But the reason no other answer id accepted is because this is a logical primer meant to teach you to take syntax very literally and to pay close attention to the semantics if you will.
Computer science and language run hand in hand and logic is the staple of computer science ;).







share|improve this answer








New contributor




user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Apr 1 at 19:39









user342390user342390

112




112




New contributor




user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user342390 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • This is very unclear. The question is about a context free grammar where “counter” is a terminal and “word” a non-terminal symbol. They are not variables to be substituted with natural language words like cold, go or right. You’re mischaracterizing the core of the question.

    – Richard Z
    Apr 1 at 19:46











  • what exactly do you mean?

    – user342390
    Apr 1 at 21:49











  • “"Counter-word" in that example is "hot" -> "cold" ” - that’s not what the question is about. “Counter” can be any symbol. Say “a” or “foo” or “blupp”. It is NOT intended as a short form for “opposite.” Are you familiar with Context Free Grammar?

    – Richard Z
    Apr 1 at 22:14



















  • This is very unclear. The question is about a context free grammar where “counter” is a terminal and “word” a non-terminal symbol. They are not variables to be substituted with natural language words like cold, go or right. You’re mischaracterizing the core of the question.

    – Richard Z
    Apr 1 at 19:46











  • what exactly do you mean?

    – user342390
    Apr 1 at 21:49











  • “"Counter-word" in that example is "hot" -> "cold" ” - that’s not what the question is about. “Counter” can be any symbol. Say “a” or “foo” or “blupp”. It is NOT intended as a short form for “opposite.” Are you familiar with Context Free Grammar?

    – Richard Z
    Apr 1 at 22:14

















This is very unclear. The question is about a context free grammar where “counter” is a terminal and “word” a non-terminal symbol. They are not variables to be substituted with natural language words like cold, go or right. You’re mischaracterizing the core of the question.

– Richard Z
Apr 1 at 19:46





This is very unclear. The question is about a context free grammar where “counter” is a terminal and “word” a non-terminal symbol. They are not variables to be substituted with natural language words like cold, go or right. You’re mischaracterizing the core of the question.

– Richard Z
Apr 1 at 19:46













what exactly do you mean?

– user342390
Apr 1 at 21:49





what exactly do you mean?

– user342390
Apr 1 at 21:49













“"Counter-word" in that example is "hot" -> "cold" ” - that’s not what the question is about. “Counter” can be any symbol. Say “a” or “foo” or “blupp”. It is NOT intended as a short form for “opposite.” Are you familiar with Context Free Grammar?

– Richard Z
Apr 1 at 22:14





“"Counter-word" in that example is "hot" -> "cold" ” - that’s not what the question is about. “Counter” can be any symbol. Say “a” or “foo” or “blupp”. It is NOT intended as a short form for “opposite.” Are you familiar with Context Free Grammar?

– Richard Z
Apr 1 at 22:14













0














None is correct and it is because of his reason. If the grammar never terminates, the 'words' it generates are never actually formed because the grammar just keeps appending more and more symbols. For example:




Grammar:

S -> aS



Generation:

aS > aaS > aaaS > aaaaS > ...




This grammar will just keep appending a's forever. Because of this, it will never be able to output any finished words because the string will always contain a non-terminal and will continue processing them indefinitely.



Another phrase to describe this is that the grammar is recursive and non-terminating.



If we add another rule,




Grammar:
S -> aS | a




We can now generate any length of a's because the S will eventually be replaced with a terminal, giving us a string consisting of only terminals (i.e. a finished word).






share|improve this answer


























  • Change “keeps appending more and more rules” to “more and more symbols”. There is only one rule in this grammar.

    – Richard Z
    Apr 1 at 19:47











  • @RichardZ Yeah, that's a much better way to phrase it. Thanks

    – Veskah
    Apr 1 at 19:49
















0














None is correct and it is because of his reason. If the grammar never terminates, the 'words' it generates are never actually formed because the grammar just keeps appending more and more symbols. For example:




Grammar:

S -> aS



Generation:

aS > aaS > aaaS > aaaaS > ...




This grammar will just keep appending a's forever. Because of this, it will never be able to output any finished words because the string will always contain a non-terminal and will continue processing them indefinitely.



Another phrase to describe this is that the grammar is recursive and non-terminating.



If we add another rule,




Grammar:
S -> aS | a




We can now generate any length of a's because the S will eventually be replaced with a terminal, giving us a string consisting of only terminals (i.e. a finished word).






share|improve this answer


























  • Change “keeps appending more and more rules” to “more and more symbols”. There is only one rule in this grammar.

    – Richard Z
    Apr 1 at 19:47











  • @RichardZ Yeah, that's a much better way to phrase it. Thanks

    – Veskah
    Apr 1 at 19:49














0












0








0







None is correct and it is because of his reason. If the grammar never terminates, the 'words' it generates are never actually formed because the grammar just keeps appending more and more symbols. For example:




Grammar:

S -> aS



Generation:

aS > aaS > aaaS > aaaaS > ...




This grammar will just keep appending a's forever. Because of this, it will never be able to output any finished words because the string will always contain a non-terminal and will continue processing them indefinitely.



Another phrase to describe this is that the grammar is recursive and non-terminating.



If we add another rule,




Grammar:
S -> aS | a




We can now generate any length of a's because the S will eventually be replaced with a terminal, giving us a string consisting of only terminals (i.e. a finished word).






share|improve this answer















None is correct and it is because of his reason. If the grammar never terminates, the 'words' it generates are never actually formed because the grammar just keeps appending more and more symbols. For example:




Grammar:

S -> aS



Generation:

aS > aaS > aaaS > aaaaS > ...




This grammar will just keep appending a's forever. Because of this, it will never be able to output any finished words because the string will always contain a non-terminal and will continue processing them indefinitely.



Another phrase to describe this is that the grammar is recursive and non-terminating.



If we add another rule,




Grammar:
S -> aS | a




We can now generate any length of a's because the S will eventually be replaced with a terminal, giving us a string consisting of only terminals (i.e. a finished word).







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 1 at 19:48

























answered Apr 1 at 18:49









VeskahVeskah

31415




31415













  • Change “keeps appending more and more rules” to “more and more symbols”. There is only one rule in this grammar.

    – Richard Z
    Apr 1 at 19:47











  • @RichardZ Yeah, that's a much better way to phrase it. Thanks

    – Veskah
    Apr 1 at 19:49



















  • Change “keeps appending more and more rules” to “more and more symbols”. There is only one rule in this grammar.

    – Richard Z
    Apr 1 at 19:47











  • @RichardZ Yeah, that's a much better way to phrase it. Thanks

    – Veskah
    Apr 1 at 19:49

















Change “keeps appending more and more rules” to “more and more symbols”. There is only one rule in this grammar.

– Richard Z
Apr 1 at 19:47





Change “keeps appending more and more rules” to “more and more symbols”. There is only one rule in this grammar.

– Richard Z
Apr 1 at 19:47













@RichardZ Yeah, that's a much better way to phrase it. Thanks

– Veskah
Apr 1 at 19:49





@RichardZ Yeah, that's a much better way to phrase it. Thanks

– Veskah
Apr 1 at 19:49



Popular posts from this blog

Bruad Bilen | Luke uk diar | NawigatsjuunCommonskategorii: BruadCommonskategorii: RunstükenWikiquote: Bruad

Modern approach to radio buttons

A word for worn pool table felt