l3lab/ntp-mathlib huggingface dataset:
/-- If `f` grows in the punctured neighborhood of `c : ℝ` at least as fast as `1 / (x - c)`,
then it is not interval integrable on any nontrivial interval `a..b`, `c ∈ [a, b]`. -/
theorem not_intervalIntegrable_of_sub_inv_isBigO_punctured {f : ℝ → F} {a b c : ℝ}
    (hf : (fun x => (x - c)⁻¹) =O[𝓝[≠] c] f) (hne : a ≠ b) (hc : c ∈ [[a, b]]) :
    ¬IntervalIntegrable f volume a b := by
  have A : ∀ᶠ x in 𝓝[≠] c, HasDerivAt (fun x => Real.log (x - c)) (x - c)⁻¹ x := by
    filter_upwards [self_mem_nhdsWithin] with x hx
    simpa using ((hasDerivAt_id x).sub_const c).log (sub_ne_zero.2 hx)
  have B : Tendsto (fun x => ‖Real.log (x - c)‖) (𝓝[≠] c) atTop := by
    refine' tendsto_abs_atBot_atTop.comp (Real.tendsto_log_nhdsWithin_zero.comp _)
    rw [← sub_self c]
    

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
f : ℝ → F
a b c : ℝ
hf : (fun x => (x - c)⁻¹) =O[𝓝[≠] c] f
hne : a ≠ b
hc : c ∈ [[a, b]]
A : ∀ᶠ (x : ℝ) in 𝓝[≠] c, HasDerivAt (fun x => Real.log (x - c)) (x - c)⁻¹ x
⊢ Tendsto (fun x => x - c) (𝓝[≠] c) (𝓝[≠] (c - c))

Next tactic:
exact ((hasDerivAt_id c).sub_const c).tendsto_punctured_nhds one_ne_zero
/-- If `f` grows in the punctured neighborhood of `c : ℝ` at least as fast as `1 / (x - c)`,
then it is not interval integrable on any nontrivial interval `a..b`, `c ∈ [a, b]`. -/
theorem not_intervalIntegrable_of_sub_inv_isBigO_punctured {f : ℝ → F} {a b c : ℝ}
    (hf : (fun x => (x - c)⁻¹) =O[𝓝[≠] c] f) (hne : a ≠ b) (hc : c ∈ [[a, b]]) :
    ¬IntervalIntegrable f volume a b := by
  have A : ∀ᶠ x in 𝓝[≠] c, HasDerivAt (fun x => Real.log (x - c)) (x - c)⁻¹ x := by
    filter_upwards [self_mem_nhdsWithin] with x hx
    simpa using ((hasDerivAt_id x).sub_const c).log (sub_ne_zero.2 hx)
  have B : Tendsto (fun x => ‖Real.log (x - c)‖) (𝓝[≠] c) atTop := by
    refine' tendsto_abs_atBot_atTop.comp (Real.tendsto_log_nhdsWithin_zero.comp _)
    rw [← sub_self c]
    exact ((hasDerivAt_id c).sub_const c).tendsto_punctured_nhds one_ne_zero
  

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
f : ℝ → F
a b c : ℝ
hf : (fun x => (x - c)⁻¹) =O[𝓝[≠] c] f
hne : a ≠ b
hc : c ∈ [[a, b]]
A : ∀ᶠ (x : ℝ) in 𝓝[≠] c, HasDerivAt (fun x => Real.log (x - c)) (x - c)⁻¹ x
B : Tendsto (fun x => ‖Real.log (x - c)‖) (𝓝[≠] c) atTop
⊢ ¬IntervalIntegrable f volume a b

Next tactic:
exact not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_punctured
    (A.mono fun x hx => hx.differentiableAt) B
    (hf.congr' (A.mono fun x hx => hx.deriv.symm) EventuallyEq.rfl) hne hc
/-- The function `fun x => (x - c)⁻¹` is integrable on `a..b` if and only if
`a = b` or `c ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :
    IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]] := by
  

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a b c : ℝ
⊢ IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]]

Next tactic:
constructor
/-- The function `fun x => (x - c)⁻¹` is integrable on `a..b` if and only if
`a = b` or `c ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :
    IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]] := by
  constructor
  · 

