The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V34. The tactics of Mathlib

Mathlib.Tactic.DeprecateTo

5 declarations. Mathlib docs · Source

#deprecate to -- a deprecation tool

Writing

#deprecate to new_name new_name₂ ... new_nameₙ
theorem old_name : True := .intro

where new_name new_name₂ ... new_nameₙ is a sequence of identifiers produces the Try this suggestion:

theorem new_name : True := .intro

@[deprecated (since := "YYYY-MM-DD")] alias old_name := new_name

@[deprecated (since := "YYYY-MM-DD")] alias old_name₂ := new_name₂
...

@[deprecated (since := "YYYY-MM-DD")] alias old_nameₙ := new_nameₙ

where old_name old_name₂ ... old_nameₙ are the non-blacklisted declarations (auto)generated by the initial command.

TODO:

  • the "new" names come fully qualified with their namespace -- if the deprecation is happening inside a namespace X, it would be better to remove the X prefix from them;
  • preserve formatting of existing command?

def Mathlib.Tactic.DeprecateTo.mkDeprecationStx E1 #

Lean.TSyntax `ident → Lean.Name → optParam (Option String) none → Lean.Elab.Command.CommandElabM (Lean.TSyntax `command)

Produce the syntax for the command @[deprecated (since := "YYYY-MM-DD")] alias n := id.

def Mathlib.Tactic.DeprecateTo.newNames E1 #

Lean.Environment → Lean.Environment → Array Lean.Name

Returns the array of names that are in new but not in old.

def Mathlib.Tactic.DeprecateTo.renameTheorem E1 #

String → Lean.TSyntax `command → Lean.CoreM (Lean.Name × String)

If the input command is a theorem or a lemma, then it replaces the name of the resulting declaration with newName and it returns the old declaration name and the renamed command.

def Mathlib.Tactic.DeprecateTo.deprecateTo E1 #

Lean.ParserDescr

Writing

#deprecate to new_name new_name₂ ... new_nameₙ
theorem old_name : True := .intro

where new_name new_name₂ ... new_nameₙ is a sequence of identifiers produces the Try this suggestion:

theorem new_name : True := .intro

@[deprecated (since := "YYYY-MM-DD")] alias old_name := new_name

@[deprecated (since := "YYYY-MM-DD")] alias old_name₂ := new_name₂
...

@[deprecated (since := "YYYY-MM-DD")] alias old_nameₙ := new_nameₙ

where old_name old_name₂ ... old_nameₙ are the non-blacklisted declarations (auto)generated by the initial command.

The "YYYY-MM-DD" entry is today's date and it is automatically filled in.

#deprecate to makes an effort to match old_name, the "visible" name, with new_name, the first identifier produced by the user. The "old", autogenerated declarations old_name₂ ... old_nameₙ are retrieved in alphabetical order. In the case in which the initial declaration produces at most 1 non-blacklisted declarations besides itself, the alphabetical sorting is irrelevant.

Technically, the command also take an optional String argument to fill in the date in since. However, its use is mostly intended for debugging purposes, where having a variable date would make tests time-dependent.

def Mathlib.Tactic.DeprecateTo.oldStx E1 #

Lean.ParserDescr

Writing

#deprecate to new_name new_name₂ ... new_nameₙ
theorem old_name : True := .intro

where new_name new_name₂ ... new_nameₙ is a sequence of identifiers produces the Try this suggestion:

theorem new_name : True := .intro

@[deprecated (since := "YYYY-MM-DD")] alias old_name := new_name

@[deprecated (since := "YYYY-MM-DD")] alias old_name₂ := new_name₂
...

@[deprecated (since := "YYYY-MM-DD")] alias old_nameₙ := new_nameₙ

where old_name old_name₂ ... old_nameₙ are the non-blacklisted declarations (auto)generated by the initial command.

The "YYYY-MM-DD" entry is today's date and it is automatically filled in.

#deprecate to makes an effort to match old_name, the "visible" name, with new_name, the first identifier produced by the user. The "old", autogenerated declarations old_name₂ ... old_nameₙ are retrieved in alphabetical order. In the case in which the initial declaration produces at most 1 non-blacklisted declarations besides itself, the alphabetical sorting is irrelevant.

Technically, the command also take an optional String argument to fill in the date in since. However, its use is mostly intended for debugging purposes, where having a variable date would make tests time-dependent.