- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

A context free grammar (CFG) is a forma grammar which is used to generate all possible patterns of strings in a given formal language.

It is defined as four tuples −

G=(V,T,P,S)

Where,

- G is a grammar, which consists of a set of production rules. It is used to generate the strings of a language.
- T is the final set of terminal symbols. It is denoted by lower case letters.
- V is the final set of non-terminal symbols. It is denoted by capital letters
- P is a set of production rules, which is used for replacing non-terminal symbols (on the left side of production) in a string with other terminals (on the right side of production).
- S is the start symbol used to derive the string

All grammars are not always optimized, which means the grammar may consist of some extra symbols(non-terminals) which increase the length of grammar.

So, we have to reduce the grammar by removing useless symbols.

The properties to reduce the grammar are as follows −

- Each non-terminal and terminal of G appears in the derivation of some word in L.
- There should not be any production as X->Y where X and Y are non-terminals.
- If epsilon is not in language L then there need not be in the production X-> ε.

The uses of reducing the grammar are explained below −

- Related Questions & Answers
- Explain removing unit productions in context free grammar
- What is context free grammar? Explain with examples
- Explain about CYK Algorithm for Context Free Grammar
- Explain the concept of grammar in TOC
- Convert the given Context free grammar to CNF
- How to generate the language for context free grammar?
- Explain Type-0 grammar in TOC
- Explain Type-1 grammar in TOC
- Generate a CNF for a given context free grammar
- Explain the relationship between grammar and language in TOC
- Explain the context free language closure under concatenation?
- How to convert context free grammar to push down automata?
- Explain about left linear regular grammar in TOC
- Explain Operator grammar and precedence parser in TOC
- Explain Pumping lemma for context free language

Advertisements