Proof state:
case mp
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a b c : ℝ
⊢ IntervalIntegrable (fun x => (x - c)⁻¹) volume a b → a = b ∨ c ∉ [[a, b]]

Next tactic:
refine' fun h => or_iff_not_imp_left.2 fun hne hc => _
/-- The function `fun x => (x - c)⁻¹` is integrable on `a..b` if and only if
`a = b` or `c ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :
    IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]] := by
  constructor
  · refine' fun h => or_iff_not_imp_left.2 fun hne hc => _
    

Proof state:
case mp
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a b c : ℝ
h : IntervalIntegrable (fun x => (x - c)⁻¹) volume a b
hne : ¬a = b
hc : c ∈ [[a, b]]
⊢ False

Next tactic:
exact not_intervalIntegrable_of_sub_inv_isBigO_punctured (isBigO_refl _ _) hne hc h
/-- The function `fun x => (x - c)⁻¹` is integrable on `a..b` if and only if
`a = b` or `c ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :
    IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]] := by
  constructor
  · refine' fun h => or_iff_not_imp_left.2 fun hne hc => _
    exact not_intervalIntegrable_of_sub_inv_isBigO_punctured (isBigO_refl _ _) hne hc h
  · 

Proof state:
case mpr
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a b c : ℝ
⊢ a = b ∨ c ∉ [[a, b]] → IntervalIntegrable (fun x => (x - c)⁻¹) volume a b

Next tactic:
rintro (rfl | h₀)
/-- The function `fun x => (x - c)⁻¹` is integrable on `a..b` if and only if
`a = b` or `c ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :
    IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]] := by
  constructor
  · refine' fun h => or_iff_not_imp_left.2 fun hne hc => _
    exact not_intervalIntegrable_of_sub_inv_isBigO_punctured (isBigO_refl _ _) hne hc h
  · rintro (rfl | h₀)
    · 

Proof state:
case mpr.inl
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a c : ℝ
⊢ IntervalIntegrable (fun x => (x - c)⁻¹) volume a a

Next tactic:
exact IntervalIntegrable.refl
/-- The function `fun x => (x - c)⁻¹` is integrable on `a..b` if and only if
`a = b` or `c ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :
    IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]] := by
  constructor
  · refine' fun h => or_iff_not_imp_left.2 fun hne hc => _
    exact not_intervalIntegrable_of_sub_inv_isBigO_punctured (isBigO_refl _ _) hne hc h
  · rintro (rfl | h₀)
    · exact IntervalIntegrable.refl
    

Proof state:
case mpr.inr
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a b c : ℝ
h₀ : c ∉ [[a, b]]
⊢ IntervalIntegrable (fun x => (x - c)⁻¹) volume a b

Next tactic:
refine' ((continuous_sub_right c).continuousOn.inv₀ _).intervalIntegrable
/-- The function `fun x => (x - c)⁻¹` is integrable on `a..b` if and only if
`a = b` or `c ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :
    IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]] := by
  constructor
  · refine' fun h => or_iff_not_imp_left.2 fun hne hc => _
    exact not_intervalIntegrable_of_sub_inv_isBigO_punctured (isBigO_refl _ _) hne hc h
  · rintro (rfl | h₀)
    · exact IntervalIntegrable.refl
    refine' ((continuous_sub_right c).continuousOn.inv₀ _).intervalIntegrable
    

Proof state:
case mpr.inr
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a b c : ℝ
h₀ : c ∉ [[a, b]]
⊢ ∀ x ∈ [[a, b]], x - c ≠ 0

Next tactic:
exact fun x hx => sub_ne_zero.2 <| ne_of_mem_of_not_mem hx h₀
/-- The function `fun x => x⁻¹` is integrable on `a..b` if and only if
`a = b` or `0 ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_inv_iff {a b : ℝ} :
    IntervalIntegrable (fun x => x⁻¹) volume a b ↔ a = b ∨ (0 : ℝ) ∉ [[a, b]] := by
  

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a b : ℝ
⊢ IntervalIntegrable (fun x => x⁻¹) volume a b ↔ a = b ∨ 0 ∉ [[a, b]]

