Languages #
This file contains the definition and operations on formal languages over an alphabet. Note that "strings" are implemented as lists over the alphabet.
Union and concatenation define a Kleene algebra over the languages.
In addition to that, we define a reversal of a language and prove that it behaves well with respect to other language operations.
Notation #
l + m
: union of languagesl
andm
l * m
: language of stringsx ++ y
such thatx ∈ l
andy ∈ m
l ^ n
: language of strings consisting ofn
members ofl
concatenated together1
: language consisting of only the empty string. This is because it is the unit of the*
operator.l∗
: Kleene's star – language of strings consisting of arbitrarily many members ofl
concatenated together (Note that this is the Unicode asterisk∗
, and not the more common star*
)
Main definitions #
Language α
: a set of strings over the alphabetα
l.map f
: transform a languagel
overα
into a language overβ
by translating throughf : α → β
Main theorems #
Language.self_eq_mul_add_iff
: Arden's lemma – if a languagel
satisfies the equationl = m * l + n
, andm
doesn't contain the empty string, thenl
is the languagem∗ * n
Equations
Equations
Zero language has no elements.
Equations
The sum of two languages is their union.
Equations
The product of two languages l
and m
is the language made of the strings x ++ y
where
x ∈ l
and y ∈ m
.
Equations
The Kleene star of a language L
is the set of all strings which can be written by
concatenating strings from L
.
Equations
Alias of Language.notMem_zero
.
Symbols for use by all kinds of grammars.
- terminal
{T : Type u_4}
{N : Type u_5}
(t : T)
: Symbol T N
Terminal symbols (of the same type as the language)
- nonterminal
{T : Type u_4}
{N : Type u_5}
(n : N)
: Symbol T N
Nonterminal symbols (must not be present when the word being generated is finalized)