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.FunProp.ToBatteries

9 declarations. Mathlib docs · Source

funProp missing function from standard library

def Mathlib.Meta.FunProp.isOrderedSubsetOf E1 #

{α : Type u_1} → [Inhabited α] → [DecidableEq α] → Array α → Array α → Bool

Check if a can be obtained by removing elements from b.

def Lean.Expr.swapBVars E1 #

Lean.Expr → ℕ → ℕ → Lean.Expr

Swaps bvars indices i and j

NOTE: the indices i and j do not correspond to the n in bvar n. Rather they behave like indices in Expr.lowerLooseBVars, Expr.liftLooseBVars, etc.

TODO: This has to have a better implementation, but I'm still beyond confused with how bvar indices work

def Mathlib.Meta.FunProp.mkProdElem E1 #

Array Lean.Expr → Lean.MetaM Lean.Expr

For #[x₁, .., xₙ] create (x₁, .., xₙ).

def Mathlib.Meta.FunProp.mkProdProj E1 #

Lean.Expr → ℕ → ℕ → Lean.MetaM Lean.Expr

For (x₀, .., xₙ₋₁) return xᵢ but as a product projection.

We need to know the total size of the product to be considered.

For example for xyz : X × Y × Z

  • mkProdProj xyz 1 3 returns xyz.snd.fst.
  • mkProdProj xyz 1 2 returns xyz.snd.

def Mathlib.Meta.FunProp.mkProdSplitElem E1 #

Lean.Expr → ℕ → Lean.MetaM (Array Lean.Expr)

For an element of a product type (of size n) xs create an array of all possible projections i.e. #[xs.1, xs.2.1, xs.2.2.1, ..., xs.2..2]

def Mathlib.Meta.FunProp.mkUncurryFun E1 #

ℕ → Lean.Expr → Lean.MetaM Lean.Expr

Uncurry function f in n arguments.

def Mathlib.Meta.FunProp.etaExpand1 E1 #

Lean.Expr → Lean.MetaM Lean.Expr

Eta expand f in only one variable and reduce in others.

Examples:

  f                ==> fun x => f x
  fun x y => f x y ==> fun x => f x
  HAdd.hAdd y      ==> fun x => HAdd.hAdd y x
  HAdd.hAdd        ==> fun x => HAdd.hAdd x

def Mathlib.Meta.FunProp.betaThroughLet E1 #

Lean.Expr → Array Lean.Expr → Lean.Expr

Apply the given arguments to f, beta-reducing if f is a lambda expression. This variant does beta-reduction through let bindings without inlining them.

Example

beta' (fun x => let y := x * x; fun z => x + y + z) #[a,b]
==>
let y := a * a; a + y + b

def Mathlib.Meta.FunProp.headBetaThroughLet E1 #

Lean.Expr → Lean.Expr

Beta reduces head of an expression, (fun x => e) a ==> e[x/a]. This version applies arguments through let bindings without inlining them.

Example

headBeta' ((fun x => let y := x * x; fun z => x + y + z) a b)
==>
let y := a * a; a + y + b