  We develop the foundations of a general framework for producing optimal upper
and lower bounds on the sum $\sum_p a_p$ over primes $p$, where
$(a_n)_{x/2<n\le x}$ is an arbitrary non-negative sequence satisfying Type I
and Type II estimates.
  Our lower bounds on $\sum_p a_p$ depend on a new sieve method, which is
non-iterative and uses all of the Type I and Type II information at once. We
also give a complementary general procedure for constructing sequences $(a_n)$
satisfying the Type I and Type II estimates, which in many cases proves that
our lower bounds on $\sum_p a_p$ are best possible. A key role in both the
sieve method and the construction method is played by the geometry of special
subsets of $\mathbb{R}^k$.
  This allows us to determine precisely the ranges of Type I and Type II
estimates for which an asymptotic for $\sum_p a_p$ is guaranteed, that a
substantial Type II range is always necessary to guarantee a non-trivial lower
bound for $\sum_p a_p$, and to determine the optimal bounds in some naturally
occurring families of parameters from the literature. We also demonstrate that
the optimal upper and lower bounds for $\sum_p a_p$ exhibit many
discontinuities with respect to the Type I and Type II ranges, ruling out the
possibility of a particularly simple characterization.
