EDT0L Grammars #
An EDT0L grammar consists of the following data:
- a finite alphabet of terminal letters
T
; - a finite alphabet of nonterminal letters
N
; - an initial nonterminal letter; and
- a finite number of maps of the form
N → List (Symbol T N)
which we refer to as tables. Notice thatSymbol T N
is a type, provided by Mathlib, which corresponds to a disjoint union of the typesT
andN
.
To simplify proofs in this project, we index the tables of the grammar using a finite type H
.
Applying tables #
Suppose we are given some word w : List (Symbol T N)
, then we may apply a table of the form
τ : N → List (Symbol T N)
by replacing each nonterminal in w
with the corresponding word
given by τ
, and leaving all the terminal letters along.
Let E
be an EDT0L grammar. Then, a word w : List T
is then accepted by the grammar if the word
w.map Symbol.terminal
can be reached from the initial word [Symbol.nonterminal E.intial]
by applying a finite sequence of tables. The set of all such words is known as an EDT0L language.
Rewrites a symbol with respect to a given table.
Equations
- E.RewriteSymbol τ (Symbol.terminal t) = [Symbol.terminal t]
- E.RewriteSymbol τ (Symbol.nonterminal n) = E.tables τ n
Instances For
Applies a given table to the given word.
Equations
- E.RewriteWord τ w = List.flatMap (E.RewriteSymbol τ) w
Instances For
A relation which holds if there exists a table which rewrites the word
source
to the word target
.
Equations
- E.Rewrites source target = ∃ (τ : H), E.RewriteWord τ source = target
Instances For
The reflexive transitive closure of EDT0LGrammar.Rewrites
.
Equations
Instances For
The language is EDT0L.
Notice that this definition requries that the language is generated by an EDT0L language
where the set of nonterminals and terminals are of the form Fin n
and Fin m
, respectively,
for some n m : ℕ
. Our main goal in this file is to show that we can assume without loss of
generality that any given EDT0L grammar is of this form. We prove this fact in the theorem
edt0l_grammars_generate_edt0l_languages
, at the end of this file.
Instances For
Defines an equivalent EDT0L grammar.
This structure holds the data needed to construct an EDT0L grammar which can be used in the
proof of edt0l_grammars_generate_edt0l_languages
. We provide this construction as its own
structure as this construction is to be reused when defining EDT0L grammars with finite index
- E : EDT0LGrammar T N H
The grammar for which we want to find an equivalent grammar.
An equivalence relation between nonterminals.
An equivalence relation between tables.
Instances For
An equivalence relation between symbols of terminals and nonterminals.
This equivalence relation is constructed from the equivalence relation between
nonterminals, as stored in the EquivData
structure.
Equations
- One or more equations did not get rendered due to their size.
Instances For
An equivalence relation between words.
This equivalence relation is constructed from the equivalence relation between
nonterminals, as stored in the EquivData
structure.
Equations
- 𝓖.equiv_word = { toFun := List.map ⇑𝓖.equiv_symbol, invFun := List.map ⇑𝓖.equiv_symbol.symm, left_inv := ⋯, right_inv := ⋯ }