Skip to content

[Merged by Bors] - refactor(Geometry/Euclidean): promote Heron's formula to main mathlib - #44148

Closed
wwylele wants to merge 4 commits into
leanprover-community:masterfrom
wwylele:heron
Closed

wwylele wants to merge 4 commits into
leanprover-community:masterfrom
wwylele:heron

Conversation

@wwylele

@wwylele wwylele commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Now we have a proper definition of triangle's area, we can make Heron's formula an official theorem in the main library. The original proof was mostly unchanged, with only the following modification

1. Index change
The naming and indexing was changed from

    let a := dist p₁ p₂
    let b := dist p₃ p₂
    let c := dist p₁ p₃

to

    let a := dist p₁ p₂
    let b := dist p₁ p₃
    let c := dist p₂ p₃

This is to follow the existing indexing convention of "1-2, 1-3, 2-3" for triangles. We have similar order for h₁₂ h₁₃ h₂₃

2. Generalized to all degenerate cases: Removed (h1 : p₁ ≠ p₂) (h2 : p₃ ≠ p₂)


@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

PR summary d76e27215b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ _root_.EuclideanGeometry.mul_sin_eq_sqrt_mul_sub_mul_sub_mul_sub
+ volume_eq_sqrt_mul_sub_mul_sub_mul_sub
+ volume_sq_eq_mul_sub_mul_sub_mul_sub
- heron

You can run this locally as follows
## 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>

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

Declarations diff (Lean)

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

  • +3 new declarations
  • −0 removed declarations
+Affine.Triangle.volume_eq_sqrt_mul_sub_mul_sub_mul_sub
+Affine.Triangle.volume_sq_eq_mul_sub_mul_sub_mul_sub
+EuclideanGeometry.mul_sin_eq_sqrt_mul_sub_mul_sub_mul_sub

No changes to strong technical debt.
No changes to weak technical debt.

Current commit d76e27215b
Reference commit 02970ca040

This script lives in the mathlib-ci 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!

@github-actions github-actions Bot added file-removed A Lean module was (re)moved without a `deprecated_module` annotation t-euclidean-geometry Affine and axiomatic geometry labels Sep 24, 2026
@wwylele
wwylele force-pushed the heron branch 2 times, most recently from 88a81c7 to effd2a3 Compare September 24, 2026 01:24
@wwylele wwylele changed the title refactor(Euclidean/Geometry): promote Heron's formula to main mathlib refactor(Geometry/Euclidean): promote Heron's formula to main mathlib Sep 24, 2026
@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Sep 24, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 28, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 27, 2026
@mathlib-dependent-issues

Copy link
Copy Markdown

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the promotion of Heron’s formula into the triangle-area API.

No open issues 🎉

What changed in this PR

Promotes Heron’s formula from the archive into mathlib’s triangle-area API, building on the area formulas introduced in #41220.

Changes:

  • Generalizes the point-based identity to include degenerate triangles and aligns side indexing with existing conventions.
  • Adds Heron’s formula for triangle volume and its squared form.
  • Removes the archived proof and updates the 100 Theorems reference.
File Description
Mathlib/​Geometry/​Euclidean/​Volume/​Triangle.lean Adds the generalized identity and both triangle-volume formulas.
docs/​100.yaml Points Heron’s formula to the main-library theorem.
Archive/​Wiedijk100Theorems/​HeronsFormula.lean Removes the superseded archived proof.
Archive.lean Removes the deleted archive module’s import.

Review effort: Balanced

@wwylele

wwylele commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator Author

This is ready for review

@jsm28

jsm28 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

maintainer merge

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by jsm28.

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Oct 30, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 7, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 7, 2026

@j-loreaux j-loreaux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. We can make some improvements here.

@mathlib-bors mathlib-bors Bot added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Nov 10, 2026
@mathlib-bors

mathlib-bors Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

✌️ wwylele can now approve this pull request until 2026-11-24 22:43 UTC (in 2 weeks). To approve and merge, reply with bors r+. More detailed instructions are available here.

⚠️ This delegation only covers changes within Archive/**, Counterexamples/**, docs/**, DownstreamTest/**, Mathlib/**, MathlibTest/**, Wanted/**, widget/**, Archive.lean, Counterexamples.lean, docs.lean, Mathlib.lean, Wanted.lean; an author commit touching anything else will revoke it. Bors also revokes it if a later push changes too many files for it to check the full list — even if it stays within scope.

@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Nov 10, 2026
@wwylele

wwylele commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

bors r+

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Nov 10, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Nov 10, 2026
…#44148)

Now we have a proper definition of triangle's area, we can make Heron's formula an official theorem in the main library. The original proof was mostly unchanged, with only the following modification

**1. Index change**
The naming and indexing was changed from
```
    let a := dist p₁ p₂
    let b := dist p₃ p₂
    let c := dist p₁ p₃
```
to
```
    let a := dist p₁ p₂
    let b := dist p₁ p₃
    let c := dist p₂ p₃
```
This is to follow the existing indexing convention of "1-2, 1-3, 2-3" for triangles. We have similar order for `h₁₂ h₁₃ h₂₃`

**2. Generalized to all degenerate cases**: Removed `(h1 : p₁ ≠ p₂) (h2 : p₃ ≠ p₂)`
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Nov 10, 2026
@mathlib-bors

mathlib-bors Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title refactor(Geometry/Euclidean): promote Heron's formula to main mathlib [Merged by Bors] - refactor(Geometry/Euclidean): promote Heron's formula to main mathlib Nov 10, 2026
@mathlib-bors mathlib-bors Bot closed this Nov 10, 2026
@mathlib-bors mathlib-bors Bot removed the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Nov 10, 2026
@wwylele
wwylele deleted the heron branch November 10, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bors-staging This PR is currently being built by bors on the staging branch. file-removed A Lean module was (re)moved without a `deprecated_module` annotation ready-to-merge This PR has been sent to bors. t-euclidean-geometry Affine and axiomatic geometry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants