Analysis I, Section 3.3: Functions #
I have attempted to make the translation as faithful a paraphrasing as possible of the original text. When there is a choice between a more idiomatic Lean solution and a more faithful translation, I have generally chosen the latter. In particular, there will be places where the Lean code could be "golfed" to be more elegant and idiomatic, but I have consciously avoided doing so.
Main constructions and results of this section:
- A notion of function
Function X Ybetween two setsX,Yin the set theory of Section 3.1 - Various relations with the Mathlib notion of a function
X → Ybetween two typesX,Y. (Note from Section 3.1 that everySetXcan also be viewed as a subtype{x : Object // x ∈ X }ofObject.) - Basic function properties and operations, such as composition, one-to-one and onto functions, and inverses.
In the rest of the book we will deprecate the Chapter 3 version of a function, and work with the
Mathlib notion of a function instead. Even within this section, we will switch to the Mathlib
formalism for some of the examples involving number systems such as ℤ or ℝ that have not been
implemented in the Chapter 3 framework.
We will work here with the version Nat of the natural numbers internal to the Chapter 3 set
theory, though usually we will use coercions to then immediately translate to the Mathlib
natural numbers ℕ.
Tips from past users #
Users of the companion who have completed the exercises in this section are welcome to send their tips for future users in this section as PRs.
- (Add tip here)
Converting a Chapter 3 function f: Function X Y to a Mathlib function f: X → Y.
The Chapter 3 definition of a function was nonconstructive, so we have to use the
axiom of choice here.
Instances For
Equations
- Chapter3.Function.inst_coefn X Y = { coe := Chapter3.Function.to_fn }
Example 3.3.3.
Equations
Instances For
Equations
- Chapter3.SetTheory.Set.f_3_3_3a = { P := Chapter3.P_3_3_3a, unique := ⋯ }
Instances For
Equations
Instances For
Equations
- Chapter3.SetTheory.Set.f_3_3_3c = { P := Chapter3.SetTheory.Set.P_3_3_3c, unique := ⋯ }
Instances For
Equations
- Chapter3.SetTheory.Set.f_3_3_5 = { P := Chapter3.SetTheory.Set.P_3_3_5, unique := ⋯ }
Instances For
Example 3.3.10 (simplified). The second part of the example is tricky to replicate in this formalism, so a Mathlib substitute is offered instead.
Equations
Instances For
Equations
- Chapter3.SetTheory.Set.f_3_3_10b = Chapter3.Function.mk_fn fun (x : Chapter3.Nat.toSubtype) => ↑((Chapter3.SetTheory.Set.nat_equiv.symm x + 1) ^ 2)
Instances For
Equations
- Chapter3.«term_○_» = Lean.ParserDescr.trailingNode `Chapter3.«term_○_» 90 91 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "○") (Lean.ParserDescr.cat `term 91))
Instances For
Example 3.3.14
Equations
Instances For
Equations
Instances For
Compatibility with Mathlib's Function.Injective. You may wish to use the unfold tactic to
understand Mathlib concepts such as Function.Injective.
Example 3.3.18. One half of the example requires the integers, and so is expressed using Mathlib functions instead of Chapter 3 functions.
Compatibility with Mathlib's Function.Surjective
Compatibility with Mathlib's Function.Bijective
Example 3.3.24 (using Mathlib)
Equations
Instances For
Equations
Instances For
Equations
Instances For
We cannot use the notation f⁻¹ for the inverse because in Mathlib's Inv class, the inverse
of f must be exactly of the same type of f, and Function Y X is a different type from
Function X Y.
Equations
Instances For
Exercise 3.3.1. Although a proof operating directly on functions would be shorter,
the spirit of the exercise is to show these using the Function.eq_iff definition.
Exercise 3.3.2
Exercise 3.3.3 - fill in the sorrys in the statements in a reasonable fashion.
Exercise 3.3.5.
Equations
Instances For
Exercise 3.3.8
Equations
- Chapter3.Function.inclusion h = Chapter3.Function.mk_fn fun (x : X.toSubtype) => ⟨↑x, ⋯⟩
Instances For
Equations
- Chapter3.Function.id X = Chapter3.Function.mk_fn fun (x : X.toSubtype) => x