Skip to content

Commit

Permalink
chore(*): golf (#10417)
Browse files Browse the repository at this point in the history
  • Loading branch information
urkud committed Feb 14, 2024
1 parent 6f21dbd commit e4bee60
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 40 deletions.
23 changes: 3 additions & 20 deletions Mathlib/Algebra/Star/CHSH.lean
Expand Up @@ -216,26 +216,9 @@ theorem tsirelson_inequality [OrderedRing R] [StarOrderedRing R] [Algebra ℝ R]
simp only [star_smul, star_add, star_sub, star_id_of_comm, T.A₀_sa, T.A₁_sa, T.B₀_sa, T.B₁_sa]
have Q_sa : star Q = Q := by
simp only [star_smul, star_add, star_sub, star_id_of_comm, T.A₀_sa, T.A₁_sa, T.B₀_sa, T.B₁_sa]
have P2_nonneg : 0 ≤ P ^ 2 := by
rw [sq]
conv =>
congr
skip
congr
rw [← P_sa]
convert (star_mul_self_nonneg P)
have Q2_nonneg : 0 ≤ Q ^ 2 := by
rw [sq]
conv =>
congr
skip
congr
rw [← Q_sa]
convert (star_mul_self_nonneg Q)
convert smul_le_smul_of_nonneg_left (add_nonneg P2_nonneg Q2_nonneg)
(le_of_lt (show 0 < √2⁻¹ by norm_num))
-- `norm_num` can't directly show `0 ≤ √2⁻¹`
simp
have P2_nonneg : 0 ≤ P ^ 2 := by simpa only [P_sa, sq] using star_mul_self_nonneg P
have Q2_nonneg : 0 ≤ Q ^ 2 := by simpa only [Q_sa, sq] using star_mul_self_nonneg Q
exact smul_nonneg (by positivity) (add_nonneg P2_nonneg Q2_nonneg)
apply le_of_sub_nonneg
simpa only [sub_add_eq_sub_sub, ← sub_add, w, Nat.cast_zero] using pos
#align tsirelson_inequality tsirelson_inequality
1 change: 0 additions & 1 deletion Mathlib/Analysis/InnerProductSpace/Basic.lean
Expand Up @@ -1179,7 +1179,6 @@ theorem dist_div_norm_sq_smul {x y : F} (hx : x ≠ 0) (hy : y ≠ 0) (R : ℝ)
ring
_ = R ^ 2 / (‖x‖ * ‖y‖) * dist x y := by
rw [sqrt_mul, sqrt_sq, sqrt_sq, dist_eq_norm] <;> positivity

#align dist_div_norm_sq_smul dist_div_norm_sq_smul

-- See note [lower instance priority]
Expand Down
21 changes: 4 additions & 17 deletions Mathlib/Analysis/InnerProductSpace/Projection.lean
Expand Up @@ -166,23 +166,10 @@ theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h
_ ≤ 2 * ((δ + div) * (δ + div) + (δ + div) * (δ + div)) - 4 * δ * δ := by gcongr
_ = 8 * δ * div + 4 * div * div := by ring
positivity
-- third goal : `Tendsto (fun (n : ℕ) => sqrt (b n)) atTop (𝓝 0)`
apply Tendsto.comp (f := b) (g := sqrt)
· have : Tendsto sqrt (nhds 0) (nhds (sqrt 0)) := continuous_sqrt.continuousAt
convert this
exact sqrt_zero.symm
have eq₁ : Tendsto (fun n : ℕ => 8 * δ * (1 / (n + 1))) atTop (nhds (0 : ℝ)) := by
convert (tendsto_const_nhds (x := 8 * δ)).mul tendsto_one_div_add_atTop_nhds_zero_nat
simp only [mul_zero]
have : Tendsto (fun n : ℕ => (4 : ℝ) * (1 / (n + 1))) atTop (nhds (0 : ℝ)) := by
convert (tendsto_const_nhds (x := 4)).mul tendsto_one_div_add_atTop_nhds_zero_nat
simp only [mul_zero]
have eq₂ :
Tendsto (fun n : ℕ => (4 : ℝ) * (1 / (n + 1)) * (1 / (n + 1))) atTop (nhds (0 : ℝ)) := by
convert this.mul tendsto_one_div_add_atTop_nhds_zero_nat
simp only [mul_zero]
convert eq₁.add eq₂
simp only [add_zero]
-- third goal : `Tendsto (fun (n : ℕ) => √(b n)) atTop (𝓝 0)`
suffices Tendsto (fun x ↦ sqrt (8 * δ * x + 4 * x * x) : ℝ → ℝ) (𝓝 0) (𝓝 0)
from this.comp tendsto_one_div_add_atTop_nhds_zero_nat
exact Continuous.tendsto' (by continuity) _ _ (by simp)
-- Step 3: By completeness of `K`, let `w : ℕ → K` converge to some `v : K`.
-- Prove that it satisfies all requirements.
rcases cauchySeq_tendsto_of_isComplete h₁ (fun n => Subtype.mem _) seq_is_cauchy with
Expand Down
3 changes: 1 addition & 2 deletions Mathlib/Analysis/SpecialFunctions/Stirling.lean
Expand Up @@ -53,8 +53,7 @@ noncomputable def stirlingSeq (n : ℕ) : ℝ :=

@[simp]
theorem stirlingSeq_zero : stirlingSeq 0 = 0 := by
rw [stirlingSeq, cast_zero, mul_zero, Real.sqrt_zero, zero_mul,
div_zero]
rw [stirlingSeq, cast_zero, mul_zero, Real.sqrt_zero, zero_mul, div_zero]
#align stirling.stirling_seq_zero Stirling.stirlingSeq_zero

@[simp]
Expand Down

0 comments on commit e4bee60

Please sign in to comment.