Zulip Chat Archive

Stream: mathlib4

Topic: deprecated lean3-ism convention


James Gallicchio (Jan 31 2023 at 20:52):

is there a convention for naming theorems that should be deprecated but are ported for backwards compatibility? i'd rather avoid potentially-useful names like (lean3) perm_induction_on -> (lean4) perm_induction_on'.

would perm_induction_on_deprecated or perm_induction_on_old be acceptable?

Mario Carneiro (Jan 31 2023 at 20:54):

the usual convention is just @[deprecated] def perm_induction_on, unless you want something else to take the name

Mario Carneiro (Jan 31 2023 at 20:56):

(just in case this has to do with a certain std4 PR: don't PR things that are deprecated from the start, just remove them and keep them in mathlib)

James Gallicchio (Jan 31 2023 at 20:58):

I think in this case we would like to have a lemma called perm_induction_on, but its statement will be different from the mathlib3 perm_induction_on :/

James Gallicchio (Jan 31 2023 at 20:59):

(and I'd rather rename the deprecated version than the desired version...)

James Gallicchio (Jan 31 2023 at 21:01):

If there's no convention, I'll just rename the lean3 version to perm_induction_on_old. Seems reasonable enough.

Mario Carneiro (Jan 31 2023 at 21:05):

James Gallicchio said:

I think in this case we would like to have a lemma called perm_induction_on, but its statement will be different from the mathlib3 perm_induction_on :/

In that case, you should name the other one to perm_induction_on', and use #align to ensure that mathlib uses go to the deprecated one

Yury G. Kudryashov (Jan 31 2023 at 21:06):

What will be the difference between lemmas?

Yury G. Kudryashov (Jan 31 2023 at 21:07):

E.g., for list.repeat vs list.replicate, I just backported the change.

James Gallicchio (Jan 31 2023 at 21:07):

It changes the induction principle statement to work with the new elab_as_elim stuff. So it's a lean4-specific change.

Mario Carneiro (Jan 31 2023 at 21:08):

but how specifically?

Mario Carneiro (Jan 31 2023 at 21:08):

it's not necessarily a lean4 specific change if it also works in lean 3

James Gallicchio (Jan 31 2023 at 21:09):

The comment from the ad-hoc port was:

/-- The way Lean 4 computes the motive with `elab_as_elim` has changed
relative to the behaviour of `elab_as_eliminator` in Lean 3.
See
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Potential.20elaboration.20bug.20with.20.60elabAsElim.60/near/299573172
for an explanation of the change made here relative to mathlib3.
-/

Mario Carneiro (Jan 31 2023 at 21:09):

that is missing the important part of the definition :)

Yury G. Kudryashov (Jan 31 2023 at 21:10):

Can you just copy+paste the statements of 2 lemmas?

James Gallicchio (Jan 31 2023 at 21:10):

theorem perm_induction_on
    {P : (l₁ : List α)  (l₂ : List α)  l₁ ~ l₂  Prop} {l₁ l₂ : List α} (p : l₁ ~ l₂)
    (nil : P [] [] .nil)
    (cons :  x l₁ l₂, (h : l₁ ~ l₂)  P l₁ l₂ h  P (x :: l₁) (x :: l₂) (.cons x h))
    (swap :  x y l₁ l₂, (h : l₁ ~ l₂)  P l₁ l₂ h 
      P (y :: x :: l₁) (x :: y :: l₂) (.trans (.swap x y _) (.cons _ (.cons _ h))))
    (trans :  l₁ l₂ l₃, (h₁ : l₁ ~ l₂)  (h₂ : l₂ ~ l₃)  P l₁ l₂ h₁  P l₂ l₃ h₂ 
      P l₁ l₃ (.trans h₁ h₂)) : P l₁ l₂ p := ...

theorem perm_induction_on {P : List α  List α  Prop} {l₁ l₂ : List α} (p : l₁ ~ l₂) (h₁ : P [] [])
    (h₂ :  x l₁ l₂, l₁ ~ l₂  P l₁ l₂  P (x :: l₁) (x :: l₂))
    (h₃ :  x y l₁ l₂, l₁ ~ l₂  P l₁ l₂  P (y :: x :: l₁) (x :: y :: l₂))
    (h₄ :  l₁ l₂ l₃, l₁ ~ l₂  l₂ ~ l₃  P l₁ l₂  P l₂ l₃  P l₁ l₃) : P l₁ l₂ := ...

James Gallicchio (Jan 31 2023 at 21:10):

top is the new one

Mario Carneiro (Jan 31 2023 at 21:11):

it seems fine to me, lean 3 uses probably won't even notice the difference

Mario Carneiro (Jan 31 2023 at 21:11):

so a backport should just work

Mario Carneiro (Jan 31 2023 at 21:11):

unless the motive is being provided explicitly but that's a relatively easy fix

James Gallicchio (Jan 31 2023 at 21:12):

Hum, okay. Are there instructions on how to do backports?

Mario Carneiro (Jan 31 2023 at 21:13):

it's like any other mathlib3 change that may touch a ported file, you make the mathlib3 change and a parallel mathlib4 change

Eric Wieser (Jan 31 2023 at 21:39):

For heavier changes, it can be easier to make the mathlib3 change and wait for mathlib3port to regenerate before making the mathlib4 change


Last updated: Dec 20 2023 at 11:08 UTC