Next tactic:
simp only [← intervalIntegrable_sub_inv_iff, sub_zero]
/-- The function `fun x ↦ x⁻¹` is not integrable on any interval `[a, +∞)`. -/
theorem not_IntegrableOn_Ici_inv {a : ℝ} :
    ¬ IntegrableOn (fun x => x⁻¹) (Ici a) := by
  

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a : ℝ
⊢ ¬IntegrableOn (fun x => x⁻¹) (Ici a)

Next tactic:
have A : ∀ᶠ x in atTop, HasDerivAt (fun x => Real.log x) x⁻¹ x := by
    filter_upwards [Ioi_mem_atTop 0] with x hx using Real.hasDerivAt_log (ne_of_gt hx)
/-- The function `fun x ↦ x⁻¹` is not integrable on any interval `[a, +∞)`. -/
theorem not_IntegrableOn_Ici_inv {a : ℝ} :
    ¬ IntegrableOn (fun x => x⁻¹) (Ici a) := by
  have A : ∀ᶠ x in atTop, HasDerivAt (fun x => Real.log x) x⁻¹ x := by
    

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a : ℝ
⊢ ∀ᶠ (x : ℝ) in atTop, HasDerivAt (fun x => Real.log x) x⁻¹ x

Next tactic:
filter_upwards [Ioi_mem_atTop 0] with x hx using Real.hasDerivAt_log (ne_of_gt hx)
/-- The function `fun x ↦ x⁻¹` is not integrable on any interval `[a, +∞)`. -/
theorem not_IntegrableOn_Ici_inv {a : ℝ} :
    ¬ IntegrableOn (fun x => x⁻¹) (Ici a) := by
  have A : ∀ᶠ x in atTop, HasDerivAt (fun x => Real.log x) x⁻¹ x := by
    filter_upwards [Ioi_mem_atTop 0] with x hx using Real.hasDerivAt_log (ne_of_gt hx)
  

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a : ℝ
A : ∀ᶠ (x : ℝ) in atTop, HasDerivAt (fun x => Real.log x) x⁻¹ x
⊢ ¬IntegrableOn (fun x => x⁻¹) (Ici a)

Next tactic:
have B : Tendsto (fun x => ‖Real.log x‖) atTop atTop :=
    tendsto_norm_atTop_atTop.comp Real.tendsto_log_atTop
/-- The function `fun x ↦ x⁻¹` is not integrable on any interval `[a, +∞)`. -/
theorem not_IntegrableOn_Ici_inv {a : ℝ} :
    ¬ IntegrableOn (fun x => x⁻¹) (Ici a) := by
  have A : ∀ᶠ x in atTop, HasDerivAt (fun x => Real.log x) x⁻¹ x := by
    filter_upwards [Ioi_mem_atTop 0] with x hx using Real.hasDerivAt_log (ne_of_gt hx)
  have B : Tendsto (fun x => ‖Real.log x‖) atTop atTop :=
    tendsto_norm_atTop_atTop.comp Real.tendsto_log_atTop
  

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a : ℝ
A : ∀ᶠ (x : ℝ) in atTop, HasDerivAt (fun x => Real.log x) x⁻¹ x
B : Tendsto (fun x => ‖Real.log x‖) atTop atTop
⊢ ¬IntegrableOn (fun x => x⁻¹) (Ici a)

Next tactic:
exact not_integrableOn_of_tendsto_norm_atTop_of_deriv_isBigO_filter atTop (Ici_mem_atTop a)
    (A.mono (fun x hx ↦ hx.differentiableAt)) B
    (Filter.EventuallyEq.isBigO (A.mono (fun x hx ↦ hx.deriv)))
