imo.imo2013_q5Archive.Imo.Imo2013Q5

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
@@ -110,7 +110,7 @@ theorem f_pos_of_pos {f : ℚ → ℝ} {q : ℚ} (hq : 0 < q)
     calc
       (0 : ℝ) < q.num := int.cast_pos.mpr num_pos
       _ = ((q.num.nat_abs : ℤ) : ℝ) := (congr_arg coe (Int.natAbs_of_nonneg num_pos.le).symm)
-      _ ≤ f q.num.nat_abs := (H4 q.num.nat_abs (Int.natAbs_pos_of_ne_zero num_pos.ne'))
+      _ ≤ f q.num.nat_abs := (H4 q.num.nat_abs (Int.natAbs_pos num_pos.ne'))
       _ = f q.num := by rw [Nat.cast_natAbs, abs_of_nonneg num_pos.le]
       _ = f (q * q.denom) := by rw [← Rat.mul_den_eq_num]
       _ ≤ f q * f q.denom := H1 q q.denom hq (nat.cast_pos.mpr q.pos)
@@ -147,7 +147,7 @@ theorem pow_f_le_f_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n) {x : ℚ} (hx :
   cases pn
   · simp only [pow_one]
   have hpn' := hpn pn.succ_pos
-  rw [pow_succ' x (pn + 1), pow_succ' (f x) (pn + 1)]
+  rw [pow_succ x (pn + 1), pow_succ (f x) (pn + 1)]
   have hxp : 0 < x := by positivity
   calc
     f (x ^ (pn + 1) * x) ≤ f (x ^ (pn + 1)) * f x := H1 (x ^ (pn + 1)) x (pow_pos hxp (pn + 1)) hxp
@@ -260,7 +260,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
         have :=
           fixed_point_of_gt_1 (nat.one_lt_cast.mpr (Nat.succ_lt_succ n.succ_pos)) H1 H2 H4 H5 ha1
             hae
-        rwa [Rat.cast_coe_nat n.succ.succ] at this
+        rwa [Rat.cast_natCast n.succ.succ] at this
       rw [← hfneq]
       exact H1 (n.succ.succ : ℚ) x (nat.cast_pos.mpr hn) hx
     exact h2.antisymm (H3 x hx n hn)
@@ -292,7 +292,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
     have hx2num_gt_one : (1 : ℚ) < (2 * x.num : ℤ) := by norm_cast;
       linarith [rat.num_pos_iff_pos.mpr hx]
     have hh := fixed_point_of_gt_1 hx2num_gt_one H1 H2 H4 H5 ha1 hae
-    rwa [Rat.cast_coe_int x2num] at hh
+    rwa [Rat.cast_intCast x2num] at hh
   calc
     f x = f x * 1 := (mul_one (f x)).symm
     _ = f x * (x2denom / x2denom) := by rw [← div_self hx2cnezr]
Diff
@@ -131,7 +131,7 @@ theorem fx_gt_xm1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 ≤ x)
       (x - 1 : ℝ) < ⌊x⌋₊ := by exact_mod_cast Nat.sub_one_lt_floor x
       _ ≤ f ⌊x⌋₊ := H4 _ (Nat.floor_pos.2 hx)
   obtain h_eq | h_lt := (Nat.floor_le <| zero_le_one.trans hx).eq_or_lt
-  · rwa [h_eq] at hx0 
+  · rwa [h_eq] at hx0
   calc
     (x - 1 : ℝ) < f ⌊x⌋₊ := hx0
     _ < f (x - ⌊x⌋₊) + f ⌊x⌋₊ := (lt_add_of_pos_left _ (f_pos_of_pos (sub_pos.mpr h_lt) H1 H4))
@@ -180,7 +180,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
       (x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := add_le_add_right (H5 x hx) _
       _ ≤ f x + f (a ^ N - x) := add_le_add_left (H5 _ h_big_enough) _
   have hxp : 0 < x := by positivity
-  have hNp : 0 < N := by by_contra! H; rw [le_zero_iff.mp H] at hN ; linarith
+  have hNp : 0 < N := by by_contra! H; rw [le_zero_iff.mp H] at hN; linarith
   have h2 :=
     calc
       f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) :=
@@ -260,7 +260,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
         have :=
           fixed_point_of_gt_1 (nat.one_lt_cast.mpr (Nat.succ_lt_succ n.succ_pos)) H1 H2 H4 H5 ha1
             hae
-        rwa [Rat.cast_coe_nat n.succ.succ] at this 
+        rwa [Rat.cast_coe_nat n.succ.succ] at this
       rw [← hfneq]
       exact H1 (n.succ.succ : ℚ) x (nat.cast_pos.mpr hn) hx
     exact h2.antisymm (H3 x hx n hn)
@@ -292,7 +292,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
     have hx2num_gt_one : (1 : ℚ) < (2 * x.num : ℤ) := by norm_cast;
       linarith [rat.num_pos_iff_pos.mpr hx]
     have hh := fixed_point_of_gt_1 hx2num_gt_one H1 H2 H4 H5 ha1 hae
-    rwa [Rat.cast_coe_int x2num] at hh 
+    rwa [Rat.cast_coe_int x2num] at hh
   calc
     f x = f x * 1 := (mul_one (f x)).symm
     _ = f x * (x2denom / x2denom) := by rw [← div_self hx2cnezr]
Diff
@@ -98,7 +98,7 @@ theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
     intro n hn
     calc
       x ^ n - 1 < y ^ n := h n hn
-      _ ≤ y' ^ n := pow_le_pow_of_le_left hy.le h_y_lt_y'.le n
+      _ ≤ y' ^ n := pow_le_pow_left hy.le h_y_lt_y'.le n
   exact h_y'_lt_x.not_le (le_of_all_pow_lt_succ hx h1_lt_y' hh)
 #align imo2013_q5.le_of_all_pow_lt_succ' Imo2013Q5.le_of_all_pow_lt_succ'
 
Diff
@@ -39,7 +39,7 @@ namespace imo2013_q5
 theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
     (h : ∀ n : ℕ, 0 < n → x ^ n - 1 < y ^ n) : x ≤ y :=
   by
-  by_contra' hxy
+  by_contra! hxy
   have hxmy : 0 < x - y := sub_pos.mpr hxy
   have hn : ∀ n : ℕ, 0 < n → (x - y) * (n : ℝ) ≤ x ^ n - y ^ n :=
     by
@@ -77,7 +77,7 @@ theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
     (h : ∀ n : ℕ, 0 < n → x ^ n - 1 < y ^ n) : x ≤ y :=
   by
   refine' le_of_all_pow_lt_succ hx _ h
-  by_contra' hy'' : y ≤ 1
+  by_contra! hy'' : y ≤ 1
   -- Then there exists y' such that 0 < y ≤ 1 < y' < x.
   let y' := (x + 1) / 2
   have h_y'_lt_x : y' < x :=
@@ -180,7 +180,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
       (x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := add_le_add_right (H5 x hx) _
       _ ≤ f x + f (a ^ N - x) := add_le_add_left (H5 _ h_big_enough) _
   have hxp : 0 < x := by positivity
-  have hNp : 0 < N := by by_contra' H; rw [le_zero_iff.mp H] at hN ; linarith
+  have hNp : 0 < N := by by_contra! H; rw [le_zero_iff.mp H] at hN ; linarith
   have h2 :=
     calc
       f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) :=
Diff
@@ -3,10 +3,10 @@ Copyright (c) 2021 David Renshaw. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: David Renshaw
 -/
-import Mathbin.Algebra.GeomSum
-import Mathbin.Data.Rat.Defs
-import Mathbin.Data.Real.Basic
-import Mathbin.Tactic.Positivity
+import Algebra.GeomSum
+import Data.Rat.Defs
+import Data.Real.Basic
+import Tactic.Positivity
 
 #align_import imo.imo2013_q5 from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
 
Diff
@@ -2,17 +2,14 @@
 Copyright (c) 2021 David Renshaw. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: David Renshaw
-
-! This file was ported from Lean 3 source module imo.imo2013_q5
-! 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.Algebra.GeomSum
 import Mathbin.Data.Rat.Defs
 import Mathbin.Data.Real.Basic
 import Mathbin.Tactic.Positivity
 
+#align_import imo.imo2013_q5 from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
+
 /-!
 # IMO 2013 Q5
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: David Renshaw
 
 ! This file was ported from Lean 3 source module imo.imo2013_q5
-! 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.
 -/
@@ -16,6 +16,9 @@ import Mathbin.Tactic.Positivity
 /-!
 # IMO 2013 Q5
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Let `ℚ>₀` be the positive rational numbers. Let `f : ℚ>₀ → ℝ` be a function satisfying
 the conditions
 
Diff
@@ -53,7 +53,6 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
         1 ≤ x ^ i := hx'
         _ = x ^ i * 1 := (mul_one _).symm
         _ ≤ x ^ i * y ^ (n - 1 - i) := mul_le_mul_of_nonneg_left hy' (zero_le_one.trans hx')
-        
     calc
       (x - y) * (n : ℝ) = (n : ℝ) * (x - y) := mul_comm _ _
       _ = (∑ i : ℕ in Finset.range n, (1 : ℝ)) * (x - y) := by
@@ -61,7 +60,6 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
       _ ≤ (∑ i : ℕ in Finset.range n, x ^ i * y ^ (n - 1 - i)) * (x - y) :=
         ((mul_le_mul_right hxmy).mpr (Finset.sum_le_sum hterm))
       _ = x ^ n - y ^ n := geom_sum₂_mul x y n
-      
   -- Choose n larger than 1 / (x - y).
   obtain ⟨N, hN⟩ := exists_nat_gt (1 / (x - y))
   have hNp : 0 < N := by exact_mod_cast (one_div_pos.mpr hxmy).trans hN
@@ -70,7 +68,6 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
       1 = (x - y) * (1 / (x - y)) := by field_simp [ne_of_gt hxmy]
       _ < (x - y) * N := ((mul_lt_mul_left hxmy).mpr hN)
       _ ≤ x ^ N - y ^ N := hn N hNp
-      
   linarith [h N hNp]
 #align imo2013_q5.le_of_all_pow_lt_succ Imo2013Q5.le_of_all_pow_lt_succ
 
@@ -89,14 +86,12 @@ theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
     calc
       y' < x * 2 / 2 := hh
       _ = x := by field_simp
-      
   have h1_lt_y' : 1 < y' :=
     by
     have hh' : 1 * 2 / 2 < (x + 1) / 2 := by linarith
     calc
       1 = 1 * 2 / 2 := by field_simp
       _ < y' := hh'
-      
   have h_y_lt_y' : y < y' := hy''.trans_lt h1_lt_y'
   have hh : ∀ n, 0 < n → x ^ n - 1 < y' ^ n :=
     by
@@ -104,7 +99,6 @@ theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
     calc
       x ^ n - 1 < y ^ n := h n hn
       _ ≤ y' ^ n := pow_le_pow_of_le_left hy.le h_y_lt_y'.le n
-      
   exact h_y'_lt_x.not_le (le_of_all_pow_lt_succ hx h1_lt_y' hh)
 #align imo2013_q5.le_of_all_pow_lt_succ' Imo2013Q5.le_of_all_pow_lt_succ'
 
