Aho's finite compression of index strings #
This file contains the grammar-facing part of Aho's linear-space simulation of an indexed grammar. A stack-neutral derivation is saturated into the four normal-form rule shapes, and a possibly long string of flags is represented by the finite binary relation it induces on nonterminals when it is consumed.
The actual marked-derivation machine and its linear tape bound are deliberately kept separate. The declarations here only expose finite symbols and semantic lemmas that such a machine can use.
Reference #
- A. V. Aho, "Indexed grammars -- an extension of context-free grammars", JACM 15(4), Section 5, 1968.
Concrete normal-form rule predicates #
A concrete binary rule A -> B C.
Equations
Instances For
Stack-neutral saturation #
Neutral g A B means that A can become B while starting and ending with an empty
stack and without leaving any other sentential symbols behind. In normal form such a derivation
can only consist of balanced flag pushes and pops; the semantic definition is more convenient for
the saturation lemmas below.
Equations
Instances For
A neutral derivation is parametric in an arbitrary inherited stack suffix.
Aho's augmented rule predicates #
Rather than materializing an equivalent augmented grammar, we use its rules as finite semantic predicates. Ordinary terminal, binary, and push rules are precomposed with neutral closure. A pop edge is saturated on both sides: a neutral prefix may expose the concrete pop, and a neutral suffix may follow it. The prefix saturation is essential when a balanced push/pop segment lies between a productive event and the next inherited flag consumption.
An augmented terminal edge: A =>* B -> a, with the first part stack-neutral.
Equations
- IndexedGrammar.Aho.AugTerminal g A a = ∃ (B : g.nt), IndexedGrammar.Aho.Neutral g A B ∧ IndexedGrammar.Aho.TerminalRule g B a
Instances For
An augmented binary edge: A =>* D -> B C, with the first part stack-neutral.
Equations
- IndexedGrammar.Aho.AugBinary g A B C = ∃ (D : g.nt), IndexedGrammar.Aho.Neutral g A D ∧ IndexedGrammar.Aho.BinaryRule g D B C
Instances For
An augmented push edge: A =>* C -> B f, with the first part stack-neutral.
Equations
- IndexedGrammar.Aho.AugPush g A B f = ∃ (C : g.nt), IndexedGrammar.Aho.Neutral g A C ∧ IndexedGrammar.Aho.PushRule g C B f
Instances For
The relation induced by consuming one augmented flag: take a neutral prefix, pop f, then
take a neutral suffix. The flag argument comes first because AugPop g f is used as a binary
relation.
Equations
- IndexedGrammar.Aho.AugPop g f A B = ∃ (D : g.nt) (C : g.nt), IndexedGrammar.Aho.Neutral g A D ∧ IndexedGrammar.Aho.PopRule g D f C ∧ IndexedGrammar.Aho.Neutral g C B
Instances For
Ordinary rules embed into the augmented predicates #
One-rule semantic facts #
Soundness of augmented edges #
Finite compressed flags #
A compressed flag is the Boolean adjacency matrix of the relation it induces on nonterminals. For a finite nonterminal type this is itself a finite type, independently of the number or length of concrete flag strings represented by it.
Equations
- IndexedGrammar.Aho.CFlag g = (g.nt → g.nt → Bool)
Instances For
The compressed relation denoted by one concrete flag, including Aho's neutral post-saturation of a pop edge.
Equations
- IndexedGrammar.Aho.cflagBase g f A B = decide (IndexedGrammar.Aho.AugPop g f A B)
Instances For
Relational composition of two compressed flags. If the concrete stack begins with the
first flag and then the second, it is denoted by cflagComp first second.
Equations
Instances For
Extensionality specialized to compressed flags.
A base compressed edge is exactly an augmented one-flag pop edge.
Provenance for a compressed relation. Denotes g flags R records that R was built from
the concrete, top-first flag string flags by Aho's base relation and relational composition.
It is useful as a soundness invariant for a machine whose finite alphabet contains every Boolean
relation, but whose reachable compressed symbols arise only through cflagBase and
cflagComp.
- base {T : Type} {g : IndexedGrammar T} [Fintype g.nt] (f : g.flag) : Denotes g [f] (cflagBase g f)
- comp {T : Type} {g : IndexedGrammar T} [Fintype g.nt] {fs gs : List g.flag} {R S : CFlag g} (hR : Denotes g fs R) (hS : Denotes g gs S) : Denotes g (fs ++ gs) (cflagComp g R S)
Instances For
Every edge of a denoted compressed relation is sound for consuming the represented concrete flag string above any inherited stack suffix.