Skip to content

Commit

Permalink
some simplifications found by tryAtEachStep
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Dec 5, 2024
1 parent b7e6af3 commit e856f6d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
16 changes: 3 additions & 13 deletions Compfiles/Imo1982P3.lean
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,9 @@ lemma sum_Fin_eq_sum_Ico {x : ℕ → ℝ} {N : ℕ} : ∑ n : Fin N, x n = ∑
Specialization of Cauchy-Schwarz inequality with the sequences x n / √(y n) and √(y n)
-/
theorem Sedrakyan's_lemma {ι : Type*} {s : Finset ι} {x y : ι → ℝ}
(hN : 0 < Finset.card s) (_xi_pos : ∀ i ∈ s, 0 < x i) (yi_pos : ∀ i ∈ s, 0 < y i) :
(yi_pos : ∀ i ∈ s, 0 < y i) :
(∑ n ∈ s, x n) ^ 2 / (∑ n ∈ s, y n) ≤ ∑ n ∈ s, (x n) ^ 2 / y n := by
have : 0 < ∑ n ∈ s, y n := Finset.sum_pos yi_pos <| Finset.card_pos.mp hN
apply le_of_le_of_eq (b := ((∑ n ∈ s, x n ^ 2 / y n) * ∑ n ∈ s, y n) / ∑ n ∈ s, y n)
· gcongr
convert Finset.sum_mul_sq_le_sq_mul_sq s (fun n ↦ x n / √ (y n)) (fun n ↦ √ (y n)) with n hn n hn n hn
all_goals specialize _xi_pos n hn
all_goals specialize yi_pos n hn
· field_simp
· field_simp
· rw [Real.sq_sqrt]
positivity
· field_simp
exact Finset.sq_sum_div_le_sum_sq_div s x yi_pos

lemma ineq₁ {x : ℕ → ℝ} {N : ℕ} (hN : 1 < N) (hx : ∀ i , x (i + 1) ≤ x i) :
x N ≤ (∑ n : Fin (N - 1), x (n + 1)) / (N - 1) := by
Expand Down Expand Up @@ -220,7 +210,7 @@ problem iom1982_p3a {x : ℕ → ℝ} (x_pos : ∀ i, x i > (0 : ℝ))
have sedrakayan's_lemma :
∀ N > 0,
((∑ n : Fin N, (x n))^2 / (∑ n : Fin N, x (n + 1))) ≤ (∑ n : Fin N, (x n)^2 / x (n + 1)) :=
fun N hN => Sedrakyan's_lemma (by simpa) (fun i _ => x_pos i) (fun i _ => x_pos (i + 1))
fun N hN => Sedrakyan's_lemma (fun i _ => x_pos (i + 1))
have :
∃ (N : ℕ), 0 < N ∧ 1 < N ∧ 2 < N ∧ (3.999 : ℝ) ≤ 4 * ((N - 1) / N) := by use 4000; norm_num
obtain ⟨N, zero_lt_N, one_lt_N, two_lt_N, ineq₀⟩ := this
Expand Down
4 changes: 2 additions & 2 deletions Compfiles/Usa1981P5.lean
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ problem usa1981_p5 (x : ℝ) (n : ℕ) :
obtain rfl | hn := Nat.eq_zero_or_pos n
· simp [a]

have : Nonempty (Finset.Icc 1 n) := by
use 1; rw [Finset.mem_Icc]; simp only [le_refl, true_and]; exact hn
have : Nonempty (Finset.Icc 1 n) :=
1, Finset.left_mem_Icc.mpr (Nat.succ_le_of_lt hn)⟩
obtain ⟨⟨m, hm1⟩, hm2⟩ :=
Finite.exists_min (fun (m : Finset.Icc 1 n) ↦ a m / m)

Expand Down
2 changes: 1 addition & 1 deletion Compfiles/Usa2002P1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ lemma usa2002_p1_generalized
· -- Suppose that our claim holds for n = k. Let s ∈ S, |S| = k + 1,
-- and let S' denote the set of all elements of S other than s.
intros S hde hft hs N hN
have s : S := Nonempty.some (Fintype.card_pos_iff.mp (by rw [hs]; exact Nat.succ_pos k))
have s : S := Nonempty.some (Fintype.card_pos_iff.mp (Nat.lt_of_sub_eq_succ hs))
let S' := { a : S // a ≠ s }
have hs' : Fintype.card S' = k := by simp [Fintype.card_subtype_compl, hs, S']

Expand Down

0 comments on commit e856f6d

Please sign in to comment.