Skip to content

[Merged by Bors] - feat: same/opposite side of an affine subspace from scalar multiples of a common vector - #40245

Closed
Scarlett-le wants to merge 1 commit into
leanprover-community:masterfrom
Scarlett-le:feat/side-vsub-eq-smul
Closed

Scarlett-le wants to merge 1 commit into
leanprover-community:masterfrom
Scarlett-le:feat/side-vsub-eq-smul

Conversation

@Scarlett-le

@Scarlett-le Scarlett-le commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Add sameRay_smul_smul_of_mul_nonneg to Mathlib/LinearAlgebra/Ray.lean: two scalar multiples c₁ • v and c₂ • v of a common vector lie on a common ray whenever 0 ≤ c₁ * c₂. Using it, add four lemmas to Mathlib/Analysis/Convex/Side.lean giving sufficient conditions for a pair of points to be (weakly/strictly) on the same or opposite side of an affine subspace, from the displacements x -ᵥ p₁ = c₁ • m and y -ᵥ p₂ = c₂ • m. The sign of c₁ * c₂ determines same vs opposite side:

  • AffineSubspace.wSameSide_of_vsub_eq_smul / sSameSide_of_vsub_eq_smul
  • AffineSubspace.wOppSide_of_vsub_eq_smul / sOppSide_of_vsub_eq_smul

This PR is a prerequisite for #34164 (feat(Geometry/Euclidean/Sphere): define arcs on spheres).

@github-actions

github-actions Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

PR summary fa949d3193

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ sOppSide_of_vsub_eq_smul
+ sSameSide_of_vsub_eq_smul
+ sameRay_smul_smul_of_mul_nonneg
+ wOppSide_of_vsub_eq_smul
+ wSameSide_of_vsub_eq_smul

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 fa949d3).

  • +5 new declarations
  • −0 removed declarations
+AffineSubspace.sOppSide_of_vsub_eq_smul
+AffineSubspace.sSameSide_of_vsub_eq_smul
+AffineSubspace.wOppSide_of_vsub_eq_smul
+AffineSubspace.wSameSide_of_vsub_eq_smul
+sameRay_smul_smul_of_mul_nonneg

No changes to strong technical debt.

No changes to weak technical debt.

Current commit fa949d3193
Reference commit c0ba100fa0

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.sh 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).

@Scarlett-le
Scarlett-le temporarily deployed to cache-upload-forks June 5, 2026 03:59 — with GitHub Actions Inactive
@jsm28 jsm28 added the t-convex-geometry Affine geometry, cones, simplices label Jun 29, 2026
@jsm28

jsm28 commented Jun 29, 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 Jun 29, 2026

/-- If `x` and `y` are displaced from points of `s` by multiples of a common vector whose
coefficients have nonnegative product, they are weakly on the same side of `s`. -/
theorem wSameSide_of_vsub_eq_smul {s : AffineSubspace R P} {x y p₁ p₂ : P} {m : V} {c₁ c₂ : R}

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.

our naming conventions dictate that ASDFqwerZXCV is lowerCamelCased as asdfqwerZXCV, i.e., all the capital letters at the beginning are lowercased, not only the first one. The same applies for WOppSide too throughout the PR.

Suggested change
theorem wSameSide_of_vsub_eq_smul {s : AffineSubspace R P} {x y p₁ p₂ : P} {m : V} {c₁ c₂ : R}
theorem wsameSide_of_vsub_eq_smul {s : AffineSubspace R P} {x y p₁ p₂ : P} {m : V} {c₁ c₂ : R}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

https://loogle.lean-lang.org/?q=AffineSubspace.WSameSide
This clashes with existing naming though. I suggest follow the existing name and do a rename later

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would also argue that wSameSide is the correct one, same way as "htmlRequest" is the lower camel case of "HTMLRequest". The "W" here is a word of uppercase letter cluster (of a single letter), and Same is the second word, so Same keeps its uppercase

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Following the existing convention here — as the loogle results show, all 43 existing declarations use wSameSide/wOppSide/sSameSide/sOppSide, so I'll keep those forms. I also think they're correct per the naming guide: the W/S prefix is a single-letter initialism and Same/Side are separate words, so it lowercases exactly like HTMLRequest → htmlRequest (initialism fully lowercased, following word keeps its capital). So there's no clash to rename later.

Comment on lines +376 to +378
theorem sSameSide_of_vsub_eq_smul {s : AffineSubspace R P} {x y p₁ p₂ : P} {m : V} {c₁ c₂ : R}
(hp₁ : p₁ ∈ s) (hp₂ : p₂ ∈ s) (h₁ : x -ᵥ p₁ = c₁ • m) (h₂ : y -ᵥ p₂ = c₂ • m)
(hc : 0 ≤ c₁ * c₂) (hx : x ∉ s) (hy : y ∉ s) : s.SSameSide x y :=

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.

