P, NP, NP-hard, and NP-complete: Definitions and Relationships

P, NP, NP-hard, and NP-complete: Definitions and Relationships

Verified Sources
Sep 12, 2026

In computational complexity theory, PP, NPNP, NP-hardNP\text{-hard}, and NP-completeNP\text{-complete} classify decision problems by how difficult they are to solve and/or verify. The key relationships are defined using polynomial time bounds and polynomial-time reductions.4

At a high level:

  • keywordP are efficiently solvable.
  • keywordNP are efficiently verifiable (equivalently, solvable by nondeterministic polynomial-time machines).
  • keywordNP-hard are hardest (or beyond) the NP frontier; they may or may not lie in NPNP.
  • keywordNP-complete are the hardest problems within NPNP: they are in NPNP and NP-hard.

Footnotes

  1. P (complexity) - Wikipedia - Defines P as deterministic polynomial-time decision problems.

  2. Polynomial-time reduction - Wikipedia - Defines polynomial-time many-one (Karp) reductions and their role in completeness.

  3. NP-hardness - Wikipedia - Defines NP-hard problems as those to which every NP problem reduces in polynomial time; notes NP-hard need not be in NP. 2

  4. NP-completeness - Wikipedia - Defines NP-complete as problems in NP that are NP-hard; states relationship to NP and NP-hard. 2

  5. NP (complexity) - Wikipedia - Defines NP via nondeterministic polynomial time and certificate verification.

P and NP - Intro

Decision problems and polynomial-time reductions (the “glue”)

A decision problem asks a yes/no question for each input instance. Complexity class statements here are for decision problems.

To compare difficulty, we use keywordpolynomial-time many-one (Karp) reductions: AmPBA \le_m^P B means we can convert inputs for AA into inputs for BB in polynomial time so that answers are preserved.2

This lets definitions like “HH is NP-hard” mean: if we could solve HH fast, we could solve every problem in NPNP fast too (via reduction).

Footnotes

  1. Polynomial-time reduction - Wikipedia - Defines polynomial-time many-one (Karp) reductions and their role in completeness. 2

  2. NP-hardness - Wikipedia - Defines NP-hard problems as those to which every NP problem reduces in polynomial time; notes NP-hard need not be in NP. 2

1) Class PP

Definition. [keyword]def="P:decisionproblemssolvablebyadeterministicTuringmachineinpolynomialtime"PkeywordP is the class of decision problems solvable in deterministic polynomial time.

Formally: a language/problem is in PP if there exists a deterministic algorithm that decides it using time nO(1)n^{O(1)} (polynomial in input length).

Implication: If a problem is in PP, then both finding and verifying solutions are efficient (because solving is efficient).

Key terms (for this block): keyworddecision problem, keyworddeterministic, keywordpolynomial time, keywordtime complexity.

Footnotes

  1. P (complexity) - Wikipedia - Defines P as deterministic polynomial-time decision problems.

2) Class NPNP

There are two equivalent standard characterizations:

  1. Nondeterministic view: [keyword]def="NP:decisionproblemssolvablebyanondeterministicTuringmachineinpolynomialtime"NPkeywordNP is the class of decision problems decidable by a nondeterministic Turing machine in polynomial time.2

  2. Verifier/certificate view: [keyword]def="NP:problemswhereayesinstancehasapolynomialtimeverifiablecertificate"NPkeywordNP is also the class of decision problems for which “yes” instances have polynomial-size certificates that can be verified in polynomial time by a deterministic verifier.2

That these are equivalent is standard (e.g., through correspondence between nondeterministic choices and certificates).

Relationship with PP. Every problem in PP is also in NPNP because if you can solve it in polynomial time, you can also verify a claimed solution in polynomial time.2

So: PNPP \subseteq NP.2

Key terms (for this block): keywordcertificate, keywordverifier, keywordnondeterminism, keywordverification.

Footnotes

  1. P (complexity) - Wikipedia - Notes equivalently that P is contained in NP (verifiability). 2 3 4

  2. NP (complexity) - Wikipedia - Defines NP via nondeterministic polynomial time and certificate verification. 2 3

  3. P (complexity) - Wikipedia - Defines P as deterministic polynomial-time decision problems. 2

3) NP-hardNP\text{-hard}

Definition. A problem (usually decision; can be more general) HH is keywordNP-hard if every problem in NPNP reduces to HH in polynomial time.

Crucially:

  • HH does not have to be in NPNP. It might not have efficiently checkable certificates (or might even be undecidable in broader settings), but it is still “at least as hard as” all of NPNP under reductions.

Why reductions matter. If LNPL \in NP and LmPHL \le_m^P H, then a polynomial-time solver for HH would imply a polynomial-time solver for LL (by composing the reduction with the solver).2

Key terms (for this block): keywordhardness, keywordcomposition, keyworddifficulty order, keywordoutside-NP.

Footnotes

  1. NP-hardness - Wikipedia - Defines NP-hard problems as those to which every NP problem reduces in polynomial time; notes NP-hard need not be in NP. 2 3

  2. Polynomial-time reduction - Wikipedia - Defines polynomial-time many-one (Karp) reductions and their role in completeness.

4) NP-completeNP\text{-complete}

Definition. A problem CC is keywordNP-complete if:

  1. CNPC \in NP, and
  2. CC is NP-hard.

So NPNP-complete problems are the “hardest” problems within NPNP: they are efficiently verifiable, but every other problem in NPNP reduces to them in polynomial time.

Cook–Levin theorem (existence of NP-complete problems). A standard result states that Boolean satisfiability (SATSAT, and variants like 3SAT3SAT) is NP-complete; equivalently, every problem in NPNP reduces to satisfiability in polynomial time.

