l3lab/ntp-mathlib huggingface dataset:
theorem models_not_iff (h : T.IsComplete) (φ : L.Sentence) : T ⊨ᵇ φ.not ↔ ¬T ⊨ᵇ φ := by
  cases' h.2 φ with hφ hφn
  · simp only [hφ, not_true, iff_false_iff]
    rw [models_sentence_iff, not_forall]
    refine' ⟨h.1.some, _⟩
    simp only [Sentence.realize_not, Classical.not_not]
    exact models_sentence_iff.1 hφ _
  · simp only [hφn, true_iff_iff]
    intro hφ
    rw [models_sentence_iff] at *
    

Proof state:
case inr
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
hφn : ∀ (M : ModelType T), ↑M ⊨ Formula.not φ
hφ : ∀ (M : ModelType T), ↑M ⊨ φ
⊢ False

Next tactic:
exact hφn h.1.some (hφ _)
theorem realize_sentence_iff (h : T.IsComplete) (φ : L.Sentence) (M : Type*) [L.Structure M]
    [M ⊨ T] [Nonempty M] : M ⊨ φ ↔ T ⊨ᵇ φ := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
M : Type u_1
inst✝² : Structure L M
inst✝¹ : M ⊨ T
inst✝ : Nonempty M
⊢ M ⊨ φ ↔ T ⊨ᵇ φ

Next tactic:
cases' h.2 φ with hφ hφn
theorem realize_sentence_iff (h : T.IsComplete) (φ : L.Sentence) (M : Type*) [L.Structure M]
    [M ⊨ T] [Nonempty M] : M ⊨ φ ↔ T ⊨ᵇ φ := by
  cases' h.2 φ with hφ hφn
  · 

Proof state:
case inl
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
M : Type u_1
inst✝² : Structure L M
inst✝¹ : M ⊨ T
inst✝ : Nonempty M
hφ : T ⊨ᵇ φ
⊢ M ⊨ φ ↔ T ⊨ᵇ φ

Next tactic:
exact iff_of_true (hφ.realize_sentence M) hφ
theorem realize_sentence_iff (h : T.IsComplete) (φ : L.Sentence) (M : Type*) [L.Structure M]
    [M ⊨ T] [Nonempty M] : M ⊨ φ ↔ T ⊨ᵇ φ := by
  cases' h.2 φ with hφ hφn
  · exact iff_of_true (hφ.realize_sentence M) hφ
  · 

Proof state:
case inr
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
M : Type u_1
inst✝² : Structure L M
inst✝¹ : M ⊨ T
inst✝ : Nonempty M
hφn : T ⊨ᵇ Formula.not φ
⊢ M ⊨ φ ↔ T ⊨ᵇ φ

Next tactic:
exact
      iff_of_false ((Sentence.realize_not M).1 (hφn.realize_sentence M))
        ((h.models_not_iff φ).1 hφn)
theorem IsMaximal.mem_of_models (h : T.IsMaximal) {φ : L.Sentence} (hφ : T ⊨ᵇ φ) : φ ∈ T := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsMaximal T
φ : Sentence L
hφ : T ⊨ᵇ φ
⊢ φ ∈ T

Next tactic:
refine' (h.mem_or_not_mem φ).resolve_right fun con => _
theorem IsMaximal.mem_of_models (h : T.IsMaximal) {φ : L.Sentence} (hφ : T ⊨ᵇ φ) : φ ∈ T := by
  refine' (h.mem_or_not_mem φ).resolve_right fun con => _
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsMaximal T
φ : Sentence L
hφ : T ⊨ᵇ φ
con : Formula.not φ ∈ T
⊢ False

Next tactic:
rw [models_iff_not_satisfiable, Set.union_singleton, Set.insert_eq_of_mem con] at hφ
theorem IsMaximal.mem_of_models (h : T.IsMaximal) {φ : L.Sentence} (hφ : T ⊨ᵇ φ) : φ ∈ T := by
  refine' (h.mem_or_not_mem φ).resolve_right fun con => _
  rw [models_iff_not_satisfiable, Set.union_singleton, Set.insert_eq_of_mem con] at hφ
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsMaximal T
φ : Sentence L
hφ : ¬IsSatisfiable T
con : Formula.not φ ∈ T
⊢ False

Next tactic:
exact hφ h.1
@[refl]
theorem SemanticallyEquivalent.refl (φ : L.BoundedFormula α n) : T.SemanticallyEquivalent φ φ :=
  fun M v xs => by 

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : BoundedFormula L α n
M : ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ BoundedFormula.Realize (φ ⇔ φ) v xs

Next tactic:
rw [BoundedFormula.realize_iff]
@[symm]
theorem SemanticallyEquivalent.symm {φ ψ : L.BoundedFormula α n}
    (h : T.SemanticallyEquivalent φ ψ) : T.SemanticallyEquivalent ψ φ := fun M v xs => by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
h : SemanticallyEquivalent T φ ψ
M : ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ BoundedFormula.Realize (ψ ⇔ φ) v xs

Next tactic:
rw [BoundedFormula.realize_iff, Iff.comm, ← BoundedFormula.realize_iff]
@[symm]
theorem SemanticallyEquivalent.symm {φ ψ : L.BoundedFormula α n}
    (h : T.SemanticallyEquivalent φ ψ) : T.SemanticallyEquivalent ψ φ := fun M v xs => by
  rw [BoundedFormula.realize_iff, Iff.comm, ← BoundedFormula.realize_iff]
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
h : SemanticallyEquivalent T φ ψ
M : ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ BoundedFormula.Realize (φ ⇔ ψ) v xs

Next tactic:
exact h M v xs
@[trans]
theorem SemanticallyEquivalent.trans {φ ψ θ : L.BoundedFormula α n}
    (h1 : T.SemanticallyEquivalent φ ψ) (h2 : T.SemanticallyEquivalent ψ θ) :
    T.SemanticallyEquivalent φ θ := fun M v xs => by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ θ : BoundedFormula L α n
h1 : SemanticallyEquivalent T φ ψ
h2 : SemanticallyEquivalent T ψ θ
M : ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ BoundedFormula.Realize (φ ⇔ θ) v xs

Next tactic:
have h1' := h1 M v xs
@[trans]
theorem SemanticallyEquivalent.trans {φ ψ θ : L.BoundedFormula α n}
    (h1 : T.SemanticallyEquivalent φ ψ) (h2 : T.SemanticallyEquivalent ψ θ) :
    T.SemanticallyEquivalent φ θ := fun M v xs => by
  have h1' := h1 M v xs
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ θ : BoundedFormula L α n
h1 : SemanticallyEquivalent T φ ψ
h2 : SemanticallyEquivalent T ψ θ
M : ModelType T
v : α → ↑M
xs : Fin n → ↑M
h1' : BoundedFormula.Realize (φ ⇔ ψ) v xs
⊢ BoundedFormula.Realize (φ ⇔ θ) v xs

Next tactic:
have h2' := h2 M v xs
@[trans]
theorem SemanticallyEquivalent.trans {φ ψ θ : L.BoundedFormula α n}
    (h1 : T.SemanticallyEquivalent φ ψ) (h2 : T.SemanticallyEquivalent ψ θ) :
    T.SemanticallyEquivalent φ θ := fun M v xs => by
  have h1' := h1 M v xs
  have h2' := h2 M v xs
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ θ : BoundedFormula L α n
h1 : SemanticallyEquivalent T φ ψ
h2 : SemanticallyEquivalent T ψ θ
M : ModelType T
v : α → ↑M
xs : Fin n → ↑M
h1' : BoundedFormula.Realize (φ ⇔ ψ) v xs
h2' : BoundedFormula.Realize (ψ ⇔ θ) v xs
⊢ BoundedFormula.Realize (φ ⇔ θ) v xs

