Context stringlengths 295 65.3k | file_name stringlengths 21 74 | start int64 14 1.41k | end int64 20 1.41k | theorem stringlengths 27 1.42k | proof stringlengths 0 4.57k |
|---|---|---|---|---|---|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Power function on `ℝ≥0` and `ℝ≥0∞`
We construct the power functions `x ^ y` where
* `x` is a nonnegative real number and `y` is a real number;
* `x` is a number from `[0, +∞]` (a.k.a. `ℝ≥0∞`) and `y` is a real number.
We also prove basic properties of these functions.
-/
noncomputable section
open Real NNReal ENNReal ComplexConjugate Finset Function Set
namespace NNReal
variable {x : ℝ≥0} {w y z : ℝ}
/-- The nonnegative real power function `x^y`, defined for `x : ℝ≥0` and `y : ℝ` as the
restriction of the real power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`,
one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y ≠ 0`. -/
noncomputable def rpow (x : ℝ≥0) (y : ℝ) : ℝ≥0 :=
⟨(x : ℝ) ^ y, Real.rpow_nonneg x.2 y⟩
noncomputable instance : Pow ℝ≥0 ℝ :=
⟨rpow⟩
@[simp]
theorem rpow_eq_pow (x : ℝ≥0) (y : ℝ) : rpow x y = x ^ y :=
rfl
@[simp, norm_cast]
theorem coe_rpow (x : ℝ≥0) (y : ℝ) : ((x ^ y : ℝ≥0) : ℝ) = (x : ℝ) ^ y :=
rfl
@[simp]
theorem rpow_zero (x : ℝ≥0) : x ^ (0 : ℝ) = 1 :=
NNReal.eq <| Real.rpow_zero _
@[simp]
theorem rpow_eq_zero_iff {x : ℝ≥0} {y : ℝ} : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by
rw [← NNReal.coe_inj, coe_rpow, ← NNReal.coe_eq_zero]
exact Real.rpow_eq_zero_iff_of_nonneg x.2
lemma rpow_eq_zero (hy : y ≠ 0) : x ^ y = 0 ↔ x = 0 := by simp [hy]
@[simp]
theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ≥0) ^ x = 0 :=
NNReal.eq <| Real.zero_rpow h
@[simp]
theorem rpow_one (x : ℝ≥0) : x ^ (1 : ℝ) = x :=
NNReal.eq <| Real.rpow_one _
lemma rpow_neg (x : ℝ≥0) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ :=
NNReal.eq <| Real.rpow_neg x.2 _
@[simp, norm_cast]
lemma rpow_natCast (x : ℝ≥0) (n : ℕ) : x ^ (n : ℝ) = x ^ n :=
NNReal.eq <| by simpa only [coe_rpow, coe_pow] using Real.rpow_natCast x n
@[simp, norm_cast]
lemma rpow_intCast (x : ℝ≥0) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by
cases n <;> simp only [Int.ofNat_eq_coe, Int.cast_natCast, rpow_natCast, zpow_natCast,
Int.cast_negSucc, rpow_neg, zpow_negSucc]
@[simp]
theorem one_rpow (x : ℝ) : (1 : ℝ≥0) ^ x = 1 :=
NNReal.eq <| Real.one_rpow _
theorem rpow_add {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hx) _ _
theorem rpow_add' (h : y + z ≠ 0) (x : ℝ≥0) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add' x.2 h
lemma rpow_add_intCast (hx : x ≠ 0) (y : ℝ) (n : ℤ) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_intCast (mod_cast hx) _ _
lemma rpow_add_natCast (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_natCast (mod_cast hx) _ _
lemma rpow_sub_intCast (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_intCast (mod_cast hx) _ _
lemma rpow_sub_natCast (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_natCast (mod_cast hx) _ _
lemma rpow_add_intCast' {n : ℤ} (h : y + n ≠ 0) (x : ℝ≥0) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_intCast' (mod_cast x.2) h
lemma rpow_add_natCast' {n : ℕ} (h : y + n ≠ 0) (x : ℝ≥0) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_natCast' (mod_cast x.2) h
lemma rpow_sub_intCast' {n : ℤ} (h : y - n ≠ 0) (x : ℝ≥0) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_intCast' (mod_cast x.2) h
lemma rpow_sub_natCast' {n : ℕ} (h : y - n ≠ 0) (x : ℝ≥0) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_natCast' (mod_cast x.2) h
lemma rpow_add_one (hx : x ≠ 0) (y : ℝ) : x ^ (y + 1) = x ^ y * x := by
simpa using rpow_add_natCast hx y 1
lemma rpow_sub_one (hx : x ≠ 0) (y : ℝ) : x ^ (y - 1) = x ^ y / x := by
simpa using rpow_sub_natCast hx y 1
lemma rpow_add_one' (h : y + 1 ≠ 0) (x : ℝ≥0) : x ^ (y + 1) = x ^ y * x := by
rw [rpow_add' h, rpow_one]
lemma rpow_one_add' (h : 1 + y ≠ 0) (x : ℝ≥0) : x ^ (1 + y) = x * x ^ y := by
rw [rpow_add' h, rpow_one]
theorem rpow_add_of_nonneg (x : ℝ≥0) {y z : ℝ} (hy : 0 ≤ y) (hz : 0 ≤ z) :
x ^ (y + z) = x ^ y * x ^ z := by
ext; exact Real.rpow_add_of_nonneg x.2 hy hz
/-- Variant of `NNReal.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (x : ℝ≥0) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [← h, rpow_add']; rwa [h]
| Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean | 128 | 131 | theorem rpow_mul (x : ℝ≥0) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z :=
NNReal.eq <| Real.rpow_mul x.2 y z
lemma rpow_natCast_mul (x : ℝ≥0) (n : ℕ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by | |
/-
Copyright (c) 2019 Gabriel Ebner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner, Sébastien Gouëzel
-/
import Mathlib.Analysis.Calculus.FDeriv.Basic
import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace
/-!
# One-dimensional derivatives
This file defines the derivative of a function `f : 𝕜 → F` where `𝕜` is a
normed field and `F` is a normed space over this field. The derivative of
such a function `f` at a point `x` is given by an element `f' : F`.
The theory is developed analogously to the [Fréchet
derivatives](./fderiv.html). We first introduce predicates defined in terms
of the corresponding predicates for Fréchet derivatives:
- `HasDerivAtFilter f f' x L` states that the function `f` has the
derivative `f'` at the point `x` as `x` goes along the filter `L`.
- `HasDerivWithinAt f f' s x` states that the function `f` has the
derivative `f'` at the point `x` within the subset `s`.
- `HasDerivAt f f' x` states that the function `f` has the derivative `f'`
at the point `x`.
- `HasStrictDerivAt f f' x` states that the function `f` has the derivative `f'`
at the point `x` in the sense of strict differentiability, i.e.,
`f y - f z = (y - z) • f' + o (y - z)` as `y, z → x`.
For the last two notions we also define a functional version:
- `derivWithin f s x` is a derivative of `f` at `x` within `s`. If the
derivative does not exist, then `derivWithin f s x` equals zero.
- `deriv f x` is a derivative of `f` at `x`. If the derivative does not
exist, then `deriv f x` equals zero.
The theorems `fderivWithin_derivWithin` and `fderiv_deriv` show that the
one-dimensional derivatives coincide with the general Fréchet derivatives.
We also show the existence and compute the derivatives of:
- constants
- the identity function
- linear maps (in `Linear.lean`)
- addition (in `Add.lean`)
- sum of finitely many functions (in `Add.lean`)
- negation (in `Add.lean`)
- subtraction (in `Add.lean`)
- star (in `Star.lean`)
- multiplication of two functions in `𝕜 → 𝕜` (in `Mul.lean`)
- multiplication of a function in `𝕜 → 𝕜` and of a function in `𝕜 → E` (in `Mul.lean`)
- powers of a function (in `Pow.lean` and `ZPow.lean`)
- inverse `x → x⁻¹` (in `Inv.lean`)
- division (in `Inv.lean`)
- composition of a function in `𝕜 → F` with a function in `𝕜 → 𝕜` (in `Comp.lean`)
- composition of a function in `F → E` with a function in `𝕜 → F` (in `Comp.lean`)
- inverse function (assuming that it exists; the inverse function theorem is in `Inverse.lean`)
- polynomials (in `Polynomial.lean`)
For most binary operations we also define `const_op` and `op_const` theorems for the cases when
the first or second argument is a constant. This makes writing chains of `HasDerivAt`'s easier,
and they more frequently lead to the desired result.
We set up the simplifier so that it can compute the derivative of simple functions. For instance,
```lean
example (x : ℝ) :
deriv (fun x ↦ cos (sin x) * exp x) x = (cos (sin x) - sin (sin x) * cos x) * exp x := by
simp; ring
```
The relationship between the derivative of a function and its definition from a standard
undergraduate course as the limit of the slope `(f y - f x) / (y - x)` as `y` tends to `𝓝[≠] x`
is developed in the file `Slope.lean`.
## Implementation notes
Most of the theorems are direct restatements of the corresponding theorems
for Fréchet derivatives.
The strategy to construct simp lemmas that give the simplifier the possibility to compute
derivatives is the same as the one for differentiability statements, as explained in
`FDeriv/Basic.lean`. See the explanations there.
-/
universe u v w
noncomputable section
open scoped Topology ENNReal NNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
section TVS
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F]
section
variable [ContinuousSMul 𝕜 F]
/-- `f` has the derivative `f'` at the point `x` as `x` goes along the filter `L`.
That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges along the filter `L`.
-/
def HasDerivAtFilter (f : 𝕜 → F) (f' : F) (x : 𝕜) (L : Filter 𝕜) :=
HasFDerivAtFilter f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') x L
/-- `f` has the derivative `f'` at the point `x` within the subset `s`.
That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges to `x` inside `s`.
-/
def HasDerivWithinAt (f : 𝕜 → F) (f' : F) (s : Set 𝕜) (x : 𝕜) :=
HasDerivAtFilter f f' x (𝓝[s] x)
/-- `f` has the derivative `f'` at the point `x`.
That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges to `x`.
-/
def HasDerivAt (f : 𝕜 → F) (f' : F) (x : 𝕜) :=
HasDerivAtFilter f f' x (𝓝 x)
/-- `f` has the derivative `f'` at the point `x` in the sense of strict differentiability.
That is, `f y - f z = (y - z) • f' + o(y - z)` as `y, z → x`. -/
def HasStrictDerivAt (f : 𝕜 → F) (f' : F) (x : 𝕜) :=
HasStrictFDerivAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') x
end
/-- Derivative of `f` at the point `x` within the set `s`, if it exists. Zero otherwise.
If the derivative exists (i.e., `∃ f', HasDerivWithinAt f f' s x`), then
`f x' = f x + (x' - x) • derivWithin f s x + o(x' - x)` where `x'` converges to `x` inside `s`.
-/
def derivWithin (f : 𝕜 → F) (s : Set 𝕜) (x : 𝕜) :=
fderivWithin 𝕜 f s x 1
/-- Derivative of `f` at the point `x`, if it exists. Zero otherwise.
If the derivative exists (i.e., `∃ f', HasDerivAt f f' x`), then
`f x' = f x + (x' - x) • deriv f x + o(x' - x)` where `x'` converges to `x`.
-/
def deriv (f : 𝕜 → F) (x : 𝕜) :=
fderiv 𝕜 f x 1
variable {f f₀ f₁ : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L L₁ L₂ : Filter 𝕜}
section
variable [ContinuousSMul 𝕜 F]
/-- Expressing `HasFDerivAtFilter f f' x L` in terms of `HasDerivAtFilter` -/
theorem hasFDerivAtFilter_iff_hasDerivAtFilter {f' : 𝕜 →L[𝕜] F} :
HasFDerivAtFilter f f' x L ↔ HasDerivAtFilter f (f' 1) x L := by simp [HasDerivAtFilter]
theorem HasFDerivAtFilter.hasDerivAtFilter {f' : 𝕜 →L[𝕜] F} :
HasFDerivAtFilter f f' x L → HasDerivAtFilter f (f' 1) x L :=
hasFDerivAtFilter_iff_hasDerivAtFilter.mp
/-- Expressing `HasFDerivWithinAt f f' s x` in terms of `HasDerivWithinAt` -/
theorem hasFDerivWithinAt_iff_hasDerivWithinAt {f' : 𝕜 →L[𝕜] F} :
HasFDerivWithinAt f f' s x ↔ HasDerivWithinAt f (f' 1) s x :=
hasFDerivAtFilter_iff_hasDerivAtFilter
/-- Expressing `HasDerivWithinAt f f' s x` in terms of `HasFDerivWithinAt` -/
theorem hasDerivWithinAt_iff_hasFDerivWithinAt {f' : F} :
HasDerivWithinAt f f' s x ↔ HasFDerivWithinAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') s x :=
Iff.rfl
theorem HasFDerivWithinAt.hasDerivWithinAt {f' : 𝕜 →L[𝕜] F} :
HasFDerivWithinAt f f' s x → HasDerivWithinAt f (f' 1) s x :=
hasFDerivWithinAt_iff_hasDerivWithinAt.mp
theorem HasDerivWithinAt.hasFDerivWithinAt {f' : F} :
HasDerivWithinAt f f' s x → HasFDerivWithinAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') s x :=
hasDerivWithinAt_iff_hasFDerivWithinAt.mp
/-- Expressing `HasFDerivAt f f' x` in terms of `HasDerivAt` -/
theorem hasFDerivAt_iff_hasDerivAt {f' : 𝕜 →L[𝕜] F} : HasFDerivAt f f' x ↔ HasDerivAt f (f' 1) x :=
hasFDerivAtFilter_iff_hasDerivAtFilter
theorem HasFDerivAt.hasDerivAt {f' : 𝕜 →L[𝕜] F} : HasFDerivAt f f' x → HasDerivAt f (f' 1) x :=
hasFDerivAt_iff_hasDerivAt.mp
theorem hasStrictFDerivAt_iff_hasStrictDerivAt {f' : 𝕜 →L[𝕜] F} :
HasStrictFDerivAt f f' x ↔ HasStrictDerivAt f (f' 1) x := by
simp [HasStrictDerivAt, HasStrictFDerivAt]
protected theorem HasStrictFDerivAt.hasStrictDerivAt {f' : 𝕜 →L[𝕜] F} :
HasStrictFDerivAt f f' x → HasStrictDerivAt f (f' 1) x :=
hasStrictFDerivAt_iff_hasStrictDerivAt.mp
theorem hasStrictDerivAt_iff_hasStrictFDerivAt :
HasStrictDerivAt f f' x ↔ HasStrictFDerivAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') x :=
Iff.rfl
alias ⟨HasStrictDerivAt.hasStrictFDerivAt, _⟩ := hasStrictDerivAt_iff_hasStrictFDerivAt
/-- Expressing `HasDerivAt f f' x` in terms of `HasFDerivAt` -/
theorem hasDerivAt_iff_hasFDerivAt {f' : F} :
HasDerivAt f f' x ↔ HasFDerivAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') x :=
Iff.rfl
alias ⟨HasDerivAt.hasFDerivAt, _⟩ := hasDerivAt_iff_hasFDerivAt
end
theorem derivWithin_zero_of_not_differentiableWithinAt (h : ¬DifferentiableWithinAt 𝕜 f s x) :
derivWithin f s x = 0 := by
unfold derivWithin
rw [fderivWithin_zero_of_not_differentiableWithinAt h]
simp
theorem differentiableWithinAt_of_derivWithin_ne_zero (h : derivWithin f s x ≠ 0) :
DifferentiableWithinAt 𝕜 f s x :=
not_imp_comm.1 derivWithin_zero_of_not_differentiableWithinAt h
end TVS
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f f₀ f₁ : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L L₁ L₂ : Filter 𝕜}
theorem derivWithin_zero_of_not_accPt (h : ¬AccPt x (𝓟 s)) : derivWithin f s x = 0 := by
rw [derivWithin, fderivWithin_zero_of_not_accPt h, ContinuousLinearMap.zero_apply]
theorem derivWithin_zero_of_not_uniqueDiffWithinAt (h : ¬UniqueDiffWithinAt 𝕜 s x) :
derivWithin f s x = 0 :=
derivWithin_zero_of_not_accPt <| mt AccPt.uniqueDiffWithinAt h
set_option linter.deprecated false in
@[deprecated derivWithin_zero_of_not_accPt (since := "2025-04-20")]
theorem derivWithin_zero_of_isolated (h : 𝓝[s \ {x}] x = ⊥) : derivWithin f s x = 0 := by
rw [derivWithin, fderivWithin_zero_of_isolated h, ContinuousLinearMap.zero_apply]
theorem derivWithin_zero_of_nmem_closure (h : x ∉ closure s) : derivWithin f s x = 0 := by
rw [derivWithin, fderivWithin_zero_of_nmem_closure h, ContinuousLinearMap.zero_apply]
theorem deriv_zero_of_not_differentiableAt (h : ¬DifferentiableAt 𝕜 f x) : deriv f x = 0 := by
unfold deriv
rw [fderiv_zero_of_not_differentiableAt h]
simp
theorem differentiableAt_of_deriv_ne_zero (h : deriv f x ≠ 0) : DifferentiableAt 𝕜 f x :=
not_imp_comm.1 deriv_zero_of_not_differentiableAt h
theorem UniqueDiffWithinAt.eq_deriv (s : Set 𝕜) (H : UniqueDiffWithinAt 𝕜 s x)
(h : HasDerivWithinAt f f' s x) (h₁ : HasDerivWithinAt f f₁' s x) : f' = f₁' :=
smulRight_one_eq_iff.mp <| UniqueDiffWithinAt.eq H h h₁
theorem hasDerivAtFilter_iff_isLittleO :
HasDerivAtFilter f f' x L ↔ (fun x' : 𝕜 => f x' - f x - (x' - x) • f') =o[L] fun x' => x' - x :=
hasFDerivAtFilter_iff_isLittleO ..
theorem hasDerivAtFilter_iff_tendsto :
HasDerivAtFilter f f' x L ↔
Tendsto (fun x' : 𝕜 => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) L (𝓝 0) :=
hasFDerivAtFilter_iff_tendsto
theorem hasDerivWithinAt_iff_isLittleO :
HasDerivWithinAt f f' s x ↔
(fun x' : 𝕜 => f x' - f x - (x' - x) • f') =o[𝓝[s] x] fun x' => x' - x :=
hasFDerivAtFilter_iff_isLittleO ..
theorem hasDerivWithinAt_iff_tendsto :
HasDerivWithinAt f f' s x ↔
Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) (𝓝[s] x) (𝓝 0) :=
hasFDerivAtFilter_iff_tendsto
theorem hasDerivAt_iff_isLittleO :
HasDerivAt f f' x ↔ (fun x' : 𝕜 => f x' - f x - (x' - x) • f') =o[𝓝 x] fun x' => x' - x :=
hasFDerivAtFilter_iff_isLittleO ..
theorem hasDerivAt_iff_tendsto :
HasDerivAt f f' x ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) (𝓝 x) (𝓝 0) :=
hasFDerivAtFilter_iff_tendsto
theorem HasDerivAtFilter.isBigO_sub (h : HasDerivAtFilter f f' x L) :
(fun x' => f x' - f x) =O[L] fun x' => x' - x :=
HasFDerivAtFilter.isBigO_sub h
nonrec theorem HasDerivAtFilter.isBigO_sub_rev (hf : HasDerivAtFilter f f' x L) (hf' : f' ≠ 0) :
(fun x' => x' - x) =O[L] fun x' => f x' - f x :=
suffices AntilipschitzWith ‖f'‖₊⁻¹ (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') from hf.isBigO_sub_rev this
AddMonoidHomClass.antilipschitz_of_bound (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') fun x => by
simp [norm_smul, ← div_eq_inv_mul, mul_div_cancel_right₀ _ (mt norm_eq_zero.1 hf')]
theorem HasStrictDerivAt.hasDerivAt (h : HasStrictDerivAt f f' x) : HasDerivAt f f' x :=
h.hasFDerivAt
theorem hasDerivWithinAt_congr_set' {s t : Set 𝕜} (y : 𝕜) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
HasDerivWithinAt f f' s x ↔ HasDerivWithinAt f f' t x :=
hasFDerivWithinAt_congr_set' y h
theorem hasDerivWithinAt_congr_set {s t : Set 𝕜} (h : s =ᶠ[𝓝 x] t) :
HasDerivWithinAt f f' s x ↔ HasDerivWithinAt f f' t x :=
hasFDerivWithinAt_congr_set h
alias ⟨HasDerivWithinAt.congr_set, _⟩ := hasDerivWithinAt_congr_set
@[simp]
theorem hasDerivWithinAt_diff_singleton :
HasDerivWithinAt f f' (s \ {x}) x ↔ HasDerivWithinAt f f' s x :=
hasFDerivWithinAt_diff_singleton _
@[simp]
theorem hasDerivWithinAt_Ioi_iff_Ici [PartialOrder 𝕜] :
HasDerivWithinAt f f' (Ioi x) x ↔ HasDerivWithinAt f f' (Ici x) x := by
rw [← Ici_diff_left, hasDerivWithinAt_diff_singleton]
alias ⟨HasDerivWithinAt.Ici_of_Ioi, HasDerivWithinAt.Ioi_of_Ici⟩ := hasDerivWithinAt_Ioi_iff_Ici
@[simp]
theorem hasDerivWithinAt_Iio_iff_Iic [PartialOrder 𝕜] :
HasDerivWithinAt f f' (Iio x) x ↔ HasDerivWithinAt f f' (Iic x) x := by
rw [← Iic_diff_right, hasDerivWithinAt_diff_singleton]
alias ⟨HasDerivWithinAt.Iic_of_Iio, HasDerivWithinAt.Iio_of_Iic⟩ := hasDerivWithinAt_Iio_iff_Iic
theorem HasDerivWithinAt.Ioi_iff_Ioo [LinearOrder 𝕜] [OrderClosedTopology 𝕜] {x y : 𝕜} (h : x < y) :
HasDerivWithinAt f f' (Ioo x y) x ↔ HasDerivWithinAt f f' (Ioi x) x :=
hasFDerivWithinAt_inter <| Iio_mem_nhds h
alias ⟨HasDerivWithinAt.Ioi_of_Ioo, HasDerivWithinAt.Ioo_of_Ioi⟩ := HasDerivWithinAt.Ioi_iff_Ioo
theorem hasDerivAt_iff_isLittleO_nhds_zero :
HasDerivAt f f' x ↔ (fun h => f (x + h) - f x - h • f') =o[𝓝 0] fun h => h :=
hasFDerivAt_iff_isLittleO_nhds_zero
theorem HasDerivAtFilter.mono (h : HasDerivAtFilter f f' x L₂) (hst : L₁ ≤ L₂) :
HasDerivAtFilter f f' x L₁ :=
HasFDerivAtFilter.mono h hst
theorem HasDerivWithinAt.mono (h : HasDerivWithinAt f f' t x) (hst : s ⊆ t) :
HasDerivWithinAt f f' s x :=
HasFDerivWithinAt.mono h hst
theorem HasDerivWithinAt.mono_of_mem_nhdsWithin (h : HasDerivWithinAt f f' t x) (hst : t ∈ 𝓝[s] x) :
HasDerivWithinAt f f' s x :=
HasFDerivWithinAt.mono_of_mem_nhdsWithin h hst
@[deprecated (since := "2024-10-31")]
alias HasDerivWithinAt.mono_of_mem := HasDerivWithinAt.mono_of_mem_nhdsWithin
theorem HasDerivAt.hasDerivAtFilter (h : HasDerivAt f f' x) (hL : L ≤ 𝓝 x) :
HasDerivAtFilter f f' x L :=
HasFDerivAt.hasFDerivAtFilter h hL
theorem HasDerivAt.hasDerivWithinAt (h : HasDerivAt f f' x) : HasDerivWithinAt f f' s x :=
HasFDerivAt.hasFDerivWithinAt h
theorem HasDerivWithinAt.differentiableWithinAt (h : HasDerivWithinAt f f' s x) :
DifferentiableWithinAt 𝕜 f s x :=
HasFDerivWithinAt.differentiableWithinAt h
theorem HasDerivAt.differentiableAt (h : HasDerivAt f f' x) : DifferentiableAt 𝕜 f x :=
HasFDerivAt.differentiableAt h
@[simp]
theorem hasDerivWithinAt_univ : HasDerivWithinAt f f' univ x ↔ HasDerivAt f f' x :=
hasFDerivWithinAt_univ
theorem HasDerivAt.unique (h₀ : HasDerivAt f f₀' x) (h₁ : HasDerivAt f f₁' x) : f₀' = f₁' :=
smulRight_one_eq_iff.mp <| h₀.hasFDerivAt.unique h₁
theorem hasDerivWithinAt_inter' (h : t ∈ 𝓝[s] x) :
HasDerivWithinAt f f' (s ∩ t) x ↔ HasDerivWithinAt f f' s x :=
hasFDerivWithinAt_inter' h
theorem hasDerivWithinAt_inter (h : t ∈ 𝓝 x) :
HasDerivWithinAt f f' (s ∩ t) x ↔ HasDerivWithinAt f f' s x :=
hasFDerivWithinAt_inter h
theorem HasDerivWithinAt.union (hs : HasDerivWithinAt f f' s x) (ht : HasDerivWithinAt f f' t x) :
HasDerivWithinAt f f' (s ∪ t) x :=
hs.hasFDerivWithinAt.union ht.hasFDerivWithinAt
theorem HasDerivWithinAt.hasDerivAt (h : HasDerivWithinAt f f' s x) (hs : s ∈ 𝓝 x) :
HasDerivAt f f' x :=
HasFDerivWithinAt.hasFDerivAt h hs
theorem DifferentiableWithinAt.hasDerivWithinAt (h : DifferentiableWithinAt 𝕜 f s x) :
HasDerivWithinAt f (derivWithin f s x) s x :=
h.hasFDerivWithinAt.hasDerivWithinAt
theorem DifferentiableAt.hasDerivAt (h : DifferentiableAt 𝕜 f x) : HasDerivAt f (deriv f x) x :=
h.hasFDerivAt.hasDerivAt
@[simp]
theorem hasDerivAt_deriv_iff : HasDerivAt f (deriv f x) x ↔ DifferentiableAt 𝕜 f x :=
⟨fun h => h.differentiableAt, fun h => h.hasDerivAt⟩
@[simp]
theorem hasDerivWithinAt_derivWithin_iff :
HasDerivWithinAt f (derivWithin f s x) s x ↔ DifferentiableWithinAt 𝕜 f s x :=
⟨fun h => h.differentiableWithinAt, fun h => h.hasDerivWithinAt⟩
theorem DifferentiableOn.hasDerivAt (h : DifferentiableOn 𝕜 f s) (hs : s ∈ 𝓝 x) :
HasDerivAt f (deriv f x) x :=
(h.hasFDerivAt hs).hasDerivAt
theorem HasDerivAt.deriv (h : HasDerivAt f f' x) : deriv f x = f' :=
h.differentiableAt.hasDerivAt.unique h
theorem deriv_eq {f' : 𝕜 → F} (h : ∀ x, HasDerivAt f (f' x) x) : deriv f = f' :=
funext fun x => (h x).deriv
theorem HasDerivWithinAt.derivWithin (h : HasDerivWithinAt f f' s x)
(hxs : UniqueDiffWithinAt 𝕜 s x) : derivWithin f s x = f' :=
hxs.eq_deriv _ h.differentiableWithinAt.hasDerivWithinAt h
theorem fderivWithin_derivWithin : (fderivWithin 𝕜 f s x : 𝕜 → F) 1 = derivWithin f s x :=
rfl
theorem derivWithin_fderivWithin :
smulRight (1 : 𝕜 →L[𝕜] 𝕜) (derivWithin f s x) = fderivWithin 𝕜 f s x := by simp [derivWithin]
theorem norm_derivWithin_eq_norm_fderivWithin : ‖derivWithin f s x‖ = ‖fderivWithin 𝕜 f s x‖ := by
simp [← derivWithin_fderivWithin]
theorem fderiv_deriv : (fderiv 𝕜 f x : 𝕜 → F) 1 = deriv f x :=
rfl
@[simp]
theorem fderiv_eq_smul_deriv (y : 𝕜) : (fderiv 𝕜 f x : 𝕜 → F) y = y • deriv f x := by
rw [← fderiv_deriv, ← ContinuousLinearMap.map_smul]
simp only [smul_eq_mul, mul_one]
theorem deriv_fderiv : smulRight (1 : 𝕜 →L[𝕜] 𝕜) (deriv f x) = fderiv 𝕜 f x := by
simp only [deriv, ContinuousLinearMap.smulRight_one_one]
lemma fderiv_eq_deriv_mul {f : 𝕜 → 𝕜} {x y : 𝕜} : (fderiv 𝕜 f x : 𝕜 → 𝕜) y = (deriv f x) * y := by
simp [mul_comm]
theorem norm_deriv_eq_norm_fderiv : ‖deriv f x‖ = ‖fderiv 𝕜 f x‖ := by
simp [← deriv_fderiv]
theorem DifferentiableAt.derivWithin (h : DifferentiableAt 𝕜 f x) (hxs : UniqueDiffWithinAt 𝕜 s x) :
derivWithin f s x = deriv f x := by
unfold _root_.derivWithin deriv
rw [h.fderivWithin hxs]
theorem HasDerivWithinAt.deriv_eq_zero (hd : HasDerivWithinAt f 0 s x)
(H : UniqueDiffWithinAt 𝕜 s x) : deriv f x = 0 :=
(em' (DifferentiableAt 𝕜 f x)).elim deriv_zero_of_not_differentiableAt fun h =>
H.eq_deriv _ h.hasDerivAt.hasDerivWithinAt hd
theorem derivWithin_of_mem_nhdsWithin (st : t ∈ 𝓝[s] x) (ht : UniqueDiffWithinAt 𝕜 s x)
(h : DifferentiableWithinAt 𝕜 f t x) : derivWithin f s x = derivWithin f t x :=
((DifferentiableWithinAt.hasDerivWithinAt h).mono_of_mem_nhdsWithin st).derivWithin ht
@[deprecated (since := "2024-10-31")] alias derivWithin_of_mem := derivWithin_of_mem_nhdsWithin
theorem derivWithin_subset (st : s ⊆ t) (ht : UniqueDiffWithinAt 𝕜 s x)
(h : DifferentiableWithinAt 𝕜 f t x) : derivWithin f s x = derivWithin f t x :=
((DifferentiableWithinAt.hasDerivWithinAt h).mono st).derivWithin ht
theorem derivWithin_congr_set' (y : 𝕜) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
derivWithin f s x = derivWithin f t x := by simp only [derivWithin, fderivWithin_congr_set' y h]
theorem derivWithin_congr_set (h : s =ᶠ[𝓝 x] t) : derivWithin f s x = derivWithin f t x := by
simp only [derivWithin, fderivWithin_congr_set h]
@[simp]
theorem derivWithin_univ : derivWithin f univ = deriv f := by
ext
unfold derivWithin deriv
rw [fderivWithin_univ]
theorem derivWithin_inter (ht : t ∈ 𝓝 x) : derivWithin f (s ∩ t) x = derivWithin f s x := by
unfold derivWithin
rw [fderivWithin_inter ht]
theorem derivWithin_of_mem_nhds (h : s ∈ 𝓝 x) : derivWithin f s x = deriv f x := by
simp only [derivWithin, deriv, fderivWithin_of_mem_nhds h]
theorem derivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : derivWithin f s x = deriv f x :=
derivWithin_of_mem_nhds (hs.mem_nhds hx)
lemma deriv_eqOn {f' : 𝕜 → F} (hs : IsOpen s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) :
s.EqOn (deriv f) f' := fun x hx ↦ by
rw [← derivWithin_of_isOpen hs hx, (hf' _ hx).derivWithin <| hs.uniqueDiffWithinAt hx]
theorem deriv_mem_iff {f : 𝕜 → F} {s : Set F} {x : 𝕜} :
deriv f x ∈ s ↔
DifferentiableAt 𝕜 f x ∧ deriv f x ∈ s ∨ ¬DifferentiableAt 𝕜 f x ∧ (0 : F) ∈ s := by
by_cases hx : DifferentiableAt 𝕜 f x <;> simp [deriv_zero_of_not_differentiableAt, *]
theorem derivWithin_mem_iff {f : 𝕜 → F} {t : Set 𝕜} {s : Set F} {x : 𝕜} :
derivWithin f t x ∈ s ↔
DifferentiableWithinAt 𝕜 f t x ∧ derivWithin f t x ∈ s ∨
¬DifferentiableWithinAt 𝕜 f t x ∧ (0 : F) ∈ s := by
by_cases hx : DifferentiableWithinAt 𝕜 f t x <;>
simp [derivWithin_zero_of_not_differentiableWithinAt, *]
theorem differentiableWithinAt_Ioi_iff_Ici [PartialOrder 𝕜] :
DifferentiableWithinAt 𝕜 f (Ioi x) x ↔ DifferentiableWithinAt 𝕜 f (Ici x) x :=
⟨fun h => h.hasDerivWithinAt.Ici_of_Ioi.differentiableWithinAt, fun h =>
h.hasDerivWithinAt.Ioi_of_Ici.differentiableWithinAt⟩
-- Golfed while splitting the file
theorem derivWithin_Ioi_eq_Ici {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] (f : ℝ → E)
(x : ℝ) : derivWithin f (Ioi x) x = derivWithin f (Ici x) x := by
by_cases H : DifferentiableWithinAt ℝ f (Ioi x) x
· have A := H.hasDerivWithinAt.Ici_of_Ioi
have B := (differentiableWithinAt_Ioi_iff_Ici.1 H).hasDerivWithinAt
simpa using (uniqueDiffOn_Ici x).eq left_mem_Ici A B
· rw [derivWithin_zero_of_not_differentiableWithinAt H,
derivWithin_zero_of_not_differentiableWithinAt]
rwa [differentiableWithinAt_Ioi_iff_Ici] at H
section congr
/-! ### Congruence properties of derivatives -/
theorem Filter.EventuallyEq.hasDerivAtFilter_iff (h₀ : f₀ =ᶠ[L] f₁) (hx : f₀ x = f₁ x)
(h₁ : f₀' = f₁') : HasDerivAtFilter f₀ f₀' x L ↔ HasDerivAtFilter f₁ f₁' x L :=
h₀.hasFDerivAtFilter_iff hx (by simp [h₁])
theorem HasDerivAtFilter.congr_of_eventuallyEq (h : HasDerivAtFilter f f' x L) (hL : f₁ =ᶠ[L] f)
(hx : f₁ x = f x) : HasDerivAtFilter f₁ f' x L := by rwa [hL.hasDerivAtFilter_iff hx rfl]
theorem HasDerivWithinAt.congr_mono (h : HasDerivWithinAt f f' s x) (ht : ∀ x ∈ t, f₁ x = f x)
(hx : f₁ x = f x) (h₁ : t ⊆ s) : HasDerivWithinAt f₁ f' t x :=
HasFDerivWithinAt.congr_mono h ht hx h₁
theorem HasDerivWithinAt.congr (h : HasDerivWithinAt f f' s x) (hs : ∀ x ∈ s, f₁ x = f x)
(hx : f₁ x = f x) : HasDerivWithinAt f₁ f' s x :=
h.congr_mono hs hx (Subset.refl _)
theorem HasDerivWithinAt.congr_of_mem (h : HasDerivWithinAt f f' s x) (hs : ∀ x ∈ s, f₁ x = f x)
(hx : x ∈ s) : HasDerivWithinAt f₁ f' s x :=
h.congr hs (hs _ hx)
theorem HasDerivWithinAt.congr_of_eventuallyEq (h : HasDerivWithinAt f f' s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : HasDerivWithinAt f₁ f' s x :=
HasDerivAtFilter.congr_of_eventuallyEq h h₁ hx
theorem Filter.EventuallyEq.hasDerivWithinAt_iff (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) :
HasDerivWithinAt f₁ f' s x ↔ HasDerivWithinAt f f' s x :=
⟨fun h' ↦ h'.congr_of_eventuallyEq h₁.symm hx.symm, fun h' ↦ h'.congr_of_eventuallyEq h₁ hx⟩
theorem HasDerivWithinAt.congr_of_eventuallyEq_of_mem (h : HasDerivWithinAt f f' s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) : HasDerivWithinAt f₁ f' s x :=
h.congr_of_eventuallyEq h₁ (h₁.eq_of_nhdsWithin hx)
theorem Filter.EventuallyEq.hasDerivWithinAt_iff_of_mem (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) :
HasDerivWithinAt f₁ f' s x ↔ HasDerivWithinAt f f' s x :=
⟨fun h' ↦ h'.congr_of_eventuallyEq_of_mem h₁.symm hx,
fun h' ↦ h'.congr_of_eventuallyEq_of_mem h₁ hx⟩
theorem HasStrictDerivAt.congr_deriv (h : HasStrictDerivAt f f' x) (h' : f' = g') :
HasStrictDerivAt f g' x :=
h.congr_fderiv <| congr_arg _ h'
theorem HasDerivAt.congr_deriv (h : HasDerivAt f f' x) (h' : f' = g') : HasDerivAt f g' x :=
HasFDerivAt.congr_fderiv h <| congr_arg _ h'
theorem HasDerivWithinAt.congr_deriv (h : HasDerivWithinAt f f' s x) (h' : f' = g') :
HasDerivWithinAt f g' s x :=
HasFDerivWithinAt.congr_fderiv h <| congr_arg _ h'
theorem HasDerivAt.congr_of_eventuallyEq (h : HasDerivAt f f' x) (h₁ : f₁ =ᶠ[𝓝 x] f) :
HasDerivAt f₁ f' x :=
HasDerivAtFilter.congr_of_eventuallyEq h h₁ (mem_of_mem_nhds h₁ :)
theorem Filter.EventuallyEq.hasDerivAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) :
HasDerivAt f₀ f' x ↔ HasDerivAt f₁ f' x :=
⟨fun h' ↦ h'.congr_of_eventuallyEq h.symm, fun h' ↦ h'.congr_of_eventuallyEq h⟩
theorem Filter.EventuallyEq.derivWithin_eq (hs : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) :
derivWithin f₁ s x = derivWithin f s x := by
unfold derivWithin
rw [hs.fderivWithin_eq hx]
theorem derivWithin_congr (hs : EqOn f₁ f s) (hx : f₁ x = f x) :
derivWithin f₁ s x = derivWithin f s x := by
unfold derivWithin
rw [fderivWithin_congr hs hx]
theorem Filter.EventuallyEq.deriv_eq (hL : f₁ =ᶠ[𝓝 x] f) : deriv f₁ x = deriv f x := by
unfold deriv
rwa [Filter.EventuallyEq.fderiv_eq]
protected theorem Filter.EventuallyEq.deriv (h : f₁ =ᶠ[𝓝 x] f) : deriv f₁ =ᶠ[𝓝 x] deriv f :=
h.eventuallyEq_nhds.mono fun _ h => h.deriv_eq
end congr
section id
/-! ### Derivative of the identity -/
variable (s x L)
theorem hasDerivAtFilter_id : HasDerivAtFilter id 1 x L :=
(hasFDerivAtFilter_id x L).hasDerivAtFilter
theorem hasDerivWithinAt_id : HasDerivWithinAt id 1 s x :=
hasDerivAtFilter_id _ _
theorem hasDerivAt_id : HasDerivAt id 1 x :=
hasDerivAtFilter_id _ _
theorem hasDerivAt_id' : HasDerivAt (fun x : 𝕜 => x) 1 x :=
hasDerivAtFilter_id _ _
theorem hasStrictDerivAt_id : HasStrictDerivAt id 1 x :=
(hasStrictFDerivAt_id x).hasStrictDerivAt
theorem deriv_id : deriv id x = 1 :=
HasDerivAt.deriv (hasDerivAt_id x)
@[simp]
theorem deriv_id' : deriv (@id 𝕜) = fun _ => 1 :=
funext deriv_id
/-- Variant with `fun x => x` rather than `id` -/
@[simp]
theorem deriv_id'' : (deriv fun x : 𝕜 => x) = fun _ => 1 :=
deriv_id'
theorem derivWithin_id (hxs : UniqueDiffWithinAt 𝕜 s x) : derivWithin id s x = 1 :=
(hasDerivWithinAt_id x s).derivWithin hxs
/-- Variant with `fun x => x` rather than `id` -/
theorem derivWithin_id' (hxs : UniqueDiffWithinAt 𝕜 s x) : derivWithin (fun x => x) s x = 1 :=
derivWithin_id x s hxs
end id
section Const
/-! ### Derivative of constant functions
This include the constant functions `0`, `1`, `Nat.cast n`, `Int.cast z`, and other numerals.
-/
variable (c : F) (s x L)
theorem hasDerivAtFilter_const : HasDerivAtFilter (fun _ => c) 0 x L :=
(hasFDerivAtFilter_const c x L).hasDerivAtFilter
theorem hasDerivAtFilter_zero : HasDerivAtFilter (0 : 𝕜 → F) 0 x L :=
hasDerivAtFilter_const _ _ _
theorem hasDerivAtFilter_one [One F] : HasDerivAtFilter (1 : 𝕜 → F) 0 x L :=
hasDerivAtFilter_const _ _ _
theorem hasDerivAtFilter_natCast [NatCast F] (n : ℕ) : HasDerivAtFilter (n : 𝕜 → F) 0 x L :=
hasDerivAtFilter_const _ _ _
theorem hasDerivAtFilter_intCast [IntCast F] (z : ℤ) : HasDerivAtFilter (z : 𝕜 → F) 0 x L :=
hasDerivAtFilter_const _ _ _
theorem hasDerivAtFilter_ofNat (n : ℕ) [OfNat F n] : HasDerivAtFilter (ofNat(n) : 𝕜 → F) 0 x L :=
hasDerivAtFilter_const _ _ _
theorem hasStrictDerivAt_const : HasStrictDerivAt (fun _ => c) 0 x :=
(hasStrictFDerivAt_const c x).hasStrictDerivAt
theorem hasStrictDerivAt_zero : HasStrictDerivAt (0 : 𝕜 → F) 0 x :=
hasStrictDerivAt_const _ _
theorem hasStrictDerivAt_one [One F] : HasStrictDerivAt (1 : 𝕜 → F) 0 x :=
hasStrictDerivAt_const _ _
theorem hasStrictDerivAt_natCast [NatCast F] (n : ℕ) : HasStrictDerivAt (n : 𝕜 → F) 0 x :=
hasStrictDerivAt_const _ _
theorem hasStrictDerivAt_intCast [IntCast F] (z : ℤ) : HasStrictDerivAt (z : 𝕜 → F) 0 x :=
hasStrictDerivAt_const _ _
theorem HasStrictDerivAt_ofNat (n : ℕ) [OfNat F n] : HasStrictDerivAt (ofNat(n) : 𝕜 → F) 0 x :=
hasStrictDerivAt_const _ _
theorem hasDerivWithinAt_const : HasDerivWithinAt (fun _ => c) 0 s x :=
hasDerivAtFilter_const _ _ _
theorem hasDerivWithinAt_zero : HasDerivWithinAt (0 : 𝕜 → F) 0 s x :=
hasDerivAtFilter_zero _ _
theorem hasDerivWithinAt_one [One F] : HasDerivWithinAt (1 : 𝕜 → F) 0 s x :=
hasDerivWithinAt_const _ _ _
theorem hasDerivWithinAt_natCast [NatCast F] (n : ℕ) : HasDerivWithinAt (n : 𝕜 → F) 0 s x :=
hasDerivWithinAt_const _ _ _
theorem hasDerivWithinAt_intCast [IntCast F] (z : ℤ) : HasDerivWithinAt (z : 𝕜 → F) 0 s x :=
hasDerivWithinAt_const _ _ _
theorem hasDerivWithinAt_ofNat (n : ℕ) [OfNat F n] : HasDerivWithinAt (ofNat(n) : 𝕜 → F) 0 s x :=
hasDerivWithinAt_const _ _ _
theorem hasDerivAt_const : HasDerivAt (fun _ => c) 0 x :=
hasDerivAtFilter_const _ _ _
theorem hasDerivAt_zero : HasDerivAt (0 : 𝕜 → F) 0 x :=
hasDerivAtFilter_zero _ _
theorem hasDerivAt_one [One F] : HasDerivAt (1 : 𝕜 → F) 0 x :=
hasDerivAt_const _ _
theorem hasDerivAt_natCast [NatCast F] (n : ℕ) : HasDerivAt (n : 𝕜 → F) 0 x :=
hasDerivAt_const _ _
theorem hasDerivAt_intCast [IntCast F] (z : ℤ) : HasDerivAt (z : 𝕜 → F) 0 x :=
hasDerivAt_const _ _
theorem hasDerivAt_ofNat (n : ℕ) [OfNat F n] : HasDerivAt (ofNat(n) : 𝕜 → F) 0 x :=
hasDerivAt_const _ _
theorem deriv_const : deriv (fun _ => c) x = 0 :=
HasDerivAt.deriv (hasDerivAt_const x c)
@[simp]
theorem deriv_const' : (deriv fun _ : 𝕜 => c) = fun _ => 0 :=
funext fun x => deriv_const x c
@[simp]
theorem deriv_zero : deriv (0 : 𝕜 → F) = 0 := funext fun _ => deriv_const _ _
@[simp]
theorem deriv_one [One F] : deriv (1 : 𝕜 → F) = 0 := funext fun _ => deriv_const _ _
@[simp]
theorem deriv_natCast [NatCast F] (n : ℕ) : deriv (n : 𝕜 → F) = 0 := funext fun _ => deriv_const _ _
@[simp]
theorem deriv_intCast [IntCast F] (z : ℤ) : deriv (z : 𝕜 → F) = 0 := funext fun _ => deriv_const _ _
@[simp low]
theorem deriv_ofNat (n : ℕ) [OfNat F n] : deriv (ofNat(n) : 𝕜 → F) = 0 :=
funext fun _ => deriv_const _ _
@[simp]
theorem derivWithin_const : derivWithin (fun _ => c) s = 0 := by
ext; simp [derivWithin]
@[simp]
theorem derivWithin_zero : derivWithin (0 : 𝕜 → F) s = 0 := derivWithin_const _ _
@[simp]
theorem derivWithin_one [One F] : derivWithin (1 : 𝕜 → F) s = 0 := derivWithin_const _ _
@[simp]
theorem derivWithin_natCast [NatCast F] (n : ℕ) : derivWithin (n : 𝕜 → F) s = 0 :=
derivWithin_const _ _
@[simp]
theorem derivWithin_intCast [IntCast F] (z : ℤ) : derivWithin (z : 𝕜 → F) s = 0 :=
derivWithin_const _ _
@[simp low]
theorem derivWithin_ofNat (n : ℕ) [OfNat F n] : derivWithin (ofNat(n) : 𝕜 → F) s = 0 :=
derivWithin_const _ _
end Const
section Continuous
/-! ### Continuity of a function admitting a derivative -/
nonrec theorem HasDerivAtFilter.tendsto_nhds (hL : L ≤ 𝓝 x) (h : HasDerivAtFilter f f' x L) :
Tendsto f L (𝓝 (f x)) :=
h.tendsto_nhds hL
theorem HasDerivWithinAt.continuousWithinAt (h : HasDerivWithinAt f f' s x) :
ContinuousWithinAt f s x :=
HasDerivAtFilter.tendsto_nhds inf_le_left h
theorem HasDerivAt.continuousAt (h : HasDerivAt f f' x) : ContinuousAt f x :=
HasDerivAtFilter.tendsto_nhds le_rfl h
protected theorem HasDerivAt.continuousOn {f f' : 𝕜 → F} (hderiv : ∀ x ∈ s, HasDerivAt f (f' x) x) :
ContinuousOn f s := fun x hx => (hderiv x hx).continuousAt.continuousWithinAt
end Continuous
section MeanValue
/-- Converse to the mean value inequality: if `f` is differentiable at `x₀` and `C`-lipschitz
on a neighborhood of `x₀` then its derivative at `x₀` has norm bounded by `C`. This version
only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. -/
theorem HasDerivAt.le_of_lip' {f : 𝕜 → F} {f' : F} {x₀ : 𝕜} (hf : HasDerivAt f f' x₀)
{C : ℝ} (hC₀ : 0 ≤ C) (hlip : ∀ᶠ x in 𝓝 x₀, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) :
‖f'‖ ≤ C := by
simpa using HasFDerivAt.le_of_lip' hf.hasFDerivAt hC₀ hlip
/-- Converse to the mean value inequality: if `f` is differentiable at `x₀` and `C`-lipschitz
on a neighborhood of `x₀` then its derivative at `x₀` has norm bounded by `C`. -/
theorem HasDerivAt.le_of_lipschitzOn {f : 𝕜 → F} {f' : F} {x₀ : 𝕜} (hf : HasDerivAt f f' x₀)
{s : Set 𝕜} (hs : s ∈ 𝓝 x₀) {C : ℝ≥0} (hlip : LipschitzOnWith C f s) : ‖f'‖ ≤ C := by
simpa using HasFDerivAt.le_of_lipschitzOn hf.hasFDerivAt hs hlip
/-- Converse to the mean value inequality: if `f` is differentiable at `x₀` and `C`-lipschitz
then its derivative at `x₀` has norm bounded by `C`. -/
| Mathlib/Analysis/Calculus/Deriv/Basic.lean | 807 | 809 | theorem HasDerivAt.le_of_lipschitz {f : 𝕜 → F} {f' : F} {x₀ : 𝕜} (hf : HasDerivAt f f' x₀)
{C : ℝ≥0} (hlip : LipschitzWith C f) : ‖f'‖ ≤ C := by | simpa using HasFDerivAt.le_of_lipschitz hf.hasFDerivAt hlip |
/-
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky, Yury Kudryashov
-/
import Mathlib.Data.Set.Image
import Mathlib.Data.List.InsertIdx
/-! # Some lemmas about lists involving sets
Split out from `Data.List.Basic` to reduce its dependencies.
-/
open List
variable {α β γ : Type*}
namespace List
@[simp]
theorem setOf_mem_eq_empty_iff {l : List α} : { x | x ∈ l } = ∅ ↔ l = [] :=
Set.eq_empty_iff_forall_not_mem.trans eq_nil_iff_forall_not_mem.symm
@[deprecated (since := "2024-12-10")] alias tail_reverse_eq_reverse_dropLast := tail_reverse
theorem injOn_insertIdx_index_of_not_mem (l : List α) (x : α) (hx : x ∉ l) :
Set.InjOn (fun k => l.insertIdx k x) { n | n ≤ l.length } := by
induction' l with hd tl IH
· intro n hn m hm _
simp_all [Set.mem_singleton_iff, Set.setOf_eq_eq_singleton, length]
· intro n hn m hm h
simp only [length, Set.mem_setOf_eq] at hn hm
simp only [mem_cons, not_or] at hx
cases n <;> cases m
· rfl
· simp [hx.left] at h
· simp [Ne.symm hx.left] at h
· simp only [true_and, eq_self_iff_true, insertIdx_succ_cons] at h
rw [Nat.succ_inj]
refine IH hx.right ?_ ?_ (by injection h)
· simpa [Nat.succ_le_succ_iff] using hn
· simpa [Nat.succ_le_succ_iff] using hm
| Mathlib/Data/List/Lemmas.lean | 44 | 52 | theorem foldr_range_subset_of_range_subset {f : β → α → α} {g : γ → α → α}
(hfg : Set.range f ⊆ Set.range g) (a : α) : Set.range (foldr f a) ⊆ Set.range (foldr g a) := by | rintro _ ⟨l, rfl⟩
induction' l with b l H
· exact ⟨[], rfl⟩
· obtain ⟨c, hgf⟩ := hfg (Set.mem_range_self b)
obtain ⟨m, hgf'⟩ := H
rw [foldr_cons, ← hgf, ← hgf']
exact ⟨c :: m, rfl⟩ |
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Ken Lee, Chris Hughes
-/
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Int.GCD
import Mathlib.RingTheory.Coprime.Basic
/-!
# Additional lemmas about elements of a ring satisfying `IsCoprime`
and elements of a monoid satisfying `IsRelPrime`
These lemmas are in a separate file to the definition of `IsCoprime` or `IsRelPrime`
as they require more imports.
Notably, this includes lemmas about `Finset.prod` as this requires importing BigOperators, and
lemmas about `Pow` since these are easiest to prove via `Finset.prod`.
-/
universe u v
open scoped Function -- required for scoped `on` notation
section IsCoprime
variable {R : Type u} {I : Type v} [CommSemiring R] {x y z : R} {s : I → R} {t : Finset I}
section
theorem Int.isCoprime_iff_gcd_eq_one {m n : ℤ} : IsCoprime m n ↔ Int.gcd m n = 1 := by
constructor
· rintro ⟨a, b, h⟩
refine Nat.dvd_one.mp (Int.gcd_dvd_iff.mpr ⟨a, b, ?_⟩)
rwa [mul_comm m, mul_comm n, eq_comm]
· rw [← Int.ofNat_inj, IsCoprime, Int.gcd_eq_gcd_ab, mul_comm m, mul_comm n, Nat.cast_one]
intro h
exact ⟨_, _, h⟩
theorem Nat.isCoprime_iff_coprime {m n : ℕ} : IsCoprime (m : ℤ) n ↔ Nat.Coprime m n := by
rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_natCast_natCast]
alias ⟨IsCoprime.nat_coprime, Nat.Coprime.isCoprime⟩ := Nat.isCoprime_iff_coprime
theorem Nat.Coprime.cast {R : Type*} [CommRing R] {a b : ℕ} (h : Nat.Coprime a b) :
IsCoprime (a : R) (b : R) := by
rw [← isCoprime_iff_coprime] at h
rw [← Int.cast_natCast a, ← Int.cast_natCast b]
exact IsCoprime.intCast h
theorem ne_zero_or_ne_zero_of_nat_coprime {A : Type u} [CommRing A] [Nontrivial A] {a b : ℕ}
(h : Nat.Coprime a b) : (a : A) ≠ 0 ∨ (b : A) ≠ 0 :=
IsCoprime.ne_zero_or_ne_zero (R := A) <| by
simpa only [map_natCast] using IsCoprime.map (Nat.Coprime.isCoprime h) (Int.castRingHom A)
theorem IsCoprime.prod_left : (∀ i ∈ t, IsCoprime (s i) x) → IsCoprime (∏ i ∈ t, s i) x := by
classical
refine Finset.induction_on t (fun _ ↦ isCoprime_one_left) fun b t hbt ih H ↦ ?_
rw [Finset.prod_insert hbt]
rw [Finset.forall_mem_insert] at H
exact H.1.mul_left (ih H.2)
theorem IsCoprime.prod_right : (∀ i ∈ t, IsCoprime x (s i)) → IsCoprime x (∏ i ∈ t, s i) := by
simpa only [isCoprime_comm] using IsCoprime.prod_left (R := R)
theorem IsCoprime.prod_left_iff : IsCoprime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsCoprime (s i) x := by
classical
refine Finset.induction_on t (iff_of_true isCoprime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_
rw [Finset.prod_insert hbt, IsCoprime.mul_left_iff, ih, Finset.forall_mem_insert]
theorem IsCoprime.prod_right_iff : IsCoprime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsCoprime x (s i) := by
simpa only [isCoprime_comm] using IsCoprime.prod_left_iff (R := R)
theorem IsCoprime.of_prod_left (H1 : IsCoprime (∏ i ∈ t, s i) x) (i : I) (hit : i ∈ t) :
IsCoprime (s i) x :=
IsCoprime.prod_left_iff.1 H1 i hit
theorem IsCoprime.of_prod_right (H1 : IsCoprime x (∏ i ∈ t, s i)) (i : I) (hit : i ∈ t) :
IsCoprime x (s i) :=
IsCoprime.prod_right_iff.1 H1 i hit
-- Porting note: removed names of things due to linter, but they seem helpful
theorem Finset.prod_dvd_of_coprime :
(t : Set I).Pairwise (IsCoprime on s) → (∀ i ∈ t, s i ∣ z) → (∏ x ∈ t, s x) ∣ z := by
classical
exact Finset.induction_on t (fun _ _ ↦ one_dvd z)
(by
intro a r har ih Hs Hs1
rw [Finset.prod_insert har]
have aux1 : a ∈ (↑(insert a r) : Set I) := Finset.mem_insert_self a r
refine
(IsCoprime.prod_right fun i hir ↦
Hs aux1 (Finset.mem_insert_of_mem hir) <| by
rintro rfl
exact har hir).mul_dvd
(Hs1 a aux1) (ih (Hs.mono ?_) fun i hi ↦ Hs1 i <| Finset.mem_insert_of_mem hi)
simp only [Finset.coe_insert, Set.subset_insert])
theorem Fintype.prod_dvd_of_coprime [Fintype I] (Hs : Pairwise (IsCoprime on s))
(Hs1 : ∀ i, s i ∣ z) : (∏ x, s x) ∣ z :=
Finset.prod_dvd_of_coprime (Hs.set_pairwise _) fun i _ ↦ Hs1 i
end
open Finset
theorem exists_sum_eq_one_iff_pairwise_coprime [DecidableEq I] (h : t.Nonempty) :
(∃ μ : I → R, (∑ i ∈ t, μ i * ∏ j ∈ t \ {i}, s j) = 1) ↔
Pairwise (IsCoprime on fun i : t ↦ s i) := by
induction h using Finset.Nonempty.cons_induction with
| singleton =>
simp [exists_apply_eq, Pairwise, Function.onFun]
| cons a t hat h ih =>
rw [pairwise_cons']
have mem : ∀ x ∈ t, a ∈ insert a t \ {x} := fun x hx ↦ by
rw [mem_sdiff, mem_singleton]
exact ⟨mem_insert_self _ _, fun ha ↦ hat (ha ▸ hx)⟩
constructor
· rintro ⟨μ, hμ⟩
rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat] at hμ
refine ⟨ih.mp ⟨Pi.single h.choose (μ a * s h.choose) + μ * fun _ ↦ s a, ?_⟩, fun b hb ↦ ?_⟩
· rw [prod_eq_mul_prod_diff_singleton h.choose_spec, ← mul_assoc, ←
@if_pos _ _ h.choose_spec R (_ * _) 0, ← sum_pi_single', ← sum_add_distrib] at hμ
rw [← hμ, sum_congr rfl]
intro x hx
dsimp -- Porting note: terms were showing as sort of `HAdd.hadd` instead of `+`
-- this whole proof pretty much breaks and has to be rewritten from scratch
rw [add_mul]
congr 1
· by_cases hx : x = h.choose
· rw [hx, Pi.single_eq_same, Pi.single_eq_same]
· rw [Pi.single_eq_of_ne hx, Pi.single_eq_of_ne hx, zero_mul]
· rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _, mul_comm]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
· have : IsCoprime (s b) (s a) :=
⟨μ a * ∏ i ∈ t \ {b}, s i, ∑ i ∈ t, μ i * ∏ j ∈ t \ {i}, s j, ?_⟩
· exact ⟨this.symm, this⟩
rw [mul_assoc, ← prod_eq_prod_diff_singleton_mul hb, sum_mul, ← hμ, sum_congr rfl]
intro x hx
rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
· rintro ⟨hs, Hb⟩
obtain ⟨μ, hμ⟩ := ih.mpr hs
obtain ⟨u, v, huv⟩ := IsCoprime.prod_left fun b hb ↦ (Hb b hb).right
use fun i ↦ if i = a then u else v * μ i
have hμ' : (∑ i ∈ t, v * ((μ i * ∏ j ∈ t \ {i}, s j) * s a)) = v * s a := by
rw [← mul_sum, ← sum_mul, hμ, one_mul]
rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat]
simp only [↓reduceIte, ite_mul]
rw [← huv, ← hμ', sum_congr rfl]
intro x hx
rw [mul_assoc, if_neg fun ha : x = a ↦ hat (ha.casesOn hx)]
rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
theorem exists_sum_eq_one_iff_pairwise_coprime' [Fintype I] [Nonempty I] [DecidableEq I] :
(∃ μ : I → R, (∑ i : I, μ i * ∏ j ∈ {i}ᶜ, s j) = 1) ↔ Pairwise (IsCoprime on s) := by
convert exists_sum_eq_one_iff_pairwise_coprime Finset.univ_nonempty (s := s) using 1
simp only [Function.onFun, pairwise_subtype_iff_pairwise_finset', coe_univ, Set.pairwise_univ]
theorem pairwise_coprime_iff_coprime_prod [DecidableEq I] :
Pairwise (IsCoprime on fun i : t ↦ s i) ↔ ∀ i ∈ t, IsCoprime (s i) (∏ j ∈ t \ {i}, s j) := by
refine ⟨fun hp i hi ↦ IsCoprime.prod_right_iff.mpr fun j hj ↦ ?_, fun hp ↦ ?_⟩
· rw [Finset.mem_sdiff, Finset.mem_singleton] at hj
obtain ⟨hj, ji⟩ := hj
refine @hp ⟨i, hi⟩ ⟨j, hj⟩ fun h ↦ ji (congrArg Subtype.val h).symm
-- Porting note: is there a better way compared to the old `congr_arg coe h`?
· rintro ⟨i, hi⟩ ⟨j, hj⟩ h
apply IsCoprime.prod_right_iff.mp (hp i hi)
exact Finset.mem_sdiff.mpr ⟨hj, fun f ↦ h <| Subtype.ext (Finset.mem_singleton.mp f).symm⟩
variable {m n : ℕ}
theorem IsCoprime.pow_left (H : IsCoprime x y) : IsCoprime (x ^ m) y := by
rw [← Finset.card_range m, ← Finset.prod_const]
exact IsCoprime.prod_left fun _ _ ↦ H
theorem IsCoprime.pow_right (H : IsCoprime x y) : IsCoprime x (y ^ n) := by
rw [← Finset.card_range n, ← Finset.prod_const]
exact IsCoprime.prod_right fun _ _ ↦ H
theorem IsCoprime.pow (H : IsCoprime x y) : IsCoprime (x ^ m) (y ^ n) :=
H.pow_left.pow_right
theorem IsCoprime.pow_left_iff (hm : 0 < m) : IsCoprime (x ^ m) y ↔ IsCoprime x y := by
refine ⟨fun h ↦ ?_, IsCoprime.pow_left⟩
rw [← Finset.card_range m, ← Finset.prod_const] at h
exact h.of_prod_left 0 (Finset.mem_range.mpr hm)
theorem IsCoprime.pow_right_iff (hm : 0 < m) : IsCoprime x (y ^ m) ↔ IsCoprime x y :=
isCoprime_comm.trans <| (IsCoprime.pow_left_iff hm).trans <| isCoprime_comm
theorem IsCoprime.pow_iff (hm : 0 < m) (hn : 0 < n) : IsCoprime (x ^ m) (y ^ n) ↔ IsCoprime x y :=
(IsCoprime.pow_left_iff hm).trans <| IsCoprime.pow_right_iff hn
end IsCoprime
section RelPrime
variable {α I} [CommMonoid α] [DecompositionMonoid α] {x y z : α} {s : I → α} {t : Finset I}
theorem IsRelPrime.prod_left : (∀ i ∈ t, IsRelPrime (s i) x) → IsRelPrime (∏ i ∈ t, s i) x := by
classical
refine Finset.induction_on t (fun _ ↦ isRelPrime_one_left) fun b t hbt ih H ↦ ?_
rw [Finset.prod_insert hbt]
rw [Finset.forall_mem_insert] at H
exact H.1.mul_left (ih H.2)
theorem IsRelPrime.prod_right : (∀ i ∈ t, IsRelPrime x (s i)) → IsRelPrime x (∏ i ∈ t, s i) := by
simpa only [isRelPrime_comm] using IsRelPrime.prod_left (α := α)
theorem IsRelPrime.prod_left_iff : IsRelPrime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsRelPrime (s i) x := by
classical
refine Finset.induction_on t (iff_of_true isRelPrime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_
rw [Finset.prod_insert hbt, IsRelPrime.mul_left_iff, ih, Finset.forall_mem_insert]
theorem IsRelPrime.prod_right_iff : IsRelPrime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsRelPrime x (s i) := by
simpa only [isRelPrime_comm] using IsRelPrime.prod_left_iff (α := α)
theorem IsRelPrime.of_prod_left (H1 : IsRelPrime (∏ i ∈ t, s i) x) (i : I) (hit : i ∈ t) :
IsRelPrime (s i) x :=
IsRelPrime.prod_left_iff.1 H1 i hit
| Mathlib/RingTheory/Coprime/Lemmas.lean | 235 | 240 | theorem IsRelPrime.of_prod_right (H1 : IsRelPrime x (∏ i ∈ t, s i)) (i : I) (hit : i ∈ t) :
IsRelPrime x (s i) :=
IsRelPrime.prod_right_iff.1 H1 i hit
theorem Finset.prod_dvd_of_isRelPrime :
(t : Set I).Pairwise (IsRelPrime on s) → (∀ i ∈ t, s i ∣ z) → (∏ x ∈ t, s x) ∣ z := by | |
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Yury Kudryashov, Neil Strickland
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Algebra.GroupWithZero.Defs
import Mathlib.Data.Int.Cast.Defs
import Mathlib.Tactic.Spread
import Mathlib.Util.AssertExists
import Mathlib.Tactic.StacksAttribute
/-!
# Semirings and rings
This file defines semirings, rings and domains. This is analogous to `Algebra.Group.Defs` and
`Algebra.Group.Basic`, the difference being that the former is about `+` and `*` separately, while
the present file is about their interaction.
## Main definitions
* `Distrib`: Typeclass for distributivity of multiplication over addition.
* `HasDistribNeg`: Typeclass for commutativity of negation and multiplication. This is useful when
dealing with multiplicative submonoids which are closed under negation without being closed under
addition, for example `Units`.
* `(NonUnital)(NonAssoc)(Semi)Ring`: Typeclasses for possibly non-unital or non-associative
rings and semirings. Some combinations are not defined yet because they haven't found use.
For Lie Rings, there is a type synonym `CommutatorRing` defined in
`Mathlib/Algebra/Algebra/NonUnitalHom.lean` turning the bracket into a multiplication so that the
instance `instNonUnitalNonAssocSemiringCommutatorRing` can be defined.
## Tags
`Semiring`, `CommSemiring`, `Ring`, `CommRing`, domain, `IsDomain`, nonzero, units
-/
/-!
Previously an import dependency on `Mathlib.Algebra.Group.Basic` had crept in.
In general, the `.Defs` files in the basic algebraic hierarchy should only depend on earlier `.Defs`
files, without importing `.Basic` theory development.
These `assert_not_exists` statements guard against this returning.
-/
assert_not_exists DivisionMonoid.toDivInvOneMonoid mul_rotate
universe u v
variable {α : Type u} {R : Type v}
open Function
/-!
### `Distrib` class
-/
/-- A typeclass stating that multiplication is left and right distributive
over addition. -/
class Distrib (R : Type*) extends Mul R, Add R where
/-- Multiplication is left distributive over addition -/
protected left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c
/-- Multiplication is right distributive over addition -/
protected right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c
/-- A typeclass stating that multiplication is left distributive over addition. -/
class LeftDistribClass (R : Type*) [Mul R] [Add R] : Prop where
/-- Multiplication is left distributive over addition -/
protected left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c
/-- A typeclass stating that multiplication is right distributive over addition. -/
class RightDistribClass (R : Type*) [Mul R] [Add R] : Prop where
/-- Multiplication is right distributive over addition -/
protected right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c
-- see Note [lower instance priority]
instance (priority := 100) Distrib.leftDistribClass (R : Type*) [Distrib R] : LeftDistribClass R :=
⟨Distrib.left_distrib⟩
-- see Note [lower instance priority]
instance (priority := 100) Distrib.rightDistribClass (R : Type*) [Distrib R] :
RightDistribClass R :=
⟨Distrib.right_distrib⟩
theorem left_distrib [Mul R] [Add R] [LeftDistribClass R] (a b c : R) :
a * (b + c) = a * b + a * c :=
LeftDistribClass.left_distrib a b c
alias mul_add := left_distrib
theorem right_distrib [Mul R] [Add R] [RightDistribClass R] (a b c : R) :
(a + b) * c = a * c + b * c :=
RightDistribClass.right_distrib a b c
alias add_mul := right_distrib
theorem distrib_three_right [Mul R] [Add R] [RightDistribClass R] (a b c d : R) :
(a + b + c) * d = a * d + b * d + c * d := by simp [right_distrib]
/-!
### Classes of semirings and rings
We make sure that the canonical path from `NonAssocSemiring` to `Ring` passes through `Semiring`,
as this is a path which is followed all the time in linear algebra where the defining semilinear map
`σ : R →+* S` depends on the `NonAssocSemiring` structure of `R` and `S` while the module
definition depends on the `Semiring` structure.
It is not currently possible to adjust priorities by hand (see https://github.com/leanprover/lean4/issues/2115). Instead, the last
declared instance is used, so we make sure that `Semiring` is declared after `NonAssocRing`, so
that `Semiring -> NonAssocSemiring` is tried before `NonAssocRing -> NonAssocSemiring`.
TODO: clean this once https://github.com/leanprover/lean4/issues/2115 is fixed
-/
/-- A not-necessarily-unital, not-necessarily-associative semiring. See `CommutatorRing` and the
documentation thereof in case you need a `NonUnitalNonAssocSemiring` instance on a Lie ring
or a Lie algebra. -/
class NonUnitalNonAssocSemiring (α : Type u) extends AddCommMonoid α, Distrib α, MulZeroClass α
/-- An associative but not-necessarily unital semiring. -/
class NonUnitalSemiring (α : Type u) extends NonUnitalNonAssocSemiring α, SemigroupWithZero α
/-- A unital but not-necessarily-associative semiring. -/
class NonAssocSemiring (α : Type u) extends NonUnitalNonAssocSemiring α, MulZeroOneClass α,
AddCommMonoidWithOne α
/-- A not-necessarily-unital, not-necessarily-associative ring. -/
class NonUnitalNonAssocRing (α : Type u) extends AddCommGroup α, NonUnitalNonAssocSemiring α
/-- An associative but not-necessarily unital ring. -/
class NonUnitalRing (α : Type*) extends NonUnitalNonAssocRing α, NonUnitalSemiring α
/-- A unital but not-necessarily-associative ring. -/
class NonAssocRing (α : Type*) extends NonUnitalNonAssocRing α, NonAssocSemiring α,
AddCommGroupWithOne α
/-- A `Semiring` is a type with addition, multiplication, a `0` and a `1` where addition is
commutative and associative, multiplication is associative and left and right distributive over
addition, and `0` and `1` are additive and multiplicative identities. -/
class Semiring (α : Type u) extends NonUnitalSemiring α, NonAssocSemiring α, MonoidWithZero α
/-- A `Ring` is a `Semiring` with negation making it an additive group. -/
class Ring (R : Type u) extends Semiring R, AddCommGroup R, AddGroupWithOne R
/-!
### Semirings
-/
section DistribMulOneClass
variable [Add α] [MulOneClass α]
theorem add_one_mul [RightDistribClass α] (a b : α) : (a + 1) * b = a * b + b := by
rw [add_mul, one_mul]
| Mathlib/Algebra/Ring/Defs.lean | 156 | 157 | theorem mul_add_one [LeftDistribClass α] (a b : α) : a * (b + 1) = a * b + a := by | rw [mul_add, mul_one] |
/-
Copyright (c) 2017 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis, Keeley Hoek
-/
import Mathlib.Algebra.NeZero
import Mathlib.Data.Int.DivMod
import Mathlib.Logic.Embedding.Basic
import Mathlib.Logic.Equiv.Set
import Mathlib.Tactic.Common
import Mathlib.Tactic.Attr.Register
/-!
# The finite type with `n` elements
`Fin n` is the type whose elements are natural numbers smaller than `n`.
This file expands on the development in the core library.
## Main definitions
### Induction principles
* `finZeroElim` : Elimination principle for the empty set `Fin 0`, generalizes `Fin.elim0`.
Further definitions and eliminators can be found in `Init.Data.Fin.Lemmas`
### Embeddings and isomorphisms
* `Fin.valEmbedding` : coercion to natural numbers as an `Embedding`;
* `Fin.succEmb` : `Fin.succ` as an `Embedding`;
* `Fin.castLEEmb h` : `Fin.castLE` as an `Embedding`, embed `Fin n` into `Fin m`, `h : n ≤ m`;
* `finCongr` : `Fin.cast` as an `Equiv`, equivalence between `Fin n` and `Fin m` when `n = m`;
* `Fin.castAddEmb m` : `Fin.castAdd` as an `Embedding`, embed `Fin n` into `Fin (n+m)`;
* `Fin.castSuccEmb` : `Fin.castSucc` as an `Embedding`, embed `Fin n` into `Fin (n+1)`;
* `Fin.addNatEmb m i` : `Fin.addNat` as an `Embedding`, add `m` on `i` on the right,
generalizes `Fin.succ`;
* `Fin.natAddEmb n i` : `Fin.natAdd` as an `Embedding`, adds `n` on `i` on the left;
### Other casts
* `Fin.divNat i` : divides `i : Fin (m * n)` by `n`;
* `Fin.modNat i` : takes the mod of `i : Fin (m * n)` by `n`;
-/
assert_not_exists Monoid Finset
open Fin Nat Function
attribute [simp] Fin.succ_ne_zero Fin.castSucc_lt_last
/-- Elimination principle for the empty set `Fin 0`, dependent version. -/
def finZeroElim {α : Fin 0 → Sort*} (x : Fin 0) : α x :=
x.elim0
namespace Fin
@[simp] theorem mk_eq_one {n a : Nat} {ha : a < n + 2} :
(⟨a, ha⟩ : Fin (n + 2)) = 1 ↔ a = 1 :=
mk.inj_iff
@[simp] theorem one_eq_mk {n a : Nat} {ha : a < n + 2} :
1 = (⟨a, ha⟩ : Fin (n + 2)) ↔ a = 1 := by
simp [eq_comm]
instance {n : ℕ} : CanLift ℕ (Fin n) Fin.val (· < n) where
prf k hk := ⟨⟨k, hk⟩, rfl⟩
/-- A dependent variant of `Fin.elim0`. -/
def rec0 {α : Fin 0 → Sort*} (i : Fin 0) : α i := absurd i.2 (Nat.not_lt_zero _)
variable {n m : ℕ}
--variable {a b : Fin n} -- this *really* breaks stuff
theorem val_injective : Function.Injective (@Fin.val n) :=
@Fin.eq_of_val_eq n
/-- If you actually have an element of `Fin n`, then the `n` is always positive -/
lemma size_positive : Fin n → 0 < n := Fin.pos
lemma size_positive' [Nonempty (Fin n)] : 0 < n :=
‹Nonempty (Fin n)›.elim Fin.pos
protected theorem prop (a : Fin n) : a.val < n :=
a.2
lemma lt_last_iff_ne_last {a : Fin (n + 1)} : a < last n ↔ a ≠ last n := by
simp [Fin.lt_iff_le_and_ne, le_last]
lemma ne_zero_of_lt {a b : Fin (n + 1)} (hab : a < b) : b ≠ 0 :=
Fin.ne_of_gt <| Fin.lt_of_le_of_lt a.zero_le hab
lemma ne_last_of_lt {a b : Fin (n + 1)} (hab : a < b) : a ≠ last n :=
Fin.ne_of_lt <| Fin.lt_of_lt_of_le hab b.le_last
/-- Equivalence between `Fin n` and `{ i // i < n }`. -/
@[simps apply symm_apply]
def equivSubtype : Fin n ≃ { i // i < n } where
toFun a := ⟨a.1, a.2⟩
invFun a := ⟨a.1, a.2⟩
left_inv := fun ⟨_, _⟩ => rfl
right_inv := fun ⟨_, _⟩ => rfl
section coe
/-!
### coercions and constructions
-/
theorem val_eq_val (a b : Fin n) : (a : ℕ) = b ↔ a = b :=
Fin.ext_iff.symm
theorem ne_iff_vne (a b : Fin n) : a ≠ b ↔ a.1 ≠ b.1 :=
Fin.ext_iff.not
theorem mk_eq_mk {a h a' h'} : @mk n a h = @mk n a' h' ↔ a = a' :=
Fin.ext_iff
-- syntactic tautologies now
/-- Assume `k = l`. If two functions defined on `Fin k` and `Fin l` are equal on each element,
then they coincide (in the heq sense). -/
protected theorem heq_fun_iff {α : Sort*} {k l : ℕ} (h : k = l) {f : Fin k → α} {g : Fin l → α} :
HEq f g ↔ ∀ i : Fin k, f i = g ⟨(i : ℕ), h ▸ i.2⟩ := by
subst h
simp [funext_iff]
/-- Assume `k = l` and `k' = l'`.
If two functions `Fin k → Fin k' → α` and `Fin l → Fin l' → α` are equal on each pair,
then they coincide (in the heq sense). -/
protected theorem heq_fun₂_iff {α : Sort*} {k l k' l' : ℕ} (h : k = l) (h' : k' = l')
{f : Fin k → Fin k' → α} {g : Fin l → Fin l' → α} :
HEq f g ↔ ∀ (i : Fin k) (j : Fin k'), f i j = g ⟨(i : ℕ), h ▸ i.2⟩ ⟨(j : ℕ), h' ▸ j.2⟩ := by
subst h
subst h'
simp [funext_iff]
/-- Two elements of `Fin k` and `Fin l` are heq iff their values in `ℕ` coincide. This requires
`k = l`. For the left implication without this assumption, see `val_eq_val_of_heq`. -/
protected theorem heq_ext_iff {k l : ℕ} (h : k = l) {i : Fin k} {j : Fin l} :
HEq i j ↔ (i : ℕ) = (j : ℕ) := by
subst h
simp [val_eq_val]
end coe
section Order
/-!
### order
-/
theorem le_iff_val_le_val {a b : Fin n} : a ≤ b ↔ (a : ℕ) ≤ b :=
Iff.rfl
/-- `a < b` as natural numbers if and only if `a < b` in `Fin n`. -/
@[norm_cast, simp]
theorem val_fin_lt {n : ℕ} {a b : Fin n} : (a : ℕ) < (b : ℕ) ↔ a < b :=
Iff.rfl
/-- `a ≤ b` as natural numbers if and only if `a ≤ b` in `Fin n`. -/
@[norm_cast, simp]
theorem val_fin_le {n : ℕ} {a b : Fin n} : (a : ℕ) ≤ (b : ℕ) ↔ a ≤ b :=
Iff.rfl
theorem min_val {a : Fin n} : min (a : ℕ) n = a := by simp
theorem max_val {a : Fin n} : max (a : ℕ) n = n := by simp
/-- The inclusion map `Fin n → ℕ` is an embedding. -/
@[simps -fullyApplied apply]
def valEmbedding : Fin n ↪ ℕ :=
⟨val, val_injective⟩
@[simp]
theorem equivSubtype_symm_trans_valEmbedding :
equivSubtype.symm.toEmbedding.trans valEmbedding = Embedding.subtype (· < n) :=
rfl
/-- Use the ordering on `Fin n` for checking recursive definitions.
For example, the following definition is not accepted by the termination checker,
unless we declare the `WellFoundedRelation` instance:
```lean
def factorial {n : ℕ} : Fin n → ℕ
| ⟨0, _⟩ := 1
| ⟨i + 1, hi⟩ := (i + 1) * factorial ⟨i, i.lt_succ_self.trans hi⟩
```
-/
instance {n : ℕ} : WellFoundedRelation (Fin n) :=
measure (val : Fin n → ℕ)
@[deprecated (since := "2025-02-24")]
alias val_zero' := val_zero
/-- `Fin.mk_zero` in `Lean` only applies in `Fin (n + 1)`.
This one instead uses a `NeZero n` typeclass hypothesis.
-/
@[simp]
theorem mk_zero' (n : ℕ) [NeZero n] : (⟨0, pos_of_neZero n⟩ : Fin n) = 0 := rfl
/--
The `Fin.zero_le` in `Lean` only applies in `Fin (n+1)`.
This one instead uses a `NeZero n` typeclass hypothesis.
-/
@[simp]
protected theorem zero_le' [NeZero n] (a : Fin n) : 0 ≤ a :=
Nat.zero_le a.val
@[simp, norm_cast]
theorem val_eq_zero_iff [NeZero n] {a : Fin n} : a.val = 0 ↔ a = 0 := by
rw [Fin.ext_iff, val_zero]
theorem val_ne_zero_iff [NeZero n] {a : Fin n} : a.val ≠ 0 ↔ a ≠ 0 :=
val_eq_zero_iff.not
@[simp, norm_cast]
theorem val_pos_iff [NeZero n] {a : Fin n} : 0 < a.val ↔ 0 < a := by
rw [← val_fin_lt, val_zero]
/--
The `Fin.pos_iff_ne_zero` in `Lean` only applies in `Fin (n+1)`.
This one instead uses a `NeZero n` typeclass hypothesis.
-/
theorem pos_iff_ne_zero' [NeZero n] (a : Fin n) : 0 < a ↔ a ≠ 0 := by
rw [← val_pos_iff, Nat.pos_iff_ne_zero, val_ne_zero_iff]
@[simp] lemma cast_eq_self (a : Fin n) : a.cast rfl = a := rfl
@[simp] theorem cast_eq_zero {k l : ℕ} [NeZero k] [NeZero l]
(h : k = l) (x : Fin k) : Fin.cast h x = 0 ↔ x = 0 := by
simp [← val_eq_zero_iff]
lemma cast_injective {k l : ℕ} (h : k = l) : Injective (Fin.cast h) :=
fun a b hab ↦ by simpa [← val_eq_val] using hab
theorem last_pos' [NeZero n] : 0 < last n := n.pos_of_neZero
theorem one_lt_last [NeZero n] : 1 < last (n + 1) := by
rw [lt_iff_val_lt_val, val_one, val_last, Nat.lt_add_left_iff_pos, Nat.pos_iff_ne_zero]
exact NeZero.ne n
end Order
/-! ### Coercions to `ℤ` and the `fin_omega` tactic. -/
open Int
theorem coe_int_sub_eq_ite {n : Nat} (u v : Fin n) :
((u - v : Fin n) : Int) = if v ≤ u then (u - v : Int) else (u - v : Int) + n := by
rw [Fin.sub_def]
split
· rw [natCast_emod, Int.emod_eq_sub_self_emod, Int.emod_eq_of_lt] <;> omega
· rw [natCast_emod, Int.emod_eq_of_lt] <;> omega
theorem coe_int_sub_eq_mod {n : Nat} (u v : Fin n) :
((u - v : Fin n) : Int) = ((u : Int) - (v : Int)) % n := by
rw [coe_int_sub_eq_ite]
split
· rw [Int.emod_eq_of_lt] <;> omega
· rw [Int.emod_eq_add_self_emod, Int.emod_eq_of_lt] <;> omega
theorem coe_int_add_eq_ite {n : Nat} (u v : Fin n) :
((u + v : Fin n) : Int) = if (u + v : ℕ) < n then (u + v : Int) else (u + v : Int) - n := by
rw [Fin.add_def]
split
· rw [natCast_emod, Int.emod_eq_of_lt] <;> omega
· rw [natCast_emod, Int.emod_eq_sub_self_emod, Int.emod_eq_of_lt] <;> omega
theorem coe_int_add_eq_mod {n : Nat} (u v : Fin n) :
((u + v : Fin n) : Int) = ((u : Int) + (v : Int)) % n := by
rw [coe_int_add_eq_ite]
split
· rw [Int.emod_eq_of_lt] <;> omega
· rw [Int.emod_eq_sub_self_emod, Int.emod_eq_of_lt] <;> omega
-- Write `a + b` as `if (a + b : ℕ) < n then (a + b : ℤ) else (a + b : ℤ) - n` and
-- similarly `a - b` as `if (b : ℕ) ≤ a then (a - b : ℤ) else (a - b : ℤ) + n`.
attribute [fin_omega] coe_int_sub_eq_ite coe_int_add_eq_ite
-- Rewrite inequalities in `Fin` to inequalities in `ℕ`
attribute [fin_omega] Fin.lt_iff_val_lt_val Fin.le_iff_val_le_val
-- Rewrite `1 : Fin (n + 2)` to `1 : ℤ`
attribute [fin_omega] val_one
/--
Preprocessor for `omega` to handle inequalities in `Fin`.
Note that this involves a lot of case splitting, so may be slow.
-/
-- Further adjustment to the simp set can probably make this more powerful.
-- Please experiment and PR updates!
macro "fin_omega" : tactic => `(tactic|
{ try simp only [fin_omega, ← Int.ofNat_lt, ← Int.ofNat_le] at *
omega })
section Add
/-!
### addition, numerals, and coercion from Nat
-/
@[simp]
theorem val_one' (n : ℕ) [NeZero n] : ((1 : Fin n) : ℕ) = 1 % n :=
rfl
@[deprecated val_one' (since := "2025-03-10")]
theorem val_one'' {n : ℕ} : ((1 : Fin (n + 1)) : ℕ) = 1 % (n + 1) :=
rfl
instance nontrivial {n : ℕ} : Nontrivial (Fin (n + 2)) where
exists_pair_ne := ⟨0, 1, (ne_iff_vne 0 1).mpr (by simp [val_one, val_zero])⟩
theorem nontrivial_iff_two_le : Nontrivial (Fin n) ↔ 2 ≤ n := by
rcases n with (_ | _ | n) <;>
simp [Fin.nontrivial, not_nontrivial, Nat.succ_le_iff]
section Monoid
instance inhabitedFinOneAdd (n : ℕ) : Inhabited (Fin (1 + n)) :=
haveI : NeZero (1 + n) := by rw [Nat.add_comm]; infer_instance
inferInstance
@[simp]
theorem default_eq_zero (n : ℕ) [NeZero n] : (default : Fin n) = 0 :=
rfl
instance instNatCast [NeZero n] : NatCast (Fin n) where
natCast i := Fin.ofNat' n i
lemma natCast_def [NeZero n] (a : ℕ) : (a : Fin n) = ⟨a % n, mod_lt _ n.pos_of_neZero⟩ := rfl
end Monoid
theorem val_add_eq_ite {n : ℕ} (a b : Fin n) :
(↑(a + b) : ℕ) = if n ≤ a + b then a + b - n else a + b := by
rw [Fin.val_add, Nat.add_mod_eq_ite, Nat.mod_eq_of_lt (show ↑a < n from a.2),
Nat.mod_eq_of_lt (show ↑b < n from b.2)]
theorem val_add_eq_of_add_lt {n : ℕ} {a b : Fin n} (huv : a.val + b.val < n) :
(a + b).val = a.val + b.val := by
rw [val_add]
simp [Nat.mod_eq_of_lt huv]
lemma intCast_val_sub_eq_sub_add_ite {n : ℕ} (a b : Fin n) :
((a - b).val : ℤ) = a.val - b.val + if b ≤ a then 0 else n := by
split <;> fin_omega
lemma one_le_of_ne_zero {n : ℕ} [NeZero n] {k : Fin n} (hk : k ≠ 0) : 1 ≤ k := by
obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (NeZero.ne n)
cases n with
| zero => simp only [Nat.reduceAdd, Fin.isValue, Fin.zero_le]
| succ n => rwa [Fin.le_iff_val_le_val, Fin.val_one, Nat.one_le_iff_ne_zero, val_ne_zero_iff]
lemma val_sub_one_of_ne_zero [NeZero n] {i : Fin n} (hi : i ≠ 0) : (i - 1).val = i - 1 := by
obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (NeZero.ne n)
rw [Fin.sub_val_of_le (one_le_of_ne_zero hi), Fin.val_one', Nat.mod_eq_of_lt
(Nat.succ_le_iff.mpr (nontrivial_iff_two_le.mp <| nontrivial_of_ne i 0 hi))]
section OfNatCoe
@[simp]
theorem ofNat'_eq_cast (n : ℕ) [NeZero n] (a : ℕ) : Fin.ofNat' n a = a :=
rfl
@[simp] lemma val_natCast (a n : ℕ) [NeZero n] : (a : Fin n).val = a % n := rfl
/-- Converting an in-range number to `Fin (n + 1)` produces a result
whose value is the original number. -/
theorem val_cast_of_lt {n : ℕ} [NeZero n] {a : ℕ} (h : a < n) : (a : Fin n).val = a :=
Nat.mod_eq_of_lt h
/-- If `n` is non-zero, converting the value of a `Fin n` to `Fin n` results
in the same value. -/
@[simp, norm_cast] theorem cast_val_eq_self {n : ℕ} [NeZero n] (a : Fin n) : (a.val : Fin n) = a :=
Fin.ext <| val_cast_of_lt a.isLt
-- This is a special case of `CharP.cast_eq_zero` that doesn't require typeclass search
@[simp high] lemma natCast_self (n : ℕ) [NeZero n] : (n : Fin n) = 0 := by ext; simp
@[simp] lemma natCast_eq_zero {a n : ℕ} [NeZero n] : (a : Fin n) = 0 ↔ n ∣ a := by
simp [Fin.ext_iff, Nat.dvd_iff_mod_eq_zero]
@[simp]
theorem natCast_eq_last (n) : (n : Fin (n + 1)) = Fin.last n := by ext; simp
theorem le_val_last (i : Fin (n + 1)) : i ≤ n := by
rw [Fin.natCast_eq_last]
exact Fin.le_last i
variable {a b : ℕ}
lemma natCast_le_natCast (han : a ≤ n) (hbn : b ≤ n) : (a : Fin (n + 1)) ≤ b ↔ a ≤ b := by
rw [← Nat.lt_succ_iff] at han hbn
simp [le_iff_val_le_val, -val_fin_le, Nat.mod_eq_of_lt, han, hbn]
lemma natCast_lt_natCast (han : a ≤ n) (hbn : b ≤ n) : (a : Fin (n + 1)) < b ↔ a < b := by
rw [← Nat.lt_succ_iff] at han hbn; simp [lt_iff_val_lt_val, Nat.mod_eq_of_lt, han, hbn]
lemma natCast_mono (hbn : b ≤ n) (hab : a ≤ b) : (a : Fin (n + 1)) ≤ b :=
(natCast_le_natCast (hab.trans hbn) hbn).2 hab
lemma natCast_strictMono (hbn : b ≤ n) (hab : a < b) : (a : Fin (n + 1)) < b :=
(natCast_lt_natCast (hab.le.trans hbn) hbn).2 hab
end OfNatCoe
end Add
section Succ
/-!
### succ and casts into larger Fin types
-/
lemma succ_injective (n : ℕ) : Injective (@Fin.succ n) := fun a b ↦ by simp [Fin.ext_iff]
/-- `Fin.succ` as an `Embedding` -/
def succEmb (n : ℕ) : Fin n ↪ Fin (n + 1) where
toFun := succ
inj' := succ_injective _
@[simp]
theorem coe_succEmb : ⇑(succEmb n) = Fin.succ :=
rfl
@[deprecated (since := "2025-04-12")]
alias val_succEmb := coe_succEmb
@[simp]
theorem exists_succ_eq {x : Fin (n + 1)} : (∃ y, Fin.succ y = x) ↔ x ≠ 0 :=
⟨fun ⟨_, hy⟩ => hy ▸ succ_ne_zero _, x.cases (fun h => h.irrefl.elim) (fun _ _ => ⟨_, rfl⟩)⟩
theorem exists_succ_eq_of_ne_zero {x : Fin (n + 1)} (h : x ≠ 0) :
∃ y, Fin.succ y = x := exists_succ_eq.mpr h
@[simp]
theorem succ_zero_eq_one' [NeZero n] : Fin.succ (0 : Fin n) = 1 := by
cases n
· exact (NeZero.ne 0 rfl).elim
· rfl
theorem one_pos' [NeZero n] : (0 : Fin (n + 1)) < 1 := succ_zero_eq_one' (n := n) ▸ succ_pos _
theorem zero_ne_one' [NeZero n] : (0 : Fin (n + 1)) ≠ 1 := Fin.ne_of_lt one_pos'
/--
The `Fin.succ_one_eq_two` in `Lean` only applies in `Fin (n+2)`.
This one instead uses a `NeZero n` typeclass hypothesis.
-/
@[simp]
theorem succ_one_eq_two' [NeZero n] : Fin.succ (1 : Fin (n + 1)) = 2 := by
cases n
· exact (NeZero.ne 0 rfl).elim
· rfl
-- Version of `succ_one_eq_two` to be used by `dsimp`.
-- Note the `'` swapped around due to a move to std4.
/--
The `Fin.le_zero_iff` in `Lean` only applies in `Fin (n+1)`.
This one instead uses a `NeZero n` typeclass hypothesis.
-/
@[simp]
theorem le_zero_iff' {n : ℕ} [NeZero n] {k : Fin n} : k ≤ 0 ↔ k = 0 :=
⟨fun h => Fin.ext <| by rw [Nat.eq_zero_of_le_zero h]; rfl, by rintro rfl; exact Nat.le_refl _⟩
-- TODO: Move to Batteries
@[simp] lemma castLE_inj {hmn : m ≤ n} {a b : Fin m} : castLE hmn a = castLE hmn b ↔ a = b := by
simp [Fin.ext_iff]
@[simp] lemma castAdd_inj {a b : Fin m} : castAdd n a = castAdd n b ↔ a = b := by simp [Fin.ext_iff]
attribute [simp] castSucc_inj
lemma castLE_injective (hmn : m ≤ n) : Injective (castLE hmn) :=
fun _ _ hab ↦ Fin.ext (congr_arg val hab :)
lemma castAdd_injective (m n : ℕ) : Injective (@Fin.castAdd m n) := castLE_injective _
lemma castSucc_injective (n : ℕ) : Injective (@Fin.castSucc n) := castAdd_injective _ _
/-- `Fin.castLE` as an `Embedding`, `castLEEmb h i` embeds `i` into a larger `Fin` type. -/
@[simps apply]
def castLEEmb (h : n ≤ m) : Fin n ↪ Fin m where
toFun := castLE h
inj' := castLE_injective _
@[simp, norm_cast] lemma coe_castLEEmb {m n} (hmn : m ≤ n) : castLEEmb hmn = castLE hmn := rfl
/- The next proof can be golfed a lot using `Fintype.card`.
It is written this way to define `ENat.card` and `Nat.card` without a `Fintype` dependency
(not done yet). -/
lemma nonempty_embedding_iff : Nonempty (Fin n ↪ Fin m) ↔ n ≤ m := by
refine ⟨fun h ↦ ?_, fun h ↦ ⟨castLEEmb h⟩⟩
induction n generalizing m with
| zero => exact m.zero_le
| succ n ihn =>
obtain ⟨e⟩ := h
rcases exists_eq_succ_of_ne_zero (pos_iff_nonempty.2 (Nonempty.map e inferInstance)).ne'
with ⟨m, rfl⟩
refine Nat.succ_le_succ <| ihn ⟨?_⟩
refine ⟨fun i ↦ (e.setValue 0 0 i.succ).pred (mt e.setValue_eq_iff.1 i.succ_ne_zero),
fun i j h ↦ ?_⟩
simpa only [pred_inj, EmbeddingLike.apply_eq_iff_eq, succ_inj] using h
lemma equiv_iff_eq : Nonempty (Fin m ≃ Fin n) ↔ m = n :=
⟨fun ⟨e⟩ ↦ le_antisymm (nonempty_embedding_iff.1 ⟨e⟩) (nonempty_embedding_iff.1 ⟨e.symm⟩),
fun h ↦ h ▸ ⟨.refl _⟩⟩
@[simp] lemma castLE_castSucc {n m} (i : Fin n) (h : n + 1 ≤ m) :
i.castSucc.castLE h = i.castLE (Nat.le_of_succ_le h) :=
rfl
@[simp] lemma castLE_comp_castSucc {n m} (h : n + 1 ≤ m) :
Fin.castLE h ∘ Fin.castSucc = Fin.castLE (Nat.le_of_succ_le h) :=
rfl
@[simp] lemma castLE_rfl (n : ℕ) : Fin.castLE (le_refl n) = id :=
rfl
@[simp]
theorem range_castLE {n k : ℕ} (h : n ≤ k) : Set.range (castLE h) = { i : Fin k | (i : ℕ) < n } :=
Set.ext fun x => ⟨fun ⟨y, hy⟩ => hy ▸ y.2, fun hx => ⟨⟨x, hx⟩, rfl⟩⟩
@[simp]
theorem coe_of_injective_castLE_symm {n k : ℕ} (h : n ≤ k) (i : Fin k) (hi) :
((Equiv.ofInjective _ (castLE_injective h)).symm ⟨i, hi⟩ : ℕ) = i := by
rw [← coe_castLE h]
exact congr_arg Fin.val (Equiv.apply_ofInjective_symm _ _)
theorem leftInverse_cast (eq : n = m) : LeftInverse (Fin.cast eq.symm) (Fin.cast eq) :=
fun _ => rfl
theorem rightInverse_cast (eq : n = m) : RightInverse (Fin.cast eq.symm) (Fin.cast eq) :=
fun _ => rfl
@[simp]
theorem cast_inj (eq : n = m) {a b : Fin n} : a.cast eq = b.cast eq ↔ a = b := by
simp [← val_inj]
@[simp]
theorem cast_lt_cast (eq : n = m) {a b : Fin n} : a.cast eq < b.cast eq ↔ a < b :=
Iff.rfl
@[simp]
theorem cast_le_cast (eq : n = m) {a b : Fin n} : a.cast eq ≤ b.cast eq ↔ a ≤ b :=
Iff.rfl
/-- The 'identity' equivalence between `Fin m` and `Fin n` when `m = n`. -/
@[simps]
def _root_.finCongr (eq : n = m) : Fin n ≃ Fin m where
toFun := Fin.cast eq
invFun := Fin.cast eq.symm
left_inv := leftInverse_cast eq
right_inv := rightInverse_cast eq
@[simp] lemma _root_.finCongr_apply_mk (h : m = n) (k : ℕ) (hk : k < m) :
finCongr h ⟨k, hk⟩ = ⟨k, h ▸ hk⟩ := rfl
@[simp]
lemma _root_.finCongr_refl (h : n = n := rfl) : finCongr h = Equiv.refl (Fin n) := by ext; simp
@[simp] lemma _root_.finCongr_symm (h : m = n) : (finCongr h).symm = finCongr h.symm := rfl
@[simp] lemma _root_.finCongr_apply_coe (h : m = n) (k : Fin m) : (finCongr h k : ℕ) = k := rfl
lemma _root_.finCongr_symm_apply_coe (h : m = n) (k : Fin n) : ((finCongr h).symm k : ℕ) = k := rfl
/-- While in many cases `finCongr` is better than `Equiv.cast`/`cast`, sometimes we want to apply
a generic theorem about `cast`. -/
lemma _root_.finCongr_eq_equivCast (h : n = m) : finCongr h = .cast (h ▸ rfl) := by subst h; simp
/-- While in many cases `Fin.cast` is better than `Equiv.cast`/`cast`, sometimes we want to apply
a generic theorem about `cast`. -/
theorem cast_eq_cast (h : n = m) : (Fin.cast h : Fin n → Fin m) = _root_.cast (h ▸ rfl) := by
subst h
ext
rfl
/-- `Fin.castAdd` as an `Embedding`, `castAddEmb m i` embeds `i : Fin n` in `Fin (n+m)`.
See also `Fin.natAddEmb` and `Fin.addNatEmb`. -/
def castAddEmb (m) : Fin n ↪ Fin (n + m) := castLEEmb (le_add_right n m)
@[simp]
lemma coe_castAddEmb (m) : (castAddEmb m : Fin n → Fin (n + m)) = castAdd m := rfl
lemma castAddEmb_apply (m) (i : Fin n) : castAddEmb m i = castAdd m i := rfl
/-- `Fin.castSucc` as an `Embedding`, `castSuccEmb i` embeds `i : Fin n` in `Fin (n+1)`. -/
def castSuccEmb : Fin n ↪ Fin (n + 1) := castAddEmb _
@[simp, norm_cast] lemma coe_castSuccEmb : (castSuccEmb : Fin n → Fin (n + 1)) = Fin.castSucc := rfl
lemma castSuccEmb_apply (i : Fin n) : castSuccEmb i = i.castSucc := rfl
theorem castSucc_le_succ {n} (i : Fin n) : i.castSucc ≤ i.succ := Nat.le_succ i
@[simp] theorem castSucc_le_castSucc_iff {a b : Fin n} : castSucc a ≤ castSucc b ↔ a ≤ b := .rfl
@[simp] theorem succ_le_castSucc_iff {a b : Fin n} : succ a ≤ castSucc b ↔ a < b := by
rw [le_castSucc_iff, succ_lt_succ_iff]
@[simp] theorem castSucc_lt_succ_iff {a b : Fin n} : castSucc a < succ b ↔ a ≤ b := by
rw [castSucc_lt_iff_succ_le, succ_le_succ_iff]
theorem le_of_castSucc_lt_of_succ_lt {a b : Fin (n + 1)} {i : Fin n}
(hl : castSucc i < a) (hu : b < succ i) : b < a := by
simp [Fin.lt_def, -val_fin_lt] at *; omega
theorem castSucc_lt_or_lt_succ (p : Fin (n + 1)) (i : Fin n) : castSucc i < p ∨ p < i.succ := by
simp [Fin.lt_def, -val_fin_lt]; omega
theorem succ_le_or_le_castSucc (p : Fin (n + 1)) (i : Fin n) : succ i ≤ p ∨ p ≤ i.castSucc := by
rw [le_castSucc_iff, ← castSucc_lt_iff_succ_le]
exact p.castSucc_lt_or_lt_succ i
theorem eq_castSucc_of_ne_last {x : Fin (n + 1)} (h : x ≠ (last _)) :
∃ y, Fin.castSucc y = x := exists_castSucc_eq.mpr h
@[deprecated (since := "2025-02-06")]
alias exists_castSucc_eq_of_ne_last := eq_castSucc_of_ne_last
theorem forall_fin_succ' {P : Fin (n + 1) → Prop} :
(∀ i, P i) ↔ (∀ i : Fin n, P i.castSucc) ∧ P (.last _) :=
⟨fun H => ⟨fun _ => H _, H _⟩, fun ⟨H0, H1⟩ i => Fin.lastCases H1 H0 i⟩
-- to match `Fin.eq_zero_or_eq_succ`
theorem eq_castSucc_or_eq_last {n : Nat} (i : Fin (n + 1)) :
(∃ j : Fin n, i = j.castSucc) ∨ i = last n := i.lastCases (Or.inr rfl) (Or.inl ⟨·, rfl⟩)
@[simp]
theorem castSucc_ne_last {n : ℕ} (i : Fin n) : i.castSucc ≠ .last n :=
Fin.ne_of_lt i.castSucc_lt_last
theorem exists_fin_succ' {P : Fin (n + 1) → Prop} :
(∃ i, P i) ↔ (∃ i : Fin n, P i.castSucc) ∨ P (.last _) :=
⟨fun ⟨i, h⟩ => Fin.lastCases Or.inr (fun i hi => Or.inl ⟨i, hi⟩) i h,
fun h => h.elim (fun ⟨i, hi⟩ => ⟨i.castSucc, hi⟩) (fun h => ⟨.last _, h⟩)⟩
/--
The `Fin.castSucc_zero` in `Lean` only applies in `Fin (n+1)`.
This one instead uses a `NeZero n` typeclass hypothesis.
-/
@[simp]
theorem castSucc_zero' [NeZero n] : castSucc (0 : Fin n) = 0 := rfl
@[simp]
theorem castSucc_pos_iff [NeZero n] {i : Fin n} : 0 < castSucc i ↔ 0 < i := by simp [← val_pos_iff]
/-- `castSucc i` is positive when `i` is positive.
The `Fin.castSucc_pos` in `Lean` only applies in `Fin (n+1)`.
This one instead uses a `NeZero n` typeclass hypothesis. -/
alias ⟨_, castSucc_pos'⟩ := castSucc_pos_iff
/--
The `Fin.castSucc_eq_zero_iff` in `Lean` only applies in `Fin (n+1)`.
This one instead uses a `NeZero n` typeclass hypothesis.
-/
@[simp]
theorem castSucc_eq_zero_iff' [NeZero n] (a : Fin n) : castSucc a = 0 ↔ a = 0 :=
Fin.ext_iff.trans <| (Fin.ext_iff.trans <| by simp).symm
/--
The `Fin.castSucc_ne_zero_iff` in `Lean` only applies in `Fin (n+1)`.
This one instead uses a `NeZero n` typeclass hypothesis.
-/
theorem castSucc_ne_zero_iff' [NeZero n] (a : Fin n) : castSucc a ≠ 0 ↔ a ≠ 0 :=
not_iff_not.mpr <| castSucc_eq_zero_iff' a
theorem castSucc_ne_zero_of_lt {p i : Fin n} (h : p < i) : castSucc i ≠ 0 := by
cases n
· exact i.elim0
· rw [castSucc_ne_zero_iff', Ne, Fin.ext_iff]
exact ((zero_le _).trans_lt h).ne'
theorem succ_ne_last_iff (a : Fin (n + 1)) : succ a ≠ last (n + 1) ↔ a ≠ last n :=
not_iff_not.mpr <| succ_eq_last_succ
theorem succ_ne_last_of_lt {p i : Fin n} (h : i < p) : succ i ≠ last n := by
cases n
· exact i.elim0
· rw [succ_ne_last_iff, Ne, Fin.ext_iff]
exact ((le_last _).trans_lt' h).ne
@[norm_cast, simp]
theorem coe_eq_castSucc {a : Fin n} : (a : Fin (n + 1)) = castSucc a := by
ext
exact val_cast_of_lt (Nat.lt.step a.is_lt)
theorem coe_succ_lt_iff_lt {n : ℕ} {j k : Fin n} : (j : Fin <| n + 1) < k ↔ j < k := by
simp only [coe_eq_castSucc, castSucc_lt_castSucc_iff]
@[simp]
theorem range_castSucc {n : ℕ} : Set.range (castSucc : Fin n → Fin n.succ) =
({ i | (i : ℕ) < n } : Set (Fin n.succ)) := range_castLE (by omega)
@[simp]
theorem coe_of_injective_castSucc_symm {n : ℕ} (i : Fin n.succ) (hi) :
((Equiv.ofInjective castSucc (castSucc_injective _)).symm ⟨i, hi⟩ : ℕ) = i := by
rw [← coe_castSucc]
exact congr_arg val (Equiv.apply_ofInjective_symm _ _)
/-- `Fin.addNat` as an `Embedding`, `addNatEmb m i` adds `m` to `i`, generalizes `Fin.succ`. -/
@[simps! apply]
def addNatEmb (m) : Fin n ↪ Fin (n + m) where
toFun := (addNat · m)
inj' a b := by simp [Fin.ext_iff]
/-- `Fin.natAdd` as an `Embedding`, `natAddEmb n i` adds `n` to `i` "on the left". -/
@[simps! apply]
def natAddEmb (n) {m} : Fin m ↪ Fin (n + m) where
toFun := natAdd n
inj' a b := by simp [Fin.ext_iff]
theorem castSucc_castAdd (i : Fin n) : castSucc (castAdd m i) = castAdd (m + 1) i := rfl
theorem castSucc_natAdd (i : Fin m) : castSucc (natAdd n i) = natAdd n (castSucc i) := rfl
theorem succ_castAdd (i : Fin n) : succ (castAdd m i) =
if h : i.succ = last _ then natAdd n (0 : Fin (m + 1))
else castAdd (m + 1) ⟨i.1 + 1, lt_of_le_of_ne i.2 (Fin.val_ne_iff.mpr h)⟩ := by
split_ifs with h
exacts [Fin.ext (congr_arg Fin.val h :), rfl]
theorem succ_natAdd (i : Fin m) : succ (natAdd n i) = natAdd n (succ i) := rfl
end Succ
section Pred
/-!
### pred
-/
theorem pred_one' [NeZero n] (h := (zero_ne_one' (n := n)).symm) :
Fin.pred (1 : Fin (n + 1)) h = 0 := by
simp_rw [Fin.ext_iff, coe_pred, val_one', val_zero, Nat.sub_eq_zero_iff_le, Nat.mod_le]
theorem pred_last (h := Fin.ext_iff.not.2 last_pos'.ne') :
pred (last (n + 1)) h = last n := by simp_rw [← succ_last, pred_succ]
theorem pred_lt_iff {j : Fin n} {i : Fin (n + 1)} (hi : i ≠ 0) : pred i hi < j ↔ i < succ j := by
rw [← succ_lt_succ_iff, succ_pred]
theorem lt_pred_iff {j : Fin n} {i : Fin (n + 1)} (hi : i ≠ 0) : j < pred i hi ↔ succ j < i := by
rw [← succ_lt_succ_iff, succ_pred]
theorem pred_le_iff {j : Fin n} {i : Fin (n + 1)} (hi : i ≠ 0) : pred i hi ≤ j ↔ i ≤ succ j := by
rw [← succ_le_succ_iff, succ_pred]
theorem le_pred_iff {j : Fin n} {i : Fin (n + 1)} (hi : i ≠ 0) : j ≤ pred i hi ↔ succ j ≤ i := by
rw [← succ_le_succ_iff, succ_pred]
theorem castSucc_pred_eq_pred_castSucc {a : Fin (n + 1)} (ha : a ≠ 0)
(ha' := castSucc_ne_zero_iff.mpr ha) :
(a.pred ha).castSucc = (castSucc a).pred ha' := rfl
| Mathlib/Data/Fin/Basic.lean | 757 | 768 | theorem castSucc_pred_add_one_eq {a : Fin (n + 1)} (ha : a ≠ 0) :
(a.pred ha).castSucc + 1 = a := by | cases a using cases
· exact (ha rfl).elim
· rw [pred_succ, coeSucc_eq_succ]
theorem le_pred_castSucc_iff {a b : Fin (n + 1)} (ha : castSucc a ≠ 0) :
b ≤ (castSucc a).pred ha ↔ b < a := by
rw [le_pred_iff, succ_le_castSucc_iff]
theorem pred_castSucc_lt_iff {a b : Fin (n + 1)} (ha : castSucc a ≠ 0) :
(castSucc a).pred ha < b ↔ a ≤ b := by |
/-
Copyright (c) 2024 Jz Pan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jz Pan
-/
import Mathlib.Algebra.Module.Submodule.Ker
/-!
# Iterate maps and comaps of submodules
Some preliminary work for establishing the strong rank condition for noetherian rings.
Given two linear maps `f i : N →ₗ[R] M` and a submodule `K : Submodule R N`, we can define
`LinearMap.iterateMapComap f i n K : Submodule R N` to be `f⁻¹(i(⋯(f⁻¹(i(K)))))` (`n` times).
If `f(K) ≤ i(K)`, then this sequence is non-decreasing (`LinearMap.iterateMapComap_le_succ`).
On the other hand, if `f` is surjective, `i` is injective, and there exists some `m` such that
`LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`,
then for any `n`,
`LinearMap.iterateMapComap f i n K = LinearMap.iterateMapComap f i (n + 1) K`.
In particular, by taking `n = 0`, the kernel of `f` is contained in `K`
(`LinearMap.ker_le_of_iterateMapComap_eq_succ`),
which is a consequence of `LinearMap.ker_le_comap`.
As a special case, if one can take `K` to be zero,
then `f` is injective. This is the key result for establishing the strong rank condition
for noetherian rings.
The construction here is adapted from the proof in Djoković's paper
*Epimorphisms of modules which must be isomorphisms* [djokovic1973].
-/
open Function Submodule
namespace LinearMap
variable {R N M : Type*} [Semiring R] [AddCommMonoid N] [Module R N]
[AddCommMonoid M] [Module R M] (f i : N →ₗ[R] M)
/-- The `LinearMap.iterateMapComap f i n K : Submodule R N` is
`f⁻¹(i(⋯(f⁻¹(i(K)))))` (`n` times). -/
def iterateMapComap (n : ℕ) := (fun K : Submodule R N ↦ (K.map i).comap f)^[n]
/-- If `f(K) ≤ i(K)`, then `LinearMap.iterateMapComap` is not decreasing. -/
theorem iterateMapComap_le_succ (K : Submodule R N) (h : K.map f ≤ K.map i) (n : ℕ) :
f.iterateMapComap i n K ≤ f.iterateMapComap i (n + 1) K := by
nth_rw 2 [iterateMapComap]
rw [iterate_succ', Function.comp_apply, ← iterateMapComap, ← map_le_iff_le_comap]
induction n with
| zero => exact h
| succ n ih =>
simp_rw [iterateMapComap, iterate_succ', Function.comp_apply]
calc
_ ≤ (f.iterateMapComap i n K).map i := map_comap_le _ _
_ ≤ (((f.iterateMapComap i n K).map f).comap f).map i := map_mono (le_comap_map _ _)
_ ≤ _ := map_mono (comap_mono ih)
/-- If `f` is surjective, `i` is injective, and there exists some `m` such that
`LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`,
then for any `n`,
`LinearMap.iterateMapComap f i n K = LinearMap.iterateMapComap f i (n + 1) K`.
In particular, by taking `n = 0`, the kernel of `f` is contained in `K`
(`LinearMap.ker_le_of_iterateMapComap_eq_succ`),
which is a consequence of `LinearMap.ker_le_comap`. -/
| Mathlib/Algebra/Module/Submodule/IterateMapComap.lean | 65 | 79 | theorem iterateMapComap_eq_succ (K : Submodule R N)
(m : ℕ) (heq : f.iterateMapComap i m K = f.iterateMapComap i (m + 1) K)
(hf : Surjective f) (hi : Injective i) (n : ℕ) :
f.iterateMapComap i n K = f.iterateMapComap i (n + 1) K := by | induction n with
| zero =>
contrapose! heq
induction m with
| zero => exact heq
| succ m ih =>
rw [iterateMapComap, iterateMapComap, iterate_succ', iterate_succ']
exact fun H ↦ ih (map_injective_of_injective hi (comap_injective_of_surjective hf H))
| succ n ih =>
rw [iterateMapComap, iterateMapComap, iterate_succ', iterate_succ',
Function.comp_apply, Function.comp_apply, ← iterateMapComap, ← iterateMapComap, ih] |
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Devon Tuma
-/
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.RingTheory.Coprime.Basic
import Mathlib.Tactic.AdaptationNote
/-!
# Scaling the roots of a polynomial
This file defines `scaleRoots p s` for a polynomial `p` in one variable and a ring element `s` to
be the polynomial with root `r * s` for each root `r` of `p` and proves some basic results about it.
-/
variable {R S A K : Type*}
namespace Polynomial
section Semiring
variable [Semiring R] [Semiring S]
/-- `scaleRoots p s` is a polynomial with root `r * s` for each root `r` of `p`. -/
noncomputable def scaleRoots (p : R[X]) (s : R) : R[X] :=
∑ i ∈ p.support, monomial i (p.coeff i * s ^ (p.natDegree - i))
@[simp]
theorem coeff_scaleRoots (p : R[X]) (s : R) (i : ℕ) :
(scaleRoots p s).coeff i = coeff p i * s ^ (p.natDegree - i) := by
simp +contextual [scaleRoots, coeff_monomial]
theorem coeff_scaleRoots_natDegree (p : R[X]) (s : R) :
(scaleRoots p s).coeff p.natDegree = p.leadingCoeff := by
rw [leadingCoeff, coeff_scaleRoots, tsub_self, pow_zero, mul_one]
@[simp]
theorem zero_scaleRoots (s : R) : scaleRoots 0 s = 0 := by
ext
simp
theorem scaleRoots_ne_zero {p : R[X]} (hp : p ≠ 0) (s : R) : scaleRoots p s ≠ 0 := by
intro h
have : p.coeff p.natDegree ≠ 0 := mt leadingCoeff_eq_zero.mp hp
have : (scaleRoots p s).coeff p.natDegree = 0 :=
congr_fun (congr_arg (coeff : R[X] → ℕ → R) h) p.natDegree
rw [coeff_scaleRoots_natDegree] at this
contradiction
| Mathlib/RingTheory/Polynomial/ScaleRoots.lean | 53 | 59 | theorem support_scaleRoots_le (p : R[X]) (s : R) : (scaleRoots p s).support ≤ p.support := by | intro
simpa using left_ne_zero_of_mul
theorem support_scaleRoots_eq (p : R[X]) {s : R} (hs : s ∈ nonZeroDivisors R) :
(scaleRoots p s).support = p.support :=
le_antisymm (support_scaleRoots_le p s) |
/-
Copyright (c) 2018 Michael Jendrusch. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Jendrusch, Kim Morrison, Bhavik Mehta, Jakob von Raumer
-/
import Mathlib.CategoryTheory.EqToHom
import Mathlib.CategoryTheory.Functor.Trifunctor
import Mathlib.CategoryTheory.Products.Basic
/-!
# Monoidal categories
A monoidal category is a category equipped with a tensor product, unitors, and an associator.
In the definition, we provide the tensor product as a pair of functions
* `tensorObj : C → C → C`
* `tensorHom : (X₁ ⟶ Y₁) → (X₂ ⟶ Y₂) → ((X₁ ⊗ X₂) ⟶ (Y₁ ⊗ Y₂))`
and allow use of the overloaded notation `⊗` for both.
The unitors and associator are provided componentwise.
The tensor product can be expressed as a functor via `tensor : C × C ⥤ C`.
The unitors and associator are gathered together as natural
isomorphisms in `leftUnitor_nat_iso`, `rightUnitor_nat_iso` and `associator_nat_iso`.
Some consequences of the definition are proved in other files after proving the coherence theorem,
e.g. `(λ_ (𝟙_ C)).hom = (ρ_ (𝟙_ C)).hom` in `CategoryTheory.Monoidal.CoherenceLemmas`.
## Implementation notes
In the definition of monoidal categories, we also provide the whiskering operators:
* `whiskerLeft (X : C) {Y₁ Y₂ : C} (f : Y₁ ⟶ Y₂) : X ⊗ Y₁ ⟶ X ⊗ Y₂`, denoted by `X ◁ f`,
* `whiskerRight {X₁ X₂ : C} (f : X₁ ⟶ X₂) (Y : C) : X₁ ⊗ Y ⟶ X₂ ⊗ Y`, denoted by `f ▷ Y`.
These are products of an object and a morphism (the terminology "whiskering"
is borrowed from 2-category theory). The tensor product of morphisms `tensorHom` can be defined
in terms of the whiskerings. There are two possible such definitions, which are related by
the exchange property of the whiskerings. These two definitions are accessed by `tensorHom_def`
and `tensorHom_def'`. By default, `tensorHom` is defined so that `tensorHom_def` holds
definitionally.
If you want to provide `tensorHom` and define `whiskerLeft` and `whiskerRight` in terms of it,
you can use the alternative constructor `CategoryTheory.MonoidalCategory.ofTensorHom`.
The whiskerings are useful when considering simp-normal forms of morphisms in monoidal categories.
### Simp-normal form for morphisms
Rewriting involving associators and unitors could be very complicated. We try to ease this
complexity by putting carefully chosen simp lemmas that rewrite any morphisms into the simp-normal
form defined below. Rewriting into simp-normal form is especially useful in preprocessing
performed by the `coherence` tactic.
The simp-normal form of morphisms is defined to be an expression that has the minimal number of
parentheses. More precisely,
1. it is a composition of morphisms like `f₁ ≫ f₂ ≫ f₃ ≫ f₄ ≫ f₅` such that each `fᵢ` is
either a structural morphisms (morphisms made up only of identities, associators, unitors)
or non-structural morphisms, and
2. each non-structural morphism in the composition is of the form `X₁ ◁ X₂ ◁ X₃ ◁ f ▷ X₄ ▷ X₅`,
where each `Xᵢ` is a object that is not the identity or a tensor and `f` is a non-structural
morphisms that is not the identity or a composite.
Note that `X₁ ◁ X₂ ◁ X₃ ◁ f ▷ X₄ ▷ X₅` is actually `X₁ ◁ (X₂ ◁ (X₃ ◁ ((f ▷ X₄) ▷ X₅)))`.
Currently, the simp lemmas don't rewrite `𝟙 X ⊗ f` and `f ⊗ 𝟙 Y` into `X ◁ f` and `f ▷ Y`,
respectively, since it requires a huge refactoring. We hope to add these simp lemmas soon.
## References
* Tensor categories, Etingof, Gelaki, Nikshych, Ostrik,
http://www-math.mit.edu/~etingof/egnobookfinal.pdf
* <https://stacks.math.columbia.edu/tag/0FFK>.
-/
universe v u
open CategoryTheory.Category
open CategoryTheory.Iso
namespace CategoryTheory
/-- Auxiliary structure to carry only the data fields of (and provide notation for)
`MonoidalCategory`. -/
class MonoidalCategoryStruct (C : Type u) [𝒞 : Category.{v} C] where
/-- curried tensor product of objects -/
tensorObj : C → C → C
/-- left whiskering for morphisms -/
whiskerLeft (X : C) {Y₁ Y₂ : C} (f : Y₁ ⟶ Y₂) : tensorObj X Y₁ ⟶ tensorObj X Y₂
/-- right whiskering for morphisms -/
whiskerRight {X₁ X₂ : C} (f : X₁ ⟶ X₂) (Y : C) : tensorObj X₁ Y ⟶ tensorObj X₂ Y
/-- Tensor product of identity maps is the identity: `(𝟙 X₁ ⊗ 𝟙 X₂) = 𝟙 (X₁ ⊗ X₂)` -/
-- By default, it is defined in terms of whiskerings.
tensorHom {X₁ Y₁ X₂ Y₂ : C} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) : (tensorObj X₁ X₂ ⟶ tensorObj Y₁ Y₂) :=
whiskerRight f X₂ ≫ whiskerLeft Y₁ g
/-- The tensor unity in the monoidal structure `𝟙_ C` -/
tensorUnit (C) : C
/-- The associator isomorphism `(X ⊗ Y) ⊗ Z ≃ X ⊗ (Y ⊗ Z)` -/
associator : ∀ X Y Z : C, tensorObj (tensorObj X Y) Z ≅ tensorObj X (tensorObj Y Z)
/-- The left unitor: `𝟙_ C ⊗ X ≃ X` -/
leftUnitor : ∀ X : C, tensorObj tensorUnit X ≅ X
/-- The right unitor: `X ⊗ 𝟙_ C ≃ X` -/
rightUnitor : ∀ X : C, tensorObj X tensorUnit ≅ X
namespace MonoidalCategory
export MonoidalCategoryStruct
(tensorObj whiskerLeft whiskerRight tensorHom tensorUnit associator leftUnitor rightUnitor)
end MonoidalCategory
namespace MonoidalCategory
/-- Notation for `tensorObj`, the tensor product of objects in a monoidal category -/
scoped infixr:70 " ⊗ " => MonoidalCategoryStruct.tensorObj
/-- Notation for the `whiskerLeft` operator of monoidal categories -/
scoped infixr:81 " ◁ " => MonoidalCategoryStruct.whiskerLeft
/-- Notation for the `whiskerRight` operator of monoidal categories -/
scoped infixl:81 " ▷ " => MonoidalCategoryStruct.whiskerRight
/-- Notation for `tensorHom`, the tensor product of morphisms in a monoidal category -/
scoped infixr:70 " ⊗ " => MonoidalCategoryStruct.tensorHom
/-- Notation for `tensorUnit`, the two-sided identity of `⊗` -/
scoped notation "𝟙_ " C:arg => MonoidalCategoryStruct.tensorUnit C
/-- Notation for the monoidal `associator`: `(X ⊗ Y) ⊗ Z ≃ X ⊗ (Y ⊗ Z)` -/
scoped notation "α_" => MonoidalCategoryStruct.associator
/-- Notation for the `leftUnitor`: `𝟙_C ⊗ X ≃ X` -/
scoped notation "λ_" => MonoidalCategoryStruct.leftUnitor
/-- Notation for the `rightUnitor`: `X ⊗ 𝟙_C ≃ X` -/
scoped notation "ρ_" => MonoidalCategoryStruct.rightUnitor
/-- The property that the pentagon relation is satisfied by four objects
in a category equipped with a `MonoidalCategoryStruct`. -/
def Pentagon {C : Type u} [Category.{v} C] [MonoidalCategoryStruct C]
(Y₁ Y₂ Y₃ Y₄ : C) : Prop :=
(α_ Y₁ Y₂ Y₃).hom ▷ Y₄ ≫ (α_ Y₁ (Y₂ ⊗ Y₃) Y₄).hom ≫ Y₁ ◁ (α_ Y₂ Y₃ Y₄).hom =
(α_ (Y₁ ⊗ Y₂) Y₃ Y₄).hom ≫ (α_ Y₁ Y₂ (Y₃ ⊗ Y₄)).hom
end MonoidalCategory
open MonoidalCategory
/--
In a monoidal category, we can take the tensor product of objects, `X ⊗ Y` and of morphisms `f ⊗ g`.
Tensor product does not need to be strictly associative on objects, but there is a
specified associator, `α_ X Y Z : (X ⊗ Y) ⊗ Z ≅ X ⊗ (Y ⊗ Z)`. There is a tensor unit `𝟙_ C`,
with specified left and right unitor isomorphisms `λ_ X : 𝟙_ C ⊗ X ≅ X` and `ρ_ X : X ⊗ 𝟙_ C ≅ X`.
These associators and unitors satisfy the pentagon and triangle equations. -/
@[stacks 0FFK]
-- Porting note: The Mathport did not translate the temporary notation
class MonoidalCategory (C : Type u) [𝒞 : Category.{v} C] extends MonoidalCategoryStruct C where
tensorHom_def {X₁ Y₁ X₂ Y₂ : C} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) :
f ⊗ g = (f ▷ X₂) ≫ (Y₁ ◁ g) := by
aesop_cat
/-- Tensor product of identity maps is the identity: `(𝟙 X₁ ⊗ 𝟙 X₂) = 𝟙 (X₁ ⊗ X₂)` -/
tensor_id : ∀ X₁ X₂ : C, 𝟙 X₁ ⊗ 𝟙 X₂ = 𝟙 (X₁ ⊗ X₂) := by aesop_cat
/--
Tensor product of compositions is composition of tensor products:
`(f₁ ≫ g₁) ⊗ (f₂ ≫ g₂) = (f₁ ⊗ f₂) ≫ (g₁ ⊗ g₂)`
-/
tensor_comp :
∀ {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂),
(f₁ ≫ g₁) ⊗ (f₂ ≫ g₂) = (f₁ ⊗ f₂) ≫ (g₁ ⊗ g₂) := by
aesop_cat
whiskerLeft_id : ∀ (X Y : C), X ◁ 𝟙 Y = 𝟙 (X ⊗ Y) := by
aesop_cat
id_whiskerRight : ∀ (X Y : C), 𝟙 X ▷ Y = 𝟙 (X ⊗ Y) := by
aesop_cat
/-- Naturality of the associator isomorphism: `(f₁ ⊗ f₂) ⊗ f₃ ≃ f₁ ⊗ (f₂ ⊗ f₃)` -/
associator_naturality :
∀ {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃),
((f₁ ⊗ f₂) ⊗ f₃) ≫ (α_ Y₁ Y₂ Y₃).hom = (α_ X₁ X₂ X₃).hom ≫ (f₁ ⊗ (f₂ ⊗ f₃)) := by
aesop_cat
/--
Naturality of the left unitor, commutativity of `𝟙_ C ⊗ X ⟶ 𝟙_ C ⊗ Y ⟶ Y` and `𝟙_ C ⊗ X ⟶ X ⟶ Y`
-/
leftUnitor_naturality :
∀ {X Y : C} (f : X ⟶ Y), 𝟙_ _ ◁ f ≫ (λ_ Y).hom = (λ_ X).hom ≫ f := by
aesop_cat
/--
Naturality of the right unitor: commutativity of `X ⊗ 𝟙_ C ⟶ Y ⊗ 𝟙_ C ⟶ Y` and `X ⊗ 𝟙_ C ⟶ X ⟶ Y`
-/
rightUnitor_naturality :
∀ {X Y : C} (f : X ⟶ Y), f ▷ 𝟙_ _ ≫ (ρ_ Y).hom = (ρ_ X).hom ≫ f := by
aesop_cat
/--
The pentagon identity relating the isomorphism between `X ⊗ (Y ⊗ (Z ⊗ W))` and `((X ⊗ Y) ⊗ Z) ⊗ W`
-/
pentagon :
∀ W X Y Z : C,
(α_ W X Y).hom ▷ Z ≫ (α_ W (X ⊗ Y) Z).hom ≫ W ◁ (α_ X Y Z).hom =
(α_ (W ⊗ X) Y Z).hom ≫ (α_ W X (Y ⊗ Z)).hom := by
aesop_cat
/--
The identity relating the isomorphisms between `X ⊗ (𝟙_ C ⊗ Y)`, `(X ⊗ 𝟙_ C) ⊗ Y` and `X ⊗ Y`
-/
triangle :
∀ X Y : C, (α_ X (𝟙_ _) Y).hom ≫ X ◁ (λ_ Y).hom = (ρ_ X).hom ▷ Y := by
aesop_cat
attribute [reassoc] MonoidalCategory.tensorHom_def
attribute [reassoc, simp] MonoidalCategory.whiskerLeft_id
attribute [reassoc, simp] MonoidalCategory.id_whiskerRight
attribute [reassoc] MonoidalCategory.tensor_comp
attribute [simp] MonoidalCategory.tensor_comp
attribute [reassoc] MonoidalCategory.associator_naturality
attribute [reassoc] MonoidalCategory.leftUnitor_naturality
attribute [reassoc] MonoidalCategory.rightUnitor_naturality
attribute [reassoc (attr := simp)] MonoidalCategory.pentagon
attribute [reassoc (attr := simp)] MonoidalCategory.triangle
namespace MonoidalCategory
variable {C : Type u} [𝒞 : Category.{v} C] [MonoidalCategory C]
@[simp]
theorem id_tensorHom (X : C) {Y₁ Y₂ : C} (f : Y₁ ⟶ Y₂) :
𝟙 X ⊗ f = X ◁ f := by
simp [tensorHom_def]
@[simp]
theorem tensorHom_id {X₁ X₂ : C} (f : X₁ ⟶ X₂) (Y : C) :
f ⊗ 𝟙 Y = f ▷ Y := by
simp [tensorHom_def]
@[reassoc, simp]
theorem whiskerLeft_comp (W : C) {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :
W ◁ (f ≫ g) = W ◁ f ≫ W ◁ g := by
simp only [← id_tensorHom, ← tensor_comp, comp_id]
@[reassoc, simp]
theorem id_whiskerLeft {X Y : C} (f : X ⟶ Y) :
𝟙_ C ◁ f = (λ_ X).hom ≫ f ≫ (λ_ Y).inv := by
rw [← assoc, ← leftUnitor_naturality]; simp [id_tensorHom]
@[reassoc, simp]
theorem tensor_whiskerLeft (X Y : C) {Z Z' : C} (f : Z ⟶ Z') :
(X ⊗ Y) ◁ f = (α_ X Y Z).hom ≫ X ◁ Y ◁ f ≫ (α_ X Y Z').inv := by
simp only [← id_tensorHom, ← tensorHom_id]
rw [← assoc, ← associator_naturality]
simp
@[reassoc, simp]
theorem comp_whiskerRight {W X Y : C} (f : W ⟶ X) (g : X ⟶ Y) (Z : C) :
(f ≫ g) ▷ Z = f ▷ Z ≫ g ▷ Z := by
simp only [← tensorHom_id, ← tensor_comp, id_comp]
@[reassoc, simp]
theorem whiskerRight_id {X Y : C} (f : X ⟶ Y) :
f ▷ 𝟙_ C = (ρ_ X).hom ≫ f ≫ (ρ_ Y).inv := by
rw [← assoc, ← rightUnitor_naturality]; simp [tensorHom_id]
@[reassoc, simp]
theorem whiskerRight_tensor {X X' : C} (f : X ⟶ X') (Y Z : C) :
f ▷ (Y ⊗ Z) = (α_ X Y Z).inv ≫ f ▷ Y ▷ Z ≫ (α_ X' Y Z).hom := by
simp only [← id_tensorHom, ← tensorHom_id]
rw [associator_naturality]
simp [tensor_id]
@[reassoc, simp]
theorem whisker_assoc (X : C) {Y Y' : C} (f : Y ⟶ Y') (Z : C) :
(X ◁ f) ▷ Z = (α_ X Y Z).hom ≫ X ◁ f ▷ Z ≫ (α_ X Y' Z).inv := by
simp only [← id_tensorHom, ← tensorHom_id]
rw [← assoc, ← associator_naturality]
simp
@[reassoc]
theorem whisker_exchange {W X Y Z : C} (f : W ⟶ X) (g : Y ⟶ Z) :
W ◁ g ≫ f ▷ Z = f ▷ Y ≫ X ◁ g := by
simp only [← id_tensorHom, ← tensorHom_id, ← tensor_comp, id_comp, comp_id]
@[reassoc]
theorem tensorHom_def' {X₁ Y₁ X₂ Y₂ : C} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) :
f ⊗ g = X₁ ◁ g ≫ f ▷ Y₂ :=
whisker_exchange f g ▸ tensorHom_def f g
@[reassoc (attr := simp)]
theorem whiskerLeft_hom_inv (X : C) {Y Z : C} (f : Y ≅ Z) :
X ◁ f.hom ≫ X ◁ f.inv = 𝟙 (X ⊗ Y) := by
rw [← whiskerLeft_comp, hom_inv_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem hom_inv_whiskerRight {X Y : C} (f : X ≅ Y) (Z : C) :
f.hom ▷ Z ≫ f.inv ▷ Z = 𝟙 (X ⊗ Z) := by
rw [← comp_whiskerRight, hom_inv_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_inv_hom (X : C) {Y Z : C} (f : Y ≅ Z) :
X ◁ f.inv ≫ X ◁ f.hom = 𝟙 (X ⊗ Z) := by
rw [← whiskerLeft_comp, inv_hom_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem inv_hom_whiskerRight {X Y : C} (f : X ≅ Y) (Z : C) :
f.inv ▷ Z ≫ f.hom ▷ Z = 𝟙 (Y ⊗ Z) := by
rw [← comp_whiskerRight, inv_hom_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_hom_inv' (X : C) {Y Z : C} (f : Y ⟶ Z) [IsIso f] :
X ◁ f ≫ X ◁ inv f = 𝟙 (X ⊗ Y) := by
rw [← whiskerLeft_comp, IsIso.hom_inv_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem hom_inv_whiskerRight' {X Y : C} (f : X ⟶ Y) [IsIso f] (Z : C) :
f ▷ Z ≫ inv f ▷ Z = 𝟙 (X ⊗ Z) := by
rw [← comp_whiskerRight, IsIso.hom_inv_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_inv_hom' (X : C) {Y Z : C} (f : Y ⟶ Z) [IsIso f] :
X ◁ inv f ≫ X ◁ f = 𝟙 (X ⊗ Z) := by
rw [← whiskerLeft_comp, IsIso.inv_hom_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem inv_hom_whiskerRight' {X Y : C} (f : X ⟶ Y) [IsIso f] (Z : C) :
inv f ▷ Z ≫ f ▷ Z = 𝟙 (Y ⊗ Z) := by
rw [← comp_whiskerRight, IsIso.inv_hom_id, id_whiskerRight]
/-- The left whiskering of an isomorphism is an isomorphism. -/
@[simps]
def whiskerLeftIso (X : C) {Y Z : C} (f : Y ≅ Z) : X ⊗ Y ≅ X ⊗ Z where
hom := X ◁ f.hom
inv := X ◁ f.inv
instance whiskerLeft_isIso (X : C) {Y Z : C} (f : Y ⟶ Z) [IsIso f] : IsIso (X ◁ f) :=
(whiskerLeftIso X (asIso f)).isIso_hom
@[simp]
theorem inv_whiskerLeft (X : C) {Y Z : C} (f : Y ⟶ Z) [IsIso f] :
inv (X ◁ f) = X ◁ inv f := by
aesop_cat
@[simp]
lemma whiskerLeftIso_refl (W X : C) :
whiskerLeftIso W (Iso.refl X) = Iso.refl (W ⊗ X) :=
Iso.ext (whiskerLeft_id W X)
@[simp]
lemma whiskerLeftIso_trans (W : C) {X Y Z : C} (f : X ≅ Y) (g : Y ≅ Z) :
whiskerLeftIso W (f ≪≫ g) = whiskerLeftIso W f ≪≫ whiskerLeftIso W g :=
Iso.ext (whiskerLeft_comp W f.hom g.hom)
@[simp]
lemma whiskerLeftIso_symm (W : C) {X Y : C} (f : X ≅ Y) :
(whiskerLeftIso W f).symm = whiskerLeftIso W f.symm := rfl
/-- The right whiskering of an isomorphism is an isomorphism. -/
@[simps!]
def whiskerRightIso {X Y : C} (f : X ≅ Y) (Z : C) : X ⊗ Z ≅ Y ⊗ Z where
hom := f.hom ▷ Z
inv := f.inv ▷ Z
instance whiskerRight_isIso {X Y : C} (f : X ⟶ Y) (Z : C) [IsIso f] : IsIso (f ▷ Z) :=
(whiskerRightIso (asIso f) Z).isIso_hom
@[simp]
theorem inv_whiskerRight {X Y : C} (f : X ⟶ Y) (Z : C) [IsIso f] :
inv (f ▷ Z) = inv f ▷ Z := by
aesop_cat
@[simp]
lemma whiskerRightIso_refl (X W : C) :
whiskerRightIso (Iso.refl X) W = Iso.refl (X ⊗ W) :=
Iso.ext (id_whiskerRight X W)
@[simp]
lemma whiskerRightIso_trans {X Y Z : C} (f : X ≅ Y) (g : Y ≅ Z) (W : C) :
whiskerRightIso (f ≪≫ g) W = whiskerRightIso f W ≪≫ whiskerRightIso g W :=
Iso.ext (comp_whiskerRight f.hom g.hom W)
@[simp]
lemma whiskerRightIso_symm {X Y : C} (f : X ≅ Y) (W : C) :
(whiskerRightIso f W).symm = whiskerRightIso f.symm W := rfl
/-- The tensor product of two isomorphisms is an isomorphism. -/
@[simps]
def tensorIso {X Y X' Y' : C} (f : X ≅ Y)
(g : X' ≅ Y') : X ⊗ X' ≅ Y ⊗ Y' where
hom := f.hom ⊗ g.hom
inv := f.inv ⊗ g.inv
hom_inv_id := by rw [← tensor_comp, Iso.hom_inv_id, Iso.hom_inv_id, ← tensor_id]
inv_hom_id := by rw [← tensor_comp, Iso.inv_hom_id, Iso.inv_hom_id, ← tensor_id]
/-- Notation for `tensorIso`, the tensor product of isomorphisms -/
scoped infixr:70 " ⊗ " => tensorIso
theorem tensorIso_def {X Y X' Y' : C} (f : X ≅ Y) (g : X' ≅ Y') :
f ⊗ g = whiskerRightIso f X' ≪≫ whiskerLeftIso Y g :=
Iso.ext (tensorHom_def f.hom g.hom)
theorem tensorIso_def' {X Y X' Y' : C} (f : X ≅ Y) (g : X' ≅ Y') :
f ⊗ g = whiskerLeftIso X g ≪≫ whiskerRightIso f Y' :=
Iso.ext (tensorHom_def' f.hom g.hom)
instance tensor_isIso {W X Y Z : C} (f : W ⟶ X) [IsIso f] (g : Y ⟶ Z) [IsIso g] : IsIso (f ⊗ g) :=
(asIso f ⊗ asIso g).isIso_hom
@[simp]
theorem inv_tensor {W X Y Z : C} (f : W ⟶ X) [IsIso f] (g : Y ⟶ Z) [IsIso g] :
inv (f ⊗ g) = inv f ⊗ inv g := by
simp [tensorHom_def ,whisker_exchange]
variable {W X Y Z : C}
theorem whiskerLeft_dite {P : Prop} [Decidable P]
(X : C) {Y Z : C} (f : P → (Y ⟶ Z)) (f' : ¬P → (Y ⟶ Z)) :
X ◁ (if h : P then f h else f' h) = if h : P then X ◁ f h else X ◁ f' h := by
split_ifs <;> rfl
theorem dite_whiskerRight {P : Prop} [Decidable P]
{X Y : C} (f : P → (X ⟶ Y)) (f' : ¬P → (X ⟶ Y)) (Z : C) :
(if h : P then f h else f' h) ▷ Z = if h : P then f h ▷ Z else f' h ▷ Z := by
split_ifs <;> rfl
theorem tensor_dite {P : Prop} [Decidable P] {W X Y Z : C} (f : W ⟶ X) (g : P → (Y ⟶ Z))
(g' : ¬P → (Y ⟶ Z)) : (f ⊗ if h : P then g h else g' h) =
if h : P then f ⊗ g h else f ⊗ g' h := by split_ifs <;> rfl
theorem dite_tensor {P : Prop} [Decidable P] {W X Y Z : C} (f : W ⟶ X) (g : P → (Y ⟶ Z))
(g' : ¬P → (Y ⟶ Z)) : (if h : P then g h else g' h) ⊗ f =
if h : P then g h ⊗ f else g' h ⊗ f := by split_ifs <;> rfl
@[simp]
theorem whiskerLeft_eqToHom (X : C) {Y Z : C} (f : Y = Z) :
X ◁ eqToHom f = eqToHom (congr_arg₂ tensorObj rfl f) := by
cases f
simp only [whiskerLeft_id, eqToHom_refl]
@[simp]
theorem eqToHom_whiskerRight {X Y : C} (f : X = Y) (Z : C) :
eqToHom f ▷ Z = eqToHom (congr_arg₂ tensorObj f rfl) := by
cases f
simp only [id_whiskerRight, eqToHom_refl]
@[reassoc]
theorem associator_naturality_left {X X' : C} (f : X ⟶ X') (Y Z : C) :
f ▷ Y ▷ Z ≫ (α_ X' Y Z).hom = (α_ X Y Z).hom ≫ f ▷ (Y ⊗ Z) := by simp
@[reassoc]
theorem associator_inv_naturality_left {X X' : C} (f : X ⟶ X') (Y Z : C) :
f ▷ (Y ⊗ Z) ≫ (α_ X' Y Z).inv = (α_ X Y Z).inv ≫ f ▷ Y ▷ Z := by simp
@[reassoc]
theorem whiskerRight_tensor_symm {X X' : C} (f : X ⟶ X') (Y Z : C) :
f ▷ Y ▷ Z = (α_ X Y Z).hom ≫ f ▷ (Y ⊗ Z) ≫ (α_ X' Y Z).inv := by simp
@[reassoc]
theorem associator_naturality_middle (X : C) {Y Y' : C} (f : Y ⟶ Y') (Z : C) :
(X ◁ f) ▷ Z ≫ (α_ X Y' Z).hom = (α_ X Y Z).hom ≫ X ◁ f ▷ Z := by simp
@[reassoc]
theorem associator_inv_naturality_middle (X : C) {Y Y' : C} (f : Y ⟶ Y') (Z : C) :
X ◁ f ▷ Z ≫ (α_ X Y' Z).inv = (α_ X Y Z).inv ≫ (X ◁ f) ▷ Z := by simp
@[reassoc]
theorem whisker_assoc_symm (X : C) {Y Y' : C} (f : Y ⟶ Y') (Z : C) :
X ◁ f ▷ Z = (α_ X Y Z).inv ≫ (X ◁ f) ▷ Z ≫ (α_ X Y' Z).hom := by simp
@[reassoc]
theorem associator_naturality_right (X Y : C) {Z Z' : C} (f : Z ⟶ Z') :
(X ⊗ Y) ◁ f ≫ (α_ X Y Z').hom = (α_ X Y Z).hom ≫ X ◁ Y ◁ f := by simp
@[reassoc]
theorem associator_inv_naturality_right (X Y : C) {Z Z' : C} (f : Z ⟶ Z') :
X ◁ Y ◁ f ≫ (α_ X Y Z').inv = (α_ X Y Z).inv ≫ (X ⊗ Y) ◁ f := by simp
@[reassoc]
theorem tensor_whiskerLeft_symm (X Y : C) {Z Z' : C} (f : Z ⟶ Z') :
X ◁ Y ◁ f = (α_ X Y Z).inv ≫ (X ⊗ Y) ◁ f ≫ (α_ X Y Z').hom := by simp
@[reassoc]
theorem leftUnitor_inv_naturality {X Y : C} (f : X ⟶ Y) :
f ≫ (λ_ Y).inv = (λ_ X).inv ≫ _ ◁ f := by simp
@[reassoc]
theorem id_whiskerLeft_symm {X X' : C} (f : X ⟶ X') :
f = (λ_ X).inv ≫ 𝟙_ C ◁ f ≫ (λ_ X').hom := by
simp only [id_whiskerLeft, assoc, inv_hom_id, comp_id, inv_hom_id_assoc]
@[reassoc]
theorem rightUnitor_inv_naturality {X X' : C} (f : X ⟶ X') :
f ≫ (ρ_ X').inv = (ρ_ X).inv ≫ f ▷ _ := by simp
@[reassoc]
theorem whiskerRight_id_symm {X Y : C} (f : X ⟶ Y) :
f = (ρ_ X).inv ≫ f ▷ 𝟙_ C ≫ (ρ_ Y).hom := by
simp
theorem whiskerLeft_iff {X Y : C} (f g : X ⟶ Y) : 𝟙_ C ◁ f = 𝟙_ C ◁ g ↔ f = g := by simp
theorem whiskerRight_iff {X Y : C} (f g : X ⟶ Y) : f ▷ 𝟙_ C = g ▷ 𝟙_ C ↔ f = g := by simp
/-! The lemmas in the next section are true by coherence,
but we prove them directly as they are used in proving the coherence theorem. -/
section
@[reassoc (attr := simp)]
theorem pentagon_inv :
W ◁ (α_ X Y Z).inv ≫ (α_ W (X ⊗ Y) Z).inv ≫ (α_ W X Y).inv ▷ Z =
(α_ W X (Y ⊗ Z)).inv ≫ (α_ (W ⊗ X) Y Z).inv :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_inv_inv_hom_hom_inv :
(α_ W (X ⊗ Y) Z).inv ≫ (α_ W X Y).inv ▷ Z ≫ (α_ (W ⊗ X) Y Z).hom =
W ◁ (α_ X Y Z).hom ≫ (α_ W X (Y ⊗ Z)).inv := by
rw [← cancel_epi (W ◁ (α_ X Y Z).inv), ← cancel_mono (α_ (W ⊗ X) Y Z).inv]
simp
@[reassoc (attr := simp)]
theorem pentagon_inv_hom_hom_hom_inv :
(α_ (W ⊗ X) Y Z).inv ≫ (α_ W X Y).hom ▷ Z ≫ (α_ W (X ⊗ Y) Z).hom =
(α_ W X (Y ⊗ Z)).hom ≫ W ◁ (α_ X Y Z).inv :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_hom_inv_inv_inv_inv :
W ◁ (α_ X Y Z).hom ≫ (α_ W X (Y ⊗ Z)).inv ≫ (α_ (W ⊗ X) Y Z).inv =
(α_ W (X ⊗ Y) Z).inv ≫ (α_ W X Y).inv ▷ Z := by
simp [← cancel_epi (W ◁ (α_ X Y Z).inv)]
@[reassoc (attr := simp)]
theorem pentagon_hom_hom_inv_hom_hom :
(α_ (W ⊗ X) Y Z).hom ≫ (α_ W X (Y ⊗ Z)).hom ≫ W ◁ (α_ X Y Z).inv =
(α_ W X Y).hom ▷ Z ≫ (α_ W (X ⊗ Y) Z).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Monoidal/Category.lean | 530 | 534 | theorem pentagon_hom_inv_inv_inv_hom :
(α_ W X (Y ⊗ Z)).hom ≫ W ◁ (α_ X Y Z).inv ≫ (α_ W (X ⊗ Y) Z).inv =
(α_ (W ⊗ X) Y Z).inv ≫ (α_ W X Y).hom ▷ Z := by | rw [← cancel_epi (α_ W X (Y ⊗ Z)).inv, ← cancel_mono ((α_ W X Y).inv ▷ Z)]
simp |
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.List.Sublists
import Mathlib.Data.List.Zip
import Mathlib.Data.Multiset.Bind
import Mathlib.Data.Multiset.Range
/-!
# The powerset of a multiset
-/
namespace Multiset
open List
variable {α : Type*}
/-! ### powerset -/
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: Write a more efficient version
/-- A helper function for the powerset of a multiset. Given a list `l`, returns a list
of sublists of `l` as multisets. -/
def powersetAux (l : List α) : List (Multiset α) :=
(sublists l).map (↑)
theorem powersetAux_eq_map_coe {l : List α} : powersetAux l = (sublists l).map (↑) :=
rfl
@[simp]
theorem mem_powersetAux {l : List α} {s} : s ∈ powersetAux l ↔ s ≤ ↑l :=
Quotient.inductionOn s <| by simp [powersetAux_eq_map_coe, Subperm, and_comm]
/-- Helper function for the powerset of a multiset. Given a list `l`, returns a list
of sublists of `l` (using `sublists'`), as multisets. -/
def powersetAux' (l : List α) : List (Multiset α) :=
(sublists' l).map (↑)
theorem powersetAux_perm_powersetAux' {l : List α} : powersetAux l ~ powersetAux' l := by
rw [powersetAux_eq_map_coe]; exact (sublists_perm_sublists' _).map _
@[simp]
theorem powersetAux'_nil : powersetAux' (@nil α) = [0] :=
rfl
@[simp]
theorem powersetAux'_cons (a : α) (l : List α) :
powersetAux' (a :: l) = powersetAux' l ++ List.map (cons a) (powersetAux' l) := by
simp [powersetAux']
theorem powerset_aux'_perm {l₁ l₂ : List α} (p : l₁ ~ l₂) : powersetAux' l₁ ~ powersetAux' l₂ := by
induction p with
| nil => simp
| cons _ _ IH =>
simp only [powersetAux'_cons]
exact IH.append (IH.map _)
| swap a b =>
simp only [powersetAux'_cons, map_append, List.map_map, append_assoc]
apply Perm.append_left
rw [← append_assoc, ← append_assoc,
(by funext s; simp [cons_swap] : cons b ∘ cons a = cons a ∘ cons b)]
exact perm_append_comm.append_right _
| trans _ _ IH₁ IH₂ => exact IH₁.trans IH₂
theorem powersetAux_perm {l₁ l₂ : List α} (p : l₁ ~ l₂) : powersetAux l₁ ~ powersetAux l₂ :=
powersetAux_perm_powersetAux'.trans <|
(powerset_aux'_perm p).trans powersetAux_perm_powersetAux'.symm
--Porting note (https://github.com/leanprover-community/mathlib4/issues/11083): slightly slower implementation due to `map ofList`
/-- The power set of a multiset. -/
def powerset (s : Multiset α) : Multiset (Multiset α) :=
Quot.liftOn s
(fun l => (powersetAux l : Multiset (Multiset α)))
(fun _ _ h => Quot.sound (powersetAux_perm h))
theorem powerset_coe (l : List α) : @powerset α l = ((sublists l).map (↑) : List (Multiset α)) :=
congr_arg ((↑) : List (Multiset α) → Multiset (Multiset α)) powersetAux_eq_map_coe
@[simp]
theorem powerset_coe' (l : List α) : @powerset α l = ((sublists' l).map (↑) : List (Multiset α)) :=
Quot.sound powersetAux_perm_powersetAux'
@[simp]
theorem powerset_zero : @powerset α 0 = {0} :=
rfl
@[simp]
theorem powerset_cons (a : α) (s) : powerset (a ::ₘ s) = powerset s + map (cons a) (powerset s) :=
Quotient.inductionOn s fun l => by simp [Function.comp_def]
@[simp]
theorem mem_powerset {s t : Multiset α} : s ∈ powerset t ↔ s ≤ t :=
Quotient.inductionOn₂ s t <| by simp [Subperm, and_comm]
theorem map_single_le_powerset (s : Multiset α) : s.map singleton ≤ powerset s :=
Quotient.inductionOn s fun l => by
simp only [powerset_coe, quot_mk_to_coe, coe_le, map_coe]
show l.map (((↑) : List α → Multiset α) ∘ pure) <+~ (sublists l).map (↑)
rw [← List.map_map]
exact ((map_pure_sublist_sublists _).map _).subperm
@[simp]
theorem card_powerset (s : Multiset α) : card (powerset s) = 2 ^ card s :=
Quotient.inductionOn s <| by simp
| Mathlib/Data/Multiset/Powerset.lean | 108 | 109 | theorem revzip_powersetAux {l : List α} ⦃x⦄ (h : x ∈ revzip (powersetAux l)) : x.1 + x.2 = ↑l := by | rw [revzip, powersetAux_eq_map_coe, ← map_reverse, zip_map, ← revzip, List.mem_map] at h |
/-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker, Sébastien Gouëzel, Yury Kudryashov, Dylan MacKenzie, Patrick Massot
-/
import Mathlib.Algebra.BigOperators.Module
import Mathlib.Algebra.Order.Field.Power
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.Analysis.Asymptotics.Lemmas
import Mathlib.Analysis.Normed.Ring.InfiniteSum
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.List.TFAE
import Mathlib.Data.Nat.Choose.Bounds
import Mathlib.Order.Filter.AtTopBot.ModEq
import Mathlib.RingTheory.Polynomial.Pochhammer
import Mathlib.Tactic.NoncommRing
/-!
# A collection of specific limit computations
This file contains important specific limit computations in (semi-)normed groups/rings/spaces, as
well as such computations in `ℝ` when the natural proof passes through a fact about normed spaces.
-/
noncomputable section
open Set Function Filter Finset Metric Asymptotics Topology Nat NNReal ENNReal
variable {α : Type*}
/-! ### Powers -/
theorem isLittleO_pow_pow_of_lt_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ < r₂) :
(fun n : ℕ ↦ r₁ ^ n) =o[atTop] fun n ↦ r₂ ^ n :=
have H : 0 < r₂ := h₁.trans_lt h₂
(isLittleO_of_tendsto fun _ hn ↦ False.elim <| H.ne' <| pow_eq_zero hn) <|
(tendsto_pow_atTop_nhds_zero_of_lt_one
(div_nonneg h₁ (h₁.trans h₂.le)) ((div_lt_one H).2 h₂)).congr fun _ ↦ div_pow _ _ _
theorem isBigO_pow_pow_of_le_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ ≤ r₂) :
(fun n : ℕ ↦ r₁ ^ n) =O[atTop] fun n ↦ r₂ ^ n :=
h₂.eq_or_lt.elim (fun h ↦ h ▸ isBigO_refl _ _) fun h ↦ (isLittleO_pow_pow_of_lt_left h₁ h).isBigO
theorem isLittleO_pow_pow_of_abs_lt_left {r₁ r₂ : ℝ} (h : |r₁| < |r₂|) :
(fun n : ℕ ↦ r₁ ^ n) =o[atTop] fun n ↦ r₂ ^ n := by
refine (IsLittleO.of_norm_left ?_).of_norm_right
exact (isLittleO_pow_pow_of_lt_left (abs_nonneg r₁) h).congr (pow_abs r₁) (pow_abs r₂)
open List in
/-- Various statements equivalent to the fact that `f n` grows exponentially slower than `R ^ n`.
* 0: $f n = o(a ^ n)$ for some $-R < a < R$;
* 1: $f n = o(a ^ n)$ for some $0 < a < R$;
* 2: $f n = O(a ^ n)$ for some $-R < a < R$;
* 3: $f n = O(a ^ n)$ for some $0 < a < R$;
* 4: there exist `a < R` and `C` such that one of `C` and `R` is positive and $|f n| ≤ Ca^n$
for all `n`;
* 5: there exists `0 < a < R` and a positive `C` such that $|f n| ≤ Ca^n$ for all `n`;
* 6: there exists `a < R` such that $|f n| ≤ a ^ n$ for sufficiently large `n`;
* 7: there exists `0 < a < R` such that $|f n| ≤ a ^ n$ for sufficiently large `n`.
NB: For backwards compatibility, if you add more items to the list, please append them at the end of
the list. -/
theorem TFAE_exists_lt_isLittleO_pow (f : ℕ → ℝ) (R : ℝ) :
TFAE
[∃ a ∈ Ioo (-R) R, f =o[atTop] (a ^ ·), ∃ a ∈ Ioo 0 R, f =o[atTop] (a ^ ·),
∃ a ∈ Ioo (-R) R, f =O[atTop] (a ^ ·), ∃ a ∈ Ioo 0 R, f =O[atTop] (a ^ ·),
∃ a < R, ∃ C : ℝ, (0 < C ∨ 0 < R) ∧ ∀ n, |f n| ≤ C * a ^ n,
∃ a ∈ Ioo 0 R, ∃ C > 0, ∀ n, |f n| ≤ C * a ^ n, ∃ a < R, ∀ᶠ n in atTop, |f n| ≤ a ^ n,
∃ a ∈ Ioo 0 R, ∀ᶠ n in atTop, |f n| ≤ a ^ n] := by
have A : Ico 0 R ⊆ Ioo (-R) R :=
fun x hx ↦ ⟨(neg_lt_zero.2 (hx.1.trans_lt hx.2)).trans_le hx.1, hx.2⟩
have B : Ioo 0 R ⊆ Ioo (-R) R := Subset.trans Ioo_subset_Ico_self A
-- First we prove that 1-4 are equivalent using 2 → 3 → 4, 1 → 3, and 2 → 1
tfae_have 1 → 3 := fun ⟨a, ha, H⟩ ↦ ⟨a, ha, H.isBigO⟩
tfae_have 2 → 1 := fun ⟨a, ha, H⟩ ↦ ⟨a, B ha, H⟩
tfae_have 3 → 2
| ⟨a, ha, H⟩ => by
rcases exists_between (abs_lt.2 ha) with ⟨b, hab, hbR⟩
exact ⟨b, ⟨(abs_nonneg a).trans_lt hab, hbR⟩,
H.trans_isLittleO (isLittleO_pow_pow_of_abs_lt_left (hab.trans_le (le_abs_self b)))⟩
tfae_have 2 → 4 := fun ⟨a, ha, H⟩ ↦ ⟨a, ha, H.isBigO⟩
tfae_have 4 → 3 := fun ⟨a, ha, H⟩ ↦ ⟨a, B ha, H⟩
-- Add 5 and 6 using 4 → 6 → 5 → 3
tfae_have 4 → 6
| ⟨a, ha, H⟩ => by
rcases bound_of_isBigO_nat_atTop H with ⟨C, hC₀, hC⟩
refine ⟨a, ha, C, hC₀, fun n ↦ ?_⟩
simpa only [Real.norm_eq_abs, abs_pow, abs_of_nonneg ha.1.le] using hC (pow_ne_zero n ha.1.ne')
tfae_have 6 → 5 := fun ⟨a, ha, C, H₀, H⟩ ↦ ⟨a, ha.2, C, Or.inl H₀, H⟩
tfae_have 5 → 3
| ⟨a, ha, C, h₀, H⟩ => by
rcases sign_cases_of_C_mul_pow_nonneg fun n ↦ (abs_nonneg _).trans (H n) with (rfl | ⟨hC₀, ha₀⟩)
· obtain rfl : f = 0 := by
ext n
simpa using H n
simp only [lt_irrefl, false_or] at h₀
exact ⟨0, ⟨neg_lt_zero.2 h₀, h₀⟩, isBigO_zero _ _⟩
exact ⟨a, A ⟨ha₀, ha⟩,
isBigO_of_le' _ fun n ↦ (H n).trans <| mul_le_mul_of_nonneg_left (le_abs_self _) hC₀.le⟩
-- Add 7 and 8 using 2 → 8 → 7 → 3
tfae_have 2 → 8
| ⟨a, ha, H⟩ => by
refine ⟨a, ha, (H.def zero_lt_one).mono fun n hn ↦ ?_⟩
rwa [Real.norm_eq_abs, Real.norm_eq_abs, one_mul, abs_pow, abs_of_pos ha.1] at hn
tfae_have 8 → 7 := fun ⟨a, ha, H⟩ ↦ ⟨a, ha.2, H⟩
tfae_have 7 → 3
| ⟨a, ha, H⟩ => by
refine ⟨a, A ⟨?_, ha⟩, .of_norm_eventuallyLE H⟩
exact nonneg_of_eventually_pow_nonneg (H.mono fun n ↦ (abs_nonneg _).trans)
tfae_finish
/-- For any natural `k` and a real `r > 1` we have `n ^ k = o(r ^ n)` as `n → ∞`. -/
theorem isLittleO_pow_const_const_pow_of_one_lt {R : Type*} [NormedRing R] (k : ℕ) {r : ℝ}
(hr : 1 < r) : (fun n ↦ (n : R) ^ k : ℕ → R) =o[atTop] fun n ↦ r ^ n := by
have : Tendsto (fun x : ℝ ↦ x ^ k) (𝓝[>] 1) (𝓝 1) :=
((continuous_id.pow k).tendsto' (1 : ℝ) 1 (one_pow _)).mono_left inf_le_left
obtain ⟨r' : ℝ, hr' : r' ^ k < r, h1 : 1 < r'⟩ :=
((this.eventually (gt_mem_nhds hr)).and self_mem_nhdsWithin).exists
have h0 : 0 ≤ r' := zero_le_one.trans h1.le
suffices (fun n ↦ (n : R) ^ k : ℕ → R) =O[atTop] fun n : ℕ ↦ (r' ^ k) ^ n from
this.trans_isLittleO (isLittleO_pow_pow_of_lt_left (pow_nonneg h0 _) hr')
conv in (r' ^ _) ^ _ => rw [← pow_mul, mul_comm, pow_mul]
suffices ∀ n : ℕ, ‖(n : R)‖ ≤ (r' - 1)⁻¹ * ‖(1 : R)‖ * ‖r' ^ n‖ from
(isBigO_of_le' _ this).pow _
intro n
rw [mul_right_comm]
refine n.norm_cast_le.trans (mul_le_mul_of_nonneg_right ?_ (norm_nonneg _))
simpa [_root_.div_eq_inv_mul, Real.norm_eq_abs, abs_of_nonneg h0] using n.cast_le_pow_div_sub h1
/-- For a real `r > 1` we have `n = o(r ^ n)` as `n → ∞`. -/
theorem isLittleO_coe_const_pow_of_one_lt {R : Type*} [NormedRing R] {r : ℝ} (hr : 1 < r) :
((↑) : ℕ → R) =o[atTop] fun n ↦ r ^ n := by
simpa only [pow_one] using @isLittleO_pow_const_const_pow_of_one_lt R _ 1 _ hr
/-- If `‖r₁‖ < r₂`, then for any natural `k` we have `n ^ k r₁ ^ n = o (r₂ ^ n)` as `n → ∞`. -/
theorem isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt {R : Type*} [NormedRing R] (k : ℕ)
{r₁ : R} {r₂ : ℝ} (h : ‖r₁‖ < r₂) :
(fun n ↦ (n : R) ^ k * r₁ ^ n : ℕ → R) =o[atTop] fun n ↦ r₂ ^ n := by
by_cases h0 : r₁ = 0
· refine (isLittleO_zero _ _).congr' (mem_atTop_sets.2 <| ⟨1, fun n hn ↦ ?_⟩) EventuallyEq.rfl
simp [zero_pow (one_le_iff_ne_zero.1 hn), h0]
rw [← Ne, ← norm_pos_iff] at h0
have A : (fun n ↦ (n : R) ^ k : ℕ → R) =o[atTop] fun n ↦ (r₂ / ‖r₁‖) ^ n :=
isLittleO_pow_const_const_pow_of_one_lt k ((one_lt_div h0).2 h)
suffices (fun n ↦ r₁ ^ n) =O[atTop] fun n ↦ ‖r₁‖ ^ n by
simpa [div_mul_cancel₀ _ (pow_pos h0 _).ne', div_pow] using A.mul_isBigO this
exact .of_norm_eventuallyLE <| eventually_norm_pow_le r₁
theorem tendsto_pow_const_div_const_pow_of_one_lt (k : ℕ) {r : ℝ} (hr : 1 < r) :
Tendsto (fun n ↦ (n : ℝ) ^ k / r ^ n : ℕ → ℝ) atTop (𝓝 0) :=
(isLittleO_pow_const_const_pow_of_one_lt k hr).tendsto_div_nhds_zero
/-- If `|r| < 1`, then `n ^ k r ^ n` tends to zero for any natural `k`. -/
theorem tendsto_pow_const_mul_const_pow_of_abs_lt_one (k : ℕ) {r : ℝ} (hr : |r| < 1) :
Tendsto (fun n ↦ (n : ℝ) ^ k * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by
by_cases h0 : r = 0
· exact tendsto_const_nhds.congr'
(mem_atTop_sets.2 ⟨1, fun n hn ↦ by simp [zero_lt_one.trans_le hn |>.ne', h0]⟩)
have hr' : 1 < |r|⁻¹ := (one_lt_inv₀ (abs_pos.2 h0)).2 hr
rw [tendsto_zero_iff_norm_tendsto_zero]
simpa [div_eq_mul_inv] using tendsto_pow_const_div_const_pow_of_one_lt k hr'
/-- For `k ≠ 0` and a constant `r` the function `r / n ^ k` tends to zero. -/
lemma tendsto_const_div_pow (r : ℝ) (k : ℕ) (hk : k ≠ 0) :
Tendsto (fun n : ℕ => r / n ^ k) atTop (𝓝 0) := by
simpa using Filter.Tendsto.const_div_atTop (tendsto_natCast_atTop_atTop (R := ℝ).comp
(tendsto_pow_atTop hk) ) r
/-- If `0 ≤ r < 1`, then `n ^ k r ^ n` tends to zero for any natural `k`.
This is a specialized version of `tendsto_pow_const_mul_const_pow_of_abs_lt_one`, singled out
for ease of application. -/
theorem tendsto_pow_const_mul_const_pow_of_lt_one (k : ℕ) {r : ℝ} (hr : 0 ≤ r) (h'r : r < 1) :
Tendsto (fun n ↦ (n : ℝ) ^ k * r ^ n : ℕ → ℝ) atTop (𝓝 0) :=
tendsto_pow_const_mul_const_pow_of_abs_lt_one k (abs_lt.2 ⟨neg_one_lt_zero.trans_le hr, h'r⟩)
/-- If `|r| < 1`, then `n * r ^ n` tends to zero. -/
theorem tendsto_self_mul_const_pow_of_abs_lt_one {r : ℝ} (hr : |r| < 1) :
Tendsto (fun n ↦ n * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by
simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_abs_lt_one 1 hr
/-- If `0 ≤ r < 1`, then `n * r ^ n` tends to zero. This is a specialized version of
`tendsto_self_mul_const_pow_of_abs_lt_one`, singled out for ease of application. -/
theorem tendsto_self_mul_const_pow_of_lt_one {r : ℝ} (hr : 0 ≤ r) (h'r : r < 1) :
Tendsto (fun n ↦ n * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by
simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_lt_one 1 hr h'r
/-- In a normed ring, the powers of an element x with `‖x‖ < 1` tend to zero. -/
theorem tendsto_pow_atTop_nhds_zero_of_norm_lt_one {R : Type*} [SeminormedRing R] {x : R}
(h : ‖x‖ < 1) :
Tendsto (fun n : ℕ ↦ x ^ n) atTop (𝓝 0) := by
apply squeeze_zero_norm' (eventually_norm_pow_le x)
exact tendsto_pow_atTop_nhds_zero_of_lt_one (norm_nonneg _) h
theorem tendsto_pow_atTop_nhds_zero_of_abs_lt_one {r : ℝ} (h : |r| < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) :=
tendsto_pow_atTop_nhds_zero_of_norm_lt_one h
lemma tendsto_pow_atTop_nhds_zero_iff_norm_lt_one {R : Type*} [SeminormedRing R] [NormMulClass R]
{x : R} : Tendsto (fun n : ℕ ↦ x ^ n) atTop (𝓝 0) ↔ ‖x‖ < 1 := by
-- this proof is slightly fiddly since `‖x ^ n‖ = ‖x‖ ^ n` might not hold for `n = 0`
refine ⟨?_, tendsto_pow_atTop_nhds_zero_of_norm_lt_one⟩
rw [← abs_of_nonneg (norm_nonneg _), ← tendsto_pow_atTop_nhds_zero_iff,
tendsto_zero_iff_norm_tendsto_zero]
apply Tendsto.congr'
filter_upwards [eventually_ge_atTop 1] with n hn
induction n, hn using Nat.le_induction with
| base => simp
| succ n hn IH => simp [norm_pow, pow_succ, IH]
/-! ### Geometric series -/
/-- A normed ring has summable geometric series if, for all `ξ` of norm `< 1`, the geometric series
`∑ ξ ^ n` converges. This holds both in complete normed rings and in normed fields, providing a
convenient abstraction of these two classes to avoid repeating the same proofs. -/
class HasSummableGeomSeries (K : Type*) [NormedRing K] : Prop where
summable_geometric_of_norm_lt_one : ∀ (ξ : K), ‖ξ‖ < 1 → Summable (fun n ↦ ξ ^ n)
lemma summable_geometric_of_norm_lt_one {K : Type*} [NormedRing K] [HasSummableGeomSeries K]
{x : K} (h : ‖x‖ < 1) : Summable (fun n ↦ x ^ n) :=
HasSummableGeomSeries.summable_geometric_of_norm_lt_one x h
instance {R : Type*} [NormedRing R] [CompleteSpace R] : HasSummableGeomSeries R := by
constructor
intro x hx
have h1 : Summable fun n : ℕ ↦ ‖x‖ ^ n := summable_geometric_of_lt_one (norm_nonneg _) hx
exact h1.of_norm_bounded_eventually_nat _ (eventually_norm_pow_le x)
section HasSummableGeometricSeries
variable {R : Type*} [NormedRing R]
open NormedSpace
/-- Bound for the sum of a geometric series in a normed ring. This formula does not assume that the
normed ring satisfies the axiom `‖1‖ = 1`. -/
theorem tsum_geometric_le_of_norm_lt_one (x : R) (h : ‖x‖ < 1) :
‖∑' n : ℕ, x ^ n‖ ≤ ‖(1 : R)‖ - 1 + (1 - ‖x‖)⁻¹ := by
by_cases hx : Summable (fun n ↦ x ^ n)
· rw [hx.tsum_eq_zero_add]
simp only [_root_.pow_zero]
refine le_trans (norm_add_le _ _) ?_
have : ‖∑' b : ℕ, (fun n ↦ x ^ (n + 1)) b‖ ≤ (1 - ‖x‖)⁻¹ - 1 := by
refine tsum_of_norm_bounded ?_ fun b ↦ norm_pow_le' _ (Nat.succ_pos b)
convert (hasSum_nat_add_iff' 1).mpr (hasSum_geometric_of_lt_one (norm_nonneg x) h)
simp
linarith
· simp [tsum_eq_zero_of_not_summable hx]
nontriviality R
have : 1 ≤ ‖(1 : R)‖ := one_le_norm_one R
have : 0 ≤ (1 - ‖x‖) ⁻¹ := inv_nonneg.2 (by linarith)
linarith
variable [HasSummableGeomSeries R]
| Mathlib/Analysis/SpecificLimits/Normed.lean | 257 | 259 | theorem geom_series_mul_neg (x : R) (h : ‖x‖ < 1) : (∑' i : ℕ, x ^ i) * (1 - x) = 1 := by | have := (summable_geometric_of_norm_lt_one h).hasSum.mul_right (1 - x)
refine tendsto_nhds_unique this.tendsto_sum_nat ?_ |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.Algebra.Polynomial.Splits
import Mathlib.RingTheory.Adjoin.Basic
import Mathlib.RingTheory.AdjoinRoot
/-!
# Adjoining elements to a field
Some lemmas on the ring generated by adjoining an element to a field.
## Main statements
* `Polynomial.lift_of_splits`: If `K` and `L` are field extensions of `F`
and we have `s : Finset K` such that the minimal polynomial of each `x ∈ s` splits in `L`
then `Algebra.adjoin F s` embeds in `L`.
-/
noncomputable section
open Polynomial
section Embeddings
variable (F : Type*) [Field F]
open AdjoinRoot in
/-- If `p` is the minimal polynomial of `a` over `F` then `F[a] ≃ₐ[F] F[x]/(p)` -/
def AlgEquiv.adjoinSingletonEquivAdjoinRootMinpoly {R : Type*} [CommRing R] [Algebra F R] (x : R) :
Algebra.adjoin F ({x} : Set R) ≃ₐ[F] AdjoinRoot (minpoly F x) :=
AlgEquiv.symm <| AlgEquiv.ofBijective (Minpoly.toAdjoin F x) <| by
refine ⟨(injective_iff_map_eq_zero _).2 fun P₁ hP₁ ↦ ?_, Minpoly.toAdjoin.surjective F x⟩
obtain ⟨P, rfl⟩ := mk_surjective P₁
refine AdjoinRoot.mk_eq_zero.mpr (minpoly.dvd F x ?_)
rwa [Minpoly.toAdjoin_apply', liftHom_mk, ← Subalgebra.coe_eq_zero, aeval_subalgebra_coe] at hP₁
/-- Produce an algebra homomorphism `Adjoin R {x} →ₐ[R] T` sending `x` to
a root of `x`'s minimal polynomial in `T`. -/
noncomputable def Algebra.adjoin.liftSingleton {S T : Type*}
[CommRing S] [CommRing T] [Algebra F S] [Algebra F T]
(x : S) (y : T) (h : aeval y (minpoly F x) = 0) :
Algebra.adjoin F {x} →ₐ[F] T :=
(AdjoinRoot.liftHom _ y h).comp (AlgEquiv.adjoinSingletonEquivAdjoinRootMinpoly F x).toAlgHom
open Finset
/-- If `K` and `L` are field extensions of `F` and we have `s : Finset K` such that
the minimal polynomial of each `x ∈ s` splits in `L` then `Algebra.adjoin F s` embeds in `L`. -/
theorem Polynomial.lift_of_splits {F K L : Type*} [Field F] [Field K] [Field L] [Algebra F K]
[Algebra F L] (s : Finset K) : (∀ x ∈ s, IsIntegral F x ∧
Splits (algebraMap F L) (minpoly F x)) → Nonempty (Algebra.adjoin F (s : Set K) →ₐ[F] L) := by
classical
refine Finset.induction_on s (fun _ ↦ ?_) fun a s _ ih H ↦ ?_
· rw [coe_empty, Algebra.adjoin_empty]
exact ⟨(Algebra.ofId F L).comp (Algebra.botEquiv F K)⟩
rw [forall_mem_insert] at H
rcases H with ⟨⟨H1, H2⟩, H3⟩
obtain ⟨f⟩ := ih H3
choose H3 _ using H3
rw [coe_insert, Set.insert_eq, Set.union_comm, Algebra.adjoin_union_eq_adjoin_adjoin]
set Ks := Algebra.adjoin F (s : Set K)
haveI : FiniteDimensional F Ks := ((Submodule.fg_iff_finiteDimensional _).1
(fg_adjoin_of_finite s.finite_toSet H3)).of_subalgebra_toSubmodule
letI := fieldOfFiniteDimensional F Ks
letI := (f : Ks →+* L).toAlgebra
have H5 : IsIntegral Ks a := H1.tower_top
have H6 : (minpoly Ks a).Splits (algebraMap Ks L) := by
refine splits_of_splits_of_dvd _ ((minpoly.monic H1).map (algebraMap F Ks)).ne_zero
((splits_map_iff _ _).2 ?_) (minpoly.dvd _ _ ?_)
· rw [← IsScalarTower.algebraMap_eq]
exact H2
· rw [Polynomial.aeval_map_algebraMap, minpoly.aeval]
obtain ⟨y, hy⟩ := Polynomial.exists_root_of_splits _ H6 (minpoly.degree_pos H5).ne'
exact ⟨Subalgebra.ofRestrictScalars F _ <| Algebra.adjoin.liftSingleton Ks a y hy⟩
end Embeddings
variable {R K L M : Type*} [CommRing R] [Field K] [Field L] [CommRing M] [Algebra R K]
[Algebra R M] {x : L}
section
variable [Algebra R L]
theorem IsIntegral.mem_range_algHom_of_minpoly_splits
(int : IsIntegral R x) (h : Splits (algebraMap R K) (minpoly R x)) (f : K →ₐ[R] L) :
x ∈ f.range :=
show x ∈ Set.range f from Set.image_subset_range _ ((minpoly R x).rootSet K) <| by
rw [image_rootSet h f, mem_rootSet']
exact ⟨((minpoly.monic int).map _).ne_zero, minpoly.aeval R x⟩
theorem IsIntegral.mem_range_algebraMap_of_minpoly_splits [Algebra K L] [IsScalarTower R K L]
(int : IsIntegral R x) (h : Splits (algebraMap R K) (minpoly R x)) :
x ∈ (algebraMap K L).range :=
int.mem_range_algHom_of_minpoly_splits h (IsScalarTower.toAlgHom R K L)
theorem minpoly_neg_splits [Algebra K L] {x : L} (g : (minpoly K x).Splits (algebraMap K L)) :
(minpoly K (-x)).Splits (algebraMap K L) := by
rw [minpoly.neg]
apply splits_mul _ _ g.comp_neg_X
simpa only [map_pow, map_neg, map_one] using
splits_C (algebraMap K L) ((-1) ^ (minpoly K x).natDegree)
theorem minpoly_add_algebraMap_splits [Algebra K L] {x : L} (r : K)
(g : (minpoly K x).Splits (algebraMap K L)) :
(minpoly K (x + algebraMap K L r)).Splits (algebraMap K L) := by
simpa [minpoly.add_algebraMap] using g.comp_X_sub_C r
| Mathlib/RingTheory/Adjoin/Field.lean | 112 | 121 | theorem minpoly_sub_algebraMap_splits [Algebra K L] {x : L} (r : K)
(g : (minpoly K x).Splits (algebraMap K L)) :
(minpoly K (x - algebraMap K L r)).Splits (algebraMap K L) := by | simpa only [sub_eq_add_neg, map_neg] using minpoly_add_algebraMap_splits (-r) g
theorem minpoly_algebraMap_add_splits [Algebra K L] {x : L} (r : K)
(g : (minpoly K x).Splits (algebraMap K L)) :
(minpoly K (algebraMap K L r + x)).Splits (algebraMap K L) := by
simpa only [add_comm] using minpoly_add_algebraMap_splits r g |
/-
Copyright (c) 2018 Andreas Swerdlow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andreas Swerdlow, Kexing Ying
-/
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.LinearAlgebra.BilinearForm.Properties
/-!
# Bilinear form
This file defines orthogonal bilinear forms.
## Notations
Given any term `B` of type `BilinForm`, due to a coercion, can use
the notation `B x y` to refer to the function field, ie. `B x y = B.bilin x y`.
In this file we use the following type variables:
- `M`, `M'`, ... are modules over the commutative semiring `R`,
- `M₁`, `M₁'`, ... are modules over the commutative ring `R₁`,
- `V`, ... is a vector space over the field `K`.
## References
* <https://en.wikipedia.org/wiki/Bilinear_form>
## Tags
Bilinear form,
-/
open LinearMap (BilinForm)
universe u v w
variable {R : Type*} {M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
variable {R₁ : Type*} {M₁ : Type*} [CommRing R₁] [AddCommGroup M₁] [Module R₁ M₁]
variable {V : Type*} {K : Type*} [Field K] [AddCommGroup V] [Module K V]
variable {B : BilinForm R M} {B₁ : BilinForm R₁ M₁}
namespace LinearMap
namespace BilinForm
/-- The proposition that two elements of a bilinear form space are orthogonal. For orthogonality
of an indexed set of elements, use `BilinForm.iIsOrtho`. -/
def IsOrtho (B : BilinForm R M) (x y : M) : Prop :=
B x y = 0
theorem isOrtho_def {B : BilinForm R M} {x y : M} : B.IsOrtho x y ↔ B x y = 0 :=
Iff.rfl
theorem isOrtho_zero_left (x : M) : IsOrtho B (0 : M) x := LinearMap.isOrtho_zero_left B x
theorem isOrtho_zero_right (x : M) : IsOrtho B x (0 : M) :=
zero_right x
theorem ne_zero_of_not_isOrtho_self {B : BilinForm K V} (x : V) (hx₁ : ¬B.IsOrtho x x) : x ≠ 0 :=
fun hx₂ => hx₁ (hx₂.symm ▸ isOrtho_zero_left _)
theorem IsRefl.ortho_comm (H : B.IsRefl) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x :=
⟨eq_zero H, eq_zero H⟩
theorem IsAlt.ortho_comm (H : B₁.IsAlt) {x y : M₁} : IsOrtho B₁ x y ↔ IsOrtho B₁ y x :=
LinearMap.IsAlt.ortho_comm H
theorem IsSymm.ortho_comm (H : B.IsSymm) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x :=
LinearMap.IsSymm.ortho_comm H
/-- A set of vectors `v` is orthogonal with respect to some bilinear form `B` if and only
if for all `i ≠ j`, `B (v i) (v j) = 0`. For orthogonality between two elements, use
`BilinForm.IsOrtho` -/
def iIsOrtho {n : Type w} (B : BilinForm R M) (v : n → M) : Prop :=
B.IsOrthoᵢ v
theorem iIsOrtho_def {n : Type w} {B : BilinForm R M} {v : n → M} :
B.iIsOrtho v ↔ ∀ i j : n, i ≠ j → B (v i) (v j) = 0 :=
Iff.rfl
section
variable {R₄ M₄ : Type*} [CommRing R₄] [IsDomain R₄]
variable [AddCommGroup M₄] [Module R₄ M₄] {G : BilinForm R₄ M₄}
@[simp]
theorem isOrtho_smul_left {x y : M₄} {a : R₄} (ha : a ≠ 0) :
IsOrtho G (a • x) y ↔ IsOrtho G x y := by
dsimp only [IsOrtho]
rw [map_smul]
simp only [LinearMap.smul_apply, smul_eq_mul, mul_eq_zero, or_iff_right_iff_imp]
exact fun a ↦ (ha a).elim
@[simp]
theorem isOrtho_smul_right {x y : M₄} {a : R₄} (ha : a ≠ 0) :
IsOrtho G x (a • y) ↔ IsOrtho G x y := by
dsimp only [IsOrtho]
rw [map_smul]
simp only [smul_eq_mul, mul_eq_zero, or_iff_right_iff_imp]
exact fun a ↦ (ha a).elim
/-- A set of orthogonal vectors `v` with respect to some bilinear form `B` is linearly independent
if for all `i`, `B (v i) (v i) ≠ 0`. -/
theorem linearIndependent_of_iIsOrtho {n : Type w} {B : BilinForm K V} {v : n → V}
(hv₁ : B.iIsOrtho v) (hv₂ : ∀ i, ¬B.IsOrtho (v i) (v i)) : LinearIndependent K v := by
classical
rw [linearIndependent_iff']
intro s w hs i hi
have : B (s.sum fun i : n => w i • v i) (v i) = 0 := by rw [hs, zero_left]
have hsum : (s.sum fun j : n => w j * B (v j) (v i)) = w i * B (v i) (v i) := by
apply Finset.sum_eq_single_of_mem i hi
intro j _ hij
rw [iIsOrtho_def.1 hv₁ _ _ hij, mul_zero]
simp_rw [sum_left, smul_left, hsum] at this
exact eq_zero_of_ne_zero_of_mul_right_eq_zero (hv₂ i) this
end
section Orthogonal
/-- The orthogonal complement of a submodule `N` with respect to some bilinear form is the set of
elements `x` which are orthogonal to all elements of `N`; i.e., for all `y` in `N`, `B x y = 0`.
Note that for general (neither symmetric nor antisymmetric) bilinear forms this definition has a
chirality; in addition to this "left" orthogonal complement one could define a "right" orthogonal
complement for which, for all `y` in `N`, `B y x = 0`. This variant definition is not currently
provided in mathlib. -/
def orthogonal (B : BilinForm R M) (N : Submodule R M) : Submodule R M where
carrier := { m | ∀ n ∈ N, IsOrtho B n m }
zero_mem' x _ := isOrtho_zero_right x
add_mem' {x y} hx hy n hn := by
rw [IsOrtho, add_right, show B n x = 0 from hx n hn, show B n y = 0 from hy n hn, zero_add]
smul_mem' c x hx n hn := by
rw [IsOrtho, smul_right, show B n x = 0 from hx n hn, mul_zero]
variable {N L : Submodule R M}
@[simp]
theorem mem_orthogonal_iff {N : Submodule R M} {m : M} :
m ∈ B.orthogonal N ↔ ∀ n ∈ N, IsOrtho B n m :=
Iff.rfl
@[simp] lemma orthogonal_bot : B.orthogonal ⊥ = ⊤ := by ext; simp [IsOrtho]
theorem orthogonal_le (h : N ≤ L) : B.orthogonal L ≤ B.orthogonal N := fun _ hn l hl => hn l (h hl)
theorem le_orthogonal_orthogonal (b : B.IsRefl) : N ≤ B.orthogonal (B.orthogonal N) :=
fun n hn _ hm => b _ _ (hm n hn)
lemma orthogonal_top_eq_ker (hB : B.IsRefl) :
B.orthogonal ⊤ = LinearMap.ker B := by
ext; simp [LinearMap.BilinForm.IsOrtho, LinearMap.ext_iff, hB.eq_iff]
lemma orthogonal_top_eq_bot (hB : B.Nondegenerate) (hB₀ : B.IsRefl) :
B.orthogonal ⊤ = ⊥ :=
(Submodule.eq_bot_iff _).mpr fun _ hx ↦ hB _ fun y ↦ hB₀ _ _ <| hx y Submodule.mem_top
-- ↓ This lemma only applies in fields as we require `a * b = 0 → a = 0 ∨ b = 0`
theorem span_singleton_inf_orthogonal_eq_bot {B : BilinForm K V} {x : V} (hx : ¬B.IsOrtho x x) :
(K ∙ x) ⊓ B.orthogonal (K ∙ x) = ⊥ := by
rw [← Finset.coe_singleton]
refine eq_bot_iff.2 fun y h => ?_
obtain ⟨μ, -, rfl⟩ := Submodule.mem_span_finset.1 h.1
have := h.2 x ?_
· rw [Finset.sum_singleton] at this ⊢
suffices hμzero : μ x = 0 by rw [hμzero, zero_smul, Submodule.mem_bot]
change B x (μ x • x) = 0 at this
rw [smul_right] at this
exact eq_zero_of_ne_zero_of_mul_right_eq_zero hx this
· rw [Submodule.mem_span]
exact fun _ hp => hp <| Finset.mem_singleton_self _
-- ↓ This lemma only applies in fields since we use the `mul_eq_zero`
theorem orthogonal_span_singleton_eq_toLin_ker {B : BilinForm K V} (x : V) :
B.orthogonal (K ∙ x) = LinearMap.ker (LinearMap.BilinForm.toLinHomAux₁ B x) := by
ext y
simp_rw [mem_orthogonal_iff, LinearMap.mem_ker, Submodule.mem_span_singleton]
constructor
· exact fun h => h x ⟨1, one_smul _ _⟩
· rintro h _ ⟨z, rfl⟩
rw [IsOrtho, smul_left, mul_eq_zero]
exact Or.intro_right _ h
theorem span_singleton_sup_orthogonal_eq_top {B : BilinForm K V} {x : V} (hx : ¬B.IsOrtho x x) :
(K ∙ x) ⊔ B.orthogonal (K ∙ x) = ⊤ := by
rw [orthogonal_span_singleton_eq_toLin_ker]
exact LinearMap.span_singleton_sup_ker_eq_top _ hx
/-- Given a bilinear form `B` and some `x` such that `B x x ≠ 0`, the span of the singleton of `x`
is complement to its orthogonal complement. -/
theorem isCompl_span_singleton_orthogonal {B : BilinForm K V} {x : V} (hx : ¬B.IsOrtho x x) :
IsCompl (K ∙ x) (B.orthogonal <| K ∙ x) :=
{ disjoint := disjoint_iff.2 <| span_singleton_inf_orthogonal_eq_bot hx
codisjoint := codisjoint_iff.2 <| span_singleton_sup_orthogonal_eq_top hx }
end Orthogonal
variable {M₂' : Type*}
variable [AddCommMonoid M₂'] [Module R M₂']
/-- The restriction of a reflexive bilinear form `B` onto a submodule `W` is
nondegenerate if `Disjoint W (B.orthogonal W)`. -/
theorem nondegenerate_restrict_of_disjoint_orthogonal (B : BilinForm R₁ M₁) (b : B.IsRefl)
{W : Submodule R₁ M₁} (hW : Disjoint W (B.orthogonal W)) : (B.restrict W).Nondegenerate := by
rintro ⟨x, hx⟩ b₁
rw [Submodule.mk_eq_zero, ← Submodule.mem_bot R₁]
refine hW.le_bot ⟨hx, fun y hy => ?_⟩
specialize b₁ ⟨y, hy⟩
simp only [restrict_apply, domRestrict_apply] at b₁
exact isOrtho_def.mpr (b x y b₁)
/-- An orthogonal basis with respect to a nondegenerate bilinear form has no self-orthogonal
elements. -/
theorem iIsOrtho.not_isOrtho_basis_self_of_nondegenerate {n : Type w} [Nontrivial R]
{B : BilinForm R M} {v : Basis n R M} (h : B.iIsOrtho v) (hB : B.Nondegenerate) (i : n) :
¬B.IsOrtho (v i) (v i) := by
intro ho
refine v.ne_zero i (hB (v i) fun m => ?_)
obtain ⟨vi, rfl⟩ := v.repr.symm.surjective m
rw [Basis.repr_symm_apply, Finsupp.linearCombination_apply, Finsupp.sum, sum_right]
apply Finset.sum_eq_zero
rintro j -
rw [smul_right]
convert mul_zero (vi j) using 2
obtain rfl | hij := eq_or_ne i j
· exact ho
· exact h hij
/-- Given an orthogonal basis with respect to a bilinear form, the bilinear form is nondegenerate
iff the basis has no elements which are self-orthogonal. -/
theorem iIsOrtho.nondegenerate_iff_not_isOrtho_basis_self {n : Type w} [Nontrivial R]
[NoZeroDivisors R] (B : BilinForm R M) (v : Basis n R M) (hO : B.iIsOrtho v) :
B.Nondegenerate ↔ ∀ i, ¬B.IsOrtho (v i) (v i) := by
refine ⟨hO.not_isOrtho_basis_self_of_nondegenerate, fun ho m hB => ?_⟩
obtain ⟨vi, rfl⟩ := v.repr.symm.surjective m
rw [LinearEquiv.map_eq_zero_iff]
ext i
rw [Finsupp.zero_apply]
specialize hB (v i)
simp_rw [Basis.repr_symm_apply, Finsupp.linearCombination_apply, Finsupp.sum, sum_left,
smul_left] at hB
rw [Finset.sum_eq_single i] at hB
· exact eq_zero_of_ne_zero_of_mul_right_eq_zero (ho i) hB
· intro j _ hij
convert mul_zero (vi j) using 2
exact hO hij
· intro hi
convert zero_mul (M₀ := R) _ using 2
exact Finsupp.not_mem_support_iff.mp hi
section
theorem toLin_restrict_ker_eq_inf_orthogonal (B : BilinForm K V) (W : Subspace K V) (b : B.IsRefl) :
(LinearMap.ker <| B.domRestrict W).map W.subtype = (W ⊓ B.orthogonal ⊤ : Subspace K V) := by
ext x; constructor <;> intro hx
· rcases hx with ⟨⟨x, hx⟩, hker, rfl⟩
erw [LinearMap.mem_ker] at hker
constructor
· simp [hx]
· intro y _
rw [IsOrtho, b]
change (B.domRestrict W) ⟨x, hx⟩ y = 0
rw [hker]
rfl
· simp_rw [Submodule.mem_map, LinearMap.mem_ker]
refine ⟨⟨x, hx.1⟩, ?_, rfl⟩
ext y
change B x y = 0
rw [b]
exact hx.2 _ Submodule.mem_top
theorem toLin_restrict_range_dualCoannihilator_eq_orthogonal (B : BilinForm K V)
(W : Subspace K V) :
(LinearMap.range (B.domRestrict W)).dualCoannihilator = B.orthogonal W := by
ext x; constructor <;> rw [mem_orthogonal_iff] <;> intro hx
· intro y hy
rw [Submodule.mem_dualCoannihilator] at hx
exact hx (B.domRestrict W ⟨y, hy⟩) ⟨⟨y, hy⟩, rfl⟩
· rw [Submodule.mem_dualCoannihilator]
rintro _ ⟨⟨w, hw⟩, rfl⟩
exact hx w hw
lemma ker_restrict_eq_of_codisjoint {p q : Submodule R M} (hpq : Codisjoint p q)
{B : LinearMap.BilinForm R M} (hB : ∀ x ∈ p, ∀ y ∈ q, B x y = 0) :
LinearMap.ker (B.restrict p) = (LinearMap.ker B).comap p.subtype := by
ext ⟨z, hz⟩
simp only [LinearMap.mem_ker, Submodule.mem_comap, Submodule.coe_subtype]
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· ext w
obtain ⟨x, hx, y, hy, rfl⟩ := Submodule.exists_add_eq_of_codisjoint hpq w
simpa [hB z hz y hy] using LinearMap.congr_fun h ⟨x, hx⟩
· ext ⟨x, hx⟩
simpa using LinearMap.congr_fun h x
lemma inf_orthogonal_self_le_ker_restrict {W : Submodule R M} (b₁ : B.IsRefl) :
W ⊓ B.orthogonal W ≤ (LinearMap.ker <| B.restrict W).map W.subtype := by
rintro v ⟨hv : v ∈ W, hv' : v ∈ B.orthogonal W⟩
simp only [Submodule.mem_map, mem_ker, restrict_apply, Submodule.coe_subtype, Subtype.exists,
exists_and_left, exists_prop, exists_eq_right_right]
refine ⟨?_, hv⟩
ext ⟨w, hw⟩
exact b₁ w v <| hv' w hw
variable [FiniteDimensional K V]
open Module Submodule
variable {B : BilinForm K V}
theorem finrank_add_finrank_orthogonal (b₁ : B.IsRefl) (W : Submodule K V) :
finrank K W + finrank K (B.orthogonal W) =
finrank K V + finrank K (W ⊓ B.orthogonal ⊤ : Subspace K V) := by
rw [← toLin_restrict_ker_eq_inf_orthogonal _ _ b₁, ←
toLin_restrict_range_dualCoannihilator_eq_orthogonal _ _, finrank_map_subtype_eq]
conv_rhs =>
rw [← @Subspace.finrank_add_finrank_dualCoannihilator_eq K V _ _ _ _
(LinearMap.range (B.domRestrict W)),
add_comm, ← add_assoc, add_comm (finrank K (LinearMap.ker (B.domRestrict W))),
LinearMap.finrank_range_add_finrank_ker]
lemma finrank_orthogonal (hB : B.Nondegenerate) (hB₀ : B.IsRefl) (W : Submodule K V) :
finrank K (B.orthogonal W) = finrank K V - finrank K W := by
have := finrank_add_finrank_orthogonal hB₀ (W := W)
rw [B.orthogonal_top_eq_bot hB hB₀, inf_bot_eq, finrank_bot, add_zero] at this
omega
lemma orthogonal_orthogonal (hB : B.Nondegenerate) (hB₀ : B.IsRefl) (W : Submodule K V) :
B.orthogonal (B.orthogonal W) = W := by
apply (eq_of_le_of_finrank_le (LinearMap.BilinForm.le_orthogonal_orthogonal hB₀) _).symm
simp only [finrank_orthogonal hB hB₀]
omega
variable {W : Submodule K V}
lemma isCompl_orthogonal_iff_disjoint (hB₀ : B.IsRefl) :
IsCompl W (B.orthogonal W) ↔ Disjoint W (B.orthogonal W) := by
refine ⟨IsCompl.disjoint, fun h ↦ ⟨h, ?_⟩⟩
rw [codisjoint_iff]
apply (eq_top_of_finrank_eq <| (finrank_le _).antisymm _)
calc
finrank K V ≤ finrank K V + finrank K ↥(W ⊓ B.orthogonal ⊤) := le_self_add
_ ≤ finrank K ↥(W ⊔ B.orthogonal W) + finrank K ↥(W ⊓ B.orthogonal W) := ?_
_ ≤ finrank K ↥(W ⊔ B.orthogonal W) := by simp [h.eq_bot]
rw [finrank_sup_add_finrank_inf_eq, finrank_add_finrank_orthogonal hB₀ W]
/-- A subspace is complement to its orthogonal complement with respect to some
reflexive bilinear form if that bilinear form restricted on to the subspace is nondegenerate. -/
| Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean | 349 | 354 | theorem isCompl_orthogonal_of_restrict_nondegenerate
(b₁ : B.IsRefl) (b₂ : (B.restrict W).Nondegenerate) : IsCompl W (B.orthogonal W) := by | have : W ⊓ B.orthogonal W = ⊥ := by
rw [eq_bot_iff]
intro x hx
obtain ⟨hx₁, hx₂⟩ := mem_inf.1 hx |
/-
Copyright (c) 2022 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Algebra.Polynomial.Taylor
import Mathlib.FieldTheory.RatFunc.AsPolynomial
/-!
# Laurent expansions of rational functions
## Main declarations
* `RatFunc.laurent`: the Laurent expansion of the rational function `f` at `r`, as an `AlgHom`.
* `RatFunc.laurent_injective`: the Laurent expansion at `r` is unique
## Implementation details
Implemented as the quotient of two Taylor expansions, over domains.
An auxiliary definition is provided first to make the construction of the `AlgHom` easier,
which works on `CommRing` which are not necessarily domains.
-/
universe u
namespace RatFunc
noncomputable section
open Polynomial
open scoped nonZeroDivisors
variable {R : Type u} [CommRing R] (r s : R) (p q : R[X]) (f : RatFunc R)
theorem taylor_mem_nonZeroDivisors (hp : p ∈ R[X]⁰) : taylor r p ∈ R[X]⁰ := by
rw [mem_nonZeroDivisors_iff]
intro x hx
have : x = taylor (r - r) x := by simp
rwa [this, sub_eq_add_neg, ← taylor_taylor, ← taylor_mul,
LinearMap.map_eq_zero_iff _ (taylor_injective _), mul_right_mem_nonZeroDivisors_eq_zero_iff hp,
LinearMap.map_eq_zero_iff _ (taylor_injective _)] at hx
/-- The Laurent expansion of rational functions about a value.
Auxiliary definition, usage when over integral domains should prefer `RatFunc.laurent`. -/
def laurentAux : RatFunc R →+* RatFunc R :=
RatFunc.mapRingHom
( { toFun := taylor r
map_add' := map_add (taylor r)
map_mul' := taylor_mul _
map_zero' := map_zero (taylor r)
map_one' := taylor_one r } : R[X] →+* R[X])
(taylor_mem_nonZeroDivisors _)
theorem laurentAux_ofFractionRing_mk (q : R[X]⁰) :
laurentAux r (ofFractionRing (Localization.mk p q)) =
ofFractionRing (.mk (taylor r p) ⟨taylor r q, taylor_mem_nonZeroDivisors r q q.prop⟩) :=
map_apply_ofFractionRing_mk _ _ _ _
variable [IsDomain R]
theorem laurentAux_div :
laurentAux r (algebraMap _ _ p / algebraMap _ _ q) =
algebraMap _ _ (taylor r p) / algebraMap _ _ (taylor r q) :=
-- Porting note: added `by exact taylor_mem_nonZeroDivisors r`
map_apply_div _ (by exact taylor_mem_nonZeroDivisors r) _ _
@[simp]
theorem laurentAux_algebraMap : laurentAux r (algebraMap _ _ p) = algebraMap _ _ (taylor r p) := by
rw [← mk_one, ← mk_one, mk_eq_div, laurentAux_div, mk_eq_div, taylor_one, map_one, map_one]
/-- The Laurent expansion of rational functions about a value. -/
def laurent : RatFunc R →ₐ[R] RatFunc R :=
RatFunc.mapAlgHom (.ofLinearMap (taylor r) (taylor_one _) (taylor_mul _))
(taylor_mem_nonZeroDivisors _)
theorem laurent_div :
laurent r (algebraMap _ _ p / algebraMap _ _ q) =
algebraMap _ _ (taylor r p) / algebraMap _ _ (taylor r q) :=
laurentAux_div r p q
@[simp]
theorem laurent_algebraMap : laurent r (algebraMap _ _ p) = algebraMap _ _ (taylor r p) :=
laurentAux_algebraMap _ _
@[simp]
theorem laurent_X : laurent r X = X + C r := by
rw [← algebraMap_X, laurent_algebraMap, taylor_X, map_add, algebraMap_C]
@[simp]
theorem laurent_C (x : R) : laurent r (C x) = C x := by
rw [← algebraMap_C, laurent_algebraMap, taylor_C]
@[simp]
| Mathlib/FieldTheory/Laurent.lean | 96 | 97 | theorem laurent_at_zero : laurent 0 f = f := by | induction f using RatFunc.induction_on; simp |
/-
Copyright (c) 2023 Richard M. Hill. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Richard M. Hill
-/
import Mathlib.RingTheory.PowerSeries.Trunc
import Mathlib.RingTheory.PowerSeries.Inverse
import Mathlib.RingTheory.Derivation.Basic
/-!
# Definitions
In this file we define an operation `derivative` (formal differentiation)
on the ring of formal power series in one variable (over an arbitrary commutative semiring).
Under suitable assumptions, we prove that two power series are equal if their derivatives
are equal and their constant terms are equal. This will give us a simple tool for proving
power series identities. For example, one can easily prove the power series identity
$\exp ( \log (1+X)) = 1+X$ by differentiating twice.
## Main Definition
- `PowerSeries.derivative R : Derivation R R⟦X⟧ R⟦X⟧` the formal derivative operation.
This is abbreviated `d⁄dX R`.
-/
namespace PowerSeries
open Polynomial Derivation Nat
section CommutativeSemiring
variable {R} [CommSemiring R]
/--
The formal derivative of a power series in one variable.
This is defined here as a function, but will be packaged as a
derivation `derivative` on `R⟦X⟧`.
-/
noncomputable def derivativeFun (f : R⟦X⟧) : R⟦X⟧ := mk fun n ↦ coeff R (n + 1) f * (n + 1)
theorem coeff_derivativeFun (f : R⟦X⟧) (n : ℕ) :
coeff R n f.derivativeFun = coeff R (n + 1) f * (n + 1) := by
rw [derivativeFun, coeff_mk]
theorem derivativeFun_coe (f : R[X]) : (f : R⟦X⟧).derivativeFun = derivative f := by
ext
rw [coeff_derivativeFun, coeff_coe, coeff_coe, coeff_derivative]
theorem derivativeFun_add (f g : R⟦X⟧) :
derivativeFun (f + g) = derivativeFun f + derivativeFun g := by
ext
rw [coeff_derivativeFun, map_add, map_add, coeff_derivativeFun,
coeff_derivativeFun, add_mul]
theorem derivativeFun_C (r : R) : derivativeFun (C R r) = 0 := by
ext n
-- Note that `map_zero` didn't get picked up, apparently due to a missing `FunLike.coe`
rw [coeff_derivativeFun, coeff_succ_C, zero_mul, (coeff R n).map_zero]
theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) :
trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by
ext d
rw [coeff_trunc]
split_ifs with h
· have : d + 1 < n + 1 := succ_lt_succ_iff.2 h
rw [coeff_derivativeFun, coeff_derivative, coeff_trunc, if_pos this]
· have : ¬d + 1 < n + 1 := by rwa [succ_lt_succ_iff]
rw [coeff_derivative, coeff_trunc, if_neg this, zero_mul]
--A special case of `derivativeFun_mul`, used in its proof.
private theorem derivativeFun_coe_mul_coe (f g : R[X]) : derivativeFun (f * g : R⟦X⟧) =
f * derivative g + g * derivative f := by
rw [← coe_mul, derivativeFun_coe, derivative_mul,
add_comm, mul_comm _ g, ← coe_mul, ← coe_mul, Polynomial.coe_add]
/-- **Leibniz rule for formal power series**. -/
| Mathlib/RingTheory/PowerSeries/Derivative.lean | 77 | 85 | theorem derivativeFun_mul (f g : R⟦X⟧) :
derivativeFun (f * g) = f • g.derivativeFun + g • f.derivativeFun := by | ext n
have h₁ : n < n + 1 := lt_succ_self n
have h₂ : n < n + 1 + 1 := Nat.lt_add_right _ h₁
rw [coeff_derivativeFun, map_add, coeff_mul_eq_coeff_trunc_mul_trunc _ _ (lt_succ_self _),
smul_eq_mul, smul_eq_mul, coeff_mul_eq_coeff_trunc_mul_trunc₂ g f.derivativeFun h₂ h₁,
coeff_mul_eq_coeff_trunc_mul_trunc₂ f g.derivativeFun h₂ h₁, trunc_derivativeFun,
trunc_derivativeFun, ← map_add, ← derivativeFun_coe_mul_coe, coeff_derivativeFun] |
/-
Copyright (c) 2024 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Chambert-Loir, Oliver Nash
-/
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Identities
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.RingTheory.Polynomial.Nilpotent
import Mathlib.RingTheory.Polynomial.Tower
/-!
# Newton-Raphson method
Given a single-variable polynomial `P` with derivative `P'`, Newton's method concerns iteration of
the rational map: `x ↦ x - P(x) / P'(x)`.
Over a field it can serve as a root-finding algorithm. It is also useful tool in certain proofs
such as Hensel's lemma and Jordan-Chevalley decomposition.
## Main definitions / results:
* `Polynomial.newtonMap`: the map `x ↦ x - P(x) / P'(x)`, where `P'` is the derivative of the
polynomial `P`.
* `Polynomial.isFixedPt_newtonMap_of_isUnit_iff`: `x` is a fixed point for Newton iteration iff
it is a root of `P` (provided `P'(x)` is a unit).
* `Polynomial.existsUnique_nilpotent_sub_and_aeval_eq_zero`: if `x` is almost a root of `P` in the
sense that `P(x)` is nilpotent (and `P'(x)` is a unit) then we may write `x` as a sum
`x = n + r` where `n` is nilpotent and `r` is a root of `P`. This can be used to prove the
Jordan-Chevalley decomposition of linear endomorphims.
-/
open Set Function
noncomputable section
namespace Polynomial
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] (P : R[X]) {x : S}
/-- Given a single-variable polynomial `P` with derivative `P'`, this is the map:
`x ↦ x - P(x) / P'(x)`. When `P'(x)` is not a unit we use a junk-value pattern and send `x ↦ x`. -/
def newtonMap (x : S) : S :=
x - (Ring.inverse <| aeval x (derivative P)) * aeval x P
theorem newtonMap_apply :
P.newtonMap x = x - (Ring.inverse <| aeval x (derivative P)) * (aeval x P) :=
rfl
variable {P}
theorem newtonMap_apply_of_isUnit (h : IsUnit <| aeval x (derivative P)) :
P.newtonMap x = x - h.unit⁻¹ * aeval x P := by
simp [newtonMap_apply, Ring.inverse, h]
theorem newtonMap_apply_of_not_isUnit (h : ¬ (IsUnit <| aeval x (derivative P))) :
P.newtonMap x = x := by
simp [newtonMap_apply, Ring.inverse, h]
| Mathlib/Dynamics/Newton.lean | 61 | 69 | theorem isNilpotent_iterate_newtonMap_sub_of_isNilpotent (h : IsNilpotent <| aeval x P) (n : ℕ) :
IsNilpotent <| P.newtonMap^[n] x - x := by | induction n with
| zero => simp
| succ n ih =>
rw [iterate_succ', comp_apply, newtonMap_apply, sub_right_comm]
refine (Commute.all _ _).isNilpotent_sub ih <| (Commute.all _ _).isNilpotent_mul_right ?_
simpa using Commute.isNilpotent_add (Commute.all _ _)
(isNilpotent_aeval_sub_of_isNilpotent_sub P ih) h |
/-
Copyright (c) 2022 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine
import Mathlib.Geometry.Euclidean.Angle.Unoriented.RightAngle
/-!
# Oriented angles in right-angled triangles.
This file proves basic geometrical results about distances and oriented angles in (possibly
degenerate) right-angled triangles in real inner product spaces and Euclidean affine spaces.
-/
noncomputable section
open scoped EuclideanGeometry
open scoped Real
open scoped RealInnerProductSpace
namespace Orientation
open Module
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
variable [hd2 : Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2))
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arccos_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arccos (‖y‖ / ‖x + y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arcsin`. -/
theorem oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arcsin_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- An angle in a right-angled triangle expressed using `arcsin`. -/
theorem oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arcsin (‖x‖ / ‖x + y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arctan`. -/
theorem oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arctan_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h) (o.left_ne_zero_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arctan`. -/
theorem oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arctan (‖x‖ / ‖y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two h
/-- The cosine of an angle in a right-angled triangle as a ratio of sides. -/
theorem cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle x (x + y)) = ‖x‖ / ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle as a ratio of sides. -/
theorem cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle (x + y) y) = ‖y‖ / ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).cos_oangle_add_right_of_oangle_eq_pi_div_two h
/-- The sine of an angle in a right-angled triangle as a ratio of sides. -/
theorem sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle x (x + y)) = ‖y‖ / ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- The sine of an angle in a right-angled triangle as a ratio of sides. -/
theorem sin_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle (x + y) y) = ‖x‖ / ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).sin_oangle_add_right_of_oangle_eq_pi_div_two h
/-- The tangent of an angle in a right-angled triangle as a ratio of sides. -/
theorem tan_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle x (x + y)) = ‖y‖ / ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The tangent of an angle in a right-angled triangle as a ratio of sides. -/
theorem tan_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle (x + y) y) = ‖x‖ / ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).tan_oangle_add_right_of_oangle_eq_pi_div_two h
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side. -/
theorem cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle x (x + y)) * ‖x + y‖ = ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side. -/
theorem cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x + y) y) * ‖x + y‖ = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side. -/
theorem sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle x (x + y)) * ‖x + y‖ = ‖y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side. -/
theorem sin_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle (x + y) y) * ‖x + y‖ = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side. -/
theorem tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle x (x + y)) * ‖x‖ = ‖y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side. -/
theorem tan_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle (x + y) y) * ‖y‖ = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse. -/
theorem norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.cos (o.oangle x (x + y)) = ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.norm_div_cos_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse. -/
theorem norm_div_cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.cos (o.oangle (x + y) y) = ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse. -/
theorem norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.sin (o.oangle x (x + y)) = ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.norm_div_sin_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse. -/
theorem norm_div_sin_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.sin (o.oangle (x + y) y) = ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side. -/
theorem norm_div_tan_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.tan (o.oangle x (x + y)) = ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.norm_div_tan_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side. -/
theorem norm_div_tan_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.tan (o.oangle (x + y) y) = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_tan_oangle_add_right_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arccos`, version subtracting vectors. -/
theorem oangle_sub_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle y (y - x) = Real.arccos (‖y‖ / ‖y - x‖) := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_sub_eq_arccos_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arccos`, version subtracting vectors. -/
theorem oangle_sub_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x - y) x = Real.arccos (‖x‖ / ‖x - y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).oangle_sub_right_eq_arccos_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arcsin`, version subtracting vectors. -/
theorem oangle_sub_right_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle y (y - x) = Real.arcsin (‖x‖ / ‖y - x‖) := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_sub_eq_arcsin_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- An angle in a right-angled triangle expressed using `arcsin`, version subtracting vectors. -/
theorem oangle_sub_left_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x - y) x = Real.arcsin (‖y‖ / ‖x - y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).oangle_sub_right_eq_arcsin_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arctan`, version subtracting vectors. -/
theorem oangle_sub_right_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle y (y - x) = Real.arctan (‖x‖ / ‖y‖) := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_sub_eq_arctan_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h) (o.right_ne_zero_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arctan`, version subtracting vectors. -/
theorem oangle_sub_left_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x - y) x = Real.arctan (‖y‖ / ‖x‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).oangle_sub_right_eq_arctan_of_oangle_eq_pi_div_two h
/-- The cosine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem cos_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle y (y - x)) = ‖y‖ / ‖y - x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem cos_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle (x - y) x) = ‖x‖ / ‖x - y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).cos_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- The sine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem sin_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle y (y - x)) = ‖x‖ / ‖y - x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- The sine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem sin_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle (x - y) x) = ‖y‖ / ‖x - y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).sin_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- The tangent of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem tan_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle y (y - x)) = ‖x‖ / ‖y‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The tangent of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem tan_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle (x - y) x) = ‖y‖ / ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).tan_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side, version subtracting vectors. -/
theorem cos_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle y (y - x)) * ‖y - x‖ = ‖y‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_sub_mul_norm_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side, version subtracting vectors. -/
theorem cos_oangle_sub_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x - y) x) * ‖x - y‖ = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).cos_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two h
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side, version subtracting vectors. -/
theorem sin_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle y (y - x)) * ‖y - x‖ = ‖x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_sub_mul_norm_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side, version subtracting vectors. -/
theorem sin_oangle_sub_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle (x - y) x) * ‖x - y‖ = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).sin_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two h
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side, version subtracting vectors. -/
theorem tan_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle y (y - x)) * ‖y‖ = ‖x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_sub_mul_norm_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side, version subtracting vectors. -/
theorem tan_oangle_sub_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle (x - y) x) * ‖x‖ = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).tan_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_cos_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.cos (o.oangle y (y - x)) = ‖y - x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.norm_div_cos_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_cos_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.cos (o.oangle (x - y) x) = ‖x - y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).norm_div_cos_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_sin_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.sin (o.oangle y (y - x)) = ‖y - x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.norm_div_sin_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_sin_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.sin (o.oangle (x - y) x) = ‖x - y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).norm_div_sin_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side, version subtracting vectors. -/
theorem norm_div_tan_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.tan (o.oangle y (y - x)) = ‖y‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.norm_div_tan_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side, version subtracting vectors. -/
theorem norm_div_tan_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.tan (o.oangle (x - y) x) = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).norm_div_tan_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arctan`, where one side is a multiple
of a rotation of another by `π / 2`. -/
theorem oangle_add_right_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
o.oangle x (x + r • o.rotation (π / 2 : ℝ) x) = Real.arctan r := by
rcases lt_trichotomy r 0 with (hr | rfl | hr)
· have ha : o.oangle x (r • o.rotation (π / 2 : ℝ) x) = -(π / 2 : ℝ) := by
rw [o.oangle_smul_right_of_neg _ _ hr, o.oangle_neg_right h, o.oangle_rotation_self_right h, ←
sub_eq_zero, add_comm, sub_neg_eq_add, ← Real.Angle.coe_add, ← Real.Angle.coe_add,
add_assoc, add_halves, ← two_mul, Real.Angle.coe_two_pi]
simpa using h
-- Porting note: if the type is not given in `neg_neg` then Lean "forgets" about the instance
-- `Neg (Orientation ℝ V (Fin 2))`
rw [← neg_inj, ← oangle_neg_orientation_eq_neg, @neg_neg Real.Angle] at ha
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj, oangle_rev,
(-o).oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two ha, norm_smul,
LinearIsometryEquiv.norm_map, mul_div_assoc, div_self (norm_ne_zero_iff.2 h), mul_one,
Real.norm_eq_abs, abs_of_neg hr, Real.arctan_neg, Real.Angle.coe_neg, neg_neg]
· rw [zero_smul, add_zero, oangle_self, Real.arctan_zero, Real.Angle.coe_zero]
· have ha : o.oangle x (r • o.rotation (π / 2 : ℝ) x) = (π / 2 : ℝ) := by
rw [o.oangle_smul_right_of_pos _ _ hr, o.oangle_rotation_self_right h]
rw [o.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two ha, norm_smul,
LinearIsometryEquiv.norm_map, mul_div_assoc, div_self (norm_ne_zero_iff.2 h), mul_one,
Real.norm_eq_abs, abs_of_pos hr]
/-- An angle in a right-angled triangle expressed using `arctan`, where one side is a multiple
of a rotation of another by `π / 2`. -/
theorem oangle_add_left_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
o.oangle (x + r • o.rotation (π / 2 : ℝ) x) (r • o.rotation (π / 2 : ℝ) x)
= Real.arctan r⁻¹ := by
by_cases hr : r = 0; · simp [hr]
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj, ←
neg_neg ((π / 2 : ℝ) : Real.Angle), ← rotation_neg_orientation_eq_neg, add_comm]
have hx : x = r⁻¹ • (-o).rotation (π / 2 : ℝ) (r • (-o).rotation (-(π / 2 : ℝ)) x) := by simp [hr]
nth_rw 3 [hx]
refine (-o).oangle_add_right_smul_rotation_pi_div_two ?_ _
simp [hr, h]
/-- The tangent of an angle in a right-angled triangle, where one side is a multiple of a
rotation of another by `π / 2`. -/
theorem tan_oangle_add_right_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
Real.Angle.tan (o.oangle x (x + r • o.rotation (π / 2 : ℝ) x)) = r := by
rw [o.oangle_add_right_smul_rotation_pi_div_two h, Real.Angle.tan_coe, Real.tan_arctan]
/-- The tangent of an angle in a right-angled triangle, where one side is a multiple of a
rotation of another by `π / 2`. -/
theorem tan_oangle_add_left_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
Real.Angle.tan (o.oangle (x + r • o.rotation (π / 2 : ℝ) x) (r • o.rotation (π / 2 : ℝ) x)) =
r⁻¹ := by
rw [o.oangle_add_left_smul_rotation_pi_div_two h, Real.Angle.tan_coe, Real.tan_arctan]
/-- An angle in a right-angled triangle expressed using `arctan`, where one side is a multiple
of a rotation of another by `π / 2`, version subtracting vectors. -/
| Mathlib/Geometry/Euclidean/Angle/Oriented/RightAngle.lean | 496 | 516 | theorem oangle_sub_right_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
o.oangle (r • o.rotation (π / 2 : ℝ) x) (r • o.rotation (π / 2 : ℝ) x - x)
= Real.arctan r⁻¹ := by | by_cases hr : r = 0; · simp [hr]
have hx : -x = r⁻¹ • o.rotation (π / 2 : ℝ) (r • o.rotation (π / 2 : ℝ) x) := by
simp [hr, ← Real.Angle.coe_add]
rw [sub_eq_add_neg, hx, o.oangle_add_right_smul_rotation_pi_div_two]
simpa [hr] using h
/-- An angle in a right-angled triangle expressed using `arctan`, where one side is a multiple
of a rotation of another by `π / 2`, version subtracting vectors. -/
theorem oangle_sub_left_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
o.oangle (x - r • o.rotation (π / 2 : ℝ) x) x = Real.arctan r := by
by_cases hr : r = 0; · simp [hr]
have hx : x = r⁻¹ • o.rotation (π / 2 : ℝ) (-(r • o.rotation (π / 2 : ℝ) x)) := by
simp [hr, ← Real.Angle.coe_add]
rw [sub_eq_add_neg, add_comm]
nth_rw 3 [hx]
nth_rw 2 [hx]
rw [o.oangle_add_left_smul_rotation_pi_div_two, inv_inv]
simpa [hr] using h |
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.Perm.Option
import Mathlib.Logic.Equiv.Fin.Rotate
import Mathlib.Logic.Equiv.Fintype
/-!
# Permutations of `Fin n`
-/
assert_not_exists LinearMap
open Equiv
/-- Permutations of `Fin (n + 1)` are equivalent to fixing a single
`Fin (n + 1)` and permuting the remaining with a `Perm (Fin n)`.
The fixed `Fin (n + 1)` is swapped with `0`. -/
def Equiv.Perm.decomposeFin {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) :=
((Equiv.permCongr <| finSuccEquiv n).trans Equiv.Perm.decomposeOption).trans
(Equiv.prodCongr (finSuccEquiv n).symm (Equiv.refl _))
@[simp]
theorem Equiv.Perm.decomposeFin_symm_of_refl {n : ℕ} (p : Fin (n + 1)) :
Equiv.Perm.decomposeFin.symm (p, Equiv.refl _) = swap 0 p := by
simp [Equiv.Perm.decomposeFin, Equiv.permCongr_def]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_of_one {n : ℕ} (p : Fin (n + 1)) :
Equiv.Perm.decomposeFin.symm (p, 1) = swap 0 p :=
Equiv.Perm.decomposeFin_symm_of_refl p
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_zero {n : ℕ} (p : Fin (n + 1)) (e : Perm (Fin n)) :
Equiv.Perm.decomposeFin.symm (p, e) 0 = p := by simp [Equiv.Perm.decomposeFin]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_succ {n : ℕ} (e : Perm (Fin n)) (p : Fin (n + 1))
(x : Fin n) : Equiv.Perm.decomposeFin.symm (p, e) x.succ = swap 0 p (e x).succ := by
refine Fin.cases ?_ ?_ p
· simp [Equiv.Perm.decomposeFin, EquivFunctor.map]
· intro i
by_cases h : i = e x
· simp [h, Equiv.Perm.decomposeFin, EquivFunctor.map]
· simp [h, Equiv.Perm.decomposeFin, EquivFunctor.map, swap_apply_def, Ne.symm h]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_one {n : ℕ} (e : Perm (Fin (n + 1))) (p : Fin (n + 2)) :
Equiv.Perm.decomposeFin.symm (p, e) 1 = swap 0 p (e 0).succ := by
rw [← Fin.succ_zero_eq_one, Equiv.Perm.decomposeFin_symm_apply_succ e p 0]
@[simp]
theorem Equiv.Perm.decomposeFin.symm_sign {n : ℕ} (p : Fin (n + 1)) (e : Perm (Fin n)) :
Perm.sign (Equiv.Perm.decomposeFin.symm (p, e)) = ite (p = 0) 1 (-1) * Perm.sign e := by
refine Fin.cases ?_ ?_ p <;> simp [Equiv.Perm.decomposeFin]
/-- The set of all permutations of `Fin (n + 1)` can be constructed by augmenting the set of
permutations of `Fin n` by each element of `Fin (n + 1)` in turn. -/
theorem Finset.univ_perm_fin_succ {n : ℕ} :
@Finset.univ (Perm <| Fin n.succ) _ =
(Finset.univ : Finset <| Fin n.succ × Perm (Fin n)).map
Equiv.Perm.decomposeFin.symm.toEmbedding :=
(Finset.univ_map_equiv_to_embedding _).symm
section CycleRange
/-! ### `cycleRange` section
Define the permutations `Fin.cycleRange i`, the cycle `(0 1 2 ... i)`.
-/
open Equiv.Perm
theorem finRotate_succ_eq_decomposeFin {n : ℕ} :
finRotate n.succ = decomposeFin.symm (1, finRotate n) := by
ext i
cases n; · simp
refine Fin.cases ?_ (fun i => ?_) i
· simp
rw [coe_finRotate, decomposeFin_symm_apply_succ, if_congr i.succ_eq_last_succ rfl rfl]
split_ifs with h
· simp [h]
· rw [Fin.val_succ, Function.Injective.map_swap Fin.val_injective, Fin.val_succ, coe_finRotate,
if_neg h, Fin.val_zero, Fin.val_one,
swap_apply_of_ne_of_ne (Nat.succ_ne_zero _) (Nat.succ_succ_ne_one _)]
@[simp]
theorem sign_finRotate (n : ℕ) : Perm.sign (finRotate (n + 1)) = (-1) ^ n := by
induction n with
| zero => simp
| succ n ih =>
rw [finRotate_succ_eq_decomposeFin]
simp [ih, pow_succ]
@[simp]
theorem support_finRotate {n : ℕ} : support (finRotate (n + 2)) = Finset.univ := by
ext
simp
theorem support_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : support (finRotate n) = Finset.univ := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm, support_finRotate]
theorem isCycle_finRotate {n : ℕ} : IsCycle (finRotate (n + 2)) := by
refine ⟨0, by simp, fun x hx' => ⟨x, ?_⟩⟩
clear hx'
obtain ⟨x, hx⟩ := x
rw [zpow_natCast, Fin.ext_iff, Fin.val_mk]
induction' x with x ih; · rfl
rw [pow_succ', Perm.mul_apply, coe_finRotate_of_ne_last, ih (lt_trans x.lt_succ_self hx)]
rw [Ne, Fin.ext_iff, ih (lt_trans x.lt_succ_self hx), Fin.val_last]
exact ne_of_lt (Nat.lt_of_succ_lt_succ hx)
theorem isCycle_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : IsCycle (finRotate n) := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm]
exact isCycle_finRotate
@[simp]
theorem cycleType_finRotate {n : ℕ} : cycleType (finRotate (n + 2)) = {n + 2} := by
rw [isCycle_finRotate.cycleType, support_finRotate, ← Fintype.card, Fintype.card_fin]
theorem cycleType_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : cycleType (finRotate n) = {n} := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm, cycleType_finRotate]
namespace Fin
/-- `Fin.cycleRange i` is the cycle `(0 1 2 ... i)` leaving `(i+1 ... (n-1))` unchanged. -/
def cycleRange {n : ℕ} (i : Fin n) : Perm (Fin n) :=
(finRotate (i + 1)).extendDomain
(Equiv.ofLeftInverse' (Fin.castLEEmb (Nat.succ_le_of_lt i.is_lt)) (↑)
(by
intro x
ext
simp))
theorem cycleRange_of_gt {n : ℕ} {i j : Fin n} (h : i < j) : cycleRange i j = j := by
rw [cycleRange, ofLeftInverse'_eq_ofInjective,
← Function.Embedding.toEquivRange_eq_ofInjective, ← viaFintypeEmbedding,
viaFintypeEmbedding_apply_not_mem_range]
simpa
theorem cycleRange_of_le {n : ℕ} [NeZero n] {i j : Fin n} (h : j ≤ i) :
cycleRange i j = if j = i then 0 else j + 1 := by
cases n
· subsingleton
have : j = (Fin.castLE (Nat.succ_le_of_lt i.is_lt))
⟨j, lt_of_le_of_lt h (Nat.lt_succ_self i)⟩ := by simp
ext
rw [this, cycleRange, ofLeftInverse'_eq_ofInjective, ←
Function.Embedding.toEquivRange_eq_ofInjective, ← viaFintypeEmbedding, ← coe_castLEEmb,
viaFintypeEmbedding_apply_image, coe_castLEEmb, coe_castLE, coe_finRotate]
simp only [Fin.ext_iff, val_last, val_mk, val_zero, Fin.eta, castLE_mk]
split_ifs with heq
· rfl
· rw [Fin.val_add_one_of_lt]
exact lt_of_lt_of_le (lt_of_le_of_ne h (mt (congr_arg _) heq)) (le_last i)
theorem coe_cycleRange_of_le {n : ℕ} {i j : Fin n} (h : j ≤ i) :
(cycleRange i j : ℕ) = if j = i then 0 else (j : ℕ) + 1 := by
rcases n with - | n
· exact absurd le_rfl i.pos.not_le
rw [cycleRange_of_le h]
split_ifs with h'
· rfl
exact
val_add_one_of_lt
(calc
(j : ℕ) < i := Fin.lt_iff_val_lt_val.mp (lt_of_le_of_ne h h')
_ ≤ n := Nat.lt_succ_iff.mp i.2)
theorem cycleRange_of_lt {n : ℕ} [NeZero n] {i j : Fin n} (h : j < i) : cycleRange i j = j + 1 := by
rw [cycleRange_of_le h.le, if_neg h.ne]
theorem coe_cycleRange_of_lt {n : ℕ} {i j : Fin n} (h : j < i) :
(cycleRange i j : ℕ) = j + 1 := by rw [coe_cycleRange_of_le h.le, if_neg h.ne]
theorem cycleRange_of_eq {n : ℕ} [NeZero n] {i j : Fin n} (h : j = i) : cycleRange i j = 0 := by
rw [cycleRange_of_le h.le, if_pos h]
@[simp]
theorem cycleRange_self {n : ℕ} [NeZero n] (i : Fin n) : cycleRange i i = 0 :=
cycleRange_of_eq rfl
theorem cycleRange_apply {n : ℕ} [NeZero n] (i j : Fin n) :
cycleRange i j = if j < i then j + 1 else if j = i then 0 else j := by
split_ifs with h₁ h₂
· exact cycleRange_of_lt h₁
· exact cycleRange_of_eq h₂
· exact cycleRange_of_gt (lt_of_le_of_ne (le_of_not_gt h₁) (Ne.symm h₂))
@[simp]
theorem cycleRange_zero (n : ℕ) [NeZero n] : cycleRange (0 : Fin n) = 1 := by
ext j
rcases (Fin.zero_le' j).eq_or_lt with rfl | hj
· simp
· rw [cycleRange_of_gt hj, one_apply]
@[simp]
| Mathlib/GroupTheory/Perm/Fin.lean | 205 | 206 | theorem cycleRange_last (n : ℕ) : cycleRange (last n) = finRotate (n + 1) := by | ext i |
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Aurélien Saue, Anne Baanen
-/
import Mathlib.Tactic.NormNum.Inv
import Mathlib.Tactic.NormNum.Pow
import Mathlib.Util.AtomM
/-!
# `ring` tactic
A tactic for solving equations in commutative (semi)rings,
where the exponents can also contain variables.
Based on <http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf> .
More precisely, expressions of the following form are supported:
- constants (non-negative integers)
- variables
- coefficients (any rational number, embedded into the (semi)ring)
- addition of expressions
- multiplication of expressions (`a * b`)
- scalar multiplication of expressions (`n • a`; the multiplier must have type `ℕ`)
- exponentiation of expressions (the exponent must have type `ℕ`)
- subtraction and negation of expressions (if the base is a full ring)
The extension to exponents means that something like `2 * 2^n * b = b * 2^(n+1)` can be proved,
even though it is not strictly speaking an equation in the language of commutative rings.
## Implementation notes
The basic approach to prove equalities is to normalise both sides and check for equality.
The normalisation is guided by building a value in the type `ExSum` at the meta level,
together with a proof (at the base level) that the original value is equal to
the normalised version.
The outline of the file:
- Define a mutual inductive family of types `ExSum`, `ExProd`, `ExBase`,
which can represent expressions with `+`, `*`, `^` and rational numerals.
The mutual induction ensures that associativity and distributivity are applied,
by restricting which kinds of subexpressions appear as arguments to the various operators.
- Represent addition, multiplication and exponentiation in the `ExSum` type,
thus allowing us to map expressions to `ExSum` (the `eval` function drives this).
We apply associativity and distributivity of the operators here (helped by `Ex*` types)
and commutativity as well (by sorting the subterms; unfortunately not helped by anything).
Any expression not of the above formats is treated as an atom (the same as a variable).
There are some details we glossed over which make the plan more complicated:
- The order on atoms is not initially obvious.
We construct a list containing them in order of initial appearance in the expression,
then use the index into the list as a key to order on.
- For `pow`, the exponent must be a natural number, while the base can be any semiring `α`.
We swap out operations for the base ring `α` with those for the exponent ring `ℕ`
as soon as we deal with exponents.
## Caveats and future work
The normalized form of an expression is the one that is useful for the tactic,
but not as nice to read. To remedy this, the user-facing normalization calls `ringNFCore`.
Subtraction cancels out identical terms, but division does not.
That is: `a - a = 0 := by ring` solves the goal,
but `a / a := 1 by ring` doesn't.
Note that `0 / 0` is generally defined to be `0`,
so division cancelling out is not true in general.
Multiplication of powers can be simplified a little bit further:
`2 ^ n * 2 ^ n = 4 ^ n := by ring` could be implemented
in a similar way that `2 * a + 2 * a = 4 * a := by ring` already works.
This feature wasn't needed yet, so it's not implemented yet.
## Tags
ring, semiring, exponent, power
-/
assert_not_exists OrderedAddCommMonoid
namespace Mathlib.Tactic
namespace Ring
open Mathlib.Meta Qq NormNum Lean.Meta AtomM
attribute [local instance] monadLiftOptionMetaM
open Lean (MetaM Expr mkRawNatLit)
/-- A shortcut instance for `CommSemiring ℕ` used by ring. -/
def instCommSemiringNat : CommSemiring ℕ := inferInstance
/--
A typed expression of type `CommSemiring ℕ` used when we are working on
ring subexpressions of type `ℕ`.
-/
def sℕ : Q(CommSemiring ℕ) := q(instCommSemiringNat)
mutual
/-- The base `e` of a normalized exponent expression. -/
inductive ExBase : ∀ {u : Lean.Level} {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
/--
An atomic expression `e` with id `id`.
Atomic expressions are those which `ring` cannot parse any further.
For instance, `a + (a % b)` has `a` and `(a % b)` as atoms.
The `ring1` tactic does not normalize the subexpressions in atoms, but `ring_nf` does.
Atoms in fact represent equivalence classes of expressions, modulo definitional equality.
The field `index : ℕ` should be a unique number for each class,
while `value : expr` contains a representative of this class.
The function `resolve_atom` determines the appropriate atom for a given expression.
-/
| atom {sα} {e} (id : ℕ) : ExBase sα e
/-- A sum of monomials. -/
| sum {sα} {e} (_ : ExSum sα e) : ExBase sα e
/--
A monomial, which is a product of powers of `ExBase` expressions,
terminated by a (nonzero) constant coefficient.
-/
inductive ExProd : ∀ {u : Lean.Level} {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
/-- A coefficient `value`, which must not be `0`. `e` is a raw rat cast.
If `value` is not an integer, then `hyp` should be a proof of `(value.den : α) ≠ 0`. -/
| const {sα} {e} (value : ℚ) (hyp : Option Expr := none) : ExProd sα e
/-- A product `x ^ e * b` is a monomial if `b` is a monomial. Here `x` is an `ExBase`
and `e` is an `ExProd` representing a monomial expression in `ℕ` (it is a monomial instead of
a polynomial because we eagerly normalize `x ^ (a + b) = x ^ a * x ^ b`.) -/
| mul {u : Lean.Level} {α : Q(Type u)} {sα} {x : Q($α)} {e : Q(ℕ)} {b : Q($α)} :
ExBase sα x → ExProd sℕ e → ExProd sα b → ExProd sα q($x ^ $e * $b)
/-- A polynomial expression, which is a sum of monomials. -/
inductive ExSum : ∀ {u : Lean.Level} {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
/-- Zero is a polynomial. `e` is the expression `0`. -/
| zero {u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} : ExSum sα q(0 : $α)
/-- A sum `a + b` is a polynomial if `a` is a monomial and `b` is another polynomial. -/
| add {u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExProd sα a → ExSum sα b → ExSum sα q($a + $b)
end
mutual -- partial only to speed up compilation
/-- Equality test for expressions. This is not a `BEq` instance because it is heterogeneous. -/
partial def ExBase.eq
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExBase sα a → ExBase sα b → Bool
| .atom i, .atom j => i == j
| .sum a, .sum b => a.eq b
| _, _ => false
@[inherit_doc ExBase.eq]
partial def ExProd.eq
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExProd sα a → ExProd sα b → Bool
| .const i _, .const j _ => i == j
| .mul a₁ a₂ a₃, .mul b₁ b₂ b₃ => a₁.eq b₁ && a₂.eq b₂ && a₃.eq b₃
| _, _ => false
@[inherit_doc ExBase.eq]
partial def ExSum.eq
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExSum sα a → ExSum sα b → Bool
| .zero, .zero => true
| .add a₁ a₂, .add b₁ b₂ => a₁.eq b₁ && a₂.eq b₂
| _, _ => false
end
mutual -- partial only to speed up compilation
/--
A total order on normalized expressions.
This is not an `Ord` instance because it is heterogeneous.
-/
partial def ExBase.cmp
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExBase sα a → ExBase sα b → Ordering
| .atom i, .atom j => compare i j
| .sum a, .sum b => a.cmp b
| .atom .., .sum .. => .lt
| .sum .., .atom .. => .gt
@[inherit_doc ExBase.cmp]
partial def ExProd.cmp
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExProd sα a → ExProd sα b → Ordering
| .const i _, .const j _ => compare i j
| .mul a₁ a₂ a₃, .mul b₁ b₂ b₃ => (a₁.cmp b₁).then (a₂.cmp b₂) |>.then (a₃.cmp b₃)
| .const _ _, .mul .. => .lt
| .mul .., .const _ _ => .gt
@[inherit_doc ExBase.cmp]
partial def ExSum.cmp
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExSum sα a → ExSum sα b → Ordering
| .zero, .zero => .eq
| .add a₁ a₂, .add b₁ b₂ => (a₁.cmp b₁).then (a₂.cmp b₂)
| .zero, .add .. => .lt
| .add .., .zero => .gt
end
variable {u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)}
instance : Inhabited (Σ e, (ExBase sα) e) := ⟨default, .atom 0⟩
instance : Inhabited (Σ e, (ExSum sα) e) := ⟨_, .zero⟩
instance : Inhabited (Σ e, (ExProd sα) e) := ⟨default, .const 0 none⟩
mutual
/-- Converts `ExBase sα` to `ExBase sβ`, assuming `sα` and `sβ` are defeq. -/
partial def ExBase.cast
{v : Lean.Level} {β : Q(Type v)} {sβ : Q(CommSemiring $β)} {a : Q($α)} :
ExBase sα a → Σ a, ExBase sβ a
| .atom i => ⟨a, .atom i⟩
| .sum a => let ⟨_, vb⟩ := a.cast; ⟨_, .sum vb⟩
/-- Converts `ExProd sα` to `ExProd sβ`, assuming `sα` and `sβ` are defeq. -/
partial def ExProd.cast
{v : Lean.Level} {β : Q(Type v)} {sβ : Q(CommSemiring $β)} {a : Q($α)} :
ExProd sα a → Σ a, ExProd sβ a
| .const i h => ⟨a, .const i h⟩
| .mul a₁ a₂ a₃ => ⟨_, .mul a₁.cast.2 a₂ a₃.cast.2⟩
/-- Converts `ExSum sα` to `ExSum sβ`, assuming `sα` and `sβ` are defeq. -/
partial def ExSum.cast
{v : Lean.Level} {β : Q(Type v)} {sβ : Q(CommSemiring $β)} {a : Q($α)} :
ExSum sα a → Σ a, ExSum sβ a
| .zero => ⟨_, .zero⟩
| .add a₁ a₂ => ⟨_, .add a₁.cast.2 a₂.cast.2⟩
end
variable {u : Lean.Level}
/--
The result of evaluating an (unnormalized) expression `e` into the type family `E`
(one of `ExSum`, `ExProd`, `ExBase`) is a (normalized) element `e'`
and a representation `E e'` for it, and a proof of `e = e'`.
-/
structure Result {α : Q(Type u)} (E : Q($α) → Type) (e : Q($α)) where
/-- The normalized result. -/
expr : Q($α)
/-- The data associated to the normalization. -/
val : E expr
/-- A proof that the original expression is equal to the normalized result. -/
proof : Q($e = $expr)
instance {α : Q(Type u)} {E : Q($α) → Type} {e : Q($α)} [Inhabited (Σ e, E e)] :
Inhabited (Result E e) :=
let ⟨e', v⟩ : Σ e, E e := default; ⟨e', v, default⟩
variable {α : Q(Type u)} (sα : Q(CommSemiring $α)) {R : Type*} [CommSemiring R]
/--
Constructs the expression corresponding to `.const n`.
(The `.const` constructor does not check that the expression is correct.)
-/
def ExProd.mkNat (n : ℕ) : (e : Q($α)) × ExProd sα e :=
let lit : Q(ℕ) := mkRawNatLit n
⟨q(($lit).rawCast : $α), .const n none⟩
/--
Constructs the expression corresponding to `.const (-n)`.
(The `.const` constructor does not check that the expression is correct.)
-/
def ExProd.mkNegNat (_ : Q(Ring $α)) (n : ℕ) : (e : Q($α)) × ExProd sα e :=
let lit : Q(ℕ) := mkRawNatLit n
⟨q((Int.negOfNat $lit).rawCast : $α), .const (-n) none⟩
/--
Constructs the expression corresponding to `.const q h` for `q = n / d`
and `h` a proof that `(d : α) ≠ 0`.
(The `.const` constructor does not check that the expression is correct.)
-/
def ExProd.mkRat (_ : Q(DivisionRing $α)) (q : ℚ) (n : Q(ℤ)) (d : Q(ℕ)) (h : Expr) :
(e : Q($α)) × ExProd sα e :=
⟨q(Rat.rawCast $n $d : $α), .const q h⟩
section
/-- Embed an exponent (an `ExBase, ExProd` pair) as an `ExProd` by multiplying by 1. -/
def ExBase.toProd {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a : Q($α)} {b : Q(ℕ)}
(va : ExBase sα a) (vb : ExProd sℕ b) :
ExProd sα q($a ^ $b * (nat_lit 1).rawCast) := .mul va vb (.const 1 none)
/-- Embed `ExProd` in `ExSum` by adding 0. -/
def ExProd.toSum {sα : Q(CommSemiring $α)} {e : Q($α)} (v : ExProd sα e) : ExSum sα q($e + 0) :=
.add v .zero
/-- Get the leading coefficient of an `ExProd`. -/
def ExProd.coeff {sα : Q(CommSemiring $α)} {e : Q($α)} : ExProd sα e → ℚ
| .const q _ => q
| .mul _ _ v => v.coeff
end
/--
Two monomials are said to "overlap" if they differ by a constant factor, in which case the
constants just add. When this happens, the constant may be either zero (if the monomials cancel)
or nonzero (if they add up); the zero case is handled specially.
-/
inductive Overlap (e : Q($α)) where
/-- The expression `e` (the sum of monomials) is equal to `0`. -/
| zero (_ : Q(IsNat $e (nat_lit 0)))
/-- The expression `e` (the sum of monomials) is equal to another monomial
(with nonzero leading coefficient). -/
| nonzero (_ : Result (ExProd sα) e)
variable {a a' a₁ a₂ a₃ b b' b₁ b₂ b₃ c c₁ c₂ : R}
theorem add_overlap_pf (x : R) (e) (pq_pf : a + b = c) :
x ^ e * a + x ^ e * b = x ^ e * c := by subst_vars; simp [mul_add]
theorem add_overlap_pf_zero (x : R) (e) :
IsNat (a + b) (nat_lit 0) → IsNat (x ^ e * a + x ^ e * b) (nat_lit 0)
| ⟨h⟩ => ⟨by simp [h, ← mul_add]⟩
-- TODO: decide if this is a good idea globally in
-- https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60MonadLift.20Option.20.28OptionT.20m.29.60/near/469097834
private local instance {m} [Pure m] : MonadLift Option (OptionT m) where
monadLift f := .mk <| pure f
/--
Given monomials `va, vb`, attempts to add them together to get another monomial.
If the monomials are not compatible, returns `none`.
For example, `xy + 2xy = 3xy` is a `.nonzero` overlap, while `xy + xz` returns `none`
and `xy + -xy = 0` is a `.zero` overlap.
-/
def evalAddOverlap {a b : Q($α)} (va : ExProd sα a) (vb : ExProd sα b) :
OptionT Lean.Core.CoreM (Overlap sα q($a + $b)) := do
Lean.Core.checkSystem decl_name%.toString
match va, vb with
| .const za ha, .const zb hb => do
let ra := Result.ofRawRat za a ha; let rb := Result.ofRawRat zb b hb
let res ← NormNum.evalAdd.core q($a + $b) q(HAdd.hAdd) a b ra rb
match res with
| .isNat _ (.lit (.natVal 0)) p => pure <| .zero p
| rc =>
let ⟨zc, hc⟩ ← rc.toRatNZ
let ⟨c, pc⟩ := rc.toRawEq
pure <| .nonzero ⟨c, .const zc hc, pc⟩
| .mul (x := a₁) (e := a₂) va₁ va₂ va₃, .mul vb₁ vb₂ vb₃ => do
guard (va₁.eq vb₁ && va₂.eq vb₂)
match ← evalAddOverlap va₃ vb₃ with
| .zero p => pure <| .zero (q(add_overlap_pf_zero $a₁ $a₂ $p) : Expr)
| .nonzero ⟨_, vc, p⟩ =>
pure <| .nonzero ⟨_, .mul va₁ va₂ vc, (q(add_overlap_pf $a₁ $a₂ $p) : Expr)⟩
| _, _ => OptionT.fail
theorem add_pf_zero_add (b : R) : 0 + b = b := by simp
theorem add_pf_add_zero (a : R) : a + 0 = a := by simp
theorem add_pf_add_overlap
(_ : a₁ + b₁ = c₁) (_ : a₂ + b₂ = c₂) : (a₁ + a₂ : R) + (b₁ + b₂) = c₁ + c₂ := by
subst_vars; simp [add_assoc, add_left_comm]
theorem add_pf_add_overlap_zero
(h : IsNat (a₁ + b₁) (nat_lit 0)) (h₄ : a₂ + b₂ = c) : (a₁ + a₂ : R) + (b₁ + b₂) = c := by
subst_vars; rw [add_add_add_comm, h.1, Nat.cast_zero, add_pf_zero_add]
theorem add_pf_add_lt (a₁ : R) (_ : a₂ + b = c) : (a₁ + a₂) + b = a₁ + c := by simp [*, add_assoc]
theorem add_pf_add_gt (b₁ : R) (_ : a + b₂ = c) : a + (b₁ + b₂) = b₁ + c := by
subst_vars; simp [add_left_comm]
/-- Adds two polynomials `va, vb` together to get a normalized result polynomial.
* `0 + b = b`
* `a + 0 = a`
* `a * x + a * y = a * (x + y)` (for `x`, `y` coefficients; uses `evalAddOverlap`)
* `(a₁ + a₂) + (b₁ + b₂) = a₁ + (a₂ + (b₁ + b₂))` (if `a₁.lt b₁`)
* `(a₁ + a₂) + (b₁ + b₂) = b₁ + ((a₁ + a₂) + b₂)` (if not `a₁.lt b₁`)
-/
partial def evalAdd {a b : Q($α)} (va : ExSum sα a) (vb : ExSum sα b) :
Lean.Core.CoreM <| Result (ExSum sα) q($a + $b) := do
Lean.Core.checkSystem decl_name%.toString
match va, vb with
| .zero, vb => return ⟨b, vb, q(add_pf_zero_add $b)⟩
| va, .zero => return ⟨a, va, q(add_pf_add_zero $a)⟩
| .add (a := a₁) (b := _a₂) va₁ va₂, .add (a := b₁) (b := _b₂) vb₁ vb₂ =>
match ← (evalAddOverlap sα va₁ vb₁).run with
| some (.nonzero ⟨_, vc₁, pc₁⟩) =>
let ⟨_, vc₂, pc₂⟩ ← evalAdd va₂ vb₂
return ⟨_, .add vc₁ vc₂, q(add_pf_add_overlap $pc₁ $pc₂)⟩
| some (.zero pc₁) =>
let ⟨c₂, vc₂, pc₂⟩ ← evalAdd va₂ vb₂
return ⟨c₂, vc₂, q(add_pf_add_overlap_zero $pc₁ $pc₂)⟩
| none =>
if let .lt := va₁.cmp vb₁ then
let ⟨_c, vc, (pc : Q($_a₂ + ($b₁ + $_b₂) = $_c))⟩ ← evalAdd va₂ vb
return ⟨_, .add va₁ vc, q(add_pf_add_lt $a₁ $pc)⟩
else
let ⟨_c, vc, (pc : Q($a₁ + $_a₂ + $_b₂ = $_c))⟩ ← evalAdd va vb₂
return ⟨_, .add vb₁ vc, q(add_pf_add_gt $b₁ $pc)⟩
theorem one_mul (a : R) : (nat_lit 1).rawCast * a = a := by simp [Nat.rawCast]
theorem mul_one (a : R) : a * (nat_lit 1).rawCast = a := by simp [Nat.rawCast]
theorem mul_pf_left (a₁ : R) (a₂) (_ : a₃ * b = c) :
(a₁ ^ a₂ * a₃ : R) * b = a₁ ^ a₂ * c := by
subst_vars; rw [mul_assoc]
theorem mul_pf_right (b₁ : R) (b₂) (_ : a * b₃ = c) :
a * (b₁ ^ b₂ * b₃) = b₁ ^ b₂ * c := by
subst_vars; rw [mul_left_comm]
theorem mul_pp_pf_overlap {ea eb e : ℕ} (x : R) (_ : ea + eb = e) (_ : a₂ * b₂ = c) :
(x ^ ea * a₂ : R) * (x ^ eb * b₂) = x ^ e * c := by
subst_vars; simp [pow_add, mul_mul_mul_comm]
/-- Multiplies two monomials `va, vb` together to get a normalized result monomial.
* `x * y = (x * y)` (for `x`, `y` coefficients)
* `x * (b₁ * b₂) = b₁ * (b₂ * x)` (for `x` coefficient)
* `(a₁ * a₂) * y = a₁ * (a₂ * y)` (for `y` coefficient)
* `(x ^ ea * a₂) * (x ^ eb * b₂) = x ^ (ea + eb) * (a₂ * b₂)`
(if `ea` and `eb` are identical except coefficient)
* `(a₁ * a₂) * (b₁ * b₂) = a₁ * (a₂ * (b₁ * b₂))` (if `a₁.lt b₁`)
* `(a₁ * a₂) * (b₁ * b₂) = b₁ * ((a₁ * a₂) * b₂)` (if not `a₁.lt b₁`)
-/
partial def evalMulProd {a b : Q($α)} (va : ExProd sα a) (vb : ExProd sα b) :
Lean.Core.CoreM <| Result (ExProd sα) q($a * $b) := do
Lean.Core.checkSystem decl_name%.toString
match va, vb with
| .const za ha, .const zb hb =>
if za = 1 then
return ⟨b, .const zb hb, (q(one_mul $b) : Expr)⟩
else if zb = 1 then
return ⟨a, .const za ha, (q(mul_one $a) : Expr)⟩
else
let ra := Result.ofRawRat za a ha; let rb := Result.ofRawRat zb b hb
let rc := (NormNum.evalMul.core q($a * $b) q(HMul.hMul) _ _
q(CommSemiring.toSemiring) ra rb).get!
let ⟨zc, hc⟩ := rc.toRatNZ.get!
let ⟨c, pc⟩ := rc.toRawEq
return ⟨c, .const zc hc, pc⟩
| .mul (x := a₁) (e := a₂) va₁ va₂ va₃, .const _ _ =>
let ⟨_, vc, pc⟩ ← evalMulProd va₃ vb
return ⟨_, .mul va₁ va₂ vc, (q(mul_pf_left $a₁ $a₂ $pc) : Expr)⟩
| .const _ _, .mul (x := b₁) (e := b₂) vb₁ vb₂ vb₃ =>
let ⟨_, vc, pc⟩ ← evalMulProd va vb₃
return ⟨_, .mul vb₁ vb₂ vc, (q(mul_pf_right $b₁ $b₂ $pc) : Expr)⟩
| .mul (x := xa) (e := ea) vxa vea va₂, .mul (x := xb) (e := eb) vxb veb vb₂ => do
if vxa.eq vxb then
if let some (.nonzero ⟨_, ve, pe⟩) ← (evalAddOverlap sℕ vea veb).run then
let ⟨_, vc, pc⟩ ← evalMulProd va₂ vb₂
return ⟨_, .mul vxa ve vc, (q(mul_pp_pf_overlap $xa $pe $pc) : Expr)⟩
if let .lt := (vxa.cmp vxb).then (vea.cmp veb) then
let ⟨_, vc, pc⟩ ← evalMulProd va₂ vb
return ⟨_, .mul vxa vea vc, (q(mul_pf_left $xa $ea $pc) : Expr)⟩
else
let ⟨_, vc, pc⟩ ← evalMulProd va vb₂
return ⟨_, .mul vxb veb vc, (q(mul_pf_right $xb $eb $pc) : Expr)⟩
theorem mul_zero (a : R) : a * 0 = 0 := by simp
theorem mul_add {d : R} (_ : (a : R) * b₁ = c₁) (_ : a * b₂ = c₂) (_ : c₁ + 0 + c₂ = d) :
a * (b₁ + b₂) = d := by
subst_vars; simp [_root_.mul_add]
/-- Multiplies a monomial `va` to a polynomial `vb` to get a normalized result polynomial.
* `a * 0 = 0`
* `a * (b₁ + b₂) = (a * b₁) + (a * b₂)`
-/
def evalMul₁ {a b : Q($α)} (va : ExProd sα a) (vb : ExSum sα b) :
Lean.Core.CoreM <| Result (ExSum sα) q($a * $b) := do
match vb with
| .zero => return ⟨_, .zero, q(mul_zero $a)⟩
| .add vb₁ vb₂ =>
let ⟨_, vc₁, pc₁⟩ ← evalMulProd sα va vb₁
let ⟨_, vc₂, pc₂⟩ ← evalMul₁ va vb₂
let ⟨_, vd, pd⟩ ← evalAdd sα vc₁.toSum vc₂
return ⟨_, vd, q(mul_add $pc₁ $pc₂ $pd)⟩
theorem zero_mul (b : R) : 0 * b = 0 := by simp
theorem add_mul {d : R} (_ : (a₁ : R) * b = c₁) (_ : a₂ * b = c₂) (_ : c₁ + c₂ = d) :
(a₁ + a₂) * b = d := by subst_vars; simp [_root_.add_mul]
/-- Multiplies two polynomials `va, vb` together to get a normalized result polynomial.
* `0 * b = 0`
* `(a₁ + a₂) * b = (a₁ * b) + (a₂ * b)`
-/
def evalMul {a b : Q($α)} (va : ExSum sα a) (vb : ExSum sα b) :
Lean.Core.CoreM <| Result (ExSum sα) q($a * $b) := do
match va with
| .zero => return ⟨_, .zero, q(zero_mul $b)⟩
| .add va₁ va₂ =>
let ⟨_, vc₁, pc₁⟩ ← evalMul₁ sα va₁ vb
let ⟨_, vc₂, pc₂⟩ ← evalMul va₂ vb
let ⟨_, vd, pd⟩ ← evalAdd sα vc₁ vc₂
return ⟨_, vd, q(add_mul $pc₁ $pc₂ $pd)⟩
theorem natCast_nat (n) : ((Nat.rawCast n : ℕ) : R) = Nat.rawCast n := by simp
theorem natCast_mul {a₁ a₃ : ℕ} (a₂) (_ : ((a₁ : ℕ) : R) = b₁)
(_ : ((a₃ : ℕ) : R) = b₃) : ((a₁ ^ a₂ * a₃ : ℕ) : R) = b₁ ^ a₂ * b₃ := by
subst_vars; simp
theorem natCast_zero : ((0 : ℕ) : R) = 0 := Nat.cast_zero
theorem natCast_add {a₁ a₂ : ℕ}
(_ : ((a₁ : ℕ) : R) = b₁) (_ : ((a₂ : ℕ) : R) = b₂) : ((a₁ + a₂ : ℕ) : R) = b₁ + b₂ := by
subst_vars; simp
mutual
/-- Applies `Nat.cast` to a nat polynomial to produce a polynomial in `α`.
* An atom `e` causes `↑e` to be allocated as a new atom.
* A sum delegates to `ExSum.evalNatCast`.
-/
partial def ExBase.evalNatCast {a : Q(ℕ)} (va : ExBase sℕ a) : AtomM (Result (ExBase sα) q($a)) :=
match va with
| .atom _ => do
let (i, ⟨b', _⟩) ← addAtomQ q($a)
pure ⟨b', ExBase.atom i, q(Eq.refl $b')⟩
| .sum va => do
let ⟨_, vc, p⟩ ← va.evalNatCast
pure ⟨_, .sum vc, p⟩
/-- Applies `Nat.cast` to a nat monomial to produce a monomial in `α`.
* `↑c = c` if `c` is a numeric literal
* `↑(a ^ n * b) = ↑a ^ n * ↑b`
-/
partial def ExProd.evalNatCast {a : Q(ℕ)} (va : ExProd sℕ a) : AtomM (Result (ExProd sα) q($a)) :=
match va with
| .const c hc =>
have n : Q(ℕ) := a.appArg!
pure ⟨q(Nat.rawCast $n), .const c hc, (q(natCast_nat (R := $α) $n) : Expr)⟩
| .mul (e := a₂) va₁ va₂ va₃ => do
let ⟨_, vb₁, pb₁⟩ ← va₁.evalNatCast
let ⟨_, vb₃, pb₃⟩ ← va₃.evalNatCast
pure ⟨_, .mul vb₁ va₂ vb₃, q(natCast_mul $a₂ $pb₁ $pb₃)⟩
/-- Applies `Nat.cast` to a nat polynomial to produce a polynomial in `α`.
* `↑0 = 0`
* `↑(a + b) = ↑a + ↑b`
-/
partial def ExSum.evalNatCast {a : Q(ℕ)} (va : ExSum sℕ a) : AtomM (Result (ExSum sα) q($a)) :=
match va with
| .zero => pure ⟨_, .zero, q(natCast_zero (R := $α))⟩
| .add va₁ va₂ => do
let ⟨_, vb₁, pb₁⟩ ← va₁.evalNatCast
let ⟨_, vb₂, pb₂⟩ ← va₂.evalNatCast
pure ⟨_, .add vb₁ vb₂, q(natCast_add $pb₁ $pb₂)⟩
end
theorem smul_nat {a b c : ℕ} (_ : (a * b : ℕ) = c) : a • b = c := by subst_vars; simp
theorem smul_eq_cast {a : ℕ} (_ : ((a : ℕ) : R) = a') (_ : a' * b = c) : a • b = c := by
subst_vars; simp
/-- Constructs the scalar multiplication `n • a`, where both `n : ℕ` and `a : α` are normalized
polynomial expressions.
* `a • b = a * b` if `α = ℕ`
* `a • b = ↑a * b` otherwise
-/
def evalNSMul {a : Q(ℕ)} {b : Q($α)} (va : ExSum sℕ a) (vb : ExSum sα b) :
AtomM (Result (ExSum sα) q($a • $b)) := do
if ← isDefEq sα sℕ then
let ⟨_, va'⟩ := va.cast
have _b : Q(ℕ) := b
let ⟨(_c : Q(ℕ)), vc, (pc : Q($a * $_b = $_c))⟩ ← evalMul sα va' vb
pure ⟨_, vc, (q(smul_nat $pc) : Expr)⟩
else
let ⟨_, va', pa'⟩ ← va.evalNatCast sα
let ⟨_, vc, pc⟩ ← evalMul sα va' vb
pure ⟨_, vc, (q(smul_eq_cast $pa' $pc) : Expr)⟩
theorem neg_one_mul {R} [Ring R] {a b : R} (_ : (Int.negOfNat (nat_lit 1)).rawCast * a = b) :
-a = b := by subst_vars; simp [Int.negOfNat]
theorem neg_mul {R} [Ring R] (a₁ : R) (a₂) {a₃ b : R}
(_ : -a₃ = b) : -(a₁ ^ a₂ * a₃) = a₁ ^ a₂ * b := by subst_vars; simp
/-- Negates a monomial `va` to get another monomial.
* `-c = (-c)` (for `c` coefficient)
* `-(a₁ * a₂) = a₁ * -a₂`
-/
def evalNegProd {a : Q($α)} (rα : Q(Ring $α)) (va : ExProd sα a) :
Lean.Core.CoreM <| Result (ExProd sα) q(-$a) := do
Lean.Core.checkSystem decl_name%.toString
match va with
| .const za ha =>
let lit : Q(ℕ) := mkRawNatLit 1
let ⟨m1, _⟩ := ExProd.mkNegNat sα rα 1
let rm := Result.isNegNat rα lit (q(IsInt.of_raw $α (.negOfNat $lit)) : Expr)
let ra := Result.ofRawRat za a ha
let rb := (NormNum.evalMul.core q($m1 * $a) q(HMul.hMul) _ _
q(CommSemiring.toSemiring) rm ra).get!
let ⟨zb, hb⟩ := rb.toRatNZ.get!
let ⟨b, (pb : Q((Int.negOfNat (nat_lit 1)).rawCast * $a = $b))⟩ := rb.toRawEq
return ⟨b, .const zb hb, (q(neg_one_mul (R := $α) $pb) : Expr)⟩
| .mul (x := a₁) (e := a₂) va₁ va₂ va₃ =>
let ⟨_, vb, pb⟩ ← evalNegProd rα va₃
return ⟨_, .mul va₁ va₂ vb, (q(neg_mul $a₁ $a₂ $pb) : Expr)⟩
theorem neg_zero {R} [Ring R] : -(0 : R) = 0 := by simp
theorem neg_add {R} [Ring R] {a₁ a₂ b₁ b₂ : R}
(_ : -a₁ = b₁) (_ : -a₂ = b₂) : -(a₁ + a₂) = b₁ + b₂ := by
subst_vars; simp [add_comm]
/-- Negates a polynomial `va` to get another polynomial.
* `-0 = 0` (for `c` coefficient)
* `-(a₁ + a₂) = -a₁ + -a₂`
-/
def evalNeg {a : Q($α)} (rα : Q(Ring $α)) (va : ExSum sα a) :
Lean.Core.CoreM <| Result (ExSum sα) q(-$a) := do
match va with
| .zero => return ⟨_, .zero, (q(neg_zero (R := $α)) : Expr)⟩
| .add va₁ va₂ =>
let ⟨_, vb₁, pb₁⟩ ← evalNegProd sα rα va₁
let ⟨_, vb₂, pb₂⟩ ← evalNeg rα va₂
return ⟨_, .add vb₁ vb₂, (q(neg_add $pb₁ $pb₂) : Expr)⟩
theorem sub_pf {R} [Ring R] {a b c d : R}
(_ : -b = c) (_ : a + c = d) : a - b = d := by subst_vars; simp [sub_eq_add_neg]
/-- Subtracts two polynomials `va, vb` to get a normalized result polynomial.
* `a - b = a + -b`
-/
def evalSub {α : Q(Type u)} (sα : Q(CommSemiring $α)) {a b : Q($α)}
(rα : Q(Ring $α)) (va : ExSum sα a) (vb : ExSum sα b) :
Lean.Core.CoreM <| Result (ExSum sα) q($a - $b) := do
let ⟨_c, vc, pc⟩ ← evalNeg sα rα vb
let ⟨d, vd, (pd : Q($a + $_c = $d))⟩ ← evalAdd sα va vc
return ⟨d, vd, (q(sub_pf $pc $pd) : Expr)⟩
theorem pow_prod_atom (a : R) (b) : a ^ b = (a + 0) ^ b * (nat_lit 1).rawCast := by simp
/--
The fallback case for exponentiating polynomials is to use `ExBase.toProd` to just build an
exponent expression. (This has a slightly different normalization than `evalPowAtom` because
the input types are different.)
* `x ^ e = (x + 0) ^ e * 1`
-/
def evalPowProdAtom {a : Q($α)} {b : Q(ℕ)} (va : ExProd sα a) (vb : ExProd sℕ b) :
Result (ExProd sα) q($a ^ $b) :=
⟨_, (ExBase.sum va.toSum).toProd vb, q(pow_prod_atom $a $b)⟩
theorem pow_atom (a : R) (b) : a ^ b = a ^ b * (nat_lit 1).rawCast + 0 := by simp
/--
The fallback case for exponentiating polynomials is to use `ExBase.toProd` to just build an
exponent expression.
* `x ^ e = x ^ e * 1 + 0`
-/
def evalPowAtom {a : Q($α)} {b : Q(ℕ)} (va : ExBase sα a) (vb : ExProd sℕ b) :
Result (ExSum sα) q($a ^ $b) :=
⟨_, (va.toProd vb).toSum, q(pow_atom $a $b)⟩
theorem const_pos (n : ℕ) (h : Nat.ble 1 n = true) : 0 < (n.rawCast : ℕ) := Nat.le_of_ble_eq_true h
theorem mul_exp_pos {a₁ a₂ : ℕ} (n) (h₁ : 0 < a₁) (h₂ : 0 < a₂) : 0 < a₁ ^ n * a₂ :=
Nat.mul_pos (Nat.pow_pos h₁) h₂
theorem add_pos_left {a₁ : ℕ} (a₂) (h : 0 < a₁) : 0 < a₁ + a₂ :=
Nat.lt_of_lt_of_le h (Nat.le_add_right ..)
theorem add_pos_right {a₂ : ℕ} (a₁) (h : 0 < a₂) : 0 < a₁ + a₂ :=
Nat.lt_of_lt_of_le h (Nat.le_add_left ..)
mutual
/-- Attempts to prove that a polynomial expression in `ℕ` is positive.
* Atoms are not (necessarily) positive
* Sums defer to `ExSum.evalPos`
-/
partial def ExBase.evalPos {a : Q(ℕ)} (va : ExBase sℕ a) : Option Q(0 < $a) :=
match va with
| .atom _ => none
| .sum va => va.evalPos
/-- Attempts to prove that a monomial expression in `ℕ` is positive.
* `0 < c` (where `c` is a numeral) is true by the normalization invariant (`c` is not zero)
* `0 < x ^ e * b` if `0 < x` and `0 < b`
-/
partial def ExProd.evalPos {a : Q(ℕ)} (va : ExProd sℕ a) : Option Q(0 < $a) :=
match va with
| .const _ _ =>
-- it must be positive because it is a nonzero nat literal
have lit : Q(ℕ) := a.appArg!
haveI : $a =Q Nat.rawCast $lit := ⟨⟩
haveI p : Nat.ble 1 $lit =Q true := ⟨⟩
some q(const_pos $lit $p)
| .mul (e := ea₁) vxa₁ _ va₂ => do
let pa₁ ← vxa₁.evalPos
let pa₂ ← va₂.evalPos
some q(mul_exp_pos $ea₁ $pa₁ $pa₂)
/-- Attempts to prove that a polynomial expression in `ℕ` is positive.
* `0 < 0` fails
* `0 < a + b` if `0 < a` or `0 < b`
-/
partial def ExSum.evalPos {a : Q(ℕ)} (va : ExSum sℕ a) : Option Q(0 < $a) :=
match va with
| .zero => none
| .add (a := a₁) (b := a₂) va₁ va₂ => do
match va₁.evalPos with
| some p => some q(add_pos_left $a₂ $p)
| none => let p ← va₂.evalPos; some q(add_pos_right $a₁ $p)
end
theorem pow_one (a : R) : a ^ nat_lit 1 = a := by simp
theorem pow_bit0 {k : ℕ} (_ : (a : R) ^ k = b) (_ : b * b = c) :
a ^ (Nat.mul (nat_lit 2) k) = c := by
subst_vars; simp [Nat.succ_mul, pow_add]
theorem pow_bit1 {k : ℕ} {d : R} (_ : (a : R) ^ k = b) (_ : b * b = c) (_ : c * a = d) :
a ^ (Nat.add (Nat.mul (nat_lit 2) k) (nat_lit 1)) = d := by
subst_vars; simp [Nat.succ_mul, pow_add]
/--
The main case of exponentiation of ring expressions is when `va` is a polynomial and `n` is a
nonzero literal expression, like `(x + y)^5`. In this case we work out the polynomial completely
into a sum of monomials.
* `x ^ 1 = x`
* `x ^ (2*n) = x ^ n * x ^ n`
* `x ^ (2*n+1) = x ^ n * x ^ n * x`
-/
partial def evalPowNat {a : Q($α)} (va : ExSum sα a) (n : Q(ℕ)) :
Lean.Core.CoreM <| Result (ExSum sα) q($a ^ $n) := do
let nn := n.natLit!
if nn = 1 then
return ⟨_, va, (q(pow_one $a) : Expr)⟩
else
let nm := nn >>> 1
have m : Q(ℕ) := mkRawNatLit nm
if nn &&& 1 = 0 then
let ⟨_, vb, pb⟩ ← evalPowNat va m
let ⟨_, vc, pc⟩ ← evalMul sα vb vb
return ⟨_, vc, (q(pow_bit0 $pb $pc) : Expr)⟩
else
let ⟨_, vb, pb⟩ ← evalPowNat va m
let ⟨_, vc, pc⟩ ← evalMul sα vb vb
let ⟨_, vd, pd⟩ ← evalMul sα vc va
return ⟨_, vd, (q(pow_bit1 $pb $pc $pd) : Expr)⟩
theorem one_pow (b : ℕ) : ((nat_lit 1).rawCast : R) ^ b = (nat_lit 1).rawCast := by simp
theorem mul_pow {ea₁ b c₁ : ℕ} {xa₁ : R}
(_ : ea₁ * b = c₁) (_ : a₂ ^ b = c₂) : (xa₁ ^ ea₁ * a₂ : R) ^ b = xa₁ ^ c₁ * c₂ := by
subst_vars; simp [_root_.mul_pow, pow_mul]
/-- There are several special cases when exponentiating monomials:
* `1 ^ n = 1`
* `x ^ y = (x ^ y)` when `x` and `y` are constants
* `(a * b) ^ e = a ^ e * b ^ e`
In all other cases we use `evalPowProdAtom`.
-/
def evalPowProd {a : Q($α)} {b : Q(ℕ)} (va : ExProd sα a) (vb : ExProd sℕ b) :
Lean.Core.CoreM <| Result (ExProd sα) q($a ^ $b) := do
Lean.Core.checkSystem decl_name%.toString
let res : OptionT Lean.Core.CoreM (Result (ExProd sα) q($a ^ $b)) := do
match va, vb with
| .const 1, _ => return ⟨_, va, (q(one_pow (R := $α) $b) : Expr)⟩
| .const za ha, .const zb hb =>
assert! 0 ≤ zb
let ra := Result.ofRawRat za a ha
have lit : Q(ℕ) := b.appArg!
let rb := (q(IsNat.of_raw ℕ $lit) : Expr)
let rc ← NormNum.evalPow.core q($a ^ $b) q(HPow.hPow) q($a) q($b) lit rb
q(CommSemiring.toSemiring) ra
let ⟨zc, hc⟩ ← rc.toRatNZ
let ⟨c, pc⟩ := rc.toRawEq
return ⟨c, .const zc hc, pc⟩
| .mul vxa₁ vea₁ va₂, vb =>
let ⟨_, vc₁, pc₁⟩ ← evalMulProd sℕ vea₁ vb
let ⟨_, vc₂, pc₂⟩ ← evalPowProd va₂ vb
return ⟨_, .mul vxa₁ vc₁ vc₂, q(mul_pow $pc₁ $pc₂)⟩
| _, _ => OptionT.fail
return (← res.run).getD (evalPowProdAtom sα va vb)
/--
The result of `extractCoeff` is a numeral and a proof that the original expression
factors by this numeral.
-/
structure ExtractCoeff (e : Q(ℕ)) where
/-- A raw natural number literal. -/
k : Q(ℕ)
/-- The result of extracting the coefficient is a monic monomial. -/
e' : Q(ℕ)
/-- `e'` is a monomial. -/
ve' : ExProd sℕ e'
/-- The proof that `e` splits into the coefficient `k` and the monic monomial `e'`. -/
p : Q($e = $e' * $k)
theorem coeff_one (k : ℕ) : k.rawCast = (nat_lit 1).rawCast * k := by simp
theorem coeff_mul {a₃ c₂ k : ℕ}
(a₁ a₂ : ℕ) (_ : a₃ = c₂ * k) : a₁ ^ a₂ * a₃ = (a₁ ^ a₂ * c₂) * k := by
subst_vars; rw [mul_assoc]
/-- Given a monomial expression `va`, splits off the leading coefficient `k` and the remainder
`e'`, stored in the `ExtractCoeff` structure.
* `c = 1 * c` (if `c` is a constant)
* `a * b = (a * b') * k` if `b = b' * k`
-/
def extractCoeff {a : Q(ℕ)} (va : ExProd sℕ a) : ExtractCoeff a :=
match va with
| .const _ _ =>
have k : Q(ℕ) := a.appArg!
⟨k, q((nat_lit 1).rawCast), .const 1, (q(coeff_one $k) : Expr)⟩
| .mul (x := a₁) (e := a₂) va₁ va₂ va₃ =>
let ⟨k, _, vc, pc⟩ := extractCoeff va₃
⟨k, _, .mul va₁ va₂ vc, q(coeff_mul $a₁ $a₂ $pc)⟩
theorem pow_one_cast (a : R) : a ^ (nat_lit 1).rawCast = a := by simp
theorem zero_pow {b : ℕ} (_ : 0 < b) : (0 : R) ^ b = 0 := match b with | b+1 => by simp [pow_succ]
theorem single_pow {b : ℕ} (_ : (a : R) ^ b = c) : (a + 0) ^ b = c + 0 := by
simp [*]
theorem pow_nat {b c k : ℕ} {d e : R} (_ : b = c * k) (_ : a ^ c = d) (_ : d ^ k = e) :
(a : R) ^ b = e := by
subst_vars; simp [pow_mul]
/-- Exponentiates a polynomial `va` by a monomial `vb`, including several special cases.
* `a ^ 1 = a`
* `0 ^ e = 0` if `0 < e`
* `(a + 0) ^ b = a ^ b` computed using `evalPowProd`
* `a ^ b = (a ^ b') ^ k` if `b = b' * k` and `k > 1`
Otherwise `a ^ b` is just encoded as `a ^ b * 1 + 0` using `evalPowAtom`.
-/
partial def evalPow₁ {a : Q($α)} {b : Q(ℕ)} (va : ExSum sα a) (vb : ExProd sℕ b) :
Lean.Core.CoreM <| Result (ExSum sα) q($a ^ $b) := do
match va, vb with
| va, .const 1 =>
haveI : $b =Q Nat.rawCast (nat_lit 1) := ⟨⟩
return ⟨_, va, q(pow_one_cast $a)⟩
| .zero, vb => match vb.evalPos with
| some p => return ⟨_, .zero, q(zero_pow (R := $α) $p)⟩
| none => return evalPowAtom sα (.sum .zero) vb
| ExSum.add va .zero, vb => -- TODO: using `.add` here takes a while to compile?
let ⟨_, vc, pc⟩ ← evalPowProd sα va vb
return ⟨_, vc.toSum, q(single_pow $pc)⟩
| va, vb =>
if vb.coeff > 1 then
let ⟨k, _, vc, pc⟩ := extractCoeff vb
let ⟨_, vd, pd⟩ ← evalPow₁ va vc
let ⟨_, ve, pe⟩ ← evalPowNat sα vd k
return ⟨_, ve, q(pow_nat $pc $pd $pe)⟩
else
return evalPowAtom sα (.sum va) vb
theorem pow_zero (a : R) : a ^ 0 = (nat_lit 1).rawCast + 0 := by simp
theorem pow_add {b₁ b₂ : ℕ} {d : R}
(_ : a ^ b₁ = c₁) (_ : a ^ b₂ = c₂) (_ : c₁ * c₂ = d) : (a : R) ^ (b₁ + b₂) = d := by
subst_vars; simp [_root_.pow_add]
/-- Exponentiates two polynomials `va, vb`.
* `a ^ 0 = 1`
* `a ^ (b₁ + b₂) = a ^ b₁ * a ^ b₂`
-/
def evalPow {a : Q($α)} {b : Q(ℕ)} (va : ExSum sα a) (vb : ExSum sℕ b) :
Lean.Core.CoreM <| Result (ExSum sα) q($a ^ $b) := do
match vb with
| .zero => return ⟨_, (ExProd.mkNat sα 1).2.toSum, q(pow_zero $a)⟩
| .add vb₁ vb₂ =>
let ⟨_, vc₁, pc₁⟩ ← evalPow₁ sα va vb₁
let ⟨_, vc₂, pc₂⟩ ← evalPow va vb₂
let ⟨_, vd, pd⟩ ← evalMul sα vc₁ vc₂
return ⟨_, vd, q(pow_add $pc₁ $pc₂ $pd)⟩
/-- This cache contains data required by the `ring` tactic during execution. -/
structure Cache {α : Q(Type u)} (sα : Q(CommSemiring $α)) where
/-- A ring instance on `α`, if available. -/
rα : Option Q(Ring $α)
/-- A division ring instance on `α`, if available. -/
dα : Option Q(DivisionRing $α)
/-- A characteristic zero ring instance on `α`, if available. -/
czα : Option Q(CharZero $α)
/-- Create a new cache for `α` by doing the necessary instance searches. -/
def mkCache {α : Q(Type u)} (sα : Q(CommSemiring $α)) : MetaM (Cache sα) :=
return {
rα := (← trySynthInstanceQ q(Ring $α)).toOption
dα := (← trySynthInstanceQ q(DivisionRing $α)).toOption
czα := (← trySynthInstanceQ q(CharZero $α)).toOption }
theorem cast_pos {n : ℕ} : IsNat (a : R) n → a = n.rawCast + 0
| ⟨e⟩ => by simp [e]
theorem cast_zero : IsNat (a : R) (nat_lit 0) → a = 0
| ⟨e⟩ => by simp [e]
theorem cast_neg {n : ℕ} {R} [Ring R] {a : R} :
IsInt a (.negOfNat n) → a = (Int.negOfNat n).rawCast + 0
| ⟨e⟩ => by simp [e]
theorem cast_rat {n : ℤ} {d : ℕ} {R} [DivisionRing R] {a : R} :
IsRat a n d → a = Rat.rawCast n d + 0
| ⟨_, e⟩ => by simp [e, div_eq_mul_inv]
/-- Converts a proof by `norm_num` that `e` is a numeral, into a normalization as a monomial:
* `e = 0` if `norm_num` returns `IsNat e 0`
* `e = Nat.rawCast n + 0` if `norm_num` returns `IsNat e n`
* `e = Int.rawCast n + 0` if `norm_num` returns `IsInt e n`
* `e = Rat.rawCast n d + 0` if `norm_num` returns `IsRat e n d`
-/
def evalCast {α : Q(Type u)} (sα : Q(CommSemiring $α)) {e : Q($α)} :
NormNum.Result e → Option (Result (ExSum sα) e)
| .isNat _ (.lit (.natVal 0)) p => do
assumeInstancesCommute
pure ⟨_, .zero, q(cast_zero $p)⟩
| .isNat _ lit p => do
assumeInstancesCommute
pure ⟨_, (ExProd.mkNat sα lit.natLit!).2.toSum, (q(cast_pos $p) :)⟩
| .isNegNat rα lit p =>
pure ⟨_, (ExProd.mkNegNat _ rα lit.natLit!).2.toSum, (q(cast_neg $p) : Expr)⟩
| .isRat dα q n d p =>
pure ⟨_, (ExProd.mkRat sα dα q n d q(IsRat.den_nz $p)).2.toSum, (q(cast_rat $p) : Expr)⟩
| _ => none
theorem toProd_pf (p : (a : R) = a') :
a = a' ^ (nat_lit 1).rawCast * (nat_lit 1).rawCast := by simp [*]
theorem atom_pf (a : R) : a = a ^ (nat_lit 1).rawCast * (nat_lit 1).rawCast + 0 := by simp
theorem atom_pf' (p : (a : R) = a') :
a = a' ^ (nat_lit 1).rawCast * (nat_lit 1).rawCast + 0 := by simp [*]
/--
Evaluates an atom, an expression where `ring` can find no additional structure.
* `a = a ^ 1 * 1 + 0`
-/
def evalAtom (e : Q($α)) : AtomM (Result (ExSum sα) e) := do
let r ← (← read).evalAtom e
have e' : Q($α) := r.expr
let (i, ⟨a', _⟩) ← addAtomQ e'
let ve' := (ExBase.atom i (e := a')).toProd (ExProd.mkNat sℕ 1).2 |>.toSum
pure ⟨_, ve', match r.proof? with
| none => (q(atom_pf $e) : Expr)
| some (p : Q($e = $a')) => (q(atom_pf' $p) : Expr)⟩
theorem inv_mul {R} [DivisionRing R] {a₁ a₂ a₃ b₁ b₃ c}
(_ : (a₁⁻¹ : R) = b₁) (_ : (a₃⁻¹ : R) = b₃)
(_ : b₃ * (b₁ ^ a₂ * (nat_lit 1).rawCast) = c) :
(a₁ ^ a₂ * a₃ : R)⁻¹ = c := by subst_vars; simp
nonrec theorem inv_zero {R} [DivisionRing R] : (0 : R)⁻¹ = 0 := inv_zero
| Mathlib/Tactic/Ring/Basic.lean | 968 | 969 | theorem inv_single {R} [DivisionRing R] {a b : R}
(_ : (a : R)⁻¹ = b) : (a + 0)⁻¹ = b + 0 := by | simp [*] |
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Yury Kudryashov, Neil Strickland
-/
import Mathlib.Algebra.Ring.InjSurj
import Mathlib.Algebra.Group.Units.Hom
import Mathlib.Algebra.Ring.Hom.Defs
/-!
# Units in semirings and rings
-/
universe u v w x
variable {α : Type u} {β : Type v} {R : Type x}
open Function
namespace Units
section HasDistribNeg
variable [Monoid α] [HasDistribNeg α]
/-- Each element of the group of units of a ring has an additive inverse. -/
instance : Neg αˣ :=
⟨fun u => ⟨-↑u, -↑u⁻¹, by simp, by simp⟩⟩
/-- Representing an element of a ring's unit group as an element of the ring commutes with
mapping this element to its additive inverse. -/
@[simp, norm_cast]
protected theorem val_neg (u : αˣ) : (↑(-u) : α) = -u :=
rfl
@[simp, norm_cast]
protected theorem coe_neg_one : ((-1 : αˣ) : α) = -1 :=
rfl
instance : HasDistribNeg αˣ :=
Units.ext.hasDistribNeg _ Units.val_neg Units.val_mul
@[field_simps]
theorem neg_divp (a : α) (u : αˣ) : -(a /ₚ u) = -a /ₚ u := by simp only [divp, neg_mul]
end HasDistribNeg
section Ring
variable [Ring α]
-- Needs to have higher simp priority than divp_add_divp. 1000 is the default priority.
@[field_simps 1010]
theorem divp_add_divp_same (a b : α) (u : αˣ) : a /ₚ u + b /ₚ u = (a + b) /ₚ u := by
simp only [divp, add_mul]
-- Needs to have higher simp priority than divp_sub_divp. 1000 is the default priority.
@[field_simps 1010]
| Mathlib/Algebra/Ring/Units.lean | 61 | 62 | theorem divp_sub_divp_same (a b : α) (u : αˣ) : a /ₚ u - b /ₚ u = (a - b) /ₚ u := by | rw [sub_eq_add_neg, sub_eq_add_neg, neg_divp, divp_add_divp_same] |
/-
Copyright (c) 2018 Louis Carlin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Louis Carlin, Mario Carneiro
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Order.RelClasses
/-!
# Euclidean domains
This file introduces Euclidean domains and provides the extended Euclidean algorithm. To be precise,
a slightly more general version is provided which is sometimes called a transfinite Euclidean domain
and differs in the fact that the degree function need not take values in `ℕ` but can take values in
any well-ordered set. Transfinite Euclidean domains were introduced by Motzkin and examples which
don't satisfy the classical notion were provided independently by Hiblot and Nagata.
## Main definitions
* `EuclideanDomain`: Defines Euclidean domain with functions `quotient` and `remainder`. Instances
of `Div` and `Mod` are provided, so that one can write `a = b * (a / b) + a % b`.
* `gcd`: defines the greatest common divisors of two elements of a Euclidean domain.
* `xgcd`: given two elements `a b : R`, `xgcd a b` defines the pair `(x, y)` such that
`x * a + y * b = gcd a b`.
* `lcm`: defines the lowest common multiple of two elements `a` and `b` of a Euclidean domain as
`a * b / (gcd a b)`
## Main statements
See `Algebra.EuclideanDomain.Basic` for most of the theorems about Euclidean domains,
including Bézout's lemma.
See `Algebra.EuclideanDomain.Instances` for the fact that `ℤ` is a Euclidean domain,
as is any field.
## Notation
`≺` denotes the well founded relation on the Euclidean domain, e.g. in the example of the polynomial
ring over a field, `p ≺ q` for polynomials `p` and `q` if and only if the degree of `p` is less than
the degree of `q`.
## Implementation details
Instead of working with a valuation, `EuclideanDomain` is implemented with the existence of a well
founded relation `r` on the integral domain `R`, which in the example of `ℤ` would correspond to
setting `i ≺ j` for integers `i` and `j` if the absolute value of `i` is smaller than the absolute
value of `j`.
## References
* [Th. Motzkin, *The Euclidean algorithm*][MR32592]
* [J.-J. Hiblot, *Des anneaux euclidiens dont le plus petit algorithme n'est pas à valeurs finies*]
[MR399081]
* [M. Nagata, *On Euclid algorithm*][MR541021]
## Tags
Euclidean domain, transfinite Euclidean domain, Bézout's lemma
-/
universe u
/-- A `EuclideanDomain` is a non-trivial commutative ring with a division and a remainder,
satisfying `b * (a / b) + a % b = a`.
The definition of a Euclidean domain usually includes a valuation function `R → ℕ`.
This definition is slightly generalised to include a well founded relation
`r` with the property that `r (a % b) b`, instead of a valuation. -/
class EuclideanDomain (R : Type u) extends CommRing R, Nontrivial R where
/-- A division function (denoted `/`) on `R`.
This satisfies the property `b * (a / b) + a % b = a`, where `%` denotes `remainder`. -/
protected quotient : R → R → R
/-- Division by zero should always give zero by convention. -/
protected quotient_zero : ∀ a, quotient a 0 = 0
/-- A remainder function (denoted `%`) on `R`.
This satisfies the property `b * (a / b) + a % b = a`, where `/` denotes `quotient`. -/
protected remainder : R → R → R
/-- The property that links the quotient and remainder functions.
This allows us to compute GCDs and LCMs. -/
protected quotient_mul_add_remainder_eq : ∀ a b, b * quotient a b + remainder a b = a
/-- A well-founded relation on `R`, satisfying `r (a % b) b`.
This ensures that the GCD algorithm always terminates. -/
protected r : R → R → Prop
/-- The relation `r` must be well-founded.
This ensures that the GCD algorithm always terminates. -/
r_wellFounded : WellFounded r
/-- The relation `r` satisfies `r (a % b) b`. -/
protected remainder_lt : ∀ (a) {b}, b ≠ 0 → r (remainder a b) b
/-- An additional constraint on `r`. -/
mul_left_not_lt : ∀ (a) {b}, b ≠ 0 → ¬r (a * b) a
namespace EuclideanDomain
variable {R : Type u} [EuclideanDomain R]
/-- Abbreviated notation for the well-founded relation `r` in a Euclidean domain. -/
local infixl:50 " ≺ " => EuclideanDomain.r
local instance wellFoundedRelation : WellFoundedRelation R where
rel := EuclideanDomain.r
wf := r_wellFounded
instance isWellFounded : IsWellFounded R (· ≺ ·) where
wf := r_wellFounded
-- see Note [lower instance priority]
instance (priority := 70) : Div R :=
⟨EuclideanDomain.quotient⟩
-- see Note [lower instance priority]
instance (priority := 70) : Mod R :=
⟨EuclideanDomain.remainder⟩
theorem div_add_mod (a b : R) : b * (a / b) + a % b = a :=
EuclideanDomain.quotient_mul_add_remainder_eq _ _
theorem mod_add_div (a b : R) : a % b + b * (a / b) = a :=
(add_comm _ _).trans (div_add_mod _ _)
theorem mod_add_div' (m k : R) : m % k + m / k * k = m := by
rw [mul_comm]
exact mod_add_div _ _
theorem div_add_mod' (m k : R) : m / k * k + m % k = m := by
rw [mul_comm]
exact div_add_mod _ _
theorem mod_lt : ∀ (a) {b : R}, b ≠ 0 → a % b ≺ b :=
EuclideanDomain.remainder_lt
| Mathlib/Algebra/EuclideanDomain/Defs.lean | 131 | 133 | theorem mul_right_not_lt {a : R} (b) (h : a ≠ 0) : ¬a * b ≺ b := by | rw [mul_comm]
exact mul_left_not_lt b h |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro
-/
import Mathlib.Algebra.MvPolynomial.Eval
/-!
# Renaming variables of polynomials
This file establishes the `rename` operation on multivariate polynomials,
which modifies the set of variables.
## Main declarations
* `MvPolynomial.rename`
* `MvPolynomial.renameEquiv`
## Notation
As in other polynomial files, we typically use the notation:
+ `σ τ α : Type*` (indexing the variables)
+ `R S : Type*` `[CommSemiring R]` `[CommSemiring S]` (the coefficients)
+ `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set.
This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s`
+ `r : R` elements of the coefficient ring
+ `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians
+ `p : MvPolynomial σ α`
-/
noncomputable section
open Set Function Finsupp AddMonoidAlgebra
variable {σ τ α R S : Type*} [CommSemiring R] [CommSemiring S]
namespace MvPolynomial
section Rename
/-- Rename all the variables in a multivariable polynomial. -/
def rename (f : σ → τ) : MvPolynomial σ R →ₐ[R] MvPolynomial τ R :=
aeval (X ∘ f)
theorem rename_C (f : σ → τ) (r : R) : rename f (C r) = C r :=
eval₂_C _ _ _
@[simp]
theorem rename_X (f : σ → τ) (i : σ) : rename f (X i : MvPolynomial σ R) = X (f i) :=
eval₂_X _ _ _
theorem map_rename (f : R →+* S) (g : σ → τ) (p : MvPolynomial σ R) :
map f (rename g p) = rename g (map f p) := by
apply MvPolynomial.induction_on p
(fun a => by simp only [map_C, rename_C])
(fun p q hp hq => by simp only [hp, hq, map_add]) fun p n hp => by
simp only [hp, rename_X, map_X, map_mul]
lemma map_comp_rename (f : R →+* S) (g : σ → τ) :
(map f).comp (rename g).toRingHom = (rename g).toRingHom.comp (map f) :=
RingHom.ext fun p ↦ map_rename f g p
@[simp]
theorem rename_rename (f : σ → τ) (g : τ → α) (p : MvPolynomial σ R) :
rename g (rename f p) = rename (g ∘ f) p :=
show rename g (eval₂ C (X ∘ f) p) = _ by
simp only [rename, aeval_eq_eval₂Hom]
-- Porting note: the Lean 3 proof of this was very fragile and included a nonterminal `simp`.
-- Hopefully this is less prone to breaking
rw [eval₂_comp_left (eval₂Hom (algebraMap R (MvPolynomial α R)) (X ∘ g)) C (X ∘ f) p]
simp only [comp_def, eval₂Hom_X']
refine eval₂Hom_congr ?_ rfl rfl
ext1; simp only [comp_apply, RingHom.coe_comp, eval₂Hom_C]
lemma rename_comp_rename (f : σ → τ) (g : τ → α) :
(rename (R := R) g).comp (rename f) = rename (g ∘ f) :=
AlgHom.ext fun p ↦ rename_rename f g p
@[simp]
theorem rename_id : rename id = AlgHom.id R (MvPolynomial σ R) :=
AlgHom.ext fun p ↦ eval₂_eta p
lemma rename_id_apply (p : MvPolynomial σ R) : rename id p = p := by
simp
theorem rename_monomial (f : σ → τ) (d : σ →₀ ℕ) (r : R) :
rename f (monomial d r) = monomial (d.mapDomain f) r := by
rw [rename, aeval_monomial, monomial_eq (s := Finsupp.mapDomain f d),
Finsupp.prod_mapDomain_index]
· rfl
· exact fun n => pow_zero _
· exact fun n i₁ i₂ => pow_add _ _ _
theorem rename_eq (f : σ → τ) (p : MvPolynomial σ R) :
rename f p = Finsupp.mapDomain (Finsupp.mapDomain f) p := by
simp only [rename, aeval_def, eval₂, Finsupp.mapDomain, algebraMap_eq, comp_apply,
X_pow_eq_monomial, ← monomial_finsupp_sum_index]
rfl
theorem rename_injective (f : σ → τ) (hf : Function.Injective f) :
Function.Injective (rename f : MvPolynomial σ R → MvPolynomial τ R) := by
have :
(rename f : MvPolynomial σ R → MvPolynomial τ R) = Finsupp.mapDomain (Finsupp.mapDomain f) :=
funext (rename_eq f)
rw [this]
exact Finsupp.mapDomain_injective (Finsupp.mapDomain_injective hf)
theorem rename_leftInverse {f : σ → τ} {g : τ → σ} (hf : Function.LeftInverse f g) :
Function.LeftInverse (rename f : MvPolynomial σ R → MvPolynomial τ R) (rename g) := by
intro x
simp [hf.comp_eq_id]
theorem rename_rightInverse {f : σ → τ} {g : τ → σ} (hf : Function.RightInverse f g) :
Function.RightInverse (rename f : MvPolynomial σ R → MvPolynomial τ R) (rename g) :=
rename_leftInverse hf
theorem rename_surjective (f : σ → τ) (hf : Function.Surjective f) :
Function.Surjective (rename f : MvPolynomial σ R → MvPolynomial τ R) :=
let ⟨_, hf⟩ := hf.hasRightInverse; rename_rightInverse hf |>.surjective
section
variable {f : σ → τ} (hf : Function.Injective f)
open Classical in
/-- Given a function between sets of variables `f : σ → τ` that is injective with proof `hf`,
`MvPolynomial.killCompl hf` is the `AlgHom` from `R[τ]` to `R[σ]` that is left inverse to
`rename f : R[σ] → R[τ]` and sends the variables in the complement of the range of `f` to `0`. -/
def killCompl : MvPolynomial τ R →ₐ[R] MvPolynomial σ R :=
aeval fun i => if h : i ∈ Set.range f then X <| (Equiv.ofInjective f hf).symm ⟨i, h⟩ else 0
theorem killCompl_C (r : R) : killCompl hf (C r) = C r := algHom_C _ _
theorem killCompl_comp_rename : (killCompl hf).comp (rename f) = AlgHom.id R _ :=
algHom_ext fun i => by
dsimp
rw [rename, killCompl, aeval_X, comp_apply, aeval_X, dif_pos, Equiv.ofInjective_symm_apply]
@[simp]
theorem killCompl_rename_app (p : MvPolynomial σ R) : killCompl hf (rename f p) = p :=
AlgHom.congr_fun (killCompl_comp_rename hf) p
end
section
variable (R)
/-- `MvPolynomial.rename e` is an equivalence when `e` is. -/
@[simps apply]
def renameEquiv (f : σ ≃ τ) : MvPolynomial σ R ≃ₐ[R] MvPolynomial τ R :=
{ rename f with
toFun := rename f
invFun := rename f.symm
left_inv := fun p => by rw [rename_rename, f.symm_comp_self, rename_id_apply]
right_inv := fun p => by rw [rename_rename, f.self_comp_symm, rename_id_apply] }
@[simp]
theorem renameEquiv_refl : renameEquiv R (Equiv.refl σ) = AlgEquiv.refl :=
AlgEquiv.ext (by simp)
@[simp]
theorem renameEquiv_symm (f : σ ≃ τ) : (renameEquiv R f).symm = renameEquiv R f.symm :=
rfl
@[simp]
theorem renameEquiv_trans (e : σ ≃ τ) (f : τ ≃ α) :
(renameEquiv R e).trans (renameEquiv R f) = renameEquiv R (e.trans f) :=
AlgEquiv.ext (rename_rename e f)
end
section
variable (f : R →+* S) (k : σ → τ) (g : τ → S) (p : MvPolynomial σ R)
theorem eval₂_rename : (rename k p).eval₂ f g = p.eval₂ f (g ∘ k) := by
apply MvPolynomial.induction_on p <;>
· intros
simp [*]
theorem eval_rename (g : τ → R) (p : MvPolynomial σ R) : eval g (rename k p) = eval (g ∘ k) p :=
eval₂_rename _ _ _ _
theorem eval₂Hom_rename : eval₂Hom f g (rename k p) = eval₂Hom f (g ∘ k) p :=
eval₂_rename _ _ _ _
theorem aeval_rename [Algebra R S] : aeval g (rename k p) = aeval (g ∘ k) p :=
eval₂Hom_rename _ _ _ _
lemma aeval_comp_rename [Algebra R S] :
(aeval (R := R) g).comp (rename k) = MvPolynomial.aeval (g ∘ k) :=
AlgHom.ext fun p ↦ aeval_rename k g p
theorem rename_eval₂ (g : τ → MvPolynomial σ R) :
rename k (p.eval₂ C (g ∘ k)) = (rename k p).eval₂ C (rename k ∘ g) := by
apply MvPolynomial.induction_on p <;>
· intros
simp [*]
theorem rename_prod_mk_eval₂ (j : τ) (g : σ → MvPolynomial σ R) :
rename (Prod.mk j) (p.eval₂ C g) = p.eval₂ C fun x => rename (Prod.mk j) (g x) := by
apply MvPolynomial.induction_on p <;>
· intros
simp [*]
theorem eval₂_rename_prod_mk (g : σ × τ → S) (i : σ) (p : MvPolynomial τ R) :
(rename (Prod.mk i) p).eval₂ f g = eval₂ f (fun j => g (i, j)) p := by
apply MvPolynomial.induction_on p <;>
· intros
simp [*]
theorem eval_rename_prod_mk (g : σ × τ → R) (i : σ) (p : MvPolynomial τ R) :
eval g (rename (Prod.mk i) p) = eval (fun j => g (i, j)) p :=
eval₂_rename_prod_mk (RingHom.id _) _ _ _
end
/-- Every polynomial is a polynomial in finitely many variables. -/
theorem exists_finset_rename (p : MvPolynomial σ R) :
∃ (s : Finset σ) (q : MvPolynomial { x // x ∈ s } R), p = rename (↑) q := by
classical
apply induction_on p
· intro r
exact ⟨∅, C r, by rw [rename_C]⟩
· rintro p q ⟨s, p, rfl⟩ ⟨t, q, rfl⟩
refine ⟨s ∪ t, ⟨?_, ?_⟩⟩
· refine rename (Subtype.map id ?_) p + rename (Subtype.map id ?_) q <;>
simp +contextual only [id, true_or, or_true,
Finset.mem_union, forall_true_iff]
· simp only [rename_rename, map_add]
rfl
· rintro p n ⟨s, p, rfl⟩
refine ⟨insert n s, ⟨?_, ?_⟩⟩
· refine rename (Subtype.map id ?_) p * X ⟨n, s.mem_insert_self n⟩
simp +contextual only [id, or_true, Finset.mem_insert, forall_true_iff]
· simp only [rename_rename, rename_X, Subtype.coe_mk, map_mul]
rfl
/-- `exists_finset_rename` for two polynomials at once: for any two polynomials `p₁`, `p₂` in a
polynomial semiring `R[σ]` of possibly infinitely many variables, `exists_finset_rename₂` yields
a finite subset `s` of `σ` such that both `p₁` and `p₂` are contained in the polynomial semiring
`R[s]` of finitely many variables. -/
theorem exists_finset_rename₂ (p₁ p₂ : MvPolynomial σ R) :
∃ (s : Finset σ) (q₁ q₂ : MvPolynomial s R), p₁ = rename (↑) q₁ ∧ p₂ = rename (↑) q₂ := by
obtain ⟨s₁, q₁, rfl⟩ := exists_finset_rename p₁
obtain ⟨s₂, q₂, rfl⟩ := exists_finset_rename p₂
classical
use s₁ ∪ s₂
use rename (Set.inclusion s₁.subset_union_left) q₁
use rename (Set.inclusion s₁.subset_union_right) q₂
constructor <;> simp [Function.comp_def]
/-- Every polynomial is a polynomial in finitely many variables. -/
theorem exists_fin_rename (p : MvPolynomial σ R) :
∃ (n : ℕ) (f : Fin n → σ) (_hf : Injective f) (q : MvPolynomial (Fin n) R), p = rename f q := by
obtain ⟨s, q, rfl⟩ := exists_finset_rename p
let n := Fintype.card { x // x ∈ s }
let e := Fintype.equivFin { x // x ∈ s }
refine ⟨n, (↑) ∘ e.symm, Subtype.val_injective.comp e.symm.injective, rename e q, ?_⟩
rw [← rename_rename, rename_rename e]
simp only [Function.comp_def, Equiv.symm_apply_apply, rename_rename]
end Rename
theorem eval₂_cast_comp (f : σ → τ) (c : ℤ →+* R) (g : τ → R) (p : MvPolynomial σ ℤ) :
eval₂ c (g ∘ f) p = eval₂ c g (rename f p) := by
apply MvPolynomial.induction_on p (fun n => by simp only [eval₂_C, rename_C])
(fun p q hp hq => by simp only [hp, hq, rename, eval₂_add, map_add])
fun p n hp => by simp only [eval₂_mul, hp, eval₂_X, comp_apply, map_mul, rename_X, eval₂_mul]
section Coeff
@[simp]
theorem coeff_rename_mapDomain (f : σ → τ) (hf : Injective f) (φ : MvPolynomial σ R) (d : σ →₀ ℕ) :
(rename f φ).coeff (d.mapDomain f) = φ.coeff d := by
classical
apply φ.induction_on' (P := fun ψ => coeff (Finsupp.mapDomain f d) ((rename f) ψ) = coeff d ψ)
-- Lean could no longer infer the motive
· intro u r
rw [rename_monomial, coeff_monomial, coeff_monomial]
simp only [(Finsupp.mapDomain_injective hf).eq_iff]
· intros
simp only [*, map_add, coeff_add]
@[simp]
theorem coeff_rename_embDomain (f : σ ↪ τ) (φ : MvPolynomial σ R) (d : σ →₀ ℕ) :
(rename f φ).coeff (d.embDomain f) = φ.coeff d := by
rw [Finsupp.embDomain_eq_mapDomain f, coeff_rename_mapDomain f f.injective]
theorem coeff_rename_eq_zero (f : σ → τ) (φ : MvPolynomial σ R) (d : τ →₀ ℕ)
(h : ∀ u : σ →₀ ℕ, u.mapDomain f = d → φ.coeff u = 0) : (rename f φ).coeff d = 0 := by
classical
rw [rename_eq, ← not_mem_support_iff]
intro H
replace H := mapDomain_support H
rw [Finset.mem_image] at H
obtain ⟨u, hu, rfl⟩ := H
specialize h u rfl
simp? at h hu says simp only [Finsupp.mem_support_iff, ne_eq] at h hu
contradiction
| Mathlib/Algebra/MvPolynomial/Rename.lean | 311 | 321 | theorem coeff_rename_ne_zero (f : σ → τ) (φ : MvPolynomial σ R) (d : τ →₀ ℕ)
(h : (rename f φ).coeff d ≠ 0) : ∃ u : σ →₀ ℕ, u.mapDomain f = d ∧ φ.coeff u ≠ 0 := by | contrapose! h
apply coeff_rename_eq_zero _ _ _ h
@[simp]
theorem constantCoeff_rename {τ : Type*} (f : σ → τ) (φ : MvPolynomial σ R) :
constantCoeff (rename f φ) = constantCoeff φ := by
apply φ.induction_on
· intro a
simp only [constantCoeff_C, rename_C] |
/-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Floris van Doorn
-/
import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Analysis.Normed.Module.FiniteDimension
/-!
# Higher differentiability in finite dimensions.
-/
noncomputable section
universe uD uE uF
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{D : Type uD} [NormedAddCommGroup D] [NormedSpace 𝕜 D]
{E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{n : WithTop ℕ∞} {f : D → E} {s : Set D}
/-! ### Finite dimensional results -/
section FiniteDimensional
open Function Module
open scoped ContDiff
variable [CompleteSpace 𝕜]
/-- A family of continuous linear maps is `C^n` on `s` if all its applications are. -/
theorem contDiffOn_clm_apply {f : D → E →L[𝕜] F} {s : Set D} [FiniteDimensional 𝕜 E] :
ContDiffOn 𝕜 n f s ↔ ∀ y, ContDiffOn 𝕜 n (fun x => f x y) s := by
refine ⟨fun h y => h.clm_apply contDiffOn_const, fun h => ?_⟩
let d := finrank 𝕜 E
have hd : d = finrank 𝕜 (Fin d → 𝕜) := (finrank_fin_fun 𝕜).symm
let e₁ := ContinuousLinearEquiv.ofFinrankEq hd
let e₂ := (e₁.arrowCongr (1 : F ≃L[𝕜] F)).trans (ContinuousLinearEquiv.piRing (Fin d))
rw [← id_comp f, ← e₂.symm_comp_self]
exact e₂.symm.contDiff.comp_contDiffOn (contDiffOn_pi.mpr fun i => h _)
theorem contDiff_clm_apply_iff {f : D → E →L[𝕜] F} [FiniteDimensional 𝕜 E] :
ContDiff 𝕜 n f ↔ ∀ y, ContDiff 𝕜 n fun x => f x y := by
simp_rw [← contDiffOn_univ, contDiffOn_clm_apply]
/-- This is a useful lemma to prove that a certain operation preserves functions being `C^n`.
When you do induction on `n`, this gives a useful characterization of a function being `C^(n+1)`,
assuming you have already computed the derivative. The advantage of this version over
`contDiff_succ_iff_fderiv` is that both occurrences of `ContDiff` are for functions with the same
domain and codomain (`D` and `E`). This is not the case for `contDiff_succ_iff_fderiv`, which
often requires an inconvenient need to generalize `F`, which results in universe issues
(see the discussion in the section of `ContDiff.comp`).
This lemma avoids these universe issues, but only applies for finite dimensional `D`. -/
| Mathlib/Analysis/Calculus/ContDiff/FiniteDimension.lean | 60 | 62 | theorem contDiff_succ_iff_fderiv_apply [FiniteDimensional 𝕜 D] :
ContDiff 𝕜 (n + 1) f ↔ Differentiable 𝕜 f ∧
(n = ω → AnalyticOnNhd 𝕜 f Set.univ) ∧ ∀ y, ContDiff 𝕜 n fun x => fderiv 𝕜 f x y := by | |
/-
Copyright (c) 2022 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker
-/
import Mathlib.Topology.UniformSpace.UniformConvergenceTopology
/-!
# Equicontinuity of a family of functions
Let `X` be a topological space and `α` a `UniformSpace`. A family of functions `F : ι → X → α`
is said to be *equicontinuous at a point `x₀ : X`* when, for any entourage `U` in `α`, there is a
neighborhood `V` of `x₀` such that, for all `x ∈ V`, and *for all `i`*, `F i x` is `U`-close to
`F i x₀`. In other words, one has `∀ U ∈ 𝓤 α, ∀ᶠ x in 𝓝 x₀, ∀ i, (F i x₀, F i x) ∈ U`.
For maps between metric spaces, this corresponds to
`∀ ε > 0, ∃ δ > 0, ∀ x, ∀ i, dist x₀ x < δ → dist (F i x₀) (F i x) < ε`.
`F` is said to be *equicontinuous* if it is equicontinuous at each point.
A closely related concept is that of ***uniform*** *equicontinuity* of a family of functions
`F : ι → β → α` between uniform spaces, which means that, for any entourage `U` in `α`, there is an
entourage `V` in `β` such that, if `x` and `y` are `V`-close, then *for all `i`*, `F i x` and
`F i y` are `U`-close. In other words, one has
`∀ U ∈ 𝓤 α, ∀ᶠ xy in 𝓤 β, ∀ i, (F i xy.1, F i xy.2) ∈ U`.
For maps between metric spaces, this corresponds to
`∀ ε > 0, ∃ δ > 0, ∀ x y, ∀ i, dist x y < δ → dist (F i x₀) (F i x) < ε`.
## Main definitions
* `EquicontinuousAt`: equicontinuity of a family of functions at a point
* `Equicontinuous`: equicontinuity of a family of functions on the whole domain
* `UniformEquicontinuous`: uniform equicontinuity of a family of functions on the whole domain
We also introduce relative versions, namely `EquicontinuousWithinAt`, `EquicontinuousOn` and
`UniformEquicontinuousOn`, akin to `ContinuousWithinAt`, `ContinuousOn` and `UniformContinuousOn`
respectively.
## Main statements
* `equicontinuous_iff_continuous`: equicontinuity can be expressed as a simple continuity
condition between well-chosen function spaces. This is really useful for building up the theory.
* `Equicontinuous.closure`: if a set of functions is equicontinuous, its closure
*for the topology of pointwise convergence* is also equicontinuous.
## Notations
Throughout this file, we use :
- `ι`, `κ` for indexing types
- `X`, `Y`, `Z` for topological spaces
- `α`, `β`, `γ` for uniform spaces
## Implementation details
We choose to express equicontinuity as a properties of indexed families of functions rather
than sets of functions for the following reasons:
- it is really easy to express equicontinuity of `H : Set (X → α)` using our setup: it is just
equicontinuity of the family `(↑) : ↥H → (X → α)`. On the other hand, going the other way around
would require working with the range of the family, which is always annoying because it
introduces useless existentials.
- in most applications, one doesn't work with bare functions but with a more specific hom type
`hom`. Equicontinuity of a set `H : Set hom` would then have to be expressed as equicontinuity
of `coe_fn '' H`, which is super annoying to work with. This is much simpler with families,
because equicontinuity of a family `𝓕 : ι → hom` would simply be expressed as equicontinuity
of `coe_fn ∘ 𝓕`, which doesn't introduce any nasty existentials.
To simplify statements, we do provide abbreviations `Set.EquicontinuousAt`, `Set.Equicontinuous`
and `Set.UniformEquicontinuous` asserting the corresponding fact about the family
`(↑) : ↥H → (X → α)` where `H : Set (X → α)`. Note however that these won't work for sets of hom
types, and in that case one should go back to the family definition rather than using `Set.image`.
## References
* [N. Bourbaki, *General Topology, Chapter X*][bourbaki1966]
## Tags
equicontinuity, uniform convergence, ascoli
-/
section
open UniformSpace Filter Set Uniformity Topology UniformConvergence Function
variable {ι κ X X' Y α α' β β' γ : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y]
[uα : UniformSpace α] [uβ : UniformSpace β] [uγ : UniformSpace γ]
/-- A family `F : ι → X → α` of functions from a topological space to a uniform space is
*equicontinuous at `x₀ : X`* if, for all entourages `U ∈ 𝓤 α`, there is a neighborhood `V` of `x₀`
such that, for all `x ∈ V` and for all `i : ι`, `F i x` is `U`-close to `F i x₀`. -/
def EquicontinuousAt (F : ι → X → α) (x₀ : X) : Prop :=
∀ U ∈ 𝓤 α, ∀ᶠ x in 𝓝 x₀, ∀ i, (F i x₀, F i x) ∈ U
/-- We say that a set `H : Set (X → α)` of functions is equicontinuous at a point if the family
`(↑) : ↥H → (X → α)` is equicontinuous at that point. -/
protected abbrev Set.EquicontinuousAt (H : Set <| X → α) (x₀ : X) : Prop :=
EquicontinuousAt ((↑) : H → X → α) x₀
/-- A family `F : ι → X → α` of functions from a topological space to a uniform space is
*equicontinuous at `x₀ : X` within `S : Set X`* if, for all entourages `U ∈ 𝓤 α`, there is a
neighborhood `V` of `x₀` within `S` such that, for all `x ∈ V` and for all `i : ι`, `F i x` is
`U`-close to `F i x₀`. -/
def EquicontinuousWithinAt (F : ι → X → α) (S : Set X) (x₀ : X) : Prop :=
∀ U ∈ 𝓤 α, ∀ᶠ x in 𝓝[S] x₀, ∀ i, (F i x₀, F i x) ∈ U
/-- We say that a set `H : Set (X → α)` of functions is equicontinuous at a point within a subset
if the family `(↑) : ↥H → (X → α)` is equicontinuous at that point within that same subset. -/
protected abbrev Set.EquicontinuousWithinAt (H : Set <| X → α) (S : Set X) (x₀ : X) : Prop :=
EquicontinuousWithinAt ((↑) : H → X → α) S x₀
/-- A family `F : ι → X → α` of functions from a topological space to a uniform space is
*equicontinuous* on all of `X` if it is equicontinuous at each point of `X`. -/
def Equicontinuous (F : ι → X → α) : Prop :=
∀ x₀, EquicontinuousAt F x₀
/-- We say that a set `H : Set (X → α)` of functions is equicontinuous if the family
`(↑) : ↥H → (X → α)` is equicontinuous. -/
protected abbrev Set.Equicontinuous (H : Set <| X → α) : Prop :=
Equicontinuous ((↑) : H → X → α)
/-- A family `F : ι → X → α` of functions from a topological space to a uniform space is
*equicontinuous on `S : Set X`* if it is equicontinuous *within `S`* at each point of `S`. -/
def EquicontinuousOn (F : ι → X → α) (S : Set X) : Prop :=
∀ x₀ ∈ S, EquicontinuousWithinAt F S x₀
/-- We say that a set `H : Set (X → α)` of functions is equicontinuous on a subset if the family
`(↑) : ↥H → (X → α)` is equicontinuous on that subset. -/
protected abbrev Set.EquicontinuousOn (H : Set <| X → α) (S : Set X) : Prop :=
EquicontinuousOn ((↑) : H → X → α) S
/-- A family `F : ι → β → α` of functions between uniform spaces is *uniformly equicontinuous* if,
for all entourages `U ∈ 𝓤 α`, there is an entourage `V ∈ 𝓤 β` such that, whenever `x` and `y` are
`V`-close, we have that, *for all `i : ι`*, `F i x` is `U`-close to `F i y`. -/
def UniformEquicontinuous (F : ι → β → α) : Prop :=
∀ U ∈ 𝓤 α, ∀ᶠ xy : β × β in 𝓤 β, ∀ i, (F i xy.1, F i xy.2) ∈ U
/-- We say that a set `H : Set (X → α)` of functions is uniformly equicontinuous if the family
`(↑) : ↥H → (X → α)` is uniformly equicontinuous. -/
protected abbrev Set.UniformEquicontinuous (H : Set <| β → α) : Prop :=
UniformEquicontinuous ((↑) : H → β → α)
/-- A family `F : ι → β → α` of functions between uniform spaces is
*uniformly equicontinuous on `S : Set β`* if, for all entourages `U ∈ 𝓤 α`, there is a relative
entourage `V ∈ 𝓤 β ⊓ 𝓟 (S ×ˢ S)` such that, whenever `x` and `y` are `V`-close, we have that,
*for all `i : ι`*, `F i x` is `U`-close to `F i y`. -/
def UniformEquicontinuousOn (F : ι → β → α) (S : Set β) : Prop :=
∀ U ∈ 𝓤 α, ∀ᶠ xy : β × β in 𝓤 β ⊓ 𝓟 (S ×ˢ S), ∀ i, (F i xy.1, F i xy.2) ∈ U
/-- We say that a set `H : Set (X → α)` of functions is uniformly equicontinuous on a subset if the
family `(↑) : ↥H → (X → α)` is uniformly equicontinuous on that subset. -/
protected abbrev Set.UniformEquicontinuousOn (H : Set <| β → α) (S : Set β) : Prop :=
UniformEquicontinuousOn ((↑) : H → β → α) S
lemma EquicontinuousAt.equicontinuousWithinAt {F : ι → X → α} {x₀ : X} (H : EquicontinuousAt F x₀)
(S : Set X) : EquicontinuousWithinAt F S x₀ :=
fun U hU ↦ (H U hU).filter_mono inf_le_left
lemma EquicontinuousWithinAt.mono {F : ι → X → α} {x₀ : X} {S T : Set X}
(H : EquicontinuousWithinAt F T x₀) (hST : S ⊆ T) : EquicontinuousWithinAt F S x₀ :=
fun U hU ↦ (H U hU).filter_mono <| nhdsWithin_mono x₀ hST
@[simp] lemma equicontinuousWithinAt_univ (F : ι → X → α) (x₀ : X) :
EquicontinuousWithinAt F univ x₀ ↔ EquicontinuousAt F x₀ := by
rw [EquicontinuousWithinAt, EquicontinuousAt, nhdsWithin_univ]
lemma equicontinuousAt_restrict_iff (F : ι → X → α) {S : Set X} (x₀ : S) :
EquicontinuousAt (S.restrict ∘ F) x₀ ↔ EquicontinuousWithinAt F S x₀ := by
simp [EquicontinuousWithinAt, EquicontinuousAt,
← eventually_nhds_subtype_iff]
lemma Equicontinuous.equicontinuousOn {F : ι → X → α} (H : Equicontinuous F)
(S : Set X) : EquicontinuousOn F S :=
fun x _ ↦ (H x).equicontinuousWithinAt S
lemma EquicontinuousOn.mono {F : ι → X → α} {S T : Set X}
(H : EquicontinuousOn F T) (hST : S ⊆ T) : EquicontinuousOn F S :=
fun x hx ↦ (H x (hST hx)).mono hST
lemma equicontinuousOn_univ (F : ι → X → α) :
EquicontinuousOn F univ ↔ Equicontinuous F := by
simp [EquicontinuousOn, Equicontinuous]
lemma equicontinuous_restrict_iff (F : ι → X → α) {S : Set X} :
Equicontinuous (S.restrict ∘ F) ↔ EquicontinuousOn F S := by
simp [Equicontinuous, EquicontinuousOn, equicontinuousAt_restrict_iff]
lemma UniformEquicontinuous.uniformEquicontinuousOn {F : ι → β → α} (H : UniformEquicontinuous F)
(S : Set β) : UniformEquicontinuousOn F S :=
fun U hU ↦ (H U hU).filter_mono inf_le_left
lemma UniformEquicontinuousOn.mono {F : ι → β → α} {S T : Set β}
(H : UniformEquicontinuousOn F T) (hST : S ⊆ T) : UniformEquicontinuousOn F S :=
fun U hU ↦ (H U hU).filter_mono <| by gcongr
lemma uniformEquicontinuousOn_univ (F : ι → β → α) :
UniformEquicontinuousOn F univ ↔ UniformEquicontinuous F := by
simp [UniformEquicontinuousOn, UniformEquicontinuous]
lemma uniformEquicontinuous_restrict_iff (F : ι → β → α) {S : Set β} :
UniformEquicontinuous (S.restrict ∘ F) ↔ UniformEquicontinuousOn F S := by
rw [UniformEquicontinuous, UniformEquicontinuousOn]
conv in _ ⊓ _ => rw [← Subtype.range_val (s := S), ← range_prodMap, ← map_comap]
rfl
/-!
### Empty index type
-/
@[simp]
lemma equicontinuousAt_empty [h : IsEmpty ι] (F : ι → X → α) (x₀ : X) :
EquicontinuousAt F x₀ :=
fun _ _ ↦ Eventually.of_forall (fun _ ↦ h.elim)
@[simp]
lemma equicontinuousWithinAt_empty [h : IsEmpty ι] (F : ι → X → α) (S : Set X) (x₀ : X) :
EquicontinuousWithinAt F S x₀ :=
fun _ _ ↦ Eventually.of_forall (fun _ ↦ h.elim)
@[simp]
lemma equicontinuous_empty [IsEmpty ι] (F : ι → X → α) :
Equicontinuous F :=
equicontinuousAt_empty F
@[simp]
lemma equicontinuousOn_empty [IsEmpty ι] (F : ι → X → α) (S : Set X) :
EquicontinuousOn F S :=
fun x₀ _ ↦ equicontinuousWithinAt_empty F S x₀
@[simp]
lemma uniformEquicontinuous_empty [h : IsEmpty ι] (F : ι → β → α) :
UniformEquicontinuous F :=
fun _ _ ↦ Eventually.of_forall (fun _ ↦ h.elim)
@[simp]
lemma uniformEquicontinuousOn_empty [h : IsEmpty ι] (F : ι → β → α) (S : Set β) :
UniformEquicontinuousOn F S :=
fun _ _ ↦ Eventually.of_forall (fun _ ↦ h.elim)
/-!
### Finite index type
-/
theorem equicontinuousAt_finite [Finite ι] {F : ι → X → α} {x₀ : X} :
EquicontinuousAt F x₀ ↔ ∀ i, ContinuousAt (F i) x₀ := by
simp [EquicontinuousAt, ContinuousAt, (nhds_basis_uniformity' (𝓤 α).basis_sets).tendsto_right_iff,
UniformSpace.ball, @forall_swap _ ι]
theorem equicontinuousWithinAt_finite [Finite ι] {F : ι → X → α} {S : Set X} {x₀ : X} :
EquicontinuousWithinAt F S x₀ ↔ ∀ i, ContinuousWithinAt (F i) S x₀ := by
simp [EquicontinuousWithinAt, ContinuousWithinAt,
(nhds_basis_uniformity' (𝓤 α).basis_sets).tendsto_right_iff, UniformSpace.ball,
@forall_swap _ ι]
theorem equicontinuous_finite [Finite ι] {F : ι → X → α} :
Equicontinuous F ↔ ∀ i, Continuous (F i) := by
simp only [Equicontinuous, equicontinuousAt_finite, continuous_iff_continuousAt, @forall_swap ι]
theorem equicontinuousOn_finite [Finite ι] {F : ι → X → α} {S : Set X} :
EquicontinuousOn F S ↔ ∀ i, ContinuousOn (F i) S := by
simp only [EquicontinuousOn, equicontinuousWithinAt_finite, ContinuousOn, @forall_swap ι]
theorem uniformEquicontinuous_finite [Finite ι] {F : ι → β → α} :
UniformEquicontinuous F ↔ ∀ i, UniformContinuous (F i) := by
simp only [UniformEquicontinuous, eventually_all, @forall_swap _ ι]; rfl
| Mathlib/Topology/UniformSpace/Equicontinuity.lean | 266 | 268 | theorem uniformEquicontinuousOn_finite [Finite ι] {F : ι → β → α} {S : Set β} :
UniformEquicontinuousOn F S ↔ ∀ i, UniformContinuousOn (F i) S := by | simp only [UniformEquicontinuousOn, eventually_all, @forall_swap _ ι]; rfl |
/-
Copyright (c) 2018 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis
-/
import Mathlib.RingTheory.Valuation.Basic
import Mathlib.NumberTheory.Padics.PadicNorm
import Mathlib.Analysis.Normed.Field.Lemmas
import Mathlib.Tactic.Peel
import Mathlib.Topology.MetricSpace.Ultra.Basic
/-!
# p-adic numbers
This file defines the `p`-adic numbers (rationals) `ℚ_[p]` as
the completion of `ℚ` with respect to the `p`-adic norm.
We show that the `p`-adic norm on `ℚ` extends to `ℚ_[p]`, that `ℚ` is embedded in `ℚ_[p]`,
and that `ℚ_[p]` is Cauchy complete.
## Important definitions
* `Padic` : the type of `p`-adic numbers
* `padicNormE` : the rational valued `p`-adic norm on `ℚ_[p]`
* `Padic.addValuation` : the additive `p`-adic valuation on `ℚ_[p]`, with values in `WithTop ℤ`
## Notation
We introduce the notation `ℚ_[p]` for the `p`-adic numbers.
## Implementation notes
Much, but not all, of this file assumes that `p` is prime. This assumption is inferred automatically
by taking `[Fact p.Prime]` as a type class argument.
We use the same concrete Cauchy sequence construction that is used to construct `ℝ`.
`ℚ_[p]` inherits a field structure from this construction.
The extension of the norm on `ℚ` to `ℚ_[p]` is *not* analogous to extending the absolute value to
`ℝ` and hence the proof that `ℚ_[p]` is complete is different from the proof that ℝ is complete.
`padicNormE` is the rational-valued `p`-adic norm on `ℚ_[p]`.
To instantiate `ℚ_[p]` as a normed field, we must cast this into an `ℝ`-valued norm.
The `ℝ`-valued norm, using notation `‖ ‖` from normed spaces,
is the canonical representation of this norm.
`simp` prefers `padicNorm` to `padicNormE` when possible.
Since `padicNormE` and `‖ ‖` have different types, `simp` does not rewrite one to the other.
Coercions from `ℚ` to `ℚ_[p]` are set up to work with the `norm_cast` tactic.
## References
* [F. Q. Gouvêa, *p-adic numbers*][gouvea1997]
* [R. Y. Lewis, *A formal proof of Hensel's lemma over the p-adic integers*][lewis2019]
* <https://en.wikipedia.org/wiki/P-adic_number>
## Tags
p-adic, p adic, padic, norm, valuation, cauchy, completion, p-adic completion
-/
noncomputable section
open Nat padicNorm CauSeq CauSeq.Completion Metric
/-- The type of Cauchy sequences of rationals with respect to the `p`-adic norm. -/
abbrev PadicSeq (p : ℕ) :=
CauSeq _ (padicNorm p)
namespace PadicSeq
section
variable {p : ℕ} [Fact p.Prime]
/-- The `p`-adic norm of the entries of a nonzero Cauchy sequence of rationals is eventually
constant. -/
theorem stationary {f : CauSeq ℚ (padicNorm p)} (hf : ¬f ≈ 0) :
∃ N, ∀ m n, N ≤ m → N ≤ n → padicNorm p (f n) = padicNorm p (f m) :=
have : ∃ ε > 0, ∃ N1, ∀ j ≥ N1, ε ≤ padicNorm p (f j) :=
CauSeq.abv_pos_of_not_limZero <| not_limZero_of_not_congr_zero hf
let ⟨ε, hε, N1, hN1⟩ := this
let ⟨N2, hN2⟩ := CauSeq.cauchy₂ f hε
⟨max N1 N2, fun n m hn hm ↦ by
have : padicNorm p (f n - f m) < ε := hN2 _ (max_le_iff.1 hn).2 _ (max_le_iff.1 hm).2
have : padicNorm p (f n - f m) < padicNorm p (f n) :=
lt_of_lt_of_le this <| hN1 _ (max_le_iff.1 hn).1
have : padicNorm p (f n - f m) < max (padicNorm p (f n)) (padicNorm p (f m)) :=
lt_max_iff.2 (Or.inl this)
by_contra hne
rw [← padicNorm.neg (f m)] at hne
have hnam := add_eq_max_of_ne hne
rw [padicNorm.neg, max_comm] at hnam
rw [← hnam, sub_eq_add_neg, add_comm] at this
apply _root_.lt_irrefl _ this⟩
/-- For all `n ≥ stationaryPoint f hf`, the `p`-adic norm of `f n` is the same. -/
def stationaryPoint {f : PadicSeq p} (hf : ¬f ≈ 0) : ℕ :=
Classical.choose <| stationary hf
theorem stationaryPoint_spec {f : PadicSeq p} (hf : ¬f ≈ 0) :
∀ {m n},
stationaryPoint hf ≤ m → stationaryPoint hf ≤ n → padicNorm p (f n) = padicNorm p (f m) :=
@(Classical.choose_spec <| stationary hf)
open Classical in
/-- Since the norm of the entries of a Cauchy sequence is eventually stationary,
we can lift the norm to sequences. -/
def norm (f : PadicSeq p) : ℚ :=
if hf : f ≈ 0 then 0 else padicNorm p (f (stationaryPoint hf))
theorem norm_zero_iff (f : PadicSeq p) : f.norm = 0 ↔ f ≈ 0 := by
constructor
· intro h
by_contra hf
unfold norm at h
split_ifs at h
apply hf
intro ε hε
exists stationaryPoint hf
intro j hj
have heq := stationaryPoint_spec hf le_rfl hj
simpa [h, heq]
· intro h
simp [norm, h]
end
section Embedding
open CauSeq
variable {p : ℕ} [Fact p.Prime]
theorem equiv_zero_of_val_eq_of_equiv_zero {f g : PadicSeq p}
(h : ∀ k, padicNorm p (f k) = padicNorm p (g k)) (hf : f ≈ 0) : g ≈ 0 := fun ε hε ↦
let ⟨i, hi⟩ := hf _ hε
⟨i, fun j hj ↦ by simpa [h] using hi _ hj⟩
theorem norm_nonzero_of_not_equiv_zero {f : PadicSeq p} (hf : ¬f ≈ 0) : f.norm ≠ 0 :=
hf ∘ f.norm_zero_iff.1
theorem norm_eq_norm_app_of_nonzero {f : PadicSeq p} (hf : ¬f ≈ 0) :
∃ k, f.norm = padicNorm p k ∧ k ≠ 0 :=
have heq : f.norm = padicNorm p (f <| stationaryPoint hf) := by simp [norm, hf]
⟨f <| stationaryPoint hf, heq, fun h ↦
norm_nonzero_of_not_equiv_zero hf (by simpa [h] using heq)⟩
theorem not_limZero_const_of_nonzero {q : ℚ} (hq : q ≠ 0) : ¬LimZero (const (padicNorm p) q) :=
fun h' ↦ hq <| const_limZero.1 h'
theorem not_equiv_zero_const_of_nonzero {q : ℚ} (hq : q ≠ 0) : ¬const (padicNorm p) q ≈ 0 :=
fun h : LimZero (const (padicNorm p) q - 0) ↦
not_limZero_const_of_nonzero (p := p) hq <| by simpa using h
theorem norm_nonneg (f : PadicSeq p) : 0 ≤ f.norm := by
classical exact if hf : f ≈ 0 then by simp [hf, norm] else by simp [norm, hf, padicNorm.nonneg]
/-- An auxiliary lemma for manipulating sequence indices. -/
theorem lift_index_left_left {f : PadicSeq p} (hf : ¬f ≈ 0) (v2 v3 : ℕ) :
padicNorm p (f (stationaryPoint hf)) =
padicNorm p (f (max (stationaryPoint hf) (max v2 v3))) := by
apply stationaryPoint_spec hf
· apply le_max_left
· exact le_rfl
/-- An auxiliary lemma for manipulating sequence indices. -/
theorem lift_index_left {f : PadicSeq p} (hf : ¬f ≈ 0) (v1 v3 : ℕ) :
padicNorm p (f (stationaryPoint hf)) =
padicNorm p (f (max v1 (max (stationaryPoint hf) v3))) := by
apply stationaryPoint_spec hf
· apply le_trans
· apply le_max_left _ v3
· apply le_max_right
· exact le_rfl
/-- An auxiliary lemma for manipulating sequence indices. -/
theorem lift_index_right {f : PadicSeq p} (hf : ¬f ≈ 0) (v1 v2 : ℕ) :
padicNorm p (f (stationaryPoint hf)) =
padicNorm p (f (max v1 (max v2 (stationaryPoint hf)))) := by
apply stationaryPoint_spec hf
· apply le_trans
· apply le_max_right v2
· apply le_max_right
· exact le_rfl
end Embedding
section Valuation
open CauSeq
variable {p : ℕ} [Fact p.Prime]
/-! ### Valuation on `PadicSeq` -/
open Classical in
/-- The `p`-adic valuation on `ℚ` lifts to `PadicSeq p`.
`Valuation f` is defined to be the valuation of the (`ℚ`-valued) stationary point of `f`. -/
def valuation (f : PadicSeq p) : ℤ :=
if hf : f ≈ 0 then 0 else padicValRat p (f (stationaryPoint hf))
theorem norm_eq_zpow_neg_valuation {f : PadicSeq p} (hf : ¬f ≈ 0) :
f.norm = (p : ℚ) ^ (-f.valuation : ℤ) := by
rw [norm, valuation, dif_neg hf, dif_neg hf, padicNorm, if_neg]
intro H
apply CauSeq.not_limZero_of_not_congr_zero hf
intro ε hε
use stationaryPoint hf
intro n hn
rw [stationaryPoint_spec hf le_rfl hn]
simpa [H] using hε
@[deprecated (since := "2024-12-10")] alias norm_eq_pow_val := norm_eq_zpow_neg_valuation
theorem val_eq_iff_norm_eq {f g : PadicSeq p} (hf : ¬f ≈ 0) (hg : ¬g ≈ 0) :
f.valuation = g.valuation ↔ f.norm = g.norm := by
rw [norm_eq_zpow_neg_valuation hf, norm_eq_zpow_neg_valuation hg, ← neg_inj, zpow_right_inj₀]
· exact mod_cast (Fact.out : p.Prime).pos
· exact mod_cast (Fact.out : p.Prime).ne_one
end Valuation
end PadicSeq
section
open PadicSeq
-- Porting note: Commented out `padic_index_simp` tactic
/-
private unsafe def index_simp_core (hh hf hg : expr)
(at_ : Interactive.Loc := Interactive.Loc.ns [none]) : tactic Unit := do
let [v1, v2, v3] ← [hh, hf, hg].mapM fun n => tactic.mk_app `` stationary_point [n] <|> return n
let e1 ← tactic.mk_app `` lift_index_left_left [hh, v2, v3] <|> return q(True)
let e2 ← tactic.mk_app `` lift_index_left [hf, v1, v3] <|> return q(True)
let e3 ← tactic.mk_app `` lift_index_right [hg, v1, v2] <|> return q(True)
let sl ← [e1, e2, e3].foldlM (fun s e => simp_lemmas.add s e) simp_lemmas.mk
when at_ (tactic.simp_target sl >> tactic.skip)
let hs ← at_.get_locals
hs (tactic.simp_hyp sl [])
/-- This is a special-purpose tactic that lifts `padicNorm (f (stationary_point f))` to
`padicNorm (f (max _ _ _))`. -/
unsafe def tactic.interactive.padic_index_simp (l : interactive.parse interactive.types.pexpr_list)
(at_ : interactive.parse interactive.types.location) : tactic Unit := do
let [h, f, g] ← l.mapM tactic.i_to_expr
index_simp_core h f g at_
-/
end
namespace PadicSeq
section Embedding
open CauSeq
variable {p : ℕ} [hp : Fact p.Prime]
theorem norm_mul (f g : PadicSeq p) : (f * g).norm = f.norm * g.norm := by
classical
exact if hf : f ≈ 0 then by
have hg : f * g ≈ 0 := mul_equiv_zero' _ hf
simp only [hf, hg, norm, dif_pos, zero_mul]
else
if hg : g ≈ 0 then by
have hf : f * g ≈ 0 := mul_equiv_zero _ hg
simp only [hf, hg, norm, dif_pos, mul_zero]
else by
unfold norm
have hfg := mul_not_equiv_zero hf hg
simp only [hfg, hf, hg, dite_false]
-- Porting note: originally `padic_index_simp [hfg, hf, hg]`
rw [lift_index_left_left hfg, lift_index_left hf, lift_index_right hg]
apply padicNorm.mul
theorem eq_zero_iff_equiv_zero (f : PadicSeq p) : mk f = 0 ↔ f ≈ 0 :=
mk_eq
theorem ne_zero_iff_nequiv_zero (f : PadicSeq p) : mk f ≠ 0 ↔ ¬f ≈ 0 :=
eq_zero_iff_equiv_zero _ |>.not
theorem norm_const (q : ℚ) : norm (const (padicNorm p) q) = padicNorm p q := by
obtain rfl | hq := eq_or_ne q 0
· simp [norm]
· simp [norm, not_equiv_zero_const_of_nonzero hq]
theorem norm_values_discrete (a : PadicSeq p) (ha : ¬a ≈ 0) : ∃ z : ℤ, a.norm = (p : ℚ) ^ (-z) := by
let ⟨k, hk, hk'⟩ := norm_eq_norm_app_of_nonzero ha
simpa [hk] using padicNorm.values_discrete hk'
theorem norm_one : norm (1 : PadicSeq p) = 1 := by
have h1 : ¬(1 : PadicSeq p) ≈ 0 := one_not_equiv_zero _
simp [h1, norm, hp.1.one_lt]
private theorem norm_eq_of_equiv_aux {f g : PadicSeq p} (hf : ¬f ≈ 0) (hg : ¬g ≈ 0) (hfg : f ≈ g)
(h : padicNorm p (f (stationaryPoint hf)) ≠ padicNorm p (g (stationaryPoint hg)))
(hlt : padicNorm p (g (stationaryPoint hg)) < padicNorm p (f (stationaryPoint hf))) :
False := by
have hpn : 0 < padicNorm p (f (stationaryPoint hf)) - padicNorm p (g (stationaryPoint hg)) :=
sub_pos_of_lt hlt
obtain ⟨N, hN⟩ := hfg _ hpn
let i := max N (max (stationaryPoint hf) (stationaryPoint hg))
have hi : N ≤ i := le_max_left _ _
have hN' := hN _ hi
-- Porting note: originally `padic_index_simp [N, hf, hg] at hN' h hlt`
rw [lift_index_left hf N (stationaryPoint hg), lift_index_right hg N (stationaryPoint hf)]
at hN' h hlt
have hpne : padicNorm p (f i) ≠ padicNorm p (-g i) := by rwa [← padicNorm.neg (g i)] at h
rw [CauSeq.sub_apply, sub_eq_add_neg, add_eq_max_of_ne hpne, padicNorm.neg, max_eq_left_of_lt hlt]
at hN'
have : padicNorm p (f i) < padicNorm p (f i) := by
apply lt_of_lt_of_le hN'
apply sub_le_self
apply padicNorm.nonneg
exact lt_irrefl _ this
private theorem norm_eq_of_equiv {f g : PadicSeq p} (hf : ¬f ≈ 0) (hg : ¬g ≈ 0) (hfg : f ≈ g) :
padicNorm p (f (stationaryPoint hf)) = padicNorm p (g (stationaryPoint hg)) := by
by_contra h
cases lt_or_le (padicNorm p (g (stationaryPoint hg))) (padicNorm p (f (stationaryPoint hf))) with
| inl hlt =>
exact norm_eq_of_equiv_aux hf hg hfg h hlt
| inr hle =>
apply norm_eq_of_equiv_aux hg hf (Setoid.symm hfg) (Ne.symm h)
exact lt_of_le_of_ne hle h
theorem norm_equiv {f g : PadicSeq p} (hfg : f ≈ g) : f.norm = g.norm := by
classical
exact if hf : f ≈ 0 then by
have hg : g ≈ 0 := Setoid.trans (Setoid.symm hfg) hf
simp [norm, hf, hg]
else by
have hg : ¬g ≈ 0 := hf ∘ Setoid.trans hfg
unfold norm; split_ifs; exact norm_eq_of_equiv hf hg hfg
private theorem norm_nonarchimedean_aux {f g : PadicSeq p} (hfg : ¬f + g ≈ 0) (hf : ¬f ≈ 0)
(hg : ¬g ≈ 0) : (f + g).norm ≤ max f.norm g.norm := by
unfold norm; split_ifs
-- Porting note: originally `padic_index_simp [hfg, hf, hg]`
rw [lift_index_left_left hfg, lift_index_left hf, lift_index_right hg]
apply padicNorm.nonarchimedean
theorem norm_nonarchimedean (f g : PadicSeq p) : (f + g).norm ≤ max f.norm g.norm := by
classical
exact if hfg : f + g ≈ 0 then by
have : 0 ≤ max f.norm g.norm := le_max_of_le_left (norm_nonneg _)
simpa only [hfg, norm]
else
if hf : f ≈ 0 then by
have hfg' : f + g ≈ g := by
change LimZero (f - 0) at hf
show LimZero (f + g - g); · simpa only [sub_zero, add_sub_cancel_right] using hf
have hcfg : (f + g).norm = g.norm := norm_equiv hfg'
have hcl : f.norm = 0 := (norm_zero_iff f).2 hf
have : max f.norm g.norm = g.norm := by rw [hcl]; exact max_eq_right (norm_nonneg _)
rw [this, hcfg]
else
if hg : g ≈ 0 then by
have hfg' : f + g ≈ f := by
change LimZero (g - 0) at hg
show LimZero (f + g - f); · simpa only [add_sub_cancel_left, sub_zero] using hg
have hcfg : (f + g).norm = f.norm := norm_equiv hfg'
have hcl : g.norm = 0 := (norm_zero_iff g).2 hg
have : max f.norm g.norm = f.norm := by rw [hcl]; exact max_eq_left (norm_nonneg _)
rw [this, hcfg]
else norm_nonarchimedean_aux hfg hf hg
theorem norm_eq {f g : PadicSeq p} (h : ∀ k, padicNorm p (f k) = padicNorm p (g k)) :
f.norm = g.norm := by
classical
exact if hf : f ≈ 0 then by
have hg : g ≈ 0 := equiv_zero_of_val_eq_of_equiv_zero h hf
simp only [hf, hg, norm, dif_pos]
else by
have hg : ¬g ≈ 0 := fun hg ↦
hf <| equiv_zero_of_val_eq_of_equiv_zero (by simp only [h, forall_const, eq_self_iff_true]) hg
simp only [hg, hf, norm, dif_neg, not_false_iff]
let i := max (stationaryPoint hf) (stationaryPoint hg)
have hpf : padicNorm p (f (stationaryPoint hf)) = padicNorm p (f i) := by
apply stationaryPoint_spec
· apply le_max_left
· exact le_rfl
have hpg : padicNorm p (g (stationaryPoint hg)) = padicNorm p (g i) := by
apply stationaryPoint_spec
· apply le_max_right
· exact le_rfl
rw [hpf, hpg, h]
theorem norm_neg (a : PadicSeq p) : (-a).norm = a.norm :=
norm_eq <| by simp
theorem norm_eq_of_add_equiv_zero {f g : PadicSeq p} (h : f + g ≈ 0) : f.norm = g.norm := by
have : LimZero (f + g - 0) := h
have : f ≈ -g := show LimZero (f - -g) by simpa only [sub_zero, sub_neg_eq_add]
have : f.norm = (-g).norm := norm_equiv this
simpa only [norm_neg] using this
theorem add_eq_max_of_ne {f g : PadicSeq p} (hfgne : f.norm ≠ g.norm) :
(f + g).norm = max f.norm g.norm := by
classical
have hfg : ¬f + g ≈ 0 := mt norm_eq_of_add_equiv_zero hfgne
exact if hf : f ≈ 0 then by
have : LimZero (f - 0) := hf
have : f + g ≈ g := show LimZero (f + g - g) by simpa only [sub_zero, add_sub_cancel_right]
have h1 : (f + g).norm = g.norm := norm_equiv this
have h2 : f.norm = 0 := (norm_zero_iff _).2 hf
rw [h1, h2, max_eq_right (norm_nonneg _)]
else
if hg : g ≈ 0 then by
have : LimZero (g - 0) := hg
have : f + g ≈ f := show LimZero (f + g - f) by simpa only [add_sub_cancel_left, sub_zero]
have h1 : (f + g).norm = f.norm := norm_equiv this
have h2 : g.norm = 0 := (norm_zero_iff _).2 hg
rw [h1, h2, max_eq_left (norm_nonneg _)]
else by
unfold norm at hfgne ⊢; split_ifs at hfgne ⊢
-- Porting note: originally `padic_index_simp [hfg, hf, hg] at hfgne ⊢`
rw [lift_index_left hf, lift_index_right hg] at hfgne
· rw [lift_index_left_left hfg, lift_index_left hf, lift_index_right hg]
exact padicNorm.add_eq_max_of_ne hfgne
end Embedding
end PadicSeq
/-- The `p`-adic numbers `ℚ_[p]` are the Cauchy completion of `ℚ` with respect to the `p`-adic norm.
-/
def Padic (p : ℕ) [Fact p.Prime] :=
CauSeq.Completion.Cauchy (padicNorm p)
/-- notation for p-padic rationals -/
notation "ℚ_[" p "]" => Padic p
namespace Padic
section Completion
variable {p : ℕ} [Fact p.Prime]
instance field : Field ℚ_[p] :=
Cauchy.field
instance : Inhabited ℚ_[p] :=
⟨0⟩
-- short circuits
instance : CommRing ℚ_[p] :=
Cauchy.commRing
instance : Ring ℚ_[p] :=
Cauchy.ring
instance : Zero ℚ_[p] := by infer_instance
instance : One ℚ_[p] := by infer_instance
instance : Add ℚ_[p] := by infer_instance
instance : Mul ℚ_[p] := by infer_instance
instance : Sub ℚ_[p] := by infer_instance
instance : Neg ℚ_[p] := by infer_instance
instance : Div ℚ_[p] := by infer_instance
instance : AddCommGroup ℚ_[p] := by infer_instance
/-- Builds the equivalence class of a Cauchy sequence of rationals. -/
def mk : PadicSeq p → ℚ_[p] :=
Quotient.mk'
variable (p)
theorem zero_def : (0 : ℚ_[p]) = ⟦0⟧ := rfl
theorem mk_eq {f g : PadicSeq p} : mk f = mk g ↔ f ≈ g :=
Quotient.eq'
theorem const_equiv {q r : ℚ} : const (padicNorm p) q ≈ const (padicNorm p) r ↔ q = r :=
⟨fun heq ↦ eq_of_sub_eq_zero <| const_limZero.1 heq, fun heq ↦ by
rw [heq]⟩
@[norm_cast]
theorem coe_inj {q r : ℚ} : (↑q : ℚ_[p]) = ↑r ↔ q = r :=
⟨(const_equiv p).1 ∘ Quotient.eq'.1, fun h ↦ by rw [h]⟩
instance : CharZero ℚ_[p] :=
⟨fun m n ↦ by
rw [← Rat.cast_natCast]
norm_cast
exact id⟩
@[norm_cast]
theorem coe_add : ∀ {x y : ℚ}, (↑(x + y) : ℚ_[p]) = ↑x + ↑y :=
Rat.cast_add _ _
@[norm_cast]
theorem coe_neg : ∀ {x : ℚ}, (↑(-x) : ℚ_[p]) = -↑x :=
Rat.cast_neg _
@[norm_cast]
theorem coe_mul : ∀ {x y : ℚ}, (↑(x * y) : ℚ_[p]) = ↑x * ↑y :=
Rat.cast_mul _ _
@[norm_cast]
theorem coe_sub : ∀ {x y : ℚ}, (↑(x - y) : ℚ_[p]) = ↑x - ↑y :=
Rat.cast_sub _ _
@[norm_cast]
theorem coe_div : ∀ {x y : ℚ}, (↑(x / y) : ℚ_[p]) = ↑x / ↑y :=
Rat.cast_div _ _
@[norm_cast]
theorem coe_one : (↑(1 : ℚ) : ℚ_[p]) = 1 := rfl
@[norm_cast]
theorem coe_zero : (↑(0 : ℚ) : ℚ_[p]) = 0 := rfl
end Completion
end Padic
/-- The rational-valued `p`-adic norm on `ℚ_[p]` is lifted from the norm on Cauchy sequences. The
canonical form of this function is the normed space instance, with notation `‖ ‖`. -/
def padicNormE {p : ℕ} [hp : Fact p.Prime] : AbsoluteValue ℚ_[p] ℚ where
toFun := Quotient.lift PadicSeq.norm <| @PadicSeq.norm_equiv _ _
map_mul' q r := Quotient.inductionOn₂ q r <| PadicSeq.norm_mul
nonneg' q := Quotient.inductionOn q <| PadicSeq.norm_nonneg
eq_zero' q := Quotient.inductionOn q fun r ↦ by
rw [Padic.zero_def, Quotient.eq]
exact PadicSeq.norm_zero_iff r
add_le' q r := by
trans
max ((Quotient.lift PadicSeq.norm <| @PadicSeq.norm_equiv _ _) q)
((Quotient.lift PadicSeq.norm <| @PadicSeq.norm_equiv _ _) r)
· exact Quotient.inductionOn₂ q r <| PadicSeq.norm_nonarchimedean
refine max_le_add_of_nonneg (Quotient.inductionOn q <| PadicSeq.norm_nonneg) ?_
exact Quotient.inductionOn r <| PadicSeq.norm_nonneg
namespace padicNormE
section Embedding
open PadicSeq
variable {p : ℕ} [Fact p.Prime]
theorem defn (f : PadicSeq p) {ε : ℚ} (hε : 0 < ε) :
∃ N, ∀ i ≥ N, padicNormE (Padic.mk f - f i : ℚ_[p]) < ε := by
dsimp [padicNormE]
-- `change ∃ N, ∀ i ≥ N, (f - const _ (f i)).norm < ε` also works, but is very slow
suffices hyp : ∃ N, ∀ i ≥ N, (f - const _ (f i)).norm < ε by peel hyp with N; use N
by_contra! h
obtain ⟨N, hN⟩ := cauchy₂ f hε
rcases h N with ⟨i, hi, hge⟩
have hne : ¬f - const (padicNorm p) (f i) ≈ 0 := fun h ↦ by
rw [PadicSeq.norm, dif_pos h] at hge
exact not_lt_of_ge hge hε
unfold PadicSeq.norm at hge; split_ifs at hge
apply not_le_of_gt _ hge
cases _root_.le_total N (stationaryPoint hne) with
| inl hgen =>
exact hN _ hgen _ hi
| inr hngen =>
have := stationaryPoint_spec hne le_rfl hngen
rw [← this]
exact hN _ le_rfl _ hi
/-- Theorems about `padicNormE` are named with a `'` so the names do not conflict with the
equivalent theorems about `norm` (`‖ ‖`). -/
theorem nonarchimedean' (q r : ℚ_[p]) :
padicNormE (q + r : ℚ_[p]) ≤ max (padicNormE q) (padicNormE r) :=
Quotient.inductionOn₂ q r <| norm_nonarchimedean
/-- Theorems about `padicNormE` are named with a `'` so the names do not conflict with the
equivalent theorems about `norm` (`‖ ‖`). -/
theorem add_eq_max_of_ne' {q r : ℚ_[p]} :
padicNormE q ≠ padicNormE r → padicNormE (q + r : ℚ_[p]) = max (padicNormE q) (padicNormE r) :=
Quotient.inductionOn₂ q r fun _ _ ↦ PadicSeq.add_eq_max_of_ne
@[simp]
theorem eq_padic_norm' (q : ℚ) : padicNormE (q : ℚ_[p]) = padicNorm p q :=
norm_const _
protected theorem image' {q : ℚ_[p]} : q ≠ 0 → ∃ n : ℤ, padicNormE q = (p : ℚ) ^ (-n) :=
Quotient.inductionOn q fun f hf ↦
have : ¬f ≈ 0 := (ne_zero_iff_nequiv_zero f).1 hf
norm_values_discrete f this
end Embedding
end padicNormE
namespace Padic
section Complete
open PadicSeq Padic
variable {p : ℕ} [Fact p.Prime] (f : CauSeq _ (@padicNormE p _))
theorem rat_dense' (q : ℚ_[p]) {ε : ℚ} (hε : 0 < ε) : ∃ r : ℚ, padicNormE (q - r : ℚ_[p]) < ε :=
Quotient.inductionOn q fun q' ↦
have : ∃ N, ∀ m ≥ N, ∀ n ≥ N, padicNorm p (q' m - q' n) < ε := cauchy₂ _ hε
let ⟨N, hN⟩ := this
⟨q' N, by
classical
dsimp [padicNormE]
-- Porting note: this used to be `change`, but that times out.
convert_to PadicSeq.norm (q' - const _ (q' N)) < ε
rcases Decidable.em (q' - const (padicNorm p) (q' N) ≈ 0) with heq | hne'
· simpa only [heq, PadicSeq.norm, dif_pos]
· simp only [PadicSeq.norm, dif_neg hne']
change padicNorm p (q' _ - q' _) < ε
rcases Decidable.em (stationaryPoint hne' ≤ N) with hle | hle
· have := (stationaryPoint_spec hne' le_rfl hle).symm
simp only [const_apply, sub_apply, padicNorm.zero, sub_self] at this
simpa only [this]
· exact hN _ (lt_of_not_ge hle).le _ le_rfl⟩
private theorem div_nat_pos (n : ℕ) : 0 < 1 / (n + 1 : ℚ) :=
div_pos zero_lt_one (mod_cast succ_pos _)
/-- `limSeq f`, for `f` a Cauchy sequence of `p`-adic numbers, is a sequence of rationals with the
same limit point as `f`. -/
def limSeq : ℕ → ℚ :=
fun n ↦ Classical.choose (rat_dense' (f n) (div_nat_pos n))
theorem exi_rat_seq_conv {ε : ℚ} (hε : 0 < ε) :
∃ N, ∀ i ≥ N, padicNormE (f i - (limSeq f i : ℚ_[p]) : ℚ_[p]) < ε := by
refine (exists_nat_gt (1 / ε)).imp fun N hN i hi ↦ ?_
have h := Classical.choose_spec (rat_dense' (f i) (div_nat_pos i))
refine lt_of_lt_of_le h ((div_le_iff₀' <| mod_cast succ_pos _).mpr ?_)
rw [right_distrib]
apply le_add_of_le_of_nonneg
· exact (div_le_iff₀ hε).mp (le_trans (le_of_lt hN) (mod_cast hi))
· apply le_of_lt
simpa
theorem exi_rat_seq_conv_cauchy : IsCauSeq (padicNorm p) (limSeq f) := fun ε hε ↦ by
have hε3 : 0 < ε / 3 := div_pos hε (by norm_num)
let ⟨N, hN⟩ := exi_rat_seq_conv f hε3
let ⟨N2, hN2⟩ := f.cauchy₂ hε3
exists max N N2
intro j hj
suffices
padicNormE (limSeq f j - f (max N N2) + (f (max N N2) - limSeq f (max N N2)) : ℚ_[p]) < ε by
ring_nf at this ⊢
rw [← padicNormE.eq_padic_norm']
exact mod_cast this
apply lt_of_le_of_lt
· apply padicNormE.add_le
· rw [← add_thirds ε]
apply _root_.add_lt_add
· suffices padicNormE (limSeq f j - f j + (f j - f (max N N2)) : ℚ_[p]) < ε / 3 + ε / 3 by
simpa only [sub_add_sub_cancel]
apply lt_of_le_of_lt
· apply padicNormE.add_le
· apply _root_.add_lt_add
· rw [padicNormE.map_sub]
apply mod_cast hN j
exact le_of_max_le_left hj
· exact hN2 _ (le_of_max_le_right hj) _ (le_max_right _ _)
· apply mod_cast hN (max N N2)
apply le_max_left
private def lim' : PadicSeq p :=
⟨_, exi_rat_seq_conv_cauchy f⟩
private def lim : ℚ_[p] :=
⟦lim' f⟧
theorem complete' : ∃ q : ℚ_[p], ∀ ε > 0, ∃ N, ∀ i ≥ N, padicNormE (q - f i : ℚ_[p]) < ε :=
⟨lim f, fun ε hε ↦ by
obtain ⟨N, hN⟩ := exi_rat_seq_conv f (half_pos hε)
obtain ⟨N2, hN2⟩ := padicNormE.defn (lim' f) (half_pos hε)
refine ⟨max N N2, fun i hi ↦ ?_⟩
rw [← sub_add_sub_cancel _ (lim' f i : ℚ_[p]) _]
refine (padicNormE.add_le _ _).trans_lt ?_
rw [← add_halves ε]
apply _root_.add_lt_add
· apply hN2 _ (le_of_max_le_right hi)
· rw [padicNormE.map_sub]
exact hN _ (le_of_max_le_left hi)⟩
| Mathlib/NumberTheory/Padics/PadicNumbers.lean | 688 | 697 | theorem complete'' : ∃ q : ℚ_[p], ∀ ε > 0, ∃ N, ∀ i ≥ N, padicNormE (f i - q : ℚ_[p]) < ε := by | obtain ⟨x, hx⟩ := complete' f
refine ⟨x, fun ε hε => ?_⟩
obtain ⟨N, hN⟩ := hx ε hε
refine ⟨N, fun i hi => ?_⟩
rw [padicNormE.map_sub]
exact hN i hi
end Complete
section NormedSpace |
/-
Copyright (c) 2019 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov, Patrick Massot
-/
import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
import Mathlib.MeasureTheory.Measure.Real
import Mathlib.Order.Filter.IndicatorFunction
/-!
# The dominated convergence theorem
This file collects various results related to the Lebesgue dominated convergence theorem
for the Bochner integral.
## Main results
- `MeasureTheory.tendsto_integral_of_dominated_convergence`:
the Lebesgue dominated convergence theorem for the Bochner integral
- `MeasureTheory.hasSum_integral_of_dominated_convergence`:
the Lebesgue dominated convergence theorem for series
- `MeasureTheory.integral_tsum`, `MeasureTheory.integral_tsum_of_summable_integral_norm`:
the integral and `tsum`s commute, if the norms of the functions form a summable series
- `intervalIntegral.hasSum_integral_of_dominated_convergence`: the Lebesgue dominated convergence
theorem for parametric interval integrals
- `intervalIntegral.continuous_of_dominated_interval`: continuity of the interval integral
w.r.t. a parameter
- `intervalIntegral.continuous_primitive` and friends: primitives of interval integrable
measurable functions are continuous
-/
open MeasureTheory Metric
/-!
## The Lebesgue dominated convergence theorem for the Bochner integral
-/
section DominatedConvergenceTheorem
open Set Filter TopologicalSpace ENNReal
open scoped Topology Interval
namespace MeasureTheory
variable {α E G : Type*}
[NormedAddCommGroup E] [NormedSpace ℝ E]
[NormedAddCommGroup G] [NormedSpace ℝ G]
{m : MeasurableSpace α} {μ : Measure α}
/-- **Lebesgue dominated convergence theorem** provides sufficient conditions under which almost
everywhere convergence of a sequence of functions implies the convergence of their integrals.
We could weaken the condition `bound_integrable` to require `HasFiniteIntegral bound μ` instead
(i.e. not requiring that `bound` is measurable), but in all applications proving integrability
is easier. -/
theorem tendsto_integral_of_dominated_convergence {F : ℕ → α → G} {f : α → G} (bound : α → ℝ)
(F_measurable : ∀ n, AEStronglyMeasurable (F n) μ) (bound_integrable : Integrable bound μ)
(h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a)
(h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) :
Tendsto (fun n => ∫ a, F n a ∂μ) atTop (𝓝 <| ∫ a, f a ∂μ) := by
by_cases hG : CompleteSpace G
· simp only [integral, hG, L1.integral]
exact tendsto_setToFun_of_dominated_convergence (dominatedFinMeasAdditive_weightedSMul μ)
bound F_measurable bound_integrable h_bound h_lim
· simp [integral, hG]
/-- Lebesgue dominated convergence theorem for filters with a countable basis -/
theorem tendsto_integral_filter_of_dominated_convergence {ι} {l : Filter ι} [l.IsCountablyGenerated]
{F : ι → α → G} {f : α → G} (bound : α → ℝ) (hF_meas : ∀ᶠ n in l, AEStronglyMeasurable (F n) μ)
(h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (bound_integrable : Integrable bound μ)
(h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) l (𝓝 (f a))) :
Tendsto (fun n => ∫ a, F n a ∂μ) l (𝓝 <| ∫ a, f a ∂μ) := by
by_cases hG : CompleteSpace G
· simp only [integral, hG, L1.integral]
exact tendsto_setToFun_filter_of_dominated_convergence (dominatedFinMeasAdditive_weightedSMul μ)
bound hF_meas h_bound bound_integrable h_lim
· simp [integral, hG, tendsto_const_nhds]
/-- Lebesgue dominated convergence theorem for series. -/
theorem hasSum_integral_of_dominated_convergence {ι} [Countable ι] {F : ι → α → G} {f : α → G}
(bound : ι → α → ℝ) (hF_meas : ∀ n, AEStronglyMeasurable (F n) μ)
(h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound n a)
(bound_summable : ∀ᵐ a ∂μ, Summable fun n => bound n a)
(bound_integrable : Integrable (fun a => ∑' n, bound n a) μ)
(h_lim : ∀ᵐ a ∂μ, HasSum (fun n => F n a) (f a)) :
HasSum (fun n => ∫ a, F n a ∂μ) (∫ a, f a ∂μ) := by
have hb_nonneg : ∀ᵐ a ∂μ, ∀ n, 0 ≤ bound n a :=
eventually_countable_forall.2 fun n => (h_bound n).mono fun a => (norm_nonneg _).trans
have hb_le_tsum : ∀ n, bound n ≤ᵐ[μ] fun a => ∑' n, bound n a := by
intro n
filter_upwards [hb_nonneg, bound_summable]
with _ ha0 ha_sum using ha_sum.le_tsum _ fun i _ => ha0 i
have hF_integrable : ∀ n, Integrable (F n) μ := by
refine fun n => bound_integrable.mono' (hF_meas n) ?_
exact EventuallyLE.trans (h_bound n) (hb_le_tsum n)
simp only [HasSum, ← integral_finset_sum _ fun n _ => hF_integrable n]
refine tendsto_integral_filter_of_dominated_convergence
(fun a => ∑' n, bound n a) ?_ ?_ bound_integrable h_lim
· exact Eventually.of_forall fun s => s.aestronglyMeasurable_sum fun n _ => hF_meas n
· filter_upwards with s
filter_upwards [eventually_countable_forall.2 h_bound, hb_nonneg, bound_summable]
with a hFa ha0 has
calc
‖∑ n ∈ s, F n a‖ ≤ ∑ n ∈ s, bound n a := norm_sum_le_of_le _ fun n _ => hFa n
_ ≤ ∑' n, bound n a := has.sum_le_tsum _ (fun n _ => ha0 n)
theorem integral_tsum {ι} [Countable ι] {f : ι → α → G} (hf : ∀ i, AEStronglyMeasurable (f i) μ)
(hf' : ∑' i, ∫⁻ a : α, ‖f i a‖ₑ ∂μ ≠ ∞) :
∫ a : α, ∑' i, f i a ∂μ = ∑' i, ∫ a : α, f i a ∂μ := by
by_cases hG : CompleteSpace G; swap
· simp [integral, hG]
have hf'' i : AEMeasurable (‖f i ·‖ₑ) μ := (hf i).enorm
have hhh : ∀ᵐ a : α ∂μ, Summable fun n => (‖f n a‖₊ : ℝ) := by
rw [← lintegral_tsum hf''] at hf'
refine (ae_lt_top' (AEMeasurable.ennreal_tsum hf'') hf').mono ?_
intro x hx
rw [← ENNReal.tsum_coe_ne_top_iff_summable_coe]
exact hx.ne
convert (MeasureTheory.hasSum_integral_of_dominated_convergence (fun i a => ‖f i a‖₊) hf _ hhh
⟨_, _⟩ _).tsum_eq.symm
· intro n
filter_upwards with x
rfl
· simp_rw [← NNReal.coe_tsum]
rw [aestronglyMeasurable_iff_aemeasurable]
apply AEMeasurable.coe_nnreal_real
apply AEMeasurable.nnreal_tsum
exact fun i => (hf i).nnnorm.aemeasurable
· dsimp [HasFiniteIntegral]
have : ∫⁻ a, ∑' n, ‖f n a‖ₑ ∂μ < ⊤ := by rwa [lintegral_tsum hf'', lt_top_iff_ne_top]
convert this using 1
apply lintegral_congr_ae
simp_rw [← coe_nnnorm, ← NNReal.coe_tsum, enorm_eq_nnnorm, NNReal.nnnorm_eq]
filter_upwards [hhh] with a ha
exact ENNReal.coe_tsum (NNReal.summable_coe.mp ha)
· filter_upwards [hhh] with x hx
exact hx.of_norm.hasSum
lemma hasSum_integral_of_summable_integral_norm {ι} [Countable ι] {F : ι → α → E}
(hF_int : ∀ i : ι, Integrable (F i) μ) (hF_sum : Summable fun i ↦ ∫ a, ‖F i a‖ ∂μ) :
HasSum (∫ a, F · a ∂μ) (∫ a, (∑' i, F i a) ∂μ) := by
by_cases hE : CompleteSpace E; swap
· simp [integral, hE, hasSum_zero]
rw [integral_tsum (fun i ↦ (hF_int i).1)]
· exact (hF_sum.of_norm_bounded _ fun i ↦ norm_integral_le_integral_norm _).hasSum
have (i : ι) : ∫⁻ a, ‖F i a‖ₑ ∂μ = ‖∫ a, ‖F i a‖ ∂μ‖ₑ := by
dsimp [enorm]
rw [lintegral_coe_eq_integral _ (hF_int i).norm, coe_nnreal_eq, coe_nnnorm,
Real.norm_of_nonneg (integral_nonneg (fun a ↦ norm_nonneg (F i a)))]
simp only [coe_nnnorm]
rw [funext this]
exact ENNReal.tsum_coe_ne_top_iff_summable.2 <| NNReal.summable_coe.1 hF_sum.abs
lemma integral_tsum_of_summable_integral_norm {ι} [Countable ι] {F : ι → α → E}
(hF_int : ∀ i : ι, Integrable (F i) μ) (hF_sum : Summable fun i ↦ ∫ a, ‖F i a‖ ∂μ) :
∑' i, (∫ a, F i a ∂μ) = ∫ a, (∑' i, F i a) ∂μ :=
(hasSum_integral_of_summable_integral_norm hF_int hF_sum).tsum_eq
/-- Corollary of the Lebesgue dominated convergence theorem: If a sequence of functions `F n` is
(eventually) uniformly bounded by a constant and converges (eventually) pointwise to a
function `f`, then the integrals of `F n` with respect to a finite measure `μ` converge
to the integral of `f`. -/
theorem tendsto_integral_filter_of_norm_le_const {ι} {l : Filter ι} [l.IsCountablyGenerated]
{F : ι → α → G} [IsFiniteMeasure μ] {f : α → G}
(h_meas : ∀ᶠ n in l, AEStronglyMeasurable (F n) μ)
(h_bound : ∃ C, ∀ᶠ n in l, (∀ᵐ ω ∂μ, ‖F n ω‖ ≤ C))
(h_lim : ∀ᵐ ω ∂μ, Tendsto (fun n => F n ω) l (𝓝 (f ω))) :
Tendsto (fun n => ∫ ω, F n ω ∂μ) l (nhds (∫ ω, f ω ∂μ)) := by
obtain ⟨c, h_boundc⟩ := h_bound
let C : α → ℝ := (fun _ => c)
exact tendsto_integral_filter_of_dominated_convergence
C h_meas h_boundc (integrable_const c) h_lim
end MeasureTheory
section TendstoMono
variable {α E : Type*} [MeasurableSpace α]
{μ : Measure α} [NormedAddCommGroup E] [NormedSpace ℝ E] {s : ℕ → Set α}
{f : α → E}
theorem _root_.Antitone.tendsto_setIntegral (hsm : ∀ i, MeasurableSet (s i)) (h_anti : Antitone s)
(hfi : IntegrableOn f (s 0) μ) :
Tendsto (fun i => ∫ a in s i, f a ∂μ) atTop (𝓝 (∫ a in ⋂ n, s n, f a ∂μ)) := by
let bound : α → ℝ := indicator (s 0) fun a => ‖f a‖
have h_int_eq : (fun i => ∫ a in s i, f a ∂μ) = fun i => ∫ a, (s i).indicator f a ∂μ :=
funext fun i => (integral_indicator (hsm i)).symm
rw [h_int_eq]
rw [← integral_indicator (MeasurableSet.iInter hsm)]
refine tendsto_integral_of_dominated_convergence bound ?_ ?_ ?_ ?_
· intro n
rw [aestronglyMeasurable_indicator_iff (hsm n)]
exact (IntegrableOn.mono_set hfi (h_anti (zero_le n))).1
· rw [integrable_indicator_iff (hsm 0)]
exact hfi.norm
· simp_rw [norm_indicator_eq_indicator_norm]
refine fun n => Eventually.of_forall fun x => ?_
exact indicator_le_indicator_of_subset (h_anti (zero_le n)) (fun a => norm_nonneg _) _
· filter_upwards [] with a using le_trans (h_anti.tendsto_indicator _ _ _) (pure_le_nhds _)
end TendstoMono
/-!
## The Lebesgue dominated convergence theorem for interval integrals
As an application, we show continuity of parametric integrals.
-/
namespace intervalIntegral
section DCT
variable {ι E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
{a b : ℝ} {f : ℝ → E} {μ : Measure ℝ}
/-- Lebesgue dominated convergence theorem for filters with a countable basis -/
nonrec theorem tendsto_integral_filter_of_dominated_convergence {ι} {l : Filter ι}
[l.IsCountablyGenerated] {F : ι → ℝ → E} (bound : ℝ → ℝ)
(hF_meas : ∀ᶠ n in l, AEStronglyMeasurable (F n) (μ.restrict (Ι a b)))
(h_bound : ∀ᶠ n in l, ∀ᵐ x ∂μ, x ∈ Ι a b → ‖F n x‖ ≤ bound x)
(bound_integrable : IntervalIntegrable bound μ a b)
(h_lim : ∀ᵐ x ∂μ, x ∈ Ι a b → Tendsto (fun n => F n x) l (𝓝 (f x))) :
Tendsto (fun n => ∫ x in a..b, F n x ∂μ) l (𝓝 <| ∫ x in a..b, f x ∂μ) := by
simp only [intervalIntegrable_iff, intervalIntegral_eq_integral_uIoc,
← ae_restrict_iff' (α := ℝ) (μ := μ) measurableSet_uIoc] at *
exact tendsto_const_nhds.smul <|
tendsto_integral_filter_of_dominated_convergence bound hF_meas h_bound bound_integrable h_lim
/-- Lebesgue dominated convergence theorem for parametric interval integrals. -/
nonrec theorem hasSum_integral_of_dominated_convergence {ι} [Countable ι] {F : ι → ℝ → E}
(bound : ι → ℝ → ℝ) (hF_meas : ∀ n, AEStronglyMeasurable (F n) (μ.restrict (Ι a b)))
(h_bound : ∀ n, ∀ᵐ t ∂μ, t ∈ Ι a b → ‖F n t‖ ≤ bound n t)
(bound_summable : ∀ᵐ t ∂μ, t ∈ Ι a b → Summable fun n => bound n t)
(bound_integrable : IntervalIntegrable (fun t => ∑' n, bound n t) μ a b)
(h_lim : ∀ᵐ t ∂μ, t ∈ Ι a b → HasSum (fun n => F n t) (f t)) :
HasSum (fun n => ∫ t in a..b, F n t ∂μ) (∫ t in a..b, f t ∂μ) := by
simp only [intervalIntegrable_iff, intervalIntegral_eq_integral_uIoc, ←
ae_restrict_iff' (α := ℝ) (μ := μ) measurableSet_uIoc] at *
exact
(hasSum_integral_of_dominated_convergence bound hF_meas h_bound bound_summable bound_integrable
h_lim).const_smul
_
/-- Interval integrals commute with countable sums, when the supremum norms are summable (a
special case of the dominated convergence theorem). -/
theorem hasSum_intervalIntegral_of_summable_norm [Countable ι] {f : ι → C(ℝ, E)}
(hf_sum : Summable fun i : ι => ‖(f i).restrict (⟨uIcc a b, isCompact_uIcc⟩ : Compacts ℝ)‖) :
HasSum (fun i : ι => ∫ x in a..b, f i x) (∫ x in a..b, ∑' i : ι, f i x) := by
by_cases hE : CompleteSpace E; swap
· simp [intervalIntegral, integral, hE, hasSum_zero]
apply hasSum_integral_of_dominated_convergence
(fun i (x : ℝ) => ‖(f i).restrict ↑(⟨uIcc a b, isCompact_uIcc⟩ : Compacts ℝ)‖)
(fun i => (map_continuous <| f i).aestronglyMeasurable)
· intro i; filter_upwards with x hx
apply ContinuousMap.norm_coe_le_norm ((f i).restrict _) ⟨x, _⟩
exact ⟨hx.1.le, hx.2⟩
· exact ae_of_all _ fun x _ => hf_sum
· exact intervalIntegrable_const
· refine ae_of_all _ fun x hx => Summable.hasSum ?_
let x : (⟨uIcc a b, isCompact_uIcc⟩ : Compacts ℝ) := ⟨x, ⟨hx.1.le, hx.2⟩⟩
have := hf_sum.of_norm
simpa only [Compacts.coe_mk, ContinuousMap.restrict_apply]
using ContinuousMap.summable_apply this x
theorem tsum_intervalIntegral_eq_of_summable_norm [Countable ι] {f : ι → C(ℝ, E)}
(hf_sum : Summable fun i : ι => ‖(f i).restrict (⟨uIcc a b, isCompact_uIcc⟩ : Compacts ℝ)‖) :
∑' i : ι, ∫ x in a..b, f i x = ∫ x in a..b, ∑' i : ι, f i x :=
(hasSum_intervalIntegral_of_summable_norm hf_sum).tsum_eq
variable {X : Type*} [TopologicalSpace X] [FirstCountableTopology X]
/-- Continuity of interval integral with respect to a parameter, at a point within a set.
Given `F : X → ℝ → E`, assume `F x` is ae-measurable on `[a, b]` for `x` in a
neighborhood of `x₀` within `s` and at `x₀`, and assume it is bounded by a function integrable
on `[a, b]` independent of `x` in a neighborhood of `x₀` within `s`. If `(fun x ↦ F x t)`
is continuous at `x₀` within `s` for almost every `t` in `[a, b]`
then the same holds for `(fun x ↦ ∫ t in a..b, F x t ∂μ) s x₀`. -/
theorem continuousWithinAt_of_dominated_interval {F : X → ℝ → E} {x₀ : X} {bound : ℝ → ℝ} {a b : ℝ}
{s : Set X} (hF_meas : ∀ᶠ x in 𝓝[s] x₀, AEStronglyMeasurable (F x) (μ.restrict <| Ι a b))
(h_bound : ∀ᶠ x in 𝓝[s] x₀, ∀ᵐ t ∂μ, t ∈ Ι a b → ‖F x t‖ ≤ bound t)
(bound_integrable : IntervalIntegrable bound μ a b)
(h_cont : ∀ᵐ t ∂μ, t ∈ Ι a b → ContinuousWithinAt (fun x => F x t) s x₀) :
ContinuousWithinAt (fun x => ∫ t in a..b, F x t ∂μ) s x₀ :=
tendsto_integral_filter_of_dominated_convergence bound hF_meas h_bound bound_integrable h_cont
/-- Continuity of interval integral with respect to a parameter at a point.
Given `F : X → ℝ → E`, assume `F x` is ae-measurable on `[a, b]` for `x` in a
neighborhood of `x₀`, and assume it is bounded by a function integrable on
`[a, b]` independent of `x` in a neighborhood of `x₀`. If `(fun x ↦ F x t)`
is continuous at `x₀` for almost every `t` in `[a, b]`
then the same holds for `(fun x ↦ ∫ t in a..b, F x t ∂μ) s x₀`. -/
theorem continuousAt_of_dominated_interval {F : X → ℝ → E} {x₀ : X} {bound : ℝ → ℝ} {a b : ℝ}
(hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) (μ.restrict <| Ι a b))
(h_bound : ∀ᶠ x in 𝓝 x₀, ∀ᵐ t ∂μ, t ∈ Ι a b → ‖F x t‖ ≤ bound t)
(bound_integrable : IntervalIntegrable bound μ a b)
(h_cont : ∀ᵐ t ∂μ, t ∈ Ι a b → ContinuousAt (fun x => F x t) x₀) :
ContinuousAt (fun x => ∫ t in a..b, F x t ∂μ) x₀ :=
tendsto_integral_filter_of_dominated_convergence bound hF_meas h_bound bound_integrable h_cont
/-- Continuity of interval integral with respect to a parameter.
Given `F : X → ℝ → E`, assume each `F x` is ae-measurable on `[a, b]`,
and assume it is bounded by a function integrable on `[a, b]` independent of `x`.
If `(fun x ↦ F x t)` is continuous for almost every `t` in `[a, b]`
then the same holds for `(fun x ↦ ∫ t in a..b, F x t ∂μ) s x₀`. -/
theorem continuous_of_dominated_interval {F : X → ℝ → E} {bound : ℝ → ℝ} {a b : ℝ}
(hF_meas : ∀ x, AEStronglyMeasurable (F x) <| μ.restrict <| Ι a b)
(h_bound : ∀ x, ∀ᵐ t ∂μ, t ∈ Ι a b → ‖F x t‖ ≤ bound t)
(bound_integrable : IntervalIntegrable bound μ a b)
(h_cont : ∀ᵐ t ∂μ, t ∈ Ι a b → Continuous fun x => F x t) :
Continuous fun x => ∫ t in a..b, F x t ∂μ :=
continuous_iff_continuousAt.mpr fun _ =>
continuousAt_of_dominated_interval (Eventually.of_forall hF_meas) (Eventually.of_forall h_bound)
bound_integrable <|
h_cont.mono fun _ himp hx => (himp hx).continuousAt
end DCT
section ContinuousPrimitive
open scoped Interval
variable {E X : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [TopologicalSpace X]
{a b b₀ b₁ b₂ : ℝ} {μ : Measure ℝ} {f : ℝ → E}
theorem continuousWithinAt_primitive (hb₀ : μ {b₀} = 0)
(h_int : IntervalIntegrable f μ (min a b₁) (max a b₂)) :
ContinuousWithinAt (fun b => ∫ x in a..b, f x ∂μ) (Icc b₁ b₂) b₀ := by
by_cases h₀ : b₀ ∈ Icc b₁ b₂
· have h₁₂ : b₁ ≤ b₂ := h₀.1.trans h₀.2
have min₁₂ : min b₁ b₂ = b₁ := min_eq_left h₁₂
have h_int' : ∀ {x}, x ∈ Icc b₁ b₂ → IntervalIntegrable f μ b₁ x := by
rintro x ⟨h₁, h₂⟩
apply h_int.mono_set
apply uIcc_subset_uIcc
· exact ⟨min_le_of_left_le (min_le_right a b₁),
h₁.trans (h₂.trans <| le_max_of_le_right <| le_max_right _ _)⟩
· exact ⟨min_le_of_left_le <| (min_le_right _ _).trans h₁,
le_max_of_le_right <| h₂.trans <| le_max_right _ _⟩
have : ∀ b ∈ Icc b₁ b₂,
∫ x in a..b, f x ∂μ = (∫ x in a..b₁, f x ∂μ) + ∫ x in b₁..b, f x ∂μ := by
rintro b ⟨h₁, h₂⟩
rw [← integral_add_adjacent_intervals _ (h_int' ⟨h₁, h₂⟩)]
apply h_int.mono_set
apply uIcc_subset_uIcc
· exact ⟨min_le_of_left_le (min_le_left a b₁), le_max_of_le_right (le_max_left _ _)⟩
· exact ⟨min_le_of_left_le (min_le_right _ _),
le_max_of_le_right (h₁.trans <| h₂.trans (le_max_right a b₂))⟩
apply ContinuousWithinAt.congr _ this (this _ h₀); clear this
refine continuousWithinAt_const.add ?_
have :
(fun b => ∫ x in b₁..b, f x ∂μ) =ᶠ[𝓝[Icc b₁ b₂] b₀] fun b =>
∫ x in b₁..b₂, indicator {x | x ≤ b} f x ∂μ := by
apply eventuallyEq_of_mem self_mem_nhdsWithin
exact fun b b_in => (integral_indicator b_in).symm
apply ContinuousWithinAt.congr_of_eventuallyEq _ this (integral_indicator h₀).symm
have : IntervalIntegrable (fun x => ‖f x‖) μ b₁ b₂ :=
IntervalIntegrable.norm (h_int' <| right_mem_Icc.mpr h₁₂)
refine continuousWithinAt_of_dominated_interval ?_ ?_ this ?_ <;> clear this
· filter_upwards [self_mem_nhdsWithin]
intro x hx
rw [aestronglyMeasurable_indicator_iff, Measure.restrict_restrict, uIoc, Iic_def,
Iic_inter_Ioc_of_le]
· rw [min₁₂]
exact (h_int' hx).1.aestronglyMeasurable
· exact le_max_of_le_right hx.2
exacts [measurableSet_Iic, measurableSet_Iic]
· filter_upwards with x; filter_upwards with t
dsimp [indicator]
split_ifs <;> simp
· have : ∀ᵐ t ∂μ, t < b₀ ∨ b₀ < t := by
filter_upwards [compl_mem_ae_iff.mpr hb₀] with x hx using Ne.lt_or_lt hx
apply this.mono
rintro x₀ (hx₀ | hx₀) -
· have : ∀ᶠ x in 𝓝[Icc b₁ b₂] b₀, {t : ℝ | t ≤ x}.indicator f x₀ = f x₀ := by
apply mem_nhdsWithin_of_mem_nhds
apply Eventually.mono (Ioi_mem_nhds hx₀)
intro x hx
simp [hx.le]
apply continuousWithinAt_const.congr_of_eventuallyEq this
simp [hx₀.le]
· have : ∀ᶠ x in 𝓝[Icc b₁ b₂] b₀, {t : ℝ | t ≤ x}.indicator f x₀ = 0 := by
apply mem_nhdsWithin_of_mem_nhds
apply Eventually.mono (Iio_mem_nhds hx₀)
intro x hx
simp [hx]
apply continuousWithinAt_const.congr_of_eventuallyEq this
simp [hx₀]
· apply continuousWithinAt_of_not_mem_closure
rwa [closure_Icc]
theorem continuousAt_parametric_primitive_of_dominated [FirstCountableTopology X]
{F : X → ℝ → E} (bound : ℝ → ℝ) (a b : ℝ)
{a₀ b₀ : ℝ} {x₀ : X} (hF_meas : ∀ x, AEStronglyMeasurable (F x) (μ.restrict <| Ι a b))
(h_bound : ∀ᶠ x in 𝓝 x₀, ∀ᵐ t ∂μ.restrict <| Ι a b, ‖F x t‖ ≤ bound t)
(bound_integrable : IntervalIntegrable bound μ a b)
(h_cont : ∀ᵐ t ∂μ.restrict <| Ι a b, ContinuousAt (fun x ↦ F x t) x₀) (ha₀ : a₀ ∈ Ioo a b)
(hb₀ : b₀ ∈ Ioo a b) (hμb₀ : μ {b₀} = 0) :
ContinuousAt (fun p : X × ℝ ↦ ∫ t : ℝ in a₀..p.2, F p.1 t ∂μ) (x₀, b₀) := by
have hsub : ∀ {a₀ b₀}, a₀ ∈ Ioo a b → b₀ ∈ Ioo a b → Ι a₀ b₀ ⊆ Ι a b := fun ha₀ hb₀ ↦
(ordConnected_Ioo.uIoc_subset ha₀ hb₀).trans (Ioo_subset_Ioc_self.trans Ioc_subset_uIoc)
have Ioo_nhds : Ioo a b ∈ 𝓝 b₀ := Ioo_mem_nhds hb₀.1 hb₀.2
have Icc_nhds : Icc a b ∈ 𝓝 b₀ := Icc_mem_nhds hb₀.1 hb₀.2
have hx₀ : ∀ᵐ t : ℝ ∂μ.restrict (Ι a b), ‖F x₀ t‖ ≤ bound t := h_bound.self_of_nhds
have : ∀ᶠ p : X × ℝ in 𝓝 (x₀, b₀),
∫ s in a₀..p.2, F p.1 s ∂μ =
∫ s in a₀..b₀, F p.1 s ∂μ + ∫ s in b₀..p.2, F x₀ s ∂μ +
∫ s in b₀..p.2, F p.1 s - F x₀ s ∂μ := by
rw [nhds_prod_eq]
refine (h_bound.prod_mk Ioo_nhds).mono ?_
rintro ⟨x, t⟩ ⟨hx : ∀ᵐ t : ℝ ∂μ.restrict (Ι a b), ‖F x t‖ ≤ bound t, ht : t ∈ Ioo a b⟩
dsimp
have hiF : ∀ {x a₀ b₀},
(∀ᵐ t : ℝ ∂μ.restrict (Ι a b), ‖F x t‖ ≤ bound t) → a₀ ∈ Ioo a b → b₀ ∈ Ioo a b →
IntervalIntegrable (F x) μ a₀ b₀ := fun {x a₀ b₀} hx ha₀ hb₀ ↦
(bound_integrable.mono_set_ae <| Eventually.of_forall <| hsub ha₀ hb₀).mono_fun'
((hF_meas x).mono_set <| hsub ha₀ hb₀)
(ae_restrict_of_ae_restrict_of_subset (hsub ha₀ hb₀) hx)
rw [intervalIntegral.integral_sub, add_assoc, add_sub_cancel,
intervalIntegral.integral_add_adjacent_intervals]
· exact hiF hx ha₀ hb₀
· exact hiF hx hb₀ ht
· exact hiF hx hb₀ ht
· exact hiF hx₀ hb₀ ht
rw [continuousAt_congr this]; clear this
refine (ContinuousAt.add ?_ ?_).add ?_
· exact (intervalIntegral.continuousAt_of_dominated_interval
(Eventually.of_forall fun x ↦ (hF_meas x).mono_set <| hsub ha₀ hb₀)
(h_bound.mono fun x hx ↦
ae_imp_of_ae_restrict <| ae_restrict_of_ae_restrict_of_subset (hsub ha₀ hb₀) hx)
(bound_integrable.mono_set_ae <| Eventually.of_forall <| hsub ha₀ hb₀) <|
ae_imp_of_ae_restrict <| ae_restrict_of_ae_restrict_of_subset (hsub ha₀ hb₀) h_cont).fst'
· refine (?_ : ContinuousAt (fun t ↦ ∫ s in b₀..t, F x₀ s ∂μ) b₀).snd'
apply ContinuousWithinAt.continuousAt _ (Icc_mem_nhds hb₀.1 hb₀.2)
apply intervalIntegral.continuousWithinAt_primitive hμb₀
rw [min_eq_right hb₀.1.le, max_eq_right hb₀.2.le]
exact bound_integrable.mono_fun' (hF_meas x₀) hx₀
· suffices Tendsto (fun x : X × ℝ ↦ ∫ s in b₀..x.2, F x.1 s - F x₀ s ∂μ) (𝓝 (x₀, b₀)) (𝓝 0) by
simpa [ContinuousAt]
have : ∀ᶠ p : X × ℝ in 𝓝 (x₀, b₀),
‖∫ s in b₀..p.2, F p.1 s - F x₀ s ∂μ‖ ≤ |∫ s in b₀..p.2, 2 * bound s ∂μ| := by
rw [nhds_prod_eq]
refine (h_bound.prod_mk Ioo_nhds).mono ?_
rintro ⟨x, t⟩ ⟨hx : ∀ᵐ t ∂μ.restrict (Ι a b), ‖F x t‖ ≤ bound t, ht : t ∈ Ioo a b⟩
have H : ∀ᵐ t : ℝ ∂μ.restrict (Ι b₀ t), ‖F x t - F x₀ t‖ ≤ 2 * bound t := by
apply (ae_restrict_of_ae_restrict_of_subset (hsub hb₀ ht) (hx.and hx₀)).mono
rintro s ⟨hs₁, hs₂⟩
calc
‖F x s - F x₀ s‖ ≤ ‖F x s‖ + ‖F x₀ s‖ := norm_sub_le _ _
_ ≤ 2 * bound s := by linarith only [hs₁, hs₂]
exact intervalIntegral.norm_integral_le_of_norm_le H
((bound_integrable.mono_set' <| hsub hb₀ ht).const_mul 2)
apply squeeze_zero_norm' this
have : Tendsto (fun t ↦ ∫ s in b₀..t, 2 * bound s ∂μ) (𝓝 b₀) (𝓝 0) := by
suffices ContinuousAt (fun t ↦ ∫ s in b₀..t, 2 * bound s ∂μ) b₀ by
simpa [ContinuousAt] using this
apply ContinuousWithinAt.continuousAt _ Icc_nhds
apply intervalIntegral.continuousWithinAt_primitive hμb₀
apply IntervalIntegrable.const_mul
apply bound_integrable.mono_set'
rw [min_eq_right hb₀.1.le, max_eq_right hb₀.2.le]
rw [nhds_prod_eq]
exact (continuous_abs.tendsto' _ _ abs_zero).comp (this.comp tendsto_snd)
variable [NoAtoms μ]
theorem continuousOn_primitive (h_int : IntegrableOn f (Icc a b) μ) :
ContinuousOn (fun x => ∫ t in Ioc a x, f t ∂μ) (Icc a b) := by
by_cases h : a ≤ b
· have : ∀ x ∈ Icc a b, ∫ t in Ioc a x, f t ∂μ = ∫ t in a..x, f t ∂μ := by
intro x x_in
simp_rw [integral_of_le x_in.1]
rw [continuousOn_congr this]
intro x₀ _
refine continuousWithinAt_primitive (measure_singleton x₀) ?_
simp only [intervalIntegrable_iff_integrableOn_Ioc_of_le, min_eq_left, max_eq_right, h,
min_self]
exact h_int.mono Ioc_subset_Icc_self le_rfl
· rw [Icc_eq_empty h]
exact continuousOn_empty _
| Mathlib/MeasureTheory/Integral/DominatedConvergence.lean | 477 | 483 | theorem continuousOn_primitive_Icc (h_int : IntegrableOn f (Icc a b) μ) :
ContinuousOn (fun x => ∫ t in Icc a x, f t ∂μ) (Icc a b) := by | have aux : (fun x => ∫ t in Icc a x, f t ∂μ) = fun x => ∫ t in Ioc a x, f t ∂μ := by
ext x
exact integral_Icc_eq_integral_Ioc
rw [aux]
exact continuousOn_primitive h_int |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Yury Kudryashov, Kexing Ying
-/
import Mathlib.Topology.Semicontinuous
import Mathlib.MeasureTheory.Function.AEMeasurableSequence
import Mathlib.MeasureTheory.Order.Lattice
import Mathlib.Topology.Order.Lattice
import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic
/-!
# Borel sigma algebras on spaces with orders
## Main statements
* `borel_eq_generateFrom_Ixx` (where Ixx is one of {Iio, Ioi, Iic, Ici, Ico, Ioc}):
The Borel sigma algebra of a linear order topology is generated by intervals of the given kind.
* `Dense.borel_eq_generateFrom_Ico_mem`, `Dense.borel_eq_generateFrom_Ioc_mem`:
The Borel sigma algebra of a dense linear order topology is generated by intervals of a given
kind, with endpoints from dense subsets.
* `ext_of_Ico`, `ext_of_Ioc`:
A locally finite Borel measure on a second countable conditionally complete linear order is
characterized by the measures of intervals of the given kind.
* `ext_of_Iic`, `ext_of_Ici`:
A finite Borel measure on a second countable linear order is characterized by the measures of
intervals of the given kind.
* `UpperSemicontinuous.measurable`, `LowerSemicontinuous.measurable`:
Semicontinuous functions are measurable.
* `Measurable.iSup`, `Measurable.iInf`, `Measurable.sSup`, `Measurable.sInf`:
Countable supremums and infimums of measurable functions to conditionally complete linear orders
are measurable.
* `Measurable.liminf`, `Measurable.limsup`:
Countable liminfs and limsups of measurable functions to conditionally complete linear orders
are measurable.
-/
open Set Filter MeasureTheory MeasurableSpace TopologicalSpace
open scoped Topology NNReal ENNReal MeasureTheory
universe u v w x y
variable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α}
section OrderTopology
variable (α)
variable [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α]
theorem borel_eq_generateFrom_Iio : borel α = .generateFrom (range Iio) := by
refine le_antisymm ?_ (generateFrom_le ?_)
· rw [borel_eq_generateFrom_of_subbasis (@OrderTopology.topology_eq_generate_intervals α _ _ _)]
letI : MeasurableSpace α := MeasurableSpace.generateFrom (range Iio)
have H : ∀ a : α, MeasurableSet (Iio a) := fun a => GenerateMeasurable.basic _ ⟨_, rfl⟩
refine generateFrom_le ?_
rintro _ ⟨a, rfl | rfl⟩
· rcases em (∃ b, a ⋖ b) with ⟨b, hb⟩ | hcovBy
· rw [hb.Ioi_eq, ← compl_Iio]
exact (H _).compl
· rcases isOpen_biUnion_countable (Ioi a) Ioi fun _ _ ↦ isOpen_Ioi with ⟨t, hat, htc, htU⟩
have : Ioi a = ⋃ b ∈ t, Ici b := by
refine Subset.antisymm ?_ <| iUnion₂_subset fun b hb ↦ Ici_subset_Ioi.2 (hat hb)
refine Subset.trans ?_ <| iUnion₂_mono fun _ _ ↦ Ioi_subset_Ici_self
simpa [CovBy, htU, subset_def] using hcovBy
simp only [this, ← compl_Iio]
exact .biUnion htc <| fun _ _ ↦ (H _).compl
· apply H
· rw [forall_mem_range]
intro a
exact GenerateMeasurable.basic _ isOpen_Iio
theorem borel_eq_generateFrom_Ioi : borel α = .generateFrom (range Ioi) :=
@borel_eq_generateFrom_Iio αᵒᵈ _ (by infer_instance : SecondCountableTopology α) _ _
theorem borel_eq_generateFrom_Iic :
borel α = MeasurableSpace.generateFrom (range Iic) := by
rw [borel_eq_generateFrom_Ioi]
refine le_antisymm ?_ ?_
· refine MeasurableSpace.generateFrom_le fun t ht => ?_
obtain ⟨u, rfl⟩ := ht
rw [← compl_Iic]
exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl
· refine MeasurableSpace.generateFrom_le fun t ht => ?_
obtain ⟨u, rfl⟩ := ht
rw [← compl_Ioi]
exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl
theorem borel_eq_generateFrom_Ici : borel α = MeasurableSpace.generateFrom (range Ici) :=
@borel_eq_generateFrom_Iic αᵒᵈ _ _ _ _
end OrderTopology
section Orders
variable [TopologicalSpace α] {mα : MeasurableSpace α} [OpensMeasurableSpace α]
variable {mδ : MeasurableSpace δ}
section Preorder
variable [Preorder α] [OrderClosedTopology α] {a b x : α} {μ : Measure α}
@[simp, measurability]
theorem measurableSet_Ici : MeasurableSet (Ici a) :=
isClosed_Ici.measurableSet
theorem nullMeasurableSet_Ici : NullMeasurableSet (Ici a) μ :=
measurableSet_Ici.nullMeasurableSet
@[simp, measurability]
theorem measurableSet_Iic : MeasurableSet (Iic a) :=
isClosed_Iic.measurableSet
theorem nullMeasurableSet_Iic : NullMeasurableSet (Iic a) μ :=
measurableSet_Iic.nullMeasurableSet
@[simp, measurability]
theorem measurableSet_Icc : MeasurableSet (Icc a b) :=
isClosed_Icc.measurableSet
theorem nullMeasurableSet_Icc : NullMeasurableSet (Icc a b) μ :=
measurableSet_Icc.nullMeasurableSet
instance nhdsWithin_Ici_isMeasurablyGenerated : (𝓝[Ici b] a).IsMeasurablyGenerated :=
measurableSet_Ici.nhdsWithin_isMeasurablyGenerated _
instance nhdsWithin_Iic_isMeasurablyGenerated : (𝓝[Iic b] a).IsMeasurablyGenerated :=
measurableSet_Iic.nhdsWithin_isMeasurablyGenerated _
instance nhdsWithin_Icc_isMeasurablyGenerated : IsMeasurablyGenerated (𝓝[Icc a b] x) := by
rw [← Ici_inter_Iic, nhdsWithin_inter]
infer_instance
instance atTop_isMeasurablyGenerated : (Filter.atTop : Filter α).IsMeasurablyGenerated :=
@Filter.iInf_isMeasurablyGenerated _ _ _ _ fun a =>
(measurableSet_Ici : MeasurableSet (Ici a)).principal_isMeasurablyGenerated
instance atBot_isMeasurablyGenerated : (Filter.atBot : Filter α).IsMeasurablyGenerated :=
@Filter.iInf_isMeasurablyGenerated _ _ _ _ fun a =>
(measurableSet_Iic : MeasurableSet (Iic a)).principal_isMeasurablyGenerated
instance [R1Space α] : IsMeasurablyGenerated (cocompact α) where
exists_measurable_subset := by
intro _ hs
obtain ⟨t, ht, hts⟩ := mem_cocompact.mp hs
exact ⟨(closure t)ᶜ, ht.closure.compl_mem_cocompact, isClosed_closure.measurableSet.compl,
(compl_subset_compl.2 subset_closure).trans hts⟩
end Preorder
section PartialOrder
variable [PartialOrder α] [OrderClosedTopology α] [SecondCountableTopology α] {a b : α}
@[measurability]
theorem measurableSet_le' : MeasurableSet { p : α × α | p.1 ≤ p.2 } :=
OrderClosedTopology.isClosed_le'.measurableSet
@[measurability]
theorem measurableSet_le {f g : δ → α} (hf : Measurable f) (hg : Measurable g) :
MeasurableSet { a | f a ≤ g a } :=
hf.prodMk hg measurableSet_le'
end PartialOrder
section LinearOrder
variable [LinearOrder α] [OrderClosedTopology α] {a b x : α} {μ : Measure α}
-- we open this locale only here to avoid issues with list being treated as intervals above
open Interval
@[simp, measurability]
theorem measurableSet_Iio : MeasurableSet (Iio a) :=
isOpen_Iio.measurableSet
theorem nullMeasurableSet_Iio : NullMeasurableSet (Iio a) μ :=
measurableSet_Iio.nullMeasurableSet
@[simp, measurability]
theorem measurableSet_Ioi : MeasurableSet (Ioi a) :=
isOpen_Ioi.measurableSet
theorem nullMeasurableSet_Ioi : NullMeasurableSet (Ioi a) μ :=
measurableSet_Ioi.nullMeasurableSet
@[simp, measurability]
theorem measurableSet_Ioo : MeasurableSet (Ioo a b) :=
isOpen_Ioo.measurableSet
theorem nullMeasurableSet_Ioo : NullMeasurableSet (Ioo a b) μ :=
measurableSet_Ioo.nullMeasurableSet
@[simp, measurability]
theorem measurableSet_Ioc : MeasurableSet (Ioc a b) :=
measurableSet_Ioi.inter measurableSet_Iic
theorem nullMeasurableSet_Ioc : NullMeasurableSet (Ioc a b) μ :=
measurableSet_Ioc.nullMeasurableSet
@[simp, measurability]
theorem measurableSet_Ico : MeasurableSet (Ico a b) :=
measurableSet_Ici.inter measurableSet_Iio
theorem nullMeasurableSet_Ico : NullMeasurableSet (Ico a b) μ :=
measurableSet_Ico.nullMeasurableSet
instance nhdsWithin_Ioi_isMeasurablyGenerated : (𝓝[Ioi b] a).IsMeasurablyGenerated :=
measurableSet_Ioi.nhdsWithin_isMeasurablyGenerated _
instance nhdsWithin_Iio_isMeasurablyGenerated : (𝓝[Iio b] a).IsMeasurablyGenerated :=
measurableSet_Iio.nhdsWithin_isMeasurablyGenerated _
instance nhdsWithin_uIcc_isMeasurablyGenerated : IsMeasurablyGenerated (𝓝[[[a, b]]] x) :=
nhdsWithin_Icc_isMeasurablyGenerated
@[measurability]
theorem measurableSet_lt' [SecondCountableTopology α] : MeasurableSet { p : α × α | p.1 < p.2 } :=
(isOpen_lt continuous_fst continuous_snd).measurableSet
@[measurability]
theorem measurableSet_lt [SecondCountableTopology α] {f g : δ → α} (hf : Measurable f)
(hg : Measurable g) : MeasurableSet { a | f a < g a } :=
hf.prodMk hg measurableSet_lt'
theorem nullMeasurableSet_lt [SecondCountableTopology α] {μ : Measure δ} {f g : δ → α}
(hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : NullMeasurableSet { a | f a < g a } μ :=
(hf.prodMk hg).nullMeasurable measurableSet_lt'
theorem nullMeasurableSet_lt' [SecondCountableTopology α] {μ : Measure (α × α)} :
NullMeasurableSet { p : α × α | p.1 < p.2 } μ :=
measurableSet_lt'.nullMeasurableSet
theorem nullMeasurableSet_le [SecondCountableTopology α] {μ : Measure δ}
{f g : δ → α} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) :
NullMeasurableSet { a | f a ≤ g a } μ :=
(hf.prodMk hg).nullMeasurable measurableSet_le'
theorem Set.OrdConnected.measurableSet (h : OrdConnected s) : MeasurableSet s := by
let u := ⋃ (x ∈ s) (y ∈ s), Ioo x y
have huopen : IsOpen u := isOpen_biUnion fun _ _ => isOpen_biUnion fun _ _ => isOpen_Ioo
have humeas : MeasurableSet u := huopen.measurableSet
have hfinite : (s \ u).Finite := s.finite_diff_iUnion_Ioo
have : u ⊆ s := iUnion₂_subset fun x hx => iUnion₂_subset fun y hy =>
Ioo_subset_Icc_self.trans (h.out hx hy)
rw [← union_diff_cancel this]
exact humeas.union hfinite.measurableSet
theorem IsPreconnected.measurableSet (h : IsPreconnected s) : MeasurableSet s :=
h.ordConnected.measurableSet
theorem generateFrom_Ico_mem_le_borel {α : Type*} [TopologicalSpace α] [LinearOrder α]
[OrderClosedTopology α] (s t : Set α) :
MeasurableSpace.generateFrom { S | ∃ l ∈ s, ∃ u ∈ t, l < u ∧ Ico l u = S }
≤ borel α := by
apply generateFrom_le
borelize α
rintro _ ⟨a, -, b, -, -, rfl⟩
exact measurableSet_Ico
theorem Dense.borel_eq_generateFrom_Ico_mem_aux {α : Type*} [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s)
(hbot : ∀ x, IsBot x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → y ∈ s) :
borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S } := by
set S : Set (Set α) := { S | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S }
refine le_antisymm ?_ (generateFrom_Ico_mem_le_borel _ _)
letI : MeasurableSpace α := generateFrom S
rw [borel_eq_generateFrom_Iio]
refine generateFrom_le (forall_mem_range.2 fun a => ?_)
rcases hd.exists_countable_dense_subset_bot_top with ⟨t, hts, hc, htd, htb, -⟩
by_cases ha : ∀ b < a, (Ioo b a).Nonempty
· convert_to MeasurableSet (⋃ (l ∈ t) (u ∈ t) (_ : l < u) (_ : u ≤ a), Ico l u)
· ext y
simp only [mem_iUnion, mem_Iio, mem_Ico]
constructor
· intro hy
rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) y with ⟨l, hlt, hly⟩
rcases htd.exists_mem_open isOpen_Ioo (ha y hy) with ⟨u, hut, hyu, hua⟩
exact ⟨l, hlt, u, hut, hly.trans_lt hyu, hua.le, hly, hyu⟩
· rintro ⟨l, -, u, -, -, hua, -, hyu⟩
exact hyu.trans_le hua
· refine MeasurableSet.biUnion hc fun a ha => MeasurableSet.biUnion hc fun b hb => ?_
refine MeasurableSet.iUnion fun hab => MeasurableSet.iUnion fun _ => ?_
exact .basic _ ⟨a, hts ha, b, hts hb, hab, mem_singleton _⟩
· simp only [not_forall, not_nonempty_iff_eq_empty] at ha
replace ha : a ∈ s := hIoo ha.choose a ha.choose_spec.fst ha.choose_spec.snd
convert_to MeasurableSet (⋃ (l ∈ t) (_ : l < a), Ico l a)
· symm
simp only [← Ici_inter_Iio, ← iUnion_inter, inter_eq_right, subset_def, mem_iUnion,
mem_Ici, mem_Iio]
intro x hx
rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) x with ⟨z, hzt, hzx⟩
exact ⟨z, hzt, hzx.trans_lt hx, hzx⟩
· refine .biUnion hc fun x hx => MeasurableSet.iUnion fun hlt => ?_
exact .basic _ ⟨x, hts hx, a, ha, hlt, mem_singleton _⟩
theorem Dense.borel_eq_generateFrom_Ico_mem {α : Type*} [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMinOrder α] {s : Set α}
(hd : Dense s) :
borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S } :=
hd.borel_eq_generateFrom_Ico_mem_aux (by simp) fun _ _ hxy H =>
((nonempty_Ioo.2 hxy).ne_empty H).elim
theorem borel_eq_generateFrom_Ico (α : Type*) [TopologicalSpace α] [SecondCountableTopology α]
[LinearOrder α] [OrderTopology α] :
borel α = .generateFrom { S : Set α | ∃ (l u : α), l < u ∧ Ico l u = S } := by
simpa only [exists_prop, mem_univ, true_and] using
(@dense_univ α _).borel_eq_generateFrom_Ico_mem_aux (fun _ _ => mem_univ _) fun _ _ _ _ =>
mem_univ _
theorem Dense.borel_eq_generateFrom_Ioc_mem_aux {α : Type*} [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s)
(hbot : ∀ x, IsTop x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → x ∈ s) :
borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ioc l u = S } := by
convert hd.orderDual.borel_eq_generateFrom_Ico_mem_aux hbot fun x y hlt he => hIoo y x hlt _
using 2
· ext s
constructor <;> rintro ⟨l, hl, u, hu, hlt, rfl⟩
exacts [⟨u, hu, l, hl, hlt, Ico_toDual⟩, ⟨u, hu, l, hl, hlt, Ioc_toDual⟩]
· erw [Ioo_toDual]
exact he
theorem Dense.borel_eq_generateFrom_Ioc_mem {α : Type*} [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMaxOrder α] {s : Set α}
(hd : Dense s) :
borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ioc l u = S } :=
hd.borel_eq_generateFrom_Ioc_mem_aux (by simp) fun _ _ hxy H =>
((nonempty_Ioo.2 hxy).ne_empty H).elim
theorem borel_eq_generateFrom_Ioc (α : Type*) [TopologicalSpace α] [SecondCountableTopology α]
[LinearOrder α] [OrderTopology α] :
borel α = .generateFrom { S : Set α | ∃ l u, l < u ∧ Ioc l u = S } := by
simpa only [exists_prop, mem_univ, true_and] using
(@dense_univ α _).borel_eq_generateFrom_Ioc_mem_aux (fun _ _ => mem_univ _) fun _ _ _ _ =>
mem_univ _
namespace MeasureTheory.Measure
/-- Two finite measures on a Borel space are equal if they agree on all closed-open intervals. If
`α` is a conditionally complete linear order with no top element,
`MeasureTheory.Measure.ext_of_Ico` is an extensionality lemma with weaker assumptions on `μ` and
`ν`. -/
theorem ext_of_Ico_finite {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α}
[SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α)
[IsFiniteMeasure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) :
μ = ν := by
refine
ext_of_generate_finite _ (BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Ico α))
(isPiSystem_Ico (id : α → α) id) ?_ hμν
rintro - ⟨a, b, hlt, rfl⟩
exact h hlt
/-- Two finite measures on a Borel space are equal if they agree on all open-closed intervals. If
`α` is a conditionally complete linear order with no top element,
`MeasureTheory.Measure.ext_of_Ioc` is an extensionality lemma with weaker assumptions on `μ` and
`ν`. -/
theorem ext_of_Ioc_finite {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α}
[SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α)
[IsFiniteMeasure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) :
μ = ν := by
refine @ext_of_Ico_finite αᵒᵈ _ _ _ _ _ ‹_› μ ν _ hμν fun a b hab => ?_
erw [Ico_toDual (α := α)]
exact h hab
/-- Two measures which are finite on closed-open intervals are equal if they agree on all
closed-open intervals. -/
theorem ext_of_Ico' {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α}
[SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] [NoMaxOrder α]
(μ ν : Measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ico a b) ≠ ∞)
(h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν := by
rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, hsb, _⟩
have : (⋃ (l ∈ s) (u ∈ s) (_ : l < u), {Ico l u} : Set (Set α)).Countable :=
hsc.biUnion fun l _ => hsc.biUnion fun u _ => countable_iUnion fun _ => countable_singleton _
simp only [← setOf_eq_eq_singleton, ← setOf_exists] at this
refine
Measure.ext_of_generateFrom_of_cover_subset
(BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Ico α)) (isPiSystem_Ico id id) ?_ this
?_ ?_ ?_
· rintro _ ⟨l, -, u, -, h, rfl⟩
exact ⟨l, u, h, rfl⟩
· refine sUnion_eq_univ_iff.2 fun x => ?_
rcases hsd.exists_le' hsb x with ⟨l, hls, hlx⟩
rcases hsd.exists_gt x with ⟨u, hus, hxu⟩
exact ⟨_, ⟨l, hls, u, hus, hlx.trans_lt hxu, rfl⟩, hlx, hxu⟩
· rintro _ ⟨l, -, u, -, hlt, rfl⟩
exact hμ hlt
· rintro _ ⟨l, u, hlt, rfl⟩
exact h hlt
/-- Two measures which are finite on closed-open intervals are equal if they agree on all
open-closed intervals. -/
theorem ext_of_Ioc' {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α}
[SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] [NoMinOrder α]
(μ ν : Measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ioc a b) ≠ ∞)
(h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := by
refine @ext_of_Ico' αᵒᵈ _ _ _ _ _ ‹_› _ μ ν ?_ ?_ <;> intro a b hab <;> erw [Ico_toDual (α := α)]
exacts [hμ hab, h hab]
/-- Two measures which are finite on closed-open intervals are equal if they agree on all
closed-open intervals. -/
theorem ext_of_Ico {α : Type*} [TopologicalSpace α] {_m : MeasurableSpace α}
[SecondCountableTopology α] [ConditionallyCompleteLinearOrder α] [OrderTopology α]
[BorelSpace α] [NoMaxOrder α] (μ ν : Measure α) [IsLocallyFiniteMeasure μ]
(h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν :=
μ.ext_of_Ico' ν (fun _ _ _ => measure_Ico_lt_top.ne) h
/-- Two measures which are finite on closed-open intervals are equal if they agree on all
open-closed intervals. -/
theorem ext_of_Ioc {α : Type*} [TopologicalSpace α] {_m : MeasurableSpace α}
[SecondCountableTopology α] [ConditionallyCompleteLinearOrder α] [OrderTopology α]
[BorelSpace α] [NoMinOrder α] (μ ν : Measure α) [IsLocallyFiniteMeasure μ]
(h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν :=
μ.ext_of_Ioc' ν (fun _ _ _ => measure_Ioc_lt_top.ne) h
/-- Two finite measures on a Borel space are equal if they agree on all left-infinite right-closed
intervals. -/
theorem ext_of_Iic {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α}
[SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α)
[IsFiniteMeasure μ] (h : ∀ a, μ (Iic a) = ν (Iic a)) : μ = ν := by
refine ext_of_Ioc_finite μ ν ?_ fun a b hlt => ?_
· rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, -, hst⟩
have : DirectedOn (· ≤ ·) s := directedOn_iff_directed.2 (Subtype.mono_coe _).directed_le
simp only [← biSup_measure_Iic hsc (hsd.exists_ge' hst) this, h]
rw [← Iic_diff_Iic, measure_diff (Iic_subset_Iic.2 hlt.le) nullMeasurableSet_Iic,
measure_diff (Iic_subset_Iic.2 hlt.le) nullMeasurableSet_Iic, h a, h b]
· rw [← h a]
exact measure_ne_top μ _
· exact measure_ne_top μ _
/-- Two finite measures on a Borel space are equal if they agree on all left-closed right-infinite
intervals. -/
theorem ext_of_Ici {α : Type*} [TopologicalSpace α] {_ : MeasurableSpace α}
[SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α)
[IsFiniteMeasure μ] (h : ∀ a, μ (Ici a) = ν (Ici a)) : μ = ν :=
@ext_of_Iic αᵒᵈ _ _ _ _ _ ‹_› _ _ _ h
end MeasureTheory.Measure
@[measurability]
theorem measurableSet_uIcc : MeasurableSet (uIcc a b) :=
measurableSet_Icc
@[measurability]
theorem measurableSet_uIoc : MeasurableSet (uIoc a b) :=
measurableSet_Ioc
variable [SecondCountableTopology α]
@[measurability, fun_prop]
theorem Measurable.max {f g : δ → α} (hf : Measurable f) (hg : Measurable g) :
Measurable fun a => max (f a) (g a) := by
simpa only [max_def'] using hf.piecewise (measurableSet_le hg hf) hg
@[measurability, fun_prop]
nonrec theorem AEMeasurable.max {f g : δ → α} {μ : Measure δ} (hf : AEMeasurable f μ)
(hg : AEMeasurable g μ) : AEMeasurable (fun a => max (f a) (g a)) μ :=
⟨fun a => max (hf.mk f a) (hg.mk g a), hf.measurable_mk.max hg.measurable_mk,
EventuallyEq.comp₂ hf.ae_eq_mk _ hg.ae_eq_mk⟩
@[measurability, fun_prop]
theorem Measurable.min {f g : δ → α} (hf : Measurable f) (hg : Measurable g) :
Measurable fun a => min (f a) (g a) := by
simpa only [min_def] using hf.piecewise (measurableSet_le hf hg) hg
@[measurability, fun_prop]
nonrec theorem AEMeasurable.min {f g : δ → α} {μ : Measure δ} (hf : AEMeasurable f μ)
(hg : AEMeasurable g μ) : AEMeasurable (fun a => min (f a) (g a)) μ :=
⟨fun a => min (hf.mk f a) (hg.mk g a), hf.measurable_mk.min hg.measurable_mk,
EventuallyEq.comp₂ hf.ae_eq_mk _ hg.ae_eq_mk⟩
end LinearOrder
section Lattice
variable [TopologicalSpace γ] {mγ : MeasurableSpace γ} [BorelSpace γ]
instance (priority := 100) ContinuousSup.measurableSup [Max γ] [ContinuousSup γ] :
MeasurableSup γ where
measurable_const_sup _ := (continuous_const.sup continuous_id).measurable
measurable_sup_const _ := (continuous_id.sup continuous_const).measurable
instance (priority := 100) ContinuousSup.measurableSup₂ [SecondCountableTopology γ] [Max γ]
[ContinuousSup γ] : MeasurableSup₂ γ :=
⟨continuous_sup.measurable⟩
instance (priority := 100) ContinuousInf.measurableInf [Min γ] [ContinuousInf γ] :
MeasurableInf γ where
measurable_const_inf _ := (continuous_const.inf continuous_id).measurable
measurable_inf_const _ := (continuous_id.inf continuous_const).measurable
instance (priority := 100) ContinuousInf.measurableInf₂ [SecondCountableTopology γ] [Min γ]
[ContinuousInf γ] : MeasurableInf₂ γ :=
⟨continuous_inf.measurable⟩
end Lattice
end Orders
section BorelSpace
variable [TopologicalSpace α] {mα : MeasurableSpace α} [BorelSpace α]
variable [TopologicalSpace β] {mβ : MeasurableSpace β} [BorelSpace β]
variable {mδ : MeasurableSpace δ}
section LinearOrder
variable [LinearOrder α] [OrderTopology α] [SecondCountableTopology α]
theorem measurable_of_Iio {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iio x)) : Measurable f := by
convert measurable_generateFrom (α := δ) _
· exact BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Iio _)
· rintro _ ⟨x, rfl⟩; exact hf x
theorem UpperSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α}
(hf : UpperSemicontinuous f) : Measurable f :=
measurable_of_Iio fun y => (hf.isOpen_preimage y).measurableSet
theorem measurable_of_Ioi {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Ioi x)) : Measurable f := by
convert measurable_generateFrom (α := δ) _
· exact BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Ioi _)
· rintro _ ⟨x, rfl⟩; exact hf x
theorem LowerSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α}
(hf : LowerSemicontinuous f) : Measurable f :=
measurable_of_Ioi fun y => (hf.isOpen_preimage y).measurableSet
theorem measurable_of_Iic {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iic x)) : Measurable f := by
apply measurable_of_Ioi
simp_rw [← compl_Iic, preimage_compl, MeasurableSet.compl_iff]
assumption
theorem measurable_of_Ici {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Ici x)) : Measurable f := by
apply measurable_of_Iio
simp_rw [← compl_Ici, preimage_compl, MeasurableSet.compl_iff]
assumption
/-- If a function is the least upper bound of countably many measurable functions,
then it is measurable. -/
| Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean | 540 | 543 | theorem Measurable.isLUB {ι} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, Measurable (f i))
(hg : ∀ b, IsLUB { a | ∃ i, f i b = a } (g b)) : Measurable g := by | change ∀ b, IsLUB (range fun i => f i b) (g b) at hg
rw [‹BorelSpace α›.measurable_eq, borel_eq_generateFrom_Ioi α] |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Kim Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.MonoidAlgebra.Degree
import Mathlib.Algebra.Order.Ring.WithTop
import Mathlib.Algebra.Polynomial.Basic
import Mathlib.Data.Nat.Cast.WithTop
import Mathlib.Data.Nat.SuccPred
import Mathlib.Order.SuccPred.WithBot
/-!
# Degree of univariate polynomials
## Main definitions
* `Polynomial.degree`: the degree of a polynomial, where `0` has degree `⊥`
* `Polynomial.natDegree`: the degree of a polynomial, where `0` has degree `0`
* `Polynomial.leadingCoeff`: the leading coefficient of a polynomial
* `Polynomial.Monic`: a polynomial is monic if its leading coefficient is 0
* `Polynomial.nextCoeff`: the next coefficient after the leading coefficient
## Main results
* `Polynomial.degree_eq_natDegree`: the degree and natDegree coincide for nonzero polynomials
-/
noncomputable section
open Finsupp Finset
open Polynomial
namespace Polynomial
universe u v
variable {R : Type u} {S : Type v} {a b c d : R} {n m : ℕ}
section Semiring
variable [Semiring R] {p q r : R[X]}
/-- `degree p` is the degree of the polynomial `p`, i.e. the largest `X`-exponent in `p`.
`degree p = some n` when `p ≠ 0` and `n` is the highest power of `X` that appears in `p`, otherwise
`degree 0 = ⊥`. -/
def degree (p : R[X]) : WithBot ℕ :=
p.support.max
/-- `natDegree p` forces `degree p` to ℕ, by defining `natDegree 0 = 0`. -/
def natDegree (p : R[X]) : ℕ :=
(degree p).unbotD 0
/-- `leadingCoeff p` gives the coefficient of the highest power of `X` in `p`. -/
def leadingCoeff (p : R[X]) : R :=
coeff p (natDegree p)
/-- a polynomial is `Monic` if its leading coefficient is 1 -/
def Monic (p : R[X]) :=
leadingCoeff p = (1 : R)
theorem Monic.def : Monic p ↔ leadingCoeff p = 1 :=
Iff.rfl
instance Monic.decidable [DecidableEq R] : Decidable (Monic p) := by unfold Monic; infer_instance
@[simp]
theorem Monic.leadingCoeff {p : R[X]} (hp : p.Monic) : leadingCoeff p = 1 :=
hp
theorem Monic.coeff_natDegree {p : R[X]} (hp : p.Monic) : p.coeff p.natDegree = 1 :=
hp
@[simp]
theorem degree_zero : degree (0 : R[X]) = ⊥ :=
rfl
@[simp]
theorem natDegree_zero : natDegree (0 : R[X]) = 0 :=
rfl
@[simp]
theorem coeff_natDegree : coeff p (natDegree p) = leadingCoeff p :=
rfl
@[simp]
theorem degree_eq_bot : degree p = ⊥ ↔ p = 0 :=
⟨fun h => support_eq_empty.1 (Finset.max_eq_bot.1 h), fun h => h.symm ▸ rfl⟩
theorem degree_ne_bot : degree p ≠ ⊥ ↔ p ≠ 0 := degree_eq_bot.not
theorem degree_eq_natDegree (hp : p ≠ 0) : degree p = (natDegree p : WithBot ℕ) := by
let ⟨n, hn⟩ := not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt degree_eq_bot.1 hp))
have hn : degree p = some n := Classical.not_not.1 hn
rw [natDegree, hn]; rfl
theorem degree_eq_iff_natDegree_eq {p : R[X]} {n : ℕ} (hp : p ≠ 0) :
p.degree = n ↔ p.natDegree = n := by rw [degree_eq_natDegree hp]; exact WithBot.coe_eq_coe
theorem degree_eq_iff_natDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
p.degree = n ↔ p.natDegree = n := by
obtain rfl|h := eq_or_ne p 0
· simp [hn.ne]
· exact degree_eq_iff_natDegree_eq h
theorem natDegree_eq_of_degree_eq_some {p : R[X]} {n : ℕ} (h : degree p = n) : natDegree p = n := by
rw [natDegree, h, Nat.cast_withBot, WithBot.unbotD_coe]
theorem degree_ne_of_natDegree_ne {n : ℕ} : p.natDegree ≠ n → degree p ≠ n :=
mt natDegree_eq_of_degree_eq_some
@[simp]
theorem degree_le_natDegree : degree p ≤ natDegree p :=
WithBot.giUnbotDBot.gc.le_u_l _
theorem natDegree_eq_of_degree_eq [Semiring S] {q : S[X]} (h : degree p = degree q) :
natDegree p = natDegree q := by unfold natDegree; rw [h]
theorem le_degree_of_ne_zero (h : coeff p n ≠ 0) : (n : WithBot ℕ) ≤ degree p := by
rw [Nat.cast_withBot]
exact Finset.le_sup (mem_support_iff.2 h)
theorem degree_mono [Semiring S] {f : R[X]} {g : S[X]} (h : f.support ⊆ g.support) :
f.degree ≤ g.degree :=
Finset.sup_mono h
| Mathlib/Algebra/Polynomial/Degree/Definitions.lean | 128 | 129 | theorem degree_le_degree (h : coeff q (natDegree p) ≠ 0) : degree p ≤ degree q := by | by_cases hp : p = 0 |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Joey van Langen, Casper Putz
-/
import Mathlib.Algebra.CharP.Algebra
import Mathlib.Algebra.CharP.Reduced
import Mathlib.Algebra.Field.ZMod
import Mathlib.Data.Nat.Prime.Int
import Mathlib.Data.ZMod.ValMinAbs
import Mathlib.LinearAlgebra.FreeModule.Finite.Matrix
import Mathlib.FieldTheory.Finiteness
import Mathlib.FieldTheory.Perfect
import Mathlib.FieldTheory.Separable
import Mathlib.RingTheory.IntegralDomain
/-!
# Finite fields
This file contains basic results about finite fields.
Throughout most of this file, `K` denotes a finite field
and `q` is notation for the cardinality of `K`.
See `RingTheory.IntegralDomain` for the fact that the unit group of a finite field is a
cyclic group, as well as the fact that every finite integral domain is a field
(`Fintype.fieldOfDomain`).
## Main results
1. `Fintype.card_units`: The unit group of a finite field has cardinality `q - 1`.
2. `sum_pow_units`: The sum of `x^i`, where `x` ranges over the units of `K`, is
- `q-1` if `q-1 ∣ i`
- `0` otherwise
3. `FiniteField.card`: The cardinality `q` is a power of the characteristic of `K`.
See `FiniteField.card'` for a variant.
## Notation
Throughout most of this file, `K` denotes a finite field
and `q` is notation for the cardinality of `K`.
## Implementation notes
While `Fintype Kˣ` can be inferred from `Fintype K` in the presence of `DecidableEq K`,
in this file we take the `Fintype Kˣ` argument directly to reduce the chance of typeclass
diamonds, as `Fintype` carries data.
-/
variable {K : Type*} {R : Type*}
local notation "q" => Fintype.card K
open Finset
open scoped Polynomial
namespace FiniteField
section Polynomial
variable [CommRing R] [IsDomain R]
open Polynomial
/-- The cardinality of a field is at most `n` times the cardinality of the image of a degree `n`
polynomial -/
theorem card_image_polynomial_eval [DecidableEq R] [Fintype R] {p : R[X]} (hp : 0 < p.degree) :
Fintype.card R ≤ natDegree p * #(univ.image fun x => eval x p) :=
Finset.card_le_mul_card_image _ _ (fun a _ =>
calc
_ = #(p - C a).roots.toFinset :=
congr_arg card (by simp [Finset.ext_iff, ← mem_roots_sub_C hp])
_ ≤ Multiset.card (p - C a).roots := Multiset.toFinset_card_le _
_ ≤ _ := card_roots_sub_C' hp)
/-- If `f` and `g` are quadratic polynomials, then the `f.eval a + g.eval b = 0` has a solution. -/
theorem exists_root_sum_quadratic [Fintype R] {f g : R[X]} (hf2 : degree f = 2) (hg2 : degree g = 2)
(hR : Fintype.card R % 2 = 1) : ∃ a b, f.eval a + g.eval b = 0 :=
letI := Classical.decEq R
suffices ¬Disjoint (univ.image fun x : R => eval x f)
(univ.image fun x : R => eval x (-g)) by
simp only [disjoint_left, mem_image] at this
push_neg at this
rcases this with ⟨x, ⟨a, _, ha⟩, ⟨b, _, hb⟩⟩
exact ⟨a, b, by rw [ha, ← hb, eval_neg, neg_add_cancel]⟩
fun hd : Disjoint _ _ =>
lt_irrefl (2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g))) <|
calc 2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g))
≤ 2 * Fintype.card R := Nat.mul_le_mul_left _ (Finset.card_le_univ _)
_ = Fintype.card R + Fintype.card R := two_mul _
_ < natDegree f * #(univ.image fun x : R => eval x f) +
natDegree (-g) * #(univ.image fun x : R => eval x (-g)) :=
(add_lt_add_of_lt_of_le
(lt_of_le_of_ne (card_image_polynomial_eval (by rw [hf2]; decide))
(mt (congr_arg (· % 2)) (by simp [natDegree_eq_of_degree_eq_some hf2, hR])))
(card_image_polynomial_eval (by rw [degree_neg, hg2]; decide)))
_ = 2 * #((univ.image fun x : R => eval x f) ∪ univ.image fun x : R => eval x (-g)) := by
rw [card_union_of_disjoint hd]
simp [natDegree_eq_of_degree_eq_some hf2, natDegree_eq_of_degree_eq_some hg2, mul_add]
end Polynomial
theorem prod_univ_units_id_eq_neg_one [CommRing K] [IsDomain K] [Fintype Kˣ] :
∏ x : Kˣ, x = (-1 : Kˣ) := by
classical
have : (∏ x ∈ (@univ Kˣ _).erase (-1), x) = 1 :=
prod_involution (fun x _ => x⁻¹) (by simp)
(fun a => by simp +contextual [Units.inv_eq_self_iff])
(fun a => by simp [@inv_eq_iff_eq_inv _ _ a]) (by simp)
rw [← insert_erase (mem_univ (-1 : Kˣ)), prod_insert (not_mem_erase _ _), this, mul_one]
theorem card_cast_subgroup_card_ne_zero [Ring K] [NoZeroDivisors K] [Nontrivial K]
(G : Subgroup Kˣ) [Fintype G] : (Fintype.card G : K) ≠ 0 := by
let n := Fintype.card G
intro nzero
have ⟨p, char_p⟩ := CharP.exists K
have hd : p ∣ n := (CharP.cast_eq_zero_iff K p n).mp nzero
cases CharP.char_is_prime_or_zero K p with
| inr pzero =>
exact (Fintype.card_pos).ne' <| Nat.eq_zero_of_zero_dvd <| pzero ▸ hd
| inl pprime =>
have fact_pprime := Fact.mk pprime
-- G has an element x of order p by Cauchy's theorem
have ⟨x, hx⟩ := exists_prime_orderOf_dvd_card p hd
-- F has an element u (= ↑↑x) of order p
let u := ((x : Kˣ) : K)
have hu : orderOf u = p := by rwa [orderOf_units, Subgroup.orderOf_coe]
-- u ^ p = 1 implies (u - 1) ^ p = 0 and hence u = 1 ...
have h : u = 1 := by
rw [← sub_left_inj, sub_self 1]
apply pow_eq_zero (n := p)
rw [sub_pow_char_of_commute, one_pow, ← hu, pow_orderOf_eq_one, sub_self]
exact Commute.one_right u
-- ... meaning x didn't have order p after all, contradiction
apply pprime.one_lt.ne
rw [← hu, h, orderOf_one]
/-- The sum of a nontrivial subgroup of the units of a field is zero. -/
theorem sum_subgroup_units_eq_zero [Ring K] [NoZeroDivisors K]
{G : Subgroup Kˣ} [Fintype G] (hg : G ≠ ⊥) :
∑ x : G, (x.val : K) = 0 := by
rw [Subgroup.ne_bot_iff_exists_ne_one] at hg
rcases hg with ⟨a, ha⟩
-- The action of a on G as an embedding
let a_mul_emb : G ↪ G := mulLeftEmbedding a
-- ... and leaves G unchanged
have h_unchanged : Finset.univ.map a_mul_emb = Finset.univ := by simp
-- Therefore the sum of x over a G is the sum of a x over G
have h_sum_map := Finset.univ.sum_map a_mul_emb fun x => ((x : Kˣ) : K)
-- ... and the former is the sum of x over G.
-- By algebraic manipulation, we have Σ G, x = ∑ G, a x = a ∑ G, x
simp only [h_unchanged, mulLeftEmbedding_apply, Subgroup.coe_mul, Units.val_mul, ← mul_sum,
a_mul_emb] at h_sum_map
-- thus one of (a - 1) or ∑ G, x is zero
have hzero : (((a : Kˣ) : K) - 1) = 0 ∨ ∑ x : ↥G, ((x : Kˣ) : K) = 0 := by
rw [← mul_eq_zero, sub_mul, ← h_sum_map, one_mul, sub_self]
apply Or.resolve_left hzero
contrapose! ha
ext
rwa [← sub_eq_zero]
/-- The sum of a subgroup of the units of a field is 1 if the subgroup is trivial and 1 otherwise -/
@[simp]
theorem sum_subgroup_units [Ring K] [NoZeroDivisors K]
{G : Subgroup Kˣ} [Fintype G] [Decidable (G = ⊥)] :
∑ x : G, (x.val : K) = if G = ⊥ then 1 else 0 := by
by_cases G_bot : G = ⊥
· subst G_bot
simp only [univ_unique, sum_singleton, ↓reduceIte, Units.val_eq_one, OneMemClass.coe_eq_one]
rw [Set.default_coe_singleton]
rfl
· simp only [G_bot, ite_false]
exact sum_subgroup_units_eq_zero G_bot
@[simp]
| Mathlib/FieldTheory/Finite/Basic.lean | 178 | 209 | theorem sum_subgroup_pow_eq_zero [CommRing K] [NoZeroDivisors K]
{G : Subgroup Kˣ} [Fintype G] {k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Fintype.card G) :
∑ x : G, ((x : Kˣ) : K) ^ k = 0 := by | rw [← Nat.card_eq_fintype_card] at k_lt_card_G
nontriviality K
have := NoZeroDivisors.to_isDomain K
rcases (exists_pow_ne_one_of_isCyclic k_pos k_lt_card_G) with ⟨a, ha⟩
rw [Finset.sum_eq_multiset_sum]
have h_multiset_map :
Finset.univ.val.map (fun x : G => ((x : Kˣ) : K) ^ k) =
Finset.univ.val.map (fun x : G => ((x : Kˣ) : K) ^ k * ((a : Kˣ) : K) ^ k) := by
simp_rw [← mul_pow]
have as_comp :
(fun x : ↥G => (((x : Kˣ) : K) * ((a : Kˣ) : K)) ^ k)
= (fun x : ↥G => ((x : Kˣ) : K) ^ k) ∘ fun x : ↥G => x * a := by
funext x
simp only [Function.comp_apply, Subgroup.coe_mul, Units.val_mul]
rw [as_comp, ← Multiset.map_map]
congr
rw [eq_comm]
exact Multiset.map_univ_val_equiv (Equiv.mulRight a)
have h_multiset_map_sum : (Multiset.map (fun x : G => ((x : Kˣ) : K) ^ k) Finset.univ.val).sum =
(Multiset.map (fun x : G => ((x : Kˣ) : K) ^ k * ((a : Kˣ) : K) ^ k) Finset.univ.val).sum := by
rw [h_multiset_map]
rw [Multiset.sum_map_mul_right] at h_multiset_map_sum
have hzero : (((a : Kˣ) : K) ^ k - 1 : K)
* (Multiset.map (fun i : G => (i.val : K) ^ k) Finset.univ.val).sum = 0 := by
rw [sub_mul, mul_comm, ← h_multiset_map_sum, one_mul, sub_self]
rw [mul_eq_zero] at hzero
refine hzero.resolve_left fun h => ha ?_
ext
rw [← sub_eq_zero] |
/-
Copyright (c) 2021 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Bhavik Mehta
-/
import Mathlib.Combinatorics.SetFamily.Shadow
/-!
# UV-compressions
This file defines UV-compression. It is an operation on a set family that reduces its shadow.
UV-compressing `a : α` along `u v : α` means replacing `a` by `(a ⊔ u) \ v` if `a` and `u` are
disjoint and `v ≤ a`. In some sense, it's moving `a` from `v` to `u`.
UV-compressions are immensely useful to prove the Kruskal-Katona theorem. The idea is that
compressing a set family might decrease the size of its shadow, so iterated compressions hopefully
minimise the shadow.
## Main declarations
* `UV.compress`: `compress u v a` is `a` compressed along `u` and `v`.
* `UV.compression`: `compression u v s` is the compression of the set family `s` along `u` and `v`.
It is the compressions of the elements of `s` whose compression is not already in `s` along with
the element whose compression is already in `s`. This way of splitting into what moves and what
does not ensures the compression doesn't squash the set family, which is proved by
`UV.card_compression`.
* `UV.card_shadow_compression_le`: Compressing reduces the size of the shadow. This is a key fact in
the proof of Kruskal-Katona.
## Notation
`𝓒` (typed with `\MCC`) is notation for `UV.compression` in locale `FinsetFamily`.
## Notes
Even though our emphasis is on `Finset α`, we define UV-compressions more generally in a generalized
boolean algebra, so that one can use it for `Set α`.
## References
* https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf
## Tags
compression, UV-compression, shadow
-/
open Finset
variable {α : Type*}
/-- UV-compression is injective on the elements it moves. See `UV.compress`. -/
theorem sup_sdiff_injOn [GeneralizedBooleanAlgebra α] (u v : α) :
{ x | Disjoint u x ∧ v ≤ x }.InjOn fun x => (x ⊔ u) \ v := by
rintro a ha b hb hab
have h : ((a ⊔ u) \ v) \ u ⊔ v = ((b ⊔ u) \ v) \ u ⊔ v := by
dsimp at hab
rw [hab]
rwa [sdiff_sdiff_comm, ha.1.symm.sup_sdiff_cancel_right, sdiff_sdiff_comm,
hb.1.symm.sup_sdiff_cancel_right, sdiff_sup_cancel ha.2, sdiff_sup_cancel hb.2] at h
-- The namespace is here to distinguish from other compressions.
namespace UV
/-! ### UV-compression in generalized boolean algebras -/
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α] [DecidableRel (@Disjoint α _ _)]
[DecidableLE α] {s : Finset α} {u v a : α}
/-- UV-compressing `a` means removing `v` from it and adding `u` if `a` and `u` are disjoint and
`v ≤ a` (it replaces the `v` part of `a` by the `u` part). Else, UV-compressing `a` doesn't do
anything. This is most useful when `u` and `v` are disjoint finsets of the same size. -/
def compress (u v a : α) : α :=
if Disjoint u a ∧ v ≤ a then (a ⊔ u) \ v else a
theorem compress_of_disjoint_of_le (hua : Disjoint u a) (hva : v ≤ a) :
compress u v a = (a ⊔ u) \ v :=
if_pos ⟨hua, hva⟩
theorem compress_of_disjoint_of_le' (hva : Disjoint v a) (hua : u ≤ a) :
compress u v ((a ⊔ v) \ u) = a := by
rw [compress_of_disjoint_of_le disjoint_sdiff_self_right
(le_sdiff.2 ⟨(le_sup_right : v ≤ a ⊔ v), hva.mono_right hua⟩),
sdiff_sup_cancel (le_sup_of_le_left hua), hva.symm.sup_sdiff_cancel_right]
@[simp]
theorem compress_self (u a : α) : compress u u a = a := by
unfold compress
split_ifs with h
· exact h.1.symm.sup_sdiff_cancel_right
· rfl
/-- An element can be compressed to any other element by removing/adding the differences. -/
@[simp]
theorem compress_sdiff_sdiff (a b : α) : compress (a \ b) (b \ a) b = a := by
refine (compress_of_disjoint_of_le disjoint_sdiff_self_left sdiff_le).trans ?_
rw [sup_sdiff_self_right, sup_sdiff, disjoint_sdiff_self_right.sdiff_eq_left, sup_eq_right]
exact sdiff_sdiff_le
/-- Compressing an element is idempotent. -/
@[simp]
| Mathlib/Combinatorics/SetFamily/Compression/UV.lean | 107 | 110 | theorem compress_idem (u v a : α) : compress u v (compress u v a) = compress u v a := by | unfold compress
split_ifs with h h'
· rw [le_sdiff_right.1 h'.2, sdiff_bot, sdiff_bot, sup_assoc, sup_idem] |
/-
Copyright (c) 2014 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis, Leonardo de Moura, Mario Carneiro, Floris van Doorn
-/
import Mathlib.Algebra.Field.Basic
import Mathlib.Algebra.GroupWithZero.Units.Lemmas
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Order.Bounds.Basic
import Mathlib.Order.Bounds.OrderIso
import Mathlib.Tactic.Positivity.Core
/-!
# Lemmas about linear ordered (semi)fields
-/
open Function OrderDual
variable {ι α β : Type*}
section LinearOrderedSemifield
variable [Semifield α] [LinearOrder α] [IsStrictOrderedRing α] {a b c d e : α} {m n : ℤ}
/-!
### Relating two divisions.
-/
@[deprecated div_le_div_iff_of_pos_right (since := "2024-11-12")]
theorem div_le_div_right (hc : 0 < c) : a / c ≤ b / c ↔ a ≤ b := div_le_div_iff_of_pos_right hc
@[deprecated div_lt_div_iff_of_pos_right (since := "2024-11-12")]
theorem div_lt_div_right (hc : 0 < c) : a / c < b / c ↔ a < b := div_lt_div_iff_of_pos_right hc
@[deprecated div_lt_div_iff_of_pos_left (since := "2024-11-13")]
theorem div_lt_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b < a / c ↔ c < b :=
div_lt_div_iff_of_pos_left ha hb hc
@[deprecated div_le_div_iff_of_pos_left (since := "2024-11-12")]
theorem div_le_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b ≤ a / c ↔ c ≤ b :=
div_le_div_iff_of_pos_left ha hb hc
@[deprecated div_lt_div_iff₀ (since := "2024-11-12")]
theorem div_lt_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b < c / d ↔ a * d < c * b :=
div_lt_div_iff₀ b0 d0
@[deprecated div_le_div_iff₀ (since := "2024-11-12")]
theorem div_le_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b ≤ c / d ↔ a * d ≤ c * b :=
div_le_div_iff₀ b0 d0
@[deprecated div_le_div₀ (since := "2024-11-12")]
theorem div_le_div (hc : 0 ≤ c) (hac : a ≤ c) (hd : 0 < d) (hbd : d ≤ b) : a / b ≤ c / d :=
div_le_div₀ hc hac hd hbd
@[deprecated div_lt_div₀ (since := "2024-11-12")]
theorem div_lt_div (hac : a < c) (hbd : d ≤ b) (c0 : 0 ≤ c) (d0 : 0 < d) : a / b < c / d :=
div_lt_div₀ hac hbd c0 d0
@[deprecated div_lt_div₀' (since := "2024-11-12")]
theorem div_lt_div' (hac : a ≤ c) (hbd : d < b) (c0 : 0 < c) (d0 : 0 < d) : a / b < c / d :=
div_lt_div₀' hac hbd c0 d0
/-!
### Relating one division and involving `1`
-/
@[bound]
theorem div_le_self (ha : 0 ≤ a) (hb : 1 ≤ b) : a / b ≤ a := by
simpa only [div_one] using div_le_div_of_nonneg_left ha zero_lt_one hb
@[bound]
theorem div_lt_self (ha : 0 < a) (hb : 1 < b) : a / b < a := by
simpa only [div_one] using div_lt_div_of_pos_left ha zero_lt_one hb
@[bound]
theorem le_div_self (ha : 0 ≤ a) (hb₀ : 0 < b) (hb₁ : b ≤ 1) : a ≤ a / b := by
simpa only [div_one] using div_le_div_of_nonneg_left ha hb₀ hb₁
theorem one_le_div (hb : 0 < b) : 1 ≤ a / b ↔ b ≤ a := by rw [le_div_iff₀ hb, one_mul]
theorem div_le_one (hb : 0 < b) : a / b ≤ 1 ↔ a ≤ b := by rw [div_le_iff₀ hb, one_mul]
theorem one_lt_div (hb : 0 < b) : 1 < a / b ↔ b < a := by rw [lt_div_iff₀ hb, one_mul]
theorem div_lt_one (hb : 0 < b) : a / b < 1 ↔ a < b := by rw [div_lt_iff₀ hb, one_mul]
theorem one_div_le (ha : 0 < a) (hb : 0 < b) : 1 / a ≤ b ↔ 1 / b ≤ a := by
simpa using inv_le_comm₀ ha hb
theorem one_div_lt (ha : 0 < a) (hb : 0 < b) : 1 / a < b ↔ 1 / b < a := by
simpa using inv_lt_comm₀ ha hb
theorem le_one_div (ha : 0 < a) (hb : 0 < b) : a ≤ 1 / b ↔ b ≤ 1 / a := by
simpa using le_inv_comm₀ ha hb
theorem lt_one_div (ha : 0 < a) (hb : 0 < b) : a < 1 / b ↔ b < 1 / a := by
simpa using lt_inv_comm₀ ha hb
@[bound] lemma Bound.one_lt_div_of_pos_of_lt (b0 : 0 < b) : b < a → 1 < a / b := (one_lt_div b0).mpr
@[bound] lemma Bound.div_lt_one_of_pos_of_lt (b0 : 0 < b) : a < b → a / b < 1 := (div_lt_one b0).mpr
/-!
### Relating two divisions, involving `1`
-/
| Mathlib/Algebra/Order/Field/Basic.lean | 110 | 110 | theorem one_div_le_one_div_of_le (ha : 0 < a) (h : a ≤ b) : 1 / b ≤ 1 / a := by | |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
/-!
# Limits and asymptotics of power functions at `+∞`
This file contains results about the limiting behaviour of power functions at `+∞`. For convenience
some results on asymptotics as `x → 0` (those which are not just continuity statements) are also
located here.
-/
noncomputable section
open Real Topology NNReal ENNReal Filter ComplexConjugate Finset Set
/-!
## Limits at `+∞`
-/
section Limits
open Real Filter
/-- The function `x ^ y` tends to `+∞` at `+∞` for any positive real `y`. -/
theorem tendsto_rpow_atTop {y : ℝ} (hy : 0 < y) : Tendsto (fun x : ℝ => x ^ y) atTop atTop := by
rw [(atTop_basis' 0).tendsto_right_iff]
intro b hb
filter_upwards [eventually_ge_atTop 0, eventually_ge_atTop (b ^ (1 / y))] with x hx₀ hx
simpa (disch := positivity) [Real.rpow_inv_le_iff_of_pos] using hx
/-- The function `x ^ (-y)` tends to `0` at `+∞` for any positive real `y`. -/
theorem tendsto_rpow_neg_atTop {y : ℝ} (hy : 0 < y) : Tendsto (fun x : ℝ => x ^ (-y)) atTop (𝓝 0) :=
Tendsto.congr' (eventuallyEq_of_mem (Ioi_mem_atTop 0) fun _ hx => (rpow_neg (le_of_lt hx) y).symm)
(tendsto_rpow_atTop hy).inv_tendsto_atTop
open Asymptotics in
lemma tendsto_rpow_atTop_of_base_lt_one (b : ℝ) (hb₀ : -1 < b) (hb₁ : b < 1) :
Tendsto (b ^ · : ℝ → ℝ) atTop (𝓝 (0 : ℝ)) := by
rcases lt_trichotomy b 0 with hb|rfl|hb
case inl => -- b < 0
simp_rw [Real.rpow_def_of_nonpos hb.le, hb.ne, ite_false]
rw [← isLittleO_const_iff (c := (1 : ℝ)) one_ne_zero, (one_mul (1 : ℝ)).symm]
refine IsLittleO.mul_isBigO ?exp ?cos
case exp =>
rw [isLittleO_const_iff one_ne_zero]
refine tendsto_exp_atBot.comp <| (tendsto_const_mul_atBot_of_neg ?_).mpr tendsto_id
rw [← log_neg_eq_log, log_neg_iff (by linarith)]
linarith
case cos =>
rw [isBigO_iff]
exact ⟨1, Eventually.of_forall fun x => by simp [Real.abs_cos_le_one]⟩
case inr.inl => -- b = 0
refine Tendsto.mono_right ?_ (Iff.mpr pure_le_nhds_iff rfl)
rw [tendsto_pure]
filter_upwards [eventually_ne_atTop 0] with _ hx
simp [hx]
case inr.inr => -- b > 0
simp_rw [Real.rpow_def_of_pos hb]
refine tendsto_exp_atBot.comp <| (tendsto_const_mul_atBot_of_neg ?_).mpr tendsto_id
exact (log_neg_iff hb).mpr hb₁
lemma tendsto_rpow_atTop_of_base_gt_one (b : ℝ) (hb : 1 < b) :
Tendsto (b ^ · : ℝ → ℝ) atBot (𝓝 (0 : ℝ)) := by
simp_rw [Real.rpow_def_of_pos (by positivity : 0 < b)]
refine tendsto_exp_atBot.comp <| (tendsto_const_mul_atBot_of_pos ?_).mpr tendsto_id
exact (log_pos_iff (by positivity)).mpr <| by aesop
lemma tendsto_rpow_atBot_of_base_lt_one (b : ℝ) (hb₀ : 0 < b) (hb₁ : b < 1) :
Tendsto (b ^ · : ℝ → ℝ) atBot atTop := by
simp_rw [Real.rpow_def_of_pos (by positivity : 0 < b)]
refine tendsto_exp_atTop.comp <| (tendsto_const_mul_atTop_iff_neg <| tendsto_id (α := ℝ)).mpr ?_
exact (log_neg_iff hb₀).mpr hb₁
lemma tendsto_rpow_atBot_of_base_gt_one (b : ℝ) (hb : 1 < b) :
Tendsto (b ^ · : ℝ → ℝ) atBot (𝓝 0) := by
simp_rw [Real.rpow_def_of_pos (by positivity : 0 < b)]
refine tendsto_exp_atBot.comp <| (tendsto_const_mul_atBot_iff_pos <| tendsto_id (α := ℝ)).mpr ?_
exact (log_pos_iff (by positivity)).mpr <| by aesop
/-- The function `x ^ (a / (b * x + c))` tends to `1` at `+∞`, for any real numbers `a`, `b`, and
`c` such that `b` is nonzero. -/
theorem tendsto_rpow_div_mul_add (a b c : ℝ) (hb : 0 ≠ b) :
Tendsto (fun x => x ^ (a / (b * x + c))) atTop (𝓝 1) := by
refine
Tendsto.congr' ?_
((tendsto_exp_nhds_zero_nhds_one.comp
(by
simpa only [mul_zero, pow_one] using
(tendsto_const_nhds (x := a)).mul
(tendsto_div_pow_mul_exp_add_atTop b c 1 hb))).comp
tendsto_log_atTop)
apply eventuallyEq_of_mem (Ioi_mem_atTop (0 : ℝ))
intro x hx
simp only [Set.mem_Ioi, Function.comp_apply] at hx ⊢
rw [exp_log hx, ← exp_log (rpow_pos_of_pos hx (a / (b * x + c))), log_rpow hx (a / (b * x + c))]
field_simp
/-- The function `x ^ (1 / x)` tends to `1` at `+∞`. -/
theorem tendsto_rpow_div : Tendsto (fun x => x ^ ((1 : ℝ) / x)) atTop (𝓝 1) := by
convert tendsto_rpow_div_mul_add (1 : ℝ) _ (0 : ℝ) zero_ne_one
ring
/-- The function `x ^ (-1 / x)` tends to `1` at `+∞`. -/
theorem tendsto_rpow_neg_div : Tendsto (fun x => x ^ (-(1 : ℝ) / x)) atTop (𝓝 1) := by
convert tendsto_rpow_div_mul_add (-(1 : ℝ)) _ (0 : ℝ) zero_ne_one
ring
/-- The function `exp(x) / x ^ s` tends to `+∞` at `+∞`, for any real number `s`. -/
theorem tendsto_exp_div_rpow_atTop (s : ℝ) : Tendsto (fun x : ℝ => exp x / x ^ s) atTop atTop := by
obtain ⟨n, hn⟩ := archimedean_iff_nat_lt.1 Real.instArchimedean s
refine tendsto_atTop_mono' _ ?_ (tendsto_exp_div_pow_atTop n)
filter_upwards [eventually_gt_atTop (0 : ℝ), eventually_ge_atTop (1 : ℝ)] with x hx₀ hx₁
gcongr
simpa using rpow_le_rpow_of_exponent_le hx₁ hn.le
/-- The function `exp (b * x) / x ^ s` tends to `+∞` at `+∞`, for any real `s` and `b > 0`. -/
theorem tendsto_exp_mul_div_rpow_atTop (s : ℝ) (b : ℝ) (hb : 0 < b) :
Tendsto (fun x : ℝ => exp (b * x) / x ^ s) atTop atTop := by
refine ((tendsto_rpow_atTop hb).comp (tendsto_exp_div_rpow_atTop (s / b))).congr' ?_
filter_upwards [eventually_ge_atTop (0 : ℝ)] with x hx₀
simp [Real.div_rpow, (exp_pos x).le, rpow_nonneg, ← Real.rpow_mul, ← exp_mul,
mul_comm x, hb.ne', *]
/-- The function `x ^ s * exp (-b * x)` tends to `0` at `+∞`, for any real `s` and `b > 0`. -/
theorem tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (s : ℝ) (b : ℝ) (hb : 0 < b) :
Tendsto (fun x : ℝ => x ^ s * exp (-b * x)) atTop (𝓝 0) := by
refine (tendsto_exp_mul_div_rpow_atTop s b hb).inv_tendsto_atTop.congr' ?_
filter_upwards with x using by simp [exp_neg, inv_div, div_eq_mul_inv _ (exp _)]
nonrec theorem NNReal.tendsto_rpow_atTop {y : ℝ} (hy : 0 < y) :
Tendsto (fun x : ℝ≥0 => x ^ y) atTop atTop := by
rw [Filter.tendsto_atTop_atTop]
intro b
obtain ⟨c, hc⟩ := tendsto_atTop_atTop.mp (tendsto_rpow_atTop hy) b
use c.toNNReal
intro a ha
exact mod_cast hc a (Real.toNNReal_le_iff_le_coe.mp ha)
theorem ENNReal.tendsto_rpow_at_top {y : ℝ} (hy : 0 < y) :
Tendsto (fun x : ℝ≥0∞ => x ^ y) (𝓝 ⊤) (𝓝 ⊤) := by
rw [ENNReal.tendsto_nhds_top_iff_nnreal]
intro x
obtain ⟨c, _, hc⟩ :=
(atTop_basis_Ioi.tendsto_iff atTop_basis_Ioi).mp (NNReal.tendsto_rpow_atTop hy) x trivial
have hc' : Set.Ioi ↑c ∈ 𝓝 (⊤ : ℝ≥0∞) := Ioi_mem_nhds ENNReal.coe_lt_top
filter_upwards [hc'] with a ha
by_cases ha' : a = ⊤
· simp [ha', hy]
lift a to ℝ≥0 using ha'
simp only [Set.mem_Ioi, coe_lt_coe] at ha hc
rw [← ENNReal.coe_rpow_of_nonneg _ hy.le]
exact mod_cast hc a ha
end Limits
/-!
## Asymptotic results: `IsBigO`, `IsLittleO` and `IsTheta`
-/
namespace Complex
section
variable {α : Type*} {l : Filter α} {f g : α → ℂ}
open Asymptotics
theorem isTheta_exp_arg_mul_im (hl : IsBoundedUnder (· ≤ ·) l fun x => |(g x).im|) :
(fun x => Real.exp (arg (f x) * im (g x))) =Θ[l] fun _ => (1 : ℝ) := by
rcases hl with ⟨b, hb⟩
refine Real.isTheta_exp_comp_one.2 ⟨π * b, ?_⟩
rw [eventually_map] at hb ⊢
refine hb.mono fun x hx => ?_
rw [abs_mul]
exact mul_le_mul (abs_arg_le_pi _) hx (abs_nonneg _) Real.pi_pos.le
theorem isBigO_cpow_rpow (hl : IsBoundedUnder (· ≤ ·) l fun x => |(g x).im|) :
(fun x => f x ^ g x) =O[l] fun x => ‖f x‖ ^ (g x).re :=
calc
(fun x => f x ^ g x) =O[l]
(show α → ℝ from fun x => ‖f x‖ ^ (g x).re / Real.exp (arg (f x) * im (g x))) :=
isBigO_of_le _ fun _ => (norm_cpow_le _ _).trans (le_abs_self _)
_ =Θ[l] (show α → ℝ from fun x => ‖f x‖ ^ (g x).re / (1 : ℝ)) :=
((isTheta_refl _ _).div (isTheta_exp_arg_mul_im hl))
_ =ᶠ[l] (show α → ℝ from fun x => ‖f x‖ ^ (g x).re) := by
simp only [ofReal_one, div_one, EventuallyEq.rfl]
theorem isTheta_cpow_rpow (hl_im : IsBoundedUnder (· ≤ ·) l fun x => |(g x).im|)
(hl : ∀ᶠ x in l, f x = 0 → re (g x) = 0 → g x = 0) :
(fun x => f x ^ g x) =Θ[l] fun x => ‖f x‖ ^ (g x).re :=
calc
(fun x => f x ^ g x) =Θ[l]
(fun x => ‖f x‖ ^ (g x).re / Real.exp (arg (f x) * im (g x))) :=
.of_norm_eventuallyEq <| hl.mono fun _ => norm_cpow_of_imp
_ =Θ[l] fun x => ‖f x‖ ^ (g x).re / (1 : ℝ) :=
(isTheta_refl _ _).div (isTheta_exp_arg_mul_im hl_im)
_ =ᶠ[l] (fun x => ‖f x‖ ^ (g x).re) := by
simp only [ofReal_one, div_one, EventuallyEq.rfl]
theorem isTheta_cpow_const_rpow {b : ℂ} (hl : b.re = 0 → b ≠ 0 → ∀ᶠ x in l, f x ≠ 0) :
(fun x => f x ^ b) =Θ[l] fun x => ‖f x‖ ^ b.re :=
isTheta_cpow_rpow isBoundedUnder_const <| by
simpa only [eventually_imp_distrib_right, not_imp_not, Imp.swap (a := b.re = 0)] using hl
end
end Complex
open Real
namespace Asymptotics
variable {α : Type*} {r c : ℝ} {l : Filter α} {f g : α → ℝ}
theorem IsBigOWith.rpow (h : IsBigOWith c l f g) (hc : 0 ≤ c) (hr : 0 ≤ r) (hg : 0 ≤ᶠ[l] g) :
IsBigOWith (c ^ r) l (fun x => f x ^ r) fun x => g x ^ r := by
apply IsBigOWith.of_bound
filter_upwards [hg, h.bound] with x hgx hx
calc
|f x ^ r| ≤ |f x| ^ r := abs_rpow_le_abs_rpow _ _
_ ≤ (c * |g x|) ^ r := rpow_le_rpow (abs_nonneg _) hx hr
_ = c ^ r * |g x ^ r| := by rw [mul_rpow hc (abs_nonneg _), abs_rpow_of_nonneg hgx]
theorem IsBigO.rpow (hr : 0 ≤ r) (hg : 0 ≤ᶠ[l] g) (h : f =O[l] g) :
(fun x => f x ^ r) =O[l] fun x => g x ^ r :=
let ⟨_, hc, h'⟩ := h.exists_nonneg
(h'.rpow hc hr hg).isBigO
theorem IsTheta.rpow (hr : 0 ≤ r) (hf : 0 ≤ᶠ[l] f) (hg : 0 ≤ᶠ[l] g) (h : f =Θ[l] g) :
(fun x => f x ^ r) =Θ[l] fun x => g x ^ r :=
⟨h.1.rpow hr hg, h.2.rpow hr hf⟩
theorem IsLittleO.rpow (hr : 0 < r) (hg : 0 ≤ᶠ[l] g) (h : f =o[l] g) :
(fun x => f x ^ r) =o[l] fun x => g x ^ r := by
refine .of_isBigOWith fun c hc ↦ ?_
rw [← rpow_inv_rpow hc.le hr.ne']
refine (h.forall_isBigOWith ?_).rpow ?_ ?_ hg <;> positivity
protected lemma IsBigO.sqrt (hfg : f =O[l] g) (hg : 0 ≤ᶠ[l] g) :
(Real.sqrt <| f ·) =O[l] (Real.sqrt <| g ·) := by
simpa [Real.sqrt_eq_rpow] using hfg.rpow one_half_pos.le hg
protected lemma IsLittleO.sqrt (hfg : f =o[l] g) (hg : 0 ≤ᶠ[l] g) :
(Real.sqrt <| f ·) =o[l] (Real.sqrt <| g ·) := by
simpa [Real.sqrt_eq_rpow] using hfg.rpow one_half_pos hg
protected lemma IsTheta.sqrt (hfg : f =Θ[l] g) (hf : 0 ≤ᶠ[l] f) (hg : 0 ≤ᶠ[l] g) :
(Real.sqrt <| f ·) =Θ[l] (Real.sqrt <| g ·) :=
⟨hfg.1.sqrt hg, hfg.2.sqrt hf⟩
theorem isBigO_atTop_natCast_rpow_of_tendsto_div_rpow {𝕜 : Type*} [RCLike 𝕜] {g : ℕ → 𝕜}
{a : 𝕜} {r : ℝ} (hlim : Tendsto (fun n ↦ g n / (n ^ r : ℝ)) atTop (𝓝 a)) :
g =O[atTop] fun n ↦ (n : ℝ) ^ r := by
refine (isBigO_of_div_tendsto_nhds ?_ ‖a‖ ?_).of_norm_left
· filter_upwards [eventually_ne_atTop 0] with _ h
simp [Real.rpow_eq_zero_iff_of_nonneg, h]
· exact hlim.norm.congr fun n ↦ by simp [abs_of_nonneg, show 0 ≤ (n : ℝ) ^ r by positivity]
variable {E : Type*} [SeminormedRing E] (a b c : ℝ)
theorem IsBigO.mul_atTop_rpow_of_isBigO_rpow {f g : ℝ → E}
(hf : f =O[atTop] fun t ↦ (t : ℝ) ^ a) (hg : g =O[atTop] fun t ↦ (t : ℝ) ^ b)
(h : a + b ≤ c) :
(f * g) =O[atTop] fun t ↦ (t : ℝ) ^ c := by
refine (hf.mul hg).trans (Eventually.isBigO ?_)
filter_upwards [eventually_ge_atTop 1] with t ht
rw [← Real.rpow_add (zero_lt_one.trans_le ht), Real.norm_of_nonneg (Real.rpow_nonneg
(zero_le_one.trans ht) (a + b))]
exact Real.rpow_le_rpow_of_exponent_le ht h
theorem IsBigO.mul_atTop_rpow_natCast_of_isBigO_rpow {f g : ℕ → E}
(hf : f =O[atTop] fun n ↦ (n : ℝ) ^ a) (hg : g =O[atTop] fun n ↦ (n : ℝ) ^ b)
(h : a + b ≤ c) :
(f * g) =O[atTop] fun n ↦ (n : ℝ) ^ c := by
refine (hf.mul hg).trans (Eventually.isBigO ?_)
filter_upwards [eventually_ge_atTop 1] with t ht
replace ht : 1 ≤ (t : ℝ) := Nat.one_le_cast.mpr ht
rw [← Real.rpow_add (zero_lt_one.trans_le ht), Real.norm_of_nonneg (Real.rpow_nonneg
(zero_le_one.trans ht) (a + b))]
exact Real.rpow_le_rpow_of_exponent_le ht h
end Asymptotics
open Asymptotics
/-- `x ^ s = o(exp(b * x))` as `x → ∞` for any real `s` and positive `b`. -/
theorem isLittleO_rpow_exp_pos_mul_atTop (s : ℝ) {b : ℝ} (hb : 0 < b) :
(fun x : ℝ => x ^ s) =o[atTop] fun x => exp (b * x) :=
isLittleO_of_tendsto (fun _ h => absurd h (exp_pos _).ne') <| by
simpa only [div_eq_mul_inv, exp_neg, neg_mul] using
tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero s b hb
/-- `x ^ k = o(exp(b * x))` as `x → ∞` for any integer `k` and positive `b`. -/
theorem isLittleO_zpow_exp_pos_mul_atTop (k : ℤ) {b : ℝ} (hb : 0 < b) :
(fun x : ℝ => x ^ k) =o[atTop] fun x => exp (b * x) := by
simpa only [Real.rpow_intCast] using isLittleO_rpow_exp_pos_mul_atTop k hb
/-- `x ^ k = o(exp(b * x))` as `x → ∞` for any natural `k` and positive `b`. -/
theorem isLittleO_pow_exp_pos_mul_atTop (k : ℕ) {b : ℝ} (hb : 0 < b) :
(fun x : ℝ => x ^ k) =o[atTop] fun x => exp (b * x) := by
simpa using isLittleO_zpow_exp_pos_mul_atTop k hb
/-- `x ^ s = o(exp x)` as `x → ∞` for any real `s`. -/
theorem isLittleO_rpow_exp_atTop (s : ℝ) : (fun x : ℝ => x ^ s) =o[atTop] exp := by
simpa only [one_mul] using isLittleO_rpow_exp_pos_mul_atTop s one_pos
/-- `exp (-a * x) = o(x ^ s)` as `x → ∞`, for any positive `a` and real `s`. -/
| Mathlib/Analysis/SpecialFunctions/Pow/Asymptotics.lean | 317 | 319 | theorem isLittleO_exp_neg_mul_rpow_atTop {a : ℝ} (ha : 0 < a) (b : ℝ) :
IsLittleO atTop (fun x : ℝ => exp (-a * x)) fun x : ℝ => x ^ b := by | apply isLittleO_of_tendsto' |
/-
Copyright (c) 2019 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Topology.Constructions
/-!
# Neighborhoods and continuity relative to a subset
This file develops API on the relative versions
* `nhdsWithin` of `nhds`
* `ContinuousOn` of `Continuous`
* `ContinuousWithinAt` of `ContinuousAt`
related to continuity, which are defined in previous definition files.
Their basic properties studied in this file include the relationships between
these restricted notions and the corresponding notions for the subtype
equipped with the subspace topology.
## Notation
* `𝓝 x`: the filter of neighborhoods of a point `x`;
* `𝓟 s`: the principal filter of a set `s`;
* `𝓝[s] x`: the filter `nhdsWithin x s` of neighborhoods of a point `x` within a set `s`.
-/
open Set Filter Function Topology Filter
variable {α β γ δ : Type*}
variable [TopologicalSpace α]
/-!
## Properties of the neighborhood-within filter
-/
@[simp]
theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a :=
bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl
@[simp]
theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x :=
Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x }
theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x :=
eventually_inf_principal
theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} :
(∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s :=
frequently_inf_principal.trans <| by simp only [and_comm]
theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} :
z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by
simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff]
@[simp]
theorem eventually_eventually_nhdsWithin {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by
refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩
simp only [eventually_nhdsWithin_iff] at h ⊢
exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs
@[simp]
theorem eventually_mem_nhdsWithin_iff {x : α} {s t : Set α} :
(∀ᶠ x' in 𝓝[s] x, t ∈ 𝓝[s] x') ↔ t ∈ 𝓝[s] x :=
eventually_eventually_nhdsWithin
theorem nhdsWithin_eq (a : α) (s : Set α) :
𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) :=
((nhds_basis_opens a).inf_principal s).eq_biInf
@[simp] lemma nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by
rw [nhdsWithin, principal_univ, inf_top_eq]
theorem nhdsWithin_hasBasis {ι : Sort*} {p : ι → Prop} {s : ι → Set α} {a : α}
(h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t :=
h.inf_principal t
theorem nhdsWithin_basis_open (a : α) (t : Set α) :
(𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t :=
nhdsWithin_hasBasis (nhds_basis_opens a) t
theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} :
t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by
simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff
theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} :
t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t :=
(nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff
theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) :
s \ t ∈ 𝓝[tᶜ] x :=
diff_mem_inf_principal_compl hs t
theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) :
s \ t' ∈ 𝓝[t \ t'] x := by
rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc]
exact inter_mem_inf hs (mem_principal_self _)
theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) :
t ∈ 𝓝 a := by
rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩
exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw
theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t :=
eventually_inf_principal
theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by
simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and]
theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t :=
set_eventuallyEq_iff_inf_principal.symm
theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x :=
set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal
theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t)
(hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) :
π ⁻¹' s ∈ 𝓝[t] a := by
lift a to t using h
replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs
rwa [← map_nhds_subtype_val, mem_map]
theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a :=
mem_inf_of_left h
theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a :=
mem_inf_of_right (mem_principal_self s)
theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s :=
self_mem_nhdsWithin
theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a :=
inter_mem self_mem_nhdsWithin (mem_inf_of_left h)
theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a :=
le_inf (pure_le_nhds a) (le_principal_iff.2 ha)
theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t :=
pure_le_nhdsWithin ha ht
theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α}
(h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x :=
mem_of_mem_nhdsWithin hx h
theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) :
Tendsto (fun _ : β => a) l (𝓝[s] a) :=
tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha
theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) :
𝓝[s] a = 𝓝[s ∩ t] a :=
le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h)))
(inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left))
theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict'' s <| mem_inf_of_left h
theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) :
𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀)
theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a :=
nhdsWithin_le_iff.mpr h
theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by
rw [← nhdsWithin_univ]
apply nhdsWithin_le_of_mem
exact univ_mem
theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) :
𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂]
theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s)
(h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by
rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂]
@[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a :=
inf_eq_left.trans le_principal_iff
theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a :=
nhdsWithin_eq_nhds.2 <| h.mem_nhds ha
theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t)
(ht : IsOpen t)
(hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) :
π ⁻¹' s ∈ 𝓝 a := by
rw [← ht.nhdsWithin_eq h]
exact preimage_nhdsWithin_coinduced' h hs
@[simp]
theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq]
theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by
delta nhdsWithin
rw [← inf_sup_left, sup_principal]
theorem nhds_eq_nhdsWithin_sup_nhdsWithin (b : α) {I₁ I₂ : Set α} (hI : Set.univ = I₁ ∪ I₂) :
nhds b = nhdsWithin b I₁ ⊔ nhdsWithin b I₂ := by
rw [← nhdsWithin_univ b, hI, nhdsWithin_union]
/-- If `L` and `R` are neighborhoods of `b` within sets whose union is `Set.univ`, then
`L ∪ R` is a neighborhood of `b`. -/
theorem union_mem_nhds_of_mem_nhdsWithin {b : α}
{I₁ I₂ : Set α} (h : Set.univ = I₁ ∪ I₂)
{L : Set α} (hL : L ∈ nhdsWithin b I₁)
{R : Set α} (hR : R ∈ nhdsWithin b I₂) : L ∪ R ∈ nhds b := by
rw [← nhdsWithin_univ b, h, nhdsWithin_union]
exact ⟨mem_of_superset hL (by simp), mem_of_superset hR (by simp)⟩
/-- Writing a punctured neighborhood filter as a sup of left and right filters. -/
lemma punctured_nhds_eq_nhdsWithin_sup_nhdsWithin [LinearOrder α] {x : α} :
𝓝[≠] x = 𝓝[<] x ⊔ 𝓝[>] x := by
rw [← Iio_union_Ioi, nhdsWithin_union]
/-- Obtain a "predictably-sided" neighborhood of `b` from two one-sided neighborhoods. -/
theorem nhds_of_Ici_Iic [LinearOrder α] {b : α}
{L : Set α} (hL : L ∈ 𝓝[≤] b)
{R : Set α} (hR : R ∈ 𝓝[≥] b) : L ∩ Iic b ∪ R ∩ Ici b ∈ 𝓝 b :=
union_mem_nhds_of_mem_nhdsWithin Iic_union_Ici.symm
(inter_mem hL self_mem_nhdsWithin) (inter_mem hR self_mem_nhdsWithin)
theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) :
𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := by
induction I, hI using Set.Finite.induction_on with
| empty => simp
| insert _ _ hT => simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert]
theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) :
𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by
rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS]
theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) :
𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by
rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range]
theorem nhdsWithin_inter (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓝[t] a := by
delta nhdsWithin
rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem]
theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by
delta nhdsWithin
rw [← inf_principal, inf_assoc]
theorem nhdsWithin_inter_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by
rw [nhdsWithin_inter, inf_eq_right]
exact nhdsWithin_le_of_mem h
theorem nhdsWithin_inter_of_mem' {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by
rw [inter_comm, nhdsWithin_inter_of_mem h]
@[simp]
theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by
rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)]
@[simp]
theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by
rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton]
theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by
simp
theorem insert_mem_nhdsWithin_insert {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) :
insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h]
theorem insert_mem_nhds_iff {a : α} {s : Set α} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[≠] a := by
simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left,
insert_def]
@[simp]
theorem nhdsNE_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by
rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ]
@[deprecated (since := "2025-03-02")]
alias nhdsWithin_compl_singleton_sup_pure := nhdsNE_sup_pure
@[simp]
theorem pure_sup_nhdsNE (a : α) : pure a ⊔ 𝓝[≠] a = 𝓝 a := by rw [← sup_comm, nhdsNE_sup_pure]
theorem nhdsWithin_prod [TopologicalSpace β]
{s u : Set α} {t v : Set β} {a : α} {b : β} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) :
u ×ˢ v ∈ 𝓝[s ×ˢ t] (a, b) := by
rw [nhdsWithin_prod_eq]
exact prod_mem_prod hu hv
lemma Filter.EventuallyEq.mem_interior {x : α} {s t : Set α} (hst : s =ᶠ[𝓝 x] t)
(h : x ∈ interior s) : x ∈ interior t := by
rw [← nhdsWithin_eq_iff_eventuallyEq] at hst
simpa [mem_interior_iff_mem_nhds, ← nhdsWithin_eq_nhds, hst] using h
lemma Filter.EventuallyEq.mem_interior_iff {x : α} {s t : Set α} (hst : s =ᶠ[𝓝 x] t) :
x ∈ interior s ↔ x ∈ interior t :=
⟨fun h ↦ hst.mem_interior h, fun h ↦ hst.symm.mem_interior h⟩
@[deprecated (since := "2024-11-11")]
alias EventuallyEq.mem_interior_iff := Filter.EventuallyEq.mem_interior_iff
section Pi
variable {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)]
theorem nhdsWithin_pi_eq' {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi I s] x = ⨅ i, comap (fun x => x i) (𝓝 (x i) ⊓ ⨅ (_ : i ∈ I), 𝓟 (s i)) := by
simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ←
iInf_principal_finite hI, ← iInf_inf_eq]
theorem nhdsWithin_pi_eq {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi I s] x =
(⨅ i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) ⊓
⨅ (i) (_ : i ∉ I), comap (fun x => x i) (𝓝 (x i)) := by
simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf,
comap_principal, eval]
rw [iInf_split _ fun i => i ∈ I, inf_right_comm]
simp only [iInf_inf_eq]
theorem nhdsWithin_pi_univ_eq [Finite ι] (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi univ s] x = ⨅ i, comap (fun x => x i) (𝓝[s i] x i) := by
simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x
theorem nhdsWithin_pi_eq_bot {I : Set ι} {s : ∀ i, Set (π i)} {x : ∀ i, π i} :
𝓝[pi I s] x = ⊥ ↔ ∃ i ∈ I, 𝓝[s i] x i = ⊥ := by
simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot]
theorem nhdsWithin_pi_neBot {I : Set ι} {s : ∀ i, Set (π i)} {x : ∀ i, π i} :
(𝓝[pi I s] x).NeBot ↔ ∀ i ∈ I, (𝓝[s i] x i).NeBot := by
simp [neBot_iff, nhdsWithin_pi_eq_bot]
instance instNeBotNhdsWithinUnivPi {s : ∀ i, Set (π i)} {x : ∀ i, π i}
[∀ i, (𝓝[s i] x i).NeBot] : (𝓝[pi univ s] x).NeBot := by
simpa [nhdsWithin_pi_neBot]
instance Pi.instNeBotNhdsWithinIio [Nonempty ι] [∀ i, Preorder (π i)] {x : ∀ i, π i}
[∀ i, (𝓝[<] x i).NeBot] : (𝓝[<] x).NeBot :=
have : (𝓝[pi univ fun i ↦ Iio (x i)] x).NeBot := inferInstance
this.mono <| nhdsWithin_mono _ fun _y hy ↦ lt_of_strongLT fun i ↦ hy i trivial
instance Pi.instNeBotNhdsWithinIoi [Nonempty ι] [∀ i, Preorder (π i)] {x : ∀ i, π i}
[∀ i, (𝓝[>] x i).NeBot] : (𝓝[>] x).NeBot :=
Pi.instNeBotNhdsWithinIio (π := fun i ↦ (π i)ᵒᵈ) (x := fun i ↦ OrderDual.toDual (x i))
end Pi
theorem Filter.Tendsto.piecewise_nhdsWithin {f g : α → β} {t : Set α} [∀ x, Decidable (x ∈ t)]
{a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ t] a) l)
(h₁ : Tendsto g (𝓝[s ∩ tᶜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by
apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter']
theorem Filter.Tendsto.if_nhdsWithin {f g : α → β} {p : α → Prop} [DecidablePred p] {a : α}
{s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ { x | p x }] a) l)
(h₁ : Tendsto g (𝓝[s ∩ { x | ¬p x }] a) l) :
Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l :=
h₀.piecewise_nhdsWithin h₁
theorem map_nhdsWithin (f : α → β) (a : α) (s : Set α) :
map f (𝓝[s] a) = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (f '' (t ∩ s)) :=
((nhdsWithin_basis_open a s).map f).eq_biInf
theorem tendsto_nhdsWithin_mono_left {f : α → β} {a : α} {s t : Set α} {l : Filter β} (hst : s ⊆ t)
(h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l :=
h.mono_left <| nhdsWithin_mono a hst
theorem tendsto_nhdsWithin_mono_right {f : β → α} {l : Filter β} {a : α} {s t : Set α} (hst : s ⊆ t)
(h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) :=
h.mono_right (nhdsWithin_mono a hst)
theorem tendsto_nhdsWithin_of_tendsto_nhds {f : α → β} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l :=
h.mono_left inf_le_left
theorem eventually_mem_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f l (𝓝[s] a)) : ∀ᶠ i in l, f i ∈ s := by
simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff,
eventually_and] at h
exact (h univ ⟨mem_univ a, isOpen_univ⟩).2
theorem tendsto_nhds_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) :=
h.mono_right nhdsWithin_le_nhds
theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) :=
mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx
theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set α} (hs : IsClosed s) {x : α}
(hx : NeBot <| 𝓝[s] x) : x ∈ s :=
hs.closure_eq ▸ mem_closure_iff_nhdsWithin_neBot.2 hx
theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) :
NeBot (𝓝[range f] x) :=
mem_closure_iff_clusterPt.1 (h x)
theorem mem_closure_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι}
{s : ∀ i, Set (α i)} {x : ∀ i, α i} : x ∈ closure (pi I s) ↔ ∀ i ∈ I, x i ∈ closure (s i) := by
simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot]
theorem closure_pi_set {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] (I : Set ι)
(s : ∀ i, Set (α i)) : closure (pi I s) = pi I fun i => closure (s i) :=
Set.ext fun _ => mem_closure_pi
theorem dense_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {s : ∀ i, Set (α i)}
(I : Set ι) (hs : ∀ i ∈ I, Dense (s i)) : Dense (pi I s) := by
simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq,
pi_univ]
theorem DenseRange.piMap {ι : Type*} {X Y : ι → Type*} [∀ i, TopologicalSpace (Y i)]
{f : (i : ι) → (X i) → (Y i)} (hf : ∀ i, DenseRange (f i)):
DenseRange (Pi.map f) := by
rw [DenseRange, Set.range_piMap]
exact dense_pi Set.univ (fun i _ => hf i)
theorem eventuallyEq_nhdsWithin_iff {f g : α → β} {s : Set α} {a : α} :
f =ᶠ[𝓝[s] a] g ↔ ∀ᶠ x in 𝓝 a, x ∈ s → f x = g x :=
mem_inf_principal
/-- Two functions agree on a neighborhood of `x` if they agree at `x` and in a punctured
neighborhood. -/
theorem eventuallyEq_nhds_of_eventuallyEq_nhdsNE {f g : α → β} {a : α} (h₁ : f =ᶠ[𝓝[≠] a] g)
(h₂ : f a = g a) :
f =ᶠ[𝓝 a] g := by
filter_upwards [eventually_nhdsWithin_iff.1 h₁]
intro x hx
by_cases h₂x : x = a
· simp [h₂x, h₂]
· tauto
theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) :
f =ᶠ[𝓝[s] a] g :=
mem_inf_of_right h
theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) :
f =ᶠ[𝓝[s] a] g :=
eventuallyEq_nhdsWithin_of_eqOn h
theorem tendsto_nhdsWithin_congr {f g : α → β} {s : Set α} {a : α} {l : Filter β}
(hfg : ∀ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l :=
(tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf
theorem eventually_nhdsWithin_of_forall {s : Set α} {a : α} {p : α → Prop} (h : ∀ x ∈ s, p x) :
∀ᶠ x in 𝓝[s] a, p x :=
mem_inf_of_right h
theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : α} {l : Filter β} {s : Set α}
(f : β → α) (h1 : Tendsto f l (𝓝 a)) (h2 : ∀ᶠ x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) :=
tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩
theorem tendsto_nhdsWithin_iff {a : α} {l : Filter β} {s : Set α} {f : β → α} :
Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ ∀ᶠ n in l, f n ∈ s :=
⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h =>
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩
@[simp]
theorem tendsto_nhdsWithin_range {a : α} {l : Filter β} {f : β → α} :
Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) :=
⟨fun h => h.mono_right inf_le_left, fun h =>
tendsto_inf.2 ⟨h, tendsto_principal.2 <| Eventually.of_forall mem_range_self⟩⟩
theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set α} {f g : α → β} {a : α} (h : f =ᶠ[𝓝[s] a] g)
(hmem : a ∈ s) : f a = g a :=
h.self_of_nhdsWithin hmem
theorem eventually_nhdsWithin_of_eventually_nhds {s : Set α}
{a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x :=
mem_nhdsWithin_of_mem_nhds h
lemma Set.MapsTo.preimage_mem_nhdsWithin {f : α → β} {s : Set α} {t : Set β} {x : α}
(hst : MapsTo f s t) : f ⁻¹' t ∈ 𝓝[s] x :=
Filter.mem_of_superset self_mem_nhdsWithin hst
/-!
### `nhdsWithin` and subtypes
-/
theorem mem_nhdsWithin_subtype {s : Set α} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} :
t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s → α) (𝓝[(↑) '' u] a) := by
rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin]
theorem nhdsWithin_subtype (s : Set α) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) :
𝓝[t] a = comap ((↑) : s → α) (𝓝[(↑) '' t] a) :=
Filter.ext fun _ => mem_nhdsWithin_subtype
theorem nhdsWithin_eq_map_subtype_coe {s : Set α} {a : α} (h : a ∈ s) :
𝓝[s] a = map ((↑) : s → α) (𝓝 ⟨a, h⟩) :=
(map_nhds_subtype_val ⟨a, h⟩).symm
theorem mem_nhds_subtype_iff_nhdsWithin {s : Set α} {a : s} {t : Set s} :
t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : α) := by
rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective]
theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by
rw [← map_nhds_subtype_val, mem_map]
theorem eventually_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) :
(∀ᶠ x : s in 𝓝 a, P x) ↔ ∀ᶠ x in 𝓝[s] a, P x :=
preimage_coe_mem_nhds_subtype
theorem frequently_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) :
(∃ᶠ x : s in 𝓝 a, P x) ↔ ∃ᶠ x in 𝓝[s] a, P x :=
eventually_nhds_subtype_iff s a (¬ P ·) |>.not
theorem tendsto_nhdsWithin_iff_subtype {s : Set α} {a : α} (h : a ∈ s) (f : α → β) (l : Filter β) :
Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by
rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl
/-!
## Local continuity properties of functions
-/
variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ]
{f g : α → β} {s s' s₁ t : Set α} {x : α}
/-!
### `ContinuousWithinAt`
-/
/-- If a function is continuous within `s` at `x`, then it tends to `f x` within `s` by definition.
We register this fact for use with the dot notation, especially to use `Filter.Tendsto.comp` as
`ContinuousWithinAt.comp` will have a different meaning. -/
theorem ContinuousWithinAt.tendsto (h : ContinuousWithinAt f s x) :
Tendsto f (𝓝[s] x) (𝓝 (f x)) :=
h
theorem continuousWithinAt_univ (f : α → β) (x : α) :
ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by
rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ]
theorem continuous_iff_continuousOn_univ {f : α → β} : Continuous f ↔ ContinuousOn f univ := by
simp [continuous_iff_continuousAt, ContinuousOn, ContinuousAt, ContinuousWithinAt,
nhdsWithin_univ]
theorem continuousWithinAt_iff_continuousAt_restrict (f : α → β) {x : α} {s : Set α} (h : x ∈ s) :
ContinuousWithinAt f s x ↔ ContinuousAt (s.restrict f) ⟨x, h⟩ :=
tendsto_nhdsWithin_iff_subtype h f _
theorem ContinuousWithinAt.tendsto_nhdsWithin {t : Set β}
(h : ContinuousWithinAt f s x) (ht : MapsTo f s t) :
Tendsto f (𝓝[s] x) (𝓝[t] f x) :=
tendsto_inf.2 ⟨h, tendsto_principal.2 <| mem_inf_of_right <| mem_principal.2 <| ht⟩
theorem ContinuousWithinAt.tendsto_nhdsWithin_image (h : ContinuousWithinAt f s x) :
Tendsto f (𝓝[s] x) (𝓝[f '' s] f x) :=
h.tendsto_nhdsWithin (mapsTo_image _ _)
theorem nhdsWithin_le_comap (ctsf : ContinuousWithinAt f s x) :
𝓝[s] x ≤ comap f (𝓝[f '' s] f x) :=
ctsf.tendsto_nhdsWithin_image.le_comap
theorem ContinuousWithinAt.preimage_mem_nhdsWithin {t : Set β}
(h : ContinuousWithinAt f s x) (ht : t ∈ 𝓝 (f x)) : f ⁻¹' t ∈ 𝓝[s] x :=
h ht
theorem ContinuousWithinAt.preimage_mem_nhdsWithin' {t : Set β}
(h : ContinuousWithinAt f s x) (ht : t ∈ 𝓝[f '' s] f x) : f ⁻¹' t ∈ 𝓝[s] x :=
h.tendsto_nhdsWithin (mapsTo_image _ _) ht
theorem ContinuousWithinAt.preimage_mem_nhdsWithin'' {y : β} {s t : Set β}
(h : ContinuousWithinAt f (f ⁻¹' s) x) (ht : t ∈ 𝓝[s] y) (hxy : y = f x) :
f ⁻¹' t ∈ 𝓝[f ⁻¹' s] x := by
rw [hxy] at ht
exact h.preimage_mem_nhdsWithin' (nhdsWithin_mono _ (image_preimage_subset f s) ht)
theorem continuousWithinAt_of_not_mem_closure (hx : x ∉ closure s) :
ContinuousWithinAt f s x := by
rw [mem_closure_iff_nhdsWithin_neBot, not_neBot] at hx
rw [ContinuousWithinAt, hx]
exact tendsto_bot
/-!
### `ContinuousOn`
-/
| Mathlib/Topology/ContinuousOn.lean | 577 | 581 | theorem continuousOn_iff :
ContinuousOn f s ↔
∀ x ∈ s, ∀ t : Set β, IsOpen t → f x ∈ t → ∃ u, IsOpen u ∧ x ∈ u ∧ u ∩ s ⊆ f ⁻¹' t := by | simp only [ContinuousOn, ContinuousWithinAt, tendsto_nhds, mem_nhdsWithin] |
/-
Copyright (c) 2022 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers, Heather Macbeth
-/
import Mathlib.Analysis.SpecialFunctions.Complex.Circle
import Mathlib.Geometry.Euclidean.Angle.Oriented.Basic
/-!
# Rotations by oriented angles.
This file defines rotations by oriented angles in real inner product spaces.
## Main definitions
* `Orientation.rotation` is the rotation by an oriented angle with respect to an orientation.
-/
noncomputable section
open Module Complex
open scoped Real RealInnerProductSpace ComplexConjugate
namespace Orientation
attribute [local instance] Complex.finrank_real_complex_fact
variable {V V' : Type*}
variable [NormedAddCommGroup V] [NormedAddCommGroup V']
variable [InnerProductSpace ℝ V] [InnerProductSpace ℝ V']
variable [Fact (finrank ℝ V = 2)] [Fact (finrank ℝ V' = 2)] (o : Orientation ℝ V (Fin 2))
local notation "J" => o.rightAngleRotation
/-- Auxiliary construction to build a rotation by the oriented angle `θ`. -/
def rotationAux (θ : Real.Angle) : V →ₗᵢ[ℝ] V :=
LinearMap.isometryOfInner
(Real.Angle.cos θ • LinearMap.id +
Real.Angle.sin θ • (LinearIsometryEquiv.toLinearEquiv J).toLinearMap)
(by
intro x y
simp only [RCLike.conj_to_real, id, LinearMap.smul_apply, LinearMap.add_apply,
LinearMap.id_coe, LinearEquiv.coe_coe, LinearIsometryEquiv.coe_toLinearEquiv,
Orientation.areaForm_rightAngleRotation_left, Orientation.inner_rightAngleRotation_left,
Orientation.inner_rightAngleRotation_right, inner_add_left, inner_smul_left,
inner_add_right, inner_smul_right]
linear_combination inner (𝕜 := ℝ) x y * θ.cos_sq_add_sin_sq)
@[simp]
theorem rotationAux_apply (θ : Real.Angle) (x : V) :
o.rotationAux θ x = Real.Angle.cos θ • x + Real.Angle.sin θ • J x :=
rfl
/-- A rotation by the oriented angle `θ`. -/
def rotation (θ : Real.Angle) : V ≃ₗᵢ[ℝ] V :=
LinearIsometryEquiv.ofLinearIsometry (o.rotationAux θ)
(Real.Angle.cos θ • LinearMap.id -
Real.Angle.sin θ • (LinearIsometryEquiv.toLinearEquiv J).toLinearMap)
(by
ext x
convert congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1
· simp only [o.rightAngleRotation_rightAngleRotation, o.rotationAux_apply,
Function.comp_apply, id, LinearEquiv.coe_coe, LinearIsometry.coe_toLinearMap,
LinearIsometryEquiv.coe_toLinearEquiv, map_smul, map_sub, LinearMap.coe_comp,
LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply]
module
· simp)
(by
ext x
convert congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1
· simp only [o.rightAngleRotation_rightAngleRotation, o.rotationAux_apply,
Function.comp_apply, id, LinearEquiv.coe_coe, LinearIsometry.coe_toLinearMap,
LinearIsometryEquiv.coe_toLinearEquiv, map_add, map_smul, LinearMap.coe_comp,
LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply]
module
· simp)
theorem rotation_apply (θ : Real.Angle) (x : V) :
o.rotation θ x = Real.Angle.cos θ • x + Real.Angle.sin θ • J x :=
rfl
theorem rotation_symm_apply (θ : Real.Angle) (x : V) :
(o.rotation θ).symm x = Real.Angle.cos θ • x - Real.Angle.sin θ • J x :=
rfl
theorem rotation_eq_matrix_toLin (θ : Real.Angle) {x : V} (hx : x ≠ 0) :
(o.rotation θ).toLinearMap =
Matrix.toLin (o.basisRightAngleRotation x hx) (o.basisRightAngleRotation x hx)
!![θ.cos, -θ.sin; θ.sin, θ.cos] := by
apply (o.basisRightAngleRotation x hx).ext
intro i
fin_cases i
· rw [Matrix.toLin_self]
simp [rotation_apply, Fin.sum_univ_succ]
· rw [Matrix.toLin_self]
simp [rotation_apply, Fin.sum_univ_succ, add_comm]
/-- The determinant of `rotation` (as a linear map) is equal to `1`. -/
@[simp]
theorem det_rotation (θ : Real.Angle) : LinearMap.det (o.rotation θ).toLinearMap = 1 := by
haveI : Nontrivial V := nontrivial_of_finrank_eq_succ (@Fact.out (finrank ℝ V = 2) _)
obtain ⟨x, hx⟩ : ∃ x, x ≠ (0 : V) := exists_ne (0 : V)
rw [o.rotation_eq_matrix_toLin θ hx]
simpa [sq] using θ.cos_sq_add_sin_sq
/-- The determinant of `rotation` (as a linear equiv) is equal to `1`. -/
@[simp]
theorem linearEquiv_det_rotation (θ : Real.Angle) :
LinearEquiv.det (o.rotation θ).toLinearEquiv = 1 :=
Units.ext <| by
-- Porting note: Lean can't see through `LinearEquiv.coe_det` and needed the rewrite
-- in mathlib3 this was just `units.ext <| o.det_rotation θ`
simpa only [LinearEquiv.coe_det, Units.val_one] using o.det_rotation θ
/-- The inverse of `rotation` is rotation by the negation of the angle. -/
@[simp]
theorem rotation_symm (θ : Real.Angle) : (o.rotation θ).symm = o.rotation (-θ) := by
ext; simp [o.rotation_apply, o.rotation_symm_apply, sub_eq_add_neg]
/-- Rotation by 0 is the identity. -/
@[simp]
theorem rotation_zero : o.rotation 0 = LinearIsometryEquiv.refl ℝ V := by ext; simp [rotation]
/-- Rotation by π is negation. -/
@[simp]
theorem rotation_pi : o.rotation π = LinearIsometryEquiv.neg ℝ := by
ext x
simp [rotation]
/-- Rotation by π is negation. -/
theorem rotation_pi_apply (x : V) : o.rotation π x = -x := by simp
/-- Rotation by π / 2 is the "right-angle-rotation" map `J`. -/
theorem rotation_pi_div_two : o.rotation (π / 2 : ℝ) = J := by
ext x
simp [rotation]
/-- Rotating twice is equivalent to rotating by the sum of the angles. -/
@[simp]
theorem rotation_rotation (θ₁ θ₂ : Real.Angle) (x : V) :
o.rotation θ₁ (o.rotation θ₂ x) = o.rotation (θ₁ + θ₂) x := by
simp only [o.rotation_apply, Real.Angle.cos_add, Real.Angle.sin_add, LinearIsometryEquiv.map_add,
LinearIsometryEquiv.trans_apply, map_smul, rightAngleRotation_rightAngleRotation]
module
/-- Rotating twice is equivalent to rotating by the sum of the angles. -/
@[simp]
theorem rotation_trans (θ₁ θ₂ : Real.Angle) :
(o.rotation θ₁).trans (o.rotation θ₂) = o.rotation (θ₂ + θ₁) :=
LinearIsometryEquiv.ext fun _ => by rw [← rotation_rotation, LinearIsometryEquiv.trans_apply]
/-- Rotating the first of two vectors by `θ` scales their Kahler form by `cos θ - sin θ * I`. -/
@[simp]
theorem kahler_rotation_left (x y : V) (θ : Real.Angle) :
o.kahler (o.rotation θ x) y = conj (θ.toCircle : ℂ) * o.kahler x y := by
-- Porting note: this needed the `Complex.conj_ofReal` instead of `RCLike.conj_ofReal`;
-- I believe this is because the respective coercions are no longer defeq, and
-- `Real.Angle.coe_toCircle` uses the `Complex` version.
simp only [o.rotation_apply, map_add, map_mul, LinearMap.map_smulₛₗ, RingHom.id_apply,
LinearMap.add_apply, LinearMap.smul_apply, real_smul, kahler_rightAngleRotation_left,
Real.Angle.coe_toCircle, Complex.conj_ofReal, conj_I]
ring
/-- Negating a rotation is equivalent to rotation by π plus the angle. -/
theorem neg_rotation (θ : Real.Angle) (x : V) : -o.rotation θ x = o.rotation (π + θ) x := by
rw [← o.rotation_pi_apply, rotation_rotation]
/-- Negating a rotation by -π / 2 is equivalent to rotation by π / 2. -/
@[simp]
| Mathlib/Geometry/Euclidean/Angle/Oriented/Rotation.lean | 173 | 175 | theorem neg_rotation_neg_pi_div_two (x : V) :
-o.rotation (-π / 2 : ℝ) x = o.rotation (π / 2 : ℝ) x := by | rw [neg_rotation, ← Real.Angle.coe_add, neg_div, ← sub_eq_add_neg, sub_half] |
/-
Copyright (c) 2019 Jean Lo. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean Lo, Yaël Dillies, Moritz Doll
-/
import Mathlib.Algebra.Order.Pi
import Mathlib.Analysis.Convex.Function
import Mathlib.Analysis.LocallyConvex.Basic
import Mathlib.Data.Real.Pointwise
/-!
# Seminorms
This file defines seminorms.
A seminorm is a function to the reals which is positive-semidefinite, absolutely homogeneous, and
subadditive. They are closely related to convex sets, and a topological vector space is locally
convex if and only if its topology is induced by a family of seminorms.
## Main declarations
For a module over a normed ring:
* `Seminorm`: A function to the reals that is positive-semidefinite, absolutely homogeneous, and
subadditive.
* `normSeminorm 𝕜 E`: The norm on `E` as a seminorm.
## References
* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]
## Tags
seminorm, locally convex, LCTVS
-/
assert_not_exists balancedCore
open NormedField Set Filter
open scoped NNReal Pointwise Topology Uniformity
variable {R R' 𝕜 𝕜₂ 𝕜₃ 𝕝 E E₂ E₃ F ι : Type*}
/-- A seminorm on a module over a normed ring is a function to the reals that is positive
semidefinite, positive homogeneous, and subadditive. -/
structure Seminorm (𝕜 : Type*) (E : Type*) [SeminormedRing 𝕜] [AddGroup E] [SMul 𝕜 E] extends
AddGroupSeminorm E where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
smul' : ∀ (a : 𝕜) (x : E), toFun (a • x) = ‖a‖ * toFun x
attribute [nolint docBlame] Seminorm.toAddGroupSeminorm
/-- `SeminormClass F 𝕜 E` states that `F` is a type of seminorms on the `𝕜`-module `E`.
You should extend this class when you extend `Seminorm`. -/
class SeminormClass (F : Type*) (𝕜 E : outParam Type*) [SeminormedRing 𝕜] [AddGroup E]
[SMul 𝕜 E] [FunLike F E ℝ] : Prop extends AddGroupSeminormClass F E ℝ where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
map_smul_eq_mul (f : F) (a : 𝕜) (x : E) : f (a • x) = ‖a‖ * f x
export SeminormClass (map_smul_eq_mul)
section Of
/-- Alternative constructor for a `Seminorm` on an `AddCommGroup E` that is a module over a
`SeminormedRing 𝕜`. -/
def Seminorm.of [SeminormedRing 𝕜] [AddCommGroup E] [Module 𝕜 E] (f : E → ℝ)
(add_le : ∀ x y : E, f (x + y) ≤ f x + f y) (smul : ∀ (a : 𝕜) (x : E), f (a • x) = ‖a‖ * f x) :
Seminorm 𝕜 E where
toFun := f
map_zero' := by rw [← zero_smul 𝕜 (0 : E), smul, norm_zero, zero_mul]
add_le' := add_le
smul' := smul
neg' x := by rw [← neg_one_smul 𝕜, smul, norm_neg, ← smul, one_smul]
/-- Alternative constructor for a `Seminorm` over a normed field `𝕜` that only assumes `f 0 = 0`
and an inequality for the scalar multiplication. -/
def Seminorm.ofSMulLE [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] (f : E → ℝ) (map_zero : f 0 = 0)
(add_le : ∀ x y, f (x + y) ≤ f x + f y) (smul_le : ∀ (r : 𝕜) (x), f (r • x) ≤ ‖r‖ * f x) :
Seminorm 𝕜 E :=
Seminorm.of f add_le fun r x => by
refine le_antisymm (smul_le r x) ?_
by_cases h : r = 0
· simp [h, map_zero]
rw [← mul_le_mul_left (inv_pos.mpr (norm_pos_iff.mpr h))]
rw [inv_mul_cancel_left₀ (norm_ne_zero_iff.mpr h)]
specialize smul_le r⁻¹ (r • x)
rw [norm_inv] at smul_le
convert smul_le
simp [h]
end Of
namespace Seminorm
section SeminormedRing
variable [SeminormedRing 𝕜]
section AddGroup
variable [AddGroup E]
section SMul
variable [SMul 𝕜 E]
instance instFunLike : FunLike (Seminorm 𝕜 E) E ℝ where
coe f := f.toFun
coe_injective' f g h := by
rcases f with ⟨⟨_⟩⟩
rcases g with ⟨⟨_⟩⟩
congr
instance instSeminormClass : SeminormClass (Seminorm 𝕜 E) 𝕜 E where
map_zero f := f.map_zero'
map_add_le_add f := f.add_le'
map_neg_eq_map f := f.neg'
map_smul_eq_mul f := f.smul'
@[ext]
theorem ext {p q : Seminorm 𝕜 E} (h : ∀ x, (p : E → ℝ) x = q x) : p = q :=
DFunLike.ext p q h
instance instZero : Zero (Seminorm 𝕜 E) :=
⟨{ AddGroupSeminorm.instZeroAddGroupSeminorm.zero with
smul' := fun _ _ => (mul_zero _).symm }⟩
@[simp]
theorem coe_zero : ⇑(0 : Seminorm 𝕜 E) = 0 :=
rfl
@[simp]
theorem zero_apply (x : E) : (0 : Seminorm 𝕜 E) x = 0 :=
rfl
instance : Inhabited (Seminorm 𝕜 E) :=
⟨0⟩
variable (p : Seminorm 𝕜 E) (x : E) (r : ℝ)
/-- Any action on `ℝ` which factors through `ℝ≥0` applies to a seminorm. -/
instance instSMul [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] : SMul R (Seminorm 𝕜 E) where
smul r p :=
{ r • p.toAddGroupSeminorm with
toFun := fun x => r • p x
smul' := fun _ _ => by
simp only [← smul_one_smul ℝ≥0 r (_ : ℝ), NNReal.smul_def, smul_eq_mul]
rw [map_smul_eq_mul, mul_left_comm] }
instance [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] [SMul R' ℝ] [SMul R' ℝ≥0]
[IsScalarTower R' ℝ≥0 ℝ] [SMul R R'] [IsScalarTower R R' ℝ] :
IsScalarTower R R' (Seminorm 𝕜 E) where
smul_assoc r a p := ext fun x => smul_assoc r a (p x)
theorem coe_smul [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p : Seminorm 𝕜 E) :
⇑(r • p) = r • ⇑p :=
rfl
@[simp]
theorem smul_apply [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p : Seminorm 𝕜 E)
(x : E) : (r • p) x = r • p x :=
rfl
instance instAdd : Add (Seminorm 𝕜 E) where
add p q :=
{ p.toAddGroupSeminorm + q.toAddGroupSeminorm with
toFun := fun x => p x + q x
smul' := fun a x => by simp only [map_smul_eq_mul, map_smul_eq_mul, mul_add] }
theorem coe_add (p q : Seminorm 𝕜 E) : ⇑(p + q) = p + q :=
rfl
@[simp]
theorem add_apply (p q : Seminorm 𝕜 E) (x : E) : (p + q) x = p x + q x :=
rfl
instance instAddMonoid : AddMonoid (Seminorm 𝕜 E) :=
DFunLike.coe_injective.addMonoid _ rfl coe_add fun _ _ => by rfl
instance instAddCommMonoid : AddCommMonoid (Seminorm 𝕜 E) :=
DFunLike.coe_injective.addCommMonoid _ rfl coe_add fun _ _ => by rfl
instance instPartialOrder : PartialOrder (Seminorm 𝕜 E) :=
PartialOrder.lift _ DFunLike.coe_injective
instance instIsOrderedCancelAddMonoid : IsOrderedCancelAddMonoid (Seminorm 𝕜 E) :=
DFunLike.coe_injective.isOrderedCancelAddMonoid _ rfl coe_add fun _ _ => rfl
instance instMulAction [Monoid R] [MulAction R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] :
MulAction R (Seminorm 𝕜 E) :=
DFunLike.coe_injective.mulAction _ (by intros; rfl)
variable (𝕜 E)
/-- `coeFn` as an `AddMonoidHom`. Helper definition for showing that `Seminorm 𝕜 E` is a module. -/
@[simps]
def coeFnAddMonoidHom : AddMonoidHom (Seminorm 𝕜 E) (E → ℝ) where
toFun := (↑)
map_zero' := coe_zero
map_add' := coe_add
theorem coeFnAddMonoidHom_injective : Function.Injective (coeFnAddMonoidHom 𝕜 E) :=
show @Function.Injective (Seminorm 𝕜 E) (E → ℝ) (↑) from DFunLike.coe_injective
variable {𝕜 E}
instance instDistribMulAction [Monoid R] [DistribMulAction R ℝ] [SMul R ℝ≥0]
[IsScalarTower R ℝ≥0 ℝ] : DistribMulAction R (Seminorm 𝕜 E) :=
(coeFnAddMonoidHom_injective 𝕜 E).distribMulAction _ (by intros; rfl)
instance instModule [Semiring R] [Module R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] :
Module R (Seminorm 𝕜 E) :=
(coeFnAddMonoidHom_injective 𝕜 E).module R _ (by intros; rfl)
instance instSup : Max (Seminorm 𝕜 E) where
max p q :=
{ p.toAddGroupSeminorm ⊔ q.toAddGroupSeminorm with
toFun := p ⊔ q
smul' := fun x v =>
(congr_arg₂ max (map_smul_eq_mul p x v) (map_smul_eq_mul q x v)).trans <|
(mul_max_of_nonneg _ _ <| norm_nonneg x).symm }
@[simp]
theorem coe_sup (p q : Seminorm 𝕜 E) : ⇑(p ⊔ q) = (p : E → ℝ) ⊔ (q : E → ℝ) :=
rfl
theorem sup_apply (p q : Seminorm 𝕜 E) (x : E) : (p ⊔ q) x = p x ⊔ q x :=
rfl
theorem smul_sup [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p q : Seminorm 𝕜 E) :
r • (p ⊔ q) = r • p ⊔ r • q :=
have real.smul_max : ∀ x y : ℝ, r • max x y = max (r • x) (r • y) := fun x y => by
simpa only [← smul_eq_mul, ← NNReal.smul_def, smul_one_smul ℝ≥0 r (_ : ℝ)] using
mul_max_of_nonneg x y (r • (1 : ℝ≥0) : ℝ≥0).coe_nonneg
ext fun _ => real.smul_max _ _
@[simp, norm_cast]
theorem coe_le_coe {p q : Seminorm 𝕜 E} : (p : E → ℝ) ≤ q ↔ p ≤ q :=
Iff.rfl
@[simp, norm_cast]
theorem coe_lt_coe {p q : Seminorm 𝕜 E} : (p : E → ℝ) < q ↔ p < q :=
Iff.rfl
theorem le_def {p q : Seminorm 𝕜 E} : p ≤ q ↔ ∀ x, p x ≤ q x :=
Iff.rfl
theorem lt_def {p q : Seminorm 𝕜 E} : p < q ↔ p ≤ q ∧ ∃ x, p x < q x :=
@Pi.lt_def _ _ _ p q
instance instSemilatticeSup : SemilatticeSup (Seminorm 𝕜 E) :=
Function.Injective.semilatticeSup _ DFunLike.coe_injective coe_sup
end SMul
end AddGroup
section Module
variable [SeminormedRing 𝕜₂] [SeminormedRing 𝕜₃]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
variable {σ₂₃ : 𝕜₂ →+* 𝕜₃} [RingHomIsometric σ₂₃]
variable {σ₁₃ : 𝕜 →+* 𝕜₃} [RingHomIsometric σ₁₃]
variable [AddCommGroup E] [AddCommGroup E₂] [AddCommGroup E₃]
variable [Module 𝕜 E] [Module 𝕜₂ E₂] [Module 𝕜₃ E₃]
variable [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ]
/-- Composition of a seminorm with a linear map is a seminorm. -/
def comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) : Seminorm 𝕜 E :=
{ p.toAddGroupSeminorm.comp f.toAddMonoidHom with
toFun := fun x => p (f x)
-- Porting note: the `simp only` below used to be part of the `rw`.
-- I'm not sure why this change was needed, and am worried by it!
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to change `map_smulₛₗ` to `map_smulₛₗ _`
smul' := fun _ _ => by simp only [map_smulₛₗ _]; rw [map_smul_eq_mul, RingHomIsometric.is_iso] }
theorem coe_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) : ⇑(p.comp f) = p ∘ f :=
rfl
@[simp]
theorem comp_apply (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (x : E) : (p.comp f) x = p (f x) :=
rfl
@[simp]
theorem comp_id (p : Seminorm 𝕜 E) : p.comp LinearMap.id = p :=
ext fun _ => rfl
@[simp]
theorem comp_zero (p : Seminorm 𝕜₂ E₂) : p.comp (0 : E →ₛₗ[σ₁₂] E₂) = 0 :=
ext fun _ => map_zero p
@[simp]
theorem zero_comp (f : E →ₛₗ[σ₁₂] E₂) : (0 : Seminorm 𝕜₂ E₂).comp f = 0 :=
ext fun _ => rfl
theorem comp_comp [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] (p : Seminorm 𝕜₃ E₃) (g : E₂ →ₛₗ[σ₂₃] E₃)
(f : E →ₛₗ[σ₁₂] E₂) : p.comp (g.comp f) = (p.comp g).comp f :=
ext fun _ => rfl
theorem add_comp (p q : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) :
(p + q).comp f = p.comp f + q.comp f :=
ext fun _ => rfl
theorem comp_add_le (p : Seminorm 𝕜₂ E₂) (f g : E →ₛₗ[σ₁₂] E₂) :
p.comp (f + g) ≤ p.comp f + p.comp g := fun _ => map_add_le_add p _ _
theorem smul_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : R) :
(c • p).comp f = c • p.comp f :=
ext fun _ => rfl
theorem comp_mono {p q : Seminorm 𝕜₂ E₂} (f : E →ₛₗ[σ₁₂] E₂) (hp : p ≤ q) : p.comp f ≤ q.comp f :=
fun _ => hp _
/-- The composition as an `AddMonoidHom`. -/
@[simps]
def pullback (f : E →ₛₗ[σ₁₂] E₂) : Seminorm 𝕜₂ E₂ →+ Seminorm 𝕜 E where
toFun := fun p => p.comp f
map_zero' := zero_comp f
map_add' := fun p q => add_comp p q f
instance instOrderBot : OrderBot (Seminorm 𝕜 E) where
bot := 0
bot_le := apply_nonneg
@[simp]
theorem coe_bot : ⇑(⊥ : Seminorm 𝕜 E) = 0 :=
rfl
theorem bot_eq_zero : (⊥ : Seminorm 𝕜 E) = 0 :=
rfl
theorem smul_le_smul {p q : Seminorm 𝕜 E} {a b : ℝ≥0} (hpq : p ≤ q) (hab : a ≤ b) :
a • p ≤ b • q := by
simp_rw [le_def]
intro x
exact mul_le_mul hab (hpq x) (apply_nonneg p x) (NNReal.coe_nonneg b)
theorem finset_sup_apply (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) :
s.sup p x = ↑(s.sup fun i => ⟨p i x, apply_nonneg (p i) x⟩ : ℝ≥0) := by
induction' s using Finset.cons_induction_on with a s ha ih
· rw [Finset.sup_empty, Finset.sup_empty, coe_bot, _root_.bot_eq_zero, Pi.zero_apply]
norm_cast
· rw [Finset.sup_cons, Finset.sup_cons, coe_sup, Pi.sup_apply, NNReal.coe_max, NNReal.coe_mk, ih]
theorem exists_apply_eq_finset_sup (p : ι → Seminorm 𝕜 E) {s : Finset ι} (hs : s.Nonempty) (x : E) :
∃ i ∈ s, s.sup p x = p i x := by
rcases Finset.exists_mem_eq_sup s hs (fun i ↦ (⟨p i x, apply_nonneg _ _⟩ : ℝ≥0)) with ⟨i, hi, hix⟩
rw [finset_sup_apply]
exact ⟨i, hi, congr_arg _ hix⟩
theorem zero_or_exists_apply_eq_finset_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) :
s.sup p x = 0 ∨ ∃ i ∈ s, s.sup p x = p i x := by
rcases Finset.eq_empty_or_nonempty s with (rfl|hs)
· left; rfl
· right; exact exists_apply_eq_finset_sup p hs x
theorem finset_sup_smul (p : ι → Seminorm 𝕜 E) (s : Finset ι) (C : ℝ≥0) :
s.sup (C • p) = C • s.sup p := by
ext x
rw [smul_apply, finset_sup_apply, finset_sup_apply]
symm
exact congr_arg ((↑) : ℝ≥0 → ℝ) (NNReal.mul_finset_sup C s (fun i ↦ ⟨p i x, apply_nonneg _ _⟩))
theorem finset_sup_le_sum (p : ι → Seminorm 𝕜 E) (s : Finset ι) : s.sup p ≤ ∑ i ∈ s, p i := by
classical
refine Finset.sup_le_iff.mpr ?_
intro i hi
rw [Finset.sum_eq_sum_diff_singleton_add hi, le_add_iff_nonneg_left]
exact bot_le
theorem finset_sup_apply_le {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {a : ℝ} (ha : 0 ≤ a)
(h : ∀ i, i ∈ s → p i x ≤ a) : s.sup p x ≤ a := by
lift a to ℝ≥0 using ha
rw [finset_sup_apply, NNReal.coe_le_coe]
exact Finset.sup_le h
theorem le_finset_sup_apply {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {i : ι}
(hi : i ∈ s) : p i x ≤ s.sup p x :=
(Finset.le_sup hi : p i ≤ s.sup p) x
theorem finset_sup_apply_lt {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {a : ℝ} (ha : 0 < a)
(h : ∀ i, i ∈ s → p i x < a) : s.sup p x < a := by
lift a to ℝ≥0 using ha.le
rw [finset_sup_apply, NNReal.coe_lt_coe, Finset.sup_lt_iff]
· exact h
· exact NNReal.coe_pos.mpr ha
theorem norm_sub_map_le_sub (p : Seminorm 𝕜 E) (x y : E) : ‖p x - p y‖ ≤ p (x - y) :=
abs_sub_map_le_sub p x y
end Module
end SeminormedRing
section SeminormedCommRing
variable [SeminormedRing 𝕜] [SeminormedCommRing 𝕜₂]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
variable [AddCommGroup E] [AddCommGroup E₂] [Module 𝕜 E] [Module 𝕜₂ E₂]
theorem comp_smul (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : 𝕜₂) :
p.comp (c • f) = ‖c‖₊ • p.comp f :=
ext fun _ => by
rw [comp_apply, smul_apply, LinearMap.smul_apply, map_smul_eq_mul, NNReal.smul_def, coe_nnnorm,
smul_eq_mul, comp_apply]
theorem comp_smul_apply (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : 𝕜₂) (x : E) :
p.comp (c • f) x = ‖c‖ * p (f x) :=
map_smul_eq_mul p _ _
end SeminormedCommRing
section NormedField
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] {p q : Seminorm 𝕜 E} {x : E}
/-- Auxiliary lemma to show that the infimum of seminorms is well-defined. -/
theorem bddBelow_range_add : BddBelow (range fun u => p u + q (x - u)) :=
⟨0, by
rintro _ ⟨x, rfl⟩
dsimp; positivity⟩
noncomputable instance instInf : Min (Seminorm 𝕜 E) where
min p q :=
{ p.toAddGroupSeminorm ⊓ q.toAddGroupSeminorm with
toFun := fun x => ⨅ u : E, p u + q (x - u)
smul' := by
intro a x
obtain rfl | ha := eq_or_ne a 0
· rw [norm_zero, zero_mul, zero_smul]
refine
ciInf_eq_of_forall_ge_of_forall_gt_exists_lt
(fun i => by positivity)
fun x hx => ⟨0, by rwa [map_zero, sub_zero, map_zero, add_zero]⟩
simp_rw [Real.mul_iInf_of_nonneg (norm_nonneg a), mul_add, ← map_smul_eq_mul p, ←
map_smul_eq_mul q, smul_sub]
refine
Function.Surjective.iInf_congr ((a⁻¹ • ·) : E → E)
(fun u => ⟨a • u, inv_smul_smul₀ ha u⟩) fun u => ?_
rw [smul_inv_smul₀ ha] }
@[simp]
theorem inf_apply (p q : Seminorm 𝕜 E) (x : E) : (p ⊓ q) x = ⨅ u : E, p u + q (x - u) :=
rfl
noncomputable instance instLattice : Lattice (Seminorm 𝕜 E) :=
{ Seminorm.instSemilatticeSup with
inf := (· ⊓ ·)
inf_le_left := fun p q x =>
ciInf_le_of_le bddBelow_range_add x <| by
simp only [sub_self, map_zero, add_zero]; rfl
inf_le_right := fun p q x =>
ciInf_le_of_le bddBelow_range_add 0 <| by
simp only [sub_self, map_zero, zero_add, sub_zero]; rfl
le_inf := fun a _ _ hab hac _ =>
le_ciInf fun _ => (le_map_add_map_sub a _ _).trans <| add_le_add (hab _) (hac _) }
theorem smul_inf [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p q : Seminorm 𝕜 E) :
r • (p ⊓ q) = r • p ⊓ r • q := by
ext
simp_rw [smul_apply, inf_apply, smul_apply, ← smul_one_smul ℝ≥0 r (_ : ℝ), NNReal.smul_def,
smul_eq_mul, Real.mul_iInf_of_nonneg (NNReal.coe_nonneg _), mul_add]
section Classical
open Classical in
/-- We define the supremum of an arbitrary subset of `Seminorm 𝕜 E` as follows:
* if `s` is `BddAbove` *as a set of functions `E → ℝ`* (that is, if `s` is pointwise bounded
above), we take the pointwise supremum of all elements of `s`, and we prove that it is indeed a
seminorm.
* otherwise, we take the zero seminorm `⊥`.
There are two things worth mentioning here:
* First, it is not trivial at first that `s` being bounded above *by a function* implies
being bounded above *as a seminorm*. We show this in `Seminorm.bddAbove_iff` by using
that the `Sup s` as defined here is then a bounding seminorm for `s`. So it is important to make
the case disjunction on `BddAbove ((↑) '' s : Set (E → ℝ))` and not `BddAbove s`.
* Since the pointwise `Sup` already gives `0` at points where a family of functions is
not bounded above, one could hope that just using the pointwise `Sup` would work here, without the
need for an additional case disjunction. As discussed on Zulip, this doesn't work because this can
give a function which does *not* satisfy the seminorm axioms (typically sub-additivity).
-/
noncomputable instance instSupSet : SupSet (Seminorm 𝕜 E) where
sSup s :=
if h : BddAbove ((↑) '' s : Set (E → ℝ)) then
{ toFun := ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ)
map_zero' := by
rw [iSup_apply, ← @Real.iSup_const_zero s]
congr!
rename_i _ _ _ i
exact map_zero i.1
add_le' := fun x y => by
rcases h with ⟨q, hq⟩
obtain rfl | h := s.eq_empty_or_nonempty
· simp [Real.iSup_of_isEmpty]
haveI : Nonempty ↑s := h.coe_sort
simp only [iSup_apply]
refine ciSup_le fun i =>
((i : Seminorm 𝕜 E).add_le' x y).trans <| add_le_add
-- Porting note: `f` is provided to force `Subtype.val` to appear.
-- A type ascription on `_` would have also worked, but would have been more verbose.
(le_ciSup (f := fun i => (Subtype.val i : Seminorm 𝕜 E).toFun x) ⟨q x, ?_⟩ i)
(le_ciSup (f := fun i => (Subtype.val i : Seminorm 𝕜 E).toFun y) ⟨q y, ?_⟩ i)
<;> rw [mem_upperBounds, forall_mem_range]
<;> exact fun j => hq (mem_image_of_mem _ j.2) _
neg' := fun x => by
simp only [iSup_apply]
congr! 2
rename_i _ _ _ i
exact i.1.neg' _
smul' := fun a x => by
simp only [iSup_apply]
rw [← smul_eq_mul,
Real.smul_iSup_of_nonneg (norm_nonneg a) fun i : s => (i : Seminorm 𝕜 E) x]
congr!
rename_i _ _ _ i
exact i.1.smul' a x }
else ⊥
protected theorem coe_sSup_eq' {s : Set <| Seminorm 𝕜 E}
(hs : BddAbove ((↑) '' s : Set (E → ℝ))) : ↑(sSup s) = ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ) :=
congr_arg _ (dif_pos hs)
protected theorem bddAbove_iff {s : Set <| Seminorm 𝕜 E} :
BddAbove s ↔ BddAbove ((↑) '' s : Set (E → ℝ)) :=
⟨fun ⟨q, hq⟩ => ⟨q, forall_mem_image.2 fun _ hp => hq hp⟩, fun H =>
⟨sSup s, fun p hp x => by
dsimp
rw [Seminorm.coe_sSup_eq' H, iSup_apply]
rcases H with ⟨q, hq⟩
exact
le_ciSup ⟨q x, forall_mem_range.mpr fun i : s => hq (mem_image_of_mem _ i.2) x⟩ ⟨p, hp⟩⟩⟩
protected theorem bddAbove_range_iff {ι : Sort*} {p : ι → Seminorm 𝕜 E} :
BddAbove (range p) ↔ ∀ x, BddAbove (range fun i ↦ p i x) := by
rw [Seminorm.bddAbove_iff, ← range_comp, bddAbove_range_pi]; rfl
protected theorem coe_sSup_eq {s : Set <| Seminorm 𝕜 E} (hs : BddAbove s) :
↑(sSup s) = ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ) :=
Seminorm.coe_sSup_eq' (Seminorm.bddAbove_iff.mp hs)
protected theorem coe_iSup_eq {ι : Sort*} {p : ι → Seminorm 𝕜 E} (hp : BddAbove (range p)) :
↑(⨆ i, p i) = ⨆ i, ((p i : Seminorm 𝕜 E) : E → ℝ) := by
rw [← sSup_range, Seminorm.coe_sSup_eq hp]
exact iSup_range' (fun p : Seminorm 𝕜 E => (p : E → ℝ)) p
protected theorem sSup_apply {s : Set (Seminorm 𝕜 E)} (hp : BddAbove s) {x : E} :
(sSup s) x = ⨆ p : s, (p : E → ℝ) x := by
rw [Seminorm.coe_sSup_eq hp, iSup_apply]
protected theorem iSup_apply {ι : Sort*} {p : ι → Seminorm 𝕜 E}
(hp : BddAbove (range p)) {x : E} : (⨆ i, p i) x = ⨆ i, p i x := by
rw [Seminorm.coe_iSup_eq hp, iSup_apply]
protected theorem sSup_empty : sSup (∅ : Set (Seminorm 𝕜 E)) = ⊥ := by
ext
rw [Seminorm.sSup_apply bddAbove_empty, Real.iSup_of_isEmpty]
rfl
private theorem isLUB_sSup (s : Set (Seminorm 𝕜 E)) (hs₁ : BddAbove s) (hs₂ : s.Nonempty) :
IsLUB s (sSup s) := by
refine ⟨fun p hp x => ?_, fun p hp x => ?_⟩ <;> haveI : Nonempty ↑s := hs₂.coe_sort <;>
dsimp <;> rw [Seminorm.coe_sSup_eq hs₁, iSup_apply]
· rcases hs₁ with ⟨q, hq⟩
exact le_ciSup ⟨q x, forall_mem_range.mpr fun i : s => hq i.2 x⟩ ⟨p, hp⟩
· exact ciSup_le fun q => hp q.2 x
/-- `Seminorm 𝕜 E` is a conditionally complete lattice.
Note that, while `inf`, `sup` and `sSup` have good definitional properties (corresponding to
the instances given here for `Inf`, `Sup` and `SupSet` respectively), `sInf s` is just
defined as the supremum of the lower bounds of `s`, which is not really useful in practice. If you
need to use `sInf` on seminorms, then you should probably provide a more workable definition first,
but this is unlikely to happen so we keep the "bad" definition for now. -/
noncomputable instance instConditionallyCompleteLattice :
ConditionallyCompleteLattice (Seminorm 𝕜 E) :=
conditionallyCompleteLatticeOfLatticeOfsSup (Seminorm 𝕜 E) Seminorm.isLUB_sSup
end Classical
end NormedField
/-! ### Seminorm ball -/
section SeminormedRing
variable [SeminormedRing 𝕜]
section AddCommGroup
variable [AddCommGroup E]
section SMul
variable [SMul 𝕜 E] (p : Seminorm 𝕜 E)
/-- The ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y` with
`p (y - x) < r`. -/
def ball (x : E) (r : ℝ) :=
{ y : E | p (y - x) < r }
/-- The closed ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y`
with `p (y - x) ≤ r`. -/
def closedBall (x : E) (r : ℝ) :=
{ y : E | p (y - x) ≤ r }
variable {x y : E} {r : ℝ}
@[simp]
theorem mem_ball : y ∈ ball p x r ↔ p (y - x) < r :=
Iff.rfl
@[simp]
theorem mem_closedBall : y ∈ closedBall p x r ↔ p (y - x) ≤ r :=
Iff.rfl
| Mathlib/Analysis/Seminorm.lean | 621 | 627 | theorem mem_ball_self (hr : 0 < r) : x ∈ ball p x r := by | simp [hr]
theorem mem_closedBall_self (hr : 0 ≤ r) : x ∈ closedBall p x r := by simp [hr]
theorem mem_ball_zero : y ∈ ball p 0 r ↔ p y < r := by rw [mem_ball, sub_zero]
theorem mem_closedBall_zero : y ∈ closedBall p 0 r ↔ p y ≤ r := by rw [mem_closedBall, sub_zero] |
/-
Copyright (c) 2024 Emilie Burgun. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Emilie Burgun
-/
import Mathlib.Dynamics.PeriodicPts.Lemmas
import Mathlib.GroupTheory.Exponent
import Mathlib.GroupTheory.GroupAction.Basic
/-!
# Period of a group action
This module defines some helpful lemmas around [`MulAction.period`] and [`AddAction.period`].
The period of a point `a` by a group element `g` is the smallest `m` such that `g ^ m • a = a`
(resp. `(m • g) +ᵥ a = a`) for a given `g : G` and `a : α`.
If such an `m` does not exist,
then by convention `MulAction.period` and `AddAction.period` return 0.
-/
namespace MulAction
universe u v
variable {α : Type v}
variable {G : Type u} [Group G] [MulAction G α]
variable {M : Type u} [Monoid M] [MulAction M α]
/-- If the action is periodic, then a lower bound for its period can be computed. -/
@[to_additive "If the action is periodic, then a lower bound for its period can be computed."]
theorem le_period {m : M} {a : α} {n : ℕ} (period_pos : 0 < period m a)
(moved : ∀ k, 0 < k → k < n → m ^ k • a ≠ a) : n ≤ period m a :=
le_of_not_gt fun period_lt_n =>
moved _ period_pos period_lt_n <| pow_period_smul m a
/-- If for some `n`, `m ^ n • a = a`, then `period m a ≤ n`. -/
@[to_additive "If for some `n`, `(n • m) +ᵥ a = a`, then `period m a ≤ n`."]
theorem period_le_of_fixed {m : M} {a : α} {n : ℕ} (n_pos : 0 < n) (fixed : m ^ n • a = a) :
period m a ≤ n :=
(isPeriodicPt_smul_iff.mpr fixed).minimalPeriod_le n_pos
/-- If for some `n`, `m ^ n • a = a`, then `0 < period m a`. -/
@[to_additive "If for some `n`, `(n • m) +ᵥ a = a`, then `0 < period m a`."]
theorem period_pos_of_fixed {m : M} {a : α} {n : ℕ} (n_pos : 0 < n) (fixed : m ^ n • a = a) :
0 < period m a :=
(isPeriodicPt_smul_iff.mpr fixed).minimalPeriod_pos n_pos
@[to_additive]
theorem period_eq_one_iff {m : M} {a : α} : period m a = 1 ↔ m • a = a :=
⟨fun eq_one => pow_one m ▸ eq_one ▸ pow_period_smul m a,
fun fixed => le_antisymm
(period_le_of_fixed one_pos (by simpa))
(period_pos_of_fixed one_pos (by simpa))⟩
/-- For any non-zero `n` less than the period of `m` on `a`, `a` is moved by `m ^ n`. -/
@[to_additive "For any non-zero `n` less than the period of `m` on `a`, `a` is moved by `n • m`."]
theorem pow_smul_ne_of_lt_period {m : M} {a : α} {n : ℕ} (n_pos : 0 < n)
(n_lt_period : n < period m a) : m ^ n • a ≠ a := fun a_fixed =>
not_le_of_gt n_lt_period <| period_le_of_fixed n_pos a_fixed
section Identities
/-! ### `MulAction.period` for common group elements
-/
variable (M) in
@[to_additive (attr := simp)]
theorem period_one (a : α) : period (1 : M) a = 1 := period_eq_one_iff.mpr (one_smul M a)
@[to_additive (attr := simp)]
theorem period_inv (g : G) (a : α) : period g⁻¹ a = period g a := by
simp only [period_eq_minimalPeriod, Function.minimalPeriod_eq_minimalPeriod_iff,
isPeriodicPt_smul_iff]
intro n
rw [smul_eq_iff_eq_inv_smul, eq_comm, ← zpow_natCast, inv_zpow, inv_inv, zpow_natCast]
end Identities
section MonoidExponent
/-! ### `MulAction.period` and group exponents
The period of a given element `m : M` can be bounded by the `Monoid.exponent M` or `orderOf m`.
-/
@[to_additive]
theorem period_dvd_orderOf (m : M) (a : α) : period m a ∣ orderOf m := by
rw [← pow_smul_eq_iff_period_dvd, pow_orderOf_eq_one, one_smul]
@[to_additive]
theorem period_pos_of_orderOf_pos {m : M} (order_pos : 0 < orderOf m) (a : α) :
0 < period m a :=
Nat.pos_of_dvd_of_pos (period_dvd_orderOf m a) order_pos
@[to_additive]
theorem period_le_orderOf {m : M} (order_pos : 0 < orderOf m) (a : α) :
period m a ≤ orderOf m :=
Nat.le_of_dvd order_pos (period_dvd_orderOf m a)
@[to_additive]
theorem period_dvd_exponent (m : M) (a : α) : period m a ∣ Monoid.exponent M := by
rw [← pow_smul_eq_iff_period_dvd, Monoid.pow_exponent_eq_one, one_smul]
@[to_additive]
theorem period_pos_of_exponent_pos (exp_pos : 0 < Monoid.exponent M) (m : M) (a : α) :
0 < period m a :=
Nat.pos_of_dvd_of_pos (period_dvd_exponent m a) exp_pos
@[to_additive]
theorem period_le_exponent (exp_pos : 0 < Monoid.exponent M) (m : M) (a : α) :
period m a ≤ Monoid.exponent M :=
Nat.le_of_dvd exp_pos (period_dvd_exponent m a)
variable (α)
@[to_additive]
| Mathlib/GroupTheory/GroupAction/Period.lean | 117 | 120 | theorem period_bounded_of_exponent_pos (exp_pos : 0 < Monoid.exponent M) (m : M) :
BddAbove (Set.range (fun a : α => period m a)) := by | use Monoid.exponent M
simpa [upperBounds] using period_le_exponent exp_pos _ |
/-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Arctan
import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
/-!
# Right-angled triangles
This file proves basic geometrical results about distances and angles in (possibly degenerate)
right-angled triangles in real inner product spaces and Euclidean affine spaces.
## Implementation notes
Results in this file are generally given in a form with only those non-degeneracy conditions
needed for the particular result, rather than requiring affine independence of the points of a
triangle unnecessarily.
## References
* https://en.wikipedia.org/wiki/Pythagorean_theorem
-/
noncomputable section
open scoped EuclideanGeometry
open scoped Real
open scoped RealInnerProductSpace
namespace InnerProductGeometry
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
/-- Pythagorean theorem, if-and-only-if vector angle form. -/
theorem norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ angle x y = π / 2 := by
rw [norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero]
exact inner_eq_zero_iff_angle_eq_pi_div_two x y
/-- Pythagorean theorem, vector angle form. -/
theorem norm_add_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = π / 2) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=
(norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h
/-- Pythagorean theorem, subtracting vectors, if-and-only-if vector angle form. -/
theorem norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ angle x y = π / 2 := by
rw [norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero]
exact inner_eq_zero_iff_angle_eq_pi_div_two x y
/-- Pythagorean theorem, subtracting vectors, vector angle form. -/
theorem norm_sub_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = π / 2) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=
(norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem angle_add_eq_arccos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
angle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by
rw [angle, inner_add_right, h, add_zero, real_inner_self_eq_norm_mul_norm]
by_cases hx : ‖x‖ = 0; · simp [hx]
rw [div_mul_eq_div_div, mul_self_div_self]
/-- An angle in a right-angled triangle expressed using `arcsin`. -/
theorem angle_add_eq_arcsin_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :
angle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by
have hxy : ‖x + y‖ ^ 2 ≠ 0 := by
rw [pow_two, norm_add_sq_eq_norm_sq_add_norm_sq_real h, ne_comm]
refine ne_of_lt ?_
rcases h0 with (h0 | h0)
· exact
Left.add_pos_of_pos_of_nonneg (mul_self_pos.2 (norm_ne_zero_iff.2 h0)) (mul_self_nonneg _)
· exact
Left.add_pos_of_nonneg_of_pos (mul_self_nonneg _) (mul_self_pos.2 (norm_ne_zero_iff.2 h0))
rw [angle_add_eq_arccos_of_inner_eq_zero h,
Real.arccos_eq_arcsin (div_nonneg (norm_nonneg _) (norm_nonneg _)), div_pow, one_sub_div hxy]
nth_rw 1 [pow_two]
rw [norm_add_sq_eq_norm_sq_add_norm_sq_real h, pow_two, add_sub_cancel_left, ← pow_two, ← div_pow,
Real.sqrt_sq (div_nonneg (norm_nonneg _) (norm_nonneg _))]
/-- An angle in a right-angled triangle expressed using `arctan`. -/
theorem angle_add_eq_arctan_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :
angle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by
rw [angle_add_eq_arcsin_of_inner_eq_zero h (Or.inl h0), Real.arctan_eq_arcsin, ←
div_mul_eq_div_div, norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
nth_rw 3 [← Real.sqrt_sq (norm_nonneg x)]
rw_mod_cast [← Real.sqrt_mul (sq_nonneg _), div_pow, pow_two, pow_two, mul_add, mul_one, mul_div,
mul_comm (‖x‖ * ‖x‖), ← mul_div, div_self (mul_self_pos.2 (norm_ne_zero_iff.2 h0)).ne', mul_one]
/-- An angle in a non-degenerate right-angled triangle is positive. -/
theorem angle_add_pos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :
0 < angle x (x + y) := by
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_pos,
norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
by_cases hx : x = 0; · simp [hx]
rw [div_lt_one (Real.sqrt_pos.2 (Left.add_pos_of_pos_of_nonneg (mul_self_pos.2
(norm_ne_zero_iff.2 hx)) (mul_self_nonneg _))), Real.lt_sqrt (norm_nonneg _), pow_two]
simpa [hx] using h0
/-- An angle in a right-angled triangle is at most `π / 2`. -/
theorem angle_add_le_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
angle x (x + y) ≤ π / 2 := by
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_le_pi_div_two]
exact div_nonneg (norm_nonneg _) (norm_nonneg _)
/-- An angle in a non-degenerate right-angled triangle is less than `π / 2`. -/
theorem angle_add_lt_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :
angle x (x + y) < π / 2 := by
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_lt_pi_div_two,
norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
exact div_pos (norm_pos_iff.2 h0) (Real.sqrt_pos.2 (Left.add_pos_of_pos_of_nonneg
(mul_self_pos.2 (norm_ne_zero_iff.2 h0)) (mul_self_nonneg _)))
/-- The cosine of an angle in a right-angled triangle as a ratio of sides. -/
theorem cos_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
Real.cos (angle x (x + y)) = ‖x‖ / ‖x + y‖ := by
rw [angle_add_eq_arccos_of_inner_eq_zero h,
Real.cos_arccos (le_trans (by norm_num) (div_nonneg (norm_nonneg _) (norm_nonneg _)))
(div_le_one_of_le₀ _ (norm_nonneg _))]
rw [mul_self_le_mul_self_iff (norm_nonneg _) (norm_nonneg _),
norm_add_sq_eq_norm_sq_add_norm_sq_real h]
exact le_add_of_nonneg_right (mul_self_nonneg _)
/-- The sine of an angle in a right-angled triangle as a ratio of sides. -/
theorem sin_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :
Real.sin (angle x (x + y)) = ‖y‖ / ‖x + y‖ := by
rw [angle_add_eq_arcsin_of_inner_eq_zero h h0,
Real.sin_arcsin (le_trans (by norm_num) (div_nonneg (norm_nonneg _) (norm_nonneg _)))
(div_le_one_of_le₀ _ (norm_nonneg _))]
rw [mul_self_le_mul_self_iff (norm_nonneg _) (norm_nonneg _),
norm_add_sq_eq_norm_sq_add_norm_sq_real h]
exact le_add_of_nonneg_left (mul_self_nonneg _)
/-- The tangent of an angle in a right-angled triangle as a ratio of sides. -/
theorem tan_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
Real.tan (angle x (x + y)) = ‖y‖ / ‖x‖ := by
by_cases h0 : x = 0; · simp [h0]
rw [angle_add_eq_arctan_of_inner_eq_zero h h0, Real.tan_arctan]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side. -/
theorem cos_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
Real.cos (angle x (x + y)) * ‖x + y‖ = ‖x‖ := by
rw [cos_angle_add_of_inner_eq_zero h]
by_cases hxy : ‖x + y‖ = 0
· have h' := norm_add_sq_eq_norm_sq_add_norm_sq_real h
rw [hxy, zero_mul, eq_comm,
add_eq_zero_iff_of_nonneg (mul_self_nonneg ‖x‖) (mul_self_nonneg ‖y‖), mul_self_eq_zero] at h'
simp [h'.1]
· exact div_mul_cancel₀ _ hxy
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side. -/
theorem sin_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
Real.sin (angle x (x + y)) * ‖x + y‖ = ‖y‖ := by
by_cases h0 : x = 0 ∧ y = 0; · simp [h0]
rw [not_and_or] at h0
rw [sin_angle_add_of_inner_eq_zero h h0, div_mul_cancel₀]
rw [← mul_self_ne_zero, norm_add_sq_eq_norm_sq_add_norm_sq_real h]
refine (ne_of_lt ?_).symm
rcases h0 with (h0 | h0)
· exact Left.add_pos_of_pos_of_nonneg (mul_self_pos.2 (norm_ne_zero_iff.2 h0)) (mul_self_nonneg _)
· exact Left.add_pos_of_nonneg_of_pos (mul_self_nonneg _) (mul_self_pos.2 (norm_ne_zero_iff.2 h0))
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side. -/
theorem tan_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y = 0) :
Real.tan (angle x (x + y)) * ‖x‖ = ‖y‖ := by
rw [tan_angle_add_of_inner_eq_zero h]
rcases h0 with (h0 | h0) <;> simp [h0]
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse. -/
theorem norm_div_cos_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y = 0) :
‖x‖ / Real.cos (angle x (x + y)) = ‖x + y‖ := by
rw [cos_angle_add_of_inner_eq_zero h]
rcases h0 with (h0 | h0)
· rw [div_div_eq_mul_div, mul_comm, div_eq_mul_inv, mul_inv_cancel_right₀ (norm_ne_zero_iff.2 h0)]
· simp [h0]
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse. -/
theorem norm_div_sin_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :
‖y‖ / Real.sin (angle x (x + y)) = ‖x + y‖ := by
rcases h0 with (h0 | h0); · simp [h0]
rw [sin_angle_add_of_inner_eq_zero h (Or.inr h0), div_div_eq_mul_div, mul_comm, div_eq_mul_inv,
mul_inv_cancel_right₀ (norm_ne_zero_iff.2 h0)]
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side. -/
theorem norm_div_tan_angle_add_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :
‖y‖ / Real.tan (angle x (x + y)) = ‖x‖ := by
rw [tan_angle_add_of_inner_eq_zero h]
rcases h0 with (h0 | h0)
· simp [h0]
· rw [div_div_eq_mul_div, mul_comm, div_eq_mul_inv, mul_inv_cancel_right₀ (norm_ne_zero_iff.2 h0)]
/-- An angle in a right-angled triangle expressed using `arccos`, version subtracting vectors. -/
theorem angle_sub_eq_arccos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
angle x (x - y) = Real.arccos (‖x‖ / ‖x - y‖) := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [sub_eq_add_neg, angle_add_eq_arccos_of_inner_eq_zero h]
/-- An angle in a right-angled triangle expressed using `arcsin`, version subtracting vectors. -/
theorem angle_sub_eq_arcsin_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :
angle x (x - y) = Real.arcsin (‖y‖ / ‖x - y‖) := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [or_comm, ← neg_ne_zero, or_comm] at h0
rw [sub_eq_add_neg, angle_add_eq_arcsin_of_inner_eq_zero h h0, norm_neg]
/-- An angle in a right-angled triangle expressed using `arctan`, version subtracting vectors. -/
theorem angle_sub_eq_arctan_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :
angle x (x - y) = Real.arctan (‖y‖ / ‖x‖) := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [sub_eq_add_neg, angle_add_eq_arctan_of_inner_eq_zero h h0, norm_neg]
/-- An angle in a non-degenerate right-angled triangle is positive, version subtracting
vectors. -/
theorem angle_sub_pos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :
0 < angle x (x - y) := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [← neg_ne_zero] at h0
rw [sub_eq_add_neg]
exact angle_add_pos_of_inner_eq_zero h h0
/-- An angle in a right-angled triangle is at most `π / 2`, version subtracting vectors. -/
theorem angle_sub_le_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
angle x (x - y) ≤ π / 2 := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [sub_eq_add_neg]
exact angle_add_le_pi_div_two_of_inner_eq_zero h
/-- An angle in a non-degenerate right-angled triangle is less than `π / 2`, version subtracting
vectors. -/
theorem angle_sub_lt_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :
angle x (x - y) < π / 2 := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [sub_eq_add_neg]
exact angle_add_lt_pi_div_two_of_inner_eq_zero h h0
/-- The cosine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem cos_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
Real.cos (angle x (x - y)) = ‖x‖ / ‖x - y‖ := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [sub_eq_add_neg, cos_angle_add_of_inner_eq_zero h]
/-- The sine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem sin_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :
Real.sin (angle x (x - y)) = ‖y‖ / ‖x - y‖ := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [or_comm, ← neg_ne_zero, or_comm] at h0
rw [sub_eq_add_neg, sin_angle_add_of_inner_eq_zero h h0, norm_neg]
/-- The tangent of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem tan_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
Real.tan (angle x (x - y)) = ‖y‖ / ‖x‖ := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [sub_eq_add_neg, tan_angle_add_of_inner_eq_zero h, norm_neg]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side, version subtracting vectors. -/
theorem cos_angle_sub_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
Real.cos (angle x (x - y)) * ‖x - y‖ = ‖x‖ := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [sub_eq_add_neg, cos_angle_add_mul_norm_of_inner_eq_zero h]
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side, version subtracting vectors. -/
theorem sin_angle_sub_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
Real.sin (angle x (x - y)) * ‖x - y‖ = ‖y‖ := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [sub_eq_add_neg, sin_angle_add_mul_norm_of_inner_eq_zero h, norm_neg]
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side, version subtracting vectors. -/
theorem tan_angle_sub_mul_norm_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y = 0) :
Real.tan (angle x (x - y)) * ‖x‖ = ‖y‖ := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [← neg_eq_zero] at h0
rw [sub_eq_add_neg, tan_angle_add_mul_norm_of_inner_eq_zero h h0, norm_neg]
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_cos_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y = 0) :
‖x‖ / Real.cos (angle x (x - y)) = ‖x - y‖ := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [← neg_eq_zero] at h0
rw [sub_eq_add_neg, norm_div_cos_angle_add_of_inner_eq_zero h h0]
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_sin_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :
‖y‖ / Real.sin (angle x (x - y)) = ‖x - y‖ := by
rw [← neg_eq_zero, ← inner_neg_right] at h
rw [← neg_ne_zero] at h0
rw [sub_eq_add_neg, ← norm_neg, norm_div_sin_angle_add_of_inner_eq_zero h h0]
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side, version subtracting vectors. -/
| Mathlib/Geometry/Euclidean/Angle/Unoriented/RightAngle.lean | 308 | 311 | theorem norm_div_tan_angle_sub_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :
‖y‖ / Real.tan (angle x (x - y)) = ‖x‖ := by | rw [← neg_eq_zero, ← inner_neg_right] at h
rw [← neg_ne_zero] at h0 |
/-
Copyright (c) 2021 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import Mathlib.MeasureTheory.Integral.FinMeasAdditive
/-!
# Extension of a linear function from indicators to L1
Given `T : Set α → E →L[ℝ] F` with `DominatedFinMeasAdditive μ T C`, we construct an extension
of `T` to integrable simple functions, which are finite sums of indicators of measurable sets
with finite measure, then to integrable functions, which are limits of integrable simple functions.
The main result is a continuous linear map `(α →₁[μ] E) →L[ℝ] F`.
This extension process is used to define the Bochner integral
in the `Mathlib.MeasureTheory.Integral.Bochner.Basic` file
and the conditional expectation of an integrable function
in `Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL1`.
## Main definitions
- `setToL1 (hT : DominatedFinMeasAdditive μ T C) : (α →₁[μ] E) →L[ℝ] F`: the extension of `T`
from indicators to L1.
- `setToFun μ T (hT : DominatedFinMeasAdditive μ T C) (f : α → E) : F`: a version of the
extension which applies to functions (with value 0 if the function is not integrable).
## Properties
For most properties of `setToFun`, we provide two lemmas. One version uses hypotheses valid on
all sets, like `T = T'`, and a second version which uses a primed name uses hypotheses on
measurable sets with finite measure, like `∀ s, MeasurableSet s → μ s < ∞ → T s = T' s`.
The lemmas listed here don't show all hypotheses. Refer to the actual lemmas for details.
Linearity:
- `setToFun_zero_left : setToFun μ 0 hT f = 0`
- `setToFun_add_left : setToFun μ (T + T') _ f = setToFun μ T hT f + setToFun μ T' hT' f`
- `setToFun_smul_left : setToFun μ (fun s ↦ c • (T s)) (hT.smul c) f = c • setToFun μ T hT f`
- `setToFun_zero : setToFun μ T hT (0 : α → E) = 0`
- `setToFun_neg : setToFun μ T hT (-f) = - setToFun μ T hT f`
If `f` and `g` are integrable:
- `setToFun_add : setToFun μ T hT (f + g) = setToFun μ T hT f + setToFun μ T hT g`
- `setToFun_sub : setToFun μ T hT (f - g) = setToFun μ T hT f - setToFun μ T hT g`
If `T` is verifies `∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x`:
- `setToFun_smul : setToFun μ T hT (c • f) = c • setToFun μ T hT f`
Other:
- `setToFun_congr_ae (h : f =ᵐ[μ] g) : setToFun μ T hT f = setToFun μ T hT g`
- `setToFun_measure_zero (h : μ = 0) : setToFun μ T hT f = 0`
If the space is also an ordered additive group with an order closed topology and `T` is such that
`0 ≤ T s x` for `0 ≤ x`, we also prove order-related properties:
- `setToFun_mono_left (h : ∀ s x, T s x ≤ T' s x) : setToFun μ T hT f ≤ setToFun μ T' hT' f`
- `setToFun_nonneg (hf : 0 ≤ᵐ[μ] f) : 0 ≤ setToFun μ T hT f`
- `setToFun_mono (hfg : f ≤ᵐ[μ] g) : setToFun μ T hT f ≤ setToFun μ T hT g`
-/
noncomputable section
open scoped Topology NNReal
open Set Filter TopologicalSpace ENNReal
namespace MeasureTheory
variable {α E F F' G 𝕜 : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
[NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup F'] [NormedSpace ℝ F']
[NormedAddCommGroup G] {m : MeasurableSpace α} {μ : Measure α}
namespace L1
open AEEqFun Lp.simpleFunc Lp
namespace SimpleFunc
theorem norm_eq_sum_mul (f : α →₁ₛ[μ] G) :
‖f‖ = ∑ x ∈ (toSimpleFunc f).range, μ.real (toSimpleFunc f ⁻¹' {x}) * ‖x‖ := by
rw [norm_toSimpleFunc, eLpNorm_one_eq_lintegral_enorm]
have h_eq := SimpleFunc.map_apply (‖·‖ₑ) (toSimpleFunc f)
simp_rw [← h_eq, measureReal_def]
rw [SimpleFunc.lintegral_eq_lintegral, SimpleFunc.map_lintegral, ENNReal.toReal_sum]
· congr
ext1 x
rw [ENNReal.toReal_mul, mul_comm, ← ofReal_norm_eq_enorm,
ENNReal.toReal_ofReal (norm_nonneg _)]
· intro x _
by_cases hx0 : x = 0
· rw [hx0]; simp
· exact
ENNReal.mul_ne_top ENNReal.coe_ne_top
(SimpleFunc.measure_preimage_lt_top_of_integrable _ (SimpleFunc.integrable f) hx0).ne
section SetToL1S
variable [NormedField 𝕜] [NormedSpace 𝕜 E]
attribute [local instance] Lp.simpleFunc.module
attribute [local instance] Lp.simpleFunc.normedSpace
/-- Extend `Set α → (E →L[ℝ] F')` to `(α →₁ₛ[μ] E) → F'`. -/
def setToL1S (T : Set α → E →L[ℝ] F) (f : α →₁ₛ[μ] E) : F :=
(toSimpleFunc f).setToSimpleFunc T
theorem setToL1S_eq_setToSimpleFunc (T : Set α → E →L[ℝ] F) (f : α →₁ₛ[μ] E) :
setToL1S T f = (toSimpleFunc f).setToSimpleFunc T :=
rfl
@[simp]
theorem setToL1S_zero_left (f : α →₁ₛ[μ] E) : setToL1S (0 : Set α → E →L[ℝ] F) f = 0 :=
SimpleFunc.setToSimpleFunc_zero _
theorem setToL1S_zero_left' {T : Set α → E →L[ℝ] F}
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →₁ₛ[μ] E) : setToL1S T f = 0 :=
SimpleFunc.setToSimpleFunc_zero' h_zero _ (SimpleFunc.integrable f)
theorem setToL1S_congr (T : Set α → E →L[ℝ] F) (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) {f g : α →₁ₛ[μ] E} (h : toSimpleFunc f =ᵐ[μ] toSimpleFunc g) :
setToL1S T f = setToL1S T g :=
SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable f) h
theorem setToL1S_congr_left (T T' : Set α → E →L[ℝ] F)
(h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s) (f : α →₁ₛ[μ] E) :
setToL1S T f = setToL1S T' f :=
SimpleFunc.setToSimpleFunc_congr_left T T' h (simpleFunc.toSimpleFunc f) (SimpleFunc.integrable f)
/-- `setToL1S` does not change if we replace the measure `μ` by `μ'` with `μ ≪ μ'`. The statement
uses two functions `f` and `f'` because they have to belong to different types, but morally these
are the same function (we have `f =ᵐ[μ] f'`). -/
theorem setToL1S_congr_measure {μ' : Measure α} (T : Set α → E →L[ℝ] F)
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T) (hμ : μ ≪ μ')
(f : α →₁ₛ[μ] E) (f' : α →₁ₛ[μ'] E) (h : (f : α → E) =ᵐ[μ] f') :
setToL1S T f = setToL1S T f' := by
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable f) ?_
refine (toSimpleFunc_eq_toFun f).trans ?_
suffices (f' : α → E) =ᵐ[μ] simpleFunc.toSimpleFunc f' from h.trans this
have goal' : (f' : α → E) =ᵐ[μ'] simpleFunc.toSimpleFunc f' := (toSimpleFunc_eq_toFun f').symm
exact hμ.ae_eq goal'
theorem setToL1S_add_left (T T' : Set α → E →L[ℝ] F) (f : α →₁ₛ[μ] E) :
setToL1S (T + T') f = setToL1S T f + setToL1S T' f :=
SimpleFunc.setToSimpleFunc_add_left T T'
theorem setToL1S_add_left' (T T' T'' : Set α → E →L[ℝ] F)
(h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) (f : α →₁ₛ[μ] E) :
setToL1S T'' f = setToL1S T f + setToL1S T' f :=
SimpleFunc.setToSimpleFunc_add_left' T T' T'' h_add (SimpleFunc.integrable f)
theorem setToL1S_smul_left (T : Set α → E →L[ℝ] F) (c : ℝ) (f : α →₁ₛ[μ] E) :
setToL1S (fun s => c • T s) f = c • setToL1S T f :=
SimpleFunc.setToSimpleFunc_smul_left T c _
theorem setToL1S_smul_left' (T T' : Set α → E →L[ℝ] F) (c : ℝ)
(h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) (f : α →₁ₛ[μ] E) :
setToL1S T' f = c • setToL1S T f :=
SimpleFunc.setToSimpleFunc_smul_left' T T' c h_smul (SimpleFunc.integrable f)
theorem setToL1S_add (T : Set α → E →L[ℝ] F) (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) (f g : α →₁ₛ[μ] E) :
setToL1S T (f + g) = setToL1S T f + setToL1S T g := by
simp_rw [setToL1S]
rw [← SimpleFunc.setToSimpleFunc_add T h_add (SimpleFunc.integrable f)
(SimpleFunc.integrable g)]
exact
SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _)
(add_toSimpleFunc f g)
theorem setToL1S_neg {T : Set α → E →L[ℝ] F} (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) (f : α →₁ₛ[μ] E) : setToL1S T (-f) = -setToL1S T f := by
simp_rw [setToL1S]
have : simpleFunc.toSimpleFunc (-f) =ᵐ[μ] ⇑(-simpleFunc.toSimpleFunc f) :=
neg_toSimpleFunc f
rw [SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) this]
exact SimpleFunc.setToSimpleFunc_neg T h_add (SimpleFunc.integrable f)
theorem setToL1S_sub {T : Set α → E →L[ℝ] F} (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) (f g : α →₁ₛ[μ] E) :
setToL1S T (f - g) = setToL1S T f - setToL1S T g := by
rw [sub_eq_add_neg, setToL1S_add T h_zero h_add, setToL1S_neg h_zero h_add, sub_eq_add_neg]
theorem setToL1S_smul_real (T : Set α → E →L[ℝ] F)
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T) (c : ℝ)
(f : α →₁ₛ[μ] E) : setToL1S T (c • f) = c • setToL1S T f := by
simp_rw [setToL1S]
rw [← SimpleFunc.setToSimpleFunc_smul_real T h_add c (SimpleFunc.integrable f)]
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact smul_toSimpleFunc c f
theorem setToL1S_smul {E} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E]
[DistribSMul 𝕜 F] (T : Set α → E →L[ℝ] F) (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) (h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (c : 𝕜)
(f : α →₁ₛ[μ] E) : setToL1S T (c • f) = c • setToL1S T f := by
simp_rw [setToL1S]
rw [← SimpleFunc.setToSimpleFunc_smul T h_add h_smul c (SimpleFunc.integrable f)]
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact smul_toSimpleFunc c f
theorem norm_setToL1S_le (T : Set α → E →L[ℝ] F) {C : ℝ}
(hT_norm : ∀ s, MeasurableSet s → μ s < ∞ → ‖T s‖ ≤ C * μ.real s) (f : α →₁ₛ[μ] E) :
‖setToL1S T f‖ ≤ C * ‖f‖ := by
rw [setToL1S, norm_eq_sum_mul f]
exact
SimpleFunc.norm_setToSimpleFunc_le_sum_mul_norm_of_integrable T hT_norm _
(SimpleFunc.integrable f)
theorem setToL1S_indicatorConst {T : Set α → E →L[ℝ] F} {s : Set α}
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T)
(hs : MeasurableSet s) (hμs : μ s < ∞) (x : E) :
setToL1S T (simpleFunc.indicatorConst 1 hs hμs.ne x) = T s x := by
have h_empty : T ∅ = 0 := h_zero _ MeasurableSet.empty measure_empty
rw [setToL1S_eq_setToSimpleFunc]
refine Eq.trans ?_ (SimpleFunc.setToSimpleFunc_indicator T h_empty hs x)
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact toSimpleFunc_indicatorConst hs hμs.ne x
theorem setToL1S_const [IsFiniteMeasure μ] {T : Set α → E →L[ℝ] F}
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T) (x : E) :
setToL1S T (simpleFunc.indicatorConst 1 MeasurableSet.univ (measure_ne_top μ _) x) = T univ x :=
setToL1S_indicatorConst h_zero h_add MeasurableSet.univ (measure_lt_top _ _) x
section Order
variable {G'' G' : Type*}
[NormedAddCommGroup G'] [PartialOrder G'] [IsOrderedAddMonoid G'] [NormedSpace ℝ G']
[NormedAddCommGroup G''] [PartialOrder G''] [IsOrderedAddMonoid G''] [NormedSpace ℝ G'']
{T : Set α → G'' →L[ℝ] G'}
theorem setToL1S_mono_left {T T' : Set α → E →L[ℝ] G''} (hTT' : ∀ s x, T s x ≤ T' s x)
(f : α →₁ₛ[μ] E) : setToL1S T f ≤ setToL1S T' f :=
SimpleFunc.setToSimpleFunc_mono_left T T' hTT' _
theorem setToL1S_mono_left' {T T' : Set α → E →L[ℝ] G''}
(hTT' : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, T s x ≤ T' s x) (f : α →₁ₛ[μ] E) :
setToL1S T f ≤ setToL1S T' f :=
SimpleFunc.setToSimpleFunc_mono_left' T T' hTT' _ (SimpleFunc.integrable f)
omit [IsOrderedAddMonoid G''] in
theorem setToL1S_nonneg (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f : α →₁ₛ[μ] G''}
(hf : 0 ≤ f) : 0 ≤ setToL1S T f := by
simp_rw [setToL1S]
obtain ⟨f', hf', hff'⟩ := exists_simpleFunc_nonneg_ae_eq hf
replace hff' : simpleFunc.toSimpleFunc f =ᵐ[μ] f' :=
(Lp.simpleFunc.toSimpleFunc_eq_toFun f).trans hff'
rw [SimpleFunc.setToSimpleFunc_congr _ h_zero h_add (SimpleFunc.integrable _) hff']
exact
SimpleFunc.setToSimpleFunc_nonneg' T hT_nonneg _ hf' ((SimpleFunc.integrable f).congr hff')
theorem setToL1S_mono (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f g : α →₁ₛ[μ] G''}
(hfg : f ≤ g) : setToL1S T f ≤ setToL1S T g := by
rw [← sub_nonneg] at hfg ⊢
rw [← setToL1S_sub h_zero h_add]
exact setToL1S_nonneg h_zero h_add hT_nonneg hfg
end Order
variable [NormedSpace 𝕜 F]
variable (α E μ 𝕜)
/-- Extend `Set α → E →L[ℝ] F` to `(α →₁ₛ[μ] E) →L[𝕜] F`. -/
def setToL1SCLM' {T : Set α → E →L[ℝ] F} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) : (α →₁ₛ[μ] E) →L[𝕜] F :=
LinearMap.mkContinuous
⟨⟨setToL1S T, setToL1S_add T (fun _ => hT.eq_zero_of_measure_zero) hT.1⟩,
setToL1S_smul T (fun _ => hT.eq_zero_of_measure_zero) hT.1 h_smul⟩
C fun f => norm_setToL1S_le T hT.2 f
/-- Extend `Set α → E →L[ℝ] F` to `(α →₁ₛ[μ] E) →L[ℝ] F`. -/
def setToL1SCLM {T : Set α → E →L[ℝ] F} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C) :
(α →₁ₛ[μ] E) →L[ℝ] F :=
LinearMap.mkContinuous
⟨⟨setToL1S T, setToL1S_add T (fun _ => hT.eq_zero_of_measure_zero) hT.1⟩,
setToL1S_smul_real T (fun _ => hT.eq_zero_of_measure_zero) hT.1⟩
C fun f => norm_setToL1S_le T hT.2 f
variable {α E μ 𝕜}
variable {T T' T'' : Set α → E →L[ℝ] F} {C C' C'' : ℝ}
@[simp]
theorem setToL1SCLM_zero_left (hT : DominatedFinMeasAdditive μ (0 : Set α → E →L[ℝ] F) C)
(f : α →₁ₛ[μ] E) : setToL1SCLM α E μ hT f = 0 :=
setToL1S_zero_left _
theorem setToL1SCLM_zero_left' (hT : DominatedFinMeasAdditive μ T C)
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT f = 0 :=
setToL1S_zero_left' h_zero f
theorem setToL1SCLM_congr_left (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (h : T = T') (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT f = setToL1SCLM α E μ hT' f :=
setToL1S_congr_left T T' (fun _ _ _ => by rw [h]) f
theorem setToL1SCLM_congr_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s)
(f : α →₁ₛ[μ] E) : setToL1SCLM α E μ hT f = setToL1SCLM α E μ hT' f :=
setToL1S_congr_left T T' h f
theorem setToL1SCLM_congr_measure {μ' : Measure α} (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ' T C') (hμ : μ ≪ μ') (f : α →₁ₛ[μ] E) (f' : α →₁ₛ[μ'] E)
(h : (f : α → E) =ᵐ[μ] f') : setToL1SCLM α E μ hT f = setToL1SCLM α E μ' hT' f' :=
setToL1S_congr_measure T (fun _ => hT.eq_zero_of_measure_zero) hT.1 hμ _ _ h
theorem setToL1SCLM_add_left (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ (hT.add hT') f = setToL1SCLM α E μ hT f + setToL1SCLM α E μ hT' f :=
setToL1S_add_left T T' f
theorem setToL1SCLM_add_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (hT'' : DominatedFinMeasAdditive μ T'' C'')
(h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT'' f = setToL1SCLM α E μ hT f + setToL1SCLM α E μ hT' f :=
setToL1S_add_left' T T' T'' h_add f
theorem setToL1SCLM_smul_left (c : ℝ) (hT : DominatedFinMeasAdditive μ T C) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ (hT.smul c) f = c • setToL1SCLM α E μ hT f :=
setToL1S_smul_left T c f
theorem setToL1SCLM_smul_left' (c : ℝ) (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C')
(h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT' f = c • setToL1SCLM α E μ hT f :=
setToL1S_smul_left' T T' c h_smul f
theorem norm_setToL1SCLM_le {T : Set α → E →L[ℝ] F} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(hC : 0 ≤ C) : ‖setToL1SCLM α E μ hT‖ ≤ C :=
LinearMap.mkContinuous_norm_le _ hC _
theorem norm_setToL1SCLM_le' {T : Set α → E →L[ℝ] F} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C) :
‖setToL1SCLM α E μ hT‖ ≤ max C 0 :=
LinearMap.mkContinuous_norm_le' _ _
theorem setToL1SCLM_const [IsFiniteMeasure μ] {T : Set α → E →L[ℝ] F} {C : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (x : E) :
setToL1SCLM α E μ hT (simpleFunc.indicatorConst 1 MeasurableSet.univ (measure_ne_top μ _) x) =
T univ x :=
setToL1S_const (fun _ => hT.eq_zero_of_measure_zero) hT.1 x
section Order
variable {G' G'' : Type*}
[NormedAddCommGroup G''] [PartialOrder G''] [IsOrderedAddMonoid G''] [NormedSpace ℝ G'']
[NormedAddCommGroup G'] [PartialOrder G'] [IsOrderedAddMonoid G'] [NormedSpace ℝ G']
theorem setToL1SCLM_mono_left {T T' : Set α → E →L[ℝ] G''} {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(hTT' : ∀ s x, T s x ≤ T' s x) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT f ≤ setToL1SCLM α E μ hT' f :=
SimpleFunc.setToSimpleFunc_mono_left T T' hTT' _
theorem setToL1SCLM_mono_left' {T T' : Set α → E →L[ℝ] G''} {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(hTT' : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, T s x ≤ T' s x) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT f ≤ setToL1SCLM α E μ hT' f :=
SimpleFunc.setToSimpleFunc_mono_left' T T' hTT' _ (SimpleFunc.integrable f)
omit [IsOrderedAddMonoid G'] in
theorem setToL1SCLM_nonneg {T : Set α → G' →L[ℝ] G''} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f : α →₁ₛ[μ] G'}
(hf : 0 ≤ f) : 0 ≤ setToL1SCLM α G' μ hT f :=
setToL1S_nonneg (fun _ => hT.eq_zero_of_measure_zero) hT.1 hT_nonneg hf
theorem setToL1SCLM_mono {T : Set α → G' →L[ℝ] G''} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f g : α →₁ₛ[μ] G'}
(hfg : f ≤ g) : setToL1SCLM α G' μ hT f ≤ setToL1SCLM α G' μ hT g :=
setToL1S_mono (fun _ => hT.eq_zero_of_measure_zero) hT.1 hT_nonneg hfg
end Order
end SetToL1S
end SimpleFunc
open SimpleFunc
section SetToL1
attribute [local instance] Lp.simpleFunc.module
attribute [local instance] Lp.simpleFunc.normedSpace
variable (𝕜) [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] [CompleteSpace F]
{T T' T'' : Set α → E →L[ℝ] F} {C C' C'' : ℝ}
/-- Extend `Set α → (E →L[ℝ] F)` to `(α →₁[μ] E) →L[𝕜] F`. -/
def setToL1' (hT : DominatedFinMeasAdditive μ T C)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) : (α →₁[μ] E) →L[𝕜] F :=
(setToL1SCLM' α E 𝕜 μ hT h_smul).extend (coeToLp α E 𝕜) (simpleFunc.denseRange one_ne_top)
simpleFunc.isUniformInducing
variable {𝕜}
/-- Extend `Set α → E →L[ℝ] F` to `(α →₁[μ] E) →L[ℝ] F`. -/
def setToL1 (hT : DominatedFinMeasAdditive μ T C) : (α →₁[μ] E) →L[ℝ] F :=
(setToL1SCLM α E μ hT).extend (coeToLp α E ℝ) (simpleFunc.denseRange one_ne_top)
simpleFunc.isUniformInducing
theorem setToL1_eq_setToL1SCLM (hT : DominatedFinMeasAdditive μ T C) (f : α →₁ₛ[μ] E) :
setToL1 hT f = setToL1SCLM α E μ hT f :=
uniformly_extend_of_ind simpleFunc.isUniformInducing (simpleFunc.denseRange one_ne_top)
(setToL1SCLM α E μ hT).uniformContinuous _
theorem setToL1_eq_setToL1' (hT : DominatedFinMeasAdditive μ T C)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (f : α →₁[μ] E) :
setToL1 hT f = setToL1' 𝕜 hT h_smul f :=
rfl
@[simp]
theorem setToL1_zero_left (hT : DominatedFinMeasAdditive μ (0 : Set α → E →L[ℝ] F) C)
(f : α →₁[μ] E) : setToL1 hT f = 0 := by
suffices setToL1 hT = 0 by rw [this]; simp
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT) _ _ _ _ ?_
ext1 f
rw [setToL1SCLM_zero_left hT f, ContinuousLinearMap.zero_comp, ContinuousLinearMap.zero_apply]
theorem setToL1_zero_left' (hT : DominatedFinMeasAdditive μ T C)
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →₁[μ] E) : setToL1 hT f = 0 := by
suffices setToL1 hT = 0 by rw [this]; simp
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT) _ _ _ _ ?_
ext1 f
rw [setToL1SCLM_zero_left' hT h_zero f, ContinuousLinearMap.zero_comp,
ContinuousLinearMap.zero_apply]
theorem setToL1_congr_left (T T' : Set α → E →L[ℝ] F) {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C') (h : T = T')
(f : α →₁[μ] E) : setToL1 hT f = setToL1 hT' f := by
suffices setToL1 hT = setToL1 hT' by rw [this]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT) _ _ _ _ ?_
ext1 f
suffices setToL1 hT' f = setToL1SCLM α E μ hT f by rw [← this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM]
exact setToL1SCLM_congr_left hT' hT h.symm f
theorem setToL1_congr_left' (T T' : Set α → E →L[ℝ] F) {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s) (f : α →₁[μ] E) :
setToL1 hT f = setToL1 hT' f := by
suffices setToL1 hT = setToL1 hT' by rw [this]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT) _ _ _ _ ?_
ext1 f
suffices setToL1 hT' f = setToL1SCLM α E μ hT f by rw [← this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM]
exact (setToL1SCLM_congr_left' hT hT' h f).symm
theorem setToL1_add_left (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (f : α →₁[μ] E) :
setToL1 (hT.add hT') f = setToL1 hT f + setToL1 hT' f := by
suffices setToL1 (hT.add hT') = setToL1 hT + setToL1 hT' by
rw [this, ContinuousLinearMap.add_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ (hT.add hT')) _ _ _ _ ?_
ext1 f
suffices setToL1 hT f + setToL1 hT' f = setToL1SCLM α E μ (hT.add hT') f by
rw [← this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM, setToL1_eq_setToL1SCLM, setToL1SCLM_add_left hT hT']
theorem setToL1_add_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (hT'' : DominatedFinMeasAdditive μ T'' C'')
(h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) (f : α →₁[μ] E) :
setToL1 hT'' f = setToL1 hT f + setToL1 hT' f := by
suffices setToL1 hT'' = setToL1 hT + setToL1 hT' by rw [this, ContinuousLinearMap.add_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT'') _ _ _ _ ?_
ext1 f
suffices setToL1 hT f + setToL1 hT' f = setToL1SCLM α E μ hT'' f by rw [← this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM, setToL1_eq_setToL1SCLM,
setToL1SCLM_add_left' hT hT' hT'' h_add]
theorem setToL1_smul_left (hT : DominatedFinMeasAdditive μ T C) (c : ℝ) (f : α →₁[μ] E) :
setToL1 (hT.smul c) f = c • setToL1 hT f := by
suffices setToL1 (hT.smul c) = c • setToL1 hT by rw [this, ContinuousLinearMap.smul_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ (hT.smul c)) _ _ _ _ ?_
ext1 f
suffices c • setToL1 hT f = setToL1SCLM α E μ (hT.smul c) f by rw [← this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM, setToL1SCLM_smul_left c hT]
theorem setToL1_smul_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (c : ℝ)
(h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) (f : α →₁[μ] E) :
setToL1 hT' f = c • setToL1 hT f := by
suffices setToL1 hT' = c • setToL1 hT by rw [this, ContinuousLinearMap.smul_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT') _ _ _ _ ?_
ext1 f
suffices c • setToL1 hT f = setToL1SCLM α E μ hT' f by rw [← this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM, setToL1SCLM_smul_left' c hT hT' h_smul]
theorem setToL1_smul (hT : DominatedFinMeasAdditive μ T C)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (c : 𝕜) (f : α →₁[μ] E) :
setToL1 hT (c • f) = c • setToL1 hT f := by
rw [setToL1_eq_setToL1' hT h_smul, setToL1_eq_setToL1' hT h_smul]
exact ContinuousLinearMap.map_smul _ _ _
theorem setToL1_simpleFunc_indicatorConst (hT : DominatedFinMeasAdditive μ T C) {s : Set α}
(hs : MeasurableSet s) (hμs : μ s < ∞) (x : E) :
setToL1 hT (simpleFunc.indicatorConst 1 hs hμs.ne x) = T s x := by
rw [setToL1_eq_setToL1SCLM]
exact setToL1S_indicatorConst (fun s => hT.eq_zero_of_measure_zero) hT.1 hs hμs x
theorem setToL1_indicatorConstLp (hT : DominatedFinMeasAdditive μ T C) {s : Set α}
(hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E) :
setToL1 hT (indicatorConstLp 1 hs hμs x) = T s x := by
rw [← Lp.simpleFunc.coe_indicatorConst hs hμs x]
exact setToL1_simpleFunc_indicatorConst hT hs hμs.lt_top x
theorem setToL1_const [IsFiniteMeasure μ] (hT : DominatedFinMeasAdditive μ T C) (x : E) :
setToL1 hT (indicatorConstLp 1 MeasurableSet.univ (measure_ne_top _ _) x) = T univ x :=
setToL1_indicatorConstLp hT MeasurableSet.univ (measure_ne_top _ _) x
section Order
variable {G' G'' : Type*}
[NormedAddCommGroup G''] [PartialOrder G''] [OrderClosedTopology G''] [IsOrderedAddMonoid G'']
[NormedSpace ℝ G''] [CompleteSpace G'']
[NormedAddCommGroup G'] [PartialOrder G'] [NormedSpace ℝ G']
| Mathlib/MeasureTheory/Integral/SetToL1.lean | 519 | 525 | theorem setToL1_mono_left' {T T' : Set α → E →L[ℝ] G''} {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(hTT' : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, T s x ≤ T' s x) (f : α →₁[μ] E) :
setToL1 hT f ≤ setToL1 hT' f := by | induction f using Lp.induction (hp_ne_top := one_ne_top) with
| @indicatorConst c s hs hμs =>
rw [setToL1_simpleFunc_indicatorConst hT hs hμs, setToL1_simpleFunc_indicatorConst hT' hs hμs] |
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.Analytic.IsolatedZeros
import Mathlib.Analysis.SpecialFunctions.Complex.CircleMap
import Mathlib.Analysis.SpecialFunctions.NonIntegrable
/-!
# Integral over a circle in `ℂ`
In this file we define `∮ z in C(c, R), f z` to be the integral $\oint_{|z-c|=|R|} f(z)\,dz$ and
prove some properties of this integral. We give definition and prove most lemmas for a function
`f : ℂ → E`, where `E` is a complex Banach space. For this reason,
some lemmas use, e.g., `(z - c)⁻¹ • f z` instead of `f z / (z - c)`.
## Main definitions
* `CircleIntegrable f c R`: a function `f : ℂ → E` is integrable on the circle with center `c` and
radius `R` if `f ∘ circleMap c R` is integrable on `[0, 2π]`;
* `circleIntegral f c R`: the integral $\oint_{|z-c|=|R|} f(z)\,dz$, defined as
$\int_{0}^{2π}(c + Re^{θ i})' f(c+Re^{θ i})\,dθ$;
* `cauchyPowerSeries f c R`: the power series that is equal to
$\sum_{n=0}^{\infty} \oint_{|z-c|=R} \left(\frac{w-c}{z - c}\right)^n \frac{1}{z-c}f(z)\,dz$ at
`w - c`. The coefficients of this power series depend only on `f ∘ circleMap c R`, and the power
series converges to `f w` if `f` is differentiable on the closed ball `Metric.closedBall c R`
and `w` belongs to the corresponding open ball.
## Main statements
* `hasFPowerSeriesOn_cauchy_integral`: for any circle integrable function `f`, the power series
`cauchyPowerSeries f c R`, `R > 0`, converges to the Cauchy integral
`(2 * π * I : ℂ)⁻¹ • ∮ z in C(c, R), (z - w)⁻¹ • f z` on the open disc `Metric.ball c R`;
* `circleIntegral.integral_sub_zpow_of_undef`, `circleIntegral.integral_sub_zpow_of_ne`, and
`circleIntegral.integral_sub_inv_of_mem_ball`: formulas for `∮ z in C(c, R), (z - w) ^ n`,
`n : ℤ`. These lemmas cover the following cases:
- `circleIntegral.integral_sub_zpow_of_undef`, `n < 0` and `|w - c| = |R|`: in this case the
function is not integrable, so the integral is equal to its default value (zero);
- `circleIntegral.integral_sub_zpow_of_ne`, `n ≠ -1`: in the cases not covered by the previous
lemma, we have `(z - w) ^ n = ((z - w) ^ (n + 1) / (n + 1))'`, thus the integral equals zero;
- `circleIntegral.integral_sub_inv_of_mem_ball`, `n = -1`, `|w - c| < R`: in this case the
integral is equal to `2πi`.
The case `n = -1`, `|w -c| > R` is not covered by these lemmas. While it is possible to construct
an explicit primitive, it is easier to apply Cauchy theorem, so we postpone the proof till we have
this theorem (see https://github.com/leanprover-community/mathlib4/pull/10000).
## Notation
- `∮ z in C(c, R), f z`: notation for the integral $\oint_{|z-c|=|R|} f(z)\,dz$, defined as
$\int_{0}^{2π}(c + Re^{θ i})' f(c+Re^{θ i})\,dθ$.
## Tags
integral, circle, Cauchy integral
-/
variable {E : Type*} [NormedAddCommGroup E]
noncomputable section
open scoped Real NNReal Interval Pointwise Topology
open Complex MeasureTheory TopologicalSpace Metric Function Set Filter Asymptotics
/-!
### Facts about `circleMap`
-/
/-- The range of `circleMap c R` is the circle with center `c` and radius `|R|`. -/
@[simp]
theorem range_circleMap (c : ℂ) (R : ℝ) : range (circleMap c R) = sphere c |R| :=
calc
range (circleMap c R) = c +ᵥ R • range fun θ : ℝ => exp (θ * I) := by
simp +unfoldPartialApp only [← image_vadd, ← image_smul, ← range_comp,
vadd_eq_add, circleMap, comp_def, real_smul]
_ = sphere c |R| := by
rw [range_exp_mul_I, smul_sphere R 0 zero_le_one]
simp
/-- The image of `(0, 2π]` under `circleMap c R` is the circle with center `c` and radius `|R|`. -/
@[simp]
theorem image_circleMap_Ioc (c : ℂ) (R : ℝ) : circleMap c R '' Ioc 0 (2 * π) = sphere c |R| := by
rw [← range_circleMap, ← (periodic_circleMap c R).image_Ioc Real.two_pi_pos 0, zero_add]
theorem hasDerivAt_circleMap (c : ℂ) (R : ℝ) (θ : ℝ) :
HasDerivAt (circleMap c R) (circleMap 0 R θ * I) θ := by
simpa only [mul_assoc, one_mul, ofRealCLM_apply, circleMap, ofReal_one, zero_add]
using (((ofRealCLM.hasDerivAt (x := θ)).mul_const I).cexp.const_mul (R : ℂ)).const_add c
theorem differentiable_circleMap (c : ℂ) (R : ℝ) : Differentiable ℝ (circleMap c R) := fun θ =>
(hasDerivAt_circleMap c R θ).differentiableAt
/-- The circleMap is real analytic. -/
theorem analyticOnNhd_circleMap (c : ℂ) (R : ℝ) :
AnalyticOnNhd ℝ (circleMap c R) Set.univ := by
intro z hz
apply analyticAt_const.add
apply analyticAt_const.mul
rw [← Function.comp_def]
apply analyticAt_cexp.restrictScalars.comp ((ofRealCLM.analyticAt z).mul (by fun_prop))
/-- The circleMap is continuously differentiable. -/
theorem contDiff_circleMap (c : ℂ) (R : ℝ) {n : WithTop ℕ∞} :
ContDiff ℝ n (circleMap c R) :=
(analyticOnNhd_circleMap c R).contDiff
@[continuity, fun_prop]
theorem continuous_circleMap (c : ℂ) (R : ℝ) : Continuous (circleMap c R) :=
(differentiable_circleMap c R).continuous
@[fun_prop, measurability]
theorem measurable_circleMap (c : ℂ) (R : ℝ) : Measurable (circleMap c R) :=
(continuous_circleMap c R).measurable
@[simp]
theorem deriv_circleMap (c : ℂ) (R : ℝ) (θ : ℝ) : deriv (circleMap c R) θ = circleMap 0 R θ * I :=
(hasDerivAt_circleMap _ _ _).deriv
theorem deriv_circleMap_eq_zero_iff {c : ℂ} {R : ℝ} {θ : ℝ} :
deriv (circleMap c R) θ = 0 ↔ R = 0 := by simp [I_ne_zero]
theorem deriv_circleMap_ne_zero {c : ℂ} {R : ℝ} {θ : ℝ} (hR : R ≠ 0) :
deriv (circleMap c R) θ ≠ 0 :=
mt deriv_circleMap_eq_zero_iff.1 hR
theorem lipschitzWith_circleMap (c : ℂ) (R : ℝ) : LipschitzWith (Real.nnabs R) (circleMap c R) :=
lipschitzWith_of_nnnorm_deriv_le (differentiable_circleMap _ _) fun θ =>
NNReal.coe_le_coe.1 <| by simp
theorem continuous_circleMap_inv {R : ℝ} {z w : ℂ} (hw : w ∈ ball z R) :
Continuous fun θ => (circleMap z R θ - w)⁻¹ := by
have : ∀ θ, circleMap z R θ - w ≠ 0 := by
simp_rw [sub_ne_zero]
exact fun θ => circleMap_ne_mem_ball hw θ
-- Porting note: was `continuity`
exact Continuous.inv₀ (by fun_prop) this
theorem circleMap_preimage_codiscrete {c : ℂ} {R : ℝ} (hR : R ≠ 0) :
map (circleMap c R) (codiscrete ℝ) ≤ codiscreteWithin (Metric.sphere c |R|) := by
intro s hs
apply (analyticOnNhd_circleMap c R).preimage_mem_codiscreteWithin
· intro x hx
by_contra hCon
obtain ⟨a, ha⟩ := eventuallyConst_iff_exists_eventuallyEq.1 hCon
have := ha.deriv.eq_of_nhds
simp [hR] at this
· rwa [Set.image_univ, range_circleMap]
/-!
### Integrability of a function on a circle
-/
/-- We say that a function `f : ℂ → E` is integrable on the circle with center `c` and radius `R` if
the function `f ∘ circleMap c R` is integrable on `[0, 2π]`.
Note that the actual function used in the definition of `circleIntegral` is
`(deriv (circleMap c R) θ) • f (circleMap c R θ)`. Integrability of this function is equivalent
to integrability of `f ∘ circleMap c R` whenever `R ≠ 0`. -/
def CircleIntegrable (f : ℂ → E) (c : ℂ) (R : ℝ) : Prop :=
IntervalIntegrable (fun θ : ℝ => f (circleMap c R θ)) volume 0 (2 * π)
@[simp]
theorem circleIntegrable_const (a : E) (c : ℂ) (R : ℝ) : CircleIntegrable (fun _ => a) c R :=
intervalIntegrable_const
namespace CircleIntegrable
variable {f g : ℂ → E} {c : ℂ} {R : ℝ}
nonrec theorem add (hf : CircleIntegrable f c R) (hg : CircleIntegrable g c R) :
CircleIntegrable (f + g) c R :=
hf.add hg
nonrec theorem neg (hf : CircleIntegrable f c R) : CircleIntegrable (-f) c R :=
hf.neg
/-- The function we actually integrate over `[0, 2π]` in the definition of `circleIntegral` is
integrable. -/
theorem out [NormedSpace ℂ E] (hf : CircleIntegrable f c R) :
IntervalIntegrable (fun θ : ℝ => deriv (circleMap c R) θ • f (circleMap c R θ)) volume 0
(2 * π) := by
simp only [CircleIntegrable, deriv_circleMap, intervalIntegrable_iff] at *
refine (hf.norm.const_mul |R|).mono' ?_ ?_
· exact ((continuous_circleMap _ _).aestronglyMeasurable.mul_const I).smul hf.aestronglyMeasurable
· simp [norm_smul]
end CircleIntegrable
@[simp]
| Mathlib/MeasureTheory/Integral/CircleIntegral.lean | 198 | 199 | theorem circleIntegrable_zero_radius {f : ℂ → E} {c : ℂ} : CircleIntegrable f c 0 := by | simp [CircleIntegrable] |
/-
Copyright (c) 2019 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Topology.Constructions
/-!
# Neighborhoods and continuity relative to a subset
This file develops API on the relative versions
* `nhdsWithin` of `nhds`
* `ContinuousOn` of `Continuous`
* `ContinuousWithinAt` of `ContinuousAt`
related to continuity, which are defined in previous definition files.
Their basic properties studied in this file include the relationships between
these restricted notions and the corresponding notions for the subtype
equipped with the subspace topology.
## Notation
* `𝓝 x`: the filter of neighborhoods of a point `x`;
* `𝓟 s`: the principal filter of a set `s`;
* `𝓝[s] x`: the filter `nhdsWithin x s` of neighborhoods of a point `x` within a set `s`.
-/
open Set Filter Function Topology Filter
variable {α β γ δ : Type*}
variable [TopologicalSpace α]
/-!
## Properties of the neighborhood-within filter
-/
@[simp]
theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a :=
bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl
@[simp]
theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x :=
Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x }
theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x :=
eventually_inf_principal
theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} :
(∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s :=
frequently_inf_principal.trans <| by simp only [and_comm]
theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} :
z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by
simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff]
@[simp]
theorem eventually_eventually_nhdsWithin {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by
refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩
simp only [eventually_nhdsWithin_iff] at h ⊢
exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs
@[simp]
theorem eventually_mem_nhdsWithin_iff {x : α} {s t : Set α} :
(∀ᶠ x' in 𝓝[s] x, t ∈ 𝓝[s] x') ↔ t ∈ 𝓝[s] x :=
eventually_eventually_nhdsWithin
theorem nhdsWithin_eq (a : α) (s : Set α) :
𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) :=
((nhds_basis_opens a).inf_principal s).eq_biInf
@[simp] lemma nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by
rw [nhdsWithin, principal_univ, inf_top_eq]
theorem nhdsWithin_hasBasis {ι : Sort*} {p : ι → Prop} {s : ι → Set α} {a : α}
(h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t :=
h.inf_principal t
theorem nhdsWithin_basis_open (a : α) (t : Set α) :
(𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t :=
nhdsWithin_hasBasis (nhds_basis_opens a) t
theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} :
t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by
simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff
theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} :
t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t :=
(nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff
theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) :
s \ t ∈ 𝓝[tᶜ] x :=
diff_mem_inf_principal_compl hs t
theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) :
s \ t' ∈ 𝓝[t \ t'] x := by
rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc]
exact inter_mem_inf hs (mem_principal_self _)
theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) :
t ∈ 𝓝 a := by
rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩
exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw
theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t :=
eventually_inf_principal
theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by
simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and]
theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t :=
set_eventuallyEq_iff_inf_principal.symm
theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x :=
set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal
theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t)
(hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) :
π ⁻¹' s ∈ 𝓝[t] a := by
lift a to t using h
replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs
rwa [← map_nhds_subtype_val, mem_map]
theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a :=
mem_inf_of_left h
theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a :=
mem_inf_of_right (mem_principal_self s)
theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s :=
self_mem_nhdsWithin
theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a :=
inter_mem self_mem_nhdsWithin (mem_inf_of_left h)
theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a :=
le_inf (pure_le_nhds a) (le_principal_iff.2 ha)
theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t :=
pure_le_nhdsWithin ha ht
theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α}
(h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x :=
mem_of_mem_nhdsWithin hx h
theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) :
Tendsto (fun _ : β => a) l (𝓝[s] a) :=
tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha
theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) :
𝓝[s] a = 𝓝[s ∩ t] a :=
le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h)))
(inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left))
theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict'' s <| mem_inf_of_left h
theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) :
𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀)
theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a :=
nhdsWithin_le_iff.mpr h
theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by
rw [← nhdsWithin_univ]
apply nhdsWithin_le_of_mem
exact univ_mem
theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) :
𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂]
theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s)
(h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by
rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂]
@[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a :=
inf_eq_left.trans le_principal_iff
theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a :=
nhdsWithin_eq_nhds.2 <| h.mem_nhds ha
theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t)
(ht : IsOpen t)
(hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) :
π ⁻¹' s ∈ 𝓝 a := by
rw [← ht.nhdsWithin_eq h]
exact preimage_nhdsWithin_coinduced' h hs
@[simp]
theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq]
theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by
delta nhdsWithin
rw [← inf_sup_left, sup_principal]
theorem nhds_eq_nhdsWithin_sup_nhdsWithin (b : α) {I₁ I₂ : Set α} (hI : Set.univ = I₁ ∪ I₂) :
nhds b = nhdsWithin b I₁ ⊔ nhdsWithin b I₂ := by
rw [← nhdsWithin_univ b, hI, nhdsWithin_union]
/-- If `L` and `R` are neighborhoods of `b` within sets whose union is `Set.univ`, then
`L ∪ R` is a neighborhood of `b`. -/
theorem union_mem_nhds_of_mem_nhdsWithin {b : α}
{I₁ I₂ : Set α} (h : Set.univ = I₁ ∪ I₂)
{L : Set α} (hL : L ∈ nhdsWithin b I₁)
{R : Set α} (hR : R ∈ nhdsWithin b I₂) : L ∪ R ∈ nhds b := by
rw [← nhdsWithin_univ b, h, nhdsWithin_union]
exact ⟨mem_of_superset hL (by simp), mem_of_superset hR (by simp)⟩
/-- Writing a punctured neighborhood filter as a sup of left and right filters. -/
lemma punctured_nhds_eq_nhdsWithin_sup_nhdsWithin [LinearOrder α] {x : α} :
𝓝[≠] x = 𝓝[<] x ⊔ 𝓝[>] x := by
rw [← Iio_union_Ioi, nhdsWithin_union]
/-- Obtain a "predictably-sided" neighborhood of `b` from two one-sided neighborhoods. -/
theorem nhds_of_Ici_Iic [LinearOrder α] {b : α}
{L : Set α} (hL : L ∈ 𝓝[≤] b)
{R : Set α} (hR : R ∈ 𝓝[≥] b) : L ∩ Iic b ∪ R ∩ Ici b ∈ 𝓝 b :=
union_mem_nhds_of_mem_nhdsWithin Iic_union_Ici.symm
(inter_mem hL self_mem_nhdsWithin) (inter_mem hR self_mem_nhdsWithin)
theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) :
𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := by
induction I, hI using Set.Finite.induction_on with
| empty => simp
| insert _ _ hT => simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert]
theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) :
𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by
rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS]
theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) :
𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by
rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range]
theorem nhdsWithin_inter (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓝[t] a := by
delta nhdsWithin
rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem]
theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by
delta nhdsWithin
rw [← inf_principal, inf_assoc]
theorem nhdsWithin_inter_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by
rw [nhdsWithin_inter, inf_eq_right]
exact nhdsWithin_le_of_mem h
theorem nhdsWithin_inter_of_mem' {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by
rw [inter_comm, nhdsWithin_inter_of_mem h]
@[simp]
theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by
rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)]
@[simp]
theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by
rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton]
theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by
simp
theorem insert_mem_nhdsWithin_insert {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) :
insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h]
theorem insert_mem_nhds_iff {a : α} {s : Set α} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[≠] a := by
simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left,
insert_def]
@[simp]
theorem nhdsNE_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by
rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ]
@[deprecated (since := "2025-03-02")]
alias nhdsWithin_compl_singleton_sup_pure := nhdsNE_sup_pure
@[simp]
theorem pure_sup_nhdsNE (a : α) : pure a ⊔ 𝓝[≠] a = 𝓝 a := by rw [← sup_comm, nhdsNE_sup_pure]
theorem nhdsWithin_prod [TopologicalSpace β]
{s u : Set α} {t v : Set β} {a : α} {b : β} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) :
u ×ˢ v ∈ 𝓝[s ×ˢ t] (a, b) := by
rw [nhdsWithin_prod_eq]
exact prod_mem_prod hu hv
lemma Filter.EventuallyEq.mem_interior {x : α} {s t : Set α} (hst : s =ᶠ[𝓝 x] t)
(h : x ∈ interior s) : x ∈ interior t := by
rw [← nhdsWithin_eq_iff_eventuallyEq] at hst
simpa [mem_interior_iff_mem_nhds, ← nhdsWithin_eq_nhds, hst] using h
lemma Filter.EventuallyEq.mem_interior_iff {x : α} {s t : Set α} (hst : s =ᶠ[𝓝 x] t) :
x ∈ interior s ↔ x ∈ interior t :=
⟨fun h ↦ hst.mem_interior h, fun h ↦ hst.symm.mem_interior h⟩
@[deprecated (since := "2024-11-11")]
alias EventuallyEq.mem_interior_iff := Filter.EventuallyEq.mem_interior_iff
section Pi
variable {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)]
theorem nhdsWithin_pi_eq' {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi I s] x = ⨅ i, comap (fun x => x i) (𝓝 (x i) ⊓ ⨅ (_ : i ∈ I), 𝓟 (s i)) := by
simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ←
iInf_principal_finite hI, ← iInf_inf_eq]
theorem nhdsWithin_pi_eq {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi I s] x =
(⨅ i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) ⊓
⨅ (i) (_ : i ∉ I), comap (fun x => x i) (𝓝 (x i)) := by
simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf,
comap_principal, eval]
rw [iInf_split _ fun i => i ∈ I, inf_right_comm]
simp only [iInf_inf_eq]
theorem nhdsWithin_pi_univ_eq [Finite ι] (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi univ s] x = ⨅ i, comap (fun x => x i) (𝓝[s i] x i) := by
simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x
theorem nhdsWithin_pi_eq_bot {I : Set ι} {s : ∀ i, Set (π i)} {x : ∀ i, π i} :
𝓝[pi I s] x = ⊥ ↔ ∃ i ∈ I, 𝓝[s i] x i = ⊥ := by
simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot]
theorem nhdsWithin_pi_neBot {I : Set ι} {s : ∀ i, Set (π i)} {x : ∀ i, π i} :
(𝓝[pi I s] x).NeBot ↔ ∀ i ∈ I, (𝓝[s i] x i).NeBot := by
simp [neBot_iff, nhdsWithin_pi_eq_bot]
instance instNeBotNhdsWithinUnivPi {s : ∀ i, Set (π i)} {x : ∀ i, π i}
[∀ i, (𝓝[s i] x i).NeBot] : (𝓝[pi univ s] x).NeBot := by
simpa [nhdsWithin_pi_neBot]
instance Pi.instNeBotNhdsWithinIio [Nonempty ι] [∀ i, Preorder (π i)] {x : ∀ i, π i}
[∀ i, (𝓝[<] x i).NeBot] : (𝓝[<] x).NeBot :=
have : (𝓝[pi univ fun i ↦ Iio (x i)] x).NeBot := inferInstance
this.mono <| nhdsWithin_mono _ fun _y hy ↦ lt_of_strongLT fun i ↦ hy i trivial
instance Pi.instNeBotNhdsWithinIoi [Nonempty ι] [∀ i, Preorder (π i)] {x : ∀ i, π i}
[∀ i, (𝓝[>] x i).NeBot] : (𝓝[>] x).NeBot :=
Pi.instNeBotNhdsWithinIio (π := fun i ↦ (π i)ᵒᵈ) (x := fun i ↦ OrderDual.toDual (x i))
end Pi
theorem Filter.Tendsto.piecewise_nhdsWithin {f g : α → β} {t : Set α} [∀ x, Decidable (x ∈ t)]
{a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ t] a) l)
(h₁ : Tendsto g (𝓝[s ∩ tᶜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by
apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter']
theorem Filter.Tendsto.if_nhdsWithin {f g : α → β} {p : α → Prop} [DecidablePred p] {a : α}
{s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ { x | p x }] a) l)
(h₁ : Tendsto g (𝓝[s ∩ { x | ¬p x }] a) l) :
Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l :=
h₀.piecewise_nhdsWithin h₁
theorem map_nhdsWithin (f : α → β) (a : α) (s : Set α) :
map f (𝓝[s] a) = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (f '' (t ∩ s)) :=
((nhdsWithin_basis_open a s).map f).eq_biInf
theorem tendsto_nhdsWithin_mono_left {f : α → β} {a : α} {s t : Set α} {l : Filter β} (hst : s ⊆ t)
(h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l :=
h.mono_left <| nhdsWithin_mono a hst
theorem tendsto_nhdsWithin_mono_right {f : β → α} {l : Filter β} {a : α} {s t : Set α} (hst : s ⊆ t)
(h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) :=
h.mono_right (nhdsWithin_mono a hst)
theorem tendsto_nhdsWithin_of_tendsto_nhds {f : α → β} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l :=
h.mono_left inf_le_left
theorem eventually_mem_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f l (𝓝[s] a)) : ∀ᶠ i in l, f i ∈ s := by
simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff,
eventually_and] at h
exact (h univ ⟨mem_univ a, isOpen_univ⟩).2
theorem tendsto_nhds_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) :=
h.mono_right nhdsWithin_le_nhds
theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) :=
mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx
theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set α} (hs : IsClosed s) {x : α}
(hx : NeBot <| 𝓝[s] x) : x ∈ s :=
hs.closure_eq ▸ mem_closure_iff_nhdsWithin_neBot.2 hx
theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) :
NeBot (𝓝[range f] x) :=
mem_closure_iff_clusterPt.1 (h x)
theorem mem_closure_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι}
{s : ∀ i, Set (α i)} {x : ∀ i, α i} : x ∈ closure (pi I s) ↔ ∀ i ∈ I, x i ∈ closure (s i) := by
simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot]
theorem closure_pi_set {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] (I : Set ι)
(s : ∀ i, Set (α i)) : closure (pi I s) = pi I fun i => closure (s i) :=
Set.ext fun _ => mem_closure_pi
theorem dense_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {s : ∀ i, Set (α i)}
(I : Set ι) (hs : ∀ i ∈ I, Dense (s i)) : Dense (pi I s) := by
simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq,
pi_univ]
theorem DenseRange.piMap {ι : Type*} {X Y : ι → Type*} [∀ i, TopologicalSpace (Y i)]
{f : (i : ι) → (X i) → (Y i)} (hf : ∀ i, DenseRange (f i)):
DenseRange (Pi.map f) := by
rw [DenseRange, Set.range_piMap]
exact dense_pi Set.univ (fun i _ => hf i)
theorem eventuallyEq_nhdsWithin_iff {f g : α → β} {s : Set α} {a : α} :
f =ᶠ[𝓝[s] a] g ↔ ∀ᶠ x in 𝓝 a, x ∈ s → f x = g x :=
mem_inf_principal
/-- Two functions agree on a neighborhood of `x` if they agree at `x` and in a punctured
neighborhood. -/
theorem eventuallyEq_nhds_of_eventuallyEq_nhdsNE {f g : α → β} {a : α} (h₁ : f =ᶠ[𝓝[≠] a] g)
(h₂ : f a = g a) :
f =ᶠ[𝓝 a] g := by
filter_upwards [eventually_nhdsWithin_iff.1 h₁]
intro x hx
by_cases h₂x : x = a
· simp [h₂x, h₂]
· tauto
theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) :
f =ᶠ[𝓝[s] a] g :=
mem_inf_of_right h
theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) :
f =ᶠ[𝓝[s] a] g :=
eventuallyEq_nhdsWithin_of_eqOn h
theorem tendsto_nhdsWithin_congr {f g : α → β} {s : Set α} {a : α} {l : Filter β}
(hfg : ∀ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l :=
(tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf
theorem eventually_nhdsWithin_of_forall {s : Set α} {a : α} {p : α → Prop} (h : ∀ x ∈ s, p x) :
∀ᶠ x in 𝓝[s] a, p x :=
mem_inf_of_right h
theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : α} {l : Filter β} {s : Set α}
(f : β → α) (h1 : Tendsto f l (𝓝 a)) (h2 : ∀ᶠ x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) :=
tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩
theorem tendsto_nhdsWithin_iff {a : α} {l : Filter β} {s : Set α} {f : β → α} :
Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ ∀ᶠ n in l, f n ∈ s :=
⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h =>
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩
@[simp]
theorem tendsto_nhdsWithin_range {a : α} {l : Filter β} {f : β → α} :
Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) :=
⟨fun h => h.mono_right inf_le_left, fun h =>
tendsto_inf.2 ⟨h, tendsto_principal.2 <| Eventually.of_forall mem_range_self⟩⟩
theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set α} {f g : α → β} {a : α} (h : f =ᶠ[𝓝[s] a] g)
(hmem : a ∈ s) : f a = g a :=
h.self_of_nhdsWithin hmem
theorem eventually_nhdsWithin_of_eventually_nhds {s : Set α}
{a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x :=
mem_nhdsWithin_of_mem_nhds h
lemma Set.MapsTo.preimage_mem_nhdsWithin {f : α → β} {s : Set α} {t : Set β} {x : α}
(hst : MapsTo f s t) : f ⁻¹' t ∈ 𝓝[s] x :=
Filter.mem_of_superset self_mem_nhdsWithin hst
/-!
### `nhdsWithin` and subtypes
-/
theorem mem_nhdsWithin_subtype {s : Set α} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} :
t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s → α) (𝓝[(↑) '' u] a) := by
rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin]
theorem nhdsWithin_subtype (s : Set α) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) :
𝓝[t] a = comap ((↑) : s → α) (𝓝[(↑) '' t] a) :=
Filter.ext fun _ => mem_nhdsWithin_subtype
theorem nhdsWithin_eq_map_subtype_coe {s : Set α} {a : α} (h : a ∈ s) :
𝓝[s] a = map ((↑) : s → α) (𝓝 ⟨a, h⟩) :=
(map_nhds_subtype_val ⟨a, h⟩).symm
theorem mem_nhds_subtype_iff_nhdsWithin {s : Set α} {a : s} {t : Set s} :
t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : α) := by
rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective]
theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by
rw [← map_nhds_subtype_val, mem_map]
theorem eventually_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) :
(∀ᶠ x : s in 𝓝 a, P x) ↔ ∀ᶠ x in 𝓝[s] a, P x :=
preimage_coe_mem_nhds_subtype
theorem frequently_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) :
(∃ᶠ x : s in 𝓝 a, P x) ↔ ∃ᶠ x in 𝓝[s] a, P x :=
eventually_nhds_subtype_iff s a (¬ P ·) |>.not
theorem tendsto_nhdsWithin_iff_subtype {s : Set α} {a : α} (h : a ∈ s) (f : α → β) (l : Filter β) :
Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by
rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl
/-!
## Local continuity properties of functions
-/
variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ]
{f g : α → β} {s s' s₁ t : Set α} {x : α}
/-!
### `ContinuousWithinAt`
-/
/-- If a function is continuous within `s` at `x`, then it tends to `f x` within `s` by definition.
We register this fact for use with the dot notation, especially to use `Filter.Tendsto.comp` as
`ContinuousWithinAt.comp` will have a different meaning. -/
theorem ContinuousWithinAt.tendsto (h : ContinuousWithinAt f s x) :
Tendsto f (𝓝[s] x) (𝓝 (f x)) :=
h
theorem continuousWithinAt_univ (f : α → β) (x : α) :
ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by
rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ]
theorem continuous_iff_continuousOn_univ {f : α → β} : Continuous f ↔ ContinuousOn f univ := by
simp [continuous_iff_continuousAt, ContinuousOn, ContinuousAt, ContinuousWithinAt,
nhdsWithin_univ]
theorem continuousWithinAt_iff_continuousAt_restrict (f : α → β) {x : α} {s : Set α} (h : x ∈ s) :
ContinuousWithinAt f s x ↔ ContinuousAt (s.restrict f) ⟨x, h⟩ :=
tendsto_nhdsWithin_iff_subtype h f _
theorem ContinuousWithinAt.tendsto_nhdsWithin {t : Set β}
(h : ContinuousWithinAt f s x) (ht : MapsTo f s t) :
Tendsto f (𝓝[s] x) (𝓝[t] f x) :=
tendsto_inf.2 ⟨h, tendsto_principal.2 <| mem_inf_of_right <| mem_principal.2 <| ht⟩
theorem ContinuousWithinAt.tendsto_nhdsWithin_image (h : ContinuousWithinAt f s x) :
Tendsto f (𝓝[s] x) (𝓝[f '' s] f x) :=
h.tendsto_nhdsWithin (mapsTo_image _ _)
theorem nhdsWithin_le_comap (ctsf : ContinuousWithinAt f s x) :
𝓝[s] x ≤ comap f (𝓝[f '' s] f x) :=
ctsf.tendsto_nhdsWithin_image.le_comap
theorem ContinuousWithinAt.preimage_mem_nhdsWithin {t : Set β}
(h : ContinuousWithinAt f s x) (ht : t ∈ 𝓝 (f x)) : f ⁻¹' t ∈ 𝓝[s] x :=
h ht
theorem ContinuousWithinAt.preimage_mem_nhdsWithin' {t : Set β}
(h : ContinuousWithinAt f s x) (ht : t ∈ 𝓝[f '' s] f x) : f ⁻¹' t ∈ 𝓝[s] x :=
h.tendsto_nhdsWithin (mapsTo_image _ _) ht
theorem ContinuousWithinAt.preimage_mem_nhdsWithin'' {y : β} {s t : Set β}
(h : ContinuousWithinAt f (f ⁻¹' s) x) (ht : t ∈ 𝓝[s] y) (hxy : y = f x) :
f ⁻¹' t ∈ 𝓝[f ⁻¹' s] x := by
rw [hxy] at ht
exact h.preimage_mem_nhdsWithin' (nhdsWithin_mono _ (image_preimage_subset f s) ht)
theorem continuousWithinAt_of_not_mem_closure (hx : x ∉ closure s) :
ContinuousWithinAt f s x := by
rw [mem_closure_iff_nhdsWithin_neBot, not_neBot] at hx
rw [ContinuousWithinAt, hx]
exact tendsto_bot
/-!
### `ContinuousOn`
-/
theorem continuousOn_iff :
ContinuousOn f s ↔
∀ x ∈ s, ∀ t : Set β, IsOpen t → f x ∈ t → ∃ u, IsOpen u ∧ x ∈ u ∧ u ∩ s ⊆ f ⁻¹' t := by
simp only [ContinuousOn, ContinuousWithinAt, tendsto_nhds, mem_nhdsWithin]
theorem ContinuousOn.continuousWithinAt (hf : ContinuousOn f s) (hx : x ∈ s) :
ContinuousWithinAt f s x :=
hf x hx
theorem continuousOn_iff_continuous_restrict :
ContinuousOn f s ↔ Continuous (s.restrict f) := by
rw [ContinuousOn, continuous_iff_continuousAt]; constructor
· rintro h ⟨x, xs⟩
exact (continuousWithinAt_iff_continuousAt_restrict f xs).mp (h x xs)
intro h x xs
exact (continuousWithinAt_iff_continuousAt_restrict f xs).mpr (h ⟨x, xs⟩)
alias ⟨ContinuousOn.restrict, _⟩ := continuousOn_iff_continuous_restrict
theorem ContinuousOn.restrict_mapsTo {t : Set β} (hf : ContinuousOn f s) (ht : MapsTo f s t) :
Continuous (ht.restrict f s t) :=
hf.restrict.codRestrict _
theorem continuousOn_iff' :
ContinuousOn f s ↔ ∀ t : Set β, IsOpen t → ∃ u, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by
have : ∀ t, IsOpen (s.restrict f ⁻¹' t) ↔ ∃ u : Set α, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by
intro t
rw [isOpen_induced_iff, Set.restrict_eq, Set.preimage_comp]
simp only [Subtype.preimage_coe_eq_preimage_coe_iff]
constructor <;>
· rintro ⟨u, ou, useq⟩
exact ⟨u, ou, by simpa only [Set.inter_comm, eq_comm] using useq⟩
rw [continuousOn_iff_continuous_restrict, continuous_def]; simp only [this]
/-- If a function is continuous on a set for some topologies, then it is
continuous on the same set with respect to any finer topology on the source space. -/
theorem ContinuousOn.mono_dom {α β : Type*} {t₁ t₂ : TopologicalSpace α} {t₃ : TopologicalSpace β}
(h₁ : t₂ ≤ t₁) {s : Set α} {f : α → β} (h₂ : @ContinuousOn α β t₁ t₃ f s) :
@ContinuousOn α β t₂ t₃ f s := fun x hx _u hu =>
map_mono (inf_le_inf_right _ <| nhds_mono h₁) (h₂ x hx hu)
/-- If a function is continuous on a set for some topologies, then it is
continuous on the same set with respect to any coarser topology on the target space. -/
theorem ContinuousOn.mono_rng {α β : Type*} {t₁ : TopologicalSpace α} {t₂ t₃ : TopologicalSpace β}
(h₁ : t₂ ≤ t₃) {s : Set α} {f : α → β} (h₂ : @ContinuousOn α β t₁ t₂ f s) :
@ContinuousOn α β t₁ t₃ f s := fun x hx _u hu =>
h₂ x hx <| nhds_mono h₁ hu
theorem continuousOn_iff_isClosed :
ContinuousOn f s ↔ ∀ t : Set β, IsClosed t → ∃ u, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by
have : ∀ t, IsClosed (s.restrict f ⁻¹' t) ↔ ∃ u : Set α, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by
intro t
rw [isClosed_induced_iff, Set.restrict_eq, Set.preimage_comp]
simp only [Subtype.preimage_coe_eq_preimage_coe_iff, eq_comm, Set.inter_comm s]
rw [continuousOn_iff_continuous_restrict, continuous_iff_isClosed]; simp only [this]
theorem continuous_of_cover_nhds {ι : Sort*} {s : ι → Set α}
(hs : ∀ x : α, ∃ i, s i ∈ 𝓝 x) (hf : ∀ i, ContinuousOn f (s i)) :
Continuous f :=
continuous_iff_continuousAt.mpr fun x ↦ let ⟨i, hi⟩ := hs x; by
rw [ContinuousAt, ← nhdsWithin_eq_nhds.2 hi]
exact hf _ _ (mem_of_mem_nhds hi)
@[simp] theorem continuousOn_empty (f : α → β) : ContinuousOn f ∅ := fun _ => False.elim
@[simp]
theorem continuousOn_singleton (f : α → β) (a : α) : ContinuousOn f {a} :=
forall_eq.2 <| by
simpa only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_left] using fun s =>
mem_of_mem_nhds
theorem Set.Subsingleton.continuousOn {s : Set α} (hs : s.Subsingleton) (f : α → β) :
ContinuousOn f s :=
hs.induction_on (continuousOn_empty f) (continuousOn_singleton f)
theorem continuousOn_open_iff (hs : IsOpen s) :
ContinuousOn f s ↔ ∀ t, IsOpen t → IsOpen (s ∩ f ⁻¹' t) := by
rw [continuousOn_iff']
constructor
· intro h t ht
rcases h t ht with ⟨u, u_open, hu⟩
rw [inter_comm, hu]
apply IsOpen.inter u_open hs
· intro h t ht
refine ⟨s ∩ f ⁻¹' t, h t ht, ?_⟩
rw [@inter_comm _ s (f ⁻¹' t), inter_assoc, inter_self]
theorem ContinuousOn.isOpen_inter_preimage {t : Set β}
(hf : ContinuousOn f s) (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ∩ f ⁻¹' t) :=
(continuousOn_open_iff hs).1 hf t ht
theorem ContinuousOn.isOpen_preimage {t : Set β} (h : ContinuousOn f s)
(hs : IsOpen s) (hp : f ⁻¹' t ⊆ s) (ht : IsOpen t) : IsOpen (f ⁻¹' t) := by
convert (continuousOn_open_iff hs).mp h t ht
rw [inter_comm, inter_eq_self_of_subset_left hp]
theorem ContinuousOn.preimage_isClosed_of_isClosed {t : Set β}
(hf : ContinuousOn f s) (hs : IsClosed s) (ht : IsClosed t) : IsClosed (s ∩ f ⁻¹' t) := by
rcases continuousOn_iff_isClosed.1 hf t ht with ⟨u, hu⟩
rw [inter_comm, hu.2]
apply IsClosed.inter hu.1 hs
theorem ContinuousOn.preimage_interior_subset_interior_preimage {t : Set β}
(hf : ContinuousOn f s) (hs : IsOpen s) : s ∩ f ⁻¹' interior t ⊆ s ∩ interior (f ⁻¹' t) :=
calc
s ∩ f ⁻¹' interior t ⊆ interior (s ∩ f ⁻¹' t) :=
interior_maximal (inter_subset_inter (Subset.refl _) (preimage_mono interior_subset))
(hf.isOpen_inter_preimage hs isOpen_interior)
_ = s ∩ interior (f ⁻¹' t) := by rw [interior_inter, hs.interior_eq]
theorem continuousOn_of_locally_continuousOn
(h : ∀ x ∈ s, ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn f (s ∩ t)) : ContinuousOn f s := by
intro x xs
rcases h x xs with ⟨t, open_t, xt, ct⟩
have := ct x ⟨xs, xt⟩
rwa [ContinuousWithinAt, ← nhdsWithin_restrict _ xt open_t] at this
theorem continuousOn_to_generateFrom_iff {β : Type*} {T : Set (Set β)} {f : α → β} :
@ContinuousOn α β _ (.generateFrom T) f s ↔ ∀ x ∈ s, ∀ t ∈ T, f x ∈ t → f ⁻¹' t ∈ 𝓝[s] x :=
forall₂_congr fun x _ => by
delta ContinuousWithinAt
simp only [TopologicalSpace.nhds_generateFrom, tendsto_iInf, tendsto_principal, mem_setOf_eq,
and_imp]
exact forall_congr' fun t => forall_swap
theorem continuousOn_isOpen_of_generateFrom {β : Type*} {s : Set α} {T : Set (Set β)} {f : α → β}
(h : ∀ t ∈ T, IsOpen (s ∩ f ⁻¹' t)) :
@ContinuousOn α β _ (.generateFrom T) f s :=
continuousOn_to_generateFrom_iff.2 fun _x hx t ht hxt => mem_nhdsWithin.2
⟨_, h t ht, ⟨hx, hxt⟩, fun _y hy => hy.1.2⟩
/-!
### Congruence and monotonicity properties with respect to sets
-/
theorem ContinuousWithinAt.mono (h : ContinuousWithinAt f t x)
(hs : s ⊆ t) : ContinuousWithinAt f s x :=
h.mono_left (nhdsWithin_mono x hs)
theorem ContinuousWithinAt.mono_of_mem_nhdsWithin (h : ContinuousWithinAt f t x) (hs : t ∈ 𝓝[s] x) :
ContinuousWithinAt f s x :=
h.mono_left (nhdsWithin_le_of_mem hs)
/-- If two sets coincide around `x`, then being continuous within one or the other at `x` is
equivalent. See also `continuousWithinAt_congr_set'` which requires that the sets coincide
locally away from a point `y`, in a T1 space. -/
theorem continuousWithinAt_congr_set (h : s =ᶠ[𝓝 x] t) :
ContinuousWithinAt f s x ↔ ContinuousWithinAt f t x := by
simp only [ContinuousWithinAt, nhdsWithin_eq_iff_eventuallyEq.mpr h]
theorem ContinuousWithinAt.congr_set (hf : ContinuousWithinAt f s x) (h : s =ᶠ[𝓝 x] t) :
ContinuousWithinAt f t x :=
(continuousWithinAt_congr_set h).1 hf
theorem continuousWithinAt_inter' (h : t ∈ 𝓝[s] x) :
ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by
simp [ContinuousWithinAt, nhdsWithin_restrict'' s h]
theorem continuousWithinAt_inter (h : t ∈ 𝓝 x) :
ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by
simp [ContinuousWithinAt, nhdsWithin_restrict' s h]
theorem continuousWithinAt_union :
ContinuousWithinAt f (s ∪ t) x ↔ ContinuousWithinAt f s x ∧ ContinuousWithinAt f t x := by
simp only [ContinuousWithinAt, nhdsWithin_union, tendsto_sup]
theorem ContinuousWithinAt.union (hs : ContinuousWithinAt f s x) (ht : ContinuousWithinAt f t x) :
ContinuousWithinAt f (s ∪ t) x :=
continuousWithinAt_union.2 ⟨hs, ht⟩
@[simp]
theorem continuousWithinAt_singleton : ContinuousWithinAt f {x} x := by
simp only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_nhds]
@[simp]
theorem continuousWithinAt_insert_self :
ContinuousWithinAt f (insert x s) x ↔ ContinuousWithinAt f s x := by
simp only [← singleton_union, continuousWithinAt_union, continuousWithinAt_singleton, true_and]
protected alias ⟨_, ContinuousWithinAt.insert⟩ := continuousWithinAt_insert_self
/- `continuousWithinAt_insert` gives the same equivalence but at a point `y` possibly different
from `x`. As this requires the space to be T1, and this property is not available in this file,
this is found in another file although it is part of the basic API for `continuousWithinAt`. -/
theorem ContinuousWithinAt.diff_iff
(ht : ContinuousWithinAt f t x) : ContinuousWithinAt f (s \ t) x ↔ ContinuousWithinAt f s x :=
⟨fun h => (h.union ht).mono <| by simp only [diff_union_self, subset_union_left], fun h =>
h.mono diff_subset⟩
/-- See also `continuousWithinAt_diff_singleton` for the case of `s \ {y}`, but
requiring `T1Space α. -/
@[simp]
theorem continuousWithinAt_diff_self :
ContinuousWithinAt f (s \ {x}) x ↔ ContinuousWithinAt f s x :=
continuousWithinAt_singleton.diff_iff
@[simp]
theorem continuousWithinAt_compl_self :
ContinuousWithinAt f {x}ᶜ x ↔ ContinuousAt f x := by
rw [compl_eq_univ_diff, continuousWithinAt_diff_self, continuousWithinAt_univ]
theorem ContinuousOn.mono (hf : ContinuousOn f s) (h : t ⊆ s) :
ContinuousOn f t := fun x hx => (hf x (h hx)).mono_left (nhdsWithin_mono _ h)
theorem antitone_continuousOn {f : α → β} : Antitone (ContinuousOn f) := fun _s _t hst hf =>
hf.mono hst
/-!
### Relation between `ContinuousAt` and `ContinuousWithinAt`
-/
theorem ContinuousAt.continuousWithinAt (h : ContinuousAt f x) :
ContinuousWithinAt f s x :=
ContinuousWithinAt.mono ((continuousWithinAt_univ f x).2 h) (subset_univ _)
theorem continuousWithinAt_iff_continuousAt (h : s ∈ 𝓝 x) :
ContinuousWithinAt f s x ↔ ContinuousAt f x := by
rw [← univ_inter s, continuousWithinAt_inter h, continuousWithinAt_univ]
theorem ContinuousWithinAt.continuousAt
(h : ContinuousWithinAt f s x) (hs : s ∈ 𝓝 x) : ContinuousAt f x :=
(continuousWithinAt_iff_continuousAt hs).mp h
theorem IsOpen.continuousOn_iff (hs : IsOpen s) :
ContinuousOn f s ↔ ∀ ⦃a⦄, a ∈ s → ContinuousAt f a :=
forall₂_congr fun _ => continuousWithinAt_iff_continuousAt ∘ hs.mem_nhds
theorem ContinuousOn.continuousAt (h : ContinuousOn f s)
(hx : s ∈ 𝓝 x) : ContinuousAt f x :=
(h x (mem_of_mem_nhds hx)).continuousAt hx
theorem continuousOn_of_forall_continuousAt (hcont : ∀ x ∈ s, ContinuousAt f x) :
ContinuousOn f s := fun x hx => (hcont x hx).continuousWithinAt
@[deprecated (since := "2024-10-30")]
alias ContinuousAt.continuousOn := continuousOn_of_forall_continuousAt
@[fun_prop]
theorem Continuous.continuousOn (h : Continuous f) : ContinuousOn f s := by
rw [continuous_iff_continuousOn_univ] at h
exact h.mono (subset_univ _)
theorem Continuous.continuousWithinAt (h : Continuous f) :
ContinuousWithinAt f s x :=
h.continuousAt.continuousWithinAt
/-!
### Congruence properties with respect to functions
-/
theorem ContinuousOn.congr_mono (h : ContinuousOn f s) (h' : EqOn g f s₁) (h₁ : s₁ ⊆ s) :
ContinuousOn g s₁ := by
intro x hx
unfold ContinuousWithinAt
have A := (h x (h₁ hx)).mono h₁
unfold ContinuousWithinAt at A
rw [← h' hx] at A
exact A.congr' h'.eventuallyEq_nhdsWithin.symm
theorem ContinuousOn.congr (h : ContinuousOn f s) (h' : EqOn g f s) :
ContinuousOn g s :=
h.congr_mono h' (Subset.refl _)
theorem continuousOn_congr (h' : EqOn g f s) :
ContinuousOn g s ↔ ContinuousOn f s :=
⟨fun h => ContinuousOn.congr h h'.symm, fun h => h.congr h'⟩
| Mathlib/Topology/ContinuousOn.lean | 846 | 853 | theorem Filter.EventuallyEq.congr_continuousWithinAt (h : f =ᶠ[𝓝[s] x] g) (hx : f x = g x) :
ContinuousWithinAt f s x ↔ ContinuousWithinAt g s x := by | rw [ContinuousWithinAt, hx, tendsto_congr' h, ContinuousWithinAt]
theorem ContinuousWithinAt.congr_of_eventuallyEq
(h : ContinuousWithinAt f s x) (h₁ : g =ᶠ[𝓝[s] x] f) (hx : g x = f x) :
ContinuousWithinAt g s x :=
(h₁.congr_continuousWithinAt hx).2 h |
/-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import Mathlib.Algebra.IsPrimePow
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Algebra.Order.Ring.Int
import Mathlib.Algebra.Ring.CharZero
import Mathlib.Data.Nat.Cast.Order.Ring
import Mathlib.Data.Nat.PrimeFin
import Mathlib.Order.Interval.Finset.Nat
/-!
# Divisor Finsets
This file defines sets of divisors of a natural number. This is particularly useful as background
for defining Dirichlet convolution.
## Main Definitions
Let `n : ℕ`. All of the following definitions are in the `Nat` namespace:
* `divisors n` is the `Finset` of natural numbers that divide `n`.
* `properDivisors n` is the `Finset` of natural numbers that divide `n`, other than `n`.
* `divisorsAntidiagonal n` is the `Finset` of pairs `(x,y)` such that `x * y = n`.
* `Perfect n` is true when `n` is positive and the sum of `properDivisors n` is `n`.
## Conventions
Since `0` has infinitely many divisors, none of the definitions in this file make sense for it.
Therefore we adopt the convention that `Nat.divisors 0`, `Nat.properDivisors 0`,
`Nat.divisorsAntidiagonal 0` and `Int.divisorsAntidiag 0` are all `∅`.
## Tags
divisors, perfect numbers
-/
open Finset
namespace Nat
variable (n : ℕ)
/-- `divisors n` is the `Finset` of divisors of `n`. By convention, we set `divisors 0 = ∅`. -/
def divisors : Finset ℕ := {d ∈ Ico 1 (n + 1) | d ∣ n}
/-- `properDivisors n` is the `Finset` of divisors of `n`, other than `n`.
By convention, we set `properDivisors 0 = ∅`. -/
def properDivisors : Finset ℕ := {d ∈ Ico 1 n | d ∣ n}
/-- Pairs of divisors of a natural number as a finset.
`n.divisorsAntidiagonal` is the finset of pairs `(a, b) : ℕ × ℕ` such that `a * b = n`.
By convention, we set `Nat.divisorsAntidiagonal 0 = ∅`.
O(n). -/
def divisorsAntidiagonal : Finset (ℕ × ℕ) :=
(Icc 1 n).filterMap (fun x ↦ let y := n / x; if x * y = n then some (x, y) else none)
fun x₁ x₂ (x, y) hx₁ hx₂ ↦ by aesop
/-- Pairs of divisors of a natural number, as a list.
`n.divisorsAntidiagonalList` is the list of pairs `(a, b) : ℕ × ℕ` such that `a * b = n`, ordered
by increasing `a`. By convention, we set `Nat.divisorsAntidiagonalList 0 = []`.
-/
def divisorsAntidiagonalList (n : ℕ) : List (ℕ × ℕ) :=
(List.range' 1 n).filterMap
(fun x ↦ let y := n / x; if x * y = n then some (x, y) else none)
variable {n}
@[simp]
theorem filter_dvd_eq_divisors (h : n ≠ 0) : {d ∈ range n.succ | d ∣ n} = n.divisors := by
ext
simp only [divisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt)
@[simp]
theorem filter_dvd_eq_properDivisors (h : n ≠ 0) : {d ∈ range n | d ∣ n} = n.properDivisors := by
ext
simp only [properDivisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt)
theorem properDivisors.not_self_mem : ¬n ∈ properDivisors n := by simp [properDivisors]
@[simp]
theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m := by
rcases eq_or_ne m 0 with (rfl | hm); · simp [properDivisors]
simp only [and_comm, ← filter_dvd_eq_properDivisors hm, mem_filter, mem_range]
theorem insert_self_properDivisors (h : n ≠ 0) : insert n (properDivisors n) = divisors n := by
rw [divisors, properDivisors, Ico_succ_right_eq_insert_Ico (one_le_iff_ne_zero.2 h),
Finset.filter_insert, if_pos (dvd_refl n)]
| Mathlib/NumberTheory/Divisors.lean | 95 | 99 | theorem cons_self_properDivisors (h : n ≠ 0) :
cons n (properDivisors n) properDivisors.not_self_mem = divisors n := by | rw [cons_eq_insert, insert_self_properDivisors h]
@[simp] |
/-
Copyright (c) 2021 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying, Eric Wieser
-/
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.NormNum.Inv
/-!
# Real sign function
This file introduces and contains some results about `Real.sign` which maps negative
real numbers to -1, positive real numbers to 1, and 0 to 0.
## Main definitions
* `Real.sign r` is $\begin{cases} -1 & \text{if } r < 0, \\
~~\, 0 & \text{if } r = 0, \\
~~\, 1 & \text{if } r > 0. \end{cases}$
## Tags
sign function
-/
namespace Real
/-- The sign function that maps negative real numbers to -1, positive numbers to 1, and 0
otherwise. -/
noncomputable def sign (r : ℝ) : ℝ :=
if r < 0 then -1 else if 0 < r then 1 else 0
theorem sign_of_neg {r : ℝ} (hr : r < 0) : sign r = -1 := by rw [sign, if_pos hr]
theorem sign_of_pos {r : ℝ} (hr : 0 < r) : sign r = 1 := by rw [sign, if_pos hr, if_neg hr.not_lt]
@[simp]
theorem sign_zero : sign 0 = 0 := by rw [sign, if_neg (lt_irrefl _), if_neg (lt_irrefl _)]
@[simp]
theorem sign_one : sign 1 = 1 :=
sign_of_pos <| by norm_num
theorem sign_apply_eq (r : ℝ) : sign r = -1 ∨ sign r = 0 ∨ sign r = 1 := by
obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ)
· exact Or.inl <| sign_of_neg hn
· exact Or.inr <| Or.inl <| sign_zero
· exact Or.inr <| Or.inr <| sign_of_pos hp
/-- This lemma is useful for working with `ℝˣ` -/
theorem sign_apply_eq_of_ne_zero (r : ℝ) (h : r ≠ 0) : sign r = -1 ∨ sign r = 1 :=
h.lt_or_lt.imp sign_of_neg sign_of_pos
@[simp]
theorem sign_eq_zero_iff {r : ℝ} : sign r = 0 ↔ r = 0 := by
refine ⟨fun h => ?_, fun h => h.symm ▸ sign_zero⟩
obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ)
· rw [sign_of_neg hn, neg_eq_zero] at h
exact (one_ne_zero h).elim
· rfl
· rw [sign_of_pos hp] at h
exact (one_ne_zero h).elim
theorem sign_intCast (z : ℤ) : sign (z : ℝ) = ↑(Int.sign z) := by
obtain hn | rfl | hp := lt_trichotomy z (0 : ℤ)
· rw [sign_of_neg (Int.cast_lt_zero.mpr hn), Int.sign_eq_neg_one_of_neg hn, Int.cast_neg,
Int.cast_one]
· rw [Int.cast_zero, sign_zero, Int.sign_zero, Int.cast_zero]
· rw [sign_of_pos (Int.cast_pos.mpr hp), Int.sign_eq_one_of_pos hp, Int.cast_one]
theorem sign_neg {r : ℝ} : sign (-r) = -sign r := by
obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ)
· rw [sign_of_neg hn, sign_of_pos (neg_pos.mpr hn), neg_neg]
· rw [sign_zero, neg_zero, sign_zero]
· rw [sign_of_pos hp, sign_of_neg (neg_lt_zero.mpr hp)]
theorem sign_mul_nonneg (r : ℝ) : 0 ≤ sign r * r := by
obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ)
· rw [sign_of_neg hn]
exact mul_nonneg_of_nonpos_of_nonpos (by norm_num) hn.le
· rw [mul_zero]
· rw [sign_of_pos hp, one_mul]
exact hp.le
theorem sign_mul_pos_of_ne_zero (r : ℝ) (hr : r ≠ 0) : 0 < sign r * r := by
refine lt_of_le_of_ne (sign_mul_nonneg r) fun h => hr ?_
have hs0 := (zero_eq_mul.mp h).resolve_right hr
exact sign_eq_zero_iff.mp hs0
@[simp]
theorem inv_sign (r : ℝ) : (sign r)⁻¹ = sign r := by
obtain hn | hz | hp := sign_apply_eq r
· rw [hn]
norm_num
· rw [hz]
exact inv_zero
· rw [hp]
exact inv_one
@[simp]
| Mathlib/Data/Real/Sign.lean | 102 | 105 | theorem sign_inv (r : ℝ) : sign r⁻¹ = sign r := by | obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ)
· rw [sign_of_neg hn, sign_of_neg (inv_lt_zero.mpr hn)]
· rw [sign_zero, inv_zero, sign_zero] |
/-
Copyright (c) 2022 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying, Rémy Degenne
-/
import Mathlib.Probability.Process.Stopping
import Mathlib.Tactic.AdaptationNote
/-!
# Hitting time
Given a stochastic process, the hitting time provides the first time the process "hits" some
subset of the state space. The hitting time is a stopping time in the case that the time index is
discrete and the process is adapted (this is true in a far more general setting however we have
only proved it for the discrete case so far).
## Main definition
* `MeasureTheory.hitting`: the hitting time of a stochastic process
## Main results
* `MeasureTheory.hitting_isStoppingTime`: a discrete hitting time of an adapted process is a
stopping time
## Implementation notes
In the definition of the hitting time, we bound the hitting time by an upper and lower bound.
This is to ensure that our result is meaningful in the case we are taking the infimum of an
empty set or the infimum of a set which is unbounded from below. With this, we can talk about
hitting times indexed by the natural numbers or the reals. By taking the bounds to be
`⊤` and `⊥`, we obtain the standard definition in the case that the index is `ℕ∞` or `ℝ≥0∞`.
-/
open Filter Order TopologicalSpace
open scoped MeasureTheory NNReal ENNReal Topology
namespace MeasureTheory
variable {Ω β ι : Type*} {m : MeasurableSpace Ω}
open scoped Classical in
/-- Hitting time: given a stochastic process `u` and a set `s`, `hitting u s n m` is the first time
`u` is in `s` after time `n` and before time `m` (if `u` does not hit `s` after time `n` and
before `m` then the hitting time is simply `m`).
The hitting time is a stopping time if the process is adapted and discrete. -/
noncomputable def hitting [Preorder ι] [InfSet ι] (u : ι → Ω → β)
(s : Set β) (n m : ι) : Ω → ι :=
fun x => if ∃ j ∈ Set.Icc n m, u j x ∈ s
then sInf (Set.Icc n m ∩ {i : ι | u i x ∈ s}) else m
open scoped Classical in
theorem hitting_def [Preorder ι] [InfSet ι] (u : ι → Ω → β) (s : Set β) (n m : ι) :
hitting u s n m =
fun x => if ∃ j ∈ Set.Icc n m, u j x ∈ s then sInf (Set.Icc n m ∩ {i : ι | u i x ∈ s}) else m :=
rfl
section Inequalities
variable [ConditionallyCompleteLinearOrder ι] {u : ι → Ω → β} {s : Set β} {n i : ι} {ω : Ω}
/-- This lemma is strictly weaker than `hitting_of_le`. -/
theorem hitting_of_lt {m : ι} (h : m < n) : hitting u s n m ω = m := by
simp_rw [hitting]
have h_not : ¬∃ (j : ι) (_ : j ∈ Set.Icc n m), u j ω ∈ s := by
push_neg
intro j
rw [Set.Icc_eq_empty_of_lt h]
simp only [Set.mem_empty_iff_false, IsEmpty.forall_iff]
simp only [exists_prop] at h_not
simp only [h_not, if_false]
theorem hitting_le {m : ι} (ω : Ω) : hitting u s n m ω ≤ m := by
simp only [hitting]
split_ifs with h
· obtain ⟨j, hj₁, hj₂⟩ := h
change j ∈ {i | u i ω ∈ s} at hj₂
exact (csInf_le (BddBelow.inter_of_left bddBelow_Icc) (Set.mem_inter hj₁ hj₂)).trans hj₁.2
· exact le_rfl
theorem not_mem_of_lt_hitting {m k : ι} (hk₁ : k < hitting u s n m ω) (hk₂ : n ≤ k) :
u k ω ∉ s := by
classical
intro h
have hexists : ∃ j ∈ Set.Icc n m, u j ω ∈ s := ⟨k, ⟨hk₂, le_trans hk₁.le <| hitting_le _⟩, h⟩
refine not_le.2 hk₁ ?_
simp_rw [hitting, if_pos hexists]
exact csInf_le bddBelow_Icc.inter_of_left ⟨⟨hk₂, le_trans hk₁.le <| hitting_le _⟩, h⟩
theorem hitting_eq_end_iff {m : ι} : hitting u s n m ω = m ↔
(∃ j ∈ Set.Icc n m, u j ω ∈ s) → sInf (Set.Icc n m ∩ {i : ι | u i ω ∈ s}) = m := by
classical
rw [hitting, ite_eq_right_iff]
theorem hitting_of_le {m : ι} (hmn : m ≤ n) : hitting u s n m ω = m := by
obtain rfl | h := le_iff_eq_or_lt.1 hmn
· classical
rw [hitting, ite_eq_right_iff, forall_exists_index]
conv => intro; rw [Set.mem_Icc, Set.Icc_self, and_imp, and_imp]
intro i hi₁ hi₂ hi
rw [Set.inter_eq_left.2, csInf_singleton]
exact Set.singleton_subset_iff.2 (le_antisymm hi₂ hi₁ ▸ hi)
· exact hitting_of_lt h
theorem le_hitting {m : ι} (hnm : n ≤ m) (ω : Ω) : n ≤ hitting u s n m ω := by
simp only [hitting]
split_ifs with h
· refine le_csInf ?_ fun b hb => ?_
· obtain ⟨k, hk_Icc, hk_s⟩ := h
exact ⟨k, hk_Icc, hk_s⟩
· rw [Set.mem_inter_iff] at hb
exact hb.1.1
· exact hnm
theorem le_hitting_of_exists {m : ι} (h_exists : ∃ j ∈ Set.Icc n m, u j ω ∈ s) :
n ≤ hitting u s n m ω := by
refine le_hitting ?_ ω
by_contra h
rw [Set.Icc_eq_empty_of_lt (not_le.mp h)] at h_exists
simp at h_exists
theorem hitting_mem_Icc {m : ι} (hnm : n ≤ m) (ω : Ω) : hitting u s n m ω ∈ Set.Icc n m :=
⟨le_hitting hnm ω, hitting_le ω⟩
theorem hitting_mem_set [WellFoundedLT ι] {m : ι} (h_exists : ∃ j ∈ Set.Icc n m, u j ω ∈ s) :
u (hitting u s n m ω) ω ∈ s := by
simp_rw [hitting, if_pos h_exists]
have h_nonempty : (Set.Icc n m ∩ {i : ι | u i ω ∈ s}).Nonempty := by
obtain ⟨k, hk₁, hk₂⟩ := h_exists
exact ⟨k, Set.mem_inter hk₁ hk₂⟩
have h_mem := csInf_mem h_nonempty
rw [Set.mem_inter_iff] at h_mem
exact h_mem.2
theorem hitting_mem_set_of_hitting_lt [WellFoundedLT ι] {m : ι} (hl : hitting u s n m ω < m) :
u (hitting u s n m ω) ω ∈ s := by
by_cases h : ∃ j ∈ Set.Icc n m, u j ω ∈ s
· exact hitting_mem_set h
· simp_rw [hitting, if_neg h] at hl
exact False.elim (hl.ne rfl)
| Mathlib/Probability/Process/HittingTime.lean | 146 | 151 | theorem hitting_le_of_mem {m : ι} (hin : n ≤ i) (him : i ≤ m) (his : u i ω ∈ s) :
hitting u s n m ω ≤ i := by | have h_exists : ∃ k ∈ Set.Icc n m, u k ω ∈ s := ⟨i, ⟨hin, him⟩, his⟩
simp_rw [hitting, if_pos h_exists]
exact csInf_le (BddBelow.inter_of_left bddBelow_Icc) (Set.mem_inter ⟨hin, him⟩ his) |
/-
Copyright (c) 2019 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison, Yaël Dillies
-/
import Mathlib.Order.Cover
import Mathlib.Order.Interval.Finset.Defs
/-!
# Intervals as finsets
This file provides basic results about all the `Finset.Ixx`, which are defined in
`Order.Interval.Finset.Defs`.
In addition, it shows that in a locally finite order `≤` and `<` are the transitive closures of,
respectively, `⩿` and `⋖`, which then leads to a characterization of monotone and strictly
functions whose domain is a locally finite order. In particular, this file proves:
* `le_iff_transGen_wcovBy`: `≤` is the transitive closure of `⩿`
* `lt_iff_transGen_covBy`: `<` is the transitive closure of `⋖`
* `monotone_iff_forall_wcovBy`: Characterization of monotone functions
* `strictMono_iff_forall_covBy`: Characterization of strictly monotone functions
## TODO
This file was originally only about `Finset.Ico a b` where `a b : ℕ`. No care has yet been taken to
generalize these lemmas properly and many lemmas about `Icc`, `Ioc`, `Ioo` are missing. In general,
what's to do is taking the lemmas in `Data.X.Intervals` and abstract away the concrete structure.
Complete the API. See
https://github.com/leanprover-community/mathlib/pull/14448#discussion_r906109235
for some ideas.
-/
assert_not_exists MonoidWithZero Finset.sum
open Function OrderDual
open FinsetInterval
variable {ι α : Type*} {a a₁ a₂ b b₁ b₂ c x : α}
namespace Finset
section Preorder
variable [Preorder α]
section LocallyFiniteOrder
variable [LocallyFiniteOrder α]
@[simp]
theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b := by
rw [← coe_nonempty, coe_Icc, Set.nonempty_Icc]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias ⟨_, Aesop.nonempty_Icc_of_le⟩ := nonempty_Icc
@[simp]
theorem nonempty_Ico : (Ico a b).Nonempty ↔ a < b := by
rw [← coe_nonempty, coe_Ico, Set.nonempty_Ico]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias ⟨_, Aesop.nonempty_Ico_of_lt⟩ := nonempty_Ico
@[simp]
theorem nonempty_Ioc : (Ioc a b).Nonempty ↔ a < b := by
rw [← coe_nonempty, coe_Ioc, Set.nonempty_Ioc]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias ⟨_, Aesop.nonempty_Ioc_of_lt⟩ := nonempty_Ioc
-- TODO: This is nonsense. A locally finite order is never densely ordered
@[simp]
theorem nonempty_Ioo [DenselyOrdered α] : (Ioo a b).Nonempty ↔ a < b := by
rw [← coe_nonempty, coe_Ioo, Set.nonempty_Ioo]
@[simp]
theorem Icc_eq_empty_iff : Icc a b = ∅ ↔ ¬a ≤ b := by
rw [← coe_eq_empty, coe_Icc, Set.Icc_eq_empty_iff]
@[simp]
theorem Ico_eq_empty_iff : Ico a b = ∅ ↔ ¬a < b := by
rw [← coe_eq_empty, coe_Ico, Set.Ico_eq_empty_iff]
@[simp]
theorem Ioc_eq_empty_iff : Ioc a b = ∅ ↔ ¬a < b := by
rw [← coe_eq_empty, coe_Ioc, Set.Ioc_eq_empty_iff]
-- TODO: This is nonsense. A locally finite order is never densely ordered
@[simp]
theorem Ioo_eq_empty_iff [DenselyOrdered α] : Ioo a b = ∅ ↔ ¬a < b := by
rw [← coe_eq_empty, coe_Ioo, Set.Ioo_eq_empty_iff]
alias ⟨_, Icc_eq_empty⟩ := Icc_eq_empty_iff
alias ⟨_, Ico_eq_empty⟩ := Ico_eq_empty_iff
alias ⟨_, Ioc_eq_empty⟩ := Ioc_eq_empty_iff
@[simp]
theorem Ioo_eq_empty (h : ¬a < b) : Ioo a b = ∅ :=
eq_empty_iff_forall_not_mem.2 fun _ hx => h ((mem_Ioo.1 hx).1.trans (mem_Ioo.1 hx).2)
@[simp]
theorem Icc_eq_empty_of_lt (h : b < a) : Icc a b = ∅ :=
Icc_eq_empty h.not_le
@[simp]
theorem Ico_eq_empty_of_le (h : b ≤ a) : Ico a b = ∅ :=
Ico_eq_empty h.not_lt
@[simp]
theorem Ioc_eq_empty_of_le (h : b ≤ a) : Ioc a b = ∅ :=
Ioc_eq_empty h.not_lt
@[simp]
theorem Ioo_eq_empty_of_le (h : b ≤ a) : Ioo a b = ∅ :=
Ioo_eq_empty h.not_lt
theorem left_mem_Icc : a ∈ Icc a b ↔ a ≤ b := by simp only [mem_Icc, true_and, le_rfl]
theorem left_mem_Ico : a ∈ Ico a b ↔ a < b := by simp only [mem_Ico, true_and, le_refl]
theorem right_mem_Icc : b ∈ Icc a b ↔ a ≤ b := by simp only [mem_Icc, and_true, le_rfl]
theorem right_mem_Ioc : b ∈ Ioc a b ↔ a < b := by simp only [mem_Ioc, and_true, le_rfl]
theorem left_not_mem_Ioc : a ∉ Ioc a b := fun h => lt_irrefl _ (mem_Ioc.1 h).1
theorem left_not_mem_Ioo : a ∉ Ioo a b := fun h => lt_irrefl _ (mem_Ioo.1 h).1
theorem right_not_mem_Ico : b ∉ Ico a b := fun h => lt_irrefl _ (mem_Ico.1 h).2
theorem right_not_mem_Ioo : b ∉ Ioo a b := fun h => lt_irrefl _ (mem_Ioo.1 h).2
@[gcongr]
theorem Icc_subset_Icc (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Icc a₁ b₁ ⊆ Icc a₂ b₂ := by
simpa [← coe_subset] using Set.Icc_subset_Icc ha hb
@[gcongr]
theorem Ico_subset_Ico (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ico a₁ b₁ ⊆ Ico a₂ b₂ := by
simpa [← coe_subset] using Set.Ico_subset_Ico ha hb
@[gcongr]
theorem Ioc_subset_Ioc (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ioc a₁ b₁ ⊆ Ioc a₂ b₂ := by
simpa [← coe_subset] using Set.Ioc_subset_Ioc ha hb
@[gcongr]
theorem Ioo_subset_Ioo (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ioo a₁ b₁ ⊆ Ioo a₂ b₂ := by
simpa [← coe_subset] using Set.Ioo_subset_Ioo ha hb
@[gcongr]
theorem Icc_subset_Icc_left (h : a₁ ≤ a₂) : Icc a₂ b ⊆ Icc a₁ b :=
Icc_subset_Icc h le_rfl
@[gcongr]
theorem Ico_subset_Ico_left (h : a₁ ≤ a₂) : Ico a₂ b ⊆ Ico a₁ b :=
Ico_subset_Ico h le_rfl
@[gcongr]
theorem Ioc_subset_Ioc_left (h : a₁ ≤ a₂) : Ioc a₂ b ⊆ Ioc a₁ b :=
Ioc_subset_Ioc h le_rfl
@[gcongr]
theorem Ioo_subset_Ioo_left (h : a₁ ≤ a₂) : Ioo a₂ b ⊆ Ioo a₁ b :=
Ioo_subset_Ioo h le_rfl
@[gcongr]
theorem Icc_subset_Icc_right (h : b₁ ≤ b₂) : Icc a b₁ ⊆ Icc a b₂ :=
Icc_subset_Icc le_rfl h
@[gcongr]
theorem Ico_subset_Ico_right (h : b₁ ≤ b₂) : Ico a b₁ ⊆ Ico a b₂ :=
Ico_subset_Ico le_rfl h
@[gcongr]
theorem Ioc_subset_Ioc_right (h : b₁ ≤ b₂) : Ioc a b₁ ⊆ Ioc a b₂ :=
Ioc_subset_Ioc le_rfl h
@[gcongr]
theorem Ioo_subset_Ioo_right (h : b₁ ≤ b₂) : Ioo a b₁ ⊆ Ioo a b₂ :=
Ioo_subset_Ioo le_rfl h
theorem Ico_subset_Ioo_left (h : a₁ < a₂) : Ico a₂ b ⊆ Ioo a₁ b := by
rw [← coe_subset, coe_Ico, coe_Ioo]
exact Set.Ico_subset_Ioo_left h
theorem Ioc_subset_Ioo_right (h : b₁ < b₂) : Ioc a b₁ ⊆ Ioo a b₂ := by
rw [← coe_subset, coe_Ioc, coe_Ioo]
exact Set.Ioc_subset_Ioo_right h
theorem Icc_subset_Ico_right (h : b₁ < b₂) : Icc a b₁ ⊆ Ico a b₂ := by
rw [← coe_subset, coe_Icc, coe_Ico]
exact Set.Icc_subset_Ico_right h
theorem Ioo_subset_Ico_self : Ioo a b ⊆ Ico a b := by
rw [← coe_subset, coe_Ioo, coe_Ico]
exact Set.Ioo_subset_Ico_self
theorem Ioo_subset_Ioc_self : Ioo a b ⊆ Ioc a b := by
rw [← coe_subset, coe_Ioo, coe_Ioc]
exact Set.Ioo_subset_Ioc_self
theorem Ico_subset_Icc_self : Ico a b ⊆ Icc a b := by
rw [← coe_subset, coe_Ico, coe_Icc]
exact Set.Ico_subset_Icc_self
theorem Ioc_subset_Icc_self : Ioc a b ⊆ Icc a b := by
rw [← coe_subset, coe_Ioc, coe_Icc]
exact Set.Ioc_subset_Icc_self
theorem Ioo_subset_Icc_self : Ioo a b ⊆ Icc a b :=
Ioo_subset_Ico_self.trans Ico_subset_Icc_self
theorem Icc_subset_Icc_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Icc a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ ≤ b₂ := by
rw [← coe_subset, coe_Icc, coe_Icc, Set.Icc_subset_Icc_iff h₁]
theorem Icc_subset_Ioo_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ioo a₂ b₂ ↔ a₂ < a₁ ∧ b₁ < b₂ := by
rw [← coe_subset, coe_Icc, coe_Ioo, Set.Icc_subset_Ioo_iff h₁]
theorem Icc_subset_Ico_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ico a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ < b₂ := by
rw [← coe_subset, coe_Icc, coe_Ico, Set.Icc_subset_Ico_iff h₁]
theorem Icc_subset_Ioc_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ioc a₂ b₂ ↔ a₂ < a₁ ∧ b₁ ≤ b₂ :=
(Icc_subset_Ico_iff h₁.dual).trans and_comm
--TODO: `Ico_subset_Ioo_iff`, `Ioc_subset_Ioo_iff`
theorem Icc_ssubset_Icc_left (hI : a₂ ≤ b₂) (ha : a₂ < a₁) (hb : b₁ ≤ b₂) :
Icc a₁ b₁ ⊂ Icc a₂ b₂ := by
rw [← coe_ssubset, coe_Icc, coe_Icc]
exact Set.Icc_ssubset_Icc_left hI ha hb
theorem Icc_ssubset_Icc_right (hI : a₂ ≤ b₂) (ha : a₂ ≤ a₁) (hb : b₁ < b₂) :
Icc a₁ b₁ ⊂ Icc a₂ b₂ := by
rw [← coe_ssubset, coe_Icc, coe_Icc]
exact Set.Icc_ssubset_Icc_right hI ha hb
@[simp]
theorem Ioc_disjoint_Ioc_of_le {d : α} (hbc : b ≤ c) : Disjoint (Ioc a b) (Ioc c d) :=
disjoint_left.2 fun _ h1 h2 ↦ not_and_of_not_left _
((mem_Ioc.1 h1).2.trans hbc).not_lt (mem_Ioc.1 h2)
variable (a)
theorem Ico_self : Ico a a = ∅ :=
Ico_eq_empty <| lt_irrefl _
theorem Ioc_self : Ioc a a = ∅ :=
Ioc_eq_empty <| lt_irrefl _
theorem Ioo_self : Ioo a a = ∅ :=
Ioo_eq_empty <| lt_irrefl _
variable {a}
/-- A set with upper and lower bounds in a locally finite order is a fintype -/
def _root_.Set.fintypeOfMemBounds {s : Set α} [DecidablePred (· ∈ s)] (ha : a ∈ lowerBounds s)
(hb : b ∈ upperBounds s) : Fintype s :=
Set.fintypeSubset (Set.Icc a b) fun _ hx => ⟨ha hx, hb hx⟩
section Filter
theorem Ico_filter_lt_of_le_left [DecidablePred (· < c)] (hca : c ≤ a) :
{x ∈ Ico a b | x < c} = ∅ :=
filter_false_of_mem fun _ hx => (hca.trans (mem_Ico.1 hx).1).not_lt
theorem Ico_filter_lt_of_right_le [DecidablePred (· < c)] (hbc : b ≤ c) :
{x ∈ Ico a b | x < c} = Ico a b :=
filter_true_of_mem fun _ hx => (mem_Ico.1 hx).2.trans_le hbc
theorem Ico_filter_lt_of_le_right [DecidablePred (· < c)] (hcb : c ≤ b) :
{x ∈ Ico a b | x < c} = Ico a c := by
ext x
rw [mem_filter, mem_Ico, mem_Ico, and_right_comm]
exact and_iff_left_of_imp fun h => h.2.trans_le hcb
theorem Ico_filter_le_of_le_left {a b c : α} [DecidablePred (c ≤ ·)] (hca : c ≤ a) :
{x ∈ Ico a b | c ≤ x} = Ico a b :=
filter_true_of_mem fun _ hx => hca.trans (mem_Ico.1 hx).1
theorem Ico_filter_le_of_right_le {a b : α} [DecidablePred (b ≤ ·)] :
{x ∈ Ico a b | b ≤ x} = ∅ :=
filter_false_of_mem fun _ hx => (mem_Ico.1 hx).2.not_le
theorem Ico_filter_le_of_left_le {a b c : α} [DecidablePred (c ≤ ·)] (hac : a ≤ c) :
{x ∈ Ico a b | c ≤ x} = Ico c b := by
ext x
rw [mem_filter, mem_Ico, mem_Ico, and_comm, and_left_comm]
exact and_iff_right_of_imp fun h => hac.trans h.1
theorem Icc_filter_lt_of_lt_right {a b c : α} [DecidablePred (· < c)] (h : b < c) :
{x ∈ Icc a b | x < c} = Icc a b :=
filter_true_of_mem fun _ hx => lt_of_le_of_lt (mem_Icc.1 hx).2 h
theorem Ioc_filter_lt_of_lt_right {a b c : α} [DecidablePred (· < c)] (h : b < c) :
{x ∈ Ioc a b | x < c} = Ioc a b :=
filter_true_of_mem fun _ hx => lt_of_le_of_lt (mem_Ioc.1 hx).2 h
theorem Iic_filter_lt_of_lt_right {α} [Preorder α] [LocallyFiniteOrderBot α] {a c : α}
[DecidablePred (· < c)] (h : a < c) : {x ∈ Iic a | x < c} = Iic a :=
filter_true_of_mem fun _ hx => lt_of_le_of_lt (mem_Iic.1 hx) h
variable (a b) [Fintype α]
theorem filter_lt_lt_eq_Ioo [DecidablePred fun j => a < j ∧ j < b] :
({j | a < j ∧ j < b} : Finset _) = Ioo a b := by ext; simp
theorem filter_lt_le_eq_Ioc [DecidablePred fun j => a < j ∧ j ≤ b] :
({j | a < j ∧ j ≤ b} : Finset _) = Ioc a b := by ext; simp
theorem filter_le_lt_eq_Ico [DecidablePred fun j => a ≤ j ∧ j < b] :
({j | a ≤ j ∧ j < b} : Finset _) = Ico a b := by ext; simp
theorem filter_le_le_eq_Icc [DecidablePred fun j => a ≤ j ∧ j ≤ b] :
({j | a ≤ j ∧ j ≤ b} : Finset _) = Icc a b := by ext; simp
end Filter
end LocallyFiniteOrder
section LocallyFiniteOrderTop
variable [LocallyFiniteOrderTop α]
@[simp]
theorem Ioi_eq_empty : Ioi a = ∅ ↔ IsMax a := by
rw [← coe_eq_empty, coe_Ioi, Set.Ioi_eq_empty_iff]
@[simp] alias ⟨_, _root_.IsMax.finsetIoi_eq⟩ := Ioi_eq_empty
@[simp] lemma Ioi_nonempty : (Ioi a).Nonempty ↔ ¬ IsMax a := by simp [nonempty_iff_ne_empty]
theorem Ioi_top [OrderTop α] : Ioi (⊤ : α) = ∅ := Ioi_eq_empty.mpr isMax_top
@[simp]
theorem Ici_bot [OrderBot α] [Fintype α] : Ici (⊥ : α) = univ := by
ext a; simp only [mem_Ici, bot_le, mem_univ]
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
lemma nonempty_Ici : (Ici a).Nonempty := ⟨a, mem_Ici.2 le_rfl⟩
lemma nonempty_Ioi : (Ioi a).Nonempty ↔ ¬ IsMax a := by simp [Finset.Nonempty]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias ⟨_, Aesop.nonempty_Ioi_of_not_isMax⟩ := nonempty_Ioi
@[simp]
theorem Ici_subset_Ici : Ici a ⊆ Ici b ↔ b ≤ a := by
simp [← coe_subset]
@[gcongr]
alias ⟨_, _root_.GCongr.Finset.Ici_subset_Ici⟩ := Ici_subset_Ici
@[simp]
theorem Ici_ssubset_Ici : Ici a ⊂ Ici b ↔ b < a := by
simp [← coe_ssubset]
@[gcongr]
alias ⟨_, _root_.GCongr.Finset.Ici_ssubset_Ici⟩ := Ici_ssubset_Ici
@[gcongr]
theorem Ioi_subset_Ioi (h : a ≤ b) : Ioi b ⊆ Ioi a := by
simpa [← coe_subset] using Set.Ioi_subset_Ioi h
@[gcongr]
theorem Ioi_ssubset_Ioi (h : a < b) : Ioi b ⊂ Ioi a := by
simpa [← coe_ssubset] using Set.Ioi_ssubset_Ioi h
variable [LocallyFiniteOrder α]
theorem Icc_subset_Ici_self : Icc a b ⊆ Ici a := by
simpa [← coe_subset] using Set.Icc_subset_Ici_self
theorem Ico_subset_Ici_self : Ico a b ⊆ Ici a := by
simpa [← coe_subset] using Set.Ico_subset_Ici_self
theorem Ioc_subset_Ioi_self : Ioc a b ⊆ Ioi a := by
simpa [← coe_subset] using Set.Ioc_subset_Ioi_self
theorem Ioo_subset_Ioi_self : Ioo a b ⊆ Ioi a := by
simpa [← coe_subset] using Set.Ioo_subset_Ioi_self
theorem Ioc_subset_Ici_self : Ioc a b ⊆ Ici a :=
Ioc_subset_Icc_self.trans Icc_subset_Ici_self
theorem Ioo_subset_Ici_self : Ioo a b ⊆ Ici a :=
Ioo_subset_Ico_self.trans Ico_subset_Ici_self
end LocallyFiniteOrderTop
section LocallyFiniteOrderBot
variable [LocallyFiniteOrderBot α]
@[simp]
theorem Iio_eq_empty : Iio a = ∅ ↔ IsMin a := Ioi_eq_empty (α := αᵒᵈ)
@[simp] alias ⟨_, _root_.IsMin.finsetIio_eq⟩ := Iio_eq_empty
@[simp] lemma Iio_nonempty : (Iio a).Nonempty ↔ ¬ IsMin a := by simp [nonempty_iff_ne_empty]
theorem Iio_bot [OrderBot α] : Iio (⊥ : α) = ∅ := Iio_eq_empty.mpr isMin_bot
@[simp]
theorem Iic_top [OrderTop α] [Fintype α] : Iic (⊤ : α) = univ := by
ext a; simp only [mem_Iic, le_top, mem_univ]
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
lemma nonempty_Iic : (Iic a).Nonempty := ⟨a, mem_Iic.2 le_rfl⟩
lemma nonempty_Iio : (Iio a).Nonempty ↔ ¬ IsMin a := by simp [Finset.Nonempty]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias ⟨_, Aesop.nonempty_Iio_of_not_isMin⟩ := nonempty_Iio
@[simp]
theorem Iic_subset_Iic : Iic a ⊆ Iic b ↔ a ≤ b := by
simp [← coe_subset]
@[gcongr]
alias ⟨_, _root_.GCongr.Finset.Iic_subset_Iic⟩ := Iic_subset_Iic
@[simp]
theorem Iic_ssubset_Iic : Iic a ⊂ Iic b ↔ a < b := by
simp [← coe_ssubset]
@[gcongr]
alias ⟨_, _root_.GCongr.Finset.Iic_ssubset_Iic⟩ := Iic_ssubset_Iic
@[gcongr]
theorem Iio_subset_Iio (h : a ≤ b) : Iio a ⊆ Iio b := by
simpa [← coe_subset] using Set.Iio_subset_Iio h
@[gcongr]
theorem Iio_ssubset_Iio (h : a < b) : Iio a ⊂ Iio b := by
simpa [← coe_ssubset] using Set.Iio_ssubset_Iio h
variable [LocallyFiniteOrder α]
theorem Icc_subset_Iic_self : Icc a b ⊆ Iic b := by
simpa [← coe_subset] using Set.Icc_subset_Iic_self
theorem Ioc_subset_Iic_self : Ioc a b ⊆ Iic b := by
simpa [← coe_subset] using Set.Ioc_subset_Iic_self
theorem Ico_subset_Iio_self : Ico a b ⊆ Iio b := by
simpa [← coe_subset] using Set.Ico_subset_Iio_self
theorem Ioo_subset_Iio_self : Ioo a b ⊆ Iio b := by
simpa [← coe_subset] using Set.Ioo_subset_Iio_self
theorem Ico_subset_Iic_self : Ico a b ⊆ Iic b :=
Ico_subset_Icc_self.trans Icc_subset_Iic_self
theorem Ioo_subset_Iic_self : Ioo a b ⊆ Iic b :=
Ioo_subset_Ioc_self.trans Ioc_subset_Iic_self
theorem Iic_disjoint_Ioc (h : a ≤ b) : Disjoint (Iic a) (Ioc b c) :=
disjoint_left.2 fun _ hax hbcx ↦ (mem_Iic.1 hax).not_lt <| lt_of_le_of_lt h (mem_Ioc.1 hbcx).1
/-- An equivalence between `Finset.Iic a` and `Set.Iic a`. -/
def _root_.Equiv.IicFinsetSet (a : α) : Iic a ≃ Set.Iic a where
toFun b := ⟨b.1, coe_Iic a ▸ mem_coe.2 b.2⟩
invFun b := ⟨b.1, by rw [← mem_coe, coe_Iic a]; exact b.2⟩
left_inv := fun _ ↦ rfl
right_inv := fun _ ↦ rfl
end LocallyFiniteOrderBot
section LocallyFiniteOrderTop
variable [LocallyFiniteOrderTop α] {a : α}
theorem Ioi_subset_Ici_self : Ioi a ⊆ Ici a := by
simpa [← coe_subset] using Set.Ioi_subset_Ici_self
theorem _root_.BddBelow.finite {s : Set α} (hs : BddBelow s) : s.Finite :=
let ⟨a, ha⟩ := hs
(Ici a).finite_toSet.subset fun _ hx => mem_Ici.2 <| ha hx
theorem _root_.Set.Infinite.not_bddBelow {s : Set α} : s.Infinite → ¬BddBelow s :=
mt BddBelow.finite
variable [Fintype α]
theorem filter_lt_eq_Ioi [DecidablePred (a < ·)] : ({x | a < x} : Finset _) = Ioi a := by ext; simp
theorem filter_le_eq_Ici [DecidablePred (a ≤ ·)] : ({x | a ≤ x} : Finset _) = Ici a := by ext; simp
end LocallyFiniteOrderTop
section LocallyFiniteOrderBot
variable [LocallyFiniteOrderBot α] {a : α}
theorem Iio_subset_Iic_self : Iio a ⊆ Iic a := by
simpa [← coe_subset] using Set.Iio_subset_Iic_self
theorem _root_.BddAbove.finite {s : Set α} (hs : BddAbove s) : s.Finite :=
hs.dual.finite
theorem _root_.Set.Infinite.not_bddAbove {s : Set α} : s.Infinite → ¬BddAbove s :=
mt BddAbove.finite
variable [Fintype α]
theorem filter_gt_eq_Iio [DecidablePred (· < a)] : ({x | x < a} : Finset _) = Iio a := by ext; simp
theorem filter_ge_eq_Iic [DecidablePred (· ≤ a)] : ({x | x ≤ a} : Finset _) = Iic a := by ext; simp
end LocallyFiniteOrderBot
section LocallyFiniteOrder
variable [LocallyFiniteOrder α]
@[simp]
theorem Icc_bot [OrderBot α] : Icc (⊥ : α) a = Iic a := rfl
@[simp]
theorem Icc_top [OrderTop α] : Icc a (⊤ : α) = Ici a := rfl
@[simp]
theorem Ico_bot [OrderBot α] : Ico (⊥ : α) a = Iio a := rfl
@[simp]
theorem Ioc_top [OrderTop α] : Ioc a (⊤ : α) = Ioi a := rfl
theorem Icc_bot_top [BoundedOrder α] [Fintype α] : Icc (⊥ : α) (⊤ : α) = univ := by
rw [Icc_bot, Iic_top]
end LocallyFiniteOrder
variable [LocallyFiniteOrderTop α] [LocallyFiniteOrderBot α]
theorem disjoint_Ioi_Iio (a : α) : Disjoint (Ioi a) (Iio a) :=
disjoint_left.2 fun _ hab hba => (mem_Ioi.1 hab).not_lt <| mem_Iio.1 hba
end Preorder
section PartialOrder
variable [PartialOrder α] [LocallyFiniteOrder α] {a b c : α}
@[simp]
theorem Icc_self (a : α) : Icc a a = {a} := by rw [← coe_eq_singleton, coe_Icc, Set.Icc_self]
@[simp]
theorem Icc_eq_singleton_iff : Icc a b = {c} ↔ a = c ∧ b = c := by
rw [← coe_eq_singleton, coe_Icc, Set.Icc_eq_singleton_iff]
theorem Ico_disjoint_Ico_consecutive (a b c : α) : Disjoint (Ico a b) (Ico b c) :=
disjoint_left.2 fun _ hab hbc => (mem_Ico.mp hab).2.not_le (mem_Ico.mp hbc).1
@[simp]
theorem Ici_top [OrderTop α] : Ici (⊤ : α) = {⊤} := Icc_eq_singleton_iff.2 ⟨rfl, rfl⟩
@[simp]
theorem Iic_bot [OrderBot α] : Iic (⊥ : α) = {⊥} := Icc_eq_singleton_iff.2 ⟨rfl, rfl⟩
section DecidableEq
variable [DecidableEq α]
@[simp]
theorem Icc_erase_left (a b : α) : (Icc a b).erase a = Ioc a b := by simp [← coe_inj]
@[simp]
theorem Icc_erase_right (a b : α) : (Icc a b).erase b = Ico a b := by simp [← coe_inj]
@[simp]
theorem Ico_erase_left (a b : α) : (Ico a b).erase a = Ioo a b := by simp [← coe_inj]
@[simp]
theorem Ioc_erase_right (a b : α) : (Ioc a b).erase b = Ioo a b := by simp [← coe_inj]
@[simp]
theorem Icc_diff_both (a b : α) : Icc a b \ {a, b} = Ioo a b := by simp [← coe_inj]
@[simp]
theorem Ico_insert_right (h : a ≤ b) : insert b (Ico a b) = Icc a b := by
rw [← coe_inj, coe_insert, coe_Icc, coe_Ico, Set.insert_eq, Set.union_comm, Set.Ico_union_right h]
@[simp]
theorem Ioc_insert_left (h : a ≤ b) : insert a (Ioc a b) = Icc a b := by
rw [← coe_inj, coe_insert, coe_Ioc, coe_Icc, Set.insert_eq, Set.union_comm, Set.Ioc_union_left h]
@[simp]
theorem Ioo_insert_left (h : a < b) : insert a (Ioo a b) = Ico a b := by
rw [← coe_inj, coe_insert, coe_Ioo, coe_Ico, Set.insert_eq, Set.union_comm, Set.Ioo_union_left h]
@[simp]
| Mathlib/Order/Interval/Finset/Basic.lean | 591 | 592 | theorem Ioo_insert_right (h : a < b) : insert b (Ioo a b) = Ioc a b := by | rw [← coe_inj, coe_insert, coe_Ioo, coe_Ioc, Set.insert_eq, Set.union_comm, Set.Ioo_union_right h] |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Kim Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.Polynomial.Eval.Degree
import Mathlib.Algebra.Prime.Lemmas
/-!
# Theory of degrees of polynomials
Some of the main results include
- `natDegree_comp_le` : The degree of the composition is at most the product of degrees
-/
noncomputable section
open Polynomial
open Finsupp Finset
namespace Polynomial
universe u v w
variable {R : Type u} {S : Type v} {ι : Type w} {a b : R} {m n : ℕ}
section Semiring
variable [Semiring R] {p q r : R[X]}
section Degree
theorem natDegree_comp_le : natDegree (p.comp q) ≤ natDegree p * natDegree q :=
letI := Classical.decEq R
if h0 : p.comp q = 0 then by rw [h0, natDegree_zero]; exact Nat.zero_le _
else
WithBot.coe_le_coe.1 <|
calc
↑(natDegree (p.comp q)) = degree (p.comp q) := (degree_eq_natDegree h0).symm
_ = _ := congr_arg degree comp_eq_sum_left
_ ≤ _ := degree_sum_le _ _
_ ≤ _ :=
Finset.sup_le fun n hn =>
calc
degree (C (coeff p n) * q ^ n) ≤ degree (C (coeff p n)) + degree (q ^ n) :=
degree_mul_le _ _
_ ≤ natDegree (C (coeff p n)) + n • degree q :=
(add_le_add degree_le_natDegree (degree_pow_le _ _))
_ ≤ natDegree (C (coeff p n)) + n • ↑(natDegree q) :=
(add_le_add_left (nsmul_le_nsmul_right (@degree_le_natDegree _ _ q) n) _)
_ = (n * natDegree q : ℕ) := by
rw [natDegree_C, Nat.cast_zero, zero_add, nsmul_eq_mul]
simp
_ ≤ (natDegree p * natDegree q : ℕ) :=
WithBot.coe_le_coe.2 <|
mul_le_mul_of_nonneg_right (le_natDegree_of_ne_zero (mem_support_iff.1 hn))
(Nat.zero_le _)
theorem natDegree_comp_eq_of_mul_ne_zero (h : p.leadingCoeff * q.leadingCoeff ^ p.natDegree ≠ 0) :
natDegree (p.comp q) = natDegree p * natDegree q := by
by_cases hq : natDegree q = 0
· exact le_antisymm natDegree_comp_le (by simp [hq])
apply natDegree_eq_of_le_of_coeff_ne_zero natDegree_comp_le
rwa [coeff_comp_degree_mul_degree hq]
theorem degree_pos_of_root {p : R[X]} (hp : p ≠ 0) (h : IsRoot p a) : 0 < degree p :=
lt_of_not_ge fun hlt => by
have := eq_C_of_degree_le_zero hlt
rw [IsRoot, this, eval_C] at h
simp only [h, RingHom.map_zero] at this
exact hp this
theorem natDegree_le_iff_coeff_eq_zero : p.natDegree ≤ n ↔ ∀ N : ℕ, n < N → p.coeff N = 0 := by
simp_rw [natDegree_le_iff_degree_le, degree_le_iff_coeff_zero, Nat.cast_lt]
theorem natDegree_add_le_iff_left {n : ℕ} (p q : R[X]) (qn : q.natDegree ≤ n) :
(p + q).natDegree ≤ n ↔ p.natDegree ≤ n := by
refine ⟨fun h => ?_, fun h => natDegree_add_le_of_degree_le h qn⟩
refine natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_
convert natDegree_le_iff_coeff_eq_zero.mp h m hm using 1
rw [coeff_add, natDegree_le_iff_coeff_eq_zero.mp qn _ hm, add_zero]
theorem natDegree_add_le_iff_right {n : ℕ} (p q : R[X]) (pn : p.natDegree ≤ n) :
(p + q).natDegree ≤ n ↔ q.natDegree ≤ n := by
rw [add_comm]
exact natDegree_add_le_iff_left _ _ pn
-- TODO: Do we really want the following two lemmas? They are straightforward consequences of a
-- more atomic lemma
theorem natDegree_C_mul_le (a : R) (f : R[X]) : (C a * f).natDegree ≤ f.natDegree := by
simpa using natDegree_mul_le (p := C a)
theorem natDegree_mul_C_le (f : R[X]) (a : R) : (f * C a).natDegree ≤ f.natDegree := by
simpa using natDegree_mul_le (q := C a)
theorem eq_natDegree_of_le_mem_support (pn : p.natDegree ≤ n) (ns : n ∈ p.support) :
p.natDegree = n :=
le_antisymm pn (le_natDegree_of_mem_supp _ ns)
theorem natDegree_C_mul_eq_of_mul_eq_one {ai : R} (au : ai * a = 1) :
(C a * p).natDegree = p.natDegree :=
le_antisymm (natDegree_C_mul_le a p)
(calc
p.natDegree = (1 * p).natDegree := by nth_rw 1 [← one_mul p]
_ = (C ai * (C a * p)).natDegree := by rw [← C_1, ← au, RingHom.map_mul, ← mul_assoc]
_ ≤ (C a * p).natDegree := natDegree_C_mul_le ai (C a * p))
| Mathlib/Algebra/Polynomial/Degree/Lemmas.lean | 111 | 117 | theorem natDegree_mul_C_eq_of_mul_eq_one {ai : R} (au : a * ai = 1) :
(p * C a).natDegree = p.natDegree :=
le_antisymm (natDegree_mul_C_le p a)
(calc
p.natDegree = (p * 1).natDegree := by | nth_rw 1 [← mul_one p]
_ = (p * C a * C ai).natDegree := by rw [← C_1, ← au, RingHom.map_mul, ← mul_assoc]
_ ≤ (p * C a).natDegree := natDegree_mul_C_le (p * C a) ai) |
/-
Copyright (c) 2018 Violeta Hernández Palacios, Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Violeta Hernández Palacios, Mario Carneiro
-/
import Mathlib.Logic.Small.List
import Mathlib.SetTheory.Ordinal.Enum
import Mathlib.SetTheory.Ordinal.Exponential
/-!
# Fixed points of normal functions
We prove various statements about the fixed points of normal ordinal functions. We state them in
three forms: as statements about type-indexed families of normal functions, as statements about
ordinal-indexed families of normal functions, and as statements about a single normal function. For
the most part, the first case encompasses the others.
Moreover, we prove some lemmas about the fixed points of specific normal functions.
## Main definitions and results
* `nfpFamily`, `nfp`: the next fixed point of a (family of) normal function(s).
* `not_bddAbove_fp_family`, `not_bddAbove_fp`: the (common) fixed points of a (family of) normal
function(s) are unbounded in the ordinals.
* `deriv_add_eq_mul_omega0_add`: a characterization of the derivative of addition.
* `deriv_mul_eq_opow_omega0_mul`: a characterization of the derivative of multiplication.
-/
noncomputable section
universe u v
open Function Order
namespace Ordinal
/-! ### Fixed points of type-indexed families of ordinals -/
section
variable {ι : Type*} {f : ι → Ordinal.{u} → Ordinal.{u}}
/-- The next common fixed point, at least `a`, for a family of normal functions.
This is defined for any family of functions, as the supremum of all values reachable by applying
finitely many functions in the family to `a`.
`Ordinal.nfpFamily_fp` shows this is a fixed point, `Ordinal.le_nfpFamily` shows it's at
least `a`, and `Ordinal.nfpFamily_le_fp` shows this is the least ordinal with these properties. -/
def nfpFamily (f : ι → Ordinal.{u} → Ordinal.{u}) (a : Ordinal.{u}) : Ordinal :=
⨆ i, List.foldr f a i
theorem foldr_le_nfpFamily [Small.{u} ι] (f : ι → Ordinal.{u} → Ordinal.{u}) (a l) :
List.foldr f a l ≤ nfpFamily f a :=
Ordinal.le_iSup _ _
theorem le_nfpFamily [Small.{u} ι] (f : ι → Ordinal.{u} → Ordinal.{u}) (a) : a ≤ nfpFamily f a :=
foldr_le_nfpFamily f a []
theorem lt_nfpFamily_iff [Small.{u} ι] {a b} : a < nfpFamily f b ↔ ∃ l, a < List.foldr f b l :=
Ordinal.lt_iSup_iff
@[deprecated (since := "2025-02-16")]
alias lt_nfpFamily := lt_nfpFamily_iff
theorem nfpFamily_le_iff [Small.{u} ι] {a b} : nfpFamily f a ≤ b ↔ ∀ l, List.foldr f a l ≤ b :=
Ordinal.iSup_le_iff
theorem nfpFamily_le {a b} : (∀ l, List.foldr f a l ≤ b) → nfpFamily f a ≤ b :=
Ordinal.iSup_le
theorem nfpFamily_monotone [Small.{u} ι] (hf : ∀ i, Monotone (f i)) : Monotone (nfpFamily f) :=
fun _ _ h ↦ nfpFamily_le <| fun l ↦ (List.foldr_monotone hf l h).trans (foldr_le_nfpFamily _ _ l)
theorem apply_lt_nfpFamily [Small.{u} ι] (H : ∀ i, IsNormal (f i)) {a b}
(hb : b < nfpFamily f a) (i) : f i b < nfpFamily f a :=
let ⟨l, hl⟩ := lt_nfpFamily_iff.1 hb
lt_nfpFamily_iff.2 ⟨i::l, (H i).strictMono hl⟩
theorem apply_lt_nfpFamily_iff [Nonempty ι] [Small.{u} ι] (H : ∀ i, IsNormal (f i)) {a b} :
(∀ i, f i b < nfpFamily f a) ↔ b < nfpFamily f a := by
refine ⟨fun h ↦ ?_, apply_lt_nfpFamily H⟩
let ⟨l, hl⟩ := lt_nfpFamily_iff.1 (h (Classical.arbitrary ι))
exact lt_nfpFamily_iff.2 <| ⟨l, (H _).le_apply.trans_lt hl⟩
theorem nfpFamily_le_apply [Nonempty ι] [Small.{u} ι] (H : ∀ i, IsNormal (f i)) {a b} :
(∃ i, nfpFamily f a ≤ f i b) ↔ nfpFamily f a ≤ b := by
rw [← not_iff_not]
push_neg
exact apply_lt_nfpFamily_iff H
theorem nfpFamily_le_fp (H : ∀ i, Monotone (f i)) {a b} (ab : a ≤ b) (h : ∀ i, f i b ≤ b) :
nfpFamily f a ≤ b := by
apply Ordinal.iSup_le
intro l
induction' l with i l IH generalizing a
· exact ab
· exact (H i (IH ab)).trans (h i)
theorem nfpFamily_fp [Small.{u} ι] {i} (H : IsNormal (f i)) (a) :
f i (nfpFamily f a) = nfpFamily f a := by
rw [nfpFamily, H.map_iSup]
apply le_antisymm <;> refine Ordinal.iSup_le fun l => ?_
· exact Ordinal.le_iSup _ (i::l)
· exact H.le_apply.trans (Ordinal.le_iSup _ _)
theorem apply_le_nfpFamily [Small.{u} ι] [hι : Nonempty ι] (H : ∀ i, IsNormal (f i)) {a b} :
(∀ i, f i b ≤ nfpFamily f a) ↔ b ≤ nfpFamily f a := by
refine ⟨fun h => ?_, fun h i => ?_⟩
· obtain ⟨i⟩ := hι
exact (H i).le_apply.trans (h i)
· rw [← nfpFamily_fp (H i)]
exact (H i).monotone h
theorem nfpFamily_eq_self [Small.{u} ι] {a} (h : ∀ i, f i a = a) : nfpFamily f a = a := by
apply (Ordinal.iSup_le ?_).antisymm (le_nfpFamily f a)
intro l
rw [List.foldr_fixed' h l]
-- Todo: This is actually a special case of the fact the intersection of club sets is a club set.
/-- A generalization of the fixed point lemma for normal functions: any family of normal functions
has an unbounded set of common fixed points. -/
theorem not_bddAbove_fp_family [Small.{u} ι] (H : ∀ i, IsNormal (f i)) :
¬ BddAbove (⋂ i, Function.fixedPoints (f i)) := by
rw [not_bddAbove_iff]
refine fun a ↦ ⟨nfpFamily f (succ a), ?_, (lt_succ a).trans_le (le_nfpFamily f _)⟩
rintro _ ⟨i, rfl⟩
exact nfpFamily_fp (H i) _
/-- The derivative of a family of normal functions is the sequence of their common fixed points.
This is defined for all functions such that `Ordinal.derivFamily_zero`,
`Ordinal.derivFamily_succ`, and `Ordinal.derivFamily_limit` are satisfied. -/
def derivFamily (f : ι → Ordinal.{u} → Ordinal.{u}) (o : Ordinal.{u}) : Ordinal.{u} :=
limitRecOn o (nfpFamily f 0) (fun _ IH => nfpFamily f (succ IH))
fun a _ g => ⨆ b : Set.Iio a, g _ b.2
@[simp]
theorem derivFamily_zero (f : ι → Ordinal → Ordinal) :
derivFamily f 0 = nfpFamily f 0 :=
limitRecOn_zero ..
@[simp]
theorem derivFamily_succ (f : ι → Ordinal → Ordinal) (o) :
derivFamily f (succ o) = nfpFamily f (succ (derivFamily f o)) :=
limitRecOn_succ ..
theorem derivFamily_limit (f : ι → Ordinal → Ordinal) {o} :
IsLimit o → derivFamily f o = ⨆ b : Set.Iio o, derivFamily f b :=
limitRecOn_limit _ _ _ _
theorem isNormal_derivFamily [Small.{u} ι] (f : ι → Ordinal.{u} → Ordinal.{u}) :
IsNormal (derivFamily f) := by
refine ⟨fun o ↦ ?_, fun o h a ↦ ?_⟩
· rw [derivFamily_succ, ← succ_le_iff]
exact le_nfpFamily _ _
· simp_rw [derivFamily_limit _ h, Ordinal.iSup_le_iff, Subtype.forall, Set.mem_Iio]
theorem derivFamily_strictMono [Small.{u} ι] (f : ι → Ordinal.{u} → Ordinal.{u}) :
StrictMono (derivFamily f) :=
(isNormal_derivFamily f).strictMono
theorem derivFamily_fp [Small.{u} ι] {i} (H : IsNormal (f i)) (o : Ordinal) :
f i (derivFamily f o) = derivFamily f o := by
induction' o using limitRecOn with o _ o l IH
· rw [derivFamily_zero]
exact nfpFamily_fp H 0
· rw [derivFamily_succ]
exact nfpFamily_fp H _
· have : Nonempty (Set.Iio o) := ⟨0, l.pos⟩
rw [derivFamily_limit _ l, H.map_iSup]
refine eq_of_forall_ge_iff fun c => ?_
rw [Ordinal.iSup_le_iff, Ordinal.iSup_le_iff]
refine forall_congr' fun a ↦ ?_
rw [IH _ a.2]
theorem le_iff_derivFamily [Small.{u} ι] (H : ∀ i, IsNormal (f i)) {a} :
(∀ i, f i a ≤ a) ↔ ∃ o, derivFamily f o = a :=
⟨fun ha => by
suffices ∀ (o), a ≤ derivFamily f o → ∃ o, derivFamily f o = a from
this a (isNormal_derivFamily _).le_apply
intro o
induction' o using limitRecOn with o IH o l IH
· intro h₁
refine ⟨0, le_antisymm ?_ h₁⟩
rw [derivFamily_zero]
exact nfpFamily_le_fp (fun i => (H i).monotone) (Ordinal.zero_le _) ha
· intro h₁
rcases le_or_lt a (derivFamily f o) with h | h
· exact IH h
refine ⟨succ o, le_antisymm ?_ h₁⟩
rw [derivFamily_succ]
exact nfpFamily_le_fp (fun i => (H i).monotone) (succ_le_of_lt h) ha
· intro h₁
rcases eq_or_lt_of_le h₁ with h | h
· exact ⟨_, h.symm⟩
rw [derivFamily_limit _ l, ← not_le, Ordinal.iSup_le_iff, not_forall] at h
obtain ⟨o', h⟩ := h
exact IH o' o'.2 (le_of_not_le h),
fun ⟨_, e⟩ i => e ▸ (derivFamily_fp (H i) _).le⟩
theorem fp_iff_derivFamily [Small.{u} ι] (H : ∀ i, IsNormal (f i)) {a} :
(∀ i, f i a = a) ↔ ∃ o, derivFamily f o = a :=
Iff.trans ⟨fun h i => le_of_eq (h i), fun h i => (H i).le_iff_eq.1 (h i)⟩ (le_iff_derivFamily H)
/-- For a family of normal functions, `Ordinal.derivFamily` enumerates the common fixed points. -/
theorem derivFamily_eq_enumOrd [Small.{u} ι] (H : ∀ i, IsNormal (f i)) :
derivFamily f = enumOrd (⋂ i, Function.fixedPoints (f i)) := by
rw [eq_comm, eq_enumOrd _ (not_bddAbove_fp_family H)]
use (isNormal_derivFamily f).strictMono
rw [Set.range_eq_iff]
refine ⟨?_, fun a ha => ?_⟩
· rintro a S ⟨i, hi⟩
rw [← hi]
exact derivFamily_fp (H i) a
rw [Set.mem_iInter] at ha
rwa [← fp_iff_derivFamily H]
end
/-! ### Fixed points of a single function -/
section
variable {f : Ordinal.{u} → Ordinal.{u}}
/-- The next fixed point function, the least fixed point of the normal function `f`, at least `a`.
This is defined as `nfpFamily` applied to a family consisting only of `f`. -/
def nfp (f : Ordinal → Ordinal) : Ordinal → Ordinal :=
nfpFamily fun _ : Unit => f
theorem nfp_eq_nfpFamily (f : Ordinal → Ordinal) : nfp f = nfpFamily fun _ : Unit => f :=
rfl
theorem iSup_iterate_eq_nfp (f : Ordinal.{u} → Ordinal.{u}) (a : Ordinal.{u}) :
⨆ n : ℕ, f^[n] a = nfp f a := by
apply le_antisymm
· rw [Ordinal.iSup_le_iff]
intro n
rw [← List.length_replicate (n := n) (a := Unit.unit), ← List.foldr_const f a]
exact Ordinal.le_iSup _ _
· apply Ordinal.iSup_le
intro l
rw [List.foldr_const f a l]
exact Ordinal.le_iSup _ _
theorem iterate_le_nfp (f a n) : f^[n] a ≤ nfp f a := by
rw [← iSup_iterate_eq_nfp]
exact Ordinal.le_iSup (fun n ↦ f^[n] a) n
theorem le_nfp (f a) : a ≤ nfp f a :=
iterate_le_nfp f a 0
theorem lt_nfp_iff {a b} : a < nfp f b ↔ ∃ n, a < f^[n] b := by
rw [← iSup_iterate_eq_nfp]
exact Ordinal.lt_iSup_iff
theorem nfp_le_iff {a b} : nfp f a ≤ b ↔ ∀ n, f^[n] a ≤ b := by
rw [← iSup_iterate_eq_nfp]
exact Ordinal.iSup_le_iff
theorem nfp_le {a b} : (∀ n, f^[n] a ≤ b) → nfp f a ≤ b :=
nfp_le_iff.2
@[simp]
theorem nfp_id : nfp id = id := by
ext
simp_rw [← iSup_iterate_eq_nfp, iterate_id]
exact ciSup_const
theorem nfp_monotone (hf : Monotone f) : Monotone (nfp f) :=
nfpFamily_monotone fun _ => hf
theorem IsNormal.apply_lt_nfp (H : IsNormal f) {a b} : f b < nfp f a ↔ b < nfp f a := by
unfold nfp
rw [← @apply_lt_nfpFamily_iff Unit (fun _ => f) _ _ (fun _ => H) a b]
exact ⟨fun h _ => h, fun h => h Unit.unit⟩
theorem IsNormal.nfp_le_apply (H : IsNormal f) {a b} : nfp f a ≤ f b ↔ nfp f a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 H.apply_lt_nfp
theorem nfp_le_fp (H : Monotone f) {a b} (ab : a ≤ b) (h : f b ≤ b) : nfp f a ≤ b :=
nfpFamily_le_fp (fun _ => H) ab fun _ => h
theorem IsNormal.nfp_fp (H : IsNormal f) : ∀ a, f (nfp f a) = nfp f a :=
@nfpFamily_fp Unit (fun _ => f) _ () H
theorem IsNormal.apply_le_nfp (H : IsNormal f) {a b} : f b ≤ nfp f a ↔ b ≤ nfp f a :=
⟨H.le_apply.trans, fun h => by simpa only [H.nfp_fp] using H.le_iff.2 h⟩
theorem nfp_eq_self {a} (h : f a = a) : nfp f a = a :=
nfpFamily_eq_self fun _ => h
/-- The fixed point lemma for normal functions: any normal function has an unbounded set of
fixed points. -/
theorem not_bddAbove_fp (H : IsNormal f) : ¬ BddAbove (Function.fixedPoints f) := by
convert not_bddAbove_fp_family fun _ : Unit => H
exact (Set.iInter_const _).symm
/-- The derivative of a normal function `f` is the sequence of fixed points of `f`.
This is defined as `Ordinal.derivFamily` applied to a trivial family consisting only of `f`. -/
def deriv (f : Ordinal → Ordinal) : Ordinal → Ordinal :=
derivFamily fun _ : Unit => f
theorem deriv_eq_derivFamily (f : Ordinal → Ordinal) : deriv f = derivFamily fun _ : Unit => f :=
rfl
@[simp]
theorem deriv_zero_right (f) : deriv f 0 = nfp f 0 :=
derivFamily_zero _
@[simp]
theorem deriv_succ (f o) : deriv f (succ o) = nfp f (succ (deriv f o)) :=
derivFamily_succ _ _
theorem deriv_limit (f) {o} : IsLimit o → deriv f o = ⨆ a : {a // a < o}, deriv f a :=
derivFamily_limit _
theorem isNormal_deriv (f) : IsNormal (deriv f) :=
isNormal_derivFamily _
theorem deriv_strictMono (f) : StrictMono (deriv f) :=
derivFamily_strictMono _
theorem deriv_id_of_nfp_id (h : nfp f = id) : deriv f = id :=
((isNormal_deriv _).eq_iff_zero_and_succ IsNormal.refl).2 (by simp [h])
theorem IsNormal.deriv_fp (H : IsNormal f) : ∀ o, f (deriv f o) = deriv f o :=
derivFamily_fp (i := ⟨⟩) H
theorem IsNormal.le_iff_deriv (H : IsNormal f) {a} : f a ≤ a ↔ ∃ o, deriv f o = a := by
unfold deriv
rw [← le_iff_derivFamily fun _ : Unit => H]
exact ⟨fun h _ => h, fun h => h Unit.unit⟩
theorem IsNormal.fp_iff_deriv (H : IsNormal f) {a} : f a = a ↔ ∃ o, deriv f o = a := by
rw [← H.le_iff_eq, H.le_iff_deriv]
/-- `Ordinal.deriv` enumerates the fixed points of a normal function. -/
theorem deriv_eq_enumOrd (H : IsNormal f) : deriv f = enumOrd (Function.fixedPoints f) := by
convert derivFamily_eq_enumOrd fun _ : Unit => H
exact (Set.iInter_const _).symm
theorem deriv_eq_id_of_nfp_eq_id (h : nfp f = id) : deriv f = id :=
(IsNormal.eq_iff_zero_and_succ (isNormal_deriv _) IsNormal.refl).2 <| by simp [h]
theorem nfp_zero_left (a) : nfp 0 a = a := by
rw [← iSup_iterate_eq_nfp]
apply (Ordinal.iSup_le ?_).antisymm (Ordinal.le_iSup _ 0)
intro n
cases n
· rfl
· rw [Function.iterate_succ']
simp
@[simp]
theorem nfp_zero : nfp 0 = id := by
ext
exact nfp_zero_left _
@[simp]
theorem deriv_zero : deriv 0 = id :=
deriv_eq_id_of_nfp_eq_id nfp_zero
theorem deriv_zero_left (a) : deriv 0 a = a := by
rw [deriv_zero, id_eq]
end
/-! ### Fixed points of addition -/
@[simp]
theorem nfp_add_zero (a) : nfp (a + ·) 0 = a * ω := by
simp_rw [← iSup_iterate_eq_nfp, ← iSup_mul_nat]
congr; funext n
induction' n with n hn
· rw [Nat.cast_zero, mul_zero, iterate_zero_apply]
· rw [iterate_succ_apply', Nat.add_comm, Nat.cast_add, Nat.cast_one, mul_one_add, hn]
theorem nfp_add_eq_mul_omega0 {a b} (hba : b ≤ a * ω) : nfp (a + ·) b = a * ω := by
apply le_antisymm (nfp_le_fp (isNormal_add_right a).monotone hba _)
· rw [← nfp_add_zero]
exact nfp_monotone (isNormal_add_right a).monotone (Ordinal.zero_le b)
· dsimp; rw [← mul_one_add, one_add_omega0]
theorem add_eq_right_iff_mul_omega0_le {a b : Ordinal} : a + b = b ↔ a * ω ≤ b := by
refine ⟨fun h => ?_, fun h => ?_⟩
· rw [← nfp_add_zero a, ← deriv_zero_right]
obtain ⟨c, hc⟩ := (isNormal_add_right a).fp_iff_deriv.1 h
rw [← hc]
exact (isNormal_deriv _).monotone (Ordinal.zero_le _)
· have := Ordinal.add_sub_cancel_of_le h
nth_rw 1 [← this]
rwa [← add_assoc, ← mul_one_add, one_add_omega0]
theorem add_le_right_iff_mul_omega0_le {a b : Ordinal} : a + b ≤ b ↔ a * ω ≤ b := by
rw [← add_eq_right_iff_mul_omega0_le]
exact (isNormal_add_right a).le_iff_eq
theorem deriv_add_eq_mul_omega0_add (a b : Ordinal.{u}) : deriv (a + ·) b = a * ω + b := by
revert b
rw [← funext_iff, IsNormal.eq_iff_zero_and_succ (isNormal_deriv _) (isNormal_add_right _)]
refine ⟨?_, fun a h => ?_⟩
· rw [deriv_zero_right, add_zero]
exact nfp_add_zero a
· rw [deriv_succ, h, add_succ]
exact nfp_eq_self (add_eq_right_iff_mul_omega0_le.2 ((le_add_right _ _).trans (le_succ _)))
/-! ### Fixed points of multiplication -/
@[simp]
theorem nfp_mul_one {a : Ordinal} (ha : 0 < a) : nfp (a * ·) 1 = a ^ ω := by
rw [← iSup_iterate_eq_nfp, ← iSup_pow ha]
congr
funext n
induction' n with n hn
· rw [pow_zero, iterate_zero_apply]
· rw [iterate_succ_apply', Nat.add_comm, pow_add, pow_one, hn]
@[simp]
| Mathlib/SetTheory/Ordinal/FixedPoint.lean | 424 | 432 | theorem nfp_mul_zero (a : Ordinal) : nfp (a * ·) 0 = 0 := by | rw [← Ordinal.le_zero, nfp_le_iff]
intro n
induction' n with n hn; · rfl
dsimp only; rwa [iterate_succ_apply, mul_zero]
theorem nfp_mul_eq_opow_omega0 {a b : Ordinal} (hb : 0 < b) (hba : b ≤ a ^ ω) :
nfp (a * ·) b = a ^ ω := by
rcases eq_zero_or_pos a with ha | ha |
/-
Copyright (c) 2019 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Eric Wieser
-/
import Mathlib.Data.Matrix.ConjTranspose
/-!
# Row and column matrices
This file provides results about row and column matrices.
## Main definitions
* `Matrix.replicateRow ι r : Matrix ι n α`: the matrix where every row is the vector `r : n → α`
* `Matrix.replicateCol ι c : Matrix m ι α`: the matrix where every column is the vector `c : m → α`
* `Matrix.updateRow M i r`: update the `i`th row of `M` to `r`
* `Matrix.updateCol M j c`: update the `j`th column of `M` to `c`
-/
variable {l m n o : Type*}
universe u v w
variable {R : Type*} {α : Type v} {β : Type w}
namespace Matrix
/--
`Matrix.replicateCol ι u` is the matrix with all columns equal to the vector `u`.
To get a column matrix with exactly one column,
`Matrix.replicateCol (Fin 1) u` is the canonical choice.
-/
def replicateCol (ι : Type*) (w : m → α) : Matrix m ι α :=
of fun x _ => w x
-- TODO: set as an equation lemma for `replicateCol`, see https://github.com/leanprover-community/mathlib4/pull/3024
@[simp]
theorem replicateCol_apply {ι : Type*} (w : m → α) (i) (j : ι) : replicateCol ι w i j = w i :=
rfl
/--
`Matrix.replicateRow ι u` is the matrix with all rows equal to the vector `u`.
To get a row matrix with exactly one row, `Matrix.replicateRow (Fin 1) u` is the canonical choice.
-/
def replicateRow (ι : Type*) (v : n → α) : Matrix ι n α :=
of fun _ y => v y
variable {ι : Type*}
-- TODO: set as an equation lemma for `replicateRow`, see https://github.com/leanprover-community/mathlib4/pull/3024
@[simp]
theorem replicateRow_apply (v : n → α) (i : ι) (j) : replicateRow ι v i j = v j :=
rfl
theorem replicateCol_injective [Nonempty ι] :
Function.Injective (replicateCol ι : (m → α) → Matrix m ι α) := by
inhabit ι
exact fun _x _y h => funext fun i => congr_fun₂ h i default
@[deprecated (since := "2025-03-20")] alias col_injective := replicateCol_injective
@[simp] theorem replicateCol_inj [Nonempty ι] {v w : m → α} :
replicateCol ι v = replicateCol ι w ↔ v = w :=
replicateCol_injective.eq_iff
@[deprecated (since := "2025-03-20")] alias col_inj := replicateCol_inj
@[simp] theorem replicateCol_zero [Zero α] : replicateCol ι (0 : m → α) = 0 := rfl
@[deprecated (since := "2025-03-20")] alias col_zero := replicateCol_zero
@[simp] theorem replicateCol_eq_zero [Zero α] [Nonempty ι] (v : m → α) :
replicateCol ι v = 0 ↔ v = 0 :=
replicateCol_inj
@[deprecated (since := "2025-03-20")] alias col_eq_zero := replicateCol_eq_zero
@[simp]
theorem replicateCol_add [Add α] (v w : m → α) :
replicateCol ι (v + w) = replicateCol ι v + replicateCol ι w := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias col_add := replicateCol_add
@[simp]
theorem replicateCol_smul [SMul R α] (x : R) (v : m → α) :
replicateCol ι (x • v) = x • replicateCol ι v := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias col_smul := replicateCol_smul
theorem replicateRow_injective [Nonempty ι] :
Function.Injective (replicateRow ι : (n → α) → Matrix ι n α) := by
inhabit ι
exact fun _x _y h => funext fun j => congr_fun₂ h default j
@[deprecated (since := "2025-03-20")] alias row_injective := replicateRow_injective
@[simp] theorem replicateRow_inj [Nonempty ι] {v w : n → α} :
replicateRow ι v = replicateRow ι w ↔ v = w :=
replicateRow_injective.eq_iff
@[simp] theorem replicateRow_zero [Zero α] : replicateRow ι (0 : n → α) = 0 := rfl
@[deprecated (since := "2025-03-20")] alias row_zero := replicateRow_zero
@[simp] theorem replicateRow_eq_zero [Zero α] [Nonempty ι] (v : n → α) :
replicateRow ι v = 0 ↔ v = 0 :=
replicateRow_inj
@[deprecated (since := "2025-03-20")] alias row_eq_zero := replicateRow_eq_zero
@[simp]
theorem replicateRow_add [Add α] (v w : m → α) :
replicateRow ι (v + w) = replicateRow ι v + replicateRow ι w := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias row_add := replicateRow_add
@[simp]
theorem replicateRow_smul [SMul R α] (x : R) (v : m → α) :
replicateRow ι (x • v) = x • replicateRow ι v := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias row_smul := replicateRow_smul
@[simp]
theorem transpose_replicateCol (v : m → α) : (replicateCol ι v)ᵀ = replicateRow ι v := by
ext
rfl
@[simp]
theorem transpose_replicateRow (v : m → α) : (replicateRow ι v)ᵀ = replicateCol ι v := by
ext
rfl
@[simp]
theorem conjTranspose_replicateCol [Star α] (v : m → α) :
(replicateCol ι v)ᴴ = replicateRow ι (star v) := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias conjTranspose_col := conjTranspose_replicateCol
@[simp]
theorem conjTranspose_replicateRow [Star α] (v : m → α) :
(replicateRow ι v)ᴴ = replicateCol ι (star v) := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias conjTranspose_row := conjTranspose_replicateRow
theorem replicateRow_vecMul [Fintype m] [NonUnitalNonAssocSemiring α] (M : Matrix m n α)
(v : m → α) : replicateRow ι (v ᵥ* M) = replicateRow ι v * M := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias row_vecMul := replicateRow_vecMul
theorem replicateCol_vecMul [Fintype m] [NonUnitalNonAssocSemiring α] (M : Matrix m n α)
(v : m → α) : replicateCol ι (v ᵥ* M) = (replicateRow ι v * M)ᵀ := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias col_vecMul := replicateCol_vecMul
theorem replicateCol_mulVec [Fintype n] [NonUnitalNonAssocSemiring α] (M : Matrix m n α)
(v : n → α) : replicateCol ι (M *ᵥ v) = M * replicateCol ι v := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias col_mulVec := replicateCol_mulVec
theorem replicateRow_mulVec [Fintype n] [NonUnitalNonAssocSemiring α] (M : Matrix m n α)
(v : n → α) : replicateRow ι (M *ᵥ v) = (M * replicateCol ι v)ᵀ := by
ext
rfl
@[deprecated (since := "2025-03-20")] alias row_mulVec := replicateRow_mulVec
theorem replicateRow_mulVec_eq_const [Fintype m] [NonUnitalNonAssocSemiring α] (v w : m → α) :
replicateRow ι v *ᵥ w = Function.const _ (v ⬝ᵥ w) := rfl
@[deprecated (since := "2025-03-20")] alias row_mulVec_eq_const := replicateRow_mulVec_eq_const
theorem mulVec_replicateCol_eq_const [Fintype m] [NonUnitalNonAssocSemiring α] (v w : m → α) :
v ᵥ* replicateCol ι w = Function.const _ (v ⬝ᵥ w) := rfl
@[deprecated (since := "2025-03-20")] alias mulVec_col_eq_const := mulVec_replicateCol_eq_const
theorem replicateRow_mul_replicateCol [Fintype m] [Mul α] [AddCommMonoid α] (v w : m → α) :
replicateRow ι v * replicateCol ι w = of fun _ _ => v ⬝ᵥ w :=
rfl
@[deprecated (since := "2025-03-20")] alias row_mul_col := replicateRow_mul_replicateCol
@[simp]
theorem replicateRow_mul_replicateCol_apply [Fintype m] [Mul α] [AddCommMonoid α] (v w : m → α)
(i j) : (replicateRow ι v * replicateCol ι w) i j = v ⬝ᵥ w :=
rfl
@[deprecated (since := "2025-03-20")] alias row_mul_col_apply := replicateRow_mul_replicateCol_apply
@[simp]
theorem diag_replicateCol_mul_replicateRow [Mul α] [AddCommMonoid α] [Unique ι] (a b : n → α) :
diag (replicateCol ι a * replicateRow ι b) = a * b := by
ext
simp [Matrix.mul_apply, replicateCol, replicateRow]
@[deprecated (since := "2025-03-20")] alias diag_col_mul_row := diag_replicateCol_mul_replicateRow
variable (ι)
theorem vecMulVec_eq [Mul α] [AddCommMonoid α] [Unique ι] (w : m → α) (v : n → α) :
vecMulVec w v = replicateCol ι w * replicateRow ι v := by
ext
simp [vecMulVec, mul_apply]
/-! ### Updating rows and columns -/
/-- Update, i.e. replace the `i`th row of matrix `A` with the values in `b`. -/
def updateRow [DecidableEq m] (M : Matrix m n α) (i : m) (b : n → α) : Matrix m n α :=
of <| Function.update M i b
/-- Update, i.e. replace the `j`th column of matrix `A` with the values in `b`. -/
def updateCol [DecidableEq n] (M : Matrix m n α) (j : n) (b : m → α) : Matrix m n α :=
of fun i => Function.update (M i) j (b i)
@[deprecated (since := "2024-12-11")] alias updateColumn := updateCol
variable {M : Matrix m n α} {i : m} {j : n} {b : n → α} {c : m → α}
@[simp]
theorem updateRow_self [DecidableEq m] : updateRow M i b i = b :=
Function.update_self (β := fun _ => (n → α)) i b M
@[simp]
theorem updateCol_self [DecidableEq n] : updateCol M j c i j = c i :=
Function.update_self (β := fun _ => α) j (c i) (M i)
@[deprecated (since := "2024-12-11")] alias updateColumn_self := updateCol_self
@[simp]
theorem updateRow_ne [DecidableEq m] {i' : m} (i_ne : i' ≠ i) : updateRow M i b i' = M i' :=
Function.update_of_ne (β := fun _ => (n → α)) i_ne b M
@[simp]
theorem updateCol_ne [DecidableEq n] {j' : n} (j_ne : j' ≠ j) :
updateCol M j c i j' = M i j' :=
Function.update_of_ne (β := fun _ => α) j_ne (c i) (M i)
@[deprecated (since := "2024-12-11")] alias updateColumn_ne := updateCol_ne
theorem updateRow_apply [DecidableEq m] {i' : m} :
updateRow M i b i' j = if i' = i then b j else M i' j := by
by_cases h : i' = i
· rw [h, updateRow_self, if_pos rfl]
· rw [updateRow_ne h, if_neg h]
theorem updateCol_apply [DecidableEq n] {j' : n} :
updateCol M j c i j' = if j' = j then c i else M i j' := by
by_cases h : j' = j
· rw [h, updateCol_self, if_pos rfl]
· rw [updateCol_ne h, if_neg h]
@[deprecated (since := "2024-12-11")] alias updateColumn_apply := updateCol_apply
@[simp]
theorem updateCol_subsingleton [Subsingleton n] (A : Matrix m n R) (i : n) (b : m → R) :
A.updateCol i b = (replicateCol (Fin 1) b).submatrix id (Function.const n 0) := by
ext x y
simp [updateCol_apply, Subsingleton.elim i y]
@[deprecated (since := "2024-12-11")] alias updateColumn_subsingleton := updateCol_subsingleton
@[simp]
theorem updateRow_subsingleton [Subsingleton m] (A : Matrix m n R) (i : m) (b : n → R) :
A.updateRow i b = (replicateRow (Fin 1) b).submatrix (Function.const m 0) id := by
ext x y
simp [updateCol_apply, Subsingleton.elim i x]
theorem map_updateRow [DecidableEq m] (f : α → β) :
map (updateRow M i b) f = updateRow (M.map f) i (f ∘ b) := by
ext
rw [updateRow_apply, map_apply, map_apply, updateRow_apply]
exact apply_ite f _ _ _
theorem map_updateCol [DecidableEq n] (f : α → β) :
map (updateCol M j c) f = updateCol (M.map f) j (f ∘ c) := by
ext
rw [updateCol_apply, map_apply, map_apply, updateCol_apply]
exact apply_ite f _ _ _
@[deprecated (since := "2024-12-11")] alias map_updateColumn := map_updateCol
theorem updateRow_transpose [DecidableEq n] : updateRow Mᵀ j c = (updateCol M j c)ᵀ := by
ext
rw [transpose_apply, updateRow_apply, updateCol_apply]
rfl
theorem updateCol_transpose [DecidableEq m] : updateCol Mᵀ i b = (updateRow M i b)ᵀ := by
ext
rw [transpose_apply, updateRow_apply, updateCol_apply]
rfl
@[deprecated (since := "2024-12-11")] alias updateColumn_transpose := updateCol_transpose
theorem updateRow_conjTranspose [DecidableEq n] [Star α] :
updateRow Mᴴ j (star c) = (updateCol M j c)ᴴ := by
rw [conjTranspose, conjTranspose, transpose_map, transpose_map, updateRow_transpose,
map_updateCol]
rfl
| Mathlib/Data/Matrix/RowCol.lean | 321 | 324 | theorem updateCol_conjTranspose [DecidableEq m] [Star α] :
updateCol Mᴴ i (star b) = (updateRow M i b)ᴴ := by | rw [conjTranspose, conjTranspose, transpose_map, transpose_map, updateCol_transpose,
map_updateRow] |
/-
Copyright (c) 2024 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne
-/
import Mathlib.LinearAlgebra.FreeModule.Basic
import Mathlib.MeasureTheory.Measure.Decomposition.Exhaustion
import Mathlib.Probability.ConditionalProbability
/-!
# s-finite measures can be written as `withDensity` of a finite measure
If `μ` is an s-finite measure, then there exists a finite measure `μ.toFinite`
such that a set is `μ`-null iff it is `μ.toFinite`-null.
In particular, `MeasureTheory.ae μ.toFinite = MeasureTheory.ae μ` and `μ.toFinite = 0` iff `μ = 0`.
As a corollary, `μ` can be represented as `μ.toFinite.withDensity (μ.rnDeriv μ.toFinite)`.
Our definition of `MeasureTheory.Measure.toFinite` ensures some extra properties:
- if `μ` is a finite measure, then `μ.toFinite = μ[|univ] = (μ univ)⁻¹ • μ`;
- in particular, `μ.toFinite = μ` for a probability measure;
- if `μ ≠ 0`, then `μ.toFinite` is a probability measure.
## Main definitions
In these definitions and the results below, `μ` is an s-finite measure (`SFinite μ`).
* `MeasureTheory.Measure.toFinite`: a finite measure with `μ ≪ μ.toFinite` and `μ.toFinite ≪ μ`.
If `μ ≠ 0`, this is a probability measure.
* `MeasureTheory.Measure.densityToFinite` (deprecated, use `MeasureTheory.Measure.rnDeriv`):
the Radon-Nikodym derivative of `μ.toFinite` with respect to `μ`.
## Main statements
* `absolutelyContinuous_toFinite`: `μ ≪ μ.toFinite`.
* `toFinite_absolutelyContinuous`: `μ.toFinite ≪ μ`.
* `ae_toFinite`: `ae μ.toFinite = ae μ`.
-/
open Set
open scoped ENNReal ProbabilityTheory
namespace MeasureTheory
variable {α : Type*} {mα : MeasurableSpace α} {μ : Measure α}
/-- Auxiliary definition for `MeasureTheory.Measure.toFinite`. -/
noncomputable def Measure.toFiniteAux (μ : Measure α) [SFinite μ] : Measure α :=
letI := Classical.dec
if IsFiniteMeasure μ then μ else (exists_isFiniteMeasure_absolutelyContinuous μ).choose
/-- A finite measure obtained from an s-finite measure `μ`, such that
`μ = μ.toFinite.withDensity μ.densityToFinite` (see `withDensity_densitytoFinite`).
If `μ` is non-zero, this is a probability measure. -/
noncomputable def Measure.toFinite (μ : Measure α) [SFinite μ] : Measure α :=
μ.toFiniteAux[|univ]
@[local simp]
lemma ae_toFiniteAux [SFinite μ] : ae μ.toFiniteAux = ae μ := by
rw [Measure.toFiniteAux]
split_ifs
· simp
· obtain ⟨_, h₁, h₂⟩ := (exists_isFiniteMeasure_absolutelyContinuous μ).choose_spec
exact h₂.ae_le.antisymm h₁.ae_le
@[local instance]
| Mathlib/MeasureTheory/Measure/WithDensityFinite.lean | 68 | 70 | theorem isFiniteMeasure_toFiniteAux [SFinite μ] : IsFiniteMeasure μ.toFiniteAux := by | rw [Measure.toFiniteAux]
split_ifs |
/-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.JapaneseBracket
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Integral.IntegralEqImproper
import Mathlib.MeasureTheory.Measure.Lebesgue.Integral
/-!
# Evaluation of specific improper integrals
This file contains some integrability results, and evaluations of integrals, over `ℝ` or over
half-infinite intervals in `ℝ`.
These lemmas are stated in terms of either `Iic` or `Ioi` (neglecting `Iio` and `Ici`) to match
mathlib's conventions for integrals over finite intervals (see `intervalIntegral`).
## See also
- `Mathlib.Analysis.SpecialFunctions.Integrals` -- integrals over finite intervals
- `Mathlib.Analysis.SpecialFunctions.Gaussian` -- integral of `exp (-x ^ 2)`
- `Mathlib.Analysis.SpecialFunctions.JapaneseBracket`-- integrability of `(1+‖x‖)^(-r)`.
-/
open Real Set Filter MeasureTheory intervalIntegral
open scoped Topology
theorem integrableOn_exp_Iic (c : ℝ) : IntegrableOn exp (Iic c) := by
refine
integrableOn_Iic_of_intervalIntegral_norm_bounded (exp c) c
(fun y => intervalIntegrable_exp.1) tendsto_id
(eventually_of_mem (Iic_mem_atBot 0) fun y _ => ?_)
simp_rw [norm_of_nonneg (exp_pos _).le, integral_exp, sub_le_self_iff]
exact (exp_pos _).le
theorem integrableOn_exp_neg_Ioi (c : ℝ) : IntegrableOn (fun (x : ℝ) => exp (-x)) (Ioi c) :=
integrableOn_Ici_iff_integrableOn_Ioi.mp (integrableOn_exp_Iic (-c)).comp_neg_Ici
theorem integral_exp_Iic (c : ℝ) : ∫ x : ℝ in Iic c, exp x = exp c := by
refine
tendsto_nhds_unique
(intervalIntegral_tendsto_integral_Iic _ (integrableOn_exp_Iic _) tendsto_id) ?_
simp_rw [integral_exp, show 𝓝 (exp c) = 𝓝 (exp c - 0) by rw [sub_zero]]
exact tendsto_exp_atBot.const_sub _
theorem integral_exp_Iic_zero : ∫ x : ℝ in Iic 0, exp x = 1 :=
exp_zero ▸ integral_exp_Iic 0
theorem integral_exp_neg_Ioi (c : ℝ) : (∫ x : ℝ in Ioi c, exp (-x)) = exp (-c) := by
simpa only [integral_comp_neg_Ioi] using integral_exp_Iic (-c)
| Mathlib/Analysis/SpecialFunctions/ImproperIntegrals.lean | 57 | 58 | theorem integral_exp_neg_Ioi_zero : (∫ x : ℝ in Ioi 0, exp (-x)) = 1 := by | simpa only [neg_zero, exp_zero] using integral_exp_neg_Ioi 0 |
/-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Module.Basic
import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv
/-!
# Midpoint of a segment
## Main definitions
* `midpoint R x y`: midpoint of the segment `[x, y]`. We define it for `x` and `y`
in a module over a ring `R` with invertible `2`.
* `AddMonoidHom.ofMapMidpoint`: construct an `AddMonoidHom` given a map `f` such that
`f` sends zero to zero and midpoints to midpoints.
## Main theorems
* `midpoint_eq_iff`: `z` is the midpoint of `[x, y]` if and only if `x + y = z + z`,
* `midpoint_unique`: `midpoint R x y` does not depend on `R`;
* `midpoint x y` is linear both in `x` and `y`;
* `pointReflection_midpoint_left`, `pointReflection_midpoint_right`:
`Equiv.pointReflection (midpoint R x y)` swaps `x` and `y`.
We do not mark most lemmas as `@[simp]` because it is hard to tell which side is simpler.
## Tags
midpoint, AddMonoidHom
-/
open AffineMap AffineEquiv
section
variable (R : Type*) {V V' P P' : Type*} [Ring R] [Invertible (2 : R)] [AddCommGroup V]
[Module R V] [AddTorsor V P] [AddCommGroup V'] [Module R V'] [AddTorsor V' P']
/-- `midpoint x y` is the midpoint of the segment `[x, y]`. -/
def midpoint (x y : P) : P :=
lineMap x y (⅟ 2 : R)
variable {R} {x y z : P}
@[simp]
theorem AffineMap.map_midpoint (f : P →ᵃ[R] P') (a b : P) :
f (midpoint R a b) = midpoint R (f a) (f b) :=
f.apply_lineMap a b _
@[simp]
theorem AffineEquiv.map_midpoint (f : P ≃ᵃ[R] P') (a b : P) :
f (midpoint R a b) = midpoint R (f a) (f b) :=
f.apply_lineMap a b _
theorem AffineEquiv.pointReflection_midpoint_left (x y : P) :
pointReflection R (midpoint R x y) x = y := by
rw [midpoint, pointReflection_apply, lineMap_apply, vadd_vsub, vadd_vadd, ← add_smul, ← two_mul,
mul_invOf_self, one_smul, vsub_vadd]
@[simp]
theorem Equiv.pointReflection_midpoint_left (x y : P) :
(Equiv.pointReflection (midpoint R x y)) x = y := by
rw [midpoint, pointReflection_apply, lineMap_apply, vadd_vsub, vadd_vadd, ← add_smul, ← two_mul,
mul_invOf_self, one_smul, vsub_vadd]
| Mathlib/LinearAlgebra/AffineSpace/Midpoint.lean | 68 | 71 | theorem midpoint_comm (x y : P) : midpoint R x y = midpoint R y x := by | rw [midpoint, ← lineMap_apply_one_sub, one_sub_invOf_two, midpoint]
theorem AffineEquiv.pointReflection_midpoint_right (x y : P) : |
/-
Copyright (c) 2022 Alexander Bentkamp. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alexander Bentkamp
-/
import Mathlib.Analysis.InnerProductSpace.Spectrum
import Mathlib.Data.Matrix.Rank
import Mathlib.LinearAlgebra.Matrix.Diagonal
import Mathlib.LinearAlgebra.Matrix.Hermitian
import Mathlib.Topology.Algebra.Module.FiniteDimension
/-! # Spectral theory of hermitian matrices
This file proves the spectral theorem for matrices. The proof of the spectral theorem is based on
the spectral theorem for linear maps (`LinearMap.IsSymmetric.eigenvectorBasis_apply_self_apply`).
## Tags
spectral theorem, diagonalization theorem -/
namespace Matrix
variable {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
variable {A : Matrix n n 𝕜}
namespace IsHermitian
section DecidableEq
variable [DecidableEq n]
variable (hA : A.IsHermitian)
/-- The eigenvalues of a hermitian matrix, indexed by `Fin (Fintype.card n)` where `n` is the index
type of the matrix. -/
noncomputable def eigenvalues₀ : Fin (Fintype.card n) → ℝ :=
(isHermitian_iff_isSymmetric.1 hA).eigenvalues finrank_euclideanSpace
/-- The eigenvalues of a hermitian matrix, reusing the index `n` of the matrix entries. -/
noncomputable def eigenvalues : n → ℝ := fun i =>
hA.eigenvalues₀ <| (Fintype.equivOfCardEq (Fintype.card_fin _)).symm i
/-- A choice of an orthonormal basis of eigenvectors of a hermitian matrix. -/
noncomputable def eigenvectorBasis : OrthonormalBasis n 𝕜 (EuclideanSpace 𝕜 n) :=
((isHermitian_iff_isSymmetric.1 hA).eigenvectorBasis finrank_euclideanSpace).reindex
(Fintype.equivOfCardEq (Fintype.card_fin _))
lemma mulVec_eigenvectorBasis (j : n) :
A *ᵥ ⇑(hA.eigenvectorBasis j) = (hA.eigenvalues j) • ⇑(hA.eigenvectorBasis j) := by
simpa only [eigenvectorBasis, OrthonormalBasis.reindex_apply, toEuclideanLin_apply,
RCLike.real_smul_eq_coe_smul (K := 𝕜)] using
congr(⇑$((isHermitian_iff_isSymmetric.1 hA).apply_eigenvectorBasis
finrank_euclideanSpace ((Fintype.equivOfCardEq (Fintype.card_fin _)).symm j)))
/-- The spectrum of a Hermitian matrix `A` coincides with the spectrum of `toEuclideanLin A`. -/
theorem spectrum_toEuclideanLin : spectrum 𝕜 (toEuclideanLin A) = spectrum 𝕜 A :=
AlgEquiv.spectrum_eq (Matrix.toLinAlgEquiv (PiLp.basisFun 2 𝕜 n)) _
/-- Eigenvalues of a hermitian matrix A are in the ℝ spectrum of A. -/
theorem eigenvalues_mem_spectrum_real (i : n) : hA.eigenvalues i ∈ spectrum ℝ A := by
apply spectrum.of_algebraMap_mem 𝕜
rw [← spectrum_toEuclideanLin]
exact LinearMap.IsSymmetric.hasEigenvalue_eigenvalues _ _ _ |>.mem_spectrum
/-- Unitary matrix whose columns are `Matrix.IsHermitian.eigenvectorBasis`. -/
noncomputable def eigenvectorUnitary {𝕜 : Type*} [RCLike 𝕜] {n : Type*}
[Fintype n] {A : Matrix n n 𝕜} [DecidableEq n] (hA : Matrix.IsHermitian A) :
Matrix.unitaryGroup n 𝕜 :=
⟨(EuclideanSpace.basisFun n 𝕜).toBasis.toMatrix (hA.eigenvectorBasis).toBasis,
(EuclideanSpace.basisFun n 𝕜).toMatrix_orthonormalBasis_mem_unitary (eigenvectorBasis hA)⟩
lemma eigenvectorUnitary_coe {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
{A : Matrix n n 𝕜} [DecidableEq n] (hA : Matrix.IsHermitian A) :
eigenvectorUnitary hA =
(EuclideanSpace.basisFun n 𝕜).toBasis.toMatrix (hA.eigenvectorBasis).toBasis :=
rfl
@[simp]
theorem eigenvectorUnitary_transpose_apply (j : n) :
(eigenvectorUnitary hA)ᵀ j = ⇑(hA.eigenvectorBasis j) :=
rfl
@[simp]
theorem eigenvectorUnitary_apply (i j : n) :
eigenvectorUnitary hA i j = ⇑(hA.eigenvectorBasis j) i :=
rfl
theorem eigenvectorUnitary_mulVec (j : n) :
eigenvectorUnitary hA *ᵥ Pi.single j 1 = ⇑(hA.eigenvectorBasis j) := by
simp_rw [mulVec_single_one, eigenvectorUnitary_transpose_apply]
theorem star_eigenvectorUnitary_mulVec (j : n) :
(star (eigenvectorUnitary hA : Matrix n n 𝕜)) *ᵥ ⇑(hA.eigenvectorBasis j) = Pi.single j 1 := by
rw [← eigenvectorUnitary_mulVec, mulVec_mulVec, unitary.coe_star_mul_self, one_mulVec]
/-- Unitary diagonalization of a Hermitian matrix. -/
theorem star_mul_self_mul_eq_diagonal :
(star (eigenvectorUnitary hA : Matrix n n 𝕜)) * A * (eigenvectorUnitary hA : Matrix n n 𝕜)
= diagonal (RCLike.ofReal ∘ hA.eigenvalues) := by
apply Matrix.toEuclideanLin.injective
apply Basis.ext (EuclideanSpace.basisFun n 𝕜).toBasis
intro i
simp only [toEuclideanLin_apply, OrthonormalBasis.coe_toBasis, EuclideanSpace.basisFun_apply,
WithLp.equiv_single, ← mulVec_mulVec, eigenvectorUnitary_mulVec, ← mulVec_mulVec,
mulVec_eigenvectorBasis, Matrix.diagonal_mulVec_single, mulVec_smul,
star_eigenvectorUnitary_mulVec, RCLike.real_smul_eq_coe_smul (K := 𝕜), WithLp.equiv_symm_smul,
WithLp.equiv_symm_single, Function.comp_apply, mul_one, WithLp.equiv_symm_single]
apply PiLp.ext
intro j
simp only [PiLp.smul_apply, EuclideanSpace.single_apply, smul_eq_mul, mul_ite, mul_one, mul_zero]
/-- **Diagonalization theorem**, **spectral theorem** for matrices; A hermitian matrix can be
diagonalized by a change of basis. For the spectral theorem on linear maps, see
`LinearMap.IsSymmetric.eigenvectorBasis_apply_self_apply`. -/
theorem spectral_theorem :
A = (eigenvectorUnitary hA : Matrix n n 𝕜) * diagonal (RCLike.ofReal ∘ hA.eigenvalues)
* (star (eigenvectorUnitary hA : Matrix n n 𝕜)) := by
rw [← star_mul_self_mul_eq_diagonal, mul_assoc, mul_assoc,
(Matrix.mem_unitaryGroup_iff).mp (eigenvectorUnitary hA).2, mul_one,
← mul_assoc, (Matrix.mem_unitaryGroup_iff).mp (eigenvectorUnitary hA).2, one_mul]
theorem eigenvalues_eq (i : n) :
(hA.eigenvalues i) = RCLike.re (dotProduct (star ⇑(hA.eigenvectorBasis i))
(A *ᵥ ⇑(hA.eigenvectorBasis i))) := by
rw [dotProduct_comm]
simp only [mulVec_eigenvectorBasis, smul_dotProduct, ← EuclideanSpace.inner_eq_star_dotProduct,
inner_self_eq_norm_sq_to_K, RCLike.smul_re, hA.eigenvectorBasis.orthonormal.1 i,
mul_one, algebraMap.coe_one, one_pow, RCLike.one_re]
/-- The determinant of a hermitian matrix is the product of its eigenvalues. -/
| Mathlib/LinearAlgebra/Matrix/Spectrum.lean | 131 | 136 | theorem det_eq_prod_eigenvalues : det A = ∏ i, (hA.eigenvalues i : 𝕜) := by | convert congr_arg det hA.spectral_theorem
rw [det_mul_right_comm]
simp
/-- rank of a hermitian matrix is the rank of after diagonalization by the eigenvector unitary -/ |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot, Yury Kudryashov, Rémy Degenne
-/
import Mathlib.Data.Set.Subsingleton
import Mathlib.Order.Interval.Set.Defs
/-!
# Intervals
In any preorder, we define intervals (which on each side can be either infinite, open or closed)
using the following naming conventions:
- `i`: infinite
- `o`: open
- `c`: closed
Each interval has the name `I` + letter for left side + letter for right side.
For instance, `Ioc a b` denotes the interval `(a, b]`.
The definitions can be found in `Mathlib.Order.Interval.Set.Defs`.
This file contains basic facts on inclusion of and set operations on intervals
(where the precise statements depend on the order's properties;
statements requiring `LinearOrder` are in `Mathlib.Order.Interval.Set.LinearOrder`).
TODO: This is just the beginning; a lot of rules are missing
-/
assert_not_exists RelIso
open Function
open OrderDual (toDual ofDual)
variable {α : Type*}
namespace Set
section Preorder
variable [Preorder α] {a a₁ a₂ b b₁ b₂ c x : α}
instance decidableMemIoo [Decidable (a < x ∧ x < b)] : Decidable (x ∈ Ioo a b) := by assumption
instance decidableMemIco [Decidable (a ≤ x ∧ x < b)] : Decidable (x ∈ Ico a b) := by assumption
instance decidableMemIio [Decidable (x < b)] : Decidable (x ∈ Iio b) := by assumption
instance decidableMemIcc [Decidable (a ≤ x ∧ x ≤ b)] : Decidable (x ∈ Icc a b) := by assumption
instance decidableMemIic [Decidable (x ≤ b)] : Decidable (x ∈ Iic b) := by assumption
instance decidableMemIoc [Decidable (a < x ∧ x ≤ b)] : Decidable (x ∈ Ioc a b) := by assumption
instance decidableMemIci [Decidable (a ≤ x)] : Decidable (x ∈ Ici a) := by assumption
instance decidableMemIoi [Decidable (a < x)] : Decidable (x ∈ Ioi a) := by assumption
theorem left_mem_Ioo : a ∈ Ioo a b ↔ False := by simp [lt_irrefl]
theorem left_mem_Ico : a ∈ Ico a b ↔ a < b := by simp [le_refl]
theorem left_mem_Icc : a ∈ Icc a b ↔ a ≤ b := by simp [le_refl]
theorem left_mem_Ioc : a ∈ Ioc a b ↔ False := by simp [lt_irrefl]
theorem left_mem_Ici : a ∈ Ici a := by simp
theorem right_mem_Ioo : b ∈ Ioo a b ↔ False := by simp [lt_irrefl]
theorem right_mem_Ico : b ∈ Ico a b ↔ False := by simp [lt_irrefl]
theorem right_mem_Icc : b ∈ Icc a b ↔ a ≤ b := by simp [le_refl]
theorem right_mem_Ioc : b ∈ Ioc a b ↔ a < b := by simp [le_refl]
theorem right_mem_Iic : a ∈ Iic a := by simp
@[simp]
theorem Ici_toDual : Ici (toDual a) = ofDual ⁻¹' Iic a :=
rfl
@[deprecated (since := "2025-03-20")]
alias dual_Ici := Ici_toDual
@[simp]
theorem Iic_toDual : Iic (toDual a) = ofDual ⁻¹' Ici a :=
rfl
@[deprecated (since := "2025-03-20")]
alias dual_Iic := Iic_toDual
@[simp]
theorem Ioi_toDual : Ioi (toDual a) = ofDual ⁻¹' Iio a :=
rfl
@[deprecated (since := "2025-03-20")]
alias dual_Ioi := Ioi_toDual
@[simp]
theorem Iio_toDual : Iio (toDual a) = ofDual ⁻¹' Ioi a :=
rfl
@[deprecated (since := "2025-03-20")]
alias dual_Iio := Iio_toDual
@[simp]
theorem Icc_toDual : Icc (toDual a) (toDual b) = ofDual ⁻¹' Icc b a :=
Set.ext fun _ => and_comm
@[deprecated (since := "2025-03-20")]
alias dual_Icc := Icc_toDual
@[simp]
theorem Ioc_toDual : Ioc (toDual a) (toDual b) = ofDual ⁻¹' Ico b a :=
Set.ext fun _ => and_comm
@[deprecated (since := "2025-03-20")]
alias dual_Ioc := Ioc_toDual
@[simp]
theorem Ico_toDual : Ico (toDual a) (toDual b) = ofDual ⁻¹' Ioc b a :=
Set.ext fun _ => and_comm
@[deprecated (since := "2025-03-20")]
alias dual_Ico := Ico_toDual
@[simp]
theorem Ioo_toDual : Ioo (toDual a) (toDual b) = ofDual ⁻¹' Ioo b a :=
Set.ext fun _ => and_comm
@[deprecated (since := "2025-03-20")]
alias dual_Ioo := Ioo_toDual
@[simp]
theorem Ici_ofDual {x : αᵒᵈ} : Ici (ofDual x) = toDual ⁻¹' Iic x :=
rfl
@[simp]
theorem Iic_ofDual {x : αᵒᵈ} : Iic (ofDual x) = toDual ⁻¹' Ici x :=
rfl
@[simp]
theorem Ioi_ofDual {x : αᵒᵈ} : Ioi (ofDual x) = toDual ⁻¹' Iio x :=
rfl
@[simp]
theorem Iio_ofDual {x : αᵒᵈ} : Iio (ofDual x) = toDual ⁻¹' Ioi x :=
rfl
@[simp]
theorem Icc_ofDual {x y : αᵒᵈ} : Icc (ofDual y) (ofDual x) = toDual ⁻¹' Icc x y :=
Set.ext fun _ => and_comm
@[simp]
theorem Ico_ofDual {x y : αᵒᵈ} : Ico (ofDual y) (ofDual x) = toDual ⁻¹' Ioc x y :=
Set.ext fun _ => and_comm
@[simp]
theorem Ioc_ofDual {x y : αᵒᵈ} : Ioc (ofDual y) (ofDual x) = toDual ⁻¹' Ico x y :=
Set.ext fun _ => and_comm
@[simp]
theorem Ioo_ofDual {x y : αᵒᵈ} : Ioo (ofDual y) (ofDual x) = toDual ⁻¹' Ioo x y :=
Set.ext fun _ => and_comm
@[simp]
theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b :=
⟨fun ⟨_, hx⟩ => hx.1.trans hx.2, fun h => ⟨a, left_mem_Icc.2 h⟩⟩
@[simp]
theorem nonempty_Ico : (Ico a b).Nonempty ↔ a < b :=
⟨fun ⟨_, hx⟩ => hx.1.trans_lt hx.2, fun h => ⟨a, left_mem_Ico.2 h⟩⟩
@[simp]
theorem nonempty_Ioc : (Ioc a b).Nonempty ↔ a < b :=
⟨fun ⟨_, hx⟩ => hx.1.trans_le hx.2, fun h => ⟨b, right_mem_Ioc.2 h⟩⟩
@[simp]
theorem nonempty_Ici : (Ici a).Nonempty :=
⟨a, left_mem_Ici⟩
@[simp]
theorem nonempty_Iic : (Iic a).Nonempty :=
⟨a, right_mem_Iic⟩
@[simp]
theorem nonempty_Ioo [DenselyOrdered α] : (Ioo a b).Nonempty ↔ a < b :=
⟨fun ⟨_, ha, hb⟩ => ha.trans hb, exists_between⟩
@[simp]
theorem nonempty_Ioi [NoMaxOrder α] : (Ioi a).Nonempty :=
exists_gt a
@[simp]
theorem nonempty_Iio [NoMinOrder α] : (Iio a).Nonempty :=
exists_lt a
theorem nonempty_Icc_subtype (h : a ≤ b) : Nonempty (Icc a b) :=
Nonempty.to_subtype (nonempty_Icc.mpr h)
theorem nonempty_Ico_subtype (h : a < b) : Nonempty (Ico a b) :=
Nonempty.to_subtype (nonempty_Ico.mpr h)
theorem nonempty_Ioc_subtype (h : a < b) : Nonempty (Ioc a b) :=
Nonempty.to_subtype (nonempty_Ioc.mpr h)
/-- An interval `Ici a` is nonempty. -/
instance nonempty_Ici_subtype : Nonempty (Ici a) :=
Nonempty.to_subtype nonempty_Ici
/-- An interval `Iic a` is nonempty. -/
instance nonempty_Iic_subtype : Nonempty (Iic a) :=
Nonempty.to_subtype nonempty_Iic
theorem nonempty_Ioo_subtype [DenselyOrdered α] (h : a < b) : Nonempty (Ioo a b) :=
Nonempty.to_subtype (nonempty_Ioo.mpr h)
/-- In an order without maximal elements, the intervals `Ioi` are nonempty. -/
instance nonempty_Ioi_subtype [NoMaxOrder α] : Nonempty (Ioi a) :=
Nonempty.to_subtype nonempty_Ioi
/-- In an order without minimal elements, the intervals `Iio` are nonempty. -/
instance nonempty_Iio_subtype [NoMinOrder α] : Nonempty (Iio a) :=
Nonempty.to_subtype nonempty_Iio
instance [NoMinOrder α] : NoMinOrder (Iio a) :=
⟨fun a =>
let ⟨b, hb⟩ := exists_lt (a : α)
⟨⟨b, lt_trans hb a.2⟩, hb⟩⟩
instance [NoMinOrder α] : NoMinOrder (Iic a) :=
⟨fun a =>
let ⟨b, hb⟩ := exists_lt (a : α)
⟨⟨b, hb.le.trans a.2⟩, hb⟩⟩
instance [NoMaxOrder α] : NoMaxOrder (Ioi a) :=
OrderDual.noMaxOrder (α := Iio (toDual a))
instance [NoMaxOrder α] : NoMaxOrder (Ici a) :=
OrderDual.noMaxOrder (α := Iic (toDual a))
@[simp]
theorem Icc_eq_empty (h : ¬a ≤ b) : Icc a b = ∅ :=
eq_empty_iff_forall_not_mem.2 fun _ ⟨ha, hb⟩ => h (ha.trans hb)
@[simp]
theorem Ico_eq_empty (h : ¬a < b) : Ico a b = ∅ :=
eq_empty_iff_forall_not_mem.2 fun _ ⟨ha, hb⟩ => h (ha.trans_lt hb)
@[simp]
theorem Ioc_eq_empty (h : ¬a < b) : Ioc a b = ∅ :=
eq_empty_iff_forall_not_mem.2 fun _ ⟨ha, hb⟩ => h (ha.trans_le hb)
@[simp]
theorem Ioo_eq_empty (h : ¬a < b) : Ioo a b = ∅ :=
eq_empty_iff_forall_not_mem.2 fun _ ⟨ha, hb⟩ => h (ha.trans hb)
@[simp]
theorem Icc_eq_empty_of_lt (h : b < a) : Icc a b = ∅ :=
Icc_eq_empty h.not_le
@[simp]
theorem Ico_eq_empty_of_le (h : b ≤ a) : Ico a b = ∅ :=
Ico_eq_empty h.not_lt
@[simp]
theorem Ioc_eq_empty_of_le (h : b ≤ a) : Ioc a b = ∅ :=
Ioc_eq_empty h.not_lt
@[simp]
theorem Ioo_eq_empty_of_le (h : b ≤ a) : Ioo a b = ∅ :=
Ioo_eq_empty h.not_lt
theorem Ico_self (a : α) : Ico a a = ∅ :=
Ico_eq_empty <| lt_irrefl _
theorem Ioc_self (a : α) : Ioc a a = ∅ :=
Ioc_eq_empty <| lt_irrefl _
theorem Ioo_self (a : α) : Ioo a a = ∅ :=
Ioo_eq_empty <| lt_irrefl _
@[simp]
theorem Ici_subset_Ici : Ici a ⊆ Ici b ↔ b ≤ a :=
⟨fun h => h <| left_mem_Ici, fun h _ hx => h.trans hx⟩
@[gcongr] alias ⟨_, _root_.GCongr.Ici_subset_Ici_of_le⟩ := Ici_subset_Ici
@[simp]
theorem Ici_ssubset_Ici : Ici a ⊂ Ici b ↔ b < a where
mp h := by
obtain ⟨ab, c, cb, ac⟩ := ssubset_iff_exists.mp h
exact lt_of_le_not_le (Ici_subset_Ici.mp ab) (fun h' ↦ ac (h'.trans cb))
mpr h := (ssubset_iff_of_subset (Ici_subset_Ici.mpr h.le)).mpr
⟨b, right_mem_Iic, fun h' => h.not_le h'⟩
@[gcongr] alias ⟨_, _root_.GCongr.Ici_ssubset_Ici_of_le⟩ := Ici_ssubset_Ici
@[simp]
theorem Iic_subset_Iic : Iic a ⊆ Iic b ↔ a ≤ b :=
@Ici_subset_Ici αᵒᵈ _ _ _
@[gcongr] alias ⟨_, _root_.GCongr.Iic_subset_Iic_of_le⟩ := Iic_subset_Iic
@[simp]
theorem Iic_ssubset_Iic : Iic a ⊂ Iic b ↔ a < b :=
@Ici_ssubset_Ici αᵒᵈ _ _ _
@[gcongr] alias ⟨_, _root_.GCongr.Iic_ssubset_Iic_of_le⟩ := Iic_ssubset_Iic
@[simp]
theorem Ici_subset_Ioi : Ici a ⊆ Ioi b ↔ b < a :=
⟨fun h => h left_mem_Ici, fun h _ hx => h.trans_le hx⟩
@[simp]
theorem Iic_subset_Iio : Iic a ⊆ Iio b ↔ a < b :=
⟨fun h => h right_mem_Iic, fun h _ hx => lt_of_le_of_lt hx h⟩
@[gcongr]
theorem Ioo_subset_Ioo (h₁ : a₂ ≤ a₁) (h₂ : b₁ ≤ b₂) : Ioo a₁ b₁ ⊆ Ioo a₂ b₂ := fun _ ⟨hx₁, hx₂⟩ =>
⟨h₁.trans_lt hx₁, hx₂.trans_le h₂⟩
@[gcongr]
theorem Ioo_subset_Ioo_left (h : a₁ ≤ a₂) : Ioo a₂ b ⊆ Ioo a₁ b :=
Ioo_subset_Ioo h le_rfl
@[gcongr]
theorem Ioo_subset_Ioo_right (h : b₁ ≤ b₂) : Ioo a b₁ ⊆ Ioo a b₂ :=
Ioo_subset_Ioo le_rfl h
@[gcongr]
theorem Ico_subset_Ico (h₁ : a₂ ≤ a₁) (h₂ : b₁ ≤ b₂) : Ico a₁ b₁ ⊆ Ico a₂ b₂ := fun _ ⟨hx₁, hx₂⟩ =>
⟨h₁.trans hx₁, hx₂.trans_le h₂⟩
@[gcongr]
theorem Ico_subset_Ico_left (h : a₁ ≤ a₂) : Ico a₂ b ⊆ Ico a₁ b :=
Ico_subset_Ico h le_rfl
@[gcongr]
theorem Ico_subset_Ico_right (h : b₁ ≤ b₂) : Ico a b₁ ⊆ Ico a b₂ :=
Ico_subset_Ico le_rfl h
@[gcongr]
theorem Icc_subset_Icc (h₁ : a₂ ≤ a₁) (h₂ : b₁ ≤ b₂) : Icc a₁ b₁ ⊆ Icc a₂ b₂ := fun _ ⟨hx₁, hx₂⟩ =>
⟨h₁.trans hx₁, le_trans hx₂ h₂⟩
@[gcongr]
theorem Icc_subset_Icc_left (h : a₁ ≤ a₂) : Icc a₂ b ⊆ Icc a₁ b :=
Icc_subset_Icc h le_rfl
@[gcongr]
theorem Icc_subset_Icc_right (h : b₁ ≤ b₂) : Icc a b₁ ⊆ Icc a b₂ :=
Icc_subset_Icc le_rfl h
theorem Icc_subset_Ioo (ha : a₂ < a₁) (hb : b₁ < b₂) : Icc a₁ b₁ ⊆ Ioo a₂ b₂ := fun _ hx =>
⟨ha.trans_le hx.1, hx.2.trans_lt hb⟩
theorem Icc_subset_Ici_self : Icc a b ⊆ Ici a := fun _ => And.left
theorem Icc_subset_Iic_self : Icc a b ⊆ Iic b := fun _ => And.right
theorem Ioc_subset_Iic_self : Ioc a b ⊆ Iic b := fun _ => And.right
@[gcongr]
theorem Ioc_subset_Ioc (h₁ : a₂ ≤ a₁) (h₂ : b₁ ≤ b₂) : Ioc a₁ b₁ ⊆ Ioc a₂ b₂ := fun _ ⟨hx₁, hx₂⟩ =>
⟨h₁.trans_lt hx₁, hx₂.trans h₂⟩
@[gcongr]
theorem Ioc_subset_Ioc_left (h : a₁ ≤ a₂) : Ioc a₂ b ⊆ Ioc a₁ b :=
Ioc_subset_Ioc h le_rfl
@[gcongr]
theorem Ioc_subset_Ioc_right (h : b₁ ≤ b₂) : Ioc a b₁ ⊆ Ioc a b₂ :=
Ioc_subset_Ioc le_rfl h
theorem Ico_subset_Ioo_left (h₁ : a₁ < a₂) : Ico a₂ b ⊆ Ioo a₁ b := fun _ =>
And.imp_left h₁.trans_le
theorem Ioc_subset_Ioo_right (h : b₁ < b₂) : Ioc a b₁ ⊆ Ioo a b₂ := fun _ =>
And.imp_right fun h' => h'.trans_lt h
theorem Icc_subset_Ico_right (h₁ : b₁ < b₂) : Icc a b₁ ⊆ Ico a b₂ := fun _ =>
And.imp_right fun h₂ => h₂.trans_lt h₁
theorem Ioo_subset_Ico_self : Ioo a b ⊆ Ico a b := fun _ => And.imp_left le_of_lt
theorem Ioo_subset_Ioc_self : Ioo a b ⊆ Ioc a b := fun _ => And.imp_right le_of_lt
theorem Ico_subset_Icc_self : Ico a b ⊆ Icc a b := fun _ => And.imp_right le_of_lt
theorem Ioc_subset_Icc_self : Ioc a b ⊆ Icc a b := fun _ => And.imp_left le_of_lt
theorem Ioo_subset_Icc_self : Ioo a b ⊆ Icc a b :=
Subset.trans Ioo_subset_Ico_self Ico_subset_Icc_self
theorem Ico_subset_Iio_self : Ico a b ⊆ Iio b := fun _ => And.right
theorem Ioo_subset_Iio_self : Ioo a b ⊆ Iio b := fun _ => And.right
theorem Ioc_subset_Ioi_self : Ioc a b ⊆ Ioi a := fun _ => And.left
theorem Ioo_subset_Ioi_self : Ioo a b ⊆ Ioi a := fun _ => And.left
theorem Ioi_subset_Ici_self : Ioi a ⊆ Ici a := fun _ hx => le_of_lt hx
theorem Iio_subset_Iic_self : Iio a ⊆ Iic a := fun _ hx => le_of_lt hx
theorem Ico_subset_Ici_self : Ico a b ⊆ Ici a := fun _ => And.left
theorem Ioi_ssubset_Ici_self : Ioi a ⊂ Ici a :=
⟨Ioi_subset_Ici_self, fun h => lt_irrefl a (h le_rfl)⟩
theorem Iio_ssubset_Iic_self : Iio a ⊂ Iic a :=
@Ioi_ssubset_Ici_self αᵒᵈ _ _
theorem Icc_subset_Icc_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Icc a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ ≤ b₂ :=
⟨fun h => ⟨(h ⟨le_rfl, h₁⟩).1, (h ⟨h₁, le_rfl⟩).2⟩, fun ⟨h, h'⟩ _ ⟨hx, hx'⟩ =>
⟨h.trans hx, hx'.trans h'⟩⟩
theorem Icc_subset_Ioo_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ioo a₂ b₂ ↔ a₂ < a₁ ∧ b₁ < b₂ :=
⟨fun h => ⟨(h ⟨le_rfl, h₁⟩).1, (h ⟨h₁, le_rfl⟩).2⟩, fun ⟨h, h'⟩ _ ⟨hx, hx'⟩ =>
⟨h.trans_le hx, hx'.trans_lt h'⟩⟩
theorem Icc_subset_Ico_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ico a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ < b₂ :=
⟨fun h => ⟨(h ⟨le_rfl, h₁⟩).1, (h ⟨h₁, le_rfl⟩).2⟩, fun ⟨h, h'⟩ _ ⟨hx, hx'⟩ =>
⟨h.trans hx, hx'.trans_lt h'⟩⟩
theorem Icc_subset_Ioc_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ioc a₂ b₂ ↔ a₂ < a₁ ∧ b₁ ≤ b₂ :=
⟨fun h => ⟨(h ⟨le_rfl, h₁⟩).1, (h ⟨h₁, le_rfl⟩).2⟩, fun ⟨h, h'⟩ _ ⟨hx, hx'⟩ =>
⟨h.trans_le hx, hx'.trans h'⟩⟩
theorem Icc_subset_Iio_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Iio b₂ ↔ b₁ < b₂ :=
⟨fun h => h ⟨h₁, le_rfl⟩, fun h _ ⟨_, hx'⟩ => hx'.trans_lt h⟩
theorem Icc_subset_Ioi_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ioi a₂ ↔ a₂ < a₁ :=
⟨fun h => h ⟨le_rfl, h₁⟩, fun h _ ⟨hx, _⟩ => h.trans_le hx⟩
theorem Icc_subset_Iic_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Iic b₂ ↔ b₁ ≤ b₂ :=
⟨fun h => h ⟨h₁, le_rfl⟩, fun h _ ⟨_, hx'⟩ => hx'.trans h⟩
theorem Icc_subset_Ici_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ici a₂ ↔ a₂ ≤ a₁ :=
⟨fun h => h ⟨le_rfl, h₁⟩, fun h _ ⟨hx, _⟩ => h.trans hx⟩
theorem Icc_ssubset_Icc_left (hI : a₂ ≤ b₂) (ha : a₂ < a₁) (hb : b₁ ≤ b₂) : Icc a₁ b₁ ⊂ Icc a₂ b₂ :=
(ssubset_iff_of_subset (Icc_subset_Icc (le_of_lt ha) hb)).mpr
⟨a₂, left_mem_Icc.mpr hI, not_and.mpr fun f _ => lt_irrefl a₂ (ha.trans_le f)⟩
theorem Icc_ssubset_Icc_right (hI : a₂ ≤ b₂) (ha : a₂ ≤ a₁) (hb : b₁ < b₂) :
Icc a₁ b₁ ⊂ Icc a₂ b₂ :=
(ssubset_iff_of_subset (Icc_subset_Icc ha (le_of_lt hb))).mpr
⟨b₂, right_mem_Icc.mpr hI, fun f => lt_irrefl b₁ (hb.trans_le f.2)⟩
/-- If `a ≤ b`, then `(b, +∞) ⊆ (a, +∞)`. In preorders, this is just an implication. If you need
the equivalence in linear orders, use `Ioi_subset_Ioi_iff`. -/
@[gcongr]
theorem Ioi_subset_Ioi (h : a ≤ b) : Ioi b ⊆ Ioi a := fun _ hx => h.trans_lt hx
/-- If `a < b`, then `(b, +∞) ⊂ (a, +∞)`. In preorders, this is just an implication. If you need
the equivalence in linear orders, use `Ioi_ssubset_Ioi_iff`. -/
@[gcongr]
theorem Ioi_ssubset_Ioi (h : a < b) : Ioi b ⊂ Ioi a :=
(ssubset_iff_of_subset (Ioi_subset_Ioi h.le)).mpr ⟨b, h, lt_irrefl b⟩
/-- If `a ≤ b`, then `(b, +∞) ⊆ [a, +∞)`. In preorders, this is just an implication. If you need
the equivalence in dense linear orders, use `Ioi_subset_Ici_iff`. -/
theorem Ioi_subset_Ici (h : a ≤ b) : Ioi b ⊆ Ici a :=
Subset.trans (Ioi_subset_Ioi h) Ioi_subset_Ici_self
/-- If `a ≤ b`, then `(-∞, a) ⊆ (-∞, b)`. In preorders, this is just an implication. If you need
the equivalence in linear orders, use `Iio_subset_Iio_iff`. -/
@[gcongr]
theorem Iio_subset_Iio (h : a ≤ b) : Iio a ⊆ Iio b := fun _ hx => lt_of_lt_of_le hx h
/-- If `a < b`, then `(-∞, a) ⊂ (-∞, b)`. In preorders, this is just an implication. If you need
the equivalence in linear orders, use `Iio_ssubset_Iio_iff`. -/
@[gcongr]
theorem Iio_ssubset_Iio (h : a < b) : Iio a ⊂ Iio b :=
(ssubset_iff_of_subset (Iio_subset_Iio h.le)).mpr ⟨a, h, lt_irrefl a⟩
/-- If `a ≤ b`, then `(-∞, a) ⊆ (-∞, b]`. In preorders, this is just an implication. If you need
the equivalence in dense linear orders, use `Iio_subset_Iic_iff`. -/
theorem Iio_subset_Iic (h : a ≤ b) : Iio a ⊆ Iic b :=
Subset.trans (Iio_subset_Iio h) Iio_subset_Iic_self
theorem Ici_inter_Iic : Ici a ∩ Iic b = Icc a b :=
rfl
theorem Ici_inter_Iio : Ici a ∩ Iio b = Ico a b :=
rfl
theorem Ioi_inter_Iic : Ioi a ∩ Iic b = Ioc a b :=
rfl
theorem Ioi_inter_Iio : Ioi a ∩ Iio b = Ioo a b :=
rfl
theorem Iic_inter_Ici : Iic a ∩ Ici b = Icc b a :=
inter_comm _ _
theorem Iio_inter_Ici : Iio a ∩ Ici b = Ico b a :=
inter_comm _ _
theorem Iic_inter_Ioi : Iic a ∩ Ioi b = Ioc b a :=
inter_comm _ _
theorem Iio_inter_Ioi : Iio a ∩ Ioi b = Ioo b a :=
inter_comm _ _
theorem mem_Icc_of_Ioo (h : x ∈ Ioo a b) : x ∈ Icc a b :=
Ioo_subset_Icc_self h
theorem mem_Ico_of_Ioo (h : x ∈ Ioo a b) : x ∈ Ico a b :=
Ioo_subset_Ico_self h
theorem mem_Ioc_of_Ioo (h : x ∈ Ioo a b) : x ∈ Ioc a b :=
Ioo_subset_Ioc_self h
theorem mem_Icc_of_Ico (h : x ∈ Ico a b) : x ∈ Icc a b :=
Ico_subset_Icc_self h
theorem mem_Icc_of_Ioc (h : x ∈ Ioc a b) : x ∈ Icc a b :=
Ioc_subset_Icc_self h
theorem mem_Ici_of_Ioi (h : x ∈ Ioi a) : x ∈ Ici a :=
Ioi_subset_Ici_self h
theorem mem_Iic_of_Iio (h : x ∈ Iio a) : x ∈ Iic a :=
Iio_subset_Iic_self h
theorem Icc_eq_empty_iff : Icc a b = ∅ ↔ ¬a ≤ b := by
rw [← not_nonempty_iff_eq_empty, not_iff_not, nonempty_Icc]
theorem Ico_eq_empty_iff : Ico a b = ∅ ↔ ¬a < b := by
rw [← not_nonempty_iff_eq_empty, not_iff_not, nonempty_Ico]
theorem Ioc_eq_empty_iff : Ioc a b = ∅ ↔ ¬a < b := by
rw [← not_nonempty_iff_eq_empty, not_iff_not, nonempty_Ioc]
theorem Ioo_eq_empty_iff [DenselyOrdered α] : Ioo a b = ∅ ↔ ¬a < b := by
rw [← not_nonempty_iff_eq_empty, not_iff_not, nonempty_Ioo]
theorem _root_.IsTop.Iic_eq (h : IsTop a) : Iic a = univ :=
eq_univ_of_forall h
theorem _root_.IsBot.Ici_eq (h : IsBot a) : Ici a = univ :=
eq_univ_of_forall h
@[simp] theorem Ioi_eq_empty_iff : Ioi a = ∅ ↔ IsMax a := by
simp only [isMax_iff_forall_not_lt, eq_empty_iff_forall_not_mem, mem_Ioi]
@[simp] theorem Iio_eq_empty_iff : Iio a = ∅ ↔ IsMin a := Ioi_eq_empty_iff (α := αᵒᵈ)
@[simp] alias ⟨_, _root_.IsMax.Ioi_eq⟩ := Ioi_eq_empty_iff
@[simp] alias ⟨_, _root_.IsMin.Iio_eq⟩ := Iio_eq_empty_iff
@[simp] lemma Iio_nonempty : (Iio a).Nonempty ↔ ¬ IsMin a := by simp [nonempty_iff_ne_empty]
@[simp] lemma Ioi_nonempty : (Ioi a).Nonempty ↔ ¬ IsMax a := by simp [nonempty_iff_ne_empty]
theorem Iic_inter_Ioc_of_le (h : a ≤ c) : Iic a ∩ Ioc b c = Ioc b a :=
ext fun _ => ⟨fun H => ⟨H.2.1, H.1⟩, fun H => ⟨H.2, H.1, H.2.trans h⟩⟩
theorem not_mem_Icc_of_lt (ha : c < a) : c ∉ Icc a b := fun h => ha.not_le h.1
theorem not_mem_Icc_of_gt (hb : b < c) : c ∉ Icc a b := fun h => hb.not_le h.2
theorem not_mem_Ico_of_lt (ha : c < a) : c ∉ Ico a b := fun h => ha.not_le h.1
theorem not_mem_Ioc_of_gt (hb : b < c) : c ∉ Ioc a b := fun h => hb.not_le h.2
theorem not_mem_Ioi_self : a ∉ Ioi a := lt_irrefl _
theorem not_mem_Iio_self : b ∉ Iio b := lt_irrefl _
theorem not_mem_Ioc_of_le (ha : c ≤ a) : c ∉ Ioc a b := fun h => lt_irrefl _ <| h.1.trans_le ha
theorem not_mem_Ico_of_ge (hb : b ≤ c) : c ∉ Ico a b := fun h => lt_irrefl _ <| h.2.trans_le hb
theorem not_mem_Ioo_of_le (ha : c ≤ a) : c ∉ Ioo a b := fun h => lt_irrefl _ <| h.1.trans_le ha
theorem not_mem_Ioo_of_ge (hb : b ≤ c) : c ∉ Ioo a b := fun h => lt_irrefl _ <| h.2.trans_le hb
section matched_intervals
@[simp] theorem Icc_eq_Ioc_same_iff : Icc a b = Ioc a b ↔ ¬a ≤ b where
mp h := by simpa using Set.ext_iff.mp h a
mpr h := by rw [Icc_eq_empty h, Ioc_eq_empty (mt le_of_lt h)]
@[simp] theorem Icc_eq_Ico_same_iff : Icc a b = Ico a b ↔ ¬a ≤ b where
mp h := by simpa using Set.ext_iff.mp h b
mpr h := by rw [Icc_eq_empty h, Ico_eq_empty (mt le_of_lt h)]
@[simp] theorem Icc_eq_Ioo_same_iff : Icc a b = Ioo a b ↔ ¬a ≤ b where
mp h := by simpa using Set.ext_iff.mp h b
mpr h := by rw [Icc_eq_empty h, Ioo_eq_empty (mt le_of_lt h)]
@[simp] theorem Ioc_eq_Ico_same_iff : Ioc a b = Ico a b ↔ ¬a < b where
mp h := by simpa using Set.ext_iff.mp h a
mpr h := by rw [Ioc_eq_empty h, Ico_eq_empty h]
@[simp] theorem Ioo_eq_Ioc_same_iff : Ioo a b = Ioc a b ↔ ¬a < b where
mp h := by simpa using Set.ext_iff.mp h b
mpr h := by rw [Ioo_eq_empty h, Ioc_eq_empty h]
@[simp] theorem Ioo_eq_Ico_same_iff : Ioo a b = Ico a b ↔ ¬a < b where
mp h := by simpa using Set.ext_iff.mp h a
mpr h := by rw [Ioo_eq_empty h, Ico_eq_empty h]
-- Mirrored versions of the above for `simp`.
@[simp] theorem Ioc_eq_Icc_same_iff : Ioc a b = Icc a b ↔ ¬a ≤ b :=
eq_comm.trans Icc_eq_Ioc_same_iff
@[simp] theorem Ico_eq_Icc_same_iff : Ico a b = Icc a b ↔ ¬a ≤ b :=
eq_comm.trans Icc_eq_Ico_same_iff
@[simp] theorem Ioo_eq_Icc_same_iff : Ioo a b = Icc a b ↔ ¬a ≤ b :=
eq_comm.trans Icc_eq_Ioo_same_iff
@[simp] theorem Ico_eq_Ioc_same_iff : Ico a b = Ioc a b ↔ ¬a < b :=
eq_comm.trans Ioc_eq_Ico_same_iff
@[simp] theorem Ioc_eq_Ioo_same_iff : Ioc a b = Ioo a b ↔ ¬a < b :=
eq_comm.trans Ioo_eq_Ioc_same_iff
@[simp] theorem Ico_eq_Ioo_same_iff : Ico a b = Ioo a b ↔ ¬a < b :=
eq_comm.trans Ioo_eq_Ico_same_iff
end matched_intervals
end Preorder
section PartialOrder
variable [PartialOrder α] {a b c : α}
@[simp]
theorem Icc_self (a : α) : Icc a a = {a} :=
Set.ext <| by simp [Icc, le_antisymm_iff, and_comm]
instance instIccUnique : Unique (Set.Icc a a) where
default := ⟨a, by simp⟩
uniq y := Subtype.ext <| by simpa using y.2
@[simp]
theorem Icc_eq_singleton_iff : Icc a b = {c} ↔ a = c ∧ b = c := by
refine ⟨fun h => ?_, ?_⟩
· have hab : a ≤ b := nonempty_Icc.1 (h.symm.subst <| singleton_nonempty c)
exact
⟨eq_of_mem_singleton <| h ▸ left_mem_Icc.2 hab,
eq_of_mem_singleton <| h ▸ right_mem_Icc.2 hab⟩
· rintro ⟨rfl, rfl⟩
exact Icc_self _
lemma subsingleton_Icc_of_ge (hba : b ≤ a) : Set.Subsingleton (Icc a b) :=
fun _x ⟨hax, hxb⟩ _y ⟨hay, hyb⟩ ↦ le_antisymm
(le_implies_le_of_le_of_le hxb hay hba) (le_implies_le_of_le_of_le hyb hax hba)
@[simp] lemma subsingleton_Icc_iff {α : Type*} [LinearOrder α] {a b : α} :
Set.Subsingleton (Icc a b) ↔ b ≤ a := by
refine ⟨fun h ↦ ?_, subsingleton_Icc_of_ge⟩
contrapose! h
simp only [gt_iff_lt, not_subsingleton_iff]
exact ⟨a, ⟨le_refl _, h.le⟩, b, ⟨h.le, le_refl _⟩, h.ne⟩
@[simp]
theorem Icc_diff_left : Icc a b \ {a} = Ioc a b :=
ext fun x => by simp [lt_iff_le_and_ne, eq_comm, and_right_comm]
@[simp]
theorem Icc_diff_right : Icc a b \ {b} = Ico a b :=
ext fun x => by simp [lt_iff_le_and_ne, and_assoc]
@[simp]
theorem Ico_diff_left : Ico a b \ {a} = Ioo a b :=
ext fun x => by simp [and_right_comm, ← lt_iff_le_and_ne, eq_comm]
@[simp]
theorem Ioc_diff_right : Ioc a b \ {b} = Ioo a b :=
ext fun x => by simp [and_assoc, ← lt_iff_le_and_ne]
@[simp]
theorem Icc_diff_both : Icc a b \ {a, b} = Ioo a b := by
rw [insert_eq, ← diff_diff, Icc_diff_left, Ioc_diff_right]
@[simp]
theorem Ici_diff_left : Ici a \ {a} = Ioi a :=
ext fun x => by simp [lt_iff_le_and_ne, eq_comm]
@[simp]
theorem Iic_diff_right : Iic a \ {a} = Iio a :=
ext fun x => by simp [lt_iff_le_and_ne]
@[simp]
theorem Ico_diff_Ioo_same (h : a < b) : Ico a b \ Ioo a b = {a} := by
rw [← Ico_diff_left, diff_diff_cancel_left (singleton_subset_iff.2 <| left_mem_Ico.2 h)]
@[simp]
theorem Ioc_diff_Ioo_same (h : a < b) : Ioc a b \ Ioo a b = {b} := by
rw [← Ioc_diff_right, diff_diff_cancel_left (singleton_subset_iff.2 <| right_mem_Ioc.2 h)]
@[simp]
| Mathlib/Order/Interval/Set/Basic.lean | 704 | 705 | theorem Icc_diff_Ico_same (h : a ≤ b) : Icc a b \ Ico a b = {b} := by | rw [← Icc_diff_right, diff_diff_cancel_left (singleton_subset_iff.2 <| right_mem_Icc.2 h)] |
/-
Copyright (c) 2022 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying
-/
import Mathlib.Algebra.Order.Archimedean.IndicatorCard
import Mathlib.Probability.Martingale.Centering
import Mathlib.Probability.Martingale.Convergence
import Mathlib.Probability.Martingale.OptionalStopping
/-!
# Generalized Borel-Cantelli lemma
This file proves Lévy's generalized Borel-Cantelli lemma which is a generalization of the
Borel-Cantelli lemmas. With this generalization, one can easily deduce the Borel-Cantelli lemmas
by choosing appropriate filtrations. This file also contains the one sided martingale bound which
is required to prove the generalized Borel-Cantelli.
**Note**: the usual Borel-Cantelli lemmas are not in this file.
See `MeasureTheory.measure_limsup_atTop_eq_zero` for the first (which does not depend on
the results here), and `ProbabilityTheory.measure_limsup_eq_one` for the second (which does).
## Main results
- `MeasureTheory.Submartingale.bddAbove_iff_exists_tendsto`: the one sided martingale bound: given
a submartingale `f` with uniformly bounded differences, the set for which `f` converges is almost
everywhere equal to the set for which it is bounded.
- `MeasureTheory.ae_mem_limsup_atTop_iff`: Lévy's generalized Borel-Cantelli:
given a filtration `ℱ` and a sequence of sets `s` such that `s n ∈ ℱ n` for all `n`,
`limsup atTop s` is almost everywhere equal to the set for which `∑ ℙ[s (n + 1)∣ℱ n] = ∞`.
-/
open Filter
open scoped NNReal ENNReal MeasureTheory ProbabilityTheory Topology
namespace MeasureTheory
variable {Ω : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} {ℱ : Filtration ℕ m0} {f : ℕ → Ω → ℝ}
/-!
### One sided martingale bound
-/
-- TODO: `leastGE` should be defined taking values in `WithTop ℕ` once the `stoppedProcess`
-- refactor is complete
/-- `leastGE f r n` is the stopping time corresponding to the first time `f ≥ r`. -/
noncomputable def leastGE (f : ℕ → Ω → ℝ) (r : ℝ) (n : ℕ) :=
hitting f (Set.Ici r) 0 n
theorem Adapted.isStoppingTime_leastGE (r : ℝ) (n : ℕ) (hf : Adapted ℱ f) :
IsStoppingTime ℱ (leastGE f r n) :=
hitting_isStoppingTime hf measurableSet_Ici
theorem leastGE_le {i : ℕ} {r : ℝ} (ω : Ω) : leastGE f r i ω ≤ i :=
hitting_le ω
-- The following four lemmas shows `leastGE` behaves like a stopped process. Ideally we should
-- define `leastGE` as a stopping time and take its stopped process. However, we can't do that
-- with our current definition since a stopping time takes only finite indices. An upcoming
-- refactor should hopefully make it possible to have stopping times taking infinity as a value
theorem leastGE_mono {n m : ℕ} (hnm : n ≤ m) (r : ℝ) (ω : Ω) : leastGE f r n ω ≤ leastGE f r m ω :=
hitting_mono hnm
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
classical
refine le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) ?_
by_cases hle : π ω ≤ leastGE f r n ω
· rw [min_eq_left hle, leastGE]
by_cases h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
· refine hle.trans (Eq.le ?_)
rw [leastGE, ← hitting_eq_hitting_of_exists (hπn ω) h]
· simp only [hitting, if_neg h, le_rfl]
· rw [min_eq_right (not_le.1 hle).le, leastGE, leastGE, ←
hitting_eq_hitting_of_exists (hπn ω) _]
rw [not_le, leastGE, hitting_lt_iff _ (hπn ω)] at hle
exact
let ⟨j, hj₁, hj₂⟩ := hle
⟨j, ⟨hj₁.1, hj₁.2.le⟩, hj₂⟩
theorem stoppedValue_stoppedValue_leastGE (f : ℕ → Ω → ℝ) (π : Ω → ℕ) (r : ℝ) {n : ℕ}
(hπn : ∀ ω, π ω ≤ n) : stoppedValue (fun i => stoppedValue f (leastGE f r i)) π =
stoppedValue (stoppedProcess f (leastGE f r n)) π := by
ext1 ω
simp +unfoldPartialApp only [stoppedProcess, stoppedValue]
rw [leastGE_eq_min _ _ _ hπn]
| Mathlib/Probability/Martingale/BorelCantelli.lean | 93 | 98 | theorem Submartingale.stoppedValue_leastGE [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (r : ℝ) :
Submartingale (fun i => stoppedValue f (leastGE f r i)) ℱ μ := by | rw [submartingale_iff_expected_stoppedValue_mono]
· intro σ π hσ hπ hσ_le_π hπ_bdd
obtain ⟨n, hπ_le_n⟩ := hπ_bdd
simp_rw [stoppedValue_stoppedValue_leastGE f σ r fun i => (hσ_le_π i).trans (hπ_le_n i)] |
/-
Copyright (c) 2020 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis, Eric Wieser
-/
import Mathlib.LinearAlgebra.Multilinear.TensorProduct
import Mathlib.Tactic.AdaptationNote
import Mathlib.LinearAlgebra.Multilinear.Curry
/-!
# Tensor product of an indexed family of modules over commutative semirings
We define the tensor product of an indexed family `s : ι → Type*` of modules over commutative
semirings. We denote this space by `⨂[R] i, s i` and define it as `FreeAddMonoid (R × Π i, s i)`
quotiented by the appropriate equivalence relation. The treatment follows very closely that of the
binary tensor product in `LinearAlgebra/TensorProduct.lean`.
## Main definitions
* `PiTensorProduct R s` with `R` a commutative semiring and `s : ι → Type*` is the tensor product
of all the `s i`'s. This is denoted by `⨂[R] i, s i`.
* `tprod R f` with `f : Π i, s i` is the tensor product of the vectors `f i` over all `i : ι`.
This is bundled as a multilinear map from `Π i, s i` to `⨂[R] i, s i`.
* `liftAddHom` constructs an `AddMonoidHom` from `(⨂[R] i, s i)` to some space `F` from a
function `φ : (R × Π i, s i) → F` with the appropriate properties.
* `lift φ` with `φ : MultilinearMap R s E` is the corresponding linear map
`(⨂[R] i, s i) →ₗ[R] E`. This is bundled as a linear equivalence.
* `PiTensorProduct.reindex e` re-indexes the components of `⨂[R] i : ι, M` along `e : ι ≃ ι₂`.
* `PiTensorProduct.tmulEquiv` equivalence between a `TensorProduct` of `PiTensorProduct`s and
a single `PiTensorProduct`.
## Notations
* `⨂[R] i, s i` is defined as localized notation in locale `TensorProduct`.
* `⨂ₜ[R] i, f i` with `f : ∀ i, s i` is defined globally as the tensor product of all the `f i`'s.
## Implementation notes
* We define it via `FreeAddMonoid (R × Π i, s i)` with the `R` representing a "hidden" tensor
factor, rather than `FreeAddMonoid (Π i, s i)` to ensure that, if `ι` is an empty type,
the space is isomorphic to the base ring `R`.
* We have not restricted the index type `ι` to be a `Fintype`, as nothing we do here strictly
requires it. However, problems may arise in the case where `ι` is infinite; use at your own
caution.
* Instead of requiring `DecidableEq ι` as an argument to `PiTensorProduct` itself, we include it
as an argument in the constructors of the relation. A decidability instance still has to come
from somewhere due to the use of `Function.update`, but this hides it from the downstream user.
See the implementation notes for `MultilinearMap` for an extended discussion of this choice.
## TODO
* Define tensor powers, symmetric subspace, etc.
* API for the various ways `ι` can be split into subsets; connect this with the binary
tensor product.
* Include connection with holors.
* Port more of the API from the binary tensor product over to this case.
## Tags
multilinear, tensor, tensor product
-/
suppress_compilation
open Function
section Semiring
variable {ι ι₂ ι₃ : Type*}
variable {R : Type*} [CommSemiring R]
variable {R₁ R₂ : Type*}
variable {s : ι → Type*} [∀ i, AddCommMonoid (s i)] [∀ i, Module R (s i)]
variable {M : Type*} [AddCommMonoid M] [Module R M]
variable {E : Type*} [AddCommMonoid E] [Module R E]
variable {F : Type*} [AddCommMonoid F]
namespace PiTensorProduct
variable (R) (s)
/-- The relation on `FreeAddMonoid (R × Π i, s i)` that generates a congruence whose quotient is
the tensor product. -/
inductive Eqv : FreeAddMonoid (R × Π i, s i) → FreeAddMonoid (R × Π i, s i) → Prop
| of_zero : ∀ (r : R) (f : Π i, s i) (i : ι) (_ : f i = 0), Eqv (FreeAddMonoid.of (r, f)) 0
| of_zero_scalar : ∀ f : Π i, s i, Eqv (FreeAddMonoid.of (0, f)) 0
| of_add : ∀ (_ : DecidableEq ι) (r : R) (f : Π i, s i) (i : ι) (m₁ m₂ : s i),
Eqv (FreeAddMonoid.of (r, update f i m₁) + FreeAddMonoid.of (r, update f i m₂))
(FreeAddMonoid.of (r, update f i (m₁ + m₂)))
| of_add_scalar : ∀ (r r' : R) (f : Π i, s i),
Eqv (FreeAddMonoid.of (r, f) + FreeAddMonoid.of (r', f)) (FreeAddMonoid.of (r + r', f))
| of_smul : ∀ (_ : DecidableEq ι) (r : R) (f : Π i, s i) (i : ι) (r' : R),
Eqv (FreeAddMonoid.of (r, update f i (r' • f i))) (FreeAddMonoid.of (r' * r, f))
| add_comm : ∀ x y, Eqv (x + y) (y + x)
end PiTensorProduct
variable (R) (s)
/-- `PiTensorProduct R s` with `R` a commutative semiring and `s : ι → Type*` is the tensor
product of all the `s i`'s. This is denoted by `⨂[R] i, s i`. -/
def PiTensorProduct : Type _ :=
(addConGen (PiTensorProduct.Eqv R s)).Quotient
variable {R}
unsuppress_compilation in
/-- This enables the notation `⨂[R] i : ι, s i` for the pi tensor product `PiTensorProduct`,
given an indexed family of types `s : ι → Type*`. -/
scoped[TensorProduct] notation3:100"⨂["R"] "(...)", "r:(scoped f => PiTensorProduct R f) => r
open TensorProduct
namespace PiTensorProduct
section Module
instance : AddCommMonoid (⨂[R] i, s i) :=
{ (addConGen (PiTensorProduct.Eqv R s)).addMonoid with
add_comm := fun x y ↦
AddCon.induction_on₂ x y fun _ _ ↦
Quotient.sound' <| AddConGen.Rel.of _ _ <| Eqv.add_comm _ _ }
instance : Inhabited (⨂[R] i, s i) := ⟨0⟩
variable (R) {s}
/-- `tprodCoeff R r f` with `r : R` and `f : Π i, s i` is the tensor product of the vectors `f i`
over all `i : ι`, multiplied by the coefficient `r`. Note that this is meant as an auxiliary
definition for this file alone, and that one should use `tprod` defined below for most purposes. -/
def tprodCoeff (r : R) (f : Π i, s i) : ⨂[R] i, s i :=
AddCon.mk' _ <| FreeAddMonoid.of (r, f)
variable {R}
theorem zero_tprodCoeff (f : Π i, s i) : tprodCoeff R 0 f = 0 :=
Quotient.sound' <| AddConGen.Rel.of _ _ <| Eqv.of_zero_scalar _
theorem zero_tprodCoeff' (z : R) (f : Π i, s i) (i : ι) (hf : f i = 0) : tprodCoeff R z f = 0 :=
Quotient.sound' <| AddConGen.Rel.of _ _ <| Eqv.of_zero _ _ i hf
theorem add_tprodCoeff [DecidableEq ι] (z : R) (f : Π i, s i) (i : ι) (m₁ m₂ : s i) :
tprodCoeff R z (update f i m₁) + tprodCoeff R z (update f i m₂) =
tprodCoeff R z (update f i (m₁ + m₂)) :=
Quotient.sound' <| AddConGen.Rel.of _ _ (Eqv.of_add _ z f i m₁ m₂)
theorem add_tprodCoeff' (z₁ z₂ : R) (f : Π i, s i) :
tprodCoeff R z₁ f + tprodCoeff R z₂ f = tprodCoeff R (z₁ + z₂) f :=
Quotient.sound' <| AddConGen.Rel.of _ _ (Eqv.of_add_scalar z₁ z₂ f)
theorem smul_tprodCoeff_aux [DecidableEq ι] (z : R) (f : Π i, s i) (i : ι) (r : R) :
tprodCoeff R z (update f i (r • f i)) = tprodCoeff R (r * z) f :=
Quotient.sound' <| AddConGen.Rel.of _ _ <| Eqv.of_smul _ _ _ _ _
theorem smul_tprodCoeff [DecidableEq ι] (z : R) (f : Π i, s i) (i : ι) (r : R₁) [SMul R₁ R]
[IsScalarTower R₁ R R] [SMul R₁ (s i)] [IsScalarTower R₁ R (s i)] :
tprodCoeff R z (update f i (r • f i)) = tprodCoeff R (r • z) f := by
have h₁ : r • z = r • (1 : R) * z := by rw [smul_mul_assoc, one_mul]
have h₂ : r • f i = (r • (1 : R)) • f i := (smul_one_smul _ _ _).symm
rw [h₁, h₂]
exact smul_tprodCoeff_aux z f i _
/-- Construct an `AddMonoidHom` from `(⨂[R] i, s i)` to some space `F` from a function
`φ : (R × Π i, s i) → F` with the appropriate properties. -/
def liftAddHom (φ : (R × Π i, s i) → F)
(C0 : ∀ (r : R) (f : Π i, s i) (i : ι) (_ : f i = 0), φ (r, f) = 0)
(C0' : ∀ f : Π i, s i, φ (0, f) = 0)
(C_add : ∀ [DecidableEq ι] (r : R) (f : Π i, s i) (i : ι) (m₁ m₂ : s i),
φ (r, update f i m₁) + φ (r, update f i m₂) = φ (r, update f i (m₁ + m₂)))
(C_add_scalar : ∀ (r r' : R) (f : Π i, s i), φ (r, f) + φ (r', f) = φ (r + r', f))
(C_smul : ∀ [DecidableEq ι] (r : R) (f : Π i, s i) (i : ι) (r' : R),
φ (r, update f i (r' • f i)) = φ (r' * r, f)) :
(⨂[R] i, s i) →+ F :=
(addConGen (PiTensorProduct.Eqv R s)).lift (FreeAddMonoid.lift φ) <|
AddCon.addConGen_le fun x y hxy ↦
match hxy with
| Eqv.of_zero r' f i hf =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, C0 r' f i hf]
| Eqv.of_zero_scalar f =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, C0']
| Eqv.of_add inst z f i m₁ m₂ =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, @C_add inst]
| Eqv.of_add_scalar z₁ z₂ f =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, C_add_scalar]
| Eqv.of_smul inst z f i r' =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, @C_smul inst]
| Eqv.add_comm x y =>
(AddCon.ker_rel _).2 <| by simp_rw [AddMonoidHom.map_add, add_comm]
/-- Induct using `tprodCoeff` -/
@[elab_as_elim]
protected theorem induction_on' {motive : (⨂[R] i, s i) → Prop} (z : ⨂[R] i, s i)
(tprodCoeff : ∀ (r : R) (f : Π i, s i), motive (tprodCoeff R r f))
(add : ∀ x y, motive x → motive y → motive (x + y)) :
motive z := by
have C0 : motive 0 := by
have h₁ := tprodCoeff 0 0
rwa [zero_tprodCoeff] at h₁
refine AddCon.induction_on z fun x ↦ FreeAddMonoid.recOn x C0 ?_
simp_rw [AddCon.coe_add]
refine fun f y ih ↦ add _ _ ?_ ih
convert tprodCoeff f.1 f.2
section DistribMulAction
variable [Monoid R₁] [DistribMulAction R₁ R] [SMulCommClass R₁ R R]
variable [Monoid R₂] [DistribMulAction R₂ R] [SMulCommClass R₂ R R]
-- Most of the time we want the instance below this one, which is easier for typeclass resolution
-- to find.
instance hasSMul' : SMul R₁ (⨂[R] i, s i) :=
⟨fun r ↦
liftAddHom (fun f : R × Π i, s i ↦ tprodCoeff R (r • f.1) f.2)
(fun r' f i hf ↦ by simp_rw [zero_tprodCoeff' _ f i hf])
(fun f ↦ by simp [zero_tprodCoeff]) (fun r' f i m₁ m₂ ↦ by simp [add_tprodCoeff])
(fun r' r'' f ↦ by simp [add_tprodCoeff', mul_add]) fun z f i r' ↦ by
simp [smul_tprodCoeff, mul_smul_comm]⟩
instance : SMul R (⨂[R] i, s i) :=
PiTensorProduct.hasSMul'
theorem smul_tprodCoeff' (r : R₁) (z : R) (f : Π i, s i) :
r • tprodCoeff R z f = tprodCoeff R (r • z) f := rfl
protected theorem smul_add (r : R₁) (x y : ⨂[R] i, s i) : r • (x + y) = r • x + r • y :=
AddMonoidHom.map_add _ _ _
instance distribMulAction' : DistribMulAction R₁ (⨂[R] i, s i) where
smul := (· • ·)
smul_add _ _ _ := AddMonoidHom.map_add _ _ _
mul_smul r r' x :=
PiTensorProduct.induction_on' x (fun {r'' f} ↦ by simp [smul_tprodCoeff', smul_smul])
fun {x y} ihx ihy ↦ by simp_rw [PiTensorProduct.smul_add, ihx, ihy]
one_smul x :=
PiTensorProduct.induction_on' x (fun {r f} ↦ by rw [smul_tprodCoeff', one_smul])
fun {z y} ihz ihy ↦ by simp_rw [PiTensorProduct.smul_add, ihz, ihy]
smul_zero _ := AddMonoidHom.map_zero _
instance smulCommClass' [SMulCommClass R₁ R₂ R] : SMulCommClass R₁ R₂ (⨂[R] i, s i) :=
⟨fun {r' r''} x ↦
PiTensorProduct.induction_on' x (fun {xr xf} ↦ by simp only [smul_tprodCoeff', smul_comm])
fun {z y} ihz ihy ↦ by simp_rw [PiTensorProduct.smul_add, ihz, ihy]⟩
instance isScalarTower' [SMul R₁ R₂] [IsScalarTower R₁ R₂ R] :
IsScalarTower R₁ R₂ (⨂[R] i, s i) :=
⟨fun {r' r''} x ↦
PiTensorProduct.induction_on' x (fun {xr xf} ↦ by simp only [smul_tprodCoeff', smul_assoc])
fun {z y} ihz ihy ↦ by simp_rw [PiTensorProduct.smul_add, ihz, ihy]⟩
end DistribMulAction
-- Most of the time we want the instance below this one, which is easier for typeclass resolution
-- to find.
instance module' [Semiring R₁] [Module R₁ R] [SMulCommClass R₁ R R] : Module R₁ (⨂[R] i, s i) :=
{ PiTensorProduct.distribMulAction' with
add_smul := fun r r' x ↦
PiTensorProduct.induction_on' x
(fun {r f} ↦ by simp_rw [smul_tprodCoeff', add_smul, add_tprodCoeff'])
fun {x y} ihx ihy ↦ by simp_rw [PiTensorProduct.smul_add, ihx, ihy, add_add_add_comm]
zero_smul := fun x ↦
PiTensorProduct.induction_on' x
(fun {r f} ↦ by simp_rw [smul_tprodCoeff', zero_smul, zero_tprodCoeff])
fun {x y} ihx ihy ↦ by simp_rw [PiTensorProduct.smul_add, ihx, ihy, add_zero] }
-- shortcut instances
instance : Module R (⨂[R] i, s i) :=
PiTensorProduct.module'
instance : SMulCommClass R R (⨂[R] i, s i) :=
PiTensorProduct.smulCommClass'
instance : IsScalarTower R R (⨂[R] i, s i) :=
PiTensorProduct.isScalarTower'
variable (R) in
/-- The canonical `MultilinearMap R s (⨂[R] i, s i)`.
`tprod R fun i => f i` has notation `⨂ₜ[R] i, f i`. -/
def tprod : MultilinearMap R s (⨂[R] i, s i) where
toFun := tprodCoeff R 1
map_update_add' {_ f} i x y := (add_tprodCoeff (1 : R) f i x y).symm
map_update_smul' {_ f} i r x := by
rw [smul_tprodCoeff', ← smul_tprodCoeff (1 : R) _ i, update_idem, update_self]
unsuppress_compilation in
@[inherit_doc tprod]
notation3:100 "⨂ₜ["R"] "(...)", "r:(scoped f => tprod R f) => r
theorem tprod_eq_tprodCoeff_one :
⇑(tprod R : MultilinearMap R s (⨂[R] i, s i)) = tprodCoeff R 1 := rfl
@[simp]
theorem tprodCoeff_eq_smul_tprod (z : R) (f : Π i, s i) : tprodCoeff R z f = z • tprod R f := by
have : z = z • (1 : R) := by simp only [mul_one, Algebra.id.smul_eq_mul]
conv_lhs => rw [this]
rfl
/-- The image of an element `p` of `FreeAddMonoid (R × Π i, s i)` in the `PiTensorProduct` is
equal to the sum of `a • ⨂ₜ[R] i, m i` over all the entries `(a, m)` of `p`.
-/
lemma _root_.FreeAddMonoid.toPiTensorProduct (p : FreeAddMonoid (R × Π i, s i)) :
AddCon.toQuotient (c := addConGen (PiTensorProduct.Eqv R s)) p =
List.sum (List.map (fun x ↦ x.1 • ⨂ₜ[R] i, x.2 i) p.toList) := by
-- TODO: this is defeq abuse: `p` is not a `List`.
match p with
| [] => rw [FreeAddMonoid.toList_nil, List.map_nil, List.sum_nil]; rfl
| x :: ps =>
rw [FreeAddMonoid.toList_cons, List.map_cons, List.sum_cons, ← List.singleton_append,
← toPiTensorProduct ps, ← tprodCoeff_eq_smul_tprod]
rfl
/-- The set of lifts of an element `x` of `⨂[R] i, s i` in `FreeAddMonoid (R × Π i, s i)`. -/
def lifts (x : ⨂[R] i, s i) : Set (FreeAddMonoid (R × Π i, s i)) :=
{p | AddCon.toQuotient (c := addConGen (PiTensorProduct.Eqv R s)) p = x}
/-- An element `p` of `FreeAddMonoid (R × Π i, s i)` lifts an element `x` of `⨂[R] i, s i`
if and only if `x` is equal to the sum of `a • ⨂ₜ[R] i, m i` over all the entries
`(a, m)` of `p`.
-/
lemma mem_lifts_iff (x : ⨂[R] i, s i) (p : FreeAddMonoid (R × Π i, s i)) :
p ∈ lifts x ↔ List.sum (List.map (fun x ↦ x.1 • ⨂ₜ[R] i, x.2 i) p.toList) = x := by
simp only [lifts, Set.mem_setOf_eq, FreeAddMonoid.toPiTensorProduct]
/-- Every element of `⨂[R] i, s i` has a lift in `FreeAddMonoid (R × Π i, s i)`.
-/
lemma nonempty_lifts (x : ⨂[R] i, s i) : Set.Nonempty (lifts x) := by
existsi @Quotient.out _ (addConGen (PiTensorProduct.Eqv R s)).toSetoid x
simp only [lifts, Set.mem_setOf_eq]
rw [← AddCon.quot_mk_eq_coe]
erw [Quot.out_eq]
/-- The empty list lifts the element `0` of `⨂[R] i, s i`.
-/
lemma lifts_zero : 0 ∈ lifts (0 : ⨂[R] i, s i) := by
rw [mem_lifts_iff]; erw [List.map_nil]; rw [List.sum_nil]
/-- If elements `p,q` of `FreeAddMonoid (R × Π i, s i)` lift elements `x,y` of `⨂[R] i, s i`
respectively, then `p + q` lifts `x + y`.
-/
lemma lifts_add {x y : ⨂[R] i, s i} {p q : FreeAddMonoid (R × Π i, s i)}
(hp : p ∈ lifts x) (hq : q ∈ lifts y) : p + q ∈ lifts (x + y) := by
simp only [lifts, Set.mem_setOf_eq, AddCon.coe_add]
rw [hp, hq]
/-- If an element `p` of `FreeAddMonoid (R × Π i, s i)` lifts an element `x` of `⨂[R] i, s i`,
and if `a` is an element of `R`, then the list obtained by multiplying the first entry of each
element of `p` by `a` lifts `a • x`.
-/
lemma lifts_smul {x : ⨂[R] i, s i} {p : FreeAddMonoid (R × Π i, s i)} (h : p ∈ lifts x) (a : R) :
p.map (fun (y : R × Π i, s i) ↦ (a * y.1, y.2)) ∈ lifts (a • x) := by
rw [mem_lifts_iff] at h ⊢
rw [← h]
simp [Function.comp_def, mul_smul, List.smul_sum]
/-- Induct using scaled versions of `PiTensorProduct.tprod`. -/
@[elab_as_elim]
protected theorem induction_on {motive : (⨂[R] i, s i) → Prop} (z : ⨂[R] i, s i)
(smul_tprod : ∀ (r : R) (f : Π i, s i), motive (r • tprod R f))
(add : ∀ x y, motive x → motive y → motive (x + y)) :
motive z := by
simp_rw [← tprodCoeff_eq_smul_tprod] at smul_tprod
exact PiTensorProduct.induction_on' z smul_tprod add
@[ext]
theorem ext {φ₁ φ₂ : (⨂[R] i, s i) →ₗ[R] E}
(H : φ₁.compMultilinearMap (tprod R) = φ₂.compMultilinearMap (tprod R)) : φ₁ = φ₂ := by
refine LinearMap.ext ?_
refine fun z ↦
PiTensorProduct.induction_on' z ?_ fun {x y} hx hy ↦ by rw [φ₁.map_add, φ₂.map_add, hx, hy]
· intro r f
rw [tprodCoeff_eq_smul_tprod, φ₁.map_smul, φ₂.map_smul]
apply congr_arg
exact MultilinearMap.congr_fun H f
/-- The pure tensors (i.e. the elements of the image of `PiTensorProduct.tprod`) span
the tensor product. -/
theorem span_tprod_eq_top :
Submodule.span R (Set.range (tprod R)) = (⊤ : Submodule R (⨂[R] i, s i)) :=
Submodule.eq_top_iff'.mpr fun t ↦ t.induction_on
(fun _ _ ↦ Submodule.smul_mem _ _
(Submodule.subset_span (by simp only [Set.mem_range, exists_apply_eq_apply])))
(fun _ _ hx hy ↦ Submodule.add_mem _ hx hy)
end Module
section Multilinear
open MultilinearMap
variable {s}
section lift
/-- Auxiliary function to constructing a linear map `(⨂[R] i, s i) → E` given a
`MultilinearMap R s E` with the property that its composition with the canonical
`MultilinearMap R s (⨂[R] i, s i)` is the given multilinear map. -/
def liftAux (φ : MultilinearMap R s E) : (⨂[R] i, s i) →+ E :=
liftAddHom (fun p : R × Π i, s i ↦ p.1 • φ p.2)
(fun z f i hf ↦ by simp_rw [map_coord_zero φ i hf, smul_zero])
(fun f ↦ by simp_rw [zero_smul])
(fun z f i m₁ m₂ ↦ by simp_rw [← smul_add, φ.map_update_add])
(fun z₁ z₂ f ↦ by rw [← add_smul])
fun z f i r ↦ by simp [φ.map_update_smul, smul_smul, mul_comm]
theorem liftAux_tprod (φ : MultilinearMap R s E) (f : Π i, s i) : liftAux φ (tprod R f) = φ f := by
simp only [liftAux, liftAddHom, tprod_eq_tprodCoeff_one, tprodCoeff, AddCon.coe_mk']
-- The end of this proof was very different before https://github.com/leanprover/lean4/pull/2644:
-- rw [FreeAddMonoid.of, FreeAddMonoid.ofList, Equiv.refl_apply, AddCon.lift_coe]
-- dsimp [FreeAddMonoid.lift, FreeAddMonoid.sumAux]
-- show _ • _ = _
-- rw [one_smul]
erw [AddCon.lift_coe]
rw [FreeAddMonoid.of]
dsimp [FreeAddMonoid.ofList]
rw [← one_smul R (φ f)]
erw [Equiv.refl_apply]
convert one_smul R (φ f)
simp
theorem liftAux_tprodCoeff (φ : MultilinearMap R s E) (z : R) (f : Π i, s i) :
liftAux φ (tprodCoeff R z f) = z • φ f := rfl
theorem liftAux.smul {φ : MultilinearMap R s E} (r : R) (x : ⨂[R] i, s i) :
liftAux φ (r • x) = r • liftAux φ x := by
refine PiTensorProduct.induction_on' x ?_ ?_
· intro z f
rw [smul_tprodCoeff' r z f, liftAux_tprodCoeff, liftAux_tprodCoeff, smul_assoc]
· intro z y ihz ihy
rw [smul_add, (liftAux φ).map_add, ihz, ihy, (liftAux φ).map_add, smul_add]
/-- Constructing a linear map `(⨂[R] i, s i) → E` given a `MultilinearMap R s E` with the
property that its composition with the canonical `MultilinearMap R s E` is
the given multilinear map `φ`. -/
def lift : MultilinearMap R s E ≃ₗ[R] (⨂[R] i, s i) →ₗ[R] E where
toFun φ := { liftAux φ with map_smul' := liftAux.smul }
invFun φ' := φ'.compMultilinearMap (tprod R)
left_inv φ := by
ext
simp [liftAux_tprod, LinearMap.compMultilinearMap]
right_inv φ := by
ext
simp [liftAux_tprod]
map_add' φ₁ φ₂ := by
ext
simp [liftAux_tprod]
map_smul' r φ₂ := by
ext
simp [liftAux_tprod]
variable {φ : MultilinearMap R s E}
@[simp]
theorem lift.tprod (f : Π i, s i) : lift φ (tprod R f) = φ f :=
liftAux_tprod φ f
theorem lift.unique' {φ' : (⨂[R] i, s i) →ₗ[R] E}
(H : φ'.compMultilinearMap (PiTensorProduct.tprod R) = φ) : φ' = lift φ :=
ext <| H.symm ▸ (lift.symm_apply_apply φ).symm
theorem lift.unique {φ' : (⨂[R] i, s i) →ₗ[R] E} (H : ∀ f, φ' (PiTensorProduct.tprod R f) = φ f) :
φ' = lift φ :=
lift.unique' (MultilinearMap.ext H)
@[simp]
theorem lift_symm (φ' : (⨂[R] i, s i) →ₗ[R] E) : lift.symm φ' = φ'.compMultilinearMap (tprod R) :=
rfl
@[simp]
theorem lift_tprod : lift (tprod R : MultilinearMap R s _) = LinearMap.id :=
Eq.symm <| lift.unique' rfl
end lift
section map
variable {t t' : ι → Type*}
variable [∀ i, AddCommMonoid (t i)] [∀ i, Module R (t i)]
variable [∀ i, AddCommMonoid (t' i)] [∀ i, Module R (t' i)]
variable (g : Π i, t i →ₗ[R] t' i) (f : Π i, s i →ₗ[R] t i)
/--
Let `sᵢ` and `tᵢ` be two families of `R`-modules.
Let `f` be a family of `R`-linear maps between `sᵢ` and `tᵢ`, i.e. `f : Πᵢ sᵢ → tᵢ`,
then there is an induced map `⨂ᵢ sᵢ → ⨂ᵢ tᵢ` by `⨂ aᵢ ↦ ⨂ fᵢ aᵢ`.
This is `TensorProduct.map` for an arbitrary family of modules.
-/
def map : (⨂[R] i, s i) →ₗ[R] ⨂[R] i, t i :=
lift <| (tprod R).compLinearMap f
@[simp] lemma map_tprod (x : Π i, s i) :
map f (tprod R x) = tprod R fun i ↦ f i (x i) :=
lift.tprod _
-- No lemmas about associativity, because we don't have associativity of `PiTensorProduct` yet.
theorem map_range_eq_span_tprod :
LinearMap.range (map f) =
Submodule.span R {t | ∃ (m : Π i, s i), tprod R (fun i ↦ f i (m i)) = t} := by
rw [← Submodule.map_top, ← span_tprod_eq_top, Submodule.map_span, ← Set.range_comp]
apply congrArg; ext x
simp only [Set.mem_range, comp_apply, map_tprod, Set.mem_setOf_eq]
/-- Given submodules `p i ⊆ s i`, this is the natural map: `⨂[R] i, p i → ⨂[R] i, s i`.
This is `TensorProduct.mapIncl` for an arbitrary family of modules.
-/
@[simp]
def mapIncl (p : Π i, Submodule R (s i)) : (⨂[R] i, p i) →ₗ[R] ⨂[R] i, s i :=
map fun (i : ι) ↦ (p i).subtype
theorem map_comp : map (fun (i : ι) ↦ g i ∘ₗ f i) = map g ∘ₗ map f := by
ext
simp only [LinearMap.compMultilinearMap_apply, map_tprod, LinearMap.coe_comp, Function.comp_apply]
theorem lift_comp_map (h : MultilinearMap R t E) :
lift h ∘ₗ map f = lift (h.compLinearMap f) := by
ext
simp only [LinearMap.compMultilinearMap_apply, LinearMap.coe_comp, Function.comp_apply,
map_tprod, lift.tprod, MultilinearMap.compLinearMap_apply]
attribute [local ext high] ext
@[simp]
theorem map_id : map (fun i ↦ (LinearMap.id : s i →ₗ[R] s i)) = .id := by
ext
simp only [LinearMap.compMultilinearMap_apply, map_tprod, LinearMap.id_coe, id_eq]
@[simp]
protected theorem map_one : map (fun (i : ι) ↦ (1 : s i →ₗ[R] s i)) = 1 :=
map_id
protected theorem map_mul (f₁ f₂ : Π i, s i →ₗ[R] s i) :
map (fun i ↦ f₁ i * f₂ i) = map f₁ * map f₂ :=
map_comp f₁ f₂
/-- Upgrading `PiTensorProduct.map` to a `MonoidHom` when `s = t`. -/
@[simps]
def mapMonoidHom : (Π i, s i →ₗ[R] s i) →* ((⨂[R] i, s i) →ₗ[R] ⨂[R] i, s i) where
toFun := map
map_one' := PiTensorProduct.map_one
map_mul' := PiTensorProduct.map_mul
@[simp]
protected theorem map_pow (f : Π i, s i →ₗ[R] s i) (n : ℕ) :
map (f ^ n) = map f ^ n := MonoidHom.map_pow mapMonoidHom _ _
open Function in
private theorem map_add_smul_aux [DecidableEq ι] (i : ι) (x : Π i, s i) (u : s i →ₗ[R] t i) :
(fun j ↦ update f i u j (x j)) = update (fun j ↦ (f j) (x j)) i (u (x i)) := by
ext j
exact apply_update (fun i F => F (x i)) f i u j
open Function in
protected theorem map_update_add [DecidableEq ι] (i : ι) (u v : s i →ₗ[R] t i) :
map (update f i (u + v)) = map (update f i u) + map (update f i v) := by
ext x
simp only [LinearMap.compMultilinearMap_apply, map_tprod, map_add_smul_aux, LinearMap.add_apply,
MultilinearMap.map_update_add]
@[deprecated (since := "2024-11-03")] protected alias map_add := PiTensorProduct.map_update_add
open Function in
protected theorem map_update_smul [DecidableEq ι] (i : ι) (c : R) (u : s i →ₗ[R] t i) :
map (update f i (c • u)) = c • map (update f i u) := by
ext x
simp only [LinearMap.compMultilinearMap_apply, map_tprod, map_add_smul_aux, LinearMap.smul_apply,
MultilinearMap.map_update_smul]
@[deprecated (since := "2024-11-03")] protected alias map_smul := PiTensorProduct.map_update_smul
variable (R s t)
/-- The tensor of a family of linear maps from `sᵢ` to `tᵢ`, as a multilinear map of
the family.
-/
@[simps]
noncomputable def mapMultilinear :
MultilinearMap R (fun (i : ι) ↦ s i →ₗ[R] t i) ((⨂[R] i, s i) →ₗ[R] ⨂[R] i, t i) where
toFun := map
map_update_smul' _ _ _ _ := PiTensorProduct.map_update_smul _ _ _ _
map_update_add' _ _ _ _ := PiTensorProduct.map_update_add _ _ _ _
variable {R s t}
/--
Let `sᵢ` and `tᵢ` be families of `R`-modules.
Then there is an `R`-linear map between `⨂ᵢ Hom(sᵢ, tᵢ)` and `Hom(⨂ᵢ sᵢ, ⨂ tᵢ)` defined by
`⨂ᵢ fᵢ ↦ ⨂ᵢ aᵢ ↦ ⨂ᵢ fᵢ aᵢ`.
This is `TensorProduct.homTensorHomMap` for an arbitrary family of modules.
Note that `PiTensorProduct.piTensorHomMap (tprod R f)` is equal to `PiTensorProduct.map f`.
-/
def piTensorHomMap : (⨂[R] i, s i →ₗ[R] t i) →ₗ[R] (⨂[R] i, s i) →ₗ[R] ⨂[R] i, t i :=
lift.toLinearMap ∘ₗ lift (MultilinearMap.piLinearMap <| tprod R)
@[simp] lemma piTensorHomMap_tprod_tprod (f : Π i, s i →ₗ[R] t i) (x : Π i, s i) :
piTensorHomMap (tprod R f) (tprod R x) = tprod R fun i ↦ f i (x i) := by
simp [piTensorHomMap]
lemma piTensorHomMap_tprod_eq_map (f : Π i, s i →ₗ[R] t i) :
piTensorHomMap (tprod R f) = map f := by
ext; simp
/-- If `s i` and `t i` are linearly equivalent for every `i` in `ι`, then `⨂[R] i, s i` and
`⨂[R] i, t i` are linearly equivalent.
This is the n-ary version of `TensorProduct.congr`
-/
noncomputable def congr (f : Π i, s i ≃ₗ[R] t i) :
(⨂[R] i, s i) ≃ₗ[R] ⨂[R] i, t i :=
.ofLinear
(map (fun i ↦ f i))
(map (fun i ↦ (f i).symm))
(by ext; simp)
(by ext; simp)
@[simp]
theorem congr_tprod (f : Π i, s i ≃ₗ[R] t i) (m : Π i, s i) :
congr f (tprod R m) = tprod R (fun (i : ι) ↦ (f i) (m i)) := by
simp only [congr, LinearEquiv.ofLinear_apply, map_tprod, LinearEquiv.coe_coe]
@[simp]
theorem congr_symm_tprod (f : Π i, s i ≃ₗ[R] t i) (p : Π i, t i) :
(congr f).symm (tprod R p) = tprod R (fun (i : ι) ↦ (f i).symm (p i)) := by
simp only [congr, LinearEquiv.ofLinear_symm_apply, map_tprod, LinearEquiv.coe_coe]
/--
Let `sᵢ`, `tᵢ` and `t'ᵢ` be families of `R`-modules, then `f : Πᵢ sᵢ → tᵢ → t'ᵢ` induces an
element of `Hom(⨂ᵢ sᵢ, Hom(⨂ tᵢ, ⨂ᵢ t'ᵢ))` defined by `⨂ᵢ aᵢ ↦ ⨂ᵢ bᵢ ↦ ⨂ᵢ fᵢ aᵢ bᵢ`.
This is `PiTensorProduct.map` for two arbitrary families of modules.
This is `TensorProduct.map₂` for families of modules.
-/
def map₂ (f : Π i, s i →ₗ[R] t i →ₗ[R] t' i) :
(⨂[R] i, s i) →ₗ[R] (⨂[R] i, t i) →ₗ[R] ⨂[R] i, t' i :=
lift <| LinearMap.compMultilinearMap piTensorHomMap <| (tprod R).compLinearMap f
lemma map₂_tprod_tprod (f : Π i, s i →ₗ[R] t i →ₗ[R] t' i) (x : Π i, s i) (y : Π i, t i) :
map₂ f (tprod R x) (tprod R y) = tprod R fun i ↦ f i (x i) (y i) := by
simp [map₂]
/--
Let `sᵢ`, `tᵢ` and `t'ᵢ` be families of `R`-modules.
Then there is a function from `⨂ᵢ Hom(sᵢ, Hom(tᵢ, t'ᵢ))` to `Hom(⨂ᵢ sᵢ, Hom(⨂ tᵢ, ⨂ᵢ t'ᵢ))`
defined by `⨂ᵢ fᵢ ↦ ⨂ᵢ aᵢ ↦ ⨂ᵢ bᵢ ↦ ⨂ᵢ fᵢ aᵢ bᵢ`. -/
def piTensorHomMapFun₂ : (⨂[R] i, s i →ₗ[R] t i →ₗ[R] t' i) →
(⨂[R] i, s i) →ₗ[R] (⨂[R] i, t i) →ₗ[R] (⨂[R] i, t' i) :=
fun φ => lift <| LinearMap.compMultilinearMap piTensorHomMap <|
(lift <| MultilinearMap.piLinearMap <| tprod R) φ
theorem piTensorHomMapFun₂_add (φ ψ : ⨂[R] i, s i →ₗ[R] t i →ₗ[R] t' i) :
piTensorHomMapFun₂ (φ + ψ) = piTensorHomMapFun₂ φ + piTensorHomMapFun₂ ψ := by
dsimp [piTensorHomMapFun₂]; ext; simp only [map_add, LinearMap.compMultilinearMap_apply,
lift.tprod, add_apply, LinearMap.add_apply]
| Mathlib/LinearAlgebra/PiTensorProduct.lean | 656 | 658 | theorem piTensorHomMapFun₂_smul (r : R) (φ : ⨂[R] i, s i →ₗ[R] t i →ₗ[R] t' i) :
piTensorHomMapFun₂ (r • φ) = r • piTensorHomMapFun₂ φ := by | dsimp [piTensorHomMapFun₂]; ext; simp only [map_smul, LinearMap.compMultilinearMap_apply, |
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.Perm.Option
import Mathlib.Logic.Equiv.Fin.Rotate
import Mathlib.Logic.Equiv.Fintype
/-!
# Permutations of `Fin n`
-/
assert_not_exists LinearMap
open Equiv
/-- Permutations of `Fin (n + 1)` are equivalent to fixing a single
`Fin (n + 1)` and permuting the remaining with a `Perm (Fin n)`.
The fixed `Fin (n + 1)` is swapped with `0`. -/
def Equiv.Perm.decomposeFin {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) :=
((Equiv.permCongr <| finSuccEquiv n).trans Equiv.Perm.decomposeOption).trans
(Equiv.prodCongr (finSuccEquiv n).symm (Equiv.refl _))
@[simp]
theorem Equiv.Perm.decomposeFin_symm_of_refl {n : ℕ} (p : Fin (n + 1)) :
Equiv.Perm.decomposeFin.symm (p, Equiv.refl _) = swap 0 p := by
simp [Equiv.Perm.decomposeFin, Equiv.permCongr_def]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_of_one {n : ℕ} (p : Fin (n + 1)) :
Equiv.Perm.decomposeFin.symm (p, 1) = swap 0 p :=
Equiv.Perm.decomposeFin_symm_of_refl p
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_zero {n : ℕ} (p : Fin (n + 1)) (e : Perm (Fin n)) :
Equiv.Perm.decomposeFin.symm (p, e) 0 = p := by simp [Equiv.Perm.decomposeFin]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_succ {n : ℕ} (e : Perm (Fin n)) (p : Fin (n + 1))
(x : Fin n) : Equiv.Perm.decomposeFin.symm (p, e) x.succ = swap 0 p (e x).succ := by
refine Fin.cases ?_ ?_ p
· simp [Equiv.Perm.decomposeFin, EquivFunctor.map]
· intro i
by_cases h : i = e x
· simp [h, Equiv.Perm.decomposeFin, EquivFunctor.map]
· simp [h, Equiv.Perm.decomposeFin, EquivFunctor.map, swap_apply_def, Ne.symm h]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_one {n : ℕ} (e : Perm (Fin (n + 1))) (p : Fin (n + 2)) :
Equiv.Perm.decomposeFin.symm (p, e) 1 = swap 0 p (e 0).succ := by
rw [← Fin.succ_zero_eq_one, Equiv.Perm.decomposeFin_symm_apply_succ e p 0]
@[simp]
theorem Equiv.Perm.decomposeFin.symm_sign {n : ℕ} (p : Fin (n + 1)) (e : Perm (Fin n)) :
Perm.sign (Equiv.Perm.decomposeFin.symm (p, e)) = ite (p = 0) 1 (-1) * Perm.sign e := by
refine Fin.cases ?_ ?_ p <;> simp [Equiv.Perm.decomposeFin]
/-- The set of all permutations of `Fin (n + 1)` can be constructed by augmenting the set of
permutations of `Fin n` by each element of `Fin (n + 1)` in turn. -/
theorem Finset.univ_perm_fin_succ {n : ℕ} :
@Finset.univ (Perm <| Fin n.succ) _ =
(Finset.univ : Finset <| Fin n.succ × Perm (Fin n)).map
Equiv.Perm.decomposeFin.symm.toEmbedding :=
(Finset.univ_map_equiv_to_embedding _).symm
section CycleRange
/-! ### `cycleRange` section
Define the permutations `Fin.cycleRange i`, the cycle `(0 1 2 ... i)`.
-/
open Equiv.Perm
theorem finRotate_succ_eq_decomposeFin {n : ℕ} :
finRotate n.succ = decomposeFin.symm (1, finRotate n) := by
ext i
cases n; · simp
refine Fin.cases ?_ (fun i => ?_) i
· simp
rw [coe_finRotate, decomposeFin_symm_apply_succ, if_congr i.succ_eq_last_succ rfl rfl]
split_ifs with h
· simp [h]
· rw [Fin.val_succ, Function.Injective.map_swap Fin.val_injective, Fin.val_succ, coe_finRotate,
if_neg h, Fin.val_zero, Fin.val_one,
swap_apply_of_ne_of_ne (Nat.succ_ne_zero _) (Nat.succ_succ_ne_one _)]
@[simp]
theorem sign_finRotate (n : ℕ) : Perm.sign (finRotate (n + 1)) = (-1) ^ n := by
induction n with
| zero => simp
| succ n ih =>
rw [finRotate_succ_eq_decomposeFin]
simp [ih, pow_succ]
@[simp]
theorem support_finRotate {n : ℕ} : support (finRotate (n + 2)) = Finset.univ := by
ext
simp
theorem support_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : support (finRotate n) = Finset.univ := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm, support_finRotate]
theorem isCycle_finRotate {n : ℕ} : IsCycle (finRotate (n + 2)) := by
refine ⟨0, by simp, fun x hx' => ⟨x, ?_⟩⟩
clear hx'
obtain ⟨x, hx⟩ := x
rw [zpow_natCast, Fin.ext_iff, Fin.val_mk]
induction' x with x ih; · rfl
rw [pow_succ', Perm.mul_apply, coe_finRotate_of_ne_last, ih (lt_trans x.lt_succ_self hx)]
rw [Ne, Fin.ext_iff, ih (lt_trans x.lt_succ_self hx), Fin.val_last]
exact ne_of_lt (Nat.lt_of_succ_lt_succ hx)
theorem isCycle_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : IsCycle (finRotate n) := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm]
exact isCycle_finRotate
@[simp]
theorem cycleType_finRotate {n : ℕ} : cycleType (finRotate (n + 2)) = {n + 2} := by
rw [isCycle_finRotate.cycleType, support_finRotate, ← Fintype.card, Fintype.card_fin]
theorem cycleType_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : cycleType (finRotate n) = {n} := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm, cycleType_finRotate]
namespace Fin
/-- `Fin.cycleRange i` is the cycle `(0 1 2 ... i)` leaving `(i+1 ... (n-1))` unchanged. -/
def cycleRange {n : ℕ} (i : Fin n) : Perm (Fin n) :=
(finRotate (i + 1)).extendDomain
(Equiv.ofLeftInverse' (Fin.castLEEmb (Nat.succ_le_of_lt i.is_lt)) (↑)
(by
intro x
ext
simp))
theorem cycleRange_of_gt {n : ℕ} {i j : Fin n} (h : i < j) : cycleRange i j = j := by
rw [cycleRange, ofLeftInverse'_eq_ofInjective,
← Function.Embedding.toEquivRange_eq_ofInjective, ← viaFintypeEmbedding,
viaFintypeEmbedding_apply_not_mem_range]
simpa
theorem cycleRange_of_le {n : ℕ} [NeZero n] {i j : Fin n} (h : j ≤ i) :
cycleRange i j = if j = i then 0 else j + 1 := by
cases n
· subsingleton
have : j = (Fin.castLE (Nat.succ_le_of_lt i.is_lt))
⟨j, lt_of_le_of_lt h (Nat.lt_succ_self i)⟩ := by simp
ext
rw [this, cycleRange, ofLeftInverse'_eq_ofInjective, ←
Function.Embedding.toEquivRange_eq_ofInjective, ← viaFintypeEmbedding, ← coe_castLEEmb,
viaFintypeEmbedding_apply_image, coe_castLEEmb, coe_castLE, coe_finRotate]
simp only [Fin.ext_iff, val_last, val_mk, val_zero, Fin.eta, castLE_mk]
split_ifs with heq
· rfl
· rw [Fin.val_add_one_of_lt]
exact lt_of_lt_of_le (lt_of_le_of_ne h (mt (congr_arg _) heq)) (le_last i)
theorem coe_cycleRange_of_le {n : ℕ} {i j : Fin n} (h : j ≤ i) :
(cycleRange i j : ℕ) = if j = i then 0 else (j : ℕ) + 1 := by
rcases n with - | n
· exact absurd le_rfl i.pos.not_le
rw [cycleRange_of_le h]
split_ifs with h'
· rfl
exact
val_add_one_of_lt
(calc
(j : ℕ) < i := Fin.lt_iff_val_lt_val.mp (lt_of_le_of_ne h h')
_ ≤ n := Nat.lt_succ_iff.mp i.2)
theorem cycleRange_of_lt {n : ℕ} [NeZero n] {i j : Fin n} (h : j < i) : cycleRange i j = j + 1 := by
rw [cycleRange_of_le h.le, if_neg h.ne]
theorem coe_cycleRange_of_lt {n : ℕ} {i j : Fin n} (h : j < i) :
(cycleRange i j : ℕ) = j + 1 := by rw [coe_cycleRange_of_le h.le, if_neg h.ne]
theorem cycleRange_of_eq {n : ℕ} [NeZero n] {i j : Fin n} (h : j = i) : cycleRange i j = 0 := by
rw [cycleRange_of_le h.le, if_pos h]
@[simp]
theorem cycleRange_self {n : ℕ} [NeZero n] (i : Fin n) : cycleRange i i = 0 :=
cycleRange_of_eq rfl
theorem cycleRange_apply {n : ℕ} [NeZero n] (i j : Fin n) :
cycleRange i j = if j < i then j + 1 else if j = i then 0 else j := by
split_ifs with h₁ h₂
· exact cycleRange_of_lt h₁
· exact cycleRange_of_eq h₂
· exact cycleRange_of_gt (lt_of_le_of_ne (le_of_not_gt h₁) (Ne.symm h₂))
@[simp]
theorem cycleRange_zero (n : ℕ) [NeZero n] : cycleRange (0 : Fin n) = 1 := by
ext j
rcases (Fin.zero_le' j).eq_or_lt with rfl | hj
· simp
· rw [cycleRange_of_gt hj, one_apply]
@[simp]
theorem cycleRange_last (n : ℕ) : cycleRange (last n) = finRotate (n + 1) := by
ext i
rw [coe_cycleRange_of_le (le_last _), coe_finRotate]
@[simp]
theorem cycleRange_mk_zero {n : ℕ} (h : 0 < n) : cycleRange ⟨0, h⟩ = 1 :=
have : NeZero n := .of_pos h
cycleRange_zero n
@[deprecated (since := "2025-01-28")]
alias cycleRange_zero' := cycleRange_mk_zero
@[simp]
theorem sign_cycleRange {n : ℕ} (i : Fin n) : Perm.sign (cycleRange i) = (-1) ^ (i : ℕ) := by
simp [cycleRange]
@[simp]
| Mathlib/GroupTheory/Perm/Fin.lean | 222 | 227 | theorem succAbove_cycleRange {n : ℕ} (i j : Fin n) :
i.succ.succAbove (i.cycleRange j) = swap 0 i.succ j.succ := by | cases n
· rcases j with ⟨_, ⟨⟩⟩
rcases lt_trichotomy j i with (hlt | heq | hgt)
· have : castSucc (j + 1) = j.succ := by |
/-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.Convex.Function
import Mathlib.Analysis.Convex.StrictConvexSpace
import Mathlib.MeasureTheory.Function.AEEqOfIntegral
import Mathlib.MeasureTheory.Integral.Average
/-!
# Jensen's inequality for integrals
In this file we prove several forms of Jensen's inequality for integrals.
- for convex sets: `Convex.average_mem`, `Convex.set_average_mem`, `Convex.integral_mem`;
- for convex functions: `ConvexOn.average_mem_epigraph`, `ConvexOn.map_average_le`,
`ConvexOn.set_average_mem_epigraph`, `ConvexOn.map_set_average_le`, `ConvexOn.map_integral_le`;
- for strictly convex sets: `StrictConvex.ae_eq_const_or_average_mem_interior`;
- for a closed ball in a strictly convex normed space:
`ae_eq_const_or_norm_integral_lt_of_norm_le_const`;
- for strictly convex functions: `StrictConvexOn.ae_eq_const_or_map_average_lt`.
## TODO
- Use a typeclass for strict convexity of a closed ball.
## Tags
convex, integral, center mass, average value, Jensen's inequality
-/
open MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
open scoped Topology ENNReal Convex
variable {α E : Type*} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
[CompleteSpace E] {μ : Measure α} {s : Set E} {t : Set α} {f : α → E} {g : E → ℝ} {C : ℝ}
/-!
### Non-strict Jensen's inequality
-/
/-- If `μ` is a probability measure on `α`, `s` is a convex closed set in `E`, and `f` is an
integrable function sending `μ`-a.e. points to `s`, then the expected value of `f` belongs to `s`:
`∫ x, f x ∂μ ∈ s`. See also `Convex.sum_mem` for a finite sum version of this lemma. -/
theorem Convex.integral_mem [IsProbabilityMeasure μ] (hs : Convex ℝ s) (hsc : IsClosed s)
(hf : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ) : (∫ x, f x ∂μ) ∈ s := by
borelize E
rcases hfi.aestronglyMeasurable with ⟨g, hgm, hfg⟩
haveI : SeparableSpace (range g ∩ s : Set E) :=
(hgm.isSeparable_range.mono inter_subset_left).separableSpace
obtain ⟨y₀, h₀⟩ : (range g ∩ s).Nonempty := by
rcases (hf.and hfg).exists with ⟨x₀, h₀⟩
exact ⟨f x₀, by simp only [h₀.2, mem_range_self], h₀.1⟩
rw [integral_congr_ae hfg]; rw [integrable_congr hfg] at hfi
have hg : ∀ᵐ x ∂μ, g x ∈ closure (range g ∩ s) := by
filter_upwards [hfg.rw (fun _ y => y ∈ s) hf] with x hx
apply subset_closure
exact ⟨mem_range_self _, hx⟩
set G : ℕ → SimpleFunc α E := SimpleFunc.approxOn _ hgm.measurable (range g ∩ s) y₀ h₀
have : Tendsto (fun n => (G n).integral μ) atTop (𝓝 <| ∫ x, g x ∂μ) :=
tendsto_integral_approxOn_of_measurable hfi _ hg _ (integrable_const _)
refine hsc.mem_of_tendsto this (Eventually.of_forall fun n => hs.sum_mem ?_ ?_ ?_)
· exact fun _ _ => ENNReal.toReal_nonneg
· simp_rw [measureReal_def]
rw [← ENNReal.toReal_sum, (G n).sum_range_measure_preimage_singleton, measure_univ,
ENNReal.toReal_one]
exact fun _ _ => measure_ne_top _ _
· simp only [SimpleFunc.mem_range, forall_mem_range]
intro x
apply (range g).inter_subset_right
exact SimpleFunc.approxOn_mem hgm.measurable h₀ _ _
/-- If `μ` is a non-zero finite measure on `α`, `s` is a convex closed set in `E`, and `f` is an
integrable function sending `μ`-a.e. points to `s`, then the average value of `f` belongs to `s`:
`⨍ x, f x ∂μ ∈ s`. See also `Convex.centerMass_mem` for a finite sum version of this lemma. -/
theorem Convex.average_mem [IsFiniteMeasure μ] [NeZero μ] (hs : Convex ℝ s) (hsc : IsClosed s)
(hfs : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ) : (⨍ x, f x ∂μ) ∈ s :=
hs.integral_mem hsc (ae_mono' smul_absolutelyContinuous hfs) hfi.to_average
/-- If `μ` is a non-zero finite measure on `α`, `s` is a convex closed set in `E`, and `f` is an
integrable function sending `μ`-a.e. points to `s`, then the average value of `f` belongs to `s`:
`⨍ x, f x ∂μ ∈ s`. See also `Convex.centerMass_mem` for a finite sum version of this lemma. -/
theorem Convex.set_average_mem (hs : Convex ℝ s) (hsc : IsClosed s) (h0 : μ t ≠ 0) (ht : μ t ≠ ∞)
(hfs : ∀ᵐ x ∂μ.restrict t, f x ∈ s) (hfi : IntegrableOn f t μ) : (⨍ x in t, f x ∂μ) ∈ s :=
have := Fact.mk ht.lt_top
have := NeZero.mk h0
hs.average_mem hsc hfs hfi
/-- If `μ` is a non-zero finite measure on `α`, `s` is a convex set in `E`, and `f` is an integrable
function sending `μ`-a.e. points to `s`, then the average value of `f` belongs to `closure s`:
`⨍ x, f x ∂μ ∈ s`. See also `Convex.centerMass_mem` for a finite sum version of this lemma. -/
theorem Convex.set_average_mem_closure (hs : Convex ℝ s) (h0 : μ t ≠ 0) (ht : μ t ≠ ∞)
(hfs : ∀ᵐ x ∂μ.restrict t, f x ∈ s) (hfi : IntegrableOn f t μ) :
(⨍ x in t, f x ∂μ) ∈ closure s :=
hs.closure.set_average_mem isClosed_closure h0 ht (hfs.mono fun _ hx => subset_closure hx) hfi
theorem ConvexOn.average_mem_epigraph [IsFiniteMeasure μ] [NeZero μ] (hg : ConvexOn ℝ s g)
(hgc : ContinuousOn g s) (hsc : IsClosed s) (hfs : ∀ᵐ x ∂μ, f x ∈ s)
(hfi : Integrable f μ) (hgi : Integrable (g ∘ f) μ) :
(⨍ x, f x ∂μ, ⨍ x, g (f x) ∂μ) ∈ {p : E × ℝ | p.1 ∈ s ∧ g p.1 ≤ p.2} := by
have ht_mem : ∀ᵐ x ∂μ, (f x, g (f x)) ∈ {p : E × ℝ | p.1 ∈ s ∧ g p.1 ≤ p.2} :=
hfs.mono fun x hx => ⟨hx, le_rfl⟩
exact average_pair hfi hgi ▸
hg.convex_epigraph.average_mem (hsc.epigraph hgc) ht_mem (hfi.prodMk hgi)
theorem ConcaveOn.average_mem_hypograph [IsFiniteMeasure μ] [NeZero μ] (hg : ConcaveOn ℝ s g)
(hgc : ContinuousOn g s) (hsc : IsClosed s) (hfs : ∀ᵐ x ∂μ, f x ∈ s)
(hfi : Integrable f μ) (hgi : Integrable (g ∘ f) μ) :
(⨍ x, f x ∂μ, ⨍ x, g (f x) ∂μ) ∈ {p : E × ℝ | p.1 ∈ s ∧ p.2 ≤ g p.1} := by
simpa only [mem_setOf_eq, Pi.neg_apply, average_neg, neg_le_neg_iff] using
hg.neg.average_mem_epigraph hgc.neg hsc hfs hfi hgi.neg
/-- **Jensen's inequality**: if a function `g : E → ℝ` is convex and continuous on a convex closed
set `s`, `μ` is a finite non-zero measure on `α`, and `f : α → E` is a function sending
`μ`-a.e. points to `s`, then the value of `g` at the average value of `f` is less than or equal to
the average value of `g ∘ f` provided that both `f` and `g ∘ f` are integrable. See also
`ConvexOn.map_centerMass_le` for a finite sum version of this lemma. -/
theorem ConvexOn.map_average_le [IsFiniteMeasure μ] [NeZero μ]
(hg : ConvexOn ℝ s g) (hgc : ContinuousOn g s) (hsc : IsClosed s)
(hfs : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ) (hgi : Integrable (g ∘ f) μ) :
g (⨍ x, f x ∂μ) ≤ ⨍ x, g (f x) ∂μ :=
(hg.average_mem_epigraph hgc hsc hfs hfi hgi).2
/-- **Jensen's inequality**: if a function `g : E → ℝ` is concave and continuous on a convex closed
set `s`, `μ` is a finite non-zero measure on `α`, and `f : α → E` is a function sending
`μ`-a.e. points to `s`, then the average value of `g ∘ f` is less than or equal to the value of `g`
at the average value of `f` provided that both `f` and `g ∘ f` are integrable. See also
`ConcaveOn.le_map_centerMass` for a finite sum version of this lemma. -/
theorem ConcaveOn.le_map_average [IsFiniteMeasure μ] [NeZero μ]
(hg : ConcaveOn ℝ s g) (hgc : ContinuousOn g s) (hsc : IsClosed s)
(hfs : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ) (hgi : Integrable (g ∘ f) μ) :
(⨍ x, g (f x) ∂μ) ≤ g (⨍ x, f x ∂μ) :=
(hg.average_mem_hypograph hgc hsc hfs hfi hgi).2
/-- **Jensen's inequality**: if a function `g : E → ℝ` is convex and continuous on a convex closed
set `s`, `μ` is a finite non-zero measure on `α`, and `f : α → E` is a function sending
`μ`-a.e. points of a set `t` to `s`, then the value of `g` at the average value of `f` over `t` is
less than or equal to the average value of `g ∘ f` over `t` provided that both `f` and `g ∘ f` are
integrable. -/
theorem ConvexOn.set_average_mem_epigraph (hg : ConvexOn ℝ s g) (hgc : ContinuousOn g s)
(hsc : IsClosed s) (h0 : μ t ≠ 0) (ht : μ t ≠ ∞) (hfs : ∀ᵐ x ∂μ.restrict t, f x ∈ s)
(hfi : IntegrableOn f t μ) (hgi : IntegrableOn (g ∘ f) t μ) :
(⨍ x in t, f x ∂μ, ⨍ x in t, g (f x) ∂μ) ∈ {p : E × ℝ | p.1 ∈ s ∧ g p.1 ≤ p.2} :=
have := Fact.mk ht.lt_top
have := NeZero.mk h0
hg.average_mem_epigraph hgc hsc hfs hfi hgi
/-- **Jensen's inequality**: if a function `g : E → ℝ` is concave and continuous on a convex closed
set `s`, `μ` is a finite non-zero measure on `α`, and `f : α → E` is a function sending
`μ`-a.e. points of a set `t` to `s`, then the average value of `g ∘ f` over `t` is less than or
equal to the value of `g` at the average value of `f` over `t` provided that both `f` and `g ∘ f`
are integrable. -/
theorem ConcaveOn.set_average_mem_hypograph (hg : ConcaveOn ℝ s g) (hgc : ContinuousOn g s)
(hsc : IsClosed s) (h0 : μ t ≠ 0) (ht : μ t ≠ ∞) (hfs : ∀ᵐ x ∂μ.restrict t, f x ∈ s)
(hfi : IntegrableOn f t μ) (hgi : IntegrableOn (g ∘ f) t μ) :
(⨍ x in t, f x ∂μ, ⨍ x in t, g (f x) ∂μ) ∈ {p : E × ℝ | p.1 ∈ s ∧ p.2 ≤ g p.1} := by
simpa only [mem_setOf_eq, Pi.neg_apply, average_neg, neg_le_neg_iff] using
hg.neg.set_average_mem_epigraph hgc.neg hsc h0 ht hfs hfi hgi.neg
/-- **Jensen's inequality**: if a function `g : E → ℝ` is convex and continuous on a convex closed
set `s`, `μ` is a finite non-zero measure on `α`, and `f : α → E` is a function sending
`μ`-a.e. points of a set `t` to `s`, then the value of `g` at the average value of `f` over `t` is
less than or equal to the average value of `g ∘ f` over `t` provided that both `f` and `g ∘ f` are
integrable. -/
theorem ConvexOn.map_set_average_le (hg : ConvexOn ℝ s g) (hgc : ContinuousOn g s)
(hsc : IsClosed s) (h0 : μ t ≠ 0) (ht : μ t ≠ ∞) (hfs : ∀ᵐ x ∂μ.restrict t, f x ∈ s)
(hfi : IntegrableOn f t μ) (hgi : IntegrableOn (g ∘ f) t μ) :
g (⨍ x in t, f x ∂μ) ≤ ⨍ x in t, g (f x) ∂μ :=
(hg.set_average_mem_epigraph hgc hsc h0 ht hfs hfi hgi).2
/-- **Jensen's inequality**: if a function `g : E → ℝ` is concave and continuous on a convex closed
set `s`, `μ` is a finite non-zero measure on `α`, and `f : α → E` is a function sending
`μ`-a.e. points of a set `t` to `s`, then the average value of `g ∘ f` over `t` is less than or
equal to the value of `g` at the average value of `f` over `t` provided that both `f` and `g ∘ f`
are integrable. -/
theorem ConcaveOn.le_map_set_average (hg : ConcaveOn ℝ s g) (hgc : ContinuousOn g s)
(hsc : IsClosed s) (h0 : μ t ≠ 0) (ht : μ t ≠ ∞) (hfs : ∀ᵐ x ∂μ.restrict t, f x ∈ s)
(hfi : IntegrableOn f t μ) (hgi : IntegrableOn (g ∘ f) t μ) :
(⨍ x in t, g (f x) ∂μ) ≤ g (⨍ x in t, f x ∂μ) :=
(hg.set_average_mem_hypograph hgc hsc h0 ht hfs hfi hgi).2
/-- **Jensen's inequality**: if a function `g : E → ℝ` is convex and continuous on a convex closed
set `s`, `μ` is a probability measure on `α`, and `f : α → E` is a function sending `μ`-a.e. points
to `s`, then the value of `g` at the expected value of `f` is less than or equal to the expected
value of `g ∘ f` provided that both `f` and `g ∘ f` are integrable. See also
`ConvexOn.map_centerMass_le` for a finite sum version of this lemma. -/
theorem ConvexOn.map_integral_le [IsProbabilityMeasure μ] (hg : ConvexOn ℝ s g)
(hgc : ContinuousOn g s) (hsc : IsClosed s) (hfs : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ)
(hgi : Integrable (g ∘ f) μ) : g (∫ x, f x ∂μ) ≤ ∫ x, g (f x) ∂μ := by
simpa only [average_eq_integral] using hg.map_average_le hgc hsc hfs hfi hgi
/-- **Jensen's inequality**: if a function `g : E → ℝ` is concave and continuous on a convex closed
set `s`, `μ` is a probability measure on `α`, and `f : α → E` is a function sending `μ`-a.e. points
to `s`, then the expected value of `g ∘ f` is less than or equal to the value of `g` at the expected
value of `f` provided that both `f` and `g ∘ f` are integrable. -/
theorem ConcaveOn.le_map_integral [IsProbabilityMeasure μ] (hg : ConcaveOn ℝ s g)
(hgc : ContinuousOn g s) (hsc : IsClosed s) (hfs : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ)
(hgi : Integrable (g ∘ f) μ) : (∫ x, g (f x) ∂μ) ≤ g (∫ x, f x ∂μ) := by
simpa only [average_eq_integral] using hg.le_map_average hgc hsc hfs hfi hgi
/-!
### Strict Jensen's inequality
-/
/-- If `f : α → E` is an integrable function, then either it is a.e. equal to the constant
`⨍ x, f x ∂μ` or there exists a measurable set such that `μ t ≠ 0`, `μ tᶜ ≠ 0`, and the average
values of `f` over `t` and `tᶜ` are different. -/
theorem ae_eq_const_or_exists_average_ne_compl [IsFiniteMeasure μ] (hfi : Integrable f μ) :
f =ᵐ[μ] const α (⨍ x, f x ∂μ) ∨
∃ t, MeasurableSet t ∧ μ t ≠ 0 ∧ μ tᶜ ≠ 0 ∧ (⨍ x in t, f x ∂μ) ≠ ⨍ x in tᶜ, f x ∂μ := by
refine or_iff_not_imp_right.mpr fun H => ?_; push_neg at H
refine hfi.ae_eq_of_forall_setIntegral_eq _ _ (integrable_const _) fun t ht ht' => ?_; clear ht'
simp only [const_apply, setIntegral_const]
by_cases h₀ : μ t = 0
· rw [restrict_eq_zero.2 h₀, integral_zero_measure, measureReal_def, h₀,
ENNReal.toReal_zero, zero_smul]
by_cases h₀' : μ tᶜ = 0
· rw [← ae_eq_univ] at h₀'
rw [restrict_congr_set h₀', restrict_univ, measureReal_congr h₀', measure_smul_average]
have := average_mem_openSegment_compl_self ht.nullMeasurableSet h₀ h₀' hfi
rw [← H t ht h₀ h₀', openSegment_same, mem_singleton_iff] at this
rw [this, measure_smul_setAverage _ (measure_ne_top μ _)]
/-- If an integrable function `f : α → E` takes values in a convex set `s` and for some set `t` of
positive measure, the average value of `f` over `t` belongs to the interior of `s`, then the average
of `f` over the whole space belongs to the interior of `s`. -/
theorem Convex.average_mem_interior_of_set [IsFiniteMeasure μ] (hs : Convex ℝ s) (h0 : μ t ≠ 0)
(hfs : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ) (ht : (⨍ x in t, f x ∂μ) ∈ interior s) :
(⨍ x, f x ∂μ) ∈ interior s := by
rw [← measure_toMeasurable] at h0; rw [← restrict_toMeasurable (measure_ne_top μ t)] at ht
by_cases h0' : μ (toMeasurable μ t)ᶜ = 0
· rw [← ae_eq_univ] at h0'
rwa [restrict_congr_set h0', restrict_univ] at ht
exact
hs.openSegment_interior_closure_subset_interior ht
(hs.set_average_mem_closure h0' (measure_ne_top _ _) (ae_restrict_of_ae hfs)
hfi.integrableOn)
(average_mem_openSegment_compl_self (measurableSet_toMeasurable μ t).nullMeasurableSet h0
h0' hfi)
/-- If an integrable function `f : α → E` takes values in a strictly convex closed set `s`, then
either it is a.e. equal to its average value, or its average value belongs to the interior of
`s`. -/
| Mathlib/Analysis/Convex/Integral.lean | 253 | 265 | theorem StrictConvex.ae_eq_const_or_average_mem_interior [IsFiniteMeasure μ] (hs : StrictConvex ℝ s)
(hsc : IsClosed s) (hfs : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ) :
f =ᵐ[μ] const α (⨍ x, f x ∂μ) ∨ (⨍ x, f x ∂μ) ∈ interior s := by | have : ∀ {t}, μ t ≠ 0 → (⨍ x in t, f x ∂μ) ∈ s := fun ht =>
hs.convex.set_average_mem hsc ht (measure_ne_top _ _) (ae_restrict_of_ae hfs) hfi.integrableOn
refine (ae_eq_const_or_exists_average_ne_compl hfi).imp_right ?_
rintro ⟨t, hm, h₀, h₀', hne⟩
exact
hs.openSegment_subset (this h₀) (this h₀') hne
(average_mem_openSegment_compl_self hm.nullMeasurableSet h₀ h₀' hfi)
/-- **Jensen's inequality**, strict version: if an integrable function `f : α → E` takes values in a
convex closed set `s`, and `g : E → ℝ` is continuous and strictly convex on `s`, then |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fin.Fin2
import Mathlib.Util.Notation3
import Mathlib.Tactic.TypeStar
/-!
# Alternate definition of `Vector` in terms of `Fin2`
This file provides a locale `Vector3` which overrides the `[a, b, c]` notation to create a `Vector3`
instead of a `List`.
The `::` notation is also overloaded by this file to mean `Vector3.cons`.
-/
open Fin2 Nat
universe u
variable {α : Type*} {m n : ℕ}
/-- Alternate definition of `Vector` based on `Fin2`. -/
def Vector3 (α : Type u) (n : ℕ) : Type u :=
Fin2 n → α
instance [Inhabited α] : Inhabited (Vector3 α n) where
default := fun _ => default
namespace Vector3
/-- The empty vector -/
@[match_pattern]
def nil : Vector3 α 0 :=
nofun
/-- The vector cons operation -/
@[match_pattern]
def cons (a : α) (v : Vector3 α n) : Vector3 α (n + 1) := fun i => by
refine i.cases' ?_ ?_
· exact a
· exact v
section
open Lean
scoped macro_rules | `([$l,*]) => `(expand_foldr% (h t => cons h t) nil [$(.ofElems l),*])
-- this is copied from `src/Init/NotationExtra.lean`
/-- Unexpander for `Vector3.nil` -/
@[app_unexpander Vector3.nil] def unexpandNil : Lean.PrettyPrinter.Unexpander
| `($(_)) => `([])
-- this is copied from `src/Init/NotationExtra.lean`
/-- Unexpander for `Vector3.cons` -/
@[app_unexpander Vector3.cons] def unexpandCons : Lean.PrettyPrinter.Unexpander
| `($(_) $x []) => `([$x])
| `($(_) $x [$xs,*]) => `([$x, $xs,*])
| _ => throw ()
end
-- Overloading the usual `::` notation for `List.cons` with `Vector3.cons`.
@[inherit_doc]
scoped notation a " :: " b => cons a b
@[simp]
theorem cons_fz (a : α) (v : Vector3 α n) : (a :: v) fz = a :=
rfl
@[simp]
theorem cons_fs (a : α) (v : Vector3 α n) (i) : (a :: v) (fs i) = v i :=
rfl
/-- Get the `i`th element of a vector -/
abbrev nth (i : Fin2 n) (v : Vector3 α n) : α :=
v i
/-- Construct a vector from a function on `Fin2`. -/
abbrev ofFn (f : Fin2 n → α) : Vector3 α n :=
f
/-- Get the head of a nonempty vector. -/
def head (v : Vector3 α (n + 1)) : α :=
v fz
/-- Get the tail of a nonempty vector. -/
def tail (v : Vector3 α (n + 1)) : Vector3 α n := fun i => v (fs i)
theorem eq_nil (v : Vector3 α 0) : v = [] :=
funext fun i => nomatch i
theorem cons_head_tail (v : Vector3 α (n + 1)) : (head v :: tail v) = v :=
funext fun i => Fin2.cases' rfl (fun _ => rfl) i
/-- Eliminator for an empty vector. -/
@[elab_as_elim]
def nilElim {C : Vector3 α 0 → Sort u} (H : C []) (v : Vector3 α 0) : C v := by
rw [eq_nil v]; apply H
/-- Recursion principle for a nonempty vector. -/
@[elab_as_elim]
def consElim {C : Vector3 α (n + 1) → Sort u} (H : ∀ (a : α) (t : Vector3 α n), C (a :: t))
(v : Vector3 α (n + 1)) : C v := by rw [← cons_head_tail v]; apply H
@[simp]
theorem consElim_cons {C H a t} : @consElim α n C H (a :: t) = H a t :=
rfl
/-- Recursion principle with the vector as first argument. -/
@[elab_as_elim]
protected def recOn {C : ∀ {n}, Vector3 α n → Sort u} {n} (v : Vector3 α n) (H0 : C [])
(Hs : ∀ {n} (a) (w : Vector3 α n), C w → C (a :: w)) : C v :=
match n with
| 0 => v.nilElim H0
| _ + 1 => v.consElim fun a t => Hs a t (Vector3.recOn t H0 Hs)
@[simp]
theorem recOn_nil {C H0 Hs} : @Vector3.recOn α (@C) 0 [] H0 @Hs = H0 :=
rfl
@[simp]
theorem recOn_cons {C H0 Hs n a v} :
@Vector3.recOn α (@C) (n + 1) (a :: v) H0 @Hs = Hs a v (@Vector3.recOn α (@C) n v H0 @Hs) :=
rfl
/-- Append two vectors -/
def append (v : Vector3 α m) (w : Vector3 α n) : Vector3 α (n + m) :=
v.recOn w (fun a _ IH => a :: IH)
/--
A local infix notation for `Vector3.append`
-/
local infixl:65 " +-+ " => Vector3.append
@[simp]
theorem append_nil (w : Vector3 α n) : [] +-+ w = w :=
rfl
@[simp]
theorem append_cons (a : α) (v : Vector3 α m) (w : Vector3 α n) : (a :: v) +-+ w = a :: v +-+ w :=
rfl
@[simp]
theorem append_left :
∀ {m} (i : Fin2 m) (v : Vector3 α m) {n} (w : Vector3 α n), (v +-+ w) (left n i) = v i
| _, @fz m, v, _, _ => v.consElim fun a _t => by simp [*, left]
| _, @fs m i, v, n, w => v.consElim fun _a t => by simp [append_left, left]
@[simp]
theorem append_add :
∀ {m} (v : Vector3 α m) {n} (w : Vector3 α n) (i : Fin2 n), (v +-+ w) (add i m) = w i
| 0, _, _, _, _ => rfl
| m + 1, v, n, w, i => v.consElim fun _a t => by simp [append_add, add]
/-- Insert `a` into `v` at index `i`. -/
def insert (a : α) (v : Vector3 α n) (i : Fin2 (n + 1)) : Vector3 α (n + 1) := fun j =>
(a :: v) (insertPerm i j)
@[simp]
theorem insert_fz (a : α) (v : Vector3 α n) : insert a v fz = a :: v := by
refine funext fun j => j.cases' ?_ ?_ <;> intros <;> rfl
@[simp]
theorem insert_fs (a : α) (b : α) (v : Vector3 α n) (i : Fin2 (n + 1)) :
insert a (b :: v) (fs i) = b :: insert a v i :=
funext fun j => by
refine j.cases' ?_ fun j => ?_ <;> simp [insert, insertPerm]
refine Fin2.cases' ?_ ?_ (insertPerm i j) <;> simp [insertPerm]
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (n + 1))
(e : (n + 1) + m = (n + m) + 1) :
insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
refine Vector3.recOn t (fun e => ?_) (@fun k b t IH _ => ?_) e
· rfl
have e' : (n + 1) + k = (n + k) + 1 := by omega
change
insert a (b :: t +-+ v)
(Eq.recOn (congr_arg (· + 1) e' : _ + 1 = _) (fs (add i k))) =
Eq.recOn (congr_arg (· + 1) e' : _ + 1 = _) (b :: t +-+ insert a v i)
rw [← (Eq.recOn e' rfl :
fs (Eq.recOn e' (i.add k) : Fin2 ((n + k) + 1)) =
Eq.recOn (congr_arg (· + 1) e' : _ + 1 = _) (fs (i.add k)))]
simpa [IH] using Eq.recOn e' rfl
end Vector3
section Vector3
open Vector3
/-- "Curried" exists, i.e. `∃ x₁ ... xₙ, f [x₁, ..., xₙ]`. -/
def VectorEx : ∀ k, (Vector3 α k → Prop) → Prop
| 0, f => f []
| succ k, f => ∃ x : α, VectorEx k fun v => f (x :: v)
/-- "Curried" forall, i.e. `∀ x₁ ... xₙ, f [x₁, ..., xₙ]`. -/
def VectorAll : ∀ k, (Vector3 α k → Prop) → Prop
| 0, f => f []
| succ k, f => ∀ x : α, VectorAll k fun v => f (x :: v)
theorem exists_vector_zero (f : Vector3 α 0 → Prop) : Exists f ↔ f [] :=
⟨fun ⟨v, fv⟩ => by rw [← eq_nil v]; exact fv, fun f0 => ⟨[], f0⟩⟩
theorem exists_vector_succ (f : Vector3 α (succ n) → Prop) : Exists f ↔ ∃ x v, f (x :: v) :=
⟨fun ⟨v, fv⟩ => ⟨_, _, by rw [cons_head_tail v]; exact fv⟩, fun ⟨_, _, fxv⟩ => ⟨_, fxv⟩⟩
theorem vectorEx_iff_exists : ∀ {n} (f : Vector3 α n → Prop), VectorEx n f ↔ Exists f
| 0, f => (exists_vector_zero f).symm
| succ _, f =>
Iff.trans (exists_congr fun _ => vectorEx_iff_exists _) (exists_vector_succ f).symm
theorem vectorAll_iff_forall : ∀ {n} (f : Vector3 α n → Prop), VectorAll n f ↔ ∀ v, f v
| 0, _ => ⟨fun f0 v => v.nilElim f0, fun al => al []⟩
| succ _, f =>
(forall_congr' fun x => vectorAll_iff_forall fun v => f (x :: v)).trans
⟨fun al v => v.consElim al, fun al x v => al (x :: v)⟩
/-- `VectorAllP p v` is equivalent to `∀ i, p (v i)`, but unfolds directly to a conjunction,
i.e. `VectorAllP p [0, 1, 2] = p 0 ∧ p 1 ∧ p 2`. -/
def VectorAllP (p : α → Prop) (v : Vector3 α n) : Prop :=
Vector3.recOn v True fun a v IH =>
@Vector3.recOn _ (fun _ => Prop) _ v (p a) fun _ _ _ => p a ∧ IH
@[simp]
theorem vectorAllP_nil (p : α → Prop) : VectorAllP p [] = True :=
rfl
@[simp]
theorem vectorAllP_singleton (p : α → Prop) (x : α) : VectorAllP p (cons x []) = p x :=
rfl
@[simp]
theorem vectorAllP_cons (p : α → Prop) (x : α) (v : Vector3 α n) :
VectorAllP p (x :: v) ↔ p x ∧ VectorAllP p v :=
Vector3.recOn v (iff_of_eq (and_true _)).symm fun _ _ _ => Iff.rfl
| Mathlib/Data/Vector3.lean | 240 | 241 | theorem vectorAllP_iff_forall (p : α → Prop) (v : Vector3 α n) :
VectorAllP p v ↔ ∀ i, p (v i) := by | |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.Diagonal
import Mathlib.LinearAlgebra.Matrix.Transvection
import Mathlib.MeasureTheory.Group.LIntegral
import Mathlib.MeasureTheory.Integral.Marginal
import Mathlib.MeasureTheory.Measure.Stieltjes
import Mathlib.MeasureTheory.Measure.Haar.OfBasis
/-!
# Lebesgue measure on the real line and on `ℝⁿ`
We show that the Lebesgue measure on the real line (constructed as a particular case of additive
Haar measure on inner product spaces) coincides with the Stieltjes measure associated
to the function `x ↦ x`. We deduce properties of this measure on `ℝ`, and then of the product
Lebesgue measure on `ℝⁿ`. In particular, we prove that they are translation invariant.
We show that, on `ℝⁿ`, a linear map acts on Lebesgue measure by rescaling it through the absolute
value of its determinant, in `Real.map_linearMap_volume_pi_eq_smul_volume_pi`.
More properties of the Lebesgue measure are deduced from this in
`Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean`, where they are proved more generally for any
additive Haar measure on a finite-dimensional real vector space.
-/
assert_not_exists MeasureTheory.integral
noncomputable section
open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace
open ENNReal (ofReal)
open scoped ENNReal NNReal Topology
/-!
### Definition of the Lebesgue measure and lengths of intervals
-/
namespace Real
variable {ι : Type*} [Fintype ι]
/-- The volume on the real line (as a particular case of the volume on a finite-dimensional
inner product space) coincides with the Stieltjes measure coming from the identity function. -/
theorem volume_eq_stieltjes_id : (volume : Measure ℝ) = StieltjesFunction.id.measure := by
haveI : IsAddLeftInvariant StieltjesFunction.id.measure :=
⟨fun a =>
Eq.symm <|
Real.measure_ext_Ioo_rat fun p q => by
simp only [Measure.map_apply (measurable_const_add a) measurableSet_Ioo,
sub_sub_sub_cancel_right, StieltjesFunction.measure_Ioo, StieltjesFunction.id_leftLim,
StieltjesFunction.id_apply, id, preimage_const_add_Ioo]⟩
have A : StieltjesFunction.id.measure (stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped = 1 := by
change StieltjesFunction.id.measure (parallelepiped (stdOrthonormalBasis ℝ ℝ)) = 1
rcases parallelepiped_orthonormalBasis_one_dim (stdOrthonormalBasis ℝ ℝ) with (H | H) <;>
simp only [H, StieltjesFunction.measure_Icc, StieltjesFunction.id_apply, id, tsub_zero,
StieltjesFunction.id_leftLim, sub_neg_eq_add, zero_add, ENNReal.ofReal_one]
conv_rhs =>
rw [addHaarMeasure_unique StieltjesFunction.id.measure
(stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped, A]
simp only [volume, Basis.addHaar, one_smul]
theorem volume_val (s) : volume s = StieltjesFunction.id.measure s := by
simp [volume_eq_stieltjes_id]
@[simp]
theorem volume_Ico {a b : ℝ} : volume (Ico a b) = ofReal (b - a) := by simp [volume_val]
@[simp]
theorem volume_real_Ico {a b : ℝ} : volume.real (Ico a b) = max (b - a) 0 := by
simp [measureReal_def, ENNReal.toReal_ofReal']
theorem volume_real_Ico_of_le {a b : ℝ} (hab : a ≤ b) : volume.real (Ico a b) = b - a := by
simp [hab]
@[simp]
theorem volume_Icc {a b : ℝ} : volume (Icc a b) = ofReal (b - a) := by simp [volume_val]
@[simp]
theorem volume_real_Icc {a b : ℝ} : volume.real (Icc a b) = max (b - a) 0 := by
simp [measureReal_def, ENNReal.toReal_ofReal']
theorem volume_real_Icc_of_le {a b : ℝ} (hab : a ≤ b) : volume.real (Icc a b) = b - a := by
simp [hab]
@[simp]
theorem volume_Ioo {a b : ℝ} : volume (Ioo a b) = ofReal (b - a) := by simp [volume_val]
@[simp]
theorem volume_real_Ioo {a b : ℝ} : volume.real (Ioo a b) = max (b - a) 0 := by
simp [measureReal_def, ENNReal.toReal_ofReal']
theorem volume_real_Ioo_of_le {a b : ℝ} (hab : a ≤ b) : volume.real (Ioo a b) = b - a := by
simp [hab]
@[simp]
theorem volume_Ioc {a b : ℝ} : volume (Ioc a b) = ofReal (b - a) := by simp [volume_val]
@[simp]
theorem volume_real_Ioc {a b : ℝ} : volume.real (Ioc a b) = max (b - a) 0 := by
simp [measureReal_def, ENNReal.toReal_ofReal']
theorem volume_real_Ioc_of_le {a b : ℝ} (hab : a ≤ b) : volume.real (Ioc a b) = b - a := by
simp [hab]
theorem volume_singleton {a : ℝ} : volume ({a} : Set ℝ) = 0 := by simp [volume_val]
theorem volume_univ : volume (univ : Set ℝ) = ∞ :=
ENNReal.eq_top_of_forall_nnreal_le fun r =>
calc
(r : ℝ≥0∞) = volume (Icc (0 : ℝ) r) := by simp
_ ≤ volume univ := measure_mono (subset_univ _)
@[simp]
theorem volume_ball (a r : ℝ) : volume (Metric.ball a r) = ofReal (2 * r) := by
rw [ball_eq_Ioo, volume_Ioo, ← sub_add, add_sub_cancel_left, two_mul]
@[simp]
theorem volume_real_ball {a r : ℝ} (hr : 0 ≤ r) : volume.real (Metric.ball a r) = 2 * r := by
simp [measureReal_def, hr]
@[simp]
theorem volume_closedBall (a r : ℝ) : volume (Metric.closedBall a r) = ofReal (2 * r) := by
rw [closedBall_eq_Icc, volume_Icc, ← sub_add, add_sub_cancel_left, two_mul]
@[simp]
theorem volume_real_closedBall {a r : ℝ} (hr : 0 ≤ r) :
volume.real (Metric.closedBall a r) = 2 * r := by
simp [measureReal_def, hr]
@[simp]
theorem volume_emetric_ball (a : ℝ) (r : ℝ≥0∞) : volume (EMetric.ball a r) = 2 * r := by
rcases eq_or_ne r ∞ with (rfl | hr)
· rw [Metric.emetric_ball_top, volume_univ, two_mul, _root_.top_add]
· lift r to ℝ≥0 using hr
rw [Metric.emetric_ball_nnreal, volume_ball, two_mul, ← NNReal.coe_add,
ENNReal.ofReal_coe_nnreal, ENNReal.coe_add, two_mul]
@[simp]
theorem volume_emetric_closedBall (a : ℝ) (r : ℝ≥0∞) : volume (EMetric.closedBall a r) = 2 * r := by
rcases eq_or_ne r ∞ with (rfl | hr)
· rw [EMetric.closedBall_top, volume_univ, two_mul, _root_.top_add]
· lift r to ℝ≥0 using hr
rw [Metric.emetric_closedBall_nnreal, volume_closedBall, two_mul, ← NNReal.coe_add,
ENNReal.ofReal_coe_nnreal, ENNReal.coe_add, two_mul]
instance noAtoms_volume : NoAtoms (volume : Measure ℝ) :=
⟨fun _ => volume_singleton⟩
@[simp]
theorem volume_interval {a b : ℝ} : volume (uIcc a b) = ofReal |b - a| := by
rw [← Icc_min_max, volume_Icc, max_sub_min_eq_abs]
@[simp]
theorem volume_real_interval {a b : ℝ} : volume.real (uIcc a b) = |b - a| := by
simp [measureReal_def]
@[simp]
theorem volume_Ioi {a : ℝ} : volume (Ioi a) = ∞ :=
top_unique <|
le_of_tendsto' ENNReal.tendsto_nat_nhds_top fun n =>
calc
(n : ℝ≥0∞) = volume (Ioo a (a + n)) := by simp
_ ≤ volume (Ioi a) := measure_mono Ioo_subset_Ioi_self
@[simp]
theorem volume_Ici {a : ℝ} : volume (Ici a) = ∞ := by rw [← measure_congr Ioi_ae_eq_Ici]; simp
@[simp]
theorem volume_Iio {a : ℝ} : volume (Iio a) = ∞ :=
top_unique <|
le_of_tendsto' ENNReal.tendsto_nat_nhds_top fun n =>
calc
(n : ℝ≥0∞) = volume (Ioo (a - n) a) := by simp
_ ≤ volume (Iio a) := measure_mono Ioo_subset_Iio_self
@[simp]
theorem volume_Iic {a : ℝ} : volume (Iic a) = ∞ := by rw [← measure_congr Iio_ae_eq_Iic]; simp
instance locallyFinite_volume : IsLocallyFiniteMeasure (volume : Measure ℝ) :=
⟨fun x =>
⟨Ioo (x - 1) (x + 1),
IsOpen.mem_nhds isOpen_Ioo ⟨sub_lt_self _ zero_lt_one, lt_add_of_pos_right _ zero_lt_one⟩, by
simp only [Real.volume_Ioo, ENNReal.ofReal_lt_top]⟩⟩
instance isFiniteMeasure_restrict_Icc (x y : ℝ) : IsFiniteMeasure (volume.restrict (Icc x y)) :=
⟨by simp⟩
instance isFiniteMeasure_restrict_Ico (x y : ℝ) : IsFiniteMeasure (volume.restrict (Ico x y)) :=
⟨by simp⟩
instance isFiniteMeasure_restrict_Ioc (x y : ℝ) : IsFiniteMeasure (volume.restrict (Ioc x y)) :=
⟨by simp⟩
instance isFiniteMeasure_restrict_Ioo (x y : ℝ) : IsFiniteMeasure (volume.restrict (Ioo x y)) :=
⟨by simp⟩
theorem volume_le_diam (s : Set ℝ) : volume s ≤ EMetric.diam s := by
by_cases hs : Bornology.IsBounded s
· rw [Real.ediam_eq hs, ← volume_Icc]
exact volume.mono hs.subset_Icc_sInf_sSup
· rw [Metric.ediam_of_unbounded hs]; exact le_top
theorem _root_.Filter.Eventually.volume_pos_of_nhds_real {p : ℝ → Prop} {a : ℝ}
(h : ∀ᶠ x in 𝓝 a, p x) : (0 : ℝ≥0∞) < volume { x | p x } := by
rcases h.exists_Ioo_subset with ⟨l, u, hx, hs⟩
refine lt_of_lt_of_le ?_ (measure_mono hs)
simpa [-mem_Ioo] using hx.1.trans hx.2
/-!
### Volume of a box in `ℝⁿ`
-/
theorem volume_Icc_pi {a b : ι → ℝ} : volume (Icc a b) = ∏ i, ENNReal.ofReal (b i - a i) := by
rw [← pi_univ_Icc, volume_pi_pi]
simp only [Real.volume_Icc]
@[simp]
theorem volume_Icc_pi_toReal {a b : ι → ℝ} (h : a ≤ b) :
(volume (Icc a b)).toReal = ∏ i, (b i - a i) := by
simp only [volume_Icc_pi, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))]
theorem volume_pi_Ioo {a b : ι → ℝ} :
volume (pi univ fun i => Ioo (a i) (b i)) = ∏ i, ENNReal.ofReal (b i - a i) :=
(measure_congr Measure.univ_pi_Ioo_ae_eq_Icc).trans volume_Icc_pi
@[simp]
theorem volume_pi_Ioo_toReal {a b : ι → ℝ} (h : a ≤ b) :
(volume (pi univ fun i => Ioo (a i) (b i))).toReal = ∏ i, (b i - a i) := by
simp only [volume_pi_Ioo, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))]
theorem volume_pi_Ioc {a b : ι → ℝ} :
volume (pi univ fun i => Ioc (a i) (b i)) = ∏ i, ENNReal.ofReal (b i - a i) :=
(measure_congr Measure.univ_pi_Ioc_ae_eq_Icc).trans volume_Icc_pi
@[simp]
theorem volume_pi_Ioc_toReal {a b : ι → ℝ} (h : a ≤ b) :
(volume (pi univ fun i => Ioc (a i) (b i))).toReal = ∏ i, (b i - a i) := by
simp only [volume_pi_Ioc, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))]
theorem volume_pi_Ico {a b : ι → ℝ} :
volume (pi univ fun i => Ico (a i) (b i)) = ∏ i, ENNReal.ofReal (b i - a i) :=
(measure_congr Measure.univ_pi_Ico_ae_eq_Icc).trans volume_Icc_pi
@[simp]
theorem volume_pi_Ico_toReal {a b : ι → ℝ} (h : a ≤ b) :
(volume (pi univ fun i => Ico (a i) (b i))).toReal = ∏ i, (b i - a i) := by
simp only [volume_pi_Ico, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))]
@[simp]
nonrec theorem volume_pi_ball (a : ι → ℝ) {r : ℝ} (hr : 0 < r) :
volume (Metric.ball a r) = ENNReal.ofReal ((2 * r) ^ Fintype.card ι) := by
simp only [MeasureTheory.volume_pi_ball a hr, volume_ball, Finset.prod_const]
exact (ENNReal.ofReal_pow (mul_nonneg zero_le_two hr.le) _).symm
@[simp]
nonrec theorem volume_pi_closedBall (a : ι → ℝ) {r : ℝ} (hr : 0 ≤ r) :
volume (Metric.closedBall a r) = ENNReal.ofReal ((2 * r) ^ Fintype.card ι) := by
simp only [MeasureTheory.volume_pi_closedBall a hr, volume_closedBall, Finset.prod_const]
exact (ENNReal.ofReal_pow (mul_nonneg zero_le_two hr) _).symm
theorem volume_pi_le_prod_diam (s : Set (ι → ℝ)) :
volume s ≤ ∏ i : ι, EMetric.diam (Function.eval i '' s) :=
calc
volume s ≤ volume (pi univ fun i => closure (Function.eval i '' s)) :=
volume.mono <|
Subset.trans (subset_pi_eval_image univ s) <| pi_mono fun _ _ => subset_closure
_ = ∏ i, volume (closure <| Function.eval i '' s) := volume_pi_pi _
_ ≤ ∏ i : ι, EMetric.diam (Function.eval i '' s) :=
Finset.prod_le_prod' fun _ _ => (volume_le_diam _).trans_eq (EMetric.diam_closure _)
| Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean | 281 | 287 | theorem volume_pi_le_diam_pow (s : Set (ι → ℝ)) : volume s ≤ EMetric.diam s ^ Fintype.card ι :=
calc
volume s ≤ ∏ i : ι, EMetric.diam (Function.eval i '' s) := volume_pi_le_prod_diam s
_ ≤ ∏ _i : ι, (1 : ℝ≥0) * EMetric.diam s :=
(Finset.prod_le_prod' fun i _ => (LipschitzWith.eval i).ediam_image_le s)
_ = EMetric.diam s ^ Fintype.card ι := by | simp only [ENNReal.coe_one, one_mul, Finset.prod_const, Fintype.card] |
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kim Morrison
-/
import Mathlib.Tactic.NormNum.Basic
import Mathlib.Tactic.TryThis
import Mathlib.Util.AtomM
/-!
# The `abel` tactic
Evaluate expressions in the language of additive, commutative monoids and groups.
-/
-- TODO: assert_not_exists NonUnitalNonAssociativeSemiring
assert_not_exists OrderedAddCommMonoid TopologicalSpace PseudoMetricSpace
namespace Mathlib.Tactic.Abel
open Lean Elab Meta Tactic Qq
initialize registerTraceClass `abel
initialize registerTraceClass `abel.detail
/--
Tactic for evaluating equations in the language of
*additive*, commutative monoids and groups.
`abel` and its variants work as both tactics and conv tactics.
* `abel1` fails if the target is not an equality that is provable by the axioms of
commutative monoids/groups.
* `abel_nf` rewrites all group expressions into a normal form.
* In tactic mode, `abel_nf at h` can be used to rewrite in a hypothesis.
* `abel_nf (config := cfg)` allows for additional configuration:
* `red`: the reducibility setting (overridden by `!`)
* `zetaDelta`: if true, local let variables can be unfolded (overridden by `!`)
* `recursive`: if true, `abel_nf` will also recurse into atoms
* `abel!`, `abel1!`, `abel_nf!` will use a more aggressive reducibility setting to identify atoms.
For example:
```
example [AddCommMonoid α] (a b : α) : a + (b + a) = a + a + b := by abel
example [AddCommGroup α] (a : α) : (3 : ℤ) • a = a + (2 : ℤ) • a := by abel
```
## Future work
* In mathlib 3, `abel` accepted additional optional arguments:
```
syntax "abel" (&" raw" <|> &" term")? (location)? : tactic
```
It is undecided whether these features should be restored eventually.
-/
syntax (name := abel) "abel" "!"? : tactic
/-- The `Context` for a call to `abel`.
Stores a few options for this call, and caches some common subexpressions
such as typeclass instances and `0 : α`.
-/
structure Context where
/-- The type of the ambient additive commutative group or monoid. -/
α : Expr
/-- The universe level for `α`. -/
univ : Level
/-- The expression representing `0 : α`. -/
α0 : Expr
/-- Specify whether we are in an additive commutative group or an additive commutative monoid. -/
isGroup : Bool
/-- The `AddCommGroup α` or `AddCommMonoid α` expression. -/
inst : Expr
/-- Populate a `context` object for evaluating `e`. -/
def mkContext (e : Expr) : MetaM Context := do
let α ← inferType e
let c ← synthInstance (← mkAppM ``AddCommMonoid #[α])
let cg ← synthInstance? (← mkAppM ``AddCommGroup #[α])
let u ← mkFreshLevelMVar
_ ← isDefEq (.sort (.succ u)) (← inferType α)
let α0 ← Expr.ofNat α 0
match cg with
| some cg => return ⟨α, u, α0, true, cg⟩
| _ => return ⟨α, u, α0, false, c⟩
/-- The monad for `Abel` contains, in addition to the `AtomM` state,
some information about the current type we are working over, so that we can consistently
use group lemmas or monoid lemmas as appropriate. -/
abbrev M := ReaderT Context AtomM
/-- Apply the function `n : ∀ {α} [inst : AddWhatever α], _` to the
implicit parameters in the context, and the given list of arguments. -/
def Context.app (c : Context) (n : Name) (inst : Expr) : Array Expr → Expr :=
mkAppN (((@Expr.const n [c.univ]).app c.α).app inst)
/-- Apply the function `n : ∀ {α} [inst α], _` to the implicit parameters in the
context, and the given list of arguments.
Compared to `context.app`, this takes the name of the typeclass, rather than an
inferred typeclass instance.
-/
def Context.mkApp (c : Context) (n inst : Name) (l : Array Expr) : MetaM Expr := do
return c.app n (← synthInstance ((Expr.const inst [c.univ]).app c.α)) l
/-- Add the letter "g" to the end of the name, e.g. turning `term` into `termg`.
This is used to choose between declarations taking `AddCommMonoid` and those
taking `AddCommGroup` instances.
-/
def addG : Name → Name
| .str p s => .str p (s ++ "g")
| n => n
/-- Apply the function `n : ∀ {α} [AddComm{Monoid,Group} α]` to the given list of arguments.
Will use the `AddComm{Monoid,Group}` instance that has been cached in the context.
-/
def iapp (n : Name) (xs : Array Expr) : M Expr := do
let c ← read
return c.app (if c.isGroup then addG n else n) c.inst xs
/-- A type synonym used by `abel` to represent `n • x + a` in an additive commutative monoid. -/
def term {α} [AddCommMonoid α] (n : ℕ) (x a : α) : α := n • x + a
/-- A type synonym used by `abel` to represent `n • x + a` in an additive commutative group. -/
def termg {α} [AddCommGroup α] (n : ℤ) (x a : α) : α := n • x + a
/-- Evaluate a term with coefficient `n`, atom `x` and successor terms `a`. -/
def mkTerm (n x a : Expr) : M Expr := iapp ``term #[n, x, a]
/-- Interpret an integer as a coefficient to a term. -/
def intToExpr (n : ℤ) : M Expr := do
Expr.ofInt (mkConst (if (← read).isGroup then ``Int else ``Nat) []) n
/-- A normal form for `abel`.
Expressions are represented as a list of terms of the form `e = n • x`,
where `n : ℤ` and `x` is an arbitrary element of the additive commutative monoid or group.
We explicitly track the `Expr` forms of `e` and `n`, even though they could be reconstructed,
for efficiency. -/
inductive NormalExpr : Type
| zero (e : Expr) : NormalExpr
| nterm (e : Expr) (n : Expr × ℤ) (x : ℕ × Expr) (a : NormalExpr) : NormalExpr
deriving Inhabited
/-- Extract the expression from a normal form. -/
def NormalExpr.e : NormalExpr → Expr
| .zero e => e
| .nterm e .. => e
instance : Coe NormalExpr Expr where coe := NormalExpr.e
/-- Construct the normal form representing a single term. -/
def NormalExpr.term' (n : Expr × ℤ) (x : ℕ × Expr) (a : NormalExpr) : M NormalExpr :=
return .nterm (← mkTerm n.1 x.2 a) n x a
/-- Construct the normal form representing zero. -/
def NormalExpr.zero' : M NormalExpr := return NormalExpr.zero (← read).α0
open NormalExpr
theorem const_add_term {α} [AddCommMonoid α] (k n x a a') (h : k + a = a') :
k + @term α _ n x a = term n x a' := by
simp [h.symm, term, add_comm, add_assoc]
theorem const_add_termg {α} [AddCommGroup α] (k n x a a') (h : k + a = a') :
k + @termg α _ n x a = termg n x a' := by
simp [h.symm, termg, add_comm, add_assoc]
theorem term_add_const {α} [AddCommMonoid α] (n x a k a') (h : a + k = a') :
@term α _ n x a + k = term n x a' := by
simp [h.symm, term, add_assoc]
theorem term_add_constg {α} [AddCommGroup α] (n x a k a') (h : a + k = a') :
@termg α _ n x a + k = termg n x a' := by
simp [h.symm, termg, add_assoc]
theorem term_add_term {α} [AddCommMonoid α] (n₁ x a₁ n₂ a₂ n' a') (h₁ : n₁ + n₂ = n')
(h₂ : a₁ + a₂ = a') : @term α _ n₁ x a₁ + @term α _ n₂ x a₂ = term n' x a' := by
simp [h₁.symm, h₂.symm, term, add_nsmul, add_assoc, add_left_comm]
theorem term_add_termg {α} [AddCommGroup α] (n₁ x a₁ n₂ a₂ n' a')
(h₁ : n₁ + n₂ = n') (h₂ : a₁ + a₂ = a') :
@termg α _ n₁ x a₁ + @termg α _ n₂ x a₂ = termg n' x a' := by
simp only [termg, h₁.symm, add_zsmul, h₂.symm]
exact add_add_add_comm (n₁ • x) a₁ (n₂ • x) a₂
theorem zero_term {α} [AddCommMonoid α] (x a) : @term α _ 0 x a = a := by
simp [term, zero_nsmul, one_nsmul]
theorem zero_termg {α} [AddCommGroup α] (x a) : @termg α _ 0 x a = a := by
simp [termg, zero_zsmul]
/--
Interpret the sum of two expressions in `abel`'s normal form.
-/
partial def evalAdd : NormalExpr → NormalExpr → M (NormalExpr × Expr)
| zero _, e₂ => do
let p ← mkAppM ``zero_add #[e₂]
return (e₂, p)
| e₁, zero _ => do
let p ← mkAppM ``add_zero #[e₁]
return (e₁, p)
| he₁@(nterm e₁ n₁ x₁ a₁), he₂@(nterm e₂ n₂ x₂ a₂) => do
if x₁.1 = x₂.1 then
let n' ← Mathlib.Meta.NormNum.eval (← mkAppM ``HAdd.hAdd #[n₁.1, n₂.1])
let (a', h₂) ← evalAdd a₁ a₂
let k := n₁.2 + n₂.2
let p₁ ← iapp ``term_add_term
#[n₁.1, x₁.2, a₁, n₂.1, a₂, n'.expr, a', ← n'.getProof, h₂]
if k = 0 then do
let p ← mkEqTrans p₁ (← iapp ``zero_term #[x₁.2, a'])
return (a', p)
else return (← term' (n'.expr, k) x₁ a', p₁)
else if x₁.1 < x₂.1 then do
let (a', h) ← evalAdd a₁ he₂
return (← term' n₁ x₁ a', ← iapp ``term_add_const #[n₁.1, x₁.2, a₁, e₂, a', h])
else do
let (a', h) ← evalAdd he₁ a₂
return (← term' n₂ x₂ a', ← iapp ``const_add_term #[e₁, n₂.1, x₂.2, a₂, a', h])
theorem term_neg {α} [AddCommGroup α] (n x a n' a')
(h₁ : -n = n') (h₂ : -a = a') : -@termg α _ n x a = termg n' x a' := by
simpa [h₂.symm, h₁.symm, termg] using add_comm _ _
/--
Interpret a negated expression in `abel`'s normal form.
-/
def evalNeg : NormalExpr → M (NormalExpr × Expr)
| (zero _) => do
let p ← (← read).mkApp ``neg_zero ``NegZeroClass #[]
return (← zero', p)
| (nterm _ n x a) => do
let n' ← Mathlib.Meta.NormNum.eval (← mkAppM ``Neg.neg #[n.1])
let (a', h₂) ← evalNeg a
return (← term' (n'.expr, -n.2) x a',
(← read).app ``term_neg (← read).inst #[n.1, x.2, a, n'.expr, a', ← n'.getProof, h₂])
/-- A synonym for `•`, used internally in `abel`. -/
def smul {α} [AddCommMonoid α] (n : ℕ) (x : α) : α := n • x
/-- A synonym for `•`, used internally in `abel`. -/
def smulg {α} [AddCommGroup α] (n : ℤ) (x : α) : α := n • x
| Mathlib/Tactic/Abel.lean | 244 | 245 | theorem zero_smul {α} [AddCommMonoid α] (c) : smul c (0 : α) = 0 := by | simp [smul, nsmul_zero] |
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Order.Group.Indicator
import Mathlib.Analysis.Normed.Affine.AddTorsor
import Mathlib.Analysis.NormedSpace.FunctionSeries
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.LinearAlgebra.AffineSpace.Ordered
import Mathlib.Topology.ContinuousMap.Algebra
import Mathlib.Topology.GDelta.Basic
/-!
# Urysohn's lemma
In this file we prove Urysohn's lemma `exists_continuous_zero_one_of_isClosed`: for any two disjoint
closed sets `s` and `t` in a normal topological space `X` there exists a continuous function
`f : X → ℝ` such that
* `f` equals zero on `s`;
* `f` equals one on `t`;
* `0 ≤ f x ≤ 1` for all `x`.
We also give versions in a regular locally compact space where one assumes that `s` is compact
and `t` is closed, in `exists_continuous_zero_one_of_isCompact`
and `exists_continuous_one_zero_of_isCompact` (the latter providing additionally a function with
compact support).
We write a generic proof so that it applies both to normal spaces and to regular locally
compact spaces.
## Implementation notes
Most paper sources prove Urysohn's lemma using a family of open sets indexed by dyadic rational
numbers on `[0, 1]`. There are many technical difficulties with formalizing this proof (e.g., one
needs to formalize the "dyadic induction", then prove that the resulting family of open sets is
monotone). So, we formalize a slightly different proof.
Let `Urysohns.CU` be the type of pairs `(C, U)` of a closed set `C` and an open set `U` such that
`C ⊆ U`. Since `X` is a normal topological space, for each `c : CU` there exists an open set `u`
such that `c.C ⊆ u ∧ closure u ⊆ c.U`. We define `c.left` and `c.right` to be `(c.C, u)` and
`(closure u, c.U)`, respectively. Then we define a family of functions
`Urysohns.CU.approx (c : Urysohns.CU) (n : ℕ) : X → ℝ` by recursion on `n`:
* `c.approx 0` is the indicator of `c.Uᶜ`;
* `c.approx (n + 1) x = (c.left.approx n x + c.right.approx n x) / 2`.
For each `x` this is a monotone family of functions that are equal to zero on `c.C` and are equal to
one outside of `c.U`. We also have `c.approx n x ∈ [0, 1]` for all `c`, `n`, and `x`.
Let `Urysohns.CU.lim c` be the supremum (or equivalently, the limit) of `c.approx n`. Then
properties of `Urysohns.CU.approx` immediately imply that
* `c.lim x ∈ [0, 1]` for all `x`;
* `c.lim` equals zero on `c.C` and equals one outside of `c.U`;
* `c.lim x = (c.left.lim x + c.right.lim x) / 2`.
In order to prove that `c.lim` is continuous at `x`, we prove by induction on `n : ℕ` that for `y`
in a small neighborhood of `x` we have `|c.lim y - c.lim x| ≤ (3 / 4) ^ n`. Induction base follows
from `c.lim x ∈ [0, 1]`, `c.lim y ∈ [0, 1]`. For the induction step, consider two cases:
* `x ∈ c.left.U`; then for `y` in a small neighborhood of `x` we have `y ∈ c.left.U ⊆ c.right.C`
(hence `c.right.lim x = c.right.lim y = 0`) and `|c.left.lim y - c.left.lim x| ≤ (3 / 4) ^ n`.
Then
`|c.lim y - c.lim x| = |c.left.lim y - c.left.lim x| / 2 ≤ (3 / 4) ^ n / 2 < (3 / 4) ^ (n + 1)`.
* otherwise, `x ∉ c.left.right.C`; then for `y` in a small neighborhood of `x` we have
`y ∉ c.left.right.C ⊇ c.left.left.U` (hence `c.left.left.lim x = c.left.left.lim y = 1`),
`|c.left.right.lim y - c.left.right.lim x| ≤ (3 / 4) ^ n`, and
`|c.right.lim y - c.right.lim x| ≤ (3 / 4) ^ n`. Combining these inequalities, the triangle
inequality, and the recurrence formula for `c.lim`, we get
`|c.lim x - c.lim y| ≤ (3 / 4) ^ (n + 1)`.
The actual formalization uses `midpoint ℝ x y` instead of `(x + y) / 2` because we have more API
lemmas about `midpoint`.
## Tags
Urysohn's lemma, normal topological space, locally compact topological space
-/
variable {X : Type*} [TopologicalSpace X]
open Set Filter TopologicalSpace Topology Filter
open scoped Pointwise
namespace Urysohns
/--
An auxiliary type for the proof of Urysohn's lemma: a pair of a closed set `C` and its open
neighborhood `U`, together with the assumption that `C` and `U` satisfy the property `P C U`.
The latter assumption will make it possible to prove simultaneously both versions of Urysohn's
lemma, in normal spaces (with `P` always true) and in locally compact spaces
(with `P C U = IsCompact C`). We put also in the structure the assumption that, for any such pair,
one may find an intermediate pair in between satisfying `P`,
to avoid carrying it around in the argument.
-/
structure CU {X : Type*} [TopologicalSpace X] (P : Set X → Set X → Prop) where
/-- The inner set in the inductive construction towards Urysohn's lemma -/
protected C : Set X
/-- The outer set in the inductive construction towards Urysohn's lemma -/
protected U : Set X
/-- The proof that `C` and `U` satisfy the property `P C U` -/
protected P_C_U : P C U
protected closed_C : IsClosed C
protected open_U : IsOpen U
protected subset : C ⊆ U
/-- The proof that we can divide `CU` pairs in half -/
protected hP : ∀ {c u : Set X}, IsClosed c → P c u → IsOpen u → c ⊆ u →
∃ (v : Set X), IsOpen v ∧ c ⊆ v ∧ closure v ⊆ u ∧ P c v ∧ P (closure v) u
namespace CU
variable {P : Set X → Set X → Prop}
/-- By assumption, for each `c : CU P` there exists an open set `u`
such that `c.C ⊆ u` and `closure u ⊆ c.U`. `c.left` is the pair `(c.C, u)`. -/
@[simps C]
def left (c : CU P) : CU P where
C := c.C
U := (c.hP c.closed_C c.P_C_U c.open_U c.subset).choose
closed_C := c.closed_C
P_C_U := (c.hP c.closed_C c.P_C_U c.open_U c.subset).choose_spec.2.2.2.1
open_U := (c.hP c.closed_C c.P_C_U c.open_U c.subset).choose_spec.1
subset := (c.hP c.closed_C c.P_C_U c.open_U c.subset).choose_spec.2.1
hP := c.hP
/-- By assumption, for each `c : CU P` there exists an open set `u`
such that `c.C ⊆ u` and `closure u ⊆ c.U`. `c.right` is the pair `(closure u, c.U)`. -/
@[simps U]
def right (c : CU P) : CU P where
C := closure (c.hP c.closed_C c.P_C_U c.open_U c.subset).choose
U := c.U
closed_C := isClosed_closure
P_C_U := (c.hP c.closed_C c.P_C_U c.open_U c.subset).choose_spec.2.2.2.2
open_U := c.open_U
subset := (c.hP c.closed_C c.P_C_U c.open_U c.subset).choose_spec.2.2.1
hP := c.hP
theorem left_U_subset_right_C (c : CU P) : c.left.U ⊆ c.right.C :=
subset_closure
theorem left_U_subset (c : CU P) : c.left.U ⊆ c.U :=
Subset.trans c.left_U_subset_right_C c.right.subset
theorem subset_right_C (c : CU P) : c.C ⊆ c.right.C :=
Subset.trans c.left.subset c.left_U_subset_right_C
/-- `n`-th approximation to a continuous function `f : X → ℝ` such that `f = 0` on `c.C` and `f = 1`
outside of `c.U`. -/
noncomputable def approx : ℕ → CU P → X → ℝ
| 0, c, x => indicator c.Uᶜ 1 x
| n + 1, c, x => midpoint ℝ (approx n c.left x) (approx n c.right x)
theorem approx_of_mem_C (c : CU P) (n : ℕ) {x : X} (hx : x ∈ c.C) : c.approx n x = 0 := by
induction n generalizing c with
| zero => exact indicator_of_not_mem (fun (hU : x ∈ c.Uᶜ) => hU <| c.subset hx) _
| succ n ihn =>
simp only [approx]
rw [ihn, ihn, midpoint_self]
exacts [c.subset_right_C hx, hx]
theorem approx_of_nmem_U (c : CU P) (n : ℕ) {x : X} (hx : x ∉ c.U) : c.approx n x = 1 := by
induction n generalizing c with
| zero =>
rw [← mem_compl_iff] at hx
exact indicator_of_mem hx _
| succ n ihn =>
simp only [approx]
rw [ihn, ihn, midpoint_self]
exacts [hx, fun hU => hx <| c.left_U_subset hU]
theorem approx_nonneg (c : CU P) (n : ℕ) (x : X) : 0 ≤ c.approx n x := by
induction n generalizing c with
| zero => exact indicator_nonneg (fun _ _ => zero_le_one) _
| succ n ihn =>
simp only [approx, midpoint_eq_smul_add, invOf_eq_inv]
refine mul_nonneg (inv_nonneg.2 zero_le_two) (add_nonneg ?_ ?_) <;> apply ihn
theorem approx_le_one (c : CU P) (n : ℕ) (x : X) : c.approx n x ≤ 1 := by
induction n generalizing c with
| zero => exact indicator_apply_le' (fun _ => le_rfl) fun _ => zero_le_one
| succ n ihn =>
simp only [approx, midpoint_eq_smul_add, invOf_eq_inv, smul_eq_mul, ← div_eq_inv_mul]
have := add_le_add (ihn (left c)) (ihn (right c))
norm_num at this
exact Iff.mpr (div_le_one zero_lt_two) this
theorem bddAbove_range_approx (c : CU P) (x : X) : BddAbove (range fun n => c.approx n x) :=
⟨1, fun _ ⟨n, hn⟩ => hn ▸ c.approx_le_one n x⟩
theorem approx_le_approx_of_U_sub_C {c₁ c₂ : CU P} (h : c₁.U ⊆ c₂.C) (n₁ n₂ : ℕ) (x : X) :
c₂.approx n₂ x ≤ c₁.approx n₁ x := by
by_cases hx : x ∈ c₁.U
· calc
approx n₂ c₂ x = 0 := approx_of_mem_C _ _ (h hx)
_ ≤ approx n₁ c₁ x := approx_nonneg _ _ _
· calc
approx n₂ c₂ x ≤ 1 := approx_le_one _ _ _
_ = approx n₁ c₁ x := (approx_of_nmem_U _ _ hx).symm
theorem approx_mem_Icc_right_left (c : CU P) (n : ℕ) (x : X) :
c.approx n x ∈ Icc (c.right.approx n x) (c.left.approx n x) := by
induction n generalizing c with
| zero =>
exact ⟨le_rfl, indicator_le_indicator_of_subset (compl_subset_compl.2 c.left_U_subset)
(fun _ => zero_le_one) _⟩
| succ n ihn =>
simp only [approx, mem_Icc]
refine ⟨midpoint_le_midpoint ?_ (ihn _).1, midpoint_le_midpoint (ihn _).2 ?_⟩ <;>
apply approx_le_approx_of_U_sub_C
exacts [subset_closure, subset_closure]
theorem approx_le_succ (c : CU P) (n : ℕ) (x : X) : c.approx n x ≤ c.approx (n + 1) x := by
induction n generalizing c with
| zero =>
simp only [approx, right_U, right_le_midpoint]
exact (approx_mem_Icc_right_left c 0 x).2
| succ n ihn =>
rw [approx, approx]
exact midpoint_le_midpoint (ihn _) (ihn _)
theorem approx_mono (c : CU P) (x : X) : Monotone fun n => c.approx n x :=
monotone_nat_of_le_succ fun n => c.approx_le_succ n x
/-- A continuous function `f : X → ℝ` such that
* `0 ≤ f x ≤ 1` for all `x`;
* `f` equals zero on `c.C` and equals one outside of `c.U`;
-/
protected noncomputable def lim (c : CU P) (x : X) : ℝ :=
⨆ n, c.approx n x
theorem tendsto_approx_atTop (c : CU P) (x : X) :
Tendsto (fun n => c.approx n x) atTop (𝓝 <| c.lim x) :=
tendsto_atTop_ciSup (c.approx_mono x) ⟨1, fun _ ⟨_, hn⟩ => hn ▸ c.approx_le_one _ _⟩
theorem lim_of_mem_C (c : CU P) (x : X) (h : x ∈ c.C) : c.lim x = 0 := by
simp only [CU.lim, approx_of_mem_C, h, ciSup_const]
theorem disjoint_C_support_lim (c : CU P) : Disjoint c.C (Function.support c.lim) :=
Function.disjoint_support_iff.mpr (fun x hx => lim_of_mem_C c x hx)
| Mathlib/Topology/UrysohnsLemma.lean | 246 | 247 | theorem lim_of_nmem_U (c : CU P) (x : X) (h : x ∉ c.U) : c.lim x = 1 := by | simp only [CU.lim, approx_of_nmem_U c _ h, ciSup_const] |
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Moritz Doll
-/
import Mathlib.Algebra.GroupWithZero.Action.Opposite
import Mathlib.LinearAlgebra.Finsupp.VectorSpace
import Mathlib.LinearAlgebra.Matrix.Basis
import Mathlib.LinearAlgebra.Matrix.Nondegenerate
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
import Mathlib.LinearAlgebra.Matrix.ToLinearEquiv
import Mathlib.LinearAlgebra.SesquilinearForm
import Mathlib.LinearAlgebra.Basis.Bilinear
/-!
# Sesquilinear form
This file defines the conversion between sesquilinear maps and matrices.
## Main definitions
* `Matrix.toLinearMap₂` given a basis define a bilinear map
* `Matrix.toLinearMap₂'` define the bilinear map on `n → R`
* `LinearMap.toMatrix₂`: calculate the matrix coefficients of a bilinear map
* `LinearMap.toMatrix₂'`: calculate the matrix coefficients of a bilinear map on `n → R`
## TODO
At the moment this is quite a literal port from `Matrix.BilinearForm`. Everything should be
generalized to fully semibilinear forms.
## Tags
Sesquilinear form, Sesquilinear map, matrix, basis
-/
variable {R R₁ S₁ R₂ S₂ M₁ M₂ M₁' M₂' N₂ n m n' m' ι : Type*}
open Finset LinearMap Matrix
open Matrix
open scoped RightActions
section AuxToLinearMap
variable [Semiring R₁] [Semiring S₁] [Semiring R₂] [Semiring S₂] [AddCommMonoid N₂]
[Module S₁ N₂] [Module S₂ N₂] [SMulCommClass S₂ S₁ N₂]
variable [Fintype n] [Fintype m]
variable (σ₁ : R₁ →+* S₁) (σ₂ : R₂ →+* S₂)
/-- The map from `Matrix n n R` to bilinear maps on `n → R`.
This is an auxiliary definition for the equivalence `Matrix.toLinearMap₂'`. -/
def Matrix.toLinearMap₂'Aux (f : Matrix n m N₂) : (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] N₂ :=
-- porting note: we don't seem to have `∑ i j` as valid notation yet
mk₂'ₛₗ σ₁ σ₂ (fun (v : n → R₁) (w : m → R₂) => ∑ i, ∑ j, σ₂ (w j) • σ₁ (v i) • f i j)
(fun _ _ _ => by simp only [Pi.add_apply, map_add, smul_add, sum_add_distrib, add_smul])
(fun c v w => by
simp only [Pi.smul_apply, smul_sum, smul_eq_mul, σ₁.map_mul, ← smul_comm _ (σ₁ c),
MulAction.mul_smul])
(fun _ _ _ => by simp only [Pi.add_apply, map_add, add_smul, smul_add, sum_add_distrib])
(fun _ v w => by
simp only [Pi.smul_apply, smul_eq_mul, map_mul, MulAction.mul_smul, smul_sum])
variable [DecidableEq n] [DecidableEq m]
theorem Matrix.toLinearMap₂'Aux_single (f : Matrix n m N₂) (i : n) (j : m) :
f.toLinearMap₂'Aux σ₁ σ₂ (Pi.single i 1) (Pi.single j 1) = f i j := by
rw [Matrix.toLinearMap₂'Aux, mk₂'ₛₗ_apply]
have : (∑ i', ∑ j', (if i = i' then (1 : S₁) else (0 : S₁)) •
(if j = j' then (1 : S₂) else (0 : S₂)) • f i' j') =
f i j := by
simp_rw [← Finset.smul_sum]
simp only [op_smul_eq_smul, ite_smul, one_smul, zero_smul, sum_ite_eq, mem_univ, ↓reduceIte]
rw [← this]
exact Finset.sum_congr rfl fun _ _ => Finset.sum_congr rfl fun _ _ => by aesop
end AuxToLinearMap
section AuxToMatrix
section CommSemiring
variable [CommSemiring R] [Semiring R₁] [Semiring S₁] [Semiring R₂] [Semiring S₂]
variable [AddCommMonoid M₁] [Module R₁ M₁] [AddCommMonoid M₂] [Module R₂ M₂] [AddCommMonoid N₂]
[Module R N₂] [Module S₁ N₂] [Module S₂ N₂] [SMulCommClass S₁ R N₂] [SMulCommClass S₂ R N₂]
[SMulCommClass S₂ S₁ N₂]
variable {σ₁ : R₁ →+* S₁} {σ₂ : R₂ →+* S₂}
variable (R)
/-- The linear map from sesquilinear maps to `Matrix n m N₂` given an `n`-indexed basis for `M₁`
and an `m`-indexed basis for `M₂`.
This is an auxiliary definition for the equivalence `Matrix.toLinearMapₛₗ₂'`. -/
def LinearMap.toMatrix₂Aux (b₁ : n → M₁) (b₂ : m → M₂) :
(M₁ →ₛₗ[σ₁] M₂ →ₛₗ[σ₂] N₂) →ₗ[R] Matrix n m N₂ where
toFun f := of fun i j => f (b₁ i) (b₂ j)
map_add' _f _g := rfl
map_smul' _f _g := rfl
@[simp]
theorem LinearMap.toMatrix₂Aux_apply (f : M₁ →ₛₗ[σ₁] M₂ →ₛₗ[σ₂] N₂) (b₁ : n → M₁) (b₂ : m → M₂)
(i : n) (j : m) : LinearMap.toMatrix₂Aux R b₁ b₂ f i j = f (b₁ i) (b₂ j) :=
rfl
variable [Fintype n] [Fintype m]
variable [DecidableEq n] [DecidableEq m]
theorem LinearMap.toLinearMap₂'Aux_toMatrix₂Aux (f : (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] N₂) :
Matrix.toLinearMap₂'Aux σ₁ σ₂
(LinearMap.toMatrix₂Aux R (fun i => Pi.single i 1) (fun j => Pi.single j 1) f) =
f := by
refine ext_basis (Pi.basisFun R₁ n) (Pi.basisFun R₂ m) fun i j => ?_
simp_rw [Pi.basisFun_apply, Matrix.toLinearMap₂'Aux_single, LinearMap.toMatrix₂Aux_apply]
theorem Matrix.toMatrix₂Aux_toLinearMap₂'Aux (f : Matrix n m N₂) :
LinearMap.toMatrix₂Aux R (fun i => Pi.single i 1)
(fun j => Pi.single j 1) (f.toLinearMap₂'Aux σ₁ σ₂) =
f := by
ext i j
simp_rw [LinearMap.toMatrix₂Aux_apply, Matrix.toLinearMap₂'Aux_single]
end CommSemiring
end AuxToMatrix
section ToMatrix'
/-! ### Bilinear maps over `n → R`
This section deals with the conversion between matrices and sesquilinear maps on `n → R`.
-/
variable [CommSemiring R] [AddCommMonoid N₂] [Module R N₂] [Semiring R₁] [Semiring R₂]
[Semiring S₁] [Semiring S₂] [Module S₁ N₂] [Module S₂ N₂]
[SMulCommClass S₁ R N₂] [SMulCommClass S₂ R N₂] [SMulCommClass S₂ S₁ N₂]
variable {σ₁ : R₁ →+* S₁} {σ₂ : R₂ →+* S₂}
variable [Fintype n] [Fintype m]
variable [DecidableEq n] [DecidableEq m]
variable (R)
/-- The linear equivalence between sesquilinear maps and `n × m` matrices -/
def LinearMap.toMatrixₛₗ₂' : ((n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] N₂) ≃ₗ[R] Matrix n m N₂ :=
{ LinearMap.toMatrix₂Aux R (fun i => Pi.single i 1) (fun j => Pi.single j 1) with
toFun := LinearMap.toMatrix₂Aux R _ _
invFun := Matrix.toLinearMap₂'Aux σ₁ σ₂
left_inv := LinearMap.toLinearMap₂'Aux_toMatrix₂Aux R
right_inv := Matrix.toMatrix₂Aux_toLinearMap₂'Aux R }
/-- The linear equivalence between bilinear maps and `n × m` matrices -/
def LinearMap.toMatrix₂' : ((n → S₁) →ₗ[S₁] (m → S₂) →ₗ[S₂] N₂) ≃ₗ[R] Matrix n m N₂ :=
LinearMap.toMatrixₛₗ₂' R
variable (σ₁ σ₂)
/-- The linear equivalence between `n × n` matrices and sesquilinear maps on `n → R` -/
def Matrix.toLinearMapₛₗ₂' : Matrix n m N₂ ≃ₗ[R] (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] N₂ :=
(LinearMap.toMatrixₛₗ₂' R).symm
/-- The linear equivalence between `n × n` matrices and bilinear maps on `n → R` -/
def Matrix.toLinearMap₂' : Matrix n m N₂ ≃ₗ[R] (n → S₁) →ₗ[S₁] (m → S₂) →ₗ[S₂] N₂ :=
(LinearMap.toMatrix₂' R).symm
variable {R}
theorem Matrix.toLinearMapₛₗ₂'_aux_eq (M : Matrix n m N₂) :
Matrix.toLinearMap₂'Aux σ₁ σ₂ M = Matrix.toLinearMapₛₗ₂' R σ₁ σ₂ M :=
rfl
theorem Matrix.toLinearMapₛₗ₂'_apply (M : Matrix n m N₂) (x : n → R₁) (y : m → R₂) :
-- porting note: we don't seem to have `∑ i j` as valid notation yet
Matrix.toLinearMapₛₗ₂' R σ₁ σ₂ M x y = ∑ i, ∑ j, σ₁ (x i) • σ₂ (y j) • M i j := by
rw [toLinearMapₛₗ₂', toMatrixₛₗ₂', LinearEquiv.coe_symm_mk, toLinearMap₂'Aux, mk₂'ₛₗ_apply]
apply Finset.sum_congr rfl fun _ _ => Finset.sum_congr rfl fun _ _ => by
rw [smul_comm]
theorem Matrix.toLinearMap₂'_apply (M : Matrix n m N₂) (x : n → S₁) (y : m → S₂) :
-- porting note: we don't seem to have `∑ i j` as valid notation yet
Matrix.toLinearMap₂' R M x y = ∑ i, ∑ j, x i • y j • M i j :=
Finset.sum_congr rfl fun _ _ => Finset.sum_congr rfl fun _ _ => by
rw [RingHom.id_apply, RingHom.id_apply, smul_comm]
theorem Matrix.toLinearMap₂'_apply' {T : Type*} [CommSemiring T] (M : Matrix n m T) (v : n → T)
(w : m → T) : Matrix.toLinearMap₂' T M v w = dotProduct v (M *ᵥ w) := by
simp_rw [Matrix.toLinearMap₂'_apply, dotProduct, Matrix.mulVec, dotProduct]
refine Finset.sum_congr rfl fun _ _ => ?_
rw [Finset.mul_sum]
refine Finset.sum_congr rfl fun _ _ => ?_
rw [smul_eq_mul, smul_eq_mul, mul_comm (w _), ← mul_assoc]
@[simp]
theorem Matrix.toLinearMapₛₗ₂'_single (M : Matrix n m N₂) (i : n) (j : m) :
Matrix.toLinearMapₛₗ₂' R σ₁ σ₂ M (Pi.single i 1) (Pi.single j 1) = M i j :=
Matrix.toLinearMap₂'Aux_single σ₁ σ₂ M i j
@[simp]
theorem Matrix.toLinearMap₂'_single (M : Matrix n m N₂) (i : n) (j : m) :
Matrix.toLinearMap₂' R M (Pi.single i 1) (Pi.single j 1) = M i j :=
Matrix.toLinearMap₂'Aux_single _ _ M i j
@[simp]
theorem LinearMap.toMatrixₛₗ₂'_symm :
((LinearMap.toMatrixₛₗ₂' R).symm : Matrix n m N₂ ≃ₗ[R] _) = Matrix.toLinearMapₛₗ₂' R σ₁ σ₂ :=
rfl
@[simp]
theorem Matrix.toLinearMapₛₗ₂'_symm :
((Matrix.toLinearMapₛₗ₂' R σ₁ σ₂).symm : _ ≃ₗ[R] Matrix n m N₂) = LinearMap.toMatrixₛₗ₂' R :=
(LinearMap.toMatrixₛₗ₂' R).symm_symm
@[simp]
theorem Matrix.toLinearMapₛₗ₂'_toMatrix' (B : (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] N₂) :
Matrix.toLinearMapₛₗ₂' R σ₁ σ₂ (LinearMap.toMatrixₛₗ₂' R B) = B :=
(Matrix.toLinearMapₛₗ₂' R σ₁ σ₂).apply_symm_apply B
@[simp]
theorem Matrix.toLinearMap₂'_toMatrix' (B : (n → S₁) →ₗ[S₁] (m → S₂) →ₗ[S₂] N₂) :
Matrix.toLinearMap₂' R (LinearMap.toMatrix₂' R B) = B :=
(Matrix.toLinearMap₂' R).apply_symm_apply B
@[simp]
theorem LinearMap.toMatrix'_toLinearMapₛₗ₂' (M : Matrix n m N₂) :
LinearMap.toMatrixₛₗ₂' R (Matrix.toLinearMapₛₗ₂' R σ₁ σ₂ M) = M :=
(LinearMap.toMatrixₛₗ₂' R).apply_symm_apply M
@[simp]
theorem LinearMap.toMatrix'_toLinearMap₂' (M : Matrix n m N₂) :
LinearMap.toMatrix₂' R (Matrix.toLinearMap₂' R (S₁ := S₁) (S₂ := S₂) M) = M :=
(LinearMap.toMatrixₛₗ₂' R).apply_symm_apply M
@[simp]
theorem LinearMap.toMatrixₛₗ₂'_apply (B : (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] N₂) (i : n) (j : m) :
LinearMap.toMatrixₛₗ₂' R B i j = B (Pi.single i 1) (Pi.single j 1) :=
rfl
@[simp]
theorem LinearMap.toMatrix₂'_apply (B : (n → S₁) →ₗ[S₁] (m → S₂) →ₗ[S₂] N₂) (i : n) (j : m) :
LinearMap.toMatrix₂' R B i j = B (Pi.single i 1) (Pi.single j 1) :=
rfl
end ToMatrix'
section CommToMatrix'
-- TODO: Introduce matrix multiplication by matrices of scalars
variable {R : Type*} [CommSemiring R]
variable [Fintype n] [Fintype m]
variable [DecidableEq n] [DecidableEq m]
variable [Fintype n'] [Fintype m']
variable [DecidableEq n'] [DecidableEq m']
@[simp]
theorem LinearMap.toMatrix₂'_compl₁₂ (B : (n → R) →ₗ[R] (m → R) →ₗ[R] R) (l : (n' → R) →ₗ[R] n → R)
(r : (m' → R) →ₗ[R] m → R) :
toMatrix₂' R (B.compl₁₂ l r) = (toMatrix' l)ᵀ * toMatrix₂' R B * toMatrix' r := by
ext i j
simp only [LinearMap.toMatrix₂'_apply, LinearMap.compl₁₂_apply, transpose_apply, Matrix.mul_apply,
LinearMap.toMatrix', LinearEquiv.coe_mk, sum_mul]
rw [sum_comm]
conv_lhs => rw [← LinearMap.sum_repr_mul_repr_mul (Pi.basisFun R n) (Pi.basisFun R m) (l _) (r _)]
rw [Finsupp.sum_fintype]
· apply sum_congr rfl
rintro i' -
rw [Finsupp.sum_fintype]
· apply sum_congr rfl
rintro j' -
simp only [smul_eq_mul, Pi.basisFun_repr, mul_assoc, mul_comm, mul_left_comm,
Pi.basisFun_apply, of_apply]
· intros
simp only [zero_smul, smul_zero]
· intros
simp only [zero_smul, Finsupp.sum_zero]
theorem LinearMap.toMatrix₂'_comp (B : (n → R) →ₗ[R] (m → R) →ₗ[R] R) (f : (n' → R) →ₗ[R] n → R) :
toMatrix₂' R (B.comp f) = (toMatrix' f)ᵀ * toMatrix₂' R B := by
rw [← LinearMap.compl₂_id (B.comp f), ← LinearMap.compl₁₂]
simp
theorem LinearMap.toMatrix₂'_compl₂ (B : (n → R) →ₗ[R] (m → R) →ₗ[R] R) (f : (m' → R) →ₗ[R] m → R) :
toMatrix₂' R (B.compl₂ f) = toMatrix₂' R B * toMatrix' f := by
rw [← LinearMap.comp_id B, ← LinearMap.compl₁₂]
simp
theorem LinearMap.mul_toMatrix₂'_mul (B : (n → R) →ₗ[R] (m → R) →ₗ[R] R) (M : Matrix n' n R)
(N : Matrix m m' R) :
M * toMatrix₂' R B * N = toMatrix₂' R (B.compl₁₂ (toLin' Mᵀ) (toLin' N)) := by
simp
theorem LinearMap.mul_toMatrix' (B : (n → R) →ₗ[R] (m → R) →ₗ[R] R) (M : Matrix n' n R) :
M * toMatrix₂' R B = toMatrix₂' R (B.comp <| toLin' Mᵀ) := by
simp only [B.toMatrix₂'_comp, transpose_transpose, toMatrix'_toLin']
theorem LinearMap.toMatrix₂'_mul (B : (n → R) →ₗ[R] (m → R) →ₗ[R] R) (M : Matrix m m' R) :
toMatrix₂' R B * M = toMatrix₂' R (B.compl₂ <| toLin' M) := by
simp only [B.toMatrix₂'_compl₂, toMatrix'_toLin']
theorem Matrix.toLinearMap₂'_comp (M : Matrix n m R) (P : Matrix n n' R) (Q : Matrix m m' R) :
LinearMap.compl₁₂ (Matrix.toLinearMap₂' R M) (toLin' P) (toLin' Q) =
toLinearMap₂' R (Pᵀ * M * Q) :=
(LinearMap.toMatrix₂' R).injective (by simp)
end CommToMatrix'
section ToMatrix
/-! ### Bilinear maps over arbitrary vector spaces
This section deals with the conversion between matrices and bilinear maps on
a module with a fixed basis.
-/
variable [CommSemiring R]
variable [AddCommMonoid M₁] [Module R M₁] [AddCommMonoid M₂] [Module R M₂] [AddCommMonoid N₂]
[Module R N₂]
variable [DecidableEq n] [Fintype n]
variable [DecidableEq m] [Fintype m]
section
variable (b₁ : Basis n R M₁) (b₂ : Basis m R M₂)
/-- `LinearMap.toMatrix₂ b₁ b₂` is the equivalence between `R`-bilinear maps on `M` and
`n`-by-`m` matrices with entries in `R`, if `b₁` and `b₂` are `R`-bases for `M₁` and `M₂`,
respectively. -/
noncomputable def LinearMap.toMatrix₂ : (M₁ →ₗ[R] M₂ →ₗ[R] N₂) ≃ₗ[R] Matrix n m N₂ :=
(b₁.equivFun.arrowCongr (b₂.equivFun.arrowCongr (LinearEquiv.refl R N₂))).trans
(LinearMap.toMatrix₂' R)
/-- `Matrix.toLinearMap₂ b₁ b₂` is the equivalence between `R`-bilinear maps on `M` and
`n`-by-`m` matrices with entries in `R`, if `b₁` and `b₂` are `R`-bases for `M₁` and `M₂`,
respectively; this is the reverse direction of `LinearMap.toMatrix₂ b₁ b₂`. -/
noncomputable def Matrix.toLinearMap₂ : Matrix n m N₂ ≃ₗ[R] M₁ →ₗ[R] M₂ →ₗ[R] N₂ :=
(LinearMap.toMatrix₂ b₁ b₂).symm
-- We make this and not `LinearMap.toMatrix₂` a `simp` lemma to avoid timeouts
@[simp]
theorem LinearMap.toMatrix₂_apply (B : M₁ →ₗ[R] M₂ →ₗ[R] N₂) (i : n) (j : m) :
LinearMap.toMatrix₂ b₁ b₂ B i j = B (b₁ i) (b₂ j) := by
simp only [toMatrix₂, LinearEquiv.trans_apply, toMatrix₂'_apply, LinearEquiv.arrowCongr_apply,
Basis.equivFun_symm_apply, Pi.single_apply, ite_smul, one_smul, zero_smul, sum_ite_eq',
mem_univ, ↓reduceIte, LinearEquiv.refl_apply]
@[simp]
theorem Matrix.toLinearMap₂_apply (M : Matrix n m N₂) (x : M₁) (y : M₂) :
Matrix.toLinearMap₂ b₁ b₂ M x y = ∑ i, ∑ j, b₁.repr x i • b₂.repr y j • M i j :=
Finset.sum_congr rfl fun _ _ => Finset.sum_congr rfl fun _ _ =>
smul_algebra_smul_comm ((RingHom.id R) ((Basis.equivFun b₁) x _))
((RingHom.id R) ((Basis.equivFun b₂) y _)) (M _ _)
-- Not a `simp` lemma since `LinearMap.toMatrix₂` needs an extra argument
theorem LinearMap.toMatrix₂Aux_eq (B : M₁ →ₗ[R] M₂ →ₗ[R] N₂) :
LinearMap.toMatrix₂Aux R b₁ b₂ B = LinearMap.toMatrix₂ b₁ b₂ B :=
Matrix.ext fun i j => by rw [LinearMap.toMatrix₂_apply, LinearMap.toMatrix₂Aux_apply]
@[simp]
theorem LinearMap.toMatrix₂_symm :
(LinearMap.toMatrix₂ b₁ b₂).symm = Matrix.toLinearMap₂ (N₂ := N₂) b₁ b₂ :=
rfl
@[simp]
theorem Matrix.toLinearMap₂_symm :
(Matrix.toLinearMap₂ b₁ b₂).symm = LinearMap.toMatrix₂ (N₂ := N₂) b₁ b₂ :=
(LinearMap.toMatrix₂ b₁ b₂).symm_symm
theorem Matrix.toLinearMap₂_basisFun :
Matrix.toLinearMap₂ (Pi.basisFun R n) (Pi.basisFun R m) =
Matrix.toLinearMap₂' R (N₂ := N₂) := by
ext M
simp only [coe_comp, coe_single, Function.comp_apply, toLinearMap₂_apply, Pi.basisFun_repr,
toLinearMap₂'_apply]
theorem LinearMap.toMatrix₂_basisFun :
LinearMap.toMatrix₂ (Pi.basisFun R n) (Pi.basisFun R m) =
LinearMap.toMatrix₂' R (N₂ := N₂) := by
ext B
rw [LinearMap.toMatrix₂_apply, LinearMap.toMatrix₂'_apply, Pi.basisFun_apply, Pi.basisFun_apply]
@[simp]
theorem Matrix.toLinearMap₂_toMatrix₂ (B : M₁ →ₗ[R] M₂ →ₗ[R] N₂) :
Matrix.toLinearMap₂ b₁ b₂ (LinearMap.toMatrix₂ b₁ b₂ B) = B :=
(Matrix.toLinearMap₂ b₁ b₂).apply_symm_apply B
@[simp]
theorem LinearMap.toMatrix₂_toLinearMap₂ (M : Matrix n m N₂) :
LinearMap.toMatrix₂ b₁ b₂ (Matrix.toLinearMap₂ b₁ b₂ M) = M :=
(LinearMap.toMatrix₂ b₁ b₂).apply_symm_apply M
variable (b₁ : Basis n R M₁) (b₂ : Basis m R M₂)
variable [AddCommMonoid M₁'] [Module R M₁']
variable [AddCommMonoid M₂'] [Module R M₂']
variable (b₁' : Basis n' R M₁')
variable (b₂' : Basis m' R M₂')
variable [Fintype n'] [Fintype m']
variable [DecidableEq n'] [DecidableEq m']
-- Cannot be a `simp` lemma because `b₁` and `b₂` must be inferred.
theorem LinearMap.toMatrix₂_compl₁₂ (B : M₁ →ₗ[R] M₂ →ₗ[R] R) (l : M₁' →ₗ[R] M₁)
(r : M₂' →ₗ[R] M₂) :
LinearMap.toMatrix₂ b₁' b₂' (B.compl₁₂ l r) =
(toMatrix b₁' b₁ l)ᵀ * LinearMap.toMatrix₂ b₁ b₂ B * toMatrix b₂' b₂ r := by
ext i j
simp only [LinearMap.toMatrix₂_apply, compl₁₂_apply, transpose_apply, Matrix.mul_apply,
LinearMap.toMatrix_apply, LinearEquiv.coe_mk, sum_mul]
rw [sum_comm]
conv_lhs => rw [← LinearMap.sum_repr_mul_repr_mul b₁ b₂]
rw [Finsupp.sum_fintype]
· apply sum_congr rfl
rintro i' -
rw [Finsupp.sum_fintype]
· apply sum_congr rfl
rintro j' -
simp only [smul_eq_mul, LinearMap.toMatrix_apply, Basis.equivFun_apply, mul_assoc, mul_comm,
mul_left_comm]
· intros
simp only [zero_smul, smul_zero]
· intros
simp only [zero_smul, Finsupp.sum_zero]
theorem LinearMap.toMatrix₂_comp (B : M₁ →ₗ[R] M₂ →ₗ[R] R) (f : M₁' →ₗ[R] M₁) :
LinearMap.toMatrix₂ b₁' b₂ (B.comp f) =
(toMatrix b₁' b₁ f)ᵀ * LinearMap.toMatrix₂ b₁ b₂ B := by
rw [← LinearMap.compl₂_id (B.comp f), ← LinearMap.compl₁₂, LinearMap.toMatrix₂_compl₁₂ b₁ b₂]
simp
theorem LinearMap.toMatrix₂_compl₂ (B : M₁ →ₗ[R] M₂ →ₗ[R] R) (f : M₂' →ₗ[R] M₂) :
LinearMap.toMatrix₂ b₁ b₂' (B.compl₂ f) =
LinearMap.toMatrix₂ b₁ b₂ B * toMatrix b₂' b₂ f := by
rw [← LinearMap.comp_id B, ← LinearMap.compl₁₂, LinearMap.toMatrix₂_compl₁₂ b₁ b₂]
simp
@[simp]
theorem LinearMap.toMatrix₂_mul_basis_toMatrix (c₁ : Basis n' R M₁) (c₂ : Basis m' R M₂)
(B : M₁ →ₗ[R] M₂ →ₗ[R] R) :
(b₁.toMatrix c₁)ᵀ * LinearMap.toMatrix₂ b₁ b₂ B * b₂.toMatrix c₂ =
LinearMap.toMatrix₂ c₁ c₂ B := by
simp_rw [← LinearMap.toMatrix_id_eq_basis_toMatrix]
rw [← LinearMap.toMatrix₂_compl₁₂, LinearMap.compl₁₂_id_id]
theorem LinearMap.mul_toMatrix₂_mul (B : M₁ →ₗ[R] M₂ →ₗ[R] R) (M : Matrix n' n R)
(N : Matrix m m' R) :
M * LinearMap.toMatrix₂ b₁ b₂ B * N =
LinearMap.toMatrix₂ b₁' b₂' (B.compl₁₂ (toLin b₁' b₁ Mᵀ) (toLin b₂' b₂ N)) := by
simp_rw [LinearMap.toMatrix₂_compl₁₂ b₁ b₂, toMatrix_toLin, transpose_transpose]
theorem LinearMap.mul_toMatrix₂ (B : M₁ →ₗ[R] M₂ →ₗ[R] R) (M : Matrix n' n R) :
M * LinearMap.toMatrix₂ b₁ b₂ B =
LinearMap.toMatrix₂ b₁' b₂ (B.comp (toLin b₁' b₁ Mᵀ)) := by
rw [LinearMap.toMatrix₂_comp b₁, toMatrix_toLin, transpose_transpose]
| Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean | 456 | 461 | theorem LinearMap.toMatrix₂_mul (B : M₁ →ₗ[R] M₂ →ₗ[R] R) (M : Matrix m m' R) :
LinearMap.toMatrix₂ b₁ b₂ B * M =
LinearMap.toMatrix₂ b₁ b₂' (B.compl₂ (toLin b₂' b₂ M)) := by | rw [LinearMap.toMatrix₂_compl₂ b₁ b₂, toMatrix_toLin]
theorem Matrix.toLinearMap₂_compl₁₂ (M : Matrix n m R) (P : Matrix n n' R) (Q : Matrix m m' R) : |
/-
Copyright (c) 2022 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.MeasureTheory.Measure.Typeclasses.Probability
/-!
# Ergodic maps and measures
Let `f : α → α` be measure preserving with respect to a measure `μ`. We say `f` is ergodic with
respect to `μ` (or `μ` is ergodic with respect to `f`) if the only measurable sets `s` such that
`f⁻¹' s = s` are either almost empty or full.
In this file we define ergodic maps / measures together with quasi-ergodic maps / measures and
provide some basic API. Quasi-ergodicity is a weaker condition than ergodicity for which the measure
preserving condition is relaxed to quasi measure preserving.
# Main definitions:
* `PreErgodic`: the ergodicity condition without the measure preserving condition. This exists
to share code between the `Ergodic` and `QuasiErgodic` definitions.
* `Ergodic`: the definition of ergodic maps / measures.
* `QuasiErgodic`: the definition of quasi ergodic maps / measures.
* `Ergodic.quasiErgodic`: an ergodic map / measure is quasi ergodic.
* `QuasiErgodic.ae_empty_or_univ'`: when the map is quasi measure preserving, one may relax the
strict invariance condition to almost invariance in the ergodicity condition.
-/
open Set Function Filter MeasureTheory MeasureTheory.Measure
open ENNReal
variable {α : Type*} {m : MeasurableSpace α} {s : Set α}
/-- A map `f : α → α` is said to be pre-ergodic with respect to a measure `μ` if any measurable
strictly invariant set is either almost empty or full. -/
structure PreErgodic (f : α → α) (μ : Measure α := by volume_tac) : Prop where
aeconst_set ⦃s : Set α⦄ : MeasurableSet s → f ⁻¹' s = s → EventuallyConst s (ae μ)
/-- A map `f : α → α` is said to be ergodic with respect to a measure `μ` if it is measure
preserving and pre-ergodic. -/
structure Ergodic (f : α → α) (μ : Measure α := by volume_tac) : Prop extends
MeasurePreserving f μ μ, PreErgodic f μ
/-- A map `f : α → α` is said to be quasi ergodic with respect to a measure `μ` if it is quasi
measure preserving and pre-ergodic. -/
structure QuasiErgodic (f : α → α) (μ : Measure α := by volume_tac) : Prop extends
QuasiMeasurePreserving f μ μ, PreErgodic f μ
variable {f : α → α} {μ : Measure α}
namespace PreErgodic
theorem ae_empty_or_univ (hf : PreErgodic f μ) (hs : MeasurableSet s) (hfs : f ⁻¹' s = s) :
s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := by
simpa only [eventuallyConst_set'] using hf.aeconst_set hs hfs
theorem measure_self_or_compl_eq_zero (hf : PreErgodic f μ) (hs : MeasurableSet s)
(hs' : f ⁻¹' s = s) : μ s = 0 ∨ μ sᶜ = 0 := by
simpa using hf.ae_empty_or_univ hs hs'
theorem ae_mem_or_ae_nmem (hf : PreErgodic f μ) (hsm : MeasurableSet s) (hs : f ⁻¹' s = s) :
(∀ᵐ x ∂μ, x ∈ s) ∨ ∀ᵐ x ∂μ, x ∉ s :=
eventuallyConst_set.1 <| hf.aeconst_set hsm hs
/-- On a probability space, the (pre)ergodicity condition is a zero one law. -/
theorem prob_eq_zero_or_one [IsProbabilityMeasure μ] (hf : PreErgodic f μ) (hs : MeasurableSet s)
(hs' : f ⁻¹' s = s) : μ s = 0 ∨ μ s = 1 := by
simpa [hs] using hf.measure_self_or_compl_eq_zero hs hs'
theorem of_iterate (n : ℕ) (hf : PreErgodic f^[n] μ) : PreErgodic f μ :=
⟨fun _ hs hs' => hf.aeconst_set hs <| IsFixedPt.preimage_iterate hs' n⟩
theorem smul_measure {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
(hf : PreErgodic f μ) (c : R) : PreErgodic f (c • μ) where
aeconst_set _s hs hfs := (hf.aeconst_set hs hfs).anti <| ae_smul_measure_le _
theorem zero_measure (f : α → α) : @PreErgodic α m f 0 where
aeconst_set _ _ _ := by simp
end PreErgodic
namespace MeasureTheory.MeasurePreserving
variable {β : Type*} {m' : MeasurableSpace β} {μ' : Measure β} {g : α → β}
theorem preErgodic_of_preErgodic_conjugate (hg : MeasurePreserving g μ μ') (hf : PreErgodic f μ)
{f' : β → β} (h_comm : Semiconj g f f') : PreErgodic f' μ' where
aeconst_set s hs₀ hs₁ := by
rw [← hg.aeconst_preimage hs₀.nullMeasurableSet]
apply hf.aeconst_set (hg.measurable hs₀)
rw [← preimage_comp, h_comm.comp_eq, preimage_comp, hs₁]
theorem preErgodic_conjugate_iff {e : α ≃ᵐ β} (h : MeasurePreserving e μ μ') :
PreErgodic (e ∘ f ∘ e.symm) μ' ↔ PreErgodic f μ := by
refine ⟨fun hf => preErgodic_of_preErgodic_conjugate (h.symm e) hf ?_,
fun hf => preErgodic_of_preErgodic_conjugate h hf ?_⟩
· simp [Semiconj]
· simp [Semiconj]
theorem ergodic_conjugate_iff {e : α ≃ᵐ β} (h : MeasurePreserving e μ μ') :
Ergodic (e ∘ f ∘ e.symm) μ' ↔ Ergodic f μ := by
have : MeasurePreserving (e ∘ f ∘ e.symm) μ' μ' ↔ MeasurePreserving f μ μ := by
rw [h.comp_left_iff, (MeasurePreserving.symm e h).comp_right_iff]
replace h : PreErgodic (e ∘ f ∘ e.symm) μ' ↔ PreErgodic f μ := h.preErgodic_conjugate_iff
exact ⟨fun hf => { this.mp hf.toMeasurePreserving, h.mp hf.toPreErgodic with },
fun hf => { this.mpr hf.toMeasurePreserving, h.mpr hf.toPreErgodic with }⟩
end MeasureTheory.MeasurePreserving
namespace QuasiErgodic
theorem aeconst_set₀ (hf : QuasiErgodic f μ) (hsm : NullMeasurableSet s μ) (hs : f ⁻¹' s =ᵐ[μ] s) :
EventuallyConst s (ae μ) :=
let ⟨_t, h₀, h₁, h₂⟩ := hf.toQuasiMeasurePreserving.exists_preimage_eq_of_preimage_ae hsm hs
(hf.aeconst_set h₀ h₂).congr h₁
/-- For a quasi ergodic map, sets that are almost invariant (rather than strictly invariant) are
still either almost empty or full. -/
theorem ae_empty_or_univ₀ (hf : QuasiErgodic f μ) (hsm : NullMeasurableSet s μ)
(hs : f ⁻¹' s =ᵐ[μ] s) :
s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ :=
eventuallyConst_set'.mp <| hf.aeconst_set₀ hsm hs
/-- For a quasi ergodic map, sets that are almost invariant (rather than strictly invariant) are
still either almost empty or full. -/
theorem ae_mem_or_ae_nmem₀ (hf : QuasiErgodic f μ) (hsm : NullMeasurableSet s μ)
(hs : f ⁻¹' s =ᵐ[μ] s) :
(∀ᵐ x ∂μ, x ∈ s) ∨ ∀ᵐ x ∂μ, x ∉ s :=
eventuallyConst_set.mp <| hf.aeconst_set₀ hsm hs
theorem smul_measure {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
(hf : QuasiErgodic f μ) (c : R) : QuasiErgodic f (c • μ) :=
⟨hf.1.smul_measure _, hf.2.smul_measure _⟩
| Mathlib/Dynamics/Ergodic/Ergodic.lean | 140 | 143 | theorem zero_measure {f : α → α} (hf : Measurable f) : @QuasiErgodic α m f 0 where
measurable := hf
absolutelyContinuous := by | simp
toPreErgodic := .zero_measure f |
/-
Copyright (c) 2023 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Joël Riou
-/
import Mathlib.Algebra.Homology.ShortComplex.ModuleCat
import Mathlib.RepresentationTheory.GroupCohomology.Basic
import Mathlib.RepresentationTheory.Invariants
/-!
# The low-degree cohomology of a `k`-linear `G`-representation
Let `k` be a commutative ring and `G` a group. This file gives simple expressions for
the group cohomology of a `k`-linear `G`-representation `A` in degrees 0, 1 and 2.
In `RepresentationTheory.GroupCohomology.Basic`, we define the `n`th group cohomology of `A` to be
the cohomology of a complex `inhomogeneousCochains A`, whose objects are `(Fin n → G) → A`; this is
unnecessarily unwieldy in low degree. Moreover, cohomology of a complex is defined as an abstract
cokernel, whereas the definitions here are explicit quotients of cocycles by coboundaries.
We also show that when the representation on `A` is trivial, `H¹(G, A) ≃ Hom(G, A)`.
Given an additive or multiplicative abelian group `A` with an appropriate scalar action of `G`,
we provide support for turning a function `f : G → A` satisfying the 1-cocycle identity into an
element of the `oneCocycles` of the representation on `A` (or `Additive A`) corresponding to the
scalar action. We also do this for 1-coboundaries, 2-cocycles and 2-coboundaries. The
multiplicative case, starting with the section `IsMulCocycle`, just mirrors the additive case;
unfortunately `@[to_additive]` can't deal with scalar actions.
The file also contains an identification between the definitions in
`RepresentationTheory.GroupCohomology.Basic`, `groupCohomology.cocycles A n` and
`groupCohomology A n`, and the `nCocycles` and `Hn A` in this file, for `n = 0, 1, 2`.
## Main definitions
* `groupCohomology.H0 A`: the invariants `Aᴳ` of the `G`-representation on `A`.
* `groupCohomology.H1 A`: 1-cocycles (i.e. `Z¹(G, A) := Ker(d¹ : Fun(G, A) → Fun(G², A)`) modulo
1-coboundaries (i.e. `B¹(G, A) := Im(d⁰: A → Fun(G, A))`).
* `groupCohomology.H2 A`: 2-cocycles (i.e. `Z²(G, A) := Ker(d² : Fun(G², A) → Fun(G³, A)`) modulo
2-coboundaries (i.e. `B²(G, A) := Im(d¹: Fun(G, A) → Fun(G², A))`).
* `groupCohomology.H1LequivOfIsTrivial`: the isomorphism `H¹(G, A) ≃ Hom(G, A)` when the
representation on `A` is trivial.
* `groupCohomology.isoHn` for `n = 0, 1, 2`: an isomorphism
`groupCohomology A n ≅ groupCohomology.Hn A`.
## TODO
* The relationship between `H2` and group extensions
* The inflation-restriction exact sequence
* Nonabelian group cohomology
-/
universe v u
noncomputable section
open CategoryTheory Limits Representation
variable {k G : Type u} [CommRing k] [Group G] (A : Rep k G)
namespace groupCohomology
section Cochains
/-- The 0th object in the complex of inhomogeneous cochains of `A : Rep k G` is isomorphic
to `A` as a `k`-module. -/
def zeroCochainsLequiv : (inhomogeneousCochains A).X 0 ≃ₗ[k] A :=
LinearEquiv.funUnique (Fin 0 → G) k A
/-- The 1st object in the complex of inhomogeneous cochains of `A : Rep k G` is isomorphic
to `Fun(G, A)` as a `k`-module. -/
def oneCochainsLequiv : (inhomogeneousCochains A).X 1 ≃ₗ[k] G → A :=
LinearEquiv.funCongrLeft k A (Equiv.funUnique (Fin 1) G).symm
/-- The 2nd object in the complex of inhomogeneous cochains of `A : Rep k G` is isomorphic
to `Fun(G², A)` as a `k`-module. -/
def twoCochainsLequiv : (inhomogeneousCochains A).X 2 ≃ₗ[k] G × G → A :=
LinearEquiv.funCongrLeft k A <| (piFinTwoEquiv fun _ => G).symm
/-- The 3rd object in the complex of inhomogeneous cochains of `A : Rep k G` is isomorphic
to `Fun(G³, A)` as a `k`-module. -/
def threeCochainsLequiv : (inhomogeneousCochains A).X 3 ≃ₗ[k] G × G × G → A :=
LinearEquiv.funCongrLeft k A <| ((Fin.consEquiv _).symm.trans
((Equiv.refl G).prodCongr (piFinTwoEquiv fun _ => G))).symm
end Cochains
section Differentials
/-- The 0th differential in the complex of inhomogeneous cochains of `A : Rep k G`, as a
`k`-linear map `A → Fun(G, A)`. It sends `(a, g) ↦ ρ_A(g)(a) - a.` -/
@[simps]
def dZero : A →ₗ[k] G → A where
toFun m g := A.ρ g m - m
map_add' x y := funext fun g => by simp only [map_add, add_sub_add_comm]; rfl
map_smul' r x := funext fun g => by dsimp; rw [map_smul, smul_sub]
theorem dZero_ker_eq_invariants : LinearMap.ker (dZero A) = invariants A.ρ := by
ext x
simp only [LinearMap.mem_ker, mem_invariants, ← @sub_eq_zero _ _ _ x, funext_iff]
rfl
@[simp] theorem dZero_eq_zero [A.IsTrivial] : dZero A = 0 := by
ext
simp only [dZero_apply, isTrivial_apply, sub_self, LinearMap.zero_apply, Pi.zero_apply]
lemma dZero_comp_subtype : dZero A ∘ₗ A.ρ.invariants.subtype = 0 := by
ext ⟨x, hx⟩ g
replace hx := hx g
rw [← sub_eq_zero] at hx
exact hx
/-- The 1st differential in the complex of inhomogeneous cochains of `A : Rep k G`, as a
`k`-linear map `Fun(G, A) → Fun(G × G, A)`. It sends
`(f, (g₁, g₂)) ↦ ρ_A(g₁)(f(g₂)) - f(g₁g₂) + f(g₁).` -/
@[simps]
def dOne : (G → A) →ₗ[k] G × G → A where
toFun f g := A.ρ g.1 (f g.2) - f (g.1 * g.2) + f g.1
map_add' x y := funext fun g => by dsimp; rw [map_add, add_add_add_comm, add_sub_add_comm]
map_smul' r x := funext fun g => by dsimp; rw [map_smul, smul_add, smul_sub]
/-- The 2nd differential in the complex of inhomogeneous cochains of `A : Rep k G`, as a
`k`-linear map `Fun(G × G, A) → Fun(G × G × G, A)`. It sends
`(f, (g₁, g₂, g₃)) ↦ ρ_A(g₁)(f(g₂, g₃)) - f(g₁g₂, g₃) + f(g₁, g₂g₃) - f(g₁, g₂).` -/
@[simps]
def dTwo : (G × G → A) →ₗ[k] G × G × G → A where
toFun f g :=
A.ρ g.1 (f (g.2.1, g.2.2)) - f (g.1 * g.2.1, g.2.2) + f (g.1, g.2.1 * g.2.2) - f (g.1, g.2.1)
map_add' x y :=
funext fun g => by
dsimp
rw [map_add, add_sub_add_comm (A.ρ _ _), add_sub_assoc, add_sub_add_comm, add_add_add_comm,
add_sub_assoc, add_sub_assoc]
map_smul' r x := funext fun g => by dsimp; simp only [map_smul, smul_add, smul_sub]
/-- Let `C(G, A)` denote the complex of inhomogeneous cochains of `A : Rep k G`. This lemma
says `dZero` gives a simpler expression for the 0th differential: that is, the following
square commutes:
```
C⁰(G, A) ---d⁰---> C¹(G, A)
| |
| |
| |
v v
A ---- dZero ---> Fun(G, A)
```
where the vertical arrows are `zeroCochainsLequiv` and `oneCochainsLequiv` respectively.
-/
theorem dZero_comp_eq : dZero A ∘ₗ (zeroCochainsLequiv A) =
oneCochainsLequiv A ∘ₗ ((inhomogeneousCochains A).d 0 1).hom := by
ext x y
show A.ρ y (x default) - x default = _ + ({0} : Finset _).sum _
simp_rw [Fin.val_eq_zero, zero_add, pow_one, neg_smul, one_smul,
Finset.sum_singleton, sub_eq_add_neg]
rcongr i <;> exact Fin.elim0 i
/-- Let `C(G, A)` denote the complex of inhomogeneous cochains of `A : Rep k G`. This lemma
says `dOne` gives a simpler expression for the 1st differential: that is, the following
square commutes:
```
C¹(G, A) ---d¹-----> C²(G, A)
| |
| |
| |
v v
Fun(G, A) -dOne-> Fun(G × G, A)
```
where the vertical arrows are `oneCochainsLequiv` and `twoCochainsLequiv` respectively.
-/
theorem dOne_comp_eq : dOne A ∘ₗ oneCochainsLequiv A =
twoCochainsLequiv A ∘ₗ ((inhomogeneousCochains A).d 1 2).hom := by
ext x y
show A.ρ y.1 (x _) - x _ + x _ = _ + _
rw [Fin.sum_univ_two]
simp only [Fin.val_zero, zero_add, pow_one, neg_smul, one_smul, Fin.val_one,
Nat.one_add, neg_one_sq, sub_eq_add_neg, add_assoc]
rcongr i <;> rw [Subsingleton.elim i 0] <;> rfl
/-- Let `C(G, A)` denote the complex of inhomogeneous cochains of `A : Rep k G`. This lemma
says `dTwo` gives a simpler expression for the 2nd differential: that is, the following
square commutes:
```
C²(G, A) -------d²-----> C³(G, A)
| |
| |
| |
v v
Fun(G × G, A) --dTwo--> Fun(G × G × G, A)
```
where the vertical arrows are `twoCochainsLequiv` and `threeCochainsLequiv` respectively.
-/
theorem dTwo_comp_eq :
dTwo A ∘ₗ twoCochainsLequiv A =
threeCochainsLequiv A ∘ₗ ((inhomogeneousCochains A).d 2 3).hom := by
ext x y
show A.ρ y.1 (x _) - x _ + x _ - x _ = _ + _
dsimp
rw [Fin.sum_univ_three]
simp only [sub_eq_add_neg, add_assoc, Fin.val_zero, zero_add, pow_one, neg_smul,
one_smul, Fin.val_one, Fin.val_two, pow_succ' (-1 : k) 2, neg_sq, Nat.one_add, one_pow, mul_one]
rcongr i <;> fin_cases i <;> rfl
| Mathlib/RepresentationTheory/GroupCohomology/LowDegree.lean | 204 | 210 | theorem dOne_comp_dZero : dOne A ∘ₗ dZero A = 0 := by | ext x g
simp only [LinearMap.coe_comp, Function.comp_apply, dOne_apply A, dZero_apply A, map_sub,
map_mul, Module.End.mul_apply, sub_sub_sub_cancel_left, sub_add_sub_cancel, sub_self]
rfl
theorem dTwo_comp_dOne : dTwo A ∘ₗ dOne A = 0 := by |
/-
Copyright (c) 2024 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alex Kontorovich, David Loeffler, Heather Macbeth, Sébastien Gouëzel
-/
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.Analysis.Calculus.ContDiff.CPolynomial
import Mathlib.Analysis.Fourier.AddCircle
import Mathlib.Analysis.Fourier.FourierTransform
import Mathlib.Analysis.Calculus.FDeriv.Analytic
import Mathlib.Analysis.Calculus.LineDeriv.IntegrationByParts
import Mathlib.Analysis.Calculus.ContDiff.Bounds
/-!
# Derivatives of the Fourier transform
In this file we compute the Fréchet derivative of the Fourier transform of `f`, where `f` is a
function such that both `f` and `v ↦ ‖v‖ * ‖f v‖` are integrable. Here the Fourier transform is
understood as an operator `(V → E) → (W → E)`, where `V` and `W` are normed `ℝ`-vector spaces
and the Fourier transform is taken with respect to a continuous `ℝ`-bilinear
pairing `L : V × W → ℝ` and a given reference measure `μ`.
We also investigate higher derivatives: Assuming that `‖v‖^n * ‖f v‖` is integrable, we show
that the Fourier transform of `f` is `C^n`.
We also study in a parallel way the Fourier transform of the derivative, which is obtained by
tensoring the Fourier transform of the original function with the bilinear form. We also get
results for iterated derivatives.
A consequence of these results is that, if a function is smooth and all its derivatives are
integrable when multiplied by `‖v‖^k`, then the same goes for its Fourier transform, with
explicit bounds.
We give specialized versions of these results on inner product spaces (where `L` is the scalar
product) and on the real line, where we express the one-dimensional derivative in more concrete
terms, as the Fourier transform of `-2πI x * f x` (or `(-2πI x)^n * f x` for higher derivatives).
## Main definitions and results
We introduce two convenience definitions:
* `VectorFourier.fourierSMulRight L f`: given `f : V → E` and `L` a bilinear pairing
between `V` and `W`, then this is the function `fun v ↦ -(2 * π * I) (L v ⬝) • f v`,
from `V` to `Hom (W, E)`.
This is essentially `ContinuousLinearMap.smulRight`, up to the factor `- 2πI` designed to make
sure that the Fourier integral of `fourierSMulRight L f` is the derivative of the Fourier
integral of `f`.
* `VectorFourier.fourierPowSMulRight` is the higher order analogue for higher derivatives:
`fourierPowSMulRight L f v n` is informally `(-(2 * π * I))^n (L v ⬝)^n • f v`, in
the space of continuous multilinear maps `W [×n]→L[ℝ] E`.
With these definitions, the statements read as follows, first in a general context
(arbitrary `L` and `μ`):
* `VectorFourier.hasFDerivAt_fourierIntegral`: the Fourier integral of `f` is differentiable, with
derivative the Fourier integral of `fourierSMulRight L f`.
* `VectorFourier.differentiable_fourierIntegral`: the Fourier integral of `f` is differentiable.
* `VectorFourier.fderiv_fourierIntegral`: formula for the derivative of the Fourier integral of `f`.
* `VectorFourier.fourierIntegral_fderiv`: formula for the Fourier integral of the derivative of `f`.
* `VectorFourier.hasFTaylorSeriesUpTo_fourierIntegral`: under suitable integrability conditions,
the Fourier integral of `f` has an explicit Taylor series up to order `N`, given by the Fourier
integrals of `fun v ↦ fourierPowSMulRight L f v n`.
* `VectorFourier.contDiff_fourierIntegral`: under suitable integrability conditions,
the Fourier integral of `f` is `C^n`.
* `VectorFourier.iteratedFDeriv_fourierIntegral`: under suitable integrability conditions,
explicit formula for the `n`-th derivative of the Fourier integral of `f`, as the Fourier
integral of `fun v ↦ fourierPowSMulRight L f v n`.
* `VectorFourier.pow_mul_norm_iteratedFDeriv_fourierIntegral_le`: explicit bounds for the `n`-th
derivative of the Fourier integral, multiplied by a power function, in terms of corresponding
integrals for the original function.
These statements are then specialized to the case of the usual Fourier transform on
finite-dimensional inner product spaces with their canonical Lebesgue measure (covering in
particular the case of the real line), replacing the namespace `VectorFourier` by
the namespace `Real` in the above statements.
We also give specialized versions of the one-dimensional real derivative (and iterated derivative)
in `Real.deriv_fourierIntegral` and `Real.iteratedDeriv_fourierIntegral`.
-/
noncomputable section
open Real Complex MeasureTheory Filter TopologicalSpace
open scoped FourierTransform Topology ContDiff
-- without this local instance, Lean tries first the instance
-- `secondCountableTopologyEither_of_right` (whose priority is 100) and takes a very long time to
-- fail. Since we only use the left instance in this file, we make sure it is tried first.
attribute [local instance 101] secondCountableTopologyEither_of_left
namespace Real
lemma hasDerivAt_fourierChar (x : ℝ) : HasDerivAt (𝐞 · : ℝ → ℂ) (2 * π * I * 𝐞 x) x := by
have h1 (y : ℝ) : 𝐞 y = fourier 1 (y : UnitAddCircle) := by
rw [fourierChar_apply, fourier_coe_apply]
push_cast
ring_nf
simpa only [h1, Int.cast_one, ofReal_one, div_one, mul_one] using hasDerivAt_fourier 1 1 x
lemma differentiable_fourierChar : Differentiable ℝ (𝐞 · : ℝ → ℂ) :=
fun x ↦ (Real.hasDerivAt_fourierChar x).differentiableAt
lemma deriv_fourierChar (x : ℝ) : deriv (𝐞 · : ℝ → ℂ) x = 2 * π * I * 𝐞 x :=
(Real.hasDerivAt_fourierChar x).deriv
variable {V W : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V]
[NormedAddCommGroup W] [NormedSpace ℝ W] (L : V →L[ℝ] W →L[ℝ] ℝ)
lemma hasFDerivAt_fourierChar_neg_bilinear_right (v : V) (w : W) :
HasFDerivAt (fun w ↦ (𝐞 (-L v w) : ℂ))
((-2 * π * I * 𝐞 (-L v w)) • (ofRealCLM ∘L (L v))) w := by
have ha : HasFDerivAt (fun w' : W ↦ L v w') (L v) w := ContinuousLinearMap.hasFDerivAt (L v)
convert (hasDerivAt_fourierChar (-L v w)).hasFDerivAt.comp w ha.neg using 1
ext y
simp only [neg_mul, ContinuousLinearMap.coe_smul', ContinuousLinearMap.coe_comp', Pi.smul_apply,
Function.comp_apply, ofRealCLM_apply, smul_eq_mul, ContinuousLinearMap.comp_neg,
ContinuousLinearMap.neg_apply, ContinuousLinearMap.smulRight_apply,
ContinuousLinearMap.one_apply, real_smul, neg_inj]
ring
lemma fderiv_fourierChar_neg_bilinear_right_apply (v : V) (w y : W) :
fderiv ℝ (fun w ↦ (𝐞 (-L v w) : ℂ)) w y = -2 * π * I * L v y * 𝐞 (-L v w) := by
simp only [(hasFDerivAt_fourierChar_neg_bilinear_right L v w).fderiv, neg_mul,
ContinuousLinearMap.coe_smul', ContinuousLinearMap.coe_comp', Pi.smul_apply,
Function.comp_apply, ofRealCLM_apply, smul_eq_mul, neg_inj]
ring
lemma differentiable_fourierChar_neg_bilinear_right (v : V) :
Differentiable ℝ (fun w ↦ (𝐞 (-L v w) : ℂ)) :=
fun w ↦ (hasFDerivAt_fourierChar_neg_bilinear_right L v w).differentiableAt
lemma hasFDerivAt_fourierChar_neg_bilinear_left (v : V) (w : W) :
HasFDerivAt (fun v ↦ (𝐞 (-L v w) : ℂ))
((-2 * π * I * 𝐞 (-L v w)) • (ofRealCLM ∘L (L.flip w))) v :=
hasFDerivAt_fourierChar_neg_bilinear_right L.flip w v
lemma fderiv_fourierChar_neg_bilinear_left_apply (v y : V) (w : W) :
fderiv ℝ (fun v ↦ (𝐞 (-L v w) : ℂ)) v y = -2 * π * I * L y w * 𝐞 (-L v w) := by
simp only [(hasFDerivAt_fourierChar_neg_bilinear_left L v w).fderiv, neg_mul,
ContinuousLinearMap.coe_smul', ContinuousLinearMap.coe_comp', Pi.smul_apply,
Function.comp_apply, ContinuousLinearMap.flip_apply, ofRealCLM_apply, smul_eq_mul, neg_inj]
ring
lemma differentiable_fourierChar_neg_bilinear_left (w : W) :
Differentiable ℝ (fun v ↦ (𝐞 (-L v w) : ℂ)) :=
fun v ↦ (hasFDerivAt_fourierChar_neg_bilinear_left L v w).differentiableAt
end Real
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E]
namespace VectorFourier
variable {V W : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V]
[NormedAddCommGroup W] [NormedSpace ℝ W] (L : V →L[ℝ] W →L[ℝ] ℝ) (f : V → E)
/-- Send a function `f : V → E` to the function `f : V → Hom (W, E)` given by
`v ↦ (w ↦ -2 * π * I * L (v, w) • f v)`. This is designed so that the Fourier transform of
`fourierSMulRight L f` is the derivative of the Fourier transform of `f`. -/
def fourierSMulRight (v : V) : (W →L[ℝ] E) := -(2 * π * I) • (L v).smulRight (f v)
@[simp] lemma fourierSMulRight_apply (v : V) (w : W) :
fourierSMulRight L f v w = -(2 * π * I) • L v w • f v := rfl
/-- The `w`-derivative of the Fourier transform integrand. -/
lemma hasFDerivAt_fourierChar_smul (v : V) (w : W) :
HasFDerivAt (fun w' ↦ 𝐞 (-L v w') • f v) (𝐞 (-L v w) • fourierSMulRight L f v) w := by
have ha : HasFDerivAt (fun w' : W ↦ L v w') (L v) w := ContinuousLinearMap.hasFDerivAt (L v)
convert ((hasDerivAt_fourierChar (-L v w)).hasFDerivAt.comp w ha.neg).smul_const (f v)
ext w' : 1
simp_rw [fourierSMulRight, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply]
rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.neg_apply,
ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, ← smul_assoc, smul_comm,
← smul_assoc, real_smul, real_smul, Submonoid.smul_def, smul_eq_mul]
push_cast
ring_nf
lemma norm_fourierSMulRight (L : V →L[ℝ] W →L[ℝ] ℝ) (f : V → E) (v : V) :
‖fourierSMulRight L f v‖ = (2 * π) * ‖L v‖ * ‖f v‖ := by
rw [fourierSMulRight, norm_smul _ (ContinuousLinearMap.smulRight (L v) (f v)),
norm_neg, norm_mul, norm_mul, norm_I, mul_one, Complex.norm_of_nonneg pi_pos.le,
Complex.norm_two, ContinuousLinearMap.norm_smulRight_apply, ← mul_assoc]
lemma norm_fourierSMulRight_le (L : V →L[ℝ] W →L[ℝ] ℝ) (f : V → E) (v : V) :
‖fourierSMulRight L f v‖ ≤ 2 * π * ‖L‖ * ‖v‖ * ‖f v‖ := calc
‖fourierSMulRight L f v‖ = (2 * π) * ‖L v‖ * ‖f v‖ := norm_fourierSMulRight _ _ _
_ ≤ (2 * π) * (‖L‖ * ‖v‖) * ‖f v‖ := by gcongr; exact L.le_opNorm _
_ = 2 * π * ‖L‖ * ‖v‖ * ‖f v‖ := by ring
lemma _root_.MeasureTheory.AEStronglyMeasurable.fourierSMulRight
[SecondCountableTopologyEither V (W →L[ℝ] ℝ)] [MeasurableSpace V] [BorelSpace V]
{L : V →L[ℝ] W →L[ℝ] ℝ} {f : V → E} {μ : Measure V}
(hf : AEStronglyMeasurable f μ) :
AEStronglyMeasurable (fun v ↦ fourierSMulRight L f v) μ := by
apply AEStronglyMeasurable.const_smul'
have aux0 : Continuous fun p : (W →L[ℝ] ℝ) × E ↦ p.1.smulRight p.2 :=
(ContinuousLinearMap.smulRightL ℝ W E).continuous₂
have aux1 : AEStronglyMeasurable (fun v ↦ (L v, f v)) μ :=
L.continuous.aestronglyMeasurable.prodMk hf
-- Elaboration without the expected type is faster here:
exact (aux0.comp_aestronglyMeasurable aux1 :)
variable {f}
/-- Main theorem of this section: if both `f` and `x ↦ ‖x‖ * ‖f x‖` are integrable, then the
Fourier transform of `f` has a Fréchet derivative (everywhere in its domain) and its derivative is
the Fourier transform of `smulRight L f`. -/
theorem hasFDerivAt_fourierIntegral
[MeasurableSpace V] [BorelSpace V] [SecondCountableTopology V] {μ : Measure V}
(hf : Integrable f μ) (hf' : Integrable (fun v : V ↦ ‖v‖ * ‖f v‖) μ) (w : W) :
HasFDerivAt (fourierIntegral 𝐞 μ L.toLinearMap₂ f)
(fourierIntegral 𝐞 μ L.toLinearMap₂ (fourierSMulRight L f) w) w := by
let F : W → V → E := fun w' v ↦ 𝐞 (-L v w') • f v
let F' : W → V → W →L[ℝ] E := fun w' v ↦ 𝐞 (-L v w') • fourierSMulRight L f v
let B : V → ℝ := fun v ↦ 2 * π * ‖L‖ * ‖v‖ * ‖f v‖
have h0 (w' : W) : Integrable (F w') μ :=
(fourierIntegral_convergent_iff continuous_fourierChar
(by apply L.continuous₂ : Continuous (fun p : V × W ↦ L.toLinearMap₂ p.1 p.2)) w').2 hf
have h1 : ∀ᶠ w' in 𝓝 w, AEStronglyMeasurable (F w') μ :=
Eventually.of_forall (fun w' ↦ (h0 w').aestronglyMeasurable)
have h3 : AEStronglyMeasurable (F' w) μ := by
refine .smul ?_ hf.1.fourierSMulRight
refine (continuous_fourierChar.comp ?_).aestronglyMeasurable
fun_prop
have h4 : (∀ᵐ v ∂μ, ∀ (w' : W), w' ∈ Metric.ball w 1 → ‖F' w' v‖ ≤ B v) := by
filter_upwards with v w' _
rw [Circle.norm_smul _ (fourierSMulRight L f v)]
exact norm_fourierSMulRight_le L f v
have h5 : Integrable B μ := by simpa only [← mul_assoc] using hf'.const_mul (2 * π * ‖L‖)
have h6 : ∀ᵐ v ∂μ, ∀ w', w' ∈ Metric.ball w 1 → HasFDerivAt (fun x ↦ F x v) (F' w' v) w' :=
ae_of_all _ (fun v w' _ ↦ hasFDerivAt_fourierChar_smul L f v w')
exact hasFDerivAt_integral_of_dominated_of_fderiv_le one_pos h1 (h0 w) h3 h4 h5 h6
lemma fderiv_fourierIntegral
[MeasurableSpace V] [BorelSpace V] [SecondCountableTopology V] {μ : Measure V}
(hf : Integrable f μ) (hf' : Integrable (fun v : V ↦ ‖v‖ * ‖f v‖) μ) :
fderiv ℝ (fourierIntegral 𝐞 μ L.toLinearMap₂ f) =
fourierIntegral 𝐞 μ L.toLinearMap₂ (fourierSMulRight L f) := by
ext w : 1
exact (hasFDerivAt_fourierIntegral L hf hf' w).fderiv
lemma differentiable_fourierIntegral
[MeasurableSpace V] [BorelSpace V] [SecondCountableTopology V] {μ : Measure V}
(hf : Integrable f μ) (hf' : Integrable (fun v : V ↦ ‖v‖ * ‖f v‖) μ) :
Differentiable ℝ (fourierIntegral 𝐞 μ L.toLinearMap₂ f) :=
fun w ↦ (hasFDerivAt_fourierIntegral L hf hf' w).differentiableAt
/-- The Fourier integral of the derivative of a function is obtained by multiplying the Fourier
integral of the original function by `-L w v`. -/
| Mathlib/Analysis/Fourier/FourierTransformDeriv.lean | 251 | 277 | theorem fourierIntegral_fderiv [MeasurableSpace V] [BorelSpace V] [FiniteDimensional ℝ V]
{μ : Measure V} [Measure.IsAddHaarMeasure μ]
(hf : Integrable f μ) (h'f : Differentiable ℝ f) (hf' : Integrable (fderiv ℝ f) μ) :
fourierIntegral 𝐞 μ L.toLinearMap₂ (fderiv ℝ f)
= fourierSMulRight (-L.flip) (fourierIntegral 𝐞 μ L.toLinearMap₂ f) := by | ext w y
let g (v : V) : ℂ := 𝐞 (-L v w)
/- First rewrite things in a simplified form, without any real change. -/
suffices ∫ x, g x • fderiv ℝ f x y ∂μ = ∫ x, (2 * ↑π * I * L y w * g x) • f x ∂μ by
rw [fourierIntegral_continuousLinearMap_apply' hf']
simpa only [fourierIntegral, ContinuousLinearMap.toLinearMap₂_apply, fourierSMulRight_apply,
ContinuousLinearMap.neg_apply, ContinuousLinearMap.flip_apply, ← integral_smul, neg_smul,
smul_neg, ← smul_smul, coe_smul, neg_neg]
-- Key step: integrate by parts with respect to `y` to switch the derivative from `f` to `g`.
have A x : fderiv ℝ g x y = - 2 * ↑π * I * L y w * g x :=
fderiv_fourierChar_neg_bilinear_left_apply _ _ _ _
rw [integral_smul_fderiv_eq_neg_fderiv_smul_of_integrable, ← integral_neg]
· congr with x
simp only [A, neg_mul, neg_smul, neg_neg]
· have : Integrable (fun x ↦ (-(2 * ↑π * I * ↑((L y) w)) • ((g x : ℂ) • f x))) μ :=
((fourierIntegral_convergent_iff' _ _).2 hf).smul _
convert this using 2 with x
simp only [A, neg_mul, neg_smul, smul_smul]
· exact (fourierIntegral_convergent_iff' _ _).2 (hf'.apply_continuousLinearMap _)
· exact (fourierIntegral_convergent_iff' _ _).2 hf
· exact differentiable_fourierChar_neg_bilinear_left _ _
· exact h'f |
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen
-/
import Mathlib.GroupTheory.Submonoid.Inverses
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Localization.Defs
/-!
# Submonoid of inverses
## Main definitions
* `IsLocalization.invSubmonoid M S` is the submonoid of `S = M⁻¹R` consisting of inverses of
each element `x ∈ M`
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
variable {R : Type*} [CommRing R] (M : Submonoid R) (S : Type*) [CommRing S]
variable [Algebra R S]
open Function
namespace IsLocalization
section InvSubmonoid
/-- The submonoid of `S = M⁻¹R` consisting of `{ 1 / x | x ∈ M }`. -/
def invSubmonoid : Submonoid S :=
(M.map (algebraMap R S)).leftInv
variable [IsLocalization M S]
theorem submonoid_map_le_is_unit : M.map (algebraMap R S) ≤ IsUnit.submonoid S := by
rintro _ ⟨a, ha, rfl⟩
exact IsLocalization.map_units S ⟨_, ha⟩
/-- There is an equivalence of monoids between the image of `M` and `invSubmonoid`. -/
noncomputable abbrev equivInvSubmonoid : M.map (algebraMap R S) ≃* invSubmonoid M S :=
((M.map (algebraMap R S)).leftInvEquiv (submonoid_map_le_is_unit M S)).symm
/-- There is a canonical map from `M` to `invSubmonoid` sending `x` to `1 / x`. -/
noncomputable def toInvSubmonoid : M →* invSubmonoid M S :=
(equivInvSubmonoid M S).toMonoidHom.comp ((algebraMap R S : R →* S).submonoidMap M)
theorem toInvSubmonoid_surjective : Function.Surjective (toInvSubmonoid M S) :=
Function.Surjective.comp (β := M.map (algebraMap R S))
(Equiv.surjective (equivInvSubmonoid _ _).toEquiv) (MonoidHom.submonoidMap_surjective _ _)
@[simp]
theorem toInvSubmonoid_mul (m : M) : (toInvSubmonoid M S m : S) * algebraMap R S m = 1 :=
Submonoid.leftInvEquiv_symm_mul _ (submonoid_map_le_is_unit _ _) _
@[simp]
theorem mul_toInvSubmonoid (m : M) : algebraMap R S m * (toInvSubmonoid M S m : S) = 1 :=
Submonoid.mul_leftInvEquiv_symm _ (submonoid_map_le_is_unit _ _) ⟨_, _⟩
@[simp]
theorem smul_toInvSubmonoid (m : M) : m • (toInvSubmonoid M S m : S) = 1 := by
convert mul_toInvSubmonoid M S m
ext
rw [← Algebra.smul_def]
rfl
variable {S}
-- Porting note: `surj'` was taken, so use `surj''` instead
theorem surj'' (z : S) : ∃ (r : R) (m : M), z = r • (toInvSubmonoid M S m : S) := by
rcases IsLocalization.surj M z with ⟨⟨r, m⟩, e : z * _ = algebraMap R S r⟩
refine ⟨r, m, ?_⟩
rw [Algebra.smul_def, ← e, mul_assoc]
simp
theorem toInvSubmonoid_eq_mk' (x : M) : (toInvSubmonoid M S x : S) = mk' S 1 x := by
rw [← (IsLocalization.map_units S x).mul_left_inj]
simp
| Mathlib/RingTheory/Localization/InvSubmonoid.lean | 87 | 91 | theorem mem_invSubmonoid_iff_exists_mk' (x : S) :
x ∈ invSubmonoid M S ↔ ∃ m : M, mk' S 1 m = x := by | simp_rw [← toInvSubmonoid_eq_mk']
exact ⟨fun h => ⟨_, congr_arg Subtype.val (toInvSubmonoid_surjective M S ⟨x, h⟩).choose_spec⟩,
fun h => h.choose_spec ▸ (toInvSubmonoid M S h.choose).prop⟩ |
/-
Copyright (c) 2024 Emilie Burgun. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Emilie Burgun
-/
import Mathlib.Dynamics.PeriodicPts.Lemmas
import Mathlib.GroupTheory.Exponent
import Mathlib.GroupTheory.GroupAction.Basic
/-!
# Period of a group action
This module defines some helpful lemmas around [`MulAction.period`] and [`AddAction.period`].
The period of a point `a` by a group element `g` is the smallest `m` such that `g ^ m • a = a`
(resp. `(m • g) +ᵥ a = a`) for a given `g : G` and `a : α`.
If such an `m` does not exist,
then by convention `MulAction.period` and `AddAction.period` return 0.
-/
namespace MulAction
universe u v
variable {α : Type v}
variable {G : Type u} [Group G] [MulAction G α]
variable {M : Type u} [Monoid M] [MulAction M α]
/-- If the action is periodic, then a lower bound for its period can be computed. -/
@[to_additive "If the action is periodic, then a lower bound for its period can be computed."]
theorem le_period {m : M} {a : α} {n : ℕ} (period_pos : 0 < period m a)
(moved : ∀ k, 0 < k → k < n → m ^ k • a ≠ a) : n ≤ period m a :=
le_of_not_gt fun period_lt_n =>
moved _ period_pos period_lt_n <| pow_period_smul m a
/-- If for some `n`, `m ^ n • a = a`, then `period m a ≤ n`. -/
@[to_additive "If for some `n`, `(n • m) +ᵥ a = a`, then `period m a ≤ n`."]
theorem period_le_of_fixed {m : M} {a : α} {n : ℕ} (n_pos : 0 < n) (fixed : m ^ n • a = a) :
period m a ≤ n :=
(isPeriodicPt_smul_iff.mpr fixed).minimalPeriod_le n_pos
/-- If for some `n`, `m ^ n • a = a`, then `0 < period m a`. -/
@[to_additive "If for some `n`, `(n • m) +ᵥ a = a`, then `0 < period m a`."]
theorem period_pos_of_fixed {m : M} {a : α} {n : ℕ} (n_pos : 0 < n) (fixed : m ^ n • a = a) :
0 < period m a :=
(isPeriodicPt_smul_iff.mpr fixed).minimalPeriod_pos n_pos
@[to_additive]
theorem period_eq_one_iff {m : M} {a : α} : period m a = 1 ↔ m • a = a :=
⟨fun eq_one => pow_one m ▸ eq_one ▸ pow_period_smul m a,
fun fixed => le_antisymm
(period_le_of_fixed one_pos (by simpa))
(period_pos_of_fixed one_pos (by simpa))⟩
/-- For any non-zero `n` less than the period of `m` on `a`, `a` is moved by `m ^ n`. -/
@[to_additive "For any non-zero `n` less than the period of `m` on `a`, `a` is moved by `n • m`."]
theorem pow_smul_ne_of_lt_period {m : M} {a : α} {n : ℕ} (n_pos : 0 < n)
(n_lt_period : n < period m a) : m ^ n • a ≠ a := fun a_fixed =>
not_le_of_gt n_lt_period <| period_le_of_fixed n_pos a_fixed
section Identities
/-! ### `MulAction.period` for common group elements
-/
variable (M) in
@[to_additive (attr := simp)]
theorem period_one (a : α) : period (1 : M) a = 1 := period_eq_one_iff.mpr (one_smul M a)
@[to_additive (attr := simp)]
theorem period_inv (g : G) (a : α) : period g⁻¹ a = period g a := by
simp only [period_eq_minimalPeriod, Function.minimalPeriod_eq_minimalPeriod_iff,
isPeriodicPt_smul_iff]
intro n
rw [smul_eq_iff_eq_inv_smul, eq_comm, ← zpow_natCast, inv_zpow, inv_inv, zpow_natCast]
end Identities
section MonoidExponent
/-! ### `MulAction.period` and group exponents
The period of a given element `m : M` can be bounded by the `Monoid.exponent M` or `orderOf m`.
-/
@[to_additive]
theorem period_dvd_orderOf (m : M) (a : α) : period m a ∣ orderOf m := by
rw [← pow_smul_eq_iff_period_dvd, pow_orderOf_eq_one, one_smul]
@[to_additive]
theorem period_pos_of_orderOf_pos {m : M} (order_pos : 0 < orderOf m) (a : α) :
0 < period m a :=
Nat.pos_of_dvd_of_pos (period_dvd_orderOf m a) order_pos
@[to_additive]
theorem period_le_orderOf {m : M} (order_pos : 0 < orderOf m) (a : α) :
period m a ≤ orderOf m :=
Nat.le_of_dvd order_pos (period_dvd_orderOf m a)
@[to_additive]
| Mathlib/GroupTheory/GroupAction/Period.lean | 101 | 102 | theorem period_dvd_exponent (m : M) (a : α) : period m a ∣ Monoid.exponent M := by | rw [← pow_smul_eq_iff_period_dvd, Monoid.pow_exponent_eq_one, one_smul] |
/-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Algebra.Polynomial.Module.Basic
import Mathlib.RingTheory.Finiteness.Nakayama
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.ReesAlgebra
/-!
# `I`-filtrations of modules
This file contains the definitions and basic results around (stable) `I`-filtrations of modules.
## Main results
- `Ideal.Filtration`:
An `I`-filtration on the module `M` is a sequence of decreasing submodules `N i` such that
`∀ i, I • (N i) ≤ N (i + 1)`. Note that we do not require the filtration to start from `⊤`.
- `Ideal.Filtration.Stable`: An `I`-filtration is stable if `I • (N i) = N (i + 1)` for large
enough `i`.
- `Ideal.Filtration.submodule`: The associated module `⨁ Nᵢ` of a filtration, implemented as a
submodule of `M[X]`.
- `Ideal.Filtration.submodule_fg_iff_stable`: If `F.N i` are all finitely generated, then
`F.Stable` iff `F.submodule.FG`.
- `Ideal.Filtration.Stable.of_le`: In a finite module over a noetherian ring,
if `F' ≤ F`, then `F.Stable → F'.Stable`.
- `Ideal.exists_pow_inf_eq_pow_smul`: **Artin-Rees lemma**.
given `N ≤ M`, there exists a `k` such that `IⁿM ⊓ N = Iⁿ⁻ᵏ(IᵏM ⊓ N)` for all `n ≥ k`.
- `Ideal.iInf_pow_eq_bot_of_isLocalRing`:
**Krull's intersection theorem** (`⨅ i, I ^ i = ⊥`) for noetherian local rings.
- `Ideal.iInf_pow_eq_bot_of_isDomain`:
**Krull's intersection theorem** (`⨅ i, I ^ i = ⊥`) for noetherian domains.
-/
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] (I : Ideal R)
open Polynomial
open scoped Polynomial
/-- An `I`-filtration on the module `M` is a sequence of decreasing submodules `N i` such that
`I • (N i) ≤ N (i + 1)`. Note that we do not require the filtration to start from `⊤`. -/
@[ext]
structure Ideal.Filtration (M : Type*) [AddCommGroup M] [Module R M] where
N : ℕ → Submodule R M
mono : ∀ i, N (i + 1) ≤ N i
smul_le : ∀ i, I • N i ≤ N (i + 1)
variable (F F' : I.Filtration M) {I}
namespace Ideal.Filtration
theorem pow_smul_le (i j : ℕ) : I ^ i • F.N j ≤ F.N (i + j) := by
induction' i with _ ih
· simp
· rw [pow_succ', mul_smul, add_assoc, add_comm 1, ← add_assoc]
exact (smul_mono_right _ ih).trans (F.smul_le _)
theorem pow_smul_le_pow_smul (i j k : ℕ) : I ^ (i + k) • F.N j ≤ I ^ k • F.N (i + j) := by
rw [add_comm, pow_add, mul_smul]
exact smul_mono_right _ (F.pow_smul_le i j)
protected theorem antitone : Antitone F.N :=
antitone_nat_of_succ_le F.mono
/-- The trivial `I`-filtration of `N`. -/
@[simps]
def _root_.Ideal.trivialFiltration (I : Ideal R) (N : Submodule R M) : I.Filtration M where
N _ := N
mono _ := le_rfl
smul_le _ := Submodule.smul_le_right
/-- The `sup` of two `I.Filtration`s is an `I.Filtration`. -/
instance : Max (I.Filtration M) :=
⟨fun F F' =>
⟨F.N ⊔ F'.N, fun i => sup_le_sup (F.mono i) (F'.mono i), fun i =>
(Submodule.smul_sup _ _ _).trans_le <| sup_le_sup (F.smul_le i) (F'.smul_le i)⟩⟩
/-- The `sSup` of a family of `I.Filtration`s is an `I.Filtration`. -/
instance : SupSet (I.Filtration M) :=
⟨fun S =>
{ N := sSup (Ideal.Filtration.N '' S)
mono := fun i => by
apply sSup_le_sSup_of_forall_exists_le _
rintro _ ⟨⟨_, F, hF, rfl⟩, rfl⟩
exact ⟨_, ⟨⟨_, F, hF, rfl⟩, rfl⟩, F.mono i⟩
smul_le := fun i => by
rw [sSup_eq_iSup', iSup_apply, Submodule.smul_iSup, iSup_apply]
apply iSup_mono _
rintro ⟨_, F, hF, rfl⟩
exact F.smul_le i }⟩
/-- The `inf` of two `I.Filtration`s is an `I.Filtration`. -/
instance : Min (I.Filtration M) :=
⟨fun F F' =>
⟨F.N ⊓ F'.N, fun i => inf_le_inf (F.mono i) (F'.mono i), fun i =>
(smul_inf_le _ _ _).trans <| inf_le_inf (F.smul_le i) (F'.smul_le i)⟩⟩
/-- The `sInf` of a family of `I.Filtration`s is an `I.Filtration`. -/
instance : InfSet (I.Filtration M) :=
⟨fun S =>
{ N := sInf (Ideal.Filtration.N '' S)
mono := fun i => by
apply sInf_le_sInf_of_forall_exists_le _
rintro _ ⟨⟨_, F, hF, rfl⟩, rfl⟩
exact ⟨_, ⟨⟨_, F, hF, rfl⟩, rfl⟩, F.mono i⟩
smul_le := fun i => by
rw [sInf_eq_iInf', iInf_apply, iInf_apply]
refine smul_iInf_le.trans ?_
apply iInf_mono _
rintro ⟨_, F, hF, rfl⟩
exact F.smul_le i }⟩
instance : Top (I.Filtration M) :=
⟨I.trivialFiltration ⊤⟩
instance : Bot (I.Filtration M) :=
⟨I.trivialFiltration ⊥⟩
@[simp]
theorem sup_N : (F ⊔ F').N = F.N ⊔ F'.N :=
rfl
@[simp]
theorem sSup_N (S : Set (I.Filtration M)) : (sSup S).N = sSup (Ideal.Filtration.N '' S) :=
rfl
@[simp]
theorem inf_N : (F ⊓ F').N = F.N ⊓ F'.N :=
rfl
@[simp]
theorem sInf_N (S : Set (I.Filtration M)) : (sInf S).N = sInf (Ideal.Filtration.N '' S) :=
rfl
@[simp]
theorem top_N : (⊤ : I.Filtration M).N = ⊤ :=
rfl
@[simp]
theorem bot_N : (⊥ : I.Filtration M).N = ⊥ :=
rfl
@[simp]
theorem iSup_N {ι : Sort*} (f : ι → I.Filtration M) : (iSup f).N = ⨆ i, (f i).N :=
congr_arg sSup (Set.range_comp _ _).symm
@[simp]
theorem iInf_N {ι : Sort*} (f : ι → I.Filtration M) : (iInf f).N = ⨅ i, (f i).N :=
congr_arg sInf (Set.range_comp _ _).symm
instance : CompleteLattice (I.Filtration M) :=
Function.Injective.completeLattice Ideal.Filtration.N
(fun _ _ => Ideal.Filtration.ext) sup_N inf_N
(fun _ => sSup_image) (fun _ => sInf_image) top_N bot_N
instance : Inhabited (I.Filtration M) :=
⟨⊥⟩
/-- An `I` filtration is stable if `I • F.N n = F.N (n+1)` for large enough `n`. -/
def Stable : Prop :=
∃ n₀, ∀ n ≥ n₀, I • F.N n = F.N (n + 1)
/-- The trivial stable `I`-filtration of `N`. -/
@[simps]
def _root_.Ideal.stableFiltration (I : Ideal R) (N : Submodule R M) : I.Filtration M where
N i := I ^ i • N
mono i := by rw [add_comm, pow_add, mul_smul]; exact Submodule.smul_le_right
smul_le i := by rw [add_comm, pow_add, mul_smul, pow_one]
theorem _root_.Ideal.stableFiltration_stable (I : Ideal R) (N : Submodule R M) :
(I.stableFiltration N).Stable := by
use 0
intro n _
dsimp
rw [add_comm, pow_add, mul_smul, pow_one]
variable {F F'}
theorem Stable.exists_pow_smul_eq (h : F.Stable) : ∃ n₀, ∀ k, F.N (n₀ + k) = I ^ k • F.N n₀ := by
obtain ⟨n₀, hn⟩ := h
use n₀
intro k
induction' k with _ ih
· simp
· rw [← add_assoc, ← hn, ih, add_comm, pow_add, mul_smul, pow_one]
omega
theorem Stable.exists_pow_smul_eq_of_ge (h : F.Stable) :
∃ n₀, ∀ n ≥ n₀, F.N n = I ^ (n - n₀) • F.N n₀ := by
obtain ⟨n₀, hn₀⟩ := h.exists_pow_smul_eq
use n₀
intro n hn
convert hn₀ (n - n₀)
rw [add_comm, tsub_add_cancel_of_le hn]
theorem stable_iff_exists_pow_smul_eq_of_ge :
F.Stable ↔ ∃ n₀, ∀ n ≥ n₀, F.N n = I ^ (n - n₀) • F.N n₀ := by
refine ⟨Stable.exists_pow_smul_eq_of_ge, fun h => ⟨h.choose, fun n hn => ?_⟩⟩
rw [h.choose_spec n hn, h.choose_spec (n + 1) (by omega), smul_smul, ← pow_succ',
tsub_add_eq_add_tsub hn]
theorem Stable.exists_forall_le (h : F.Stable) (e : F.N 0 ≤ F'.N 0) :
∃ n₀, ∀ n, F.N (n + n₀) ≤ F'.N n := by
obtain ⟨n₀, hF⟩ := h
use n₀
intro n
induction' n with n hn
· refine (F.antitone ?_).trans e; simp
· rw [add_right_comm, ← hF]
· exact (smul_mono_right _ hn).trans (F'.smul_le _)
simp
theorem Stable.bounded_difference (h : F.Stable) (h' : F'.Stable) (e : F.N 0 = F'.N 0) :
∃ n₀, ∀ n, F.N (n + n₀) ≤ F'.N n ∧ F'.N (n + n₀) ≤ F.N n := by
obtain ⟨n₁, h₁⟩ := h.exists_forall_le (le_of_eq e)
obtain ⟨n₂, h₂⟩ := h'.exists_forall_le (le_of_eq e.symm)
use max n₁ n₂
intro n
refine ⟨(F.antitone ?_).trans (h₁ n), (F'.antitone ?_).trans (h₂ n)⟩ <;> simp
open PolynomialModule
variable (F F')
/-- The `R[IX]`-submodule of `M[X]` associated with an `I`-filtration. -/
protected def submodule : Submodule (reesAlgebra I) (PolynomialModule R M) where
carrier := { f | ∀ i, f i ∈ F.N i }
add_mem' hf hg i := Submodule.add_mem _ (hf i) (hg i)
zero_mem' _ := Submodule.zero_mem _
smul_mem' r f hf i := by
rw [Subalgebra.smul_def, PolynomialModule.smul_apply]
apply Submodule.sum_mem
rintro ⟨j, k⟩ e
rw [Finset.mem_antidiagonal] at e
subst e
exact F.pow_smul_le j k (Submodule.smul_mem_smul (r.2 j) (hf k))
@[simp]
theorem mem_submodule (f : PolynomialModule R M) : f ∈ F.submodule ↔ ∀ i, f i ∈ F.N i :=
Iff.rfl
theorem inf_submodule : (F ⊓ F').submodule = F.submodule ⊓ F'.submodule := by
ext
exact forall_and
variable (I M)
/-- `Ideal.Filtration.submodule` as an `InfHom`. -/
def submoduleInfHom :
InfHom (I.Filtration M) (Submodule (reesAlgebra I) (PolynomialModule R M)) where
toFun := Ideal.Filtration.submodule
map_inf' := inf_submodule
variable {I M}
theorem submodule_closure_single :
AddSubmonoid.closure (⋃ i, single R i '' (F.N i : Set M)) = F.submodule.toAddSubmonoid := by
apply le_antisymm
· rw [AddSubmonoid.closure_le, Set.iUnion_subset_iff]
rintro i _ ⟨m, hm, rfl⟩ j
rw [single_apply]
split_ifs with h
· rwa [← h]
· exact (F.N j).zero_mem
· intro f hf
rw [← f.sum_single]
apply AddSubmonoid.sum_mem _ _
rintro c -
exact AddSubmonoid.subset_closure (Set.subset_iUnion _ c <| Set.mem_image_of_mem _ (hf c))
theorem submodule_span_single :
Submodule.span (reesAlgebra I) (⋃ i, single R i '' (F.N i : Set M)) = F.submodule := by
rw [← Submodule.span_closure, submodule_closure_single, Submodule.coe_toAddSubmonoid]
exact Submodule.span_eq (Filtration.submodule F)
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
rw [← submodule_span_single, ← LE.le.le_iff_eq, Submodule.span_le, Set.iUnion_subset_iff]
swap; · exact Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)
constructor
· intro H n hn
refine (F.smul_le n).antisymm ?_
intro x hx
obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_linearCombination _ _ _).mp (H _ ⟨x, hx, rfl⟩)
replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
dsimp only at hl
rw [PolynomialModule.single_apply, if_pos rfl] at hl
rw [← hl, Finsupp.linearCombination_apply, Finsupp.sum_apply]
apply Submodule.sum_mem _ _
rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
dsimp only [Subtype.coe_mk]
rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by omega)]
have e : n' ≤ n := by omega
have := F.pow_smul_le_pow_smul (n - n') n' 1
rw [tsub_add_cancel_of_le e, pow_one, add_comm _ 1, ← add_tsub_assoc_of_le e, add_comm] at this
exact this (Submodule.smul_mem_smul ((l _).2 <| n + 1 - n') hm)
· let F' := Submodule.span (reesAlgebra I) (⋃ i ≤ n₀, single R i '' (F.N i : Set M))
intro hF i
have : ∀ i ≤ n₀, single R i '' (F.N i : Set M) ⊆ F' := by
-- Porting note: Original proof was
-- `fun i hi => Set.Subset.trans (Set.subset_iUnion₂ i hi) Submodule.subset_span`
intro i hi
refine Set.Subset.trans ?_ Submodule.subset_span
refine @Set.subset_iUnion₂ _ _ _ (fun i => fun _ => ↑((single R i) '' ((N F i) : Set M))) i ?_
exact hi
induction' i with j hj
· exact this _ (zero_le _)
by_cases hj' : j.succ ≤ n₀
· exact this _ hj'
simp only [not_le, Nat.lt_succ_iff] at hj'
rw [← hF _ hj']
rintro _ ⟨m, hm, rfl⟩
refine Submodule.smul_induction_on hm (fun r hr m' hm' => ?_) (fun x y hx hy => ?_)
· rw [add_comm, ← monomial_smul_single]
exact F'.smul_mem
⟨_, reesAlgebra.monomial_mem.mpr (by rwa [pow_one])⟩ (hj <| Set.mem_image_of_mem _ hm')
· rw [map_add]
exact F'.add_mem hx hy
/-- If the components of a filtration are finitely generated, then the filtration is stable iff
its associated submodule of is finitely generated. -/
theorem submodule_fg_iff_stable (hF' : ∀ i, (F.N i).FG) : F.submodule.FG ↔ F.Stable := by
classical
delta Ideal.Filtration.Stable
simp_rw [← F.submodule_eq_span_le_iff_stable_ge]
constructor
· rintro H
refine H.stabilizes_of_iSup_eq
⟨fun n₀ => Submodule.span _ (⋃ (i : ℕ) (_ : i ≤ n₀), single R i '' ↑(F.N i)), ?_⟩ ?_
· intro n m e
rw [Submodule.span_le, Set.iUnion₂_subset_iff]
intro i hi
refine Set.Subset.trans ?_ Submodule.subset_span
refine @Set.subset_iUnion₂ _ _ _ (fun i => fun _ => ↑((single R i) '' ((N F i) : Set M))) i ?_
exact hi.trans e
· dsimp
rw [← Submodule.span_iUnion, ← submodule_span_single]
congr 1
ext
simp only [Set.mem_iUnion, Set.mem_image, SetLike.mem_coe, exists_prop]
constructor
· rintro ⟨-, i, -, e⟩; exact ⟨i, e⟩
· rintro ⟨i, e⟩; exact ⟨i, i, le_refl i, e⟩
· rintro ⟨n, hn⟩
rw [hn]
simp_rw [Submodule.span_iUnion₂, ← Finset.mem_range_succ_iff, iSup_subtype']
apply Submodule.fg_iSup
rintro ⟨i, hi⟩
obtain ⟨s, hs⟩ := hF' i
have : Submodule.span (reesAlgebra I) (s.image (lsingle R i) : Set (PolynomialModule R M)) =
Submodule.span _ (single R i '' (F.N i : Set M)) := by
rw [Finset.coe_image, ← Submodule.span_span_of_tower R, ← Submodule.map_span, hs]; rfl
rw [Subtype.coe_mk, ← this]
exact ⟨_, rfl⟩
variable {F}
theorem Stable.of_le [IsNoetherianRing R] [Module.Finite R M] (hF : F.Stable)
{F' : I.Filtration M} (hf : F' ≤ F) : F'.Stable := by
rw [← submodule_fg_iff_stable] at hF ⊢
any_goals intro i; exact IsNoetherian.noetherian _
have := isNoetherian_of_fg_of_noetherian _ hF
rw [isNoetherian_submodule] at this
exact this _ (OrderHomClass.mono (submoduleInfHom M I) hf)
| Mathlib/RingTheory/Filtration.lean | 372 | 404 | theorem Stable.inter_right [IsNoetherianRing R] [Module.Finite R M] (hF : F.Stable) :
(F ⊓ F').Stable :=
hF.of_le inf_le_left
theorem Stable.inter_left [IsNoetherianRing R] [Module.Finite R M] (hF : F.Stable) :
(F' ⊓ F).Stable :=
hF.of_le inf_le_right
end Ideal.Filtration
variable (I)
/-- **Artin-Rees lemma** -/
theorem Ideal.exists_pow_inf_eq_pow_smul [IsNoetherianRing R] [Module.Finite R M]
(N : Submodule R M) : ∃ k : ℕ, ∀ n ≥ k, I ^ n • ⊤ ⊓ N = I ^ (n - k) • (I ^ k • ⊤ ⊓ N) :=
((I.stableFiltration_stable ⊤).inter_right (I.trivialFiltration N)).exists_pow_smul_eq_of_ge
theorem Ideal.mem_iInf_smul_pow_eq_bot_iff [IsNoetherianRing R] [Module.Finite R M] (x : M) :
x ∈ (⨅ i : ℕ, I ^ i • ⊤ : Submodule R M) ↔ ∃ r : I, (r : R) • x = x := by | let N := (⨅ i : ℕ, I ^ i • ⊤ : Submodule R M)
have hN : ∀ k, (I.stableFiltration ⊤ ⊓ I.trivialFiltration N).N k = N :=
fun k => inf_eq_right.mpr ((iInf_le _ k).trans <| le_of_eq <| by simp)
constructor
· obtain ⟨r, hr₁, hr₂⟩ :=
Submodule.exists_mem_and_smul_eq_self_of_fg_of_le_smul I N (IsNoetherian.noetherian N) (by
obtain ⟨k, hk⟩ := (I.stableFiltration_stable ⊤).inter_right (I.trivialFiltration N)
have := hk k (le_refl _)
rw [hN, hN] at this
exact le_of_eq this.symm)
intro H
exact ⟨⟨r, hr₁⟩, hr₂ _ H⟩
· rintro ⟨r, eq⟩
rw [Submodule.mem_iInf] |
/-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Order.Group.Defs
import Mathlib.Algebra.Order.Monoid.OrderDual
import Mathlib.Order.Monotone.Union
/-!
# Monotonicity of odd functions
An odd function on a linear ordered additive commutative group `G` is monotone on the whole group
provided that it is monotone on `Set.Ici 0`, see `monotone_of_odd_of_monotoneOn_nonneg`. We also
prove versions of this lemma for `Antitone`, `StrictMono`, and `StrictAnti`.
-/
open Set
variable {G H : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G]
[AddCommGroup H] [PartialOrder H] [IsOrderedAddMonoid H]
/-- An odd function on a linear ordered additive commutative group is strictly monotone on the whole
group provided that it is strictly monotone on `Set.Ici 0`. -/
| Mathlib/Order/Monotone/Odd.lean | 26 | 30 | theorem strictMono_of_odd_strictMonoOn_nonneg {f : G → H} (h₁ : ∀ x, f (-x) = -f x)
(h₂ : StrictMonoOn f (Ici 0)) : StrictMono f := by | refine StrictMonoOn.Iic_union_Ici (fun x hx y hy hxy => neg_lt_neg_iff.1 ?_) h₂
rw [← h₁, ← h₁]
exact h₂ (neg_nonneg.2 hy) (neg_nonneg.2 hx) (neg_lt_neg hxy) |
/-
Copyright (c) 2022 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Data.List.Induction
import Mathlib.Data.List.TakeWhile
/-!
# Dropping or taking from lists on the right
Taking or removing element from the tail end of a list
## Main definitions
- `rdrop n`: drop `n : ℕ` elements from the tail
- `rtake n`: take `n : ℕ` elements from the tail
- `rdropWhile p`: remove all the elements from the tail of a list until it finds the first element
for which `p : α → Bool` returns false. This element and everything before is returned.
- `rtakeWhile p`: Returns the longest terminal segment of a list for which `p : α → Bool` returns
true.
## Implementation detail
The two predicate-based methods operate by performing the regular "from-left" operation on
`List.reverse`, followed by another `List.reverse`, so they are not the most performant.
The other two rely on `List.length l` so they still traverse the list twice. One could construct
another function that takes a `L : ℕ` and use `L - n`. Under a proof condition that
`L = l.length`, the function would do the right thing.
-/
-- Make sure we don't import algebra
assert_not_exists Monoid
variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ)
namespace List
/-- Drop `n` elements from the tail end of a list. -/
def rdrop : List α :=
l.take (l.length - n)
@[simp]
theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop]
@[simp]
theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop]
theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by
rw [rdrop]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· simp [take_append]
· simp [take_append_eq_append_take, IH]
@[simp]
theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by
simp [rdrop_eq_reverse_drop_reverse]
/-- Take `n` elements from the tail end of a list. -/
def rtake : List α :=
l.drop (l.length - n)
@[simp]
theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake]
@[simp]
theorem rtake_zero : rtake l 0 = [] := by simp [rtake]
theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by
rw [rtake]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· exact drop_length
· simp [drop_append_eq_append_drop, IH]
@[simp]
theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by
simp [rtake_eq_reverse_take_reverse]
/-- Drop elements from the tail end of a list that satisfy `p : α → Bool`.
Implemented naively via `List.reverse` -/
def rdropWhile : List α :=
reverse (l.reverse.dropWhile p)
@[simp]
| Mathlib/Data/List/DropRight.lean | 91 | 92 | theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by | simp [rdropWhile, dropWhile] |
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.DirectSum.Algebra
import Mathlib.Algebra.MonoidAlgebra.Basic
import Mathlib.Data.Finsupp.ToDFinsupp
/-!
# Conversion between `AddMonoidAlgebra` and homogeneous `DirectSum`
This module provides conversions between `AddMonoidAlgebra` and `DirectSum`.
The latter is essentially a dependent version of the former.
Note that since `DirectSum.instMul` combines indices additively, there is no equivalent to
`MonoidAlgebra`.
## Main definitions
* `AddMonoidAlgebra.toDirectSum : AddMonoidAlgebra M ι → (⨁ i : ι, M)`
* `DirectSum.toAddMonoidAlgebra : (⨁ i : ι, M) → AddMonoidAlgebra M ι`
* Bundled equiv versions of the above:
* `addMonoidAlgebraEquivDirectSum : AddMonoidAlgebra M ι ≃ (⨁ i : ι, M)`
* `addMonoidAlgebraAddEquivDirectSum : AddMonoidAlgebra M ι ≃+ (⨁ i : ι, M)`
* `addMonoidAlgebraRingEquivDirectSum R : AddMonoidAlgebra M ι ≃+* (⨁ i : ι, M)`
* `addMonoidAlgebraAlgEquivDirectSum R : AddMonoidAlgebra A ι ≃ₐ[R] (⨁ i : ι, A)`
## Theorems
The defining feature of these operations is that they map `Finsupp.single` to
`DirectSum.of` and vice versa:
* `AddMonoidAlgebra.toDirectSum_single`
* `DirectSum.toAddMonoidAlgebra_of`
as well as preserving arithmetic operations.
For the bundled equivalences, we provide lemmas that they reduce to
`AddMonoidAlgebra.toDirectSum`:
* `addMonoidAlgebraAddEquivDirectSum_apply`
* `add_monoid_algebra_lequiv_direct_sum_apply`
* `addMonoidAlgebraAddEquivDirectSum_symm_apply`
* `add_monoid_algebra_lequiv_direct_sum_symm_apply`
## Implementation notes
This file largely just copies the API of `Mathlib/Data/Finsupp/ToDFinsupp.lean`, and reuses the
proofs. Recall that `AddMonoidAlgebra M ι` is defeq to `ι →₀ M` and `⨁ i : ι, M` is defeq to
`Π₀ i : ι, M`.
Note that there is no `AddMonoidAlgebra` equivalent to `Finsupp.single`, so many statements
still involve this definition.
-/
variable {ι : Type*} {R : Type*} {M : Type*} {A : Type*}
open DirectSum
/-! ### Basic definitions and lemmas -/
section Defs
/-- Interpret an `AddMonoidAlgebra` as a homogeneous `DirectSum`. -/
def AddMonoidAlgebra.toDirectSum [Semiring M] (f : AddMonoidAlgebra M ι) : ⨁ _ : ι, M :=
Finsupp.toDFinsupp f
section
variable [DecidableEq ι] [Semiring M]
@[simp]
theorem AddMonoidAlgebra.toDirectSum_single (i : ι) (m : M) :
AddMonoidAlgebra.toDirectSum (Finsupp.single i m) = DirectSum.of _ i m :=
Finsupp.toDFinsupp_single i m
variable [∀ m : M, Decidable (m ≠ 0)]
/-- Interpret a homogeneous `DirectSum` as an `AddMonoidAlgebra`. -/
def DirectSum.toAddMonoidAlgebra (f : ⨁ _ : ι, M) : AddMonoidAlgebra M ι :=
DFinsupp.toFinsupp f
@[simp]
theorem DirectSum.toAddMonoidAlgebra_of (i : ι) (m : M) :
(DirectSum.of _ i m : ⨁ _ : ι, M).toAddMonoidAlgebra = Finsupp.single i m :=
DFinsupp.toFinsupp_single i m
@[simp]
theorem AddMonoidAlgebra.toDirectSum_toAddMonoidAlgebra (f : AddMonoidAlgebra M ι) :
f.toDirectSum.toAddMonoidAlgebra = f :=
Finsupp.toDFinsupp_toFinsupp f
@[simp]
theorem DirectSum.toAddMonoidAlgebra_toDirectSum (f : ⨁ _ : ι, M) :
f.toAddMonoidAlgebra.toDirectSum = f :=
(DFinsupp.toFinsupp_toDFinsupp (show Π₀ _ : ι, M from f) :)
end
end Defs
/-! ### Lemmas about arithmetic operations -/
section Lemmas
namespace AddMonoidAlgebra
@[simp]
theorem toDirectSum_zero [Semiring M] : (0 : AddMonoidAlgebra M ι).toDirectSum = 0 :=
Finsupp.toDFinsupp_zero
@[simp]
theorem toDirectSum_add [Semiring M] (f g : AddMonoidAlgebra M ι) :
(f + g).toDirectSum = f.toDirectSum + g.toDirectSum :=
Finsupp.toDFinsupp_add _ _
@[simp]
theorem toDirectSum_natCast [DecidableEq ι] [AddMonoid ι] [Semiring M] (n : ℕ) :
(n : AddMonoidAlgebra M ι).toDirectSum = n :=
Finsupp.toDFinsupp_single _ _
@[simp]
theorem toDirectSum_ofNat [DecidableEq ι] [AddMonoid ι] [Semiring M] (n : ℕ) [n.AtLeastTwo] :
(ofNat(n) : AddMonoidAlgebra M ι).toDirectSum = ofNat(n) :=
Finsupp.toDFinsupp_single _ _
@[simp]
| Mathlib/Algebra/MonoidAlgebra/ToDirectSum.lean | 132 | 159 | theorem toDirectSum_sub [Ring M] (f g : AddMonoidAlgebra M ι) :
(f - g).toDirectSum = f.toDirectSum - g.toDirectSum :=
Finsupp.toDFinsupp_sub _ _
@[simp]
theorem toDirectSum_neg [Ring M] (f : AddMonoidAlgebra M ι) :
(- f).toDirectSum = - f.toDirectSum :=
Finsupp.toDFinsupp_neg _
@[simp]
theorem toDirectSum_intCast [DecidableEq ι] [AddMonoid ι] [Ring M] (z : ℤ) :
(Int.cast z : AddMonoidAlgebra M ι).toDirectSum = z :=
Finsupp.toDFinsupp_single _ _
@[simp]
theorem toDirectSum_one [DecidableEq ι] [Zero ι] [Semiring M] :
(1 : AddMonoidAlgebra M ι).toDirectSum = 1 :=
Finsupp.toDFinsupp_single _ _
@[simp]
theorem toDirectSum_mul [DecidableEq ι] [AddMonoid ι] [Semiring M] (f g : AddMonoidAlgebra M ι) :
(f * g).toDirectSum = f.toDirectSum * g.toDirectSum := by | let to_hom : AddMonoidAlgebra M ι →+ ⨁ _ : ι, M :=
{ toFun := toDirectSum
map_zero' := toDirectSum_zero
map_add' := toDirectSum_add }
show to_hom (f * g) = to_hom f * to_hom g
revert f g |
/-
Copyright (c) 2019 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, David Kurniadi Angdinata, Devon Tuma, Riccardo Brasca
-/
import Mathlib.Algebra.Polynomial.Div
import Mathlib.Algebra.Polynomial.Eval.SMul
import Mathlib.GroupTheory.GroupAction.Ring
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.Polynomial.Basic
import Mathlib.RingTheory.Polynomial.Ideal
/-!
# Quotients of polynomial rings
-/
open Polynomial
namespace Polynomial
variable {R : Type*} [CommRing R]
private noncomputable def quotientSpanXSubCAlgEquivAux2 (x : R) :
(R[X] ⧸ (RingHom.ker (aeval x).toRingHom : Ideal R[X])) ≃ₐ[R] R :=
let e := RingHom.quotientKerEquivOfRightInverse (fun x => by
exact eval_C : Function.RightInverse (fun a : R => (C a : R[X])) (@aeval R R _ _ _ x))
{ e with commutes' := fun r => e.apply_symm_apply r }
private noncomputable def quotientSpanXSubCAlgEquivAux1 (x : R) :
(R[X] ⧸ Ideal.span {X - C x}) ≃ₐ[R] (R[X] ⧸ (RingHom.ker (aeval x).toRingHom : Ideal R[X])) :=
Ideal.quotientEquivAlgOfEq R (ker_evalRingHom x).symm
-- Porting note: need to split this definition into two sub-definitions to prevent time out
/-- For a commutative ring $R$, evaluating a polynomial at an element $x \in R$ induces an
isomorphism of $R$-algebras $R[X] / \langle X - x \rangle \cong R$. -/
noncomputable def quotientSpanXSubCAlgEquiv (x : R) :
(R[X] ⧸ Ideal.span ({X - C x} : Set R[X])) ≃ₐ[R] R :=
(quotientSpanXSubCAlgEquivAux1 x).trans (quotientSpanXSubCAlgEquivAux2 x)
@[simp]
theorem quotientSpanXSubCAlgEquiv_mk (x : R) (p : R[X]) :
quotientSpanXSubCAlgEquiv x (Ideal.Quotient.mk _ p) = p.eval x :=
rfl
@[simp]
theorem quotientSpanXSubCAlgEquiv_symm_apply (x : R) (y : R) :
(quotientSpanXSubCAlgEquiv x).symm y = algebraMap R _ y :=
rfl
/-- For a commutative ring $R$, evaluating a polynomial at an element $y \in R$ induces an
isomorphism of $R$-algebras $R[X] / \langle x, X - y \rangle \cong R / \langle x \rangle$. -/
noncomputable def quotientSpanCXSubCAlgEquiv (x y : R) :
(R[X] ⧸ (Ideal.span {C x, X - C y} : Ideal R[X])) ≃ₐ[R] R ⧸ (Ideal.span {x} : Ideal R) :=
(Ideal.quotientEquivAlgOfEq R <| by rw [Ideal.span_insert, sup_comm]).trans <|
(DoubleQuot.quotQuotEquivQuotSupₐ R _ _).symm.trans <|
(Ideal.quotientEquivAlg _ _ (quotientSpanXSubCAlgEquiv y) rfl).trans <|
Ideal.quotientEquivAlgOfEq R <| by
simp only [Ideal.map_span, Set.image_singleton]; congr 2; exact eval_C
/-- For a commutative ring $R$, evaluating a polynomial at elements $y(X) \in R[X]$ and $x \in R$
induces an isomorphism of $R$-algebras $R[X, Y] / \langle X - x, Y - y(X) \rangle \cong R$. -/
noncomputable def quotientSpanCXSubCXSubCAlgEquiv {x : R} {y : R[X]} :
@AlgEquiv R (R[X][X] ⧸ (Ideal.span {C (X - C x), X - C y} : Ideal <| R[X][X])) R _ _ _
(Ideal.Quotient.algebra R) _ :=
((quotientSpanCXSubCAlgEquiv (X - C x) y).restrictScalars R).trans <| quotientSpanXSubCAlgEquiv x
lemma modByMonic_eq_zero_iff_quotient_eq_zero (p q : R[X]) (hq : q.Monic) :
p %ₘ q = 0 ↔ (p : R[X] ⧸ Ideal.span {q}) = 0 := by
rw [modByMonic_eq_zero_iff_dvd hq, Ideal.Quotient.eq_zero_iff_dvd]
end Polynomial
namespace Ideal
noncomputable section
open Polynomial
variable {R : Type*} [CommRing R]
theorem quotient_map_C_eq_zero {I : Ideal R} :
∀ a ∈ I, ((Quotient.mk (map (C : R →+* R[X]) I : Ideal R[X])).comp C) a = 0 := by
intro a ha
rw [RingHom.comp_apply, Quotient.eq_zero_iff_mem]
exact mem_map_of_mem _ ha
theorem eval₂_C_mk_eq_zero {I : Ideal R} :
∀ f ∈ (map (C : R →+* R[X]) I : Ideal R[X]), eval₂RingHom (C.comp (Quotient.mk I)) X f = 0 := by
intro a ha
rw [← sum_monomial_eq a]
dsimp
rw [eval₂_sum]
refine Finset.sum_eq_zero fun n _ => ?_
dsimp
rw [eval₂_monomial (C.comp (Quotient.mk I)) X]
refine mul_eq_zero_of_left (Polynomial.ext fun m => ?_) (X ^ n)
rw [RingHom.comp_apply, coeff_C]
by_cases h : m = 0
· simpa [h] using Quotient.eq_zero_iff_mem.2 ((mem_map_C_iff.1 ha) n)
· simp [h]
/-- If `I` is an ideal of `R`, then the ring polynomials over the quotient ring `I.quotient` is
isomorphic to the quotient of `R[X]` by the ideal `map C I`,
where `map C I` contains exactly the polynomials whose coefficients all lie in `I`. -/
def polynomialQuotientEquivQuotientPolynomial (I : Ideal R) :
(R ⧸ I)[X] ≃+* R[X] ⧸ (map C I : Ideal R[X]) where
toFun :=
eval₂RingHom
(Quotient.lift I ((Quotient.mk (map C I : Ideal R[X])).comp C) quotient_map_C_eq_zero)
(Quotient.mk (map C I : Ideal R[X]) X)
invFun :=
Quotient.lift (map C I : Ideal R[X]) (eval₂RingHom (C.comp (Quotient.mk I)) X)
eval₂_C_mk_eq_zero
map_mul' f g := by simp only [coe_eval₂RingHom, eval₂_mul]
map_add' f g := by simp only [eval₂_add, coe_eval₂RingHom]
left_inv := by
intro f
refine Polynomial.induction_on' f ?_ ?_
· intro p q hp hq
simp only [coe_eval₂RingHom] at hp hq
simp only [coe_eval₂RingHom, hp, hq, RingHom.map_add]
· rintro n ⟨x⟩
simp only [← smul_X_eq_monomial, C_mul', Quotient.lift_mk, Submodule.Quotient.quot_mk_eq_mk,
Quotient.mk_eq_mk, eval₂_X_pow, eval₂_smul, coe_eval₂RingHom, RingHom.map_pow, eval₂_C,
RingHom.coe_comp, RingHom.map_mul, eval₂_X, Function.comp_apply]
right_inv := by
rintro ⟨f⟩
refine Polynomial.induction_on' f ?_ ?_
· -- Porting note: was `simp_intro p q hp hq`
intros p q hp hq
simp only [Submodule.Quotient.quot_mk_eq_mk, Quotient.mk_eq_mk, map_add, Quotient.lift_mk,
coe_eval₂RingHom] at hp hq ⊢
rw [hp, hq]
· intro n a
simp only [← smul_X_eq_monomial, ← C_mul' a (X ^ n), Quotient.lift_mk,
Submodule.Quotient.quot_mk_eq_mk, Quotient.mk_eq_mk, eval₂_X_pow, eval₂_smul,
coe_eval₂RingHom, RingHom.map_pow, eval₂_C, RingHom.coe_comp, RingHom.map_mul, eval₂_X,
Function.comp_apply]
@[simp]
theorem polynomialQuotientEquivQuotientPolynomial_symm_mk (I : Ideal R) (f : R[X]) :
I.polynomialQuotientEquivQuotientPolynomial.symm (Quotient.mk _ f) = f.map (Quotient.mk I) := by
rw [polynomialQuotientEquivQuotientPolynomial, RingEquiv.symm_mk, RingEquiv.coe_mk,
Equiv.coe_fn_mk, Quotient.lift_mk, coe_eval₂RingHom, eval₂_eq_eval_map, ← Polynomial.map_map,
← eval₂_eq_eval_map, Polynomial.eval₂_C_X]
@[simp]
| Mathlib/RingTheory/Polynomial/Quotient.lean | 150 | 154 | theorem polynomialQuotientEquivQuotientPolynomial_map_mk (I : Ideal R) (f : R[X]) :
I.polynomialQuotientEquivQuotientPolynomial (f.map <| Quotient.mk I) =
Quotient.mk (map C I : Ideal R[X]) f := by | apply (polynomialQuotientEquivQuotientPolynomial I).symm.injective
rw [RingEquiv.symm_apply_apply, polynomialQuotientEquivQuotientPolynomial_symm_mk] |
/-
Copyright (c) 2019 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison, Markus Himmel
-/
import Mathlib.CategoryTheory.Limits.Shapes.Equalizers
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Mono
import Mathlib.CategoryTheory.Limits.Shapes.StrongEpi
import Mathlib.CategoryTheory.MorphismProperty.Factorization
/-!
# Categorical images
We define the categorical image of `f` as a factorisation `f = e ≫ m` through a monomorphism `m`,
so that `m` factors through the `m'` in any other such factorisation.
## Main definitions
* A `MonoFactorisation` is a factorisation `f = e ≫ m`, where `m` is a monomorphism
* `IsImage F` means that a given mono factorisation `F` has the universal property of the image.
* `HasImage f` means that there is some image factorization for the morphism `f : X ⟶ Y`.
* In this case, `image f` is some image object (selected with choice), `image.ι f : image f ⟶ Y`
is the monomorphism `m` of the factorisation and `factorThruImage f : X ⟶ image f` is the
morphism `e`.
* `HasImages C` means that every morphism in `C` has an image.
* Let `f : X ⟶ Y` and `g : P ⟶ Q` be morphisms in `C`, which we will represent as objects of the
arrow category `Arrow C`. Then `sq : f ⟶ g` is a commutative square in `C`. If `f` and `g` have
images, then `HasImageMap sq` represents the fact that there is a morphism
`i : image f ⟶ image g` making the diagram
X ----→ image f ----→ Y
| | |
| | |
↓ ↓ ↓
P ----→ image g ----→ Q
commute, where the top row is the image factorisation of `f`, the bottom row is the image
factorisation of `g`, and the outer rectangle is the commutative square `sq`.
* If a category `HasImages`, then `HasImageMaps` means that every commutative square admits an
image map.
* If a category `HasImages`, then `HasStrongEpiImages` means that the morphism to the image is
always a strong epimorphism.
## Main statements
* When `C` has equalizers, the morphism `e` appearing in an image factorisation is an epimorphism.
* When `C` has strong epi images, then these images admit image maps.
## Future work
* TODO: coimages, and abelian categories.
* TODO: connect this with existing working in the group theory and ring theory libraries.
-/
noncomputable section
universe v u
open CategoryTheory
open CategoryTheory.Limits.WalkingParallelPair
namespace CategoryTheory.Limits
variable {C : Type u} [Category.{v} C]
variable {X Y : C} (f : X ⟶ Y)
/-- A factorisation of a morphism `f = e ≫ m`, with `m` monic. -/
structure MonoFactorisation (f : X ⟶ Y) where
I : C -- Porting note: violates naming conventions but can't think a better replacement
m : I ⟶ Y
[m_mono : Mono m]
e : X ⟶ I
fac : e ≫ m = f := by aesop_cat
attribute [inherit_doc MonoFactorisation] MonoFactorisation.I MonoFactorisation.m
MonoFactorisation.m_mono MonoFactorisation.e MonoFactorisation.fac
attribute [reassoc (attr := simp)] MonoFactorisation.fac
attribute [instance] MonoFactorisation.m_mono
namespace MonoFactorisation
/-- The obvious factorisation of a monomorphism through itself. -/
def self [Mono f] : MonoFactorisation f where
I := X
m := f
e := 𝟙 X
-- I'm not sure we really need this, but the linter says that an inhabited instance
-- ought to exist...
instance [Mono f] : Inhabited (MonoFactorisation f) := ⟨self f⟩
variable {f}
/-- The morphism `m` in a factorisation `f = e ≫ m` through a monomorphism is uniquely
determined. -/
@[ext (iff := false)]
theorem ext {F F' : MonoFactorisation f} (hI : F.I = F'.I)
(hm : F.m = eqToHom hI ≫ F'.m) : F = F' := by
obtain ⟨_, Fm, _, Ffac⟩ := F; obtain ⟨_, Fm', _, Ffac'⟩ := F'
cases hI
simp? at hm says simp only [eqToHom_refl, Category.id_comp] at hm
congr
apply (cancel_mono Fm).1
rw [Ffac, hm, Ffac']
/-- Any mono factorisation of `f` gives a mono factorisation of `f ≫ g` when `g` is a mono. -/
@[simps]
def compMono (F : MonoFactorisation f) {Y' : C} (g : Y ⟶ Y') [Mono g] :
MonoFactorisation (f ≫ g) where
I := F.I
m := F.m ≫ g
m_mono := mono_comp _ _
e := F.e
/-- A mono factorisation of `f ≫ g`, where `g` is an isomorphism,
gives a mono factorisation of `f`. -/
@[simps]
def ofCompIso {Y' : C} {g : Y ⟶ Y'} [IsIso g] (F : MonoFactorisation (f ≫ g)) :
MonoFactorisation f where
I := F.I
m := F.m ≫ inv g
m_mono := mono_comp _ _
e := F.e
/-- Any mono factorisation of `f` gives a mono factorisation of `g ≫ f`. -/
@[simps]
def isoComp (F : MonoFactorisation f) {X' : C} (g : X' ⟶ X) : MonoFactorisation (g ≫ f) where
I := F.I
m := F.m
e := g ≫ F.e
/-- A mono factorisation of `g ≫ f`, where `g` is an isomorphism,
gives a mono factorisation of `f`. -/
@[simps]
def ofIsoComp {X' : C} (g : X' ⟶ X) [IsIso g] (F : MonoFactorisation (g ≫ f)) :
MonoFactorisation f where
I := F.I
m := F.m
e := inv g ≫ F.e
/-- If `f` and `g` are isomorphic arrows, then a mono factorisation of `f`
gives a mono factorisation of `g` -/
@[simps]
def ofArrowIso {f g : Arrow C} (F : MonoFactorisation f.hom) (sq : f ⟶ g) [IsIso sq] :
MonoFactorisation g.hom where
I := F.I
m := F.m ≫ sq.right
e := inv sq.left ≫ F.e
m_mono := mono_comp _ _
fac := by simp only [fac_assoc, Arrow.w, IsIso.inv_comp_eq, Category.assoc]
end MonoFactorisation
variable {f}
/-- Data exhibiting that a given factorisation through a mono is initial. -/
structure IsImage (F : MonoFactorisation f) where
lift : ∀ F' : MonoFactorisation f, F.I ⟶ F'.I
lift_fac : ∀ F' : MonoFactorisation f, lift F' ≫ F'.m = F.m := by aesop_cat
attribute [inherit_doc IsImage] IsImage.lift IsImage.lift_fac
attribute [reassoc (attr := simp)] IsImage.lift_fac
namespace IsImage
@[reassoc (attr := simp)]
theorem fac_lift {F : MonoFactorisation f} (hF : IsImage F) (F' : MonoFactorisation f) :
F.e ≫ hF.lift F' = F'.e :=
(cancel_mono F'.m).1 <| by simp
variable (f)
/-- The trivial factorisation of a monomorphism satisfies the universal property. -/
@[simps]
def self [Mono f] : IsImage (MonoFactorisation.self f) where lift F' := F'.e
instance [Mono f] : Inhabited (IsImage (MonoFactorisation.self f)) :=
⟨self f⟩
variable {f}
-- TODO this is another good candidate for a future `UniqueUpToCanonicalIso`.
/-- Two factorisations through monomorphisms satisfying the universal property
must factor through isomorphic objects. -/
@[simps]
def isoExt {F F' : MonoFactorisation f} (hF : IsImage F) (hF' : IsImage F') :
F.I ≅ F'.I where
hom := hF.lift F'
inv := hF'.lift F
hom_inv_id := (cancel_mono F.m).1 (by simp)
inv_hom_id := (cancel_mono F'.m).1 (by simp)
variable {F F' : MonoFactorisation f} (hF : IsImage F) (hF' : IsImage F')
theorem isoExt_hom_m : (isoExt hF hF').hom ≫ F'.m = F.m := by simp
theorem isoExt_inv_m : (isoExt hF hF').inv ≫ F.m = F'.m := by simp
theorem e_isoExt_hom : F.e ≫ (isoExt hF hF').hom = F'.e := by simp
theorem e_isoExt_inv : F'.e ≫ (isoExt hF hF').inv = F.e := by simp
/-- If `f` and `g` are isomorphic arrows, then a mono factorisation of `f` that is an image
gives a mono factorisation of `g` that is an image -/
@[simps]
def ofArrowIso {f g : Arrow C} {F : MonoFactorisation f.hom} (hF : IsImage F) (sq : f ⟶ g)
[IsIso sq] : IsImage (F.ofArrowIso sq) where
lift F' := hF.lift (F'.ofArrowIso (inv sq))
lift_fac F' := by
simpa only [MonoFactorisation.ofArrowIso_m, Arrow.inv_right, ← Category.assoc,
IsIso.comp_inv_eq] using hF.lift_fac (F'.ofArrowIso (inv sq))
end IsImage
variable (f)
/-- Data exhibiting that a morphism `f` has an image. -/
structure ImageFactorisation (f : X ⟶ Y) where
F : MonoFactorisation f -- Porting note: another violation of the naming convention
isImage : IsImage F
attribute [inherit_doc ImageFactorisation] ImageFactorisation.F ImageFactorisation.isImage
namespace ImageFactorisation
instance [Mono f] : Inhabited (ImageFactorisation f) :=
⟨⟨_, IsImage.self f⟩⟩
/-- If `f` and `g` are isomorphic arrows, then an image factorisation of `f`
gives an image factorisation of `g` -/
@[simps]
def ofArrowIso {f g : Arrow C} (F : ImageFactorisation f.hom) (sq : f ⟶ g) [IsIso sq] :
ImageFactorisation g.hom where
F := F.F.ofArrowIso sq
isImage := F.isImage.ofArrowIso sq
end ImageFactorisation
/-- `HasImage f` means that there exists an image factorisation of `f`. -/
class HasImage (f : X ⟶ Y) : Prop where mk' ::
exists_image : Nonempty (ImageFactorisation f)
attribute [inherit_doc HasImage] HasImage.exists_image
theorem HasImage.mk {f : X ⟶ Y} (F : ImageFactorisation f) : HasImage f :=
⟨Nonempty.intro F⟩
theorem HasImage.of_arrow_iso {f g : Arrow C} [h : HasImage f.hom] (sq : f ⟶ g) [IsIso sq] :
HasImage g.hom :=
⟨⟨h.exists_image.some.ofArrowIso sq⟩⟩
instance (priority := 100) mono_hasImage (f : X ⟶ Y) [Mono f] : HasImage f :=
HasImage.mk ⟨_, IsImage.self f⟩
section
variable [HasImage f]
/-- Some factorisation of `f` through a monomorphism (selected with choice). -/
def Image.monoFactorisation : MonoFactorisation f :=
(Classical.choice HasImage.exists_image).F
/-- The witness of the universal property for the chosen factorisation of `f` through
a monomorphism. -/
def Image.isImage : IsImage (Image.monoFactorisation f) :=
(Classical.choice HasImage.exists_image).isImage
/-- The categorical image of a morphism. -/
def image : C :=
(Image.monoFactorisation f).I
/-- The inclusion of the image of a morphism into the target. -/
def image.ι : image f ⟶ Y :=
(Image.monoFactorisation f).m
@[simp]
theorem image.as_ι : (Image.monoFactorisation f).m = image.ι f := rfl
instance : Mono (image.ι f) :=
(Image.monoFactorisation f).m_mono
/-- The map from the source to the image of a morphism. -/
def factorThruImage : X ⟶ image f :=
(Image.monoFactorisation f).e
/-- Rewrite in terms of the `factorThruImage` interface. -/
@[simp]
theorem as_factorThruImage : (Image.monoFactorisation f).e = factorThruImage f :=
rfl
@[reassoc (attr := simp)]
theorem image.fac : factorThruImage f ≫ image.ι f = f :=
(Image.monoFactorisation f).fac
variable {f}
/-- Any other factorisation of the morphism `f` through a monomorphism receives a map from the
image. -/
def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I :=
(Image.isImage f).lift F'
@[reassoc (attr := simp)]
theorem image.lift_fac (F' : MonoFactorisation f) : image.lift F' ≫ F'.m = image.ι f :=
(Image.isImage f).lift_fac F'
@[reassoc (attr := simp)]
theorem image.fac_lift (F' : MonoFactorisation f) : factorThruImage f ≫ image.lift F' = F'.e :=
(Image.isImage f).fac_lift F'
@[simp]
theorem image.isImage_lift (F : MonoFactorisation f) : (Image.isImage f).lift F = image.lift F :=
rfl
@[reassoc (attr := simp)]
theorem IsImage.lift_ι {F : MonoFactorisation f} (hF : IsImage F) :
hF.lift (Image.monoFactorisation f) ≫ image.ι f = F.m :=
hF.lift_fac _
-- TODO we could put a category structure on `MonoFactorisation f`,
-- with the morphisms being `g : I ⟶ I'` commuting with the `m`s
-- (they then automatically commute with the `e`s)
-- and show that an `imageOf f` gives an initial object there
-- (uniqueness of the lift comes for free).
instance image.lift_mono (F' : MonoFactorisation f) : Mono (image.lift F') := by
refine @mono_of_mono _ _ _ _ _ _ F'.m ?_
simpa using MonoFactorisation.m_mono _
theorem HasImage.uniq (F' : MonoFactorisation f) (l : image f ⟶ F'.I) (w : l ≫ F'.m = image.ι f) :
l = image.lift F' :=
(cancel_mono F'.m).1 (by simp [w])
/-- If `has_image g`, then `has_image (f ≫ g)` when `f` is an isomorphism. -/
instance {X Y Z : C} (f : X ⟶ Y) [IsIso f] (g : Y ⟶ Z) [HasImage g] : HasImage (f ≫ g) where
exists_image :=
⟨{ F :=
{ I := image g
m := image.ι g
e := f ≫ factorThruImage g }
isImage :=
{ lift := fun F' => image.lift
{ I := F'.I
m := F'.m
e := inv f ≫ F'.e } } }⟩
end
section
variable (C)
/-- `HasImages` asserts that every morphism has an image. -/
class HasImages : Prop where
has_image : ∀ {X Y : C} (f : X ⟶ Y), HasImage f
attribute [inherit_doc HasImages] HasImages.has_image
attribute [instance 100] HasImages.has_image
end
section
/-- The image of a monomorphism is isomorphic to the source. -/
def imageMonoIsoSource [Mono f] : image f ≅ X :=
IsImage.isoExt (Image.isImage f) (IsImage.self f)
@[reassoc (attr := simp)]
theorem imageMonoIsoSource_inv_ι [Mono f] : (imageMonoIsoSource f).inv ≫ image.ι f = f := by
simp [imageMonoIsoSource]
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Limits/Shapes/Images.lean | 377 | 379 | theorem imageMonoIsoSource_hom_self [Mono f] : (imageMonoIsoSource f).hom ≫ f = image.ι f := by | simp only [← imageMonoIsoSource_inv_ι f]
rw [← Category.assoc, Iso.hom_inv_id, Category.id_comp] |
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Michael Howes, Antoine Chambert-Loir
-/
import Mathlib.Data.Finite.Card
import Mathlib.GroupTheory.Commutator.Basic
import Mathlib.GroupTheory.Coset.Basic
import Mathlib.GroupTheory.Rank
/-!
# The abelianization of a group
This file defines the commutator and the abelianization of a group. It furthermore prepares for the
result that the abelianization is left adjoint to the forgetful functor from abelian groups to
groups, which can be found in `Algebra/Category/Group/Adjunctions`.
## Main definitions
* `commutator`: defines the commutator of a group `G` as a subgroup of `G`.
* `Abelianization`: defines the abelianization of a group `G` as the quotient of a group by its
commutator subgroup.
* `Abelianization.map`: lifts a group homomorphism to a homomorphism between the abelianizations
* `MulEquiv.abelianizationCongr`: Equivalent groups have equivalent abelianizations
-/
assert_not_exists Field
universe u v w
-- Let G be a group.
variable (G : Type u) [Group G]
open Subgroup (centralizer)
/-- The commutator subgroup of a group G is the normal subgroup
generated by the commutators [p,q]=`p*q*p⁻¹*q⁻¹`. -/
def commutator : Subgroup G := ⁅(⊤ : Subgroup G), ⊤⁆
-- The `Subgroup.Normal` instance should be constructed by a deriving handler.
-- https://github.com/leanprover-community/mathlib4/issues/380
instance : Subgroup.Normal (commutator G) := Subgroup.commutator_normal ⊤ ⊤
theorem commutator_def : commutator G = ⁅(⊤ : Subgroup G), ⊤⁆ :=
rfl
theorem commutator_eq_closure : commutator G = Subgroup.closure (commutatorSet G) := by
simp [commutator, Subgroup.commutator_def, commutatorSet]
theorem commutator_eq_normalClosure : commutator G = Subgroup.normalClosure (commutatorSet G) := by
simp [commutator, Subgroup.commutator_def', commutatorSet]
variable {G} in
theorem Subgroup.map_subtype_commutator (H : Subgroup G) :
(_root_.commutator H).map H.subtype = ⁅H, H⁆ := by
rw [_root_.commutator_def, map_commutator, ← MonoidHom.range_eq_map, H.range_subtype]
instance commutator_characteristic : (commutator G).Characteristic :=
Subgroup.commutator_characteristic ⊤ ⊤
instance [Finite (commutatorSet G)] : Group.FG (commutator G) := by
rw [commutator_eq_closure]
apply Group.closure_finite_fg
theorem rank_commutator_le_card [Finite (commutatorSet G)] :
Group.rank (commutator G) ≤ Nat.card (commutatorSet G) := by
rw [Subgroup.rank_congr (commutator_eq_closure G)]
apply Subgroup.rank_closure_finite_le_nat_card
| Mathlib/GroupTheory/Abelianization.lean | 71 | 79 | theorem commutator_centralizer_commutator_le_center :
⁅centralizer (commutator G : Set G), centralizer (commutator G)⁆ ≤ Subgroup.center G := by | rw [← Subgroup.centralizer_univ, ← Subgroup.coe_top, ←
Subgroup.commutator_eq_bot_iff_le_centralizer]
suffices ⁅⁅⊤, centralizer (commutator G : Set G)⁆, centralizer (commutator G : Set G)⁆ = ⊥ by
refine Subgroup.commutator_commutator_eq_bot_of_rotate ?_ this
rwa [Subgroup.commutator_comm (centralizer (commutator G : Set G))]
rw [Subgroup.commutator_comm, Subgroup.commutator_eq_bot_iff_le_centralizer]
exact Set.centralizer_subset (Subgroup.commutator_mono le_top le_top) |
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.ContDiff.RCLike
import Mathlib.MeasureTheory.Measure.Hausdorff
/-!
# Hausdorff dimension
The Hausdorff dimension of a set `X` in an (extended) metric space is the unique number
`dimH s : ℝ≥0∞` such that for any `d : ℝ≥0` we have
- `μH[d] s = 0` if `dimH s < d`, and
- `μH[d] s = ∞` if `d < dimH s`.
In this file we define `dimH s` to be the Hausdorff dimension of `s`, then prove some basic
properties of Hausdorff dimension.
## Main definitions
* `MeasureTheory.dimH`: the Hausdorff dimension of a set. For the Hausdorff dimension of the whole
space we use `MeasureTheory.dimH (Set.univ : Set X)`.
## Main results
### Basic properties of Hausdorff dimension
* `hausdorffMeasure_of_lt_dimH`, `dimH_le_of_hausdorffMeasure_ne_top`,
`le_dimH_of_hausdorffMeasure_eq_top`, `hausdorffMeasure_of_dimH_lt`, `measure_zero_of_dimH_lt`,
`le_dimH_of_hausdorffMeasure_ne_zero`, `dimH_of_hausdorffMeasure_ne_zero_ne_top`: various forms
of the characteristic property of the Hausdorff dimension;
* `dimH_union`: the Hausdorff dimension of the union of two sets is the maximum of their Hausdorff
dimensions.
* `dimH_iUnion`, `dimH_bUnion`, `dimH_sUnion`: the Hausdorff dimension of a countable union of sets
is the supremum of their Hausdorff dimensions;
* `dimH_empty`, `dimH_singleton`, `Set.Subsingleton.dimH_zero`, `Set.Countable.dimH_zero` : `dimH s
= 0` whenever `s` is countable;
### (Pre)images under (anti)lipschitz and Hölder continuous maps
* `HolderWith.dimH_image_le` etc: if `f : X → Y` is Hölder continuous with exponent `r > 0`, then
for any `s`, `dimH (f '' s) ≤ dimH s / r`. We prove versions of this statement for `HolderWith`,
`HolderOnWith`, and locally Hölder maps, as well as for `Set.image` and `Set.range`.
* `LipschitzWith.dimH_image_le` etc: Lipschitz continuous maps do not increase the Hausdorff
dimension of sets.
* for a map that is known to be both Lipschitz and antilipschitz (e.g., for an `Isometry` or
a `ContinuousLinearEquiv`) we also prove `dimH (f '' s) = dimH s`.
### Hausdorff measure in `ℝⁿ`
* `Real.dimH_of_nonempty_interior`: if `s` is a set in a finite dimensional real vector space `E`
with nonempty interior, then the Hausdorff dimension of `s` is equal to the dimension of `E`.
* `dense_compl_of_dimH_lt_finrank`: if `s` is a set in a finite dimensional real vector space `E`
with Hausdorff dimension strictly less than the dimension of `E`, the `s` has a dense complement.
* `ContDiff.dense_compl_range_of_finrank_lt_finrank`: the complement to the range of a `C¹`
smooth map is dense provided that the dimension of the domain is strictly less than the dimension
of the codomain.
## Notations
We use the following notation localized in `MeasureTheory`. It is defined in
`MeasureTheory.Measure.Hausdorff`.
- `μH[d]` : `MeasureTheory.Measure.hausdorffMeasure d`
## Implementation notes
* The definition of `dimH` explicitly uses `borel X` as a measurable space structure. This way we
can formulate lemmas about Hausdorff dimension without assuming that the environment has a
`[MeasurableSpace X]` instance that is equal but possibly not defeq to `borel X`.
Lemma `dimH_def` unfolds this definition using whatever `[MeasurableSpace X]` instance we have in
the environment (as long as it is equal to `borel X`).
* The definition `dimH` is irreducible; use API lemmas or `dimH_def` instead.
## Tags
Hausdorff measure, Hausdorff dimension, dimension
-/
open scoped MeasureTheory ENNReal NNReal Topology
open MeasureTheory MeasureTheory.Measure Set TopologicalSpace Module Filter
variable {ι X Y : Type*} [EMetricSpace X] [EMetricSpace Y]
/-- Hausdorff dimension of a set in an (e)metric space. -/
@[irreducible] noncomputable def dimH (s : Set X) : ℝ≥0∞ := by
borelize X; exact ⨆ (d : ℝ≥0) (_ : @hausdorffMeasure X _ _ ⟨rfl⟩ d s = ∞), d
/-!
### Basic properties
-/
section Measurable
variable [MeasurableSpace X] [BorelSpace X]
/-- Unfold the definition of `dimH` using `[MeasurableSpace X] [BorelSpace X]` from the
environment. -/
theorem dimH_def (s : Set X) : dimH s = ⨆ (d : ℝ≥0) (_ : μH[d] s = ∞), (d : ℝ≥0∞) := by
borelize X; rw [dimH]
theorem hausdorffMeasure_of_lt_dimH {s : Set X} {d : ℝ≥0} (h : ↑d < dimH s) : μH[d] s = ∞ := by
simp only [dimH_def, lt_iSup_iff] at h
rcases h with ⟨d', hsd', hdd'⟩
rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at hdd'
exact top_unique (hsd' ▸ hausdorffMeasure_mono hdd'.le _)
theorem dimH_le {s : Set X} {d : ℝ≥0∞} (H : ∀ d' : ℝ≥0, μH[d'] s = ∞ → ↑d' ≤ d) : dimH s ≤ d :=
(dimH_def s).trans_le <| iSup₂_le H
theorem dimH_le_of_hausdorffMeasure_ne_top {s : Set X} {d : ℝ≥0} (h : μH[d] s ≠ ∞) : dimH s ≤ d :=
le_of_not_lt <| mt hausdorffMeasure_of_lt_dimH h
theorem le_dimH_of_hausdorffMeasure_eq_top {s : Set X} {d : ℝ≥0} (h : μH[d] s = ∞) :
↑d ≤ dimH s := by
rw [dimH_def]; exact le_iSup₂ (α := ℝ≥0∞) d h
theorem hausdorffMeasure_of_dimH_lt {s : Set X} {d : ℝ≥0} (h : dimH s < d) : μH[d] s = 0 := by
rw [dimH_def] at h
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 h with ⟨d', hsd', hd'd⟩
rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at hd'd
exact (hausdorffMeasure_zero_or_top hd'd s).resolve_right fun h₂ => hsd'.not_le <|
le_iSup₂ (α := ℝ≥0∞) d' h₂
theorem measure_zero_of_dimH_lt {μ : Measure X} {d : ℝ≥0} (h : μ ≪ μH[d]) {s : Set X}
(hd : dimH s < d) : μ s = 0 :=
h <| hausdorffMeasure_of_dimH_lt hd
theorem le_dimH_of_hausdorffMeasure_ne_zero {s : Set X} {d : ℝ≥0} (h : μH[d] s ≠ 0) : ↑d ≤ dimH s :=
le_of_not_lt <| mt hausdorffMeasure_of_dimH_lt h
theorem dimH_of_hausdorffMeasure_ne_zero_ne_top {d : ℝ≥0} {s : Set X} (h : μH[d] s ≠ 0)
(h' : μH[d] s ≠ ∞) : dimH s = d :=
le_antisymm (dimH_le_of_hausdorffMeasure_ne_top h') (le_dimH_of_hausdorffMeasure_ne_zero h)
end Measurable
@[mono]
theorem dimH_mono {s t : Set X} (h : s ⊆ t) : dimH s ≤ dimH t := by
borelize X
exact dimH_le fun d hd => le_dimH_of_hausdorffMeasure_eq_top <| top_unique <| hd ▸ measure_mono h
theorem dimH_subsingleton {s : Set X} (h : s.Subsingleton) : dimH s = 0 := by
borelize X
apply le_antisymm _ (zero_le _)
refine dimH_le_of_hausdorffMeasure_ne_top ?_
exact ((hausdorffMeasure_le_one_of_subsingleton h le_rfl).trans_lt ENNReal.one_lt_top).ne
alias Set.Subsingleton.dimH_zero := dimH_subsingleton
@[simp]
theorem dimH_empty : dimH (∅ : Set X) = 0 :=
subsingleton_empty.dimH_zero
@[simp]
theorem dimH_singleton (x : X) : dimH ({x} : Set X) = 0 :=
subsingleton_singleton.dimH_zero
@[simp]
theorem dimH_iUnion {ι : Sort*} [Countable ι] (s : ι → Set X) :
dimH (⋃ i, s i) = ⨆ i, dimH (s i) := by
borelize X
refine le_antisymm (dimH_le fun d hd => ?_) (iSup_le fun i => dimH_mono <| subset_iUnion _ _)
contrapose! hd
have : ∀ i, μH[d] (s i) = 0 := fun i =>
hausdorffMeasure_of_dimH_lt ((le_iSup (fun i => dimH (s i)) i).trans_lt hd)
rw [measure_iUnion_null this]
exact ENNReal.zero_ne_top
@[simp]
theorem dimH_bUnion {s : Set ι} (hs : s.Countable) (t : ι → Set X) :
dimH (⋃ i ∈ s, t i) = ⨆ i ∈ s, dimH (t i) := by
haveI := hs.toEncodable
rw [biUnion_eq_iUnion, dimH_iUnion, ← iSup_subtype'']
@[simp]
theorem dimH_sUnion {S : Set (Set X)} (hS : S.Countable) : dimH (⋃₀ S) = ⨆ s ∈ S, dimH s := by
rw [sUnion_eq_biUnion, dimH_bUnion hS]
@[simp]
theorem dimH_union (s t : Set X) : dimH (s ∪ t) = max (dimH s) (dimH t) := by
rw [union_eq_iUnion, dimH_iUnion, iSup_bool_eq, cond, cond]
theorem dimH_countable {s : Set X} (hs : s.Countable) : dimH s = 0 :=
biUnion_of_singleton s ▸ by simp only [dimH_bUnion hs, dimH_singleton, ENNReal.iSup_zero]
alias Set.Countable.dimH_zero := dimH_countable
theorem dimH_finite {s : Set X} (hs : s.Finite) : dimH s = 0 :=
hs.countable.dimH_zero
alias Set.Finite.dimH_zero := dimH_finite
@[simp]
theorem dimH_coe_finset (s : Finset X) : dimH (s : Set X) = 0 :=
s.finite_toSet.dimH_zero
alias Finset.dimH_zero := dimH_coe_finset
/-!
### Hausdorff dimension as the supremum of local Hausdorff dimensions
-/
section
variable [SecondCountableTopology X]
/-- If `r` is less than the Hausdorff dimension of a set `s` in an (extended) metric space with
second countable topology, then there exists a point `x ∈ s` such that every neighborhood
`t` of `x` within `s` has Hausdorff dimension greater than `r`. -/
theorem exists_mem_nhdsWithin_lt_dimH_of_lt_dimH {s : Set X} {r : ℝ≥0∞} (h : r < dimH s) :
∃ x ∈ s, ∀ t ∈ 𝓝[s] x, r < dimH t := by
contrapose! h; choose! t htx htr using h
rcases countable_cover_nhdsWithin htx with ⟨S, hSs, hSc, hSU⟩
calc
dimH s ≤ dimH (⋃ x ∈ S, t x) := dimH_mono hSU
_ = ⨆ x ∈ S, dimH (t x) := dimH_bUnion hSc _
_ ≤ r := iSup₂_le fun x hx => htr x <| hSs hx
/-- In an (extended) metric space with second countable topology, the Hausdorff dimension
of a set `s` is the supremum over `x ∈ s` of the limit superiors of `dimH t` along
`(𝓝[s] x).smallSets`. -/
theorem bsupr_limsup_dimH (s : Set X) : ⨆ x ∈ s, limsup dimH (𝓝[s] x).smallSets = dimH s := by
refine le_antisymm (iSup₂_le fun x _ => ?_) ?_
· refine limsup_le_of_le isCobounded_le_of_bot ?_
exact eventually_smallSets.2 ⟨s, self_mem_nhdsWithin, fun t => dimH_mono⟩
· refine le_of_forall_lt_imp_le_of_dense fun r hr => ?_
rcases exists_mem_nhdsWithin_lt_dimH_of_lt_dimH hr with ⟨x, hxs, hxr⟩
refine le_iSup₂_of_le x hxs ?_; rw [limsup_eq]; refine le_sInf fun b hb => ?_
rcases eventually_smallSets.1 hb with ⟨t, htx, ht⟩
exact (hxr t htx).le.trans (ht t Subset.rfl)
/-- In an (extended) metric space with second countable topology, the Hausdorff dimension
of a set `s` is the supremum over all `x` of the limit superiors of `dimH t` along
`(𝓝[s] x).smallSets`. -/
theorem iSup_limsup_dimH (s : Set X) : ⨆ x, limsup dimH (𝓝[s] x).smallSets = dimH s := by
refine le_antisymm (iSup_le fun x => ?_) ?_
· refine limsup_le_of_le isCobounded_le_of_bot ?_
exact eventually_smallSets.2 ⟨s, self_mem_nhdsWithin, fun t => dimH_mono⟩
· rw [← bsupr_limsup_dimH]; exact iSup₂_le_iSup _ _
end
/-!
### Hausdorff dimension and Hölder continuity
-/
variable {C K r : ℝ≥0} {f : X → Y} {s : Set X}
/-- If `f` is a Hölder continuous map with exponent `r > 0`, then `dimH (f '' s) ≤ dimH s / r`. -/
theorem HolderOnWith.dimH_image_le (h : HolderOnWith C r f s) (hr : 0 < r) :
dimH (f '' s) ≤ dimH s / r := by
borelize X Y
refine dimH_le fun d hd => ?_
have := h.hausdorffMeasure_image_le hr d.coe_nonneg
rw [hd, ← ENNReal.coe_rpow_of_nonneg _ d.coe_nonneg, top_le_iff] at this
have Hrd : μH[(r * d : ℝ≥0)] s = ⊤ := by
contrapose this
exact ENNReal.mul_ne_top ENNReal.coe_ne_top this
rw [ENNReal.le_div_iff_mul_le, mul_comm, ← ENNReal.coe_mul]
exacts [le_dimH_of_hausdorffMeasure_eq_top Hrd, Or.inl (mt ENNReal.coe_eq_zero.1 hr.ne'),
Or.inl ENNReal.coe_ne_top]
namespace HolderWith
/-- If `f : X → Y` is Hölder continuous with a positive exponent `r`, then the Hausdorff dimension
of the image of a set `s` is at most `dimH s / r`. -/
theorem dimH_image_le (h : HolderWith C r f) (hr : 0 < r) (s : Set X) :
dimH (f '' s) ≤ dimH s / r :=
(h.holderOnWith s).dimH_image_le hr
/-- If `f` is a Hölder continuous map with exponent `r > 0`, then the Hausdorff dimension of its
range is at most the Hausdorff dimension of its domain divided by `r`. -/
theorem dimH_range_le (h : HolderWith C r f) (hr : 0 < r) :
dimH (range f) ≤ dimH (univ : Set X) / r :=
@image_univ _ _ f ▸ h.dimH_image_le hr univ
end HolderWith
/-- If `s` is a set in a space `X` with second countable topology and `f : X → Y` is Hölder
continuous in a neighborhood within `s` of every point `x ∈ s` with the same positive exponent `r`
but possibly different coefficients, then the Hausdorff dimension of the image `f '' s` is at most
the Hausdorff dimension of `s` divided by `r`. -/
theorem dimH_image_le_of_locally_holder_on [SecondCountableTopology X] {r : ℝ≥0} {f : X → Y}
(hr : 0 < r) {s : Set X} (hf : ∀ x ∈ s, ∃ C : ℝ≥0, ∃ t ∈ 𝓝[s] x, HolderOnWith C r f t) :
dimH (f '' s) ≤ dimH s / r := by
choose! C t htn hC using hf
rcases countable_cover_nhdsWithin htn with ⟨u, hus, huc, huU⟩
replace huU := inter_eq_self_of_subset_left huU; rw [inter_iUnion₂] at huU
rw [← huU, image_iUnion₂, dimH_bUnion huc, dimH_bUnion huc]; simp only [ENNReal.iSup_div]
exact iSup₂_mono fun x hx => ((hC x (hus hx)).mono inter_subset_right).dimH_image_le hr
/-- If `f : X → Y` is Hölder continuous in a neighborhood of every point `x : X` with the same
positive exponent `r` but possibly different coefficients, then the Hausdorff dimension of the range
of `f` is at most the Hausdorff dimension of `X` divided by `r`. -/
theorem dimH_range_le_of_locally_holder_on [SecondCountableTopology X] {r : ℝ≥0} {f : X → Y}
(hr : 0 < r) (hf : ∀ x : X, ∃ C : ℝ≥0, ∃ s ∈ 𝓝 x, HolderOnWith C r f s) :
dimH (range f) ≤ dimH (univ : Set X) / r := by
rw [← image_univ]
refine dimH_image_le_of_locally_holder_on hr fun x _ => ?_
simpa only [exists_prop, nhdsWithin_univ] using hf x
/-!
### Hausdorff dimension and Lipschitz continuity
-/
/-- If `f : X → Y` is Lipschitz continuous on `s`, then `dimH (f '' s) ≤ dimH s`. -/
| Mathlib/Topology/MetricSpace/HausdorffDimension.lean | 318 | 329 | theorem LipschitzOnWith.dimH_image_le (h : LipschitzOnWith K f s) : dimH (f '' s) ≤ dimH s := by | simpa using h.holderOnWith.dimH_image_le zero_lt_one
namespace LipschitzWith
/-- If `f` is a Lipschitz continuous map, then `dimH (f '' s) ≤ dimH s`. -/
theorem dimH_image_le (h : LipschitzWith K f) (s : Set X) : dimH (f '' s) ≤ dimH s :=
h.lipschitzOnWith.dimH_image_le
/-- If `f` is a Lipschitz continuous map, then the Hausdorff dimension of its range is at most the
Hausdorff dimension of its domain. -/
theorem dimH_range_le (h : LipschitzWith K f) : dimH (range f) ≤ dimH (univ : Set X) := |
/-
Copyright (c) 2022 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine
import Mathlib.Geometry.Euclidean.Angle.Unoriented.RightAngle
/-!
# Oriented angles in right-angled triangles.
This file proves basic geometrical results about distances and oriented angles in (possibly
degenerate) right-angled triangles in real inner product spaces and Euclidean affine spaces.
-/
noncomputable section
open scoped EuclideanGeometry
open scoped Real
open scoped RealInnerProductSpace
namespace Orientation
open Module
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
variable [hd2 : Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2))
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arccos_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arccos (‖y‖ / ‖x + y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arcsin`. -/
theorem oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arcsin_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- An angle in a right-angled triangle expressed using `arcsin`. -/
theorem oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arcsin (‖x‖ / ‖x + y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arctan`. -/
theorem oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arctan_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h) (o.left_ne_zero_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arctan`. -/
theorem oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arctan (‖x‖ / ‖y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two h
/-- The cosine of an angle in a right-angled triangle as a ratio of sides. -/
theorem cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle x (x + y)) = ‖x‖ / ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle as a ratio of sides. -/
theorem cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle (x + y) y) = ‖y‖ / ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).cos_oangle_add_right_of_oangle_eq_pi_div_two h
/-- The sine of an angle in a right-angled triangle as a ratio of sides. -/
theorem sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle x (x + y)) = ‖y‖ / ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- The sine of an angle in a right-angled triangle as a ratio of sides. -/
theorem sin_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle (x + y) y) = ‖x‖ / ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).sin_oangle_add_right_of_oangle_eq_pi_div_two h
/-- The tangent of an angle in a right-angled triangle as a ratio of sides. -/
theorem tan_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle x (x + y)) = ‖y‖ / ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The tangent of an angle in a right-angled triangle as a ratio of sides. -/
theorem tan_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle (x + y) y) = ‖x‖ / ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).tan_oangle_add_right_of_oangle_eq_pi_div_two h
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side. -/
theorem cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle x (x + y)) * ‖x + y‖ = ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side. -/
theorem cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x + y) y) * ‖x + y‖ = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side. -/
theorem sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle x (x + y)) * ‖x + y‖ = ‖y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side. -/
theorem sin_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle (x + y) y) * ‖x + y‖ = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side. -/
theorem tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle x (x + y)) * ‖x‖ = ‖y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side. -/
theorem tan_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle (x + y) y) * ‖y‖ = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse. -/
theorem norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.cos (o.oangle x (x + y)) = ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.norm_div_cos_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse. -/
theorem norm_div_cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.cos (o.oangle (x + y) y) = ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse. -/
theorem norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.sin (o.oangle x (x + y)) = ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.norm_div_sin_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse. -/
theorem norm_div_sin_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.sin (o.oangle (x + y) y) = ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side. -/
theorem norm_div_tan_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.tan (o.oangle x (x + y)) = ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.norm_div_tan_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side. -/
theorem norm_div_tan_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.tan (o.oangle (x + y) y) = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_tan_oangle_add_right_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arccos`, version subtracting vectors. -/
theorem oangle_sub_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle y (y - x) = Real.arccos (‖y‖ / ‖y - x‖) := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_sub_eq_arccos_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arccos`, version subtracting vectors. -/
theorem oangle_sub_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x - y) x = Real.arccos (‖x‖ / ‖x - y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).oangle_sub_right_eq_arccos_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arcsin`, version subtracting vectors. -/
theorem oangle_sub_right_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle y (y - x) = Real.arcsin (‖x‖ / ‖y - x‖) := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_sub_eq_arcsin_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- An angle in a right-angled triangle expressed using `arcsin`, version subtracting vectors. -/
theorem oangle_sub_left_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x - y) x = Real.arcsin (‖y‖ / ‖x - y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).oangle_sub_right_eq_arcsin_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arctan`, version subtracting vectors. -/
theorem oangle_sub_right_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle y (y - x) = Real.arctan (‖x‖ / ‖y‖) := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_sub_eq_arctan_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h) (o.right_ne_zero_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arctan`, version subtracting vectors. -/
theorem oangle_sub_left_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x - y) x = Real.arctan (‖y‖ / ‖x‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).oangle_sub_right_eq_arctan_of_oangle_eq_pi_div_two h
/-- The cosine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem cos_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle y (y - x)) = ‖y‖ / ‖y - x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem cos_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle (x - y) x) = ‖x‖ / ‖x - y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).cos_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- The sine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem sin_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle y (y - x)) = ‖x‖ / ‖y - x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- The sine of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem sin_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle (x - y) x) = ‖y‖ / ‖x - y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).sin_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- The tangent of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem tan_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle y (y - x)) = ‖x‖ / ‖y‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The tangent of an angle in a right-angled triangle as a ratio of sides, version subtracting
vectors. -/
theorem tan_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle (x - y) x) = ‖y‖ / ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).tan_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side, version subtracting vectors. -/
theorem cos_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle y (y - x)) * ‖y - x‖ = ‖y‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_sub_mul_norm_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side, version subtracting vectors. -/
theorem cos_oangle_sub_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x - y) x) * ‖x - y‖ = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).cos_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two h
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side, version subtracting vectors. -/
theorem sin_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle y (y - x)) * ‖y - x‖ = ‖x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_sub_mul_norm_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side, version subtracting vectors. -/
theorem sin_oangle_sub_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle (x - y) x) * ‖x - y‖ = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).sin_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two h
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side, version subtracting vectors. -/
theorem tan_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle y (y - x)) * ‖y‖ = ‖x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_sub_mul_norm_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side, version subtracting vectors. -/
theorem tan_oangle_sub_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle (x - y) x) * ‖x‖ = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).tan_oangle_sub_right_mul_norm_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_cos_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.cos (o.oangle y (y - x)) = ‖y - x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.norm_div_cos_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_cos_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.cos (o.oangle (x - y) x) = ‖x - y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).norm_div_cos_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_sin_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.sin (o.oangle y (y - x)) = ‖y - x‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.norm_div_sin_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse, version subtracting vectors. -/
theorem norm_div_sin_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.sin (o.oangle (x - y) x) = ‖x - y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).norm_div_sin_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side, version subtracting vectors. -/
theorem norm_div_tan_oangle_sub_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.tan (o.oangle y (y - x)) = ‖y‖ := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.norm_div_tan_angle_sub_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side, version subtracting vectors. -/
theorem norm_div_tan_oangle_sub_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.tan (o.oangle (x - y) x) = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).norm_div_tan_oangle_sub_right_of_oangle_eq_pi_div_two h
/-- An angle in a right-angled triangle expressed using `arctan`, where one side is a multiple
of a rotation of another by `π / 2`. -/
theorem oangle_add_right_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
o.oangle x (x + r • o.rotation (π / 2 : ℝ) x) = Real.arctan r := by
rcases lt_trichotomy r 0 with (hr | rfl | hr)
· have ha : o.oangle x (r • o.rotation (π / 2 : ℝ) x) = -(π / 2 : ℝ) := by
rw [o.oangle_smul_right_of_neg _ _ hr, o.oangle_neg_right h, o.oangle_rotation_self_right h, ←
sub_eq_zero, add_comm, sub_neg_eq_add, ← Real.Angle.coe_add, ← Real.Angle.coe_add,
add_assoc, add_halves, ← two_mul, Real.Angle.coe_two_pi]
simpa using h
-- Porting note: if the type is not given in `neg_neg` then Lean "forgets" about the instance
-- `Neg (Orientation ℝ V (Fin 2))`
rw [← neg_inj, ← oangle_neg_orientation_eq_neg, @neg_neg Real.Angle] at ha
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj, oangle_rev,
(-o).oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two ha, norm_smul,
LinearIsometryEquiv.norm_map, mul_div_assoc, div_self (norm_ne_zero_iff.2 h), mul_one,
Real.norm_eq_abs, abs_of_neg hr, Real.arctan_neg, Real.Angle.coe_neg, neg_neg]
· rw [zero_smul, add_zero, oangle_self, Real.arctan_zero, Real.Angle.coe_zero]
· have ha : o.oangle x (r • o.rotation (π / 2 : ℝ) x) = (π / 2 : ℝ) := by
rw [o.oangle_smul_right_of_pos _ _ hr, o.oangle_rotation_self_right h]
rw [o.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two ha, norm_smul,
LinearIsometryEquiv.norm_map, mul_div_assoc, div_self (norm_ne_zero_iff.2 h), mul_one,
Real.norm_eq_abs, abs_of_pos hr]
/-- An angle in a right-angled triangle expressed using `arctan`, where one side is a multiple
of a rotation of another by `π / 2`. -/
theorem oangle_add_left_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
o.oangle (x + r • o.rotation (π / 2 : ℝ) x) (r • o.rotation (π / 2 : ℝ) x)
= Real.arctan r⁻¹ := by
by_cases hr : r = 0; · simp [hr]
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj, ←
neg_neg ((π / 2 : ℝ) : Real.Angle), ← rotation_neg_orientation_eq_neg, add_comm]
have hx : x = r⁻¹ • (-o).rotation (π / 2 : ℝ) (r • (-o).rotation (-(π / 2 : ℝ)) x) := by simp [hr]
nth_rw 3 [hx]
refine (-o).oangle_add_right_smul_rotation_pi_div_two ?_ _
simp [hr, h]
/-- The tangent of an angle in a right-angled triangle, where one side is a multiple of a
rotation of another by `π / 2`. -/
theorem tan_oangle_add_right_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
Real.Angle.tan (o.oangle x (x + r • o.rotation (π / 2 : ℝ) x)) = r := by
rw [o.oangle_add_right_smul_rotation_pi_div_two h, Real.Angle.tan_coe, Real.tan_arctan]
/-- The tangent of an angle in a right-angled triangle, where one side is a multiple of a
rotation of another by `π / 2`. -/
theorem tan_oangle_add_left_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
Real.Angle.tan (o.oangle (x + r • o.rotation (π / 2 : ℝ) x) (r • o.rotation (π / 2 : ℝ) x)) =
r⁻¹ := by
rw [o.oangle_add_left_smul_rotation_pi_div_two h, Real.Angle.tan_coe, Real.tan_arctan]
/-- An angle in a right-angled triangle expressed using `arctan`, where one side is a multiple
of a rotation of another by `π / 2`, version subtracting vectors. -/
theorem oangle_sub_right_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
o.oangle (r • o.rotation (π / 2 : ℝ) x) (r • o.rotation (π / 2 : ℝ) x - x)
= Real.arctan r⁻¹ := by
by_cases hr : r = 0; · simp [hr]
have hx : -x = r⁻¹ • o.rotation (π / 2 : ℝ) (r • o.rotation (π / 2 : ℝ) x) := by
simp [hr, ← Real.Angle.coe_add]
rw [sub_eq_add_neg, hx, o.oangle_add_right_smul_rotation_pi_div_two]
simpa [hr] using h
/-- An angle in a right-angled triangle expressed using `arctan`, where one side is a multiple
of a rotation of another by `π / 2`, version subtracting vectors. -/
theorem oangle_sub_left_smul_rotation_pi_div_two {x : V} (h : x ≠ 0) (r : ℝ) :
o.oangle (x - r • o.rotation (π / 2 : ℝ) x) x = Real.arctan r := by
by_cases hr : r = 0; · simp [hr]
have hx : x = r⁻¹ • o.rotation (π / 2 : ℝ) (-(r • o.rotation (π / 2 : ℝ) x)) := by
simp [hr, ← Real.Angle.coe_add]
rw [sub_eq_add_neg, add_comm]
nth_rw 3 [hx]
nth_rw 2 [hx]
rw [o.oangle_add_left_smul_rotation_pi_div_two, inv_inv]
simpa [hr] using h
end Orientation
namespace EuclideanGeometry
open Module
variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P] [hd2 : Fact (finrank ℝ V = 2)] [Module.Oriented ℝ V (Fin 2)]
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem oangle_right_eq_arccos_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
∡ p₂ p₃ p₁ = Real.arccos (dist p₃ p₂ / dist p₁ p₃) := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs,
angle_eq_arccos_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem oangle_left_eq_arccos_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
∡ p₃ p₁ p₂ = Real.arccos (dist p₁ p₂ / dist p₁ p₃) := by
have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm,
angle_eq_arccos_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h),
dist_comm p₁ p₃]
/-- An angle in a right-angled triangle expressed using `arcsin`. -/
theorem oangle_right_eq_arcsin_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
∡ p₂ p₃ p₁ = Real.arcsin (dist p₁ p₂ / dist p₁ p₃) := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs,
angle_eq_arcsin_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)
(Or.inl (left_ne_of_oangle_eq_pi_div_two h))]
/-- An angle in a right-angled triangle expressed using `arcsin`. -/
theorem oangle_left_eq_arcsin_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
∡ p₃ p₁ p₂ = Real.arcsin (dist p₃ p₂ / dist p₁ p₃) := by
have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm,
angle_eq_arcsin_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h)
(Or.inr (left_ne_of_oangle_eq_pi_div_two h)),
dist_comm p₁ p₃]
/-- An angle in a right-angled triangle expressed using `arctan`. -/
theorem oangle_right_eq_arctan_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
∡ p₂ p₃ p₁ = Real.arctan (dist p₁ p₂ / dist p₃ p₂) := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs,
angle_eq_arctan_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)
(right_ne_of_oangle_eq_pi_div_two h)]
/-- An angle in a right-angled triangle expressed using `arctan`. -/
theorem oangle_left_eq_arctan_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
∡ p₃ p₁ p₂ = Real.arctan (dist p₃ p₂ / dist p₁ p₂) := by
have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm,
angle_eq_arctan_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h)
(left_ne_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle as a ratio of sides. -/
theorem cos_oangle_right_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
Real.Angle.cos (∡ p₂ p₃ p₁) = dist p₃ p₂ / dist p₁ p₃ := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
cos_angle_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle as a ratio of sides. -/
theorem cos_oangle_left_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
Real.Angle.cos (∡ p₃ p₁ p₂) = dist p₁ p₂ / dist p₁ p₃ := by
have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm, Real.Angle.cos_coe,
cos_angle_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h),
dist_comm p₁ p₃]
/-- The sine of an angle in a right-angled triangle as a ratio of sides. -/
theorem sin_oangle_right_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
Real.Angle.sin (∡ p₂ p₃ p₁) = dist p₁ p₂ / dist p₁ p₃ := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
sin_angle_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)
(Or.inl (left_ne_of_oangle_eq_pi_div_two h))]
/-- The sine of an angle in a right-angled triangle as a ratio of sides. -/
theorem sin_oangle_left_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
Real.Angle.sin (∡ p₃ p₁ p₂) = dist p₃ p₂ / dist p₁ p₃ := by
have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm, Real.Angle.sin_coe,
sin_angle_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h)
(Or.inr (left_ne_of_oangle_eq_pi_div_two h)),
dist_comm p₁ p₃]
/-- The tangent of an angle in a right-angled triangle as a ratio of sides. -/
theorem tan_oangle_right_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
Real.Angle.tan (∡ p₂ p₃ p₁) = dist p₁ p₂ / dist p₃ p₂ := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
tan_angle_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)]
/-- The tangent of an angle in a right-angled triangle as a ratio of sides. -/
theorem tan_oangle_left_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
Real.Angle.tan (∡ p₃ p₁ p₂) = dist p₃ p₂ / dist p₁ p₂ := by
have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm, Real.Angle.tan_coe,
tan_angle_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side. -/
theorem cos_oangle_right_mul_dist_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P}
(h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : Real.Angle.cos (∡ p₂ p₃ p₁) * dist p₁ p₃ = dist p₃ p₂ := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
cos_angle_mul_dist_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side. -/
theorem cos_oangle_left_mul_dist_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P}
(h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : Real.Angle.cos (∡ p₃ p₁ p₂) * dist p₁ p₃ = dist p₁ p₂ := by
have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm, Real.Angle.cos_coe, dist_comm p₁ p₃,
cos_angle_mul_dist_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h)]
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side. -/
theorem sin_oangle_right_mul_dist_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P}
(h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : Real.Angle.sin (∡ p₂ p₃ p₁) * dist p₁ p₃ = dist p₁ p₂ := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
sin_angle_mul_dist_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)]
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side. -/
theorem sin_oangle_left_mul_dist_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P}
(h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : Real.Angle.sin (∡ p₃ p₁ p₂) * dist p₁ p₃ = dist p₃ p₂ := by
have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm, Real.Angle.sin_coe, dist_comm p₁ p₃,
sin_angle_mul_dist_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h)]
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side. -/
theorem tan_oangle_right_mul_dist_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P}
(h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : Real.Angle.tan (∡ p₂ p₃ p₁) * dist p₃ p₂ = dist p₁ p₂ := by
have hs : (∡ p₂ p₃ p₁).sign = 1 := by rw [oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
tan_angle_mul_dist_of_angle_eq_pi_div_two (angle_eq_pi_div_two_of_oangle_eq_pi_div_two h)
(Or.inr (right_ne_of_oangle_eq_pi_div_two h))]
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side. -/
| Mathlib/Geometry/Euclidean/Angle/Oriented/RightAngle.lean | 664 | 670 | theorem tan_oangle_left_mul_dist_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P}
(h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : Real.Angle.tan (∡ p₃ p₁ p₂) * dist p₁ p₂ = dist p₃ p₂ := by | have hs : (∡ p₃ p₁ p₂).sign = 1 := by rw [← oangle_rotate_sign, h, Real.Angle.sign_coe_pi_div_two]
rw [oangle_eq_angle_of_sign_eq_one hs, angle_comm, Real.Angle.tan_coe,
tan_angle_mul_dist_of_angle_eq_pi_div_two (angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two h)
(Or.inr (left_ne_of_oangle_eq_pi_div_two h))] |
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.BoxIntegral.Partition.Basic
/-!
# Split a box along one or more hyperplanes
## Main definitions
A hyperplane `{x : ι → ℝ | x i = a}` splits a rectangular box `I : BoxIntegral.Box ι` into two
smaller boxes. If `a ∉ Ioo (I.lower i, I.upper i)`, then one of these boxes is empty, so it is not a
box in the sense of `BoxIntegral.Box`.
We introduce the following definitions.
* `BoxIntegral.Box.splitLower I i a` and `BoxIntegral.Box.splitUpper I i a` are these boxes (as
`WithBot (BoxIntegral.Box ι)`);
* `BoxIntegral.Prepartition.split I i a` is the partition of `I` made of these two boxes (or of one
box `I` if one of these boxes is empty);
* `BoxIntegral.Prepartition.splitMany I s`, where `s : Finset (ι × ℝ)` is a finite set of
hyperplanes `{x : ι → ℝ | x i = a}` encoded as pairs `(i, a)`, is the partition of `I` made by
cutting it along all the hyperplanes in `s`.
## Main results
The main result `BoxIntegral.Prepartition.exists_iUnion_eq_diff` says that any prepartition `π` of
`I` admits a prepartition `π'` of `I` that covers exactly `I \ π.iUnion`. One of these prepartitions
is available as `BoxIntegral.Prepartition.compl`.
## Tags
rectangular box, partition, hyperplane
-/
noncomputable section
open Function Set Filter
namespace BoxIntegral
variable {ι M : Type*} {n : ℕ}
namespace Box
variable {I : Box ι} {i : ι} {x : ℝ} {y : ι → ℝ}
open scoped Classical in
/-- Given a box `I` and `x ∈ (I.lower i, I.upper i)`, the hyperplane `{y : ι → ℝ | y i = x}` splits
`I` into two boxes. `BoxIntegral.Box.splitLower I i x` is the box `I ∩ {y | y i ≤ x}`
(if it is nonempty). As usual, we represent a box that may be empty as
`WithBot (BoxIntegral.Box ι)`. -/
def splitLower (I : Box ι) (i : ι) (x : ℝ) : WithBot (Box ι) :=
mk' I.lower (update I.upper i (min x (I.upper i)))
@[simp]
theorem coe_splitLower : (splitLower I i x : Set (ι → ℝ)) = ↑I ∩ { y | y i ≤ x } := by
rw [splitLower, coe_mk']
ext y
simp only [mem_univ_pi, mem_Ioc, mem_inter_iff, mem_coe, mem_setOf_eq, forall_and, ← Pi.le_def,
le_update_iff, le_min_iff, and_assoc, and_forall_ne (p := fun j => y j ≤ upper I j) i, mem_def]
rw [and_comm (a := y i ≤ x)]
theorem splitLower_le : I.splitLower i x ≤ I :=
withBotCoe_subset_iff.1 <| by simp
@[simp]
theorem splitLower_eq_bot {i x} : I.splitLower i x = ⊥ ↔ x ≤ I.lower i := by
classical
rw [splitLower, mk'_eq_bot, exists_update_iff I.upper fun j y => y ≤ I.lower j]
simp [(I.lower_lt_upper _).not_le]
@[simp]
theorem splitLower_eq_self : I.splitLower i x = I ↔ I.upper i ≤ x := by
simp [splitLower, update_eq_iff]
theorem splitLower_def [DecidableEq ι] {i x} (h : x ∈ Ioo (I.lower i) (I.upper i))
(h' : ∀ j, I.lower j < update I.upper i x j :=
(forall_update_iff I.upper fun j y => I.lower j < y).2
⟨h.1, fun _ _ => I.lower_lt_upper _⟩) :
I.splitLower i x = (⟨I.lower, update I.upper i x, h'⟩ : Box ι) := by
simp +unfoldPartialApp only [splitLower, mk'_eq_coe, min_eq_left h.2.le,
update, and_self]
open scoped Classical in
/-- Given a box `I` and `x ∈ (I.lower i, I.upper i)`, the hyperplane `{y : ι → ℝ | y i = x}` splits
`I` into two boxes. `BoxIntegral.Box.splitUpper I i x` is the box `I ∩ {y | x < y i}`
(if it is nonempty). As usual, we represent a box that may be empty as
`WithBot (BoxIntegral.Box ι)`. -/
def splitUpper (I : Box ι) (i : ι) (x : ℝ) : WithBot (Box ι) :=
mk' (update I.lower i (max x (I.lower i))) I.upper
@[simp]
theorem coe_splitUpper : (splitUpper I i x : Set (ι → ℝ)) = ↑I ∩ { y | x < y i } := by
classical
rw [splitUpper, coe_mk']
ext y
simp only [mem_univ_pi, mem_Ioc, mem_inter_iff, mem_coe, mem_setOf_eq, forall_and,
forall_update_iff I.lower fun j z => z < y j, max_lt_iff, and_assoc (a := x < y i),
and_forall_ne (p := fun j => lower I j < y j) i, mem_def]
exact and_comm
theorem splitUpper_le : I.splitUpper i x ≤ I :=
withBotCoe_subset_iff.1 <| by simp
@[simp]
theorem splitUpper_eq_bot {i x} : I.splitUpper i x = ⊥ ↔ I.upper i ≤ x := by
classical
rw [splitUpper, mk'_eq_bot, exists_update_iff I.lower fun j y => I.upper j ≤ y]
simp [(I.lower_lt_upper _).not_le]
@[simp]
| Mathlib/Analysis/BoxIntegral/Partition/Split.lean | 115 | 116 | theorem splitUpper_eq_self : I.splitUpper i x = I ↔ x ≤ I.lower i := by | simp [splitUpper, update_eq_iff] |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Kim Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.Algebra.MonoidAlgebra.Defs
import Mathlib.Algebra.Order.Monoid.Unbundled.WithTop
import Mathlib.Algebra.Ring.Action.Rat
import Mathlib.Data.Finset.Sort
import Mathlib.Tactic.FastInstance
/-!
# Theory of univariate polynomials
This file defines `Polynomial R`, the type of univariate polynomials over the semiring `R`, builds
a semiring structure on it, and gives basic definitions that are expanded in other files in this
directory.
## Main definitions
* `monomial n a` is the polynomial `a X^n`. Note that `monomial n` is defined as an `R`-linear map.
* `C a` is the constant polynomial `a`. Note that `C` is defined as a ring homomorphism.
* `X` is the polynomial `X`, i.e., `monomial 1 1`.
* `p.sum f` is `∑ n ∈ p.support, f n (p.coeff n)`, i.e., one sums the values of functions applied
to coefficients of the polynomial `p`.
* `p.erase n` is the polynomial `p` in which one removes the `c X^n` term.
There are often two natural variants of lemmas involving sums, depending on whether one acts on the
polynomials, or on the function. The naming convention is that one adds `index` when acting on
the polynomials. For instance,
* `sum_add_index` states that `(p + q).sum f = p.sum f + q.sum f`;
* `sum_add` states that `p.sum (fun n x ↦ f n x + g n x) = p.sum f + p.sum g`.
* Notation to refer to `Polynomial R`, as `R[X]` or `R[t]`.
## Implementation
Polynomials are defined using `R[ℕ]`, where `R` is a semiring.
The variable `X` commutes with every polynomial `p`: lemma `X_mul` proves the identity
`X * p = p * X`. The relationship to `R[ℕ]` is through a structure
to make polynomials irreducible from the point of view of the kernel. Most operations
are irreducible since Lean can not compute anyway with `AddMonoidAlgebra`. There are two
exceptions that we make semireducible:
* The zero polynomial, so that its coefficients are definitionally equal to `0`.
* The scalar action, to permit typeclass search to unfold it to resolve potential instance
diamonds.
The raw implementation of the equivalence between `R[X]` and `R[ℕ]` is
done through `ofFinsupp` and `toFinsupp` (or, equivalently, `rcases p` when `p` is a polynomial
gives an element `q` of `R[ℕ]`, and conversely `⟨q⟩` gives back `p`). The
equivalence is also registered as a ring equiv in `Polynomial.toFinsuppIso`. These should
in general not be used once the basic API for polynomials is constructed.
-/
noncomputable section
/-- `Polynomial R` is the type of univariate polynomials over `R`,
denoted as `R[X]` within the `Polynomial` namespace.
Polynomials should be seen as (semi-)rings with the additional constructor `X`.
The embedding from `R` is called `C`. -/
structure Polynomial (R : Type*) [Semiring R] where ofFinsupp ::
toFinsupp : AddMonoidAlgebra R ℕ
@[inherit_doc] scoped[Polynomial] notation:9000 R "[X]" => Polynomial R
open AddMonoidAlgebra Finset
open Finsupp hiding single
open Function hiding Commute
namespace Polynomial
universe u
variable {R : Type u} {a b : R} {m n : ℕ}
section Semiring
variable [Semiring R] {p q : R[X]}
theorem forall_iff_forall_finsupp (P : R[X] → Prop) :
(∀ p, P p) ↔ ∀ q : R[ℕ], P ⟨q⟩ :=
⟨fun h q => h ⟨q⟩, fun h ⟨p⟩ => h p⟩
theorem exists_iff_exists_finsupp (P : R[X] → Prop) :
(∃ p, P p) ↔ ∃ q : R[ℕ], P ⟨q⟩ :=
⟨fun ⟨⟨p⟩, hp⟩ => ⟨p, hp⟩, fun ⟨q, hq⟩ => ⟨⟨q⟩, hq⟩⟩
@[simp]
theorem eta (f : R[X]) : Polynomial.ofFinsupp f.toFinsupp = f := by cases f; rfl
/-! ### Conversions to and from `AddMonoidAlgebra`
Since `R[X]` is not defeq to `R[ℕ]`, but instead is a structure wrapping
it, we have to copy across all the arithmetic operators manually, along with the lemmas about how
they unfold around `Polynomial.ofFinsupp` and `Polynomial.toFinsupp`.
-/
section AddMonoidAlgebra
private irreducible_def add : R[X] → R[X] → R[X]
| ⟨a⟩, ⟨b⟩ => ⟨a + b⟩
private irreducible_def neg {R : Type u} [Ring R] : R[X] → R[X]
| ⟨a⟩ => ⟨-a⟩
private irreducible_def mul : R[X] → R[X] → R[X]
| ⟨a⟩, ⟨b⟩ => ⟨a * b⟩
instance zero : Zero R[X] :=
⟨⟨0⟩⟩
instance one : One R[X] :=
⟨⟨1⟩⟩
instance add' : Add R[X] :=
⟨add⟩
instance neg' {R : Type u} [Ring R] : Neg R[X] :=
⟨neg⟩
instance sub {R : Type u} [Ring R] : Sub R[X] :=
⟨fun a b => a + -b⟩
instance mul' : Mul R[X] :=
⟨mul⟩
-- If the private definitions are accidentally exposed, simplify them away.
@[simp] theorem add_eq_add : add p q = p + q := rfl
@[simp] theorem mul_eq_mul : mul p q = p * q := rfl
instance instNSMul : SMul ℕ R[X] where
smul r p := ⟨r • p.toFinsupp⟩
instance smulZeroClass {S : Type*} [SMulZeroClass S R] : SMulZeroClass S R[X] where
smul r p := ⟨r • p.toFinsupp⟩
smul_zero a := congr_arg ofFinsupp (smul_zero a)
instance {S : Type*} [Zero S] [SMulZeroClass S R] [NoZeroSMulDivisors S R] :
NoZeroSMulDivisors S R[X] where
eq_zero_or_eq_zero_of_smul_eq_zero eq :=
(eq_zero_or_eq_zero_of_smul_eq_zero <| congr_arg toFinsupp eq).imp id (congr_arg ofFinsupp)
-- to avoid a bug in the `ring` tactic
instance (priority := 1) pow : Pow R[X] ℕ where pow p n := npowRec n p
@[simp]
theorem ofFinsupp_zero : (⟨0⟩ : R[X]) = 0 :=
rfl
@[simp]
theorem ofFinsupp_one : (⟨1⟩ : R[X]) = 1 :=
rfl
@[simp]
theorem ofFinsupp_add {a b} : (⟨a + b⟩ : R[X]) = ⟨a⟩ + ⟨b⟩ :=
show _ = add _ _ by rw [add_def]
@[simp]
theorem ofFinsupp_neg {R : Type u} [Ring R] {a} : (⟨-a⟩ : R[X]) = -⟨a⟩ :=
show _ = neg _ by rw [neg_def]
@[simp]
theorem ofFinsupp_sub {R : Type u} [Ring R] {a b} : (⟨a - b⟩ : R[X]) = ⟨a⟩ - ⟨b⟩ := by
rw [sub_eq_add_neg, ofFinsupp_add, ofFinsupp_neg]
rfl
@[simp]
theorem ofFinsupp_mul (a b) : (⟨a * b⟩ : R[X]) = ⟨a⟩ * ⟨b⟩ :=
show _ = mul _ _ by rw [mul_def]
@[simp]
theorem ofFinsupp_nsmul (a : ℕ) (b) :
(⟨a • b⟩ : R[X]) = (a • ⟨b⟩ : R[X]) :=
rfl
@[simp]
theorem ofFinsupp_smul {S : Type*} [SMulZeroClass S R] (a : S) (b) :
(⟨a • b⟩ : R[X]) = (a • ⟨b⟩ : R[X]) :=
rfl
@[simp]
theorem ofFinsupp_pow (a) (n : ℕ) : (⟨a ^ n⟩ : R[X]) = ⟨a⟩ ^ n := by
change _ = npowRec n _
induction n with
| zero => simp [npowRec]
| succ n n_ih => simp [npowRec, n_ih, pow_succ]
@[simp]
theorem toFinsupp_zero : (0 : R[X]).toFinsupp = 0 :=
rfl
@[simp]
theorem toFinsupp_one : (1 : R[X]).toFinsupp = 1 :=
rfl
@[simp]
theorem toFinsupp_add (a b : R[X]) : (a + b).toFinsupp = a.toFinsupp + b.toFinsupp := by
cases a
cases b
rw [← ofFinsupp_add]
@[simp]
theorem toFinsupp_neg {R : Type u} [Ring R] (a : R[X]) : (-a).toFinsupp = -a.toFinsupp := by
cases a
rw [← ofFinsupp_neg]
@[simp]
theorem toFinsupp_sub {R : Type u} [Ring R] (a b : R[X]) :
(a - b).toFinsupp = a.toFinsupp - b.toFinsupp := by
rw [sub_eq_add_neg, ← toFinsupp_neg, ← toFinsupp_add]
rfl
@[simp]
theorem toFinsupp_mul (a b : R[X]) : (a * b).toFinsupp = a.toFinsupp * b.toFinsupp := by
cases a
cases b
rw [← ofFinsupp_mul]
@[simp]
theorem toFinsupp_nsmul (a : ℕ) (b : R[X]) :
(a • b).toFinsupp = a • b.toFinsupp :=
rfl
@[simp]
theorem toFinsupp_smul {S : Type*} [SMulZeroClass S R] (a : S) (b : R[X]) :
(a • b).toFinsupp = a • b.toFinsupp :=
rfl
@[simp]
theorem toFinsupp_pow (a : R[X]) (n : ℕ) : (a ^ n).toFinsupp = a.toFinsupp ^ n := by
cases a
rw [← ofFinsupp_pow]
theorem _root_.IsSMulRegular.polynomial {S : Type*} [SMulZeroClass S R] {a : S}
(ha : IsSMulRegular R a) : IsSMulRegular R[X] a
| ⟨_x⟩, ⟨_y⟩, h => congr_arg _ <| ha.finsupp (Polynomial.ofFinsupp.inj h)
theorem toFinsupp_injective : Function.Injective (toFinsupp : R[X] → AddMonoidAlgebra _ _) :=
fun ⟨_x⟩ ⟨_y⟩ => congr_arg _
@[simp]
theorem toFinsupp_inj {a b : R[X]} : a.toFinsupp = b.toFinsupp ↔ a = b :=
toFinsupp_injective.eq_iff
@[simp]
theorem toFinsupp_eq_zero {a : R[X]} : a.toFinsupp = 0 ↔ a = 0 := by
rw [← toFinsupp_zero, toFinsupp_inj]
@[simp]
theorem toFinsupp_eq_one {a : R[X]} : a.toFinsupp = 1 ↔ a = 1 := by
rw [← toFinsupp_one, toFinsupp_inj]
/-- A more convenient spelling of `Polynomial.ofFinsupp.injEq` in terms of `Iff`. -/
theorem ofFinsupp_inj {a b} : (⟨a⟩ : R[X]) = ⟨b⟩ ↔ a = b :=
iff_of_eq (ofFinsupp.injEq _ _)
@[simp]
theorem ofFinsupp_eq_zero {a} : (⟨a⟩ : R[X]) = 0 ↔ a = 0 := by
rw [← ofFinsupp_zero, ofFinsupp_inj]
@[simp]
theorem ofFinsupp_eq_one {a} : (⟨a⟩ : R[X]) = 1 ↔ a = 1 := by rw [← ofFinsupp_one, ofFinsupp_inj]
instance inhabited : Inhabited R[X] :=
⟨0⟩
instance instNatCast : NatCast R[X] where natCast n := ofFinsupp n
@[simp]
theorem ofFinsupp_natCast (n : ℕ) : (⟨n⟩ : R[X]) = n := rfl
@[simp]
theorem toFinsupp_natCast (n : ℕ) : (n : R[X]).toFinsupp = n := rfl
@[simp]
theorem ofFinsupp_ofNat (n : ℕ) [n.AtLeastTwo] : (⟨ofNat(n)⟩ : R[X]) = ofNat(n) := rfl
@[simp]
theorem toFinsupp_ofNat (n : ℕ) [n.AtLeastTwo] : (ofNat(n) : R[X]).toFinsupp = ofNat(n) := rfl
instance semiring : Semiring R[X] :=
fast_instance% Function.Injective.semiring toFinsupp toFinsupp_injective toFinsupp_zero
toFinsupp_one toFinsupp_add toFinsupp_mul (fun _ _ => toFinsupp_nsmul _ _) toFinsupp_pow
fun _ => rfl
instance distribSMul {S} [DistribSMul S R] : DistribSMul S R[X] :=
fast_instance% Function.Injective.distribSMul ⟨⟨toFinsupp, toFinsupp_zero⟩, toFinsupp_add⟩
toFinsupp_injective toFinsupp_smul
instance distribMulAction {S} [Monoid S] [DistribMulAction S R] : DistribMulAction S R[X] :=
fast_instance% Function.Injective.distribMulAction
⟨⟨toFinsupp, toFinsupp_zero (R := R)⟩, toFinsupp_add⟩ toFinsupp_injective toFinsupp_smul
instance faithfulSMul {S} [SMulZeroClass S R] [FaithfulSMul S R] : FaithfulSMul S R[X] where
eq_of_smul_eq_smul {_s₁ _s₂} h :=
eq_of_smul_eq_smul fun a : ℕ →₀ R => congr_arg toFinsupp (h ⟨a⟩)
instance module {S} [Semiring S] [Module S R] : Module S R[X] :=
fast_instance% Function.Injective.module _ ⟨⟨toFinsupp, toFinsupp_zero⟩, toFinsupp_add⟩
toFinsupp_injective toFinsupp_smul
instance smulCommClass {S₁ S₂} [SMulZeroClass S₁ R] [SMulZeroClass S₂ R] [SMulCommClass S₁ S₂ R] :
SMulCommClass S₁ S₂ R[X] :=
⟨by
rintro m n ⟨f⟩
simp_rw [← ofFinsupp_smul, smul_comm m n f]⟩
instance isScalarTower {S₁ S₂} [SMul S₁ S₂] [SMulZeroClass S₁ R] [SMulZeroClass S₂ R]
[IsScalarTower S₁ S₂ R] : IsScalarTower S₁ S₂ R[X] :=
⟨by
rintro _ _ ⟨⟩
simp_rw [← ofFinsupp_smul, smul_assoc]⟩
instance isScalarTower_right {α K : Type*} [Semiring K] [DistribSMul α K] [IsScalarTower α K K] :
IsScalarTower α K[X] K[X] :=
⟨by
rintro _ ⟨⟩ ⟨⟩
simp_rw [smul_eq_mul, ← ofFinsupp_smul, ← ofFinsupp_mul, ← ofFinsupp_smul, smul_mul_assoc]⟩
instance isCentralScalar {S} [SMulZeroClass S R] [SMulZeroClass Sᵐᵒᵖ R] [IsCentralScalar S R] :
IsCentralScalar S R[X] :=
⟨by
rintro _ ⟨⟩
simp_rw [← ofFinsupp_smul, op_smul_eq_smul]⟩
instance unique [Subsingleton R] : Unique R[X] :=
{ Polynomial.inhabited with
uniq := by
rintro ⟨x⟩
apply congr_arg ofFinsupp
simp [eq_iff_true_of_subsingleton] }
variable (R)
/-- Ring isomorphism between `R[X]` and `R[ℕ]`. This is just an
implementation detail, but it can be useful to transfer results from `Finsupp` to polynomials. -/
@[simps apply symm_apply]
def toFinsuppIso : R[X] ≃+* R[ℕ] where
toFun := toFinsupp
invFun := ofFinsupp
left_inv := fun ⟨_p⟩ => rfl
right_inv _p := rfl
map_mul' := toFinsupp_mul
map_add' := toFinsupp_add
instance [DecidableEq R] : DecidableEq R[X] :=
@Equiv.decidableEq R[X] _ (toFinsuppIso R).toEquiv (Finsupp.instDecidableEq)
/-- Linear isomorphism between `R[X]` and `R[ℕ]`. This is just an
implementation detail, but it can be useful to transfer results from `Finsupp` to polynomials. -/
@[simps!]
def toFinsuppIsoLinear : R[X] ≃ₗ[R] R[ℕ] where
__ := toFinsuppIso R
map_smul' _ _ := rfl
end AddMonoidAlgebra
theorem ofFinsupp_sum {ι : Type*} (s : Finset ι) (f : ι → R[ℕ]) :
(⟨∑ i ∈ s, f i⟩ : R[X]) = ∑ i ∈ s, ⟨f i⟩ :=
map_sum (toFinsuppIso R).symm f s
theorem toFinsupp_sum {ι : Type*} (s : Finset ι) (f : ι → R[X]) :
(∑ i ∈ s, f i : R[X]).toFinsupp = ∑ i ∈ s, (f i).toFinsupp :=
map_sum (toFinsuppIso R) f s
/-- The set of all `n` such that `X^n` has a non-zero coefficient. -/
def support : R[X] → Finset ℕ
| ⟨p⟩ => p.support
@[simp]
theorem support_ofFinsupp (p) : support (⟨p⟩ : R[X]) = p.support := by rw [support]
theorem support_toFinsupp (p : R[X]) : p.toFinsupp.support = p.support := by rw [support]
@[simp]
theorem support_zero : (0 : R[X]).support = ∅ :=
rfl
@[simp]
theorem support_eq_empty : p.support = ∅ ↔ p = 0 := by
rcases p with ⟨⟩
simp [support]
@[simp] lemma support_nonempty : p.support.Nonempty ↔ p ≠ 0 :=
Finset.nonempty_iff_ne_empty.trans support_eq_empty.not
theorem card_support_eq_zero : #p.support = 0 ↔ p = 0 := by simp
/-- `monomial s a` is the monomial `a * X^s` -/
def monomial (n : ℕ) : R →ₗ[R] R[X] where
toFun t := ⟨Finsupp.single n t⟩
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/10745): was `simp`.
map_add' x y := by simp; rw [ofFinsupp_add]
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/10745): was `simp [← ofFinsupp_smul]`.
map_smul' r x := by simp; rw [← ofFinsupp_smul, smul_single']
@[simp]
theorem toFinsupp_monomial (n : ℕ) (r : R) : (monomial n r).toFinsupp = Finsupp.single n r := by
simp [monomial]
@[simp]
theorem ofFinsupp_single (n : ℕ) (r : R) : (⟨Finsupp.single n r⟩ : R[X]) = monomial n r := by
simp [monomial]
@[simp]
theorem monomial_zero_right (n : ℕ) : monomial n (0 : R) = 0 :=
(monomial n).map_zero
-- This is not a `simp` lemma as `monomial_zero_left` is more general.
theorem monomial_zero_one : monomial 0 (1 : R) = 1 :=
rfl
-- TODO: can't we just delete this one?
theorem monomial_add (n : ℕ) (r s : R) : monomial n (r + s) = monomial n r + monomial n s :=
(monomial n).map_add _ _
theorem monomial_mul_monomial (n m : ℕ) (r s : R) :
monomial n r * monomial m s = monomial (n + m) (r * s) :=
toFinsupp_injective <| by
simp only [toFinsupp_monomial, toFinsupp_mul, AddMonoidAlgebra.single_mul_single]
@[simp]
theorem monomial_pow (n : ℕ) (r : R) (k : ℕ) : monomial n r ^ k = monomial (n * k) (r ^ k) := by
induction k with
| zero => simp [pow_zero, monomial_zero_one]
| succ k ih => simp [pow_succ, ih, monomial_mul_monomial, mul_add, add_comm]
theorem smul_monomial {S} [SMulZeroClass S R] (a : S) (n : ℕ) (b : R) :
a • monomial n b = monomial n (a • b) :=
toFinsupp_injective <| AddMonoidAlgebra.smul_single _ _ _
theorem monomial_injective (n : ℕ) : Function.Injective (monomial n : R → R[X]) :=
(toFinsuppIso R).symm.injective.comp (single_injective n)
@[simp]
theorem monomial_eq_zero_iff (t : R) (n : ℕ) : monomial n t = 0 ↔ t = 0 :=
LinearMap.map_eq_zero_iff _ (Polynomial.monomial_injective n)
theorem monomial_eq_monomial_iff {m n : ℕ} {a b : R} :
monomial m a = monomial n b ↔ m = n ∧ a = b ∨ a = 0 ∧ b = 0 := by
rw [← toFinsupp_inj, toFinsupp_monomial, toFinsupp_monomial, Finsupp.single_eq_single_iff]
theorem support_add : (p + q).support ⊆ p.support ∪ q.support := by
simpa [support] using Finsupp.support_add
/-- `C a` is the constant polynomial `a`.
`C` is provided as a ring homomorphism.
-/
def C : R →+* R[X] :=
{ monomial 0 with
map_one' := by simp [monomial_zero_one]
map_mul' := by simp [monomial_mul_monomial]
map_zero' := by simp }
@[simp]
theorem monomial_zero_left (a : R) : monomial 0 a = C a :=
rfl
@[simp]
theorem toFinsupp_C (a : R) : (C a).toFinsupp = single 0 a :=
rfl
theorem C_0 : C (0 : R) = 0 := by simp
theorem C_1 : C (1 : R) = 1 :=
rfl
theorem C_mul : C (a * b) = C a * C b :=
C.map_mul a b
theorem C_add : C (a + b) = C a + C b :=
C.map_add a b
@[simp]
theorem smul_C {S} [SMulZeroClass S R] (s : S) (r : R) : s • C r = C (s • r) :=
smul_monomial _ _ r
theorem C_pow : C (a ^ n) = C a ^ n :=
C.map_pow a n
theorem C_eq_natCast (n : ℕ) : C (n : R) = (n : R[X]) :=
map_natCast C n
@[simp]
theorem C_mul_monomial : C a * monomial n b = monomial n (a * b) := by
simp only [← monomial_zero_left, monomial_mul_monomial, zero_add]
@[simp]
theorem monomial_mul_C : monomial n a * C b = monomial n (a * b) := by
simp only [← monomial_zero_left, monomial_mul_monomial, add_zero]
/-- `X` is the polynomial variable (aka indeterminate). -/
def X : R[X] :=
monomial 1 1
theorem monomial_one_one_eq_X : monomial 1 (1 : R) = X :=
rfl
theorem monomial_one_right_eq_X_pow (n : ℕ) : monomial n (1 : R) = X ^ n := by
induction n with
| zero => simp [monomial_zero_one]
| succ n ih => rw [pow_succ, ← ih, ← monomial_one_one_eq_X, monomial_mul_monomial, mul_one]
@[simp]
theorem toFinsupp_X : X.toFinsupp = Finsupp.single 1 (1 : R) :=
rfl
theorem X_ne_C [Nontrivial R] (a : R) : X ≠ C a := by
intro he
simpa using monomial_eq_monomial_iff.1 he
/-- `X` commutes with everything, even when the coefficients are noncommutative. -/
theorem X_mul : X * p = p * X := by
rcases p with ⟨⟩
simp only [X, ← ofFinsupp_single, ← ofFinsupp_mul, LinearMap.coe_mk, ofFinsupp.injEq]
ext
simp [AddMonoidAlgebra.mul_apply, AddMonoidAlgebra.sum_single_index, add_comm]
theorem X_pow_mul {n : ℕ} : X ^ n * p = p * X ^ n := by
induction n with
| zero => simp
| succ n ih =>
conv_lhs => rw [pow_succ]
rw [mul_assoc, X_mul, ← mul_assoc, ih, mul_assoc, ← pow_succ]
/-- Prefer putting constants to the left of `X`.
This lemma is the loop-avoiding `simp` version of `Polynomial.X_mul`. -/
@[simp]
theorem X_mul_C (r : R) : X * C r = C r * X :=
X_mul
/-- Prefer putting constants to the left of `X ^ n`.
This lemma is the loop-avoiding `simp` version of `X_pow_mul`. -/
@[simp]
theorem X_pow_mul_C (r : R) (n : ℕ) : X ^ n * C r = C r * X ^ n :=
X_pow_mul
theorem X_pow_mul_assoc {n : ℕ} : p * X ^ n * q = p * q * X ^ n := by
rw [mul_assoc, X_pow_mul, ← mul_assoc]
/-- Prefer putting constants to the left of `X ^ n`.
This lemma is the loop-avoiding `simp` version of `X_pow_mul_assoc`. -/
@[simp]
theorem X_pow_mul_assoc_C {n : ℕ} (r : R) : p * X ^ n * C r = p * C r * X ^ n :=
X_pow_mul_assoc
theorem commute_X (p : R[X]) : Commute X p :=
X_mul
theorem commute_X_pow (p : R[X]) (n : ℕ) : Commute (X ^ n) p :=
X_pow_mul
@[simp]
theorem monomial_mul_X (n : ℕ) (r : R) : monomial n r * X = monomial (n + 1) r := by
rw [X, monomial_mul_monomial, mul_one]
@[simp]
theorem monomial_mul_X_pow (n : ℕ) (r : R) (k : ℕ) :
monomial n r * X ^ k = monomial (n + k) r := by
induction k with
| zero => simp
| succ k ih => simp [ih, pow_succ, ← mul_assoc, add_assoc]
@[simp]
theorem X_mul_monomial (n : ℕ) (r : R) : X * monomial n r = monomial (n + 1) r := by
rw [X_mul, monomial_mul_X]
@[simp]
theorem X_pow_mul_monomial (k n : ℕ) (r : R) : X ^ k * monomial n r = monomial (n + k) r := by
rw [X_pow_mul, monomial_mul_X_pow]
/-- `coeff p n` (often denoted `p.coeff n`) is the coefficient of `X^n` in `p`. -/
def coeff : R[X] → ℕ → R
| ⟨p⟩ => p
@[simp]
theorem coeff_ofFinsupp (p) : coeff (⟨p⟩ : R[X]) = p := by rw [coeff]
theorem coeff_injective : Injective (coeff : R[X] → ℕ → R) := by
rintro ⟨p⟩ ⟨q⟩
simp only [coeff, DFunLike.coe_fn_eq, imp_self, ofFinsupp.injEq]
@[simp]
theorem coeff_inj : p.coeff = q.coeff ↔ p = q :=
coeff_injective.eq_iff
theorem toFinsupp_apply (f : R[X]) (i) : f.toFinsupp i = f.coeff i := by cases f; rfl
theorem coeff_monomial : coeff (monomial n a) m = if n = m then a else 0 := by
simp [coeff, Finsupp.single_apply]
@[simp]
theorem coeff_monomial_same (n : ℕ) (c : R) : (monomial n c).coeff n = c :=
Finsupp.single_eq_same
theorem coeff_monomial_of_ne {m n : ℕ} (c : R) (h : n ≠ m) : (monomial n c).coeff m = 0 :=
Finsupp.single_eq_of_ne h
@[simp]
theorem coeff_zero (n : ℕ) : coeff (0 : R[X]) n = 0 :=
rfl
theorem coeff_one {n : ℕ} : coeff (1 : R[X]) n = if n = 0 then 1 else 0 := by
simp_rw [eq_comm (a := n) (b := 0)]
exact coeff_monomial
@[simp]
theorem coeff_one_zero : coeff (1 : R[X]) 0 = 1 := by
simp [coeff_one]
@[simp]
theorem coeff_X_one : coeff (X : R[X]) 1 = 1 :=
coeff_monomial
@[simp]
theorem coeff_X_zero : coeff (X : R[X]) 0 = 0 :=
coeff_monomial
@[simp]
theorem coeff_monomial_succ : coeff (monomial (n + 1) a) 0 = 0 := by simp [coeff_monomial]
theorem coeff_X : coeff (X : R[X]) n = if 1 = n then 1 else 0 :=
coeff_monomial
theorem coeff_X_of_ne_one {n : ℕ} (hn : n ≠ 1) : coeff (X : R[X]) n = 0 := by
rw [coeff_X, if_neg hn.symm]
@[simp]
theorem mem_support_iff : n ∈ p.support ↔ p.coeff n ≠ 0 := by
rcases p with ⟨⟩
simp
theorem not_mem_support_iff : n ∉ p.support ↔ p.coeff n = 0 := by simp
theorem coeff_C : coeff (C a) n = ite (n = 0) a 0 := by
convert coeff_monomial (a := a) (m := n) (n := 0) using 2
simp [eq_comm]
@[simp]
theorem coeff_C_zero : coeff (C a) 0 = a :=
coeff_monomial
theorem coeff_C_ne_zero (h : n ≠ 0) : (C a).coeff n = 0 := by rw [coeff_C, if_neg h]
@[simp]
lemma coeff_C_succ {r : R} {n : ℕ} : coeff (C r) (n + 1) = 0 := by simp [coeff_C]
@[simp]
theorem coeff_natCast_ite : (Nat.cast m : R[X]).coeff n = ite (n = 0) m 0 := by
simp only [← C_eq_natCast, coeff_C, Nat.cast_ite, Nat.cast_zero]
@[simp]
theorem coeff_ofNat_zero (a : ℕ) [a.AtLeastTwo] :
coeff (ofNat(a) : R[X]) 0 = ofNat(a) :=
coeff_monomial
@[simp]
theorem coeff_ofNat_succ (a n : ℕ) [h : a.AtLeastTwo] :
coeff (ofNat(a) : R[X]) (n + 1) = 0 := by
rw [← Nat.cast_ofNat]
simp [-Nat.cast_ofNat]
theorem C_mul_X_pow_eq_monomial : ∀ {n : ℕ}, C a * X ^ n = monomial n a
| 0 => mul_one _
| n + 1 => by
rw [pow_succ, ← mul_assoc, C_mul_X_pow_eq_monomial, X, monomial_mul_monomial, mul_one]
@[simp high]
theorem toFinsupp_C_mul_X_pow (a : R) (n : ℕ) :
Polynomial.toFinsupp (C a * X ^ n) = Finsupp.single n a := by
rw [C_mul_X_pow_eq_monomial, toFinsupp_monomial]
theorem C_mul_X_eq_monomial : C a * X = monomial 1 a := by rw [← C_mul_X_pow_eq_monomial, pow_one]
@[simp high]
theorem toFinsupp_C_mul_X (a : R) : Polynomial.toFinsupp (C a * X) = Finsupp.single 1 a := by
rw [C_mul_X_eq_monomial, toFinsupp_monomial]
theorem C_injective : Injective (C : R → R[X]) :=
monomial_injective 0
@[simp]
theorem C_inj : C a = C b ↔ a = b :=
C_injective.eq_iff
@[simp]
theorem C_eq_zero : C a = 0 ↔ a = 0 :=
C_injective.eq_iff' (map_zero C)
theorem C_ne_zero : C a ≠ 0 ↔ a ≠ 0 :=
C_eq_zero.not
theorem subsingleton_iff_subsingleton : Subsingleton R[X] ↔ Subsingleton R :=
⟨@Injective.subsingleton _ _ _ C_injective, by
intro
infer_instance⟩
theorem Nontrivial.of_polynomial_ne (h : p ≠ q) : Nontrivial R :=
(subsingleton_or_nontrivial R).resolve_left fun _hI => h <| Subsingleton.elim _ _
theorem forall_eq_iff_forall_eq : (∀ f g : R[X], f = g) ↔ ∀ a b : R, a = b := by
simpa only [← subsingleton_iff] using subsingleton_iff_subsingleton
theorem ext_iff {p q : R[X]} : p = q ↔ ∀ n, coeff p n = coeff q n := by
rcases p with ⟨f : ℕ →₀ R⟩
rcases q with ⟨g : ℕ →₀ R⟩
simpa [coeff] using DFunLike.ext_iff (f := f) (g := g)
@[ext]
theorem ext {p q : R[X]} : (∀ n, coeff p n = coeff q n) → p = q :=
ext_iff.2
/-- Monomials generate the additive monoid of polynomials. -/
theorem addSubmonoid_closure_setOf_eq_monomial :
AddSubmonoid.closure { p : R[X] | ∃ n a, p = monomial n a } = ⊤ := by
apply top_unique
rw [← AddSubmonoid.map_equiv_top (toFinsuppIso R).symm.toAddEquiv, ←
Finsupp.add_closure_setOf_eq_single, AddMonoidHom.map_mclosure]
refine AddSubmonoid.closure_mono (Set.image_subset_iff.2 ?_)
rintro _ ⟨n, a, rfl⟩
exact ⟨n, a, Polynomial.ofFinsupp_single _ _⟩
theorem addHom_ext {M : Type*} [AddZeroClass M] {f g : R[X] →+ M}
(h : ∀ n a, f (monomial n a) = g (monomial n a)) : f = g :=
AddMonoidHom.eq_of_eqOn_denseM addSubmonoid_closure_setOf_eq_monomial <| by
rintro p ⟨n, a, rfl⟩
exact h n a
@[ext high]
theorem addHom_ext' {M : Type*} [AddZeroClass M] {f g : R[X] →+ M}
(h : ∀ n, f.comp (monomial n).toAddMonoidHom = g.comp (monomial n).toAddMonoidHom) : f = g :=
addHom_ext fun n => DFunLike.congr_fun (h n)
@[ext high]
theorem lhom_ext' {M : Type*} [AddCommMonoid M] [Module R M] {f g : R[X] →ₗ[R] M}
(h : ∀ n, f.comp (monomial n) = g.comp (monomial n)) : f = g :=
LinearMap.toAddMonoidHom_injective <| addHom_ext fun n => LinearMap.congr_fun (h n)
-- this has the same content as the subsingleton
theorem eq_zero_of_eq_zero (h : (0 : R) = (1 : R)) (p : R[X]) : p = 0 := by
rw [← one_smul R p, ← h, zero_smul]
section Fewnomials
theorem support_monomial (n) {a : R} (H : a ≠ 0) : (monomial n a).support = singleton n := by
rw [← ofFinsupp_single, support]; exact Finsupp.support_single_ne_zero _ H
theorem support_monomial' (n) (a : R) : (monomial n a).support ⊆ singleton n := by
rw [← ofFinsupp_single, support]
exact Finsupp.support_single_subset
theorem support_C {a : R} (h : a ≠ 0) : (C a).support = singleton 0 :=
support_monomial 0 h
theorem support_C_subset (a : R) : (C a).support ⊆ singleton 0 :=
support_monomial' 0 a
theorem support_C_mul_X {c : R} (h : c ≠ 0) : Polynomial.support (C c * X) = singleton 1 := by
rw [C_mul_X_eq_monomial, support_monomial 1 h]
theorem support_C_mul_X' (c : R) : Polynomial.support (C c * X) ⊆ singleton 1 := by
simpa only [C_mul_X_eq_monomial] using support_monomial' 1 c
theorem support_C_mul_X_pow (n : ℕ) {c : R} (h : c ≠ 0) :
Polynomial.support (C c * X ^ n) = singleton n := by
rw [C_mul_X_pow_eq_monomial, support_monomial n h]
theorem support_C_mul_X_pow' (n : ℕ) (c : R) : Polynomial.support (C c * X ^ n) ⊆ singleton n := by
simpa only [C_mul_X_pow_eq_monomial] using support_monomial' n c
open Finset
theorem support_binomial' (k m : ℕ) (x y : R) :
Polynomial.support (C x * X ^ k + C y * X ^ m) ⊆ {k, m} :=
support_add.trans
(union_subset
((support_C_mul_X_pow' k x).trans (singleton_subset_iff.mpr (mem_insert_self k {m})))
((support_C_mul_X_pow' m y).trans
(singleton_subset_iff.mpr (mem_insert_of_mem (mem_singleton_self m)))))
theorem support_trinomial' (k m n : ℕ) (x y z : R) :
Polynomial.support (C x * X ^ k + C y * X ^ m + C z * X ^ n) ⊆ {k, m, n} :=
support_add.trans
(union_subset
(support_add.trans
(union_subset
((support_C_mul_X_pow' k x).trans (singleton_subset_iff.mpr (mem_insert_self k {m, n})))
((support_C_mul_X_pow' m y).trans
(singleton_subset_iff.mpr (mem_insert_of_mem (mem_insert_self m {n}))))))
((support_C_mul_X_pow' n z).trans
(singleton_subset_iff.mpr (mem_insert_of_mem (mem_insert_of_mem (mem_singleton_self n))))))
end Fewnomials
theorem X_pow_eq_monomial (n) : X ^ n = monomial n (1 : R) := by
induction n with
| zero => rw [pow_zero, monomial_zero_one]
| succ n hn => rw [pow_succ, hn, X, monomial_mul_monomial, one_mul]
@[simp high]
theorem toFinsupp_X_pow (n : ℕ) : (X ^ n).toFinsupp = Finsupp.single n (1 : R) := by
rw [X_pow_eq_monomial, toFinsupp_monomial]
theorem smul_X_eq_monomial {n} : a • X ^ n = monomial n (a : R) := by
rw [X_pow_eq_monomial, smul_monomial, smul_eq_mul, mul_one]
theorem support_X_pow (H : ¬(1 : R) = 0) (n : ℕ) : (X ^ n : R[X]).support = singleton n := by
convert support_monomial n H
exact X_pow_eq_monomial n
theorem support_X_empty (H : (1 : R) = 0) : (X : R[X]).support = ∅ := by
rw [X, H, monomial_zero_right, support_zero]
theorem support_X (H : ¬(1 : R) = 0) : (X : R[X]).support = singleton 1 := by
rw [← pow_one X, support_X_pow H 1]
theorem monomial_left_inj {a : R} (ha : a ≠ 0) {i j : ℕ} :
monomial i a = monomial j a ↔ i = j := by
simp only [← ofFinsupp_single, ofFinsupp.injEq, Finsupp.single_left_inj ha]
theorem binomial_eq_binomial {k l m n : ℕ} {u v : R} (hu : u ≠ 0) (hv : v ≠ 0) :
C u * X ^ k + C v * X ^ l = C u * X ^ m + C v * X ^ n ↔
k = m ∧ l = n ∨ u = v ∧ k = n ∧ l = m ∨ u + v = 0 ∧ k = l ∧ m = n := by
simp_rw [C_mul_X_pow_eq_monomial, ← toFinsupp_inj, toFinsupp_add, toFinsupp_monomial]
exact Finsupp.single_add_single_eq_single_add_single hu hv
theorem natCast_mul (n : ℕ) (p : R[X]) : (n : R[X]) * p = n • p :=
(nsmul_eq_mul _ _).symm
/-- Summing the values of a function applied to the coefficients of a polynomial -/
def sum {S : Type*} [AddCommMonoid S] (p : R[X]) (f : ℕ → R → S) : S :=
∑ n ∈ p.support, f n (p.coeff n)
theorem sum_def {S : Type*} [AddCommMonoid S] (p : R[X]) (f : ℕ → R → S) :
p.sum f = ∑ n ∈ p.support, f n (p.coeff n) :=
rfl
theorem sum_eq_of_subset {S : Type*} [AddCommMonoid S] {p : R[X]} (f : ℕ → R → S)
(hf : ∀ i, f i 0 = 0) {s : Finset ℕ} (hs : p.support ⊆ s) :
p.sum f = ∑ n ∈ s, f n (p.coeff n) :=
Finsupp.sum_of_support_subset _ hs f (fun i _ ↦ hf i)
/-- Expressing the product of two polynomials as a double sum. -/
theorem mul_eq_sum_sum :
p * q = ∑ i ∈ p.support, q.sum fun j a => (monomial (i + j)) (p.coeff i * a) := by
apply toFinsupp_injective
rcases p with ⟨⟩; rcases q with ⟨⟩
simp_rw [sum, coeff, toFinsupp_sum, support, toFinsupp_mul, toFinsupp_monomial,
AddMonoidAlgebra.mul_def, Finsupp.sum]
@[simp]
theorem sum_zero_index {S : Type*} [AddCommMonoid S] (f : ℕ → R → S) : (0 : R[X]).sum f = 0 := by
simp [sum]
@[simp]
theorem sum_monomial_index {S : Type*} [AddCommMonoid S] {n : ℕ} (a : R) (f : ℕ → R → S)
(hf : f n 0 = 0) : (monomial n a : R[X]).sum f = f n a :=
Finsupp.sum_single_index hf
@[simp]
theorem sum_C_index {a} {β} [AddCommMonoid β] {f : ℕ → R → β} (h : f 0 0 = 0) :
(C a).sum f = f 0 a :=
sum_monomial_index a f h
-- the assumption `hf` is only necessary when the ring is trivial
@[simp]
theorem sum_X_index {S : Type*} [AddCommMonoid S] {f : ℕ → R → S} (hf : f 1 0 = 0) :
(X : R[X]).sum f = f 1 1 :=
sum_monomial_index 1 f hf
theorem sum_add_index {S : Type*} [AddCommMonoid S] (p q : R[X]) (f : ℕ → R → S)
(hf : ∀ i, f i 0 = 0) (h_add : ∀ a b₁ b₂, f a (b₁ + b₂) = f a b₁ + f a b₂) :
(p + q).sum f = p.sum f + q.sum f := by
rw [show p + q = ⟨p.toFinsupp + q.toFinsupp⟩ from add_def p q]
exact Finsupp.sum_add_index (fun i _ ↦ hf i) (fun a _ b₁ b₂ ↦ h_add a b₁ b₂)
theorem sum_add' {S : Type*} [AddCommMonoid S] (p : R[X]) (f g : ℕ → R → S) :
p.sum (f + g) = p.sum f + p.sum g := by simp [sum_def, Finset.sum_add_distrib]
theorem sum_add {S : Type*} [AddCommMonoid S] (p : R[X]) (f g : ℕ → R → S) :
(p.sum fun n x => f n x + g n x) = p.sum f + p.sum g :=
sum_add' _ _ _
theorem sum_smul_index {S : Type*} [AddCommMonoid S] (p : R[X]) (b : R) (f : ℕ → R → S)
(hf : ∀ i, f i 0 = 0) : (b • p).sum f = p.sum fun n a => f n (b * a) :=
Finsupp.sum_smul_index hf
theorem sum_smul_index' {S T : Type*} [DistribSMul T R] [AddCommMonoid S] (p : R[X]) (b : T)
(f : ℕ → R → S) (hf : ∀ i, f i 0 = 0) : (b • p).sum f = p.sum fun n a => f n (b • a) :=
Finsupp.sum_smul_index' hf
protected theorem smul_sum {S T : Type*} [AddCommMonoid S] [DistribSMul T S] (p : R[X]) (b : T)
(f : ℕ → R → S) : b • p.sum f = p.sum fun n a => b • f n a :=
Finsupp.smul_sum
@[simp]
theorem sum_monomial_eq : ∀ p : R[X], (p.sum fun n a => monomial n a) = p
| ⟨_p⟩ => (ofFinsupp_sum _ _).symm.trans (congr_arg _ <| Finsupp.sum_single _)
theorem sum_C_mul_X_pow_eq (p : R[X]) : (p.sum fun n a => C a * X ^ n) = p := by
simp_rw [C_mul_X_pow_eq_monomial, sum_monomial_eq]
@[elab_as_elim]
protected theorem induction_on {motive : R[X] → Prop} (p : R[X]) (C : ∀ a, motive (C a))
(add : ∀ p q, motive p → motive q → motive (p + q))
(monomial : ∀ (n : ℕ) (a : R),
motive (Polynomial.C a * X ^ n) → motive (Polynomial.C a * X ^ (n + 1))) : motive p := by
have A : ∀ {n : ℕ} {a}, motive (Polynomial.C a * X ^ n) := by
intro n a
induction n with
| zero => rw [pow_zero, mul_one]; exact C a
| succ n ih => exact monomial _ _ ih
have B : ∀ s : Finset ℕ, motive (s.sum fun n : ℕ => Polynomial.C (p.coeff n) * X ^ n) := by
apply Finset.induction
· convert C 0
exact C_0.symm
· intro n s ns ih
rw [sum_insert ns]
exact add _ _ A ih
rw [← sum_C_mul_X_pow_eq p, Polynomial.sum]
exact B (support p)
/-- To prove something about polynomials,
it suffices to show the condition is closed under taking sums,
and it holds for monomials.
-/
@[elab_as_elim]
protected theorem induction_on' {motive : R[X] → Prop} (p : R[X])
(add : ∀ p q, motive p → motive q → motive (p + q))
(monomial : ∀ (n : ℕ) (a : R), motive (monomial n a)) : motive p :=
Polynomial.induction_on p (monomial 0) add fun n a _h =>
by rw [C_mul_X_pow_eq_monomial]; exact monomial _ _
/-- `erase p n` is the polynomial `p` in which the `X^n` term has been erased. -/
irreducible_def erase (n : ℕ) : R[X] → R[X]
| ⟨p⟩ => ⟨p.erase n⟩
@[simp]
theorem toFinsupp_erase (p : R[X]) (n : ℕ) : toFinsupp (p.erase n) = p.toFinsupp.erase n := by
rcases p with ⟨⟩
simp only [erase_def]
@[simp]
theorem ofFinsupp_erase (p : R[ℕ]) (n : ℕ) :
(⟨p.erase n⟩ : R[X]) = (⟨p⟩ : R[X]).erase n := by
rcases p with ⟨⟩
simp only [erase_def]
@[simp]
theorem support_erase (p : R[X]) (n : ℕ) : support (p.erase n) = (support p).erase n := by
rcases p with ⟨⟩
simp only [support, erase_def, Finsupp.support_erase]
theorem monomial_add_erase (p : R[X]) (n : ℕ) : monomial n (coeff p n) + p.erase n = p :=
toFinsupp_injective <| by
rcases p with ⟨⟩
rw [toFinsupp_add, toFinsupp_monomial, toFinsupp_erase, coeff]
exact Finsupp.single_add_erase _ _
theorem coeff_erase (p : R[X]) (n i : ℕ) :
(p.erase n).coeff i = if i = n then 0 else p.coeff i := by
rcases p with ⟨⟩
simp only [erase_def, coeff]
exact ite_congr rfl (fun _ => rfl) (fun _ => rfl)
@[simp]
theorem erase_zero (n : ℕ) : (0 : R[X]).erase n = 0 :=
toFinsupp_injective <| by simp
@[simp]
theorem erase_monomial {n : ℕ} {a : R} : erase n (monomial n a) = 0 :=
toFinsupp_injective <| by simp
@[simp]
theorem erase_same (p : R[X]) (n : ℕ) : coeff (p.erase n) n = 0 := by simp [coeff_erase]
@[simp]
theorem erase_ne (p : R[X]) (n i : ℕ) (h : i ≠ n) : coeff (p.erase n) i = coeff p i := by
simp [coeff_erase, h]
section Update
/-- Replace the coefficient of a `p : R[X]` at a given degree `n : ℕ`
by a given value `a : R`. If `a = 0`, this is equal to `p.erase n`
If `p.natDegree < n` and `a ≠ 0`, this increases the degree to `n`. -/
def update (p : R[X]) (n : ℕ) (a : R) : R[X] :=
Polynomial.ofFinsupp (p.toFinsupp.update n a)
theorem coeff_update (p : R[X]) (n : ℕ) (a : R) :
(p.update n a).coeff = Function.update p.coeff n a := by
ext
cases p
simp only [coeff, update, Function.update_apply, coe_update]
theorem coeff_update_apply (p : R[X]) (n : ℕ) (a : R) (i : ℕ) :
(p.update n a).coeff i = if i = n then a else p.coeff i := by
rw [coeff_update, Function.update_apply]
@[simp]
theorem coeff_update_same (p : R[X]) (n : ℕ) (a : R) : (p.update n a).coeff n = a := by
rw [p.coeff_update_apply, if_pos rfl]
theorem coeff_update_ne (p : R[X]) {n : ℕ} (a : R) {i : ℕ} (h : i ≠ n) :
(p.update n a).coeff i = p.coeff i := by rw [p.coeff_update_apply, if_neg h]
@[simp]
theorem update_zero_eq_erase (p : R[X]) (n : ℕ) : p.update n 0 = p.erase n := by
ext
rw [coeff_update_apply, coeff_erase]
theorem support_update (p : R[X]) (n : ℕ) (a : R) [Decidable (a = 0)] :
support (p.update n a) = if a = 0 then p.support.erase n else insert n p.support := by
classical
cases p
simp only [support, update, Finsupp.support_update]
congr
theorem support_update_zero (p : R[X]) (n : ℕ) : support (p.update n 0) = p.support.erase n := by
rw [update_zero_eq_erase, support_erase]
theorem support_update_ne_zero (p : R[X]) (n : ℕ) {a : R} (ha : a ≠ 0) :
support (p.update n a) = insert n p.support := by classical rw [support_update, if_neg ha]
end Update
/-- The finset of nonzero coefficients of a polynomial. -/
def coeffs (p : R[X]) : Finset R :=
letI := Classical.decEq R
Finset.image (fun n => p.coeff n) p.support
@[simp]
theorem coeffs_zero : coeffs (0 : R[X]) = ∅ :=
rfl
theorem mem_coeffs_iff {p : R[X]} {c : R} : c ∈ p.coeffs ↔ ∃ n ∈ p.support, c = p.coeff n := by
simp [coeffs, eq_comm, (Finset.mem_image)]
theorem coeffs_one : coeffs (1 : R[X]) ⊆ {1} := by
classical
simp_rw [coeffs, Finset.image_subset_iff]
simp_all [coeff_one]
theorem coeff_mem_coeffs (p : R[X]) (n : ℕ) (h : p.coeff n ≠ 0) : p.coeff n ∈ p.coeffs := by
classical
simp only [coeffs, exists_prop, mem_support_iff, Finset.mem_image, Ne]
exact ⟨n, h, rfl⟩
theorem coeffs_monomial (n : ℕ) {c : R} (hc : c ≠ 0) : (monomial n c).coeffs = {c} := by
rw [coeffs, support_monomial n hc]
simp
end Semiring
section CommSemiring
variable [CommSemiring R]
instance commSemiring : CommSemiring R[X] :=
fast_instance% { Function.Injective.commSemigroup toFinsupp toFinsupp_injective toFinsupp_mul with
toSemiring := Polynomial.semiring }
end CommSemiring
section Ring
variable [Ring R]
instance instZSMul : SMul ℤ R[X] where
smul r p := ⟨r • p.toFinsupp⟩
@[simp]
theorem ofFinsupp_zsmul (a : ℤ) (b) :
(⟨a • b⟩ : R[X]) = (a • ⟨b⟩ : R[X]) :=
rfl
@[simp]
theorem toFinsupp_zsmul (a : ℤ) (b : R[X]) :
(a • b).toFinsupp = a • b.toFinsupp :=
rfl
instance instIntCast : IntCast R[X] where intCast n := ofFinsupp n
@[simp]
theorem ofFinsupp_intCast (z : ℤ) : (⟨z⟩ : R[X]) = z := rfl
@[simp]
theorem toFinsupp_intCast (z : ℤ) : (z : R[X]).toFinsupp = z := rfl
instance ring : Ring R[X] :=
fast_instance% Function.Injective.ring toFinsupp toFinsupp_injective (toFinsupp_zero (R := R))
toFinsupp_one toFinsupp_add
toFinsupp_mul toFinsupp_neg toFinsupp_sub (fun _ _ => toFinsupp_nsmul _ _)
(fun _ _ => toFinsupp_zsmul _ _) toFinsupp_pow (fun _ => rfl) fun _ => rfl
@[simp]
theorem coeff_neg (p : R[X]) (n : ℕ) : coeff (-p) n = -coeff p n := by
rcases p with ⟨⟩
rw [← ofFinsupp_neg, coeff, coeff, Finsupp.neg_apply]
@[simp]
theorem coeff_sub (p q : R[X]) (n : ℕ) : coeff (p - q) n = coeff p n - coeff q n := by
rcases p with ⟨⟩
rcases q with ⟨⟩
rw [← ofFinsupp_sub, coeff, coeff, coeff, Finsupp.sub_apply]
@[simp]
theorem monomial_neg (n : ℕ) (a : R) : monomial n (-a) = -monomial n a := by
rw [eq_neg_iff_add_eq_zero, ← monomial_add, neg_add_cancel, monomial_zero_right]
theorem monomial_sub (n : ℕ) : monomial n (a - b) = monomial n a - monomial n b := by
rw [sub_eq_add_neg, monomial_add, monomial_neg, sub_eq_add_neg]
@[simp]
theorem support_neg {p : R[X]} : (-p).support = p.support := by
rcases p with ⟨⟩
rw [← ofFinsupp_neg, support, support, Finsupp.support_neg]
| Mathlib/Algebra/Polynomial/Basic.lean | 1,123 | 1,125 | theorem C_eq_intCast (n : ℤ) : C (n : R) = n := by | simp
theorem C_neg : C (-a) = -C a := |
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Julian Kuelshammer
-/
import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Algebra.Group.Pointwise.Set.Finite
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Algebra.Module.NatInt
import Mathlib.Algebra.Order.Group.Action
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Data.Int.ModEq
import Mathlib.Dynamics.PeriodicPts.Lemmas
import Mathlib.GroupTheory.Index
import Mathlib.NumberTheory.Divisors
import Mathlib.Order.Interval.Set.Infinite
/-!
# Order of an element
This file defines the order of an element of a finite group. For a finite group `G` the order of
`x ∈ G` is the minimal `n ≥ 1` such that `x ^ n = 1`.
## Main definitions
* `IsOfFinOrder` is a predicate on an element `x` of a monoid `G` saying that `x` is of finite
order.
* `IsOfFinAddOrder` is the additive analogue of `IsOfFinOrder`.
* `orderOf x` defines the order of an element `x` of a monoid `G`, by convention its value is `0`
if `x` has infinite order.
* `addOrderOf` is the additive analogue of `orderOf`.
## Tags
order of an element
-/
assert_not_exists Field
open Function Fintype Nat Pointwise Subgroup Submonoid
open scoped Finset
variable {G H A α β : Type*}
section Monoid
variable [Monoid G] {a b x y : G} {n m : ℕ}
section IsOfFinOrder
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/12129): additional beta reduction needed
@[to_additive]
theorem isPeriodicPt_mul_iff_pow_eq_one (x : G) : IsPeriodicPt (x * ·) n 1 ↔ x ^ n = 1 := by
rw [IsPeriodicPt, IsFixedPt, mul_left_iterate]; beta_reduce; rw [mul_one]
/-- `IsOfFinOrder` is a predicate on an element `x` of a monoid to be of finite order, i.e. there
exists `n ≥ 1` such that `x ^ n = 1`. -/
@[to_additive "`IsOfFinAddOrder` is a predicate on an element `a` of an
additive monoid to be of finite order, i.e. there exists `n ≥ 1` such that `n • a = 0`."]
def IsOfFinOrder (x : G) : Prop :=
(1 : G) ∈ periodicPts (x * ·)
theorem isOfFinAddOrder_ofMul_iff : IsOfFinAddOrder (Additive.ofMul x) ↔ IsOfFinOrder x :=
Iff.rfl
theorem isOfFinOrder_ofAdd_iff {α : Type*} [AddMonoid α] {x : α} :
IsOfFinOrder (Multiplicative.ofAdd x) ↔ IsOfFinAddOrder x := Iff.rfl
@[to_additive]
theorem isOfFinOrder_iff_pow_eq_one : IsOfFinOrder x ↔ ∃ n, 0 < n ∧ x ^ n = 1 := by
simp [IsOfFinOrder, mem_periodicPts, isPeriodicPt_mul_iff_pow_eq_one]
@[to_additive] alias ⟨IsOfFinOrder.exists_pow_eq_one, _⟩ := isOfFinOrder_iff_pow_eq_one
@[to_additive]
lemma isOfFinOrder_iff_zpow_eq_one {G} [DivisionMonoid G] {x : G} :
IsOfFinOrder x ↔ ∃ (n : ℤ), n ≠ 0 ∧ x ^ n = 1 := by
rw [isOfFinOrder_iff_pow_eq_one]
refine ⟨fun ⟨n, hn, hn'⟩ ↦ ⟨n, Int.natCast_ne_zero_iff_pos.mpr hn, zpow_natCast x n ▸ hn'⟩,
fun ⟨n, hn, hn'⟩ ↦ ⟨n.natAbs, Int.natAbs_pos.mpr hn, ?_⟩⟩
rcases (Int.natAbs_eq_iff (a := n)).mp rfl with h | h
· rwa [h, zpow_natCast] at hn'
· rwa [h, zpow_neg, inv_eq_one, zpow_natCast] at hn'
/-- See also `injective_pow_iff_not_isOfFinOrder`. -/
@[to_additive "See also `injective_nsmul_iff_not_isOfFinAddOrder`."]
theorem not_isOfFinOrder_of_injective_pow {x : G} (h : Injective fun n : ℕ => x ^ n) :
¬IsOfFinOrder x := by
simp_rw [isOfFinOrder_iff_pow_eq_one, not_exists, not_and]
intro n hn_pos hnx
rw [← pow_zero x] at hnx
rw [h hnx] at hn_pos
exact irrefl 0 hn_pos
/-- 1 is of finite order in any monoid. -/
@[to_additive (attr := simp) "0 is of finite order in any additive monoid."]
theorem IsOfFinOrder.one : IsOfFinOrder (1 : G) :=
isOfFinOrder_iff_pow_eq_one.mpr ⟨1, Nat.one_pos, one_pow 1⟩
@[to_additive]
lemma IsOfFinOrder.pow {n : ℕ} : IsOfFinOrder a → IsOfFinOrder (a ^ n) := by
simp_rw [isOfFinOrder_iff_pow_eq_one]
rintro ⟨m, hm, ha⟩
exact ⟨m, hm, by simp [pow_right_comm _ n, ha]⟩
@[to_additive]
lemma IsOfFinOrder.of_pow {n : ℕ} (h : IsOfFinOrder (a ^ n)) (hn : n ≠ 0) : IsOfFinOrder a := by
rw [isOfFinOrder_iff_pow_eq_one] at *
rcases h with ⟨m, hm, ha⟩
exact ⟨n * m, mul_pos hn.bot_lt hm, by rwa [pow_mul]⟩
@[to_additive (attr := simp)]
lemma isOfFinOrder_pow {n : ℕ} : IsOfFinOrder (a ^ n) ↔ IsOfFinOrder a ∨ n = 0 := by
rcases Decidable.eq_or_ne n 0 with rfl | hn
· simp
· exact ⟨fun h ↦ .inl <| h.of_pow hn, fun h ↦ (h.resolve_right hn).pow⟩
/-- Elements of finite order are of finite order in submonoids. -/
@[to_additive "Elements of finite order are of finite order in submonoids."]
theorem Submonoid.isOfFinOrder_coe {H : Submonoid G} {x : H} :
IsOfFinOrder (x : G) ↔ IsOfFinOrder x := by
rw [isOfFinOrder_iff_pow_eq_one, isOfFinOrder_iff_pow_eq_one]
norm_cast
theorem IsConj.isOfFinOrder (h : IsConj x y) : IsOfFinOrder x → IsOfFinOrder y := by
simp_rw [isOfFinOrder_iff_pow_eq_one]
rintro ⟨n, n_gt_0, eq'⟩
exact ⟨n, n_gt_0, by rw [← isConj_one_right, ← eq']; exact h.pow n⟩
/-- The image of an element of finite order has finite order. -/
@[to_additive "The image of an element of finite additive order has finite additive order."]
theorem MonoidHom.isOfFinOrder [Monoid H] (f : G →* H) {x : G} (h : IsOfFinOrder x) :
IsOfFinOrder <| f x :=
isOfFinOrder_iff_pow_eq_one.mpr <| by
obtain ⟨n, npos, hn⟩ := h.exists_pow_eq_one
exact ⟨n, npos, by rw [← f.map_pow, hn, f.map_one]⟩
/-- If a direct product has finite order then so does each component. -/
@[to_additive "If a direct product has finite additive order then so does each component."]
theorem IsOfFinOrder.apply {η : Type*} {Gs : η → Type*} [∀ i, Monoid (Gs i)] {x : ∀ i, Gs i}
(h : IsOfFinOrder x) : ∀ i, IsOfFinOrder (x i) := by
obtain ⟨n, npos, hn⟩ := h.exists_pow_eq_one
exact fun _ => isOfFinOrder_iff_pow_eq_one.mpr ⟨n, npos, (congr_fun hn.symm _).symm⟩
/-- The submonoid generated by an element is a group if that element has finite order. -/
@[to_additive "The additive submonoid generated by an element is
an additive group if that element has finite order."]
noncomputable abbrev IsOfFinOrder.groupPowers (hx : IsOfFinOrder x) :
Group (Submonoid.powers x) := by
obtain ⟨hpos, hx⟩ := hx.exists_pow_eq_one.choose_spec
exact Submonoid.groupPowers hpos hx
end IsOfFinOrder
/-- `orderOf x` is the order of the element `x`, i.e. the `n ≥ 1`, s.t. `x ^ n = 1` if it exists.
Otherwise, i.e. if `x` is of infinite order, then `orderOf x` is `0` by convention. -/
@[to_additive
"`addOrderOf a` is the order of the element `a`, i.e. the `n ≥ 1`, s.t. `n • a = 0` if it
exists. Otherwise, i.e. if `a` is of infinite order, then `addOrderOf a` is `0` by convention."]
noncomputable def orderOf (x : G) : ℕ :=
minimalPeriod (x * ·) 1
@[simp]
theorem addOrderOf_ofMul_eq_orderOf (x : G) : addOrderOf (Additive.ofMul x) = orderOf x :=
rfl
@[simp]
lemma orderOf_ofAdd_eq_addOrderOf {α : Type*} [AddMonoid α] (a : α) :
orderOf (Multiplicative.ofAdd a) = addOrderOf a := rfl
@[to_additive]
protected lemma IsOfFinOrder.orderOf_pos (h : IsOfFinOrder x) : 0 < orderOf x :=
minimalPeriod_pos_of_mem_periodicPts h
@[to_additive addOrderOf_nsmul_eq_zero]
theorem pow_orderOf_eq_one (x : G) : x ^ orderOf x = 1 := by
convert Eq.trans _ (isPeriodicPt_minimalPeriod (x * ·) 1)
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/12129): additional beta reduction needed in the middle of the rewrite
rw [orderOf, mul_left_iterate]; beta_reduce; rw [mul_one]
@[to_additive]
theorem orderOf_eq_zero (h : ¬IsOfFinOrder x) : orderOf x = 0 := by
rwa [orderOf, minimalPeriod, dif_neg]
@[to_additive]
theorem orderOf_eq_zero_iff : orderOf x = 0 ↔ ¬IsOfFinOrder x :=
⟨fun h H ↦ H.orderOf_pos.ne' h, orderOf_eq_zero⟩
@[to_additive]
theorem orderOf_eq_zero_iff' : orderOf x = 0 ↔ ∀ n : ℕ, 0 < n → x ^ n ≠ 1 := by
simp_rw [orderOf_eq_zero_iff, isOfFinOrder_iff_pow_eq_one, not_exists, not_and]
@[to_additive]
theorem orderOf_eq_iff {n} (h : 0 < n) :
orderOf x = n ↔ x ^ n = 1 ∧ ∀ m, m < n → 0 < m → x ^ m ≠ 1 := by
simp_rw [Ne, ← isPeriodicPt_mul_iff_pow_eq_one, orderOf, minimalPeriod]
split_ifs with h1
· classical
rw [find_eq_iff]
simp only [h, true_and]
push_neg
rfl
· rw [iff_false_left h.ne]
rintro ⟨h', -⟩
exact h1 ⟨n, h, h'⟩
/-- A group element has finite order iff its order is positive. -/
@[to_additive
"A group element has finite additive order iff its order is positive."]
theorem orderOf_pos_iff : 0 < orderOf x ↔ IsOfFinOrder x := by
rw [iff_not_comm.mp orderOf_eq_zero_iff, pos_iff_ne_zero]
@[to_additive]
theorem IsOfFinOrder.mono [Monoid β] {y : β} (hx : IsOfFinOrder x) (h : orderOf y ∣ orderOf x) :
IsOfFinOrder y := by rw [← orderOf_pos_iff] at hx ⊢; exact Nat.pos_of_dvd_of_pos h hx
@[to_additive]
theorem pow_ne_one_of_lt_orderOf (n0 : n ≠ 0) (h : n < orderOf x) : x ^ n ≠ 1 := fun j =>
not_isPeriodicPt_of_pos_of_lt_minimalPeriod n0 h ((isPeriodicPt_mul_iff_pow_eq_one x).mpr j)
@[to_additive]
theorem orderOf_le_of_pow_eq_one (hn : 0 < n) (h : x ^ n = 1) : orderOf x ≤ n :=
IsPeriodicPt.minimalPeriod_le hn (by rwa [isPeriodicPt_mul_iff_pow_eq_one])
@[to_additive (attr := simp)]
theorem orderOf_one : orderOf (1 : G) = 1 := by
rw [orderOf, ← minimalPeriod_id (x := (1 : G)), ← one_mul_eq_id]
@[to_additive (attr := simp) AddMonoid.addOrderOf_eq_one_iff]
theorem orderOf_eq_one_iff : orderOf x = 1 ↔ x = 1 := by
rw [orderOf, minimalPeriod_eq_one_iff_isFixedPt, IsFixedPt, mul_one]
@[to_additive (attr := simp) mod_addOrderOf_nsmul]
lemma pow_mod_orderOf (x : G) (n : ℕ) : x ^ (n % orderOf x) = x ^ n :=
calc
x ^ (n % orderOf x) = x ^ (n % orderOf x + orderOf x * (n / orderOf x)) := by
simp [pow_add, pow_mul, pow_orderOf_eq_one]
_ = x ^ n := by rw [Nat.mod_add_div]
@[to_additive]
theorem orderOf_dvd_of_pow_eq_one (h : x ^ n = 1) : orderOf x ∣ n :=
IsPeriodicPt.minimalPeriod_dvd ((isPeriodicPt_mul_iff_pow_eq_one _).mpr h)
@[to_additive]
theorem orderOf_dvd_iff_pow_eq_one {n : ℕ} : orderOf x ∣ n ↔ x ^ n = 1 :=
⟨fun h => by rw [← pow_mod_orderOf, Nat.mod_eq_zero_of_dvd h, _root_.pow_zero],
orderOf_dvd_of_pow_eq_one⟩
@[to_additive addOrderOf_smul_dvd]
theorem orderOf_pow_dvd (n : ℕ) : orderOf (x ^ n) ∣ orderOf x := by
rw [orderOf_dvd_iff_pow_eq_one, pow_right_comm, pow_orderOf_eq_one, one_pow]
@[to_additive]
lemma pow_injOn_Iio_orderOf : (Set.Iio <| orderOf x).InjOn (x ^ ·) := by
simpa only [mul_left_iterate, mul_one]
using iterate_injOn_Iio_minimalPeriod (f := (x * ·)) (x := 1)
@[to_additive]
protected lemma IsOfFinOrder.mem_powers_iff_mem_range_orderOf [DecidableEq G]
(hx : IsOfFinOrder x) :
y ∈ Submonoid.powers x ↔ y ∈ (Finset.range (orderOf x)).image (x ^ ·) :=
Finset.mem_range_iff_mem_finset_range_of_mod_eq' hx.orderOf_pos <| pow_mod_orderOf _
@[to_additive]
protected lemma IsOfFinOrder.powers_eq_image_range_orderOf [DecidableEq G] (hx : IsOfFinOrder x) :
(Submonoid.powers x : Set G) = (Finset.range (orderOf x)).image (x ^ ·) :=
Set.ext fun _ ↦ hx.mem_powers_iff_mem_range_orderOf
@[to_additive]
theorem pow_eq_one_iff_modEq : x ^ n = 1 ↔ n ≡ 0 [MOD orderOf x] := by
rw [modEq_zero_iff_dvd, orderOf_dvd_iff_pow_eq_one]
@[to_additive]
| Mathlib/GroupTheory/OrderOfElement.lean | 272 | 274 | theorem orderOf_map_dvd {H : Type*} [Monoid H] (ψ : G →* H) (x : G) :
orderOf (ψ x) ∣ orderOf x := by | apply orderOf_dvd_of_pow_eq_one |
/-
Copyright (c) 2022 George Peter Banyard, Yaël Dillies, Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: George Peter Banyard, Yaël Dillies, Kyle Miller
-/
import Mathlib.Combinatorics.SimpleGraph.Path
import Mathlib.Combinatorics.SimpleGraph.Metric
/-!
# Graph products
This file defines the box product of graphs and other product constructions. The box product of `G`
and `H` is the graph on the product of the vertices such that `x` and `y` are related iff they agree
on one component and the other one is related via either `G` or `H`. For example, the box product of
two edges is a square.
## Main declarations
* `SimpleGraph.boxProd`: The box product.
## Notation
* `G □ H`: The box product of `G` and `H`.
## TODO
Define all other graph products!
-/
variable {α β γ : Type*}
namespace SimpleGraph
variable {G : SimpleGraph α} {H : SimpleGraph β}
/-- Box product of simple graphs. It relates `(a₁, b)` and `(a₂, b)` if `G` relates `a₁` and `a₂`,
and `(a, b₁)` and `(a, b₂)` if `H` relates `b₁` and `b₂`. -/
def boxProd (G : SimpleGraph α) (H : SimpleGraph β) : SimpleGraph (α × β) where
Adj x y := G.Adj x.1 y.1 ∧ x.2 = y.2 ∨ H.Adj x.2 y.2 ∧ x.1 = y.1
symm x y := by simp [and_comm, or_comm, eq_comm, adj_comm]
loopless x := by simp
/-- Box product of simple graphs. It relates `(a₁, b)` and `(a₂, b)` if `G` relates `a₁` and `a₂`,
and `(a, b₁)` and `(a, b₂)` if `H` relates `b₁` and `b₂`. -/
infixl:70 " □ " => boxProd
@[simp]
theorem boxProd_adj {x y : α × β} :
(G □ H).Adj x y ↔ G.Adj x.1 y.1 ∧ x.2 = y.2 ∨ H.Adj x.2 y.2 ∧ x.1 = y.1 :=
Iff.rfl
theorem boxProd_adj_left {a₁ : α} {b : β} {a₂ : α} :
(G □ H).Adj (a₁, b) (a₂, b) ↔ G.Adj a₁ a₂ := by
simp only [boxProd_adj, and_true, SimpleGraph.irrefl, false_and, or_false]
theorem boxProd_adj_right {a : α} {b₁ b₂ : β} : (G □ H).Adj (a, b₁) (a, b₂) ↔ H.Adj b₁ b₂ := by
simp only [boxProd_adj, SimpleGraph.irrefl, false_and, and_true, false_or]
| Mathlib/Combinatorics/SimpleGraph/Prod.lean | 59 | 60 | theorem boxProd_neighborSet (x : α × β) :
(G □ H).neighborSet x = G.neighborSet x.1 ×ˢ {x.2} ∪ {x.1} ×ˢ H.neighborSet x.2 := by | |
/-
Copyright (c) 2022 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Patrick Massot, Yury Kudryashov, Kevin H. Wilson, Heather Macbeth
-/
import Mathlib.Order.Filter.Tendsto
/-!
# Product and coproduct filters
In this file we define `Filter.prod f g` (notation: `f ×ˢ g`) and `Filter.coprod f g`. The product
of two filters is the largest filter `l` such that `Filter.Tendsto Prod.fst l f` and
`Filter.Tendsto Prod.snd l g`.
## Implementation details
The product filter cannot be defined using the monad structure on filters. For example:
```lean
F := do {x ← seq, y ← top, return (x, y)}
G := do {y ← top, x ← seq, return (x, y)}
```
hence:
```lean
s ∈ F ↔ ∃ n, [n..∞] × univ ⊆ s
s ∈ G ↔ ∀ i:ℕ, ∃ n, [n..∞] × {i} ⊆ s
```
Now `⋃ i, [i..∞] × {i}` is in `G` but not in `F`.
As product filter we want to have `F` as result.
## Notations
* `f ×ˢ g` : `Filter.prod f g`, localized in `Filter`.
-/
open Set
open Filter
namespace Filter
variable {α β γ δ : Type*} {ι : Sort*}
section Prod
variable {s : Set α} {t : Set β} {f : Filter α} {g : Filter β}
theorem prod_mem_prod (hs : s ∈ f) (ht : t ∈ g) : s ×ˢ t ∈ f ×ˢ g :=
inter_mem_inf (preimage_mem_comap hs) (preimage_mem_comap ht)
theorem mem_prod_iff {s : Set (α × β)} {f : Filter α} {g : Filter β} :
s ∈ f ×ˢ g ↔ ∃ t₁ ∈ f, ∃ t₂ ∈ g, t₁ ×ˢ t₂ ⊆ s := by
constructor
· rintro ⟨t₁, ⟨s₁, hs₁, hts₁⟩, t₂, ⟨s₂, hs₂, hts₂⟩, rfl⟩
exact ⟨s₁, hs₁, s₂, hs₂, fun p ⟨h, h'⟩ => ⟨hts₁ h, hts₂ h'⟩⟩
· rintro ⟨t₁, ht₁, t₂, ht₂, h⟩
exact mem_inf_of_inter (preimage_mem_comap ht₁) (preimage_mem_comap ht₂) h
@[simp]
theorem compl_diagonal_mem_prod {l₁ l₂ : Filter α} : (diagonal α)ᶜ ∈ l₁ ×ˢ l₂ ↔ Disjoint l₁ l₂ := by
simp only [mem_prod_iff, Filter.disjoint_iff, prod_subset_compl_diagonal_iff_disjoint]
@[simp]
theorem prod_mem_prod_iff [f.NeBot] [g.NeBot] : s ×ˢ t ∈ f ×ˢ g ↔ s ∈ f ∧ t ∈ g :=
⟨fun h =>
let ⟨_s', hs', _t', ht', H⟩ := mem_prod_iff.1 h
(prod_subset_prod_iff.1 H).elim
(fun ⟨hs's, ht't⟩ => ⟨mem_of_superset hs' hs's, mem_of_superset ht' ht't⟩) fun h =>
h.elim (fun hs'e => absurd hs'e (nonempty_of_mem hs').ne_empty) fun ht'e =>
absurd ht'e (nonempty_of_mem ht').ne_empty,
fun h => prod_mem_prod h.1 h.2⟩
theorem mem_prod_principal {s : Set (α × β)} :
s ∈ f ×ˢ 𝓟 t ↔ { a | ∀ b ∈ t, (a, b) ∈ s } ∈ f := by
rw [← @exists_mem_subset_iff _ f, mem_prod_iff]
refine exists_congr fun u => Iff.rfl.and ⟨?_, fun h => ⟨t, mem_principal_self t, ?_⟩⟩
· rintro ⟨v, v_in, hv⟩ a a_in b b_in
exact hv (mk_mem_prod a_in <| v_in b_in)
· rintro ⟨x, y⟩ ⟨hx, hy⟩
exact h hx y hy
theorem mem_prod_top {s : Set (α × β)} :
s ∈ f ×ˢ (⊤ : Filter β) ↔ { a | ∀ b, (a, b) ∈ s } ∈ f := by
rw [← principal_univ, mem_prod_principal]
simp only [mem_univ, forall_true_left]
theorem eventually_prod_principal_iff {p : α × β → Prop} {s : Set β} :
(∀ᶠ x : α × β in f ×ˢ 𝓟 s, p x) ↔ ∀ᶠ x : α in f, ∀ y : β, y ∈ s → p (x, y) := by
rw [eventually_iff, eventually_iff, mem_prod_principal]
simp only [mem_setOf_eq]
theorem comap_prod (f : α → β × γ) (b : Filter β) (c : Filter γ) :
comap f (b ×ˢ c) = comap (Prod.fst ∘ f) b ⊓ comap (Prod.snd ∘ f) c := by
rw [prod_eq_inf, comap_inf, Filter.comap_comap, Filter.comap_comap]
theorem comap_prodMap_prod (f : α → β) (g : γ → δ) (lb : Filter β) (ld : Filter δ) :
comap (Prod.map f g) (lb ×ˢ ld) = comap f lb ×ˢ comap g ld := by
simp [prod_eq_inf, comap_comap, Function.comp_def]
| Mathlib/Order/Filter/Prod.lean | 101 | 104 | theorem prod_top : f ×ˢ (⊤ : Filter β) = f.comap Prod.fst := by | rw [prod_eq_inf, comap_top, inf_top_eq]
theorem top_prod : (⊤ : Filter α) ×ˢ g = g.comap Prod.snd := by |
/-
Copyright (c) 2019 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.Data.List.Lattice
import Mathlib.Data.Bool.Basic
import Mathlib.Order.Lattice
/-!
# Intervals in ℕ
This file defines intervals of naturals. `List.Ico m n` is the list of integers greater than `m`
and strictly less than `n`.
## TODO
- Define `Ioo` and `Icc`, state basic lemmas about them.
- Also do the versions for integers?
- One could generalise even further, defining 'locally finite partial orders', for which
`Set.Ico a b` is `[Finite]`, and 'locally finite total orders', for which there is a list model.
- Once the above is done, get rid of `Int.range` (and maybe `List.range'`?).
-/
open Nat
namespace List
/-- `Ico n m` is the list of natural numbers `n ≤ x < m`.
(Ico stands for "interval, closed-open".)
See also `Mathlib/Order/Interval/Basic.lean` for modelling intervals in general preorders, as well
as sibling definitions alongside it such as `Set.Ico`, `Multiset.Ico` and `Finset.Ico`
for sets, multisets and finite sets respectively.
-/
def Ico (n m : ℕ) : List ℕ :=
range' n (m - n)
namespace Ico
theorem zero_bot (n : ℕ) : Ico 0 n = range n := by rw [Ico, Nat.sub_zero, range_eq_range']
@[simp]
theorem length (n m : ℕ) : length (Ico n m) = m - n := by
dsimp [Ico]
simp [length_range']
theorem pairwise_lt (n m : ℕ) : Pairwise (· < ·) (Ico n m) := by
dsimp [Ico]
simp [pairwise_lt_range']
theorem nodup (n m : ℕ) : Nodup (Ico n m) := by
dsimp [Ico]
simp [nodup_range']
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
omega
theorem eq_nil_of_le {n m : ℕ} (h : m ≤ n) : Ico n m = [] := by
simp [Ico, Nat.sub_eq_zero_iff_le.mpr h]
theorem map_add (n m k : ℕ) : (Ico n m).map (k + ·) = Ico (n + k) (m + k) := by
rw [Ico, Ico, map_add_range', Nat.add_sub_add_right m k, Nat.add_comm n k]
theorem map_sub (n m k : ℕ) (h₁ : k ≤ n) :
((Ico n m).map fun x => x - k) = Ico (n - k) (m - k) := by
rw [Ico, Ico, Nat.sub_sub_sub_cancel_right h₁, map_sub_range' h₁]
@[simp]
theorem self_empty {n : ℕ} : Ico n n = [] :=
eq_nil_of_le (le_refl n)
@[simp]
theorem eq_empty_iff {n m : ℕ} : Ico n m = [] ↔ m ≤ n :=
Iff.intro (fun h => Nat.sub_eq_zero_iff_le.mp <| by rw [← length, h, List.length]) eq_nil_of_le
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :
Ico n m ++ Ico m l = Ico n l := by
dsimp only [Ico]
convert range'_append using 2
· rw [Nat.one_mul, Nat.add_sub_cancel' hnm]
· omega
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
apply eq_nil_iff_forall_not_mem.2
intro a
simp only [and_imp, not_and, not_lt, List.mem_inter_iff, List.Ico.mem]
intro _ h₂ h₃
exfalso
exact not_lt_of_ge h₃ h₂
@[simp]
theorem bagInter_consecutive (n m l : Nat) :
@List.bagInter ℕ instBEqOfDecidableEq (Ico n m) (Ico m l) = [] :=
(bagInter_nil_iff_inter_nil _ _).2 (by convert inter_consecutive n m l)
@[simp]
theorem succ_singleton {n : ℕ} : Ico n (n + 1) = [n] := by
dsimp [Ico]
simp [range', Nat.add_sub_cancel_left]
theorem succ_top {n m : ℕ} (h : n ≤ m) : Ico n (m + 1) = Ico n m ++ [m] := by
rwa [← succ_singleton, append_consecutive]
exact Nat.le_succ _
theorem eq_cons {n m : ℕ} (h : n < m) : Ico n m = n :: Ico (n + 1) m := by
rw [← append_consecutive (Nat.le_succ n) h, succ_singleton]
rfl
@[simp]
| Mathlib/Data/List/Intervals.lean | 114 | 116 | theorem pred_singleton {m : ℕ} (h : 0 < m) : Ico (m - 1) m = [m - 1] := by | simp [Ico, Nat.sub_sub_self (succ_le_of_lt h)] |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Johannes Hölzl, Yury Kudryashov, Patrick Massot
-/
import Mathlib.Algebra.GeomSum
import Mathlib.Order.Filter.AtTopBot.Archimedean
import Mathlib.Order.Iterate
import Mathlib.Topology.Algebra.Algebra
import Mathlib.Topology.Algebra.InfiniteSum.Real
import Mathlib.Topology.Instances.EReal.Lemmas
/-!
# A collection of specific limit computations
This file, by design, is independent of `NormedSpace` in the import hierarchy. It contains
important specific limit computations in metric spaces, in ordered rings/fields, and in specific
instances of these such as `ℝ`, `ℝ≥0` and `ℝ≥0∞`.
-/
assert_not_exists Basis NormedSpace
noncomputable section
open Set Function Filter Finset Metric Topology Nat uniformity NNReal ENNReal
variable {α : Type*} {β : Type*} {ι : Type*}
theorem tendsto_inverse_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ (n : ℝ)⁻¹) atTop (𝓝 0) :=
tendsto_inv_atTop_zero.comp tendsto_natCast_atTop_atTop
theorem tendsto_const_div_atTop_nhds_zero_nat (C : ℝ) :
Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by
simpa only [mul_zero] using tendsto_const_nhds.mul tendsto_inverse_atTop_nhds_zero_nat
theorem tendsto_one_div_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ 1/(n : ℝ)) atTop (𝓝 0) :=
tendsto_const_div_atTop_nhds_zero_nat 1
theorem NNReal.tendsto_inverse_atTop_nhds_zero_nat :
Tendsto (fun n : ℕ ↦ (n : ℝ≥0)⁻¹) atTop (𝓝 0) := by
rw [← NNReal.tendsto_coe]
exact _root_.tendsto_inverse_atTop_nhds_zero_nat
theorem NNReal.tendsto_const_div_atTop_nhds_zero_nat (C : ℝ≥0) :
Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by
simpa using tendsto_const_nhds.mul NNReal.tendsto_inverse_atTop_nhds_zero_nat
theorem EReal.tendsto_const_div_atTop_nhds_zero_nat {C : EReal} (h : C ≠ ⊥) (h' : C ≠ ⊤) :
Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by
have : (fun n : ℕ ↦ C / n) = fun n : ℕ ↦ ((C.toReal / n : ℝ) : EReal) := by
ext n
nth_rw 1 [← coe_toReal h' h, ← coe_coe_eq_natCast n, ← coe_div C.toReal n]
rw [this, ← coe_zero, tendsto_coe]
exact _root_.tendsto_const_div_atTop_nhds_zero_nat C.toReal
theorem tendsto_one_div_add_atTop_nhds_zero_nat :
Tendsto (fun n : ℕ ↦ 1 / ((n : ℝ) + 1)) atTop (𝓝 0) :=
suffices Tendsto (fun n : ℕ ↦ 1 / (↑(n + 1) : ℝ)) atTop (𝓝 0) by simpa
(tendsto_add_atTop_iff_nat 1).2 (_root_.tendsto_const_div_atTop_nhds_zero_nat 1)
theorem NNReal.tendsto_algebraMap_inverse_atTop_nhds_zero_nat (𝕜 : Type*) [Semiring 𝕜]
[Algebra ℝ≥0 𝕜] [TopologicalSpace 𝕜] [ContinuousSMul ℝ≥0 𝕜] :
Tendsto (algebraMap ℝ≥0 𝕜 ∘ fun n : ℕ ↦ (n : ℝ≥0)⁻¹) atTop (𝓝 0) := by
convert (continuous_algebraMap ℝ≥0 𝕜).continuousAt.tendsto.comp
tendsto_inverse_atTop_nhds_zero_nat
rw [map_zero]
theorem tendsto_algebraMap_inverse_atTop_nhds_zero_nat (𝕜 : Type*) [Semiring 𝕜] [Algebra ℝ 𝕜]
[TopologicalSpace 𝕜] [ContinuousSMul ℝ 𝕜] :
Tendsto (algebraMap ℝ 𝕜 ∘ fun n : ℕ ↦ (n : ℝ)⁻¹) atTop (𝓝 0) :=
NNReal.tendsto_algebraMap_inverse_atTop_nhds_zero_nat 𝕜
/-- The limit of `n / (n + x)` is 1, for any constant `x` (valid in `ℝ` or any topological division
algebra over `ℝ`, e.g., `ℂ`).
TODO: introduce a typeclass saying that `1 / n` tends to 0 at top, making it possible to get this
statement simultaneously on `ℚ`, `ℝ` and `ℂ`. -/
theorem tendsto_natCast_div_add_atTop {𝕜 : Type*} [DivisionRing 𝕜] [TopologicalSpace 𝕜]
[CharZero 𝕜] [Algebra ℝ 𝕜] [ContinuousSMul ℝ 𝕜] [IsTopologicalDivisionRing 𝕜] (x : 𝕜) :
Tendsto (fun n : ℕ ↦ (n : 𝕜) / (n + x)) atTop (𝓝 1) := by
convert Tendsto.congr' ((eventually_ne_atTop 0).mp (Eventually.of_forall fun n hn ↦ _)) _
· exact fun n : ℕ ↦ 1 / (1 + x / n)
· field_simp [Nat.cast_ne_zero.mpr hn]
· have : 𝓝 (1 : 𝕜) = 𝓝 (1 / (1 + x * (0 : 𝕜))) := by
rw [mul_zero, add_zero, div_one]
rw [this]
refine tendsto_const_nhds.div (tendsto_const_nhds.add ?_) (by simp)
simp_rw [div_eq_mul_inv]
refine tendsto_const_nhds.mul ?_
have := ((continuous_algebraMap ℝ 𝕜).tendsto _).comp tendsto_inverse_atTop_nhds_zero_nat
rw [map_zero, Filter.tendsto_atTop'] at this
refine Iff.mpr tendsto_atTop' ?_
intros
simp_all only [comp_apply, map_inv₀, map_natCast]
/-- For any positive `m : ℕ`, `((n % m : ℕ) : ℝ) / (n : ℝ)` tends to `0` as `n` tends to `∞`. -/
theorem tendsto_mod_div_atTop_nhds_zero_nat {m : ℕ} (hm : 0 < m) :
Tendsto (fun n : ℕ => ((n % m : ℕ) : ℝ) / (n : ℝ)) atTop (𝓝 0) := by
have h0 : ∀ᶠ n : ℕ in atTop, 0 ≤ (fun n : ℕ => ((n % m : ℕ) : ℝ)) n := by aesop
exact tendsto_bdd_div_atTop_nhds_zero h0
(.of_forall (fun n ↦ cast_le.mpr (mod_lt n hm).le)) tendsto_natCast_atTop_atTop
theorem Filter.EventuallyEq.div_mul_cancel {α G : Type*} [GroupWithZero G] {f g : α → G}
{l : Filter α} (hg : Tendsto g l (𝓟 {0}ᶜ)) : (fun x ↦ f x / g x * g x) =ᶠ[l] fun x ↦ f x := by
filter_upwards [hg.le_comap <| preimage_mem_comap (m := g) (mem_principal_self {0}ᶜ)] with x hx
aesop
/-- If `g` tends to `∞`, then eventually for all `x` we have `(f x / g x) * g x = f x`. -/
theorem Filter.EventuallyEq.div_mul_cancel_atTop {α K : Type*}
[Semifield K] [LinearOrder K] [IsStrictOrderedRing K]
{f g : α → K} {l : Filter α} (hg : Tendsto g l atTop) :
(fun x ↦ f x / g x * g x) =ᶠ[l] fun x ↦ f x :=
div_mul_cancel <| hg.mono_right <| le_principal_iff.mpr <|
mem_of_superset (Ioi_mem_atTop 0) <| by simp
/-- If when `x` tends to `∞`, `g` tends to `∞` and `f x / g x` tends to a positive
constant, then `f` tends to `∞`. -/
theorem Tendsto.num {α K : Type*} [Field K] [LinearOrder K] [IsStrictOrderedRing K]
[TopologicalSpace K] [OrderTopology K]
{f g : α → K} {l : Filter α} (hg : Tendsto g l atTop) {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (𝓝 a)) :
Tendsto f l atTop :=
(hlim.pos_mul_atTop ha hg).congr' (EventuallyEq.div_mul_cancel_atTop hg)
/-- If when `x` tends to `∞`, `g` tends to `∞` and `f x / g x` tends to a positive
constant, then `f` tends to `∞`. -/
theorem Tendsto.den {α K : Type*} [Field K] [LinearOrder K] [IsStrictOrderedRing K]
[TopologicalSpace K] [OrderTopology K]
[ContinuousInv K] {f g : α → K} {l : Filter α} (hf : Tendsto f l atTop) {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (𝓝 a)) :
Tendsto g l atTop :=
have hlim' : Tendsto (fun x => g x / f x) l (𝓝 a⁻¹) := by
simp_rw [← inv_div (f _)]
exact Filter.Tendsto.inv (f := fun x => f x / g x) hlim
(hlim'.pos_mul_atTop (inv_pos_of_pos ha) hf).congr' (.div_mul_cancel_atTop hf)
/-- If when `x` tends to `∞`, `f x / g x` tends to a positive constant, then `f` tends to `∞` if
and only if `g` tends to `∞`. -/
theorem Tendsto.num_atTop_iff_den_atTop {α K : Type*}
[Field K] [LinearOrder K] [IsStrictOrderedRing K] [TopologicalSpace K]
[OrderTopology K] [ContinuousInv K] {f g : α → K} {l : Filter α} {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (𝓝 a)) :
Tendsto f l atTop ↔ Tendsto g l atTop :=
⟨fun hf ↦ Tendsto.den hf ha hlim, fun hg ↦ Tendsto.num hg ha hlim⟩
/-! ### Powers -/
theorem tendsto_add_one_pow_atTop_atTop_of_pos
[Semiring α] [LinearOrder α] [IsStrictOrderedRing α] [Archimedean α] {r : α}
(h : 0 < r) : Tendsto (fun n : ℕ ↦ (r + 1) ^ n) atTop atTop :=
tendsto_atTop_atTop_of_monotone' (pow_right_mono₀ <| le_add_of_nonneg_left h.le) <|
not_bddAbove_iff.2 fun _ ↦ Set.exists_range_iff.2 <| add_one_pow_unbounded_of_pos _ h
theorem tendsto_pow_atTop_atTop_of_one_lt
[Ring α] [LinearOrder α] [IsStrictOrderedRing α] [Archimedean α] {r : α}
(h : 1 < r) : Tendsto (fun n : ℕ ↦ r ^ n) atTop atTop :=
sub_add_cancel r 1 ▸ tendsto_add_one_pow_atTop_atTop_of_pos (sub_pos.2 h)
theorem Nat.tendsto_pow_atTop_atTop_of_one_lt {m : ℕ} (h : 1 < m) :
Tendsto (fun n : ℕ ↦ m ^ n) atTop atTop :=
tsub_add_cancel_of_le (le_of_lt h) ▸ tendsto_add_one_pow_atTop_atTop_of_pos (tsub_pos_of_lt h)
theorem tendsto_pow_atTop_nhds_zero_of_lt_one {𝕜 : Type*}
[Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [Archimedean 𝕜]
[TopologicalSpace 𝕜] [OrderTopology 𝕜] {r : 𝕜} (h₁ : 0 ≤ r) (h₂ : r < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) :=
h₁.eq_or_lt.elim
(fun hr ↦ (tendsto_add_atTop_iff_nat 1).mp <| by
simp [_root_.pow_succ, ← hr, tendsto_const_nhds])
(fun hr ↦
have := (one_lt_inv₀ hr).2 h₂ |> tendsto_pow_atTop_atTop_of_one_lt
(tendsto_inv_atTop_zero.comp this).congr fun n ↦ by simp)
@[simp] theorem tendsto_pow_atTop_nhds_zero_iff {𝕜 : Type*}
[Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [Archimedean 𝕜]
[TopologicalSpace 𝕜] [OrderTopology 𝕜] {r : 𝕜} :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) ↔ |r| < 1 := by
rw [tendsto_zero_iff_abs_tendsto_zero]
refine ⟨fun h ↦ by_contra (fun hr_le ↦ ?_), fun h ↦ ?_⟩
· by_cases hr : 1 = |r|
· replace h : Tendsto (fun n : ℕ ↦ |r|^n) atTop (𝓝 0) := by simpa only [← abs_pow, h]
simp only [hr.symm, one_pow] at h
exact zero_ne_one <| tendsto_nhds_unique h tendsto_const_nhds
· apply @not_tendsto_nhds_of_tendsto_atTop 𝕜 ℕ _ _ _ _ atTop _ (fun n ↦ |r| ^ n) _ 0 _
· refine (pow_right_strictMono₀ <| lt_of_le_of_ne (le_of_not_lt hr_le)
hr).monotone.tendsto_atTop_atTop (fun b ↦ ?_)
obtain ⟨n, hn⟩ := (pow_unbounded_of_one_lt b (lt_of_le_of_ne (le_of_not_lt hr_le) hr))
exact ⟨n, le_of_lt hn⟩
· simpa only [← abs_pow]
· simpa only [← abs_pow] using (tendsto_pow_atTop_nhds_zero_of_lt_one (abs_nonneg r)) h
theorem tendsto_pow_atTop_nhdsWithin_zero_of_lt_one {𝕜 : Type*}
[Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜]
[Archimedean 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] {r : 𝕜} (h₁ : 0 < r) (h₂ : r < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝[>] 0) :=
tendsto_inf.2
⟨tendsto_pow_atTop_nhds_zero_of_lt_one h₁.le h₂,
tendsto_principal.2 <| Eventually.of_forall fun _ ↦ pow_pos h₁ _⟩
theorem uniformity_basis_dist_pow_of_lt_one {α : Type*} [PseudoMetricSpace α] {r : ℝ} (h₀ : 0 < r)
(h₁ : r < 1) :
(uniformity α).HasBasis (fun _ : ℕ ↦ True) fun k ↦ { p : α × α | dist p.1 p.2 < r ^ k } :=
Metric.mk_uniformity_basis (fun _ _ ↦ pow_pos h₀ _) fun _ ε0 ↦
(exists_pow_lt_of_lt_one ε0 h₁).imp fun _ hk ↦ ⟨trivial, hk.le⟩
theorem geom_lt {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) {n : ℕ} (hn : 0 < n)
(h : ∀ k < n, c * u k < u (k + 1)) : c ^ n * u 0 < u n := by
apply (monotone_mul_left_of_nonneg hc).seq_pos_lt_seq_of_le_of_lt hn _ _ h
· simp
· simp [_root_.pow_succ', mul_assoc, le_refl]
theorem geom_le {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) (n : ℕ) (h : ∀ k < n, c * u k ≤ u (k + 1)) :
c ^ n * u 0 ≤ u n := by
apply (monotone_mul_left_of_nonneg hc).seq_le_seq n _ _ h <;>
simp [_root_.pow_succ', mul_assoc, le_refl]
theorem lt_geom {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) {n : ℕ} (hn : 0 < n)
(h : ∀ k < n, u (k + 1) < c * u k) : u n < c ^ n * u 0 := by
apply (monotone_mul_left_of_nonneg hc).seq_pos_lt_seq_of_lt_of_le hn _ h _
· simp
· simp [_root_.pow_succ', mul_assoc, le_refl]
theorem le_geom {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) (n : ℕ) (h : ∀ k < n, u (k + 1) ≤ c * u k) :
u n ≤ c ^ n * u 0 := by
apply (monotone_mul_left_of_nonneg hc).seq_le_seq n _ h _ <;>
simp [_root_.pow_succ', mul_assoc, le_refl]
/-- If a sequence `v` of real numbers satisfies `k * v n ≤ v (n+1)` with `1 < k`,
then it goes to +∞. -/
theorem tendsto_atTop_of_geom_le {v : ℕ → ℝ} {c : ℝ} (h₀ : 0 < v 0) (hc : 1 < c)
(hu : ∀ n, c * v n ≤ v (n + 1)) : Tendsto v atTop atTop :=
(tendsto_atTop_mono fun n ↦ geom_le (zero_le_one.trans hc.le) n fun k _ ↦ hu k) <|
(tendsto_pow_atTop_atTop_of_one_lt hc).atTop_mul_const h₀
theorem NNReal.tendsto_pow_atTop_nhds_zero_of_lt_one {r : ℝ≥0} (hr : r < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) :=
NNReal.tendsto_coe.1 <| by
simp only [NNReal.coe_pow, NNReal.coe_zero,
_root_.tendsto_pow_atTop_nhds_zero_of_lt_one r.coe_nonneg hr]
@[simp]
protected theorem NNReal.tendsto_pow_atTop_nhds_zero_iff {r : ℝ≥0} :
Tendsto (fun n : ℕ => r ^ n) atTop (𝓝 0) ↔ r < 1 :=
⟨fun h => by simpa [coe_pow, coe_zero, abs_eq, coe_lt_one, val_eq_coe] using
tendsto_pow_atTop_nhds_zero_iff.mp <| tendsto_coe.mpr h, tendsto_pow_atTop_nhds_zero_of_lt_one⟩
theorem ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one {r : ℝ≥0∞} (hr : r < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) := by
rcases ENNReal.lt_iff_exists_coe.1 hr with ⟨r, rfl, hr'⟩
rw [← ENNReal.coe_zero]
norm_cast at *
apply NNReal.tendsto_pow_atTop_nhds_zero_of_lt_one hr
@[simp]
protected theorem ENNReal.tendsto_pow_atTop_nhds_zero_iff {r : ℝ≥0∞} :
Tendsto (fun n : ℕ => r ^ n) atTop (𝓝 0) ↔ r < 1 := by
refine ⟨fun h ↦ ?_, tendsto_pow_atTop_nhds_zero_of_lt_one⟩
lift r to NNReal
· refine fun hr ↦ top_ne_zero (tendsto_nhds_unique (EventuallyEq.tendsto ?_) (hr ▸ h))
exact eventually_atTop.mpr ⟨1, fun _ hn ↦ pow_eq_top_iff.mpr ⟨rfl, Nat.pos_iff_ne_zero.mp hn⟩⟩
rw [← coe_zero] at h
norm_cast at h ⊢
exact NNReal.tendsto_pow_atTop_nhds_zero_iff.mp h
@[simp]
protected theorem ENNReal.tendsto_pow_atTop_nhds_top_iff {r : ℝ≥0∞} :
Tendsto (fun n ↦ r^n) atTop (𝓝 ∞) ↔ 1 < r := by
refine ⟨?_, ?_⟩
· contrapose!
intro r_le_one h_tends
specialize h_tends (Ioi_mem_nhds one_lt_top)
simp only [Filter.mem_map, mem_atTop_sets, ge_iff_le, Set.mem_preimage, Set.mem_Ioi] at h_tends
obtain ⟨n, hn⟩ := h_tends
exact lt_irrefl _ <| lt_of_lt_of_le (hn n le_rfl) <| pow_le_one₀ (zero_le _) r_le_one
· intro r_gt_one
have obs := @Tendsto.inv ℝ≥0∞ ℕ _ _ _ (fun n ↦ (r⁻¹)^n) atTop 0
simp only [ENNReal.tendsto_pow_atTop_nhds_zero_iff, inv_zero] at obs
simpa [← ENNReal.inv_pow] using obs <| ENNReal.inv_lt_one.mpr r_gt_one
lemma ENNReal.eq_zero_of_le_mul_pow {x r : ℝ≥0∞} {ε : ℝ≥0} (hr : r < 1)
(h : ∀ n : ℕ, x ≤ ε * r ^ n) : x = 0 := by
rw [← nonpos_iff_eq_zero]
refine ge_of_tendsto' (f := fun (n : ℕ) ↦ ε * r ^ n) (x := atTop) ?_ h
rw [← mul_zero (M₀ := ℝ≥0∞) (a := ε)]
exact Tendsto.const_mul (tendsto_pow_atTop_nhds_zero_of_lt_one hr) (Or.inr coe_ne_top)
/-! ### Geometric series -/
section Geometric
theorem hasSum_geometric_of_lt_one {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) :
HasSum (fun n : ℕ ↦ r ^ n) (1 - r)⁻¹ :=
have : r ≠ 1 := ne_of_lt h₂
have : Tendsto (fun n ↦ (r ^ n - 1) * (r - 1)⁻¹) atTop (𝓝 ((0 - 1) * (r - 1)⁻¹)) :=
((tendsto_pow_atTop_nhds_zero_of_lt_one h₁ h₂).sub tendsto_const_nhds).mul tendsto_const_nhds
(hasSum_iff_tendsto_nat_of_nonneg (pow_nonneg h₁) _).mpr <| by
simp_all [neg_inv, geom_sum_eq, div_eq_mul_inv]
theorem summable_geometric_of_lt_one {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) :
Summable fun n : ℕ ↦ r ^ n :=
⟨_, hasSum_geometric_of_lt_one h₁ h₂⟩
theorem tsum_geometric_of_lt_one {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) : ∑' n : ℕ, r ^ n = (1 - r)⁻¹ :=
(hasSum_geometric_of_lt_one h₁ h₂).tsum_eq
theorem hasSum_geometric_two : HasSum (fun n : ℕ ↦ ((1 : ℝ) / 2) ^ n) 2 := by
convert hasSum_geometric_of_lt_one _ _ <;> norm_num
theorem summable_geometric_two : Summable fun n : ℕ ↦ ((1 : ℝ) / 2) ^ n :=
⟨_, hasSum_geometric_two⟩
theorem summable_geometric_two_encode {ι : Type*} [Encodable ι] :
Summable fun i : ι ↦ (1 / 2 : ℝ) ^ Encodable.encode i :=
summable_geometric_two.comp_injective Encodable.encode_injective
theorem tsum_geometric_two : (∑' n : ℕ, ((1 : ℝ) / 2) ^ n) = 2 :=
hasSum_geometric_two.tsum_eq
theorem sum_geometric_two_le (n : ℕ) : (∑ i ∈ range n, (1 / (2 : ℝ)) ^ i) ≤ 2 := by
have : ∀ i, 0 ≤ (1 / (2 : ℝ)) ^ i := by
intro i
apply pow_nonneg
norm_num
convert summable_geometric_two.sum_le_tsum (range n) (fun i _ ↦ this i)
exact tsum_geometric_two.symm
theorem tsum_geometric_inv_two : (∑' n : ℕ, (2 : ℝ)⁻¹ ^ n) = 2 :=
(inv_eq_one_div (2 : ℝ)).symm ▸ tsum_geometric_two
/-- The sum of `2⁻¹ ^ i` for `n ≤ i` equals `2 * 2⁻¹ ^ n`. -/
theorem tsum_geometric_inv_two_ge (n : ℕ) :
(∑' i, ite (n ≤ i) ((2 : ℝ)⁻¹ ^ i) 0) = 2 * 2⁻¹ ^ n := by
have A : Summable fun i : ℕ ↦ ite (n ≤ i) ((2⁻¹ : ℝ) ^ i) 0 := by
simpa only [← piecewise_eq_indicator, one_div]
using summable_geometric_two.indicator {i | n ≤ i}
have B : ((Finset.range n).sum fun i : ℕ ↦ ite (n ≤ i) ((2⁻¹ : ℝ) ^ i) 0) = 0 :=
Finset.sum_eq_zero fun i hi ↦
ite_eq_right_iff.2 fun h ↦ (lt_irrefl _ ((Finset.mem_range.1 hi).trans_le h)).elim
simp only [← Summable.sum_add_tsum_nat_add n A, B, if_true, zero_add, zero_le',
le_add_iff_nonneg_left, pow_add, _root_.tsum_mul_right, tsum_geometric_inv_two]
theorem hasSum_geometric_two' (a : ℝ) : HasSum (fun n : ℕ ↦ a / 2 / 2 ^ n) a := by
convert HasSum.mul_left (a / 2)
(hasSum_geometric_of_lt_one (le_of_lt one_half_pos) one_half_lt_one) using 1
· funext n
simp only [one_div, inv_pow]
rfl
· norm_num
theorem summable_geometric_two' (a : ℝ) : Summable fun n : ℕ ↦ a / 2 / 2 ^ n :=
⟨a, hasSum_geometric_two' a⟩
theorem tsum_geometric_two' (a : ℝ) : ∑' n : ℕ, a / 2 / 2 ^ n = a :=
(hasSum_geometric_two' a).tsum_eq
/-- **Sum of a Geometric Series** -/
theorem NNReal.hasSum_geometric {r : ℝ≥0} (hr : r < 1) : HasSum (fun n : ℕ ↦ r ^ n) (1 - r)⁻¹ := by
apply NNReal.hasSum_coe.1
push_cast
rw [NNReal.coe_sub (le_of_lt hr)]
exact hasSum_geometric_of_lt_one r.coe_nonneg hr
theorem NNReal.summable_geometric {r : ℝ≥0} (hr : r < 1) : Summable fun n : ℕ ↦ r ^ n :=
⟨_, NNReal.hasSum_geometric hr⟩
theorem tsum_geometric_nnreal {r : ℝ≥0} (hr : r < 1) : ∑' n : ℕ, r ^ n = (1 - r)⁻¹ :=
(NNReal.hasSum_geometric hr).tsum_eq
/-- The series `pow r` converges to `(1-r)⁻¹`. For `r < 1` the RHS is a finite number,
and for `1 ≤ r` the RHS equals `∞`. -/
@[simp]
theorem ENNReal.tsum_geometric (r : ℝ≥0∞) : ∑' n : ℕ, r ^ n = (1 - r)⁻¹ := by
rcases lt_or_le r 1 with hr | hr
· rcases ENNReal.lt_iff_exists_coe.1 hr with ⟨r, rfl, hr'⟩
norm_cast at *
convert ENNReal.tsum_coe_eq (NNReal.hasSum_geometric hr)
rw [ENNReal.coe_inv <| ne_of_gt <| tsub_pos_iff_lt.2 hr, coe_sub, coe_one]
· rw [tsub_eq_zero_iff_le.mpr hr, ENNReal.inv_zero, ENNReal.tsum_eq_iSup_nat, iSup_eq_top]
refine fun a ha ↦
(ENNReal.exists_nat_gt (lt_top_iff_ne_top.1 ha)).imp fun n hn ↦ lt_of_lt_of_le hn ?_
calc
(n : ℝ≥0∞) = ∑ i ∈ range n, 1 := by rw [sum_const, nsmul_one, card_range]
_ ≤ ∑ i ∈ range n, r ^ i := by gcongr; apply one_le_pow₀ hr
theorem ENNReal.tsum_geometric_add_one (r : ℝ≥0∞) : ∑' n : ℕ, r ^ (n + 1) = r * (1 - r)⁻¹ := by
simp only [_root_.pow_succ', ENNReal.tsum_mul_left, ENNReal.tsum_geometric]
end Geometric
/-!
### Sequences with geometrically decaying distance in metric spaces
In this paragraph, we discuss sequences in metric spaces or emetric spaces for which the distance
between two consecutive terms decays geometrically. We show that such sequences are Cauchy
sequences, and bound their distances to the limit. We also discuss series with geometrically
decaying terms.
-/
section EdistLeGeometric
variable [PseudoEMetricSpace α] (r C : ℝ≥0∞) (hr : r < 1) (hC : C ≠ ⊤) {f : ℕ → α}
(hu : ∀ n, edist (f n) (f (n + 1)) ≤ C * r ^ n)
include hr hC hu in
/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, `C ≠ ∞`, `r < 1`,
then `f` is a Cauchy sequence. -/
theorem cauchySeq_of_edist_le_geometric : CauchySeq f := by
refine cauchySeq_of_edist_le_of_tsum_ne_top _ hu ?_
rw [ENNReal.tsum_mul_left, ENNReal.tsum_geometric]
refine ENNReal.mul_ne_top hC (ENNReal.inv_ne_top.2 ?_)
exact (tsub_pos_iff_lt.2 hr).ne'
include hu in
/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, then the distance from
`f n` to the limit of `f` is bounded above by `C * r^n / (1 - r)`. -/
theorem edist_le_of_edist_le_geometric_of_tendsto {a : α} (ha : Tendsto f atTop (𝓝 a)) (n : ℕ) :
edist (f n) a ≤ C * r ^ n / (1 - r) := by
convert edist_le_tsum_of_edist_le_of_tendsto _ hu ha _
simp only [pow_add, ENNReal.tsum_mul_left, ENNReal.tsum_geometric, div_eq_mul_inv, mul_assoc]
include hu in
/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, then the distance from
`f 0` to the limit of `f` is bounded above by `C / (1 - r)`. -/
theorem edist_le_of_edist_le_geometric_of_tendsto₀ {a : α} (ha : Tendsto f atTop (𝓝 a)) :
edist (f 0) a ≤ C / (1 - r) := by
simpa only [_root_.pow_zero, mul_one] using edist_le_of_edist_le_geometric_of_tendsto r C hu ha 0
end EdistLeGeometric
section EdistLeGeometricTwo
variable [PseudoEMetricSpace α] (C : ℝ≥0∞) (hC : C ≠ ⊤) {f : ℕ → α}
(hu : ∀ n, edist (f n) (f (n + 1)) ≤ C / 2 ^ n) {a : α} (ha : Tendsto f atTop (𝓝 a))
include hC hu in
/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then `f` is a Cauchy sequence. -/
theorem cauchySeq_of_edist_le_geometric_two : CauchySeq f := by
simp only [div_eq_mul_inv, ENNReal.inv_pow] at hu
refine cauchySeq_of_edist_le_geometric 2⁻¹ C ?_ hC hu
simp [ENNReal.one_lt_two]
include hu ha in
/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then the distance from
`f n` to the limit of `f` is bounded above by `2 * C * 2^-n`. -/
theorem edist_le_of_edist_le_geometric_two_of_tendsto (n : ℕ) : edist (f n) a ≤ 2 * C / 2 ^ n := by
simp only [div_eq_mul_inv, ENNReal.inv_pow] at *
rw [mul_assoc, mul_comm]
convert edist_le_of_edist_le_geometric_of_tendsto 2⁻¹ C hu ha n using 1
rw [ENNReal.one_sub_inv_two, div_eq_mul_inv, inv_inv]
include hu ha in
/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then the distance from
`f 0` to the limit of `f` is bounded above by `2 * C`. -/
theorem edist_le_of_edist_le_geometric_two_of_tendsto₀ : edist (f 0) a ≤ 2 * C := by
simpa only [_root_.pow_zero, div_eq_mul_inv, inv_one, mul_one] using
edist_le_of_edist_le_geometric_two_of_tendsto C hu ha 0
end EdistLeGeometricTwo
section LeGeometric
variable [PseudoMetricSpace α] {r C : ℝ} {f : ℕ → α}
section
variable (hr : r < 1) (hu : ∀ n, dist (f n) (f (n + 1)) ≤ C * r ^ n)
include hr hu
/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then `f` is a Cauchy sequence. -/
theorem aux_hasSum_of_le_geometric : HasSum (fun n : ℕ ↦ C * r ^ n) (C / (1 - r)) := by
rcases sign_cases_of_C_mul_pow_nonneg fun n ↦ dist_nonneg.trans (hu n) with (rfl | ⟨_, r₀⟩)
· simp [hasSum_zero]
· refine HasSum.mul_left C ?_
simpa using hasSum_geometric_of_lt_one r₀ hr
variable (r C)
/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then `f` is a Cauchy sequence.
Note that this lemma does not assume `0 ≤ C` or `0 ≤ r`. -/
theorem cauchySeq_of_le_geometric : CauchySeq f :=
cauchySeq_of_dist_le_of_summable _ hu ⟨_, aux_hasSum_of_le_geometric hr hu⟩
/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then the distance from
`f n` to the limit of `f` is bounded above by `C * r^n / (1 - r)`. -/
theorem dist_le_of_le_geometric_of_tendsto₀ {a : α} (ha : Tendsto f atTop (𝓝 a)) :
dist (f 0) a ≤ C / (1 - r) :=
(aux_hasSum_of_le_geometric hr hu).tsum_eq ▸
dist_le_tsum_of_dist_le_of_tendsto₀ _ hu ⟨_, aux_hasSum_of_le_geometric hr hu⟩ ha
/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then the distance from
`f 0` to the limit of `f` is bounded above by `C / (1 - r)`. -/
theorem dist_le_of_le_geometric_of_tendsto {a : α} (ha : Tendsto f atTop (𝓝 a)) (n : ℕ) :
dist (f n) a ≤ C * r ^ n / (1 - r) := by
have := aux_hasSum_of_le_geometric hr hu
convert dist_le_tsum_of_dist_le_of_tendsto _ hu ⟨_, this⟩ ha n
simp only [pow_add, mul_left_comm C, mul_div_right_comm]
rw [mul_comm]
exact (this.mul_left _).tsum_eq.symm
end
variable (hu₂ : ∀ n, dist (f n) (f (n + 1)) ≤ C / 2 / 2 ^ n)
include hu₂
/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then `f` is a Cauchy sequence. -/
theorem cauchySeq_of_le_geometric_two : CauchySeq f :=
cauchySeq_of_dist_le_of_summable _ hu₂ <| ⟨_, hasSum_geometric_two' C⟩
/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then the distance from
`f 0` to the limit of `f` is bounded above by `C`. -/
theorem dist_le_of_le_geometric_two_of_tendsto₀ {a : α} (ha : Tendsto f atTop (𝓝 a)) :
dist (f 0) a ≤ C :=
tsum_geometric_two' C ▸ dist_le_tsum_of_dist_le_of_tendsto₀ _ hu₂ (summable_geometric_two' C) ha
/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then the distance from
`f n` to the limit of `f` is bounded above by `C / 2^n`. -/
theorem dist_le_of_le_geometric_two_of_tendsto {a : α} (ha : Tendsto f atTop (𝓝 a)) (n : ℕ) :
dist (f n) a ≤ C / 2 ^ n := by
convert dist_le_tsum_of_dist_le_of_tendsto _ hu₂ (summable_geometric_two' C) ha n
simp only [add_comm n, pow_add, ← div_div]
symm
exact ((hasSum_geometric_two' C).div_const _).tsum_eq
end LeGeometric
/-! ### Summability tests based on comparison with geometric series -/
/-- A series whose terms are bounded by the terms of a converging geometric series converges. -/
theorem summable_one_div_pow_of_le {m : ℝ} {f : ℕ → ℕ} (hm : 1 < m) (fi : ∀ i, i ≤ f i) :
Summable fun i ↦ 1 / m ^ f i := by
refine .of_nonneg_of_le (fun a ↦ by positivity) (fun a ↦ ?_)
(summable_geometric_of_lt_one (one_div_nonneg.mpr (zero_le_one.trans hm.le))
((one_div_lt (zero_lt_one.trans hm) zero_lt_one).mpr (one_div_one.le.trans_lt hm)))
rw [div_pow, one_pow]
refine (one_div_le_one_div ?_ ?_).mpr (pow_right_mono₀ hm.le (fi a)) <;>
exact pow_pos (zero_lt_one.trans hm) _
/-! ### Positive sequences with small sums on countable types -/
/-- For any positive `ε`, define on an encodable type a positive sequence with sum less than `ε` -/
def posSumOfEncodable {ε : ℝ} (hε : 0 < ε) (ι) [Encodable ι] :
{ ε' : ι → ℝ // (∀ i, 0 < ε' i) ∧ ∃ c, HasSum ε' c ∧ c ≤ ε } := by
let f n := ε / 2 / 2 ^ n
have hf : HasSum f ε := hasSum_geometric_two' _
have f0 : ∀ n, 0 < f n := fun n ↦ div_pos (half_pos hε) (pow_pos zero_lt_two _)
refine ⟨f ∘ Encodable.encode, fun i ↦ f0 _, ?_⟩
rcases hf.summable.comp_injective (@Encodable.encode_injective ι _) with ⟨c, hg⟩
refine ⟨c, hg, hasSum_le_inj _ (@Encodable.encode_injective ι _) ?_ ?_ hg hf⟩
· intro i _
exact le_of_lt (f0 _)
· intro n
exact le_rfl
theorem Set.Countable.exists_pos_hasSum_le {ι : Type*} {s : Set ι} (hs : s.Countable) {ε : ℝ}
(hε : 0 < ε) : ∃ ε' : ι → ℝ, (∀ i, 0 < ε' i) ∧ ∃ c, HasSum (fun i : s ↦ ε' i) c ∧ c ≤ ε := by
classical
haveI := hs.toEncodable
rcases posSumOfEncodable hε s with ⟨f, hf0, ⟨c, hfc, hcε⟩⟩
refine ⟨fun i ↦ if h : i ∈ s then f ⟨i, h⟩ else 1, fun i ↦ ?_, ⟨c, ?_, hcε⟩⟩
· conv_rhs => simp
split_ifs
exacts [hf0 _, zero_lt_one]
· simpa only [Subtype.coe_prop, dif_pos, Subtype.coe_eta]
theorem Set.Countable.exists_pos_forall_sum_le {ι : Type*} {s : Set ι} (hs : s.Countable) {ε : ℝ}
(hε : 0 < ε) : ∃ ε' : ι → ℝ,
(∀ i, 0 < ε' i) ∧ ∀ t : Finset ι, ↑t ⊆ s → ∑ i ∈ t, ε' i ≤ ε := by
classical
rcases hs.exists_pos_hasSum_le hε with ⟨ε', hpos, c, hε'c, hcε⟩
refine ⟨ε', hpos, fun t ht ↦ ?_⟩
rw [← sum_subtype_of_mem _ ht]
refine (sum_le_hasSum _ ?_ hε'c).trans hcε
exact fun _ _ ↦ (hpos _).le
namespace NNReal
theorem exists_pos_sum_of_countable {ε : ℝ≥0} (hε : ε ≠ 0) (ι) [Countable ι] :
∃ ε' : ι → ℝ≥0, (∀ i, 0 < ε' i) ∧ ∃ c, HasSum ε' c ∧ c < ε := by
cases nonempty_encodable ι
obtain ⟨a, a0, aε⟩ := exists_between (pos_iff_ne_zero.2 hε)
obtain ⟨ε', hε', c, hc, hcε⟩ := posSumOfEncodable a0 ι
exact
⟨fun i ↦ ⟨ε' i, (hε' i).le⟩, fun i ↦ NNReal.coe_lt_coe.1 <| hε' i,
⟨c, hasSum_le (fun i ↦ (hε' i).le) hasSum_zero hc⟩, NNReal.hasSum_coe.1 hc,
aε.trans_le' <| NNReal.coe_le_coe.1 hcε⟩
end NNReal
namespace ENNReal
theorem exists_pos_sum_of_countable {ε : ℝ≥0∞} (hε : ε ≠ 0) (ι) [Countable ι] :
∃ ε' : ι → ℝ≥0, (∀ i, 0 < ε' i) ∧ (∑' i, (ε' i : ℝ≥0∞)) < ε := by
rcases exists_between (pos_iff_ne_zero.2 hε) with ⟨r, h0r, hrε⟩
rcases lt_iff_exists_coe.1 hrε with ⟨x, rfl, _⟩
rcases NNReal.exists_pos_sum_of_countable (coe_pos.1 h0r).ne' ι with ⟨ε', hp, c, hc, hcr⟩
exact ⟨ε', hp, (ENNReal.tsum_coe_eq hc).symm ▸ lt_trans (coe_lt_coe.2 hcr) hrε⟩
theorem exists_pos_sum_of_countable' {ε : ℝ≥0∞} (hε : ε ≠ 0) (ι) [Countable ι] :
∃ ε' : ι → ℝ≥0∞, (∀ i, 0 < ε' i) ∧ ∑' i, ε' i < ε :=
let ⟨δ, δpos, hδ⟩ := exists_pos_sum_of_countable hε ι
⟨fun i ↦ δ i, fun i ↦ ENNReal.coe_pos.2 (δpos i), hδ⟩
theorem exists_pos_tsum_mul_lt_of_countable {ε : ℝ≥0∞} (hε : ε ≠ 0) {ι} [Countable ι] (w : ι → ℝ≥0∞)
(hw : ∀ i, w i ≠ ∞) : ∃ δ : ι → ℝ≥0, (∀ i, 0 < δ i) ∧ (∑' i, (w i * δ i : ℝ≥0∞)) < ε := by
lift w to ι → ℝ≥0 using hw
rcases exists_pos_sum_of_countable hε ι with ⟨δ', Hpos, Hsum⟩
have : ∀ i, 0 < max 1 (w i) := fun i ↦ zero_lt_one.trans_le (le_max_left _ _)
refine ⟨fun i ↦ δ' i / max 1 (w i), fun i ↦ div_pos (Hpos _) (this i), ?_⟩
refine lt_of_le_of_lt (ENNReal.tsum_le_tsum fun i ↦ ?_) Hsum
rw [coe_div (this i).ne']
refine mul_le_of_le_div' (mul_le_mul_left' (ENNReal.inv_le_inv.2 ?_) _)
exact coe_le_coe.2 (le_max_right _ _)
end ENNReal
/-!
### Factorial
-/
theorem factorial_tendsto_atTop : Tendsto Nat.factorial atTop atTop :=
tendsto_atTop_atTop_of_monotone (fun _ _ ↦ Nat.factorial_le) fun n ↦ ⟨n, n.self_le_factorial⟩
theorem tendsto_factorial_div_pow_self_atTop :
Tendsto (fun n ↦ n ! / (n : ℝ) ^ n : ℕ → ℝ) atTop (𝓝 0) :=
tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds
(tendsto_const_div_atTop_nhds_zero_nat 1)
(Eventually.of_forall fun n ↦
div_nonneg (mod_cast n.factorial_pos.le)
(pow_nonneg (mod_cast n.zero_le) _))
(by
refine (eventually_gt_atTop 0).mono fun n hn ↦ ?_
rcases Nat.exists_eq_succ_of_ne_zero hn.ne.symm with ⟨k, rfl⟩
rw [← prod_range_add_one_eq_factorial, pow_eq_prod_const, div_eq_mul_inv, ← inv_eq_one_div,
prod_natCast, Nat.cast_succ, ← Finset.prod_inv_distrib, ← prod_mul_distrib,
Finset.prod_range_succ']
simp only [prod_range_succ', one_mul, Nat.cast_add, zero_add, Nat.cast_one]
refine
mul_le_of_le_one_left (inv_nonneg.mpr <| mod_cast hn.le) (prod_le_one ?_ ?_) <;>
intro x hx <;>
rw [Finset.mem_range] at hx
· positivity
· refine (div_le_one <| mod_cast hn).mpr ?_
norm_cast
omega)
/-!
### Ceil and floor
-/
section
theorem tendsto_nat_floor_atTop {α : Type*}
[Semiring α] [LinearOrder α] [IsStrictOrderedRing α] [FloorSemiring α] :
Tendsto (fun x : α ↦ ⌊x⌋₊) atTop atTop :=
Nat.floor_mono.tendsto_atTop_atTop fun x ↦ ⟨max 0 (x + 1), by simp [Nat.le_floor_iff]⟩
lemma tendsto_nat_ceil_atTop {α : Type*}
[Semiring α] [LinearOrder α] [IsStrictOrderedRing α] [FloorSemiring α] :
Tendsto (fun x : α ↦ ⌈x⌉₊) atTop atTop := by
refine Nat.ceil_mono.tendsto_atTop_atTop (fun x ↦ ⟨x, ?_⟩)
simp only [Nat.ceil_natCast, le_refl]
lemma tendsto_nat_floor_mul_atTop {α : Type _}
[Semifield α] [LinearOrder α] [IsStrictOrderedRing α] [FloorSemiring α]
[Archimedean α] (a : α) (ha : 0 < a) : Tendsto (fun (x : ℕ) => ⌊a * x⌋₊) atTop atTop :=
Tendsto.comp tendsto_nat_floor_atTop
<| Tendsto.const_mul_atTop ha tendsto_natCast_atTop_atTop
variable {R : Type*} [TopologicalSpace R] [Field R] [LinearOrder R] [IsStrictOrderedRing R]
[OrderTopology R] [FloorRing R]
theorem tendsto_nat_floor_mul_div_atTop {a : R} (ha : 0 ≤ a) :
Tendsto (fun x ↦ (⌊a * x⌋₊ : R) / x) atTop (𝓝 a) := by
have A : Tendsto (fun x : R ↦ a - x⁻¹) atTop (𝓝 (a - 0)) :=
tendsto_const_nhds.sub tendsto_inv_atTop_zero
rw [sub_zero] at A
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' A tendsto_const_nhds
· refine eventually_atTop.2 ⟨1, fun x hx ↦ ?_⟩
simp only [le_div_iff₀ (zero_lt_one.trans_le hx), _root_.sub_mul,
inv_mul_cancel₀ (zero_lt_one.trans_le hx).ne']
have := Nat.lt_floor_add_one (a * x)
linarith
· refine eventually_atTop.2 ⟨1, fun x hx ↦ ?_⟩
rw [div_le_iff₀ (zero_lt_one.trans_le hx)]
simp [Nat.floor_le (mul_nonneg ha (zero_le_one.trans hx))]
theorem tendsto_nat_floor_div_atTop : Tendsto (fun x ↦ (⌊x⌋₊ : R) / x) atTop (𝓝 1) := by
simpa using tendsto_nat_floor_mul_div_atTop (zero_le_one' R)
theorem tendsto_nat_ceil_mul_div_atTop {a : R} (ha : 0 ≤ a) :
Tendsto (fun x ↦ (⌈a * x⌉₊ : R) / x) atTop (𝓝 a) := by
have A : Tendsto (fun x : R ↦ a + x⁻¹) atTop (𝓝 (a + 0)) :=
tendsto_const_nhds.add tendsto_inv_atTop_zero
rw [add_zero] at A
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds A
· refine eventually_atTop.2 ⟨1, fun x hx ↦ ?_⟩
rw [le_div_iff₀ (zero_lt_one.trans_le hx)]
exact Nat.le_ceil _
· refine eventually_atTop.2 ⟨1, fun x hx ↦ ?_⟩
simp [div_le_iff₀ (zero_lt_one.trans_le hx), inv_mul_cancel₀ (zero_lt_one.trans_le hx).ne',
(Nat.ceil_lt_add_one (mul_nonneg ha (zero_le_one.trans hx))).le, add_mul]
| Mathlib/Analysis/SpecificLimits/Basic.lean | 709 | 710 | theorem tendsto_nat_ceil_div_atTop : Tendsto (fun x ↦ (⌈x⌉₊ : R) / x) atTop (𝓝 1) := by | simpa using tendsto_nat_ceil_mul_div_atTop (zero_le_one' R) |
/-
Copyright (c) 2023 Xavier Roblot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Xavier Roblot
-/
import Mathlib.Analysis.SpecialFunctions.PolarCoord
import Mathlib.Analysis.SpecialFunctions.Gamma.Basic
/-!
# Integrals involving the Gamma function
In this file, we collect several integrals over `ℝ` or `ℂ` that evaluate in terms of the
`Real.Gamma` function.
-/
open Real Set MeasureTheory MeasureTheory.Measure
section real
theorem integral_rpow_mul_exp_neg_rpow {p q : ℝ} (hp : 0 < p) (hq : -1 < q) :
∫ x in Ioi (0 : ℝ), x ^ q * exp (- x ^ p) = (1 / p) * Gamma ((q + 1) / p) := by
calc
_ = ∫ (x : ℝ) in Ioi 0, (1 / p * x ^ (1 / p - 1)) • ((x ^ (1 / p)) ^ q * exp (-x)) := by
rw [← integral_comp_rpow_Ioi _ (one_div_ne_zero (ne_of_gt hp)),
abs_eq_self.mpr (le_of_lt (one_div_pos.mpr hp))]
refine setIntegral_congr_fun measurableSet_Ioi (fun _ hx => ?_)
rw [← rpow_mul (le_of_lt hx) _ p, one_div_mul_cancel (ne_of_gt hp), rpow_one]
_ = ∫ (x : ℝ) in Ioi 0, 1 / p * exp (-x) * x ^ (1 / p - 1 + q / p) := by
simp_rw [smul_eq_mul, mul_assoc]
refine setIntegral_congr_fun measurableSet_Ioi (fun _ hx => ?_)
rw [← rpow_mul (le_of_lt hx), div_mul_eq_mul_div, one_mul, rpow_add hx]
ring_nf
_ = (1 / p) * Gamma ((q + 1) / p) := by
rw [Gamma_eq_integral (div_pos (neg_lt_iff_pos_add.mp hq) hp)]
simp_rw [show 1 / p - 1 + q / p = (q + 1) / p - 1 by field_simp; ring, ← integral_const_mul,
← mul_assoc]
| Mathlib/MeasureTheory/Integral/Gamma.lean | 39 | 57 | theorem integral_rpow_mul_exp_neg_mul_rpow {p q b : ℝ} (hp : 0 < p) (hq : -1 < q) (hb : 0 < b) :
∫ x in Ioi (0 : ℝ), x ^ q * exp (- b * x ^ p) =
b ^ (-(q + 1) / p) * (1 / p) * Gamma ((q + 1) / p) := by | calc
_ = ∫ x in Ioi (0 : ℝ), b ^ (-p⁻¹ * q) * ((b ^ p⁻¹ * x) ^ q * rexp (-(b ^ p⁻¹ * x) ^ p)) := by
refine setIntegral_congr_fun measurableSet_Ioi (fun _ hx => ?_)
rw [mul_rpow _ (le_of_lt hx), mul_rpow _ (le_of_lt hx), ← rpow_mul, ← rpow_mul,
inv_mul_cancel₀, rpow_one, mul_assoc, ← mul_assoc, ← rpow_add, neg_mul p⁻¹, neg_add_cancel,
rpow_zero, one_mul, neg_mul]
all_goals positivity
_ = (b ^ p⁻¹)⁻¹ * ∫ x in Ioi (0 : ℝ), b ^ (-p⁻¹ * q) * (x ^ q * rexp (-x ^ p)) := by
rw [integral_comp_mul_left_Ioi (fun x => b ^ (-p⁻¹ * q) * (x ^ q * exp (- x ^ p))) 0,
mul_zero, smul_eq_mul]
all_goals positivity
_ = b ^ (-(q + 1) / p) * (1 / p) * Gamma ((q + 1) / p) := by
rw [integral_const_mul, integral_rpow_mul_exp_neg_rpow _ hq, mul_assoc, ← mul_assoc,
← rpow_neg_one, ← rpow_mul, ← rpow_add]
· congr; ring
all_goals positivity |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.MeasureTheory.MeasurableSpace.MeasurablyGenerated
import Mathlib.MeasureTheory.Measure.NullMeasurable
import Mathlib.Order.Interval.Set.Monotone
/-!
# Measure spaces
The definition of a measure and a measure space are in `MeasureTheory.MeasureSpaceDef`, with
only a few basic properties. This file provides many more properties of these objects.
This separation allows the measurability tactic to import only the file `MeasureSpaceDef`, and to
be available in `MeasureSpace` (through `MeasurableSpace`).
Given a measurable space `α`, a measure on `α` is a function that sends measurable sets to the
extended nonnegative reals that satisfies the following conditions:
1. `μ ∅ = 0`;
2. `μ` is countably additive. This means that the measure of a countable union of pairwise disjoint
sets is equal to the measure of the individual sets.
Every measure can be canonically extended to an outer measure, so that it assigns values to
all subsets, not just the measurable subsets. On the other hand, a measure that is countably
additive on measurable sets can be restricted to measurable sets to obtain a measure.
In this file a measure is defined to be an outer measure that is countably additive on
measurable sets, with the additional assumption that the outer measure is the canonical
extension of the restricted measure.
Measures on `α` form a complete lattice, and are closed under scalar multiplication with `ℝ≥0∞`.
Given a measure, the null sets are the sets where `μ s = 0`, where `μ` denotes the corresponding
outer measure (so `s` might not be measurable). We can then define the completion of `μ` as the
measure on the least `σ`-algebra that also contains all null sets, by defining the measure to be `0`
on the null sets.
## Main statements
* `completion` is the completion of a measure to all null measurable sets.
* `Measure.ofMeasurable` and `OuterMeasure.toMeasure` are two important ways to define a measure.
## Implementation notes
Given `μ : Measure α`, `μ s` is the value of the *outer measure* applied to `s`.
This conveniently allows us to apply the measure to sets without proving that they are measurable.
We get countable subadditivity for all sets, but only countable additivity for measurable sets.
You often don't want to define a measure via its constructor.
Two ways that are sometimes more convenient:
* `Measure.ofMeasurable` is a way to define a measure by only giving its value on measurable sets
and proving the properties (1) and (2) mentioned above.
* `OuterMeasure.toMeasure` is a way of obtaining a measure from an outer measure by showing that
all measurable sets in the measurable space are Carathéodory measurable.
To prove that two measures are equal, there are multiple options:
* `ext`: two measures are equal if they are equal on all measurable sets.
* `ext_of_generateFrom_of_iUnion`: two measures are equal if they are equal on a π-system generating
the measurable sets, if the π-system contains a spanning increasing sequence of sets where the
measures take finite value (in particular the measures are σ-finite). This is a special case of
the more general `ext_of_generateFrom_of_cover`
* `ext_of_generate_finite`: two finite measures are equal if they are equal on a π-system
generating the measurable sets. This is a special case of `ext_of_generateFrom_of_iUnion` using
`C ∪ {univ}`, but is easier to work with.
A `MeasureSpace` is a class that is a measurable space with a canonical measure.
The measure is denoted `volume`.
## References
* <https://en.wikipedia.org/wiki/Measure_(mathematics)>
* <https://en.wikipedia.org/wiki/Complete_measure>
* <https://en.wikipedia.org/wiki/Almost_everywhere>
## Tags
measure, almost everywhere, measure space, completion, null set, null measurable set
-/
noncomputable section
open Set
open Filter hiding map
open Function MeasurableSpace Topology Filter ENNReal NNReal Interval MeasureTheory
open scoped symmDiff
variable {α β γ δ ι R R' : Type*}
namespace MeasureTheory
section
variable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α}
instance ae_isMeasurablyGenerated : IsMeasurablyGenerated (ae μ) :=
⟨fun _s hs =>
let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs
⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩
/-- See also `MeasureTheory.ae_restrict_uIoc_iff`. -/
theorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :
(∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by
simp only [uIoc_eq_union, mem_union, or_imp, eventually_and]
theorem measure_union (hd : Disjoint s₁ s₂) (h : MeasurableSet s₂) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀ h.nullMeasurableSet hd.aedisjoint
theorem measure_union' (hd : Disjoint s₁ s₂) (h : MeasurableSet s₁) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀' h.nullMeasurableSet hd.aedisjoint
theorem measure_inter_add_diff (s : Set α) (ht : MeasurableSet t) : μ (s ∩ t) + μ (s \ t) = μ s :=
measure_inter_add_diff₀ _ ht.nullMeasurableSet
theorem measure_diff_add_inter (s : Set α) (ht : MeasurableSet t) : μ (s \ t) + μ (s ∩ t) = μ s :=
(add_comm _ _).trans (measure_inter_add_diff s ht)
theorem measure_diff_eq_top (hs : μ s = ∞) (ht : μ t ≠ ∞) : μ (s \ t) = ∞ := by
contrapose! hs
exact ((measure_mono (subset_diff_union s t)).trans_lt
((measure_union_le _ _).trans_lt (ENNReal.add_lt_top.2 ⟨hs.lt_top, ht.lt_top⟩))).ne
theorem measure_union_add_inter (s : Set α) (ht : MeasurableSet t) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [← measure_inter_add_diff (s ∪ t) ht, Set.union_inter_cancel_right, union_diff_right, ←
measure_inter_add_diff s ht]
ac_rfl
theorem measure_union_add_inter' (hs : MeasurableSet s) (t : Set α) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm]
lemma measure_symmDiff_eq (hs : NullMeasurableSet s μ) (ht : NullMeasurableSet t μ) :
μ (s ∆ t) = μ (s \ t) + μ (t \ s) := by
simpa only [symmDiff_def, sup_eq_union]
using measure_union₀ (ht.diff hs) disjoint_sdiff_sdiff.aedisjoint
lemma measure_symmDiff_le (s t u : Set α) :
μ (s ∆ u) ≤ μ (s ∆ t) + μ (t ∆ u) :=
le_trans (μ.mono <| symmDiff_triangle s t u) (measure_union_le (s ∆ t) (t ∆ u))
theorem measure_symmDiff_eq_top (hs : μ s ≠ ∞) (ht : μ t = ∞) : μ (s ∆ t) = ∞ :=
measure_mono_top subset_union_right (measure_diff_eq_top ht hs)
theorem measure_add_measure_compl (h : MeasurableSet s) : μ s + μ sᶜ = μ univ :=
measure_add_measure_compl₀ h.nullMeasurableSet
theorem measure_biUnion₀ {s : Set β} {f : β → Set α} (hs : s.Countable)
(hd : s.Pairwise (AEDisjoint μ on f)) (h : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) := by
haveI := hs.toEncodable
rw [biUnion_eq_iUnion]
exact measure_iUnion₀ (hd.on_injective Subtype.coe_injective fun x => x.2) fun x => h x x.2
theorem measure_biUnion {s : Set β} {f : β → Set α} (hs : s.Countable) (hd : s.PairwiseDisjoint f)
(h : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) :=
measure_biUnion₀ hs hd.aedisjoint fun b hb => (h b hb).nullMeasurableSet
theorem measure_sUnion₀ {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise (AEDisjoint μ))
(h : ∀ s ∈ S, NullMeasurableSet s μ) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion₀ hs hd h]
theorem measure_sUnion {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise Disjoint)
(h : ∀ s ∈ S, MeasurableSet s) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion hs hd h]
theorem measure_biUnion_finset₀ {s : Finset ι} {f : ι → Set α}
(hd : Set.Pairwise (↑s) (AEDisjoint μ on f)) (hm : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) := by
rw [← Finset.sum_attach, Finset.attach_eq_univ, ← tsum_fintype]
exact measure_biUnion₀ s.countable_toSet hd hm
theorem measure_biUnion_finset {s : Finset ι} {f : ι → Set α} (hd : PairwiseDisjoint (↑s) f)
(hm : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) :=
measure_biUnion_finset₀ hd.aedisjoint fun b hb => (hm b hb).nullMeasurableSet
/-- The measure of an a.e. disjoint union (even uncountable) of null-measurable sets is at least
the sum of the measures of the sets. -/
theorem tsum_meas_le_meas_iUnion_of_disjoint₀ {ι : Type*} {_ : MeasurableSpace α} (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, NullMeasurableSet (As i) μ)
(As_disj : Pairwise (AEDisjoint μ on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) := by
rw [ENNReal.tsum_eq_iSup_sum, iSup_le_iff]
intro s
simp only [← measure_biUnion_finset₀ (fun _i _hi _j _hj hij => As_disj hij) fun i _ => As_mble i]
gcongr
exact iUnion_subset fun _ ↦ Subset.rfl
/-- The measure of a disjoint union (even uncountable) of measurable sets is at least the sum of
the measures of the sets. -/
theorem tsum_meas_le_meas_iUnion_of_disjoint {ι : Type*} {_ : MeasurableSpace α} (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))
(As_disj : Pairwise (Disjoint on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) :=
tsum_meas_le_meas_iUnion_of_disjoint₀ μ (fun i ↦ (As_mble i).nullMeasurableSet)
(fun _ _ h ↦ Disjoint.aedisjoint (As_disj h))
/-- If `s` is a countable set, then the measure of its preimage can be found as the sum of measures
of the fibers `f ⁻¹' {y}`. -/
theorem tsum_measure_preimage_singleton {s : Set β} (hs : s.Countable) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑' b : s, μ (f ⁻¹' {↑b})) = μ (f ⁻¹' s) := by
rw [← Set.biUnion_preimage_singleton, measure_biUnion hs (pairwiseDisjoint_fiber f s) hf]
lemma measure_preimage_eq_zero_iff_of_countable {s : Set β} {f : α → β} (hs : s.Countable) :
μ (f ⁻¹' s) = 0 ↔ ∀ x ∈ s, μ (f ⁻¹' {x}) = 0 := by
rw [← biUnion_preimage_singleton, measure_biUnion_null_iff hs]
/-- If `s` is a `Finset`, then the measure of its preimage can be found as the sum of measures
of the fibers `f ⁻¹' {y}`. -/
theorem sum_measure_preimage_singleton (s : Finset β) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑ b ∈ s, μ (f ⁻¹' {b})) = μ (f ⁻¹' ↑s) := by
simp only [← measure_biUnion_finset (pairwiseDisjoint_fiber f s) hf,
Finset.set_biUnion_preimage_singleton]
@[simp] lemma sum_measure_singleton {s : Finset α} [MeasurableSingletonClass α] :
∑ x ∈ s, μ {x} = μ s := by
trans ∑ x ∈ s, μ (id ⁻¹' {x})
· simp
rw [sum_measure_preimage_singleton]
· simp
· simp
theorem measure_diff_null' (h : μ (s₁ ∩ s₂) = 0) : μ (s₁ \ s₂) = μ s₁ :=
measure_congr <| diff_ae_eq_self.2 h
theorem measure_add_diff (hs : NullMeasurableSet s μ) (t : Set α) :
μ s + μ (t \ s) = μ (s ∪ t) := by
rw [← measure_union₀' hs disjoint_sdiff_right.aedisjoint, union_diff_self]
theorem measure_diff' (s : Set α) (hm : NullMeasurableSet t μ) (h_fin : μ t ≠ ∞) :
μ (s \ t) = μ (s ∪ t) - μ t :=
ENNReal.eq_sub_of_add_eq h_fin <| by rw [add_comm, measure_add_diff hm, union_comm]
theorem measure_diff (h : s₂ ⊆ s₁) (h₂ : NullMeasurableSet s₂ μ) (h_fin : μ s₂ ≠ ∞) :
μ (s₁ \ s₂) = μ s₁ - μ s₂ := by rw [measure_diff' _ h₂ h_fin, union_eq_self_of_subset_right h]
theorem le_measure_diff : μ s₁ - μ s₂ ≤ μ (s₁ \ s₂) :=
tsub_le_iff_left.2 <| (measure_le_inter_add_diff μ s₁ s₂).trans <| by
gcongr; apply inter_subset_right
/-- If the measure of the symmetric difference of two sets is finite,
then one has infinite measure if and only if the other one does. -/
theorem measure_eq_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s = ∞ ↔ μ t = ∞ := by
suffices h : ∀ u v, μ (u ∆ v) ≠ ∞ → μ u = ∞ → μ v = ∞
from ⟨h s t hμst, h t s (symmDiff_comm s t ▸ hμst)⟩
intro u v hμuv hμu
by_contra! hμv
apply hμuv
rw [Set.symmDiff_def, eq_top_iff]
calc
∞ = μ u - μ v := by rw [ENNReal.sub_eq_top_iff.2 ⟨hμu, hμv⟩]
_ ≤ μ (u \ v) := le_measure_diff
_ ≤ μ (u \ v ∪ v \ u) := measure_mono subset_union_left
/-- If the measure of the symmetric difference of two sets is finite,
then one has finite measure if and only if the other one does. -/
theorem measure_ne_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s ≠ ∞ ↔ μ t ≠ ∞ :=
(measure_eq_top_iff_of_symmDiff hμst).ne
theorem measure_diff_lt_of_lt_add (hs : NullMeasurableSet s μ) (hst : s ⊆ t) (hs' : μ s ≠ ∞)
{ε : ℝ≥0∞} (h : μ t < μ s + ε) : μ (t \ s) < ε := by
rw [measure_diff hst hs hs']; rw [add_comm] at h
exact ENNReal.sub_lt_of_lt_add (measure_mono hst) h
theorem measure_diff_le_iff_le_add (hs : NullMeasurableSet s μ) (hst : s ⊆ t) (hs' : μ s ≠ ∞)
{ε : ℝ≥0∞} : μ (t \ s) ≤ ε ↔ μ t ≤ μ s + ε := by
rw [measure_diff hst hs hs', tsub_le_iff_left]
theorem measure_eq_measure_of_null_diff {s t : Set α} (hst : s ⊆ t) (h_nulldiff : μ (t \ s) = 0) :
μ s = μ t := measure_congr <|
EventuallyLE.antisymm (HasSubset.Subset.eventuallyLE hst) (ae_le_set.mpr h_nulldiff)
theorem measure_eq_measure_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃)
(h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ ∧ μ s₂ = μ s₃ := by
have le12 : μ s₁ ≤ μ s₂ := measure_mono h12
have le23 : μ s₂ ≤ μ s₃ := measure_mono h23
have key : μ s₃ ≤ μ s₁ :=
calc
μ s₃ = μ (s₃ \ s₁ ∪ s₁) := by rw [diff_union_of_subset (h12.trans h23)]
_ ≤ μ (s₃ \ s₁) + μ s₁ := measure_union_le _ _
_ = μ s₁ := by simp only [h_nulldiff, zero_add]
exact ⟨le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)⟩
theorem measure_eq_measure_smaller_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)
(h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ :=
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).1
theorem measure_eq_measure_larger_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)
(h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₂ = μ s₃ :=
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2
lemma measure_compl₀ (h : NullMeasurableSet s μ) (hs : μ s ≠ ∞) :
μ sᶜ = μ Set.univ - μ s := by
rw [← measure_add_measure_compl₀ h, ENNReal.add_sub_cancel_left hs]
theorem measure_compl (h₁ : MeasurableSet s) (h_fin : μ s ≠ ∞) : μ sᶜ = μ univ - μ s :=
measure_compl₀ h₁.nullMeasurableSet h_fin
lemma measure_inter_conull' (ht : μ (s \ t) = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null']; rwa [← diff_eq]
lemma measure_inter_conull (ht : μ tᶜ = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null ht]
@[simp]
theorem union_ae_eq_left_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] s ↔ t ≤ᵐ[μ] s := by
rw [ae_le_set]
refine
⟨fun h => by simpa only [union_diff_left] using (ae_eq_set.mp h).1, fun h =>
eventuallyLE_antisymm_iff.mpr
⟨by rwa [ae_le_set, union_diff_left],
HasSubset.Subset.eventuallyLE subset_union_left⟩⟩
@[simp]
theorem union_ae_eq_right_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] t ↔ s ≤ᵐ[μ] t := by
rw [union_comm, union_ae_eq_left_iff_ae_subset]
theorem ae_eq_of_ae_subset_of_measure_ge (h₁ : s ≤ᵐ[μ] t) (h₂ : μ t ≤ μ s)
(hsm : NullMeasurableSet s μ) (ht : μ t ≠ ∞) : s =ᵐ[μ] t := by
refine eventuallyLE_antisymm_iff.mpr ⟨h₁, ae_le_set.mpr ?_⟩
replace h₂ : μ t = μ s := h₂.antisymm (measure_mono_ae h₁)
replace ht : μ s ≠ ∞ := h₂ ▸ ht
rw [measure_diff' t hsm ht, measure_congr (union_ae_eq_left_iff_ae_subset.mpr h₁), h₂, tsub_self]
/-- If `s ⊆ t`, `μ t ≤ μ s`, `μ t ≠ ∞`, and `s` is measurable, then `s =ᵐ[μ] t`. -/
theorem ae_eq_of_subset_of_measure_ge (h₁ : s ⊆ t) (h₂ : μ t ≤ μ s) (hsm : NullMeasurableSet s μ)
(ht : μ t ≠ ∞) : s =ᵐ[μ] t :=
ae_eq_of_ae_subset_of_measure_ge (HasSubset.Subset.eventuallyLE h₁) h₂ hsm ht
theorem measure_iUnion_congr_of_subset {ι : Sort*} [Countable ι] {s : ι → Set α} {t : ι → Set α}
(hsub : ∀ i, s i ⊆ t i) (h_le : ∀ i, μ (t i) ≤ μ (s i)) : μ (⋃ i, s i) = μ (⋃ i, t i) := by
refine le_antisymm (by gcongr; apply hsub) ?_
rcases Classical.em (∃ i, μ (t i) = ∞) with (⟨i, hi⟩ | htop)
· calc
μ (⋃ i, t i) ≤ ∞ := le_top
_ ≤ μ (s i) := hi ▸ h_le i
_ ≤ μ (⋃ i, s i) := measure_mono <| subset_iUnion _ _
push_neg at htop
set M := toMeasurable μ
have H : ∀ b, (M (t b) ∩ M (⋃ b, s b) : Set α) =ᵐ[μ] M (t b) := by
refine fun b => ae_eq_of_subset_of_measure_ge inter_subset_left ?_ ?_ ?_
· calc
μ (M (t b)) = μ (t b) := measure_toMeasurable _
_ ≤ μ (s b) := h_le b
_ ≤ μ (M (t b) ∩ M (⋃ b, s b)) :=
measure_mono <|
subset_inter ((hsub b).trans <| subset_toMeasurable _ _)
((subset_iUnion _ _).trans <| subset_toMeasurable _ _)
· measurability
· rw [measure_toMeasurable]
exact htop b
calc
μ (⋃ b, t b) ≤ μ (⋃ b, M (t b)) := measure_mono (iUnion_mono fun b => subset_toMeasurable _ _)
_ = μ (⋃ b, M (t b) ∩ M (⋃ b, s b)) := measure_congr (EventuallyEq.countable_iUnion H).symm
_ ≤ μ (M (⋃ b, s b)) := measure_mono (iUnion_subset fun b => inter_subset_right)
_ = μ (⋃ b, s b) := measure_toMeasurable _
theorem measure_union_congr_of_subset {t₁ t₂ : Set α} (hs : s₁ ⊆ s₂) (hsμ : μ s₂ ≤ μ s₁)
(ht : t₁ ⊆ t₂) (htμ : μ t₂ ≤ μ t₁) : μ (s₁ ∪ t₁) = μ (s₂ ∪ t₂) := by
rw [union_eq_iUnion, union_eq_iUnion]
exact measure_iUnion_congr_of_subset (Bool.forall_bool.2 ⟨ht, hs⟩) (Bool.forall_bool.2 ⟨htμ, hsμ⟩)
@[simp]
theorem measure_iUnion_toMeasurable {ι : Sort*} [Countable ι] (s : ι → Set α) :
μ (⋃ i, toMeasurable μ (s i)) = μ (⋃ i, s i) :=
Eq.symm <| measure_iUnion_congr_of_subset (fun _i => subset_toMeasurable _ _) fun _i ↦
(measure_toMeasurable _).le
theorem measure_biUnion_toMeasurable {I : Set β} (hc : I.Countable) (s : β → Set α) :
μ (⋃ b ∈ I, toMeasurable μ (s b)) = μ (⋃ b ∈ I, s b) := by
haveI := hc.toEncodable
simp only [biUnion_eq_iUnion, measure_iUnion_toMeasurable]
@[simp]
theorem measure_toMeasurable_union : μ (toMeasurable μ s ∪ t) = μ (s ∪ t) :=
Eq.symm <|
measure_union_congr_of_subset (subset_toMeasurable _ _) (measure_toMeasurable _).le Subset.rfl
le_rfl
@[simp]
theorem measure_union_toMeasurable : μ (s ∪ toMeasurable μ t) = μ (s ∪ t) :=
Eq.symm <|
measure_union_congr_of_subset Subset.rfl le_rfl (subset_toMeasurable _ _)
(measure_toMeasurable _).le
theorem sum_measure_le_measure_univ {s : Finset ι} {t : ι → Set α}
(h : ∀ i ∈ s, NullMeasurableSet (t i) μ) (H : Set.Pairwise s (AEDisjoint μ on t)) :
(∑ i ∈ s, μ (t i)) ≤ μ (univ : Set α) := by
rw [← measure_biUnion_finset₀ H h]
exact measure_mono (subset_univ _)
theorem tsum_measure_le_measure_univ {s : ι → Set α} (hs : ∀ i, NullMeasurableSet (s i) μ)
(H : Pairwise (AEDisjoint μ on s)) : ∑' i, μ (s i) ≤ μ (univ : Set α) := by
rw [ENNReal.tsum_eq_iSup_sum]
exact iSup_le fun s =>
sum_measure_le_measure_univ (fun i _hi => hs i) fun i _hi j _hj hij => H hij
/-- Pigeonhole principle for measure spaces: if `∑' i, μ (s i) > μ univ`, then
one of the intersections `s i ∩ s j` is not empty. -/
theorem exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : MeasurableSpace α}
(μ : Measure α) {s : ι → Set α} (hs : ∀ i, NullMeasurableSet (s i) μ)
(H : μ (univ : Set α) < ∑' i, μ (s i)) : ∃ i j, i ≠ j ∧ (s i ∩ s j).Nonempty := by
contrapose! H
apply tsum_measure_le_measure_univ hs
intro i j hij
exact (disjoint_iff_inter_eq_empty.mpr (H i j hij)).aedisjoint
/-- Pigeonhole principle for measure spaces: if `s` is a `Finset` and
`∑ i ∈ s, μ (t i) > μ univ`, then one of the intersections `t i ∩ t j` is not empty. -/
| Mathlib/MeasureTheory/Measure/MeasureSpace.lean | 409 | 413 | theorem exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : MeasurableSpace α} (μ : Measure α)
{s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, NullMeasurableSet (t i) μ)
(H : μ (univ : Set α) < ∑ i ∈ s, μ (t i)) :
∃ i ∈ s, ∃ j ∈ s, ∃ _h : i ≠ j, (t i ∩ t j).Nonempty := by | contrapose! H |
/-
Copyright (c) 2021 Apurva Nakade. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Apurva Nakade
-/
import Mathlib.Algebra.Algebra.Defs
import Mathlib.Algebra.Order.Group.Basic
import Mathlib.Algebra.Ring.Regular
import Mathlib.GroupTheory.MonoidLocalization.Away
import Mathlib.RingTheory.Localization.Defs
import Mathlib.SetTheory.Game.Birthday
import Mathlib.SetTheory.Surreal.Multiplication
import Mathlib.Tactic.Linarith
/-!
# Dyadic numbers
Dyadic numbers are obtained by localizing ℤ away from 2. They are the initial object in the category
of rings with no 2-torsion.
## Dyadic surreal numbers
We construct dyadic surreal numbers using the canonical map from ℤ[2 ^ {-1}] to surreals.
As we currently do not have a ring structure on `Surreal` we construct this map explicitly. Once we
have the ring structure, this map can be constructed directly by sending `2 ^ {-1}` to `half`.
## Embeddings
The above construction gives us an abelian group embedding of ℤ into `Surreal`. The goal is to
extend this to an embedding of dyadic rationals into `Surreal` and use Cauchy sequences of dyadic
rational numbers to construct an ordered field embedding of ℝ into `Surreal`.
-/
universe u
namespace SetTheory
namespace PGame
/-- For a natural number `n`, the pre-game `powHalf (n + 1)` is recursively defined as
`{0 | powHalf n}`. These are the explicit expressions of powers of `1 / 2`. By definition, we have
`powHalf 0 = 1` and `powHalf 1 ≈ 1 / 2` and we prove later on that
`powHalf (n + 1) + powHalf (n + 1) ≈ powHalf n`. -/
def powHalf : ℕ → PGame
| 0 => 1
| n + 1 => ⟨PUnit, PUnit, 0, fun _ => powHalf n⟩
@[simp]
theorem powHalf_zero : powHalf 0 = 1 :=
rfl
theorem powHalf_leftMoves (n) : (powHalf n).LeftMoves = PUnit := by cases n <;> rfl
theorem powHalf_zero_rightMoves : (powHalf 0).RightMoves = PEmpty :=
rfl
theorem powHalf_succ_rightMoves (n) : (powHalf (n + 1)).RightMoves = PUnit :=
rfl
@[simp]
theorem powHalf_moveLeft (n i) : (powHalf n).moveLeft i = 0 := by cases n <;> cases i <;> rfl
@[simp]
theorem powHalf_succ_moveRight (n i) : (powHalf (n + 1)).moveRight i = powHalf n :=
rfl
instance uniquePowHalfLeftMoves (n) : Unique (powHalf n).LeftMoves := by
cases n <;> exact PUnit.instUnique
instance isEmpty_powHalf_zero_rightMoves : IsEmpty (powHalf 0).RightMoves :=
inferInstanceAs (IsEmpty PEmpty)
instance uniquePowHalfSuccRightMoves (n) : Unique (powHalf (n + 1)).RightMoves :=
PUnit.instUnique
@[simp]
theorem birthday_half : birthday (powHalf 1) = 2 := by
rw [birthday_def]; simp
/-- For all natural numbers `n`, the pre-games `powHalf n` are numeric. -/
theorem numeric_powHalf (n) : (powHalf n).Numeric := by
induction n with
| zero => exact numeric_one
| succ n hn =>
constructor
· simpa using hn.moveLeft_lt default
· exact ⟨fun _ => numeric_zero, fun _ => hn⟩
theorem powHalf_succ_lt_powHalf (n : ℕ) : powHalf (n + 1) < powHalf n :=
(numeric_powHalf (n + 1)).lt_moveRight default
| Mathlib/SetTheory/Surreal/Dyadic.lean | 90 | 95 | theorem powHalf_succ_le_powHalf (n : ℕ) : powHalf (n + 1) ≤ powHalf n :=
(powHalf_succ_lt_powHalf n).le
theorem powHalf_le_one (n : ℕ) : powHalf n ≤ 1 := by | induction n with
| zero => exact le_rfl |
/-
Copyright (c) 2019 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Topology.Constructions
/-!
# Neighborhoods and continuity relative to a subset
This file develops API on the relative versions
* `nhdsWithin` of `nhds`
* `ContinuousOn` of `Continuous`
* `ContinuousWithinAt` of `ContinuousAt`
related to continuity, which are defined in previous definition files.
Their basic properties studied in this file include the relationships between
these restricted notions and the corresponding notions for the subtype
equipped with the subspace topology.
## Notation
* `𝓝 x`: the filter of neighborhoods of a point `x`;
* `𝓟 s`: the principal filter of a set `s`;
* `𝓝[s] x`: the filter `nhdsWithin x s` of neighborhoods of a point `x` within a set `s`.
-/
open Set Filter Function Topology Filter
variable {α β γ δ : Type*}
variable [TopologicalSpace α]
/-!
## Properties of the neighborhood-within filter
-/
@[simp]
theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a :=
bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl
@[simp]
theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x :=
Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x }
theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x :=
eventually_inf_principal
theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} :
(∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s :=
frequently_inf_principal.trans <| by simp only [and_comm]
theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} :
z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by
simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff]
@[simp]
theorem eventually_eventually_nhdsWithin {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by
refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩
simp only [eventually_nhdsWithin_iff] at h ⊢
exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs
@[simp]
theorem eventually_mem_nhdsWithin_iff {x : α} {s t : Set α} :
(∀ᶠ x' in 𝓝[s] x, t ∈ 𝓝[s] x') ↔ t ∈ 𝓝[s] x :=
eventually_eventually_nhdsWithin
theorem nhdsWithin_eq (a : α) (s : Set α) :
𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) :=
((nhds_basis_opens a).inf_principal s).eq_biInf
@[simp] lemma nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by
rw [nhdsWithin, principal_univ, inf_top_eq]
theorem nhdsWithin_hasBasis {ι : Sort*} {p : ι → Prop} {s : ι → Set α} {a : α}
(h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t :=
h.inf_principal t
theorem nhdsWithin_basis_open (a : α) (t : Set α) :
(𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t :=
nhdsWithin_hasBasis (nhds_basis_opens a) t
theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} :
t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by
simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff
theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} :
t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t :=
(nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff
theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) :
s \ t ∈ 𝓝[tᶜ] x :=
diff_mem_inf_principal_compl hs t
theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) :
s \ t' ∈ 𝓝[t \ t'] x := by
rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc]
exact inter_mem_inf hs (mem_principal_self _)
theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) :
t ∈ 𝓝 a := by
rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩
exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw
theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t :=
eventually_inf_principal
theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by
simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and]
theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t :=
set_eventuallyEq_iff_inf_principal.symm
theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x :=
set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal
theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t)
(hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) :
π ⁻¹' s ∈ 𝓝[t] a := by
lift a to t using h
replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs
rwa [← map_nhds_subtype_val, mem_map]
theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a :=
mem_inf_of_left h
theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a :=
mem_inf_of_right (mem_principal_self s)
theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s :=
self_mem_nhdsWithin
theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a :=
inter_mem self_mem_nhdsWithin (mem_inf_of_left h)
theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a :=
le_inf (pure_le_nhds a) (le_principal_iff.2 ha)
theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t :=
pure_le_nhdsWithin ha ht
theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α}
(h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x :=
mem_of_mem_nhdsWithin hx h
theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) :
Tendsto (fun _ : β => a) l (𝓝[s] a) :=
tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha
theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) :
𝓝[s] a = 𝓝[s ∩ t] a :=
le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h)))
(inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left))
theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict'' s <| mem_inf_of_left h
theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) :
𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀)
theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a :=
nhdsWithin_le_iff.mpr h
theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by
rw [← nhdsWithin_univ]
apply nhdsWithin_le_of_mem
exact univ_mem
theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) :
𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂]
theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s)
(h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by
rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂]
@[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a :=
inf_eq_left.trans le_principal_iff
theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a :=
nhdsWithin_eq_nhds.2 <| h.mem_nhds ha
theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t)
(ht : IsOpen t)
(hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) :
π ⁻¹' s ∈ 𝓝 a := by
rw [← ht.nhdsWithin_eq h]
exact preimage_nhdsWithin_coinduced' h hs
@[simp]
theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq]
theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by
delta nhdsWithin
rw [← inf_sup_left, sup_principal]
theorem nhds_eq_nhdsWithin_sup_nhdsWithin (b : α) {I₁ I₂ : Set α} (hI : Set.univ = I₁ ∪ I₂) :
nhds b = nhdsWithin b I₁ ⊔ nhdsWithin b I₂ := by
rw [← nhdsWithin_univ b, hI, nhdsWithin_union]
/-- If `L` and `R` are neighborhoods of `b` within sets whose union is `Set.univ`, then
`L ∪ R` is a neighborhood of `b`. -/
theorem union_mem_nhds_of_mem_nhdsWithin {b : α}
{I₁ I₂ : Set α} (h : Set.univ = I₁ ∪ I₂)
{L : Set α} (hL : L ∈ nhdsWithin b I₁)
{R : Set α} (hR : R ∈ nhdsWithin b I₂) : L ∪ R ∈ nhds b := by
rw [← nhdsWithin_univ b, h, nhdsWithin_union]
exact ⟨mem_of_superset hL (by simp), mem_of_superset hR (by simp)⟩
/-- Writing a punctured neighborhood filter as a sup of left and right filters. -/
lemma punctured_nhds_eq_nhdsWithin_sup_nhdsWithin [LinearOrder α] {x : α} :
𝓝[≠] x = 𝓝[<] x ⊔ 𝓝[>] x := by
rw [← Iio_union_Ioi, nhdsWithin_union]
/-- Obtain a "predictably-sided" neighborhood of `b` from two one-sided neighborhoods. -/
theorem nhds_of_Ici_Iic [LinearOrder α] {b : α}
{L : Set α} (hL : L ∈ 𝓝[≤] b)
{R : Set α} (hR : R ∈ 𝓝[≥] b) : L ∩ Iic b ∪ R ∩ Ici b ∈ 𝓝 b :=
union_mem_nhds_of_mem_nhdsWithin Iic_union_Ici.symm
(inter_mem hL self_mem_nhdsWithin) (inter_mem hR self_mem_nhdsWithin)
theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) :
𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := by
induction I, hI using Set.Finite.induction_on with
| empty => simp
| insert _ _ hT => simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert]
theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) :
𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by
rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS]
theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) :
𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by
rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range]
theorem nhdsWithin_inter (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓝[t] a := by
delta nhdsWithin
rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem]
theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by
delta nhdsWithin
rw [← inf_principal, inf_assoc]
theorem nhdsWithin_inter_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by
rw [nhdsWithin_inter, inf_eq_right]
exact nhdsWithin_le_of_mem h
theorem nhdsWithin_inter_of_mem' {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by
rw [inter_comm, nhdsWithin_inter_of_mem h]
@[simp]
theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by
rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)]
@[simp]
theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by
rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton]
theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by
simp
theorem insert_mem_nhdsWithin_insert {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) :
insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h]
theorem insert_mem_nhds_iff {a : α} {s : Set α} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[≠] a := by
simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left,
insert_def]
@[simp]
theorem nhdsNE_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by
rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ]
@[deprecated (since := "2025-03-02")]
alias nhdsWithin_compl_singleton_sup_pure := nhdsNE_sup_pure
@[simp]
theorem pure_sup_nhdsNE (a : α) : pure a ⊔ 𝓝[≠] a = 𝓝 a := by rw [← sup_comm, nhdsNE_sup_pure]
theorem nhdsWithin_prod [TopologicalSpace β]
{s u : Set α} {t v : Set β} {a : α} {b : β} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) :
u ×ˢ v ∈ 𝓝[s ×ˢ t] (a, b) := by
rw [nhdsWithin_prod_eq]
exact prod_mem_prod hu hv
lemma Filter.EventuallyEq.mem_interior {x : α} {s t : Set α} (hst : s =ᶠ[𝓝 x] t)
(h : x ∈ interior s) : x ∈ interior t := by
rw [← nhdsWithin_eq_iff_eventuallyEq] at hst
simpa [mem_interior_iff_mem_nhds, ← nhdsWithin_eq_nhds, hst] using h
lemma Filter.EventuallyEq.mem_interior_iff {x : α} {s t : Set α} (hst : s =ᶠ[𝓝 x] t) :
x ∈ interior s ↔ x ∈ interior t :=
⟨fun h ↦ hst.mem_interior h, fun h ↦ hst.symm.mem_interior h⟩
@[deprecated (since := "2024-11-11")]
alias EventuallyEq.mem_interior_iff := Filter.EventuallyEq.mem_interior_iff
section Pi
variable {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)]
theorem nhdsWithin_pi_eq' {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi I s] x = ⨅ i, comap (fun x => x i) (𝓝 (x i) ⊓ ⨅ (_ : i ∈ I), 𝓟 (s i)) := by
simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ←
iInf_principal_finite hI, ← iInf_inf_eq]
theorem nhdsWithin_pi_eq {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi I s] x =
(⨅ i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) ⊓
⨅ (i) (_ : i ∉ I), comap (fun x => x i) (𝓝 (x i)) := by
simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf,
comap_principal, eval]
rw [iInf_split _ fun i => i ∈ I, inf_right_comm]
simp only [iInf_inf_eq]
theorem nhdsWithin_pi_univ_eq [Finite ι] (s : ∀ i, Set (π i)) (x : ∀ i, π i) :
𝓝[pi univ s] x = ⨅ i, comap (fun x => x i) (𝓝[s i] x i) := by
simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x
theorem nhdsWithin_pi_eq_bot {I : Set ι} {s : ∀ i, Set (π i)} {x : ∀ i, π i} :
𝓝[pi I s] x = ⊥ ↔ ∃ i ∈ I, 𝓝[s i] x i = ⊥ := by
simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot]
theorem nhdsWithin_pi_neBot {I : Set ι} {s : ∀ i, Set (π i)} {x : ∀ i, π i} :
(𝓝[pi I s] x).NeBot ↔ ∀ i ∈ I, (𝓝[s i] x i).NeBot := by
simp [neBot_iff, nhdsWithin_pi_eq_bot]
instance instNeBotNhdsWithinUnivPi {s : ∀ i, Set (π i)} {x : ∀ i, π i}
[∀ i, (𝓝[s i] x i).NeBot] : (𝓝[pi univ s] x).NeBot := by
simpa [nhdsWithin_pi_neBot]
instance Pi.instNeBotNhdsWithinIio [Nonempty ι] [∀ i, Preorder (π i)] {x : ∀ i, π i}
[∀ i, (𝓝[<] x i).NeBot] : (𝓝[<] x).NeBot :=
have : (𝓝[pi univ fun i ↦ Iio (x i)] x).NeBot := inferInstance
this.mono <| nhdsWithin_mono _ fun _y hy ↦ lt_of_strongLT fun i ↦ hy i trivial
instance Pi.instNeBotNhdsWithinIoi [Nonempty ι] [∀ i, Preorder (π i)] {x : ∀ i, π i}
[∀ i, (𝓝[>] x i).NeBot] : (𝓝[>] x).NeBot :=
Pi.instNeBotNhdsWithinIio (π := fun i ↦ (π i)ᵒᵈ) (x := fun i ↦ OrderDual.toDual (x i))
end Pi
theorem Filter.Tendsto.piecewise_nhdsWithin {f g : α → β} {t : Set α} [∀ x, Decidable (x ∈ t)]
{a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ t] a) l)
(h₁ : Tendsto g (𝓝[s ∩ tᶜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by
apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter']
theorem Filter.Tendsto.if_nhdsWithin {f g : α → β} {p : α → Prop} [DecidablePred p] {a : α}
{s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ { x | p x }] a) l)
(h₁ : Tendsto g (𝓝[s ∩ { x | ¬p x }] a) l) :
Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l :=
h₀.piecewise_nhdsWithin h₁
theorem map_nhdsWithin (f : α → β) (a : α) (s : Set α) :
map f (𝓝[s] a) = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (f '' (t ∩ s)) :=
((nhdsWithin_basis_open a s).map f).eq_biInf
theorem tendsto_nhdsWithin_mono_left {f : α → β} {a : α} {s t : Set α} {l : Filter β} (hst : s ⊆ t)
(h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l :=
h.mono_left <| nhdsWithin_mono a hst
theorem tendsto_nhdsWithin_mono_right {f : β → α} {l : Filter β} {a : α} {s t : Set α} (hst : s ⊆ t)
(h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) :=
h.mono_right (nhdsWithin_mono a hst)
theorem tendsto_nhdsWithin_of_tendsto_nhds {f : α → β} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l :=
h.mono_left inf_le_left
theorem eventually_mem_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f l (𝓝[s] a)) : ∀ᶠ i in l, f i ∈ s := by
simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff,
eventually_and] at h
exact (h univ ⟨mem_univ a, isOpen_univ⟩).2
theorem tendsto_nhds_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β}
(h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) :=
h.mono_right nhdsWithin_le_nhds
theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) :=
mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx
theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set α} (hs : IsClosed s) {x : α}
(hx : NeBot <| 𝓝[s] x) : x ∈ s :=
hs.closure_eq ▸ mem_closure_iff_nhdsWithin_neBot.2 hx
theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) :
NeBot (𝓝[range f] x) :=
mem_closure_iff_clusterPt.1 (h x)
theorem mem_closure_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι}
{s : ∀ i, Set (α i)} {x : ∀ i, α i} : x ∈ closure (pi I s) ↔ ∀ i ∈ I, x i ∈ closure (s i) := by
simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot]
theorem closure_pi_set {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] (I : Set ι)
(s : ∀ i, Set (α i)) : closure (pi I s) = pi I fun i => closure (s i) :=
Set.ext fun _ => mem_closure_pi
theorem dense_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {s : ∀ i, Set (α i)}
(I : Set ι) (hs : ∀ i ∈ I, Dense (s i)) : Dense (pi I s) := by
simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq,
pi_univ]
theorem DenseRange.piMap {ι : Type*} {X Y : ι → Type*} [∀ i, TopologicalSpace (Y i)]
{f : (i : ι) → (X i) → (Y i)} (hf : ∀ i, DenseRange (f i)):
DenseRange (Pi.map f) := by
rw [DenseRange, Set.range_piMap]
exact dense_pi Set.univ (fun i _ => hf i)
theorem eventuallyEq_nhdsWithin_iff {f g : α → β} {s : Set α} {a : α} :
f =ᶠ[𝓝[s] a] g ↔ ∀ᶠ x in 𝓝 a, x ∈ s → f x = g x :=
mem_inf_principal
/-- Two functions agree on a neighborhood of `x` if they agree at `x` and in a punctured
neighborhood. -/
theorem eventuallyEq_nhds_of_eventuallyEq_nhdsNE {f g : α → β} {a : α} (h₁ : f =ᶠ[𝓝[≠] a] g)
(h₂ : f a = g a) :
f =ᶠ[𝓝 a] g := by
filter_upwards [eventually_nhdsWithin_iff.1 h₁]
intro x hx
by_cases h₂x : x = a
· simp [h₂x, h₂]
· tauto
theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) :
f =ᶠ[𝓝[s] a] g :=
mem_inf_of_right h
theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) :
f =ᶠ[𝓝[s] a] g :=
eventuallyEq_nhdsWithin_of_eqOn h
theorem tendsto_nhdsWithin_congr {f g : α → β} {s : Set α} {a : α} {l : Filter β}
(hfg : ∀ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l :=
(tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf
theorem eventually_nhdsWithin_of_forall {s : Set α} {a : α} {p : α → Prop} (h : ∀ x ∈ s, p x) :
∀ᶠ x in 𝓝[s] a, p x :=
mem_inf_of_right h
theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : α} {l : Filter β} {s : Set α}
(f : β → α) (h1 : Tendsto f l (𝓝 a)) (h2 : ∀ᶠ x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) :=
tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩
theorem tendsto_nhdsWithin_iff {a : α} {l : Filter β} {s : Set α} {f : β → α} :
Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ ∀ᶠ n in l, f n ∈ s :=
⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h =>
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩
@[simp]
theorem tendsto_nhdsWithin_range {a : α} {l : Filter β} {f : β → α} :
Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) :=
⟨fun h => h.mono_right inf_le_left, fun h =>
tendsto_inf.2 ⟨h, tendsto_principal.2 <| Eventually.of_forall mem_range_self⟩⟩
theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set α} {f g : α → β} {a : α} (h : f =ᶠ[𝓝[s] a] g)
(hmem : a ∈ s) : f a = g a :=
h.self_of_nhdsWithin hmem
theorem eventually_nhdsWithin_of_eventually_nhds {s : Set α}
{a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x :=
mem_nhdsWithin_of_mem_nhds h
lemma Set.MapsTo.preimage_mem_nhdsWithin {f : α → β} {s : Set α} {t : Set β} {x : α}
(hst : MapsTo f s t) : f ⁻¹' t ∈ 𝓝[s] x :=
Filter.mem_of_superset self_mem_nhdsWithin hst
/-!
### `nhdsWithin` and subtypes
-/
theorem mem_nhdsWithin_subtype {s : Set α} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} :
t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s → α) (𝓝[(↑) '' u] a) := by
rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin]
theorem nhdsWithin_subtype (s : Set α) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) :
𝓝[t] a = comap ((↑) : s → α) (𝓝[(↑) '' t] a) :=
Filter.ext fun _ => mem_nhdsWithin_subtype
theorem nhdsWithin_eq_map_subtype_coe {s : Set α} {a : α} (h : a ∈ s) :
𝓝[s] a = map ((↑) : s → α) (𝓝 ⟨a, h⟩) :=
(map_nhds_subtype_val ⟨a, h⟩).symm
theorem mem_nhds_subtype_iff_nhdsWithin {s : Set α} {a : s} {t : Set s} :
t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : α) := by
rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective]
theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by
rw [← map_nhds_subtype_val, mem_map]
theorem eventually_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) :
(∀ᶠ x : s in 𝓝 a, P x) ↔ ∀ᶠ x in 𝓝[s] a, P x :=
preimage_coe_mem_nhds_subtype
theorem frequently_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) :
(∃ᶠ x : s in 𝓝 a, P x) ↔ ∃ᶠ x in 𝓝[s] a, P x :=
eventually_nhds_subtype_iff s a (¬ P ·) |>.not
theorem tendsto_nhdsWithin_iff_subtype {s : Set α} {a : α} (h : a ∈ s) (f : α → β) (l : Filter β) :
Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by
rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl
/-!
## Local continuity properties of functions
-/
variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ]
{f g : α → β} {s s' s₁ t : Set α} {x : α}
/-!
### `ContinuousWithinAt`
-/
/-- If a function is continuous within `s` at `x`, then it tends to `f x` within `s` by definition.
We register this fact for use with the dot notation, especially to use `Filter.Tendsto.comp` as
`ContinuousWithinAt.comp` will have a different meaning. -/
theorem ContinuousWithinAt.tendsto (h : ContinuousWithinAt f s x) :
Tendsto f (𝓝[s] x) (𝓝 (f x)) :=
h
theorem continuousWithinAt_univ (f : α → β) (x : α) :
ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by
rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ]
theorem continuous_iff_continuousOn_univ {f : α → β} : Continuous f ↔ ContinuousOn f univ := by
simp [continuous_iff_continuousAt, ContinuousOn, ContinuousAt, ContinuousWithinAt,
nhdsWithin_univ]
theorem continuousWithinAt_iff_continuousAt_restrict (f : α → β) {x : α} {s : Set α} (h : x ∈ s) :
ContinuousWithinAt f s x ↔ ContinuousAt (s.restrict f) ⟨x, h⟩ :=
tendsto_nhdsWithin_iff_subtype h f _
theorem ContinuousWithinAt.tendsto_nhdsWithin {t : Set β}
(h : ContinuousWithinAt f s x) (ht : MapsTo f s t) :
Tendsto f (𝓝[s] x) (𝓝[t] f x) :=
tendsto_inf.2 ⟨h, tendsto_principal.2 <| mem_inf_of_right <| mem_principal.2 <| ht⟩
theorem ContinuousWithinAt.tendsto_nhdsWithin_image (h : ContinuousWithinAt f s x) :
Tendsto f (𝓝[s] x) (𝓝[f '' s] f x) :=
h.tendsto_nhdsWithin (mapsTo_image _ _)
theorem nhdsWithin_le_comap (ctsf : ContinuousWithinAt f s x) :
𝓝[s] x ≤ comap f (𝓝[f '' s] f x) :=
ctsf.tendsto_nhdsWithin_image.le_comap
theorem ContinuousWithinAt.preimage_mem_nhdsWithin {t : Set β}
(h : ContinuousWithinAt f s x) (ht : t ∈ 𝓝 (f x)) : f ⁻¹' t ∈ 𝓝[s] x :=
h ht
theorem ContinuousWithinAt.preimage_mem_nhdsWithin' {t : Set β}
(h : ContinuousWithinAt f s x) (ht : t ∈ 𝓝[f '' s] f x) : f ⁻¹' t ∈ 𝓝[s] x :=
h.tendsto_nhdsWithin (mapsTo_image _ _) ht
theorem ContinuousWithinAt.preimage_mem_nhdsWithin'' {y : β} {s t : Set β}
(h : ContinuousWithinAt f (f ⁻¹' s) x) (ht : t ∈ 𝓝[s] y) (hxy : y = f x) :
f ⁻¹' t ∈ 𝓝[f ⁻¹' s] x := by
rw [hxy] at ht
exact h.preimage_mem_nhdsWithin' (nhdsWithin_mono _ (image_preimage_subset f s) ht)
theorem continuousWithinAt_of_not_mem_closure (hx : x ∉ closure s) :
ContinuousWithinAt f s x := by
rw [mem_closure_iff_nhdsWithin_neBot, not_neBot] at hx
rw [ContinuousWithinAt, hx]
exact tendsto_bot
/-!
### `ContinuousOn`
-/
theorem continuousOn_iff :
ContinuousOn f s ↔
∀ x ∈ s, ∀ t : Set β, IsOpen t → f x ∈ t → ∃ u, IsOpen u ∧ x ∈ u ∧ u ∩ s ⊆ f ⁻¹' t := by
simp only [ContinuousOn, ContinuousWithinAt, tendsto_nhds, mem_nhdsWithin]
theorem ContinuousOn.continuousWithinAt (hf : ContinuousOn f s) (hx : x ∈ s) :
ContinuousWithinAt f s x :=
hf x hx
theorem continuousOn_iff_continuous_restrict :
ContinuousOn f s ↔ Continuous (s.restrict f) := by
rw [ContinuousOn, continuous_iff_continuousAt]; constructor
· rintro h ⟨x, xs⟩
exact (continuousWithinAt_iff_continuousAt_restrict f xs).mp (h x xs)
intro h x xs
exact (continuousWithinAt_iff_continuousAt_restrict f xs).mpr (h ⟨x, xs⟩)
alias ⟨ContinuousOn.restrict, _⟩ := continuousOn_iff_continuous_restrict
theorem ContinuousOn.restrict_mapsTo {t : Set β} (hf : ContinuousOn f s) (ht : MapsTo f s t) :
Continuous (ht.restrict f s t) :=
hf.restrict.codRestrict _
theorem continuousOn_iff' :
ContinuousOn f s ↔ ∀ t : Set β, IsOpen t → ∃ u, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by
have : ∀ t, IsOpen (s.restrict f ⁻¹' t) ↔ ∃ u : Set α, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by
intro t
rw [isOpen_induced_iff, Set.restrict_eq, Set.preimage_comp]
simp only [Subtype.preimage_coe_eq_preimage_coe_iff]
constructor <;>
· rintro ⟨u, ou, useq⟩
exact ⟨u, ou, by simpa only [Set.inter_comm, eq_comm] using useq⟩
rw [continuousOn_iff_continuous_restrict, continuous_def]; simp only [this]
/-- If a function is continuous on a set for some topologies, then it is
continuous on the same set with respect to any finer topology on the source space. -/
theorem ContinuousOn.mono_dom {α β : Type*} {t₁ t₂ : TopologicalSpace α} {t₃ : TopologicalSpace β}
(h₁ : t₂ ≤ t₁) {s : Set α} {f : α → β} (h₂ : @ContinuousOn α β t₁ t₃ f s) :
@ContinuousOn α β t₂ t₃ f s := fun x hx _u hu =>
map_mono (inf_le_inf_right _ <| nhds_mono h₁) (h₂ x hx hu)
/-- If a function is continuous on a set for some topologies, then it is
continuous on the same set with respect to any coarser topology on the target space. -/
theorem ContinuousOn.mono_rng {α β : Type*} {t₁ : TopologicalSpace α} {t₂ t₃ : TopologicalSpace β}
(h₁ : t₂ ≤ t₃) {s : Set α} {f : α → β} (h₂ : @ContinuousOn α β t₁ t₂ f s) :
@ContinuousOn α β t₁ t₃ f s := fun x hx _u hu =>
h₂ x hx <| nhds_mono h₁ hu
theorem continuousOn_iff_isClosed :
ContinuousOn f s ↔ ∀ t : Set β, IsClosed t → ∃ u, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by
have : ∀ t, IsClosed (s.restrict f ⁻¹' t) ↔ ∃ u : Set α, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by
intro t
rw [isClosed_induced_iff, Set.restrict_eq, Set.preimage_comp]
simp only [Subtype.preimage_coe_eq_preimage_coe_iff, eq_comm, Set.inter_comm s]
rw [continuousOn_iff_continuous_restrict, continuous_iff_isClosed]; simp only [this]
theorem continuous_of_cover_nhds {ι : Sort*} {s : ι → Set α}
(hs : ∀ x : α, ∃ i, s i ∈ 𝓝 x) (hf : ∀ i, ContinuousOn f (s i)) :
Continuous f :=
continuous_iff_continuousAt.mpr fun x ↦ let ⟨i, hi⟩ := hs x; by
rw [ContinuousAt, ← nhdsWithin_eq_nhds.2 hi]
exact hf _ _ (mem_of_mem_nhds hi)
@[simp] theorem continuousOn_empty (f : α → β) : ContinuousOn f ∅ := fun _ => False.elim
@[simp]
theorem continuousOn_singleton (f : α → β) (a : α) : ContinuousOn f {a} :=
forall_eq.2 <| by
simpa only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_left] using fun s =>
mem_of_mem_nhds
theorem Set.Subsingleton.continuousOn {s : Set α} (hs : s.Subsingleton) (f : α → β) :
ContinuousOn f s :=
hs.induction_on (continuousOn_empty f) (continuousOn_singleton f)
theorem continuousOn_open_iff (hs : IsOpen s) :
ContinuousOn f s ↔ ∀ t, IsOpen t → IsOpen (s ∩ f ⁻¹' t) := by
rw [continuousOn_iff']
constructor
· intro h t ht
rcases h t ht with ⟨u, u_open, hu⟩
rw [inter_comm, hu]
apply IsOpen.inter u_open hs
· intro h t ht
refine ⟨s ∩ f ⁻¹' t, h t ht, ?_⟩
rw [@inter_comm _ s (f ⁻¹' t), inter_assoc, inter_self]
theorem ContinuousOn.isOpen_inter_preimage {t : Set β}
(hf : ContinuousOn f s) (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ∩ f ⁻¹' t) :=
(continuousOn_open_iff hs).1 hf t ht
theorem ContinuousOn.isOpen_preimage {t : Set β} (h : ContinuousOn f s)
(hs : IsOpen s) (hp : f ⁻¹' t ⊆ s) (ht : IsOpen t) : IsOpen (f ⁻¹' t) := by
convert (continuousOn_open_iff hs).mp h t ht
rw [inter_comm, inter_eq_self_of_subset_left hp]
theorem ContinuousOn.preimage_isClosed_of_isClosed {t : Set β}
(hf : ContinuousOn f s) (hs : IsClosed s) (ht : IsClosed t) : IsClosed (s ∩ f ⁻¹' t) := by
rcases continuousOn_iff_isClosed.1 hf t ht with ⟨u, hu⟩
rw [inter_comm, hu.2]
apply IsClosed.inter hu.1 hs
theorem ContinuousOn.preimage_interior_subset_interior_preimage {t : Set β}
(hf : ContinuousOn f s) (hs : IsOpen s) : s ∩ f ⁻¹' interior t ⊆ s ∩ interior (f ⁻¹' t) :=
calc
s ∩ f ⁻¹' interior t ⊆ interior (s ∩ f ⁻¹' t) :=
interior_maximal (inter_subset_inter (Subset.refl _) (preimage_mono interior_subset))
(hf.isOpen_inter_preimage hs isOpen_interior)
_ = s ∩ interior (f ⁻¹' t) := by rw [interior_inter, hs.interior_eq]
theorem continuousOn_of_locally_continuousOn
(h : ∀ x ∈ s, ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn f (s ∩ t)) : ContinuousOn f s := by
intro x xs
rcases h x xs with ⟨t, open_t, xt, ct⟩
have := ct x ⟨xs, xt⟩
rwa [ContinuousWithinAt, ← nhdsWithin_restrict _ xt open_t] at this
theorem continuousOn_to_generateFrom_iff {β : Type*} {T : Set (Set β)} {f : α → β} :
@ContinuousOn α β _ (.generateFrom T) f s ↔ ∀ x ∈ s, ∀ t ∈ T, f x ∈ t → f ⁻¹' t ∈ 𝓝[s] x :=
forall₂_congr fun x _ => by
delta ContinuousWithinAt
simp only [TopologicalSpace.nhds_generateFrom, tendsto_iInf, tendsto_principal, mem_setOf_eq,
and_imp]
exact forall_congr' fun t => forall_swap
theorem continuousOn_isOpen_of_generateFrom {β : Type*} {s : Set α} {T : Set (Set β)} {f : α → β}
(h : ∀ t ∈ T, IsOpen (s ∩ f ⁻¹' t)) :
@ContinuousOn α β _ (.generateFrom T) f s :=
continuousOn_to_generateFrom_iff.2 fun _x hx t ht hxt => mem_nhdsWithin.2
⟨_, h t ht, ⟨hx, hxt⟩, fun _y hy => hy.1.2⟩
/-!
### Congruence and monotonicity properties with respect to sets
-/
theorem ContinuousWithinAt.mono (h : ContinuousWithinAt f t x)
(hs : s ⊆ t) : ContinuousWithinAt f s x :=
h.mono_left (nhdsWithin_mono x hs)
theorem ContinuousWithinAt.mono_of_mem_nhdsWithin (h : ContinuousWithinAt f t x) (hs : t ∈ 𝓝[s] x) :
ContinuousWithinAt f s x :=
h.mono_left (nhdsWithin_le_of_mem hs)
/-- If two sets coincide around `x`, then being continuous within one or the other at `x` is
equivalent. See also `continuousWithinAt_congr_set'` which requires that the sets coincide
locally away from a point `y`, in a T1 space. -/
theorem continuousWithinAt_congr_set (h : s =ᶠ[𝓝 x] t) :
ContinuousWithinAt f s x ↔ ContinuousWithinAt f t x := by
simp only [ContinuousWithinAt, nhdsWithin_eq_iff_eventuallyEq.mpr h]
theorem ContinuousWithinAt.congr_set (hf : ContinuousWithinAt f s x) (h : s =ᶠ[𝓝 x] t) :
ContinuousWithinAt f t x :=
(continuousWithinAt_congr_set h).1 hf
theorem continuousWithinAt_inter' (h : t ∈ 𝓝[s] x) :
ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by
simp [ContinuousWithinAt, nhdsWithin_restrict'' s h]
theorem continuousWithinAt_inter (h : t ∈ 𝓝 x) :
ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by
simp [ContinuousWithinAt, nhdsWithin_restrict' s h]
theorem continuousWithinAt_union :
ContinuousWithinAt f (s ∪ t) x ↔ ContinuousWithinAt f s x ∧ ContinuousWithinAt f t x := by
simp only [ContinuousWithinAt, nhdsWithin_union, tendsto_sup]
theorem ContinuousWithinAt.union (hs : ContinuousWithinAt f s x) (ht : ContinuousWithinAt f t x) :
ContinuousWithinAt f (s ∪ t) x :=
continuousWithinAt_union.2 ⟨hs, ht⟩
@[simp]
theorem continuousWithinAt_singleton : ContinuousWithinAt f {x} x := by
simp only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_nhds]
@[simp]
theorem continuousWithinAt_insert_self :
ContinuousWithinAt f (insert x s) x ↔ ContinuousWithinAt f s x := by
simp only [← singleton_union, continuousWithinAt_union, continuousWithinAt_singleton, true_and]
protected alias ⟨_, ContinuousWithinAt.insert⟩ := continuousWithinAt_insert_self
/- `continuousWithinAt_insert` gives the same equivalence but at a point `y` possibly different
from `x`. As this requires the space to be T1, and this property is not available in this file,
this is found in another file although it is part of the basic API for `continuousWithinAt`. -/
theorem ContinuousWithinAt.diff_iff
(ht : ContinuousWithinAt f t x) : ContinuousWithinAt f (s \ t) x ↔ ContinuousWithinAt f s x :=
⟨fun h => (h.union ht).mono <| by simp only [diff_union_self, subset_union_left], fun h =>
h.mono diff_subset⟩
/-- See also `continuousWithinAt_diff_singleton` for the case of `s \ {y}`, but
requiring `T1Space α. -/
@[simp]
theorem continuousWithinAt_diff_self :
ContinuousWithinAt f (s \ {x}) x ↔ ContinuousWithinAt f s x :=
continuousWithinAt_singleton.diff_iff
@[simp]
theorem continuousWithinAt_compl_self :
ContinuousWithinAt f {x}ᶜ x ↔ ContinuousAt f x := by
rw [compl_eq_univ_diff, continuousWithinAt_diff_self, continuousWithinAt_univ]
theorem ContinuousOn.mono (hf : ContinuousOn f s) (h : t ⊆ s) :
ContinuousOn f t := fun x hx => (hf x (h hx)).mono_left (nhdsWithin_mono _ h)
theorem antitone_continuousOn {f : α → β} : Antitone (ContinuousOn f) := fun _s _t hst hf =>
hf.mono hst
/-!
### Relation between `ContinuousAt` and `ContinuousWithinAt`
-/
theorem ContinuousAt.continuousWithinAt (h : ContinuousAt f x) :
ContinuousWithinAt f s x :=
ContinuousWithinAt.mono ((continuousWithinAt_univ f x).2 h) (subset_univ _)
theorem continuousWithinAt_iff_continuousAt (h : s ∈ 𝓝 x) :
ContinuousWithinAt f s x ↔ ContinuousAt f x := by
rw [← univ_inter s, continuousWithinAt_inter h, continuousWithinAt_univ]
theorem ContinuousWithinAt.continuousAt
(h : ContinuousWithinAt f s x) (hs : s ∈ 𝓝 x) : ContinuousAt f x :=
(continuousWithinAt_iff_continuousAt hs).mp h
theorem IsOpen.continuousOn_iff (hs : IsOpen s) :
ContinuousOn f s ↔ ∀ ⦃a⦄, a ∈ s → ContinuousAt f a :=
forall₂_congr fun _ => continuousWithinAt_iff_continuousAt ∘ hs.mem_nhds
theorem ContinuousOn.continuousAt (h : ContinuousOn f s)
(hx : s ∈ 𝓝 x) : ContinuousAt f x :=
(h x (mem_of_mem_nhds hx)).continuousAt hx
theorem continuousOn_of_forall_continuousAt (hcont : ∀ x ∈ s, ContinuousAt f x) :
ContinuousOn f s := fun x hx => (hcont x hx).continuousWithinAt
@[deprecated (since := "2024-10-30")]
alias ContinuousAt.continuousOn := continuousOn_of_forall_continuousAt
@[fun_prop]
theorem Continuous.continuousOn (h : Continuous f) : ContinuousOn f s := by
rw [continuous_iff_continuousOn_univ] at h
exact h.mono (subset_univ _)
theorem Continuous.continuousWithinAt (h : Continuous f) :
ContinuousWithinAt f s x :=
h.continuousAt.continuousWithinAt
/-!
### Congruence properties with respect to functions
-/
theorem ContinuousOn.congr_mono (h : ContinuousOn f s) (h' : EqOn g f s₁) (h₁ : s₁ ⊆ s) :
ContinuousOn g s₁ := by
intro x hx
unfold ContinuousWithinAt
have A := (h x (h₁ hx)).mono h₁
unfold ContinuousWithinAt at A
rw [← h' hx] at A
exact A.congr' h'.eventuallyEq_nhdsWithin.symm
theorem ContinuousOn.congr (h : ContinuousOn f s) (h' : EqOn g f s) :
ContinuousOn g s :=
h.congr_mono h' (Subset.refl _)
theorem continuousOn_congr (h' : EqOn g f s) :
ContinuousOn g s ↔ ContinuousOn f s :=
⟨fun h => ContinuousOn.congr h h'.symm, fun h => h.congr h'⟩
theorem Filter.EventuallyEq.congr_continuousWithinAt (h : f =ᶠ[𝓝[s] x] g) (hx : f x = g x) :
ContinuousWithinAt f s x ↔ ContinuousWithinAt g s x := by
rw [ContinuousWithinAt, hx, tendsto_congr' h, ContinuousWithinAt]
theorem ContinuousWithinAt.congr_of_eventuallyEq
(h : ContinuousWithinAt f s x) (h₁ : g =ᶠ[𝓝[s] x] f) (hx : g x = f x) :
ContinuousWithinAt g s x :=
(h₁.congr_continuousWithinAt hx).2 h
theorem ContinuousWithinAt.congr_of_eventuallyEq_of_mem
(h : ContinuousWithinAt f s x) (h₁ : g =ᶠ[𝓝[s] x] f) (hx : x ∈ s) :
ContinuousWithinAt g s x :=
h.congr_of_eventuallyEq h₁ (mem_of_mem_nhdsWithin hx h₁ :)
theorem Filter.EventuallyEq.congr_continuousWithinAt_of_mem (h : f =ᶠ[𝓝[s] x] g) (hx : x ∈ s) :
ContinuousWithinAt f s x ↔ ContinuousWithinAt g s x :=
⟨fun h' ↦ h'.congr_of_eventuallyEq_of_mem h.symm hx,
fun h' ↦ h'.congr_of_eventuallyEq_of_mem h hx⟩
theorem ContinuousWithinAt.congr_of_eventuallyEq_insert
(h : ContinuousWithinAt f s x) (h₁ : g =ᶠ[𝓝[insert x s] x] f) :
ContinuousWithinAt g s x :=
h.congr_of_eventuallyEq (nhdsWithin_mono _ (subset_insert _ _) h₁)
(mem_of_mem_nhdsWithin (mem_insert _ _) h₁ :)
theorem Filter.EventuallyEq.congr_continuousWithinAt_of_insert (h : f =ᶠ[𝓝[insert x s] x] g) :
ContinuousWithinAt f s x ↔ ContinuousWithinAt g s x :=
⟨fun h' ↦ h'.congr_of_eventuallyEq_insert h.symm,
fun h' ↦ h'.congr_of_eventuallyEq_insert h⟩
theorem ContinuousWithinAt.congr (h : ContinuousWithinAt f s x)
(h₁ : ∀ y ∈ s, g y = f y) (hx : g x = f x) : ContinuousWithinAt g s x :=
h.congr_of_eventuallyEq (mem_of_superset self_mem_nhdsWithin h₁) hx
theorem continuousWithinAt_congr (h₁ : ∀ y ∈ s, g y = f y) (hx : g x = f x) :
ContinuousWithinAt g s x ↔ ContinuousWithinAt f s x :=
⟨fun h' ↦ h'.congr (fun x hx ↦ (h₁ x hx).symm) hx.symm, fun h' ↦ h'.congr h₁ hx⟩
theorem ContinuousWithinAt.congr_of_mem (h : ContinuousWithinAt f s x)
(h₁ : ∀ y ∈ s, g y = f y) (hx : x ∈ s) : ContinuousWithinAt g s x :=
h.congr h₁ (h₁ x hx)
theorem continuousWithinAt_congr_of_mem (h₁ : ∀ y ∈ s, g y = f y) (hx : x ∈ s) :
ContinuousWithinAt g s x ↔ ContinuousWithinAt f s x :=
continuousWithinAt_congr h₁ (h₁ x hx)
theorem ContinuousWithinAt.congr_of_insert (h : ContinuousWithinAt f s x)
(h₁ : ∀ y ∈ insert x s, g y = f y) : ContinuousWithinAt g s x :=
h.congr (fun y hy ↦ h₁ y (mem_insert_of_mem _ hy)) (h₁ x (mem_insert _ _))
theorem continuousWithinAt_congr_of_insert
(h₁ : ∀ y ∈ insert x s, g y = f y) :
ContinuousWithinAt g s x ↔ ContinuousWithinAt f s x :=
continuousWithinAt_congr (fun y hy ↦ h₁ y (mem_insert_of_mem _ hy)) (h₁ x (mem_insert _ _))
theorem ContinuousWithinAt.congr_mono
(h : ContinuousWithinAt f s x) (h' : EqOn g f s₁) (h₁ : s₁ ⊆ s) (hx : g x = f x) :
ContinuousWithinAt g s₁ x :=
(h.mono h₁).congr h' hx
theorem ContinuousAt.congr_of_eventuallyEq (h : ContinuousAt f x) (hg : g =ᶠ[𝓝 x] f) :
ContinuousAt g x := by
simp only [← continuousWithinAt_univ] at h ⊢
exact h.congr_of_eventuallyEq_of_mem (by rwa [nhdsWithin_univ]) (mem_univ x)
/-!
### Composition
-/
theorem ContinuousWithinAt.comp {g : β → γ} {t : Set β}
(hg : ContinuousWithinAt g t (f x)) (hf : ContinuousWithinAt f s x) (h : MapsTo f s t) :
ContinuousWithinAt (g ∘ f) s x :=
hg.tendsto.comp (hf.tendsto_nhdsWithin h)
theorem ContinuousWithinAt.comp_of_eq {g : β → γ} {t : Set β} {y : β}
(hg : ContinuousWithinAt g t y) (hf : ContinuousWithinAt f s x) (h : MapsTo f s t)
(hy : f x = y) : ContinuousWithinAt (g ∘ f) s x := by
subst hy; exact hg.comp hf h
theorem ContinuousWithinAt.comp_inter {g : β → γ} {t : Set β}
(hg : ContinuousWithinAt g t (f x)) (hf : ContinuousWithinAt f s x) :
ContinuousWithinAt (g ∘ f) (s ∩ f ⁻¹' t) x :=
hg.comp (hf.mono inter_subset_left) inter_subset_right
theorem ContinuousWithinAt.comp_inter_of_eq {g : β → γ} {t : Set β} {y : β}
(hg : ContinuousWithinAt g t y) (hf : ContinuousWithinAt f s x) (hy : f x = y) :
ContinuousWithinAt (g ∘ f) (s ∩ f ⁻¹' t) x := by
subst hy; exact hg.comp_inter hf
theorem ContinuousWithinAt.comp_of_preimage_mem_nhdsWithin {g : β → γ} {t : Set β}
(hg : ContinuousWithinAt g t (f x)) (hf : ContinuousWithinAt f s x) (h : f ⁻¹' t ∈ 𝓝[s] x) :
ContinuousWithinAt (g ∘ f) s x :=
hg.tendsto.comp (tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within f hf h)
theorem ContinuousWithinAt.comp_of_preimage_mem_nhdsWithin_of_eq {g : β → γ} {t : Set β} {y : β}
(hg : ContinuousWithinAt g t y) (hf : ContinuousWithinAt f s x) (h : f ⁻¹' t ∈ 𝓝[s] x)
(hy : f x = y) :
ContinuousWithinAt (g ∘ f) s x := by
subst hy; exact hg.comp_of_preimage_mem_nhdsWithin hf h
theorem ContinuousWithinAt.comp_of_mem_nhdsWithin_image {g : β → γ} {t : Set β}
(hg : ContinuousWithinAt g t (f x)) (hf : ContinuousWithinAt f s x)
(hs : t ∈ 𝓝[f '' s] f x) : ContinuousWithinAt (g ∘ f) s x :=
(hg.mono_of_mem_nhdsWithin hs).comp hf (mapsTo_image f s)
theorem ContinuousWithinAt.comp_of_mem_nhdsWithin_image_of_eq {g : β → γ} {t : Set β} {y : β}
(hg : ContinuousWithinAt g t y) (hf : ContinuousWithinAt f s x)
(hs : t ∈ 𝓝[f '' s] y) (hy : f x = y) : ContinuousWithinAt (g ∘ f) s x := by
subst hy; exact hg.comp_of_mem_nhdsWithin_image hf hs
theorem ContinuousAt.comp_continuousWithinAt {g : β → γ}
(hg : ContinuousAt g (f x)) (hf : ContinuousWithinAt f s x) : ContinuousWithinAt (g ∘ f) s x :=
hg.continuousWithinAt.comp hf (mapsTo_univ _ _)
theorem ContinuousAt.comp_continuousWithinAt_of_eq {g : β → γ} {y : β}
(hg : ContinuousAt g y) (hf : ContinuousWithinAt f s x) (hy : f x = y) :
ContinuousWithinAt (g ∘ f) s x := by
subst hy; exact hg.comp_continuousWithinAt hf
/-- See also `ContinuousOn.comp'` using the form `fun y ↦ g (f y)` instead of `g ∘ f`. -/
theorem ContinuousOn.comp {g : β → γ} {t : Set β} (hg : ContinuousOn g t)
(hf : ContinuousOn f s) (h : MapsTo f s t) : ContinuousOn (g ∘ f) s := fun x hx =>
ContinuousWithinAt.comp (hg _ (h hx)) (hf x hx) h
/-- Variant of `ContinuousOn.comp` using the form `fun y ↦ g (f y)` instead of `g ∘ f`. -/
@[fun_prop]
theorem ContinuousOn.comp' {g : β → γ} {f : α → β} {s : Set α} {t : Set β} (hg : ContinuousOn g t)
(hf : ContinuousOn f s) (h : Set.MapsTo f s t) : ContinuousOn (fun x => g (f x)) s :=
ContinuousOn.comp hg hf h
@[fun_prop]
theorem ContinuousOn.comp_inter {g : β → γ} {t : Set β} (hg : ContinuousOn g t)
(hf : ContinuousOn f s) : ContinuousOn (g ∘ f) (s ∩ f ⁻¹' t) :=
hg.comp (hf.mono inter_subset_left) inter_subset_right
/-- See also `Continuous.comp_continuousOn'` using the form `fun y ↦ g (f y)`
instead of `g ∘ f`. -/
theorem Continuous.comp_continuousOn {g : β → γ} {f : α → β} {s : Set α} (hg : Continuous g)
(hf : ContinuousOn f s) : ContinuousOn (g ∘ f) s :=
hg.continuousOn.comp hf (mapsTo_univ _ _)
/-- Variant of `Continuous.comp_continuousOn` using the form `fun y ↦ g (f y)`
instead of `g ∘ f`. -/
@[fun_prop]
theorem Continuous.comp_continuousOn' {g : β → γ} {f : α → β} {s : Set α} (hg : Continuous g)
(hf : ContinuousOn f s) : ContinuousOn (fun x ↦ g (f x)) s :=
hg.comp_continuousOn hf
theorem ContinuousOn.comp_continuous {g : β → γ} {f : α → β} {s : Set β} (hg : ContinuousOn g s)
(hf : Continuous f) (hs : ∀ x, f x ∈ s) : Continuous (g ∘ f) := by
rw [continuous_iff_continuousOn_univ] at *
exact hg.comp hf fun x _ => hs x
theorem ContinuousOn.image_comp_continuous {g : β → γ} {f : α → β} {s : Set α}
(hg : ContinuousOn g (f '' s)) (hf : Continuous f) : ContinuousOn (g ∘ f) s :=
hg.comp hf.continuousOn (s.mapsTo_image f)
theorem ContinuousAt.comp₂_continuousWithinAt {f : β × γ → δ} {g : α → β} {h : α → γ} {x : α}
{s : Set α} (hf : ContinuousAt f (g x, h x)) (hg : ContinuousWithinAt g s x)
(hh : ContinuousWithinAt h s x) :
ContinuousWithinAt (fun x ↦ f (g x, h x)) s x :=
ContinuousAt.comp_continuousWithinAt hf (hg.prodMk_nhds hh)
theorem ContinuousAt.comp₂_continuousWithinAt_of_eq {f : β × γ → δ} {g : α → β}
{h : α → γ} {x : α} {s : Set α} {y : β × γ} (hf : ContinuousAt f y)
(hg : ContinuousWithinAt g s x) (hh : ContinuousWithinAt h s x) (e : (g x, h x) = y) :
ContinuousWithinAt (fun x ↦ f (g x, h x)) s x := by
rw [← e] at hf
exact hf.comp₂_continuousWithinAt hg hh
/-!
### Image
-/
theorem ContinuousWithinAt.mem_closure_image
(h : ContinuousWithinAt f s x) (hx : x ∈ closure s) : f x ∈ closure (f '' s) :=
haveI := mem_closure_iff_nhdsWithin_neBot.1 hx
mem_closure_of_tendsto h <| mem_of_superset self_mem_nhdsWithin (subset_preimage_image f s)
theorem ContinuousWithinAt.mem_closure {t : Set β}
(h : ContinuousWithinAt f s x) (hx : x ∈ closure s) (ht : MapsTo f s t) : f x ∈ closure t :=
closure_mono (image_subset_iff.2 ht) (h.mem_closure_image hx)
theorem Set.MapsTo.closure_of_continuousWithinAt {t : Set β}
(h : MapsTo f s t) (hc : ∀ x ∈ closure s, ContinuousWithinAt f s x) :
MapsTo f (closure s) (closure t) := fun x hx => (hc x hx).mem_closure hx h
theorem Set.MapsTo.closure_of_continuousOn {t : Set β} (h : MapsTo f s t)
(hc : ContinuousOn f (closure s)) : MapsTo f (closure s) (closure t) :=
h.closure_of_continuousWithinAt fun x hx => (hc x hx).mono subset_closure
theorem ContinuousWithinAt.image_closure
(hf : ∀ x ∈ closure s, ContinuousWithinAt f s x) : f '' closure s ⊆ closure (f '' s) :=
((mapsTo_image f s).closure_of_continuousWithinAt hf).image_subset
theorem ContinuousOn.image_closure (hf : ContinuousOn f (closure s)) :
f '' closure s ⊆ closure (f '' s) :=
ContinuousWithinAt.image_closure fun x hx => (hf x hx).mono subset_closure
/-!
### Product
-/
theorem ContinuousWithinAt.prodMk {f : α → β} {g : α → γ} {s : Set α} {x : α}
(hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) :
ContinuousWithinAt (fun x => (f x, g x)) s x :=
hf.prodMk_nhds hg
@[deprecated (since := "2025-03-10")]
alias ContinuousWithinAt.prod := ContinuousWithinAt.prodMk
@[fun_prop]
theorem ContinuousOn.prodMk {f : α → β} {g : α → γ} {s : Set α} (hf : ContinuousOn f s)
(hg : ContinuousOn g s) : ContinuousOn (fun x => (f x, g x)) s := fun x hx =>
(hf x hx).prodMk (hg x hx)
@[deprecated (since := "2025-03-10")]
alias ContinuousOn.prod := ContinuousOn.prodMk
theorem continuousOn_fst {s : Set (α × β)} : ContinuousOn Prod.fst s :=
continuous_fst.continuousOn
theorem continuousWithinAt_fst {s : Set (α × β)} {p : α × β} : ContinuousWithinAt Prod.fst s p :=
continuous_fst.continuousWithinAt
@[fun_prop]
theorem ContinuousOn.fst {f : α → β × γ} {s : Set α} (hf : ContinuousOn f s) :
ContinuousOn (fun x => (f x).1) s :=
continuous_fst.comp_continuousOn hf
theorem ContinuousWithinAt.fst {f : α → β × γ} {s : Set α} {a : α} (h : ContinuousWithinAt f s a) :
ContinuousWithinAt (fun x => (f x).fst) s a :=
continuousAt_fst.comp_continuousWithinAt h
theorem continuousOn_snd {s : Set (α × β)} : ContinuousOn Prod.snd s :=
continuous_snd.continuousOn
theorem continuousWithinAt_snd {s : Set (α × β)} {p : α × β} : ContinuousWithinAt Prod.snd s p :=
continuous_snd.continuousWithinAt
@[fun_prop]
theorem ContinuousOn.snd {f : α → β × γ} {s : Set α} (hf : ContinuousOn f s) :
ContinuousOn (fun x => (f x).2) s :=
continuous_snd.comp_continuousOn hf
theorem ContinuousWithinAt.snd {f : α → β × γ} {s : Set α} {a : α} (h : ContinuousWithinAt f s a) :
ContinuousWithinAt (fun x => (f x).snd) s a :=
continuousAt_snd.comp_continuousWithinAt h
theorem continuousWithinAt_prod_iff {f : α → β × γ} {s : Set α} {x : α} :
ContinuousWithinAt f s x ↔
ContinuousWithinAt (Prod.fst ∘ f) s x ∧ ContinuousWithinAt (Prod.snd ∘ f) s x :=
⟨fun h => ⟨h.fst, h.snd⟩, fun ⟨h1, h2⟩ => h1.prodMk h2⟩
theorem ContinuousWithinAt.prodMap {f : α → γ} {g : β → δ} {s : Set α} {t : Set β} {x : α} {y : β}
(hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g t y) :
ContinuousWithinAt (Prod.map f g) (s ×ˢ t) (x, y) :=
.prodMk (hf.comp continuousWithinAt_fst mapsTo_fst_prod)
(hg.comp continuousWithinAt_snd mapsTo_snd_prod)
@[deprecated (since := "2025-03-10")]
alias ContinuousWithinAt.prod_map := ContinuousWithinAt.prodMap
theorem ContinuousOn.prodMap {f : α → γ} {g : β → δ} {s : Set α} {t : Set β} (hf : ContinuousOn f s)
(hg : ContinuousOn g t) : ContinuousOn (Prod.map f g) (s ×ˢ t) := fun ⟨x, y⟩ ⟨hx, hy⟩ =>
(hf x hx).prodMap (hg y hy)
@[deprecated (since := "2025-03-10")]
alias ContinuousOn.prod_map := ContinuousOn.prodMap
theorem continuousWithinAt_prod_of_discrete_left [DiscreteTopology α]
{f : α × β → γ} {s : Set (α × β)} {x : α × β} :
ContinuousWithinAt f s x ↔ ContinuousWithinAt (f ⟨x.1, ·⟩) {b | (x.1, b) ∈ s} x.2 := by
rw [← x.eta]; simp_rw [ContinuousWithinAt, nhdsWithin, nhds_prod_eq, nhds_discrete, pure_prod,
← map_inf_principal_preimage]; rfl
theorem continuousWithinAt_prod_of_discrete_right [DiscreteTopology β]
{f : α × β → γ} {s : Set (α × β)} {x : α × β} :
ContinuousWithinAt f s x ↔ ContinuousWithinAt (f ⟨·, x.2⟩) {a | (a, x.2) ∈ s} x.1 := by
rw [← x.eta]; simp_rw [ContinuousWithinAt, nhdsWithin, nhds_prod_eq, nhds_discrete, prod_pure,
← map_inf_principal_preimage]; rfl
theorem continuousAt_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} {x : α × β} :
ContinuousAt f x ↔ ContinuousAt (f ⟨x.1, ·⟩) x.2 := by
simp_rw [← continuousWithinAt_univ]; exact continuousWithinAt_prod_of_discrete_left
theorem continuousAt_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} {x : α × β} :
ContinuousAt f x ↔ ContinuousAt (f ⟨·, x.2⟩) x.1 := by
simp_rw [← continuousWithinAt_univ]; exact continuousWithinAt_prod_of_discrete_right
theorem continuousOn_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} {s : Set (α × β)} :
ContinuousOn f s ↔ ∀ a, ContinuousOn (f ⟨a, ·⟩) {b | (a, b) ∈ s} := by
simp_rw [ContinuousOn, Prod.forall, continuousWithinAt_prod_of_discrete_left]; rfl
theorem continuousOn_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} {s : Set (α × β)} :
ContinuousOn f s ↔ ∀ b, ContinuousOn (f ⟨·, b⟩) {a | (a, b) ∈ s} := by
simp_rw [ContinuousOn, Prod.forall, continuousWithinAt_prod_of_discrete_right]; apply forall_swap
/-- If a function `f a b` is such that `y ↦ f a b` is continuous for all `a`, and `a` lives in a
discrete space, then `f` is continuous, and vice versa. -/
theorem continuous_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} :
Continuous f ↔ ∀ a, Continuous (f ⟨a, ·⟩) := by
simp_rw [continuous_iff_continuousOn_univ]; exact continuousOn_prod_of_discrete_left
theorem continuous_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} :
Continuous f ↔ ∀ b, Continuous (f ⟨·, b⟩) := by
simp_rw [continuous_iff_continuousOn_univ]; exact continuousOn_prod_of_discrete_right
theorem isOpenMap_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} :
IsOpenMap f ↔ ∀ a, IsOpenMap (f ⟨a, ·⟩) := by
simp_rw [isOpenMap_iff_nhds_le, Prod.forall, nhds_prod_eq, nhds_discrete, pure_prod, map_map]
rfl
theorem isOpenMap_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} :
IsOpenMap f ↔ ∀ b, IsOpenMap (f ⟨·, b⟩) := by
simp_rw [isOpenMap_iff_nhds_le, Prod.forall, forall_swap (α := α) (β := β), nhds_prod_eq,
nhds_discrete, prod_pure, map_map]; rfl
/-!
### Pi
-/
theorem continuousWithinAt_pi {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)]
{f : α → ∀ i, π i} {s : Set α} {x : α} :
ContinuousWithinAt f s x ↔ ∀ i, ContinuousWithinAt (fun y => f y i) s x :=
tendsto_pi_nhds
theorem continuousOn_pi {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)]
{f : α → ∀ i, π i} {s : Set α} : ContinuousOn f s ↔ ∀ i, ContinuousOn (fun y => f y i) s :=
⟨fun h i x hx => tendsto_pi_nhds.1 (h x hx) i, fun h x hx => tendsto_pi_nhds.2 fun i => h i x hx⟩
@[fun_prop]
theorem continuousOn_pi' {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)]
{f : α → ∀ i, π i} {s : Set α} (hf : ∀ i, ContinuousOn (fun y => f y i) s) :
ContinuousOn f s :=
continuousOn_pi.2 hf
@[fun_prop]
theorem continuousOn_apply {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)]
(i : ι) (s) : ContinuousOn (fun p : ∀ i, π i => p i) s :=
Continuous.continuousOn (continuous_apply i)
/-!
### Specific functions
-/
@[fun_prop]
theorem continuousOn_const {s : Set α} {c : β} : ContinuousOn (fun _ => c) s :=
continuous_const.continuousOn
theorem continuousWithinAt_const {b : β} {s : Set α} {x : α} :
ContinuousWithinAt (fun _ : α => b) s x :=
continuous_const.continuousWithinAt
theorem continuousOn_id {s : Set α} : ContinuousOn id s :=
continuous_id.continuousOn
@[fun_prop]
theorem continuousOn_id' (s : Set α) : ContinuousOn (fun x : α => x) s := continuousOn_id
theorem continuousWithinAt_id {s : Set α} {x : α} : ContinuousWithinAt id s x :=
continuous_id.continuousWithinAt
protected theorem ContinuousOn.iterate {f : α → α} {s : Set α} (hcont : ContinuousOn f s)
(hmaps : MapsTo f s s) : ∀ n, ContinuousOn (f^[n]) s
| 0 => continuousOn_id
| (n + 1) => (hcont.iterate hmaps n).comp hcont hmaps
section Fin
variable {n : ℕ} {π : Fin (n + 1) → Type*} [∀ i, TopologicalSpace (π i)]
theorem ContinuousWithinAt.finCons
{f : α → π 0} {g : α → ∀ j : Fin n, π (Fin.succ j)} {a : α} {s : Set α}
(hf : ContinuousWithinAt f s a) (hg : ContinuousWithinAt g s a) :
ContinuousWithinAt (fun a => Fin.cons (f a) (g a)) s a :=
hf.tendsto.finCons hg
theorem ContinuousOn.finCons {f : α → π 0} {s : Set α} {g : α → ∀ j : Fin n, π (Fin.succ j)}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun a => Fin.cons (f a) (g a)) s := fun a ha =>
(hf a ha).finCons (hg a ha)
theorem ContinuousWithinAt.matrixVecCons {f : α → β} {g : α → Fin n → β} {a : α} {s : Set α}
(hf : ContinuousWithinAt f s a) (hg : ContinuousWithinAt g s a) :
ContinuousWithinAt (fun a => Matrix.vecCons (f a) (g a)) s a :=
hf.tendsto.matrixVecCons hg
theorem ContinuousOn.matrixVecCons {f : α → β} {g : α → Fin n → β} {s : Set α}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun a => Matrix.vecCons (f a) (g a)) s := fun a ha =>
(hf a ha).matrixVecCons (hg a ha)
theorem ContinuousWithinAt.finSnoc
{f : α → ∀ j : Fin n, π (Fin.castSucc j)} {g : α → π (Fin.last _)} {a : α} {s : Set α}
(hf : ContinuousWithinAt f s a) (hg : ContinuousWithinAt g s a) :
ContinuousWithinAt (fun a => Fin.snoc (f a) (g a)) s a :=
hf.tendsto.finSnoc hg
theorem ContinuousOn.finSnoc
{f : α → ∀ j : Fin n, π (Fin.castSucc j)} {g : α → π (Fin.last _)} {s : Set α}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun a => Fin.snoc (f a) (g a)) s := fun a ha =>
(hf a ha).finSnoc (hg a ha)
theorem ContinuousWithinAt.finInsertNth
(i : Fin (n + 1)) {f : α → π i} {g : α → ∀ j : Fin n, π (i.succAbove j)} {a : α} {s : Set α}
(hf : ContinuousWithinAt f s a) (hg : ContinuousWithinAt g s a) :
ContinuousWithinAt (fun a => i.insertNth (f a) (g a)) s a :=
hf.tendsto.finInsertNth i hg
@[deprecated (since := "2025-01-02")]
alias ContinuousWithinAt.fin_insertNth := ContinuousWithinAt.finInsertNth
theorem ContinuousOn.finInsertNth
(i : Fin (n + 1)) {f : α → π i} {g : α → ∀ j : Fin n, π (i.succAbove j)} {s : Set α}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun a => i.insertNth (f a) (g a)) s := fun a ha =>
(hf a ha).finInsertNth i (hg a ha)
@[deprecated (since := "2025-01-02")]
alias ContinuousOn.fin_insertNth := ContinuousOn.finInsertNth
end Fin
theorem Set.LeftInvOn.map_nhdsWithin_eq {f : α → β} {g : β → α} {x : β} {s : Set β}
(h : LeftInvOn f g s) (hx : f (g x) = x) (hf : ContinuousWithinAt f (g '' s) (g x))
(hg : ContinuousWithinAt g s x) : map g (𝓝[s] x) = 𝓝[g '' s] g x := by
apply le_antisymm
· exact hg.tendsto_nhdsWithin (mapsTo_image _ _)
· have A : g ∘ f =ᶠ[𝓝[g '' s] g x] id :=
h.rightInvOn_image.eqOn.eventuallyEq_of_mem self_mem_nhdsWithin
refine le_map_of_right_inverse A ?_
simpa only [hx] using hf.tendsto_nhdsWithin (h.mapsTo (surjOn_image _ _))
theorem Function.LeftInverse.map_nhds_eq {f : α → β} {g : β → α} {x : β}
(h : Function.LeftInverse f g) (hf : ContinuousWithinAt f (range g) (g x))
(hg : ContinuousAt g x) : map g (𝓝 x) = 𝓝[range g] g x := by
simpa only [nhdsWithin_univ, image_univ] using
(h.leftInvOn univ).map_nhdsWithin_eq (h x) (by rwa [image_univ]) hg.continuousWithinAt
lemma Topology.IsInducing.continuousWithinAt_iff {f : α → β} {g : β → γ} (hg : IsInducing g)
{s : Set α} {x : α} : ContinuousWithinAt f s x ↔ ContinuousWithinAt (g ∘ f) s x := by
simp_rw [ContinuousWithinAt, hg.tendsto_nhds_iff]; rfl
@[deprecated (since := "2024-10-28")]
alias Inducing.continuousWithinAt_iff := IsInducing.continuousWithinAt_iff
lemma Topology.IsInducing.continuousOn_iff {f : α → β} {g : β → γ} (hg : IsInducing g)
{s : Set α} : ContinuousOn f s ↔ ContinuousOn (g ∘ f) s := by
simp_rw [ContinuousOn, hg.continuousWithinAt_iff]
@[deprecated (since := "2024-10-28")] alias Inducing.continuousOn_iff := IsInducing.continuousOn_iff
lemma Topology.IsEmbedding.continuousOn_iff {f : α → β} {g : β → γ} (hg : IsEmbedding g)
{s : Set α} : ContinuousOn f s ↔ ContinuousOn (g ∘ f) s :=
hg.isInducing.continuousOn_iff
@[deprecated (since := "2024-10-26")]
alias Embedding.continuousOn_iff := IsEmbedding.continuousOn_iff
lemma Topology.IsEmbedding.map_nhdsWithin_eq {f : α → β} (hf : IsEmbedding f) (s : Set α) (x : α) :
map f (𝓝[s] x) = 𝓝[f '' s] f x := by
rw [nhdsWithin, Filter.map_inf hf.injective, hf.map_nhds_eq, map_principal, ← nhdsWithin_inter',
inter_eq_self_of_subset_right (image_subset_range _ _)]
@[deprecated (since := "2024-10-26")]
alias Embedding.map_nhdsWithin_eq := IsEmbedding.map_nhdsWithin_eq
theorem Topology.IsOpenEmbedding.map_nhdsWithin_preimage_eq {f : α → β} (hf : IsOpenEmbedding f)
(s : Set β) (x : α) : map f (𝓝[f ⁻¹' s] x) = 𝓝[s] f x := by
rw [hf.isEmbedding.map_nhdsWithin_eq, image_preimage_eq_inter_range]
apply nhdsWithin_eq_nhdsWithin (mem_range_self _) hf.isOpen_range
rw [inter_assoc, inter_self]
theorem Topology.IsQuotientMap.continuousOn_isOpen_iff {f : α → β} {g : β → γ} (h : IsQuotientMap f)
{s : Set β} (hs : IsOpen s) : ContinuousOn g s ↔ ContinuousOn (g ∘ f) (f ⁻¹' s) := by
simp only [continuousOn_iff_continuous_restrict, (h.restrictPreimage_isOpen hs).continuous_iff]
rfl
@[deprecated (since := "2024-10-22")]
alias QuotientMap.continuousOn_isOpen_iff := IsQuotientMap.continuousOn_isOpen_iff
theorem IsOpenMap.continuousOn_image_of_leftInvOn {f : α → β} {s : Set α}
(h : IsOpenMap (s.restrict f)) {finv : β → α} (hleft : LeftInvOn finv f s) :
ContinuousOn finv (f '' s) := by
refine continuousOn_iff'.2 fun t ht => ⟨f '' (t ∩ s), ?_, ?_⟩
· rw [← image_restrict]
exact h _ (ht.preimage continuous_subtype_val)
· rw [inter_eq_self_of_subset_left (image_subset f inter_subset_right), hleft.image_inter']
theorem IsOpenMap.continuousOn_range_of_leftInverse {f : α → β} (hf : IsOpenMap f) {finv : β → α}
(hleft : Function.LeftInverse finv f) : ContinuousOn finv (range f) := by
rw [← image_univ]
exact (hf.restrict isOpen_univ).continuousOn_image_of_leftInvOn fun x _ => hleft x
/-- If `f` is continuous on an open set `s` and continuous at each point of another
set `t` then `f` is continuous on `s ∪ t`. -/
lemma ContinuousOn.union_continuousAt {f : α → β} (s_op : IsOpen s)
(hs : ContinuousOn f s) (ht : ∀ x ∈ t, ContinuousAt f x) :
ContinuousOn f (s ∪ t) :=
continuousOn_of_forall_continuousAt <| fun _ hx => hx.elim
(fun h => ContinuousWithinAt.continuousAt (continuousWithinAt hs h) <| IsOpen.mem_nhds s_op h)
(ht _)
open Classical in
/-- If a function is continuous on two closed sets, it is also continuous on their union. -/
| Mathlib/Topology/ContinuousOn.lean | 1,353 | 1,360 | theorem ContinuousOn.union_isClosed (hs : IsClosed s)
(ht : IsClosed t) {f : α → β} (hfs : ContinuousOn f s)
(hft : ContinuousOn f t) : ContinuousOn f (s ∪ t) := by | refine fun x hx ↦ .union ?_ ?_
· refine if hx : x ∈ s then hfs x hx else continuousWithinAt_of_not_mem_closure ?_
rwa [hs.closure_eq]
· refine if hx : x ∈ t then hft x hx else continuousWithinAt_of_not_mem_closure ?_
rwa [ht.closure_eq] |
/-
Copyright (c) 2023 Xavier Roblot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Xavier Roblot
-/
import Mathlib.Analysis.SpecialFunctions.PolarCoord
import Mathlib.Analysis.SpecialFunctions.Gamma.Basic
/-!
# Integrals involving the Gamma function
In this file, we collect several integrals over `ℝ` or `ℂ` that evaluate in terms of the
`Real.Gamma` function.
-/
open Real Set MeasureTheory MeasureTheory.Measure
section real
theorem integral_rpow_mul_exp_neg_rpow {p q : ℝ} (hp : 0 < p) (hq : -1 < q) :
∫ x in Ioi (0 : ℝ), x ^ q * exp (- x ^ p) = (1 / p) * Gamma ((q + 1) / p) := by
calc
_ = ∫ (x : ℝ) in Ioi 0, (1 / p * x ^ (1 / p - 1)) • ((x ^ (1 / p)) ^ q * exp (-x)) := by
rw [← integral_comp_rpow_Ioi _ (one_div_ne_zero (ne_of_gt hp)),
abs_eq_self.mpr (le_of_lt (one_div_pos.mpr hp))]
refine setIntegral_congr_fun measurableSet_Ioi (fun _ hx => ?_)
rw [← rpow_mul (le_of_lt hx) _ p, one_div_mul_cancel (ne_of_gt hp), rpow_one]
_ = ∫ (x : ℝ) in Ioi 0, 1 / p * exp (-x) * x ^ (1 / p - 1 + q / p) := by
simp_rw [smul_eq_mul, mul_assoc]
refine setIntegral_congr_fun measurableSet_Ioi (fun _ hx => ?_)
rw [← rpow_mul (le_of_lt hx), div_mul_eq_mul_div, one_mul, rpow_add hx]
ring_nf
_ = (1 / p) * Gamma ((q + 1) / p) := by
rw [Gamma_eq_integral (div_pos (neg_lt_iff_pos_add.mp hq) hp)]
simp_rw [show 1 / p - 1 + q / p = (q + 1) / p - 1 by field_simp; ring, ← integral_const_mul,
← mul_assoc]
theorem integral_rpow_mul_exp_neg_mul_rpow {p q b : ℝ} (hp : 0 < p) (hq : -1 < q) (hb : 0 < b) :
∫ x in Ioi (0 : ℝ), x ^ q * exp (- b * x ^ p) =
b ^ (-(q + 1) / p) * (1 / p) * Gamma ((q + 1) / p) := by
calc
_ = ∫ x in Ioi (0 : ℝ), b ^ (-p⁻¹ * q) * ((b ^ p⁻¹ * x) ^ q * rexp (-(b ^ p⁻¹ * x) ^ p)) := by
refine setIntegral_congr_fun measurableSet_Ioi (fun _ hx => ?_)
rw [mul_rpow _ (le_of_lt hx), mul_rpow _ (le_of_lt hx), ← rpow_mul, ← rpow_mul,
inv_mul_cancel₀, rpow_one, mul_assoc, ← mul_assoc, ← rpow_add, neg_mul p⁻¹, neg_add_cancel,
rpow_zero, one_mul, neg_mul]
all_goals positivity
_ = (b ^ p⁻¹)⁻¹ * ∫ x in Ioi (0 : ℝ), b ^ (-p⁻¹ * q) * (x ^ q * rexp (-x ^ p)) := by
rw [integral_comp_mul_left_Ioi (fun x => b ^ (-p⁻¹ * q) * (x ^ q * exp (- x ^ p))) 0,
mul_zero, smul_eq_mul]
all_goals positivity
_ = b ^ (-(q + 1) / p) * (1 / p) * Gamma ((q + 1) / p) := by
rw [integral_const_mul, integral_rpow_mul_exp_neg_rpow _ hq, mul_assoc, ← mul_assoc,
← rpow_neg_one, ← rpow_mul, ← rpow_add]
· congr; ring
all_goals positivity
theorem integral_exp_neg_rpow {p : ℝ} (hp : 0 < p) :
∫ x in Ioi (0 : ℝ), exp (- x ^ p) = Gamma (1 / p + 1) := by
convert (integral_rpow_mul_exp_neg_rpow hp neg_one_lt_zero) using 1
· simp_rw [rpow_zero, one_mul]
· rw [zero_add, Gamma_add_one (one_div_ne_zero (ne_of_gt hp))]
theorem integral_exp_neg_mul_rpow {p b : ℝ} (hp : 0 < p) (hb : 0 < b) :
∫ x in Ioi (0 : ℝ), exp (- b * x ^ p) = b ^ (- 1 / p) * Gamma (1 / p + 1) := by
convert (integral_rpow_mul_exp_neg_mul_rpow hp neg_one_lt_zero hb) using 1
· simp_rw [rpow_zero, one_mul]
· rw [zero_add, Gamma_add_one (one_div_ne_zero (ne_of_gt hp)), mul_assoc]
end real
section complex
| Mathlib/MeasureTheory/Integral/Gamma.lean | 75 | 97 | theorem Complex.integral_rpow_mul_exp_neg_rpow {p q : ℝ} (hp : 1 ≤ p) (hq : -2 < q) :
∫ x : ℂ, ‖x‖ ^ q * rexp (- ‖x‖ ^ p) = (2 * π / p) * Real.Gamma ((q + 2) / p) := by | calc
_ = ∫ x in Ioi (0 : ℝ) ×ˢ Ioo (-π) π, x.1 * (|x.1| ^ q * rexp (-|x.1| ^ p)) := by
rw [← Complex.integral_comp_polarCoord_symm, polarCoord_target]
simp_rw [Complex.norm_polarCoord_symm, smul_eq_mul]
_ = (∫ x in Ioi (0 : ℝ), x * |x| ^ q * rexp (-|x| ^ p)) * ∫ _ in Ioo (-π) π, 1 := by
rw [← setIntegral_prod_mul, volume_eq_prod]
simp_rw [mul_one]
congr! 2; ring
_ = 2 * π * ∫ x in Ioi (0 : ℝ), x * |x| ^ q * rexp (-|x| ^ p) := by
simp_rw [integral_const, measureReal_restrict_apply MeasurableSet.univ, Set.univ_inter,
volume_real_Ioo_of_le (a := -π) (b := π) (by linarith [pi_nonneg]),
sub_neg_eq_add, ← two_mul, smul_eq_mul, mul_one, mul_comm]
_ = 2 * π * ∫ x in Ioi (0 : ℝ), x ^ (q + 1) * rexp (-x ^ p) := by
congr 1
refine setIntegral_congr_fun measurableSet_Ioi (fun x hx => ?_)
rw [mem_Ioi] at hx
rw [abs_eq_self.mpr hx.le, rpow_add hx, rpow_one]
ring
_ = (2 * Real.pi / p) * Real.Gamma ((q + 2) / p) := by
rw [_root_.integral_rpow_mul_exp_neg_rpow (by linarith) (by linarith), add_assoc,
one_add_one_eq_two] |
/-
Copyright (c) 2023 Peter Nelson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Peter Nelson
-/
import Mathlib.SetTheory.Cardinal.Finite
import Mathlib.Data.Set.Finite.Powerset
/-!
# Noncomputable Set Cardinality
We define the cardinality of set `s` as a term `Set.encard s : ℕ∞` and a term `Set.ncard s : ℕ`.
The latter takes the junk value of zero if `s` is infinite. Both functions are noncomputable, and
are defined in terms of `ENat.card` (which takes a type as its argument); this file can be seen
as an API for the same function in the special case where the type is a coercion of a `Set`,
allowing for smoother interactions with the `Set` API.
`Set.encard` never takes junk values, so is more mathematically natural than `Set.ncard`, even
though it takes values in a less convenient type. It is probably the right choice in settings where
one is concerned with the cardinalities of sets that may or may not be infinite.
`Set.ncard` has a nicer codomain, but when using it, `Set.Finite` hypotheses are normally needed to
make sure its values are meaningful. More generally, `Set.ncard` is intended to be used over the
obvious alternative `Finset.card` when finiteness is 'propositional' rather than 'structural'.
When working with sets that are finite by virtue of their definition, then `Finset.card` probably
makes more sense. One setting where `Set.ncard` works nicely is in a type `α` with `[Finite α]`,
where every set is automatically finite. In this setting, we use default arguments and a simple
tactic so that finiteness goals are discharged automatically in `Set.ncard` theorems.
## Main Definitions
* `Set.encard s` is the cardinality of the set `s` as an extended natural number, with value `⊤` if
`s` is infinite.
* `Set.ncard s` is the cardinality of the set `s` as a natural number, provided `s` is Finite.
If `s` is Infinite, then `Set.ncard s = 0`.
* `toFinite_tac` is a tactic that tries to synthesize a `Set.Finite s` argument with
`Set.toFinite`. This will work for `s : Set α` where there is a `Finite α` instance.
## Implementation Notes
The theorems in this file are very similar to those in `Data.Finset.Card`, but with `Set` operations
instead of `Finset`. We first prove all the theorems for `Set.encard`, and then derive most of the
`Set.ncard` results as a consequence. Things are done this way to avoid reliance on the `Finset` API
for theorems about infinite sets, and to allow for a refactor that removes or modifies `Set.ncard`
in the future.
Nearly all the theorems for `Set.ncard` require finiteness of one or more of their arguments. We
provide this assumption with a default argument of the form `(hs : s.Finite := by toFinite_tac)`,
where `toFinite_tac` will find an `s.Finite` term in the cases where `s` is a set in a `Finite`
type.
Often, where there are two set arguments `s` and `t`, the finiteness of one follows from the other
in the context of the theorem, in which case we only include the ones that are needed, and derive
the other inside the proof. A few of the theorems, such as `ncard_union_le` do not require
finiteness arguments; they are true by coincidence due to junk values.
-/
namespace Set
variable {α β : Type*} {s t : Set α}
/-- The cardinality of a set as a term in `ℕ∞` -/
noncomputable def encard (s : Set α) : ℕ∞ := ENat.card s
@[simp] theorem encard_univ_coe (s : Set α) : encard (univ : Set s) = encard s := by
rw [encard, encard, ENat.card_congr (Equiv.Set.univ ↑s)]
theorem encard_univ (α : Type*) :
encard (univ : Set α) = ENat.card α := by
rw [encard, ENat.card_congr (Equiv.Set.univ α)]
theorem Finite.encard_eq_coe_toFinset_card (h : s.Finite) : s.encard = h.toFinset.card := by
have := h.fintype
rw [encard, ENat.card_eq_coe_fintype_card, toFinite_toFinset, toFinset_card]
theorem encard_eq_coe_toFinset_card (s : Set α) [Fintype s] : encard s = s.toFinset.card := by
have h := toFinite s
rw [h.encard_eq_coe_toFinset_card, toFinite_toFinset]
@[simp] theorem toENat_cardinalMk (s : Set α) : (Cardinal.mk s).toENat = s.encard := rfl
theorem toENat_cardinalMk_subtype (P : α → Prop) :
(Cardinal.mk {x // P x}).toENat = {x | P x}.encard :=
rfl
@[simp] theorem coe_fintypeCard (s : Set α) [Fintype s] : Fintype.card s = s.encard := by
simp [encard_eq_coe_toFinset_card]
@[simp, norm_cast] theorem encard_coe_eq_coe_finsetCard (s : Finset α) :
encard (s : Set α) = s.card := by
rw [Finite.encard_eq_coe_toFinset_card (Finset.finite_toSet s)]; simp
@[simp] theorem Infinite.encard_eq {s : Set α} (h : s.Infinite) : s.encard = ⊤ := by
have := h.to_subtype
rw [encard, ENat.card_eq_top_of_infinite]
@[simp] theorem encard_eq_zero : s.encard = 0 ↔ s = ∅ := by
rw [encard, ENat.card_eq_zero_iff_empty, isEmpty_subtype, eq_empty_iff_forall_not_mem]
@[simp] theorem encard_empty : (∅ : Set α).encard = 0 := by
rw [encard_eq_zero]
theorem nonempty_of_encard_ne_zero (h : s.encard ≠ 0) : s.Nonempty := by
rwa [nonempty_iff_ne_empty, Ne, ← encard_eq_zero]
theorem encard_ne_zero : s.encard ≠ 0 ↔ s.Nonempty := by
rw [ne_eq, encard_eq_zero, nonempty_iff_ne_empty]
@[simp] theorem encard_pos : 0 < s.encard ↔ s.Nonempty := by
rw [pos_iff_ne_zero, encard_ne_zero]
protected alias ⟨_, Nonempty.encard_pos⟩ := encard_pos
@[simp] theorem encard_singleton (e : α) : ({e} : Set α).encard = 1 := by
rw [encard, ENat.card_eq_coe_fintype_card, Fintype.card_ofSubsingleton, Nat.cast_one]
theorem encard_union_eq (h : Disjoint s t) : (s ∪ t).encard = s.encard + t.encard := by
classical
simp [encard, ENat.card_congr (Equiv.Set.union h)]
theorem encard_insert_of_not_mem {a : α} (has : a ∉ s) : (insert a s).encard = s.encard + 1 := by
rw [← union_singleton, encard_union_eq (by simpa), encard_singleton]
theorem Finite.encard_lt_top (h : s.Finite) : s.encard < ⊤ := by
induction s, h using Set.Finite.induction_on with
| empty => simp
| insert hat _ ht' =>
rw [encard_insert_of_not_mem hat]
exact lt_tsub_iff_right.1 ht'
theorem Finite.encard_eq_coe (h : s.Finite) : s.encard = ENat.toNat s.encard :=
(ENat.coe_toNat h.encard_lt_top.ne).symm
theorem Finite.exists_encard_eq_coe (h : s.Finite) : ∃ (n : ℕ), s.encard = n :=
⟨_, h.encard_eq_coe⟩
@[simp] theorem encard_lt_top_iff : s.encard < ⊤ ↔ s.Finite :=
⟨fun h ↦ by_contra fun h' ↦ h.ne (Infinite.encard_eq h'), Finite.encard_lt_top⟩
@[simp] theorem encard_eq_top_iff : s.encard = ⊤ ↔ s.Infinite := by
rw [← not_iff_not, ← Ne, ← lt_top_iff_ne_top, encard_lt_top_iff, not_infinite]
alias ⟨_, encard_eq_top⟩ := encard_eq_top_iff
theorem encard_ne_top_iff : s.encard ≠ ⊤ ↔ s.Finite := by
simp
theorem finite_of_encard_le_coe {k : ℕ} (h : s.encard ≤ k) : s.Finite := by
rw [← encard_lt_top_iff]; exact h.trans_lt (WithTop.coe_lt_top _)
theorem finite_of_encard_eq_coe {k : ℕ} (h : s.encard = k) : s.Finite :=
finite_of_encard_le_coe h.le
theorem encard_le_coe_iff {k : ℕ} : s.encard ≤ k ↔ s.Finite ∧ ∃ (n₀ : ℕ), s.encard = n₀ ∧ n₀ ≤ k :=
⟨fun h ↦ ⟨finite_of_encard_le_coe h, by rwa [ENat.le_coe_iff] at h⟩,
fun ⟨_,⟨n₀,hs, hle⟩⟩ ↦ by rwa [hs, Nat.cast_le]⟩
@[simp]
theorem encard_prod : (s ×ˢ t).encard = s.encard * t.encard := by
simp [Set.encard, ENat.card_congr (Equiv.Set.prod ..)]
section Lattice
theorem encard_le_encard (h : s ⊆ t) : s.encard ≤ t.encard := by
rw [← union_diff_cancel h, encard_union_eq disjoint_sdiff_right]; exact le_self_add
@[deprecated (since := "2025-01-05")] alias encard_le_card := encard_le_encard
theorem encard_mono {α : Type*} : Monotone (encard : Set α → ℕ∞) :=
fun _ _ ↦ encard_le_encard
theorem encard_diff_add_encard_of_subset (h : s ⊆ t) : (t \ s).encard + s.encard = t.encard := by
rw [← encard_union_eq disjoint_sdiff_left, diff_union_self, union_eq_self_of_subset_right h]
@[simp] theorem one_le_encard_iff_nonempty : 1 ≤ s.encard ↔ s.Nonempty := by
rw [nonempty_iff_ne_empty, Ne, ← encard_eq_zero, ENat.one_le_iff_ne_zero]
theorem encard_diff_add_encard_inter (s t : Set α) :
(s \ t).encard + (s ∩ t).encard = s.encard := by
rw [← encard_union_eq (disjoint_of_subset_right inter_subset_right disjoint_sdiff_left),
diff_union_inter]
theorem encard_union_add_encard_inter (s t : Set α) :
(s ∪ t).encard + (s ∩ t).encard = s.encard + t.encard := by
rw [← diff_union_self, encard_union_eq disjoint_sdiff_left, add_right_comm,
encard_diff_add_encard_inter]
theorem encard_eq_encard_iff_encard_diff_eq_encard_diff (h : (s ∩ t).Finite) :
s.encard = t.encard ↔ (s \ t).encard = (t \ s).encard := by
rw [← encard_diff_add_encard_inter s t, ← encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_right_inj h.encard_lt_top.ne]
theorem encard_le_encard_iff_encard_diff_le_encard_diff (h : (s ∩ t).Finite) :
s.encard ≤ t.encard ↔ (s \ t).encard ≤ (t \ s).encard := by
rw [← encard_diff_add_encard_inter s t, ← encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_le_add_iff_right h.encard_lt_top.ne]
theorem encard_lt_encard_iff_encard_diff_lt_encard_diff (h : (s ∩ t).Finite) :
s.encard < t.encard ↔ (s \ t).encard < (t \ s).encard := by
rw [← encard_diff_add_encard_inter s t, ← encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_lt_add_iff_right h.encard_lt_top.ne]
theorem encard_union_le (s t : Set α) : (s ∪ t).encard ≤ s.encard + t.encard := by
rw [← encard_union_add_encard_inter]; exact le_self_add
theorem finite_iff_finite_of_encard_eq_encard (h : s.encard = t.encard) : s.Finite ↔ t.Finite := by
rw [← encard_lt_top_iff, ← encard_lt_top_iff, h]
theorem infinite_iff_infinite_of_encard_eq_encard (h : s.encard = t.encard) :
s.Infinite ↔ t.Infinite := by rw [← encard_eq_top_iff, h, encard_eq_top_iff]
theorem Finite.finite_of_encard_le {s : Set α} {t : Set β} (hs : s.Finite)
(h : t.encard ≤ s.encard) : t.Finite :=
encard_lt_top_iff.1 (h.trans_lt hs.encard_lt_top)
lemma Finite.eq_of_subset_of_encard_le' (ht : t.Finite) (hst : s ⊆ t) (hts : t.encard ≤ s.encard) :
s = t := by
rw [← zero_add (a := encard s), ← encard_diff_add_encard_of_subset hst] at hts
have hdiff := WithTop.le_of_add_le_add_right (ht.subset hst).encard_lt_top.ne hts
rw [nonpos_iff_eq_zero, encard_eq_zero, diff_eq_empty] at hdiff
exact hst.antisymm hdiff
theorem Finite.eq_of_subset_of_encard_le (hs : s.Finite) (hst : s ⊆ t)
(hts : t.encard ≤ s.encard) : s = t :=
(hs.finite_of_encard_le hts).eq_of_subset_of_encard_le' hst hts
theorem Finite.encard_lt_encard (hs : s.Finite) (h : s ⊂ t) : s.encard < t.encard :=
(encard_mono h.subset).lt_of_ne fun he ↦ h.ne (hs.eq_of_subset_of_encard_le h.subset he.symm.le)
theorem encard_strictMono [Finite α] : StrictMono (encard : Set α → ℕ∞) :=
fun _ _ h ↦ (toFinite _).encard_lt_encard h
theorem encard_diff_add_encard (s t : Set α) : (s \ t).encard + t.encard = (s ∪ t).encard := by
rw [← encard_union_eq disjoint_sdiff_left, diff_union_self]
theorem encard_le_encard_diff_add_encard (s t : Set α) : s.encard ≤ (s \ t).encard + t.encard :=
(encard_mono subset_union_left).trans_eq (encard_diff_add_encard _ _).symm
theorem tsub_encard_le_encard_diff (s t : Set α) : s.encard - t.encard ≤ (s \ t).encard := by
rw [tsub_le_iff_left, add_comm]; apply encard_le_encard_diff_add_encard
theorem encard_add_encard_compl (s : Set α) : s.encard + sᶜ.encard = (univ : Set α).encard := by
rw [← encard_union_eq disjoint_compl_right, union_compl_self]
end Lattice
section InsertErase
variable {a b : α}
theorem encard_insert_le (s : Set α) (x : α) : (insert x s).encard ≤ s.encard + 1 := by
rw [← union_singleton, ← encard_singleton x]; apply encard_union_le
theorem encard_singleton_inter (s : Set α) (x : α) : ({x} ∩ s).encard ≤ 1 := by
rw [← encard_singleton x]; exact encard_le_encard inter_subset_left
theorem encard_diff_singleton_add_one (h : a ∈ s) :
(s \ {a}).encard + 1 = s.encard := by
rw [← encard_insert_of_not_mem (fun h ↦ h.2 rfl), insert_diff_singleton, insert_eq_of_mem h]
theorem encard_diff_singleton_of_mem (h : a ∈ s) :
(s \ {a}).encard = s.encard - 1 := by
rw [← encard_diff_singleton_add_one h, ← WithTop.add_right_inj WithTop.one_ne_top,
tsub_add_cancel_of_le (self_le_add_left _ _)]
theorem encard_tsub_one_le_encard_diff_singleton (s : Set α) (x : α) :
s.encard - 1 ≤ (s \ {x}).encard := by
rw [← encard_singleton x]; apply tsub_encard_le_encard_diff
theorem encard_exchange (ha : a ∉ s) (hb : b ∈ s) : (insert a (s \ {b})).encard = s.encard := by
rw [encard_insert_of_not_mem, encard_diff_singleton_add_one hb]
simp_all only [not_true, mem_diff, mem_singleton_iff, false_and, not_false_eq_true]
theorem encard_exchange' (ha : a ∉ s) (hb : b ∈ s) : (insert a s \ {b}).encard = s.encard := by
rw [← insert_diff_singleton_comm (by rintro rfl; exact ha hb), encard_exchange ha hb]
theorem encard_eq_add_one_iff {k : ℕ∞} :
s.encard = k + 1 ↔ (∃ a t, ¬a ∈ t ∧ insert a t = s ∧ t.encard = k) := by
refine ⟨fun h ↦ ?_, ?_⟩
· obtain ⟨a, ha⟩ := nonempty_of_encard_ne_zero (s := s) (by simp [h])
refine ⟨a, s \ {a}, fun h ↦ h.2 rfl, by rwa [insert_diff_singleton, insert_eq_of_mem], ?_⟩
rw [← WithTop.add_right_inj WithTop.one_ne_top, ← h,
encard_diff_singleton_add_one ha]
rintro ⟨a, t, h, rfl, rfl⟩
rw [encard_insert_of_not_mem h]
/-- Every set is either empty, infinite, or can have its `encard` reduced by a removal. Intended
for well-founded induction on the value of `encard`. -/
theorem eq_empty_or_encard_eq_top_or_encard_diff_singleton_lt (s : Set α) :
s = ∅ ∨ s.encard = ⊤ ∨ ∃ a ∈ s, (s \ {a}).encard < s.encard := by
refine s.eq_empty_or_nonempty.elim Or.inl (Or.inr ∘ fun ⟨a,ha⟩ ↦
(s.finite_or_infinite.elim (fun hfin ↦ Or.inr ⟨a, ha, ?_⟩) (Or.inl ∘ Infinite.encard_eq)))
rw [← encard_diff_singleton_add_one ha]; nth_rw 1 [← add_zero (encard _)]
exact WithTop.add_lt_add_left hfin.diff.encard_lt_top.ne zero_lt_one
end InsertErase
section SmallSets
theorem encard_pair {x y : α} (hne : x ≠ y) : ({x, y} : Set α).encard = 2 := by
rw [encard_insert_of_not_mem (by simpa), ← one_add_one_eq_two,
WithTop.add_right_inj WithTop.one_ne_top, encard_singleton]
theorem encard_eq_one : s.encard = 1 ↔ ∃ x, s = {x} := by
refine ⟨fun h ↦ ?_, fun ⟨x, hx⟩ ↦ by rw [hx, encard_singleton]⟩
obtain ⟨x, hx⟩ := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp)
exact ⟨x, ((finite_singleton x).eq_of_subset_of_encard_le (by simpa) (by simp [h])).symm⟩
theorem encard_le_one_iff_eq : s.encard ≤ 1 ↔ s = ∅ ∨ ∃ x, s = {x} := by
rw [le_iff_lt_or_eq, lt_iff_not_le, ENat.one_le_iff_ne_zero, not_not, encard_eq_zero,
encard_eq_one]
theorem encard_le_one_iff : s.encard ≤ 1 ↔ ∀ a b, a ∈ s → b ∈ s → a = b := by
rw [encard_le_one_iff_eq, or_iff_not_imp_left, ← Ne, ← nonempty_iff_ne_empty]
refine ⟨fun h a b has hbs ↦ ?_,
fun h ⟨x, hx⟩ ↦ ⟨x, ((singleton_subset_iff.2 hx).antisymm' (fun y hy ↦ h _ _ hy hx))⟩⟩
obtain ⟨x, rfl⟩ := h ⟨_, has⟩
rw [(has : a = x), (hbs : b = x)]
theorem encard_le_one_iff_subsingleton : s.encard ≤ 1 ↔ s.Subsingleton := by
rw [encard_le_one_iff, Set.Subsingleton]
tauto
theorem one_lt_encard_iff_nontrivial : 1 < s.encard ↔ s.Nontrivial := by
rw [← not_iff_not, not_lt, Set.not_nontrivial_iff, ← encard_le_one_iff_subsingleton]
theorem one_lt_encard_iff : 1 < s.encard ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b := by
rw [← not_iff_not, not_exists, not_lt, encard_le_one_iff]; aesop
theorem exists_ne_of_one_lt_encard (h : 1 < s.encard) (a : α) : ∃ b ∈ s, b ≠ a := by
by_contra! h'
obtain ⟨b, b', hb, hb', hne⟩ := one_lt_encard_iff.1 h
apply hne
rw [h' b hb, h' b' hb']
theorem encard_eq_two : s.encard = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y} := by
refine ⟨fun h ↦ ?_, fun ⟨x, y, hne, hs⟩ ↦ by rw [hs, encard_pair hne]⟩
obtain ⟨x, hx⟩ := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp)
rw [← insert_eq_of_mem hx, ← insert_diff_singleton, encard_insert_of_not_mem (fun h ↦ h.2 rfl),
← one_add_one_eq_two, WithTop.add_right_inj (WithTop.one_ne_top), encard_eq_one] at h
obtain ⟨y, h⟩ := h
refine ⟨x, y, by rintro rfl; exact (h.symm.subset rfl).2 rfl, ?_⟩
rw [← h, insert_diff_singleton, insert_eq_of_mem hx]
| Mathlib/Data/Set/Card.lean | 345 | 349 | theorem encard_eq_three {α : Type u_1} {s : Set α} :
encard s = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z} := by | refine ⟨fun h ↦ ?_, fun ⟨x, y, z, hxy, hyz, hxz, hs⟩ ↦ ?_⟩
· obtain ⟨x, hx⟩ := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp)
rw [← insert_eq_of_mem hx, ← insert_diff_singleton, |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Sébastien Gouëzel, Patrick Massot
-/
import Mathlib.Topology.UniformSpace.Cauchy
import Mathlib.Topology.UniformSpace.Separation
import Mathlib.Topology.DenseEmbedding
/-!
# Uniform embeddings of uniform spaces.
Extension of uniform continuous functions.
-/
open Filter Function Set Uniformity Topology
section
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w} [UniformSpace α] [UniformSpace β] [UniformSpace γ]
{f : α → β}
/-!
### Uniform inducing maps
-/
/-- A map `f : α → β` between uniform spaces is called *uniform inducing* if the uniformity filter
on `α` is the pullback of the uniformity filter on `β` under `Prod.map f f`. If `α` is a separated
space, then this implies that `f` is injective, hence it is a `IsUniformEmbedding`. -/
@[mk_iff]
structure IsUniformInducing (f : α → β) : Prop where
/-- The uniformity filter on the domain is the pullback of the uniformity filter on the codomain
under `Prod.map f f`. -/
comap_uniformity : comap (fun x : α × α => (f x.1, f x.2)) (𝓤 β) = 𝓤 α
lemma isUniformInducing_iff_uniformSpace {f : α → β} :
IsUniformInducing f ↔ ‹UniformSpace β›.comap f = ‹UniformSpace α› := by
rw [isUniformInducing_iff, UniformSpace.ext_iff, Filter.ext_iff]
rfl
protected alias ⟨IsUniformInducing.comap_uniformSpace, _⟩ := isUniformInducing_iff_uniformSpace
lemma isUniformInducing_iff' {f : α → β} :
IsUniformInducing f ↔ UniformContinuous f ∧ comap (Prod.map f f) (𝓤 β) ≤ 𝓤 α := by
rw [isUniformInducing_iff, UniformContinuous, tendsto_iff_comap, le_antisymm_iff, and_comm]; rfl
protected lemma Filter.HasBasis.isUniformInducing_iff {ι ι'} {p : ι → Prop} {p' : ι' → Prop} {s s'}
(h : (𝓤 α).HasBasis p s) (h' : (𝓤 β).HasBasis p' s') {f : α → β} :
IsUniformInducing f ↔
(∀ i, p' i → ∃ j, p j ∧ ∀ x y, (x, y) ∈ s j → (f x, f y) ∈ s' i) ∧
(∀ j, p j → ∃ i, p' i ∧ ∀ x y, (f x, f y) ∈ s' i → (x, y) ∈ s j) := by
simp [isUniformInducing_iff', h.uniformContinuous_iff h', (h'.comap _).le_basis_iff h, subset_def]
theorem IsUniformInducing.mk' {f : α → β}
(h : ∀ s, s ∈ 𝓤 α ↔ ∃ t ∈ 𝓤 β, ∀ x y : α, (f x, f y) ∈ t → (x, y) ∈ s) : IsUniformInducing f :=
⟨by simp [eq_comm, Filter.ext_iff, subset_def, h]⟩
theorem IsUniformInducing.id : IsUniformInducing (@id α) :=
⟨by rw [← Prod.map_def, Prod.map_id, comap_id]⟩
theorem IsUniformInducing.comp {g : β → γ} (hg : IsUniformInducing g) {f : α → β}
(hf : IsUniformInducing f) : IsUniformInducing (g ∘ f) :=
⟨by rw [← hf.1, ← hg.1, comap_comap]; rfl⟩
theorem IsUniformInducing.of_comp_iff {g : β → γ} (hg : IsUniformInducing g) {f : α → β} :
IsUniformInducing (g ∘ f) ↔ IsUniformInducing f := by
refine ⟨fun h ↦ ?_, hg.comp⟩
rw [isUniformInducing_iff, ← hg.comap_uniformity, comap_comap, ← h.comap_uniformity,
Function.comp_def, Function.comp_def]
theorem IsUniformInducing.basis_uniformity {f : α → β} (hf : IsUniformInducing f) {ι : Sort*}
{p : ι → Prop} {s : ι → Set (β × β)} (H : (𝓤 β).HasBasis p s) :
(𝓤 α).HasBasis p fun i => Prod.map f f ⁻¹' s i :=
hf.1 ▸ H.comap _
theorem IsUniformInducing.cauchy_map_iff {f : α → β} (hf : IsUniformInducing f) {F : Filter α} :
Cauchy (map f F) ↔ Cauchy F := by
simp only [Cauchy, map_neBot_iff, prod_map_map_eq, map_le_iff_le_comap, ← hf.comap_uniformity]
theorem IsUniformInducing.of_comp {f : α → β} {g : β → γ} (hf : UniformContinuous f)
(hg : UniformContinuous g) (hgf : IsUniformInducing (g ∘ f)) : IsUniformInducing f := by
refine ⟨le_antisymm ?_ hf.le_comap⟩
rw [← hgf.1, ← Prod.map_def, ← Prod.map_def, ← Prod.map_comp_map f f g g, ← comap_comap]
exact comap_mono hg.le_comap
theorem IsUniformInducing.uniformContinuous {f : α → β} (hf : IsUniformInducing f) :
UniformContinuous f := (isUniformInducing_iff'.1 hf).1
theorem IsUniformInducing.uniformContinuous_iff {f : α → β} {g : β → γ} (hg : IsUniformInducing g) :
UniformContinuous f ↔ UniformContinuous (g ∘ f) := by
dsimp only [UniformContinuous, Tendsto]
simp only [← hg.comap_uniformity, ← map_le_iff_le_comap, Filter.map_map, Function.comp_def]
protected theorem IsUniformInducing.isUniformInducing_comp_iff {f : α → β} {g : β → γ}
(hg : IsUniformInducing g) : IsUniformInducing (g ∘ f) ↔ IsUniformInducing f := by
simp only [isUniformInducing_iff, ← hg.comap_uniformity, comap_comap, Function.comp_def]
theorem IsUniformInducing.uniformContinuousOn_iff {f : α → β} {g : β → γ} {S : Set α}
(hg : IsUniformInducing g) :
UniformContinuousOn f S ↔ UniformContinuousOn (g ∘ f) S := by
dsimp only [UniformContinuousOn, Tendsto]
rw [← hg.comap_uniformity, ← map_le_iff_le_comap, Filter.map_map, comp_def, comp_def]
theorem IsUniformInducing.isInducing {f : α → β} (h : IsUniformInducing f) : IsInducing f := by
obtain rfl := h.comap_uniformSpace
exact .induced f
@[deprecated (since := "2024-10-28")]
alias IsUniformInducing.inducing := IsUniformInducing.isInducing
@[deprecated (since := "2024-10-28")] alias UniformInducing.inducing := IsUniformInducing.isInducing
theorem IsUniformInducing.prod {α' : Type*} {β' : Type*} [UniformSpace α'] [UniformSpace β']
{e₁ : α → α'} {e₂ : β → β'} (h₁ : IsUniformInducing e₁) (h₂ : IsUniformInducing e₂) :
IsUniformInducing fun p : α × β => (e₁ p.1, e₂ p.2) :=
⟨by simp [Function.comp_def, uniformity_prod, ← h₁.1, ← h₂.1, comap_inf, comap_comap]⟩
lemma IsUniformInducing.isDenseInducing (h : IsUniformInducing f) (hd : DenseRange f) :
IsDenseInducing f where
toIsInducing := h.isInducing
dense := hd
lemma SeparationQuotient.isUniformInducing_mk :
IsUniformInducing (mk : α → SeparationQuotient α) :=
⟨comap_mk_uniformity⟩
protected theorem IsUniformInducing.injective [T0Space α] {f : α → β} (h : IsUniformInducing f) :
Injective f :=
h.isInducing.injective
/-!
### Uniform embeddings
-/
/-- A map `f : α → β` between uniform spaces is a *uniform embedding* if it is uniform inducing and
injective. If `α` is a separated space, then the latter assumption follows from the former. -/
@[mk_iff]
structure IsUniformEmbedding (f : α → β) : Prop extends IsUniformInducing f where
/-- A uniform embedding is injective. -/
injective : Function.Injective f
lemma IsUniformEmbedding.isUniformInducing (hf : IsUniformEmbedding f) : IsUniformInducing f :=
hf.toIsUniformInducing
theorem isUniformEmbedding_iff' {f : α → β} :
IsUniformEmbedding f ↔
Injective f ∧ UniformContinuous f ∧ comap (Prod.map f f) (𝓤 β) ≤ 𝓤 α := by
rw [isUniformEmbedding_iff, and_comm, isUniformInducing_iff']
theorem Filter.HasBasis.isUniformEmbedding_iff' {ι ι'} {p : ι → Prop} {p' : ι' → Prop} {s s'}
(h : (𝓤 α).HasBasis p s) (h' : (𝓤 β).HasBasis p' s') {f : α → β} :
IsUniformEmbedding f ↔ Injective f ∧
(∀ i, p' i → ∃ j, p j ∧ ∀ x y, (x, y) ∈ s j → (f x, f y) ∈ s' i) ∧
(∀ j, p j → ∃ i, p' i ∧ ∀ x y, (f x, f y) ∈ s' i → (x, y) ∈ s j) := by
rw [isUniformEmbedding_iff, and_comm, h.isUniformInducing_iff h']
theorem Filter.HasBasis.isUniformEmbedding_iff {ι ι'} {p : ι → Prop} {p' : ι' → Prop} {s s'}
(h : (𝓤 α).HasBasis p s) (h' : (𝓤 β).HasBasis p' s') {f : α → β} :
IsUniformEmbedding f ↔ Injective f ∧ UniformContinuous f ∧
(∀ j, p j → ∃ i, p' i ∧ ∀ x y, (f x, f y) ∈ s' i → (x, y) ∈ s j) := by
simp only [h.isUniformEmbedding_iff' h', h.uniformContinuous_iff h']
theorem isUniformEmbedding_subtype_val {p : α → Prop} :
IsUniformEmbedding (Subtype.val : Subtype p → α) :=
{ comap_uniformity := rfl
injective := Subtype.val_injective }
theorem isUniformEmbedding_set_inclusion {s t : Set α} (hst : s ⊆ t) :
IsUniformEmbedding (inclusion hst) where
comap_uniformity := by rw [uniformity_subtype, uniformity_subtype, comap_comap]; rfl
injective := inclusion_injective hst
theorem IsUniformEmbedding.comp {g : β → γ} (hg : IsUniformEmbedding g) {f : α → β}
(hf : IsUniformEmbedding f) : IsUniformEmbedding (g ∘ f) where
toIsUniformInducing := hg.isUniformInducing.comp hf.isUniformInducing
injective := hg.injective.comp hf.injective
theorem IsUniformEmbedding.of_comp_iff {g : β → γ} (hg : IsUniformEmbedding g) {f : α → β} :
IsUniformEmbedding (g ∘ f) ↔ IsUniformEmbedding f := by
simp_rw [isUniformEmbedding_iff, hg.isUniformInducing.of_comp_iff, hg.injective.of_comp_iff f]
theorem Equiv.isUniformEmbedding {α β : Type*} [UniformSpace α] [UniformSpace β] (f : α ≃ β)
(h₁ : UniformContinuous f) (h₂ : UniformContinuous f.symm) : IsUniformEmbedding f :=
isUniformEmbedding_iff'.2 ⟨f.injective, h₁, by rwa [← Equiv.prodCongr_apply, ← map_equiv_symm]⟩
theorem isUniformEmbedding_inl : IsUniformEmbedding (Sum.inl : α → α ⊕ β) :=
isUniformEmbedding_iff'.2 ⟨Sum.inl_injective, uniformContinuous_inl, fun s hs =>
⟨Prod.map Sum.inl Sum.inl '' s ∪ range (Prod.map Sum.inr Sum.inr),
union_mem_sup (image_mem_map hs) range_mem_map,
fun x h => by simpa [Prod.map_apply'] using h⟩⟩
theorem isUniformEmbedding_inr : IsUniformEmbedding (Sum.inr : β → α ⊕ β) :=
isUniformEmbedding_iff'.2 ⟨Sum.inr_injective, uniformContinuous_inr, fun s hs =>
⟨range (Prod.map Sum.inl Sum.inl) ∪ Prod.map Sum.inr Sum.inr '' s,
union_mem_sup range_mem_map (image_mem_map hs),
fun x h => by simpa [Prod.map_apply'] using h⟩⟩
/-- If the domain of a `IsUniformInducing` map `f` is a T₀ space, then `f` is injective,
hence it is a `IsUniformEmbedding`. -/
protected theorem IsUniformInducing.isUniformEmbedding [T0Space α] {f : α → β}
(hf : IsUniformInducing f) : IsUniformEmbedding f :=
⟨hf, hf.isInducing.injective⟩
theorem isUniformEmbedding_iff_isUniformInducing [T0Space α] {f : α → β} :
IsUniformEmbedding f ↔ IsUniformInducing f :=
⟨IsUniformEmbedding.isUniformInducing, IsUniformInducing.isUniformEmbedding⟩
/-- If a map `f : α → β` sends any two distinct points to point that are **not** related by a fixed
`s ∈ 𝓤 β`, then `f` is uniform inducing with respect to the discrete uniformity on `α`:
the preimage of `𝓤 β` under `Prod.map f f` is the principal filter generated by the diagonal in
`α × α`. -/
theorem comap_uniformity_of_spaced_out {α} {f : α → β} {s : Set (β × β)} (hs : s ∈ 𝓤 β)
(hf : Pairwise fun x y => (f x, f y) ∉ s) : comap (Prod.map f f) (𝓤 β) = 𝓟 idRel := by
refine le_antisymm ?_ (@refl_le_uniformity α (UniformSpace.comap f _))
calc
comap (Prod.map f f) (𝓤 β) ≤ comap (Prod.map f f) (𝓟 s) := comap_mono (le_principal_iff.2 hs)
_ = 𝓟 (Prod.map f f ⁻¹' s) := comap_principal
_ ≤ 𝓟 idRel := principal_mono.2 ?_
rintro ⟨x, y⟩; simpa [not_imp_not] using @hf x y
/-- If a map `f : α → β` sends any two distinct points to point that are **not** related by a fixed
`s ∈ 𝓤 β`, then `f` is a uniform embedding with respect to the discrete uniformity on `α`. -/
theorem isUniformEmbedding_of_spaced_out {α} {f : α → β} {s : Set (β × β)} (hs : s ∈ 𝓤 β)
(hf : Pairwise fun x y => (f x, f y) ∉ s) : @IsUniformEmbedding α β ⊥ ‹_› f := by
let _ : UniformSpace α := ⊥; have := discreteTopology_bot α
exact IsUniformInducing.isUniformEmbedding ⟨comap_uniformity_of_spaced_out hs hf⟩
protected lemma IsUniformEmbedding.isEmbedding {f : α → β} (h : IsUniformEmbedding f) :
IsEmbedding f where
toIsInducing := h.toIsUniformInducing.isInducing
injective := h.injective
@[deprecated (since := "2024-10-26")]
alias IsUniformEmbedding.embedding := IsUniformEmbedding.isEmbedding
theorem IsUniformEmbedding.isDenseEmbedding {f : α → β} (h : IsUniformEmbedding f)
(hd : DenseRange f) : IsDenseEmbedding f :=
{ h.isEmbedding with dense := hd }
| Mathlib/Topology/UniformSpace/UniformEmbedding.lean | 242 | 245 | theorem isClosedEmbedding_of_spaced_out {α} [TopologicalSpace α] [DiscreteTopology α]
[T0Space β] {f : α → β} {s : Set (β × β)} (hs : s ∈ 𝓤 β)
(hf : Pairwise fun x y => (f x, f y) ∉ s) : IsClosedEmbedding f := by | rcases @DiscreteTopology.eq_bot α _ _ with rfl; let _ : UniformSpace α := ⊥ |
/-
Copyright (c) 2020 Yury Kudryashov, Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Anne Baanen
-/
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Group.Action.Pi
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Fin
import Mathlib.Logic.Equiv.Fin.Basic
/-!
# Big operators and `Fin`
Some results about products and sums over the type `Fin`.
The most important results are the induction formulas `Fin.prod_univ_castSucc`
and `Fin.prod_univ_succ`, and the formula `Fin.prod_const` for the product of a
constant function. These results have variants for sums instead of products.
## Main declarations
* `finFunctionFinEquiv`: An explicit equivalence between `Fin n → Fin m` and `Fin (m ^ n)`.
-/
assert_not_exists Field
open Finset
variable {α M : Type*}
namespace Finset
@[to_additive]
theorem prod_range [CommMonoid M] {n : ℕ} (f : ℕ → M) :
∏ i ∈ Finset.range n, f i = ∏ i : Fin n, f i :=
(Fin.prod_univ_eq_prod_range _ _).symm
end Finset
namespace Fin
section CommMonoid
variable [CommMonoid M] {n : ℕ}
@[to_additive]
theorem prod_ofFn (f : Fin n → M) : (List.ofFn f).prod = ∏ i, f i := by
simp [prod_eq_multiset_prod]
@[to_additive]
| Mathlib/Algebra/BigOperators/Fin.lean | 52 | 54 | theorem prod_univ_def (f : Fin n → M) : ∏ i, f i = ((List.finRange n).map f).prod := by | rw [← List.ofFn_eq_map, prod_ofFn] |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes Hölzl, Patrick Massot
-/
import Mathlib.Data.Set.Image
import Mathlib.Data.SProd
/-!
# Sets in product and pi types
This file proves basic properties of product of sets in `α × β` and in `Π i, α i`, and of the
diagonal of a type.
## Main declarations
This file contains basic results on the following notions, which are defined in `Set.Operations`.
* `Set.prod`: Binary product of sets. For `s : Set α`, `t : Set β`, we have
`s.prod t : Set (α × β)`. Denoted by `s ×ˢ t`.
* `Set.diagonal`: Diagonal of a type. `Set.diagonal α = {(x, x) | x : α}`.
* `Set.offDiag`: Off-diagonal. `s ×ˢ s` without the diagonal.
* `Set.pi`: Arbitrary product of sets.
-/
open Function
namespace Set
/-! ### Cartesian binary product of sets -/
section Prod
variable {α β γ δ : Type*} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {a : α} {b : β}
theorem Subsingleton.prod (hs : s.Subsingleton) (ht : t.Subsingleton) :
(s ×ˢ t).Subsingleton := fun _x hx _y hy ↦
Prod.ext (hs hx.1 hy.1) (ht hx.2 hy.2)
noncomputable instance decidableMemProd [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] :
DecidablePred (· ∈ s ×ˢ t) := fun x => inferInstanceAs (Decidable (x.1 ∈ s ∧ x.2 ∈ t))
@[gcongr]
theorem prod_mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : s₁ ×ˢ t₁ ⊆ s₂ ×ˢ t₂ :=
fun _ ⟨h₁, h₂⟩ => ⟨hs h₁, ht h₂⟩
@[gcongr]
theorem prod_mono_left (hs : s₁ ⊆ s₂) : s₁ ×ˢ t ⊆ s₂ ×ˢ t :=
prod_mono hs Subset.rfl
@[gcongr]
theorem prod_mono_right (ht : t₁ ⊆ t₂) : s ×ˢ t₁ ⊆ s ×ˢ t₂ :=
prod_mono Subset.rfl ht
@[simp]
theorem prod_self_subset_prod_self : s₁ ×ˢ s₁ ⊆ s₂ ×ˢ s₂ ↔ s₁ ⊆ s₂ :=
⟨fun h _ hx => (h (mk_mem_prod hx hx)).1, fun h _ hx => ⟨h hx.1, h hx.2⟩⟩
@[simp]
theorem prod_self_ssubset_prod_self : s₁ ×ˢ s₁ ⊂ s₂ ×ˢ s₂ ↔ s₁ ⊂ s₂ :=
and_congr prod_self_subset_prod_self <| not_congr prod_self_subset_prod_self
theorem prod_subset_iff {P : Set (α × β)} : s ×ˢ t ⊆ P ↔ ∀ x ∈ s, ∀ y ∈ t, (x, y) ∈ P :=
⟨fun h _ hx _ hy => h (mk_mem_prod hx hy), fun h ⟨_, _⟩ hp => h _ hp.1 _ hp.2⟩
theorem forall_prod_set {p : α × β → Prop} : (∀ x ∈ s ×ˢ t, p x) ↔ ∀ x ∈ s, ∀ y ∈ t, p (x, y) :=
prod_subset_iff
theorem exists_prod_set {p : α × β → Prop} : (∃ x ∈ s ×ˢ t, p x) ↔ ∃ x ∈ s, ∃ y ∈ t, p (x, y) := by
simp [and_assoc]
@[simp]
theorem prod_empty : s ×ˢ (∅ : Set β) = ∅ := by
ext
exact iff_of_eq (and_false _)
@[simp]
theorem empty_prod : (∅ : Set α) ×ˢ t = ∅ := by
ext
exact iff_of_eq (false_and _)
@[simp, mfld_simps]
theorem univ_prod_univ : @univ α ×ˢ @univ β = univ := by
ext
exact iff_of_eq (true_and _)
theorem univ_prod {t : Set β} : (univ : Set α) ×ˢ t = Prod.snd ⁻¹' t := by simp [prod_eq]
theorem prod_univ {s : Set α} : s ×ˢ (univ : Set β) = Prod.fst ⁻¹' s := by simp [prod_eq]
@[simp] lemma prod_eq_univ [Nonempty α] [Nonempty β] : s ×ˢ t = univ ↔ s = univ ∧ t = univ := by
simp [eq_univ_iff_forall, forall_and]
theorem singleton_prod : ({a} : Set α) ×ˢ t = Prod.mk a '' t := by
ext ⟨x, y⟩
simp [and_left_comm, eq_comm]
theorem prod_singleton : s ×ˢ ({b} : Set β) = (fun a => (a, b)) '' s := by
ext ⟨x, y⟩
simp [and_left_comm, eq_comm]
@[simp]
theorem singleton_prod_singleton : ({a} : Set α) ×ˢ ({b} : Set β) = {(a, b)} := by ext ⟨c, d⟩; simp
@[simp]
theorem union_prod : (s₁ ∪ s₂) ×ˢ t = s₁ ×ˢ t ∪ s₂ ×ˢ t := by
ext ⟨x, y⟩
simp [or_and_right]
@[simp]
theorem prod_union : s ×ˢ (t₁ ∪ t₂) = s ×ˢ t₁ ∪ s ×ˢ t₂ := by
ext ⟨x, y⟩
simp [and_or_left]
theorem inter_prod : (s₁ ∩ s₂) ×ˢ t = s₁ ×ˢ t ∩ s₂ ×ˢ t := by
ext ⟨x, y⟩
simp only [← and_and_right, mem_inter_iff, mem_prod]
theorem prod_inter : s ×ˢ (t₁ ∩ t₂) = s ×ˢ t₁ ∩ s ×ˢ t₂ := by
ext ⟨x, y⟩
simp only [← and_and_left, mem_inter_iff, mem_prod]
@[mfld_simps]
theorem prod_inter_prod : s₁ ×ˢ t₁ ∩ s₂ ×ˢ t₂ = (s₁ ∩ s₂) ×ˢ (t₁ ∩ t₂) := by
ext ⟨x, y⟩
simp [and_assoc, and_left_comm]
lemma compl_prod_eq_union {α β : Type*} (s : Set α) (t : Set β) :
(s ×ˢ t)ᶜ = (sᶜ ×ˢ univ) ∪ (univ ×ˢ tᶜ) := by
ext p
simp only [mem_compl_iff, mem_prod, not_and, mem_union, mem_univ, and_true, true_and]
constructor <;> intro h
· by_cases fst_in_s : p.fst ∈ s
· exact Or.inr (h fst_in_s)
· exact Or.inl fst_in_s
· intro fst_in_s
simpa only [fst_in_s, not_true, false_or] using h
@[simp]
theorem disjoint_prod : Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) ↔ Disjoint s₁ s₂ ∨ Disjoint t₁ t₂ := by
simp_rw [disjoint_left, mem_prod, not_and_or, Prod.forall, and_imp, ← @forall_or_right α, ←
@forall_or_left β, ← @forall_or_right (_ ∈ s₁), ← @forall_or_left (_ ∈ t₁)]
theorem Disjoint.set_prod_left (hs : Disjoint s₁ s₂) (t₁ t₂ : Set β) :
Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) :=
disjoint_left.2 fun ⟨_a, _b⟩ ⟨ha₁, _⟩ ⟨ha₂, _⟩ => disjoint_left.1 hs ha₁ ha₂
theorem Disjoint.set_prod_right (ht : Disjoint t₁ t₂) (s₁ s₂ : Set α) :
Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) :=
disjoint_left.2 fun ⟨_a, _b⟩ ⟨_, hb₁⟩ ⟨_, hb₂⟩ => disjoint_left.1 ht hb₁ hb₂
theorem prodMap_image_prod (f : α → β) (g : γ → δ) (s : Set α) (t : Set γ) :
(Prod.map f g) '' (s ×ˢ t) = (f '' s) ×ˢ (g '' t) := by
ext
aesop
theorem insert_prod : insert a s ×ˢ t = Prod.mk a '' t ∪ s ×ˢ t := by
simp only [insert_eq, union_prod, singleton_prod]
theorem prod_insert : s ×ˢ insert b t = (fun a => (a, b)) '' s ∪ s ×ˢ t := by
simp only [insert_eq, prod_union, prod_singleton]
theorem prod_preimage_eq {f : γ → α} {g : δ → β} :
(f ⁻¹' s) ×ˢ (g ⁻¹' t) = (fun p : γ × δ => (f p.1, g p.2)) ⁻¹' s ×ˢ t :=
rfl
theorem prod_preimage_left {f : γ → α} :
(f ⁻¹' s) ×ˢ t = (fun p : γ × β => (f p.1, p.2)) ⁻¹' s ×ˢ t :=
rfl
theorem prod_preimage_right {g : δ → β} :
s ×ˢ (g ⁻¹' t) = (fun p : α × δ => (p.1, g p.2)) ⁻¹' s ×ˢ t :=
rfl
theorem preimage_prod_map_prod (f : α → β) (g : γ → δ) (s : Set β) (t : Set δ) :
Prod.map f g ⁻¹' s ×ˢ t = (f ⁻¹' s) ×ˢ (g ⁻¹' t) :=
rfl
theorem mk_preimage_prod (f : γ → α) (g : γ → β) :
(fun x => (f x, g x)) ⁻¹' s ×ˢ t = f ⁻¹' s ∩ g ⁻¹' t :=
rfl
@[simp]
theorem mk_preimage_prod_left (hb : b ∈ t) : (fun a => (a, b)) ⁻¹' s ×ˢ t = s := by
ext a
simp [hb]
@[simp]
theorem mk_preimage_prod_right (ha : a ∈ s) : Prod.mk a ⁻¹' s ×ˢ t = t := by
ext b
simp [ha]
@[simp]
theorem mk_preimage_prod_left_eq_empty (hb : b ∉ t) : (fun a => (a, b)) ⁻¹' s ×ˢ t = ∅ := by
ext a
simp [hb]
@[simp]
theorem mk_preimage_prod_right_eq_empty (ha : a ∉ s) : Prod.mk a ⁻¹' s ×ˢ t = ∅ := by
ext b
simp [ha]
theorem mk_preimage_prod_left_eq_if [DecidablePred (· ∈ t)] :
(fun a => (a, b)) ⁻¹' s ×ˢ t = if b ∈ t then s else ∅ := by split_ifs with h <;> simp [h]
theorem mk_preimage_prod_right_eq_if [DecidablePred (· ∈ s)] :
Prod.mk a ⁻¹' s ×ˢ t = if a ∈ s then t else ∅ := by split_ifs with h <;> simp [h]
theorem mk_preimage_prod_left_fn_eq_if [DecidablePred (· ∈ t)] (f : γ → α) :
(fun a => (f a, b)) ⁻¹' s ×ˢ t = if b ∈ t then f ⁻¹' s else ∅ := by
rw [← mk_preimage_prod_left_eq_if, prod_preimage_left, preimage_preimage]
theorem mk_preimage_prod_right_fn_eq_if [DecidablePred (· ∈ s)] (g : δ → β) :
(fun b => (a, g b)) ⁻¹' s ×ˢ t = if a ∈ s then g ⁻¹' t else ∅ := by
rw [← mk_preimage_prod_right_eq_if, prod_preimage_right, preimage_preimage]
@[simp]
theorem preimage_swap_prod (s : Set α) (t : Set β) : Prod.swap ⁻¹' s ×ˢ t = t ×ˢ s := by
ext ⟨x, y⟩
simp [and_comm]
@[simp]
theorem image_swap_prod (s : Set α) (t : Set β) : Prod.swap '' s ×ˢ t = t ×ˢ s := by
rw [image_swap_eq_preimage_swap, preimage_swap_prod]
theorem mapsTo_swap_prod (s : Set α) (t : Set β) : MapsTo Prod.swap (s ×ˢ t) (t ×ˢ s) :=
fun _ ⟨hx, hy⟩ ↦ ⟨hy, hx⟩
theorem prod_image_image_eq {m₁ : α → γ} {m₂ : β → δ} :
(m₁ '' s) ×ˢ (m₂ '' t) = (fun p : α × β => (m₁ p.1, m₂ p.2)) '' s ×ˢ t :=
ext <| by
simp [-exists_and_right, exists_and_right.symm, and_left_comm, and_assoc, and_comm]
theorem prod_range_range_eq {m₁ : α → γ} {m₂ : β → δ} :
range m₁ ×ˢ range m₂ = range fun p : α × β => (m₁ p.1, m₂ p.2) :=
ext <| by simp [range]
@[simp, mfld_simps]
theorem range_prodMap {m₁ : α → γ} {m₂ : β → δ} : range (Prod.map m₁ m₂) = range m₁ ×ˢ range m₂ :=
prod_range_range_eq.symm
@[deprecated (since := "2025-04-10")] alias range_prod_map := range_prodMap
theorem prod_range_univ_eq {m₁ : α → γ} :
range m₁ ×ˢ (univ : Set β) = range fun p : α × β => (m₁ p.1, p.2) :=
ext <| by simp [range]
theorem prod_univ_range_eq {m₂ : β → δ} :
(univ : Set α) ×ˢ range m₂ = range fun p : α × β => (p.1, m₂ p.2) :=
ext <| by simp [range]
theorem range_pair_subset (f : α → β) (g : α → γ) :
(range fun x => (f x, g x)) ⊆ range f ×ˢ range g := by
have : (fun x => (f x, g x)) = Prod.map f g ∘ fun x => (x, x) := funext fun x => rfl
rw [this, ← range_prodMap]
apply range_comp_subset_range
theorem Nonempty.prod : s.Nonempty → t.Nonempty → (s ×ˢ t).Nonempty := fun ⟨x, hx⟩ ⟨y, hy⟩ =>
⟨(x, y), ⟨hx, hy⟩⟩
theorem Nonempty.fst : (s ×ˢ t).Nonempty → s.Nonempty := fun ⟨x, hx⟩ => ⟨x.1, hx.1⟩
theorem Nonempty.snd : (s ×ˢ t).Nonempty → t.Nonempty := fun ⟨x, hx⟩ => ⟨x.2, hx.2⟩
@[simp]
theorem prod_nonempty_iff : (s ×ˢ t).Nonempty ↔ s.Nonempty ∧ t.Nonempty :=
⟨fun h => ⟨h.fst, h.snd⟩, fun h => h.1.prod h.2⟩
@[simp]
theorem prod_eq_empty_iff : s ×ˢ t = ∅ ↔ s = ∅ ∨ t = ∅ := by
simp only [not_nonempty_iff_eq_empty.symm, prod_nonempty_iff, not_and_or]
theorem prod_sub_preimage_iff {W : Set γ} {f : α × β → γ} :
s ×ˢ t ⊆ f ⁻¹' W ↔ ∀ a b, a ∈ s → b ∈ t → f (a, b) ∈ W := by simp [subset_def]
theorem image_prodMk_subset_prod {f : α → β} {g : α → γ} {s : Set α} :
(fun x => (f x, g x)) '' s ⊆ (f '' s) ×ˢ (g '' s) := by
rintro _ ⟨x, hx, rfl⟩
exact mk_mem_prod (mem_image_of_mem f hx) (mem_image_of_mem g hx)
@[deprecated (since := "2025-02-22")]
alias image_prod_mk_subset_prod := image_prodMk_subset_prod
theorem image_prodMk_subset_prod_left (hb : b ∈ t) : (fun a => (a, b)) '' s ⊆ s ×ˢ t := by
rintro _ ⟨a, ha, rfl⟩
exact ⟨ha, hb⟩
@[deprecated (since := "2025-02-22")]
alias image_prod_mk_subset_prod_left := image_prodMk_subset_prod_left
theorem image_prodMk_subset_prod_right (ha : a ∈ s) : Prod.mk a '' t ⊆ s ×ˢ t := by
rintro _ ⟨b, hb, rfl⟩
exact ⟨ha, hb⟩
@[deprecated (since := "2025-02-22")]
alias image_prod_mk_subset_prod_right := image_prodMk_subset_prod_right
theorem prod_subset_preimage_fst (s : Set α) (t : Set β) : s ×ˢ t ⊆ Prod.fst ⁻¹' s :=
inter_subset_left
theorem fst_image_prod_subset (s : Set α) (t : Set β) : Prod.fst '' s ×ˢ t ⊆ s :=
image_subset_iff.2 <| prod_subset_preimage_fst s t
theorem fst_image_prod (s : Set β) {t : Set α} (ht : t.Nonempty) : Prod.fst '' s ×ˢ t = s :=
(fst_image_prod_subset _ _).antisymm fun y hy =>
let ⟨x, hx⟩ := ht
⟨(y, x), ⟨hy, hx⟩, rfl⟩
lemma mapsTo_fst_prod {s : Set α} {t : Set β} : MapsTo Prod.fst (s ×ˢ t) s :=
fun _ hx ↦ (mem_prod.1 hx).1
theorem prod_subset_preimage_snd (s : Set α) (t : Set β) : s ×ˢ t ⊆ Prod.snd ⁻¹' t :=
inter_subset_right
theorem snd_image_prod_subset (s : Set α) (t : Set β) : Prod.snd '' s ×ˢ t ⊆ t :=
image_subset_iff.2 <| prod_subset_preimage_snd s t
theorem snd_image_prod {s : Set α} (hs : s.Nonempty) (t : Set β) : Prod.snd '' s ×ˢ t = t :=
(snd_image_prod_subset _ _).antisymm fun y y_in =>
let ⟨x, x_in⟩ := hs
⟨(x, y), ⟨x_in, y_in⟩, rfl⟩
lemma mapsTo_snd_prod {s : Set α} {t : Set β} : MapsTo Prod.snd (s ×ˢ t) t :=
fun _ hx ↦ (mem_prod.1 hx).2
theorem prod_diff_prod : s ×ˢ t \ s₁ ×ˢ t₁ = s ×ˢ (t \ t₁) ∪ (s \ s₁) ×ˢ t := by
ext x
by_cases h₁ : x.1 ∈ s₁ <;> by_cases h₂ : x.2 ∈ t₁ <;> simp [*]
/-- A product set is included in a product set if and only factors are included, or a factor of the
first set is empty. -/
theorem prod_subset_prod_iff : s ×ˢ t ⊆ s₁ ×ˢ t₁ ↔ s ⊆ s₁ ∧ t ⊆ t₁ ∨ s = ∅ ∨ t = ∅ := by
rcases (s ×ˢ t).eq_empty_or_nonempty with h | h
· simp [h, prod_eq_empty_iff.1 h]
have st : s.Nonempty ∧ t.Nonempty := by rwa [prod_nonempty_iff] at h
refine ⟨fun H => Or.inl ⟨?_, ?_⟩, ?_⟩
· have := image_subset (Prod.fst : α × β → α) H
rwa [fst_image_prod _ st.2, fst_image_prod _ (h.mono H).snd] at this
· have := image_subset (Prod.snd : α × β → β) H
rwa [snd_image_prod st.1, snd_image_prod (h.mono H).fst] at this
· intro H
simp only [st.1.ne_empty, st.2.ne_empty, or_false] at H
exact prod_mono H.1 H.2
theorem prod_eq_prod_iff_of_nonempty (h : (s ×ˢ t).Nonempty) :
s ×ˢ t = s₁ ×ˢ t₁ ↔ s = s₁ ∧ t = t₁ := by
constructor
· intro heq
have h₁ : (s₁ ×ˢ t₁ : Set _).Nonempty := by rwa [← heq]
rw [prod_nonempty_iff] at h h₁
rw [← fst_image_prod s h.2, ← fst_image_prod s₁ h₁.2, heq, eq_self_iff_true, true_and, ←
snd_image_prod h.1 t, ← snd_image_prod h₁.1 t₁, heq]
· rintro ⟨rfl, rfl⟩
rfl
theorem prod_eq_prod_iff :
s ×ˢ t = s₁ ×ˢ t₁ ↔ s = s₁ ∧ t = t₁ ∨ (s = ∅ ∨ t = ∅) ∧ (s₁ = ∅ ∨ t₁ = ∅) := by
symm
rcases eq_empty_or_nonempty (s ×ˢ t) with h | h
· simp_rw [h, @eq_comm _ ∅, prod_eq_empty_iff, prod_eq_empty_iff.mp h, true_and,
or_iff_right_iff_imp]
rintro ⟨rfl, rfl⟩
exact prod_eq_empty_iff.mp h
rw [prod_eq_prod_iff_of_nonempty h]
rw [nonempty_iff_ne_empty, Ne, prod_eq_empty_iff] at h
simp_rw [h, false_and, or_false]
@[simp]
theorem prod_eq_iff_eq (ht : t.Nonempty) : s ×ˢ t = s₁ ×ˢ t ↔ s = s₁ := by
simp_rw [prod_eq_prod_iff, ht.ne_empty, and_true, or_iff_left_iff_imp, or_false]
rintro ⟨rfl, rfl⟩
rfl
theorem subset_prod {s : Set (α × β)} : s ⊆ (Prod.fst '' s) ×ˢ (Prod.snd '' s) :=
fun _ hp ↦ mem_prod.2 ⟨mem_image_of_mem _ hp, mem_image_of_mem _ hp⟩
section Mono
variable [Preorder α] {f : α → Set β} {g : α → Set γ}
theorem _root_.Monotone.set_prod (hf : Monotone f) (hg : Monotone g) :
Monotone fun x => f x ×ˢ g x :=
fun _ _ h => prod_mono (hf h) (hg h)
theorem _root_.Antitone.set_prod (hf : Antitone f) (hg : Antitone g) :
Antitone fun x => f x ×ˢ g x :=
fun _ _ h => prod_mono (hf h) (hg h)
theorem _root_.MonotoneOn.set_prod (hf : MonotoneOn f s) (hg : MonotoneOn g s) :
MonotoneOn (fun x => f x ×ˢ g x) s := fun _ ha _ hb h => prod_mono (hf ha hb h) (hg ha hb h)
theorem _root_.AntitoneOn.set_prod (hf : AntitoneOn f s) (hg : AntitoneOn g s) :
AntitoneOn (fun x => f x ×ˢ g x) s := fun _ ha _ hb h => prod_mono (hf ha hb h) (hg ha hb h)
end Mono
end Prod
/-! ### Diagonal
In this section we prove some lemmas about the diagonal set `{p | p.1 = p.2}` and the diagonal map
`fun x ↦ (x, x)`.
-/
section Diagonal
variable {α : Type*} {s t : Set α}
lemma diagonal_nonempty [Nonempty α] : (diagonal α).Nonempty :=
Nonempty.elim ‹_› fun x => ⟨_, mem_diagonal x⟩
instance decidableMemDiagonal [h : DecidableEq α] (x : α × α) : Decidable (x ∈ diagonal α) :=
h x.1 x.2
theorem preimage_coe_coe_diagonal (s : Set α) :
Prod.map (fun x : s => (x : α)) (fun x : s => (x : α)) ⁻¹' diagonal α = diagonal s := by
ext ⟨⟨x, hx⟩, ⟨y, hy⟩⟩
simp [Set.diagonal]
@[simp]
theorem range_diag : (range fun x => (x, x)) = diagonal α := by
ext ⟨x, y⟩
simp [diagonal, eq_comm]
theorem diagonal_subset_iff {s} : diagonal α ⊆ s ↔ ∀ x, (x, x) ∈ s := by
rw [← range_diag, range_subset_iff]
@[simp]
theorem prod_subset_compl_diagonal_iff_disjoint : s ×ˢ t ⊆ (diagonal α)ᶜ ↔ Disjoint s t :=
prod_subset_iff.trans disjoint_iff_forall_ne.symm
@[simp]
theorem diag_preimage_prod (s t : Set α) : (fun x => (x, x)) ⁻¹' s ×ˢ t = s ∩ t :=
rfl
theorem diag_preimage_prod_self (s : Set α) : (fun x => (x, x)) ⁻¹' s ×ˢ s = s :=
inter_self s
theorem diag_image (s : Set α) : (fun x => (x, x)) '' s = diagonal α ∩ s ×ˢ s := by
rw [← range_diag, ← image_preimage_eq_range_inter, diag_preimage_prod_self]
theorem diagonal_eq_univ_iff : diagonal α = univ ↔ Subsingleton α := by
simp only [subsingleton_iff, eq_univ_iff_forall, Prod.forall, mem_diagonal_iff]
theorem diagonal_eq_univ [Subsingleton α] : diagonal α = univ := diagonal_eq_univ_iff.2 ‹_›
end Diagonal
/-- A function is `Function.const α a` for some `a` if and only if `∀ x y, f x = f y`. -/
theorem range_const_eq_diagonal {α β : Type*} [hβ : Nonempty β] :
range (const α) = {f : α → β | ∀ x y, f x = f y} := by
refine (range_eq_iff _ _).mpr ⟨fun _ _ _ ↦ rfl, fun f hf ↦ ?_⟩
rcases isEmpty_or_nonempty α with h|⟨⟨a⟩⟩
· exact hβ.elim fun b ↦ ⟨b, Subsingleton.elim _ _⟩
· exact ⟨f a, funext fun x ↦ hf _ _⟩
end Set
section Pullback
open Set
variable {X Y Z}
/-- The fiber product $X \times_Y Z$. -/
abbrev Function.Pullback (f : X → Y) (g : Z → Y) := {p : X × Z // f p.1 = g p.2}
/-- The fiber product $X \times_Y X$. -/
abbrev Function.PullbackSelf (f : X → Y) := f.Pullback f
/-- The projection from the fiber product to the first factor. -/
def Function.Pullback.fst {f : X → Y} {g : Z → Y} (p : f.Pullback g) : X := p.val.1
/-- The projection from the fiber product to the second factor. -/
def Function.Pullback.snd {f : X → Y} {g : Z → Y} (p : f.Pullback g) : Z := p.val.2
open Function.Pullback in
lemma Function.pullback_comm_sq (f : X → Y) (g : Z → Y) :
f ∘ @fst X Y Z f g = g ∘ @snd X Y Z f g := funext fun p ↦ p.2
/-- The diagonal map $\Delta: X \to X \times_Y X$. -/
@[simps]
def toPullbackDiag (f : X → Y) (x : X) : f.Pullback f := ⟨(x, x), rfl⟩
/-- The diagonal $\Delta(X) \subseteq X \times_Y X$. -/
def Function.pullbackDiagonal (f : X → Y) : Set (f.Pullback f) := {p | p.fst = p.snd}
/-- Three functions between the three pairs of spaces $X_i, Y_i, Z_i$ that are compatible
induce a function $X_1 \times_{Y_1} Z_1 \to X_2 \times_{Y_2} Z_2$. -/
def Function.mapPullback {X₁ X₂ Y₁ Y₂ Z₁ Z₂}
{f₁ : X₁ → Y₁} {g₁ : Z₁ → Y₁} {f₂ : X₂ → Y₂} {g₂ : Z₂ → Y₂}
(mapX : X₁ → X₂) (mapY : Y₁ → Y₂) (mapZ : Z₁ → Z₂)
(commX : f₂ ∘ mapX = mapY ∘ f₁) (commZ : g₂ ∘ mapZ = mapY ∘ g₁)
(p : f₁.Pullback g₁) : f₂.Pullback g₂ :=
⟨(mapX p.fst, mapZ p.snd),
(congr_fun commX _).trans <| (congr_arg mapY p.2).trans <| congr_fun commZ.symm _⟩
open Function.Pullback in
/-- The projection $(X \times_Y Z) \times_Z (X \times_Y Z) \to X \times_Y X$. -/
def Function.PullbackSelf.map_fst {f : X → Y} {g : Z → Y} :
(@snd X Y Z f g).PullbackSelf → f.PullbackSelf :=
mapPullback fst g fst (pullback_comm_sq f g) (pullback_comm_sq f g)
open Function.Pullback in
/-- The projection $(X \times_Y Z) \times_X (X \times_Y Z) \to Z \times_Y Z$. -/
def Function.PullbackSelf.map_snd {f : X → Y} {g : Z → Y} :
(@fst X Y Z f g).PullbackSelf → g.PullbackSelf :=
mapPullback snd f snd (pullback_comm_sq f g).symm (pullback_comm_sq f g).symm
open Function.PullbackSelf Function.Pullback
theorem preimage_map_fst_pullbackDiagonal {f : X → Y} {g : Z → Y} :
@map_fst X Y Z f g ⁻¹' pullbackDiagonal f = pullbackDiagonal (@snd X Y Z f g) := by
ext ⟨⟨p₁, p₂⟩, he⟩
simp_rw [pullbackDiagonal, mem_setOf, Subtype.ext_iff, Prod.ext_iff]
exact (and_iff_left he).symm
theorem Function.Injective.preimage_pullbackDiagonal {f : X → Y} {g : Z → X} (inj : g.Injective) :
mapPullback g id g (by rfl) (by rfl) ⁻¹' pullbackDiagonal f = pullbackDiagonal (f ∘ g) :=
ext fun _ ↦ inj.eq_iff
theorem image_toPullbackDiag (f : X → Y) (s : Set X) :
toPullbackDiag f '' s = pullbackDiagonal f ∩ Subtype.val ⁻¹' s ×ˢ s := by
ext x
constructor
· rintro ⟨x, hx, rfl⟩
exact ⟨rfl, hx, hx⟩
· obtain ⟨⟨x, y⟩, h⟩ := x
rintro ⟨rfl : x = y, h2x⟩
exact mem_image_of_mem _ h2x.1
theorem range_toPullbackDiag (f : X → Y) : range (toPullbackDiag f) = pullbackDiagonal f := by
rw [← image_univ, image_toPullbackDiag, univ_prod_univ, preimage_univ, inter_univ]
theorem injective_toPullbackDiag (f : X → Y) : (toPullbackDiag f).Injective :=
fun _ _ h ↦ congr_arg Prod.fst (congr_arg Subtype.val h)
end Pullback
namespace Set
section OffDiag
variable {α : Type*} {s t : Set α} {a : α}
theorem offDiag_mono : Monotone (offDiag : Set α → Set (α × α)) := fun _ _ h _ =>
And.imp (@h _) <| And.imp_left <| @h _
@[simp]
theorem offDiag_nonempty : s.offDiag.Nonempty ↔ s.Nontrivial := by
simp [offDiag, Set.Nonempty, Set.Nontrivial]
@[simp]
theorem offDiag_eq_empty : s.offDiag = ∅ ↔ s.Subsingleton := by
rw [← not_nonempty_iff_eq_empty, ← not_nontrivial_iff, offDiag_nonempty.not]
alias ⟨_, Nontrivial.offDiag_nonempty⟩ := offDiag_nonempty
alias ⟨_, Subsingleton.offDiag_eq_empty⟩ := offDiag_nonempty
variable (s t)
theorem offDiag_subset_prod : s.offDiag ⊆ s ×ˢ s := fun _ hx => ⟨hx.1, hx.2.1⟩
theorem offDiag_eq_sep_prod : s.offDiag = { x ∈ s ×ˢ s | x.1 ≠ x.2 } :=
ext fun _ => and_assoc.symm
@[simp]
theorem offDiag_empty : (∅ : Set α).offDiag = ∅ := by simp
@[simp]
theorem offDiag_singleton (a : α) : ({a} : Set α).offDiag = ∅ := by simp
@[simp]
theorem offDiag_univ : (univ : Set α).offDiag = (diagonal α)ᶜ :=
ext <| by simp
@[simp]
theorem prod_sdiff_diagonal : s ×ˢ s \ diagonal α = s.offDiag :=
ext fun _ => and_assoc
@[simp]
theorem disjoint_diagonal_offDiag : Disjoint (diagonal α) s.offDiag :=
disjoint_left.mpr fun _ hd ho => ho.2.2 hd
theorem offDiag_inter : (s ∩ t).offDiag = s.offDiag ∩ t.offDiag :=
ext fun x => by
simp only [mem_offDiag, mem_inter_iff]
tauto
variable {s t}
theorem offDiag_union (h : Disjoint s t) :
(s ∪ t).offDiag = s.offDiag ∪ t.offDiag ∪ s ×ˢ t ∪ t ×ˢ s := by
ext x
simp only [mem_offDiag, mem_union, ne_eq, mem_prod]
constructor
· rintro ⟨h0|h0, h1|h1, h2⟩ <;> simp [h0, h1, h2]
· rintro (((⟨h0, h1, h2⟩|⟨h0, h1, h2⟩)|⟨h0, h1⟩)|⟨h0, h1⟩) <;> simp [*]
· rintro h3
rw [h3] at h0
exact Set.disjoint_left.mp h h0 h1
· rintro h3
rw [h3] at h0
exact (Set.disjoint_right.mp h h0 h1).elim
theorem offDiag_insert (ha : a ∉ s) : (insert a s).offDiag = s.offDiag ∪ {a} ×ˢ s ∪ s ×ˢ {a} := by
rw [insert_eq, union_comm, offDiag_union, offDiag_singleton, union_empty, union_right_comm]
rw [disjoint_left]
rintro b hb (rfl : b = a)
exact ha hb
end OffDiag
/-! ### Cartesian set-indexed product of sets -/
section Pi
variable {ι : Type*} {α β : ι → Type*} {s s₁ s₂ : Set ι} {t t₁ t₂ : ∀ i, Set (α i)} {i : ι}
@[simp]
theorem empty_pi (s : ∀ i, Set (α i)) : pi ∅ s = univ := by
ext
simp [pi]
theorem subsingleton_univ_pi (ht : ∀ i, (t i).Subsingleton) :
(univ.pi t).Subsingleton := fun _f hf _g hg ↦ funext fun i ↦
(ht i) (hf _ <| mem_univ _) (hg _ <| mem_univ _)
@[simp]
theorem pi_univ (s : Set ι) : (pi s fun i => (univ : Set (α i))) = univ :=
eq_univ_of_forall fun _ _ _ => mem_univ _
@[simp]
theorem pi_univ_ite (s : Set ι) [DecidablePred (· ∈ s)] (t : ∀ i, Set (α i)) :
(pi univ fun i => if i ∈ s then t i else univ) = s.pi t := by
ext; simp_rw [Set.mem_pi]; apply forall_congr'; intro i; split_ifs with h <;> simp [h]
theorem pi_mono (h : ∀ i ∈ s, t₁ i ⊆ t₂ i) : pi s t₁ ⊆ pi s t₂ := fun _ hx i hi => h i hi <| hx i hi
theorem pi_inter_distrib : (s.pi fun i => t i ∩ t₁ i) = s.pi t ∩ s.pi t₁ :=
ext fun x => by simp only [forall_and, mem_pi, mem_inter_iff]
theorem pi_congr (h : s₁ = s₂) (h' : ∀ i ∈ s₁, t₁ i = t₂ i) : s₁.pi t₁ = s₂.pi t₂ :=
h ▸ ext fun _ => forall₂_congr fun i hi => h' i hi ▸ Iff.rfl
theorem pi_eq_empty (hs : i ∈ s) (ht : t i = ∅) : s.pi t = ∅ := by
ext f
simp only [mem_empty_iff_false, not_forall, iff_false, mem_pi, Classical.not_imp]
exact ⟨i, hs, by simp [ht]⟩
theorem univ_pi_eq_empty (ht : t i = ∅) : pi univ t = ∅ :=
pi_eq_empty (mem_univ i) ht
theorem pi_nonempty_iff : (s.pi t).Nonempty ↔ ∀ i, ∃ x, i ∈ s → x ∈ t i := by
simp [Classical.skolem, Set.Nonempty]
theorem univ_pi_nonempty_iff : (pi univ t).Nonempty ↔ ∀ i, (t i).Nonempty := by
simp [Classical.skolem, Set.Nonempty]
theorem pi_eq_empty_iff : s.pi t = ∅ ↔ ∃ i, IsEmpty (α i) ∨ i ∈ s ∧ t i = ∅ := by
rw [← not_nonempty_iff_eq_empty, pi_nonempty_iff]
push_neg
refine exists_congr fun i => ?_
cases isEmpty_or_nonempty (α i) <;> simp [*, forall_and, eq_empty_iff_forall_not_mem]
@[simp]
theorem univ_pi_eq_empty_iff : pi univ t = ∅ ↔ ∃ i, t i = ∅ := by
simp [← not_nonempty_iff_eq_empty, univ_pi_nonempty_iff]
@[simp]
theorem univ_pi_empty [h : Nonempty ι] : pi univ (fun _ => ∅ : ∀ i, Set (α i)) = ∅ :=
univ_pi_eq_empty_iff.2 <| h.elim fun x => ⟨x, rfl⟩
@[simp]
theorem disjoint_univ_pi : Disjoint (pi univ t₁) (pi univ t₂) ↔ ∃ i, Disjoint (t₁ i) (t₂ i) := by
simp only [disjoint_iff_inter_eq_empty, ← pi_inter_distrib, univ_pi_eq_empty_iff]
theorem Disjoint.set_pi (hi : i ∈ s) (ht : Disjoint (t₁ i) (t₂ i)) : Disjoint (s.pi t₁) (s.pi t₂) :=
disjoint_left.2 fun _ h₁ h₂ => disjoint_left.1 ht (h₁ _ hi) (h₂ _ hi)
theorem uniqueElim_preimage [Unique ι] (t : ∀ i, Set (α i)) :
uniqueElim ⁻¹' pi univ t = t (default : ι) := by ext; simp [Unique.forall_iff]
section Nonempty
variable [∀ i, Nonempty (α i)]
theorem pi_eq_empty_iff' : s.pi t = ∅ ↔ ∃ i ∈ s, t i = ∅ := by simp [pi_eq_empty_iff]
@[simp]
theorem disjoint_pi : Disjoint (s.pi t₁) (s.pi t₂) ↔ ∃ i ∈ s, Disjoint (t₁ i) (t₂ i) := by
simp only [disjoint_iff_inter_eq_empty, ← pi_inter_distrib, pi_eq_empty_iff']
end Nonempty
@[simp]
theorem insert_pi (i : ι) (s : Set ι) (t : ∀ i, Set (α i)) :
pi (insert i s) t = eval i ⁻¹' t i ∩ pi s t := by
ext
simp [pi, or_imp, forall_and]
@[simp]
theorem singleton_pi (i : ι) (t : ∀ i, Set (α i)) : pi {i} t = eval i ⁻¹' t i := by
ext
simp [pi]
theorem singleton_pi' (i : ι) (t : ∀ i, Set (α i)) : pi {i} t = { x | x i ∈ t i } :=
singleton_pi i t
theorem univ_pi_singleton (f : ∀ i, α i) : (pi univ fun i => {f i}) = ({f} : Set (∀ i, α i)) :=
ext fun g => by simp [funext_iff]
theorem preimage_pi (s : Set ι) (t : ∀ i, Set (β i)) (f : ∀ i, α i → β i) :
(fun (g : ∀ i, α i) i => f _ (g i)) ⁻¹' s.pi t = s.pi fun i => f i ⁻¹' t i :=
rfl
theorem pi_if {p : ι → Prop} [h : DecidablePred p] (s : Set ι) (t₁ t₂ : ∀ i, Set (α i)) :
(pi s fun i => if p i then t₁ i else t₂ i) =
pi ({ i ∈ s | p i }) t₁ ∩ pi ({ i ∈ s | ¬p i }) t₂ := by
ext f
refine ⟨fun h => ?_, ?_⟩
· constructor <;>
· rintro i ⟨his, hpi⟩
simpa [*] using h i
· rintro ⟨ht₁, ht₂⟩ i his
by_cases p i <;> simp_all
theorem union_pi : (s₁ ∪ s₂).pi t = s₁.pi t ∩ s₂.pi t := by
simp [pi, or_imp, forall_and, setOf_and]
theorem union_pi_inter
(ht₁ : ∀ i ∉ s₁, t₁ i = univ) (ht₂ : ∀ i ∉ s₂, t₂ i = univ) :
(s₁ ∪ s₂).pi (fun i ↦ t₁ i ∩ t₂ i) = s₁.pi t₁ ∩ s₂.pi t₂ := by
ext x
simp only [mem_pi, mem_union, mem_inter_iff]
refine ⟨fun h ↦ ⟨fun i his₁ ↦ (h i (Or.inl his₁)).1, fun i his₂ ↦ (h i (Or.inr his₂)).2⟩,
fun h i hi ↦ ?_⟩
rcases hi with hi | hi
· by_cases hi2 : i ∈ s₂
· exact ⟨h.1 i hi, h.2 i hi2⟩
· refine ⟨h.1 i hi, ?_⟩
rw [ht₂ i hi2]
exact mem_univ _
· by_cases hi1 : i ∈ s₁
· exact ⟨h.1 i hi1, h.2 i hi⟩
· refine ⟨?_, h.2 i hi⟩
rw [ht₁ i hi1]
exact mem_univ _
@[simp]
theorem pi_inter_compl (s : Set ι) : pi s t ∩ pi sᶜ t = pi univ t := by
rw [← union_pi, union_compl_self]
theorem pi_update_of_not_mem [DecidableEq ι] (hi : i ∉ s) (f : ∀ j, α j) (a : α i)
(t : ∀ j, α j → Set (β j)) : (s.pi fun j => t j (update f i a j)) = s.pi fun j => t j (f j) :=
(pi_congr rfl) fun j hj => by
rw [update_of_ne]
exact fun h => hi (h ▸ hj)
theorem pi_update_of_mem [DecidableEq ι] (hi : i ∈ s) (f : ∀ j, α j) (a : α i)
(t : ∀ j, α j → Set (β j)) :
(s.pi fun j => t j (update f i a j)) = { x | x i ∈ t i a } ∩ (s \ {i}).pi fun j => t j (f j) :=
calc
(s.pi fun j => t j (update f i a j)) = ({i} ∪ s \ {i}).pi fun j => t j (update f i a j) := by
rw [union_diff_self, union_eq_self_of_subset_left (singleton_subset_iff.2 hi)]
_ = { x | x i ∈ t i a } ∩ (s \ {i}).pi fun j => t j (f j) := by
rw [union_pi, singleton_pi', update_self, pi_update_of_not_mem]; simp
theorem univ_pi_update [DecidableEq ι] {β : ι → Type*} (i : ι) (f : ∀ j, α j) (a : α i)
(t : ∀ j, α j → Set (β j)) :
(pi univ fun j => t j (update f i a j)) = { x | x i ∈ t i a } ∩ pi {i}ᶜ fun j => t j (f j) := by
rw [compl_eq_univ_diff, ← pi_update_of_mem (mem_univ _)]
theorem univ_pi_update_univ [DecidableEq ι] (i : ι) (s : Set (α i)) :
pi univ (update (fun j : ι => (univ : Set (α j))) i s) = eval i ⁻¹' s := by
rw [univ_pi_update i (fun j => (univ : Set (α j))) s fun j t => t, pi_univ, inter_univ, preimage]
theorem eval_image_pi_subset (hs : i ∈ s) : eval i '' s.pi t ⊆ t i :=
image_subset_iff.2 fun _ hf => hf i hs
theorem eval_image_univ_pi_subset : eval i '' pi univ t ⊆ t i :=
eval_image_pi_subset (mem_univ i)
theorem subset_eval_image_pi (ht : (s.pi t).Nonempty) (i : ι) : t i ⊆ eval i '' s.pi t := by
classical
obtain ⟨f, hf⟩ := ht
refine fun y hy => ⟨update f i y, fun j hj => ?_, update_self ..⟩
obtain rfl | hji := eq_or_ne j i <;> simp [*, hf _ hj]
theorem eval_image_pi (hs : i ∈ s) (ht : (s.pi t).Nonempty) : eval i '' s.pi t = t i :=
(eval_image_pi_subset hs).antisymm (subset_eval_image_pi ht i)
lemma eval_image_pi_of_not_mem [Decidable (s.pi t).Nonempty] (hi : i ∉ s) :
eval i '' s.pi t = if (s.pi t).Nonempty then univ else ∅ := by
classical
ext xᵢ
simp only [eval, mem_image, mem_pi, Set.Nonempty, mem_ite_empty_right, mem_univ, and_true]
constructor
· rintro ⟨x, hx, rfl⟩
exact ⟨x, hx⟩
· rintro ⟨x, hx⟩
refine ⟨Function.update x i xᵢ, ?_⟩
simpa (config := { contextual := true }) [(ne_of_mem_of_not_mem · hi)]
@[simp]
theorem eval_image_univ_pi (ht : (pi univ t).Nonempty) :
(fun f : ∀ i, α i => f i) '' pi univ t = t i :=
eval_image_pi (mem_univ i) ht
theorem piMap_mapsTo_pi {I : Set ι} {f : ∀ i, α i → β i} {s : ∀ i, Set (α i)} {t : ∀ i, Set (β i)}
(h : ∀ i ∈ I, MapsTo (f i) (s i) (t i)) :
MapsTo (Pi.map f) (I.pi s) (I.pi t) :=
fun _x hx i hi => h i hi (hx i hi)
theorem piMap_image_pi_subset {f : ∀ i, α i → β i} (t : ∀ i, Set (α i)) :
Pi.map f '' s.pi t ⊆ s.pi fun i ↦ f i '' t i :=
image_subset_iff.2 <| piMap_mapsTo_pi fun _ _ => mapsTo_image _ _
theorem piMap_image_pi {f : ∀ i, α i → β i} (hf : ∀ i ∉ s, Surjective (f i)) (t : ∀ i, Set (α i)) :
Pi.map f '' s.pi t = s.pi fun i ↦ f i '' t i := by
refine Subset.antisymm (piMap_image_pi_subset _) fun b hb => ?_
have (i : ι) : ∃ a, f i a = b i ∧ (i ∈ s → a ∈ t i) := by
if hi : i ∈ s then
exact (hb i hi).imp fun a ⟨hat, hab⟩ ↦ ⟨hab, fun _ ↦ hat⟩
else
exact (hf i hi (b i)).imp fun a ha ↦ ⟨ha, (absurd · hi)⟩
choose a hab hat using this
exact ⟨a, hat, funext hab⟩
theorem piMap_image_univ_pi (f : ∀ i, α i → β i) (t : ∀ i, Set (α i)) :
Pi.map f '' univ.pi t = univ.pi fun i ↦ f i '' t i :=
piMap_image_pi (by simp) t
@[simp]
theorem range_piMap (f : ∀ i, α i → β i) : range (Pi.map f) = pi univ fun i ↦ range (f i) := by
simp only [← image_univ, ← piMap_image_univ_pi, pi_univ]
theorem pi_subset_pi_iff : pi s t₁ ⊆ pi s t₂ ↔ (∀ i ∈ s, t₁ i ⊆ t₂ i) ∨ pi s t₁ = ∅ := by
refine
⟨fun h => or_iff_not_imp_right.2 ?_, fun h => h.elim pi_mono fun h' => h'.symm ▸ empty_subset _⟩
rw [← Ne, ← nonempty_iff_ne_empty]
intro hne i hi
simpa only [eval_image_pi hi hne, eval_image_pi hi (hne.mono h)] using
image_subset (fun f : ∀ i, α i => f i) h
theorem univ_pi_subset_univ_pi_iff :
pi univ t₁ ⊆ pi univ t₂ ↔ (∀ i, t₁ i ⊆ t₂ i) ∨ ∃ i, t₁ i = ∅ := by simp [pi_subset_pi_iff]
theorem eval_preimage [DecidableEq ι] {s : Set (α i)} :
eval i ⁻¹' s = pi univ (update (fun _ => univ) i s) := by
ext x
simp [@forall_update_iff _ (fun i => Set (α i)) _ _ _ _ fun i' y => x i' ∈ y]
theorem eval_preimage' [DecidableEq ι] {s : Set (α i)} :
eval i ⁻¹' s = pi {i} (update (fun _ => univ) i s) := by
ext
simp
theorem update_preimage_pi [DecidableEq ι] {f : ∀ i, α i} (hi : i ∈ s)
(hf : ∀ j ∈ s, j ≠ i → f j ∈ t j) : update f i ⁻¹' s.pi t = t i := by
ext x
refine ⟨fun h => ?_, fun hx j hj => ?_⟩
· convert h i hi
simp
· obtain rfl | h := eq_or_ne j i
· simpa
· rw [update_of_ne h]
exact hf j hj h
theorem update_image [DecidableEq ι] (x : (i : ι) → β i) (i : ι) (s : Set (β i)) :
update x i '' s = Set.univ.pi (update (fun j ↦ {x j}) i s) := by
ext y
simp only [mem_image, update_eq_iff, ne_eq, and_left_comm (a := _ ∈ s), exists_eq_left, mem_pi,
mem_univ, true_implies]
rw [forall_update_iff (p := fun x s => y x ∈ s)]
simp [eq_comm]
theorem update_preimage_univ_pi [DecidableEq ι] {f : ∀ i, α i} (hf : ∀ j ≠ i, f j ∈ t j) :
update f i ⁻¹' pi univ t = t i :=
update_preimage_pi (mem_univ i) fun j _ => hf j
theorem subset_pi_eval_image (s : Set ι) (u : Set (∀ i, α i)) : u ⊆ pi s fun i => eval i '' u :=
fun f hf _ _ => ⟨f, hf, rfl⟩
theorem univ_pi_ite (s : Set ι) [DecidablePred (· ∈ s)] (t : ∀ i, Set (α i)) :
(pi univ fun i => if i ∈ s then t i else univ) = s.pi t := by
ext
simp_rw [mem_univ_pi]
refine forall_congr' fun i => ?_
split_ifs with h <;> simp [h]
end Pi
end Set
namespace Equiv
open Set
variable {ι ι' : Type*} {α : ι → Type*}
theorem piCongrLeft_symm_preimage_pi (f : ι' ≃ ι) (s : Set ι') (t : ∀ i, Set (α i)) :
(f.piCongrLeft α).symm ⁻¹' s.pi (fun i' => t <| f i') = (f '' s).pi t := by
ext; simp
theorem piCongrLeft_symm_preimage_univ_pi (f : ι' ≃ ι) (t : ∀ i, Set (α i)) :
(f.piCongrLeft α).symm ⁻¹' univ.pi (fun i' => t <| f i') = univ.pi t := by
simpa [f.surjective.range_eq] using piCongrLeft_symm_preimage_pi f univ t
theorem piCongrLeft_preimage_pi (f : ι' ≃ ι) (s : Set ι') (t : ∀ i, Set (α i)) :
f.piCongrLeft α ⁻¹' (f '' s).pi t = s.pi fun i => t (f i) := by
apply Set.ext
rw [← (f.piCongrLeft α).symm.forall_congr_right]
simp
| Mathlib/Data/Set/Prod.lean | 919 | 929 | theorem piCongrLeft_preimage_univ_pi (f : ι' ≃ ι) (t : ∀ i, Set (α i)) :
f.piCongrLeft α ⁻¹' univ.pi t = univ.pi fun i => t (f i) := by | simpa [f.surjective.range_eq] using piCongrLeft_preimage_pi f univ t
theorem sumPiEquivProdPi_symm_preimage_univ_pi (π : ι ⊕ ι' → Type*) (t : ∀ i, Set (π i)) :
(sumPiEquivProdPi π).symm ⁻¹' univ.pi t =
univ.pi (fun i => t (.inl i)) ×ˢ univ.pi fun i => t (.inr i) := by
ext
simp_rw [mem_preimage, mem_prod, mem_univ_pi, sumPiEquivProdPi_symm_apply]
constructor
· intro h; constructor <;> intro i <;> apply h |
/-
Copyright (c) 2021 Bolton Bailey. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bolton Bailey
-/
import Mathlib.Algebra.Ring.Periodic
import Mathlib.Data.Nat.Count
/-!
# Periodic Functions on ℕ
This file identifies a few functions on `ℕ` which are periodic, and also proves a lemma about
periodic predicates which helps determine their cardinality when filtering intervals over them.
-/
assert_not_exists TwoSidedIdeal
namespace Nat
open Function
theorem periodic_gcd (a : ℕ) : Periodic (gcd a) a := by
simp only [forall_const, gcd_add_self_right, eq_self_iff_true, Periodic]
| Mathlib/Data/Nat/Periodic.lean | 25 | 26 | theorem periodic_coprime (a : ℕ) : Periodic (Coprime a) a := by | simp only [coprime_add_self_right, forall_const, eq_iff_iff, Periodic] |
/-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Lu-Ming Zhang
-/
import Mathlib.Combinatorics.SimpleGraph.Basic
import Mathlib.Combinatorics.SimpleGraph.Connectivity.WalkCounting
import Mathlib.LinearAlgebra.Matrix.Trace
import Mathlib.LinearAlgebra.Matrix.Symmetric
/-!
# Adjacency Matrices
This module defines the adjacency matrix of a graph, and provides theorems connecting graph
properties to computational properties of the matrix.
## Main definitions
* `Matrix.IsAdjMatrix`: `A : Matrix V V α` is qualified as an "adjacency matrix" if
(1) every entry of `A` is `0` or `1`,
(2) `A` is symmetric,
(3) every diagonal entry of `A` is `0`.
* `Matrix.IsAdjMatrix.to_graph`: for `A : Matrix V V α` and `h : A.IsAdjMatrix`,
`h.to_graph` is the simple graph induced by `A`.
* `Matrix.compl`: for `A : Matrix V V α`, `A.compl` is supposed to be
the adjacency matrix of the complement graph of the graph induced by `A`.
* `SimpleGraph.adjMatrix`: the adjacency matrix of a `SimpleGraph`.
* `SimpleGraph.adjMatrix_pow_apply_eq_card_walk`: each entry of the `n`th power of
a graph's adjacency matrix counts the number of length-`n` walks between the corresponding
pair of vertices.
-/
open Matrix
open Finset Matrix SimpleGraph
variable {V α : Type*}
namespace Matrix
/-- `A : Matrix V V α` is qualified as an "adjacency matrix" if
(1) every entry of `A` is `0` or `1`,
(2) `A` is symmetric,
(3) every diagonal entry of `A` is `0`. -/
structure IsAdjMatrix [Zero α] [One α] (A : Matrix V V α) : Prop where
zero_or_one : ∀ i j, A i j = 0 ∨ A i j = 1 := by aesop
symm : A.IsSymm := by aesop
apply_diag : ∀ i, A i i = 0 := by aesop
namespace IsAdjMatrix
variable {A : Matrix V V α}
@[simp]
theorem apply_diag_ne [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i : V) :
¬A i i = 1 := by simp [h.apply_diag i]
@[simp]
theorem apply_ne_one_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
¬A i j = 1 ↔ A i j = 0 := by obtain h | h := h.zero_or_one i j <;> simp [h]
@[simp]
theorem apply_ne_zero_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
¬A i j = 0 ↔ A i j = 1 := by rw [← apply_ne_one_iff h, Classical.not_not]
/-- For `A : Matrix V V α` and `h : IsAdjMatrix A`,
`h.toGraph` is the simple graph whose adjacency matrix is `A`. -/
@[simps]
def toGraph [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) : SimpleGraph V where
Adj i j := A i j = 1
symm i j hij := by simp only; rwa [h.symm.apply i j]
loopless i := by simp [h]
instance [MulZeroOneClass α] [Nontrivial α] [DecidableEq α] (h : IsAdjMatrix A) :
DecidableRel h.toGraph.Adj := by
simp only [toGraph]
infer_instance
end IsAdjMatrix
/-- For `A : Matrix V V α`, `A.compl` is supposed to be the adjacency matrix of
the complement graph of the graph induced by `A.adjMatrix`. -/
def compl [Zero α] [One α] [DecidableEq α] [DecidableEq V] (A : Matrix V V α) : Matrix V V α :=
fun i j => ite (i = j) 0 (ite (A i j = 0) 1 0)
section Compl
variable [DecidableEq α] [DecidableEq V] (A : Matrix V V α)
@[simp]
theorem compl_apply_diag [Zero α] [One α] (i : V) : A.compl i i = 0 := by simp [compl]
@[simp]
theorem compl_apply [Zero α] [One α] (i j : V) : A.compl i j = 0 ∨ A.compl i j = 1 := by
unfold compl
split_ifs <;> simp
@[simp]
theorem isSymm_compl [Zero α] [One α] (h : A.IsSymm) : A.compl.IsSymm := by
ext
simp [compl, h.apply, eq_comm]
@[simp]
theorem isAdjMatrix_compl [Zero α] [One α] (h : A.IsSymm) : IsAdjMatrix A.compl :=
{ symm := by simp [h] }
namespace IsAdjMatrix
variable {A}
@[simp]
theorem compl [Zero α] [One α] (h : IsAdjMatrix A) : IsAdjMatrix A.compl :=
isAdjMatrix_compl A h.symm
| Mathlib/Combinatorics/SimpleGraph/AdjMatrix.lean | 121 | 122 | theorem toGraph_compl_eq [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) :
h.compl.toGraph = h.toGraphᶜ := by | |
/-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.CategoryTheory.Comma.Over.Pullback
import Mathlib.CategoryTheory.Limits.Shapes.KernelPair
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Assoc
/-!
# The diagonal object of a morphism.
We provide various API and isomorphisms considering the diagonal object `Δ_{Y/X} := pullback f f`
of a morphism `f : X ⟶ Y`.
-/
open CategoryTheory
noncomputable section
namespace CategoryTheory.Limits
variable {C : Type*} [Category C] {X Y Z : C}
namespace pullback
section Diagonal
variable (f : X ⟶ Y) [HasPullback f f]
/-- The diagonal object of a morphism `f : X ⟶ Y` is `Δ_{X/Y} := pullback f f`. -/
abbrev diagonalObj : C :=
pullback f f
/-- The diagonal morphism `X ⟶ Δ_{X/Y}` for a morphism `f : X ⟶ Y`. -/
def diagonal : X ⟶ diagonalObj f :=
pullback.lift (𝟙 _) (𝟙 _) rfl
@[reassoc (attr := simp)]
theorem diagonal_fst : diagonal f ≫ pullback.fst _ _ = 𝟙 _ :=
pullback.lift_fst _ _ _
@[reassoc (attr := simp)]
theorem diagonal_snd : diagonal f ≫ pullback.snd _ _ = 𝟙 _ :=
pullback.lift_snd _ _ _
instance : IsSplitMono (diagonal f) :=
⟨⟨⟨pullback.fst _ _, diagonal_fst f⟩⟩⟩
instance : IsSplitEpi (pullback.fst f f) :=
⟨⟨⟨diagonal f, diagonal_fst f⟩⟩⟩
instance : IsSplitEpi (pullback.snd f f) :=
⟨⟨⟨diagonal f, diagonal_snd f⟩⟩⟩
instance [Mono f] : IsIso (diagonal f) := by
rw [(IsIso.inv_eq_of_inv_hom_id (diagonal_fst f)).symm]
infer_instance
lemma isIso_diagonal_iff : IsIso (diagonal f) ↔ Mono f :=
⟨fun H ↦ ⟨fun _ _ e ↦ by rw [← lift_fst _ _ e, (cancel_epi (g := fst f f) (h := snd f f)
(diagonal f)).mp (by simp), lift_snd]⟩, fun _ ↦ inferInstance⟩
/-- The two projections `Δ_{X/Y} ⟶ X` form a kernel pair for `f : X ⟶ Y`. -/
theorem diagonal_isKernelPair : IsKernelPair f (pullback.fst f f) (pullback.snd f f) :=
IsPullback.of_hasPullback f f
end Diagonal
end pullback
variable [HasPullbacks C]
open pullback
section
variable {U V₁ V₂ : C} (f : X ⟶ Y) (i : U ⟶ Y)
variable (i₁ : V₁ ⟶ pullback f i) (i₂ : V₂ ⟶ pullback f i)
@[reassoc (attr := simp)]
theorem pullback_diagonal_map_snd_fst_fst :
(pullback.snd (diagonal f)
(map (i₁ ≫ snd f i) (i₂ ≫ snd f i) f f (i₁ ≫ fst f i) (i₂ ≫ fst f i) i
(by simp [condition]) (by simp [condition]))) ≫
fst _ _ ≫ i₁ ≫ fst _ _ =
pullback.fst _ _ := by
conv_rhs => rw [← Category.comp_id (pullback.fst _ _)]
rw [← diagonal_fst f, pullback.condition_assoc, pullback.lift_fst]
@[reassoc (attr := simp)]
theorem pullback_diagonal_map_snd_snd_fst :
(pullback.snd (diagonal f)
(map (i₁ ≫ snd f i) (i₂ ≫ snd f i) f f (i₁ ≫ fst f i) (i₂ ≫ fst f i) i
(by simp [condition]) (by simp [condition]))) ≫
snd _ _ ≫ i₂ ≫ fst _ _ =
pullback.fst _ _ := by
conv_rhs => rw [← Category.comp_id (pullback.fst _ _)]
rw [← diagonal_snd f, pullback.condition_assoc, pullback.lift_snd]
variable [HasPullback i₁ i₂]
/-- The underlying map of `pullbackDiagonalIso` -/
abbrev pullbackDiagonalMapIso.hom :
pullback (diagonal f)
(map (i₁ ≫ snd _ _) (i₂ ≫ snd _ _) f f (i₁ ≫ fst _ _) (i₂ ≫ fst _ _) i
(by simp only [Category.assoc, condition])
(by simp only [Category.assoc, condition])) ⟶
pullback i₁ i₂ :=
pullback.lift (pullback.snd _ _ ≫ pullback.fst _ _) (pullback.snd _ _ ≫ pullback.snd _ _) (by
ext
· simp only [Category.assoc, pullback_diagonal_map_snd_fst_fst,
pullback_diagonal_map_snd_snd_fst]
· simp only [Category.assoc, condition])
/-- The underlying inverse of `pullbackDiagonalIso` -/
abbrev pullbackDiagonalMapIso.inv : pullback i₁ i₂ ⟶
pullback (diagonal f)
(map (i₁ ≫ snd _ _) (i₂ ≫ snd _ _) f f (i₁ ≫ fst _ _) (i₂ ≫ fst _ _) i
(by simp only [Category.assoc, condition])
(by simp only [Category.assoc, condition])) :=
pullback.lift (pullback.fst _ _ ≫ i₁ ≫ pullback.fst _ _)
(pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (pullback.snd _ _) (Category.id_comp _).symm
(Category.id_comp _).symm) (by
ext
· simp only [Category.assoc, diagonal_fst, Category.comp_id, limit.lift_π,
PullbackCone.mk_pt, PullbackCone.mk_π_app, limit.lift_π_assoc, cospan_left]
· simp only [condition_assoc, Category.assoc, diagonal_snd, Category.comp_id, limit.lift_π,
PullbackCone.mk_pt, PullbackCone.mk_π_app, limit.lift_π_assoc, cospan_right])
/-- This iso witnesses the fact that
given `f : X ⟶ Y`, `i : U ⟶ Y`, and `i₁ : V₁ ⟶ X ×[Y] U`, `i₂ : V₂ ⟶ X ×[Y] U`, the diagram
```
V₁ ×[X ×[Y] U] V₂ ⟶ V₁ ×[U] V₂
| |
| |
↓ ↓
X ⟶ X ×[Y] X
```
is a pullback square.
Also see `pullback_fst_map_snd_isPullback`.
-/
def pullbackDiagonalMapIso :
pullback (diagonal f)
(map (i₁ ≫ snd _ _) (i₂ ≫ snd _ _) f f (i₁ ≫ fst _ _) (i₂ ≫ fst _ _) i
(by simp only [Category.assoc, condition])
(by simp only [Category.assoc, condition])) ≅
pullback i₁ i₂ where
hom := pullbackDiagonalMapIso.hom f i i₁ i₂
inv := pullbackDiagonalMapIso.inv f i i₁ i₂
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso.hom_fst :
(pullbackDiagonalMapIso f i i₁ i₂).hom ≫ pullback.fst _ _ =
pullback.snd _ _ ≫ pullback.fst _ _ := by
delta pullbackDiagonalMapIso
simp only [limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app]
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso.hom_snd :
(pullbackDiagonalMapIso f i i₁ i₂).hom ≫ pullback.snd _ _ =
pullback.snd _ _ ≫ pullback.snd _ _ := by
delta pullbackDiagonalMapIso
simp only [limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app]
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso.inv_fst :
(pullbackDiagonalMapIso f i i₁ i₂).inv ≫ pullback.fst _ _ =
pullback.fst _ _ ≫ i₁ ≫ pullback.fst _ _ := by
delta pullbackDiagonalMapIso
simp only [limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app]
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso.inv_snd_fst :
(pullbackDiagonalMapIso f i i₁ i₂).inv ≫ pullback.snd _ _ ≫ pullback.fst _ _ =
pullback.fst _ _ := by
delta pullbackDiagonalMapIso
simp
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso.inv_snd_snd :
(pullbackDiagonalMapIso f i i₁ i₂).inv ≫ pullback.snd _ _ ≫ pullback.snd _ _ =
pullback.snd _ _ := by
delta pullbackDiagonalMapIso
simp
theorem pullback_fst_map_snd_isPullback :
IsPullback (fst _ _ ≫ i₁ ≫ fst _ _)
(map i₁ i₂ (i₁ ≫ snd _ _) (i₂ ≫ snd _ _) _ _ _
(Category.id_comp _).symm (Category.id_comp _).symm)
(diagonal f)
(map (i₁ ≫ snd _ _) (i₂ ≫ snd _ _) f f (i₁ ≫ fst _ _) (i₂ ≫ fst _ _) i (by simp [condition])
(by simp [condition])) :=
IsPullback.of_iso_pullback ⟨by ext <;> simp [condition_assoc]⟩
(pullbackDiagonalMapIso f i i₁ i₂).symm (pullbackDiagonalMapIso.inv_fst f i i₁ i₂)
(by aesop_cat)
end
section
variable {S T : C} (f : X ⟶ T) (g : Y ⟶ T) (i : T ⟶ S)
variable [HasPullback i i] [HasPullback f g] [HasPullback (f ≫ i) (g ≫ i)]
variable
[HasPullback (diagonal i)
(pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _) (Category.comp_id _) (Category.comp_id _))]
/-- This iso witnesses the fact that
given `f : X ⟶ T`, `g : Y ⟶ T`, and `i : T ⟶ S`, the diagram
```
X ×ₜ Y ⟶ X ×ₛ Y
| |
| |
↓ ↓
T ⟶ T ×ₛ T
```
is a pullback square.
Also see `pullback_map_diagonal_isPullback`.
-/
def pullbackDiagonalMapIdIso :
pullback (diagonal i)
(pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _) (Category.comp_id _) (Category.comp_id _)) ≅
pullback f g := by
refine ?_ ≪≫
pullbackDiagonalMapIso i (𝟙 _) (f ≫ inv (pullback.fst _ _)) (g ≫ inv (pullback.fst _ _)) ≪≫ ?_
· refine @asIso _ _ _ _ (pullback.map _ _ _ _ (𝟙 T) ((pullback.congrHom ?_ ?_).hom) (𝟙 _) ?_ ?_)
?_
· rw [← Category.comp_id (pullback.snd ..), ← condition, Category.assoc, IsIso.inv_hom_id_assoc]
· rw [← Category.comp_id (pullback.snd ..), ← condition, Category.assoc, IsIso.inv_hom_id_assoc]
· rw [Category.comp_id, Category.id_comp]
· ext <;> simp
· infer_instance
· refine @asIso _ _ _ _ (pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (pullback.fst _ _) ?_ ?_) ?_
· rw [Category.assoc, IsIso.inv_hom_id, Category.comp_id, Category.id_comp]
· rw [Category.assoc, IsIso.inv_hom_id, Category.comp_id, Category.id_comp]
· infer_instance
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIdIso_hom_fst :
(pullbackDiagonalMapIdIso f g i).hom ≫ pullback.fst _ _ =
pullback.snd _ _ ≫ pullback.fst _ _ := by
delta pullbackDiagonalMapIdIso
simp
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIdIso_hom_snd :
(pullbackDiagonalMapIdIso f g i).hom ≫ pullback.snd _ _ =
pullback.snd _ _ ≫ pullback.snd _ _ := by
delta pullbackDiagonalMapIdIso
simp
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIdIso_inv_fst :
(pullbackDiagonalMapIdIso f g i).inv ≫ pullback.fst _ _ = pullback.fst _ _ ≫ f := by
rw [Iso.inv_comp_eq, ← Category.comp_id (pullback.fst _ _), ← diagonal_fst i,
pullback.condition_assoc]
simp
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIdIso_inv_snd_fst :
(pullbackDiagonalMapIdIso f g i).inv ≫ pullback.snd _ _ ≫ pullback.fst _ _ =
pullback.fst _ _ := by
rw [Iso.inv_comp_eq]
simp
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIdIso_inv_snd_snd :
(pullbackDiagonalMapIdIso f g i).inv ≫ pullback.snd _ _ ≫ pullback.snd _ _ =
pullback.snd _ _ := by
rw [Iso.inv_comp_eq]
simp
theorem pullback.diagonal_comp (f : X ⟶ Y) (g : Y ⟶ Z) :
diagonal (f ≫ g) = diagonal f ≫ (pullbackDiagonalMapIdIso f f g).inv ≫ pullback.snd _ _ := by
ext <;> simp
@[reassoc]
lemma pullback.comp_diagonal (f : X ⟶ Y) (g : Y ⟶ Z) :
f ≫ pullback.diagonal g = pullback.diagonal (f ≫ g) ≫
pullback.map (f ≫ g) (f ≫ g) g g f f (𝟙 Z) (by simp) (by simp) := by
ext <;> simp
theorem pullback_map_diagonal_isPullback :
IsPullback (pullback.fst _ _ ≫ f)
(pullback.map f g (f ≫ i) (g ≫ i) _ _ i (Category.id_comp _).symm (Category.id_comp _).symm)
(diagonal i)
(pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _) (Category.comp_id _) (Category.comp_id _)) := by
apply IsPullback.of_iso_pullback _ (pullbackDiagonalMapIdIso f g i).symm
· simp
· ext <;> simp
· constructor
ext <;> simp [condition]
/-- The diagonal object of `X ×[Z] Y ⟶ X` is isomorphic to `Δ_{Y/Z} ×[Z] X`. -/
def diagonalObjPullbackFstIso {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
diagonalObj (pullback.fst f g) ≅
pullback (pullback.snd _ _ ≫ g : diagonalObj g ⟶ Z) f :=
pullbackRightPullbackFstIso _ _ _ ≪≫
pullback.congrHom pullback.condition rfl ≪≫
pullbackAssoc _ _ _ _ ≪≫ pullbackSymmetry _ _ ≪≫ pullback.congrHom pullback.condition rfl
@[reassoc (attr := simp)]
theorem diagonalObjPullbackFstIso_hom_fst_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(diagonalObjPullbackFstIso f g).hom ≫ pullback.fst _ _ ≫ pullback.fst _ _ =
pullback.fst _ _ ≫ pullback.snd _ _ := by
delta diagonalObjPullbackFstIso
simp
@[reassoc (attr := simp)]
theorem diagonalObjPullbackFstIso_hom_fst_snd {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(diagonalObjPullbackFstIso f g).hom ≫ pullback.fst _ _ ≫ pullback.snd _ _ =
pullback.snd _ _ ≫ pullback.snd _ _ := by
delta diagonalObjPullbackFstIso
simp
@[reassoc (attr := simp)]
theorem diagonalObjPullbackFstIso_hom_snd {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(diagonalObjPullbackFstIso f g).hom ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.fst _ _ := by
delta diagonalObjPullbackFstIso
simp
@[reassoc (attr := simp)]
theorem diagonalObjPullbackFstIso_inv_fst_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(diagonalObjPullbackFstIso f g).inv ≫ pullback.fst _ _ ≫ pullback.fst _ _ =
pullback.snd _ _ := by
delta diagonalObjPullbackFstIso
simp
@[reassoc (attr := simp)]
theorem diagonalObjPullbackFstIso_inv_fst_snd {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(diagonalObjPullbackFstIso f g).inv ≫ pullback.fst _ _ ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.fst _ _ := by
delta diagonalObjPullbackFstIso
simp
@[reassoc (attr := simp)]
theorem diagonalObjPullbackFstIso_inv_snd_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(diagonalObjPullbackFstIso f g).inv ≫ pullback.snd _ _ ≫ pullback.fst _ _ =
pullback.snd _ _ := by
delta diagonalObjPullbackFstIso
simp
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Limits/Shapes/Diagonal.lean | 352 | 358 | theorem diagonalObjPullbackFstIso_inv_snd_snd {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(diagonalObjPullbackFstIso f g).inv ≫ pullback.snd _ _ ≫ pullback.snd _ _ =
pullback.fst _ _ ≫ pullback.snd _ _ := by | delta diagonalObjPullbackFstIso
simp
theorem diagonal_pullback_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : |
/-
Copyright (c) 2022 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis
-/
import Mathlib.Topology.Algebra.Module.WeakDual
import Mathlib.Algebra.Algebra.Spectrum.Basic
import Mathlib.Topology.ContinuousMap.Algebra
import Mathlib.Data.Set.Lattice
/-!
# Character space of a topological algebra
The character space of a topological algebra is the subset of elements of the weak dual that
are also algebra homomorphisms. This space is used in the Gelfand transform, which gives an
isomorphism between a commutative C⋆-algebra and continuous functions on the character space
of the algebra. This, in turn, is used to construct the continuous functional calculus on
C⋆-algebras.
## Implementation notes
We define `WeakDual.characterSpace 𝕜 A` as a subset of the weak dual, which automatically puts the
correct topology on the space. We then define `WeakDual.CharacterSpace.toAlgHom` which provides the
algebra homomorphism corresponding to any element. We also provide `WeakDual.CharacterSpace.toCLM`
which provides the element as a continuous linear map. (Even though `WeakDual 𝕜 A` is a type copy of
`A →L[𝕜] 𝕜`, this is often more convenient.)
## Tags
character space, Gelfand transform, functional calculus
-/
namespace WeakDual
/-- The character space of a topological algebra is the subset of elements of the weak dual that
are also algebra homomorphisms. -/
def characterSpace (𝕜 : Type*) (A : Type*) [CommSemiring 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜]
[ContinuousConstSMul 𝕜 𝕜] [NonUnitalNonAssocSemiring A] [TopologicalSpace A] [Module 𝕜 A] :=
{φ : WeakDual 𝕜 A | φ ≠ 0 ∧ ∀ x y : A, φ (x * y) = φ x * φ y}
variable {𝕜 : Type*} {A : Type*}
-- Even though the capitalization of the namespace differs, it doesn't matter
-- because there is no dot notation since `characterSpace` is only a type via `CoeSort`.
namespace CharacterSpace
section NonUnitalNonAssocSemiring
variable [CommSemiring 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜] [ContinuousConstSMul 𝕜 𝕜]
[NonUnitalNonAssocSemiring A] [TopologicalSpace A] [Module 𝕜 A]
instance instFunLike : FunLike (characterSpace 𝕜 A) A 𝕜 where
coe φ := ((φ : WeakDual 𝕜 A) : A → 𝕜)
coe_injective' φ ψ h := by ext1; apply DFunLike.ext; exact congr_fun h
/-- Elements of the character space are continuous linear maps. -/
instance instContinuousLinearMapClass : ContinuousLinearMapClass (characterSpace 𝕜 A) 𝕜 A 𝕜 where
map_smulₛₗ φ := (φ : WeakDual 𝕜 A).map_smul
map_add φ := (φ : WeakDual 𝕜 A).map_add
map_continuous φ := (φ : WeakDual 𝕜 A).cont
-- Porting note: moved because Lean 4 doesn't see the `DFunLike` instance on `characterSpace 𝕜 A`
-- until the `ContinuousLinearMapClass` instance is declared
@[simp, norm_cast]
protected theorem coe_coe (φ : characterSpace 𝕜 A) : ⇑(φ : WeakDual 𝕜 A) = (φ : A → 𝕜) :=
rfl
@[ext]
theorem ext {φ ψ : characterSpace 𝕜 A} (h : ∀ x, φ x = ψ x) : φ = ψ :=
DFunLike.ext _ _ h
/-- An element of the character space, as a continuous linear map. -/
def toCLM (φ : characterSpace 𝕜 A) : A →L[𝕜] 𝕜 :=
(φ : WeakDual 𝕜 A)
@[simp]
theorem coe_toCLM (φ : characterSpace 𝕜 A) : ⇑(toCLM φ) = φ :=
rfl
/-- Elements of the character space are non-unital algebra homomorphisms. -/
instance instNonUnitalAlgHomClass : NonUnitalAlgHomClass (characterSpace 𝕜 A) 𝕜 A 𝕜 :=
{ CharacterSpace.instContinuousLinearMapClass with
map_smulₛₗ := fun φ => map_smul φ
map_zero := fun φ => map_zero φ
map_mul := fun φ => φ.prop.2 }
/-- An element of the character space, as a non-unital algebra homomorphism. -/
def toNonUnitalAlgHom (φ : characterSpace 𝕜 A) : A →ₙₐ[𝕜] 𝕜 where
toFun := (φ : A → 𝕜)
map_mul' := map_mul φ
map_smul' := map_smul φ
map_zero' := map_zero φ
map_add' := map_add φ
@[simp]
theorem coe_toNonUnitalAlgHom (φ : characterSpace 𝕜 A) : ⇑(toNonUnitalAlgHom φ) = φ :=
rfl
instance instIsEmpty [Subsingleton A] : IsEmpty (characterSpace 𝕜 A) :=
⟨fun φ => φ.prop.1 <|
ContinuousLinearMap.ext fun x => by
rw [show x = 0 from Subsingleton.elim x 0, map_zero, map_zero] ⟩
variable (𝕜 A)
theorem union_zero :
characterSpace 𝕜 A ∪ {0} = {φ : WeakDual 𝕜 A | ∀ x y : A, φ (x * y) = φ x * φ y} :=
le_antisymm (by
rintro φ (hφ | rfl)
· exact hφ.2
· exact fun _ _ => by exact (zero_mul (0 : 𝕜)).symm)
fun φ hφ => Or.elim (em <| φ = 0) Or.inr fun h₀ => Or.inl ⟨h₀, hφ⟩
/-- The `characterSpace 𝕜 A` along with `0` is always a closed set in `WeakDual 𝕜 A`. -/
theorem union_zero_isClosed [T2Space 𝕜] [ContinuousMul 𝕜] :
IsClosed (characterSpace 𝕜 A ∪ {0}) := by
simp only [union_zero, Set.setOf_forall]
exact
isClosed_iInter fun x =>
isClosed_iInter fun y =>
isClosed_eq (eval_continuous _) <| (eval_continuous _).mul (eval_continuous _)
end NonUnitalNonAssocSemiring
section Unital
variable [CommRing 𝕜] [NoZeroDivisors 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜]
[ContinuousConstSMul 𝕜 𝕜] [TopologicalSpace A] [Semiring A] [Algebra 𝕜 A]
/-- In a unital algebra, elements of the character space are algebra homomorphisms. -/
instance instAlgHomClass : AlgHomClass (characterSpace 𝕜 A) 𝕜 A 𝕜 :=
haveI map_one' : ∀ φ : characterSpace 𝕜 A, φ 1 = 1 := fun φ => by
have h₁ : φ 1 * (1 - φ 1) = 0 := by rw [mul_sub, sub_eq_zero, mul_one, ← map_mul φ, one_mul]
rcases mul_eq_zero.mp h₁ with (h₂ | h₂)
· have : ∀ a, φ (a * 1) = 0 := fun a => by simp only [map_mul φ, h₂, mul_zero]
exact False.elim (φ.prop.1 <| ContinuousLinearMap.ext <| by simpa only [mul_one] using this)
· exact (sub_eq_zero.mp h₂).symm
{ CharacterSpace.instNonUnitalAlgHomClass with
map_one := map_one'
commutes := fun φ r => by
rw [Algebra.algebraMap_eq_smul_one, Algebra.id.map_eq_id, RingHom.id_apply]
rw [map_smul, Algebra.id.smul_eq_mul, map_one' φ, mul_one] }
/-- An element of the character space of a unital algebra, as an algebra homomorphism. -/
@[simps]
def toAlgHom (φ : characterSpace 𝕜 A) : A →ₐ[𝕜] 𝕜 :=
{ toNonUnitalAlgHom φ with
map_one' := map_one φ
commutes' := AlgHomClass.commutes φ }
theorem eq_set_map_one_map_mul [Nontrivial 𝕜] :
characterSpace 𝕜 A = {φ : WeakDual 𝕜 A | φ 1 = 1 ∧ ∀ x y : A, φ (x * y) = φ x * φ y} := by
ext φ
refine ⟨?_, ?_⟩
· rintro hφ
lift φ to characterSpace 𝕜 A using hφ
exact ⟨map_one φ, map_mul φ⟩
· rintro ⟨hφ₁, hφ₂⟩
refine ⟨?_, hφ₂⟩
rintro rfl
exact zero_ne_one hφ₁
/-- under suitable mild assumptions on `𝕜`, the character space is a closed set in
`WeakDual 𝕜 A`. -/
protected theorem isClosed [Nontrivial 𝕜] [T2Space 𝕜] [ContinuousMul 𝕜] :
IsClosed (characterSpace 𝕜 A) := by
rw [eq_set_map_one_map_mul, Set.setOf_and]
refine IsClosed.inter (isClosed_eq (eval_continuous _) continuous_const) ?_
simpa only [(union_zero 𝕜 A).symm] using union_zero_isClosed _ _
end Unital
section Ring
variable [CommRing 𝕜] [NoZeroDivisors 𝕜] [TopologicalSpace 𝕜] [ContinuousAdd 𝕜]
[ContinuousConstSMul 𝕜 𝕜] [TopologicalSpace A] [Ring A] [Algebra 𝕜 A]
| Mathlib/Topology/Algebra/Module/CharacterSpace.lean | 181 | 185 | theorem apply_mem_spectrum [Nontrivial 𝕜] (φ : characterSpace 𝕜 A) (a : A) : φ a ∈ spectrum 𝕜 a :=
AlgHom.apply_mem_spectrum φ a
theorem ext_ker {φ ψ : characterSpace 𝕜 A} (h : RingHom.ker φ = RingHom.ker ψ) : φ = ψ := by | ext x |
/-
Copyright (c) 2024 Ira Fesefeldt. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ira Fesefeldt
-/
import Mathlib.SetTheory.Ordinal.Arithmetic
/-!
# Ordinal Approximants for the Fixed points on complete lattices
This file sets up the ordinal-indexed approximation theory of fixed points
of a monotone function in a complete lattice [Cousot1979].
The proof follows loosely the one from [Echenique2005].
However, the proof given here is not constructive as we use the non-constructive axiomatization of
ordinals from mathlib. It still allows an approximation scheme indexed over the ordinals.
## Main definitions
* `OrdinalApprox.lfpApprox`: The ordinal-indexed approximation of the least fixed point
greater or equal than an initial value of a bundled monotone function.
* `OrdinalApprox.gfpApprox`: The ordinal-indexed approximation of the greatest fixed point
less or equal than an initial value of a bundled monotone function.
## Main theorems
* `OrdinalApprox.lfp_mem_range_lfpApprox`: The ordinal-indexed approximation of
the least fixed point eventually reaches the least fixed point
* `OrdinalApprox.gfp_mem_range_gfpApprox`: The ordinal-indexed approximation of
the greatest fixed point eventually reaches the greatest fixed point
## References
* [F. Echenique, *A short and constructive proof of Tarski’s fixed-point theorem*][Echenique2005]
* [P. Cousot & R. Cousot, *Constructive Versions of Tarski's Fixed Point Theorems*][Cousot1979]
## Tags
fixed point, complete lattice, monotone function, ordinals, approximation
-/
namespace Cardinal
universe u
variable {α : Type u}
variable (g : Ordinal → α)
open Cardinal Ordinal SuccOrder Function Set
theorem not_injective_limitation_set : ¬ InjOn g (Iio (ord <| succ #α)) := by
intro h_inj
have h := lift_mk_le_lift_mk_of_injective <| injOn_iff_injective.1 h_inj
have mk_initialSeg_subtype :
#(Iio (ord <| succ #α)) = lift.{u + 1} (succ #α) := by
simpa only [coe_setOf, card_typein, card_ord] using mk_Iio_ordinal (ord <| succ #α)
rw [mk_initialSeg_subtype, lift_lift, lift_le] at h
exact not_le_of_lt (Order.lt_succ #α) h
end Cardinal
namespace OrdinalApprox
universe u
variable {α : Type u}
variable [CompleteLattice α] (f : α →o α) (x : α)
open Function fixedPoints Cardinal Order OrderHom
set_option linter.unusedVariables false in
/-- The ordinal-indexed sequence approximating the least fixed point greater than
an initial value `x`. It is defined in such a way that we have `lfpApprox 0 x = x` and
`lfpApprox a x = ⨆ b < a, f (lfpApprox b x)`. -/
def lfpApprox (a : Ordinal.{u}) : α :=
sSup ({ f (lfpApprox b) | (b : Ordinal) (h : b < a) } ∪ {x})
termination_by a
decreasing_by exact h
theorem lfpApprox_monotone : Monotone (lfpApprox f x) := by
intros a b h
rw [lfpApprox, lfpApprox]
refine sSup_le_sSup ?h
apply sup_le_sup_right
simp only [exists_prop, Set.le_eq_subset, Set.setOf_subset_setOf, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intros a' h'
use a'
exact ⟨lt_of_lt_of_le h' h, rfl⟩
| Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean | 87 | 90 | theorem le_lfpApprox {a : Ordinal} : x ≤ lfpApprox f x a := by | rw [lfpApprox]
apply le_sSup
simp only [exists_prop, Set.union_singleton, Set.mem_insert_iff, Set.mem_setOf_eq, true_or] |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Johannes Hölzl, Yury Kudryashov, Patrick Massot
-/
import Mathlib.Algebra.GeomSum
import Mathlib.Order.Filter.AtTopBot.Archimedean
import Mathlib.Order.Iterate
import Mathlib.Topology.Algebra.Algebra
import Mathlib.Topology.Algebra.InfiniteSum.Real
import Mathlib.Topology.Instances.EReal.Lemmas
/-!
# A collection of specific limit computations
This file, by design, is independent of `NormedSpace` in the import hierarchy. It contains
important specific limit computations in metric spaces, in ordered rings/fields, and in specific
instances of these such as `ℝ`, `ℝ≥0` and `ℝ≥0∞`.
-/
assert_not_exists Basis NormedSpace
noncomputable section
open Set Function Filter Finset Metric Topology Nat uniformity NNReal ENNReal
variable {α : Type*} {β : Type*} {ι : Type*}
theorem tendsto_inverse_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ (n : ℝ)⁻¹) atTop (𝓝 0) :=
tendsto_inv_atTop_zero.comp tendsto_natCast_atTop_atTop
theorem tendsto_const_div_atTop_nhds_zero_nat (C : ℝ) :
Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by
simpa only [mul_zero] using tendsto_const_nhds.mul tendsto_inverse_atTop_nhds_zero_nat
theorem tendsto_one_div_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ 1/(n : ℝ)) atTop (𝓝 0) :=
tendsto_const_div_atTop_nhds_zero_nat 1
theorem NNReal.tendsto_inverse_atTop_nhds_zero_nat :
Tendsto (fun n : ℕ ↦ (n : ℝ≥0)⁻¹) atTop (𝓝 0) := by
rw [← NNReal.tendsto_coe]
exact _root_.tendsto_inverse_atTop_nhds_zero_nat
theorem NNReal.tendsto_const_div_atTop_nhds_zero_nat (C : ℝ≥0) :
Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by
simpa using tendsto_const_nhds.mul NNReal.tendsto_inverse_atTop_nhds_zero_nat
theorem EReal.tendsto_const_div_atTop_nhds_zero_nat {C : EReal} (h : C ≠ ⊥) (h' : C ≠ ⊤) :
Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by
have : (fun n : ℕ ↦ C / n) = fun n : ℕ ↦ ((C.toReal / n : ℝ) : EReal) := by
ext n
nth_rw 1 [← coe_toReal h' h, ← coe_coe_eq_natCast n, ← coe_div C.toReal n]
rw [this, ← coe_zero, tendsto_coe]
exact _root_.tendsto_const_div_atTop_nhds_zero_nat C.toReal
theorem tendsto_one_div_add_atTop_nhds_zero_nat :
Tendsto (fun n : ℕ ↦ 1 / ((n : ℝ) + 1)) atTop (𝓝 0) :=
suffices Tendsto (fun n : ℕ ↦ 1 / (↑(n + 1) : ℝ)) atTop (𝓝 0) by simpa
(tendsto_add_atTop_iff_nat 1).2 (_root_.tendsto_const_div_atTop_nhds_zero_nat 1)
theorem NNReal.tendsto_algebraMap_inverse_atTop_nhds_zero_nat (𝕜 : Type*) [Semiring 𝕜]
[Algebra ℝ≥0 𝕜] [TopologicalSpace 𝕜] [ContinuousSMul ℝ≥0 𝕜] :
Tendsto (algebraMap ℝ≥0 𝕜 ∘ fun n : ℕ ↦ (n : ℝ≥0)⁻¹) atTop (𝓝 0) := by
convert (continuous_algebraMap ℝ≥0 𝕜).continuousAt.tendsto.comp
tendsto_inverse_atTop_nhds_zero_nat
rw [map_zero]
theorem tendsto_algebraMap_inverse_atTop_nhds_zero_nat (𝕜 : Type*) [Semiring 𝕜] [Algebra ℝ 𝕜]
[TopologicalSpace 𝕜] [ContinuousSMul ℝ 𝕜] :
Tendsto (algebraMap ℝ 𝕜 ∘ fun n : ℕ ↦ (n : ℝ)⁻¹) atTop (𝓝 0) :=
NNReal.tendsto_algebraMap_inverse_atTop_nhds_zero_nat 𝕜
/-- The limit of `n / (n + x)` is 1, for any constant `x` (valid in `ℝ` or any topological division
algebra over `ℝ`, e.g., `ℂ`).
TODO: introduce a typeclass saying that `1 / n` tends to 0 at top, making it possible to get this
statement simultaneously on `ℚ`, `ℝ` and `ℂ`. -/
theorem tendsto_natCast_div_add_atTop {𝕜 : Type*} [DivisionRing 𝕜] [TopologicalSpace 𝕜]
[CharZero 𝕜] [Algebra ℝ 𝕜] [ContinuousSMul ℝ 𝕜] [IsTopologicalDivisionRing 𝕜] (x : 𝕜) :
Tendsto (fun n : ℕ ↦ (n : 𝕜) / (n + x)) atTop (𝓝 1) := by
convert Tendsto.congr' ((eventually_ne_atTop 0).mp (Eventually.of_forall fun n hn ↦ _)) _
· exact fun n : ℕ ↦ 1 / (1 + x / n)
· field_simp [Nat.cast_ne_zero.mpr hn]
· have : 𝓝 (1 : 𝕜) = 𝓝 (1 / (1 + x * (0 : 𝕜))) := by
rw [mul_zero, add_zero, div_one]
rw [this]
refine tendsto_const_nhds.div (tendsto_const_nhds.add ?_) (by simp)
simp_rw [div_eq_mul_inv]
refine tendsto_const_nhds.mul ?_
have := ((continuous_algebraMap ℝ 𝕜).tendsto _).comp tendsto_inverse_atTop_nhds_zero_nat
rw [map_zero, Filter.tendsto_atTop'] at this
refine Iff.mpr tendsto_atTop' ?_
intros
simp_all only [comp_apply, map_inv₀, map_natCast]
/-- For any positive `m : ℕ`, `((n % m : ℕ) : ℝ) / (n : ℝ)` tends to `0` as `n` tends to `∞`. -/
theorem tendsto_mod_div_atTop_nhds_zero_nat {m : ℕ} (hm : 0 < m) :
Tendsto (fun n : ℕ => ((n % m : ℕ) : ℝ) / (n : ℝ)) atTop (𝓝 0) := by
have h0 : ∀ᶠ n : ℕ in atTop, 0 ≤ (fun n : ℕ => ((n % m : ℕ) : ℝ)) n := by aesop
exact tendsto_bdd_div_atTop_nhds_zero h0
(.of_forall (fun n ↦ cast_le.mpr (mod_lt n hm).le)) tendsto_natCast_atTop_atTop
theorem Filter.EventuallyEq.div_mul_cancel {α G : Type*} [GroupWithZero G] {f g : α → G}
{l : Filter α} (hg : Tendsto g l (𝓟 {0}ᶜ)) : (fun x ↦ f x / g x * g x) =ᶠ[l] fun x ↦ f x := by
filter_upwards [hg.le_comap <| preimage_mem_comap (m := g) (mem_principal_self {0}ᶜ)] with x hx
aesop
/-- If `g` tends to `∞`, then eventually for all `x` we have `(f x / g x) * g x = f x`. -/
theorem Filter.EventuallyEq.div_mul_cancel_atTop {α K : Type*}
[Semifield K] [LinearOrder K] [IsStrictOrderedRing K]
{f g : α → K} {l : Filter α} (hg : Tendsto g l atTop) :
(fun x ↦ f x / g x * g x) =ᶠ[l] fun x ↦ f x :=
div_mul_cancel <| hg.mono_right <| le_principal_iff.mpr <|
mem_of_superset (Ioi_mem_atTop 0) <| by simp
/-- If when `x` tends to `∞`, `g` tends to `∞` and `f x / g x` tends to a positive
constant, then `f` tends to `∞`. -/
theorem Tendsto.num {α K : Type*} [Field K] [LinearOrder K] [IsStrictOrderedRing K]
[TopologicalSpace K] [OrderTopology K]
{f g : α → K} {l : Filter α} (hg : Tendsto g l atTop) {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (𝓝 a)) :
Tendsto f l atTop :=
(hlim.pos_mul_atTop ha hg).congr' (EventuallyEq.div_mul_cancel_atTop hg)
/-- If when `x` tends to `∞`, `g` tends to `∞` and `f x / g x` tends to a positive
constant, then `f` tends to `∞`. -/
theorem Tendsto.den {α K : Type*} [Field K] [LinearOrder K] [IsStrictOrderedRing K]
[TopologicalSpace K] [OrderTopology K]
[ContinuousInv K] {f g : α → K} {l : Filter α} (hf : Tendsto f l atTop) {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (𝓝 a)) :
Tendsto g l atTop :=
have hlim' : Tendsto (fun x => g x / f x) l (𝓝 a⁻¹) := by
simp_rw [← inv_div (f _)]
exact Filter.Tendsto.inv (f := fun x => f x / g x) hlim
(hlim'.pos_mul_atTop (inv_pos_of_pos ha) hf).congr' (.div_mul_cancel_atTop hf)
/-- If when `x` tends to `∞`, `f x / g x` tends to a positive constant, then `f` tends to `∞` if
and only if `g` tends to `∞`. -/
theorem Tendsto.num_atTop_iff_den_atTop {α K : Type*}
[Field K] [LinearOrder K] [IsStrictOrderedRing K] [TopologicalSpace K]
[OrderTopology K] [ContinuousInv K] {f g : α → K} {l : Filter α} {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (𝓝 a)) :
Tendsto f l atTop ↔ Tendsto g l atTop :=
⟨fun hf ↦ Tendsto.den hf ha hlim, fun hg ↦ Tendsto.num hg ha hlim⟩
/-! ### Powers -/
theorem tendsto_add_one_pow_atTop_atTop_of_pos
[Semiring α] [LinearOrder α] [IsStrictOrderedRing α] [Archimedean α] {r : α}
(h : 0 < r) : Tendsto (fun n : ℕ ↦ (r + 1) ^ n) atTop atTop :=
tendsto_atTop_atTop_of_monotone' (pow_right_mono₀ <| le_add_of_nonneg_left h.le) <|
not_bddAbove_iff.2 fun _ ↦ Set.exists_range_iff.2 <| add_one_pow_unbounded_of_pos _ h
theorem tendsto_pow_atTop_atTop_of_one_lt
[Ring α] [LinearOrder α] [IsStrictOrderedRing α] [Archimedean α] {r : α}
(h : 1 < r) : Tendsto (fun n : ℕ ↦ r ^ n) atTop atTop :=
sub_add_cancel r 1 ▸ tendsto_add_one_pow_atTop_atTop_of_pos (sub_pos.2 h)
theorem Nat.tendsto_pow_atTop_atTop_of_one_lt {m : ℕ} (h : 1 < m) :
Tendsto (fun n : ℕ ↦ m ^ n) atTop atTop :=
tsub_add_cancel_of_le (le_of_lt h) ▸ tendsto_add_one_pow_atTop_atTop_of_pos (tsub_pos_of_lt h)
theorem tendsto_pow_atTop_nhds_zero_of_lt_one {𝕜 : Type*}
[Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [Archimedean 𝕜]
[TopologicalSpace 𝕜] [OrderTopology 𝕜] {r : 𝕜} (h₁ : 0 ≤ r) (h₂ : r < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) :=
h₁.eq_or_lt.elim
(fun hr ↦ (tendsto_add_atTop_iff_nat 1).mp <| by
simp [_root_.pow_succ, ← hr, tendsto_const_nhds])
(fun hr ↦
have := (one_lt_inv₀ hr).2 h₂ |> tendsto_pow_atTop_atTop_of_one_lt
(tendsto_inv_atTop_zero.comp this).congr fun n ↦ by simp)
@[simp] theorem tendsto_pow_atTop_nhds_zero_iff {𝕜 : Type*}
[Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [Archimedean 𝕜]
[TopologicalSpace 𝕜] [OrderTopology 𝕜] {r : 𝕜} :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) ↔ |r| < 1 := by
rw [tendsto_zero_iff_abs_tendsto_zero]
refine ⟨fun h ↦ by_contra (fun hr_le ↦ ?_), fun h ↦ ?_⟩
· by_cases hr : 1 = |r|
· replace h : Tendsto (fun n : ℕ ↦ |r|^n) atTop (𝓝 0) := by simpa only [← abs_pow, h]
simp only [hr.symm, one_pow] at h
exact zero_ne_one <| tendsto_nhds_unique h tendsto_const_nhds
· apply @not_tendsto_nhds_of_tendsto_atTop 𝕜 ℕ _ _ _ _ atTop _ (fun n ↦ |r| ^ n) _ 0 _
· refine (pow_right_strictMono₀ <| lt_of_le_of_ne (le_of_not_lt hr_le)
hr).monotone.tendsto_atTop_atTop (fun b ↦ ?_)
obtain ⟨n, hn⟩ := (pow_unbounded_of_one_lt b (lt_of_le_of_ne (le_of_not_lt hr_le) hr))
exact ⟨n, le_of_lt hn⟩
· simpa only [← abs_pow]
· simpa only [← abs_pow] using (tendsto_pow_atTop_nhds_zero_of_lt_one (abs_nonneg r)) h
theorem tendsto_pow_atTop_nhdsWithin_zero_of_lt_one {𝕜 : Type*}
[Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜]
[Archimedean 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] {r : 𝕜} (h₁ : 0 < r) (h₂ : r < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝[>] 0) :=
tendsto_inf.2
⟨tendsto_pow_atTop_nhds_zero_of_lt_one h₁.le h₂,
tendsto_principal.2 <| Eventually.of_forall fun _ ↦ pow_pos h₁ _⟩
theorem uniformity_basis_dist_pow_of_lt_one {α : Type*} [PseudoMetricSpace α] {r : ℝ} (h₀ : 0 < r)
(h₁ : r < 1) :
(uniformity α).HasBasis (fun _ : ℕ ↦ True) fun k ↦ { p : α × α | dist p.1 p.2 < r ^ k } :=
Metric.mk_uniformity_basis (fun _ _ ↦ pow_pos h₀ _) fun _ ε0 ↦
(exists_pow_lt_of_lt_one ε0 h₁).imp fun _ hk ↦ ⟨trivial, hk.le⟩
theorem geom_lt {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) {n : ℕ} (hn : 0 < n)
(h : ∀ k < n, c * u k < u (k + 1)) : c ^ n * u 0 < u n := by
apply (monotone_mul_left_of_nonneg hc).seq_pos_lt_seq_of_le_of_lt hn _ _ h
· simp
· simp [_root_.pow_succ', mul_assoc, le_refl]
theorem geom_le {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) (n : ℕ) (h : ∀ k < n, c * u k ≤ u (k + 1)) :
c ^ n * u 0 ≤ u n := by
apply (monotone_mul_left_of_nonneg hc).seq_le_seq n _ _ h <;>
simp [_root_.pow_succ', mul_assoc, le_refl]
theorem lt_geom {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) {n : ℕ} (hn : 0 < n)
(h : ∀ k < n, u (k + 1) < c * u k) : u n < c ^ n * u 0 := by
apply (monotone_mul_left_of_nonneg hc).seq_pos_lt_seq_of_lt_of_le hn _ h _
· simp
· simp [_root_.pow_succ', mul_assoc, le_refl]
theorem le_geom {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) (n : ℕ) (h : ∀ k < n, u (k + 1) ≤ c * u k) :
u n ≤ c ^ n * u 0 := by
apply (monotone_mul_left_of_nonneg hc).seq_le_seq n _ h _ <;>
simp [_root_.pow_succ', mul_assoc, le_refl]
/-- If a sequence `v` of real numbers satisfies `k * v n ≤ v (n+1)` with `1 < k`,
then it goes to +∞. -/
theorem tendsto_atTop_of_geom_le {v : ℕ → ℝ} {c : ℝ} (h₀ : 0 < v 0) (hc : 1 < c)
(hu : ∀ n, c * v n ≤ v (n + 1)) : Tendsto v atTop atTop :=
(tendsto_atTop_mono fun n ↦ geom_le (zero_le_one.trans hc.le) n fun k _ ↦ hu k) <|
(tendsto_pow_atTop_atTop_of_one_lt hc).atTop_mul_const h₀
theorem NNReal.tendsto_pow_atTop_nhds_zero_of_lt_one {r : ℝ≥0} (hr : r < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) :=
NNReal.tendsto_coe.1 <| by
simp only [NNReal.coe_pow, NNReal.coe_zero,
_root_.tendsto_pow_atTop_nhds_zero_of_lt_one r.coe_nonneg hr]
@[simp]
protected theorem NNReal.tendsto_pow_atTop_nhds_zero_iff {r : ℝ≥0} :
Tendsto (fun n : ℕ => r ^ n) atTop (𝓝 0) ↔ r < 1 :=
⟨fun h => by simpa [coe_pow, coe_zero, abs_eq, coe_lt_one, val_eq_coe] using
tendsto_pow_atTop_nhds_zero_iff.mp <| tendsto_coe.mpr h, tendsto_pow_atTop_nhds_zero_of_lt_one⟩
| Mathlib/Analysis/SpecificLimits/Basic.lean | 248 | 256 | theorem ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one {r : ℝ≥0∞} (hr : r < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) := by | rcases ENNReal.lt_iff_exists_coe.1 hr with ⟨r, rfl, hr'⟩
rw [← ENNReal.coe_zero]
norm_cast at *
apply NNReal.tendsto_pow_atTop_nhds_zero_of_lt_one hr
@[simp]
protected theorem ENNReal.tendsto_pow_atTop_nhds_zero_iff {r : ℝ≥0∞} : |
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.GeomSum
import Mathlib.Algebra.GroupWithZero.Action.Defs
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.Algebra.NoZeroSMulDivisors.Defs
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.Data.Nat.Lattice
import Mathlib.RingTheory.Nilpotent.Defs
import Mathlib.Algebra.BigOperators.Finprod
/-!
# Nilpotent elements
This file develops the basic theory of nilpotent elements. In particular it shows that the
nilpotent elements are closed under many operations.
For the definition of `nilradical`, see `Mathlib.RingTheory.Nilpotent.Lemmas`.
## Main definitions
* `isNilpotent_neg_iff`
* `Commute.isNilpotent_add`
* `Commute.isNilpotent_sub`
-/
universe u v
open Function Set
variable {R S : Type*} {x y : R}
theorem IsNilpotent.neg [Ring R] (h : IsNilpotent x) : IsNilpotent (-x) := by
obtain ⟨n, hn⟩ := h
use n
rw [neg_pow, hn, mul_zero]
@[simp]
theorem isNilpotent_neg_iff [Ring R] : IsNilpotent (-x) ↔ IsNilpotent x :=
⟨fun h => neg_neg x ▸ h.neg, fun h => h.neg⟩
lemma IsNilpotent.smul [MonoidWithZero R] [MonoidWithZero S] [MulActionWithZero R S]
[SMulCommClass R S S] [IsScalarTower R S S] {a : S} (ha : IsNilpotent a) (t : R) :
IsNilpotent (t • a) := by
obtain ⟨k, ha⟩ := ha
use k
rw [smul_pow, ha, smul_zero]
theorem IsNilpotent.isUnit_sub_one [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by
obtain ⟨n, hn⟩ := hnil
refine ⟨⟨r - 1, -∑ i ∈ Finset.range n, r ^ i, ?_, ?_⟩, rfl⟩
· simp [mul_geom_sum, hn]
· simp [geom_sum_mul, hn]
theorem IsNilpotent.isUnit_one_sub [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (1 - r) := by
rw [← IsUnit.neg_iff, neg_sub]
exact isUnit_sub_one hnil
theorem IsNilpotent.isUnit_add_one [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r + 1) := by
rw [← IsUnit.neg_iff, neg_add']
exact isUnit_sub_one hnil.neg
theorem IsNilpotent.isUnit_one_add [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (1 + r) :=
add_comm r 1 ▸ isUnit_add_one hnil
theorem IsNilpotent.isUnit_add_left_of_commute [Ring R] {r u : R}
(hnil : IsNilpotent r) (hu : IsUnit u) (h_comm : Commute r u) :
IsUnit (u + r) := by
rw [← Units.isUnit_mul_units _ hu.unit⁻¹, add_mul, IsUnit.mul_val_inv]
replace h_comm : Commute r (↑hu.unit⁻¹) := Commute.units_inv_right h_comm
refine IsNilpotent.isUnit_one_add ?_
exact (hu.unit⁻¹.isUnit.isNilpotent_mul_unit_of_commute_iff h_comm).mpr hnil
theorem IsNilpotent.isUnit_add_right_of_commute [Ring R] {r u : R}
(hnil : IsNilpotent r) (hu : IsUnit u) (h_comm : Commute r u) :
IsUnit (r + u) :=
add_comm r u ▸ hnil.isUnit_add_left_of_commute hu h_comm
lemma IsUnit.not_isNilpotent [Ring R] [Nontrivial R] {x : R} (hx : IsUnit x) :
¬ IsNilpotent x := by
intro H
simpa using H.isUnit_add_right_of_commute hx.neg (by simp)
lemma IsNilpotent.not_isUnit [Ring R] [Nontrivial R] {x : R} (hx : IsNilpotent x) :
¬ IsUnit x :=
mt IsUnit.not_isNilpotent (by simpa only [not_not] using hx)
lemma IsIdempotentElem.eq_zero_of_isNilpotent [MonoidWithZero R] {e : R}
(idem : IsIdempotentElem e) (nilp : IsNilpotent e) : e = 0 := by
obtain ⟨rfl | n, hn⟩ := nilp
· rw [pow_zero] at hn; rw [← one_mul e, hn, zero_mul]
· rw [← hn, idem.pow_succ_eq]
alias IsNilpotent.eq_zero_of_isIdempotentElem := IsIdempotentElem.eq_zero_of_isNilpotent
instance [Zero R] [Pow R ℕ] [Zero S] [Pow S ℕ] [IsReduced R] [IsReduced S] : IsReduced (R × S) where
eq_zero _ := fun ⟨n, hn⟩ ↦ have hn := Prod.ext_iff.1 hn
Prod.ext (IsReduced.eq_zero _ ⟨n, hn.1⟩) (IsReduced.eq_zero _ ⟨n, hn.2⟩)
theorem Prime.isRadical [CommMonoidWithZero R] {y : R} (hy : Prime y) : IsRadical y :=
fun _ _ ↦ hy.dvd_of_dvd_pow
theorem zero_isRadical_iff [MonoidWithZero R] : IsRadical (0 : R) ↔ IsReduced R := by
simp_rw [isReduced_iff, IsNilpotent, exists_imp, ← zero_dvd_iff]
exact forall_swap
theorem isReduced_iff_pow_one_lt [MonoidWithZero R] (k : ℕ) (hk : 1 < k) :
IsReduced R ↔ ∀ x : R, x ^ k = 0 → x = 0 := by
simp_rw [← zero_isRadical_iff, isRadical_iff_pow_one_lt k hk, zero_dvd_iff]
theorem IsRadical.of_dvd [CancelCommMonoidWithZero R] {x y : R} (hy : IsRadical y) (h0 : y ≠ 0)
(hxy : x ∣ y) : IsRadical x := (isRadical_iff_pow_one_lt 2 one_lt_two).2 <| by
obtain ⟨z, rfl⟩ := hxy
refine fun w dvd ↦ ((mul_dvd_mul_iff_right <| right_ne_zero_of_mul h0).mp <| hy 2 _ ?_)
rw [mul_pow, sq z]; exact mul_dvd_mul dvd (dvd_mul_left z z)
namespace Commute
section Semiring
variable [Semiring R]
| Mathlib/RingTheory/Nilpotent/Basic.lean | 129 | 132 | theorem add_pow_eq_zero_of_add_le_succ_of_pow_eq_zero (h_comm : Commute x y) {m n k : ℕ}
(hx : x ^ m = 0) (hy : y ^ n = 0) (h : m + n ≤ k + 1) :
(x + y) ^ k = 0 := by | rw [h_comm.add_pow'] |
/-
Copyright (c) 2023 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Logic.UnivLE
import Mathlib.SetTheory.Ordinal.Basic
/-!
# UnivLE and cardinals
-/
noncomputable section
universe u v
open Cardinal
| Mathlib/SetTheory/Cardinal/UnivLE.lean | 19 | 27 | theorem univLE_iff_cardinal_le : UnivLE.{u, v} ↔ univ.{u, v+1} ≤ univ.{v, u+1} := by | rw [← not_iff_not, univLE_iff]; simp_rw [small_iff_lift_mk_lt_univ]; push_neg
-- strange: simp_rw [univ_umax.{v,u}] doesn't work
refine ⟨fun ⟨α, le⟩ ↦ ?_, fun h ↦ ?_⟩
· rw [univ_umax.{v,u}, ← lift_le.{u+1}, lift_univ, lift_lift] at le
exact le.trans_lt (lift_lt_univ'.{u,v+1} #α)
· obtain ⟨⟨α⟩, h⟩ := lt_univ'.mp h; use α
rw [univ_umax.{v,u}, ← lift_le.{u+1}, lift_univ, lift_lift]
exact h.le |
/-
Copyright (c) 2024 Sophie Morel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sophie Morel
-/
import Mathlib.Analysis.NormedSpace.PiTensorProduct.ProjectiveSeminorm
import Mathlib.LinearAlgebra.Isomorphisms
/-!
# Injective seminorm on the tensor of a finite family of normed spaces.
Let `𝕜` be a nontrivially normed field and `E` be a family of normed `𝕜`-vector spaces `Eᵢ`,
indexed by a finite type `ι`. We define a seminorm on `⨂[𝕜] i, Eᵢ`, which we call the
"injective seminorm". It is chosen to satisfy the following property: for every
normed `𝕜`-vector space `F`, the linear equivalence
`MultilinearMap 𝕜 E F ≃ₗ[𝕜] (⨂[𝕜] i, Eᵢ) →ₗ[𝕜] F`
expressing the universal property of the tensor product induces an isometric linear equivalence
`ContinuousMultilinearMap 𝕜 E F ≃ₗᵢ[𝕜] (⨂[𝕜] i, Eᵢ) →L[𝕜] F`.
The idea is the following: Every normed `𝕜`-vector space `F` defines a linear map
from `⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →ₗ[𝕜] F`, which sends `x` to the map
`f ↦ f.lift x`. Thanks to `PiTensorProduct.norm_eval_le_projectiveSeminorm`, this map lands in
`ContinuousMultilinearMap 𝕜 E F →L[𝕜] F`. As this last space has a natural operator (semi)norm,
we get an induced seminorm on `⨂[𝕜] i, Eᵢ`, which, by
`PiTensorProduct.norm_eval_le_projectiveSeminorm`, is bounded above by the projective seminorm
`PiTensorProduct.projectiveSeminorm`. We then take the `sup` of these seminorms as `F` varies;
as this family of seminorms is bounded, its `sup` has good properties.
In fact, we cannot take the `sup` over all normed spaces `F` because of set-theoretical issues,
so we only take spaces `F` in the same universe as `⨂[𝕜] i, Eᵢ`. We prove in
`norm_eval_le_injectiveSeminorm` that this gives the same result, because every multilinear map
from `E = Πᵢ Eᵢ` to `F` factors though a normed vector space in the same universe as
`⨂[𝕜] i, Eᵢ`.
We then prove the universal property and the functoriality of `⨂[𝕜] i, Eᵢ` as a normed vector
space.
## Main definitions
* `PiTensorProduct.toDualContinuousMultilinearMap`: The `𝕜`-linear map from
`⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →L[𝕜] F` sending `x` to the map
`f ↦ f x`.
* `PiTensorProduct.injectiveSeminorm`: The injective seminorm on `⨂[𝕜] i, Eᵢ`.
* `PiTensorProduct.liftEquiv`: The bijection between `ContinuousMultilinearMap 𝕜 E F`
and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`, as a continuous linear equivalence.
* `PiTensorProduct.liftIsometry`: The bijection between `ContinuousMultilinearMap 𝕜 E F`
and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`, as an isometric linear equivalence.
* `PiTensorProduct.tprodL`: The canonical continuous multilinear map from `E = Πᵢ Eᵢ`
to `⨂[𝕜] i, Eᵢ`.
* `PiTensorProduct.mapL`: The continuous linear map from `⨂[𝕜] i, Eᵢ` to `⨂[𝕜] i, E'ᵢ`
induced by a family of continuous linear maps `Eᵢ →L[𝕜] E'ᵢ`.
* `PiTensorProduct.mapLMultilinear`: The continuous multilinear map from
`Πᵢ (Eᵢ →L[𝕜] E'ᵢ)` to `(⨂[𝕜] i, Eᵢ) →L[𝕜] (⨂[𝕜] i, E'ᵢ)` sending a family
`f` to `PiTensorProduct.mapL f`.
## Main results
* `PiTensorProduct.norm_eval_le_injectiveSeminorm`: The main property of the injective seminorm
on `⨂[𝕜] i, Eᵢ`: for every `x` in `⨂[𝕜] i, Eᵢ` and every continuous multilinear map `f` from
`E = Πᵢ Eᵢ` to a normed space `F`, we have `‖f.lift x‖ ≤ ‖f‖ * injectiveSeminorm x `.
* `PiTensorProduct.mapL_opNorm`: If `f` is a family of continuous linear maps
`fᵢ : Eᵢ →L[𝕜] Fᵢ`, then `‖PiTensorProduct.mapL f‖ ≤ ∏ i, ‖fᵢ‖`.
* `PiTensorProduct.mapLMultilinear_opNorm` : If `F` is a normed vecteor space, then
`‖mapLMultilinear 𝕜 E F‖ ≤ 1`.
## TODO
* If all `Eᵢ` are separated and satisfy `SeparatingDual`, then the seminorm on
`⨂[𝕜] i, Eᵢ` is a norm. This uses the construction of a basis of the `PiTensorProduct`, hence
depends on PR https://github.com/leanprover-community/mathlib4/pull/11156. It should probably go in a separate file.
* Adapt the remaining functoriality constructions/properties from `PiTensorProduct`.
-/
universe uι u𝕜 uE uF
variable {ι : Type uι} [Fintype ι]
variable {𝕜 : Type u𝕜} [NontriviallyNormedField 𝕜]
variable {E : ι → Type uE} [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
variable {F : Type uF} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
open scoped TensorProduct
namespace PiTensorProduct
section seminorm
variable (F) in
/-- The linear map from `⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →L[𝕜] F` sending
`x` in `⨂[𝕜] i, Eᵢ` to the map `f ↦ f.lift x`.
-/
@[simps!]
noncomputable def toDualContinuousMultilinearMap : (⨂[𝕜] i, E i) →ₗ[𝕜]
ContinuousMultilinearMap 𝕜 E F →L[𝕜] F where
toFun x := LinearMap.mkContinuous
((LinearMap.flip (lift (R := 𝕜) (s := E) (E := F)).toLinearMap x) ∘ₗ
ContinuousMultilinearMap.toMultilinearMapLinear)
(projectiveSeminorm x)
(fun _ ↦ by simp only [LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.flip_apply,
LinearEquiv.coe_coe]
exact norm_eval_le_projectiveSeminorm _ _ _)
map_add' x y := by
ext _
simp only [map_add, LinearMap.mkContinuous_apply, LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.add_apply,
LinearMap.flip_apply, LinearEquiv.coe_coe, ContinuousLinearMap.add_apply]
map_smul' a x := by
ext _
simp only [map_smul, LinearMap.mkContinuous_apply, LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.smul_apply,
LinearMap.flip_apply, LinearEquiv.coe_coe, RingHom.id_apply, ContinuousLinearMap.coe_smul',
Pi.smul_apply]
| Mathlib/Analysis/NormedSpace/PiTensorProduct/InjectiveSeminorm.lean | 116 | 119 | theorem toDualContinuousMultilinearMap_le_projectiveSeminorm (x : ⨂[𝕜] i, E i) :
‖toDualContinuousMultilinearMap F x‖ ≤ projectiveSeminorm x := by | simp only [toDualContinuousMultilinearMap, LinearMap.coe_mk, AddHom.coe_mk]
apply LinearMap.mkContinuous_norm_le _ (apply_nonneg _ _) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.