imo.imo2021_q1Archive.Imo.Imo2021Q1

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
@@ -134,7 +134,7 @@ theorem exists_triplet_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
     all_goals norm_num
 #align imo2021_q1.exists_triplet_summing_to_squares Imo2021Q1.exists_triplet_summing_to_squares
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (a b «expr ∈ » B) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (a b «expr ∈ » B) -/
 -- Since it will be more convenient to work with sets later on, we will translate the above claim
 -- to state that there always exists a set B ⊆ [n, 2n] of cardinality at least 3, such that each
 -- pair of pairwise unequal elements of B sums to a perfect square.
@@ -169,9 +169,9 @@ end imo2021_q1
 
 open imo2021_q1
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (A «expr ⊆ » finset.Icc[finset.Icc] n «expr * »(2, n)) -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (a b «expr ∈ » A) -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (a b «expr ∈ » «expr \ »(finset.Icc[finset.Icc] n «expr * »(2, n), A)) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (A «expr ⊆ » finset.Icc[finset.Icc] n «expr * »(2, n)) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (a b «expr ∈ » A) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (a b «expr ∈ » «expr \ »(finset.Icc[finset.Icc] n «expr * »(2, n), A)) -/
 theorem imo2021_q1 :
     ∀ n : ℕ,
       100 ≤ n →
@@ -191,7 +191,7 @@ theorem imo2021_q1 :
     simpa only [Finset.mem_Icc] using h₂ c hcB
   have hB' : 2 * 1 < (B ∩ (Finset.Icc n (2 * n) \ A) ∪ B ∩ A).card :=
     by
