#P, parsimonious polynomial-time reductions, #P-hardness and #P-completeness on the CookLevin machine model
DefinitionNQueensComp_NPC_SharpPThis module adds a counting layer on top of the published CookLevin framework (multi-tape Turing machines, step-bounded polynomial time, NP verifiers).
- A function from binary strings to is in #P if there are a polynomial-time NP verifier (in the sense of
CookLevin.IsNPVerifier: decided by a machine within a polynomial number of steps, and accepting only certificates of length at most a polynomial in ) such that for every input
- A parsimonious reduction from to is a map on binary strings, computable in polynomial time (
CookLevin.IsPolyTimeComputable), with for every . - is #P-hard if every parsimoniously reduces to , and #P-complete if moreover .
The paper (p. 819) proves #P-completeness through "a sequence of parsimonious reductions as described by Papadimitriou (1994, Chapter 18)": maps that preserve the number of solutions exactly and are computable in polynomial time. These definitions make that notion precise; hardness under parsimonious reductions implies hardness under polynomial-time Turing reductions.
Formalization Note Because the verifier's certificates have bounded length, the set of accepted certificates is finite and Set.ncard is its true size. The reduction must be polynomial-time computable; without that requirement every counting function would reduce to any counting function that is onto .
import Mathlib
import Definitions.Def_CookLevin_Complexity
namespace NQueensComp.NPC
/-- `f ∈ #P` (Valiant; Papadimitriou 1994, Ch. 18): `f` counts the accepted certificates of a
polynomial-time NP verifier on the published CookLevin machine model. `IsNPVerifier` bounds the
length of every accepted certificate by a polynomial in `|x|`, so the set below is finite and its
`ncard` is the true number of accepted certificates. -/
def InSharpP (f : List Bool → ℕ) : Prop :=
∃ (V : List Bool → List Bool → Bool) (c d : ℕ),
CookLevin.IsNPVerifier c d V ∧
∀ x : List Bool, f x = _root_.Set.ncard {w : List Bool | V x w = true}
/-- A parsimonious reduction from the counting function `f` to the counting function `g`: a map
`R` computable in polynomial time (on the CookLevin model) with `f x = g (R x)` for every input
string `x`, i.e. the number of solutions is exactly preserved (p. 819). -/
def ParsimoniousReducible (f g : List Bool → ℕ) : Prop :=
∃ R : List Bool → List Bool, CookLevin.IsPolyTimeComputable R ∧ ∀ x : List Bool, f x = g (R x)
/-- `g` is #P-hard: every function in #P parsimoniously reduces to it. -/
def SharpPHard (g : List Bool → ℕ) : Prop :=
∀ f : List Bool → ℕ, InSharpP f → ParsimoniousReducible f g
/-- `g` is #P-complete: it is in #P and #P-hard under parsimonious polynomial-time reductions. -/
def SharpPComplete (g : List Bool → ℕ) : Prop :=
InSharpP g ∧ SharpPHard g
end NQueensComp.NPC
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.