Theorem: Set.Definable.image_comp_embedding
File: Mathlib/ModelTheory/Definability.lean

tactic: classical
  cases nonempty_fintype β
  refine'
    (congr rfl (ext fun x => _)).mp
      (((h.image_comp_equiv (Equiv.Set.sumCompl (range f))).image_comp_equiv
            (Equiv.sumCongr (Equiv.ofInjective f f.injective)
              (Fintype.equivFin (↥((range f)ᶜ))).symm)).image_comp_sum_inl_fin
        _)
  simp only [mem_preimage, mem_image, exists_exists_and_eq_and]
  refine' exists_congr fun y => and_congr_right fun _ => Eq.congr_left (funext fun a => _)
  simp
state_before: M : Type w
A : Set M
L : Language
inst✝¹ : Structure L M
α : Type u₁
β : Type u_1
B : Set M
s✝ : Set (α → M)
s : Set (β → M)
h : Definable A L s
f : α ↪ β
inst✝ : Finite β
⊢ Definable A L ((fun g => g ∘ ↑f) '' s)

tactic: cases nonempty_fintype β
state_before: M : Type w
A : Set M
L : Language
inst✝¹ : Structure L M
α : Type u₁
β : Type u_1
B : Set M
s✝ : Set (α → M)
s : Set (β → M)
h : Definable A L s
f : α ↪ β
inst✝ : Finite β
⊢ Definable A L ((fun g => g ∘ ↑f) '' s)

tactic: refine'
  (congr rfl (ext fun x => _)).mp
    (((h.image_comp_equiv (Equiv.Set.sumCompl (range f))).image_comp_equiv
          (Equiv.sumCongr (Equiv.ofInjective f f.injective)
            (Fintype.equivFin (↥((range f)ᶜ))).symm)).image_comp_sum_inl_fin
      _)
state_before: case intro
M : Type w
A : Set M
L : Language
inst✝¹ : Structure L M
α : Type u₁
β : Type u_1
B : Set M
s✝ : Set (α → M)
s : Set (β → M)
h : Definable A L s
f : α ↪ β
inst✝ : Finite β
val✝ : Fintype β
⊢ Definable A L ((fun g => g ∘ ↑f) '' s)

tactic: simp only [mem_preimage, mem_image, exists_exists_and_eq_and]
state_before: case intro
M : Type w
A : Set M
L : Language
inst✝¹ : Structure L M
α : Type u₁
β : Type u_1
B : Set M
s✝ : Set (α → M)
s : Set (β → M)
h : Definable A L s
f : α ↪ β
inst✝ : Finite β
val✝ : Fintype β
x : α → M
⊢ x ∈
      (fun g => g ∘ Sum.inl) ''
        ((fun g =>
            g ∘
              ↑(Equiv.sumCongr (Equiv.ofInjective ↑f (_ : Function.Injective ↑f))
                  (Fintype.equivFin ↑(range ↑fᶜ)).symm)) ''
          ((fun g => g ∘ ↑(Equiv.Set.sumCompl (range ↑f))) '' s)) ↔
    x ∈ (fun g => g ∘ ↑f) '' s

tactic: refine' exists_congr fun y => and_congr_right fun _ => Eq.congr_left (funext fun a => _)
state_before: case intro
M : Type w
A : Set M
L : Language
inst✝¹ : Structure L M
α : Type u₁
β : Type u_1
B : Set M
s✝ : Set (α → M)
s : Set (β → M)
h : Definable A L s
f : α ↪ β
inst✝ : Finite β
val✝ : Fintype β
x : α → M
⊢ (∃ a,
      a ∈ s ∧
        ((a ∘ ↑(Equiv.Set.sumCompl (range ↑f))) ∘
              ↑(Equiv.sumCongr (Equiv.ofInjective ↑f (_ : Function.Injective ↑f))
                  (Fintype.equivFin ↑(range ↑fᶜ)).symm)) ∘
            Sum.inl =
          x) ↔
    ∃ x_1, x_1 ∈ s ∧ x_1 ∘ ↑f = x

tactic: simp
state_before: case intro
M : Type w
A : Set M
L : Language
inst✝¹ : Structure L M
α : Type u₁
β : Type u_1
B : Set M
s✝ : Set (α → M)
s : Set (β → M)
h : Definable A L s
f : α ↪ β
inst✝ : Finite β
val✝ : Fintype β
x : α → M
y : β → M
x✝ : y ∈ s
a : α
⊢ (((y ∘ ↑(Equiv.Set.sumCompl (range ↑f))) ∘
          ↑(Equiv.sumCongr (Equiv.ofInjective ↑f (_ : Function.Injective ↑f)) (Fintype.equivFin ↑(range ↑fᶜ)).symm)) ∘
        Sum.inl)
      a =
    (y ∘ ↑f) a