Formalisation of Lecture 3: Covers the definition of DFAs and total DFAs, the corresponding languages and how to obtain a total DFA from a non-total DFA. Grammars are (for now) not part of this formalisation, so in lecture 3 and 4 all things related to grammars and the Chomsky Hierarchy is left out.
Slides for lecture 3 can be found at https://iccl.inf.tu-dresden.de/w/images/e/e2/FS2025-Vorlesung-03-print.pdf
We define a DFA as a generic structure with two type parameters Q and Sigma. Definitions in the lecture and textbooks usually define Q and Sigma as finite sets. We already know from lecture 1 that it is sufficient to define Sigma as an arbitrary type. The states however need to be finite, otherwise it would not be a finite automaton. Therefore we require an instance of Fintype for Q. For further information on Fintype please refer to the corresponding file.
δ is a function mapping a state of type Q and a symbol of type Sigma to something of type Option Q. This is how we "encode" that δ is a partial function: if δ(q,a) = None, it is undefined.
Instances For
The transition function δ of a DFA can be extended to words.
- w = ε: δ_word(q,ε) = q
- w = av (a ∈ Σ, v ∈ Σ*): δ_word(q,av) = δ_word(δ(q,a),v) In case any of the transitions is undefined, δ_word is undefined as well (which is expressed with bind).
Equations
Instances For
The transition function δ of a total DFA can be extended to words.
- w = ε: δ_word(q,ε) = q
- w = av (a ∈ Σ, v ∈ Σ*): δ_word(q,av) = δ_word(δ(q,a),v) Contrary to the DFA this function is defined for any pair (q,w) since δ is total.
Instances For
Given a total DFA, a word w is contained in its language iff the DFA ends up in a final state when reading w.
Instances For
Given a DFA, a word w is contained in its language iff δ_word(q0,w) is defined and the DFA ends up in a final state when reading w.
Instances For
A function turning a DFA into a total DFA.
At first glance this might look very different from the lecture where we explicitly introduced a "garbage state". We change the type of Q to (Option Q) and just keep all the transitions. Since Q is an arbitrary type this results in a total DFA with states of type (Option Q). "none" is now a valid state that is reached whenever the original DFA had an undefined transition. It behaves exactly like the the garbage state from which there is no way out.
Equations
Instances For
A total DFA can (obviously) be converted to a DFA. The only thing that changes is the type of δ. Since δ is defined for every possible input (q,a) we can just wrap the value of δ with some to obtain an Option Q.