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 DFAMLanguage.IsRegular L: a predicate stating thatLis 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 (and have the overall string still be accepted)
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
evalis rewritten toevalFromautomatically? - Should
mem_acceptsandmem_acceptsFrombe 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.