Theorem: FirstOrder.Language.Substructure.cg_iff_empty_or_exists_nat_generating_family
File: Mathlib/ModelTheory/FinitelyGenerated.lean

tactic: rw [cg_def]
state_before: L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
⊢ N.CG ↔ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
state_after: L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
⊢ (∃ S, S.Countable ∧ (closure L).toFun S = N) ↔ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N

tactic: constructor
state_before: L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
⊢ (∃ S, S.Countable ∧ (closure L).toFun S = N) ↔ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
state_after: case mp
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
⊢ (∃ S, S.Countable ∧ (closure L).toFun S = N) → ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N

case mpr
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
⊢ (↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N) → ∃ S, S.Countable ∧ (closure L).toFun S = N

tactic: rintro ⟨S, Scount, hS⟩
state_before: case mp
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
⊢ (∃ S, S.Countable ∧ (closure L).toFun S = N) → ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
state_after: case mp.intro.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
⊢ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N

tactic: rcases eq_empty_or_nonempty (N : Set M) with h | h
state_before: case mp.intro.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
⊢ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
state_after: case mp.intro.intro.inl
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : ↑N = ∅
⊢ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N

case mp.intro.intro.inr
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : (↑N).Nonempty
⊢ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N

tactic: obtain ⟨f, h'⟩ :=
  (Scount.union (Set.countable_singleton h.some)).exists_eq_range
    (singleton_nonempty h.some).inr
state_before: case mp.intro.intro.inr
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : (↑N).Nonempty
⊢ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
state_after: case mp.intro.intro.inr.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : (↑N).Nonempty
f : ℕ → M
h' : S ∪ {h.some} = range f
⊢ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N

tactic: refine Or.intro_right _ ⟨f, ?_⟩
state_before: case mp.intro.intro.inr.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : (↑N).Nonempty
f : ℕ → M
h' : S ∪ {h.some} = range f
⊢ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
state_after: case mp.intro.intro.inr.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : (↑N).Nonempty
f : ℕ → M
h' : S ∪ {h.some} = range f
⊢ (closure L).toFun (range f) = N

tactic: rw [← h', closure_union, hS, sup_eq_left, closure_le]
state_before: case mp.intro.intro.inr.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : (↑N).Nonempty
f : ℕ → M
h' : S ∪ {h.some} = range f
⊢ (closure L).toFun (range f) = N
state_after: case mp.intro.intro.inr.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : (↑N).Nonempty
f : ℕ → M
h' : S ∪ {h.some} = range f
⊢ {h.some} ⊆ ↑N

tactic: exact singleton_subset_iff.2 h.some_mem
state_before: case mp.intro.intro.inr.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : (↑N).Nonempty
f : ℕ → M
h' : S ∪ {h.some} = range f
⊢ {h.some} ⊆ ↑N
state_after: no goals

tactic: exact Or.intro_left _ h
state_before: case mp.intro.intro.inl
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
S : Set M
Scount : S.Countable
hS : (closure L).toFun S = N
h : ↑N = ∅
⊢ ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
state_after: no goals

tactic: intro h
state_before: case mpr
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
⊢ (↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N) → ∃ S, S.Countable ∧ (closure L).toFun S = N
state_after: case mpr
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
⊢ ∃ S, S.Countable ∧ (closure L).toFun S = N

tactic: cases' h with h h
state_before: case mpr
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ↑N = ∅ ∨ ∃ s, (closure L).toFun (range s) = N
⊢ ∃ S, S.Countable ∧ (closure L).toFun S = N
state_after: case mpr.inl
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ↑N = ∅
⊢ ∃ S, S.Countable ∧ (closure L).toFun S = N

case mpr.inr
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ∃ s, (closure L).toFun (range s) = N
⊢ ∃ S, S.Countable ∧ (closure L).toFun S = N

tactic: refine ⟨∅, countable_empty, closure_eq_of_le (empty_subset _) ?_⟩
state_before: case mpr.inl
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ↑N = ∅
⊢ ∃ S, S.Countable ∧ (closure L).toFun S = N
state_after: case mpr.inl
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ↑N = ∅
⊢ N ≤ (closure L).toFun ∅

tactic: rw [← SetLike.coe_subset_coe, h]
state_before: case mpr.inl
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ↑N = ∅
⊢ N ≤ (closure L).toFun ∅
state_after: case mpr.inl
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ↑N = ∅
⊢ ∅ ⊆ ↑((closure L).toFun ∅)

tactic: exact empty_subset _
state_before: case mpr.inl
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ↑N = ∅
⊢ ∅ ⊆ ↑((closure L).toFun ∅)
state_after: no goals

tactic: obtain ⟨f, rfl⟩ := h
state_before: case mpr.inr
L : Language
M : Type u_1
inst✝ : L.Structure M
N : L.Substructure M
h : ∃ s, (closure L).toFun (range s) = N
⊢ ∃ S, S.Countable ∧ (closure L).toFun S = N
state_after: case mpr.inr.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
f : ℕ → M
⊢ ∃ S, S.Countable ∧ (closure L).toFun S = (closure L).toFun (range f)

tactic: exact ⟨range f, countable_range _, rfl⟩
state_before: case mpr.inr.intro
L : Language
M : Type u_1
inst✝ : L.Structure M
f : ℕ → M
⊢ ∃ S, S.Countable ∧ (closure L).toFun S = (closure L).toFun (range f)
state_after: no goals