l3lab/ntp-mathlib huggingface dataset:
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    

Proof state:
case intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
⊢ (∀ (M : Theory.ModelType T), ↑M ⊨ φ) ∨ ∀ (M : Theory.ModelType T), ↑M ⊨ Formula.not φ

Next tactic:
by_contra! con
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    

Proof state:
case intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
con : (∃ M, ¬↑M ⊨ φ) ∧ ∃ M, ¬↑M ⊨ Formula.not φ
⊢ False

Next tactic:
obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
    

Proof state:
case intro.intro.intro.intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
MF : Theory.ModelType T
hMF : ¬↑MF ⊨ φ
MT : Theory.ModelType T
hMT : ¬↑MT ⊨ Formula.not φ
⊢ False

Next tactic:
rw [Sentence.realize_not, Classical.not_not] at hMT
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
    rw [Sentence.realize_not, Classical.not_not] at hMT
    

Proof state:
case intro.intro.intro.intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
MF : Theory.ModelType T
hMF : ¬↑MF ⊨ φ
MT : Theory.ModelType T
hMT : ↑MT ⊨ φ
⊢ False

Next tactic:
refine' hMF _
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
    rw [Sentence.realize_not, Classical.not_not] at hMT
    refine' hMF _
    

Proof state:
case intro.intro.intro.intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
MF : Theory.ModelType T
hMF : ¬↑MF ⊨ φ
MT : Theory.ModelType T
hMT : ↑MT ⊨ φ
⊢ ↑MF ⊨ φ

Next tactic:
haveI := hT MT
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
    rw [Sentence.realize_not, Classical.not_not] at hMT
    refine' hMF _
    haveI := hT MT
    

Proof state:
case intro.intro.intro.intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
MF : Theory.ModelType T
hMF : ¬↑MF ⊨ φ
MT : Theory.ModelType T
hMT : ↑MT ⊨ φ
this : Infinite ↑MT
⊢ ↑MF ⊨ φ

Next tactic:
haveI := hT MF
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
    rw [Sentence.realize_not, Classical.not_not] at hMT
    refine' hMF _
    haveI := hT MT
    haveI := hT MF
    

Proof state:
case intro.intro.intro.intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
MF : Theory.ModelType T
hMF : ¬↑MF ⊨ φ
MT : Theory.ModelType T
hMT : ↑MT ⊨ φ
this✝ : Infinite ↑MT
this : Infinite ↑MF
⊢ ↑MF ⊨ φ

Next tactic:
obtain ⟨NT, MNT, hNT⟩ := exists_elementarilyEquivalent_card_eq L MT κ h1 h2
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
    rw [Sentence.realize_not, Classical.not_not] at hMT
    refine' hMF _
    haveI := hT MT
    haveI := hT MF
    obtain ⟨NT, MNT, hNT⟩ := exists_elementarilyEquivalent_card_eq L MT κ h1 h2
    

Proof state:
case intro.intro.intro.intro.intro.intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
MF : Theory.ModelType T
hMF : ¬↑MF ⊨ φ
MT : Theory.ModelType T
hMT : ↑MT ⊨ φ
this✝ : Infinite ↑MT
this : Infinite ↑MF
NT : Bundled (Structure L)
MNT : ↑MT ≅[L] ↑NT
hNT : #↑NT = κ
⊢ ↑MF ⊨ φ

Next tactic:
obtain ⟨NF, MNF, hNF⟩ := exists_elementarilyEquivalent_card_eq L MF κ h1 h2
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
    rw [Sentence.realize_not, Classical.not_not] at hMT
    refine' hMF _
    haveI := hT MT
    haveI := hT MF
    obtain ⟨NT, MNT, hNT⟩ := exists_elementarilyEquivalent_card_eq L MT κ h1 h2
    obtain ⟨NF, MNF, hNF⟩ := exists_elementarilyEquivalent_card_eq L MF κ h1 h2
    

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
MF : Theory.ModelType T
hMF : ¬↑MF ⊨ φ
MT : Theory.ModelType T
hMT : ↑MT ⊨ φ
this✝ : Infinite ↑MT
this : Infinite ↑MF
NT : Bundled (Structure L)
MNT : ↑MT ≅[L] ↑NT
hNT : #↑NT = κ
NF : Bundled (Structure L)
MNF : ↑MF ≅[L] ↑NF
hNF : #↑NF = κ
⊢ ↑MF ⊨ φ

