File: Mathlib/Topology/EMetricSpace/Lipschitz.lean

full_name: LipschitzWith
code: /-- A function `f` is **Lipschitz continuous** with constant `K ≥ 0` if for all `x, y`
we have `dist (f x) (f y) ≤ K * dist x y`. -/
def LipschitzWith (K : ℝ≥0) (f : α → β) 
goal: Prop

full_name: LipschitzOnWith
code: /-- A function `f` is **Lipschitz continuous** with constant `K ≥ 0` **on `s`** if
for all `x, y` in `s` we have `dist (f x) (f y) ≤ K * dist x y`. -/
def LipschitzOnWith (K : ℝ≥0) (f : α → β) (s : Set α) 
goal: Prop

full_name: LocallyLipschitz
code: /-- `f : α → β` is called **locally Lipschitz continuous** iff every point `x`
has a neighourhood on which `f` is Lipschitz. -/
def LocallyLipschitz (f : α → β) : Prop 
goal: Prop

full_name: LocallyLipschitzOn
code: /-- `f : α → β` is called **locally Lipschitz continuous** on `s` iff every point `x` of `s`
has a neighourhood within `s` on which `f` is Lipschitz. -/
def LocallyLipschitzOn (s : Set α) (f : α → β) : Prop 
goal: Prop

full_name: lipschitzOnWith_empty
code: /-- Every function is Lipschitz on the empty set (with any Lipschitz constant). -/
@[simp]
theorem lipschitzOnWith_empty (K : ℝ≥0) (f : α → β) : LipschitzOnWith K f ∅ 
goal: LipschitzOnWith K f ∅

full_name: locallyLipschitzOn_empty
code: @[simp] lemma locallyLipschitzOn_empty (f : α → β) : LocallyLipschitzOn ∅ f 
goal: LocallyLipschitzOn ∅ f

full_name: LipschitzOnWith.mono
code: /-- Being Lipschitz on a set is monotone w.r.t. that set. -/
theorem LipschitzOnWith.mono (hf : LipschitzOnWith K f t) (h : s ⊆ t) : LipschitzOnWith K f s 
goal: LipschitzOnWith K f s

full_name: LocallyLipschitzOn.mono
code: lemma LocallyLipschitzOn.mono (hf : LocallyLipschitzOn t f) (h : s ⊆ t) : LocallyLipschitzOn s f 
goal: LocallyLipschitzOn s f

full_name: lipschitzOnWith_univ
code: /-- `f` is Lipschitz iff it is Lipschitz on the entire space. -/
@[simp] lemma lipschitzOnWith_univ : LipschitzOnWith K f univ ↔ LipschitzWith K f 
goal: LipschitzOnWith K f Set.univ ↔ LipschitzWith K f

full_name: locallyLipschitzOn_univ
code: @[simp] lemma locallyLipschitzOn_univ : LocallyLipschitzOn univ f ↔ LocallyLipschitz f 
goal: LocallyLipschitzOn Set.univ f ↔ LocallyLipschitz f

full_name: lipschitzOnWith_iff_restrict
code: theorem lipschitzOnWith_iff_restrict : LipschitzOnWith K f s ↔ LipschitzWith K (s.restrict f) 
goal: LipschitzOnWith K f s ↔ LipschitzWith K (s.restrict f)

full_name: lipschitzOnWith_restrict
code: lemma lipschitzOnWith_restrict {t : Set s} :
    LipschitzOnWith K (s.restrict f) t ↔ LipschitzOnWith K f (s ∩ Subtype.val '' t) 
goal: LipschitzOnWith K (s.restrict f) t ↔ LipschitzOnWith K f (s ∩ Subtype.val '' t)

full_name: locallyLipschitzOn_iff_restrict
code: lemma locallyLipschitzOn_iff_restrict :
    LocallyLipschitzOn s f ↔ LocallyLipschitz (s.restrict f) 
goal: LocallyLipschitzOn s f ↔ LocallyLipschitz (s.restrict f)

full_name: Set.MapsTo.lipschitzOnWith_iff_restrict
code: lemma Set.MapsTo.lipschitzOnWith_iff_restrict {t : Set β} (h : MapsTo f s t) :
    LipschitzOnWith K f s ↔ LipschitzWith K (h.restrict f s t) 
