l3lab/ntp-mathlib huggingface dataset:
theorem sum_le_of_monotoneOn_Icc (f : α → E) {s : Set α} {m n : ℕ} {u : ℕ → α}
    (hu : MonotoneOn u (Icc m n)) (us : ∀ i ∈ Icc m n, u i ∈ s) :
    (∑ i in Finset.Ico m n, edist (f (u (i + 1))) (f (u i))) ≤ eVariationOn f s := by
  rcases le_total n m with hnm | hmn
  · simp [Finset.Ico_eq_empty_of_le hnm]
  let π := projIcc m n hmn
  let v i := u (π i)
  calc
    ∑ i in Finset.Ico m n, edist (f (u (i + 1))) (f (u i))
        = ∑ i in Finset.Ico m n, edist (f (v (i + 1))) (f (v i)) :=
      Finset.sum_congr rfl fun i hi ↦ by
        rw [Finset.mem_Ico] at hi
        

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
m n : ℕ
u : ℕ → α
hu : MonotoneOn u (Icc m n)
us : ∀ i ∈ Icc m n, u i ∈ s
hmn : m ≤ n
π : ℕ → ↑(Icc m n) := projIcc m n hmn
v : ℕ → α := fun i => u ↑(π i)
i : ℕ
hi : m ≤ i ∧ i < n
⊢ edist (f (u (i + 1))) (f (u i)) = edist (f (v (i + 1))) (f (v i))

Next tactic:
simp only [projIcc_of_mem hmn ⟨hi.1, hi.2.le⟩,
          projIcc_of_mem hmn ⟨hi.1.trans i.le_succ, hi.2⟩]
theorem sum_le_of_monotoneOn_Iic (f : α → E) {s : Set α} {n : ℕ} {u : ℕ → α}
    (hu : MonotoneOn u (Iic n)) (us : ∀ i ≤ n, u i ∈ s) :
    (∑ i in Finset.range n, edist (f (u (i + 1))) (f (u i))) ≤ eVariationOn f s := by
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
n : ℕ
u : ℕ → α
hu : MonotoneOn u (Iic n)
us : ∀ i ≤ n, u i ∈ s
⊢ ∑ i in Finset.range n, edist (f (u (i + 1))) (f (u i)) ≤ eVariationOn f s

Next tactic:
simpa using sum_le_of_monotoneOn_Icc f (m := 0) (hu.mono Icc_subset_Iic_self) fun i hi ↦ us i hi.2
theorem mono (f : α → E) {s t : Set α} (hst : t ⊆ s) : eVariationOn f t ≤ eVariationOn f s := by
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s t : Set α
hst : t ⊆ s
⊢ eVariationOn f t ≤ eVariationOn f s

Next tactic:
apply iSup_le _
theorem mono (f : α → E) {s t : Set α} (hst : t ⊆ s) : eVariationOn f t ≤ eVariationOn f s := by
  apply iSup_le _
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s t : Set α
hst : t ⊆ s
⊢ ∀ (i : ℕ × { u // Monotone u ∧ ∀ (i : ℕ), u i ∈ t }),
    ∑ i_1 in Finset.range i.1, edist (f (↑i.2 (i_1 + 1))) (f (↑i.2 i_1)) ≤ eVariationOn f s

Next tactic:
rintro ⟨n, ⟨u, hu, ut⟩⟩
theorem mono (f : α → E) {s t : Set α} (hst : t ⊆ s) : eVariationOn f t ≤ eVariationOn f s := by
  apply iSup_le _
  rintro ⟨n, ⟨u, hu, ut⟩⟩
  

Proof state:
case mk.mk.intro
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s t : Set α
hst : t ⊆ s
n : ℕ
u : ℕ → α
hu : Monotone u
ut : ∀ (i : ℕ), u i ∈ t
⊢ ∑ i in Finset.range (n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ t) }).1,
      edist (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ t) }).2 (i + 1)))
        (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ t) }).2 i)) ≤
    eVariationOn f s

