What do you mean by grammar and production in TOC?

Let us understand the concept of grammar in the theory of computation (TOC).

Introduction to Grammar

A language over an alphabet ∑ is a set of strings from ∑.

Grammar is a set of rules used to define a language. In short, it is the structure of the strings in the language.

To describe a grammar for a language, two collections of alphabets (symbols) are necessary. These are explained below −

  • Terminals are those symbols from which all strings in the language are made – symbols of a ‘given’ alphabet for a generated language. These are usually the lower case letters.

  • Non-terminal are ‘temporary’ symbols (disjoint from terminals) used to define the grammar replacement rules (in the production rules). These must all be replaced by terminals before the production can successfully make a valid string of the language. These are usually upper case letters.


Furthermore, a grammar for a language L (over an alphabet ∑) consists of a set of grammar rules (productions) of the following form −

α → β,

Where α, β are strings of symbols taken from the set of terminals (∑) and non-terminals.

A grammar rule α → β can be read in any of several ways mentioned below −

  • “replace α by β”,

  • “α produces β”,

  • “α rewrites to β” ,

  • “α reduces to β”.

Formal definition of grammar

Consider an example given below −

If ∑ = {a, b} and S is a non-terminal symbol then the rules S → aS, S → ∧ are examples of productions for a grammar L.

Now we are ready for the formal definition of a grammar, which is as follows −

  • An alphabet T of symbols called terminals. These are identical to the alphabet of the resulting language.

  • An alphabet N of grammar symbols is called non-terminals and is used in the production rules.

  • A specific non-terminal called the start symbol. It is usually S.

  • A finite set of productions of the form α → β, where α and β are strings over the alphabet N ∪ T.

Updated on: 15-Jun-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started