Use this theorem
Create a project
lake +leanprover/lean4:v4.35.0 new myproject std.toml cd myprojectStandard template, not
math: themathtemplate adds its own Mathlib requirement pinned to the Lean release tag, not to the Mathlib commit this package is built and tested with, so you would get a second, different Mathlib. Mathlib comes in through this package. Skip this step in an existing project with the same Lean and Mathlib.Add the dependency to
lakefile.toml[[require]] name = "formalizations" git = "https://github.com/karlesmarin/formalizations" rev = "v0.15.0"Import the minimal module
import Formalizations.Reusable.GeometryIn a file of the project, e.g.
Example.lean.Paste the example
open Formalizations.Reusable Matrix Real /-- Wolstenholme's inequality, from the defect identity. -/ example (x y z A B C : ℝ) (h : A + B + C = π) : 2 * y * z * Real.cos A + 2 * z * x * Real.cos B + 2 * x * y * Real.cos C ≤ x ^ 2 + y ^ 2 + z ^ 2 := by have := wolstenholme_defect_eq_sq_add_sq x y z A B C h nlinarith [sq_nonneg (x - z * Real.cos B - y * Real.cos C), sq_nonneg (z * Real.sin B - y * Real.sin C)]Steps 3 and 4 together are a complete Lean file:
FormalizationsTest/ReusableGeometryExample.leanat v0.15.0, compiled by the CI.Fetch and check
lake update lake lean Example.leanlake updatefetches this package and Mathlib, and Mathlib's update hook downloads the compiled Mathlib (lake exe cache get).lake lean Example.leanbuilds the imports of the file (steps 3 and 4) and checks it. If the file belongs to alean_libof your project,lake build <lib>does the same. Avoid a barelake buildin a project from the standard template: its default target is the executable, whose link compiles every imported Mathlib module to native code. Same versions required: Leanv4.35.0, Mathlibf0b4c81.
Alternative: import Formalizations.Reusable imports the whole layer (all areas).
If A + B + C = π, then x² + y² + z² − (2yz cos A + 2zx cos B + 2xy cos C) = (x − z cos B − y cos C)² + (z sin B − y sin C)² for all real x, y, z; hence Wolstenholme's inequality.
Lean statement
theorem wolstenholme_defect_eq_sq_add_sq (x y z A B C : ℝ) (h : A + B + C = Real.pi) :
x ^ 2 + y ^ 2 + z ^ 2 - (2 * y * z * Real.cos A + 2 * z * x * Real.cos B
+ 2 * x * y * Real.cos C) =
(x - z * Real.cos B - y * Real.cos C) ^ 2 + (z * Real.sin B - y * Real.sin C) ^ 2Links
Lean docstring
Wolstenholme's inequality, defect form. If A + B + C = π then for all real x, y, z, x² + y² + z² − (2yz cos A + 2zx cos B + 2xy cos C) = (x − z cos B − y cos C)² + (z sin B − y sin C)². In particular 2yz cos A + 2zx cos B + 2xy cos C ≤ x² + y² + z² (Wolstenholme's inequality, archive WolstenholmeInequality.cos_le). No sign condition on the angles is needed.
- Archive:
WolstenholmeInequality.sub_eq_sq_add_sq(Formalizations.Geometry.Euclidean.WolstenholmeInequality); no research paper. - Classical reference: J. Wolstenholme, A Book of Mathematical Problems, Macmillan, 1867.
- Example:
wolstenholme_defect_eq_sq_add_sq 1 1 1 (π/3) (π/3) (π/3) hfor the equilateral triangle, withh : π/3 + π/3 + π/3 = π.
Upstream
an olympiad-style identity with a six-line proof; Mathlib's Archive at most
Depends on, in this repository
None besides the archive module (repo_dependencies = []).