@@ -120,12 +114,10 @@ theorem f_pos_of_pos {f : ℚ → ℝ} {q : ℚ} (hq : 0 < q)
       _ = f q.num := by rw [Nat.cast_natAbs, abs_of_nonneg num_pos.le]
       _ = f (q * q.denom) := by rw [← Rat.mul_den_eq_num]
       _ ≤ f q * f q.denom := H1 q q.denom hq (nat.cast_pos.mpr q.pos)
-      
   have h_f_denom_pos :=
     calc
       (0 : ℝ) < q.denom := nat.cast_pos.mpr q.pos
       _ ≤ f q.denom := H4 q.denom q.pos
-      
   exact pos_of_mul_pos_left hmul_pos h_f_denom_pos.le
 #align imo2013_q5.f_pos_of_pos Imo2013Q5.f_pos_of_pos
 
@@ -138,7 +130,6 @@ theorem fx_gt_xm1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 ≤ x)
     calc
       (x - 1 : ℝ) < ⌊x⌋₊ := by exact_mod_cast Nat.sub_one_lt_floor x
       _ ≤ f ⌊x⌋₊ := H4 _ (Nat.floor_pos.2 hx)
-      
   obtain h_eq | h_lt := (Nat.floor_le <| zero_le_one.trans hx).eq_or_lt
   · rwa [h_eq] at hx0 
   calc
@@ -146,7 +137,6 @@ theorem fx_gt_xm1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 ≤ x)
     _ < f (x - ⌊x⌋₊) + f ⌊x⌋₊ := (lt_add_of_pos_left _ (f_pos_of_pos (sub_pos.mpr h_lt) H1 H4))
     _ ≤ f (x - ⌊x⌋₊ + ⌊x⌋₊) := (H2 _ _ (sub_pos.mpr h_lt) (Nat.cast_pos.2 (Nat.floor_pos.2 hx)))
     _ = f x := by rw [sub_add_cancel]
-    
 #align imo2013_q5.fx_gt_xm1 Imo2013Q5.fx_gt_xm1
 
 theorem pow_f_le_f_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n) {x : ℚ} (hx : 1 < x)
