l3lab/ntp-mathlib huggingface dataset:
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
  { continuousPrelocal X T with
    locality := fun {U} f w => by
      

Proof state:
X : TopCat
T✝ : ↑X → Type v
T : TopCat
src✝ : PrelocalPredicate fun x => ↑T := continuousPrelocal X T
U : Opens ↑X
f : ↥U → ↑T
w :
  ∀ (x : ↥U),
    ∃ V,
      ∃ (_ : ↑x ∈ V),
        ∃ i,
          PrelocalPredicate.pred
            { pred := fun {U} => PrelocalPredicate.pred src✝,
              res :=
                (_ :
                  ∀ {U V : Opens ↑X} (i : U ⟶ V) (f : ↥V → ↑T),
                    PrelocalPredicate.pred src✝ f →
                      PrelocalPredicate.pred src✝ fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
            fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ PrelocalPredicate.pred
    { pred := fun {U} => PrelocalPredicate.pred src✝,
      res :=
        (_ :
          ∀ {U V : Opens ↑X} (i : U ⟶ V) (f : ↥V → ↑T),
            PrelocalPredicate.pred src✝ f →
              PrelocalPredicate.pred src✝ fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
    f

Next tactic:
apply continuous_iff_continuousAt.2
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
  { continuousPrelocal X T with
    locality := fun {U} f w => by
      apply continuous_iff_continuousAt.2
      

Proof state:
X : TopCat
T✝ : ↑X → Type v
T : TopCat
src✝ : PrelocalPredicate fun x => ↑T := continuousPrelocal X T
U : Opens ↑X
f : ↥U → ↑T
w :
  ∀ (x : ↥U),
    ∃ V,
      ∃ (_ : ↑x ∈ V),
        ∃ i,
          PrelocalPredicate.pred
            { pred := fun {U} => PrelocalPredicate.pred src✝,
              res :=
                (_ :
                  ∀ {U V : Opens ↑X} (i : U ⟶ V) (f : ↥V → ↑T),
                    PrelocalPredicate.pred src✝ f →
                      PrelocalPredicate.pred src✝ fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
            fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ ∀ (x : ↥U), ContinuousAt f x

Next tactic:
intro x
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
  { continuousPrelocal X T with
    locality := fun {U} f w => by
      apply continuous_iff_continuousAt.2
      intro x
      

Proof state:
X : TopCat
T✝ : ↑X → Type v
T : TopCat
src✝ : PrelocalPredicate fun x => ↑T := continuousPrelocal X T
U : Opens ↑X
f : ↥U → ↑T
w :
  ∀ (x : ↥U),
    ∃ V,
      ∃ (_ : ↑x ∈ V),
        ∃ i,
          PrelocalPredicate.pred
            { pred := fun {U} => PrelocalPredicate.pred src✝,
              res :=
                (_ :
                  ∀ {U V : Opens ↑X} (i : U ⟶ V) (f : ↥V → ↑T),
                    PrelocalPredicate.pred src✝ f →
                      PrelocalPredicate.pred src✝ fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
            fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
x : ↥U
⊢ ContinuousAt f x

Next tactic:
specialize w x
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
  { continuousPrelocal X T with
    locality := fun {U} f w => by
      apply continuous_iff_continuousAt.2
      intro x
      specialize w x
      

Proof state:
X : TopCat
T✝ : ↑X → Type v
T : TopCat
src✝ : PrelocalPredicate fun x => ↑T := continuousPrelocal X T
U : Opens ↑X
f : ↥U → ↑T
x : ↥U
w :
  ∃ V,
    ∃ (_ : ↑x ∈ V),
      ∃ i,
        PrelocalPredicate.pred
          { pred := fun {U} => PrelocalPredicate.pred src✝,
            res :=
              (_ :
                ∀ {U V : Opens ↑X} (i : U ⟶ V) (f : ↥V → ↑T),
                  PrelocalPredicate.pred src✝ f →
                    PrelocalPredicate.pred src✝ fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
          fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ ContinuousAt f x

Next tactic:
rcases w with ⟨V, m, i, w⟩
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
  { continuousPrelocal X T with
    locality := fun {U} f w => by
      apply continuous_iff_continuousAt.2
      intro x
      specialize w x
      rcases w with ⟨V, m, i, w⟩
      

Proof state:
case intro.intro.intro
X : TopCat
T✝ : ↑X → Type v
T : TopCat
src✝ : PrelocalPredicate fun x => ↑T := continuousPrelocal X T
U : Opens ↑X
f : ↥U → ↑T
x : ↥U
V : Opens ↑X
m : ↑x ∈ V
i : V ⟶ U
w :
  PrelocalPredicate.pred
    { pred := fun {U} => PrelocalPredicate.pred src✝,
      res :=
        (_ :
          ∀ {U V : Opens ↑X} (i : U ⟶ V) (f : ↥V → ↑T),
            PrelocalPredicate.pred src✝ f →
              PrelocalPredicate.pred src✝ fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
    fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ ContinuousAt f x

Next tactic:
dsimp at w
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
  { continuousPrelocal X T with
    locality := fun {U} f w => by
      apply continuous_iff_continuousAt.2
      intro x
      specialize w x
      rcases w with ⟨V, m, i, w⟩
      dsimp at w
      

Proof state:
case intro.intro.intro
X : TopCat
T✝ : ↑X → Type v
T : TopCat
src✝ : PrelocalPredicate fun x => ↑T := continuousPrelocal X T
U : Opens ↑X
f : ↥U → ↑T
x : ↥U
V : Opens ↑X
m : ↑x ∈ V
i : V ⟶ U
w : Continuous fun x => f { val := ↑x, property := (_ : ↑x ∈ ↑U) }
⊢ ContinuousAt f x

Next tactic:
rw [continuous_iff_continuousAt] at w
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
  { continuousPrelocal X T with
    locality := fun {U} f w => by
      apply continuous_iff_continuousAt.2
      intro x
      specialize w x
      rcases w with ⟨V, m, i, w⟩
      dsimp at w
      rw [continuous_iff_continuousAt] at w
      

Proof state:
case intro.intro.intro
X : TopCat
T✝ : ↑X → Type v
T : TopCat
src✝ : PrelocalPredicate fun x => ↑T := continuousPrelocal X T
U : Opens ↑X
f : ↥U → ↑T
x : ↥U
V : Opens ↑X
m : ↑x ∈ V
i : V ⟶ U
w : ∀ (x : ↥V), ContinuousAt (fun x => f { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x
⊢ ContinuousAt f x

Next tactic:
specialize w ⟨x, m⟩
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
  { continuousPrelocal X T with
    locality := fun {U} f w => by
      apply continuous_iff_continuousAt.2
      intro x
      specialize w x
      rcases w with ⟨V, m, i, w⟩
      dsimp at w
      rw [continuous_iff_continuousAt] at w
      specialize w ⟨x, m⟩
      

Proof state:
case intro.intro.intro
X : TopCat
T✝ : ↑X → Type v
T : TopCat
src✝ : PrelocalPredicate fun x => ↑T := continuousPrelocal X T
U : Opens ↑X
f : ↥U → ↑T
x : ↥U
V : Opens ↑X
m : ↑x ∈ V
i : V ⟶ U
w : ContinuousAt (fun x => f { val := ↑x, property := (_ : ↑x ∈ ↑U) }) { val := ↑x, property := m }
⊢ ContinuousAt f x

Next tactic:
simpa using (Opens.openEmbedding_of_le i.le).continuousAt_iff.1 w
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    

Proof state:
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
V U : Opens ↑X
i : V ⟶ U
f : (x : ↥U) → T ↑x
w :
  (fun {U} f =>
      ∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
    f
x : ↥V
⊢ ∃ V_1,
    ∃ (_ : ↑x ∈ V_1),
      ∃ i_1,
        pred P fun x =>
          (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
            ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)

Next tactic:
specialize w (i x)
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    specialize w (i x)
    

Proof state:
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
V U : Opens ↑X
i : V ⟶ U
f : (x : ↥U) → T ↑x
x : ↥V
w :
  ∃ V_1,
    ∃ (_ : ↑((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x) ∈ V_1),
      ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ ∃ V_1,
    ∃ (_ : ↑x ∈ V_1),
      ∃ i_1,
        pred P fun x =>
          (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
            ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)

Next tactic:
rcases w with ⟨V', m', i', p⟩
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    specialize w (i x)
    rcases w with ⟨V', m', i', p⟩
    

Proof state:
case intro.intro.intro
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
V U : Opens ↑X
i : V ⟶ U
f : (x : ↥U) → T ↑x
x : ↥V
V' : Opens ↑X
m' : ↑((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x) ∈ V'
i' : V' ⟶ U
p : pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ ∃ V_1,
    ∃ (_ : ↑x ∈ V_1),
      ∃ i_1,
        pred P fun x =>
          (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
            ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)

Next tactic:
refine' ⟨V ⊓ V', ⟨x.2, m'⟩, Opens.infLELeft _ _, _⟩
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    specialize w (i x)
    rcases w with ⟨V', m', i', p⟩
    refine' ⟨V ⊓ V', ⟨x.2, m'⟩, Opens.infLELeft _ _, _⟩
    

Proof state:
case intro.intro.intro
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
V U : Opens ↑X
i : V ⟶ U
f : (x : ↥U) → T ↑x
x : ↥V
V' : Opens ↑X
m' : ↑((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x) ∈ V'
i' : V' ⟶ U
p : pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ pred P fun x =>
    (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
      ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)

Next tactic:
convert P.res (Opens.infLERight V V') _ p
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    specialize w (i x)
    rcases w with ⟨V', m', i', p⟩
    refine' ⟨V ⊓ V', ⟨x.2, m'⟩, Opens.infLELeft _ _, _⟩
    convert P.res (Opens.infLERight V V') _ p
  locality {U} f w x := by
    

Proof state:
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
U : Opens ↑X
f : (x : ↥U) → T ↑x
w :
  ∀ (x : ↥U),
    ∃ V,
      ∃ (_ : ↑x ∈ V),
        ∃ i,
          pred
            {
              pred := fun {U} f =>
                ∀ (x : ↥U),
                  ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x),
              res :=
                (_ :
                  ∀ {V U : Opens ↑X} (i : V ⟶ U) (f : (x : ↥U) → T ↑x),
                    (∀ (x : ↥U),
                        ∃ V,
                          ∃ (_ : ↑x ∈ V),
                            ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)) →
                      ∀ (x : ↥V),
                        ∃ V_1,
                          ∃ (_ : ↑x ∈ V_1),
                            ∃ i_1,
                              pred P fun x =>
                                (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
                                  ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
            fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
x : ↥U
⊢ ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)

Next tactic:
specialize w x
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    specialize w (i x)
    rcases w with ⟨V', m', i', p⟩
    refine' ⟨V ⊓ V', ⟨x.2, m'⟩, Opens.infLELeft _ _, _⟩
    convert P.res (Opens.infLERight V V') _ p
  locality {U} f w x := by
    specialize w x
    

Proof state:
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
U : Opens ↑X
f : (x : ↥U) → T ↑x
x : ↥U
w :
  ∃ V,
    ∃ (_ : ↑x ∈ V),
      ∃ i,
        pred
          {
            pred := fun {U} f =>
              ∀ (x : ↥U),
                ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x),
            res :=
              (_ :
                ∀ {V U : Opens ↑X} (i : V ⟶ U) (f : (x : ↥U) → T ↑x),
                  (∀ (x : ↥U),
                      ∃ V,
                        ∃ (_ : ↑x ∈ V),
                          ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)) →
                    ∀ (x : ↥V),
                      ∃ V_1,
                        ∃ (_ : ↑x ∈ V_1),
                          ∃ i_1,
                            pred P fun x =>
                              (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
                                ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
          fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)

Next tactic:
rcases w with ⟨V, m, i, p⟩
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    specialize w (i x)
    rcases w with ⟨V', m', i', p⟩
    refine' ⟨V ⊓ V', ⟨x.2, m'⟩, Opens.infLELeft _ _, _⟩
    convert P.res (Opens.infLERight V V') _ p
  locality {U} f w x := by
    specialize w x
    rcases w with ⟨V, m, i, p⟩
    

Proof state:
case intro.intro.intro
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
U : Opens ↑X
f : (x : ↥U) → T ↑x
x : ↥U
V : Opens ↑X
m : ↑x ∈ V
i : V ⟶ U
p :
  pred
    {
      pred := fun {U} f =>
        ∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x),
      res :=
        (_ :
          ∀ {V U : Opens ↑X} (i : V ⟶ U) (f : (x : ↥U) → T ↑x),
            (∀ (x : ↥U),
                ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)) →
              ∀ (x : ↥V),
                ∃ V_1,
                  ∃ (_ : ↑x ∈ V_1),
                    ∃ i_1,
                      pred P fun x =>
                        (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
                          ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) }
    fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)
⊢ ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)

Next tactic:
specialize p ⟨x.1, m⟩
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    specialize w (i x)
    rcases w with ⟨V', m', i', p⟩
    refine' ⟨V ⊓ V', ⟨x.2, m'⟩, Opens.infLELeft _ _, _⟩
    convert P.res (Opens.infLERight V V') _ p
  locality {U} f w x := by
    specialize w x
    rcases w with ⟨V, m, i, p⟩
    specialize p ⟨x.1, m⟩
    

Proof state:
case intro.intro.intro
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
U : Opens ↑X
f : (x : ↥U) → T ↑x
x : ↥U
V : Opens ↑X
m : ↑x ∈ V
i : V ⟶ U
p :
  ∃ V_1,
    ∃ (_ : ↑{ val := ↑x, property := m } ∈ V_1),
      ∃ i_1,
        pred P fun x =>
          (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
            ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)
⊢ ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)

Next tactic:
rcases p with ⟨V', m', i', p'⟩
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
  pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
  res {V U} i f w x := by
    specialize w (i x)
    rcases w with ⟨V', m', i', p⟩
    refine' ⟨V ⊓ V', ⟨x.2, m'⟩, Opens.infLELeft _ _, _⟩
    convert P.res (Opens.infLERight V V') _ p
  locality {U} f w x := by
    specialize w x
    rcases w with ⟨V, m, i, p⟩
    specialize p ⟨x.1, m⟩
    rcases p with ⟨V', m', i', p'⟩
    

Proof state:
case intro.intro.intro.intro.intro.intro
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
U : Opens ↑X
f : (x : ↥U) → T ↑x
x : ↥U
V : Opens ↑X
m : ↑x ∈ V
i : V ⟶ U
V' : Opens ↑X
m' : ↑{ val := ↑x, property := m } ∈ V'
i' : V' ⟶ V
p' :
  pred P fun x =>
    (fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x))
      ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)
⊢ ∃ V, ∃ (_ : ↑x ∈ V), ∃ i, pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)

Next tactic:
exact ⟨V', m', i' ≫ i, p'⟩
theorem PrelocalPredicate.sheafifyOf {T : X → Type v} {P : PrelocalPredicate T} {U : Opens X}
    {f : ∀ x : U, T x} (h : P.pred f) : P.sheafify.pred f := fun x =>
  ⟨U, x.2, 𝟙 _, by 

Proof state:
X : TopCat
T✝ T : ↑X → Type v
P : PrelocalPredicate T
U : Opens ↑X
f : (x : ↥U) → T ↑x
h : pred P f
x : ↥U
⊢ pred P fun x => f ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑U) }) x)

Next tactic:
convert h
/-- The functions satisfying a local predicate satisfy the sheaf condition.
-/
theorem isSheaf (P : LocalPredicate T) : (subpresheafToTypes P.toPrelocalPredicate).IsSheaf :=
  Presheaf.isSheaf_of_isSheafUniqueGluing_types.{v} _ fun ι U sf sf_comp => by
    -- We show the sheaf condition in terms of unique gluing.
    -- First we obtain a family of sections for the underlying sheaf of functions,
    -- by forgetting that the predicate holds
    

Proof state:
X : TopCat
T : ↑X → Type v
P✝ : PrelocalPredicate T
P : LocalPredicate T
ι : Type v
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type v)).obj ((subpresheafToTypes P.toPrelocalPredicate).obj (op (U i)))
sf_comp : IsCompatible (subpresheafToTypes P.toPrelocalPredicate) U sf
⊢ ∃! s, IsGluing (subpresheafToTypes P.toPrelocalPredicate) U sf s

Next tactic:
let sf' : ∀ i : ι, (presheafToTypes X T).obj (op (U i)) := fun i => (sf i).val
/-- The functions satisfying a local predicate satisfy the sheaf condition.
-/
theorem isSheaf (P : LocalPredicate T) : (subpresheafToTypes P.toPrelocalPredicate).IsSheaf :=
  Presheaf.isSheaf_of_isSheafUniqueGluing_types.{v} _ fun ι U sf sf_comp => by
    -- We show the sheaf condition in terms of unique gluing.
    -- First we obtain a family of sections for the underlying sheaf of functions,
    -- by forgetting that the predicate holds
    let sf' : ∀ i : ι, (presheafToTypes X T).obj (op (U i)) := fun i => (sf i).val
    -- Since our original family is compatible, this one is as well
    

Proof state:
X : TopCat
T : ↑X → Type v
P✝ : PrelocalPredicate T
P : LocalPredicate T
ι : Type v
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type v)).obj ((subpresheafToTypes P.toPrelocalPredicate).obj (op (U i)))
sf_comp : IsCompatible (subpresheafToTypes P.toPrelocalPredicate) U sf
sf' : (i : ι) → (presheafToTypes X T).obj (op (U i)) := fun i => ↑(sf i)
⊢ ∃! s, IsGluing (subpresheafToTypes P.toPrelocalPredicate) U sf s

Next tactic:
have sf'_comp : (presheafToTypes X T).IsCompatible U sf' := fun i j =>
      congr_arg Subtype.val (sf_comp i j)
/-- The functions satisfying a local predicate satisfy the sheaf condition.
-/
theorem isSheaf (P : LocalPredicate T) : (subpresheafToTypes P.toPrelocalPredicate).IsSheaf :=
  Presheaf.isSheaf_of_isSheafUniqueGluing_types.{v} _ fun ι U sf sf_comp => by
    -- We show the sheaf condition in terms of unique gluing.
    -- First we obtain a family of sections for the underlying sheaf of functions,
    -- by forgetting that the predicate holds
    let sf' : ∀ i : ι, (presheafToTypes X T).obj (op (U i)) := fun i => (sf i).val
    -- Since our original family is compatible, this one is as well
    have sf'_comp : (presheafToTypes X T).IsCompatible U sf' := fun i j =>
      congr_arg Subtype.val (sf_comp i j)
    -- So, we can obtain a unique gluing
    

Proof state:
X : TopCat
T : ↑X → Type v
P✝ : PrelocalPredicate T
P : LocalPredicate T
ι : Type v
U : ι → Opens ↑X
sf : (i : ι) → (forget (Type v)).obj ((subpresheafToTypes P.toPrelocalPredicate).obj (op (U i)))
sf_comp : IsCompatible (subpresheafToTypes P.toPrelocalPredicate) U sf
sf' : (i : ι) → (presheafToTypes X T).obj (op (U i)) := fun i => ↑(sf i)
sf'_comp : IsCompatible (presheafToTypes X T) U sf'
⊢ ∃! s, IsGluing (subpresheafToTypes P.toPrelocalPredicate) U sf s

Next tactic:
obtain ⟨gl, gl_spec, gl_uniq⟩ := (sheafToTypes X T).existsUnique_gluing U sf' sf'_comp