import Mathlib.Analysis.SpecialFunctions.Sqrt import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring namespace Inekoalaty /-! Auxiliary inequalities for the inekoalaty game. -/ lemma pair_sum_ge_sqrt_two {t : ℝ} (ht0 : 0 ≤ t) (ht2 : t ^ 2 ≤ (2 : ℝ)) : t + Real.sqrt (2 - t ^ 2) ≥ Real.sqrt 2 := by have hts : 0 ≤ 2 - t ^ 2 := by nlinarith have hts' : 0 ≤ 2 - t * t := by -- `pow_two` rewrites `t ^ 2` as `t * t`. simpa [pow_two] using hts have hs0 : 0 ≤ Real.sqrt (2 - t ^ 2) := Real.sqrt_nonneg _ have hnonneg : 0 ≤ t + Real.sqrt (2 - t ^ 2) := by nlinarith have hcalc : (t + Real.sqrt (2 - t ^ 2)) ^ 2 = 2 + 2 * t * Real.sqrt (2 - t ^ 2) := by calc (t + Real.sqrt (2 - t ^ 2)) ^ 2 = t ^ 2 + (Real.sqrt (2 - t ^ 2)) ^ 2 + 2 * t * Real.sqrt (2 - t ^ 2) := by ring _ = t ^ 2 + (2 - t ^ 2) + 2 * t * Real.sqrt (2 - t ^ 2) := by -- `ring` rewrites squares as multiplication, so we use `mul_self_sqrt`. simp [pow_two, Real.mul_self_sqrt hts'] _ = 2 + 2 * t * Real.sqrt (2 - t ^ 2) := by ring have hsq : (Real.sqrt 2) ^ 2 ≤ (t + Real.sqrt (2 - t ^ 2)) ^ 2 := by calc (Real.sqrt 2) ^ 2 = (2 : ℝ) := by simp _ ≤ 2 + 2 * t * Real.sqrt (2 - t ^ 2) := by have : 0 ≤ 2 * t * Real.sqrt (2 - t ^ 2) := by nlinarith nlinarith _ = (t + Real.sqrt (2 - t ^ 2)) ^ 2 := by simp [hcalc] have habs : |Real.sqrt 2| ≤ |t + Real.sqrt (2 - t ^ 2)| := (sq_le_sq).1 hsq have hsqrt : 0 ≤ Real.sqrt 2 := by simp simpa [abs_of_nonneg hsqrt, abs_of_nonneg hnonneg] using habs end Inekoalaty