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

Lax251941.PostCorrespondence

The Post correspondence problem

concepts/Lax251941/PostCorrespondence.lean · lax-251941

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

    Definition

    An instance of the Post correspondence problem is a finite collection of dominos [t/b][t / b], each carrying a top string tt and a bottom string bb over some alphabet. A match is a nonempty sequence of dominos from the collection, repetitions allowed, such that reading off the top strings gives the same string as reading off the bottom strings. The problem asks whether a given instance has a match (Sipser, Section 5.2; Post 1946).

    The same problem in index form, as the book Transducers uses it: an instance is a finite list of pairs of strings (u1,v1),,(un,vn)(u_1, v_1), \ldots, (u_n, v_n) over the alphabet N\mathbb{N}, and it is solvable if some nonempty sequence of indices i1iki_1 \cdots i_k satisfies

    ui1uik=vi1vik.u_{i_1} \cdots u_{i_k} = v_{i_1} \cdots v_{i_k}.

    Lean source view on GitHub

    1import Mathlib.Data.List.Basic
    2
    3/-!
    4---
    5title: The Post correspondence problem
    6type: definition
    7---
    8An instance of the *Post correspondence problem* is a finite collection of
    9*dominos* [t/b][t / b], each carrying a top string tt and a bottom string bb over
    10some alphabet. A *match* is a nonempty sequence of dominos from the collection,
    11repetitions allowed, such that reading off the top strings gives the same string
    12as reading off the bottom strings. The problem asks whether a given instance has
    13a match (Sipser, Section 5.2; Post 1946).
    14
    15The same problem in *index form*, as the book *Transducers* uses it: an
    16instance is a finite list of pairs of strings (u1,v1),,(un,vn)(u_1, v_1), \ldots, (u_n, v_n)
    17over the alphabet N\mathbb{N}, and it is solvable if some nonempty sequence of
    18indices i1iki_1 \cdots i_k satisfies
    19ui1uik=vi1vik.u_{i_1} \cdots u_{i_k} = v_{i_1} \cdots v_{i_k}.
    20
    21# Formalization notes
    22
    23`Inst α` is a list of dominos over any alphabet `α`; `IsMatch P s` says that the
    24nonempty list `s` of dominos, each belonging to `P`, has equal top and bottom
    25strings, and `HasMatch P` that some match exists. `Solvable` is the index form
    26over `ℕ`: `conc ws idx` concatenates the strings of `ws` selected by the indices
    27(an index out of range selects the empty string, but the definition requires
    28every index to be in range). The two forms carry the same information — choose
    29an index for each domino, or read a domino off each index — and both are stated
    30as undecidable.
    31-/
    32
    33namespace Lax251941.PostCorrespondence
    34
    35/-- A domino: a top string and a bottom string. -/
    36abbrev Domino (α : Type*) := List α × List α
    37
    38/-- An instance of the Post correspondence problem: a finite list of dominos. -/
    39abbrev Inst (α : Type*) := List (Domino α)
    40
    41/-- The string read off the top halves of a sequence of dominos. -/
    42def topStr {α : Type*} (s : List (Domino α)) : List α := (s.map Prod.fst).flatten
    43
    44/-- The string read off the bottom halves of a sequence of dominos. -/
    45def botStr {α : Type*} (s : List (Domino α)) : List α := (s.map Prod.snd).flatten
    46
    47/-- `s` is a match of the instance `P`: a nonempty sequence of dominos of `P`
    48whose top string equals its bottom string. -/
    49def IsMatch {α : Type*} (P : Inst α) (s : List (Domino α)) : Prop :=
    50 s ≠ [] ∧ (∀ d ∈ s, d ∈ P) ∧ topStr s = botStr s
    51
    52/-- The instance `P` has a match. -/
    53def HasMatch {α : Type*} (P : Inst α) : Prop := ∃ s, IsMatch P s
    54
    55/-- An instance in index form: a finite list of pairs of strings over `ℕ`. -/
    56abbrev Instance := List (List ℕ × List ℕ)
    57
    58/-- The concatenation of the strings of `ws` selected by a list of indices. -/
    59def conc (ws : List (List ℕ)) (idx : List ℕ) : List ℕ :=
    60 (idx.map (fun i => ws.getD i [])).flatten
    61
    62/-- An instance is solvable if some nonempty sequence of indices makes the two
    63concatenations equal. -/
    64def Solvable (P : Instance) : Prop :=
    65 ∃ idx : List ℕ, idx ≠ [] ∧ (∀ i ∈ idx, i < P.length) ∧
    66 conc (P.map Prod.fst) idx = conc (P.map Prod.snd) idx
    67
    68end Lax251941.PostCorrespondence
    69

    Formalization notes

    InstαInst α is a list of dominos over any alphabet αα; IsMatchPsIsMatch P s says that the nonempty list ss of dominos, each belonging to PP, has equal top and bottom strings, and HasMatchPHasMatch P that some match exists. SolvableSolvable is the index form over N: concwsidxconc ws idx concatenates the strings of wsws selected by the indices (an index out of range selects the empty string, but the definition requires every index to be in range). The two forms carry the same information — choose an index for each domino, or read a domino off each index — and both are stated as undecidable.

    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…