Skip to content

Commit 074dad7

Browse files
vihdzperic-wieser
andcommitted
feat: port IMO 2006 Q5 helper results (#3136)
We don't port the IMO proof itself since it seems there's no archive in Mathlib4. Mathlib 3: leanprover-community/mathlib3#15613 Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
1 parent d8d0c89 commit 074dad7

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

Mathlib/Data/Int/Basic.lean

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad
55
66
! This file was ported from Lean 3 source module data.int.basic
7-
! leanprover-community/mathlib commit 2196ab363eb097c008d4497125e0dde23fb36db2
7+
! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -127,6 +127,16 @@ theorem coe_nat_nonneg (n : ℕ) : 0 ≤ (n : ℤ) := ofNat_le.2 (Nat.zero_le _)
127127
#align int.neg_of_nat_ne_zero Int.negSucc_ne_zero
128128
#align int.zero_ne_neg_of_nat Int.zero_ne_negSucc
129129

130+
@[simp]
131+
theorem sign_coe_add_one (n : ℕ) : Int.sign (n + 1) = 1 :=
132+
rfl
133+
#align int.sign_coe_add_one Int.sign_coe_add_one
134+
135+
@[simp]
136+
theorem sign_negSucc (n : ℕ) : Int.sign -[n+1] = -1 :=
137+
rfl
138+
#align int.sign_neg_succ_of_nat Int.sign_negSucc
139+
130140
/-! ### succ and pred -/
131141

132142
/-- Immediate successor of an integer: `succ n = n + 1` -/

Mathlib/Data/Int/Order/Basic.lean

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad
55
66
! This file was ported from Lean 3 source module data.int.order.basic
7-
! leanprover-community/mathlib commit bd835ef554f37ef9b804f0903089211f89cb370b
7+
! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -90,6 +90,13 @@ theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
9090
@[norm_cast] lemma abs_coe_nat (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (coe_nat_nonneg n)
9191
#align int.abs_coe_nat Int.abs_coe_nat
9292

93+
theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign := by
94+
have : (1 : ℤ) ≠ -1 := by decide
95+
rintro ((_ | m) | m) ((_ | n) | n) <;> simp [this, this.symm]
96+
rw [Int.sign_eq_one_iff_pos]
97+
apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| coe_nat_nonneg _)
98+
#align int.sign_add_eq_of_sign_eq Int.sign_add_eq_of_sign_eq
99+
93100
/-! ### succ and pred -/
94101

95102

Mathlib/Data/List/Cycle.lean

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yakov Pechersky
55
66
! This file was ported from Lean 3 source module data.list.cycle
7-
! leanprover-community/mathlib commit 008205aa645b3f194c1da47025c5f110c8406eab
7+
! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -745,6 +745,12 @@ theorem map_eq_nil {β : Type _} (f : α → β) (s : Cycle α) : map f s = nil
745745
Quotient.inductionOn' s (by simp)
746746
#align cycle.map_eq_nil Cycle.map_eq_nil
747747

748+
@[simp]
749+
theorem mem_map {β : Type _} {f : α → β} {b : β} {s : Cycle α} :
750+
b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=
751+
Quotient.inductionOn' s (by simp)
752+
#align cycle.mem_map Cycle.mem_map
753+
748754
/-- The `Multiset` of lists that can make the cycle. -/
749755
def lists (s : Cycle α) : Multiset (List α) :=
750756
Quotient.liftOn' s (fun l => (l.cyclicPermutations : Multiset (List α))) fun l₁ l₂ h => by

Mathlib/Data/Polynomial/Degree/Lemmas.lean

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker
55
66
! This file was ported from Lean 3 source module data.polynomial.degree.lemmas
7-
! leanprover-community/mathlib commit 302eab4f46abb63de520828de78c04cb0f9b5836
7+
! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -355,6 +355,14 @@ theorem natDegree_comp : natDegree (p.comp q) = natDegree p * natDegree q := by
355355
ne_zero_of_natDegree_gt (Nat.pos_of_ne_zero q0), pow_ne_zero, Ne.def, not_false_iff]
356356
#align polynomial.nat_degree_comp Polynomial.natDegree_comp
357357

358+
@[simp]
359+
theorem natDegree_iterate_comp (k : ℕ) :
360+
((p.comp^[k]) q).natDegree = p.natDegree ^ k * q.natDegree := by
361+
induction' k with k IH
362+
· simp
363+
· rw [Function.iterate_succ_apply', natDegree_comp, IH, pow_succ, mul_assoc]
364+
#align polynomial.nat_degree_iterate_comp Polynomial.natDegree_iterate_comp
365+
358366
theorem leadingCoeff_comp (hq : natDegree q ≠ 0) :
359367
leadingCoeff (p.comp q) = leadingCoeff p * leadingCoeff q ^ natDegree p := by
360368
rw [← coeff_comp_degree_mul_degree hq, ← natDegree_comp, coeff_natDegree]

Mathlib/Data/Polynomial/Eval.lean

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker
55
66
! This file was ported from Lean 3 source module data.polynomial.eval
7-
! leanprover-community/mathlib commit e064a7bf82ad94c3c17b5128bbd860d1ec34874e
7+
! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -1035,6 +1035,14 @@ theorem eval₂_comp {x : S} : eval₂ f x (p.comp q) = eval₂ f (eval₂ f x q
10351035
rw [comp, p.as_sum_range]; simp [eval₂_finset_sum, eval₂_pow]
10361036
#align polynomial.eval₂_comp Polynomial.eval₂_comp
10371037

1038+
@[simp]
1039+
theorem iterate_comp_eval₂ (k : ℕ) (t : S) :
1040+
eval₂ f t ((p.comp^[k]) q) = ((fun x => eval₂ f x p)^[k]) (eval₂ f t q) := by
1041+
induction' k with k IH
1042+
· simp
1043+
· rw [Function.iterate_succ_apply', Function.iterate_succ_apply', eval₂_comp, IH]
1044+
#align polynomial.iterate_comp_eval₂ Polynomial.iterate_comp_eval₂
1045+
10381046
end
10391047

10401048
section

0 commit comments

Comments
 (0)