The state of a n : NFA
is a natual number
The number of states is n.tr.size
The set of all possible states is {0,1,...,n.tr.size}
,
where 0
is the initial state and n.size
is the accept state
n.tr
represents the transition function
of the NFA
, where Unit
is the ε
transition.
We assume that the accept state does not have any
outward transitions, so it's not recorded in n
.
So, by definition, the accept state has no outcoming edges.
However, the initial state might have incoming edges
- attrs : Array (Std.HashSet String)
Instances For
Equations
- Auto.instToStringNFA = { toString := Auto.NFA.toString }
def
Auto.NFA.εClosureOfStates
{σ : Type}
[BEq σ]
[Hashable σ]
[ToString σ]
(r : NFA σ)
(ss : Std.HashSet Nat)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Auto.NFA.move
{σ : Type}
[BEq σ]
[Hashable σ]
[ToString σ]
(r : NFA σ)
(ss : Std.HashSet Nat)
(c : σ)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Auto.NFA.moves
{σ : Type}
[BEq σ]
[Hashable σ]
[ToString σ]
(r : NFA σ)
(ss : Std.HashSet Nat)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Auto.NFA.moveε
{σ : Type}
[BEq σ]
[Hashable σ]
[ToString σ]
(r : NFA σ)
(ss : Std.HashSet Nat)
(c : σ)
:
Equations
- r.moveε ss c = r.εClosureOfStates (r.move ss c)
Instances For
def
Auto.NFA.moveεMany
{σ : Type}
[BEq σ]
[Hashable σ]
[ToString σ]
(r : NFA σ)
(ss : Std.HashSet Nat)
(cs : Array σ)
:
Equations
- r.moveεMany ss cs = Array.foldl (fun (ss' : Std.HashSet Nat) (c : σ) => r.moveε ss' c) ss cs
Instances For
Equations
- r.run cs = r.moveεMany (r.εClosureOfStates (Std.HashSet.emptyWithCapacity.insert 0)) cs
Instances For
Whether the NFA's initial state has incoming edges
Equations
Instances For
Does not accept any string
Equations
Instances For
Only accepts empty string
Equations
Instances For
Accepts a character
Equations
- Auto.NFA.ofSymb c = { tr := #[Std.HashMap.emptyWithCapacity.insert (Sum.inr c) #[1]], attrs := #[Std.HashSet.emptyWithCapacity, Std.HashSet.emptyWithCapacity] }
Instances For
Equations
Instances For
Equations
- r.repeatBounded n m = if n > m then Auto.NFA.epsilon else (r.repeatN n).comp (r.repeatAtMost (m - n))
Instances For
Accepts all characters in an array of characters
Equations
- Auto.NFA.ofSymbPlus cs = { tr := #[Std.HashMap.ofList (Array.map (fun (c : σ) => (Sum.inr c, #[1])) cs).toList], attrs := #[Std.HashSet.emptyWithCapacity, Std.HashSet.emptyWithCapacity] }
Instances For
- accepts : Std.HashSet Nat
- tr : Array (Std.HashMap σ Nat)
- attrs : Array (Std.HashSet String)
Instances For
Equations
- Auto.instToStringDFA = { toString := Auto.DFA.toString }