Documentation

CslibFrontier.Computability.Complexity.Classes.ModP

Modular counting classes #

For fixed k ≥ 2, ModP k accepts when a #P count is nonzero modulo k. This is the convention of Fortnow, Classification 4.7; in particular ModP 2 = ParityP. The definition is total in k: at 0 it gives NP, and at 1 it contains only the empty language. The modulus is a class parameter, not part of the input.

We use verifier counts, not a claimed equivalence with nondeterministic counting machines. Reduction closure follows from exact-count precomposition. For a prime modulus, intersection uses the absence of zero divisors and complement uses Fermat's little theorem: if f is the original count, 1 + (p - 1) * f ^ (p - 1) is nonzero modulo p exactly when f is zero modulo p. These are elementary algebraic derivations; the prime-modulus closure framework is classical Papadimitriou and Zachos. No such closure is claimed here for arbitrary composite moduli.

Main definitions #

Main results #

The complement class coModP is defined by zero residues. For prime moduli it equals ModP, by the complement theorem above; no such equality is asserted for composite moduli.

References #

def Cslib.Complexity.ModP {α : Type} (k : ℕ) (enc : α ↪ List Bool) :
Set (Set α)

For a fixed modulus k, languages recognized by a nonzero residue of a #P count Fortnow, Classification 4.7. The standard modular counting classes use k ≥ 2.

theorem Cslib.Complexity.mem_ModP {α : Type} {enc : α ↪ List Bool} {A : Set α} {k : ℕ} :
A ∈ ModP k enc ↔ ∃ f ∈ SharpP enc, ∀ (a : α), a ∈ A ↔ f a % k ≠ 0
theorem Cslib.Complexity.ModP_two {α : Type} {enc : α ↪ List Bool} :
ModP 2 enc = ParityP enc

Modulo two, nonzero residue is oddness Fortnow, after Classification 4.7.

theorem Cslib.Complexity.ModP_zero {α : Type} {enc : α ↪ List Bool} :
ModP 0 enc = NP enc

Modulus zero specializes to the positive-count characterization of NP.

theorem Cslib.Complexity.mem_ModP_one {α : Type} {enc : α ↪ List Bool} {A : Set α} :
A ∈ ModP 1 enc ↔ A = ∅

Modulus one recognizes only the empty language.

theorem Cslib.Complexity.UP_subset_ModP {α : Type} {enc : α ↪ List Bool} {k : ℕ} (hk : 2 ≤ k) :
UP enc ⊆ ModP k enc

Unambiguous counts are zero or one, so any modulus at least two recognizes them.

theorem Cslib.Complexity.P_subset_ModP {α : Type} {enc : α ↪ List Bool} {k : ℕ} (hk : 2 ≤ k) :
P enc ⊆ ModP k enc

P ⊆ ModP k for every fixed k ≥ 2.

theorem Cslib.Complexity.PolyTimeReducible.mem_ModP {α : Type} {enc : α ↪ List Bool} {A : Set α} {k : ℕ} {β : Type} {encB : β ↪ List Bool} {B : Set β} (h : PolyTimeReducible enc encB A B) (hB : B ∈ ModP k encB) :
A ∈ ModP k enc

Exact-count precomposition preserves every modulus.

theorem Cslib.Complexity.inter_mem_ModP {α : Type} {enc : α ↪ List Bool} {A B : Set α} {k : ℕ} (hk : Nat.Prime k) (hA : A ∈ ModP k enc) (hB : B ∈ ModP k enc) :
A ∩ B ∈ ModP k enc

Prime divisibility of a product gives intersection closure.

theorem Cslib.Complexity.compl_mem_ModP {α : Type} {enc : α ↪ List Bool} {A : Set α} {k : ℕ} (hk : Nat.Prime k) (hA : A ∈ ModP k enc) :
Aᶜ ∈ ModP k enc

Fermat's little theorem turns a zero residue into a one residue and conversely.

For prime k, ModP k as a Boolean subalgebra of Set α.

@[simp]
theorem Cslib.Complexity.ModP.coe_booleanSubalgebra {α : Type} {enc : α ↪ List Bool} {k : ℕ} (hk : Nat.Prime k) :
↑(booleanSubalgebra hk enc) = ModP k enc
@[simp]
theorem Cslib.Complexity.ModP.mem_booleanSubalgebra {α : Type} {enc : α ↪ List Bool} {A : Set α} {k : ℕ} (hk : Nat.Prime k) :
A ∈ booleanSubalgebra hk enc ↔ A ∈ ModP k enc
theorem Cslib.Complexity.union_mem_ModP {α : Type} {enc : α ↪ List Bool} {A B : Set α} {k : ℕ} (hk : Nat.Prime k) (hA : A ∈ ModP k enc) (hB : B ∈ ModP k enc) :
A ∪ B ∈ ModP k enc

Prime-modulus union closure follows by De Morgan's law.

theorem Cslib.Complexity.diff_mem_ModP {α : Type} {enc : α ↪ List Bool} {A B : Set α} {k : ℕ} (hk : Nat.Prime k) (hA : A ∈ ModP k enc) (hB : B ∈ ModP k enc) :
A \ B ∈ ModP k enc

Prime-modulus set-difference closure.

theorem Cslib.Complexity.symmDiff_mem_ModP {α : Type} {enc : α ↪ List Bool} {A B : Set α} {k : ℕ} (hk : Nat.Prime k) (hA : A ∈ ModP k enc) (hB : B ∈ ModP k enc) :
symmDiff A B ∈ ModP k enc

Prime-modulus symmetric-difference closure.

def Cslib.Complexity.coModP {α : Type} (k : ℕ) (enc : α ↪ List Bool) :
Set (Set α)

The complementary modular class: a #P count is divisible by the fixed modulus.

theorem Cslib.Complexity.mem_coModP {α : Type} {enc : α ↪ List Bool} {A : Set α} {k : ℕ} :
A ∈ coModP k enc ↔ Aᶜ ∈ ModP k enc
@[simp]
theorem Cslib.Complexity.compl_mem_coModP {α : Type} {enc : α ↪ List Bool} {A : Set α} {k : ℕ} :
Aᶜ ∈ coModP k enc ↔ A ∈ ModP k enc
theorem Cslib.Complexity.mem_coModP_iff_exists_SharpP {α : Type} {enc : α ↪ List Bool} {A : Set α} {k : ℕ} :
A ∈ coModP k enc ↔ ∃ f ∈ SharpP enc, ∀ (a : α), a ∈ A ↔ f a % k = 0

Zero residues characterize the complementary modular class.

theorem Cslib.Complexity.PolyTimeReducible.mem_coModP {α : Type} {enc : α ↪ List Bool} {A : Set α} {k : ℕ} {β : Type} {encB : β ↪ List Bool} {B : Set β} (h : PolyTimeReducible enc encB A B) (hB : B ∈ coModP k encB) :
A ∈ coModP k enc

Complementary modular counting is closed under polynomial-time reductions.

theorem Cslib.Complexity.coModP_eq_ModP {α : Type} {enc : α ↪ List Bool} {k : ℕ} (hk : Nat.Prime k) :
coModP k enc = ModP k enc

For prime moduli, complement closure identifies the two modular classes.