Here, we provide a theoretical framework revealing that a steady compression ramp flow must have the minimal dissipation of kinetic energy, and can be demonstrated using the least action principle. For a given inflow Mach number $M_{0}$ and ramp angle $alpha$, the separation angle $theta_{s}$ manifesting flow system states can be determined based on this theory. Thus, both the shapes of shock wave configurations and pressure peak $p_{peak}$ behind reattachment shock waves are predictable. These theoretical predictions agree excellently with both experimental data and numerical simulations, covering a wide range of $M_{0}$ and $alpha$. In addition, for a large separation, the theory indicates that $theta_{s}$ only depends on $M_{0}$ and $alpha$, but is independent of the Reynolds number $Re$ and wall temperature $T_{w}$. These facts suggest that the proposed theoretical framework can be applied to other flow systems dominated by shock waves, which are ubiquitous in aerospace engineering.