Next tactic:
rw [BoundedFormula.realize_iff] at *
@[trans]
theorem SemanticallyEquivalent.trans {φ ψ θ : L.BoundedFormula α n}
    (h1 : T.SemanticallyEquivalent φ ψ) (h2 : T.SemanticallyEquivalent ψ θ) :
    T.SemanticallyEquivalent φ θ := fun M v xs => by
  have h1' := h1 M v xs
  have h2' := h2 M v xs
  rw [BoundedFormula.realize_iff] at *
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ θ : BoundedFormula L α n
h1 : SemanticallyEquivalent T φ ψ
h2 : SemanticallyEquivalent T ψ θ
M : ModelType T
v : α → ↑M
xs : Fin n → ↑M
h1' : BoundedFormula.Realize φ v xs ↔ BoundedFormula.Realize ψ v xs
h2' : BoundedFormula.Realize ψ v xs ↔ BoundedFormula.Realize θ v xs
⊢ BoundedFormula.Realize φ v xs ↔ BoundedFormula.Realize θ v xs

Next tactic:
exact ⟨h2'.1 ∘ h1'.1, h1'.2 ∘ h2'.2⟩
protected theorem SemanticallyEquivalent.all {φ ψ : L.BoundedFormula α (n + 1)}
    (h : T.SemanticallyEquivalent φ ψ) : T.SemanticallyEquivalent φ.all ψ.all := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α (n + 1)
h : SemanticallyEquivalent T φ ψ
⊢ SemanticallyEquivalent T (∀'φ) (∀'ψ)

Next tactic:
simp_rw [SemanticallyEquivalent, ModelsBoundedFormula, BoundedFormula.realize_iff,
    BoundedFormula.realize_all]
protected theorem SemanticallyEquivalent.all {φ ψ : L.BoundedFormula α (n + 1)}
    (h : T.SemanticallyEquivalent φ ψ) : T.SemanticallyEquivalent φ.all ψ.all := by
  simp_rw [SemanticallyEquivalent, ModelsBoundedFormula, BoundedFormula.realize_iff,
    BoundedFormula.realize_all]
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α (n + 1)
h : SemanticallyEquivalent T φ ψ
⊢ ∀ (M : ModelType T) (v : α → ↑M) (xs : Fin n → ↑M),
    (∀ (a : ↑M), BoundedFormula.Realize φ v (Fin.snoc xs a)) ↔ ∀ (a : ↑M), BoundedFormula.Realize ψ v (Fin.snoc xs a)

Next tactic:
exact fun M v xs => forall_congr' fun a => h.realize_bd_iff
protected theorem SemanticallyEquivalent.ex {φ ψ : L.BoundedFormula α (n + 1)}
    (h : T.SemanticallyEquivalent φ ψ) : T.SemanticallyEquivalent φ.ex ψ.ex := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α (n + 1)
h : SemanticallyEquivalent T φ ψ
⊢ SemanticallyEquivalent T (∃'φ) (∃'ψ)

Next tactic:
simp_rw [SemanticallyEquivalent, ModelsBoundedFormula, BoundedFormula.realize_iff,
    BoundedFormula.realize_ex]
protected theorem SemanticallyEquivalent.ex {φ ψ : L.BoundedFormula α (n + 1)}
    (h : T.SemanticallyEquivalent φ ψ) : T.SemanticallyEquivalent φ.ex ψ.ex := by
  simp_rw [SemanticallyEquivalent, ModelsBoundedFormula, BoundedFormula.realize_iff,
    BoundedFormula.realize_ex]
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α (n + 1)
h : SemanticallyEquivalent T φ ψ
⊢ ∀ (M : ModelType T) (v : α → ↑M) (xs : Fin n → ↑M),
    (∃ a, BoundedFormula.Realize φ v (Fin.snoc xs a)) ↔ ∃ a, BoundedFormula.Realize ψ v (Fin.snoc xs a)

Next tactic:
exact fun M v xs => exists_congr fun a => h.realize_bd_iff
protected theorem SemanticallyEquivalent.not {φ ψ : L.BoundedFormula α n}
    (h : T.SemanticallyEquivalent φ ψ) : T.SemanticallyEquivalent φ.not ψ.not := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
h : SemanticallyEquivalent T φ ψ
⊢ SemanticallyEquivalent T (∼φ) ∼ψ

Next tactic:
simp_rw [SemanticallyEquivalent, ModelsBoundedFormula, BoundedFormula.realize_iff,
    BoundedFormula.realize_not]
protected theorem SemanticallyEquivalent.not {φ ψ : L.BoundedFormula α n}
    (h : T.SemanticallyEquivalent φ ψ) : T.SemanticallyEquivalent φ.not ψ.not := by
  simp_rw [SemanticallyEquivalent, ModelsBoundedFormula, BoundedFormula.realize_iff,
    BoundedFormula.realize_not]
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
h : SemanticallyEquivalent T φ ψ
⊢ ∀ (M : ModelType T) (v : α → ↑M) (xs : Fin n → ↑M), ¬BoundedFormula.Realize φ v xs ↔ ¬BoundedFormula.Realize ψ v xs

Next tactic:
exact fun M v xs => not_congr h.realize_bd_iff
protected theorem SemanticallyEquivalent.imp {φ ψ φ' ψ' : L.BoundedFormula α n}
    (h : T.SemanticallyEquivalent φ ψ) (h' : T.SemanticallyEquivalent φ' ψ') :
    T.SemanticallyEquivalent (φ.imp φ') (ψ.imp ψ') := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ φ' ψ' : BoundedFormula L α n
h : SemanticallyEquivalent T φ ψ
h' : SemanticallyEquivalent T φ' ψ'
⊢ SemanticallyEquivalent T (φ ⟹ φ') (ψ ⟹ ψ')

Next tactic:
simp_rw [SemanticallyEquivalent, ModelsBoundedFormula, BoundedFormula.realize_iff,
    BoundedFormula.realize_imp]
protected theorem SemanticallyEquivalent.imp {φ ψ φ' ψ' : L.BoundedFormula α n}
    (h : T.SemanticallyEquivalent φ ψ) (h' : T.SemanticallyEquivalent φ' ψ') :
    T.SemanticallyEquivalent (φ.imp φ') (ψ.imp ψ') := by
  simp_rw [SemanticallyEquivalent, ModelsBoundedFormula, BoundedFormula.realize_iff,
    BoundedFormula.realize_imp]
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ φ' ψ' : BoundedFormula L α n
h : SemanticallyEquivalent T φ ψ
h' : SemanticallyEquivalent T φ' ψ'
⊢ ∀ (M : ModelType T) (v : α → ↑M) (xs : Fin n → ↑M),
    BoundedFormula.Realize φ v xs → BoundedFormula.Realize φ' v xs ↔
      BoundedFormula.Realize ψ v xs → BoundedFormula.Realize ψ' v xs

Next tactic:
exact fun M v xs => imp_congr h.realize_bd_iff h'.realize_bd_iff
theorem mem_or_not_mem (φ : L.Sentence) : φ ∈ L.completeTheory M ∨ φ.not ∈ L.completeTheory M := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
M : Type w
inst✝ : Structure L M
φ : Sentence L
⊢ φ ∈ completeTheory L M ∨ Formula.not φ ∈ completeTheory L M

Next tactic:
simp_rw [completeTheory, Set.mem_setOf_eq, Sentence.Realize, Formula.realize_not, or_not]
theorem semanticallyEquivalent_not_not : T.SemanticallyEquivalent φ φ.not.not := fun M v xs => by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
M : Theory.ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (φ ⇔ ∼∼φ) v xs

Next tactic:
simp
theorem imp_semanticallyEquivalent_not_sup : T.SemanticallyEquivalent (φ.imp ψ) (φ.not ⊔ ψ) :=
  fun M v xs => by 

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
M : Theory.ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (φ ⟹ ψ ⇔ ∼φ ⊔ ψ) v xs

Next tactic:
simp [imp_iff_not_or]
theorem sup_semanticallyEquivalent_not_inf_not :
    T.SemanticallyEquivalent (φ ⊔ ψ) (φ.not ⊓ ψ.not).not := fun M v xs => by 

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
M : Theory.ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (φ ⊔ ψ ⇔ ∼(∼φ ⊓ ∼ψ)) v xs

Next tactic:
simp [imp_iff_not_or]
theorem inf_semanticallyEquivalent_not_sup_not :
    T.SemanticallyEquivalent (φ ⊓ ψ) (φ.not ⊔ ψ.not).not := fun M v xs => by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
M : Theory.ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (φ ⊓ ψ ⇔ ∼(∼φ ⊔ ∼ψ)) v xs

Next tactic:
simp [and_iff_not_or_not]
theorem all_semanticallyEquivalent_not_ex_not (φ : L.BoundedFormula α (n + 1)) :
    T.SemanticallyEquivalent φ.all φ.not.ex.not := fun M v xs => by 

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ✝ ψ : BoundedFormula L α n
φ : BoundedFormula L α (n + 1)
M : Theory.ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (∀'φ ⇔ ∼(∃'∼φ)) v xs

Next tactic:
simp
theorem ex_semanticallyEquivalent_not_all_not (φ : L.BoundedFormula α (n + 1)) :
    T.SemanticallyEquivalent φ.ex φ.not.all.not := fun M v xs => by 

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ✝ ψ : BoundedFormula L α n
φ : BoundedFormula L α (n + 1)
M : Theory.ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (∃'φ ⇔ ∼(∀'∼φ)) v xs

Next tactic:
simp
theorem semanticallyEquivalent_all_liftAt : T.SemanticallyEquivalent φ (φ.liftAt 1 n).all :=
  fun M v xs => by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
M : Theory.ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (φ ⇔ ∀'liftAt 1 n φ) v xs

Next tactic:
skip
theorem semanticallyEquivalent_all_liftAt : T.SemanticallyEquivalent φ (φ.liftAt 1 n).all :=
  fun M v xs => by
  skip
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ ψ : BoundedFormula L α n
M : Theory.ModelType T
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (φ ⇔ ∀'liftAt 1 n φ) v xs

Next tactic:
rw [realize_iff, realize_all_liftAt_one_self]
theorem semanticallyEquivalent_toPrenex (φ : L.BoundedFormula α n) :
    (∅ : L.Theory).SemanticallyEquivalent φ φ.toPrenex := fun M v xs => by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : BoundedFormula L α n
M : Theory.ModelType ∅
v : α → ↑M
xs : Fin n → ↑M
⊢ Realize (φ ⇔ toPrenex φ) v xs

Next tactic:
rw [realize_iff, realize_toPrenex]
theorem induction_on_all_ex {P : ∀ {m}, L.BoundedFormula α m → Prop} (φ : L.BoundedFormula α n)
    (hqf : ∀ {m} {ψ : L.BoundedFormula α m}, IsQF ψ → P ψ)
    (hall : ∀ {m} {ψ : L.BoundedFormula α (m + 1)}, P ψ → P ψ.all)
    (hex : ∀ {m} {φ : L.BoundedFormula α (m + 1)}, P φ → P φ.ex)
    (hse : ∀ {m} {φ₁ φ₂ : L.BoundedFormula α m},
      Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)) :
    P φ := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
P : {m : ℕ} → BoundedFormula L α m → Prop
φ : BoundedFormula L α n
hqf : ∀ {m : ℕ} {ψ : BoundedFormula L α m}, IsQF ψ → P ψ
hall : ∀ {m : ℕ} {ψ : BoundedFormula L α (m + 1)}, P ψ → P (∀'ψ)
hex : ∀ {m : ℕ} {φ : BoundedFormula L α (m + 1)}, P φ → P (∃'φ)
hse : ∀ {m : ℕ} {φ₁ φ₂ : BoundedFormula L α m}, Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)
⊢ P φ

Next tactic:
suffices h' : ∀ {m} {φ : L.BoundedFormula α m}, φ.IsPrenex → P φ
theorem induction_on_all_ex {P : ∀ {m}, L.BoundedFormula α m → Prop} (φ : L.BoundedFormula α n)
    (hqf : ∀ {m} {ψ : L.BoundedFormula α m}, IsQF ψ → P ψ)
    (hall : ∀ {m} {ψ : L.BoundedFormula α (m + 1)}, P ψ → P ψ.all)
    (hex : ∀ {m} {φ : L.BoundedFormula α (m + 1)}, P φ → P φ.ex)
    (hse : ∀ {m} {φ₁ φ₂ : L.BoundedFormula α m},
      Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)) :
    P φ := by
  suffices h' : ∀ {m} {φ : L.BoundedFormula α m}, φ.IsPrenex → P φ
  · 

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
P : {m : ℕ} → BoundedFormula L α m → Prop
φ : BoundedFormula L α n
hqf : ∀ {m : ℕ} {ψ : BoundedFormula L α m}, IsQF ψ → P ψ
hall : ∀ {m : ℕ} {ψ : BoundedFormula L α (m + 1)}, P ψ → P (∀'ψ)
hex : ∀ {m : ℕ} {φ : BoundedFormula L α (m + 1)}, P φ → P (∃'φ)
hse : ∀ {m : ℕ} {φ₁ φ₂ : BoundedFormula L α m}, Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)
h' : ∀ {m : ℕ} {φ : BoundedFormula L α m}, IsPrenex φ → P φ
⊢ P φ

Next tactic:
exact (hse φ.semanticallyEquivalent_toPrenex).2 (h' φ.toPrenex_isPrenex)
theorem induction_on_all_ex {P : ∀ {m}, L.BoundedFormula α m → Prop} (φ : L.BoundedFormula α n)
    (hqf : ∀ {m} {ψ : L.BoundedFormula α m}, IsQF ψ → P ψ)
    (hall : ∀ {m} {ψ : L.BoundedFormula α (m + 1)}, P ψ → P ψ.all)
    (hex : ∀ {m} {φ : L.BoundedFormula α (m + 1)}, P φ → P φ.ex)
    (hse : ∀ {m} {φ₁ φ₂ : L.BoundedFormula α m},
      Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)) :
    P φ := by
  suffices h' : ∀ {m} {φ : L.BoundedFormula α m}, φ.IsPrenex → P φ
  · exact (hse φ.semanticallyEquivalent_toPrenex).2 (h' φ.toPrenex_isPrenex)
  

Proof state:
case h'
L : Language
T : Theory L
α : Type w
n : ℕ
P : {m : ℕ} → BoundedFormula L α m → Prop
φ : BoundedFormula L α n
hqf : ∀ {m : ℕ} {ψ : BoundedFormula L α m}, IsQF ψ → P ψ
hall : ∀ {m : ℕ} {ψ : BoundedFormula L α (m + 1)}, P ψ → P (∀'ψ)
hex : ∀ {m : ℕ} {φ : BoundedFormula L α (m + 1)}, P φ → P (∃'φ)
hse : ∀ {m : ℕ} {φ₁ φ₂ : BoundedFormula L α m}, Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)
⊢ ∀ {m : ℕ} {φ : BoundedFormula L α m}, IsPrenex φ → P φ

Next tactic:
intro m φ hφ
theorem induction_on_all_ex {P : ∀ {m}, L.BoundedFormula α m → Prop} (φ : L.BoundedFormula α n)
    (hqf : ∀ {m} {ψ : L.BoundedFormula α m}, IsQF ψ → P ψ)
    (hall : ∀ {m} {ψ : L.BoundedFormula α (m + 1)}, P ψ → P ψ.all)
    (hex : ∀ {m} {φ : L.BoundedFormula α (m + 1)}, P φ → P φ.ex)
    (hse : ∀ {m} {φ₁ φ₂ : L.BoundedFormula α m},
      Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)) :
    P φ := by
  suffices h' : ∀ {m} {φ : L.BoundedFormula α m}, φ.IsPrenex → P φ
  · exact (hse φ.semanticallyEquivalent_toPrenex).2 (h' φ.toPrenex_isPrenex)
  intro m φ hφ
  

Proof state:
case h'
L : Language
T : Theory L
α : Type w
n : ℕ
P : {m : ℕ} → BoundedFormula L α m → Prop
φ✝ : BoundedFormula L α n
hqf : ∀ {m : ℕ} {ψ : BoundedFormula L α m}, IsQF ψ → P ψ
hall : ∀ {m : ℕ} {ψ : BoundedFormula L α (m + 1)}, P ψ → P (∀'ψ)
hex : ∀ {m : ℕ} {φ : BoundedFormula L α (m + 1)}, P φ → P (∃'φ)
hse : ∀ {m : ℕ} {φ₁ φ₂ : BoundedFormula L α m}, Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)
m : ℕ
φ : BoundedFormula L α m
hφ : IsPrenex φ
⊢ P φ

Next tactic:
induction' hφ with _ _ hφ _ _ _ hφ _ _ _ hφ
theorem induction_on_all_ex {P : ∀ {m}, L.BoundedFormula α m → Prop} (φ : L.BoundedFormula α n)
    (hqf : ∀ {m} {ψ : L.BoundedFormula α m}, IsQF ψ → P ψ)
    (hall : ∀ {m} {ψ : L.BoundedFormula α (m + 1)}, P ψ → P ψ.all)
    (hex : ∀ {m} {φ : L.BoundedFormula α (m + 1)}, P φ → P φ.ex)
    (hse : ∀ {m} {φ₁ φ₂ : L.BoundedFormula α m},
      Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)) :
    P φ := by
  suffices h' : ∀ {m} {φ : L.BoundedFormula α m}, φ.IsPrenex → P φ
  · exact (hse φ.semanticallyEquivalent_toPrenex).2 (h' φ.toPrenex_isPrenex)
  intro m φ hφ
  induction' hφ with _ _ hφ _ _ _ hφ _ _ _ hφ
  · 

Proof state:
case h'.of_isQF
L : Language
T : Theory L
α : Type w
n : ℕ
P : {m : ℕ} → BoundedFormula L α m → Prop
φ✝¹ : BoundedFormula L α n
hqf : ∀ {m : ℕ} {ψ : BoundedFormula L α m}, IsQF ψ → P ψ
hall : ∀ {m : ℕ} {ψ : BoundedFormula L α (m + 1)}, P ψ → P (∀'ψ)
hex : ∀ {m : ℕ} {φ : BoundedFormula L α (m + 1)}, P φ → P (∃'φ)
hse : ∀ {m : ℕ} {φ₁ φ₂ : BoundedFormula L α m}, Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)
m : ℕ
φ : BoundedFormula L α m
n✝ : ℕ
φ✝ : BoundedFormula L α n✝
hφ : IsQF φ✝
⊢ P φ✝

Next tactic:
exact hqf hφ
theorem induction_on_all_ex {P : ∀ {m}, L.BoundedFormula α m → Prop} (φ : L.BoundedFormula α n)
    (hqf : ∀ {m} {ψ : L.BoundedFormula α m}, IsQF ψ → P ψ)
    (hall : ∀ {m} {ψ : L.BoundedFormula α (m + 1)}, P ψ → P ψ.all)
    (hex : ∀ {m} {φ : L.BoundedFormula α (m + 1)}, P φ → P φ.ex)
    (hse : ∀ {m} {φ₁ φ₂ : L.BoundedFormula α m},
      Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)) :
    P φ := by
  suffices h' : ∀ {m} {φ : L.BoundedFormula α m}, φ.IsPrenex → P φ
  · exact (hse φ.semanticallyEquivalent_toPrenex).2 (h' φ.toPrenex_isPrenex)
  intro m φ hφ
  induction' hφ with _ _ hφ _ _ _ hφ _ _ _ hφ
  · exact hqf hφ
  · 

Proof state:
case h'.all
L : Language
T : Theory L
α : Type w
n : ℕ
P : {m : ℕ} → BoundedFormula L α m → Prop
φ✝¹ : BoundedFormula L α n
hqf : ∀ {m : ℕ} {ψ : BoundedFormula L α m}, IsQF ψ → P ψ
hall : ∀ {m : ℕ} {ψ : BoundedFormula L α (m + 1)}, P ψ → P (∀'ψ)
hex : ∀ {m : ℕ} {φ : BoundedFormula L α (m + 1)}, P φ → P (∃'φ)
hse : ∀ {m : ℕ} {φ₁ φ₂ : BoundedFormula L α m}, Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)
m : ℕ
φ : BoundedFormula L α m
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
h✝ : IsPrenex φ✝
hφ : P φ✝
⊢ P (∀'φ✝)

Next tactic:
exact hall hφ
theorem induction_on_all_ex {P : ∀ {m}, L.BoundedFormula α m → Prop} (φ : L.BoundedFormula α n)
    (hqf : ∀ {m} {ψ : L.BoundedFormula α m}, IsQF ψ → P ψ)
    (hall : ∀ {m} {ψ : L.BoundedFormula α (m + 1)}, P ψ → P ψ.all)
    (hex : ∀ {m} {φ : L.BoundedFormula α (m + 1)}, P φ → P φ.ex)
    (hse : ∀ {m} {φ₁ φ₂ : L.BoundedFormula α m},
      Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)) :
    P φ := by
  suffices h' : ∀ {m} {φ : L.BoundedFormula α m}, φ.IsPrenex → P φ
  · exact (hse φ.semanticallyEquivalent_toPrenex).2 (h' φ.toPrenex_isPrenex)
  intro m φ hφ
  induction' hφ with _ _ hφ _ _ _ hφ _ _ _ hφ
  · exact hqf hφ
  · exact hall hφ
  · 

Proof state:
case h'.ex
L : Language
T : Theory L
α : Type w
n : ℕ
P : {m : ℕ} → BoundedFormula L α m → Prop
φ✝¹ : BoundedFormula L α n
hqf : ∀ {m : ℕ} {ψ : BoundedFormula L α m}, IsQF ψ → P ψ
hall : ∀ {m : ℕ} {ψ : BoundedFormula L α (m + 1)}, P ψ → P (∀'ψ)
hex : ∀ {m : ℕ} {φ : BoundedFormula L α (m + 1)}, P φ → P (∃'φ)
hse : ∀ {m : ℕ} {φ₁ φ₂ : BoundedFormula L α m}, Theory.SemanticallyEquivalent ∅ φ₁ φ₂ → (P φ₁ ↔ P φ₂)
m : ℕ
φ : BoundedFormula L α m
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
h✝ : IsPrenex φ✝
hφ : P φ✝
⊢ P (∃'φ✝)

Next tactic:
exact hex hφ
/-- 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
    

Proof state:
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
⊢ T ⊨ᵇ φ ∨ T ⊨ᵇ Formula.not φ

Next tactic:
obtain ⟨_, _⟩ := Theory.exists_model_card_eq ⟨hS.some, hT hS.some⟩ κ 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
    

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✝ = κ
⊢ T ⊨ᵇ φ ∨ T ⊨ᵇ Formula.not φ

Next tactic:
rw [Theory.models_sentence_iff, Theory.models_sentence_iff]