Talk:Formal grammar

message: Please feel free to list any potentially bothersome/burdensome/opaque terminology clarification requests here as the article stands, in order that editors not over-clarify the terms. :-) 
Current candidates (see archive 1) are:
* "recognize"
-- QTJ 06:02, 6 November 2006 (UTC)
thread_title: Terminology clarification requests

message: "A context-free grammar is a grammar in which the left-hand side of each production rule consists of only a single nonterminal symbol."
Is this correct? It seems different from the definition in Context-free_grammar. Took 10:22, 2 June 2007 (UTC)
replies: text: No, it's the same definition. (I'm rather confused by your question, actually — it's not that these are two different definitions that can be proved equivalent, but rather that they're actually the same definition, albeit worded differently. Am I missing something?) —RuakhTALK 16:37, 2 June 2007 (UTC)

text: The problem is that the definition given in the context-free_grammar article was simply wrong (I have never seen it before, and I suspect it produces a formalism more powerful than context-free grammars.)  I have taken the liberty to rewrite it there. Rp 14:58, 24 July 2007 (UTC)
replies: text: That's really funny. The definition was right when Took wrote his/her comment, then the definition was changed to be wrong, and you're only now seeing his/her comment, which prompted you to take a look and fix the definition. That works really well. :-) —RuakhTALK 15:55, 24 July 2007 (UTC)
replies: text: I just realize that I misunderstood some word in the above definition. So everything is fine, and glad to see that my comment (unintentionally) helps correct an error :) Took 12:37, 6 August 2007 (UTC)
thread_title:  context-free grammar 

message: Does the language generated by a grammar consist only of the results of applications of finitely many production rules, or is there a notion of convergence to deal with?
- Brad 65.93.148.11 05:29, 19 August 2007 (UTC)
replies: text: The language generated consists of words obtainable by a finite number of production rule applications. There is no natural notion of convergence that would allow one to consider infinite number of production rule applications in the context of formal grammars. — Carl (CBM · talk) 15:35, 19 August 2007 (UTC)
thread_title:  Definition of "language" 

message: Just changed the left hand side of rule 6 in the regular grammar example from S to B.  With S, the grammar can derive the empty string (which it shouldn't), and every non-empty derived string would contain at least 2 b's (so, e.g., ab could not be derived).  So it looks very much like a typo where the S should simply be changed to B.
However, the parenthesis to the right of rule 6 is now inconsistent (because it talks about S, and the rule does not contain S any more).  I'm not sure how to resolve that, so I left it unchanged.  Anybody who knows exactly how to fix that?
ErikErnst 16:13, 25 September 2007 (UTC)
thread_title:  Regular Grammar typo 

message: From the current example: This process is repeated until we only have symbols from the alphabet (i.e., a and b).
S itself must consist of elements of the given alphabet only, right? As we said the alphabet consists of a and b only, the process of transforming S (with which we start in the example) is already finished when we start. --Abdull 11:52, 4 December 2007 (UTC)
replies: text: In this example S is just a symbol, but not a symbol from the alphabet. It's a symbol that is used to recursively generate strings. The actual strings that are generated are the ones that don't contain S; the ones that do contain S aren't done yet. — Carl (CBM · talk) 14:08, 4 December 2007 (UTC)
thread_title:  S and alphabet 

message: This page is useful, but very messy.  The main reason, I feel, of its messiness was the continuous attempt to appease both computer scientists and linguists; I have taken the liberty to take what I  I felt was the most urgent step to rectify this, namely, renaming it to use well-established terminology.  The old name (formal grammar) isn't used by anyone I know.  Rp (talk)
:I have performed this deletion and move, as requested.  I don't do this often, so if there's something that I should have done, or should have done differently, I'd appreciate knowing about it.  Accounting4Taste:talk 16:37, 30 April 2008 (UTC)
replies: text: No, you undid the move I made.  Can I please redo it?? Rp (talk) 16:16, 2 June 2008 (UTC)
replies: text: Yeah can some admin somewhere move this back to Grammar (formal language theory) -- the current name, formal grammar, is just kind of bizarre ... linas (talk) 02:43, 1 September 2008 (UTC)
thread_title:  Renaming 

message: Mine:
I call:
"0,1,2,3" are here regular, context-free, "l-system", "touring" respectively.
While sentence is made from tokens the "0,1,2 languages" add or leave it as it is (terms into that sentence). Turing can also change parts of it.
Therefore there are 2 categories : may add , may add or change.
In this list I presume that the actions like "adding" or "insert" might not be done at all. And "more places" might mean just 1 or zero. I just don't say it in the list to make it shorter :). 
*0 language adds to sentence.
*1 language inserts to sentence.
*2 language inserts at more places. He inserts it in parallel, therefore rules should be mutually exclusive.
It is important to know that 0,1 languages make change only at one place at a time. They can be (even 0 when there is some foretelling) made to run in parallel by machine, but it might not work.
2 language have to work, it is given by what it is (just like 2 + 2 is 4, for it is given. It might have been 8, but it would make sense ... I hope You get mine point :) ).
Now, something I just ask, because:
*0 language changes only 1  symbol.                A -> aB //// A-> Aa   is not possible in 0 language because it is not expanded at the end? But it can be understood as  A->aA in this case of just one rule (like simple recursion)?
*1,2,3 languages can change sequence of symbols?   AA -> aBACd
*3 can change symbols and terms?                   aA -> Ab
Correct me please. 84.16.123.194 (talk) 12:42, 10 May 2009 (UTC)
replies: text: In the Chomsky hierarchy, a type 2 language is a context sensitive language, not a language generated by L-systems. The answer to your first two questions is no.  For the answer to the first, see the discussion in regular grammar; to the second, see the definition of context-free grammars, which says there must be exactly one nonterminal on the left hand side of a rule; to the third, yes you're correct.  If this is not clear from the article, it should be.  How to improve it? Rp (talk) 16:15, 16 June 2009 (UTC)
thread_title:  Interpetations 