Next tactic:
obtain ⟨TF⟩ := h (MNT.toModel T) (MNF.toModel T) hNT hNF
/-- The Łoś–Vaught Test : a criterion for categorical theories to be complete. -/
theorem Categorical.isComplete (h : κ.Categorical T) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w} L.card ≤ Cardinal.lift.{max u v} κ) (hS : T.IsSatisfiable)
    (hT : ∀ M : Theory.ModelType.{u, v, max u v} T, Infinite M) : T.IsComplete :=
  ⟨hS, fun φ => by
    obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ h1 h2
    rw [Theory.models_sentence_iff, Theory.models_sentence_iff]
    by_contra! con
    obtain ⟨⟨MF, hMF⟩, MT, hMT⟩ := con
    rw [Sentence.realize_not, Classical.not_not] at hMT
    refine' hMF _
    haveI := hT MT
    haveI := hT MF
    obtain ⟨NT, MNT, hNT⟩ := exists_elementarilyEquivalent_card_eq L MT κ h1 h2
    obtain ⟨NF, MNF, hNF⟩ := exists_elementarilyEquivalent_card_eq L MF κ h1 h2
    obtain ⟨TF⟩ := h (MNT.toModel T) (MNF.toModel T) hNT hNF
    

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro.intro
L : Language
κ : Cardinal.{w}
T : Theory L
h : Categorical κ T
h1 : ℵ₀ ≤ κ
h2 : lift.{w, max u v} (card L) ≤ lift.{max u v, w} κ
hS : Theory.IsSatisfiable T
hT : ∀ (M : Theory.ModelType T), Infinite ↑M
φ : Sentence L
w✝ : Theory.ModelType T
h✝ : #↑w✝ = κ
MF : Theory.ModelType T
hMF : ¬↑MF ⊨ φ
MT : Theory.ModelType T
hMT : ↑MT ⊨ φ
this✝ : Infinite ↑MT
this : Infinite ↑MF
NT : Bundled (Structure L)
MNT : ↑MT ≅[L] ↑NT
hNT : #↑NT = κ
NF : Bundled (Structure L)
MNF : ↑MF ≅[L] ↑NF
hNF : #↑NF = κ
TF : ↑(ElementarilyEquivalent.toModel T MNT) ≃[L] ↑(ElementarilyEquivalent.toModel T MNF)
⊢ ↑MF ⊨ φ

Next tactic:
exact
      ((MNT.realize_sentence φ).trans
        ((TF.realize_sentence φ).trans (MNF.realize_sentence φ).symm)).1 hMT
theorem empty_theory_categorical (T : Language.empty.Theory) : κ.Categorical T := fun M N hM hN =>
  by 

Proof state:
L : Language
κ : Cardinal.{w}
T✝ : Theory L
T : Theory Language.empty
M N : Theory.ModelType T
hM : #↑M = κ
hN : #↑N = κ
⊢ Nonempty (↑M ≃[Language.empty] ↑N)

Next tactic:
rw [empty.nonempty_equiv_iff, hM, hN]
theorem empty_infinite_Theory_isComplete : Language.empty.infiniteTheory.IsComplete :=
  (empty_theory_categorical.{0} ℵ₀ _).isComplete ℵ₀ _ le_rfl (by 

Proof state:
L : Language
κ : Cardinal.{w}
T : Theory L
⊢ lift.{0, 0} (card Language.empty) ≤ lift.{0, 0} ℵ₀

Next tactic:
simp
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P
      (IsLocalization.Away.map (↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r))))
        (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))) (Scheme.Γ.map f.op) r)

