imo.imo2006_q3Archive.Imo.Imo2006Q3

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -40,7 +40,7 @@ namespace imo2006_q3
 theorem lhs_ineq {x y : ℝ} (hxy : 0 ≤ x * y) :
     16 * x ^ 2 * y ^ 2 * (x + y) ^ 2 ≤ ((x + y) ^ 2) ^ 3 :=
   by
-  conv_rhs => rw [pow_succ']
+  conv_rhs => rw [pow_succ]
   refine' mul_le_mul_of_nonneg_right _ (sq_nonneg _)
   apply le_of_sub_nonneg
   calc
Diff
@@ -143,7 +143,7 @@ theorem proof₂ (M : ℝ)
     by intro; ring
   have h₂ : ∀ x : ℝ, (2 - 3 * x) ^ 2 + 2 ^ 2 + (2 + 3 * x) ^ 2 = 18 * x ^ 2 + 12 := by intro; ring
   have := h (2 - 3 * sqrt 2) 2 (2 + 3 * sqrt 2)
-  rw [lhs_identity, h₁, h₂, sq_sqrt zero_le_two, abs_neg, abs_eq_self.mpr, ← div_le_iff] at this 
+  rw [lhs_identity, h₁, h₂, sq_sqrt zero_le_two, abs_neg, abs_eq_self.mpr, ← div_le_iff] at this
   · convert this using 1; ring
   · apply pow_pos; norm_num
   · exact mul_nonneg (mul_nonneg (sq_nonneg _) zero_le_two) (sqrt_nonneg _)
Diff
@@ -84,9 +84,9 @@ theorem subst_wlog {x y z s : ℝ} (hxy : 0 ≤ x * y) (hxyz : x + y + z = 0) :
         le_trans (mul_le_mul_of_nonneg_left (lhs_ineq hxy) hs) mid_ineq
       _ ≤ (2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2) + 2 * s ^ 2) ^ 4 / 4 ^ 4 :=
         div_le_div_of_le four_pow_four_pos.le <|
-          pow_le_pow_of_le_left (add_nonneg (mul_nonneg zero_lt_three.le (sq_nonneg _)) hs)
+          pow_le_pow_left (add_nonneg (mul_nonneg zero_lt_three.le (sq_nonneg _)) hs)
             (add_le_add_right rhs_ineq _) _
-  le_of_pow_le_pow _ (mul_nonneg (sqrt_nonneg _) (sq_nonneg _)) Nat.succ_pos' <|
+  le_of_pow_le_pow_left _ (mul_nonneg (sqrt_nonneg _) (sq_nonneg _)) Nat.succ_pos' <|
     calc
       (32 * |x * y * z * s|) ^ 2 = 32 * (2 * s ^ 2 * (16 * x ^ 2 * y ^ 2 * (x + y) ^ 2)) := by
         rw [mul_pow, sq_abs, hz] <;> ring
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2021 Tian Chen. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Tian Chen
 -/
-import Mathbin.Analysis.SpecialFunctions.Sqrt
+import Analysis.SpecialFunctions.Sqrt
 
 #align_import imo.imo2006_q3 from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
 
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2021 Tian Chen. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Tian Chen
-
-! This file was ported from Lean 3 source module imo.imo2006_q3
-! leanprover-community/mathlib commit 08b081ea92d80e3a41f899eea36ef6d56e0f1db0
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Analysis.SpecialFunctions.Sqrt
 
+#align_import imo.imo2006_q3 from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
+
 /-!
 # IMO 2006 Q3
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Tian Chen
 
 ! This file was ported from Lean 3 source module imo.imo2006_q3
-! leanprover-community/mathlib commit 308826471968962c6b59c7ff82a22757386603e3
+! leanprover-community/mathlib commit 08b081ea92d80e3a41f899eea36ef6d56e0f1db0
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,9 @@ import Mathbin.Analysis.SpecialFunctions.Sqrt
 /-!
 # IMO 2006 Q3
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Determine the least real number $M$ such that
 $$
 \left| ab(a^2 - b^2) + bc(b^2 - c^2) + ca(c^2 - a^2) \right|