-    rw [← Finset.inter_distrib_left, Finset.sdiff_union_self_eq_union,
+    rw [← Finset.inter_union_distrib_left, Finset.sdiff_union_self_eq_union,
       finset.union_eq_left_iff_subset.mpr hA, (Finset.inter_eq_left_iff_subset _ _).mpr hBsub]
     exact nat.succ_le_iff.mp hB
   -- Since B has cardinality greater or equal to 3, there must exist a subset C ⊆ B such that
Diff
@@ -54,16 +54,16 @@ theorem lower_bound (n l : ℕ) (hl : 2 + sqrt (4 + 2 * n) ≤ 2 * l) : n + 4 *
   by
   suffices 2 * ((n : ℝ) + 4 * l) - 8 * l + 4 ≤ 2 * (2 * l * l) - 8 * l + 4
     by
-    simp only [mul_le_mul_left, sub_le_sub_iff_right, add_le_add_iff_right, zero_lt_two] at this 
+    simp only [mul_le_mul_left, sub_le_sub_iff_right, add_le_add_iff_right, zero_lt_two] at this
     exact_mod_cast this
-  rw [← le_sub_iff_add_le', sqrt_le_iff, pow_two] at hl 
+  rw [← le_sub_iff_add_le', sqrt_le_iff, pow_two] at hl
   convert hl.2 using 1 <;> ring
 #align imo2021_q1.lower_bound Imo2021Q1.lower_bound
 
 theorem upper_bound (n l : ℕ) (hl : (l : ℝ) ≤ sqrt (1 + n) - 1) : 2 * l * l + 4 * l ≤ 2 * n :=
   by
   have h1 : ∀ n : ℕ, 0 ≤ 1 + (n : ℝ) := by intro n; exact_mod_cast Nat.zero_le (1 + n)
-  rw [le_sub_iff_add_le', le_sqrt (h1 l) (h1 n), pow_two] at hl 
+  rw [le_sub_iff_add_le', le_sqrt (h1 l) (h1 n), pow_two] at hl
   rw [← add_le_add_iff_right 2, ← @Nat.cast_le ℝ]
   simp only [Nat.cast_bit0, Nat.cast_add, Nat.cast_one, Nat.cast_mul]
   convert (mul_le_mul_left zero_lt_two).mpr hl using 1 <;> ring
@@ -154,7 +154,7 @@ theorem exists_finset_3_le_card_with_pairs_summing_to_squares (n : ℕ) (hn : 10
       push_neg
       exact ⟨⟨hab.ne, (hab.trans hbc).Ne⟩, hbc.ne⟩
   · intro x hx y hy hxy
-    simp only [Finset.mem_insert, Finset.mem_singleton] at hx hy 
+    simp only [Finset.mem_insert, Finset.mem_singleton] at hx hy
     rcases hx with (rfl | rfl | rfl) <;> rcases hy with (rfl | rfl | rfl)
     all_goals
       first
@@ -198,9 +198,9 @@ theorem imo2021_q1 :
   -- for any A ⊆ [n, 2n], either C ⊆ A or C ⊆ [n, 2n] \ A and C has cardinality greater
   -- or equal to 2.
   obtain ⟨C, hC, hCA⟩ := Finset.exists_subset_or_subset_of_two_mul_lt_card hB'
-  rw [Finset.one_lt_card] at hC 
+  rw [Finset.one_lt_card] at hC
   rcases hC with ⟨a, ha, b, hb, hab⟩
-  simp only [Finset.subset_iff, Finset.mem_inter] at hCA 
+  simp only [Finset.subset_iff, Finset.mem_inter] at hCA
   -- Now we split into the two cases C ⊆ [n, 2n] \ A and C ⊆ A, which can be dealt with identically.
       cases hCA <;>
       [right; left] <;>
Diff
@@ -74,7 +74,7 @@ theorem radical_inequality {n : ℕ} (h : 107 ≤ n) : sqrt (4 + 2 * n) ≤ 2 *
   have h1n : 0 ≤ 1 + (n : ℝ) := by norm_cast; exact Nat.zero_le _
   rw [sqrt_le_iff]
   constructor
-  · simp only [sub_nonneg, zero_le_mul_left, zero_lt_two, le_sqrt zero_lt_three.le h1n]
+  · simp only [sub_nonneg, mul_nonneg_iff_of_pos_left, zero_lt_two, le_sqrt zero_lt_three.le h1n]
     norm_cast; linarith only [h]
   ring
   rw [pow_two, ← sqrt_mul h1n, sqrt_mul_self h1n]
Diff
@@ -3,12 +3,12 @@ Copyright (c) 2021 Mantas Bakšys. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mantas Bakšys
 -/
-import Mathbin.Data.Real.Sqrt
-import Mathbin.Tactic.IntervalCases
+import Data.Real.Sqrt
+import Tactic.IntervalCases
 import Mathbin.Tactic.Linarith.Default
-import Mathbin.Tactic.NormCast
-import Mathbin.Tactic.NormNum
-import Mathbin.Tactic.RingExp
+import Tactic.NormCast
+import Tactic.NormNum
+import Tactic.RingExp
 
 #align_import imo.imo2021_q1 from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
 
@@ -134,7 +134,7 @@ theorem exists_triplet_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
     all_goals norm_num
 #align imo2021_q1.exists_triplet_summing_to_squares Imo2021Q1.exists_triplet_summing_to_squares
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » B) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (a b «expr ∈ » B) -/
 -- Since it will be more convenient to work with sets later on, we will translate the above claim
 -- to state that there always exists a set B ⊆ [n, 2n] of cardinality at least 3, such that each
 -- pair of pairwise unequal elements of B sums to a perfect square.
@@ -169,9 +169,9 @@ end imo2021_q1
 
 open imo2021_q1
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (A «expr ⊆ » finset.Icc[finset.Icc] n «expr * »(2, n)) -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » A) -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » «expr \ »(finset.Icc[finset.Icc] n «expr * »(2, n), A)) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (A «expr ⊆ » finset.Icc[finset.Icc] n «expr * »(2, n)) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (a b «expr ∈ » A) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (a b «expr ∈ » «expr \ »(finset.Icc[finset.Icc] n «expr * »(2, n), A)) -/
 theorem imo2021_q1 :
     ∀ n : ℕ,
       100 ≤ n →
Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2021 Mantas Bakšys. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mantas Bakšys
-
-! This file was ported from Lean 3 source module imo.imo2021_q1
-! 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.Data.Real.Sqrt
 import Mathbin.Tactic.IntervalCases
@@ -15,6 +10,8 @@ import Mathbin.Tactic.NormCast
 import Mathbin.Tactic.NormNum
 import Mathbin.Tactic.RingExp
 
+#align_import imo.imo2021_q1 from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
+
 /-!
 # IMO 2021 Q1
 
@@ -137,7 +134,7 @@ theorem exists_triplet_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
     all_goals norm_num
 #align imo2021_q1.exists_triplet_summing_to_squares Imo2021Q1.exists_triplet_summing_to_squares
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (a b «expr ∈ » B) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » B) -/
 -- Since it will be more convenient to work with sets later on, we will translate the above claim
 -- to state that there always exists a set B ⊆ [n, 2n] of cardinality at least 3, such that each
 -- pair of pairwise unequal elements of B sums to a perfect square.
@@ -172,9 +169,9 @@ end imo2021_q1
 
 open imo2021_q1
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (A «expr ⊆ » finset.Icc[finset.Icc] n «expr * »(2, n)) -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (a b «expr ∈ » A) -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (a b «expr ∈ » «expr \ »(finset.Icc[finset.Icc] n «expr * »(2, n), A)) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (A «expr ⊆ » finset.Icc[finset.Icc] n «expr * »(2, n)) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » A) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » «expr \ »(finset.Icc[finset.Icc] n «expr * »(2, n), A)) -/
 theorem imo2021_q1 :
     ∀ n : ℕ,
       100 ≤ n →
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mantas Bakšys
 
 ! This file was ported from Lean 3 source module imo.imo2021_q1
