P is the class of decision problems decided by a deterministic algorithm in time polynomial in the encoded input length. NP is the class whose yes-instances have complexity certificates of polynomial length that a deterministic algorithm verifies in polynomial time.
A decision problem is NP-complete if it belongs to NP and is NP-hard: every problem in NP admits a polynomial-time many-one reduction to it. Such a reduction maps an instance to an instance in polynomial time and satisfies is a yes-instance if and only if is a yes-instance. Membership in NP and NP-hardness are both required.
Use the usual finite binary encoding of integer or rational input data. NP consists of decision problems whose yes-instances have polynomial-length certificates in computational complexity verifiable in polynomial time. A decision problem is NP-hard if every problem in NP has a polynomial-time many-one reduction to it. It is NP-complete if it is both NP-hard and in NP. An optimization problem is NP-hard when computing its optimum would solve every NP decision problem through a polynomial-time reduction and an optimum-value query; membership in NP applies directly to decision problems, not to an unqualified optimization task.
Reduce subset sum to the 0-1 knapsack problem by setting and . Every feasible value is at most , and the optimum equals exactly when the subset sum answer is yes. The transformation and final comparison take polynomial time. Since subset sum is assumed NP-complete, exact knapsack optimization is NP-hard.
For the half-approximation algorithm for knapsack, use nonnegative weights and profits. Delete overweight items and nonpositive-profit items; take all positive-profit zero-weight items for free. On the remaining positive-weight items, sort decreasing . Take the maximal initial prefix fitting the capacity, and stop at the first item that would overflow. Let be the prefix profit, and let be the largest profit of any individually feasible remaining item. Return the better of the prefix and that singleton, together with the free items. If every item fits, take them all.
The fractional knapsack problem fills exactly that prefix and a fraction of the first excluded item. Its optimum bounds the integer optimum, and without the free items its value is at most . Thus
With total free profit , the same inequality is . This gives an approximation ratio of in sorting time, with polynomial bit complexity for rational data. Nonnegative weights and capacity are the standard knapsack problem assumptions; unrestricted negative weights would not support this argument.
For the quadratic knapsack problem and its fractional row bound for quadratic knapsack, multiply the capacity inequality by the binary and use :
Remove items with first. If , the remaining coordinates are feasible in the fractional problem defining , so . If , that row's contribution is zero. Hence, with ,
The double sum counts each symmetric interaction twice; there is no factor in this problem. Each is a fractional knapsack problem, computable by sorting positive ratios, also handling zero weights separately. This takes polynomial time even when some interactions are negative, because an optional fractional item with negative profit is omitted.
The resulting 0-1 knapsack problem need not be solved exactly. Relax its capacity constraint with a Lagrange multiplier . Its Lagrangian knapsack bound is
For feasible , adding only increases its objective, and maximizing over independent binary choices produces the displayed expression. It is a convex piecewise-linear function with breakpoints at positive . Evaluate those breakpoints and zero, or use the fractional knapsack problem ordering; the best bound is computable in polynomial time. Thus computing all and one additional Lagrangian relaxation gives the requested upper bound.
For the numerical example, the problem has capacity and item ratios and . Select and . This gives
An exchange argument justifies optimality: capacity used on the lower-ratio item can be transferred to the higher-ratio item until the latter is full. The stated and similarly follow from residual capacities and . Therefore , with ratios . The fractional solution takes items and one-third of item , yielding . At the Lagrangian knapsack bound gives the same value:
The fractional solution attaining proves that this is the best bound from this auxiliary Lagrangian relaxation, though it need not be the exact quadratic optimum.
For branch and bound, branch on whether an unresolved is zero or one. If the selected set is , subtract its weight from the residual capacity and retain its exact objective as a constant. For each remaining item replace by , preserving the original interactions between remaining items. Recompute the fractional row bounds and the Lagrangian knapsack bound for that residual problem. Maintain an incumbent from genuine feasible binary solutions evaluated with the quadratic objective; prune infeasible nodes and nodes whose bound is no better than the incumbent. For example, selecting items gives the feasible value . A finite binary branching tree eventually certifies the optimum, but worst-case running time is exponential, as expected for an NP-hard problem.
Write . Instead of storing the output vector, use Heisenberg propagation of a Pauli observable through a Clifford circuit:
Initialize the compact Pauli group representation at and conjugate successively by , in that order, using . This gives
with local-update work and storage. The resulting Pauli operator is Hermitian, so we can express it as , where and each is or . Any factors in the representation from part (i) are converted using , with their phases absorbed into .
The product state input now makes the expectation factorize:
Each factor is a two-by-two matrix calculation. More explicitly, for , the three nontrivial expectations are , , and for , respectively.
Thus this single-output process has a strong classical simulation in polynomial time, even when the individual input states are not stabilizer states. As usual, the given state identities must provide efficiently computable amplitudes. With finite-precision inputs, each factor can be evaluated to error and its approximation clipped to to obtain the final expectation to error at most , because all factors lie in . The required extra precision is only bits. Exact evaluation applies when the input descriptions support exact arithmetic. This avoids silently assigning a finite exact-computation cost to arbitrary unspecified real numbers.
Once the probabilities are known, a classical randomized computation can reproduce this measured bit. The argument concerns the specified one-qubit output; it does not assert that every joint measurement distribution for arbitrary product inputs can be simulated by this same single-observable calculation.
Use the positive-exponent quantum Fourier transform convention . The period of a function here is the least positive translation leaving the function unchanged on the cyclic group . The injective promise means exactly when . In particular : the subgroup of period translations is generated by , and wrapping the argument by preserves its value. This is exact quantum period finding on a finite cyclic group, rather than the truncated, nondividing-period version requiring continued fractions.
Prepare a uniform superposition state in the first quantum register using , and perform a reversible computation of the function into a second quantum register, cleaning its workspace by uncomputation:
A quantum measurement in the computational basis of the second quantum register leaves a periodic coset state in the first:
For the quantum Fourier transform of this periodic coset state, the finite geometric series vanishes unless the measured label is . On those labels its normalized amplitude is . Thus has the uniform distribution on a finite set on , irrespective of .
Compute the greatest common divisor by the Euclidean algorithm, and set , with . Since ,
The exact period recovery from a Fourier sample is therefore certified by testing . Every candidate divides and lies between and , so the injective promise makes that equality equivalent to . This includes , where the test uses input , and , which always succeeds. The test does not assert that an arbitrary equality of function values certifies an arbitrary period; the Fourier-derived divisor restriction is essential.
The concise result is
Here is the Euler totient function, with . The totient lower bound from the Mertens product gives for . Each trial uses polynomial time quantum Fourier transforms, function evaluations and Euclidean algorithm arithmetic in . Repeating independent trials gives constant success probability; the herald accepts only correct answers.
The printed asymptotic bound has the wrong direction for this argument. In Big O notation, the stated upper bound on the number of coprime integers supplies no success lower bound and is itself false uniformly: for prime , , not . Likewise the single-trial success need not be , since it tends to one for prime. The meaningful corrected guarantee is the lower bound above. If an upper-bounded success rate is literally required, one may deliberately retain an accepted result with an independent probability proportional to ; this discards useful successes and is unnecessary for efficient recovery.
The usual sufficient input promises for the HHL algorithm are efficient quantum state preparation of the nonzero vector , efficient access to a sparse matrix with at most nonzero entries per row, and a condition number after an efficiently known normalization. Both the positions and values of the nonzero matrix elements must be computable coherently in polynomial time. More generally, efficient Hamiltonian simulation can replace the sparsity promise. We assume is invertible; if zero eigenvalues occur, one must instead restrict to their orthogonal complement and specify the desired inverse on that support.
With and a known bound , choose . The HHL controlled reciprocal rotation then succeeds with probability
This is the required inverse-polynomial lower bound. In the usual approximate algorithm, inverse-polynomial requested error also gives polynomial runtime under these input promises. The original HHL paper states the dependence on sparsity, conditioning, and accuracy.
There is a qualification for a literally exact version. Representability of the eigenvalues in bits does not itself make exact quantum phase estimation efficient: using requires controlled powers corresponding to evolution times as large as . Under the paper's idealization we may describe their exact action, but polynomial runtime for that exact circuit additionally requires efficient implementations of those controlled powers, or equivalent efficient exact spectral access. Assuming an operation executes exactly does not bound its cost. This distinction is recorded in cost of exact phase estimation on a dyadic spectrum.
Use a reversible circuit to compute an -bit representation of the angle into a workspace register, with all additional work bits retained:
Write that representation as , with known binary place values (including the fixed scale and any integer bit). On the target, apply a controlled unitary gate controlled by each angle bit . Rotations about the same axis add their angles, so their product is
Finally apply to perform uncomputation. The workspace returns to zero while the control register and rotated target remain unchanged; the construction works coherently on every superposition of .
A polynomial time classical calculation has a polynomial-size reversible circuit with Toffoli gates, and each Toffoli gate has a constant-size decomposition into one-qubit and two-qubit gates. The controlled rotations are themselves two-qubit gates. Thus the total quantum circuit size is . This is the binary-angle implementation of a quantum variable rotation; the stipulated angle precision is understood.
Choose a power of two with
Since the multiplicative order is less than , this guarantees . Prepare two quantum registers in the state
and use quantum modular exponentiation to obtain
Measure the second register. The order as the exact period of modular exponentiation implies that, conditional on the measured value, the first register is a normalized truncated periodic coset
where is the largest integer for which .
Apply the quantum Fourier transform to the first register and measure it, obtaining . The supplied Fourier-transform theorem states that, with probability of order , is an integer nearest to for some coprime to . On that event,
The supplied continued-fraction theorem, applied through continued-fraction recovery in quantum order finding, therefore recovers the reduced fraction from . Because and are coprime, its denominator is the exact order . The candidate is checked classically by verifying .
The quantum Fourier transform, quantum modular exponentiation, continued-fraction algorithm, and final modular check all take polynomial time in . Since , the successful event has probability of order , as required.
A strong classical simulation of a quantum circuit computes any requested output probability
in polynomial time, to the prescribed inverse-polynomial accuracy. A weak classical simulation of a quantum circuit instead produces classical samples from the circuit's output distribution, with exact or suitably small total-variation error.
The Extended Gottesman--Knill theorem states that a unitary Clifford circuit with an arbitrary product state input and final computational-basis measurements is weakly classically simulable. It is strongly simulable when only output qubits are measured. Indeed, each joint output projector expands into Pauli operators, and Clifford conjugation maps every such operator to another Pauli operator whose expectation factors over the input qubits. The factor is polynomial precisely for .
After testing nonnegative edge coordinates and any explicit box or budget inequalities, treat those coordinates as lengths. A shortest path of length below one supplies a violated path inequality; a minimum length at least one certifies all path inequalities. If no source-to-target path exists, all those inequalities are vacuous. Thus a polynomial time shortest path problem calculation separates an exponentially constrained linear program.
P (complexity) Created 2026-09-24 Updated 2026-10-06
Quantum modular exponentiation Created 2026-10-03 Updated 2026-10-06
Quantum modular exponentiation is the reversible computation that maps
It can be implemented in polynomial time in the bit lengths of and by repeated squaring and controlled modular multiplication.
A nonempty linear polyhedron with integer inequality coefficients and right sides bounded by contains a point with the displayed bounds. Intersect with an orthant containing a feasible point. Moving along directions annihilating the active constraints, until another constraint becomes active, produces a vertex: the orthant prevents a whole nontrivial line from remaining feasible. At that vertex, choose independent active inequalities, including coordinate constraints as necessary. Cramer's rule and the Hadamard determinant inequality bound both determinants by . The resulting rational witness has polynomial binary length and is verifiable in polynomial time, proving that integer linear feasibility is in NP.
Separation oracle 2026-10-14
A separation oracle either certifies that a supplied point belongs to a convex feasible set or returns a violated linear inequality whose half-space contains the whole feasible set. Its running time can be small even when the set has exponentially many defining inequalities. Together with rational encoding bounds and an outer bound, this permits polynomial time ellipsoid method feasibility and optimization.