- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Production
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.
- Related Articles
- What do you mean by ambiguity in grammar in TOC?
- What do you mean by shrubs and herbs?
- What do you mean by measurement and motion?
- What do you mean by wear and tear?
- What do you mean by interfaces and services?
- What do you mean by Salmon?
- What do you mean by transpose?
- What do you mean by machine?
- What do you mean by cartilage?
- What do you mean by Mode?
- What do you mean by Silk?
- What do you mean by Sex?
- What do you mean by Virtual ?
- What do you mean by Adaptation?
- What do you mean by thermometer?
