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.Translate.UnfoldBoundary

24 declarations. Mathlib docs · Source

Modify proof terms so that they don't rely on unfolding certain constants

This file defines a procedure for inserting casts into (proof) terms in order to make them well typed in a setting where certain constants aren't allowed to be unfolded.

We make use of withCanUnfoldPred in order to modify which constants can and cannot be unfolded. This way, whnf and isDefEq do not unfold these constants.

So, the procedure is to check that an expression is well typed, analogous to Meta.check, and at each type mismatch, we try to insert a cast.

There are two kinds of casts:

  • Equality casts. This is for propositions and terms, where it is possible to prove that one is equal to the other. For example Monotone.
  • Explicit casting functions, both for unfolding and refolding. This is for types, where we cannot express their equivalence with an equality. For example DecidableLE.

def Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.ctorIdx E1 #

Mathlib.Tactic.UnfoldBoundary.UnfoldEntry → ℕ

theorem Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.unfold.injEq E0 #

∀ (declName unfold declName_1 unfold_1 : Lean.Name),
  (Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.unfold declName unfold =
      Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.unfold declName_1 unfold_1) =
    (declName = declName_1 ∧ unfold = unfold_1)

theorem Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.mk.inj E1 #

∀ {unfolds : Lean.NameMap Lean.Meta.SimpTheorem} {casts : Lean.NameMap (Lean.Name × Lean.Name)}
  {insertionFuns : Lean.NameSet} {unfolds_1 : Lean.NameMap Lean.Meta.SimpTheorem}
  {casts_1 : Lean.NameMap (Lean.Name × Lean.Name)} {insertionFuns_1 : Lean.NameSet},
  { unfolds := unfolds, casts := casts, insertionFuns := insertionFuns } =
      { unfolds := unfolds_1, casts := casts_1, insertionFuns := insertionFuns_1 } →
    unfolds = unfolds_1 ∧ casts = casts_1 ∧ insertionFuns = insertionFuns_1

abbrev Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.ctorElimType E1 #

{motive : Mathlib.Tactic.UnfoldBoundary.UnfoldEntry → Sort u} → ℕ → Sort (max 1 u)

def Mathlib.Tactic.UnfoldBoundary.instInhabitedUnfoldBoundaries.default E1 #

Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries

theorem Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.unfold.inj E1 #

∀ {declName unfold declName_1 unfold_1 : Lean.Name},
  Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.unfold declName unfold =
      Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.unfold declName_1 unfold_1 →
    declName = declName_1 ∧ unfold = unfold_1

theorem Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.cast.inj E1 #

∀ {declName unfold refold unfold' refold' declName_1 unfold_1 refold_1 unfold'_1 refold'_1 : Lean.Name},
  Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.cast declName unfold refold unfold' refold' =
      Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.cast declName_1 unfold_1 refold_1 unfold'_1 refold'_1 →
    declName = declName_1 ∧ unfold = unfold_1 ∧ refold = refold_1 ∧ unfold' = unfold'_1 ∧ refold' = refold'_1

theorem Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.cast.injEq E0 #

∀ (declName unfold refold unfold' refold' declName_1 unfold_1 refold_1 unfold'_1 refold'_1 : Lean.Name),
  (Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.cast declName unfold refold unfold' refold' =
      Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.cast declName_1 unfold_1 refold_1 unfold'_1 refold'_1) =
    (declName = declName_1 ∧ unfold = unfold_1 ∧ refold = refold_1 ∧ unfold' = unfold'_1 ∧ refold' = refold'_1)

theorem Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.mk.injEq E0 #

∀ (unfolds : Lean.NameMap Lean.Meta.SimpTheorem) (casts : Lean.NameMap (Lean.Name × Lean.Name))
  (insertionFuns : Lean.NameSet) (unfolds_1 : Lean.NameMap Lean.Meta.SimpTheorem)
  (casts_1 : Lean.NameMap (Lean.Name × Lean.Name)) (insertionFuns_1 : Lean.NameSet),
  ({ unfolds := unfolds, casts := casts, insertionFuns := insertionFuns } =
      { unfolds := unfolds_1, casts := casts_1, insertionFuns := insertionFuns_1 }) =
    (unfolds = unfolds_1 ∧ casts = casts_1 ∧ insertionFuns = insertionFuns_1)

def Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.ctorIdx E1 #

Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries → ℕ

structure Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries E1 #

Type

UnfoldBoundaries stores abstraction boundaries for definitions that shouldn't be unfolded.

ctor Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.mk E0 #

Lean.NameMap Lean.Meta.SimpTheorem →
  Lean.NameMap (Lean.Name × Lean.Name) → Lean.NameSet → Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries

abbrev Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.unfolds E1 #

Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries → Lean.NameMap Lean.Meta.SimpTheorem

For propositions and terms of types, we store a rewrite theorem that unfolds it.

abbrev Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.casts E1 #

Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries → Lean.NameMap (Lean.Name × Lean.Name)

For types, we store a cast for translating from and to the type respectively.

abbrev Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.insertionFuns E1 #

Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries → Lean.NameSet

The functions that we want to unfold again after the translation has happened.

instance Mathlib.Tactic.UnfoldBoundary.instInhabitedUnfoldBoundaries E0 #

Inhabited Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries

def Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.cast E1 #

Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries → Lean.Expr → Lean.Expr → Lean.Name → Lean.MetaM Lean.Expr

Modify e so that it has type expectedType if the constants in b cannot be unfolded.

def Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.insertBoundaries E1 #

Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries → Lean.Expr → Lean.Name → Lean.MetaM Lean.Expr

Modify e so that it is well typed if the constants in b cannot be unfolded.

Note: it may be that e contains some constant whose type is not well typed in this setting. We don't make an effort to replace such constants. It seems that this approximation works well enough.

def Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.unfoldInsertions E1 #

Lean.Expr → Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries → Lean.CoreM Lean.Expr

Unfold all of the auxiliary functions that were inserted as unfold boundaries.

inductive Mathlib.Tactic.UnfoldBoundary.UnfoldEntry E1 #

Type

An entry for the UnfoldBoundaries environment extension.

ctor Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.unfold E0 #

Lean.Name → Lean.Name → Mathlib.Tactic.UnfoldBoundary.UnfoldEntry

ctor Mathlib.Tactic.UnfoldBoundary.UnfoldEntry.cast E0 #

Lean.Name → Lean.Name → Lean.Name → Lean.Name → Lean.Name → Mathlib.Tactic.UnfoldBoundary.UnfoldEntry

abbrev Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaryExt E1 #

Type

Extensions for handling abstraction boundaries for definitions that shouldn't be unfolded.

def Mathlib.Tactic.UnfoldBoundary.registerUnfoldBoundaryExt E1 #

IO Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaryExt

Register a new UnfoldBoundaryExt.