Skip to content

Instantly share code, notes, and snippets.

@gaxiiiiiiiiiiii
Created August 29, 2025 14:13
Show Gist options
  • Select an option

  • Save gaxiiiiiiiiiiii/3272b907be8f45a809cde35f123e811c to your computer and use it in GitHub Desktop.

Select an option

Save gaxiiiiiiiiiiii/3272b907be8f45a809cde35f123e811c to your computer and use it in GitHub Desktop.
U : ๐“ โฅค ๐“‘ ใŒๅณ้šไผดใงใ‚ใ‚‹ไบ‹ใ€ ไปปๆ„ใฎBใซใคใ„ใฆHom(B, U -)ใŒ่กจ็พๅฏ่ƒฝใงใ‚ใ‚‹ไบ‹ใ€ใฎๅŒๅ€คๆ€งใ‚’่จผๆ˜Ž
import Mathlib
open CategoryTheory
example [Category ๐“] [Category ๐“‘] (U : ๐“ โฅค ๐“‘) :
U.IsRightAdjoint โ†” โˆ€ B : ๐“‘, (U โ‹™ coyoneda.obj (Opposite.op B)).IsCorepresentable
:= by
constructor<;> intro H
ยท rcases H with โŸจF, โŸจฯƒโŸฉโŸฉ
intro B; constructor
use F.obj B; constructor
refine {
homEquiv := by
intro A; simp
exact ฯƒ.homEquiv B A
homEquiv_comp {A A'} f g := by
simp
rw [ฯƒ.homEquiv_apply, ฯƒ.homEquiv_apply, U.map_comp, Category.assoc]
}
ยท
let F : ๐“‘ โฅค ๐“ := {
obj B := (H B).has_corepresentation.choose
map {B B'} f :=
(H B).has_corepresentation.choose_spec.some.homEquiv.symm
(f โ‰ซ (H B').has_corepresentation.choose_spec.some.homEquiv
(๐Ÿ™ (H B').has_corepresentation.choose)
)
map_id B := by simp
map_comp {Bโ‚ Bโ‚‚ Bโ‚ƒ} f g := by
simp
let HBโ‚ := (H Bโ‚).has_corepresentation
let HBโ‚‚ := (H Bโ‚‚).has_corepresentation
let HBโ‚ƒ := (H Bโ‚ƒ).has_corepresentation
let ฯƒโ‚ := HBโ‚.choose_spec.some
let ฯƒโ‚‚ := HBโ‚‚.choose_spec.some
let ฯƒโ‚ƒ := HBโ‚ƒ.choose_spec.some
let Aโ‚ := HBโ‚.choose
let Aโ‚‚ := HBโ‚‚.choose
let Aโ‚ƒ := HBโ‚ƒ.choose
set L : Aโ‚ โŸถ Aโ‚‚ := ฯƒโ‚.homEquiv.symm (f โ‰ซ ฯƒโ‚‚.homEquiv (๐Ÿ™ Aโ‚‚))
set R : Aโ‚‚ โŸถ Aโ‚ƒ := ฯƒโ‚‚.homEquiv.symm (g โ‰ซ ฯƒโ‚ƒ.homEquiv (๐Ÿ™ Aโ‚ƒ))
set F : Aโ‚ โŸถ Aโ‚ƒ := ฯƒโ‚.homEquiv.symm (f โ‰ซ g โ‰ซ ฯƒโ‚ƒ.homEquiv (๐Ÿ™ Aโ‚ƒ))
change F = L โ‰ซ R
have E := ฯƒโ‚.homEquiv_comp R L; simp at E
have := (ฯƒโ‚.homEquiv (Y := Aโ‚ƒ)).left_inv (L โ‰ซ R)
rw [<- this]; clear this
conv => arg 2; arg 2; simp; rw [E]
simp; clear E
conv => arg 2; arg 2; arg 1; simp [L]; change ฯƒโ‚.homEquiv.toFun (ฯƒโ‚.homEquiv.invFun (f โ‰ซ ฯƒโ‚‚.homEquiv (๐Ÿ™ Aโ‚‚)))
have E := ฯƒโ‚.homEquiv.right_inv (f โ‰ซ ฯƒโ‚‚.homEquiv (๐Ÿ™ Aโ‚‚))
rw [E]; simp [F]; clear E
have E := ฯƒโ‚‚.homEquiv_comp R (๐Ÿ™ Aโ‚‚); simp at E
rw [<- E, Category.id_comp]
simp only [R]; simp
have := ฯƒโ‚‚.homEquiv.right_inv (g โ‰ซ ฯƒโ‚ƒ.homEquiv (๐Ÿ™ Aโ‚ƒ)); simp at this
nth_rw 1 [<- this]
}
constructor; use F; constructor
refine {
unit := {
app B :=
(H B).has_corepresentation.choose_spec.some.homEquiv
(๐Ÿ™ (H B).has_corepresentation.choose)
naturality {B B'} f := by
simp [F]
set HB := (H B).has_corepresentation.choose_spec
set HB' := (H B').has_corepresentation.choose_spec
let A := (H B).has_corepresentation.choose
let A' := (H B').has_corepresentation.choose
change f โ‰ซ HB'.some.homEquiv (๐Ÿ™ A') = HB.some.homEquiv (๐Ÿ™ A) โ‰ซ U.map (HB.some.homEquiv.symm (f โ‰ซ HB'.some.homEquiv (๐Ÿ™ A')))
set R := (HB.some.homEquiv.symm (f โ‰ซ HB'.some.homEquiv (๐Ÿ™ A')))
have E := HB.some.homEquiv_comp R (๐Ÿ™ A); simp at E
rw [Category.id_comp] at E
conv at E => arg 1; simp [R]; change HB.some.homEquiv.toFun (HB.some.homEquiv.invFun (f โ‰ซ HB'.some.homEquiv (๐Ÿ™ A')))
have := HB.some.homEquiv.right_inv (f โ‰ซ HB'.some.homEquiv (๐Ÿ™ A'))
rw [this] at E
rw [E]; rfl
}
counit := {
app A := ((H (U.obj A)).has_corepresentation.choose_spec.some.homEquiv (Y := A)).symm (๐Ÿ™ _)
naturality {A A'} f := by
simp [F]
set HA := (H (U.obj A)).has_corepresentation.choose_spec
set HA' := (H (U.obj A')).has_corepresentation.choose_spec
let B' := (H (U.obj A')).has_corepresentation.choose
let B := (H (U.obj A)).has_corepresentation.choose
conv => arg 1; arg 1; arg 2; arg 2; arg 2; change ๐Ÿ™ B'
let L : B โŸถ B' := HA.some.homEquiv.symm (U.map f โ‰ซ HA'.some.homEquiv (๐Ÿ™ B'))
let R : B' โŸถ A' := HA'.some.homEquiv.symm (๐Ÿ™ (U.obj A'))
change L โ‰ซ R = _
have E := HA.some.homEquiv_comp R L; simp at E
have := HA.some.homEquiv.left_inv (L โ‰ซ R)
conv => arg 1; rw [<- this]; arg 2; simp; rw [E]; arg 1; simp [L]; change HA.some.homEquiv.toFun (HA.some.homEquiv.invFun (U.map f โ‰ซ HA'.some.homEquiv (๐Ÿ™ B')))
clear this E
have E := HA.some.homEquiv.right_inv (U.map f โ‰ซ HA'.some.homEquiv (๐Ÿ™ B'))
rw [E]; simp; clear E
have E := HA'.some.homEquiv_comp R (๐Ÿ™ B'); simp at E
rw [<- E, Category.id_comp]; simp [R]; clear E
conv => arg 1; arg 2; arg 2; change HA'.some.homEquiv.toFun (HA'.some.homEquiv.invFun (๐Ÿ™ (U.obj A')))
have E := HA'.some.homEquiv.right_inv (๐Ÿ™ (U.obj A')); rw [E, Category.comp_id]; clear E
have E := HA.some.homEquiv_comp f (HA.some.homEquiv.symm (๐Ÿ™ (U.obj A))); simp at E
conv at E => arg 2; arg 1; change HA.some.homEquiv.toFun (HA.some.homEquiv.invFun (๐Ÿ™ (U.obj A)))
have := HA.some.homEquiv.right_inv (๐Ÿ™ (U.obj A)); rw [this] at E; clear this; simp at E
apply (Equiv.symm_apply_eq HA.some.homEquiv).mpr
rw [<- E]; simp
}
left_triangle_components B := by
simp [F]
set HB := (H B).has_corepresentation.choose_spec
set HB' := (H (U.obj (F.obj B))).has_corepresentation.choose_spec
let A := (H B).has_corepresentation.choose
let A' := (H (U.obj (F.obj B))).has_corepresentation.choose
change HB.some.homEquiv.symm (HB.some.homEquiv (๐Ÿ™ A) โ‰ซ HB'.some.homEquiv (๐Ÿ™ A')) โ‰ซ HB'.some.homEquiv.symm (๐Ÿ™ (U.obj A)) = ๐Ÿ™ A
set L : A โŸถ A' := HB.some.homEquiv.symm (HB.some.homEquiv (๐Ÿ™ A) โ‰ซ HB'.some.homEquiv (๐Ÿ™ A'))
set R : A' โŸถ A := HB'.some.homEquiv.symm (๐Ÿ™ (U.obj A))
have E := HB.some.homEquiv.left_inv (L โ‰ซ R)
have E' := HB.some.homEquiv_comp R L; simp at E'
conv => arg 1; rw [<- E]; arg 2; simp; rw [E']; simp [L]; simp
clear E E'
set F := (HB.some.homEquiv (๐Ÿ™ A) โ‰ซ HB'.some.homEquiv (๐Ÿ™ A'))
have E := HB.some.homEquiv.right_inv F; dsimp at F
conv => arg 1; arg 2; arg 1; change HB.some.homEquiv.toFun (HB.some.homEquiv.invFun F); rw [E]
simp [F]; clear E F
have E := HB'.some.homEquiv_comp R (๐Ÿ™ A') ; simp at E
rw [<- E, Category.id_comp]; simp [R]; clear E
have E := HB'.some.homEquiv.right_inv (๐Ÿ™ (U.obj A)); dsimp at E
rw [E]; simp
right_triangle_components A := by
simp
set ฯƒ := (H (U.obj A)).has_corepresentation.choose_spec.some
let B := (H (U.obj A)).has_corepresentation.choose
conv => arg 1; arg 1; arg 2; change ๐Ÿ™ B
have E := ฯƒ.homEquiv_comp ((ฯƒ.homEquiv.symm (๐Ÿ™ (U.obj A)))) (๐Ÿ™ B); simp at E
rw [<- E, Category.id_comp]; clear E
have E := ฯƒ.homEquiv.right_inv (๐Ÿ™ (U.obj A)); dsimp at E
rw [E]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment