l3lab/ntp-mathlib huggingface dataset:
/-- If `f` has a local max on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and
`y` belongs to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/
theorem IsLocalMaxOn.hasFDerivWithinAt_nonpos {s : Set E} (h : IsLocalMaxOn f s a)
    (hf : HasFDerivWithinAt f f' s a) {y} (hy : y ∈ posTangentConeAt s a) : f' y ≤ 0 := by
  rcases hy with ⟨c, d, hd, hc, hcd⟩
  have hc' : Tendsto (‖c ·‖) atTop atTop := tendsto_abs_atTop_atTop.comp hc
  suffices : ∀ᶠ n in atTop, c n • (f (a + d n) - f a) ≤ 0
  · exact le_of_tendsto (hf.lim atTop hd hc' hcd) this
  replace hd : Tendsto (fun n => a + d n) atTop (𝓝[s] (a + 0))
  · exact tendsto_nhdsWithin_iff.2 ⟨tendsto_const_nhds.add (tangentConeAt.lim_zero _ hc' hcd), hd⟩
  

Proof state:
case this
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMaxOn f s a
hf : HasFDerivWithinAt f f' s a
y : E
c : ℕ → ℝ
d : ℕ → E
hc : Tendsto c atTop atTop
hcd : Tendsto (fun n => c n • d n) atTop (𝓝 y)
hc' : Tendsto (fun x => ‖c x‖) atTop atTop
hd : Tendsto (fun n => a + d n) atTop (𝓝[s] (a + 0))
⊢ ∀ᶠ (n : ℕ) in atTop, c n • (f (a + d n) - f a) ≤ 0

Next tactic:
rw [add_zero] at hd
/-- If `f` has a local max on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and
`y` belongs to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/
theorem IsLocalMaxOn.hasFDerivWithinAt_nonpos {s : Set E} (h : IsLocalMaxOn f s a)
    (hf : HasFDerivWithinAt f f' s a) {y} (hy : y ∈ posTangentConeAt s a) : f' y ≤ 0 := by
  rcases hy with ⟨c, d, hd, hc, hcd⟩
  have hc' : Tendsto (‖c ·‖) atTop atTop := tendsto_abs_atTop_atTop.comp hc
  suffices : ∀ᶠ n in atTop, c n • (f (a + d n) - f a) ≤ 0
  · exact le_of_tendsto (hf.lim atTop hd hc' hcd) this
  replace hd : Tendsto (fun n => a + d n) atTop (𝓝[s] (a + 0))
  · exact tendsto_nhdsWithin_iff.2 ⟨tendsto_const_nhds.add (tangentConeAt.lim_zero _ hc' hcd), hd⟩
  rw [add_zero] at hd
  

Proof state:
case this
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMaxOn f s a
hf : HasFDerivWithinAt f f' s a
y : E
c : ℕ → ℝ
d : ℕ → E
hc : Tendsto c atTop atTop
hcd : Tendsto (fun n => c n • d n) atTop (𝓝 y)
hc' : Tendsto (fun x => ‖c x‖) atTop atTop
hd : Tendsto (fun n => a + d n) atTop (𝓝[s] a)
⊢ ∀ᶠ (n : ℕ) in atTop, c n • (f (a + d n) - f a) ≤ 0

Next tactic:
filter_upwards [hd.eventually h, hc.eventually_ge_atTop 0] with n hfn hcn
/-- If `f` has a local max on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and
`y` belongs to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/
theorem IsLocalMaxOn.hasFDerivWithinAt_nonpos {s : Set E} (h : IsLocalMaxOn f s a)
    (hf : HasFDerivWithinAt f f' s a) {y} (hy : y ∈ posTangentConeAt s a) : f' y ≤ 0 := by
  rcases hy with ⟨c, d, hd, hc, hcd⟩
  have hc' : Tendsto (‖c ·‖) atTop atTop := tendsto_abs_atTop_atTop.comp hc
  suffices : ∀ᶠ n in atTop, c n • (f (a + d n) - f a) ≤ 0
  · exact le_of_tendsto (hf.lim atTop hd hc' hcd) this
  replace hd : Tendsto (fun n => a + d n) atTop (𝓝[s] (a + 0))
  · exact tendsto_nhdsWithin_iff.2 ⟨tendsto_const_nhds.add (tangentConeAt.lim_zero _ hc' hcd), hd⟩
  rw [add_zero] at hd
  filter_upwards [hd.eventually h, hc.eventually_ge_atTop 0] with n hfn hcn
  

Proof state:
case h
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMaxOn f s a
hf : HasFDerivWithinAt f f' s a
y : E
c : ℕ → ℝ
d : ℕ → E
hc : Tendsto c atTop atTop
hcd : Tendsto (fun n => c n • d n) atTop (𝓝 y)
hc' : Tendsto (fun x => ‖c x‖) atTop atTop
hd : Tendsto (fun n => a + d n) atTop (𝓝[s] a)
n : ℕ
hfn : f (a + d n) ≤ f a
hcn : 0 ≤ c n
⊢ c n • (f (a + d n) - f a) ≤ 0

Next tactic:
exact mul_nonpos_of_nonneg_of_nonpos hcn (sub_nonpos.2 hfn)
/-- If `f` has a local max on `s` at `a` and `y` belongs to the positive tangent cone
of `s` at `a`, then `f' y ≤ 0`. -/
theorem IsLocalMaxOn.fderivWithin_nonpos {s : Set E} (h : IsLocalMaxOn f s a) {y}
    (hy : y ∈ posTangentConeAt s a) : (fderivWithin ℝ f s a : E → ℝ) y ≤ 0 :=
  if hf : DifferentiableWithinAt ℝ f s a then h.hasFDerivWithinAt_nonpos hf.hasFDerivWithinAt hy
  else by 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMaxOn f s a
y : E
hy : y ∈ posTangentConeAt s a
hf : ¬DifferentiableWithinAt ℝ f s a
⊢ (fderivWithin ℝ f s a) y ≤ 0

Next tactic:
rw [fderivWithin_zero_of_not_differentiableWithinAt hf]
/-- If `f` has a local max on `s` at `a` and `y` belongs to the positive tangent cone
of `s` at `a`, then `f' y ≤ 0`. -/
theorem IsLocalMaxOn.fderivWithin_nonpos {s : Set E} (h : IsLocalMaxOn f s a) {y}
    (hy : y ∈ posTangentConeAt s a) : (fderivWithin ℝ f s a : E → ℝ) y ≤ 0 :=
  if hf : DifferentiableWithinAt ℝ f s a then h.hasFDerivWithinAt_nonpos hf.hasFDerivWithinAt hy
  else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMaxOn f s a
y : E
hy : y ∈ posTangentConeAt s a
hf : ¬DifferentiableWithinAt ℝ f s a
⊢ 0 y ≤ 0

Next tactic:
rfl
/-- If `f` has a local max on `s` at `a`, `f'` is a derivative of `f` at `a` within `s`, and
both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/
theorem IsLocalMaxOn.hasFDerivWithinAt_eq_zero {s : Set E} (h : IsLocalMaxOn f s a)
    (hf : HasFDerivWithinAt f f' s a) {y} (hy : y ∈ posTangentConeAt s a)
    (hy' : -y ∈ posTangentConeAt s a) : f' y = 0 :=
  le_antisymm (h.hasFDerivWithinAt_nonpos hf hy) <| by 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMaxOn f s a
hf : HasFDerivWithinAt f f' s a
y : E
hy : y ∈ posTangentConeAt s a
hy' : -y ∈ posTangentConeAt s a
⊢ 0 ≤ f' y

Next tactic:
simpa using h.hasFDerivWithinAt_nonpos hf hy'
/-- If `f` has a local max on `s` at `a` and both `y` and `-y` belong to the positive tangent cone
of `s` at `a`, then `f' y = 0`. -/
theorem IsLocalMaxOn.fderivWithin_eq_zero {s : Set E} (h : IsLocalMaxOn f s a) {y}
    (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) :
    (fderivWithin ℝ f s a : E → ℝ) y = 0 :=
  if hf : DifferentiableWithinAt ℝ f s a then
    h.hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt hy hy'
  else by 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMaxOn f s a
y : E
hy : y ∈ posTangentConeAt s a
hy' : -y ∈ posTangentConeAt s a
hf : ¬DifferentiableWithinAt ℝ f s a
⊢ (fderivWithin ℝ f s a) y = 0

Next tactic:
rw [fderivWithin_zero_of_not_differentiableWithinAt hf]
/-- If `f` has a local max on `s` at `a` and both `y` and `-y` belong to the positive tangent cone
of `s` at `a`, then `f' y = 0`. -/
theorem IsLocalMaxOn.fderivWithin_eq_zero {s : Set E} (h : IsLocalMaxOn f s a) {y}
    (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) :
    (fderivWithin ℝ f s a : E → ℝ) y = 0 :=
  if hf : DifferentiableWithinAt ℝ f s a then
    h.hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt hy hy'
  else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMaxOn f s a
y : E
hy : y ∈ posTangentConeAt s a
hy' : -y ∈ posTangentConeAt s a
hf : ¬DifferentiableWithinAt ℝ f s a
⊢ 0 y = 0

Next tactic:
rfl
/-- If `f` has a local min on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and
`y` belongs to the positive tangent cone of `s` at `a`, then `0 ≤ f' y`. -/
theorem IsLocalMinOn.hasFDerivWithinAt_nonneg {s : Set E} (h : IsLocalMinOn f s a)
    (hf : HasFDerivWithinAt f f' s a) {y} (hy : y ∈ posTangentConeAt s a) : 0 ≤ f' y := by
  

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMinOn f s a
hf : HasFDerivWithinAt f f' s a
y : E
hy : y ∈ posTangentConeAt s a
⊢ 0 ≤ f' y

Next tactic:
simpa using h.neg.hasFDerivWithinAt_nonpos hf.neg hy
/-- If `f` has a local min on `s` at `a` and `y` belongs to the positive tangent cone
of `s` at `a`, then `0 ≤ f' y`. -/
theorem IsLocalMinOn.fderivWithin_nonneg {s : Set E} (h : IsLocalMinOn f s a) {y}
    (hy : y ∈ posTangentConeAt s a) : (0 : ℝ) ≤ (fderivWithin ℝ f s a : E → ℝ) y :=
  if hf : DifferentiableWithinAt ℝ f s a then h.hasFDerivWithinAt_nonneg hf.hasFDerivWithinAt hy
  else by 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMinOn f s a
y : E
hy : y ∈ posTangentConeAt s a
hf : ¬DifferentiableWithinAt ℝ f s a
⊢ 0 ≤ (fderivWithin ℝ f s a) y

Next tactic:
rw [fderivWithin_zero_of_not_differentiableWithinAt hf]
/-- If `f` has a local min on `s` at `a` and `y` belongs to the positive tangent cone
of `s` at `a`, then `0 ≤ f' y`. -/
theorem IsLocalMinOn.fderivWithin_nonneg {s : Set E} (h : IsLocalMinOn f s a) {y}
    (hy : y ∈ posTangentConeAt s a) : (0 : ℝ) ≤ (fderivWithin ℝ f s a : E → ℝ) y :=
  if hf : DifferentiableWithinAt ℝ f s a then h.hasFDerivWithinAt_nonneg hf.hasFDerivWithinAt hy
  else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMinOn f s a
y : E
hy : y ∈ posTangentConeAt s a
hf : ¬DifferentiableWithinAt ℝ f s a
⊢ 0 ≤ 0 y

Next tactic:
rfl
/-- If `f` has a local max on `s` at `a`, `f'` is a derivative of `f` at `a` within `s`, and
both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/
theorem IsLocalMinOn.hasFDerivWithinAt_eq_zero {s : Set E} (h : IsLocalMinOn f s a)
    (hf : HasFDerivWithinAt f f' s a) {y} (hy : y ∈ posTangentConeAt s a)
    (hy' : -y ∈ posTangentConeAt s a) : f' y = 0 := by
  

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMinOn f s a
hf : HasFDerivWithinAt f f' s a
y : E
hy : y ∈ posTangentConeAt s a
hy' : -y ∈ posTangentConeAt s a
⊢ f' y = 0

Next tactic:
simpa using h.neg.hasFDerivWithinAt_eq_zero hf.neg hy hy'
/-- If `f` has a local min on `s` at `a` and both `y` and `-y` belong to the positive tangent cone
of `s` at `a`, then `f' y = 0`. -/
theorem IsLocalMinOn.fderivWithin_eq_zero {s : Set E} (h : IsLocalMinOn f s a) {y}
    (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) :
    (fderivWithin ℝ f s a : E → ℝ) y = 0 :=
  if hf : DifferentiableWithinAt ℝ f s a then
    h.hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt hy hy'
  else by 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMinOn f s a
y : E
hy : y ∈ posTangentConeAt s a
hy' : -y ∈ posTangentConeAt s a
hf : ¬DifferentiableWithinAt ℝ f s a
⊢ (fderivWithin ℝ f s a) y = 0

Next tactic:
rw [fderivWithin_zero_of_not_differentiableWithinAt hf]
/-- If `f` has a local min on `s` at `a` and both `y` and `-y` belong to the positive tangent cone
of `s` at `a`, then `f' y = 0`. -/
theorem IsLocalMinOn.fderivWithin_eq_zero {s : Set E} (h : IsLocalMinOn f s a) {y}
    (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) :
    (fderivWithin ℝ f s a : E → ℝ) y = 0 :=
  if hf : DifferentiableWithinAt ℝ f s a then
    h.hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt hy hy'
  else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; 

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
s : Set E
h : IsLocalMinOn f s a
y : E
hy : y ∈ posTangentConeAt s a
hy' : -y ∈ posTangentConeAt s a
hf : ¬DifferentiableWithinAt ℝ f s a
⊢ 0 y = 0

Next tactic:
rfl
/-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/
theorem IsLocalMin.hasFDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasFDerivAt f f' a) : f' = 0 := by
  

Proof state:
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
h : IsLocalMin f a
hf : HasFDerivAt f f' a
⊢ f' = 0

Next tactic:
ext y
/-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/
theorem IsLocalMin.hasFDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasFDerivAt f f' a) : f' = 0 := by
  ext y
  

Proof state:
case h
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
h : IsLocalMin f a
hf : HasFDerivAt f f' a
y : E
⊢ f' y = 0 y

Next tactic:
apply (h.on univ).hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt
/-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/
theorem IsLocalMin.hasFDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasFDerivAt f f' a) : f' = 0 := by
  ext y
  apply (h.on univ).hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt <;>
      

Proof state:
case h.hy
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
h : IsLocalMin f a
hf : HasFDerivAt f f' a
y : E
⊢ y ∈ posTangentConeAt univ a

Next tactic:
rw [posTangentConeAt_univ]
/-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/
theorem IsLocalMin.hasFDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasFDerivAt f f' a) : f' = 0 := by
  ext y
  apply (h.on univ).hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt <;>
      

Proof state:
case h.hy'
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
h : IsLocalMin f a
hf : HasFDerivAt f f' a
y : E
⊢ -y ∈ posTangentConeAt univ a

Next tactic:
rw [posTangentConeAt_univ]
/-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/
theorem IsLocalMin.hasFDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasFDerivAt f f' a) : f' = 0 := by
  ext y
  apply (h.on univ).hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt <;>
      rw [posTangentConeAt_univ] <;>
    

Proof state:
case h.hy
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
h : IsLocalMin f a
hf : HasFDerivAt f f' a
y : E
⊢ y ∈ univ

Next tactic:
apply mem_univ
/-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/
theorem IsLocalMin.hasFDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasFDerivAt f f' a) : f' = 0 := by
  ext y
  apply (h.on univ).hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt <;>
      rw [posTangentConeAt_univ] <;>
    

Proof state:
case h.hy'
E : Type u
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : E → ℝ
a : E
f' : E →L[ℝ] ℝ
h : IsLocalMin f a
hf : HasFDerivAt f f' a
y : E
⊢ -y ∈ univ

Next tactic:
apply mem_univ
/-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/
theorem IsLocalMin.hasDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasDerivAt f f' a) : f' = 0 := by
  

Proof state:
f : ℝ → ℝ
f' a b : ℝ
h : IsLocalMin f a
hf : HasDerivAt f f' a
⊢ f' = 0

Next tactic:
simpa using FunLike.congr_fun (h.hasFDerivAt_eq_zero (hasDerivAt_iff_hasFDerivAt.1 hf)) 1
instance [DecidableEq α] [Fintype α] {n : ℕ} : Fintype (Sym.Sym' α n) := by
  

Proof state:
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Fintype α
n : ℕ
⊢ Fintype (Sym.Sym' α n)

Next tactic:
refine @Quotient.fintype _ _ _ ?_
instance [DecidableEq α] [Fintype α] {n : ℕ} : Fintype (Sym.Sym' α n) := by
  refine @Quotient.fintype _ _ _ ?_
  -- Porting note: had to build the instance manually
  

Proof state:
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Fintype α
n : ℕ
⊢ DecidableRel fun x x_1 => x ≈ x_1

Next tactic:
intros x y
instance [DecidableEq α] [Fintype α] {n : ℕ} : Fintype (Sym.Sym' α n) := by
  refine @Quotient.fintype _ _ _ ?_
  -- Porting note: had to build the instance manually
  intros x y
  

Proof state:
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Fintype α
n : ℕ
x y : Vector α n
⊢ Decidable ((fun x x_1 => x ≈ x_1) x y)

Next tactic:
apply List.decidablePerm
lemma hInv_hInv (h : CatCommSq T.functor L R B.functor) :
    hInv T.symm R L B.symm (hInv T L R B h) = h := by
  

Proof state:
C₁ : Type u_1
C₂ : Type u_2
C₃ : Type u_3
C₄ : Type u_4
C₅ : Type u_5
C₆ : Type u_6
inst✝⁵ : Category.{u_8, u_1} C₁
inst✝⁴ : Category.{u_9, u_2} C₂
inst✝³ : Category.{u_10, u_3} C₃
inst✝² : Category.{u_7, u_4} C₄
inst✝¹ : Category.{?u.18271, u_5} C₅
inst✝ : Category.{?u.18275, u_6} C₆
T✝ : C₁ ⥤ C₂
L✝ : C₁ ⥤ C₃
R✝ : C₂ ⥤ C₄
B✝ : C₃ ⥤ C₄
T : C₁ ≌ C₂
L : C₁ ⥤ C₃
R : C₂ ⥤ C₄
B : C₃ ≌ C₄
h : CatCommSq T.functor L R B.functor
⊢ hInv T.symm R L B.symm (hInv T L R B h) = h

Next tactic:
ext X
lemma hInv_hInv (h : CatCommSq T.functor L R B.functor) :
    hInv T.symm R L B.symm (hInv T L R B h) = h := by
  ext X
  

Proof state:
case iso'.w.w.h
C₁ : Type u_1
C₂ : Type u_2
C₃ : Type u_3
C₄ : Type u_4
C₅ : Type u_5
C₆ : Type u_6
inst✝⁵ : Category.{u_8, u_1} C₁
inst✝⁴ : Category.{u_9, u_2} C₂
inst✝³ : Category.{u_10, u_3} C₃
inst✝² : Category.{u_7, u_4} C₄
inst✝¹ : Category.{?u.18271, u_5} C₅
inst✝ : Category.{?u.18275, u_6} C₆
T✝ : C₁ ⥤ C₂
L✝ : C₁ ⥤ C₃
R✝ : C₂ ⥤ C₄
B✝ : C₃ ⥤ C₄
T : C₁ ≌ C₂
L : C₁ ⥤ C₃
R : C₂ ⥤ C₄
B : C₃ ≌ C₄
h : CatCommSq T.functor L R B.functor
X : C₁
⊢ iso'.hom.app X = iso'.hom.app X

Next tactic:
erw [← cancel_mono (B.functor.map (L.map (T.unitIso.hom.app X))),
    ← h.iso'.hom.naturality (T.unitIso.hom.app X), hInv_iso'_hom_app, hInv_iso'_inv_app]
lemma hInv_hInv (h : CatCommSq T.functor L R B.functor) :
    hInv T.symm R L B.symm (hInv T L R B h) = h := by
  ext X
  erw [← cancel_mono (B.functor.map (L.map (T.unitIso.hom.app X))),
    ← h.iso'.hom.naturality (T.unitIso.hom.app X), hInv_iso'_hom_app, hInv_iso'_inv_app]
  

Proof state:
case iso'.w.w.h
C₁ : Type u_1
C₂ : Type u_2
C₃ : Type u_3
C₄ : Type u_4
C₅ : Type u_5
C₆ : Type u_6
inst✝⁵ : Category.{u_8, u_1} C₁
inst✝⁴ : Category.{u_9, u_2} C₂
inst✝³ : Category.{u_10, u_3} C₃
inst✝² : Category.{u_7, u_4} C₄
inst✝¹ : Category.{?u.18271, u_5} C₅
inst✝ : Category.{?u.18275, u_6} C₆
T✝ : C₁ ⥤ C₂
L✝ : C₁ ⥤ C₃
R✝ : C₂ ⥤ C₄
B✝ : C₃ ⥤ C₄
T : C₁ ≌ C₂
L : C₁ ⥤ C₃
R : C₂ ⥤ C₄
B : C₃ ≌ C₄
h : CatCommSq T.functor L R B.functor
X : C₁
⊢ (B.symm.unitIso.hom.app (R.obj (T.symm.inverse.obj X)) ≫
        B.symm.inverse.map
            (B.inverse.map (R.map (T.counitIso.inv.app (T.symm.inverse.obj X))) ≫
              B.inverse.map ((iso T.functor L R B.functor).hom.app (T.inverse.obj (T.symm.inverse.obj X))) ≫
                B.unitIso.inv.app (L.obj (T.inverse.obj (T.symm.inverse.obj X)))) ≫
          B.symm.inverse.map (L.map (T.symm.counitIso.hom.app X))) ≫
      B.functor.map (L.map (T.unitIso.hom.app X)) =
    (T.functor ⋙ R).map (T.unitIso.hom.app X) ≫ iso'.hom.app ((T.functor ⋙ T.inverse).obj X)

Next tactic:
dsimp
lemma hInv_hInv (h : CatCommSq T.functor L R B.functor) :
    hInv T.symm R L B.symm (hInv T L R B h) = h := by
  ext X
  erw [← cancel_mono (B.functor.map (L.map (T.unitIso.hom.app X))),
    ← h.iso'.hom.naturality (T.unitIso.hom.app X), hInv_iso'_hom_app, hInv_iso'_inv_app]
  dsimp
  

Proof state:
case iso'.w.w.h
C₁ : Type u_1
C₂ : Type u_2
C₃ : Type u_3
C₄ : Type u_4
C₅ : Type u_5
C₆ : Type u_6
inst✝⁵ : Category.{u_8, u_1} C₁
inst✝⁴ : Category.{u_9, u_2} C₂
inst✝³ : Category.{u_10, u_3} C₃
inst✝² : Category.{u_7, u_4} C₄
inst✝¹ : Category.{?u.18271, u_5} C₅
inst✝ : Category.{?u.18275, u_6} C₆
T✝ : C₁ ⥤ C₂
L✝ : C₁ ⥤ C₃
R✝ : C₂ ⥤ C₄
B✝ : C₃ ⥤ C₄
T : C₁ ≌ C₂
L : C₁ ⥤ C₃
R : C₂ ⥤ C₄
B : C₃ ≌ C₄
h : CatCommSq T.functor L R B.functor
X : C₁
⊢ (B.counitIso.inv.app (R.obj (T.functor.obj X)) ≫
        B.functor.map
            (B.inverse.map (R.map (T.counitIso.inv.app (T.functor.obj X))) ≫
              B.inverse.map ((iso T.functor L R B.functor).hom.app (T.inverse.obj (T.functor.obj X))) ≫
                B.unitIso.inv.app (L.obj (T.inverse.obj (T.functor.obj X)))) ≫
          B.functor.map (L.map (T.unitIso.inv.app X))) ≫
      B.functor.map (L.map (T.unitIso.hom.app X)) =
    R.map (T.functor.map (T.unitIso.hom.app X)) ≫ iso'.hom.app (T.inverse.obj (T.functor.obj X))

Next tactic:
simp only [Functor.comp_obj, assoc, ← Functor.map_comp, Iso.inv_hom_id_app,
    Equivalence.counitInv_app_functor, Functor.map_id]
lemma hInv_hInv (h : CatCommSq T.functor L R B.functor) :
    hInv T.symm R L B.symm (hInv T L R B h) = h := by
  ext X
  erw [← cancel_mono (B.functor.map (L.map (T.unitIso.hom.app X))),
    ← h.iso'.hom.naturality (T.unitIso.hom.app X), hInv_iso'_hom_app, hInv_iso'_inv_app]
  dsimp
  simp only [Functor.comp_obj, assoc, ← Functor.map_comp, Iso.inv_hom_id_app,
    Equivalence.counitInv_app_functor, Functor.map_id]
  

Proof state:
case iso'.w.w.h
C₁ : Type u_1
C₂ : Type u_2
C₃ : Type u_3
C₄ : Type u_4
C₅ : Type u_5
C₆ : Type u_6
inst✝⁵ : Category.{u_8, u_1} C₁
inst✝⁴ : Category.{u_9, u_2} C₂
inst✝³ : Category.{u_10, u_3} C₃
inst✝² : Category.{u_7, u_4} C₄
inst✝¹ : Category.{?u.18271, u_5} C₅
inst✝ : Category.{?u.18275, u_6} C₆
T✝ : C₁ ⥤ C₂
L✝ : C₁ ⥤ C₃
R✝ : C₂ ⥤ C₄
B✝ : C₃ ⥤ C₄
T : C₁ ≌ C₂
L : C₁ ⥤ C₃
R : C₂ ⥤ C₄
B : C₃ ≌ C₄
h : CatCommSq T.functor L R B.functor
X : C₁
⊢ B.counitIso.inv.app (R.obj (T.functor.obj X)) ≫
      B.functor.map
        (B.inverse.map (R.map (T.functor.map (T.unit.app X))) ≫
          B.inverse.map ((iso T.functor L R B.functor).hom.app (T.inverse.obj (T.functor.obj X))) ≫
            B.unitIso.inv.app (L.obj (T.inverse.obj (T.functor.obj X))) ≫ 𝟙 (L.obj (T.inverse.obj (T.functor.obj X)))) =
    R.map (T.functor.map (T.unitIso.hom.app X)) ≫ iso'.hom.app (T.inverse.obj (T.functor.obj X))

Next tactic:
simp only [Functor.map_comp, Equivalence.fun_inv_map, assoc,
    Equivalence.counitInv_functor_comp, comp_id, Iso.inv_hom_id_app_assoc]
lemma hInv_hInv (h : CatCommSq T.functor L R B.functor) :
    hInv T.symm R L B.symm (hInv T L R B h) = h := by
  ext X
  erw [← cancel_mono (B.functor.map (L.map (T.unitIso.hom.app X))),
    ← h.iso'.hom.naturality (T.unitIso.hom.app X), hInv_iso'_hom_app, hInv_iso'_inv_app]
  dsimp
  simp only [Functor.comp_obj, assoc, ← Functor.map_comp, Iso.inv_hom_id_app,
    Equivalence.counitInv_app_functor, Functor.map_id]
  simp only [Functor.map_comp, Equivalence.fun_inv_map, assoc,
    Equivalence.counitInv_functor_comp, comp_id, Iso.inv_hom_id_app_assoc]
  

Proof state:
case iso'.w.w.h
C₁ : Type u_1
C₂ : Type u_2
C₃ : Type u_3
C₄ : Type u_4
C₅ : Type u_5
C₆ : Type u_6
inst✝⁵ : Category.{u_8, u_1} C₁
inst✝⁴ : Category.{u_9, u_2} C₂
inst✝³ : Category.{u_10, u_3} C₃
inst✝² : Category.{u_7, u_4} C₄
inst✝¹ : Category.{?u.18271, u_5} C₅
inst✝ : Category.{?u.18275, u_6} C₆
T✝ : C₁ ⥤ C₂
L✝ : C₁ ⥤ C₃
R✝ : C₂ ⥤ C₄
B✝ : C₃ ⥤ C₄
T : C₁ ≌ C₂
L : C₁ ⥤ C₃
R : C₂ ⥤ C₄
B : C₃ ≌ C₄
h : CatCommSq T.functor L R B.functor
X : C₁
⊢ R.map (T.functor.map (T.unit.app X)) ≫ (iso T.functor L R B.functor).hom.app (T.inverse.obj (T.functor.obj X)) =
    R.map (T.functor.map (T.unitIso.hom.app X)) ≫ iso'.hom.app (T.inverse.obj (T.functor.obj X))

Next tactic:
rfl
instance linearOrderedAddCommGroupWithTop : LinearOrderedAddCommGroupWithTop (WithTop α) where
  __ := WithTop.linearOrderedAddCommMonoidWithTop
  __ := Option.nontrivial
  neg := Option.map fun a : α => -a
  neg_top := Option.map_none
  add_neg_cancel := by
    

Proof state:
α : Type u_1
inst✝ : LinearOrderedAddCommGroup α
a b c d : α
src✝¹ : LinearOrderedAddCommMonoidWithTop (WithTop α) := linearOrderedAddCommMonoidWithTop
src✝ : Nontrivial (Option α) := Option.nontrivial
⊢ ∀ (a : WithTop α), a ≠ ⊤ → a + -a = 0

Next tactic:
rintro (a | a) ha
instance linearOrderedAddCommGroupWithTop : LinearOrderedAddCommGroupWithTop (WithTop α) where
  __ := WithTop.linearOrderedAddCommMonoidWithTop
  __ := Option.nontrivial
  neg := Option.map fun a : α => -a
  neg_top := Option.map_none
  add_neg_cancel := by
    rintro (a | a) ha
    · 

Proof state:
case none
α : Type u_1
inst✝ : LinearOrderedAddCommGroup α
a b c d : α
src✝¹ : LinearOrderedAddCommMonoidWithTop (WithTop α) := linearOrderedAddCommMonoidWithTop
src✝ : Nontrivial (Option α) := Option.nontrivial
ha : none ≠ ⊤
⊢ none + -none = 0

Next tactic:
exact (ha rfl).elim