Diff
@@ -46,7 +46,6 @@ theorem lhs_ineq {x y : ℝ} (hxy : 0 ≤ x * y) :
   calc
     ((x + y) ^ 2) ^ 2 - 16 * x ^ 2 * y ^ 2 = (x - y) ^ 2 * ((x + y) ^ 2 + 4 * (x * y)) := by ring
     _ ≥ 0 := mul_nonneg (sq_nonneg _) <| add_nonneg (sq_nonneg _) <| mul_nonneg zero_lt_four.le hxy
-    
 #align imo2006_q3.lhs_ineq Imo2006Q3.lhs_ineq
 
 theorem four_pow_four_pos : (0 : ℝ) < 4 ^ 4 :=
@@ -62,7 +61,6 @@ theorem mid_ineq {s t : ℝ} : s * t ^ 3 ≤ (3 * t + s) ^ 4 / 4 ^ 4 :=
         _ ≥ 0 :=
           mul_nonneg (sq_nonneg _) <|
             add_nonneg (sq_nonneg _) <| mul_nonneg zero_le_two (sq_nonneg _)
-        
 #align imo2006_q3.mid_ineq Imo2006Q3.mid_ineq
 
 /-- Replacing `x` and `y` with their average decreases the right side. -/
@@ -71,7 +69,6 @@ theorem rhs_ineq {x y : ℝ} : 3 * (x + y) ^ 2 ≤ 2 * (x ^ 2 + y ^ 2 + (x + y)
     calc
       _ = (x - y) ^ 2 := by ring
       _ ≥ 0 := sq_nonneg _
-      
 #align imo2006_q3.rhs_ineq Imo2006Q3.rhs_ineq
 
 theorem zero_lt_32 : (0 : ℝ) < 32 := by norm_num
@@ -89,7 +86,6 @@ theorem subst_wlog {x y z s : ℝ} (hxy : 0 ≤ x * y) (hxyz : x + y + z = 0) :
         div_le_div_of_le four_pow_four_pos.le <|
           pow_le_pow_of_le_left (add_nonneg (mul_nonneg zero_lt_three.le (sq_nonneg _)) hs)
             (add_le_add_right rhs_ineq _) _
-      
   le_of_pow_le_pow _ (mul_nonneg (sqrt_nonneg _) (sq_nonneg _)) Nat.succ_pos' <|
     calc
       (32 * |x * y * z * s|) ^ 2 = 32 * (2 * s ^ 2 * (16 * x ^ 2 * y ^ 2 * (x + y) ^ 2)) := by
@@ -99,7 +95,6 @@ theorem subst_wlog {x y z s : ℝ} (hxy : 0 ≤ x * y) (hxyz : x + y + z = 0) :
       _ = (sqrt 2 * (x ^ 2 + y ^ 2 + z ^ 2 + s ^ 2) ^ 2) ^ 2 := by
         rw [mul_pow, sq_sqrt zero_le_two, hz, ← pow_mul, ← mul_add, mul_pow, ← mul_comm_div, ←
           mul_assoc, show 32 / 4 ^ 4 * 2 ^ 4 = (2 : ℝ) by norm_num, show 2 * 2 = 4 by rfl]
-      
 #align imo2006_q3.subst_wlog Imo2006Q3.subst_wlog
 
 /-- Proof that `M = 9 * sqrt 2 / 32` works with the substitution. -/
@@ -131,7 +126,6 @@ theorem proof₁ {a b c : ℝ} :
     _ = _ := congr_arg _ <| lhs_identity a b c
     _ ≤ _ := (subst_proof₁ (a - b) (b - c) (c - a) (-(a + b + c)) (by ring))
     _ = _ := by ring
-    
 #align imo2006_q3.proof₁ Imo2006Q3.proof₁
 
 theorem proof₂ (M : ℝ)

Changes in mathlib4

mathlib3
mathlib4
chore: Rename pow monotonicity lemmas (#9095)

The names for lemmas about monotonicity of (a ^ ·) and (· ^ n) were a mess. This PR tidies up everything related by following the naming convention for (a * ·) and (· * b). Namely, (a ^ ·) is pow_right and (· ^ n) is pow_left in lemma names. All lemma renames follow the corresponding multiplication lemma names closely.

Renames

Algebra.GroupPower.Order

  • pow_monopow_right_mono
  • pow_le_powpow_le_pow_right
  • pow_le_pow_of_le_leftpow_le_pow_left
  • pow_lt_pow_of_lt_leftpow_lt_pow_left
  • strictMonoOn_powpow_left_strictMonoOn
  • pow_strictMono_rightpow_right_strictMono
  • pow_lt_powpow_lt_pow_right
  • pow_lt_pow_iffpow_lt_pow_iff_right
  • pow_le_pow_iffpow_le_pow_iff_right
  • self_lt_powlt_self_pow
  • strictAnti_powpow_right_strictAnti
  • pow_lt_pow_iff_of_lt_onepow_lt_pow_iff_right_of_lt_one
  • pow_lt_pow_of_lt_onepow_lt_pow_right_of_lt_one
  • lt_of_pow_lt_powlt_of_pow_lt_pow_left
  • le_of_pow_le_powle_of_pow_le_pow_left
  • pow_lt_pow₀pow_lt_pow_right₀

Algebra.GroupPower.CovariantClass

  • pow_le_pow_of_le_left'pow_le_pow_left'
  • nsmul_le_nsmul_of_le_rightnsmul_le_nsmul_right
  • pow_lt_pow'pow_lt_pow_right'
  • nsmul_lt_nsmulnsmul_lt_nsmul_left
  • pow_strictMono_leftpow_right_strictMono'
  • nsmul_strictMono_rightnsmul_left_strictMono
  • StrictMono.pow_right'StrictMono.pow_const
  • StrictMono.nsmul_leftStrictMono.const_nsmul
  • pow_strictMono_right'pow_left_strictMono
  • nsmul_strictMono_leftnsmul_right_strictMono
  • Monotone.pow_rightMonotone.pow_const
  • Monotone.nsmul_leftMonotone.const_nsmul
  • lt_of_pow_lt_pow'lt_of_pow_lt_pow_left'
  • lt_of_nsmul_lt_nsmullt_of_nsmul_lt_nsmul_right
  • pow_le_pow'pow_le_pow_right'
  • nsmul_le_nsmulnsmul_le_nsmul_left
  • pow_le_pow_of_le_one'pow_le_pow_right_of_le_one'
  • nsmul_le_nsmul_of_nonposnsmul_le_nsmul_left_of_nonpos
  • le_of_pow_le_pow'le_of_pow_le_pow_left'
  • le_of_nsmul_le_nsmul'le_of_nsmul_le_nsmul_right'
  • pow_le_pow_iff'pow_le_pow_iff_right'
  • nsmul_le_nsmul_iffnsmul_le_nsmul_iff_left
  • pow_lt_pow_iff'pow_lt_pow_iff_right'
  • nsmul_lt_nsmul_iffnsmul_lt_nsmul_iff_left

Data.Nat.Pow

  • Nat.pow_lt_pow_of_lt_leftNat.pow_lt_pow_left
  • Nat.pow_le_iff_le_leftNat.pow_le_pow_iff_left
  • Nat.pow_lt_iff_lt_leftNat.pow_lt_pow_iff_left

Lemmas added

  • pow_le_pow_iff_left
  • pow_lt_pow_iff_left
  • pow_right_injective
  • pow_right_inj
  • Nat.pow_le_pow_left to have the correct name since Nat.pow_le_pow_of_le_left is in Std.
  • Nat.pow_le_pow_right to have the correct name since Nat.pow_le_pow_of_le_right is in Std.

Lemmas removed

  • self_le_pow was a duplicate of le_self_pow.
  • Nat.pow_lt_pow_of_lt_right is defeq to pow_lt_pow_right.
  • Nat.pow_right_strictMono is defeq to pow_right_strictMono.
  • Nat.pow_le_iff_le_right is defeq to pow_le_pow_iff_right.
  • Nat.pow_lt_iff_lt_right is defeq to pow_lt_pow_iff_right.

Other changes

  • A bunch of proofs have been golfed.
  • Some lemma assumptions have been turned from 0 < n or 1 ≤ n to n ≠ 0.
  • A few Nat lemmas have been protected.
  • One docstring has been fixed.
Diff
@@ -71,7 +71,7 @@ theorem subst_wlog {x y z s : ℝ} (hxy : 0 ≤ x * y) (hxyz : x + y + z = 0) :
       _ ≤ (2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2) + 2 * s ^ 2) ^ 4 / 4 ^ 4 := by
           gcongr (?_ + _) ^ 4 / _
           apply rhs_ineq
-  refine le_of_pow_le_pow 2 (by positivity) (by positivity) ?_
+  refine le_of_pow_le_pow_left two_ne_zero (by positivity) ?_
   calc
     (32 * |x * y * z * s|) ^ 2 = 32 * (2 * s ^ 2 * (16 * x ^ 2 * y ^ 2 * (x + y) ^ 2)) := by
       rw [mul_pow, sq_abs, hz]; ring
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2021 Tian Chen. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Tian Chen
-
-! This file was ported from Lean 3 source module imo.imo2006_q3
-! leanprover-community/mathlib commit 308826471968962c6b59c7ff82a22757386603e3
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Analysis.SpecialFunctions.Sqrt
 import Mathlib.Tactic.Polyrith
 
+#align_import imo.imo2006_q3 from "leanprover-community/mathlib"@"308826471968962c6b59c7ff82a22757386603e3"
+
 /-!
 # IMO 2006 Q3
 
feat: port Probability.Kernel.Condexp (#5324)
Diff
@@ -9,6 +9,7 @@ Authors: Tian Chen
 ! if you have ported upstream changes.
 -/
 import Mathlib.Analysis.SpecialFunctions.Sqrt
+import Mathlib.Tactic.Polyrith
 
 /-!
 # IMO 2006 Q3
@@ -39,61 +40,49 @@ namespace Imo2006Q3
 /-- Replacing `x` and `y` with their average increases the left side. -/
 theorem lhs_ineq {x y : ℝ} (hxy : 0 ≤ x * y) :
     16 * x ^ 2 * y ^ 2 * (x + y) ^ 2 ≤ ((x + y) ^ 2) ^ 3 := by
-  conv_rhs => rw [pow_succ']
-  refine' mul_le_mul_of_nonneg_right _ (sq_nonneg _)
-  apply le_of_sub_nonneg
-  calc
-    ((x + y) ^ 2) ^ 2 - 16 * x ^ 2 * y ^ 2 = (x - y) ^ 2 * ((x + y) ^ 2 + 4 * (x * y)) := by ring
-    _ ≥ 0 := mul_nonneg (sq_nonneg _) <| add_nonneg (sq_nonneg _) <| mul_nonneg zero_lt_four.le hxy
+  have : (x - y) ^ 2 * ((x + y) ^ 2 + 4 * (x * y)) ≥ 0 := by positivity
+  calc 16 * x ^ 2 * y ^ 2 * (x + y) ^ 2 ≤ ((x + y) ^ 2) ^ 2 * (x + y) ^ 2 := by gcongr; linarith
+    _ = ((x + y) ^ 2) ^ 3 := by ring
 #align imo2006_q3.lhs_ineq Imo2006Q3.lhs_ineq
 
-theorem four_pow_four_pos : (0 : ℝ) < 4 ^ 4 :=
-  pow_pos zero_lt_four _
+theorem four_pow_four_pos : (0 : ℝ) < 4 ^ 4 := by norm_num
 #align imo2006_q3.four_pow_four_pos Imo2006Q3.four_pow_four_pos
 
-theorem mid_ineq {s t : ℝ} : s * t ^ 3 ≤ (3 * t + s) ^ 4 / 4 ^ 4 :=
-  (le_div_iff four_pow_four_pos).mpr <|
-    le_of_sub_nonneg <|
-      calc
-        (3 * t + s) ^ 4 - s * t ^ 3 * 4 ^ 4 = (s - t) ^ 2 * ((s + 7 * t) ^ 2 + 2 * (4 * t) ^ 2) :=
-          by ring
-        _ ≥ 0 :=
-          mul_nonneg (sq_nonneg _) <|
-            add_nonneg (sq_nonneg _) <| mul_nonneg zero_le_two (sq_nonneg _)
+theorem mid_ineq {s t : ℝ} : s * t ^ 3 ≤ (3 * t + s) ^ 4 / 4 ^ 4 := by
+  rw [le_div_iff four_pow_four_pos]
+  have : 0 ≤ (s - t) ^ 2 * ((s + 7 * t) ^ 2 + 2 * (4 * t) ^ 2) := by positivity
+  linarith
 #align imo2006_q3.mid_ineq Imo2006Q3.mid_ineq
 
 /-- Replacing `x` and `y` with their average decreases the right side. -/
-theorem rhs_ineq {x y : ℝ} : 3 * (x + y) ^ 2 ≤ 2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2) :=
-  le_of_sub_nonneg <|
-    calc
-      _ = (x - y) ^ 2 := by ring
-      _ ≥ 0 := sq_nonneg _
+theorem rhs_ineq {x y : ℝ} : 3 * (x + y) ^ 2 ≤ 2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2) := by
+  have : 0 ≤ (x - y) ^ 2 := by positivity
+  linarith
 #align imo2006_q3.rhs_ineq Imo2006Q3.rhs_ineq
 
 theorem zero_lt_32 : (0 : ℝ) < 32 := by norm_num
 #align imo2006_q3.zero_lt_32 Imo2006Q3.zero_lt_32
 
 theorem subst_wlog {x y z s : ℝ} (hxy : 0 ≤ x * y) (hxyz : x + y + z = 0) :
-    32 * |x * y * z * s| ≤ sqrt 2 * (x ^ 2 + y ^ 2 + z ^ 2 + s ^ 2) ^ 2 :=
-  have hz : (x + y) ^ 2 = z ^ 2 := neg_eq_of_add_eq_zero_right hxyz ▸ (neg_sq _).symm
-  have hs : 0 ≤ 2 * s ^ 2 := mul_nonneg zero_le_two (sq_nonneg s)
+    32 * |x * y * z * s| ≤ sqrt 2 * (x ^ 2 + y ^ 2 + z ^ 2 + s ^ 2) ^ 2 := by
+  have hz : (x + y) ^ 2 = z ^ 2 := by linear_combination (x + y - z) * hxyz
   have this :=
     calc
-      2 * s ^ 2 * (16 * x ^ 2 * y ^ 2 * (x + y) ^ 2) ≤ (3 * (x + y) ^ 2 + 2 * s ^ 2) ^ 4 / 4 ^ 4 :=
-        le_trans (mul_le_mul_of_nonneg_left (lhs_ineq hxy) hs) mid_ineq
-      _ ≤ (2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2) + 2 * s ^ 2) ^ 4 / 4 ^ 4 :=
-        div_le_div_of_le four_pow_four_pos.le <|
-          pow_le_pow_of_le_left (add_nonneg (mul_nonneg zero_lt_three.le (sq_nonneg _)) hs)
-            (add_le_add_right rhs_ineq _) _
-  le_of_pow_le_pow _ (mul_nonneg (sqrt_nonneg _) (sq_nonneg _)) Nat.succ_pos' <|
-    calc
-      (32 * |x * y * z * s|) ^ 2 = 32 * (2 * s ^ 2 * (16 * x ^ 2 * y ^ 2 * (x + y) ^ 2)) := by
-        rw [mul_pow, sq_abs, hz]; ring
-      _ ≤ 32 * ((2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2) + 2 * s ^ 2) ^ 4 / 4 ^ 4) :=
-        (mul_le_mul_of_nonneg_left this zero_lt_32.le)
-      _ = (sqrt 2 * (x ^ 2 + y ^ 2 + z ^ 2 + s ^ 2) ^ 2) ^ 2 := by
-        rw [mul_pow, sq_sqrt zero_le_two, hz, ← pow_mul, ← mul_add, mul_pow, ← mul_comm_div,
-          ← mul_assoc, show 32 / 4 ^ 4 * 2 ^ 4 = (2 : ℝ) by norm_num, show 2 * 2 = 4 by rfl]
+      2 * s ^ 2 * (16 * x ^ 2 * y ^ 2 * (x + y) ^ 2)
+        ≤ _ * _ ^ 3 := by gcongr; exact lhs_ineq hxy
+      _ ≤ (3 * (x + y) ^ 2 + 2 * s ^ 2) ^ 4 / 4 ^ 4 := mid_ineq
+      _ ≤ (2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2) + 2 * s ^ 2) ^ 4 / 4 ^ 4 := by
+          gcongr (?_ + _) ^ 4 / _
+          apply rhs_ineq
+  refine le_of_pow_le_pow 2 (by positivity) (by positivity) ?_
+  calc
+    (32 * |x * y * z * s|) ^ 2 = 32 * (2 * s ^ 2 * (16 * x ^ 2 * y ^ 2 * (x + y) ^ 2)) := by
+      rw [mul_pow, sq_abs, hz]; ring
+    _ ≤ 32 * ((2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2) + 2 * s ^ 2) ^ 4 / 4 ^ 4) := by gcongr
+    _ = (sqrt 2 * (x ^ 2 + y ^ 2 + z ^ 2 + s ^ 2) ^ 2) ^ 2 := by
+      field_simp
+      rw [mul_pow, sq_sqrt zero_le_two, hz]
+      ring
 #align imo2006_q3.subst_wlog Imo2006Q3.subst_wlog
 
 /-- Proof that `M = 9 * sqrt 2 / 32` works with the substitution. -/