Next tactic:
exact sum_le f n hu fun i => hst (ut i)
theorem edist_le (f : α → E) {s : Set α} {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
    edist (f x) (f y) ≤ eVariationOn f s := by
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
x y : α
hx : x ∈ s
hy : y ∈ s
⊢ edist (f x) (f y) ≤ eVariationOn f s

Next tactic:
wlog hxy : y ≤ x generalizing x y
theorem edist_le (f : α → E) {s : Set α} {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
    edist (f x) (f y) ≤ eVariationOn f s := by
  wlog hxy : y ≤ x generalizing x y
  · 

Proof state:
case inr
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
x y : α
hx : x ∈ s
hy : y ∈ s
this : ∀ {x y : α}, x ∈ s → y ∈ s → y ≤ x → edist (f x) (f y) ≤ eVariationOn f s
hxy : ¬y ≤ x
⊢ edist (f x) (f y) ≤ eVariationOn f s

Next tactic:
rw [edist_comm]
theorem edist_le (f : α → E) {s : Set α} {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
    edist (f x) (f y) ≤ eVariationOn f s := by
  wlog hxy : y ≤ x generalizing x y
  · rw [edist_comm]
    

Proof state:
case inr
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
x y : α
hx : x ∈ s
hy : y ∈ s
this : ∀ {x y : α}, x ∈ s → y ∈ s → y ≤ x → edist (f x) (f y) ≤ eVariationOn f s
hxy : ¬y ≤ x
⊢ edist (f y) (f x) ≤ eVariationOn f s

Next tactic:
exact this hy hx (le_of_not_le hxy)
theorem edist_le (f : α → E) {s : Set α} {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
    edist (f x) (f y) ≤ eVariationOn f s := by
  wlog hxy : y ≤ x generalizing x y
  · rw [edist_comm]
    exact this hy hx (le_of_not_le hxy)
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
x y : α
hx : x ∈ s
hy : y ∈ s
hxy : y ≤ x
⊢ edist (f x) (f y) ≤ eVariationOn f s

Next tactic:
let u : ℕ → α := fun n => if n = 0 then y else x
theorem edist_le (f : α → E) {s : Set α} {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
    edist (f x) (f y) ≤ eVariationOn f s := by
  wlog hxy : y ≤ x generalizing x y
  · rw [edist_comm]
    exact this hy hx (le_of_not_le hxy)
  let u : ℕ → α := fun n => if n = 0 then y else x
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
x y : α
hx : x ∈ s
hy : y ∈ s
hxy : y ≤ x
u : ℕ → α := fun n => if n = 0 then y else x
⊢ edist (f x) (f y) ≤ eVariationOn f s

Next tactic:
have hu : Monotone u := monotone_nat_of_le_succ fun
  | 0 => hxy
  | (_ + 1) => le_rfl
theorem edist_le (f : α → E) {s : Set α} {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
    edist (f x) (f y) ≤ eVariationOn f s := by
  wlog hxy : y ≤ x generalizing x y
  · rw [edist_comm]
    exact this hy hx (le_of_not_le hxy)
  let u : ℕ → α := fun n => if n = 0 then y else x
  have hu : Monotone u := monotone_nat_of_le_succ fun
  | 0 => hxy
  | (_ + 1) => le_rfl
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
x y : α
hx : x ∈ s
hy : y ∈ s
hxy : y ≤ x
u : ℕ → α := fun n => if n = 0 then y else x
hu : Monotone u
⊢ edist (f x) (f y) ≤ eVariationOn f s

Next tactic:
have us : ∀ i, u i ∈ s := fun
  | 0 => hy
  | (_ + 1) => hx
theorem edist_le (f : α → E) {s : Set α} {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
    edist (f x) (f y) ≤ eVariationOn f s := by
  wlog hxy : y ≤ x generalizing x y
  · rw [edist_comm]
    exact this hy hx (le_of_not_le hxy)
  let u : ℕ → α := fun n => if n = 0 then y else x
  have hu : Monotone u := monotone_nat_of_le_succ fun
  | 0 => hxy
  | (_ + 1) => le_rfl
  have us : ∀ i, u i ∈ s := fun
  | 0 => hy
  | (_ + 1) => hx
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
x y : α
hx : x ∈ s
hy : y ∈ s
hxy : y ≤ x
u : ℕ → α := fun n => if n = 0 then y else x
hu : Monotone u
us : ∀ (i : ℕ), u i ∈ s
⊢ edist (f x) (f y) ≤ eVariationOn f s

Next tactic:
simpa only [Finset.sum_range_one] using sum_le f 1 hu us
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
⊢ eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0

Next tactic:
constructor
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  constructor
  · 

Proof state:
case mp
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
⊢ eVariationOn f s = 0 → ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0

Next tactic:
rintro h x xs y ys
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  constructor
  · rintro h x xs y ys
    

Proof state:
case mp
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
h : eVariationOn f s = 0
x : α
xs : x ∈ s
y : α
ys : y ∈ s
⊢ edist (f x) (f y) = 0

Next tactic:
rw [← le_zero_iff, ← h]
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  constructor
  · rintro h x xs y ys
    rw [← le_zero_iff, ← h]
    

Proof state:
case mp
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
h : eVariationOn f s = 0
x : α
xs : x ∈ s
y : α
ys : y ∈ s
⊢ edist (f x) (f y) ≤ eVariationOn f s

Next tactic:
exact edist_le f xs ys
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  constructor
  · rintro h x xs y ys
    rw [← le_zero_iff, ← h]
    exact edist_le f xs ys
  · 

Proof state:
case mpr
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
⊢ (∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0) → eVariationOn f s = 0

Next tactic:
rintro h
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  constructor
  · rintro h x xs y ys
    rw [← le_zero_iff, ← h]
    exact edist_le f xs ys
  · rintro h
    

Proof state:
case mpr
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
h : ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0
⊢ eVariationOn f s = 0

Next tactic:
dsimp only [eVariationOn]
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  constructor
  · rintro h x xs y ys
    rw [← le_zero_iff, ← h]
    exact edist_le f xs ys
  · rintro h
    dsimp only [eVariationOn]
    

Proof state:
case mpr
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
h : ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0
⊢ ⨆ p, ∑ i in Finset.range p.1, edist (f (↑p.2 (i + 1))) (f (↑p.2 i)) = 0

Next tactic:
rw [ENNReal.iSup_eq_zero]
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  constructor
  · rintro h x xs y ys
    rw [← le_zero_iff, ← h]
    exact edist_le f xs ys
  · rintro h
    dsimp only [eVariationOn]
    rw [ENNReal.iSup_eq_zero]
    

Proof state:
case mpr
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
h : ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0
⊢ ∀ (i : ℕ × { u // Monotone u ∧ ∀ (i : ℕ), u i ∈ s }),
    ∑ i_1 in Finset.range i.1, edist (f (↑i.2 (i_1 + 1))) (f (↑i.2 i_1)) = 0

Next tactic:
rintro ⟨n, u, um, us⟩
theorem eq_zero_iff (f : α → E) {s : Set α} :
    eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
  constructor
  · rintro h x xs y ys
    rw [← le_zero_iff, ← h]
    exact edist_le f xs ys
  · rintro h
    dsimp only [eVariationOn]
    rw [ENNReal.iSup_eq_zero]
    rintro ⟨n, u, um, us⟩
    

Proof state:
case mpr.mk.mk.intro
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
h : ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0
n : ℕ
u : ℕ → α
um : Monotone u
us : ∀ (i : ℕ), u i ∈ s
⊢ ∑ i in Finset.range (n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).1,
      edist (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 (i + 1)))
        (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 i)) =
    0

Next tactic:
exact Finset.sum_eq_zero fun i _ => h _ (us i.succ) _ (us i)
theorem constant_on {f : α → E} {s : Set α} (hf : (f '' s).Subsingleton) :
    eVariationOn f s = 0 := by
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
hf : Set.Subsingleton (f '' s)
⊢ eVariationOn f s = 0

Next tactic:
rw [eq_zero_iff]
theorem constant_on {f : α → E} {s : Set α} (hf : (f '' s).Subsingleton) :
    eVariationOn f s = 0 := by
  rw [eq_zero_iff]
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
hf : Set.Subsingleton (f '' s)
⊢ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0

Next tactic:
rintro x xs y ys
theorem constant_on {f : α → E} {s : Set α} (hf : (f '' s).Subsingleton) :
    eVariationOn f s = 0 := by
  rw [eq_zero_iff]
  rintro x xs y ys
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
f : α → E
s : Set α
hf : Set.Subsingleton (f '' s)
x : α
xs : x ∈ s
y : α
ys : y ∈ s
⊢ edist (f x) (f y) = 0

Next tactic:
rw [hf ⟨x, xs, rfl⟩ ⟨y, ys, rfl⟩, edist_self]
theorem lowerSemicontinuous_aux {ι : Type*} {F : ι → α → E} {p : Filter ι} {f : α → E} {s : Set α}
    (Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))) {v : ℝ≥0∞} (hv : v < eVariationOn f s) :
    ∀ᶠ n : ι in p, v < eVariationOn (F n) s := by
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
ι : Type u_3
F : ι → α → E
p : Filter ι
f : α → E
s : Set α
Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))
v : ℝ≥0∞
hv : v < eVariationOn f s
⊢ ∀ᶠ (n : ι) in p, v < eVariationOn (F n) s

Next tactic:
obtain ⟨⟨n, ⟨u, um, us⟩⟩, hlt⟩ :
    ∃ p : ℕ × { u : ℕ → α // Monotone u ∧ ∀ i, u i ∈ s },
      v < ∑ i in Finset.range p.1, edist (f ((p.2 : ℕ → α) (i + 1))) (f ((p.2 : ℕ → α) i)) :=
    lt_iSup_iff.mp hv
theorem lowerSemicontinuous_aux {ι : Type*} {F : ι → α → E} {p : Filter ι} {f : α → E} {s : Set α}
    (Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))) {v : ℝ≥0∞} (hv : v < eVariationOn f s) :
    ∀ᶠ n : ι in p, v < eVariationOn (F n) s := by
  obtain ⟨⟨n, ⟨u, um, us⟩⟩, hlt⟩ :
    ∃ p : ℕ × { u : ℕ → α // Monotone u ∧ ∀ i, u i ∈ s },
      v < ∑ i in Finset.range p.1, edist (f ((p.2 : ℕ → α) (i + 1))) (f ((p.2 : ℕ → α) i)) :=
    lt_iSup_iff.mp hv
  

Proof state:
case intro.mk.mk.intro
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
ι : Type u_3
F : ι → α → E
p : Filter ι
f : α → E
s : Set α
Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))
v : ℝ≥0∞
hv : v < eVariationOn f s
n : ℕ
u : ℕ → α
um : Monotone u
us : ∀ (i : ℕ), u i ∈ s
hlt :
  v <
    ∑ i in Finset.range (n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).1,
      edist (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 (i + 1)))
        (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 i))
