Production (computer science)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

A production or production rule in computer science is a rewrite rule specifying a symbol substitution that can be recursively performed to generate new symbol sequences. A finite set of productions Pdisplaystyle PP is the main component in the specification of a formal grammar (specifically a generative grammar). The other components are a finite set Ndisplaystyle NN of nonterminal symbols, a finite set (known as an alphabet) Σdisplaystyle Sigma Sigma of terminal symbols that is disjoint from Ndisplaystyle NN and a distinguished symbol S∈Ndisplaystyle Sin NSin N that is the start symbol.


In an unrestricted grammar, a production is of the form u→vdisplaystyle uto vuto v where udisplaystyle uu and vdisplaystyle vv are arbitrary strings of terminals and nonterminals however udisplaystyle uu may not be the empty string. If vdisplaystyle vv is the empty string, this is denoted by the symbol ϵdisplaystyle epsilon epsilon , or λdisplaystyle lambda lambda (rather than leave the right-hand side blank). So productions are members of the cartesian product



V∗NV∗×V∗=(V∗∖Σ∗)×V∗displaystyle V^*NV^*times V^*=(V^*setminus Sigma ^*)times V^*displaystyle V^*NV^*times V^*=(V^*setminus Sigma ^*)times V^*,

where V:=N∪Σdisplaystyle V:=Ncup Sigma displaystyle V:=Ncup Sigma is the vocabulary, ∗displaystyle ^*^* is the Kleene star operator, V∗NV∗displaystyle V^*NV^*displaystyle V^*NV^* indicates concatenation, and ∪displaystyle cup cup denotes set union. If we do not allow the start symbol to occur in vdisplaystyle vv (the word on the right side), we have to replace V∗displaystyle V^*V^* by (V∖S)∗displaystyle (Vsetminus S)^*displaystyle (Vsetminus S)^* on the right side of the cartesian product symbol.[1]


The other types of formal grammar in the Chomsky hierarchy impose additional restrictions on what constitutes a production. Notably in a context-free grammar, the left-hand side of a production must be a single nonterminal symbol. So productions are of the form:


N→(N∪Σ)∗displaystyle Nto (Ncup Sigma )^*Nto (Ncup Sigma )^*


Grammar generation


To generate a string in the language, one begins with a string consisting of only a single start symbol, and then successively applies the rules (any number of times, in any order) to rewrite this string. This stops when we obtain a string containing only terminals. The language consists of all the strings that can be generated in this manner. Any particular sequence of legal choices taken during this rewriting process yields one particular string in the language. If there are multiple different ways of generating this single string, then the grammar is said to be ambiguous.


For example, assume the alphabet consists of adisplaystyle aa and bdisplaystyle bb, with the start symbol Sdisplaystyle SS, and we have the following rules:


1. S→aSbdisplaystyle Srightarrow aSbSrightarrow aSb

2. S→badisplaystyle Srightarrow baSrightarrow ba

then we start with Sdisplaystyle SS, and can choose a rule to apply to it. If we choose rule 1, we replace Sdisplaystyle SS with aSbdisplaystyle aSbaSb and obtain the string aSbdisplaystyle aSbaSb. If we choose rule 1 again, we replace Sdisplaystyle SS with aSbdisplaystyle aSbaSb and obtain the string aaSbbdisplaystyle aaSbbaaSbb. This process is repeated until we only have symbols from the alphabet (i.e., adisplaystyle aa and bdisplaystyle bb). If we now choose rule 2, we replace Sdisplaystyle SS with badisplaystyle baba and obtain the string aababbdisplaystyle aababbaababb, and are done. We can write this series of choices more briefly, using symbols: S⇒aSb⇒aaSbb⇒aababbdisplaystyle SRightarrow aSbRightarrow aaSbbRightarrow aababbSRightarrow aSbRightarrow aaSbbRightarrow aababb. The language of the grammar is the set of all the strings that can be generated using this process: ba,abab,aababb,aaababbb,…displaystyle ba,abab,aababb,aaababbb,dotsc ba,abab,aababb,aaababbb,dotsc .



See also


  • Formal grammar

  • Finite automata

  • Generative grammar

  • L-system

  • Rewrite rule


  • Backus–Naur form (A compact form for writing the productions of a context-free grammar.)

  • Phrase structure rule


  • Post canonical system (Emil Post's production systems- a model of computation.)


References



  1. ^ See Klaus Reinhardt: Prioritatszahlerautomaten und die Synchronisation von Halbspursprachen; Fakultät Informatik der Universität Stuttgart; 1994 (German)







Popular posts from this blog

California gubernatorial recall election

Telugu cinema

List of Pawn Stars episodes