NP-Hardness of a Problem on Words of Numbers

Lax496464.WH_F3_NPHard · concepts/Lax496464/WH_F3_NPHard.lean · lax-496464

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

    A problem is NP-hard if every language in NP reduces to its yes-instances by a map computable in polynomial time: a map ff from binary words to words of numbers such that x∈Ax \in A if and only if f(x)f(x) is a yes-instance, for every xx.

    Concept map
    9 concepts; 1 descendant hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Lax888481.ParameterizedComplexity
    2import Lax434930.NondeterministicPolynomialTime
    3import Lax759944.TuringPolytime
    4
    5/-!
    6---
    7title: NP-Hardness of a Problem on Words of Numbers
    8type: definition
    9---
    10A problem is **NP-hard** if every language in NP reduces to its yes-instances by a map computable
    11in polynomial time: a map ff from binary words to words of numbers such that x∈Ax \in A if and only
    12if f(x)f(x) is a yes-instance, for every xx.
    13
    14# Formalization Notes
    15
    16**Machines.** The map is computed by a Turing machine in polynomial time
    17(`Turing.TM2ComputableInPolyTime`). The machine reads the binary word and writes the canonical
    18binary encoding of the resulting word of numbers (`Lax759944.BinaryWordEncoding.encode`), each
    19number a separator followed by its bits. By the equivalence proved in `Lax759944`, this is
    20polynomial time on the word RAM in the bit size of the word.
    21
    22**Words outside the domain.** The condition is x∈A  ⟺  f(x)x \in A \iff f(x) is a yes-instance. A word
    23that ff maps to a word presenting no instance is therefore a non-member of AA. `NPHardIn` asks
    24in addition that no word is mapped outside the domain.
    25-/
    26
    27namespace Lax496464.WH_F3_NPHard
    28
    29open Lax434930.PolynomialTime Lax434930.NondeterministicPolynomialTime
    30open Lax888481.ParameterizedComplexity
    31
    32/-- `P` is **NP-hard**: every language in NP reduces to it in polynomial time by a Turing
    33machine writing the canonical encoding of the resulting word. -/
    34def NPHard (P : Problem) : Prop :=
    35 ∀ A : Language, A ∈ NP →
    36 ∃ f : Word → List ℕ,
    37 Nonempty (Turing.TM2ComputableInPolyTime id Lax759944.BinaryWordEncoding.encode f) ∧
    38 ∀ x, x ∈ A ↔ P.Yes (f x)
    39
    40/-- `P` is **NP-hard on its domain**: as `NPHard`, and in addition the reduction always outputs a
    41word of the domain, that is a word presenting an instance of `P`. This is the form a reduction that
    42is correct only on instances can be composed with. -/
    43def NPHardIn (P : Problem) : Prop :=
    44 ∀ A : Language, A ∈ NP →
    45 ∃ f : Word → List ℕ,
    46 Nonempty (Turing.TM2ComputableInPolyTime id Lax759944.BinaryWordEncoding.encode f) ∧
    47 ∀ x, f x ∈ P.Domain ∧ (x ∈ A ↔ P.Yes (f x))
    48
    49end Lax496464.WH_F3_NPHard
    50
    Formalization Notes

    Machines. The map is computed by a Turing machine in polynomial time (Turing.TM2ComputableInPolyTimeTuring.TM2ComputableInPolyTime). The machine reads the binary word and writes the canonical binary encoding of the resulting word of numbers (Lax759944.BinaryWordEncoding.encodeLax759944.BinaryWordEncoding.encode), each number a separator followed by its bits. By the equivalence proved in Lax759944Lax759944, this is polynomial time on the word RAM in the bit size of the word.

    Words outside the domain. The condition is x∈A  ⟺  f(x)x \in A \iff f(x) is a yes-instance. A word that ff maps to a word presenting no instance is therefore a non-member of AA. NPHardInNPHardIn asks in addition that no word is mapped outside the domain.

    Discussion

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

    Loading discussion…