Deterministic Finite Automata #
A Deterministic Finite Automaton (DFA) is a state machine which
decides membership in a particular Language
, by following a path
uniquely determined by an input string.
We define regular languages to be ones for which a DFA exists, other formulations are later proved equivalent.
Note that this definition allows for automata with infinite states,
a Fintype
instance must be supplied for true DFAs.
Main definitions #
DFA α σ
: automaton over alphabetα
and set of statesσ
M.accepts
: the language accepted by the DFAM
Language.IsRegular L
: a predicate stating thatL
is a regular language, i.e. there exists a DFA that recognizes the language
Main theorems #
DFA.pumping_lemma
: every sufficiently long string accepted by the DFA has a substring that can be repeated arbitrarily many times
Implementation notes #
Currently, there are two disjoint sets of simp lemmas: one for DFA.eval
, and another for
DFA.evalFrom
. You can switch from the former to the latter using simp [eval]
.
TODO #
- Should we unify these simp sets, such that
eval
is rewritten toevalFrom
automatically? - Should
mem_accepts
andmem_acceptsFrom
be marked@[simp]
?
A DFA is a set of states (σ
), a transition function from state to state labelled by the
alphabet (step
), a starting state (start
) and a set of acceptance states (accept
).
- step : σ → α → σ
A transition function from state to state labelled by the alphabet.
- start : σ
Starting state.
- accept : Set σ
Set of acceptance states.
Instances For
M.comap f
pulls back the alphabet of M
along f
. In other words, it applies f
to the input
before passing it to M
.
Equations
Instances For
A language is regular if and only if it is defined by a DFA with finite states.
This is more general than using the definition of Language.IsRegular
directly, as the state type
σ
is universe-polymorphic.