⊢ ∀ᶠ (n : ι) in p, v < eVariationOn (F n) s

Next tactic:
have : Tendsto (fun j => ∑ i : ℕ in Finset.range n, edist (F j (u (i + 1))) (F j (u i))) p
      (𝓝 (∑ i : ℕ in Finset.range n, edist (f (u (i + 1))) (f (u i)))) := by
    apply tendsto_finset_sum
    exact fun i _ => Tendsto.edist (Ffs (u i.succ) (us i.succ)) (Ffs (u i) (us i))
theorem lowerSemicontinuous_aux {ι : Type*} {F : ι → α → E} {p : Filter ι} {f : α → E} {s : Set α}
    (Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))) {v : ℝ≥0∞} (hv : v < eVariationOn f s) :
    ∀ᶠ n : ι in p, v < eVariationOn (F n) s := by
  obtain ⟨⟨n, ⟨u, um, us⟩⟩, hlt⟩ :
    ∃ p : ℕ × { u : ℕ → α // Monotone u ∧ ∀ i, u i ∈ s },
      v < ∑ i in Finset.range p.1, edist (f ((p.2 : ℕ → α) (i + 1))) (f ((p.2 : ℕ → α) i)) :=
    lt_iSup_iff.mp hv
  have : Tendsto (fun j => ∑ i : ℕ in Finset.range n, edist (F j (u (i + 1))) (F j (u i))) p
      (𝓝 (∑ i : ℕ in Finset.range n, edist (f (u (i + 1))) (f (u i)))) := by
    

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
ι : Type u_3
F : ι → α → E
p : Filter ι
f : α → E
s : Set α
Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))
v : ℝ≥0∞
hv : v < eVariationOn f s
n : ℕ
u : ℕ → α
um : Monotone u
us : ∀ (i : ℕ), u i ∈ s
hlt :
  v <
    ∑ i in Finset.range (n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).1,
      edist (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 (i + 1)))
        (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 i))
