Epsilon Nondeterministic Finite Automata #
This file contains the definition of an epsilon Nondeterministic Finite Automaton (εNFA), a state
machine which determines whether a string (implemented as a list over an arbitrary alphabet) is in a
regular set by evaluating the string over every possible path, also having access to ε-transitions,
which can be followed without reading a character.
Since this definition allows for automata with infinite states, a Fintype instance must be
supplied for true εNFA's.
An εNFA 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).
Note the transition function sends a state to a Set of states and can make ε-transitions by
inputing none.
Since this definition allows for Automata with infinite states, a Fintype instance must be
supplied for true εNFA's.
Instances For
The εClosure of a set is the set of states which can be reached by taking a finite string of
ε-transitions from an element of the set.
- base: ∀ {α : Type u} {σ : Type v} {M : εNFA α σ} {S : Set σ}, ∀ s ∈ S, εNFA.εClosure M S s
- step: ∀ {α : Type u} {σ : Type v} {M : εNFA α σ} {S : Set σ} (s t : σ), t ∈ M.step s none → εNFA.εClosure M S s → εNFA.εClosure M S t
Instances For
M.stepSet S a is the union of the ε-closure of M.step s a for all s ∈ S.
Equations
- εNFA.stepSet M S a = ⋃ s ∈ S, εNFA.εClosure M (M.step s (some a))
Instances For
M.evalFrom S x computes all possible paths through M with input x starting at an element
of S.
Equations
- εNFA.evalFrom M start = List.foldl (εNFA.stepSet M) (εNFA.εClosure M start)
Instances For
M.toNFA is an NFA constructed from an εNFA M.
Equations
- εNFA.toNFA M = { step := fun (S : σ) (a : α) => εNFA.εClosure M (M.step S (some a)), start := εNFA.εClosure M M.start, accept := M.accept }
Instances For
M.toεNFA is an εNFA constructed from an NFA M by using the same start and accept
states and transition functions.
Equations
- NFA.toεNFA M = { step := fun (s : σ) (a : Option α) => Option.casesOn' a ∅ fun (a : α) => M.step s a, start := M.start, accept := M.accept }