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

Lax765601.ElementaryProperties

Prefix preservation and length preservation

concepts/Lax765601/ElementaryProperties.lean · lax-765601

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

    Three elementary properties of a string-to-string function f:ABf : A^* \to B^* that the characterisation theorems of the book are stated with.

    • ff is prefix preserving if wvw \sqsubseteq v implies f(w)f(v)f(w) \sqsubseteq f(v), where \sqsubseteq is the prefix order on strings.
    • ff is length preserving, or letter-to-letter, if f(w)=w|f(w)| = |w| for every input string ww.
    • ff is prefix determined if the first nn output letters depend only on the first nn input letters: input strings that agree on their first nn letters have outputs that agree on their first nn letters.

    For a letter-to-letter function, being prefix determined says exactly that the nn-th output letter depends only on the first nn input letters, which is condition (3) of the Myhill–Nerode lemma for Mealy machines (Lemma A.2.10), and it is the determinism condition of Theorem B.2.7; prefix preservation and length preservation together are the shape of the machine-independent characterisation of Mealy machines (Theorem B.4.1).

    Lean source view on GitHub

    1import Mathlib.Data.List.Infix
    2
    3/-!
    4---
    5title: Prefix preservation and length preservation
    6type: definition
    7---
    8Three elementary properties of a string-to-string function f:ABf : A^* \to B^* that
    9the characterisation theorems of the book are stated with.
    10
    11* ff is *prefix preserving* if wvw \sqsubseteq v implies f(w)f(v)f(w) \sqsubseteq f(v),
    12 where \sqsubseteq is the prefix order on strings.
    13* ff is *length preserving*, or *letter-to-letter*, if f(w)=w|f(w)| = |w| for every
    14 input string ww.
    15* ff is *prefix determined* if the first nn output letters depend only on the
    16 first nn input letters: input strings that agree on their first nn letters
    17 have outputs that agree on their first nn letters.
    18
    19For a letter-to-letter function, being prefix determined says exactly that the
    20nn-th output letter depends only on the first nn input letters, which is
    21condition (3) of the Myhill–Nerode lemma for Mealy machines (Lemma A.2.10), and
    22it is the determinism condition of Theorem B.2.7; prefix preservation and length
    23preservation together are the shape of the machine-independent characterisation
    24of Mealy machines (Theorem B.4.1).
    25
    26# Formalization notes
    27
    28`<+:` is mathlib's prefix relation on lists. The three definitions quantify over
    29all strings of the input alphabet and carry no finiteness hypothesis.
    30-/
    31
    32namespace Lax765601.ElementaryProperties
    33
    34/-- `f` is prefix preserving: `w ⊑ v` implies `f w ⊑ f v`. -/
    35def PrefixPreserving {A B : Type} (f : List A → List B) : Prop :=
    36 ∀ w v : List A, w <+: v → f w <+: f v
    37
    38/-- `f` is length preserving, i.e. letter-to-letter: the output has the length of
    39the input. -/
    40def LengthPreserving {A B : Type} (f : List A → List B) : Prop :=
    41 ∀ w : List A, (f w).length = w.length
    42
    43/-- `f` is prefix determined: the first `n` output letters depend only on the
    44first `n` input letters. -/
    45def PrefixDetermined {A B : Type} (f : List A → List B) : Prop :=
    46 ∀ (w v : List A) (n : ℕ), w.take n = v.take n → (f w).take n = (f v).take n
    47
    48end Lax765601.ElementaryProperties
    49

    Formalization notes

    <+:<+: is mathlib's prefix relation on lists. The three definitions quantify over all strings of the input alphabet and carry no finiteness hypothesis.

    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…