⊢ Tendsto (fun j => ∑ i in Finset.range n, edist (F j (u (i + 1))) (F j (u i))) p
    (𝓝 (∑ i in Finset.range n, edist (f (u (i + 1))) (f (u i))))

Next tactic:
apply tendsto_finset_sum
theorem lowerSemicontinuous_aux {ι : Type*} {F : ι → α → E} {p : Filter ι} {f : α → E} {s : Set α}
    (Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))) {v : ℝ≥0∞} (hv : v < eVariationOn f s) :
    ∀ᶠ n : ι in p, v < eVariationOn (F n) s := by
  obtain ⟨⟨n, ⟨u, um, us⟩⟩, hlt⟩ :
    ∃ p : ℕ × { u : ℕ → α // Monotone u ∧ ∀ i, u i ∈ s },
      v < ∑ i in Finset.range p.1, edist (f ((p.2 : ℕ → α) (i + 1))) (f ((p.2 : ℕ → α) i)) :=
    lt_iSup_iff.mp hv
  have : Tendsto (fun j => ∑ i : ℕ in Finset.range n, edist (F j (u (i + 1))) (F j (u i))) p
      (𝓝 (∑ i : ℕ in Finset.range n, edist (f (u (i + 1))) (f (u i)))) := by
    apply tendsto_finset_sum
    

Proof state:
case a
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
ι : Type u_3
F : ι → α → E
p : Filter ι
f : α → E
s : Set α
Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))
v : ℝ≥0∞
hv : v < eVariationOn f s
n : ℕ
u : ℕ → α
um : Monotone u
us : ∀ (i : ℕ), u i ∈ s
hlt :
  v <
    ∑ i in Finset.range (n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).1,
      edist (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 (i + 1)))
        (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 i))
