Documentation

Mathlib.Data.Fin.Tuple.Curry

Currying and uncurrying of n-ary functions #

A function of n arguments can either be written as f a₁ a₂ ⋯ aₙ or f' ![a₁, a₂, ⋯, aₙ]. This file provides the currying and uncurrying operations that convert between the two, as n-ary generalizations of the binary curry and uncurry.

Main definitions #

def Function.FromTypes.uncurry {n : } {p : Fin nType u} {τ : Type u} (f : FromTypes p τ) :
((i : Fin n) → p i)τ

Uncurry all the arguments of Function.FromTypes p τ to get a function from a tuple.

Note this can be used on raw functions if used.

Equations
def Function.FromTypes.curry {n : } {p : Fin nType u} {τ : Type u} :
(((i : Fin n) → p i)τ)FromTypes p τ

Curry all the arguments of Function.FromTypes p τ to get a function from a tuple.

Equations
@[simp]
theorem Function.FromTypes.uncurry_apply_cons {n : } {α : Type u} {p : Fin nType u} {τ : Type u} (f : FromTypes (Matrix.vecCons α p) τ) (a : α) (args : (i : Fin n) → p i) :
f.uncurry (Fin.cons a args) = (f a).uncurry args
@[simp]
theorem Function.FromTypes.uncurry_apply_succ {n : } {p : Fin (n + 1)Type u} {τ : Type u} (f : FromTypes p τ) (args : (i : Fin (n + 1)) → p i) :
f.uncurry args = (f (args 0)).uncurry (Fin.tail args)
@[simp]
theorem Function.FromTypes.curry_apply_cons {n : } {α : Type u} {p : Fin nType u} {τ : Type u} (f : ((i : Fin (n + 1)) → Matrix.vecCons α p i)τ) (a : α) :
curry f a = curry ((fun {x : (i : Fin n) → Matrix.vecCons α p i.succ} => f) ∘' Fin.cons a)
@[simp]
theorem Function.FromTypes.curry_apply_succ {n : } {p : Fin (n + 1)Type u} {τ : Type u} (f : ((i : Fin (n + 1)) → p i)τ) (a : p 0) :
@[simp]
theorem Function.FromTypes.curry_uncurry {n : } {p : Fin nType u} {τ : Type u} (f : FromTypes p τ) :
@[simp]
theorem Function.FromTypes.uncurry_curry {n : } {p : Fin nType u} {τ : Type u} (f : ((i : Fin n) → p i)τ) :
def Function.FromTypes.curryEquiv {n : } {τ : Type u} (p : Fin nType u) :
(((i : Fin n) → p i)τ) FromTypes p τ

Equiv.curry for p-ary heterogeneous functions.

Equations
@[simp]
theorem Function.FromTypes.curryEquiv_symm_apply {n : } {τ : Type u} (p : Fin nType u) (f : FromTypes p τ) (a✝ : (i : Fin n) → p i) :
(curryEquiv p).symm f a✝ = f.uncurry a✝
@[simp]
theorem Function.FromTypes.curryEquiv_apply {n : } {τ : Type u} (p : Fin nType u) (a✝ : ((i : Fin n) → p i)τ) :
(curryEquiv p) a✝ = curry a✝
theorem Function.FromTypes.curry_two_eq_curry {p : Fin 2Type u} {τ : Type u} (f : ((i : Fin 2) → p i)τ) :
def Function.OfArity.uncurry {α β : Type u} {n : } (f : OfArity α β n) :
(Fin nα)β

Uncurry all the arguments of Function.OfArity α n to get a function from a tuple.

Note this can be used on raw functions if used.

Equations
def Function.OfArity.curry {α β : Type u} {n : } (f : (Fin nα)β) :
OfArity α β n

Curry all the arguments of Function.OfArity α β n to get a function from a tuple.

Equations
@[simp]
theorem Function.OfArity.curry_uncurry {α β : Type u} {n : } (f : OfArity α β n) :
@[simp]
theorem Function.OfArity.uncurry_curry {α β : Type u} {n : } (f : (Fin nα)β) :
def Function.OfArity.curryEquiv {α β : Type u} (n : ) :
((Fin nα)β) OfArity α β n

Equiv.curry for n-ary functions.

Equations
@[simp]
theorem Function.OfArity.curryEquiv_symm_apply {α β : Type u} (n : ) (f : FromTypes (fun (a : Fin n) => α) β) (a✝ : Fin nα) :
(curryEquiv n).symm f a✝ = f.uncurry a✝
@[simp]
theorem Function.OfArity.curryEquiv_apply {α β : Type u} (n : ) (a✝ : (Fin nα)β) :
theorem Function.OfArity.curry_two_eq_curry {α β : Type u} (f : (Fin 2α)β) :