message: Is the relation defined in
* Given a grammar G = (N, \Sigma, P, S), the binary relation \Rightarrow_G (pronounced as  "G derives in one step") on strings in (\Sigma \cup N)^{*} is defined by:
x \Rightarrow_G y \mbox{ iff } \exists u, v, p, q \in (\Sigma \cup N)^*: x = upv \wedge y = uqv \wedge p \rightarrow q \in P
well founded? Money is tight (talk) 13:09, 4 February 2010 (UTC)
thread_title:  Relation 

message: *From this article: "[A grammar's] rules describe how to form strings from the language's alphabet that are valid according to the language's syntax."
*Then there is a section called Formal definition - The syntax of grammars, but this section does not explain the relation between syntax and grammar.
Therefore, are syntax and grammar the same? Is there a mathematical way to give a relation between these two entities? --Abdull (talk) 14:42, 31 August 2010 (UTC)
replies: text: Computer scientists talk about the syntax of a programming language; mathematicians and logicians talk about the grammar of a formal language. The two concepts are more-or-less interchangeable, although there may be some technical differences. Gandalf61 (talk) 15:05, 31 August 2010 (UTC)
thread_title:  Syntax == grammar? 

message: ::It appears that the languages recognized by an unrestricted grammar are the same as those recognized by this description of a formal grammar.  The proof can be done as follows.  Add a new nonterminal symbol a′ for each terminal a, and a new nonterminal λ.  For any string T, define T′ to be obtained from S by replacing each terminal b by b′, and interspersing λ before and after every character.  For example, (if we denote nonterminals by greek letters and terminals by roman letters), if 
:::T = a\alpha b c \beta,
::then
:::T' = \lambda a' \lambda \alpha \lambda b' \lambda c' \lambda \beta \lambda.
::If we then replace each rule
:::T \rightarrow U
::in the unrestricted grammar by
:::T' \rightarrow U'
::and add new rules:
:::S \rightarrow \lambda S \lambda 
:::\lambda \rightarrow \Lambda (the empty string), and
:::a' \rightarrow a for each terminal a;
:: then the modified grammar is a formal grammar in this sense, but the language recognized is the same.
::If we can find a source for this, where does it go?  Do we merge formal grammar and unrestricted grammar?  — Arthur Rubin  (talk) 13:52, 11 October 2011 (UTC)
replies: text:  The proof is correct, I have never seen this definition of a formal grammar, as mentioned above the name is not used in computer science. But it looks a bit like the context-sensitive grammar rules, without the non-empty requirement and without the context in the right-hand side. So where does this definition comes from? It does not come from Chomskies first paper, ther he talks about rewriting a string into another string, without restrictions.--134.102.206.230 (talk) 12:06, 30 November 2011 (UTC)
replies: text:  What is more: the title, formal grammar, is also wrong, they are rarely called that. Shall we rename this article to grammar (formal language theory)? That would convey what the title tries to say using a convention that is widely used on Wikipedia. Rp (talk) 09:10, 28 August 2015 (UTC)
thread_title: [[Unrestricted grammar]]

message: The Typ 1 Chomsky Grammars are not mentioned in the article.--134.102.206.230 (talk) 11:58, 30 November 2011 (UTC)
thread_title:  Context-sensitive is missing 

message: The grammar claimed to be equivalent to example 2's, as far as I can tell, is not. Counterexample: "b" can be derived from Grammar 2 as described in the article. It can not be derived from Grammar 3. Rule 2 as the last-applied rule is out as it would produce an undesired S at the end. So we have to use aSa -> b, which can not work as we can only ever have one S at a time, and have no way of producing an a on it's right hand side. A fix would be to substitute rules 3 and 4 with S -> a and S -> b. 45.143.78.99 (talk) 12:01, 20 January 2021 (UTC)
replies: text: Done, thanks! I don't know how those extra "a"s ended up in there ... Rp (talk) 22:17, 21 January 2021 (UTC)
thread_title:  Error in Example 3 

message: There's the concept of equivalence of two grammars, and the respective article (Equivalence (formal languages)) really should be linked somewhere in here. I wrote the comment in Formal language. Shuween (talk) 17:19, 7 March 2023 (UTC)
thread_title:  Mention the topic of equivalence of two grammars