⊢ ∀ i ∈ Finset.range n, Tendsto (fun b => edist (F b (u (i + 1))) (F b (u i))) p (𝓝 (edist (f (u (i + 1))) (f (u i))))

Next tactic:
exact fun i _ => Tendsto.edist (Ffs (u i.succ) (us i.succ)) (Ffs (u i) (us i))
theorem lowerSemicontinuous_aux {ι : Type*} {F : ι → α → E} {p : Filter ι} {f : α → E} {s : Set α}
    (Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))) {v : ℝ≥0∞} (hv : v < eVariationOn f s) :
    ∀ᶠ n : ι in p, v < eVariationOn (F n) s := by
  obtain ⟨⟨n, ⟨u, um, us⟩⟩, hlt⟩ :
    ∃ p : ℕ × { u : ℕ → α // Monotone u ∧ ∀ i, u i ∈ s },
      v < ∑ i in Finset.range p.1, edist (f ((p.2 : ℕ → α) (i + 1))) (f ((p.2 : ℕ → α) i)) :=
    lt_iSup_iff.mp hv
  have : Tendsto (fun j => ∑ i : ℕ in Finset.range n, edist (F j (u (i + 1))) (F j (u i))) p
      (𝓝 (∑ i : ℕ in Finset.range n, edist (f (u (i + 1))) (f (u i)))) := by
    apply tendsto_finset_sum
    exact fun i _ => Tendsto.edist (Ffs (u i.succ) (us i.succ)) (Ffs (u i) (us i))
  

Proof state:
case intro.mk.mk.intro
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
ι : Type u_3
F : ι → α → E
p : Filter ι
f : α → E
s : Set α
Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))
v : ℝ≥0∞
hv : v < eVariationOn f s
n : ℕ
u : ℕ → α
um : Monotone u
us : ∀ (i : ℕ), u i ∈ s
hlt :
  v <
    ∑ i in Finset.range (n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).1,
      edist (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 (i + 1)))
        (f (↑(n, { val := u, property := (_ : Monotone u ∧ ∀ (i : ℕ), u i ∈ s) }).2 i))
this :
  Tendsto (fun j => ∑ i in Finset.range n, edist (F j (u (i + 1))) (F j (u i))) p
    (𝓝 (∑ i in Finset.range n, edist (f (u (i + 1))) (f (u i))))
⊢ ∀ᶠ (n : ι) in p, v < eVariationOn (F n) s

Next tactic:
exact (eventually_gt_of_tendsto_gt hlt this).mono fun i h => h.trans_le (sum_le (F i) n um us)
/-- The map `(eVariationOn · s)` is lower semicontinuous for pointwise convergence *on `s`*.
Pointwise convergence on `s` is encoded here as uniform convergence on the family consisting of the
singletons of elements of `s`.
-/
protected theorem lowerSemicontinuous (s : Set α) :
    LowerSemicontinuous fun f : α →ᵤ[s.image singleton] E => eVariationOn f s := fun f ↦ by
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
s : Set α
f : α →ᵤ[singleton '' s] E
⊢ LowerSemicontinuousAt (fun f => eVariationOn f s) f

Next tactic:
apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E (s.image singleton)) id (𝓝 f) f s _
/-- The map `(eVariationOn · s)` is lower semicontinuous for pointwise convergence *on `s`*.
Pointwise convergence on `s` is encoded here as uniform convergence on the family consisting of the
singletons of elements of `s`.
-/
protected theorem lowerSemicontinuous (s : Set α) :
    LowerSemicontinuous fun f : α →ᵤ[s.image singleton] E => eVariationOn f s := fun f ↦ by
  apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E (s.image singleton)) id (𝓝 f) f s _
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
s : Set α
f : α →ᵤ[singleton '' s] E
⊢ ∀ x ∈ s, Tendsto (fun i => id i x) (𝓝 f) (𝓝 (f x))

