declaration stringlengths 27 11.3k | file stringlengths 52 114 | context dict | tactic_states listlengths 1 1.24k |
|---|---|---|---|
theorem Nat.Prime.sq_add_sq' {p : β} [h : Fact p.Prime] (hp : p % 4 = 1) :
β a b : β, a ^ 2 + b ^ 2 = p := by
rw [β div_add_mod p 4] at h β’
rw [hp] at h β’
let k := p / 4
apply sq_add_sq_of_nonempty_fixedPoints
have key := (Equiv.Perm.card_fixedPoints_modEq (p := 2) (n := 1) (obvInvo_sq k)).symm.trans
(Equiv.Perm.card_fixedPoints_modEq (p := 2) (n := 1) (complexInvo_sq k))
contrapose key
rw [Set.not_nonempty_iff_eq_empty] at key
simp_rw [k, key, Fintype.card_eq_zero, card_fixedPoints_eq_one]
decide | /root/DuelModelResearch/mathlib4/Archive/ZagierTwoSquares.lean | {
"open": [
"Set",
"Function",
"Zagier"
],
"variables": [
"(k : β) [hk : Fact (4 * k + 1).Prime]",
"(k : β)",
"[hk : Fact (4 * k + 1).Prime]"
]
} | [
{
"line": "rw [β div_add_mod p 4] at h β’",
"before_state": "p : β\nh : Fact (Prime p)\nhp : p % 4 = 1\nβ’ β a b, a ^ 2 + b ^ 2 = p",
"after_state": "p : β\nh : Fact (Prime (4 * (p / 4) + p % 4))\nhp : p % 4 = 1\nβ’ β a b, a ^ 2 + b ^ 2 = 4 * (p / 4) + p % 4"
},
{
"line": "rewrite [β div_add_mod p ... |
example : Β¬ LucasLehmerTest 2 := by norm_num
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ Β¬LucasLehmerTest 2",
"after_state": "No Goals!"
}
] |
example : (mersenne 2).Prime := by decide
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "decide",
"before_state": "β’ Nat.Prime (mersenne 2)",
"after_state": "No Goals!"
}
] |
example : (mersenne 3).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 3",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 3",
"after_state": "No Goals!"
}
] |
example : (mersenne 5).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 5",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 5",
"after_state": "No Goals!"
}
] |
example : (mersenne 7).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 7",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 7",
"after_state": "No Goals!"
}
] |
example : (mersenne 13).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 13",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 13",
"after_state": "No Goals!"
}
] |
example : (mersenne 17).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 17",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 17",
"after_state": "No Goals!"
}
] |
example : (mersenne 19).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 19",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 19",
"after_state": "No Goals!"
}
] |
example : (mersenne 31).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 31",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 31",
"after_state": "No Goals!"
}
] |
example : (mersenne 61).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 61",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 61",
"after_state": "No Goals!"
}
] |
example : (mersenne 89).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 89",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 89",
"after_state": "No Goals!"
}
] |
example : (mersenne 107).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 107",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 107",
"after_state": "No Goals!"
}
] |
example : (mersenne 127).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 127",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 127",
"after_state": "No Goals!"
}
] |
example : (mersenne 521).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 521",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 521",
"after_state": "No Goals!"
}
] |
example : (mersenne 607).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 607",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 607",
"after_state": "No Goals!"
}
] |
example : (mersenne 1279).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 1279",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 1279",
"after_state": "No Goals!"
}
] |
example : (mersenne 2203).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 2203",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 2203",
"after_state": "No Goals!"
}
] |
example : (mersenne 2281).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 2281",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 2281",
"after_state": "No Goals!"
}
] |
example : (mersenne 3217).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 3217",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 3217",
"after_state": "No Goals!"
}
] |
example : (mersenne 4253).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 4253",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 4253",
"after_state": "No Goals!"
}
] |
example : (mersenne 4423).Prime :=
lucas_lehmer_sufficiency _ (by norm_num) (by norm_num)
| /root/DuelModelResearch/mathlib4/Archive/Examples/MersennePrimes.lean | {
"open": [],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 1 < 4423",
"after_state": "No Goals!"
},
{
"line": "norm_num",
"before_state": "β’ LucasLehmerTest 4423",
"after_state": "No Goals!"
}
] |
theorem calculation (n k : β) (h1 : k β£ 21 * n + 4) (h2 : k β£ 14 * n + 3) : k β£ 1 :=
have h3 : k β£ 2 * (21 * n + 4) := h1.mul_left 2
have h4 : k β£ 3 * (14 * n + 3) := h2.mul_left 3
have h5 : 3 * (14 * n + 3) = 2 * (21 * n + 4) + 1 := by ring
(Nat.dvd_add_right h3).mp (h5 βΈ h4)
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1959Q1.lean | {
"open": [
"Nat"
],
"variables": []
} | [
{
"line": "ring",
"before_state": "n k : β\nh1 : k β£ 21 * n + 4\nh2 : k β£ 14 * n + 3\nh3 : k β£ 2 * (21 * n + 4)\nh4 : k β£ 3 * (14 * n + 3)\nβ’ 3 * (14 * n + 3) = 2 * (21 * n + 4) + 1",
"after_state": "No Goals!"
},
{
"line": "first\n| ring1\n|\n try_this ring_nf\"\\n\\nThe `ring` tactic failed t... |
theorem Imo1961Q3 {n : β} {x : β} (hβ : n β 0) :
(cos x) ^ n - (sin x) ^ n = 1 β
(β k : β€, k * Ο = x) β§ Even n β¨ (β k : β€, k * (2 * Ο) = x) β§ Odd n β¨
(β k : β€, -(Ο / 2) + k * (2 * Ο) = x) β§ Odd n := by
constructor
Β· intro h
rcases eq_or_ne (sin x) 0 with hsinx | hsinx
Β· rw [hsinx, zero_pow hβ, sub_zero, pow_eq_one_iff_of_ne_zero hβ, cos_eq_one_iff,
cos_eq_neg_one_iff] at h
rcases h with β¨k, rflβ© | β¨β¨k, rflβ©, hnβ©
Β· cases n.even_or_odd with
| inl hn => refine .inl β¨β¨k * 2, ?_β©, hnβ©; simp [mul_assoc]
| inr hn => exact .inr <| .inl β¨β¨_, rflβ©, hnβ©
Β· exact .inl β¨β¨2 * k + 1, by push_cast; ringβ©, hnβ©
Β· rcases eq_or_ne (cos x) 0 with hcosx | hcosx
Β· right; right
rw [hcosx] at h
rw [zero_pow hβ] at h
rw [zero_sub] at h
rw [β neg_inj] at h
rw [neg_neg] at h
rw [pow_eq_neg_one_iff] at h
rw [sin_eq_neg_one_iff] at h
simpa only [eq_comm] using h
Β· have hcos1 : |cos x| < 1 := by
rw [abs_cos_eq_sqrt_one_sub_sin_sq]
rw [sqrt_lt' one_pos]
simp [sq_pos_of_ne_zero hsinx]
have hsin1 : |sin x| < 1 := by
rw [abs_sin_eq_sqrt_one_sub_cos_sq]
rw [sqrt_lt' one_pos]
simp [sq_pos_of_ne_zero hcosx]
match n with
| 1 =>
rw [pow_one] at h
rw [pow_one] at h
rw [sub_eq_iff_eq_add] at h
have : 2 * sin x * cos x = 0 := by
simpa [h, add_sq, add_assoc, β two_mul, mul_add, mul_assoc, β sq]
using cos_sq_add_sin_sq x
simp [hsinx, hcosx] at this
| 2 =>
rw [β cos_sq_add_sin_sq x] at h
rw [sub_eq_add_neg] at h
rw [add_right_inj] at h
rw [neg_eq_self β] at h
exact absurd (pow_eq_zero h) hsinx
| (n + 1 + 2) =>
set m := n + 1
refine absurd ?_ h.not_lt
calc
(cos x) ^ (m + 2) - (sin x) ^ (m + 2) β€ |cos x| ^ (m + 2) + |sin x| ^ (m + 2) := by
simp only [β abs_pow]
simp only [sub_eq_add_neg]
gcongr
exacts [le_abs_self _, neg_le_abs _]
_ = |cos x| ^ m * cos x ^ 2 + |sin x| ^ m * sin x ^ 2 := by simp [pow_add]
_ < 1 ^ m * cos x ^ 2 + 1 ^ m * sin x ^ 2 := by gcongr
_ = 1 := by simp
Β· rintro (β¨β¨k, rflβ©, hnβ© | β¨β¨k, rflβ©, -β© | β¨β¨k, rflβ©, hnβ©)
Β· rw [sin_int_mul_pi, zero_pow hβ, sub_zero, β hn.pow_abs, abs_cos_int_mul_pi, one_pow]
Β· have : sin (k * (2 * Ο)) = 0 := by simpa [mul_assoc] using sin_int_mul_pi (k * 2)
simp [hβ, this]
Β· simp [hn.neg_pow, hβ] | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1961Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "constructor",
"before_state": "n : β\nx : β\nhβ : n β 0\nβ’ cos x ^ n - sin x ^ n = 1 β\n (β k, βk * Ο = x) β§ Even n β¨ (β k, βk * (2 * Ο) = x) β§ Odd n β¨ (β k, -(Ο / 2) + βk * (2 * Ο) = x) β§ Odd n",
"after_state": "case mp\nn : β\nx : β\nhβ : n β 0\nβ’ cos x ^ n - sin x ^ n = 1 β\n (β k, β... |
theorem solve_cos2_half {x : β} : cos x ^ 2 = 1 / 2 β β k : β€, x = (2 * βk + 1) * Ο / 4 := by
rw [cos_sq]
simp only [add_eq_left]
simp only [div_eq_zero_iff]
norm_num
rw [cos_eq_zero_iff]
constructor <;>
Β· rintro β¨k, hβ©
use k
linarith
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1962Q4.lean | {
"open": [
"Real",
"scoped Real"
],
"variables": []
} | [
{
"line": "rw [cos_sq]",
"before_state": "x : β\nβ’ cos x ^ 2 = 1 / 2 β β k, x = (2 * βk + 1) * Ο / 4",
"after_state": "x : β\nβ’ 1 / 2 + cos (2 * x) / 2 = 1 / 2 β β k, x = (2 * βk + 1) * Ο / 4"
},
{
"line": "rewrite [cos_sq]",
"before_state": "x : β\nβ’ cos x ^ 2 = 1 / 2 β β k, x = (2 * βk + 1... |
theorem solve_cos3x_0 {x : β} : cos (3 * x) = 0 β β k : β€, x = (2 * βk + 1) * Ο / 6 := by
rw [cos_eq_zero_iff]
refine exists_congr fun k => ?_
constructor <;> intro <;> linarith
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1962Q4.lean | {
"open": [
"Real",
"scoped Real"
],
"variables": []
} | [
{
"line": "rw [cos_eq_zero_iff]",
"before_state": "x : β\nβ’ cos (3 * x) = 0 β β k, x = (2 * βk + 1) * Ο / 6",
"after_state": "x : β\nβ’ (β k, 3 * x = (2 * βk + 1) * Ο / 2) β β k, x = (2 * βk + 1) * Ο / 6"
},
{
"line": "rewrite [cos_eq_zero_iff]",
"before_state": "x : β\nβ’ cos (3 * x) = 0 β β ... |
theorem formula {R : Type*} [CommRing R] [IsDomain R] [CharZero R] (a : R) :
a ^ 2 + ((2 : R) * a ^ 2 - (1 : R)) ^ 2 + ((4 : R) * a ^ 3 - 3 * a) ^ 2 = 1 β
((2 : R) * a ^ 2 - (1 : R)) * ((4 : R) * a ^ 3 - 3 * a) = 0 := by
constructor <;> intro h
Β· apply pow_eq_zero (n := 2)
apply mul_left_injectiveβ (b := 2) (by norm_num)
linear_combination (8 * a ^ 4 - 10 * a ^ 2 + 3) * h
Β· linear_combination 2 * a * h
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1962Q4.lean | {
"open": [
"Real",
"scoped Real",
"Imo1962Q4"
],
"variables": []
} | [
{
"line": "focus\n constructor\n with_annotate_state\"<;>\" skip\n all_goals intro h",
"before_state": "R : Type u_1\ninstβΒ² : CommRing R\ninstβΒΉ : IsDomain R\ninstβ : CharZero R\na : R\nβ’ a ^ 2 + (2 * a ^ 2 - 1) ^ 2 + (4 * a ^ 3 - 3 * a) ^ 2 = 1 β (2 * a ^ 2 - 1) * (4 * a ^ 3 - 3 * a) = 0",
"after_s... |
theorem solve_cos2x_0 {x : β} : cos (2 * x) = 0 β β k : β€, x = (2 * βk + 1) * Ο / 4 := by
rw [cos_eq_zero_iff]
refine exists_congr fun k => ?_
constructor <;> intro <;> linarith
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1962Q4.lean | {
"open": [
"Real",
"scoped Real",
"Imo1962Q4"
],
"variables": []
} | [
{
"line": "rw [cos_eq_zero_iff]",
"before_state": "x : β\nβ’ cos (2 * x) = 0 β β k, x = (2 * βk + 1) * Ο / 4",
"after_state": "x : β\nβ’ (β k, 2 * x = (2 * βk + 1) * Ο / 2) β β k, x = (2 * βk + 1) * Ο / 4"
},
{
"line": "rewrite [cos_eq_zero_iff]",
"before_state": "x : β\nβ’ cos (2 * x) = 0 β β ... |
lemma two_sin_pi_div_seven_ne_zero : 2 * sin (Ο / 7) β 0 := by
apply mul_ne_zero two_ne_zero (Real.sin_pos_of_pos_of_lt_pi _ _).ne' <;> linarith [pi_pos]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1963Q5.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "focus\n apply mul_ne_zero two_ne_zero (Real.sin_pos_of_pos_of_lt_pi _ _).ne'\n with_annotate_state\"<;>\" skip\n all_goals linarith [pi_pos]",
"before_state": "β’ 2 * sin (Ο / 7) β 0",
"after_state": "No Goals!"
},
{
"line": "apply mul_ne_zero two_ne_zero (Real.sin_pos_of_pos_of_lt_... |
lemma sin_pi_mul_neg_div (a b : β) : sin (Ο * (- a / b)) = - sin (Ο * (a / b)) := by
ring_nf
exact sin_neg _
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1963Q5.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "ring_nf",
"before_state": "a b : β\nβ’ sin (Ο * (-a / b)) = -sin (Ο * (a / b))",
"after_state": "a b : β\nβ’ sin (-(Ο * a * bβ»ΒΉ)) = -sin (Ο * a * bβ»ΒΉ)"
},
{
"line": "exact sin_neg _",
"before_state": "a b : β\nβ’ sin (-(Ο * a * bβ»ΒΉ)) = -sin (Ο * a * bβ»ΒΉ)",
"after_state": "No Goal... |
theorem two_pow_mod_seven (n : β) : 2 ^ n β‘ 2 ^ (n % 3) [MOD 7] :=
let t := n % 3
calc 2 ^ n = 2 ^ (3 * (n / 3) + t) := by rw [Nat.div_add_mod]
_ = (2 ^ 3) ^ (n / 3) * 2 ^ t := by rw [pow_add, pow_mul]
_ β‘ 1 ^ (n / 3) * 2 ^ t [MOD 7] := by gcongr; decide
_ = 2 ^ t := by ring
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1964Q1.lean | {
"open": [
"Nat"
],
"variables": []
} | [
{
"line": "rw [Nat.div_add_mod]",
"before_state": "n : β\nt : β := n % 3\nβ’ 2 ^ n = 2 ^ (3 * (n / 3) + t)",
"after_state": "No Goals!"
},
{
"line": "rewrite [Nat.div_add_mod]",
"before_state": "n : β\nt : β := n % 3\nβ’ 2 ^ n = 2 ^ (3 * (n / 3) + t)",
"after_state": "n : β\nt : β := n % 3... |
theorem imo1964_q1a (n : β) (_ : 0 < n) : 7 β£ 2 ^ n - 1 β 3 β£ n := by
let t := n % 3
have : t < 3 := Nat.mod_lt _ (by decide)
calc 7 β£ 2 ^ n - 1 β 2 ^ n β‘ 1 [MOD 7] := by
rw [Nat.ModEq.comm]
rw [Nat.modEq_iff_dvd']
apply Nat.one_le_pow'
_ β 2 ^ t β‘ 1 [MOD 7] := β¨(two_pow_mod_seven n).symm.trans, (two_pow_mod_seven n).transβ©
_ β t = 0 := by interval_cases t <;> decide
_ β 3 β£ n := by rw [dvd_iff_mod_eq_zero]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1964Q1.lean | {
"open": [
"Nat",
"Imo1964Q1"
],
"variables": []
} | [
{
"line": "let t := n % 3",
"before_state": "n : β\nxβ : 0 < n\nβ’ 7 β£ 2 ^ n - 1 β 3 β£ n",
"after_state": "n : β\nxβ : 0 < n\nt : β := n % 3\nβ’ 7 β£ 2 ^ n - 1 β 3 β£ n"
},
{
"line": "refine_lift\n let t := n % 3;\n ?_",
"before_state": "n : β\nxβ : 0 < n\nβ’ 7 β£ 2 ^ n - 1 β 3 β£ n",
"after_... |
theorem imo1964_q1b (n : β) : Β¬7 β£ 2 ^ n + 1 := by
intro h
let t := n % 3
have : t < 3 := Nat.mod_lt _ (by decide)
have H : 2 ^ t + 1 β‘ 0 [MOD 7] := calc
2 ^ t + 1 β‘ 2 ^ n + 1 [MOD 7] := by gcongr ?_ + 1; exact (two_pow_mod_seven n).symm
_ β‘ 0 [MOD 7] := h.modEq_zero_nat
interval_cases t <;> contradiction | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1964Q1.lean | {
"open": [
"Nat",
"Imo1964Q1"
],
"variables": []
} | [
{
"line": "intro h",
"before_state": "n : β\nβ’ Β¬7 β£ 2 ^ n + 1",
"after_state": "n : β\nh : 7 β£ 2 ^ n + 1\nβ’ False"
},
{
"line": "let t := n % 3",
"before_state": "n : β\nh : 7 β£ 2 ^ n + 1\nβ’ False",
"after_state": "n : β\nh : 7 β£ 2 ^ n + 1\nt : β := n % 3\nβ’ False"
},
{
"line": "... |
theorem left_factor_large {m : β€} (n : β€) (h : 1 < m) : 1 < (n - m) ^ 2 + m ^ 2 := by nlinarith
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1969Q1.lean | {
"open": [
"Int Nat"
],
"variables": []
} | [
{
"line": "nlinarith",
"before_state": "m n : β€\nh : 1 < m\nβ’ 1 < (n - m) ^ 2 + m ^ 2",
"after_state": "No Goals!"
},
{
"line": "ring1",
"before_state": "m n : β€\nh : 1 < m\naβ : 1 β₯ (n - m) ^ 2 + m ^ 2\nβ’ 3 * -1 + (0 - (n - m) ^ 2) + 4 * (1 + 1 - m) + ((n - m) ^ 2 + m ^ 2 - 1) + (0 - (1 + 1... |
theorem right_factor_large {m : β€} (n : β€) (h : 1 < m) : 1 < (n + m) ^ 2 + m ^ 2 := by nlinarith
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1969Q1.lean | {
"open": [
"Int Nat"
],
"variables": []
} | [
{
"line": "nlinarith",
"before_state": "m n : β€\nh : 1 < m\nβ’ 1 < (n + m) ^ 2 + m ^ 2",
"after_state": "No Goals!"
},
{
"line": "ring1",
"before_state": "m n : β€\nh : 1 < m\naβ : 1 β₯ (n + m) ^ 2 + m ^ 2\nβ’ 3 * -1 + (0 - (n + m) ^ 2) + 4 * (1 + 1 - m) + ((n + m) ^ 2 + m ^ 2 - 1) + (0 - (1 + 1... |
theorem int_large {m : β€} (h : 1 < m) : 1 < m.natAbs := by
exact_mod_cast lt_of_lt_of_le h le_natAbs
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1969Q1.lean | {
"open": [
"Int Nat"
],
"variables": []
} | [
{
"line": "exact_mod_cast lt_of_lt_of_le h le_natAbs",
"before_state": "m : β€\nh : 1 < m\nβ’ 1 < m.natAbs",
"after_state": "No Goals!"
},
{
"line": "exact mod_cast (lt_of_lt_of_le h le_natAbs : _)",
"before_state": "m : β€\nh : 1 < m\nβ’ 1 < m.natAbs",
"after_state": "No Goals!"
}
] |
theorem polynomial_not_prime {m : β} (h1 : 1 < m) (n : β) : Β¬Nat.Prime (n ^ 4 + 4 * m ^ 4) := by
have h2 : 1 < (m : β€) := Int.ofNat_lt.mpr h1
refine not_prime_of_int_mul' (left_factor_large (n : β€) h2) (right_factor_large (n : β€) h2) ?_
apply factorization
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1969Q1.lean | {
"open": [
"Int Nat"
],
"variables": []
} | [
{
"line": "have h2 : 1 < (m : β€) := Int.ofNat_lt.mpr h1",
"before_state": "m : β\nh1 : 1 < m\nn : β\nβ’ Β¬Nat.Prime (n ^ 4 + 4 * m ^ 4)",
"after_state": "m : β\nh1 : 1 < m\nn : β\nh2 : 1 < βm\nβ’ Β¬Nat.Prime (n ^ 4 + 4 * m ^ 4)"
},
{
"line": "refine_lift\n have h2 : 1 < (m : β€) := Int.ofNat_lt.mpr ... |
theorem bound (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) :
a ^ 4 / (a ^ 4 + b ^ 4 + c ^ 4) β€ a ^ 3 / sqrt ((a ^ 3) ^ 2 + β8 * b ^ 3 * c ^ 3) := by
rw [div_le_div_iffβ (by positivity) (by positivity)]
calc a ^ 4 * sqrt ((a ^ 3) ^ 2 + (8:β) * b ^ 3 * c ^ 3)
= a ^ 3 * (a * sqrt ((a ^ 3) ^ 2 + (8:β) * b ^ 3 * c ^ 3)) := by ring
_ β€ a ^ 3 * (a ^ 4 + b ^ 4 + c ^ 4) := ?_
gcongr
apply le_of_pow_le_pow_leftβ two_ne_zero (by positivity)
rw [mul_pow]
rw [sq_sqrt (by positivity)]
rw [β sub_nonneg]
calc
(a ^ 4 + b ^ 4 + c ^ 4) ^ 2 - a ^ 2 * ((a ^ 3) ^ 2 + 8 * b ^ 3 * c ^ 3)
= 2 * (a ^ 2 * (b ^ 2 - c ^ 2)) ^ 2 + (b ^ 4 - c ^ 4) ^ 2 +
(2 * (a ^ 2 * b * c - b ^ 2 * c ^ 2)) ^ 2 := by ring
_ β₯ 0 := by positivity
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2001Q2.lean | {
"open": [
"Real"
],
"variables": [
"{a b c : β}"
]
} | [
{
"line": "rw [div_le_div_iffβ (by positivity) (by positivity)]",
"before_state": "a b c : β\nha : 0 < a\nhb : 0 < b\nhc : 0 < c\nβ’ a ^ 4 / (a ^ 4 + b ^ 4 + c ^ 4) β€ a ^ 3 / β((a ^ 3) ^ 2 + 8 * b ^ 3 * c ^ 3)",
"after_state": "a b c : β\nha : 0 < a\nhb : 0 < b\nhc : 0 < c\nβ’ a ^ 4 * β((a ^ 3) ^ 2 + 8 * ... |
theorem imo2001_q6 (hd : 0 < d) (hdc : d < c) (hcb : c < b) (hba : b < a)
(h : a * c + b * d = (a + b - c + d) * (-a + b + c + d)) : Β¬Prime (a * b + c * d) := by
intro (h0 : Prime (a * b + c * d))
have ha : 0 < a := by omega
have hb : 0 < b := by omega
have hc : 0 < c := by omega
-- the key step is to show that `a*c + b*d` divides the product `(a*b + c*d) * (a*d + b*c)`
have dvd_mul : a * c + b * d β£ (a * b + c * d) * (a * d + b * c) := by
use b ^ 2 + b * d + d ^ 2
linear_combination b * d * h
-- since `a*b + c*d` is prime (by assumption), it must divide `a*c + b*d` or `a*d + b*c`
obtain (h1 : a * b + c * d β£ a * c + b * d) | (h2 : a * c + b * d β£ a * d + b * c) :=
h0.left_dvd_or_dvd_right_of_dvd_mul dvd_mul
-- in both cases, we derive a contradiction
Β· have aux : 0 < a * c + b * d := by nlinarith only [ha, hb, hc, hd]
have : a * b + c * d β€ a * c + b * d := Int.le_of_dvd aux h1
nlinarith only [hba, hcb, hdc, h, this]
Β· have aux : 0 < a * d + b * c := by nlinarith only [ha, hb, hc, hd]
have : a * c + b * d β€ a * d + b * c := Int.le_of_dvd aux h2
nlinarith only [hba, hdc, h, this] | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2001Q6.lean | {
"open": [],
"variables": [
"{a b c d : β€}"
]
} | [
{
"line": "intro (h0 : Prime (a * b + c * d))",
"before_state": "a b c d : β€\nhd : 0 < d\nhdc : d < c\nhcb : c < b\nhba : b < a\nh : a * c + b * d = (a + b - c + d) * (-a + b + c + d)\nβ’ Β¬Prime (a * b + c * d)",
"after_state": "a b c d : β€\nhd : 0 < d\nhdc : d < c\nhcb : c < b\nhba : b < a\nh : a * c + ... |
theorem key_insight (x y z : β) (hx : x > 0) (hy : y > 0) (hz : z > 0) (h : x * y * z β₯ 1) :
(x ^ 5 - x ^ 2) / (x ^ 5 + y ^ 2 + z ^ 2) β₯ (x ^ 2 - y * z) / (x ^ 2 + y ^ 2 + z ^ 2) := by
have key :
(x ^ 5 - x ^ 2) / (x ^ 5 + y ^ 2 + z ^ 2) -
(x ^ 5 - x ^ 2 * 1) / (x ^ 3 * (x ^ 2 + y ^ 2 + z ^ 2)) =
(x ^ 3 - 1) ^ 2 * x ^ 2 * (y ^ 2 + z ^ 2) /
((x ^ 5 + y ^ 2 + z ^ 2) * (x ^ 3 * (x ^ 2 + y ^ 2 + z ^ 2))) := by
field_simp
ring
have hβ
:
(x ^ 3 - 1) ^ 2 * x ^ 2 * (y ^ 2 + z ^ 2) /
((x ^ 5 + y ^ 2 + z ^ 2) * (x ^ 3 * (x ^ 2 + y ^ 2 + z ^ 2))) β₯ 0 := by positivity
calc
(x ^ 5 - x ^ 2) / (x ^ 5 + y ^ 2 + z ^ 2)
β₯ (x ^ 5 - x ^ 2 * 1) / (x ^ 3 * (x ^ 2 + y ^ 2 + z ^ 2)) := by linarith only [key, hβ
]
_ β₯ (x ^ 5 - x ^ 2 * (x * y * z)) / (x ^ 3 * (x ^ 2 + y ^ 2 + z ^ 2)) := by gcongr
_ = (x ^ 2 - y * z) / (x ^ 2 + y ^ 2 + z ^ 2) := by field_simp; ring
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2005Q3.lean | {
"open": [],
"variables": []
} | [
{
"line": "have key :\n (x ^ 5 - x ^ 2) / (x ^ 5 + y ^ 2 + z ^ 2) - (x ^ 5 - x ^ 2 * 1) / (x ^ 3 * (x ^ 2 + y ^ 2 + z ^ 2)) =\n (x ^ 3 - 1) ^ 2 * x ^ 2 * (y ^ 2 + z ^ 2) / ((x ^ 5 + y ^ 2 + z ^ 2) * (x ^ 3 * (x ^ 2 + y ^ 2 + z ^ 2))) :=\n by\n field_simp\n ring",
"before_state": "x y z : β\nhx : x > ... |
theorem imo2005_q3 (x y z : β) (hx : x > 0) (hy : y > 0) (hz : z > 0) (h : x * y * z β₯ 1) :
(x ^ 5 - x ^ 2) / (x ^ 5 + y ^ 2 + z ^ 2) + (y ^ 5 - y ^ 2) / (y ^ 5 + z ^ 2 + x ^ 2) +
(z ^ 5 - z ^ 2) / (z ^ 5 + x ^ 2 + y ^ 2) β₯
0 := by
calc
(x ^ 5 - x ^ 2) / (x ^ 5 + y ^ 2 + z ^ 2) + (y ^ 5 - y ^ 2) / (y ^ 5 + z ^ 2 + x ^ 2) +
(z ^ 5 - z ^ 2) / (z ^ 5 + x ^ 2 + y ^ 2) β₯
(x ^ 2 - y * z) / (x ^ 2 + y ^ 2 + z ^ 2) + (y ^ 2 - z * x) / (y ^ 2 + z ^ 2 + x ^ 2) +
(z ^ 2 - x * y) / (z ^ 2 + x ^ 2 + y ^ 2) := by
gcongr ?_ + ?_ + ?_ <;> apply key_insight <;> linarith
_ = 1 / 2 * ((x - y) ^ 2 + (y - z) ^ 2 + (z - x) ^ 2) / (x ^ 2 + y ^ 2 + z ^ 2) := by ring
_ β₯ 0 := by positivity | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2005Q3.lean | {
"open": [
"Imo2005Q3"
],
"variables": []
} | [
{
"line": "calc\n (x ^ 5 - x ^ 2) / (x ^ 5 + y ^ 2 + z ^ 2) + (y ^ 5 - y ^ 2) / (y ^ 5 + z ^ 2 + x ^ 2) +\n (z ^ 5 - z ^ 2) / (z ^ 5 + x ^ 2 + y ^ 2) β₯\n (x ^ 2 - y * z) / (x ^ 2 + y ^ 2 + z ^ 2) + (y ^ 2 - z * x) / (y ^ 2 + z ^ 2 + x ^ 2) +\n (z ^ 2 - x * y) / (z ^ 2 + x ^ 2 + y ^ 2) :=\n ... |
theorem lhs_ineq {x y : β} (hxy : 0 β€ x * y) :
16 * x ^ 2 * y ^ 2 * (x + y) ^ 2 β€ ((x + y) ^ 2) ^ 3 := by
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
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "have : (x - y) ^ 2 * ((x + y) ^ 2 + 4 * (x * y)) β₯ 0 := by positivity",
"before_state": "x y : β\nhxy : 0 β€ x * y\nβ’ 16 * x ^ 2 * y ^ 2 * (x + y) ^ 2 β€ ((x + y) ^ 2) ^ 3",
"after_state": "x y : β\nhxy : 0 β€ x * y\nthis : (x - y) ^ 2 * ((x + y) ^ 2 + 4 * (x * y)) β₯ 0\nβ’ 16 * x ^ 2 * y ^ 2 * (x... |
theorem four_pow_four_pos : (0 : β) < 4 ^ 4 := by norm_num
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 0 < 4 ^ 4",
"after_state": "No Goals!"
}
] |
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
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "have : 0 β€ (x - y) ^ 2 := by positivity",
"before_state": "x y : β\nβ’ 3 * (x + y) ^ 2 β€ 2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2)",
"after_state": "x y : β\nthis : 0 β€ (x - y) ^ 2\nβ’ 3 * (x + y) ^ 2 β€ 2 * (x ^ 2 + y ^ 2 + (x + y) ^ 2)"
},
{
"line": "focus\n refine\n no_implicit_lambda%\n ... |
theorem zero_lt_32 : (0 : β) < 32 := by norm_num
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "norm_num",
"before_state": "β’ 0 < 32",
"after_state": "No Goals!"
}
] |
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 := 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 := 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_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]; ring
rw [sq_abs]; ring
rw [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]
rw [sq_sqrt zero_le_two]
rw [hz]
ring
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "have hz : (x + y) ^ 2 = z ^ 2 := by linear_combination (x + y - z) * hxyz",
"before_state": "x y z s : β\nhxy : 0 β€ x * y\nhxyz : x + y + z = 0\nβ’ 32 * |x * y * z * s| β€ β2 * (x ^ 2 + y ^ 2 + z ^ 2 + s ^ 2) ^ 2",
"after_state": "x y z s : β\nhxy : 0 β€ x * y\nhxyz : x + y + z = 0\nhz : (x + y)... |
theorem subst_proofβ (x y z s : β) (hxyz : x + y + z = 0) :
|x * y * z * s| β€ sqrt 2 / 32 * (x ^ 2 + y ^ 2 + z ^ 2 + s ^ 2) ^ 2 := by
wlog h' : 0 β€ x * y generalizing x y z; swap
Β· rw [div_mul_eq_mul_div, le_div_iffβ' zero_lt_32]
exact subst_wlog h' hxyz
rcases (mul_nonneg_of_three x y z).resolve_left h' with h | h
Β· convert this y z x _ h using 2 <;> linarith
Β· convert this z x y _ h using 2 <;> linarith
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "wlog h' : 0 β€ x * y generalizing x y z",
"before_state": "x y z s : β\nhxyz : x + y + z = 0\nβ’ |x * y * z * s| β€ β2 / 32 * (x ^ 2 + y ^ 2 + z ^ 2 + s ^ 2) ^ 2",
"after_state": "case inr\nx y z s : β\nhxyz : x + y + z = 0\nthis : β (x y z : β), x + y + z = 0 β 0 β€ x * y β |x * y * z * s| β€ β2 ... |
theorem proofβ (M : β)
(h : β a b c : β,
|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
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Ξ±
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "set Ξ± := sqrt (2 : β)",
"before_state": "M : β\nh :\n β (a b c : β),\n |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\nβ’ 9 * β2 / 32 β€ M",
"after_state": "M : β\nh :\n β (a b c : β),\n |a * b * (a ^ 2 - b ^ 2) + b * c * ... |
theorem subst_abc {x y z : β} (h : x * y * z = 1) :
β a b c : β, a β 0 β§ b β 0 β§ c β 0 β§ x = a / b β§ y = b / c β§ z = c / a := by
use x, 1, 1 / y
obtain β¨β¨hx, hyβ©, _β© : (x β 0 β§ y β 0) β§ z β 0 := by
have := h.symm βΈ one_ne_zero
simpa [not_or] using this
have : z * (y * x) = 1 := by rw [β h]; ac_rfl
field_simp [*]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2008Q2.lean | {
"open": [],
"variables": []
} | [
{
"line": "use x, 1, 1 / y",
"before_state": "x y z : β\nh : x * y * z = 1\nβ’ β a b c, a β 0 β§ b β 0 β§ c β 0 β§ x = a / b β§ y = b / c β§ z = c / a",
"after_state": "case h\nx y z : β\nh : x * y * z = 1\nβ’ x β 0 β§ 1 β 0 β§ 1 / y β 0 β§ x = x / 1 β§ y = 1 / (1 / y) β§ z = 1 / y / x"
},
{
"line": "refine... |
theorem imo2008_q2a (x y z : β) (h : x * y * z = 1) (hx : x β 1) (hy : y β 1) (hz : z β 1) :
x ^ 2 / (x - 1) ^ 2 + y ^ 2 / (y - 1) ^ 2 + z ^ 2 / (z - 1) ^ 2 β₯ 1 := by
obtain β¨a, b, c, ha, hb, hc, rfl, rfl, rflβ© := subst_abc h
obtain β¨m, n, rfl, rflβ© : β m n, b = c - m β§ a = c - m - n := by use c - b, b - a; simp
have hm_ne_zero : m β 0 := by contrapose! hy; field_simp; assumption
have hn_ne_zero : n β 0 := by contrapose! hx; field_simp; assumption
have hmn_ne_zero : m + n β 0 := by contrapose! hz; field_simp; linarith
have hc_sub_sub : c - (c - m - n) = m + n := by abel
rw [ge_iff_le]
rw [β sub_nonneg]
convert sq_nonneg ((c * (m ^ 2 + n ^ 2 + m * n) - m * (m + n) ^ 2) / (m * n * (m + n)))
field_simp [hc_sub_sub]; ring
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2008Q2.lean | {
"open": [],
"variables": []
} | [
{
"line": "obtain β¨a, b, c, ha, hb, hc, rfl, rfl, rflβ© := subst_abc h",
"before_state": "x y z : β\nh : x * y * z = 1\nhx : x β 1\nhy : y β 1\nhz : z β 1\nβ’ x ^ 2 / (x - 1) ^ 2 + y ^ 2 / (y - 1) ^ 2 + z ^ 2 / (z - 1) ^ 2 β₯ 1",
"after_state": "No Goals!"
}
] |
theorem abs_eq_one_of_pow_eq_one (x : β) (n : β) (hn : n β 0) (h : x ^ n = 1) : |x| = 1 := by
rw [β pow_left_injβ (abs_nonneg x) zero_le_one hn]
rw [one_pow]
rw [pow_abs]
rw [h]
rw [abs_one]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2008Q4.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "rw [β pow_left_injβ (abs_nonneg x) zero_le_one hn]",
"before_state": "x : β\nn : β\nhn : n β 0\nh : x ^ n = 1\nβ’ |x| = 1",
"after_state": "x : β\nn : β\nhn : n β 0\nh : x ^ n = 1\nβ’ |x| ^ n = 1 ^ n"
},
{
"line": "rewrite [β pow_left_injβ (abs_nonneg x) zero_le_one hn]",
"before_st... |
theorem imo2011_q3 (f : β β β) (hf : β x y, f (x + y) β€ y * f x + f (f x)) : β x β€ 0, f x = 0 := by
-- reparameterize
have hxt : β x t, f t β€ t * f x - x * f x + f (f x) := fun x t =>
calc
f t = f (x + (t - x)) := by rw [add_eq_of_eq_sub' rfl]
_ β€ (t - x) * f x + f (f x) := hf x (t - x)
_ = t * f x - x * f x + f (f x) := by rw [sub_mul]
have h_ab_combined : β a b, a * f a + b * f b β€ 2 * f a * f b := fun a b => by
linarith [hxt b (f a), hxt a (f b)]
have h_f_nonneg_of_pos : β a < 0, 0 β€ f a := fun a han =>
suffices a * f a β€ 0 from nonneg_of_mul_nonpos_right this han
add_le_iff_nonpos_left.mp (h_ab_combined a (2 * f a))
have h_f_nonpos : β x, f x β€ 0 := fun x => by
by_contra h_suppose_not
-- If we choose a small enough argument for f, then we get a contradiction.
let s := (x * f x - f (f x)) / f x
have hm : min 0 s - 1 < s := (sub_one_lt _).trans_le (min_le_right 0 s)
have hml : min 0 s - 1 < 0 := (sub_one_lt _).trans_le (min_le_left 0 s)
suffices f (min 0 s - 1) < 0 from not_le.mpr this (h_f_nonneg_of_pos (min 0 s - 1) hml)
have hp : 0 < f x := not_le.mp h_suppose_not
calc
f (min 0 s - 1) β€ (min 0 s - 1) * f x - x * f x + f (f x) := hxt x (min 0 s - 1)
_ < s * f x - x * f x + f (f x) := by linarith [(mul_lt_mul_right hp).mpr hm]
_ = 0 := by rw [(eq_div_iff hp.ne.symm).mp rfl]; linarith
have h_fx_zero_of_neg : β x < 0, f x = 0 := fun x hxz =>
(h_f_nonpos x).antisymm (h_f_nonneg_of_pos x hxz)
intro x hx
obtain (h_x_neg : x < 0) | (rfl : x = 0) := hx.lt_or_eq
Β· exact h_fx_zero_of_neg _ h_x_neg
Β· suffices 0 β€ f 0 from le_antisymm (h_f_nonpos 0) this
have hno : f (-1) = 0 := h_fx_zero_of_neg (-1) neg_one_lt_zero
have hp := hxt (-1) (-1)
rw [hno] at hp
linarith | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2011Q3.lean | {
"open": [],
"variables": []
} | [
{
"line": "have hxt : β x t, f t β€ t * f x - x * f x + f (f x) := fun x t =>\n calc\n f t = f (x + (t - x)) := by rw [add_eq_of_eq_sub' rfl]\n _ β€ (t - x) * f x + f (f x) := (hf x (t - x))\n _ = t * f x - x * f x + f (f x) := by rw [sub_mul]",
"before_state": "f : β β β\nhf : β (x y : β), f (x + y... |
theorem imo2011_q5 (f : β€ β β€) (hpos : β n : β€, 0 < f n) (hdvd : β m n : β€, f (m - n) β£ f m - f n) :
β m n : β€, f m β€ f n β f m β£ f n := by
intro m n h_fm_le_fn
rcases lt_or_eq_of_le h_fm_le_fn with h_fm_lt_fn | h_fm_eq_fn
Β· -- m < n
let d := f m - f (m - n)
have h_fn_dvd_d : f n β£ d := by
rw [β sub_sub_self m n]
exact hdvd m (m - n)
have h_d_lt_fn : d < f n := calc
d < f m := sub_lt_self _ (hpos (m - n))
_ < f n := h_fm_lt_fn
have h_neg_d_lt_fn : -d < f n := by
calc
-d = f (m - n) - f m := neg_sub _ _
_ < f (m - n) := sub_lt_self _ (hpos m)
_ β€ f n - f m := le_of_dvd (sub_pos.mpr h_fm_lt_fn) ?_
_ < f n := sub_lt_self _ (hpos m)
-- β’ f (m - n) β£ f n - f m
rw [β Int.dvd_neg]
rw [neg_sub]
exact hdvd m n
have h_d_eq_zero : d = 0 := by
obtain hd | hd | hd : d > 0 β¨ d = 0 β¨ d < 0 := trichotomous d 0
Β· -- d > 0
have hβ : f n β€ d := le_of_dvd hd h_fn_dvd_d
have hβ : Β¬f n β€ d := not_le.mpr h_d_lt_fn
contradiction
Β· -- d = 0
exact hd
Β· -- d < 0
have hβ : f n β€ -d := le_of_dvd (neg_pos.mpr hd) h_fn_dvd_d.neg_right
have hβ : Β¬f n β€ -d := not_le.mpr h_neg_d_lt_fn
contradiction
have hβ : f m = f (m - n) := sub_eq_zero.mp h_d_eq_zero
have hβ : f (m - n) β£ f m - f n := hdvd m n
rw [β hβ] at hβ
exact (dvd_iff_dvd_of_dvd_sub hβ).mp dvd_rfl
Β· -- m = n
rw [h_fm_eq_fn] | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2011Q5.lean | {
"open": [
"Int"
],
"variables": []
} | [
{
"line": "intro m n h_fm_le_fn",
"before_state": "f : β€ β β€\nhpos : β (n : β€), 0 < f n\nhdvd : β (m n : β€), f (m - n) β£ f m - f n\nβ’ β (m n : β€), f m β€ f n β f m β£ f n",
"after_state": "f : β€ β β€\nhpos : β (n : β€), 0 < f n\nhdvd : β (m n : β€), f (m - n) β£ f m - f n\nm n : β€\nh_fm_le_fn : f m β€ f n\nβ’ f... |
theorem imo2020_q2 (a b c d : β) (hd0 : 0 < d) (hdc : d β€ c) (hcb : c β€ b) (hba : b β€ a)
(h1 : a + b + c + d = 1) : (a + 2 * b + 3 * c + 4 * d) * a ^ a * b ^ b * c ^ c * d ^ d < 1 := by
have hp : a ^ a * b ^ b * c ^ c * d ^ d β€ a * a + b * b + c * c + d * d := by
refine geom_mean_le_arith_mean4_weighted ?_ ?_ ?_ ?_ ?_ ?_ ?_ ?_ h1 <;> linarith
calc
(a + 2 * b + 3 * c + 4 * d) * a ^ a * b ^ b * c ^ c * d ^ d =
(a + 2 * b + 3 * c + 4 * d) * (a ^ a * b ^ b * c ^ c * d ^ d) := by ac_rfl
_ β€ (a + 2 * b + 3 * c + 4 * d) * (a * a + b * b + c * c + d * d) := by gcongr; linarith
_ = (a + 2 * b + 3 * c + 4 * d) * a ^ 2 + (a + 2 * b + 3 * c + 4 * d) * b ^ 2
+ (a + 2 * b + 3 * c + 4 * d) * c ^ 2 + (a + 2 * b + 3 * c + 4 * d) * d ^ 2 := by ring
_ β€ (a + 3 * b + 3 * c + 3 * d) * a ^ 2 + (3 * a + b + 3 * c + 3 * d) * b ^ 2
+ (3 * a + 3 * b + c + 3 * d) * c ^ 2 + (3 * a + 3 * b + 3 * c + d) * d ^ 2 := by
gcongr ?_ * _ + ?_ * _ + ?_ * _ + ?_ * _ <;> linarith
_ < (a + 3 * b + 3 * c + 3 * d) * a ^ 2 + (3 * a + b + 3 * c + 3 * d) * b ^ 2
+ (3 * a + 3 * b + c + 3 * d) * c ^ 2 + (3 * a + 3 * b + 3 * c + d) * d ^ 2
+ (6 * a * b * c + 6 * a * b * d + 6 * a * c * d + 6 * b * c * d) :=
(lt_add_of_pos_right _ (by apply_rules [add_pos, mul_pos, zero_lt_one] <;> linarith))
_ = (a + b + c + d) ^ 3 := by ring
_ = 1 := by simp [h1] | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2020Q2.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "have hp : a ^ a * b ^ b * c ^ c * d ^ d β€ a * a + b * b + c * c + d * d := by\n refine geom_mean_le_arith_mean4_weighted ?_ ?_ ?_ ?_ ?_ ?_ ?_ ?_ h1 <;> linarith",
"before_state": "a b c d : β\nhd0 : 0 < d\nhdc : d β€ c\nhcb : c β€ b\nhba : b β€ a\nh1 : a + b + c + d = 1\nβ’ (a + 2 * b + 3 * c + 4 * ... |
theorem sqrt_two_mul_sub_one_le_one : sqrt (2 * x - 1) β€ 1 β x β€ 1 := by
simp [sqrt_le_iff, β two_mul]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1959Q2.lean | {
"open": [
"Set Real"
],
"variables": [
"{x A : β}"
]
} | [
{
"line": "simp [sqrt_le_iff, β two_mul]",
"before_state": "x : β\nβ’ β(2 * x - 1) β€ 1 β x β€ 1",
"after_state": "No Goals!"
}
] |
private lemma helper_5_digits {c : β€} (hc : 6 * 10 ^ 5 + c = 4 * (10 * c + 6)) : c = 15384 := by
omega
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1962Q1.lean | {
"open": [
"Nat"
],
"variables": []
} | [
{
"line": "omega",
"before_state": "c : β€\nhc : 6 * 10 ^ 5 + c = 4 * (10 * c + 6)\nβ’ c = 15384",
"after_state": "No Goals!"
}
] |
theorem imo1972_q5 (f g : β β β) (hf1 : β x, β y, f (x + y) + f (x - y) = 2 * f x * g y)
(hf2 : β y, βf yβ β€ 1) (hf3 : β x, f x β 0) (y : β) : βg yβ β€ 1 := by
-- Suppose the conclusion does not hold.
by_contra! hneg
set S := Set.range fun x => βf xβ
-- Introduce `k`, the supremum of `f`.
let k : β := sSup S
-- Show that `βf xβ β€ k`.
have hkβ : β x, βf xβ β€ k := by
have h : BddAbove S := β¨1, Set.forall_mem_range.mpr hf2β©
intro x
exact le_csSup h (Set.mem_range_self x)
-- Show that `2 * (βf xβ * βg yβ) β€ 2 * k`.
have hkβ : β x, 2 * (βf xβ * βg yβ) β€ 2 * k := fun x β¦
calc
2 * (βf xβ * βg yβ) = β2 * f x * g yβ := by simp [abs_mul, mul_assoc]
_ = βf (x + y) + f (x - y)β := by rw [hf1]
_ β€ βf (x + y)β + βf (x - y)β := norm_add_le _ _
_ β€ k + k := add_le_add (hkβ _) (hkβ _)
_ = 2 * k := (two_mul _).symm
set k' := k / βg yβ
-- Demonstrate that `k' < k` using `hneg`.
have Hβ : k' < k := by
have hβ : 0 < k := by
obtain β¨x, hxβ© := hf3
calc
0 < βf xβ := norm_pos_iff.mpr hx
_ β€ k := hkβ x
rw [div_lt_iffβ]
Β· apply lt_mul_of_one_lt_right hβ hneg
Β· exact zero_lt_one.trans hneg
-- Demonstrate that `k β€ k'` using `hkβ`.
have Hβ : k β€ k' := by
have hβ : β x : β, x β S := by use βf 0β; exact Set.mem_range_self 0
have hβ : β x, βf xβ β€ k' := by
intro x
rw [le_div_iffβ]
Β· apply (mul_le_mul_left zero_lt_two).mp (hkβ x)
Β· exact zero_lt_one.trans hneg
apply csSup_le hβ
rintro y' β¨yy, rflβ©
exact hβ yy
-- Conclude by obtaining a contradiction, `k' < k'`.
apply lt_irrefl k'
calc
k' < k := Hβ
_ β€ k' := Hβ
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1972Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "by_contra! hneg",
"before_state": "f g : β β β\nhf1 : β (x y : β), f (x + y) + f (x - y) = 2 * f x * g y\nhf2 : β (y : β), βf yβ β€ 1\nhf3 : β x, f x β 0\ny : β\nβ’ βg yβ β€ 1",
"after_state": "f g : β β β\nhf1 : β (x y : β), f (x + y) + f (x - y) = 2 * f x * g y\nhf2 : β (y : β), βf yβ β€ 1\nhf3... |
theorem imo1972_q5' (f g : β β β) (hf1 : β x, β y, f (x + y) + f (x - y) = 2 * f x * g y)
(hf2 : BddAbove (Set.range fun x => βf xβ)) (hf3 : β x, f x β 0) (y : β) : βg yβ β€ 1 := by
obtain β¨x, hxβ© := hf3
set k := β¨ x, βf xβ
have h : β x, βf xβ β€ k := le_ciSup hf2
by_contra! H
have hgy : 0 < βg yβ := by linarith
have k_pos : 0 < k := lt_of_lt_of_le (norm_pos_iff.mpr hx) (h x)
have : k / βg yβ < k := (div_lt_iffβ hgy).mpr (lt_mul_of_one_lt_right k_pos H)
have : k β€ k / βg yβ := by
suffices β x, βf xβ β€ k / βg yβ from ciSup_le this
intro x
suffices 2 * (βf xβ * βg yβ) β€ 2 * k by
rwa [le_div_iffβ hgy, β mul_le_mul_left (zero_lt_two : (0 : β) < 2)]
calc
2 * (βf xβ * βg yβ) = β2 * f x * g yβ := by simp [abs_mul, mul_assoc]
_ = βf (x + y) + f (x - y)β := by rw [hf1]
_ β€ βf (x + y)β + βf (x - y)β := abs_add _ _
_ β€ 2 * k := by linarith [h (x + y), h (x - y)]
linarith | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1972Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "obtain β¨x, hxβ© := hf3",
"before_state": "f g : β β β\nhf1 : β (x y : β), f (x + y) + f (x - y) = 2 * f x * g y\nhf2 : BddAbove (Set.range fun x => βf xβ)\nhf3 : β x, f x β 0\ny : β\nβ’ βg yβ β€ 1",
"after_state": "case intro\nf g : β β β\nhf1 : β (x y : β), f (x + y) + f (x - y) = 2 * f x * g y... |
theorem imo1977_q6_nat (f : β β β) (h : β n, f (f n) < f (n + 1)) : β n, f n = n := by
have h' : β k n : β, k β€ n β k β€ f n := by
intro k
induction' k with k h_ind
Β· intros; exact Nat.zero_le _
Β· intro n hk
apply Nat.succ_le_of_lt
calc
k β€ f (f (n - 1)) := h_ind _ (h_ind (n - 1) (le_tsub_of_add_le_right hk))
_ < f n := tsub_add_cancel_of_le (le_trans (Nat.succ_le_succ (Nat.zero_le _)) hk) βΈ h _
have hf : β n, n β€ f n := fun n => h' n n rfl.le
have hf_mono : StrictMono f := strictMono_nat_of_lt_succ fun _ => lt_of_le_of_lt (hf _) (h _)
intro
exact Nat.eq_of_le_of_lt_succ (hf _) (hf_mono.lt_iff_lt.mp (h _))
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1977Q6.lean | {
"open": [],
"variables": []
} | [
{
"line": "have h' : β k n : β, k β€ n β k β€ f n := by\n intro k\n induction' k with k h_ind\n Β· intros; exact Nat.zero_le _\n Β· intro n hk\n apply Nat.succ_le_of_lt\n calc\n k β€ f (f (n - 1)) := h_ind _ (h_ind (n - 1) (le_tsub_of_add_le_right hk))\n _ < f n := tsub_add_cancel_of_le (le_trans... |
lemma le_avg : β k β range (n + 1), x k β€ (β k β range n, x k) * (1 + 1 / n) := by
rw [sum_range_succ]
rw [mul_one_add]
rw [add_le_add_iff_left]
rw [mul_one_div]
rw [le_div_iffβ (mod_cast hn.bot_lt)]
rw [mul_comm]
rw [β nsmul_eq_mul]
conv_lhs => rw [β card_range n, β sum_const]
refine sum_le_sum fun k hk β¦ hx (le_of_lt ?_)
simpa using hk
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1982Q3.lean | {
"open": [
"Finset NNReal"
],
"variables": [
"{x : β β β} {n : β} (hn : n β 0) (hx : Antitone x)"
]
} | [
{
"line": "rw [sum_range_succ]",
"before_state": "x : β β β\nn : β\nβ’ β k β range (n + 1), x k β€ (β k β range n, x k) * (1 + 1 / βn)",
"after_state": "x : β β β\nn : β\nβ’ β x_1 β range n, x x_1 + x n β€ (β k β range n, x k) * (1 + 1 / βn)"
},
{
"line": "rewrite [sum_range_succ]",
"before_stat... |
lemma ineq (h0 : x 0 = 1) (hp : β k, 0 < x k) :
4 * n / (n + 1) β€ β k β range (n + 1), x k ^ 2 / x (k + 1) := by
calc
-- We first use AM-GM.
_ β€ (β k β range n, x (k + 1) + 1) ^ 2 / (β k β range n, x (k + 1)) * n / (n + 1) := by
gcongr
rw [le_div_iffβ]
Β· simpa using four_mul_le_sq_add (β k β range n, x (k + 1)) 1
Β· exact sum_pos (fun k _ β¦ hp _) (nonempty_range_iff.2 hn)
-- We move the fraction into the denominator.
_ = (β k β range n, x (k + 1) + 1) ^ 2 / ((β k β range n, x (k + 1)) * (1 + 1 / n)) := by
field_simp
-- We make use of the `le_avg` lemma.
_ β€ (β k β range (n + 1), x k) ^ 2 / β k β range (n + 1), x (k + 1) := by
gcongr
Β· exact sum_pos (fun k _ β¦ hp _) nonempty_range_succ
Β· exact add_nonneg (sum_nonneg fun k _ β¦ (hp _).le) zero_le_one
Β· rw [sum_range_succ', h0]
Β· exact le_avg hn (hx.comp_monotone @Nat.succ_le_succ)
-- We conclude by Sedrakyan.
_ β€ _ := sq_sum_div_le_sum_sq_div _ x fun k _ β¦ hp (k + 1)
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1982Q3.lean | {
"open": [
"Finset NNReal"
],
"variables": [
"{x : β β β} {n : β} (hn : n β 0) (hx : Antitone x)"
]
} | [
{
"line": "calc\n -- We first use AM-GM.\n _ β€ (β k β range n, x (k + 1) + 1) ^ 2 / (β k β range n, x (k + 1)) * n / (n + 1) :=\n by\n gcongr\n rw [le_div_iffβ]\n Β· simpa using four_mul_le_sq_add (β k β range n, x (k + 1)) 1\n Β·\n exact\n sum_pos (fun k _ β¦ hp _)\n (nonempt... |
theorem imo1982_q3a (hx : Antitone x) (h0 : x 0 = 1) (hp : β k, 0 < x k) :
β n : β, 3.999 β€ β k β range n, (x k) ^ 2 / x (k + 1) := by
use 4000
convert Imo1982Q3.ineq (Nat.succ_ne_zero 3998) hx h0 hp
norm_num
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1982Q3.lean | {
"open": [
"Finset NNReal"
],
"variables": [
"{x : β β β} {n : β} (hn : n β 0) (hx : Antitone x)"
]
} | [
{
"line": "use 4000",
"before_state": "x : β β β\nhx : Antitone x\nh0 : x 0 = 1\nhp : β (k : β), 0 < x k\nβ’ β n, 3.999 β€ β k β range n, x k ^ 2 / x (k + 1)",
"after_state": "case h\nx : β β β\nhx : Antitone x\nh0 : x 0 = 1\nhp : β (k : β), 0 < x k\nβ’ 3.999 β€ β k β range 4000, x k ^ 2 / x (k + 1)"
},
... |
theorem imo1982_q3b : β x : β β β, Antitone x β§ x 0 = 1 β§ (β k, 0 < x k)
β§ β n, β k β range n, x k ^ 2 / x (k + 1) < 4 := by
refine β¨fun k β¦ 2β»ΒΉ ^ k, ?_, pow_zero _, ?_, fun n β¦ ?_β©
Β· apply (pow_right_strictAntiβ _ _).antitone <;> norm_num
Β· simp
Β· have {k : β} : (2 : β)β»ΒΉ ^ (k * 2) * ((2 : β)β»ΒΉ ^ k)β»ΒΉ = (2 : β)β»ΒΉ ^ k := by
rw [β pow_subβ] <;> simp [mul_two]
simp_rw [β pow_mul, pow_succ, β div_eq_mul_inv, div_div_eq_mul_div, mul_comm, mul_div_assoc,
β mul_sum, div_eq_mul_inv, this, β two_add_two_eq_four, β mul_two,
mul_lt_mul_iff_of_pos_left two_pos]
convert NNReal.coe_lt_coe.2 <| geom_sum_lt (inv_ne_zero two_ne_zero) two_inv_lt_one n
Β· simp
Β· norm_num | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1982Q3.lean | {
"open": [
"Finset NNReal"
],
"variables": [
"{x : β β β} {n : β} (hn : n β 0) (hx : Antitone x)"
]
} | [
{
"line": "refine β¨fun k β¦ 2β»ΒΉ ^ k, ?_, pow_zero _, ?_, fun n β¦ ?_β©",
"before_state": "β’ β x, Antitone x β§ x 0 = 1 β§ (β (k : β), 0 < x k) β§ β (n : β), β k β range n, x k ^ 2 / x (k + 1) < 4",
"after_state": "case refine_1\nβ’ Antitone fun k => 2β»ΒΉ ^ k\n---\ncase refine_2\nβ’ β (k : β), 0 < (fun k => 2β»ΒΉ ^... |
theorem imo1988_q6 {a b : β} (h : a * b + 1 β£ a ^ 2 + b ^ 2) :
β d, d ^ 2 = (a ^ 2 + b ^ 2) / (a * b + 1) := by
rcases h with β¨k, hkβ©
rw [hk]
rw [Nat.mul_div_cancel_left _ (Nat.succ_pos (a * b))]
simp only [sq] at hk
apply constant_descent_vieta_jumping a b (H := fun a b => a * a + b * b = (a * b + 1) * k)
hk (fun x => k * x) (fun x => x * x - k) fun _ _ => False <;>
clear hk a b
Β· -- We will now show that the fibers of the solution set are described by a quadratic equation.
intro x y
rw [β Int.natCast_inj]
rw [β sub_eq_zero]
apply eq_iff_eq_cancel_right.2
simp; ring
Β· -- Show that the solution set is symmetric in a and b.
intro x y
simp [add_comm (x * x), mul_comm x]
Β· -- Show that the claim is true if b = 0.
suffices β a, a * a = k β β d, d * d = k by simpa
rintro x rfl; use x
Β· -- Show that the claim is true if a = b.
intro x hx
suffices k β€ 1 by
rw [Nat.le_add_one_iff] at this
rw [Nat.le_zero] at this
rcases this with (rfl | rfl)
Β· use 0; simp
Β· use 1; simp
contrapose! hx with k_lt_one
apply ne_of_lt
calc
x * x + x * x = x * x * 2 := by rw [mul_two]
_ β€ x * x * k := Nat.mul_le_mul_left (x * x) k_lt_one
_ < (x * x + 1) * k := by linarith
Β· -- Show the descent step.
intro x y hx x_lt_y _ _ z h_root _ hVβ
constructor
Β· have hpos : z * z + x * x > 0 := by
apply add_pos_of_nonneg_of_pos
Β· apply mul_self_nonneg
Β· apply mul_pos <;> exact mod_cast hx
have hzx : z * z + x * x = (z * x + 1) * k := by
rw [β sub_eq_zero]
rw [β h_root]
ring
rw [hzx] at hpos
replace hpos : z * x + 1 > 0 := pos_of_mul_pos_left hpos (Int.ofNat_zero_le k)
replace hpos : z * x β₯ 0 := Int.le_of_lt_add_one hpos
apply nonneg_of_mul_nonneg_left hpos (mod_cast hx)
Β· contrapose! hVβ with x_lt_z
apply ne_of_gt
calc
z * y > x * x := by apply mul_lt_mul' <;> omega
_ β₯ x * x - k := sub_le_self _ (Int.ofNat_zero_le k)
Β· -- There is no base case in this application of Vieta jumping.
simp
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1988Q6.lean | {
"open": [
"Imo1988Q6"
],
"variables": []
} | [
{
"line": "rcases h with β¨k, hkβ©",
"before_state": "a b : β\nh : a * b + 1 β£ a ^ 2 + b ^ 2\nβ’ β d, d ^ 2 = (a ^ 2 + b ^ 2) / (a * b + 1)",
"after_state": "case intro\na b k : β\nhk : a ^ 2 + b ^ 2 = (a * b + 1) * k\nβ’ β d, d ^ 2 = (a ^ 2 + b ^ 2) / (a * b + 1)"
},
{
"line": "rw [hk]",
"befor... |
example {a b : β} (h : a * b β£ a ^ 2 + b ^ 2 + 1) : 3 * a * b = a ^ 2 + b ^ 2 + 1 := by
rcases h with β¨k, hkβ©
suffices k = 3 by simp_all; ring
simp only [sq] at hk
apply constant_descent_vieta_jumping a b (H := fun a b => a * a + b * b + 1 = a * b * k)
hk (fun x => k * x) (fun x => x * x + 1) fun x _ => x β€ 1 <;>
clear hk a b
Β· -- We will now show that the fibers of the solution set are described by a quadratic equation.
intro x y
rw [β Int.natCast_inj]
rw [β sub_eq_zero]
apply eq_iff_eq_cancel_right.2
simp; ring
Β· -- Show that the solution set is symmetric in a and b.
intro x y; ring_nf
Β· -- Show that the claim is true if b = 0.
simp
Β· -- Show that the claim is true if a = b.
intro x hx
have x_sq_dvd : x * x β£ x * x * k := dvd_mul_right (x * x) k
rw [β hx] at x_sq_dvd
obtain β¨y, hyβ© : x * x β£ 1 := by simpa only [Nat.dvd_add_self_left, add_assoc] using x_sq_dvd
obtain β¨rfl, rflβ© : x = 1 β§ y = 1 := by simpa [mul_eq_one] using hy.symm
simpa using hx.symm
Β· -- Show the descent step.
intro x y _ hx h_base _ z _ _ hVβ
constructor
Β· have zy_pos : z * y β₯ 0 := by rw [hVβ]; exact mod_cast Nat.zero_le _
apply nonneg_of_mul_nonneg_left zy_pos
omega
Β· contrapose! hVβ with x_lt_z
apply ne_of_gt
push_neg at h_base
calc
z * y > x * y := by apply mul_lt_mul_of_pos_right <;> omega
_ β₯ x * (x + 1) := by apply mul_le_mul <;> omega
_ > x * x + 1 := by
rw [mul_add]
omega
Β· -- Show the base case.
intro x y h h_base
obtain rfl | rfl : x = 0 β¨ x = 1 := by rwa [Nat.le_add_one_iff, Nat.le_zero] at h_base
Β· simp at h
Β· rw [mul_one, one_mul, add_right_comm] at h
have y_dvd : y β£ y * k := dvd_mul_right y k
rw [β h] at y_dvd
rw [Nat.dvd_add_left (dvd_mul_left y y)] at y_dvd
obtain rfl | rfl := (Nat.dvd_prime Nat.prime_two).mp y_dvd <;> apply mul_left_cancelβ
exacts [one_ne_zero, h.symm, two_ne_zero, h.symm] | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1988Q6.lean | {
"open": [
"Imo1988Q6"
],
"variables": []
} | [
{
"line": "rcases h with β¨k, hkβ©",
"before_state": "a b : β\nh : a * b β£ a ^ 2 + b ^ 2 + 1\nβ’ 3 * a * b = a ^ 2 + b ^ 2 + 1",
"after_state": "case intro\na b k : β\nhk : a ^ 2 + b ^ 2 + 1 = a * b * k\nβ’ 3 * a * b = a ^ 2 + b ^ 2 + 1"
},
{
"line": "suffices k = 3 by simp_all; ring",
"before_s... |
theorem tedious (m : β) (k : Fin (m + 1)) : m - ((m + 1 - βk) + m) % (m + 1) = βk := by
obtain β¨k, hkβ© := k
rw [Nat.lt_succ_iff] at hk
rw [le_iff_exists_add] at hk
rcases hk with β¨c, rflβ©
have : (k + c + 1 - k) + (k + c) = c + (k + c + 1) := by omega
rw [Fin.val_mk]
rw [this]
rw [Nat.add_mod_right]
rw [Nat.mod_eq_of_lt]
rw [Nat.add_sub_cancel]
omega
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1994Q1.lean | {
"open": [
"Finset"
],
"variables": []
} | [
{
"line": "obtain β¨k, hkβ© := k",
"before_state": "m : β\nk : Fin (m + 1)\nβ’ m - (m + 1 - βk + m) % (m + 1) = βk",
"after_state": "case mk\nm k : β\nhk : k < m + 1\nβ’ m - (m + 1 - ββ¨k, hkβ© + m) % (m + 1) = ββ¨k, hkβ©"
},
{
"line": "rw [Nat.lt_succ_iff] at hk",
"before_state": "case mk\nm k : β\... |
theorem add_sq_add_sq_sub {Ξ± : Type*} [Ring Ξ±] (x y : Ξ±) :
(x + y) * (x + y) + (x - y) * (x - y) = 2 * x * x + 2 * y * y := by noncomm_ring
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1998Q2.lean | {
"open": [
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in"
],
"variables": [
"{C J : Type*} (r : C β J β Prop)",
"[Fintype J] [Fintype C]"
]
} | [
{
"line": "noncomm_ring",
"before_state": "Ξ± : Type u_1\ninstβ : Ring Ξ±\nx y : Ξ±\nβ’ (x + y) * (x + y) + (x - y) * (x - y) = 2 * x * x + 2 * y * y",
"after_state": "No Goals!"
},
{
"line": "focus\n (first\n |\n simp only [add_mulβ, mul_addβ, sub_eq_add_negβ, mul_assocβ, pow_oneβ, pow_zer... |
theorem clear_denominators {a b k : β} (ha : 0 < a) (hb : 0 < b) :
(b - 1 : β) / (2 * b) β€ k / a β ((b : β) - 1) * a β€ k * (2 * b) := by
rw [div_le_div_iffβ]
on_goal 1 => convert Nat.cast_le (Ξ± := β)
all_goals simp [ha, hb]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo1998Q2.lean | {
"open": [
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in",
"scoped Classical in"
],
"variables": [
"{C J : Type*} (r : C β J β Prop)",
"[Fintype J] [Fintype C]",
"[Fintype J]"
]
} | [
{
"line": "rw [div_le_div_iffβ]",
"before_state": "a b k : β\nha : 0 < a\nhb : 0 < b\nβ’ (βb - 1) / (2 * βb) β€ βk / βa β (b - 1) * a β€ k * (2 * b)",
"after_state": "a b k : β\nha : 0 < a\nhb : 0 < b\nβ’ (βb - 1) * βa β€ βk * (2 * βb) β (b - 1) * a β€ k * (2 * b)\n---\ncase hb\na b k : β\nha : 0 < a\nhb : 0 ... |
theorem Int.natAbs_eq_of_chain_dvd {l : Cycle β€} {x y : β€} (hl : l.Chain (Β· β£ Β·)) (hx : x β l)
(hy : y β l) : x.natAbs = y.natAbs := by
rw [Cycle.chain_iff_pairwise] at hl
exact Int.natAbs_eq_of_dvd_dvd (hl x hx y hy) (hl y hy x hx)
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q5.lean | {
"open": [
"Function Polynomial"
],
"variables": []
} | [
{
"line": "rw [Cycle.chain_iff_pairwise] at hl",
"before_state": "l : Cycle β€\nx y : β€\nhl : Cycle.Chain (fun x1 x2 => x1 β£ x2) l\nhx : x β l\nhy : y β l\nβ’ x.natAbs = y.natAbs",
"after_state": "l : Cycle β€\nx y : β€\nhl : β a β l, β b β l, a β£ b\nhx : x β l\nhy : y β l\nβ’ x.natAbs = y.natAbs"
},
{
... |
theorem Int.add_eq_add_of_natAbs_eq_of_natAbs_eq {a b c d : β€} (hne : a β b)
(hβ : (c - a).natAbs = (d - b).natAbs) (hβ : (c - b).natAbs = (d - a).natAbs) :
a + b = c + d := by
rcases Int.natAbs_eq_natAbs_iff.1 hβ with hβ | hβ
Β· rcases Int.natAbs_eq_natAbs_iff.1 hβ with hβ | hβ
Β· exact (hne <| by linarith).elim
Β· linarith
Β· linarith
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q5.lean | {
"open": [
"Function Polynomial"
],
"variables": []
} | [
{
"line": "rcases Int.natAbs_eq_natAbs_iff.1 hβ with hβ | hβ",
"before_state": "a b c d : β€\nhne : a β b\nhβ : (c - a).natAbs = (d - b).natAbs\nhβ : (c - b).natAbs = (d - a).natAbs\nβ’ a + b = c + d",
"after_state": "case inl\na b c d : β€\nhne : a β b\nhββ : (c - a).natAbs = (d - b).natAbs\nhβ : (c - b).... |
theorem Polynomial.isPeriodicPt_eval_two {P : Polynomial β€} {t : β€}
(ht : t β periodicPts fun x => P.eval x) : IsPeriodicPt (fun x => P.eval x) 2 t := by
-- The cycle [P(t) - t, P(P(t)) - P(t), ...]
let C : Cycle β€ := (periodicOrbit (fun x => P.eval x) t).map fun x => P.eval x - x
have HC : β {n : β}, (fun x => P.eval x)^[n + 1] t - (fun x => P.eval x)^[n] t β C := by
intro n
rw [Cycle.mem_map]
rw [Function.iterate_succ_apply']
exact β¨_, iterate_mem_periodicOrbit ht n, rflβ©
-- Elements in C are all divisible by one another.
have Hdvd : C.Chain (Β· β£ Β·) := by
rw [Cycle.chain_map]
rw [periodicOrbit_chain' _ ht]
intro n
convert sub_dvd_eval_sub ((fun x => P.eval x)^[n + 1] t) ((fun x => P.eval x)^[n] t) P <;>
rw [Function.iterate_succ_apply']
-- Any two entries in C have the same absolute value.
have Habs :
β m n : β,
((fun x => P.eval x)^[m + 1] t - (fun x => P.eval x)^[m] t).natAbs =
((fun x => P.eval x)^[n + 1] t - (fun x => P.eval x)^[n] t).natAbs :=
fun m n => Int.natAbs_eq_of_chain_dvd Hdvd HC HC
-- We case on whether the elements on C are pairwise equal.
by_cases HC' : C.Chain (Β· = Β·)
Β· -- Any two entries in C are equal.
have Heq :
β m n : β,
(fun x => P.eval x)^[m + 1] t - (fun x => P.eval x)^[m] t =
(fun x => P.eval x)^[n + 1] t - (fun x => P.eval x)^[n] t :=
fun m n => Cycle.chain_iff_pairwise.1 HC' _ HC _ HC
-- The sign of P^n(t) - t is the same as P(t) - t for positive n. Proven by induction on n.
have IH : β n : β, ((fun x => P.eval x)^[n + 1] t - t).sign = (P.eval t - t).sign := by
intro n
induction' n with n IH
Β· rfl
Β· apply Eq.trans _ (Int.sign_add_eq_of_sign_eq IH)
have H := Heq n.succ 0
dsimp at H β’
rw [β H]
rw [sub_add_sub_cancel']
-- This implies that the sign of P(t) - t is the same as the sign of P^k(t) - t, which is 0.
-- Hence P(t) = t and P(P(t)) = P(t).
rcases ht with β¨_ | k, hk, hk'β©
Β· exact (irrefl 0 hk).elim
Β· have H := IH k
rw [hk'.isFixedPt.eq] at H
rw [sub_self] at H
rw [Int.sign_zero] at H
rw [eq_comm] at H
rw [Int.sign_eq_zero_iff_zero] at H
rw [sub_eq_zero] at H
simp [IsPeriodicPt, IsFixedPt, H]
Β· -- We take two nonequal consecutive entries.
rw [Cycle.chain_map] at HC'
rw [periodicOrbit_chain' _ ht] at HC'
push_neg at HC'
obtain β¨n, hnβ© := HC'
-- They must have opposite sign, so that P^{k + 1}(t) - P^k(t) = P^{k + 2}(t) - P^{k + 1}(t).
rcases Int.natAbs_eq_natAbs_iff.1 (Habs n n.succ) with hn' | hn'
Β· apply (hn _).elim
convert hn' <;> simp only [Function.iterate_succ_apply']
-- We deduce P^{k + 2}(t) = P^k(t) and hence P(P(t)) = t.
Β· rw [neg_sub, sub_right_inj] at hn'
simp only [Function.iterate_succ_apply'] at hn'
exact isPeriodicPt_of_mem_periodicPts_of_isPeriodicPt_iterate ht hn'.symm
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q5.lean | {
"open": [
"Function Polynomial"
],
"variables": []
} | [
{
"line": "let C : Cycle β€ := (periodicOrbit (fun x => P.eval x) t).map fun x => P.eval x - x",
"before_state": "P : β€[X]\nt : β€\nht : t β periodicPts fun x => eval x P\nβ’ IsPeriodicPt (fun x => eval x P) 2 t",
"after_state": "P : β€[X]\nt : β€\nht : t β periodicPts fun x => eval x P\nC : Cycle β€ := Cycle... |
theorem Polynomial.iterate_comp_sub_X_ne {P : Polynomial β€} (hP : 1 < P.natDegree) {k : β}
(hk : 0 < k) : P.comp^[k] X - X β 0 := by
rw [sub_ne_zero]
apply_fun natDegree
simpa using (one_lt_powβ hP hk.ne').ne'
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2006Q5.lean | {
"open": [
"Function Polynomial"
],
"variables": []
} | [
{
"line": "rw [sub_ne_zero]",
"before_state": "P : β€[X]\nhP : 1 < P.natDegree\nk : β\nhk : 0 < k\nβ’ P.comp^[k] X - X β 0",
"after_state": "P : β€[X]\nhP : 1 < P.natDegree\nk : β\nhk : 0 < k\nβ’ P.comp^[k] X β X"
},
{
"line": "rewrite [sub_ne_zero]",
"before_state": "P : β€[X]\nhP : 1 < P.natDeg... |
theorem p_lemma (p : β) (hpp : Nat.Prime p) (hp_mod_4_eq_1 : p β‘ 1 [MOD 4]) (hp_gt_20 : p > 20) :
β n : β, p β£ n ^ 2 + 1 β§ (p : β) > 2 * n + sqrt (2 * n) := by
haveI := Fact.mk hpp
have hp_mod_4_ne_3 : p % 4 β 3 := by linarith [show p % 4 = 1 from hp_mod_4_eq_1]
obtain β¨y, hyβ© := ZMod.exists_sq_eq_neg_one_iff.mpr hp_mod_4_ne_3
let m := ZMod.valMinAbs y
let n := Int.natAbs m
have hnatβ : p β£ n ^ 2 + 1 := by
refine Int.natCast_dvd_natCast.mp ?_
simp only [n]
simp only [Int.natAbs_sq]
simp only [Int.natCast_pow]
simp only [Int.natCast_succ]
simp only [Int.natCast_dvd_natCast.mp]
refine (ZMod.intCast_zmod_eq_zero_iff_dvd (m ^ 2 + 1) p).mp ?_
simp only [m]
simp only [Int.cast_pow]
simp only [Int.cast_add]
simp only [Int.cast_one]
simp only [ZMod.coe_valMinAbs]
rw [pow_two]; exact neg_add_cancel 1
rw [β hy]; exact neg_add_cancel 1
have hnatβ : n β€ p / 2 := ZMod.natAbs_valMinAbs_le y
have hnatβ : p β₯ 2 * n := by omega
set k : β := p - 2 * n with hnatβ
have hnatβ
: p β£ k ^ 2 + 4 := by
obtain β¨x, hxβ© := hnatβ
have : (p : β€) β£ (k : β€) ^ 2 + 4 := by
use (p : β€) - 4 * n + 4 * x
have hcastβ : (k : β€) = p - 2 * n := by assumption_mod_cast
have hcastβ : (n : β€) ^ 2 + 1 = p * x := by assumption_mod_cast
linear_combination ((k : β€) + p - 2 * n) * hcastβ + 4 * hcastβ
assumption_mod_cast
have hnatβ : k ^ 2 + 4 β₯ p := Nat.le_of_dvd (k ^ 2 + 3).succ_pos hnatβ
have hrealβ : (k : β) = p - 2 * n := by assumption_mod_cast
have hrealβ : (p : β) > 20 := by assumption_mod_cast
have hrealβ : (k : β) ^ 2 + 4 β₯ p := by assumption_mod_cast
have hrealβ
: (k : β) > 4 := by
refine lt_of_pow_lt_pow_leftβ 2 k.cast_nonneg ?_
linarith only [hrealβ, hrealβ]
have hrealβ : (k : β) > sqrt (2 * n) := by
refine lt_of_pow_lt_pow_leftβ 2 k.cast_nonneg ?_
rw [sq_sqrt (mul_nonneg zero_le_two n.cast_nonneg)]
linarith only [hrealβ, hrealβ, hrealβ
]
exact β¨n, hnatβ, by linarith only [hrealβ, hrealβ]β©
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2008Q3.lean | {
"open": [
"Real"
],
"variables": []
} | [
{
"line": "haveI := Fact.mk hpp",
"before_state": "p : β\nhpp : Nat.Prime p\nhp_mod_4_eq_1 : p β‘ 1 [MOD 4]\nhp_gt_20 : p > 20\nβ’ β n, p β£ n ^ 2 + 1 β§ βp > 2 * βn + β(2 * βn)",
"after_state": "p : β\nhpp : Nat.Prime p\nhp_mod_4_eq_1 : p β‘ 1 [MOD 4]\nhp_gt_20 : p > 20\nthis : Fact (Nat.Prime p)\nβ’ β n, p ... |
theorem imo2008_q3 : β N : β, β n : β, n β₯ N β§
β p : β, Nat.Prime p β§ p β£ n ^ 2 + 1 β§ (p : β) > 2 * n + sqrt (2 * n) := by
intro N
obtain β¨p, hpp, hineqβ, hpmod4β© := Nat.exists_prime_gt_modEq_one (N ^ 2 + 20) four_ne_zero
obtain β¨n, hnat, hrealβ© := p_lemma p hpp hpmod4 (by linarith [hineqβ, Nat.zero_le (N ^ 2)])
have hineqβ : n ^ 2 + 1 β₯ p := Nat.le_of_dvd (n ^ 2).succ_pos hnat
have hineqβ : n * n β₯ N * N := by linarith [hineqβ, hineqβ]
have hn_ge_N : n β₯ N := Nat.mul_self_le_mul_self_iff.1 hineqβ
exact β¨n, hn_ge_N, p, hpp, hnat, hrealβ© | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2008Q3.lean | {
"open": [
"Real",
"Imo2008Q3"
],
"variables": []
} | [
{
"line": "intro N",
"before_state": "β’ β (N : β), β n β₯ N, β p, Nat.Prime p β§ p β£ n ^ 2 + 1 β§ βp > 2 * βn + β(2 * βn)",
"after_state": "N : β\nβ’ β n β₯ N, β p, Nat.Prime p β§ p β£ n ^ 2 + 1 β§ βp > 2 * βn + β(2 * βn)"
},
{
"line": "obtain β¨p, hpp, hineqβ, hpmod4β© := Nat.exists_prime_gt_modEq_one (N... |
theorem arith_lemma (k n : β) : 0 < 2 * n + 2 ^ k.succ := by positivity
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q1.lean | {
"open": [],
"variables": []
} | [
{
"line": "positivity",
"before_state": "k n : β\nβ’ 0 < 2 * n + 2 ^ k.succ",
"after_state": "No Goals!"
}
] |
theorem prod_lemma (m : β β β+) (k : β) (nm : β+) :
β i β Finset.range k, ((1 : β) + 1 / β(if i < k then m i else nm)) =
β i β Finset.range k, (1 + 1 / (m i : β)) := by
suffices β i, i β Finset.range k β (1 : β) + 1 / β(if i < k then m i else nm) = 1 + 1 / m i from
Finset.prod_congr rfl this
intro i hi
simp [Finset.mem_range.mp hi]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q1.lean | {
"open": [],
"variables": []
} | [
{
"line": "suffices β i, i β Finset.range k β (1 : β) + 1 / β(if i < k then m i else nm) = 1 + 1 / m i from\n Finset.prod_congr rfl this",
"before_state": "m : β β β+\nk : β\nnm : β+\nβ’ β i β Finset.range k, (1 + 1 / ββ(if i < k then m i else nm)) = β i β Finset.range k, (1 + 1 / ββ(m i))",
"after_stat... |
theorem imo2013_q1 (n : β+) (k : β) :
β m : β β β+, (1 : β) + (2 ^ k - 1) / n = β i β Finset.range k, (1 + 1 / (m i : β)) := by
revert n
induction' k with pk hpk
Β· intro n; use fun (_ : β) => (1 : β+); simp
-- For the base case, any m works.
intro n
obtain β¨t, ht : βn = t + tβ© | β¨t, ht : βn = 2 * t + 1β© := (n : β).even_or_odd
Β· -- even case
rw [β two_mul] at ht
rcases t with - | t
-- Eliminate the zero case to simplify later calculations.
Β· exfalso; rw [Nat.mul_zero] at ht; exact PNat.ne_zero n ht
-- Now we have ht : βn = 2 * (t + 1).
let t_succ : β+ := β¨t + 1, t.succ_posβ©
obtain β¨pm, hpmβ© := hpk t_succ
let m i := if i < pk then pm i else β¨2 * t + 2 ^ pk.succ, arith_lemma pk tβ©
use m
have hmpk : (m pk : β) = 2 * t + 2 ^ pk.succ := by
have : m pk = β¨2 * t + 2 ^ pk.succ, _β© := if_neg (irrefl pk); simp [this]
calc
((1 : β) + (2 ^ pk.succ - 1) / (n : β) : β)= 1 + (2 * 2 ^ pk - 1) / (2 * (t + 1) : β) := by
rw [ht]
rw [pow_succ']
_ = (1 + 1 / (2 * t + 2 * 2 ^ pk)) * (1 + (2 ^ pk - 1) / (βt + 1)) := by
field_simp
ring
_ = (1 + 1 / (2 * t + 2 ^ pk.succ)) * (1 + (2 ^ pk - 1) / t_succ) := by
simp [pow_succ', PNat.mk_coe, t_succ]
_ = (β i β Finset.range pk, (1 + 1 / (m i : β))) * (1 + 1 / m pk) := by
rw [prod_lemma]
rw [hpm]
rw [β hmpk]
rw [mul_comm]
_ = β i β Finset.range pk.succ, (1 + 1 / (m i : β)) := by rw [β Finset.prod_range_succ _ pk]
Β· -- odd case
let t_succ : β+ := β¨t + 1, t.succ_posβ©
obtain β¨pm, hpmβ© := hpk t_succ
let m i := if i < pk then pm i else β¨2 * t + 1, Nat.succ_pos _β©
use m
have hmpk : (m pk : β) = 2 * t + 1 := by
have : m pk = β¨2 * t + 1, _β© := if_neg (irrefl pk)
simp [this]
calc
((1 : β) + (2 ^ pk.succ - 1) / βn : β) = 1 + (2 * 2 ^ pk - 1) / (2 * t + 1 : β) := by
rw [ht]
rw [pow_succ']
_ = (1 + 1 / (2 * t + 1)) * (1 + (2 ^ pk - 1) / (t + 1)) := by
field_simp
ring
_ = (1 + 1 / (2 * t + 1)) * (1 + (2 ^ pk - 1) / t_succ) := by norm_cast
_ = (β i β Finset.range pk, (1 + 1 / (m i : β))) * (1 + 1 / β(m pk)) := by
rw [prod_lemma]
rw [hpm]
rw [β hmpk]
rw [mul_comm]
_ = β i β Finset.range pk.succ, (1 + 1 / (m i : β)) := by rw [β Finset.prod_range_succ _ pk] | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q1.lean | {
"open": [
"Imo2013Q1"
],
"variables": []
} | [
{
"line": "revert n",
"before_state": "n : β+\nk : β\nβ’ β m, 1 + (2 ^ k - 1) / ββn = β i β Finset.range k, (1 + 1 / ββ(m i))",
"after_state": "k : β\nβ’ β (n : β+), β m, 1 + (2 ^ k - 1) / ββn = β i β Finset.range k, (1 + 1 / ββ(m i))"
},
{
"line": "induction' k with pk hpk",
"before_state": "... |
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
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 _
calc
1 β€ x ^ i := one_le_powβ hx.le
_ = x ^ i * 1 := by ring
_ β€ x ^ i * y ^ (n - 1 - i) := by gcongr; apply one_le_powβ hy.le
calc
(x - y) * (n : β) = (n : β) * (x - y) := by ring
_ = (β _i β Finset.range n, (1 : β)) * (x - y) := by
simp only [mul_one]
simp only [Finset.sum_const]
simp only [nsmul_eq_mul]
simp only [Finset.card_range]
_ β€ (β i β 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))
have hNp : 0 < N := mod_cast (one_div_pos.mpr hxmy).trans hN
have :=
calc
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]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "by_contra! hxy",
"before_state": "x y : β\nhx : 1 < x\nhy : 1 < y\nh : β (n : β), 0 < n β x ^ n - 1 < y ^ n\nβ’ x β€ y",
"after_state": "x y : β\nhx : 1 < x\nhy : 1 < y\nh : β (n : β), 0 < n β x ^ n - 1 < y ^ n\nhxy : y < x\nβ’ False"
},
{
"line": "by_contra hxy",
"before_state": "x ... |
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
-- Then there exists y' such that 0 < y β€ 1 < y' < x.
have h_y'_lt_x : (x + 1) / 2 < x := by linarith
have h1_lt_y' : 1 < (x + 1) / 2 := by linarith
set y' := (x + 1) / 2
have h_y_lt_y' : y < y' := by linarith
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
exact h_y'_lt_x.not_le (le_of_all_pow_lt_succ hx h1_lt_y' hh)
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "refine le_of_all_pow_lt_succ hx ?_ h",
"before_state": "x y : β\nhx : 1 < x\nhy : 0 < y\nh : β (n : β), 0 < n β x ^ n - 1 < y ^ n\nβ’ x β€ y",
"after_state": "No Goals!"
}
] |
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.mpr hq
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
_ β€ 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]
_ β€ f q * f q.den := H1 q q.den hq (Nat.cast_pos.mpr q.pos)
have h_f_denom_pos :=
calc
(0 : β) < q.den := Nat.cast_pos.mpr q.pos
_ β€ f q.den := H4 q.den q.pos
exact pos_of_mul_pos_left hmul_pos h_f_denom_pos.le
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "have num_pos : 0 < q.num := Rat.num_pos.mpr hq",
"before_state": "f : β β β\nq : β\nhq : 0 < q\nH1 : β (x y : β), 0 < x β 0 < y β f (x * y) β€ f x * f y\nH4 : β (n : β), 0 < n β βn β€ f βn\nβ’ 0 < f q",
"after_state": "f : β β β\nq : β\nhq : 0 < q\nH1 : β (x y : β), 0 < x β 0 < y β f (x * y) β€ f... |
theorem fx_gt_xm1 {f : β β β} {x : β} (hx : 1 β€ x)
(H1 : β x y, 0 < x β 0 < y β f (x * y) β€ f x * f y)
(H2 : β x y, 0 < x β 0 < y β f x + f y β€ f (x + y)) (H4 : β n : β, 0 < n β (n : β) β€ f n) :
(x - 1 : β) < f x := by
have hx0 :=
calc
(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
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))
_ β€ f (x - βxββ + βxββ) := (H2 _ _ (sub_pos.mpr h_lt) (Nat.cast_pos.2 (Nat.floor_pos.2 hx)))
_ = f x := by ring_nf
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "have hx0 :=\n calc\n (x - 1 : β) < βxββ := mod_cast Nat.sub_one_lt_floor x\n _ β€ f βxββ := H4 _ (Nat.floor_pos.2 hx)",
"before_state": "f : β β β\nx : β\nhx : 1 β€ x\nH1 : β (x y : β), 0 < x β 0 < y β f (x * y) β€ f x * f y\nH2 : β (x y : β), 0 < x β 0 < y β f x + f y β€ f (x + y)\nH4 : β (n ... |
theorem pow_f_le_f_pow {f : β β β} {n : β} (hn : 0 < n) {x : β} (hx : 1 < x)
(H1 : β x y, 0 < x β 0 < y β f (x * y) β€ f x * f y) (H4 : β n : β, 0 < n β (n : β) β€ f n) :
f (x ^ n) β€ f x ^ n := by
induction' n with pn hpn
Β· exfalso; exact Nat.lt_asymm hn hn
rcases pn with - | pn
Β· norm_num
have hpn' := hpn pn.succ_pos
rw [pow_succ x (pn + 1)]
rw [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
_ β€ f x ^ (pn + 1) * f x := by gcongr; exact (f_pos_of_pos hxp H1 H4).le
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "induction' n with pn hpn",
"before_state": "f : β β β\nn : β\nhn : 0 < n\nx : β\nhx : 1 < x\nH1 : β (x y : β), 0 < x β 0 < y β f (x * y) β€ f x * f y\nH4 : β (n : β), 0 < n β βn β€ f βn\nβ’ f (x ^ n) β€ f x ^ n",
"after_state": "case zero\nf : β β β\nx : β\nhx : 1 < x\nH1 : β (x y : β), 0 < x β 0... |
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) := 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
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "have hh0 : (a : β) ^ n β€ f (a ^ n) := mod_cast H5 (a ^ n) (one_lt_powβ ha1 hn.ne')",
"before_state": "f : β β β\nn : β\nhn : 0 < n\nH1 : β (x y : β), 0 < x β 0 < y β f (x * y) β€ f x * f y\nH4 : β (n : β), 0 < n β βn β€ f βn\nH5 : β (x : β), 1 < x β βx β€ f x\na : β\nha1 : 1 < a\nhae : f a = βa\nβ’ f... |
theorem fixed_point_of_gt_1 {f : β β β} {x : β} (hx : 1 < x)
(H1 : β x y, 0 < x β 0 < y β f (x * y) β€ f x * f y)
(H2 : β x y, 0 < x β 0 < y β f x + f y β€ f (x + y)) (H4 : β n : β, 0 < n β (n : β) β€ f n)
(H5 : β x : β, 1 < x β (x : β) β€ f x) {a : β} (ha1 : 1 < a) (hae : f a = a) : f x = x := by
-- Choose n such that 1 + x < a^n.
obtain β¨N, hNβ© := pow_unbounded_of_one_lt (1 + x) ha1
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 : β) := 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 [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)
_ = 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 (mod_cast h2)
linarith [H5 x hx, H5 _ h_big_enough]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q5.lean | {
"open": [],
"variables": []
} | [
{
"line": "obtain β¨N, hNβ© := pow_unbounded_of_one_lt (1 + x) ha1",
"before_state": "f : β β β\nx : β\nhx : 1 < x\nH1 : β (x y : β), 0 < x β 0 < y β f (x * y) β€ f x * f y\nH2 : β (x y : β), 0 < x β 0 < y β f x + f y β€ f (x + y)\nH4 : β (n : β), 0 < n β βn β€ f βn\nH5 : β (x : β), 1 < x β βx β€ f x\na : β\nha1 ... |
theorem imo2013_q5 (f : β β β) (H1 : β x y, 0 < x β 0 < y β f (x * y) β€ f x * f y)
(H2 : β x y, 0 < x β 0 < y β f x + f y β€ f (x + y)) (H_fixed_point : β a, 1 < a β§ f a = a) :
β x, 0 < x β f x = x := by
obtain β¨a, ha1, haeβ© := H_fixed_point
have H3 : β x : β, 0 < x β β n : β, 0 < n β βn * f x β€ f (n * x) := by
intro x hx n hn
rcases n with - | n
Β· exact (lt_irrefl 0 hn).elim
induction' n with pn hpn
Β· norm_num
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 := 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
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 by rwa [β mul_le_mul_left a_pos]
calc
β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
_ = β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 := by rw [mul_one]
have H5 : β x : β, 1 < x β (x : β) β€ f x := by
intro x hx
have hxnm1 : β n : β, 0 < n β (x : β) ^ n - 1 < f x ^ n := by
intro n hn
calc
(x : β) ^ n - 1 < f (x ^ n) :=
mod_cast fx_gt_xm1 (one_le_powβ hx.le) H1 H2 H4
_ β€ f x ^ n := pow_f_le_f_pow hn hx H1 H4
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
intro n hn x hx
have h2 : f (n * x) β€ n * f x := by
rcases n with - | n
Β· exfalso; exact Nat.lt_asymm hn hn
rcases n with - | n
Β· norm_num
have hfneq : f n.succ.succ = n.succ.succ := by
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_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)
-- For the final calculation, we expand x as (2 * x.num) / (2 * x.den), because
-- 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
have Hβ : x * x.den = x.num := x.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 hx2pos : 0 < 2 * x.den := by positivity
have hx2cnezr : (x2denom : β) β (0 : β) := by positivity
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
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 | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2013Q5.lean | {
"open": [
"Imo2013Q5"
],
"variables": []
} | [
{
"line": "obtain β¨a, ha1, haeβ© := H_fixed_point",
"before_state": "f : β β β\nH1 : β (x y : β), 0 < x β 0 < y β f (x * y) β€ f x * f y\nH2 : β (x y : β), 0 < x β 0 < y β f x + f y β€ f (x + y)\nH_fixed_point : β a, 1 < a β§ f a = βa\nβ’ β (x : β), 0 < x β f x = βx",
"after_state": "case intro.intro\nf : β ... |
theorem imo2019_q1 (f : β€ β β€) :
(β a b : β€, f (2 * a) + 2 * f b = f (f (a + b))) β f = 0 β¨ β c, f = fun x => 2 * x + c := by
constructor; swap
-- easy way: f(x)=0 and f(x)=2x+c work.
Β· rintro (rfl | β¨c, rflβ©) <;> intros <;> norm_num; ring
-- hard way.
intro hf
-- functional equation
-- Using `h` for `(0, b)` and `(-1, b + 1)`, we get `f (b + 1) = f b + m`
obtain β¨m, Hβ© : β m, β b, f (b + 1) = f b + m := by
refine β¨(f 0 - f (-2)) / 2, fun b => ?_β©
refine sub_eq_iff_eq_add'.1 (Int.eq_ediv_of_mul_eq_right two_ne_zero ?_)
have h1 : f 0 + 2 * f b = f (f b) := by simpa using hf 0 b
have h2 : f (-2) + 2 * f (b + 1) = f (f b) := by simpa using hf (-1) (b + 1)
linarith
-- Hence, `f` is an affine map, `f b = f 0 + m * b`
obtain β¨c, Hβ© : β c, β b, f b = c + m * b := by
refine β¨f 0, fun b => ?_β©
induction' b with b ihb b ihb
Β· simp
Β· simp [H, ihb, mul_add, add_assoc]
Β· rw [β sub_eq_of_eq_add (H _)]
simp [ihb]; ring
-- Now use `hf 0 0` and `hf 0 1` to show that `m β {0, 2}`
have H3 : 2 * c = m * c := by simpa [H, mul_add] using hf 0 0
obtain rfl | rfl : 2 = m β¨ m = 0 := by simpa [H, mul_add, H3] using hf 0 1
Β· right; use c; ext b; simp [H, add_comm]
Β· left; ext b; simpa [H, two_ne_zero] using H3 | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2019Q1.lean | {
"open": [],
"variables": []
} | [
{
"line": "constructor",
"before_state": "f : β€ β β€\nβ’ (β (a b : β€), f (2 * a) + 2 * f b = f (f (a + b))) β f = 0 β¨ β c, f = fun x => 2 * x + c",
"after_state": "case mp\nf : β€ β β€\nβ’ (β (a b : β€), f (2 * a) + 2 * f b = f (f (a + b))) β f = 0 β¨ β c, f = fun x => 2 * x + c\n---\ncase mpr\nf : β€ β β€\nβ’ (f... |
theorem upper_bound {k n : β} (hk : k > 0)
(h : (k ! : β€) = β i β range n, ((2 : β€) ^ n - (2 : β€) ^ i)) : n < 6 := by
have h2 : β i β range n, i < k := by
suffices emultiplicity 2 (k ! : β€) = β(β i β range n, i : β) by
rw [β Nat.cast_lt (Ξ± := ββ)]; change emultiplicity ((2 : β) : β€) _ < _
rw [β this]; change emultiplicity ((2 : β) : β€) _ < _
simp_rw [Int.natCast_emultiplicity, emultiplicity_two_factorial_lt hk.lt.ne.symm]
rw [h]
rw [Finset.emultiplicity_prod Int.prime_two]
rw [Nat.cast_sum]
apply sum_congr rfl; intro i hi
rw [emultiplicity_sub_of_gt]
rw [emultiplicity_pow_self_of_prime Int.prime_two]
rwa [emultiplicity_pow_self_of_prime Int.prime_two,
emultiplicity_pow_self_of_prime Int.prime_two, Nat.cast_lt, β mem_range]
rw [β not_le]; intro hn
apply _root_.ne_of_gt _ h
calc β i β range n, ((2:β€) ^ n - (2:β€) ^ i) β€ β __ β range n, (2:β€) ^ n := ?_
_ < β k ! := ?_
Β· gcongr
Β· intro i hi
simp only [mem_range] at hi
have : (2:β€) ^ i β€ (2:β€) ^ n := by gcongr; norm_num
linarith
Β· apply sub_le_self
positivity
norm_cast
calc β __ β range n, 2 ^ n = 2 ^ (n * n) := by rw [prod_const, card_range, β pow_mul]
_ < (β i β range n, i)! := ?_
_ β€ k ! := by gcongr
clear h h2
induction' n, hn using Nat.le_induction with n' hn' IH
Β· decide
let A := β i β range n', i
have le_sum : β i β range 6, i β€ A := by
apply sum_le_sum_of_subset
simpa using hn'
calc 2 ^ ((n' + 1) * (n' + 1))
β€ 2 ^ (n' * n' + 4 * n') := by gcongr <;> linarith
_ = 2 ^ (n' * n') * (2 ^ 4) ^ n' := by rw [β pow_mul, β pow_add]
_ < A ! * (2 ^ 4) ^ n' := by gcongr
_ = A ! * (15 + 1) ^ n' := rfl
_ β€ A ! * (A + 1) ^ n' := by gcongr; exact le_sum
_ β€ (A + n')! := factorial_mul_pow_le_factorial
_ = (β i β range (n' + 1), i)! := by rw [sum_range_succ]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2019Q4.lean | {
"open": [
"scoped Nat",
"Nat hiding zero_le Prime",
"Finset"
],
"variables": []
} | [
{
"line": "have h2 : β i β range n, i < k :=\n by\n suffices emultiplicity 2 (k ! : β€) = β(β i β range n, i : β)\n by\n rw [β Nat.cast_lt (Ξ± := ββ)]; change emultiplicity ((2 : β) : β€) _ < _\n rw [β this]; change emultiplicity ((2 : β) : β€) _ < _\n simp_rw [Int.natCast_emultiplicity, emultiplicity... |
lemma 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) := by
rw [Nat.le_sqrt]
apply Nat.le_add_left
have hβ := Nat.sqrt_le' (n + 1)
have hβ := Nat.succ_le_succ_sqrt' (n + 1)
have hβ : 10 β€ (n + 1).sqrt := by
rw [Nat.le_sqrt]
omega
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β]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2021Q1.lean | {
"open": [
"Finset"
],
"variables": []
} | [
{
"line": "have hn' : 1 β€ Nat.sqrt (n + 1) := by\n rw [Nat.le_sqrt]\n apply Nat.le_add_left",
"before_state": "n : β\nhn : 100 β€ n\nβ’ β l, n + 4 * l β€ 2 * l ^ 2 β§ 2 * l ^ 2 + 4 * l β€ 2 * n",
"after_state": "n : β\nhn : 100 β€ n\nhn' : 1 β€ (n + 1).sqrt\nβ’ β l, n + 4 * l β€ 2 * l ^ 2 β§ 2 * l ^ 2 + 4 * l β€... |
lemma exists_triplet_summing_to_squares {n : β} (hn : 100 β€ n) :
β a b c : β, n β€ a β§ a < b β§ b < c β§ c β€ 2 * n β§
IsSquare (a + b) β§ IsSquare (c + a) β§ IsSquare (b + c) := by
obtain β¨l, hl1, hl2β© := exists_numbers_in_interval hn
have hl : 1 < l := by contrapose! hl1; interval_cases l <;> linarith
have hβ : 4 * l β€ 2 * l ^ 2 := by omega
have hβ : 1 β€ 2 * l := by omega
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
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2021Q1.lean | {
"open": [
"Finset"
],
"variables": []
} | [
{
"line": "obtain β¨l, hl1, hl2β© := exists_numbers_in_interval hn",
"before_state": "n : β\nhn : 100 β€ n\nβ’ β a b c, n β€ a β§ a < b β§ b < c β§ c β€ 2 * n β§ IsSquare (a + b) β§ IsSquare (c + a) β§ IsSquare (b + c)",
"after_state": "No Goals!"
}
] |
lemma exists_finset_3_le_card_with_pairs_summing_to_squares {n : β} (hn : 100 β€ n) :
β B : Finset β,
2 * 1 + 1 β€ #B β§
(β a β B, β b β B, a β b β IsSquare (a + b)) β§
β c β B, n β€ c β§ c β€ 2 * n := by
obtain β¨a, b, c, hna, hab, hbc, hcn, hβ, hβ, hββ© := exists_triplet_summing_to_squares hn
refine β¨{a, b, c}, ?_, ?_, ?_β©
Β· suffices a β {b, c} β§ b β {c} by
rw [Finset.card_insert_of_not_mem this.1]
rw [Finset.card_insert_of_not_mem this.2]
rw [Finset.card_singleton]
rw [Finset.mem_insert]
rw [Finset.mem_singleton]
rw [Finset.mem_singleton]
push_neg
exact β¨β¨hab.ne, (hab.trans hbc).neβ©, hbc.neβ©
Β· intro x hx y hy hxy
simp only [Finset.mem_insert] at hx hy
simp only [Finset.mem_singleton] at hx hy
rcases hx with (rfl | rfl | rfl) <;> rcases hy with (rfl | rfl | rfl)
all_goals
first
| contradiction
| assumption
| simpa only [add_comm x y]
Β· simp only [Finset.mem_insert, Finset.mem_singleton]
rintro d (rfl | rfl | rfl) <;> constructor <;> linarith only [hna, hab, hbc, hcn]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2021Q1.lean | {
"open": [
"Finset"
],
"variables": []
} | [
{
"line": "obtain β¨a, b, c, hna, hab, hbc, hcn, hβ, hβ, hββ© := exists_triplet_summing_to_squares hn",
"before_state": "n : β\nhn : 100 β€ n\nβ’ β B, 2 * 1 + 1 β€ #B β§ (β a β B, β b β B, a β b β IsSquare (a + b)) β§ β c β B, n β€ c β§ c β€ 2 * n",
"after_state": "No Goals!"
}
] |
theorem imo2021_q1 :
β n : β, 100 β€ n β β A β Finset.Icc n (2 * n),
(β a β A, β b β A, a β b β§ IsSquare (a + b)) β¨
β a β Finset.Icc n (2 * n) \ A, β b β Finset.Icc n (2 * n) \ A, a β b β§ IsSquare (a + b) := 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
-- a finite set B β [n, 2n] such that all pairwise unequal pairs of B sum to a perfect square
-- noting that B has cardinality greater or equal to 3, by the explicit construction of the
-- triplet {a, b, c} before.
obtain β¨B, hB, hβ, hββ© := exists_finset_3_le_card_with_pairs_summing_to_squares hn
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 β© (Icc n (2 * n) \ A) βͺ B β© A) := by
rwa [β inter_union_distrib_left, sdiff_union_self_eq_union, union_eq_left.2 hA,
inter_eq_left.2 hBsub, β Nat.succ_le_iff]
-- 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
-- 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
rcases hC with β¨a, ha, b, hb, habβ©
simp only [Finset.subset_iff] at hCA
simp only [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.
rcases hCA with hCA | hCA <;> [right; left] <;>
exact β¨a, (hCA ha).2, b, (hCA hb).2, hab, hβ a (hCA ha).1 b (hCA hb).1 habβ© | /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2021Q1.lean | {
"open": [
"Finset",
"Imo2021Q1"
],
"variables": []
} | [
{
"line": "intro n hn A hA",
"before_state": "β’ β (n : β),\n 100 β€ n β\n β A β Icc n (2 * n),\n (β a β A, β b β A, a β b β§ IsSquare (a + b)) β¨\n β a β Icc n (2 * n) \\ A, β b β Icc n (2 * n) \\ A, a β b β§ IsSquare (a + b)",
"after_state": "n : β\nhn : 100 β€ n\nA : Finset β\nhA : ... |
lemma dvd_pow_iff_of_dvd_sub {a b d n : β} {z : β€} (ha : a.Coprime d)
(hd : (Ο d : β€) β£ (n : β€) - z) :
d β£ a ^ n + b β (((ZMod.unitOfCoprime _ ha) ^ z : (ZMod d)Λ£) : ZMod d) + b = 0 := by
rcases hd with β¨k, hkβ©
rw [β ZMod.natCast_zmod_eq_zero_iff_dvd]
convert Iff.rfl
push_cast
congr
suffices (((ZMod.unitOfCoprime _ ha) ^ z : (ZMod d)Λ£) : ZMod d) =
(((ZMod.unitOfCoprime _ ha) ^ (n : β€) : (ZMod d)Λ£) : ZMod d) by
convert this
rw [sub_eq_iff_eq_add] at hk
rw [hk]
rw [zpow_add]
rw [zpow_mul]
norm_cast
rw [ZMod.pow_totient]
rw [one_zpow]
rw [one_mul]
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2024Q2.lean | {
"open": [
"scoped Nat"
],
"variables": []
} | [
{
"line": "rcases hd with β¨k, hkβ©",
"before_state": "a b d n : β\nz : β€\nha : a.Coprime d\nhd : β(Ο d) β£ βn - z\nβ’ d β£ a ^ n + b β β(ZMod.unitOfCoprime a ha ^ z) + βb = 0",
"after_state": "case intro\na b d n : β\nz : β€\nha : a.Coprime d\nk : β€\nhk : βn - z = β(Ο d) * k\nβ’ d β£ a ^ n + b β β(ZMod.unitOfC... |
lemma map_add_one_range (p : β β Prop) [DecidablePred p] (n : β) (h0 : Β¬ p 0) :
{x β Finset.range n | p (x + 1)}.map β¨(Β· + 1), add_left_injective 1β© =
{x β Finset.range (n + 1) | p x } := by
ext x
simp only [Finset.mem_map]
constructor
Β· aesop
Β· intro hx
use x - 1
cases x <;> simp_all
| /root/DuelModelResearch/mathlib4/Archive/Imo/Imo2024Q3.lean | {
"open": [
"scoped Finset"
],
"variables": []
} | [
{
"line": "ext x",
"before_state": "p : β β Prop\ninstβ : DecidablePred p\nn : β\nh0 : Β¬p 0\nβ’ Finset.map { toFun := fun x => x + 1, inj' := β― } ({x β Finset.range n | p (x + 1)}) =\n {x β Finset.range (n + 1) | p x}",
"after_state": "case h\np : β β Prop\ninstβ : DecidablePred p\nn : β\nh0 : Β¬p 0\nx... |
theorem add_mod2 (a : β) : β t, a + a % 2 = t * 2 := by
simp only [mul_comm _ 2] -- write `t*2` as `2*t`
apply dvd_of_mod_eq_zero -- it suffices to prove `(a + a % 2) % 2 = 0`
rw [add_mod]
rw [mod_mod]
rw [β two_mul]
rw [mul_mod_right]
| /root/DuelModelResearch/mathlib4/Archive/MiuLanguage/DecisionSuf.lean | {
"open": [
"MiuAtom List Nat"
],
"variables": []
} | [
{
"line": "simp only [mul_comm _ 2]\n -- write `t*2` as `2*t`",
"before_state": "a : β\nβ’ β t, a + a % 2 = t * 2",
"after_state": "a : β\nβ’ β t, a + a % 2 = 2 * t"
},
{
"line": "apply dvd_of_mod_eq_zero",
"before_state": "a : β\nβ’ β t, a + a % 2 = 2 * t",
"after_state": "No Goals!"
}
... |
private theorem le_pow2_and_pow2_eq_mod3' (c : β) (x : β) (h : c = 1 β¨ c = 2) :
β m : β, c + 3 * x β€ 2 ^ m β§ 2 ^ m % 3 = c % 3 := by
induction' x with k hk
Β· use c + 1
rcases h with hc | hc <;> Β· rw [hc]; norm_num
rcases hk with β¨g, hkg, hgmodβ©
by_cases hp : c + 3 * (k + 1) β€ 2 ^ g
Β· use g, hp, hgmod
refine β¨g + 2, ?_, ?_β©
Β· rw [mul_succ, β add_assoc, pow_add]
change c + 3 * k + 3 β€ 2 ^ g * (1 + 3); rw [mul_add (2 ^ g) 1 3, mul_one]
linarith [hkg, @Nat.one_le_two_pow g]
Β· rw [pow_add, β mul_one c]
exact ModEq.mul hgmod rfl
| /root/DuelModelResearch/mathlib4/Archive/MiuLanguage/DecisionSuf.lean | {
"open": [
"MiuAtom List Nat"
],
"variables": []
} | [
{
"line": "induction' x with k hk",
"before_state": "c x : β\nh : c = 1 β¨ c = 2\nβ’ β m, c + 3 * x β€ 2 ^ m β§ 2 ^ m % 3 = c % 3",
"after_state": "case zero\nc : β\nh : c = 1 β¨ c = 2\nβ’ β m, c + 3 * 0 β€ 2 ^ m β§ 2 ^ m % 3 = c % 3\n---\ncase succ\nc : β\nh : c = 1 β¨ c = 2\nk : β\nhk : β m, c + 3 * k β€ 2 ^ m ... |
theorem le_pow2_and_pow2_eq_mod3 (a : β) (h : a % 3 = 1 β¨ a % 3 = 2) :
β m : β, a β€ 2 ^ m β§ 2 ^ m % 3 = a % 3 := by
obtain β¨m, hmβ© := le_pow2_and_pow2_eq_mod3' (a % 3) (a / 3) h
use m
constructor
Β· convert hm.1; exact (mod_add_div a 3).symm
Β· rw [hm.2, mod_mod _ 3]
| /root/DuelModelResearch/mathlib4/Archive/MiuLanguage/DecisionSuf.lean | {
"open": [
"MiuAtom List Nat"
],
"variables": []
} | [
{
"line": "obtain β¨m, hmβ© := le_pow2_and_pow2_eq_mod3' (a % 3) (a / 3) h",
"before_state": "a : β\nh : a % 3 = 1 β¨ a % 3 = 2\nβ’ β m, a β€ 2 ^ m β§ 2 ^ m % 3 = a % 3",
"after_state": "No Goals!"
}
] |
theorem OxfordInvariants.Week3P1 (n : β) (a : β β β) (a_pos : β i β€ n, 0 < a i)
(ha : β i, i + 2 β€ n β a (i + 1) β£ a i + a (i + 2)) :
β b : β, (b : Ξ±) = β i β Finset.range n, (a 0 : Ξ±) * a n / (a i * a (i + 1)) := by
-- Treat separately `n = 0` and `n β₯ 1`
rcases n with - | n
/- Case `n = 0`
The sum is trivially equal to `0` -/
Β· exact β¨0, by rw [Nat.cast_zero, Finset.sum_range_zero]β©
-- `β¨Claim it, Prove itβ©`
/- Case `n β₯ 1`. We replace `n` by `n + 1` everywhere to make this inequality explicit
Set up the stronger induction hypothesis -/
rsuffices β¨b, hb, -β© :
β b : β,
(b : Ξ±) = β i β Finset.range (n + 1), (a 0 : Ξ±) * a (n + 1) / (a i * a (i + 1)) β§
a (n + 1) β£ a n * b - a 0
Β· exact β¨b, hbβ©
simp_rw [β @Nat.cast_pos Ξ±] at a_pos
/- Declare the induction
`ih` will be the induction hypothesis -/
induction' n with n ih
/- Base case
Claim that the sum equals `1` -/
Β· refine β¨1, ?_, ?_β©
-- Check that this indeed equals the sum
Β· rw [Nat.cast_one, Finset.sum_range_one]
norm_num
rw [div_self]
exact (mul_pos (a_pos 0 (Nat.zero_le _)) (a_pos 1 (Nat.zero_lt_succ _))).ne'
-- Check the divisibility condition
Β· rw [mul_one, tsub_self]
exact dvd_zero _
/- Induction step
`b` is the value of the previous sum as a natural, `hb` is the proof that it is indeed the
value, and `han` is the divisibility condition -/
obtain β¨b, hb, hanβ© :=
ih (fun i hi => ha i <| Nat.le_succ_of_le hi) fun i hi => a_pos i <| Nat.le_succ_of_le hi
specialize ha n le_rfl
have haβ : a 0 β€ a n * b := by
-- Needing this is an artifact of `β`-subtraction.
rw [β @Nat.cast_le Ξ±]
rw [Nat.cast_mul]
rw [hb]
rw [β div_le_iffβ' (a_pos _ <| n.le_succ.trans <| Nat.le_succ _)]
rw [β mul_div_mul_right _ _ (a_pos _ <| Nat.le_succ _).ne']
suffices h : β i, i β Finset.range (n + 1) β 0 β€ (a 0 : Ξ±) * a (n + 1) / (a i * a (i + 1)) from
Finset.single_le_sum h (Finset.self_mem_range_succ n)
refine fun i _ β¦ div_nonneg ?_ ?_ <;> refine mul_nonneg ?_ ?_ <;> exact Nat.cast_nonneg _
-- Claim that the sum equals `(aβ + aβββ)/aβββ * b - (aβ * b - aβ)/aβββ`
refine β¨(a n + a (n + 2)) / a (n + 1) * b - (a n * b - a 0) / a (n + 1), ?_, ?_β©
-- Check that this indeed equals the sum
Β· calc
(((a n + a (n + 2)) / a (n + 1) * b - (a n * b - a 0) / a (n + 1) : β) : Ξ±) =
((a n + a (n + 2)) / a (n + 1) * b - (a n * b - a 0) / a (n + 1) ) := by
have :((a (n + 1)) : Ξ±) β 0 := ne_of_gt <| a_pos (n + 1) <| Nat.le_succ (n + 1)
simp only [β Nat.cast_add]
simp only [β Nat.cast_div ha this]
simp only [β Nat.cast_mul]
simp only [β Nat.cast_sub haβ]
simp only [β Nat.cast_div han this]
rw [Nat.cast_sub (Nat.div_le_of_le_mul _)]
rw [β mul_assoc]
rw [Nat.mul_div_cancel' ha]
rw [add_mul]
exact tsub_le_self.trans (Nat.le_add_right _ _)
_ = a (n + 2) / a (n + 1) * b + a 0 * a (n + 2) / (a (n + 1) * a (n + 2)) := by
rw [add_div]
rw [add_mul]
rw [sub_div]
rw [mul_div_right_comm]
rw [add_sub_sub_cancel]
rw [mul_div_mul_right _ _ (a_pos _ le_rfl).ne']
_ = β i β Finset.range (n + 2), (a 0 : Ξ±) * a (n + 2) / (a i * a (i + 1)) := by
rw [Finset.sum_range_succ]
rw [hb]
rw [Finset.mul_sum]
congr; ext i
rw [β mul_div_assoc]
rw [β mul_div_right_comm]
rw [mul_div_assoc]
rw [mul_div_cancel_rightβ _ (a_pos _ <| Nat.le_succ _).ne']
rw [mul_comm]
-- Check the divisibility condition
Β· rw [Nat.mul_sub, β mul_assoc, Nat.mul_div_cancel' ha, add_mul, Nat.mul_div_cancel' han,
add_tsub_tsub_cancel haβ, add_tsub_cancel_right]
exact dvd_mul_right _ _ | /root/DuelModelResearch/mathlib4/Archive/OxfordInvariants/Summer2021/Week3P1.lean | {
"open": [],
"variables": [
"{Ξ± : Type*} [Field Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±]"
]
} | [
{
"line": "rcases n with - | n",
"before_state": "Ξ± : Type u_1\ninstβΒ² : Field Ξ±\ninstβΒΉ : LinearOrder Ξ±\ninstβ : IsStrictOrderedRing Ξ±\nn : β\na : β β β\na_pos : β i β€ n, 0 < a i\nha : β (i : β), i + 2 β€ n β a (i + 1) β£ a i + a (i + 2)\nβ’ β b, βb = β i β Finset.range n, β(a 0) * β(a n) / (β(a i) * β(a (i +... |
theorem cube_root_of_unity_sum (hΟ : IsPrimitiveRoot Ο 3) : 1 + Ο + Ο ^ 2 = 0 := by
simpa [cyclotomic_prime, Finset.sum_range_succ] using hΟ.isRoot_cyclotomic (by decide)
| /root/DuelModelResearch/mathlib4/Archive/Wiedijk100Theorems/SolutionOfCubicQuartic.lean | {
"open": [
"Polynomial"
],
"variables": [
"{K : Type*} [Field K] (a b c d e : K) {Ο p q r s t u v w x y : K}"
]
} | [
{
"line": "simpa [cyclotomic_prime, Finset.sum_range_succ] using hΟ.isRoot_cyclotomic (by decide)",
"before_state": "K : Type u_1\ninstβ : Field K\nΟ : K\nhΟ : IsPrimitiveRoot Ο 3\nβ’ 1 + Ο + Ο ^ 2 = 0",
"after_state": "No Goals!"
},
{
"line": "decide",
"before_state": "K : Type u_1\ninstβ : ... |
theorem cubic_eq_zero_iff_of_p_eq_zero (ha : a β 0) (hΟ : IsPrimitiveRoot Ο 3)
(hpz : 3 * a * c - b ^ 2 = 0)
(hq : q = (9 * a * b * c - 2 * b ^ 3 - 27 * a ^ 2 * d) / (54 * a ^ 3)) (hs3 : s ^ 3 = 2 * q)
(x : K) :
a * x ^ 3 + b * x ^ 2 + c * x + d = 0 β
x = s - b / (3 * a) β¨ x = s * Ο - b / (3 * a) β¨ x = s * Ο ^ 2 - b / (3 * a) := by
have hβ : β x aβ aβ aβ : K, x = aβ β¨ x = aβ β¨ x = aβ β (x - aβ) * (x - aβ) * (x - aβ) = 0 := by
intros; simp only [mul_eq_zero, sub_eq_zero, or_assoc]
have hi2 : (2 : K) β 0 := Invertible.ne_zero _
have hi3 : (3 : K) β 0 := Invertible.ne_zero _
have h54 : (54 : K) = 2 * 3 ^ 3 := by norm_num
have hb2 : b ^ 2 = 3 * a * c := by rw [sub_eq_zero] at hpz; rw [hpz]
have hb3 : b ^ 3 = 3 * a * b * c := by rw [pow_succ, hb2]; ring
have hβ :=
calc
a * x ^ 3 + b * x ^ 2 + c * x + d =
a * (x + b / (3 * a)) ^ 3 + (c - b ^ 2 / (3 * a)) * x + (d - b ^ 3 * a / (3 * a) ^ 3) := by
field_simp; ring
_ = a * (x + b / (3 * a)) ^ 3 + (d - (9 * a * b * c - 2 * b ^ 3) * a / (3 * a) ^ 3) := by
simp only [hb2]; field_simp [ha]; ring
simp only [hb3]; field_simp [ha]; ring
_ = a * ((x + b / (3 * a)) ^ 3 - s ^ 3) := by rw [hs3, hq]; field_simp [h54]; ring
have hβ : β x, a * x = 0 β x = 0 := by intro x; simp [ha]
have hβ : β x : K, x ^ 3 - s ^ 3 = (x - s) * (x - s * Ο) * (x - s * Ο ^ 2) := by
intro x
calc
x ^ 3 - s ^ 3 = (x - s) * (x ^ 2 + x * s + s ^ 2) := by ring
_ = (x - s) * (x ^ 2 - (Ο + Ο ^ 2) * x * s + (1 + Ο + Ο ^ 2) * x * s + s ^ 2) := by ring
_ = (x - s) * (x ^ 2 - (Ο + Ο ^ 2) * x * s + Ο ^ 3 * s ^ 2) := by
rw [hΟ.pow_eq_one]; simp
rw [cube_root_of_unity_sum hΟ]; simp
_ = (x - s) * (x - s * Ο) * (x - s * Ο ^ 2) := by ring
rw [hβ]
rw [hβ]
rw [hβ]
rw [hβ (x + b / (3 * a))]
ring_nf
| /root/DuelModelResearch/mathlib4/Archive/Wiedijk100Theorems/SolutionOfCubicQuartic.lean | {
"open": [
"Polynomial"
],
"variables": [
"{K : Type*} [Field K] (a b c d e : K) {Ο p q r s t u v w x y : K}",
"[Invertible (2 : K)] [Invertible (3 : K)]"
]
} | [
{
"line": "have hβ : β x aβ aβ aβ : K, x = aβ β¨ x = aβ β¨ x = aβ β (x - aβ) * (x - aβ) * (x - aβ) = 0 := by intros;\n simp only [mul_eq_zero, sub_eq_zero, or_assoc]",
"before_state": "K : Type u_1\ninstβΒ² : Field K\na b c d Ο q s : K\ninstβΒΉ : Invertible 2\ninstβ : Invertible 3\nha : a β 0\nhΟ : IsPrimitive... |
theorem quartic_depressed_eq_zero_iff
(hq_nonzero : q β 0)
(hu : u ^ 3 - p * u ^ 2 - 4 * r * u + 4 * p * r - q ^ 2 = 0)
(hs : s ^ 2 = u - p)
(hv : v ^ 2 = 4 * s ^ 2 - 8 * (u - q / s))
(hw : w ^ 2 = 4 * s ^ 2 - 8 * (u + q / s))
(x : K) :
x ^ 4 + p * x ^ 2 + q * x + r = 0 β
x = (-2 * s - v) / 4 β¨ x = (-2 * s + v) / 4 β¨ x = (2 * s - w) / 4 β¨ x = (2 * s + w) / 4 := by
have hi2 : (2 : K) β 0 := Invertible.ne_zero _
have h4 : (4 : K) = 2 ^ 2 := by norm_num
have hs_nonzero : s β 0 := by
contrapose! hq_nonzero with hs0
linear_combination (exp := 2) -hu + (4 * r - u ^ 2) * hs + (u ^ 2 * s - 4 * r * s) * hs0
calc
_ β 4 * (x ^ 4 + p * x ^ 2 + q * x + r) = 0 := by simp [h4, hi2]
_ β (2 * (x * x) + 2 * s * x + (u - q / s)) * (2 * (x * x) + -(2 * s) * x + (u + q / s)) =
0 := by
apply Eq.congr_left
field_simp
linear_combination -hu + (-x ^ 2 * s ^ 2 - x ^ 2 * p + x ^ 2 * u) * hw +
(x ^ 2 * w ^ 2 + 8 * x ^ 2 * u + 8 * x ^ 2 * q / s - u ^ 2 + 4 * r) * hs
_ β _ := by
have hv' : discrim 2 (2 * s) (u - q / s) = v * v := by rw [discrim]; linear_combination -hv
have hw' : discrim 2 (-(2 * s)) (u + q / s) = w * w := by rw [discrim]; linear_combination -hw
rw [mul_eq_zero]
rw [quadratic_eq_zero_iff hi2 hv']
rw [quadratic_eq_zero_iff hi2 hw']
simp [(by norm_num : (2 : K) * 2 = 4), or_assoc, or_comm]
| /root/DuelModelResearch/mathlib4/Archive/Wiedijk100Theorems/SolutionOfCubicQuartic.lean | {
"open": [
"Polynomial"
],
"variables": [
"{K : Type*} [Field K] (a b c d e : K) {Ο p q r s t u v w x y : K}",
"[Invertible (2 : K)] [Invertible (3 : K)]",
"[Invertible (2 : K)]"
]
} | [
{
"line": "have hi2 : (2 : K) β 0 := Invertible.ne_zero _",
"before_state": "K : Type u_1\ninstβΒ³ : Field K\np q r s u v w : K\ninstβΒ² : Invertible 2\ninstβΒΉ : Invertible 3\ninstβ : Invertible 2\nhq_nonzero : q β 0\nhu : u ^ 3 - p * u ^ 2 - 4 * r * u + 4 * p * r - q ^ 2 = 0\nhs : s ^ 2 = u - p\nhv : v ^ 2 =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.