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

Lax554803.PolynomialTime

The complexity class P

concepts/Lax554803/PolynomialTime.lean · lax-554803

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

    A language of finite binary strings belongs to P\mathrm{P} if a deterministic Turing machine decides membership in that language in polynomial time. Precisely, there are a single machine and a polynomial pN[X]p \in \mathbb{N}[X] such that, on every input ww, the machine halts within p(w)p(|w|) steps and returns the bit 11 if ww belongs to the language and 00 otherwise.

    The definition uses mathlib's deterministic stack machines, the identity encoding of binary strings, and a singleton Boolean output. Time counts transitions of fixed finite instruction blocks. We also prove equivalence with elementary single-tape machines.

    Lean source view on GitHub

    1import Mathlib.Computability.TuringMachine.Computable
    2
    3/-!
    4---
    5title: The complexity class P
    6type: definition
    7---
    8A language of finite binary strings belongs to P\mathrm{P} if a deterministic
    9Turing machine decides membership in that language in polynomial time.
    10Precisely, there are a single machine and a polynomial pN[X]p \in \mathbb{N}[X]
    11such that, on every input ww, the machine halts within p(w)p(|w|) steps and
    12returns the bit 11 if ww belongs to the language and 00 otherwise.
    13
    14The definition uses mathlib's deterministic stack machines, the identity
    15encoding of binary strings, and a singleton Boolean output. Time counts
    16transitions of fixed finite instruction blocks. We also prove equivalence
    17with elementary single-tape machines.
    18-/
    19
    20namespace Lax554803.PolynomialTime
    21
    22/-- A finite binary string. -/
    23abbrev Word := List Bool
    24
    25/-- A language of finite binary strings. -/
    26abbrev Language := Set Word
    27
    28/-- Languages whose Boolean characteristic functions are computable in polynomial time. -/
    29def P : Set Language :=
    30 {L | ∃ f : Word → Bool,
    31 (∀ w, f w = true ↔ w ∈ L) ∧
    32 Nonempty (Turing.TM2ComputableInPolyTime id Computability.encodeBool f)}
    33
    34end Lax554803.PolynomialTime
    35

    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…