I didn't think hard about this, so maybe it's wrong, but couldn't you take 0 < c₁ * c₂ as a hypothesis instead of x ∉ s and y ∉ s? That would be more natural to me (but again, maybe it's wrong).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for raising this, but I think this doesn't work as stated. SSameSide unfolds to WSameSide ∧ x ∉ s ∧ y ∉ s by definition, so the conclusion needs hypotheses strong enough to give x ∉ s and y ∉ s, and 0 < c₁ * c₂ doesn't. Counterexample: take m = 0 (or any m ∈ s.direction); then x = p₁ ∈ s and y = p₂ ∈ s regardless, yet 0 < c₁ * c₂ still holds. 0 < c₁ c₂ only fixes the sign/ray relationship, not whether m points out of s.

@j-loreaux j-loreaux added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Jul 1, 2026
@Scarlett-le

Copy link
Copy Markdown
Contributor Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Jul 2, 2026

@ocfnash ocfnash 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!

Lemmas like this do make me reflect on Mathlib's Affine and Euclidean geometry results. I've partly persuaded myself that our definitions are a real strength but that we are in dire need of better tactics and are using lemmas as a crutch.

These are certainly useful well thought out lemmas but I can imagine a world in which they don't need to exist because we have created sufficiently power "affine geometry" tactics that they are all trivial one-liners.

I encourage people generously contributing to this part of the library to think about this :-)

Anyway, for now:

bors merge

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Jul 2, 2026
@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Jul 2, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Jul 2, 2026
…of a common vector (#40245)

Add `sameRay_smul_smul_of_mul_nonneg` to `Mathlib/LinearAlgebra/Ray.lean`: two scalar multiples `c₁ • v` and `c₂ • v` of a common vector lie on a common ray whenever `0 ≤ c₁ * c₂`. Using it, add four lemmas to `Mathlib/Analysis/Convex/Side.lean` giving sufficient conditions for a pair of points to be (weakly/strictly) on the same or opposite side of an affine subspace, from the displacements `x -ᵥ p₁ = c₁ • m` and `y -ᵥ p₂ = c₂ • m`. The sign of `c₁ * c₂` determines same vs opposite side:

* `AffineSubspace.wSameSide_of_vsub_eq_smul` / `sSameSide_of_vsub_eq_smul`
* `AffineSubspace.wOppSide_of_vsub_eq_smul` / `sOppSide_of_vsub_eq_smul`

Co-authored-by: Scarlett-le <[email protected]>
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Jul 2, 2026
@mathlib-bors

mathlib-bors Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title feat: same/opposite side of an affine subspace from scalar multiples of a common vector [Merged by Bors] - feat: same/opposite side of an affine subspace from scalar multiples of a common vector Jul 2, 2026
@mathlib-bors mathlib-bors Bot closed this Jul 2, 2026
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Jul 4, 2026
…of a common vector (leanprover-community#40245)

Add `sameRay_smul_smul_of_mul_nonneg` to `Mathlib/LinearAlgebra/Ray.lean`: two scalar multiples `c₁ • v` and `c₂ • v` of a common vector lie on a common ray whenever `0 ≤ c₁ * c₂`. Using it, add four lemmas to `Mathlib/Analysis/Convex/Side.lean` giving sufficient conditions for a pair of points to be (weakly/strictly) on the same or opposite side of an affine subspace, from the displacements `x -ᵥ p₁ = c₁ • m` and `y -ᵥ p₂ = c₂ • m`. The sign of `c₁ * c₂` determines same vs opposite side:

* `AffineSubspace.wSameSide_of_vsub_eq_smul` / `sSameSide_of_vsub_eq_smul`
* `AffineSubspace.wOppSide_of_vsub_eq_smul` / `sOppSide_of_vsub_eq_smul`

Co-authored-by: Scarlett-le <[email protected]>
michaellee94 pushed a commit to michaellee94/mathlib4 that referenced this pull request Jul 11, 2026
…of a common vector (leanprover-community#40245)

Add `sameRay_smul_smul_of_mul_nonneg` to `Mathlib/LinearAlgebra/Ray.lean`: two scalar multiples `c₁ • v` and `c₂ • v` of a common vector lie on a common ray whenever `0 ≤ c₁ * c₂`. Using it, add four lemmas to `Mathlib/Analysis/Convex/Side.lean` giving sufficient conditions for a pair of points to be (weakly/strictly) on the same or opposite side of an affine subspace, from the displacements `x -ᵥ p₁ = c₁ • m` and `y -ᵥ p₂ = c₂ • m`. The sign of `c₁ * c₂` determines same vs opposite side:

* `AffineSubspace.wSameSide_of_vsub_eq_smul` / `sSameSide_of_vsub_eq_smul`
* `AffineSubspace.wOppSide_of_vsub_eq_smul` / `sOppSide_of_vsub_eq_smul`

Co-authored-by: Scarlett-le <[email protected]>

This branch was previously deployed

1 inactive deployment
cache-upload-forks — fa949d31 Deployed Jun 5, 2026 by Scarlett-le via ci (fork) / Upload to cache #303024
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. ready-to-merge This PR has been sent to bors. t-convex-geometry Affine geometry, cones, simplices

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants