Skip to content

[Merged by Bors] - chore: adaptations for nightly-2025-03-31 - #23495

Closed
kim-em wants to merge 5614 commits into
bump/v4.19.0from
bump/nightly-2025-03-31
Closed

kim-em wants to merge 5614 commits into
bump/v4.19.0from
bump/nightly-2025-03-31

Conversation

@kim-em

@kim-em kim-em commented Mar 31, 2025 •

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

ghost commented Mar 31, 2025 •

Copy link
Copy Markdown

PR summary f083a36ccd

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Data.List.AList Mathlib.Data.List.Sigma 1

Declarations diff

+ bind_congr''
+ instance (priority := 100) LinearOrder.toLattice {α : Type u} [LinearOrder α] : Lattice α
+ instance : CategoryStruct (Pairwise ι)
+ rootHashGeneration
+ toNat_lt''
- Lex.cons_iff
- add_div
- bind_congr
- ediv_emod_unique'
- emod_eq_add_self_emod
- emod_lt
- eq_or_lt_of_le
- ge_of_eq
- instance (priority := 100) LinearOrder.toLattice {α : Type u} [o : LinearOrder α] : Lattice α
- le_of_eq
- le_of_mul_le_mul_right
- le_or_lt
- le_rfl
- lt_iff_le_and_ne
- lt_of_le_of_lt
- lt_of_lt_of_le
- lt_or_eq_of_le
- lt_or_le
- lt_or_lt_of_ne
- mul_mod_mod
- natAbs_ediv
- natCast_succ
- toNat_le
- toNat_le_toNat
- toNat_lt'
- toNat_lt_toNat
- zero_le_ofNat

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


Increase in tech debt: (relative, absolute) = (4.67, 0.71)
Current number Change Type
1770 -16 porting notes
129 37 adaptation notes
7 3 maxHeartBeats modifications

Current commit f083a36ccd
Reference commit 8c10b57e9a

You can run this locally as

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

Comment on lines +77 to +83
section

open Lean Elab Tactic in
/-- A helper tactic for `aesop_cat` and `Pairwise`. -/
def pairwiseCases : TacticM Unit := do
evalTactic (← `(tactic| casesm* (_ : Pairwise _) ⟶ (_ : Pairwise _)))

attribute [local aesop safe tactic (rule_sets := [CategoryTheory])] pairwiseCases in
instance : Category (Pairwise ι) where
Hom := Hom
id := id
comp f g := comp f g

end
comp := @comp _
id_comp f := by cases f <;> rfl
comp_id f := by cases f <;> rfl
assoc f g _ := by cases f <;> cases g <;> rfl

ghost Mar 31, 2025

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.

Do we know what happened here?

ghost Mar 31, 2025

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.

Splitting the construction into CategoryStruct stage, and then a Category stage allows us to keep the automation:

instance : CategoryStruct (Pairwise ι) where
  Hom := Hom
  id := id
  comp := @comp _

section

open Lean Elab Tactic in
/-- A helper tactic for `aesop_cat` and `Pairwise`. -/
def pairwiseCases : TacticM Unit := do
  evalTactic (← `(tactic| casesm* (_ : Pairwise _) ⟶ (_ : Pairwise _)))

attribute [local aesop safe tactic (rule_sets := [CategoryTheory])] pairwiseCases in
instance : Category (Pairwise ι) where

end

ghost Mar 31, 2025

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.

I've pushed this.

ghost Mar 31, 2025

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.

My thinking here was that the automation was many more bytes than doing it directly, and the automation helped work around the fact that the fields weren't seeing the actual provided definition for comp. Maybe what I did was too big of a change for a bump PR though.

