mathlib4 review helperopen PRs by @wwylele on leanprover-community/mathlib4

← queue

#44236 feat(Geometry/Euclidean): prove Feuerbach's theorem

blocked-by-other-PR merge-conflict t-euclidean-geometry file-removed CI success

+682 −71 · 16 files · 13 commits · head 8042bfd · updated 53 days ago · Files changed on GitHub

In plain words

Proves Feuerbach's theorem (Freek list no. 29): the nine-point circle of a triangle is internally tangent to the incircle and externally tangent to each of the three excircles. Following Scheer's vector proof, it computes for the in/excenter , the nine-point center and nine-point radius , using Euler-type distance formula dist_excenter_sq from #44230 together with new formulas for the distance from a vertex to the nine-point center (via a general vertex-to-Euler-line distance formula for -simplices). Registers the result in docs/100.yaml and docs/1000.yaml, adds the reference to references.bib.

Transcriptions are drafted with an LLM from the diff and are a reading aid, not a verified statement: the Lean code is the reference.

PR description
Conversation on GitHub 3
github-actions[bot] · comment · 2026-09-26
PR summary 8042bfda50

<details><summary>

Import changes for modified files

</summary>

Dependency changes

| File | Base Count | Head Count | Change | | --- | --- | --- | --- | | Mathlib.Geometry.Euclidean.Angle.Unoriented.Projection | 2333 | 2355 | +22 (+0.94%) | | Mathlib.Geometry.Euclidean.Triangle | 2409 | 2417 | +8 (+0.33%) |

<details><summary>Import changes for all files</summary>

|Files|Import difference| |-|-| |<details><summary>3 files</summary> Mathlib.Geometry.Euclidean.Angle.Oriented.Projection Mathlib.Geometry.Euclidean.Sphere.Power Mathlib.Geometry.Euclidean.Sphere.Ptolemy</details>|3| | Mathlib.Geometry.Euclidean.Similarity|5| |<details><summary>3 files</summary> Mathlib.Geometry.Euclidean.Angle.Unoriented.TriangleInequality Mathlib.Geometry.Euclidean.Congruence Mathlib.Geometry.Euclidean.Triangle</details>|8| | Mathlib.Geometry.Euclidean.Angle.Unoriented.Projection|22| | Mathlib.Geometry.Euclidean.Volume.Incenter (new file)|2765| | Mathlib.Geometry.Euclidean.Volume.Triangle (new file)|2805| | Mathlib.Geometry.Euclidean.Feuerbach (new file)|2806|

</details>

</details>


<details><summary>

Declarations diff (regex)

</summary>

+ ExcenterExists.volume_eq_exradius_mul + _root_.Collinear.sin_angle_eq_left + _root_.Collinear.sin_angle_eq_right + _root_.EuclideanGeometry.mul_sin_eq_sqrt_mul_sub_mul_sub_mul_sub + dist_affineCombination_const_sq + dist_excenter_circumcenter_sq + dist_excenter_ninePointCircle_center_sq + dist_excenter_singleton_circumcenter_sq + dist_excenter_sq + dist_incenter_circumcenter_sq + dist_lineMap_circumcenter_centroid_sq + dist_orthogonalProjection_eq_sin_mul_dist + dist_orthogonalProjection_eq_sin_mul_dist_of_collinear + excenterExists_iff_sum_excenterWeightsFace_ne_zero + excenterWeightsFace + excenterWeightsFace_empty + excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm + excenterWeightsFace_map + excenterWeightsFace_ne_zero + excenterWeightsFace_reindex + excenterWeightsFace_restrict + excenterWeights_eq_excenterWeightsFace_div + four_mul_volume_mul_circumradius + height_eq_sin_mul_dist + inner_vsub_circumcenter_vsub_circumcenter + inradius_le_ninePointCircle_radius + isExtTangent_exsphere_ninePointCircle + isIntTangent_insphere_ninePointCircle + ninePointCircle_center_eq_lineMap_circumcenter_centroid + ninePointCircle_center_eq_point + ninePointCircle_radius_nonneg + sum_excenterWeightsFace_pos + sum_excenterWeightsFace_singleton_pos + two_mul_inradius_le_circumradius + volume_eq_height_mul + volume_eq_inradius_mul + volume_eq_mul_div_circumradius + volume_eq_mul_sin + volume_eq_sqrt_mul_sub_mul_sub_mul_sub + volume_sq_eq_mul_sub_mul_sub_mul_sub + vsub_centroid_eq ++ dist_ninePointCircle_center_sq - heron <details> <summary>You can run this locally as follows</summary>

## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

</details>

The doc-module for scripts/pr_summary/declarations_diff.sh in the undefined repository contains some details about this script.

</details>

<details><summary>

Declarations diff (Lean)

</summary>

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 8042bfd).

  • +43 new declarations
  • −0 removed declarations
+Affine.Simplex.ExcenterExists.volume_eq_exradius_mul
+Affine.Simplex.dist_lineMap_circumcenter_centroid_sq
+Affine.Simplex.dist_ninePointCircle_center_sq
+Affine.Simplex.excenterExists_iff_sum_excenterWeightsFace_ne_zero
+Affine.Simplex.excenterWeightsFace
+Affine.Simplex.excenterWeightsFace.congr_simp
+Affine.Simplex.excenterWeightsFace_empty
+Affine.Simplex.excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm
+Affine.Simplex.excenterWeightsFace_map
+Affine.Simplex.excenterWeightsFace_ne_zero
+Affine.Simplex.excenterWeightsFace_reindex
+Affine.Simplex.excenterWeightsFace_restrict
+Affine.Simplex.excenterWeights_eq_excenterWeightsFace_div
+Affine.Simplex.inner_vsub_circumcenter_vsub_circumcenter
+Affine.Simplex.ninePointCircle_center_eq_lineMap_circumcenter_centroid
+Affine.Simplex.ninePointCircle_center_eq_point
+Affine.Simplex.ninePointCircle_radius_nonneg
+Affine.Simplex.sum_excenterWeightsFace_singleton_pos
+Affine.Simplex.volume_eq_inradius_mul
+Affine.Simplex.vsub_centroid_eq
+Affine.Triangle.dist_excenter_circumcenter_sq
+Affine.Triangle.dist_excenter_singleton_circumcenter_sq
+Affine.Triangle.dist_excenter_sq
+Affine.Triangle.dist_incenter_circumcenter_sq
+Affine.Triangle.dist_ninePointCircle_center_sq
+Affine.Triangle.four_mul_volume_mul_circumradius
+Affine.Triangle.height_eq_sin_mul_dist
+Affine.Triangle.inradius_le_ninePointCircle_radius
+Affine.Triangle.isExtTangent_exsphere_ninePointCircle
+Affine.Triangle.isIntTangent_insphere_ninePointCircle
+Affine.Triangle.sum_excenterWeightsFace_pos
+Affine.Triangle.two_mul_inradius_le_circumradius
+Affine.Triangle.volume_eq_height_mul
+Affine.Triangle.volume_eq_mul_div_circumradius
+Affine.Triangle.volume_eq_mul_sin
+Affine.Triangle.volume_eq_sqrt_mul_sub_mul_sub_mul_sub
+Affine.Triangle.volume_sq_eq_mul_sub_mul_sub_mul_sub
+Collinear.sin_angle_eq_left
+Collinear.sin_angle_eq_right
+EuclideanGeometry.dist_affineCombination_const_sq
+EuclideanGeometry.dist_orthogonalProjection_eq_sin_mul_dist
+EuclideanGeometry.dist_orthogonalProjection_eq_sin_mul_dist_of_collinear
+EuclideanGeometry.mul_sin_eq_sqrt_mul_sub_mul_sub_mul_sub

</details>


No changes to strong technical debt. <details><summary>Increase in weak tech debt: (relative, absolute) = (1.00, 0.00)</summary>

|Current number|Change|Type (weak)| |-:|:-:|:-| |5067|1|exposed public sections| </details>

Current commit 8042bfda50 Reference commit 0f8a641e2e

This script lives in the undefined repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

note: file Archive/Wiedijk100Theorems/HeronsFormula.lean was removed. Please create a follow-up pull request adding a module deprecation. Thanks!

mathlib-dependent-issues[bot] · comment · 2026-09-26

This PR/issue depends on:

  • leanprover-community/mathlib4#44230
  • ~~leanprover-community/mathlib4#44218~~

By Dependent Issues (🤖). Happy coding!

mathlib-merge-conflicts[bot] · comment · 2026-09-28