goal: LipschitzOnWith K f s ↔ LipschitzWith K (Set.MapsTo.restrict f s t h)

full_name: LipschitzWith.lipschitzOnWith
code: protected theorem lipschitzOnWith (h : LipschitzWith K f) (s : Set α) : LipschitzOnWith K f s 
goal: LipschitzOnWith K f s

full_name: LipschitzWith.edist_le_mul
code: theorem edist_le_mul (h : LipschitzWith K f) (x y : α) : edist (f x) (f y) ≤ K * edist x y 
goal: edist (f x) (f y) ≤ ↑K * edist x y

full_name: LipschitzWith.edist_le_mul_of_le
code: theorem edist_le_mul_of_le (h : LipschitzWith K f) (hr : edist x y ≤ r) :
    edist (f x) (f y) ≤ K * r 
goal: edist (f x) (f y) ≤ ↑K * r

full_name: LipschitzWith.edist_lt_mul_of_lt
code: theorem edist_lt_mul_of_lt (h : LipschitzWith K f) (hK : K ≠ 0) (hr : edist x y < r) :
    edist (f x) (f y) < K * r 
goal: edist (f x) (f y) < ↑K * r

full_name: LipschitzWith.mapsTo_emetric_closedBall
code: theorem mapsTo_emetric_closedBall (h : LipschitzWith K f) (x : α) (r : ℝ≥0∞) :
    MapsTo f (closedBall x r) (closedBall (f x) (K * r)) 
goal: Set.MapsTo f (EMetric.closedBall x r) (EMetric.closedBall (f x) (↑K * r))

full_name: LipschitzWith.mapsTo_emetric_ball
code: theorem mapsTo_emetric_ball (h : LipschitzWith K f) (hK : K ≠ 0) (x : α) (r : ℝ≥0∞) :
    MapsTo f (ball x r) (ball (f x) (K * r)) 
goal: Set.MapsTo f (EMetric.ball x r) (EMetric.ball (f x) (↑K * r))

full_name: LipschitzWith.edist_lt_top
code: theorem edist_lt_top (hf : LipschitzWith K f) {x y : α} (h : edist x y ≠ ⊤) :
    edist (f x) (f y) < ⊤ 
goal: edist (f x) (f y) < ⊤

full_name: LipschitzWith.mul_edist_le
code: theorem mul_edist_le (h : LipschitzWith K f) (x y : α) :
    (K⁻¹ : ℝ≥0∞) * edist (f x) (f y) ≤ edist x y 
goal: (↑K)⁻¹ * edist (f x) (f y) ≤ edist x y

full_name: LipschitzWith.of_edist_le
code: protected theorem of_edist_le (h : ∀ x y, edist (f x) (f y) ≤ edist x y) : LipschitzWith 1 f 
goal: LipschitzWith 1 f

full_name: LipschitzWith.weaken
code: protected theorem weaken (hf : LipschitzWith K f) {K' : ℝ≥0} (h : K ≤ K') : LipschitzWith K' f 
goal: LipschitzWith K' f

full_name: LipschitzWith.ediam_image_le
code: theorem ediam_image_le (hf : LipschitzWith K f) (s : Set α) :
    EMetric.diam (f '' s) ≤ K * EMetric.diam s 
goal: EMetric.diam (f '' s) ≤ ↑K * EMetric.diam s

full_name: LipschitzWith.edist_lt_of_edist_lt_div
code: theorem edist_lt_of_edist_lt_div (hf : LipschitzWith K f) {x y : α} {d : ℝ≥0∞}
    (h : edist x y < d / K) : edist (f x) (f y) < d 
goal: edist (f x) (f y) < d

full_name: LipschitzWith.uniformContinuous
code: /-- A Lipschitz function is uniformly continuous. -/
protected theorem uniformContinuous (hf : LipschitzWith K f) : UniformContinuous f 
goal: UniformContinuous f

full_name: LipschitzWith.continuous
code: /-- A Lipschitz function is continuous. -/
protected theorem continuous (hf : LipschitzWith K f) : Continuous f 
goal: Continuous f

