Leftmost Deriviations in Context-Free Gammars #
This file contains the definition of a leftmost deriviation. These are deriviations where in each rewriting step the leftmost nonterminal is replaced
Main Definitions #
ContextFreeRule.RewritesLeftmost: Leftmost counterpart toContextFreeRule.RewritesContextFreeGrammar.ProducesLeftmost: Leftmost counterpart toContextFreeRule.ProducesContextFreeGrammar.DerivesLeftmost: Leftmost counterpart toContextFreeRule.Derives
Main Result #
ContextFreeGrammar.derives_leftmost_iff: A string of terminals can be derived from a string of symbols iff it can be leftmost derived.
- head
{T : Type uT}
{N : Type uN}
{r : ContextFreeRule T N}
(s : List (Symbol T N))
: r.RewritesLeftmost (Symbol.nonterminal r.input :: s) (r.output ++ s)
The replaced nonterminal is the leftmost symbol
- cons
{T : Type uT}
{N : Type uN}
{r : ContextFreeRule T N}
(x : T)
{s₁ s₂ : List (Symbol T N)}
(hrs : r.RewritesLeftmost s₁ s₂)
: r.RewritesLeftmost (Symbol.terminal x :: s₁) (Symbol.terminal x :: s₂)
There are terminals further left than the replaced symbol
Instances For
Given a context-free grammar g and strings u and v
g.ProducesLeftmost u v means that one application of a rule from g to the leftmost nonterminal
of u send u to v.
Equations
- g.ProducesLeftmost u v = ∃ r ∈ g.rules, r.RewritesLeftmost u v
Instances For
Given a context-free grammar g and strings u and v
g.DerivesLeftmost u v means that g can transform u to v in some number of rewriting steps,
by applying the transformation always to the leftmost symbol of u.
Equations
Instances For
Add extra prefix to context-free leftmost producing.
Add extra postfix to context-free leftmost producing.
Add extra prefix to context-free leftmost deriving.
Add extra postfix to context-free leftmost deriving.