Zulip Chat Archive
Stream: mathlib4
Topic: Dependencies of abel
Yaël Dillies (May 27 2024 at 06:38):
I just came to realising something really quite bad about our import tree, and I do not immediately know how to solve it.
Yaël Dillies (May 27 2024 at 06:40):
abel
depends on norm_num
to normalise numerals, and norm_num
depends on Field
to handle fractions (in fact it even depends on LinearOrderedField
to handle nonnegative fractions through NNRat
, but I'm pretty sure I know how to fix this).
Yaël Dillies (May 27 2024 at 06:41):
This means that eg the definition of docs#Module can't be made without importing LinearOrderedField
. Of course, one could just move to a later file or eliminate the uses of abel
, but that's solving the symptom, not the disease.
Yaël Dillies (May 27 2024 at 06:42):
Can we make it so that abel
, a tactic about commutative groups, does not need to know about linearly ordered fields?
Johan Commelin (May 27 2024 at 06:46):
Shouldn't the plug-in system of norm_num
mean that you can use a barebones norm_num
in abel
in low-level files, and norm_num
(and hence abel
) become more powerful once you import higher-level files?
Yaël Dillies (May 27 2024 at 06:46):
I would hope so, but currently Tactic.Abel
imports Tactic.NormNum
Johan Commelin (May 27 2024 at 06:46):
I mean, I understand that is not how it currently works... but it seems that it would be good to make it work like that.
Yaël Dillies (May 27 2024 at 06:47):
Actually, what even is the point of fractions in abel
? It's only dealing with Int
and Nat
, right?
Yaël Dillies (May 27 2024 at 06:49):
Even if we scrap the support for fractions, we still have the issue that those Int
and Nat
equalities are backed by Ring
. That's definitely better than LinearOrderedField
, but still not great
Mario Carneiro (May 27 2024 at 07:03):
I think this is not worth it. abel
uses norm_num
and norm_num
uses rational numbers in the framework code (not the add-ons). I would instead suggest pulling out a minimal version of fields which Tactic.NormNum.Core
can import, and use that whenever you need abel
; or don't use abel
and prove it by hand / by group
Yaël Dillies (May 27 2024 at 07:05):
I know that, Mario, but plenty of properties of Rat
are proved without using Field
, so I'm not convinced norm_num
really must depend on Field
Eric Wieser (May 27 2024 at 07:11):
Is the issue here the way that norm_num caches algebraic instances in it's result type?
Mario Carneiro (May 27 2024 at 07:36):
yes
Mario Carneiro (May 27 2024 at 07:36):
and also when it has to compute with them
Mario Carneiro (May 27 2024 at 07:37):
Yaël Dillies said:
I know that, Mario, but plenty of properties of
Rat
are proved without usingField
, so I'm not convincednorm_num
really must depend onField
It's not storing Rat
, it's storing rational expressions in a Field
Mario Carneiro (May 27 2024 at 07:37):
all math is performed over appropriate algebraic classes
Mario Carneiro (May 27 2024 at 07:38):
on the "programming side" that means working with Rat
but the generated proofs make no reference to Rat
and only use field axioms
Mario Carneiro (May 27 2024 at 07:41):
IMO all the lemmas etc are already being applied as late as they reasonably can be. Feel free to try to separate out the minimum requirements, but I don't think it is worth trying to cleave norm_num
into two tactics, which is what you would need to do to make it not know about/handle rational numerals
Yaël Dillies (May 27 2024 at 07:47):
I think your idea of a custom Field
typeclass could make sense
Eric Wieser (May 27 2024 at 07:50):
Removing abel
from the file that defines Module
seems like a more reasonable thing to aim for
Eric Wieser (May 27 2024 at 07:51):
Tactics are hard enough to write without making more rules about what they aren't allowed to import
Yaël Dillies (May 27 2024 at 07:53):
Okay but that doesn't solve the fact that abel
is a tactic about commutative groups
Mario Carneiro (May 27 2024 at 08:00):
no, it's more like a tactic about Z-modules
Eric Wieser (May 27 2024 at 08:01):
I suppose there could be an abel_core
tactic for early files which does not normalize numerals? (And so doesn't need norm_num)
Mario Carneiro (May 27 2024 at 08:02):
I think that's simp [add_assoc, add_left_comm, add_comm]
Mario Carneiro (May 27 2024 at 08:02):
There is no need to use abel
at all in early files
Eric Wieser (May 27 2024 at 08:03):
I've seen a lot of places where abel
can be replaced with rw [add_add_add_comm]
Yaël Dillies (May 27 2024 at 09:01):
Eric Wieser (May 27 2024 at 09:44):
I'd be happy to merge the de-abel bit, but don't have time to review the scope creep moves right now
Kim Morrison (May 28 2024 at 09:50):
Yes, this PR should be split according to paragraphs in the description, no need to do it all at once?
Yaël Dillies (May 28 2024 at 10:05):
I mean the first part is tiny? It's three lines of diff. The main part is the second one
Eric Wieser (May 28 2024 at 10:08):
Well, we can't tell that by looking at the PR; how many of the transitive import changes were caused by the abel
/rw
swap? If they were separate PRs then the answer would be obvious
Yaël Dillies (May 28 2024 at 10:55):
I've opened a separate PR #13305 and removed its diff from #13274
Kim Morrison (May 28 2024 at 12:31):
Imports aren't quite right yet, but LGTM.
Yaël Dillies (May 28 2024 at 14:45):
#13305 passes CI. #13274 will pass CI soon.
Last updated: May 02 2025 at 03:31 UTC