Documentation

CslibFrontier.Computability.Complexity.Classes.SharpP.Machine

Native machine terminal counts belong to #P #

For each fixed finite-control list-choice machine and polynomial clock, both accepting and rejecting terminal-branch counts belong to the verifier-defined #P. The binary verifiers are the actual certified replay programs from MultiTape.Counting.Checker, with one fixed-width code per occurrence index and uniquely forced terminal padding. Invalid codes count on neither side. The result does not identify choices with equal actions or equal successor configurations.

The clock counts native transitions. Only branches halted by that clock are counted; the existing HaltsWithin hypothesis additionally guarantees that every branch halts without getting stuck, and makes both counts stable at larger clocks. No all-branch halting assumption is needed merely to count bounded terminal branches. The machine, finite control, number of tapes and block width are fixed before the input is supplied. Classes.SharpP.Characterization supplies the reverse verifier construction and the bidirectional #P characterization. Classes.SharpP.GapMachine supplies balanced signed routing and the bidirectional GapP characterization.

Main results #

References #

This is the forward counting-machine construction. The shared native machine, binary encoding, finite-storage simulation and certified calculus retain their source credits in their modules.

theorem Turing.MultiTapeCTM.Checker.acceptCount_checkBinary {k : ℕ} {State : Type} (machine : MultiTapeCTM k Bool State) {width : ℕ} (hwidth : 0 < width) (input : List Bool) (hbound : ∀ (cfg : Cfg k Bool State input), (machine.actions cfg).length ≤ 2 ^ width) (count : ℕ) (verdict : Bool) :
Cslib.Complexity.acceptCount (checkBinary machine width verdict) input (count * width) = machine.branchCount (fun (out : List Bool) => (out == [true]) == verdict) count (Cfg.init machine.initial input)

Every accepting binary word corresponds to exactly one canonical occurrence certificate, for either requested terminal verdict. Invalid words contribute to neither count.

theorem Turing.MultiTapeCTM.acceptCount_mem_SharpP {k : ℕ} {State α : Type} [Finite State] (machine : MultiTapeCTM k Bool State) (enc : α ↪ List Bool) (clock : Polynomial ℕ) :
(fun (a : α) => machine.acceptCount (Polynomial.eval (enc a).length clock) (Cfg.init machine.initial (enc a))) ∈ Cslib.Complexity.SharpP enc

For a fixed finite-control native list-choice machine, the number of accepting branches halted by a polynomial clock is in #P. A complete all-branch computation additionally uses HaltsWithin; neither stuck nor unfinished branches are counted.

theorem Turing.MultiTapeCTM.rejectCount_mem_SharpP {k : ℕ} {State α : Type} [Finite State] (machine : MultiTapeCTM k Bool State) (enc : α ↪ List Bool) (clock : Polynomial ℕ) :
(fun (a : α) => machine.rejectCount (Polynomial.eval (enc a).length clock) (Cfg.init machine.initial (enc a))) ∈ Cslib.Complexity.SharpP enc

Rejecting terminal branches have their own valid-certificate #P verifier. It complements the output verdict while retaining validity, so invalid binary words are never counted.

theorem Turing.MultiTapeCTM.gapCount_mem_GapP {k : ℕ} {State α : Type} [Finite State] (machine : MultiTapeCTM k Bool State) (enc : α ↪ List Bool) (clock : Polynomial ℕ) :
(fun (a : α) => ↑(machine.acceptCount (Polynomial.eval (enc a).length clock) (Cfg.init machine.initial (enc a))) - ↑(machine.rejectCount (Polynomial.eval (enc a).length clock) (Cfg.init machine.initial (enc a)))) ∈ Cslib.Complexity.GapP enc

The difference of accepting and rejecting polynomial-clock terminal counts is in GapP. This is the forward implication; the reverse construction is in Classes.SharpP.GapMachine.