-
Notifications
You must be signed in to change notification settings - Fork 0
Grammar Transformations
AutomataLab features an automated mathematical engine capable of transforming your Context-Free Grammars into standardized Normal Forms.
You can access these transformations by clicking the Tools menu above the Grammar Diagnostics panel. When you apply a transformation, AutomataLab overwrites the current grammar editor with the new syntactically equivalent grammar.
A grammar is in Chomsky Normal Form if every production rule is of the exact form:
-
$A \rightarrow BC$ (Two non-terminals) -
$A \rightarrow a$ (A single terminal) -
$S \rightarrow \epsilon$ (Only if the start symbol$S$ derives epsilon and does not appear on the RHS of any rule).
When you click Convert to CNF, AutomataLab runs the classic 5-step conversion algorithm natively:
-
START: Eliminate the start symbol from right-hand sides by introducing a new start symbol
$S_0 \rightarrow S$ . -
TERM: Eliminate rules with mixed terminals and non-terminals (e.g.,
$A \rightarrow B c$ becomes$A \rightarrow B T_c$ and$T_c \rightarrow c$ ). -
BIN: Eliminate rules with more than 2 non-terminals (e.g.,
$A \rightarrow BCD$ becomes$A \rightarrow B X_1$ and$X_1 \rightarrow CD$ ). -
DEL: Eliminate
$\epsilon$ -rules (null productions) by distributing them across the grammar. -
UNIT: Eliminate unit rules (e.g.,
$A \rightarrow B$ ) by substituting the RHS of$B$ directly into$A$ .
The primary reason to convert a grammar to CNF in AutomataLab is to use the CYK Parser. The CYK dynamic programming algorithm is strictly built around the binary branching structure of CNF. If you try to run the CYK parser on a non-CNF grammar, AutomataLab will throw an error and prompt you to convert it.
(Advanced) A grammar is in Greibach Normal Form if every production rule's right-hand side begins with exactly one terminal symbol, followed by zero or more non-terminals:
GNF is highly useful for theoretical proofs. Specifically, it proves that any Context-Free Language can be parsed by a Pushdown Automaton (PDA) without any
While AutomataLab provides GNF conversion as an educational tool, none of the specific Parsers in the Parser Studio require GNF to function.
AutomataLab v4.1.0 · Repository · Download · Web app · MIT License
Getting Started
Machine Workspace
- Workspace Overview
- Finite Automata
- Pushdown Automata
- Turing Machines & LBA
- Transition Table & Data Tools
Grammar Lab
Parser Studio
Project & Architecture