@@ -103,26 +92,16 @@ theorem subst_proof₁ (x y z s : ℝ) (hxyz : x + y + z = 0) :
   · rw [div_mul_eq_mul_div, le_div_iff' zero_lt_32]
     exact subst_wlog h' hxyz
   cases' (mul_nonneg_of_three x y z).resolve_left h' with h h
-  · specialize this y z x _ h
-    · rw [← hxyz]; ring
-    · convert this using 2 <;> ring
-  · specialize this z x y _ h
-    · rw [← hxyz]; ring
-    · convert this using 2 <;> ring
+  · convert this y z x _ h using 2 <;> linarith
+  · convert this z x y _ h using 2 <;> linarith
 #align imo2006_q3.subst_proof₁ Imo2006Q3.subst_proof₁
 
-theorem lhs_identity (a b c : ℝ) :
-    a * b * (a ^ 2 - b ^ 2) + b * c * (b ^ 2 - c ^ 2) + c * a * (c ^ 2 - a ^ 2) =
-      (a - b) * (b - c) * (c - a) * -(a + b + c) :=
-  by ring
-#align imo2006_q3.lhs_identity Imo2006Q3.lhs_identity
-
 theorem proof₁ {a b c : ℝ} :
     |a * b * (a ^ 2 - b ^ 2) + b * c * (b ^ 2 - c ^ 2) + c * a * (c ^ 2 - a ^ 2)| ≤
       9 * sqrt 2 / 32 * (a ^ 2 + b ^ 2 + c ^ 2) ^ 2 :=
   calc
-    _ = _ := congr_arg _ <| lhs_identity a b c
-    _ ≤ _ := (subst_proof₁ (a - b) (b - c) (c - a) (-(a + b + c)) (by ring))
+    _ = |(a - b) * (b - c) * (c - a) * -(a + b + c)| := by ring_nf
+    _ ≤ _ := subst_proof₁ (a - b) (b - c) (c - a) (-(a + b + c)) (by ring)
     _ = _ := by ring
 #align imo2006_q3.proof₁ Imo2006Q3.proof₁
 
@@ -131,18 +110,19 @@ theorem proof₂ (M : ℝ)
       |a * b * (a ^ 2 - b ^ 2) + b * c * (b ^ 2 - c ^ 2) + c * a * (c ^ 2 - a ^ 2)| ≤
         M * (a ^ 2 + b ^ 2 + c ^ 2) ^ 2) :
     9 * sqrt 2 / 32 ≤ M := by
