Skip to content

chore: don't use by assumption for hypothesis with exposed name - #42007

Open
felixpernegger wants to merge 7 commits into
leanprover-community:masterfrom
felixpernegger:nameassumption
Open

felixpernegger wants to merge 7 commits into
leanprover-community:masterfrom
felixpernegger:nameassumption

Conversation

@felixpernegger

Copy link
Copy Markdown
Contributor

Let's say some goal if solve with := by assumption and assumption is using h to solve it. Then := h would also solve the goal (note: in most cases this is not possible, we would need to expose names before). This is more readable (tells the used explicitly what is being used) and at least in theory slightly faster.

This PR replace all such by assumption with the hypothesis directly. If this looks good / gets merged, I will make another PR replacing also assumption's which do not immediately follow a by.


Open in Gitpod

@felixpernegger

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Jul 22, 2026 •

Copy link
Copy Markdown

Benchmark results for 3d1ca39 against eb6a272 are in. No significant results found. @felixpernegger

  • ✅ build//instructions: -83.7G (-0.06%)

No significant changes detected.

@github-actions github-actions Bot added the tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip label Jul 22, 2026
@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

PR summary 51d83494ed

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

No declarations were harmed in the making of this PR! 🐙

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 51d8349).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


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

Current commit 51d83494ed
Reference commit bb1587137f

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

@felixpernegger

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Jul 22, 2026 •

Copy link
Copy Markdown

Benchmark results for 9618ba5 against eb6a272 are in. No significant results found. @felixpernegger

  • ✅ build//instructions: -76.9G (-0.05%)

No significant changes detected.

@Vierkantor Vierkantor 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.

I'm not convinced that this PR is useful. The assumption tactic does convey information to the reader, just like in written maths saying "this holds by assumption" is different from making very precise which assumption we made.

Could you open a Zulip discussion before making this change?

theorem Filter.EventuallyEq.hasFDerivWithinAt_iff (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : f₀ x = f₁ x) :
HasFDerivWithinAt f₀ f' s x ↔ HasFDerivWithinAt f₁ f' s x :=
h.prodMap (by assumption) |>.hasFDerivAtFilter_iff fun _ => _root_.rfl
h.prodMap (by exact hx) |>.hasFDerivAtFilter_iff fun _ => _root_.rfl

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.

by exact seems worse to me than by assumption. Would the following not work:

Suggested change
h.prodMap (by exact hx) |>.hasFDerivAtFilter_iff fun _ => _root_.rfl
h.prodMap hx |>.hasFDerivAtFilter_iff fun _ => _root_.rfl

@Vierkantor Vierkantor added awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there labels Jul 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 Aug 11, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

obtain ⟨M, _, i, hi⟩ :=
CochainComplex.Plus.exists_quasiIso_injective ⟨L, ⟨n, inferInstance⟩⟩ n
have : QuasiIso i.hom := by assumption
have : QuasiIso i.hom := hi

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.

Suggested change
have : QuasiIso i.hom := hi
change QuasiIso i.hom at hi

(hP : ∀ i, ∃ j, P j ∧ Nonempty (j ⟶ i)) : InitiallySmall.{v} J := by
obtain ⟨Q, H, hQ⟩ := ObjectProperty.EssentiallySmall.exists_small_le'.{v} P
have : Small.{v} (show Set _ from Q) := by assumption
have : Small.{v} (show Set _ from Q) := H

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.

Suggested change
have : Small.{v} (show Set _ from Q) := H
change Small (show Set _ from Q) at H

or maybe even

Suggested change
have : Small.{v} (show Set _ from Q) := H
change Set J at Q
change Small Q at H

(Types.FilteredColimit.isColimit_eq_iff' hc _ _).1 (congr_hom h x)
dsimp at f g h k a hk ⊢
replace hk : ∀ x, F.map (a x) (f x) = F.map (a x) (g x) := by assumption
replace hk : ∀ x, F.map (a x) (f x) = F.map (a x) (g x) := hk

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.

Suggested change
replace hk : ∀ x, F.map (a x) (f x) = F.map (a x) (g x) := hk
change ∀ x, F.map (a x) (f x) = F.map (a x) (g x) at hk

(ofHom _ ⟨fun _ ↦ b, continuous_const⟩)
(by ext; exact hab))
a⟩) by assumption
a⟩) from this

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.

This 8-line suffices is just a change in disguise, which also fits in 2 lines:

change g = ofHom _ (IsQuotientMap.liftEquiv _ ⟨e.hom.hom, fun a b hab ↦ CategoryTheory.congr_fun
  (h (ofHom _ ⟨_, continuous_const⟩) (ofHom _ ⟨_, continuous_const⟩) (by ext; exact hab)) a⟩)

or a rewrite if you prefer

rw [← IsQuotientMap.liftEquiv_apply (g := ⟨e.hom.hom, fun a b hab ↦ CategoryTheory.congr_fun
  (h (ofHom _ ⟨_, continuous_const⟩) (ofHom _ ⟨_, continuous_const⟩) (by ext; exact hab)) a⟩)]

rintro f ⟨l, rfl⟩
let L : Products I → Prop := fun m ↦ m.eval C ∈ span ℤ (Set.range (GoodProducts.eval C))
suffices L l by assumption
suffices L l from this

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.

Suggested change
suffices L l from this
change L l

(ofHom ⟨fun _ ↦ b, continuous_const⟩)
(by ext; exact hab))
a⟩) by assumption
a⟩) from this

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.

This suffices is a change

Comment thread Mathlib/Order/Atoms.lean

instance [IsStronglyCoatomic α] {s : Set α} [h : Set.OrdConnected s] : IsStronglyCoatomic s :=
Set.OrdConnected.isStronglyCoatomic <| by assumption
Set.OrdConnected.isStronglyCoatomic h

@SnirBroshi SnirBroshi Aug 11, 2026 •

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.

Suggested change
Set.OrdConnected.isStronglyCoatomic h
h.isStronglyCoatomic

although in this case maybe removing the name h is preferable

@SnirBroshi

Copy link
Copy Markdown
Collaborator

btw did you also look for ‹_›s?

@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 Sep 22, 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 26, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants