Documentation

CslibFrontier.Computability.Complexity.Classes.SharpP.Characterization

The native counting-machine characterization of #P #

Every verifier-defined #P function is the accepting count of one fixed finite-control native List-choice machine, with a polynomial all-branches clock in the encoded instance length. The converse uses the certified binary replay checker. The reverse construction also preserves the rejecting count: each unsuccessful witness contributes exactly one rejecting branch.

The machine, number of tapes, finite state type and clock are fixed before the input. For an arbitrary instance encoding the halting contract is on its image; specializing to encBits covers every binary input. Classes.SharpP.GapMachine uses balanced verdict routing to realize arbitrary #P differences and prove the signed GapP characterization.

Main results #

References #

The native construction and earlier formalization credits are in MultiTape.Counting.Verifier; the forward certified checker and its source credit are in Classes.SharpP.Machine.

theorem Turing.MultiTapeCTM.exists_verifier_counting_machine {α : Type} (enc : α ↪ List Bool) (p : Polynomial ℕ) (verifier : α × List Bool → Bool) (hverify : MultiTapeTM.ComputableInPolyTime verifier (MultiTapeTM.encPair enc MultiTapeTM.encBits) MultiTapeTM.encBool) :
∃ (k : ℕ) (State : Type) (_ : Finite State) (machine : MultiTapeCTM k Bool State) (clock : Polynomial ℕ), machine.Nonblocking ∧ ∀ (a : α), machine.HaltsWithin (Polynomial.eval (enc a).length clock) (Cfg.init machine.initial (enc a)) ∧ machine.acceptCount (Polynomial.eval (enc a).length clock) (Cfg.init machine.initial (enc a)) = Cslib.Complexity.acceptCount verifier a (Polynomial.eval (enc a).length p) ∧ machine.rejectCount (Polynomial.eval (enc a).length clock) (Cfg.init machine.initial (enc a)) = 2 ^ Polynomial.eval (enc a).length p - Cslib.Complexity.acceptCount verifier a (Polynomial.eval (enc a).length p)

Actual native guess-and-verify has one branch per witness, with both verdict counts exact. Preparation, framing, buffers and tidy restoration are included in the polynomial clock.

theorem Cslib.Complexity.mem_SharpP_iff_exists_machine {α : Type} {enc : α ↪ List Bool} {f : α → ℕ} :
f ∈ SharpP enc ↔ ∃ (k : ℕ) (State : Type) (_ : Finite State) (machine : Turing.MultiTapeCTM k Bool State) (clock : Polynomial ℕ), machine.Nonblocking ∧ ∀ (a : α), machine.HaltsWithin (Polynomial.eval (enc a).length clock) (Turing.Cfg.init machine.initial (enc a)) ∧ machine.acceptCount (Polynomial.eval (enc a).length clock) (Turing.Cfg.init machine.initial (enc a)) = f a

The verifier definition of #P is exactly polynomial-time native accepting-path counting. All machine parameters are fixed before the encoded instance; every branch halts without getting stuck. The constructed machines have globally nonblocking transition tables.