Langlib

Langlib.Classes.LR.Examples.AnBn

a^n b^n as an LR Language #

This file proves that the context-free grammar cfg_anbn for {a^n b^n} is LR(0), and hence that the language is LR.

Main results #

Rightmost sentential forms of cfg_anbn #

The grammar cfg_anbn has rules S → aSb and S → ε with a single nonterminal (). Every sentential form has at most one nonterminal, so every derivation step is automatically rightmost. The reachable rightmost forms are exactly aⁿ S bⁿ and aⁿ bⁿ.

The grammar cfg_anbn is LR(0).

The language {aⁿbⁿ} is generated by an LR(0) grammar.

The language {aⁿbⁿ} is an LR language.