Submitted:
11 November 2026
Posted:
12 November 2026
You are already at the latest version
Abstract
For d ≥ 3 with −d ≡ 0,1 (mod 4), let h(−d) be the number of classes of primitive positive definite binary quadratic forms of discriminant −d. We prove that d→ h(−d) is computable in deterministic polynomial time with an oracle for a language in the second level \( \Sigma_2^{\text{P}} \) of the polynomial hierarchy. The proof uses only reduction theory of binary quadratic forms, Lagrange’s theorem and Hermite normal forms; it does not assume the generalized Riemann hypothesis, does not take a generating set of the class group as input, and uses no randomness. A \( \Sigma_2^{\text{P}} \) oracle finds a generating set of O(log d) forms, and an NP oracle then determines the lattice of relations, whose index is h(−d). Consequently, if P = NP, class numbers of imaginary quadratic fields are computable in polynomial time. As an application, the number Dn of representations of n by the ternary form 8x2 +2y2 + 16z2 in Tunnell’s congruent number criterion equals 2h(−4n) for square-free n ≡ 2 (mod 8) and vanishes for square-free n ≡ 6 (mod 8); hence Dn lies in \( \text{FP}^{\Sigma_2^{\text{P}}} \) on even square-free n, and an exact counting reduction from #SAT to Dn would collapse the polynomial hierarchy to \( \Delta_3^{\text{P}} \).
Keywords:
class numbers
; binary quadratic forms
; polynomial hierarchy
; counting complexity
; Tunnell's theorem
; congruent numbers
; Hermite normal form
; black-box groups
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.