Skip to content

[Merged by Bors] - feat: Std.Total instance for InvImage - #43326

Closed
kim-em wants to merge 3 commits into
leanprover-community:masterfrom
kim-em:invimage_total
Closed

kim-em wants to merge 3 commits into
leanprover-community:masterfrom
kim-em:invimage_total

Conversation

@kim-em

@kim-em kim-em commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This PR fills in the transfer of unbundled relation classes along InvImage and Order.Preimage, so that both spellings carry everything Function.onFun already has.

InvImage gains Std.Refl, Std.Symm, Std.Asymm, Std.Total, IsPreorder, IsEquiv, IsStrictOrder and IsStrictWeakOrder instances, along with antisymm, trichotomous, isPartialOrder, isLinearOrder and isStrictTotalOrder for injective f. (Std.Irrefl and IsTrans are already in Mathlib/Order/Defs/Unbundled.lean.) These are stated for Sort, matching core's InvImage. Order.Preimage gains the four injectivity lemmas trichotomous, isPartialOrder, isLinearOrder and isStrictTotalOrder.

All of these are definitionally the Function.onFun versions, and are proved by inferInstanceAs, but instance search does not fire on goals stated with InvImage or ⁻¹'o (and InvImage is how goals arise from WellFoundedRelation-adjacent and Sum.Lex-based constructions). Used in leanprover/cslib#401.

example {α β : Type} (r : α → α → Prop) [Std.Total r] (f : β → α) :
    Std.Total (InvImage r f) := inferInstance

🤖 Prepared with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pxy48TaP92UgEq28KGm8BG
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

PR summary 27adedc5c9

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ antisymm
+ asymm
+ isEquiv
+ isPreorder
+ isStrictOrder
+ isStrictWeakOrder
+ refl
+ symm
+ total
++ isLinearOrder
++ isPartialOrder
++ isStrictTotalOrder
++ trichotomous
- InvImage.asymm
- InvImage.trichotomous

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

  • +15 new declarations
  • −0 removed declarations
+InvImage.antisymm
+InvImage.isEquiv
+InvImage.isLinearOrder
+InvImage.isPartialOrder
+InvImage.isPreorder
+InvImage.isStrictOrder
+InvImage.isStrictTotalOrder
+InvImage.isStrictWeakOrder
+InvImage.refl
+InvImage.symm
+InvImage.total
+Order.Preimage.isLinearOrder
+Order.Preimage.isPartialOrder
+Order.Preimage.isStrictTotalOrder
+Order.Preimage.trichotomous

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

Current commit 27adedc5c9
Reference commit 1318ddb253

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

@github-actions github-actions Bot added the t-order Order theory label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ PR Title Formatted Correctly

The title of this PR has been updated to match our commit style conventions.
Thank you!

kim-em added a commit to kim-em/cslib that referenced this pull request Sep 2, 2026
Function.Injective.extend_sum_inl_inr is proposed in
leanprover-community/mathlib4#43325 (with a golfed
LeftInverse proof, mirrored here) and the Std.Total (InvImage r f) instance
in leanprover-community/mathlib4#43326; keeping the
local copies private avoids conflicts when those land.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pxy48TaP92UgEq28KGm8BG
@b-mehta b-mehta changed the title feat: Std.Total instance for InvImage feat: Std.Total instance for InvImage Sep 2, 2026

@SnirBroshi SnirBroshi left a comment

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.

Can you add the rest? Function.onFun has all of the instances, including the ones that require injectiveness, so we should translate all of those to both Order.Preimage and InvImage.

If you could generalize core's InvImage from Prop to any sort we'll also be able to deprecate the other two.
#mathlib4 > `Order.Preimage` vs `Function.onFun`

Comment thread Mathlib/Order/RelClasses.lean Outdated
@grunweg grunweg added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 2, 2026
@kim-em

kim-em commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

If you could generalize core's InvImage from Prop to any sort we'll also be able to deprecate the other two.
#mathlib4 > Order.Preimage vs Function.onFun

Definitely out of scope for today. :-)

@kim-em

kim-em commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Can you add the rest? Function.onFun has all of the instances, including the ones that require injectiveness, so we should translate all of those to both Order.Preimage and InvImage.

Personally, I think it is not a good idea to ask for scope creep in reviews. It slows everything down unnecessarily. Nevertheless, I'll do these now.

kim-em and others added 2 commits September 9, 2026 00:50
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K9ZVGvAJNCKz5BBkUBFnyY
@kim-em kim-em removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 9, 2026
@eric-wieser

Copy link
Copy Markdown
Member

bors merge

Thanks!

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Sep 13, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Sep 13, 2026
This PR fills in the transfer of unbundled relation classes along `InvImage` and `Order.Preimage`, so that both spellings carry everything `Function.onFun` already has.

`InvImage` gains `Std.Refl`, `Std.Symm`, `Std.Asymm`, `Std.Total`, `IsPreorder`, `IsEquiv`, `IsStrictOrder` and `IsStrictWeakOrder` instances, along with `antisymm`, `trichotomous`, `isPartialOrder`, `isLinearOrder` and `isStrictTotalOrder` for injective `f`. (`Std.Irrefl` and `IsTrans` are already in `Mathlib/Order/Defs/Unbundled.lean`.) These are stated for `Sort`, matching core's `InvImage`. `Order.Preimage` gains the four injectivity lemmas `trichotomous`, `isPartialOrder`, `isLinearOrder` and `isStrictTotalOrder`.

All of these are definitionally the `Function.onFun` versions, and are proved by `inferInstanceAs`, but instance search does not fire on goals stated with `InvImage` or `⁻¹'o` (and `InvImage` is how goals arise from `WellFoundedRelation`-adjacent and `Sum.Lex`-based constructions). Used in leanprover/cslib#401.

```lean
example {α β : Type} (r : α → α → Prop) [Std.Total r] (f : β → α) :
    Std.Total (InvImage r f) := inferInstance
```

🤖 Prepared with Claude Code
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Sep 13, 2026
@mathlib-bors

mathlib-bors Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title feat: Std.Total instance for InvImage [Merged by Bors] - feat: Std.Total instance for InvImage Sep 14, 2026
@mathlib-bors mathlib-bors Bot closed this Sep 14, 2026
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-order Order theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants