Efficient heuristics have predicted many functional materials such as high-temperature superconducting hydrides, while inorganic structural chemistry explains why and how the crystal structures are stabilized. Here we develop the paired mathematical programming formalism for searching and systematizing the structural prototypes of crystals. The first is the minimization of the volume of the unit cell under the constraints of only the minimum and maximum distances between pairs of atoms. We show the capabilities of linear relaxations of inequality constraints to optimize structures by the steepest-descent method, which is computationally very efficient. The second is the discrete optimization to assign five kinds of geometrical constraints including chemical bonds for pairs of atoms. Under the constraints, the two object functions, formulated as mathematical programming, are alternately optimized to realize the given coordination numbers of atoms. This approach successfully generates a wide variety of crystal structures of oxides such as spinel, pyrochlore-α, and K2NiF4 structures.