This pull request has conflicts, please merge master and resolve them.

Archive.lean +0 −1

public import Archive.Wiedijk100Theorems.BirthdayProblem
80public import Archive.Wiedijk100Theorems.BuffonsNeedle
81public import Archive.Wiedijk100Theorems.CubingACube
82public import Archive.Wiedijk100Theorems.FriendshipGraphs
−public import Archive.Wiedijk100Theorems.HeronsFormula
83public import Archive.Wiedijk100Theorems.InverseTriangleSum
84public import Archive.Wiedijk100Theorems.Konigsberg
85public import Archive.Wiedijk100Theorems.PerfectNumbers

Archive/Wiedijk100Theorems/HeronsFormula.lean +0 −68

−/-
−Copyright (c) 2021 Matt Kempster. All rights reserved.
−Released under Apache 2.0 license as described in the file LICENSE.
−Authors: Matt Kempster
−-/
−module
−
−public import Mathlib.Geometry.Euclidean.Triangle
−
−/-!
−# Freek № 57: Heron's Formula
−
−This file proves Theorem 57 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/),
−also known as Heron's formula, which gives the area of a triangle based only on its three sides'
−lengths.
−
−## References
−
−* https://en.wikipedia.org/wiki/Herons_formula
−
−-/
−
−open Real EuclideanGeometry
−
−namespace Theorems100
−
−variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
− [NormedAddTorsor V P]
−
theorem heron removedLundefined–undefined
−/-- **Heron's formula**: The area of a triangle with side lengths `a`, `b`, and `c` is
− `√(s * (s - a) * (s - b) * (s - c))` where `s = (a + b + c) / 2` is the semiperimeter.
− We show this by equating this formula to `a * b * sin γ`, where `γ` is the angle opposite
− the side `c`.
−-/
−public theorem heron {p₁ p₂ p₃ : P} (h1 : p₁ ≠ p₂) (h2 : p₃ ≠ p₂) :
− let a := dist p₁ p₂
− let b := dist p₃ p₂
− let c := dist p₁ p₃
− let s := (a + b + c) / 2
− 1 / 2 * a * b * sin (∠ p₁ p₂ p₃) = √(s * (s - a) * (s - b) * (s - c)) := by
− intro a b c s
− let γ := ∠ p₁ p₂ p₃
− obtain := (dist_pos.mpr h1).ne', (dist_pos.mpr h2).ne'
− have cos_rule : cos γ = (a * a + b * b - c * c) / (2 * a * b) := by
− simp [field, a, b, c, γ, mul_comm,
− dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle p₁ p₂ p₃]
− let numerator := (2 * a * b) ^ 2 - (a * a + b * b - c * c) ^ 2
− let denominator := (2 * a * b) ^ 2
− have split_to_frac : ↑1 - cos γ ^ 2 = numerator / denominator := by
− simp [field, numerator, denominator, cos_rule]
− have numerator_nonneg : 0 ≤ numerator := by
− have frac_nonneg : 0 ≤ numerator / denominator :=
− (sub_nonneg.mpr (cos_sq_le_one γ)).trans_eq split_to_frac
− rcases div_nonneg_iff.mp frac_nonneg with h | h
− · exact h.left
− · simpa [numerator, denominator, a, b, c, h1, h2] using le_antisymm h.right (sq_nonneg _)
− have ab2_nonneg : 0 ≤ 2 * a * b := by positivity
− calc
− 1 / 2 * a * b * sin γ = 1 / 2 * a * b * (√numerator / √denominator) := by
− rw [sin_eq_sqrt_one_sub_cos_sq, split_to_frac, sqrt_div numerator_nonneg] <;>
− simp [γ, angle_nonneg, angle_le_pi]
− _ = 1 / 4 * √((2 * a * b) ^ 2 - (a * a + b * b - c * c) ^ 2) := by
− simp (disch := positivity) [field, numerator, denominator, -mul_eq_mul_left_iff]; ring
− _ = ↑1 / ↑4 * √(s * (s - a) * (s - b) * (s - c) * ↑4 ^ 2) := by simp only [s]; ring_nf
− _ = √(s * (s - a) * (s - b) * (s - c)) := by
− rw [sqrt_mul', sqrt_sq, div_mul_eq_mul_div, one_mul, mul_div_cancel_right₀] <;> norm_num
−end Theorems100

Mathlib.lean +3 −0

public import Mathlib.Geometry.Euclidean.Basic
4768public import Mathlib.Geometry.Euclidean.BritishFlag
4769public import Mathlib.Geometry.Euclidean.Circumcenter
4770public import Mathlib.Geometry.Euclidean.Congruence
4771public import Mathlib.Geometry.Euclidean.Feuerbach
4772public import Mathlib.Geometry.Euclidean.Incenter
4773public import Mathlib.Geometry.Euclidean.Inversion.Basic
4774public import Mathlib.Geometry.Euclidean.Inversion.Calculus
public import Mathlib.Geometry.Euclidean.Sphere.Tangent
4790public import Mathlib.Geometry.Euclidean.Triangle
4791public import Mathlib.Geometry.Euclidean.Volume.Basic
4792public import Mathlib.Geometry.Euclidean.Volume.Def
4793public import Mathlib.Geometry.Euclidean.Volume.Incenter
4794public import Mathlib.Geometry.Euclidean.Volume.Measure
4795public import Mathlib.Geometry.Euclidean.Volume.MeasureSimplex
4796public import Mathlib.Geometry.Euclidean.Volume.Triangle
4797public import Mathlib.Geometry.Group.Growth.LinearLowerBound
4798public import Mathlib.Geometry.Group.Growth.QuotientInter
4799public import Mathlib.Geometry.Group.WordMetric

Mathlib/Geometry/Euclidean/Angle/Unoriented/Affine.lean +15 −0

theorem collinear_of_sin_eq_zero {p₁ p₂ p₃ : P} (h : Real.sin (∠ p₁ p
525 contrapose
526 exact sin_ne_zero_of_not_collinear
theorem _root_.Collinear.sin_angle_eq_right newL528–537
528/-- When `q`, `r` and `s` are collinear, `∠ p r q` and `∠ p r s` are either equal or complementary,
529so their `Real.sin` are equal. -/
530theorem _root_.Collinear.sin_angle_eq_right (p : P) {q r s : P} (h : Collinear ℝ {q, r, s})
531 (hqr : q ≠ r) (hrs : r ≠ s) : Real.sin (∠ p r q) = Real.sin (∠ p r s) := by
532 rcases h.wbtw_or_wbtw_or_wbtw with h | h | h
533 · suffices ∠ p r q = π - ∠ p r s by rw [this, Real.sin_pi_sub]
534 rw [eq_sub_iff_add_eq, angle_add_angle_eq_pi_of_angle_eq_pi]
535 exact Sbtw.angle₁₂₃_eq_pi ⟨h, hqr.symm, hrs⟩
536 · rw [h.angle_eq_right p hrs.symm]
537 · rw [h.symm.angle_eq_right p hqr]
theorem _root_.Collinear.sin_angle_eq_left newL539–541
539theorem _root_.Collinear.sin_angle_eq_left (p : P) {q r s : P} (h : Collinear ℝ {q, r, s})
540 (hqr : q ≠ r) (hrs : r ≠ s) : Real.sin (∠ q r p) = Real.sin (∠ s r p) := by
541 rw [angle_comm q r p, angle_comm s r p, h.sin_angle_eq_right p hqr hrs]
543end EuclideanGeometry

Mathlib/Geometry/Euclidean/Angle/Unoriented/Projection.lean +20 −0

module
8public import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
9public import Mathlib.Geometry.Euclidean.Projection
11import Mathlib.Geometry.Euclidean.Angle.Unoriented.RightAngle
13/-!
14# Angles and orthogonal projection.
open scoped Real
43 ∠ p' (orthogonalProjection s p) p = π / 2 := by
44 rw [angle_comm, angle_self_orthogonalProjection p h]
theorem dist_orthogonalProjection_eq_sin_mul_dist newL46–51
46theorem dist_orthogonalProjection_eq_sin_mul_dist (p : P) {q : P} {s : AffineSubspace ℝ P}
47 [s.direction.HasOrthogonalProjection] (h : q ∈ s) :
48 haveI : Nonempty s := ⟨q, h⟩
49 dist p (orthogonalProjection s p) =
50 Real.sin (∠ p q (orthogonalProjection s p).val) * dist p q := by
51 rw [angle_comm, sin_angle_mul_dist_of_angle_eq_pi_div_two <| angle_self_orthogonalProjection p h]
theorem dist_orthogonalProjection_eq_sin_mul_dist_of_collinear newL53–62
53theorem dist_orthogonalProjection_eq_sin_mul_dist_of_collinear (p : P) {q r : P}
54 {s : AffineSubspace ℝ P} [s.direction.HasOrthogonalProjection] (hq : q ∈ s) (hr : r ∈ s)
55 (hcollinear : haveI : Nonempty s := ⟨q, hq⟩; Collinear ℝ {(orthogonalProjection s p).val, q, r})
56 (hqr : q ≠ r) :
57 haveI : Nonempty s := ⟨q, hq⟩
58 dist p (orthogonalProjection s p) = Real.sin (∠ p q r) * dist p q := by
59 have : Nonempty s := ⟨q, hq⟩
60 by_cases! hpq : orthogonalProjection s p = q
61 · simp [← hpq, angle_self_orthogonalProjection p hr]
62 rw [dist_orthogonalProjection_eq_sin_mul_dist p hq, hcollinear.sin_angle_eq_right p hpq hqr]
64end EuclideanGeometry

Mathlib/Geometry/Euclidean/Basic.lean +30 −0

theorem dist_affineCombination {ι : Type*} {s : Finset ι} {w₁ w₂ : ι →
86 simp_rw [Pi.sub_apply, Finset.sum_sub_distrib, h₁, h₂, sub_self]
87 exact inner_weightedVSub p h p h
theorem dist_affineCombination_const_sq changedL89–121
89/-- The squared distance from an `affineCombination` to a constant point. -/
90theorem dist_affineCombination_const_sq {ι : Type*} {s : Finset ι} {w : ι → ℝ} (p : ι → P)
91 (q : P) (h : ∑ i ∈ s, w i = 1) :
92 dist (s.affineCombination ℝ p w) q ^ 2 =
93 ∑ i ∈ s, w i * dist (p i) q ^ 2 -
94 (∑ i ∈ s, ∑ j ∈ s, w i * w j * dist (p i) (p j) ^ 2) / 2 := calc
95 _ = ‖s.affineCombination ℝ p w -ᵥ q‖ ^ 2 := by rw [dist_eq_norm_vsub]
96 _ = ‖∑ i ∈ s, w i • (p i -ᵥ q)‖ ^ 2 := by
97 rw [Finset.sum_smul_vsub_const_eq_affineCombination_vsub _ _ _ _ h]
98 _ = ⟪∑ i ∈ s, w i • (p i -ᵥ q), ∑ i ∈ s, w i • (p i -ᵥ q)⟫ := by
99 rw [real_inner_self_eq_norm_sq]
100 _ = ∑ i ∈ s, ∑ j ∈ s, w i * w j * ⟪p i -ᵥ q, p j -ᵥ q⟫ := by
101 simp_rw [sum_inner, inner_sum, real_inner_smul_left, real_inner_smul_right, ← mul_assoc]
102 _ = ∑ i ∈ s, ∑ j ∈ s, w i * w j *
103 ((dist (p i) q ^ 2 + dist (p j) q ^ 2 - dist (p i) (p j) ^ 2) / 2) := by
104 simp_rw [real_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two,
105 dist_eq_norm_vsub, sq, vsub_sub_vsub_cancel_right]
106 _ = (∑ i ∈ s, ∑ j ∈ s, w i * w j * dist (p i) q ^ 2) / 2 +
107 (∑ i ∈ s, ∑ j ∈ s, w i * w j * dist (p j) q ^ 2) / 2 -
108 (∑ i ∈ s, ∑ j ∈ s, w i * w j * dist (p i) (p j) ^ 2) / 2 := by
109 simp_rw [← mul_div_assoc, ← Finset.sum_div, mul_sub, mul_add, Finset.sum_sub_distrib,
110 Finset.sum_add_distrib, sub_div, add_div]
111 _ = (∑ i ∈ s, w i * dist (p i) q ^ 2) / 2 +
112 (∑ j ∈ s, w j * dist (p j) q ^ 2) / 2 -
113 (∑ i ∈ s, ∑ j ∈ s, w i * w j * dist (p i) (p j) ^ 2) / 2 := by
114 congrm ?_ / 2 + ?_ / 2 - _
115 · simp_rw [mul_right_comm _ _ (_ ^ 2), ← Finset.mul_sum, h, mul_one]
116 · simp_rw [mul_assoc, ← Finset.mul_sum, ← Finset.sum_mul, h, one_mul]
117 _ = _ := by ring
119/-- The squared distance between points on a line (expressed as a
120multiple of a fixed vector added to a point) and another point,
121expressed as a quadratic. -/

Mathlib/Geometry/Euclidean/Circumcenter.lean +65 −0

theorem reflection_circumcenter_eq_affineCombination_of_pointsWithCircumcenter {
608 convert! sum_const_zero
609 norm_num
theorem inner_vsub_circumcenter_vsub_circumcenter newL611–616
611theorem inner_vsub_circumcenter_vsub_circumcenter {n : ℕ} (s : Simplex ℝ P n) (i j : Fin (n + 1)) :
612 ⟪s.points i -ᵥ s.circumcenter, s.points j -ᵥ s.circumcenter⟫ =
613 s.circumradius ^ 2 - dist (s.points i) (s.points j) ^ 2 / 2 := by
614 rw [real_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two]
615 simp_rw [vsub_sub_vsub_cancel_right, ← sq, ← dist_eq_norm_vsub, dist_circumcenter_eq_circumradius]
616 ring
theorem dist_lineMap_circumcenter_centroid_sq newL618–674
618/-- This calculates the distance from a vertex to an arbitrary point on the Euler line in terms of
619circumradius and edge lengths. -/
620theorem dist_lineMap_circumcenter_centroid_sq {n : ℕ} (s : Simplex ℝ P n) (i : Fin (n + 1))
621 (x : ℝ) :
622 dist (s.points i) (AffineMap.lineMap s.circumcenter s.centroid x) ^ 2 =
623 (1 - x) ^ 2 * s.circumradius ^ 2 +
624 (1 - x / (n + 1)) * (x / (n + 1)) * ∑ j ∈ {i}ᶜ, dist (s.points i) (s.points j) ^ 2 -
625 (x / (n + 1)) ^ 2 / 2 * ∑ j ∈ {i}ᶜ, ∑ k ∈ {i}ᶜ, dist (s.points j) (s.points k) ^ 2 := calc
626 _ = ‖s.points i -ᵥ AffineMap.lineMap s.circumcenter s.centroid x‖ ^ 2 := by
627 rw [dist_eq_norm_vsub]
628 _ = ‖(1 - x) • (s.points i -ᵥ s.circumcenter) + x • (s.points i -ᵥ s.centroid)‖ ^ 2 := by
629 rw [AffineMap.vsub_lineMap, AffineMap.lineMap_apply_module]
630 _ = ‖(1 - x) • (s.points i -ᵥ s.circumcenter) +
631 (x / (n + 1)) • ∑ j ∈ {i}ᶜ, (s.points i -ᵥ s.points j)‖ ^ 2 := by
632 rw [vsub_centroid_eq, smul_smul, ← sum_eq_of_subset (subset_univ {i}ᶜ) _ (by simp),
633 ← div_eq_mul_inv]
634 _ = ‖(1 - x) • (s.points i -ᵥ s.circumcenter) +
635 (x / (n + 1)) •
636 ∑ j ∈ {i}ᶜ, ((s.points i -ᵥ s.circumcenter) - (s.points j -ᵥ s.circumcenter))‖ ^ 2 := by
637 simp
638 _ = ‖(1 - x + x / (n + 1) * n) • (s.points i -ᵥ s.circumcenter) -
639 (x / (n + 1)) • ∑ j ∈ {i}ᶜ, (s.points j -ᵥ s.circumcenter)‖ ^ 2 := by
640 congrm ‖?_‖ ^ 2
641 rw [sum_sub_distrib, sum_const, card_compl, Fintype.card_fin, card_singleton,
642 add_tsub_cancel_right]
643 module
644 _ = ‖(1 - x / (n + 1)) • (s.points i -ᵥ s.circumcenter) -
645 (x / (n + 1)) • ∑ j ∈ {i}ᶜ, (s.points j -ᵥ s.circumcenter)‖ ^ 2 :=
646 congr(‖$(by field) • _ - _‖ ^ 2)
647 _ = ‖(1 - x / (n + 1)) • (s.points i -ᵥ s.circumcenter)‖ ^ 2 -
648 2 * ⟪((1 - x / (n + 1)) • (s.points i -ᵥ s.circumcenter)),
649 (x / (n + 1)) • ∑ j ∈ {i}ᶜ, (s.points j -ᵥ s.circumcenter)⟫ +
650 ‖(x / (n + 1)) • ∑ j ∈ {i}ᶜ, (s.points j -ᵥ s.circumcenter)‖ ^ 2 := by
651 rw [norm_sub_sq_real]
652 _ = (1 - x / (n + 1)) ^ 2 * s.circumradius ^ 2 -
653 2 * (1 - x / (n + 1)) * (x / (n + 1)) *
654 ∑ j ∈ {i}ᶜ, ⟪s.points i -ᵥ s.circumcenter, s.points j -ᵥ s.circumcenter⟫ +
655 (x / (n + 1)) ^ 2 * ∑ j ∈ {i}ᶜ, ∑ k ∈ {i}ᶜ, ⟪s.points j -ᵥ s.circumcenter,
656 s.points k -ᵥ s.circumcenter⟫ := by
657 congrm ?_ - ?_ + ?_
658 · rw [norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, ← dist_eq_norm_vsub,
659 dist_circumcenter_eq_circumradius]
660 · rw [real_inner_smul_left, real_inner_smul_right, inner_sum]
661 ring
662 · rw [norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, ← real_inner_self_eq_norm_sq, sum_inner]
663 simp_rw [inner_sum]
664 _ = (1 - x / (n + 1)) ^ 2 * s.circumradius ^ 2 -
665 2 * (1 - x / (n + 1)) * (x / (n + 1)) *
666 ∑ j ∈ {i}ᶜ, (s.circumradius ^ 2 - dist (s.points i) (s.points j) ^ 2 / 2) +
667 (x / (n + 1)) ^ 2 * ∑ j ∈ {i}ᶜ, ∑ k ∈ {i}ᶜ,
668 (s.circumradius ^ 2 - dist (s.points j) (s.points k) ^ 2 / 2) := by
669 simp_rw [inner_vsub_circumcenter_vsub_circumcenter]
670 _ = _ := by
671 simp_rw [sum_sub_distrib, sum_const, card_compl, Fintype.card_fin, card_singleton,
672 add_tsub_cancel_right, ← sum_div, nsmul_eq_mul]
673 rw [← sub_eq_zero]
674 field
676end Simplex
678end Affine

Mathlib/Geometry/Euclidean/Feuerbach.lean +130 −0 new file

1/-
2Copyright (c) 2026 Weiyi Wang. All rights reserved.
3Released under Apache 2.0 license as described in the file LICENSE.
4Authors: Weiyi Wang
5-/
6module
7
8public import Mathlib.Geometry.Euclidean.NinePointCircle
9public import Mathlib.Geometry.Euclidean.Incenter
11import Mathlib.Geometry.Euclidean.Volume.Basic
12import Mathlib.Geometry.Euclidean.Volume.Triangle
14/-!
16# Feuerbach's Theorem
18This file proves Feuerbach's Theorem: the nine-point circle of a triangle is tangent to the incircle
19and all three excircles.
21## Reference
22* Michael Scheer,
23 [**A Simple Vector Proof of Feuerbach's Theorem**][scheer2011simplevectorprooffeuerbachs]
25-/
27public section
29namespace Affine.Triangle
31open Simplex EuclideanGeometry Real
33variable {V P : Type*}
34variable [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P]
35variable (t : Triangle ℝ P)
37local notation "w" => excenterWeightsFace
theorem dist_excenter_ninePointCircle_center_sq newL39–102
39private theorem dist_excenter_ninePointCircle_center_sq {signs : Finset (Fin 3)}
40 (hsigns : signs = ∅ ∨ signs = {0} ∨ signs = {1} ∨ signs = {2}) :
41 dist (t.excenter signs) t.ninePointCircle.center ^ 2 =
42 (t.exradius signs + (if signs = ∅ then -1 else 1) * t.ninePointCircle.radius) ^ 2 := by
43 have huniv : (Finset.univ : Finset (Fin 3)) = {0, 1, 2} := by grind
44 have h0 := t.sum_excenterWeightsFace_pos hsigns
45 set p0 := t.points 0
46 set p1 := t.points 1
47 set p2 := t.points 2
48 calc
49 _ = (∑ i, w t signs i * dist (t.points i) (ninePointCircle t).center ^ 2) / ∑ i, w t signs i +
50 (if signs = ∅ then -1 else 1) * 2 * t.circumradius * t.exradius signs := by
51 simp_rw [t.dist_excenter_sq _ hsigns, t.excenterWeights_eq_excenterWeightsFace_div,
52 ← mul_div_right_comm, ← Finset.sum_div]
53 _ = (w t signs 0 * dist p0 (ninePointCircle t).center ^ 2 +
54 w t signs 1 * dist p1 (ninePointCircle t).center ^ 2 +
55 w t signs 2 * dist p2 (ninePointCircle t).center ^ 2) / ∑ i, w t signs i +
56 (if signs = ∅ then -1 else 1) * 2 * t.circumradius * t.exradius signs := by
57 congrm ?_ / _ + _
58 simp [huniv]
59 ring
60 _ = ((∑ i, w t signs i) * t.circumradius ^ 2 / 4 +
61 (w t signs 0 * (dist p0 p1 ^ 2 + dist p0 p2 ^ 2 - dist p1 p2 ^ 2) +
62 w t signs 1 * (dist p0 p1 ^ 2 + dist p1 p2 ^ 2 - dist p0 p2 ^ 2) +
63 w t signs 2 * (dist p1 p2 ^ 2 + dist p0 p2 ^ 2 - dist p0 p1 ^ 2)) / 4) /
64 ∑ i, w t signs i +
65 (if signs = ∅ then -1 else 1) * 2 * t.circumradius * t.exradius signs := by
66 congrm ?_ / _ + _
67 rw [t.dist_ninePointCircle_center_sq (i₂ := 1) (i₃ := 2) (by simp) (by simp) (by simp)]
68 rw [t.dist_ninePointCircle_center_sq (i₂ := 0) (i₃ := 2) (by simp) (by simp) (by simp)]
69 rw [t.dist_ninePointCircle_center_sq (i₂ := 0) (i₃ := 1) (by simp) (by simp) (by simp)]
70 rw [dist_comm p2 p1, dist_comm p1 p0, dist_comm p2 p0]
71 simp [huniv]
72 ring
73 _ = ((∑ i, w t signs i) * t.circumradius ^ 2 / 4 +
74 ((dist p0 p1 + dist p0 p2 + dist p1 p2) * (-dist p0 p1 + dist p0 p2 + dist p1 p2) *
75 (dist p0 p1 - dist p0 p2 + dist p1 p2) * (dist p0 p1 + dist p0 p2 - dist p1 p2) /
76 ∑ i, w t signs i -
77 (if signs = ∅ then -1 else 1) * 2 * (dist p0 p1 * dist p0 p2 * dist p1 p2)) / 4) /
78 ∑ i, w t signs i +
79 (if signs = ∅ then -1 else 1) * 2 * t.circumradius * t.exradius signs := by
80 congrm (_ + ?_ / 4) / _ + _
81 field_simp
82 rcases hsigns with rfl | rfl | rfl | rfl
83 all_goals
84 · simp [huniv, excenterWeightsFace, faceOpposite_point_eq_point_succAbove, Fin.succAbove]
85 ring
86 _ = ((∑ i, w t signs i) * t.circumradius ^ 2 / 4 +
87 (16 * t.volume ^ 2 / ∑ i, w t signs i -
88 (if signs = ∅ then -1 else 1) * 2 * (dist p0 p1 * dist p0 p2 * dist p1 p2)) / 4) /
89 ∑ i, w t signs i +
90 (if signs = ∅ then -1 else 1) * 2 * t.circumradius * t.exradius signs := by
91 congrm (_ + (?_ / _ - _) / 4) / _ + _
92 rw [t.volume_sq_eq_mul_sub_mul_sub_mul_sub (i₁ := 0) (i₂ := 1) (i₃ := 2)
93 (by simp) (by simp) (by simp)]
94 ring
95 _ = t.circumradius ^ 2 / 4 + t.exradius signs ^ 2 +
96 (if signs = ∅ then -1 else 1) * t.circumradius * t.exradius signs := by
97 rw [← t.four_mul_volume_mul_circumradius (by simp) (by simp) (by simp)]
98 rw [(t.excenterExists signs).volume_eq_exradius_mul, abs_of_nonneg h0.le]
99 field
100 _ = _ := by
101 rw [t.ninePointCircle_radius]
102 by_cases h : signs = ∅ <;> simp [h] <;> ring
theorem isExtTangent_exsphere_ninePointCircle newL104–114
104/--
105**Feuerbach's Theorem** for excircles
106-/
107theorem isExtTangent_exsphere_ninePointCircle (i : Fin 3) :
108 (t.exsphere {i}).IsExtTangent t.ninePointCircle := by
109 rw [Sphere.isExtTangent_iff_dist_center]
110 refine ⟨?_, t.exradius_nonneg {i}, t.ninePointCircle_radius_nonneg⟩
111 rw [← sq_eq_sq₀ (by simp)
112 (by exact add_nonneg (t.exradius_nonneg {i}) t.ninePointCircle_radius_nonneg)]
113 rw [← excenter, t.dist_excenter_ninePointCircle_center_sq (by grind)]
114 simp
theorem isIntTangent_insphere_ninePointCircle newL116–128
116/--
117**Feuerbach's Theorem** for incircle
118-/
119theorem isIntTangent_insphere_ninePointCircle :
120 t.insphere.IsIntTangent t.ninePointCircle := by
121 have : Nontrivial V :=
122 ⟨t.points 2 -ᵥ t.points 0, t.points 1 -ᵥ t.points 0, by simp [t.independent.injective.ne]⟩
123 rw [Sphere.isIntTangent_iff_dist_center]
124 refine ⟨?_, t.exradius_nonneg ∅, t.ninePointCircle_radius_nonneg⟩
125 rw [← sq_eq_sq₀ (by simp) (by simpa using t.inradius_le_ninePointCircle_radius)]
126 rw [← t.exsphere_empty, ← excenter, t.dist_excenter_ninePointCircle_center_sq (by grind)]
127 simp
128 ring
130end Affine.Triangle

Mathlib/Geometry/Euclidean/NinePointCircle.lean +39 −0

def ninePointCircle {n : ℕ} (s : Simplex ℝ P n) : Sphere P where
56theorem ninePointCircle_center {n : ℕ} (s : Simplex ℝ P n) : s.ninePointCircle.center =
57 ((n + 1) / n : ℝ) • (s.centroid -ᵥ s.circumcenter) +ᵥ s.circumcenter := rfl
theorem ninePointCircle_center_eq_lineMap_circumcenter_centroid newL59–61
59theorem ninePointCircle_center_eq_lineMap_circumcenter_centroid {n : ℕ} (s : Simplex ℝ P n) :
60 s.ninePointCircle.center = AffineMap.lineMap s.circumcenter s.centroid ((n + 1) / n : ℝ) := by
61 rw [ninePointCircle_center, AffineMap.lineMap_apply]
theorem ninePointCircle_center_eq_point newL63–65
63theorem ninePointCircle_center_eq_point (s : Simplex ℝ P 0) (i : Fin 1) :
64 s.ninePointCircle.center = s.points i := by
65 simp [ninePointCircle_center_eq_lineMap_circumcenter_centroid, s.circumcenter_eq_point i]
67theorem ninePointCircle_center_mem_affineSpan {n : ℕ} (s : Simplex ℝ P n) :
68 s.ninePointCircle.center ∈ affineSpan ℝ (Set.range s.points) := by
69 rw [ninePointCircle_center]
theorem ninePointCircle_center_mem_affineSpan {n : ℕ} (s : Simplex ℝ P n) :
74theorem ninePointCircle_radius {n : ℕ} (s : Simplex ℝ P n) :
75 s.ninePointCircle.radius = s.circumradius / (n : ℝ) := rfl
theorem ninePointCircle_radius_nonneg newL77–80
77theorem ninePointCircle_radius_nonneg {n : ℕ} (s : Simplex ℝ P n) :
78 0 ≤ s.ninePointCircle.radius := by
79 rw [s.ninePointCircle_radius]
80 exact div_nonneg s.circumradius_nonneg (by simp)
82@[simp]
83theorem ninePointCircle_reindex {m n : ℕ} (s : Simplex ℝ P n) (e : Fin (n + 1) ≃ Fin (m + 1)) :
84 (s.reindex e).ninePointCircle = s.ninePointCircle := by
theorem ninePointCircle_eq_circumsphere_medial {n : ℕ} [NeZero n] (s : Simplex
126 · rw [Set.range_subset_iff]
127 simpa [medial_points] using s.faceOppositeCentroid_mem_ninePointCircle
theorem dist_ninePointCircle_center_sq changedL129–143
129theorem dist_ninePointCircle_center_sq {n : ℕ} (s : Simplex ℝ P n) (i : Fin (n + 1)) :
130 dist (s.points i) s.ninePointCircle.center ^ 2 =
131 (s.circumradius ^ 2 +
132 (n - 1) * ∑ j ∈ {i}ᶜ, dist (s.points i) (s.points j) ^ 2 -
133 (∑ j ∈ {i}ᶜ, ∑ k ∈ {i}ᶜ, dist (s.points j) (s.points k) ^ 2) / 2) / n ^ 2 := by
134 by_cases hn : n = 0
135 · rcases hn with rfl
136 simp [s.ninePointCircle_center_eq_point i]
137 rw [ninePointCircle_center_eq_lineMap_circumcenter_centroid,
138 dist_lineMap_circumcenter_centroid_sq]
139 field
141/-- Euler points are a set of points that the `ninePointCircle` passes through. They are defined as
142being $1/n$th of the way from the Monge point to a vertex. Specifically for triangles, these are
143the midpoints between the orthocenter and a given vertex
theorem altitudeFoot_mem_ninePointCircle (s : Triangle ℝ P) (i : Fin 3) :
246 refine Set.mem_of_mem_of_subset ?_ (s.vectorSpan_isOrtho_altitude_direction i).ge
247 exact vsub_mem_direction (s.mem_altitude i) (s.orthocenter_mem_altitude)
theorem dist_ninePointCircle_center_sq newL249–261
249/-- In triangle $ABC$ with side length $a$, $b$, and $c$, nine-point circle center $N$ and
250circumradius $R$, we have $‖AN‖^2 = (R^2 + b^2 + c^2 - a^2) / 4$. -/
251theorem dist_ninePointCircle_center_sq (s : Triangle ℝ P) {i₁ i₂ i₃ : Fin 3}
252 (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) :
253 dist (s.points i₁) s.ninePointCircle.center ^ 2 =
254 (s.circumradius ^ 2 + dist (s.points i₁) (s.points i₂) ^ 2 +
255 dist (s.points i₁) (s.points i₃) ^ 2 - dist (s.points i₂) (s.points i₃) ^ 2) / 4 := by
256 have : ({i₁}ᶜ : Finset (Fin 3)) = {i₂, i₃} := by
257 ext i
258 fin_cases i <;> simp <;> grind
259 simp [Simplex.dist_ninePointCircle_center_sq, this, Finset.sum_pair h₂₃,
260 dist_comm (s.points i₃) (s.points i₂)]
261 ring
263end Affine.Triangle
265end

Mathlib/Geometry/Euclidean/Triangle.lean +24 −0

Authors: Joseph Myers, Manuel Candales
6module
7
8public import Mathlib.Analysis.Normed.Affine.AddTorsor
9public import Mathlib.Geometry.Euclidean.Altitude
10public import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine
11public import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
12public import Mathlib.Tactic.IntervalCases
14import Mathlib.Geometry.Euclidean.Angle.Unoriented.Projection
16/-!
17# Triangles
lemma angle_lt_pi_div_three_of_le_of_le_of_ne {p₁ p₂ p₃ : P} (h₂₃₁ :
537 linarith [angle_add_angle_add_angle_eq_pi p₃ h]
539end EuclideanGeometry
541namespace Affine.Triangle
542open Simplex EuclideanGeometry
544variable {V P : Type*}
545variable [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P]
546variable (t : Triangle ℝ P) {i₁ i₂ i₃ : Fin 3}
theorem height_eq_sin_mul_dist newL548–558
548/-- The height of a triangle is equal to the sine of a side angle times the same side. -/
549theorem height_eq_sin_mul_dist (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) :
550 t.height i₁ = Real.sin (∠ (t.points i₁) (t.points i₂) (t.points i₃)) *
551 dist (t.points i₁) (t.points i₂) := by
552 refine dist_orthogonalProjection_eq_sin_mul_dist_of_collinear (t.points i₁) ?_ ?_ ?_ ?_
553 · simp [h₁₂.symm]
554 · simp [h₁₃.symm]
555 · apply collinear_insert_of_mem_affineSpan_pair
556 convert! t.altitudeFoot_mem_affineSpan_image_compl i₁
557 grind
558 · exact t.independent.injective.ne h₂₃
560end Affine.Triangle

Mathlib/Geometry/Euclidean/Volume/Incenter.lean +116 −0 new file

1/-
2Copyright (c) 2026 Weiyi Wang. All rights reserved.
3Released under Apache 2.0 license as described in the file LICENSE.
4Authors: Weiyi Wang
5-/
6module
7
8public import Mathlib.Geometry.Euclidean.Volume.Def
9public import Mathlib.Geometry.Euclidean.Incenter
11import Mathlib.Geometry.Euclidean.Volume.Basic
13/-!
15# Incenters, excenters, and volumes of simplices
17This file explores the interaction between incenters, excenters, and volumes of simplices. It shows
18that the volumes of faces are weights to characterize excenters, and the volume of the simplex can
19be calculated using exradius.
21## Main declarations
22* `Affine.Simplex.excenterWeightsFace` are volumes of faces attached with a sign. These are
23 proportional to `Affine.Simplex.excenterWeights`. (See
24 `Affine.Simplex.excenterWeights_eq_excenterWeightsFace_div`)
25* `Affine.Simplex.ExcenterExists.volume_eq_exradius_mul`: the volume of the simplex is the product
26 of `Affine.Simplex.exradius` and the sum of `Affine.Simplex.excenterWeightsFace`, divided by
27 the dimension.
28* `Affine.Simplex.volume_eq_inradius_mul`: the volume of the simplex is the product of
29 `Affine.Simplex.inradius` and the surface area, divided by the dimension.
31-/
33@[expose] public section
35namespace Affine.Simplex
37variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
38 [NormedAddTorsor V P] {n : ℕ} [NeZero n] (s : Simplex ℝ P n) (signs : Finset (Fin (n + 1)))
39 (i : Fin (n + 1))
def excenterWeightsFace newL41–47
41/--
42Similar to `Affine.Simplex.excenterWeightsUnnorm`, these are unnormalized weights whose affine
43combination gives an excenter with the signs determined by the given set of indices. It is defined
44as the volume of the `Affine.Simplex.faceOpposite` attached with a sign.
45-/
46noncomputable def excenterWeightsFace : ℝ :=
47 (if i ∈ signs then -1 else 1) * (s.faceOpposite i).volume
theorem excenterWeightsFace_ne_zero newL49–51
49theorem excenterWeightsFace_ne_zero : s.excenterWeightsFace signs i ≠ 0 := by
50 unfold excenterWeightsFace
51 positivity
theorem excenterWeightsFace_empty newL53–55
53@[simp]
54theorem excenterWeightsFace_empty : s.excenterWeightsFace ∅ i = (s.faceOpposite i).volume := by
55 simp [excenterWeightsFace]
theorem excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm newL57–60
57theorem excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm :
58 s.excenterWeightsFace signs i = n * s.volume * s.excenterWeightsUnnorm signs i := by
59 rw [s.volume_eq i, excenterWeightsUnnorm, excenterWeightsFace]
60 field [‹NeZero n›.ne]
theorem excenterWeightsFace_reindex newL62–68
62theorem excenterWeightsFace_reindex {m : ℕ} [NeZero m] (e : Fin (n + 1) ≃ Fin (m + 1))
63 (signs : Finset (Fin (m + 1))) :
64 (s.reindex e).excenterWeightsFace signs =
65 s.excenterWeightsFace (Finset.map e.symm.toEmbedding signs) ∘ e.symm := by
66 have h : n = m := by simpa using Fin.equiv_iff_eq.mp ⟨e⟩
67 ext
68 simp [excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm, excenterWeightsUnnorm_reindex, h]
theorem excenterWeightsFace_map newL70–75
70@[simp]
71theorem excenterWeightsFace_map {P₂ : Type*} [MetricSpace P₂] [NormedAddTorsor V P₂]
72 (f : P →ᵃⁱ[ℝ] P₂) :
73 (s.map f.toAffineMap f.injective).excenterWeightsFace = s.excenterWeightsFace := by
74 ext
75 simp [excenterWeightsFace]
theorem excenterWeightsFace_restrict newL77–84
77@[simp]
78theorem excenterWeightsFace_restrict (S : AffineSubspace ℝ P)
79 (hS : affineSpan ℝ (Set.range s.points) ≤ S) :
80 haveI := Nonempty.map (AffineSubspace.inclusion hS) inferInstance
81 (s.restrict S hS).excenterWeightsFace = s.excenterWeightsFace := by
82 have := Nonempty.map (AffineSubspace.inclusion hS) inferInstance
83 ext
84 simp [excenterWeightsFace, faceOpposite_restrict]
theorem excenterExists_iff_sum_excenterWeightsFace_ne_zero newL86–89
86theorem excenterExists_iff_sum_excenterWeightsFace_ne_zero :
87 s.ExcenterExists signs ↔ ∑ i, s.excenterWeightsFace signs i ≠ 0 := by
88 simp [excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm, ← Finset.mul_sum,
89 ExcenterExists, ‹NeZero n›.ne, s.volume_pos.ne']
theorem excenterWeights_eq_excenterWeightsFace_div newL91–96
91theorem excenterWeights_eq_excenterWeightsFace_div :
92 s.excenterWeights signs i =
93 s.excenterWeightsFace signs i / ∑ j, s.excenterWeightsFace signs j := by
94 simp_rw [excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm, ← Finset.mul_sum,
95 excenterWeights, Pi.smul_apply, smul_eq_mul]
96 field [‹NeZero n›.ne]
theorem sum_excenterWeightsFace_singleton_pos newL98–101
98theorem sum_excenterWeightsFace_singleton_pos [n.AtLeastTwo] (i : Fin (n + 1)) :
99 0 < ∑ j, s.excenterWeightsFace {i} j := by
100 simp_rw [excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm, ← Finset.mul_sum]
101 positivity [‹NeZero n›.pos, s.sum_excenterWeightsUnnorm_singleton_pos i]
103variable {s signs} in
theorem ExcenterExists.volume_eq_exradius_mul newL104–109
104theorem ExcenterExists.volume_eq_exradius_mul (h : s.ExcenterExists signs) :
105 s.volume = (↑n)⁻¹ * s.exradius signs * |∑ i, s.excenterWeightsFace signs i| := by
106 have : |∑ i, s.excenterWeightsUnnorm signs i| ≠ 0 := by simpa [ExcenterExists] using h
107 simp_rw [excenterWeightsFace_eq_volume_mul_excenterWeightsUnnorm, ← Finset.mul_sum, abs_mul,
108 exradius_eq_abs_inv_sum, abs_inv, Nat.abs_cast, abs_of_nonneg s.volume_pos.le]
109 field [‹NeZero n›.ne]
theorem volume_eq_inradius_mul newL111–114
111theorem volume_eq_inradius_mul :
112 s.volume = (↑n)⁻¹ * s.inradius * ∑ i, (s.faceOpposite i).volume := by
113 have : 0 < ∑ x, (s.faceOpposite x).volume := by positivity
114 simpa [abs_of_nonneg this.le] using s.excenterExists_empty.volume_eq_exradius_mul
116end Affine.Simplex

Mathlib/Geometry/Euclidean/Volume/Triangle.lean +211 −0 new file

1/-
2Copyright (c) 2026 Weiyi Wang. All rights reserved.
3Released under Apache 2.0 license as described in the file LICENSE.
4Authors: Weiyi Wang, Matt Kempster
5-/
6module
7
8public import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
9public import Mathlib.Geometry.Euclidean.Circumcenter
10public import Mathlib.Geometry.Euclidean.NinePointCircle
11public import Mathlib.Geometry.Euclidean.Volume.Incenter
13import Mathlib.Geometry.Euclidean.Angle.Sphere
14import Mathlib.Geometry.Euclidean.Triangle
15import Mathlib.Geometry.Euclidean.Volume.Basic
17/-!
18# Area of a triangle
20This file collects formulas for the area of a triangle and other related results.
22## Main theorems
24* `Affine.Triangle.volume_eq_height_mul`: $S = \frac{1}{2}hb$
25* `Affine.Triangle.volume_eq_mul_sin`: $S = \frac{1}{2}ab \sin C$3
26* `Affine.Triangle.volume_eq_sqrt_mul_sub_mul_sub_mul_sub`: Heron's formula.
27* `Affine.Triangle.volume_eq_mul_div_circumradius`: $S = abc/(4R)$ where $R$ is the circumradius.
28* `Affine.Triangle.dist_excenter_singleton_circumcenter_sq`:
29 Euler's theorem in geometry for excenter.
30* `Affine.Triangle.dist_incenter_circumcenter_sq`: Euler's theorem in geometry for incenter.
31-/
33public section
35namespace Affine.Triangle
37open Simplex EuclideanGeometry Real
39variable {V P : Type*}
40variable [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P]
41variable (t : Triangle ℝ P) {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃)
43include h₁₂ h₁₃ h₂₃ in
theorem volume_eq_height_mul newL44–48
44theorem volume_eq_height_mul : t.volume = 2⁻¹ * t.height i₁ * dist (t.points i₂) (t.points i₃) := by
45 let e : Fin 3 ≃ Fin 3 := List.Nodup.getEquivOfForallMemList [i₁, i₂, i₃] (by grind) (by grind)
46 let s := t.reindex e.symm
47 suffices s.volume = 2⁻¹ * s.height 0 * dist (s.points 1) (s.points 2) by simpa [s]
48 simp [s.volume_eq 0, volume_eq_dist, faceOpposite_point_eq_point_succAbove]
50include h₁₂ h₁₃ h₂₃ in
theorem volume_eq_mul_sin newL51–55
51theorem volume_eq_mul_sin :
52 t.volume = 2⁻¹ * dist (t.points i₁) (t.points i₂) * dist (t.points i₂) (t.points i₃) *
53 Real.sin (∠ (t.points i₁) (t.points i₂) (t.points i₃)) := by
54 rw [t.volume_eq_height_mul h₁₂ h₁₃ h₂₃, t.height_eq_sin_mul_dist h₁₂ h₁₃ h₂₃]
55 ring
theorem _root_.EuclideanGeometry.mul_sin_eq_sqrt_mul_sub_mul_sub_mul_sub newL57–98
57/-- **Heron's formula** for possibly degenerate triangle. The area of a triangle with side lengths
58`a`, `b`, and `c` is `√(s * (s - a) * (s - b) * (s - c))` where `s = (a + b + c) / 2` is the
59semiperimeter. We show this by equating this formula to `2⁻¹ * a * c * sin γ`, where `γ` is the
60angle opposite the side `b`. -/
61theorem _root_.EuclideanGeometry.mul_sin_eq_sqrt_mul_sub_mul_sub_mul_sub (p₁ p₂ p₃ : P) :
62 let a := dist p₁ p₂
63 let b := dist p₁ p₃
64 let c := dist p₂ p₃
65 let s := (a + b + c) / 2
66 2⁻¹ * a * c * sin (∠ p₁ p₂ p₃) = √(s * (s - a) * (s - b) * (s - c)) := by
67 by_cases h1 : p₁ = p₂
68 · simp [h1]
69 by_cases h2 : p₂ = p₃
70 · simp [h2]
71 intro a b c s
72 let γ := ∠ p₁ p₂ p₃
73 obtain := (dist_pos.mpr h1).ne', (dist_pos.mpr h2).ne'
74 have cos_rule : cos γ = (a * a + c * c - b * b) / (2 * a * c) := by
75 simp [field, a, b, c, γ, mul_comm,
76 dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle p₁ p₂ p₃,
77 dist_comm p₃ p₂]
78 let numerator := (2 * a * c) ^ 2 - (a * a + c * c - b * b) ^ 2
79 let denominator := (2 * a * c) ^ 2
80 have split_to_frac : 1 - cos γ ^ 2 = numerator / denominator := by
81 simp [field, numerator, denominator, cos_rule]
82 have numerator_nonneg : 0 ≤ numerator := by
83 have frac_nonneg : 0 ≤ numerator / denominator :=
84 (sub_nonneg.mpr (cos_sq_le_one γ)).trans_eq split_to_frac
85 rcases div_nonneg_iff.mp frac_nonneg with h | h
86 · exact h.left
87 · simpa [numerator, denominator, a, b, c, h1, h2, dist_comm p₃ p₂]
88 using le_antisymm h.right (sq_nonneg _)
89 have ab2_nonneg : 0 ≤ 2 * a * c := by positivity
90 calc
91 2⁻¹ * a * c * sin γ = 1 / 2 * a * c * (√numerator / √denominator) := by
92 rw [sin_eq_sqrt_one_sub_cos_sq, split_to_frac, sqrt_div numerator_nonneg] <;>
93 simp [γ, angle_nonneg, angle_le_pi]
94 _ = 1 / 4 * √((2 * a * b) ^ 2 - (a * a + b * b - c * c) ^ 2) := by
95 simp (disch := positivity) [field, numerator, denominator, -mul_eq_mul_left_iff]; ring_nf
96 _ = 1 / 4 * √(s * (s - a) * (s - b) * (s - c) * 4 ^ 2) := by simp only [s]; ring_nf
97 _ = √(s * (s - a) * (s - b) * (s - c)) := by
98 rw [sqrt_mul', sqrt_sq, div_mul_eq_mul_div, one_mul, mul_div_cancel_right₀] <;> norm_num
100include h₁₂ h₁₃ h₂₃ in
theorem volume_eq_sqrt_mul_sub_mul_sub_mul_sub newL101–110
101/-- **Heron's formula** for triangle. The area of a triangle with side lengths
102`a`, `b`, and `c` is `√(s * (s - a) * (s - b) * (s - c))` where `s = (a + b + c) / 2` is the
103semiperimeter. -/
104theorem volume_eq_sqrt_mul_sub_mul_sub_mul_sub :
105 let a := dist (t.points i₁) (t.points i₂)
106 let b := dist (t.points i₁) (t.points i₃)
107 let c := dist (t.points i₂) (t.points i₃)
108 let s := (a + b + c) / 2
109 t.volume = √(s * (s - a) * (s - b) * (s - c)) := by
110 rw [t.volume_eq_mul_sin h₁₂ h₁₃ h₂₃, mul_sin_eq_sqrt_mul_sub_mul_sub_mul_sub]
112include h₁₂ h₁₃ h₂₃ in
theorem volume_sq_eq_mul_sub_mul_sub_mul_sub newL113–123
113theorem volume_sq_eq_mul_sub_mul_sub_mul_sub :
114 let a := dist (t.points i₁) (t.points i₂)
115 let b := dist (t.points i₁) (t.points i₃)
116 let c := dist (t.points i₂) (t.points i₃)
117 let s := (a + b + c) / 2
118 t.volume ^ 2 = s * (s - a) * (s - b) * (s - c) := by
119 rw [t.volume_eq_sqrt_mul_sub_mul_sub_mul_sub h₁₂ h₁₃ h₂₃, sq_sqrt]
120 by_contra! h
121 have := sqrt_eq_zero_of_nonpos h.le
122 rw [← t.volume_eq_sqrt_mul_sub_mul_sub_mul_sub h₁₂ h₁₃ h₂₃] at this
123 simp [t.volume_pos.ne'] at this
125include h₁₂ h₁₃ h₂₃ in
theorem volume_eq_mul_div_circumradius newL126–133
126/-- Triangle area is equal to $abc / (4R)$, where $a$, $b$, and $c$ are side length and $R$ is the
127circumradius. -/
128theorem volume_eq_mul_div_circumradius :
129 t.volume = dist (t.points i₁) (t.points i₂) * dist (t.points i₁) (t.points i₃) *
130 dist (t.points i₂) (t.points i₃) / (4 * t.circumradius) := by
131 have : dist (t.points i₁) (t.points i₃) ≠ 0 := by simpa using t.independent.injective.ne h₁₃
132 rw [t.volume_eq_mul_sin h₁₂ h₁₃ h₂₃, ← t.dist_div_sin_angle_div_two_eq_circumradius h₁₂ h₁₃ h₂₃]
133 field
135include h₁₂ h₁₃ h₂₃ in
theorem four_mul_volume_mul_circumradius newL136–140
136theorem four_mul_volume_mul_circumradius :
137 4 * t.volume * t.circumradius = dist (t.points i₁) (t.points i₂) *
138 dist (t.points i₁) (t.points i₃) * dist (t.points i₂) (t.points i₃) := by
139 have : t.circumradius ≠ 0 := t.circumradius_pos.ne'
140 simp [t.volume_eq_mul_div_circumradius h₁₂ h₁₃ h₂₃, field]
142local notation "w" => excenterWeightsFace
theorem sum_excenterWeightsFace_pos newL144–150
144theorem sum_excenterWeightsFace_pos {signs : Finset (Fin 3)}
145 (hsigns : signs = ∅ ∨ signs = {0} ∨ signs = {1} ∨ signs = {2}) :
146 0 < ∑ i, w t signs i := by
147 rcases hsigns with rfl | hsigns
148 · refine Finset.sum_pos (fun i _ ↦ ?_) (by simp)
149 simp [faceOpposite_point_eq_point_succAbove, t.independent.injective.ne]
150 · rcases hsigns with rfl | rfl | rfl <;> apply sum_excenterWeightsFace_singleton_pos
theorem dist_excenter_sq newL152–178
152theorem dist_excenter_sq (p : P) {signs : Finset (Fin 3)}
153 (hsigns : signs = ∅ ∨ signs = {0} ∨ signs = {1} ∨ signs = {2}) :
154 dist (t.excenter signs) p ^ 2 = ∑ i, t.excenterWeights signs i * dist (t.points i) p ^ 2 +
155 (if signs = ∅ then -1 else 1) * 2 * t.circumradius * t.exradius signs := by
156 have h0 := t.sum_excenterWeightsFace_pos hsigns
157 rw [t.excenter_eq_affineCombination, dist_affineCombination_const_sq _ _
158 (t.sum_excenterWeights_eq_one_iff.mpr (t.excenterExists _))]
159 congrm _ + ?_
160 calc
161 _ = -((∑ i, ∑ j, w t signs i * w t signs j * dist (t.points i) (t.points j) ^ 2) / 2 /
162 (∑ i, w t signs i) ^ 2) := by
163 simp_rw [t.excenterWeights_eq_excenterWeightsFace_div, Finset.sum_div]
164 congrm -∑ i, ∑ j, $(by ring)
165 _ = (if signs = ∅ then -1 else 1) *
166 (dist (t.points 0) (t.points 1) * dist (t.points 0) (t.points 2) *
167 dist (t.points 1) (t.points 2)) * (∑ i, w t signs i) / (∑ i, w t signs i) ^ 2 := by
168 have : (Finset.univ : Finset (Fin 3)) = {0, 1, 2} := by grind
169 rcases hsigns with rfl | rfl | rfl | rfl
170 all_goals
171 simp [this, excenterWeightsFace, faceOpposite_point_eq_point_succAbove,
172 Fin.succAbove, dist_comm (t.points 1) (t.points 0), dist_comm (t.points 2) (t.points 1),
173 dist_comm (t.points 2) (t.points 0)]
174 ring
175 _ = _ := by
176 rw [← t.four_mul_volume_mul_circumradius (by simp) (by simp) (by simp),
177 (t.excenterExists signs).volume_eq_exradius_mul, abs_of_nonneg h0.le]
178 field
theorem dist_excenter_circumcenter_sq newL180–186
180theorem dist_excenter_circumcenter_sq {signs : Finset (Fin 3)}
181 (hsigns : signs = ∅ ∨ signs = {0} ∨ signs = {1} ∨ signs = {2}) :
182 dist (t.excenter signs) t.circumcenter ^ 2 =
183 t.circumradius * (t.circumradius + (if signs = ∅ then -1 else 1) * 2 * t.exradius signs) := by
184 simp_rw [t.dist_excenter_sq t.circumcenter hsigns, dist_circumcenter_eq_circumradius,
185 ← Finset.sum_mul, t.sum_excenterWeights_eq_one_iff.mpr (t.excenterExists _)]
186 ring
theorem dist_excenter_singleton_circumcenter_sq newL188–193
188/-- **Euler's theorem in geometry** for excenter. -/
189theorem dist_excenter_singleton_circumcenter_sq (i : Fin 3) :
190 dist (t.excenter {i}) t.circumcenter ^ 2 =
191 t.circumradius * (t.circumradius + 2 * t.exradius {i}) := by
192 rw [t.dist_excenter_circumcenter_sq (by grind)]
193 simp
theorem dist_incenter_circumcenter_sq newL195–199
195/-- **Euler's theorem in geometry** for incenter. -/
196theorem dist_incenter_circumcenter_sq :
197 dist t.incenter t.circumcenter ^ 2 = t.circumradius * (t.circumradius - 2 * t.inradius) := by
198 rw [← excenter_empty, t.dist_excenter_circumcenter_sq (by grind)]
199 simp [← sub_eq_add_neg]
theorem two_mul_inradius_le_circumradius newL201–205
201/-- **Euler inequality**: the inradius of a triangle is not larger than half of the circumradius. -/
202theorem two_mul_inradius_le_circumradius : 2 * t.inradius ≤ t.circumradius := by
203 have := sq_nonneg (dist t.incenter t.circumcenter)
204 rw [dist_incenter_circumcenter_sq] at this
205 simpa using nonneg_of_mul_nonneg_right this (t.circumradius_pos)
theorem inradius_le_ninePointCircle_radius newL207–209
207theorem inradius_le_ninePointCircle_radius : t.inradius ≤ t.ninePointCircle.radius := by
208 grw [ninePointCircle_radius, ← two_mul_inradius_le_circumradius]
209 simp
211end Affine.Triangle

Mathlib/LinearAlgebra/AffineSpace/Simplex/Centroid.lean +4 −0

theorem centroid_vsub_eq {n : ℕ} [CharZero k] (s : Simplex k P n) (p : P) :
97 (hw := sum_centroidWeights_eq_one_of_nonempty _ _ (by simp))]
98 simp [smul_sum]
theorem vsub_centroid_eq newL100–102
100theorem vsub_centroid_eq {n : ℕ} [CharZero k] (s : Simplex k P n) (p : P) :
101 p -ᵥ s.centroid = (n + 1 : k)⁻¹ • ∑ x, (p -ᵥ s.points x) := by
102 simpa [← smul_neg, ← sum_neg_distrib] using congr(-$(s.centroid_vsub_eq p))
104theorem centroid_eq_smul_sum_vsub_vadd [CharZero k] (s : Simplex k P n) (i : Fin (n + 1)) :
105 s.centroid = (n + 1 : k)⁻¹ • ∑ x, (s.points x -ᵥ s.points i) +ᵥ s.points i := by
106 rw [← s.centroid_vsub_eq, vsub_vadd]

docs/100.yaml +5 −1

125 title : Pascal’s Hexagon Theorem
12629:
127 title : Feuerbach’s Theorem
128 decls :
129 - Affine.Triangle.isExtTangent_exsphere_ninePointCircle
130 - Affine.Triangle.isIntTangent_insphere_ninePointCircle
131 authors: Weiyi Wang
13230:
133 title : The Ballot Problem
134 authors: Bhavik Mehta and Kexing Ying
235 title : The Hermite-Lindemann Transcendence Theorem
23657:
237 title : Heron’s Formula
− decl : Theorems100.heron
238 decl : Affine.Triangle.volume_eq_sqrt_mul_sub_mul_sub_mul_sub
239 authors: Matt Kempster
24058:
241 title : Formula for the Number of Combinations

docs/1000.yaml +10 −1

Q1422083:
1661Q1423818:
1662 title: Euler's theorem in geometry
1663 decls:
1664 - Affine.Triangle.dist_excenter_singleton_circumcenter_sq
1665 - Affine.Triangle.dist_incenter_circumcenter_sq
1666 authors: Weiyi Wang
1667 date: 2026
1669Q1424481:
1670 title: Frucht's theorem
Q2120067:
2022Q2190744:
2023 title: Feuerbach's theorem
− # in 100.yaml also
2024 decls:
2025 - Affine.Triangle.isExtTangent_exsphere_ninePointCircle
2026 - Affine.Triangle.isIntTangent_insphere_ninePointCircle
2027 authors: Weiyi Wang
2028 date: 2026
2030Q2197859:
2031 title: Nicomachus's theorem

docs/references.bib +10 −0

@Book{ schaefer1966
5420 publisher = {Macmillan}
5423@Misc{ scheer2011simplevectorprooffeuerbachs,
5424 title = {A Simple Vector Proof of Feuerbach's Theorem},
5425 author = {Michael Scheer},
5426 year = {2011},
5427 eprint = {1107.1152},
5428 archiveprefix = {arXiv},
5429 primaryclass = {math.MG},
5430 url = {https://arxiv.org/abs/1107.1152}
5433@Misc{ schleicher_stoll,
5434 author = {Dierk Schleicher and Michael Stoll},
5435 title = {An introduction to {C}onway's games and numbers},
0/44 declarations checked

Your review, as Markdown

Paste it as a comment or a review on the PR. Line links to the head commit unfold into code snippets on GitHub.