/-- The function `fun x ↦ x⁻¹` is not integrable on any interval `(a, +∞)`. -/
theorem not_IntegrableOn_Ioi_inv {a : ℝ} :
    ¬ IntegrableOn (·⁻¹) (Ioi a) := by
  

Proof state:
E : Type u_1
F : Type u_2
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : NormedAddCommGroup F
a : ℝ
⊢ ¬IntegrableOn (fun x => x⁻¹) (Ioi a)

Next tactic:
simpa only [IntegrableOn, restrict_Ioi_eq_restrict_Ici] using not_IntegrableOn_Ici_inv
instance funLike : FunLike (M ↪ₑ[L] N) M fun _ => N where
  coe f := f.toFun
  coe_injective' f g h := by
    

Proof state:
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
f g : M ↪ₑ[L] N
h : (fun f => ↑f) f = (fun f => ↑f) g
⊢ f = g

Next tactic:
cases f
instance funLike : FunLike (M ↪ₑ[L] N) M fun _ => N where
  coe f := f.toFun
  coe_injective' f g h := by
    cases f
    

Proof state:
case mk
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
g : M ↪ₑ[L] N
toFun✝ : M → N
map_formula'✝ : ∀ ⦃n : ℕ⦄ (φ : Formula L (Fin n)) (x : Fin n → M), Formula.Realize φ (toFun✝ ∘ x) ↔ Formula.Realize φ x
h : (fun f => ↑f) (mk toFun✝) = (fun f => ↑f) g
⊢ mk toFun✝ = g

Next tactic:
cases g
instance funLike : FunLike (M ↪ₑ[L] N) M fun _ => N where
  coe f := f.toFun
  coe_injective' f g h := by
    cases f
    cases g
    

Proof state:
case mk.mk
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
toFun✝¹ : M → N
map_formula'✝¹ :
  ∀ ⦃n : ℕ⦄ (φ : Formula L (Fin n)) (x : Fin n → M), Formula.Realize φ (toFun✝¹ ∘ x) ↔ Formula.Realize φ x
toFun✝ : M → N
map_formula'✝ : ∀ ⦃n : ℕ⦄ (φ : Formula L (Fin n)) (x : Fin n → M), Formula.Realize φ (toFun✝ ∘ x) ↔ Formula.Realize φ x
h : (fun f => ↑f) (mk toFun✝¹) = (fun f => ↑f) (mk toFun✝)
⊢ mk toFun✝¹ = mk toFun✝

Next tactic:
simp only [ElementaryEmbedding.mk.injEq]
instance funLike : FunLike (M ↪ₑ[L] N) M fun _ => N where
  coe f := f.toFun
  coe_injective' f g h := by
    cases f
    cases g
    simp only [ElementaryEmbedding.mk.injEq]
    

Proof state:
case mk.mk
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
toFun✝¹ : M → N
map_formula'✝¹ :
  ∀ ⦃n : ℕ⦄ (φ : Formula L (Fin n)) (x : Fin n → M), Formula.Realize φ (toFun✝¹ ∘ x) ↔ Formula.Realize φ x
toFun✝ : M → N
map_formula'✝ : ∀ ⦃n : ℕ⦄ (φ : Formula L (Fin n)) (x : Fin n → M), Formula.Realize φ (toFun✝ ∘ x) ↔ Formula.Realize φ x
h : (fun f => ↑f) (mk toFun✝¹) = (fun f => ↑f) (mk toFun✝)
⊢ toFun✝¹ = toFun✝

Next tactic:
ext x
instance funLike : FunLike (M ↪ₑ[L] N) M fun _ => N where
  coe f := f.toFun
  coe_injective' f g h := by
    cases f
    cases g
    simp only [ElementaryEmbedding.mk.injEq]
    ext x
    