@@ -162,7 +152,6 @@ theorem pow_f_le_f_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n) {x : ℚ} (hx :
   calc
     f (x ^ (pn + 1) * x) ≤ f (x ^ (pn + 1)) * f x := H1 (x ^ (pn + 1)) x (pow_pos hxp (pn + 1)) hxp
     _ ≤ f x ^ (pn + 1) * f x := (mul_le_mul_right (f_pos_of_pos hxp H1 H4)).mpr hpn'
-    
 #align imo2013_q5.pow_f_le_f_pow Imo2013Q5.pow_f_le_f_pow
 
 theorem fixed_point_of_pos_nat_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n)
@@ -175,7 +164,6 @@ theorem fixed_point_of_pos_nat_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n)
     calc
       f (a ^ n) ≤ f a ^ n := pow_f_le_f_pow hn ha1 H1 H4
       _ = (a : ℝ) ^ n := by rw [← hae]
-      
   exact hh1.antisymm hh0
 #align imo2013_q5.fixed_point_of_pos_nat_pow Imo2013Q5.fixed_point_of_pos_nat_pow
 
@@ -191,7 +179,6 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
     calc
       (x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := add_le_add_right (H5 x hx) _
       _ ≤ f x + f (a ^ N - x) := add_le_add_left (H5 _ h_big_enough) _
-      
   have hxp : 0 < x := by positivity
   have hNp : 0 < N := by by_contra' H; rw [le_zero_iff.mp H] at hN ; linarith
   have h2 :=
@@ -201,7 +188,6 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
       _ = f (a ^ N) := by ring_nf
       _ = a ^ N := (fixed_point_of_pos_nat_pow hNp H1 H4 H5 ha1 hae)
       _ = x + (a ^ N - x) := by ring
-      
   have heq := h1.antisymm (by exact_mod_cast h2)
   linarith [H5 x hx, H5 _ h_big_enough]
 #align imo2013_q5.fixed_point_of_gt_1 Imo2013Q5.fixed_point_of_gt_1
@@ -230,7 +216,6 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
       _ = f ((↑pn + 1) * x + 1 * x) := by rw [one_mul]
       _ = f ((↑pn + 1 + 1) * x) := (congr_arg f (add_mul (↑pn + 1) 1 x).symm)
       _ = f (↑(pn + 2) * x) := by norm_cast
-      
   have H4 : ∀ n : ℕ, 0 < n → (n : ℝ) ≤ f n :=
     by
     intro n hn
@@ -244,13 +229,11 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
         _ = f (a * 1) := by rw [mul_one]
         _ ≤ f a * f 1 := ((H1 a 1) (zero_lt_one.trans ha1) zero_lt_one)
         _ = ↑a * f 1 := by rw [hae]
-        
     calc
       (n : ℝ) = (n : ℝ) * 1 := (mul_one _).symm
       _ ≤ (n : ℝ) * f 1 := (mul_le_mul_of_nonneg_left hf1 (Nat.cast_nonneg _))
       _ ≤ f (n * 1) := (H3 1 zero_lt_one n hn)
       _ = f n := by rw [mul_one]
-      
   have H5 : ∀ x : ℚ, 1 < x → (x : ℝ) ≤ f x :=
     by
     intro x hx
@@ -261,7 +244,6 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
         (x : ℝ) ^ n - 1 < f (x ^ n) := by
           exact_mod_cast fx_gt_xm1 (one_le_pow_of_one_le hx.le n) H1 H2 H4
         _ ≤ f x ^ n := pow_f_le_f_pow hn hx H1 H4
-        
     have hx' : 1 < (x : ℝ) := by exact_mod_cast hx
     have hxp : 0 < x := by positivity
     exact le_of_all_pow_lt_succ' hx' (f_pos_of_pos hxp H1 H4) hxnm1
@@ -293,21 +275,18 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
       0 < x.denom := x.pos
       _ < x.denom + x.denom := (lt_add_of_pos_left x.denom x.pos)
       _ = 2 * x.denom := by ring
-      
   have hxcnez : (x.denom : ℚ) ≠ (0 : ℚ) := ne_of_gt (nat.cast_pos.mpr x.pos)
   have hx2cnezr : (x2denom : ℝ) ≠ (0 : ℝ) := nat.cast_ne_zero.mpr (ne_of_gt hx2pos)
   have hrat_expand2 :=
     calc
       x = x.num / x.denom := by exact_mod_cast rat.num_denom.symm
       _ = x2num / x2denom := by field_simp [-Rat.num_div_den]; linarith
-      
   have h_denom_times_fx :=
     calc
       (x2denom : ℝ) * f x = f (x2denom * x) :=
         (h_f_commutes_with_pos_nat_mul x2denom hx2pos x hx).symm
       _ = f (x2denom * (x2num / x2denom)) := by rw [hrat_expand2]
       _ = f x2num := by congr; field_simp; ring
-      
   have h_fx2num_fixed : f x2num = x2num :=
     by
     have hx2num_gt_one : (1 : ℚ) < (2 * x.num : ℤ) := by norm_cast;
@@ -323,6 +302,5 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
     _ = x2num / x2denom := by rw [h_fx2num_fixed]
     _ = (((x2num : ℚ) / (x2denom : ℚ) : ℚ) : ℝ) := by norm_cast
     _ = x := by rw [← hrat_expand2]
-    
 #align imo2013_q5 imo2013_q5
 

Changes in mathlib4

mathlib3
mathlib4
chore: superfluous parentheses part 2 (#12131)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -95,7 +95,7 @@ theorem f_pos_of_pos {f : ℚ → ℝ} {q : ℚ} (hq : 0 < q)
   have hmul_pos :=
     calc
       (0 : ℝ) < q.num := Int.cast_pos.mpr num_pos
-      _ = ((q.num.natAbs : ℤ) : ℝ) := (congr_arg Int.cast (Int.natAbs_of_nonneg num_pos.le).symm)
+      _ = ((q.num.natAbs : ℤ) : ℝ) := congr_arg Int.cast (Int.natAbs_of_nonneg num_pos.le).symm
       _ ≤ f q.num.natAbs := (H4 q.num.natAbs ((@Int.natAbs_pos q.num).mpr num_pos.ne.symm))
       _ = f q.num := by rw [Nat.cast_natAbs, abs_of_nonneg num_pos.le]
       _ = f (q * q.den) := by rw [← Rat.mul_den_eq_num]
@@ -168,7 +168,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
     calc
       f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) := H2 x (a ^ N - x) hxp (by positivity)
       _ = f (a ^ N) := by ring_nf
-      _ = a ^ N := (fixed_point_of_pos_nat_pow hNp H1 H4 H5 ha1 hae)
+      _ = a ^ N := fixed_point_of_pos_nat_pow hNp H1 H4 H5 ha1 hae
       _ = x + (a ^ N - x) := by ring
   have heq := h1.antisymm (mod_cast h2)
   linarith [H5 x hx, H5 _ h_big_enough]
@@ -204,12 +204,12 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
         ↑a * 1 = ↑a := mul_one (a : ℝ)
         _ = f a := hae.symm
         _ = f (a * 1) := by rw [mul_one]
-        _ ≤ f a * f 1 := ((H1 a 1) (zero_lt_one.trans ha1) zero_lt_one)
+        _ ≤ f a * f 1 := (H1 a 1) (zero_lt_one.trans ha1) zero_lt_one
         _ = ↑a * f 1 := by rw [hae]
     calc
       (n : ℝ) = (n : ℝ) * 1 := (mul_one _).symm
       _ ≤ (n : ℝ) * f 1 := by gcongr
-      _ ≤ f (n * 1) := (H3 1 zero_lt_one n hn)
+      _ ≤ f (n * 1) := H3 1 zero_lt_one n hn
       _ = f n := by rw [mul_one]
   have H5 : ∀ x : ℚ, 1 < x → (x : ℝ) ≤ f x := by
     intro x hx
chore: Reduce scope of LinearOrderedCommGroupWithZero (#11716)

Reconstitute the file Algebra.Order.Monoid.WithZero from three files:

  • Algebra.Order.Monoid.WithZero.Defs
  • Algebra.Order.Monoid.WithZero.Basic
  • Algebra.Order.WithZero

Avoid importing it in many files. Most uses were just to get le_zero_iff to work on Nat.

Before pre_11716

After post_11716

Diff
@@ -163,7 +163,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
       (x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := by gcongr; exact H5 x hx
       _ ≤ f x + f (a ^ N - x) := by gcongr; exact H5 _ h_big_enough
   have hxp : 0 < x := by positivity
-  have hNp : 0 < N := by by_contra! H; rw [le_zero_iff.mp H] at hN; linarith
+  have hNp : 0 < N := by by_contra! H; rw [Nat.le_zero.mp H] at hN; linarith
   have h2 :=
     calc
       f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) := H2 x (a ^ N - x) hxp (by positivity)
change the order of operation in zsmulRec and nsmulRec (#11451)

We change the following field in the definition of an additive commutative monoid:

 nsmul_succ : ∀ (n : ℕ) (x : G),
-  AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
+  AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x

where the latter is more natural

We adjust the definitions of ^ in monoids, groups, etc. Originally there was a warning comment about why this natural order was preferred

use x * npowRec n x and not npowRec n x * x in the definition to make sure that definitional unfolding of npowRec is blocked, to avoid deep recursion issues.

but it seems to no longer apply.

Remarks on the PR :

  • pow_succ and pow_succ' have switched their meanings.
  • Most of the time, the proofs were adjusted by priming/unpriming one lemma, or exchanging left and right; a few proofs were more complicated to adjust.
  • In particular, [Mathlib/NumberTheory/RamificationInertia.lean] used Ideal.IsPrime.mul_mem_pow which is defined in [Mathlib/RingTheory/DedekindDomain/Ideal.lean]. Changing the order of operation forced me to add the symmetric lemma Ideal.IsPrime.mem_pow_mul.
  • the docstring for Cauchy condensation test in [Mathlib/Analysis/PSeries.lean] was mathematically incorrect, I added the mention that the function is antitone.
Diff
@@ -132,7 +132,7 @@ theorem pow_f_le_f_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n) {x : ℚ} (hx :
   cases' pn with pn
   · norm_num
   have hpn' := hpn pn.succ_pos
-  rw [pow_succ' x (pn + 1), pow_succ' (f x) (pn + 1)]
+  rw [pow_succ x (pn + 1), pow_succ (f x) (pn + 1)]
   have hxp : 0 < x := by positivity
   calc
     f (x ^ (pn + 1) * x) ≤ f (x ^ (pn + 1)) * f x := H1 (x ^ (pn + 1)) x (pow_pos hxp (pn + 1)) hxp
chore: Rename cat_coe_nat/cast_coe_int to cast_natCast/cast_intCast (#11552)

Reduce the diff of #11499

Diff
@@ -233,7 +233,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
         have :=
           fixed_point_of_gt_1 (Nat.one_lt_cast.mpr (Nat.succ_lt_succ n.succ_pos)) H1 H2 H4 H5 ha1
             hae
-        rwa [Rat.cast_coe_nat n.succ.succ] at this
+        rwa [Rat.cast_natCast n.succ.succ] at this
       rw [← hfneq]
       exact H1 (n.succ.succ : ℚ) x (Nat.cast_pos.mpr hn) hx
     exact h2.antisymm (H3 x hx n hn)
feat: positivity extension for Rat.num, Rat.den (#10218)

and rename num_nonneg_iff_zero_le to num_nonneg, num_pos_iff_pos to num_pos

From LeanAPAP

Diff
@@ -91,7 +91,7 @@ theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
 theorem f_pos_of_pos {f : ℚ → ℝ} {q : ℚ} (hq : 0 < q)
     (H1 : ∀ x y, 0 < x → 0 < y → f (x * y) ≤ f x * f y) (H4 : ∀ n : ℕ, 0 < n → (n : ℝ) ≤ f n) :
     0 < f q := by
-  have num_pos : 0 < q.num := Rat.num_pos_iff_pos.mpr hq
+  have num_pos : 0 < q.num := Rat.num_pos.mpr hq
   have hmul_pos :=
     calc
       (0 : ℝ) < q.num := Int.cast_pos.mpr num_pos
@@ -248,7 +248,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
   have := x.pos
   have hx2pos : 0 < 2 * x.den := by positivity
   have hx2cnezr : (x2denom : ℝ) ≠ (0 : ℝ) := by positivity
-  have : 0 < x.num := by rwa [Rat.num_pos_iff_pos]
+  have : 0 < x.num := by rwa [Rat.num_pos]
   have hx2num_gt_one : (1 : ℚ) < (2 * x.num : ℤ) := by norm_cast; linarith
   apply mul_left_cancel₀ hx2cnezr
   calc
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -39,8 +39,8 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
   have hxmy : 0 < x - y := sub_pos.mpr hxy
   have hn : ∀ n : ℕ, 0 < n → (x - y) * (n : ℝ) ≤ x ^ n - y ^ n := by
     intro n _
-    have hterm : ∀ i : ℕ, i ∈ Finset.range n → 1 ≤ x ^ i * y ^ (n - 1 - i)
-    · intro i _
+    have hterm : ∀ i : ℕ, i ∈ Finset.range n → 1 ≤ x ^ i * y ^ (n - 1 - i) := by
+      intro i _
       calc
         1 ≤ x ^ i := one_le_pow_of_one_le hx.le i
         _ = x ^ i * 1 := by ring
@@ -80,8 +80,8 @@ theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
       1 = 1 * 2 / 2 := by field_simp
       _ < (x + 1) / 2 := by linarith
   have h_y_lt_y' : y < y' := by linarith
-  have hh : ∀ n, 0 < n → x ^ n - 1 < y' ^ n
-  · intro n hn
+  have hh : ∀ n, 0 < n → x ^ n - 1 < y' ^ n := by
+    intro n hn
     calc
       x ^ n - 1 < y ^ n := h n hn
       _ ≤ y' ^ n := by gcongr
@@ -199,7 +199,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
     intro n hn
     have hf1 : 1 ≤ f 1 := by
       have a_pos : (0 : ℝ) < a := Rat.cast_pos.mpr (zero_lt_one.trans ha1)
-      suffices : ↑a * 1 ≤ ↑a * f 1; rwa [← mul_le_mul_left a_pos]
+      suffices ↑a * 1 ≤ ↑a * f 1 by rwa [← mul_le_mul_left a_pos]
       calc
         ↑a * 1 = ↑a := mul_one (a : ℝ)
         _ = f a := hae.symm
chore: rename by_contra' to by_contra! (#8797)

To fit with the "please try harder" convention of ! tactics.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -35,7 +35,7 @@ namespace Imo2013Q5
 
 theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
     (h : ∀ n : ℕ, 0 < n → x ^ n - 1 < y ^ n) : x ≤ y := by
-  by_contra' hxy
+  by_contra! hxy
   have hxmy : 0 < x - y := sub_pos.mpr hxy
   have hn : ∀ n : ℕ, 0 < n → (x - y) * (n : ℝ) ≤ x ^ n - y ^ n := by
     intro n _
@@ -68,7 +68,7 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
 theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
     (h : ∀ n : ℕ, 0 < n → x ^ n - 1 < y ^ n) : x ≤ y := by
   refine' le_of_all_pow_lt_succ hx _ h
-  by_contra' hy'' : y ≤ 1
+  by_contra! hy'' : y ≤ 1
   -- Then there exists y' such that 0 < y ≤ 1 < y' < x.
   let y' := (x + 1) / 2
   have h_y'_lt_x : y' < x :=
@@ -163,7 +163,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
       (x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := by gcongr; exact H5 x hx
       _ ≤ f x + f (a ^ N - x) := by gcongr; exact H5 _ h_big_enough
   have hxp : 0 < x := by positivity
-  have hNp : 0 < N := by by_contra' H; rw [le_zero_iff.mp H] at hN; linarith
+  have hNp : 0 < N := by by_contra! H; rw [le_zero_iff.mp H] at hN; linarith
   have h2 :=
     calc
       f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) := H2 x (a ^ N - x) hxp (by positivity)
chore: replace exact_mod_cast tactic with mod_cast elaborator where possible (#8404)

We still have the exact_mod_cast tactic, used in a few places, which somehow (?) works a little bit harder to prevent the expected type influencing the elaboration of the term. I would like to get to the bottom of this, and it will be easier once the only usages of exact_mod_cast are the ones that don't work using the term elaborator by itself.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -54,7 +54,7 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
       _ = x ^ n - y ^ n := geom_sum₂_mul x y n
   -- Choose n larger than 1 / (x - y).
   obtain ⟨N, hN⟩ := exists_nat_gt (1 / (x - y))
-  have hNp : 0 < N := by exact_mod_cast (one_div_pos.mpr hxmy).trans hN
+  have hNp : 0 < N := mod_cast (one_div_pos.mpr hxmy).trans hN
   have :=
     calc
       1 = (x - y) * (1 / (x - y)) := by field_simp
@@ -113,7 +113,7 @@ theorem fx_gt_xm1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 ≤ x)
     (x - 1 : ℝ) < f x := by
   have hx0 :=
     calc
-      (x - 1 : ℝ) < ⌊x⌋₊ := by exact_mod_cast Nat.sub_one_lt_floor x
+      (x - 1 : ℝ) < ⌊x⌋₊ := mod_cast Nat.sub_one_lt_floor x
       _ ≤ f ⌊x⌋₊ := H4 _ (Nat.floor_pos.2 hx)
   obtain h_eq | h_lt := (Nat.floor_le <| zero_le_one.trans hx).eq_or_lt
   · rwa [h_eq] at hx0
@@ -143,12 +143,12 @@ theorem fixed_point_of_pos_nat_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n)
     (H1 : ∀ x y, 0 < x → 0 < y → f (x * y) ≤ f x * f y) (H4 : ∀ n : ℕ, 0 < n → (n : ℝ) ≤ f n)
     (H5 : ∀ x : ℚ, 1 < x → (x : ℝ) ≤ f x) {a : ℚ} (ha1 : 1 < a) (hae : f a = a) :
     f (a ^ n) = a ^ n := by
-  have hh0 : (a : ℝ) ^ n ≤ f (a ^ n) := by exact_mod_cast H5 (a ^ n) (one_lt_pow ha1 hn.ne')
+  have hh0 : (a : ℝ) ^ n ≤ f (a ^ n) := mod_cast H5 (a ^ n) (one_lt_pow ha1 hn.ne')
   have hh1 :=
     calc
       f (a ^ n) ≤ f a ^ n := pow_f_le_f_pow hn ha1 H1 H4
       _ = (a : ℝ) ^ n := by rw [← hae]
-  exact_mod_cast hh1.antisymm hh0
+  exact mod_cast hh1.antisymm hh0
 #align imo2013_q5.fixed_point_of_pos_nat_pow Imo2013Q5.fixed_point_of_pos_nat_pow
 
 theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
@@ -170,7 +170,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
       _ = f (a ^ N) := by ring_nf
       _ = a ^ N := (fixed_point_of_pos_nat_pow hNp H1 H4 H5 ha1 hae)
       _ = x + (a ^ N - x) := by ring
-  have heq := h1.antisymm (by exact_mod_cast h2)
+  have heq := h1.antisymm (mod_cast h2)
   linarith [H5 x hx, H5 _ h_big_enough]
 #align imo2013_q5.fixed_point_of_gt_1 Imo2013Q5.fixed_point_of_gt_1
 
@@ -191,7 +191,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
     calc
       ↑(pn + 2) * f x = (↑pn + 1 + 1) * f x := by norm_cast
       _ = (↑pn + 1) * f x + f x := by ring
-      _ ≤ f (↑pn.succ * x) + f x := by exact_mod_cast add_le_add_right (hpn pn.succ_pos) (f x)
+      _ ≤ f (↑pn.succ * x) + f x := mod_cast add_le_add_right (hpn pn.succ_pos) (f x)
       _ ≤ f ((↑pn + 1) * x + x) := by exact_mod_cast H2 _ _ (mul_pos pn.cast_add_one_pos hx) hx
       _ = f ((↑pn + 1 + 1) * x) := by ring_nf
       _ = f (↑(pn + 2) * x) := by norm_cast
@@ -216,10 +216,10 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
     have hxnm1 : ∀ n : ℕ, 0 < n → (x : ℝ) ^ n - 1 < f x ^ n := by
       intro n hn
       calc
-        (x : ℝ) ^ n - 1 < f (x ^ n) := by
-          exact_mod_cast fx_gt_xm1 (one_le_pow_of_one_le hx.le n) H1 H2 H4
+        (x : ℝ) ^ n - 1 < f (x ^ n) :=
+            mod_cast fx_gt_xm1 (one_le_pow_of_one_le hx.le n) H1 H2 H4
         _ ≤ f x ^ n := pow_f_le_f_pow hn hx H1 H4
-    have hx' : 1 < (x : ℝ) := by exact_mod_cast hx
+    have hx' : 1 < (x : ℝ) := mod_cast hx
     have hxp : 0 < x := by positivity
     exact le_of_all_pow_lt_succ' hx' (f_pos_of_pos hxp H1 H4) hxnm1
   have h_f_commutes_with_pos_nat_mul : ∀ n : ℕ, 0 < n → ∀ x : ℚ, 0 < x → f (n * x) = n * f x := by
chore: bump to v4.3.0-rc2 (#8366)

PR contents

This is the supremum of

along with some minor fixes from failures on nightly-testing as Mathlib master is merged into it.

Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.

I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0 branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.

Lean PRs involved in this bump

In particular this includes adjustments for the Lean PRs

leanprover/lean4#2778

We can get rid of all the

local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)

macros across Mathlib (and in any projects that want to write natural number powers of reals).

leanprover/lean4#2722

Changes the default behaviour of simp to (config := {decide := false}). This makes simp (and consequentially norm_num) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp or norm_num to decide or rfl, or adding (config := {decide := true}).

leanprover/lean4#2783

This changed the behaviour of simp so that simp [f] will only unfold "fully applied" occurrences of f. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true }). We may in future add a syntax for this, e.g. simp [!f]; please provide feedback! In the meantime, we have made the following changes:

  • switching to using explicit lemmas that have the intended level of application
  • (config := { unfoldPartialApp := true }) in some places, to recover the old behaviour
  • Using @[eqns] to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp and Function.flip.

This change in Lean may require further changes down the line (e.g. adding the !f syntax, and/or upstreaming the special treatment for Function.comp and Function.flip, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>

Diff
@@ -31,8 +31,6 @@ https://www.imo-official.org/problems/IMO2013SL.pdf
 
 open scoped BigOperators
 
-local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue lean4#2220
-
 namespace Imo2013Q5
 
 theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
chore: split Data.Real.Basic (#8356)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -4,8 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: David Renshaw
 -/
 import Mathlib.Algebra.GeomSum
-import Mathlib.Data.Rat.Defs
-import Mathlib.Data.Real.Basic
+import Mathlib.Data.Real.Archimedean
 import Mathlib.Tactic.Positivity
 import Mathlib.Tactic.LinearCombination
 
field_simp: Use positivity as a discharger (#6312)

The main reasons is that having h : 0 < denom in the context should suffice for field_simp to do its job, without the need to manually pass h.ne or similar.

Quite a few have := … ≠ 0 could be dropped, and some field_simp calls no longer need explicit arguments; this is promising.

This does break some proofs where field_simp was not used as a closing tactic, and it now shuffles terms around a bit different. These were fixed. Using field_simp in the middle of a proof seems rather fragile anyways.

As a drive-by contribution, positivity now knows about π > 0.

fixes: #4835

Co-authored-by: Matthew Ballard <matt@mrb.email>

Diff
@@ -60,7 +60,7 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
   have hNp : 0 < N := by exact_mod_cast (one_div_pos.mpr hxmy).trans hN
   have :=
     calc
-      1 = (x - y) * (1 / (x - y)) := by field_simp [ne_of_gt hxmy]
+      1 = (x - y) * (1 / (x - y)) := by field_simp
       _ < (x - y) * N := by gcongr
       _ ≤ x ^ N - y ^ N := hn N hNp
   linarith [h N hNp]
chore: regularize HPow.hPow porting notes (#6465)
Diff
@@ -32,7 +32,7 @@ https://www.imo-official.org/problems/IMO2013SL.pdf
 
 open scoped BigOperators
 
-local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue #2220
+local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue lean4#2220
 
 namespace Imo2013Q5
 
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,11 +2,6 @@
 Copyright (c) 2021 David Renshaw. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: David Renshaw
-
-! This file was ported from Lean 3 source module imo.imo2013_q5
-! 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.Algebra.GeomSum
 import Mathlib.Data.Rat.Defs
@@ -14,6 +9,8 @@ import Mathlib.Data.Real.Basic
 import Mathlib.Tactic.Positivity
 import Mathlib.Tactic.LinearCombination
 
+#align_import imo.imo2013_q5 from "leanprover-community/mathlib"@"308826471968962c6b59c7ff82a22757386603e3"
+
 /-!
 # IMO 2013 Q5
 
chore: tidy various files (#5971)
Diff
@@ -12,6 +12,7 @@ import Mathlib.Algebra.GeomSum
 import Mathlib.Data.Rat.Defs
 import Mathlib.Data.Real.Basic
 import Mathlib.Tactic.Positivity
+import Mathlib.Tactic.LinearCombination
 
 /-!
 # IMO 2013 Q5
@@ -44,20 +45,18 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
   have hxmy : 0 < x - y := sub_pos.mpr hxy
   have hn : ∀ n : ℕ, 0 < n → (x - y) * (n : ℝ) ≤ x ^ n - y ^ n := by
     intro n _
-    have hterm : ∀ i : ℕ, i ∈ Finset.range n → 1 ≤ x ^ i * y ^ (n - 1 - i) := by
-      intro i _
-      have hx' : 1 ≤ x ^ i := one_le_pow_of_one_le hx.le i
-      have hy' : 1 ≤ y ^ (n - 1 - i) := one_le_pow_of_one_le hy.le (n - 1 - i)
+    have hterm : ∀ i : ℕ, i ∈ Finset.range n → 1 ≤ x ^ i * y ^ (n - 1 - i)
+    · intro i _
       calc
-        1 ≤ x ^ i := hx'
-        _ = x ^ i * 1 := (mul_one _).symm
-        _ ≤ x ^ i * y ^ (n - 1 - i) := mul_le_mul_of_nonneg_left hy' (zero_le_one.trans hx')
+        1 ≤ x ^ i := one_le_pow_of_one_le hx.le i
+        _ = x ^ i * 1 := by ring
+        _ ≤ x ^ i * y ^ (n - 1 - i) := by gcongr; apply one_le_pow_of_one_le hy.le
     calc
-      (x - y) * (n : ℝ) = (n : ℝ) * (x - y) := mul_comm _ _
+      (x - y) * (n : ℝ) = (n : ℝ) * (x - y) := by ring
       _ = (∑ _i : ℕ in Finset.range n, (1 : ℝ)) * (x - y) := by
         simp only [mul_one, Finset.sum_const, nsmul_eq_mul, Finset.card_range]
-      _ ≤ (∑ i : ℕ in Finset.range n, x ^ i * y ^ (n - 1 - i)) * (x - y) :=
-        ((mul_le_mul_right hxmy).mpr (Finset.sum_le_sum hterm))
+      _ ≤ (∑ i : ℕ in Finset.range n, x ^ i * y ^ (n - 1 - i)) * (x - y) := by
+        gcongr with i hi; apply hterm i hi
       _ = x ^ n - y ^ n := geom_sum₂_mul x y n
   -- Choose n larger than 1 / (x - y).
   obtain ⟨N, hN⟩ := exists_nat_gt (1 / (x - y))
@@ -65,7 +64,7 @@ theorem le_of_all_pow_lt_succ {x y : ℝ} (hx : 1 < x) (hy : 1 < y)
   have :=
     calc
       1 = (x - y) * (1 / (x - y)) := by field_simp [ne_of_gt hxmy]
-      _ < (x - y) * N := ((mul_lt_mul_left hxmy).mpr hN)
+      _ < (x - y) * N := by gcongr
       _ ≤ x ^ N - y ^ N := hn N hNp
   linarith [h N hNp]
 #align imo2013_q5.le_of_all_pow_lt_succ Imo2013Q5.le_of_all_pow_lt_succ
@@ -78,22 +77,20 @@ theorem le_of_all_pow_lt_succ' {x y : ℝ} (hx : 1 < x) (hy : 0 < y)
   by_contra' hy'' : y ≤ 1
   -- Then there exists y' such that 0 < y ≤ 1 < y' < x.
   let y' := (x + 1) / 2
-  have h_y'_lt_x : y' < x := by
-    have hh : (x + 1) / 2 < x * 2 / 2 := by linarith
+  have h_y'_lt_x : y' < x :=
     calc
-      y' < x * 2 / 2 := hh
+      (x + 1) / 2 < x * 2 / 2 := by linarith
       _ = x := by field_simp
-  have h1_lt_y' : 1 < y' := by
-    have hh' : 1 * 2 / 2 < (x + 1) / 2 := by linarith
+  have h1_lt_y' : 1 < y' :=
     calc
       1 = 1 * 2 / 2 := by field_simp
-      _ < y' := hh'
-  have h_y_lt_y' : y < y' := hy''.trans_lt h1_lt_y'
-  have hh : ∀ n, 0 < n → x ^ n - 1 < y' ^ n := by
-    intro n hn
+      _ < (x + 1) / 2 := by linarith
+  have h_y_lt_y' : y < y' := by linarith
+  have hh : ∀ n, 0 < n → x ^ n - 1 < y' ^ n
+  · intro n hn
     calc
       x ^ n - 1 < y ^ n := h n hn
-      _ ≤ y' ^ n := pow_le_pow_of_le_left hy.le h_y_lt_y'.le n
+      _ ≤ y' ^ n := by gcongr
   exact h_y'_lt_x.not_le (le_of_all_pow_lt_succ hx h1_lt_y' hh)
 #align imo2013_q5.le_of_all_pow_lt_succ' Imo2013Q5.le_of_all_pow_lt_succ'
 
@@ -130,7 +127,7 @@ theorem fx_gt_xm1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 ≤ x)
     (x - 1 : ℝ) < f ⌊x⌋₊ := hx0
     _ < f (x - ⌊x⌋₊) + f ⌊x⌋₊ := (lt_add_of_pos_left _ (f_pos_of_pos (sub_pos.mpr h_lt) H1 H4))
     _ ≤ f (x - ⌊x⌋₊ + ⌊x⌋₊) := (H2 _ _ (sub_pos.mpr h_lt) (Nat.cast_pos.2 (Nat.floor_pos.2 hx)))
-    _ = f x := by rw [sub_add_cancel]
+    _ = f x := by ring_nf
 #align imo2013_q5.fx_gt_xm1 Imo2013Q5.fx_gt_xm1
 
 theorem pow_f_le_f_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n) {x : ℚ} (hx : 1 < x)
@@ -145,7 +142,7 @@ theorem pow_f_le_f_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n) {x : ℚ} (hx :
   have hxp : 0 < x := by positivity
   calc
     f (x ^ (pn + 1) * x) ≤ f (x ^ (pn + 1)) * f x := H1 (x ^ (pn + 1)) x (pow_pos hxp (pn + 1)) hxp
-    _ ≤ f x ^ (pn + 1) * f x := (mul_le_mul_right (f_pos_of_pos hxp H1 H4)).mpr hpn'
+    _ ≤ f x ^ (pn + 1) * f x := by gcongr; exact (f_pos_of_pos hxp H1 H4).le
 #align imo2013_q5.pow_f_le_f_pow Imo2013Q5.pow_f_le_f_pow
 
 theorem fixed_point_of_pos_nat_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n)
@@ -169,14 +166,13 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
   have h_big_enough : (1 : ℚ) < a ^ N - x := lt_sub_iff_add_lt.mpr hN
   have h1 :=
     calc
-      (x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := add_le_add_right (H5 x hx) _
-      _ ≤ f x + f (a ^ N - x) := add_le_add_left (H5 _ h_big_enough) _
+      (x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := by gcongr; exact H5 x hx
+      _ ≤ f x + f (a ^ N - x) := by gcongr; exact H5 _ h_big_enough
   have hxp : 0 < x := by positivity
   have hNp : 0 < N := by by_contra' H; rw [le_zero_iff.mp H] at hN; linarith
   have h2 :=
     calc
-      f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) :=
-        H2 x (a ^ N - x) hxp (zero_lt_one.trans h_big_enough)
+      f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) := H2 x (a ^ N - x) hxp (by positivity)
       _ = f (a ^ N) := by ring_nf
       _ = a ^ N := (fixed_point_of_pos_nat_pow hNp H1 H4 H5 ha1 hae)
       _ = x + (a ^ N - x) := by ring
@@ -200,18 +196,16 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
     · norm_num
     calc
       ↑(pn + 2) * f x = (↑pn + 1 + 1) * f x := by norm_cast
-      _ = ((pn : ℝ) + 1) * f x + 1 * f x := (add_mul (↑pn + 1) 1 (f x))
-      _ = (↑pn + 1) * f x + f x := by rw [one_mul]
+      _ = (↑pn + 1) * f x + f x := by ring
       _ ≤ f (↑pn.succ * x) + f x := by exact_mod_cast add_le_add_right (hpn pn.succ_pos) (f x)
       _ ≤ f ((↑pn + 1) * x + x) := by exact_mod_cast H2 _ _ (mul_pos pn.cast_add_one_pos hx) hx
-      _ = f ((↑pn + 1) * x + 1 * x) := by rw [one_mul]
-      _ = f ((↑pn + 1 + 1) * x) := (congr_arg f (add_mul (↑pn + 1) 1 x).symm)
+      _ = f ((↑pn + 1 + 1) * x) := by ring_nf
       _ = f (↑(pn + 2) * x) := by norm_cast
   have H4 : ∀ n : ℕ, 0 < n → (n : ℝ) ≤ f n := by
     intro n hn
     have hf1 : 1 ≤ f 1 := by
       have a_pos : (0 : ℝ) < a := Rat.cast_pos.mpr (zero_lt_one.trans ha1)
-      suffices : ↑a * 1 ≤ ↑a * f 1; exact (mul_le_mul_left a_pos).mp this
+      suffices : ↑a * 1 ≤ ↑a * f 1; rwa [← mul_le_mul_left a_pos]
       calc
         ↑a * 1 = ↑a := mul_one (a : ℝ)
         _ = f a := hae.symm
@@ -220,7 +214,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
         _ = ↑a * f 1 := by rw [hae]
     calc
       (n : ℝ) = (n : ℝ) * 1 := (mul_one _).symm
-      _ ≤ (n : ℝ) * f 1 := (mul_le_mul_of_nonneg_left hf1 (Nat.cast_nonneg _))
+      _ ≤ (n : ℝ) * f 1 := by gcongr
       _ ≤ f (n * 1) := (H3 1 zero_lt_one n hn)
       _ = f n := by rw [mul_one]
   have H5 : ∀ x : ℚ, 1 < x → (x : ℝ) ≤ f x := by
@@ -253,37 +247,22 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
   -- we need the top of the fraction to be strictly greater than 1 in order
   -- to apply `fixed_point_of_gt_1`.
   intro x hx
-  let x2denom := 2 * x.den
-  let x2num := 2 * x.num
-  have hx2pos :=
-    calc
-      0 < x.den := x.pos
-      _ < x.den + x.den := (lt_add_of_pos_left x.den x.pos)
-      _ = 2 * x.den := by ring
-  have hxcnez : (x.den : ℚ) ≠ (0 : ℚ) := ne_of_gt (Nat.cast_pos.mpr x.pos)
-  have hx2cnezr : (x2denom : ℝ) ≠ (0 : ℝ) := Nat.cast_ne_zero.mpr (ne_of_gt hx2pos)
-  have hrat_expand2 :=
-    calc
-      x = x.num / x.den := by exact_mod_cast Rat.num_den.symm
-      _ = x2num / x2denom := by field_simp; linarith
-  have h_denom_times_fx :=
-    calc
-      (x2denom : ℝ) * f x = f (x2denom * x) :=
-        (h_f_commutes_with_pos_nat_mul x2denom hx2pos x hx).symm
-      _ = f (x2denom * (x2num / x2denom)) := by rw [hrat_expand2]
-      _ = f x2num := by congr; field_simp; ring
-  have h_fx2num_fixed : f x2num = x2num := by
-    have hx2num_gt_one : (1 : ℚ) < (2 * x.num : ℤ) := by
-      norm_cast; linarith [Rat.num_pos_iff_pos.mpr hx]
-    have hh := fixed_point_of_gt_1 hx2num_gt_one H1 H2 H4 H5 ha1 hae
-    rwa [Rat.cast_coe_int x2num] at hh
+  have H₀ : x * x.den = x.num := Rat.mul_den_eq_num
+  have H : x * (↑(2 * x.den) : ℚ) = (↑(2 * x.num) : ℚ) := by push_cast; linear_combination 2 * H₀
+  set x2denom := 2 * x.den
+  set x2num := 2 * x.num
+  have := x.pos
+  have hx2pos : 0 < 2 * x.den := by positivity
+  have hx2cnezr : (x2denom : ℝ) ≠ (0 : ℝ) := by positivity
+  have : 0 < x.num := by rwa [Rat.num_pos_iff_pos]
+  have hx2num_gt_one : (1 : ℚ) < (2 * x.num : ℤ) := by norm_cast; linarith
+  apply mul_left_cancel₀ hx2cnezr
   calc
-    f x = f x * 1 := (mul_one (f x)).symm
-    _ = f x * (x2denom / x2denom) := by rw [← div_self hx2cnezr]
-    _ = f x * x2denom / x2denom := (mul_div_assoc' (f x) _ _)
-    _ = x2denom * f x / x2denom := by rw [mul_comm]
-    _ = f x2num / x2denom := by rw [h_denom_times_fx]
-    _ = x2num / x2denom := by rw [h_fx2num_fixed]
-    _ = (((x2num : ℚ) / (x2denom : ℚ) : ℚ) : ℝ) := by norm_cast
-    _ = x := by rw [← hrat_expand2]
+    x2denom * f x = f (x2denom * x) :=
+        (h_f_commutes_with_pos_nat_mul x2denom hx2pos x hx).symm
+    _ = f x2num := by congr; linear_combination H
+    _ = x2num := fixed_point_of_gt_1 hx2num_gt_one H1 H2 H4 H5 ha1 hae
+    _ = ((x2num : ℚ) : ℝ) := by norm_cast
+    _ = (↑(x2denom * x) : ℝ) := by congr; linear_combination -H
+    _ = x2denom * x := by push_cast; rfl
 #align imo2013_q5 imo2013_q5
chore: remove occurrences of semicolon after space (#5713)

This is the second half of the changes originally in #5699, removing all occurrences of ; after a space and implementing a linter rule to enforce it.

In most cases this 2-character substring has a space after it, so the following command was run first:

find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;

The remaining cases were few enough in number that they were done manually.

Diff
@@ -172,7 +172,7 @@ theorem fixed_point_of_gt_1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 < x)
       (x : ℝ) + (a ^ N - x : ℚ) ≤ f x + (a ^ N - x : ℚ) := add_le_add_right (H5 x hx) _
       _ ≤ f x + f (a ^ N - x) := add_le_add_left (H5 _ h_big_enough) _
   have hxp : 0 < x := by positivity
-  have hNp : 0 < N := by by_contra' H; rw [le_zero_iff.mp H] at hN ; linarith
+  have hNp : 0 < N := by by_contra' H; rw [le_zero_iff.mp H] at hN; linarith
   have h2 :=
     calc
       f x + f (a ^ N - x) ≤ f (x + (a ^ N - x)) :=
chore: tidy various files (#5233)

Dependencies 7 + 296

297 files ported (97.7%)
122321 lines ported (97.6%)
Show graph

The unported dependencies are