Footnotes

  1. NP-completeness - Wikipedia - Defines NP-complete as problems in NP that are NP-hard; states relationship to NP and NP-hard. 2

  2. Cook–Levin theorem - Wikipedia - States SAT is NP-complete and that any problem in NP reduces to it in polynomial time.

How to use reductions to prove a problem is NP-hard / NP-complete

  1. 1
    Step 1

    If you want NP-hardness, you need reductions from every LNPL \in NP (often done by reducing from a single known NP-complete GG). NP-completeness requires membership in NPNP plus NP-hardness.

    Footnotes

    1. NP-completeness - Wikipedia - Defines NP-complete as problems in NP that are NP-hard; states relationship to NP and NP-hard.

  2. 2
    Step 2

    Give a function that maps instances of GG to instances of HH in polynomial time while preserving yes/no answers (many-one/Karp reduction).

    Footnotes

    1. Polynomial-time reduction - Wikipedia - Defines polynomial-time many-one (Karp) reductions and their role in completeness.

  3. 3
    Step 3

    Show: xG    f(x)Hx \in G \iff f(x) \in H. This establishes that solving HH solves GG.

    Footnotes

    1. Polynomial-time reduction - Wikipedia - Defines polynomial-time many-one (Karp) reductions and their role in completeness.

  4. 4
    Step 4

    Because GG is NP-complete, all problems in NPNP reduce to GG, hence (by transitivity of reductions) to HH as well.2

    Footnotes

    1. Polynomial-time reduction - Wikipedia - Defines polynomial-time many-one (Karp) reductions and their role in completeness.

    2. NP-hardness - Wikipedia - Defines NP-hard problems as those to which every NP problem reduces in polynomial time; notes NP-hard need not be in NP.

  5. 5
    Step 5

    Provide a polynomial-time verifier or a nondeterministic polynomial-time algorithm for HH.2

    Footnotes

    1. NP-completeness - Wikipedia - Defines NP-complete as problems in NP that are NP-hard; states relationship to NP and NP-hard.

    2. NP (complexity) - Wikipedia - Defines NP via nondeterministic polynomial time and certificate verification.

5) Relationship between PP, NPNP, NP-hardNP\text{-hard}, and NP-completeNP\text{-complete}

The core inclusions are:

  1. PNPP \subseteq NP.2
  2. NP-completeNPNP\text{-complete} \subseteq NP (by definition: NP-complete problems are in NPNP).
  3. NP-completeNP-hardNP\text{-complete} \subseteq NP\text{-hard} (again by definition: NP-complete problems are NP-hard).
  4. NP-hardNP\text{-hard} is not necessarily a subset of NPNP (NP-hard problems may lie outside NPNP).2

So we can write the clean set-theoretic relationship:

NP-complete=NPNP-hard.NP\text{-complete} = NP \cap NP\text{-hard}.

This is exactly the “in NPNP and NP-hard” definition.

The big open question: PP vs NPNP

  • If P=NPP = NP, then every problem in NPNP becomes tractable, and many consequences follow.
  • If there exists an NP-complete problem in PP, then P=NPP = NP (because NP-complete problems are NP-hard, so polynomial-time solvability would collapse the whole NP hierarchy to PP).

This is why NP-completeness is central: NP-complete problems are the “borderline” of what might be solvable efficiently.

Footnotes

  1. P (complexity) - Wikipedia - Defines P as deterministic polynomial-time decision problems.

  2. P (complexity) - Wikipedia - Notes equivalently that P is contained in NP (verifiability).

  3. NP-completeness - Wikipedia - Defines NP-complete as problems in NP that are NP-hard; states relationship to NP and NP-hard. 2 3 4 5

  4. NP-hardness - Wikipedia - Defines NP-hard problems as those to which every NP problem reduces in polynomial time; notes NP-hard need not be in NP.

Conceptual roadmap

Efficient solving ($P$)

Step A

Deterministic polynomial-time algorithms decide the problem."

Footnotes

  1. P (complexity) - Wikipedia - Defines P as deterministic polynomial-time decision problems.

Efficient verifying ($NP$)

Step B

Yes-instances have polynomial-size certificates verifiable in polynomial time (equivalently, nondeterministic polynomial time)."

Footnotes

  1. NP (complexity) - Wikipedia - Defines NP via nondeterministic polynomial time and certificate verification.

Hardness boundary ($NP$-hard)

Step C

Every NPNP problem reduces to it in polynomial time; it may be outside NPNP."

Footnotes

  1. NP-hardness - Wikipedia - Defines NP-hard problems as those to which every NP problem reduces in polynomial time; notes NP-hard need not be in NP.

Hardest inside $NP$ ($NP$-complete)

Step D

In NPNP and NP-hard; reductions characterize complete difficulty within NPNP."

Footnotes

  1. NP-completeness - Wikipedia - Defines NP-complete as problems in NP that are NP-hard; states relationship to NP and NP-hard.

Where each class sits conceptually

Higher bars mean the class is defined to be harder (via reductions) and/or supports efficient verification.

Pro Tip: Use the “intersection” viewpoint

A problem is NP-complete exactly when it is both in NP and NP-hard. So once you prove NP-hardness via reductions, you only need to show polynomial-time verifiability to finish NP-completeness.

Footnotes

  1. NP-completeness - Wikipedia - Defines NP-complete as problems in NP that are NP-hard; states relationship to NP and NP-hard.

Warning: NP-hard does not mean “in NP”

NP-hard problems might not have polynomial-time verifiable certificates; they are “hard” by reduction, not by membership in NP.

Footnotes

  1. NP-hardness - Wikipedia - Defines NP-hard problems as those to which every NP problem reduces in polynomial time; notes NP-hard need not be in NP.

Common confusions

Knowledge Check

Question 1 of 3
Q1Single choice

Which statement is correct about the relationship between the classes?