full_name: LipschitzWith.const
code: /-- Constant functions are Lipschitz (with any constant). -/
protected theorem const (b : β) : LipschitzWith 0 fun _ : α => b 
goal: LipschitzWith 0 fun x => b

full_name: LipschitzWith.const'
code: protected theorem const' (b : β) {K : ℝ≥0} : LipschitzWith K fun _ : α => b 
goal: LipschitzWith K fun x => b

full_name: LipschitzWith.id
code: /-- The identity is 1-Lipschitz. -/
protected theorem id : LipschitzWith 1 (@id α) 
goal: LipschitzWith 1 id

full_name: LipschitzWith.subtype_val
code: /-- The inclusion of a subset is 1-Lipschitz. -/
protected theorem subtype_val (s : Set α) : LipschitzWith 1 (Subtype.val : s → α) 
goal: LipschitzWith 1 Subtype.val

full_name: LipschitzWith.subtype_mk
code: theorem subtype_mk (hf : LipschitzWith K f) {p : β → Prop} (hp : ∀ x, p (f x)) :
    LipschitzWith K (fun x => ⟨f x, hp x⟩ : α → { y // p y }) 
goal: LipschitzWith K fun x => ⟨f x, ⋯⟩

full_name: LipschitzWith.eval
code: protected theorem eval {α : ι → Type u} [∀ i, PseudoEMetricSpace (α i)] [Fintype ι] (i : ι) :
    LipschitzWith 1 (Function.eval i : (∀ i, α i) → α i) 
goal: LipschitzWith 1 (Function.eval i)

full_name: LipschitzWith.restrict
code: /-- The restriction of a `K`-Lipschitz function is `K`-Lipschitz. -/
protected theorem restrict (hf : LipschitzWith K f) (s : Set α) : LipschitzWith K (s.restrict f) 
goal: LipschitzWith K (s.restrict f)

full_name: LipschitzWith.comp
code: /-- The composition of Lipschitz functions is Lipschitz. -/
protected theorem comp {Kf Kg : ℝ≥0} {f : β → γ} {g : α → β} (hf : LipschitzWith Kf f)
    (hg : LipschitzWith Kg g) : LipschitzWith (Kf * Kg) (f ∘ g) 
goal: LipschitzWith (Kf * Kg) (f ∘ g)

full_name: LipschitzWith.comp_lipschitzOnWith
code: theorem comp_lipschitzOnWith {Kf Kg : ℝ≥0} {f : β → γ} {g : α → β} {s : Set α}
    (hf : LipschitzWith Kf f) (hg : LipschitzOnWith Kg g s) : LipschitzOnWith (Kf * Kg) (f ∘ g) s 
goal: LipschitzOnWith (Kf * Kg) (f ∘ g) s

full_name: LipschitzWith.prod_fst
code: protected theorem prod_fst : LipschitzWith 1 (@Prod.fst α β) 
goal: LipschitzWith 1 Prod.fst

full_name: LipschitzWith.prod_snd
code: protected theorem prod_snd : LipschitzWith 1 (@Prod.snd α β) 
goal: LipschitzWith 1 Prod.snd

full_name: LipschitzWith.prod
code: /-- If `f` and `g` are Lipschitz functions, so is the induced map `f × g` to the product type. -/
protected theorem prod {f : α → β} {Kf : ℝ≥0} (hf : LipschitzWith Kf f) {g : α → γ} {Kg : ℝ≥0}
    (hg : LipschitzWith Kg g) : LipschitzWith (max Kf Kg) fun x => (f x, g x) 
goal: LipschitzWith (max Kf Kg) fun x => (f x, g x)

full_name: LipschitzWith.prod_mk_left
code: protected theorem prod_mk_left (a : α) : LipschitzWith 1 (Prod.mk a : β → α × β) 
goal: LipschitzWith 1 (Prod.mk a)

full_name: LipschitzWith.prod_mk_right
code: protected theorem prod_mk_right (b : β) : LipschitzWith 1 fun a : α => (a, b) 
goal: LipschitzWith 1 fun a => (a, b)

full_name: LipschitzWith.uncurry
code: protected theorem uncurry {f : α → β → γ} {Kα Kβ : ℝ≥0} (hα : ∀ b, LipschitzWith Kα fun a => f a b)
    (hβ : ∀ a, LipschitzWith Kβ (f a)) : LipschitzWith (Kα + Kβ) (Function.uncurry f) 
goal: LipschitzWith (Kα + Kβ) (Function.uncurry f)

full_name: LipschitzWith.iterate
code: /-- Iterates of a Lipschitz function are Lipschitz. -/
protected theorem iterate {f : α → α} (hf : LipschitzWith K f) : ∀ n, LipschitzWith (K ^ n) f^[n]
  
goal: LipschitzWith (K ^ n) f^[n]

full_name: LipschitzWith.edist_iterate_succ_le_geometric
code: theorem edist_iterate_succ_le_geometric {f : α → α} (hf : LipschitzWith K f) (x n) :
    edist (f^[n] x) (f^[n + 1] x) ≤ edist x (f x) * (K : ℝ≥0∞) ^ n 
goal: edist (f^[n] x) (f^[n + 1] x) ≤ edist x (f x) * ↑K ^ n

full_name: LipschitzWith.mul_end
code: protected theorem mul_end {f g : Function.End α} {Kf Kg} (hf : LipschitzWith Kf f)
    (hg : LipschitzWith Kg g) : LipschitzWith (Kf * Kg) (f * g : Function.End α) 
goal: LipschitzWith (Kf * Kg) (f * g)

full_name: LipschitzWith.list_prod
code: /-- The product of a list of Lipschitz continuous endomorphisms is a Lipschitz continuous
endomorphism. -/
protected theorem list_prod (f : ι → Function.End α) (K : ι → ℝ≥0)
    (h : ∀ i, LipschitzWith (K i) (f i)) : ∀ l : List ι, LipschitzWith (l.map K).prod (l.map f).prod
  
goal: LipschitzWith (List.map K l).prod (List.map f l).prod

full_name: LipschitzWith.pow_end
code: protected theorem pow_end {f : Function.End α} {K} (h : LipschitzWith K f) :
    ∀ n : ℕ, LipschitzWith (K ^ n) (f ^ n : Function.End α)
  
goal: LipschitzWith (K ^ n) (f ^ n)

full_name: LipschitzOnWith.uniformContinuousOn
code: protected theorem uniformContinuousOn (hf : LipschitzOnWith K f s) : UniformContinuousOn f s 
goal: UniformContinuousOn f s

full_name: LipschitzOnWith.continuousOn
code: protected theorem continuousOn (hf : LipschitzOnWith K f s) : ContinuousOn f s 
goal: ContinuousOn f s

full_name: LipschitzOnWith.edist_le_mul_of_le
code: theorem edist_le_mul_of_le (h : LipschitzOnWith K f s) {x y : α} (hx : x ∈ s) (hy : y ∈ s)
    {r : ℝ≥0∞} (hr : edist x y ≤ r) :
    edist (f x) (f y) ≤ K * r 
goal: edist (f x) (f y) ≤ ↑K * r

full_name: LipschitzOnWith.edist_lt_of_edist_lt_div
code: theorem edist_lt_of_edist_lt_div (hf : LipschitzOnWith K f s) {x y : α} (hx : x ∈ s) (hy : y ∈ s)
    {d : ℝ≥0∞} (hd : edist x y < d / K) : edist (f x) (f y) < d 
goal: edist (f x) (f y) < d

full_name: LipschitzOnWith.comp
code: protected theorem comp {g : β → γ} {t : Set β} {Kg : ℝ≥0} (hg : LipschitzOnWith Kg g t)
    (hf : LipschitzOnWith K f s) (hmaps : MapsTo f s t) : LipschitzOnWith (Kg * K) (g ∘ f) s 
goal: LipschitzOnWith (Kg * K) (g ∘ f) s

full_name: LipschitzOnWith.prod
code: /-- If `f` and `g` are Lipschitz on `s`, so is the induced map `f × g` to the product type. -/
protected theorem prod {g : α → γ} {Kf Kg : ℝ≥0} (hf : LipschitzOnWith Kf f s)
    (hg : LipschitzOnWith Kg g s) : LipschitzOnWith (max Kf Kg) (fun x => (f x, g x)) s 
goal: LipschitzOnWith (max Kf Kg) (fun x => (f x, g x)) s

full_name: LipschitzOnWith.ediam_image2_le
code: theorem ediam_image2_le (f : α → β → γ) {K₁ K₂ : ℝ≥0} (s : Set α) (t : Set β)
    (hf₁ : ∀ b ∈ t, LipschitzOnWith K₁ (f · b) s) (hf₂ : ∀ a ∈ s, LipschitzOnWith K₂ (f a) t) :
    EMetric.diam (Set.image2 f s t) ≤ ↑K₁ * EMetric.diam s + ↑K₂ * EMetric.diam t 
goal: EMetric.diam (Set.image2 f s t) ≤ ↑K₁ * EMetric.diam s + ↑K₂ * EMetric.diam t

full_name: LipschitzWith.locallyLipschitz
code: /-- A Lipschitz function is locally Lipschitz. -/
protected lemma _root_.LipschitzWith.locallyLipschitz {K : ℝ≥0} (hf : LipschitzWith K f) :
    LocallyLipschitz f 
goal: LocallyLipschitz f

full_name: LocallyLipschitz.id
code: /-- The identity function is locally Lipschitz. -/
protected lemma id : LocallyLipschitz (@id α) 
goal: LocallyLipschitz id

full_name: LocallyLipschitz.const
code: /-- Constant functions are locally Lipschitz. -/
protected lemma const (b : β) : LocallyLipschitz (fun _ : α ↦ b) 
goal: LocallyLipschitz fun x => b

full_name: LocallyLipschitz.continuous
code: /-- A locally Lipschitz function is continuous. (The converse is false: for example,
$x ↦ \sqrt{x}$ is continuous, but not locally Lipschitz at 0.) -/
protected theorem continuous {f : α → β} (hf : LocallyLipschitz f) : Continuous f 
goal: Continuous f

full_name: LocallyLipschitz.comp
code: /-- The composition of locally Lipschitz functions is locally Lipschitz. --/
protected lemma comp  {f : β → γ} {g : α → β}
    (hf : LocallyLipschitz f) (hg : LocallyLipschitz g) : LocallyLipschitz (f ∘ g) 
goal: LocallyLipschitz (f ∘ g)

full_name: LocallyLipschitz.prod
code: /-- If `f` and `g` are locally Lipschitz, so is the induced map `f × g` to the product type. -/
protected lemma prod {f : α → β} (hf : LocallyLipschitz f) {g : α → γ} (hg : LocallyLipschitz g) :
    LocallyLipschitz fun x => (f x, g x) 
goal: LocallyLipschitz fun x => (f x, g x)

full_name: LocallyLipschitz.prod_mk_left
code: protected theorem prod_mk_left (a : α) : LocallyLipschitz (Prod.mk a : β → α × β) 
goal: LocallyLipschitz (Prod.mk a)

full_name: LocallyLipschitz.prod_mk_right
code: protected theorem prod_mk_right (b : β) : LocallyLipschitz (fun a : α => (a, b)) 
goal: LocallyLipschitz fun a => (a, b)

full_name: LocallyLipschitz.iterate
code: protected theorem iterate {f : α → α} (hf : LocallyLipschitz f) : ∀ n, LocallyLipschitz f^[n]
  
goal: LocallyLipschitz f^[n]

full_name: LocallyLipschitz.mul_end
code: protected theorem mul_end {f g : Function.End α} (hf : LocallyLipschitz f)
    (hg : LocallyLipschitz g) : LocallyLipschitz (f * g : Function.End α) 
goal: LocallyLipschitz (f * g)

full_name: LocallyLipschitz.pow_end
code: protected theorem pow_end {f : Function.End α} (h : LocallyLipschitz f) :
    ∀ n : ℕ, LocallyLipschitz (f ^ n : Function.End α)
  
goal: LocallyLipschitz (f ^ n)

full_name: LocallyLipschitzOn.continuousOn
code: protected lemma continuousOn (hf : LocallyLipschitzOn s f) : ContinuousOn f s 
goal: ContinuousOn f s

full_name: continuousOn_prod_of_subset_closure_continuousOn_lipschitzOnWith
code: /-- Consider a function `f : α × β → γ`. Suppose that it is continuous on each “vertical fiber”
`{a} × t`, `a ∈ s`, and is Lipschitz continuous on each “horizontal fiber” `s × {b}`, `b ∈ t`
with the same Lipschitz constant `K`. Then it is continuous on `s × t`. Moreover, it suffices
to require continuity on vertical fibers for `a` from a subset `s' ⊆ s` that is dense in `s`.

The actual statement uses (Lipschitz) continuity of `fun y ↦ f (a, y)` and `fun x ↦ f (x, b)`
instead of continuity of `f` on subsets of the product space. -/
theorem continuousOn_prod_of_subset_closure_continuousOn_lipschitzOnWith [PseudoEMetricSpace α]
    [TopologicalSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) {s s' : Set α} {t : Set β}
    (hs' : s' ⊆ s) (hss' : s ⊆ closure s') (K : ℝ≥0)
    (ha : ∀ a ∈ s', ContinuousOn (fun y => f (a, y)) t)
    (hb : ∀ b ∈ t, LipschitzOnWith K (fun x => f (x, b)) s) : ContinuousOn f (s ×ˢ t) 
goal: ContinuousOn f (s ×ˢ t)

full_name: continuousOn_prod_of_continuousOn_lipschitzOnWith
code: /-- Consider a function `f : α × β → γ`. Suppose that it is continuous on each “vertical fiber”
`{a} × t`, `a ∈ s`, and is Lipschitz continuous on each “horizontal fiber” `s × {b}`, `b ∈ t`
with the same Lipschitz constant `K`. Then it is continuous on `s × t`.

The actual statement uses (Lipschitz) continuity of `fun y ↦ f (a, y)` and `fun x ↦ f (x, b)`
instead of continuity of `f` on subsets of the product space. -/
theorem continuousOn_prod_of_continuousOn_lipschitzOnWith [PseudoEMetricSpace α]
    [TopologicalSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) {s : Set α} {t : Set β} (K : ℝ≥0)
    (ha : ∀ a ∈ s, ContinuousOn (fun y => f (a, y)) t)
    (hb : ∀ b ∈ t, LipschitzOnWith K (fun x => f (x, b)) s) : ContinuousOn f (s ×ˢ t) 
goal: ContinuousOn f (s ×ˢ t)

full_name: continuous_prod_of_dense_continuous_lipschitzWith
code: /-- Consider a function `f : α × β → γ`. Suppose that it is continuous on each “vertical section”
`{a} × univ` for `a : α` from a dense set. Suppose that it is Lipschitz continuous on each
“horizontal section” `univ × {b}`, `b : β` with the same Lipschitz constant `K`. Then it is
continuous.

The actual statement uses (Lipschitz) continuity of `fun y ↦ f (a, y)` and `fun x ↦ f (x, b)`
instead of continuity of `f` on subsets of the product space. -/
theorem continuous_prod_of_dense_continuous_lipschitzWith [PseudoEMetricSpace α]
    [TopologicalSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) (K : ℝ≥0) {s : Set α}
    (hs : Dense s) (ha : ∀ a ∈ s, Continuous fun y => f (a, y))
    (hb : ∀ b, LipschitzWith K fun x => f (x, b)) : Continuous f 
goal: Continuous f

full_name: continuous_prod_of_continuous_lipschitzWith
code: /-- Consider a function `f : α × β → γ`. Suppose that it is continuous on each “vertical section”
`{a} × univ`, `a : α`, and is Lipschitz continuous on each “horizontal section”
`univ × {b}`, `b : β` with the same Lipschitz constant `K`. Then it is continuous.

The actual statement uses (Lipschitz) continuity of `fun y ↦ f (a, y)` and `fun x ↦ f (x, b)`
instead of continuity of `f` on subsets of the product space. -/
theorem continuous_prod_of_continuous_lipschitzWith [PseudoEMetricSpace α] [TopologicalSpace β]
    [PseudoEMetricSpace γ] (f : α × β → γ) (K : ℝ≥0) (ha : ∀ a, Continuous fun y => f (a, y))
    (hb : ∀ b, LipschitzWith K fun x => f (x, b)) : Continuous f 
goal: Continuous f