Repository navigation
Conversation
The old behaviour caused `eq.mpr`'s in `pi_instance` output.
jcommelin
left a comment
There was a problem hiding this comment.
Looks very good to me. Thanks for doing this 🎉
I've flagged places where the instance priority is changed. This is something that we might want to discuss a bit.
I've also flagged places where proofs "downgraded". (Many proofs have moved around, so I probably didn't catch all of these cases.) We might want to discuss/investigate.
|
|
||
| universes u v w | ||
|
|
||
| local attribute [instance, priority 1001] |
There was a problem hiding this comment.
I can't comment on whether this is a good setting. I don't understand the priorities well enough, so I would like a second pair of eyes here.
| (⇑((@finset.univ _ hs.fintype).sum (λ x, (linear_map.proj x : (s → ℝ) →ₗ[ℝ] ℝ).smul_right x.1))) '' | ||
| (@std_simplex _ hs.fintype) := | ||
| (⇑((@finset.univ _ hs.fintype).sum | ||
| (λ x, (@linear_map.proj ℝ s _ (λ i, ℝ) _ _ x).smul_right x.1))) '' |
| section prio | ||
| set_option default_priority 100 -- see Note [default priority] | ||
| -- see Note[vector space definition] for why we extend `module`. | ||
| set_option default_priority 920 -- see Note [default priority]. Here, we set a rather high priority, |
| definitions are given in terms of semirings, but many applications use rings or fields. We increase | ||
| a little bit its priority above 100 to try it quickly, but remaining below the default 1000 so that | ||
| more specific instances are tried first. -/ | ||
| attribute [instance, priority 200] ring.to_semiring |
There was a problem hiding this comment.
Looks good to me. But flagging this so that other reviewers can easily find it.
| open_locale classical | ||
| open finset | ||
|
|
||
| local attribute [instance, priority 1001] |
| begin | ||
| show is_linear_map R ((lsubtype_domain s : (α →₀ M) →ₗ[R] (s →₀ M)).comp | ||
| (submodule.subtype (supported M R s))), | ||
| let F : (supported M R s) ≃ (s →₀ M) := restrict_support_equiv s M, |
| apply e.symm.injective, | ||
| ext x y z, | ||
| exact H x y z, | ||
| refine ext _, |
There was a problem hiding this comment.
Do we need to tag something with @[ext] to fix this?
| end module | ||
|
|
||
| section | ||
| set_option default_priority 910 |
|
I had to fix some additional failures after merging master. One of them is the following, in and I had to change it to So, exactly the same proof, but without the dot notation. I already had to make several changes with the same flavor when fixing the library, for instance going from |
|
Thanks 🎉 bors merge |
|
Canceled. |
|
bors merge |
|
Merge conflict. |
|
🥺 bors merge |
|
Canceled. |
|
bors merge |
…module (#2848) The file `algebra/module.lean` contains the lines ``` There were several attempts to make `module` an abbreviation of `semimodule` but this makes class instance search too hard for Lean 3. ``` It turns out that this was too hard for Lean 3 until recently, but this is not too hard for Lean 3.14. This PR removes these two lines, and changes the files accordingly. This means that the basic objects of linear algebra are now semimodules over semiring, making it possible to talk about matrices with natural number coefficients or apply general results on multilinear maps to get the binomial or the multinomial formula. A linear map is now defined over semirings, between semimodules which are `add_comm_monoid`s. For some statements, you need to have an `add_comm_group`, and a `ring` or a `comm_semiring` or a `comm_ring`. I have not tried to lower the possible typeclass assumptions like this in all files, but I have done it carefully in the following files: * `algebra/module` * `linear_algebra/basic` * `linear_algebra/multilinear` * `topology/algebra/module` * `topology/algebra/multilinear` Other files can be optimised later in the same way when needed, but this PR is already big enough. I have also fixed the breakage in all the other files. It was sometimes completely mysterious (in tensor products, I had to replace several times `linear_map.id.flip` with `linear_map.flip linear_map.id`), but globally all right. I have tweaked a few instance priorities to make sure that things don't go too bad: there are often additional steps in typeclass inference, going from `ring` to `semiring` and from `add_comm_group` to `add_comm_monoid`, so I have increased their priority (putting it strictly between 100 and 1000), and adjusted some other priorities to get more canonical instance paths, fixing some preexisting weirdnesses (notably in multilinear maps). One place where I really had to help Lean is with normed spaces of continuous multilinear maps, where instance search is just too big. I am aware that this will be a nightmare to refer, but as often with big refactor it's an "all or nothing" PR, impossible to split in tiny pieces. Co-authored-by: Scott Morrison <[email protected]> Co-authored-by: Bryan Gin-ge Chen <[email protected]> Co-authored-by: sgouezel <[email protected]>
|
Pull request successfully merged into master. Build succeeded: |
…module (leanprover-community#2848) The file `algebra/module.lean` contains the lines ``` There were several attempts to make `module` an abbreviation of `semimodule` but this makes class instance search too hard for Lean 3. ``` It turns out that this was too hard for Lean 3 until recently, but this is not too hard for Lean 3.14. This PR removes these two lines, and changes the files accordingly. This means that the basic objects of linear algebra are now semimodules over semiring, making it possible to talk about matrices with natural number coefficients or apply general results on multilinear maps to get the binomial or the multinomial formula. A linear map is now defined over semirings, between semimodules which are `add_comm_monoid`s. For some statements, you need to have an `add_comm_group`, and a `ring` or a `comm_semiring` or a `comm_ring`. I have not tried to lower the possible typeclass assumptions like this in all files, but I have done it carefully in the following files: * `algebra/module` * `linear_algebra/basic` * `linear_algebra/multilinear` * `topology/algebra/module` * `topology/algebra/multilinear` Other files can be optimised later in the same way when needed, but this PR is already big enough. I have also fixed the breakage in all the other files. It was sometimes completely mysterious (in tensor products, I had to replace several times `linear_map.id.flip` with `linear_map.flip linear_map.id`), but globally all right. I have tweaked a few instance priorities to make sure that things don't go too bad: there are often additional steps in typeclass inference, going from `ring` to `semiring` and from `add_comm_group` to `add_comm_monoid`, so I have increased their priority (putting it strictly between 100 and 1000), and adjusted some other priorities to get more canonical instance paths, fixing some preexisting weirdnesses (notably in multilinear maps). One place where I really had to help Lean is with normed spaces of continuous multilinear maps, where instance search is just too big. I am aware that this will be a nightmare to refer, but as often with big refactor it's an "all or nothing" PR, impossible to split in tiny pieces. Co-authored-by: Scott Morrison <[email protected]> Co-authored-by: Bryan Gin-ge Chen <[email protected]> Co-authored-by: sgouezel <[email protected]>
The file
algebra/module.leancontains the linesIt turns out that this was too hard for Lean 3 until recently, but this is not too hard for Lean 3.14. This PR removes these two lines, and changes the files accordingly.
This means that the basic objects of linear algebra are now semimodules over semiring, making it possible to talk about matrices with natural number coefficients or apply general results on multilinear maps to get the binomial or the multinomial formula.
A linear map is now defined over semirings, between semimodules which are
add_comm_monoids. For some statements, you need to have anadd_comm_group, and aringor acomm_semiringor acomm_ring. I have not tried to lower the possible typeclass assumptions like this in all files, but I have done it carefully in the following files:algebra/modulelinear_algebra/basiclinear_algebra/multilineartopology/algebra/moduletopology/algebra/multilinearOther files can be optimised later in the same way when needed, but this PR is already big enough.
I have also fixed the breakage in all the other files. It was sometimes completely mysterious (in tensor products, I had to replace several times
linear_map.id.flipwithlinear_map.flip linear_map.id), but globally all right. I have tweaked a few instance priorities to make sure that things don't go too bad: there are often additional steps in typeclass inference, going fromringtosemiringand fromadd_comm_grouptoadd_comm_monoid, so I have increased their priority (putting it strictly between 100 and 1000), and adjusted some other priorities to get more canonical instance paths, fixing some preexisting weirdnesses (notably in multilinear maps). One place where I really had to help Lean is with normed spaces of continuous multilinear maps, where instance search is just too big.I am aware that this will be a nightmare to refer, but as often with big refactor it's an "all or nothing" PR, impossible to split in tiny pieces.