Finite automaton inputs on powerset alphabets
Lax503819.Automata · concepts/Lax503819/Automata.lean · lax-503819
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
An input gives the number p of predicates, a finite transition table, and accepting state numbers. Its alphabet is the full powerset of {0,…,p−1}. Letters index columns by their binary masks. The initial state is 0.
A table with s rows uses states 0,…,s. A missing entry returns 0; targets are reduced modulo s+1. This total convention assigns a finite automaton to every input, without a separate promise of well-formedness. Every ordinary DFA can be represented (renumber its initial state to 0 and provide its table). The computability encoding is the standard encoding of natural numbers and lists, explicitly transported to this record.
Concept map
Lean source view on GitHub
| 1 | import Lax503819.PositiveLogic |
| 2 | import Mathlib.Computability.DFA |
| 3 | import Mathlib.Computability.Primrec.List |
| 4 | import Mathlib.Algebra.BigOperators.Group.Finset.Basic |
| 5 | |
| 6 | /-! |
| 7 | --- |
| 8 | title: Finite automaton inputs on powerset alphabets |
| 9 | type: definition |
| 10 | --- |
| 11 | An input gives the number p of predicates, a finite transition table, and |
| 12 | accepting state numbers. Its alphabet is the full powerset of {0,…,p−1}. |
| 13 | Letters index columns by their binary masks. The initial state is 0. |
| 14 | |
| 15 | A table with s rows uses states 0,…,s. A missing entry returns 0; targets are |
| 16 | reduced modulo s+1. This total convention assigns a finite automaton to every |
| 17 | input, without a separate promise of well-formedness. Every ordinary DFA can |
| 18 | be represented (renumber its initial state to 0 and provide its table). |
| 19 | The computability encoding is the standard encoding of natural numbers and |
| 20 | lists, explicitly transported to this record. |
| 21 | -/ |
| 22 | |
| 23 | namespace Lax503819.Automata |
| 24 | |
| 25 | structure Input where |
| 26 | predicates : ℕ |
| 27 | transitions : List (List ℕ) |
| 28 | accepting : List ℕ |
| 29 | |
| 30 | instance : Primcodable Input := |
| 31 | Primcodable.ofEquiv (ℕ × List (List ℕ) × List ℕ) |
| 32 | { toFun := fun d => (d.predicates, d.transitions, d.accepting) |
| 33 | invFun := fun (p, t, f) => ⟨p, t, f⟩ |
| 34 | left_inv := fun _ => rfl |
| 35 | right_inv := fun _ => rfl } |
| 36 | |
| 37 | abbrev Alphabet (d : Input) := Finset (Fin d.predicates) |
| 38 | |
| 39 | /-- Binary column number of a subset of predicates. -/ |
| 40 | def letterMask {p : ℕ} (a : Finset (Fin p)) : ℕ := |
| 41 | a.sum (fun i => 2 ^ i.val) |
| 42 | |
| 43 | def Input.automaton (d : Input) : DFA (Alphabet d) (Fin (d.transitions.length + 1)) where |
| 44 | step q a := Fin.ofNat (d.transitions.length + 1) |
| 45 | ((d.transitions.getD q.val []).getD (letterMask a) 0) |
| 46 | start := 0 |
| 47 | accept := {q | q.val ∈ d.accepting} |
| 48 | |
| 49 | def Input.language (d : Input) : Language (Alphabet d) := d.automaton.accepts |
| 50 | |
| 51 | def PositiveDefinable (d : Input) : Prop := |
| 52 | Lax503819.PositiveLogic.Definable d.language |
| 53 | |
| 54 | end Lax503819.Automata |
| 55 |
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments