Zulip Chat Archive

Stream: mathlib4

Topic: Spelling `congrArg` or `congr_arg`


Martin Dvořák (Sep 14 2023 at 11:35):

Which spelling is preferred in Mathlib?
I find congr_arg more often, but congrArg is what exact? gives me.

Eric Rodriguez (Sep 14 2023 at 11:55):

:shrug: I think the new preferred style is Kyle's congr(...)

Martin Dvořák (Sep 14 2023 at 11:57):

Can I see an example?

Mario Carneiro (Sep 14 2023 at 11:57):

it's a theorem, so congr_arg

Kyle Miller (Sep 14 2023 at 12:06):

@Martin Dvořák If h : x = y you can write congr(f $h) to get f x = f y

Eric Wieser (Sep 14 2023 at 12:13):

Mario Carneiro said:

it's a theorem, so congr_arg

Can we just remove the other spelling?

Martin Dvořák (Sep 14 2023 at 12:14):

Do we have power to rename the declaration in Init.Prelude please?

Mario Carneiro (Sep 14 2023 at 12:14):

it's in core

Martin Dvořák (Sep 14 2023 at 12:14):

Kyle Miller said:

Martin Dvořák If h : x = y you can write congr(f $h) to get f x = f y

Is there a motivation for this particular syntax?

Mario Carneiro (Sep 14 2023 at 12:14):

there is a PR which does this which has been sitting for 6+ months

Martin Dvořák (Sep 14 2023 at 12:16):

In the meanwhile, can I PR a replacement of all congrArg in Mathlib?

Mario Carneiro (Sep 14 2023 at 12:16):

actually almost a year lean4#1897

Mario Carneiro (Sep 14 2023 at 12:19):

can you mark a theorem in another file as deprecated?

Mario Carneiro (Sep 14 2023 at 12:20):

invalid attribute 'deprecated', declaration is in an imported module :sad:

Martin Dvořák (Sep 14 2023 at 12:20):

I don't know what you mean.
I would just replace all these
https://github.com/search?q=repo%3Aleanprover-community%2Fmathlib4+congrArg&type=code
by congr_arg as we prefer.

Mario Carneiro (Sep 14 2023 at 12:21):

there is a really nifty mechanism I added to core std to make it easy to find and replace deprecated things

Mario Carneiro (Sep 14 2023 at 12:22):

import Std

def foo := 1
@[deprecated] alias bar := foo

example : bar = 1 := rfl
       -- ^^ code action here

Mario Carneiro (Sep 14 2023 at 12:23):

unfortunately it only works when the alias is the one being deprecated, not the target

Eric Wieser (Sep 14 2023 at 12:23):

Mario Carneiro said:

there is a PR which does this which has been sitting for 6+ months

I think this PR suffers from making too many renames at once

Mario Carneiro (Sep 14 2023 at 12:24):

you're not wrong, it was discussed in the dev meeting and all but one or two categories was accepted

Mario Carneiro (Sep 14 2023 at 12:27):

unfortunately I forget most of the results of the meeting. I think Membership.Mem was rejected and either IsLawfulFunctor or OptParam was contentious

Eric Wieser (Sep 14 2023 at 12:28):

Presumably a Pr to rename just congrArg would be fine?

Martin Dvořák (Sep 14 2023 at 12:29):

And congrFun at the same time.

Eric Wieser (Sep 14 2023 at 12:29):

It seems the highest-value renames are the ones where mathlib has decided it has to make an alias because of a "bad" name in core

Martin Dvořák (Sep 14 2023 at 12:31):

FYI, there are quite a few aliases in Mathlib.Init.Logic including these:

alias proofIrrel  proof_irrel
alias congrFun  congr_fun
alias congrArg  congr_arg

Mario Carneiro (Sep 14 2023 at 12:31):

do we have aliases for T.constr.inj_eq?

Eric Wieser (Sep 14 2023 at 12:32):

Ok, so maybe the low hanging fruit is:

  • A PR that makes all 14 replacements in Mathlib.Init.Logic
  • Another PR that changes all the generated names

Mario Carneiro (Sep 14 2023 at 12:32):

I think that's the only generated name in my list

Eric Wieser (Sep 14 2023 at 12:33):

On the first point; why is docs#eq_rec_heq preferred to docs#eqRec_heq ?

Mario Carneiro (Sep 14 2023 at 12:34):

is that an alias?

Eric Wieser (Sep 14 2023 at 12:34):

Yes

Mario Carneiro (Sep 14 2023 at 12:35):

it was written very early on in mathlib4 history, before we had decided what to do about namespaced names and mostly only had the guidance "theorems are snake cased"

Eric Wieser (Sep 14 2023 at 12:35):

I think this is a gap in #naming where we don't say whether to tokenize Foo.barBaz as foo_barBaz_eq or fooBarBaz_eq

Mario Carneiro (Sep 14 2023 at 12:37):

I think we now have a decent amount of precedent in the form of natCast_add et al that they should be treated as one name including namespaces (when needed for disambiguation)

Eric Wieser (Sep 14 2023 at 12:37):

I don't think this thread ever reached a consensus

Martin Dvořák (Sep 14 2023 at 12:37):

Kyle Miller said:

Martin Dvořák If h : x = y you can write congr(f $h) to get f x = f y

Is this syntax useful for Mathlib?

Mario Carneiro (Sep 14 2023 at 12:38):

I guess we proceeded in spite of a poll that is mildly negative to this conclusion

Eric Wieser (Sep 14 2023 at 12:38):

Mario Carneiro said:

I think we now have a decent amount of precedent in the form of natCast_add et al that they should be treated as one name including namespaces (when needed for disambiguation)

We also have quite a lot of things of the form docs#map_multiset_sum, so I'd argue there's no established convention

Mario Carneiro (Sep 14 2023 at 12:39):

in that case it seems fine to just have the alias

Eric Wieser (Sep 14 2023 at 12:39):

(besides establishing a lack of convention)

Eric Wieser (Sep 14 2023 at 12:40):

I've revived the old thread to discuss this further. I suggest we don't rename eqRec_heq in core for now, and only make the other 13 renames.

Mario Carneiro (Sep 14 2023 at 12:40):

what are the 13?

Kyle Miller (Sep 14 2023 at 12:43):

@Martin Dvořák Have you read the documentation for the syntax? You can take a look at docs#Mathlib.Tactic.TermCongr.termCongr and see more examples all in one place in the test/TermCongr.lean file.

Eric Wieser (Sep 14 2023 at 12:49):

Mario Carneiro said:

what are the 13?

Sorry, 12:

alias proof_irrel := proofIrrel
alias congr_fun := congrFun
alias congr_arg := congrArg

alias Or.decidable := instDecidableOr
alias And.decidable := instDecidableAnd
alias Not.decidable := instDecidableNot
alias Iff.decidable := instDecidableIff
alias decidableTrue := instDecidableTrue
alias decidableFalse := instDecidableFalse

alias by_cases := byCases
alias by_contradiction := byContradiction
alias not_not_iff := not_not

Eric Wieser (Sep 14 2023 at 12:49):

I guess the decidable aliases are bad too, so really only 4 should be moved to core:

alias proof_irrel := proofIrrel
alias congr_fun := congrFun
alias congr_arg := congrArg

alias Decidable.by_contradiction := Decidable.byContradiction

Mario Carneiro (Sep 14 2023 at 12:50):

yeah they don't look very important, although I don't think you will get much pushback

Mario Carneiro (Sep 14 2023 at 12:50):

in fact they look like what you will get if you just delete the name

Mario Carneiro (Sep 14 2023 at 12:51):

oh wait I'm reading them backward

Yaël Dillies (Sep 14 2023 at 12:51):

I would have expected something like

alias Or.instDecidable := instDecidableOr
alias And.instDecidable := instDecidableAnd
alias Not.instDecidable  := instDecidableNot
alias Iff.instDecidable  := instDecidableIff
alias decidableTrue := instDecidableTrue
alias decidableFalse := instDecidableFalse

Mario Carneiro (Sep 14 2023 at 12:52):

those decidable aliases look like a good opportunity to test out @[deprecated] alias :smiley:

Eric Wieser (Sep 14 2023 at 12:53):

I think it's probably best not to make any PRs renaming instances in core; that's best left to the proposal to change the naming heuristics

Mario Carneiro (Sep 14 2023 at 12:54):

(the point of my comment was to replace uses of the alias in mathlib)

Mario Carneiro (Sep 14 2023 at 12:55):

I think we should always try to keep the naming convention for instances close to the autogenerated name because people will have to deal with both anyway

Kevin Buzzard (Sep 14 2023 at 12:57):

Don't we also have infer_instance and inferInstance?

Scott Morrison (Sep 14 2023 at 12:57):

That one is tactic vs term.

Mario Carneiro (Sep 14 2023 at 12:58):

unfortunately that's per the naming convention

Mario Carneiro (Sep 14 2023 at 12:58):

although actually both are bad

Mario Carneiro (Sep 14 2023 at 12:59):

the lean 3 apply_instance would call typeclass inference to fill your term, the lean 4 infer_instance is just exact inferInstance which infers the goal as an argument of the inferInstance no-op function

Mario Carneiro (Sep 14 2023 at 12:59):

which means the term ends up with some extra garbage

Mario Carneiro (Sep 14 2023 at 13:01):

by the way my list had byCases in the same category as byContradiction

Eric Wieser (Sep 14 2023 at 13:21):

docs#Decidable.byCases is special because it's sort-valued

Eric Wieser (Sep 14 2023 at 13:21):

So having both versions of the name seems to fit the naming conventions

Yuyang Zhao (Sep 15 2023 at 11:55):

Do we need to rename docs#Quotient.inductionOn (and ' versions)?

Eric Wieser (Sep 15 2023 at 12:13):

Yes, I think so; though I think if we want any hope of these being merged they should be separate PRs


Last updated: Dec 20 2023 at 11:08 UTC