Proof state:
case mk.mk.h
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
toFun✝¹ : M → N
map_formula'✝¹ :
  ∀ ⦃n : ℕ⦄ (φ : Formula L (Fin n)) (x : Fin n → M), Formula.Realize φ (toFun✝¹ ∘ x) ↔ Formula.Realize φ x
toFun✝ : M → N
map_formula'✝ : ∀ ⦃n : ℕ⦄ (φ : Formula L (Fin n)) (x : Fin n → M), Formula.Realize φ (toFun✝ ∘ x) ↔ Formula.Realize φ x
h : (fun f => ↑f) (mk toFun✝¹) = (fun f => ↑f) (mk toFun✝)
x : M
⊢ toFun✝¹ x = toFun✝ x

Next tactic:
exact Function.funext_iff.1 h x
@[simp]
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
    (v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
  

Proof state:
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
f : M ↪ₑ[L] N
α : Type u_5
n : ℕ
φ : BoundedFormula L α n
v : α → M
xs : Fin n → M
⊢ BoundedFormula.Realize φ (⇑f ∘ v) (⇑f ∘ xs) ↔ BoundedFormula.Realize φ v xs

Next tactic:
classical
    rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq]
    have h :=
      f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _))
        (Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm)
    simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula, iff_eq_eq] at h
    rw [← Function.comp.assoc _ _ (Fintype.equivFin _).symm,
      Function.comp.assoc _ (Fintype.equivFin _).symm (Fintype.equivFin _), Equiv.symm_comp_self,
      Function.comp.right_id, Function.comp.assoc, Sum.elim_comp_inl,
      Function.comp.assoc _ _ Sum.inr, Sum.elim_comp_inr, ← Function.comp.assoc] at h
    refine' h.trans _
    erw [Function.comp.assoc _ _ (Fintype.equivFin _), Equiv.symm_comp_self, Function.comp.right_id,
      Sum.elim_comp_inl, Sum.elim_comp_inr (v ∘ Subtype.val) xs,
      ← Set.inclusion_eq_id (s := (BoundedFormula.freeVarFinset φ : Set α)) Set.Subset.rfl,
      BoundedFormula.realize_restrictFreeVar Set.Subset.rfl]
@[simp]
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
    (v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
  classical
    

Proof state:
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
f : M ↪ₑ[L] N
α : Type u_5
n : ℕ
φ : BoundedFormula L α n
v : α → M
xs : Fin n → M
⊢ BoundedFormula.Realize φ (⇑f ∘ v) (⇑f ∘ xs) ↔ BoundedFormula.Realize φ v xs

Next tactic:
rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq]
@[simp]
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
    (v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
  classical
    rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq]
    

Proof state:
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
f : M ↪ₑ[L] N
α : Type u_5
n : ℕ
φ : BoundedFormula L α n
v : α → M
xs : Fin n → M
⊢ BoundedFormula.Realize (BoundedFormula.restrictFreeVar φ id) ((⇑f ∘ v) ∘ Subtype.val) (⇑f ∘ xs) =
    BoundedFormula.Realize φ v xs

Next tactic:
have h :=
      f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _))
        (Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm)
@[simp]
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
    (v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
  classical
    rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq]
    have h :=
      f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _))
        (Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm)
    

Proof state:
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
f : M ↪ₑ[L] N
α : Type u_5
n : ℕ
φ : BoundedFormula L α n
v : α → M
xs : Fin n → M
h :
  Formula.Realize
      (Formula.relabel (⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)))
        (BoundedFormula.toFormula (BoundedFormula.restrictFreeVar φ id)))
      (↑f ∘
        Sum.elim (v ∘ Subtype.val) xs ∘
          ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)).symm) ↔
    Formula.Realize
      (Formula.relabel (⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)))
        (BoundedFormula.toFormula (BoundedFormula.restrictFreeVar φ id)))
      (Sum.elim (v ∘ Subtype.val) xs ∘ ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)).symm)
