l3lab/ntp-mathlib huggingface dataset:
/-- If there exists a morphism `a → b` in a free groupoid, then there also exists a zigzag
from `a` to `b` in the generating quiver. -/
theorem path_nonempty_of_hom {G} [Groupoid.{u, u} G] [IsFreeGroupoid G] {a b : G} :
    Nonempty (a ⟶ b) → Nonempty (Path (symgen a) (symgen b)) := by
  rintro ⟨p⟩
  rw [← @WeaklyConnectedComponent.eq (Generators G), eq_comm, ← FreeGroup.of_injective.eq_iff, ←
    mul_inv_eq_one]
  let X := FreeGroup (WeaklyConnectedComponent <| Generators G)
  let f : G → X := fun g => FreeGroup.of (WeaklyConnectedComponent.mk g)
  let F : G ⥤ CategoryTheory.SingleObj.{u} (X : Type u) := SingleObj.differenceFunctor f
  change (F.map p) = ((@CategoryTheory.Functor.const G _ _ (SingleObj.category X)).obj ()).map p
  congr; ext
  rw [Functor.const_obj_map, id_as_one, differenceFunctor_map, @mul_inv_eq_one _ _ (f _)]
  apply congr_arg FreeGroup.of
  apply (WeaklyConnectedComponent.eq _ _).mpr
  exact ⟨Hom.toPath (Sum.inr (by 

Proof state:
G : Type u
inst✝¹ : Groupoid G
inst✝ : IsFreeGroupoid G
a b : G
p : a ⟶ b
X : Type u := FreeGroup (WeaklyConnectedComponent (Generators G))
f : G → X := fun g => FreeGroup.of (WeaklyConnectedComponent.mk g)
F : G ⥤ CategoryTheory.SingleObj X := differenceFunctor f
a✝ b✝ : Generators G
e✝ : a✝ ⟶ b✝
⊢ (let_fun this := a✝;
    this) ⟶
    b✝

Next tactic:
assumption
theorem lowerSemicontinuousWithinAt_univ_iff :
    LowerSemicontinuousWithinAt f univ x ↔ LowerSemicontinuousAt f x := by
  

Proof state:
α : Type u_1
inst✝¹ : TopologicalSpace α
β : Type u_2
inst✝ : Preorder β
f g : α → β
x : α
s t : Set α
y z : β
⊢ LowerSemicontinuousWithinAt f univ x ↔ LowerSemicontinuousAt f x

Next tactic:
simp [LowerSemicontinuousWithinAt, LowerSemicontinuousAt, nhdsWithin_univ]
theorem lowerSemicontinuousOn_univ_iff : LowerSemicontinuousOn f univ ↔ LowerSemicontinuous f := by
  

Proof state:
α : Type u_1
inst✝¹ : TopologicalSpace α
β : Type u_2
inst✝ : Preorder β
f g : α → β
x : α
s t : Set α
y z : β
⊢ LowerSemicontinuousOn f univ ↔ LowerSemicontinuous f

Next tactic:
simp [LowerSemicontinuousOn, LowerSemicontinuous, lowerSemicontinuousWithinAt_univ_iff]
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  

Proof state:
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x : α
s t : Set α
y z : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
⊢ LowerSemicontinuous (indicator s fun _x => y)

Next tactic:
intro x z hz
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  

Proof state:
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
hz : z < indicator s (fun _x => y) x
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
by_cases h : x ∈ s
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> 

Proof state:
case pos
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
hz : z < indicator s (fun _x => y) x
h : x ∈ s
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
simp [h] at hz
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> 

Proof state:
case neg
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
hz : z < indicator s (fun _x => y) x
h : x ∉ s
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
simp [h] at hz
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · 

Proof state:
case pos
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
h : x ∈ s
hz : z < y
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
filter_upwards [hs.mem_nhds h]
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · filter_upwards [hs.mem_nhds h]
    

Proof state:
case h
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
h : x ∈ s
hz : z < y
⊢ ∀ a ∈ s, z < indicator s (fun _x => y) a

Next tactic:
simp (config := { contextual := true }) [hz]
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · filter_upwards [hs.mem_nhds h]
    simp (config := { contextual := true }) [hz]
  · 

Proof state:
case neg
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
h : x ∉ s
hz : z < 0
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
refine Filter.eventually_of_forall fun x' => ?_
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · filter_upwards [hs.mem_nhds h]
    simp (config := { contextual := true }) [hz]
  · refine Filter.eventually_of_forall fun x' => ?_
    

Proof state:
case neg
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
h : x ∉ s
hz : z < 0
x' : α
⊢ z < indicator s (fun _x => y) x'

Next tactic:
by_cases h' : x' ∈ s
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · filter_upwards [hs.mem_nhds h]
    simp (config := { contextual := true }) [hz]
  · refine Filter.eventually_of_forall fun x' => ?_
    by_cases h' : x' ∈ s <;> 

Proof state:
case pos
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
h : x ∉ s
hz : z < 0
x' : α
h' : x' ∈ s
⊢ z < indicator s (fun _x => y) x'

Next tactic:
simp [h', hz.trans_le hy, hz]
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · filter_upwards [hs.mem_nhds h]
    simp (config := { contextual := true }) [hz]
  · refine Filter.eventually_of_forall fun x' => ?_
    by_cases h' : x' ∈ s <;> 

Proof state:
case neg
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsOpen s
hy : 0 ≤ y
x : α
z : β
h : x ∉ s
hz : z < 0
x' : α
h' : x' ∉ s
⊢ z < indicator s (fun _x => y) x'

Next tactic:
simp [h', hz.trans_le hy, hz]
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  

Proof state:
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x : α
s t : Set α
y z : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
⊢ LowerSemicontinuous (indicator s fun _x => y)

Next tactic:
intro x z hz
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  

Proof state:
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
hz : z < indicator s (fun _x => y) x
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
by_cases h : x ∈ s
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> 

Proof state:
case pos
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
hz : z < indicator s (fun _x => y) x
h : x ∈ s
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
simp [h] at hz
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> 

Proof state:
case neg
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
hz : z < indicator s (fun _x => y) x
h : x ∉ s
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
simp [h] at hz
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · 

Proof state:
case pos
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
h : x ∈ s
hz : z < y
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
refine Filter.eventually_of_forall fun x' => ?_
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · refine Filter.eventually_of_forall fun x' => ?_
    

Proof state:
case pos
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
h : x ∈ s
hz : z < y
x' : α
⊢ z < indicator s (fun _x => y) x'

Next tactic:
by_cases h' : x' ∈ s
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · refine Filter.eventually_of_forall fun x' => ?_
    by_cases h' : x' ∈ s <;> 

Proof state:
case pos
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
h : x ∈ s
hz : z < y
x' : α
h' : x' ∈ s
⊢ z < indicator s (fun _x => y) x'

Next tactic:
simp [h', hz, hz.trans_le hy]
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · refine Filter.eventually_of_forall fun x' => ?_
    by_cases h' : x' ∈ s <;> 

Proof state:
case neg
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
h : x ∈ s
hz : z < y
x' : α
h' : x' ∉ s
⊢ z < indicator s (fun _x => y) x'

Next tactic:
simp [h', hz, hz.trans_le hy]
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · refine Filter.eventually_of_forall fun x' => ?_
    by_cases h' : x' ∈ s <;> simp [h', hz, hz.trans_le hy]
  · 

Proof state:
case neg
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
h : x ∉ s
hz : z < 0
⊢ ∀ᶠ (x' : α) in 𝓝 x, z < indicator s (fun _x => y) x'

Next tactic:
filter_upwards [hs.isOpen_compl.mem_nhds h]
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
    LowerSemicontinuous (indicator s fun _x => y) := by
  intro x z hz
  by_cases h : x ∈ s <;> simp [h] at hz
  · refine Filter.eventually_of_forall fun x' => ?_
    by_cases h' : x' ∈ s <;> simp [h', hz, hz.trans_le hy]
  · filter_upwards [hs.isOpen_compl.mem_nhds h]
    

Proof state:
case h
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f g : α → β
x✝ : α
s t : Set α
y z✝ : β
inst✝ : Zero β
hs : IsClosed s
hy : y ≤ 0
x : α
z : β
h : x ∉ s
hz : z < 0
⊢ ∀ a ∈ sᶜ, z < indicator s (fun _x => y) a

Next tactic:
simp (config := { contextual := true }) [hz]
theorem lowerSemicontinuous_iff_isClosed_preimage {f : α → γ} :
    LowerSemicontinuous f ↔ ∀ y, IsClosed (f ⁻¹' Iic y) := by
  

Proof state:
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f✝ g : α → β
x : α
s t : Set α
y z : β
γ : Type u_3
inst✝ : LinearOrder γ
f : α → γ
⊢ LowerSemicontinuous f ↔ ∀ (y : γ), IsClosed (f ⁻¹' Iic y)

Next tactic:
rw [lowerSemicontinuous_iff_isOpen_preimage]
theorem lowerSemicontinuous_iff_isClosed_preimage {f : α → γ} :
    LowerSemicontinuous f ↔ ∀ y, IsClosed (f ⁻¹' Iic y) := by
  rw [lowerSemicontinuous_iff_isOpen_preimage]
  

Proof state:
α : Type u_1
inst✝² : TopologicalSpace α
β : Type u_2
inst✝¹ : Preorder β
f✝ g : α → β
x : α
s t : Set α
y z : β
γ : Type u_3
inst✝ : LinearOrder γ
f : α → γ
⊢ (∀ (y : γ), IsOpen (f ⁻¹' Ioi y)) ↔ ∀ (y : γ), IsClosed (f ⁻¹' Iic y)

Next tactic:
simp only [← isOpen_compl_iff, ← preimage_compl, compl_Iic]
theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ}
    (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) :
    LowerSemicontinuousWithinAt (g ∘ f) s x := by
  

Proof state:
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y z : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousWithinAt f s x
gmon : Monotone g
⊢ LowerSemicontinuousWithinAt (g ∘ f) s x

Next tactic:
intro y hy
theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ}
    (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) :
    LowerSemicontinuousWithinAt (g ∘ f) s x := by
  intro y hy
  

Proof state:
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y✝ z : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousWithinAt f s x
gmon : Monotone g
y : δ
hy : y < (g ∘ f) x
⊢ ∀ᶠ (x' : α) in 𝓝[s] x, y < (g ∘ f) x'

Next tactic:
by_cases h : ∃ l, l < f x
theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ}
    (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) :
    LowerSemicontinuousWithinAt (g ∘ f) s x := by
  intro y hy
  by_cases h : ∃ l, l < f x
  · 

Proof state:
case pos
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y✝ z : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousWithinAt f s x
gmon : Monotone g
y : δ
hy : y < (g ∘ f) x
h : ∃ l, l < f x
⊢ ∀ᶠ (x' : α) in 𝓝[s] x, y < (g ∘ f) x'

Next tactic:
obtain ⟨z, zlt, hz⟩ : ∃ z < f x, Ioc z (f x) ⊆ g ⁻¹' Ioi y :=
      exists_Ioc_subset_of_mem_nhds (hg (Ioi_mem_nhds hy)) h
theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ}
    (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) :
    LowerSemicontinuousWithinAt (g ∘ f) s x := by
  intro y hy
  by_cases h : ∃ l, l < f x
  · obtain ⟨z, zlt, hz⟩ : ∃ z < f x, Ioc z (f x) ⊆ g ⁻¹' Ioi y :=
      exists_Ioc_subset_of_mem_nhds (hg (Ioi_mem_nhds hy)) h
    

Proof state:
case pos.intro.intro
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y✝ z✝ : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousWithinAt f s x
gmon : Monotone g
y : δ
hy : y < (g ∘ f) x
h : ∃ l, l < f x
z : γ
zlt : z < f x
hz : Ioc z (f x) ⊆ g ⁻¹' Ioi y
⊢ ∀ᶠ (x' : α) in 𝓝[s] x, y < (g ∘ f) x'

Next tactic:
filter_upwards [hf z zlt] with a ha
theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ}
    (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) :
    LowerSemicontinuousWithinAt (g ∘ f) s x := by
  intro y hy
  by_cases h : ∃ l, l < f x
  · obtain ⟨z, zlt, hz⟩ : ∃ z < f x, Ioc z (f x) ⊆ g ⁻¹' Ioi y :=
      exists_Ioc_subset_of_mem_nhds (hg (Ioi_mem_nhds hy)) h
    filter_upwards [hf z zlt] with a ha
    

Proof state:
case h
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y✝ z✝ : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousWithinAt f s x
gmon : Monotone g
y : δ
hy : y < (g ∘ f) x
h : ∃ l, l < f x
z : γ
zlt : z < f x
hz : Ioc z (f x) ⊆ g ⁻¹' Ioi y
a : α
ha : z < f a
⊢ y < (g ∘ f) a

Next tactic:
calc
      y < g (min (f x) (f a)) := hz (by simp [zlt, ha, le_refl])
      _ ≤ g (f a) := gmon (min_le_right _ _)
theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ}
    (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) :
    LowerSemicontinuousWithinAt (g ∘ f) s x := by
  intro y hy
  by_cases h : ∃ l, l < f x
  · obtain ⟨z, zlt, hz⟩ : ∃ z < f x, Ioc z (f x) ⊆ g ⁻¹' Ioi y :=
      exists_Ioc_subset_of_mem_nhds (hg (Ioi_mem_nhds hy)) h
    filter_upwards [hf z zlt] with a ha
    calc
      y < g (min (f x) (f a)) := hz (by 

Proof state:
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y✝ z✝ : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousWithinAt f s x
gmon : Monotone g
y : δ
hy : y < (g ∘ f) x
h : ∃ l, l < f x
z : γ
zlt : z < f x
hz : Ioc z (f x) ⊆ g ⁻¹' Ioi y
a : α
ha : z < f a
⊢ min (f x) (f a) ∈ Ioc z (f x)

Next tactic:
simp [zlt, ha, le_refl]
theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ}
    (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) :
    LowerSemicontinuousWithinAt (g ∘ f) s x := by
  intro y hy
  by_cases h : ∃ l, l < f x
  · obtain ⟨z, zlt, hz⟩ : ∃ z < f x, Ioc z (f x) ⊆ g ⁻¹' Ioi y :=
      exists_Ioc_subset_of_mem_nhds (hg (Ioi_mem_nhds hy)) h
    filter_upwards [hf z zlt] with a ha
    calc
      y < g (min (f x) (f a)) := hz (by simp [zlt, ha, le_refl])
      _ ≤ g (f a) := gmon (min_le_right _ _)

  · 

Proof state:
case neg
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y✝ z : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousWithinAt f s x
gmon : Monotone g
y : δ
hy : y < (g ∘ f) x
h : ¬∃ l, l < f x
⊢ ∀ᶠ (x' : α) in 𝓝[s] x, y < (g ∘ f) x'

Next tactic:
simp only [not_exists, not_lt] at h
theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ}
    (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) :
    LowerSemicontinuousWithinAt (g ∘ f) s x := by
  intro y hy
  by_cases h : ∃ l, l < f x
  · obtain ⟨z, zlt, hz⟩ : ∃ z < f x, Ioc z (f x) ⊆ g ⁻¹' Ioi y :=
      exists_Ioc_subset_of_mem_nhds (hg (Ioi_mem_nhds hy)) h
    filter_upwards [hf z zlt] with a ha
    calc
      y < g (min (f x) (f a)) := hz (by simp [zlt, ha, le_refl])
      _ ≤ g (f a) := gmon (min_le_right _ _)

  · simp only [not_exists, not_lt] at h
    

Proof state:
case neg
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y✝ z : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousWithinAt f s x
gmon : Monotone g
y : δ
hy : y < (g ∘ f) x
h : ∀ (x_1 : γ), f x ≤ x_1
⊢ ∀ᶠ (x' : α) in 𝓝[s] x, y < (g ∘ f) x'

Next tactic:
exact Filter.eventually_of_forall fun a => hy.trans_le (gmon (h (f a)))
theorem ContinuousAt.comp_lowerSemicontinuousAt {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x))
    (hf : LowerSemicontinuousAt f x) (gmon : Monotone g) : LowerSemicontinuousAt (g ∘ f) x := by
  

Proof state:
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y z : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
hf : LowerSemicontinuousAt f x
gmon : Monotone g
⊢ LowerSemicontinuousAt (g ∘ f) x

Next tactic:
simp only [← lowerSemicontinuousWithinAt_univ_iff] at hf ⊢
theorem ContinuousAt.comp_lowerSemicontinuousAt {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x))
    (hf : LowerSemicontinuousAt f x) (gmon : Monotone g) : LowerSemicontinuousAt (g ∘ f) x := by
  simp only [← lowerSemicontinuousWithinAt_univ_iff] at hf ⊢
  

Proof state:
α : Type u_1
inst✝⁷ : TopologicalSpace α
β : Type u_2
inst✝⁶ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y z : β
γ : Type u_3
inst✝⁵ : LinearOrder γ
inst✝⁴ : TopologicalSpace γ
inst✝³ : OrderTopology γ
δ : Type u_4
inst✝² : LinearOrder δ
inst✝¹ : TopologicalSpace δ
inst✝ : OrderTopology δ
g : γ → δ
f : α → γ
hg : ContinuousAt g (f x)
gmon : Monotone g
hf : LowerSemicontinuousWithinAt f univ x
⊢ LowerSemicontinuousWithinAt (g ∘ f) univ x

Next tactic:
exact hg.comp_lowerSemicontinuousWithinAt hf gmon
/-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with an
explicit continuity assumption on addition, for application to `EReal`. The unprimed version of
the lemma uses `[ContinuousAdd]`. -/
theorem LowerSemicontinuousWithinAt.add' {f g : α → γ} (hf : LowerSemicontinuousWithinAt f s x)
    (hg : LowerSemicontinuousWithinAt g s x)
    (hcont : ContinuousAt (fun p : γ × γ => p.1 + p.2) (f x, g x)) :
    LowerSemicontinuousWithinAt (fun z => f z + g z) s x := by
  

Proof state:
α : Type u_1
inst✝⁴ : TopologicalSpace α
β : Type u_2
inst✝³ : Preorder β
f✝ g✝ : α → β
x : α
s t : Set α
y z : β
ι : Type u_3
γ : Type u_4
inst✝² : LinearOrderedAddCommMonoid γ
inst✝¹ : TopologicalSpace γ
inst✝ : OrderTopology γ
f g : α → γ
hf : LowerSemicontinuousWithinAt f s x
hg : LowerSemicontinuousWithinAt g s x
hcont : ContinuousAt (fun p => p.1 + p.2) (f x, g x)
⊢ LowerSemicontinuousWithinAt (fun z => f z + g z) s x

Next tactic:
intro y hy