-! 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.
 -/
@@ -18,6 +18,9 @@ import Mathbin.Tactic.RingExp
 /-!
 # IMO 2021 Q1
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Let `n≥100` be an integer. Ivan writes the numbers `n, n+1,..., 2n` each on different cards.
 He then shuffles these `n+1` cards, and divides them into two piles. Prove that at least one
 of the piles contains two cards such that the sum of their numbers is a perfect square.
Diff
@@ -134,7 +134,7 @@ theorem exists_triplet_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
     all_goals norm_num
 #align imo2021_q1.exists_triplet_summing_to_squares Imo2021Q1.exists_triplet_summing_to_squares
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » B) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (a b «expr ∈ » B) -/
 -- Since it will be more convenient to work with sets later on, we will translate the above claim
 -- to state that there always exists a set B ⊆ [n, 2n] of cardinality at least 3, such that each
 -- pair of pairwise unequal elements of B sums to a perfect square.
@@ -169,9 +169,9 @@ end imo2021_q1
 
 open imo2021_q1
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (A «expr ⊆ » finset.Icc[finset.Icc] n «expr * »(2, n)) -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » A) -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » «expr \ »(finset.Icc[finset.Icc] n «expr * »(2, n), A)) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (A «expr ⊆ » finset.Icc[finset.Icc] n «expr * »(2, n)) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (a b «expr ∈ » A) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (a b «expr ∈ » «expr \ »(finset.Icc[finset.Icc] n «expr * »(2, n), A)) -/
 theorem imo2021_q1 :
     ∀ n : ℕ,
       100 ≤ n →

Changes in mathlib4