⊢ BoundedFormula.Realize (BoundedFormula.restrictFreeVar φ id) ((⇑f ∘ v) ∘ Subtype.val) (⇑f ∘ xs) =
    BoundedFormula.Realize φ v xs

Next tactic:
simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula, iff_eq_eq] at h
@[simp]
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
    (v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
  classical
    rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq]
    have h :=
      f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _))
        (Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm)
    simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula, iff_eq_eq] at h
    

Proof state:
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
f : M ↪ₑ[L] N
α : Type u_5
n : ℕ
φ : BoundedFormula L α n
v : α → M
xs : Fin n → M
h :
  BoundedFormula.Realize (BoundedFormula.restrictFreeVar φ id)
      (((↑f ∘
            Sum.elim (v ∘ Subtype.val) xs ∘
              ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)).symm) ∘
          ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n))) ∘
        Sum.inl)
      (((↑f ∘
            Sum.elim (v ∘ Subtype.val) xs ∘
              ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)).symm) ∘
          ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n))) ∘
        Sum.inr) =
    BoundedFormula.Realize (BoundedFormula.restrictFreeVar φ id)
      (((Sum.elim (v ∘ Subtype.val) xs ∘
            ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)).symm) ∘
          ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n))) ∘
        Sum.inl)
      (((Sum.elim (v ∘ Subtype.val) xs ∘
            ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)).symm) ∘
          ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n))) ∘
        Sum.inr)
⊢ BoundedFormula.Realize (BoundedFormula.restrictFreeVar φ id) ((⇑f ∘ v) ∘ Subtype.val) (⇑f ∘ xs) =
    BoundedFormula.Realize φ v xs

Next tactic:
rw [← Function.comp.assoc _ _ (Fintype.equivFin _).symm,
      Function.comp.assoc _ (Fintype.equivFin _).symm (Fintype.equivFin _), Equiv.symm_comp_self,
      Function.comp.right_id, Function.comp.assoc, Sum.elim_comp_inl,
      Function.comp.assoc _ _ Sum.inr, Sum.elim_comp_inr, ← Function.comp.assoc] at h
@[simp]
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
    (v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
  classical
    rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq]
    have h :=
      f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _))
        (Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm)
    simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula, iff_eq_eq] at h
    rw [← Function.comp.assoc _ _ (Fintype.equivFin _).symm,
      Function.comp.assoc _ (Fintype.equivFin _).symm (Fintype.equivFin _), Equiv.symm_comp_self,
      Function.comp.right_id, Function.comp.assoc, Sum.elim_comp_inl,
      Function.comp.assoc _ _ Sum.inr, Sum.elim_comp_inr, ← Function.comp.assoc] at h
    

Proof state:
L : Language
M : Type u_1
N : Type u_2
P : Type u_3
Q : Type u_4
inst✝³ : Structure L M
inst✝² : Structure L N
inst✝¹ : Structure L P
inst✝ : Structure L Q
f : M ↪ₑ[L] N
α : Type u_5
n : ℕ
φ : BoundedFormula L α n
v : α → M
xs : Fin n → M
h :
  BoundedFormula.Realize (BoundedFormula.restrictFreeVar φ id) ((↑f ∘ v) ∘ Subtype.val) (↑f ∘ xs) =
    BoundedFormula.Realize (BoundedFormula.restrictFreeVar φ id)
      (((Sum.elim (v ∘ Subtype.val) xs ∘
            ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)).symm) ∘
          ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n))) ∘
        Sum.inl)
      (((Sum.elim (v ∘ Subtype.val) xs ∘
            ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n)).symm) ∘
          ⇑(Fintype.equivFin ({ x // x ∈ BoundedFormula.freeVarFinset φ } ⊕ Fin n))) ∘
        Sum.inr)
⊢ BoundedFormula.Realize (BoundedFormula.restrictFreeVar φ id) ((⇑f ∘ v) ∘ Subtype.val) (⇑f ∘ xs) =
    BoundedFormula.Realize φ v xs

Next tactic:
refine' h.trans _