Theorem: TopCat.Presheaf.toTypes_isSheaf
File: Mathlib/Topology/Sheaves/SheafOfFunctions.lean

tactic: choose index index_spec using fun x : ↑(iSup U) => Opens.mem_iSup.mp x.2
state_before: X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
⊢ ∃! s, IsGluing (presheafToTypes X T) U sf s

tactic: let s : ∀ x : ↑(iSup U), T x := fun x => sf (index x) ⟨x.1, index_spec x⟩
state_before: X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
index : { x // x ∈ iSup U } → ι
index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x)
⊢ ∃! s, IsGluing (presheafToTypes X T) U sf s

tactic: refine' ⟨s, _, _⟩
state_before: X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
index : { x // x ∈ iSup U } → ι
index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x)
s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) }
⊢ ∃! s, IsGluing (presheafToTypes X T) U sf s

tactic: intro i
state_before: case refine'_1
X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
index : { x // x ∈ iSup U } → ι
index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x)
s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) }
⊢ (fun s => IsGluing (presheafToTypes X T) U sf s) s

tactic: funext x
state_before: case refine'_1
X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
index : { x // x ∈ iSup U } → ι
index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x)
s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) }
i : ι
⊢ (forget (Type u)).map ((presheafToTypes X T).map (leSupr U i).op) s = sf i

tactic: exact congr_fun (hsf (index ⟨x, _⟩) i) ⟨x, ⟨index_spec ⟨x.1, _⟩, x.2⟩⟩
state_before: case refine'_1.h
X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
index : { x // x ∈ iSup U } → ι
index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x)
s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) }
i : ι
x : { x // x ∈ (U i).op.unop }
⊢ (forget (Type u)).map ((presheafToTypes X T).map (leSupr U i).op) s x = sf i x

tactic: intro t ht
state_before: case refine'_2
X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
index : { x // x ∈ iSup U } → ι
index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x)
s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) }
⊢ ∀ (y : (forget (Type u)).obj ((presheafToTypes X T).obj (iSup U).op)),
    (fun s => IsGluing (presheafToTypes X T) U sf s) y → y = s

tactic: funext x
state_before: case refine'_2
X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
index : { x // x ∈ iSup U } → ι
index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x)
s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) }
t : (forget (Type u)).obj ((presheafToTypes X T).obj (iSup U).op)
ht : IsGluing (presheafToTypes X T) U sf t
⊢ t = s

tactic: exact congr_fun (ht (index x)) ⟨x.1, index_spec x⟩
state_before: case refine'_2.h
X : TopCat
T : ↑X → Type u
ι : Type u
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type u)).obj ((presheafToTypes X T).obj (U i).op)
hsf : IsCompatible (presheafToTypes X T) U sf
index : { x // x ∈ iSup U } → ι
index_spec : ∀ (x : { x // x ∈ iSup U }), ↑x ∈ U (index x)
s : (x : { x // x ∈ iSup U }) → T ↑x := fun x => sf (index x) { val := ↑x, property := (_ : ↑x ∈ U (index x)) }
t : (forget (Type u)).obj ((presheafToTypes X T).obj (iSup U).op)
ht : IsGluing (presheafToTypes X T) U sf t
x : { x // x ∈ (iSup U).op.unop }
⊢ t x = s x