Article II: Isomorphisms
1. Isomorphisms
A map {A \xrightarrow{f} B} is called an isomorphism, or invertible map, if there is a map {B \xrightarrow{g} A} for which {g \circ f = 1_A} and {f \circ g = 1_B}.
A map g related to f by satisfying these equations is called an inverse for f.
Two objects A and B are said to be isomorphic if there is at least one isomorphism {A \xrightarrow{f} B}.
The corresponding mathlib definition for isomorphism is Iso (and IsIso), which we print below for reference.
#print Iso
#print IsIso
Reflexive: A is isomorphic to A.
Symmetric: If A is isomorphic to B, then B is isomorphic to A.
Transitive: If A is isomorphic to B, and B is isomorphic to C, then A is isomorphic to C.
The respective mathlib definitions are Iso.refl, Iso.symm, and Iso.trans, which we print below for reference.
#print Iso.refl
#print Iso.symm
#print Iso.trans
(R) Show that {A \xrightarrow{1_A} A} is an isomorphism. (Hint: find an inverse for 1_A.)
(S) Show that if {A \xrightarrow{f} B} is an isomorphism, and {B \xrightarrow{g} A} is an inverse for f; then g is also an isomorphism. (Hint: find an inverse for g.)
(T) Show that if {A \xrightarrow{f} B} and {B \xrightarrow{k} C} are isomorphisms, {A \xrightarrow{k \circ f} C} is also an isomorphism.
Solution: Exercise 1
variable {๐ : Type u} [Category.{v, u} ๐] {A B C : ๐}
(R) 1_A is an inverse for itself, so 1_A is an isomorphism.
example : IsIso (๐ A) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐โข IsIso (๐ A)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐โข ๐ A โ ๐ A = ๐ A โง ๐ A โ ๐ A = ๐ A
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐โข ๐ A โ ๐ A = ๐ A๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐โข ๐ A โ ๐ A = ๐ A ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐โข ๐ A โ ๐ A = ๐ A๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐โข ๐ A โ ๐ A = ๐ A All goals completed! ๐
(S) f is an inverse for g, so g is an isomorphism. (Note that the hypothesis "f is an isomorphism" is redundant here and could be omitted.)
example (f : A โถ B) (_ : IsIso f)
(g : B โถ A) (hg : g โ f = ๐ A โง f โ g = ๐ B)
: IsIso g := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bxโ:IsIso fg:B โถ Ahg:g โ f = ๐ A โง f โ g = ๐ Bโข IsIso g
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bxโ:IsIso fg:B โถ Ahg:g โ f = ๐ A โง f โ g = ๐ Bโข f โ g = ๐ B โง g โ f = ๐ A
All goals completed! ๐
(T) Composition of isomorphisms is transitive, so {k \circ f} is an isomorphism.
example (f : A โถ B) (hf : IsIso f) (k : B โถ C) (hk : IsIso k)
: IsIso (k โ f) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bhf:IsIso fk:B โถ Chk:IsIso kโข IsIso (k โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Chk:IsIso kfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bโข IsIso (k โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bkinv:C โถ Bhkinv:kinv โ k = ๐ B โง k โ kinv = ๐ Cโข IsIso (k โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bkinv:C โถ Bhkinv:kinv โ k = ๐ B โง k โ kinv = ๐ Cโข (finv โ kinv) โ k โ f = ๐ A โง (k โ f) โ finv โ kinv = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bkinv:C โถ Bhkinv:kinv โ k = ๐ B โง k โ kinv = ๐ Cโข (finv โ kinv) โ k โ f = ๐ A๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bkinv:C โถ Bhkinv:kinv โ k = ๐ B โง k โ kinv = ๐ Cโข (k โ f) โ finv โ kinv = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bkinv:C โถ Bhkinv:kinv โ k = ๐ B โง k โ kinv = ๐ Cโข (finv โ kinv) โ k โ f = ๐ A ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bkinv:C โถ Bhkinv:kinv โ k = ๐ B โง k โ kinv = ๐ Cโข (finv โ kinv โ k) โ f = ๐ A
All goals completed! ๐
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bkinv:C โถ Bhkinv:kinv โ k = ๐ B โง k โ kinv = ๐ Cโข (k โ f) โ finv โ kinv = ๐ C ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bk:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bkinv:C โถ Bhkinv:kinv โ k = ๐ B โง k โ kinv = ๐ Cโข (k โ f โ finv) โ kinv = ๐ C
All goals completed! ๐
Suppose {B \xrightarrow{g} A} and {B \xrightarrow{k} A} are both inverses for {A \xrightarrow{f} B}. Show that {g = k}.
Solution: Exercise 2
The inverse of a map is unique (when it exists).
example {๐ : Type u} [Category.{v, u} ๐] {A B : ๐} (f : A โถ B)
(g : B โถ A) (hg : g โ f = ๐ A โง f โ g = ๐ B)
(k : B โถ A) (hk : k โ f = ๐ A โง f โ k = ๐ B)
: g = k := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bg:B โถ Ahg:g โ f = ๐ A โง f โ g = ๐ Bk:B โถ Ahk:k โ f = ๐ A โง f โ k = ๐ Bโข g = k
calc
g = ๐ A โ g := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bg:B โถ Ahg:g โ f = ๐ A โง f โ g = ๐ Bk:B โถ Ahk:k โ f = ๐ A โง f โ k = ๐ Bโข g = ๐ A โ g All goals completed! ๐
_ = (k โ f) โ g := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bg:B โถ Ahg:g โ f = ๐ A โง f โ g = ๐ Bk:B โถ Ahk:k โ f = ๐ A โง f โ k = ๐ Bโข ๐ A โ g = (k โ f) โ g All goals completed! ๐
_ = k โ (f โ g) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bg:B โถ Ahg:g โ f = ๐ A โง f โ g = ๐ Bk:B โถ Ahk:k โ f = ๐ A โง f โ k = ๐ Bโข (k โ f) โ g = k โ f โ g All goals completed! ๐
_ = k โ ๐ B := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bg:B โถ Ahg:g โ f = ๐ A โง f โ g = ๐ Bk:B โถ Ahk:k โ f = ๐ A โง f โ k = ๐ Bโข k โ f โ g = k โ ๐ B All goals completed! ๐
_ = k := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bg:B โถ Ahg:g โ f = ๐ A โง f โ g = ๐ Bk:B โถ Ahk:k โ f = ๐ A โง f โ k = ๐ Bโข k โ ๐ B = k All goals completed! ๐
If f has an inverse, then f satisfies the two cancellation laws:
(a) If {f \circ h = f \circ k}, then {h = k}.
(b) If {h \circ f = k \circ f}, then {h = k}.
Warning: The following 'cancellation law' is not correct, even if f has an inverse.
(c) (wrong): If {h \circ f = f \circ k}, then {h = k}.
Solution: Exercise 3
variable {๐ : Type u} [Category.{v, u} ๐] {A B : ๐}
(a) We show that f is left-cancellative.
example (f : A โถ B)
(hf : โ finv : B โถ A, finv โ f = ๐ A โง f โ finv = ๐ B)
(h : B โถ A) (k : B โถ A)
: f โ h = f โ k โ h = k := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bhf:โ finv, finv โ f = ๐ A โง f โ finv = ๐ Bh:B โถ Ak:B โถ Aโข f โ h = f โ k โ h = k
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bโข f โ h = f โ k โ h = k
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bhโ:f โ h = f โ kโข h = k
have hโ : finv โ f โ h = finv โ f โ k := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bhf:โ finv, finv โ f = ๐ A โง f โ finv = ๐ Bh:B โถ Ak:B โถ Aโข f โ h = f โ k โ h = k All goals completed! ๐
repeat ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bhโ:f โ h = f โ khโ:(finv โ f) โ h = (finv โ f) โ kโข h = k
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bhโ:f โ h = f โ khโ:๐ A โ h = ๐ A โ kโข h = k
repeat ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bhโ:f โ h = f โ khโ:h = kโข h = k
All goals completed! ๐
(b) We show that f is right-cancellative.
example (f : A โถ B)
(hf : โ finv : B โถ A, finv โ f = ๐ A โง f โ finv = ๐ B)
(h : B โถ A) (k : B โถ A)
: h โ f = k โ f โ h = k := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bhf:โ finv, finv โ f = ๐ A โง f โ finv = ๐ Bh:B โถ Ak:B โถ Aโข h โ f = k โ f โ h = k
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bโข h โ f = k โ f โ h = k
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bhโ:h โ f = k โ fโข h = k
have hโ : (h โ f) โ finv = (k โ f) โ finv := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bhf:โ finv, finv โ f = ๐ A โง f โ finv = ๐ Bh:B โถ Ak:B โถ Aโข h โ f = k โ f โ h = k All goals completed! ๐
repeat ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bhโ:h โ f = k โ fhโ:h โ f โ finv = k โ f โ finvโข h = k
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bhโ:h โ f = k โ fhโ:h โ ๐ B = k โ ๐ Bโข h = k
repeat ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bh:B โถ Ak:B โถ Afinv:B โถ Ahfinvโ:finv โ f = ๐ Ahfinvโ:f โ finv = ๐ Bhโ:h โ f = k โ fhโ:h = kโข h = k
All goals completed! ๐
(c) We take our counterexample from endomaps on Fin 2, the canonical type with two elements.
def f : Fin 2 โถ Fin 2
| 0 => 1
| 1 => 0
f has an inverse, as required. (f is self-inverse.)
example : f โ f = ๐ (Fin 2) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข f โ f = ๐ (Fin 2)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐x:Fin 2โข (f โ f) x = ๐ (Fin 2) x
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข (f โ f) ((fun i โฆ i) โจ0, โฏโฉ) = ๐ (Fin 2) ((fun i โฆ i) โจ0, โฏโฉ)๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข (f โ f) ((fun i โฆ i) โจ1, โฏโฉ) = ๐ (Fin 2) ((fun i โฆ i) โจ1, โฏโฉ) ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข (f โ f) ((fun i โฆ i) โจ0, โฏโฉ) = ๐ (Fin 2) ((fun i โฆ i) โจ0, โฏโฉ)๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข (f โ f) ((fun i โฆ i) โจ1, โฏโฉ) = ๐ (Fin 2) ((fun i โฆ i) โจ1, โฏโฉ) All goals completed! ๐
def h : Fin 2 โถ Fin 2
| 0 => 1
| 1 => 1
def k : Fin 2 โถ Fin 2
| 0 => 0
| 1 => 0
example : ยฌ(h โ f = f โ k โ h = k) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข ยฌ(h โ f = f โ k โ h = k)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข h โ f = f โ k โง h โ k
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข h โ f = f โ k๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข h โ k
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข h โ f = f โ k ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐x:Fin 2โข (h โ f) x = (f โ k) x
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข (h โ f) ((fun i โฆ i) โจ0, โฏโฉ) = (f โ k) ((fun i โฆ i) โจ0, โฏโฉ)๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข (h โ f) ((fun i โฆ i) โจ1, โฏโฉ) = (f โ k) ((fun i โฆ i) โจ1, โฏโฉ) ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข (h โ f) ((fun i โฆ i) โจ0, โฏโฉ) = (f โ k) ((fun i โฆ i) โจ0, โฏโฉ)๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข (h โ f) ((fun i โฆ i) โจ1, โฏโฉ) = (f โ k) ((fun i โฆ i) โจ1, โฏโฉ) All goals completed! ๐
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐โข h โ k ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐hโ:h = kโข False
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐hโ:h = khโ:h 0 = 1 := rflโข False
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐hโ:h = khโ:h 0 = 1 := rflhโ:k 0 = 0 := rflโข False
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐hโ:h = khโ:h 0 = 1 := rflhโ:1 = 0โข False
All goals completed! ๐
For each of the five maps below: decide whether it is invertible; and if it is invertible, find a 'formula' for the inverse map.
-
\mathbb{R} \xrightarrow{f} \mathbb{R},\; f(x) = 3x + 7 -
\mathbb{R}_{\ge 0} \xrightarrow{g} \mathbb{R}_{\ge 0},\; g(x) = x^2 -
\mathbb{R} \xrightarrow{h} \mathbb{R},\; h(x) = x^2 -
\mathbb{R} \xrightarrow{k} \mathbb{R}_{\ge 0},\; k(x) = x^2 -
\mathbb{R}_{\ge 0} \xrightarrow{l} \mathbb{R}_{\ge 0},\; l(x) = \dfrac{1}{x + 1}
Solution: Exercise 4
Since all five maps have their domain and codomain as the real numbers (or a subset of the real numbers), we implement them as functions in Lean.
f is invertible, with inverse {f^{-1}(x) = \dfrac{x - 7}{3}}.
example (f : โ โ โ) (hf : โ x : โ, f x = 3 * x + 7)
: โ finv : โ โ โ, finv โ f = id โง f โ finv = id := f:โ โ โhf:โ (x : โ), f x = 3 * x + 7โข โ finv, finv โ f = id โง f โ finv = id
f:โ โ โhf:โ (x : โ), f x = 3 * x + 7โข (fun x โฆ (x - 7) / 3) โ f = id โง (f โ fun x โฆ (x - 7) / 3) = id -- fโปยน(x)
f:โ โ โhf:โ (x : โ), f x = 3 * x + 7โข (fun x โฆ (x - 7) / 3) โ f = idf:โ โ โhf:โ (x : โ), f x = 3 * x + 7โข (f โ fun x โฆ (x - 7) / 3) = id
f:โ โ โhf:โ (x : โ), f x = 3 * x + 7โข (fun x โฆ (x - 7) / 3) โ f = id f:โ โ โhf:โ (x : โ), f x = 3 * x + 7x:โโข ((fun x โฆ (x - 7) / 3) โ f) x = id x
f:โ โ โhf:โ (x : โ), f x = 3 * x + 7x:โโข (3 * x + 7 - 7) / 3 = x
All goals completed! ๐
f:โ โ โhf:โ (x : โ), f x = 3 * x + 7โข (f โ fun x โฆ (x - 7) / 3) = id f:โ โ โhf:โ (x : โ), f x = 3 * x + 7x:โโข (f โ fun x โฆ (x - 7) / 3) x = id x
f:โ โ โhf:โ (x : โ), f x = 3 * x + 7x:โโข 3 * ((x - 7) / 3) + 7 = x
All goals completed! ๐
g is invertible, with inverse {g^{-1}(x) = \sqrt{x}}.
open NNReal in
example (g : โโฅ0 โ โโฅ0) (hg : โ x : โโฅ0, g x = x * x)
: โ ginv : โโฅ0 โ โโฅ0, ginv โ g = id โง g โ ginv = id := g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xโข โ ginv, ginv โ g = id โง g โ ginv = id
g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xโข (fun x โฆ sqrt x) โ g = id โง (g โ fun x โฆ sqrt x) = id -- gโปยน(x)
g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xโข (fun x โฆ sqrt x) โ g = idg:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xโข (g โ fun x โฆ sqrt x) = id
g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xโข (fun x โฆ sqrt x) โ g = id g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xx:โโฅ0โข ((fun x โฆ sqrt x) โ g) x = id x
g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xx:โโฅ0โข sqrt (x * x) = x
All goals completed! ๐
g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xโข (g โ fun x โฆ sqrt x) = id g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xx:โโฅ0โข (g โ fun x โฆ sqrt x) x = id x
g:โโฅ0 โ โโฅ0hg:โ (x : โโฅ0), g x = x * xx:โโฅ0โข sqrt x * sqrt x = x
All goals completed! ๐
h is not invertible, since {h(1) = h(-1) = 1}.
example (h : โ โ โ) (hh : โ x : โ, h x = x * x)
: ยฌ(โ hinv : โ โ โ, hinv โ h = id โง h โ hinv = id) := h:โ โ โhh:โ (x : โ), h x = x * xโข ยฌโ hinv, hinv โ h = id โง h โ hinv = id
h:โ โ โhh:โ (x : โ), h x = x * xโข โ (hinv : โ โ โ), hinv โ h = id โ h โ hinv โ id
intro hinv h:โ โ โhh:โ (x : โ), h x = x * xhinv:โ โ โh_inv_left:hinv โ h = idโข h โ hinv โ id h:โ โ โhh:โ (x : โ), h x = x * xhinv:โ โ โh_inv_left:hinv โ h = idaโ:h โ hinv = idโข False
have hโ : h 1 = 1 := h:โ โ โhh:โ (x : โ), h x = x * xโข ยฌโ hinv, hinv โ h = id โง h โ hinv = id
h:โ โ โhh:โ (x : โ), h x = x * xhinv:โ โ โh_inv_left:hinv โ h = idaโ:h โ hinv = idโข 1 * 1 = 1
All goals completed! ๐
have hโ : h (-1) = 1 := h:โ โ โhh:โ (x : โ), h x = x * xโข ยฌโ hinv, hinv โ h = id โง h โ hinv = id
h:โ โ โhh:โ (x : โ), h x = x * xhinv:โ โ โh_inv_left:hinv โ h = idaโ:h โ hinv = idhโ:h 1 = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hh 1)))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul) (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one) (Eq.refl 1))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))โข -1 * -1 = 1
All goals completed! ๐
have hโ : (hinv โ h) 1 = 1:= h:โ โ โhh:โ (x : โ), h x = x * xโข ยฌโ hinv, hinv โ h = id โง h โ hinv = id
All goals completed! ๐
have hโ : (hinv โ h) (-1) = -1 := h:โ โ โhh:โ (x : โ), h x = x * xโข ยฌโ hinv, hinv โ h = id โง h โ hinv = id
All goals completed! ๐
h:โ โ โhh:โ (x : โ), h x = x * xhinv:โ โ โh_inv_left:hinv โ h = idaโ:h โ hinv = idhโ:h 1 = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hh 1)))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul) (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one) (Eq.refl 1))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))hโ:h (-1) = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hh (-1))))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.IsInt.to_isNat
(Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Eq.refl (Int.ofNat 1))))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))hโ:hinv (h 1) = 1 := Eq.mpr (id (congrArg (fun _a โฆ _a 1 = 1) h_inv_left)) (Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (id_eq 1))) (Eq.refl 1))hโ:hinv (h (-1)) = -1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a (-1) = -1) h_inv_left))
(Eq.mpr (id (congrArg (fun _a โฆ _a = -1) (id_eq (-1)))) (Eq.refl (-1)))โข False
h:โ โ โhh:โ (x : โ), h x = x * xhinv:โ โ โh_inv_left:hinv โ h = idaโ:h โ hinv = idhโ:h 1 = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hh 1)))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul) (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one) (Eq.refl 1))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))hโ:h (-1) = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hh (-1))))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.IsInt.to_isNat
(Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Eq.refl (Int.ofNat 1))))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))hโ:hinv 1 = 1hโ:hinv (h (-1)) = -1โข False
h:โ โ โhh:โ (x : โ), h x = x * xhinv:โ โ โh_inv_left:hinv โ h = idaโ:h โ hinv = idhโ:h 1 = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hh 1)))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul) (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one) (Eq.refl 1))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))hโ:h (-1) = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hh (-1))))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.IsInt.to_isNat
(Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Eq.refl (Int.ofNat 1))))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))hโ:hinv 1 = 1hโ:hinv 1 = -1โข False
All goals completed! ๐
k is not invertible, since {k(1) = k(-1) = 1}.
open NNReal in
example (k : โ โ โโฅ0) (hk : โ x : โ, k x = x * x)
: ยฌ(โ kinv : โโฅ0 โ โ, kinv โ k = id โง k โ kinv = id) := k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xโข ยฌโ kinv, kinv โ k = id โง k โ kinv = id
k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xโข โ (kinv : โโฅ0 โ โ), kinv โ k = id โ k โ kinv โ id
intro kinv k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xkinv:โโฅ0 โ โh_inv_left:kinv โ k = idโข k โ kinv โ id k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xkinv:โโฅ0 โ โh_inv_left:kinv โ k = idaโ:k โ kinv = idโข False
have hโ : k 1 = 1 := k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xโข ยฌโ kinv, kinv โ k = id โง k โ kinv = id
k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xkinv:โโฅ0 โ โh_inv_left:kinv โ k = idaโ:k โ kinv = idโข 1 * 1 = 1
All goals completed! ๐
have hโ : k (-1) = 1 := k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xโข ยฌโ kinv, kinv โ k = id โง k โ kinv = id
k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xkinv:โโฅ0 โ โh_inv_left:kinv โ k = idaโ:k โ kinv = idhโ:k 1 = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a) (Eq.symm (propext coe_eq_one))))
(Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hk 1)))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul) (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one) (Eq.refl 1))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)))โข -1 * -1 = 1
All goals completed! ๐
have hโ : (kinv โ k) 1 = 1:= k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xโข ยฌโ kinv, kinv โ k = id โง k โ kinv = id
All goals completed! ๐
have hโ : (kinv โ k) (-1) = -1 := k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xโข ยฌโ kinv, kinv โ k = id โง k โ kinv = id
All goals completed! ๐
k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xkinv:โโฅ0 โ โh_inv_left:kinv โ k = idaโ:k โ kinv = idhโ:k 1 = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a) (Eq.symm (propext coe_eq_one))))
(Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hk 1)))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul) (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one) (Eq.refl 1))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)))hโ:k (-1) = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a) (Eq.symm (propext coe_eq_one))))
(Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hk (-1))))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.IsInt.to_isNat
(Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Eq.refl (Int.ofNat 1))))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)))hโ:kinv (k 1) = 1 := Eq.mpr (id (congrArg (fun _a โฆ _a 1 = 1) h_inv_left)) (Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (id_eq 1))) (Eq.refl 1))hโ:kinv (k (-1)) = -1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a (-1) = -1) h_inv_left))
(Eq.mpr (id (congrArg (fun _a โฆ _a = -1) (id_eq (-1)))) (Eq.refl (-1)))โข False
k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xkinv:โโฅ0 โ โh_inv_left:kinv โ k = idaโ:k โ kinv = idhโ:k 1 = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a) (Eq.symm (propext coe_eq_one))))
(Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hk 1)))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul) (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one) (Eq.refl 1))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)))hโ:k (-1) = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a) (Eq.symm (propext coe_eq_one))))
(Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hk (-1))))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.IsInt.to_isNat
(Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Eq.refl (Int.ofNat 1))))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)))hโ:kinv 1 = 1hโ:kinv (k (-1)) = -1โข False
k:โ โ โโฅ0hk:โ (x : โ), โ(k x) = x * xkinv:โโฅ0 โ โh_inv_left:kinv โ k = idaโ:k โ kinv = idhโ:k 1 = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a) (Eq.symm (propext coe_eq_one))))
(Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hk 1)))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul) (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one) (Eq.refl 1))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)))hโ:k (-1) = 1 :=
Eq.mpr (id (congrArg (fun _a โฆ _a) (Eq.symm (propext coe_eq_one))))
(Eq.mpr (id (congrArg (fun _a โฆ _a = 1) (hk (-1))))
(Mathlib.Meta.NormNum.isNat_eq_true
(Mathlib.Meta.NormNum.IsInt.to_isNat
(Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
(Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one))
(Eq.refl (Int.negOfNat 1)))
(Eq.refl (Int.ofNat 1))))
(Mathlib.Meta.NormNum.isNat_ofNat โ Nat.cast_one)))hโ:kinv 1 = 1hโ:kinv 1 = -1โข False
All goals completed! ๐
l is invertible, with inverse {l^{-1}(x) = \dfrac{1}{x} - 1}, provided that we restrict the codomain of l to the interval {(0,1]}.
TODO Exercise II.4.5
2. General division problems: Determination and choice
Exercise 5 concerns counting the number of sections and retractions for a map (though those terms aren't formally defined until a short while later on p. 49). Rather than providing an exhaustive list of maps, we introduce here two formulas โ what the book later calls Chad's formula and Danilo's formula (p. 117).
The former states that the number of sections for a map p is given by
\prod_{\mathbf{1} \xrightarrow{a} A} \#(p^{-1}a),
where A is the codomain of p.
def Chad's_formula {ฮฑ ฯ : Type*} [DecidableEq ฮฑ]
[Fintype ฮฑ] [Fintype ฯ] (X : Finset ฯ) (A : Finset ฮฑ)
(p : ฯ โ ฮฑ)
: โ :=
โ a โ A, pinvCount a
where
pinvCount (a : ฮฑ) : โ := X.filter (fun x โฆ p x = a) |>.card
The latter states that the number of retractions for a map j, assuming j is injective, is given by
(\#A)^{(\#X - \#A)},
where A is the domain of j and X is the codomain of j.
open Finset in
def Danilo's_formula {ฮฑ ฯ : Type*}
[Fintype ฮฑ] [Fintype ฯ] (A : Finset ฮฑ) (X : Finset ฯ)
(j : ฮฑ โ ฯ) (p : ฯ โ ฮฑ) (_ : p โ j = id) (_ : Function.Injective j)
: โ :=
#A ^ (#X - #A)
Given
\{b, p, q, r, s\} \xrightarrow{g} \{0, 1\}\\\
\qquad b \mapsto 0\\\
\qquad p \mapsto 0\\\
\qquad q \mapsto 0\\\
\qquad r \mapsto 1\\\
\qquad s \mapsto 1,
how many maps f are there with {g \circ f = 1_{\{0, 1\}}}?
Choosing a particular such f, how many maps g (including the given one) satisfy the same equation?
Solution: Exercise 5
inductive XElems
| b | p | q | r | s
deriving Fintype
def A : Finset (Fin 2) := Finset.univ
def X : Finset XElems := Finset.univ
open XElems in
def g : XElems โ Fin 2
| b => 0
| p => 0
| q => 0
| r => 1
| s => 1
By Chad's formula, we have 6 different maps f with {g \circ f = 1_{\{0, 1\}}}.
#eval Chad's_formula X A g
We choose f to be
open XElems in
def f : Fin 2 โ XElems
| 0 => b
| 1 => r
Then, by Danilo's formula, we have {(\#A)^{(\#X - \#A)} = 2^3 = 8} different maps g.
#eval Danilo's_formula A X f g
(โข g โ f = id
x:Fin 2โข (g โ f) x = id x
โข (g โ f) ((fun i โฆ i) โจ0, โฏโฉ) = id ((fun i โฆ i) โจ0, โฏโฉ)โข (g โ f) ((fun i โฆ i) โจ1, โฏโฉ) = id ((fun i โฆ i) โจ1, โฏโฉ) โข (g โ f) ((fun i โฆ i) โจ0, โฏโฉ) = id ((fun i โฆ i) โจ0, โฏโฉ)โข (g โ f) ((fun i โฆ i) โจ1, โฏโฉ) = id ((fun i โฆ i) โจ1, โฏโฉ) All goals completed! ๐)
(โข Function.Injective f
intro x x:Fin 2y:Fin 2โข f x = f y โ x = y x:Fin 2y:Fin 2aโ:f x = f yโข x = y
y:Fin 2aโ:f ((fun i โฆ i) โจ0, โฏโฉ) = f yโข (fun i โฆ i) โจ0, โฏโฉ = yy:Fin 2aโ:f ((fun i โฆ i) โจ1, โฏโฉ) = f yโข (fun i โฆ i) โจ1, โฏโฉ = y y:Fin 2aโ:f ((fun i โฆ i) โจ0, โฏโฉ) = f yโข (fun i โฆ i) โจ0, โฏโฉ = yy:Fin 2aโ:f ((fun i โฆ i) โจ1, โฏโฉ) = f yโข (fun i โฆ i) โจ1, โฏโฉ = y aโ:f ((fun i โฆ i) โจ1, โฏโฉ) = f ((fun i โฆ i) โจ0, โฏโฉ)โข (fun i โฆ i) โจ1, โฏโฉ = (fun i โฆ i) โจ0, โฏโฉaโ:f ((fun i โฆ i) โจ1, โฏโฉ) = f ((fun i โฆ i) โจ1, โฏโฉ)โข (fun i โฆ i) โจ1, โฏโฉ = (fun i โฆ i) โจ1, โฏโฉ
all_goals
first | All goals completed! ๐
| aโ:f ((fun i โฆ i) โจ1, โฏโฉ) = f ((fun i โฆ i) โจ0, โฏโฉ)โข 1 = 0; All goals completed! ๐)
3. Retractions, sections, and idempotents
If {A \xrightarrow{f} B}:
a retraction for f is a map {B \xrightarrow{r} A} for which {r \circ f = 1_A};
a section for f is a map {B \xrightarrow{s} A} for which {f \circ s = 1_B}.
The mathlib definition corresponding to retraction is SplitMono (and IsSplitMono), which we print below for reference.
#print SplitMono
#print IsSplitMono
We alias SplitMono and IsSplitMono as Retraction and IsRetraction, respectively, to remain aligned with the terminology in the book.
abbrev Retraction {๐ : Type u} [Category.{v, u} ๐] {A B : ๐}
(f : A โถ B) :=
SplitMono f
abbrev IsRetraction {๐ : Type u} [Category.{v, u} ๐] {A B : ๐}
(f : A โถ B) :=
IsSplitMono f
The mathlib definition corresponding to section is SplitEpi (and IsSplitEpi), which we print below for reference.
#print SplitEpi
#print IsSplitEpi
We alias SplitEpi and IsSplitEpi as Section and IsSection, respectively, to remain aligned with the terminology in the book.
abbrev Section {๐ : Type u} [Category.{v, u} ๐] {A B : ๐}
(f : A โถ B) :=
SplitEpi f
abbrev IsSection {๐ : Type u} [Category.{v, u} ๐] {A B : ๐}
(f : A โถ B) :=
IsSplitEpi f
If a map {A \xrightarrow{f} B} has a section, then for any T and for any map {T \xrightarrow{y} B} there exists a map {T \xrightarrow{x} A} for which {f \circ x = y}.
The assumption means that we have a map s for which {f \circ s = 1_B}. Thus for any given map {T \xrightarrow{y} B} we see that we could define a map x with at least the correct domain and codomain by taking the composite s following y
x = s \circ y.
Does this map x actually satisfy the required equation? Calculating
f \circ x = f \circ (s \circ y) = (f \circ s) \circ y = 1_B \circ y = y
we see that it does.
Our implementation in Lean faithfully follows the argument of the book proof given above.
theorem prop1 {๐ : Type u} [Category.{v, u} ๐] {A B T : ๐}
(f : A โถ B) [hf : IsSection f]
: โ y : T โถ B, โ x : T โถ A, f โ x = y := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bhf:IsSection fโข โ (y : T โถ B), โ x, f โ x = y
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ Bโข โ (y : T โถ B), โ x, f โ x = y
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ By:T โถ Bโข โ x, f โ x = y
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ By:T โถ Bโข f โ s โ y = y
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ By:T โถ Bโข (f โ s) โ y = y
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ By:T โถ Bโข ๐ B โ y = y
All goals completed! ๐
If the map {A \xrightarrow{f} B} has a retraction, then for any map {A \xrightarrow{g} T}, there is a map {B \xrightarrow{t} T} for which {t \circ f = g}. (This is Proposition 1*.)
Solution: Exercise 6
Put {t = g \circ r}.
theorem ยซprop1*ยป {๐ : Type u} [Category.{v, u} ๐] {A B T : ๐}
(f : A โถ B) [hf : IsRetraction f]
: โ g : A โถ T, โ t : B โถ T, t โ f = g := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bhf:IsRetraction fโข โ (g : A โถ T), โ t, t โ f = g
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Aโข โ (g : A โถ T), โ t, t โ f = g
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Ag:A โถ Tโข โ t, t โ f = g
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Ag:A โถ Tโข (g โ r) โ f = g
All goals completed! ๐
Suppose a map {A \xrightarrow{f} B} has a retraction. Then for any set T and for any pair of maps {T \xrightarrow{x_1} A}, {T \xrightarrow{x_2} A} from any set T to A
\text{if}\; f \circ x_1 = f \circ x_2 \;\text{then}\; x_1 = x_2.
Looking back at the definition, we see that the assumption means that we have a map r for which {r \circ f = 1_A}. Using the assumption that x_1 and x_2 are such that f composes with them to get the same {T \rightarrow B}, we can compose further with r as follows:
x_1 = 1_A \circ x_1 = (r \circ f) \circ x_1 = r \circ (f \circ x_1) = r \circ (f \circ x_2) = (r \circ f) \circ x_2 = 1_A \circ x_2 = x_2.
Our implementation in Lean generalises the proposition from sets to any categorical object but otherwise faithfully follows the argument of the book proof given above.
theorem prop2 {๐ : Type u} [Category.{v, u} ๐] {A B T : ๐}
(f : A โถ B) [hf : IsRetraction f]
: โ xโ xโ : T โถ A, f โ xโ = f โ xโ โ xโ = xโ := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bhf:IsRetraction fโข โ (xโ xโ : T โถ A), f โ xโ = f โ xโ โ xโ = xโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Aโข โ (xโ xโ : T โถ A), f โ xโ = f โ xโ โ xโ = xโ
intro xโ ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Axโ:T โถ Axโ:T โถ Aโข f โ xโ = f โ xโ โ xโ = xโ ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Axโ:T โถ Axโ:T โถ Ah:f โ xโ = f โ xโโข xโ = xโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Axโ:T โถ Axโ:T โถ Ah:f โ xโ = f โ xโโข ๐ A โ xโ = xโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Axโ:T โถ Axโ:T โถ Ah:f โ xโ = f โ xโโข (r โ f) โ xโ = xโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Axโ:T โถ Axโ:T โถ Ah:f โ xโ = f โ xโโข r โ f โ xโ = xโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Axโ:T โถ Axโ:T โถ Ah:f โ xโ = f โ xโโข r โ f โ xโ = xโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Axโ:T โถ Axโ:T โถ Ah:f โ xโ = f โ xโโข (r โ f) โ xโ = xโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Br:B โถ Ahf:r โ f = ๐ Axโ:T โถ Axโ:T โถ Ah:f โ xโ = f โ xโโข ๐ A โ xโ = xโ
All goals completed! ๐
A map f satisfying the conclusion of Proposition 2 (for any pair of maps {T \xrightarrow{x_1} A} and {T \xrightarrow{x_2} A}, if {f \circ x_1 = f \circ x_2} then {x_1 = x_2}) is said to be injective for maps from T.
If f is injective for maps from T for every T, one says that f is injective, or is a monomorphism.
The corresponding mathlib definition is Mono, which we print below for reference.
#print Mono
Suppose the map {A \xrightarrow{f} B} has a section. Then for any set T and any pair {B \xrightarrow{t_1} T}, {B \xrightarrow{t_2} T} of maps from B to T, if {t_1 \circ f = t_2 \circ f} then {t_1 = t_2}. (This is Proposition 2*.)
Solution: Exercise 7
A proof of Proposition 2* is given below.
theorem ยซprop2*ยป {๐ : Type u} [Category.{v, u} ๐] {A B T : ๐}
(f : A โถ B) [hf : IsSection f]
: โ tโ tโ : B โถ T, tโ โ f = tโ โ f โ tโ = tโ := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bhf:IsSection fโข โ (tโ tโ : B โถ T), tโ โ f = tโ โ f โ tโ = tโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ Bโข โ (tโ tโ : B โถ T), tโ โ f = tโ โ f โ tโ = tโ
intro tโ ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ Btโ:B โถ Ttโ:B โถ Tโข tโ โ f = tโ โ f โ tโ = tโ ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ Btโ:B โถ Ttโ:B โถ Th:tโ โ f = tโ โ fโข tโ = tโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ Btโ:B โถ Ttโ:B โถ Th:tโ โ f = tโ โ fโข tโ โ f โ s = tโ
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐T:๐f:A โถ Bs:B โถ Ahf:f โ s = ๐ Btโ:B โถ Ttโ:B โถ Th:tโ โ f = tโ โ fโข tโ โ f โ s = tโ
All goals completed! ๐
A map f with this cancellation property (if {t_1 \circ f = t_2 \circ f} then {t_1 = t_2}) for every T is called an epimorphism.
The corresponding mathlib definition is Epi, which we print below for reference.
#print Epi
Thus both 'monomorphism' and 'epimorphism' are 'cancellation' properties.
The mathlib theorems cancel_mono and cancel_epi are relevant here.
example {๐ : Type u} [Category.{v, u} ๐] {X Y Z : ๐}
(f : X โถ Y) [Mono f] {g h : Z โถ X}
: f โ g = f โ h โ g = h := cancel_mono f
example {๐ : Type u} [Category.{v, u} ๐] {X Y Z : ๐}
(f : X โถ Y) [Epi f] {g h : Y โถ Z}
: g โ f = h โ f โ g = h := cancel_epi f
If {A \xrightarrow{f} B} has a retraction and if {B \xrightarrow{g} C} has a retraction, then {A \xrightarrow{g \circ f} C} has a retraction.
Let {r_1 \circ f = 1_A} and {r_2 \circ g = 1_B}. Then a good guess for a retraction of the composite would be the composite of the retractions in the opposite order (which is anyway the only order in which they can be composed). Does it in fact work?
r \circ (g \circ f) = (r_1 \circ r_2) \circ (g \circ f) = r_1 \circ (r_2 \circ g) \circ f = r_1 \circ 1_B \circ f = r_1 \circ f = 1_A
proves that r is a retraction for {g \circ f}.
Our implementation in Lean faithfully follows the argument of the book proof given above.
theorem prop3 {๐ : Type u} [Category.{v, u} ๐] {A B C : ๐}
(f : A โถ B) [hf : IsRetraction f] (g : B โถ C) [hg : IsRetraction g]
: IsRetraction (g โ f) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bhf:IsRetraction fg:B โถ Chg:IsRetraction gโข IsRetraction (g โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Chg:IsRetraction grโ:B โถ Ahf:rโ โ f = ๐ Aโข IsRetraction (g โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Crโ:B โถ Ahf:rโ โ f = ๐ Arโ:C โถ Bhg:rโ โ g = ๐ Bโข IsRetraction (g โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Crโ:B โถ Ahf:rโ โ f = ๐ Arโ:C โถ Bhg:rโ โ g = ๐ Bโข autoParam ((rโ โ rโ) โ g โ f = ๐ A) SplitMono.id._autoParam
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Crโ:B โถ Ahf:rโ โ f = ๐ Arโ:C โถ Bhg:rโ โ g = ๐ Bโข (rโ โ rโ) โ g โ f = ๐ A
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Crโ:B โถ Ahf:rโ โ f = ๐ Arโ:C โถ Bhg:rโ โ g = ๐ Bโข (rโ โ rโ โ g) โ f = ๐ A
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Crโ:B โถ Ahf:rโ โ f = ๐ Arโ:C โถ Bhg:rโ โ g = ๐ Bโข (rโ โ ๐ B) โ f = ๐ A
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Crโ:B โถ Ahf:rโ โ f = ๐ Arโ:C โถ Bhg:rโ โ g = ๐ Bโข rโ โ f = ๐ A
All goals completed! ๐
We note that the corresponding mathlib instance is instIsSplitMonoComp.
example {๐ : Type u} [Category.{v, u} ๐] {A B C : ๐}
(f : A โถ B) [hf : IsRetraction f] (g : B โถ C) [hg : IsRetraction g]
: IsRetraction (g โ f) := instIsSplitMonoComp
Prove that the composite of two maps, each having sections, has itself a section.
Solution: Exercise 8
The section of the composite is the composite of the sections in the opposite order (cf. Proposition 3).
example {๐ : Type u} [Category.{v, u} ๐] {A B C : ๐}
(f : A โถ B) [hf : IsSection f] (g : B โถ C) [hg : IsSection g]
: IsSection (g โ f) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bhf:IsSection fg:B โถ Chg:IsSection gโข IsSection (g โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Chg:IsSection gsโ:B โถ Ahf:f โ sโ = ๐ Bโข IsSection (g โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Csโ:B โถ Ahf:f โ sโ = ๐ Bsโ:C โถ Bhg:g โ sโ = ๐ Cโข IsSection (g โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Csโ:B โถ Ahf:f โ sโ = ๐ Bsโ:C โถ Bhg:g โ sโ = ๐ Cโข autoParam ((g โ f) โ sโ โ sโ = ๐ C) SplitEpi.id._autoParam
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Csโ:B โถ Ahf:f โ sโ = ๐ Bsโ:C โถ Bhg:g โ sโ = ๐ Cโข (g โ f) โ sโ โ sโ = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Csโ:B โถ Ahf:f โ sโ = ๐ Bsโ:C โถ Bhg:g โ sโ = ๐ Cโข (g โ f โ sโ) โ sโ = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Csโ:B โถ Ahf:f โ sโ = ๐ Bsโ:C โถ Bhg:g โ sโ = ๐ Cโข (g โ ๐ B) โ sโ = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Csโ:B โถ Ahf:f โ sโ = ๐ Bsโ:C โถ Bhg:g โ sโ = ๐ Cโข g โ sโ = ๐ C
All goals completed! ๐
We note that the corresponding mathlib instance is instIsSplitEpiComp.
example {๐ : Type u} [Category.{v, u} ๐] {A B C : ๐}
(f : A โถ B) [hf : IsSection f] (g : B โถ C) [hg : IsSection g]
: IsSection (g โ f) := instIsSplitEpiComp
An endomap e is called idempotent if {e \circ e = e}.
We implement Idempotent and IsIdempotent in Lean as follows:
structure Idempotent {๐ : Type u} [Category.{v, u} ๐] (A : ๐) where
e : A โถ A
idem : e โ e = e
class IsIdempotent {๐ : Type u} [Category.{v, u} ๐] {A : ๐}
(e : A โถ A) where
idem : e โ e = e
Suppose r is a retraction of f (equivalently f is a section of r) and let {e = f \circ r}. Show that e is an idempotent.... Show that if f is an isomorphism, then e is the identity.
Solution: Exercise 9
variable {๐ : Type u} [Category.{v, u} ๐] {A B : ๐}
(f : A โถ B) (e : B โถ B)
We show that e is an idempotent.
example (r : Retraction f) (he : e = f โ r.retraction)
: IsIdempotent e := {
idem := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Be:B โถ Br:Retraction fhe:e = f โ r.retractionโข e โ e = e
All goals completed! ๐
}
We show that e is the identity if f is an isomorphism.
example [hf : IsIso f]
(r : Retraction f) (he : e = f โ r.retraction)
: e = ๐ B := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Be:B โถ Bhf:IsIso fr:Retraction fhe:e = f โ r.retractionโข e = ๐ B
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Be:B โถ Bhf:IsIso fr:Retraction fhe:e = f โ r.retractionfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bโข e = ๐ B
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Be:B โถ Bhf:IsIso fr:Retraction fhe:e = f โ r.retractionfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bโข e = (f โ r.retraction โ f) โ finv
repeat ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Be:B โถ Bhf:IsIso fr:Retraction fhe:e = f โ r.retractionfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bโข e = f โ r.retraction โ f โ finv
rwa [hfinv.2, Category.id_comp๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Be:B โถ Bhf:IsIso fr:Retraction fhe:e = f โ r.retractionfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bโข e = f โ r.retraction
If f has both a retraction r and a section s then {r = s}.
From the definition we have, if {A \xrightarrow{f} B}, both of the equations
r \circ f = 1_A \quad\text{and}\quad f \circ s = 1_B.
Then by the identity laws and the associative law
r = r \circ 1_B = r \circ (f \circ s) = (r \circ f) \circ s = 1_A \circ s = s.
Our implementation in Lean faithfully follows the argument of the book proof given above.
theorem uniqueness_of_inverses {๐ : Type u} [Category.{v, u} ๐]
{A B : ๐} (f : A โถ B) (r : Retraction f) (s : Section f)
: r.retraction = s.section_ := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fโข r.retraction = s.section_
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bs:Section fr:B โถ Ahr:r โ f = ๐ Aโข { retraction := r, id := hr }.retraction = s.section_
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข { retraction := r, id := hr }.retraction = { section_ := s, id := hs }.section_
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข r = s
calc
r = r โ ๐ B := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข r = r โ ๐ B All goals completed! ๐
_ = r โ (f โ s) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข r โ ๐ B = r โ f โ s All goals completed! ๐
_ = (r โ f) โ s := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข r โ f โ s = (r โ f) โ s All goals completed! ๐
_ = ๐ A โ s := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข (r โ f) โ s = ๐ A โ s All goals completed! ๐
_ = s := Category.comp_id s
4. Isomorphisms and automorphisms
A map {A \xrightarrow{f} B} is called an isomorphism if there exists another map {B \xrightarrow{f^{-1}} A} which is both a retraction and a section for f:
f \circ fโปยน = 1_B,\\\
fโปยน \circ f = 1_A.
Such a map f^{-1} is called the inverse map for f; since both of the two equations are required, the theorem of uniqueness of inverses shows that there is only one inverse.
We compare these definitions of isomorphism and inverse with the earlier definitions on p. 40. A proof that the two definitions of isomorphism are equivalent is given below.
example {๐ : Type u} [Category.{v, u} ๐] {A B : ๐}
(f : A โถ B) (r : Retraction f) (s : Section f)
: r.retraction = s.section_ โ IsIso f := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fโข r.retraction = s.section_ โ IsIso f
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fโข r.retraction = s.section_ โ IsIso f๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fโข IsIso f โ r.retraction = s.section_
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fโข r.retraction = s.section_ โ IsIso f ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fh:r.retraction = s.section_โข IsIso f
exact {
out := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fh:r.retraction = s.section_โข โ inv, inv โ f = ๐ A โง f โ inv = ๐ B
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fh:r.retraction = s.section_โข r.retraction โ f = ๐ A โง f โ r.retraction = ๐ B
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fh:r.retraction = s.section_โข r.retraction โ f = ๐ A๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fh:r.retraction = s.section_โข f โ r.retraction = ๐ B
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fh:r.retraction = s.section_โข r.retraction โ f = ๐ A All goals completed! ๐
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fh:r.retraction = s.section_โข f โ r.retraction = ๐ B ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fh:r.retraction = s.section_โข f โ s.section_ = ๐ B
All goals completed! ๐
}
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section fโข IsIso f โ r.retraction = s.section_ ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Br:Retraction fs:Section ffinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bโข r.retraction = s.section_
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bs:Section ffinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Br:B โถ Ahr:r โ f = ๐ Aโข { retraction := r, id := hr }.retraction = s.section_
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข { retraction := r, id := hr }.retraction = { section_ := s, id := hs }.section_
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข r = s
calc
r = r โ ๐ B := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข r = r โ ๐ B All goals completed! ๐
_ = r โ (f โ s) := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข r โ ๐ B = r โ f โ s All goals completed! ๐
_ = (r โ f) โ s := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข r โ f โ s = (r โ f) โ s All goals completed! ๐
_ = ๐ A โ s := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐f:A โถ Bfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Br:B โถ Ahr:r โ f = ๐ As:B โถ Ahs:f โ s = ๐ Bโข (r โ f) โ s = ๐ A โ s All goals completed! ๐
_ = s := Category.comp_id s
When working with inverse maps in Excercise 10, we make use of mathlib's CategoryTheory.inv, which we print below for reference.
#print CategoryTheory.inv
If {A \xrightarrow{f} B \xrightarrow{g} C} are both isomorphisms, then {g \circ f} is an isomorphism too, and {(g \circ f)^{-1} = f^{-1} \circ g^{-1}}.
Solution: Exercise 10
The inverse of the composite is the composite of the inverses in the opposite order.
open CategoryTheory in
example {๐ : Type u} [Category.{v, u} ๐] {A B C : ๐}
(f : A โถ B) [hf : IsIso f] (g : B โถ C) [hg : IsIso g]
: IsIso (g โ f) โง inv (g โ f) = inv f โ inv g := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bhf:IsIso fg:B โถ Chg:IsIso gโข IsIso (g โ f) โง inv (g โ f) = inv f โ inv g
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bhf:IsIso fg:B โถ Chg:IsIso gโข IsIso (g โ f)๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bhf:IsIso fg:B โถ Chg:IsIso gโข inv (g โ f) = inv f โ inv g
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bhf:IsIso fg:B โถ Chg:IsIso gโข IsIso (g โ f) ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Chg:IsIso gfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bโข IsIso (g โ f)
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข IsIso (g โ f)
exact {
out := ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข โ inv, inv โ g โ f = ๐ A โง (g โ f) โ inv = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (finv โ ginv) โ g โ f = ๐ A โง (g โ f) โ finv โ ginv = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (finv โ ginv) โ g โ f = ๐ A๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (g โ f) โ finv โ ginv = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (finv โ ginv) โ g โ f = ๐ A ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (finv โ ginv โ g) โ f = ๐ A
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (finv โ ๐ B) โ f = ๐ A
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข finv โ f = ๐ A
All goals completed! ๐
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (g โ f) โ finv โ ginv = ๐ C ๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (g โ f โ finv) โ ginv = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข (g โ ๐ B) โ ginv = ๐ C
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bg:B โถ Cfinv:B โถ Ahfinv:finv โ f = ๐ A โง f โ finv = ๐ Bginv:C โถ Bhginv:ginv โ g = ๐ B โง g โ ginv = ๐ Cโข g โ ginv = ๐ C
All goals completed! ๐
}
๐:Type uinstโ:Category.{v, u} ๐A:๐B:๐C:๐f:A โถ Bhf:IsIso fg:B โถ Chg:IsIso gโข inv (g โ f) = inv f โ inv g All goals completed! ๐
If {A = \{\mathit{Fatima}, \mathit{Omer}, \mathit{Alysia}\}} and {B = \{\mathit{coffee}, \mathit{tea}, \mathit{cocoa}\}}, find an example of an isomorphism {A \xrightarrow{f} B}. If {C = \{\mathit{true}, \mathit{false}\}}, can you find any isomorphism {A \rightarrow C}?
Solution: Exercise 11
namespace ExII_11
For convenience, we use finite types here instead of finite sets.
inductive A
| Fatima | Omer | Alysia
deriving Fintype
inductive B
| coffee | tea | cocoa
deriving Fintype
We give a map f and its inverse f^{-1} below, along with a proof that f is an isomorphism.
def f : A โถ B
| A.Fatima => B.coffee
| A.Omer => B.tea
| A.Alysia => B.cocoa
def finv : B โถ A
| B.coffee => A.Fatima
| B.tea => A.Omer
| B.cocoa => A.Alysia
example : IsIso f := {
out := โข โ inv, inv โ f = ๐ A โง f โ inv = ๐ B
โข finv โ f = ๐ A โง f โ finv = ๐ B
โข finv โ f = ๐ Aโข f โ finv = ๐ B
all_goals
x:Bโข (f โ finv) x = ๐ B x
โข (f โ finv) B.coffee = ๐ B B.coffeeโข (f โ finv) B.tea = ๐ B B.teaโข (f โ finv) B.cocoa = ๐ B B.cocoa โข (f โ finv) B.coffee = ๐ B B.coffeeโข (f โ finv) B.tea = ๐ B B.teaโข (f โ finv) B.cocoa = ๐ B B.cocoa All goals completed! ๐
}
end ExII_11
Since {\#A > \#C}, there can be no pair {A \xrightarrow{j} C}, {C \xrightarrow{p} A} such that {p \circ j = 1_A}; hence there is no isomorphism {A \rightarrow C}.
A map which is both an endomap and at the same time an isomorphism is usually called by the one word automorphism.
The corresponding mathlib definition is Aut, which we print below for reference.
#print Aut
Compare this to the mathlib definition End for endomorphisms of an object in a category.
#print End
How many isomorphisms are there from {A = \{\mathit{Fatima}, \mathit{Omer}, \mathit{Alysia}\}} to {B = \{\mathit{coffee}, \mathit{tea}, \mathit{cocoa}\}}? How many automorphisms of A are there? The answers should be less than 27 โ why?
Solution: Exercise 12
Provided two sets/types have the same number n of elements, the number of isomorphisms between them is n!; if the sets/types have different numbers of elements, then there are no isomorphisms between them. We implement this formula in Lean as follows:
def isoCount (ฮฑ ฮฒ : Type*) [Fintype ฮฑ] [Fintype ฮฒ] : โ :=
if Fintype.card ฮฑ = Fintype.card ฮฒ then
Nat.factorial (Fintype.card ฮฑ)
else
0
By the formula above, we have 6 different isomorphisms.
open ExII_11
#eval isoCount A B
Essentially the same formula applies to automorphisms, since an automorphism is just an isomorphism from a set/type to itself. Thus, there are also 6 different automorphisms of A.
abbrev autCount (ฮฑ : Type*) [Fintype ฮฑ] := isoCount ฮฑ ฮฑ
open ExII_11
#eval autCount A
By Alysia's formula, {3^3 = 27} is the number of distinct maps {A \rightarrow B} (or {A \rightarrow A}), so the number of isomorphisms between A and B (or automorphisms of A) must be less than 27.
An automorphism in the category of sets is also traditionally called a permutation, suggesting that it shifts the elements of its set around in a specified way.
Repeating the second part of Exercise 12, now using sets instead of types, we have
def permCount {ฮฑ : Type*} (s : Finset ฮฑ) : โ :=
if 0 < Finset.card s then
Nat.factorial (Finset.card s)
else
0
open ExII_11
#eval permCount (Finset.univ (ฮฑ := A))