mathlib3
mathlib4
chore(Data/Nat/Defs): Integrate Nat.sqrt material (#11866)

Move the content of Data.Nat.ForSqrt and Data.Nat.Sqrt to Data.Nat.Defs by using Nat-specific Std lemmas rather than the mathlib general ones. This makes it ready to move to Std if wanted.

Diff
@@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mantas Bakšys
 -/
 import Mathlib.Data.Nat.Interval
-import Mathlib.Data.Nat.Sqrt
 import Mathlib.Tactic.IntervalCases
 import Mathlib.Tactic.Linarith
 
chore(Set/Finset): standardize names of distributivity laws (#11572)

Standardizes the following names for distributivity laws across Finset and Set:

  • inter_union_distrib_left
  • inter_union_distrib_right
  • union_inter_distrib_left
  • union_inter_distrib_right

Makes arguments explicit in:

  • Set.union_inter_distrib_right
  • Set.union_inter_distrib_left
  • Set.inter_union_distrib_right

Deprecates these theorem names:

  • Finset.inter_distrib_left
  • Finset.inter_distrib_right
  • Finset.union_distrib_right
  • Finset.union_distrib_left
  • Set.inter_distrib_left
  • Set.inter_distrib_right
  • Set.union_distrib_right
  • Set.union_distrib_left

Fixes use of deprecated names and implicit arguments in these files:

  • Topology/Basic
  • Topology/Connected/Basic
  • MeasureTheory/MeasurableSpace/Basic
  • MeasureTheory/Covering/Differentiation
  • MeasureTheory/Constructions/BorelSpace/Basic
  • Data/Set/Image
  • Data/Set/Basic
  • Data/PFun
  • Data/Matroid/Dual
  • Data/Finset/Sups
  • Data/Finset/Basic
  • Combinatorics/SetFamily/FourFunctions
  • Combinatorics/Additive/SalemSpencer
  • Counterexamples/Phillips.lean
  • Archive/Imo/Imo2021Q1.lean
Diff
@@ -124,7 +124,7 @@ theorem imo2021_q1 :
   have hBsub : B ⊆ Finset.Icc n (2 * n) := by
     intro c hcB; simpa only [Finset.mem_Icc] using h₂ c hcB
   have hB' : 2 * 1 < (B ∩ (Finset.Icc n (2 * n) \ A) ∪ B ∩ A).card := by
-    rw [← inter_distrib_left, sdiff_union_self_eq_union, union_eq_left.2 hA,
+    rw [← inter_union_distrib_left, sdiff_union_self_eq_union, union_eq_left.2 hA,
       inter_eq_left.2 hBsub]
     exact Nat.succ_le_iff.mp hB
   -- Since B has cardinality greater or equal to 3, there must exist a subset C ⊆ B such that
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
@@ -48,13 +48,13 @@ namespace Imo2021Q1
 -- n ≤ 2 * l ^ 2 - 4 * l and 2 * l ^ 2 + 4 * l ≤ 2 * n for n ≥ 100.
 theorem exists_numbers_in_interval (n : ℕ) (hn : 100 ≤ n) :
     ∃ l : ℕ, n + 4 * l ≤ 2 * l ^ 2 ∧ 2 * l ^ 2 + 4 * l ≤ 2 * n := by
-  have hn' : 1 ≤ Nat.sqrt (n + 1)
-  · rw [Nat.le_sqrt]
+  have hn' : 1 ≤ Nat.sqrt (n + 1) := by
+    rw [Nat.le_sqrt]
     linarith
   have h₁ := Nat.sqrt_le' (n + 1)
   have h₂ := Nat.succ_le_succ_sqrt' (n + 1)
-  have h₃ : 10 ≤ (n + 1).sqrt
-  · rw [Nat.le_sqrt]
+  have h₃ : 10 ≤ (n + 1).sqrt := by
+    rw [Nat.le_sqrt]
     linarith only [hn]
   rw [← Nat.sub_add_cancel hn'] at h₁ h₂ h₃
   set l := (n + 1).sqrt - 1
chore(*): use ∀ s ⊆ t, _ etc (#9276)

Changes in this PR shouldn't change the public API. The only changes about ∃ x ∈ s, _ is inside a proof.

Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com>

Diff
@@ -110,7 +110,7 @@ end Imo2021Q1
 open Imo2021Q1
 
 theorem imo2021_q1 :
-    ∀ n : ℕ, 100 ≤ n → ∀ (A) (_ : A ⊆ Finset.Icc n (2 * n)),
+    ∀ n : ℕ, 100 ≤ n → ∀ A ⊆ Finset.Icc n (2 * n),
     (∃ a ∈ A, ∃ b ∈ A, a ≠ b ∧ ∃ k : ℕ, a + b = k ^ 2) ∨
     ∃ a ∈ Finset.Icc n (2 * n) \ A, ∃ b ∈ Finset.Icc n (2 * n) \ A,
       a ≠ b ∧ ∃ k : ℕ, a + b = k ^ 2 := by
chore(*): use ∃ x ∈ s, _ instead of ∃ (x) (_ : x ∈ s), _ (#9215)

Follow-up #9184

Diff
@@ -82,7 +82,7 @@ theorem exists_triplet_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
 theorem exists_finset_3_le_card_with_pairs_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
     ∃ B : Finset ℕ,
       2 * 1 + 1 ≤ B.card ∧
-      (∀ (a) (_ : a ∈ B) (b) (_ : b ∈ B), a ≠ b → ∃ k, a + b = k ^ 2) ∧
+      (∀ a ∈ B, ∀ b ∈ B, a ≠ b → ∃ k, a + b = k ^ 2) ∧
       ∀ c ∈ B, n ≤ c ∧ c ≤ 2 * n := by
   obtain ⟨a, b, c, hna, hab, hbc, hcn, h₁, h₂, h₃⟩ := exists_triplet_summing_to_squares n hn
   refine' ⟨{a, b, c}, _, _, _⟩
@@ -111,8 +111,8 @@ open Imo2021Q1
 
 theorem imo2021_q1 :
     ∀ n : ℕ, 100 ≤ n → ∀ (A) (_ : A ⊆ Finset.Icc n (2 * n)),
-    (∃ (a : _) (_ : a ∈ A) (b : _) (_ : b ∈ A), a ≠ b ∧ ∃ k : ℕ, a + b = k ^ 2) ∨
-    ∃ (a : _) (_ : a ∈ Finset.Icc n (2 * n) \ A) (b : _) (_ : b ∈ Finset.Icc n (2 * n) \ A),
+    (∃ a ∈ A, ∃ b ∈ A, a ≠ b ∧ ∃ k : ℕ, a + b = k ^ 2) ∨
+    ∃ a ∈ Finset.Icc n (2 * n) \ A, ∃ b ∈ Finset.Icc n (2 * n) \ A,
       a ≠ b ∧ ∃ k : ℕ, a + b = k ^ 2 := by
   intro n hn A hA
   -- For each n ∈ ℕ such that 100 ≤ n, there exists a pairwise unequal triplet {a, b, c} ⊆ [n, 2n]
chore: space after (#8178)

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

Diff
@@ -124,7 +124,7 @@ theorem imo2021_q1 :
   have hBsub : B ⊆ Finset.Icc n (2 * n) := by
     intro c hcB; simpa only [Finset.mem_Icc] using h₂ c hcB
   have hB' : 2 * 1 < (B ∩ (Finset.Icc n (2 * n) \ A) ∪ B ∩ A).card := by
-    rw [←inter_distrib_left, sdiff_union_self_eq_union, union_eq_left.2 hA,
+    rw [← inter_distrib_left, sdiff_union_self_eq_union, union_eq_left.2 hA,
       inter_eq_left.2 hBsub]
     exact Nat.succ_le_iff.mp hB
   -- Since B has cardinality greater or equal to 3, there must exist a subset C ⊆ B such that
chore: Make Set/Finset lemmas match lattice lemma names (#7378)

Rename union_eq_left_iff_subset to union_eq_left to match sup_eq_left. Similarly for the right and inter versions.

Diff
@@ -40,6 +40,7 @@ Then, by the Pigeonhole principle, at least two numbers in the triplet must lie
 which finishes the proof.
 -/
 
+open Finset
 
 namespace Imo2021Q1
 
@@ -123,8 +124,8 @@ theorem imo2021_q1 :
   have hBsub : B ⊆ Finset.Icc n (2 * n) := by
     intro c hcB; simpa only [Finset.mem_Icc] using h₂ c hcB
   have hB' : 2 * 1 < (B ∩ (Finset.Icc n (2 * n) \ A) ∪ B ∩ A).card := by
-    rw [← Finset.inter_distrib_left, Finset.sdiff_union_self_eq_union,
-      Finset.union_eq_left_iff_subset.mpr hA, (Finset.inter_eq_left_iff_subset _ _).mpr hBsub]
+    rw [←inter_distrib_left, sdiff_union_self_eq_union, union_eq_left.2 hA,
+      inter_eq_left.2 hBsub]
     exact Nat.succ_le_iff.mp hB
   -- Since B has cardinality greater or equal to 3, there must exist a subset C ⊆ B such that
   -- for any A ⊆ [n, 2n], either C ⊆ A or C ⊆ [n, 2n] \ A and C has cardinality greater
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,17 +2,14 @@
 Copyright (c) 2021 Mantas Bakšys. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mantas Bakšys
-
-! This file was ported from Lean 3 source module imo.imo2021_q1
-! 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.Data.Nat.Interval
 import Mathlib.Data.Nat.Sqrt
 import Mathlib.Tactic.IntervalCases
 import Mathlib.Tactic.Linarith
 
+#align_import imo.imo2021_q1 from "leanprover-community/mathlib"@"308826471968962c6b59c7ff82a22757386603e3"
+
 /-!
 # IMO 2021 Q1
 
chore: cleanup whitespace (#5988)

Grepping for [^ .:{-] [^ :] and reviewing the results. Once I started I couldn't stop. :-)

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

Diff
@@ -60,7 +60,7 @@ theorem exists_numbers_in_interval (n : ℕ) (hn : 100 ≤ n) :
     linarith only [hn]
   rw [← Nat.sub_add_cancel hn'] at h₁ h₂ h₃
   set l := (n + 1).sqrt - 1
-  refine ⟨l, ?_,  ?_⟩
+  refine ⟨l, ?_, ?_⟩
   · calc n + 4 * l ≤ (l ^ 2 + 4 * l + 2) + 4 * l := by linarith only [h₂]
       _ ≤ 2 * l ^ 2 := by nlinarith only [h₃]
   · linarith only [h₁]
feat: port Probability.Moments (#5338)

This PR completes the port of the entire Probability folder to mathlib4.

Diff
@@ -8,11 +8,10 @@ Authors: Mantas Bakšys
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathlib.Data.Real.Sqrt
+import Mathlib.Data.Nat.Interval
+import Mathlib.Data.Nat.Sqrt
 import Mathlib.Tactic.IntervalCases
 import Mathlib.Tactic.Linarith
-import Mathlib.Tactic.NormCast
-import Mathlib.Tactic.NormNum
 
 /-!
 # IMO 2021 Q1
@@ -33,96 +32,50 @@ equations
 
 which can be solved to give
 
-    a = 2 * l * l - 4 * l
-    b = 2 * l * l + 1
-    c = 2 * l * l + 4 * l
+    a = 2 * l ^ 2 - 4 * l
+    b = 2 * l ^ 2 + 1
+    c = 2 * l ^ 2 + 4 * l
 
 Therefore, it is enough to show that there exists a natural number l such that
-`n ≤ 2 * l * l - 4 * l` and `2 * l * l + 4 * l ≤ 2 * n` for `n ≥ 100`.
+`n ≤ 2 * l ^ 2 - 4 * l` and `2 * l ^ 2 + 4 * l ≤ 2 * n` for `n ≥ 100`.
 
 Then, by the Pigeonhole principle, at least two numbers in the triplet must lie in the same pile,
 which finishes the proof.
 -/
 
 
-open Real
-
 namespace Imo2021Q1
 
-theorem lower_bound (n l : ℕ) (hl : 2 + sqrt (4 + 2 * n) ≤ 2 * l) : n + 4 * l ≤ 2 * l * l := by
-  suffices 2 * ((n : ℝ) + 4 * l) - 8 * l + 4 ≤ 2 * (2 * l * l) - 8 * l + 4 by
-    simp only [mul_le_mul_left, sub_le_sub_iff_right, add_le_add_iff_right, zero_lt_two] at this
-    exact_mod_cast this
-  rw [← le_sub_iff_add_le', sqrt_le_iff, pow_two] at hl
-  convert hl.2 using 1 <;> ring
-#align imo2021_q1.lower_bound Imo2021Q1.lower_bound
-
-theorem upper_bound (n l : ℕ) (hl : (l : ℝ) ≤ sqrt (1 + n) - 1) : 2 * l * l + 4 * l ≤ 2 * n := by
-  have h1 : ∀ n : ℕ, 0 ≤ 1 + (n : ℝ) := by intro n; exact_mod_cast Nat.zero_le (1 + n)
-  rw [le_sub_iff_add_le', le_sqrt (h1 l) (h1 n), pow_two] at hl
-  rw [← add_le_add_iff_right 2, ← @Nat.cast_le ℝ]
-  simp only [Nat.cast_add, Nat.cast_mul]
-  -- Porting note: Expanded `zero_lt_two` to `zero_lt_two' ℝ`
-  convert (mul_le_mul_left (zero_lt_two' ℝ)).mpr hl using 1 <;> ring
-#align imo2021_q1.upper_bound Imo2021Q1.upper_bound
-
-theorem radical_inequality {n : ℕ} (h : 107 ≤ n) : sqrt (4 + 2 * n) ≤ 2 * (sqrt (1 + n) - 3) := by
-  have h1n : 0 ≤ 1 + (n : ℝ) := by norm_cast; exact Nat.zero_le _
-  rw [sqrt_le_iff]
-  constructor
-  · -- Porting note: Expanded `zero_lt_three` to `zero_lt_three' ℝ`
-    simp only [sub_nonneg, zero_le_mul_left, zero_lt_two, le_sqrt (zero_lt_three' ℝ).le h1n]
-    norm_cast; linarith only [h]
-  ring_nf
-  rw [pow_two, ← sqrt_mul h1n, sqrt_mul_self h1n]
-  suffices 24 * sqrt (1 + n) ≤ 2 * n + 36 by linarith
-  rw [mul_self_le_mul_self_iff]
-  swap
-  · norm_num; apply sqrt_nonneg
-  swap
-  · norm_cast; linarith
-  ring_nf
-  rw [pow_two, ← sqrt_mul h1n, sqrt_mul_self h1n]
-  -- Not splitting into cases lead to a deterministic timeout on my machine
-  obtain ⟨rfl, h'⟩ : 107 = n ∨ 107 < n := eq_or_lt_of_le h
-  · norm_num
-  · norm_cast
-    nlinarith
-#align imo2021_q1.radical_inequality Imo2021Q1.radical_inequality
-
 -- We will later make use of the fact that there exists (l : ℕ) such that
--- n ≤ 2 * l * l - 4 * l and 2 * l * l + 4 * l ≤ 2 * n for n ≥ 107.
-theorem exists_numbers_in_interval (n : ℕ) (hn : 107 ≤ n) :
-    ∃ l : ℕ, n + 4 * l ≤ 2 * l * l ∧ 2 * l * l + 4 * l ≤ 2 * n := by
-  rsuffices ⟨l, t⟩ : ∃ l : ℕ, 2 + sqrt (4 + 2 * n) ≤ 2 * (l : ℝ) ∧ (l : ℝ) ≤ sqrt (1 + n) - 1
-  · exact ⟨l, lower_bound n l t.1, upper_bound n l t.2⟩
-  let x := sqrt (1 + n) - 1
-  refine' ⟨⌊x⌋₊, _, _⟩
-  · trans 2 * (x - 1)
-    · dsimp only; linarith only [radical_inequality hn]
-    · rw [mul_le_mul_left (zero_lt_two' ℝ)]; linarith only [(Nat.lt_floor_add_one x).le]
-  · apply Nat.floor_le; rw [sub_nonneg, le_sqrt]
-    all_goals norm_cast; try simp only [one_pow, le_add_iff_nonneg_right, zero_le']
+-- n ≤ 2 * l ^ 2 - 4 * l and 2 * l ^ 2 + 4 * l ≤ 2 * n for n ≥ 100.
+theorem exists_numbers_in_interval (n : ℕ) (hn : 100 ≤ n) :
+    ∃ l : ℕ, n + 4 * l ≤ 2 * l ^ 2 ∧ 2 * l ^ 2 + 4 * l ≤ 2 * n := by
+  have hn' : 1 ≤ Nat.sqrt (n + 1)
+  · rw [Nat.le_sqrt]
+    linarith
+  have h₁ := Nat.sqrt_le' (n + 1)
+  have h₂ := Nat.succ_le_succ_sqrt' (n + 1)
+  have h₃ : 10 ≤ (n + 1).sqrt
+  · rw [Nat.le_sqrt]
+    linarith only [hn]
+  rw [← Nat.sub_add_cancel hn'] at h₁ h₂ h₃
+  set l := (n + 1).sqrt - 1
+  refine ⟨l, ?_,  ?_⟩
+  · calc n + 4 * l ≤ (l ^ 2 + 4 * l + 2) + 4 * l := by linarith only [h₂]
+      _ ≤ 2 * l ^ 2 := by nlinarith only [h₃]
+  · linarith only [h₁]
 #align imo2021_q1.exists_numbers_in_interval Imo2021Q1.exists_numbers_in_interval
 
 theorem exists_triplet_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
     ∃ a b c : ℕ, n ≤ a ∧ a < b ∧ b < c ∧ c ≤ 2 * n ∧
-      (∃ k : ℕ, a + b = k * k) ∧ (∃ l : ℕ, c + a = l * l) ∧ ∃ m : ℕ, b + c = m * m := by
-  -- If n ≥ 107, we do not explicitly construct the triplet but use an existence
-  -- argument from lemma above.
-  obtain p | p : 107 ≤ n ∨ n < 107 := le_or_lt 107 n
-  · obtain ⟨l, hl1, hl2⟩ := exists_numbers_in_interval n p
-    have p : 1 < l := by contrapose! hl1; interval_cases l <;> linarith
-    have h₁ : 4 * l ≤ 2 * l * l := by linarith
-    have h₂ : 1 ≤ 2 * l := by linarith
-    refine' ⟨2 * l * l - 4 * l, 2 * l * l + 1, 2 * l * l + 4 * l, _, _, _,
-      ⟨_, ⟨2 * l - 1, _⟩, ⟨2 * l, _⟩, 2 * l + 1, _⟩⟩
-    all_goals zify [h₁, h₂]; linarith
-  -- Otherwise, if 100 ≤ n < 107, then it suffices to consider explicit
-  -- construction of a triplet {a, b, c}, which is constructed by setting l=9
-  -- in the argument at the start of the file.
-  · refine' ⟨126, 163, 198, p.le.trans _, _, _, by linarith, ⟨17, _⟩, ⟨18, _⟩, 19, _⟩
-    all_goals norm_num
+      (∃ k : ℕ, a + b = k ^ 2) ∧ (∃ l : ℕ, c + a = l ^ 2) ∧ ∃ m : ℕ, b + c = m ^ 2 := by
+  obtain ⟨l, hl1, hl2⟩ := exists_numbers_in_interval n hn
+  have p : 1 < l := by contrapose! hl1; interval_cases l <;> linarith
+  have h₁ : 4 * l ≤ 2 * l ^ 2 := by linarith
+  have h₂ : 1 ≤ 2 * l := by linarith
+  refine' ⟨2 * l ^ 2 - 4 * l, 2 * l ^ 2 + 1, 2 * l ^ 2 + 4 * l, _, _, _,
+    ⟨_, ⟨2 * l - 1, _⟩, ⟨2 * l, _⟩, 2 * l + 1, _⟩⟩
+  all_goals zify [h₁, h₂]; linarith
 #align imo2021_q1.exists_triplet_summing_to_squares Imo2021Q1.exists_triplet_summing_to_squares
 
 -- Since it will be more convenient to work with sets later on, we will translate the above claim
@@ -131,7 +84,7 @@ theorem exists_triplet_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
 theorem exists_finset_3_le_card_with_pairs_summing_to_squares (n : ℕ) (hn : 100 ≤ n) :
     ∃ B : Finset ℕ,
       2 * 1 + 1 ≤ B.card ∧
-      (∀ (a) (_ : a ∈ B) (b) (_ : b ∈ B), a ≠ b → ∃ k, a + b = k * k) ∧
+      (∀ (a) (_ : a ∈ B) (b) (_ : b ∈ B), a ≠ b → ∃ k, a + b = k ^ 2) ∧
       ∀ c ∈ B, n ≤ c ∧ c ≤ 2 * n := by
   obtain ⟨a, b, c, hna, hab, hbc, hcn, h₁, h₂, h₃⟩ := exists_triplet_summing_to_squares n hn
   refine' ⟨{a, b, c}, _, _, _⟩
@@ -160,9 +113,9 @@ open Imo2021Q1
 
 theorem imo2021_q1 :
     ∀ n : ℕ, 100 ≤ n → ∀ (A) (_ : A ⊆ Finset.Icc n (2 * n)),
-    (∃ (a : _) (_ : a ∈ A) (b : _) (_ : b ∈ A), a ≠ b ∧ ∃ k : ℕ, a + b = k * k) ∨
+    (∃ (a : _) (_ : a ∈ A) (b : _) (_ : b ∈ A), a ≠ b ∧ ∃ k : ℕ, a + b = k ^ 2) ∨
     ∃ (a : _) (_ : a ∈ Finset.Icc n (2 * n) \ A) (b : _) (_ : b ∈ Finset.Icc n (2 * n) \ A),
-      a ≠ b ∧ ∃ k : ℕ, a + b = k * k := by
+      a ≠ b ∧ ∃ k : ℕ, a + b = k ^ 2 := by
   intro n hn A hA
   -- For each n ∈ ℕ such that 100 ≤ n, there exists a pairwise unequal triplet {a, b, c} ⊆ [n, 2n]
   -- such that all pairwise sums are perfect squares. In practice, it will be easier to use
fix: consumeMData in ring_nf (#5246)

As reported on Zulip.

Dependencies 10 + 522

523 files ported (98.1%)
225700 lines ported (97.7%)
Show graph

The unported dependencies are

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