1-- Isomorphisms in a small category2-- Part of Cumulus, the Grace17 mathematics library.3-- Copyright (c) 2026 Grant Passmore.4-- Released under the Apache License 2.0. See LICENSE in the repository root.5-- Authors: Grant Passmore67module Grace.Cumulus.Category.Isomorphism8import Core910-- g is a two-sided inverse of f.11predicate InversePair (C f g : Set) :=12 f ∈ mor(C) ∧ g ∈ mor(C) ∧ dom(C)(g) = cod(C)(f) ∧ cod(C)(g) = dom(C)(f) ∧13 comp(C)(g, f) = id(C)(dom(C)(f)) ∧ comp(C)(f, g) = id(C)(cod(C)(f))1415notationinfixr70"∘"=> call2(C.comp, _, _) viahypothesis InversePair(C, f, g) for C.mor1617predicate Isomorphism (C f : Set) :=18∃ g, InversePair(C, f, g)1920predicate Isomorphic (C a b : Set) :=21∃ f ∈ hom(C, a, b), Isomorphism(C, f)2223theorem InversePair.morphism (C f g : Set)24requires pair : InversePair(C, f, g)25shows f ∈ mor(C)26proof27simp [InversePair]2829theorem InversePair.inverse_morphism (C f g : Set)30requires pair : InversePair(C, f, g)31shows g ∈ mor(C)32proof33simp [InversePair]3435theorem InversePair.dom (C f g : Set)36requires pair : InversePair(C, f, g)37shows dom(C)(g) = cod(C)(f)38proof39obtain⟨fInM, gInM, domG, codG, leftLaw, rightLaw⟩:= pair40exact domG4142theorem InversePair.cod (C f g : Set)43requires pair : InversePair(C, f, g)44shows cod(C)(g) = dom(C)(f)45proof46obtain⟨fInM, gInM, domG, codG, leftLaw, rightLaw⟩:= pair47exact codG4849theorem InversePair.left (C f g : Set)50requires pair : InversePair(C, f, g)51shows g ∘ f = id(C)(dom(C)(f))52proof53obtain⟨fInM, gInM, domG, codG, leftLaw, rightLaw⟩:= pair54exact leftLaw5556theorem InversePair.right (C f g : Set)57requires pair : InversePair(C, f, g)58shows f ∘ g = id(C)(cod(C)(f))59proof60obtain⟨fInM, gInM, domG, codG, leftLaw, rightLaw⟩:= pair61exact rightLaw6263theorem InversePair.symmetric (C f g : Set)64requires pair : InversePair(C, f, g)65shows InversePair(C, g, f)66proof67obtain⟨fInM, gInM, domG, codG, leftLaw, rightLaw⟩:= pair68unfold InversePair69refine⟨gInM, fInM, ?_, ?_, ?_, ?_⟩70 . cc71 . cc72 . cc73 . cc7475section InverseLaws76variable (C : Set)77hypothesis category : Category(C)7879theorem InversePair.hom (f g : Set)80requires pair : InversePair(C, f, g)81shows f : dom(C)(f) ⟶ cod(C)(f)82proof83have fInM := InversePair.morphism with pair84exact Morphism.of_morphism with category, fInM8586theorem InversePair.inverse_hom (f g : Set)87requires pair : InversePair(C, f, g)88shows g : cod(C)(f) ⟶ dom(C)(f)89proof90obtain⟨fInM, gInM, domG, codG, gf, fg⟩:= pair91unfold Morphism92refine⟨gInM, domG, codG⟩9394theorem InversePair.inverse_of_hom (a b : Set) (f : a ⟶ b) (g : Set)95requires pair : InversePair(C, f, g)96shows g : b ⟶ a97proof98have gHom : g : cod(C)(f) ⟶ dom(C)(f) := InversePair.inverse_hom with category, pair99have domF : dom(C)(f) = a bycc100have codF : cod(C)(f) = b bycc101rw [domF, codF] at gHom102exact gHom103104theorem InversePair.left_hom (a b : Set) (f : a ⟶ b) (g : Set)105requires pair : InversePair(C, f, g)106shows g ∘ f = id(C)(a)107proof108have law : g ∘ f = id(C)(dom(C)(f)) := InversePair.left with pair109have domF : dom(C)(f) = a bycc110 rwa domF at law111112theorem InversePair.right_hom (a b : Set) (f : a ⟶ b) (g : Set)113requires pair : InversePair(C, f, g)114shows f ∘ g = id(C)(b)115proof116have law : f ∘ g = id(C)(cod(C)(f)) := InversePair.right with pair117have codF : cod(C)(f) = b bycc118 rwa codF at law119120-- Inverses are unique: a left inverse equals a right inverse.121theorem InversePair.unique (a b : Set) (f : a ⟶ b) (g k : b ⟶ a)122requires gf : g ∘ f = id(C)(a)123requires fk : f ∘ k = id(C)(b)124shows g = k125proof126calc127 g = g ∘ id(C)(b) :=bysimp [Category.id_right]128 _ = g ∘ (f ∘ k) :=byrw fk129 _ = (g ∘ f) ∘ k :=byrw Category.assoc130 _ = id(C)(a) ∘ k :=byrw gf131 _ = k :=bysimp [Category.id_left]132133theorem InversePair.eq_of_pairs (f g k : Set)134requires first : InversePair(C, f, g)135requires second : InversePair(C, f, k)136shows g = k137proof138have fHom : f : dom(C)(f) ⟶ cod(C)(f) := InversePair.hom with category, first139have gHom : g : cod(C)(f) ⟶ dom(C)(f) := InversePair.inverse_hom with category, first140have kHom : k : cod(C)(f) ⟶ dom(C)(f) := InversePair.inverse_hom with category, second141have gf : g ∘ f = id(C)(dom(C)(f)) := InversePair.left with first142have fk : f ∘ k = id(C)(cod(C)(f)) := InversePair.right with second143exact InversePair.unique with category, fHom, gHom, kHom, gf, fk144145end InverseLaws146147theorem InversePair.in_hom (C a b f g : Set)148requires pair : InversePair(C, f, g)149requires fHom : f ∈ hom(C, a, b)150shows g ∈ hom(C, b, a)151proof152obtain⟨fInM, gInM, domG, codG, gf, fg⟩:= pair153obtain⟨fInM2, domF, codF⟩:= hom.membership.forward with fHom154apply hom.membership.backward155refine⟨gInM, ?_, ?_⟩156 . cc157 . cc158159theorem InversePair.id (C a : Set)160requires category : Category(C)161requires aInO : a ∈ obj(C)162shows InversePair(C, id(C)(a), id(C)(a))163proof164have idInM := Category.id_closed with category, aInO165have domId := Category.id_dom with category, aInO166have codId := Category.id_cod with category, aInO167have idId := Category.id_id with category, aInO168unfold InversePair169refine⟨idInM, idInM, ?_, ?_, ?_, ?_⟩170 . cc171 . cc172 . cc173 . cc174175section InverseComposition176variable (C : Set)177hypothesis category : Category(C)178179-- The inverse of a composite is the composite of the inverses, reversed.180theorem InversePair.comp (a b c : Set) (f : a ⟶ b) (g : b ⟶ c) (k l : Set)181requires gPair : InversePair(C, g, k)182requires fPair : InversePair(C, f, l)183shows InversePair(C, g ∘ f, l ∘ k)184proof185have kHom : k : c ⟶ b := InversePair.inverse_of_hom with category, gPair186have lHom : l : b ⟶ a := InversePair.inverse_of_hom with category, fPair187have gfHom : g ∘ f : a ⟶ c bysynthesize188have lkHom : l ∘ k : c ⟶ a bysynthesize189have kg : k ∘ g = id(C)(b) := InversePair.left_hom with category, gPair190have gk : g ∘ k = id(C)(c) := InversePair.right_hom with category, gPair191have lf : l ∘ f = id(C)(a) := InversePair.left_hom with category, fPair192have fl : f ∘ l = id(C)(b) := InversePair.right_hom with category, fPair193have leftLaw : (l ∘ k) ∘ (g ∘ f) = id(C)(a)194calc195 (l ∘ k) ∘ (g ∘ f) = l ∘ (k ∘ (g ∘ f)) :=byrw Category.assoc196 _ = l ∘ ((k ∘ g) ∘ f) :=byrw Category.assoc197 _ = l ∘ (id(C)(b) ∘ f) :=byrw kg198 _ = l ∘ f :=byrw Category.id_left199 _ = id(C)(a) := lf200have rightLaw : (g ∘ f) ∘ (l ∘ k) = id(C)(c)201calc202 (g ∘ f) ∘ (l ∘ k) = g ∘ (f ∘ (l ∘ k)) :=byrw Category.assoc203 _ = g ∘ ((f ∘ l) ∘ k) :=byrw Category.assoc204 _ = g ∘ (id(C)(b) ∘ k) :=byrw fl205 _ = g ∘ k :=byrw Category.id_left206 _ = id(C)(c) := gk207unfold InversePair208refine⟨?_, ?_, ?_, ?_, ?_, ?_⟩209 . assumption210 . assumption211 . cc212 . cc213 . cc214 . cc215216end InverseComposition217218theorem Isomorphism.morphism (C f : Set)219requires iso : Isomorphism(C, f)220shows f ∈ mor(C)221proof222obtain⟨g, pair⟩:= iso223exact InversePair.morphism with pair224225theorem Isomorphism.of_pair (C f g : Set)226requires pair : InversePair(C, f, g)227shows Isomorphism(C, f)228proof229refine⟨g, pair⟩230231theorem Isomorphism.inverse (C f g : Set)232requires pair : InversePair(C, f, g)233shows Isomorphism(C, g)234proof235have symmetric := InversePair.symmetric with pair236exact Isomorphism.of_pair with symmetric237238theorem Isomorphism.id (C a : Set)239requires category : Category(C)240requires aInO : a ∈ obj(C)241shows Isomorphism(C, id(C)(a))242proof243have pair := InversePair.id with category, aInO244exact Isomorphism.of_pair with pair245246theorem Isomorphism.comp (C g f : Set)247requires category : Category(C)248requires gIso : Isomorphism(C, g)249requires fIso : Isomorphism(C, f)250requires composable : dom(C)(g) = cod(C)(f)251shows Isomorphism(C, g ∘ f)252proof253obtain⟨k, gPair⟩:= gIso254obtain⟨l, fPair⟩:= fIso255have gInM := InversePair.morphism with gPair256have fInM := InversePair.morphism with fPair257have fHom : f : dom(C)(f) ⟶ cod(C)(f) := Morphism.of_morphism with*258have gHom : g : cod(C)(f) ⟶ cod(C)(g) := Morphism.of_composable with*259have pair := InversePair.comp with category, fHom, gHom, gPair, fPair260exact Isomorphism.of_pair with pair261262-- Cancellation against an isomorphism.263theorem InversePair.cancel_left (C f g u v : Set)264requires category : Category(C)265requires pair : InversePair(C, f, g)266requires uInM : u ∈ mor(C)267requires vInM : v ∈ mor(C)268requires uComposable : dom(C)(f) = cod(C)(u)269requires vComposable : dom(C)(f) = cod(C)(v)270requires same : f ∘ u = f ∘ v271shows u = v272proof273obtain⟨fInM, gInM, domG, codG, gf, fg⟩:= pair274have unitU : id(C)(dom(C)(f)) ∘ u = u275have law := Category.left_unit with category, uInM276 rwa ← uComposable at law277have unitV : id(C)(dom(C)(f)) ∘ v = v278have law := Category.left_unit with category, vInM279 rwa ← vComposable at law280have assocU := Category.associative with281 category, gInM, fInM, uInM, domG, uComposable282have assocV := Category.associative with283 category, gInM, fInM, vInM, domG, vComposable284calc285 u = id(C)(dom(C)(f)) ∘ u :=byrw unitU286 _ = (g ∘ f) ∘ u :=byrw gf287 _ = g ∘ (f ∘ u) := assocU288 _ = g ∘ (f ∘ v) :=byrw same289 _ = (g ∘ f) ∘ v :=byrw assocV290 _ = id(C)(dom(C)(f)) ∘ v :=byrw gf291 _ = v := unitV292293theorem InversePair.cancel_right (C f g u v : Set)294requires category : Category(C)295requires pair : InversePair(C, f, g)296requires uInM : u ∈ mor(C)297requires vInM : v ∈ mor(C)298requires uComposable : dom(C)(u) = cod(C)(f)299requires vComposable : dom(C)(v) = cod(C)(f)300requires same : u ∘ f = v ∘ f301shows u = v302proof303obtain⟨fInM, gInM, domG, codG, gf, fg⟩:= pair304have unitU := Category.id_right_of_dom with category, uInM, uComposable305have unitV := Category.id_right_of_dom with category, vInM, vComposable306have fgComposable : dom(C)(f) = cod(C)(g) bycc307have assocU := Category.associative with308 category, uInM, fInM, gInM, uComposable, fgComposable309have assocV := Category.associative with310 category, vInM, fInM, gInM, vComposable, fgComposable311calc312 u = u ∘ id(C)(cod(C)(f)) :=byrw unitU313 _ = u ∘ (f ∘ g) :=byrw fg314 _ = (u ∘ f) ∘ g :=byrw assocU315 _ = (v ∘ f) ∘ g :=byrw same316 _ = v ∘ (f ∘ g) := assocV317 _ = v ∘ id(C)(cod(C)(f)) :=byrw fg318 _ = v := unitV319320-- A morphism that is inverted on both sides by the same morphism of each321-- side is an isomorphism; in particular a left and a right inverse agree.322theorem InversePair.of_left_right (C f g k : Set)323requires category : Category(C)324requires fInM : f ∈ mor(C)325requires gInM : g ∈ mor(C)326requires kInM : k ∈ mor(C)327requires domG : dom(C)(g) = cod(C)(f)328requires codK : cod(C)(k) = dom(C)(f)329requiresleft : g ∘ f = id(C)(dom(C)(f))330requiresright : f ∘ k = id(C)(cod(C)(f))331shows g = k ∧ InversePair(C, f, k)332proof333have unitG := Category.id_right_of_dom with category, gInM, domG334have unitK := Category.id_left_of_cod with category, kInM, codK335have fkComposable : dom(C)(f) = cod(C)(k) bycc336have assoc := Category.associative with337 category, gInM, fInM, kInM, domG, fkComposable338have equal : g = k339calc340 g = g ∘ id(C)(cod(C)(f)) :=byrw unitG341 _ = g ∘ (f ∘ k) :=byrwright342 _ = (g ∘ f) ∘ k :=byrw assoc343 _ = id(C)(dom(C)(f)) ∘ k :=byrwleft344 _ = k := unitK345constructor346 . exact equal347 . unfold InversePair348refine⟨fInM, kInM, ?_, codK, ?_, right⟩349 . cc350 . rw← equal351exactleft352353theorem Isomorphic.of_hom (C a b f : Set)354requires fHom : f ∈ hom(C, a, b)355requires iso : Isomorphism(C, f)356shows Isomorphic(C, a, b)357proof358refine⟨f, fHom, iso⟩359360theorem Isomorphic.reflexive (C a : Set)361requires category : Category(C)362requires aInO : a ∈ obj(C)363shows Isomorphic(C, a, a)364proof365have idHom := hom.id with category, aInO366have iso := Isomorphism.id with category, aInO367exact Isomorphic.of_hom with idHom, iso368369theorem Isomorphic.symmetric (C a b : Set)370requires h : Isomorphic(C, a, b)371shows Isomorphic(C, b, a)372proof373obtain⟨f, fHom, g, pair⟩:= h374have gHom := InversePair.in_hom with pair, fHom375have gIso := Isomorphism.inverse with pair376exact Isomorphic.of_hom with gHom, gIso377378theorem Isomorphic.transitive (C a b c : Set)379requires category : Category(C)380requires first : Isomorphic(C, a, b)381requires second : Isomorphic(C, b, c)382shows Isomorphic(C, a, c)383proof384obtain⟨f, fHom, fIso⟩:= first385obtain⟨g, gHom, gIso⟩:= second386have composable := hom.composable with gHom, fHom387have compHom := hom.comp with category, gHom, fHom388have compIso := Isomorphism.comp with category, gIso, fIso, composable389exact Isomorphic.of_hom with compHom, compIso390391-- Inverses transpose a commutative square: if e2 ∘ u = v ∘ e1 for392-- isomorphisms e1 : a → b and e2 : c → d with inverses k1 and k2, then393-- k2 ∘ v = u ∘ k1.394theorem InversePair.transpose (C a b c d e1 k1 e2 k2 u v : Set)395requires category : Category(C)396requires firstPair : InversePair(C, e1, k1)397requires secondPair : InversePair(C, e2, k2)398requires e1Hom : e1 ∈ hom(C, a, b)399requires e2Hom : e2 ∈ hom(C, c, d)400requires uHom : u ∈ hom(C, a, c)401requires vHom : v ∈ hom(C, b, d)402requires square : e2 ∘ u = v ∘ e1403shows k2 ∘ v = u ∘ k1404proof405have k1Hom := InversePair.in_hom with firstPair, e1Hom406have k2Hom := InversePair.in_hom with secondPair, e2Hom407have e1k1 : e1 ∘ k1 = id(C)(b)408have law := InversePair.right with firstPair409have codE := hom.cod with e1Hom410 rwa codE at law411have k2e2 : k2 ∘ e2 = id(C)(c)412have law := InversePair.left with secondPair413have domE := hom.dom with e2Hom414 rwa domE at law415have uk1Hom := hom.comp with category, uHom, k1Hom416have unitV := Category.id_right_hom with category, vHom417have unitUK := Category.id_left_hom with category, uk1Hom418have assocOne := Category.assoc_hom with category, vHom, e1Hom, k1Hom419have assocTwo := Category.assoc_hom with category, e2Hom, uHom, k1Hom420have assocThree := Category.assoc_hom with category, k2Hom, e2Hom, uk1Hom421calc422 k2 ∘ v = k2 ∘ (v ∘ id(C)(b)) :=byrw unitV423 _ = k2 ∘ (v ∘ (e1 ∘ k1)) :=byrw e1k1424 _ = k2 ∘ ((v ∘ e1) ∘ k1) :=byrw assocOne425 _ = k2 ∘ ((e2 ∘ u) ∘ k1) :=byrw square426 _ = k2 ∘ (e2 ∘ (u ∘ k1)) :=byrw assocTwo427 _ = (k2 ∘ e2) ∘ (u ∘ k1) :=byrw assocThree428 _ = id(C)(c) ∘ (u ∘ k1) :=byrw k2e2429 _ = u ∘ k1 := unitUK430431-- Isomorphism as a relation on the objects.432def isomorphismRelation (C : Set) : Set:=433 { p ∈ obj(C) × obj(C) |∃ a ∈ obj(C), ∃ b ∈ obj(C), p = (a, b) ∧434 Isomorphic(C, a, b) }435436theorem isomorphismRelation.relates (C a b : Set)437requires aInO : a ∈ obj(C)438requires bInO : b ∈ obj(C)439requires iso : Isomorphic(C, a, b)440shows relates(isomorphismRelation(C), a, b)441proof442unfold relates443apply isomorphismRelation.membership.backward444constructor445 . exact product.pair with aInO, bInO446 . refine⟨a, aInO, b, bInO, rfl, iso⟩447448theorem isomorphismRelation.reflects (C a b : Set)449requires related : relates(isomorphismRelation(C),450 a, b)451shows Isomorphic(C, a, b)452proof453unfold relates at related454obtain⟨bounded, c, cInO, d, dInO, shape, iso⟩:=455 isomorphismRelation.membership.forward with related456obtain⟨aEqual, bEqual⟩:= orderedPair.injective with shape457rw [aEqual, bEqual]458exact iso459460theorem isomorphismRelation.relation (C : Set)461shows RelationOn(isomorphismRelation(C), obj(C))462proof463unfold RelationOn464unfold RelationBetween465intros p member466obtain⟨bounded, rest⟩:= isomorphismRelation.membership.forward with member467exact bounded468469theorem isomorphismRelation.equivalence (C : Set)470requires category : Category(C)471shows Equivalence(obj(C), isomorphismRelation(C))472proof473have relation := isomorphismRelation.relation at C474unfold Equivalence475refine⟨relation, ?_, ?_, ?_⟩476 . intros a aInO477have iso := Isomorphic.reflexive with category, aInO478exact isomorphismRelation.relates with aInO, aInO, iso479 . intros a aInO b bInO related480have iso := isomorphismRelation.reflects with related481have back := Isomorphic.symmetric with iso482exact isomorphismRelation.relates with bInO, aInO, back483 . intros a aInO b bInO c cInO first second484have firstIso := isomorphismRelation.reflects with first485have secondIso := isomorphismRelation.reflects with second486have iso := Isomorphic.transitive with category, firstIso, secondIso487exact isomorphismRelation.relates with aInO, cInO, iso488489-- The isomorphism class of an object.490def isomorphismClass (C a : Set) : Set:=491 { b ∈ obj(C) | Isomorphic(C, a, b) }492493theorem isomorphismClass.subset (C a : Set)494shows isomorphismClass(C, a) ⊆ obj(C)495proof496intros b member497obtain⟨bInO, iso⟩:= isomorphismClass.membership.forward with member498exact bInO499500theorem isomorphismClass.self (C a : Set)501requires category : Category(C)502requires aInO : a ∈ obj(C)503shows a ∈ isomorphismClass(C, a)504proof505have iso := Isomorphic.reflexive with category, aInO506apply isomorphismClass.membership.backward507refine⟨aInO, iso⟩508509theorem isomorphismClass.symmetric (C a b : Set)510requires aInO : a ∈ obj(C)511requires member : b ∈ isomorphismClass(C, a)512shows a ∈ isomorphismClass(C, b)513proof514obtain⟨bInO, iso⟩:= isomorphismClass.membership.forward with member515have back := Isomorphic.symmetric with iso516apply isomorphismClass.membership.backward517refine⟨aInO, back⟩518519theorem isomorphismClass.subset_of_isomorphic (C a b : Set)520requires category : Category(C)521requires iso : Isomorphic(C, a, b)522shows isomorphismClass(C, b) ⊆523 isomorphismClass(C, a)524proof525intros c member526obtain⟨cInO, second⟩:= isomorphismClass.membership.forward with member527have chain := Isomorphic.transitive with category, iso, second528apply isomorphismClass.membership.backward529refine⟨cInO, chain⟩530531theorem isomorphismClass.eq_of_isomorphic (C a b : Set)532requires category : Category(C)533requires iso : Isomorphic(C, a, b)534shows isomorphismClass(C, a) =535 isomorphismClass(C, b)536proof537have back := Isomorphic.symmetric with iso538have forward := isomorphismClass.subset_of_isomorphic with category, iso539have backward := isomorphismClass.subset_of_isomorphic with category, back540exact Subset.antisymmetric with backward, forward541542theorem isomorphismClass.eq_of_member (C a b : Set)543requires category : Category(C)544requires member : b ∈ isomorphismClass(C, a)545shows isomorphismClass(C, a) =546 isomorphismClass(C, b)547proof548obtain⟨bInO, iso⟩:= isomorphismClass.membership.forward with member549exact isomorphismClass.eq_of_isomorphic with category, iso550551theorem isomorphismClass.disjoint_or_equal (C a b : Set)552requires category : Category(C)553requires aInO : a ∈ obj(C)554requires bInO : b ∈ obj(C)555shows Disjoint(isomorphismClass(C, a),556 isomorphismClass(C, b)) ∨557 isomorphismClass(C, a) =558 isomorphismClass(C, b)559proof560by_contra negated561have notDisjoint : ¬Disjoint(isomorphismClass(C, a),562 isomorphismClass(C, b))563intro disjoint564apply negated565left566exact disjoint567have common : Nonempty(isomorphismClass(C, a) ∩568 isomorphismClass(C, b))569apply Nonempty.of_ne_empty570intro emptyMeet571apply notDisjoint572unfold Disjoint573exact emptyMeet574obtain⟨c, cInMeet⟩:= common575obtain⟨cInA, cInB⟩:= intersection.membership.forward with cInMeet576have aClass := isomorphismClass.eq_of_member with category, cInA577have bClass := isomorphismClass.eq_of_member with category, cInB578apply negated579right580cc581582-- The inverse of an isomorphism, as the unique morphism inverting it.583defunique inverseMorphism (C f : Set) (g ∈ mor(C)) :=584 InversePair(C, f, g)585requires category : Category(C)586requires iso : Isomorphism(C, f)587proof588obtain⟨g, pair⟩:= iso589have gInM := InversePair.inverse_morphism with pair590refine⟨g, gInM, pair⟩591uniqueness592intros u hu first v hv second593exact InversePair.eq_of_pairs with category, first, second594595theorem inverseMorphism.pair (C f : Set)596requires category : Category(C)597requires iso : Isomorphism(C, f)598shows InversePair(C, f,599 inverseMorphism(C, f))600proof601have selected := inverseMorphism.selected at C, f with602 category, iso603exact selected.right604605theorem inverseMorphism.morphism (C f : Set)606requires category : Category(C)607requires iso : Isomorphism(C, f)608shows inverseMorphism(C, f) ∈ mor(C)609proof610have selected := inverseMorphism.selected at C, f with611 category, iso612exact selected.left613614theorem inverseMorphism.eq (C f g : Set)615requires category : Category(C)616requires pair : InversePair(C, f, g)617shows inverseMorphism(C, f) = g618proof619have iso := Isomorphism.of_pair with pair620have canonical := inverseMorphism.pair with category, iso621exact InversePair.eq_of_pairs with category, canonical, pair622623theorem inverseMorphism.in_hom (C a b f : Set)624requires category : Category(C)625requires iso : Isomorphism(C, f)626requires fHom : f ∈ hom(C, a, b)627shows inverseMorphism(C, f) ∈ hom(C, b, a)628proof629have pair := inverseMorphism.pair with category, iso630exact InversePair.in_hom with pair, fHom631632theorem inverseMorphism.isomorphism (C f : Set)633requires category : Category(C)634requires iso : Isomorphism(C, f)635shows Isomorphism(C, inverseMorphism(C, f))636proof637have pair := inverseMorphism.pair with category, iso638exact Isomorphism.inverse with pair639640theorem inverseMorphism.involutive (C f : Set)641requires category : Category(C)642requires iso : Isomorphism(C, f)643shows inverseMorphism(C, inverseMorphism(C, f)) = f644proof645have pair := inverseMorphism.pair with category, iso646have symmetric := InversePair.symmetric with pair647exact inverseMorphism.eq with category, symmetric648649theorem inverseMorphism.id (C a : Set)650requires category : Category(C)651requires aInO : a ∈ obj(C)652shows inverseMorphism(C, id(C)(a)) = id(C)(a)653proof654have pair := InversePair.id with category, aInO655exact inverseMorphism.eq with category, pair656657theorem inverseMorphism.comp (C g f : Set)658requires category : Category(C)659requires gIso : Isomorphism(C, g)660requires fIso : Isomorphism(C, f)661requires composable : dom(C)(g) = cod(C)(f)662shows inverseMorphism(C, g ∘ f) =663 inverseMorphism(C, f) ∘664 inverseMorphism(C, g)665proof666have gPair := inverseMorphism.pair with category, gIso667have fPair := inverseMorphism.pair with category, fIso668have gInM := Isomorphism.morphism with gIso669have fInM := Isomorphism.morphism with fIso670have fHom : f : dom(C)(f) ⟶ cod(C)(f) := Morphism.of_morphism with*671have gHom : g : cod(C)(f) ⟶ cod(C)(g) := Morphism.of_composable with*672have pair := InversePair.comp with category, fHom, gHom, gPair, fPair673exact inverseMorphism.eq with category, pair674675theorem inverseMorphism.left (C f : Set)676requires category : Category(C)677requires iso : Isomorphism(C, f)678shows inverseMorphism(C, f) ∘ f = id(C)(dom(C)(f))679proof680have pair := inverseMorphism.pair with category, iso681exact InversePair.left with pair682683theorem inverseMorphism.right (C f : Set)684requires category : Category(C)685requires iso : Isomorphism(C, f)686shows f ∘ inverseMorphism(C, f) = id(C)(cod(C)(f))687proof688have pair := inverseMorphism.pair with category, iso689exact InversePair.right with pair690