Extra lemmas about context-free grammars #
Additions to Mathlib.Computability.ContextFreeGrammar from the authors'
in-review Mathlib branch (alex-loitzl-cnf) that are not yet available in the
Mathlib release pinned here: the step-counting derivation relation
ContextFreeGrammar.DerivesIn with its induction principles and splitting
lemmas, plus a few facts about ContextFreeGrammar.Produces.
Alternative definition of ContextFreeGrammar.Derives which allows to use well-founded
induction on derivations, by explicitely counting the number of steps of the transformation
Given a context-free grammar g, strings u and v, and number n
g.DerivesIn u v n means that g can transform u to v in n rewriting steps.
- refl
{T : Type uT}
{g : ContextFreeGrammar T}
(w : List (Symbol T g.NT))
: g.DerivesIn w w 0
0 steps entail no transformation
- tail
{T : Type uT}
{g : ContextFreeGrammar T}
(u v w : List (Symbol T g.NT))
(n : ℕ)
: g.DerivesIn u v n → g.Produces v w → g.DerivesIn u w n.succ
n + 1 steps, if transforms
utovin n steps, andvtowin 1 step