Rational Utility #
Helper functions and lemmas for constructing rational numbers with prescribed square bounds.
Helper function to find a positive rational number whose square is between two given rationals.
Assumes 0 ≤ lower and lower < upper.
Construction: Let N = ⌈(upper+1)/(upper-lower)⌉ + 1 and m = Nat.sqrt ⌊N²·lower⌋ + 1.
Return m / N. The choice of N ensures N·(√upper − √lower) ≥ 1, which bounds m above by
N·√upper, so (m/N)² ≤ upper. The floor construction ensures (m/N)² > lower.
Equations
Instances For
theorem
findRationalWithSquareBetween_positive
(lower upper : ℚ)
(h0 : 0 ≤ lower)
(hlt : lower < upper)
: