l3lab/ntp-mathlib huggingface dataset:
theorem models_iff_not_satisfiable (φ : L.Sentence) : T ⊨ᵇ φ ↔ ¬IsSatisfiable (T ∪ {φ.not}) := by
  rw [models_sentence_iff, IsSatisfiable]
  refine'
    ⟨fun h1 h2 =>
      (Sentence.realize_not _).1
        (realize_sentence_of_mem (T ∪ {Formula.not φ})
          (Set.subset_union_right _ _ (Set.mem_singleton _)))
        (h1 (h2.some.subtheoryModel (Set.subset_union_left _ _))),
      fun h M => _⟩
  contrapose! h
  rw [← Sentence.realize_not] at h
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
M : ModelType T
h : ↑M ⊨ Formula.not φ
⊢ Nonempty (ModelType (T ∪ {Formula.not φ}))

Next tactic:
refine'
    ⟨{  Carrier := M
        is_model := ⟨fun ψ hψ => hψ.elim (realize_sentence_of_mem _) fun h' => _⟩ }⟩
theorem models_iff_not_satisfiable (φ : L.Sentence) : T ⊨ᵇ φ ↔ ¬IsSatisfiable (T ∪ {φ.not}) := by
  rw [models_sentence_iff, IsSatisfiable]
  refine'
    ⟨fun h1 h2 =>
      (Sentence.realize_not _).1
        (realize_sentence_of_mem (T ∪ {Formula.not φ})
          (Set.subset_union_right _ _ (Set.mem_singleton _)))
        (h1 (h2.some.subtheoryModel (Set.subset_union_left _ _))),
      fun h M => _⟩
  contrapose! h
  rw [← Sentence.realize_not] at h
  refine'
    ⟨{  Carrier := M
        is_model := ⟨fun ψ hψ => hψ.elim (realize_sentence_of_mem _) fun h' => _⟩ }⟩
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
M : ModelType T
h : ↑M ⊨ Formula.not φ
ψ : Sentence L
hψ : ψ ∈ T ∪ {Formula.not φ}
h' : ψ ∈ {Formula.not φ}
⊢ ↑M ⊨ ψ

Next tactic:
rw [Set.mem_singleton_iff.1 h']
theorem models_iff_not_satisfiable (φ : L.Sentence) : T ⊨ᵇ φ ↔ ¬IsSatisfiable (T ∪ {φ.not}) := by
  rw [models_sentence_iff, IsSatisfiable]
  refine'
    ⟨fun h1 h2 =>
      (Sentence.realize_not _).1
        (realize_sentence_of_mem (T ∪ {Formula.not φ})
          (Set.subset_union_right _ _ (Set.mem_singleton _)))
        (h1 (h2.some.subtheoryModel (Set.subset_union_left _ _))),
      fun h M => _⟩
  contrapose! h
  rw [← Sentence.realize_not] at h
  refine'
    ⟨{  Carrier := M
        is_model := ⟨fun ψ hψ => hψ.elim (realize_sentence_of_mem _) fun h' => _⟩ }⟩
  rw [Set.mem_singleton_iff.1 h']
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
M : ModelType T
h : ↑M ⊨ Formula.not φ
ψ : Sentence L
hψ : ψ ∈ T ∪ {Formula.not φ}
h' : ψ ∈ {Formula.not φ}
⊢ ↑M ⊨ Formula.not φ

Next tactic:
exact h
theorem ModelsBoundedFormula.realize_sentence {φ : L.Sentence} (h : T ⊨ᵇ φ) (M : Type*)
    [L.Structure M] [M ⊨ T] [Nonempty M] : M ⊨ φ := by
  

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

Next tactic:
rw [models_iff_not_satisfiable] at h
theorem ModelsBoundedFormula.realize_sentence {φ : L.Sentence} (h : T ⊨ᵇ φ) (M : Type*)
    [L.Structure M] [M ⊨ T] [Nonempty M] : M ⊨ φ := by
  rw [models_iff_not_satisfiable] at h
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
h : ¬IsSatisfiable (T ∪ {Formula.not φ})
M : Type u_1
inst✝² : Structure L M
inst✝¹ : M ⊨ T
inst✝ : Nonempty M
⊢ M ⊨ φ

Next tactic:
contrapose! h
theorem ModelsBoundedFormula.realize_sentence {φ : L.Sentence} (h : T ⊨ᵇ φ) (M : Type*)
    [L.Structure M] [M ⊨ T] [Nonempty M] : M ⊨ φ := by
  rw [models_iff_not_satisfiable] at h
  contrapose! h
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
M : Type u_1
inst✝² : Structure L M
inst✝¹ : M ⊨ T
inst✝ : Nonempty M
h : ¬M ⊨ φ
⊢ IsSatisfiable (T ∪ {Formula.not φ})

Next tactic:
have : M ⊨ T ∪ {Formula.not φ} := by
    simp only [Set.union_singleton, model_iff, Set.mem_insert_iff, forall_eq_or_imp,
      Sentence.realize_not]
    rw [← model_iff]
    exact ⟨h, inferInstance⟩
theorem ModelsBoundedFormula.realize_sentence {φ : L.Sentence} (h : T ⊨ᵇ φ) (M : Type*)
    [L.Structure M] [M ⊨ T] [Nonempty M] : M ⊨ φ := by
  rw [models_iff_not_satisfiable] at h
  contrapose! h
  have : M ⊨ T ∪ {Formula.not φ} := by
    

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
M : Type u_1
inst✝² : Structure L M
inst✝¹ : M ⊨ T
inst✝ : Nonempty M
h : ¬M ⊨ φ
⊢ M ⊨ T ∪ {Formula.not φ}

Next tactic:
simp only [Set.union_singleton, model_iff, Set.mem_insert_iff, forall_eq_or_imp,
      Sentence.realize_not]
theorem ModelsBoundedFormula.realize_sentence {φ : L.Sentence} (h : T ⊨ᵇ φ) (M : Type*)
    [L.Structure M] [M ⊨ T] [Nonempty M] : M ⊨ φ := by
  rw [models_iff_not_satisfiable] at h
  contrapose! h
  have : M ⊨ T ∪ {Formula.not φ} := by
    simp only [Set.union_singleton, model_iff, Set.mem_insert_iff, forall_eq_or_imp,
      Sentence.realize_not]
    

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
M : Type u_1
inst✝² : Structure L M
inst✝¹ : M ⊨ T
inst✝ : Nonempty M
h : ¬M ⊨ φ
⊢ ¬M ⊨ φ ∧ ∀ a ∈ T, M ⊨ a

Next tactic:
rw [← model_iff]
theorem ModelsBoundedFormula.realize_sentence {φ : L.Sentence} (h : T ⊨ᵇ φ) (M : Type*)
    [L.Structure M] [M ⊨ T] [Nonempty M] : M ⊨ φ := by
  rw [models_iff_not_satisfiable] at h
  contrapose! h
  have : M ⊨ T ∪ {Formula.not φ} := by
    simp only [Set.union_singleton, model_iff, Set.mem_insert_iff, forall_eq_or_imp,
      Sentence.realize_not]
    rw [← model_iff]
    

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

Next tactic:
exact ⟨h, inferInstance⟩
theorem ModelsBoundedFormula.realize_sentence {φ : L.Sentence} (h : T ⊨ᵇ φ) (M : Type*)
    [L.Structure M] [M ⊨ T] [Nonempty M] : M ⊨ φ := by
  rw [models_iff_not_satisfiable] at h
  contrapose! h
  have : M ⊨ T ∪ {Formula.not φ} := by
    simp only [Set.union_singleton, model_iff, Set.mem_insert_iff, forall_eq_or_imp,
      Sentence.realize_not]
    rw [← model_iff]
    exact ⟨h, inferInstance⟩
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
M : Type u_1
inst✝² : Structure L M
inst✝¹ : M ⊨ T
inst✝ : Nonempty M
h : ¬M ⊨ φ
this : M ⊨ T ∪ {Formula.not φ}
⊢ IsSatisfiable (T ∪ {Formula.not φ})

Next tactic:
exact Model.isSatisfiable M
theorem models_of_models_theory {T' : L.Theory}
    (h : ∀ φ : L.Sentence, φ ∈ T' → T ⊨ᵇ φ)
    {φ : L.Formula α} (hφ : T' ⊨ᵇ φ) : T ⊨ᵇ φ := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
h : ∀ φ ∈ T', T ⊨ᵇ φ
φ : Formula L α
hφ : T' ⊨ᵇ φ
⊢ T ⊨ᵇ φ

Next tactic:
simp only [models_sentence_iff] at h
theorem models_of_models_theory {T' : L.Theory}
    (h : ∀ φ : L.Sentence, φ ∈ T' → T ⊨ᵇ φ)
    {φ : L.Formula α} (hφ : T' ⊨ᵇ φ) : T ⊨ᵇ φ := by
  simp only [models_sentence_iff] at h
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
φ : Formula L α
hφ : T' ⊨ᵇ φ
h : ∀ φ ∈ T', ∀ (M : ModelType T), ↑M ⊨ φ
⊢ T ⊨ᵇ φ

Next tactic:
intro M
theorem models_of_models_theory {T' : L.Theory}
    (h : ∀ φ : L.Sentence, φ ∈ T' → T ⊨ᵇ φ)
    {φ : L.Formula α} (hφ : T' ⊨ᵇ φ) : T ⊨ᵇ φ := by
  simp only [models_sentence_iff] at h
  intro M
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
φ : Formula L α
hφ : T' ⊨ᵇ φ
h : ∀ φ ∈ T', ∀ (M : ModelType T), ↑M ⊨ φ
M : ModelType T
⊢ ∀ (v : α → ↑M) (xs : Fin 0 → ↑M), BoundedFormula.Realize φ v xs

Next tactic:
have hM : M ⊨ T' := T'.model_iff.2 (fun ψ hψ => h ψ hψ M)
theorem models_of_models_theory {T' : L.Theory}
    (h : ∀ φ : L.Sentence, φ ∈ T' → T ⊨ᵇ φ)
    {φ : L.Formula α} (hφ : T' ⊨ᵇ φ) : T ⊨ᵇ φ := by
  simp only [models_sentence_iff] at h
  intro M
  have hM : M ⊨ T' := T'.model_iff.2 (fun ψ hψ => h ψ hψ M)
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
φ : Formula L α
hφ : T' ⊨ᵇ φ
h : ∀ φ ∈ T', ∀ (M : ModelType T), ↑M ⊨ φ
M : ModelType T
hM : ↑M ⊨ T'
⊢ ∀ (v : α → ↑M) (xs : Fin 0 → ↑M), BoundedFormula.Realize φ v xs

Next tactic:
let M' : ModelType T' := ⟨M⟩
theorem models_of_models_theory {T' : L.Theory}
    (h : ∀ φ : L.Sentence, φ ∈ T' → T ⊨ᵇ φ)
    {φ : L.Formula α} (hφ : T' ⊨ᵇ φ) : T ⊨ᵇ φ := by
  simp only [models_sentence_iff] at h
  intro M
  have hM : M ⊨ T' := T'.model_iff.2 (fun ψ hψ => h ψ hψ M)
  let M' : ModelType T' := ⟨M⟩
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
φ : Formula L α
hφ : T' ⊨ᵇ φ
h : ∀ φ ∈ T', ∀ (M : ModelType T), ↑M ⊨ φ
M : ModelType T
hM : ↑M ⊨ T'
M' : ModelType T' := ModelType.mk ↑M
⊢ ∀ (v : α → ↑M) (xs : Fin 0 → ↑M), BoundedFormula.Realize φ v xs

Next tactic:
exact hφ M'
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
⊢ T ⊨ᵇ φ ↔ ∃ T0, ↑T0 ⊆ T ∧ ↑T0 ⊨ᵇ φ

Next tactic:
simp only [models_iff_not_satisfiable]
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
⊢ ¬IsSatisfiable (T ∪ {Formula.not φ}) ↔ ∃ T0, ↑T0 ⊆ T ∧ ¬IsSatisfiable (↑T0 ∪ {Formula.not φ})

Next tactic:
rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
⊢ (∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T ∪ {Formula.not φ} → IsSatisfiable ↑T0) ↔
    ¬∃ T0, ↑T0 ⊆ T ∧ ¬IsSatisfiable (↑T0 ∪ {Formula.not φ})

Next tactic:
push_neg
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
⊢ (∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T ∪ {Formula.not φ} → IsSatisfiable ↑T0) ↔
    ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T → IsSatisfiable (↑T0 ∪ {Formula.not φ})

Next tactic:
letI := Classical.decEq (Sentence L)
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
⊢ (∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T ∪ {Formula.not φ} → IsSatisfiable ↑T0) ↔
    ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T → IsSatisfiable (↑T0 ∪ {Formula.not φ})

Next tactic:
constructor
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  constructor
  · 

Proof state:
case mp
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
⊢ (∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T ∪ {Formula.not φ} → IsSatisfiable ↑T0) →
    ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T → IsSatisfiable (↑T0 ∪ {Formula.not φ})

Next tactic:
intro h T0 hT0
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  constructor
  · intro h T0 hT0
    

Proof state:
case mp
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
h : ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T ∪ {Formula.not φ} → IsSatisfiable ↑T0
T0 : Finset (Sentence L)
hT0 : ↑T0 ⊆ T
⊢ IsSatisfiable (↑T0 ∪ {Formula.not φ})

Next tactic:
simpa using h (T0 ∪ {Formula.not φ})
      (by
        simp only [Finset.coe_union, Finset.coe_singleton]
        exact Set.union_subset_union hT0 (Set.Subset.refl _))
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  constructor
  · intro h T0 hT0
    simpa using h (T0 ∪ {Formula.not φ})
      (by
        

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
h : ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T ∪ {Formula.not φ} → IsSatisfiable ↑T0
T0 : Finset (Sentence L)
hT0 : ↑T0 ⊆ T
⊢ ↑(T0 ∪ {Formula.not φ}) ⊆ T ∪ {Formula.not φ}

Next tactic:
simp only [Finset.coe_union, Finset.coe_singleton]
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  constructor
  · intro h T0 hT0
    simpa using h (T0 ∪ {Formula.not φ})
      (by
        simp only [Finset.coe_union, Finset.coe_singleton]
        

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
h : ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T ∪ {Formula.not φ} → IsSatisfiable ↑T0
T0 : Finset (Sentence L)
hT0 : ↑T0 ⊆ T
⊢ ↑T0 ∪ {Formula.not φ} ⊆ T ∪ {Formula.not φ}

Next tactic:
exact Set.union_subset_union hT0 (Set.Subset.refl _)
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  constructor
  · intro h T0 hT0
    simpa using h (T0 ∪ {Formula.not φ})
      (by
        simp only [Finset.coe_union, Finset.coe_singleton]
        exact Set.union_subset_union hT0 (Set.Subset.refl _))
  · 

Proof state:
case mpr
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
⊢ (∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T → IsSatisfiable (↑T0 ∪ {Formula.not φ})) →
    ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T ∪ {Formula.not φ} → IsSatisfiable ↑T0

Next tactic:
intro h T0 hT0
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  constructor
  · intro h T0 hT0
    simpa using h (T0 ∪ {Formula.not φ})
      (by
        simp only [Finset.coe_union, Finset.coe_singleton]
        exact Set.union_subset_union hT0 (Set.Subset.refl _))
  · intro h T0 hT0
    

Proof state:
case mpr
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
h : ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T → IsSatisfiable (↑T0 ∪ {Formula.not φ})
T0 : Finset (Sentence L)
hT0 : ↑T0 ⊆ T ∪ {Formula.not φ}
⊢ IsSatisfiable ↑T0

Next tactic:
exact IsSatisfiable.mono (h (T0.erase (Formula.not φ))
      (by simpa using hT0)) (by simp)
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  constructor
  · intro h T0 hT0
    simpa using h (T0 ∪ {Formula.not φ})
      (by
        simp only [Finset.coe_union, Finset.coe_singleton]
        exact Set.union_subset_union hT0 (Set.Subset.refl _))
  · intro h T0 hT0
    exact IsSatisfiable.mono (h (T0.erase (Formula.not φ))
      (by 

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
h : ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T → IsSatisfiable (↑T0 ∪ {Formula.not φ})
T0 : Finset (Sentence L)
hT0 : ↑T0 ⊆ T ∪ {Formula.not φ}
⊢ ↑(Finset.erase T0 (Formula.not φ)) ⊆ T

Next tactic:
simpa using hT0
/-- An alternative statement of the Compactness Theorem. A formula `φ` is modeled by a
theory iff there is a finite subset `T0` of the theory such that `φ` is modeled by `T0` -/
theorem models_iff_finset_models {φ : L.Sentence} :
    T ⊨ᵇ φ ↔ ∃ T0 : Finset L.Sentence, (T0 : L.Theory) ⊆ T ∧ (T0 : L.Theory) ⊨ᵇ φ := by
  simp only [models_iff_not_satisfiable]
  rw [← not_iff_not, not_not, isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  push_neg
  letI := Classical.decEq (Sentence L)
  constructor
  · intro h T0 hT0
    simpa using h (T0 ∪ {Formula.not φ})
      (by
        simp only [Finset.coe_union, Finset.coe_singleton]
        exact Set.union_subset_union hT0 (Set.Subset.refl _))
  · intro h T0 hT0
    exact IsSatisfiable.mono (h (T0.erase (Formula.not φ))
      (by simpa using hT0)) (by 

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
φ : Sentence L
this : DecidableEq (Sentence L) := Classical.decEq (Sentence L)
h : ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ T → IsSatisfiable (↑T0 ∪ {Formula.not φ})
T0 : Finset (Sentence L)
hT0 : ↑T0 ⊆ T ∪ {Formula.not φ}
⊢ ↑T0 ⊆ ↑(Finset.erase T0 (Formula.not φ)) ∪ {Formula.not φ}

Next tactic:
simp
theorem models_not_iff (h : T.IsComplete) (φ : L.Sentence) : T ⊨ᵇ φ.not ↔ ¬T ⊨ᵇ φ := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
⊢ T ⊨ᵇ Formula.not φ ↔ ¬T ⊨ᵇ φ

Next tactic:
cases' h.2 φ with hφ hφn
theorem models_not_iff (h : T.IsComplete) (φ : L.Sentence) : T ⊨ᵇ φ.not ↔ ¬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
hφ : T ⊨ᵇ φ
⊢ T ⊨ᵇ Formula.not φ ↔ ¬T ⊨ᵇ φ

Next tactic:
simp only [hφ, not_true, iff_false_iff]
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]
    

Proof state:
case inl
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
hφ : T ⊨ᵇ φ
⊢ ¬T ⊨ᵇ Formula.not φ

Next tactic:
rw [models_sentence_iff, not_forall]
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]
    

Proof state:
case inl
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
hφ : T ⊨ᵇ φ
⊢ ∃ x, ¬↑x ⊨ Formula.not φ

Next tactic:
refine' ⟨h.1.some, _⟩
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, _⟩
    

Proof state:
case inl
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
hφ : T ⊨ᵇ φ
⊢ ¬↑(Nonempty.some (_ : IsSatisfiable T)) ⊨ Formula.not φ

Next tactic:
simp only [Sentence.realize_not, Classical.not_not]
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]
    

Proof state:
case inl
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
hφ : T ⊨ᵇ φ
⊢ ↑(Nonempty.some (_ : IsSatisfiable T)) ⊨ φ

Next tactic:
exact models_sentence_iff.1 hφ _
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φ _
  · 

Proof state:
case inr
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
hφn : T ⊨ᵇ Formula.not φ
⊢ T ⊨ᵇ Formula.not φ ↔ ¬T ⊨ᵇ φ

Next tactic:
simp only [hφn, true_iff_iff]
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]
    

Proof state:
case inr
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
hφn : T ⊨ᵇ Formula.not φ
⊢ ¬T ⊨ᵇ φ

Next tactic:
intro hφ
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φ
    

Proof state:
case inr
L : Language
T : Theory L
α : Type w
n : ℕ
h : IsComplete T
φ : Sentence L
hφn : T ⊨ᵇ Formula.not φ
hφ : T ⊨ᵇ φ
⊢ False

Next tactic:
rw [models_sentence_iff] at *