-  have h₁ :
-    ∀ x : ℝ,
-      (2 - 3 * x - 2) * (2 - (2 + 3 * x)) * (2 + 3 * x - (2 - 3 * x)) *
-          -(2 - 3 * x + 2 + (2 + 3 * x)) =
-        -(18 ^ 2 * x ^ 2 * x) :=
-    by intro; ring
-  have h₂ : ∀ x : ℝ, (2 - 3 * x) ^ 2 + 2 ^ 2 + (2 + 3 * x) ^ 2 = 18 * x ^ 2 + 12 := by intro; ring
-  have := h (2 - 3 * sqrt 2) 2 (2 + 3 * sqrt 2)
-  rw [lhs_identity, h₁, h₂, sq_sqrt zero_le_two, abs_neg, abs_eq_self.mpr, ← div_le_iff] at this
-  · convert this using 1; ring
-  · apply pow_pos; norm_num
-  · exact mul_nonneg (mul_nonneg (sq_nonneg _) zero_le_two) (sqrt_nonneg _)
+  set α := sqrt (2:ℝ)
+  have hα : α ^ 2 = 2 := sq_sqrt (by norm_num)
+  let a := 2 - 3 * α
+  let c := 2 + 3 * α
+  calc _ = 18 ^ 2 * 2 * α / 48 ^ 2 := by ring
+    _ ≤ M := ?_
+  rw [div_le_iff (by positivity)]
+  calc 18 ^ 2 * 2 * α
+      = 18 ^ 2 * α ^ 2 * α := by linear_combination -324 * α * hα
+    _ = abs (-(18 ^ 2 * α ^ 2 * α)) := by rw [abs_neg, abs_of_nonneg]; positivity
+    _ = |a * 2 * (a ^ 2 - 2 ^ 2) + 2 * c * (2 ^ 2 - c ^ 2) + c * a * (c ^ 2 - a ^ 2)| := by ring_nf
+    _ ≤ M * (a ^ 2 + 2 ^ 2 + c ^ 2) ^ 2 := by apply h
+    _ = M * 48 ^ 2 := by linear_combination (324 * α ^ 2 + 1080) * M * hα
 #align imo2006_q3.proof₂ Imo2006Q3.proof₂
 
 end Imo2006Q3
@@ -154,5 +134,5 @@ theorem imo2006_q3 (M : ℝ) :
         |a * b * (a ^ 2 - b ^ 2) + b * c * (b ^ 2 - c ^ 2) + c * a * (c ^ 2 - a ^ 2)| ≤
           M * (a ^ 2 + b ^ 2 + c ^ 2) ^ 2) ↔
       9 * sqrt 2 / 32 ≤ M :=
-  ⟨proof₂ M, fun h _ _ _ => le_trans proof₁ <| mul_le_mul_of_nonneg_right h <| sq_nonneg _⟩
+  ⟨proof₂ M, fun h _ _ _ => proof₁.trans (by gcongr)⟩
 #align imo2006_q3 imo2006_q3
feat: port CategoryTheory.Monoidal.Internal.Limits (#5150)

Dependencies 12 + 874

875 files ported (98.6%)
386517 lines ported (98.6%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file