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_3
inst✝ : Structure L M
N : Substructure L M
⊢ CG N ↔ ↑N = ∅ ∨ ∃ s, LowerAdjoint.toFun (closure L) (range s) = N

tactic: constructor
state_before: L : Language
M : Type u_3
inst✝ : Structure L M
N : Substructure L M
⊢ (∃ S, Set.Countable S ∧ LowerAdjoint.toFun (closure L) S = N) ↔
    ↑N = ∅ ∨ ∃ s, LowerAdjoint.toFun (closure L) (range s) = N

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

tactic: cases' eq_empty_or_nonempty (N : Set M) with h h
state_before: case mp.intro.intro
L : Language
M : Type u_3
inst✝ : Structure L M
N : Substructure L M
S : Set M
Scount : Set.Countable S
hS : LowerAdjoint.toFun (closure L) S = N
⊢ ↑N = ∅ ∨ ∃ s, LowerAdjoint.toFun (closure L) (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_3
inst✝ : Structure L M
N : Substructure L M
S : Set M
Scount : Set.Countable S
hS : LowerAdjoint.toFun (closure L) S = N
h : Set.Nonempty ↑N
⊢ ↑N = ∅ ∨ ∃ s, LowerAdjoint.toFun (closure L) (range s) = N

tactic: refine' Or.intro_right _ ⟨f, _⟩
state_before: case mp.intro.intro.inr.intro
L : Language
M : Type u_3
inst✝ : Structure L M
N : Substructure L M
S : Set M
Scount : Set.Countable S
hS : LowerAdjoint.toFun (closure L) S = N
h : Set.Nonempty ↑N
f : ℕ → M
h' : S ∪ {Set.Nonempty.some h} = range f
⊢ ↑N = ∅ ∨ ∃ s, LowerAdjoint.toFun (closure L) (range s) = 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_3
inst✝ : Structure L M
N : Substructure L M
S : Set M
Scount : Set.Countable S
hS : LowerAdjoint.toFun (closure L) S = N
h : Set.Nonempty ↑N
f : ℕ → M
h' : S ∪ {Set.Nonempty.some h} = range f
⊢ LowerAdjoint.toFun (closure L) (range f) = N

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

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

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

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

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

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

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

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

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