Comment thread Mathlib/Algebra/Lie/Quotient.lean Resolved
Comment thread Mathlib/CategoryTheory/Square.lean Resolved
instance (i : ι) : Inhabited (Pair d i) :=
⟨{ (empty : NormalWord d) with
head := 1,
head := 1, tail := _,

ghost Mar 31, 2025

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.

Suggested change
head := 1, tail := _,
head := 1,
tail := _,

ghost Mar 31, 2025

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.

To be fully explicit, we could also replace this with

instance (i : ι) : Inhabited (Pair d i) :=
  ⟨{ head := 1,
     tail := empty.toWord,
     fstIdx_ne := fun h => by cases h
     normalized := empty.normalized }⟩

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow! This change to core Lean has caused a lot of disruption but the vast vast majority of it is positive: there are many dsimps which are removed and the addition of various explicit structure fields I think makes the library better not worse (having them solved by unification is all very clever-clever but it's also super-obscure). I left a couple of comments. Do we understand why all those norm_mul_self_les needed to be added in the CStarAlgebra directory? But overall L(V)GTM

relation := by rintro ⟨⟩
toSolution := Relations.solutionFinsupp _
toIsPresentation := Relations.solutionFinsupp_isPresentation _
toIsPresentation := by exact Relations.solutionFinsupp_isPresentation _

ghost Mar 31, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
toIsPresentation := by exact Relations.solutionFinsupp_isPresentation _
#adaptation_note /-- 2025-03-29 lean4#7717 Needed to add `by exact` -/
toIsPresentation := by exact Relations.solutionFinsupp_isPresentation _

Or do you understand why this happened and it's expected?

ghost Mar 31, 2025

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.

Assigning to parent projections is complicated, and there are some complicated dependent types here. It used to be that only some parent projections could be assigned, and now all of them can be. For uniformity, they're all handled in the same way; the expression is lifted to a let and that value is used to fill in fields; as a later step, fields are combined when possible. This code was previously taking advantage of how toSolution and toIsPresentation were actual fields in the underlying constructor.

This is what this particular expression expands to.

def Module.presentationFinsupp.{w₀, w₁, u} : (A : Type u) → [inst : Ring A] → (G : Type w₀) → Presentation A (G →₀ A) :=
fun A [Ring A] G ↦
  let __Solution :=
    { G := G, R := PEmpty.{w₁ + 1}, relation := fun r ↦ PEmpty.casesOn (fun x ↦ G →₀ A) r }.solutionFinsupp;
  let __IsPresentation := Relations.solutionFinsupp_isPresentation
    { G := G, R := PEmpty.{u_2 + 1}, relation := fun r ↦ PEmpty.casesOn (fun x ↦ G →₀ A) r };
  { G := G, R := PEmpty.{w₁ + 1}, relation := fun r ↦ PEmpty.casesOn (fun x ↦ G →₀ A) r, toSolution := __Solution,
    toIsPresentation := __IsPresentation }

Somehow, the by exact is deferring elaboration long enough to keep some bad unification from happening.

It's possible there's some deeper problem that needs fixing, so it's worth adding the adaptation note to keep track of it.


#adaptation_note /-- 2025-03-29 for lean4#7717 had to add `norm_mul_self_le` field. -/
instance [NonUnitalCStarAlgebra A] : NonUnitalCStarAlgebra C(α, A) where
norm_mul_self_le := CStarRing.norm_mul_self_le

ghost Mar 31, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@j-loreaux do you understand why this is happening? A lot of norm_mul_self_les are being added manually now. @kmill are you able to add a comment somewhere explaining this fallout? It is one of very few "negative" changes in this PR.

ghost Mar 31, 2025

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.

Yes, this issue is on my radar. I have a brief comment about it on Zulip.

The problem is that the type of the CStarRing parent depends on the fields of NonUnitalCStarAlgebra, and that's inhibiting it from using any pre-existing instances. It's unclear what the underlying issue is yet, but I hope there will be a reasonable fix.

Comment thread MathlibTest/TermReduce.lean Resolved
Kim Morrison added 2 commits April 1, 2025 09:57
Comment thread Mathlib/Order/RelSeries.lean Resolved
@kim-em

ghost commented Apr 1, 2025

Copy link
Copy Markdown
Contributor Author

bors merge

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Apr 1, 2025
@mathlib-bors

ghost commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

Pull request successfully merged into bump/v4.19.0.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title chore: adaptations for nightly-2025-03-31 [Merged by Bors] - chore: adaptations for nightly-2025-03-31 Apr 1, 2025
@mathlib-bors mathlib-bors Bot closed this Apr 1, 2025
@mathlib-bors
mathlib-bors Bot deleted the bump/nightly-2025-03-31 branch April 1, 2025 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants