Finite nonterminal and flag support for indexed grammars #
Indexed grammars store their rules in a finite list. Even if the ambient nonterminal and flag types are infinite, every derivation from the initial symbol only uses nonterminals and flags mentioned by the initial symbol or by the rules. This file restricts an indexed grammar to those finite supports while preserving its language.
Syntactic supports #
Nonterminals mentioned by a right-hand-side symbol.
Equations
Instances For
Nonterminals mentioned by a rule, including its left-hand side.
Equations
Instances For
Flags mentioned by a right-hand-side symbol as pushed flags.
Equations
Instances For
Flags mentioned by a rule, including consumed and pushed flags.
Equations
Instances For
The finite set of nonterminals used by an indexed grammar.
Equations
Instances For
The finite set of flags used by an indexed grammar.
Equations
Instances For
Restricted grammar #
Equations
Equations
Equations
- g.restrictPush r hr none hs_2 = none
- g.restrictPush r hr (some f) hs_2 = some ⟨f, ⋯⟩
Instances For
Equations
- g.restrictRhsSymbol r hr (IRhsSymbol.terminal t) hs_2 = IRhsSymbol.terminal t
- g.restrictRhsSymbol r hr (IRhsSymbol.nonterminal n push) hs_2 = IRhsSymbol.nonterminal ⟨n, ⋯⟩ (g.restrictPush r hr push hs_2)
Instances For
Equations
- g.restrictRhs r hr = List.map (fun (s : { x : IRhsSymbol T g.nt g.flag // x ∈ r.rhs }) => g.restrictRhsSymbol r hr ↑s ⋯) r.rhs.attach
Instances For
Equations
- g.restrictRule r hr = { lhs := ⟨r.lhs, ⋯⟩, consume := g.restrictConsume r hr, rhs := g.restrictRhs r hr }
Instances For
The indexed grammar restricted to the finite nonterminal and flag supports used by g.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Embedding restricted syntax back into g #
Equations
Instances For
Equations
- g.embedRhsSymbol (IRhsSymbol.terminal t) = IRhsSymbol.terminal t
- g.embedRhsSymbol (IRhsSymbol.nonterminal n push) = IRhsSymbol.nonterminal (↑n) (Option.map Subtype.val push)
Instances For
Equations
Instances For
Finite-support sentential forms #
Equations
- g.stackSupported σ = ∀ f ∈ σ, f ∈ g.usedFlags
Instances For
Equations
- g.symSupported (IndexedGrammar.ISym.terminal a) = True
- g.symSupported (IndexedGrammar.ISym.indexed n σ) = (n ∈ g.usedNTs ∧ g.stackSupported σ)
Instances For
Equations
- g.sententialSupported w = ∀ s ∈ w, g.symSupported s
Instances For
Restricting supported sentential forms #
Equations
- g.restrictISym (IndexedGrammar.ISym.terminal t) hs_2 = IndexedGrammar.ISym.terminal t
- g.restrictISym (IndexedGrammar.ISym.indexed n σ) hs_2 = IndexedGrammar.ISym.indexed ⟨n, ⋯⟩ (g.restrictStack σ ⋯)
Instances For
Equations
Instances For
Derivation correspondence #
Language equality #
Every indexed grammar has an equivalent grammar whose nonterminal and flag types are finite.