Module docstring
{"# General operations on functions "}
{"# General operations on functions "}
Function.flip_def
theorem
{f : α → β → φ} : flip f = fun b a => f a b
Function.dcomp
definition
{β : α → Sort u₂} {φ : ∀ {x : α}, β x → Sort u₃} (f : ∀ {x : α} (y : β x), φ y) (g : ∀ x, β x) : ∀ x, φ (g x)
/-- Composition of dependent functions: `(f ∘' g) x = f (g x)`, where type of `g x` depends on `x`
and type of `f (g x)` depends on `x` and `g x`. -/
@[inline, reducible]
def dcomp {β : α → Sort u₂} {φ : ∀ {x : α}, β x → Sort u₃} (f : ∀ {x : α} (y : β x), φ y)
(g : ∀ x, β x) : ∀ x, φ (g x) := fun x => f (g x)
Function.term_∘'_
definition
: Lean.TrailingParserDescr✝
Function.onFun
abbrev
(f : β → β → φ) (g : α → β) : α → α → φ
/-- Given functions `f : β → β → φ` and `g : α → β`, produce a function `α → α → φ` that evaluates
`g` on each argument, then applies `f` to the results. Can be used, e.g., to transfer a relation
from `β` to `α`. -/
abbrev onFun (f : β → β → φ) (g : α → β) : α → α → φ := fun x y => f (g x) (g y)
Function.term_On_
definition
: Lean.TrailingParserDescr✝
Function.swap
abbrev
{φ : α → β → Sort u₃} (f : ∀ x y, φ x y) : ∀ y x, φ x y
/-- For a two-argument function `f`, `swap f` is the same function but taking the arguments
in the reverse order. `swap f y x = f x y`. -/
abbrev swap {φ : α → β → Sort u₃} (f : ∀ x y, φ x y) : ∀ y x, φ x y := fun y x => f x y
Function.swap_def
theorem
{φ : α → β → Sort u₃} (f : ∀ x y, φ x y) : swap f = fun y x => f x y
Function.id_comp
theorem
(f : α → β) : id ∘ f = f
Function.comp_id
theorem
(f : α → β) : f ∘ id = f
Function.comp_assoc
theorem
(f : φ → δ) (g : β → φ) (h : α → β) : (f ∘ g) ∘ h = f ∘ g ∘ h
theorem comp_assoc (f : φ → δ) (g : β → φ) (h : α → β) : (f ∘ g) ∘ h = f ∘ g ∘ h :=
rfl
Function.Injective
definition
(f : α → β) : Prop
/-- A function `f : α → β` is called injective if `f x = f y` implies `x = y`. -/
def Injective (f : α → β) : Prop :=
∀ ⦃a₁ a₂⦄, f a₁ = f a₂ → a₁ = a₂
Function.Injective.comp
theorem
{g : β → φ} {f : α → β} (hg : Injective g) (hf : Injective f) : Injective (g ∘ f)
theorem Injective.comp {g : β → φ} {f : α → β} (hg : Injective g) (hf : Injective f) :
Injective (g ∘ f) := fun _a₁ _a₂ => fun h => hf (hg h)
Function.Surjective
definition
(f : α → β) : Prop
/-- A function `f : α → β` is called surjective if every `b : β` is equal to `f a`
for some `a : α`. -/
def Surjective (f : α → β) : Prop :=
∀ b, ∃ a, f a = b
Function.Surjective.comp
theorem
{g : β → φ} {f : α → β} (hg : Surjective g) (hf : Surjective f) : Surjective (g ∘ f)
theorem Surjective.comp {g : β → φ} {f : α → β} (hg : Surjective g) (hf : Surjective f) :
Surjective (g ∘ f) := fun c : φ =>
Exists.elim (hg c) fun b hb =>
Exists.elim (hf b) fun a ha =>
Exists.intro a (show g (f a) = c from Eq.trans (congr_arg g ha) hb)
Function.Bijective
definition
(f : α → β)
/-- A function is called bijective if it is both injective and surjective. -/
def Bijective (f : α → β) :=
InjectiveInjective f ∧ Surjective f
Function.Bijective.comp
theorem
{g : β → φ} {f : α → β} : Bijective g → Bijective f → Bijective (g ∘ f)
theorem Bijective.comp {g : β → φ} {f : α → β} : Bijective g → Bijective f → Bijective (g ∘ f)
| ⟨h_ginj, h_gsurj⟩, ⟨h_finj, h_fsurj⟩ => ⟨h_ginj.comp h_finj, h_gsurj.comp h_fsurj⟩
Function.LeftInverse
definition
(g : β → α) (f : α → β) : Prop
/-- `LeftInverse g f` means that `g` is a left inverse to `f`. That is, `g ∘ f = id`. -/
def LeftInverse (g : β → α) (f : α → β) : Prop :=
∀ x, g (f x) = x
Function.HasLeftInverse
definition
(f : α → β) : Prop
/-- `HasLeftInverse f` means that `f` has an unspecified left inverse. -/
def HasLeftInverse (f : α → β) : Prop :=
∃ finv : β → α, LeftInverse finv f
Function.RightInverse
definition
(g : β → α) (f : α → β) : Prop
/-- `RightInverse g f` means that `g` is a right inverse to `f`. That is, `f ∘ g = id`. -/
def RightInverse (g : β → α) (f : α → β) : Prop :=
LeftInverse f g
Function.HasRightInverse
definition
(f : α → β) : Prop
/-- `HasRightInverse f` means that `f` has an unspecified right inverse. -/
def HasRightInverse (f : α → β) : Prop :=
∃ finv : β → α, RightInverse finv f
Function.LeftInverse.injective
theorem
{g : β → α} {f : α → β} : LeftInverse g f → Injective f
theorem LeftInverse.injective {g : β → α} {f : α → β} : LeftInverse g f → Injective f :=
fun h a b faeqfb =>
calc
a = g (f a) := (h a).symm
_ = g (f b) := congr_arg g faeqfb
_ = b := h b
Function.HasLeftInverse.injective
theorem
{f : α → β} : HasLeftInverse f → Injective f
theorem HasLeftInverse.injective {f : α → β} : HasLeftInverse f → Injective f := fun h =>
Exists.elim h fun _finv inv => inv.injective
Function.rightInverse_of_injective_of_leftInverse
theorem
{f : α → β} {g : β → α} (injf : Injective f) (lfg : LeftInverse f g) : RightInverse f g
theorem rightInverse_of_injective_of_leftInverse {f : α → β} {g : β → α} (injf : Injective f)
(lfg : LeftInverse f g) : RightInverse f g := fun x =>
have h : f (g (f x)) = f x := lfg (f x)
injf h
Function.RightInverse.surjective
theorem
{f : α → β} {g : β → α} (h : RightInverse g f) : Surjective f
theorem RightInverse.surjective {f : α → β} {g : β → α} (h : RightInverse g f) : Surjective f :=
fun y => ⟨g y, h y⟩
Function.HasRightInverse.surjective
theorem
{f : α → β} : HasRightInverse f → Surjective f
theorem HasRightInverse.surjective {f : α → β} : HasRightInverse f → Surjective f
| ⟨_finv, inv⟩ => inv.surjective
Function.leftInverse_of_surjective_of_rightInverse
theorem
{f : α → β} {g : β → α} (surjf : Surjective f) (rfg : RightInverse f g) : LeftInverse f g
theorem leftInverse_of_surjective_of_rightInverse {f : α → β} {g : β → α} (surjf : Surjective f)
(rfg : RightInverse f g) : LeftInverse f g := fun y =>
Exists.elim (surjf y) fun x hx =>
calc
f (g y) = f (g (f x)) := hx ▸ rfl
_ = f x := Eq.symm (rfg x) ▸ rfl
_ = y := hx
Function.injective_id
theorem
: Injective (@id α)
theorem injective_id : Injective (@id α) := fun _a₁ _a₂ h => h
Function.surjective_id
theorem
: Surjective (@id α)
theorem surjective_id : Surjective (@id α) := fun a => ⟨a, rfl⟩
Function.bijective_id
theorem
: Bijective (@id α)
theorem bijective_id : Bijective (@id α) :=
⟨injective_id, surjective_id⟩
Function.Injective.beq_eq
theorem
{α β : Type*} [BEq α] [LawfulBEq α] [BEq β] [LawfulBEq β] {f : α → β} (I : Injective f) {a b : α} :
(f a == f b) = (a == b)
theorem Injective.beq_eq {α β : Type*} [BEq α] [LawfulBEq α] [BEq β] [LawfulBEq β] {f : α → β}
(I : Injective f) {a b : α} : (f a == f b) = (a == b) := by
by_cases h : a == b <;> simp [h] <;> simpa [I.eq_iff] using h
Function.Injective.ne
theorem
(hf : Injective f) {a₁ a₂ : α} : a₁ ≠ a₂ → f a₁ ≠ f a₂
theorem Injective.ne (hf : Injective f) {a₁ a₂ : α} : a₁ ≠ a₂ → f a₁ ≠ f a₂ :=
mt fun h ↦ hf h
Function.Injective.ne_iff
theorem
(hf : Injective f) {x y : α} : f x ≠ f y ↔ x ≠ y
theorem Injective.ne_iff (hf : Injective f) {x y : α} : f x ≠ f yf x ≠ f y ↔ x ≠ y :=
⟨mt <| congr_arg f, hf.ne⟩
Function.Injective.ne_iff'
theorem
(hf : Injective f) {x y : α} {z : β} (h : f y = z) : f x ≠ z ↔ x ≠ y
theorem Injective.ne_iff' (hf : Injective f) {x y : α} {z : β} (h : f y = z) : f x ≠ zf x ≠ z ↔ x ≠ y :=
h ▸ hf.ne_iff
Function.LeftInverse.id
theorem
{g : β → α} {f : α → β} (h : LeftInverse g f) : g ∘ f = id
protected theorem LeftInverse.id {g : β → α} {f : α → β} (h : LeftInverse g f) : g ∘ f = id :=
funext h
Function.RightInverse.id
theorem
{g : β → α} {f : α → β} (h : RightInverse g f) : f ∘ g = id
protected theorem RightInverse.id {g : β → α} {f : α → β} (h : RightInverse g f) : f ∘ g = id :=
funext h
Function.IsFixedPt
definition
(f : α → α) (x : α)
/-- A point `x` is a fixed point of `f : α → α` if `f x = x`. -/
def IsFixedPt (f : α → α) (x : α) := f x = x
Pi.map
definition
(f : ∀ i, α i → β i) : (∀ i, α i) → (∀ i, β i)
/-- Sends a dependent function `a : ∀ i, α i` to a dependent function `Pi.map f a : ∀ i, β i`
by applying `f i` to `i`-th component. -/
protected def map (f : ∀ i, α i → β i) : (∀ i, α i) → (∀ i, β i) := fun a i ↦ f i (a i)
Pi.map_apply
theorem
(f : ∀ i, α i → β i) (a : ∀ i, α i) (i : ι) : Pi.map f a i = f i (a i)