Finite automaton inputs on powerset alphabets

Lax503819.Automata · concepts/Lax503819/Automata.lean · lax-503819

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural 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
    3 concepts; 2 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Lax503819.PositiveLogic
    2import Mathlib.Computability.DFA
    3import Mathlib.Computability.Primrec.List
    4import Mathlib.Algebra.BigOperators.Group.Finset.Basic
    5
    6/-!
    7---
    8title: Finite automaton inputs on powerset alphabets
    9type: definition
    10---
    11An input gives the number p of predicates, a finite transition table, and
    12accepting state numbers. Its alphabet is the full powerset of {0,…,p−1}.
    13Letters index columns by their binary masks. The initial state is 0.
    14
    15A table with s rows uses states 0,…,s. A missing entry returns 0; targets are
    16reduced modulo s+1. This total convention assigns a finite automaton to every
    17input, without a separate promise of well-formedness. Every ordinary DFA can
    18be represented (renumber its initial state to 0 and provide its table).
    19The computability encoding is the standard encoding of natural numbers and
    20lists, explicitly transported to this record.
    21-/
    22
    23namespace Lax503819.Automata
    24
    25structure Input where
    26 predicates : ℕ
    27 transitions : List (List ℕ)
    28 accepting : List ℕ
    29
    30instance : 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
    37abbrev Alphabet (d : Input) := Finset (Fin d.predicates)
    38
    39/-- Binary column number of a subset of predicates. -/
    40def letterMask {p : ℕ} (a : Finset (Fin p)) : ℕ :=
    41 a.sum (fun i => 2 ^ i.val)
    42
    43def 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
    49def Input.language (d : Input) : Language (Alphabet d) := d.automaton.accepts
    50
    51def PositiveDefinable (d : Input) : Prop :=
    52 Lax503819.PositiveLogic.Definable d.language
    53
    54end Lax503819.Automata
    55

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…