Draft — mutable and not usable as a dependency; its citation marks the draft state.

Lax132576.TransducerCodes

Codes of automata with output, and decidability under a promise

concepts/Lax132576/TransducerCodes.lean · lax-132576

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.

    Concept map

    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    In the paper

    Definition

    The decidability statements of the book are about algorithms whose inputs are automata. An automaton with output whose states and letters are natural numbers is described by a finite code: the list of its transitions (p,u,v,q)(p, u, v, q) — from state pp to state qq, reading uu and writing vv — and the lists of its initial and final states. A code mentions only finitely many letters, its alphabet; a string over that alphabet is a code word. A code is functional if the relation it describes is a total function on the code words: every code word has exactly one output.

    A problem "given an automaton satisfying a promise, decide whether it has a property" is decidable if there is a computable Boolean-valued function on codes that answers correctly on every code satisfying the promise. This is the form of Theorems B.3.4, B.4.2 and Lemma B.4.3 (and of Theorem C.1.4 in Part C).

    Lean source view on GitHub

    1import Mathlib.Computability.Halting
    2import Lax132576.RationalRelations
    3
    4/-!
    5---
    6title: Codes of automata with output, and decidability under a promise
    7type: definition
    8---
    9The decidability statements of the book are about algorithms whose inputs are
    10automata. An automaton with output whose states and letters are natural numbers
    11is described by a finite *code*: the list of its transitions (p,u,v,q)(p, u, v, q)
    12from state pp to state qq, reading uu and writing vv — and the lists of its
    13initial and final states. A code mentions only finitely many letters, its
    14*alphabet*; a string over that alphabet is a *code word*. A code is
    15*functional* if the relation it describes is a total function on the code words:
    16every code word has exactly one output.
    17
    18A problem "given an automaton satisfying a promise, decide whether it has a
    19property" is decidable if there is a computable Boolean-valued function on
    20codes that answers correctly on every code satisfying the promise. This is the
    21form of Theorems B.3.4, B.4.2 and Lemma B.4.3 (and of Theorem C.1.4 in Part C).
    22
    23# Formalization notes
    24
    25`RelCode` is a structure with the three lists as named fields; it is
    26`Primcodable` through the evident bijection with a tuple, so that
    27computability of functions on codes is mathlib's `Computable`. `codeAut c` is
    28the automaton with output over the alphabet `ℕ` that the code describes, and
    29`codeRel c` its relation. Totality over *all* of `ℕ*` cannot be asked for — a
    30code reads only the letters of its alphabet, so no code describes a total
    31function on `ℕ*` — which is why the promise `CodeFunctional` and the decided
    32properties are relativised to the code words; `DecidableUnderPromise promise P`
    33is the existence of a computable decision procedure correct under the promise.
    34-/
    35
    36namespace Lax132576.TransducerCodes
    37
    38open Lax132576.LabelledAutomata Lax132576.RationalRelations
    39
    40/-- A code of an automaton with output over the alphabet `ℕ` with states in `ℕ`:
    41its transitions `(p, u, v, q)` and its initial and final states. -/
    42structure RelCode where
    43 /-- The transitions `(p, u, v, q)`: from `p` to `q`, reading `u`, writing `v`. -/
    44 transitions : List (ℕ × List ℕ × List ℕ × ℕ)
    45 /-- The initial states. -/
    46 init : List ℕ
    47 /-- The final states. -/
    48 final : List ℕ
    49
    50/-- A code is the tuple of its three lists. -/
    51def relCodeEquiv : RelCode ≃ List (ℕ × List ℕ × List ℕ × ℕ) × List ℕ × List ℕ where
    52 toFun c := (c.transitions, c.init, c.final)
    53 invFun x := ⟨x.1, x.2.1, x.2.2
    54 left_inv := by rintro ⟨t, i, f⟩; rfl
    55 right_inv := by rintro ⟨t, i, f⟩; rfl
    56
    57instance : Primcodable RelCode := Primcodable.ofEquiv _ relCodeEquiv
    58
    59/-- The automaton with output described by a code. -/
    60def codeAut (c : RelCode) : NFAO ℕ ℕ ℕ where
    61 init := {q | q ∈ c.init}
    62 final := {q | q ∈ c.final}
    63 δ := {t | t ∈ c.transitions}
    64 δ_finite := c.transitions.finite_toSet
    65
    66/-- The rational relation described by a code. -/
    67def codeRel (c : RelCode) : List ℕ → List ℕ → Prop := (codeAut c).rel
    68
    69/-- The alphabet of a code: the letters occurring in the input strings of its
    70transitions. -/
    71def codeAlphabet (c : RelCode) : List ℕ := c.transitions.flatMap (fun t => t.2.1)
    72
    73/-- A string over the alphabet of the code. -/
    74def CodeWord (c : RelCode) (w : List ℕ) : Prop := ∀ x ∈ w, x ∈ codeAlphabet c
    75
    76/-- The relation described by the code is a total function on the code words. -/
    77def CodeFunctional (c : RelCode) : Prop := ∀ w, CodeWord c w → ∃! v, codeRel c w v
    78
    79/-- A property `P` is decidable under a promise if a computable Boolean-valued
    80function answers `P` correctly on every input satisfying the promise. -/
    81def DecidableUnderPromise {α : Type} [Primcodable α] (promise P : α → Prop) : Prop :=
    82 ∃ D : α → Bool, Computable D ∧ ∀ a, promise a → (D a = true ↔ P a)
    83
    84end Lax132576.TransducerCodes
    85

    Formalization notes

    RelCodeRelCode is a structure with the three lists as named fields; it is PrimcodablePrimcodable through the evident bijection with a tuple, so that computability of functions on codes is mathlib's ComputableComputable. codeAutccodeAut c is the automaton with output over the alphabet N that the code describes, and codeRelccodeRel c its relation. Totality over all of Nℕ* cannot be asked for — a code reads only the letters of its alphabet, so no code describes a total function on Nℕ* — which is why the promise CodeFunctionalCodeFunctional and the decided properties are relativised to the code words; DecidableUnderPromisepromisePDecidableUnderPromise promise P is the existence of a computable decision procedure correct under the promise.

    Community review

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.

    0 comments

    Loading discussion…