Next tactic:
simpa only [UniformOnFun.tendsto_iff_tendstoUniformlyOn, mem_image, forall_exists_index, and_imp,
    forall_apply_eq_imp_iff₂, tendstoUniformlyOn_singleton_iff_tendsto] using @tendsto_id _ (𝓝 f)
/-- The map `(eVariationOn · s)` is lower semicontinuous for uniform convergence on `s`.  -/
theorem lowerSemicontinuous_uniformOn (s : Set α) :
    LowerSemicontinuous fun f : α →ᵤ[{s}] E => eVariationOn f s := fun f ↦ by
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
s : Set α
f : α →ᵤ[{s}] E
⊢ LowerSemicontinuousAt (fun f => eVariationOn f s) f

Next tactic:
apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E {s}) id (𝓝 f) f s _
/-- The map `(eVariationOn · s)` is lower semicontinuous for uniform convergence on `s`.  -/
theorem lowerSemicontinuous_uniformOn (s : Set α) :
    LowerSemicontinuous fun f : α →ᵤ[{s}] E => eVariationOn f s := fun f ↦ by
  apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E {s}) id (𝓝 f) f s _
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
s : Set α
f : α →ᵤ[{s}] E
⊢ ∀ x ∈ s, Tendsto (fun i => id i x) (𝓝 f) (𝓝 (f x))

Next tactic:
have := @tendsto_id _ (𝓝 f)
/-- The map `(eVariationOn · s)` is lower semicontinuous for uniform convergence on `s`.  -/
theorem lowerSemicontinuous_uniformOn (s : Set α) :
    LowerSemicontinuous fun f : α →ᵤ[{s}] E => eVariationOn f s := fun f ↦ by
  apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E {s}) id (𝓝 f) f s _
  have := @tendsto_id _ (𝓝 f)
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
s : Set α
f : α →ᵤ[{s}] E
this : Tendsto id (𝓝 f) (𝓝 f)
⊢ ∀ x ∈ s, Tendsto (fun i => id i x) (𝓝 f) (𝓝 (f x))

Next tactic:
rw [UniformOnFun.tendsto_iff_tendstoUniformlyOn] at this
/-- The map `(eVariationOn · s)` is lower semicontinuous for uniform convergence on `s`.  -/
theorem lowerSemicontinuous_uniformOn (s : Set α) :
    LowerSemicontinuous fun f : α →ᵤ[{s}] E => eVariationOn f s := fun f ↦ by
  apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E {s}) id (𝓝 f) f s _
  have := @tendsto_id _ (𝓝 f)
  rw [UniformOnFun.tendsto_iff_tendstoUniformlyOn] at this
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
s : Set α
f : α →ᵤ[{s}] E
this : ∀ s_1 ∈ {s}, TendstoUniformlyOn (⇑(UniformOnFun.toFun {s}) ∘ id) ((UniformOnFun.toFun {s}) f) (𝓝 f) s_1
⊢ ∀ x ∈ s, Tendsto (fun i => id i x) (𝓝 f) (𝓝 (f x))

Next tactic:
simp_rw [← tendstoUniformlyOn_singleton_iff_tendsto]
/-- The map `(eVariationOn · s)` is lower semicontinuous for uniform convergence on `s`.  -/
theorem lowerSemicontinuous_uniformOn (s : Set α) :
    LowerSemicontinuous fun f : α →ᵤ[{s}] E => eVariationOn f s := fun f ↦ by
  apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E {s}) id (𝓝 f) f s _
  have := @tendsto_id _ (𝓝 f)
  rw [UniformOnFun.tendsto_iff_tendstoUniformlyOn] at this
  simp_rw [← tendstoUniformlyOn_singleton_iff_tendsto]
  

Proof state:
α : Type u_1
inst✝¹ : LinearOrder α
E : Type u_2
inst✝ : PseudoEMetricSpace E
s : Set α
f : α →ᵤ[{s}] E
this : ∀ s_1 ∈ {s}, TendstoUniformlyOn (⇑(UniformOnFun.toFun {s}) ∘ id) ((UniformOnFun.toFun {s}) f) (𝓝 f) s_1
⊢ ∀ x ∈ s, TendstoUniformlyOn (fun n => id n) f (𝓝 f) {x}

Next tactic:
exact fun x xs => (this s rfl).mono (singleton_subset_iff.mpr xs)