Context-free Grammars and Derivations

Learn about context-free grammar and look at some examples.

We'll cover the following

Let’s formally define context-free grammar (CFG).

Context-free grammar

A context-free grammar is a formal grammar consisting of the following:

Let’s look at some illustrations of CFGs for some of the languages.

Examples of CFGs

The following CFG generates the language < a n b n ∣ n >0 > \0\> < a n b n ∣ n >0 > :