Next tactic:
rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ P
      (f.val.c.app (Opposite.op (Y.basicOpen r)) ≫
        X.presheaf.map (eqToHom (_ : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r)).op) =
    P
      (IsLocalization.Away.map (↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r))))
        (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))) (Scheme.Γ.map f.op) r)

Next tactic:
congr
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  

Proof state:
case e_a
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ f.val.c.app (Opposite.op (Y.basicOpen r)) ≫
      X.presheaf.map (eqToHom (_ : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r)).op =
    IsLocalization.Away.map (↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r))))
      (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))) (Scheme.Γ.map f.op) r

Next tactic:
delta IsLocalization.Away.map
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  delta IsLocalization.Away.map
  

Proof state:
case e_a
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ f.val.c.app (Opposite.op (Y.basicOpen r)) ≫
      X.presheaf.map (eqToHom (_ : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r)).op =
    IsLocalization.map (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))) (Scheme.Γ.map f.op)
      (_ : Submonoid.powers r ≤ Submonoid.comap (Scheme.Γ.map f.op) (Submonoid.powers ((Scheme.Γ.map f.op) r)))

Next tactic:
refine' IsLocalization.ringHom_ext (Submonoid.powers r) _
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  delta IsLocalization.Away.map
  refine' IsLocalization.ringHom_ext (Submonoid.powers r) _
  

Proof state:
case e_a
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ comp
      (f.val.c.app (Opposite.op (Y.basicOpen r)) ≫
        X.presheaf.map (eqToHom (_ : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r)).op)
      (algebraMap ↑(Y.presheaf.obj (Opposite.op ⊤)) ↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r)))) =
    comp
      (IsLocalization.map (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))) (Scheme.Γ.map f.op)
        (_ : Submonoid.powers r ≤ Submonoid.comap (Scheme.Γ.map f.op) (Submonoid.powers ((Scheme.Γ.map f.op) r))))
      (algebraMap ↑(Y.presheaf.obj (Opposite.op ⊤)) ↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r))))

Next tactic:
generalize_proofs h1 h2 h3
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  delta IsLocalization.Away.map
  refine' IsLocalization.ringHom_ext (Submonoid.powers r) _
  generalize_proofs h1 h2 h3
  

Proof state:
case e_a
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
h1 : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r
h2 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
h3 : Submonoid.powers r ≤ Submonoid.comap (Scheme.Γ.map f.op) (Submonoid.powers ((Scheme.Γ.map f.op) r))
⊢ comp (f.val.c.app (Opposite.op (Y.basicOpen r)) ≫ X.presheaf.map (eqToHom h1).op)
      (algebraMap ↑(Y.presheaf.obj (Opposite.op ⊤)) ↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r)))) =
    comp
      (IsLocalization.map (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))) (Scheme.Γ.map f.op)
        h3)
      (algebraMap ↑(Y.presheaf.obj (Opposite.op ⊤)) ↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r))))

Next tactic:
haveI i1 := @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  delta IsLocalization.Away.map
  refine' IsLocalization.ringHom_ext (Submonoid.powers r) _
  generalize_proofs h1 h2 h3
  haveI i1 := @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)
  -- Porting note : needs to be very explicit here
  

Proof state:
case e_a
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
h1 : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r
h2 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
h3 : Submonoid.powers r ≤ Submonoid.comap (Scheme.Γ.map f.op) (Submonoid.powers ((Scheme.Γ.map f.op) r))
i1 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
⊢ comp (f.val.c.app (Opposite.op (Y.basicOpen r)) ≫ X.presheaf.map (eqToHom h1).op)
      (algebraMap ↑(Y.presheaf.obj (Opposite.op ⊤)) ↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r)))) =
    comp
      (IsLocalization.map (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))) (Scheme.Γ.map f.op)
        h3)
      (algebraMap ↑(Y.presheaf.obj (Opposite.op ⊤)) ↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r))))

Next tactic:
convert
    (@IsLocalization.map_comp (hy := h3) (Y.presheaf.obj <| Opposite.op (Scheme.basicOpen Y r))
    _ _ (isLocalization_away_of_isAffine _) _ _ _ i1).symm using 1