feat(RingTheory/MvPowerSeries/NoZeroDivisors): simplify the proof by adding two instances#36892
Conversation
PR summary b43655dfe2Import changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diff
You can run this locally as follows## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/pr_summary/declarations_diff.sh long <optional_commit>The doc-module for No changes to technical debt.You can run this locally as
|
|
Can we add |
|
Note that the dual instance gets different discrimination tree keys. The whole situation seems a bit dodgy Recall that |
|
@eric-wieser, could you please have a look? This comes from the discussion in #mathlib4 > help in RingTheory.MvPowerSeries.NeZeroDivisors; it looks ok to me but I might be missing something. |
|
In my opinion, |
|
Sorry for dropping the ball here; I had not thought to look at the discrimination trees, and indeed these seem like a mark against this strategy. I'll investigate a little more now. |
|
Note also that there does not exist anything similar to |
|
I will try to do as @JovanGerb requested. On the other hand, I would like to have a better understanding of the discussion — could you give me pointers to this question of discrimination trees, I'm ashamed to admit that I can't even parse Lean's output in Jovan's message. |
|
|
||
| variable (α) in | ||
| /-- The **well-ordering theorem** (or **Zermelo's theorem**): every type has a well-order -/ | ||
| theorem exists_wellOrder : ∃ (_ : LinearOrder α), WellFoundedLT α := by |
There was a problem hiding this comment.
Perhaps this should be renamed exists_wellFoundedLT? And perhaps we can generate the other one via to_dual? (or at least tag it with to_dual existing)
There was a problem hiding this comment.
About the renaming, I'm OK for that, it's only used four or five times. But WellFoundedLT doesn't impose LinearOrder, so I'm not sure that the name will truly reflect what is done. (And the remark applies to the new version exists_wellFoundedLT). Give a firm order and I'll do it.
There was a problem hiding this comment.
I do not understand the remark about to_dual, because at that point, one has no LinearOrder on the type.
There was a problem hiding this comment.
The previous name is even worse imo since we don't have anything called WellOrder (save for an auxiliary structure in the definition of ordinals, which this is not about). If you think this should reference linearOrder then why not exists_linearOrder_wellFoundedLT? Though this feels a bit verbose and I still prefer exists_wellFoundedLT.
Maybe this change can be split out of the PR? Seems like the stuff with LinearOrder.swap is a bit controversial, and the new WellFoundedGT theorem seems like a good, orthogonal change.
There was a problem hiding this comment.
I do not understand the remark about
to_dual, because at that point, one has no LinearOrder on the type.
Does to_dual existing not work regardless?
There was a problem hiding this comment.
Maybe @AntoineChambert-Loir is not familiar with the @[to_dual] attribute for generating dual versions of declarations?
There was a problem hiding this comment.
Indeed, I hadn't understood that it was similar to @[to_additive], I confused it with something applied to OrderDual.
Now, to_dual doesn't work, but to_dual existing worked. I also renamed the thing.
|
As far as I know, there isn't really a comprehensive writeup of what discrimination trees do in Lean. I should maybe write some :). In short a discrimination tree is a data structure for storing and looking up expression patterns. The is used in simp and in type class search in order to get a list of candidate simp lemmas or candidate instances. Each simp lemma/instance is stored in the discrimination tree using a list of discrimination tree keys. It's helpful to know what the keys for a specific lemma/instance are, because if the keys are wrong/too specific, it may not get found. And on the other hand if the keys are too general, then it will be found too often, which is bad for performance. |
|
But I think the discrimination tree keys aren't the main reason why I didn't like the instance. Rather, I had a problem with the swapping of the order in the funny LinearOrder instance. Instead, using |
|
I don't see how to use |
| let : LinearOrder σ := (exists_wellFoundedGT σ).choose | ||
| have : WellFoundedGT σ := (exists_wellFoundedGT σ).choose_spec |
There was a problem hiding this comment.
Rather than using choose and choose_spec, you should be able to use rcases, right?
There was a problem hiding this comment.
Yes. Is it better?
Well, |
|
Wouldn't it be tantamount to the proof to which the first round of review objected! |
|
This PR is only 16 lines, I rewrote the description and it looks fairly coherent to me. May I beg you not to ask me to split into two or three tiny parts? |
| ⟨⟨WellOrderingRel, inferInstance⟩⟩ | ||
|
|
||
| /-- This instance is about `WellOrderingRel.isWellOrder.linearOrder`. -/ | ||
| instance WellFoundedLT.wellOrderingRel : |
There was a problem hiding this comment.
Do we need this instance in this PR? I would be against adding it.
There was a problem hiding this comment.
This is the other one suggested by Eric. The (initial) point was to remove the defeq abuses related to LinearOrder.swap, maybe that one is no more necessary.
There was a problem hiding this comment.
I'm commenting it out, and if that compiles, which it should, I'll remove it.
There was a problem hiding this comment.
(This PR started doing something, and made something else, probably cleaner, maybe that's the joy of collaborative work!)
Clean up unwanted declarations regarding to well-orderings.
exists_wellFoundedGTthat gives a linear ordering that satisfiesWellFoundedGTexists_wellOrdertoexists_wellFoundedLT, deprecate the previous name, and addto_dual existingto relate the two functions.WellFoundedLT.wellOrderingRelsuggested by @eric-wieser :WellOrderingRel.isWellOrdersatisfiesWellFoundedLTMvPowerSeries.NoZeroDivisorsthat the power series rings over a ring without zero divisors has no zero divisors, where the opposite of a “anti-well ordering” was needed.LinearOrder.swapwhich abuses defeq (and was only used once for that proof).Ref. #mathlib4 > help in RingTheory.MvPowerSeries.NeZeroDivisors