l3lab/ntp-mathlib huggingface dataset:
/--
The comap of the identity is the identity. In this variant of the lemma, two open subsets `U` and
`V` are given as arguments, together with a proof that `U = V`. This is useful when `U` and `V`
are not definitionally equal.
-/
theorem comap_id (U V : Opens (PrimeSpectrum.Top R)) (hUV : U = V) :
    (comap (RingHom.id R) U V fun p hpV => by rwa [hUV, PrimeSpectrum.comap_id]) =
      eqToHom (show (structureSheaf R).1.obj (op U) = _ by rw [hUV]) :=
  by 

Proof state:
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
U V : Opens ↑(PrimeSpectrum.Top R)
hUV : U = V
⊢ comap (RingHom.id R) U V (_ : ∀ p ∈ V.carrier, p ∈ ⇑(PrimeSpectrum.comap (RingHom.id R)) ⁻¹' U.carrier) =
    eqToHom (_ : (structureSheaf R).val.obj (op U) = (structureSheaf R).val.obj (op V))

Next tactic:
erw [comap_id_eq_map U V (eqToHom hUV.symm), eqToHom_op, eqToHom_map]
@[simp]
theorem comap_id' (U : Opens (PrimeSpectrum.Top R)) :
    (comap (RingHom.id R) U U fun p hpU => by 

Proof state:
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
U : Opens ↑(PrimeSpectrum.Top R)
p : ↑(PrimeSpectrum.Top R)
hpU : p ∈ U.carrier
⊢ p ∈ ⇑(PrimeSpectrum.comap (RingHom.id R)) ⁻¹' U.carrier

Next tactic:
rwa [PrimeSpectrum.comap_id]
@[simp]
theorem comap_id' (U : Opens (PrimeSpectrum.Top R)) :
    (comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ := by
  

Proof state:
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
U : Opens ↑(PrimeSpectrum.Top R)
⊢ comap (RingHom.id R) U U (_ : ∀ p ∈ U.carrier, p ∈ ⇑(PrimeSpectrum.comap (RingHom.id R)) ⁻¹' U.carrier) =
    RingHom.id ↑((structureSheaf R).val.obj (op U))

Next tactic:
rw [comap_id U U rfl]
@[simp]
theorem comap_id' (U : Opens (PrimeSpectrum.Top R)) :
    (comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ := by
  rw [comap_id U U rfl]; 

Proof state:
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
U : Opens ↑(PrimeSpectrum.Top R)
⊢ eqToHom (_ : (structureSheaf R).val.obj (op U) = (structureSheaf R).val.obj (op U)) =
    RingHom.id ↑((structureSheaf R).val.obj (op U))

Next tactic:
rfl
theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top R))
    (V : Opens (PrimeSpectrum.Top S)) (W : Opens (PrimeSpectrum.Top P))
    (hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :
    (comap (g.comp f) U W fun p hpW => hUV (PrimeSpectrum.comap g p) (hVW p hpW)) =
      (comap g V W hVW).comp (comap f U V hUV) :=
  RingHom.ext fun s =>
    Subtype.eq <|
      funext fun p => by
        

Proof state:
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
f : R →+* S
g : S →+* P
U : Opens ↑(PrimeSpectrum.Top R)
V : Opens ↑(PrimeSpectrum.Top S)
W : Opens ↑(PrimeSpectrum.Top P)
hUV : ∀ p ∈ V, (PrimeSpectrum.comap f) p ∈ U
hVW : ∀ p ∈ W, (PrimeSpectrum.comap g) p ∈ V
s : ↑((structureSheaf R).val.obj (op U))
p : ↥(op W).unop
⊢ ↑((comap (RingHom.comp g f) U W (_ : ∀ p ∈ W.carrier, (PrimeSpectrum.comap f) ((PrimeSpectrum.comap g) p) ∈ U)) s) p =
    ↑((RingHom.comp (comap g V W hVW) (comap f U V hUV)) s) p

Next tactic:
rw [comap_apply]
theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top R))
    (V : Opens (PrimeSpectrum.Top S)) (W : Opens (PrimeSpectrum.Top P))
    (hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :
    (comap (g.comp f) U W fun p hpW => hUV (PrimeSpectrum.comap g p) (hVW p hpW)) =
      (comap g V W hVW).comp (comap f U V hUV) :=
  RingHom.ext fun s =>
    Subtype.eq <|
      funext fun p => by
        rw [comap_apply]
        

Proof state:
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
f : R →+* S
g : S →+* P
U : Opens ↑(PrimeSpectrum.Top R)
V : Opens ↑(PrimeSpectrum.Top S)
W : Opens ↑(PrimeSpectrum.Top P)
hUV : ∀ p ∈ V, (PrimeSpectrum.comap f) p ∈ U
hVW : ∀ p ∈ W, (PrimeSpectrum.comap g) p ∈ V
s : ↑((structureSheaf R).val.obj (op U))
p : ↥(op W).unop
⊢ (Localization.localRingHom ((PrimeSpectrum.comap (RingHom.comp g f)) ↑p).asIdeal (↑p).asIdeal (RingHom.comp g f)
        (_ :
          ((PrimeSpectrum.comap (RingHom.comp g f)) ↑p).asIdeal =
            ((PrimeSpectrum.comap (RingHom.comp g f)) ↑p).asIdeal))
      (↑s
        { val := (PrimeSpectrum.comap (RingHom.comp g f)) ↑p,
          property := (_ : (PrimeSpectrum.comap f) ((PrimeSpectrum.comap g) ↑p) ∈ U) }) =
    ↑((RingHom.comp (comap g V W hVW) (comap f U V hUV)) s) p

Next tactic:
erw [Localization.localRingHom_comp _ (PrimeSpectrum.comap g p.1).asIdeal]
theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top R))
    (V : Opens (PrimeSpectrum.Top S)) (W : Opens (PrimeSpectrum.Top P))
    (hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :
    (comap (g.comp f) U W fun p hpW => hUV (PrimeSpectrum.comap g p) (hVW p hpW)) =
      (comap g V W hVW).comp (comap f U V hUV) :=
  RingHom.ext fun s =>
    Subtype.eq <|
      funext fun p => by
        rw [comap_apply]
        erw [Localization.localRingHom_comp _ (PrimeSpectrum.comap g p.1).asIdeal] <;>
        -- refl works here, because `PrimeSpectrum.comap (g.comp f) p` is defeq to
        -- `PrimeSpectrum.comap f (PrimeSpectrum.comap g p)`
        

Proof state:
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
f : R →+* S
g : S →+* P
U : Opens ↑(PrimeSpectrum.Top R)
V : Opens ↑(PrimeSpectrum.Top S)
W : Opens ↑(PrimeSpectrum.Top P)
hUV : ∀ p ∈ V, (PrimeSpectrum.comap f) p ∈ U
hVW : ∀ p ∈ W, (PrimeSpectrum.comap g) p ∈ V
s : ↑((structureSheaf R).val.obj (op U))
p : ↥(op W).unop
⊢ (RingHom.comp (Localization.localRingHom ((PrimeSpectrum.comap g) ↑p).asIdeal (↑p).asIdeal g ?hJK)
        (Localization.localRingHom ((PrimeSpectrum.comap (RingHom.comp g f)) ↑p).asIdeal
          ((PrimeSpectrum.comap g) ↑p).asIdeal f ?hIJ))
      (↑s
        { val := (PrimeSpectrum.comap (RingHom.comp g f)) ↑p,
          property := (_ : (PrimeSpectrum.comap f) ((PrimeSpectrum.comap g) ↑p) ∈ U) }) =
    ↑((RingHom.comp (comap g V W hVW) (comap f U V hUV)) s) p

Next tactic:
rfl
theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top R))
    (V : Opens (PrimeSpectrum.Top S)) (W : Opens (PrimeSpectrum.Top P))
    (hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :
    (comap (g.comp f) U W fun p hpW => hUV (PrimeSpectrum.comap g p) (hVW p hpW)) =
      (comap g V W hVW).comp (comap f U V hUV) :=
  RingHom.ext fun s =>
    Subtype.eq <|
      funext fun p => by
        rw [comap_apply]
        erw [Localization.localRingHom_comp _ (PrimeSpectrum.comap g p.1).asIdeal] <;>
        -- refl works here, because `PrimeSpectrum.comap (g.comp f) p` is defeq to
        -- `PrimeSpectrum.comap f (PrimeSpectrum.comap g p)`
        

Proof state:
case hJK
R : Type u
inst✝² : CommRing R
S : Type u
inst✝¹ : CommRing S
P : Type u
inst✝ : CommRing P
f : R →+* S
g : S →+* P
U : Opens ↑(PrimeSpectrum.Top R)
V : Opens ↑(PrimeSpectrum.Top S)
W : Opens ↑(PrimeSpectrum.Top P)
hUV : ∀ p ∈ V, (PrimeSpectrum.comap f) p ∈ U
hVW : ∀ p ∈ W, (PrimeSpectrum.comap g) p ∈ V
s : ↑((structureSheaf R).val.obj (op U))
p : ↥(op W).unop
⊢ ((PrimeSpectrum.comap g) ↑p).asIdeal = Ideal.comap g (↑p).asIdeal

Next tactic:
rfl
@[ext] lemma ext {f g : StieltjesFunction} (h : ∀ x, f x = g x) : f = g := by
  

Proof state:
f g : StieltjesFunction
h : ∀ (x : ℝ), ↑f x = ↑g x
⊢ f = g

Next tactic:
exact (StieltjesFunction.mk.injEq ..).mpr (funext (by exact h))
@[ext] lemma ext {f g : StieltjesFunction} (h : ∀ x, f x = g x) : f = g := by
  exact (StieltjesFunction.mk.injEq ..).mpr (funext (by 

Proof state:
f g : StieltjesFunction
h : ∀ (x : ℝ), ↑f x = ↑g x
⊢ ∀ (x : ℝ), ↑f x = ↑g x

Next tactic:
exact h
theorem rightLim_eq (f : StieltjesFunction) (x : ℝ) : Function.rightLim f x = f x := by
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ rightLim (↑f) x = ↑f x

Next tactic:
rw [← f.mono.continuousWithinAt_Ioi_iff_rightLim_eq, continuousWithinAt_Ioi_iff_Ici]
theorem rightLim_eq (f : StieltjesFunction) (x : ℝ) : Function.rightLim f x = f x := by
  rw [← f.mono.continuousWithinAt_Ioi_iff_rightLim_eq, continuousWithinAt_Ioi_iff_Ici]
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ ContinuousWithinAt (↑f) (Ici x) x

Next tactic:
exact f.right_continuous' x
theorem iInf_Ioi_eq (f : StieltjesFunction) (x : ℝ) : ⨅ r : Ioi x, f r = f x := by
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ ⨅ r, ↑f ↑r = ↑f x

Next tactic:
suffices Function.rightLim f x = ⨅ r : Ioi x, f r by rw [← this, f.rightLim_eq]
theorem iInf_Ioi_eq (f : StieltjesFunction) (x : ℝ) : ⨅ r : Ioi x, f r = f x := by
  suffices Function.rightLim f x = ⨅ r : Ioi x, f r by 

Proof state:
f✝ f : StieltjesFunction
x : ℝ
this : rightLim (↑f) x = ⨅ r, ↑f ↑r
⊢ ⨅ r, ↑f ↑r = ↑f x

Next tactic:
rw [← this, f.rightLim_eq]
theorem iInf_Ioi_eq (f : StieltjesFunction) (x : ℝ) : ⨅ r : Ioi x, f r = f x := by
  suffices Function.rightLim f x = ⨅ r : Ioi x, f r by rw [← this, f.rightLim_eq]
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ rightLim (↑f) x = ⨅ r, ↑f ↑r

Next tactic:
rw [f.mono.rightLim_eq_sInf, sInf_image']
theorem iInf_Ioi_eq (f : StieltjesFunction) (x : ℝ) : ⨅ r : Ioi x, f r = f x := by
  suffices Function.rightLim f x = ⨅ r : Ioi x, f r by rw [← this, f.rightLim_eq]
  rw [f.mono.rightLim_eq_sInf, sInf_image']
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ 𝓝[>] x ≠ ⊥

Next tactic:
rw [← neBot_iff]
theorem iInf_Ioi_eq (f : StieltjesFunction) (x : ℝ) : ⨅ r : Ioi x, f r = f x := by
  suffices Function.rightLim f x = ⨅ r : Ioi x, f r by rw [← this, f.rightLim_eq]
  rw [f.mono.rightLim_eq_sInf, sInf_image']
  rw [← neBot_iff]
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ NeBot (𝓝[>] x)

Next tactic:
infer_instance
theorem iInf_rat_gt_eq (f : StieltjesFunction) (x : ℝ) :
    ⨅ r : { r' : ℚ // x < r' }, f r = f x := by
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ ⨅ r, ↑f ↑↑r = ↑f x

Next tactic:
rw [← iInf_Ioi_eq f x]
theorem iInf_rat_gt_eq (f : StieltjesFunction) (x : ℝ) :
    ⨅ r : { r' : ℚ // x < r' }, f r = f x := by
  rw [← iInf_Ioi_eq f x]
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ ⨅ r, ↑f ↑↑r = ⨅ r, ↑f ↑r

Next tactic:
refine' (Real.iInf_Ioi_eq_iInf_rat_gt _ _ f.mono).symm
theorem iInf_rat_gt_eq (f : StieltjesFunction) (x : ℝ) :
    ⨅ r : { r' : ℚ // x < r' }, f r = f x := by
  rw [← iInf_Ioi_eq f x]
  refine' (Real.iInf_Ioi_eq_iInf_rat_gt _ _ f.mono).symm
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
⊢ BddBelow (↑f '' Ioi x)

Next tactic:
refine' ⟨f x, fun y => _⟩
theorem iInf_rat_gt_eq (f : StieltjesFunction) (x : ℝ) :
    ⨅ r : { r' : ℚ // x < r' }, f r = f x := by
  rw [← iInf_Ioi_eq f x]
  refine' (Real.iInf_Ioi_eq_iInf_rat_gt _ _ f.mono).symm
  refine' ⟨f x, fun y => _⟩
  

Proof state:
f✝ f : StieltjesFunction
x y : ℝ
⊢ y ∈ ↑f '' Ioi x → ↑f x ≤ y

Next tactic:
rintro ⟨y, hy_mem, rfl⟩
theorem iInf_rat_gt_eq (f : StieltjesFunction) (x : ℝ) :
    ⨅ r : { r' : ℚ // x < r' }, f r = f x := by
  rw [← iInf_Ioi_eq f x]
  refine' (Real.iInf_Ioi_eq_iInf_rat_gt _ _ f.mono).symm
  refine' ⟨f x, fun y => _⟩
  rintro ⟨y, hy_mem, rfl⟩
  

Proof state:
case intro.intro
f✝ f : StieltjesFunction
x y : ℝ
hy_mem : y ∈ Ioi x
⊢ ↑f x ≤ ↑f y

Next tactic:
exact f.mono (le_of_lt hy_mem)
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    

Proof state:
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
⊢ ∀ (x : ℝ), ContinuousWithinAt (rightLim f) (Ici x) x

Next tactic:
intro x s hs
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    intro x s hs
    

Proof state:
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
x : ℝ
s : Set ℝ
hs : s ∈ 𝓝 (rightLim f x)
⊢ s ∈ map (rightLim f) (𝓝[≥] x)

Next tactic:
obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s :=
      mem_nhds_iff_exists_Ioo_subset.1 hs
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    intro x s hs
    obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s :=
      mem_nhds_iff_exists_Ioo_subset.1 hs
    

Proof state:
case intro.intro.intro
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
x : ℝ
s : Set ℝ
hs : s ∈ 𝓝 (rightLim f x)
l u : ℝ
hlu : rightLim f x ∈ Ioo l u
lus : Ioo l u ⊆ s
⊢ s ∈ map (rightLim f) (𝓝[≥] x)

Next tactic:
obtain ⟨y, xy, h'y⟩ : ∃ (y : ℝ), x < y ∧ Ioc x y ⊆ f ⁻¹' Ioo l u :=
      mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 (hf.tendsto_rightLim x (Ioo_mem_nhds hlu.1 hlu.2))
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    intro x s hs
    obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s :=
      mem_nhds_iff_exists_Ioo_subset.1 hs
    obtain ⟨y, xy, h'y⟩ : ∃ (y : ℝ), x < y ∧ Ioc x y ⊆ f ⁻¹' Ioo l u :=
      mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 (hf.tendsto_rightLim x (Ioo_mem_nhds hlu.1 hlu.2))
    

Proof state:
case intro.intro.intro.intro.intro
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
x : ℝ
s : Set ℝ
hs : s ∈ 𝓝 (rightLim f x)
l u : ℝ
hlu : rightLim f x ∈ Ioo l u
lus : Ioo l u ⊆ s
y : ℝ
xy : x < y
h'y : Ioc x y ⊆ f ⁻¹' Ioo l u
⊢ s ∈ map (rightLim f) (𝓝[≥] x)

Next tactic:
change ∀ᶠ y in 𝓝[≥] x, rightLim f y ∈ s
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    intro x s hs
    obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s :=
      mem_nhds_iff_exists_Ioo_subset.1 hs
    obtain ⟨y, xy, h'y⟩ : ∃ (y : ℝ), x < y ∧ Ioc x y ⊆ f ⁻¹' Ioo l u :=
      mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 (hf.tendsto_rightLim x (Ioo_mem_nhds hlu.1 hlu.2))
    change ∀ᶠ y in 𝓝[≥] x, rightLim f y ∈ s
    

Proof state:
case intro.intro.intro.intro.intro
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
x : ℝ
s : Set ℝ
hs : s ∈ 𝓝 (rightLim f x)
l u : ℝ
hlu : rightLim f x ∈ Ioo l u
lus : Ioo l u ⊆ s
y : ℝ
xy : x < y
h'y : Ioc x y ⊆ f ⁻¹' Ioo l u
⊢ ∀ᶠ (y : ℝ) in 𝓝[≥] x, rightLim f y ∈ s

Next tactic:
filter_upwards [Ico_mem_nhdsWithin_Ici ⟨le_refl x, xy⟩] with z hz
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    intro x s hs
    obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s :=
      mem_nhds_iff_exists_Ioo_subset.1 hs
    obtain ⟨y, xy, h'y⟩ : ∃ (y : ℝ), x < y ∧ Ioc x y ⊆ f ⁻¹' Ioo l u :=
      mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 (hf.tendsto_rightLim x (Ioo_mem_nhds hlu.1 hlu.2))
    change ∀ᶠ y in 𝓝[≥] x, rightLim f y ∈ s
    filter_upwards [Ico_mem_nhdsWithin_Ici ⟨le_refl x, xy⟩] with z hz
    

Proof state:
case h
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
x : ℝ
s : Set ℝ
hs : s ∈ 𝓝 (rightLim f x)
l u : ℝ
hlu : rightLim f x ∈ Ioo l u
lus : Ioo l u ⊆ s
y : ℝ
xy : x < y
h'y : Ioc x y ⊆ f ⁻¹' Ioo l u
z : ℝ
hz : z ∈ Ico x y
⊢ rightLim f z ∈ s

Next tactic:
apply lus
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    intro x s hs
    obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s :=
      mem_nhds_iff_exists_Ioo_subset.1 hs
    obtain ⟨y, xy, h'y⟩ : ∃ (y : ℝ), x < y ∧ Ioc x y ⊆ f ⁻¹' Ioo l u :=
      mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 (hf.tendsto_rightLim x (Ioo_mem_nhds hlu.1 hlu.2))
    change ∀ᶠ y in 𝓝[≥] x, rightLim f y ∈ s
    filter_upwards [Ico_mem_nhdsWithin_Ici ⟨le_refl x, xy⟩] with z hz
    apply lus
    

Proof state:
case h.a
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
x : ℝ
s : Set ℝ
hs : s ∈ 𝓝 (rightLim f x)
l u : ℝ
hlu : rightLim f x ∈ Ioo l u
lus : Ioo l u ⊆ s
y : ℝ
xy : x < y
h'y : Ioc x y ⊆ f ⁻¹' Ioo l u
z : ℝ
hz : z ∈ Ico x y
⊢ rightLim f z ∈ Ioo l u

Next tactic:
refine' ⟨hlu.1.trans_le (hf.rightLim hz.1), _⟩
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    intro x s hs
    obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s :=
      mem_nhds_iff_exists_Ioo_subset.1 hs
    obtain ⟨y, xy, h'y⟩ : ∃ (y : ℝ), x < y ∧ Ioc x y ⊆ f ⁻¹' Ioo l u :=
      mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 (hf.tendsto_rightLim x (Ioo_mem_nhds hlu.1 hlu.2))
    change ∀ᶠ y in 𝓝[≥] x, rightLim f y ∈ s
    filter_upwards [Ico_mem_nhdsWithin_Ici ⟨le_refl x, xy⟩] with z hz
    apply lus
    refine' ⟨hlu.1.trans_le (hf.rightLim hz.1), _⟩
    

Proof state:
case h.a
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
x : ℝ
s : Set ℝ
hs : s ∈ 𝓝 (rightLim f x)
l u : ℝ
hlu : rightLim f x ∈ Ioo l u
lus : Ioo l u ⊆ s
y : ℝ
xy : x < y
h'y : Ioc x y ⊆ f ⁻¹' Ioo l u
z : ℝ
hz : z ∈ Ico x y
⊢ rightLim f z < u

Next tactic:
obtain ⟨a, za, ay⟩ : ∃ a : ℝ, z < a ∧ a < y := exists_between hz.2
/-- If a function `f : ℝ → ℝ` is monotone, then the function mapping `x` to the right limit of `f`
at `x` is a Stieltjes function, i.e., it is monotone and right-continuous. -/
noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) :
    StieltjesFunction where
  toFun := rightLim f
  mono' x y hxy := hf.rightLim hxy
  right_continuous' := by
    intro x s hs
    obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s :=
      mem_nhds_iff_exists_Ioo_subset.1 hs
    obtain ⟨y, xy, h'y⟩ : ∃ (y : ℝ), x < y ∧ Ioc x y ⊆ f ⁻¹' Ioo l u :=
      mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 (hf.tendsto_rightLim x (Ioo_mem_nhds hlu.1 hlu.2))
    change ∀ᶠ y in 𝓝[≥] x, rightLim f y ∈ s
    filter_upwards [Ico_mem_nhdsWithin_Ici ⟨le_refl x, xy⟩] with z hz
    apply lus
    refine' ⟨hlu.1.trans_le (hf.rightLim hz.1), _⟩
    obtain ⟨a, za, ay⟩ : ∃ a : ℝ, z < a ∧ a < y := exists_between hz.2
    

Proof state:
case h.a.intro.intro
f✝ : StieltjesFunction
f : ℝ → ℝ
hf : Monotone f
x : ℝ
s : Set ℝ
hs : s ∈ 𝓝 (rightLim f x)
l u : ℝ
hlu : rightLim f x ∈ Ioo l u
lus : Ioo l u ⊆ s
y : ℝ
xy : x < y
h'y : Ioc x y ⊆ f ⁻¹' Ioo l u
z : ℝ
hz : z ∈ Ico x y
a : ℝ
za : z < a
ay : a < y
⊢ rightLim f z < u

Next tactic:
calc
      rightLim f z ≤ f a := hf.rightLim_le za
      _ < u := (h'y ⟨hz.1.trans_lt za, ay.le⟩).2
theorem countable_leftLim_ne (f : StieltjesFunction) : Set.Countable { x | leftLim f x ≠ f x } := by
  

Proof state:
f✝ f : StieltjesFunction
⊢ Set.Countable {x | leftLim (↑f) x ≠ ↑f x}

Next tactic:
refine Countable.mono ?_ f.mono.countable_not_continuousAt
theorem countable_leftLim_ne (f : StieltjesFunction) : Set.Countable { x | leftLim f x ≠ f x } := by
  refine Countable.mono ?_ f.mono.countable_not_continuousAt
  

Proof state:
f✝ f : StieltjesFunction
⊢ {x | leftLim (↑f) x ≠ ↑f x} ⊆ {x | ¬ContinuousAt (↑f) x}

Next tactic:
intro x hx h'x
theorem countable_leftLim_ne (f : StieltjesFunction) : Set.Countable { x | leftLim f x ≠ f x } := by
  refine Countable.mono ?_ f.mono.countable_not_continuousAt
  intro x hx h'x
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
hx : x ∈ {x | leftLim (↑f) x ≠ ↑f x}
h'x : ContinuousAt (↑f) x
⊢ False

Next tactic:
apply hx
theorem countable_leftLim_ne (f : StieltjesFunction) : Set.Countable { x | leftLim f x ≠ f x } := by
  refine Countable.mono ?_ f.mono.countable_not_continuousAt
  intro x hx h'x
  apply hx
  

Proof state:
f✝ f : StieltjesFunction
x : ℝ
hx : x ∈ {x | leftLim (↑f) x ≠ ↑f x}
h'x : ContinuousAt (↑f) x
⊢ leftLim (↑f) x = ↑f x

Next tactic:
exact tendsto_nhds_unique (f.mono.tendsto_leftLim x) (h'x.tendsto.mono_left nhdsWithin_le_nhds)
@[simp]
theorem length_empty : f.length ∅ = 0 :=
  nonpos_iff_eq_zero.1 <| iInf_le_of_le 0 <| iInf_le_of_le 0 <| by 

Proof state:
f : StieltjesFunction
⊢ ⨅ (_ : ∅ ⊆ Ioc 0 0), ofReal (↑f 0 - ↑f 0) ≤ 0

Next tactic:
simp
@[simp]
theorem length_Ioc (a b : ℝ) : f.length (Ioc a b) = ofReal (f b - f a) := by
  

Proof state:
f : StieltjesFunction
a b : ℝ
⊢ length f (Ioc a b) = ofReal (↑f b - ↑f a)

Next tactic:
refine'
    le_antisymm (iInf_le_of_le a <| iInf₂_le b Subset.rfl)
      (le_iInf fun a' => le_iInf fun b' => le_iInf fun h => ENNReal.coe_le_coe.2 _)
@[simp]
theorem length_Ioc (a b : ℝ) : f.length (Ioc a b) = ofReal (f b - f a) := by
  refine'
    le_antisymm (iInf_le_of_le a <| iInf₂_le b Subset.rfl)
      (le_iInf fun a' => le_iInf fun b' => le_iInf fun h => ENNReal.coe_le_coe.2 _)
  

Proof state:
f : StieltjesFunction
a b a' b' : ℝ
h : Ioc a b ⊆ Ioc a' b'
⊢ Real.toNNReal (↑f b - ↑f a) ≤ Real.toNNReal (↑f b' - ↑f a')

Next tactic:
rcases le_or_lt b a with ab | ab
@[simp]
theorem length_Ioc (a b : ℝ) : f.length (Ioc a b) = ofReal (f b - f a) := by
  refine'
    le_antisymm (iInf_le_of_le a <| iInf₂_le b Subset.rfl)
      (le_iInf fun a' => le_iInf fun b' => le_iInf fun h => ENNReal.coe_le_coe.2 _)
  rcases le_or_lt b a with ab | ab
  · 

Proof state:
case inl
f : StieltjesFunction
a b a' b' : ℝ
h : Ioc a b ⊆ Ioc a' b'
ab : b ≤ a
⊢ Real.toNNReal (↑f b - ↑f a) ≤ Real.toNNReal (↑f b' - ↑f a')

Next tactic:
rw [Real.toNNReal_of_nonpos (sub_nonpos.2 (f.mono ab))]
@[simp]
theorem length_Ioc (a b : ℝ) : f.length (Ioc a b) = ofReal (f b - f a) := by
  refine'
    le_antisymm (iInf_le_of_le a <| iInf₂_le b Subset.rfl)
      (le_iInf fun a' => le_iInf fun b' => le_iInf fun h => ENNReal.coe_le_coe.2 _)
  rcases le_or_lt b a with ab | ab
  · rw [Real.toNNReal_of_nonpos (sub_nonpos.2 (f.mono ab))]
    

Proof state:
case inl
f : StieltjesFunction
a b a' b' : ℝ
h : Ioc a b ⊆ Ioc a' b'
ab : b ≤ a
⊢ 0 ≤ Real.toNNReal (↑f b' - ↑f a')

Next tactic:
apply zero_le
@[simp]
theorem length_Ioc (a b : ℝ) : f.length (Ioc a b) = ofReal (f b - f a) := by
  refine'
    le_antisymm (iInf_le_of_le a <| iInf₂_le b Subset.rfl)
      (le_iInf fun a' => le_iInf fun b' => le_iInf fun h => ENNReal.coe_le_coe.2 _)
  rcases le_or_lt b a with ab | ab
  · rw [Real.toNNReal_of_nonpos (sub_nonpos.2 (f.mono ab))]
    apply zero_le
  

Proof state:
case inr
f : StieltjesFunction
a b a' b' : ℝ
h : Ioc a b ⊆ Ioc a' b'
ab : a < b
⊢ Real.toNNReal (↑f b - ↑f a) ≤ Real.toNNReal (↑f b' - ↑f a')

Next tactic:
cases' (Ioc_subset_Ioc_iff ab).1 h with h₁ h₂