Context stringlengths 57 85k | file_name stringlengths 21 79 | start int64 14 2.42k | end int64 18 2.43k | theorem stringlengths 25 2.71k | proof stringlengths 5 10.6k |
|---|---|---|---|---|---|
import Mathlib.Data.PNat.Prime
import Mathlib.Algebra.IsPrimePow
import Mathlib.NumberTheory.Cyclotomic.Basic
import Mathlib.RingTheory.Adjoin.PowerBasis
import Mathlib.RingTheory.Polynomial.Cyclotomic.Eval
import Mathlib.RingTheory.Norm
import Mathlib.RingTheory.Polynomial.Cyclotomic.Expand
#align_import number_theory.cyclotomic.primitive_roots from "leanprover-community/mathlib"@"5bfbcca0a7ffdd21cf1682e59106d6c942434a32"
open Polynomial Algebra Finset FiniteDimensional IsCyclotomicExtension Nat PNat Set
open scoped IntermediateField
universe u v w z
variable {p n : ℕ+} (A : Type w) (B : Type z) (K : Type u) {L : Type v} (C : Type w)
variable [CommRing A] [CommRing B] [Algebra A B] [IsCyclotomicExtension {n} A B]
section Zeta
namespace IsCyclotomicExtension
variable (n)
noncomputable def zeta : B :=
(exists_prim_root A <| Set.mem_singleton n : ∃ r : B, IsPrimitiveRoot r n).choose
#align is_cyclotomic_extension.zeta IsCyclotomicExtension.zeta
@[simp]
theorem zeta_spec : IsPrimitiveRoot (zeta n A B) n :=
Classical.choose_spec (exists_prim_root A (Set.mem_singleton n) : ∃ r : B, IsPrimitiveRoot r n)
#align is_cyclotomic_extension.zeta_spec IsCyclotomicExtension.zeta_spec
theorem aeval_zeta [IsDomain B] [NeZero ((n : ℕ) : B)] :
aeval (zeta n A B) (cyclotomic n A) = 0 := by
rw [aeval_def, ← eval_map, ← IsRoot.def, map_cyclotomic, isRoot_cyclotomic_iff]
exact zeta_spec n A B
#align is_cyclotomic_extension.aeval_zeta IsCyclotomicExtension.aeval_zeta
| Mathlib/NumberTheory/Cyclotomic/PrimitiveRoots.lean | 98 | 100 | theorem zeta_isRoot [IsDomain B] [NeZero ((n : ℕ) : B)] : IsRoot (cyclotomic n B) (zeta n A B) := by |
convert aeval_zeta n A B using 0
rw [IsRoot.def, aeval_def, eval₂_eq_eval_map, map_cyclotomic]
|
import Mathlib.LinearAlgebra.TensorProduct.Graded.External
import Mathlib.RingTheory.GradedAlgebra.Basic
import Mathlib.GroupTheory.GroupAction.Ring
suppress_compilation
open scoped TensorProduct
variable {R ι A B : Type*}
variable [CommSemiring ι] [Module ι (Additive ℤˣ)] [DecidableEq ι]
variable [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B]
variable (𝒜 : ι → Submodule R A) (ℬ : ι → Submodule R B)
variable [GradedAlgebra 𝒜] [GradedAlgebra ℬ]
open DirectSum
variable (R) in
@[nolint unusedArguments]
def GradedTensorProduct
(𝒜 : ι → Submodule R A) (ℬ : ι → Submodule R B)
[GradedAlgebra 𝒜] [GradedAlgebra ℬ] :
Type _ :=
A ⊗[R] B
namespace GradedTensorProduct
open TensorProduct
@[inherit_doc GradedTensorProduct]
scoped[TensorProduct] notation:100 𝒜 " ᵍ⊗[" R "] " ℬ:100 => GradedTensorProduct R 𝒜 ℬ
instance instAddCommGroupWithOne : AddCommGroupWithOne (𝒜 ᵍ⊗[R] ℬ) :=
Algebra.TensorProduct.instAddCommGroupWithOne
instance : Module R (𝒜 ᵍ⊗[R] ℬ) := TensorProduct.leftModule
variable (R) in
def of : A ⊗[R] B ≃ₗ[R] 𝒜 ᵍ⊗[R] ℬ := LinearEquiv.refl _ _
@[simp]
theorem of_one : of R 𝒜 ℬ 1 = 1 := rfl
@[simp]
theorem of_symm_one : (of R 𝒜 ℬ).symm 1 = 1 := rfl
-- for dsimp
@[simp, nolint simpNF]
theorem of_symm_of (x : A ⊗[R] B) : (of R 𝒜 ℬ).symm (of R 𝒜 ℬ x) = x := rfl
-- for dsimp
@[simp, nolint simpNF]
theorem symm_of_of (x : 𝒜 ᵍ⊗[R] ℬ) : of R 𝒜 ℬ ((of R 𝒜 ℬ).symm x) = x := rfl
@[ext]
theorem hom_ext {M} [AddCommMonoid M] [Module R M] ⦃f g : 𝒜 ᵍ⊗[R] ℬ →ₗ[R] M⦄
(h : f ∘ₗ of R 𝒜 ℬ = (g ∘ₗ of R 𝒜 ℬ : A ⊗[R] B →ₗ[R] M)) :
f = g :=
h
variable (R) {𝒜 ℬ} in
abbrev tmul (a : A) (b : B) : 𝒜 ᵍ⊗[R] ℬ := of R 𝒜 ℬ (a ⊗ₜ b)
@[inherit_doc]
notation:100 x " ᵍ⊗ₜ" y:100 => tmul _ x y
@[inherit_doc]
notation:100 x " ᵍ⊗ₜ[" R "] " y:100 => tmul R x y
variable (R) in
noncomputable def auxEquiv : (𝒜 ᵍ⊗[R] ℬ) ≃ₗ[R] (⨁ i, 𝒜 i) ⊗[R] (⨁ i, ℬ i) :=
let fA := (decomposeAlgEquiv 𝒜).toLinearEquiv
let fB := (decomposeAlgEquiv ℬ).toLinearEquiv
(of R 𝒜 ℬ).symm.trans (TensorProduct.congr fA fB)
theorem auxEquiv_tmul (a : A) (b : B) :
auxEquiv R 𝒜 ℬ (a ᵍ⊗ₜ b) = decompose 𝒜 a ⊗ₜ decompose ℬ b := rfl
theorem auxEquiv_one : auxEquiv R 𝒜 ℬ 1 = 1 := by
rw [← of_one, Algebra.TensorProduct.one_def, auxEquiv_tmul 𝒜 ℬ, DirectSum.decompose_one,
DirectSum.decompose_one, Algebra.TensorProduct.one_def]
theorem auxEquiv_symm_one : (auxEquiv R 𝒜 ℬ).symm 1 = 1 :=
(LinearEquiv.symm_apply_eq _).mpr (auxEquiv_one _ _).symm
noncomputable def mulHom : (𝒜 ᵍ⊗[R] ℬ) →ₗ[R] (𝒜 ᵍ⊗[R] ℬ) →ₗ[R] (𝒜 ᵍ⊗[R] ℬ) := by
letI fAB1 := auxEquiv R 𝒜 ℬ
have := ((gradedMul R (𝒜 ·) (ℬ ·)).compl₁₂ fAB1.toLinearMap fAB1.toLinearMap).compr₂
fAB1.symm.toLinearMap
exact this
theorem mulHom_apply (x y : 𝒜 ᵍ⊗[R] ℬ) :
mulHom 𝒜 ℬ x y
= (auxEquiv R 𝒜 ℬ).symm (gradedMul R (𝒜 ·) (ℬ ·) (auxEquiv R 𝒜 ℬ x) (auxEquiv R 𝒜 ℬ y)) :=
rfl
instance : Mul (𝒜 ᵍ⊗[R] ℬ) where mul x y := mulHom 𝒜 ℬ x y
theorem mul_def (x y : 𝒜 ᵍ⊗[R] ℬ) : x * y = mulHom 𝒜 ℬ x y := rfl
-- Before #8386 this was `@[simp]` but it times out when we try to apply it.
theorem auxEquiv_mul (x y : 𝒜 ᵍ⊗[R] ℬ) :
auxEquiv R 𝒜 ℬ (x * y) = gradedMul R (𝒜 ·) (ℬ ·) (auxEquiv R 𝒜 ℬ x) (auxEquiv R 𝒜 ℬ y) :=
LinearEquiv.eq_symm_apply _ |>.mp rfl
instance instMonoid : Monoid (𝒜 ᵍ⊗[R] ℬ) where
mul_one x := by
rw [mul_def, mulHom_apply, auxEquiv_one, gradedMul_one, LinearEquiv.symm_apply_apply]
one_mul x := by
rw [mul_def, mulHom_apply, auxEquiv_one, one_gradedMul, LinearEquiv.symm_apply_apply]
mul_assoc x y z := by
simp_rw [mul_def, mulHom_apply, LinearEquiv.apply_symm_apply]
rw [gradedMul_assoc]
instance instRing : Ring (𝒜 ᵍ⊗[R] ℬ) where
__ := instAddCommGroupWithOne 𝒜 ℬ
__ := instMonoid 𝒜 ℬ
right_distrib x y z := by simp_rw [mul_def, LinearMap.map_add₂]
left_distrib x y z := by simp_rw [mul_def, map_add]
mul_zero x := by simp_rw [mul_def, map_zero]
zero_mul x := by simp_rw [mul_def, LinearMap.map_zero₂]
theorem tmul_coe_mul_coe_tmul {j₁ i₂ : ι} (a₁ : A) (b₁ : ℬ j₁) (a₂ : 𝒜 i₂) (b₂ : B) :
(a₁ ᵍ⊗ₜ[R] (b₁ : B) * (a₂ : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) =
(-1 : ℤˣ)^(j₁ * i₂) • ((a₁ * a₂ : A) ᵍ⊗ₜ (b₁ * b₂ : B)) := by
dsimp only [mul_def, mulHom_apply, of_symm_of]
dsimp [auxEquiv, tmul]
erw [decompose_coe, decompose_coe]
simp_rw [← lof_eq_of R]
rw [tmul_of_gradedMul_of_tmul]
simp_rw [lof_eq_of R]
rw [LinearEquiv.symm_symm]
-- Note: #8386 had to specialize `map_smul` to `LinearEquiv.map_smul`
rw [@Units.smul_def _ _ (_) (_), zsmul_eq_smul_cast R, LinearEquiv.map_smul, map_smul,
← zsmul_eq_smul_cast R, ← @Units.smul_def _ _ (_) (_)]
rw [congr_symm_tmul]
dsimp
simp_rw [decompose_symm_mul, decompose_symm_of, Equiv.symm_apply_apply]
theorem tmul_zero_coe_mul_coe_tmul {i₂ : ι} (a₁ : A) (b₁ : ℬ 0) (a₂ : 𝒜 i₂) (b₂ : B) :
(a₁ ᵍ⊗ₜ[R] (b₁ : B) * (a₂ : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) =
((a₁ * a₂ : A) ᵍ⊗ₜ (b₁ * b₂ : B)) := by
rw [tmul_coe_mul_coe_tmul, zero_mul, uzpow_zero, one_smul]
theorem tmul_coe_mul_zero_coe_tmul {j₁ : ι} (a₁ : A) (b₁ : ℬ j₁) (a₂ : 𝒜 0) (b₂ : B) :
(a₁ ᵍ⊗ₜ[R] (b₁ : B) * (a₂ : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) =
((a₁ * a₂ : A) ᵍ⊗ₜ (b₁ * b₂ : B)) := by
rw [tmul_coe_mul_coe_tmul, mul_zero, uzpow_zero, one_smul]
theorem tmul_one_mul_coe_tmul {i₂ : ι} (a₁ : A) (a₂ : 𝒜 i₂) (b₂ : B) :
(a₁ ᵍ⊗ₜ[R] (1 : B) * (a₂ : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) = (a₁ * a₂ : A) ᵍ⊗ₜ (b₂ : B) := by
convert tmul_zero_coe_mul_coe_tmul 𝒜 ℬ a₁ (@GradedMonoid.GOne.one _ (ℬ ·) _ _) a₂ b₂
rw [SetLike.coe_gOne, one_mul]
theorem tmul_coe_mul_one_tmul {j₁ : ι} (a₁ : A) (b₁ : ℬ j₁) (b₂ : B) :
(a₁ ᵍ⊗ₜ[R] (b₁ : B) * (1 : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) = (a₁ : A) ᵍ⊗ₜ (b₁ * b₂ : B) := by
convert tmul_coe_mul_zero_coe_tmul 𝒜 ℬ a₁ b₁ (@GradedMonoid.GOne.one _ (𝒜 ·) _ _) b₂
rw [SetLike.coe_gOne, mul_one]
| Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean | 222 | 227 | theorem tmul_one_mul_one_tmul (a₁ : A) (b₂ : B) :
(a₁ ᵍ⊗ₜ[R] (1 : B) * (1 : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) = (a₁ : A) ᵍ⊗ₜ (b₂ : B) := by |
convert tmul_coe_mul_zero_coe_tmul 𝒜 ℬ
a₁ (@GradedMonoid.GOne.one _ (ℬ ·) _ _) (@GradedMonoid.GOne.one _ (𝒜 ·) _ _) b₂
· rw [SetLike.coe_gOne, mul_one]
· rw [SetLike.coe_gOne, one_mul]
|
import Mathlib.Analysis.Complex.Circle
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup
#align_import analysis.complex.isometry from "leanprover-community/mathlib"@"ae690b0c236e488a0043f6faa8ce3546e7f2f9c5"
noncomputable section
open Complex
open ComplexConjugate
local notation "|" x "|" => Complex.abs x
def rotation : circle →* ℂ ≃ₗᵢ[ℝ] ℂ where
toFun a :=
{ DistribMulAction.toLinearEquiv ℝ ℂ a with
norm_map' := fun x => show |a * x| = |x| by rw [map_mul, abs_coe_circle, one_mul] }
map_one' := LinearIsometryEquiv.ext <| one_smul circle
map_mul' a b := LinearIsometryEquiv.ext <| mul_smul a b
#align rotation rotation
@[simp]
theorem rotation_apply (a : circle) (z : ℂ) : rotation a z = a * z :=
rfl
#align rotation_apply rotation_apply
@[simp]
theorem rotation_symm (a : circle) : (rotation a).symm = rotation a⁻¹ :=
LinearIsometryEquiv.ext fun _ => rfl
#align rotation_symm rotation_symm
@[simp]
theorem rotation_trans (a b : circle) : (rotation a).trans (rotation b) = rotation (b * a) := by
ext1
simp
#align rotation_trans rotation_trans
| Mathlib/Analysis/Complex/Isometry.lean | 65 | 71 | theorem rotation_ne_conjLIE (a : circle) : rotation a ≠ conjLIE := by |
intro h
have h1 : rotation a 1 = conj 1 := LinearIsometryEquiv.congr_fun h 1
have hI : rotation a I = conj I := LinearIsometryEquiv.congr_fun h I
rw [rotation_apply, RingHom.map_one, mul_one] at h1
rw [rotation_apply, conj_I, ← neg_one_mul, mul_left_inj' I_ne_zero, h1, eq_neg_self_iff] at hI
exact one_ne_zero hI
|
import Mathlib.Data.Set.Prod
import Mathlib.Logic.Function.Conjugate
#align_import data.set.function from "leanprover-community/mathlib"@"996b0ff959da753a555053a480f36e5f264d4207"
variable {α β γ : Type*} {ι : Sort*} {π : α → Type*}
open Equiv Equiv.Perm Function
namespace Set
section restrict
def restrict (s : Set α) (f : ∀ a : α, π a) : ∀ a : s, π a := fun x => f x
#align set.restrict Set.restrict
theorem restrict_eq (f : α → β) (s : Set α) : s.restrict f = f ∘ Subtype.val :=
rfl
#align set.restrict_eq Set.restrict_eq
@[simp]
theorem restrict_apply (f : α → β) (s : Set α) (x : s) : s.restrict f x = f x :=
rfl
#align set.restrict_apply Set.restrict_apply
theorem restrict_eq_iff {f : ∀ a, π a} {s : Set α} {g : ∀ a : s, π a} :
restrict s f = g ↔ ∀ (a) (ha : a ∈ s), f a = g ⟨a, ha⟩ :=
funext_iff.trans Subtype.forall
#align set.restrict_eq_iff Set.restrict_eq_iff
theorem eq_restrict_iff {s : Set α} {f : ∀ a : s, π a} {g : ∀ a, π a} :
f = restrict s g ↔ ∀ (a) (ha : a ∈ s), f ⟨a, ha⟩ = g a :=
funext_iff.trans Subtype.forall
#align set.eq_restrict_iff Set.eq_restrict_iff
@[simp]
theorem range_restrict (f : α → β) (s : Set α) : Set.range (s.restrict f) = f '' s :=
(range_comp _ _).trans <| congr_arg (f '' ·) Subtype.range_coe
#align set.range_restrict Set.range_restrict
theorem image_restrict (f : α → β) (s t : Set α) :
s.restrict f '' (Subtype.val ⁻¹' t) = f '' (t ∩ s) := by
rw [restrict_eq, image_comp, image_preimage_eq_inter_range, Subtype.range_coe]
#align set.image_restrict Set.image_restrict
@[simp]
theorem restrict_dite {s : Set α} [∀ x, Decidable (x ∈ s)] (f : ∀ a ∈ s, β)
(g : ∀ a ∉ s, β) :
(s.restrict fun a => if h : a ∈ s then f a h else g a h) = (fun a : s => f a a.2) :=
funext fun a => dif_pos a.2
#align set.restrict_dite Set.restrict_dite
@[simp]
theorem restrict_dite_compl {s : Set α} [∀ x, Decidable (x ∈ s)] (f : ∀ a ∈ s, β)
(g : ∀ a ∉ s, β) :
(sᶜ.restrict fun a => if h : a ∈ s then f a h else g a h) = (fun a : (sᶜ : Set α) => g a a.2) :=
funext fun a => dif_neg a.2
#align set.restrict_dite_compl Set.restrict_dite_compl
@[simp]
theorem restrict_ite (f g : α → β) (s : Set α) [∀ x, Decidable (x ∈ s)] :
(s.restrict fun a => if a ∈ s then f a else g a) = s.restrict f :=
restrict_dite _ _
#align set.restrict_ite Set.restrict_ite
@[simp]
theorem restrict_ite_compl (f g : α → β) (s : Set α) [∀ x, Decidable (x ∈ s)] :
(sᶜ.restrict fun a => if a ∈ s then f a else g a) = sᶜ.restrict g :=
restrict_dite_compl _ _
#align set.restrict_ite_compl Set.restrict_ite_compl
@[simp]
theorem restrict_piecewise (f g : α → β) (s : Set α) [∀ x, Decidable (x ∈ s)] :
s.restrict (piecewise s f g) = s.restrict f :=
restrict_ite _ _ _
#align set.restrict_piecewise Set.restrict_piecewise
@[simp]
theorem restrict_piecewise_compl (f g : α → β) (s : Set α) [∀ x, Decidable (x ∈ s)] :
sᶜ.restrict (piecewise s f g) = sᶜ.restrict g :=
restrict_ite_compl _ _ _
#align set.restrict_piecewise_compl Set.restrict_piecewise_compl
theorem restrict_extend_range (f : α → β) (g : α → γ) (g' : β → γ) :
(range f).restrict (extend f g g') = fun x => g x.coe_prop.choose := by
classical
exact restrict_dite _ _
#align set.restrict_extend_range Set.restrict_extend_range
@[simp]
theorem restrict_extend_compl_range (f : α → β) (g : α → γ) (g' : β → γ) :
(range f)ᶜ.restrict (extend f g g') = g' ∘ Subtype.val := by
classical
exact restrict_dite_compl _ _
#align set.restrict_extend_compl_range Set.restrict_extend_compl_range
theorem range_extend_subset (f : α → β) (g : α → γ) (g' : β → γ) :
range (extend f g g') ⊆ range g ∪ g' '' (range f)ᶜ := by
classical
rintro _ ⟨y, rfl⟩
rw [extend_def]
split_ifs with h
exacts [Or.inl (mem_range_self _), Or.inr (mem_image_of_mem _ h)]
#align set.range_extend_subset Set.range_extend_subset
theorem range_extend {f : α → β} (hf : Injective f) (g : α → γ) (g' : β → γ) :
range (extend f g g') = range g ∪ g' '' (range f)ᶜ := by
refine (range_extend_subset _ _ _).antisymm ?_
rintro z (⟨x, rfl⟩ | ⟨y, hy, rfl⟩)
exacts [⟨f x, hf.extend_apply _ _ _⟩, ⟨y, extend_apply' _ _ _ hy⟩]
#align set.range_extend Set.range_extend
def codRestrict (f : ι → α) (s : Set α) (h : ∀ x, f x ∈ s) : ι → s := fun x => ⟨f x, h x⟩
#align set.cod_restrict Set.codRestrict
@[simp]
theorem val_codRestrict_apply (f : ι → α) (s : Set α) (h : ∀ x, f x ∈ s) (x : ι) :
(codRestrict f s h x : α) = f x :=
rfl
#align set.coe_cod_restrict_apply Set.val_codRestrict_apply
@[simp]
theorem restrict_comp_codRestrict {f : ι → α} {g : α → β} {b : Set α} (h : ∀ x, f x ∈ b) :
b.restrict g ∘ b.codRestrict f h = g ∘ f :=
rfl
#align set.restrict_comp_cod_restrict Set.restrict_comp_codRestrict
@[simp]
| Mathlib/Data/Set/Function.lean | 164 | 166 | theorem injective_codRestrict {f : ι → α} {s : Set α} (h : ∀ x, f x ∈ s) :
Injective (codRestrict f s h) ↔ Injective f := by |
simp only [Injective, Subtype.ext_iff, val_codRestrict_apply]
|
import Mathlib.Data.Real.Sqrt
import Mathlib.Analysis.NormedSpace.Star.Basic
import Mathlib.Analysis.NormedSpace.ContinuousLinearMap
import Mathlib.Analysis.NormedSpace.Basic
#align_import data.is_R_or_C.basic from "leanprover-community/mathlib"@"baa88307f3e699fa7054ef04ec79fa4f056169cb"
section
local notation "𝓚" => algebraMap ℝ _
open ComplexConjugate
class RCLike (K : semiOutParam Type*) extends DenselyNormedField K, StarRing K,
NormedAlgebra ℝ K, CompleteSpace K where
re : K →+ ℝ
im : K →+ ℝ
I : K
I_re_ax : re I = 0
I_mul_I_ax : I = 0 ∨ I * I = -1
re_add_im_ax : ∀ z : K, 𝓚 (re z) + 𝓚 (im z) * I = z
ofReal_re_ax : ∀ r : ℝ, re (𝓚 r) = r
ofReal_im_ax : ∀ r : ℝ, im (𝓚 r) = 0
mul_re_ax : ∀ z w : K, re (z * w) = re z * re w - im z * im w
mul_im_ax : ∀ z w : K, im (z * w) = re z * im w + im z * re w
conj_re_ax : ∀ z : K, re (conj z) = re z
conj_im_ax : ∀ z : K, im (conj z) = -im z
conj_I_ax : conj I = -I
norm_sq_eq_def_ax : ∀ z : K, ‖z‖ ^ 2 = re z * re z + im z * im z
mul_im_I_ax : ∀ z : K, im z * im I = im z
[toPartialOrder : PartialOrder K]
le_iff_re_im {z w : K} : z ≤ w ↔ re z ≤ re w ∧ im z = im w
-- note we cannot put this in the `extends` clause
[toDecidableEq : DecidableEq K]
#align is_R_or_C RCLike
scoped[ComplexOrder] attribute [instance 100] RCLike.toPartialOrder
attribute [instance 100] RCLike.toDecidableEq
end
variable {K E : Type*} [RCLike K]
namespace RCLike
open ComplexConjugate
@[coe] abbrev ofReal : ℝ → K := Algebra.cast
noncomputable instance (priority := 900) algebraMapCoe : CoeTC ℝ K :=
⟨ofReal⟩
#align is_R_or_C.algebra_map_coe RCLike.algebraMapCoe
theorem ofReal_alg (x : ℝ) : (x : K) = x • (1 : K) :=
Algebra.algebraMap_eq_smul_one x
#align is_R_or_C.of_real_alg RCLike.ofReal_alg
theorem real_smul_eq_coe_mul (r : ℝ) (z : K) : r • z = (r : K) * z :=
Algebra.smul_def r z
#align is_R_or_C.real_smul_eq_coe_mul RCLike.real_smul_eq_coe_mul
theorem real_smul_eq_coe_smul [AddCommGroup E] [Module K E] [Module ℝ E] [IsScalarTower ℝ K E]
(r : ℝ) (x : E) : r • x = (r : K) • x := by rw [RCLike.ofReal_alg, smul_one_smul]
#align is_R_or_C.real_smul_eq_coe_smul RCLike.real_smul_eq_coe_smul
theorem algebraMap_eq_ofReal : ⇑(algebraMap ℝ K) = ofReal :=
rfl
#align is_R_or_C.algebra_map_eq_of_real RCLike.algebraMap_eq_ofReal
@[simp, rclike_simps]
theorem re_add_im (z : K) : (re z : K) + im z * I = z :=
RCLike.re_add_im_ax z
#align is_R_or_C.re_add_im RCLike.re_add_im
@[simp, norm_cast, rclike_simps]
theorem ofReal_re : ∀ r : ℝ, re (r : K) = r :=
RCLike.ofReal_re_ax
#align is_R_or_C.of_real_re RCLike.ofReal_re
@[simp, norm_cast, rclike_simps]
theorem ofReal_im : ∀ r : ℝ, im (r : K) = 0 :=
RCLike.ofReal_im_ax
#align is_R_or_C.of_real_im RCLike.ofReal_im
@[simp, rclike_simps]
theorem mul_re : ∀ z w : K, re (z * w) = re z * re w - im z * im w :=
RCLike.mul_re_ax
#align is_R_or_C.mul_re RCLike.mul_re
@[simp, rclike_simps]
theorem mul_im : ∀ z w : K, im (z * w) = re z * im w + im z * re w :=
RCLike.mul_im_ax
#align is_R_or_C.mul_im RCLike.mul_im
theorem ext_iff {z w : K} : z = w ↔ re z = re w ∧ im z = im w :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, fun ⟨h₁, h₂⟩ => re_add_im z ▸ re_add_im w ▸ h₁ ▸ h₂ ▸ rfl⟩
#align is_R_or_C.ext_iff RCLike.ext_iff
theorem ext {z w : K} (hre : re z = re w) (him : im z = im w) : z = w :=
ext_iff.2 ⟨hre, him⟩
#align is_R_or_C.ext RCLike.ext
@[norm_cast]
theorem ofReal_zero : ((0 : ℝ) : K) = 0 :=
algebraMap.coe_zero
#align is_R_or_C.of_real_zero RCLike.ofReal_zero
@[rclike_simps]
theorem zero_re' : re (0 : K) = (0 : ℝ) :=
map_zero re
#align is_R_or_C.zero_re' RCLike.zero_re'
@[norm_cast]
theorem ofReal_one : ((1 : ℝ) : K) = 1 :=
map_one (algebraMap ℝ K)
#align is_R_or_C.of_real_one RCLike.ofReal_one
@[simp, rclike_simps]
theorem one_re : re (1 : K) = 1 := by rw [← ofReal_one, ofReal_re]
#align is_R_or_C.one_re RCLike.one_re
@[simp, rclike_simps]
theorem one_im : im (1 : K) = 0 := by rw [← ofReal_one, ofReal_im]
#align is_R_or_C.one_im RCLike.one_im
theorem ofReal_injective : Function.Injective ((↑) : ℝ → K) :=
(algebraMap ℝ K).injective
#align is_R_or_C.of_real_injective RCLike.ofReal_injective
@[norm_cast]
theorem ofReal_inj {z w : ℝ} : (z : K) = (w : K) ↔ z = w :=
algebraMap.coe_inj
#align is_R_or_C.of_real_inj RCLike.ofReal_inj
-- replaced by `RCLike.ofNat_re`
#noalign is_R_or_C.bit0_re
#noalign is_R_or_C.bit1_re
-- replaced by `RCLike.ofNat_im`
#noalign is_R_or_C.bit0_im
#noalign is_R_or_C.bit1_im
theorem ofReal_eq_zero {x : ℝ} : (x : K) = 0 ↔ x = 0 :=
algebraMap.lift_map_eq_zero_iff x
#align is_R_or_C.of_real_eq_zero RCLike.ofReal_eq_zero
theorem ofReal_ne_zero {x : ℝ} : (x : K) ≠ 0 ↔ x ≠ 0 :=
ofReal_eq_zero.not
#align is_R_or_C.of_real_ne_zero RCLike.ofReal_ne_zero
@[simp, rclike_simps, norm_cast]
theorem ofReal_add (r s : ℝ) : ((r + s : ℝ) : K) = r + s :=
algebraMap.coe_add _ _
#align is_R_or_C.of_real_add RCLike.ofReal_add
-- replaced by `RCLike.ofReal_ofNat`
#noalign is_R_or_C.of_real_bit0
#noalign is_R_or_C.of_real_bit1
@[simp, norm_cast, rclike_simps]
theorem ofReal_neg (r : ℝ) : ((-r : ℝ) : K) = -r :=
algebraMap.coe_neg r
#align is_R_or_C.of_real_neg RCLike.ofReal_neg
@[simp, norm_cast, rclike_simps]
theorem ofReal_sub (r s : ℝ) : ((r - s : ℝ) : K) = r - s :=
map_sub (algebraMap ℝ K) r s
#align is_R_or_C.of_real_sub RCLike.ofReal_sub
@[simp, rclike_simps, norm_cast]
theorem ofReal_sum {α : Type*} (s : Finset α) (f : α → ℝ) :
((∑ i ∈ s, f i : ℝ) : K) = ∑ i ∈ s, (f i : K) :=
map_sum (algebraMap ℝ K) _ _
#align is_R_or_C.of_real_sum RCLike.ofReal_sum
@[simp, rclike_simps, norm_cast]
theorem ofReal_finsupp_sum {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) :
((f.sum fun a b => g a b : ℝ) : K) = f.sum fun a b => (g a b : K) :=
map_finsupp_sum (algebraMap ℝ K) f g
#align is_R_or_C.of_real_finsupp_sum RCLike.ofReal_finsupp_sum
@[simp, norm_cast, rclike_simps]
theorem ofReal_mul (r s : ℝ) : ((r * s : ℝ) : K) = r * s :=
algebraMap.coe_mul _ _
#align is_R_or_C.of_real_mul RCLike.ofReal_mul
@[simp, norm_cast, rclike_simps]
theorem ofReal_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : K) = (r : K) ^ n :=
map_pow (algebraMap ℝ K) r n
#align is_R_or_C.of_real_pow RCLike.ofReal_pow
@[simp, rclike_simps, norm_cast]
theorem ofReal_prod {α : Type*} (s : Finset α) (f : α → ℝ) :
((∏ i ∈ s, f i : ℝ) : K) = ∏ i ∈ s, (f i : K) :=
map_prod (algebraMap ℝ K) _ _
#align is_R_or_C.of_real_prod RCLike.ofReal_prod
@[simp, rclike_simps, norm_cast]
theorem ofReal_finsupp_prod {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) :
((f.prod fun a b => g a b : ℝ) : K) = f.prod fun a b => (g a b : K) :=
map_finsupp_prod _ f g
#align is_R_or_C.of_real_finsupp_prod RCLike.ofReal_finsupp_prod
@[simp, norm_cast, rclike_simps]
theorem real_smul_ofReal (r x : ℝ) : r • (x : K) = (r : K) * (x : K) :=
real_smul_eq_coe_mul _ _
#align is_R_or_C.real_smul_of_real RCLike.real_smul_ofReal
@[rclike_simps]
theorem re_ofReal_mul (r : ℝ) (z : K) : re (↑r * z) = r * re z := by
simp only [mul_re, ofReal_im, zero_mul, ofReal_re, sub_zero]
#align is_R_or_C.of_real_mul_re RCLike.re_ofReal_mul
@[rclike_simps]
theorem im_ofReal_mul (r : ℝ) (z : K) : im (↑r * z) = r * im z := by
simp only [add_zero, ofReal_im, zero_mul, ofReal_re, mul_im]
#align is_R_or_C.of_real_mul_im RCLike.im_ofReal_mul
@[rclike_simps]
theorem smul_re (r : ℝ) (z : K) : re (r • z) = r * re z := by
rw [real_smul_eq_coe_mul, re_ofReal_mul]
#align is_R_or_C.smul_re RCLike.smul_re
@[rclike_simps]
theorem smul_im (r : ℝ) (z : K) : im (r • z) = r * im z := by
rw [real_smul_eq_coe_mul, im_ofReal_mul]
#align is_R_or_C.smul_im RCLike.smul_im
@[simp, norm_cast, rclike_simps]
theorem norm_ofReal (r : ℝ) : ‖(r : K)‖ = |r| :=
norm_algebraMap' K r
#align is_R_or_C.norm_of_real RCLike.norm_ofReal
-- see Note [lower instance priority]
instance (priority := 100) charZero_rclike : CharZero K :=
(RingHom.charZero_iff (algebraMap ℝ K).injective).1 inferInstance
set_option linter.uppercaseLean3 false in
#align is_R_or_C.char_zero_R_or_C RCLike.charZero_rclike
@[simp, rclike_simps]
theorem I_re : re (I : K) = 0 :=
I_re_ax
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_re RCLike.I_re
@[simp, rclike_simps]
theorem I_im (z : K) : im z * im (I : K) = im z :=
mul_im_I_ax z
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_im RCLike.I_im
@[simp, rclike_simps]
theorem I_im' (z : K) : im (I : K) * im z = im z := by rw [mul_comm, I_im]
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_im' RCLike.I_im'
@[rclike_simps] -- porting note (#10618): was `simp`
theorem I_mul_re (z : K) : re (I * z) = -im z := by
simp only [I_re, zero_sub, I_im', zero_mul, mul_re]
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_mul_re RCLike.I_mul_re
theorem I_mul_I : (I : K) = 0 ∨ (I : K) * I = -1 :=
I_mul_I_ax
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_mul_I RCLike.I_mul_I
variable (𝕜) in
lemma I_eq_zero_or_im_I_eq_one : (I : K) = 0 ∨ im (I : K) = 1 :=
I_mul_I (K := K) |>.imp_right fun h ↦ by simpa [h] using (I_mul_re (I : K)).symm
@[simp, rclike_simps]
theorem conj_re (z : K) : re (conj z) = re z :=
RCLike.conj_re_ax z
#align is_R_or_C.conj_re RCLike.conj_re
@[simp, rclike_simps]
theorem conj_im (z : K) : im (conj z) = -im z :=
RCLike.conj_im_ax z
#align is_R_or_C.conj_im RCLike.conj_im
@[simp, rclike_simps]
theorem conj_I : conj (I : K) = -I :=
RCLike.conj_I_ax
set_option linter.uppercaseLean3 false in
#align is_R_or_C.conj_I RCLike.conj_I
@[simp, rclike_simps]
theorem conj_ofReal (r : ℝ) : conj (r : K) = (r : K) := by
rw [ext_iff]
simp only [ofReal_im, conj_im, eq_self_iff_true, conj_re, and_self_iff, neg_zero]
#align is_R_or_C.conj_of_real RCLike.conj_ofReal
-- replaced by `RCLike.conj_ofNat`
#noalign is_R_or_C.conj_bit0
#noalign is_R_or_C.conj_bit1
theorem conj_nat_cast (n : ℕ) : conj (n : K) = n := map_natCast _ _
-- See note [no_index around OfNat.ofNat]
theorem conj_ofNat (n : ℕ) [n.AtLeastTwo] : conj (no_index (OfNat.ofNat n : K)) = OfNat.ofNat n :=
map_ofNat _ _
@[rclike_simps] -- Porting note (#10618): was a `simp` but `simp` can prove it
theorem conj_neg_I : conj (-I) = (I : K) := by rw [map_neg, conj_I, neg_neg]
set_option linter.uppercaseLean3 false in
#align is_R_or_C.conj_neg_I RCLike.conj_neg_I
theorem conj_eq_re_sub_im (z : K) : conj z = re z - im z * I :=
(congr_arg conj (re_add_im z).symm).trans <| by
rw [map_add, map_mul, conj_I, conj_ofReal, conj_ofReal, mul_neg, sub_eq_add_neg]
#align is_R_or_C.conj_eq_re_sub_im RCLike.conj_eq_re_sub_im
theorem sub_conj (z : K) : z - conj z = 2 * im z * I :=
calc
z - conj z = re z + im z * I - (re z - im z * I) := by rw [re_add_im, ← conj_eq_re_sub_im]
_ = 2 * im z * I := by rw [add_sub_sub_cancel, ← two_mul, mul_assoc]
#align is_R_or_C.sub_conj RCLike.sub_conj
@[rclike_simps]
theorem conj_smul (r : ℝ) (z : K) : conj (r • z) = r • conj z := by
rw [conj_eq_re_sub_im, conj_eq_re_sub_im, smul_re, smul_im, ofReal_mul, ofReal_mul,
real_smul_eq_coe_mul r (_ - _), mul_sub, mul_assoc]
#align is_R_or_C.conj_smul RCLike.conj_smul
theorem add_conj (z : K) : z + conj z = 2 * re z :=
calc
z + conj z = re z + im z * I + (re z - im z * I) := by rw [re_add_im, conj_eq_re_sub_im]
_ = 2 * re z := by rw [add_add_sub_cancel, two_mul]
#align is_R_or_C.add_conj RCLike.add_conj
theorem re_eq_add_conj (z : K) : ↑(re z) = (z + conj z) / 2 := by
rw [add_conj, mul_div_cancel_left₀ (re z : K) two_ne_zero]
#align is_R_or_C.re_eq_add_conj RCLike.re_eq_add_conj
theorem im_eq_conj_sub (z : K) : ↑(im z) = I * (conj z - z) / 2 := by
rw [← neg_inj, ← ofReal_neg, ← I_mul_re, re_eq_add_conj, map_mul, conj_I, ← neg_div, ← mul_neg,
neg_sub, mul_sub, neg_mul, sub_eq_add_neg]
#align is_R_or_C.im_eq_conj_sub RCLike.im_eq_conj_sub
open List in
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
tfae_have 1 → 4
· intro h
rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
ofReal_zero]
tfae_have 4 → 3
· intro h
conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
tfae_have 3 → 2
· exact fun h => ⟨_, h⟩
tfae_have 2 → 1
· exact fun ⟨r, hr⟩ => hr ▸ conj_ofReal _
tfae_finish
#align is_R_or_C.is_real_tfae RCLike.is_real_TFAE
theorem conj_eq_iff_real {z : K} : conj z = z ↔ ∃ r : ℝ, z = (r : K) :=
((is_real_TFAE z).out 0 1).trans <| by simp only [eq_comm]
#align is_R_or_C.conj_eq_iff_real RCLike.conj_eq_iff_real
theorem conj_eq_iff_re {z : K} : conj z = z ↔ (re z : K) = z :=
(is_real_TFAE z).out 0 2
#align is_R_or_C.conj_eq_iff_re RCLike.conj_eq_iff_re
theorem conj_eq_iff_im {z : K} : conj z = z ↔ im z = 0 :=
(is_real_TFAE z).out 0 3
#align is_R_or_C.conj_eq_iff_im RCLike.conj_eq_iff_im
@[simp]
theorem star_def : (Star.star : K → K) = conj :=
rfl
#align is_R_or_C.star_def RCLike.star_def
variable (K)
abbrev conjToRingEquiv : K ≃+* Kᵐᵒᵖ :=
starRingEquiv
#align is_R_or_C.conj_to_ring_equiv RCLike.conjToRingEquiv
variable {K} {z : K}
def normSq : K →*₀ ℝ where
toFun z := re z * re z + im z * im z
map_zero' := by simp only [add_zero, mul_zero, map_zero]
map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero]
map_mul' z w := by
simp only [mul_im, mul_re]
ring
#align is_R_or_C.norm_sq RCLike.normSq
theorem normSq_apply (z : K) : normSq z = re z * re z + im z * im z :=
rfl
#align is_R_or_C.norm_sq_apply RCLike.normSq_apply
theorem norm_sq_eq_def {z : K} : ‖z‖ ^ 2 = re z * re z + im z * im z :=
norm_sq_eq_def_ax z
#align is_R_or_C.norm_sq_eq_def RCLike.norm_sq_eq_def
theorem normSq_eq_def' (z : K) : normSq z = ‖z‖ ^ 2 :=
norm_sq_eq_def.symm
#align is_R_or_C.norm_sq_eq_def' RCLike.normSq_eq_def'
@[rclike_simps]
theorem normSq_zero : normSq (0 : K) = 0 :=
normSq.map_zero
#align is_R_or_C.norm_sq_zero RCLike.normSq_zero
@[rclike_simps]
theorem normSq_one : normSq (1 : K) = 1 :=
normSq.map_one
#align is_R_or_C.norm_sq_one RCLike.normSq_one
theorem normSq_nonneg (z : K) : 0 ≤ normSq z :=
add_nonneg (mul_self_nonneg _) (mul_self_nonneg _)
#align is_R_or_C.norm_sq_nonneg RCLike.normSq_nonneg
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_eq_zero {z : K} : normSq z = 0 ↔ z = 0 :=
map_eq_zero _
#align is_R_or_C.norm_sq_eq_zero RCLike.normSq_eq_zero
@[simp, rclike_simps]
theorem normSq_pos {z : K} : 0 < normSq z ↔ z ≠ 0 := by
rw [lt_iff_le_and_ne, Ne, eq_comm]; simp [normSq_nonneg]
#align is_R_or_C.norm_sq_pos RCLike.normSq_pos
@[simp, rclike_simps]
theorem normSq_neg (z : K) : normSq (-z) = normSq z := by simp only [normSq_eq_def', norm_neg]
#align is_R_or_C.norm_sq_neg RCLike.normSq_neg
@[simp, rclike_simps]
theorem normSq_conj (z : K) : normSq (conj z) = normSq z := by
simp only [normSq_apply, neg_mul, mul_neg, neg_neg, rclike_simps]
#align is_R_or_C.norm_sq_conj RCLike.normSq_conj
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_mul (z w : K) : normSq (z * w) = normSq z * normSq w :=
map_mul _ z w
#align is_R_or_C.norm_sq_mul RCLike.normSq_mul
theorem normSq_add (z w : K) : normSq (z + w) = normSq z + normSq w + 2 * re (z * conj w) := by
simp only [normSq_apply, map_add, rclike_simps]
ring
#align is_R_or_C.norm_sq_add RCLike.normSq_add
theorem re_sq_le_normSq (z : K) : re z * re z ≤ normSq z :=
le_add_of_nonneg_right (mul_self_nonneg _)
#align is_R_or_C.re_sq_le_norm_sq RCLike.re_sq_le_normSq
theorem im_sq_le_normSq (z : K) : im z * im z ≤ normSq z :=
le_add_of_nonneg_left (mul_self_nonneg _)
#align is_R_or_C.im_sq_le_norm_sq RCLike.im_sq_le_normSq
theorem mul_conj (z : K) : z * conj z = ‖z‖ ^ 2 := by
apply ext <;> simp [← ofReal_pow, norm_sq_eq_def, mul_comm]
#align is_R_or_C.mul_conj RCLike.mul_conj
theorem conj_mul (z : K) : conj z * z = ‖z‖ ^ 2 := by rw [mul_comm, mul_conj]
#align is_R_or_C.conj_mul RCLike.conj_mul
lemma inv_eq_conj (hz : ‖z‖ = 1) : z⁻¹ = conj z :=
inv_eq_of_mul_eq_one_left $ by simp_rw [conj_mul, hz, algebraMap.coe_one, one_pow]
theorem normSq_sub (z w : K) : normSq (z - w) = normSq z + normSq w - 2 * re (z * conj w) := by
simp only [normSq_add, sub_eq_add_neg, map_neg, mul_neg, normSq_neg, map_neg]
#align is_R_or_C.norm_sq_sub RCLike.normSq_sub
theorem sqrt_normSq_eq_norm {z : K} : √(normSq z) = ‖z‖ := by
rw [normSq_eq_def', Real.sqrt_sq (norm_nonneg _)]
#align is_R_or_C.sqrt_norm_sq_eq_norm RCLike.sqrt_normSq_eq_norm
@[simp, norm_cast, rclike_simps]
theorem ofReal_inv (r : ℝ) : ((r⁻¹ : ℝ) : K) = (r : K)⁻¹ :=
map_inv₀ _ r
#align is_R_or_C.of_real_inv RCLike.ofReal_inv
theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by
rcases eq_or_ne z 0 with (rfl | h₀)
· simp
· apply inv_eq_of_mul_eq_one_right
rw [← mul_assoc, mul_conj, ofReal_inv, ofReal_pow, mul_inv_cancel]
simpa
#align is_R_or_C.inv_def RCLike.inv_def
@[simp, rclike_simps]
theorem inv_re (z : K) : re z⁻¹ = re z / normSq z := by
rw [inv_def, normSq_eq_def', mul_comm, re_ofReal_mul, conj_re, div_eq_inv_mul]
#align is_R_or_C.inv_re RCLike.inv_re
@[simp, rclike_simps]
theorem inv_im (z : K) : im z⁻¹ = -im z / normSq z := by
rw [inv_def, normSq_eq_def', mul_comm, im_ofReal_mul, conj_im, div_eq_inv_mul]
#align is_R_or_C.inv_im RCLike.inv_im
theorem div_re (z w : K) : re (z / w) = re z * re w / normSq w + im z * im w / normSq w := by
simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, neg_mul, mul_neg, neg_neg, map_neg,
rclike_simps]
#align is_R_or_C.div_re RCLike.div_re
theorem div_im (z w : K) : im (z / w) = im z * re w / normSq w - re z * im w / normSq w := by
simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm, neg_mul, mul_neg, map_neg,
rclike_simps]
#align is_R_or_C.div_im RCLike.div_im
@[rclike_simps] -- porting note (#10618): was `simp`
theorem conj_inv (x : K) : conj x⁻¹ = (conj x)⁻¹ :=
star_inv' _
#align is_R_or_C.conj_inv RCLike.conj_inv
lemma conj_div (x y : K) : conj (x / y) = conj x / conj y := map_div' conj conj_inv _ _
--TODO: Do we rather want the map as an explicit definition?
lemma exists_norm_eq_mul_self (x : K) : ∃ c, ‖c‖ = 1 ∧ ↑‖x‖ = c * x := by
obtain rfl | hx := eq_or_ne x 0
· exact ⟨1, by simp⟩
· exact ⟨‖x‖ / x, by simp [norm_ne_zero_iff.2, hx]⟩
lemma exists_norm_mul_eq_self (x : K) : ∃ c, ‖c‖ = 1 ∧ c * ‖x‖ = x := by
obtain rfl | hx := eq_or_ne x 0
· exact ⟨1, by simp⟩
· exact ⟨x / ‖x‖, by simp [norm_ne_zero_iff.2, hx]⟩
@[simp, norm_cast, rclike_simps]
theorem ofReal_div (r s : ℝ) : ((r / s : ℝ) : K) = r / s :=
map_div₀ (algebraMap ℝ K) r s
#align is_R_or_C.of_real_div RCLike.ofReal_div
theorem div_re_ofReal {z : K} {r : ℝ} : re (z / r) = re z / r := by
rw [div_eq_inv_mul, div_eq_inv_mul, ← ofReal_inv, re_ofReal_mul]
#align is_R_or_C.div_re_of_real RCLike.div_re_ofReal
@[simp, norm_cast, rclike_simps]
theorem ofReal_zpow (r : ℝ) (n : ℤ) : ((r ^ n : ℝ) : K) = (r : K) ^ n :=
map_zpow₀ (algebraMap ℝ K) r n
#align is_R_or_C.of_real_zpow RCLike.ofReal_zpow
theorem I_mul_I_of_nonzero : (I : K) ≠ 0 → (I : K) * I = -1 :=
I_mul_I_ax.resolve_left
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_mul_I_of_nonzero RCLike.I_mul_I_of_nonzero
@[simp, rclike_simps]
theorem inv_I : (I : K)⁻¹ = -I := by
by_cases h : (I : K) = 0
· simp [h]
· field_simp [I_mul_I_of_nonzero h]
set_option linter.uppercaseLean3 false in
#align is_R_or_C.inv_I RCLike.inv_I
@[simp, rclike_simps]
theorem div_I (z : K) : z / I = -(z * I) := by rw [div_eq_mul_inv, inv_I, mul_neg]
set_option linter.uppercaseLean3 false in
#align is_R_or_C.div_I RCLike.div_I
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_inv (z : K) : normSq z⁻¹ = (normSq z)⁻¹ :=
map_inv₀ normSq z
#align is_R_or_C.norm_sq_inv RCLike.normSq_inv
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_div (z w : K) : normSq (z / w) = normSq z / normSq w :=
map_div₀ normSq z w
#align is_R_or_C.norm_sq_div RCLike.normSq_div
@[rclike_simps] -- porting note (#10618): was `simp`
theorem norm_conj {z : K} : ‖conj z‖ = ‖z‖ := by simp only [← sqrt_normSq_eq_norm, normSq_conj]
#align is_R_or_C.norm_conj RCLike.norm_conj
instance (priority := 100) : CstarRing K where
norm_star_mul_self {x} := (norm_mul _ _).trans <| congr_arg (· * ‖x‖) norm_conj
@[simp, rclike_simps, norm_cast]
theorem ofReal_natCast (n : ℕ) : ((n : ℝ) : K) = n :=
map_natCast (algebraMap ℝ K) n
#align is_R_or_C.of_real_nat_cast RCLike.ofReal_natCast
@[simp, rclike_simps] -- Porting note: removed `norm_cast`
theorem natCast_re (n : ℕ) : re (n : K) = n := by rw [← ofReal_natCast, ofReal_re]
#align is_R_or_C.nat_cast_re RCLike.natCast_re
@[simp, rclike_simps, norm_cast]
theorem natCast_im (n : ℕ) : im (n : K) = 0 := by rw [← ofReal_natCast, ofReal_im]
#align is_R_or_C.nat_cast_im RCLike.natCast_im
-- See note [no_index around OfNat.ofNat]
@[simp, rclike_simps]
theorem ofNat_re (n : ℕ) [n.AtLeastTwo] : re (no_index (OfNat.ofNat n) : K) = OfNat.ofNat n :=
natCast_re n
-- See note [no_index around OfNat.ofNat]
@[simp, rclike_simps]
theorem ofNat_im (n : ℕ) [n.AtLeastTwo] : im (no_index (OfNat.ofNat n) : K) = 0 :=
natCast_im n
-- See note [no_index around OfNat.ofNat]
@[simp, rclike_simps, norm_cast]
theorem ofReal_ofNat (n : ℕ) [n.AtLeastTwo] :
((no_index (OfNat.ofNat n) : ℝ) : K) = OfNat.ofNat n :=
ofReal_natCast n
theorem ofNat_mul_re (n : ℕ) [n.AtLeastTwo] (z : K) :
re (OfNat.ofNat n * z) = OfNat.ofNat n * re z := by
rw [← ofReal_ofNat, re_ofReal_mul]
| Mathlib/Analysis/RCLike/Basic.lean | 662 | 664 | theorem ofNat_mul_im (n : ℕ) [n.AtLeastTwo] (z : K) :
im (OfNat.ofNat n * z) = OfNat.ofNat n * im z := by |
rw [← ofReal_ofNat, im_ofReal_mul]
|
import Mathlib.NumberTheory.NumberField.Basic
import Mathlib.RingTheory.Localization.NormTrace
#align_import number_theory.number_field.norm from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a"
open scoped NumberField
open Finset NumberField Algebra FiniteDimensional
namespace RingOfIntegers
variable {L : Type*} (K : Type*) [Field K] [Field L] [Algebra K L] [FiniteDimensional K L]
noncomputable def norm [IsSeparable K L] : 𝓞 L →* 𝓞 K :=
RingOfIntegers.restrict_monoidHom
((Algebra.norm K).comp (algebraMap (𝓞 L) L : (𝓞 L) →* L))
fun x => isIntegral_norm K x.2
#align ring_of_integers.norm RingOfIntegers.norm
@[simp] lemma coe_norm [IsSeparable K L] (x : 𝓞 L) :
norm K x = Algebra.norm K (x : L) := rfl
theorem coe_algebraMap_norm [IsSeparable K L] (x : 𝓞 L) :
(algebraMap (𝓞 K) (𝓞 L) (norm K x) : L) = algebraMap K L (Algebra.norm K (x : L)) :=
rfl
#align ring_of_integers.coe_algebra_map_norm RingOfIntegers.coe_algebraMap_norm
theorem algebraMap_norm_algebraMap [IsSeparable K L] (x : 𝓞 K) :
algebraMap _ K (norm K (algebraMap (𝓞 K) (𝓞 L) x)) =
Algebra.norm K (algebraMap K L (algebraMap _ _ x)) := rfl
#align ring_of_integers.coe_norm_algebra_map RingOfIntegers.algebraMap_norm_algebraMap
theorem norm_algebraMap [IsSeparable K L] (x : 𝓞 K) :
norm K (algebraMap (𝓞 K) (𝓞 L) x) = x ^ finrank K L := by
rw [RingOfIntegers.ext_iff, RingOfIntegers.coe_eq_algebraMap,
RingOfIntegers.algebraMap_norm_algebraMap, Algebra.norm_algebraMap,
RingOfIntegers.coe_eq_algebraMap, map_pow]
#align ring_of_integers.norm_algebra_map RingOfIntegers.norm_algebraMap
theorem isUnit_norm_of_isGalois [IsGalois K L] {x : 𝓞 L} : IsUnit (norm K x) ↔ IsUnit x := by
classical
refine ⟨fun hx => ?_, IsUnit.map _⟩
replace hx : IsUnit (algebraMap (𝓞 K) (𝓞 L) <| norm K x) := hx.map (algebraMap (𝓞 K) <| 𝓞 L)
refine @isUnit_of_mul_isUnit_right (𝓞 L) _
⟨(univ \ {AlgEquiv.refl}).prod fun σ : L ≃ₐ[K] L => σ x,
prod_mem fun σ _ => x.2.map (σ : L →+* L).toIntAlgHom⟩ _ ?_
convert hx using 1
ext
convert_to ((univ \ {AlgEquiv.refl}).prod fun σ : L ≃ₐ[K] L => σ x) *
∏ σ ∈ {(AlgEquiv.refl : L ≃ₐ[K] L)}, σ x = _
· rw [prod_singleton, AlgEquiv.coe_refl, _root_.id, RingOfIntegers.coe_eq_algebraMap, map_mul,
RingOfIntegers.map_mk]
· rw [prod_sdiff <| subset_univ _, ← norm_eq_prod_automorphisms, coe_algebraMap_norm]
#align ring_of_integers.is_unit_norm_of_is_galois RingOfIntegers.isUnit_norm_of_isGalois
| Mathlib/NumberTheory/NumberField/Norm.lean | 90 | 99 | theorem dvd_norm [IsGalois K L] (x : 𝓞 L) : x ∣ algebraMap (𝓞 K) (𝓞 L) (norm K x) := by |
classical
have hint :
IsIntegral ℤ (∏ σ ∈ univ.erase (AlgEquiv.refl : L ≃ₐ[K] L), σ x) :=
IsIntegral.prod _ (fun σ _ =>
((RingOfIntegers.isIntegral_coe x).map σ))
refine ⟨⟨_, hint⟩, ?_⟩
ext
rw [coe_algebraMap_norm K x, norm_eq_prod_automorphisms]
simp [← Finset.mul_prod_erase _ _ (mem_univ AlgEquiv.refl)]
|
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Algebra.BigOperators.Ring.List
import Mathlib.Data.Int.ModEq
import Mathlib.Data.Nat.Bits
import Mathlib.Data.Nat.Log
import Mathlib.Data.List.Indexes
import Mathlib.Data.List.Palindrome
import Mathlib.Tactic.IntervalCases
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
#align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768"
namespace Nat
variable {n : ℕ}
def digitsAux0 : ℕ → List ℕ
| 0 => []
| n + 1 => [n + 1]
#align nat.digits_aux_0 Nat.digitsAux0
def digitsAux1 (n : ℕ) : List ℕ :=
List.replicate n 1
#align nat.digits_aux_1 Nat.digitsAux1
def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ
| 0 => []
| n + 1 =>
((n + 1) % b) :: digitsAux b h ((n + 1) / b)
decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h
#align nat.digits_aux Nat.digitsAux
@[simp]
theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by rw [digitsAux]
#align nat.digits_aux_zero Nat.digitsAux_zero
theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) :
digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by
cases n
· cases w
· rw [digitsAux]
#align nat.digits_aux_def Nat.digitsAux_def
def digits : ℕ → ℕ → List ℕ
| 0 => digitsAux0
| 1 => digitsAux1
| b + 2 => digitsAux (b + 2) (by norm_num)
#align nat.digits Nat.digits
@[simp]
theorem digits_zero (b : ℕ) : digits b 0 = [] := by
rcases b with (_ | ⟨_ | ⟨_⟩⟩) <;> simp [digits, digitsAux0, digitsAux1]
#align nat.digits_zero Nat.digits_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem digits_zero_zero : digits 0 0 = [] :=
rfl
#align nat.digits_zero_zero Nat.digits_zero_zero
@[simp]
theorem digits_zero_succ (n : ℕ) : digits 0 n.succ = [n + 1] :=
rfl
#align nat.digits_zero_succ Nat.digits_zero_succ
theorem digits_zero_succ' : ∀ {n : ℕ}, n ≠ 0 → digits 0 n = [n]
| 0, h => (h rfl).elim
| _ + 1, _ => rfl
#align nat.digits_zero_succ' Nat.digits_zero_succ'
@[simp]
theorem digits_one (n : ℕ) : digits 1 n = List.replicate n 1 :=
rfl
#align nat.digits_one Nat.digits_one
-- @[simp] -- Porting note (#10685): dsimp can prove this
theorem digits_one_succ (n : ℕ) : digits 1 (n + 1) = 1 :: digits 1 n :=
rfl
#align nat.digits_one_succ Nat.digits_one_succ
theorem digits_add_two_add_one (b n : ℕ) :
digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) := by
simp [digits, digitsAux_def]
#align nat.digits_add_two_add_one Nat.digits_add_two_add_one
@[simp]
lemma digits_of_two_le_of_pos {b : ℕ} (hb : 2 ≤ b) (hn : 0 < n) :
Nat.digits b n = n % b :: Nat.digits b (n / b) := by
rw [Nat.eq_add_of_sub_eq hb rfl, Nat.eq_add_of_sub_eq hn rfl, Nat.digits_add_two_add_one]
theorem digits_def' :
∀ {b : ℕ} (_ : 1 < b) {n : ℕ} (_ : 0 < n), digits b n = (n % b) :: digits b (n / b)
| 0, h => absurd h (by decide)
| 1, h => absurd h (by decide)
| b + 2, _ => digitsAux_def _ (by simp) _
#align nat.digits_def' Nat.digits_def'
@[simp]
theorem digits_of_lt (b x : ℕ) (hx : x ≠ 0) (hxb : x < b) : digits b x = [x] := by
rcases exists_eq_succ_of_ne_zero hx with ⟨x, rfl⟩
rcases Nat.exists_eq_add_of_le' ((Nat.le_add_left 1 x).trans_lt hxb) with ⟨b, rfl⟩
rw [digits_add_two_add_one, div_eq_of_lt hxb, digits_zero, mod_eq_of_lt hxb]
#align nat.digits_of_lt Nat.digits_of_lt
theorem digits_add (b : ℕ) (h : 1 < b) (x y : ℕ) (hxb : x < b) (hxy : x ≠ 0 ∨ y ≠ 0) :
digits b (x + b * y) = x :: digits b y := by
rcases Nat.exists_eq_add_of_le' h with ⟨b, rfl : _ = _ + 2⟩
cases y
· simp [hxb, hxy.resolve_right (absurd rfl)]
dsimp [digits]
rw [digitsAux_def]
· congr
· simp [Nat.add_mod, mod_eq_of_lt hxb]
· simp [add_mul_div_left, div_eq_of_lt hxb]
· apply Nat.succ_pos
#align nat.digits_add Nat.digits_add
-- If we had a function converting a list into a polynomial,
-- and appropriate lemmas about that function,
-- we could rewrite this in terms of that.
def ofDigits {α : Type*} [Semiring α] (b : α) : List ℕ → α
| [] => 0
| h :: t => h + b * ofDigits b t
#align nat.of_digits Nat.ofDigits
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
rw [ih]
#align nat.of_digits_eq_foldr Nat.ofDigits_eq_foldr
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
suffices
(List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
(List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
by simp [this]
congr; ext; simp [pow_succ]; ring
#align nat.of_digits_eq_sum_map_with_index_aux Nat.ofDigits_eq_sum_map_with_index_aux
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
ofDigits_eq_foldr]
induction' L with hd tl hl
· simp
· simpa [List.range_succ_eq_map, List.zipWith_map_left, ofDigits_eq_sum_map_with_index_aux] using
Or.inl hl
#align nat.of_digits_eq_sum_map_with_index Nat.ofDigits_eq_sum_mapIdx
@[simp]
theorem ofDigits_nil {b : ℕ} : ofDigits b [] = 0 := rfl
@[simp]
theorem ofDigits_singleton {b n : ℕ} : ofDigits b [n] = n := by simp [ofDigits]
#align nat.of_digits_singleton Nat.ofDigits_singleton
@[simp]
theorem ofDigits_one_cons {α : Type*} [Semiring α] (h : ℕ) (L : List ℕ) :
ofDigits (1 : α) (h :: L) = h + ofDigits 1 L := by simp [ofDigits]
#align nat.of_digits_one_cons Nat.ofDigits_one_cons
theorem ofDigits_cons {b hd} {tl : List ℕ} :
ofDigits b (hd :: tl) = hd + b * ofDigits b tl := rfl
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
induction' l1 with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ']
ring
#align nat.of_digits_append Nat.ofDigits_append
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
induction' L with d L ih
· simp [ofDigits]
· dsimp [ofDigits]; push_cast; rw [ih]
#align nat.coe_of_digits Nat.coe_ofDigits
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
induction' L with d L _
· rfl
· dsimp [ofDigits]; push_cast; simp only
#align nat.coe_int_of_digits Nat.coe_int_ofDigits
theorem digits_zero_of_eq_zero {b : ℕ} (h : b ≠ 0) :
∀ {L : List ℕ} (_ : ofDigits b L = 0), ∀ l ∈ L, l = 0
| _ :: _, h0, _, List.Mem.head .. => Nat.eq_zero_of_add_eq_zero_right h0
| _ :: _, h0, _, List.Mem.tail _ hL =>
digits_zero_of_eq_zero h (mul_right_injective₀ h (Nat.eq_zero_of_add_eq_zero_left h0)) _ hL
#align nat.digits_zero_of_eq_zero Nat.digits_zero_of_eq_zero
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
(w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
induction' L with d L ih
· dsimp [ofDigits]
simp
· dsimp [ofDigits]
replace w₂ := w₂ (by simp)
rw [digits_add b h]
· rw [ih]
· intro l m
apply w₁
exact List.mem_cons_of_mem _ m
· intro h
rw [List.getLast_cons h] at w₂
convert w₂
· exact w₁ d (List.mem_cons_self _ _)
· by_cases h' : L = []
· rcases h' with rfl
left
simpa using w₂
· right
contrapose! w₂
refine digits_zero_of_eq_zero h.ne_bot w₂ _ ?_
rw [List.getLast_cons h']
exact List.getLast_mem h'
#align nat.digits_of_digits Nat.digits_ofDigits
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
cases' b with b
· cases' n with n
· rfl
· change ofDigits 0 [n + 1] = n + 1
dsimp [ofDigits]
· cases' b with b
· induction' n with n ih
· rfl
· rw [Nat.zero_add] at ih ⊢
simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
· apply Nat.strongInductionOn n _
clear n
intro n h
cases n
· rw [digits_zero]
rfl
· simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
dsimp [ofDigits]
rw [h _ (Nat.div_lt_self' _ b)]
rw [Nat.mod_add_div]
#align nat.of_digits_digits Nat.ofDigits_digits
theorem ofDigits_one (L : List ℕ) : ofDigits 1 L = L.sum := by
induction' L with _ _ ih
· rfl
· simp [ofDigits, List.sum_cons, ih]
#align nat.of_digits_one Nat.ofDigits_one
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
constructor
· intro h
have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
convert this
rw [ofDigits_digits]
· rintro rfl
simp
#align nat.digits_eq_nil_iff_eq_zero Nat.digits_eq_nil_iff_eq_zero
theorem digits_ne_nil_iff_ne_zero {b n : ℕ} : digits b n ≠ [] ↔ n ≠ 0 :=
not_congr digits_eq_nil_iff_eq_zero
#align nat.digits_ne_nil_iff_ne_zero Nat.digits_ne_nil_iff_ne_zero
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
digits b n = (n % b) :: digits b (n / b) := by
rcases b with (_ | _ | b)
· rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
· norm_num at h
rcases n with (_ | n)
· norm_num at w
· simp only [digits_add_two_add_one, ne_eq]
#align nat.digits_eq_cons_digits_div Nat.digits_eq_cons_digits_div
theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
(digits b m).getLast p = (digits b (m / b)).getLast q := by
by_cases hm : m = 0
· simp [hm]
simp only [digits_eq_cons_digits_div h hm]
rw [List.getLast_cons]
#align nat.digits_last Nat.digits_getLast
theorem digits.injective (b : ℕ) : Function.Injective b.digits :=
Function.LeftInverse.injective (ofDigits_digits b)
#align nat.digits.injective Nat.digits.injective
@[simp]
theorem digits_inj_iff {b n m : ℕ} : b.digits n = b.digits m ↔ n = m :=
(digits.injective b).eq_iff
#align nat.digits_inj_iff Nat.digits_inj_iff
theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 := by
induction' n using Nat.strong_induction_on with n IH
rw [digits_eq_cons_digits_div hb hn, List.length]
by_cases h : n / b = 0
· have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
· have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
rw [IH _ this h, log_div_base, tsub_add_cancel_of_le]
refine Nat.succ_le_of_lt (log_pos hb ?_)
contrapose! h
exact div_eq_of_lt h
#align nat.digits_len Nat.digits_len
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
(digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
rcases b with (_ | _ | b)
· cases m
· cases hm rfl
· simp
· cases m
· cases hm rfl
rename ℕ => m
simp only [zero_add, digits_one, List.getLast_replicate_succ m 1]
exact Nat.one_ne_zero
revert hm
apply Nat.strongInductionOn m
intro n IH hn
by_cases hnb : n < b + 2
· simpa only [digits_of_lt (b + 2) n hn hnb]
· rw [digits_getLast n (le_add_left 2 b)]
refine IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) ?_
rw [← pos_iff_ne_zero]
exact Nat.div_pos (le_of_not_lt hnb) (zero_lt_succ (succ b))
#align nat.last_digit_ne_zero Nat.getLast_digit_ne_zero
theorem mul_ofDigits (n : ℕ) {b : ℕ} {l : List ℕ} :
n * ofDigits b l = ofDigits b (l.map (n * ·)) := by
induction l with
| nil => rfl
| cons hd tl ih =>
rw [List.map_cons, ofDigits_cons, ofDigits_cons, ← ih]
ring
theorem ofDigits_add_ofDigits_eq_ofDigits_zipWith_of_length_eq {b : ℕ} {l1 l2 : List ℕ}
(h : l1.length = l2.length) :
ofDigits b l1 + ofDigits b l2 = ofDigits b (l1.zipWith (· + ·) l2) := by
induction l1 generalizing l2 with
| nil => simp_all [eq_comm, List.length_eq_zero, ofDigits]
| cons hd₁ tl₁ ih₁ =>
induction l2 generalizing tl₁ with
| nil => simp_all
| cons hd₂ tl₂ ih₂ =>
simp_all only [List.length_cons, succ_eq_add_one, ofDigits_cons, add_left_inj,
eq_comm, List.zipWith_cons_cons, add_eq]
rw [← ih₁ h.symm, mul_add]
ac_rfl
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
apply Nat.strongInductionOn m
intro n IH d hd
cases' n with n
· rw [digits_zero] at hd
cases hd
-- base b+2 expansion of 0 has no digits
rw [digits_add_two_add_one] at hd
cases hd
· exact n.succ.mod_lt (by simp)
-- Porting note: Previous code (single line) contained linarith.
-- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd
· apply IH ((n + 1) / (b + 2))
· apply Nat.div_lt_self <;> omega
· assumption
#align nat.digits_lt_base' Nat.digits_lt_base'
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
rcases b with (_ | _ | b) <;> try simp_all
exact digits_lt_base' hd
#align nat.digits_lt_base Nat.digits_lt_base
theorem ofDigits_lt_base_pow_length' {b : ℕ} {l : List ℕ} (hl : ∀ x ∈ l, x < b + 2) :
ofDigits (b + 2) l < (b + 2) ^ l.length := by
induction' l with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.length_cons, pow_succ]
have : (ofDigits (b + 2) tl + 1) * (b + 2) ≤ (b + 2) ^ tl.length * (b + 2) :=
mul_le_mul (IH fun x hx => hl _ (List.mem_cons_of_mem _ hx)) (by rfl) (by simp only [zero_le])
(Nat.zero_le _)
suffices ↑hd < b + 2 by linarith
exact hl hd (List.mem_cons_self _ _)
#align nat.of_digits_lt_base_pow_length' Nat.ofDigits_lt_base_pow_length'
theorem ofDigits_lt_base_pow_length {b : ℕ} {l : List ℕ} (hb : 1 < b) (hl : ∀ x ∈ l, x < b) :
ofDigits b l < b ^ l.length := by
rcases b with (_ | _ | b) <;> try simp_all
exact ofDigits_lt_base_pow_length' hl
#align nat.of_digits_lt_base_pow_length Nat.ofDigits_lt_base_pow_length
theorem lt_base_pow_length_digits' {b m : ℕ} : m < (b + 2) ^ (digits (b + 2) m).length := by
convert @ofDigits_lt_base_pow_length' b (digits (b + 2) m) fun _ => digits_lt_base'
rw [ofDigits_digits (b + 2) m]
#align nat.lt_base_pow_length_digits' Nat.lt_base_pow_length_digits'
theorem lt_base_pow_length_digits {b m : ℕ} (hb : 1 < b) : m < b ^ (digits b m).length := by
rcases b with (_ | _ | b) <;> try simp_all
exact lt_base_pow_length_digits'
#align nat.lt_base_pow_length_digits Nat.lt_base_pow_length_digits
theorem ofDigits_digits_append_digits {b m n : ℕ} :
ofDigits b (digits b n ++ digits b m) = n + b ^ (digits b n).length * m := by
rw [ofDigits_append, ofDigits_digits, ofDigits_digits]
#align nat.of_digits_digits_append_digits Nat.ofDigits_digits_append_digits
theorem digits_append_digits {b m n : ℕ} (hb : 0 < b) :
digits b n ++ digits b m = digits b (n + b ^ (digits b n).length * m) := by
rcases eq_or_lt_of_le (Nat.succ_le_of_lt hb) with (rfl | hb)
· simp [List.replicate_add]
rw [← ofDigits_digits_append_digits]
refine (digits_ofDigits b hb _ (fun l hl => ?_) (fun h_append => ?_)).symm
· rcases (List.mem_append.mp hl) with (h | h) <;> exact digits_lt_base hb h
· by_cases h : digits b m = []
· simp only [h, List.append_nil] at h_append ⊢
exact getLast_digit_ne_zero b <| digits_ne_nil_iff_ne_zero.mp h_append
· exact (List.getLast_append' _ _ h) ▸
(getLast_digit_ne_zero _ <| digits_ne_nil_iff_ne_zero.mp h)
theorem digits_len_le_digits_len_succ (b n : ℕ) :
(digits b n).length ≤ (digits b (n + 1)).length := by
rcases Decidable.eq_or_ne n 0 with (rfl | hn)
· simp
rcases le_or_lt b 1 with hb | hb
· interval_cases b <;> simp_arith [digits_zero_succ', hn]
simpa [digits_len, hb, hn] using log_mono_right (le_succ _)
#align nat.digits_len_le_digits_len_succ Nat.digits_len_le_digits_len_succ
theorem le_digits_len_le (b n m : ℕ) (h : n ≤ m) : (digits b n).length ≤ (digits b m).length :=
monotone_nat_of_le_succ (digits_len_le_digits_len_succ b) h
#align nat.le_digits_len_le Nat.le_digits_len_le
@[mono]
theorem ofDigits_monotone {p q : ℕ} (L : List ℕ) (h : p ≤ q) : ofDigits p L ≤ ofDigits q L := by
induction' L with _ _ hi
· rfl
· simp only [ofDigits, cast_id, add_le_add_iff_left]
exact Nat.mul_le_mul h hi
theorem sum_le_ofDigits {p : ℕ} (L : List ℕ) (h : 1 ≤ p) : L.sum ≤ ofDigits p L :=
(ofDigits_one L).symm ▸ ofDigits_monotone L h
theorem digit_sum_le (p n : ℕ) : List.sum (digits p n) ≤ n := by
induction' n with n
· exact digits_zero _ ▸ Nat.le_refl (List.sum [])
· induction' p with p
· rw [digits_zero_succ, List.sum_cons, List.sum_nil, add_zero]
· nth_rw 2 [← ofDigits_digits p.succ (n + 1)]
rw [← ofDigits_one <| digits p.succ n.succ]
exact ofDigits_monotone (digits p.succ n.succ) <| Nat.succ_pos p
theorem pow_length_le_mul_ofDigits {b : ℕ} {l : List ℕ} (hl : l ≠ []) (hl2 : l.getLast hl ≠ 0) :
(b + 2) ^ l.length ≤ (b + 2) * ofDigits (b + 2) l := by
rw [← List.dropLast_append_getLast hl]
simp only [List.length_append, List.length, zero_add, List.length_dropLast, ofDigits_append,
List.length_dropLast, ofDigits_singleton, add_comm (l.length - 1), pow_add, pow_one]
apply Nat.mul_le_mul_left
refine le_trans ?_ (Nat.le_add_left _ _)
have : 0 < l.getLast hl := by rwa [pos_iff_ne_zero]
convert Nat.mul_le_mul_left ((b + 2) ^ (l.length - 1)) this using 1
rw [Nat.mul_one]
#align nat.pow_length_le_mul_of_digits Nat.pow_length_le_mul_ofDigits
theorem base_pow_length_digits_le' (b m : ℕ) (hm : m ≠ 0) :
(b + 2) ^ (digits (b + 2) m).length ≤ (b + 2) * m := by
have : digits (b + 2) m ≠ [] := digits_ne_nil_iff_ne_zero.mpr hm
convert @pow_length_le_mul_ofDigits b (digits (b+2) m)
this (getLast_digit_ne_zero _ hm)
rw [ofDigits_digits]
#align nat.base_pow_length_digits_le' Nat.base_pow_length_digits_le'
theorem base_pow_length_digits_le (b m : ℕ) (hb : 1 < b) :
m ≠ 0 → b ^ (digits b m).length ≤ b * m := by
rcases b with (_ | _ | b) <;> try simp_all
exact base_pow_length_digits_le' b m
#align nat.base_pow_length_digits_le Nat.base_pow_length_digits_le
lemma ofDigits_div_eq_ofDigits_tail {p : ℕ} (hpos : 0 < p) (digits : List ℕ)
(w₁ : ∀ l ∈ digits, l < p) : ofDigits p digits / p = ofDigits p digits.tail := by
induction' digits with hd tl
· simp [ofDigits]
· refine Eq.trans (add_mul_div_left hd _ hpos) ?_
rw [Nat.div_eq_of_lt <| w₁ _ <| List.mem_cons_self _ _, zero_add]
rfl
lemma ofDigits_div_pow_eq_ofDigits_drop
{p : ℕ} (i : ℕ) (hpos : 0 < p) (digits : List ℕ) (w₁ : ∀ l ∈ digits, l < p) :
ofDigits p digits / p ^ i = ofDigits p (digits.drop i) := by
induction' i with i hi
· simp
· rw [Nat.pow_succ, ← Nat.div_div_eq_div_mul, hi, ofDigits_div_eq_ofDigits_tail hpos
(List.drop i digits) fun x hx ↦ w₁ x <| List.mem_of_mem_drop hx, ← List.drop_one,
List.drop_drop, add_comm]
lemma self_div_pow_eq_ofDigits_drop {p : ℕ} (i n : ℕ) (h : 2 ≤ p):
n / p ^ i = ofDigits p ((p.digits n).drop i) := by
convert ofDigits_div_pow_eq_ofDigits_drop i (zero_lt_of_lt h) (p.digits n)
(fun l hl ↦ digits_lt_base h hl)
exact (ofDigits_digits p n).symm
open Finset
theorem sub_one_mul_sum_div_pow_eq_sub_sum_digits {p : ℕ}
(L : List ℕ) {h_nonempty} (h_ne_zero : L.getLast h_nonempty ≠ 0) (h_lt : ∀ l ∈ L, l < p) :
(p - 1) * ∑ i ∈ range L.length, (ofDigits p L) / p ^ i.succ = (ofDigits p L) - L.sum := by
obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p
· induction' L with hd tl ih
· simp [ofDigits]
· simp only [List.length_cons, List.sum_cons, self_div_pow_eq_ofDigits_drop _ _ h,
digits_ofDigits p h (hd :: tl) h_lt (fun _ => h_ne_zero)]
simp only [ofDigits]
rw [sum_range_succ, Nat.cast_id]
simp only [List.drop, List.drop_length]
obtain rfl | h' := em <| tl = []
· simp [ofDigits]
· have w₁' := fun l hl ↦ h_lt l <| List.mem_cons_of_mem hd hl
have w₂' := fun (h : tl ≠ []) ↦ (List.getLast_cons h) ▸ h_ne_zero
have ih := ih (w₂' h') w₁'
simp only [self_div_pow_eq_ofDigits_drop _ _ h, digits_ofDigits p h tl w₁' w₂',
← Nat.one_add] at ih
have := sum_singleton (fun x ↦ ofDigits p <| tl.drop x) tl.length
rw [← Ico_succ_singleton, List.drop_length, ofDigits] at this
have h₁ : 1 ≤ tl.length := List.length_pos.mpr h'
rw [← sum_range_add_sum_Ico _ <| h₁, ← add_zero (∑ x ∈ Ico _ _, ofDigits p (tl.drop x)),
← this, sum_Ico_consecutive _ h₁ <| (le_add_right tl.length 1),
← sum_Ico_add _ 0 tl.length 1,
Ico_zero_eq_range, mul_add, mul_add, ih, range_one, sum_singleton, List.drop, ofDigits,
mul_zero, add_zero, ← Nat.add_sub_assoc <| sum_le_ofDigits _ <| Nat.le_of_lt h]
nth_rw 2 [← one_mul <| ofDigits p tl]
rw [← add_mul, one_eq_succ_zero, Nat.sub_add_cancel <| zero_lt_of_lt h,
Nat.add_sub_add_left]
· simp [ofDigits_one]
· simp [lt_one_iff.mp h]
cases L
· rfl
· simp [ofDigits]
theorem sub_one_mul_sum_log_div_pow_eq_sub_sum_digits {p : ℕ} (n : ℕ) :
(p - 1) * ∑ i ∈ range (log p n).succ, n / p ^ i.succ = n - (p.digits n).sum := by
obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p
· rcases eq_or_ne n 0 with rfl | hn
· simp
· convert sub_one_mul_sum_div_pow_eq_sub_sum_digits (p.digits n) (getLast_digit_ne_zero p hn) <|
(fun l a ↦ digits_lt_base h a)
· refine (digits_len p n h hn).symm
all_goals exact (ofDigits_digits p n).symm
· simp
· simp [lt_one_iff.mp h]
cases n
all_goals simp
theorem digits_two_eq_bits (n : ℕ) : digits 2 n = n.bits.map fun b => cond b 1 0 := by
induction' n using Nat.binaryRecFromOne with b n h ih
· simp
· rfl
rw [bits_append_bit _ _ fun hn => absurd hn h]
cases b
· rw [digits_def' one_lt_two]
· simpa [Nat.bit, Nat.bit0_val n]
· simpa [pos_iff_ne_zero, Nat.bit0_eq_zero]
· simpa [Nat.bit, Nat.bit1_val n, add_comm, digits_add 2 one_lt_two 1 n, Nat.add_mul_div_left]
#align nat.digits_two_eq_bits Nat.digits_two_eq_bits
-- This is really a theorem about polynomials.
theorem dvd_ofDigits_sub_ofDigits {α : Type*} [CommRing α] {a b k : α} (h : k ∣ a - b)
(L : List ℕ) : k ∣ ofDigits a L - ofDigits b L := by
induction' L with d L ih
· change k ∣ 0 - 0
simp
· simp only [ofDigits, add_sub_add_left_eq_sub]
exact dvd_mul_sub_mul h ih
#align nat.dvd_of_digits_sub_of_digits Nat.dvd_ofDigits_sub_ofDigits
theorem ofDigits_modEq' (b b' : ℕ) (k : ℕ) (h : b ≡ b' [MOD k]) (L : List ℕ) :
ofDigits b L ≡ ofDigits b' L [MOD k] := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
dsimp [Nat.ModEq] at *
conv_lhs => rw [Nat.add_mod, Nat.mul_mod, h, ih]
conv_rhs => rw [Nat.add_mod, Nat.mul_mod]
#align nat.of_digits_modeq' Nat.ofDigits_modEq'
theorem ofDigits_modEq (b k : ℕ) (L : List ℕ) : ofDigits b L ≡ ofDigits (b % k) L [MOD k] :=
ofDigits_modEq' b (b % k) k (b.mod_modEq k).symm L
#align nat.of_digits_modeq Nat.ofDigits_modEq
theorem ofDigits_mod (b k : ℕ) (L : List ℕ) : ofDigits b L % k = ofDigits (b % k) L % k :=
ofDigits_modEq b k L
#align nat.of_digits_mod Nat.ofDigits_mod
theorem ofDigits_mod_eq_head! (b : ℕ) (l : List ℕ) : ofDigits b l % b = l.head! % b := by
induction l <;> simp [Nat.ofDigits, Int.ModEq]
theorem head!_digits {b n : ℕ} (h : b ≠ 1) : (Nat.digits b n).head! = n % b := by
by_cases hb : 1 < b
· rcases n with _ | n
· simp
· nth_rw 2 [← Nat.ofDigits_digits b (n + 1)]
rw [Nat.ofDigits_mod_eq_head! _ _]
exact (Nat.mod_eq_of_lt (Nat.digits_lt_base hb <| List.head!_mem_self <|
Nat.digits_ne_nil_iff_ne_zero.mpr <| Nat.succ_ne_zero n)).symm
· rcases n with _ | _ <;> simp_all [show b = 0 by omega]
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
dsimp [Int.ModEq] at *
conv_lhs => rw [Int.add_emod, Int.mul_emod, h, ih]
conv_rhs => rw [Int.add_emod, Int.mul_emod]
#align nat.of_digits_zmodeq' Nat.ofDigits_zmodeq'
theorem ofDigits_zmodeq (b : ℤ) (k : ℕ) (L : List ℕ) : ofDigits b L ≡ ofDigits (b % k) L [ZMOD k] :=
ofDigits_zmodeq' b (b % k) k (b.mod_modEq ↑k).symm L
#align nat.of_digits_zmodeq Nat.ofDigits_zmodeq
theorem ofDigits_zmod (b : ℤ) (k : ℕ) (L : List ℕ) : ofDigits b L % k = ofDigits (b % k) L % k :=
ofDigits_zmodeq b k L
#align nat.of_digits_zmod Nat.ofDigits_zmod
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
rw [← ofDigits_one]
conv =>
congr
· skip
· rw [← ofDigits_digits b' n]
convert ofDigits_modEq b' b (digits b' n)
exact h.symm
#align nat.modeq_digits_sum Nat.modEq_digits_sum
theorem modEq_three_digits_sum (n : ℕ) : n ≡ (digits 10 n).sum [MOD 3] :=
modEq_digits_sum 3 10 (by norm_num) n
#align nat.modeq_three_digits_sum Nat.modEq_three_digits_sum
theorem modEq_nine_digits_sum (n : ℕ) : n ≡ (digits 10 n).sum [MOD 9] :=
modEq_digits_sum 9 10 (by norm_num) n
#align nat.modeq_nine_digits_sum Nat.modEq_nine_digits_sum
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
n ≡ ofDigits c (digits b' n) [ZMOD b] := by
conv =>
congr
· skip
· rw [← ofDigits_digits b' n]
rw [coe_int_ofDigits]
apply ofDigits_zmodeq' _ _ _ h
#align nat.zmodeq_of_digits_digits Nat.zmodeq_ofDigits_digits
theorem ofDigits_neg_one :
∀ L : List ℕ, ofDigits (-1 : ℤ) L = (L.map fun n : ℕ => (n : ℤ)).alternatingSum
| [] => rfl
| [n] => by simp [ofDigits, List.alternatingSum]
| a :: b :: t => by
simp only [ofDigits, List.alternatingSum, List.map_cons, ofDigits_neg_one t]
ring
#align nat.of_digits_neg_one Nat.ofDigits_neg_one
theorem modEq_eleven_digits_sum (n : ℕ) :
n ≡ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum [ZMOD 11] := by
have t := zmodeq_ofDigits_digits 11 10 (-1 : ℤ) (by unfold Int.ModEq; rfl) n
rwa [ofDigits_neg_one] at t
#align nat.modeq_eleven_digits_sum Nat.modEq_eleven_digits_sum
theorem dvd_iff_dvd_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) :
b ∣ n ↔ b ∣ (digits b' n).sum := by
rw [← ofDigits_one]
conv_lhs => rw [← ofDigits_digits b' n]
rw [Nat.dvd_iff_mod_eq_zero, Nat.dvd_iff_mod_eq_zero, ofDigits_mod, h]
#align nat.dvd_iff_dvd_digits_sum Nat.dvd_iff_dvd_digits_sum
theorem three_dvd_iff (n : ℕ) : 3 ∣ n ↔ 3 ∣ (digits 10 n).sum :=
dvd_iff_dvd_digits_sum 3 10 (by norm_num) n
#align nat.three_dvd_iff Nat.three_dvd_iff
theorem nine_dvd_iff (n : ℕ) : 9 ∣ n ↔ 9 ∣ (digits 10 n).sum :=
dvd_iff_dvd_digits_sum 9 10 (by norm_num) n
#align nat.nine_dvd_iff Nat.nine_dvd_iff
theorem dvd_iff_dvd_ofDigits (b b' : ℕ) (c : ℤ) (h : (b : ℤ) ∣ (b' : ℤ) - c) (n : ℕ) :
b ∣ n ↔ (b : ℤ) ∣ ofDigits c (digits b' n) := by
rw [← Int.natCast_dvd_natCast]
exact
dvd_iff_dvd_of_dvd_sub (zmodeq_ofDigits_digits b b' c (Int.modEq_iff_dvd.2 h).symm _).symm.dvd
#align nat.dvd_iff_dvd_of_digits Nat.dvd_iff_dvd_ofDigits
theorem eleven_dvd_iff :
11 ∣ n ↔ (11 : ℤ) ∣ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum := by
have t := dvd_iff_dvd_ofDigits 11 10 (-1 : ℤ) (by norm_num) n
rw [ofDigits_neg_one] at t
exact t
#align nat.eleven_dvd_iff Nat.eleven_dvd_iff
theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
11 ∣ n := by
let dig := (digits 10 n).map fun n : ℕ => (n : ℤ)
replace h : Even dig.length := by rwa [List.length_map]
refine eleven_dvd_iff.2 ⟨0, (?_ : dig.alternatingSum = 0)⟩
have := dig.alternatingSum_reverse
rw [(p.map _).reverse_eq, _root_.pow_succ', h.neg_one_pow, mul_one, neg_one_zsmul] at this
exact eq_zero_of_neg_eq this.symm
#align nat.eleven_dvd_of_palindrome Nat.eleven_dvd_of_palindrome
lemma toDigitsCore_lens_eq_aux (b f : Nat) :
∀ (n : Nat) (l1 l2 : List Char), l1.length = l2.length →
(Nat.toDigitsCore b f n l1).length = (Nat.toDigitsCore b f n l2).length := by
induction f with (simp only [Nat.toDigitsCore, List.length]; intro n l1 l2 hlen)
| zero => assumption
| succ f ih =>
if hx : n / b = 0 then
simp only [hx, if_true, List.length, congrArg (fun l ↦ l + 1) hlen]
else
simp only [hx, if_false]
specialize ih (n / b) (Nat.digitChar (n % b) :: l1) (Nat.digitChar (n % b) :: l2)
simp only [List.length, congrArg (fun l ↦ l + 1) hlen] at ih
exact ih trivial
@[deprecated (since := "2024-02-19")] alias to_digits_core_lens_eq_aux:= toDigitsCore_lens_eq_aux
lemma toDigitsCore_lens_eq (b f : Nat) : ∀ (n : Nat) (c : Char) (tl : List Char),
(Nat.toDigitsCore b f n (c :: tl)).length = (Nat.toDigitsCore b f n tl).length + 1 := by
induction f with (intro n c tl; simp only [Nat.toDigitsCore, List.length])
| succ f ih =>
if hnb : (n / b) = 0 then
simp only [hnb, if_true, List.length]
else
generalize hx: Nat.digitChar (n % b) = x
simp only [hx, hnb, if_false] at ih
simp only [hnb, if_false]
specialize ih (n / b) c (x :: tl)
rw [← ih]
have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
apply toDigitsCore_lens_eq_aux
exact lens_eq
@[deprecated (since := "2024-02-19")] alias to_digits_core_lens_eq:= toDigitsCore_lens_eq
lemma nat_repr_len_aux (n b e : Nat) (h_b_pos : 0 < b) : n < b ^ e.succ → n / b < b ^ e := by
simp only [Nat.pow_succ]
exact (@Nat.div_lt_iff_lt_mul b n (b ^ e) h_b_pos).mpr
lemma toDigitsCore_length (b : Nat) (h : 2 <= b) (f n e : Nat)
(hlt : n < b ^ e) (h_e_pos: 0 < e) : (Nat.toDigitsCore b f n []).length <= e := by
induction f generalizing n e hlt h_e_pos with
simp only [Nat.toDigitsCore, List.length, Nat.zero_le]
| succ f ih =>
cases e with
| zero => exact False.elim (Nat.lt_irrefl 0 h_e_pos)
| succ e =>
if h_pred_pos : 0 < e then
have _ : 0 < b := Nat.lt_trans (by decide) h
specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
if hdiv_ten : n / b = 0 then
simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
else
simp only [hdiv_ten,
toDigitsCore_lens_eq b f (n / b) (Nat.digitChar <| n % b), if_false]
exact Nat.succ_le_succ ih
else
obtain rfl : e = 0 := Nat.eq_zero_of_not_pos h_pred_pos
have _ : b ^ 1 = b := by simp only [Nat.pow_succ, pow_zero, Nat.one_mul]
have _ : n < b := ‹b ^ 1 = b› ▸ hlt
simp [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0)]
@[deprecated (since := "2024-02-19")] alias to_digits_core_length := toDigitsCore_length
lemma repr_length (n e : Nat) : 0 < e → n < 10 ^ e → (Nat.repr n).length <= e := by
cases n with
(intro e0 he; simp only [Nat.repr, Nat.toDigits, String.length, List.asString])
| zero => assumption
| succ n =>
if hterm : n.succ / 10 = 0 then
simp only [hterm, Nat.toDigitsCore]; assumption
else
exact toDigitsCore_length 10 (by decide) (Nat.succ n + 1) (Nat.succ n) e he e0
namespace NormDigits
theorem digits_succ (b n m r l) (e : r + b * m = n) (hr : r < b)
(h : Nat.digits b m = l ∧ 1 < b ∧ 0 < m) : (Nat.digits b n = r :: l) ∧ 1 < b ∧ 0 < n := by
rcases h with ⟨h, b2, m0⟩
have b0 : 0 < b := by omega
have n0 : 0 < n := by linarith [mul_pos b0 m0]
refine ⟨?_, b2, n0⟩
obtain ⟨rfl, rfl⟩ := (Nat.div_mod_unique b0).2 ⟨e, hr⟩
subst h; exact Nat.digits_def' b2 n0
#align nat.norm_digits.digits_succ Nat.NormDigits.digits_succ
| Mathlib/Data/Nat/Digits.lean | 876 | 881 | theorem digits_one (b n) (n0 : 0 < n) (nb : n < b) : Nat.digits b n = [n] ∧ 1 < b ∧ 0 < n := by |
have b2 : 1 < b :=
lt_iff_add_one_le.mpr (le_trans (add_le_add_right (lt_iff_add_one_le.mp n0) 1) nb)
refine ⟨?_, b2, n0⟩
rw [Nat.digits_def' b2 n0, Nat.mod_eq_of_lt nb,
(Nat.div_eq_zero_iff ((zero_le n).trans_lt nb)).2 nb, Nat.digits_zero]
|
import Mathlib.Algebra.Order.Group.Basic
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.Algebra.Star.Unitary
import Mathlib.Data.Nat.ModEq
import Mathlib.NumberTheory.Zsqrtd.Basic
import Mathlib.Tactic.Monotonicity
#align_import number_theory.pell_matiyasevic from "leanprover-community/mathlib"@"795b501869b9fa7aa716d5fdadd00c03f983a605"
namespace Pell
open Nat
section
variable {d : ℤ}
def IsPell : ℤ√d → Prop
| ⟨x, y⟩ => x * x - d * y * y = 1
#align pell.is_pell Pell.IsPell
theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1
| ⟨x, y⟩ => by simp [Zsqrtd.ext_iff, IsPell, mul_comm]; ring_nf
#align pell.is_pell_norm Pell.isPell_norm
theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, IsPell b ↔ b ∈ unitary (ℤ√d)
| ⟨x, y⟩ => by rw [unitary.mem_iff, isPell_norm, mul_comm (star _), and_self_iff]
#align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary
theorem isPell_mul {b c : ℤ√d} (hb : IsPell b) (hc : IsPell c) : IsPell (b * c) :=
isPell_norm.2 (by simp [mul_comm, mul_left_comm c, mul_assoc,
star_mul, isPell_norm.1 hb, isPell_norm.1 hc])
#align pell.is_pell_mul Pell.isPell_mul
theorem isPell_star : ∀ {b : ℤ√d}, IsPell b ↔ IsPell (star b)
| ⟨x, y⟩ => by simp [IsPell, Zsqrtd.star_mk]
#align pell.is_pell_star Pell.isPell_star
end
section
-- Porting note: was parameter in Lean3
variable {a : ℕ} (a1 : 1 < a)
private def d (_a1 : 1 < a) :=
a * a - 1
@[simp]
theorem d_pos : 0 < d a1 :=
tsub_pos_of_lt (mul_lt_mul a1 (le_of_lt a1) (by decide) (Nat.zero_le _) : 1 * 1 < a * a)
#align pell.d_pos Pell.d_pos
-- TODO(lint): Fix double namespace issue
--@[nolint dup_namespace]
def pell : ℕ → ℕ × ℕ
-- Porting note: used pattern matching because `Nat.recOn` is noncomputable
| 0 => (1, 0)
| n+1 => ((pell n).1 * a + d a1 * (pell n).2, (pell n).1 + (pell n).2 * a)
#align pell.pell Pell.pell
def xn (n : ℕ) : ℕ :=
(pell a1 n).1
#align pell.xn Pell.xn
def yn (n : ℕ) : ℕ :=
(pell a1 n).2
#align pell.yn Pell.yn
@[simp]
theorem pell_val (n : ℕ) : pell a1 n = (xn a1 n, yn a1 n) :=
show pell a1 n = ((pell a1 n).1, (pell a1 n).2) from
match pell a1 n with
| (_, _) => rfl
#align pell.pell_val Pell.pell_val
@[simp]
theorem xn_zero : xn a1 0 = 1 :=
rfl
#align pell.xn_zero Pell.xn_zero
@[simp]
theorem yn_zero : yn a1 0 = 0 :=
rfl
#align pell.yn_zero Pell.yn_zero
@[simp]
theorem xn_succ (n : ℕ) : xn a1 (n + 1) = xn a1 n * a + d a1 * yn a1 n :=
rfl
#align pell.xn_succ Pell.xn_succ
@[simp]
theorem yn_succ (n : ℕ) : yn a1 (n + 1) = xn a1 n + yn a1 n * a :=
rfl
#align pell.yn_succ Pell.yn_succ
--@[simp] Porting note (#10618): `simp` can prove it
theorem xn_one : xn a1 1 = a := by simp
#align pell.xn_one Pell.xn_one
--@[simp] Porting note (#10618): `simp` can prove it
theorem yn_one : yn a1 1 = 1 := by simp
#align pell.yn_one Pell.yn_one
def xz (n : ℕ) : ℤ :=
xn a1 n
#align pell.xz Pell.xz
def yz (n : ℕ) : ℤ :=
yn a1 n
#align pell.yz Pell.yz
section
def az (a : ℕ) : ℤ :=
a
#align pell.az Pell.az
end
theorem asq_pos : 0 < a * a :=
le_trans (le_of_lt a1)
(by have := @Nat.mul_le_mul_left 1 a a (le_of_lt a1); rwa [mul_one] at this)
#align pell.asq_pos Pell.asq_pos
theorem dz_val : ↑(d a1) = az a * az a - 1 :=
have : 1 ≤ a * a := asq_pos a1
by rw [Pell.d, Int.ofNat_sub this]; rfl
#align pell.dz_val Pell.dz_val
@[simp]
theorem xz_succ (n : ℕ) : (xz a1 (n + 1)) = xz a1 n * az a + d a1 * yz a1 n :=
rfl
#align pell.xz_succ Pell.xz_succ
@[simp]
theorem yz_succ (n : ℕ) : yz a1 (n + 1) = xz a1 n + yz a1 n * az a :=
rfl
#align pell.yz_succ Pell.yz_succ
def pellZd (n : ℕ) : ℤ√(d a1) :=
⟨xn a1 n, yn a1 n⟩
#align pell.pell_zd Pell.pellZd
@[simp]
theorem pellZd_re (n : ℕ) : (pellZd a1 n).re = xn a1 n :=
rfl
#align pell.pell_zd_re Pell.pellZd_re
@[simp]
theorem pellZd_im (n : ℕ) : (pellZd a1 n).im = yn a1 n :=
rfl
#align pell.pell_zd_im Pell.pellZd_im
theorem isPell_nat {x y : ℕ} : IsPell (⟨x, y⟩ : ℤ√(d a1)) ↔ x * x - d a1 * y * y = 1 :=
⟨fun h =>
Nat.cast_inj.1
(by rw [Int.ofNat_sub (Int.le_of_ofNat_le_ofNat <| Int.le.intro_sub _ h)]; exact h),
fun h =>
show ((x * x : ℕ) - (d a1 * y * y : ℕ) : ℤ) = 1 by
rw [← Int.ofNat_sub <| le_of_lt <| Nat.lt_of_sub_eq_succ h, h]; rfl⟩
#align pell.is_pell_nat Pell.isPell_nat
@[simp]
theorem pellZd_succ (n : ℕ) : pellZd a1 (n + 1) = pellZd a1 n * ⟨a, 1⟩ := by ext <;> simp
#align pell.pell_zd_succ Pell.pellZd_succ
theorem isPell_one : IsPell (⟨a, 1⟩ : ℤ√(d a1)) :=
show az a * az a - d a1 * 1 * 1 = 1 by simp [dz_val]
#align pell.is_pell_one Pell.isPell_one
theorem isPell_pellZd : ∀ n : ℕ, IsPell (pellZd a1 n)
| 0 => rfl
| n + 1 => by
let o := isPell_one a1
simp; exact Pell.isPell_mul (isPell_pellZd n) o
#align pell.is_pell_pell_zd Pell.isPell_pellZd
@[simp]
theorem pell_eqz (n : ℕ) : xz a1 n * xz a1 n - d a1 * yz a1 n * yz a1 n = 1 :=
isPell_pellZd a1 n
#align pell.pell_eqz Pell.pell_eqz
@[simp]
theorem pell_eq (n : ℕ) : xn a1 n * xn a1 n - d a1 * yn a1 n * yn a1 n = 1 :=
let pn := pell_eqz a1 n
have h : (↑(xn a1 n * xn a1 n) : ℤ) - ↑(d a1 * yn a1 n * yn a1 n) = 1 := by
repeat' rw [Int.ofNat_mul]; exact pn
have hl : d a1 * yn a1 n * yn a1 n ≤ xn a1 n * xn a1 n :=
Nat.cast_le.1 <| Int.le.intro _ <| add_eq_of_eq_sub' <| Eq.symm h
Nat.cast_inj.1 (by rw [Int.ofNat_sub hl]; exact h)
#align pell.pell_eq Pell.pell_eq
instance dnsq : Zsqrtd.Nonsquare (d a1) :=
⟨fun n h =>
have : n * n + 1 = a * a := by rw [← h]; exact Nat.succ_pred_eq_of_pos (asq_pos a1)
have na : n < a := Nat.mul_self_lt_mul_self_iff.1 (by rw [← this]; exact Nat.lt_succ_self _)
have : (n + 1) * (n + 1) ≤ n * n + 1 := by rw [this]; exact Nat.mul_self_le_mul_self na
have : n + n ≤ 0 :=
@Nat.le_of_add_le_add_right _ (n * n + 1) _ (by ring_nf at this ⊢; assumption)
Nat.ne_of_gt (d_pos a1) <| by
rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h⟩
#align pell.dnsq Pell.dnsq
theorem xn_ge_a_pow : ∀ n : ℕ, a ^ n ≤ xn a1 n
| 0 => le_refl 1
| n + 1 => by
simp only [_root_.pow_succ, xn_succ]
exact le_trans (Nat.mul_le_mul_right _ (xn_ge_a_pow n)) (Nat.le_add_right _ _)
#align pell.xn_ge_a_pow Pell.xn_ge_a_pow
theorem n_lt_a_pow : ∀ n : ℕ, n < a ^ n
| 0 => Nat.le_refl 1
| n + 1 => by
have IH := n_lt_a_pow n
have : a ^ n + a ^ n ≤ a ^ n * a := by
rw [← mul_two]
exact Nat.mul_le_mul_left _ a1
simp only [_root_.pow_succ, gt_iff_lt]
refine lt_of_lt_of_le ?_ this
exact add_lt_add_of_lt_of_le IH (lt_of_le_of_lt (Nat.zero_le _) IH)
#align pell.n_lt_a_pow Pell.n_lt_a_pow
theorem n_lt_xn (n) : n < xn a1 n :=
lt_of_lt_of_le (n_lt_a_pow a1 n) (xn_ge_a_pow a1 n)
#align pell.n_lt_xn Pell.n_lt_xn
theorem x_pos (n) : 0 < xn a1 n :=
lt_of_le_of_lt (Nat.zero_le n) (n_lt_xn a1 n)
#align pell.x_pos Pell.x_pos
theorem eq_pell_lem : ∀ (n) (b : ℤ√(d a1)), 1 ≤ b → IsPell b →
b ≤ pellZd a1 n → ∃ n, b = pellZd a1 n
| 0, b => fun h1 _ hl => ⟨0, @Zsqrtd.le_antisymm _ (dnsq a1) _ _ hl h1⟩
| n + 1, b => fun h1 hp h =>
have a1p : (0 : ℤ√(d a1)) ≤ ⟨a, 1⟩ := trivial
have am1p : (0 : ℤ√(d a1)) ≤ ⟨a, -1⟩ := show (_ : Nat) ≤ _ by simp; exact Nat.pred_le _
have a1m : (⟨a, 1⟩ * ⟨a, -1⟩ : ℤ√(d a1)) = 1 := isPell_norm.1 (isPell_one a1)
if ha : (⟨↑a, 1⟩ : ℤ√(d a1)) ≤ b then
let ⟨m, e⟩ :=
eq_pell_lem n (b * ⟨a, -1⟩) (by rw [← a1m]; exact mul_le_mul_of_nonneg_right ha am1p)
(isPell_mul hp (isPell_star.1 (isPell_one a1)))
(by
have t := mul_le_mul_of_nonneg_right h am1p
rwa [pellZd_succ, mul_assoc, a1m, mul_one] at t)
⟨m + 1, by
rw [show b = b * ⟨a, -1⟩ * ⟨a, 1⟩ by rw [mul_assoc, Eq.trans (mul_comm _ _) a1m]; simp,
pellZd_succ, e]⟩
else
suffices ¬1 < b from ⟨0, show b = 1 from (Or.resolve_left (lt_or_eq_of_le h1) this).symm⟩
fun h1l => by
cases' b with x y
exact by
have bm : (_ * ⟨_, _⟩ : ℤ√d a1) = 1 := Pell.isPell_norm.1 hp
have y0l : (0 : ℤ√d a1) < ⟨x - x, y - -y⟩ :=
sub_lt_sub h1l fun hn : (1 : ℤ√d a1) ≤ ⟨x, -y⟩ => by
have t := mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1)
erw [bm, mul_one] at t
exact h1l t
have yl2 : (⟨_, _⟩ : ℤ√_) < ⟨_, _⟩ :=
show (⟨x, y⟩ - ⟨x, -y⟩ : ℤ√d a1) < ⟨a, 1⟩ - ⟨a, -1⟩ from
sub_lt_sub ha fun hn : (⟨x, -y⟩ : ℤ√d a1) ≤ ⟨a, -1⟩ => by
have t := mul_le_mul_of_nonneg_right
(mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1)) a1p
erw [bm, one_mul, mul_assoc, Eq.trans (mul_comm _ _) a1m, mul_one] at t
exact ha t
simp only [sub_self, sub_neg_eq_add] at y0l; simp only [Zsqrtd.neg_re, add_right_neg,
Zsqrtd.neg_im, neg_neg] at yl2
exact
match y, y0l, (yl2 : (⟨_, _⟩ : ℤ√_) < ⟨_, _⟩) with
| 0, y0l, _ => y0l (le_refl 0)
| (y + 1 : ℕ), _, yl2 =>
yl2
(Zsqrtd.le_of_le_le (by simp [sub_eq_add_neg])
(let t := Int.ofNat_le_ofNat_of_le (Nat.succ_pos y)
add_le_add t t))
| Int.negSucc _, y0l, _ => y0l trivial
#align pell.eq_pell_lem Pell.eq_pell_lem
theorem eq_pellZd (b : ℤ√(d a1)) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pellZd a1 n :=
let ⟨n, h⟩ := @Zsqrtd.le_arch (d a1) b
eq_pell_lem a1 n b b1 hp <|
h.trans <| by
rw [Zsqrtd.natCast_val]
exact
Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| le_of_lt <| n_lt_xn _ _)
(Int.ofNat_zero_le _)
#align pell.eq_pell_zd Pell.eq_pellZd
theorem eq_pell {x y : ℕ} (hp : x * x - d a1 * y * y = 1) : ∃ n, x = xn a1 n ∧ y = yn a1 n :=
have : (1 : ℤ√(d a1)) ≤ ⟨x, y⟩ :=
match x, hp with
| 0, (hp : 0 - _ = 1) => by rw [zero_tsub] at hp; contradiction
| x + 1, _hp =>
Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| Nat.succ_pos x) (Int.ofNat_zero_le _)
let ⟨m, e⟩ := eq_pellZd a1 ⟨x, y⟩ this ((isPell_nat a1).2 hp)
⟨m,
match x, y, e with
| _, _, rfl => ⟨rfl, rfl⟩⟩
#align pell.eq_pell Pell.eq_pell
theorem pellZd_add (m) : ∀ n, pellZd a1 (m + n) = pellZd a1 m * pellZd a1 n
| 0 => (mul_one _).symm
| n + 1 => by rw [← add_assoc, pellZd_succ, pellZd_succ, pellZd_add _ n, ← mul_assoc]
#align pell.pell_zd_add Pell.pellZd_add
theorem xn_add (m n) : xn a1 (m + n) = xn a1 m * xn a1 n + d a1 * yn a1 m * yn a1 n := by
injection pellZd_add a1 m n with h _
zify
rw [h]
simp [pellZd]
#align pell.xn_add Pell.xn_add
theorem yn_add (m n) : yn a1 (m + n) = xn a1 m * yn a1 n + yn a1 m * xn a1 n := by
injection pellZd_add a1 m n with _ h
zify
rw [h]
simp [pellZd]
#align pell.yn_add Pell.yn_add
theorem pellZd_sub {m n} (h : n ≤ m) : pellZd a1 (m - n) = pellZd a1 m * star (pellZd a1 n) := by
let t := pellZd_add a1 n (m - n)
rw [add_tsub_cancel_of_le h] at t
rw [t, mul_comm (pellZd _ n) _, mul_assoc, isPell_norm.1 (isPell_pellZd _ _), mul_one]
#align pell.pell_zd_sub Pell.pellZd_sub
theorem xz_sub {m n} (h : n ≤ m) :
xz a1 (m - n) = xz a1 m * xz a1 n - d a1 * yz a1 m * yz a1 n := by
rw [sub_eq_add_neg, ← mul_neg]
exact congr_arg Zsqrtd.re (pellZd_sub a1 h)
#align pell.xz_sub Pell.xz_sub
theorem yz_sub {m n} (h : n ≤ m) : yz a1 (m - n) = xz a1 n * yz a1 m - xz a1 m * yz a1 n := by
rw [sub_eq_add_neg, ← mul_neg, mul_comm, add_comm]
exact congr_arg Zsqrtd.im (pellZd_sub a1 h)
#align pell.yz_sub Pell.yz_sub
theorem xy_coprime (n) : (xn a1 n).Coprime (yn a1 n) :=
Nat.coprime_of_dvd' fun k _ kx ky => by
let p := pell_eq a1 n
rw [← p]
exact Nat.dvd_sub (le_of_lt <| Nat.lt_of_sub_eq_succ p) (kx.mul_left _) (ky.mul_left _)
#align pell.xy_coprime Pell.xy_coprime
theorem strictMono_y : StrictMono (yn a1)
| m, 0, h => absurd h <| Nat.not_lt_zero _
| m, n + 1, h => by
have : yn a1 m ≤ yn a1 n :=
Or.elim (lt_or_eq_of_le <| Nat.le_of_succ_le_succ h) (fun hl => le_of_lt <| strictMono_y hl)
fun e => by rw [e]
simp; refine lt_of_le_of_lt ?_ (Nat.lt_add_of_pos_left <| x_pos a1 n)
rw [← mul_one (yn a1 m)]
exact mul_le_mul this (le_of_lt a1) (Nat.zero_le _) (Nat.zero_le _)
#align pell.strict_mono_y Pell.strictMono_y
theorem strictMono_x : StrictMono (xn a1)
| m, 0, h => absurd h <| Nat.not_lt_zero _
| m, n + 1, h => by
have : xn a1 m ≤ xn a1 n :=
Or.elim (lt_or_eq_of_le <| Nat.le_of_succ_le_succ h) (fun hl => le_of_lt <| strictMono_x hl)
fun e => by rw [e]
simp; refine lt_of_lt_of_le (lt_of_le_of_lt this ?_) (Nat.le_add_right _ _)
have t := Nat.mul_lt_mul_of_pos_left a1 (x_pos a1 n)
rwa [mul_one] at t
#align pell.strict_mono_x Pell.strictMono_x
theorem yn_ge_n : ∀ n, n ≤ yn a1 n
| 0 => Nat.zero_le _
| n + 1 =>
show n < yn a1 (n + 1) from lt_of_le_of_lt (yn_ge_n n) (strictMono_y a1 <| Nat.lt_succ_self n)
#align pell.yn_ge_n Pell.yn_ge_n
theorem y_mul_dvd (n) : ∀ k, yn a1 n ∣ yn a1 (n * k)
| 0 => dvd_zero _
| k + 1 => by
rw [Nat.mul_succ, yn_add]; exact dvd_add (dvd_mul_left _ _) ((y_mul_dvd _ k).mul_right _)
#align pell.y_mul_dvd Pell.y_mul_dvd
theorem y_dvd_iff (m n) : yn a1 m ∣ yn a1 n ↔ m ∣ n :=
⟨fun h =>
Nat.dvd_of_mod_eq_zero <|
(Nat.eq_zero_or_pos _).resolve_right fun hp => by
have co : Nat.Coprime (yn a1 m) (xn a1 (m * (n / m))) :=
Nat.Coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m))
have m0 : 0 < m :=
m.eq_zero_or_pos.resolve_left fun e => by
rw [e, Nat.mod_zero] at hp;rw [e] at h
exact _root_.ne_of_lt (strictMono_y a1 hp) (eq_zero_of_zero_dvd h).symm
rw [← Nat.mod_add_div n m, yn_add] at h
exact
not_le_of_gt (strictMono_y _ <| Nat.mod_lt n m0)
(Nat.le_of_dvd (strictMono_y _ hp) <|
co.dvd_of_dvd_mul_right <|
(Nat.dvd_add_iff_right <| (y_mul_dvd _ _ _).mul_left _).2 h),
fun ⟨k, e⟩ => by rw [e]; apply y_mul_dvd⟩
#align pell.y_dvd_iff Pell.y_dvd_iff
theorem xy_modEq_yn (n) :
∀ k, xn a1 (n * k) ≡ xn a1 n ^ k [MOD yn a1 n ^ 2] ∧ yn a1 (n * k) ≡
k * xn a1 n ^ (k - 1) * yn a1 n [MOD yn a1 n ^ 3]
| 0 => by constructor <;> simp <;> exact Nat.ModEq.refl _
| k + 1 => by
let ⟨hx, hy⟩ := xy_modEq_yn n k
have L : xn a1 (n * k) * xn a1 n + d a1 * yn a1 (n * k) * yn a1 n ≡
xn a1 n ^ k * xn a1 n + 0 [MOD yn a1 n ^ 2] :=
(hx.mul_right _).add <|
modEq_zero_iff_dvd.2 <| by
rw [_root_.pow_succ]
exact
mul_dvd_mul_right
(dvd_mul_of_dvd_right
(modEq_zero_iff_dvd.1 <|
(hy.of_dvd <| by simp [_root_.pow_succ]).trans <|
modEq_zero_iff_dvd.2 <| by simp)
_) _
have R : xn a1 (n * k) * yn a1 n + yn a1 (n * k) * xn a1 n ≡
xn a1 n ^ k * yn a1 n + k * xn a1 n ^ k * yn a1 n [MOD yn a1 n ^ 3] :=
ModEq.add
(by
rw [_root_.pow_succ]
exact hx.mul_right' _) <| by
have : k * xn a1 n ^ (k - 1) * yn a1 n * xn a1 n = k * xn a1 n ^ k * yn a1 n := by
cases' k with k <;> simp [_root_.pow_succ]; ring_nf
rw [← this]
exact hy.mul_right _
rw [add_tsub_cancel_right, Nat.mul_succ, xn_add, yn_add, pow_succ (xn _ n), Nat.succ_mul,
add_comm (k * xn _ n ^ k) (xn _ n ^ k), right_distrib]
exact ⟨L, R⟩
#align pell.xy_modeq_yn Pell.xy_modEq_yn
theorem ysq_dvd_yy (n) : yn a1 n * yn a1 n ∣ yn a1 (n * yn a1 n) :=
modEq_zero_iff_dvd.1 <|
((xy_modEq_yn a1 n (yn a1 n)).right.of_dvd <| by simp [_root_.pow_succ]).trans
(modEq_zero_iff_dvd.2 <| by simp [mul_dvd_mul_left, mul_assoc])
#align pell.ysq_dvd_yy Pell.ysq_dvd_yy
theorem dvd_of_ysq_dvd {n t} (h : yn a1 n * yn a1 n ∣ yn a1 t) : yn a1 n ∣ t :=
have nt : n ∣ t := (y_dvd_iff a1 n t).1 <| dvd_of_mul_left_dvd h
n.eq_zero_or_pos.elim (fun n0 => by rwa [n0] at nt ⊢) fun n0l : 0 < n => by
let ⟨k, ke⟩ := nt
have : yn a1 n ∣ k * xn a1 n ^ (k - 1) :=
Nat.dvd_of_mul_dvd_mul_right (strictMono_y a1 n0l) <|
modEq_zero_iff_dvd.1 <| by
have xm := (xy_modEq_yn a1 n k).right; rw [← ke] at xm
exact (xm.of_dvd <| by simp [_root_.pow_succ]).symm.trans h.modEq_zero_nat
rw [ke]
exact dvd_mul_of_dvd_right (((xy_coprime _ _).pow_left _).symm.dvd_of_dvd_mul_right this) _
#align pell.dvd_of_ysq_dvd Pell.dvd_of_ysq_dvd
theorem pellZd_succ_succ (n) :
pellZd a1 (n + 2) + pellZd a1 n = (2 * a : ℕ) * pellZd a1 (n + 1) := by
have : (1 : ℤ√(d a1)) + ⟨a, 1⟩ * ⟨a, 1⟩ = ⟨a, 1⟩ * (2 * a) := by
rw [Zsqrtd.natCast_val]
change (⟨_, _⟩ : ℤ√(d a1)) = ⟨_, _⟩
rw [dz_val]
dsimp [az]
ext <;> dsimp <;> ring_nf
simpa [mul_add, mul_comm, mul_left_comm, add_comm] using congr_arg (· * pellZd a1 n) this
#align pell.pell_zd_succ_succ Pell.pellZd_succ_succ
theorem xy_succ_succ (n) :
xn a1 (n + 2) + xn a1 n =
2 * a * xn a1 (n + 1) ∧ yn a1 (n + 2) + yn a1 n = 2 * a * yn a1 (n + 1) := by
have := pellZd_succ_succ a1 n; unfold pellZd at this
erw [Zsqrtd.smul_val (2 * a : ℕ)] at this
injection this with h₁ h₂
constructor <;> apply Int.ofNat.inj <;> [simpa using h₁; simpa using h₂]
#align pell.xy_succ_succ Pell.xy_succ_succ
theorem xn_succ_succ (n) : xn a1 (n + 2) + xn a1 n = 2 * a * xn a1 (n + 1) :=
(xy_succ_succ a1 n).1
#align pell.xn_succ_succ Pell.xn_succ_succ
theorem yn_succ_succ (n) : yn a1 (n + 2) + yn a1 n = 2 * a * yn a1 (n + 1) :=
(xy_succ_succ a1 n).2
#align pell.yn_succ_succ Pell.yn_succ_succ
theorem xz_succ_succ (n) : xz a1 (n + 2) = (2 * a : ℕ) * xz a1 (n + 1) - xz a1 n :=
eq_sub_of_add_eq <| by delta xz; rw [← Int.ofNat_add, ← Int.ofNat_mul, xn_succ_succ]
#align pell.xz_succ_succ Pell.xz_succ_succ
theorem yz_succ_succ (n) : yz a1 (n + 2) = (2 * a : ℕ) * yz a1 (n + 1) - yz a1 n :=
eq_sub_of_add_eq <| by delta yz; rw [← Int.ofNat_add, ← Int.ofNat_mul, yn_succ_succ]
#align pell.yz_succ_succ Pell.yz_succ_succ
theorem yn_modEq_a_sub_one : ∀ n, yn a1 n ≡ n [MOD a - 1]
| 0 => by simp [Nat.ModEq.refl]
| 1 => by simp [Nat.ModEq.refl]
| n + 2 =>
(yn_modEq_a_sub_one n).add_right_cancel <| by
rw [yn_succ_succ, (by ring : n + 2 + n = 2 * (n + 1))]
exact ((modEq_sub a1.le).mul_left 2).mul (yn_modEq_a_sub_one (n + 1))
#align pell.yn_modeq_a_sub_one Pell.yn_modEq_a_sub_one
theorem yn_modEq_two : ∀ n, yn a1 n ≡ n [MOD 2]
| 0 => by rfl
| 1 => by simp; rfl
| n + 2 =>
(yn_modEq_two n).add_right_cancel <| by
rw [yn_succ_succ, mul_assoc, (by ring : n + 2 + n = 2 * (n + 1))]
exact (dvd_mul_right 2 _).modEq_zero_nat.trans (dvd_mul_right 2 _).zero_modEq_nat
#align pell.yn_modeq_two Pell.yn_modEq_two
section
theorem x_sub_y_dvd_pow_lem (y2 y1 y0 yn1 yn0 xn1 xn0 ay a2 : ℤ) :
(a2 * yn1 - yn0) * ay + y2 - (a2 * xn1 - xn0) =
y2 - a2 * y1 + y0 + a2 * (yn1 * ay + y1 - xn1) - (yn0 * ay + y0 - xn0) := by
ring
#align pell.x_sub_y_dvd_pow_lem Pell.x_sub_y_dvd_pow_lem
end
theorem x_sub_y_dvd_pow (y : ℕ) :
∀ n, (2 * a * y - y * y - 1 : ℤ) ∣ yz a1 n * (a - y) + ↑(y ^ n) - xz a1 n
| 0 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one]
| 1 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one]
| n + 2 => by
have : (2 * a * y - y * y - 1 : ℤ) ∣ ↑(y ^ (n + 2)) - ↑(2 * a) * ↑(y ^ (n + 1)) + ↑(y ^ n) :=
⟨-↑(y ^ n), by
simp [_root_.pow_succ, mul_add, Int.ofNat_mul, show ((2 : ℕ) : ℤ) = 2 from rfl, mul_comm,
mul_left_comm]
ring⟩
rw [xz_succ_succ, yz_succ_succ, x_sub_y_dvd_pow_lem ↑(y ^ (n + 2)) ↑(y ^ (n + 1)) ↑(y ^ n)]
exact _root_.dvd_sub (dvd_add this <| (x_sub_y_dvd_pow _ (n + 1)).mul_left _)
(x_sub_y_dvd_pow _ n)
#align pell.x_sub_y_dvd_pow Pell.x_sub_y_dvd_pow
theorem xn_modEq_x2n_add_lem (n j) : xn a1 n ∣ d a1 * yn a1 n * (yn a1 n * xn a1 j) + xn a1 j := by
have h1 : d a1 * yn a1 n * (yn a1 n * xn a1 j) + xn a1 j =
(d a1 * yn a1 n * yn a1 n + 1) * xn a1 j := by
simp [add_mul, mul_assoc]
have h2 : d a1 * yn a1 n * yn a1 n + 1 = xn a1 n * xn a1 n := by
zify at *
apply add_eq_of_eq_sub' (Eq.symm (pell_eqz a1 n))
rw [h2] at h1; rw [h1, mul_assoc]; exact dvd_mul_right _ _
#align pell.xn_modeq_x2n_add_lem Pell.xn_modEq_x2n_add_lem
theorem xn_modEq_x2n_add (n j) : xn a1 (2 * n + j) + xn a1 j ≡ 0 [MOD xn a1 n] := by
rw [two_mul, add_assoc, xn_add, add_assoc, ← zero_add 0]
refine (dvd_mul_right (xn a1 n) (xn a1 (n + j))).modEq_zero_nat.add ?_
rw [yn_add, left_distrib, add_assoc, ← zero_add 0]
exact
((dvd_mul_right _ _).mul_left _).modEq_zero_nat.add (xn_modEq_x2n_add_lem _ _ _).modEq_zero_nat
#align pell.xn_modeq_x2n_add Pell.xn_modEq_x2n_add
| Mathlib/NumberTheory/PellMatiyasevic.lean | 606 | 619 | theorem xn_modEq_x2n_sub_lem {n j} (h : j ≤ n) : xn a1 (2 * n - j) + xn a1 j ≡ 0 [MOD xn a1 n] := by |
have h1 : xz a1 n ∣ d a1 * yz a1 n * yz a1 (n - j) + xz a1 j := by
rw [yz_sub _ h, mul_sub_left_distrib, sub_add_eq_add_sub]
exact
dvd_sub
(by
delta xz; delta yz
rw [mul_comm (xn _ _ : ℤ)]
exact mod_cast (xn_modEq_x2n_add_lem _ n j))
((dvd_mul_right _ _).mul_left _)
rw [two_mul, add_tsub_assoc_of_le h, xn_add, add_assoc, ← zero_add 0]
exact
(dvd_mul_right _ _).modEq_zero_nat.add
(Int.natCast_dvd_natCast.1 <| by simpa [xz, yz] using h1).modEq_zero_nat
|
import Mathlib.Topology.Algebra.InfiniteSum.Basic
import Mathlib.Topology.Algebra.UniformGroup
noncomputable section
open Filter Finset Function
open scoped Topology
variable {α β γ δ : Type*}
section TopologicalGroup
variable [CommGroup α] [TopologicalSpace α] [TopologicalGroup α]
variable {f g : β → α} {a a₁ a₂ : α}
-- `by simpa using` speeds up elaboration. Why?
@[to_additive]
theorem HasProd.inv (h : HasProd f a) : HasProd (fun b ↦ (f b)⁻¹) a⁻¹ := by
simpa only using h.map (MonoidHom.id α)⁻¹ continuous_inv
#align has_sum.neg HasSum.neg
@[to_additive]
theorem Multipliable.inv (hf : Multipliable f) : Multipliable fun b ↦ (f b)⁻¹ :=
hf.hasProd.inv.multipliable
#align summable.neg Summable.neg
@[to_additive]
theorem Multipliable.of_inv (hf : Multipliable fun b ↦ (f b)⁻¹) : Multipliable f := by
simpa only [inv_inv] using hf.inv
#align summable.of_neg Summable.of_neg
@[to_additive]
theorem multipliable_inv_iff : (Multipliable fun b ↦ (f b)⁻¹) ↔ Multipliable f :=
⟨Multipliable.of_inv, Multipliable.inv⟩
#align summable_neg_iff summable_neg_iff
@[to_additive]
theorem HasProd.div (hf : HasProd f a₁) (hg : HasProd g a₂) :
HasProd (fun b ↦ f b / g b) (a₁ / a₂) := by
simp only [div_eq_mul_inv]
exact hf.mul hg.inv
#align has_sum.sub HasSum.sub
@[to_additive]
theorem Multipliable.div (hf : Multipliable f) (hg : Multipliable g) :
Multipliable fun b ↦ f b / g b :=
(hf.hasProd.div hg.hasProd).multipliable
#align summable.sub Summable.sub
@[to_additive]
theorem Multipliable.trans_div (hg : Multipliable g) (hfg : Multipliable fun b ↦ f b / g b) :
Multipliable f := by
simpa only [div_mul_cancel] using hfg.mul hg
#align summable.trans_sub Summable.trans_sub
@[to_additive]
theorem multipliable_iff_of_multipliable_div (hfg : Multipliable fun b ↦ f b / g b) :
Multipliable f ↔ Multipliable g :=
⟨fun hf ↦ hf.trans_div <| by simpa only [inv_div] using hfg.inv, fun hg ↦ hg.trans_div hfg⟩
#align summable_iff_of_summable_sub summable_iff_of_summable_sub
@[to_additive]
theorem HasProd.update (hf : HasProd f a₁) (b : β) [DecidableEq β] (a : α) :
HasProd (update f b a) (a / f b * a₁) := by
convert (hasProd_ite_eq b (a / f b)).mul hf with b'
by_cases h : b' = b
· rw [h, update_same]
simp [eq_self_iff_true, if_true, sub_add_cancel]
· simp only [h, update_noteq, if_false, Ne, one_mul, not_false_iff]
#align has_sum.update HasSum.update
@[to_additive]
theorem Multipliable.update (hf : Multipliable f) (b : β) [DecidableEq β] (a : α) :
Multipliable (update f b a) :=
(hf.hasProd.update b a).multipliable
#align summable.update Summable.update
@[to_additive]
theorem HasProd.hasProd_compl_iff {s : Set β} (hf : HasProd (f ∘ (↑) : s → α) a₁) :
HasProd (f ∘ (↑) : ↑sᶜ → α) a₂ ↔ HasProd f (a₁ * a₂) := by
refine ⟨fun h ↦ hf.mul_compl h, fun h ↦ ?_⟩
rw [hasProd_subtype_iff_mulIndicator] at hf ⊢
rw [Set.mulIndicator_compl]
simpa only [div_eq_mul_inv, mul_inv_cancel_comm] using h.div hf
#align has_sum.has_sum_compl_iff HasSum.hasSum_compl_iff
@[to_additive]
theorem HasProd.hasProd_iff_compl {s : Set β} (hf : HasProd (f ∘ (↑) : s → α) a₁) :
HasProd f a₂ ↔ HasProd (f ∘ (↑) : ↑sᶜ → α) (a₂ / a₁) :=
Iff.symm <| hf.hasProd_compl_iff.trans <| by rw [mul_div_cancel]
#align has_sum.has_sum_iff_compl HasSum.hasSum_iff_compl
@[to_additive]
theorem Multipliable.multipliable_compl_iff {s : Set β} (hf : Multipliable (f ∘ (↑) : s → α)) :
Multipliable (f ∘ (↑) : ↑sᶜ → α) ↔ Multipliable f where
mp := fun ⟨_, ha⟩ ↦ (hf.hasProd.hasProd_compl_iff.1 ha).multipliable
mpr := fun ⟨_, ha⟩ ↦ (hf.hasProd.hasProd_iff_compl.1 ha).multipliable
#align summable.summable_compl_iff Summable.summable_compl_iff
@[to_additive]
protected theorem Finset.hasProd_compl_iff (s : Finset β) :
HasProd (fun x : { x // x ∉ s } ↦ f x) a ↔ HasProd f (a * ∏ i ∈ s, f i) :=
(s.hasProd f).hasProd_compl_iff.trans <| by rw [mul_comm]
#align finset.has_sum_compl_iff Finset.hasSum_compl_iff
@[to_additive]
protected theorem Finset.hasProd_iff_compl (s : Finset β) :
HasProd f a ↔ HasProd (fun x : { x // x ∉ s } ↦ f x) (a / ∏ i ∈ s, f i) :=
(s.hasProd f).hasProd_iff_compl
#align finset.has_sum_iff_compl Finset.hasSum_iff_compl
@[to_additive]
protected theorem Finset.multipliable_compl_iff (s : Finset β) :
(Multipliable fun x : { x // x ∉ s } ↦ f x) ↔ Multipliable f :=
(s.multipliable f).multipliable_compl_iff
#align finset.summable_compl_iff Finset.summable_compl_iff
@[to_additive]
theorem Set.Finite.multipliable_compl_iff {s : Set β} (hs : s.Finite) :
Multipliable (f ∘ (↑) : ↑sᶜ → α) ↔ Multipliable f :=
(hs.multipliable f).multipliable_compl_iff
#align set.finite.summable_compl_iff Set.Finite.summable_compl_iff
@[to_additive]
theorem hasProd_ite_div_hasProd [DecidableEq β] (hf : HasProd f a) (b : β) :
HasProd (fun n ↦ ite (n = b) 1 (f n)) (a / f b) := by
convert hf.update b 1 using 1
· ext n
rw [Function.update_apply]
· rw [div_mul_eq_mul_div, one_mul]
#align has_sum_ite_sub_has_sum hasSum_ite_sub_hasSum
section tprod
variable [T2Space α]
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Group.lean | 150 | 154 | theorem tprod_inv : ∏' b, (f b)⁻¹ = (∏' b, f b)⁻¹ := by |
by_cases hf : Multipliable f
· exact hf.hasProd.inv.tprod_eq
· simp [tprod_eq_one_of_not_multipliable hf,
tprod_eq_one_of_not_multipliable (mt Multipliable.of_inv hf)]
|
import Mathlib.Analysis.Convex.Combination
import Mathlib.Analysis.Convex.Strict
import Mathlib.Topology.Connected.PathConnected
import Mathlib.Topology.Algebra.Affine
import Mathlib.Topology.Algebra.Module.Basic
#align_import analysis.convex.topology from "leanprover-community/mathlib"@"0e3aacdc98d25e0afe035c452d876d28cbffaa7e"
assert_not_exists Norm
open Metric Bornology Set Pointwise Convex
variable {ι 𝕜 E : Type*}
theorem Real.convex_iff_isPreconnected {s : Set ℝ} : Convex ℝ s ↔ IsPreconnected s :=
convex_iff_ordConnected.trans isPreconnected_iff_ordConnected.symm
#align real.convex_iff_is_preconnected Real.convex_iff_isPreconnected
alias ⟨_, IsPreconnected.convex⟩ := Real.convex_iff_isPreconnected
#align is_preconnected.convex IsPreconnected.convex
section ContinuousConstSMul
variable [LinearOrderedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E]
[TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E]
theorem Convex.combo_interior_closure_subset_interior {s : Set E} (hs : Convex 𝕜 s) {a b : 𝕜}
(ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) : a • interior s + b • closure s ⊆ interior s :=
interior_smul₀ ha.ne' s ▸
calc
interior (a • s) + b • closure s ⊆ interior (a • s) + closure (b • s) :=
add_subset_add Subset.rfl (smul_closure_subset b s)
_ = interior (a • s) + b • s := by rw [isOpen_interior.add_closure (b • s)]
_ ⊆ interior (a • s + b • s) := subset_interior_add_left
_ ⊆ interior s := interior_mono <| hs.set_combo_subset ha.le hb hab
#align convex.combo_interior_closure_subset_interior Convex.combo_interior_closure_subset_interior
theorem Convex.combo_interior_self_subset_interior {s : Set E} (hs : Convex 𝕜 s) {a b : 𝕜}
(ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) : a • interior s + b • s ⊆ interior s :=
calc
a • interior s + b • s ⊆ a • interior s + b • closure s :=
add_subset_add Subset.rfl <| image_subset _ subset_closure
_ ⊆ interior s := hs.combo_interior_closure_subset_interior ha hb hab
#align convex.combo_interior_self_subset_interior Convex.combo_interior_self_subset_interior
theorem Convex.combo_closure_interior_subset_interior {s : Set E} (hs : Convex 𝕜 s) {a b : 𝕜}
(ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1) : a • closure s + b • interior s ⊆ interior s := by
rw [add_comm]
exact hs.combo_interior_closure_subset_interior hb ha (add_comm a b ▸ hab)
#align convex.combo_closure_interior_subset_interior Convex.combo_closure_interior_subset_interior
theorem Convex.combo_self_interior_subset_interior {s : Set E} (hs : Convex 𝕜 s) {a b : 𝕜}
(ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1) : a • s + b • interior s ⊆ interior s := by
rw [add_comm]
exact hs.combo_interior_self_subset_interior hb ha (add_comm a b ▸ hab)
#align convex.combo_self_interior_subset_interior Convex.combo_self_interior_subset_interior
theorem Convex.combo_interior_closure_mem_interior {s : Set E} (hs : Convex 𝕜 s) {x y : E}
(hx : x ∈ interior s) (hy : y ∈ closure s) {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b)
(hab : a + b = 1) : a • x + b • y ∈ interior s :=
hs.combo_interior_closure_subset_interior ha hb hab <|
add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy)
#align convex.combo_interior_closure_mem_interior Convex.combo_interior_closure_mem_interior
theorem Convex.combo_interior_self_mem_interior {s : Set E} (hs : Convex 𝕜 s) {x y : E}
(hx : x ∈ interior s) (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) :
a • x + b • y ∈ interior s :=
hs.combo_interior_closure_mem_interior hx (subset_closure hy) ha hb hab
#align convex.combo_interior_self_mem_interior Convex.combo_interior_self_mem_interior
theorem Convex.combo_closure_interior_mem_interior {s : Set E} (hs : Convex 𝕜 s) {x y : E}
(hx : x ∈ closure s) (hy : y ∈ interior s) {a b : 𝕜} (ha : 0 ≤ a) (hb : 0 < b)
(hab : a + b = 1) : a • x + b • y ∈ interior s :=
hs.combo_closure_interior_subset_interior ha hb hab <|
add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy)
#align convex.combo_closure_interior_mem_interior Convex.combo_closure_interior_mem_interior
theorem Convex.combo_self_interior_mem_interior {s : Set E} (hs : Convex 𝕜 s) {x y : E} (hx : x ∈ s)
(hy : y ∈ interior s) {a b : 𝕜} (ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1) :
a • x + b • y ∈ interior s :=
hs.combo_closure_interior_mem_interior (subset_closure hx) hy ha hb hab
#align convex.combo_self_interior_mem_interior Convex.combo_self_interior_mem_interior
theorem Convex.openSegment_interior_closure_subset_interior {s : Set E} (hs : Convex 𝕜 s) {x y : E}
(hx : x ∈ interior s) (hy : y ∈ closure s) : openSegment 𝕜 x y ⊆ interior s := by
rintro _ ⟨a, b, ha, hb, hab, rfl⟩
exact hs.combo_interior_closure_mem_interior hx hy ha hb.le hab
#align convex.open_segment_interior_closure_subset_interior Convex.openSegment_interior_closure_subset_interior
theorem Convex.openSegment_interior_self_subset_interior {s : Set E} (hs : Convex 𝕜 s) {x y : E}
(hx : x ∈ interior s) (hy : y ∈ s) : openSegment 𝕜 x y ⊆ interior s :=
hs.openSegment_interior_closure_subset_interior hx (subset_closure hy)
#align convex.open_segment_interior_self_subset_interior Convex.openSegment_interior_self_subset_interior
theorem Convex.openSegment_closure_interior_subset_interior {s : Set E} (hs : Convex 𝕜 s) {x y : E}
(hx : x ∈ closure s) (hy : y ∈ interior s) : openSegment 𝕜 x y ⊆ interior s := by
rintro _ ⟨a, b, ha, hb, hab, rfl⟩
exact hs.combo_closure_interior_mem_interior hx hy ha.le hb hab
#align convex.open_segment_closure_interior_subset_interior Convex.openSegment_closure_interior_subset_interior
theorem Convex.openSegment_self_interior_subset_interior {s : Set E} (hs : Convex 𝕜 s) {x y : E}
(hx : x ∈ s) (hy : y ∈ interior s) : openSegment 𝕜 x y ⊆ interior s :=
hs.openSegment_closure_interior_subset_interior (subset_closure hx) hy
#align convex.open_segment_self_interior_subset_interior Convex.openSegment_self_interior_subset_interior
| Mathlib/Analysis/Convex/Topology.lean | 213 | 218 | theorem Convex.add_smul_sub_mem_interior' {s : Set E} (hs : Convex 𝕜 s) {x y : E}
(hx : x ∈ closure s) (hy : y ∈ interior s) {t : 𝕜} (ht : t ∈ Ioc (0 : 𝕜) 1) :
x + t • (y - x) ∈ interior s := by |
simpa only [sub_smul, smul_sub, one_smul, add_sub, add_comm] using
hs.combo_interior_closure_mem_interior hy hx ht.1 (sub_nonneg.mpr ht.2)
(add_sub_cancel _ _)
|
import Mathlib.Data.Nat.Factorization.Basic
import Mathlib.Data.SetLike.Fintype
import Mathlib.GroupTheory.GroupAction.ConjAct
import Mathlib.GroupTheory.PGroup
import Mathlib.GroupTheory.NoncommPiCoprod
import Mathlib.Order.Atoms.Finite
import Mathlib.Data.Set.Lattice
#align_import group_theory.sylow from "leanprover-community/mathlib"@"4be589053caf347b899a494da75410deb55fb3ef"
open Fintype MulAction Subgroup
section InfiniteSylow
variable (p : ℕ) (G : Type*) [Group G]
structure Sylow extends Subgroup G where
isPGroup' : IsPGroup p toSubgroup
is_maximal' : ∀ {Q : Subgroup G}, IsPGroup p Q → toSubgroup ≤ Q → Q = toSubgroup
#align sylow Sylow
variable {p} {G}
open Equiv Equiv.Perm Finset Function List QuotientGroup
universe u v w
variable {G : Type u} {α : Type v} {β : Type w} [Group G]
attribute [local instance 10] Subtype.fintype setFintype Classical.propDecidable
theorem QuotientGroup.card_preimage_mk [Fintype G] (s : Subgroup G) (t : Set (G ⧸ s)) :
Fintype.card (QuotientGroup.mk ⁻¹' t) = Fintype.card s * Fintype.card t := by
rw [← Fintype.card_prod, Fintype.card_congr (preimageMkEquivSubgroupProdSet _ _)]
#align quotient_group.card_preimage_mk QuotientGroup.card_preimage_mk
namespace Sylow
theorem mem_fixedPoints_mul_left_cosets_iff_mem_normalizer {H : Subgroup G} [Finite (H : Set G)]
{x : G} : (x : G ⧸ H) ∈ MulAction.fixedPoints H (G ⧸ H) ↔ x ∈ normalizer H :=
⟨fun hx =>
have ha : ∀ {y : G ⧸ H}, y ∈ orbit H (x : G ⧸ H) → y = x := mem_fixedPoints'.1 hx _
(inv_mem_iff (G := G)).1
(mem_normalizer_fintype fun n (hn : n ∈ H) =>
have : (n⁻¹ * x)⁻¹ * x ∈ H := QuotientGroup.eq.1 (ha ⟨⟨n⁻¹, inv_mem hn⟩, rfl⟩)
show _ ∈ H by
rw [mul_inv_rev, inv_inv] at this
convert this
rw [inv_inv]),
fun hx : ∀ n : G, n ∈ H ↔ x * n * x⁻¹ ∈ H =>
mem_fixedPoints'.2 fun y =>
Quotient.inductionOn' y fun y hy =>
QuotientGroup.eq.2
(let ⟨⟨b, hb₁⟩, hb₂⟩ := hy
have hb₂ : (b * x)⁻¹ * y ∈ H := QuotientGroup.eq.1 hb₂
(inv_mem_iff (G := G)).1 <|
(hx _).2 <|
(mul_mem_cancel_left (inv_mem hb₁)).1 <| by
rw [hx] at hb₂; simpa [mul_inv_rev, mul_assoc] using hb₂)⟩
#align sylow.mem_fixed_points_mul_left_cosets_iff_mem_normalizer Sylow.mem_fixedPoints_mul_left_cosets_iff_mem_normalizer
def fixedPointsMulLeftCosetsEquivQuotient (H : Subgroup G) [Finite (H : Set G)] :
MulAction.fixedPoints H (G ⧸ H) ≃
normalizer H ⧸ Subgroup.comap ((normalizer H).subtype : normalizer H →* G) H :=
@subtypeQuotientEquivQuotientSubtype G (normalizer H : Set G) (_) (_)
(MulAction.fixedPoints H (G ⧸ H))
(fun a => (@mem_fixedPoints_mul_left_cosets_iff_mem_normalizer _ _ _ ‹_› _).symm)
(by
intros
unfold_projs
rw [leftRel_apply (α := normalizer H), leftRel_apply]
rfl)
#align sylow.fixed_points_mul_left_cosets_equiv_quotient Sylow.fixedPointsMulLeftCosetsEquivQuotient
theorem card_quotient_normalizer_modEq_card_quotient [Fintype G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime]
{H : Subgroup G} (hH : Fintype.card H = p ^ n) :
Fintype.card (normalizer H ⧸ Subgroup.comap ((normalizer H).subtype : normalizer H →* G) H) ≡
card (G ⧸ H) [MOD p] := by
rw [← Fintype.card_congr (fixedPointsMulLeftCosetsEquivQuotient H)]
exact ((IsPGroup.of_card hH).card_modEq_card_fixedPoints _).symm
#align sylow.card_quotient_normalizer_modeq_card_quotient Sylow.card_quotient_normalizer_modEq_card_quotient
| Mathlib/GroupTheory/Sylow.lean | 548 | 556 | theorem card_normalizer_modEq_card [Fintype G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime] {H : Subgroup G}
(hH : Fintype.card H = p ^ n) : card (normalizer H) ≡ card G [MOD p ^ (n + 1)] := by |
have : H.subgroupOf (normalizer H) ≃ H := (subgroupOfEquivOfLe le_normalizer).toEquiv
simp only [← Nat.card_eq_fintype_card] at hH ⊢
rw [card_eq_card_quotient_mul_card_subgroup H,
card_eq_card_quotient_mul_card_subgroup (H.subgroupOf (normalizer H)), Nat.card_congr this,
hH, pow_succ']
simp only [Nat.card_eq_fintype_card] at hH ⊢
exact (card_quotient_normalizer_modEq_card_quotient hH).mul_right' _
|
import Mathlib.Algebra.Associated
import Mathlib.Algebra.Order.Monoid.Unbundled.Pow
import Mathlib.Algebra.Ring.Int
import Mathlib.Data.Nat.Factorial.Basic
import Mathlib.Data.Nat.GCD.Basic
import Mathlib.Order.Bounds.Basic
#align_import data.nat.prime from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1"
open Bool Subtype
open Nat
namespace Nat
variable {n : ℕ}
-- Porting note (#11180): removed @[pp_nodot]
def Prime (p : ℕ) :=
Irreducible p
#align nat.prime Nat.Prime
theorem irreducible_iff_nat_prime (a : ℕ) : Irreducible a ↔ Nat.Prime a :=
Iff.rfl
#align irreducible_iff_nat_prime Nat.irreducible_iff_nat_prime
@[aesop safe destruct] theorem not_prime_zero : ¬Prime 0
| h => h.ne_zero rfl
#align nat.not_prime_zero Nat.not_prime_zero
@[aesop safe destruct] theorem not_prime_one : ¬Prime 1
| h => h.ne_one rfl
#align nat.not_prime_one Nat.not_prime_one
theorem Prime.ne_zero {n : ℕ} (h : Prime n) : n ≠ 0 :=
Irreducible.ne_zero h
#align nat.prime.ne_zero Nat.Prime.ne_zero
theorem Prime.pos {p : ℕ} (pp : Prime p) : 0 < p :=
Nat.pos_of_ne_zero pp.ne_zero
#align nat.prime.pos Nat.Prime.pos
theorem Prime.two_le : ∀ {p : ℕ}, Prime p → 2 ≤ p
| 0, h => (not_prime_zero h).elim
| 1, h => (not_prime_one h).elim
| _ + 2, _ => le_add_self
#align nat.prime.two_le Nat.Prime.two_le
theorem Prime.one_lt {p : ℕ} : Prime p → 1 < p :=
Prime.two_le
#align nat.prime.one_lt Nat.Prime.one_lt
lemma Prime.one_le {p : ℕ} (hp : p.Prime) : 1 ≤ p := hp.one_lt.le
instance Prime.one_lt' (p : ℕ) [hp : Fact p.Prime] : Fact (1 < p) :=
⟨hp.1.one_lt⟩
#align nat.prime.one_lt' Nat.Prime.one_lt'
theorem Prime.ne_one {p : ℕ} (hp : p.Prime) : p ≠ 1 :=
hp.one_lt.ne'
#align nat.prime.ne_one Nat.Prime.ne_one
theorem Prime.eq_one_or_self_of_dvd {p : ℕ} (pp : p.Prime) (m : ℕ) (hm : m ∣ p) :
m = 1 ∨ m = p := by
obtain ⟨n, hn⟩ := hm
have := pp.isUnit_or_isUnit hn
rw [Nat.isUnit_iff, Nat.isUnit_iff] at this
apply Or.imp_right _ this
rintro rfl
rw [hn, mul_one]
#align nat.prime.eq_one_or_self_of_dvd Nat.Prime.eq_one_or_self_of_dvd
theorem prime_def_lt'' {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, m ∣ p → m = 1 ∨ m = p := by
refine ⟨fun h => ⟨h.two_le, h.eq_one_or_self_of_dvd⟩, fun h => ?_⟩
-- Porting note: needed to make ℕ explicit
have h1 := (@one_lt_two ℕ ..).trans_le h.1
refine ⟨mt Nat.isUnit_iff.mp h1.ne', fun a b hab => ?_⟩
simp only [Nat.isUnit_iff]
apply Or.imp_right _ (h.2 a _)
· rintro rfl
rw [← mul_right_inj' (pos_of_gt h1).ne', ← hab, mul_one]
· rw [hab]
exact dvd_mul_right _ _
#align nat.prime_def_lt'' Nat.prime_def_lt''
theorem prime_def_lt {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m < p, m ∣ p → m = 1 :=
prime_def_lt''.trans <|
and_congr_right fun p2 =>
forall_congr' fun _ =>
⟨fun h l d => (h d).resolve_right (ne_of_lt l), fun h d =>
(le_of_dvd (le_of_succ_le p2) d).lt_or_eq_dec.imp_left fun l => h l d⟩
#align nat.prime_def_lt Nat.prime_def_lt
theorem prime_def_lt' {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, 2 ≤ m → m < p → ¬m ∣ p :=
prime_def_lt.trans <|
and_congr_right fun p2 =>
forall_congr' fun m =>
⟨fun h m2 l d => not_lt_of_ge m2 ((h l d).symm ▸ by decide), fun h l d => by
rcases m with (_ | _ | m)
· rw [eq_zero_of_zero_dvd d] at p2
revert p2
decide
· rfl
· exact (h le_add_self l).elim d⟩
#align nat.prime_def_lt' Nat.prime_def_lt'
theorem prime_def_le_sqrt {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, 2 ≤ m → m ≤ sqrt p → ¬m ∣ p :=
prime_def_lt'.trans <|
and_congr_right fun p2 =>
⟨fun a m m2 l => a m m2 <| lt_of_le_of_lt l <| sqrt_lt_self p2, fun a =>
have : ∀ {m k : ℕ}, m ≤ k → 1 < m → p ≠ m * k := fun {m k} mk m1 e =>
a m m1 (le_sqrt.2 (e.symm ▸ Nat.mul_le_mul_left m mk)) ⟨k, e⟩
fun m m2 l ⟨k, e⟩ => by
rcases le_total m k with mk | km
· exact this mk m2 e
· rw [mul_comm] at e
refine this km (lt_of_mul_lt_mul_right ?_ (zero_le m)) e
rwa [one_mul, ← e]⟩
#align nat.prime_def_le_sqrt Nat.prime_def_le_sqrt
theorem prime_of_coprime (n : ℕ) (h1 : 1 < n) (h : ∀ m < n, m ≠ 0 → n.Coprime m) : Prime n := by
refine prime_def_lt.mpr ⟨h1, fun m mlt mdvd => ?_⟩
have hm : m ≠ 0 := by
rintro rfl
rw [zero_dvd_iff] at mdvd
exact mlt.ne' mdvd
exact (h m mlt hm).symm.eq_one_of_dvd mdvd
#align nat.prime_of_coprime Nat.prime_of_coprime
section
@[local instance]
def decidablePrime1 (p : ℕ) : Decidable (Prime p) :=
decidable_of_iff' _ prime_def_lt'
#align nat.decidable_prime_1 Nat.decidablePrime1
theorem prime_two : Prime 2 := by decide
#align nat.prime_two Nat.prime_two
theorem prime_three : Prime 3 := by decide
#align nat.prime_three Nat.prime_three
theorem prime_five : Prime 5 := by decide
theorem Prime.five_le_of_ne_two_of_ne_three {p : ℕ} (hp : p.Prime) (h_two : p ≠ 2)
(h_three : p ≠ 3) : 5 ≤ p := by
by_contra! h
revert h_two h_three hp
-- Porting note (#11043): was `decide!`
match p with
| 0 => decide
| 1 => decide
| 2 => decide
| 3 => decide
| 4 => decide
| n + 5 => exact (h.not_le le_add_self).elim
#align nat.prime.five_le_of_ne_two_of_ne_three Nat.Prime.five_le_of_ne_two_of_ne_three
end
theorem Prime.pred_pos {p : ℕ} (pp : Prime p) : 0 < pred p :=
lt_pred_iff.2 pp.one_lt
#align nat.prime.pred_pos Nat.Prime.pred_pos
theorem succ_pred_prime {p : ℕ} (pp : Prime p) : succ (pred p) = p :=
succ_pred_eq_of_pos pp.pos
#align nat.succ_pred_prime Nat.succ_pred_prime
theorem dvd_prime {p m : ℕ} (pp : Prime p) : m ∣ p ↔ m = 1 ∨ m = p :=
⟨fun d => pp.eq_one_or_self_of_dvd m d, fun h =>
h.elim (fun e => e.symm ▸ one_dvd _) fun e => e.symm ▸ dvd_rfl⟩
#align nat.dvd_prime Nat.dvd_prime
theorem dvd_prime_two_le {p m : ℕ} (pp : Prime p) (H : 2 ≤ m) : m ∣ p ↔ m = p :=
(dvd_prime pp).trans <| or_iff_right_of_imp <| Not.elim <| ne_of_gt H
#align nat.dvd_prime_two_le Nat.dvd_prime_two_le
theorem prime_dvd_prime_iff_eq {p q : ℕ} (pp : p.Prime) (qp : q.Prime) : p ∣ q ↔ p = q :=
dvd_prime_two_le qp (Prime.two_le pp)
#align nat.prime_dvd_prime_iff_eq Nat.prime_dvd_prime_iff_eq
theorem Prime.not_dvd_one {p : ℕ} (pp : Prime p) : ¬p ∣ 1 :=
Irreducible.not_dvd_one pp
#align nat.prime.not_dvd_one Nat.Prime.not_dvd_one
theorem prime_mul_iff {a b : ℕ} : Nat.Prime (a * b) ↔ a.Prime ∧ b = 1 ∨ b.Prime ∧ a = 1 := by
simp only [iff_self_iff, irreducible_mul_iff, ← irreducible_iff_nat_prime, Nat.isUnit_iff]
#align nat.prime_mul_iff Nat.prime_mul_iff
theorem not_prime_mul {a b : ℕ} (a1 : a ≠ 1) (b1 : b ≠ 1) : ¬Prime (a * b) := by
simp [prime_mul_iff, _root_.not_or, *]
#align nat.not_prime_mul Nat.not_prime_mul
theorem not_prime_mul' {a b n : ℕ} (h : a * b = n) (h₁ : a ≠ 1) (h₂ : b ≠ 1) : ¬Prime n :=
h ▸ not_prime_mul h₁ h₂
#align nat.not_prime_mul' Nat.not_prime_mul'
theorem Prime.dvd_iff_eq {p a : ℕ} (hp : p.Prime) (a1 : a ≠ 1) : a ∣ p ↔ p = a := by
refine ⟨?_, by rintro rfl; rfl⟩
rintro ⟨j, rfl⟩
rcases prime_mul_iff.mp hp with (⟨_, rfl⟩ | ⟨_, rfl⟩)
· exact mul_one _
· exact (a1 rfl).elim
#align nat.prime.dvd_iff_eq Nat.Prime.dvd_iff_eq
section MinFac
theorem minFac_lemma (n k : ℕ) (h : ¬n < k * k) : sqrt n - k < sqrt n + 2 - k :=
(tsub_lt_tsub_iff_right <| le_sqrt.2 <| le_of_not_gt h).2 <| Nat.lt_add_of_pos_right (by decide)
#align nat.min_fac_lemma Nat.minFac_lemma
@[semireducible] def minFacAux (n : ℕ) : ℕ → ℕ
| k =>
if n < k * k then n
else
if k ∣ n then k
else
minFacAux n (k + 2)
termination_by k => sqrt n + 2 - k
decreasing_by simp_wf; apply minFac_lemma n k; assumption
#align nat.min_fac_aux Nat.minFacAux
def minFac (n : ℕ) : ℕ :=
if 2 ∣ n then 2 else minFacAux n 3
#align nat.min_fac Nat.minFac
@[simp]
theorem minFac_zero : minFac 0 = 2 :=
rfl
#align nat.min_fac_zero Nat.minFac_zero
@[simp]
theorem minFac_one : minFac 1 = 1 := by
simp [minFac, minFacAux]
#align nat.min_fac_one Nat.minFac_one
@[simp]
theorem minFac_two : minFac 2 = 2 := by
simp [minFac, minFacAux]
theorem minFac_eq (n : ℕ) : minFac n = if 2 ∣ n then 2 else minFacAux n 3 := rfl
#align nat.min_fac_eq Nat.minFac_eq
private def minFacProp (n k : ℕ) :=
2 ≤ k ∧ k ∣ n ∧ ∀ m, 2 ≤ m → m ∣ n → k ≤ m
theorem minFacAux_has_prop {n : ℕ} (n2 : 2 ≤ n) :
∀ k i, k = 2 * i + 3 → (∀ m, 2 ≤ m → m ∣ n → k ≤ m) → minFacProp n (minFacAux n k)
| k => fun i e a => by
rw [minFacAux]
by_cases h : n < k * k <;> simp [h]
· have pp : Prime n :=
prime_def_le_sqrt.2
⟨n2, fun m m2 l d => not_lt_of_ge l <| lt_of_lt_of_le (sqrt_lt.2 h) (a m m2 d)⟩
exact ⟨n2, dvd_rfl, fun m m2 d => le_of_eq ((dvd_prime_two_le pp m2).1 d).symm⟩
have k2 : 2 ≤ k := by
subst e
apply Nat.le_add_left
by_cases dk : k ∣ n <;> simp [dk]
· exact ⟨k2, dk, a⟩
· refine
have := minFac_lemma n k h
minFacAux_has_prop n2 (k + 2) (i + 1) (by simp [k, e, left_distrib, add_right_comm])
fun m m2 d => ?_
rcases Nat.eq_or_lt_of_le (a m m2 d) with me | ml
· subst me
contradiction
apply (Nat.eq_or_lt_of_le ml).resolve_left
intro me
rw [← me, e] at d
have d' : 2 * (i + 2) ∣ n := d
have := a _ le_rfl (dvd_of_mul_right_dvd d')
rw [e] at this
exact absurd this (by contradiction)
termination_by k => sqrt n + 2 - k
#align nat.min_fac_aux_has_prop Nat.minFacAux_has_prop
| Mathlib/Data/Nat/Prime.lean | 324 | 335 | theorem minFac_has_prop {n : ℕ} (n1 : n ≠ 1) : minFacProp n (minFac n) := by |
by_cases n0 : n = 0
· simp [n0, minFacProp, GE.ge]
have n2 : 2 ≤ n := by
revert n0 n1
rcases n with (_ | _ | _) <;> simp [succ_le_succ]
simp only [minFac_eq, Nat.isUnit_iff]
by_cases d2 : 2 ∣ n <;> simp [d2]
· exact ⟨le_rfl, d2, fun k k2 _ => k2⟩
· refine
minFacAux_has_prop n2 3 0 rfl fun m m2 d => (Nat.eq_or_lt_of_le m2).resolve_left (mt ?_ d2)
exact fun e => e.symm ▸ d
|
import Mathlib.Data.Nat.Cast.WithTop
import Mathlib.RingTheory.Prime
import Mathlib.RingTheory.Polynomial.Content
import Mathlib.RingTheory.Ideal.Quotient
#align_import ring_theory.eisenstein_criterion from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff"
open Polynomial Ideal.Quotient
variable {R : Type*} [CommRing R]
namespace Polynomial
open Polynomial
namespace EisensteinCriterionAux
-- Section for auxiliary lemmas used in the proof of `irreducible_of_eisenstein_criterion`
theorem map_eq_C_mul_X_pow_of_forall_coeff_mem {f : R[X]} {P : Ideal R}
(hfP : ∀ n : ℕ, ↑n < f.degree → f.coeff n ∈ P) :
map (mk P) f = C ((mk P) f.leadingCoeff) * X ^ f.natDegree :=
Polynomial.ext fun n => by
by_cases hf0 : f = 0
· simp [hf0]
rcases lt_trichotomy (n : WithBot ℕ) (degree f) with (h | h | h)
· erw [coeff_map, eq_zero_iff_mem.2 (hfP n h), coeff_C_mul, coeff_X_pow, if_neg,
mul_zero]
rintro rfl
exact not_lt_of_ge degree_le_natDegree h
· have : natDegree f = n := natDegree_eq_of_degree_eq_some h.symm
rw [coeff_C_mul, coeff_X_pow, if_pos this.symm, mul_one, leadingCoeff, this, coeff_map]
· rw [coeff_eq_zero_of_degree_lt, coeff_eq_zero_of_degree_lt]
· refine lt_of_le_of_lt (degree_C_mul_X_pow_le _ _) ?_
rwa [← degree_eq_natDegree hf0]
· exact lt_of_le_of_lt (degree_map_le _ _) h
set_option linter.uppercaseLean3 false in
#align polynomial.eisenstein_criterion_aux.map_eq_C_mul_X_pow_of_forall_coeff_mem Polynomial.EisensteinCriterionAux.map_eq_C_mul_X_pow_of_forall_coeff_mem
theorem le_natDegree_of_map_eq_mul_X_pow {n : ℕ} {P : Ideal R} (hP : P.IsPrime) {q : R[X]}
{c : Polynomial (R ⧸ P)} (hq : map (mk P) q = c * X ^ n) (hc0 : c.degree = 0) :
n ≤ q.natDegree :=
Nat.cast_le.1
(calc
↑n = degree (q.map (mk P)) := by
rw [hq, degree_mul, hc0, zero_add, degree_pow, degree_X, nsmul_one]
_ ≤ degree q := degree_map_le _ _
_ ≤ natDegree q := degree_le_natDegree
)
set_option linter.uppercaseLean3 false in
#align polynomial.eisenstein_criterion_aux.le_nat_degree_of_map_eq_mul_X_pow Polynomial.EisensteinCriterionAux.le_natDegree_of_map_eq_mul_X_pow
theorem eval_zero_mem_ideal_of_eq_mul_X_pow {n : ℕ} {P : Ideal R} {q : R[X]}
{c : Polynomial (R ⧸ P)} (hq : map (mk P) q = c * X ^ n) (hn0 : n ≠ 0) : eval 0 q ∈ P := by
rw [← coeff_zero_eq_eval_zero, ← eq_zero_iff_mem, ← coeff_map, hq,
coeff_zero_eq_eval_zero, eval_mul, eval_pow, eval_X, zero_pow hn0, mul_zero]
set_option linter.uppercaseLean3 false in
#align polynomial.eisenstein_criterion_aux.eval_zero_mem_ideal_of_eq_mul_X_pow Polynomial.EisensteinCriterionAux.eval_zero_mem_ideal_of_eq_mul_X_pow
| Mathlib/RingTheory/EisensteinCriterion.lean | 72 | 78 | theorem isUnit_of_natDegree_eq_zero_of_isPrimitive {p q : R[X]}
-- Porting note: stated using `IsPrimitive` which is defeq to old statement.
(hu : IsPrimitive (p * q)) (hpm : p.natDegree = 0) : IsUnit p := by |
rw [eq_C_of_degree_le_zero (natDegree_eq_zero_iff_degree_le_zero.1 hpm), isUnit_C]
refine hu _ ?_
rw [← eq_C_of_degree_le_zero (natDegree_eq_zero_iff_degree_le_zero.1 hpm)]
exact dvd_mul_right _ _
|
import Mathlib.Topology.Constructions
#align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494"
open Set Filter Function Topology Filter
variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
variable [TopologicalSpace α]
@[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
#align nhds_bind_nhds_within nhds_bind_nhdsWithin
@[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 }
#align eventually_nhds_nhds_within eventually_nhds_nhdsWithin
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
#align eventually_nhds_within_iff eventually_nhdsWithin_iff
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]
#align frequently_nhds_within_iff frequently_nhdsWithin_iff
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]
#align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within
@[simp]
theorem eventually_nhdsWithin_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
#align eventually_nhds_within_nhds_within eventually_nhdsWithin_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
#align nhds_within_eq nhdsWithin_eq
theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by
rw [nhdsWithin, principal_univ, inf_top_eq]
#align nhds_within_univ nhdsWithin_univ
theorem nhdsWithin_hasBasis {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
#align nhds_within_has_basis nhdsWithin_hasBasis
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
#align nhds_within_basis_open nhdsWithin_basis_open
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
#align mem_nhds_within mem_nhdsWithin
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
#align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter
theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) :
s \ t ∈ 𝓝[tᶜ] x :=
diff_mem_inf_principal_compl hs t
#align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl
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 _)
#align diff_mem_nhds_within_diff diff_mem_nhdsWithin_diff
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
#align nhds_of_nhds_within_of_nhds nhds_of_nhdsWithin_of_nhds
theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t :=
eventually_inf_principal
#align mem_nhds_within_iff_eventually mem_nhdsWithin_iff_eventually
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]
#align mem_nhds_within_iff_eventually_eq mem_nhdsWithin_iff_eventuallyEq
theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t :=
set_eventuallyEq_iff_inf_principal.symm
#align nhds_within_eq_iff_eventually_eq nhdsWithin_eq_iff_eventuallyEq
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
#align nhds_within_le_iff nhdsWithin_le_iff
-- Porting note: golfed, dropped an unneeded assumption
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]
#align preimage_nhds_within_coinduced' preimage_nhdsWithin_coinduced'ₓ
theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a :=
mem_inf_of_left h
#align mem_nhds_within_of_mem_nhds mem_nhdsWithin_of_mem_nhds
theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a :=
mem_inf_of_right (mem_principal_self s)
#align self_mem_nhds_within self_mem_nhdsWithin
theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s :=
self_mem_nhdsWithin
#align eventually_mem_nhds_within eventually_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)
#align inter_mem_nhds_within inter_mem_nhdsWithin
theorem nhdsWithin_mono (a : α) {s t : Set α} (h : s ⊆ t) : 𝓝[s] a ≤ 𝓝[t] a :=
inf_le_inf_left _ (principal_mono.mpr h)
#align nhds_within_mono nhdsWithin_mono
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)
#align pure_le_nhds_within pure_le_nhdsWithin
theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t :=
pure_le_nhdsWithin ha ht
#align mem_of_mem_nhds_within mem_of_mem_nhdsWithin
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
#align filter.eventually.self_of_nhds_within Filter.Eventually.self_of_nhdsWithin
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
#align tendsto_const_nhds_within tendsto_const_nhdsWithin
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))
#align nhds_within_restrict'' nhdsWithin_restrict''
theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict'' s <| mem_inf_of_left h
#align nhds_within_restrict' nhdsWithin_restrict'
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₀)
#align nhds_within_restrict nhdsWithin_restrict
theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a :=
nhdsWithin_le_iff.mpr h
#align nhds_within_le_of_mem nhdsWithin_le_of_mem
theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by
rw [← nhdsWithin_univ]
apply nhdsWithin_le_of_mem
exact univ_mem
#align nhds_within_le_nhds nhdsWithin_le_nhds
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₂]
#align nhds_within_eq_nhds_within' nhdsWithin_eq_nhdsWithin'
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₂]
#align nhds_within_eq_nhds_within nhdsWithin_eq_nhdsWithin
@[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a :=
inf_eq_left.trans le_principal_iff
#align nhds_within_eq_nhds nhdsWithin_eq_nhds
theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a :=
nhdsWithin_eq_nhds.2 <| h.mem_nhds ha
#align is_open.nhds_within_eq IsOpen.nhdsWithin_eq
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
#align preimage_nhds_within_coinduced preimage_nhds_within_coinduced
@[simp]
theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq]
#align nhds_within_empty nhdsWithin_empty
theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by
delta nhdsWithin
rw [← inf_sup_left, sup_principal]
#align nhds_within_union nhdsWithin_union
theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) :
𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a :=
Set.Finite.induction_on hI (by simp) fun _ _ hT ↦ by
simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert]
#align nhds_within_bUnion nhdsWithin_biUnion
theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) :
𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by
rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS]
#align nhds_within_sUnion nhdsWithin_sUnion
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]
#align nhds_within_Union nhdsWithin_iUnion
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]
#align nhds_within_inter nhdsWithin_inter
theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by
delta nhdsWithin
rw [← inf_principal, inf_assoc]
#align nhds_within_inter' nhdsWithin_inter'
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
#align nhds_within_inter_of_mem nhdsWithin_inter_of_mem
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]
#align nhds_within_inter_of_mem' nhdsWithin_inter_of_mem'
@[simp]
theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by
rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)]
#align nhds_within_singleton nhdsWithin_singleton
@[simp]
theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by
rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton]
#align nhds_within_insert nhdsWithin_insert
theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by
simp
#align mem_nhds_within_insert mem_nhdsWithin_insert
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]
#align insert_mem_nhds_within_insert insert_mem_nhdsWithin_insert
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]
#align insert_mem_nhds_iff insert_mem_nhds_iff
@[simp]
theorem nhdsWithin_compl_singleton_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by
rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ]
#align nhds_within_compl_singleton_sup_pure nhdsWithin_compl_singleton_sup_pure
theorem nhdsWithin_prod {α : Type*} [TopologicalSpace α] {β : Type*} [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
#align nhds_within_prod nhdsWithin_prod
theorem nhdsWithin_pi_eq' {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {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]
#align nhds_within_pi_eq' nhdsWithin_pi_eq'
theorem nhdsWithin_pi_eq {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {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]
#align nhds_within_pi_eq nhdsWithin_pi_eq
theorem nhdsWithin_pi_univ_eq {ι : Type*} {α : ι → Type*} [Finite ι] [∀ i, TopologicalSpace (α i)]
(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
#align nhds_within_pi_univ_eq nhdsWithin_pi_univ_eq
theorem nhdsWithin_pi_eq_bot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {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]
#align nhds_within_pi_eq_bot nhdsWithin_pi_eq_bot
theorem nhdsWithin_pi_neBot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {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]
#align nhds_within_pi_ne_bot nhdsWithin_pi_neBot
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']
#align filter.tendsto.piecewise_nhds_within Filter.Tendsto.piecewise_nhdsWithin
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₁
#align filter.tendsto.if_nhds_within Filter.Tendsto.if_nhdsWithin
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
#align map_nhds_within map_nhdsWithin
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
#align tendsto_nhds_within_mono_left tendsto_nhdsWithin_mono_left
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)
#align tendsto_nhds_within_mono_right tendsto_nhdsWithin_mono_right
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
#align tendsto_nhds_within_of_tendsto_nhds tendsto_nhdsWithin_of_tendsto_nhds
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
#align eventually_mem_of_tendsto_nhds_within eventually_mem_of_tendsto_nhdsWithin
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
#align tendsto_nhds_of_tendsto_nhds_within tendsto_nhds_of_tendsto_nhdsWithin
theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) :=
mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx
#align nhds_within_ne_bot_of_mem nhdsWithin_neBot_of_mem
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
#align is_closed.mem_of_nhds_within_ne_bot IsClosed.mem_of_nhdsWithin_neBot
theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) :
NeBot (𝓝[range f] x) :=
mem_closure_iff_clusterPt.1 (h x)
#align dense_range.nhds_within_ne_bot DenseRange.nhdsWithin_neBot
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]
#align mem_closure_pi mem_closure_pi
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
#align closure_pi_set closure_pi_set
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]
#align dense_pi dense_pi
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
#align eventually_eq_nhds_within_iff eventuallyEq_nhdsWithin_iff
theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) :
f =ᶠ[𝓝[s] a] g :=
mem_inf_of_right h
#align eventually_eq_nhds_within_of_eq_on eventuallyEq_nhdsWithin_of_eqOn
theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) :
f =ᶠ[𝓝[s] a] g :=
eventuallyEq_nhdsWithin_of_eqOn h
#align set.eq_on.eventually_eq_nhds_within Set.EqOn.eventuallyEq_nhdsWithin
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
#align tendsto_nhds_within_congr tendsto_nhdsWithin_congr
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
#align eventually_nhds_within_of_forall eventually_nhdsWithin_of_forall
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⟩
#align tendsto_nhds_within_of_tendsto_nhds_of_eventually_within tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within
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⟩
#align tendsto_nhds_within_iff tendsto_nhdsWithin_iff
@[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⟩⟩
#align tendsto_nhds_within_range tendsto_nhdsWithin_range
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
#align filter.eventually_eq.eq_of_nhds_within Filter.EventuallyEq.eq_of_nhdsWithin
theorem eventually_nhdsWithin_of_eventually_nhds {α : Type*} [TopologicalSpace α] {s : Set α}
{a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x :=
mem_nhdsWithin_of_mem_nhds h
#align eventually_nhds_within_of_eventually_nhds eventually_nhdsWithin_of_eventually_nhds
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]
#align mem_nhds_within_subtype mem_nhdsWithin_subtype
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
#align nhds_within_subtype 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
#align nhds_within_eq_map_subtype_coe nhdsWithin_eq_map_subtype_coe
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]
#align mem_nhds_subtype_iff_nhds_within mem_nhds_subtype_iff_nhdsWithin
theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by
rw [← map_nhds_subtype_val, mem_map]
#align preimage_coe_mem_nhds_subtype preimage_coe_mem_nhds_subtype
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
#align tendsto_nhds_within_iff_subtype tendsto_nhdsWithin_iff_subtype
variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ]
theorem ContinuousWithinAt.tendsto {f : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) :
Tendsto f (𝓝[s] x) (𝓝 (f x)) :=
h
#align continuous_within_at.tendsto ContinuousWithinAt.tendsto
theorem ContinuousOn.continuousWithinAt {f : α → β} {s : Set α} {x : α} (hf : ContinuousOn f s)
(hx : x ∈ s) : ContinuousWithinAt f s x :=
hf x hx
#align continuous_on.continuous_within_at ContinuousOn.continuousWithinAt
theorem continuousWithinAt_univ (f : α → β) (x : α) :
ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by
rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ]
#align continuous_within_at_univ continuousWithinAt_univ
theorem continuous_iff_continuousOn_univ {f : α → β} : Continuous f ↔ ContinuousOn f univ := by
simp [continuous_iff_continuousAt, ContinuousOn, ContinuousAt, ContinuousWithinAt,
nhdsWithin_univ]
#align continuous_iff_continuous_on_univ continuous_iff_continuousOn_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 _
#align continuous_within_at_iff_continuous_at_restrict continuousWithinAt_iff_continuousAt_restrict
theorem ContinuousWithinAt.tendsto_nhdsWithin {f : α → β} {x : α} {s : Set α} {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⟩
#align continuous_within_at.tendsto_nhds_within ContinuousWithinAt.tendsto_nhdsWithin
theorem ContinuousWithinAt.tendsto_nhdsWithin_image {f : α → β} {x : α} {s : Set α}
(h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝[f '' s] f x) :=
h.tendsto_nhdsWithin (mapsTo_image _ _)
#align continuous_within_at.tendsto_nhds_within_image ContinuousWithinAt.tendsto_nhdsWithin_image
theorem ContinuousWithinAt.prod_map {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) := by
unfold ContinuousWithinAt at *
rw [nhdsWithin_prod_eq, Prod.map, nhds_prod_eq]
exact hf.prod_map hg
#align continuous_within_at.prod_map ContinuousWithinAt.prod_map
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
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
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
#align continuous_within_at_pi continuousWithinAt_pi
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⟩
#align continuous_on_pi continuousOn_pi
@[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
theorem ContinuousWithinAt.fin_insertNth {n} {π : Fin (n + 1) → Type*}
[∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : α → π i} {a : α} {s : Set α}
(hf : ContinuousWithinAt f s a) {g : α → ∀ j : Fin n, π (i.succAbove j)}
(hg : ContinuousWithinAt g s a) : ContinuousWithinAt (fun a => i.insertNth (f a) (g a)) s a :=
hf.tendsto.fin_insertNth i hg
#align continuous_within_at.fin_insert_nth ContinuousWithinAt.fin_insertNth
nonrec theorem ContinuousOn.fin_insertNth {n} {π : Fin (n + 1) → Type*}
[∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : α → π i} {s : Set α}
(hf : ContinuousOn f s) {g : α → ∀ j : Fin n, π (i.succAbove j)} (hg : ContinuousOn g s) :
ContinuousOn (fun a => i.insertNth (f a) (g a)) s := fun a ha =>
(hf a ha).fin_insertNth i (hg a ha)
#align continuous_on.fin_insert_nth ContinuousOn.fin_insertNth
theorem continuousOn_iff {f : α → β} {s : Set α} :
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]
#align continuous_on_iff continuousOn_iff
theorem continuousOn_iff_continuous_restrict {f : α → β} {s : Set α} :
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⟩)
#align continuous_on_iff_continuous_restrict continuousOn_iff_continuous_restrict
-- Porting note: 2 new lemmas
alias ⟨ContinuousOn.restrict, _⟩ := continuousOn_iff_continuous_restrict
theorem ContinuousOn.restrict_mapsTo {f : α → β} {s : Set α} {t : Set β} (hf : ContinuousOn f s)
(ht : MapsTo f s t) : Continuous (ht.restrict f s t) :=
hf.restrict.codRestrict _
theorem continuousOn_iff' {f : α → β} {s : Set α} :
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]
#align continuous_on_iff' continuousOn_iff'
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)
#align continuous_on.mono_dom ContinuousOn.mono_dom
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
#align continuous_on.mono_rng ContinuousOn.mono_rng
theorem continuousOn_iff_isClosed {f : α → β} {s : Set α} :
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]
#align continuous_on_iff_is_closed continuousOn_iff_isClosed
theorem ContinuousOn.prod_map {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⟩ => ContinuousWithinAt.prod_map (hf x hx) (hg y hy)
#align continuous_on.prod_map ContinuousOn.prod_map
theorem continuous_of_cover_nhds {ι : Sort*} {f : α → β} {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)
#align continuous_of_cover_nhds continuous_of_cover_nhds
theorem continuousOn_empty (f : α → β) : ContinuousOn f ∅ := fun _ => False.elim
#align continuous_on_empty continuousOn_empty
@[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
#align continuous_on_singleton continuousOn_singleton
theorem Set.Subsingleton.continuousOn {s : Set α} (hs : s.Subsingleton) (f : α → β) :
ContinuousOn f s :=
hs.induction_on (continuousOn_empty f) (continuousOn_singleton f)
#align set.subsingleton.continuous_on Set.Subsingleton.continuousOn
theorem nhdsWithin_le_comap {x : α} {s : Set α} {f : α → β} (ctsf : ContinuousWithinAt f s x) :
𝓝[s] x ≤ comap f (𝓝[f '' s] f x) :=
ctsf.tendsto_nhdsWithin_image.le_comap
#align nhds_within_le_comap nhdsWithin_le_comap
@[simp]
theorem comap_nhdsWithin_range {α} (f : α → β) (y : β) : comap f (𝓝[range f] y) = comap f (𝓝 y) :=
comap_inf_principal_range
#align comap_nhds_within_range comap_nhdsWithin_range
theorem ContinuousWithinAt.mono {f : α → β} {s t : Set α} {x : α} (h : ContinuousWithinAt f t x)
(hs : s ⊆ t) : ContinuousWithinAt f s x :=
h.mono_left (nhdsWithin_mono x hs)
#align continuous_within_at.mono ContinuousWithinAt.mono
theorem ContinuousWithinAt.mono_of_mem {f : α → β} {s t : Set α} {x : α}
(h : ContinuousWithinAt f t x) (hs : t ∈ 𝓝[s] x) : ContinuousWithinAt f s x :=
h.mono_left (nhdsWithin_le_of_mem hs)
#align continuous_within_at.mono_of_mem ContinuousWithinAt.mono_of_mem
theorem continuousWithinAt_congr_nhds {f : α → β} {s t : Set α} {x : α} (h : 𝓝[s] x = 𝓝[t] x) :
ContinuousWithinAt f s x ↔ ContinuousWithinAt f t x := by
simp only [ContinuousWithinAt, h]
theorem continuousWithinAt_inter' {f : α → β} {s t : Set α} {x : α} (h : t ∈ 𝓝[s] x) :
ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by
simp [ContinuousWithinAt, nhdsWithin_restrict'' s h]
#align continuous_within_at_inter' continuousWithinAt_inter'
theorem continuousWithinAt_inter {f : α → β} {s t : Set α} {x : α} (h : t ∈ 𝓝 x) :
ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by
simp [ContinuousWithinAt, nhdsWithin_restrict' s h]
#align continuous_within_at_inter continuousWithinAt_inter
theorem continuousWithinAt_union {f : α → β} {s t : Set α} {x : α} :
ContinuousWithinAt f (s ∪ t) x ↔ ContinuousWithinAt f s x ∧ ContinuousWithinAt f t x := by
simp only [ContinuousWithinAt, nhdsWithin_union, tendsto_sup]
#align continuous_within_at_union continuousWithinAt_union
theorem ContinuousWithinAt.union {f : α → β} {s t : Set α} {x : α} (hs : ContinuousWithinAt f s x)
(ht : ContinuousWithinAt f t x) : ContinuousWithinAt f (s ∪ t) x :=
continuousWithinAt_union.2 ⟨hs, ht⟩
#align continuous_within_at.union ContinuousWithinAt.union
theorem ContinuousWithinAt.mem_closure_image {f : α → β} {s : Set α} {x : α}
(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)
#align continuous_within_at.mem_closure_image ContinuousWithinAt.mem_closure_image
theorem ContinuousWithinAt.mem_closure {f : α → β} {s : Set α} {x : α} {A : Set β}
(h : ContinuousWithinAt f s x) (hx : x ∈ closure s) (hA : MapsTo f s A) : f x ∈ closure A :=
closure_mono (image_subset_iff.2 hA) (h.mem_closure_image hx)
#align continuous_within_at.mem_closure ContinuousWithinAt.mem_closure
theorem Set.MapsTo.closure_of_continuousWithinAt {f : α → β} {s : Set α} {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
#align set.maps_to.closure_of_continuous_within_at Set.MapsTo.closure_of_continuousWithinAt
theorem Set.MapsTo.closure_of_continuousOn {f : α → β} {s : Set α} {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
#align set.maps_to.closure_of_continuous_on Set.MapsTo.closure_of_continuousOn
theorem ContinuousWithinAt.image_closure {f : α → β} {s : Set α}
(hf : ∀ x ∈ closure s, ContinuousWithinAt f s x) : f '' closure s ⊆ closure (f '' s) :=
((mapsTo_image f s).closure_of_continuousWithinAt hf).image_subset
#align continuous_within_at.image_closure ContinuousWithinAt.image_closure
theorem ContinuousOn.image_closure {f : α → β} {s : Set α} (hf : ContinuousOn f (closure s)) :
f '' closure s ⊆ closure (f '' s) :=
ContinuousWithinAt.image_closure fun x hx => (hf x hx).mono subset_closure
#align continuous_on.image_closure ContinuousOn.image_closure
@[simp]
theorem continuousWithinAt_singleton {f : α → β} {x : α} : ContinuousWithinAt f {x} x := by
simp only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_nhds]
#align continuous_within_at_singleton continuousWithinAt_singleton
@[simp]
theorem continuousWithinAt_insert_self {f : α → β} {x : α} {s : Set α} :
ContinuousWithinAt f (insert x s) x ↔ ContinuousWithinAt f s x := by
simp only [← singleton_union, continuousWithinAt_union, continuousWithinAt_singleton,
true_and_iff]
#align continuous_within_at_insert_self continuousWithinAt_insert_self
alias ⟨_, ContinuousWithinAt.insert_self⟩ := continuousWithinAt_insert_self
#align continuous_within_at.insert_self ContinuousWithinAt.insert_self
theorem ContinuousWithinAt.diff_iff {f : α → β} {s t : Set α} {x : α}
(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⟩
#align continuous_within_at.diff_iff ContinuousWithinAt.diff_iff
@[simp]
theorem continuousWithinAt_diff_self {f : α → β} {s : Set α} {x : α} :
ContinuousWithinAt f (s \ {x}) x ↔ ContinuousWithinAt f s x :=
continuousWithinAt_singleton.diff_iff
#align continuous_within_at_diff_self continuousWithinAt_diff_self
@[simp]
| Mathlib/Topology/ContinuousOn.lean | 830 | 832 | theorem continuousWithinAt_compl_self {f : α → β} {a : α} :
ContinuousWithinAt f {a}ᶜ a ↔ ContinuousAt f a := by |
rw [compl_eq_univ_diff, continuousWithinAt_diff_self, continuousWithinAt_univ]
|
import Mathlib.MeasureTheory.Measure.Doubling
import Mathlib.MeasureTheory.Covering.Vitali
import Mathlib.MeasureTheory.Covering.Differentiation
#align_import measure_theory.covering.density_theorem from "leanprover-community/mathlib"@"5f6e827d81dfbeb6151d7016586ceeb0099b9655"
noncomputable section
open Set Filter Metric MeasureTheory TopologicalSpace
open scoped NNReal Topology
namespace IsUnifLocDoublingMeasure
variable {α : Type*} [MetricSpace α] [MeasurableSpace α] (μ : Measure α)
[IsUnifLocDoublingMeasure μ]
section
variable [SecondCountableTopology α] [BorelSpace α] [IsLocallyFiniteMeasure μ]
open scoped Topology
irreducible_def vitaliFamily (K : ℝ) : VitaliFamily μ := by
let R := scalingScaleOf μ (max (4 * K + 3) 3)
have Rpos : 0 < R := scalingScaleOf_pos _ _
have A : ∀ x : α, ∃ᶠ r in 𝓝[>] (0 : ℝ),
μ (closedBall x (3 * r)) ≤ scalingConstantOf μ (max (4 * K + 3) 3) * μ (closedBall x r) := by
intro x
apply frequently_iff.2 fun {U} hU => ?_
obtain ⟨ε, εpos, hε⟩ := mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 hU
refine ⟨min ε R, hε ⟨lt_min εpos Rpos, min_le_left _ _⟩, ?_⟩
exact measure_mul_le_scalingConstantOf_mul μ
⟨zero_lt_three, le_max_right _ _⟩ (min_le_right _ _)
exact (Vitali.vitaliFamily μ (scalingConstantOf μ (max (4 * K + 3) 3)) A).enlarge (R / 4)
(by linarith)
#align is_unif_loc_doubling_measure.vitali_family IsUnifLocDoublingMeasure.vitaliFamily
theorem closedBall_mem_vitaliFamily_of_dist_le_mul {K : ℝ} {x y : α} {r : ℝ} (h : dist x y ≤ K * r)
(rpos : 0 < r) : closedBall y r ∈ (vitaliFamily μ K).setsAt x := by
let R := scalingScaleOf μ (max (4 * K + 3) 3)
simp only [vitaliFamily, VitaliFamily.enlarge, Vitali.vitaliFamily, mem_union, mem_setOf_eq,
isClosed_ball, true_and_iff, (nonempty_ball.2 rpos).mono ball_subset_interior_closedBall,
measurableSet_closedBall]
by_cases H : closedBall y r ⊆ closedBall x (R / 4)
swap; · exact Or.inr H
left
rcases le_or_lt r R with (hr | hr)
· refine ⟨(K + 1) * r, ?_⟩
constructor
· apply closedBall_subset_closedBall'
rw [dist_comm]
linarith
· have I1 : closedBall x (3 * ((K + 1) * r)) ⊆ closedBall y ((4 * K + 3) * r) := by
apply closedBall_subset_closedBall'
linarith
have I2 : closedBall y ((4 * K + 3) * r) ⊆ closedBall y (max (4 * K + 3) 3 * r) := by
apply closedBall_subset_closedBall
exact mul_le_mul_of_nonneg_right (le_max_left _ _) rpos.le
apply (measure_mono (I1.trans I2)).trans
exact measure_mul_le_scalingConstantOf_mul _
⟨zero_lt_three.trans_le (le_max_right _ _), le_rfl⟩ hr
· refine ⟨R / 4, H, ?_⟩
have : closedBall x (3 * (R / 4)) ⊆ closedBall y r := by
apply closedBall_subset_closedBall'
have A : y ∈ closedBall y r := mem_closedBall_self rpos.le
have B := mem_closedBall'.1 (H A)
linarith
apply (measure_mono this).trans _
refine le_mul_of_one_le_left (zero_le _) ?_
exact ENNReal.one_le_coe_iff.2 (le_max_right _ _)
#align is_unif_loc_doubling_measure.closed_ball_mem_vitali_family_of_dist_le_mul IsUnifLocDoublingMeasure.closedBall_mem_vitaliFamily_of_dist_le_mul
theorem tendsto_closedBall_filterAt {K : ℝ} {x : α} {ι : Type*} {l : Filter ι} (w : ι → α)
(δ : ι → ℝ) (δlim : Tendsto δ l (𝓝[>] 0)) (xmem : ∀ᶠ j in l, x ∈ closedBall (w j) (K * δ j)) :
Tendsto (fun j => closedBall (w j) (δ j)) l ((vitaliFamily μ K).filterAt x) := by
refine (vitaliFamily μ K).tendsto_filterAt_iff.mpr ⟨?_, fun ε hε => ?_⟩
· filter_upwards [xmem, δlim self_mem_nhdsWithin] with j hj h'j
exact closedBall_mem_vitaliFamily_of_dist_le_mul μ hj h'j
· rcases l.eq_or_neBot with rfl | h
· simp
have hK : 0 ≤ K := by
rcases (xmem.and (δlim self_mem_nhdsWithin)).exists with ⟨j, hj, h'j⟩
have : 0 ≤ K * δ j := nonempty_closedBall.1 ⟨x, hj⟩
exact (mul_nonneg_iff_left_nonneg_of_pos (mem_Ioi.1 h'j)).1 this
have δpos := eventually_mem_of_tendsto_nhdsWithin δlim
replace δlim := tendsto_nhds_of_tendsto_nhdsWithin δlim
replace hK : 0 < K + 1 := by linarith
apply (((Metric.tendsto_nhds.mp δlim _ (div_pos hε hK)).and δpos).and xmem).mono
rintro j ⟨⟨hjε, hj₀ : 0 < δ j⟩, hx⟩ y hy
replace hjε : (K + 1) * δ j < ε := by
simpa [abs_eq_self.mpr hj₀.le] using (lt_div_iff' hK).mp hjε
simp only [mem_closedBall] at hx hy ⊢
linarith [dist_triangle_right y x (w j)]
#align is_unif_loc_doubling_measure.tendsto_closed_ball_filter_at IsUnifLocDoublingMeasure.tendsto_closedBall_filterAt
end
section Applications
variable [SecondCountableTopology α] [BorelSpace α] [IsLocallyFiniteMeasure μ] {E : Type*}
[NormedAddCommGroup E]
| Mathlib/MeasureTheory/Covering/DensityTheorem.lean | 146 | 151 | theorem ae_tendsto_measure_inter_div (S : Set α) (K : ℝ) : ∀ᵐ x ∂μ.restrict S,
∀ {ι : Type*} {l : Filter ι} (w : ι → α) (δ : ι → ℝ) (δlim : Tendsto δ l (𝓝[>] 0))
(xmem : ∀ᶠ j in l, x ∈ closedBall (w j) (K * δ j)),
Tendsto (fun j => μ (S ∩ closedBall (w j) (δ j)) / μ (closedBall (w j) (δ j))) l (𝓝 1) := by |
filter_upwards [(vitaliFamily μ K).ae_tendsto_measure_inter_div S] with x hx ι l w δ δlim
xmem using hx.comp (tendsto_closedBall_filterAt μ _ _ δlim xmem)
|
import Mathlib.Data.Nat.Prime
import Mathlib.Data.PNat.Basic
#align_import data.pnat.prime from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f"
namespace PNat
open Nat
def gcd (n m : ℕ+) : ℕ+ :=
⟨Nat.gcd (n : ℕ) (m : ℕ), Nat.gcd_pos_of_pos_left (m : ℕ) n.pos⟩
#align pnat.gcd PNat.gcd
def lcm (n m : ℕ+) : ℕ+ :=
⟨Nat.lcm (n : ℕ) (m : ℕ), by
let h := mul_pos n.pos m.pos
rw [← gcd_mul_lcm (n : ℕ) (m : ℕ), mul_comm] at h
exact pos_of_dvd_of_pos (Dvd.intro (Nat.gcd (n : ℕ) (m : ℕ)) rfl) h⟩
#align pnat.lcm PNat.lcm
@[simp, norm_cast]
theorem gcd_coe (n m : ℕ+) : (gcd n m : ℕ) = Nat.gcd n m :=
rfl
#align pnat.gcd_coe PNat.gcd_coe
@[simp, norm_cast]
theorem lcm_coe (n m : ℕ+) : (lcm n m : ℕ) = Nat.lcm n m :=
rfl
#align pnat.lcm_coe PNat.lcm_coe
theorem gcd_dvd_left (n m : ℕ+) : gcd n m ∣ n :=
dvd_iff.2 (Nat.gcd_dvd_left (n : ℕ) (m : ℕ))
#align pnat.gcd_dvd_left PNat.gcd_dvd_left
theorem gcd_dvd_right (n m : ℕ+) : gcd n m ∣ m :=
dvd_iff.2 (Nat.gcd_dvd_right (n : ℕ) (m : ℕ))
#align pnat.gcd_dvd_right PNat.gcd_dvd_right
theorem dvd_gcd {m n k : ℕ+} (hm : k ∣ m) (hn : k ∣ n) : k ∣ gcd m n :=
dvd_iff.2 (Nat.dvd_gcd (dvd_iff.1 hm) (dvd_iff.1 hn))
#align pnat.dvd_gcd PNat.dvd_gcd
theorem dvd_lcm_left (n m : ℕ+) : n ∣ lcm n m :=
dvd_iff.2 (Nat.dvd_lcm_left (n : ℕ) (m : ℕ))
#align pnat.dvd_lcm_left PNat.dvd_lcm_left
theorem dvd_lcm_right (n m : ℕ+) : m ∣ lcm n m :=
dvd_iff.2 (Nat.dvd_lcm_right (n : ℕ) (m : ℕ))
#align pnat.dvd_lcm_right PNat.dvd_lcm_right
theorem lcm_dvd {m n k : ℕ+} (hm : m ∣ k) (hn : n ∣ k) : lcm m n ∣ k :=
dvd_iff.2 (@Nat.lcm_dvd (m : ℕ) (n : ℕ) (k : ℕ) (dvd_iff.1 hm) (dvd_iff.1 hn))
#align pnat.lcm_dvd PNat.lcm_dvd
theorem gcd_mul_lcm (n m : ℕ+) : gcd n m * lcm n m = n * m :=
Subtype.eq (Nat.gcd_mul_lcm (n : ℕ) (m : ℕ))
#align pnat.gcd_mul_lcm PNat.gcd_mul_lcm
theorem eq_one_of_lt_two {n : ℕ+} : n < 2 → n = 1 := by
intro h; apply le_antisymm; swap
· apply PNat.one_le
· exact PNat.lt_add_one_iff.1 h
#align pnat.eq_one_of_lt_two PNat.eq_one_of_lt_two
section Coprime
def Coprime (m n : ℕ+) : Prop :=
m.gcd n = 1
#align pnat.coprime PNat.Coprime
@[simp, norm_cast]
theorem coprime_coe {m n : ℕ+} : Nat.Coprime ↑m ↑n ↔ m.Coprime n := by
unfold Nat.Coprime Coprime
rw [← coe_inj]
simp
#align pnat.coprime_coe PNat.coprime_coe
theorem Coprime.mul {k m n : ℕ+} : m.Coprime k → n.Coprime k → (m * n).Coprime k := by
repeat rw [← coprime_coe]
rw [mul_coe]
apply Nat.Coprime.mul
#align pnat.coprime.mul PNat.Coprime.mul
theorem Coprime.mul_right {k m n : ℕ+} : k.Coprime m → k.Coprime n → k.Coprime (m * n) := by
repeat rw [← coprime_coe]
rw [mul_coe]
apply Nat.Coprime.mul_right
#align pnat.coprime.mul_right PNat.Coprime.mul_right
theorem gcd_comm {m n : ℕ+} : m.gcd n = n.gcd m := by
apply eq
simp only [gcd_coe]
apply Nat.gcd_comm
#align pnat.gcd_comm PNat.gcd_comm
theorem gcd_eq_left_iff_dvd {m n : ℕ+} : m ∣ n ↔ m.gcd n = m := by
rw [dvd_iff]
rw [Nat.gcd_eq_left_iff_dvd]
rw [← coe_inj]
simp
#align pnat.gcd_eq_left_iff_dvd PNat.gcd_eq_left_iff_dvd
theorem gcd_eq_right_iff_dvd {m n : ℕ+} : m ∣ n ↔ n.gcd m = m := by
rw [gcd_comm]
apply gcd_eq_left_iff_dvd
#align pnat.gcd_eq_right_iff_dvd PNat.gcd_eq_right_iff_dvd
theorem Coprime.gcd_mul_left_cancel (m : ℕ+) {n k : ℕ+} :
k.Coprime n → (k * m).gcd n = m.gcd n := by
intro h; apply eq; simp only [gcd_coe, mul_coe]
apply Nat.Coprime.gcd_mul_left_cancel; simpa
#align pnat.coprime.gcd_mul_left_cancel PNat.Coprime.gcd_mul_left_cancel
theorem Coprime.gcd_mul_right_cancel (m : ℕ+) {n k : ℕ+} :
k.Coprime n → (m * k).gcd n = m.gcd n := by rw [mul_comm]; apply Coprime.gcd_mul_left_cancel
#align pnat.coprime.gcd_mul_right_cancel PNat.Coprime.gcd_mul_right_cancel
theorem Coprime.gcd_mul_left_cancel_right (m : ℕ+) {n k : ℕ+} :
k.Coprime m → m.gcd (k * n) = m.gcd n := by
intro h; iterate 2 rw [gcd_comm]; symm;
apply Coprime.gcd_mul_left_cancel _ h
#align pnat.coprime.gcd_mul_left_cancel_right PNat.Coprime.gcd_mul_left_cancel_right
theorem Coprime.gcd_mul_right_cancel_right (m : ℕ+) {n k : ℕ+} :
k.Coprime m → m.gcd (n * k) = m.gcd n := by
rw [mul_comm];
apply Coprime.gcd_mul_left_cancel_right
#align pnat.coprime.gcd_mul_right_cancel_right PNat.Coprime.gcd_mul_right_cancel_right
@[simp]
theorem one_gcd {n : ℕ+} : gcd 1 n = 1 := by
rw [← gcd_eq_left_iff_dvd]
apply one_dvd
#align pnat.one_gcd PNat.one_gcd
@[simp]
theorem gcd_one {n : ℕ+} : gcd n 1 = 1 := by
rw [gcd_comm]
apply one_gcd
#align pnat.gcd_one PNat.gcd_one
@[symm]
| Mathlib/Data/PNat/Prime.lean | 257 | 260 | theorem Coprime.symm {m n : ℕ+} : m.Coprime n → n.Coprime m := by |
unfold Coprime
rw [gcd_comm]
simp
|
import Mathlib.Algebra.CharP.Two
import Mathlib.Algebra.CharP.Reduced
import Mathlib.Algebra.NeZero
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.NumberTheory.Divisors
import Mathlib.RingTheory.IntegralDomain
import Mathlib.Tactic.Zify
#align_import ring_theory.roots_of_unity.basic from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f"
open scoped Classical Polynomial
noncomputable section
open Polynomial
open Finset
variable {M N G R S F : Type*}
variable [CommMonoid M] [CommMonoid N] [DivisionCommMonoid G]
section rootsOfUnity
variable {k l : ℕ+}
def rootsOfUnity (k : ℕ+) (M : Type*) [CommMonoid M] : Subgroup Mˣ where
carrier := {ζ | ζ ^ (k : ℕ) = 1}
one_mem' := one_pow _
mul_mem' _ _ := by simp_all only [Set.mem_setOf_eq, mul_pow, one_mul]
inv_mem' _ := by simp_all only [Set.mem_setOf_eq, inv_pow, inv_one]
#align roots_of_unity rootsOfUnity
@[simp]
theorem mem_rootsOfUnity (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ ζ ^ (k : ℕ) = 1 :=
Iff.rfl
#align mem_roots_of_unity mem_rootsOfUnity
theorem mem_rootsOfUnity' (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ (ζ : M) ^ (k : ℕ) = 1 := by
rw [mem_rootsOfUnity]; norm_cast
#align mem_roots_of_unity' mem_rootsOfUnity'
@[simp]
theorem rootsOfUnity_one (M : Type*) [CommMonoid M] : rootsOfUnity 1 M = ⊥ := by ext; simp
theorem rootsOfUnity.coe_injective {n : ℕ+} :
Function.Injective (fun x : rootsOfUnity n M ↦ x.val.val) :=
Units.ext.comp fun _ _ => Subtype.eq
#align roots_of_unity.coe_injective rootsOfUnity.coe_injective
@[simps! coe_val]
def rootsOfUnity.mkOfPowEq (ζ : M) {n : ℕ+} (h : ζ ^ (n : ℕ) = 1) : rootsOfUnity n M :=
⟨Units.ofPowEqOne ζ n h n.ne_zero, Units.pow_ofPowEqOne _ _⟩
#align roots_of_unity.mk_of_pow_eq rootsOfUnity.mkOfPowEq
#align roots_of_unity.mk_of_pow_eq_coe_coe rootsOfUnity.val_mkOfPowEq_coe
@[simp]
theorem rootsOfUnity.coe_mkOfPowEq {ζ : M} {n : ℕ+} (h : ζ ^ (n : ℕ) = 1) :
((rootsOfUnity.mkOfPowEq _ h : Mˣ) : M) = ζ :=
rfl
#align roots_of_unity.coe_mk_of_pow_eq rootsOfUnity.coe_mkOfPowEq
theorem rootsOfUnity_le_of_dvd (h : k ∣ l) : rootsOfUnity k M ≤ rootsOfUnity l M := by
obtain ⟨d, rfl⟩ := h
intro ζ h
simp_all only [mem_rootsOfUnity, PNat.mul_coe, pow_mul, one_pow]
#align roots_of_unity_le_of_dvd rootsOfUnity_le_of_dvd
theorem map_rootsOfUnity (f : Mˣ →* Nˣ) (k : ℕ+) : (rootsOfUnity k M).map f ≤ rootsOfUnity k N := by
rintro _ ⟨ζ, h, rfl⟩
simp_all only [← map_pow, mem_rootsOfUnity, SetLike.mem_coe, MonoidHom.map_one]
#align map_roots_of_unity map_rootsOfUnity
@[norm_cast]
theorem rootsOfUnity.coe_pow [CommMonoid R] (ζ : rootsOfUnity k R) (m : ℕ) :
(((ζ ^ m :) : Rˣ) : R) = ((ζ : Rˣ) : R) ^ m := by
rw [Subgroup.coe_pow, Units.val_pow_eq_pow_val]
#align roots_of_unity.coe_pow rootsOfUnity.coe_pow
@[mk_iff IsPrimitiveRoot.iff_def]
structure IsPrimitiveRoot (ζ : M) (k : ℕ) : Prop where
pow_eq_one : ζ ^ (k : ℕ) = 1
dvd_of_pow_eq_one : ∀ l : ℕ, ζ ^ l = 1 → k ∣ l
#align is_primitive_root IsPrimitiveRoot
#align is_primitive_root.iff_def IsPrimitiveRoot.iff_def
@[simps!]
def IsPrimitiveRoot.toRootsOfUnity {μ : M} {n : ℕ+} (h : IsPrimitiveRoot μ n) : rootsOfUnity n M :=
rootsOfUnity.mkOfPowEq μ h.pow_eq_one
#align is_primitive_root.to_roots_of_unity IsPrimitiveRoot.toRootsOfUnity
#align is_primitive_root.coe_to_roots_of_unity_coe IsPrimitiveRoot.val_toRootsOfUnity_coe
#align is_primitive_root.coe_inv_to_roots_of_unity_coe IsPrimitiveRoot.val_inv_toRootsOfUnity_coe
namespace IsPrimitiveRoot
variable {k l : ℕ}
theorem mk_of_lt (ζ : M) (hk : 0 < k) (h1 : ζ ^ k = 1) (h : ∀ l : ℕ, 0 < l → l < k → ζ ^ l ≠ 1) :
IsPrimitiveRoot ζ k := by
refine ⟨h1, fun l hl => ?_⟩
suffices k.gcd l = k by exact this ▸ k.gcd_dvd_right l
rw [eq_iff_le_not_lt]
refine ⟨Nat.le_of_dvd hk (k.gcd_dvd_left l), ?_⟩
intro h'; apply h _ (Nat.gcd_pos_of_pos_left _ hk) h'
exact pow_gcd_eq_one _ h1 hl
#align is_primitive_root.mk_of_lt IsPrimitiveRoot.mk_of_lt
section CommMonoid
variable {ζ : M} {f : F} (h : IsPrimitiveRoot ζ k)
@[nontriviality]
theorem of_subsingleton [Subsingleton M] (x : M) : IsPrimitiveRoot x 1 :=
⟨Subsingleton.elim _ _, fun _ _ => one_dvd _⟩
#align is_primitive_root.of_subsingleton IsPrimitiveRoot.of_subsingleton
theorem pow_eq_one_iff_dvd (l : ℕ) : ζ ^ l = 1 ↔ k ∣ l :=
⟨h.dvd_of_pow_eq_one l, by
rintro ⟨i, rfl⟩; simp only [pow_mul, h.pow_eq_one, one_pow, PNat.mul_coe]⟩
#align is_primitive_root.pow_eq_one_iff_dvd IsPrimitiveRoot.pow_eq_one_iff_dvd
theorem isUnit (h : IsPrimitiveRoot ζ k) (h0 : 0 < k) : IsUnit ζ := by
apply isUnit_of_mul_eq_one ζ (ζ ^ (k - 1))
rw [← pow_succ', tsub_add_cancel_of_le h0.nat_succ_le, h.pow_eq_one]
#align is_primitive_root.is_unit IsPrimitiveRoot.isUnit
theorem pow_ne_one_of_pos_of_lt (h0 : 0 < l) (hl : l < k) : ζ ^ l ≠ 1 :=
mt (Nat.le_of_dvd h0 ∘ h.dvd_of_pow_eq_one _) <| not_le_of_lt hl
#align is_primitive_root.pow_ne_one_of_pos_of_lt IsPrimitiveRoot.pow_ne_one_of_pos_of_lt
theorem ne_one (hk : 1 < k) : ζ ≠ 1 :=
h.pow_ne_one_of_pos_of_lt zero_lt_one hk ∘ (pow_one ζ).trans
#align is_primitive_root.ne_one IsPrimitiveRoot.ne_one
theorem pow_inj (h : IsPrimitiveRoot ζ k) ⦃i j : ℕ⦄ (hi : i < k) (hj : j < k) (H : ζ ^ i = ζ ^ j) :
i = j := by
wlog hij : i ≤ j generalizing i j
· exact (this hj hi H.symm (le_of_not_le hij)).symm
apply le_antisymm hij
rw [← tsub_eq_zero_iff_le]
apply Nat.eq_zero_of_dvd_of_lt _ (lt_of_le_of_lt tsub_le_self hj)
apply h.dvd_of_pow_eq_one
rw [← ((h.isUnit (lt_of_le_of_lt (Nat.zero_le _) hi)).pow i).mul_left_inj, ← pow_add,
tsub_add_cancel_of_le hij, H, one_mul]
#align is_primitive_root.pow_inj IsPrimitiveRoot.pow_inj
theorem one : IsPrimitiveRoot (1 : M) 1 :=
{ pow_eq_one := pow_one _
dvd_of_pow_eq_one := fun _ _ => one_dvd _ }
#align is_primitive_root.one IsPrimitiveRoot.one
@[simp]
theorem one_right_iff : IsPrimitiveRoot ζ 1 ↔ ζ = 1 := by
clear h
constructor
· intro h; rw [← pow_one ζ, h.pow_eq_one]
· rintro rfl; exact one
#align is_primitive_root.one_right_iff IsPrimitiveRoot.one_right_iff
@[simp]
theorem coe_submonoidClass_iff {M B : Type*} [CommMonoid M] [SetLike B M] [SubmonoidClass B M]
{N : B} {ζ : N} : IsPrimitiveRoot (ζ : M) k ↔ IsPrimitiveRoot ζ k := by
simp_rw [iff_def]
norm_cast
#align is_primitive_root.coe_submonoid_class_iff IsPrimitiveRoot.coe_submonoidClass_iff
@[simp]
theorem coe_units_iff {ζ : Mˣ} : IsPrimitiveRoot (ζ : M) k ↔ IsPrimitiveRoot ζ k := by
simp only [iff_def, Units.ext_iff, Units.val_pow_eq_pow_val, Units.val_one]
#align is_primitive_root.coe_units_iff IsPrimitiveRoot.coe_units_iff
lemma isUnit_unit {ζ : M} {n} (hn) (hζ : IsPrimitiveRoot ζ n) :
IsPrimitiveRoot (hζ.isUnit hn).unit n := coe_units_iff.mp hζ
lemma isUnit_unit' {ζ : G} {n} (hn) (hζ : IsPrimitiveRoot ζ n) :
IsPrimitiveRoot (hζ.isUnit hn).unit' n := coe_units_iff.mp hζ
-- Porting note `variable` above already contains `(h : IsPrimitiveRoot ζ k)`
theorem pow_of_coprime (i : ℕ) (hi : i.Coprime k) : IsPrimitiveRoot (ζ ^ i) k := by
by_cases h0 : k = 0
· subst k; simp_all only [pow_one, Nat.coprime_zero_right]
rcases h.isUnit (Nat.pos_of_ne_zero h0) with ⟨ζ, rfl⟩
rw [← Units.val_pow_eq_pow_val]
rw [coe_units_iff] at h ⊢
refine
{ pow_eq_one := by rw [← pow_mul', pow_mul, h.pow_eq_one, one_pow]
dvd_of_pow_eq_one := ?_ }
intro l hl
apply h.dvd_of_pow_eq_one
rw [← pow_one ζ, ← zpow_natCast ζ, ← hi.gcd_eq_one, Nat.gcd_eq_gcd_ab, zpow_add, mul_pow,
← zpow_natCast, ← zpow_mul, mul_right_comm]
simp only [zpow_mul, hl, h.pow_eq_one, one_zpow, one_pow, one_mul, zpow_natCast]
#align is_primitive_root.pow_of_coprime IsPrimitiveRoot.pow_of_coprime
theorem pow_of_prime (h : IsPrimitiveRoot ζ k) {p : ℕ} (hprime : Nat.Prime p) (hdiv : ¬p ∣ k) :
IsPrimitiveRoot (ζ ^ p) k :=
h.pow_of_coprime p (hprime.coprime_iff_not_dvd.2 hdiv)
#align is_primitive_root.pow_of_prime IsPrimitiveRoot.pow_of_prime
theorem pow_iff_coprime (h : IsPrimitiveRoot ζ k) (h0 : 0 < k) (i : ℕ) :
IsPrimitiveRoot (ζ ^ i) k ↔ i.Coprime k := by
refine ⟨?_, h.pow_of_coprime i⟩
intro hi
obtain ⟨a, ha⟩ := i.gcd_dvd_left k
obtain ⟨b, hb⟩ := i.gcd_dvd_right k
suffices b = k by
-- Porting note: was `rwa [this, ← one_mul k, mul_left_inj' h0.ne', eq_comm] at hb`
rw [this, eq_comm, Nat.mul_left_eq_self_iff h0] at hb
rwa [Nat.Coprime]
rw [ha] at hi
rw [mul_comm] at hb
apply Nat.dvd_antisymm ⟨i.gcd k, hb⟩ (hi.dvd_of_pow_eq_one b _)
rw [← pow_mul', ← mul_assoc, ← hb, pow_mul, h.pow_eq_one, one_pow]
#align is_primitive_root.pow_iff_coprime IsPrimitiveRoot.pow_iff_coprime
protected theorem orderOf (ζ : M) : IsPrimitiveRoot ζ (orderOf ζ) :=
⟨pow_orderOf_eq_one ζ, fun _ => orderOf_dvd_of_pow_eq_one⟩
#align is_primitive_root.order_of IsPrimitiveRoot.orderOf
theorem unique {ζ : M} (hk : IsPrimitiveRoot ζ k) (hl : IsPrimitiveRoot ζ l) : k = l :=
Nat.dvd_antisymm (hk.2 _ hl.1) (hl.2 _ hk.1)
#align is_primitive_root.unique IsPrimitiveRoot.unique
theorem eq_orderOf : k = orderOf ζ :=
h.unique (IsPrimitiveRoot.orderOf ζ)
#align is_primitive_root.eq_order_of IsPrimitiveRoot.eq_orderOf
protected theorem iff (hk : 0 < k) :
IsPrimitiveRoot ζ k ↔ ζ ^ k = 1 ∧ ∀ l : ℕ, 0 < l → l < k → ζ ^ l ≠ 1 := by
refine ⟨fun h => ⟨h.pow_eq_one, fun l hl' hl => ?_⟩,
fun ⟨hζ, hl⟩ => IsPrimitiveRoot.mk_of_lt ζ hk hζ hl⟩
rw [h.eq_orderOf] at hl
exact pow_ne_one_of_lt_orderOf' hl'.ne' hl
#align is_primitive_root.iff IsPrimitiveRoot.iff
protected theorem not_iff : ¬IsPrimitiveRoot ζ k ↔ orderOf ζ ≠ k :=
⟨fun h hk => h <| hk ▸ IsPrimitiveRoot.orderOf ζ,
fun h hk => h.symm <| hk.unique <| IsPrimitiveRoot.orderOf ζ⟩
#align is_primitive_root.not_iff IsPrimitiveRoot.not_iff
theorem pow_mul_pow_lcm {ζ' : M} {k' : ℕ} (hζ : IsPrimitiveRoot ζ k) (hζ' : IsPrimitiveRoot ζ' k')
(hk : k ≠ 0) (hk' : k' ≠ 0) :
IsPrimitiveRoot
(ζ ^ (k / Nat.factorizationLCMLeft k k') * ζ' ^ (k' / Nat.factorizationLCMRight k k'))
(Nat.lcm k k') := by
convert IsPrimitiveRoot.orderOf _
convert ((Commute.all ζ ζ').orderOf_mul_pow_eq_lcm
(by simpa [← hζ.eq_orderOf]) (by simpa [← hζ'.eq_orderOf])).symm using 2
all_goals simp [hζ.eq_orderOf, hζ'.eq_orderOf]
| Mathlib/RingTheory/RootsOfUnity/Basic.lean | 488 | 491 | theorem pow_of_dvd (h : IsPrimitiveRoot ζ k) {p : ℕ} (hp : p ≠ 0) (hdiv : p ∣ k) :
IsPrimitiveRoot (ζ ^ p) (k / p) := by |
suffices orderOf (ζ ^ p) = k / p by exact this ▸ IsPrimitiveRoot.orderOf (ζ ^ p)
rw [orderOf_pow' _ hp, ← eq_orderOf h, Nat.gcd_eq_right hdiv]
|
import Mathlib.MeasureTheory.Function.LpOrder
#align_import measure_theory.function.l1_space from "leanprover-community/mathlib"@"ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f"
noncomputable section
open scoped Classical
open Topology ENNReal MeasureTheory NNReal
open Set Filter TopologicalSpace ENNReal EMetric MeasureTheory
variable {α β γ δ : Type*} {m : MeasurableSpace α} {μ ν : Measure α} [MeasurableSpace δ]
variable [NormedAddCommGroup β]
variable [NormedAddCommGroup γ]
namespace MeasureTheory
theorem lintegral_nnnorm_eq_lintegral_edist (f : α → β) :
∫⁻ a, ‖f a‖₊ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [edist_eq_coe_nnnorm]
#align measure_theory.lintegral_nnnorm_eq_lintegral_edist MeasureTheory.lintegral_nnnorm_eq_lintegral_edist
theorem lintegral_norm_eq_lintegral_edist (f : α → β) :
∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by
simp only [ofReal_norm_eq_coe_nnnorm, edist_eq_coe_nnnorm]
#align measure_theory.lintegral_norm_eq_lintegral_edist MeasureTheory.lintegral_norm_eq_lintegral_edist
theorem lintegral_edist_triangle {f g h : α → β} (hf : AEStronglyMeasurable f μ)
(hh : AEStronglyMeasurable h μ) :
(∫⁻ a, edist (f a) (g a) ∂μ) ≤ (∫⁻ a, edist (f a) (h a) ∂μ) + ∫⁻ a, edist (g a) (h a) ∂μ := by
rw [← lintegral_add_left' (hf.edist hh)]
refine lintegral_mono fun a => ?_
apply edist_triangle_right
#align measure_theory.lintegral_edist_triangle MeasureTheory.lintegral_edist_triangle
theorem lintegral_nnnorm_zero : (∫⁻ _ : α, ‖(0 : β)‖₊ ∂μ) = 0 := by simp
#align measure_theory.lintegral_nnnorm_zero MeasureTheory.lintegral_nnnorm_zero
theorem lintegral_nnnorm_add_left {f : α → β} (hf : AEStronglyMeasurable f μ) (g : α → γ) :
∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ = (∫⁻ a, ‖f a‖₊ ∂μ) + ∫⁻ a, ‖g a‖₊ ∂μ :=
lintegral_add_left' hf.ennnorm _
#align measure_theory.lintegral_nnnorm_add_left MeasureTheory.lintegral_nnnorm_add_left
theorem lintegral_nnnorm_add_right (f : α → β) {g : α → γ} (hg : AEStronglyMeasurable g μ) :
∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ = (∫⁻ a, ‖f a‖₊ ∂μ) + ∫⁻ a, ‖g a‖₊ ∂μ :=
lintegral_add_right' _ hg.ennnorm
#align measure_theory.lintegral_nnnorm_add_right MeasureTheory.lintegral_nnnorm_add_right
theorem lintegral_nnnorm_neg {f : α → β} : (∫⁻ a, ‖(-f) a‖₊ ∂μ) = ∫⁻ a, ‖f a‖₊ ∂μ := by
simp only [Pi.neg_apply, nnnorm_neg]
#align measure_theory.lintegral_nnnorm_neg MeasureTheory.lintegral_nnnorm_neg
def HasFiniteIntegral {_ : MeasurableSpace α} (f : α → β) (μ : Measure α := by volume_tac) : Prop :=
(∫⁻ a, ‖f a‖₊ ∂μ) < ∞
#align measure_theory.has_finite_integral MeasureTheory.HasFiniteIntegral
theorem hasFiniteIntegral_def {_ : MeasurableSpace α} (f : α → β) (μ : Measure α) :
HasFiniteIntegral f μ ↔ ((∫⁻ a, ‖f a‖₊ ∂μ) < ∞) :=
Iff.rfl
theorem hasFiniteIntegral_iff_norm (f : α → β) :
HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) < ∞ := by
simp only [HasFiniteIntegral, ofReal_norm_eq_coe_nnnorm]
#align measure_theory.has_finite_integral_iff_norm MeasureTheory.hasFiniteIntegral_iff_norm
theorem hasFiniteIntegral_iff_edist (f : α → β) :
HasFiniteIntegral f μ ↔ (∫⁻ a, edist (f a) 0 ∂μ) < ∞ := by
simp only [hasFiniteIntegral_iff_norm, edist_dist, dist_zero_right]
#align measure_theory.has_finite_integral_iff_edist MeasureTheory.hasFiniteIntegral_iff_edist
theorem hasFiniteIntegral_iff_ofReal {f : α → ℝ} (h : 0 ≤ᵐ[μ] f) :
HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal (f a) ∂μ) < ∞ := by
rw [HasFiniteIntegral, lintegral_nnnorm_eq_of_ae_nonneg h]
#align measure_theory.has_finite_integral_iff_of_real MeasureTheory.hasFiniteIntegral_iff_ofReal
theorem hasFiniteIntegral_iff_ofNNReal {f : α → ℝ≥0} :
HasFiniteIntegral (fun x => (f x : ℝ)) μ ↔ (∫⁻ a, f a ∂μ) < ∞ := by
simp [hasFiniteIntegral_iff_norm]
#align measure_theory.has_finite_integral_iff_of_nnreal MeasureTheory.hasFiniteIntegral_iff_ofNNReal
theorem HasFiniteIntegral.mono {f : α → β} {g : α → γ} (hg : HasFiniteIntegral g μ)
(h : ∀ᵐ a ∂μ, ‖f a‖ ≤ ‖g a‖) : HasFiniteIntegral f μ := by
simp only [hasFiniteIntegral_iff_norm] at *
calc
(∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) ≤ ∫⁻ a : α, ENNReal.ofReal ‖g a‖ ∂μ :=
lintegral_mono_ae (h.mono fun a h => ofReal_le_ofReal h)
_ < ∞ := hg
#align measure_theory.has_finite_integral.mono MeasureTheory.HasFiniteIntegral.mono
theorem HasFiniteIntegral.mono' {f : α → β} {g : α → ℝ} (hg : HasFiniteIntegral g μ)
(h : ∀ᵐ a ∂μ, ‖f a‖ ≤ g a) : HasFiniteIntegral f μ :=
hg.mono <| h.mono fun _x hx => le_trans hx (le_abs_self _)
#align measure_theory.has_finite_integral.mono' MeasureTheory.HasFiniteIntegral.mono'
theorem HasFiniteIntegral.congr' {f : α → β} {g : α → γ} (hf : HasFiniteIntegral f μ)
(h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : HasFiniteIntegral g μ :=
hf.mono <| EventuallyEq.le <| EventuallyEq.symm h
#align measure_theory.has_finite_integral.congr' MeasureTheory.HasFiniteIntegral.congr'
theorem hasFiniteIntegral_congr' {f : α → β} {g : α → γ} (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) :
HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ :=
⟨fun hf => hf.congr' h, fun hg => hg.congr' <| EventuallyEq.symm h⟩
#align measure_theory.has_finite_integral_congr' MeasureTheory.hasFiniteIntegral_congr'
theorem HasFiniteIntegral.congr {f g : α → β} (hf : HasFiniteIntegral f μ) (h : f =ᵐ[μ] g) :
HasFiniteIntegral g μ :=
hf.congr' <| h.fun_comp norm
#align measure_theory.has_finite_integral.congr MeasureTheory.HasFiniteIntegral.congr
theorem hasFiniteIntegral_congr {f g : α → β} (h : f =ᵐ[μ] g) :
HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ :=
hasFiniteIntegral_congr' <| h.fun_comp norm
#align measure_theory.has_finite_integral_congr MeasureTheory.hasFiniteIntegral_congr
theorem hasFiniteIntegral_const_iff {c : β} :
HasFiniteIntegral (fun _ : α => c) μ ↔ c = 0 ∨ μ univ < ∞ := by
simp [HasFiniteIntegral, lintegral_const, lt_top_iff_ne_top, ENNReal.mul_eq_top,
or_iff_not_imp_left]
#align measure_theory.has_finite_integral_const_iff MeasureTheory.hasFiniteIntegral_const_iff
theorem hasFiniteIntegral_const [IsFiniteMeasure μ] (c : β) :
HasFiniteIntegral (fun _ : α => c) μ :=
hasFiniteIntegral_const_iff.2 (Or.inr <| measure_lt_top _ _)
#align measure_theory.has_finite_integral_const MeasureTheory.hasFiniteIntegral_const
theorem hasFiniteIntegral_of_bounded [IsFiniteMeasure μ] {f : α → β} {C : ℝ}
(hC : ∀ᵐ a ∂μ, ‖f a‖ ≤ C) : HasFiniteIntegral f μ :=
(hasFiniteIntegral_const C).mono' hC
#align measure_theory.has_finite_integral_of_bounded MeasureTheory.hasFiniteIntegral_of_bounded
theorem HasFiniteIntegral.of_finite [Finite α] [IsFiniteMeasure μ] {f : α → β} :
HasFiniteIntegral f μ :=
let ⟨_⟩ := nonempty_fintype α
hasFiniteIntegral_of_bounded <| ae_of_all μ <| norm_le_pi_norm f
@[deprecated (since := "2024-02-05")]
alias hasFiniteIntegral_of_fintype := HasFiniteIntegral.of_finite
theorem HasFiniteIntegral.mono_measure {f : α → β} (h : HasFiniteIntegral f ν) (hμ : μ ≤ ν) :
HasFiniteIntegral f μ :=
lt_of_le_of_lt (lintegral_mono' hμ le_rfl) h
#align measure_theory.has_finite_integral.mono_measure MeasureTheory.HasFiniteIntegral.mono_measure
| Mathlib/MeasureTheory/Function/L1Space.lean | 196 | 199 | theorem HasFiniteIntegral.add_measure {f : α → β} (hμ : HasFiniteIntegral f μ)
(hν : HasFiniteIntegral f ν) : HasFiniteIntegral f (μ + ν) := by |
simp only [HasFiniteIntegral, lintegral_add_measure] at *
exact add_lt_top.2 ⟨hμ, hν⟩
|
import Mathlib.NumberTheory.Zsqrtd.Basic
import Mathlib.RingTheory.PrincipalIdealDomain
import Mathlib.Data.Complex.Basic
import Mathlib.Data.Real.Archimedean
#align_import number_theory.zsqrtd.gaussian_int from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
open Zsqrtd Complex
open scoped ComplexConjugate
abbrev GaussianInt : Type :=
Zsqrtd (-1)
#align gaussian_int GaussianInt
local notation "ℤ[i]" => GaussianInt
namespace GaussianInt
instance : Repr ℤ[i] :=
⟨fun x _ => "⟨" ++ repr x.re ++ ", " ++ repr x.im ++ "⟩"⟩
instance instCommRing : CommRing ℤ[i] :=
Zsqrtd.commRing
#align gaussian_int.comm_ring GaussianInt.instCommRing
section
attribute [-instance] Complex.instField -- Avoid making things noncomputable unnecessarily.
def toComplex : ℤ[i] →+* ℂ :=
Zsqrtd.lift ⟨I, by simp⟩
#align gaussian_int.to_complex GaussianInt.toComplex
end
instance : Coe ℤ[i] ℂ :=
⟨toComplex⟩
theorem toComplex_def (x : ℤ[i]) : (x : ℂ) = x.re + x.im * I :=
rfl
#align gaussian_int.to_complex_def GaussianInt.toComplex_def
theorem toComplex_def' (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ) = x + y * I := by simp [toComplex_def]
#align gaussian_int.to_complex_def' GaussianInt.toComplex_def'
theorem toComplex_def₂ (x : ℤ[i]) : (x : ℂ) = ⟨x.re, x.im⟩ := by
apply Complex.ext <;> simp [toComplex_def]
#align gaussian_int.to_complex_def₂ GaussianInt.toComplex_def₂
@[simp]
theorem to_real_re (x : ℤ[i]) : ((x.re : ℤ) : ℝ) = (x : ℂ).re := by simp [toComplex_def]
#align gaussian_int.to_real_re GaussianInt.to_real_re
@[simp]
theorem to_real_im (x : ℤ[i]) : ((x.im : ℤ) : ℝ) = (x : ℂ).im := by simp [toComplex_def]
#align gaussian_int.to_real_im GaussianInt.to_real_im
@[simp]
theorem toComplex_re (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ).re = x := by simp [toComplex_def]
#align gaussian_int.to_complex_re GaussianInt.toComplex_re
@[simp]
theorem toComplex_im (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ).im = y := by simp [toComplex_def]
#align gaussian_int.to_complex_im GaussianInt.toComplex_im
-- Porting note (#10618): @[simp] can prove this
theorem toComplex_add (x y : ℤ[i]) : ((x + y : ℤ[i]) : ℂ) = x + y :=
toComplex.map_add _ _
#align gaussian_int.to_complex_add GaussianInt.toComplex_add
-- Porting note (#10618): @[simp] can prove this
theorem toComplex_mul (x y : ℤ[i]) : ((x * y : ℤ[i]) : ℂ) = x * y :=
toComplex.map_mul _ _
#align gaussian_int.to_complex_mul GaussianInt.toComplex_mul
-- Porting note (#10618): @[simp] can prove this
theorem toComplex_one : ((1 : ℤ[i]) : ℂ) = 1 :=
toComplex.map_one
#align gaussian_int.to_complex_one GaussianInt.toComplex_one
-- Porting note (#10618): @[simp] can prove this
theorem toComplex_zero : ((0 : ℤ[i]) : ℂ) = 0 :=
toComplex.map_zero
#align gaussian_int.to_complex_zero GaussianInt.toComplex_zero
-- Porting note (#10618): @[simp] can prove this
theorem toComplex_neg (x : ℤ[i]) : ((-x : ℤ[i]) : ℂ) = -x :=
toComplex.map_neg _
#align gaussian_int.to_complex_neg GaussianInt.toComplex_neg
-- Porting note (#10618): @[simp] can prove this
theorem toComplex_sub (x y : ℤ[i]) : ((x - y : ℤ[i]) : ℂ) = x - y :=
toComplex.map_sub _ _
#align gaussian_int.to_complex_sub GaussianInt.toComplex_sub
@[simp]
theorem toComplex_star (x : ℤ[i]) : ((star x : ℤ[i]) : ℂ) = conj (x : ℂ) := by
rw [toComplex_def₂, toComplex_def₂]
exact congr_arg₂ _ rfl (Int.cast_neg _)
#align gaussian_int.to_complex_star GaussianInt.toComplex_star
@[simp]
theorem toComplex_inj {x y : ℤ[i]} : (x : ℂ) = y ↔ x = y := by
cases x; cases y; simp [toComplex_def₂]
#align gaussian_int.to_complex_inj GaussianInt.toComplex_inj
lemma toComplex_injective : Function.Injective GaussianInt.toComplex :=
fun ⦃_ _⦄ ↦ toComplex_inj.mp
@[simp]
theorem toComplex_eq_zero {x : ℤ[i]} : (x : ℂ) = 0 ↔ x = 0 := by
rw [← toComplex_zero, toComplex_inj]
#align gaussian_int.to_complex_eq_zero GaussianInt.toComplex_eq_zero
@[simp]
theorem intCast_real_norm (x : ℤ[i]) : (x.norm : ℝ) = Complex.normSq (x : ℂ) := by
rw [Zsqrtd.norm, normSq]; simp
#align gaussian_int.nat_cast_real_norm GaussianInt.intCast_real_norm
@[deprecated (since := "2024-04-17")]
alias int_cast_real_norm := intCast_real_norm
@[simp]
theorem intCast_complex_norm (x : ℤ[i]) : (x.norm : ℂ) = Complex.normSq (x : ℂ) := by
cases x; rw [Zsqrtd.norm, normSq]; simp
#align gaussian_int.nat_cast_complex_norm GaussianInt.intCast_complex_norm
@[deprecated (since := "2024-04-17")]
alias int_cast_complex_norm := intCast_complex_norm
theorem norm_nonneg (x : ℤ[i]) : 0 ≤ norm x :=
Zsqrtd.norm_nonneg (by norm_num) _
#align gaussian_int.norm_nonneg GaussianInt.norm_nonneg
@[simp]
theorem norm_eq_zero {x : ℤ[i]} : norm x = 0 ↔ x = 0 := by rw [← @Int.cast_inj ℝ _ _ _]; simp
#align gaussian_int.norm_eq_zero GaussianInt.norm_eq_zero
theorem norm_pos {x : ℤ[i]} : 0 < norm x ↔ x ≠ 0 := by
rw [lt_iff_le_and_ne, Ne, eq_comm, norm_eq_zero]; simp [norm_nonneg]
#align gaussian_int.norm_pos GaussianInt.norm_pos
theorem abs_natCast_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
Int.natAbs_of_nonneg (norm_nonneg _)
#align gaussian_int.abs_coe_nat_norm GaussianInt.abs_natCast_norm
-- 2024-04-05
@[deprecated] alias abs_coe_nat_norm := abs_natCast_norm
@[simp]
theorem natCast_natAbs_norm {α : Type*} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
rw [← Int.cast_natCast, abs_natCast_norm]
#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.natCast_natAbs_norm
@[deprecated (since := "2024-04-17")]
alias nat_cast_natAbs_norm := natCast_natAbs_norm
theorem natAbs_norm_eq (x : ℤ[i]) :
x.norm.natAbs = x.re.natAbs * x.re.natAbs + x.im.natAbs * x.im.natAbs :=
Int.ofNat.inj <| by simp; simp [Zsqrtd.norm]
#align gaussian_int.nat_abs_norm_eq GaussianInt.natAbs_norm_eq
instance : Div ℤ[i] :=
⟨fun x y =>
let n := (norm y : ℚ)⁻¹
let c := star y
⟨round ((x * c).re * n : ℚ), round ((x * c).im * n : ℚ)⟩⟩
theorem div_def (x y : ℤ[i]) :
x / y = ⟨round ((x * star y).re / norm y : ℚ), round ((x * star y).im / norm y : ℚ)⟩ :=
show Zsqrtd.mk _ _ = _ by simp [div_eq_mul_inv]
#align gaussian_int.div_def GaussianInt.div_def
theorem toComplex_div_re (x y : ℤ[i]) : ((x / y : ℤ[i]) : ℂ).re = round (x / y : ℂ).re := by
rw [div_def, ← @Rat.round_cast ℝ _ _]
simp [-Rat.round_cast, mul_assoc, div_eq_mul_inv, mul_add, add_mul]
#align gaussian_int.to_complex_div_re GaussianInt.toComplex_div_re
| Mathlib/NumberTheory/Zsqrtd/GaussianInt.lean | 217 | 219 | theorem toComplex_div_im (x y : ℤ[i]) : ((x / y : ℤ[i]) : ℂ).im = round (x / y : ℂ).im := by |
rw [div_def, ← @Rat.round_cast ℝ _ _, ← @Rat.round_cast ℝ _ _]
simp [-Rat.round_cast, mul_assoc, div_eq_mul_inv, mul_add, add_mul]
|
import Mathlib.Data.Finset.Pointwise
#align_import combinatorics.additive.e_transform from "leanprover-community/mathlib"@"207c92594599a06e7c134f8d00a030a83e6c7259"
open MulOpposite
open Pointwise
variable {α : Type*} [DecidableEq α]
namespace Finset
section CommGroup
variable [CommGroup α] (e : α) (x : Finset α × Finset α)
@[to_additive (attr := simps) "The **Dyson e-transform**.
Turns `(s, t)` into `(s ∪ e +ᵥ t, t ∩ -e +ᵥ s)`. This reduces the sum of the two sets."]
def mulDysonETransform : Finset α × Finset α :=
(x.1 ∪ e • x.2, x.2 ∩ e⁻¹ • x.1)
#align finset.mul_dyson_e_transform Finset.mulDysonETransform
#align finset.add_dyson_e_transform Finset.addDysonETransform
@[to_additive]
theorem mulDysonETransform.subset :
(mulDysonETransform e x).1 * (mulDysonETransform e x).2 ⊆ x.1 * x.2 := by
refine union_mul_inter_subset_union.trans (union_subset Subset.rfl ?_)
rw [mul_smul_comm, smul_mul_assoc, inv_smul_smul, mul_comm]
#align finset.mul_dyson_e_transform.subset Finset.mulDysonETransform.subset
#align finset.add_dyson_e_transform.subset Finset.addDysonETransform.subset
@[to_additive]
theorem mulDysonETransform.card :
(mulDysonETransform e x).1.card + (mulDysonETransform e x).2.card = x.1.card + x.2.card := by
dsimp
rw [← card_smul_finset e (_ ∩ _), smul_finset_inter, smul_inv_smul, inter_comm,
card_union_add_card_inter, card_smul_finset]
#align finset.mul_dyson_e_transform.card Finset.mulDysonETransform.card
#align finset.add_dyson_e_transform.card Finset.addDysonETransform.card
@[to_additive (attr := simp)]
theorem mulDysonETransform_idem :
mulDysonETransform e (mulDysonETransform e x) = mulDysonETransform e x := by
ext : 1 <;> dsimp
· rw [smul_finset_inter, smul_inv_smul, inter_comm, union_eq_left]
exact inter_subset_union
· rw [smul_finset_union, inv_smul_smul, union_comm, inter_eq_left]
exact inter_subset_union
#align finset.mul_dyson_e_transform_idem Finset.mulDysonETransform_idem
#align finset.add_dyson_e_transform_idem Finset.addDysonETransform_idem
variable {e x}
@[to_additive]
| Mathlib/Combinatorics/Additive/ETransform.lean | 88 | 92 | theorem mulDysonETransform.smul_finset_snd_subset_fst :
e • (mulDysonETransform e x).2 ⊆ (mulDysonETransform e x).1 := by |
dsimp
rw [smul_finset_inter, smul_inv_smul, inter_comm]
exact inter_subset_union
|
import Mathlib.Algebra.Category.ModuleCat.Free
import Mathlib.Topology.Category.Profinite.CofilteredLimit
import Mathlib.Topology.Category.Profinite.Product
import Mathlib.Topology.LocallyConstant.Algebra
import Mathlib.Init.Data.Bool.Lemmas
universe u
namespace Profinite
namespace NobelingProof
variable {I : Type u} [LinearOrder I] [IsWellOrder I (·<·)] (C : Set (I → Bool))
open Profinite ContinuousMap CategoryTheory Limits Opposite Submodule
section Projections
variable (J K L : I → Prop) [∀ i, Decidable (J i)] [∀ i, Decidable (K i)] [∀ i, Decidable (L i)]
def Proj : (I → Bool) → (I → Bool) :=
fun c i ↦ if J i then c i else false
@[simp]
theorem continuous_proj :
Continuous (Proj J : (I → Bool) → (I → Bool)) := by
dsimp (config := { unfoldPartialApp := true }) [Proj]
apply continuous_pi
intro i
split
· apply continuous_apply
· apply continuous_const
def π : Set (I → Bool) := (Proj J) '' C
@[simps!]
def ProjRestrict : C → π C J :=
Set.MapsTo.restrict (Proj J) _ _ (Set.mapsTo_image _ _)
@[simp]
theorem continuous_projRestrict : Continuous (ProjRestrict C J) :=
Continuous.restrict _ (continuous_proj _)
theorem proj_eq_self {x : I → Bool} (h : ∀ i, x i ≠ false → J i) : Proj J x = x := by
ext i
simp only [Proj, ite_eq_left_iff]
contrapose!
simpa only [ne_comm] using h i
theorem proj_prop_eq_self (hh : ∀ i x, x ∈ C → x i ≠ false → J i) : π C J = C := by
ext x
refine ⟨fun ⟨y, hy, h⟩ ↦ ?_, fun h ↦ ⟨x, h, ?_⟩⟩
· rwa [← h, proj_eq_self]; exact (hh · y hy)
· rw [proj_eq_self]; exact (hh · x h)
theorem proj_comp_of_subset (h : ∀ i, J i → K i) : (Proj J ∘ Proj K) =
(Proj J : (I → Bool) → (I → Bool)) := by
ext x i; dsimp [Proj]; aesop
| Mathlib/Topology/Category/Profinite/Nobeling.lean | 129 | 139 | theorem proj_eq_of_subset (h : ∀ i, J i → K i) : π (π C K) J = π C J := by |
ext x
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· obtain ⟨y, ⟨z, hz, rfl⟩, rfl⟩ := h
refine ⟨z, hz, (?_ : _ = (Proj J ∘ Proj K) z)⟩
rw [proj_comp_of_subset J K h]
· obtain ⟨y, hy, rfl⟩ := h
dsimp [π]
rw [← Set.image_comp]
refine ⟨y, hy, ?_⟩
rw [proj_comp_of_subset J K h]
|
import Mathlib.Order.Filter.SmallSets
import Mathlib.Tactic.Monotonicity
import Mathlib.Topology.Compactness.Compact
import Mathlib.Topology.NhdsSet
import Mathlib.Algebra.Group.Defs
#align_import topology.uniform_space.basic from "leanprover-community/mathlib"@"195fcd60ff2bfe392543bceb0ec2adcdb472db4c"
open Set Filter Topology
universe u v ua ub uc ud
variable {α : Type ua} {β : Type ub} {γ : Type uc} {δ : Type ud} {ι : Sort*}
def idRel {α : Type*} :=
{ p : α × α | p.1 = p.2 }
#align id_rel idRel
@[simp]
theorem mem_idRel {a b : α} : (a, b) ∈ @idRel α ↔ a = b :=
Iff.rfl
#align mem_id_rel mem_idRel
@[simp]
theorem idRel_subset {s : Set (α × α)} : idRel ⊆ s ↔ ∀ a, (a, a) ∈ s := by
simp [subset_def]
#align id_rel_subset idRel_subset
def compRel (r₁ r₂ : Set (α × α)) :=
{ p : α × α | ∃ z : α, (p.1, z) ∈ r₁ ∧ (z, p.2) ∈ r₂ }
#align comp_rel compRel
@[inherit_doc]
scoped[Uniformity] infixl:62 " ○ " => compRel
open Uniformity
@[simp]
theorem mem_compRel {α : Type u} {r₁ r₂ : Set (α × α)} {x y : α} :
(x, y) ∈ r₁ ○ r₂ ↔ ∃ z, (x, z) ∈ r₁ ∧ (z, y) ∈ r₂ :=
Iff.rfl
#align mem_comp_rel mem_compRel
@[simp]
theorem swap_idRel : Prod.swap '' idRel = @idRel α :=
Set.ext fun ⟨a, b⟩ => by simpa [image_swap_eq_preimage_swap] using eq_comm
#align swap_id_rel swap_idRel
theorem Monotone.compRel [Preorder β] {f g : β → Set (α × α)} (hf : Monotone f) (hg : Monotone g) :
Monotone fun x => f x ○ g x := fun _ _ h _ ⟨z, h₁, h₂⟩ => ⟨z, hf h h₁, hg h h₂⟩
#align monotone.comp_rel Monotone.compRel
@[mono]
theorem compRel_mono {f g h k : Set (α × α)} (h₁ : f ⊆ h) (h₂ : g ⊆ k) : f ○ g ⊆ h ○ k :=
fun _ ⟨z, h, h'⟩ => ⟨z, h₁ h, h₂ h'⟩
#align comp_rel_mono compRel_mono
theorem prod_mk_mem_compRel {a b c : α} {s t : Set (α × α)} (h₁ : (a, c) ∈ s) (h₂ : (c, b) ∈ t) :
(a, b) ∈ s ○ t :=
⟨c, h₁, h₂⟩
#align prod_mk_mem_comp_rel prod_mk_mem_compRel
@[simp]
theorem id_compRel {r : Set (α × α)} : idRel ○ r = r :=
Set.ext fun ⟨a, b⟩ => by simp
#align id_comp_rel id_compRel
theorem compRel_assoc {r s t : Set (α × α)} : r ○ s ○ t = r ○ (s ○ t) := by
ext ⟨a, b⟩; simp only [mem_compRel]; tauto
#align comp_rel_assoc compRel_assoc
theorem left_subset_compRel {s t : Set (α × α)} (h : idRel ⊆ t) : s ⊆ s ○ t := fun ⟨_x, y⟩ xy_in =>
⟨y, xy_in, h <| rfl⟩
#align left_subset_comp_rel left_subset_compRel
theorem right_subset_compRel {s t : Set (α × α)} (h : idRel ⊆ s) : t ⊆ s ○ t := fun ⟨x, _y⟩ xy_in =>
⟨x, h <| rfl, xy_in⟩
#align right_subset_comp_rel right_subset_compRel
theorem subset_comp_self {s : Set (α × α)} (h : idRel ⊆ s) : s ⊆ s ○ s :=
left_subset_compRel h
#align subset_comp_self subset_comp_self
theorem subset_iterate_compRel {s t : Set (α × α)} (h : idRel ⊆ s) (n : ℕ) :
t ⊆ (s ○ ·)^[n] t := by
induction' n with n ihn generalizing t
exacts [Subset.rfl, (right_subset_compRel h).trans ihn]
#align subset_iterate_comp_rel subset_iterate_compRel
def SymmetricRel (V : Set (α × α)) : Prop :=
Prod.swap ⁻¹' V = V
#align symmetric_rel SymmetricRel
def symmetrizeRel (V : Set (α × α)) : Set (α × α) :=
V ∩ Prod.swap ⁻¹' V
#align symmetrize_rel symmetrizeRel
theorem symmetric_symmetrizeRel (V : Set (α × α)) : SymmetricRel (symmetrizeRel V) := by
simp [SymmetricRel, symmetrizeRel, preimage_inter, inter_comm, ← preimage_comp]
#align symmetric_symmetrize_rel symmetric_symmetrizeRel
theorem symmetrizeRel_subset_self (V : Set (α × α)) : symmetrizeRel V ⊆ V :=
sep_subset _ _
#align symmetrize_rel_subset_self symmetrizeRel_subset_self
@[mono]
theorem symmetrize_mono {V W : Set (α × α)} (h : V ⊆ W) : symmetrizeRel V ⊆ symmetrizeRel W :=
inter_subset_inter h <| preimage_mono h
#align symmetrize_mono symmetrize_mono
theorem SymmetricRel.mk_mem_comm {V : Set (α × α)} (hV : SymmetricRel V) {x y : α} :
(x, y) ∈ V ↔ (y, x) ∈ V :=
Set.ext_iff.1 hV (y, x)
#align symmetric_rel.mk_mem_comm SymmetricRel.mk_mem_comm
theorem SymmetricRel.eq {U : Set (α × α)} (hU : SymmetricRel U) : Prod.swap ⁻¹' U = U :=
hU
#align symmetric_rel.eq SymmetricRel.eq
theorem SymmetricRel.inter {U V : Set (α × α)} (hU : SymmetricRel U) (hV : SymmetricRel V) :
SymmetricRel (U ∩ V) := by rw [SymmetricRel, preimage_inter, hU.eq, hV.eq]
#align symmetric_rel.inter SymmetricRel.inter
structure UniformSpace.Core (α : Type u) where
uniformity : Filter (α × α)
refl : 𝓟 idRel ≤ uniformity
symm : Tendsto Prod.swap uniformity uniformity
comp : (uniformity.lift' fun s => s ○ s) ≤ uniformity
#align uniform_space.core UniformSpace.Core
protected theorem UniformSpace.Core.comp_mem_uniformity_sets {c : Core α} {s : Set (α × α)}
(hs : s ∈ c.uniformity) : ∃ t ∈ c.uniformity, t ○ t ⊆ s :=
(mem_lift'_sets <| monotone_id.compRel monotone_id).mp <| c.comp hs
def UniformSpace.Core.mk' {α : Type u} (U : Filter (α × α)) (refl : ∀ r ∈ U, ∀ (x), (x, x) ∈ r)
(symm : ∀ r ∈ U, Prod.swap ⁻¹' r ∈ U) (comp : ∀ r ∈ U, ∃ t ∈ U, t ○ t ⊆ r) :
UniformSpace.Core α :=
⟨U, fun _r ru => idRel_subset.2 (refl _ ru), symm, fun _r ru =>
let ⟨_s, hs, hsr⟩ := comp _ ru
mem_of_superset (mem_lift' hs) hsr⟩
#align uniform_space.core.mk' UniformSpace.Core.mk'
def UniformSpace.Core.mkOfBasis {α : Type u} (B : FilterBasis (α × α))
(refl : ∀ r ∈ B, ∀ (x), (x, x) ∈ r) (symm : ∀ r ∈ B, ∃ t ∈ B, t ⊆ Prod.swap ⁻¹' r)
(comp : ∀ r ∈ B, ∃ t ∈ B, t ○ t ⊆ r) : UniformSpace.Core α where
uniformity := B.filter
refl := B.hasBasis.ge_iff.mpr fun _r ru => idRel_subset.2 <| refl _ ru
symm := (B.hasBasis.tendsto_iff B.hasBasis).mpr symm
comp := (HasBasis.le_basis_iff (B.hasBasis.lift' (monotone_id.compRel monotone_id))
B.hasBasis).2 comp
#align uniform_space.core.mk_of_basis UniformSpace.Core.mkOfBasis
def UniformSpace.Core.toTopologicalSpace {α : Type u} (u : UniformSpace.Core α) :
TopologicalSpace α :=
.mkOfNhds fun x ↦ .comap (Prod.mk x) u.uniformity
#align uniform_space.core.to_topological_space UniformSpace.Core.toTopologicalSpace
theorem UniformSpace.Core.ext :
∀ {u₁ u₂ : UniformSpace.Core α}, u₁.uniformity = u₂.uniformity → u₁ = u₂
| ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl
#align uniform_space.core_eq UniformSpace.Core.ext
theorem UniformSpace.Core.nhds_toTopologicalSpace {α : Type u} (u : Core α) (x : α) :
@nhds α u.toTopologicalSpace x = comap (Prod.mk x) u.uniformity := by
apply TopologicalSpace.nhds_mkOfNhds_of_hasBasis (fun _ ↦ (basis_sets _).comap _)
· exact fun a U hU ↦ u.refl hU rfl
· intro a U hU
rcases u.comp_mem_uniformity_sets hU with ⟨V, hV, hVU⟩
filter_upwards [preimage_mem_comap hV] with b hb
filter_upwards [preimage_mem_comap hV] with c hc
exact hVU ⟨b, hb, hc⟩
-- the topological structure is embedded in the uniform structure
-- to avoid instance diamond issues. See Note [forgetful inheritance].
class UniformSpace (α : Type u) extends TopologicalSpace α where
protected uniformity : Filter (α × α)
protected symm : Tendsto Prod.swap uniformity uniformity
protected comp : (uniformity.lift' fun s => s ○ s) ≤ uniformity
protected nhds_eq_comap_uniformity (x : α) : 𝓝 x = comap (Prod.mk x) uniformity
#align uniform_space UniformSpace
#noalign uniform_space.mk' -- Can't be a `match_pattern`, so not useful anymore
def uniformity (α : Type u) [UniformSpace α] : Filter (α × α) :=
@UniformSpace.uniformity α _
#align uniformity uniformity
scoped[Uniformity] notation "𝓤[" u "]" => @uniformity _ u
@[inherit_doc] -- Porting note (#11215): TODO: should we drop the `uniformity` def?
scoped[Uniformity] notation "𝓤" => uniformity
abbrev UniformSpace.ofCoreEq {α : Type u} (u : UniformSpace.Core α) (t : TopologicalSpace α)
(h : t = u.toTopologicalSpace) : UniformSpace α where
__ := u
toTopologicalSpace := t
nhds_eq_comap_uniformity x := by rw [h, u.nhds_toTopologicalSpace]
#align uniform_space.of_core_eq UniformSpace.ofCoreEq
abbrev UniformSpace.ofCore {α : Type u} (u : UniformSpace.Core α) : UniformSpace α :=
.ofCoreEq u _ rfl
#align uniform_space.of_core UniformSpace.ofCore
abbrev UniformSpace.toCore (u : UniformSpace α) : UniformSpace.Core α where
__ := u
refl := by
rintro U hU ⟨x, y⟩ (rfl : x = y)
have : Prod.mk x ⁻¹' U ∈ 𝓝 x := by
rw [UniformSpace.nhds_eq_comap_uniformity]
exact preimage_mem_comap hU
convert mem_of_mem_nhds this
theorem UniformSpace.toCore_toTopologicalSpace (u : UniformSpace α) :
u.toCore.toTopologicalSpace = u.toTopologicalSpace :=
TopologicalSpace.ext_nhds fun a ↦ by
rw [u.nhds_eq_comap_uniformity, u.toCore.nhds_toTopologicalSpace]
#align uniform_space.to_core_to_topological_space UniformSpace.toCore_toTopologicalSpace
@[deprecated UniformSpace.mk (since := "2024-03-20")]
def UniformSpace.ofNhdsEqComap (u : UniformSpace.Core α) (_t : TopologicalSpace α)
(h : ∀ x, 𝓝 x = u.uniformity.comap (Prod.mk x)) : UniformSpace α where
__ := u
nhds_eq_comap_uniformity := h
@[ext]
protected theorem UniformSpace.ext {u₁ u₂ : UniformSpace α} (h : 𝓤[u₁] = 𝓤[u₂]) : u₁ = u₂ := by
have : u₁.toTopologicalSpace = u₂.toTopologicalSpace := TopologicalSpace.ext_nhds fun x ↦ by
rw [u₁.nhds_eq_comap_uniformity, u₂.nhds_eq_comap_uniformity]
exact congr_arg (comap _) h
cases u₁; cases u₂; congr
#align uniform_space_eq UniformSpace.ext
protected theorem UniformSpace.ext_iff {u₁ u₂ : UniformSpace α} :
u₁ = u₂ ↔ ∀ s, s ∈ 𝓤[u₁] ↔ s ∈ 𝓤[u₂] :=
⟨fun h _ => h ▸ Iff.rfl, fun h => by ext; exact h _⟩
theorem UniformSpace.ofCoreEq_toCore (u : UniformSpace α) (t : TopologicalSpace α)
(h : t = u.toCore.toTopologicalSpace) : .ofCoreEq u.toCore t h = u :=
UniformSpace.ext rfl
#align uniform_space.of_core_eq_to_core UniformSpace.ofCoreEq_toCore
abbrev UniformSpace.replaceTopology {α : Type*} [i : TopologicalSpace α] (u : UniformSpace α)
(h : i = u.toTopologicalSpace) : UniformSpace α where
__ := u
toTopologicalSpace := i
nhds_eq_comap_uniformity x := by rw [h, u.nhds_eq_comap_uniformity]
#align uniform_space.replace_topology UniformSpace.replaceTopology
theorem UniformSpace.replaceTopology_eq {α : Type*} [i : TopologicalSpace α] (u : UniformSpace α)
(h : i = u.toTopologicalSpace) : u.replaceTopology h = u :=
UniformSpace.ext rfl
#align uniform_space.replace_topology_eq UniformSpace.replaceTopology_eq
-- Porting note: rfc: use `UniformSpace.Core.mkOfBasis`? This will change defeq here and there
def UniformSpace.ofFun {α : Type u} {β : Type v} [OrderedAddCommMonoid β]
(d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x)
(triangle : ∀ x y z, d x z ≤ d x y + d y z)
(half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) :
UniformSpace α :=
.ofCore
{ uniformity := ⨅ r > 0, 𝓟 { x | d x.1 x.2 < r }
refl := le_iInf₂ fun r hr => principal_mono.2 <| idRel_subset.2 fun x => by simpa [refl]
symm := tendsto_iInf_iInf fun r => tendsto_iInf_iInf fun _ => tendsto_principal_principal.2
fun x hx => by rwa [mem_setOf, symm]
comp := le_iInf₂ fun r hr => let ⟨δ, h0, hδr⟩ := half r hr; le_principal_iff.2 <|
mem_of_superset
(mem_lift' <| mem_iInf_of_mem δ <| mem_iInf_of_mem h0 <| mem_principal_self _)
fun (x, z) ⟨y, h₁, h₂⟩ => (triangle _ _ _).trans_lt (hδr _ h₁ _ h₂) }
#align uniform_space.of_fun UniformSpace.ofFun
theorem UniformSpace.hasBasis_ofFun {α : Type u} {β : Type v} [LinearOrderedAddCommMonoid β]
(h₀ : ∃ x : β, 0 < x) (d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x)
(triangle : ∀ x y z, d x z ≤ d x y + d y z)
(half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) :
𝓤[.ofFun d refl symm triangle half].HasBasis ((0 : β) < ·) (fun ε => { x | d x.1 x.2 < ε }) :=
hasBasis_biInf_principal'
(fun ε₁ h₁ ε₂ h₂ => ⟨min ε₁ ε₂, lt_min h₁ h₂, fun _x hx => lt_of_lt_of_le hx (min_le_left _ _),
fun _x hx => lt_of_lt_of_le hx (min_le_right _ _)⟩) h₀
#align uniform_space.has_basis_of_fun UniformSpace.hasBasis_ofFun
section UniformSpace
variable [UniformSpace α]
theorem nhds_eq_comap_uniformity {x : α} : 𝓝 x = (𝓤 α).comap (Prod.mk x) :=
UniformSpace.nhds_eq_comap_uniformity x
#align nhds_eq_comap_uniformity nhds_eq_comap_uniformity
theorem isOpen_uniformity {s : Set α} :
IsOpen s ↔ ∀ x ∈ s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α := by
simp only [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity, mem_comap_prod_mk]
#align is_open_uniformity isOpen_uniformity
theorem refl_le_uniformity : 𝓟 idRel ≤ 𝓤 α :=
(@UniformSpace.toCore α _).refl
#align refl_le_uniformity refl_le_uniformity
instance uniformity.neBot [Nonempty α] : NeBot (𝓤 α) :=
diagonal_nonempty.principal_neBot.mono refl_le_uniformity
#align uniformity.ne_bot uniformity.neBot
theorem refl_mem_uniformity {x : α} {s : Set (α × α)} (h : s ∈ 𝓤 α) : (x, x) ∈ s :=
refl_le_uniformity h rfl
#align refl_mem_uniformity refl_mem_uniformity
theorem mem_uniformity_of_eq {x y : α} {s : Set (α × α)} (h : s ∈ 𝓤 α) (hx : x = y) : (x, y) ∈ s :=
refl_le_uniformity h hx
#align mem_uniformity_of_eq mem_uniformity_of_eq
theorem symm_le_uniformity : map (@Prod.swap α α) (𝓤 _) ≤ 𝓤 _ :=
UniformSpace.symm
#align symm_le_uniformity symm_le_uniformity
theorem comp_le_uniformity : ((𝓤 α).lift' fun s : Set (α × α) => s ○ s) ≤ 𝓤 α :=
UniformSpace.comp
#align comp_le_uniformity comp_le_uniformity
theorem lift'_comp_uniformity : ((𝓤 α).lift' fun s : Set (α × α) => s ○ s) = 𝓤 α :=
comp_le_uniformity.antisymm <| le_lift'.2 fun _s hs ↦ mem_of_superset hs <|
subset_comp_self <| idRel_subset.2 fun _ ↦ refl_mem_uniformity hs
theorem tendsto_swap_uniformity : Tendsto (@Prod.swap α α) (𝓤 α) (𝓤 α) :=
symm_le_uniformity
#align tendsto_swap_uniformity tendsto_swap_uniformity
theorem comp_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, t ○ t ⊆ s :=
(mem_lift'_sets <| monotone_id.compRel monotone_id).mp <| comp_le_uniformity hs
#align comp_mem_uniformity_sets comp_mem_uniformity_sets
theorem eventually_uniformity_iterate_comp_subset {s : Set (α × α)} (hs : s ∈ 𝓤 α) (n : ℕ) :
∀ᶠ t in (𝓤 α).smallSets, (t ○ ·)^[n] t ⊆ s := by
suffices ∀ᶠ t in (𝓤 α).smallSets, t ⊆ s ∧ (t ○ ·)^[n] t ⊆ s from (eventually_and.1 this).2
induction' n with n ihn generalizing s
· simpa
rcases comp_mem_uniformity_sets hs with ⟨t, htU, hts⟩
refine (ihn htU).mono fun U hU => ?_
rw [Function.iterate_succ_apply']
exact
⟨hU.1.trans <| (subset_comp_self <| refl_le_uniformity htU).trans hts,
(compRel_mono hU.1 hU.2).trans hts⟩
#align eventually_uniformity_iterate_comp_subset eventually_uniformity_iterate_comp_subset
theorem eventually_uniformity_comp_subset {s : Set (α × α)} (hs : s ∈ 𝓤 α) :
∀ᶠ t in (𝓤 α).smallSets, t ○ t ⊆ s :=
eventually_uniformity_iterate_comp_subset hs 1
#align eventually_uniformity_comp_subset eventually_uniformity_comp_subset
theorem Filter.Tendsto.uniformity_trans {l : Filter β} {f₁ f₂ f₃ : β → α}
(h₁₂ : Tendsto (fun x => (f₁ x, f₂ x)) l (𝓤 α))
(h₂₃ : Tendsto (fun x => (f₂ x, f₃ x)) l (𝓤 α)) : Tendsto (fun x => (f₁ x, f₃ x)) l (𝓤 α) := by
refine le_trans (le_lift'.2 fun s hs => mem_map.2 ?_) comp_le_uniformity
filter_upwards [mem_map.1 (h₁₂ hs), mem_map.1 (h₂₃ hs)] with x hx₁₂ hx₂₃ using ⟨_, hx₁₂, hx₂₃⟩
#align filter.tendsto.uniformity_trans Filter.Tendsto.uniformity_trans
theorem Filter.Tendsto.uniformity_symm {l : Filter β} {f : β → α × α} (h : Tendsto f l (𝓤 α)) :
Tendsto (fun x => ((f x).2, (f x).1)) l (𝓤 α) :=
tendsto_swap_uniformity.comp h
#align filter.tendsto.uniformity_symm Filter.Tendsto.uniformity_symm
theorem tendsto_diag_uniformity (f : β → α) (l : Filter β) :
Tendsto (fun x => (f x, f x)) l (𝓤 α) := fun _s hs =>
mem_map.2 <| univ_mem' fun _ => refl_mem_uniformity hs
#align tendsto_diag_uniformity tendsto_diag_uniformity
theorem tendsto_const_uniformity {a : α} {f : Filter β} : Tendsto (fun _ => (a, a)) f (𝓤 α) :=
tendsto_diag_uniformity (fun _ => a) f
#align tendsto_const_uniformity tendsto_const_uniformity
theorem symm_of_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) :
∃ t ∈ 𝓤 α, (∀ a b, (a, b) ∈ t → (b, a) ∈ t) ∧ t ⊆ s :=
have : preimage Prod.swap s ∈ 𝓤 α := symm_le_uniformity hs
⟨s ∩ preimage Prod.swap s, inter_mem hs this, fun _ _ ⟨h₁, h₂⟩ => ⟨h₂, h₁⟩, inter_subset_left⟩
#align symm_of_uniformity symm_of_uniformity
theorem comp_symm_of_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) :
∃ t ∈ 𝓤 α, (∀ {a b}, (a, b) ∈ t → (b, a) ∈ t) ∧ t ○ t ⊆ s :=
let ⟨_t, ht₁, ht₂⟩ := comp_mem_uniformity_sets hs
let ⟨t', ht', ht'₁, ht'₂⟩ := symm_of_uniformity ht₁
⟨t', ht', ht'₁ _ _, Subset.trans (monotone_id.compRel monotone_id ht'₂) ht₂⟩
#align comp_symm_of_uniformity comp_symm_of_uniformity
theorem uniformity_le_symm : 𝓤 α ≤ @Prod.swap α α <$> 𝓤 α := by
rw [map_swap_eq_comap_swap]; exact tendsto_swap_uniformity.le_comap
#align uniformity_le_symm uniformity_le_symm
theorem uniformity_eq_symm : 𝓤 α = @Prod.swap α α <$> 𝓤 α :=
le_antisymm uniformity_le_symm symm_le_uniformity
#align uniformity_eq_symm uniformity_eq_symm
@[simp]
theorem comap_swap_uniformity : comap (@Prod.swap α α) (𝓤 α) = 𝓤 α :=
(congr_arg _ uniformity_eq_symm).trans <| comap_map Prod.swap_injective
#align comap_swap_uniformity comap_swap_uniformity
theorem symmetrize_mem_uniformity {V : Set (α × α)} (h : V ∈ 𝓤 α) : symmetrizeRel V ∈ 𝓤 α := by
apply (𝓤 α).inter_sets h
rw [← image_swap_eq_preimage_swap, uniformity_eq_symm]
exact image_mem_map h
#align symmetrize_mem_uniformity symmetrize_mem_uniformity
theorem UniformSpace.hasBasis_symmetric :
(𝓤 α).HasBasis (fun s : Set (α × α) => s ∈ 𝓤 α ∧ SymmetricRel s) id :=
hasBasis_self.2 fun t t_in =>
⟨symmetrizeRel t, symmetrize_mem_uniformity t_in, symmetric_symmetrizeRel t,
symmetrizeRel_subset_self t⟩
#align uniform_space.has_basis_symmetric UniformSpace.hasBasis_symmetric
theorem uniformity_lift_le_swap {g : Set (α × α) → Filter β} {f : Filter β} (hg : Monotone g)
(h : ((𝓤 α).lift fun s => g (preimage Prod.swap s)) ≤ f) : (𝓤 α).lift g ≤ f :=
calc
(𝓤 α).lift g ≤ (Filter.map (@Prod.swap α α) <| 𝓤 α).lift g :=
lift_mono uniformity_le_symm le_rfl
_ ≤ _ := by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]; exact h
#align uniformity_lift_le_swap uniformity_lift_le_swap
theorem uniformity_lift_le_comp {f : Set (α × α) → Filter β} (h : Monotone f) :
((𝓤 α).lift fun s => f (s ○ s)) ≤ (𝓤 α).lift f :=
calc
((𝓤 α).lift fun s => f (s ○ s)) = ((𝓤 α).lift' fun s : Set (α × α) => s ○ s).lift f := by
rw [lift_lift'_assoc]
· exact monotone_id.compRel monotone_id
· exact h
_ ≤ (𝓤 α).lift f := lift_mono comp_le_uniformity le_rfl
#align uniformity_lift_le_comp uniformity_lift_le_comp
-- Porting note (#10756): new lemma
theorem comp3_mem_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, t ○ (t ○ t) ⊆ s :=
let ⟨_t', ht', ht's⟩ := comp_mem_uniformity_sets hs
let ⟨t, ht, htt'⟩ := comp_mem_uniformity_sets ht'
⟨t, ht, (compRel_mono ((subset_comp_self (refl_le_uniformity ht)).trans htt') htt').trans ht's⟩
theorem comp_le_uniformity3 : ((𝓤 α).lift' fun s : Set (α × α) => s ○ (s ○ s)) ≤ 𝓤 α := fun _ h =>
let ⟨_t, htU, ht⟩ := comp3_mem_uniformity h
mem_of_superset (mem_lift' htU) ht
#align comp_le_uniformity3 comp_le_uniformity3
theorem comp_symm_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) :
∃ t ∈ 𝓤 α, SymmetricRel t ∧ t ○ t ⊆ s := by
obtain ⟨w, w_in, w_sub⟩ : ∃ w ∈ 𝓤 α, w ○ w ⊆ s := comp_mem_uniformity_sets hs
use symmetrizeRel w, symmetrize_mem_uniformity w_in, symmetric_symmetrizeRel w
have : symmetrizeRel w ⊆ w := symmetrizeRel_subset_self w
calc symmetrizeRel w ○ symmetrizeRel w
_ ⊆ w ○ w := by mono
_ ⊆ s := w_sub
#align comp_symm_mem_uniformity_sets comp_symm_mem_uniformity_sets
theorem subset_comp_self_of_mem_uniformity {s : Set (α × α)} (h : s ∈ 𝓤 α) : s ⊆ s ○ s :=
subset_comp_self (refl_le_uniformity h)
#align subset_comp_self_of_mem_uniformity subset_comp_self_of_mem_uniformity
theorem comp_comp_symm_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) :
∃ t ∈ 𝓤 α, SymmetricRel t ∧ t ○ t ○ t ⊆ s := by
rcases comp_symm_mem_uniformity_sets hs with ⟨w, w_in, _, w_sub⟩
rcases comp_symm_mem_uniformity_sets w_in with ⟨t, t_in, t_symm, t_sub⟩
use t, t_in, t_symm
have : t ⊆ t ○ t := subset_comp_self_of_mem_uniformity t_in
-- Porting note: Needed the following `have`s to make `mono` work
have ht := Subset.refl t
have hw := Subset.refl w
calc
t ○ t ○ t ⊆ w ○ t := by mono
_ ⊆ w ○ (t ○ t) := by mono
_ ⊆ w ○ w := by mono
_ ⊆ s := w_sub
#align comp_comp_symm_mem_uniformity_sets comp_comp_symm_mem_uniformity_sets
def UniformSpace.ball (x : β) (V : Set (β × β)) : Set β :=
Prod.mk x ⁻¹' V
#align uniform_space.ball UniformSpace.ball
open UniformSpace (ball)
theorem UniformSpace.mem_ball_self (x : α) {V : Set (α × α)} (hV : V ∈ 𝓤 α) : x ∈ ball x V :=
refl_mem_uniformity hV
#align uniform_space.mem_ball_self UniformSpace.mem_ball_self
theorem mem_ball_comp {V W : Set (β × β)} {x y z} (h : y ∈ ball x V) (h' : z ∈ ball y W) :
z ∈ ball x (V ○ W) :=
prod_mk_mem_compRel h h'
#align mem_ball_comp mem_ball_comp
theorem ball_subset_of_comp_subset {V W : Set (β × β)} {x y} (h : x ∈ ball y W) (h' : W ○ W ⊆ V) :
ball x W ⊆ ball y V := fun _z z_in => h' (mem_ball_comp h z_in)
#align ball_subset_of_comp_subset ball_subset_of_comp_subset
theorem ball_mono {V W : Set (β × β)} (h : V ⊆ W) (x : β) : ball x V ⊆ ball x W :=
preimage_mono h
#align ball_mono ball_mono
theorem ball_inter (x : β) (V W : Set (β × β)) : ball x (V ∩ W) = ball x V ∩ ball x W :=
preimage_inter
#align ball_inter ball_inter
theorem ball_inter_left (x : β) (V W : Set (β × β)) : ball x (V ∩ W) ⊆ ball x V :=
ball_mono inter_subset_left x
#align ball_inter_left ball_inter_left
theorem ball_inter_right (x : β) (V W : Set (β × β)) : ball x (V ∩ W) ⊆ ball x W :=
ball_mono inter_subset_right x
#align ball_inter_right ball_inter_right
theorem mem_ball_symmetry {V : Set (β × β)} (hV : SymmetricRel V) {x y} :
x ∈ ball y V ↔ y ∈ ball x V :=
show (x, y) ∈ Prod.swap ⁻¹' V ↔ (x, y) ∈ V by
unfold SymmetricRel at hV
rw [hV]
#align mem_ball_symmetry mem_ball_symmetry
theorem ball_eq_of_symmetry {V : Set (β × β)} (hV : SymmetricRel V) {x} :
ball x V = { y | (y, x) ∈ V } := by
ext y
rw [mem_ball_symmetry hV]
exact Iff.rfl
#align ball_eq_of_symmetry ball_eq_of_symmetry
theorem mem_comp_of_mem_ball {V W : Set (β × β)} {x y z : β} (hV : SymmetricRel V)
(hx : x ∈ ball z V) (hy : y ∈ ball z W) : (x, y) ∈ V ○ W := by
rw [mem_ball_symmetry hV] at hx
exact ⟨z, hx, hy⟩
#align mem_comp_of_mem_ball mem_comp_of_mem_ball
theorem UniformSpace.isOpen_ball (x : α) {V : Set (α × α)} (hV : IsOpen V) : IsOpen (ball x V) :=
hV.preimage <| continuous_const.prod_mk continuous_id
#align uniform_space.is_open_ball UniformSpace.isOpen_ball
theorem UniformSpace.isClosed_ball (x : α) {V : Set (α × α)} (hV : IsClosed V) :
IsClosed (ball x V) :=
hV.preimage <| continuous_const.prod_mk continuous_id
theorem mem_comp_comp {V W M : Set (β × β)} (hW' : SymmetricRel W) {p : β × β} :
p ∈ V ○ M ○ W ↔ (ball p.1 V ×ˢ ball p.2 W ∩ M).Nonempty := by
cases' p with x y
constructor
· rintro ⟨z, ⟨w, hpw, hwz⟩, hzy⟩
exact ⟨(w, z), ⟨hpw, by rwa [mem_ball_symmetry hW']⟩, hwz⟩
· rintro ⟨⟨w, z⟩, ⟨w_in, z_in⟩, hwz⟩
rw [mem_ball_symmetry hW'] at z_in
exact ⟨z, ⟨w, w_in, hwz⟩, z_in⟩
#align mem_comp_comp mem_comp_comp
theorem mem_nhds_uniformity_iff_right {x : α} {s : Set α} :
s ∈ 𝓝 x ↔ { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α := by
simp only [nhds_eq_comap_uniformity, mem_comap_prod_mk]
#align mem_nhds_uniformity_iff_right mem_nhds_uniformity_iff_right
theorem mem_nhds_uniformity_iff_left {x : α} {s : Set α} :
s ∈ 𝓝 x ↔ { p : α × α | p.2 = x → p.1 ∈ s } ∈ 𝓤 α := by
rw [uniformity_eq_symm, mem_nhds_uniformity_iff_right]
simp only [map_def, mem_map, preimage_setOf_eq, Prod.snd_swap, Prod.fst_swap]
#align mem_nhds_uniformity_iff_left mem_nhds_uniformity_iff_left
theorem nhdsWithin_eq_comap_uniformity_of_mem {x : α} {T : Set α} (hx : x ∈ T) (S : Set α) :
𝓝[S] x = (𝓤 α ⊓ 𝓟 (T ×ˢ S)).comap (Prod.mk x) := by
simp [nhdsWithin, nhds_eq_comap_uniformity, hx]
theorem nhdsWithin_eq_comap_uniformity {x : α} (S : Set α) :
𝓝[S] x = (𝓤 α ⊓ 𝓟 (univ ×ˢ S)).comap (Prod.mk x) :=
nhdsWithin_eq_comap_uniformity_of_mem (mem_univ _) S
theorem isOpen_iff_ball_subset {s : Set α} : IsOpen s ↔ ∀ x ∈ s, ∃ V ∈ 𝓤 α, ball x V ⊆ s := by
simp_rw [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity, mem_comap, ball]
#align is_open_iff_ball_subset isOpen_iff_ball_subset
theorem nhds_basis_uniformity' {p : ι → Prop} {s : ι → Set (α × α)} (h : (𝓤 α).HasBasis p s)
{x : α} : (𝓝 x).HasBasis p fun i => ball x (s i) := by
rw [nhds_eq_comap_uniformity]
exact h.comap (Prod.mk x)
#align nhds_basis_uniformity' nhds_basis_uniformity'
theorem nhds_basis_uniformity {p : ι → Prop} {s : ι → Set (α × α)} (h : (𝓤 α).HasBasis p s)
{x : α} : (𝓝 x).HasBasis p fun i => { y | (y, x) ∈ s i } := by
replace h := h.comap Prod.swap
rw [comap_swap_uniformity] at h
exact nhds_basis_uniformity' h
#align nhds_basis_uniformity nhds_basis_uniformity
theorem nhds_eq_comap_uniformity' {x : α} : 𝓝 x = (𝓤 α).comap fun y => (y, x) :=
(nhds_basis_uniformity (𝓤 α).basis_sets).eq_of_same_basis <| (𝓤 α).basis_sets.comap _
#align nhds_eq_comap_uniformity' nhds_eq_comap_uniformity'
| Mathlib/Topology/UniformSpace/Basic.lean | 763 | 765 | theorem UniformSpace.mem_nhds_iff {x : α} {s : Set α} : s ∈ 𝓝 x ↔ ∃ V ∈ 𝓤 α, ball x V ⊆ s := by |
rw [nhds_eq_comap_uniformity, mem_comap]
simp_rw [ball]
|
import Mathlib.Logic.Relation
import Mathlib.Data.List.Forall2
import Mathlib.Data.List.Lex
import Mathlib.Data.List.Infix
#align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734"
-- Make sure we haven't imported `Data.Nat.Order.Basic`
assert_not_exists OrderedSub
universe u v
open Nat
namespace List
variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α}
mk_iff_of_inductive_prop List.Chain List.chain_iff
#align list.chain_iff List.chain_iff
#align list.chain.nil List.Chain.nil
#align list.chain.cons List.Chain.cons
#align list.rel_of_chain_cons List.rel_of_chain_cons
#align list.chain_of_chain_cons List.chain_of_chain_cons
#align list.chain.imp' List.Chain.imp'
#align list.chain.imp List.Chain.imp
theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} :
Chain R a l ↔ Chain S a l :=
⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩
#align list.chain.iff List.Chain.iff
theorem Chain.iff_mem {a : α} {l : List α} :
Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l :=
⟨fun p => by
induction' p with _ a b l r _ IH <;> constructor <;>
[exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩;
exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩],
Chain.imp fun a b h => h.2.2⟩
#align list.chain.iff_mem List.Chain.iff_mem
theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by
simp only [chain_cons, Chain.nil, and_true_iff]
#align list.chain_singleton List.chain_singleton
theorem chain_split {a b : α} {l₁ l₂ : List α} :
Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by
induction' l₁ with x l₁ IH generalizing a <;>
simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc]
#align list.chain_split List.chain_split
@[simp]
theorem chain_append_cons_cons {a b c : α} {l₁ l₂ : List α} :
Chain R a (l₁ ++ b :: c :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ R b c ∧ Chain R c l₂ := by
rw [chain_split, chain_cons]
#align list.chain_append_cons_cons List.chain_append_cons_cons
theorem chain_iff_forall₂ :
∀ {a : α} {l : List α}, Chain R a l ↔ l = [] ∨ Forall₂ R (a :: dropLast l) l
| a, [] => by simp
| a, b :: l => by
by_cases h : l = [] <;>
simp [@chain_iff_forall₂ b l, dropLast, *]
#align list.chain_iff_forall₂ List.chain_iff_forall₂
| Mathlib/Data/List/Chain.lean | 82 | 83 | theorem chain_append_singleton_iff_forall₂ :
Chain R a (l ++ [b]) ↔ Forall₂ R (a :: l) (l ++ [b]) := by | simp [chain_iff_forall₂]
|
import Mathlib.CategoryTheory.Monoidal.Braided.Basic
import Mathlib.CategoryTheory.Monoidal.Discrete
import Mathlib.CategoryTheory.Monoidal.CoherenceLemmas
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
import Mathlib.Algebra.PUnitInstances
#align_import category_theory.monoidal.Mon_ from "leanprover-community/mathlib"@"a836c6dba9bd1ee2a0cdc9af0006a596f243031c"
set_option linter.uppercaseLean3 false
universe v₁ v₂ u₁ u₂ u
open CategoryTheory MonoidalCategory
variable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C]
structure Mon_ where
X : C
one : 𝟙_ C ⟶ X
mul : X ⊗ X ⟶ X
one_mul : (one ▷ X) ≫ mul = (λ_ X).hom := by aesop_cat
mul_one : (X ◁ one) ≫ mul = (ρ_ X).hom := by aesop_cat
-- Obviously there is some flexibility stating this axiom.
-- This one has left- and right-hand sides matching the statement of `Monoid.mul_assoc`,
-- and chooses to place the associator on the right-hand side.
-- The heuristic is that unitors and associators "don't have much weight".
mul_assoc : (mul ▷ X) ≫ mul = (α_ X X X).hom ≫ (X ◁ mul) ≫ mul := by aesop_cat
#align Mon_ Mon_
attribute [reassoc] Mon_.one_mul Mon_.mul_one
attribute [simp] Mon_.one_mul Mon_.mul_one
-- We prove a more general `@[simp]` lemma below.
attribute [reassoc (attr := simp)] Mon_.mul_assoc
namespace Mon_
@[simps]
def trivial : Mon_ C where
X := 𝟙_ C
one := 𝟙 _
mul := (λ_ _).hom
mul_assoc := by coherence
mul_one := by coherence
#align Mon_.trivial Mon_.trivial
instance : Inhabited (Mon_ C) :=
⟨trivial C⟩
variable {C}
variable {M : Mon_ C}
@[simp]
theorem one_mul_hom {Z : C} (f : Z ⟶ M.X) : (M.one ⊗ f) ≫ M.mul = (λ_ Z).hom ≫ f := by
rw [tensorHom_def'_assoc, M.one_mul, leftUnitor_naturality]
#align Mon_.one_mul_hom Mon_.one_mul_hom
@[simp]
theorem mul_one_hom {Z : C} (f : Z ⟶ M.X) : (f ⊗ M.one) ≫ M.mul = (ρ_ Z).hom ≫ f := by
rw [tensorHom_def_assoc, M.mul_one, rightUnitor_naturality]
#align Mon_.mul_one_hom Mon_.mul_one_hom
| Mathlib/CategoryTheory/Monoidal/Mon_.lean | 84 | 85 | theorem assoc_flip :
(M.X ◁ M.mul) ≫ M.mul = (α_ M.X M.X M.X).inv ≫ (M.mul ▷ M.X) ≫ M.mul := by | simp
|
import Mathlib.Algebra.Polynomial.Splits
#align_import algebra.cubic_discriminant from "leanprover-community/mathlib"@"930133160e24036d5242039fe4972407cd4f1222"
noncomputable section
@[ext]
structure Cubic (R : Type*) where
(a b c d : R)
#align cubic Cubic
namespace Cubic
open Cubic Polynomial
open Polynomial
variable {R S F K : Type*}
instance [Inhabited R] : Inhabited (Cubic R) :=
⟨⟨default, default, default, default⟩⟩
instance [Zero R] : Zero (Cubic R) :=
⟨⟨0, 0, 0, 0⟩⟩
section Basic
variable {P Q : Cubic R} {a b c d a' b' c' d' : R} [Semiring R]
def toPoly (P : Cubic R) : R[X] :=
C P.a * X ^ 3 + C P.b * X ^ 2 + C P.c * X + C P.d
#align cubic.to_poly Cubic.toPoly
theorem C_mul_prod_X_sub_C_eq [CommRing S] {w x y z : S} :
C w * (X - C x) * (X - C y) * (X - C z) =
toPoly ⟨w, w * -(x + y + z), w * (x * y + x * z + y * z), w * -(x * y * z)⟩ := by
simp only [toPoly, C_neg, C_add, C_mul]
ring1
set_option linter.uppercaseLean3 false in
#align cubic.C_mul_prod_X_sub_C_eq Cubic.C_mul_prod_X_sub_C_eq
theorem prod_X_sub_C_eq [CommRing S] {x y z : S} :
(X - C x) * (X - C y) * (X - C z) =
toPoly ⟨1, -(x + y + z), x * y + x * z + y * z, -(x * y * z)⟩ := by
rw [← one_mul <| X - C x, ← C_1, C_mul_prod_X_sub_C_eq, one_mul, one_mul, one_mul]
set_option linter.uppercaseLean3 false in
#align cubic.prod_X_sub_C_eq Cubic.prod_X_sub_C_eq
section Coeff
private theorem coeffs : (∀ n > 3, P.toPoly.coeff n = 0) ∧ P.toPoly.coeff 3 = P.a ∧
P.toPoly.coeff 2 = P.b ∧ P.toPoly.coeff 1 = P.c ∧ P.toPoly.coeff 0 = P.d := by
simp only [toPoly, coeff_add, coeff_C, coeff_C_mul_X, coeff_C_mul_X_pow]
set_option tactic.skipAssignedInstances false in norm_num
intro n hn
repeat' rw [if_neg]
any_goals linarith only [hn]
repeat' rw [zero_add]
@[simp]
theorem coeff_eq_zero {n : ℕ} (hn : 3 < n) : P.toPoly.coeff n = 0 :=
coeffs.1 n hn
#align cubic.coeff_eq_zero Cubic.coeff_eq_zero
@[simp]
theorem coeff_eq_a : P.toPoly.coeff 3 = P.a :=
coeffs.2.1
#align cubic.coeff_eq_a Cubic.coeff_eq_a
@[simp]
theorem coeff_eq_b : P.toPoly.coeff 2 = P.b :=
coeffs.2.2.1
#align cubic.coeff_eq_b Cubic.coeff_eq_b
@[simp]
theorem coeff_eq_c : P.toPoly.coeff 1 = P.c :=
coeffs.2.2.2.1
#align cubic.coeff_eq_c Cubic.coeff_eq_c
@[simp]
theorem coeff_eq_d : P.toPoly.coeff 0 = P.d :=
coeffs.2.2.2.2
#align cubic.coeff_eq_d Cubic.coeff_eq_d
theorem a_of_eq (h : P.toPoly = Q.toPoly) : P.a = Q.a := by rw [← coeff_eq_a, h, coeff_eq_a]
#align cubic.a_of_eq Cubic.a_of_eq
theorem b_of_eq (h : P.toPoly = Q.toPoly) : P.b = Q.b := by rw [← coeff_eq_b, h, coeff_eq_b]
#align cubic.b_of_eq Cubic.b_of_eq
theorem c_of_eq (h : P.toPoly = Q.toPoly) : P.c = Q.c := by rw [← coeff_eq_c, h, coeff_eq_c]
#align cubic.c_of_eq Cubic.c_of_eq
theorem d_of_eq (h : P.toPoly = Q.toPoly) : P.d = Q.d := by rw [← coeff_eq_d, h, coeff_eq_d]
#align cubic.d_of_eq Cubic.d_of_eq
theorem toPoly_injective (P Q : Cubic R) : P.toPoly = Q.toPoly ↔ P = Q :=
⟨fun h ↦ Cubic.ext P Q (a_of_eq h) (b_of_eq h) (c_of_eq h) (d_of_eq h), congr_arg toPoly⟩
#align cubic.to_poly_injective Cubic.toPoly_injective
theorem of_a_eq_zero (ha : P.a = 0) : P.toPoly = C P.b * X ^ 2 + C P.c * X + C P.d := by
rw [toPoly, ha, C_0, zero_mul, zero_add]
#align cubic.of_a_eq_zero Cubic.of_a_eq_zero
theorem of_a_eq_zero' : toPoly ⟨0, b, c, d⟩ = C b * X ^ 2 + C c * X + C d :=
of_a_eq_zero rfl
#align cubic.of_a_eq_zero' Cubic.of_a_eq_zero'
theorem of_b_eq_zero (ha : P.a = 0) (hb : P.b = 0) : P.toPoly = C P.c * X + C P.d := by
rw [of_a_eq_zero ha, hb, C_0, zero_mul, zero_add]
#align cubic.of_b_eq_zero Cubic.of_b_eq_zero
theorem of_b_eq_zero' : toPoly ⟨0, 0, c, d⟩ = C c * X + C d :=
of_b_eq_zero rfl rfl
#align cubic.of_b_eq_zero' Cubic.of_b_eq_zero'
theorem of_c_eq_zero (ha : P.a = 0) (hb : P.b = 0) (hc : P.c = 0) : P.toPoly = C P.d := by
rw [of_b_eq_zero ha hb, hc, C_0, zero_mul, zero_add]
#align cubic.of_c_eq_zero Cubic.of_c_eq_zero
theorem of_c_eq_zero' : toPoly ⟨0, 0, 0, d⟩ = C d :=
of_c_eq_zero rfl rfl rfl
#align cubic.of_c_eq_zero' Cubic.of_c_eq_zero'
theorem of_d_eq_zero (ha : P.a = 0) (hb : P.b = 0) (hc : P.c = 0) (hd : P.d = 0) :
P.toPoly = 0 := by
rw [of_c_eq_zero ha hb hc, hd, C_0]
#align cubic.of_d_eq_zero Cubic.of_d_eq_zero
theorem of_d_eq_zero' : (⟨0, 0, 0, 0⟩ : Cubic R).toPoly = 0 :=
of_d_eq_zero rfl rfl rfl rfl
#align cubic.of_d_eq_zero' Cubic.of_d_eq_zero'
theorem zero : (0 : Cubic R).toPoly = 0 :=
of_d_eq_zero'
#align cubic.zero Cubic.zero
theorem toPoly_eq_zero_iff (P : Cubic R) : P.toPoly = 0 ↔ P = 0 := by
rw [← zero, toPoly_injective]
#align cubic.to_poly_eq_zero_iff Cubic.toPoly_eq_zero_iff
private theorem ne_zero (h0 : P.a ≠ 0 ∨ P.b ≠ 0 ∨ P.c ≠ 0 ∨ P.d ≠ 0) : P.toPoly ≠ 0 := by
contrapose! h0
rw [(toPoly_eq_zero_iff P).mp h0]
exact ⟨rfl, rfl, rfl, rfl⟩
theorem ne_zero_of_a_ne_zero (ha : P.a ≠ 0) : P.toPoly ≠ 0 :=
(or_imp.mp ne_zero).1 ha
#align cubic.ne_zero_of_a_ne_zero Cubic.ne_zero_of_a_ne_zero
theorem ne_zero_of_b_ne_zero (hb : P.b ≠ 0) : P.toPoly ≠ 0 :=
(or_imp.mp (or_imp.mp ne_zero).2).1 hb
#align cubic.ne_zero_of_b_ne_zero Cubic.ne_zero_of_b_ne_zero
theorem ne_zero_of_c_ne_zero (hc : P.c ≠ 0) : P.toPoly ≠ 0 :=
(or_imp.mp (or_imp.mp (or_imp.mp ne_zero).2).2).1 hc
#align cubic.ne_zero_of_c_ne_zero Cubic.ne_zero_of_c_ne_zero
theorem ne_zero_of_d_ne_zero (hd : P.d ≠ 0) : P.toPoly ≠ 0 :=
(or_imp.mp (or_imp.mp (or_imp.mp ne_zero).2).2).2 hd
#align cubic.ne_zero_of_d_ne_zero Cubic.ne_zero_of_d_ne_zero
@[simp]
theorem leadingCoeff_of_a_ne_zero (ha : P.a ≠ 0) : P.toPoly.leadingCoeff = P.a :=
leadingCoeff_cubic ha
#align cubic.leading_coeff_of_a_ne_zero Cubic.leadingCoeff_of_a_ne_zero
@[simp]
theorem leadingCoeff_of_a_ne_zero' (ha : a ≠ 0) : (toPoly ⟨a, b, c, d⟩).leadingCoeff = a :=
leadingCoeff_of_a_ne_zero ha
#align cubic.leading_coeff_of_a_ne_zero' Cubic.leadingCoeff_of_a_ne_zero'
@[simp]
theorem leadingCoeff_of_b_ne_zero (ha : P.a = 0) (hb : P.b ≠ 0) : P.toPoly.leadingCoeff = P.b := by
rw [of_a_eq_zero ha, leadingCoeff_quadratic hb]
#align cubic.leading_coeff_of_b_ne_zero Cubic.leadingCoeff_of_b_ne_zero
@[simp]
theorem leadingCoeff_of_b_ne_zero' (hb : b ≠ 0) : (toPoly ⟨0, b, c, d⟩).leadingCoeff = b :=
leadingCoeff_of_b_ne_zero rfl hb
#align cubic.leading_coeff_of_b_ne_zero' Cubic.leadingCoeff_of_b_ne_zero'
@[simp]
theorem leadingCoeff_of_c_ne_zero (ha : P.a = 0) (hb : P.b = 0) (hc : P.c ≠ 0) :
P.toPoly.leadingCoeff = P.c := by
rw [of_b_eq_zero ha hb, leadingCoeff_linear hc]
#align cubic.leading_coeff_of_c_ne_zero Cubic.leadingCoeff_of_c_ne_zero
@[simp]
theorem leadingCoeff_of_c_ne_zero' (hc : c ≠ 0) : (toPoly ⟨0, 0, c, d⟩).leadingCoeff = c :=
leadingCoeff_of_c_ne_zero rfl rfl hc
#align cubic.leading_coeff_of_c_ne_zero' Cubic.leadingCoeff_of_c_ne_zero'
@[simp]
| Mathlib/Algebra/CubicDiscriminant.lean | 231 | 233 | theorem leadingCoeff_of_c_eq_zero (ha : P.a = 0) (hb : P.b = 0) (hc : P.c = 0) :
P.toPoly.leadingCoeff = P.d := by |
rw [of_c_eq_zero ha hb hc, leadingCoeff_C]
|
import Mathlib.CategoryTheory.Subobject.Limits
#align_import algebra.homology.image_to_kernel from "leanprover-community/mathlib"@"618ea3d5c99240cd7000d8376924906a148bf9ff"
universe v u w
open CategoryTheory CategoryTheory.Limits
variable {ι : Type*}
variable {V : Type u} [Category.{v} V] [HasZeroMorphisms V]
open scoped Classical
noncomputable section
section
variable {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g]
theorem image_le_kernel (w : f ≫ g = 0) : imageSubobject f ≤ kernelSubobject g :=
imageSubobject_le_mk _ _ (kernel.lift _ _ w) (by simp)
#align image_le_kernel image_le_kernel
def imageToKernel (w : f ≫ g = 0) : (imageSubobject f : V) ⟶ (kernelSubobject g : V) :=
Subobject.ofLE _ _ (image_le_kernel _ _ w)
#align image_to_kernel imageToKernel
instance (w : f ≫ g = 0) : Mono (imageToKernel f g w) := by
dsimp only [imageToKernel]
infer_instance
@[simp]
theorem subobject_ofLE_as_imageToKernel (w : f ≫ g = 0) (h) :
Subobject.ofLE (imageSubobject f) (kernelSubobject g) h = imageToKernel f g w :=
rfl
#align subobject_of_le_as_image_to_kernel subobject_ofLE_as_imageToKernel
attribute [local instance] ConcreteCategory.instFunLike
-- Porting note: removed elementwise attribute which does not seem to be helpful here
-- a more suitable lemma is added below
@[reassoc (attr := simp)]
theorem imageToKernel_arrow (w : f ≫ g = 0) :
imageToKernel f g w ≫ (kernelSubobject g).arrow = (imageSubobject f).arrow := by
simp [imageToKernel]
#align image_to_kernel_arrow imageToKernel_arrow
@[simp]
lemma imageToKernel_arrow_apply [ConcreteCategory V] (w : f ≫ g = 0)
(x : (forget V).obj (Subobject.underlying.obj (imageSubobject f))) :
(kernelSubobject g).arrow (imageToKernel f g w x) =
(imageSubobject f).arrow x := by
rw [← comp_apply, imageToKernel_arrow]
-- This is less useful as a `simp` lemma than it initially appears,
-- as it "loses" the information the morphism factors through the image.
theorem factorThruImageSubobject_comp_imageToKernel (w : f ≫ g = 0) :
factorThruImageSubobject f ≫ imageToKernel f g w = factorThruKernelSubobject g f w := by
ext
simp
#align factor_thru_image_subobject_comp_image_to_kernel factorThruImageSubobject_comp_imageToKernel
end
section
variable {A B C : V} (f : A ⟶ B) (g : B ⟶ C)
@[simp]
theorem imageToKernel_zero_left [HasKernels V] [HasZeroObject V] {w} :
imageToKernel (0 : A ⟶ B) g w = 0 := by
ext
simp
#align image_to_kernel_zero_left imageToKernel_zero_left
theorem imageToKernel_zero_right [HasImages V] {w} :
imageToKernel f (0 : B ⟶ C) w =
(imageSubobject f).arrow ≫ inv (kernelSubobject (0 : B ⟶ C)).arrow := by
ext
simp
#align image_to_kernel_zero_right imageToKernel_zero_right
section
variable [HasKernels V] [HasImages V]
theorem imageToKernel_comp_right {D : V} (h : C ⟶ D) (w : f ≫ g = 0) :
imageToKernel f (g ≫ h) (by simp [reassoc_of% w]) =
imageToKernel f g w ≫ Subobject.ofLE _ _ (kernelSubobject_comp_le g h) := by
ext
simp
#align image_to_kernel_comp_right imageToKernel_comp_right
theorem imageToKernel_comp_left {Z : V} (h : Z ⟶ A) (w : f ≫ g = 0) :
imageToKernel (h ≫ f) g (by simp [w]) =
Subobject.ofLE _ _ (imageSubobject_comp_le h f) ≫ imageToKernel f g w := by
ext
simp
#align image_to_kernel_comp_left imageToKernel_comp_left
@[simp]
| Mathlib/Algebra/Homology/ImageToKernel.lean | 127 | 132 | theorem imageToKernel_comp_mono {D : V} (h : C ⟶ D) [Mono h] (w) :
imageToKernel f (g ≫ h) w =
imageToKernel f g ((cancel_mono h).mp (by simpa using w : (f ≫ g) ≫ h = 0 ≫ h)) ≫
(Subobject.isoOfEq _ _ (kernelSubobject_comp_mono g h)).inv := by |
ext
simp
|
import Mathlib.Init.Core
import Mathlib.LinearAlgebra.AffineSpace.Basis
import Mathlib.LinearAlgebra.FiniteDimensional
#align_import linear_algebra.affine_space.finite_dimensional from "leanprover-community/mathlib"@"67e606eaea14c7854bdc556bd53d98aefdf76ec0"
noncomputable section
open Affine
section AffineSpace'
variable (k : Type*) {V : Type*} {P : Type*}
variable {ι : Type*}
open AffineSubspace FiniteDimensional Module
variable [DivisionRing k] [AddCommGroup V] [Module k V] [AffineSpace V P]
theorem finiteDimensional_vectorSpan_of_finite {s : Set P} (h : Set.Finite s) :
FiniteDimensional k (vectorSpan k s) :=
span_of_finite k <| h.vsub h
#align finite_dimensional_vector_span_of_finite finiteDimensional_vectorSpan_of_finite
instance finiteDimensional_vectorSpan_range [Finite ι] (p : ι → P) :
FiniteDimensional k (vectorSpan k (Set.range p)) :=
finiteDimensional_vectorSpan_of_finite k (Set.finite_range _)
#align finite_dimensional_vector_span_range finiteDimensional_vectorSpan_range
instance finiteDimensional_vectorSpan_image_of_finite [Finite ι] (p : ι → P) (s : Set ι) :
FiniteDimensional k (vectorSpan k (p '' s)) :=
finiteDimensional_vectorSpan_of_finite k (Set.toFinite _)
#align finite_dimensional_vector_span_image_of_finite finiteDimensional_vectorSpan_image_of_finite
theorem finiteDimensional_direction_affineSpan_of_finite {s : Set P} (h : Set.Finite s) :
FiniteDimensional k (affineSpan k s).direction :=
(direction_affineSpan k s).symm ▸ finiteDimensional_vectorSpan_of_finite k h
#align finite_dimensional_direction_affine_span_of_finite finiteDimensional_direction_affineSpan_of_finite
instance finiteDimensional_direction_affineSpan_range [Finite ι] (p : ι → P) :
FiniteDimensional k (affineSpan k (Set.range p)).direction :=
finiteDimensional_direction_affineSpan_of_finite k (Set.finite_range _)
#align finite_dimensional_direction_affine_span_range finiteDimensional_direction_affineSpan_range
instance finiteDimensional_direction_affineSpan_image_of_finite [Finite ι] (p : ι → P) (s : Set ι) :
FiniteDimensional k (affineSpan k (p '' s)).direction :=
finiteDimensional_direction_affineSpan_of_finite k (Set.toFinite _)
#align finite_dimensional_direction_affine_span_image_of_finite finiteDimensional_direction_affineSpan_image_of_finite
theorem finite_of_fin_dim_affineIndependent [FiniteDimensional k V] {p : ι → P}
(hi : AffineIndependent k p) : Finite ι := by
nontriviality ι; inhabit ι
rw [affineIndependent_iff_linearIndependent_vsub k p default] at hi
letI : IsNoetherian k V := IsNoetherian.iff_fg.2 inferInstance
exact
(Set.finite_singleton default).finite_of_compl (Set.finite_coe_iff.1 hi.finite_of_isNoetherian)
#align finite_of_fin_dim_affine_independent finite_of_fin_dim_affineIndependent
theorem finite_set_of_fin_dim_affineIndependent [FiniteDimensional k V] {s : Set ι} {f : s → P}
(hi : AffineIndependent k f) : s.Finite :=
@Set.toFinite _ s (finite_of_fin_dim_affineIndependent k hi)
#align finite_set_of_fin_dim_affine_independent finite_set_of_fin_dim_affineIndependent
variable {k}
theorem AffineIndependent.finrank_vectorSpan_image_finset [DecidableEq P]
{p : ι → P} (hi : AffineIndependent k p) {s : Finset ι} {n : ℕ} (hc : Finset.card s = n + 1) :
finrank k (vectorSpan k (s.image p : Set P)) = n := by
classical
have hi' := hi.range.mono (Set.image_subset_range p ↑s)
have hc' : (s.image p).card = n + 1 := by rwa [s.card_image_of_injective hi.injective]
have hn : (s.image p).Nonempty := by simp [hc', ← Finset.card_pos]
rcases hn with ⟨p₁, hp₁⟩
have hp₁' : p₁ ∈ p '' s := by simpa using hp₁
rw [affineIndependent_set_iff_linearIndependent_vsub k hp₁', ← Finset.coe_singleton,
← Finset.coe_image, ← Finset.coe_sdiff, Finset.sdiff_singleton_eq_erase, ← Finset.coe_image]
at hi'
have hc : (Finset.image (fun p : P => p -ᵥ p₁) ((Finset.image p s).erase p₁)).card = n := by
rw [Finset.card_image_of_injective _ (vsub_left_injective _), Finset.card_erase_of_mem hp₁]
exact Nat.pred_eq_of_eq_succ hc'
rwa [vectorSpan_eq_span_vsub_finset_right_ne k hp₁, finrank_span_finset_eq_card, hc]
#align affine_independent.finrank_vector_span_image_finset AffineIndependent.finrank_vectorSpan_image_finset
theorem AffineIndependent.finrank_vectorSpan [Fintype ι] {p : ι → P} (hi : AffineIndependent k p)
{n : ℕ} (hc : Fintype.card ι = n + 1) : finrank k (vectorSpan k (Set.range p)) = n := by
classical
rw [← Finset.card_univ] at hc
rw [← Set.image_univ, ← Finset.coe_univ, ← Finset.coe_image]
exact hi.finrank_vectorSpan_image_finset hc
#align affine_independent.finrank_vector_span AffineIndependent.finrank_vectorSpan
lemma AffineIndependent.finrank_vectorSpan_add_one [Fintype ι] [Nonempty ι] {p : ι → P}
(hi : AffineIndependent k p) : finrank k (vectorSpan k (Set.range p)) + 1 = Fintype.card ι := by
rw [hi.finrank_vectorSpan (tsub_add_cancel_of_le _).symm, tsub_add_cancel_of_le] <;>
exact Fintype.card_pos
theorem AffineIndependent.vectorSpan_eq_top_of_card_eq_finrank_add_one [FiniteDimensional k V]
[Fintype ι] {p : ι → P} (hi : AffineIndependent k p) (hc : Fintype.card ι = finrank k V + 1) :
vectorSpan k (Set.range p) = ⊤ :=
Submodule.eq_top_of_finrank_eq <| hi.finrank_vectorSpan hc
#align affine_independent.vector_span_eq_top_of_card_eq_finrank_add_one AffineIndependent.vectorSpan_eq_top_of_card_eq_finrank_add_one
variable (k)
theorem finrank_vectorSpan_image_finset_le [DecidableEq P] (p : ι → P) (s : Finset ι) {n : ℕ}
(hc : Finset.card s = n + 1) : finrank k (vectorSpan k (s.image p : Set P)) ≤ n := by
classical
have hn : (s.image p).Nonempty := by
rw [Finset.image_nonempty, ← Finset.card_pos, hc]
apply Nat.succ_pos
rcases hn with ⟨p₁, hp₁⟩
rw [vectorSpan_eq_span_vsub_finset_right_ne k hp₁]
refine le_trans (finrank_span_finset_le_card (((s.image p).erase p₁).image fun p => p -ᵥ p₁)) ?_
rw [Finset.card_image_of_injective _ (vsub_left_injective p₁), Finset.card_erase_of_mem hp₁,
tsub_le_iff_right, ← hc]
apply Finset.card_image_le
#align finrank_vector_span_image_finset_le finrank_vectorSpan_image_finset_le
theorem finrank_vectorSpan_range_le [Fintype ι] (p : ι → P) {n : ℕ} (hc : Fintype.card ι = n + 1) :
finrank k (vectorSpan k (Set.range p)) ≤ n := by
classical
rw [← Set.image_univ, ← Finset.coe_univ, ← Finset.coe_image]
rw [← Finset.card_univ] at hc
exact finrank_vectorSpan_image_finset_le _ _ _ hc
#align finrank_vector_span_range_le finrank_vectorSpan_range_le
lemma finrank_vectorSpan_range_add_one_le [Fintype ι] [Nonempty ι] (p : ι → P) :
finrank k (vectorSpan k (Set.range p)) + 1 ≤ Fintype.card ι :=
(le_tsub_iff_right $ Nat.succ_le_iff.2 Fintype.card_pos).1 $ finrank_vectorSpan_range_le _ _
(tsub_add_cancel_of_le $ Nat.succ_le_iff.2 Fintype.card_pos).symm
theorem affineIndependent_iff_finrank_vectorSpan_eq [Fintype ι] (p : ι → P) {n : ℕ}
(hc : Fintype.card ι = n + 1) :
AffineIndependent k p ↔ finrank k (vectorSpan k (Set.range p)) = n := by
classical
have hn : Nonempty ι := by simp [← Fintype.card_pos_iff, hc]
cases' hn with i₁
rw [affineIndependent_iff_linearIndependent_vsub _ _ i₁,
linearIndependent_iff_card_eq_finrank_span, eq_comm,
vectorSpan_range_eq_span_range_vsub_right_ne k p i₁, Set.finrank]
rw [← Finset.card_univ] at hc
rw [Fintype.subtype_card]
simp [Finset.filter_ne', Finset.card_erase_of_mem, hc]
#align affine_independent_iff_finrank_vector_span_eq affineIndependent_iff_finrank_vectorSpan_eq
theorem affineIndependent_iff_le_finrank_vectorSpan [Fintype ι] (p : ι → P) {n : ℕ}
(hc : Fintype.card ι = n + 1) :
AffineIndependent k p ↔ n ≤ finrank k (vectorSpan k (Set.range p)) := by
rw [affineIndependent_iff_finrank_vectorSpan_eq k p hc]
constructor
· rintro rfl
rfl
· exact fun hle => le_antisymm (finrank_vectorSpan_range_le k p hc) hle
#align affine_independent_iff_le_finrank_vector_span affineIndependent_iff_le_finrank_vectorSpan
theorem affineIndependent_iff_not_finrank_vectorSpan_le [Fintype ι] (p : ι → P) {n : ℕ}
(hc : Fintype.card ι = n + 2) :
AffineIndependent k p ↔ ¬finrank k (vectorSpan k (Set.range p)) ≤ n := by
rw [affineIndependent_iff_le_finrank_vectorSpan k p hc, ← Nat.lt_iff_add_one_le, lt_iff_not_ge]
#align affine_independent_iff_not_finrank_vector_span_le affineIndependent_iff_not_finrank_vectorSpan_le
theorem finrank_vectorSpan_le_iff_not_affineIndependent [Fintype ι] (p : ι → P) {n : ℕ}
(hc : Fintype.card ι = n + 2) :
finrank k (vectorSpan k (Set.range p)) ≤ n ↔ ¬AffineIndependent k p :=
(not_iff_comm.1 (affineIndependent_iff_not_finrank_vectorSpan_le k p hc).symm).symm
#align finrank_vector_span_le_iff_not_affine_independent finrank_vectorSpan_le_iff_not_affineIndependent
variable {k}
lemma AffineIndependent.card_le_finrank_succ [Fintype ι] {p : ι → P} (hp : AffineIndependent k p) :
Fintype.card ι ≤ FiniteDimensional.finrank k (vectorSpan k (Set.range p)) + 1 := by
cases isEmpty_or_nonempty ι
· simp [Fintype.card_eq_zero]
rw [← tsub_le_iff_right]
exact (affineIndependent_iff_le_finrank_vectorSpan _ _
(tsub_add_cancel_of_le <| Nat.one_le_iff_ne_zero.2 Fintype.card_ne_zero).symm).1 hp
open Finset in
lemma AffineIndependent.card_le_card_of_subset_affineSpan {s t : Finset V}
(hs : AffineIndependent k ((↑) : s → V)) (hst : (s : Set V) ⊆ affineSpan k (t : Set V)) :
s.card ≤ t.card := by
obtain rfl | hs' := s.eq_empty_or_nonempty
· simp
obtain rfl | ht' := t.eq_empty_or_nonempty
· simpa [Set.subset_empty_iff] using hst
have := hs'.to_subtype
have := ht'.to_set.to_subtype
have direction_le := AffineSubspace.direction_le (affineSpan_mono k hst)
rw [AffineSubspace.affineSpan_coe, direction_affineSpan, direction_affineSpan,
← @Subtype.range_coe _ (s : Set V), ← @Subtype.range_coe _ (t : Set V)] at direction_le
have finrank_le := add_le_add_right (Submodule.finrank_le_finrank_of_le direction_le) 1
-- We use `erw` to elide the difference between `↥s` and `↥(s : Set V)}`
erw [hs.finrank_vectorSpan_add_one] at finrank_le
simpa using finrank_le.trans <| finrank_vectorSpan_range_add_one_le _ _
open Finset in
lemma AffineIndependent.card_lt_card_of_affineSpan_lt_affineSpan {s t : Finset V}
(hs : AffineIndependent k ((↑) : s → V))
(hst : affineSpan k (s : Set V) < affineSpan k (t : Set V)) : s.card < t.card := by
obtain rfl | hs' := s.eq_empty_or_nonempty
· simpa [card_pos] using hst
obtain rfl | ht' := t.eq_empty_or_nonempty
· simp [Set.subset_empty_iff] at hst
have := hs'.to_subtype
have := ht'.to_set.to_subtype
have dir_lt := AffineSubspace.direction_lt_of_nonempty (k := k) hst $ hs'.to_set.affineSpan k
rw [direction_affineSpan, direction_affineSpan,
← @Subtype.range_coe _ (s : Set V), ← @Subtype.range_coe _ (t : Set V)] at dir_lt
have finrank_lt := add_lt_add_right (Submodule.finrank_lt_finrank_of_lt dir_lt) 1
-- We use `erw` to elide the difference between `↥s` and `↥(s : Set V)}`
erw [hs.finrank_vectorSpan_add_one] at finrank_lt
simpa using finrank_lt.trans_le <| finrank_vectorSpan_range_add_one_le _ _
theorem AffineIndependent.vectorSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one
[DecidableEq P] {p : ι → P}
(hi : AffineIndependent k p) {s : Finset ι} {sm : Submodule k V} [FiniteDimensional k sm]
(hle : vectorSpan k (s.image p : Set P) ≤ sm) (hc : Finset.card s = finrank k sm + 1) :
vectorSpan k (s.image p : Set P) = sm :=
eq_of_le_of_finrank_eq hle <| hi.finrank_vectorSpan_image_finset hc
#align affine_independent.vector_span_image_finset_eq_of_le_of_card_eq_finrank_add_one AffineIndependent.vectorSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one
theorem AffineIndependent.vectorSpan_eq_of_le_of_card_eq_finrank_add_one [Fintype ι] {p : ι → P}
(hi : AffineIndependent k p) {sm : Submodule k V} [FiniteDimensional k sm]
(hle : vectorSpan k (Set.range p) ≤ sm) (hc : Fintype.card ι = finrank k sm + 1) :
vectorSpan k (Set.range p) = sm :=
eq_of_le_of_finrank_eq hle <| hi.finrank_vectorSpan hc
#align affine_independent.vector_span_eq_of_le_of_card_eq_finrank_add_one AffineIndependent.vectorSpan_eq_of_le_of_card_eq_finrank_add_one
theorem AffineIndependent.affineSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one
[DecidableEq P] {p : ι → P}
(hi : AffineIndependent k p) {s : Finset ι} {sp : AffineSubspace k P}
[FiniteDimensional k sp.direction] (hle : affineSpan k (s.image p : Set P) ≤ sp)
(hc : Finset.card s = finrank k sp.direction + 1) : affineSpan k (s.image p : Set P) = sp := by
have hn : s.Nonempty := by
rw [← Finset.card_pos, hc]
apply Nat.succ_pos
refine eq_of_direction_eq_of_nonempty_of_le ?_ ((hn.image p).to_set.affineSpan k) hle
have hd := direction_le hle
rw [direction_affineSpan] at hd ⊢
exact hi.vectorSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one hd hc
#align affine_independent.affine_span_image_finset_eq_of_le_of_card_eq_finrank_add_one AffineIndependent.affineSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one
theorem AffineIndependent.affineSpan_eq_of_le_of_card_eq_finrank_add_one [Fintype ι] {p : ι → P}
(hi : AffineIndependent k p) {sp : AffineSubspace k P} [FiniteDimensional k sp.direction]
(hle : affineSpan k (Set.range p) ≤ sp) (hc : Fintype.card ι = finrank k sp.direction + 1) :
affineSpan k (Set.range p) = sp := by
classical
rw [← Finset.card_univ] at hc
rw [← Set.image_univ, ← Finset.coe_univ, ← Finset.coe_image] at hle ⊢
exact hi.affineSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one hle hc
#align affine_independent.affine_span_eq_of_le_of_card_eq_finrank_add_one AffineIndependent.affineSpan_eq_of_le_of_card_eq_finrank_add_one
theorem AffineIndependent.affineSpan_eq_top_iff_card_eq_finrank_add_one [FiniteDimensional k V]
[Fintype ι] {p : ι → P} (hi : AffineIndependent k p) :
affineSpan k (Set.range p) = ⊤ ↔ Fintype.card ι = finrank k V + 1 := by
constructor
· intro h_tot
let n := Fintype.card ι - 1
have hn : Fintype.card ι = n + 1 :=
(Nat.succ_pred_eq_of_pos (card_pos_of_affineSpan_eq_top k V P h_tot)).symm
rw [hn, ← finrank_top, ← (vectorSpan_eq_top_of_affineSpan_eq_top k V P) h_tot,
← hi.finrank_vectorSpan hn]
· intro hc
rw [← finrank_top, ← direction_top k V P] at hc
exact hi.affineSpan_eq_of_le_of_card_eq_finrank_add_one le_top hc
#align affine_independent.affine_span_eq_top_iff_card_eq_finrank_add_one AffineIndependent.affineSpan_eq_top_iff_card_eq_finrank_add_one
theorem Affine.Simplex.span_eq_top [FiniteDimensional k V] {n : ℕ} (T : Affine.Simplex k V n)
(hrank : finrank k V = n) : affineSpan k (Set.range T.points) = ⊤ := by
rw [AffineIndependent.affineSpan_eq_top_iff_card_eq_finrank_add_one T.independent,
Fintype.card_fin, hrank]
#align affine.simplex.span_eq_top Affine.Simplex.span_eq_top
instance finiteDimensional_vectorSpan_insert (s : AffineSubspace k P)
[FiniteDimensional k s.direction] (p : P) :
FiniteDimensional k (vectorSpan k (insert p (s : Set P))) := by
rw [← direction_affineSpan, ← affineSpan_insert_affineSpan]
rcases (s : Set P).eq_empty_or_nonempty with (hs | ⟨p₀, hp₀⟩)
· rw [coe_eq_bot_iff] at hs
rw [hs, bot_coe, span_empty, bot_coe, direction_affineSpan]
convert finiteDimensional_bot k V <;> simp
· rw [affineSpan_coe, direction_affineSpan_insert hp₀]
infer_instance
#align finite_dimensional_vector_span_insert finiteDimensional_vectorSpan_insert
instance finiteDimensional_direction_affineSpan_insert (s : AffineSubspace k P)
[FiniteDimensional k s.direction] (p : P) :
FiniteDimensional k (affineSpan k (insert p (s : Set P))).direction :=
(direction_affineSpan k (insert p (s : Set P))).symm ▸ finiteDimensional_vectorSpan_insert s p
#align finite_dimensional_direction_affine_span_insert finiteDimensional_direction_affineSpan_insert
variable (k)
instance finiteDimensional_vectorSpan_insert_set (s : Set P) [FiniteDimensional k (vectorSpan k s)]
(p : P) : FiniteDimensional k (vectorSpan k (insert p s)) := by
haveI : FiniteDimensional k (affineSpan k s).direction :=
(direction_affineSpan k s).symm ▸ inferInstance
rw [← direction_affineSpan, ← affineSpan_insert_affineSpan, direction_affineSpan]
exact finiteDimensional_vectorSpan_insert (affineSpan k s) p
#align finite_dimensional_vector_span_insert_set finiteDimensional_vectorSpan_insert_set
def Collinear (s : Set P) : Prop :=
Module.rank k (vectorSpan k s) ≤ 1
#align collinear Collinear
theorem collinear_iff_rank_le_one (s : Set P) :
Collinear k s ↔ Module.rank k (vectorSpan k s) ≤ 1 := Iff.rfl
#align collinear_iff_rank_le_one collinear_iff_rank_le_one
variable {k}
theorem collinear_iff_finrank_le_one {s : Set P} [FiniteDimensional k (vectorSpan k s)] :
Collinear k s ↔ finrank k (vectorSpan k s) ≤ 1 := by
have h := collinear_iff_rank_le_one k s
rw [← finrank_eq_rank] at h
exact mod_cast h
#align collinear_iff_finrank_le_one collinear_iff_finrank_le_one
alias ⟨Collinear.finrank_le_one, _⟩ := collinear_iff_finrank_le_one
#align collinear.finrank_le_one Collinear.finrank_le_one
theorem Collinear.subset {s₁ s₂ : Set P} (hs : s₁ ⊆ s₂) (h : Collinear k s₂) : Collinear k s₁ :=
(rank_le_of_submodule (vectorSpan k s₁) (vectorSpan k s₂) (vectorSpan_mono k hs)).trans h
#align collinear.subset Collinear.subset
theorem Collinear.finiteDimensional_vectorSpan {s : Set P} (h : Collinear k s) :
FiniteDimensional k (vectorSpan k s) :=
IsNoetherian.iff_fg.1
(IsNoetherian.iff_rank_lt_aleph0.2 (lt_of_le_of_lt h Cardinal.one_lt_aleph0))
#align collinear.finite_dimensional_vector_span Collinear.finiteDimensional_vectorSpan
theorem Collinear.finiteDimensional_direction_affineSpan {s : Set P} (h : Collinear k s) :
FiniteDimensional k (affineSpan k s).direction :=
(direction_affineSpan k s).symm ▸ h.finiteDimensional_vectorSpan
#align collinear.finite_dimensional_direction_affine_span Collinear.finiteDimensional_direction_affineSpan
variable (k P)
theorem collinear_empty : Collinear k (∅ : Set P) := by
rw [collinear_iff_rank_le_one, vectorSpan_empty]
simp
#align collinear_empty collinear_empty
variable {P}
theorem collinear_singleton (p : P) : Collinear k ({p} : Set P) := by
rw [collinear_iff_rank_le_one, vectorSpan_singleton]
simp
#align collinear_singleton collinear_singleton
variable {k}
theorem collinear_iff_of_mem {s : Set P} {p₀ : P} (h : p₀ ∈ s) :
Collinear k s ↔ ∃ v : V, ∀ p ∈ s, ∃ r : k, p = r • v +ᵥ p₀ := by
simp_rw [collinear_iff_rank_le_one, rank_submodule_le_one_iff', Submodule.le_span_singleton_iff]
constructor
· rintro ⟨v₀, hv⟩
use v₀
intro p hp
obtain ⟨r, hr⟩ := hv (p -ᵥ p₀) (vsub_mem_vectorSpan k hp h)
use r
rw [eq_vadd_iff_vsub_eq]
exact hr.symm
· rintro ⟨v, hp₀v⟩
use v
intro w hw
have hs : vectorSpan k s ≤ k ∙ v := by
rw [vectorSpan_eq_span_vsub_set_right k h, Submodule.span_le, Set.subset_def]
intro x hx
rw [SetLike.mem_coe, Submodule.mem_span_singleton]
rw [Set.mem_image] at hx
rcases hx with ⟨p, hp, rfl⟩
rcases hp₀v p hp with ⟨r, rfl⟩
use r
simp
have hw' := SetLike.le_def.1 hs hw
rwa [Submodule.mem_span_singleton] at hw'
#align collinear_iff_of_mem collinear_iff_of_mem
theorem collinear_iff_exists_forall_eq_smul_vadd (s : Set P) :
Collinear k s ↔ ∃ (p₀ : P) (v : V), ∀ p ∈ s, ∃ r : k, p = r • v +ᵥ p₀ := by
rcases Set.eq_empty_or_nonempty s with (rfl | ⟨⟨p₁, hp₁⟩⟩)
· simp [collinear_empty]
· rw [collinear_iff_of_mem hp₁]
constructor
· exact fun h => ⟨p₁, h⟩
· rintro ⟨p, v, hv⟩
use v
intro p₂ hp₂
rcases hv p₂ hp₂ with ⟨r, rfl⟩
rcases hv p₁ hp₁ with ⟨r₁, rfl⟩
use r - r₁
simp [vadd_vadd, ← add_smul]
#align collinear_iff_exists_forall_eq_smul_vadd collinear_iff_exists_forall_eq_smul_vadd
variable (k)
theorem collinear_pair (p₁ p₂ : P) : Collinear k ({p₁, p₂} : Set P) := by
rw [collinear_iff_exists_forall_eq_smul_vadd]
use p₁, p₂ -ᵥ p₁
intro p hp
rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hp
cases' hp with hp hp
· use 0
simp [hp]
· use 1
simp [hp]
#align collinear_pair collinear_pair
variable {k}
theorem affineIndependent_iff_not_collinear {p : Fin 3 → P} :
AffineIndependent k p ↔ ¬Collinear k (Set.range p) := by
rw [collinear_iff_finrank_le_one,
affineIndependent_iff_not_finrank_vectorSpan_le k p (Fintype.card_fin 3)]
#align affine_independent_iff_not_collinear affineIndependent_iff_not_collinear
theorem collinear_iff_not_affineIndependent {p : Fin 3 → P} :
Collinear k (Set.range p) ↔ ¬AffineIndependent k p := by
rw [collinear_iff_finrank_le_one,
finrank_vectorSpan_le_iff_not_affineIndependent k p (Fintype.card_fin 3)]
#align collinear_iff_not_affine_independent collinear_iff_not_affineIndependent
theorem affineIndependent_iff_not_collinear_set {p₁ p₂ p₃ : P} :
AffineIndependent k ![p₁, p₂, p₃] ↔ ¬Collinear k ({p₁, p₂, p₃} : Set P) := by
rw [affineIndependent_iff_not_collinear]
simp_rw [Matrix.range_cons, Matrix.range_empty, Set.singleton_union, insert_emptyc_eq]
#align affine_independent_iff_not_collinear_set affineIndependent_iff_not_collinear_set
theorem collinear_iff_not_affineIndependent_set {p₁ p₂ p₃ : P} :
Collinear k ({p₁, p₂, p₃} : Set P) ↔ ¬AffineIndependent k ![p₁, p₂, p₃] :=
affineIndependent_iff_not_collinear_set.not_left.symm
#align collinear_iff_not_affine_independent_set collinear_iff_not_affineIndependent_set
theorem affineIndependent_iff_not_collinear_of_ne {p : Fin 3 → P} {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂)
(h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) :
AffineIndependent k p ↔ ¬Collinear k ({p i₁, p i₂, p i₃} : Set P) := by
have hu : (Finset.univ : Finset (Fin 3)) = {i₁, i₂, i₃} := by
-- Porting note: Originally `by decide!`
fin_cases i₁ <;> fin_cases i₂ <;> fin_cases i₃
<;> simp (config := {decide := true}) only at h₁₂ h₁₃ h₂₃ ⊢
rw [affineIndependent_iff_not_collinear, ← Set.image_univ, ← Finset.coe_univ, hu,
Finset.coe_insert, Finset.coe_insert, Finset.coe_singleton, Set.image_insert_eq, Set.image_pair]
#align affine_independent_iff_not_collinear_of_ne affineIndependent_iff_not_collinear_of_ne
theorem collinear_iff_not_affineIndependent_of_ne {p : Fin 3 → P} {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂)
(h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) :
Collinear k ({p i₁, p i₂, p i₃} : Set P) ↔ ¬AffineIndependent k p :=
(affineIndependent_iff_not_collinear_of_ne h₁₂ h₁₃ h₂₃).not_left.symm
#align collinear_iff_not_affine_independent_of_ne collinear_iff_not_affineIndependent_of_ne
theorem ne₁₂_of_not_collinear {p₁ p₂ p₃ : P} (h : ¬Collinear k ({p₁, p₂, p₃} : Set P)) :
p₁ ≠ p₂ := by
rintro rfl
simp [collinear_pair] at h
#align ne₁₂_of_not_collinear ne₁₂_of_not_collinear
theorem ne₁₃_of_not_collinear {p₁ p₂ p₃ : P} (h : ¬Collinear k ({p₁, p₂, p₃} : Set P)) :
p₁ ≠ p₃ := by
rintro rfl
simp [collinear_pair] at h
#align ne₁₃_of_not_collinear ne₁₃_of_not_collinear
theorem ne₂₃_of_not_collinear {p₁ p₂ p₃ : P} (h : ¬Collinear k ({p₁, p₂, p₃} : Set P)) :
p₂ ≠ p₃ := by
rintro rfl
simp [collinear_pair] at h
#align ne₂₃_of_not_collinear ne₂₃_of_not_collinear
theorem Collinear.mem_affineSpan_of_mem_of_ne {s : Set P} (h : Collinear k s) {p₁ p₂ p₃ : P}
(hp₁ : p₁ ∈ s) (hp₂ : p₂ ∈ s) (hp₃ : p₃ ∈ s) (hp₁p₂ : p₁ ≠ p₂) : p₃ ∈ line[k, p₁, p₂] := by
rw [collinear_iff_of_mem hp₁] at h
rcases h with ⟨v, h⟩
rcases h p₂ hp₂ with ⟨r₂, rfl⟩
rcases h p₃ hp₃ with ⟨r₃, rfl⟩
rw [vadd_left_mem_affineSpan_pair]
refine ⟨r₃ / r₂, ?_⟩
have h₂ : r₂ ≠ 0 := by
rintro rfl
simp at hp₁p₂
simp [smul_smul, h₂]
#align collinear.mem_affine_span_of_mem_of_ne Collinear.mem_affineSpan_of_mem_of_ne
theorem Collinear.affineSpan_eq_of_ne {s : Set P} (h : Collinear k s) {p₁ p₂ : P} (hp₁ : p₁ ∈ s)
(hp₂ : p₂ ∈ s) (hp₁p₂ : p₁ ≠ p₂) : line[k, p₁, p₂] = affineSpan k s :=
le_antisymm (affineSpan_mono _ (Set.insert_subset_iff.2 ⟨hp₁, Set.singleton_subset_iff.2 hp₂⟩))
(affineSpan_le.2 fun _ hp => h.mem_affineSpan_of_mem_of_ne hp₁ hp₂ hp hp₁p₂)
#align collinear.affine_span_eq_of_ne Collinear.affineSpan_eq_of_ne
theorem Collinear.collinear_insert_iff_of_ne {s : Set P} (h : Collinear k s) {p₁ p₂ p₃ : P}
(hp₂ : p₂ ∈ s) (hp₃ : p₃ ∈ s) (hp₂p₃ : p₂ ≠ p₃) :
Collinear k (insert p₁ s) ↔ Collinear k ({p₁, p₂, p₃} : Set P) := by
have hv : vectorSpan k (insert p₁ s) = vectorSpan k ({p₁, p₂, p₃} : Set P) := by
-- Porting note: Original proof used `conv_lhs` and `conv_rhs`, but these tactics timed out.
rw [← direction_affineSpan, ← affineSpan_insert_affineSpan]
symm
rw [← direction_affineSpan, ← affineSpan_insert_affineSpan, h.affineSpan_eq_of_ne hp₂ hp₃ hp₂p₃]
rw [Collinear, Collinear, hv]
#align collinear.collinear_insert_iff_of_ne Collinear.collinear_insert_iff_of_ne
theorem collinear_insert_iff_of_mem_affineSpan {s : Set P} {p : P} (h : p ∈ affineSpan k s) :
Collinear k (insert p s) ↔ Collinear k s := by
rw [Collinear, Collinear, vectorSpan_insert_eq_vectorSpan h]
#align collinear_insert_iff_of_mem_affine_span collinear_insert_iff_of_mem_affineSpan
| Mathlib/LinearAlgebra/AffineSpace/FiniteDimensional.lean | 620 | 623 | theorem collinear_insert_of_mem_affineSpan_pair {p₁ p₂ p₃ : P} (h : p₁ ∈ line[k, p₂, p₃]) :
Collinear k ({p₁, p₂, p₃} : Set P) := by |
rw [collinear_insert_iff_of_mem_affineSpan h]
exact collinear_pair _ _ _
|
import Mathlib.MeasureTheory.Decomposition.RadonNikodym
import Mathlib.MeasureTheory.Measure.Haar.OfBasis
import Mathlib.Probability.Independence.Basic
#align_import probability.density from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
open scoped Classical MeasureTheory NNReal ENNReal
open TopologicalSpace MeasureTheory.Measure
noncomputable section
namespace MeasureTheory
variable {Ω E : Type*} [MeasurableSpace E]
class HasPDF {m : MeasurableSpace Ω} (X : Ω → E) (ℙ : Measure Ω)
(μ : Measure E := by volume_tac) : Prop where
pdf' : AEMeasurable X ℙ ∧ (map X ℙ).HaveLebesgueDecomposition μ ∧ map X ℙ ≪ μ
#align measure_theory.has_pdf MeasureTheory.HasPDF
section HasPDF
variable {_ : MeasurableSpace Ω}
theorem hasPDF_iff {X : Ω → E} {ℙ : Measure Ω} {μ : Measure E} :
HasPDF X ℙ μ ↔ AEMeasurable X ℙ ∧ (map X ℙ).HaveLebesgueDecomposition μ ∧ map X ℙ ≪ μ :=
⟨@HasPDF.pdf' _ _ _ _ _ _ _, HasPDF.mk⟩
#align measure_theory.pdf.has_pdf_iff MeasureTheory.hasPDF_iff
theorem hasPDF_iff_of_aemeasurable {X : Ω → E} {ℙ : Measure Ω}
{μ : Measure E} (hX : AEMeasurable X ℙ) :
HasPDF X ℙ μ ↔ (map X ℙ).HaveLebesgueDecomposition μ ∧ map X ℙ ≪ μ := by
rw [hasPDF_iff]
simp only [hX, true_and]
#align measure_theory.pdf.has_pdf_iff_of_measurable MeasureTheory.hasPDF_iff_of_aemeasurable
@[measurability]
theorem HasPDF.aemeasurable (X : Ω → E) (ℙ : Measure Ω)
(μ : Measure E) [hX : HasPDF X ℙ μ] : AEMeasurable X ℙ :=
hX.pdf'.1
#align measure_theory.has_pdf.measurable MeasureTheory.HasPDF.aemeasurable
instance HasPDF.haveLebesgueDecomposition {X : Ω → E} {ℙ : Measure Ω}
{μ : Measure E} [hX : HasPDF X ℙ μ] : (map X ℙ).HaveLebesgueDecomposition μ :=
hX.pdf'.2.1
#align measure_theory.pdf.have_lebesgue_decomposition_of_has_pdf MeasureTheory.HasPDF.haveLebesgueDecomposition
theorem HasPDF.absolutelyContinuous {X : Ω → E} {ℙ : Measure Ω} {μ : Measure E}
[hX : HasPDF X ℙ μ] : map X ℙ ≪ μ :=
hX.pdf'.2.2
#align measure_theory.pdf.map_absolutely_continuous MeasureTheory.HasPDF.absolutelyContinuous
theorem HasPDF.quasiMeasurePreserving_of_measurable (X : Ω → E) (ℙ : Measure Ω) (μ : Measure E)
[HasPDF X ℙ μ] (h : Measurable X) : QuasiMeasurePreserving X ℙ μ :=
{ measurable := h
absolutelyContinuous := HasPDF.absolutelyContinuous }
#align measure_theory.pdf.to_quasi_measure_preserving MeasureTheory.HasPDF.quasiMeasurePreserving_of_measurable
theorem HasPDF.congr {X Y : Ω → E} {ℙ : Measure Ω} {μ : Measure E} (hXY : X =ᵐ[ℙ] Y)
[hX : HasPDF X ℙ μ] : HasPDF Y ℙ μ :=
⟨(HasPDF.aemeasurable X ℙ μ).congr hXY, ℙ.map_congr hXY ▸ hX.haveLebesgueDecomposition,
ℙ.map_congr hXY ▸ hX.absolutelyContinuous⟩
theorem HasPDF.congr' {X Y : Ω → E} {ℙ : Measure Ω} {μ : Measure E} (hXY : X =ᵐ[ℙ] Y) :
HasPDF X ℙ μ ↔ HasPDF Y ℙ μ :=
⟨fun _ ↦ HasPDF.congr hXY, fun _ ↦ HasPDF.congr hXY.symm⟩
| Mathlib/Probability/Density.lean | 122 | 128 | theorem hasPDF_of_map_eq_withDensity {X : Ω → E} {ℙ : Measure Ω} {μ : Measure E}
(hX : AEMeasurable X ℙ) (f : E → ℝ≥0∞) (hf : AEMeasurable f μ) (h : map X ℙ = μ.withDensity f) :
HasPDF X ℙ μ := by |
refine ⟨hX, ?_, ?_⟩ <;> rw [h]
· rw [withDensity_congr_ae hf.ae_eq_mk]
exact haveLebesgueDecomposition_withDensity μ hf.measurable_mk
· exact withDensity_absolutelyContinuous μ f
|
import Batteries.Classes.Order
import Batteries.Control.ForInStep.Basic
namespace Batteries
namespace BinomialHeap
namespace Imp
inductive HeapNode (α : Type u) where
| nil : HeapNode α
| node (a : α) (child sibling : HeapNode α) : HeapNode α
deriving Repr
@[simp] def HeapNode.realSize : HeapNode α → Nat
| .nil => 0
| .node _ c s => c.realSize + 1 + s.realSize
def HeapNode.singleton (a : α) : HeapNode α := .node a .nil .nil
def HeapNode.rank : HeapNode α → Nat
| .nil => 0
| .node _ _ s => s.rank + 1
@[inline] private def HeapNode.rankTR (s : HeapNode α) : Nat := go s 0 where
go : HeapNode α → Nat → Nat
| .nil, r => r
| .node _ _ s, r => go s (r + 1)
@[csimp] private theorem HeapNode.rankTR_eq : @rankTR = @rank := by
funext α s; exact go s 0
where
go {α} : ∀ s n, @rankTR.go α s n = rank s + n
| .nil, _ => (Nat.zero_add ..).symm
| .node .., _ => by simp_arith only [rankTR.go, go, rank]
inductive Heap (α : Type u) where
| nil : Heap α
| cons (rank : Nat) (val : α) (node : HeapNode α) (next : Heap α) : Heap α
deriving Repr
@[simp] def Heap.realSize : Heap α → Nat
| .nil => 0
| .cons _ _ c s => c.realSize + 1 + s.realSize
def Heap.size : Heap α → Nat
| .nil => 0
| .cons r _ _ s => 1 <<< r + s.size
@[inline] def Heap.isEmpty : Heap α → Bool
| .nil => true
| _ => false
@[inline] def Heap.singleton (a : α) : Heap α := .cons 0 a .nil .nil
def Heap.rankGT : Heap α → Nat → Prop
| .nil, _ => True
| .cons r .., n => n < r
instance : Decidable (Heap.rankGT s n) :=
match s with
| .nil => inferInstanceAs (Decidable True)
| .cons .. => inferInstanceAs (Decidable (_ < _))
@[simp] def Heap.length : Heap α → Nat
| .nil => 0
| .cons _ _ _ r => r.length + 1
@[inline] def combine (le : α → α → Bool) (a₁ a₂ : α) (n₁ n₂ : HeapNode α) : α × HeapNode α :=
if le a₁ a₂ then (a₁, .node a₂ n₂ n₁) else (a₂, .node a₁ n₁ n₂)
@[specialize] def Heap.merge (le : α → α → Bool) : Heap α → Heap α → Heap α
| .nil, h => h
| h, .nil => h
| s₁@(.cons r₁ a₁ n₁ t₁), s₂@(.cons r₂ a₂ n₂ t₂) =>
if r₁ < r₂ then .cons r₁ a₁ n₁ (merge le t₁ s₂)
else if r₂ < r₁ then .cons r₂ a₂ n₂ (merge le s₁ t₂)
else
let (a, n) := combine le a₁ a₂ n₁ n₂
let r := r₁ + 1
if t₁.rankGT r then if t₂.rankGT r
then .cons r a n (merge le t₁ t₂)
else merge le (.cons r a n t₁) t₂
else if t₂.rankGT r
then merge le t₁ (.cons r a n t₂)
else .cons r a n (merge le t₁ t₂)
termination_by s₁ s₂ => s₁.length + s₂.length
def HeapNode.toHeap (s : HeapNode α) : Heap α := go s s.rank .nil where
go : HeapNode α → Nat → Heap α → Heap α
| .nil, _, res => res
| .node a c s, n, res => go s (n - 1) (.cons (n - 1) a c res)
@[specialize] def Heap.headD (le : α → α → Bool) (a : α) : Heap α → α
| .nil => a
| .cons _ b _ hs => headD le (if le a b then a else b) hs
@[inline] def Heap.head? (le : α → α → Bool) : Heap α → Option α
| .nil => none
| .cons _ h _ hs => some <| headD le h hs
structure FindMin (α) where
before : Heap α → Heap α := id
val : α
node : HeapNode α
next : Heap α
@[specialize] def Heap.findMin (le : α → α → Bool) (k : Heap α → Heap α) :
Heap α → FindMin α → FindMin α
| .nil, res => res
| .cons r a c s, res =>
-- It is important that we check `le res.val a` here, not the other way
-- around. This ensures that head? and findMin find the same element even
-- when we have `le res.val a` and `le a res.val` (i.e. le is not antisymmetric).
findMin le (k ∘ .cons r a c) s <| if le res.val a then res else ⟨k, a, c, s⟩
def Heap.deleteMin (le : α → α → Bool) : Heap α → Option (α × Heap α)
| .nil => none
| .cons r a c s =>
let { before, val, node, next } := findMin le (.cons r a c) s ⟨id, a, c, s⟩
some (val, node.toHeap.merge le (before next))
@[inline] def Heap.tail? (le : α → α → Bool) (h : Heap α) : Option (Heap α) :=
deleteMin le h |>.map (·.snd)
@[inline] def Heap.tail (le : α → α → Bool) (h : Heap α) : Heap α := tail? le h |>.getD .nil
theorem Heap.realSize_merge (le) (s₁ s₂ : Heap α) :
(s₁.merge le s₂).realSize = s₁.realSize + s₂.realSize := by
unfold merge; split
· simp
· simp
· next r₁ a₁ n₁ t₁ r₂ a₂ n₂ t₂ =>
have IH₁ r a n := realSize_merge le t₁ (cons r a n t₂)
have IH₂ r a n := realSize_merge le (cons r a n t₁) t₂
have IH₃ := realSize_merge le t₁ t₂
split; · simp [IH₁, Nat.add_assoc]
split; · simp [IH₂, Nat.add_assoc, Nat.add_left_comm]
split; simp only; rename_i a n eq
have : n.realSize = n₁.realSize + 1 + n₂.realSize := by
rw [combine] at eq; split at eq <;> cases eq <;>
simp [Nat.add_assoc, Nat.add_left_comm, Nat.add_comm]
split <;> split <;> simp [IH₁, IH₂, IH₃, this, Nat.add_assoc, Nat.add_left_comm]
termination_by s₁.length + s₂.length
private def FindMin.HasSize (res : FindMin α) (n : Nat) : Prop :=
∃ m,
(∀ s, (res.before s).realSize = m + s.realSize) ∧
n = m + res.node.realSize + res.next.realSize + 1
private theorem Heap.realSize_findMin {s : Heap α}
(m) (hk : ∀ s, (k s).realSize = m + s.realSize)
(eq : n = m + s.realSize) (hres : res.HasSize n) :
(s.findMin le k res).HasSize n :=
match s with
| .nil => hres
| .cons r a c s => by
simp [findMin]
refine realSize_findMin (m + c.realSize + 1)
(by simp [hk, Nat.add_assoc]) (by simp [eq, Nat.add_assoc]) ?_
split
· exact hres
· exact ⟨m, hk, by simp [eq, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm]⟩
theorem HeapNode.realSize_toHeap (s : HeapNode α) : s.toHeap.realSize = s.realSize := go s where
go {n res} : ∀ s : HeapNode α, (toHeap.go s n res).realSize = s.realSize + res.realSize
| .nil => (Nat.zero_add _).symm
| .node a c s => by simp [toHeap.go, go, Nat.add_assoc, Nat.add_left_comm]
theorem Heap.realSize_deleteMin {s : Heap α} (eq : s.deleteMin le = some (a, s')) :
s.realSize = s'.realSize + 1 := by
cases s with cases eq | cons r a c s => ?_
have : (s.findMin le (cons r a c) ⟨id, a, c, s⟩).HasSize (c.realSize + s.realSize + 1) :=
Heap.realSize_findMin (c.realSize + 1) (by simp) (Nat.add_right_comm ..) ⟨0, by simp⟩
revert this
match s.findMin le (cons r a c) ⟨id, a, c, s⟩ with
| { before, val, node, next } =>
intro ⟨m, ih₁, ih₂⟩; dsimp only at ih₁ ih₂
rw [realSize, Nat.add_right_comm, ih₂]
simp only [realSize_merge, HeapNode.realSize_toHeap, ih₁, Nat.add_assoc, Nat.add_left_comm]
| .lake/packages/batteries/Batteries/Data/BinomialHeap/Basic.lean | 259 | 263 | theorem Heap.realSize_tail? {s : Heap α} : s.tail? le = some s' →
s.realSize = s'.realSize + 1 := by |
simp only [Heap.tail?]; intro eq
match eq₂ : s.deleteMin le, eq with
| some (a, tl), rfl => exact realSize_deleteMin eq₂
|
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Data.Nat.Factorial.DoubleFactorial
#align_import ring_theory.polynomial.hermite.basic from "leanprover-community/mathlib"@"938d3db9c278f8a52c0f964a405806f0f2b09b74"
noncomputable section
open Polynomial
namespace Polynomial
noncomputable def hermite : ℕ → Polynomial ℤ
| 0 => 1
| n + 1 => X * hermite n - derivative (hermite n)
#align polynomial.hermite Polynomial.hermite
@[simp]
theorem hermite_succ (n : ℕ) : hermite (n + 1) = X * hermite n - derivative (hermite n) := by
rw [hermite]
#align polynomial.hermite_succ Polynomial.hermite_succ
theorem hermite_eq_iterate (n : ℕ) : hermite n = (fun p => X * p - derivative p)^[n] 1 := by
induction' n with n ih
· rfl
· rw [Function.iterate_succ_apply', ← ih, hermite_succ]
#align polynomial.hermite_eq_iterate Polynomial.hermite_eq_iterate
@[simp]
theorem hermite_zero : hermite 0 = C 1 :=
rfl
#align polynomial.hermite_zero Polynomial.hermite_zero
-- Porting note (#10618): There was initially @[simp] on this line but it was removed
-- because simp can prove this theorem
theorem hermite_one : hermite 1 = X := by
rw [hermite_succ, hermite_zero]
simp only [map_one, mul_one, derivative_one, sub_zero]
#align polynomial.hermite_one Polynomial.hermite_one
section coeff
theorem coeff_hermite_succ_zero (n : ℕ) : coeff (hermite (n + 1)) 0 = -coeff (hermite n) 1 := by
simp [coeff_derivative]
#align polynomial.coeff_hermite_succ_zero Polynomial.coeff_hermite_succ_zero
theorem coeff_hermite_succ_succ (n k : ℕ) : coeff (hermite (n + 1)) (k + 1) =
coeff (hermite n) k - (k + 2) * coeff (hermite n) (k + 2) := by
rw [hermite_succ, coeff_sub, coeff_X_mul, coeff_derivative, mul_comm]
norm_cast
#align polynomial.coeff_hermite_succ_succ Polynomial.coeff_hermite_succ_succ
theorem coeff_hermite_of_lt {n k : ℕ} (hnk : n < k) : coeff (hermite n) k = 0 := by
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_lt hnk
clear hnk
induction' n with n ih generalizing k
· apply coeff_C
· have : n + k + 1 + 2 = n + (k + 2) + 1 := by ring
rw [coeff_hermite_succ_succ, add_right_comm, this, ih k, ih (k + 2),
mul_zero, sub_zero]
#align polynomial.coeff_hermite_of_lt Polynomial.coeff_hermite_of_lt
@[simp]
| Mathlib/RingTheory/Polynomial/Hermite/Basic.lean | 103 | 107 | theorem coeff_hermite_self (n : ℕ) : coeff (hermite n) n = 1 := by |
induction' n with n ih
· apply coeff_C
· rw [coeff_hermite_succ_succ, ih, coeff_hermite_of_lt, mul_zero, sub_zero]
simp
|
import Mathlib.Algebra.ModEq
import Mathlib.Algebra.Module.Defs
import Mathlib.Algebra.Order.Archimedean
import Mathlib.Algebra.Periodic
import Mathlib.Data.Int.SuccPred
import Mathlib.GroupTheory.QuotientGroup
import Mathlib.Order.Circular
import Mathlib.Data.List.TFAE
import Mathlib.Data.Set.Lattice
#align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec"
noncomputable section
section LinearOrderedAddCommGroup
variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p)
{a b c : α} {n : ℤ}
def toIcoDiv (a b : α) : ℤ :=
(existsUnique_sub_zsmul_mem_Ico hp b a).choose
#align to_Ico_div toIcoDiv
theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) :=
(existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1
#align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico
theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) :
toIcoDiv hp a b = n :=
((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm
#align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico
def toIocDiv (a b : α) : ℤ :=
(existsUnique_sub_zsmul_mem_Ioc hp b a).choose
#align to_Ioc_div toIocDiv
theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) :=
(existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1
#align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc
theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) :
toIocDiv hp a b = n :=
((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm
#align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc
def toIcoMod (a b : α) : α :=
b - toIcoDiv hp a b • p
#align to_Ico_mod toIcoMod
def toIocMod (a b : α) : α :=
b - toIocDiv hp a b • p
#align to_Ioc_mod toIocMod
theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) :=
sub_toIcoDiv_zsmul_mem_Ico hp a b
#align to_Ico_mod_mem_Ico toIcoMod_mem_Ico
theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by
convert toIcoMod_mem_Ico hp 0 b
exact (zero_add p).symm
#align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico'
theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) :=
sub_toIocDiv_zsmul_mem_Ioc hp a b
#align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc
theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b :=
(Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1
#align left_le_to_Ico_mod left_le_toIcoMod
theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b :=
(Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1
#align left_lt_to_Ioc_mod left_lt_toIocMod
theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p :=
(Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2
#align to_Ico_mod_lt_right toIcoMod_lt_right
theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p :=
(Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2
#align to_Ioc_mod_le_right toIocMod_le_right
@[simp]
theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b :=
rfl
#align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul
@[simp]
theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b :=
rfl
#align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul
@[simp]
theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by
rw [toIcoMod, neg_sub]
#align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self
@[simp]
theorem toIocDiv_zsmul_sub_self (a b : α) : toIocDiv hp a b • p - b = -toIocMod hp a b := by
rw [toIocMod, neg_sub]
#align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self
@[simp]
theorem toIcoMod_sub_self (a b : α) : toIcoMod hp a b - b = -toIcoDiv hp a b • p := by
rw [toIcoMod, sub_sub_cancel_left, neg_smul]
#align to_Ico_mod_sub_self toIcoMod_sub_self
@[simp]
theorem toIocMod_sub_self (a b : α) : toIocMod hp a b - b = -toIocDiv hp a b • p := by
rw [toIocMod, sub_sub_cancel_left, neg_smul]
#align to_Ioc_mod_sub_self toIocMod_sub_self
@[simp]
theorem self_sub_toIcoMod (a b : α) : b - toIcoMod hp a b = toIcoDiv hp a b • p := by
rw [toIcoMod, sub_sub_cancel]
#align self_sub_to_Ico_mod self_sub_toIcoMod
@[simp]
theorem self_sub_toIocMod (a b : α) : b - toIocMod hp a b = toIocDiv hp a b • p := by
rw [toIocMod, sub_sub_cancel]
#align self_sub_to_Ioc_mod self_sub_toIocMod
@[simp]
theorem toIcoMod_add_toIcoDiv_zsmul (a b : α) : toIcoMod hp a b + toIcoDiv hp a b • p = b := by
rw [toIcoMod, sub_add_cancel]
#align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul
@[simp]
theorem toIocMod_add_toIocDiv_zsmul (a b : α) : toIocMod hp a b + toIocDiv hp a b • p = b := by
rw [toIocMod, sub_add_cancel]
#align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul
@[simp]
theorem toIcoDiv_zsmul_sub_toIcoMod (a b : α) : toIcoDiv hp a b • p + toIcoMod hp a b = b := by
rw [add_comm, toIcoMod_add_toIcoDiv_zsmul]
#align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod
@[simp]
theorem toIocDiv_zsmul_sub_toIocMod (a b : α) : toIocDiv hp a b • p + toIocMod hp a b = b := by
rw [add_comm, toIocMod_add_toIocDiv_zsmul]
#align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod
theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by
refine
⟨fun h =>
⟨h ▸ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h ▸ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩,
?_⟩
simp_rw [← @sub_eq_iff_eq_add]
rintro ⟨hc, n, rfl⟩
rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod]
#align to_Ico_mod_eq_iff toIcoMod_eq_iff
theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by
refine
⟨fun h =>
⟨h ▸ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h ▸ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩,
?_⟩
simp_rw [← @sub_eq_iff_eq_add]
rintro ⟨hc, n, rfl⟩
rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod]
#align to_Ioc_mod_eq_iff toIocMod_eq_iff
@[simp]
theorem toIcoDiv_apply_left (a : α) : toIcoDiv hp a a = 0 :=
toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp]
#align to_Ico_div_apply_left toIcoDiv_apply_left
@[simp]
theorem toIocDiv_apply_left (a : α) : toIocDiv hp a a = -1 :=
toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp]
#align to_Ioc_div_apply_left toIocDiv_apply_left
@[simp]
theorem toIcoMod_apply_left (a : α) : toIcoMod hp a a = a := by
rw [toIcoMod_eq_iff hp, Set.left_mem_Ico]
exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩
#align to_Ico_mod_apply_left toIcoMod_apply_left
@[simp]
theorem toIocMod_apply_left (a : α) : toIocMod hp a a = a + p := by
rw [toIocMod_eq_iff hp, Set.right_mem_Ioc]
exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩
#align to_Ioc_mod_apply_left toIocMod_apply_left
theorem toIcoDiv_apply_right (a : α) : toIcoDiv hp a (a + p) = 1 :=
toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp]
#align to_Ico_div_apply_right toIcoDiv_apply_right
theorem toIocDiv_apply_right (a : α) : toIocDiv hp a (a + p) = 0 :=
toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp]
#align to_Ioc_div_apply_right toIocDiv_apply_right
theorem toIcoMod_apply_right (a : α) : toIcoMod hp a (a + p) = a := by
rw [toIcoMod_eq_iff hp, Set.left_mem_Ico]
exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩
#align to_Ico_mod_apply_right toIcoMod_apply_right
theorem toIocMod_apply_right (a : α) : toIocMod hp a (a + p) = a + p := by
rw [toIocMod_eq_iff hp, Set.right_mem_Ioc]
exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩
#align to_Ioc_mod_apply_right toIocMod_apply_right
@[simp]
theorem toIcoDiv_add_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b + m • p) = toIcoDiv hp a b + m :=
toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by
simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b
#align to_Ico_div_add_zsmul toIcoDiv_add_zsmul
@[simp]
theorem toIcoDiv_add_zsmul' (a b : α) (m : ℤ) :
toIcoDiv hp (a + m • p) b = toIcoDiv hp a b - m := by
refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_
rw [sub_smul, ← sub_add, add_right_comm]
simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b
#align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul'
@[simp]
theorem toIocDiv_add_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b + m • p) = toIocDiv hp a b + m :=
toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by
simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b
#align to_Ioc_div_add_zsmul toIocDiv_add_zsmul
@[simp]
theorem toIocDiv_add_zsmul' (a b : α) (m : ℤ) :
toIocDiv hp (a + m • p) b = toIocDiv hp a b - m := by
refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_
rw [sub_smul, ← sub_add, add_right_comm]
simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b
#align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul'
@[simp]
theorem toIcoDiv_zsmul_add (a b : α) (m : ℤ) : toIcoDiv hp a (m • p + b) = m + toIcoDiv hp a b := by
rw [add_comm, toIcoDiv_add_zsmul, add_comm]
#align to_Ico_div_zsmul_add toIcoDiv_zsmul_add
@[simp]
theorem toIocDiv_zsmul_add (a b : α) (m : ℤ) : toIocDiv hp a (m • p + b) = m + toIocDiv hp a b := by
rw [add_comm, toIocDiv_add_zsmul, add_comm]
#align to_Ioc_div_zsmul_add toIocDiv_zsmul_add
@[simp]
theorem toIcoDiv_sub_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b - m • p) = toIcoDiv hp a b - m := by
rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg]
#align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul
@[simp]
theorem toIcoDiv_sub_zsmul' (a b : α) (m : ℤ) :
toIcoDiv hp (a - m • p) b = toIcoDiv hp a b + m := by
rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add]
#align to_Ico_div_sub_zsmul' toIcoDiv_sub_zsmul'
@[simp]
theorem toIocDiv_sub_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b - m • p) = toIocDiv hp a b - m := by
rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul, sub_eq_add_neg]
#align to_Ioc_div_sub_zsmul toIocDiv_sub_zsmul
@[simp]
theorem toIocDiv_sub_zsmul' (a b : α) (m : ℤ) :
toIocDiv hp (a - m • p) b = toIocDiv hp a b + m := by
rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul', sub_neg_eq_add]
#align to_Ioc_div_sub_zsmul' toIocDiv_sub_zsmul'
@[simp]
theorem toIcoDiv_add_right (a b : α) : toIcoDiv hp a (b + p) = toIcoDiv hp a b + 1 := by
simpa only [one_zsmul] using toIcoDiv_add_zsmul hp a b 1
#align to_Ico_div_add_right toIcoDiv_add_right
@[simp]
theorem toIcoDiv_add_right' (a b : α) : toIcoDiv hp (a + p) b = toIcoDiv hp a b - 1 := by
simpa only [one_zsmul] using toIcoDiv_add_zsmul' hp a b 1
#align to_Ico_div_add_right' toIcoDiv_add_right'
@[simp]
theorem toIocDiv_add_right (a b : α) : toIocDiv hp a (b + p) = toIocDiv hp a b + 1 := by
simpa only [one_zsmul] using toIocDiv_add_zsmul hp a b 1
#align to_Ioc_div_add_right toIocDiv_add_right
@[simp]
theorem toIocDiv_add_right' (a b : α) : toIocDiv hp (a + p) b = toIocDiv hp a b - 1 := by
simpa only [one_zsmul] using toIocDiv_add_zsmul' hp a b 1
#align to_Ioc_div_add_right' toIocDiv_add_right'
@[simp]
theorem toIcoDiv_add_left (a b : α) : toIcoDiv hp a (p + b) = toIcoDiv hp a b + 1 := by
rw [add_comm, toIcoDiv_add_right]
#align to_Ico_div_add_left toIcoDiv_add_left
@[simp]
theorem toIcoDiv_add_left' (a b : α) : toIcoDiv hp (p + a) b = toIcoDiv hp a b - 1 := by
rw [add_comm, toIcoDiv_add_right']
#align to_Ico_div_add_left' toIcoDiv_add_left'
@[simp]
theorem toIocDiv_add_left (a b : α) : toIocDiv hp a (p + b) = toIocDiv hp a b + 1 := by
rw [add_comm, toIocDiv_add_right]
#align to_Ioc_div_add_left toIocDiv_add_left
@[simp]
theorem toIocDiv_add_left' (a b : α) : toIocDiv hp (p + a) b = toIocDiv hp a b - 1 := by
rw [add_comm, toIocDiv_add_right']
#align to_Ioc_div_add_left' toIocDiv_add_left'
@[simp]
theorem toIcoDiv_sub (a b : α) : toIcoDiv hp a (b - p) = toIcoDiv hp a b - 1 := by
simpa only [one_zsmul] using toIcoDiv_sub_zsmul hp a b 1
#align to_Ico_div_sub toIcoDiv_sub
@[simp]
theorem toIcoDiv_sub' (a b : α) : toIcoDiv hp (a - p) b = toIcoDiv hp a b + 1 := by
simpa only [one_zsmul] using toIcoDiv_sub_zsmul' hp a b 1
#align to_Ico_div_sub' toIcoDiv_sub'
@[simp]
theorem toIocDiv_sub (a b : α) : toIocDiv hp a (b - p) = toIocDiv hp a b - 1 := by
simpa only [one_zsmul] using toIocDiv_sub_zsmul hp a b 1
#align to_Ioc_div_sub toIocDiv_sub
@[simp]
theorem toIocDiv_sub' (a b : α) : toIocDiv hp (a - p) b = toIocDiv hp a b + 1 := by
simpa only [one_zsmul] using toIocDiv_sub_zsmul' hp a b 1
#align to_Ioc_div_sub' toIocDiv_sub'
theorem toIcoDiv_sub_eq_toIcoDiv_add (a b c : α) :
toIcoDiv hp a (b - c) = toIcoDiv hp (a + c) b := by
apply toIcoDiv_eq_of_sub_zsmul_mem_Ico
rw [← sub_right_comm, Set.sub_mem_Ico_iff_left, add_right_comm]
exact sub_toIcoDiv_zsmul_mem_Ico hp (a + c) b
#align to_Ico_div_sub_eq_to_Ico_div_add toIcoDiv_sub_eq_toIcoDiv_add
theorem toIocDiv_sub_eq_toIocDiv_add (a b c : α) :
toIocDiv hp a (b - c) = toIocDiv hp (a + c) b := by
apply toIocDiv_eq_of_sub_zsmul_mem_Ioc
rw [← sub_right_comm, Set.sub_mem_Ioc_iff_left, add_right_comm]
exact sub_toIocDiv_zsmul_mem_Ioc hp (a + c) b
#align to_Ioc_div_sub_eq_to_Ioc_div_add toIocDiv_sub_eq_toIocDiv_add
theorem toIcoDiv_sub_eq_toIcoDiv_add' (a b c : α) :
toIcoDiv hp (a - c) b = toIcoDiv hp a (b + c) := by
rw [← sub_neg_eq_add, toIcoDiv_sub_eq_toIcoDiv_add, sub_eq_add_neg]
#align to_Ico_div_sub_eq_to_Ico_div_add' toIcoDiv_sub_eq_toIcoDiv_add'
theorem toIocDiv_sub_eq_toIocDiv_add' (a b c : α) :
toIocDiv hp (a - c) b = toIocDiv hp a (b + c) := by
rw [← sub_neg_eq_add, toIocDiv_sub_eq_toIocDiv_add, sub_eq_add_neg]
#align to_Ioc_div_sub_eq_to_Ioc_div_add' toIocDiv_sub_eq_toIocDiv_add'
theorem toIcoDiv_neg (a b : α) : toIcoDiv hp a (-b) = -(toIocDiv hp (-a) b + 1) := by
suffices toIcoDiv hp a (-b) = -toIocDiv hp (-(a + p)) b by
rwa [neg_add, ← sub_eq_add_neg, toIocDiv_sub_eq_toIocDiv_add', toIocDiv_add_right] at this
rw [← neg_eq_iff_eq_neg, eq_comm]
apply toIocDiv_eq_of_sub_zsmul_mem_Ioc
obtain ⟨hc, ho⟩ := sub_toIcoDiv_zsmul_mem_Ico hp a (-b)
rw [← neg_lt_neg_iff, neg_sub' (-b), neg_neg, ← neg_smul] at ho
rw [← neg_le_neg_iff, neg_sub' (-b), neg_neg, ← neg_smul] at hc
refine ⟨ho, hc.trans_eq ?_⟩
rw [neg_add, neg_add_cancel_right]
#align to_Ico_div_neg toIcoDiv_neg
theorem toIcoDiv_neg' (a b : α) : toIcoDiv hp (-a) b = -(toIocDiv hp a (-b) + 1) := by
simpa only [neg_neg] using toIcoDiv_neg hp (-a) (-b)
#align to_Ico_div_neg' toIcoDiv_neg'
theorem toIocDiv_neg (a b : α) : toIocDiv hp a (-b) = -(toIcoDiv hp (-a) b + 1) := by
rw [← neg_neg b, toIcoDiv_neg, neg_neg, neg_neg, neg_add', neg_neg, add_sub_cancel_right]
#align to_Ioc_div_neg toIocDiv_neg
theorem toIocDiv_neg' (a b : α) : toIocDiv hp (-a) b = -(toIcoDiv hp a (-b) + 1) := by
simpa only [neg_neg] using toIocDiv_neg hp (-a) (-b)
#align to_Ioc_div_neg' toIocDiv_neg'
@[simp]
theorem toIcoMod_add_zsmul (a b : α) (m : ℤ) : toIcoMod hp a (b + m • p) = toIcoMod hp a b := by
rw [toIcoMod, toIcoDiv_add_zsmul, toIcoMod, add_smul]
abel
#align to_Ico_mod_add_zsmul toIcoMod_add_zsmul
@[simp]
theorem toIcoMod_add_zsmul' (a b : α) (m : ℤ) :
toIcoMod hp (a + m • p) b = toIcoMod hp a b + m • p := by
simp only [toIcoMod, toIcoDiv_add_zsmul', sub_smul, sub_add]
#align to_Ico_mod_add_zsmul' toIcoMod_add_zsmul'
@[simp]
theorem toIocMod_add_zsmul (a b : α) (m : ℤ) : toIocMod hp a (b + m • p) = toIocMod hp a b := by
rw [toIocMod, toIocDiv_add_zsmul, toIocMod, add_smul]
abel
#align to_Ioc_mod_add_zsmul toIocMod_add_zsmul
@[simp]
theorem toIocMod_add_zsmul' (a b : α) (m : ℤ) :
toIocMod hp (a + m • p) b = toIocMod hp a b + m • p := by
simp only [toIocMod, toIocDiv_add_zsmul', sub_smul, sub_add]
#align to_Ioc_mod_add_zsmul' toIocMod_add_zsmul'
@[simp]
theorem toIcoMod_zsmul_add (a b : α) (m : ℤ) : toIcoMod hp a (m • p + b) = toIcoMod hp a b := by
rw [add_comm, toIcoMod_add_zsmul]
#align to_Ico_mod_zsmul_add toIcoMod_zsmul_add
@[simp]
theorem toIcoMod_zsmul_add' (a b : α) (m : ℤ) :
toIcoMod hp (m • p + a) b = m • p + toIcoMod hp a b := by
rw [add_comm, toIcoMod_add_zsmul', add_comm]
#align to_Ico_mod_zsmul_add' toIcoMod_zsmul_add'
@[simp]
theorem toIocMod_zsmul_add (a b : α) (m : ℤ) : toIocMod hp a (m • p + b) = toIocMod hp a b := by
rw [add_comm, toIocMod_add_zsmul]
#align to_Ioc_mod_zsmul_add toIocMod_zsmul_add
@[simp]
theorem toIocMod_zsmul_add' (a b : α) (m : ℤ) :
toIocMod hp (m • p + a) b = m • p + toIocMod hp a b := by
rw [add_comm, toIocMod_add_zsmul', add_comm]
#align to_Ioc_mod_zsmul_add' toIocMod_zsmul_add'
@[simp]
theorem toIcoMod_sub_zsmul (a b : α) (m : ℤ) : toIcoMod hp a (b - m • p) = toIcoMod hp a b := by
rw [sub_eq_add_neg, ← neg_smul, toIcoMod_add_zsmul]
#align to_Ico_mod_sub_zsmul toIcoMod_sub_zsmul
@[simp]
theorem toIcoMod_sub_zsmul' (a b : α) (m : ℤ) :
toIcoMod hp (a - m • p) b = toIcoMod hp a b - m • p := by
simp_rw [sub_eq_add_neg, ← neg_smul, toIcoMod_add_zsmul']
#align to_Ico_mod_sub_zsmul' toIcoMod_sub_zsmul'
@[simp]
theorem toIocMod_sub_zsmul (a b : α) (m : ℤ) : toIocMod hp a (b - m • p) = toIocMod hp a b := by
rw [sub_eq_add_neg, ← neg_smul, toIocMod_add_zsmul]
#align to_Ioc_mod_sub_zsmul toIocMod_sub_zsmul
@[simp]
theorem toIocMod_sub_zsmul' (a b : α) (m : ℤ) :
toIocMod hp (a - m • p) b = toIocMod hp a b - m • p := by
simp_rw [sub_eq_add_neg, ← neg_smul, toIocMod_add_zsmul']
#align to_Ioc_mod_sub_zsmul' toIocMod_sub_zsmul'
@[simp]
theorem toIcoMod_add_right (a b : α) : toIcoMod hp a (b + p) = toIcoMod hp a b := by
simpa only [one_zsmul] using toIcoMod_add_zsmul hp a b 1
#align to_Ico_mod_add_right toIcoMod_add_right
@[simp]
| Mathlib/Algebra/Order/ToIntervalMod.lean | 480 | 481 | theorem toIcoMod_add_right' (a b : α) : toIcoMod hp (a + p) b = toIcoMod hp a b + p := by |
simpa only [one_zsmul] using toIcoMod_add_zsmul' hp a b 1
|
import Mathlib.Analysis.Convex.Gauge
import Mathlib.Analysis.Convex.Normed
open Metric Bornology Filter Set
open scoped NNReal Topology Pointwise
noncomputable section
section Module
variable {E : Type*} [AddCommGroup E] [Module ℝ E]
def gaugeRescale (s t : Set E) (x : E) : E := (gauge s x / gauge t x) • x
theorem gaugeRescale_def (s t : Set E) (x : E) :
gaugeRescale s t x = (gauge s x / gauge t x) • x :=
rfl
@[simp] theorem gaugeRescale_zero (s t : Set E) : gaugeRescale s t 0 = 0 := smul_zero _
theorem gaugeRescale_smul (s t : Set E) {c : ℝ} (hc : 0 ≤ c) (x : E) :
gaugeRescale s t (c • x) = c • gaugeRescale s t x := by
simp only [gaugeRescale, gauge_smul_of_nonneg hc, smul_smul, smul_eq_mul]
rw [mul_div_mul_comm, mul_right_comm, div_self_mul_self]
variable [TopologicalSpace E] [T1Space E]
| Mathlib/Analysis/Convex/GaugeRescale.lean | 48 | 52 | theorem gaugeRescale_self_apply {s : Set E} (hsa : Absorbent ℝ s) (hsb : IsVonNBounded ℝ s)
(x : E) : gaugeRescale s s x = x := by |
rcases eq_or_ne x 0 with rfl | hx; · simp
rw [gaugeRescale, div_self, one_smul]
exact ((gauge_pos hsa hsb).2 hx).ne'
|
import Mathlib.CategoryTheory.Sites.Sieves
#align_import category_theory.sites.sheaf_of_types from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
universe w v₁ v₂ u₁ u₂
namespace CategoryTheory
open Opposite CategoryTheory Category Limits Sieve
namespace Presieve
variable {C : Type u₁} [Category.{v₁} C]
variable {P Q U : Cᵒᵖ ⥤ Type w}
variable {X Y : C} {S : Sieve X} {R : Presieve X}
def FamilyOfElements (P : Cᵒᵖ ⥤ Type w) (R : Presieve X) :=
∀ ⦃Y : C⦄ (f : Y ⟶ X), R f → P.obj (op Y)
#align category_theory.presieve.family_of_elements CategoryTheory.Presieve.FamilyOfElements
instance : Inhabited (FamilyOfElements P (⊥ : Presieve X)) :=
⟨fun _ _ => False.elim⟩
def FamilyOfElements.restrict {R₁ R₂ : Presieve X} (h : R₁ ≤ R₂) :
FamilyOfElements P R₂ → FamilyOfElements P R₁ := fun x _ f hf => x f (h _ hf)
#align category_theory.presieve.family_of_elements.restrict CategoryTheory.Presieve.FamilyOfElements.restrict
def FamilyOfElements.map (p : FamilyOfElements P R) (φ : P ⟶ Q) :
FamilyOfElements Q R :=
fun _ f hf => φ.app _ (p f hf)
@[simp]
lemma FamilyOfElements.map_apply
(p : FamilyOfElements P R) (φ : P ⟶ Q) {Y : C} (f : Y ⟶ X) (hf : R f) :
p.map φ f hf = φ.app _ (p f hf) := rfl
lemma FamilyOfElements.restrict_map
(p : FamilyOfElements P R) (φ : P ⟶ Q) {R' : Presieve X} (h : R' ≤ R) :
(p.restrict h).map φ = (p.map φ).restrict h := rfl
def FamilyOfElements.Compatible (x : FamilyOfElements P R) : Prop :=
∀ ⦃Y₁ Y₂ Z⦄ (g₁ : Z ⟶ Y₁) (g₂ : Z ⟶ Y₂) ⦃f₁ : Y₁ ⟶ X⦄ ⦃f₂ : Y₂ ⟶ X⦄ (h₁ : R f₁) (h₂ : R f₂),
g₁ ≫ f₁ = g₂ ≫ f₂ → P.map g₁.op (x f₁ h₁) = P.map g₂.op (x f₂ h₂)
#align category_theory.presieve.family_of_elements.compatible CategoryTheory.Presieve.FamilyOfElements.Compatible
def FamilyOfElements.PullbackCompatible (x : FamilyOfElements P R) [R.hasPullbacks] : Prop :=
∀ ⦃Y₁ Y₂⦄ ⦃f₁ : Y₁ ⟶ X⦄ ⦃f₂ : Y₂ ⟶ X⦄ (h₁ : R f₁) (h₂ : R f₂),
haveI := hasPullbacks.has_pullbacks h₁ h₂
P.map (pullback.fst : Limits.pullback f₁ f₂ ⟶ _).op (x f₁ h₁) = P.map pullback.snd.op (x f₂ h₂)
#align category_theory.presieve.family_of_elements.pullback_compatible CategoryTheory.Presieve.FamilyOfElements.PullbackCompatible
theorem pullbackCompatible_iff (x : FamilyOfElements P R) [R.hasPullbacks] :
x.Compatible ↔ x.PullbackCompatible := by
constructor
· intro t Y₁ Y₂ f₁ f₂ hf₁ hf₂
apply t
haveI := hasPullbacks.has_pullbacks hf₁ hf₂
apply pullback.condition
· intro t Y₁ Y₂ Z g₁ g₂ f₁ f₂ hf₁ hf₂ comm
haveI := hasPullbacks.has_pullbacks hf₁ hf₂
rw [← pullback.lift_fst _ _ comm, op_comp, FunctorToTypes.map_comp_apply, t hf₁ hf₂,
← FunctorToTypes.map_comp_apply, ← op_comp, pullback.lift_snd]
#align category_theory.presieve.pullback_compatible_iff CategoryTheory.Presieve.pullbackCompatible_iff
theorem FamilyOfElements.Compatible.restrict {R₁ R₂ : Presieve X} (h : R₁ ≤ R₂)
{x : FamilyOfElements P R₂} : x.Compatible → (x.restrict h).Compatible :=
fun q _ _ _ g₁ g₂ _ _ h₁ h₂ comm => q g₁ g₂ (h _ h₁) (h _ h₂) comm
#align category_theory.presieve.family_of_elements.compatible.restrict CategoryTheory.Presieve.FamilyOfElements.Compatible.restrict
noncomputable def FamilyOfElements.sieveExtend (x : FamilyOfElements P R) :
FamilyOfElements P (generate R : Presieve X) := fun _ _ hf =>
P.map hf.choose_spec.choose.op (x _ hf.choose_spec.choose_spec.choose_spec.1)
#align category_theory.presieve.family_of_elements.sieve_extend CategoryTheory.Presieve.FamilyOfElements.sieveExtend
theorem FamilyOfElements.Compatible.sieveExtend {x : FamilyOfElements P R} (hx : x.Compatible) :
x.sieveExtend.Compatible := by
intro _ _ _ _ _ _ _ h₁ h₂ comm
iterate 2 erw [← FunctorToTypes.map_comp_apply]; rw [← op_comp]
apply hx
simp [comm, h₁.choose_spec.choose_spec.choose_spec.2, h₂.choose_spec.choose_spec.choose_spec.2]
#align category_theory.presieve.family_of_elements.compatible.sieve_extend CategoryTheory.Presieve.FamilyOfElements.Compatible.sieveExtend
| Mathlib/CategoryTheory/Sites/IsSheafFor.lean | 195 | 202 | theorem extend_agrees {x : FamilyOfElements P R} (t : x.Compatible) {f : Y ⟶ X} (hf : R f) :
x.sieveExtend f (le_generate R Y hf) = x f hf := by |
have h := (le_generate R Y hf).choose_spec
unfold FamilyOfElements.sieveExtend
rw [t h.choose (𝟙 _) _ hf _]
· simp
· rw [id_comp]
exact h.choose_spec.choose_spec.2
|
import Mathlib.Init.Data.Prod
import Mathlib.Data.Seq.WSeq
#align_import data.seq.parallel from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
universe u v
namespace Computation
open Stream'
variable {α : Type u} {β : Type v}
def parallel.aux2 : List (Computation α) → Sum α (List (Computation α)) :=
List.foldr
(fun c o =>
match o with
| Sum.inl a => Sum.inl a
| Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
(Sum.inr [])
#align computation.parallel.aux2 Computation.parallel.aux2
def parallel.aux1 :
List (Computation α) × WSeq (Computation α) →
Sum α (List (Computation α) × WSeq (Computation α))
| (l, S) =>
rmap
(fun l' =>
match Seq.destruct S with
| none => (l', Seq.nil)
| some (none, S') => (l', S')
| some (some c, S') => (c :: l', S'))
(parallel.aux2 l)
#align computation.parallel.aux1 Computation.parallel.aux1
def parallel (S : WSeq (Computation α)) : Computation α :=
corec parallel.aux1 ([], S)
#align computation.parallel Computation.parallel
theorem terminates_parallel.aux :
∀ {l : List (Computation α)} {S c},
c ∈ l → Terminates c → Terminates (corec parallel.aux1 (l, S)) := by
have lem1 :
∀ l S, (∃ a : α, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S)) := by
intro l S e
cases' e with a e
have : corec parallel.aux1 (l, S) = return a := by
apply destruct_eq_pure
simp only [parallel.aux1, rmap, corec_eq]
rw [e]
rw [this]
-- Porting note: This line is required.
exact ret_terminates a
intro l S c m T
revert l S
apply @terminatesRecOn _ _ c T _ _
· intro a l S m
apply lem1
induction' l with c l IH <;> simp at m
cases' m with e m
· rw [← e]
simp only [parallel.aux2, rmap, List.foldr_cons, destruct_pure]
split <;> simp
· cases' IH m with a' e
simp only [parallel.aux2, rmap, List.foldr_cons]
simp? [parallel.aux2] at e says simp only [parallel.aux2, rmap] at e
rw [e]
exact ⟨a', rfl⟩
· intro s IH l S m
have H1 : ∀ l', parallel.aux2 l = Sum.inr l' → s ∈ l' := by
induction' l with c l IH' <;> intro l' e' <;> simp at m
cases' m with e m <;> simp [parallel.aux2] at e'
· rw [← e] at e'
-- Porting note: `revert e'` & `intro e'` are required.
revert e'
split
· simp
· simp only [destruct_think, Sum.inr.injEq]
rintro rfl
simp
· induction' e : List.foldr (fun c o =>
match o with
| Sum.inl a => Sum.inl a
| Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
(Sum.inr List.nil) l with a' ls <;> erw [e] at e'
· contradiction
have := IH' m _ e
-- Porting note: `revert e'` & `intro e'` are required.
revert e'
cases destruct c <;> intro e' <;> [injection e'; injection e' with h']
rw [← h']
simp [this]
induction' h : parallel.aux2 l with a l'
· exact lem1 _ _ ⟨a, h⟩
· have H2 : corec parallel.aux1 (l, S) = think _ := destruct_eq_think (by
simp only [parallel.aux1, rmap, corec_eq]
rw [h])
rw [H2]
refine @Computation.think_terminates _ _ ?_
have := H1 _ h
rcases Seq.destruct S with (_ | ⟨_ | c, S'⟩) <;> simp [parallel.aux1] <;> apply IH <;>
simp [this]
#align computation.terminates_parallel.aux Computation.terminates_parallel.aux
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
Terminates (parallel S) := by
suffices
∀ (n) (l : List (Computation α)) (S c),
c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
from
let ⟨n, h⟩ := h
this n [] S c (Or.inr h) T
intro n; induction' n with n IH <;> intro l S c o T
· cases' o with a a
· exact terminates_parallel.aux a T
have H : Seq.destruct S = some (some c, Seq.tail S) := by simp [Seq.destruct, (· <$> ·), ← a]
induction' h : parallel.aux2 l with a l'
· have C : corec parallel.aux1 (l, S) = pure a := by
apply destruct_eq_pure
rw [corec_eq, parallel.aux1]
dsimp only []
rw [h]
simp only [rmap]
rw [C]
infer_instance
· have C : corec parallel.aux1 (l, S) = _ := destruct_eq_think (by
simp only [corec_eq, rmap, parallel.aux1.eq_1]
rw [h, H])
rw [C]
refine @Computation.think_terminates _ _ ?_
apply terminates_parallel.aux _ T
simp
· cases' o with a a
· exact terminates_parallel.aux a T
induction' h : parallel.aux2 l with a l'
· have C : corec parallel.aux1 (l, S) = pure a := by
apply destruct_eq_pure
rw [corec_eq, parallel.aux1]
dsimp only []
rw [h]
simp only [rmap]
rw [C]
infer_instance
· have C : corec parallel.aux1 (l, S) = _ := destruct_eq_think (by
simp only [corec_eq, rmap, parallel.aux1.eq_1]
rw [h])
rw [C]
refine @Computation.think_terminates _ _ ?_
have TT : ∀ l', Terminates (corec parallel.aux1 (l', S.tail)) := by
intro
apply IH _ _ _ (Or.inr _) T
rw [a]
cases' S with f al
rfl
induction' e : Seq.get? S 0 with o
· have D : Seq.destruct S = none := by
dsimp [Seq.destruct]
rw [e]
rfl
rw [D]
simp only
have TT := TT l'
rwa [Seq.destruct_eq_nil D, Seq.tail_nil] at TT
· have D : Seq.destruct S = some (o, S.tail) := by
dsimp [Seq.destruct]
rw [e]
rfl
rw [D]
cases' o with c <;> simp [parallel.aux1, TT]
#align computation.terminates_parallel Computation.terminates_parallel
| Mathlib/Data/Seq/Parallel.lean | 189 | 266 | theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parallel S) :
∃ c ∈ S, a ∈ c := by |
suffices
∀ C, a ∈ C → ∀ (l : List (Computation α)) (S),
corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c from
let ⟨c, h1, h2⟩ := this _ h [] S rfl
⟨c, h1.resolve_left <| List.not_mem_nil _, h2⟩
let F : List (Computation α) → Sum α (List (Computation α)) → Prop := by
intro l a
cases' a with a l'
· exact ∃ c ∈ l, a ∈ c
· exact ∀ a', (∃ c ∈ l', a' ∈ c) → ∃ c ∈ l, a' ∈ c
have lem1 : ∀ l : List (Computation α), F l (parallel.aux2 l) := by
intro l
induction' l with c l IH <;> simp only [parallel.aux2, List.foldr]
· intro a h
rcases h with ⟨c, hn, _⟩
exact False.elim <| List.not_mem_nil _ hn
· simp only [parallel.aux2] at IH
-- Porting note: `revert IH` & `intro IH` are required.
revert IH
cases' List.foldr (fun c o =>
match o with
| Sum.inl a => Sum.inl a
| Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) (Sum.inr List.nil) l with a ls <;>
intro IH <;>
simp only [parallel.aux2]
· rcases IH with ⟨c', cl, ac⟩
exact ⟨c', List.Mem.tail _ cl, ac⟩
· induction' h : destruct c with a c' <;> simp only [rmap]
· refine ⟨c, List.mem_cons_self _ _, ?_⟩
rw [destruct_eq_pure h]
apply ret_mem
· intro a' h
rcases h with ⟨d, dm, ad⟩
simp? at dm says simp only [List.mem_cons] at dm
cases' dm with e dl
· rw [e] at ad
refine ⟨c, List.mem_cons_self _ _, ?_⟩
rw [destruct_eq_think h]
exact think_mem ad
· cases' IH a' ⟨d, dl, ad⟩ with d dm
cases' dm with dm ad
exact ⟨d, List.Mem.tail _ dm, ad⟩
intro C aC
-- Porting note: `revert e'` & `intro e'` are required.
apply memRecOn aC <;> [skip; intro C' IH] <;> intro l S e <;> have e' := congr_arg destruct e <;>
have := lem1 l <;> simp only [parallel.aux1, corec_eq, destruct_pure, destruct_think] at e' <;>
revert this e' <;> cases' parallel.aux2 l with a' l' <;> intro this e' <;>
[injection e' with h'; injection e'; injection e'; injection e' with h']
· rw [h'] at this
rcases this with ⟨c, cl, ac⟩
exact ⟨c, Or.inl cl, ac⟩
· induction' e : Seq.destruct S with a <;> rw [e] at h'
· exact
let ⟨d, o, ad⟩ := IH _ _ h'
let ⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (WSeq.not_mem_nil _), ad⟩
⟨c, Or.inl cl, ac⟩
· cases' a with o S'
cases' o with c <;> simp [parallel.aux1] at h' <;> rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
· exact
let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩
⟨c, Or.inl cl, ac⟩
· refine ⟨d, Or.inr ?_, ad⟩
rw [Seq.destruct_eq_cons e]
exact Seq.mem_cons_of_mem _ dS'
· simp at dl
cases' dl with dc dl
· rw [dc] at ad
refine ⟨c, Or.inr ?_, ad⟩
rw [Seq.destruct_eq_cons e]
apply Seq.mem_cons
· exact
let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩
⟨c, Or.inl cl, ac⟩
· refine ⟨d, Or.inr ?_, ad⟩
rw [Seq.destruct_eq_cons e]
exact Seq.mem_cons_of_mem _ dS'
|
import Mathlib.Algebra.Group.Equiv.Basic
import Mathlib.Algebra.Group.Aut
import Mathlib.Data.ZMod.Defs
import Mathlib.Tactic.Ring
#align_import algebra.quandle from "leanprover-community/mathlib"@"28aa996fc6fb4317f0083c4e6daf79878d81be33"
open MulOpposite
universe u v
class Shelf (α : Type u) where
act : α → α → α
self_distrib : ∀ {x y z : α}, act x (act y z) = act (act x y) (act x z)
#align shelf Shelf
class UnitalShelf (α : Type u) extends Shelf α, One α :=
(one_act : ∀ a : α, act 1 a = a)
(act_one : ∀ a : α, act a 1 = a)
#align unital_shelf UnitalShelf
@[ext]
structure ShelfHom (S₁ : Type*) (S₂ : Type*) [Shelf S₁] [Shelf S₂] where
toFun : S₁ → S₂
map_act' : ∀ {x y : S₁}, toFun (Shelf.act x y) = Shelf.act (toFun x) (toFun y)
#align shelf_hom ShelfHom
#align shelf_hom.ext_iff ShelfHom.ext_iff
#align shelf_hom.ext ShelfHom.ext
class Rack (α : Type u) extends Shelf α where
invAct : α → α → α
left_inv : ∀ x, Function.LeftInverse (invAct x) (act x)
right_inv : ∀ x, Function.RightInverse (invAct x) (act x)
#align rack Rack
scoped[Quandles] infixr:65 " ◃ " => Shelf.act
scoped[Quandles] infixr:65 " ◃⁻¹ " => Rack.invAct
scoped[Quandles] infixr:25 " →◃ " => ShelfHom
open Quandles
namespace Rack
variable {R : Type*} [Rack R]
-- Porting note: No longer a need for `Rack.self_distrib`
export Shelf (self_distrib)
-- porting note, changed name to `act'` to not conflict with `Shelf.act`
def act' (x : R) : R ≃ R where
toFun := Shelf.act x
invFun := invAct x
left_inv := left_inv x
right_inv := right_inv x
#align rack.act Rack.act'
@[simp]
theorem act'_apply (x y : R) : act' x y = x ◃ y :=
rfl
#align rack.act_apply Rack.act'_apply
@[simp]
theorem act'_symm_apply (x y : R) : (act' x).symm y = x ◃⁻¹ y :=
rfl
#align rack.act_symm_apply Rack.act'_symm_apply
@[simp]
theorem invAct_apply (x y : R) : (act' x)⁻¹ y = x ◃⁻¹ y :=
rfl
#align rack.inv_act_apply Rack.invAct_apply
@[simp]
theorem invAct_act_eq (x y : R) : x ◃⁻¹ x ◃ y = y :=
left_inv x y
#align rack.inv_act_act_eq Rack.invAct_act_eq
@[simp]
theorem act_invAct_eq (x y : R) : x ◃ x ◃⁻¹ y = y :=
right_inv x y
#align rack.act_inv_act_eq Rack.act_invAct_eq
theorem left_cancel (x : R) {y y' : R} : x ◃ y = x ◃ y' ↔ y = y' := by
constructor
· apply (act' x).injective
rintro rfl
rfl
#align rack.left_cancel Rack.left_cancel
| Mathlib/Algebra/Quandle.lean | 232 | 236 | theorem left_cancel_inv (x : R) {y y' : R} : x ◃⁻¹ y = x ◃⁻¹ y' ↔ y = y' := by |
constructor
· apply (act' x).symm.injective
rintro rfl
rfl
|
import Mathlib.Order.ConditionallyCompleteLattice.Basic
import Mathlib.Data.Set.Finite
#align_import order.conditionally_complete_lattice.finset from "leanprover-community/mathlib"@"2445c98ae4b87eabebdde552593519b9b6dc350c"
open Set
variable {ι α β γ : Type*}
section ConditionallyCompleteLinearOrder
variable [ConditionallyCompleteLinearOrder α] {s t : Set α} {a b : α}
theorem Finset.Nonempty.csSup_eq_max' {s : Finset α} (h : s.Nonempty) : sSup ↑s = s.max' h :=
eq_of_forall_ge_iff fun _ => (csSup_le_iff s.bddAbove h.to_set).trans (s.max'_le_iff h).symm
#align finset.nonempty.cSup_eq_max' Finset.Nonempty.csSup_eq_max'
theorem Finset.Nonempty.csInf_eq_min' {s : Finset α} (h : s.Nonempty) : sInf ↑s = s.min' h :=
@Finset.Nonempty.csSup_eq_max' αᵒᵈ _ s h
#align finset.nonempty.cInf_eq_min' Finset.Nonempty.csInf_eq_min'
| Mathlib/Order/ConditionallyCompleteLattice/Finset.lean | 33 | 35 | theorem Finset.Nonempty.csSup_mem {s : Finset α} (h : s.Nonempty) : sSup (s : Set α) ∈ s := by |
rw [h.csSup_eq_max']
exact s.max'_mem _
|
import Mathlib.Data.Nat.Lattice
import Mathlib.Logic.Denumerable
import Mathlib.Logic.Function.Iterate
import Mathlib.Order.Hom.Basic
import Mathlib.Data.Set.Subsingleton
#align_import order.order_iso_nat from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90"
variable {α : Type*}
namespace RelEmbedding
variable {r : α → α → Prop} [IsStrictOrder α r]
def natLT (f : ℕ → α) (H : ∀ n : ℕ, r (f n) (f (n + 1))) : ((· < ·) : ℕ → ℕ → Prop) ↪r r :=
ofMonotone f <| Nat.rel_of_forall_rel_succ_of_lt r H
#align rel_embedding.nat_lt RelEmbedding.natLT
@[simp]
theorem coe_natLT {f : ℕ → α} {H : ∀ n : ℕ, r (f n) (f (n + 1))} : ⇑(natLT f H) = f :=
rfl
#align rel_embedding.coe_nat_lt RelEmbedding.coe_natLT
def natGT (f : ℕ → α) (H : ∀ n : ℕ, r (f (n + 1)) (f n)) : ((· > ·) : ℕ → ℕ → Prop) ↪r r :=
haveI := IsStrictOrder.swap r
RelEmbedding.swap (natLT f H)
#align rel_embedding.nat_gt RelEmbedding.natGT
@[simp]
theorem coe_natGT {f : ℕ → α} {H : ∀ n : ℕ, r (f (n + 1)) (f n)} : ⇑(natGT f H) = f :=
rfl
#align rel_embedding.coe_nat_gt RelEmbedding.coe_natGT
| Mathlib/Order/OrderIsoNat.lean | 58 | 62 | theorem exists_not_acc_lt_of_not_acc {a : α} {r} (h : ¬Acc r a) : ∃ b, ¬Acc r b ∧ r b a := by |
contrapose! h
refine ⟨_, fun b hr => ?_⟩
by_contra hb
exact h b hb hr
|
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Data.Set.NAry
import Mathlib.Order.Directed
#align_import order.bounds.basic from "leanprover-community/mathlib"@"b1abe23ae96fef89ad30d9f4362c307f72a55010"
open Function Set
open OrderDual (toDual ofDual)
universe u v w x
variable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x}
section
variable [Preorder α] [Preorder β] {s t : Set α} {a b : α}
def upperBounds (s : Set α) : Set α :=
{ x | ∀ ⦃a⦄, a ∈ s → a ≤ x }
#align upper_bounds upperBounds
def lowerBounds (s : Set α) : Set α :=
{ x | ∀ ⦃a⦄, a ∈ s → x ≤ a }
#align lower_bounds lowerBounds
def BddAbove (s : Set α) :=
(upperBounds s).Nonempty
#align bdd_above BddAbove
def BddBelow (s : Set α) :=
(lowerBounds s).Nonempty
#align bdd_below BddBelow
def IsLeast (s : Set α) (a : α) : Prop :=
a ∈ s ∧ a ∈ lowerBounds s
#align is_least IsLeast
def IsGreatest (s : Set α) (a : α) : Prop :=
a ∈ s ∧ a ∈ upperBounds s
#align is_greatest IsGreatest
def IsLUB (s : Set α) : α → Prop :=
IsLeast (upperBounds s)
#align is_lub IsLUB
def IsGLB (s : Set α) : α → Prop :=
IsGreatest (lowerBounds s)
#align is_glb IsGLB
theorem mem_upperBounds : a ∈ upperBounds s ↔ ∀ x ∈ s, x ≤ a :=
Iff.rfl
#align mem_upper_bounds mem_upperBounds
theorem mem_lowerBounds : a ∈ lowerBounds s ↔ ∀ x ∈ s, a ≤ x :=
Iff.rfl
#align mem_lower_bounds mem_lowerBounds
lemma mem_upperBounds_iff_subset_Iic : a ∈ upperBounds s ↔ s ⊆ Iic a := Iff.rfl
#align mem_upper_bounds_iff_subset_Iic mem_upperBounds_iff_subset_Iic
lemma mem_lowerBounds_iff_subset_Ici : a ∈ lowerBounds s ↔ s ⊆ Ici a := Iff.rfl
#align mem_lower_bounds_iff_subset_Ici mem_lowerBounds_iff_subset_Ici
theorem bddAbove_def : BddAbove s ↔ ∃ x, ∀ y ∈ s, y ≤ x :=
Iff.rfl
#align bdd_above_def bddAbove_def
theorem bddBelow_def : BddBelow s ↔ ∃ x, ∀ y ∈ s, x ≤ y :=
Iff.rfl
#align bdd_below_def bddBelow_def
theorem bot_mem_lowerBounds [OrderBot α] (s : Set α) : ⊥ ∈ lowerBounds s := fun _ _ => bot_le
#align bot_mem_lower_bounds bot_mem_lowerBounds
theorem top_mem_upperBounds [OrderTop α] (s : Set α) : ⊤ ∈ upperBounds s := fun _ _ => le_top
#align top_mem_upper_bounds top_mem_upperBounds
@[simp]
theorem isLeast_bot_iff [OrderBot α] : IsLeast s ⊥ ↔ ⊥ ∈ s :=
and_iff_left <| bot_mem_lowerBounds _
#align is_least_bot_iff isLeast_bot_iff
@[simp]
theorem isGreatest_top_iff [OrderTop α] : IsGreatest s ⊤ ↔ ⊤ ∈ s :=
and_iff_left <| top_mem_upperBounds _
#align is_greatest_top_iff isGreatest_top_iff
theorem not_bddAbove_iff' : ¬BddAbove s ↔ ∀ x, ∃ y ∈ s, ¬y ≤ x := by
simp [BddAbove, upperBounds, Set.Nonempty]
#align not_bdd_above_iff' not_bddAbove_iff'
theorem not_bddBelow_iff' : ¬BddBelow s ↔ ∀ x, ∃ y ∈ s, ¬x ≤ y :=
@not_bddAbove_iff' αᵒᵈ _ _
#align not_bdd_below_iff' not_bddBelow_iff'
theorem not_bddAbove_iff {α : Type*} [LinearOrder α] {s : Set α} :
¬BddAbove s ↔ ∀ x, ∃ y ∈ s, x < y := by
simp only [not_bddAbove_iff', not_le]
#align not_bdd_above_iff not_bddAbove_iff
theorem not_bddBelow_iff {α : Type*} [LinearOrder α] {s : Set α} :
¬BddBelow s ↔ ∀ x, ∃ y ∈ s, y < x :=
@not_bddAbove_iff αᵒᵈ _ _
#align not_bdd_below_iff not_bddBelow_iff
@[simp] lemma bddBelow_preimage_ofDual {s : Set α} : BddBelow (ofDual ⁻¹' s) ↔ BddAbove s := Iff.rfl
@[simp] lemma bddAbove_preimage_ofDual {s : Set α} : BddAbove (ofDual ⁻¹' s) ↔ BddBelow s := Iff.rfl
@[simp] lemma bddBelow_preimage_toDual {s : Set αᵒᵈ} :
BddBelow (toDual ⁻¹' s) ↔ BddAbove s := Iff.rfl
@[simp] lemma bddAbove_preimage_toDual {s : Set αᵒᵈ} :
BddAbove (toDual ⁻¹' s) ↔ BddBelow s := Iff.rfl
theorem BddAbove.dual (h : BddAbove s) : BddBelow (ofDual ⁻¹' s) :=
h
#align bdd_above.dual BddAbove.dual
theorem BddBelow.dual (h : BddBelow s) : BddAbove (ofDual ⁻¹' s) :=
h
#align bdd_below.dual BddBelow.dual
theorem IsLeast.dual (h : IsLeast s a) : IsGreatest (ofDual ⁻¹' s) (toDual a) :=
h
#align is_least.dual IsLeast.dual
theorem IsGreatest.dual (h : IsGreatest s a) : IsLeast (ofDual ⁻¹' s) (toDual a) :=
h
#align is_greatest.dual IsGreatest.dual
theorem IsLUB.dual (h : IsLUB s a) : IsGLB (ofDual ⁻¹' s) (toDual a) :=
h
#align is_lub.dual IsLUB.dual
theorem IsGLB.dual (h : IsGLB s a) : IsLUB (ofDual ⁻¹' s) (toDual a) :=
h
#align is_glb.dual IsGLB.dual
abbrev IsLeast.orderBot (h : IsLeast s a) :
OrderBot s where
bot := ⟨a, h.1⟩
bot_le := Subtype.forall.2 h.2
#align is_least.order_bot IsLeast.orderBot
abbrev IsGreatest.orderTop (h : IsGreatest s a) :
OrderTop s where
top := ⟨a, h.1⟩
le_top := Subtype.forall.2 h.2
#align is_greatest.order_top IsGreatest.orderTop
theorem upperBounds_mono_set ⦃s t : Set α⦄ (hst : s ⊆ t) : upperBounds t ⊆ upperBounds s :=
fun _ hb _ h => hb <| hst h
#align upper_bounds_mono_set upperBounds_mono_set
theorem lowerBounds_mono_set ⦃s t : Set α⦄ (hst : s ⊆ t) : lowerBounds t ⊆ lowerBounds s :=
fun _ hb _ h => hb <| hst h
#align lower_bounds_mono_set lowerBounds_mono_set
theorem upperBounds_mono_mem ⦃a b⦄ (hab : a ≤ b) : a ∈ upperBounds s → b ∈ upperBounds s :=
fun ha _ h => le_trans (ha h) hab
#align upper_bounds_mono_mem upperBounds_mono_mem
theorem lowerBounds_mono_mem ⦃a b⦄ (hab : a ≤ b) : b ∈ lowerBounds s → a ∈ lowerBounds s :=
fun hb _ h => le_trans hab (hb h)
#align lower_bounds_mono_mem lowerBounds_mono_mem
theorem upperBounds_mono ⦃s t : Set α⦄ (hst : s ⊆ t) ⦃a b⦄ (hab : a ≤ b) :
a ∈ upperBounds t → b ∈ upperBounds s := fun ha =>
upperBounds_mono_set hst <| upperBounds_mono_mem hab ha
#align upper_bounds_mono upperBounds_mono
theorem lowerBounds_mono ⦃s t : Set α⦄ (hst : s ⊆ t) ⦃a b⦄ (hab : a ≤ b) :
b ∈ lowerBounds t → a ∈ lowerBounds s := fun hb =>
lowerBounds_mono_set hst <| lowerBounds_mono_mem hab hb
#align lower_bounds_mono lowerBounds_mono
theorem BddAbove.mono ⦃s t : Set α⦄ (h : s ⊆ t) : BddAbove t → BddAbove s :=
Nonempty.mono <| upperBounds_mono_set h
#align bdd_above.mono BddAbove.mono
theorem BddBelow.mono ⦃s t : Set α⦄ (h : s ⊆ t) : BddBelow t → BddBelow s :=
Nonempty.mono <| lowerBounds_mono_set h
#align bdd_below.mono BddBelow.mono
theorem IsLUB.of_subset_of_superset {s t p : Set α} (hs : IsLUB s a) (hp : IsLUB p a) (hst : s ⊆ t)
(htp : t ⊆ p) : IsLUB t a :=
⟨upperBounds_mono_set htp hp.1, lowerBounds_mono_set (upperBounds_mono_set hst) hs.2⟩
#align is_lub.of_subset_of_superset IsLUB.of_subset_of_superset
theorem IsGLB.of_subset_of_superset {s t p : Set α} (hs : IsGLB s a) (hp : IsGLB p a) (hst : s ⊆ t)
(htp : t ⊆ p) : IsGLB t a :=
hs.dual.of_subset_of_superset hp hst htp
#align is_glb.of_subset_of_superset IsGLB.of_subset_of_superset
theorem IsLeast.mono (ha : IsLeast s a) (hb : IsLeast t b) (hst : s ⊆ t) : b ≤ a :=
hb.2 (hst ha.1)
#align is_least.mono IsLeast.mono
theorem IsGreatest.mono (ha : IsGreatest s a) (hb : IsGreatest t b) (hst : s ⊆ t) : a ≤ b :=
hb.2 (hst ha.1)
#align is_greatest.mono IsGreatest.mono
theorem IsLUB.mono (ha : IsLUB s a) (hb : IsLUB t b) (hst : s ⊆ t) : a ≤ b :=
IsLeast.mono hb ha <| upperBounds_mono_set hst
#align is_lub.mono IsLUB.mono
theorem IsGLB.mono (ha : IsGLB s a) (hb : IsGLB t b) (hst : s ⊆ t) : b ≤ a :=
IsGreatest.mono hb ha <| lowerBounds_mono_set hst
#align is_glb.mono IsGLB.mono
theorem subset_lowerBounds_upperBounds (s : Set α) : s ⊆ lowerBounds (upperBounds s) :=
fun _ hx _ hy => hy hx
#align subset_lower_bounds_upper_bounds subset_lowerBounds_upperBounds
theorem subset_upperBounds_lowerBounds (s : Set α) : s ⊆ upperBounds (lowerBounds s) :=
fun _ hx _ hy => hy hx
#align subset_upper_bounds_lower_bounds subset_upperBounds_lowerBounds
theorem Set.Nonempty.bddAbove_lowerBounds (hs : s.Nonempty) : BddAbove (lowerBounds s) :=
hs.mono (subset_upperBounds_lowerBounds s)
#align set.nonempty.bdd_above_lower_bounds Set.Nonempty.bddAbove_lowerBounds
theorem Set.Nonempty.bddBelow_upperBounds (hs : s.Nonempty) : BddBelow (upperBounds s) :=
hs.mono (subset_lowerBounds_upperBounds s)
#align set.nonempty.bdd_below_upper_bounds Set.Nonempty.bddBelow_upperBounds
theorem IsLeast.isGLB (h : IsLeast s a) : IsGLB s a :=
⟨h.2, fun _ hb => hb h.1⟩
#align is_least.is_glb IsLeast.isGLB
theorem IsGreatest.isLUB (h : IsGreatest s a) : IsLUB s a :=
⟨h.2, fun _ hb => hb h.1⟩
#align is_greatest.is_lub IsGreatest.isLUB
theorem IsLUB.upperBounds_eq (h : IsLUB s a) : upperBounds s = Ici a :=
Set.ext fun _ => ⟨fun hb => h.2 hb, fun hb => upperBounds_mono_mem hb h.1⟩
#align is_lub.upper_bounds_eq IsLUB.upperBounds_eq
theorem IsGLB.lowerBounds_eq (h : IsGLB s a) : lowerBounds s = Iic a :=
h.dual.upperBounds_eq
#align is_glb.lower_bounds_eq IsGLB.lowerBounds_eq
theorem IsLeast.lowerBounds_eq (h : IsLeast s a) : lowerBounds s = Iic a :=
h.isGLB.lowerBounds_eq
#align is_least.lower_bounds_eq IsLeast.lowerBounds_eq
theorem IsGreatest.upperBounds_eq (h : IsGreatest s a) : upperBounds s = Ici a :=
h.isLUB.upperBounds_eq
#align is_greatest.upper_bounds_eq IsGreatest.upperBounds_eq
-- Porting note (#10756): new lemma
theorem IsGreatest.lt_iff (h : IsGreatest s a) : a < b ↔ ∀ x ∈ s, x < b :=
⟨fun hlt _x hx => (h.2 hx).trans_lt hlt, fun h' => h' _ h.1⟩
-- Porting note (#10756): new lemma
theorem IsLeast.lt_iff (h : IsLeast s a) : b < a ↔ ∀ x ∈ s, b < x :=
h.dual.lt_iff
theorem isLUB_le_iff (h : IsLUB s a) : a ≤ b ↔ b ∈ upperBounds s := by
rw [h.upperBounds_eq]
rfl
#align is_lub_le_iff isLUB_le_iff
theorem le_isGLB_iff (h : IsGLB s a) : b ≤ a ↔ b ∈ lowerBounds s := by
rw [h.lowerBounds_eq]
rfl
#align le_is_glb_iff le_isGLB_iff
theorem isLUB_iff_le_iff : IsLUB s a ↔ ∀ b, a ≤ b ↔ b ∈ upperBounds s :=
⟨fun h _ => isLUB_le_iff h, fun H => ⟨(H _).1 le_rfl, fun b hb => (H b).2 hb⟩⟩
#align is_lub_iff_le_iff isLUB_iff_le_iff
theorem isGLB_iff_le_iff : IsGLB s a ↔ ∀ b, b ≤ a ↔ b ∈ lowerBounds s :=
@isLUB_iff_le_iff αᵒᵈ _ _ _
#align is_glb_iff_le_iff isGLB_iff_le_iff
theorem IsLUB.bddAbove (h : IsLUB s a) : BddAbove s :=
⟨a, h.1⟩
#align is_lub.bdd_above IsLUB.bddAbove
theorem IsGLB.bddBelow (h : IsGLB s a) : BddBelow s :=
⟨a, h.1⟩
#align is_glb.bdd_below IsGLB.bddBelow
theorem IsGreatest.bddAbove (h : IsGreatest s a) : BddAbove s :=
⟨a, h.2⟩
#align is_greatest.bdd_above IsGreatest.bddAbove
theorem IsLeast.bddBelow (h : IsLeast s a) : BddBelow s :=
⟨a, h.2⟩
#align is_least.bdd_below IsLeast.bddBelow
theorem IsLeast.nonempty (h : IsLeast s a) : s.Nonempty :=
⟨a, h.1⟩
#align is_least.nonempty IsLeast.nonempty
theorem IsGreatest.nonempty (h : IsGreatest s a) : s.Nonempty :=
⟨a, h.1⟩
#align is_greatest.nonempty IsGreatest.nonempty
@[simp]
theorem upperBounds_union : upperBounds (s ∪ t) = upperBounds s ∩ upperBounds t :=
Subset.antisymm (fun _ hb => ⟨fun _ hx => hb (Or.inl hx), fun _ hx => hb (Or.inr hx)⟩)
fun _ hb _ hx => hx.elim (fun hs => hb.1 hs) fun ht => hb.2 ht
#align upper_bounds_union upperBounds_union
@[simp]
theorem lowerBounds_union : lowerBounds (s ∪ t) = lowerBounds s ∩ lowerBounds t :=
@upperBounds_union αᵒᵈ _ s t
#align lower_bounds_union lowerBounds_union
theorem union_upperBounds_subset_upperBounds_inter :
upperBounds s ∪ upperBounds t ⊆ upperBounds (s ∩ t) :=
union_subset (upperBounds_mono_set inter_subset_left)
(upperBounds_mono_set inter_subset_right)
#align union_upper_bounds_subset_upper_bounds_inter union_upperBounds_subset_upperBounds_inter
theorem union_lowerBounds_subset_lowerBounds_inter :
lowerBounds s ∪ lowerBounds t ⊆ lowerBounds (s ∩ t) :=
@union_upperBounds_subset_upperBounds_inter αᵒᵈ _ s t
#align union_lower_bounds_subset_lower_bounds_inter union_lowerBounds_subset_lowerBounds_inter
theorem isLeast_union_iff {a : α} {s t : Set α} :
IsLeast (s ∪ t) a ↔ IsLeast s a ∧ a ∈ lowerBounds t ∨ a ∈ lowerBounds s ∧ IsLeast t a := by
simp [IsLeast, lowerBounds_union, or_and_right, and_comm (a := a ∈ t), and_assoc]
#align is_least_union_iff isLeast_union_iff
theorem isGreatest_union_iff :
IsGreatest (s ∪ t) a ↔
IsGreatest s a ∧ a ∈ upperBounds t ∨ a ∈ upperBounds s ∧ IsGreatest t a :=
@isLeast_union_iff αᵒᵈ _ a s t
#align is_greatest_union_iff isGreatest_union_iff
theorem BddAbove.inter_of_left (h : BddAbove s) : BddAbove (s ∩ t) :=
h.mono inter_subset_left
#align bdd_above.inter_of_left BddAbove.inter_of_left
theorem BddAbove.inter_of_right (h : BddAbove t) : BddAbove (s ∩ t) :=
h.mono inter_subset_right
#align bdd_above.inter_of_right BddAbove.inter_of_right
theorem BddBelow.inter_of_left (h : BddBelow s) : BddBelow (s ∩ t) :=
h.mono inter_subset_left
#align bdd_below.inter_of_left BddBelow.inter_of_left
theorem BddBelow.inter_of_right (h : BddBelow t) : BddBelow (s ∩ t) :=
h.mono inter_subset_right
#align bdd_below.inter_of_right BddBelow.inter_of_right
theorem BddAbove.union [IsDirected α (· ≤ ·)] {s t : Set α} :
BddAbove s → BddAbove t → BddAbove (s ∪ t) := by
rintro ⟨a, ha⟩ ⟨b, hb⟩
obtain ⟨c, hca, hcb⟩ := exists_ge_ge a b
rw [BddAbove, upperBounds_union]
exact ⟨c, upperBounds_mono_mem hca ha, upperBounds_mono_mem hcb hb⟩
#align bdd_above.union BddAbove.union
theorem bddAbove_union [IsDirected α (· ≤ ·)] {s t : Set α} :
BddAbove (s ∪ t) ↔ BddAbove s ∧ BddAbove t :=
⟨fun h => ⟨h.mono subset_union_left, h.mono subset_union_right⟩, fun h =>
h.1.union h.2⟩
#align bdd_above_union bddAbove_union
theorem BddBelow.union [IsDirected α (· ≥ ·)] {s t : Set α} :
BddBelow s → BddBelow t → BddBelow (s ∪ t) :=
@BddAbove.union αᵒᵈ _ _ _ _
#align bdd_below.union BddBelow.union
theorem bddBelow_union [IsDirected α (· ≥ ·)] {s t : Set α} :
BddBelow (s ∪ t) ↔ BddBelow s ∧ BddBelow t :=
@bddAbove_union αᵒᵈ _ _ _ _
#align bdd_below_union bddBelow_union
theorem IsLUB.union [SemilatticeSup γ] {a b : γ} {s t : Set γ} (hs : IsLUB s a) (ht : IsLUB t b) :
IsLUB (s ∪ t) (a ⊔ b) :=
⟨fun _ h =>
h.casesOn (fun h => le_sup_of_le_left <| hs.left h) fun h => le_sup_of_le_right <| ht.left h,
fun _ hc =>
sup_le (hs.right fun _ hd => hc <| Or.inl hd) (ht.right fun _ hd => hc <| Or.inr hd)⟩
#align is_lub.union IsLUB.union
theorem IsGLB.union [SemilatticeInf γ] {a₁ a₂ : γ} {s t : Set γ} (hs : IsGLB s a₁)
(ht : IsGLB t a₂) : IsGLB (s ∪ t) (a₁ ⊓ a₂) :=
hs.dual.union ht
#align is_glb.union IsGLB.union
theorem IsLeast.union [LinearOrder γ] {a b : γ} {s t : Set γ} (ha : IsLeast s a)
(hb : IsLeast t b) : IsLeast (s ∪ t) (min a b) :=
⟨by rcases le_total a b with h | h <;> simp [h, ha.1, hb.1], (ha.isGLB.union hb.isGLB).1⟩
#align is_least.union IsLeast.union
theorem IsGreatest.union [LinearOrder γ] {a b : γ} {s t : Set γ} (ha : IsGreatest s a)
(hb : IsGreatest t b) : IsGreatest (s ∪ t) (max a b) :=
⟨by rcases le_total a b with h | h <;> simp [h, ha.1, hb.1], (ha.isLUB.union hb.isLUB).1⟩
#align is_greatest.union IsGreatest.union
theorem IsLUB.inter_Ici_of_mem [LinearOrder γ] {s : Set γ} {a b : γ} (ha : IsLUB s a) (hb : b ∈ s) :
IsLUB (s ∩ Ici b) a :=
⟨fun _ hx => ha.1 hx.1, fun c hc =>
have hbc : b ≤ c := hc ⟨hb, le_rfl⟩
ha.2 fun x hx => ((le_total x b).elim fun hxb => hxb.trans hbc) fun hbx => hc ⟨hx, hbx⟩⟩
#align is_lub.inter_Ici_of_mem IsLUB.inter_Ici_of_mem
theorem IsGLB.inter_Iic_of_mem [LinearOrder γ] {s : Set γ} {a b : γ} (ha : IsGLB s a) (hb : b ∈ s) :
IsGLB (s ∩ Iic b) a :=
ha.dual.inter_Ici_of_mem hb
#align is_glb.inter_Iic_of_mem IsGLB.inter_Iic_of_mem
| Mathlib/Order/Bounds/Basic.lean | 496 | 499 | theorem bddAbove_iff_exists_ge [SemilatticeSup γ] {s : Set γ} (x₀ : γ) :
BddAbove s ↔ ∃ x, x₀ ≤ x ∧ ∀ y ∈ s, y ≤ x := by |
rw [bddAbove_def, exists_ge_and_iff_exists]
exact Monotone.ball fun x _ => monotone_le
|
import Mathlib.Geometry.Manifold.MFDeriv.Defs
#align_import geometry.manifold.mfderiv from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833"
noncomputable section
open scoped Topology Manifold
open Set Bundle
section DerivativesProperties
variable
{𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{H : Type*} [TopologicalSpace H] (I : ModelWithCorners 𝕜 E H)
{M : Type*} [TopologicalSpace M] [ChartedSpace H M]
{E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E']
{H' : Type*} [TopologicalSpace H'] {I' : ModelWithCorners 𝕜 E' H'}
{M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M']
{E'' : Type*} [NormedAddCommGroup E''] [NormedSpace 𝕜 E'']
{H'' : Type*} [TopologicalSpace H''] {I'' : ModelWithCorners 𝕜 E'' H''}
{M'' : Type*} [TopologicalSpace M''] [ChartedSpace H'' M'']
{f f₀ f₁ : M → M'} {x : M} {s t : Set M} {g : M' → M''} {u : Set M'}
theorem uniqueMDiffWithinAt_univ : UniqueMDiffWithinAt I univ x := by
unfold UniqueMDiffWithinAt
simp only [preimage_univ, univ_inter]
exact I.unique_diff _ (mem_range_self _)
#align unique_mdiff_within_at_univ uniqueMDiffWithinAt_univ
variable {I}
theorem uniqueMDiffWithinAt_iff {s : Set M} {x : M} :
UniqueMDiffWithinAt I s x ↔
UniqueDiffWithinAt 𝕜 ((extChartAt I x).symm ⁻¹' s ∩ (extChartAt I x).target)
((extChartAt I x) x) := by
apply uniqueDiffWithinAt_congr
rw [nhdsWithin_inter, nhdsWithin_inter, nhdsWithin_extChartAt_target_eq]
#align unique_mdiff_within_at_iff uniqueMDiffWithinAt_iff
nonrec theorem UniqueMDiffWithinAt.mono_nhds {s t : Set M} {x : M} (hs : UniqueMDiffWithinAt I s x)
(ht : 𝓝[s] x ≤ 𝓝[t] x) : UniqueMDiffWithinAt I t x :=
hs.mono_nhds <| by simpa only [← map_extChartAt_nhdsWithin] using Filter.map_mono ht
theorem UniqueMDiffWithinAt.mono_of_mem {s t : Set M} {x : M} (hs : UniqueMDiffWithinAt I s x)
(ht : t ∈ 𝓝[s] x) : UniqueMDiffWithinAt I t x :=
hs.mono_nhds (nhdsWithin_le_iff.2 ht)
theorem UniqueMDiffWithinAt.mono (h : UniqueMDiffWithinAt I s x) (st : s ⊆ t) :
UniqueMDiffWithinAt I t x :=
UniqueDiffWithinAt.mono h <| inter_subset_inter (preimage_mono st) (Subset.refl _)
#align unique_mdiff_within_at.mono UniqueMDiffWithinAt.mono
theorem UniqueMDiffWithinAt.inter' (hs : UniqueMDiffWithinAt I s x) (ht : t ∈ 𝓝[s] x) :
UniqueMDiffWithinAt I (s ∩ t) x :=
hs.mono_of_mem (Filter.inter_mem self_mem_nhdsWithin ht)
#align unique_mdiff_within_at.inter' UniqueMDiffWithinAt.inter'
theorem UniqueMDiffWithinAt.inter (hs : UniqueMDiffWithinAt I s x) (ht : t ∈ 𝓝 x) :
UniqueMDiffWithinAt I (s ∩ t) x :=
hs.inter' (nhdsWithin_le_nhds ht)
#align unique_mdiff_within_at.inter UniqueMDiffWithinAt.inter
theorem IsOpen.uniqueMDiffWithinAt (hs : IsOpen s) (xs : x ∈ s) : UniqueMDiffWithinAt I s x :=
(uniqueMDiffWithinAt_univ I).mono_of_mem <| nhdsWithin_le_nhds <| hs.mem_nhds xs
#align is_open.unique_mdiff_within_at IsOpen.uniqueMDiffWithinAt
theorem UniqueMDiffOn.inter (hs : UniqueMDiffOn I s) (ht : IsOpen t) : UniqueMDiffOn I (s ∩ t) :=
fun _x hx => UniqueMDiffWithinAt.inter (hs _ hx.1) (ht.mem_nhds hx.2)
#align unique_mdiff_on.inter UniqueMDiffOn.inter
theorem IsOpen.uniqueMDiffOn (hs : IsOpen s) : UniqueMDiffOn I s :=
fun _x hx => hs.uniqueMDiffWithinAt hx
#align is_open.unique_mdiff_on IsOpen.uniqueMDiffOn
theorem uniqueMDiffOn_univ : UniqueMDiffOn I (univ : Set M) :=
isOpen_univ.uniqueMDiffOn
#align unique_mdiff_on_univ uniqueMDiffOn_univ
variable [Is : SmoothManifoldWithCorners I M] [I's : SmoothManifoldWithCorners I' M']
[I''s : SmoothManifoldWithCorners I'' M'']
{f' f₀' f₁' : TangentSpace I x →L[𝕜] TangentSpace I' (f x)}
{g' : TangentSpace I' (f x) →L[𝕜] TangentSpace I'' (g (f x))}
nonrec theorem UniqueMDiffWithinAt.eq (U : UniqueMDiffWithinAt I s x)
(h : HasMFDerivWithinAt I I' f s x f') (h₁ : HasMFDerivWithinAt I I' f s x f₁') : f' = f₁' := by
-- Porting note: didn't need `convert` because of finding instances by unification
convert U.eq h.2 h₁.2
#align unique_mdiff_within_at.eq UniqueMDiffWithinAt.eq
theorem UniqueMDiffOn.eq (U : UniqueMDiffOn I s) (hx : x ∈ s) (h : HasMFDerivWithinAt I I' f s x f')
(h₁ : HasMFDerivWithinAt I I' f s x f₁') : f' = f₁' :=
UniqueMDiffWithinAt.eq (U _ hx) h h₁
#align unique_mdiff_on.eq UniqueMDiffOn.eq
nonrec theorem UniqueMDiffWithinAt.prod {x : M} {y : M'} {s t} (hs : UniqueMDiffWithinAt I s x)
(ht : UniqueMDiffWithinAt I' t y) : UniqueMDiffWithinAt (I.prod I') (s ×ˢ t) (x, y) := by
refine (hs.prod ht).mono ?_
rw [ModelWithCorners.range_prod, ← prod_inter_prod]
rfl
theorem UniqueMDiffOn.prod {s : Set M} {t : Set M'} (hs : UniqueMDiffOn I s)
(ht : UniqueMDiffOn I' t) : UniqueMDiffOn (I.prod I') (s ×ˢ t) := fun x h ↦
(hs x.1 h.1).prod (ht x.2 h.2)
theorem mdifferentiableWithinAt_iff {f : M → M'} {s : Set M} {x : M} :
MDifferentiableWithinAt I I' f s x ↔
ContinuousWithinAt f s x ∧
DifferentiableWithinAt 𝕜 (writtenInExtChartAt I I' x f)
((extChartAt I x).target ∩ (extChartAt I x).symm ⁻¹' s) ((extChartAt I x) x) := by
rw [mdifferentiableWithinAt_iff']
refine and_congr Iff.rfl (exists_congr fun f' => ?_)
rw [inter_comm]
simp only [HasFDerivWithinAt, nhdsWithin_inter, nhdsWithin_extChartAt_target_eq]
#align mdifferentiable_within_at_iff mdifferentiableWithinAt_iff
theorem mdifferentiableWithinAt_iff_of_mem_source {x' : M} {y : M'}
(hx : x' ∈ (chartAt H x).source) (hy : f x' ∈ (chartAt H' y).source) :
MDifferentiableWithinAt I I' f s x' ↔
ContinuousWithinAt f s x' ∧
DifferentiableWithinAt 𝕜 (extChartAt I' y ∘ f ∘ (extChartAt I x).symm)
((extChartAt I x).symm ⁻¹' s ∩ Set.range I) ((extChartAt I x) x') :=
(differentiable_within_at_localInvariantProp I I').liftPropWithinAt_indep_chart
(StructureGroupoid.chart_mem_maximalAtlas _ x) hx (StructureGroupoid.chart_mem_maximalAtlas _ y)
hy
#align mdifferentiable_within_at_iff_of_mem_source mdifferentiableWithinAt_iff_of_mem_source
theorem mfderivWithin_zero_of_not_mdifferentiableWithinAt
(h : ¬MDifferentiableWithinAt I I' f s x) : mfderivWithin I I' f s x = 0 := by
simp only [mfderivWithin, h, if_neg, not_false_iff]
#align mfderiv_within_zero_of_not_mdifferentiable_within_at mfderivWithin_zero_of_not_mdifferentiableWithinAt
theorem mfderiv_zero_of_not_mdifferentiableAt (h : ¬MDifferentiableAt I I' f x) :
mfderiv I I' f x = 0 := by simp only [mfderiv, h, if_neg, not_false_iff]
#align mfderiv_zero_of_not_mdifferentiable_at mfderiv_zero_of_not_mdifferentiableAt
theorem HasMFDerivWithinAt.mono (h : HasMFDerivWithinAt I I' f t x f') (hst : s ⊆ t) :
HasMFDerivWithinAt I I' f s x f' :=
⟨ContinuousWithinAt.mono h.1 hst,
HasFDerivWithinAt.mono h.2 (inter_subset_inter (preimage_mono hst) (Subset.refl _))⟩
#align has_mfderiv_within_at.mono HasMFDerivWithinAt.mono
theorem HasMFDerivAt.hasMFDerivWithinAt (h : HasMFDerivAt I I' f x f') :
HasMFDerivWithinAt I I' f s x f' :=
⟨ContinuousAt.continuousWithinAt h.1, HasFDerivWithinAt.mono h.2 inter_subset_right⟩
#align has_mfderiv_at.has_mfderiv_within_at HasMFDerivAt.hasMFDerivWithinAt
theorem HasMFDerivWithinAt.mdifferentiableWithinAt (h : HasMFDerivWithinAt I I' f s x f') :
MDifferentiableWithinAt I I' f s x :=
⟨h.1, ⟨f', h.2⟩⟩
#align has_mfderiv_within_at.mdifferentiable_within_at HasMFDerivWithinAt.mdifferentiableWithinAt
theorem HasMFDerivAt.mdifferentiableAt (h : HasMFDerivAt I I' f x f') :
MDifferentiableAt I I' f x := by
rw [mdifferentiableAt_iff]
exact ⟨h.1, ⟨f', h.2⟩⟩
#align has_mfderiv_at.mdifferentiable_at HasMFDerivAt.mdifferentiableAt
@[simp, mfld_simps]
theorem hasMFDerivWithinAt_univ :
HasMFDerivWithinAt I I' f univ x f' ↔ HasMFDerivAt I I' f x f' := by
simp only [HasMFDerivWithinAt, HasMFDerivAt, continuousWithinAt_univ, mfld_simps]
#align has_mfderiv_within_at_univ hasMFDerivWithinAt_univ
theorem hasMFDerivAt_unique (h₀ : HasMFDerivAt I I' f x f₀') (h₁ : HasMFDerivAt I I' f x f₁') :
f₀' = f₁' := by
rw [← hasMFDerivWithinAt_univ] at h₀ h₁
exact (uniqueMDiffWithinAt_univ I).eq h₀ h₁
#align has_mfderiv_at_unique hasMFDerivAt_unique
theorem hasMFDerivWithinAt_inter' (h : t ∈ 𝓝[s] x) :
HasMFDerivWithinAt I I' f (s ∩ t) x f' ↔ HasMFDerivWithinAt I I' f s x f' := by
rw [HasMFDerivWithinAt, HasMFDerivWithinAt, extChartAt_preimage_inter_eq,
hasFDerivWithinAt_inter', continuousWithinAt_inter' h]
exact extChartAt_preimage_mem_nhdsWithin I h
#align has_mfderiv_within_at_inter' hasMFDerivWithinAt_inter'
theorem hasMFDerivWithinAt_inter (h : t ∈ 𝓝 x) :
HasMFDerivWithinAt I I' f (s ∩ t) x f' ↔ HasMFDerivWithinAt I I' f s x f' := by
rw [HasMFDerivWithinAt, HasMFDerivWithinAt, extChartAt_preimage_inter_eq, hasFDerivWithinAt_inter,
continuousWithinAt_inter h]
exact extChartAt_preimage_mem_nhds I h
#align has_mfderiv_within_at_inter hasMFDerivWithinAt_inter
theorem HasMFDerivWithinAt.union (hs : HasMFDerivWithinAt I I' f s x f')
(ht : HasMFDerivWithinAt I I' f t x f') : HasMFDerivWithinAt I I' f (s ∪ t) x f' := by
constructor
· exact ContinuousWithinAt.union hs.1 ht.1
· convert HasFDerivWithinAt.union hs.2 ht.2 using 1
simp only [union_inter_distrib_right, preimage_union]
#align has_mfderiv_within_at.union HasMFDerivWithinAt.union
theorem HasMFDerivWithinAt.mono_of_mem (h : HasMFDerivWithinAt I I' f s x f') (ht : s ∈ 𝓝[t] x) :
HasMFDerivWithinAt I I' f t x f' :=
(hasMFDerivWithinAt_inter' ht).1 (h.mono inter_subset_right)
#align has_mfderiv_within_at.nhds_within HasMFDerivWithinAt.mono_of_mem
theorem HasMFDerivWithinAt.hasMFDerivAt (h : HasMFDerivWithinAt I I' f s x f') (hs : s ∈ 𝓝 x) :
HasMFDerivAt I I' f x f' := by
rwa [← univ_inter s, hasMFDerivWithinAt_inter hs, hasMFDerivWithinAt_univ] at h
#align has_mfderiv_within_at.has_mfderiv_at HasMFDerivWithinAt.hasMFDerivAt
theorem MDifferentiableWithinAt.hasMFDerivWithinAt (h : MDifferentiableWithinAt I I' f s x) :
HasMFDerivWithinAt I I' f s x (mfderivWithin I I' f s x) := by
refine ⟨h.1, ?_⟩
simp only [mfderivWithin, h, if_pos, mfld_simps]
exact DifferentiableWithinAt.hasFDerivWithinAt h.2
#align mdifferentiable_within_at.has_mfderiv_within_at MDifferentiableWithinAt.hasMFDerivWithinAt
protected theorem MDifferentiableWithinAt.mfderivWithin (h : MDifferentiableWithinAt I I' f s x) :
mfderivWithin I I' f s x =
fderivWithin 𝕜 (writtenInExtChartAt I I' x f : _) ((extChartAt I x).symm ⁻¹' s ∩ range I)
((extChartAt I x) x) := by
simp only [mfderivWithin, h, if_pos]
#align mdifferentiable_within_at.mfderiv_within MDifferentiableWithinAt.mfderivWithin
theorem MDifferentiableAt.hasMFDerivAt (h : MDifferentiableAt I I' f x) :
HasMFDerivAt I I' f x (mfderiv I I' f x) := by
refine ⟨h.continuousAt, ?_⟩
simp only [mfderiv, h, if_pos, mfld_simps]
exact DifferentiableWithinAt.hasFDerivWithinAt h.differentiableWithinAt_writtenInExtChartAt
#align mdifferentiable_at.has_mfderiv_at MDifferentiableAt.hasMFDerivAt
protected theorem MDifferentiableAt.mfderiv (h : MDifferentiableAt I I' f x) :
mfderiv I I' f x =
fderivWithin 𝕜 (writtenInExtChartAt I I' x f : _) (range I) ((extChartAt I x) x) := by
simp only [mfderiv, h, if_pos]
#align mdifferentiable_at.mfderiv MDifferentiableAt.mfderiv
protected theorem HasMFDerivAt.mfderiv (h : HasMFDerivAt I I' f x f') : mfderiv I I' f x = f' :=
(hasMFDerivAt_unique h h.mdifferentiableAt.hasMFDerivAt).symm
#align has_mfderiv_at.mfderiv HasMFDerivAt.mfderiv
theorem HasMFDerivWithinAt.mfderivWithin (h : HasMFDerivWithinAt I I' f s x f')
(hxs : UniqueMDiffWithinAt I s x) : mfderivWithin I I' f s x = f' := by
ext
rw [hxs.eq h h.mdifferentiableWithinAt.hasMFDerivWithinAt]
#align has_mfderiv_within_at.mfderiv_within HasMFDerivWithinAt.mfderivWithin
theorem MDifferentiable.mfderivWithin (h : MDifferentiableAt I I' f x)
(hxs : UniqueMDiffWithinAt I s x) : mfderivWithin I I' f s x = mfderiv I I' f x := by
apply HasMFDerivWithinAt.mfderivWithin _ hxs
exact h.hasMFDerivAt.hasMFDerivWithinAt
#align mdifferentiable.mfderiv_within MDifferentiable.mfderivWithin
theorem mfderivWithin_subset (st : s ⊆ t) (hs : UniqueMDiffWithinAt I s x)
(h : MDifferentiableWithinAt I I' f t x) :
mfderivWithin I I' f s x = mfderivWithin I I' f t x :=
((MDifferentiableWithinAt.hasMFDerivWithinAt h).mono st).mfderivWithin hs
#align mfderiv_within_subset mfderivWithin_subset
theorem MDifferentiableWithinAt.mono (hst : s ⊆ t) (h : MDifferentiableWithinAt I I' f t x) :
MDifferentiableWithinAt I I' f s x :=
⟨ContinuousWithinAt.mono h.1 hst, DifferentiableWithinAt.mono
h.differentiableWithinAt_writtenInExtChartAt
(inter_subset_inter_left _ (preimage_mono hst))⟩
#align mdifferentiable_within_at.mono MDifferentiableWithinAt.mono
theorem mdifferentiableWithinAt_univ :
MDifferentiableWithinAt I I' f univ x ↔ MDifferentiableAt I I' f x := by
simp_rw [MDifferentiableWithinAt, MDifferentiableAt, ChartedSpace.LiftPropAt]
#align mdifferentiable_within_at_univ mdifferentiableWithinAt_univ
theorem mdifferentiableWithinAt_inter (ht : t ∈ 𝓝 x) :
MDifferentiableWithinAt I I' f (s ∩ t) x ↔ MDifferentiableWithinAt I I' f s x := by
rw [MDifferentiableWithinAt, MDifferentiableWithinAt,
(differentiable_within_at_localInvariantProp I I').liftPropWithinAt_inter ht]
#align mdifferentiable_within_at_inter mdifferentiableWithinAt_inter
theorem mdifferentiableWithinAt_inter' (ht : t ∈ 𝓝[s] x) :
MDifferentiableWithinAt I I' f (s ∩ t) x ↔ MDifferentiableWithinAt I I' f s x := by
rw [MDifferentiableWithinAt, MDifferentiableWithinAt,
(differentiable_within_at_localInvariantProp I I').liftPropWithinAt_inter' ht]
#align mdifferentiable_within_at_inter' mdifferentiableWithinAt_inter'
theorem MDifferentiableAt.mdifferentiableWithinAt (h : MDifferentiableAt I I' f x) :
MDifferentiableWithinAt I I' f s x :=
MDifferentiableWithinAt.mono (subset_univ _) (mdifferentiableWithinAt_univ.2 h)
#align mdifferentiable_at.mdifferentiable_within_at MDifferentiableAt.mdifferentiableWithinAt
theorem MDifferentiableWithinAt.mdifferentiableAt (h : MDifferentiableWithinAt I I' f s x)
(hs : s ∈ 𝓝 x) : MDifferentiableAt I I' f x := by
have : s = univ ∩ s := by rw [univ_inter]
rwa [this, mdifferentiableWithinAt_inter hs, mdifferentiableWithinAt_univ] at h
#align mdifferentiable_within_at.mdifferentiable_at MDifferentiableWithinAt.mdifferentiableAt
theorem MDifferentiableOn.mdifferentiableAt (h : MDifferentiableOn I I' f s) (hx : s ∈ 𝓝 x) :
MDifferentiableAt I I' f x :=
(h x (mem_of_mem_nhds hx)).mdifferentiableAt hx
theorem MDifferentiableOn.mono (h : MDifferentiableOn I I' f t) (st : s ⊆ t) :
MDifferentiableOn I I' f s := fun x hx => (h x (st hx)).mono st
#align mdifferentiable_on.mono MDifferentiableOn.mono
theorem mdifferentiableOn_univ : MDifferentiableOn I I' f univ ↔ MDifferentiable I I' f := by
simp only [MDifferentiableOn, mdifferentiableWithinAt_univ, mfld_simps]; rfl
#align mdifferentiable_on_univ mdifferentiableOn_univ
theorem MDifferentiable.mdifferentiableOn (h : MDifferentiable I I' f) :
MDifferentiableOn I I' f s :=
(mdifferentiableOn_univ.2 h).mono (subset_univ _)
#align mdifferentiable.mdifferentiable_on MDifferentiable.mdifferentiableOn
theorem mdifferentiableOn_of_locally_mdifferentiableOn
(h : ∀ x ∈ s, ∃ u, IsOpen u ∧ x ∈ u ∧ MDifferentiableOn I I' f (s ∩ u)) :
MDifferentiableOn I I' f s := by
intro x xs
rcases h x xs with ⟨t, t_open, xt, ht⟩
exact (mdifferentiableWithinAt_inter (t_open.mem_nhds xt)).1 (ht x ⟨xs, xt⟩)
#align mdifferentiable_on_of_locally_mdifferentiable_on mdifferentiableOn_of_locally_mdifferentiableOn
@[simp, mfld_simps]
theorem mfderivWithin_univ : mfderivWithin I I' f univ = mfderiv I I' f := by
ext x : 1
simp only [mfderivWithin, mfderiv, mfld_simps]
rw [mdifferentiableWithinAt_univ]
#align mfderiv_within_univ mfderivWithin_univ
theorem mfderivWithin_inter (ht : t ∈ 𝓝 x) :
mfderivWithin I I' f (s ∩ t) x = mfderivWithin I I' f s x := by
rw [mfderivWithin, mfderivWithin, extChartAt_preimage_inter_eq, mdifferentiableWithinAt_inter ht,
fderivWithin_inter (extChartAt_preimage_mem_nhds I ht)]
#align mfderiv_within_inter mfderivWithin_inter
theorem mfderivWithin_of_mem_nhds (h : s ∈ 𝓝 x) : mfderivWithin I I' f s x = mfderiv I I' f x := by
rw [← mfderivWithin_univ, ← univ_inter s, mfderivWithin_inter h]
lemma mfderivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) :
mfderivWithin I I' f s x = mfderiv I I' f x :=
mfderivWithin_of_mem_nhds (hs.mem_nhds hx)
theorem mfderivWithin_eq_mfderiv (hs : UniqueMDiffWithinAt I s x) (h : MDifferentiableAt I I' f x) :
mfderivWithin I I' f s x = mfderiv I I' f x := by
rw [← mfderivWithin_univ]
exact mfderivWithin_subset (subset_univ _) hs h.mdifferentiableWithinAt
theorem mdifferentiableAt_iff_of_mem_source {x' : M} {y : M'}
(hx : x' ∈ (chartAt H x).source) (hy : f x' ∈ (chartAt H' y).source) :
MDifferentiableAt I I' f x' ↔
ContinuousAt f x' ∧
DifferentiableWithinAt 𝕜 (extChartAt I' y ∘ f ∘ (extChartAt I x).symm) (Set.range I)
((extChartAt I x) x') :=
mdifferentiableWithinAt_univ.symm.trans <|
(mdifferentiableWithinAt_iff_of_mem_source hx hy).trans <| by
rw [continuousWithinAt_univ, Set.preimage_univ, Set.univ_inter]
#align mdifferentiable_at_iff_of_mem_source mdifferentiableAt_iff_of_mem_source
-- Porting note: moved from `ContMDiffMFDeriv`
variable {n : ℕ∞}
theorem ContMDiffWithinAt.mdifferentiableWithinAt (hf : ContMDiffWithinAt I I' n f s x)
(hn : 1 ≤ n) : MDifferentiableWithinAt I I' f s x := by
suffices h : MDifferentiableWithinAt I I' f (s ∩ f ⁻¹' (extChartAt I' (f x)).source) x by
rwa [mdifferentiableWithinAt_inter'] at h
apply hf.1.preimage_mem_nhdsWithin
exact extChartAt_source_mem_nhds I' (f x)
rw [mdifferentiableWithinAt_iff]
exact ⟨hf.1.mono inter_subset_left, (hf.2.differentiableWithinAt hn).mono (by mfld_set_tac)⟩
#align cont_mdiff_within_at.mdifferentiable_within_at ContMDiffWithinAt.mdifferentiableWithinAt
theorem ContMDiffAt.mdifferentiableAt (hf : ContMDiffAt I I' n f x) (hn : 1 ≤ n) :
MDifferentiableAt I I' f x :=
mdifferentiableWithinAt_univ.1 <| ContMDiffWithinAt.mdifferentiableWithinAt hf hn
#align cont_mdiff_at.mdifferentiable_at ContMDiffAt.mdifferentiableAt
theorem ContMDiffOn.mdifferentiableOn (hf : ContMDiffOn I I' n f s) (hn : 1 ≤ n) :
MDifferentiableOn I I' f s := fun x hx => (hf x hx).mdifferentiableWithinAt hn
#align cont_mdiff_on.mdifferentiable_on ContMDiffOn.mdifferentiableOn
theorem ContMDiff.mdifferentiable (hf : ContMDiff I I' n f) (hn : 1 ≤ n) : MDifferentiable I I' f :=
fun x => (hf x).mdifferentiableAt hn
#align cont_mdiff.mdifferentiable ContMDiff.mdifferentiable
nonrec theorem SmoothWithinAt.mdifferentiableWithinAt (hf : SmoothWithinAt I I' f s x) :
MDifferentiableWithinAt I I' f s x :=
hf.mdifferentiableWithinAt le_top
#align smooth_within_at.mdifferentiable_within_at SmoothWithinAt.mdifferentiableWithinAt
nonrec theorem SmoothAt.mdifferentiableAt (hf : SmoothAt I I' f x) : MDifferentiableAt I I' f x :=
hf.mdifferentiableAt le_top
#align smooth_at.mdifferentiable_at SmoothAt.mdifferentiableAt
nonrec theorem SmoothOn.mdifferentiableOn (hf : SmoothOn I I' f s) : MDifferentiableOn I I' f s :=
hf.mdifferentiableOn le_top
#align smooth_on.mdifferentiable_on SmoothOn.mdifferentiableOn
theorem Smooth.mdifferentiable (hf : Smooth I I' f) : MDifferentiable I I' f :=
ContMDiff.mdifferentiable hf le_top
#align smooth.mdifferentiable Smooth.mdifferentiable
theorem Smooth.mdifferentiableAt (hf : Smooth I I' f) : MDifferentiableAt I I' f x :=
hf.mdifferentiable x
#align smooth.mdifferentiable_at Smooth.mdifferentiableAt
theorem Smooth.mdifferentiableWithinAt (hf : Smooth I I' f) : MDifferentiableWithinAt I I' f s x :=
hf.mdifferentiableAt.mdifferentiableWithinAt
#align smooth.mdifferentiable_within_at Smooth.mdifferentiableWithinAt
theorem HasMFDerivWithinAt.continuousWithinAt (h : HasMFDerivWithinAt I I' f s x f') :
ContinuousWithinAt f s x :=
h.1
#align has_mfderiv_within_at.continuous_within_at HasMFDerivWithinAt.continuousWithinAt
theorem HasMFDerivAt.continuousAt (h : HasMFDerivAt I I' f x f') : ContinuousAt f x :=
h.1
#align has_mfderiv_at.continuous_at HasMFDerivAt.continuousAt
theorem MDifferentiableOn.continuousOn (h : MDifferentiableOn I I' f s) : ContinuousOn f s :=
fun x hx => (h x hx).continuousWithinAt
#align mdifferentiable_on.continuous_on MDifferentiableOn.continuousOn
theorem MDifferentiable.continuous (h : MDifferentiable I I' f) : Continuous f :=
continuous_iff_continuousAt.2 fun x => (h x).continuousAt
#align mdifferentiable.continuous MDifferentiable.continuous
theorem tangentMapWithin_subset {p : TangentBundle I M} (st : s ⊆ t)
(hs : UniqueMDiffWithinAt I s p.1) (h : MDifferentiableWithinAt I I' f t p.1) :
tangentMapWithin I I' f s p = tangentMapWithin I I' f t p := by
simp only [tangentMapWithin, mfld_simps]
rw [mfderivWithin_subset st hs h]
#align tangent_map_within_subset tangentMapWithin_subset
| Mathlib/Geometry/Manifold/MFDeriv/Basic.lean | 460 | 462 | theorem tangentMapWithin_univ : tangentMapWithin I I' f univ = tangentMap I I' f := by |
ext p : 1
simp only [tangentMapWithin, tangentMap, mfld_simps]
|
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Fintype.BigOperators
import Mathlib.LinearAlgebra.AffineSpace.AffineMap
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.Tactic.FinCases
#align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
noncomputable section
open Affine
namespace Finset
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
ext x
fin_cases x <;> simp
#align finset.univ_fin2 Finset.univ_fin2
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
variable [S : AffineSpace V P]
variable {ι : Type*} (s : Finset ι)
variable {ι₂ : Type*} (s₂ : Finset ι₂)
def weightedVSubOfPoint (p : ι → P) (b : P) : (ι → k) →ₗ[k] V :=
∑ i ∈ s, (LinearMap.proj i : (ι → k) →ₗ[k] k).smulRight (p i -ᵥ b)
#align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint
@[simp]
theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) :
s.weightedVSubOfPoint p b w = ∑ i ∈ s, w i • (p i -ᵥ b) := by
simp [weightedVSubOfPoint, LinearMap.sum_apply]
#align finset.weighted_vsub_of_point_apply Finset.weightedVSubOfPoint_apply
@[simp (high)]
theorem weightedVSubOfPoint_apply_const (w : ι → k) (p : P) (b : P) :
s.weightedVSubOfPoint (fun _ => p) b w = (∑ i ∈ s, w i) • (p -ᵥ b) := by
rw [weightedVSubOfPoint_apply, sum_smul]
#align finset.weighted_vsub_of_point_apply_const Finset.weightedVSubOfPoint_apply_const
theorem weightedVSubOfPoint_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P}
(hp : ∀ i ∈ s, p₁ i = p₂ i) (b : P) :
s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint p₂ b w₂ := by
simp_rw [weightedVSubOfPoint_apply]
refine sum_congr rfl fun i hi => ?_
rw [hw i hi, hp i hi]
#align finset.weighted_vsub_of_point_congr Finset.weightedVSubOfPoint_congr
theorem weightedVSubOfPoint_eq_of_weights_eq (p : ι → P) (j : ι) (w₁ w₂ : ι → k)
(hw : ∀ i, i ≠ j → w₁ i = w₂ i) :
s.weightedVSubOfPoint p (p j) w₁ = s.weightedVSubOfPoint p (p j) w₂ := by
simp only [Finset.weightedVSubOfPoint_apply]
congr
ext i
rcases eq_or_ne i j with h | h
· simp [h]
· simp [hw i h]
#align finset.weighted_vsub_of_point_eq_of_weights_eq Finset.weightedVSubOfPoint_eq_of_weights_eq
theorem weightedVSubOfPoint_eq_of_sum_eq_zero (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 0)
(b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w = s.weightedVSubOfPoint p b₂ w := by
apply eq_of_sub_eq_zero
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_sub_distrib]
conv_lhs =>
congr
· skip
· ext
rw [← smul_sub, vsub_sub_vsub_cancel_left]
rw [← sum_smul, h, zero_smul]
#align finset.weighted_vsub_of_point_eq_of_sum_eq_zero Finset.weightedVSubOfPoint_eq_of_sum_eq_zero
theorem weightedVSubOfPoint_vadd_eq_of_sum_eq_one (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 1)
(b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w +ᵥ b₁ = s.weightedVSubOfPoint p b₂ w +ᵥ b₂ := by
erw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← @vsub_eq_zero_iff_eq V,
vadd_vsub_assoc, vsub_vadd_eq_vsub_sub, ← add_sub_assoc, add_comm, add_sub_assoc, ←
sum_sub_distrib]
conv_lhs =>
congr
· skip
· congr
· skip
· ext
rw [← smul_sub, vsub_sub_vsub_cancel_left]
rw [← sum_smul, h, one_smul, vsub_add_vsub_cancel, vsub_self]
#align finset.weighted_vsub_of_point_vadd_eq_of_sum_eq_one Finset.weightedVSubOfPoint_vadd_eq_of_sum_eq_one
@[simp (high)]
theorem weightedVSubOfPoint_erase [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) :
(s.erase i).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
apply sum_erase
rw [vsub_self, smul_zero]
#align finset.weighted_vsub_of_point_erase Finset.weightedVSubOfPoint_erase
@[simp (high)]
theorem weightedVSubOfPoint_insert [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) :
(insert i s).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
apply sum_insert_zero
rw [vsub_self, smul_zero]
#align finset.weighted_vsub_of_point_insert Finset.weightedVSubOfPoint_insert
theorem weightedVSubOfPoint_indicator_subset (w : ι → k) (p : ι → P) (b : P) {s₁ s₂ : Finset ι}
(h : s₁ ⊆ s₂) :
s₁.weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint p b (Set.indicator (↑s₁) w) := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
exact Eq.symm <|
sum_indicator_subset_of_eq_zero w (fun i wi => wi • (p i -ᵥ b : V)) h fun i => zero_smul k _
#align finset.weighted_vsub_of_point_indicator_subset Finset.weightedVSubOfPoint_indicator_subset
theorem weightedVSubOfPoint_map (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) (b : P) :
(s₂.map e).weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint (p ∘ e) b (w ∘ e) := by
simp_rw [weightedVSubOfPoint_apply]
exact Finset.sum_map _ _ _
#align finset.weighted_vsub_of_point_map Finset.weightedVSubOfPoint_map
theorem sum_smul_vsub_eq_weightedVSubOfPoint_sub (w : ι → k) (p₁ p₂ : ι → P) (b : P) :
(∑ i ∈ s, w i • (p₁ i -ᵥ p₂ i)) =
s.weightedVSubOfPoint p₁ b w - s.weightedVSubOfPoint p₂ b w := by
simp_rw [weightedVSubOfPoint_apply, ← sum_sub_distrib, ← smul_sub, vsub_sub_vsub_cancel_right]
#align finset.sum_smul_vsub_eq_weighted_vsub_of_point_sub Finset.sum_smul_vsub_eq_weightedVSubOfPoint_sub
theorem sum_smul_vsub_const_eq_weightedVSubOfPoint_sub (w : ι → k) (p₁ : ι → P) (p₂ b : P) :
(∑ i ∈ s, w i • (p₁ i -ᵥ p₂)) = s.weightedVSubOfPoint p₁ b w - (∑ i ∈ s, w i) • (p₂ -ᵥ b) := by
rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const]
#align finset.sum_smul_vsub_const_eq_weighted_vsub_of_point_sub Finset.sum_smul_vsub_const_eq_weightedVSubOfPoint_sub
theorem sum_smul_const_vsub_eq_sub_weightedVSubOfPoint (w : ι → k) (p₂ : ι → P) (p₁ b : P) :
(∑ i ∈ s, w i • (p₁ -ᵥ p₂ i)) = (∑ i ∈ s, w i) • (p₁ -ᵥ b) - s.weightedVSubOfPoint p₂ b w := by
rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const]
#align finset.sum_smul_const_vsub_eq_sub_weighted_vsub_of_point Finset.sum_smul_const_vsub_eq_sub_weightedVSubOfPoint
theorem weightedVSubOfPoint_sdiff [DecidableEq ι] {s₂ : Finset ι} (h : s₂ ⊆ s) (w : ι → k)
(p : ι → P) (b : P) :
(s \ s₂).weightedVSubOfPoint p b w + s₂.weightedVSubOfPoint p b w =
s.weightedVSubOfPoint p b w := by
simp_rw [weightedVSubOfPoint_apply, sum_sdiff h]
#align finset.weighted_vsub_of_point_sdiff Finset.weightedVSubOfPoint_sdiff
theorem weightedVSubOfPoint_sdiff_sub [DecidableEq ι] {s₂ : Finset ι} (h : s₂ ⊆ s) (w : ι → k)
(p : ι → P) (b : P) :
(s \ s₂).weightedVSubOfPoint p b w - s₂.weightedVSubOfPoint p b (-w) =
s.weightedVSubOfPoint p b w := by
rw [map_neg, sub_neg_eq_add, s.weightedVSubOfPoint_sdiff h]
#align finset.weighted_vsub_of_point_sdiff_sub Finset.weightedVSubOfPoint_sdiff_sub
theorem weightedVSubOfPoint_subtype_eq_filter (w : ι → k) (p : ι → P) (b : P) (pred : ι → Prop)
[DecidablePred pred] :
((s.subtype pred).weightedVSubOfPoint (fun i => p i) b fun i => w i) =
(s.filter pred).weightedVSubOfPoint p b w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_subtype_eq_sum_filter]
#align finset.weighted_vsub_of_point_subtype_eq_filter Finset.weightedVSubOfPoint_subtype_eq_filter
theorem weightedVSubOfPoint_filter_of_ne (w : ι → k) (p : ι → P) (b : P) {pred : ι → Prop}
[DecidablePred pred] (h : ∀ i ∈ s, w i ≠ 0 → pred i) :
(s.filter pred).weightedVSubOfPoint p b w = s.weightedVSubOfPoint p b w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, sum_filter_of_ne]
intro i hi hne
refine h i hi ?_
intro hw
simp [hw] at hne
#align finset.weighted_vsub_of_point_filter_of_ne Finset.weightedVSubOfPoint_filter_of_ne
theorem weightedVSubOfPoint_const_smul (w : ι → k) (p : ι → P) (b : P) (c : k) :
s.weightedVSubOfPoint p b (c • w) = c • s.weightedVSubOfPoint p b w := by
simp_rw [weightedVSubOfPoint_apply, smul_sum, Pi.smul_apply, smul_smul, smul_eq_mul]
#align finset.weighted_vsub_of_point_const_smul Finset.weightedVSubOfPoint_const_smul
def weightedVSub (p : ι → P) : (ι → k) →ₗ[k] V :=
s.weightedVSubOfPoint p (Classical.choice S.nonempty)
#align finset.weighted_vsub Finset.weightedVSub
theorem weightedVSub_apply (w : ι → k) (p : ι → P) :
s.weightedVSub p w = ∑ i ∈ s, w i • (p i -ᵥ Classical.choice S.nonempty) := by
simp [weightedVSub, LinearMap.sum_apply]
#align finset.weighted_vsub_apply Finset.weightedVSub_apply
theorem weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero (w : ι → k) (p : ι → P)
(h : ∑ i ∈ s, w i = 0) (b : P) : s.weightedVSub p w = s.weightedVSubOfPoint p b w :=
s.weightedVSubOfPoint_eq_of_sum_eq_zero w p h _ _
#align finset.weighted_vsub_eq_weighted_vsub_of_point_of_sum_eq_zero Finset.weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero
@[simp]
theorem weightedVSub_apply_const (w : ι → k) (p : P) (h : ∑ i ∈ s, w i = 0) :
s.weightedVSub (fun _ => p) w = 0 := by
rw [weightedVSub, weightedVSubOfPoint_apply_const, h, zero_smul]
#align finset.weighted_vsub_apply_const Finset.weightedVSub_apply_const
@[simp]
theorem weightedVSub_empty (w : ι → k) (p : ι → P) : (∅ : Finset ι).weightedVSub p w = (0 : V) := by
simp [weightedVSub_apply]
#align finset.weighted_vsub_empty Finset.weightedVSub_empty
theorem weightedVSub_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P}
(hp : ∀ i ∈ s, p₁ i = p₂ i) : s.weightedVSub p₁ w₁ = s.weightedVSub p₂ w₂ :=
s.weightedVSubOfPoint_congr hw hp _
#align finset.weighted_vsub_congr Finset.weightedVSub_congr
theorem weightedVSub_indicator_subset (w : ι → k) (p : ι → P) {s₁ s₂ : Finset ι} (h : s₁ ⊆ s₂) :
s₁.weightedVSub p w = s₂.weightedVSub p (Set.indicator (↑s₁) w) :=
weightedVSubOfPoint_indicator_subset _ _ _ h
#align finset.weighted_vsub_indicator_subset Finset.weightedVSub_indicator_subset
theorem weightedVSub_map (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) :
(s₂.map e).weightedVSub p w = s₂.weightedVSub (p ∘ e) (w ∘ e) :=
s₂.weightedVSubOfPoint_map _ _ _ _
#align finset.weighted_vsub_map Finset.weightedVSub_map
theorem sum_smul_vsub_eq_weightedVSub_sub (w : ι → k) (p₁ p₂ : ι → P) :
(∑ i ∈ s, w i • (p₁ i -ᵥ p₂ i)) = s.weightedVSub p₁ w - s.weightedVSub p₂ w :=
s.sum_smul_vsub_eq_weightedVSubOfPoint_sub _ _ _ _
#align finset.sum_smul_vsub_eq_weighted_vsub_sub Finset.sum_smul_vsub_eq_weightedVSub_sub
theorem sum_smul_vsub_const_eq_weightedVSub (w : ι → k) (p₁ : ι → P) (p₂ : P)
(h : ∑ i ∈ s, w i = 0) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂)) = s.weightedVSub p₁ w := by
rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, sub_zero]
#align finset.sum_smul_vsub_const_eq_weighted_vsub Finset.sum_smul_vsub_const_eq_weightedVSub
| Mathlib/LinearAlgebra/AffineSpace/Combination.lean | 320 | 322 | theorem sum_smul_const_vsub_eq_neg_weightedVSub (w : ι → k) (p₂ : ι → P) (p₁ : P)
(h : ∑ i ∈ s, w i = 0) : (∑ i ∈ s, w i • (p₁ -ᵥ p₂ i)) = -s.weightedVSub p₂ w := by |
rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, zero_sub]
|
import Mathlib.Init.Control.Combinators
import Mathlib.Init.Function
import Mathlib.Tactic.CasesM
import Mathlib.Tactic.Attr.Core
#align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
universe u v w
variable {α β γ : Type u}
section Monad
variable {m : Type u → Type v} [Monad m] [LawfulMonad m]
open List
#align list.mpartition List.partitionM
| Mathlib/Control/Basic.lean | 83 | 85 | theorem map_bind (x : m α) {g : α → m β} {f : β → γ} :
f <$> (x >>= g) = x >>= fun a => f <$> g a := by |
rw [← bind_pure_comp, bind_assoc]; simp [bind_pure_comp]
|
import Mathlib.Algebra.Group.Units.Hom
import Mathlib.Algebra.GroupWithZero.Commute
import Mathlib.Algebra.GroupWithZero.Hom
import Mathlib.GroupTheory.GroupAction.Units
#align_import algebra.group_with_zero.units.lemmas from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988"
assert_not_exists DenselyOrdered
variable {α M₀ G₀ M₀' G₀' F F' : Type*}
variable [MonoidWithZero M₀]
section MonoidWithZero
variable [GroupWithZero G₀] [Nontrivial M₀] [MonoidWithZero M₀'] [FunLike F G₀ M₀]
[MonoidWithZeroHomClass F G₀ M₀] [FunLike F' G₀ M₀'] [MonoidWithZeroHomClass F' G₀ M₀']
(f : F) {a : G₀}
theorem map_ne_zero : f a ≠ 0 ↔ a ≠ 0 :=
⟨fun hfa ha => hfa <| ha.symm ▸ map_zero f, fun ha => ((IsUnit.mk0 a ha).map f).ne_zero⟩
#align map_ne_zero map_ne_zero
@[simp]
theorem map_eq_zero : f a = 0 ↔ a = 0 :=
not_iff_not.1 (map_ne_zero f)
#align map_eq_zero map_eq_zero
| Mathlib/Algebra/GroupWithZero/Units/Lemmas.lean | 49 | 52 | theorem eq_on_inv₀ (f g : F') (h : f a = g a) : f a⁻¹ = g a⁻¹ := by |
rcases eq_or_ne a 0 with (rfl | ha)
· rw [inv_zero, map_zero, map_zero]
· exact (IsUnit.mk0 a ha).eq_on_inv f g h
|
import Mathlib.CategoryTheory.Sites.Subsheaf
import Mathlib.CategoryTheory.Sites.CompatibleSheafification
import Mathlib.CategoryTheory.Sites.LocallyInjective
#align_import category_theory.sites.surjective from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
universe v u w v' u' w'
open Opposite CategoryTheory CategoryTheory.GrothendieckTopology
namespace CategoryTheory
variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C)
attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike
variable {A : Type u'} [Category.{v'} A] [ConcreteCategory.{w'} A]
namespace Presheaf
@[simps (config := .lemmasOnly)]
def imageSieve {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) : Sieve U where
arrows V i := ∃ t : F.obj (op V), f.app _ t = G.map i.op s
downward_closed := by
rintro V W i ⟨t, ht⟩ j
refine ⟨F.map j.op t, ?_⟩
rw [op_comp, G.map_comp, comp_apply, ← ht, elementwise_of% f.naturality]
#align category_theory.image_sieve CategoryTheory.Presheaf.imageSieve
theorem imageSieve_eq_sieveOfSection {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) :
imageSieve f s = (imagePresheaf (whiskerRight f (forget A))).sieveOfSection s :=
rfl
#align category_theory.image_sieve_eq_sieve_of_section CategoryTheory.Presheaf.imageSieve_eq_sieveOfSection
theorem imageSieve_whisker_forget {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) :
imageSieve (whiskerRight f (forget A)) s = imageSieve f s :=
rfl
#align category_theory.image_sieve_whisker_forget CategoryTheory.Presheaf.imageSieve_whisker_forget
theorem imageSieve_app {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : F.obj (op U)) :
imageSieve f (f.app _ s) = ⊤ := by
ext V i
simp only [Sieve.top_apply, iff_true_iff, imageSieve_apply]
have := elementwise_of% (f.naturality i.op)
exact ⟨F.map i.op s, this s⟩
#align category_theory.image_sieve_app CategoryTheory.Presheaf.imageSieve_app
noncomputable def localPreimage {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : Cᵒᵖ} (s : G.obj U)
{V : C} (g : V ⟶ U.unop) (hg : imageSieve f s g) :
F.obj (op V) :=
hg.choose
@[simp]
lemma app_localPreimage {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : Cᵒᵖ} (s : G.obj U)
{V : C} (g : V ⟶ U.unop) (hg : imageSieve f s g) :
f.app _ (localPreimage f s g hg) = G.map g.op s :=
hg.choose_spec
class IsLocallySurjective {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) : Prop where
imageSieve_mem {U : C} (s : G.obj (op U)) : imageSieve f s ∈ J U
#align category_theory.is_locally_surjective CategoryTheory.Presheaf.IsLocallySurjective
lemma imageSieve_mem {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) [IsLocallySurjective J f] {U : Cᵒᵖ}
(s : G.obj U) : imageSieve f s ∈ J U.unop :=
IsLocallySurjective.imageSieve_mem _
instance {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) [IsLocallySurjective J f] :
IsLocallySurjective J (whiskerRight f (forget A)) where
imageSieve_mem s := imageSieve_mem J f s
| Mathlib/CategoryTheory/Sites/LocallySurjective.lean | 101 | 105 | theorem isLocallySurjective_iff_imagePresheaf_sheafify_eq_top {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) :
IsLocallySurjective J f ↔ (imagePresheaf (whiskerRight f (forget A))).sheafify J = ⊤ := by |
simp only [Subpresheaf.ext_iff, Function.funext_iff, Set.ext_iff, top_subpresheaf_obj,
Set.top_eq_univ, Set.mem_univ, iff_true_iff]
exact ⟨fun H _ => H.imageSieve_mem, fun H => ⟨H _⟩⟩
|
import Mathlib.FieldTheory.Minpoly.Field
#align_import ring_theory.power_basis from "leanprover-community/mathlib"@"d1d69e99ed34c95266668af4e288fc1c598b9a7f"
open Polynomial
open Polynomial
variable {R S T : Type*} [CommRing R] [Ring S] [Algebra R S]
variable {A B : Type*} [CommRing A] [CommRing B] [IsDomain B] [Algebra A B]
variable {K : Type*} [Field K]
-- Porting note(#5171): this linter isn't ported yet.
-- @[nolint has_nonempty_instance]
structure PowerBasis (R S : Type*) [CommRing R] [Ring S] [Algebra R S] where
gen : S
dim : ℕ
basis : Basis (Fin dim) R S
basis_eq_pow : ∀ (i), basis i = gen ^ (i : ℕ)
#align power_basis PowerBasis
-- this is usually not needed because of `basis_eq_pow` but can be needed in some cases;
-- in such circumstances, add it manually using `@[simps dim gen basis]`.
initialize_simps_projections PowerBasis (-basis)
namespace PowerBasis
@[simp]
theorem coe_basis (pb : PowerBasis R S) : ⇑pb.basis = fun i : Fin pb.dim => pb.gen ^ (i : ℕ) :=
funext pb.basis_eq_pow
#align power_basis.coe_basis PowerBasis.coe_basis
theorem finite (pb : PowerBasis R S) : Module.Finite R S := .of_basis pb.basis
#align power_basis.finite_dimensional PowerBasis.finite
@[deprecated] alias finiteDimensional := PowerBasis.finite
theorem finrank [StrongRankCondition R] (pb : PowerBasis R S) :
FiniteDimensional.finrank R S = pb.dim := by
rw [FiniteDimensional.finrank_eq_card_basis pb.basis, Fintype.card_fin]
#align power_basis.finrank PowerBasis.finrank
theorem mem_span_pow' {x y : S} {d : ℕ} :
y ∈ Submodule.span R (Set.range fun i : Fin d => x ^ (i : ℕ)) ↔
∃ f : R[X], f.degree < d ∧ y = aeval x f := by
have : (Set.range fun i : Fin d => x ^ (i : ℕ)) = (fun i : ℕ => x ^ i) '' ↑(Finset.range d) := by
ext n
simp_rw [Set.mem_range, Set.mem_image, Finset.mem_coe, Finset.mem_range]
exact ⟨fun ⟨⟨i, hi⟩, hy⟩ => ⟨i, hi, hy⟩, fun ⟨i, hi, hy⟩ => ⟨⟨i, hi⟩, hy⟩⟩
simp only [this, Finsupp.mem_span_image_iff_total, degree_lt_iff_coeff_zero, support,
exists_iff_exists_finsupp, coeff, aeval_def, eval₂RingHom', eval₂_eq_sum, Polynomial.sum,
Finsupp.mem_supported', Finsupp.total, Finsupp.sum, Algebra.smul_def, eval₂_zero, exists_prop,
LinearMap.id_coe, eval₂_one, id, not_lt, Finsupp.coe_lsum, LinearMap.coe_smulRight,
Finset.mem_range, AlgHom.coe_mks, Finset.mem_coe]
simp_rw [@eq_comm _ y]
exact Iff.rfl
#align power_basis.mem_span_pow' PowerBasis.mem_span_pow'
theorem mem_span_pow {x y : S} {d : ℕ} (hd : d ≠ 0) :
y ∈ Submodule.span R (Set.range fun i : Fin d => x ^ (i : ℕ)) ↔
∃ f : R[X], f.natDegree < d ∧ y = aeval x f := by
rw [mem_span_pow']
constructor <;>
· rintro ⟨f, h, hy⟩
refine ⟨f, ?_, hy⟩
by_cases hf : f = 0
· simp only [hf, natDegree_zero, degree_zero] at h ⊢
first | exact lt_of_le_of_ne (Nat.zero_le d) hd.symm | exact WithBot.bot_lt_coe d
simp_all only [degree_eq_natDegree hf]
· first | exact WithBot.coe_lt_coe.1 h | exact WithBot.coe_lt_coe.2 h
#align power_basis.mem_span_pow PowerBasis.mem_span_pow
theorem dim_ne_zero [Nontrivial S] (pb : PowerBasis R S) : pb.dim ≠ 0 := fun h =>
not_nonempty_iff.mpr (h.symm ▸ Fin.isEmpty : IsEmpty (Fin pb.dim)) pb.basis.index_nonempty
#align power_basis.dim_ne_zero PowerBasis.dim_ne_zero
theorem dim_pos [Nontrivial S] (pb : PowerBasis R S) : 0 < pb.dim :=
Nat.pos_of_ne_zero pb.dim_ne_zero
#align power_basis.dim_pos PowerBasis.dim_pos
theorem exists_eq_aeval [Nontrivial S] (pb : PowerBasis R S) (y : S) :
∃ f : R[X], f.natDegree < pb.dim ∧ y = aeval pb.gen f :=
(mem_span_pow pb.dim_ne_zero).mp (by simpa using pb.basis.mem_span y)
#align power_basis.exists_eq_aeval PowerBasis.exists_eq_aeval
| Mathlib/RingTheory/PowerBasis.lean | 132 | 135 | theorem exists_eq_aeval' (pb : PowerBasis R S) (y : S) : ∃ f : R[X], y = aeval pb.gen f := by |
nontriviality S
obtain ⟨f, _, hf⟩ := exists_eq_aeval pb y
exact ⟨f, hf⟩
|
import Mathlib.Algebra.Lie.OfAssociative
import Mathlib.Algebra.Lie.IdealOperations
#align_import algebra.lie.abelian from "leanprover-community/mathlib"@"8983bec7cdf6cb2dd1f21315c8a34ab00d7b2f6d"
universe u v w w₁ w₂
class LieModule.IsTrivial (L : Type v) (M : Type w) [Bracket L M] [Zero M] : Prop where
trivial : ∀ (x : L) (m : M), ⁅x, m⁆ = 0
#align lie_module.is_trivial LieModule.IsTrivial
@[simp]
theorem trivial_lie_zero (L : Type v) (M : Type w) [Bracket L M] [Zero M] [LieModule.IsTrivial L M]
(x : L) (m : M) : ⁅x, m⁆ = 0 :=
LieModule.IsTrivial.trivial x m
#align trivial_lie_zero trivial_lie_zero
instance LieModule.instIsTrivialOfSubsingleton {L M : Type*}
[LieRing L] [AddCommGroup M] [LieRingModule L M] [Subsingleton L] : LieModule.IsTrivial L M :=
⟨fun x m ↦ by rw [Subsingleton.eq_zero x, zero_lie]⟩
instance LieModule.instIsTrivialOfSubsingleton' {L M : Type*}
[LieRing L] [AddCommGroup M] [LieRingModule L M] [Subsingleton M] : LieModule.IsTrivial L M :=
⟨fun x m ↦ by simp_rw [Subsingleton.eq_zero m, lie_zero]⟩
abbrev IsLieAbelian (L : Type v) [Bracket L L] [Zero L] : Prop :=
LieModule.IsTrivial L L
#align is_lie_abelian IsLieAbelian
instance LieIdeal.isLieAbelian_of_trivial (R : Type u) (L : Type v) [CommRing R] [LieRing L]
[LieAlgebra R L] (I : LieIdeal R L) [h : LieModule.IsTrivial L I] : IsLieAbelian I where
trivial x y := by apply h.trivial
#align lie_ideal.is_lie_abelian_of_trivial LieIdeal.isLieAbelian_of_trivial
theorem Function.Injective.isLieAbelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R]
[LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] {f : L₁ →ₗ⁅R⁆ L₂}
(h₁ : Function.Injective f) (_ : IsLieAbelian L₂) : IsLieAbelian L₁ :=
{ trivial := fun x y => h₁ <|
calc
f ⁅x, y⁆ = ⁅f x, f y⁆ := LieHom.map_lie f x y
_ = 0 := trivial_lie_zero _ _ _ _
_ = f 0 := f.map_zero.symm}
#align function.injective.is_lie_abelian Function.Injective.isLieAbelian
theorem Function.Surjective.isLieAbelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R]
[LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] {f : L₁ →ₗ⁅R⁆ L₂}
(h₁ : Function.Surjective f) (h₂ : IsLieAbelian L₁) : IsLieAbelian L₂ :=
{ trivial := fun x y => by
obtain ⟨u, rfl⟩ := h₁ x
obtain ⟨v, rfl⟩ := h₁ y
rw [← LieHom.map_lie, trivial_lie_zero, LieHom.map_zero] }
#align function.surjective.is_lie_abelian Function.Surjective.isLieAbelian
theorem lie_abelian_iff_equiv_lie_abelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R]
[LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] (e : L₁ ≃ₗ⁅R⁆ L₂) :
IsLieAbelian L₁ ↔ IsLieAbelian L₂ :=
⟨e.symm.injective.isLieAbelian, e.injective.isLieAbelian⟩
#align lie_abelian_iff_equiv_lie_abelian lie_abelian_iff_equiv_lie_abelian
theorem commutative_ring_iff_abelian_lie_ring {A : Type v} [Ring A] :
Std.Commutative (α := A) (· * ·) ↔ IsLieAbelian A := by
have h₁ : Std.Commutative (α := A) (· * ·) ↔ ∀ a b : A, a * b = b * a :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
have h₂ : IsLieAbelian A ↔ ∀ a b : A, ⁅a, b⁆ = 0 := ⟨fun h => h.1, fun h => ⟨h⟩⟩
simp only [h₁, h₂, LieRing.of_associative_ring_bracket, sub_eq_zero]
#align commutative_ring_iff_abelian_lie_ring commutative_ring_iff_abelian_lie_ring
section Center
variable (R : Type u) (L : Type v) (M : Type w) (N : Type w₁)
variable [CommRing R] [LieRing L] [LieAlgebra R L]
variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M]
variable [AddCommGroup N] [Module R N] [LieRingModule L N] [LieModule R L N]
section IdealOperations
open LieSubmodule LieSubalgebra
variable {R : Type u} {L : Type v} {M : Type w}
variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M]
variable [LieRingModule L M] [LieModule R L M]
variable (N N' : LieSubmodule R L M) (I J : LieIdeal R L)
@[simp]
theorem LieSubmodule.trivial_lie_oper_zero [LieModule.IsTrivial L M] : ⁅I, N⁆ = ⊥ := by
suffices ⁅I, N⁆ ≤ ⊥ from le_bot_iff.mp this
rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le]
rintro m ⟨x, n, h⟩; rw [trivial_lie_zero] at h; simp [← h]
#align lie_submodule.trivial_lie_oper_zero LieSubmodule.trivial_lie_oper_zero
| Mathlib/Algebra/Lie/Abelian.lean | 318 | 326 | theorem LieSubmodule.lie_abelian_iff_lie_self_eq_bot : IsLieAbelian I ↔ ⁅I, I⁆ = ⊥ := by |
simp only [_root_.eq_bot_iff, lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le,
LieSubmodule.bot_coe, Set.subset_singleton_iff, Set.mem_setOf_eq, exists_imp]
refine
⟨fun h z x y hz =>
hz.symm.trans
(((I : LieSubalgebra R L).coe_bracket x y).symm.trans
((coe_zero_iff_zero _ _).mpr (by apply h.trivial))),
fun h => ⟨fun x y => ((I : LieSubalgebra R L).coe_zero_iff_zero _).mp (h _ x y rfl)⟩⟩
|
import Mathlib.Data.Complex.Module
import Mathlib.Data.Complex.Order
import Mathlib.Data.Complex.Exponential
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Topology.Algebra.InfiniteSum.Module
import Mathlib.Topology.Instances.RealVectorSpace
#align_import analysis.complex.basic from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b"
assert_not_exists Absorbs
noncomputable section
namespace Complex
variable {z : ℂ}
open ComplexConjugate Topology Filter
instance : Norm ℂ :=
⟨abs⟩
@[simp]
theorem norm_eq_abs (z : ℂ) : ‖z‖ = abs z :=
rfl
#align complex.norm_eq_abs Complex.norm_eq_abs
lemma norm_I : ‖I‖ = 1 := abs_I
theorem norm_exp_ofReal_mul_I (t : ℝ) : ‖exp (t * I)‖ = 1 := by
simp only [norm_eq_abs, abs_exp_ofReal_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.norm_exp_of_real_mul_I Complex.norm_exp_ofReal_mul_I
instance instNormedAddCommGroup : NormedAddCommGroup ℂ :=
AddGroupNorm.toNormedAddCommGroup
{ abs with
map_zero' := map_zero abs
neg' := abs.map_neg
eq_zero_of_map_eq_zero' := fun _ => abs.eq_zero.1 }
instance : NormedField ℂ where
dist_eq _ _ := rfl
norm_mul' := map_mul abs
instance : DenselyNormedField ℂ where
lt_norm_lt r₁ r₂ h₀ hr :=
let ⟨x, h⟩ := exists_between hr
⟨x, by rwa [norm_eq_abs, abs_ofReal, abs_of_pos (h₀.trans_lt h.1)]⟩
instance {R : Type*} [NormedField R] [NormedAlgebra R ℝ] : NormedAlgebra R ℂ where
norm_smul_le r x := by
rw [← algebraMap_smul ℝ r x, real_smul, norm_mul, norm_eq_abs, abs_ofReal, ← Real.norm_eq_abs,
norm_algebraMap']
variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℂ E]
-- see Note [lower instance priority]
instance (priority := 900) _root_.NormedSpace.complexToReal : NormedSpace ℝ E :=
NormedSpace.restrictScalars ℝ ℂ E
#align normed_space.complex_to_real NormedSpace.complexToReal
-- see Note [lower instance priority]
instance (priority := 900) _root_.NormedAlgebra.complexToReal {A : Type*} [SeminormedRing A]
[NormedAlgebra ℂ A] : NormedAlgebra ℝ A :=
NormedAlgebra.restrictScalars ℝ ℂ A
theorem dist_eq (z w : ℂ) : dist z w = abs (z - w) :=
rfl
#align complex.dist_eq Complex.dist_eq
theorem dist_eq_re_im (z w : ℂ) : dist z w = √((z.re - w.re) ^ 2 + (z.im - w.im) ^ 2) := by
rw [sq, sq]
rfl
#align complex.dist_eq_re_im Complex.dist_eq_re_im
@[simp]
theorem dist_mk (x₁ y₁ x₂ y₂ : ℝ) :
dist (mk x₁ y₁) (mk x₂ y₂) = √((x₁ - x₂) ^ 2 + (y₁ - y₂) ^ 2) :=
dist_eq_re_im _ _
#align complex.dist_mk Complex.dist_mk
theorem dist_of_re_eq {z w : ℂ} (h : z.re = w.re) : dist z w = dist z.im w.im := by
rw [dist_eq_re_im, h, sub_self, zero_pow two_ne_zero, zero_add, Real.sqrt_sq_eq_abs, Real.dist_eq]
#align complex.dist_of_re_eq Complex.dist_of_re_eq
theorem nndist_of_re_eq {z w : ℂ} (h : z.re = w.re) : nndist z w = nndist z.im w.im :=
NNReal.eq <| dist_of_re_eq h
#align complex.nndist_of_re_eq Complex.nndist_of_re_eq
theorem edist_of_re_eq {z w : ℂ} (h : z.re = w.re) : edist z w = edist z.im w.im := by
rw [edist_nndist, edist_nndist, nndist_of_re_eq h]
#align complex.edist_of_re_eq Complex.edist_of_re_eq
theorem dist_of_im_eq {z w : ℂ} (h : z.im = w.im) : dist z w = dist z.re w.re := by
rw [dist_eq_re_im, h, sub_self, zero_pow two_ne_zero, add_zero, Real.sqrt_sq_eq_abs, Real.dist_eq]
#align complex.dist_of_im_eq Complex.dist_of_im_eq
theorem nndist_of_im_eq {z w : ℂ} (h : z.im = w.im) : nndist z w = nndist z.re w.re :=
NNReal.eq <| dist_of_im_eq h
#align complex.nndist_of_im_eq Complex.nndist_of_im_eq
theorem edist_of_im_eq {z w : ℂ} (h : z.im = w.im) : edist z w = edist z.re w.re := by
rw [edist_nndist, edist_nndist, nndist_of_im_eq h]
#align complex.edist_of_im_eq Complex.edist_of_im_eq
theorem dist_conj_self (z : ℂ) : dist (conj z) z = 2 * |z.im| := by
rw [dist_of_re_eq (conj_re z), conj_im, dist_comm, Real.dist_eq, sub_neg_eq_add, ← two_mul,
_root_.abs_mul, abs_of_pos (zero_lt_two' ℝ)]
#align complex.dist_conj_self Complex.dist_conj_self
theorem nndist_conj_self (z : ℂ) : nndist (conj z) z = 2 * Real.nnabs z.im :=
NNReal.eq <| by rw [← dist_nndist, NNReal.coe_mul, NNReal.coe_two, Real.coe_nnabs, dist_conj_self]
#align complex.nndist_conj_self Complex.nndist_conj_self
theorem dist_self_conj (z : ℂ) : dist z (conj z) = 2 * |z.im| := by rw [dist_comm, dist_conj_self]
#align complex.dist_self_conj Complex.dist_self_conj
theorem nndist_self_conj (z : ℂ) : nndist z (conj z) = 2 * Real.nnabs z.im := by
rw [nndist_comm, nndist_conj_self]
#align complex.nndist_self_conj Complex.nndist_self_conj
@[simp 1100]
theorem comap_abs_nhds_zero : comap abs (𝓝 0) = 𝓝 0 :=
comap_norm_nhds_zero
#align complex.comap_abs_nhds_zero Complex.comap_abs_nhds_zero
theorem norm_real (r : ℝ) : ‖(r : ℂ)‖ = ‖r‖ :=
abs_ofReal _
#align complex.norm_real Complex.norm_real
@[simp 1100]
theorem norm_rat (r : ℚ) : ‖(r : ℂ)‖ = |(r : ℝ)| := by
rw [← ofReal_ratCast]
exact norm_real _
#align complex.norm_rat Complex.norm_rat
@[simp 1100]
theorem norm_nat (n : ℕ) : ‖(n : ℂ)‖ = n :=
abs_natCast _
#align complex.norm_nat Complex.norm_nat
@[simp 1100]
lemma norm_int {n : ℤ} : ‖(n : ℂ)‖ = |(n : ℝ)| := abs_intCast n
#align complex.norm_int Complex.norm_int
theorem norm_int_of_nonneg {n : ℤ} (hn : 0 ≤ n) : ‖(n : ℂ)‖ = n := by
rw [norm_int, ← Int.cast_abs, _root_.abs_of_nonneg hn]
#align complex.norm_int_of_nonneg Complex.norm_int_of_nonneg
lemma normSq_eq_norm_sq (z : ℂ) : normSq z = ‖z‖ ^ 2 := by
rw [normSq_eq_abs, norm_eq_abs]
@[continuity]
theorem continuous_abs : Continuous abs :=
continuous_norm
#align complex.continuous_abs Complex.continuous_abs
@[continuity]
theorem continuous_normSq : Continuous normSq := by
simpa [← normSq_eq_abs] using continuous_abs.pow 2
#align complex.continuous_norm_sq Complex.continuous_normSq
@[simp, norm_cast]
theorem nnnorm_real (r : ℝ) : ‖(r : ℂ)‖₊ = ‖r‖₊ :=
Subtype.ext <| norm_real r
#align complex.nnnorm_real Complex.nnnorm_real
@[simp, norm_cast]
theorem nnnorm_nat (n : ℕ) : ‖(n : ℂ)‖₊ = n :=
Subtype.ext <| by simp
#align complex.nnnorm_nat Complex.nnnorm_nat
@[simp, norm_cast]
theorem nnnorm_int (n : ℤ) : ‖(n : ℂ)‖₊ = ‖n‖₊ :=
Subtype.ext norm_int
#align complex.nnnorm_int Complex.nnnorm_int
theorem nnnorm_eq_one_of_pow_eq_one {ζ : ℂ} {n : ℕ} (h : ζ ^ n = 1) (hn : n ≠ 0) : ‖ζ‖₊ = 1 :=
(pow_left_inj zero_le' zero_le' hn).1 <| by rw [← nnnorm_pow, h, nnnorm_one, one_pow]
#align complex.nnnorm_eq_one_of_pow_eq_one Complex.nnnorm_eq_one_of_pow_eq_one
theorem norm_eq_one_of_pow_eq_one {ζ : ℂ} {n : ℕ} (h : ζ ^ n = 1) (hn : n ≠ 0) : ‖ζ‖ = 1 :=
congr_arg Subtype.val (nnnorm_eq_one_of_pow_eq_one h hn)
#align complex.norm_eq_one_of_pow_eq_one Complex.norm_eq_one_of_pow_eq_one
theorem equivRealProd_apply_le (z : ℂ) : ‖equivRealProd z‖ ≤ abs z := by
simp [Prod.norm_def, abs_re_le_abs, abs_im_le_abs]
#align complex.equiv_real_prod_apply_le Complex.equivRealProd_apply_le
theorem equivRealProd_apply_le' (z : ℂ) : ‖equivRealProd z‖ ≤ 1 * abs z := by
simpa using equivRealProd_apply_le z
#align complex.equiv_real_prod_apply_le' Complex.equivRealProd_apply_le'
theorem lipschitz_equivRealProd : LipschitzWith 1 equivRealProd := by
simpa using AddMonoidHomClass.lipschitz_of_bound equivRealProdLm 1 equivRealProd_apply_le'
#align complex.lipschitz_equiv_real_prod Complex.lipschitz_equivRealProd
theorem antilipschitz_equivRealProd : AntilipschitzWith (NNReal.sqrt 2) equivRealProd :=
AddMonoidHomClass.antilipschitz_of_bound equivRealProdLm fun z ↦ by
simpa only [Real.coe_sqrt, NNReal.coe_ofNat] using abs_le_sqrt_two_mul_max z
#align complex.antilipschitz_equiv_real_prod Complex.antilipschitz_equivRealProd
theorem uniformEmbedding_equivRealProd : UniformEmbedding equivRealProd :=
antilipschitz_equivRealProd.uniformEmbedding lipschitz_equivRealProd.uniformContinuous
#align complex.uniform_embedding_equiv_real_prod Complex.uniformEmbedding_equivRealProd
instance : CompleteSpace ℂ :=
(completeSpace_congr uniformEmbedding_equivRealProd).mpr inferInstance
instance instT2Space : T2Space ℂ := TopologicalSpace.t2Space_of_metrizableSpace
@[simps! (config := { simpRhs := true }) apply symm_apply_re symm_apply_im]
def equivRealProdCLM : ℂ ≃L[ℝ] ℝ × ℝ :=
equivRealProdLm.toContinuousLinearEquivOfBounds 1 (√2) equivRealProd_apply_le' fun p =>
abs_le_sqrt_two_mul_max (equivRealProd.symm p)
#align complex.equiv_real_prod_clm Complex.equivRealProdCLM
theorem equivRealProdCLM_symm_apply (p : ℝ × ℝ) :
Complex.equivRealProdCLM.symm p = p.1 + p.2 * Complex.I := Complex.equivRealProd_symm_apply p
instance : ProperSpace ℂ :=
(id lipschitz_equivRealProd : LipschitzWith 1 equivRealProdCLM.toHomeomorph).properSpace
theorem tendsto_abs_cocompact_atTop : Tendsto abs (cocompact ℂ) atTop :=
tendsto_norm_cocompact_atTop
#align complex.tendsto_abs_cocompact_at_top Complex.tendsto_abs_cocompact_atTop
theorem tendsto_normSq_cocompact_atTop : Tendsto normSq (cocompact ℂ) atTop := by
simpa [mul_self_abs]
using tendsto_abs_cocompact_atTop.atTop_mul_atTop tendsto_abs_cocompact_atTop
#align complex.tendsto_norm_sq_cocompact_at_top Complex.tendsto_normSq_cocompact_atTop
open ContinuousLinearMap
def reCLM : ℂ →L[ℝ] ℝ :=
reLm.mkContinuous 1 fun x => by simp [abs_re_le_abs]
#align complex.re_clm Complex.reCLM
@[continuity, fun_prop]
theorem continuous_re : Continuous re :=
reCLM.continuous
#align complex.continuous_re Complex.continuous_re
@[simp]
theorem reCLM_coe : (reCLM : ℂ →ₗ[ℝ] ℝ) = reLm :=
rfl
#align complex.re_clm_coe Complex.reCLM_coe
@[simp]
theorem reCLM_apply (z : ℂ) : (reCLM : ℂ → ℝ) z = z.re :=
rfl
#align complex.re_clm_apply Complex.reCLM_apply
def imCLM : ℂ →L[ℝ] ℝ :=
imLm.mkContinuous 1 fun x => by simp [abs_im_le_abs]
#align complex.im_clm Complex.imCLM
@[continuity, fun_prop]
theorem continuous_im : Continuous im :=
imCLM.continuous
#align complex.continuous_im Complex.continuous_im
@[simp]
theorem imCLM_coe : (imCLM : ℂ →ₗ[ℝ] ℝ) = imLm :=
rfl
#align complex.im_clm_coe Complex.imCLM_coe
@[simp]
theorem imCLM_apply (z : ℂ) : (imCLM : ℂ → ℝ) z = z.im :=
rfl
#align complex.im_clm_apply Complex.imCLM_apply
| Mathlib/Analysis/Complex/Basic.lean | 309 | 313 | theorem restrictScalars_one_smulRight' (x : E) :
ContinuousLinearMap.restrictScalars ℝ ((1 : ℂ →L[ℂ] ℂ).smulRight x : ℂ →L[ℂ] E) =
reCLM.smulRight x + I • imCLM.smulRight x := by |
ext ⟨a, b⟩
simp [mk_eq_add_mul_I, mul_smul, smul_comm I b x]
|
import Mathlib.Data.Option.NAry
import Mathlib.Data.Seq.Computation
#align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace Stream'
universe u v w
def IsSeq {α : Type u} (s : Stream' (Option α)) : Prop :=
∀ {n : ℕ}, s n = none → s (n + 1) = none
#align stream.is_seq Stream'.IsSeq
def Seq (α : Type u) : Type u :=
{ f : Stream' (Option α) // f.IsSeq }
#align stream.seq Stream'.Seq
def Seq1 (α) :=
α × Seq α
#align stream.seq1 Stream'.Seq1
namespace Seq
variable {α : Type u} {β : Type v} {γ : Type w}
def nil : Seq α :=
⟨Stream'.const none, fun {_} _ => rfl⟩
#align stream.seq.nil Stream'.Seq.nil
instance : Inhabited (Seq α) :=
⟨nil⟩
def cons (a : α) (s : Seq α) : Seq α :=
⟨some a::s.1, by
rintro (n | _) h
· contradiction
· exact s.2 h⟩
#align stream.seq.cons Stream'.Seq.cons
@[simp]
theorem val_cons (s : Seq α) (x : α) : (cons x s).val = some x::s.val :=
rfl
#align stream.seq.val_cons Stream'.Seq.val_cons
def get? : Seq α → ℕ → Option α :=
Subtype.val
#align stream.seq.nth Stream'.Seq.get?
@[simp]
theorem get?_mk (f hf) : @get? α ⟨f, hf⟩ = f :=
rfl
#align stream.seq.nth_mk Stream'.Seq.get?_mk
@[simp]
theorem get?_nil (n : ℕ) : (@nil α).get? n = none :=
rfl
#align stream.seq.nth_nil Stream'.Seq.get?_nil
@[simp]
theorem get?_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a :=
rfl
#align stream.seq.nth_cons_zero Stream'.Seq.get?_cons_zero
@[simp]
theorem get?_cons_succ (a : α) (s : Seq α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n :=
rfl
#align stream.seq.nth_cons_succ Stream'.Seq.get?_cons_succ
@[ext]
protected theorem ext {s t : Seq α} (h : ∀ n : ℕ, s.get? n = t.get? n) : s = t :=
Subtype.eq <| funext h
#align stream.seq.ext Stream'.Seq.ext
theorem cons_injective2 : Function.Injective2 (cons : α → Seq α → Seq α) := fun x y s t h =>
⟨by rw [← Option.some_inj, ← get?_cons_zero, h, get?_cons_zero],
Seq.ext fun n => by simp_rw [← get?_cons_succ x s n, h, get?_cons_succ]⟩
#align stream.seq.cons_injective2 Stream'.Seq.cons_injective2
theorem cons_left_injective (s : Seq α) : Function.Injective fun x => cons x s :=
cons_injective2.left _
#align stream.seq.cons_left_injective Stream'.Seq.cons_left_injective
theorem cons_right_injective (x : α) : Function.Injective (cons x) :=
cons_injective2.right _
#align stream.seq.cons_right_injective Stream'.Seq.cons_right_injective
def TerminatedAt (s : Seq α) (n : ℕ) : Prop :=
s.get? n = none
#align stream.seq.terminated_at Stream'.Seq.TerminatedAt
instance terminatedAtDecidable (s : Seq α) (n : ℕ) : Decidable (s.TerminatedAt n) :=
decidable_of_iff' (s.get? n).isNone <| by unfold TerminatedAt; cases s.get? n <;> simp
#align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable
def Terminates (s : Seq α) : Prop :=
∃ n : ℕ, s.TerminatedAt n
#align stream.seq.terminates Stream'.Seq.Terminates
theorem not_terminates_iff {s : Seq α} : ¬s.Terminates ↔ ∀ n, (s.get? n).isSome := by
simp only [Terminates, TerminatedAt, ← Ne.eq_def, Option.ne_none_iff_isSome, not_exists, iff_self]
#align stream.seq.not_terminates_iff Stream'.Seq.not_terminates_iff
@[simp]
def omap (f : β → γ) : Option (α × β) → Option (α × γ)
| none => none
| some (a, b) => some (a, f b)
#align stream.seq.omap Stream'.Seq.omap
def head (s : Seq α) : Option α :=
get? s 0
#align stream.seq.head Stream'.Seq.head
def tail (s : Seq α) : Seq α :=
⟨s.1.tail, fun n' => by
cases' s with f al
exact al n'⟩
#align stream.seq.tail Stream'.Seq.tail
protected def Mem (a : α) (s : Seq α) :=
some a ∈ s.1
#align stream.seq.mem Stream'.Seq.Mem
instance : Membership α (Seq α) :=
⟨Seq.Mem⟩
theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none := by
cases' s with f al
induction' h with n _ IH
exacts [id, fun h2 => al (IH h2)]
#align stream.seq.le_stable Stream'.Seq.le_stable
theorem terminated_stable : ∀ (s : Seq α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n :=
le_stable
#align stream.seq.terminated_stable Stream'.Seq.terminated_stable
| Mathlib/Data/Seq/Seq.lean | 174 | 178 | theorem ge_stable (s : Seq α) {aₙ : α} {n m : ℕ} (m_le_n : m ≤ n)
(s_nth_eq_some : s.get? n = some aₙ) : ∃ aₘ : α, s.get? m = some aₘ :=
have : s.get? n ≠ none := by | simp [s_nth_eq_some]
have : s.get? m ≠ none := mt (s.le_stable m_le_n) this
Option.ne_none_iff_exists'.mp this
|
import Mathlib.Order.Filter.Lift
import Mathlib.Topology.Defs.Filter
#align_import topology.basic from "leanprover-community/mathlib"@"e354e865255654389cc46e6032160238df2e0f40"
noncomputable section
open Set Filter
universe u v w x
def TopologicalSpace.ofClosed {X : Type u} (T : Set (Set X)) (empty_mem : ∅ ∈ T)
(sInter_mem : ∀ A, A ⊆ T → ⋂₀ A ∈ T)
(union_mem : ∀ A, A ∈ T → ∀ B, B ∈ T → A ∪ B ∈ T) : TopologicalSpace X where
IsOpen X := Xᶜ ∈ T
isOpen_univ := by simp [empty_mem]
isOpen_inter s t hs ht := by simpa only [compl_inter] using union_mem sᶜ hs tᶜ ht
isOpen_sUnion s hs := by
simp only [Set.compl_sUnion]
exact sInter_mem (compl '' s) fun z ⟨y, hy, hz⟩ => hz ▸ hs y hy
#align topological_space.of_closed TopologicalSpace.ofClosed
section TopologicalSpace
variable {X : Type u} {Y : Type v} {ι : Sort w} {α β : Type*}
{x : X} {s s₁ s₂ t : Set X} {p p₁ p₂ : X → Prop}
open Topology
lemma isOpen_mk {p h₁ h₂ h₃} : IsOpen[⟨p, h₁, h₂, h₃⟩] s ↔ p s := Iff.rfl
#align is_open_mk isOpen_mk
@[ext]
protected theorem TopologicalSpace.ext :
∀ {f g : TopologicalSpace X}, IsOpen[f] = IsOpen[g] → f = g
| ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl
#align topological_space_eq TopologicalSpace.ext
section
variable [TopologicalSpace X]
end
protected theorem TopologicalSpace.ext_iff {t t' : TopologicalSpace X} :
t = t' ↔ ∀ s, IsOpen[t] s ↔ IsOpen[t'] s :=
⟨fun h s => h ▸ Iff.rfl, fun h => by ext; exact h _⟩
#align topological_space_eq_iff TopologicalSpace.ext_iff
theorem isOpen_fold {t : TopologicalSpace X} : t.IsOpen s = IsOpen[t] s :=
rfl
#align is_open_fold isOpen_fold
variable [TopologicalSpace X]
theorem isOpen_iUnion {f : ι → Set X} (h : ∀ i, IsOpen (f i)) : IsOpen (⋃ i, f i) :=
isOpen_sUnion (forall_mem_range.2 h)
#align is_open_Union isOpen_iUnion
theorem isOpen_biUnion {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋃ i ∈ s, f i) :=
isOpen_iUnion fun i => isOpen_iUnion fun hi => h i hi
#align is_open_bUnion isOpen_biUnion
theorem IsOpen.union (h₁ : IsOpen s₁) (h₂ : IsOpen s₂) : IsOpen (s₁ ∪ s₂) := by
rw [union_eq_iUnion]; exact isOpen_iUnion (Bool.forall_bool.2 ⟨h₂, h₁⟩)
#align is_open.union IsOpen.union
lemma isOpen_iff_of_cover {f : α → Set X} (ho : ∀ i, IsOpen (f i)) (hU : (⋃ i, f i) = univ) :
IsOpen s ↔ ∀ i, IsOpen (f i ∩ s) := by
refine ⟨fun h i ↦ (ho i).inter h, fun h ↦ ?_⟩
rw [← s.inter_univ, inter_comm, ← hU, iUnion_inter]
exact isOpen_iUnion fun i ↦ h i
@[simp] theorem isOpen_empty : IsOpen (∅ : Set X) := by
rw [← sUnion_empty]; exact isOpen_sUnion fun a => False.elim
#align is_open_empty isOpen_empty
theorem Set.Finite.isOpen_sInter {s : Set (Set X)} (hs : s.Finite) :
(∀ t ∈ s, IsOpen t) → IsOpen (⋂₀ s) :=
Finite.induction_on hs (fun _ => by rw [sInter_empty]; exact isOpen_univ) fun _ _ ih h => by
simp only [sInter_insert, forall_mem_insert] at h ⊢
exact h.1.inter (ih h.2)
#align is_open_sInter Set.Finite.isOpen_sInter
theorem Set.Finite.isOpen_biInter {s : Set α} {f : α → Set X} (hs : s.Finite)
(h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋂ i ∈ s, f i) :=
sInter_image f s ▸ (hs.image _).isOpen_sInter (forall_mem_image.2 h)
#align is_open_bInter Set.Finite.isOpen_biInter
theorem isOpen_iInter_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsOpen (s i)) :
IsOpen (⋂ i, s i) :=
(finite_range _).isOpen_sInter (forall_mem_range.2 h)
#align is_open_Inter isOpen_iInter_of_finite
theorem isOpen_biInter_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋂ i ∈ s, f i) :=
s.finite_toSet.isOpen_biInter h
#align is_open_bInter_finset isOpen_biInter_finset
@[simp] -- Porting note: added `simp`
theorem isOpen_const {p : Prop} : IsOpen { _x : X | p } := by by_cases p <;> simp [*]
#align is_open_const isOpen_const
theorem IsOpen.and : IsOpen { x | p₁ x } → IsOpen { x | p₂ x } → IsOpen { x | p₁ x ∧ p₂ x } :=
IsOpen.inter
#align is_open.and IsOpen.and
@[simp] theorem isOpen_compl_iff : IsOpen sᶜ ↔ IsClosed s :=
⟨fun h => ⟨h⟩, fun h => h.isOpen_compl⟩
#align is_open_compl_iff isOpen_compl_iff
theorem TopologicalSpace.ext_iff_isClosed {t₁ t₂ : TopologicalSpace X} :
t₁ = t₂ ↔ ∀ s, IsClosed[t₁] s ↔ IsClosed[t₂] s := by
rw [TopologicalSpace.ext_iff, compl_surjective.forall]
simp only [@isOpen_compl_iff _ _ t₁, @isOpen_compl_iff _ _ t₂]
alias ⟨_, TopologicalSpace.ext_isClosed⟩ := TopologicalSpace.ext_iff_isClosed
-- Porting note (#10756): new lemma
theorem isClosed_const {p : Prop} : IsClosed { _x : X | p } := ⟨isOpen_const (p := ¬p)⟩
@[simp] theorem isClosed_empty : IsClosed (∅ : Set X) := isClosed_const
#align is_closed_empty isClosed_empty
@[simp] theorem isClosed_univ : IsClosed (univ : Set X) := isClosed_const
#align is_closed_univ isClosed_univ
theorem IsClosed.union : IsClosed s₁ → IsClosed s₂ → IsClosed (s₁ ∪ s₂) := by
simpa only [← isOpen_compl_iff, compl_union] using IsOpen.inter
#align is_closed.union IsClosed.union
theorem isClosed_sInter {s : Set (Set X)} : (∀ t ∈ s, IsClosed t) → IsClosed (⋂₀ s) := by
simpa only [← isOpen_compl_iff, compl_sInter, sUnion_image] using isOpen_biUnion
#align is_closed_sInter isClosed_sInter
theorem isClosed_iInter {f : ι → Set X} (h : ∀ i, IsClosed (f i)) : IsClosed (⋂ i, f i) :=
isClosed_sInter <| forall_mem_range.2 h
#align is_closed_Inter isClosed_iInter
theorem isClosed_biInter {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋂ i ∈ s, f i) :=
isClosed_iInter fun i => isClosed_iInter <| h i
#align is_closed_bInter isClosed_biInter
@[simp]
theorem isClosed_compl_iff {s : Set X} : IsClosed sᶜ ↔ IsOpen s := by
rw [← isOpen_compl_iff, compl_compl]
#align is_closed_compl_iff isClosed_compl_iff
alias ⟨_, IsOpen.isClosed_compl⟩ := isClosed_compl_iff
#align is_open.is_closed_compl IsOpen.isClosed_compl
theorem IsOpen.sdiff (h₁ : IsOpen s) (h₂ : IsClosed t) : IsOpen (s \ t) :=
IsOpen.inter h₁ h₂.isOpen_compl
#align is_open.sdiff IsOpen.sdiff
theorem IsClosed.inter (h₁ : IsClosed s₁) (h₂ : IsClosed s₂) : IsClosed (s₁ ∩ s₂) := by
rw [← isOpen_compl_iff] at *
rw [compl_inter]
exact IsOpen.union h₁ h₂
#align is_closed.inter IsClosed.inter
theorem IsClosed.sdiff (h₁ : IsClosed s) (h₂ : IsOpen t) : IsClosed (s \ t) :=
IsClosed.inter h₁ (isClosed_compl_iff.mpr h₂)
#align is_closed.sdiff IsClosed.sdiff
theorem Set.Finite.isClosed_biUnion {s : Set α} {f : α → Set X} (hs : s.Finite)
(h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋃ i ∈ s, f i) := by
simp only [← isOpen_compl_iff, compl_iUnion] at *
exact hs.isOpen_biInter h
#align is_closed_bUnion Set.Finite.isClosed_biUnion
lemma isClosed_biUnion_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋃ i ∈ s, f i) :=
s.finite_toSet.isClosed_biUnion h
theorem isClosed_iUnion_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsClosed (s i)) :
IsClosed (⋃ i, s i) := by
simp only [← isOpen_compl_iff, compl_iUnion] at *
exact isOpen_iInter_of_finite h
#align is_closed_Union isClosed_iUnion_of_finite
theorem isClosed_imp {p q : X → Prop} (hp : IsOpen { x | p x }) (hq : IsClosed { x | q x }) :
IsClosed { x | p x → q x } := by
simpa only [imp_iff_not_or] using hp.isClosed_compl.union hq
#align is_closed_imp isClosed_imp
theorem IsClosed.not : IsClosed { a | p a } → IsOpen { a | ¬p a } :=
isOpen_compl_iff.mpr
#align is_closed.not IsClosed.not
theorem mem_interior : x ∈ interior s ↔ ∃ t ⊆ s, IsOpen t ∧ x ∈ t := by
simp only [interior, mem_sUnion, mem_setOf_eq, and_assoc, and_left_comm]
#align mem_interior mem_interiorₓ
@[simp]
theorem isOpen_interior : IsOpen (interior s) :=
isOpen_sUnion fun _ => And.left
#align is_open_interior isOpen_interior
theorem interior_subset : interior s ⊆ s :=
sUnion_subset fun _ => And.right
#align interior_subset interior_subset
theorem interior_maximal (h₁ : t ⊆ s) (h₂ : IsOpen t) : t ⊆ interior s :=
subset_sUnion_of_mem ⟨h₂, h₁⟩
#align interior_maximal interior_maximal
theorem IsOpen.interior_eq (h : IsOpen s) : interior s = s :=
interior_subset.antisymm (interior_maximal (Subset.refl s) h)
#align is_open.interior_eq IsOpen.interior_eq
theorem interior_eq_iff_isOpen : interior s = s ↔ IsOpen s :=
⟨fun h => h ▸ isOpen_interior, IsOpen.interior_eq⟩
#align interior_eq_iff_is_open interior_eq_iff_isOpen
theorem subset_interior_iff_isOpen : s ⊆ interior s ↔ IsOpen s := by
simp only [interior_eq_iff_isOpen.symm, Subset.antisymm_iff, interior_subset, true_and]
#align subset_interior_iff_is_open subset_interior_iff_isOpen
theorem IsOpen.subset_interior_iff (h₁ : IsOpen s) : s ⊆ interior t ↔ s ⊆ t :=
⟨fun h => Subset.trans h interior_subset, fun h₂ => interior_maximal h₂ h₁⟩
#align is_open.subset_interior_iff IsOpen.subset_interior_iff
theorem subset_interior_iff : t ⊆ interior s ↔ ∃ U, IsOpen U ∧ t ⊆ U ∧ U ⊆ s :=
⟨fun h => ⟨interior s, isOpen_interior, h, interior_subset⟩, fun ⟨_U, hU, htU, hUs⟩ =>
htU.trans (interior_maximal hUs hU)⟩
#align subset_interior_iff subset_interior_iff
lemma interior_subset_iff : interior s ⊆ t ↔ ∀ U, IsOpen U → U ⊆ s → U ⊆ t := by
simp [interior]
@[mono, gcongr]
theorem interior_mono (h : s ⊆ t) : interior s ⊆ interior t :=
interior_maximal (Subset.trans interior_subset h) isOpen_interior
#align interior_mono interior_mono
@[simp]
theorem interior_empty : interior (∅ : Set X) = ∅ :=
isOpen_empty.interior_eq
#align interior_empty interior_empty
@[simp]
theorem interior_univ : interior (univ : Set X) = univ :=
isOpen_univ.interior_eq
#align interior_univ interior_univ
@[simp]
theorem interior_eq_univ : interior s = univ ↔ s = univ :=
⟨fun h => univ_subset_iff.mp <| h.symm.trans_le interior_subset, fun h => h.symm ▸ interior_univ⟩
#align interior_eq_univ interior_eq_univ
@[simp]
theorem interior_interior : interior (interior s) = interior s :=
isOpen_interior.interior_eq
#align interior_interior interior_interior
@[simp]
theorem interior_inter : interior (s ∩ t) = interior s ∩ interior t :=
(Monotone.map_inf_le (fun _ _ ↦ interior_mono) s t).antisymm <|
interior_maximal (inter_subset_inter interior_subset interior_subset) <|
isOpen_interior.inter isOpen_interior
#align interior_inter interior_inter
theorem Set.Finite.interior_biInter {ι : Type*} {s : Set ι} (hs : s.Finite) (f : ι → Set X) :
interior (⋂ i ∈ s, f i) = ⋂ i ∈ s, interior (f i) :=
hs.induction_on (by simp) <| by intros; simp [*]
theorem Set.Finite.interior_sInter {S : Set (Set X)} (hS : S.Finite) :
interior (⋂₀ S) = ⋂ s ∈ S, interior s := by
rw [sInter_eq_biInter, hS.interior_biInter]
@[simp]
theorem Finset.interior_iInter {ι : Type*} (s : Finset ι) (f : ι → Set X) :
interior (⋂ i ∈ s, f i) = ⋂ i ∈ s, interior (f i) :=
s.finite_toSet.interior_biInter f
#align finset.interior_Inter Finset.interior_iInter
@[simp]
theorem interior_iInter_of_finite [Finite ι] (f : ι → Set X) :
interior (⋂ i, f i) = ⋂ i, interior (f i) := by
rw [← sInter_range, (finite_range f).interior_sInter, biInter_range]
#align interior_Inter interior_iInter_of_finite
theorem interior_union_isClosed_of_interior_empty (h₁ : IsClosed s)
(h₂ : interior t = ∅) : interior (s ∪ t) = interior s :=
have : interior (s ∪ t) ⊆ s := fun x ⟨u, ⟨(hu₁ : IsOpen u), (hu₂ : u ⊆ s ∪ t)⟩, (hx₁ : x ∈ u)⟩ =>
by_contradiction fun hx₂ : x ∉ s =>
have : u \ s ⊆ t := fun x ⟨h₁, h₂⟩ => Or.resolve_left (hu₂ h₁) h₂
have : u \ s ⊆ interior t := by rwa [(IsOpen.sdiff hu₁ h₁).subset_interior_iff]
have : u \ s ⊆ ∅ := by rwa [h₂] at this
this ⟨hx₁, hx₂⟩
Subset.antisymm (interior_maximal this isOpen_interior) (interior_mono subset_union_left)
#align interior_union_is_closed_of_interior_empty interior_union_isClosed_of_interior_empty
theorem isOpen_iff_forall_mem_open : IsOpen s ↔ ∀ x ∈ s, ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := by
rw [← subset_interior_iff_isOpen]
simp only [subset_def, mem_interior]
#align is_open_iff_forall_mem_open isOpen_iff_forall_mem_open
theorem interior_iInter_subset (s : ι → Set X) : interior (⋂ i, s i) ⊆ ⋂ i, interior (s i) :=
subset_iInter fun _ => interior_mono <| iInter_subset _ _
#align interior_Inter_subset interior_iInter_subset
theorem interior_iInter₂_subset (p : ι → Sort*) (s : ∀ i, p i → Set X) :
interior (⋂ (i) (j), s i j) ⊆ ⋂ (i) (j), interior (s i j) :=
(interior_iInter_subset _).trans <| iInter_mono fun _ => interior_iInter_subset _
#align interior_Inter₂_subset interior_iInter₂_subset
theorem interior_sInter_subset (S : Set (Set X)) : interior (⋂₀ S) ⊆ ⋂ s ∈ S, interior s :=
calc
interior (⋂₀ S) = interior (⋂ s ∈ S, s) := by rw [sInter_eq_biInter]
_ ⊆ ⋂ s ∈ S, interior s := interior_iInter₂_subset _ _
#align interior_sInter_subset interior_sInter_subset
theorem Filter.HasBasis.lift'_interior {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) : (l.lift' interior).HasBasis p fun i => interior (s i) :=
h.lift' fun _ _ ↦ interior_mono
theorem Filter.lift'_interior_le (l : Filter X) : l.lift' interior ≤ l := fun _s hs ↦
mem_of_superset (mem_lift' hs) interior_subset
theorem Filter.HasBasis.lift'_interior_eq_self {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) (ho : ∀ i, p i → IsOpen (s i)) : l.lift' interior = l :=
le_antisymm l.lift'_interior_le <| h.lift'_interior.ge_iff.2 fun i hi ↦ by
simpa only [(ho i hi).interior_eq] using h.mem_of_mem hi
@[simp]
theorem isClosed_closure : IsClosed (closure s) :=
isClosed_sInter fun _ => And.left
#align is_closed_closure isClosed_closure
theorem subset_closure : s ⊆ closure s :=
subset_sInter fun _ => And.right
#align subset_closure subset_closure
theorem not_mem_of_not_mem_closure {P : X} (hP : P ∉ closure s) : P ∉ s := fun h =>
hP (subset_closure h)
#align not_mem_of_not_mem_closure not_mem_of_not_mem_closure
theorem closure_minimal (h₁ : s ⊆ t) (h₂ : IsClosed t) : closure s ⊆ t :=
sInter_subset_of_mem ⟨h₂, h₁⟩
#align closure_minimal closure_minimal
theorem Disjoint.closure_left (hd : Disjoint s t) (ht : IsOpen t) :
Disjoint (closure s) t :=
disjoint_compl_left.mono_left <| closure_minimal hd.subset_compl_right ht.isClosed_compl
#align disjoint.closure_left Disjoint.closure_left
theorem Disjoint.closure_right (hd : Disjoint s t) (hs : IsOpen s) :
Disjoint s (closure t) :=
(hd.symm.closure_left hs).symm
#align disjoint.closure_right Disjoint.closure_right
theorem IsClosed.closure_eq (h : IsClosed s) : closure s = s :=
Subset.antisymm (closure_minimal (Subset.refl s) h) subset_closure
#align is_closed.closure_eq IsClosed.closure_eq
theorem IsClosed.closure_subset (hs : IsClosed s) : closure s ⊆ s :=
closure_minimal (Subset.refl _) hs
#align is_closed.closure_subset IsClosed.closure_subset
theorem IsClosed.closure_subset_iff (h₁ : IsClosed t) : closure s ⊆ t ↔ s ⊆ t :=
⟨Subset.trans subset_closure, fun h => closure_minimal h h₁⟩
#align is_closed.closure_subset_iff IsClosed.closure_subset_iff
theorem IsClosed.mem_iff_closure_subset (hs : IsClosed s) :
x ∈ s ↔ closure ({x} : Set X) ⊆ s :=
(hs.closure_subset_iff.trans Set.singleton_subset_iff).symm
#align is_closed.mem_iff_closure_subset IsClosed.mem_iff_closure_subset
@[mono, gcongr]
theorem closure_mono (h : s ⊆ t) : closure s ⊆ closure t :=
closure_minimal (Subset.trans h subset_closure) isClosed_closure
#align closure_mono closure_mono
theorem monotone_closure (X : Type*) [TopologicalSpace X] : Monotone (@closure X _) := fun _ _ =>
closure_mono
#align monotone_closure monotone_closure
theorem diff_subset_closure_iff : s \ t ⊆ closure t ↔ s ⊆ closure t := by
rw [diff_subset_iff, union_eq_self_of_subset_left subset_closure]
#align diff_subset_closure_iff diff_subset_closure_iff
theorem closure_inter_subset_inter_closure (s t : Set X) :
closure (s ∩ t) ⊆ closure s ∩ closure t :=
(monotone_closure X).map_inf_le s t
#align closure_inter_subset_inter_closure closure_inter_subset_inter_closure
theorem isClosed_of_closure_subset (h : closure s ⊆ s) : IsClosed s := by
rw [subset_closure.antisymm h]; exact isClosed_closure
#align is_closed_of_closure_subset isClosed_of_closure_subset
theorem closure_eq_iff_isClosed : closure s = s ↔ IsClosed s :=
⟨fun h => h ▸ isClosed_closure, IsClosed.closure_eq⟩
#align closure_eq_iff_is_closed closure_eq_iff_isClosed
theorem closure_subset_iff_isClosed : closure s ⊆ s ↔ IsClosed s :=
⟨isClosed_of_closure_subset, IsClosed.closure_subset⟩
#align closure_subset_iff_is_closed closure_subset_iff_isClosed
@[simp]
theorem closure_empty : closure (∅ : Set X) = ∅ :=
isClosed_empty.closure_eq
#align closure_empty closure_empty
@[simp]
theorem closure_empty_iff (s : Set X) : closure s = ∅ ↔ s = ∅ :=
⟨subset_eq_empty subset_closure, fun h => h.symm ▸ closure_empty⟩
#align closure_empty_iff closure_empty_iff
@[simp]
theorem closure_nonempty_iff : (closure s).Nonempty ↔ s.Nonempty := by
simp only [nonempty_iff_ne_empty, Ne, closure_empty_iff]
#align closure_nonempty_iff closure_nonempty_iff
alias ⟨Set.Nonempty.of_closure, Set.Nonempty.closure⟩ := closure_nonempty_iff
#align set.nonempty.of_closure Set.Nonempty.of_closure
#align set.nonempty.closure Set.Nonempty.closure
@[simp]
theorem closure_univ : closure (univ : Set X) = univ :=
isClosed_univ.closure_eq
#align closure_univ closure_univ
@[simp]
theorem closure_closure : closure (closure s) = closure s :=
isClosed_closure.closure_eq
#align closure_closure closure_closure
theorem closure_eq_compl_interior_compl : closure s = (interior sᶜ)ᶜ := by
rw [interior, closure, compl_sUnion, compl_image_set_of]
simp only [compl_subset_compl, isOpen_compl_iff]
#align closure_eq_compl_interior_compl closure_eq_compl_interior_compl
@[simp]
theorem closure_union : closure (s ∪ t) = closure s ∪ closure t := by
simp [closure_eq_compl_interior_compl, compl_inter]
#align closure_union closure_union
theorem Set.Finite.closure_biUnion {ι : Type*} {s : Set ι} (hs : s.Finite) (f : ι → Set X) :
closure (⋃ i ∈ s, f i) = ⋃ i ∈ s, closure (f i) := by
simp [closure_eq_compl_interior_compl, hs.interior_biInter]
theorem Set.Finite.closure_sUnion {S : Set (Set X)} (hS : S.Finite) :
closure (⋃₀ S) = ⋃ s ∈ S, closure s := by
rw [sUnion_eq_biUnion, hS.closure_biUnion]
@[simp]
theorem Finset.closure_biUnion {ι : Type*} (s : Finset ι) (f : ι → Set X) :
closure (⋃ i ∈ s, f i) = ⋃ i ∈ s, closure (f i) :=
s.finite_toSet.closure_biUnion f
#align finset.closure_bUnion Finset.closure_biUnion
@[simp]
theorem closure_iUnion_of_finite [Finite ι] (f : ι → Set X) :
closure (⋃ i, f i) = ⋃ i, closure (f i) := by
rw [← sUnion_range, (finite_range _).closure_sUnion, biUnion_range]
#align closure_Union closure_iUnion_of_finite
theorem interior_subset_closure : interior s ⊆ closure s :=
Subset.trans interior_subset subset_closure
#align interior_subset_closure interior_subset_closure
@[simp]
theorem interior_compl : interior sᶜ = (closure s)ᶜ := by
simp [closure_eq_compl_interior_compl]
#align interior_compl interior_compl
@[simp]
theorem closure_compl : closure sᶜ = (interior s)ᶜ := by
simp [closure_eq_compl_interior_compl]
#align closure_compl closure_compl
theorem mem_closure_iff :
x ∈ closure s ↔ ∀ o, IsOpen o → x ∈ o → (o ∩ s).Nonempty :=
⟨fun h o oo ao =>
by_contradiction fun os =>
have : s ⊆ oᶜ := fun x xs xo => os ⟨x, xo, xs⟩
closure_minimal this (isClosed_compl_iff.2 oo) h ao,
fun H _ ⟨h₁, h₂⟩ =>
by_contradiction fun nc =>
let ⟨_, hc, hs⟩ := H _ h₁.isOpen_compl nc
hc (h₂ hs)⟩
#align mem_closure_iff mem_closure_iff
theorem closure_inter_open_nonempty_iff (h : IsOpen t) :
(closure s ∩ t).Nonempty ↔ (s ∩ t).Nonempty :=
⟨fun ⟨_x, hxcs, hxt⟩ => inter_comm t s ▸ mem_closure_iff.1 hxcs t h hxt, fun h =>
h.mono <| inf_le_inf_right t subset_closure⟩
#align closure_inter_open_nonempty_iff closure_inter_open_nonempty_iff
theorem Filter.le_lift'_closure (l : Filter X) : l ≤ l.lift' closure :=
le_lift'.2 fun _ h => mem_of_superset h subset_closure
#align filter.le_lift'_closure Filter.le_lift'_closure
theorem Filter.HasBasis.lift'_closure {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) : (l.lift' closure).HasBasis p fun i => closure (s i) :=
h.lift' (monotone_closure X)
#align filter.has_basis.lift'_closure Filter.HasBasis.lift'_closure
theorem Filter.HasBasis.lift'_closure_eq_self {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) (hc : ∀ i, p i → IsClosed (s i)) : l.lift' closure = l :=
le_antisymm (h.ge_iff.2 fun i hi => (hc i hi).closure_eq ▸ mem_lift' (h.mem_of_mem hi))
l.le_lift'_closure
#align filter.has_basis.lift'_closure_eq_self Filter.HasBasis.lift'_closure_eq_self
@[simp]
theorem Filter.lift'_closure_eq_bot {l : Filter X} : l.lift' closure = ⊥ ↔ l = ⊥ :=
⟨fun h => bot_unique <| h ▸ l.le_lift'_closure, fun h =>
h.symm ▸ by rw [lift'_bot (monotone_closure _), closure_empty, principal_empty]⟩
#align filter.lift'_closure_eq_bot Filter.lift'_closure_eq_bot
theorem dense_iff_closure_eq : Dense s ↔ closure s = univ :=
eq_univ_iff_forall.symm
#align dense_iff_closure_eq dense_iff_closure_eq
alias ⟨Dense.closure_eq, _⟩ := dense_iff_closure_eq
#align dense.closure_eq Dense.closure_eq
theorem interior_eq_empty_iff_dense_compl : interior s = ∅ ↔ Dense sᶜ := by
rw [dense_iff_closure_eq, closure_compl, compl_univ_iff]
#align interior_eq_empty_iff_dense_compl interior_eq_empty_iff_dense_compl
theorem Dense.interior_compl (h : Dense s) : interior sᶜ = ∅ :=
interior_eq_empty_iff_dense_compl.2 <| by rwa [compl_compl]
#align dense.interior_compl Dense.interior_compl
@[simp]
theorem dense_closure : Dense (closure s) ↔ Dense s := by
rw [Dense, Dense, closure_closure]
#align dense_closure dense_closure
protected alias ⟨_, Dense.closure⟩ := dense_closure
alias ⟨Dense.of_closure, _⟩ := dense_closure
#align dense.of_closure Dense.of_closure
#align dense.closure Dense.closure
@[simp]
theorem dense_univ : Dense (univ : Set X) := fun _ => subset_closure trivial
#align dense_univ dense_univ
theorem dense_iff_inter_open :
Dense s ↔ ∀ U, IsOpen U → U.Nonempty → (U ∩ s).Nonempty := by
constructor <;> intro h
· rintro U U_op ⟨x, x_in⟩
exact mem_closure_iff.1 (h _) U U_op x_in
· intro x
rw [mem_closure_iff]
intro U U_op x_in
exact h U U_op ⟨_, x_in⟩
#align dense_iff_inter_open dense_iff_inter_open
alias ⟨Dense.inter_open_nonempty, _⟩ := dense_iff_inter_open
#align dense.inter_open_nonempty Dense.inter_open_nonempty
theorem Dense.exists_mem_open (hs : Dense s) {U : Set X} (ho : IsOpen U)
(hne : U.Nonempty) : ∃ x ∈ s, x ∈ U :=
let ⟨x, hx⟩ := hs.inter_open_nonempty U ho hne
⟨x, hx.2, hx.1⟩
#align dense.exists_mem_open Dense.exists_mem_open
theorem Dense.nonempty_iff (hs : Dense s) : s.Nonempty ↔ Nonempty X :=
⟨fun ⟨x, _⟩ => ⟨x⟩, fun ⟨x⟩ =>
let ⟨y, hy⟩ := hs.inter_open_nonempty _ isOpen_univ ⟨x, trivial⟩
⟨y, hy.2⟩⟩
#align dense.nonempty_iff Dense.nonempty_iff
theorem Dense.nonempty [h : Nonempty X] (hs : Dense s) : s.Nonempty :=
hs.nonempty_iff.2 h
#align dense.nonempty Dense.nonempty
@[mono]
theorem Dense.mono (h : s₁ ⊆ s₂) (hd : Dense s₁) : Dense s₂ := fun x =>
closure_mono h (hd x)
#align dense.mono Dense.mono
theorem dense_compl_singleton_iff_not_open :
Dense ({x}ᶜ : Set X) ↔ ¬IsOpen ({x} : Set X) := by
constructor
· intro hd ho
exact (hd.inter_open_nonempty _ ho (singleton_nonempty _)).ne_empty (inter_compl_self _)
· refine fun ho => dense_iff_inter_open.2 fun U hU hne => inter_compl_nonempty_iff.2 fun hUx => ?_
obtain rfl : U = {x} := eq_singleton_iff_nonempty_unique_mem.2 ⟨hne, hUx⟩
exact ho hU
#align dense_compl_singleton_iff_not_open dense_compl_singleton_iff_not_open
@[simp]
theorem closure_diff_interior (s : Set X) : closure s \ interior s = frontier s :=
rfl
#align closure_diff_interior closure_diff_interior
lemma disjoint_interior_frontier : Disjoint (interior s) (frontier s) := by
rw [disjoint_iff_inter_eq_empty, ← closure_diff_interior, diff_eq,
← inter_assoc, inter_comm, ← inter_assoc, compl_inter_self, empty_inter]
@[simp]
theorem closure_diff_frontier (s : Set X) : closure s \ frontier s = interior s := by
rw [frontier, diff_diff_right_self, inter_eq_self_of_subset_right interior_subset_closure]
#align closure_diff_frontier closure_diff_frontier
@[simp]
theorem self_diff_frontier (s : Set X) : s \ frontier s = interior s := by
rw [frontier, diff_diff_right, diff_eq_empty.2 subset_closure,
inter_eq_self_of_subset_right interior_subset, empty_union]
#align self_diff_frontier self_diff_frontier
theorem frontier_eq_closure_inter_closure : frontier s = closure s ∩ closure sᶜ := by
rw [closure_compl, frontier, diff_eq]
#align frontier_eq_closure_inter_closure frontier_eq_closure_inter_closure
theorem frontier_subset_closure : frontier s ⊆ closure s :=
diff_subset
#align frontier_subset_closure frontier_subset_closure
theorem IsClosed.frontier_subset (hs : IsClosed s) : frontier s ⊆ s :=
frontier_subset_closure.trans hs.closure_eq.subset
#align is_closed.frontier_subset IsClosed.frontier_subset
theorem frontier_closure_subset : frontier (closure s) ⊆ frontier s :=
diff_subset_diff closure_closure.subset <| interior_mono subset_closure
#align frontier_closure_subset frontier_closure_subset
theorem frontier_interior_subset : frontier (interior s) ⊆ frontier s :=
diff_subset_diff (closure_mono interior_subset) interior_interior.symm.subset
#align frontier_interior_subset frontier_interior_subset
@[simp]
theorem frontier_compl (s : Set X) : frontier sᶜ = frontier s := by
simp only [frontier_eq_closure_inter_closure, compl_compl, inter_comm]
#align frontier_compl frontier_compl
@[simp]
theorem frontier_univ : frontier (univ : Set X) = ∅ := by simp [frontier]
#align frontier_univ frontier_univ
@[simp]
theorem frontier_empty : frontier (∅ : Set X) = ∅ := by simp [frontier]
#align frontier_empty frontier_empty
theorem frontier_inter_subset (s t : Set X) :
frontier (s ∩ t) ⊆ frontier s ∩ closure t ∪ closure s ∩ frontier t := by
simp only [frontier_eq_closure_inter_closure, compl_inter, closure_union]
refine (inter_subset_inter_left _ (closure_inter_subset_inter_closure s t)).trans_eq ?_
simp only [inter_union_distrib_left, union_inter_distrib_right, inter_assoc,
inter_comm (closure t)]
#align frontier_inter_subset frontier_inter_subset
theorem frontier_union_subset (s t : Set X) :
frontier (s ∪ t) ⊆ frontier s ∩ closure tᶜ ∪ closure sᶜ ∩ frontier t := by
simpa only [frontier_compl, ← compl_union] using frontier_inter_subset sᶜ tᶜ
#align frontier_union_subset frontier_union_subset
theorem IsClosed.frontier_eq (hs : IsClosed s) : frontier s = s \ interior s := by
rw [frontier, hs.closure_eq]
#align is_closed.frontier_eq IsClosed.frontier_eq
theorem IsOpen.frontier_eq (hs : IsOpen s) : frontier s = closure s \ s := by
rw [frontier, hs.interior_eq]
#align is_open.frontier_eq IsOpen.frontier_eq
theorem IsOpen.inter_frontier_eq (hs : IsOpen s) : s ∩ frontier s = ∅ := by
rw [hs.frontier_eq, inter_diff_self]
#align is_open.inter_frontier_eq IsOpen.inter_frontier_eq
theorem isClosed_frontier : IsClosed (frontier s) := by
rw [frontier_eq_closure_inter_closure]; exact IsClosed.inter isClosed_closure isClosed_closure
#align is_closed_frontier isClosed_frontier
theorem interior_frontier (h : IsClosed s) : interior (frontier s) = ∅ := by
have A : frontier s = s \ interior s := h.frontier_eq
have B : interior (frontier s) ⊆ interior s := by rw [A]; exact interior_mono diff_subset
have C : interior (frontier s) ⊆ frontier s := interior_subset
have : interior (frontier s) ⊆ interior s ∩ (s \ interior s) :=
subset_inter B (by simpa [A] using C)
rwa [inter_diff_self, subset_empty_iff] at this
#align interior_frontier interior_frontier
theorem closure_eq_interior_union_frontier (s : Set X) : closure s = interior s ∪ frontier s :=
(union_diff_cancel interior_subset_closure).symm
#align closure_eq_interior_union_frontier closure_eq_interior_union_frontier
theorem closure_eq_self_union_frontier (s : Set X) : closure s = s ∪ frontier s :=
(union_diff_cancel' interior_subset subset_closure).symm
#align closure_eq_self_union_frontier closure_eq_self_union_frontier
theorem Disjoint.frontier_left (ht : IsOpen t) (hd : Disjoint s t) : Disjoint (frontier s) t :=
subset_compl_iff_disjoint_right.1 <|
frontier_subset_closure.trans <| closure_minimal (disjoint_left.1 hd) <| isClosed_compl_iff.2 ht
#align disjoint.frontier_left Disjoint.frontier_left
theorem Disjoint.frontier_right (hs : IsOpen s) (hd : Disjoint s t) : Disjoint s (frontier t) :=
(hd.symm.frontier_left hs).symm
#align disjoint.frontier_right Disjoint.frontier_right
theorem frontier_eq_inter_compl_interior :
frontier s = (interior s)ᶜ ∩ (interior sᶜ)ᶜ := by
rw [← frontier_compl, ← closure_compl, ← diff_eq, closure_diff_interior]
#align frontier_eq_inter_compl_interior frontier_eq_inter_compl_interior
theorem compl_frontier_eq_union_interior :
(frontier s)ᶜ = interior s ∪ interior sᶜ := by
rw [frontier_eq_inter_compl_interior]
simp only [compl_inter, compl_compl]
#align compl_frontier_eq_union_interior compl_frontier_eq_union_interior
theorem nhds_def' (x : X) : 𝓝 x = ⨅ (s : Set X) (_ : IsOpen s) (_ : x ∈ s), 𝓟 s := by
simp only [nhds_def, mem_setOf_eq, @and_comm (x ∈ _), iInf_and]
#align nhds_def' nhds_def'
theorem nhds_basis_opens (x : X) :
(𝓝 x).HasBasis (fun s : Set X => x ∈ s ∧ IsOpen s) fun s => s := by
rw [nhds_def]
exact hasBasis_biInf_principal
(fun s ⟨has, hs⟩ t ⟨hat, ht⟩ =>
⟨s ∩ t, ⟨⟨has, hat⟩, IsOpen.inter hs ht⟩, ⟨inter_subset_left, inter_subset_right⟩⟩)
⟨univ, ⟨mem_univ x, isOpen_univ⟩⟩
#align nhds_basis_opens nhds_basis_opens
theorem nhds_basis_closeds (x : X) : (𝓝 x).HasBasis (fun s : Set X => x ∉ s ∧ IsClosed s) compl :=
⟨fun t => (nhds_basis_opens x).mem_iff.trans <|
compl_surjective.exists.trans <| by simp only [isOpen_compl_iff, mem_compl_iff]⟩
#align nhds_basis_closeds nhds_basis_closeds
@[simp]
theorem lift'_nhds_interior (x : X) : (𝓝 x).lift' interior = 𝓝 x :=
(nhds_basis_opens x).lift'_interior_eq_self fun _ ↦ And.right
theorem Filter.HasBasis.nhds_interior {x : X} {p : ι → Prop} {s : ι → Set X}
(h : (𝓝 x).HasBasis p s) : (𝓝 x).HasBasis p (interior <| s ·) :=
lift'_nhds_interior x ▸ h.lift'_interior
theorem le_nhds_iff {f} : f ≤ 𝓝 x ↔ ∀ s : Set X, x ∈ s → IsOpen s → s ∈ f := by simp [nhds_def]
#align le_nhds_iff le_nhds_iff
theorem nhds_le_of_le {f} (h : x ∈ s) (o : IsOpen s) (sf : 𝓟 s ≤ f) : 𝓝 x ≤ f := by
rw [nhds_def]; exact iInf₂_le_of_le s ⟨h, o⟩ sf
#align nhds_le_of_le nhds_le_of_le
theorem mem_nhds_iff : s ∈ 𝓝 x ↔ ∃ t ⊆ s, IsOpen t ∧ x ∈ t :=
(nhds_basis_opens x).mem_iff.trans <| exists_congr fun _ =>
⟨fun h => ⟨h.2, h.1.2, h.1.1⟩, fun h => ⟨⟨h.2.2, h.2.1⟩, h.1⟩⟩
#align mem_nhds_iff mem_nhds_iffₓ
theorem eventually_nhds_iff {p : X → Prop} :
(∀ᶠ x in 𝓝 x, p x) ↔ ∃ t : Set X, (∀ x ∈ t, p x) ∧ IsOpen t ∧ x ∈ t :=
mem_nhds_iff.trans <| by simp only [subset_def, exists_prop, mem_setOf_eq]
#align eventually_nhds_iff eventually_nhds_iff
theorem mem_interior_iff_mem_nhds : x ∈ interior s ↔ s ∈ 𝓝 x :=
mem_interior.trans mem_nhds_iff.symm
#align mem_interior_iff_mem_nhds mem_interior_iff_mem_nhds
theorem map_nhds {f : X → α} :
map f (𝓝 x) = ⨅ s ∈ { s : Set X | x ∈ s ∧ IsOpen s }, 𝓟 (f '' s) :=
((nhds_basis_opens x).map f).eq_biInf
#align map_nhds map_nhds
theorem mem_of_mem_nhds : s ∈ 𝓝 x → x ∈ s := fun H =>
let ⟨_t, ht, _, hs⟩ := mem_nhds_iff.1 H; ht hs
#align mem_of_mem_nhds mem_of_mem_nhds
theorem Filter.Eventually.self_of_nhds {p : X → Prop} (h : ∀ᶠ y in 𝓝 x, p y) : p x :=
mem_of_mem_nhds h
#align filter.eventually.self_of_nhds Filter.Eventually.self_of_nhds
theorem IsOpen.mem_nhds (hs : IsOpen s) (hx : x ∈ s) : s ∈ 𝓝 x :=
mem_nhds_iff.2 ⟨s, Subset.refl _, hs, hx⟩
#align is_open.mem_nhds IsOpen.mem_nhds
protected theorem IsOpen.mem_nhds_iff (hs : IsOpen s) : s ∈ 𝓝 x ↔ x ∈ s :=
⟨mem_of_mem_nhds, fun hx => mem_nhds_iff.2 ⟨s, Subset.rfl, hs, hx⟩⟩
#align is_open.mem_nhds_iff IsOpen.mem_nhds_iff
theorem IsClosed.compl_mem_nhds (hs : IsClosed s) (hx : x ∉ s) : sᶜ ∈ 𝓝 x :=
hs.isOpen_compl.mem_nhds (mem_compl hx)
#align is_closed.compl_mem_nhds IsClosed.compl_mem_nhds
theorem IsOpen.eventually_mem (hs : IsOpen s) (hx : x ∈ s) :
∀ᶠ x in 𝓝 x, x ∈ s :=
IsOpen.mem_nhds hs hx
#align is_open.eventually_mem IsOpen.eventually_mem
theorem nhds_basis_opens' (x : X) :
(𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsOpen s) fun x => x := by
convert nhds_basis_opens x using 2
exact and_congr_left_iff.2 IsOpen.mem_nhds_iff
#align nhds_basis_opens' nhds_basis_opens'
theorem exists_open_set_nhds {U : Set X} (h : ∀ x ∈ s, U ∈ 𝓝 x) :
∃ V : Set X, s ⊆ V ∧ IsOpen V ∧ V ⊆ U :=
⟨interior U, fun x hx => mem_interior_iff_mem_nhds.2 <| h x hx, isOpen_interior, interior_subset⟩
#align exists_open_set_nhds exists_open_set_nhds
theorem exists_open_set_nhds' {U : Set X} (h : U ∈ ⨆ x ∈ s, 𝓝 x) :
∃ V : Set X, s ⊆ V ∧ IsOpen V ∧ V ⊆ U :=
exists_open_set_nhds (by simpa using h)
#align exists_open_set_nhds' exists_open_set_nhds'
theorem Filter.Eventually.eventually_nhds {p : X → Prop} (h : ∀ᶠ y in 𝓝 x, p y) :
∀ᶠ y in 𝓝 x, ∀ᶠ x in 𝓝 y, p x :=
let ⟨t, htp, hto, ha⟩ := eventually_nhds_iff.1 h
eventually_nhds_iff.2 ⟨t, fun _x hx => eventually_nhds_iff.2 ⟨t, htp, hto, hx⟩, hto, ha⟩
#align filter.eventually.eventually_nhds Filter.Eventually.eventually_nhds
@[simp]
theorem eventually_eventually_nhds {p : X → Prop} :
(∀ᶠ y in 𝓝 x, ∀ᶠ x in 𝓝 y, p x) ↔ ∀ᶠ x in 𝓝 x, p x :=
⟨fun h => h.self_of_nhds, fun h => h.eventually_nhds⟩
#align eventually_eventually_nhds eventually_eventually_nhds
@[simp]
theorem frequently_frequently_nhds {p : X → Prop} :
(∃ᶠ x' in 𝓝 x, ∃ᶠ x'' in 𝓝 x', p x'') ↔ ∃ᶠ x in 𝓝 x, p x := by
rw [← not_iff_not]
simp only [not_frequently, eventually_eventually_nhds]
#align frequently_frequently_nhds frequently_frequently_nhds
@[simp]
theorem eventually_mem_nhds : (∀ᶠ x' in 𝓝 x, s ∈ 𝓝 x') ↔ s ∈ 𝓝 x :=
eventually_eventually_nhds
#align eventually_mem_nhds eventually_mem_nhds
@[simp]
theorem nhds_bind_nhds : (𝓝 x).bind 𝓝 = 𝓝 x :=
Filter.ext fun _ => eventually_eventually_nhds
#align nhds_bind_nhds nhds_bind_nhds
@[simp]
theorem eventually_eventuallyEq_nhds {f g : X → α} :
(∀ᶠ y in 𝓝 x, f =ᶠ[𝓝 y] g) ↔ f =ᶠ[𝓝 x] g :=
eventually_eventually_nhds
#align eventually_eventually_eq_nhds eventually_eventuallyEq_nhds
theorem Filter.EventuallyEq.eq_of_nhds {f g : X → α} (h : f =ᶠ[𝓝 x] g) : f x = g x :=
h.self_of_nhds
#align filter.eventually_eq.eq_of_nhds Filter.EventuallyEq.eq_of_nhds
@[simp]
theorem eventually_eventuallyLE_nhds [LE α] {f g : X → α} :
(∀ᶠ y in 𝓝 x, f ≤ᶠ[𝓝 y] g) ↔ f ≤ᶠ[𝓝 x] g :=
eventually_eventually_nhds
#align eventually_eventually_le_nhds eventually_eventuallyLE_nhds
theorem Filter.EventuallyEq.eventuallyEq_nhds {f g : X → α} (h : f =ᶠ[𝓝 x] g) :
∀ᶠ y in 𝓝 x, f =ᶠ[𝓝 y] g :=
h.eventually_nhds
#align filter.eventually_eq.eventually_eq_nhds Filter.EventuallyEq.eventuallyEq_nhds
theorem Filter.EventuallyLE.eventuallyLE_nhds [LE α] {f g : X → α} (h : f ≤ᶠ[𝓝 x] g) :
∀ᶠ y in 𝓝 x, f ≤ᶠ[𝓝 y] g :=
h.eventually_nhds
#align filter.eventually_le.eventually_le_nhds Filter.EventuallyLE.eventuallyLE_nhds
theorem all_mem_nhds (x : X) (P : Set X → Prop) (hP : ∀ s t, s ⊆ t → P s → P t) :
(∀ s ∈ 𝓝 x, P s) ↔ ∀ s, IsOpen s → x ∈ s → P s :=
((nhds_basis_opens x).forall_iff hP).trans <| by simp only [@and_comm (x ∈ _), and_imp]
#align all_mem_nhds all_mem_nhds
theorem all_mem_nhds_filter (x : X) (f : Set X → Set α) (hf : ∀ s t, s ⊆ t → f s ⊆ f t)
(l : Filter α) : (∀ s ∈ 𝓝 x, f s ∈ l) ↔ ∀ s, IsOpen s → x ∈ s → f s ∈ l :=
all_mem_nhds _ _ fun s t ssubt h => mem_of_superset h (hf s t ssubt)
#align all_mem_nhds_filter all_mem_nhds_filter
theorem tendsto_nhds {f : α → X} {l : Filter α} :
Tendsto f l (𝓝 x) ↔ ∀ s, IsOpen s → x ∈ s → f ⁻¹' s ∈ l :=
all_mem_nhds_filter _ _ (fun _ _ h => preimage_mono h) _
#align tendsto_nhds tendsto_nhds
theorem tendsto_atTop_nhds [Nonempty α] [SemilatticeSup α] {f : α → X} :
Tendsto f atTop (𝓝 x) ↔ ∀ U : Set X, x ∈ U → IsOpen U → ∃ N, ∀ n, N ≤ n → f n ∈ U :=
(atTop_basis.tendsto_iff (nhds_basis_opens x)).trans <| by
simp only [and_imp, exists_prop, true_and_iff, mem_Ici, ge_iff_le]
#align tendsto_at_top_nhds tendsto_atTop_nhds
theorem tendsto_const_nhds {f : Filter α} : Tendsto (fun _ : α => x) f (𝓝 x) :=
tendsto_nhds.mpr fun _ _ ha => univ_mem' fun _ => ha
#align tendsto_const_nhds tendsto_const_nhds
theorem tendsto_atTop_of_eventually_const {ι : Type*} [SemilatticeSup ι] [Nonempty ι]
{u : ι → X} {i₀ : ι} (h : ∀ i ≥ i₀, u i = x) : Tendsto u atTop (𝓝 x) :=
Tendsto.congr' (EventuallyEq.symm (eventually_atTop.mpr ⟨i₀, h⟩)) tendsto_const_nhds
#align tendsto_at_top_of_eventually_const tendsto_atTop_of_eventually_const
theorem tendsto_atBot_of_eventually_const {ι : Type*} [SemilatticeInf ι] [Nonempty ι]
{u : ι → X} {i₀ : ι} (h : ∀ i ≤ i₀, u i = x) : Tendsto u atBot (𝓝 x) :=
Tendsto.congr' (EventuallyEq.symm (eventually_atBot.mpr ⟨i₀, h⟩)) tendsto_const_nhds
#align tendsto_at_bot_of_eventually_const tendsto_atBot_of_eventually_const
theorem pure_le_nhds : pure ≤ (𝓝 : X → Filter X) := fun _ _ hs => mem_pure.2 <| mem_of_mem_nhds hs
#align pure_le_nhds pure_le_nhds
theorem tendsto_pure_nhds (f : α → X) (a : α) : Tendsto f (pure a) (𝓝 (f a)) :=
(tendsto_pure_pure f a).mono_right (pure_le_nhds _)
#align tendsto_pure_nhds tendsto_pure_nhds
theorem OrderTop.tendsto_atTop_nhds [PartialOrder α] [OrderTop α] (f : α → X) :
Tendsto f atTop (𝓝 (f ⊤)) :=
(tendsto_atTop_pure f).mono_right (pure_le_nhds _)
#align order_top.tendsto_at_top_nhds OrderTop.tendsto_atTop_nhds
@[simp]
instance nhds_neBot : NeBot (𝓝 x) :=
neBot_of_le (pure_le_nhds x)
#align nhds_ne_bot nhds_neBot
theorem tendsto_nhds_of_eventually_eq {l : Filter α} {f : α → X} (h : ∀ᶠ x' in l, f x' = x) :
Tendsto f l (𝓝 x) :=
tendsto_const_nhds.congr' (.symm h)
theorem Filter.EventuallyEq.tendsto {l : Filter α} {f : α → X} (hf : f =ᶠ[l] fun _ ↦ x) :
Tendsto f l (𝓝 x) :=
tendsto_nhds_of_eventually_eq hf
theorem ClusterPt.neBot {F : Filter X} (h : ClusterPt x F) : NeBot (𝓝 x ⊓ F) :=
h
#align cluster_pt.ne_bot ClusterPt.neBot
theorem Filter.HasBasis.clusterPt_iff {ιX ιF} {pX : ιX → Prop} {sX : ιX → Set X} {pF : ιF → Prop}
{sF : ιF → Set X} {F : Filter X} (hX : (𝓝 x).HasBasis pX sX) (hF : F.HasBasis pF sF) :
ClusterPt x F ↔ ∀ ⦃i⦄, pX i → ∀ ⦃j⦄, pF j → (sX i ∩ sF j).Nonempty :=
hX.inf_basis_neBot_iff hF
#align filter.has_basis.cluster_pt_iff Filter.HasBasis.clusterPt_iff
theorem clusterPt_iff {F : Filter X} :
ClusterPt x F ↔ ∀ ⦃U : Set X⦄, U ∈ 𝓝 x → ∀ ⦃V⦄, V ∈ F → (U ∩ V).Nonempty :=
inf_neBot_iff
#align cluster_pt_iff clusterPt_iff
theorem clusterPt_iff_not_disjoint {F : Filter X} :
ClusterPt x F ↔ ¬Disjoint (𝓝 x) F := by
rw [disjoint_iff, ClusterPt, neBot_iff]
theorem clusterPt_principal_iff :
ClusterPt x (𝓟 s) ↔ ∀ U ∈ 𝓝 x, (U ∩ s).Nonempty :=
inf_principal_neBot_iff
#align cluster_pt_principal_iff clusterPt_principal_iff
theorem clusterPt_principal_iff_frequently :
ClusterPt x (𝓟 s) ↔ ∃ᶠ y in 𝓝 x, y ∈ s := by
simp only [clusterPt_principal_iff, frequently_iff, Set.Nonempty, exists_prop, mem_inter_iff]
#align cluster_pt_principal_iff_frequently clusterPt_principal_iff_frequently
theorem ClusterPt.of_le_nhds {f : Filter X} (H : f ≤ 𝓝 x) [NeBot f] : ClusterPt x f := by
rwa [ClusterPt, inf_eq_right.mpr H]
#align cluster_pt.of_le_nhds ClusterPt.of_le_nhds
theorem ClusterPt.of_le_nhds' {f : Filter X} (H : f ≤ 𝓝 x) (_hf : NeBot f) :
ClusterPt x f :=
ClusterPt.of_le_nhds H
#align cluster_pt.of_le_nhds' ClusterPt.of_le_nhds'
theorem ClusterPt.of_nhds_le {f : Filter X} (H : 𝓝 x ≤ f) : ClusterPt x f := by
simp only [ClusterPt, inf_eq_left.mpr H, nhds_neBot]
#align cluster_pt.of_nhds_le ClusterPt.of_nhds_le
theorem ClusterPt.mono {f g : Filter X} (H : ClusterPt x f) (h : f ≤ g) : ClusterPt x g :=
NeBot.mono H <| inf_le_inf_left _ h
#align cluster_pt.mono ClusterPt.mono
theorem ClusterPt.of_inf_left {f g : Filter X} (H : ClusterPt x <| f ⊓ g) : ClusterPt x f :=
H.mono inf_le_left
#align cluster_pt.of_inf_left ClusterPt.of_inf_left
theorem ClusterPt.of_inf_right {f g : Filter X} (H : ClusterPt x <| f ⊓ g) :
ClusterPt x g :=
H.mono inf_le_right
#align cluster_pt.of_inf_right ClusterPt.of_inf_right
theorem Ultrafilter.clusterPt_iff {f : Ultrafilter X} : ClusterPt x f ↔ ↑f ≤ 𝓝 x :=
⟨f.le_of_inf_neBot', fun h => ClusterPt.of_le_nhds h⟩
#align ultrafilter.cluster_pt_iff Ultrafilter.clusterPt_iff
theorem clusterPt_iff_ultrafilter {f : Filter X} : ClusterPt x f ↔
∃ u : Ultrafilter X, u ≤ f ∧ u ≤ 𝓝 x := by
simp_rw [ClusterPt, ← le_inf_iff, exists_ultrafilter_iff, inf_comm]
theorem mapClusterPt_def {ι : Type*} (x : X) (F : Filter ι) (u : ι → X) :
MapClusterPt x F u ↔ ClusterPt x (map u F) := Iff.rfl
theorem mapClusterPt_iff {ι : Type*} (x : X) (F : Filter ι) (u : ι → X) :
MapClusterPt x F u ↔ ∀ s ∈ 𝓝 x, ∃ᶠ a in F, u a ∈ s := by
simp_rw [MapClusterPt, ClusterPt, inf_neBot_iff_frequently_left, frequently_map]
rfl
#align map_cluster_pt_iff mapClusterPt_iff
theorem mapClusterPt_iff_ultrafilter {ι : Type*} (x : X) (F : Filter ι) (u : ι → X) :
MapClusterPt x F u ↔ ∃ U : Ultrafilter ι, U ≤ F ∧ Tendsto u U (𝓝 x) := by
simp_rw [MapClusterPt, ClusterPt, ← Filter.push_pull', map_neBot_iff, tendsto_iff_comap,
← le_inf_iff, exists_ultrafilter_iff, inf_comm]
theorem mapClusterPt_comp {X α β : Type*} {x : X} [TopologicalSpace X] {F : Filter α} {φ : α → β}
{u : β → X} : MapClusterPt x F (u ∘ φ) ↔ MapClusterPt x (map φ F) u := Iff.rfl
theorem mapClusterPt_of_comp {F : Filter α} {φ : β → α} {p : Filter β}
{u : α → X} [NeBot p] (h : Tendsto φ p F) (H : Tendsto (u ∘ φ) p (𝓝 x)) :
MapClusterPt x F u := by
have :=
calc
map (u ∘ φ) p = map u (map φ p) := map_map
_ ≤ map u F := map_mono h
have : map (u ∘ φ) p ≤ 𝓝 x ⊓ map u F := le_inf H this
exact neBot_of_le this
#align map_cluster_pt_of_comp mapClusterPt_of_comp
theorem acc_iff_cluster (x : X) (F : Filter X) : AccPt x F ↔ ClusterPt x (𝓟 {x}ᶜ ⊓ F) := by
rw [AccPt, nhdsWithin, ClusterPt, inf_assoc]
#align acc_iff_cluster acc_iff_cluster
theorem acc_principal_iff_cluster (x : X) (C : Set X) :
AccPt x (𝓟 C) ↔ ClusterPt x (𝓟 (C \ {x})) := by
rw [acc_iff_cluster, inf_principal, inter_comm, diff_eq]
#align acc_principal_iff_cluster acc_principal_iff_cluster
theorem accPt_iff_nhds (x : X) (C : Set X) : AccPt x (𝓟 C) ↔ ∀ U ∈ 𝓝 x, ∃ y ∈ U ∩ C, y ≠ x := by
simp [acc_principal_iff_cluster, clusterPt_principal_iff, Set.Nonempty, exists_prop, and_assoc,
@and_comm (¬_ = x)]
#align acc_pt_iff_nhds accPt_iff_nhds
theorem accPt_iff_frequently (x : X) (C : Set X) : AccPt x (𝓟 C) ↔ ∃ᶠ y in 𝓝 x, y ≠ x ∧ y ∈ C := by
simp [acc_principal_iff_cluster, clusterPt_principal_iff_frequently, and_comm]
#align acc_pt_iff_frequently accPt_iff_frequently
theorem AccPt.mono {F G : Filter X} (h : AccPt x F) (hFG : F ≤ G) : AccPt x G :=
NeBot.mono h (inf_le_inf_left _ hFG)
#align acc_pt.mono AccPt.mono
theorem interior_eq_nhds' : interior s = { x | s ∈ 𝓝 x } :=
Set.ext fun x => by simp only [mem_interior, mem_nhds_iff, mem_setOf_eq]
#align interior_eq_nhds' interior_eq_nhds'
theorem interior_eq_nhds : interior s = { x | 𝓝 x ≤ 𝓟 s } :=
interior_eq_nhds'.trans <| by simp only [le_principal_iff]
#align interior_eq_nhds interior_eq_nhds
@[simp]
theorem interior_mem_nhds : interior s ∈ 𝓝 x ↔ s ∈ 𝓝 x :=
⟨fun h => mem_of_superset h interior_subset, fun h =>
IsOpen.mem_nhds isOpen_interior (mem_interior_iff_mem_nhds.2 h)⟩
#align interior_mem_nhds interior_mem_nhds
theorem interior_setOf_eq {p : X → Prop} : interior { x | p x } = { x | ∀ᶠ y in 𝓝 x, p y } :=
interior_eq_nhds'
#align interior_set_of_eq interior_setOf_eq
theorem isOpen_setOf_eventually_nhds {p : X → Prop} : IsOpen { x | ∀ᶠ y in 𝓝 x, p y } := by
simp only [← interior_setOf_eq, isOpen_interior]
#align is_open_set_of_eventually_nhds isOpen_setOf_eventually_nhds
theorem subset_interior_iff_nhds {V : Set X} : s ⊆ interior V ↔ ∀ x ∈ s, V ∈ 𝓝 x := by
simp_rw [subset_def, mem_interior_iff_mem_nhds]
#align subset_interior_iff_nhds subset_interior_iff_nhds
theorem isOpen_iff_nhds : IsOpen s ↔ ∀ x ∈ s, 𝓝 x ≤ 𝓟 s :=
calc
IsOpen s ↔ s ⊆ interior s := subset_interior_iff_isOpen.symm
_ ↔ ∀ x ∈ s, 𝓝 x ≤ 𝓟 s := by simp_rw [interior_eq_nhds, subset_def, mem_setOf]
#align is_open_iff_nhds isOpen_iff_nhds
theorem TopologicalSpace.ext_iff_nhds {t t' : TopologicalSpace X} :
t = t' ↔ ∀ x, @nhds _ t x = @nhds _ t' x :=
⟨fun H x ↦ congrFun (congrArg _ H) _, fun H ↦ by ext; simp_rw [@isOpen_iff_nhds _ _ _, H]⟩
alias ⟨_, TopologicalSpace.ext_nhds⟩ := TopologicalSpace.ext_iff_nhds
theorem isOpen_iff_mem_nhds : IsOpen s ↔ ∀ x ∈ s, s ∈ 𝓝 x :=
isOpen_iff_nhds.trans <| forall_congr' fun _ => imp_congr_right fun _ => le_principal_iff
#align is_open_iff_mem_nhds isOpen_iff_mem_nhds
theorem isOpen_iff_eventually : IsOpen s ↔ ∀ x, x ∈ s → ∀ᶠ y in 𝓝 x, y ∈ s :=
isOpen_iff_mem_nhds
#align is_open_iff_eventually isOpen_iff_eventually
theorem isOpen_iff_ultrafilter :
IsOpen s ↔ ∀ x ∈ s, ∀ (l : Ultrafilter X), ↑l ≤ 𝓝 x → s ∈ l := by
simp_rw [isOpen_iff_mem_nhds, ← mem_iff_ultrafilter]
#align is_open_iff_ultrafilter isOpen_iff_ultrafilter
theorem isOpen_singleton_iff_nhds_eq_pure (x : X) : IsOpen ({x} : Set X) ↔ 𝓝 x = pure x := by
constructor
· intro h
apply le_antisymm _ (pure_le_nhds x)
rw [le_pure_iff]
exact h.mem_nhds (mem_singleton x)
· intro h
simp [isOpen_iff_nhds, h]
#align is_open_singleton_iff_nhds_eq_pure isOpen_singleton_iff_nhds_eq_pure
theorem isOpen_singleton_iff_punctured_nhds (x : X) : IsOpen ({x} : Set X) ↔ 𝓝[≠] x = ⊥ := by
rw [isOpen_singleton_iff_nhds_eq_pure, nhdsWithin, ← mem_iff_inf_principal_compl, ← le_pure_iff,
nhds_neBot.le_pure_iff]
#align is_open_singleton_iff_punctured_nhds isOpen_singleton_iff_punctured_nhds
theorem mem_closure_iff_frequently : x ∈ closure s ↔ ∃ᶠ x in 𝓝 x, x ∈ s := by
rw [Filter.Frequently, Filter.Eventually, ← mem_interior_iff_mem_nhds,
closure_eq_compl_interior_compl, mem_compl_iff, compl_def]
#align mem_closure_iff_frequently mem_closure_iff_frequently
alias ⟨_, Filter.Frequently.mem_closure⟩ := mem_closure_iff_frequently
#align filter.frequently.mem_closure Filter.Frequently.mem_closure
theorem isClosed_iff_frequently : IsClosed s ↔ ∀ x, (∃ᶠ y in 𝓝 x, y ∈ s) → x ∈ s := by
rw [← closure_subset_iff_isClosed]
refine forall_congr' fun x => ?_
rw [mem_closure_iff_frequently]
#align is_closed_iff_frequently isClosed_iff_frequently
theorem isClosed_setOf_clusterPt {f : Filter X} : IsClosed { x | ClusterPt x f } := by
simp only [ClusterPt, inf_neBot_iff_frequently_left, setOf_forall, imp_iff_not_or]
refine isClosed_iInter fun p => IsClosed.union ?_ ?_ <;> apply isClosed_compl_iff.2
exacts [isOpen_setOf_eventually_nhds, isOpen_const]
#align is_closed_set_of_cluster_pt isClosed_setOf_clusterPt
theorem mem_closure_iff_clusterPt : x ∈ closure s ↔ ClusterPt x (𝓟 s) :=
mem_closure_iff_frequently.trans clusterPt_principal_iff_frequently.symm
#align mem_closure_iff_cluster_pt mem_closure_iff_clusterPt
theorem mem_closure_iff_nhds_ne_bot : x ∈ closure s ↔ 𝓝 x ⊓ 𝓟 s ≠ ⊥ :=
mem_closure_iff_clusterPt.trans neBot_iff
#align mem_closure_iff_nhds_ne_bot mem_closure_iff_nhds_ne_bot
@[deprecated (since := "2024-01-28")]
alias mem_closure_iff_nhds_neBot := mem_closure_iff_nhds_ne_bot
theorem mem_closure_iff_nhdsWithin_neBot : x ∈ closure s ↔ NeBot (𝓝[s] x) :=
mem_closure_iff_clusterPt
#align mem_closure_iff_nhds_within_ne_bot mem_closure_iff_nhdsWithin_neBot
lemma not_mem_closure_iff_nhdsWithin_eq_bot : x ∉ closure s ↔ 𝓝[s] x = ⊥ := by
rw [mem_closure_iff_nhdsWithin_neBot, not_neBot]
theorem dense_compl_singleton (x : X) [NeBot (𝓝[≠] x)] : Dense ({x}ᶜ : Set X) := by
intro y
rcases eq_or_ne y x with (rfl | hne)
· rwa [mem_closure_iff_nhdsWithin_neBot]
· exact subset_closure hne
#align dense_compl_singleton dense_compl_singleton
-- Porting note (#10618): was a `@[simp]` lemma but `simp` can prove it
theorem closure_compl_singleton (x : X) [NeBot (𝓝[≠] x)] : closure {x}ᶜ = (univ : Set X) :=
(dense_compl_singleton x).closure_eq
#align closure_compl_singleton closure_compl_singleton
@[simp]
theorem interior_singleton (x : X) [NeBot (𝓝[≠] x)] : interior {x} = (∅ : Set X) :=
interior_eq_empty_iff_dense_compl.2 (dense_compl_singleton x)
#align interior_singleton interior_singleton
theorem not_isOpen_singleton (x : X) [NeBot (𝓝[≠] x)] : ¬IsOpen ({x} : Set X) :=
dense_compl_singleton_iff_not_open.1 (dense_compl_singleton x)
#align not_is_open_singleton not_isOpen_singleton
theorem closure_eq_cluster_pts : closure s = { a | ClusterPt a (𝓟 s) } :=
Set.ext fun _ => mem_closure_iff_clusterPt
#align closure_eq_cluster_pts closure_eq_cluster_pts
theorem mem_closure_iff_nhds : x ∈ closure s ↔ ∀ t ∈ 𝓝 x, (t ∩ s).Nonempty :=
mem_closure_iff_clusterPt.trans clusterPt_principal_iff
#align mem_closure_iff_nhds mem_closure_iff_nhds
theorem mem_closure_iff_nhds' : x ∈ closure s ↔ ∀ t ∈ 𝓝 x, ∃ y : s, ↑y ∈ t := by
simp only [mem_closure_iff_nhds, Set.inter_nonempty_iff_exists_right, SetCoe.exists, exists_prop]
#align mem_closure_iff_nhds' mem_closure_iff_nhds'
theorem mem_closure_iff_comap_neBot :
x ∈ closure s ↔ NeBot (comap ((↑) : s → X) (𝓝 x)) := by
simp_rw [mem_closure_iff_nhds, comap_neBot_iff, Set.inter_nonempty_iff_exists_right,
SetCoe.exists, exists_prop]
#align mem_closure_iff_comap_ne_bot mem_closure_iff_comap_neBot
theorem mem_closure_iff_nhds_basis' {p : ι → Prop} {s : ι → Set X} (h : (𝓝 x).HasBasis p s) :
x ∈ closure t ↔ ∀ i, p i → (s i ∩ t).Nonempty :=
mem_closure_iff_clusterPt.trans <|
(h.clusterPt_iff (hasBasis_principal _)).trans <| by simp only [exists_prop, forall_const]
#align mem_closure_iff_nhds_basis' mem_closure_iff_nhds_basis'
theorem mem_closure_iff_nhds_basis {p : ι → Prop} {s : ι → Set X} (h : (𝓝 x).HasBasis p s) :
x ∈ closure t ↔ ∀ i, p i → ∃ y ∈ t, y ∈ s i :=
(mem_closure_iff_nhds_basis' h).trans <| by
simp only [Set.Nonempty, mem_inter_iff, exists_prop, and_comm]
#align mem_closure_iff_nhds_basis mem_closure_iff_nhds_basis
theorem clusterPt_iff_forall_mem_closure {F : Filter X} :
ClusterPt x F ↔ ∀ s ∈ F, x ∈ closure s := by
simp_rw [ClusterPt, inf_neBot_iff, mem_closure_iff_nhds]
rw [forall₂_swap]
theorem clusterPt_iff_lift'_closure {F : Filter X} :
ClusterPt x F ↔ pure x ≤ (F.lift' closure) := by
simp_rw [clusterPt_iff_forall_mem_closure,
(hasBasis_pure _).le_basis_iff F.basis_sets.lift'_closure, id, singleton_subset_iff, true_and,
exists_const]
theorem clusterPt_iff_lift'_closure' {F : Filter X} :
ClusterPt x F ↔ (F.lift' closure ⊓ pure x).NeBot := by
rw [clusterPt_iff_lift'_closure, ← Ultrafilter.coe_pure, inf_comm, Ultrafilter.inf_neBot_iff]
@[simp]
theorem clusterPt_lift'_closure_iff {F : Filter X} :
ClusterPt x (F.lift' closure) ↔ ClusterPt x F := by
simp [clusterPt_iff_lift'_closure, lift'_lift'_assoc (monotone_closure X) (monotone_closure X)]
| Mathlib/Topology/Basic.lean | 1,332 | 1,334 | theorem mem_closure_iff_ultrafilter :
x ∈ closure s ↔ ∃ u : Ultrafilter X, s ∈ u ∧ ↑u ≤ 𝓝 x := by |
simp [closure_eq_cluster_pts, ClusterPt, ← exists_ultrafilter_iff, and_comm]
|
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Interval Pointwise
variable {α : Type*}
namespace Set
section LinearOrderedField
variable [LinearOrderedField α] {a : α}
@[simp]
theorem preimage_mul_const_Iio (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Iio a = Iio (a / c) :=
ext fun _x => (lt_div_iff h).symm
#align set.preimage_mul_const_Iio Set.preimage_mul_const_Iio
@[simp]
theorem preimage_mul_const_Ioi (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioi a = Ioi (a / c) :=
ext fun _x => (div_lt_iff h).symm
#align set.preimage_mul_const_Ioi Set.preimage_mul_const_Ioi
@[simp]
theorem preimage_mul_const_Iic (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Iic a = Iic (a / c) :=
ext fun _x => (le_div_iff h).symm
#align set.preimage_mul_const_Iic Set.preimage_mul_const_Iic
@[simp]
theorem preimage_mul_const_Ici (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ici a = Ici (a / c) :=
ext fun _x => (div_le_iff h).symm
#align set.preimage_mul_const_Ici Set.preimage_mul_const_Ici
@[simp]
theorem preimage_mul_const_Ioo (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioo a b = Ioo (a / c) (b / c) := by simp [← Ioi_inter_Iio, h]
#align set.preimage_mul_const_Ioo Set.preimage_mul_const_Ioo
@[simp]
| Mathlib/Data/Set/Pointwise/Interval.lean | 624 | 625 | theorem preimage_mul_const_Ioc (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioc a b = Ioc (a / c) (b / c) := by | simp [← Ioi_inter_Iic, h]
|
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Algebra.Polynomial.RingDivision
#align_import data.polynomial.mirror from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
namespace Polynomial
open Polynomial
section Semiring
variable {R : Type*} [Semiring R] (p q : R[X])
noncomputable def mirror :=
p.reverse * X ^ p.natTrailingDegree
#align polynomial.mirror Polynomial.mirror
@[simp]
theorem mirror_zero : (0 : R[X]).mirror = 0 := by simp [mirror]
#align polynomial.mirror_zero Polynomial.mirror_zero
theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a := by
classical
by_cases ha : a = 0
· rw [ha, monomial_zero_right, mirror_zero]
· rw [mirror, reverse, natDegree_monomial n a, if_neg ha, natTrailingDegree_monomial ha, ←
C_mul_X_pow_eq_monomial, reflect_C_mul_X_pow, revAt_le (le_refl n), tsub_self, pow_zero,
mul_one]
#align polynomial.mirror_monomial Polynomial.mirror_monomial
theorem mirror_C (a : R) : (C a).mirror = C a :=
mirror_monomial 0 a
set_option linter.uppercaseLean3 false in
#align polynomial.mirror_C Polynomial.mirror_C
theorem mirror_X : X.mirror = (X : R[X]) :=
mirror_monomial 1 (1 : R)
set_option linter.uppercaseLean3 false in
#align polynomial.mirror_X Polynomial.mirror_X
theorem mirror_natDegree : p.mirror.natDegree = p.natDegree := by
by_cases hp : p = 0
· rw [hp, mirror_zero]
nontriviality R
rw [mirror, natDegree_mul', reverse_natDegree, natDegree_X_pow,
tsub_add_cancel_of_le p.natTrailingDegree_le_natDegree]
rwa [leadingCoeff_X_pow, mul_one, reverse_leadingCoeff, Ne, trailingCoeff_eq_zero]
#align polynomial.mirror_nat_degree Polynomial.mirror_natDegree
theorem mirror_natTrailingDegree : p.mirror.natTrailingDegree = p.natTrailingDegree := by
by_cases hp : p = 0
· rw [hp, mirror_zero]
· rw [mirror, natTrailingDegree_mul_X_pow ((mt reverse_eq_zero.mp) hp),
natTrailingDegree_reverse, zero_add]
#align polynomial.mirror_nat_trailing_degree Polynomial.mirror_natTrailingDegree
| Mathlib/Algebra/Polynomial/Mirror.lean | 82 | 97 | theorem coeff_mirror (n : ℕ) :
p.mirror.coeff n = p.coeff (revAt (p.natDegree + p.natTrailingDegree) n) := by |
by_cases h2 : p.natDegree < n
· rw [coeff_eq_zero_of_natDegree_lt (by rwa [mirror_natDegree])]
by_cases h1 : n ≤ p.natDegree + p.natTrailingDegree
· rw [revAt_le h1, coeff_eq_zero_of_lt_natTrailingDegree]
exact (tsub_lt_iff_left h1).mpr (Nat.add_lt_add_right h2 _)
· rw [← revAtFun_eq, revAtFun, if_neg h1, coeff_eq_zero_of_natDegree_lt h2]
rw [not_lt] at h2
rw [revAt_le (h2.trans (Nat.le_add_right _ _))]
by_cases h3 : p.natTrailingDegree ≤ n
· rw [← tsub_add_eq_add_tsub h2, ← tsub_tsub_assoc h2 h3, mirror, coeff_mul_X_pow', if_pos h3,
coeff_reverse, revAt_le (tsub_le_self.trans h2)]
rw [not_le] at h3
rw [coeff_eq_zero_of_natDegree_lt (lt_tsub_iff_right.mpr (Nat.add_lt_add_left h3 _))]
exact coeff_eq_zero_of_lt_natTrailingDegree (by rwa [mirror_natTrailingDegree])
|
import Mathlib.Algebra.GroupPower.IterateHom
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Order.Iterate
import Mathlib.Order.SemiconjSup
import Mathlib.Tactic.Monotonicity
import Mathlib.Topology.Order.MonotoneContinuity
#align_import dynamics.circle.rotation_number.translation_number from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open scoped Classical
open Filter Set Int Topology
open Function hiding Commute
structure CircleDeg1Lift extends ℝ →o ℝ : Type where
map_add_one' : ∀ x, toFun (x + 1) = toFun x + 1
#align circle_deg1_lift CircleDeg1Lift
namespace CircleDeg1Lift
instance : FunLike CircleDeg1Lift ℝ ℝ where
coe f := f.toFun
coe_injective' | ⟨⟨_, _⟩, _⟩, ⟨⟨_, _⟩, _⟩, rfl => rfl
instance : OrderHomClass CircleDeg1Lift ℝ ℝ where
map_rel f _ _ h := f.monotone' h
@[simp] theorem coe_mk (f h) : ⇑(mk f h) = f := rfl
#align circle_deg1_lift.coe_mk CircleDeg1Lift.coe_mk
variable (f g : CircleDeg1Lift)
@[simp] theorem coe_toOrderHom : ⇑f.toOrderHom = f := rfl
protected theorem monotone : Monotone f := f.monotone'
#align circle_deg1_lift.monotone CircleDeg1Lift.monotone
@[mono] theorem mono {x y} (h : x ≤ y) : f x ≤ f y := f.monotone h
#align circle_deg1_lift.mono CircleDeg1Lift.mono
theorem strictMono_iff_injective : StrictMono f ↔ Injective f :=
f.monotone.strictMono_iff_injective
#align circle_deg1_lift.strict_mono_iff_injective CircleDeg1Lift.strictMono_iff_injective
@[simp]
theorem map_add_one : ∀ x, f (x + 1) = f x + 1 :=
f.map_add_one'
#align circle_deg1_lift.map_add_one CircleDeg1Lift.map_add_one
@[simp]
theorem map_one_add (x : ℝ) : f (1 + x) = 1 + f x := by rw [add_comm, map_add_one, add_comm 1]
#align circle_deg1_lift.map_one_add CircleDeg1Lift.map_one_add
#noalign circle_deg1_lift.coe_inj -- Use `DFunLike.coe_inj`
@[ext]
theorem ext ⦃f g : CircleDeg1Lift⦄ (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext f g h
#align circle_deg1_lift.ext CircleDeg1Lift.ext
theorem ext_iff {f g : CircleDeg1Lift} : f = g ↔ ∀ x, f x = g x :=
DFunLike.ext_iff
#align circle_deg1_lift.ext_iff CircleDeg1Lift.ext_iff
instance : Monoid CircleDeg1Lift where
mul f g :=
{ toOrderHom := f.1.comp g.1
map_add_one' := fun x => by simp [map_add_one] }
one := ⟨.id, fun _ => rfl⟩
mul_one f := rfl
one_mul f := rfl
mul_assoc f₁ f₂ f₃ := DFunLike.coe_injective rfl
instance : Inhabited CircleDeg1Lift := ⟨1⟩
@[simp]
theorem coe_mul : ⇑(f * g) = f ∘ g :=
rfl
#align circle_deg1_lift.coe_mul CircleDeg1Lift.coe_mul
theorem mul_apply (x) : (f * g) x = f (g x) :=
rfl
#align circle_deg1_lift.mul_apply CircleDeg1Lift.mul_apply
@[simp]
theorem coe_one : ⇑(1 : CircleDeg1Lift) = id :=
rfl
#align circle_deg1_lift.coe_one CircleDeg1Lift.coe_one
instance unitsHasCoeToFun : CoeFun CircleDeg1Liftˣ fun _ => ℝ → ℝ :=
⟨fun f => ⇑(f : CircleDeg1Lift)⟩
#align circle_deg1_lift.units_has_coe_to_fun CircleDeg1Lift.unitsHasCoeToFun
#noalign circle_deg1_lift.units_coe -- now LHS = RHS
@[simp]
theorem units_inv_apply_apply (f : CircleDeg1Liftˣ) (x : ℝ) :
(f⁻¹ : CircleDeg1Liftˣ) (f x) = x := by simp only [← mul_apply, f.inv_mul, coe_one, id]
#align circle_deg1_lift.units_inv_apply_apply CircleDeg1Lift.units_inv_apply_apply
@[simp]
theorem units_apply_inv_apply (f : CircleDeg1Liftˣ) (x : ℝ) :
f ((f⁻¹ : CircleDeg1Liftˣ) x) = x := by simp only [← mul_apply, f.mul_inv, coe_one, id]
#align circle_deg1_lift.units_apply_inv_apply CircleDeg1Lift.units_apply_inv_apply
def toOrderIso : CircleDeg1Liftˣ →* ℝ ≃o ℝ where
toFun f :=
{ toFun := f
invFun := ⇑f⁻¹
left_inv := units_inv_apply_apply f
right_inv := units_apply_inv_apply f
map_rel_iff' := ⟨fun h => by simpa using mono (↑f⁻¹) h, mono f⟩ }
map_one' := rfl
map_mul' f g := rfl
#align circle_deg1_lift.to_order_iso CircleDeg1Lift.toOrderIso
@[simp]
theorem coe_toOrderIso (f : CircleDeg1Liftˣ) : ⇑(toOrderIso f) = f :=
rfl
#align circle_deg1_lift.coe_to_order_iso CircleDeg1Lift.coe_toOrderIso
@[simp]
theorem coe_toOrderIso_symm (f : CircleDeg1Liftˣ) :
⇑(toOrderIso f).symm = (f⁻¹ : CircleDeg1Liftˣ) :=
rfl
#align circle_deg1_lift.coe_to_order_iso_symm CircleDeg1Lift.coe_toOrderIso_symm
@[simp]
theorem coe_toOrderIso_inv (f : CircleDeg1Liftˣ) : ⇑(toOrderIso f)⁻¹ = (f⁻¹ : CircleDeg1Liftˣ) :=
rfl
#align circle_deg1_lift.coe_to_order_iso_inv CircleDeg1Lift.coe_toOrderIso_inv
theorem isUnit_iff_bijective {f : CircleDeg1Lift} : IsUnit f ↔ Bijective f :=
⟨fun ⟨u, h⟩ => h ▸ (toOrderIso u).bijective, fun h =>
Units.isUnit
{ val := f
inv :=
{ toFun := (Equiv.ofBijective f h).symm
monotone' := fun x y hxy =>
(f.strictMono_iff_injective.2 h.1).le_iff_le.1
(by simp only [Equiv.ofBijective_apply_symm_apply f h, hxy])
map_add_one' := fun x =>
h.1 <| by simp only [Equiv.ofBijective_apply_symm_apply f, f.map_add_one] }
val_inv := ext <| Equiv.ofBijective_apply_symm_apply f h
inv_val := ext <| Equiv.ofBijective_symm_apply_apply f h }⟩
#align circle_deg1_lift.is_unit_iff_bijective CircleDeg1Lift.isUnit_iff_bijective
theorem coe_pow : ∀ n : ℕ, ⇑(f ^ n) = f^[n]
| 0 => rfl
| n + 1 => by
ext x
simp [coe_pow n, pow_succ]
#align circle_deg1_lift.coe_pow CircleDeg1Lift.coe_pow
theorem semiconjBy_iff_semiconj {f g₁ g₂ : CircleDeg1Lift} :
SemiconjBy f g₁ g₂ ↔ Semiconj f g₁ g₂ :=
ext_iff
#align circle_deg1_lift.semiconj_by_iff_semiconj CircleDeg1Lift.semiconjBy_iff_semiconj
theorem commute_iff_commute {f g : CircleDeg1Lift} : Commute f g ↔ Function.Commute f g :=
ext_iff
#align circle_deg1_lift.commute_iff_commute CircleDeg1Lift.commute_iff_commute
def translate : Multiplicative ℝ →* CircleDeg1Liftˣ := MonoidHom.toHomUnits <|
{ toFun := fun x =>
⟨⟨fun y => Multiplicative.toAdd x + y, fun _ _ h => add_le_add_left h _⟩, fun _ =>
(add_assoc _ _ _).symm⟩
map_one' := ext <| zero_add
map_mul' := fun _ _ => ext <| add_assoc _ _ }
#align circle_deg1_lift.translate CircleDeg1Lift.translate
@[simp]
theorem translate_apply (x y : ℝ) : translate (Multiplicative.ofAdd x) y = x + y :=
rfl
#align circle_deg1_lift.translate_apply CircleDeg1Lift.translate_apply
@[simp]
theorem translate_inv_apply (x y : ℝ) : (translate <| Multiplicative.ofAdd x)⁻¹ y = -x + y :=
rfl
#align circle_deg1_lift.translate_inv_apply CircleDeg1Lift.translate_inv_apply
@[simp]
theorem translate_zpow (x : ℝ) (n : ℤ) :
translate (Multiplicative.ofAdd x) ^ n = translate (Multiplicative.ofAdd <| ↑n * x) := by
simp only [← zsmul_eq_mul, ofAdd_zsmul, MonoidHom.map_zpow]
#align circle_deg1_lift.translate_zpow CircleDeg1Lift.translate_zpow
@[simp]
theorem translate_pow (x : ℝ) (n : ℕ) :
translate (Multiplicative.ofAdd x) ^ n = translate (Multiplicative.ofAdd <| ↑n * x) :=
translate_zpow x n
#align circle_deg1_lift.translate_pow CircleDeg1Lift.translate_pow
@[simp]
theorem translate_iterate (x : ℝ) (n : ℕ) :
(translate (Multiplicative.ofAdd x))^[n] = translate (Multiplicative.ofAdd <| ↑n * x) := by
rw [← coe_pow, ← Units.val_pow_eq_pow_val, translate_pow]
#align circle_deg1_lift.translate_iterate CircleDeg1Lift.translate_iterate
theorem commute_nat_add (n : ℕ) : Function.Commute f (n + ·) := by
simpa only [nsmul_one, add_left_iterate] using Function.Commute.iterate_right f.map_one_add n
#align circle_deg1_lift.commute_nat_add CircleDeg1Lift.commute_nat_add
theorem commute_add_nat (n : ℕ) : Function.Commute f (· + n) := by
simp only [add_comm _ (n : ℝ), f.commute_nat_add n]
#align circle_deg1_lift.commute_add_nat CircleDeg1Lift.commute_add_nat
theorem commute_sub_nat (n : ℕ) : Function.Commute f (· - n) := by
simpa only [sub_eq_add_neg] using
(f.commute_add_nat n).inverses_right (Equiv.addRight _).right_inv (Equiv.addRight _).left_inv
#align circle_deg1_lift.commute_sub_nat CircleDeg1Lift.commute_sub_nat
theorem commute_add_int : ∀ n : ℤ, Function.Commute f (· + n)
| (n : ℕ) => f.commute_add_nat n
| -[n+1] => by simpa [sub_eq_add_neg] using f.commute_sub_nat (n + 1)
#align circle_deg1_lift.commute_add_int CircleDeg1Lift.commute_add_int
theorem commute_int_add (n : ℤ) : Function.Commute f (n + ·) := by
simpa only [add_comm _ (n : ℝ)] using f.commute_add_int n
#align circle_deg1_lift.commute_int_add CircleDeg1Lift.commute_int_add
theorem commute_sub_int (n : ℤ) : Function.Commute f (· - n) := by
simpa only [sub_eq_add_neg] using
(f.commute_add_int n).inverses_right (Equiv.addRight _).right_inv (Equiv.addRight _).left_inv
#align circle_deg1_lift.commute_sub_int CircleDeg1Lift.commute_sub_int
@[simp]
theorem map_int_add (m : ℤ) (x : ℝ) : f (m + x) = m + f x :=
f.commute_int_add m x
#align circle_deg1_lift.map_int_add CircleDeg1Lift.map_int_add
@[simp]
theorem map_add_int (x : ℝ) (m : ℤ) : f (x + m) = f x + m :=
f.commute_add_int m x
#align circle_deg1_lift.map_add_int CircleDeg1Lift.map_add_int
@[simp]
theorem map_sub_int (x : ℝ) (n : ℤ) : f (x - n) = f x - n :=
f.commute_sub_int n x
#align circle_deg1_lift.map_sub_int CircleDeg1Lift.map_sub_int
@[simp]
theorem map_add_nat (x : ℝ) (n : ℕ) : f (x + n) = f x + n :=
f.map_add_int x n
#align circle_deg1_lift.map_add_nat CircleDeg1Lift.map_add_nat
@[simp]
theorem map_nat_add (n : ℕ) (x : ℝ) : f (n + x) = n + f x :=
f.map_int_add n x
#align circle_deg1_lift.map_nat_add CircleDeg1Lift.map_nat_add
@[simp]
theorem map_sub_nat (x : ℝ) (n : ℕ) : f (x - n) = f x - n :=
f.map_sub_int x n
#align circle_deg1_lift.map_sub_nat CircleDeg1Lift.map_sub_nat
theorem map_int_of_map_zero (n : ℤ) : f n = f 0 + n := by rw [← f.map_add_int, zero_add]
#align circle_deg1_lift.map_int_of_map_zero CircleDeg1Lift.map_int_of_map_zero
@[simp]
theorem map_fract_sub_fract_eq (x : ℝ) : f (fract x) - fract x = f x - x := by
rw [Int.fract, f.map_sub_int, sub_sub_sub_cancel_right]
#align circle_deg1_lift.map_fract_sub_fract_eq CircleDeg1Lift.map_fract_sub_fract_eq
noncomputable instance : Lattice CircleDeg1Lift where
sup f g :=
{ toFun := fun x => max (f x) (g x)
monotone' := fun x y h => max_le_max (f.mono h) (g.mono h)
-- TODO: generalize to `Monotone.max`
map_add_one' := fun x => by simp [max_add_add_right] }
le f g := ∀ x, f x ≤ g x
le_refl f x := le_refl (f x)
le_trans f₁ f₂ f₃ h₁₂ h₂₃ x := le_trans (h₁₂ x) (h₂₃ x)
le_antisymm f₁ f₂ h₁₂ h₂₁ := ext fun x => le_antisymm (h₁₂ x) (h₂₁ x)
le_sup_left f g x := le_max_left (f x) (g x)
le_sup_right f g x := le_max_right (f x) (g x)
sup_le f₁ f₂ f₃ h₁ h₂ x := max_le (h₁ x) (h₂ x)
inf f g :=
{ toFun := fun x => min (f x) (g x)
monotone' := fun x y h => min_le_min (f.mono h) (g.mono h)
map_add_one' := fun x => by simp [min_add_add_right] }
inf_le_left f g x := min_le_left (f x) (g x)
inf_le_right f g x := min_le_right (f x) (g x)
le_inf f₁ f₂ f₃ h₂ h₃ x := le_min (h₂ x) (h₃ x)
@[simp]
theorem sup_apply (x : ℝ) : (f ⊔ g) x = max (f x) (g x) :=
rfl
#align circle_deg1_lift.sup_apply CircleDeg1Lift.sup_apply
@[simp]
theorem inf_apply (x : ℝ) : (f ⊓ g) x = min (f x) (g x) :=
rfl
#align circle_deg1_lift.inf_apply CircleDeg1Lift.inf_apply
theorem iterate_monotone (n : ℕ) : Monotone fun f : CircleDeg1Lift => f^[n] := fun f _ h =>
f.monotone.iterate_le_of_le h _
#align circle_deg1_lift.iterate_monotone CircleDeg1Lift.iterate_monotone
theorem iterate_mono {f g : CircleDeg1Lift} (h : f ≤ g) (n : ℕ) : f^[n] ≤ g^[n] :=
iterate_monotone n h
#align circle_deg1_lift.iterate_mono CircleDeg1Lift.iterate_mono
theorem pow_mono {f g : CircleDeg1Lift} (h : f ≤ g) (n : ℕ) : f ^ n ≤ g ^ n := fun x => by
simp only [coe_pow, iterate_mono h n x]
#align circle_deg1_lift.pow_mono CircleDeg1Lift.pow_mono
theorem pow_monotone (n : ℕ) : Monotone fun f : CircleDeg1Lift => f ^ n := fun _ _ h => pow_mono h n
#align circle_deg1_lift.pow_monotone CircleDeg1Lift.pow_monotone
theorem map_le_of_map_zero (x : ℝ) : f x ≤ f 0 + ⌈x⌉ :=
calc
f x ≤ f ⌈x⌉ := f.monotone <| le_ceil _
_ = f 0 + ⌈x⌉ := f.map_int_of_map_zero _
#align circle_deg1_lift.map_le_of_map_zero CircleDeg1Lift.map_le_of_map_zero
theorem map_map_zero_le : f (g 0) ≤ f 0 + ⌈g 0⌉ :=
f.map_le_of_map_zero (g 0)
#align circle_deg1_lift.map_map_zero_le CircleDeg1Lift.map_map_zero_le
theorem floor_map_map_zero_le : ⌊f (g 0)⌋ ≤ ⌊f 0⌋ + ⌈g 0⌉ :=
calc
⌊f (g 0)⌋ ≤ ⌊f 0 + ⌈g 0⌉⌋ := floor_mono <| f.map_map_zero_le g
_ = ⌊f 0⌋ + ⌈g 0⌉ := floor_add_int _ _
#align circle_deg1_lift.floor_map_map_zero_le CircleDeg1Lift.floor_map_map_zero_le
theorem ceil_map_map_zero_le : ⌈f (g 0)⌉ ≤ ⌈f 0⌉ + ⌈g 0⌉ :=
calc
⌈f (g 0)⌉ ≤ ⌈f 0 + ⌈g 0⌉⌉ := ceil_mono <| f.map_map_zero_le g
_ = ⌈f 0⌉ + ⌈g 0⌉ := ceil_add_int _ _
#align circle_deg1_lift.ceil_map_map_zero_le CircleDeg1Lift.ceil_map_map_zero_le
theorem map_map_zero_lt : f (g 0) < f 0 + g 0 + 1 :=
calc
f (g 0) ≤ f 0 + ⌈g 0⌉ := f.map_map_zero_le g
_ < f 0 + (g 0 + 1) := add_lt_add_left (ceil_lt_add_one _) _
_ = f 0 + g 0 + 1 := (add_assoc _ _ _).symm
#align circle_deg1_lift.map_map_zero_lt CircleDeg1Lift.map_map_zero_lt
theorem le_map_of_map_zero (x : ℝ) : f 0 + ⌊x⌋ ≤ f x :=
calc
f 0 + ⌊x⌋ = f ⌊x⌋ := (f.map_int_of_map_zero _).symm
_ ≤ f x := f.monotone <| floor_le _
#align circle_deg1_lift.le_map_of_map_zero CircleDeg1Lift.le_map_of_map_zero
theorem le_map_map_zero : f 0 + ⌊g 0⌋ ≤ f (g 0) :=
f.le_map_of_map_zero (g 0)
#align circle_deg1_lift.le_map_map_zero CircleDeg1Lift.le_map_map_zero
theorem le_floor_map_map_zero : ⌊f 0⌋ + ⌊g 0⌋ ≤ ⌊f (g 0)⌋ :=
calc
⌊f 0⌋ + ⌊g 0⌋ = ⌊f 0 + ⌊g 0⌋⌋ := (floor_add_int _ _).symm
_ ≤ ⌊f (g 0)⌋ := floor_mono <| f.le_map_map_zero g
#align circle_deg1_lift.le_floor_map_map_zero CircleDeg1Lift.le_floor_map_map_zero
theorem le_ceil_map_map_zero : ⌈f 0⌉ + ⌊g 0⌋ ≤ ⌈(f * g) 0⌉ :=
calc
⌈f 0⌉ + ⌊g 0⌋ = ⌈f 0 + ⌊g 0⌋⌉ := (ceil_add_int _ _).symm
_ ≤ ⌈f (g 0)⌉ := ceil_mono <| f.le_map_map_zero g
#align circle_deg1_lift.le_ceil_map_map_zero CircleDeg1Lift.le_ceil_map_map_zero
theorem lt_map_map_zero : f 0 + g 0 - 1 < f (g 0) :=
calc
f 0 + g 0 - 1 = f 0 + (g 0 - 1) := add_sub_assoc _ _ _
_ < f 0 + ⌊g 0⌋ := add_lt_add_left (sub_one_lt_floor _) _
_ ≤ f (g 0) := f.le_map_map_zero g
#align circle_deg1_lift.lt_map_map_zero CircleDeg1Lift.lt_map_map_zero
theorem dist_map_map_zero_lt : dist (f 0 + g 0) (f (g 0)) < 1 := by
rw [dist_comm, Real.dist_eq, abs_lt, lt_sub_iff_add_lt', sub_lt_iff_lt_add', ← sub_eq_add_neg]
exact ⟨f.lt_map_map_zero g, f.map_map_zero_lt g⟩
#align circle_deg1_lift.dist_map_map_zero_lt CircleDeg1Lift.dist_map_map_zero_lt
theorem dist_map_zero_lt_of_semiconj {f g₁ g₂ : CircleDeg1Lift} (h : Function.Semiconj f g₁ g₂) :
dist (g₁ 0) (g₂ 0) < 2 :=
calc
dist (g₁ 0) (g₂ 0) ≤ dist (g₁ 0) (f (g₁ 0) - f 0) + dist _ (g₂ 0) := dist_triangle _ _ _
_ = dist (f 0 + g₁ 0) (f (g₁ 0)) + dist (g₂ 0 + f 0) (g₂ (f 0)) := by
simp only [h.eq, Real.dist_eq, sub_sub, add_comm (f 0), sub_sub_eq_add_sub,
abs_sub_comm (g₂ (f 0))]
_ < 1 + 1 := add_lt_add (f.dist_map_map_zero_lt g₁) (g₂.dist_map_map_zero_lt f)
_ = 2 := one_add_one_eq_two
#align circle_deg1_lift.dist_map_zero_lt_of_semiconj CircleDeg1Lift.dist_map_zero_lt_of_semiconj
theorem dist_map_zero_lt_of_semiconjBy {f g₁ g₂ : CircleDeg1Lift} (h : SemiconjBy f g₁ g₂) :
dist (g₁ 0) (g₂ 0) < 2 :=
dist_map_zero_lt_of_semiconj <| semiconjBy_iff_semiconj.1 h
#align circle_deg1_lift.dist_map_zero_lt_of_semiconj_by CircleDeg1Lift.dist_map_zero_lt_of_semiconjBy
protected theorem tendsto_atBot : Tendsto f atBot atBot :=
tendsto_atBot_mono f.map_le_of_map_zero <| tendsto_atBot_add_const_left _ _ <|
(tendsto_atBot_mono fun x => (ceil_lt_add_one x).le) <|
tendsto_atBot_add_const_right _ _ tendsto_id
#align circle_deg1_lift.tendsto_at_bot CircleDeg1Lift.tendsto_atBot
protected theorem tendsto_atTop : Tendsto f atTop atTop :=
tendsto_atTop_mono f.le_map_of_map_zero <| tendsto_atTop_add_const_left _ _ <|
(tendsto_atTop_mono fun x => (sub_one_lt_floor x).le) <| by
simpa [sub_eq_add_neg] using tendsto_atTop_add_const_right _ _ tendsto_id
#align circle_deg1_lift.tendsto_at_top CircleDeg1Lift.tendsto_atTop
theorem continuous_iff_surjective : Continuous f ↔ Function.Surjective f :=
⟨fun h => h.surjective f.tendsto_atTop f.tendsto_atBot, f.monotone.continuous_of_surjective⟩
#align circle_deg1_lift.continuous_iff_surjective CircleDeg1Lift.continuous_iff_surjective
theorem iterate_le_of_map_le_add_int {x : ℝ} {m : ℤ} (h : f x ≤ x + m) (n : ℕ) :
f^[n] x ≤ x + n * m := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).iterate_le_of_map_le f.monotone (monotone_id.add_const (m : ℝ)) h n
#align circle_deg1_lift.iterate_le_of_map_le_add_int CircleDeg1Lift.iterate_le_of_map_le_add_int
theorem le_iterate_of_add_int_le_map {x : ℝ} {m : ℤ} (h : x + m ≤ f x) (n : ℕ) :
x + n * m ≤ f^[n] x := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).symm.iterate_le_of_map_le (monotone_id.add_const (m : ℝ)) f.monotone h n
#align circle_deg1_lift.le_iterate_of_add_int_le_map CircleDeg1Lift.le_iterate_of_add_int_le_map
theorem iterate_eq_of_map_eq_add_int {x : ℝ} {m : ℤ} (h : f x = x + m) (n : ℕ) :
f^[n] x = x + n * m := by
simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_eq_of_map_eq n h
#align circle_deg1_lift.iterate_eq_of_map_eq_add_int CircleDeg1Lift.iterate_eq_of_map_eq_add_int
theorem iterate_pos_le_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) :
f^[n] x ≤ x + n * m ↔ f x ≤ x + m := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).iterate_pos_le_iff_map_le f.monotone (strictMono_id.add_const (m : ℝ)) hn
#align circle_deg1_lift.iterate_pos_le_iff CircleDeg1Lift.iterate_pos_le_iff
theorem iterate_pos_lt_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) :
f^[n] x < x + n * m ↔ f x < x + m := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).iterate_pos_lt_iff_map_lt f.monotone (strictMono_id.add_const (m : ℝ)) hn
#align circle_deg1_lift.iterate_pos_lt_iff CircleDeg1Lift.iterate_pos_lt_iff
| Mathlib/Dynamics/Circle/RotationNumber/TranslationNumber.lean | 600 | 603 | theorem iterate_pos_eq_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) :
f^[n] x = x + n * m ↔ f x = x + m := by |
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).iterate_pos_eq_iff_map_eq f.monotone (strictMono_id.add_const (m : ℝ)) hn
|
import Mathlib.NumberTheory.FLT.Basic
import Mathlib.NumberTheory.PythagoreanTriples
import Mathlib.RingTheory.Coprime.Lemmas
import Mathlib.Tactic.LinearCombination
#align_import number_theory.fermat4 from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
noncomputable section
open scoped Classical
def Fermat42 (a b c : ℤ) : Prop :=
a ≠ 0 ∧ b ≠ 0 ∧ a ^ 4 + b ^ 4 = c ^ 2
#align fermat_42 Fermat42
namespace Fermat42
theorem comm {a b c : ℤ} : Fermat42 a b c ↔ Fermat42 b a c := by
delta Fermat42
rw [add_comm]
tauto
#align fermat_42.comm Fermat42.comm
theorem mul {a b c k : ℤ} (hk0 : k ≠ 0) :
Fermat42 a b c ↔ Fermat42 (k * a) (k * b) (k ^ 2 * c) := by
delta Fermat42
constructor
· intro f42
constructor
· exact mul_ne_zero hk0 f42.1
constructor
· exact mul_ne_zero hk0 f42.2.1
· have H : a ^ 4 + b ^ 4 = c ^ 2 := f42.2.2
linear_combination k ^ 4 * H
· intro f42
constructor
· exact right_ne_zero_of_mul f42.1
constructor
· exact right_ne_zero_of_mul f42.2.1
apply (mul_right_inj' (pow_ne_zero 4 hk0)).mp
linear_combination f42.2.2
#align fermat_42.mul Fermat42.mul
theorem ne_zero {a b c : ℤ} (h : Fermat42 a b c) : c ≠ 0 := by
apply ne_zero_pow two_ne_zero _; apply ne_of_gt
rw [← h.2.2, (by ring : a ^ 4 + b ^ 4 = (a ^ 2) ^ 2 + (b ^ 2) ^ 2)]
exact
add_pos (sq_pos_of_ne_zero (pow_ne_zero 2 h.1)) (sq_pos_of_ne_zero (pow_ne_zero 2 h.2.1))
#align fermat_42.ne_zero Fermat42.ne_zero
def Minimal (a b c : ℤ) : Prop :=
Fermat42 a b c ∧ ∀ a1 b1 c1 : ℤ, Fermat42 a1 b1 c1 → Int.natAbs c ≤ Int.natAbs c1
#align fermat_42.minimal Fermat42.Minimal
theorem exists_minimal {a b c : ℤ} (h : Fermat42 a b c) : ∃ a0 b0 c0, Minimal a0 b0 c0 := by
let S : Set ℕ := { n | ∃ s : ℤ × ℤ × ℤ, Fermat42 s.1 s.2.1 s.2.2 ∧ n = Int.natAbs s.2.2 }
have S_nonempty : S.Nonempty := by
use Int.natAbs c
rw [Set.mem_setOf_eq]
use ⟨a, ⟨b, c⟩⟩
let m : ℕ := Nat.find S_nonempty
have m_mem : m ∈ S := Nat.find_spec S_nonempty
rcases m_mem with ⟨s0, hs0, hs1⟩
use s0.1, s0.2.1, s0.2.2, hs0
intro a1 b1 c1 h1
rw [← hs1]
apply Nat.find_min'
use ⟨a1, ⟨b1, c1⟩⟩
#align fermat_42.exists_minimal Fermat42.exists_minimal
theorem coprime_of_minimal {a b c : ℤ} (h : Minimal a b c) : IsCoprime a b := by
apply Int.gcd_eq_one_iff_coprime.mp
by_contra hab
obtain ⟨p, hp, hpa, hpb⟩ := Nat.Prime.not_coprime_iff_dvd.mp hab
obtain ⟨a1, rfl⟩ := Int.natCast_dvd.mpr hpa
obtain ⟨b1, rfl⟩ := Int.natCast_dvd.mpr hpb
have hpc : (p : ℤ) ^ 2 ∣ c := by
rw [← Int.pow_dvd_pow_iff two_ne_zero, ← h.1.2.2]
apply Dvd.intro (a1 ^ 4 + b1 ^ 4)
ring
obtain ⟨c1, rfl⟩ := hpc
have hf : Fermat42 a1 b1 c1 :=
(Fermat42.mul (Int.natCast_ne_zero.mpr (Nat.Prime.ne_zero hp))).mpr h.1
apply Nat.le_lt_asymm (h.2 _ _ _ hf)
rw [Int.natAbs_mul, lt_mul_iff_one_lt_left, Int.natAbs_pow, Int.natAbs_ofNat]
· exact Nat.one_lt_pow two_ne_zero (Nat.Prime.one_lt hp)
· exact Nat.pos_of_ne_zero (Int.natAbs_ne_zero.2 (ne_zero hf))
#align fermat_42.coprime_of_minimal Fermat42.coprime_of_minimal
theorem minimal_comm {a b c : ℤ} : Minimal a b c → Minimal b a c := fun ⟨h1, h2⟩ =>
⟨Fermat42.comm.mp h1, h2⟩
#align fermat_42.minimal_comm Fermat42.minimal_comm
theorem neg_of_minimal {a b c : ℤ} : Minimal a b c → Minimal a b (-c) := by
rintro ⟨⟨ha, hb, heq⟩, h2⟩
constructor
· apply And.intro ha (And.intro hb _)
rw [heq]
exact (neg_sq c).symm
rwa [Int.natAbs_neg c]
#align fermat_42.neg_of_minimal Fermat42.neg_of_minimal
theorem exists_odd_minimal {a b c : ℤ} (h : Fermat42 a b c) :
∃ a0 b0 c0, Minimal a0 b0 c0 ∧ a0 % 2 = 1 := by
obtain ⟨a0, b0, c0, hf⟩ := exists_minimal h
cases' Int.emod_two_eq_zero_or_one a0 with hap hap
· cases' Int.emod_two_eq_zero_or_one b0 with hbp hbp
· exfalso
have h1 : 2 ∣ (Int.gcd a0 b0 : ℤ) :=
Int.dvd_gcd (Int.dvd_of_emod_eq_zero hap) (Int.dvd_of_emod_eq_zero hbp)
rw [Int.gcd_eq_one_iff_coprime.mpr (coprime_of_minimal hf)] at h1
revert h1
decide
· exact ⟨b0, ⟨a0, ⟨c0, minimal_comm hf, hbp⟩⟩⟩
exact ⟨a0, ⟨b0, ⟨c0, hf, hap⟩⟩⟩
#align fermat_42.exists_odd_minimal Fermat42.exists_odd_minimal
| Mathlib/NumberTheory/FLT/Four.lean | 141 | 149 | theorem exists_pos_odd_minimal {a b c : ℤ} (h : Fermat42 a b c) :
∃ a0 b0 c0, Minimal a0 b0 c0 ∧ a0 % 2 = 1 ∧ 0 < c0 := by |
obtain ⟨a0, b0, c0, hf, hc⟩ := exists_odd_minimal h
rcases lt_trichotomy 0 c0 with (h1 | h1 | h1)
· use a0, b0, c0
· exfalso
exact ne_zero hf.1 h1.symm
· use a0, b0, -c0, neg_of_minimal hf, hc
exact neg_pos.mpr h1
|
import Mathlib.Algebra.Algebra.Unitization
import Mathlib.Algebra.Star.NonUnitalSubalgebra
import Mathlib.Algebra.Star.Subalgebra
import Mathlib.GroupTheory.GroupAction.Ring
section Subalgebra
variable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]
def Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A :=
{ S with
smul_mem' := fun r _x hx => S.smul_mem hx r }
theorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) :
(1 : A) ∈ S.toNonUnitalSubalgebra :=
S.one_mem
def NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) :
Subalgebra R A :=
{ S with
one_mem' := h1
algebraMap_mem' := fun r =>
(Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }
theorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) :
S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl
| Mathlib/Algebra/Algebra/Subalgebra/Unitization.lean | 73 | 75 | theorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A)
(h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by |
cases S; rfl
|
import Mathlib.Algebra.Group.Basic
import Mathlib.Algebra.Group.Commute.Defs
import Mathlib.Logic.Unique
import Mathlib.Tactic.Nontriviality
import Mathlib.Tactic.Lift
#align_import algebra.group.units from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
assert_not_exists Multiplicative
assert_not_exists MonoidWithZero
assert_not_exists DenselyOrdered
open Function
universe u
variable {α : Type u}
structure Units (α : Type u) [Monoid α] where
val : α
inv : α
val_inv : val * inv = 1
inv_val : inv * val = 1
#align units Units
#align units.val Units.val
#align units.inv Units.inv
#align units.val_inv Units.val_inv
#align units.inv_val Units.inv_val
attribute [coe] Units.val
@[inherit_doc]
postfix:1024 "ˣ" => Units
-- We don't provide notation for the additive version, because its use is somewhat rare.
structure AddUnits (α : Type u) [AddMonoid α] where
val : α
neg : α
val_neg : val + neg = 0
neg_val : neg + val = 0
#align add_units AddUnits
#align add_units.val AddUnits.val
#align add_units.neg AddUnits.neg
#align add_units.val_neg AddUnits.val_neg
#align add_units.neg_val AddUnits.neg_val
attribute [to_additive] Units
attribute [coe] AddUnits.val
namespace Units
section Monoid
variable [Monoid α]
-- Porting note: unclear whether this should be a `CoeHead` or `CoeTail`
@[to_additive "An additive unit can be interpreted as a term in the base `AddMonoid`."]
instance : CoeHead αˣ α :=
⟨val⟩
@[to_additive "The additive inverse of an additive unit in an `AddMonoid`."]
instance instInv : Inv αˣ :=
⟨fun u => ⟨u.2, u.1, u.4, u.3⟩⟩
attribute [instance] AddUnits.instNeg
#noalign units.simps.coe
#noalign add_units.simps.coe
@[to_additive "See Note [custom simps projection]"]
def Simps.val_inv (u : αˣ) : α := ↑(u⁻¹)
#align units.simps.coe_inv Units.Simps.val_inv
#align add_units.simps.coe_neg AddUnits.Simps.val_neg
initialize_simps_projections Units (as_prefix val, val_inv → null, inv → val_inv, as_prefix val_inv)
initialize_simps_projections AddUnits
(as_prefix val, val_neg → null, neg → val_neg, as_prefix val_neg)
-- Porting note: removed `simp` tag because of the tautology
@[to_additive]
theorem val_mk (a : α) (b h₁ h₂) : ↑(Units.mk a b h₁ h₂) = a :=
rfl
#align units.coe_mk Units.val_mk
#align add_units.coe_mk AddUnits.val_mk
@[to_additive (attr := ext)]
theorem ext : Function.Injective (val : αˣ → α)
| ⟨v, i₁, vi₁, iv₁⟩, ⟨v', i₂, vi₂, iv₂⟩, e => by
simp only at e; subst v'; congr;
simpa only [iv₂, vi₁, one_mul, mul_one] using mul_assoc i₂ v i₁
#align units.ext Units.ext
#align add_units.ext AddUnits.ext
@[to_additive (attr := norm_cast)]
theorem eq_iff {a b : αˣ} : (a : α) = b ↔ a = b :=
ext.eq_iff
#align units.eq_iff Units.eq_iff
#align add_units.eq_iff AddUnits.eq_iff
@[to_additive]
theorem ext_iff {a b : αˣ} : a = b ↔ (a : α) = b :=
eq_iff.symm
#align units.ext_iff Units.ext_iff
#align add_units.ext_iff AddUnits.ext_iff
@[to_additive "Additive units have decidable equality
if the base `AddMonoid` has deciable equality."]
instance [DecidableEq α] : DecidableEq αˣ := fun _ _ => decidable_of_iff' _ ext_iff
@[to_additive (attr := simp)]
theorem mk_val (u : αˣ) (y h₁ h₂) : mk (u : α) y h₁ h₂ = u :=
ext rfl
#align units.mk_coe Units.mk_val
#align add_units.mk_coe AddUnits.mk_val
@[to_additive (attr := simps) "Copy an `AddUnit`, adjusting definitional equalities."]
def copy (u : αˣ) (val : α) (hv : val = u) (inv : α) (hi : inv = ↑u⁻¹) : αˣ :=
{ val, inv, inv_val := hv.symm ▸ hi.symm ▸ u.inv_val, val_inv := hv.symm ▸ hi.symm ▸ u.val_inv }
#align units.copy Units.copy
#align add_units.copy AddUnits.copy
#align units.coe_copy Units.val_copy
#align add_units.coe_copy AddUnits.val_copy
#align units.coe_inv_copy Units.val_inv_copy
#align add_units.coe_neg_copy AddUnits.val_neg_copy
@[to_additive]
theorem copy_eq (u : αˣ) (val hv inv hi) : u.copy val hv inv hi = u :=
ext hv
#align units.copy_eq Units.copy_eq
#align add_units.copy_eq AddUnits.copy_eq
@[to_additive "Additive units of an additive monoid have an induced addition."]
instance : Mul αˣ where
mul u₁ u₂ :=
⟨u₁.val * u₂.val, u₂.inv * u₁.inv,
by rw [mul_assoc, ← mul_assoc u₂.val, val_inv, one_mul, val_inv],
by rw [mul_assoc, ← mul_assoc u₁.inv, inv_val, one_mul, inv_val]⟩
@[to_additive "Additive units of an additive monoid have a zero."]
instance : One αˣ where
one := ⟨1, 1, one_mul 1, one_mul 1⟩
@[to_additive "Additive units of an additive monoid have an addition and an additive identity."]
instance instMulOneClass : MulOneClass αˣ where
one_mul u := ext <| one_mul (u : α)
mul_one u := ext <| mul_one (u : α)
@[to_additive "Additive units of an additive monoid are inhabited because `0` is an additive unit."]
instance : Inhabited αˣ :=
⟨1⟩
@[to_additive "Additive units of an additive monoid have a representation of the base value in
the `AddMonoid`."]
instance [Repr α] : Repr αˣ :=
⟨reprPrec ∘ val⟩
variable (a b c : αˣ) {u : αˣ}
@[to_additive (attr := simp, norm_cast)]
theorem val_mul : (↑(a * b) : α) = a * b :=
rfl
#align units.coe_mul Units.val_mul
#align add_units.coe_add AddUnits.val_add
@[to_additive (attr := simp, norm_cast)]
theorem val_one : ((1 : αˣ) : α) = 1 :=
rfl
#align units.coe_one Units.val_one
#align add_units.coe_zero AddUnits.val_zero
@[to_additive (attr := simp, norm_cast)]
theorem val_eq_one {a : αˣ} : (a : α) = 1 ↔ a = 1 := by rw [← Units.val_one, eq_iff]
#align units.coe_eq_one Units.val_eq_one
#align add_units.coe_eq_zero AddUnits.val_eq_zero
@[to_additive (attr := simp)]
theorem inv_mk (x y : α) (h₁ h₂) : (mk x y h₁ h₂)⁻¹ = mk y x h₂ h₁ :=
rfl
#align units.inv_mk Units.inv_mk
#align add_units.neg_mk AddUnits.neg_mk
-- Porting note: coercions are now eagerly elaborated, so no need for `val_eq_coe`
#noalign units.val_eq_coe
#noalign add_units.val_eq_coe
@[to_additive (attr := simp)]
theorem inv_eq_val_inv : a.inv = ((a⁻¹ : αˣ) : α) :=
rfl
#align units.inv_eq_coe_inv Units.inv_eq_val_inv
#align add_units.neg_eq_coe_neg AddUnits.neg_eq_val_neg
@[to_additive (attr := simp)]
theorem inv_mul : (↑a⁻¹ * a : α) = 1 :=
inv_val _
#align units.inv_mul Units.inv_mul
#align add_units.neg_add AddUnits.neg_add
@[to_additive (attr := simp)]
theorem mul_inv : (a * ↑a⁻¹ : α) = 1 :=
val_inv _
#align units.mul_inv Units.mul_inv
#align add_units.add_neg AddUnits.add_neg
@[to_additive] lemma commute_coe_inv : Commute (a : α) ↑a⁻¹ := by
rw [Commute, SemiconjBy, inv_mul, mul_inv]
@[to_additive] lemma commute_inv_coe : Commute ↑a⁻¹ (a : α) := a.commute_coe_inv.symm
@[to_additive]
theorem inv_mul_of_eq {a : α} (h : ↑u = a) : ↑u⁻¹ * a = 1 := by rw [← h, u.inv_mul]
#align units.inv_mul_of_eq Units.inv_mul_of_eq
#align add_units.neg_add_of_eq AddUnits.neg_add_of_eq
@[to_additive]
theorem mul_inv_of_eq {a : α} (h : ↑u = a) : a * ↑u⁻¹ = 1 := by rw [← h, u.mul_inv]
#align units.mul_inv_of_eq Units.mul_inv_of_eq
#align add_units.add_neg_of_eq AddUnits.add_neg_of_eq
@[to_additive (attr := simp)]
theorem mul_inv_cancel_left (a : αˣ) (b : α) : (a : α) * (↑a⁻¹ * b) = b := by
rw [← mul_assoc, mul_inv, one_mul]
#align units.mul_inv_cancel_left Units.mul_inv_cancel_left
#align add_units.add_neg_cancel_left AddUnits.add_neg_cancel_left
@[to_additive (attr := simp)]
theorem inv_mul_cancel_left (a : αˣ) (b : α) : (↑a⁻¹ : α) * (a * b) = b := by
rw [← mul_assoc, inv_mul, one_mul]
#align units.inv_mul_cancel_left Units.inv_mul_cancel_left
#align add_units.neg_add_cancel_left AddUnits.neg_add_cancel_left
@[to_additive (attr := simp)]
theorem mul_inv_cancel_right (a : α) (b : αˣ) : a * b * ↑b⁻¹ = a := by
rw [mul_assoc, mul_inv, mul_one]
#align units.mul_inv_cancel_right Units.mul_inv_cancel_right
#align add_units.add_neg_cancel_right AddUnits.add_neg_cancel_right
@[to_additive (attr := simp)]
| Mathlib/Algebra/Group/Units.lean | 304 | 305 | theorem inv_mul_cancel_right (a : α) (b : αˣ) : a * ↑b⁻¹ * b = a := by |
rw [mul_assoc, inv_mul, mul_one]
|
import Mathlib.Data.Bool.Basic
import Mathlib.Init.Order.Defs
import Mathlib.Order.Monotone.Basic
import Mathlib.Order.ULift
import Mathlib.Tactic.GCongr.Core
#align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c"
@[gcongr_forward] def exactSubsetOfSSubset : Mathlib.Tactic.GCongr.ForwardExt where
eval h goal := do goal.assignIfDefeq (← Lean.Meta.mkAppM ``subset_of_ssubset #[h])
universe u v w
variable {α : Type u} {β : Type v}
#align le_antisymm' le_antisymm
-- TODO: automatic construction of dual definitions / theorems
class SemilatticeSup (α : Type u) extends Sup α, PartialOrder α where
protected le_sup_left : ∀ a b : α, a ≤ a ⊔ b
protected le_sup_right : ∀ a b : α, b ≤ a ⊔ b
protected sup_le : ∀ a b c : α, a ≤ c → b ≤ c → a ⊔ b ≤ c
#align semilattice_sup SemilatticeSup
def SemilatticeSup.mk' {α : Type*} [Sup α] (sup_comm : ∀ a b : α, a ⊔ b = b ⊔ a)
(sup_assoc : ∀ a b c : α, a ⊔ b ⊔ c = a ⊔ (b ⊔ c)) (sup_idem : ∀ a : α, a ⊔ a = a) :
SemilatticeSup α where
sup := (· ⊔ ·)
le a b := a ⊔ b = b
le_refl := sup_idem
le_trans a b c hab hbc := by dsimp; rw [← hbc, ← sup_assoc, hab]
le_antisymm a b hab hba := by rwa [← hba, sup_comm]
le_sup_left a b := by dsimp; rw [← sup_assoc, sup_idem]
le_sup_right a b := by dsimp; rw [sup_comm, sup_assoc, sup_idem]
sup_le a b c hac hbc := by dsimp; rwa [sup_assoc, hbc]
#align semilattice_sup.mk' SemilatticeSup.mk'
instance OrderDual.instSup (α : Type*) [Inf α] : Sup αᵒᵈ :=
⟨((· ⊓ ·) : α → α → α)⟩
instance OrderDual.instInf (α : Type*) [Sup α] : Inf αᵒᵈ :=
⟨((· ⊔ ·) : α → α → α)⟩
section SemilatticeSup
variable [SemilatticeSup α] {a b c d : α}
@[simp]
theorem le_sup_left : a ≤ a ⊔ b :=
SemilatticeSup.le_sup_left a b
#align le_sup_left le_sup_left
#align le_sup_left' le_sup_left
@[deprecated (since := "2024-06-04")] alias le_sup_left' := le_sup_left
@[simp]
theorem le_sup_right : b ≤ a ⊔ b :=
SemilatticeSup.le_sup_right a b
#align le_sup_right le_sup_right
#align le_sup_right' le_sup_right
@[deprecated (since := "2024-06-04")] alias le_sup_right' := le_sup_right
theorem le_sup_of_le_left (h : c ≤ a) : c ≤ a ⊔ b :=
le_trans h le_sup_left
#align le_sup_of_le_left le_sup_of_le_left
theorem le_sup_of_le_right (h : c ≤ b) : c ≤ a ⊔ b :=
le_trans h le_sup_right
#align le_sup_of_le_right le_sup_of_le_right
theorem lt_sup_of_lt_left (h : c < a) : c < a ⊔ b :=
h.trans_le le_sup_left
#align lt_sup_of_lt_left lt_sup_of_lt_left
theorem lt_sup_of_lt_right (h : c < b) : c < a ⊔ b :=
h.trans_le le_sup_right
#align lt_sup_of_lt_right lt_sup_of_lt_right
theorem sup_le : a ≤ c → b ≤ c → a ⊔ b ≤ c :=
SemilatticeSup.sup_le a b c
#align sup_le sup_le
@[simp]
theorem sup_le_iff : a ⊔ b ≤ c ↔ a ≤ c ∧ b ≤ c :=
⟨fun h : a ⊔ b ≤ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩,
fun ⟨h₁, h₂⟩ => sup_le h₁ h₂⟩
#align sup_le_iff sup_le_iff
@[simp]
theorem sup_eq_left : a ⊔ b = a ↔ b ≤ a :=
le_antisymm_iff.trans <| by simp [le_rfl]
#align sup_eq_left sup_eq_left
@[simp]
theorem sup_eq_right : a ⊔ b = b ↔ a ≤ b :=
le_antisymm_iff.trans <| by simp [le_rfl]
#align sup_eq_right sup_eq_right
@[simp]
theorem left_eq_sup : a = a ⊔ b ↔ b ≤ a :=
eq_comm.trans sup_eq_left
#align left_eq_sup left_eq_sup
@[simp]
theorem right_eq_sup : b = a ⊔ b ↔ a ≤ b :=
eq_comm.trans sup_eq_right
#align right_eq_sup right_eq_sup
alias ⟨_, sup_of_le_left⟩ := sup_eq_left
#align sup_of_le_left sup_of_le_left
alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right
#align sup_of_le_right sup_of_le_right
#align le_of_sup_eq le_of_sup_eq
attribute [simp] sup_of_le_left sup_of_le_right
@[simp]
theorem left_lt_sup : a < a ⊔ b ↔ ¬b ≤ a :=
le_sup_left.lt_iff_ne.trans <| not_congr left_eq_sup
#align left_lt_sup left_lt_sup
@[simp]
theorem right_lt_sup : b < a ⊔ b ↔ ¬a ≤ b :=
le_sup_right.lt_iff_ne.trans <| not_congr right_eq_sup
#align right_lt_sup right_lt_sup
theorem left_or_right_lt_sup (h : a ≠ b) : a < a ⊔ b ∨ b < a ⊔ b :=
h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2
#align left_or_right_lt_sup left_or_right_lt_sup
theorem le_iff_exists_sup : a ≤ b ↔ ∃ c, b = a ⊔ c := by
constructor
· intro h
exact ⟨b, (sup_eq_right.mpr h).symm⟩
· rintro ⟨c, rfl : _ = _ ⊔ _⟩
exact le_sup_left
#align le_iff_exists_sup le_iff_exists_sup
@[gcongr]
theorem sup_le_sup (h₁ : a ≤ b) (h₂ : c ≤ d) : a ⊔ c ≤ b ⊔ d :=
sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right h₂)
#align sup_le_sup sup_le_sup
@[gcongr]
theorem sup_le_sup_left (h₁ : a ≤ b) (c) : c ⊔ a ≤ c ⊔ b :=
sup_le_sup le_rfl h₁
#align sup_le_sup_left sup_le_sup_left
@[gcongr]
theorem sup_le_sup_right (h₁ : a ≤ b) (c) : a ⊔ c ≤ b ⊔ c :=
sup_le_sup h₁ le_rfl
#align sup_le_sup_right sup_le_sup_right
| Mathlib/Order/Lattice.lean | 219 | 219 | theorem sup_idem (a : α) : a ⊔ a = a := by | simp
|
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.RingTheory.Localization.FractionRing
#align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8"
noncomputable section
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ}
section CommRing
variable [CommRing R] [IsDomain R] {p q : R[X]}
section Roots
open Multiset Finset
noncomputable def roots (p : R[X]) : Multiset R :=
haveI := Classical.decEq R
haveI := Classical.dec (p = 0)
if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h)
#align polynomial.roots Polynomial.roots
theorem roots_def [DecidableEq R] (p : R[X]) [Decidable (p = 0)] :
p.roots = if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h) := by
-- porting noteL `‹_›` doesn't work for instance arguments
rename_i iR ip0
obtain rfl := Subsingleton.elim iR (Classical.decEq R)
obtain rfl := Subsingleton.elim ip0 (Classical.dec (p = 0))
rfl
#align polynomial.roots_def Polynomial.roots_def
@[simp]
theorem roots_zero : (0 : R[X]).roots = 0 :=
dif_pos rfl
#align polynomial.roots_zero Polynomial.roots_zero
theorem card_roots (hp0 : p ≠ 0) : (Multiset.card (roots p) : WithBot ℕ) ≤ degree p := by
classical
unfold roots
rw [dif_neg hp0]
exact (Classical.choose_spec (exists_multiset_roots hp0)).1
#align polynomial.card_roots Polynomial.card_roots
theorem card_roots' (p : R[X]) : Multiset.card p.roots ≤ natDegree p := by
by_cases hp0 : p = 0
· simp [hp0]
exact WithBot.coe_le_coe.1 (le_trans (card_roots hp0) (le_of_eq <| degree_eq_natDegree hp0))
#align polynomial.card_roots' Polynomial.card_roots'
theorem card_roots_sub_C {p : R[X]} {a : R} (hp0 : 0 < degree p) :
(Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree p :=
calc
(Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree (p - C a) :=
card_roots <| mt sub_eq_zero.1 fun h => not_le_of_gt hp0 <| h.symm ▸ degree_C_le
_ = degree p := by rw [sub_eq_add_neg, ← C_neg]; exact degree_add_C hp0
set_option linter.uppercaseLean3 false in
#align polynomial.card_roots_sub_C Polynomial.card_roots_sub_C
theorem card_roots_sub_C' {p : R[X]} {a : R} (hp0 : 0 < degree p) :
Multiset.card (p - C a).roots ≤ natDegree p :=
WithBot.coe_le_coe.1
(le_trans (card_roots_sub_C hp0)
(le_of_eq <| degree_eq_natDegree fun h => by simp_all [lt_irrefl]))
set_option linter.uppercaseLean3 false in
#align polynomial.card_roots_sub_C' Polynomial.card_roots_sub_C'
@[simp]
theorem count_roots [DecidableEq R] (p : R[X]) : p.roots.count a = rootMultiplicity a p := by
classical
by_cases hp : p = 0
· simp [hp]
rw [roots_def, dif_neg hp]
exact (Classical.choose_spec (exists_multiset_roots hp)).2 a
#align polynomial.count_roots Polynomial.count_roots
@[simp]
theorem mem_roots' : a ∈ p.roots ↔ p ≠ 0 ∧ IsRoot p a := by
classical
rw [← count_pos, count_roots p, rootMultiplicity_pos']
#align polynomial.mem_roots' Polynomial.mem_roots'
theorem mem_roots (hp : p ≠ 0) : a ∈ p.roots ↔ IsRoot p a :=
mem_roots'.trans <| and_iff_right hp
#align polynomial.mem_roots Polynomial.mem_roots
theorem ne_zero_of_mem_roots (h : a ∈ p.roots) : p ≠ 0 :=
(mem_roots'.1 h).1
#align polynomial.ne_zero_of_mem_roots Polynomial.ne_zero_of_mem_roots
theorem isRoot_of_mem_roots (h : a ∈ p.roots) : IsRoot p a :=
(mem_roots'.1 h).2
#align polynomial.is_root_of_mem_roots Polynomial.isRoot_of_mem_roots
-- Porting note: added during port.
lemma mem_roots_iff_aeval_eq_zero {x : R} (w : p ≠ 0) : x ∈ roots p ↔ aeval x p = 0 := by
rw [mem_roots w, IsRoot.def, aeval_def, eval₂_eq_eval_map]
simp
theorem card_le_degree_of_subset_roots {p : R[X]} {Z : Finset R} (h : Z.val ⊆ p.roots) :
Z.card ≤ p.natDegree :=
(Multiset.card_le_card (Finset.val_le_iff_val_subset.2 h)).trans (Polynomial.card_roots' p)
#align polynomial.card_le_degree_of_subset_roots Polynomial.card_le_degree_of_subset_roots
theorem finite_setOf_isRoot {p : R[X]} (hp : p ≠ 0) : Set.Finite { x | IsRoot p x } := by
classical
simpa only [← Finset.setOf_mem, Multiset.mem_toFinset, mem_roots hp]
using p.roots.toFinset.finite_toSet
#align polynomial.finite_set_of_is_root Polynomial.finite_setOf_isRoot
theorem eq_zero_of_infinite_isRoot (p : R[X]) (h : Set.Infinite { x | IsRoot p x }) : p = 0 :=
not_imp_comm.mp finite_setOf_isRoot h
#align polynomial.eq_zero_of_infinite_is_root Polynomial.eq_zero_of_infinite_isRoot
theorem exists_max_root [LinearOrder R] (p : R[X]) (hp : p ≠ 0) : ∃ x₀, ∀ x, p.IsRoot x → x ≤ x₀ :=
Set.exists_upper_bound_image _ _ <| finite_setOf_isRoot hp
#align polynomial.exists_max_root Polynomial.exists_max_root
theorem exists_min_root [LinearOrder R] (p : R[X]) (hp : p ≠ 0) : ∃ x₀, ∀ x, p.IsRoot x → x₀ ≤ x :=
Set.exists_lower_bound_image _ _ <| finite_setOf_isRoot hp
#align polynomial.exists_min_root Polynomial.exists_min_root
theorem eq_of_infinite_eval_eq (p q : R[X]) (h : Set.Infinite { x | eval x p = eval x q }) :
p = q := by
rw [← sub_eq_zero]
apply eq_zero_of_infinite_isRoot
simpa only [IsRoot, eval_sub, sub_eq_zero]
#align polynomial.eq_of_infinite_eval_eq Polynomial.eq_of_infinite_eval_eq
theorem roots_mul {p q : R[X]} (hpq : p * q ≠ 0) : (p * q).roots = p.roots + q.roots := by
classical
exact Multiset.ext.mpr fun r => by
rw [count_add, count_roots, count_roots, count_roots, rootMultiplicity_mul hpq]
#align polynomial.roots_mul Polynomial.roots_mul
theorem roots.le_of_dvd (h : q ≠ 0) : p ∣ q → roots p ≤ roots q := by
rintro ⟨k, rfl⟩
exact Multiset.le_iff_exists_add.mpr ⟨k.roots, roots_mul h⟩
#align polynomial.roots.le_of_dvd Polynomial.roots.le_of_dvd
theorem mem_roots_sub_C' {p : R[X]} {a x : R} : x ∈ (p - C a).roots ↔ p ≠ C a ∧ p.eval x = a := by
rw [mem_roots', IsRoot.def, sub_ne_zero, eval_sub, sub_eq_zero, eval_C]
set_option linter.uppercaseLean3 false in
#align polynomial.mem_roots_sub_C' Polynomial.mem_roots_sub_C'
theorem mem_roots_sub_C {p : R[X]} {a x : R} (hp0 : 0 < degree p) :
x ∈ (p - C a).roots ↔ p.eval x = a :=
mem_roots_sub_C'.trans <| and_iff_right fun hp => hp0.not_le <| hp.symm ▸ degree_C_le
set_option linter.uppercaseLean3 false in
#align polynomial.mem_roots_sub_C Polynomial.mem_roots_sub_C
@[simp]
theorem roots_X_sub_C (r : R) : roots (X - C r) = {r} := by
classical
ext s
rw [count_roots, rootMultiplicity_X_sub_C, count_singleton]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_X_sub_C Polynomial.roots_X_sub_C
@[simp]
theorem roots_X : roots (X : R[X]) = {0} := by rw [← roots_X_sub_C, C_0, sub_zero]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_X Polynomial.roots_X
@[simp]
theorem roots_C (x : R) : (C x).roots = 0 := by
classical exact
if H : x = 0 then by rw [H, C_0, roots_zero]
else
Multiset.ext.mpr fun r => (by
rw [count_roots, count_zero, rootMultiplicity_eq_zero (not_isRoot_C _ _ H)])
set_option linter.uppercaseLean3 false in
#align polynomial.roots_C Polynomial.roots_C
@[simp]
theorem roots_one : (1 : R[X]).roots = ∅ :=
roots_C 1
#align polynomial.roots_one Polynomial.roots_one
@[simp]
theorem roots_C_mul (p : R[X]) (ha : a ≠ 0) : (C a * p).roots = p.roots := by
by_cases hp : p = 0 <;>
simp only [roots_mul, *, Ne, mul_eq_zero, C_eq_zero, or_self_iff, not_false_iff, roots_C,
zero_add, mul_zero]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_C_mul Polynomial.roots_C_mul
@[simp]
theorem roots_smul_nonzero (p : R[X]) (ha : a ≠ 0) : (a • p).roots = p.roots := by
rw [smul_eq_C_mul, roots_C_mul _ ha]
#align polynomial.roots_smul_nonzero Polynomial.roots_smul_nonzero
@[simp]
lemma roots_neg (p : R[X]) : (-p).roots = p.roots := by
rw [← neg_one_smul R p, roots_smul_nonzero p (neg_ne_zero.mpr one_ne_zero)]
theorem roots_list_prod (L : List R[X]) :
(0 : R[X]) ∉ L → L.prod.roots = (L : Multiset R[X]).bind roots :=
List.recOn L (fun _ => roots_one) fun hd tl ih H => by
rw [List.mem_cons, not_or] at H
rw [List.prod_cons, roots_mul (mul_ne_zero (Ne.symm H.1) <| List.prod_ne_zero H.2), ←
Multiset.cons_coe, Multiset.cons_bind, ih H.2]
#align polynomial.roots_list_prod Polynomial.roots_list_prod
theorem roots_multiset_prod (m : Multiset R[X]) : (0 : R[X]) ∉ m → m.prod.roots = m.bind roots := by
rcases m with ⟨L⟩
simpa only [Multiset.prod_coe, quot_mk_to_coe''] using roots_list_prod L
#align polynomial.roots_multiset_prod Polynomial.roots_multiset_prod
theorem roots_prod {ι : Type*} (f : ι → R[X]) (s : Finset ι) :
s.prod f ≠ 0 → (s.prod f).roots = s.val.bind fun i => roots (f i) := by
rcases s with ⟨m, hm⟩
simpa [Multiset.prod_eq_zero_iff, Multiset.bind_map] using roots_multiset_prod (m.map f)
#align polynomial.roots_prod Polynomial.roots_prod
@[simp]
theorem roots_pow (p : R[X]) (n : ℕ) : (p ^ n).roots = n • p.roots := by
induction' n with n ihn
· rw [pow_zero, roots_one, zero_smul, empty_eq_zero]
· rcases eq_or_ne p 0 with (rfl | hp)
· rw [zero_pow n.succ_ne_zero, roots_zero, smul_zero]
· rw [pow_succ, roots_mul (mul_ne_zero (pow_ne_zero _ hp) hp), ihn, add_smul, one_smul]
#align polynomial.roots_pow Polynomial.roots_pow
theorem roots_X_pow (n : ℕ) : (X ^ n : R[X]).roots = n • ({0} : Multiset R) := by
rw [roots_pow, roots_X]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_X_pow Polynomial.roots_X_pow
theorem roots_C_mul_X_pow (ha : a ≠ 0) (n : ℕ) :
Polynomial.roots (C a * X ^ n) = n • ({0} : Multiset R) := by
rw [roots_C_mul _ ha, roots_X_pow]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_C_mul_X_pow Polynomial.roots_C_mul_X_pow
@[simp]
theorem roots_monomial (ha : a ≠ 0) (n : ℕ) : (monomial n a).roots = n • ({0} : Multiset R) := by
rw [← C_mul_X_pow_eq_monomial, roots_C_mul_X_pow ha]
#align polynomial.roots_monomial Polynomial.roots_monomial
theorem roots_prod_X_sub_C (s : Finset R) : (s.prod fun a => X - C a).roots = s.val := by
apply (roots_prod (fun a => X - C a) s ?_).trans
· simp_rw [roots_X_sub_C]
rw [Multiset.bind_singleton, Multiset.map_id']
· refine prod_ne_zero_iff.mpr (fun a _ => X_sub_C_ne_zero a)
set_option linter.uppercaseLean3 false in
#align polynomial.roots_prod_X_sub_C Polynomial.roots_prod_X_sub_C
@[simp]
theorem roots_multiset_prod_X_sub_C (s : Multiset R) : (s.map fun a => X - C a).prod.roots = s := by
rw [roots_multiset_prod, Multiset.bind_map]
· simp_rw [roots_X_sub_C]
rw [Multiset.bind_singleton, Multiset.map_id']
· rw [Multiset.mem_map]
rintro ⟨a, -, h⟩
exact X_sub_C_ne_zero a h
set_option linter.uppercaseLean3 false in
#align polynomial.roots_multiset_prod_X_sub_C Polynomial.roots_multiset_prod_X_sub_C
theorem card_roots_X_pow_sub_C {n : ℕ} (hn : 0 < n) (a : R) :
Multiset.card (roots ((X : R[X]) ^ n - C a)) ≤ n :=
WithBot.coe_le_coe.1 <|
calc
(Multiset.card (roots ((X : R[X]) ^ n - C a)) : WithBot ℕ) ≤ degree ((X : R[X]) ^ n - C a) :=
card_roots (X_pow_sub_C_ne_zero hn a)
_ = n := degree_X_pow_sub_C hn a
set_option linter.uppercaseLean3 false in
#align polynomial.card_roots_X_pow_sub_C Polynomial.card_roots_X_pow_sub_C
theorem zero_of_eval_zero [Infinite R] (p : R[X]) (h : ∀ x, p.eval x = 0) : p = 0 := by
classical
by_contra hp
refine @Fintype.false R _ ?_
exact ⟨p.roots.toFinset, fun x => Multiset.mem_toFinset.mpr ((mem_roots hp).mpr (h _))⟩
#align polynomial.zero_of_eval_zero Polynomial.zero_of_eval_zero
theorem funext [Infinite R] {p q : R[X]} (ext : ∀ r : R, p.eval r = q.eval r) : p = q := by
rw [← sub_eq_zero]
apply zero_of_eval_zero
intro x
rw [eval_sub, sub_eq_zero, ext]
#align polynomial.funext Polynomial.funext
variable [CommRing T]
noncomputable abbrev aroots (p : T[X]) (S) [CommRing S] [IsDomain S] [Algebra T S] : Multiset S :=
(p.map (algebraMap T S)).roots
theorem aroots_def (p : T[X]) (S) [CommRing S] [IsDomain S] [Algebra T S] :
p.aroots S = (p.map (algebraMap T S)).roots :=
rfl
theorem mem_aroots' [CommRing S] [IsDomain S] [Algebra T S] {p : T[X]} {a : S} :
a ∈ p.aroots S ↔ p.map (algebraMap T S) ≠ 0 ∧ aeval a p = 0 := by
rw [mem_roots', IsRoot.def, ← eval₂_eq_eval_map, aeval_def]
theorem mem_aroots [CommRing S] [IsDomain S] [Algebra T S]
[NoZeroSMulDivisors T S] {p : T[X]} {a : S} : a ∈ p.aroots S ↔ p ≠ 0 ∧ aeval a p = 0 := by
rw [mem_aroots', Polynomial.map_ne_zero_iff]
exact NoZeroSMulDivisors.algebraMap_injective T S
theorem aroots_mul [CommRing S] [IsDomain S] [Algebra T S]
[NoZeroSMulDivisors T S] {p q : T[X]} (hpq : p * q ≠ 0) :
(p * q).aroots S = p.aroots S + q.aroots S := by
suffices map (algebraMap T S) p * map (algebraMap T S) q ≠ 0 by
rw [aroots_def, Polynomial.map_mul, roots_mul this]
rwa [← Polynomial.map_mul, Polynomial.map_ne_zero_iff
(NoZeroSMulDivisors.algebraMap_injective T S)]
@[simp]
theorem aroots_X_sub_C [CommRing S] [IsDomain S] [Algebra T S]
(r : T) : aroots (X - C r) S = {algebraMap T S r} := by
rw [aroots_def, Polynomial.map_sub, map_X, map_C, roots_X_sub_C]
@[simp]
theorem aroots_X [CommRing S] [IsDomain S] [Algebra T S] :
aroots (X : T[X]) S = {0} := by
rw [aroots_def, map_X, roots_X]
@[simp]
theorem aroots_C [CommRing S] [IsDomain S] [Algebra T S] (a : T) : (C a).aroots S = 0 := by
rw [aroots_def, map_C, roots_C]
@[simp]
theorem aroots_zero (S) [CommRing S] [IsDomain S] [Algebra T S] : (0 : T[X]).aroots S = 0 := by
rw [← C_0, aroots_C]
@[simp]
theorem aroots_one [CommRing S] [IsDomain S] [Algebra T S] :
(1 : T[X]).aroots S = 0 :=
aroots_C 1
@[simp]
theorem aroots_neg [CommRing S] [IsDomain S] [Algebra T S] (p : T[X]) :
(-p).aroots S = p.aroots S := by
rw [aroots, Polynomial.map_neg, roots_neg]
@[simp]
theorem aroots_C_mul [CommRing S] [IsDomain S] [Algebra T S]
[NoZeroSMulDivisors T S] {a : T} (p : T[X]) (ha : a ≠ 0) :
(C a * p).aroots S = p.aroots S := by
rw [aroots_def, Polynomial.map_mul, map_C, roots_C_mul]
rwa [map_ne_zero_iff]
exact NoZeroSMulDivisors.algebraMap_injective T S
@[simp]
theorem aroots_smul_nonzero [CommRing S] [IsDomain S] [Algebra T S]
[NoZeroSMulDivisors T S] {a : T} (p : T[X]) (ha : a ≠ 0) :
(a • p).aroots S = p.aroots S := by
rw [smul_eq_C_mul, aroots_C_mul _ ha]
@[simp]
theorem aroots_pow [CommRing S] [IsDomain S] [Algebra T S] (p : T[X]) (n : ℕ) :
(p ^ n).aroots S = n • p.aroots S := by
rw [aroots_def, Polynomial.map_pow, roots_pow]
theorem aroots_X_pow [CommRing S] [IsDomain S] [Algebra T S] (n : ℕ) :
(X ^ n : T[X]).aroots S = n • ({0} : Multiset S) := by
rw [aroots_pow, aroots_X]
theorem aroots_C_mul_X_pow [CommRing S] [IsDomain S] [Algebra T S]
[NoZeroSMulDivisors T S] {a : T} (ha : a ≠ 0) (n : ℕ) :
(C a * X ^ n : T[X]).aroots S = n • ({0} : Multiset S) := by
rw [aroots_C_mul _ ha, aroots_X_pow]
@[simp]
theorem aroots_monomial [CommRing S] [IsDomain S] [Algebra T S]
[NoZeroSMulDivisors T S] {a : T} (ha : a ≠ 0) (n : ℕ) :
(monomial n a).aroots S = n • ({0} : Multiset S) := by
rw [← C_mul_X_pow_eq_monomial, aroots_C_mul_X_pow ha]
def rootSet (p : T[X]) (S) [CommRing S] [IsDomain S] [Algebra T S] : Set S :=
haveI := Classical.decEq S
(p.aroots S).toFinset
#align polynomial.root_set Polynomial.rootSet
theorem rootSet_def (p : T[X]) (S) [CommRing S] [IsDomain S] [Algebra T S] [DecidableEq S] :
p.rootSet S = (p.aroots S).toFinset := by
rw [rootSet]
convert rfl
#align polynomial.root_set_def Polynomial.rootSet_def
@[simp]
| Mathlib/Algebra/Polynomial/Roots.lean | 515 | 517 | theorem rootSet_C [CommRing S] [IsDomain S] [Algebra T S] (a : T) : (C a).rootSet S = ∅ := by |
classical
rw [rootSet_def, aroots_C, Multiset.toFinset_zero, Finset.coe_empty]
|
import Mathlib.CategoryTheory.Monoidal.Free.Coherence
import Mathlib.CategoryTheory.Monoidal.Discrete
import Mathlib.CategoryTheory.Monoidal.NaturalTransformation
import Mathlib.CategoryTheory.Monoidal.Opposite
import Mathlib.Tactic.CategoryTheory.Coherence
import Mathlib.CategoryTheory.CommSq
#align_import category_theory.monoidal.braided from "leanprover-community/mathlib"@"2efd2423f8d25fa57cf7a179f5d8652ab4d0df44"
open CategoryTheory MonoidalCategory
universe v v₁ v₂ v₃ u u₁ u₂ u₃
namespace CategoryTheory
class BraidedCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where
braiding : ∀ X Y : C, X ⊗ Y ≅ Y ⊗ X
braiding_naturality_right :
∀ (X : C) {Y Z : C} (f : Y ⟶ Z),
X ◁ f ≫ (braiding X Z).hom = (braiding X Y).hom ≫ f ▷ X := by
aesop_cat
braiding_naturality_left :
∀ {X Y : C} (f : X ⟶ Y) (Z : C),
f ▷ Z ≫ (braiding Y Z).hom = (braiding X Z).hom ≫ Z ◁ f := by
aesop_cat
hexagon_forward :
∀ X Y Z : C,
(α_ X Y Z).hom ≫ (braiding X (Y ⊗ Z)).hom ≫ (α_ Y Z X).hom =
((braiding X Y).hom ▷ Z) ≫ (α_ Y X Z).hom ≫ (Y ◁ (braiding X Z).hom) := by
aesop_cat
hexagon_reverse :
∀ X Y Z : C,
(α_ X Y Z).inv ≫ (braiding (X ⊗ Y) Z).hom ≫ (α_ Z X Y).inv =
(X ◁ (braiding Y Z).hom) ≫ (α_ X Z Y).inv ≫ ((braiding X Z).hom ▷ Y) := by
aesop_cat
#align category_theory.braided_category CategoryTheory.BraidedCategory
attribute [reassoc (attr := simp)]
BraidedCategory.braiding_naturality_left
BraidedCategory.braiding_naturality_right
attribute [reassoc] BraidedCategory.hexagon_forward BraidedCategory.hexagon_reverse
open Category
open MonoidalCategory
open BraidedCategory
@[inherit_doc]
notation "β_" => BraidedCategory.braiding
namespace BraidedCategory
variable {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C] [BraidedCategory.{v} C]
@[simp, reassoc]
theorem braiding_tensor_left (X Y Z : C) :
(β_ (X ⊗ Y) Z).hom =
(α_ X Y Z).hom ≫ X ◁ (β_ Y Z).hom ≫ (α_ X Z Y).inv ≫
(β_ X Z).hom ▷ Y ≫ (α_ Z X Y).hom := by
apply (cancel_epi (α_ X Y Z).inv).1
apply (cancel_mono (α_ Z X Y).inv).1
simp [hexagon_reverse]
@[simp, reassoc]
theorem braiding_tensor_right (X Y Z : C) :
(β_ X (Y ⊗ Z)).hom =
(α_ X Y Z).inv ≫ (β_ X Y).hom ▷ Z ≫ (α_ Y X Z).hom ≫
Y ◁ (β_ X Z).hom ≫ (α_ Y Z X).inv := by
apply (cancel_epi (α_ X Y Z).hom).1
apply (cancel_mono (α_ Y Z X).hom).1
simp [hexagon_forward]
@[simp, reassoc]
theorem braiding_inv_tensor_left (X Y Z : C) :
(β_ (X ⊗ Y) Z).inv =
(α_ Z X Y).inv ≫ (β_ X Z).inv ▷ Y ≫ (α_ X Z Y).hom ≫
X ◁ (β_ Y Z).inv ≫ (α_ X Y Z).inv :=
eq_of_inv_eq_inv (by simp)
@[simp, reassoc]
theorem braiding_inv_tensor_right (X Y Z : C) :
(β_ X (Y ⊗ Z)).inv =
(α_ Y Z X).hom ≫ Y ◁ (β_ X Z).inv ≫ (α_ Y X Z).inv ≫
(β_ X Y).inv ▷ Z ≫ (α_ X Y Z).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem braiding_naturality {X X' Y Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') :
(f ⊗ g) ≫ (braiding Y Y').hom = (braiding X X').hom ≫ (g ⊗ f) := by
rw [tensorHom_def' f g, tensorHom_def g f]
simp_rw [Category.assoc, braiding_naturality_left, braiding_naturality_right_assoc]
@[reassoc (attr := simp)]
theorem braiding_inv_naturality_right (X : C) {Y Z : C} (f : Y ⟶ Z) :
X ◁ f ≫ (β_ Z X).inv = (β_ Y X).inv ≫ f ▷ X :=
CommSq.w <| .vert_inv <| .mk <| braiding_naturality_left f X
@[reassoc (attr := simp)]
theorem braiding_inv_naturality_left {X Y : C} (f : X ⟶ Y) (Z : C) :
f ▷ Z ≫ (β_ Z Y).inv = (β_ Z X).inv ≫ Z ◁ f :=
CommSq.w <| .vert_inv <| .mk <| braiding_naturality_right Z f
@[reassoc (attr := simp)]
theorem braiding_inv_naturality {X X' Y Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') :
(f ⊗ g) ≫ (β_ Y' Y).inv = (β_ X' X).inv ≫ (g ⊗ f) :=
CommSq.w <| .vert_inv <| .mk <| braiding_naturality g f
@[reassoc]
theorem yang_baxter (X Y Z : C) :
(α_ X Y Z).inv ≫ (β_ X Y).hom ▷ Z ≫ (α_ Y X Z).hom ≫
Y ◁ (β_ X Z).hom ≫ (α_ Y Z X).inv ≫ (β_ Y Z).hom ▷ X ≫ (α_ Z Y X).hom =
X ◁ (β_ Y Z).hom ≫ (α_ X Z Y).inv ≫ (β_ X Z).hom ▷ Y ≫
(α_ Z X Y).hom ≫ Z ◁ (β_ X Y).hom := by
rw [← braiding_tensor_right_assoc X Y Z, ← cancel_mono (α_ Z Y X).inv]
repeat rw [assoc]
rw [Iso.hom_inv_id, comp_id, ← braiding_naturality_right, braiding_tensor_right]
theorem yang_baxter' (X Y Z : C) :
(β_ X Y).hom ▷ Z ⊗≫ Y ◁ (β_ X Z).hom ⊗≫ (β_ Y Z).hom ▷ X =
𝟙 _ ⊗≫ (X ◁ (β_ Y Z).hom ⊗≫ (β_ X Z).hom ▷ Y ⊗≫ Z ◁ (β_ X Y).hom) ⊗≫ 𝟙 _ := by
rw [← cancel_epi (α_ X Y Z).inv, ← cancel_mono (α_ Z Y X).hom]
convert yang_baxter X Y Z using 1
all_goals coherence
theorem yang_baxter_iso (X Y Z : C) :
(α_ X Y Z).symm ≪≫ whiskerRightIso (β_ X Y) Z ≪≫ α_ Y X Z ≪≫
whiskerLeftIso Y (β_ X Z) ≪≫ (α_ Y Z X).symm ≪≫
whiskerRightIso (β_ Y Z) X ≪≫ (α_ Z Y X) =
whiskerLeftIso X (β_ Y Z) ≪≫ (α_ X Z Y).symm ≪≫
whiskerRightIso (β_ X Z) Y ≪≫ α_ Z X Y ≪≫
whiskerLeftIso Z (β_ X Y) := Iso.ext (yang_baxter X Y Z)
theorem hexagon_forward_iso (X Y Z : C) :
α_ X Y Z ≪≫ β_ X (Y ⊗ Z) ≪≫ α_ Y Z X =
whiskerRightIso (β_ X Y) Z ≪≫ α_ Y X Z ≪≫ whiskerLeftIso Y (β_ X Z) :=
Iso.ext (hexagon_forward X Y Z)
theorem hexagon_reverse_iso (X Y Z : C) :
(α_ X Y Z).symm ≪≫ β_ (X ⊗ Y) Z ≪≫ (α_ Z X Y).symm =
whiskerLeftIso X (β_ Y Z) ≪≫ (α_ X Z Y).symm ≪≫ whiskerRightIso (β_ X Z) Y :=
Iso.ext (hexagon_reverse X Y Z)
@[reassoc]
| Mathlib/CategoryTheory/Monoidal/Braided/Basic.lean | 181 | 184 | theorem hexagon_forward_inv (X Y Z : C) :
(α_ Y Z X).inv ≫ (β_ X (Y ⊗ Z)).inv ≫ (α_ X Y Z).inv =
Y ◁ (β_ X Z).inv ≫ (α_ Y X Z).inv ≫ (β_ X Y).inv ▷ Z := by |
simp
|
import Mathlib.Data.ENNReal.Operations
#align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
open Set NNReal
namespace ENNReal
noncomputable section Inv
variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}
protected theorem div_eq_inv_mul : a / b = b⁻¹ * a := by rw [div_eq_mul_inv, mul_comm]
#align ennreal.div_eq_inv_mul ENNReal.div_eq_inv_mul
@[simp] theorem inv_zero : (0 : ℝ≥0∞)⁻¹ = ∞ :=
show sInf { b : ℝ≥0∞ | 1 ≤ 0 * b } = ∞ by simp
#align ennreal.inv_zero ENNReal.inv_zero
@[simp] theorem inv_top : ∞⁻¹ = 0 :=
bot_unique <| le_of_forall_le_of_dense fun a (h : 0 < a) => sInf_le <| by simp [*, h.ne', top_mul]
#align ennreal.inv_top ENNReal.inv_top
theorem coe_inv_le : (↑r⁻¹ : ℝ≥0∞) ≤ (↑r)⁻¹ :=
le_sInf fun b (hb : 1 ≤ ↑r * b) =>
coe_le_iff.2 <| by
rintro b rfl
apply NNReal.inv_le_of_le_mul
rwa [← coe_mul, ← coe_one, coe_le_coe] at hb
#align ennreal.coe_inv_le ENNReal.coe_inv_le
@[simp, norm_cast]
theorem coe_inv (hr : r ≠ 0) : (↑r⁻¹ : ℝ≥0∞) = (↑r)⁻¹ :=
coe_inv_le.antisymm <| sInf_le <| mem_setOf.2 <| by rw [← coe_mul, mul_inv_cancel hr, coe_one]
#align ennreal.coe_inv ENNReal.coe_inv
@[norm_cast]
theorem coe_inv_two : ((2⁻¹ : ℝ≥0) : ℝ≥0∞) = 2⁻¹ := by rw [coe_inv _root_.two_ne_zero, coe_two]
#align ennreal.coe_inv_two ENNReal.coe_inv_two
@[simp, norm_cast]
theorem coe_div (hr : r ≠ 0) : (↑(p / r) : ℝ≥0∞) = p / r := by
rw [div_eq_mul_inv, div_eq_mul_inv, coe_mul, coe_inv hr]
#align ennreal.coe_div ENNReal.coe_div
lemma coe_div_le : ↑(p / r) ≤ (p / r : ℝ≥0∞) := by
simpa only [div_eq_mul_inv, coe_mul] using mul_le_mul_left' coe_inv_le _
theorem div_zero (h : a ≠ 0) : a / 0 = ∞ := by simp [div_eq_mul_inv, h]
#align ennreal.div_zero ENNReal.div_zero
instance : DivInvOneMonoid ℝ≥0∞ :=
{ inferInstanceAs (DivInvMonoid ℝ≥0∞) with
inv_one := by simpa only [coe_inv one_ne_zero, coe_one] using coe_inj.2 inv_one }
protected theorem inv_pow : ∀ {a : ℝ≥0∞} {n : ℕ}, (a ^ n)⁻¹ = a⁻¹ ^ n
| _, 0 => by simp only [pow_zero, inv_one]
| ⊤, n + 1 => by simp [top_pow]
| (a : ℝ≥0), n + 1 => by
rcases eq_or_ne a 0 with (rfl | ha)
· simp [top_pow]
· have := pow_ne_zero (n + 1) ha
norm_cast
rw [inv_pow]
#align ennreal.inv_pow ENNReal.inv_pow
protected theorem mul_inv_cancel (h0 : a ≠ 0) (ht : a ≠ ∞) : a * a⁻¹ = 1 := by
lift a to ℝ≥0 using ht
norm_cast at h0; norm_cast
exact mul_inv_cancel h0
#align ennreal.mul_inv_cancel ENNReal.mul_inv_cancel
protected theorem inv_mul_cancel (h0 : a ≠ 0) (ht : a ≠ ∞) : a⁻¹ * a = 1 :=
mul_comm a a⁻¹ ▸ ENNReal.mul_inv_cancel h0 ht
#align ennreal.inv_mul_cancel ENNReal.inv_mul_cancel
protected theorem div_mul_cancel (h0 : a ≠ 0) (hI : a ≠ ∞) : b / a * a = b := by
rw [div_eq_mul_inv, mul_assoc, ENNReal.inv_mul_cancel h0 hI, mul_one]
#align ennreal.div_mul_cancel ENNReal.div_mul_cancel
protected theorem mul_div_cancel' (h0 : a ≠ 0) (hI : a ≠ ∞) : a * (b / a) = b := by
rw [mul_comm, ENNReal.div_mul_cancel h0 hI]
#align ennreal.mul_div_cancel' ENNReal.mul_div_cancel'
-- Porting note: `simp only [div_eq_mul_inv, mul_comm, mul_assoc]` doesn't work in the following two
protected theorem mul_comm_div : a / b * c = a * (c / b) := by
simp only [div_eq_mul_inv, mul_right_comm, ← mul_assoc]
#align ennreal.mul_comm_div ENNReal.mul_comm_div
protected theorem mul_div_right_comm : a * b / c = a / c * b := by
simp only [div_eq_mul_inv, mul_right_comm]
#align ennreal.mul_div_right_comm ENNReal.mul_div_right_comm
instance : InvolutiveInv ℝ≥0∞ where
inv_inv a := by
by_cases a = 0 <;> cases a <;> simp_all [none_eq_top, some_eq_coe, -coe_inv, (coe_inv _).symm]
@[simp] protected lemma inv_eq_one : a⁻¹ = 1 ↔ a = 1 := by rw [← inv_inj, inv_inv, inv_one]
@[simp] theorem inv_eq_top : a⁻¹ = ∞ ↔ a = 0 := inv_zero ▸ inv_inj
#align ennreal.inv_eq_top ENNReal.inv_eq_top
theorem inv_ne_top : a⁻¹ ≠ ∞ ↔ a ≠ 0 := by simp
#align ennreal.inv_ne_top ENNReal.inv_ne_top
@[simp]
theorem inv_lt_top {x : ℝ≥0∞} : x⁻¹ < ∞ ↔ 0 < x := by
simp only [lt_top_iff_ne_top, inv_ne_top, pos_iff_ne_zero]
#align ennreal.inv_lt_top ENNReal.inv_lt_top
theorem div_lt_top {x y : ℝ≥0∞} (h1 : x ≠ ∞) (h2 : y ≠ 0) : x / y < ∞ :=
mul_lt_top h1 (inv_ne_top.mpr h2)
#align ennreal.div_lt_top ENNReal.div_lt_top
@[simp]
protected theorem inv_eq_zero : a⁻¹ = 0 ↔ a = ∞ :=
inv_top ▸ inv_inj
#align ennreal.inv_eq_zero ENNReal.inv_eq_zero
protected theorem inv_ne_zero : a⁻¹ ≠ 0 ↔ a ≠ ∞ := by simp
#align ennreal.inv_ne_zero ENNReal.inv_ne_zero
protected theorem div_pos (ha : a ≠ 0) (hb : b ≠ ∞) : 0 < a / b :=
ENNReal.mul_pos ha <| ENNReal.inv_ne_zero.2 hb
#align ennreal.div_pos ENNReal.div_pos
protected theorem mul_inv {a b : ℝ≥0∞} (ha : a ≠ 0 ∨ b ≠ ∞) (hb : a ≠ ∞ ∨ b ≠ 0) :
(a * b)⁻¹ = a⁻¹ * b⁻¹ := by
induction' b with b
· replace ha : a ≠ 0 := ha.neg_resolve_right rfl
simp [ha]
induction' a with a
· replace hb : b ≠ 0 := coe_ne_zero.1 (hb.neg_resolve_left rfl)
simp [hb]
by_cases h'a : a = 0
· simp only [h'a, top_mul, ENNReal.inv_zero, ENNReal.coe_ne_top, zero_mul, Ne,
not_false_iff, ENNReal.coe_zero, ENNReal.inv_eq_zero]
by_cases h'b : b = 0
· simp only [h'b, ENNReal.inv_zero, ENNReal.coe_ne_top, mul_top, Ne, not_false_iff,
mul_zero, ENNReal.coe_zero, ENNReal.inv_eq_zero]
rw [← ENNReal.coe_mul, ← ENNReal.coe_inv, ← ENNReal.coe_inv h'a, ← ENNReal.coe_inv h'b, ←
ENNReal.coe_mul, mul_inv_rev, mul_comm]
simp [h'a, h'b]
#align ennreal.mul_inv ENNReal.mul_inv
protected theorem mul_div_mul_left (a b : ℝ≥0∞) (hc : c ≠ 0) (hc' : c ≠ ⊤) :
c * a / (c * b) = a / b := by
rw [div_eq_mul_inv, div_eq_mul_inv, ENNReal.mul_inv (Or.inl hc) (Or.inl hc'), mul_mul_mul_comm,
ENNReal.mul_inv_cancel hc hc', one_mul]
#align ennreal.mul_div_mul_left ENNReal.mul_div_mul_left
protected theorem mul_div_mul_right (a b : ℝ≥0∞) (hc : c ≠ 0) (hc' : c ≠ ⊤) :
a * c / (b * c) = a / b := by
rw [div_eq_mul_inv, div_eq_mul_inv, ENNReal.mul_inv (Or.inr hc') (Or.inr hc), mul_mul_mul_comm,
ENNReal.mul_inv_cancel hc hc', mul_one]
#align ennreal.mul_div_mul_right ENNReal.mul_div_mul_right
protected theorem sub_div (h : 0 < b → b < a → c ≠ 0) : (a - b) / c = a / c - b / c := by
simp_rw [div_eq_mul_inv]
exact ENNReal.sub_mul (by simpa using h)
#align ennreal.sub_div ENNReal.sub_div
@[simp]
protected theorem inv_pos : 0 < a⁻¹ ↔ a ≠ ∞ :=
pos_iff_ne_zero.trans ENNReal.inv_ne_zero
#align ennreal.inv_pos ENNReal.inv_pos
theorem inv_strictAnti : StrictAnti (Inv.inv : ℝ≥0∞ → ℝ≥0∞) := by
intro a b h
lift a to ℝ≥0 using h.ne_top
induction b; · simp
rw [coe_lt_coe] at h
rcases eq_or_ne a 0 with (rfl | ha); · simp [h]
rw [← coe_inv h.ne_bot, ← coe_inv ha, coe_lt_coe]
exact NNReal.inv_lt_inv ha h
#align ennreal.inv_strict_anti ENNReal.inv_strictAnti
@[simp]
protected theorem inv_lt_inv : a⁻¹ < b⁻¹ ↔ b < a :=
inv_strictAnti.lt_iff_lt
#align ennreal.inv_lt_inv ENNReal.inv_lt_inv
theorem inv_lt_iff_inv_lt : a⁻¹ < b ↔ b⁻¹ < a := by
simpa only [inv_inv] using @ENNReal.inv_lt_inv a b⁻¹
#align ennreal.inv_lt_iff_inv_lt ENNReal.inv_lt_iff_inv_lt
theorem lt_inv_iff_lt_inv : a < b⁻¹ ↔ b < a⁻¹ := by
simpa only [inv_inv] using @ENNReal.inv_lt_inv a⁻¹ b
#align ennreal.lt_inv_iff_lt_inv ENNReal.lt_inv_iff_lt_inv
@[simp]
protected theorem inv_le_inv : a⁻¹ ≤ b⁻¹ ↔ b ≤ a :=
inv_strictAnti.le_iff_le
#align ennreal.inv_le_inv ENNReal.inv_le_inv
theorem inv_le_iff_inv_le : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by
simpa only [inv_inv] using @ENNReal.inv_le_inv a b⁻¹
#align ennreal.inv_le_iff_inv_le ENNReal.inv_le_iff_inv_le
theorem le_inv_iff_le_inv : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by
simpa only [inv_inv] using @ENNReal.inv_le_inv a⁻¹ b
#align ennreal.le_inv_iff_le_inv ENNReal.le_inv_iff_le_inv
@[gcongr] protected theorem inv_le_inv' (h : a ≤ b) : b⁻¹ ≤ a⁻¹ :=
ENNReal.inv_strictAnti.antitone h
@[gcongr] protected theorem inv_lt_inv' (h : a < b) : b⁻¹ < a⁻¹ := ENNReal.inv_strictAnti h
@[simp]
protected theorem inv_le_one : a⁻¹ ≤ 1 ↔ 1 ≤ a := by rw [inv_le_iff_inv_le, inv_one]
#align ennreal.inv_le_one ENNReal.inv_le_one
protected theorem one_le_inv : 1 ≤ a⁻¹ ↔ a ≤ 1 := by rw [le_inv_iff_le_inv, inv_one]
#align ennreal.one_le_inv ENNReal.one_le_inv
@[simp]
protected theorem inv_lt_one : a⁻¹ < 1 ↔ 1 < a := by rw [inv_lt_iff_inv_lt, inv_one]
#align ennreal.inv_lt_one ENNReal.inv_lt_one
@[simp]
protected theorem one_lt_inv : 1 < a⁻¹ ↔ a < 1 := by rw [lt_inv_iff_lt_inv, inv_one]
#align ennreal.one_lt_inv ENNReal.one_lt_inv
@[simps! apply]
def _root_.OrderIso.invENNReal : ℝ≥0∞ ≃o ℝ≥0∞ᵒᵈ where
map_rel_iff' := ENNReal.inv_le_inv
toEquiv := (Equiv.inv ℝ≥0∞).trans OrderDual.toDual
#align order_iso.inv_ennreal OrderIso.invENNReal
#align order_iso.inv_ennreal_apply OrderIso.invENNReal_apply
@[simp]
theorem _root_.OrderIso.invENNReal_symm_apply (a : ℝ≥0∞ᵒᵈ) :
OrderIso.invENNReal.symm a = (OrderDual.ofDual a)⁻¹ :=
rfl
#align order_iso.inv_ennreal_symm_apply OrderIso.invENNReal_symm_apply
@[simp] theorem div_top : a / ∞ = 0 := by rw [div_eq_mul_inv, inv_top, mul_zero]
#align ennreal.div_top ENNReal.div_top
-- Porting note: reordered 4 lemmas
theorem top_div : ∞ / a = if a = ∞ then 0 else ∞ := by simp [div_eq_mul_inv, top_mul']
#align ennreal.top_div ENNReal.top_div
theorem top_div_of_ne_top (h : a ≠ ∞) : ∞ / a = ∞ := by simp [top_div, h]
#align ennreal.top_div_of_ne_top ENNReal.top_div_of_ne_top
@[simp] theorem top_div_coe : ∞ / p = ∞ := top_div_of_ne_top coe_ne_top
#align ennreal.top_div_coe ENNReal.top_div_coe
theorem top_div_of_lt_top (h : a < ∞) : ∞ / a = ∞ := top_div_of_ne_top h.ne
#align ennreal.top_div_of_lt_top ENNReal.top_div_of_lt_top
@[simp] protected theorem zero_div : 0 / a = 0 := zero_mul a⁻¹
#align ennreal.zero_div ENNReal.zero_div
theorem div_eq_top : a / b = ∞ ↔ a ≠ 0 ∧ b = 0 ∨ a = ∞ ∧ b ≠ ∞ := by
simp [div_eq_mul_inv, ENNReal.mul_eq_top]
#align ennreal.div_eq_top ENNReal.div_eq_top
protected theorem le_div_iff_mul_le (h0 : b ≠ 0 ∨ c ≠ 0) (ht : b ≠ ∞ ∨ c ≠ ∞) :
a ≤ c / b ↔ a * b ≤ c := by
induction' b with b
· lift c to ℝ≥0 using ht.neg_resolve_left rfl
rw [div_top, nonpos_iff_eq_zero]
rcases eq_or_ne a 0 with (rfl | ha) <;> simp [*]
rcases eq_or_ne b 0 with (rfl | hb)
· have hc : c ≠ 0 := h0.neg_resolve_left rfl
simp [div_zero hc]
· rw [← coe_ne_zero] at hb
rw [← ENNReal.mul_le_mul_right hb coe_ne_top, ENNReal.div_mul_cancel hb coe_ne_top]
#align ennreal.le_div_iff_mul_le ENNReal.le_div_iff_mul_le
protected theorem div_le_iff_le_mul (hb0 : b ≠ 0 ∨ c ≠ ∞) (hbt : b ≠ ∞ ∨ c ≠ 0) :
a / b ≤ c ↔ a ≤ c * b := by
suffices a * b⁻¹ ≤ c ↔ a ≤ c / b⁻¹ by simpa [div_eq_mul_inv]
refine (ENNReal.le_div_iff_mul_le ?_ ?_).symm <;> simpa
#align ennreal.div_le_iff_le_mul ENNReal.div_le_iff_le_mul
protected theorem lt_div_iff_mul_lt (hb0 : b ≠ 0 ∨ c ≠ ∞) (hbt : b ≠ ∞ ∨ c ≠ 0) :
c < a / b ↔ c * b < a :=
lt_iff_lt_of_le_iff_le (ENNReal.div_le_iff_le_mul hb0 hbt)
#align ennreal.lt_div_iff_mul_lt ENNReal.lt_div_iff_mul_lt
theorem div_le_of_le_mul (h : a ≤ b * c) : a / c ≤ b := by
by_cases h0 : c = 0
· have : a = 0 := by simpa [h0] using h
simp [*]
by_cases hinf : c = ∞; · simp [hinf]
exact (ENNReal.div_le_iff_le_mul (Or.inl h0) (Or.inl hinf)).2 h
#align ennreal.div_le_of_le_mul ENNReal.div_le_of_le_mul
theorem div_le_of_le_mul' (h : a ≤ b * c) : a / b ≤ c :=
div_le_of_le_mul <| mul_comm b c ▸ h
#align ennreal.div_le_of_le_mul' ENNReal.div_le_of_le_mul'
protected theorem div_self_le_one : a / a ≤ 1 := div_le_of_le_mul <| by rw [one_mul]
theorem mul_le_of_le_div (h : a ≤ b / c) : a * c ≤ b := by
rw [← inv_inv c]
exact div_le_of_le_mul h
#align ennreal.mul_le_of_le_div ENNReal.mul_le_of_le_div
theorem mul_le_of_le_div' (h : a ≤ b / c) : c * a ≤ b :=
mul_comm a c ▸ mul_le_of_le_div h
#align ennreal.mul_le_of_le_div' ENNReal.mul_le_of_le_div'
protected theorem div_lt_iff (h0 : b ≠ 0 ∨ c ≠ 0) (ht : b ≠ ∞ ∨ c ≠ ∞) : c / b < a ↔ c < a * b :=
lt_iff_lt_of_le_iff_le <| ENNReal.le_div_iff_mul_le h0 ht
#align ennreal.div_lt_iff ENNReal.div_lt_iff
theorem mul_lt_of_lt_div (h : a < b / c) : a * c < b := by
contrapose! h
exact ENNReal.div_le_of_le_mul h
#align ennreal.mul_lt_of_lt_div ENNReal.mul_lt_of_lt_div
theorem mul_lt_of_lt_div' (h : a < b / c) : c * a < b :=
mul_comm a c ▸ mul_lt_of_lt_div h
#align ennreal.mul_lt_of_lt_div' ENNReal.mul_lt_of_lt_div'
theorem div_lt_of_lt_mul (h : a < b * c) : a / c < b :=
mul_lt_of_lt_div <| by rwa [div_eq_mul_inv, inv_inv]
theorem div_lt_of_lt_mul' (h : a < b * c) : a / b < c :=
div_lt_of_lt_mul <| by rwa [mul_comm]
theorem inv_le_iff_le_mul (h₁ : b = ∞ → a ≠ 0) (h₂ : a = ∞ → b ≠ 0) : a⁻¹ ≤ b ↔ 1 ≤ a * b := by
rw [← one_div, ENNReal.div_le_iff_le_mul, mul_comm]
exacts [or_not_of_imp h₁, not_or_of_imp h₂]
#align ennreal.inv_le_iff_le_mul ENNReal.inv_le_iff_le_mul
@[simp 900]
theorem le_inv_iff_mul_le : a ≤ b⁻¹ ↔ a * b ≤ 1 := by
rw [← one_div, ENNReal.le_div_iff_mul_le] <;>
· right
simp
#align ennreal.le_inv_iff_mul_le ENNReal.le_inv_iff_mul_le
@[gcongr] protected theorem div_le_div (hab : a ≤ b) (hdc : d ≤ c) : a / c ≤ b / d :=
div_eq_mul_inv b d ▸ div_eq_mul_inv a c ▸ mul_le_mul' hab (ENNReal.inv_le_inv.mpr hdc)
#align ennreal.div_le_div ENNReal.div_le_div
@[gcongr] protected theorem div_le_div_left (h : a ≤ b) (c : ℝ≥0∞) : c / b ≤ c / a :=
ENNReal.div_le_div le_rfl h
#align ennreal.div_le_div_left ENNReal.div_le_div_left
@[gcongr] protected theorem div_le_div_right (h : a ≤ b) (c : ℝ≥0∞) : a / c ≤ b / c :=
ENNReal.div_le_div h le_rfl
#align ennreal.div_le_div_right ENNReal.div_le_div_right
protected theorem eq_inv_of_mul_eq_one_left (h : a * b = 1) : a = b⁻¹ := by
rw [← mul_one a, ← ENNReal.mul_inv_cancel (right_ne_zero_of_mul_eq_one h), ← mul_assoc, h,
one_mul]
rintro rfl
simp [left_ne_zero_of_mul_eq_one h] at h
#align ennreal.eq_inv_of_mul_eq_one_left ENNReal.eq_inv_of_mul_eq_one_left
theorem mul_le_iff_le_inv {a b r : ℝ≥0∞} (hr₀ : r ≠ 0) (hr₁ : r ≠ ∞) : r * a ≤ b ↔ a ≤ r⁻¹ * b := by
rw [← @ENNReal.mul_le_mul_left _ a _ hr₀ hr₁, ← mul_assoc, ENNReal.mul_inv_cancel hr₀ hr₁,
one_mul]
#align ennreal.mul_le_iff_le_inv ENNReal.mul_le_iff_le_inv
instance : PosSMulStrictMono ℝ≥0 ℝ≥0∞ where
elim _r hr _a _b hab := ENNReal.mul_lt_mul_left' (coe_pos.2 hr).ne' coe_ne_top hab
instance : SMulPosMono ℝ≥0 ℝ≥0∞ where
elim _r _ _a _b hab := mul_le_mul_right' (coe_le_coe.2 hab) _
#align ennreal.le_inv_smul_iff_of_pos le_inv_smul_iff_of_pos
#align ennreal.inv_smul_le_iff_of_pos inv_smul_le_iff_of_pos
theorem le_of_forall_nnreal_lt {x y : ℝ≥0∞} (h : ∀ r : ℝ≥0, ↑r < x → ↑r ≤ y) : x ≤ y := by
refine le_of_forall_ge_of_dense fun r hr => ?_
lift r to ℝ≥0 using ne_top_of_lt hr
exact h r hr
#align ennreal.le_of_forall_nnreal_lt ENNReal.le_of_forall_nnreal_lt
theorem le_of_forall_pos_nnreal_lt {x y : ℝ≥0∞} (h : ∀ r : ℝ≥0, 0 < r → ↑r < x → ↑r ≤ y) : x ≤ y :=
le_of_forall_nnreal_lt fun r hr =>
(zero_le r).eq_or_lt.elim (fun h => h ▸ zero_le _) fun h0 => h r h0 hr
#align ennreal.le_of_forall_pos_nnreal_lt ENNReal.le_of_forall_pos_nnreal_lt
theorem eq_top_of_forall_nnreal_le {x : ℝ≥0∞} (h : ∀ r : ℝ≥0, ↑r ≤ x) : x = ∞ :=
top_unique <| le_of_forall_nnreal_lt fun r _ => h r
#align ennreal.eq_top_of_forall_nnreal_le ENNReal.eq_top_of_forall_nnreal_le
protected theorem add_div : (a + b) / c = a / c + b / c :=
right_distrib a b c⁻¹
#align ennreal.add_div ENNReal.add_div
protected theorem div_add_div_same {a b c : ℝ≥0∞} : a / c + b / c = (a + b) / c :=
ENNReal.add_div.symm
#align ennreal.div_add_div_same ENNReal.div_add_div_same
protected theorem div_self (h0 : a ≠ 0) (hI : a ≠ ∞) : a / a = 1 :=
ENNReal.mul_inv_cancel h0 hI
#align ennreal.div_self ENNReal.div_self
theorem mul_div_le : a * (b / a) ≤ b :=
mul_le_of_le_div' le_rfl
#align ennreal.mul_div_le ENNReal.mul_div_le
theorem eq_div_iff (ha : a ≠ 0) (ha' : a ≠ ∞) : b = c / a ↔ a * b = c :=
⟨fun h => by rw [h, ENNReal.mul_div_cancel' ha ha'], fun h => by
rw [← h, mul_div_assoc, ENNReal.mul_div_cancel' ha ha']⟩
#align ennreal.eq_div_iff ENNReal.eq_div_iff
protected theorem div_eq_div_iff (ha : a ≠ 0) (ha' : a ≠ ∞) (hb : b ≠ 0) (hb' : b ≠ ∞) :
c / b = d / a ↔ a * c = b * d := by
rw [eq_div_iff ha ha']
conv_rhs => rw [eq_comm]
rw [← eq_div_iff hb hb', mul_div_assoc, eq_comm]
#align ennreal.div_eq_div_iff ENNReal.div_eq_div_iff
theorem div_eq_one_iff {a b : ℝ≥0∞} (hb₀ : b ≠ 0) (hb₁ : b ≠ ∞) : a / b = 1 ↔ a = b :=
⟨fun h => by rw [← (eq_div_iff hb₀ hb₁).mp h.symm, mul_one], fun h =>
h.symm ▸ ENNReal.div_self hb₀ hb₁⟩
#align ennreal.div_eq_one_iff ENNReal.div_eq_one_iff
theorem inv_two_add_inv_two : (2 : ℝ≥0∞)⁻¹ + 2⁻¹ = 1 := by
rw [← two_mul, ← div_eq_mul_inv, ENNReal.div_self two_ne_zero two_ne_top]
#align ennreal.inv_two_add_inv_two ENNReal.inv_two_add_inv_two
theorem inv_three_add_inv_three : (3 : ℝ≥0∞)⁻¹ + 3⁻¹ + 3⁻¹ = 1 :=
calc (3 : ℝ≥0∞)⁻¹ + 3⁻¹ + 3⁻¹ = 3 * 3⁻¹ := by ring
_ = 1 := ENNReal.mul_inv_cancel (Nat.cast_ne_zero.2 <| by decide) coe_ne_top
#align ennreal.inv_three_add_inv_three ENNReal.inv_three_add_inv_three
@[simp]
protected theorem add_halves (a : ℝ≥0∞) : a / 2 + a / 2 = a := by
rw [div_eq_mul_inv, ← mul_add, inv_two_add_inv_two, mul_one]
#align ennreal.add_halves ENNReal.add_halves
@[simp]
theorem add_thirds (a : ℝ≥0∞) : a / 3 + a / 3 + a / 3 = a := by
rw [div_eq_mul_inv, ← mul_add, ← mul_add, inv_three_add_inv_three, mul_one]
#align ennreal.add_thirds ENNReal.add_thirds
@[simp] theorem div_eq_zero_iff : a / b = 0 ↔ a = 0 ∨ b = ∞ := by simp [div_eq_mul_inv]
#align ennreal.div_zero_iff ENNReal.div_eq_zero_iff
@[simp] theorem div_pos_iff : 0 < a / b ↔ a ≠ 0 ∧ b ≠ ∞ := by simp [pos_iff_ne_zero, not_or]
#align ennreal.div_pos_iff ENNReal.div_pos_iff
protected theorem half_pos (h : a ≠ 0) : 0 < a / 2 := by
simp only [div_pos_iff, ne_eq, h, not_false_eq_true, two_ne_top, and_self]
#align ennreal.half_pos ENNReal.half_pos
protected theorem one_half_lt_one : (2⁻¹ : ℝ≥0∞) < 1 :=
ENNReal.inv_lt_one.2 <| one_lt_two
#align ennreal.one_half_lt_one ENNReal.one_half_lt_one
protected theorem half_lt_self (hz : a ≠ 0) (ht : a ≠ ∞) : a / 2 < a := by
lift a to ℝ≥0 using ht
rw [coe_ne_zero] at hz
rw [← coe_two, ← coe_div, coe_lt_coe]
exacts [NNReal.half_lt_self hz, two_ne_zero' _]
#align ennreal.half_lt_self ENNReal.half_lt_self
protected theorem half_le_self : a / 2 ≤ a :=
le_add_self.trans_eq <| ENNReal.add_halves _
#align ennreal.half_le_self ENNReal.half_le_self
theorem sub_half (h : a ≠ ∞) : a - a / 2 = a / 2 := by
lift a to ℝ≥0 using h
exact sub_eq_of_add_eq (mul_ne_top coe_ne_top <| by simp) (ENNReal.add_halves a)
#align ennreal.sub_half ENNReal.sub_half
@[simp]
theorem one_sub_inv_two : (1 : ℝ≥0∞) - 2⁻¹ = 2⁻¹ := by
simpa only [div_eq_mul_inv, one_mul] using sub_half one_ne_top
#align ennreal.one_sub_inv_two ENNReal.one_sub_inv_two
@[simps! apply_coe]
def orderIsoIicOneBirational : ℝ≥0∞ ≃o Iic (1 : ℝ≥0∞) := by
refine StrictMono.orderIsoOfRightInverse
(fun x => ⟨(x⁻¹ + 1)⁻¹, ENNReal.inv_le_one.2 <| le_add_self⟩)
(fun x y hxy => ?_) (fun x => (x.1⁻¹ - 1)⁻¹) fun x => Subtype.ext ?_
· simpa only [Subtype.mk_lt_mk, ENNReal.inv_lt_inv, ENNReal.add_lt_add_iff_right one_ne_top]
· have : (1 : ℝ≥0∞) ≤ x.1⁻¹ := ENNReal.one_le_inv.2 x.2
simp only [inv_inv, Subtype.coe_mk, tsub_add_cancel_of_le this]
#align ennreal.order_iso_Iic_one_birational ENNReal.orderIsoIicOneBirational
@[simp]
theorem orderIsoIicOneBirational_symm_apply (x : Iic (1 : ℝ≥0∞)) :
orderIsoIicOneBirational.symm x = (x.1⁻¹ - 1)⁻¹ :=
rfl
#align ennreal.order_iso_Iic_one_birational_symm_apply ENNReal.orderIsoIicOneBirational_symm_apply
@[simps! apply_coe]
def orderIsoIicCoe (a : ℝ≥0) : Iic (a : ℝ≥0∞) ≃o Iic a :=
OrderIso.symm
{ toFun := fun x => ⟨x, coe_le_coe.2 x.2⟩
invFun := fun x => ⟨ENNReal.toNNReal x, coe_le_coe.1 <| coe_toNNReal_le_self.trans x.2⟩
left_inv := fun x => Subtype.ext <| toNNReal_coe
right_inv := fun x => Subtype.ext <| coe_toNNReal (ne_top_of_le_ne_top coe_ne_top x.2)
map_rel_iff' := fun {_ _} => by
simp only [Equiv.coe_fn_mk, Subtype.mk_le_mk, coe_le_coe, Subtype.coe_le_coe] }
#align ennreal.order_iso_Iic_coe ENNReal.orderIsoIicCoe
@[simp]
theorem orderIsoIicCoe_symm_apply_coe (a : ℝ≥0) (b : Iic a) :
((orderIsoIicCoe a).symm b : ℝ≥0∞) = b :=
rfl
#align ennreal.order_iso_Iic_coe_symm_apply_coe ENNReal.orderIsoIicCoe_symm_apply_coe
def orderIsoUnitIntervalBirational : ℝ≥0∞ ≃o Icc (0 : ℝ) 1 :=
orderIsoIicOneBirational.trans <| (orderIsoIicCoe 1).trans <| (NNReal.orderIsoIccZeroCoe 1).symm
#align ennreal.order_iso_unit_interval_birational ENNReal.orderIsoUnitIntervalBirational
@[simp]
theorem orderIsoUnitIntervalBirational_apply_coe (x : ℝ≥0∞) :
(orderIsoUnitIntervalBirational x : ℝ) = (x⁻¹ + 1)⁻¹.toReal :=
rfl
#align ennreal.order_iso_unit_interval_birational_apply_coe ENNReal.orderIsoUnitIntervalBirational_apply_coe
theorem exists_inv_nat_lt {a : ℝ≥0∞} (h : a ≠ 0) : ∃ n : ℕ, (n : ℝ≥0∞)⁻¹ < a :=
inv_inv a ▸ by simp only [ENNReal.inv_lt_inv, ENNReal.exists_nat_gt (inv_ne_top.2 h)]
#align ennreal.exists_inv_nat_lt ENNReal.exists_inv_nat_lt
theorem exists_nat_pos_mul_gt (ha : a ≠ 0) (hb : b ≠ ∞) : ∃ n > 0, b < (n : ℕ) * a :=
let ⟨n, hn⟩ := ENNReal.exists_nat_gt (div_lt_top hb ha).ne
⟨n, Nat.cast_pos.1 ((zero_le _).trans_lt hn), by
rwa [← ENNReal.div_lt_iff (Or.inl ha) (Or.inr hb)]⟩
#align ennreal.exists_nat_pos_mul_gt ENNReal.exists_nat_pos_mul_gt
theorem exists_nat_mul_gt (ha : a ≠ 0) (hb : b ≠ ∞) : ∃ n : ℕ, b < n * a :=
(exists_nat_pos_mul_gt ha hb).imp fun _ => And.right
#align ennreal.exists_nat_mul_gt ENNReal.exists_nat_mul_gt
theorem exists_nat_pos_inv_mul_lt (ha : a ≠ ∞) (hb : b ≠ 0) :
∃ n > 0, ((n : ℕ) : ℝ≥0∞)⁻¹ * a < b := by
rcases exists_nat_pos_mul_gt hb ha with ⟨n, npos, hn⟩
use n, npos
rw [← ENNReal.div_eq_inv_mul]
exact div_lt_of_lt_mul' hn
#align ennreal.exists_nat_pos_inv_mul_lt ENNReal.exists_nat_pos_inv_mul_lt
| Mathlib/Data/ENNReal/Inv.lean | 573 | 576 | theorem exists_nnreal_pos_mul_lt (ha : a ≠ ∞) (hb : b ≠ 0) : ∃ n > 0, ↑(n : ℝ≥0) * a < b := by |
rcases exists_nat_pos_inv_mul_lt ha hb with ⟨n, npos : 0 < n, hn⟩
use (n : ℝ≥0)⁻¹
simp [*, npos.ne', zero_lt_one]
|
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.Data.Set.MemPartition
import Mathlib.Order.Filter.CountableSeparatingOn
open Set MeasureTheory
namespace MeasurableSpace
variable {α β : Type*}
class CountablyGenerated (α : Type*) [m : MeasurableSpace α] : Prop where
isCountablyGenerated : ∃ b : Set (Set α), b.Countable ∧ m = generateFrom b
#align measurable_space.countably_generated MeasurableSpace.CountablyGenerated
def countableGeneratingSet (α : Type*) [MeasurableSpace α] [h : CountablyGenerated α] :
Set (Set α) :=
insert ∅ h.isCountablyGenerated.choose
lemma countable_countableGeneratingSet [MeasurableSpace α] [h : CountablyGenerated α] :
Set.Countable (countableGeneratingSet α) :=
Countable.insert _ h.isCountablyGenerated.choose_spec.1
lemma generateFrom_countableGeneratingSet [m : MeasurableSpace α] [h : CountablyGenerated α] :
generateFrom (countableGeneratingSet α) = m :=
(generateFrom_insert_empty _).trans <| h.isCountablyGenerated.choose_spec.2.symm
lemma empty_mem_countableGeneratingSet [MeasurableSpace α] [CountablyGenerated α] :
∅ ∈ countableGeneratingSet α := mem_insert _ _
lemma nonempty_countableGeneratingSet [MeasurableSpace α] [CountablyGenerated α] :
Set.Nonempty (countableGeneratingSet α) :=
⟨∅, mem_insert _ _⟩
lemma measurableSet_countableGeneratingSet [MeasurableSpace α] [CountablyGenerated α]
{s : Set α} (hs : s ∈ countableGeneratingSet α) :
MeasurableSet s := by
rw [← generateFrom_countableGeneratingSet (α := α)]
exact measurableSet_generateFrom hs
def natGeneratingSequence (α : Type*) [MeasurableSpace α] [CountablyGenerated α] : ℕ → (Set α) :=
enumerateCountable (countable_countableGeneratingSet (α := α)) ∅
lemma generateFrom_natGeneratingSequence (α : Type*) [m : MeasurableSpace α]
[CountablyGenerated α] : generateFrom (range (natGeneratingSequence _)) = m := by
rw [natGeneratingSequence, range_enumerateCountable_of_mem _ empty_mem_countableGeneratingSet,
generateFrom_countableGeneratingSet]
lemma measurableSet_natGeneratingSequence [MeasurableSpace α] [CountablyGenerated α] (n : ℕ) :
MeasurableSet (natGeneratingSequence α n) :=
measurableSet_countableGeneratingSet $ Set.enumerateCountable_mem _
empty_mem_countableGeneratingSet n
theorem CountablyGenerated.comap [m : MeasurableSpace β] [h : CountablyGenerated β] (f : α → β) :
@CountablyGenerated α (.comap f m) := by
rcases h with ⟨⟨b, hbc, rfl⟩⟩
rw [comap_generateFrom]
letI := generateFrom (preimage f '' b)
exact ⟨_, hbc.image _, rfl⟩
theorem CountablyGenerated.sup {m₁ m₂ : MeasurableSpace β} (h₁ : @CountablyGenerated β m₁)
(h₂ : @CountablyGenerated β m₂) : @CountablyGenerated β (m₁ ⊔ m₂) := by
rcases h₁ with ⟨⟨b₁, hb₁c, rfl⟩⟩
rcases h₂ with ⟨⟨b₂, hb₂c, rfl⟩⟩
exact @mk _ (_ ⊔ _) ⟨_, hb₁c.union hb₂c, generateFrom_sup_generateFrom⟩
instance (priority := 100) [MeasurableSpace α] [Countable α] : CountablyGenerated α where
isCountablyGenerated := by
refine ⟨⋃ y, {measurableAtom y}, countable_iUnion (fun i ↦ countable_singleton _), ?_⟩
refine le_antisymm ?_ (generateFrom_le (by simp [MeasurableSet.measurableAtom_of_countable]))
intro s hs
have : s = ⋃ y ∈ s, measurableAtom y := by
apply Subset.antisymm
· intro x hx
simpa using ⟨x, hx, by simp⟩
· simp only [iUnion_subset_iff]
intro x hx
exact measurableAtom_subset hs hx
rw [this]
apply MeasurableSet.biUnion (to_countable s) (fun x _hx ↦ ?_)
apply measurableSet_generateFrom
simp
instance [MeasurableSpace α] [CountablyGenerated α] {p : α → Prop} :
CountablyGenerated { x // p x } := .comap _
instance [MeasurableSpace α] [CountablyGenerated α] [MeasurableSpace β] [CountablyGenerated β] :
CountablyGenerated (α × β) :=
.sup (.comap Prod.fst) (.comap Prod.snd)
section SeparatesPoints
class SeparatesPoints (α : Type*) [m : MeasurableSpace α] : Prop where
separates : ∀ x y : α, (∀ s, MeasurableSet s → (x ∈ s → y ∈ s)) → x = y
theorem separatesPoints_def [MeasurableSpace α] [hs : SeparatesPoints α] {x y : α}
(h : ∀ s, MeasurableSet s → (x ∈ s → y ∈ s)) : x = y := hs.separates _ _ h
theorem exists_measurableSet_of_ne [MeasurableSpace α] [SeparatesPoints α] {x y : α}
(h : x ≠ y) : ∃ s, MeasurableSet s ∧ x ∈ s ∧ y ∉ s := by
contrapose! h
exact separatesPoints_def h
theorem separatesPoints_iff [MeasurableSpace α] : SeparatesPoints α ↔
∀ x y : α, (∀ s, MeasurableSet s → (x ∈ s ↔ y ∈ s)) → x = y :=
⟨fun h ↦ fun _ _ hxy ↦ h.separates _ _ fun _ hs xs ↦ (hxy _ hs).mp xs,
fun h ↦ ⟨fun _ _ hxy ↦ h _ _ fun _ hs ↦
⟨fun xs ↦ hxy _ hs xs, not_imp_not.mp fun xs ↦ hxy _ hs.compl xs⟩⟩⟩
theorem separating_of_generateFrom (S : Set (Set α))
[h : @SeparatesPoints α (generateFrom S)] :
∀ x y : α, (∀ s ∈ S, x ∈ s ↔ y ∈ s) → x = y := by
letI := generateFrom S
intros x y hxy
rw [← forall_generateFrom_mem_iff_mem_iff] at hxy
exact separatesPoints_def $ fun _ hs ↦ (hxy _ hs).mp
theorem SeparatesPoints.mono {m m' : MeasurableSpace α} [hsep : @SeparatesPoints _ m] (h : m ≤ m') :
@SeparatesPoints _ m' := @SeparatesPoints.mk _ m' fun _ _ hxy ↦
@SeparatesPoints.separates _ m hsep _ _ fun _ hs ↦ hxy _ (h _ hs)
class CountablySeparated (α : Type*) [MeasurableSpace α] : Prop where
countably_separated : HasCountableSeparatingOn α MeasurableSet univ
instance countablySeparated_of_hasCountableSeparatingOn [MeasurableSpace α]
[h : HasCountableSeparatingOn α MeasurableSet univ] : CountablySeparated α := ⟨h⟩
instance hasCountableSeparatingOn_of_countablySeparated [MeasurableSpace α]
[h : CountablySeparated α] : HasCountableSeparatingOn α MeasurableSet univ :=
h.countably_separated
theorem countablySeparated_def [MeasurableSpace α] :
CountablySeparated α ↔ HasCountableSeparatingOn α MeasurableSet univ :=
⟨fun h ↦ h.countably_separated, fun h ↦ ⟨h⟩⟩
| Mathlib/MeasureTheory/MeasurableSpace/CountablyGenerated.lean | 185 | 189 | theorem CountablySeparated.mono {m m' : MeasurableSpace α} [hsep : @CountablySeparated _ m]
(h : m ≤ m') : @CountablySeparated _ m' := by |
simp_rw [countablySeparated_def] at *
rcases hsep with ⟨S, Sct, Smeas, hS⟩
use S, Sct, (fun s hs ↦ h _ <| Smeas _ hs), hS
|
import Mathlib.MeasureTheory.Measure.Lebesgue.Complex
import Mathlib.MeasureTheory.Integral.DivergenceTheorem
import Mathlib.MeasureTheory.Integral.CircleIntegral
import Mathlib.Analysis.Calculus.Dslope
import Mathlib.Analysis.Analytic.Basic
import Mathlib.Analysis.Complex.ReImTopology
import Mathlib.Analysis.Calculus.DiffContOnCl
import Mathlib.Analysis.Calculus.FDeriv.Analytic
import Mathlib.Data.Real.Cardinality
#align_import analysis.complex.cauchy_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
open TopologicalSpace Set MeasureTheory intervalIntegral Metric Filter Function
open scoped Interval Real NNReal ENNReal Topology
noncomputable section
universe u
variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E]
namespace Complex
theorem integral_boundary_rect_of_hasFDerivAt_real_off_countable (f : ℂ → E) (f' : ℂ → ℂ →L[ℝ] E)
(z w : ℂ) (s : Set ℂ) (hs : s.Countable)
(Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]]))
(Hd : ∀ x ∈ Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im) \ s,
HasFDerivAt f (f' x) x)
(Hi : IntegrableOn (fun z => I • f' z 1 - f' z I) ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) :
(∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) +
I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) -
I • ∫ y : ℝ in z.im..w.im, f (re z + y * I) =
∫ x : ℝ in z.re..w.re, ∫ y : ℝ in z.im..w.im, I • f' (x + y * I) 1 - f' (x + y * I) I := by
set e : (ℝ × ℝ) ≃L[ℝ] ℂ := equivRealProdCLM.symm
have he : ∀ x y : ℝ, ↑x + ↑y * I = e (x, y) := fun x y => (mk_eq_add_mul_I x y).symm
have he₁ : e (1, 0) = 1 := rfl; have he₂ : e (0, 1) = I := rfl
simp only [he] at *
set F : ℝ × ℝ → E := f ∘ e
set F' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E := fun p => (f' (e p)).comp (e : ℝ × ℝ →L[ℝ] ℂ)
have hF' : ∀ p : ℝ × ℝ, (-(I • F' p)) (1, 0) + F' p (0, 1) = -(I • f' (e p) 1 - f' (e p) I) := by
rintro ⟨x, y⟩
simp only [F', ContinuousLinearMap.neg_apply, ContinuousLinearMap.smul_apply,
ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe, he₁, he₂, neg_add_eq_sub,
neg_sub]
set R : Set (ℝ × ℝ) := [[z.re, w.re]] ×ˢ [[w.im, z.im]]
set t : Set (ℝ × ℝ) := e ⁻¹' s
rw [uIcc_comm z.im] at Hc Hi; rw [min_comm z.im, max_comm z.im] at Hd
have hR : e ⁻¹' ([[z.re, w.re]] ×ℂ [[w.im, z.im]]) = R := rfl
have htc : ContinuousOn F R := Hc.comp e.continuousOn hR.ge
have htd :
∀ p ∈ Ioo (min z.re w.re) (max z.re w.re) ×ˢ Ioo (min w.im z.im) (max w.im z.im) \ t,
HasFDerivAt F (F' p) p :=
fun p hp => (Hd (e p) hp).comp p e.hasFDerivAt
simp_rw [← intervalIntegral.integral_smul, intervalIntegral.integral_symm w.im z.im, ←
intervalIntegral.integral_neg, ← hF']
refine (integral2_divergence_prod_of_hasFDerivWithinAt_off_countable (fun p => -(I • F p)) F
(fun p => -(I • F' p)) F' z.re w.im w.re z.im t (hs.preimage e.injective)
(htc.const_smul _).neg htc (fun p hp => ((htd p hp).const_smul I).neg) htd ?_).symm
rw [← (volume_preserving_equiv_real_prod.symm _).integrableOn_comp_preimage
(MeasurableEquiv.measurableEmbedding _)] at Hi
simpa only [hF'] using Hi.neg
#align complex.integral_boundary_rect_of_has_fderiv_at_real_off_countable Complex.integral_boundary_rect_of_hasFDerivAt_real_off_countable
theorem integral_boundary_rect_of_continuousOn_of_hasFDerivAt_real (f : ℂ → E) (f' : ℂ → ℂ →L[ℝ] E)
(z w : ℂ) (Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]]))
(Hd : ∀ x ∈ Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im),
HasFDerivAt f (f' x) x)
(Hi : IntegrableOn (fun z => I • f' z 1 - f' z I) ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) :
(∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) +
I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) -
I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) =
∫ x : ℝ in z.re..w.re, ∫ y : ℝ in z.im..w.im, I • f' (x + y * I) 1 - f' (x + y * I) I :=
integral_boundary_rect_of_hasFDerivAt_real_off_countable f f' z w ∅ countable_empty Hc
(fun x hx => Hd x hx.1) Hi
#align complex.integral_boundary_rect_of_continuous_on_of_has_fderiv_at_real Complex.integral_boundary_rect_of_continuousOn_of_hasFDerivAt_real
theorem integral_boundary_rect_of_differentiableOn_real (f : ℂ → E) (z w : ℂ)
(Hd : DifferentiableOn ℝ f ([[z.re, w.re]] ×ℂ [[z.im, w.im]]))
(Hi : IntegrableOn (fun z => I • fderiv ℝ f z 1 - fderiv ℝ f z I)
([[z.re, w.re]] ×ℂ [[z.im, w.im]])) :
(∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) +
I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) -
I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) =
∫ x : ℝ in z.re..w.re, ∫ y : ℝ in z.im..w.im,
I • fderiv ℝ f (x + y * I) 1 - fderiv ℝ f (x + y * I) I :=
integral_boundary_rect_of_hasFDerivAt_real_off_countable f (fderiv ℝ f) z w ∅ countable_empty
Hd.continuousOn
(fun x hx => Hd.hasFDerivAt <| by
simpa only [← mem_interior_iff_mem_nhds, interior_reProdIm, uIcc, interior_Icc] using hx.1)
Hi
#align complex.integral_boundary_rect_of_differentiable_on_real Complex.integral_boundary_rect_of_differentiableOn_real
theorem integral_boundary_rect_eq_zero_of_differentiable_on_off_countable (f : ℂ → E) (z w : ℂ)
(s : Set ℂ) (hs : s.Countable) (Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]]))
(Hd : ∀ x ∈ Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im) \ s,
DifferentiableAt ℂ f x) :
(∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) +
I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) -
I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) = 0 := by
refine (integral_boundary_rect_of_hasFDerivAt_real_off_countable f
(fun z => (fderiv ℂ f z).restrictScalars ℝ) z w s hs Hc
(fun x hx => (Hd x hx).hasFDerivAt.restrictScalars ℝ) ?_).trans ?_ <;>
simp [← ContinuousLinearMap.map_smul]
#align complex.integral_boundary_rect_eq_zero_of_differentiable_on_off_countable Complex.integral_boundary_rect_eq_zero_of_differentiable_on_off_countable
theorem integral_boundary_rect_eq_zero_of_continuousOn_of_differentiableOn (f : ℂ → E) (z w : ℂ)
(Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]]))
(Hd : DifferentiableOn ℂ f
(Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im))) :
(∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) +
I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) -
I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) = 0 :=
integral_boundary_rect_eq_zero_of_differentiable_on_off_countable f z w ∅ countable_empty Hc
fun _x hx => Hd.differentiableAt <| (isOpen_Ioo.reProdIm isOpen_Ioo).mem_nhds hx.1
#align complex.integral_boundary_rect_eq_zero_of_continuous_on_of_differentiable_on Complex.integral_boundary_rect_eq_zero_of_continuousOn_of_differentiableOn
theorem integral_boundary_rect_eq_zero_of_differentiableOn (f : ℂ → E) (z w : ℂ)
(H : DifferentiableOn ℂ f ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) :
(∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) +
I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) -
I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) = 0 :=
integral_boundary_rect_eq_zero_of_continuousOn_of_differentiableOn f z w H.continuousOn <|
H.mono <|
inter_subset_inter (preimage_mono Ioo_subset_Icc_self) (preimage_mono Ioo_subset_Icc_self)
#align complex.integral_boundary_rect_eq_zero_of_differentiable_on Complex.integral_boundary_rect_eq_zero_of_differentiableOn
theorem circleIntegral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable {c : ℂ}
{r R : ℝ} (h0 : 0 < r) (hle : r ≤ R) {f : ℂ → E} {s : Set ℂ} (hs : s.Countable)
(hc : ContinuousOn f (closedBall c R \ ball c r))
(hd : ∀ z ∈ (ball c R \ closedBall c r) \ s, DifferentiableAt ℂ f z) :
(∮ z in C(c, R), (z - c)⁻¹ • f z) = ∮ z in C(c, r), (z - c)⁻¹ • f z := by
set A := closedBall c R \ ball c r
obtain ⟨a, rfl⟩ : ∃ a, Real.exp a = r := ⟨Real.log r, Real.exp_log h0⟩
obtain ⟨b, rfl⟩ : ∃ b, Real.exp b = R := ⟨Real.log R, Real.exp_log (h0.trans_le hle)⟩
rw [Real.exp_le_exp] at hle
-- Unfold definition of `circleIntegral` and cancel some terms.
suffices
(∫ θ in (0)..2 * π, I • f (circleMap c (Real.exp b) θ)) =
∫ θ in (0)..2 * π, I • f (circleMap c (Real.exp a) θ) by
simpa only [circleIntegral, add_sub_cancel_left, ofReal_exp, ← exp_add, smul_smul, ←
div_eq_mul_inv, mul_div_cancel_left₀ _ (circleMap_ne_center (Real.exp_pos _).ne'),
circleMap_sub_center, deriv_circleMap]
set R := [[a, b]] ×ℂ [[0, 2 * π]]
set g : ℂ → ℂ := (c + exp ·)
have hdg : Differentiable ℂ g := differentiable_exp.const_add _
replace hs : (g ⁻¹' s).Countable := (hs.preimage (add_right_injective c)).preimage_cexp
have h_maps : MapsTo g R A := by rintro z ⟨h, -⟩; simpa [g, A, dist_eq, abs_exp, hle] using h.symm
replace hc : ContinuousOn (f ∘ g) R := hc.comp hdg.continuous.continuousOn h_maps
replace hd : ∀ z ∈ Ioo (min a b) (max a b) ×ℂ Ioo (min 0 (2 * π)) (max 0 (2 * π)) \ g ⁻¹' s,
DifferentiableAt ℂ (f ∘ g) z := by
refine fun z hz => (hd (g z) ⟨?_, hz.2⟩).comp z (hdg _)
simpa [g, dist_eq, abs_exp, hle, and_comm] using hz.1.1
simpa [g, circleMap, exp_periodic _, sub_eq_zero, ← exp_add] using
integral_boundary_rect_eq_zero_of_differentiable_on_off_countable _ ⟨a, 0⟩ ⟨b, 2 * π⟩ _ hs hc hd
#align complex.circle_integral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable Complex.circleIntegral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable
theorem circleIntegral_eq_of_differentiable_on_annulus_off_countable {c : ℂ} {r R : ℝ} (h0 : 0 < r)
(hle : r ≤ R) {f : ℂ → E} {s : Set ℂ} (hs : s.Countable)
(hc : ContinuousOn f (closedBall c R \ ball c r))
(hd : ∀ z ∈ (ball c R \ closedBall c r) \ s, DifferentiableAt ℂ f z) :
(∮ z in C(c, R), f z) = ∮ z in C(c, r), f z :=
calc
(∮ z in C(c, R), f z) = ∮ z in C(c, R), (z - c)⁻¹ • (z - c) • f z :=
(circleIntegral.integral_sub_inv_smul_sub_smul _ _ _ _).symm
_ = ∮ z in C(c, r), (z - c)⁻¹ • (z - c) • f z :=
(circleIntegral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable h0 hle hs
((continuousOn_id.sub continuousOn_const).smul hc) fun z hz =>
(differentiableAt_id.sub_const _).smul (hd z hz))
_ = ∮ z in C(c, r), f z := circleIntegral.integral_sub_inv_smul_sub_smul _ _ _ _
#align complex.circle_integral_eq_of_differentiable_on_annulus_off_countable Complex.circleIntegral_eq_of_differentiable_on_annulus_off_countable
theorem circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable_of_tendsto {c : ℂ}
{R : ℝ} (h0 : 0 < R) {f : ℂ → E} {y : E} {s : Set ℂ} (hs : s.Countable)
(hc : ContinuousOn f (closedBall c R \ {c}))
(hd : ∀ z ∈ (ball c R \ {c}) \ s, DifferentiableAt ℂ f z) (hy : Tendsto f (𝓝[{c}ᶜ] c) (𝓝 y)) :
(∮ z in C(c, R), (z - c)⁻¹ • f z) = (2 * π * I : ℂ) • y := by
rw [← sub_eq_zero, ← norm_le_zero_iff]
refine le_of_forall_le_of_dense fun ε ε0 => ?_
obtain ⟨δ, δ0, hδ⟩ : ∃ δ > (0 : ℝ), ∀ z ∈ closedBall c δ \ {c}, dist (f z) y < ε / (2 * π) :=
((nhdsWithin_hasBasis nhds_basis_closedBall _).tendsto_iff nhds_basis_ball).1 hy _
(div_pos ε0 Real.two_pi_pos)
obtain ⟨r, hr0, hrδ, hrR⟩ : ∃ r, 0 < r ∧ r ≤ δ ∧ r ≤ R :=
⟨min δ R, lt_min δ0 h0, min_le_left _ _, min_le_right _ _⟩
have hsub : closedBall c R \ ball c r ⊆ closedBall c R \ {c} :=
diff_subset_diff_right (singleton_subset_iff.2 <| mem_ball_self hr0)
have hsub' : ball c R \ closedBall c r ⊆ ball c R \ {c} :=
diff_subset_diff_right (singleton_subset_iff.2 <| mem_closedBall_self hr0.le)
have hzne : ∀ z ∈ sphere c r, z ≠ c := fun z hz =>
ne_of_mem_of_not_mem hz fun h => hr0.ne' <| dist_self c ▸ Eq.symm h
calc
‖(∮ z in C(c, R), (z - c)⁻¹ • f z) - (2 * ↑π * I) • y‖ =
‖(∮ z in C(c, r), (z - c)⁻¹ • f z) - ∮ z in C(c, r), (z - c)⁻¹ • y‖ := by
congr 2
· exact circleIntegral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable hr0
hrR hs (hc.mono hsub) fun z hz => hd z ⟨hsub' hz.1, hz.2⟩
· simp [hr0.ne']
_ = ‖∮ z in C(c, r), (z - c)⁻¹ • (f z - y)‖ := by
simp only [smul_sub]
have hc' : ContinuousOn (fun z => (z - c)⁻¹) (sphere c r) :=
(continuousOn_id.sub continuousOn_const).inv₀ fun z hz => sub_ne_zero.2 <| hzne _ hz
rw [circleIntegral.integral_sub] <;> refine (hc'.smul ?_).circleIntegrable hr0.le
· exact hc.mono <| subset_inter
(sphere_subset_closedBall.trans <| closedBall_subset_closedBall hrR) hzne
· exact continuousOn_const
_ ≤ 2 * π * r * (r⁻¹ * (ε / (2 * π))) := by
refine circleIntegral.norm_integral_le_of_norm_le_const hr0.le fun z hz => ?_
specialize hzne z hz
rw [mem_sphere, dist_eq_norm] at hz
rw [norm_smul, norm_inv, hz, ← dist_eq_norm]
refine mul_le_mul_of_nonneg_left (hδ _ ⟨?_, hzne⟩).le (inv_nonneg.2 hr0.le)
rwa [mem_closedBall_iff_norm, hz]
_ = ε := by field_simp [hr0.ne', Real.two_pi_pos.ne']; ac_rfl
#align complex.circle_integral_sub_center_inv_smul_of_differentiable_on_off_countable_of_tendsto Complex.circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable_of_tendsto
theorem circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable {R : ℝ} (h0 : 0 < R)
{f : ℂ → E} {c : ℂ} {s : Set ℂ} (hs : s.Countable) (hc : ContinuousOn f (closedBall c R))
(hd : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) :
(∮ z in C(c, R), (z - c)⁻¹ • f z) = (2 * π * I : ℂ) • f c :=
circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable_of_tendsto h0 hs
(hc.mono diff_subset) (fun z hz => hd z ⟨hz.1.1, hz.2⟩)
(hc.continuousAt <| closedBall_mem_nhds _ h0).continuousWithinAt
#align complex.circle_integral_sub_center_inv_smul_of_differentiable_on_off_countable Complex.circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable
| Mathlib/Analysis/Complex/CauchyIntegral.lean | 410 | 421 | theorem circleIntegral_eq_zero_of_differentiable_on_off_countable {R : ℝ} (h0 : 0 ≤ R) {f : ℂ → E}
{c : ℂ} {s : Set ℂ} (hs : s.Countable) (hc : ContinuousOn f (closedBall c R))
(hd : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) : (∮ z in C(c, R), f z) = 0 := by |
rcases h0.eq_or_lt with (rfl | h0); · apply circleIntegral.integral_radius_zero
calc
(∮ z in C(c, R), f z) = ∮ z in C(c, R), (z - c)⁻¹ • (z - c) • f z :=
(circleIntegral.integral_sub_inv_smul_sub_smul _ _ _ _).symm
_ = (2 * ↑π * I : ℂ) • (c - c) • f c :=
(circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable h0 hs
((continuousOn_id.sub continuousOn_const).smul hc) fun z hz =>
(differentiableAt_id.sub_const _).smul (hd z hz))
_ = 0 := by rw [sub_self, zero_smul, smul_zero]
|
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order
#align_import measure_theory.function.simple_func from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf"
noncomputable section
open Set hiding restrict restrict_apply
open Filter ENNReal
open Function (support)
open scoped Classical
open Topology NNReal ENNReal MeasureTheory
namespace MeasureTheory
variable {α β γ δ : Type*}
structure SimpleFunc.{u, v} (α : Type u) [MeasurableSpace α] (β : Type v) where
toFun : α → β
measurableSet_fiber' : ∀ x, MeasurableSet (toFun ⁻¹' {x})
finite_range' : (Set.range toFun).Finite
#align measure_theory.simple_func MeasureTheory.SimpleFunc
#align measure_theory.simple_func.to_fun MeasureTheory.SimpleFunc.toFun
#align measure_theory.simple_func.measurable_set_fiber' MeasureTheory.SimpleFunc.measurableSet_fiber'
#align measure_theory.simple_func.finite_range' MeasureTheory.SimpleFunc.finite_range'
local infixr:25 " →ₛ " => SimpleFunc
namespace SimpleFunc
section Measurable
variable [MeasurableSpace α]
attribute [coe] toFun
instance instCoeFun : CoeFun (α →ₛ β) fun _ => α → β :=
⟨toFun⟩
#align measure_theory.simple_func.has_coe_to_fun MeasureTheory.SimpleFunc.instCoeFun
theorem coe_injective ⦃f g : α →ₛ β⦄ (H : (f : α → β) = g) : f = g := by
cases f; cases g; congr
#align measure_theory.simple_func.coe_injective MeasureTheory.SimpleFunc.coe_injective
@[ext]
theorem ext {f g : α →ₛ β} (H : ∀ a, f a = g a) : f = g :=
coe_injective <| funext H
#align measure_theory.simple_func.ext MeasureTheory.SimpleFunc.ext
theorem finite_range (f : α →ₛ β) : (Set.range f).Finite :=
f.finite_range'
#align measure_theory.simple_func.finite_range MeasureTheory.SimpleFunc.finite_range
theorem measurableSet_fiber (f : α →ₛ β) (x : β) : MeasurableSet (f ⁻¹' {x}) :=
f.measurableSet_fiber' x
#align measure_theory.simple_func.measurable_set_fiber MeasureTheory.SimpleFunc.measurableSet_fiber
-- @[simp] -- Porting note (#10618): simp can prove this
theorem apply_mk (f : α → β) (h h') (x : α) : SimpleFunc.mk f h h' x = f x :=
rfl
#align measure_theory.simple_func.apply_mk MeasureTheory.SimpleFunc.apply_mk
def ofFinite [Finite α] [MeasurableSingletonClass α] (f : α → β) : α →ₛ β where
toFun := f
measurableSet_fiber' x := (toFinite (f ⁻¹' {x})).measurableSet
finite_range' := Set.finite_range f
@[deprecated (since := "2024-02-05")] alias ofFintype := ofFinite
def ofIsEmpty [IsEmpty α] : α →ₛ β := ofFinite isEmptyElim
#align measure_theory.simple_func.of_is_empty MeasureTheory.SimpleFunc.ofIsEmpty
protected def range (f : α →ₛ β) : Finset β :=
f.finite_range.toFinset
#align measure_theory.simple_func.range MeasureTheory.SimpleFunc.range
@[simp]
theorem mem_range {f : α →ₛ β} {b} : b ∈ f.range ↔ b ∈ range f :=
Finite.mem_toFinset _
#align measure_theory.simple_func.mem_range MeasureTheory.SimpleFunc.mem_range
theorem mem_range_self (f : α →ₛ β) (x : α) : f x ∈ f.range :=
mem_range.2 ⟨x, rfl⟩
#align measure_theory.simple_func.mem_range_self MeasureTheory.SimpleFunc.mem_range_self
@[simp]
theorem coe_range (f : α →ₛ β) : (↑f.range : Set β) = Set.range f :=
f.finite_range.coe_toFinset
#align measure_theory.simple_func.coe_range MeasureTheory.SimpleFunc.coe_range
theorem mem_range_of_measure_ne_zero {f : α →ₛ β} {x : β} {μ : Measure α} (H : μ (f ⁻¹' {x}) ≠ 0) :
x ∈ f.range :=
let ⟨a, ha⟩ := nonempty_of_measure_ne_zero H
mem_range.2 ⟨a, ha⟩
#align measure_theory.simple_func.mem_range_of_measure_ne_zero MeasureTheory.SimpleFunc.mem_range_of_measure_ne_zero
theorem forall_mem_range {f : α →ₛ β} {p : β → Prop} : (∀ y ∈ f.range, p y) ↔ ∀ x, p (f x) := by
simp only [mem_range, Set.forall_mem_range]
#align measure_theory.simple_func.forall_mem_range MeasureTheory.SimpleFunc.forall_mem_range
theorem exists_range_iff {f : α →ₛ β} {p : β → Prop} : (∃ y ∈ f.range, p y) ↔ ∃ x, p (f x) := by
simpa only [mem_range, exists_prop] using Set.exists_range_iff
#align measure_theory.simple_func.exists_range_iff MeasureTheory.SimpleFunc.exists_range_iff
theorem preimage_eq_empty_iff (f : α →ₛ β) (b : β) : f ⁻¹' {b} = ∅ ↔ b ∉ f.range :=
preimage_singleton_eq_empty.trans <| not_congr mem_range.symm
#align measure_theory.simple_func.preimage_eq_empty_iff MeasureTheory.SimpleFunc.preimage_eq_empty_iff
theorem exists_forall_le [Nonempty β] [Preorder β] [IsDirected β (· ≤ ·)] (f : α →ₛ β) :
∃ C, ∀ x, f x ≤ C :=
f.range.exists_le.imp fun _ => forall_mem_range.1
#align measure_theory.simple_func.exists_forall_le MeasureTheory.SimpleFunc.exists_forall_le
def const (α) {β} [MeasurableSpace α] (b : β) : α →ₛ β :=
⟨fun _ => b, fun _ => MeasurableSet.const _, finite_range_const⟩
#align measure_theory.simple_func.const MeasureTheory.SimpleFunc.const
instance instInhabited [Inhabited β] : Inhabited (α →ₛ β) :=
⟨const _ default⟩
#align measure_theory.simple_func.inhabited MeasureTheory.SimpleFunc.instInhabited
theorem const_apply (a : α) (b : β) : (const α b) a = b :=
rfl
#align measure_theory.simple_func.const_apply MeasureTheory.SimpleFunc.const_apply
@[simp]
theorem coe_const (b : β) : ⇑(const α b) = Function.const α b :=
rfl
#align measure_theory.simple_func.coe_const MeasureTheory.SimpleFunc.coe_const
@[simp]
theorem range_const (α) [MeasurableSpace α] [Nonempty α] (b : β) : (const α b).range = {b} :=
Finset.coe_injective <| by simp (config := { unfoldPartialApp := true }) [Function.const]
#align measure_theory.simple_func.range_const MeasureTheory.SimpleFunc.range_const
theorem range_const_subset (α) [MeasurableSpace α] (b : β) : (const α b).range ⊆ {b} :=
Finset.coe_subset.1 <| by simp
#align measure_theory.simple_func.range_const_subset MeasureTheory.SimpleFunc.range_const_subset
theorem simpleFunc_bot {α} (f : @SimpleFunc α ⊥ β) [Nonempty β] : ∃ c, ∀ x, f x = c := by
have hf_meas := @SimpleFunc.measurableSet_fiber α _ ⊥ f
simp_rw [MeasurableSpace.measurableSet_bot_iff] at hf_meas
exact (exists_eq_const_of_preimage_singleton hf_meas).imp fun c hc ↦ congr_fun hc
#align measure_theory.simple_func.simple_func_bot MeasureTheory.SimpleFunc.simpleFunc_bot
theorem simpleFunc_bot' {α} [Nonempty β] (f : @SimpleFunc α ⊥ β) :
∃ c, f = @SimpleFunc.const α _ ⊥ c :=
letI : MeasurableSpace α := ⊥; (simpleFunc_bot f).imp fun _ ↦ ext
#align measure_theory.simple_func.simple_func_bot' MeasureTheory.SimpleFunc.simpleFunc_bot'
theorem measurableSet_cut (r : α → β → Prop) (f : α →ₛ β) (h : ∀ b, MeasurableSet { a | r a b }) :
MeasurableSet { a | r a (f a) } := by
have : { a | r a (f a) } = ⋃ b ∈ range f, { a | r a b } ∩ f ⁻¹' {b} := by
ext a
suffices r a (f a) ↔ ∃ i, r a (f i) ∧ f a = f i by simpa
exact ⟨fun h => ⟨a, ⟨h, rfl⟩⟩, fun ⟨a', ⟨h', e⟩⟩ => e.symm ▸ h'⟩
rw [this]
exact
MeasurableSet.biUnion f.finite_range.countable fun b _ =>
MeasurableSet.inter (h b) (f.measurableSet_fiber _)
#align measure_theory.simple_func.measurable_set_cut MeasureTheory.SimpleFunc.measurableSet_cut
@[measurability]
theorem measurableSet_preimage (f : α →ₛ β) (s) : MeasurableSet (f ⁻¹' s) :=
measurableSet_cut (fun _ b => b ∈ s) f fun b => MeasurableSet.const (b ∈ s)
#align measure_theory.simple_func.measurable_set_preimage MeasureTheory.SimpleFunc.measurableSet_preimage
@[measurability]
protected theorem measurable [MeasurableSpace β] (f : α →ₛ β) : Measurable f := fun s _ =>
measurableSet_preimage f s
#align measure_theory.simple_func.measurable MeasureTheory.SimpleFunc.measurable
@[measurability]
protected theorem aemeasurable [MeasurableSpace β] {μ : Measure α} (f : α →ₛ β) :
AEMeasurable f μ :=
f.measurable.aemeasurable
#align measure_theory.simple_func.ae_measurable MeasureTheory.SimpleFunc.aemeasurable
protected theorem sum_measure_preimage_singleton (f : α →ₛ β) {μ : Measure α} (s : Finset β) :
(∑ y ∈ s, μ (f ⁻¹' {y})) = μ (f ⁻¹' ↑s) :=
sum_measure_preimage_singleton _ fun _ _ => f.measurableSet_fiber _
#align measure_theory.simple_func.sum_measure_preimage_singleton MeasureTheory.SimpleFunc.sum_measure_preimage_singleton
theorem sum_range_measure_preimage_singleton (f : α →ₛ β) (μ : Measure α) :
(∑ y ∈ f.range, μ (f ⁻¹' {y})) = μ univ := by
rw [f.sum_measure_preimage_singleton, coe_range, preimage_range]
#align measure_theory.simple_func.sum_range_measure_preimage_singleton MeasureTheory.SimpleFunc.sum_range_measure_preimage_singleton
def piecewise (s : Set α) (hs : MeasurableSet s) (f g : α →ₛ β) : α →ₛ β :=
⟨s.piecewise f g, fun _ =>
letI : MeasurableSpace β := ⊤
f.measurable.piecewise hs g.measurable trivial,
(f.finite_range.union g.finite_range).subset range_ite_subset⟩
#align measure_theory.simple_func.piecewise MeasureTheory.SimpleFunc.piecewise
@[simp]
theorem coe_piecewise {s : Set α} (hs : MeasurableSet s) (f g : α →ₛ β) :
⇑(piecewise s hs f g) = s.piecewise f g :=
rfl
#align measure_theory.simple_func.coe_piecewise MeasureTheory.SimpleFunc.coe_piecewise
theorem piecewise_apply {s : Set α} (hs : MeasurableSet s) (f g : α →ₛ β) (a) :
piecewise s hs f g a = if a ∈ s then f a else g a :=
rfl
#align measure_theory.simple_func.piecewise_apply MeasureTheory.SimpleFunc.piecewise_apply
@[simp]
theorem piecewise_compl {s : Set α} (hs : MeasurableSet sᶜ) (f g : α →ₛ β) :
piecewise sᶜ hs f g = piecewise s hs.of_compl g f :=
coe_injective <| by
set_option tactic.skipAssignedInstances false in
simp [hs]; convert Set.piecewise_compl s f g
#align measure_theory.simple_func.piecewise_compl MeasureTheory.SimpleFunc.piecewise_compl
@[simp]
theorem piecewise_univ (f g : α →ₛ β) : piecewise univ MeasurableSet.univ f g = f :=
coe_injective <| by
set_option tactic.skipAssignedInstances false in
simp; convert Set.piecewise_univ f g
#align measure_theory.simple_func.piecewise_univ MeasureTheory.SimpleFunc.piecewise_univ
@[simp]
theorem piecewise_empty (f g : α →ₛ β) : piecewise ∅ MeasurableSet.empty f g = g :=
coe_injective <| by
set_option tactic.skipAssignedInstances false in
simp; convert Set.piecewise_empty f g
#align measure_theory.simple_func.piecewise_empty MeasureTheory.SimpleFunc.piecewise_empty
@[simp]
theorem piecewise_same (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) :
piecewise s hs f f = f :=
coe_injective <| Set.piecewise_same _ _
theorem support_indicator [Zero β] {s : Set α} (hs : MeasurableSet s) (f : α →ₛ β) :
Function.support (f.piecewise s hs (SimpleFunc.const α 0)) = s ∩ Function.support f :=
Set.support_indicator
#align measure_theory.simple_func.support_indicator MeasureTheory.SimpleFunc.support_indicator
theorem range_indicator {s : Set α} (hs : MeasurableSet s) (hs_nonempty : s.Nonempty)
(hs_ne_univ : s ≠ univ) (x y : β) :
(piecewise s hs (const α x) (const α y)).range = {x, y} := by
simp only [← Finset.coe_inj, coe_range, coe_piecewise, range_piecewise, coe_const,
Finset.coe_insert, Finset.coe_singleton, hs_nonempty.image_const,
(nonempty_compl.2 hs_ne_univ).image_const, singleton_union, Function.const]
#align measure_theory.simple_func.range_indicator MeasureTheory.SimpleFunc.range_indicator
theorem measurable_bind [MeasurableSpace γ] (f : α →ₛ β) (g : β → α → γ)
(hg : ∀ b, Measurable (g b)) : Measurable fun a => g (f a) a := fun s hs =>
f.measurableSet_cut (fun a b => g b a ∈ s) fun b => hg b hs
#align measure_theory.simple_func.measurable_bind MeasureTheory.SimpleFunc.measurable_bind
def bind (f : α →ₛ β) (g : β → α →ₛ γ) : α →ₛ γ :=
⟨fun a => g (f a) a, fun c =>
f.measurableSet_cut (fun a b => g b a = c) fun b => (g b).measurableSet_preimage {c},
(f.finite_range.biUnion fun b _ => (g b).finite_range).subset <| by
rintro _ ⟨a, rfl⟩; simp⟩
#align measure_theory.simple_func.bind MeasureTheory.SimpleFunc.bind
@[simp]
theorem bind_apply (f : α →ₛ β) (g : β → α →ₛ γ) (a) : f.bind g a = g (f a) a :=
rfl
#align measure_theory.simple_func.bind_apply MeasureTheory.SimpleFunc.bind_apply
def map (g : β → γ) (f : α →ₛ β) : α →ₛ γ :=
bind f (const α ∘ g)
#align measure_theory.simple_func.map MeasureTheory.SimpleFunc.map
theorem map_apply (g : β → γ) (f : α →ₛ β) (a) : f.map g a = g (f a) :=
rfl
#align measure_theory.simple_func.map_apply MeasureTheory.SimpleFunc.map_apply
theorem map_map (g : β → γ) (h : γ → δ) (f : α →ₛ β) : (f.map g).map h = f.map (h ∘ g) :=
rfl
#align measure_theory.simple_func.map_map MeasureTheory.SimpleFunc.map_map
@[simp]
theorem coe_map (g : β → γ) (f : α →ₛ β) : (f.map g : α → γ) = g ∘ f :=
rfl
#align measure_theory.simple_func.coe_map MeasureTheory.SimpleFunc.coe_map
@[simp]
theorem range_map [DecidableEq γ] (g : β → γ) (f : α →ₛ β) : (f.map g).range = f.range.image g :=
Finset.coe_injective <| by simp only [coe_range, coe_map, Finset.coe_image, range_comp]
#align measure_theory.simple_func.range_map MeasureTheory.SimpleFunc.range_map
@[simp]
theorem map_const (g : β → γ) (b : β) : (const α b).map g = const α (g b) :=
rfl
#align measure_theory.simple_func.map_const MeasureTheory.SimpleFunc.map_const
theorem map_preimage (f : α →ₛ β) (g : β → γ) (s : Set γ) :
f.map g ⁻¹' s = f ⁻¹' ↑(f.range.filter fun b => g b ∈ s) := by
simp only [coe_range, sep_mem_eq, coe_map, Finset.coe_filter,
← mem_preimage, inter_comm, preimage_inter_range, ← Finset.mem_coe]
exact preimage_comp
#align measure_theory.simple_func.map_preimage MeasureTheory.SimpleFunc.map_preimage
theorem map_preimage_singleton (f : α →ₛ β) (g : β → γ) (c : γ) :
f.map g ⁻¹' {c} = f ⁻¹' ↑(f.range.filter fun b => g b = c) :=
map_preimage _ _ _
#align measure_theory.simple_func.map_preimage_singleton MeasureTheory.SimpleFunc.map_preimage_singleton
def comp [MeasurableSpace β] (f : β →ₛ γ) (g : α → β) (hgm : Measurable g) : α →ₛ γ where
toFun := f ∘ g
finite_range' := f.finite_range.subset <| Set.range_comp_subset_range _ _
measurableSet_fiber' z := hgm (f.measurableSet_fiber z)
#align measure_theory.simple_func.comp MeasureTheory.SimpleFunc.comp
@[simp]
theorem coe_comp [MeasurableSpace β] (f : β →ₛ γ) {g : α → β} (hgm : Measurable g) :
⇑(f.comp g hgm) = f ∘ g :=
rfl
#align measure_theory.simple_func.coe_comp MeasureTheory.SimpleFunc.coe_comp
theorem range_comp_subset_range [MeasurableSpace β] (f : β →ₛ γ) {g : α → β} (hgm : Measurable g) :
(f.comp g hgm).range ⊆ f.range :=
Finset.coe_subset.1 <| by simp only [coe_range, coe_comp, Set.range_comp_subset_range]
#align measure_theory.simple_func.range_comp_subset_range MeasureTheory.SimpleFunc.range_comp_subset_range
def extend [MeasurableSpace β] (f₁ : α →ₛ γ) (g : α → β) (hg : MeasurableEmbedding g)
(f₂ : β →ₛ γ) : β →ₛ γ where
toFun := Function.extend g f₁ f₂
finite_range' :=
(f₁.finite_range.union <| f₂.finite_range.subset (image_subset_range _ _)).subset
(range_extend_subset _ _ _)
measurableSet_fiber' := by
letI : MeasurableSpace γ := ⊤; haveI : MeasurableSingletonClass γ := ⟨fun _ => trivial⟩
exact fun x => hg.measurable_extend f₁.measurable f₂.measurable (measurableSet_singleton _)
#align measure_theory.simple_func.extend MeasureTheory.SimpleFunc.extend
@[simp]
theorem extend_apply [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g)
(f₂ : β →ₛ γ) (x : α) : (f₁.extend g hg f₂) (g x) = f₁ x :=
hg.injective.extend_apply _ _ _
#align measure_theory.simple_func.extend_apply MeasureTheory.SimpleFunc.extend_apply
@[simp]
theorem extend_apply' [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g)
(f₂ : β →ₛ γ) {y : β} (h : ¬∃ x, g x = y) : (f₁.extend g hg f₂) y = f₂ y :=
Function.extend_apply' _ _ _ h
#align measure_theory.simple_func.extend_apply' MeasureTheory.SimpleFunc.extend_apply'
@[simp]
theorem extend_comp_eq' [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g)
(f₂ : β →ₛ γ) : f₁.extend g hg f₂ ∘ g = f₁ :=
funext fun _ => extend_apply _ _ _ _
#align measure_theory.simple_func.extend_comp_eq' MeasureTheory.SimpleFunc.extend_comp_eq'
@[simp]
theorem extend_comp_eq [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g)
(f₂ : β →ₛ γ) : (f₁.extend g hg f₂).comp g hg.measurable = f₁ :=
coe_injective <| extend_comp_eq' _ hg _
#align measure_theory.simple_func.extend_comp_eq MeasureTheory.SimpleFunc.extend_comp_eq
def seq (f : α →ₛ β → γ) (g : α →ₛ β) : α →ₛ γ :=
f.bind fun f => g.map f
#align measure_theory.simple_func.seq MeasureTheory.SimpleFunc.seq
@[simp]
theorem seq_apply (f : α →ₛ β → γ) (g : α →ₛ β) (a : α) : f.seq g a = f a (g a) :=
rfl
#align measure_theory.simple_func.seq_apply MeasureTheory.SimpleFunc.seq_apply
def pair (f : α →ₛ β) (g : α →ₛ γ) : α →ₛ β × γ :=
(f.map Prod.mk).seq g
#align measure_theory.simple_func.pair MeasureTheory.SimpleFunc.pair
@[simp]
theorem pair_apply (f : α →ₛ β) (g : α →ₛ γ) (a) : pair f g a = (f a, g a) :=
rfl
#align measure_theory.simple_func.pair_apply MeasureTheory.SimpleFunc.pair_apply
theorem pair_preimage (f : α →ₛ β) (g : α →ₛ γ) (s : Set β) (t : Set γ) :
pair f g ⁻¹' s ×ˢ t = f ⁻¹' s ∩ g ⁻¹' t :=
rfl
#align measure_theory.simple_func.pair_preimage MeasureTheory.SimpleFunc.pair_preimage
-- A special form of `pair_preimage`
| Mathlib/MeasureTheory/Function/SimpleFunc.lean | 421 | 424 | theorem pair_preimage_singleton (f : α →ₛ β) (g : α →ₛ γ) (b : β) (c : γ) :
pair f g ⁻¹' {(b, c)} = f ⁻¹' {b} ∩ g ⁻¹' {c} := by |
rw [← singleton_prod_singleton]
exact pair_preimage _ _ _ _
|
import Mathlib.Data.Finset.Fold
import Mathlib.Algebra.GCDMonoid.Multiset
#align_import algebra.gcd_monoid.finset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
#align_import algebra.gcd_monoid.div from "leanprover-community/mathlib"@"b537794f8409bc9598febb79cd510b1df5f4539d"
variable {ι α β γ : Type*}
namespace Finset
open Multiset
variable [CancelCommMonoidWithZero α] [NormalizedGCDMonoid α]
section lcm
def lcm (s : Finset β) (f : β → α) : α :=
s.fold GCDMonoid.lcm 1 f
#align finset.lcm Finset.lcm
variable {s s₁ s₂ : Finset β} {f : β → α}
theorem lcm_def : s.lcm f = (s.1.map f).lcm :=
rfl
#align finset.lcm_def Finset.lcm_def
@[simp]
theorem lcm_empty : (∅ : Finset β).lcm f = 1 :=
fold_empty
#align finset.lcm_empty Finset.lcm_empty
@[simp]
theorem lcm_dvd_iff {a : α} : s.lcm f ∣ a ↔ ∀ b ∈ s, f b ∣ a := by
apply Iff.trans Multiset.lcm_dvd
simp only [Multiset.mem_map, and_imp, exists_imp]
exact ⟨fun k b hb ↦ k _ _ hb rfl, fun k a' b hb h ↦ h ▸ k _ hb⟩
#align finset.lcm_dvd_iff Finset.lcm_dvd_iff
theorem lcm_dvd {a : α} : (∀ b ∈ s, f b ∣ a) → s.lcm f ∣ a :=
lcm_dvd_iff.2
#align finset.lcm_dvd Finset.lcm_dvd
theorem dvd_lcm {b : β} (hb : b ∈ s) : f b ∣ s.lcm f :=
lcm_dvd_iff.1 dvd_rfl _ hb
#align finset.dvd_lcm Finset.dvd_lcm
@[simp]
| Mathlib/Algebra/GCDMonoid/Finset.lean | 77 | 82 | theorem lcm_insert [DecidableEq β] {b : β} :
(insert b s : Finset β).lcm f = GCDMonoid.lcm (f b) (s.lcm f) := by |
by_cases h : b ∈ s
· rw [insert_eq_of_mem h,
(lcm_eq_right_iff (f b) (s.lcm f) (Multiset.normalize_lcm (s.1.map f))).2 (dvd_lcm h)]
apply fold_insert h
|
import Mathlib.FieldTheory.RatFunc.Defs
import Mathlib.RingTheory.EuclideanDomain
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Polynomial.Content
#align_import field_theory.ratfunc from "leanprover-community/mathlib"@"bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6"
universe u v
noncomputable section
open scoped Classical
open scoped nonZeroDivisors Polynomial
variable {K : Type u}
namespace RatFunc
section Field
variable [CommRing K]
protected irreducible_def zero : RatFunc K :=
⟨0⟩
#align ratfunc.zero RatFunc.zero
instance : Zero (RatFunc K) :=
⟨RatFunc.zero⟩
-- Porting note: added `OfNat.ofNat`. using `simp?` produces `simp only [zero_def]`
-- that does not close the goal
theorem ofFractionRing_zero : (ofFractionRing 0 : RatFunc K) = 0 := by
simp only [Zero.zero, OfNat.ofNat, RatFunc.zero]
#align ratfunc.of_fraction_ring_zero RatFunc.ofFractionRing_zero
protected irreducible_def add : RatFunc K → RatFunc K → RatFunc K
| ⟨p⟩, ⟨q⟩ => ⟨p + q⟩
#align ratfunc.add RatFunc.add
instance : Add (RatFunc K) :=
⟨RatFunc.add⟩
-- Porting note: added `HAdd.hAdd`. using `simp?` produces `simp only [add_def]`
-- that does not close the goal
theorem ofFractionRing_add (p q : FractionRing K[X]) :
ofFractionRing (p + q) = ofFractionRing p + ofFractionRing q := by
simp only [HAdd.hAdd, Add.add, RatFunc.add]
#align ratfunc.of_fraction_ring_add RatFunc.ofFractionRing_add
protected irreducible_def sub : RatFunc K → RatFunc K → RatFunc K
| ⟨p⟩, ⟨q⟩ => ⟨p - q⟩
#align ratfunc.sub RatFunc.sub
instance : Sub (RatFunc K) :=
⟨RatFunc.sub⟩
-- Porting note: added `HSub.hSub`. using `simp?` produces `simp only [sub_def]`
-- that does not close the goal
theorem ofFractionRing_sub (p q : FractionRing K[X]) :
ofFractionRing (p - q) = ofFractionRing p - ofFractionRing q := by
simp only [Sub.sub, HSub.hSub, RatFunc.sub]
#align ratfunc.of_fraction_ring_sub RatFunc.ofFractionRing_sub
protected irreducible_def neg : RatFunc K → RatFunc K
| ⟨p⟩ => ⟨-p⟩
#align ratfunc.neg RatFunc.neg
instance : Neg (RatFunc K) :=
⟨RatFunc.neg⟩
theorem ofFractionRing_neg (p : FractionRing K[X]) :
ofFractionRing (-p) = -ofFractionRing p := by simp only [Neg.neg, RatFunc.neg]
#align ratfunc.of_fraction_ring_neg RatFunc.ofFractionRing_neg
protected irreducible_def one : RatFunc K :=
⟨1⟩
#align ratfunc.one RatFunc.one
instance : One (RatFunc K) :=
⟨RatFunc.one⟩
-- Porting note: added `OfNat.ofNat`. using `simp?` produces `simp only [one_def]`
-- that does not close the goal
theorem ofFractionRing_one : (ofFractionRing 1 : RatFunc K) = 1 := by
simp only [One.one, OfNat.ofNat, RatFunc.one]
#align ratfunc.of_fraction_ring_one RatFunc.ofFractionRing_one
protected irreducible_def mul : RatFunc K → RatFunc K → RatFunc K
| ⟨p⟩, ⟨q⟩ => ⟨p * q⟩
#align ratfunc.mul RatFunc.mul
instance : Mul (RatFunc K) :=
⟨RatFunc.mul⟩
-- Porting note: added `HMul.hMul`. using `simp?` produces `simp only [mul_def]`
-- that does not close the goal
theorem ofFractionRing_mul (p q : FractionRing K[X]) :
ofFractionRing (p * q) = ofFractionRing p * ofFractionRing q := by
simp only [Mul.mul, HMul.hMul, RatFunc.mul]
#align ratfunc.of_fraction_ring_mul RatFunc.ofFractionRing_mul
section IsDomain
variable [IsDomain K]
protected irreducible_def div : RatFunc K → RatFunc K → RatFunc K
| ⟨p⟩, ⟨q⟩ => ⟨p / q⟩
#align ratfunc.div RatFunc.div
instance : Div (RatFunc K) :=
⟨RatFunc.div⟩
-- Porting note: added `HDiv.hDiv`. using `simp?` produces `simp only [div_def]`
-- that does not close the goal
theorem ofFractionRing_div (p q : FractionRing K[X]) :
ofFractionRing (p / q) = ofFractionRing p / ofFractionRing q := by
simp only [Div.div, HDiv.hDiv, RatFunc.div]
#align ratfunc.of_fraction_ring_div RatFunc.ofFractionRing_div
protected irreducible_def inv : RatFunc K → RatFunc K
| ⟨p⟩ => ⟨p⁻¹⟩
#align ratfunc.inv RatFunc.inv
instance : Inv (RatFunc K) :=
⟨RatFunc.inv⟩
| Mathlib/FieldTheory/RatFunc/Basic.lean | 177 | 179 | theorem ofFractionRing_inv (p : FractionRing K[X]) :
ofFractionRing p⁻¹ = (ofFractionRing p)⁻¹ := by |
simp only [Inv.inv, RatFunc.inv]
|
import Mathlib.Algebra.Homology.Single
#align_import algebra.homology.augment from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
noncomputable section
open CategoryTheory Limits HomologicalComplex
universe v u
variable {V : Type u} [Category.{v} V]
namespace CochainComplex
@[simps]
def truncate [HasZeroMorphisms V] : CochainComplex V ℕ ⥤ CochainComplex V ℕ where
obj C :=
{ X := fun i => C.X (i + 1)
d := fun i j => C.d (i + 1) (j + 1)
shape := fun i j w => by
apply C.shape
simpa }
map f := { f := fun i => f.f (i + 1) }
#align cochain_complex.truncate CochainComplex.truncate
def toTruncate [HasZeroObject V] [HasZeroMorphisms V] (C : CochainComplex V ℕ) :
(single₀ V).obj (C.X 0) ⟶ truncate.obj C :=
(fromSingle₀Equiv (truncate.obj C) (C.X 0)).symm ⟨C.d 0 1, by aesop⟩
#align cochain_complex.to_truncate CochainComplex.toTruncate
variable [HasZeroMorphisms V]
def augment (C : CochainComplex V ℕ) {X : V} (f : X ⟶ C.X 0) (w : f ≫ C.d 0 1 = 0) :
CochainComplex V ℕ where
X | 0 => X
| i + 1 => C.X i
d | 0, 1 => f
| i + 1, j + 1 => C.d i j
| _, _ => 0
shape i j s := by
simp? at s says simp only [ComplexShape.up_Rel] at s
rcases j with (_ | _ | j) <;> cases i <;> try simp
· contradiction
· rw [C.shape]
simp only [ComplexShape.up_Rel]
contrapose! s
rw [← s]
d_comp_d' i j k hij hjk := by
rcases k with (_ | _ | k) <;> rcases j with (_ | _ | j) <;> cases i <;> try simp
cases k
· exact w
· rw [C.shape, comp_zero]
simp only [Nat.zero_eq, ComplexShape.up_Rel, zero_add]
exact (Nat.one_lt_succ_succ _).ne
#align cochain_complex.augment CochainComplex.augment
@[simp]
theorem augment_X_zero (C : CochainComplex V ℕ) {X : V} (f : X ⟶ C.X 0) (w : f ≫ C.d 0 1 = 0) :
(augment C f w).X 0 = X :=
rfl
set_option linter.uppercaseLean3 false in
#align cochain_complex.augment_X_zero CochainComplex.augment_X_zero
@[simp]
theorem augment_X_succ (C : CochainComplex V ℕ) {X : V} (f : X ⟶ C.X 0) (w : f ≫ C.d 0 1 = 0)
(i : ℕ) : (augment C f w).X (i + 1) = C.X i :=
rfl
set_option linter.uppercaseLean3 false in
#align cochain_complex.augment_X_succ CochainComplex.augment_X_succ
@[simp]
theorem augment_d_zero_one (C : CochainComplex V ℕ) {X : V} (f : X ⟶ C.X 0) (w : f ≫ C.d 0 1 = 0) :
(augment C f w).d 0 1 = f :=
rfl
#align cochain_complex.augment_d_zero_one CochainComplex.augment_d_zero_one
@[simp]
theorem augment_d_succ_succ (C : CochainComplex V ℕ) {X : V} (f : X ⟶ C.X 0) (w : f ≫ C.d 0 1 = 0)
(i j : ℕ) : (augment C f w).d (i + 1) (j + 1) = C.d i j :=
rfl
#align cochain_complex.augment_d_succ_succ CochainComplex.augment_d_succ_succ
def truncateAugment (C : CochainComplex V ℕ) {X : V} (f : X ⟶ C.X 0) (w : f ≫ C.d 0 1 = 0) :
truncate.obj (augment C f w) ≅ C where
hom := { f := fun i => 𝟙 _ }
inv :=
{ f := fun i => 𝟙 _
comm' := fun i j => by
cases j <;>
· dsimp
simp }
hom_inv_id := by
ext i
cases i <;>
· dsimp
simp
inv_hom_id := by
ext i
cases i <;>
· dsimp
simp
#align cochain_complex.truncate_augment CochainComplex.truncateAugment
@[simp]
theorem truncateAugment_hom_f (C : CochainComplex V ℕ) {X : V} (f : X ⟶ C.X 0)
(w : f ≫ C.d 0 1 = 0) (i : ℕ) : (truncateAugment C f w).hom.f i = 𝟙 (C.X i) :=
rfl
#align cochain_complex.truncate_augment_hom_f CochainComplex.truncateAugment_hom_f
@[simp]
theorem truncateAugment_inv_f (C : CochainComplex V ℕ) {X : V} (f : X ⟶ C.X 0)
(w : f ≫ C.d 0 1 = 0) (i : ℕ) :
(truncateAugment C f w).inv.f i = 𝟙 ((truncate.obj (augment C f w)).X i) :=
rfl
#align cochain_complex.truncate_augment_inv_f CochainComplex.truncateAugment_inv_f
@[simp]
| Mathlib/Algebra/Homology/Augment.lean | 325 | 328 | theorem cochainComplex_d_succ_succ_zero (C : CochainComplex V ℕ) (i : ℕ) : C.d 0 (i + 2) = 0 := by |
rw [C.shape]
simp only [ComplexShape.up_Rel, zero_add]
exact (Nat.one_lt_succ_succ _).ne
|
import Mathlib.NumberTheory.Cyclotomic.PrimitiveRoots
import Mathlib.NumberTheory.NumberField.Discriminant
#align_import number_theory.cyclotomic.discriminant from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
universe u v
open Algebra Polynomial Nat IsPrimitiveRoot PowerBasis
open scoped Polynomial Cyclotomic
namespace IsCyclotomicExtension
variable {p : ℕ+} {k : ℕ} {K : Type u} {L : Type v} {ζ : L} [Field K] [Field L]
variable [Algebra K L]
set_option tactic.skipAssignedInstances false in
theorem discr_prime_pow_ne_two [IsCyclotomicExtension {p ^ (k + 1)} K L] [hp : Fact (p : ℕ).Prime]
(hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) (hirr : Irreducible (cyclotomic (↑(p ^ (k + 1)) : ℕ) K))
(hk : p ^ (k + 1) ≠ 2) : discr K (hζ.powerBasis K).basis =
(-1) ^ ((p ^ (k + 1) : ℕ).totient / 2) * p ^ ((p : ℕ) ^ k * ((p - 1) * (k + 1) - 1)) := by
haveI hne := IsCyclotomicExtension.neZero' (p ^ (k + 1)) K L
-- Porting note: these two instances are not automatically synthesised and must be constructed
haveI mf : Module.Finite K L := finiteDimensional {p ^ (k + 1)} K L
haveI se : IsSeparable K L := (isGalois (p ^ (k + 1)) K L).to_isSeparable
rw [discr_powerBasis_eq_norm, finrank L hirr, hζ.powerBasis_gen _, ←
hζ.minpoly_eq_cyclotomic_of_irreducible hirr, PNat.pow_coe,
totient_prime_pow hp.out (succ_pos k), Nat.add_one_sub_one]
have coe_two : ((2 : ℕ+) : ℕ) = 2 := rfl
have hp2 : p = 2 → k ≠ 0 := by
rintro rfl rfl
exact absurd rfl hk
congr 1
· rcases eq_or_ne p 2 with (rfl | hp2)
· rcases Nat.exists_eq_succ_of_ne_zero (hp2 rfl) with ⟨k, rfl⟩
rw [coe_two, succ_sub_succ_eq_sub, tsub_zero, mul_one]; simp only [_root_.pow_succ']
rw [mul_assoc, Nat.mul_div_cancel_left _ zero_lt_two, Nat.mul_div_cancel_left _ zero_lt_two]
cases k
· simp
· simp_rw [_root_.pow_succ', (even_two.mul_right _).neg_one_pow,
((even_two.mul_right _).mul_right _).neg_one_pow]
· replace hp2 : (p : ℕ) ≠ 2 := by rwa [Ne, ← coe_two, PNat.coe_inj]
have hpo : Odd (p : ℕ) := hp.out.odd_of_ne_two hp2
obtain ⟨a, ha⟩ := (hp.out.even_sub_one hp2).two_dvd
rw [ha, mul_left_comm, mul_assoc, Nat.mul_div_cancel_left _ two_pos,
Nat.mul_div_cancel_left _ two_pos, mul_right_comm, pow_mul, (hpo.pow.mul _).neg_one_pow,
pow_mul, hpo.pow.neg_one_pow]
refine Nat.Even.sub_odd ?_ (even_two_mul _) odd_one
rw [mul_left_comm, ← ha]
exact one_le_mul (one_le_pow _ _ hp.1.pos) (succ_le_iff.2 <| tsub_pos_of_lt hp.1.one_lt)
· have H := congr_arg (@derivative K _) (cyclotomic_prime_pow_mul_X_pow_sub_one K p k)
rw [derivative_mul, derivative_sub, derivative_one, sub_zero, derivative_X_pow, C_eq_natCast,
derivative_sub, derivative_one, sub_zero, derivative_X_pow, C_eq_natCast, ← PNat.pow_coe,
hζ.minpoly_eq_cyclotomic_of_irreducible hirr] at H
replace H := congr_arg (fun P => aeval ζ P) H
simp only [aeval_add, aeval_mul, minpoly.aeval, zero_mul, add_zero, aeval_natCast,
_root_.map_sub, aeval_one, aeval_X_pow] at H
replace H := congr_arg (Algebra.norm K) H
have hnorm : (norm K) (ζ ^ (p : ℕ) ^ k - 1) = (p : K) ^ (p : ℕ) ^ k := by
by_cases hp : p = 2
· exact mod_cast hζ.norm_pow_sub_one_eq_prime_pow_of_ne_zero hirr le_rfl (hp2 hp)
· exact mod_cast hζ.norm_pow_sub_one_of_prime_ne_two hirr le_rfl hp
rw [MonoidHom.map_mul, hnorm, MonoidHom.map_mul, ← map_natCast (algebraMap K L),
Algebra.norm_algebraMap, finrank L hirr] at H
conv_rhs at H => -- Porting note: need to drill down to successfully rewrite the totient
enter [1, 2]
rw [PNat.pow_coe, ← succ_eq_add_one, totient_prime_pow hp.out (succ_pos k), Nat.sub_one,
Nat.pred_succ]
rw [← hζ.minpoly_eq_cyclotomic_of_irreducible hirr, map_pow, hζ.norm_eq_one hk hirr, one_pow,
mul_one, PNat.pow_coe, cast_pow, ← pow_mul, ← mul_assoc, mul_comm (k + 1), mul_assoc] at H
have := mul_pos (succ_pos k) (tsub_pos_of_lt hp.out.one_lt)
rw [← succ_pred_eq_of_pos this, mul_succ, pow_add _ _ ((p : ℕ) ^ k)] at H
replace H := (mul_left_inj' fun h => ?_).1 H
· simp only [H, mul_comm _ (k + 1)]; norm_cast
· -- Porting note: was `replace h := pow_eq_zero h; rw [coe_coe] at h; simpa using hne.1`
have := hne.1
rw [PNat.pow_coe, Nat.cast_pow, Ne, pow_eq_zero_iff (by omega)] at this
exact absurd (pow_eq_zero h) this
#align is_cyclotomic_extension.discr_prime_pow_ne_two IsCyclotomicExtension.discr_prime_pow_ne_two
theorem discr_prime_pow_ne_two' [IsCyclotomicExtension {p ^ (k + 1)} K L] [hp : Fact (p : ℕ).Prime]
(hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) (hirr : Irreducible (cyclotomic (↑(p ^ (k + 1)) : ℕ) K))
(hk : p ^ (k + 1) ≠ 2) : discr K (hζ.powerBasis K).basis =
(-1) ^ ((p : ℕ) ^ k * (p - 1) / 2) * p ^ ((p : ℕ) ^ k * ((p - 1) * (k + 1) - 1)) := by
simpa [totient_prime_pow hp.out (succ_pos k)] using discr_prime_pow_ne_two hζ hirr hk
#align is_cyclotomic_extension.discr_prime_pow_ne_two' IsCyclotomicExtension.discr_prime_pow_ne_two'
set_option tactic.skipAssignedInstances false in
theorem discr_prime_pow [hcycl : IsCyclotomicExtension {p ^ k} K L] [hp : Fact (p : ℕ).Prime]
(hζ : IsPrimitiveRoot ζ ↑(p ^ k)) (hirr : Irreducible (cyclotomic (↑(p ^ k) : ℕ) K)) :
discr K (hζ.powerBasis K).basis =
(-1) ^ ((p ^ k : ℕ).totient / 2) * p ^ ((p : ℕ) ^ (k - 1) * ((p - 1) * k - 1)) := by
cases' k with k k
· simp only [coe_basis, _root_.pow_zero, powerBasis_gen _ hζ, totient_one, mul_zero, mul_one,
show 1 / 2 = 0 by rfl, discr, traceMatrix]
have hζone : ζ = 1 := by simpa using hζ
rw [hζ.powerBasis_dim _, hζone, ← (algebraMap K L).map_one,
minpoly.eq_X_sub_C_of_algebraMap_inj _ (algebraMap K L).injective, natDegree_X_sub_C]
simp only [traceMatrix, map_one, one_pow, Matrix.det_unique, traceForm_apply, mul_one]
rw [← (algebraMap K L).map_one, trace_algebraMap, finrank _ hirr]
norm_num
· by_cases hk : p ^ (k + 1) = 2
· have coe_two : 2 = ((2 : ℕ+) : ℕ) := rfl
have hp : p = 2 := by
rw [← PNat.coe_inj, PNat.pow_coe, ← pow_one 2] at hk
replace hk :=
eq_of_prime_pow_eq (prime_iff.1 hp.out) (prime_iff.1 Nat.prime_two) (succ_pos _) hk
rwa [coe_two, PNat.coe_inj] at hk
subst hp
rw [← PNat.coe_inj, PNat.pow_coe] at hk
nth_rw 2 [← pow_one 2] at hk
replace hk := Nat.pow_right_injective rfl.le hk
rw [add_left_eq_self] at hk
subst hk
rw [pow_one] at hζ hcycl
have : natDegree (minpoly K ζ) = 1 := by
rw [hζ.eq_neg_one_of_two_right, show (-1 : L) = algebraMap K L (-1) by simp,
minpoly.eq_X_sub_C_of_algebraMap_inj _ (NoZeroSMulDivisors.algebraMap_injective K L)]
exact natDegree_X_sub_C (-1)
rcases Fin.equiv_iff_eq.2 this with ⟨e⟩
rw [← Algebra.discr_reindex K (hζ.powerBasis K).basis e, coe_basis, powerBasis_gen]; norm_num
simp_rw [hζ.eq_neg_one_of_two_right, show (-1 : L) = algebraMap K L (-1) by simp]
convert_to (discr K fun i : Fin 1 ↦ (algebraMap K L) (-1) ^ ↑i) = _
· congr
ext i
simp only [map_neg, map_one, Function.comp_apply, Fin.coe_fin_one, _root_.pow_zero]
suffices (e.symm i : ℕ) = 0 by simp [this]
rw [← Nat.lt_one_iff]
convert (e.symm i).2
rw [this]
· simp only [discr, traceMatrix_apply, Matrix.det_unique, Fin.default_eq_zero, Fin.val_zero,
_root_.pow_zero, traceForm_apply, mul_one]
rw [← (algebraMap K L).map_one, trace_algebraMap, finrank _ hirr]; norm_num
· exact discr_prime_pow_ne_two hζ hirr hk
#align is_cyclotomic_extension.discr_prime_pow IsCyclotomicExtension.discr_prime_pow
set_option tactic.skipAssignedInstances false in
theorem discr_prime_pow_eq_unit_mul_pow [IsCyclotomicExtension {p ^ k} K L]
[hp : Fact (p : ℕ).Prime] (hζ : IsPrimitiveRoot ζ ↑(p ^ k))
(hirr : Irreducible (cyclotomic (↑(p ^ k) : ℕ) K)) :
∃ (u : ℤˣ) (n : ℕ), discr K (hζ.powerBasis K).basis = u * p ^ n := by
rw [discr_prime_pow hζ hirr]
by_cases heven : Even ((p ^ k : ℕ).totient / 2)
· exact ⟨1, (p : ℕ) ^ (k - 1) * ((p - 1) * k - 1), by rw [heven.neg_one_pow]; norm_num⟩
· exact ⟨-1, (p : ℕ) ^ (k - 1) * ((p - 1) * k - 1), by
rw [(odd_iff_not_even.2 heven).neg_one_pow]; norm_num⟩
#align is_cyclotomic_extension.discr_prime_pow_eq_unit_mul_pow IsCyclotomicExtension.discr_prime_pow_eq_unit_mul_pow
| Mathlib/NumberTheory/Cyclotomic/Discriminant.lean | 207 | 216 | theorem discr_odd_prime [IsCyclotomicExtension {p} K L] [hp : Fact (p : ℕ).Prime]
(hζ : IsPrimitiveRoot ζ p) (hirr : Irreducible (cyclotomic p K)) (hodd : p ≠ 2) :
discr K (hζ.powerBasis K).basis = (-1) ^ (((p : ℕ) - 1) / 2) * p ^ ((p : ℕ) - 2) := by |
have : IsCyclotomicExtension {p ^ (0 + 1)} K L := by
rw [zero_add, pow_one]
infer_instance
have hζ' : IsPrimitiveRoot ζ (p ^ (0 + 1) :) := by simpa using hζ
convert discr_prime_pow_ne_two hζ' (by simpa [hirr]) (by simp [hodd]) using 2
· rw [zero_add, pow_one, totient_prime hp.out]
· rw [_root_.pow_zero, one_mul, zero_add, mul_one, Nat.sub_sub]
|
import Mathlib.Tactic.Ring
import Mathlib.Data.PNat.Prime
#align_import data.pnat.xgcd from "leanprover-community/mathlib"@"6afc9b06856ad973f6a2619e3e8a0a8d537a58f2"
open Nat
namespace PNat
structure XgcdType where
wp : ℕ
x : ℕ
y : ℕ
zp : ℕ
ap : ℕ
bp : ℕ
deriving Inhabited
#align pnat.xgcd_type PNat.XgcdType
namespace XgcdType
variable (u : XgcdType)
instance : SizeOf XgcdType :=
⟨fun u => u.bp⟩
instance : Repr XgcdType where
reprPrec
| g, _ => s!"[[[{repr (g.wp + 1)}, {repr g.x}], \
[{repr g.y}, {repr (g.zp + 1)}]], \
[{repr (g.ap + 1)}, {repr (g.bp + 1)}]]"
def mk' (w : ℕ+) (x : ℕ) (y : ℕ) (z : ℕ+) (a : ℕ+) (b : ℕ+) : XgcdType :=
mk w.val.pred x y z.val.pred a.val.pred b.val.pred
#align pnat.xgcd_type.mk' PNat.XgcdType.mk'
def w : ℕ+ :=
succPNat u.wp
#align pnat.xgcd_type.w PNat.XgcdType.w
def z : ℕ+ :=
succPNat u.zp
#align pnat.xgcd_type.z PNat.XgcdType.z
def a : ℕ+ :=
succPNat u.ap
#align pnat.xgcd_type.a PNat.XgcdType.a
def b : ℕ+ :=
succPNat u.bp
#align pnat.xgcd_type.b PNat.XgcdType.b
def r : ℕ :=
(u.ap + 1) % (u.bp + 1)
#align pnat.xgcd_type.r PNat.XgcdType.r
def q : ℕ :=
(u.ap + 1) / (u.bp + 1)
#align pnat.xgcd_type.q PNat.XgcdType.q
def qp : ℕ :=
u.q - 1
#align pnat.xgcd_type.qp PNat.XgcdType.qp
def vp : ℕ × ℕ :=
⟨u.wp + u.x + u.ap + u.wp * u.ap + u.x * u.bp, u.y + u.zp + u.bp + u.y * u.ap + u.zp * u.bp⟩
#align pnat.xgcd_type.vp PNat.XgcdType.vp
def v : ℕ × ℕ :=
⟨u.w * u.a + u.x * u.b, u.y * u.a + u.z * u.b⟩
#align pnat.xgcd_type.v PNat.XgcdType.v
def succ₂ (t : ℕ × ℕ) : ℕ × ℕ :=
⟨t.1.succ, t.2.succ⟩
#align pnat.xgcd_type.succ₂ PNat.XgcdType.succ₂
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> ring_nf
#align pnat.xgcd_type.v_eq_succ_vp PNat.XgcdType.v_eq_succ_vp
def IsSpecial : Prop :=
u.wp + u.zp + u.wp * u.zp = u.x * u.y
#align pnat.xgcd_type.is_special PNat.XgcdType.IsSpecial
def IsSpecial' : Prop :=
u.w * u.z = succPNat (u.x * u.y)
#align pnat.xgcd_type.is_special' PNat.XgcdType.IsSpecial'
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
dsimp [IsSpecial, IsSpecial']
let ⟨wp, x, y, zp, ap, bp⟩ := u
constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
simp only [← coe_inj, mul_coe, mk_coe] at *
· simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; ring
· simp [Nat.succ_eq_add_one, Nat.mul_add, Nat.add_mul, ← Nat.add_assoc] at h; rw [← h]; ring
-- Porting note: Old code has been removed as it was much more longer.
#align pnat.xgcd_type.is_special_iff PNat.XgcdType.isSpecial_iff
def IsReduced : Prop :=
u.ap = u.bp
#align pnat.xgcd_type.is_reduced PNat.XgcdType.IsReduced
def IsReduced' : Prop :=
u.a = u.b
#align pnat.xgcd_type.is_reduced' PNat.XgcdType.IsReduced'
theorem isReduced_iff : u.IsReduced ↔ u.IsReduced' :=
succPNat_inj.symm
#align pnat.xgcd_type.is_reduced_iff PNat.XgcdType.isReduced_iff
def flip : XgcdType where
wp := u.zp
x := u.y
y := u.x
zp := u.wp
ap := u.bp
bp := u.ap
#align pnat.xgcd_type.flip PNat.XgcdType.flip
@[simp]
theorem flip_w : (flip u).w = u.z :=
rfl
#align pnat.xgcd_type.flip_w PNat.XgcdType.flip_w
@[simp]
theorem flip_x : (flip u).x = u.y :=
rfl
#align pnat.xgcd_type.flip_x PNat.XgcdType.flip_x
@[simp]
theorem flip_y : (flip u).y = u.x :=
rfl
#align pnat.xgcd_type.flip_y PNat.XgcdType.flip_y
@[simp]
theorem flip_z : (flip u).z = u.w :=
rfl
#align pnat.xgcd_type.flip_z PNat.XgcdType.flip_z
@[simp]
theorem flip_a : (flip u).a = u.b :=
rfl
#align pnat.xgcd_type.flip_a PNat.XgcdType.flip_a
@[simp]
theorem flip_b : (flip u).b = u.a :=
rfl
#align pnat.xgcd_type.flip_b PNat.XgcdType.flip_b
theorem flip_isReduced : (flip u).IsReduced ↔ u.IsReduced := by
dsimp [IsReduced, flip]
constructor <;> intro h <;> exact h.symm
#align pnat.xgcd_type.flip_is_reduced PNat.XgcdType.flip_isReduced
theorem flip_isSpecial : (flip u).IsSpecial ↔ u.IsSpecial := by
dsimp [IsSpecial, flip]
rw [mul_comm u.x, mul_comm u.zp, add_comm u.zp]
#align pnat.xgcd_type.flip_is_special PNat.XgcdType.flip_isSpecial
theorem flip_v : (flip u).v = u.v.swap := by
dsimp [v]
ext
· simp only
ring
· simp only
ring
#align pnat.xgcd_type.flip_v PNat.XgcdType.flip_v
theorem rq_eq : u.r + (u.bp + 1) * u.q = u.ap + 1 :=
Nat.mod_add_div (u.ap + 1) (u.bp + 1)
#align pnat.xgcd_type.rq_eq PNat.XgcdType.rq_eq
| Mathlib/Data/PNat/Xgcd.lean | 241 | 246 | theorem qp_eq (hr : u.r = 0) : u.q = u.qp + 1 := by |
by_cases hq : u.q = 0
· let h := u.rq_eq
rw [hr, hq, mul_zero, add_zero] at h
cases h
· exact (Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hq)).symm
|
import Mathlib.Algebra.Group.ConjFinite
import Mathlib.GroupTheory.Abelianization
import Mathlib.GroupTheory.GroupAction.ConjAct
import Mathlib.GroupTheory.GroupAction.Quotient
import Mathlib.GroupTheory.Index
import Mathlib.GroupTheory.SpecificGroups.Dihedral
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Qify
#align_import group_theory.commuting_probability from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988"
noncomputable section
open scoped Classical
open Fintype
variable (M : Type*) [Mul M]
def commProb : ℚ :=
Nat.card { p : M × M // Commute p.1 p.2 } / (Nat.card M : ℚ) ^ 2
#align comm_prob commProb
theorem commProb_def :
commProb M = Nat.card { p : M × M // Commute p.1 p.2 } / (Nat.card M : ℚ) ^ 2 :=
rfl
#align comm_prob_def commProb_def
theorem commProb_prod (M' : Type*) [Mul M'] : commProb (M × M') = commProb M * commProb M' := by
simp_rw [commProb_def, div_mul_div_comm, Nat.card_prod, Nat.cast_mul, mul_pow, ← Nat.cast_mul,
← Nat.card_prod, Commute, SemiconjBy, Prod.ext_iff]
congr 2
exact Nat.card_congr ⟨fun x => ⟨⟨⟨x.1.1.1, x.1.2.1⟩, x.2.1⟩, ⟨⟨x.1.1.2, x.1.2.2⟩, x.2.2⟩⟩,
fun x => ⟨⟨⟨x.1.1.1, x.2.1.1⟩, ⟨x.1.1.2, x.2.1.2⟩⟩, ⟨x.1.2, x.2.2⟩⟩, fun x => rfl, fun x => rfl⟩
theorem commProb_pi {α : Type*} (i : α → Type*) [Fintype α] [∀ a, Mul (i a)] :
commProb (∀ a, i a) = ∏ a, commProb (i a) := by
simp_rw [commProb_def, Finset.prod_div_distrib, Finset.prod_pow, ← Nat.cast_prod,
← Nat.card_pi, Commute, SemiconjBy, Function.funext_iff]
congr 2
exact Nat.card_congr ⟨fun x a => ⟨⟨x.1.1 a, x.1.2 a⟩, x.2 a⟩, fun x => ⟨⟨fun a => (x a).1.1,
fun a => (x a).1.2⟩, fun a => (x a).2⟩, fun x => rfl, fun x => rfl⟩
theorem commProb_function {α β : Type*} [Fintype α] [Mul β] :
commProb (α → β) = (commProb β) ^ Fintype.card α := by
rw [commProb_pi, Finset.prod_const, Finset.card_univ]
@[simp]
theorem commProb_eq_zero_of_infinite [Infinite M] : commProb M = 0 :=
div_eq_zero_iff.2 (Or.inl (Nat.cast_eq_zero.2 Nat.card_eq_zero_of_infinite))
variable [Finite M]
theorem commProb_pos [h : Nonempty M] : 0 < commProb M :=
h.elim fun x ↦
div_pos (Nat.cast_pos.mpr (Finite.card_pos_iff.mpr ⟨⟨(x, x), rfl⟩⟩))
(pow_pos (Nat.cast_pos.mpr Finite.card_pos) 2)
#align comm_prob_pos commProb_pos
| Mathlib/GroupTheory/CommutingProbability.lean | 78 | 81 | theorem commProb_le_one : commProb M ≤ 1 := by |
refine div_le_one_of_le ?_ (sq_nonneg (Nat.card M : ℚ))
rw [← Nat.cast_pow, Nat.cast_le, sq, ← Nat.card_prod]
apply Finite.card_subtype_le
|
import Mathlib.Topology.Order.MonotoneContinuity
import Mathlib.Topology.Algebra.Order.LiminfLimsup
import Mathlib.Topology.Instances.NNReal
import Mathlib.Topology.EMetricSpace.Lipschitz
import Mathlib.Topology.Metrizable.Basic
import Mathlib.Topology.Order.T5
#align_import topology.instances.ennreal from "leanprover-community/mathlib"@"ec4b2eeb50364487f80421c0b4c41328a611f30d"
noncomputable section
open Set Filter Metric Function
open scoped Classical Topology ENNReal NNReal Filter
variable {α : Type*} {β : Type*} {γ : Type*}
namespace ENNReal
variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} {x y z : ℝ≥0∞} {ε ε₁ ε₂ : ℝ≥0∞} {s : Set ℝ≥0∞}
section TopologicalSpace
open TopologicalSpace
instance : TopologicalSpace ℝ≥0∞ := Preorder.topology ℝ≥0∞
instance : OrderTopology ℝ≥0∞ := ⟨rfl⟩
-- short-circuit type class inference
instance : T2Space ℝ≥0∞ := inferInstance
instance : T5Space ℝ≥0∞ := inferInstance
instance : T4Space ℝ≥0∞ := inferInstance
instance : SecondCountableTopology ℝ≥0∞ :=
orderIsoUnitIntervalBirational.toHomeomorph.embedding.secondCountableTopology
instance : MetrizableSpace ENNReal :=
orderIsoUnitIntervalBirational.toHomeomorph.embedding.metrizableSpace
theorem embedding_coe : Embedding ((↑) : ℝ≥0 → ℝ≥0∞) :=
coe_strictMono.embedding_of_ordConnected <| by rw [range_coe']; exact ordConnected_Iio
#align ennreal.embedding_coe ENNReal.embedding_coe
theorem isOpen_ne_top : IsOpen { a : ℝ≥0∞ | a ≠ ∞ } := isOpen_ne
#align ennreal.is_open_ne_top ENNReal.isOpen_ne_top
theorem isOpen_Ico_zero : IsOpen (Ico 0 b) := by
rw [ENNReal.Ico_eq_Iio]
exact isOpen_Iio
#align ennreal.is_open_Ico_zero ENNReal.isOpen_Ico_zero
theorem openEmbedding_coe : OpenEmbedding ((↑) : ℝ≥0 → ℝ≥0∞) :=
⟨embedding_coe, by rw [range_coe']; exact isOpen_Iio⟩
#align ennreal.open_embedding_coe ENNReal.openEmbedding_coe
theorem coe_range_mem_nhds : range ((↑) : ℝ≥0 → ℝ≥0∞) ∈ 𝓝 (r : ℝ≥0∞) :=
IsOpen.mem_nhds openEmbedding_coe.isOpen_range <| mem_range_self _
#align ennreal.coe_range_mem_nhds ENNReal.coe_range_mem_nhds
@[norm_cast]
theorem tendsto_coe {f : Filter α} {m : α → ℝ≥0} {a : ℝ≥0} :
Tendsto (fun a => (m a : ℝ≥0∞)) f (𝓝 ↑a) ↔ Tendsto m f (𝓝 a) :=
embedding_coe.tendsto_nhds_iff.symm
#align ennreal.tendsto_coe ENNReal.tendsto_coe
theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ≥0∞) :=
embedding_coe.continuous
#align ennreal.continuous_coe ENNReal.continuous_coe
theorem continuous_coe_iff {α} [TopologicalSpace α] {f : α → ℝ≥0} :
(Continuous fun a => (f a : ℝ≥0∞)) ↔ Continuous f :=
embedding_coe.continuous_iff.symm
#align ennreal.continuous_coe_iff ENNReal.continuous_coe_iff
theorem nhds_coe {r : ℝ≥0} : 𝓝 (r : ℝ≥0∞) = (𝓝 r).map (↑) :=
(openEmbedding_coe.map_nhds_eq r).symm
#align ennreal.nhds_coe ENNReal.nhds_coe
theorem tendsto_nhds_coe_iff {α : Type*} {l : Filter α} {x : ℝ≥0} {f : ℝ≥0∞ → α} :
Tendsto f (𝓝 ↑x) l ↔ Tendsto (f ∘ (↑) : ℝ≥0 → α) (𝓝 x) l := by
rw [nhds_coe, tendsto_map'_iff]
#align ennreal.tendsto_nhds_coe_iff ENNReal.tendsto_nhds_coe_iff
theorem continuousAt_coe_iff {α : Type*} [TopologicalSpace α] {x : ℝ≥0} {f : ℝ≥0∞ → α} :
ContinuousAt f ↑x ↔ ContinuousAt (f ∘ (↑) : ℝ≥0 → α) x :=
tendsto_nhds_coe_iff
#align ennreal.continuous_at_coe_iff ENNReal.continuousAt_coe_iff
theorem nhds_coe_coe {r p : ℝ≥0} :
𝓝 ((r : ℝ≥0∞), (p : ℝ≥0∞)) = (𝓝 (r, p)).map fun p : ℝ≥0 × ℝ≥0 => (↑p.1, ↑p.2) :=
((openEmbedding_coe.prod openEmbedding_coe).map_nhds_eq (r, p)).symm
#align ennreal.nhds_coe_coe ENNReal.nhds_coe_coe
theorem continuous_ofReal : Continuous ENNReal.ofReal :=
(continuous_coe_iff.2 continuous_id).comp continuous_real_toNNReal
#align ennreal.continuous_of_real ENNReal.continuous_ofReal
theorem tendsto_ofReal {f : Filter α} {m : α → ℝ} {a : ℝ} (h : Tendsto m f (𝓝 a)) :
Tendsto (fun a => ENNReal.ofReal (m a)) f (𝓝 (ENNReal.ofReal a)) :=
(continuous_ofReal.tendsto a).comp h
#align ennreal.tendsto_of_real ENNReal.tendsto_ofReal
theorem tendsto_toNNReal {a : ℝ≥0∞} (ha : a ≠ ∞) :
Tendsto ENNReal.toNNReal (𝓝 a) (𝓝 a.toNNReal) := by
lift a to ℝ≥0 using ha
rw [nhds_coe, tendsto_map'_iff]
exact tendsto_id
#align ennreal.tendsto_to_nnreal ENNReal.tendsto_toNNReal
theorem eventuallyEq_of_toReal_eventuallyEq {l : Filter α} {f g : α → ℝ≥0∞}
(hfi : ∀ᶠ x in l, f x ≠ ∞) (hgi : ∀ᶠ x in l, g x ≠ ∞)
(hfg : (fun x => (f x).toReal) =ᶠ[l] fun x => (g x).toReal) : f =ᶠ[l] g := by
filter_upwards [hfi, hgi, hfg] with _ hfx hgx _
rwa [← ENNReal.toReal_eq_toReal hfx hgx]
#align ennreal.eventually_eq_of_to_real_eventually_eq ENNReal.eventuallyEq_of_toReal_eventuallyEq
theorem continuousOn_toNNReal : ContinuousOn ENNReal.toNNReal { a | a ≠ ∞ } := fun _a ha =>
ContinuousAt.continuousWithinAt (tendsto_toNNReal ha)
#align ennreal.continuous_on_to_nnreal ENNReal.continuousOn_toNNReal
theorem tendsto_toReal {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto ENNReal.toReal (𝓝 a) (𝓝 a.toReal) :=
NNReal.tendsto_coe.2 <| tendsto_toNNReal ha
#align ennreal.tendsto_to_real ENNReal.tendsto_toReal
lemma continuousOn_toReal : ContinuousOn ENNReal.toReal { a | a ≠ ∞ } :=
NNReal.continuous_coe.comp_continuousOn continuousOn_toNNReal
lemma continuousAt_toReal (hx : x ≠ ∞) : ContinuousAt ENNReal.toReal x :=
continuousOn_toReal.continuousAt (isOpen_ne_top.mem_nhds_iff.mpr hx)
def neTopHomeomorphNNReal : { a | a ≠ ∞ } ≃ₜ ℝ≥0 where
toEquiv := neTopEquivNNReal
continuous_toFun := continuousOn_iff_continuous_restrict.1 continuousOn_toNNReal
continuous_invFun := continuous_coe.subtype_mk _
#align ennreal.ne_top_homeomorph_nnreal ENNReal.neTopHomeomorphNNReal
def ltTopHomeomorphNNReal : { a | a < ∞ } ≃ₜ ℝ≥0 := by
refine (Homeomorph.setCongr ?_).trans neTopHomeomorphNNReal
simp only [mem_setOf_eq, lt_top_iff_ne_top]
#align ennreal.lt_top_homeomorph_nnreal ENNReal.ltTopHomeomorphNNReal
theorem nhds_top : 𝓝 ∞ = ⨅ (a) (_ : a ≠ ∞), 𝓟 (Ioi a) :=
nhds_top_order.trans <| by simp [lt_top_iff_ne_top, Ioi]
#align ennreal.nhds_top ENNReal.nhds_top
theorem nhds_top' : 𝓝 ∞ = ⨅ r : ℝ≥0, 𝓟 (Ioi ↑r) :=
nhds_top.trans <| iInf_ne_top _
#align ennreal.nhds_top' ENNReal.nhds_top'
theorem nhds_top_basis : (𝓝 ∞).HasBasis (fun a => a < ∞) fun a => Ioi a :=
_root_.nhds_top_basis
#align ennreal.nhds_top_basis ENNReal.nhds_top_basis
theorem tendsto_nhds_top_iff_nnreal {m : α → ℝ≥0∞} {f : Filter α} :
Tendsto m f (𝓝 ∞) ↔ ∀ x : ℝ≥0, ∀ᶠ a in f, ↑x < m a := by
simp only [nhds_top', tendsto_iInf, tendsto_principal, mem_Ioi]
#align ennreal.tendsto_nhds_top_iff_nnreal ENNReal.tendsto_nhds_top_iff_nnreal
theorem tendsto_nhds_top_iff_nat {m : α → ℝ≥0∞} {f : Filter α} :
Tendsto m f (𝓝 ∞) ↔ ∀ n : ℕ, ∀ᶠ a in f, ↑n < m a :=
tendsto_nhds_top_iff_nnreal.trans
⟨fun h n => by simpa only [ENNReal.coe_natCast] using h n, fun h x =>
let ⟨n, hn⟩ := exists_nat_gt x
(h n).mono fun y => lt_trans <| by rwa [← ENNReal.coe_natCast, coe_lt_coe]⟩
#align ennreal.tendsto_nhds_top_iff_nat ENNReal.tendsto_nhds_top_iff_nat
theorem tendsto_nhds_top {m : α → ℝ≥0∞} {f : Filter α} (h : ∀ n : ℕ, ∀ᶠ a in f, ↑n < m a) :
Tendsto m f (𝓝 ∞) :=
tendsto_nhds_top_iff_nat.2 h
#align ennreal.tendsto_nhds_top ENNReal.tendsto_nhds_top
theorem tendsto_nat_nhds_top : Tendsto (fun n : ℕ => ↑n) atTop (𝓝 ∞) :=
tendsto_nhds_top fun n =>
mem_atTop_sets.2 ⟨n + 1, fun _m hm => mem_setOf.2 <| Nat.cast_lt.2 <| Nat.lt_of_succ_le hm⟩
#align ennreal.tendsto_nat_nhds_top ENNReal.tendsto_nat_nhds_top
@[simp, norm_cast]
theorem tendsto_coe_nhds_top {f : α → ℝ≥0} {l : Filter α} :
Tendsto (fun x => (f x : ℝ≥0∞)) l (𝓝 ∞) ↔ Tendsto f l atTop := by
rw [tendsto_nhds_top_iff_nnreal, atTop_basis_Ioi.tendsto_right_iff]; simp
#align ennreal.tendsto_coe_nhds_top ENNReal.tendsto_coe_nhds_top
theorem tendsto_ofReal_atTop : Tendsto ENNReal.ofReal atTop (𝓝 ∞) :=
tendsto_coe_nhds_top.2 tendsto_real_toNNReal_atTop
#align ennreal.tendsto_of_real_at_top ENNReal.tendsto_ofReal_atTop
theorem nhds_zero : 𝓝 (0 : ℝ≥0∞) = ⨅ (a) (_ : a ≠ 0), 𝓟 (Iio a) :=
nhds_bot_order.trans <| by simp [pos_iff_ne_zero, Iio]
#align ennreal.nhds_zero ENNReal.nhds_zero
theorem nhds_zero_basis : (𝓝 (0 : ℝ≥0∞)).HasBasis (fun a : ℝ≥0∞ => 0 < a) fun a => Iio a :=
nhds_bot_basis
#align ennreal.nhds_zero_basis ENNReal.nhds_zero_basis
theorem nhds_zero_basis_Iic : (𝓝 (0 : ℝ≥0∞)).HasBasis (fun a : ℝ≥0∞ => 0 < a) Iic :=
nhds_bot_basis_Iic
#align ennreal.nhds_zero_basis_Iic ENNReal.nhds_zero_basis_Iic
-- Porting note (#11215): TODO: add a TC for `≠ ∞`?
@[instance]
theorem nhdsWithin_Ioi_coe_neBot {r : ℝ≥0} : (𝓝[>] (r : ℝ≥0∞)).NeBot :=
nhdsWithin_Ioi_self_neBot' ⟨∞, ENNReal.coe_lt_top⟩
#align ennreal.nhds_within_Ioi_coe_ne_bot ENNReal.nhdsWithin_Ioi_coe_neBot
@[instance]
theorem nhdsWithin_Ioi_zero_neBot : (𝓝[>] (0 : ℝ≥0∞)).NeBot :=
nhdsWithin_Ioi_coe_neBot
#align ennreal.nhds_within_Ioi_zero_ne_bot ENNReal.nhdsWithin_Ioi_zero_neBot
@[instance]
theorem nhdsWithin_Ioi_one_neBot : (𝓝[>] (1 : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot
@[instance]
theorem nhdsWithin_Ioi_nat_neBot (n : ℕ) : (𝓝[>] (n : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot
@[instance]
theorem nhdsWithin_Ioi_ofNat_nebot (n : ℕ) [n.AtLeastTwo] :
(𝓝[>] (OfNat.ofNat n : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot
@[instance]
theorem nhdsWithin_Iio_neBot [NeZero x] : (𝓝[<] x).NeBot :=
nhdsWithin_Iio_self_neBot' ⟨0, NeZero.pos x⟩
theorem hasBasis_nhds_of_ne_top' (xt : x ≠ ∞) :
(𝓝 x).HasBasis (· ≠ 0) (fun ε => Icc (x - ε) (x + ε)) := by
rcases (zero_le x).eq_or_gt with rfl | x0
· simp_rw [zero_tsub, zero_add, ← bot_eq_zero, Icc_bot, ← bot_lt_iff_ne_bot]
exact nhds_bot_basis_Iic
· refine (nhds_basis_Ioo' ⟨_, x0⟩ ⟨_, xt.lt_top⟩).to_hasBasis ?_ fun ε ε0 => ?_
· rintro ⟨a, b⟩ ⟨ha, hb⟩
rcases exists_between (tsub_pos_of_lt ha) with ⟨ε, ε0, hε⟩
rcases lt_iff_exists_add_pos_lt.1 hb with ⟨δ, δ0, hδ⟩
refine ⟨min ε δ, (lt_min ε0 (coe_pos.2 δ0)).ne', Icc_subset_Ioo ?_ ?_⟩
· exact lt_tsub_comm.2 ((min_le_left _ _).trans_lt hε)
· exact (add_le_add_left (min_le_right _ _) _).trans_lt hδ
· exact ⟨(x - ε, x + ε), ⟨ENNReal.sub_lt_self xt x0.ne' ε0,
lt_add_right xt ε0⟩, Ioo_subset_Icc_self⟩
theorem hasBasis_nhds_of_ne_top (xt : x ≠ ∞) :
(𝓝 x).HasBasis (0 < ·) (fun ε => Icc (x - ε) (x + ε)) := by
simpa only [pos_iff_ne_zero] using hasBasis_nhds_of_ne_top' xt
theorem Icc_mem_nhds (xt : x ≠ ∞) (ε0 : ε ≠ 0) : Icc (x - ε) (x + ε) ∈ 𝓝 x :=
(hasBasis_nhds_of_ne_top' xt).mem_of_mem ε0
#align ennreal.Icc_mem_nhds ENNReal.Icc_mem_nhds
theorem nhds_of_ne_top (xt : x ≠ ∞) : 𝓝 x = ⨅ ε > 0, 𝓟 (Icc (x - ε) (x + ε)) :=
(hasBasis_nhds_of_ne_top xt).eq_biInf
#align ennreal.nhds_of_ne_top ENNReal.nhds_of_ne_top
theorem biInf_le_nhds : ∀ x : ℝ≥0∞, ⨅ ε > 0, 𝓟 (Icc (x - ε) (x + ε)) ≤ 𝓝 x
| ∞ => iInf₂_le_of_le 1 one_pos <| by
simpa only [← coe_one, top_sub_coe, top_add, Icc_self, principal_singleton] using pure_le_nhds _
| (x : ℝ≥0) => (nhds_of_ne_top coe_ne_top).ge
-- Porting note (#10756): new lemma
protected theorem tendsto_nhds_of_Icc {f : Filter α} {u : α → ℝ≥0∞} {a : ℝ≥0∞}
(h : ∀ ε > 0, ∀ᶠ x in f, u x ∈ Icc (a - ε) (a + ε)) : Tendsto u f (𝓝 a) := by
refine Tendsto.mono_right ?_ (biInf_le_nhds _)
simpa only [tendsto_iInf, tendsto_principal]
protected theorem tendsto_nhds {f : Filter α} {u : α → ℝ≥0∞} {a : ℝ≥0∞} (ha : a ≠ ∞) :
Tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, u x ∈ Icc (a - ε) (a + ε) := by
simp only [nhds_of_ne_top ha, tendsto_iInf, tendsto_principal]
#align ennreal.tendsto_nhds ENNReal.tendsto_nhds
protected theorem tendsto_nhds_zero {f : Filter α} {u : α → ℝ≥0∞} :
Tendsto u f (𝓝 0) ↔ ∀ ε > 0, ∀ᶠ x in f, u x ≤ ε :=
nhds_zero_basis_Iic.tendsto_right_iff
#align ennreal.tendsto_nhds_zero ENNReal.tendsto_nhds_zero
protected theorem tendsto_atTop [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} {a : ℝ≥0∞}
(ha : a ≠ ∞) : Tendsto f atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, f n ∈ Icc (a - ε) (a + ε) :=
.trans (atTop_basis.tendsto_iff (hasBasis_nhds_of_ne_top ha)) (by simp only [true_and]; rfl)
#align ennreal.tendsto_at_top ENNReal.tendsto_atTop
instance : ContinuousAdd ℝ≥0∞ := by
refine ⟨continuous_iff_continuousAt.2 ?_⟩
rintro ⟨_ | a, b⟩
· exact tendsto_nhds_top_mono' continuousAt_fst fun p => le_add_right le_rfl
rcases b with (_ | b)
· exact tendsto_nhds_top_mono' continuousAt_snd fun p => le_add_left le_rfl
simp only [ContinuousAt, some_eq_coe, nhds_coe_coe, ← coe_add, tendsto_map'_iff, (· ∘ ·),
tendsto_coe, tendsto_add]
protected theorem tendsto_atTop_zero [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} :
Tendsto f atTop (𝓝 0) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, f n ≤ ε :=
.trans (atTop_basis.tendsto_iff nhds_zero_basis_Iic) (by simp only [true_and]; rfl)
#align ennreal.tendsto_at_top_zero ENNReal.tendsto_atTop_zero
theorem tendsto_sub : ∀ {a b : ℝ≥0∞}, (a ≠ ∞ ∨ b ≠ ∞) →
Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 - p.2) (𝓝 (a, b)) (𝓝 (a - b))
| ∞, ∞, h => by simp only [ne_eq, not_true_eq_false, or_self] at h
| ∞, (b : ℝ≥0), _ => by
rw [top_sub_coe, tendsto_nhds_top_iff_nnreal]
refine fun x => ((lt_mem_nhds <| @coe_lt_top (b + 1 + x)).prod_nhds
(ge_mem_nhds <| coe_lt_coe.2 <| lt_add_one b)).mono fun y hy => ?_
rw [lt_tsub_iff_left]
calc y.2 + x ≤ ↑(b + 1) + x := add_le_add_right hy.2 _
_ < y.1 := hy.1
| (a : ℝ≥0), ∞, _ => by
rw [sub_top]
refine (tendsto_pure.2 ?_).mono_right (pure_le_nhds _)
exact ((gt_mem_nhds <| coe_lt_coe.2 <| lt_add_one a).prod_nhds
(lt_mem_nhds <| @coe_lt_top (a + 1))).mono fun x hx =>
tsub_eq_zero_iff_le.2 (hx.1.trans hx.2).le
| (a : ℝ≥0), (b : ℝ≥0), _ => by
simp only [nhds_coe_coe, tendsto_map'_iff, ← ENNReal.coe_sub, (· ∘ ·), tendsto_coe]
exact continuous_sub.tendsto (a, b)
#align ennreal.tendsto_sub ENNReal.tendsto_sub
protected theorem Tendsto.sub {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hma : Tendsto ma f (𝓝 a)) (hmb : Tendsto mb f (𝓝 b)) (h : a ≠ ∞ ∨ b ≠ ∞) :
Tendsto (fun a => ma a - mb a) f (𝓝 (a - b)) :=
show Tendsto ((fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 - p.2) ∘ fun a => (ma a, mb a)) f (𝓝 (a - b)) from
Tendsto.comp (ENNReal.tendsto_sub h) (hma.prod_mk_nhds hmb)
#align ennreal.tendsto.sub ENNReal.Tendsto.sub
protected theorem tendsto_mul (ha : a ≠ 0 ∨ b ≠ ∞) (hb : b ≠ 0 ∨ a ≠ ∞) :
Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) (𝓝 (a, b)) (𝓝 (a * b)) := by
have ht : ∀ b : ℝ≥0∞, b ≠ 0 →
Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) (𝓝 (∞, b)) (𝓝 ∞) := fun b hb => by
refine tendsto_nhds_top_iff_nnreal.2 fun n => ?_
rcases lt_iff_exists_nnreal_btwn.1 (pos_iff_ne_zero.2 hb) with ⟨ε, hε, hεb⟩
have : ∀ᶠ c : ℝ≥0∞ × ℝ≥0∞ in 𝓝 (∞, b), ↑n / ↑ε < c.1 ∧ ↑ε < c.2 :=
(lt_mem_nhds <| div_lt_top coe_ne_top hε.ne').prod_nhds (lt_mem_nhds hεb)
refine this.mono fun c hc => ?_
exact (ENNReal.div_mul_cancel hε.ne' coe_ne_top).symm.trans_lt (mul_lt_mul hc.1 hc.2)
induction a with
| top => simp only [ne_eq, or_false, not_true_eq_false] at hb; simp [ht b hb, top_mul hb]
| coe a =>
induction b with
| top =>
simp only [ne_eq, or_false, not_true_eq_false] at ha
simpa [(· ∘ ·), mul_comm, mul_top ha]
using (ht a ha).comp (continuous_swap.tendsto (ofNNReal a, ∞))
| coe b =>
simp only [nhds_coe_coe, ← coe_mul, tendsto_coe, tendsto_map'_iff, (· ∘ ·), tendsto_mul]
#align ennreal.tendsto_mul ENNReal.tendsto_mul
protected theorem Tendsto.mul {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hma : Tendsto ma f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ ∞) (hmb : Tendsto mb f (𝓝 b))
(hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun a => ma a * mb a) f (𝓝 (a * b)) :=
show Tendsto ((fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) ∘ fun a => (ma a, mb a)) f (𝓝 (a * b)) from
Tendsto.comp (ENNReal.tendsto_mul ha hb) (hma.prod_mk_nhds hmb)
#align ennreal.tendsto.mul ENNReal.Tendsto.mul
theorem _root_.ContinuousOn.ennreal_mul [TopologicalSpace α] {f g : α → ℝ≥0∞} {s : Set α}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) (h₁ : ∀ x ∈ s, f x ≠ 0 ∨ g x ≠ ∞)
(h₂ : ∀ x ∈ s, g x ≠ 0 ∨ f x ≠ ∞) : ContinuousOn (fun x => f x * g x) s := fun x hx =>
ENNReal.Tendsto.mul (hf x hx) (h₁ x hx) (hg x hx) (h₂ x hx)
#align continuous_on.ennreal_mul ContinuousOn.ennreal_mul
theorem _root_.Continuous.ennreal_mul [TopologicalSpace α] {f g : α → ℝ≥0∞} (hf : Continuous f)
(hg : Continuous g) (h₁ : ∀ x, f x ≠ 0 ∨ g x ≠ ∞) (h₂ : ∀ x, g x ≠ 0 ∨ f x ≠ ∞) :
Continuous fun x => f x * g x :=
continuous_iff_continuousAt.2 fun x =>
ENNReal.Tendsto.mul hf.continuousAt (h₁ x) hg.continuousAt (h₂ x)
#align continuous.ennreal_mul Continuous.ennreal_mul
protected theorem Tendsto.const_mul {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hm : Tendsto m f (𝓝 b)) (hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun b => a * m b) f (𝓝 (a * b)) :=
by_cases (fun (this : a = 0) => by simp [this, tendsto_const_nhds]) fun ha : a ≠ 0 =>
ENNReal.Tendsto.mul tendsto_const_nhds (Or.inl ha) hm hb
#align ennreal.tendsto.const_mul ENNReal.Tendsto.const_mul
protected theorem Tendsto.mul_const {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hm : Tendsto m f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ ∞) : Tendsto (fun x => m x * b) f (𝓝 (a * b)) := by
simpa only [mul_comm] using ENNReal.Tendsto.const_mul hm ha
#align ennreal.tendsto.mul_const ENNReal.Tendsto.mul_const
theorem tendsto_finset_prod_of_ne_top {ι : Type*} {f : ι → α → ℝ≥0∞} {x : Filter α} {a : ι → ℝ≥0∞}
(s : Finset ι) (h : ∀ i ∈ s, Tendsto (f i) x (𝓝 (a i))) (h' : ∀ i ∈ s, a i ≠ ∞) :
Tendsto (fun b => ∏ c ∈ s, f c b) x (𝓝 (∏ c ∈ s, a c)) := by
induction' s using Finset.induction with a s has IH
· simp [tendsto_const_nhds]
simp only [Finset.prod_insert has]
apply Tendsto.mul (h _ (Finset.mem_insert_self _ _))
· right
exact (prod_lt_top fun i hi => h' _ (Finset.mem_insert_of_mem hi)).ne
· exact IH (fun i hi => h _ (Finset.mem_insert_of_mem hi)) fun i hi =>
h' _ (Finset.mem_insert_of_mem hi)
· exact Or.inr (h' _ (Finset.mem_insert_self _ _))
#align ennreal.tendsto_finset_prod_of_ne_top ENNReal.tendsto_finset_prod_of_ne_top
protected theorem continuousAt_const_mul {a b : ℝ≥0∞} (h : a ≠ ∞ ∨ b ≠ 0) :
ContinuousAt (a * ·) b :=
Tendsto.const_mul tendsto_id h.symm
#align ennreal.continuous_at_const_mul ENNReal.continuousAt_const_mul
protected theorem continuousAt_mul_const {a b : ℝ≥0∞} (h : a ≠ ∞ ∨ b ≠ 0) :
ContinuousAt (fun x => x * a) b :=
Tendsto.mul_const tendsto_id h.symm
#align ennreal.continuous_at_mul_const ENNReal.continuousAt_mul_const
protected theorem continuous_const_mul {a : ℝ≥0∞} (ha : a ≠ ∞) : Continuous (a * ·) :=
continuous_iff_continuousAt.2 fun _ => ENNReal.continuousAt_const_mul (Or.inl ha)
#align ennreal.continuous_const_mul ENNReal.continuous_const_mul
protected theorem continuous_mul_const {a : ℝ≥0∞} (ha : a ≠ ∞) : Continuous fun x => x * a :=
continuous_iff_continuousAt.2 fun _ => ENNReal.continuousAt_mul_const (Or.inl ha)
#align ennreal.continuous_mul_const ENNReal.continuous_mul_const
protected theorem continuous_div_const (c : ℝ≥0∞) (c_ne_zero : c ≠ 0) :
Continuous fun x : ℝ≥0∞ => x / c := by
simp_rw [div_eq_mul_inv, continuous_iff_continuousAt]
intro x
exact ENNReal.continuousAt_mul_const (Or.intro_left _ (inv_ne_top.mpr c_ne_zero))
#align ennreal.continuous_div_const ENNReal.continuous_div_const
@[continuity]
theorem continuous_pow (n : ℕ) : Continuous fun a : ℝ≥0∞ => a ^ n := by
induction' n with n IH
· simp [continuous_const]
simp_rw [pow_add, pow_one, continuous_iff_continuousAt]
intro x
refine ENNReal.Tendsto.mul (IH.tendsto _) ?_ tendsto_id ?_ <;> by_cases H : x = 0
· simp only [H, zero_ne_top, Ne, or_true_iff, not_false_iff]
· exact Or.inl fun h => H (pow_eq_zero h)
· simp only [H, pow_eq_top_iff, zero_ne_top, false_or_iff, eq_self_iff_true, not_true, Ne,
not_false_iff, false_and_iff]
· simp only [H, true_or_iff, Ne, not_false_iff]
#align ennreal.continuous_pow ENNReal.continuous_pow
theorem continuousOn_sub :
ContinuousOn (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) { p : ℝ≥0∞ × ℝ≥0∞ | p ≠ ⟨∞, ∞⟩ } := by
rw [ContinuousOn]
rintro ⟨x, y⟩ hp
simp only [Ne, Set.mem_setOf_eq, Prod.mk.inj_iff] at hp
exact tendsto_nhdsWithin_of_tendsto_nhds (tendsto_sub (not_and_or.mp hp))
#align ennreal.continuous_on_sub ENNReal.continuousOn_sub
theorem continuous_sub_left {a : ℝ≥0∞} (a_ne_top : a ≠ ∞) : Continuous (a - ·) := by
change Continuous (Function.uncurry Sub.sub ∘ (a, ·))
refine continuousOn_sub.comp_continuous (Continuous.Prod.mk a) fun x => ?_
simp only [a_ne_top, Ne, mem_setOf_eq, Prod.mk.inj_iff, false_and_iff, not_false_iff]
#align ennreal.continuous_sub_left ENNReal.continuous_sub_left
theorem continuous_nnreal_sub {a : ℝ≥0} : Continuous fun x : ℝ≥0∞ => (a : ℝ≥0∞) - x :=
continuous_sub_left coe_ne_top
#align ennreal.continuous_nnreal_sub ENNReal.continuous_nnreal_sub
theorem continuousOn_sub_left (a : ℝ≥0∞) : ContinuousOn (a - ·) { x : ℝ≥0∞ | x ≠ ∞ } := by
rw [show (fun x => a - x) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨a, x⟩ by rfl]
apply ContinuousOn.comp continuousOn_sub (Continuous.continuousOn (Continuous.Prod.mk a))
rintro _ h (_ | _)
exact h none_eq_top
#align ennreal.continuous_on_sub_left ENNReal.continuousOn_sub_left
theorem continuous_sub_right (a : ℝ≥0∞) : Continuous fun x : ℝ≥0∞ => x - a := by
by_cases a_infty : a = ∞
· simp [a_infty, continuous_const]
· rw [show (fun x => x - a) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨x, a⟩ by rfl]
apply ContinuousOn.comp_continuous continuousOn_sub (continuous_id'.prod_mk continuous_const)
intro x
simp only [a_infty, Ne, mem_setOf_eq, Prod.mk.inj_iff, and_false_iff, not_false_iff]
#align ennreal.continuous_sub_right ENNReal.continuous_sub_right
protected theorem Tendsto.pow {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} {n : ℕ}
(hm : Tendsto m f (𝓝 a)) : Tendsto (fun x => m x ^ n) f (𝓝 (a ^ n)) :=
((continuous_pow n).tendsto a).comp hm
#align ennreal.tendsto.pow ENNReal.Tendsto.pow
theorem le_of_forall_lt_one_mul_le {x y : ℝ≥0∞} (h : ∀ a < 1, a * x ≤ y) : x ≤ y := by
have : Tendsto (· * x) (𝓝[<] 1) (𝓝 (1 * x)) :=
(ENNReal.continuousAt_mul_const (Or.inr one_ne_zero)).mono_left inf_le_left
rw [one_mul] at this
exact le_of_tendsto this (eventually_nhdsWithin_iff.2 <| eventually_of_forall h)
#align ennreal.le_of_forall_lt_one_mul_le ENNReal.le_of_forall_lt_one_mul_le
theorem iInf_mul_left' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0)
(h0 : a = 0 → Nonempty ι) : ⨅ i, a * f i = a * ⨅ i, f i := by
by_cases H : a = ∞ ∧ ⨅ i, f i = 0
· rcases h H.1 H.2 with ⟨i, hi⟩
rw [H.2, mul_zero, ← bot_eq_zero, iInf_eq_bot]
exact fun b hb => ⟨i, by rwa [hi, mul_zero, ← bot_eq_zero]⟩
· rw [not_and_or] at H
cases isEmpty_or_nonempty ι
· rw [iInf_of_empty, iInf_of_empty, mul_top]
exact mt h0 (not_nonempty_iff.2 ‹_›)
· exact (ENNReal.mul_left_mono.map_iInf_of_continuousAt'
(ENNReal.continuousAt_const_mul H)).symm
#align ennreal.infi_mul_left' ENNReal.iInf_mul_left'
theorem iInf_mul_left {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞}
(h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) : ⨅ i, a * f i = a * ⨅ i, f i :=
iInf_mul_left' h fun _ => ‹Nonempty ι›
#align ennreal.infi_mul_left ENNReal.iInf_mul_left
theorem iInf_mul_right' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0)
(h0 : a = 0 → Nonempty ι) : ⨅ i, f i * a = (⨅ i, f i) * a := by
simpa only [mul_comm a] using iInf_mul_left' h h0
#align ennreal.infi_mul_right' ENNReal.iInf_mul_right'
theorem iInf_mul_right {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞}
(h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) : ⨅ i, f i * a = (⨅ i, f i) * a :=
iInf_mul_right' h fun _ => ‹Nonempty ι›
#align ennreal.infi_mul_right ENNReal.iInf_mul_right
theorem inv_map_iInf {ι : Sort*} {x : ι → ℝ≥0∞} : (iInf x)⁻¹ = ⨆ i, (x i)⁻¹ :=
OrderIso.invENNReal.map_iInf x
#align ennreal.inv_map_infi ENNReal.inv_map_iInf
theorem inv_map_iSup {ι : Sort*} {x : ι → ℝ≥0∞} : (iSup x)⁻¹ = ⨅ i, (x i)⁻¹ :=
OrderIso.invENNReal.map_iSup x
#align ennreal.inv_map_supr ENNReal.inv_map_iSup
theorem inv_limsup {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} :
(limsup x l)⁻¹ = liminf (fun i => (x i)⁻¹) l :=
OrderIso.invENNReal.limsup_apply
#align ennreal.inv_limsup ENNReal.inv_limsup
theorem inv_liminf {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} :
(liminf x l)⁻¹ = limsup (fun i => (x i)⁻¹) l :=
OrderIso.invENNReal.liminf_apply
#align ennreal.inv_liminf ENNReal.inv_liminf
instance : ContinuousInv ℝ≥0∞ := ⟨OrderIso.invENNReal.continuous⟩
@[simp] -- Porting note (#11215): TODO: generalize to `[InvolutiveInv _] [ContinuousInv _]`
protected theorem tendsto_inv_iff {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} :
Tendsto (fun x => (m x)⁻¹) f (𝓝 a⁻¹) ↔ Tendsto m f (𝓝 a) :=
⟨fun h => by simpa only [inv_inv] using Tendsto.inv h, Tendsto.inv⟩
#align ennreal.tendsto_inv_iff ENNReal.tendsto_inv_iff
protected theorem Tendsto.div {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hma : Tendsto ma f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ 0) (hmb : Tendsto mb f (𝓝 b))
(hb : b ≠ ∞ ∨ a ≠ ∞) : Tendsto (fun a => ma a / mb a) f (𝓝 (a / b)) := by
apply Tendsto.mul hma _ (ENNReal.tendsto_inv_iff.2 hmb) _ <;> simp [ha, hb]
#align ennreal.tendsto.div ENNReal.Tendsto.div
protected theorem Tendsto.const_div {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hm : Tendsto m f (𝓝 b)) (hb : b ≠ ∞ ∨ a ≠ ∞) : Tendsto (fun b => a / m b) f (𝓝 (a / b)) := by
apply Tendsto.const_mul (ENNReal.tendsto_inv_iff.2 hm)
simp [hb]
#align ennreal.tendsto.const_div ENNReal.Tendsto.const_div
protected theorem Tendsto.div_const {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hm : Tendsto m f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ 0) : Tendsto (fun x => m x / b) f (𝓝 (a / b)) := by
apply Tendsto.mul_const hm
simp [ha]
#align ennreal.tendsto.div_const ENNReal.Tendsto.div_const
protected theorem tendsto_inv_nat_nhds_zero : Tendsto (fun n : ℕ => (n : ℝ≥0∞)⁻¹) atTop (𝓝 0) :=
ENNReal.inv_top ▸ ENNReal.tendsto_inv_iff.2 tendsto_nat_nhds_top
#align ennreal.tendsto_inv_nat_nhds_zero ENNReal.tendsto_inv_nat_nhds_zero
theorem iSup_add {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : iSup s + a = ⨆ b, s b + a :=
Monotone.map_iSup_of_continuousAt' (continuousAt_id.add continuousAt_const) <|
monotone_id.add monotone_const
#align ennreal.supr_add ENNReal.iSup_add
theorem biSup_add' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} :
(⨆ (i) (_ : p i), f i) + a = ⨆ (i) (_ : p i), f i + a := by
haveI : Nonempty { i // p i } := nonempty_subtype.2 h
simp only [iSup_subtype', iSup_add]
#align ennreal.bsupr_add' ENNReal.biSup_add'
theorem add_biSup' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} :
(a + ⨆ (i) (_ : p i), f i) = ⨆ (i) (_ : p i), a + f i := by
simp only [add_comm a, biSup_add' h]
#align ennreal.add_bsupr' ENNReal.add_biSup'
theorem biSup_add {ι} {s : Set ι} (hs : s.Nonempty) {f : ι → ℝ≥0∞} :
(⨆ i ∈ s, f i) + a = ⨆ i ∈ s, f i + a :=
biSup_add' hs
#align ennreal.bsupr_add ENNReal.biSup_add
theorem add_biSup {ι} {s : Set ι} (hs : s.Nonempty) {f : ι → ℝ≥0∞} :
(a + ⨆ i ∈ s, f i) = ⨆ i ∈ s, a + f i :=
add_biSup' hs
#align ennreal.add_bsupr ENNReal.add_biSup
theorem sSup_add {s : Set ℝ≥0∞} (hs : s.Nonempty) : sSup s + a = ⨆ b ∈ s, b + a := by
rw [sSup_eq_iSup, biSup_add hs]
#align ennreal.Sup_add ENNReal.sSup_add
theorem add_iSup {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : a + iSup s = ⨆ b, a + s b := by
rw [add_comm, iSup_add]; simp [add_comm]
#align ennreal.add_supr ENNReal.add_iSup
theorem iSup_add_iSup_le {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞}
{a : ℝ≥0∞} (h : ∀ i j, f i + g j ≤ a) : iSup f + iSup g ≤ a := by
simp_rw [iSup_add, add_iSup]; exact iSup₂_le h
#align ennreal.supr_add_supr_le ENNReal.iSup_add_iSup_le
theorem biSup_add_biSup_le' {ι ι'} {p : ι → Prop} {q : ι' → Prop} (hp : ∃ i, p i) (hq : ∃ j, q j)
{f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ i, p i → ∀ j, q j → f i + g j ≤ a) :
((⨆ (i) (_ : p i), f i) + ⨆ (j) (_ : q j), g j) ≤ a := by
simp_rw [biSup_add' hp, add_biSup' hq]
exact iSup₂_le fun i hi => iSup₂_le (h i hi)
#align ennreal.bsupr_add_bsupr_le' ENNReal.biSup_add_biSup_le'
theorem biSup_add_biSup_le {ι ι'} {s : Set ι} {t : Set ι'} (hs : s.Nonempty) (ht : t.Nonempty)
{f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ i ∈ s, ∀ j ∈ t, f i + g j ≤ a) :
((⨆ i ∈ s, f i) + ⨆ j ∈ t, g j) ≤ a :=
biSup_add_biSup_le' hs ht h
#align ennreal.bsupr_add_bsupr_le ENNReal.biSup_add_biSup_le
| Mathlib/Topology/Instances/ENNReal.lean | 621 | 628 | theorem iSup_add_iSup {ι : Sort*} {f g : ι → ℝ≥0∞} (h : ∀ i j, ∃ k, f i + g j ≤ f k + g k) :
iSup f + iSup g = ⨆ a, f a + g a := by |
cases isEmpty_or_nonempty ι
· simp only [iSup_of_empty, bot_eq_zero, zero_add]
· refine le_antisymm ?_ (iSup_le fun a => add_le_add (le_iSup _ _) (le_iSup _ _))
refine iSup_add_iSup_le fun i j => ?_
rcases h i j with ⟨k, hk⟩
exact le_iSup_of_le k hk
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Topology.Order.ProjIcc
#align_import analysis.special_functions.trigonometric.inverse from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open scoped Classical
open Topology Filter
open Set Filter
open Real
namespace Real
variable {x y : ℝ}
-- @[pp_nodot] Porting note: not implemented
noncomputable def arcsin : ℝ → ℝ :=
Subtype.val ∘ IccExtend (neg_le_self zero_le_one) sinOrderIso.symm
#align real.arcsin Real.arcsin
theorem arcsin_mem_Icc (x : ℝ) : arcsin x ∈ Icc (-(π / 2)) (π / 2) :=
Subtype.coe_prop _
#align real.arcsin_mem_Icc Real.arcsin_mem_Icc
@[simp]
theorem range_arcsin : range arcsin = Icc (-(π / 2)) (π / 2) := by
rw [arcsin, range_comp Subtype.val]
simp [Icc]
#align real.range_arcsin Real.range_arcsin
theorem arcsin_le_pi_div_two (x : ℝ) : arcsin x ≤ π / 2 :=
(arcsin_mem_Icc x).2
#align real.arcsin_le_pi_div_two Real.arcsin_le_pi_div_two
theorem neg_pi_div_two_le_arcsin (x : ℝ) : -(π / 2) ≤ arcsin x :=
(arcsin_mem_Icc x).1
#align real.neg_pi_div_two_le_arcsin Real.neg_pi_div_two_le_arcsin
theorem arcsin_projIcc (x : ℝ) :
arcsin (projIcc (-1) 1 (neg_le_self zero_le_one) x) = arcsin x := by
rw [arcsin, Function.comp_apply, IccExtend_val, Function.comp_apply, IccExtend,
Function.comp_apply]
#align real.arcsin_proj_Icc Real.arcsin_projIcc
theorem sin_arcsin' {x : ℝ} (hx : x ∈ Icc (-1 : ℝ) 1) : sin (arcsin x) = x := by
simpa [arcsin, IccExtend_of_mem _ _ hx, -OrderIso.apply_symm_apply] using
Subtype.ext_iff.1 (sinOrderIso.apply_symm_apply ⟨x, hx⟩)
#align real.sin_arcsin' Real.sin_arcsin'
theorem sin_arcsin {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : sin (arcsin x) = x :=
sin_arcsin' ⟨hx₁, hx₂⟩
#align real.sin_arcsin Real.sin_arcsin
theorem arcsin_sin' {x : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) : arcsin (sin x) = x :=
injOn_sin (arcsin_mem_Icc _) hx <| by rw [sin_arcsin (neg_one_le_sin _) (sin_le_one _)]
#align real.arcsin_sin' Real.arcsin_sin'
theorem arcsin_sin {x : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) : arcsin (sin x) = x :=
arcsin_sin' ⟨hx₁, hx₂⟩
#align real.arcsin_sin Real.arcsin_sin
theorem strictMonoOn_arcsin : StrictMonoOn arcsin (Icc (-1) 1) :=
(Subtype.strictMono_coe _).comp_strictMonoOn <|
sinOrderIso.symm.strictMono.strictMonoOn_IccExtend _
#align real.strict_mono_on_arcsin Real.strictMonoOn_arcsin
theorem monotone_arcsin : Monotone arcsin :=
(Subtype.mono_coe _).comp <| sinOrderIso.symm.monotone.IccExtend _
#align real.monotone_arcsin Real.monotone_arcsin
theorem injOn_arcsin : InjOn arcsin (Icc (-1) 1) :=
strictMonoOn_arcsin.injOn
#align real.inj_on_arcsin Real.injOn_arcsin
theorem arcsin_inj {x y : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) (hy₁ : -1 ≤ y) (hy₂ : y ≤ 1) :
arcsin x = arcsin y ↔ x = y :=
injOn_arcsin.eq_iff ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩
#align real.arcsin_inj Real.arcsin_inj
@[continuity]
theorem continuous_arcsin : Continuous arcsin :=
continuous_subtype_val.comp sinOrderIso.symm.continuous.Icc_extend'
#align real.continuous_arcsin Real.continuous_arcsin
theorem continuousAt_arcsin {x : ℝ} : ContinuousAt arcsin x :=
continuous_arcsin.continuousAt
#align real.continuous_at_arcsin Real.continuousAt_arcsin
theorem arcsin_eq_of_sin_eq {x y : ℝ} (h₁ : sin x = y) (h₂ : x ∈ Icc (-(π / 2)) (π / 2)) :
arcsin y = x := by
subst y
exact injOn_sin (arcsin_mem_Icc _) h₂ (sin_arcsin' (sin_mem_Icc x))
#align real.arcsin_eq_of_sin_eq Real.arcsin_eq_of_sin_eq
@[simp]
theorem arcsin_zero : arcsin 0 = 0 :=
arcsin_eq_of_sin_eq sin_zero ⟨neg_nonpos.2 pi_div_two_pos.le, pi_div_two_pos.le⟩
#align real.arcsin_zero Real.arcsin_zero
@[simp]
theorem arcsin_one : arcsin 1 = π / 2 :=
arcsin_eq_of_sin_eq sin_pi_div_two <| right_mem_Icc.2 (neg_le_self pi_div_two_pos.le)
#align real.arcsin_one Real.arcsin_one
theorem arcsin_of_one_le {x : ℝ} (hx : 1 ≤ x) : arcsin x = π / 2 := by
rw [← arcsin_projIcc, projIcc_of_right_le _ hx, Subtype.coe_mk, arcsin_one]
#align real.arcsin_of_one_le Real.arcsin_of_one_le
theorem arcsin_neg_one : arcsin (-1) = -(π / 2) :=
arcsin_eq_of_sin_eq (by rw [sin_neg, sin_pi_div_two]) <|
left_mem_Icc.2 (neg_le_self pi_div_two_pos.le)
#align real.arcsin_neg_one Real.arcsin_neg_one
theorem arcsin_of_le_neg_one {x : ℝ} (hx : x ≤ -1) : arcsin x = -(π / 2) := by
rw [← arcsin_projIcc, projIcc_of_le_left _ hx, Subtype.coe_mk, arcsin_neg_one]
#align real.arcsin_of_le_neg_one Real.arcsin_of_le_neg_one
@[simp]
theorem arcsin_neg (x : ℝ) : arcsin (-x) = -arcsin x := by
rcases le_total x (-1) with hx₁ | hx₁
· rw [arcsin_of_le_neg_one hx₁, neg_neg, arcsin_of_one_le (le_neg.2 hx₁)]
rcases le_total 1 x with hx₂ | hx₂
· rw [arcsin_of_one_le hx₂, arcsin_of_le_neg_one (neg_le_neg hx₂)]
refine arcsin_eq_of_sin_eq ?_ ?_
· rw [sin_neg, sin_arcsin hx₁ hx₂]
· exact ⟨neg_le_neg (arcsin_le_pi_div_two _), neg_le.2 (neg_pi_div_two_le_arcsin _)⟩
#align real.arcsin_neg Real.arcsin_neg
theorem arcsin_le_iff_le_sin {x y : ℝ} (hx : x ∈ Icc (-1 : ℝ) 1) (hy : y ∈ Icc (-(π / 2)) (π / 2)) :
arcsin x ≤ y ↔ x ≤ sin y := by
rw [← arcsin_sin' hy, strictMonoOn_arcsin.le_iff_le hx (sin_mem_Icc _), arcsin_sin' hy]
#align real.arcsin_le_iff_le_sin Real.arcsin_le_iff_le_sin
theorem arcsin_le_iff_le_sin' {x y : ℝ} (hy : y ∈ Ico (-(π / 2)) (π / 2)) :
arcsin x ≤ y ↔ x ≤ sin y := by
rcases le_total x (-1) with hx₁ | hx₁
· simp [arcsin_of_le_neg_one hx₁, hy.1, hx₁.trans (neg_one_le_sin _)]
cases' lt_or_le 1 x with hx₂ hx₂
· simp [arcsin_of_one_le hx₂.le, hy.2.not_le, (sin_le_one y).trans_lt hx₂]
exact arcsin_le_iff_le_sin ⟨hx₁, hx₂⟩ (mem_Icc_of_Ico hy)
#align real.arcsin_le_iff_le_sin' Real.arcsin_le_iff_le_sin'
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Inverse.lean | 162 | 166 | theorem le_arcsin_iff_sin_le {x y : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) (hy : y ∈ Icc (-1 : ℝ) 1) :
x ≤ arcsin y ↔ sin x ≤ y := by |
rw [← neg_le_neg_iff, ← arcsin_neg,
arcsin_le_iff_le_sin ⟨neg_le_neg hy.2, neg_le.2 hy.1⟩ ⟨neg_le_neg hx.2, neg_le.2 hx.1⟩, sin_neg,
neg_le_neg_iff]
|
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Data.Nat.GCD.BigOperators
import Mathlib.Data.Nat.PrimeFin
import Mathlib.NumberTheory.Padics.PadicVal
import Mathlib.Order.Interval.Finset.Nat
#align_import data.nat.factorization.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
-- Workaround for lean4#2038
attribute [-instance] instBEqNat
open Nat Finset List Finsupp
namespace Nat
variable {a b m n p : ℕ}
def factorization (n : ℕ) : ℕ →₀ ℕ where
support := n.primeFactors
toFun p := if p.Prime then padicValNat p n else 0
mem_support_toFun := by simp [not_or]; aesop
#align nat.factorization Nat.factorization
@[simp] lemma support_factorization (n : ℕ) : (factorization n).support = n.primeFactors := rfl
theorem factorization_def (n : ℕ) {p : ℕ} (pp : p.Prime) : n.factorization p = padicValNat p n := by
simpa [factorization] using absurd pp
#align nat.factorization_def Nat.factorization_def
@[simp]
theorem factors_count_eq {n p : ℕ} : n.factors.count p = n.factorization p := by
rcases n.eq_zero_or_pos with (rfl | hn0)
· simp [factorization, count]
if pp : p.Prime then ?_ else
rw [count_eq_zero_of_not_mem (mt prime_of_mem_factors pp)]
simp [factorization, pp]
simp only [factorization_def _ pp]
apply _root_.le_antisymm
· rw [le_padicValNat_iff_replicate_subperm_factors pp hn0.ne']
exact List.le_count_iff_replicate_sublist.mp le_rfl |>.subperm
· rw [← lt_add_one_iff, lt_iff_not_ge, ge_iff_le,
le_padicValNat_iff_replicate_subperm_factors pp hn0.ne']
intro h
have := h.count_le p
simp at this
#align nat.factors_count_eq Nat.factors_count_eq
theorem factorization_eq_factors_multiset (n : ℕ) :
n.factorization = Multiset.toFinsupp (n.factors : Multiset ℕ) := by
ext p
simp
#align nat.factorization_eq_factors_multiset Nat.factorization_eq_factors_multiset
theorem multiplicity_eq_factorization {n p : ℕ} (pp : p.Prime) (hn : n ≠ 0) :
multiplicity p n = n.factorization p := by
simp [factorization, pp, padicValNat_def' pp.ne_one hn.bot_lt]
#align nat.multiplicity_eq_factorization Nat.multiplicity_eq_factorization
@[simp]
theorem factorization_prod_pow_eq_self {n : ℕ} (hn : n ≠ 0) : n.factorization.prod (· ^ ·) = n := by
rw [factorization_eq_factors_multiset n]
simp only [← prod_toMultiset, factorization, Multiset.prod_coe, Multiset.toFinsupp_toMultiset]
exact prod_factors hn
#align nat.factorization_prod_pow_eq_self Nat.factorization_prod_pow_eq_self
theorem eq_of_factorization_eq {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0)
(h : ∀ p : ℕ, a.factorization p = b.factorization p) : a = b :=
eq_of_perm_factors ha hb (by simpa only [List.perm_iff_count, factors_count_eq] using h)
#align nat.eq_of_factorization_eq Nat.eq_of_factorization_eq
theorem factorization_inj : Set.InjOn factorization { x : ℕ | x ≠ 0 } := fun a ha b hb h =>
eq_of_factorization_eq ha hb fun p => by simp [h]
#align nat.factorization_inj Nat.factorization_inj
@[simp]
theorem factorization_zero : factorization 0 = 0 := by ext; simp [factorization]
#align nat.factorization_zero Nat.factorization_zero
@[simp]
theorem factorization_one : factorization 1 = 0 := by ext; simp [factorization]
#align nat.factorization_one Nat.factorization_one
#noalign nat.support_factorization
#align nat.factor_iff_mem_factorization Nat.mem_primeFactors_iff_mem_factors
#align nat.prime_of_mem_factorization Nat.prime_of_mem_primeFactors
#align nat.pos_of_mem_factorization Nat.pos_of_mem_primeFactors
#align nat.le_of_mem_factorization Nat.le_of_mem_primeFactors
theorem factorization_eq_zero_iff (n p : ℕ) :
n.factorization p = 0 ↔ ¬p.Prime ∨ ¬p ∣ n ∨ n = 0 := by
simp_rw [← not_mem_support_iff, support_factorization, mem_primeFactors, not_and_or, not_ne_iff]
#align nat.factorization_eq_zero_iff Nat.factorization_eq_zero_iff
@[simp]
theorem factorization_eq_zero_of_non_prime (n : ℕ) {p : ℕ} (hp : ¬p.Prime) :
n.factorization p = 0 := by simp [factorization_eq_zero_iff, hp]
#align nat.factorization_eq_zero_of_non_prime Nat.factorization_eq_zero_of_non_prime
theorem factorization_eq_zero_of_not_dvd {n p : ℕ} (h : ¬p ∣ n) : n.factorization p = 0 := by
simp [factorization_eq_zero_iff, h]
#align nat.factorization_eq_zero_of_not_dvd Nat.factorization_eq_zero_of_not_dvd
theorem factorization_eq_zero_of_lt {n p : ℕ} (h : n < p) : n.factorization p = 0 :=
Finsupp.not_mem_support_iff.mp (mt le_of_mem_primeFactors (not_le_of_lt h))
#align nat.factorization_eq_zero_of_lt Nat.factorization_eq_zero_of_lt
@[simp]
theorem factorization_zero_right (n : ℕ) : n.factorization 0 = 0 :=
factorization_eq_zero_of_non_prime _ not_prime_zero
#align nat.factorization_zero_right Nat.factorization_zero_right
@[simp]
theorem factorization_one_right (n : ℕ) : n.factorization 1 = 0 :=
factorization_eq_zero_of_non_prime _ not_prime_one
#align nat.factorization_one_right Nat.factorization_one_right
theorem dvd_of_factorization_pos {n p : ℕ} (hn : n.factorization p ≠ 0) : p ∣ n :=
dvd_of_mem_factors <| mem_primeFactors_iff_mem_factors.1 <| mem_support_iff.2 hn
#align nat.dvd_of_factorization_pos Nat.dvd_of_factorization_pos
theorem Prime.factorization_pos_of_dvd {n p : ℕ} (hp : p.Prime) (hn : n ≠ 0) (h : p ∣ n) :
0 < n.factorization p := by
rwa [← factors_count_eq, count_pos_iff_mem, mem_factors_iff_dvd hn hp]
#align nat.prime.factorization_pos_of_dvd Nat.Prime.factorization_pos_of_dvd
theorem factorization_eq_zero_of_remainder {p r : ℕ} (i : ℕ) (hr : ¬p ∣ r) :
(p * i + r).factorization p = 0 := by
apply factorization_eq_zero_of_not_dvd
rwa [← Nat.dvd_add_iff_right (Dvd.intro i rfl)]
#align nat.factorization_eq_zero_of_remainder Nat.factorization_eq_zero_of_remainder
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
¬p ∣ r ↔ (p * i + r).factorization p = 0 := by
refine ⟨factorization_eq_zero_of_remainder i, fun h => ?_⟩
rw [factorization_eq_zero_iff] at h
contrapose! h
refine ⟨pp, ?_, ?_⟩
· rwa [← Nat.dvd_add_iff_right (dvd_mul_right p i)]
· contrapose! hr0
exact (add_eq_zero_iff.mp hr0).2
#align nat.factorization_eq_zero_iff_remainder Nat.factorization_eq_zero_iff_remainder
theorem factorization_eq_zero_iff' (n : ℕ) : n.factorization = 0 ↔ n = 0 ∨ n = 1 := by
rw [factorization_eq_factors_multiset n]
simp [factorization, AddEquiv.map_eq_zero_iff, Multiset.coe_eq_zero]
#align nat.factorization_eq_zero_iff' Nat.factorization_eq_zero_iff'
@[simp]
theorem factorization_mul {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) :
(a * b).factorization = a.factorization + b.factorization := by
ext p
simp only [add_apply, ← factors_count_eq, perm_iff_count.mp (perm_factors_mul ha hb) p,
count_append]
#align nat.factorization_mul Nat.factorization_mul
#align nat.factorization_mul_support Nat.primeFactors_mul
lemma prod_factorization_eq_prod_primeFactors {β : Type*} [CommMonoid β] (f : ℕ → ℕ → β) :
n.factorization.prod f = ∏ p ∈ n.primeFactors, f p (n.factorization p) := rfl
#align nat.prod_factorization_eq_prod_factors Nat.prod_factorization_eq_prod_primeFactors
lemma prod_primeFactors_prod_factorization {β : Type*} [CommMonoid β] (f : ℕ → β) :
∏ p ∈ n.primeFactors, f p = n.factorization.prod (fun p _ ↦ f p) := rfl
theorem factorization_prod {α : Type*} {S : Finset α} {g : α → ℕ} (hS : ∀ x ∈ S, g x ≠ 0) :
(S.prod g).factorization = S.sum fun x => (g x).factorization := by
classical
ext p
refine Finset.induction_on' S ?_ ?_
· simp
· intro x T hxS hTS hxT IH
have hT : T.prod g ≠ 0 := prod_ne_zero_iff.mpr fun x hx => hS x (hTS hx)
simp [prod_insert hxT, sum_insert hxT, ← IH, factorization_mul (hS x hxS) hT]
#align nat.factorization_prod Nat.factorization_prod
@[simp]
theorem factorization_pow (n k : ℕ) : factorization (n ^ k) = k • n.factorization := by
induction' k with k ih; · simp
rcases eq_or_ne n 0 with (rfl | hn)
· simp
rw [Nat.pow_succ, mul_comm, factorization_mul hn (pow_ne_zero _ hn), ih,
add_smul, one_smul, add_comm]
#align nat.factorization_pow Nat.factorization_pow
@[simp]
protected theorem Prime.factorization {p : ℕ} (hp : Prime p) : p.factorization = single p 1 := by
ext q
rw [← factors_count_eq, factors_prime hp, single_apply, count_singleton', if_congr eq_comm] <;>
rfl
#align nat.prime.factorization Nat.Prime.factorization
@[simp]
theorem Prime.factorization_self {p : ℕ} (hp : Prime p) : p.factorization p = 1 := by simp [hp]
#align nat.prime.factorization_self Nat.Prime.factorization_self
theorem Prime.factorization_pow {p k : ℕ} (hp : Prime p) : (p ^ k).factorization = single p k := by
simp [hp]
#align nat.prime.factorization_pow Nat.Prime.factorization_pow
theorem eq_pow_of_factorization_eq_single {n p k : ℕ} (hn : n ≠ 0)
(h : n.factorization = Finsupp.single p k) : n = p ^ k := by
-- Porting note: explicitly added `Finsupp.prod_single_index`
rw [← Nat.factorization_prod_pow_eq_self hn, h, Finsupp.prod_single_index]
simp
#align nat.eq_pow_of_factorization_eq_single Nat.eq_pow_of_factorization_eq_single
theorem Prime.eq_of_factorization_pos {p q : ℕ} (hp : Prime p) (h : p.factorization q ≠ 0) :
p = q := by simpa [hp.factorization, single_apply] using h
#align nat.prime.eq_of_factorization_pos Nat.Prime.eq_of_factorization_pos
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
(f.prod (· ^ ·)).factorization = f := by
have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp =>
pow_ne_zero _ (Prime.ne_zero (hf p hp))
simp only [Finsupp.prod, factorization_prod h]
conv =>
rhs
rw [(sum_single f).symm]
exact sum_congr rfl fun p hp => Prime.factorization_pow (hf p hp)
#align nat.prod_pow_factorization_eq_self Nat.prod_pow_factorization_eq_self
theorem eq_factorization_iff {n : ℕ} {f : ℕ →₀ ℕ} (hn : n ≠ 0) (hf : ∀ p ∈ f.support, Prime p) :
f = n.factorization ↔ f.prod (· ^ ·) = n :=
⟨fun h => by rw [h, factorization_prod_pow_eq_self hn], fun h => by
rw [← h, prod_pow_factorization_eq_self hf]⟩
#align nat.eq_factorization_iff Nat.eq_factorization_iff
def factorizationEquiv : ℕ+ ≃ { f : ℕ →₀ ℕ | ∀ p ∈ f.support, Prime p } where
toFun := fun ⟨n, _⟩ => ⟨n.factorization, fun _ => prime_of_mem_primeFactors⟩
invFun := fun ⟨f, hf⟩ =>
⟨f.prod _, prod_pow_pos_of_zero_not_mem_support fun H => not_prime_zero (hf 0 H)⟩
left_inv := fun ⟨_, hx⟩ => Subtype.ext <| factorization_prod_pow_eq_self hx.ne.symm
right_inv := fun ⟨_, hf⟩ => Subtype.ext <| prod_pow_factorization_eq_self hf
#align nat.factorization_equiv Nat.factorizationEquiv
theorem factorizationEquiv_apply (n : ℕ+) : (factorizationEquiv n).1 = n.1.factorization := by
cases n
rfl
#align nat.factorization_equiv_apply Nat.factorizationEquiv_apply
theorem factorizationEquiv_inv_apply {f : ℕ →₀ ℕ} (hf : ∀ p ∈ f.support, Prime p) :
(factorizationEquiv.symm ⟨f, hf⟩).1 = f.prod (· ^ ·) :=
rfl
#align nat.factorization_equiv_inv_apply Nat.factorizationEquiv_inv_apply
-- Porting note: Lean 4 thinks we need `HPow` without this
set_option quotPrecheck false in
notation "ord_proj[" p "] " n:arg => p ^ Nat.factorization n p
notation "ord_compl[" p "] " n:arg => n / ord_proj[p] n
@[simp]
theorem ord_proj_of_not_prime (n p : ℕ) (hp : ¬p.Prime) : ord_proj[p] n = 1 := by
simp [factorization_eq_zero_of_non_prime n hp]
#align nat.ord_proj_of_not_prime Nat.ord_proj_of_not_prime
@[simp]
theorem ord_compl_of_not_prime (n p : ℕ) (hp : ¬p.Prime) : ord_compl[p] n = n := by
simp [factorization_eq_zero_of_non_prime n hp]
#align nat.ord_compl_of_not_prime Nat.ord_compl_of_not_prime
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
if hp : p.Prime then ?_ else simp [hp]
rw [← factors_count_eq]
apply dvd_of_factors_subperm (pow_ne_zero _ hp.ne_zero)
rw [hp.factors_pow, List.subperm_ext_iff]
intro q hq
simp [List.eq_of_mem_replicate hq]
#align nat.ord_proj_dvd Nat.ord_proj_dvd
theorem ord_compl_dvd (n p : ℕ) : ord_compl[p] n ∣ n :=
div_dvd_of_dvd (ord_proj_dvd n p)
#align nat.ord_compl_dvd Nat.ord_compl_dvd
theorem ord_proj_pos (n p : ℕ) : 0 < ord_proj[p] n := by
if pp : p.Prime then simp [pow_pos pp.pos] else simp [pp]
#align nat.ord_proj_pos Nat.ord_proj_pos
theorem ord_proj_le {n : ℕ} (p : ℕ) (hn : n ≠ 0) : ord_proj[p] n ≤ n :=
le_of_dvd hn.bot_lt (Nat.ord_proj_dvd n p)
#align nat.ord_proj_le Nat.ord_proj_le
theorem ord_compl_pos {n : ℕ} (p : ℕ) (hn : n ≠ 0) : 0 < ord_compl[p] n := by
if pp : p.Prime then
exact Nat.div_pos (ord_proj_le p hn) (ord_proj_pos n p)
else
simpa [Nat.factorization_eq_zero_of_non_prime n pp] using hn.bot_lt
#align nat.ord_compl_pos Nat.ord_compl_pos
theorem ord_compl_le (n p : ℕ) : ord_compl[p] n ≤ n :=
Nat.div_le_self _ _
#align nat.ord_compl_le Nat.ord_compl_le
theorem ord_proj_mul_ord_compl_eq_self (n p : ℕ) : ord_proj[p] n * ord_compl[p] n = n :=
Nat.mul_div_cancel' (ord_proj_dvd n p)
#align nat.ord_proj_mul_ord_compl_eq_self Nat.ord_proj_mul_ord_compl_eq_self
theorem ord_proj_mul {a b : ℕ} (p : ℕ) (ha : a ≠ 0) (hb : b ≠ 0) :
ord_proj[p] (a * b) = ord_proj[p] a * ord_proj[p] b := by
simp [factorization_mul ha hb, pow_add]
#align nat.ord_proj_mul Nat.ord_proj_mul
theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b := by
if ha : a = 0 then simp [ha] else
if hb : b = 0 then simp [hb] else
simp only [ord_proj_mul p ha hb]
rw [div_mul_div_comm (ord_proj_dvd a p) (ord_proj_dvd b p)]
#align nat.ord_compl_mul Nat.ord_compl_mul
#align nat.dvd_of_mem_factorization Nat.dvd_of_mem_primeFactors
theorem factorization_lt {n : ℕ} (p : ℕ) (hn : n ≠ 0) : n.factorization p < n := by
by_cases pp : p.Prime
· exact (pow_lt_pow_iff_right pp.one_lt).1 <| (ord_proj_le p hn).trans_lt <|
lt_pow_self pp.one_lt _
· simpa only [factorization_eq_zero_of_non_prime n pp] using hn.bot_lt
#align nat.factorization_lt Nat.factorization_lt
theorem factorization_le_of_le_pow {n p b : ℕ} (hb : n ≤ p ^ b) : n.factorization p ≤ b := by
if hn : n = 0 then simp [hn] else
if pp : p.Prime then
exact (pow_le_pow_iff_right pp.one_lt).1 ((ord_proj_le p hn).trans hb)
else
simp [factorization_eq_zero_of_non_prime n pp]
#align nat.factorization_le_of_le_pow Nat.factorization_le_of_le_pow
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
d.factorization ≤ n.factorization ↔ d ∣ n := by
constructor
· intro hdn
set K := n.factorization - d.factorization with hK
use K.prod (· ^ ·)
rw [← factorization_prod_pow_eq_self hn, ← factorization_prod_pow_eq_self hd,
← Finsupp.prod_add_index' pow_zero pow_add, hK, add_tsub_cancel_of_le hdn]
· rintro ⟨c, rfl⟩
rw [factorization_mul hd (right_ne_zero_of_mul hn)]
simp
#align nat.factorization_le_iff_dvd Nat.factorization_le_iff_dvd
theorem factorization_prime_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
(∀ p : ℕ, p.Prime → d.factorization p ≤ n.factorization p) ↔ d ∣ n := by
rw [← factorization_le_iff_dvd hd hn]
refine ⟨fun h p => (em p.Prime).elim (h p) fun hp => ?_, fun h p _ => h p⟩
simp_rw [factorization_eq_zero_of_non_prime _ hp]
rfl
#align nat.factorization_prime_le_iff_dvd Nat.factorization_prime_le_iff_dvd
theorem pow_succ_factorization_not_dvd {n p : ℕ} (hn : n ≠ 0) (hp : p.Prime) :
¬p ^ (n.factorization p + 1) ∣ n := by
intro h
rw [← factorization_le_iff_dvd (pow_pos hp.pos _).ne' hn] at h
simpa [hp.factorization] using h p
#align nat.pow_succ_factorization_not_dvd Nat.pow_succ_factorization_not_dvd
theorem factorization_le_factorization_mul_left {a b : ℕ} (hb : b ≠ 0) :
a.factorization ≤ (a * b).factorization := by
rcases eq_or_ne a 0 with (rfl | ha)
· simp
rw [factorization_le_iff_dvd ha <| mul_ne_zero ha hb]
exact Dvd.intro b rfl
#align nat.factorization_le_factorization_mul_left Nat.factorization_le_factorization_mul_left
| Mathlib/Data/Nat/Factorization/Basic.lean | 445 | 448 | theorem factorization_le_factorization_mul_right {a b : ℕ} (ha : a ≠ 0) :
b.factorization ≤ (a * b).factorization := by |
rw [mul_comm]
apply factorization_le_factorization_mul_left ha
|
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.MonoidAlgebra.Basic
import Mathlib.Data.Finset.Sort
#align_import data.polynomial.basic from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69"
set_option linter.uppercaseLean3 false
noncomputable section
structure Polynomial (R : Type*) [Semiring R] where ofFinsupp ::
toFinsupp : AddMonoidAlgebra R ℕ
#align polynomial Polynomial
#align polynomial.of_finsupp Polynomial.ofFinsupp
#align polynomial.to_finsupp Polynomial.toFinsupp
@[inherit_doc] scoped[Polynomial] notation:9000 R "[X]" => Polynomial R
open AddMonoidAlgebra
open Finsupp hiding single
open Function hiding Commute
open Polynomial
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⟩
#align polynomial.forall_iff_forall_finsupp Polynomial.forall_iff_forall_finsupp
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⟩⟩
#align polynomial.exists_iff_exists_finsupp Polynomial.exists_iff_exists_finsupp
@[simp]
theorem eta (f : R[X]) : Polynomial.ofFinsupp f.toFinsupp = f := by cases f; rfl
#align polynomial.eta Polynomial.eta
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⟩⟩
#align polynomial.has_zero Polynomial.zero
instance one : One R[X] :=
⟨⟨1⟩⟩
#align polynomial.one Polynomial.one
instance add' : Add R[X] :=
⟨add⟩
#align polynomial.has_add Polynomial.add'
instance neg' {R : Type u} [Ring R] : Neg R[X] :=
⟨neg⟩
#align polynomial.has_neg Polynomial.neg'
instance sub {R : Type u} [Ring R] : Sub R[X] :=
⟨fun a b => a + -b⟩
#align polynomial.has_sub Polynomial.sub
instance mul' : Mul R[X] :=
⟨mul⟩
#align polynomial.has_mul Polynomial.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 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)
#align polynomial.smul_zero_class Polynomial.smulZeroClass
-- to avoid a bug in the `ring` tactic
instance (priority := 1) pow : Pow R[X] ℕ where pow p n := npowRec n p
#align polynomial.has_pow Polynomial.pow
@[simp]
theorem ofFinsupp_zero : (⟨0⟩ : R[X]) = 0 :=
rfl
#align polynomial.of_finsupp_zero Polynomial.ofFinsupp_zero
@[simp]
theorem ofFinsupp_one : (⟨1⟩ : R[X]) = 1 :=
rfl
#align polynomial.of_finsupp_one Polynomial.ofFinsupp_one
@[simp]
theorem ofFinsupp_add {a b} : (⟨a + b⟩ : R[X]) = ⟨a⟩ + ⟨b⟩ :=
show _ = add _ _ by rw [add_def]
#align polynomial.of_finsupp_add Polynomial.ofFinsupp_add
@[simp]
theorem ofFinsupp_neg {R : Type u} [Ring R] {a} : (⟨-a⟩ : R[X]) = -⟨a⟩ :=
show _ = neg _ by rw [neg_def]
#align polynomial.of_finsupp_neg Polynomial.ofFinsupp_neg
@[simp]
| Mathlib/Algebra/Polynomial/Basic.lean | 178 | 180 | 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
|
import Mathlib.Order.Filter.Basic
#align_import order.filter.prod from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce"
open Set
open Filter
namespace Filter
variable {α β γ δ : Type*} {ι : Sort*}
section Prod
variable {s : Set α} {t : Set β} {f : Filter α} {g : Filter β}
protected def prod (f : Filter α) (g : Filter β) : Filter (α × β) :=
f.comap Prod.fst ⊓ g.comap Prod.snd
#align filter.prod Filter.prod
instance instSProd : SProd (Filter α) (Filter β) (Filter (α × β)) where
sprod := Filter.prod
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)
#align filter.prod_mem_prod Filter.prod_mem_prod
theorem mem_prod_iff {s : Set (α × β)} {f : Filter α} {g : Filter β} :
s ∈ f ×ˢ g ↔ ∃ t₁ ∈ f, ∃ t₂ ∈ g, t₁ ×ˢ t₂ ⊆ s := by
simp only [SProd.sprod, Filter.prod]
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
#align filter.mem_prod_iff Filter.mem_prod_iff
@[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⟩
#align filter.prod_mem_prod_iff Filter.prod_mem_prod_iff
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
#align filter.mem_prod_principal Filter.mem_prod_principal
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]
#align filter.mem_prod_top Filter.mem_prod_top
| Mathlib/Order/Filter/Prod.lean | 101 | 104 | 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]
|
import Mathlib.Analysis.Calculus.MeanValue
#align_import analysis.calculus.extend_deriv from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F]
[NormedSpace ℝ F]
open Filter Set Metric ContinuousLinearMap
open scoped Topology
attribute [local mono] Set.prod_mono
theorem has_fderiv_at_boundary_of_tendsto_fderiv {f : E → F} {s : Set E} {x : E} {f' : E →L[ℝ] F}
(f_diff : DifferentiableOn ℝ f s) (s_conv : Convex ℝ s) (s_open : IsOpen s)
(f_cont : ∀ y ∈ closure s, ContinuousWithinAt f s y)
(h : Tendsto (fun y => fderiv ℝ f y) (𝓝[s] x) (𝓝 f')) :
HasFDerivWithinAt f f' (closure s) x := by
classical
-- one can assume without loss of generality that `x` belongs to the closure of `s`, as the
-- statement is empty otherwise
by_cases hx : x ∉ closure s
· rw [← closure_closure] at hx; exact hasFDerivWithinAt_of_nmem_closure hx
push_neg at hx
rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleO, Asymptotics.isLittleO_iff]
intro ε ε_pos
obtain ⟨δ, δ_pos, hδ⟩ : ∃ δ > 0, ∀ y ∈ s, dist y x < δ → ‖fderiv ℝ f y - f'‖ < ε := by
simpa [dist_zero_right] using tendsto_nhdsWithin_nhds.1 h ε ε_pos
set B := ball x δ
suffices ∀ y ∈ B ∩ closure s, ‖f y - f x - (f' y - f' x)‖ ≤ ε * ‖y - x‖ from
mem_nhdsWithin_iff.2 ⟨δ, δ_pos, fun y hy => by simpa using this y hy⟩
suffices
∀ p : E × E,
p ∈ closure ((B ∩ s) ×ˢ (B ∩ s)) → ‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ by
rw [closure_prod_eq] at this
intro y y_in
apply this ⟨x, y⟩
have : B ∩ closure s ⊆ closure (B ∩ s) := isOpen_ball.inter_closure
exact ⟨this ⟨mem_ball_self δ_pos, hx⟩, this y_in⟩
have key : ∀ p : E × E, p ∈ (B ∩ s) ×ˢ (B ∩ s) →
‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ := by
rintro ⟨u, v⟩ ⟨u_in, v_in⟩
have conv : Convex ℝ (B ∩ s) := (convex_ball _ _).inter s_conv
have diff : DifferentiableOn ℝ f (B ∩ s) := f_diff.mono inter_subset_right
have bound : ∀ z ∈ B ∩ s, ‖fderivWithin ℝ f (B ∩ s) z - f'‖ ≤ ε := by
intro z z_in
have h := hδ z
have : fderivWithin ℝ f (B ∩ s) z = fderiv ℝ f z := by
have op : IsOpen (B ∩ s) := isOpen_ball.inter s_open
rw [DifferentiableAt.fderivWithin _ (op.uniqueDiffOn z z_in)]
exact (diff z z_in).differentiableAt (IsOpen.mem_nhds op z_in)
rw [← this] at h
exact le_of_lt (h z_in.2 z_in.1)
simpa using conv.norm_image_sub_le_of_norm_fderivWithin_le' diff bound u_in v_in
rintro ⟨u, v⟩ uv_in
have f_cont' : ∀ y ∈ closure s, ContinuousWithinAt (f - ⇑f') s y := by
intro y y_in
exact Tendsto.sub (f_cont y y_in) f'.cont.continuousWithinAt
refine ContinuousWithinAt.closure_le uv_in ?_ ?_ key
all_goals
-- common start for both continuity proofs
have : (B ∩ s) ×ˢ (B ∩ s) ⊆ s ×ˢ s := by mono <;> exact inter_subset_right
obtain ⟨u_in, v_in⟩ : u ∈ closure s ∧ v ∈ closure s := by
simpa [closure_prod_eq] using closure_mono this uv_in
apply ContinuousWithinAt.mono _ this
simp only [ContinuousWithinAt]
· rw [nhdsWithin_prod_eq]
have : ∀ u v, f v - f u - (f' v - f' u) = f v - f' v - (f u - f' u) := by intros; abel
simp only [this]
exact
Tendsto.comp continuous_norm.continuousAt
((Tendsto.comp (f_cont' v v_in) tendsto_snd).sub <|
Tendsto.comp (f_cont' u u_in) tendsto_fst)
· apply tendsto_nhdsWithin_of_tendsto_nhds
rw [nhds_prod_eq]
exact
tendsto_const_nhds.mul
(Tendsto.comp continuous_norm.continuousAt <| tendsto_snd.sub tendsto_fst)
#align has_fderiv_at_boundary_of_tendsto_fderiv has_fderiv_at_boundary_of_tendsto_fderiv
theorem has_deriv_at_interval_left_endpoint_of_tendsto_deriv {s : Set ℝ} {e : E} {a : ℝ} {f : ℝ → E}
(f_diff : DifferentiableOn ℝ f s) (f_lim : ContinuousWithinAt f s a) (hs : s ∈ 𝓝[>] a)
(f_lim' : Tendsto (fun x => deriv f x) (𝓝[>] a) (𝓝 e)) : HasDerivWithinAt f e (Ici a) a := by
obtain ⟨b, ab : a < b, sab : Ioc a b ⊆ s⟩ := mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 hs
let t := Ioo a b
have ts : t ⊆ s := Subset.trans Ioo_subset_Ioc_self sab
have t_diff : DifferentiableOn ℝ f t := f_diff.mono ts
have t_conv : Convex ℝ t := convex_Ioo a b
have t_open : IsOpen t := isOpen_Ioo
have t_closure : closure t = Icc a b := closure_Ioo ab.ne
have t_cont : ∀ y ∈ closure t, ContinuousWithinAt f t y := by
rw [t_closure]
intro y hy
by_cases h : y = a
· rw [h]; exact f_lim.mono ts
· have : y ∈ s := sab ⟨lt_of_le_of_ne hy.1 (Ne.symm h), hy.2⟩
exact (f_diff.continuousOn y this).mono ts
have t_diff' : Tendsto (fun x => fderiv ℝ f x) (𝓝[t] a) (𝓝 (smulRight (1 : ℝ →L[ℝ] ℝ) e)) := by
simp only [deriv_fderiv.symm]
exact Tendsto.comp
(isBoundedBilinearMap_smulRight : IsBoundedBilinearMap ℝ _).continuous_right.continuousAt
(tendsto_nhdsWithin_mono_left Ioo_subset_Ioi_self f_lim')
-- now we can apply `has_fderiv_at_boundary_of_differentiable`
have : HasDerivWithinAt f e (Icc a b) a := by
rw [hasDerivWithinAt_iff_hasFDerivWithinAt, ← t_closure]
exact has_fderiv_at_boundary_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff'
exact this.mono_of_mem (Icc_mem_nhdsWithin_Ici <| left_mem_Ico.2 ab)
#align has_deriv_at_interval_left_endpoint_of_tendsto_deriv has_deriv_at_interval_left_endpoint_of_tendsto_deriv
theorem has_deriv_at_interval_right_endpoint_of_tendsto_deriv {s : Set ℝ} {e : E} {a : ℝ}
{f : ℝ → E} (f_diff : DifferentiableOn ℝ f s) (f_lim : ContinuousWithinAt f s a)
(hs : s ∈ 𝓝[<] a) (f_lim' : Tendsto (fun x => deriv f x) (𝓝[<] a) (𝓝 e)) :
HasDerivWithinAt f e (Iic a) a := by
obtain ⟨b, ba, sab⟩ : ∃ b ∈ Iio a, Ico b a ⊆ s := mem_nhdsWithin_Iio_iff_exists_Ico_subset.1 hs
let t := Ioo b a
have ts : t ⊆ s := Subset.trans Ioo_subset_Ico_self sab
have t_diff : DifferentiableOn ℝ f t := f_diff.mono ts
have t_conv : Convex ℝ t := convex_Ioo b a
have t_open : IsOpen t := isOpen_Ioo
have t_closure : closure t = Icc b a := closure_Ioo (ne_of_lt ba)
have t_cont : ∀ y ∈ closure t, ContinuousWithinAt f t y := by
rw [t_closure]
intro y hy
by_cases h : y = a
· rw [h]; exact f_lim.mono ts
· have : y ∈ s := sab ⟨hy.1, lt_of_le_of_ne hy.2 h⟩
exact (f_diff.continuousOn y this).mono ts
have t_diff' : Tendsto (fun x => fderiv ℝ f x) (𝓝[t] a) (𝓝 (smulRight (1 : ℝ →L[ℝ] ℝ) e)) := by
simp only [deriv_fderiv.symm]
exact Tendsto.comp
(isBoundedBilinearMap_smulRight : IsBoundedBilinearMap ℝ _).continuous_right.continuousAt
(tendsto_nhdsWithin_mono_left Ioo_subset_Iio_self f_lim')
-- now we can apply `has_fderiv_at_boundary_of_differentiable`
have : HasDerivWithinAt f e (Icc b a) a := by
rw [hasDerivWithinAt_iff_hasFDerivWithinAt, ← t_closure]
exact has_fderiv_at_boundary_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff'
exact this.mono_of_mem (Icc_mem_nhdsWithin_Iic <| right_mem_Ioc.2 ba)
#align has_deriv_at_interval_right_endpoint_of_tendsto_deriv has_deriv_at_interval_right_endpoint_of_tendsto_deriv
| Mathlib/Analysis/Calculus/FDeriv/Extend.lean | 180 | 209 | theorem hasDerivAt_of_hasDerivAt_of_ne {f g : ℝ → E} {x : ℝ}
(f_diff : ∀ y ≠ x, HasDerivAt f (g y) y) (hf : ContinuousAt f x)
(hg : ContinuousAt g x) : HasDerivAt f (g x) x := by |
have A : HasDerivWithinAt f (g x) (Ici x) x := by
have diff : DifferentiableOn ℝ f (Ioi x) := fun y hy =>
(f_diff y (ne_of_gt hy)).differentiableAt.differentiableWithinAt
-- next line is the nontrivial bit of this proof, appealing to differentiability
-- extension results.
apply
has_deriv_at_interval_left_endpoint_of_tendsto_deriv diff hf.continuousWithinAt
self_mem_nhdsWithin
have : Tendsto g (𝓝[>] x) (𝓝 (g x)) := tendsto_inf_left hg
apply this.congr' _
apply mem_of_superset self_mem_nhdsWithin fun y hy => _
intros y hy
exact (f_diff y (ne_of_gt hy)).deriv.symm
have B : HasDerivWithinAt f (g x) (Iic x) x := by
have diff : DifferentiableOn ℝ f (Iio x) := fun y hy =>
(f_diff y (ne_of_lt hy)).differentiableAt.differentiableWithinAt
-- next line is the nontrivial bit of this proof, appealing to differentiability
-- extension results.
apply
has_deriv_at_interval_right_endpoint_of_tendsto_deriv diff hf.continuousWithinAt
self_mem_nhdsWithin
have : Tendsto g (𝓝[<] x) (𝓝 (g x)) := tendsto_inf_left hg
apply this.congr' _
apply mem_of_superset self_mem_nhdsWithin fun y hy => _
intros y hy
exact (f_diff y (ne_of_lt hy)).deriv.symm
simpa using B.union A
|
import Mathlib.Algebra.Group.Equiv.Basic
import Mathlib.Data.ENat.Lattice
import Mathlib.Data.Part
import Mathlib.Tactic.NormNum
#align_import data.nat.part_enat from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8"
open Part hiding some
def PartENat : Type :=
Part ℕ
#align part_enat PartENat
namespace PartENat
@[coe]
def some : ℕ → PartENat :=
Part.some
#align part_enat.some PartENat.some
instance : Zero PartENat :=
⟨some 0⟩
instance : Inhabited PartENat :=
⟨0⟩
instance : One PartENat :=
⟨some 1⟩
instance : Add PartENat :=
⟨fun x y => ⟨x.Dom ∧ y.Dom, fun h => get x h.1 + get y h.2⟩⟩
instance (n : ℕ) : Decidable (some n).Dom :=
isTrue trivial
@[simp]
theorem dom_some (x : ℕ) : (some x).Dom :=
trivial
#align part_enat.dom_some PartENat.dom_some
instance addCommMonoid : AddCommMonoid PartENat where
add := (· + ·)
zero := 0
add_comm x y := Part.ext' and_comm fun _ _ => add_comm _ _
zero_add x := Part.ext' (true_and_iff _) fun _ _ => zero_add _
add_zero x := Part.ext' (and_true_iff _) fun _ _ => add_zero _
add_assoc x y z := Part.ext' and_assoc fun _ _ => add_assoc _ _ _
nsmul := nsmulRec
instance : AddCommMonoidWithOne PartENat :=
{ PartENat.addCommMonoid with
one := 1
natCast := some
natCast_zero := rfl
natCast_succ := fun _ => Part.ext' (true_and_iff _).symm fun _ _ => rfl }
theorem some_eq_natCast (n : ℕ) : some n = n :=
rfl
#align part_enat.some_eq_coe PartENat.some_eq_natCast
instance : CharZero PartENat where
cast_injective := Part.some_injective
theorem natCast_inj {x y : ℕ} : (x : PartENat) = y ↔ x = y :=
Nat.cast_inj
#align part_enat.coe_inj PartENat.natCast_inj
@[simp]
theorem dom_natCast (x : ℕ) : (x : PartENat).Dom :=
trivial
#align part_enat.dom_coe PartENat.dom_natCast
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem dom_ofNat (x : ℕ) [x.AtLeastTwo] : (no_index (OfNat.ofNat x : PartENat)).Dom :=
trivial
@[simp]
theorem dom_zero : (0 : PartENat).Dom :=
trivial
@[simp]
theorem dom_one : (1 : PartENat).Dom :=
trivial
instance : CanLift PartENat ℕ (↑) Dom :=
⟨fun n hn => ⟨n.get hn, Part.some_get _⟩⟩
instance : LE PartENat :=
⟨fun x y => ∃ h : y.Dom → x.Dom, ∀ hy : y.Dom, x.get (h hy) ≤ y.get hy⟩
instance : Top PartENat :=
⟨none⟩
instance : Bot PartENat :=
⟨0⟩
instance : Sup PartENat :=
⟨fun x y => ⟨x.Dom ∧ y.Dom, fun h => x.get h.1 ⊔ y.get h.2⟩⟩
theorem le_def (x y : PartENat) :
x ≤ y ↔ ∃ h : y.Dom → x.Dom, ∀ hy : y.Dom, x.get (h hy) ≤ y.get hy :=
Iff.rfl
#align part_enat.le_def PartENat.le_def
@[elab_as_elim]
protected theorem casesOn' {P : PartENat → Prop} :
∀ a : PartENat, P ⊤ → (∀ n : ℕ, P (some n)) → P a :=
Part.induction_on
#align part_enat.cases_on' PartENat.casesOn'
@[elab_as_elim]
protected theorem casesOn {P : PartENat → Prop} : ∀ a : PartENat, P ⊤ → (∀ n : ℕ, P n) → P a := by
exact PartENat.casesOn'
#align part_enat.cases_on PartENat.casesOn
-- not a simp lemma as we will provide a `LinearOrderedAddCommMonoidWithTop` instance later
theorem top_add (x : PartENat) : ⊤ + x = ⊤ :=
Part.ext' (false_and_iff _) fun h => h.left.elim
#align part_enat.top_add PartENat.top_add
-- not a simp lemma as we will provide a `LinearOrderedAddCommMonoidWithTop` instance later
theorem add_top (x : PartENat) : x + ⊤ = ⊤ := by rw [add_comm, top_add]
#align part_enat.add_top PartENat.add_top
@[simp]
theorem natCast_get {x : PartENat} (h : x.Dom) : (x.get h : PartENat) = x := by
exact Part.ext' (iff_of_true trivial h) fun _ _ => rfl
#align part_enat.coe_get PartENat.natCast_get
@[simp, norm_cast]
theorem get_natCast' (x : ℕ) (h : (x : PartENat).Dom) : get (x : PartENat) h = x := by
rw [← natCast_inj, natCast_get]
#align part_enat.get_coe' PartENat.get_natCast'
theorem get_natCast {x : ℕ} : get (x : PartENat) (dom_natCast x) = x :=
get_natCast' _ _
#align part_enat.get_coe PartENat.get_natCast
theorem coe_add_get {x : ℕ} {y : PartENat} (h : ((x : PartENat) + y).Dom) :
get ((x : PartENat) + y) h = x + get y h.2 := by
rfl
#align part_enat.coe_add_get PartENat.coe_add_get
@[simp]
theorem get_add {x y : PartENat} (h : (x + y).Dom) : get (x + y) h = x.get h.1 + y.get h.2 :=
rfl
#align part_enat.get_add PartENat.get_add
@[simp]
theorem get_zero (h : (0 : PartENat).Dom) : (0 : PartENat).get h = 0 :=
rfl
#align part_enat.get_zero PartENat.get_zero
@[simp]
theorem get_one (h : (1 : PartENat).Dom) : (1 : PartENat).get h = 1 :=
rfl
#align part_enat.get_one PartENat.get_one
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem get_ofNat' (x : ℕ) [x.AtLeastTwo] (h : (no_index (OfNat.ofNat x : PartENat)).Dom) :
Part.get (no_index (OfNat.ofNat x : PartENat)) h = (no_index (OfNat.ofNat x)) :=
get_natCast' x h
nonrec theorem get_eq_iff_eq_some {a : PartENat} {ha : a.Dom} {b : ℕ} : a.get ha = b ↔ a = some b :=
get_eq_iff_eq_some
#align part_enat.get_eq_iff_eq_some PartENat.get_eq_iff_eq_some
theorem get_eq_iff_eq_coe {a : PartENat} {ha : a.Dom} {b : ℕ} : a.get ha = b ↔ a = b := by
rw [get_eq_iff_eq_some]
rfl
#align part_enat.get_eq_iff_eq_coe PartENat.get_eq_iff_eq_coe
theorem dom_of_le_of_dom {x y : PartENat} : x ≤ y → y.Dom → x.Dom := fun ⟨h, _⟩ => h
#align part_enat.dom_of_le_of_dom PartENat.dom_of_le_of_dom
theorem dom_of_le_some {x : PartENat} {y : ℕ} (h : x ≤ some y) : x.Dom :=
dom_of_le_of_dom h trivial
#align part_enat.dom_of_le_some PartENat.dom_of_le_some
theorem dom_of_le_natCast {x : PartENat} {y : ℕ} (h : x ≤ y) : x.Dom := by
exact dom_of_le_some h
#align part_enat.dom_of_le_coe PartENat.dom_of_le_natCast
instance decidableLe (x y : PartENat) [Decidable x.Dom] [Decidable y.Dom] : Decidable (x ≤ y) :=
if hx : x.Dom then
decidable_of_decidable_of_iff (by rw [le_def])
else
if hy : y.Dom then isFalse fun h => hx <| dom_of_le_of_dom h hy
else isTrue ⟨fun h => (hy h).elim, fun h => (hy h).elim⟩
#align part_enat.decidable_le PartENat.decidableLe
-- Porting note: Removed. Use `Nat.castAddMonoidHom` instead.
#noalign part_enat.coe_hom
#noalign part_enat.coe_coe_hom
instance partialOrder : PartialOrder PartENat where
le := (· ≤ ·)
le_refl _ := ⟨id, fun _ => le_rfl⟩
le_trans := fun _ _ _ ⟨hxy₁, hxy₂⟩ ⟨hyz₁, hyz₂⟩ =>
⟨hxy₁ ∘ hyz₁, fun _ => le_trans (hxy₂ _) (hyz₂ _)⟩
lt_iff_le_not_le _ _ := Iff.rfl
le_antisymm := fun _ _ ⟨hxy₁, hxy₂⟩ ⟨hyx₁, hyx₂⟩ =>
Part.ext' ⟨hyx₁, hxy₁⟩ fun _ _ => le_antisymm (hxy₂ _) (hyx₂ _)
theorem lt_def (x y : PartENat) : x < y ↔ ∃ hx : x.Dom, ∀ hy : y.Dom, x.get hx < y.get hy := by
rw [lt_iff_le_not_le, le_def, le_def, not_exists]
constructor
· rintro ⟨⟨hyx, H⟩, h⟩
by_cases hx : x.Dom
· use hx
intro hy
specialize H hy
specialize h fun _ => hy
rw [not_forall] at h
cases' h with hx' h
rw [not_le] at h
exact h
· specialize h fun hx' => (hx hx').elim
rw [not_forall] at h
cases' h with hx' h
exact (hx hx').elim
· rintro ⟨hx, H⟩
exact ⟨⟨fun _ => hx, fun hy => (H hy).le⟩, fun hxy h => not_lt_of_le (h _) (H _)⟩
#align part_enat.lt_def PartENat.lt_def
noncomputable instance orderedAddCommMonoid : OrderedAddCommMonoid PartENat :=
{ PartENat.partialOrder, PartENat.addCommMonoid with
add_le_add_left := fun a b ⟨h₁, h₂⟩ c =>
PartENat.casesOn c (by simp [top_add]) fun c =>
⟨fun h => And.intro (dom_natCast _) (h₁ h.2), fun h => by
simpa only [coe_add_get] using add_le_add_left (h₂ _) c⟩ }
instance semilatticeSup : SemilatticeSup PartENat :=
{ PartENat.partialOrder with
sup := (· ⊔ ·)
le_sup_left := fun _ _ => ⟨And.left, fun _ => le_sup_left⟩
le_sup_right := fun _ _ => ⟨And.right, fun _ => le_sup_right⟩
sup_le := fun _ _ _ ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩ =>
⟨fun hz => ⟨hx₁ hz, hy₁ hz⟩, fun _ => sup_le (hx₂ _) (hy₂ _)⟩ }
#align part_enat.semilattice_sup PartENat.semilatticeSup
instance orderBot : OrderBot PartENat where
bot := ⊥
bot_le _ := ⟨fun _ => trivial, fun _ => Nat.zero_le _⟩
#align part_enat.order_bot PartENat.orderBot
instance orderTop : OrderTop PartENat where
top := ⊤
le_top _ := ⟨fun h => False.elim h, fun hy => False.elim hy⟩
#align part_enat.order_top PartENat.orderTop
instance : ZeroLEOneClass PartENat where
zero_le_one := bot_le
theorem coe_le_coe {x y : ℕ} : (x : PartENat) ≤ y ↔ x ≤ y := Nat.cast_le
#align part_enat.coe_le_coe PartENat.coe_le_coe
theorem coe_lt_coe {x y : ℕ} : (x : PartENat) < y ↔ x < y := Nat.cast_lt
#align part_enat.coe_lt_coe PartENat.coe_lt_coe
@[simp]
theorem get_le_get {x y : PartENat} {hx : x.Dom} {hy : y.Dom} : x.get hx ≤ y.get hy ↔ x ≤ y := by
conv =>
lhs
rw [← coe_le_coe, natCast_get, natCast_get]
#align part_enat.get_le_get PartENat.get_le_get
theorem le_coe_iff (x : PartENat) (n : ℕ) : x ≤ n ↔ ∃ h : x.Dom, x.get h ≤ n := by
show (∃ h : True → x.Dom, _) ↔ ∃ h : x.Dom, x.get h ≤ n
simp only [forall_prop_of_true, dom_natCast, get_natCast']
#align part_enat.le_coe_iff PartENat.le_coe_iff
theorem lt_coe_iff (x : PartENat) (n : ℕ) : x < n ↔ ∃ h : x.Dom, x.get h < n := by
simp only [lt_def, forall_prop_of_true, get_natCast', dom_natCast]
#align part_enat.lt_coe_iff PartENat.lt_coe_iff
theorem coe_le_iff (n : ℕ) (x : PartENat) : (n : PartENat) ≤ x ↔ ∀ h : x.Dom, n ≤ x.get h := by
rw [← some_eq_natCast]
simp only [le_def, exists_prop_of_true, dom_some, forall_true_iff]
rfl
#align part_enat.coe_le_iff PartENat.coe_le_iff
theorem coe_lt_iff (n : ℕ) (x : PartENat) : (n : PartENat) < x ↔ ∀ h : x.Dom, n < x.get h := by
rw [← some_eq_natCast]
simp only [lt_def, exists_prop_of_true, dom_some, forall_true_iff]
rfl
#align part_enat.coe_lt_iff PartENat.coe_lt_iff
nonrec theorem eq_zero_iff {x : PartENat} : x = 0 ↔ x ≤ 0 :=
eq_bot_iff
#align part_enat.eq_zero_iff PartENat.eq_zero_iff
theorem ne_zero_iff {x : PartENat} : x ≠ 0 ↔ ⊥ < x :=
bot_lt_iff_ne_bot.symm
#align part_enat.ne_zero_iff PartENat.ne_zero_iff
theorem dom_of_lt {x y : PartENat} : x < y → x.Dom :=
PartENat.casesOn x not_top_lt fun _ _ => dom_natCast _
#align part_enat.dom_of_lt PartENat.dom_of_lt
theorem top_eq_none : (⊤ : PartENat) = Part.none :=
rfl
#align part_enat.top_eq_none PartENat.top_eq_none
@[simp]
theorem natCast_lt_top (x : ℕ) : (x : PartENat) < ⊤ :=
Ne.lt_top fun h => absurd (congr_arg Dom h) <| by simp only [dom_natCast]; exact true_ne_false
#align part_enat.coe_lt_top PartENat.natCast_lt_top
@[simp]
theorem zero_lt_top : (0 : PartENat) < ⊤ :=
natCast_lt_top 0
@[simp]
theorem one_lt_top : (1 : PartENat) < ⊤ :=
natCast_lt_top 1
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ofNat_lt_top (x : ℕ) [x.AtLeastTwo] : (no_index (OfNat.ofNat x : PartENat)) < ⊤ :=
natCast_lt_top x
@[simp]
theorem natCast_ne_top (x : ℕ) : (x : PartENat) ≠ ⊤ :=
ne_of_lt (natCast_lt_top x)
#align part_enat.coe_ne_top PartENat.natCast_ne_top
@[simp]
theorem zero_ne_top : (0 : PartENat) ≠ ⊤ :=
natCast_ne_top 0
@[simp]
theorem one_ne_top : (1 : PartENat) ≠ ⊤ :=
natCast_ne_top 1
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ofNat_ne_top (x : ℕ) [x.AtLeastTwo] : (no_index (OfNat.ofNat x : PartENat)) ≠ ⊤ :=
natCast_ne_top x
theorem not_isMax_natCast (x : ℕ) : ¬IsMax (x : PartENat) :=
not_isMax_of_lt (natCast_lt_top x)
#align part_enat.not_is_max_coe PartENat.not_isMax_natCast
theorem ne_top_iff {x : PartENat} : x ≠ ⊤ ↔ ∃ n : ℕ, x = n := by
simpa only [← some_eq_natCast] using Part.ne_none_iff
#align part_enat.ne_top_iff PartENat.ne_top_iff
theorem ne_top_iff_dom {x : PartENat} : x ≠ ⊤ ↔ x.Dom := by
classical exact not_iff_comm.1 Part.eq_none_iff'.symm
#align part_enat.ne_top_iff_dom PartENat.ne_top_iff_dom
theorem not_dom_iff_eq_top {x : PartENat} : ¬x.Dom ↔ x = ⊤ :=
Iff.not_left ne_top_iff_dom.symm
#align part_enat.not_dom_iff_eq_top PartENat.not_dom_iff_eq_top
theorem ne_top_of_lt {x y : PartENat} (h : x < y) : x ≠ ⊤ :=
ne_of_lt <| lt_of_lt_of_le h le_top
#align part_enat.ne_top_of_lt PartENat.ne_top_of_lt
theorem eq_top_iff_forall_lt (x : PartENat) : x = ⊤ ↔ ∀ n : ℕ, (n : PartENat) < x := by
constructor
· rintro rfl n
exact natCast_lt_top _
· contrapose!
rw [ne_top_iff]
rintro ⟨n, rfl⟩
exact ⟨n, irrefl _⟩
#align part_enat.eq_top_iff_forall_lt PartENat.eq_top_iff_forall_lt
theorem eq_top_iff_forall_le (x : PartENat) : x = ⊤ ↔ ∀ n : ℕ, (n : PartENat) ≤ x :=
(eq_top_iff_forall_lt x).trans
⟨fun h n => (h n).le, fun h n => lt_of_lt_of_le (coe_lt_coe.mpr n.lt_succ_self) (h (n + 1))⟩
#align part_enat.eq_top_iff_forall_le PartENat.eq_top_iff_forall_le
theorem pos_iff_one_le {x : PartENat} : 0 < x ↔ 1 ≤ x :=
PartENat.casesOn x
(by simp only [iff_true_iff, le_top, natCast_lt_top, ← @Nat.cast_zero PartENat])
fun n => by
rw [← Nat.cast_zero, ← Nat.cast_one, PartENat.coe_lt_coe, PartENat.coe_le_coe]
rfl
#align part_enat.pos_iff_one_le PartENat.pos_iff_one_le
instance isTotal : IsTotal PartENat (· ≤ ·) where
total x y :=
PartENat.casesOn (P := fun z => z ≤ y ∨ y ≤ z) x (Or.inr le_top)
(PartENat.casesOn y (fun _ => Or.inl le_top) fun x y =>
(le_total x y).elim (Or.inr ∘ coe_le_coe.2) (Or.inl ∘ coe_le_coe.2))
noncomputable instance linearOrder : LinearOrder PartENat :=
{ PartENat.partialOrder with
le_total := IsTotal.total
decidableLE := Classical.decRel _
max := (· ⊔ ·)
-- Porting note: was `max_def := @sup_eq_maxDefault _ _ (id _) _ }`
max_def := fun a b => by
change (fun a b => a ⊔ b) a b = _
rw [@sup_eq_maxDefault PartENat _ (id _) _]
rfl }
instance boundedOrder : BoundedOrder PartENat :=
{ PartENat.orderTop, PartENat.orderBot with }
noncomputable instance lattice : Lattice PartENat :=
{ PartENat.semilatticeSup with
inf := min
inf_le_left := min_le_left
inf_le_right := min_le_right
le_inf := fun _ _ _ => le_min }
noncomputable instance : CanonicallyOrderedAddCommMonoid PartENat :=
{ PartENat.semilatticeSup, PartENat.orderBot,
PartENat.orderedAddCommMonoid with
le_self_add := fun a b =>
PartENat.casesOn b (le_top.trans_eq (add_top _).symm) fun b =>
PartENat.casesOn a (top_add _).ge fun a =>
(coe_le_coe.2 le_self_add).trans_eq (Nat.cast_add _ _)
exists_add_of_le := fun {a b} =>
PartENat.casesOn b (fun _ => ⟨⊤, (add_top _).symm⟩) fun b =>
PartENat.casesOn a (fun h => ((natCast_lt_top _).not_le h).elim) fun a h =>
⟨(b - a : ℕ), by
rw [← Nat.cast_add, natCast_inj, add_comm, tsub_add_cancel_of_le (coe_le_coe.1 h)]⟩ }
theorem eq_natCast_sub_of_add_eq_natCast {x y : PartENat} {n : ℕ} (h : x + y = n) :
x = ↑(n - y.get (dom_of_le_natCast ((le_add_left le_rfl).trans_eq h))) := by
lift x to ℕ using dom_of_le_natCast ((le_add_right le_rfl).trans_eq h)
lift y to ℕ using dom_of_le_natCast ((le_add_left le_rfl).trans_eq h)
rw [← Nat.cast_add, natCast_inj] at h
rw [get_natCast, natCast_inj, eq_tsub_of_add_eq h]
#align part_enat.eq_coe_sub_of_add_eq_coe PartENat.eq_natCast_sub_of_add_eq_natCast
protected theorem add_lt_add_right {x y z : PartENat} (h : x < y) (hz : z ≠ ⊤) : x + z < y + z := by
rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩
rcases ne_top_iff.mp hz with ⟨k, rfl⟩
induction' y using PartENat.casesOn with n
· rw [top_add]
-- Porting note: was apply_mod_cast natCast_lt_top
norm_cast; apply natCast_lt_top
norm_cast at h
-- Porting note: was `apply_mod_cast add_lt_add_right h`
norm_cast; apply add_lt_add_right h
#align part_enat.add_lt_add_right PartENat.add_lt_add_right
protected theorem add_lt_add_iff_right {x y z : PartENat} (hz : z ≠ ⊤) : x + z < y + z ↔ x < y :=
⟨lt_of_add_lt_add_right, fun h => PartENat.add_lt_add_right h hz⟩
#align part_enat.add_lt_add_iff_right PartENat.add_lt_add_iff_right
protected theorem add_lt_add_iff_left {x y z : PartENat} (hz : z ≠ ⊤) : z + x < z + y ↔ x < y := by
rw [add_comm z, add_comm z, PartENat.add_lt_add_iff_right hz]
#align part_enat.add_lt_add_iff_left PartENat.add_lt_add_iff_left
protected theorem lt_add_iff_pos_right {x y : PartENat} (hx : x ≠ ⊤) : x < x + y ↔ 0 < y := by
conv_rhs => rw [← PartENat.add_lt_add_iff_left hx]
rw [add_zero]
#align part_enat.lt_add_iff_pos_right PartENat.lt_add_iff_pos_right
theorem lt_add_one {x : PartENat} (hx : x ≠ ⊤) : x < x + 1 := by
rw [PartENat.lt_add_iff_pos_right hx]
norm_cast
#align part_enat.lt_add_one PartENat.lt_add_one
theorem le_of_lt_add_one {x y : PartENat} (h : x < y + 1) : x ≤ y := by
induction' y using PartENat.casesOn with n
· apply le_top
rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩
-- Porting note: was `apply_mod_cast Nat.le_of_lt_succ; apply_mod_cast h`
norm_cast; apply Nat.le_of_lt_succ; norm_cast at h
#align part_enat.le_of_lt_add_one PartENat.le_of_lt_add_one
theorem add_one_le_of_lt {x y : PartENat} (h : x < y) : x + 1 ≤ y := by
induction' y using PartENat.casesOn with n
· apply le_top
rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩
-- Porting note: was `apply_mod_cast Nat.succ_le_of_lt; apply_mod_cast h`
norm_cast; apply Nat.succ_le_of_lt; norm_cast at h
#align part_enat.add_one_le_of_lt PartENat.add_one_le_of_lt
theorem add_one_le_iff_lt {x y : PartENat} (hx : x ≠ ⊤) : x + 1 ≤ y ↔ x < y := by
refine ⟨fun h => ?_, add_one_le_of_lt⟩
rcases ne_top_iff.mp hx with ⟨m, rfl⟩
induction' y using PartENat.casesOn with n
· apply natCast_lt_top
-- Porting note: was `apply_mod_cast Nat.lt_of_succ_le; apply_mod_cast h`
norm_cast; apply Nat.lt_of_succ_le; norm_cast at h
#align part_enat.add_one_le_iff_lt PartENat.add_one_le_iff_lt
theorem coe_succ_le_iff {n : ℕ} {e : PartENat} : ↑n.succ ≤ e ↔ ↑n < e := by
rw [Nat.succ_eq_add_one n, Nat.cast_add, Nat.cast_one, add_one_le_iff_lt (natCast_ne_top n)]
#align part_enat.coe_succ_le_succ_iff PartENat.coe_succ_le_iff
theorem lt_add_one_iff_lt {x y : PartENat} (hx : x ≠ ⊤) : x < y + 1 ↔ x ≤ y := by
refine ⟨le_of_lt_add_one, fun h => ?_⟩
rcases ne_top_iff.mp hx with ⟨m, rfl⟩
induction' y using PartENat.casesOn with n
· rw [top_add]
apply natCast_lt_top
-- Porting note: was `apply_mod_cast Nat.lt_succ_of_le; apply_mod_cast h`
norm_cast; apply Nat.lt_succ_of_le; norm_cast at h
#align part_enat.lt_add_one_iff_lt PartENat.lt_add_one_iff_lt
lemma lt_coe_succ_iff_le {x : PartENat} {n : ℕ} (hx : x ≠ ⊤) : x < n.succ ↔ x ≤ n := by
rw [Nat.succ_eq_add_one n, Nat.cast_add, Nat.cast_one, lt_add_one_iff_lt hx]
#align part_enat.lt_coe_succ_iff_le PartENat.lt_coe_succ_iff_le
theorem add_eq_top_iff {a b : PartENat} : a + b = ⊤ ↔ a = ⊤ ∨ b = ⊤ := by
refine PartENat.casesOn a ?_ ?_
<;> refine PartENat.casesOn b ?_ ?_
<;> simp [top_add, add_top]
simp only [← Nat.cast_add, PartENat.natCast_ne_top, forall_const, not_false_eq_true]
#align part_enat.add_eq_top_iff PartENat.add_eq_top_iff
protected theorem add_right_cancel_iff {a b c : PartENat} (hc : c ≠ ⊤) : a + c = b + c ↔ a = b := by
rcases ne_top_iff.1 hc with ⟨c, rfl⟩
refine PartENat.casesOn a ?_ ?_
<;> refine PartENat.casesOn b ?_ ?_
<;> simp [add_eq_top_iff, natCast_ne_top, @eq_comm _ (⊤ : PartENat), top_add]
simp only [← Nat.cast_add, add_left_cancel_iff, PartENat.natCast_inj, add_comm, forall_const]
#align part_enat.add_right_cancel_iff PartENat.add_right_cancel_iff
protected theorem add_left_cancel_iff {a b c : PartENat} (ha : a ≠ ⊤) : a + b = a + c ↔ b = c := by
rw [add_comm a, add_comm a, PartENat.add_right_cancel_iff ha]
#align part_enat.add_left_cancel_iff PartENat.add_left_cancel_iff
section WithTop
def toWithTop (x : PartENat) [Decidable x.Dom] : ℕ∞ :=
x.toOption
#align part_enat.to_with_top PartENat.toWithTop
theorem toWithTop_top :
have : Decidable (⊤ : PartENat).Dom := Part.noneDecidable
toWithTop ⊤ = ⊤ :=
rfl
#align part_enat.to_with_top_top PartENat.toWithTop_top
@[simp]
theorem toWithTop_top' {h : Decidable (⊤ : PartENat).Dom} : toWithTop ⊤ = ⊤ := by
convert toWithTop_top
#align part_enat.to_with_top_top' PartENat.toWithTop_top'
theorem toWithTop_zero :
have : Decidable (0 : PartENat).Dom := someDecidable 0
toWithTop 0 = 0 :=
rfl
#align part_enat.to_with_top_zero PartENat.toWithTop_zero
@[simp]
theorem toWithTop_zero' {h : Decidable (0 : PartENat).Dom} : toWithTop 0 = 0 := by
convert toWithTop_zero
#align part_enat.to_with_top_zero' PartENat.toWithTop_zero'
theorem toWithTop_one :
have : Decidable (1 : PartENat).Dom := someDecidable 1
toWithTop 1 = 1 :=
rfl
@[simp]
theorem toWithTop_one' {h : Decidable (1 : PartENat).Dom} : toWithTop 1 = 1 := by
convert toWithTop_one
theorem toWithTop_some (n : ℕ) : toWithTop (some n) = n :=
rfl
#align part_enat.to_with_top_some PartENat.toWithTop_some
theorem toWithTop_natCast (n : ℕ) {_ : Decidable (n : PartENat).Dom} : toWithTop n = n := by
simp only [← toWithTop_some]
congr
#align part_enat.to_with_top_coe PartENat.toWithTop_natCast
@[simp]
| Mathlib/Data/Nat/PartENat.lean | 628 | 630 | theorem toWithTop_natCast' (n : ℕ) {_ : Decidable (n : PartENat).Dom} :
toWithTop (n : PartENat) = n := by |
rw [toWithTop_natCast n]
|
import Mathlib.Order.BooleanAlgebra
import Mathlib.Logic.Equiv.Basic
#align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904"
open Function OrderDual
variable {ι α β : Type*} {π : ι → Type*}
def symmDiff [Sup α] [SDiff α] (a b : α) : α :=
a \ b ⊔ b \ a
#align symm_diff symmDiff
def bihimp [Inf α] [HImp α] (a b : α) : α :=
(b ⇨ a) ⊓ (a ⇨ b)
#align bihimp bihimp
scoped[symmDiff] infixl:100 " ∆ " => symmDiff
scoped[symmDiff] infixl:100 " ⇔ " => bihimp
open scoped symmDiff
theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a :=
rfl
#align symm_diff_def symmDiff_def
theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) :=
rfl
#align bihimp_def bihimp_def
theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q :=
rfl
#align symm_diff_eq_xor symmDiff_eq_Xor'
@[simp]
theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) :=
(iff_iff_implies_and_implies _ _).symm.trans Iff.comm
#align bihimp_iff_iff bihimp_iff_iff
@[simp]
theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide
#align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor
section GeneralizedCoheytingAlgebra
variable [GeneralizedCoheytingAlgebra α] (a b c d : α)
@[simp]
theorem toDual_symmDiff : toDual (a ∆ b) = toDual a ⇔ toDual b :=
rfl
#align to_dual_symm_diff toDual_symmDiff
@[simp]
theorem ofDual_bihimp (a b : αᵒᵈ) : ofDual (a ⇔ b) = ofDual a ∆ ofDual b :=
rfl
#align of_dual_bihimp ofDual_bihimp
theorem symmDiff_comm : a ∆ b = b ∆ a := by simp only [symmDiff, sup_comm]
#align symm_diff_comm symmDiff_comm
instance symmDiff_isCommutative : Std.Commutative (α := α) (· ∆ ·) :=
⟨symmDiff_comm⟩
#align symm_diff_is_comm symmDiff_isCommutative
@[simp]
theorem symmDiff_self : a ∆ a = ⊥ := by rw [symmDiff, sup_idem, sdiff_self]
#align symm_diff_self symmDiff_self
@[simp]
theorem symmDiff_bot : a ∆ ⊥ = a := by rw [symmDiff, sdiff_bot, bot_sdiff, sup_bot_eq]
#align symm_diff_bot symmDiff_bot
@[simp]
theorem bot_symmDiff : ⊥ ∆ a = a := by rw [symmDiff_comm, symmDiff_bot]
#align bot_symm_diff bot_symmDiff
@[simp]
theorem symmDiff_eq_bot {a b : α} : a ∆ b = ⊥ ↔ a = b := by
simp_rw [symmDiff, sup_eq_bot_iff, sdiff_eq_bot_iff, le_antisymm_iff]
#align symm_diff_eq_bot symmDiff_eq_bot
theorem symmDiff_of_le {a b : α} (h : a ≤ b) : a ∆ b = b \ a := by
rw [symmDiff, sdiff_eq_bot_iff.2 h, bot_sup_eq]
#align symm_diff_of_le symmDiff_of_le
theorem symmDiff_of_ge {a b : α} (h : b ≤ a) : a ∆ b = a \ b := by
rw [symmDiff, sdiff_eq_bot_iff.2 h, sup_bot_eq]
#align symm_diff_of_ge symmDiff_of_ge
theorem symmDiff_le {a b c : α} (ha : a ≤ b ⊔ c) (hb : b ≤ a ⊔ c) : a ∆ b ≤ c :=
sup_le (sdiff_le_iff.2 ha) <| sdiff_le_iff.2 hb
#align symm_diff_le symmDiff_le
theorem symmDiff_le_iff {a b c : α} : a ∆ b ≤ c ↔ a ≤ b ⊔ c ∧ b ≤ a ⊔ c := by
simp_rw [symmDiff, sup_le_iff, sdiff_le_iff]
#align symm_diff_le_iff symmDiff_le_iff
@[simp]
theorem symmDiff_le_sup {a b : α} : a ∆ b ≤ a ⊔ b :=
sup_le_sup sdiff_le sdiff_le
#align symm_diff_le_sup symmDiff_le_sup
theorem symmDiff_eq_sup_sdiff_inf : a ∆ b = (a ⊔ b) \ (a ⊓ b) := by simp [sup_sdiff, symmDiff]
#align symm_diff_eq_sup_sdiff_inf symmDiff_eq_sup_sdiff_inf
theorem Disjoint.symmDiff_eq_sup {a b : α} (h : Disjoint a b) : a ∆ b = a ⊔ b := by
rw [symmDiff, h.sdiff_eq_left, h.sdiff_eq_right]
#align disjoint.symm_diff_eq_sup Disjoint.symmDiff_eq_sup
theorem symmDiff_sdiff : a ∆ b \ c = a \ (b ⊔ c) ⊔ b \ (a ⊔ c) := by
rw [symmDiff, sup_sdiff_distrib, sdiff_sdiff_left, sdiff_sdiff_left]
#align symm_diff_sdiff symmDiff_sdiff
@[simp]
theorem symmDiff_sdiff_inf : a ∆ b \ (a ⊓ b) = a ∆ b := by
rw [symmDiff_sdiff]
simp [symmDiff]
#align symm_diff_sdiff_inf symmDiff_sdiff_inf
@[simp]
theorem symmDiff_sdiff_eq_sup : a ∆ (b \ a) = a ⊔ b := by
rw [symmDiff, sdiff_idem]
exact
le_antisymm (sup_le_sup sdiff_le sdiff_le)
(sup_le le_sdiff_sup <| le_sdiff_sup.trans <| sup_le le_sup_right le_sdiff_sup)
#align symm_diff_sdiff_eq_sup symmDiff_sdiff_eq_sup
@[simp]
theorem sdiff_symmDiff_eq_sup : (a \ b) ∆ b = a ⊔ b := by
rw [symmDiff_comm, symmDiff_sdiff_eq_sup, sup_comm]
#align sdiff_symm_diff_eq_sup sdiff_symmDiff_eq_sup
@[simp]
theorem symmDiff_sup_inf : a ∆ b ⊔ a ⊓ b = a ⊔ b := by
refine le_antisymm (sup_le symmDiff_le_sup inf_le_sup) ?_
rw [sup_inf_left, symmDiff]
refine sup_le (le_inf le_sup_right ?_) (le_inf ?_ le_sup_right)
· rw [sup_right_comm]
exact le_sup_of_le_left le_sdiff_sup
· rw [sup_assoc]
exact le_sup_of_le_right le_sdiff_sup
#align symm_diff_sup_inf symmDiff_sup_inf
@[simp]
theorem inf_sup_symmDiff : a ⊓ b ⊔ a ∆ b = a ⊔ b := by rw [sup_comm, symmDiff_sup_inf]
#align inf_sup_symm_diff inf_sup_symmDiff
@[simp]
theorem symmDiff_symmDiff_inf : a ∆ b ∆ (a ⊓ b) = a ⊔ b := by
rw [← symmDiff_sdiff_inf a, sdiff_symmDiff_eq_sup, symmDiff_sup_inf]
#align symm_diff_symm_diff_inf symmDiff_symmDiff_inf
@[simp]
theorem inf_symmDiff_symmDiff : (a ⊓ b) ∆ (a ∆ b) = a ⊔ b := by
rw [symmDiff_comm, symmDiff_symmDiff_inf]
#align inf_symm_diff_symm_diff inf_symmDiff_symmDiff
theorem symmDiff_triangle : a ∆ c ≤ a ∆ b ⊔ b ∆ c := by
refine (sup_le_sup (sdiff_triangle a b c) <| sdiff_triangle _ b _).trans_eq ?_
rw [sup_comm (c \ b), sup_sup_sup_comm, symmDiff, symmDiff]
#align symm_diff_triangle symmDiff_triangle
| Mathlib/Order/SymmDiff.lean | 218 | 219 | theorem le_symmDiff_sup_right (a b : α) : a ≤ (a ∆ b) ⊔ b := by |
convert symmDiff_triangle a b ⊥ <;> rw [symmDiff_bot]
|
import Mathlib.Order.CompleteLattice
import Mathlib.Order.GaloisConnection
import Mathlib.Data.Set.Lattice
import Mathlib.Tactic.AdaptationNote
#align_import data.rel from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2"
variable {α β γ : Type*}
def Rel (α β : Type*) :=
α → β → Prop -- deriving CompleteLattice, Inhabited
#align rel Rel
-- Porting note: `deriving` above doesn't work.
instance : CompleteLattice (Rel α β) := show CompleteLattice (α → β → Prop) from inferInstance
instance : Inhabited (Rel α β) := show Inhabited (α → β → Prop) from inferInstance
namespace Rel
variable (r : Rel α β)
-- Porting note: required for later theorems.
@[ext] theorem ext {r s : Rel α β} : (∀ a, r a = s a) → r = s := funext
def inv : Rel β α :=
flip r
#align rel.inv Rel.inv
theorem inv_def (x : α) (y : β) : r.inv y x ↔ r x y :=
Iff.rfl
#align rel.inv_def Rel.inv_def
theorem inv_inv : inv (inv r) = r := by
ext x y
rfl
#align rel.inv_inv Rel.inv_inv
def dom := { x | ∃ y, r x y }
#align rel.dom Rel.dom
theorem dom_mono {r s : Rel α β} (h : r ≤ s) : dom r ⊆ dom s := fun a ⟨b, hx⟩ => ⟨b, h a b hx⟩
#align rel.dom_mono Rel.dom_mono
def codom := { y | ∃ x, r x y }
#align rel.codom Rel.codom
theorem codom_inv : r.inv.codom = r.dom := by
ext x
rfl
#align rel.codom_inv Rel.codom_inv
theorem dom_inv : r.inv.dom = r.codom := by
ext x
rfl
#align rel.dom_inv Rel.dom_inv
def comp (r : Rel α β) (s : Rel β γ) : Rel α γ := fun x z => ∃ y, r x y ∧ s y z
#align rel.comp Rel.comp
-- Porting note: the original `∘` syntax can't be overloaded here, lean considers it ambiguous.
local infixr:90 " • " => Rel.comp
theorem comp_assoc {δ : Type*} (r : Rel α β) (s : Rel β γ) (t : Rel γ δ) :
(r • s) • t = r • (s • t) := by
unfold comp; ext (x w); constructor
· rintro ⟨z, ⟨y, rxy, syz⟩, tzw⟩; exact ⟨y, rxy, z, syz, tzw⟩
· rintro ⟨y, rxy, z, syz, tzw⟩; exact ⟨z, ⟨y, rxy, syz⟩, tzw⟩
#align rel.comp_assoc Rel.comp_assoc
@[simp]
theorem comp_right_id (r : Rel α β) : r • @Eq β = r := by
unfold comp
ext y
simp
#align rel.comp_right_id Rel.comp_right_id
@[simp]
theorem comp_left_id (r : Rel α β) : @Eq α • r = r := by
unfold comp
ext x
simp
#align rel.comp_left_id Rel.comp_left_id
@[simp]
theorem comp_right_bot (r : Rel α β) : r • (⊥ : Rel β γ) = ⊥ := by
ext x y
simp [comp, Bot.bot]
@[simp]
theorem comp_left_bot (r : Rel α β) : (⊥ : Rel γ α) • r = ⊥ := by
ext x y
simp [comp, Bot.bot]
@[simp]
theorem comp_right_top (r : Rel α β) : r • (⊤ : Rel β γ) = fun x _ ↦ x ∈ r.dom := by
ext x z
simp [comp, Top.top, dom]
@[simp]
theorem comp_left_top (r : Rel α β) : (⊤ : Rel γ α) • r = fun _ y ↦ y ∈ r.codom := by
ext x z
simp [comp, Top.top, codom]
theorem inv_id : inv (@Eq α) = @Eq α := by
ext x y
constructor <;> apply Eq.symm
#align rel.inv_id Rel.inv_id
theorem inv_comp (r : Rel α β) (s : Rel β γ) : inv (r • s) = inv s • inv r := by
ext x z
simp [comp, inv, flip, and_comm]
#align rel.inv_comp Rel.inv_comp
@[simp]
| Mathlib/Data/Rel.lean | 156 | 158 | theorem inv_bot : (⊥ : Rel α β).inv = (⊥ : Rel β α) := by |
#adaptation_note /-- nightly-2024-03-16: simp was `simp [Bot.bot, inv, flip]` -/
simp [Bot.bot, inv, Function.flip_def]
|
import Mathlib.Data.Set.Basic
#align_import data.set.bool_indicator from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e"
open Bool
namespace Set
variable {α : Type*} (s : Set α)
noncomputable def boolIndicator (x : α) :=
@ite _ (x ∈ s) (Classical.propDecidable _) true false
#align set.bool_indicator Set.boolIndicator
theorem mem_iff_boolIndicator (x : α) : x ∈ s ↔ s.boolIndicator x = true := by
unfold boolIndicator
split_ifs with h <;> simp [h]
#align set.mem_iff_bool_indicator Set.mem_iff_boolIndicator
| Mathlib/Data/Set/BoolIndicator.lean | 32 | 34 | theorem not_mem_iff_boolIndicator (x : α) : x ∉ s ↔ s.boolIndicator x = false := by |
unfold boolIndicator
split_ifs with h <;> simp [h]
|
import Mathlib.Analysis.NormedSpace.PiLp
import Mathlib.Analysis.InnerProductSpace.PiL2
#align_import analysis.matrix from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open scoped NNReal Matrix
namespace Matrix
variable {R l m n α β : Type*} [Fintype l] [Fintype m] [Fintype n]
section LinfLinf
protected def normedAddCommGroup [NormedAddCommGroup α] : NormedAddCommGroup (Matrix m n α) :=
Pi.normedAddCommGroup
#align matrix.normed_add_comm_group Matrix.normedAddCommGroup
section frobenius
open scoped Matrix
@[local instance]
def frobeniusSeminormedAddCommGroup [SeminormedAddCommGroup α] :
SeminormedAddCommGroup (Matrix m n α) :=
inferInstanceAs (SeminormedAddCommGroup (PiLp 2 fun _i : m => PiLp 2 fun _j : n => α))
#align matrix.frobenius_seminormed_add_comm_group Matrix.frobeniusSeminormedAddCommGroup
@[local instance]
def frobeniusNormedAddCommGroup [NormedAddCommGroup α] : NormedAddCommGroup (Matrix m n α) :=
(by infer_instance : NormedAddCommGroup (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
#align matrix.frobenius_normed_add_comm_group Matrix.frobeniusNormedAddCommGroup
@[local instance]
theorem frobeniusBoundedSMul [SeminormedRing R] [SeminormedAddCommGroup α] [Module R α]
[BoundedSMul R α] :
BoundedSMul R (Matrix m n α) :=
(by infer_instance : BoundedSMul R (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
@[local instance]
def frobeniusNormedSpace [NormedField R] [SeminormedAddCommGroup α] [NormedSpace R α] :
NormedSpace R (Matrix m n α) :=
(by infer_instance : NormedSpace R (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
#align matrix.frobenius_normed_space Matrix.frobeniusNormedSpace
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β]
theorem frobenius_nnnorm_def (A : Matrix m n α) :
‖A‖₊ = (∑ i, ∑ j, ‖A i j‖₊ ^ (2 : ℝ)) ^ (1 / 2 : ℝ) := by
-- Porting note: added, along with `WithLp.equiv_symm_pi_apply` below
change ‖(WithLp.equiv 2 _).symm fun i => (WithLp.equiv 2 _).symm fun j => A i j‖₊ = _
simp_rw [PiLp.nnnorm_eq_of_L2, NNReal.sq_sqrt, NNReal.sqrt_eq_rpow, NNReal.rpow_two,
WithLp.equiv_symm_pi_apply]
#align matrix.frobenius_nnnorm_def Matrix.frobenius_nnnorm_def
theorem frobenius_norm_def (A : Matrix m n α) :
‖A‖ = (∑ i, ∑ j, ‖A i j‖ ^ (2 : ℝ)) ^ (1 / 2 : ℝ) :=
(congr_arg ((↑) : ℝ≥0 → ℝ) (frobenius_nnnorm_def A)).trans <| by simp [NNReal.coe_sum]
#align matrix.frobenius_norm_def Matrix.frobenius_norm_def
@[simp]
theorem frobenius_nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) :
‖A.map f‖₊ = ‖A‖₊ := by simp_rw [frobenius_nnnorm_def, Matrix.map_apply, hf]
#align matrix.frobenius_nnnorm_map_eq Matrix.frobenius_nnnorm_map_eq
@[simp]
theorem frobenius_norm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖ = ‖a‖) :
‖A.map f‖ = ‖A‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_map_eq A f fun a => Subtype.ext <| hf a : _)
#align matrix.frobenius_norm_map_eq Matrix.frobenius_norm_map_eq
@[simp]
theorem frobenius_nnnorm_transpose (A : Matrix m n α) : ‖Aᵀ‖₊ = ‖A‖₊ := by
rw [frobenius_nnnorm_def, frobenius_nnnorm_def, Finset.sum_comm]
simp_rw [Matrix.transpose_apply] -- Porting note: added
#align matrix.frobenius_nnnorm_transpose Matrix.frobenius_nnnorm_transpose
@[simp]
theorem frobenius_norm_transpose (A : Matrix m n α) : ‖Aᵀ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_transpose A
#align matrix.frobenius_norm_transpose Matrix.frobenius_norm_transpose
@[simp]
theorem frobenius_nnnorm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖₊ = ‖A‖₊ :=
(frobenius_nnnorm_map_eq _ _ nnnorm_star).trans A.frobenius_nnnorm_transpose
#align matrix.frobenius_nnnorm_conj_transpose Matrix.frobenius_nnnorm_conjTranspose
@[simp]
theorem frobenius_norm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_conjTranspose A
#align matrix.frobenius_norm_conj_transpose Matrix.frobenius_norm_conjTranspose
instance frobenius_normedStarGroup [StarAddMonoid α] [NormedStarGroup α] :
NormedStarGroup (Matrix m m α) :=
⟨frobenius_norm_conjTranspose⟩
#align matrix.frobenius_normed_star_group Matrix.frobenius_normedStarGroup
@[simp]
theorem frobenius_norm_row (v : m → α) : ‖row v‖ = ‖(WithLp.equiv 2 _).symm v‖ := by
rw [frobenius_norm_def, Fintype.sum_unique, PiLp.norm_eq_of_L2, Real.sqrt_eq_rpow]
simp only [row_apply, Real.rpow_two, WithLp.equiv_symm_pi_apply]
#align matrix.frobenius_norm_row Matrix.frobenius_norm_row
@[simp]
theorem frobenius_nnnorm_row (v : m → α) : ‖row v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ :=
Subtype.ext <| frobenius_norm_row v
#align matrix.frobenius_nnnorm_row Matrix.frobenius_nnnorm_row
@[simp]
theorem frobenius_norm_col (v : n → α) : ‖col v‖ = ‖(WithLp.equiv 2 _).symm v‖ := by
simp_rw [frobenius_norm_def, Fintype.sum_unique, PiLp.norm_eq_of_L2, Real.sqrt_eq_rpow]
simp only [col_apply, Real.rpow_two, WithLp.equiv_symm_pi_apply]
#align matrix.frobenius_norm_col Matrix.frobenius_norm_col
@[simp]
theorem frobenius_nnnorm_col (v : n → α) : ‖col v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ :=
Subtype.ext <| frobenius_norm_col v
#align matrix.frobenius_nnnorm_col Matrix.frobenius_nnnorm_col
@[simp]
| Mathlib/Analysis/Matrix.lean | 635 | 646 | theorem frobenius_nnnorm_diagonal [DecidableEq n] (v : n → α) :
‖diagonal v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ := by |
simp_rw [frobenius_nnnorm_def, ← Finset.sum_product', Finset.univ_product_univ,
PiLp.nnnorm_eq_of_L2]
let s := (Finset.univ : Finset n).map ⟨fun i : n => (i, i), fun i j h => congr_arg Prod.fst h⟩
rw [← Finset.sum_subset (Finset.subset_univ s) fun i _hi his => ?_]
· rw [Finset.sum_map, NNReal.sqrt_eq_rpow]
dsimp
simp_rw [diagonal_apply_eq, NNReal.rpow_two]
· suffices i.1 ≠ i.2 by rw [diagonal_apply_ne _ this, nnnorm_zero, NNReal.zero_rpow two_ne_zero]
intro h
exact Finset.mem_map.not.mp his ⟨i.1, Finset.mem_univ _, Prod.ext rfl h⟩
|
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.RingTheory.PowerSeries.Basic
#align_import ring_theory.power_series.well_known from "leanprover-community/mathlib"@"8199f6717c150a7fe91c4534175f4cf99725978f"
namespace PowerSeries
section Field
variable (A A' : Type*) [Ring A] [Ring A'] [Algebra ℚ A] [Algebra ℚ A']
open Nat
def exp : PowerSeries A :=
mk fun n => algebraMap ℚ A (1 / n !)
#align power_series.exp PowerSeries.exp
def sin : PowerSeries A :=
mk fun n => if Even n then 0 else algebraMap ℚ A ((-1) ^ (n / 2) / n !)
#align power_series.sin PowerSeries.sin
def cos : PowerSeries A :=
mk fun n => if Even n then algebraMap ℚ A ((-1) ^ (n / 2) / n !) else 0
#align power_series.cos PowerSeries.cos
variable {A A'} [Ring A] [Ring A'] [Algebra ℚ A] [Algebra ℚ A'] (n : ℕ) (f : A →+* A')
@[simp]
theorem coeff_exp : coeff A n (exp A) = algebraMap ℚ A (1 / n !) :=
coeff_mk _ _
#align power_series.coeff_exp PowerSeries.coeff_exp
@[simp]
theorem constantCoeff_exp : constantCoeff A (exp A) = 1 := by
rw [← coeff_zero_eq_constantCoeff_apply, coeff_exp]
simp
#align power_series.constant_coeff_exp PowerSeries.constantCoeff_exp
set_option linter.deprecated false in
@[simp]
| Mathlib/RingTheory/PowerSeries/WellKnown.lean | 181 | 182 | theorem coeff_sin_bit0 : coeff A (bit0 n) (sin A) = 0 := by |
rw [sin, coeff_mk, if_pos (even_bit0 n)]
|
import Mathlib.LinearAlgebra.Dimension.Finrank
import Mathlib.LinearAlgebra.InvariantBasisNumber
#align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5"
noncomputable section
universe u v w w'
variable {R : Type u} {M : Type v} [Ring R] [AddCommGroup M] [Module R M]
variable {ι : Type w} {ι' : Type w'}
open Cardinal Basis Submodule Function Set
attribute [local instance] nontrivial_of_invariantBasisNumber
section StrongRankCondition
variable [StrongRankCondition R]
open Submodule
-- An auxiliary lemma for `linearIndependent_le_span'`,
-- with the additional assumption that the linearly independent family is finite.
theorem linearIndependent_le_span_aux' {ι : Type*} [Fintype ι] (v : ι → M)
(i : LinearIndependent R v) (w : Set M) [Fintype w] (s : range v ≤ span R w) :
Fintype.card ι ≤ Fintype.card w := by
-- We construct an injective linear map `(ι → R) →ₗ[R] (w → R)`,
-- by thinking of `f : ι → R` as a linear combination of the finite family `v`,
-- and expressing that (using the axiom of choice) as a linear combination over `w`.
-- We can do this linearly by constructing the map on a basis.
fapply card_le_of_injective' R
· apply Finsupp.total
exact fun i => Span.repr R w ⟨v i, s (mem_range_self i)⟩
· intro f g h
apply_fun Finsupp.total w M R (↑) at h
simp only [Finsupp.total_total, Submodule.coe_mk, Span.finsupp_total_repr] at h
rw [← sub_eq_zero, ← LinearMap.map_sub] at h
exact sub_eq_zero.mp (linearIndependent_iff.mp i _ h)
#align linear_independent_le_span_aux' linearIndependent_le_span_aux'
lemma LinearIndependent.finite_of_le_span_finite {ι : Type*} (v : ι → M) (i : LinearIndependent R v)
(w : Set M) [Finite w] (s : range v ≤ span R w) : Finite ι :=
letI := Fintype.ofFinite w
Fintype.finite <| fintypeOfFinsetCardLe (Fintype.card w) fun t => by
let v' := fun x : (t : Set ι) => v x
have i' : LinearIndependent R v' := i.comp _ Subtype.val_injective
have s' : range v' ≤ span R w := (range_comp_subset_range _ _).trans s
simpa using linearIndependent_le_span_aux' v' i' w s'
#align linear_independent_fintype_of_le_span_fintype LinearIndependent.finite_of_le_span_finite
theorem linearIndependent_le_span' {ι : Type*} (v : ι → M) (i : LinearIndependent R v) (w : Set M)
[Fintype w] (s : range v ≤ span R w) : #ι ≤ Fintype.card w := by
haveI : Finite ι := i.finite_of_le_span_finite v w s
letI := Fintype.ofFinite ι
rw [Cardinal.mk_fintype]
simp only [Cardinal.natCast_le]
exact linearIndependent_le_span_aux' v i w s
#align linear_independent_le_span' linearIndependent_le_span'
theorem linearIndependent_le_span {ι : Type*} (v : ι → M) (i : LinearIndependent R v) (w : Set M)
[Fintype w] (s : span R w = ⊤) : #ι ≤ Fintype.card w := by
apply linearIndependent_le_span' v i w
rw [s]
exact le_top
#align linear_independent_le_span linearIndependent_le_span
theorem linearIndependent_le_span_finset {ι : Type*} (v : ι → M) (i : LinearIndependent R v)
(w : Finset M) (s : span R (w : Set M) = ⊤) : #ι ≤ w.card := by
simpa only [Finset.coe_sort_coe, Fintype.card_coe] using linearIndependent_le_span v i w s
#align linear_independent_le_span_finset linearIndependent_le_span_finset
theorem linearIndependent_le_infinite_basis {ι : Type w} (b : Basis ι R M) [Infinite ι] {κ : Type w}
(v : κ → M) (i : LinearIndependent R v) : #κ ≤ #ι := by
classical
by_contra h
rw [not_le, ← Cardinal.mk_finset_of_infinite ι] at h
let Φ := fun k : κ => (b.repr (v k)).support
obtain ⟨s, w : Infinite ↑(Φ ⁻¹' {s})⟩ := Cardinal.exists_infinite_fiber Φ h (by infer_instance)
let v' := fun k : Φ ⁻¹' {s} => v k
have i' : LinearIndependent R v' := i.comp _ Subtype.val_injective
have w' : Finite (Φ ⁻¹' {s}) := by
apply i'.finite_of_le_span_finite v' (s.image b)
rintro m ⟨⟨p, ⟨rfl⟩⟩, rfl⟩
simp only [SetLike.mem_coe, Subtype.coe_mk, Finset.coe_image]
apply Basis.mem_span_repr_support
exact w.false
#align linear_independent_le_infinite_basis linearIndependent_le_infinite_basis
| Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean | 266 | 276 | theorem linearIndependent_le_basis {ι : Type w} (b : Basis ι R M) {κ : Type w} (v : κ → M)
(i : LinearIndependent R v) : #κ ≤ #ι := by |
classical
-- We split into cases depending on whether `ι` is infinite.
cases fintypeOrInfinite ι
· rw [Cardinal.mk_fintype ι] -- When `ι` is finite, we have `linearIndependent_le_span`,
haveI : Nontrivial R := nontrivial_of_invariantBasisNumber R
rw [Fintype.card_congr (Equiv.ofInjective b b.injective)]
exact linearIndependent_le_span v i (range b) b.span_eq
· -- and otherwise we have `linearIndependent_le_infinite_basis`.
exact linearIndependent_le_infinite_basis b v i
|
import Mathlib.Algebra.Order.Group.Basic
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.Algebra.Ring.Nat
import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.RingTheory.Fintype
import Mathlib.Tactic.IntervalCases
#align_import number_theory.lucas_lehmer from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
def mersenne (p : ℕ) : ℕ :=
2 ^ p - 1
#align mersenne mersenne
theorem strictMono_mersenne : StrictMono mersenne := fun m n h ↦
(Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1
@[simp]
theorem mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q :=
strictMono_mersenne.lt_iff_lt
@[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne
@[simp]
theorem mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q :=
strictMono_mersenne.le_iff_le
@[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne
@[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl
@[simp] theorem mersenne_pos {p : ℕ} : 0 < mersenne p ↔ 0 < p := mersenne_lt_mersenne (p := 0)
#align mersenne_pos mersenne_pos
@[simp]
theorem one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p :=
mersenne_lt_mersenne (p := 1)
@[simp]
theorem succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by
rw [mersenne, tsub_add_cancel_of_le]
exact one_le_pow_of_one_le (by norm_num) k
#align succ_mersenne succ_mersenne
namespace LucasLehmer
open Nat
def s : ℕ → ℤ
| 0 => 4
| i + 1 => s i ^ 2 - 2
#align lucas_lehmer.s LucasLehmer.s
def sZMod (p : ℕ) : ℕ → ZMod (2 ^ p - 1)
| 0 => 4
| i + 1 => sZMod p i ^ 2 - 2
#align lucas_lehmer.s_zmod LucasLehmer.sZMod
def sMod (p : ℕ) : ℕ → ℤ
| 0 => 4 % (2 ^ p - 1)
| i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1)
#align lucas_lehmer.s_mod LucasLehmer.sMod
theorem mersenne_int_pos {p : ℕ} (hp : p ≠ 0) : (0 : ℤ) < 2 ^ p - 1 :=
sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp
theorem mersenne_int_ne_zero (p : ℕ) (hp : p ≠ 0) : (2 ^ p - 1 : ℤ) ≠ 0 :=
(mersenne_int_pos hp).ne'
#align lucas_lehmer.mersenne_int_ne_zero LucasLehmer.mersenne_int_ne_zero
theorem sMod_nonneg (p : ℕ) (hp : p ≠ 0) (i : ℕ) : 0 ≤ sMod p i := by
cases i <;> dsimp [sMod]
· exact sup_eq_right.mp rfl
· apply Int.emod_nonneg
exact mersenne_int_ne_zero p hp
#align lucas_lehmer.s_mod_nonneg LucasLehmer.sMod_nonneg
theorem sMod_mod (p i : ℕ) : sMod p i % (2 ^ p - 1) = sMod p i := by cases i <;> simp [sMod]
#align lucas_lehmer.s_mod_mod LucasLehmer.sMod_mod
theorem sMod_lt (p : ℕ) (hp : p ≠ 0) (i : ℕ) : sMod p i < 2 ^ p - 1 := by
rw [← sMod_mod]
refine (Int.emod_lt _ (mersenne_int_ne_zero p hp)).trans_eq ?_
exact abs_of_nonneg (mersenne_int_pos hp).le
#align lucas_lehmer.s_mod_lt LucasLehmer.sMod_lt
theorem sZMod_eq_s (p' : ℕ) (i : ℕ) : sZMod (p' + 2) i = (s i : ZMod (2 ^ (p' + 2) - 1)) := by
induction' i with i ih
· dsimp [s, sZMod]
norm_num
· push_cast [s, sZMod, ih]; rfl
#align lucas_lehmer.s_zmod_eq_s LucasLehmer.sZMod_eq_s
-- These next two don't make good `norm_cast` lemmas.
theorem Int.natCast_pow_pred (b p : ℕ) (w : 0 < b) : ((b ^ p - 1 : ℕ) : ℤ) = (b : ℤ) ^ p - 1 := by
have : 1 ≤ b ^ p := Nat.one_le_pow p b w
norm_cast
#align lucas_lehmer.int.coe_nat_pow_pred LucasLehmer.Int.natCast_pow_pred
@[deprecated (since := "2024-05-25")] alias Int.coe_nat_pow_pred := Int.natCast_pow_pred
theorem Int.coe_nat_two_pow_pred (p : ℕ) : ((2 ^ p - 1 : ℕ) : ℤ) = (2 ^ p - 1 : ℤ) :=
Int.natCast_pow_pred 2 p (by decide)
#align lucas_lehmer.int.coe_nat_two_pow_pred LucasLehmer.Int.coe_nat_two_pow_pred
| Mathlib/NumberTheory/LucasLehmer.lean | 173 | 174 | theorem sZMod_eq_sMod (p : ℕ) (i : ℕ) : sZMod p i = (sMod p i : ZMod (2 ^ p - 1)) := by |
induction i <;> push_cast [← Int.coe_nat_two_pow_pred p, sMod, sZMod, *] <;> rfl
|
import Mathlib.Algebra.Field.Defs
import Mathlib.Tactic.Common
#align_import algebra.field.defs from "leanprover-community/mathlib"@"2651125b48fc5c170ab1111afd0817c903b1fc6c"
universe u
section IsField
structure IsField (R : Type u) [Semiring R] : Prop where
exists_pair_ne : ∃ x y : R, x ≠ y
mul_comm : ∀ x y : R, x * y = y * x
mul_inv_cancel : ∀ {a : R}, a ≠ 0 → ∃ b, a * b = 1
#align is_field IsField
theorem Semifield.toIsField (R : Type u) [Semifield R] : IsField R where
__ := ‹Semifield R›
mul_inv_cancel {a} ha := ⟨a⁻¹, mul_inv_cancel ha⟩
#align semifield.to_is_field Semifield.toIsField
theorem Field.toIsField (R : Type u) [Field R] : IsField R :=
Semifield.toIsField _
#align field.to_is_field Field.toIsField
@[simp]
theorem IsField.nontrivial {R : Type u} [Semiring R] (h : IsField R) : Nontrivial R :=
⟨h.exists_pair_ne⟩
#align is_field.nontrivial IsField.nontrivial
@[simp]
theorem not_isField_of_subsingleton (R : Type u) [Semiring R] [Subsingleton R] : ¬IsField R :=
fun h =>
let ⟨_, _, h⟩ := h.exists_pair_ne
h (Subsingleton.elim _ _)
#align not_is_field_of_subsingleton not_isField_of_subsingleton
open scoped Classical
noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R) : Semifield R where
__ := ‹Semiring R›
__ := h
inv a := if ha : a = 0 then 0 else Classical.choose (h.mul_inv_cancel ha)
inv_zero := dif_pos rfl
mul_inv_cancel a ha := by convert Classical.choose_spec (h.mul_inv_cancel ha); exact dif_neg ha
nnqsmul := _
#align is_field.to_semifield IsField.toSemifield
noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field R :=
{ ‹Ring R›, IsField.toSemifield h with qsmul := _ }
#align is_field.to_field IsField.toField
| Mathlib/Algebra/Field/IsField.lean | 84 | 93 | theorem uniq_inv_of_isField (R : Type u) [Ring R] (hf : IsField R) :
∀ x : R, x ≠ 0 → ∃! y : R, x * y = 1 := by |
intro x hx
apply exists_unique_of_exists_of_unique
· exact hf.mul_inv_cancel hx
· intro y z hxy hxz
calc
y = y * (x * z) := by rw [hxz, mul_one]
_ = x * y * z := by rw [← mul_assoc, hf.mul_comm y x]
_ = z := by rw [hxy, one_mul]
|
import Mathlib.MeasureTheory.Function.LpOrder
#align_import measure_theory.function.l1_space from "leanprover-community/mathlib"@"ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f"
noncomputable section
open scoped Classical
open Topology ENNReal MeasureTheory NNReal
open Set Filter TopologicalSpace ENNReal EMetric MeasureTheory
variable {α β γ δ : Type*} {m : MeasurableSpace α} {μ ν : Measure α} [MeasurableSpace δ]
variable [NormedAddCommGroup β]
variable [NormedAddCommGroup γ]
namespace MeasureTheory
theorem lintegral_nnnorm_eq_lintegral_edist (f : α → β) :
∫⁻ a, ‖f a‖₊ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [edist_eq_coe_nnnorm]
#align measure_theory.lintegral_nnnorm_eq_lintegral_edist MeasureTheory.lintegral_nnnorm_eq_lintegral_edist
theorem lintegral_norm_eq_lintegral_edist (f : α → β) :
∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by
simp only [ofReal_norm_eq_coe_nnnorm, edist_eq_coe_nnnorm]
#align measure_theory.lintegral_norm_eq_lintegral_edist MeasureTheory.lintegral_norm_eq_lintegral_edist
theorem lintegral_edist_triangle {f g h : α → β} (hf : AEStronglyMeasurable f μ)
(hh : AEStronglyMeasurable h μ) :
(∫⁻ a, edist (f a) (g a) ∂μ) ≤ (∫⁻ a, edist (f a) (h a) ∂μ) + ∫⁻ a, edist (g a) (h a) ∂μ := by
rw [← lintegral_add_left' (hf.edist hh)]
refine lintegral_mono fun a => ?_
apply edist_triangle_right
#align measure_theory.lintegral_edist_triangle MeasureTheory.lintegral_edist_triangle
theorem lintegral_nnnorm_zero : (∫⁻ _ : α, ‖(0 : β)‖₊ ∂μ) = 0 := by simp
#align measure_theory.lintegral_nnnorm_zero MeasureTheory.lintegral_nnnorm_zero
theorem lintegral_nnnorm_add_left {f : α → β} (hf : AEStronglyMeasurable f μ) (g : α → γ) :
∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ = (∫⁻ a, ‖f a‖₊ ∂μ) + ∫⁻ a, ‖g a‖₊ ∂μ :=
lintegral_add_left' hf.ennnorm _
#align measure_theory.lintegral_nnnorm_add_left MeasureTheory.lintegral_nnnorm_add_left
theorem lintegral_nnnorm_add_right (f : α → β) {g : α → γ} (hg : AEStronglyMeasurable g μ) :
∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ = (∫⁻ a, ‖f a‖₊ ∂μ) + ∫⁻ a, ‖g a‖₊ ∂μ :=
lintegral_add_right' _ hg.ennnorm
#align measure_theory.lintegral_nnnorm_add_right MeasureTheory.lintegral_nnnorm_add_right
theorem lintegral_nnnorm_neg {f : α → β} : (∫⁻ a, ‖(-f) a‖₊ ∂μ) = ∫⁻ a, ‖f a‖₊ ∂μ := by
simp only [Pi.neg_apply, nnnorm_neg]
#align measure_theory.lintegral_nnnorm_neg MeasureTheory.lintegral_nnnorm_neg
def HasFiniteIntegral {_ : MeasurableSpace α} (f : α → β) (μ : Measure α := by volume_tac) : Prop :=
(∫⁻ a, ‖f a‖₊ ∂μ) < ∞
#align measure_theory.has_finite_integral MeasureTheory.HasFiniteIntegral
theorem hasFiniteIntegral_def {_ : MeasurableSpace α} (f : α → β) (μ : Measure α) :
HasFiniteIntegral f μ ↔ ((∫⁻ a, ‖f a‖₊ ∂μ) < ∞) :=
Iff.rfl
theorem hasFiniteIntegral_iff_norm (f : α → β) :
HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) < ∞ := by
simp only [HasFiniteIntegral, ofReal_norm_eq_coe_nnnorm]
#align measure_theory.has_finite_integral_iff_norm MeasureTheory.hasFiniteIntegral_iff_norm
theorem hasFiniteIntegral_iff_edist (f : α → β) :
HasFiniteIntegral f μ ↔ (∫⁻ a, edist (f a) 0 ∂μ) < ∞ := by
simp only [hasFiniteIntegral_iff_norm, edist_dist, dist_zero_right]
#align measure_theory.has_finite_integral_iff_edist MeasureTheory.hasFiniteIntegral_iff_edist
theorem hasFiniteIntegral_iff_ofReal {f : α → ℝ} (h : 0 ≤ᵐ[μ] f) :
HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal (f a) ∂μ) < ∞ := by
rw [HasFiniteIntegral, lintegral_nnnorm_eq_of_ae_nonneg h]
#align measure_theory.has_finite_integral_iff_of_real MeasureTheory.hasFiniteIntegral_iff_ofReal
theorem hasFiniteIntegral_iff_ofNNReal {f : α → ℝ≥0} :
HasFiniteIntegral (fun x => (f x : ℝ)) μ ↔ (∫⁻ a, f a ∂μ) < ∞ := by
simp [hasFiniteIntegral_iff_norm]
#align measure_theory.has_finite_integral_iff_of_nnreal MeasureTheory.hasFiniteIntegral_iff_ofNNReal
theorem HasFiniteIntegral.mono {f : α → β} {g : α → γ} (hg : HasFiniteIntegral g μ)
(h : ∀ᵐ a ∂μ, ‖f a‖ ≤ ‖g a‖) : HasFiniteIntegral f μ := by
simp only [hasFiniteIntegral_iff_norm] at *
calc
(∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) ≤ ∫⁻ a : α, ENNReal.ofReal ‖g a‖ ∂μ :=
lintegral_mono_ae (h.mono fun a h => ofReal_le_ofReal h)
_ < ∞ := hg
#align measure_theory.has_finite_integral.mono MeasureTheory.HasFiniteIntegral.mono
theorem HasFiniteIntegral.mono' {f : α → β} {g : α → ℝ} (hg : HasFiniteIntegral g μ)
(h : ∀ᵐ a ∂μ, ‖f a‖ ≤ g a) : HasFiniteIntegral f μ :=
hg.mono <| h.mono fun _x hx => le_trans hx (le_abs_self _)
#align measure_theory.has_finite_integral.mono' MeasureTheory.HasFiniteIntegral.mono'
theorem HasFiniteIntegral.congr' {f : α → β} {g : α → γ} (hf : HasFiniteIntegral f μ)
(h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : HasFiniteIntegral g μ :=
hf.mono <| EventuallyEq.le <| EventuallyEq.symm h
#align measure_theory.has_finite_integral.congr' MeasureTheory.HasFiniteIntegral.congr'
theorem hasFiniteIntegral_congr' {f : α → β} {g : α → γ} (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) :
HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ :=
⟨fun hf => hf.congr' h, fun hg => hg.congr' <| EventuallyEq.symm h⟩
#align measure_theory.has_finite_integral_congr' MeasureTheory.hasFiniteIntegral_congr'
theorem HasFiniteIntegral.congr {f g : α → β} (hf : HasFiniteIntegral f μ) (h : f =ᵐ[μ] g) :
HasFiniteIntegral g μ :=
hf.congr' <| h.fun_comp norm
#align measure_theory.has_finite_integral.congr MeasureTheory.HasFiniteIntegral.congr
theorem hasFiniteIntegral_congr {f g : α → β} (h : f =ᵐ[μ] g) :
HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ :=
hasFiniteIntegral_congr' <| h.fun_comp norm
#align measure_theory.has_finite_integral_congr MeasureTheory.hasFiniteIntegral_congr
theorem hasFiniteIntegral_const_iff {c : β} :
HasFiniteIntegral (fun _ : α => c) μ ↔ c = 0 ∨ μ univ < ∞ := by
simp [HasFiniteIntegral, lintegral_const, lt_top_iff_ne_top, ENNReal.mul_eq_top,
or_iff_not_imp_left]
#align measure_theory.has_finite_integral_const_iff MeasureTheory.hasFiniteIntegral_const_iff
theorem hasFiniteIntegral_const [IsFiniteMeasure μ] (c : β) :
HasFiniteIntegral (fun _ : α => c) μ :=
hasFiniteIntegral_const_iff.2 (Or.inr <| measure_lt_top _ _)
#align measure_theory.has_finite_integral_const MeasureTheory.hasFiniteIntegral_const
theorem hasFiniteIntegral_of_bounded [IsFiniteMeasure μ] {f : α → β} {C : ℝ}
(hC : ∀ᵐ a ∂μ, ‖f a‖ ≤ C) : HasFiniteIntegral f μ :=
(hasFiniteIntegral_const C).mono' hC
#align measure_theory.has_finite_integral_of_bounded MeasureTheory.hasFiniteIntegral_of_bounded
theorem HasFiniteIntegral.of_finite [Finite α] [IsFiniteMeasure μ] {f : α → β} :
HasFiniteIntegral f μ :=
let ⟨_⟩ := nonempty_fintype α
hasFiniteIntegral_of_bounded <| ae_of_all μ <| norm_le_pi_norm f
@[deprecated (since := "2024-02-05")]
alias hasFiniteIntegral_of_fintype := HasFiniteIntegral.of_finite
theorem HasFiniteIntegral.mono_measure {f : α → β} (h : HasFiniteIntegral f ν) (hμ : μ ≤ ν) :
HasFiniteIntegral f μ :=
lt_of_le_of_lt (lintegral_mono' hμ le_rfl) h
#align measure_theory.has_finite_integral.mono_measure MeasureTheory.HasFiniteIntegral.mono_measure
theorem HasFiniteIntegral.add_measure {f : α → β} (hμ : HasFiniteIntegral f μ)
(hν : HasFiniteIntegral f ν) : HasFiniteIntegral f (μ + ν) := by
simp only [HasFiniteIntegral, lintegral_add_measure] at *
exact add_lt_top.2 ⟨hμ, hν⟩
#align measure_theory.has_finite_integral.add_measure MeasureTheory.HasFiniteIntegral.add_measure
theorem HasFiniteIntegral.left_of_add_measure {f : α → β} (h : HasFiniteIntegral f (μ + ν)) :
HasFiniteIntegral f μ :=
h.mono_measure <| Measure.le_add_right <| le_rfl
#align measure_theory.has_finite_integral.left_of_add_measure MeasureTheory.HasFiniteIntegral.left_of_add_measure
theorem HasFiniteIntegral.right_of_add_measure {f : α → β} (h : HasFiniteIntegral f (μ + ν)) :
HasFiniteIntegral f ν :=
h.mono_measure <| Measure.le_add_left <| le_rfl
#align measure_theory.has_finite_integral.right_of_add_measure MeasureTheory.HasFiniteIntegral.right_of_add_measure
@[simp]
theorem hasFiniteIntegral_add_measure {f : α → β} :
HasFiniteIntegral f (μ + ν) ↔ HasFiniteIntegral f μ ∧ HasFiniteIntegral f ν :=
⟨fun h => ⟨h.left_of_add_measure, h.right_of_add_measure⟩, fun h => h.1.add_measure h.2⟩
#align measure_theory.has_finite_integral_add_measure MeasureTheory.hasFiniteIntegral_add_measure
theorem HasFiniteIntegral.smul_measure {f : α → β} (h : HasFiniteIntegral f μ) {c : ℝ≥0∞}
(hc : c ≠ ∞) : HasFiniteIntegral f (c • μ) := by
simp only [HasFiniteIntegral, lintegral_smul_measure] at *
exact mul_lt_top hc h.ne
#align measure_theory.has_finite_integral.smul_measure MeasureTheory.HasFiniteIntegral.smul_measure
@[simp]
theorem hasFiniteIntegral_zero_measure {m : MeasurableSpace α} (f : α → β) :
HasFiniteIntegral f (0 : Measure α) := by
simp only [HasFiniteIntegral, lintegral_zero_measure, zero_lt_top]
#align measure_theory.has_finite_integral_zero_measure MeasureTheory.hasFiniteIntegral_zero_measure
variable (α β μ)
@[simp]
theorem hasFiniteIntegral_zero : HasFiniteIntegral (fun _ : α => (0 : β)) μ := by
simp [HasFiniteIntegral]
#align measure_theory.has_finite_integral_zero MeasureTheory.hasFiniteIntegral_zero
variable {α β μ}
theorem HasFiniteIntegral.neg {f : α → β} (hfi : HasFiniteIntegral f μ) :
HasFiniteIntegral (-f) μ := by simpa [HasFiniteIntegral] using hfi
#align measure_theory.has_finite_integral.neg MeasureTheory.HasFiniteIntegral.neg
@[simp]
theorem hasFiniteIntegral_neg_iff {f : α → β} : HasFiniteIntegral (-f) μ ↔ HasFiniteIntegral f μ :=
⟨fun h => neg_neg f ▸ h.neg, HasFiniteIntegral.neg⟩
#align measure_theory.has_finite_integral_neg_iff MeasureTheory.hasFiniteIntegral_neg_iff
theorem HasFiniteIntegral.norm {f : α → β} (hfi : HasFiniteIntegral f μ) :
HasFiniteIntegral (fun a => ‖f a‖) μ := by
have eq : (fun a => (nnnorm ‖f a‖ : ℝ≥0∞)) = fun a => (‖f a‖₊ : ℝ≥0∞) := by
funext
rw [nnnorm_norm]
rwa [HasFiniteIntegral, eq]
#align measure_theory.has_finite_integral.norm MeasureTheory.HasFiniteIntegral.norm
theorem hasFiniteIntegral_norm_iff (f : α → β) :
HasFiniteIntegral (fun a => ‖f a‖) μ ↔ HasFiniteIntegral f μ :=
hasFiniteIntegral_congr' <| eventually_of_forall fun x => norm_norm (f x)
#align measure_theory.has_finite_integral_norm_iff MeasureTheory.hasFiniteIntegral_norm_iff
theorem hasFiniteIntegral_toReal_of_lintegral_ne_top {f : α → ℝ≥0∞} (hf : (∫⁻ x, f x ∂μ) ≠ ∞) :
HasFiniteIntegral (fun x => (f x).toReal) μ := by
have :
∀ x, (‖(f x).toReal‖₊ : ℝ≥0∞) = ENNReal.ofNNReal ⟨(f x).toReal, ENNReal.toReal_nonneg⟩ := by
intro x
rw [Real.nnnorm_of_nonneg]
simp_rw [HasFiniteIntegral, this]
refine lt_of_le_of_lt (lintegral_mono fun x => ?_) (lt_top_iff_ne_top.2 hf)
by_cases hfx : f x = ∞
· simp [hfx]
· lift f x to ℝ≥0 using hfx with fx h
simp [← h, ← NNReal.coe_le_coe]
#align measure_theory.has_finite_integral_to_real_of_lintegral_ne_top MeasureTheory.hasFiniteIntegral_toReal_of_lintegral_ne_top
theorem isFiniteMeasure_withDensity_ofReal {f : α → ℝ} (hfi : HasFiniteIntegral f μ) :
IsFiniteMeasure (μ.withDensity fun x => ENNReal.ofReal <| f x) := by
refine isFiniteMeasure_withDensity ((lintegral_mono fun x => ?_).trans_lt hfi).ne
exact Real.ofReal_le_ennnorm (f x)
#align measure_theory.is_finite_measure_with_density_of_real MeasureTheory.isFiniteMeasure_withDensity_ofReal
-- variable [MeasurableSpace β] [MeasurableSpace γ] [MeasurableSpace δ]
def Integrable {α} {_ : MeasurableSpace α} (f : α → β) (μ : Measure α := by volume_tac) : Prop :=
AEStronglyMeasurable f μ ∧ HasFiniteIntegral f μ
#align measure_theory.integrable MeasureTheory.Integrable
theorem memℒp_one_iff_integrable {f : α → β} : Memℒp f 1 μ ↔ Integrable f μ := by
simp_rw [Integrable, HasFiniteIntegral, Memℒp, snorm_one_eq_lintegral_nnnorm]
#align measure_theory.mem_ℒp_one_iff_integrable MeasureTheory.memℒp_one_iff_integrable
theorem Integrable.aestronglyMeasurable {f : α → β} (hf : Integrable f μ) :
AEStronglyMeasurable f μ :=
hf.1
#align measure_theory.integrable.ae_strongly_measurable MeasureTheory.Integrable.aestronglyMeasurable
theorem Integrable.aemeasurable [MeasurableSpace β] [BorelSpace β] {f : α → β}
(hf : Integrable f μ) : AEMeasurable f μ :=
hf.aestronglyMeasurable.aemeasurable
#align measure_theory.integrable.ae_measurable MeasureTheory.Integrable.aemeasurable
theorem Integrable.hasFiniteIntegral {f : α → β} (hf : Integrable f μ) : HasFiniteIntegral f μ :=
hf.2
#align measure_theory.integrable.has_finite_integral MeasureTheory.Integrable.hasFiniteIntegral
theorem Integrable.mono {f : α → β} {g : α → γ} (hg : Integrable g μ)
(hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ ‖g a‖) : Integrable f μ :=
⟨hf, hg.hasFiniteIntegral.mono h⟩
#align measure_theory.integrable.mono MeasureTheory.Integrable.mono
theorem Integrable.mono' {f : α → β} {g : α → ℝ} (hg : Integrable g μ)
(hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ g a) : Integrable f μ :=
⟨hf, hg.hasFiniteIntegral.mono' h⟩
#align measure_theory.integrable.mono' MeasureTheory.Integrable.mono'
theorem Integrable.congr' {f : α → β} {g : α → γ} (hf : Integrable f μ)
(hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : Integrable g μ :=
⟨hg, hf.hasFiniteIntegral.congr' h⟩
#align measure_theory.integrable.congr' MeasureTheory.Integrable.congr'
theorem integrable_congr' {f : α → β} {g : α → γ} (hf : AEStronglyMeasurable f μ)
(hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) :
Integrable f μ ↔ Integrable g μ :=
⟨fun h2f => h2f.congr' hg h, fun h2g => h2g.congr' hf <| EventuallyEq.symm h⟩
#align measure_theory.integrable_congr' MeasureTheory.integrable_congr'
theorem Integrable.congr {f g : α → β} (hf : Integrable f μ) (h : f =ᵐ[μ] g) : Integrable g μ :=
⟨hf.1.congr h, hf.2.congr h⟩
#align measure_theory.integrable.congr MeasureTheory.Integrable.congr
theorem integrable_congr {f g : α → β} (h : f =ᵐ[μ] g) : Integrable f μ ↔ Integrable g μ :=
⟨fun hf => hf.congr h, fun hg => hg.congr h.symm⟩
#align measure_theory.integrable_congr MeasureTheory.integrable_congr
theorem integrable_const_iff {c : β} : Integrable (fun _ : α => c) μ ↔ c = 0 ∨ μ univ < ∞ := by
have : AEStronglyMeasurable (fun _ : α => c) μ := aestronglyMeasurable_const
rw [Integrable, and_iff_right this, hasFiniteIntegral_const_iff]
#align measure_theory.integrable_const_iff MeasureTheory.integrable_const_iff
@[simp]
theorem integrable_const [IsFiniteMeasure μ] (c : β) : Integrable (fun _ : α => c) μ :=
integrable_const_iff.2 <| Or.inr <| measure_lt_top _ _
#align measure_theory.integrable_const MeasureTheory.integrable_const
@[simp]
theorem Integrable.of_finite [Finite α] [MeasurableSpace α] [MeasurableSingletonClass α]
(μ : Measure α) [IsFiniteMeasure μ] (f : α → β) : Integrable (fun a ↦ f a) μ :=
⟨(StronglyMeasurable.of_finite f).aestronglyMeasurable, .of_finite⟩
@[deprecated (since := "2024-02-05")] alias integrable_of_fintype := Integrable.of_finite
theorem Memℒp.integrable_norm_rpow {f : α → β} {p : ℝ≥0∞} (hf : Memℒp f p μ) (hp_ne_zero : p ≠ 0)
(hp_ne_top : p ≠ ∞) : Integrable (fun x : α => ‖f x‖ ^ p.toReal) μ := by
rw [← memℒp_one_iff_integrable]
exact hf.norm_rpow hp_ne_zero hp_ne_top
#align measure_theory.mem_ℒp.integrable_norm_rpow MeasureTheory.Memℒp.integrable_norm_rpow
theorem Memℒp.integrable_norm_rpow' [IsFiniteMeasure μ] {f : α → β} {p : ℝ≥0∞} (hf : Memℒp f p μ) :
Integrable (fun x : α => ‖f x‖ ^ p.toReal) μ := by
by_cases h_zero : p = 0
· simp [h_zero, integrable_const]
by_cases h_top : p = ∞
· simp [h_top, integrable_const]
exact hf.integrable_norm_rpow h_zero h_top
#align measure_theory.mem_ℒp.integrable_norm_rpow' MeasureTheory.Memℒp.integrable_norm_rpow'
theorem Integrable.mono_measure {f : α → β} (h : Integrable f ν) (hμ : μ ≤ ν) : Integrable f μ :=
⟨h.aestronglyMeasurable.mono_measure hμ, h.hasFiniteIntegral.mono_measure hμ⟩
#align measure_theory.integrable.mono_measure MeasureTheory.Integrable.mono_measure
theorem Integrable.of_measure_le_smul {μ' : Measure α} (c : ℝ≥0∞) (hc : c ≠ ∞) (hμ'_le : μ' ≤ c • μ)
{f : α → β} (hf : Integrable f μ) : Integrable f μ' := by
rw [← memℒp_one_iff_integrable] at hf ⊢
exact hf.of_measure_le_smul c hc hμ'_le
#align measure_theory.integrable.of_measure_le_smul MeasureTheory.Integrable.of_measure_le_smul
theorem Integrable.add_measure {f : α → β} (hμ : Integrable f μ) (hν : Integrable f ν) :
Integrable f (μ + ν) := by
simp_rw [← memℒp_one_iff_integrable] at hμ hν ⊢
refine ⟨hμ.aestronglyMeasurable.add_measure hν.aestronglyMeasurable, ?_⟩
rw [snorm_one_add_measure, ENNReal.add_lt_top]
exact ⟨hμ.snorm_lt_top, hν.snorm_lt_top⟩
#align measure_theory.integrable.add_measure MeasureTheory.Integrable.add_measure
theorem Integrable.left_of_add_measure {f : α → β} (h : Integrable f (μ + ν)) : Integrable f μ := by
rw [← memℒp_one_iff_integrable] at h ⊢
exact h.left_of_add_measure
#align measure_theory.integrable.left_of_add_measure MeasureTheory.Integrable.left_of_add_measure
theorem Integrable.right_of_add_measure {f : α → β} (h : Integrable f (μ + ν)) :
Integrable f ν := by
rw [← memℒp_one_iff_integrable] at h ⊢
exact h.right_of_add_measure
#align measure_theory.integrable.right_of_add_measure MeasureTheory.Integrable.right_of_add_measure
@[simp]
theorem integrable_add_measure {f : α → β} :
Integrable f (μ + ν) ↔ Integrable f μ ∧ Integrable f ν :=
⟨fun h => ⟨h.left_of_add_measure, h.right_of_add_measure⟩, fun h => h.1.add_measure h.2⟩
#align measure_theory.integrable_add_measure MeasureTheory.integrable_add_measure
@[simp]
theorem integrable_zero_measure {_ : MeasurableSpace α} {f : α → β} :
Integrable f (0 : Measure α) :=
⟨aestronglyMeasurable_zero_measure f, hasFiniteIntegral_zero_measure f⟩
#align measure_theory.integrable_zero_measure MeasureTheory.integrable_zero_measure
theorem integrable_finset_sum_measure {ι} {m : MeasurableSpace α} {f : α → β} {μ : ι → Measure α}
{s : Finset ι} : Integrable f (∑ i ∈ s, μ i) ↔ ∀ i ∈ s, Integrable f (μ i) := by
induction s using Finset.induction_on <;> simp [*]
#align measure_theory.integrable_finset_sum_measure MeasureTheory.integrable_finset_sum_measure
theorem Integrable.smul_measure {f : α → β} (h : Integrable f μ) {c : ℝ≥0∞} (hc : c ≠ ∞) :
Integrable f (c • μ) := by
rw [← memℒp_one_iff_integrable] at h ⊢
exact h.smul_measure hc
#align measure_theory.integrable.smul_measure MeasureTheory.Integrable.smul_measure
| Mathlib/MeasureTheory/Function/L1Space.lean | 572 | 575 | theorem Integrable.smul_measure_nnreal {f : α → β} (h : Integrable f μ) {c : ℝ≥0} :
Integrable f (c • μ) := by |
apply h.smul_measure
simp
|
import Mathlib.FieldTheory.Finite.Polynomial
import Mathlib.NumberTheory.Basic
import Mathlib.RingTheory.WittVector.WittPolynomial
#align_import ring_theory.witt_vector.structure_polynomial from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
open MvPolynomial Set
open Finset (range)
open Finsupp (single)
-- This lemma reduces a bundled morphism to a "mere" function,
-- and consequently the simplifier cannot use a lot of powerful simp-lemmas.
-- We disable this locally, and probably it should be disabled globally in mathlib.
attribute [-simp] coe_eval₂Hom
variable {p : ℕ} {R : Type*} {idx : Type*} [CommRing R]
open scoped Witt
section PPrime
variable (p) [hp : Fact p.Prime]
-- Notation with ring of coefficients explicit
set_option quotPrecheck false in
@[inherit_doc]
scoped[Witt] notation "W_" => wittPolynomial p
-- Notation with ring of coefficients implicit
set_option quotPrecheck false in
@[inherit_doc]
scoped[Witt] notation "W" => wittPolynomial p _
noncomputable def wittStructureRat (Φ : MvPolynomial idx ℚ) (n : ℕ) : MvPolynomial (idx × ℕ) ℚ :=
bind₁ (fun k => bind₁ (fun i => rename (Prod.mk i) (W_ ℚ k)) Φ) (xInTermsOfW p ℚ n)
#align witt_structure_rat wittStructureRat
theorem wittStructureRat_prop (Φ : MvPolynomial idx ℚ) (n : ℕ) :
bind₁ (wittStructureRat p Φ) (W_ ℚ n) = bind₁ (fun i => rename (Prod.mk i) (W_ ℚ n)) Φ :=
calc
bind₁ (wittStructureRat p Φ) (W_ ℚ n) =
bind₁ (fun k => bind₁ (fun i => (rename (Prod.mk i)) (W_ ℚ k)) Φ)
(bind₁ (xInTermsOfW p ℚ) (W_ ℚ n)) := by
rw [bind₁_bind₁]; exact eval₂Hom_congr (RingHom.ext_rat _ _) rfl rfl
_ = bind₁ (fun i => rename (Prod.mk i) (W_ ℚ n)) Φ := by
rw [bind₁_xInTermsOfW_wittPolynomial p _ n, bind₁_X_right]
#align witt_structure_rat_prop wittStructureRat_prop
theorem wittStructureRat_existsUnique (Φ : MvPolynomial idx ℚ) :
∃! φ : ℕ → MvPolynomial (idx × ℕ) ℚ,
∀ n : ℕ, bind₁ φ (W_ ℚ n) = bind₁ (fun i => rename (Prod.mk i) (W_ ℚ n)) Φ := by
refine ⟨wittStructureRat p Φ, ?_, ?_⟩
· intro n; apply wittStructureRat_prop
· intro φ H
funext n
rw [show φ n = bind₁ φ (bind₁ (W_ ℚ) (xInTermsOfW p ℚ n)) by
rw [bind₁_wittPolynomial_xInTermsOfW p, bind₁_X_right]]
rw [bind₁_bind₁]
exact eval₂Hom_congr (RingHom.ext_rat _ _) (funext H) rfl
#align witt_structure_rat_exists_unique wittStructureRat_existsUnique
theorem wittStructureRat_rec_aux (Φ : MvPolynomial idx ℚ) (n : ℕ) :
wittStructureRat p Φ n * C ((p : ℚ) ^ n) =
bind₁ (fun b => rename (fun i => (b, i)) (W_ ℚ n)) Φ -
∑ i ∈ range n, C ((p : ℚ) ^ i) * wittStructureRat p Φ i ^ p ^ (n - i) := by
have := xInTermsOfW_aux p ℚ n
replace := congr_arg (bind₁ fun k : ℕ => bind₁ (fun i => rename (Prod.mk i) (W_ ℚ k)) Φ) this
rw [AlgHom.map_mul, bind₁_C_right] at this
rw [wittStructureRat, this]; clear this
conv_lhs => simp only [AlgHom.map_sub, bind₁_X_right]
rw [sub_right_inj]
simp only [AlgHom.map_sum, AlgHom.map_mul, bind₁_C_right, AlgHom.map_pow]
rfl
#align witt_structure_rat_rec_aux wittStructureRat_rec_aux
theorem wittStructureRat_rec (Φ : MvPolynomial idx ℚ) (n : ℕ) :
wittStructureRat p Φ n =
C (1 / (p : ℚ) ^ n) *
(bind₁ (fun b => rename (fun i => (b, i)) (W_ ℚ n)) Φ -
∑ i ∈ range n, C ((p : ℚ) ^ i) * wittStructureRat p Φ i ^ p ^ (n - i)) := by
calc
wittStructureRat p Φ n = C (1 / (p : ℚ) ^ n) * (wittStructureRat p Φ n * C ((p : ℚ) ^ n)) := ?_
_ = _ := by rw [wittStructureRat_rec_aux]
rw [mul_left_comm, ← C_mul, div_mul_cancel₀, C_1, mul_one]
exact pow_ne_zero _ (Nat.cast_ne_zero.2 hp.1.ne_zero)
#align witt_structure_rat_rec wittStructureRat_rec
noncomputable def wittStructureInt (Φ : MvPolynomial idx ℤ) (n : ℕ) : MvPolynomial (idx × ℕ) ℤ :=
Finsupp.mapRange Rat.num (Rat.num_intCast 0) (wittStructureRat p (map (Int.castRingHom ℚ) Φ) n)
#align witt_structure_int wittStructureInt
variable {p}
theorem bind₁_rename_expand_wittPolynomial (Φ : MvPolynomial idx ℤ) (n : ℕ)
(IH :
∀ m : ℕ,
m < n + 1 →
map (Int.castRingHom ℚ) (wittStructureInt p Φ m) =
wittStructureRat p (map (Int.castRingHom ℚ) Φ) m) :
bind₁ (fun b => rename (fun i => (b, i)) (expand p (W_ ℤ n))) Φ =
bind₁ (fun i => expand p (wittStructureInt p Φ i)) (W_ ℤ n) := by
apply MvPolynomial.map_injective (Int.castRingHom ℚ) Int.cast_injective
simp only [map_bind₁, map_rename, map_expand, rename_expand, map_wittPolynomial]
have key := (wittStructureRat_prop p (map (Int.castRingHom ℚ) Φ) n).symm
apply_fun expand p at key
simp only [expand_bind₁] at key
rw [key]; clear key
apply eval₂Hom_congr' rfl _ rfl
rintro i hi -
rw [wittPolynomial_vars, Finset.mem_range] at hi
simp only [IH i hi]
#align bind₁_rename_expand_witt_polynomial bind₁_rename_expand_wittPolynomial
theorem C_p_pow_dvd_bind₁_rename_wittPolynomial_sub_sum (Φ : MvPolynomial idx ℤ) (n : ℕ)
(IH :
∀ m : ℕ,
m < n →
map (Int.castRingHom ℚ) (wittStructureInt p Φ m) =
wittStructureRat p (map (Int.castRingHom ℚ) Φ) m) :
(C ((p ^ n :) : ℤ) : MvPolynomial (idx × ℕ) ℤ) ∣
bind₁ (fun b : idx => rename (fun i => (b, i)) (wittPolynomial p ℤ n)) Φ -
∑ i ∈ range n, C ((p : ℤ) ^ i) * wittStructureInt p Φ i ^ p ^ (n - i) := by
cases' n with n
· simp only [isUnit_one, Int.ofNat_zero, Int.ofNat_succ, zero_add, pow_zero, C_1, IsUnit.dvd,
Nat.cast_one, Nat.zero_eq]
-- prepare a useful equation for rewriting
have key := bind₁_rename_expand_wittPolynomial Φ n IH
apply_fun map (Int.castRingHom (ZMod (p ^ (n + 1)))) at key
conv_lhs at key => simp only [map_bind₁, map_rename, map_expand, map_wittPolynomial]
-- clean up and massage
rw [C_dvd_iff_zmod, RingHom.map_sub, sub_eq_zero, map_bind₁]
simp only [map_rename, map_wittPolynomial, wittPolynomial_zmod_self]
rw [key]; clear key IH
rw [bind₁, aeval_wittPolynomial, map_sum, map_sum, Finset.sum_congr rfl]
intro k hk
rw [Finset.mem_range, Nat.lt_succ_iff] at hk
-- Porting note (#11083): was much slower
-- simp only [← sub_eq_zero, ← RingHom.map_sub, ← C_dvd_iff_zmod, C_eq_coe_nat, ← mul_sub, ←
-- Nat.cast_pow]
rw [← sub_eq_zero, ← RingHom.map_sub, ← C_dvd_iff_zmod, C_eq_coe_nat, ← Nat.cast_pow,
← Nat.cast_pow, C_eq_coe_nat, ← mul_sub]
have : p ^ (n + 1) = p ^ k * p ^ (n - k + 1) := by
rw [← pow_add, ← add_assoc]; congr 2; rw [add_comm, ← tsub_eq_iff_eq_add_of_le hk]
rw [this]
rw [Nat.cast_mul, Nat.cast_pow, Nat.cast_pow]
apply mul_dvd_mul_left ((p : MvPolynomial (idx × ℕ) ℤ) ^ k)
rw [show p ^ (n + 1 - k) = p * p ^ (n - k) by rw [← pow_succ', ← tsub_add_eq_add_tsub hk]]
rw [pow_mul]
-- the machine!
apply dvd_sub_pow_of_dvd_sub
rw [← C_eq_coe_nat, C_dvd_iff_zmod, RingHom.map_sub, sub_eq_zero, map_expand, RingHom.map_pow,
MvPolynomial.expand_zmod]
set_option linter.uppercaseLean3 false in
#align C_p_pow_dvd_bind₁_rename_witt_polynomial_sub_sum C_p_pow_dvd_bind₁_rename_wittPolynomial_sub_sum
variable (p)
@[simp]
theorem map_wittStructureInt (Φ : MvPolynomial idx ℤ) (n : ℕ) :
map (Int.castRingHom ℚ) (wittStructureInt p Φ n) =
wittStructureRat p (map (Int.castRingHom ℚ) Φ) n := by
induction n using Nat.strong_induction_on with | h n IH => ?_
rw [wittStructureInt, map_mapRange_eq_iff, Int.coe_castRingHom]
intro c
rw [wittStructureRat_rec, coeff_C_mul, mul_comm, mul_div_assoc', mul_one]
have sum_induction_steps :
map (Int.castRingHom ℚ)
(∑ i ∈ range n, C ((p : ℤ) ^ i) * wittStructureInt p Φ i ^ p ^ (n - i)) =
∑ i ∈ range n,
C ((p : ℚ) ^ i) * wittStructureRat p (map (Int.castRingHom ℚ) Φ) i ^ p ^ (n - i) := by
rw [map_sum]
apply Finset.sum_congr rfl
intro i hi
rw [Finset.mem_range] at hi
simp only [IH i hi, RingHom.map_mul, RingHom.map_pow, map_C]
rfl
simp only [← sum_induction_steps, ← map_wittPolynomial p (Int.castRingHom ℚ), ← map_rename, ←
map_bind₁, ← RingHom.map_sub, coeff_map]
rw [show (p : ℚ) ^ n = ((↑(p ^ n) : ℤ) : ℚ) by norm_cast]
rw [← Rat.den_eq_one_iff, eq_intCast, Rat.den_div_intCast_eq_one_iff]
swap; · exact mod_cast pow_ne_zero n hp.1.ne_zero
revert c; rw [← C_dvd_iff_dvd_coeff]
exact C_p_pow_dvd_bind₁_rename_wittPolynomial_sub_sum Φ n IH
#align map_witt_structure_int map_wittStructureInt
theorem wittStructureInt_prop (Φ : MvPolynomial idx ℤ) (n) :
bind₁ (wittStructureInt p Φ) (wittPolynomial p ℤ n) =
bind₁ (fun i => rename (Prod.mk i) (W_ ℤ n)) Φ := by
apply MvPolynomial.map_injective (Int.castRingHom ℚ) Int.cast_injective
have := wittStructureRat_prop p (map (Int.castRingHom ℚ) Φ) n
simpa only [map_bind₁, ← eval₂Hom_map_hom, eval₂Hom_C_left, map_rename, map_wittPolynomial,
AlgHom.coe_toRingHom, map_wittStructureInt]
#align witt_structure_int_prop wittStructureInt_prop
theorem eq_wittStructureInt (Φ : MvPolynomial idx ℤ) (φ : ℕ → MvPolynomial (idx × ℕ) ℤ)
(h : ∀ n, bind₁ φ (wittPolynomial p ℤ n) = bind₁ (fun i => rename (Prod.mk i) (W_ ℤ n)) Φ) :
φ = wittStructureInt p Φ := by
funext k
apply MvPolynomial.map_injective (Int.castRingHom ℚ) Int.cast_injective
rw [map_wittStructureInt]
-- Porting note: was `refine' congr_fun _ k`
revert k
refine congr_fun ?_
apply ExistsUnique.unique (wittStructureRat_existsUnique p (map (Int.castRingHom ℚ) Φ))
· intro n
specialize h n
apply_fun map (Int.castRingHom ℚ) at h
simpa only [map_bind₁, ← eval₂Hom_map_hom, eval₂Hom_C_left, map_rename, map_wittPolynomial,
AlgHom.coe_toRingHom] using h
· intro n; apply wittStructureRat_prop
#align eq_witt_structure_int eq_wittStructureInt
theorem wittStructureInt_existsUnique (Φ : MvPolynomial idx ℤ) :
∃! φ : ℕ → MvPolynomial (idx × ℕ) ℤ,
∀ n : ℕ,
bind₁ φ (wittPolynomial p ℤ n) = bind₁ (fun i : idx => rename (Prod.mk i) (W_ ℤ n)) Φ :=
⟨wittStructureInt p Φ, wittStructureInt_prop _ _, eq_wittStructureInt _ _⟩
#align witt_structure_int_exists_unique wittStructureInt_existsUnique
theorem witt_structure_prop (Φ : MvPolynomial idx ℤ) (n) :
aeval (fun i => map (Int.castRingHom R) (wittStructureInt p Φ i)) (wittPolynomial p ℤ n) =
aeval (fun i => rename (Prod.mk i) (W n)) Φ := by
convert congr_arg (map (Int.castRingHom R)) (wittStructureInt_prop p Φ n) using 1 <;>
rw [hom_bind₁] <;>
apply eval₂Hom_congr (RingHom.ext_int _ _) _ rfl
· rfl
· simp only [map_rename, map_wittPolynomial]
#align witt_structure_prop witt_structure_prop
theorem wittStructureInt_rename {σ : Type*} (Φ : MvPolynomial idx ℤ) (f : idx → σ) (n : ℕ) :
wittStructureInt p (rename f Φ) n = rename (Prod.map f id) (wittStructureInt p Φ n) := by
apply MvPolynomial.map_injective (Int.castRingHom ℚ) Int.cast_injective
simp only [map_rename, map_wittStructureInt, wittStructureRat, rename_bind₁, rename_rename,
bind₁_rename]
rfl
#align witt_structure_int_rename wittStructureInt_rename
@[simp]
theorem constantCoeff_wittStructureRat_zero (Φ : MvPolynomial idx ℚ) :
constantCoeff (wittStructureRat p Φ 0) = constantCoeff Φ := by
simp only [wittStructureRat, bind₁, map_aeval, xInTermsOfW_zero, constantCoeff_rename,
constantCoeff_wittPolynomial, aeval_X, constantCoeff_comp_algebraMap, eval₂Hom_zero'_apply,
RingHom.id_apply]
#align constant_coeff_witt_structure_rat_zero constantCoeff_wittStructureRat_zero
theorem constantCoeff_wittStructureRat (Φ : MvPolynomial idx ℚ) (h : constantCoeff Φ = 0) (n : ℕ) :
constantCoeff (wittStructureRat p Φ n) = 0 := by
simp only [wittStructureRat, eval₂Hom_zero'_apply, h, bind₁, map_aeval, constantCoeff_rename,
constantCoeff_wittPolynomial, constantCoeff_comp_algebraMap, RingHom.id_apply,
constantCoeff_xInTermsOfW]
#align constant_coeff_witt_structure_rat constantCoeff_wittStructureRat
@[simp]
theorem constantCoeff_wittStructureInt_zero (Φ : MvPolynomial idx ℤ) :
constantCoeff (wittStructureInt p Φ 0) = constantCoeff Φ := by
have inj : Function.Injective (Int.castRingHom ℚ) := by intro m n; exact Int.cast_inj.mp
apply inj
rw [← constantCoeff_map, map_wittStructureInt, constantCoeff_wittStructureRat_zero,
constantCoeff_map]
#align constant_coeff_witt_structure_int_zero constantCoeff_wittStructureInt_zero
theorem constantCoeff_wittStructureInt (Φ : MvPolynomial idx ℤ) (h : constantCoeff Φ = 0) (n : ℕ) :
constantCoeff (wittStructureInt p Φ n) = 0 := by
have inj : Function.Injective (Int.castRingHom ℚ) := by intro m n; exact Int.cast_inj.mp
apply inj
rw [← constantCoeff_map, map_wittStructureInt, constantCoeff_wittStructureRat, RingHom.map_zero]
rw [constantCoeff_map, h, RingHom.map_zero]
#align constant_coeff_witt_structure_int constantCoeff_wittStructureInt
variable (R)
-- we could relax the fintype on `idx`, but then we need to cast from finset to set.
-- for our applications `idx` is always finite.
| Mathlib/RingTheory/WittVector/StructurePolynomial.lean | 389 | 400 | theorem wittStructureRat_vars [Fintype idx] (Φ : MvPolynomial idx ℚ) (n : ℕ) :
(wittStructureRat p Φ n).vars ⊆ Finset.univ ×ˢ Finset.range (n + 1) := by |
rw [wittStructureRat]
intro x hx
simp only [Finset.mem_product, true_and_iff, Finset.mem_univ, Finset.mem_range]
obtain ⟨k, hk, hx'⟩ := mem_vars_bind₁ _ _ hx
obtain ⟨i, -, hx''⟩ := mem_vars_bind₁ _ _ hx'
obtain ⟨j, hj, rfl⟩ := mem_vars_rename _ _ hx''
rw [wittPolynomial_vars, Finset.mem_range] at hj
replace hk := xInTermsOfW_vars_subset p _ hk
rw [Finset.mem_range] at hk
exact lt_of_lt_of_le hj hk
|
import Mathlib.CategoryTheory.Limits.Shapes.SplitCoequalizer
import Mathlib.CategoryTheory.Limits.Preserves.Basic
#align_import category_theory.limits.preserves.shapes.equalizers from "leanprover-community/mathlib"@"4698e35ca56a0d4fa53aa5639c3364e0a77f4eba"
noncomputable section
universe w v₁ v₂ u₁ u₂
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
variable {C : Type u₁} [Category.{v₁} C]
variable {D : Type u₂} [Category.{v₂} D]
variable (G : C ⥤ D)
namespace CategoryTheory.Limits
section Coequalizers
variable {X Y Z : C} {f g : X ⟶ Y} {h : Y ⟶ Z} (w : f ≫ h = g ≫ h)
def isColimitMapCoconeCoforkEquiv :
IsColimit (G.mapCocone (Cofork.ofπ h w)) ≃
IsColimit
(Cofork.ofπ (G.map h) (by simp only [← G.map_comp, w]) : Cofork (G.map f) (G.map g)) :=
(IsColimit.precomposeInvEquiv (diagramIsoParallelPair _) _).symm.trans <|
IsColimit.equivIsoColimit <|
Cofork.ext (Iso.refl _) <| by
dsimp only [Cofork.π, Cofork.ofπ_ι_app]
dsimp; rw [Category.comp_id, Category.id_comp]
#align category_theory.limits.is_colimit_map_cocone_cofork_equiv CategoryTheory.Limits.isColimitMapCoconeCoforkEquiv
def isColimitCoforkMapOfIsColimit [PreservesColimit (parallelPair f g) G]
(l : IsColimit (Cofork.ofπ h w)) :
IsColimit
(Cofork.ofπ (G.map h) (by simp only [← G.map_comp, w]) : Cofork (G.map f) (G.map g)) :=
isColimitMapCoconeCoforkEquiv G w (PreservesColimit.preserves l)
#align category_theory.limits.is_colimit_cofork_map_of_is_colimit CategoryTheory.Limits.isColimitCoforkMapOfIsColimit
def isColimitOfIsColimitCoforkMap [ReflectsColimit (parallelPair f g) G]
(l :
IsColimit
(Cofork.ofπ (G.map h) (by simp only [← G.map_comp, w]) : Cofork (G.map f) (G.map g))) :
IsColimit (Cofork.ofπ h w) :=
ReflectsColimit.reflects ((isColimitMapCoconeCoforkEquiv G w).symm l)
#align category_theory.limits.is_colimit_of_is_colimit_cofork_map CategoryTheory.Limits.isColimitOfIsColimitCoforkMap
variable (f g) [HasCoequalizer f g]
def isColimitOfHasCoequalizerOfPreservesColimit [PreservesColimit (parallelPair f g) G] :
IsColimit (Cofork.ofπ (G.map (coequalizer.π f g)) (by
simp only [← G.map_comp]; rw [coequalizer.condition]) : Cofork (G.map f) (G.map g)) :=
isColimitCoforkMapOfIsColimit G _ (coequalizerIsCoequalizer f g)
#align category_theory.limits.is_colimit_of_has_coequalizer_of_preserves_colimit CategoryTheory.Limits.isColimitOfHasCoequalizerOfPreservesColimit
variable [HasCoequalizer (G.map f) (G.map g)]
def ofIsoComparison [i : IsIso (coequalizerComparison f g G)] :
PreservesColimit (parallelPair f g) G := by
apply preservesColimitOfPreservesColimitCocone (coequalizerIsCoequalizer f g)
apply (isColimitMapCoconeCoforkEquiv _ _).symm _
refine
@IsColimit.ofPointIso _ _ _ _ _ _ _ (colimit.isColimit (parallelPair (G.map f) (G.map g))) ?_
apply i
#align category_theory.limits.of_iso_comparison CategoryTheory.Limits.ofIsoComparison
variable [PreservesColimit (parallelPair f g) G]
def PreservesCoequalizer.iso : coequalizer (G.map f) (G.map g) ≅ G.obj (coequalizer f g) :=
IsColimit.coconePointUniqueUpToIso (colimit.isColimit _)
(isColimitOfHasCoequalizerOfPreservesColimit G f g)
#align category_theory.limits.preserves_coequalizer.iso CategoryTheory.Limits.PreservesCoequalizer.iso
@[simp]
theorem PreservesCoequalizer.iso_hom :
(PreservesCoequalizer.iso G f g).hom = coequalizerComparison f g G :=
rfl
#align category_theory.limits.preserves_coequalizer.iso_hom CategoryTheory.Limits.PreservesCoequalizer.iso_hom
instance : IsIso (coequalizerComparison f g G) := by
rw [← PreservesCoequalizer.iso_hom]
infer_instance
instance map_π_epi : Epi (G.map (coequalizer.π f g)) :=
⟨fun {W} h k => by
rw [← ι_comp_coequalizerComparison]
haveI : Epi (coequalizer.π (G.map f) (G.map g) ≫ coequalizerComparison f g G) := by
apply epi_comp
apply (cancel_epi _).1⟩
#align category_theory.limits.map_π_epi CategoryTheory.Limits.map_π_epi
@[reassoc]
| Mathlib/CategoryTheory/Limits/Preserves/Shapes/Equalizers.lean | 207 | 211 | theorem map_π_preserves_coequalizer_inv :
G.map (coequalizer.π f g) ≫ (PreservesCoequalizer.iso G f g).inv =
coequalizer.π (G.map f) (G.map g) := by |
rw [← ι_comp_coequalizerComparison_assoc, ← PreservesCoequalizer.iso_hom, Iso.hom_inv_id,
comp_id]
|
import Mathlib.Analysis.PSeries
import Mathlib.Data.Real.Pi.Wallis
import Mathlib.Tactic.AdaptationNote
#align_import analysis.special_functions.stirling from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
open scoped Topology Real Nat Asymptotics
open Finset Filter Nat Real
namespace Stirling
noncomputable def stirlingSeq (n : ℕ) : ℝ :=
n ! / (√(2 * n : ℝ) * (n / exp 1) ^ n)
#align stirling.stirling_seq Stirling.stirlingSeq
@[simp]
theorem stirlingSeq_zero : stirlingSeq 0 = 0 := by
rw [stirlingSeq, cast_zero, mul_zero, Real.sqrt_zero, zero_mul, div_zero]
#align stirling.stirling_seq_zero Stirling.stirlingSeq_zero
@[simp]
theorem stirlingSeq_one : stirlingSeq 1 = exp 1 / √2 := by
rw [stirlingSeq, pow_one, factorial_one, cast_one, mul_one, mul_one_div, one_div_div]
#align stirling.stirling_seq_one Stirling.stirlingSeq_one
theorem log_stirlingSeq_formula (n : ℕ) :
log (stirlingSeq n) = Real.log n ! - 1 / 2 * Real.log (2 * n) - n * log (n / exp 1) := by
cases n
· simp
· rw [stirlingSeq, log_div, log_mul, sqrt_eq_rpow, log_rpow, Real.log_pow, tsub_tsub]
<;> positivity
-- Porting note: generalized from `n.succ` to `n`
#align stirling.log_stirling_seq_formula Stirling.log_stirlingSeq_formulaₓ
theorem log_stirlingSeq_diff_hasSum (m : ℕ) :
HasSum (fun k : ℕ => (1 : ℝ) / (2 * ↑(k + 1) + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ ↑(k + 1))
(log (stirlingSeq (m + 1)) - log (stirlingSeq (m + 2))) := by
let f (k : ℕ) := (1 : ℝ) / (2 * k + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ k
change HasSum (fun k => f (k + 1)) _
rw [hasSum_nat_add_iff]
convert (hasSum_log_one_add_inv m.cast_add_one_pos).mul_left ((↑(m + 1) : ℝ) + 1 / 2) using 1
· ext k
dsimp only [f]
rw [← pow_mul, pow_add]
push_cast
field_simp
ring
· have h : ∀ x ≠ (0 : ℝ), 1 + x⁻¹ = (x + 1) / x := fun x hx ↦ by field_simp [hx]
simp (disch := positivity) only [log_stirlingSeq_formula, log_div, log_mul, log_exp,
factorial_succ, cast_mul, cast_succ, cast_zero, range_one, sum_singleton, h]
ring
#align stirling.log_stirling_seq_diff_has_sum Stirling.log_stirlingSeq_diff_hasSum
theorem log_stirlingSeq'_antitone : Antitone (Real.log ∘ stirlingSeq ∘ succ) :=
antitone_nat_of_succ_le fun n =>
sub_nonneg.mp <| (log_stirlingSeq_diff_hasSum n).nonneg fun m => by positivity
#align stirling.log_stirling_seq'_antitone Stirling.log_stirlingSeq'_antitone
| Mathlib/Analysis/SpecialFunctions/Stirling.lean | 104 | 120 | theorem log_stirlingSeq_diff_le_geo_sum (n : ℕ) :
log (stirlingSeq (n + 1)) - log (stirlingSeq (n + 2)) ≤
((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2 / (1 - ((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2) := by |
have h_nonneg : (0 : ℝ) ≤ ((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2 := sq_nonneg _
have g : HasSum (fun k : ℕ => (((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2) ^ ↑(k + 1))
(((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2 / (1 - ((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2)) := by
have := (hasSum_geometric_of_lt_one h_nonneg ?_).mul_left (((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2)
· simp_rw [← _root_.pow_succ'] at this
exact this
rw [one_div, inv_pow]
exact inv_lt_one (one_lt_pow ((lt_add_iff_pos_left 1).mpr <| by positivity) two_ne_zero)
have hab (k : ℕ) : (1 : ℝ) / (2 * ↑(k + 1) + 1) * ((1 / (2 * ↑(n + 1) + 1)) ^ 2) ^ ↑(k + 1) ≤
(((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2) ^ ↑(k + 1) := by
refine mul_le_of_le_one_left (pow_nonneg h_nonneg ↑(k + 1)) ?_
rw [one_div]
exact inv_le_one (le_add_of_nonneg_left <| by positivity)
exact hasSum_le hab (log_stirlingSeq_diff_hasSum n) g
|
import Mathlib.MeasureTheory.OuterMeasure.Caratheodory
#align_import measure_theory.measure.outer_measure from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
noncomputable section
open Set Function Filter
open scoped Classical NNReal Topology ENNReal
namespace MeasureTheory
open OuterMeasure
section Extend
variable {α : Type*} {P : α → Prop}
variable (m : ∀ s : α, P s → ℝ≥0∞)
def extend (s : α) : ℝ≥0∞ :=
⨅ h : P s, m s h
#align measure_theory.extend MeasureTheory.extend
theorem extend_eq {s : α} (h : P s) : extend m s = m s h := by simp [extend, h]
#align measure_theory.extend_eq MeasureTheory.extend_eq
theorem extend_eq_top {s : α} (h : ¬P s) : extend m s = ∞ := by simp [extend, h]
#align measure_theory.extend_eq_top MeasureTheory.extend_eq_top
theorem smul_extend {R} [Zero R] [SMulWithZero R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
[NoZeroSMulDivisors R ℝ≥0∞] {c : R} (hc : c ≠ 0) :
c • extend m = extend fun s h => c • m s h := by
ext1 s
dsimp [extend]
by_cases h : P s
· simp [h]
· simp [h, ENNReal.smul_top, hc]
#align measure_theory.smul_extend MeasureTheory.smul_extend
| Mathlib/MeasureTheory/OuterMeasure/Induced.lean | 65 | 68 | theorem le_extend {s : α} (h : P s) : m s h ≤ extend m s := by |
simp only [extend, le_iInf_iff]
intro
rfl
|
import Batteries.Control.ForInStep.Lemmas
import Batteries.Data.List.Basic
import Batteries.Tactic.Init
import Batteries.Tactic.Alias
namespace List
open Nat
@[simp] theorem mem_toArray {a : α} {l : List α} : a ∈ l.toArray ↔ a ∈ l := by
simp [Array.mem_def]
@[simp]
theorem drop_one : ∀ l : List α, drop 1 l = tail l
| [] | _ :: _ => rfl
theorem zipWith_distrib_tail : (zipWith f l l').tail = zipWith f l.tail l'.tail := by
rw [← drop_one]; simp [zipWith_distrib_drop]
theorem subset_def {l₁ l₂ : List α} : l₁ ⊆ l₂ ↔ ∀ {a : α}, a ∈ l₁ → a ∈ l₂ := .rfl
@[simp] theorem nil_subset (l : List α) : [] ⊆ l := nofun
@[simp] theorem Subset.refl (l : List α) : l ⊆ l := fun _ i => i
theorem Subset.trans {l₁ l₂ l₃ : List α} (h₁ : l₁ ⊆ l₂) (h₂ : l₂ ⊆ l₃) : l₁ ⊆ l₃ :=
fun _ i => h₂ (h₁ i)
instance : Trans (Membership.mem : α → List α → Prop) Subset Membership.mem :=
⟨fun h₁ h₂ => h₂ h₁⟩
instance : Trans (Subset : List α → List α → Prop) Subset Subset :=
⟨Subset.trans⟩
@[simp] theorem subset_cons (a : α) (l : List α) : l ⊆ a :: l := fun _ => Mem.tail _
theorem subset_of_cons_subset {a : α} {l₁ l₂ : List α} : a :: l₁ ⊆ l₂ → l₁ ⊆ l₂ :=
fun s _ i => s (mem_cons_of_mem _ i)
theorem subset_cons_of_subset (a : α) {l₁ l₂ : List α} : l₁ ⊆ l₂ → l₁ ⊆ a :: l₂ :=
fun s _ i => .tail _ (s i)
theorem cons_subset_cons {l₁ l₂ : List α} (a : α) (s : l₁ ⊆ l₂) : a :: l₁ ⊆ a :: l₂ :=
fun _ => by simp only [mem_cons]; exact Or.imp_right (@s _)
@[simp] theorem subset_append_left (l₁ l₂ : List α) : l₁ ⊆ l₁ ++ l₂ := fun _ => mem_append_left _
@[simp] theorem subset_append_right (l₁ l₂ : List α) : l₂ ⊆ l₁ ++ l₂ := fun _ => mem_append_right _
theorem subset_append_of_subset_left (l₂ : List α) : l ⊆ l₁ → l ⊆ l₁ ++ l₂ :=
fun s => Subset.trans s <| subset_append_left _ _
theorem subset_append_of_subset_right (l₁ : List α) : l ⊆ l₂ → l ⊆ l₁ ++ l₂ :=
fun s => Subset.trans s <| subset_append_right _ _
@[simp] theorem cons_subset : a :: l ⊆ m ↔ a ∈ m ∧ l ⊆ m := by
simp only [subset_def, mem_cons, or_imp, forall_and, forall_eq]
@[simp] theorem append_subset {l₁ l₂ l : List α} :
l₁ ++ l₂ ⊆ l ↔ l₁ ⊆ l ∧ l₂ ⊆ l := by simp [subset_def, or_imp, forall_and]
theorem subset_nil {l : List α} : l ⊆ [] ↔ l = [] :=
⟨fun h => match l with | [] => rfl | _::_ => (nomatch h (.head ..)), fun | rfl => Subset.refl _⟩
theorem map_subset {l₁ l₂ : List α} (f : α → β) (H : l₁ ⊆ l₂) : map f l₁ ⊆ map f l₂ :=
fun x => by simp only [mem_map]; exact .imp fun a => .imp_left (@H _)
@[simp] theorem nil_sublist : ∀ l : List α, [] <+ l
| [] => .slnil
| a :: l => (nil_sublist l).cons a
@[simp] theorem Sublist.refl : ∀ l : List α, l <+ l
| [] => .slnil
| a :: l => (Sublist.refl l).cons₂ a
theorem Sublist.trans {l₁ l₂ l₃ : List α} (h₁ : l₁ <+ l₂) (h₂ : l₂ <+ l₃) : l₁ <+ l₃ := by
induction h₂ generalizing l₁ with
| slnil => exact h₁
| cons _ _ IH => exact (IH h₁).cons _
| @cons₂ l₂ _ a _ IH =>
generalize e : a :: l₂ = l₂'
match e ▸ h₁ with
| .slnil => apply nil_sublist
| .cons a' h₁' => cases e; apply (IH h₁').cons
| .cons₂ a' h₁' => cases e; apply (IH h₁').cons₂
instance : Trans (@Sublist α) Sublist Sublist := ⟨Sublist.trans⟩
@[simp] theorem sublist_cons (a : α) (l : List α) : l <+ a :: l := (Sublist.refl l).cons _
theorem sublist_of_cons_sublist : a :: l₁ <+ l₂ → l₁ <+ l₂ :=
(sublist_cons a l₁).trans
@[simp] theorem sublist_append_left : ∀ l₁ l₂ : List α, l₁ <+ l₁ ++ l₂
| [], _ => nil_sublist _
| _ :: l₁, l₂ => (sublist_append_left l₁ l₂).cons₂ _
@[simp] theorem sublist_append_right : ∀ l₁ l₂ : List α, l₂ <+ l₁ ++ l₂
| [], _ => Sublist.refl _
| _ :: l₁, l₂ => (sublist_append_right l₁ l₂).cons _
theorem sublist_append_of_sublist_left (s : l <+ l₁) : l <+ l₁ ++ l₂ :=
s.trans <| sublist_append_left ..
theorem sublist_append_of_sublist_right (s : l <+ l₂) : l <+ l₁ ++ l₂ :=
s.trans <| sublist_append_right ..
@[simp]
theorem cons_sublist_cons : a :: l₁ <+ a :: l₂ ↔ l₁ <+ l₂ :=
⟨fun | .cons _ s => sublist_of_cons_sublist s | .cons₂ _ s => s, .cons₂ _⟩
@[simp] theorem append_sublist_append_left : ∀ l, l ++ l₁ <+ l ++ l₂ ↔ l₁ <+ l₂
| [] => Iff.rfl
| _ :: l => cons_sublist_cons.trans (append_sublist_append_left l)
theorem Sublist.append_left : l₁ <+ l₂ → ∀ l, l ++ l₁ <+ l ++ l₂ :=
fun h l => (append_sublist_append_left l).mpr h
theorem Sublist.append_right : l₁ <+ l₂ → ∀ l, l₁ ++ l <+ l₂ ++ l
| .slnil, _ => Sublist.refl _
| .cons _ h, _ => (h.append_right _).cons _
| .cons₂ _ h, _ => (h.append_right _).cons₂ _
theorem sublist_or_mem_of_sublist (h : l <+ l₁ ++ a :: l₂) : l <+ l₁ ++ l₂ ∨ a ∈ l := by
induction l₁ generalizing l with
| nil => match h with
| .cons _ h => exact .inl h
| .cons₂ _ h => exact .inr (.head ..)
| cons b l₁ IH =>
match h with
| .cons _ h => exact (IH h).imp_left (Sublist.cons _)
| .cons₂ _ h => exact (IH h).imp (Sublist.cons₂ _) (.tail _)
theorem Sublist.reverse : l₁ <+ l₂ → l₁.reverse <+ l₂.reverse
| .slnil => Sublist.refl _
| .cons _ h => by rw [reverse_cons]; exact sublist_append_of_sublist_left h.reverse
| .cons₂ _ h => by rw [reverse_cons, reverse_cons]; exact h.reverse.append_right _
@[simp] theorem reverse_sublist : l₁.reverse <+ l₂.reverse ↔ l₁ <+ l₂ :=
⟨fun h => l₁.reverse_reverse ▸ l₂.reverse_reverse ▸ h.reverse, Sublist.reverse⟩
@[simp] theorem append_sublist_append_right (l) : l₁ ++ l <+ l₂ ++ l ↔ l₁ <+ l₂ :=
⟨fun h => by
have := h.reverse
simp only [reverse_append, append_sublist_append_left, reverse_sublist] at this
exact this,
fun h => h.append_right l⟩
theorem Sublist.append (hl : l₁ <+ l₂) (hr : r₁ <+ r₂) : l₁ ++ r₁ <+ l₂ ++ r₂ :=
(hl.append_right _).trans ((append_sublist_append_left _).2 hr)
theorem Sublist.subset : l₁ <+ l₂ → l₁ ⊆ l₂
| .slnil, _, h => h
| .cons _ s, _, h => .tail _ (s.subset h)
| .cons₂ .., _, .head .. => .head ..
| .cons₂ _ s, _, .tail _ h => .tail _ (s.subset h)
instance : Trans (@Sublist α) Subset Subset :=
⟨fun h₁ h₂ => trans h₁.subset h₂⟩
instance : Trans Subset (@Sublist α) Subset :=
⟨fun h₁ h₂ => trans h₁ h₂.subset⟩
instance : Trans (Membership.mem : α → List α → Prop) Sublist Membership.mem :=
⟨fun h₁ h₂ => h₂.subset h₁⟩
theorem Sublist.length_le : l₁ <+ l₂ → length l₁ ≤ length l₂
| .slnil => Nat.le_refl 0
| .cons _l s => le_succ_of_le (length_le s)
| .cons₂ _ s => succ_le_succ (length_le s)
@[simp] theorem sublist_nil {l : List α} : l <+ [] ↔ l = [] :=
⟨fun s => subset_nil.1 s.subset, fun H => H ▸ Sublist.refl _⟩
theorem Sublist.eq_of_length : l₁ <+ l₂ → length l₁ = length l₂ → l₁ = l₂
| .slnil, _ => rfl
| .cons a s, h => nomatch Nat.not_lt.2 s.length_le (h ▸ lt_succ_self _)
| .cons₂ a s, h => by rw [s.eq_of_length (succ.inj h)]
theorem Sublist.eq_of_length_le (s : l₁ <+ l₂) (h : length l₂ ≤ length l₁) : l₁ = l₂ :=
s.eq_of_length <| Nat.le_antisymm s.length_le h
@[simp] theorem singleton_sublist {a : α} {l} : [a] <+ l ↔ a ∈ l := by
refine ⟨fun h => h.subset (mem_singleton_self _), fun h => ?_⟩
obtain ⟨_, _, rfl⟩ := append_of_mem h
exact ((nil_sublist _).cons₂ _).trans (sublist_append_right ..)
@[simp] theorem replicate_sublist_replicate {m n} (a : α) :
replicate m a <+ replicate n a ↔ m ≤ n := by
refine ⟨fun h => ?_, fun h => ?_⟩
· have := h.length_le; simp only [length_replicate] at this ⊢; exact this
· induction h with
| refl => apply Sublist.refl
| step => simp [*, replicate, Sublist.cons]
theorem isSublist_iff_sublist [BEq α] [LawfulBEq α] {l₁ l₂ : List α} :
l₁.isSublist l₂ ↔ l₁ <+ l₂ := by
cases l₁ <;> cases l₂ <;> simp [isSublist]
case cons.cons hd₁ tl₁ hd₂ tl₂ =>
if h_eq : hd₁ = hd₂ then
simp [h_eq, cons_sublist_cons, isSublist_iff_sublist]
else
simp only [beq_iff_eq, h_eq]
constructor
· intro h_sub
apply Sublist.cons
exact isSublist_iff_sublist.mp h_sub
· intro h_sub
cases h_sub
case cons h_sub =>
exact isSublist_iff_sublist.mpr h_sub
case cons₂ =>
contradiction
instance [DecidableEq α] (l₁ l₂ : List α) : Decidable (l₁ <+ l₂) :=
decidable_of_iff (l₁.isSublist l₂) isSublist_iff_sublist
theorem tail_eq_tailD (l) : @tail α l = tailD l [] := by cases l <;> rfl
theorem tail_eq_tail? (l) : @tail α l = (tail? l).getD [] := by simp [tail_eq_tailD]
@[simp] theorem next?_nil : @next? α [] = none := rfl
@[simp] theorem next?_cons (a l) : @next? α (a :: l) = some (a, l) := rfl
theorem get_eq_iff : List.get l n = x ↔ l.get? n.1 = some x := by simp [get?_eq_some]
theorem get?_inj
(h₀ : i < xs.length) (h₁ : Nodup xs) (h₂ : xs.get? i = xs.get? j) : i = j := by
induction xs generalizing i j with
| nil => cases h₀
| cons x xs ih =>
match i, j with
| 0, 0 => rfl
| i+1, j+1 => simp; cases h₁ with
| cons ha h₁ => exact ih (Nat.lt_of_succ_lt_succ h₀) h₁ h₂
| i+1, 0 => ?_ | 0, j+1 => ?_
all_goals
simp at h₂
cases h₁; rename_i h' h
have := h x ?_ rfl; cases this
rw [mem_iff_get?]
exact ⟨_, h₂⟩; exact ⟨_ , h₂.symm⟩
theorem tail_drop (l : List α) (n : Nat) : (l.drop n).tail = l.drop (n + 1) := by
induction l generalizing n with
| nil => simp
| cons hd tl hl =>
cases n
· simp
· simp [hl]
@[simp] theorem modifyNth_nil (f : α → α) (n) : [].modifyNth f n = [] := by cases n <;> rfl
@[simp] theorem modifyNth_zero_cons (f : α → α) (a : α) (l : List α) :
(a :: l).modifyNth f 0 = f a :: l := rfl
@[simp] theorem modifyNth_succ_cons (f : α → α) (a : α) (l : List α) (n) :
(a :: l).modifyNth f (n + 1) = a :: l.modifyNth f n := by rfl
theorem modifyNthTail_id : ∀ n (l : List α), l.modifyNthTail id n = l
| 0, _ => rfl
| _+1, [] => rfl
| n+1, a :: l => congrArg (cons a) (modifyNthTail_id n l)
theorem eraseIdx_eq_modifyNthTail : ∀ n (l : List α), eraseIdx l n = modifyNthTail tail n l
| 0, l => by cases l <;> rfl
| n+1, [] => rfl
| n+1, a :: l => congrArg (cons _) (eraseIdx_eq_modifyNthTail _ _)
@[deprecated] alias removeNth_eq_nth_tail := eraseIdx_eq_modifyNthTail
theorem get?_modifyNth (f : α → α) :
∀ n (l : List α) m, (modifyNth f n l).get? m = (fun a => if n = m then f a else a) <$> l.get? m
| n, l, 0 => by cases l <;> cases n <;> rfl
| n, [], _+1 => by cases n <;> rfl
| 0, _ :: l, m+1 => by cases h : l.get? m <;> simp [h, modifyNth, m.succ_ne_zero.symm]
| n+1, a :: l, m+1 =>
(get?_modifyNth f n l m).trans <| by
cases h' : l.get? m <;> by_cases h : n = m <;>
simp [h, if_pos, if_neg, Option.map, mt Nat.succ.inj, not_false_iff, h']
theorem modifyNthTail_length (f : List α → List α) (H : ∀ l, length (f l) = length l) :
∀ n l, length (modifyNthTail f n l) = length l
| 0, _ => H _
| _+1, [] => rfl
| _+1, _ :: _ => congrArg (·+1) (modifyNthTail_length _ H _ _)
theorem modifyNthTail_add (f : List α → List α) (n) (l₁ l₂ : List α) :
modifyNthTail f (l₁.length + n) (l₁ ++ l₂) = l₁ ++ modifyNthTail f n l₂ := by
induction l₁ <;> simp [*, Nat.succ_add]
theorem exists_of_modifyNthTail (f : List α → List α) {n} {l : List α} (h : n ≤ l.length) :
∃ l₁ l₂, l = l₁ ++ l₂ ∧ l₁.length = n ∧ modifyNthTail f n l = l₁ ++ f l₂ :=
have ⟨_, _, eq, hl⟩ : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ l₁.length = n :=
⟨_, _, (take_append_drop n l).symm, length_take_of_le h⟩
⟨_, _, eq, hl, hl ▸ eq ▸ modifyNthTail_add (n := 0) ..⟩
@[simp] theorem modify_get?_length (f : α → α) : ∀ n l, length (modifyNth f n l) = length l :=
modifyNthTail_length _ fun l => by cases l <;> rfl
@[simp] theorem get?_modifyNth_eq (f : α → α) (n) (l : List α) :
(modifyNth f n l).get? n = f <$> l.get? n := by
simp only [get?_modifyNth, if_pos]
@[simp] theorem get?_modifyNth_ne (f : α → α) {m n} (l : List α) (h : m ≠ n) :
(modifyNth f m l).get? n = l.get? n := by
simp only [get?_modifyNth, if_neg h, id_map']
theorem exists_of_modifyNth (f : α → α) {n} {l : List α} (h : n < l.length) :
∃ l₁ a l₂, l = l₁ ++ a :: l₂ ∧ l₁.length = n ∧ modifyNth f n l = l₁ ++ f a :: l₂ :=
match exists_of_modifyNthTail _ (Nat.le_of_lt h) with
| ⟨_, _::_, eq, hl, H⟩ => ⟨_, _, _, eq, hl, H⟩
| ⟨_, [], eq, hl, _⟩ => nomatch Nat.ne_of_gt h (eq ▸ append_nil _ ▸ hl)
theorem modifyNthTail_eq_take_drop (f : List α → List α) (H : f [] = []) :
∀ n l, modifyNthTail f n l = take n l ++ f (drop n l)
| 0, _ => rfl
| _ + 1, [] => H.symm
| n + 1, b :: l => congrArg (cons b) (modifyNthTail_eq_take_drop f H n l)
theorem modifyNth_eq_take_drop (f : α → α) :
∀ n l, modifyNth f n l = take n l ++ modifyHead f (drop n l) :=
modifyNthTail_eq_take_drop _ rfl
theorem modifyNth_eq_take_cons_drop (f : α → α) {n l} (h) :
modifyNth f n l = take n l ++ f (get l ⟨n, h⟩) :: drop (n + 1) l := by
rw [modifyNth_eq_take_drop, drop_eq_get_cons h]; rfl
theorem set_eq_modifyNth (a : α) : ∀ n (l : List α), set l n a = modifyNth (fun _ => a) n l
| 0, l => by cases l <;> rfl
| n+1, [] => rfl
| n+1, b :: l => congrArg (cons _) (set_eq_modifyNth _ _ _)
| .lake/packages/batteries/Batteries/Data/List/Lemmas.lean | 361 | 363 | theorem set_eq_take_cons_drop (a : α) {n l} (h : n < length l) :
set l n a = take n l ++ a :: drop (n + 1) l := by |
rw [set_eq_modifyNth, modifyNth_eq_take_cons_drop _ h]
|
import Mathlib.LinearAlgebra.BilinearForm.TensorProduct
import Mathlib.LinearAlgebra.QuadraticForm.Basic
universe uR uA uM₁ uM₂
variable {R : Type uR} {A : Type uA} {M₁ : Type uM₁} {M₂ : Type uM₂}
open TensorProduct
open LinearMap (BilinForm)
namespace QuadraticForm
section CommRing
variable [CommRing R] [CommRing A]
variable [AddCommGroup M₁] [AddCommGroup M₂]
variable [Algebra R A] [Module R M₁] [Module A M₁]
variable [SMulCommClass R A M₁] [SMulCommClass A R M₁] [IsScalarTower R A M₁]
variable [Module R M₂] [Invertible (2 : R)]
variable (R A) in
-- `noncomputable` is a performance workaround for mathlib4#7103
noncomputable def tensorDistrib :
QuadraticForm A M₁ ⊗[R] QuadraticForm R M₂ →ₗ[A] QuadraticForm A (M₁ ⊗[R] M₂) :=
letI : Invertible (2 : A) := (Invertible.map (algebraMap R A) 2).copy 2 (map_ofNat _ _).symm
-- while `letI`s would produce a better term than `let`, they would make this already-slow
-- definition even slower.
let toQ := BilinForm.toQuadraticFormLinearMap A A (M₁ ⊗[R] M₂)
let tmulB := BilinForm.tensorDistrib R A (M₁ := M₁) (M₂ := M₂)
let toB := AlgebraTensorModule.map
(QuadraticForm.associated : QuadraticForm A M₁ →ₗ[A] BilinForm A M₁)
(QuadraticForm.associated : QuadraticForm R M₂ →ₗ[R] BilinForm R M₂)
toQ ∘ₗ tmulB ∘ₗ toB
-- TODO: make the RHS `MulOpposite.op (Q₂ m₂) • Q₁ m₁` so that this has a nicer defeq for
-- `R = A` of `Q₁ m₁ * Q₂ m₂`.
@[simp]
theorem tensorDistrib_tmul (Q₁ : QuadraticForm A M₁) (Q₂ : QuadraticForm R M₂) (m₁ : M₁) (m₂ : M₂) :
tensorDistrib R A (Q₁ ⊗ₜ Q₂) (m₁ ⊗ₜ m₂) = Q₂ m₂ • Q₁ m₁ :=
letI : Invertible (2 : A) := (Invertible.map (algebraMap R A) 2).copy 2 (map_ofNat _ _).symm
(BilinForm.tensorDistrib_tmul _ _ _ _ _ _).trans <| congr_arg₂ _
(associated_eq_self_apply _ _ _) (associated_eq_self_apply _ _ _)
-- `noncomputable` is a performance workaround for mathlib4#7103
protected noncomputable abbrev tmul (Q₁ : QuadraticForm A M₁) (Q₂ : QuadraticForm R M₂) :
QuadraticForm A (M₁ ⊗[R] M₂) :=
tensorDistrib R A (Q₁ ⊗ₜ[R] Q₂)
theorem associated_tmul [Invertible (2 : A)] (Q₁ : QuadraticForm A M₁) (Q₂ : QuadraticForm R M₂) :
associated (R := A) (Q₁.tmul Q₂)
= (associated (R := A) Q₁).tmul (associated (R := R) Q₂) := by
rw [QuadraticForm.tmul, tensorDistrib, BilinForm.tmul]
dsimp
have : Subsingleton (Invertible (2 : A)) := inferInstance
convert associated_left_inverse A ((associated_isSymm A Q₁).tmul (associated_isSymm R Q₂))
theorem polarBilin_tmul [Invertible (2 : A)] (Q₁ : QuadraticForm A M₁) (Q₂ : QuadraticForm R M₂) :
polarBilin (Q₁.tmul Q₂) = ⅟(2 : A) • (polarBilin Q₁).tmul (polarBilin Q₂) := by
simp_rw [← two_nsmul_associated A, ← two_nsmul_associated R, BilinForm.tmul, tmul_smul,
← smul_tmul', map_nsmul, associated_tmul]
rw [smul_comm (_ : A) (_ : ℕ), ← smul_assoc, two_smul _ (_ : A), invOf_two_add_invOf_two,
one_smul]
variable (A) in
-- `noncomputable` is a performance workaround for mathlib4#7103
protected noncomputable def baseChange (Q : QuadraticForm R M₂) : QuadraticForm A (A ⊗[R] M₂) :=
QuadraticForm.tmul (R := R) (A := A) (M₁ := A) (M₂ := M₂) (QuadraticForm.sq (R := A)) Q
@[simp]
theorem baseChange_tmul (Q : QuadraticForm R M₂) (a : A) (m₂ : M₂) :
Q.baseChange A (a ⊗ₜ m₂) = Q m₂ • (a * a) :=
tensorDistrib_tmul _ _ _ _
| Mathlib/LinearAlgebra/QuadraticForm/TensorProduct.lean | 95 | 99 | theorem associated_baseChange [Invertible (2 : A)] (Q : QuadraticForm R M₂) :
associated (R := A) (Q.baseChange A) = (associated (R := R) Q).baseChange A := by |
dsimp only [QuadraticForm.baseChange, LinearMap.baseChange]
rw [associated_tmul (QuadraticForm.sq (R := A)) Q, associated_sq]
exact rfl
|
import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.Data.DFinsupp.Basic
#align_import algebra.direct_sum.basic from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c"
open Function
universe u v w u₁
variable (ι : Type v) [dec_ι : DecidableEq ι] (β : ι → Type w)
def DirectSum [∀ i, AddCommMonoid (β i)] : Type _ :=
-- Porting note: Failed to synthesize
-- Π₀ i, β i deriving AddCommMonoid, Inhabited
-- See https://github.com/leanprover-community/mathlib4/issues/5020
Π₀ i, β i
#align direct_sum DirectSum
-- Porting note (#10754): Added inhabited instance manually
instance [∀ i, AddCommMonoid (β i)] : Inhabited (DirectSum ι β) :=
inferInstanceAs (Inhabited (Π₀ i, β i))
-- Porting note (#10754): Added addCommMonoid instance manually
instance [∀ i, AddCommMonoid (β i)] : AddCommMonoid (DirectSum ι β) :=
inferInstanceAs (AddCommMonoid (Π₀ i, β i))
instance [∀ i, AddCommMonoid (β i)] : DFunLike (DirectSum ι β) _ fun i : ι => β i :=
inferInstanceAs (DFunLike (Π₀ i, β i) _ _)
instance [∀ i, AddCommMonoid (β i)] : CoeFun (DirectSum ι β) fun _ => ∀ i : ι, β i :=
inferInstanceAs (CoeFun (Π₀ i, β i) fun _ => ∀ i : ι, β i)
scoped[DirectSum] notation3 "⨁ "(...)", "r:(scoped f => DirectSum _ f) => r
-- Porting note: The below recreates some of the lean3 notation, not fully yet
-- section
-- open Batteries.ExtendedBinder
-- syntax (name := bigdirectsum) "⨁ " extBinders ", " term : term
-- macro_rules (kind := bigdirectsum)
-- | `(⨁ $_:ident, $y:ident → $z:ident) => `(DirectSum _ (fun $y ↦ $z))
-- | `(⨁ $x:ident, $p) => `(DirectSum _ (fun $x ↦ $p))
-- | `(⨁ $_:ident : $t:ident, $p) => `(DirectSum _ (fun $t ↦ $p))
-- | `(⨁ ($x:ident) ($y:ident), $p) => `(DirectSum _ (fun $x ↦ fun $y ↦ $p))
-- end
instance [∀ i, AddCommMonoid (β i)] [∀ i, DecidableEq (β i)] : DecidableEq (DirectSum ι β) :=
inferInstanceAs <| DecidableEq (Π₀ i, β i)
namespace DirectSum
variable {ι}
variable [∀ i, AddCommMonoid (β i)]
@[simp]
theorem zero_apply (i : ι) : (0 : ⨁ i, β i) i = 0 :=
rfl
#align direct_sum.zero_apply DirectSum.zero_apply
variable {β}
@[simp]
theorem add_apply (g₁ g₂ : ⨁ i, β i) (i : ι) : (g₁ + g₂) i = g₁ i + g₂ i :=
rfl
#align direct_sum.add_apply DirectSum.add_apply
variable (β)
def mk (s : Finset ι) : (∀ i : (↑s : Set ι), β i.1) →+ ⨁ i, β i where
toFun := DFinsupp.mk s
map_add' _ _ := DFinsupp.mk_add
map_zero' := DFinsupp.mk_zero
#align direct_sum.mk DirectSum.mk
def of (i : ι) : β i →+ ⨁ i, β i :=
DFinsupp.singleAddHom β i
#align direct_sum.of DirectSum.of
@[simp]
theorem of_eq_same (i : ι) (x : β i) : (of _ i x) i = x :=
DFinsupp.single_eq_same
#align direct_sum.of_eq_same DirectSum.of_eq_same
theorem of_eq_of_ne (i j : ι) (x : β i) (h : i ≠ j) : (of _ i x) j = 0 :=
DFinsupp.single_eq_of_ne h
#align direct_sum.of_eq_of_ne DirectSum.of_eq_of_ne
lemma of_apply {i : ι} (j : ι) (x : β i) : of β i x j = if h : i = j then Eq.recOn h x else 0 :=
DFinsupp.single_apply
@[simp]
theorem support_zero [∀ (i : ι) (x : β i), Decidable (x ≠ 0)] : (0 : ⨁ i, β i).support = ∅ :=
DFinsupp.support_zero
#align direct_sum.support_zero DirectSum.support_zero
@[simp]
theorem support_of [∀ (i : ι) (x : β i), Decidable (x ≠ 0)] (i : ι) (x : β i) (h : x ≠ 0) :
(of _ i x).support = {i} :=
DFinsupp.support_single_ne_zero h
#align direct_sum.support_of DirectSum.support_of
theorem support_of_subset [∀ (i : ι) (x : β i), Decidable (x ≠ 0)] {i : ι} {b : β i} :
(of _ i b).support ⊆ {i} :=
DFinsupp.support_single_subset
#align direct_sum.support_of_subset DirectSum.support_of_subset
theorem sum_support_of [∀ (i : ι) (x : β i), Decidable (x ≠ 0)] (x : ⨁ i, β i) :
(∑ i ∈ x.support, of β i (x i)) = x :=
DFinsupp.sum_single
#align direct_sum.sum_support_of DirectSum.sum_support_of
| Mathlib/Algebra/DirectSum/Basic.lean | 155 | 159 | theorem sum_univ_of [Fintype ι] (x : ⨁ i, β i) :
∑ i ∈ Finset.univ, of β i (x i) = x := by |
apply DFinsupp.ext (fun i ↦ ?_)
rw [DFinsupp.finset_sum_apply]
simp [of_apply]
|
import Mathlib.Algebra.Polynomial.Module.AEval
#align_import data.polynomial.module from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0"
universe u v
open Polynomial BigOperators
@[nolint unusedArguments]
def PolynomialModule (R M : Type*) [CommRing R] [AddCommGroup M] [Module R M] := ℕ →₀ M
#align polynomial_module PolynomialModule
variable (R M : Type*) [CommRing R] [AddCommGroup M] [Module R M] (I : Ideal R)
-- Porting note: stated instead of deriving
noncomputable instance : Inhabited (PolynomialModule R M) := Finsupp.instInhabited
noncomputable instance : AddCommGroup (PolynomialModule R M) := Finsupp.instAddCommGroup
variable {M}
variable {S : Type*} [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M]
namespace PolynomialModule
@[nolint unusedArguments]
noncomputable instance : Module S (PolynomialModule R M) :=
Finsupp.module ℕ M
instance instFunLike : FunLike (PolynomialModule R M) ℕ M :=
Finsupp.instFunLike
instance : CoeFun (PolynomialModule R M) fun _ => ℕ → M :=
Finsupp.instCoeFun
theorem zero_apply (i : ℕ) : (0 : PolynomialModule R M) i = 0 :=
Finsupp.zero_apply
theorem add_apply (g₁ g₂ : PolynomialModule R M) (a : ℕ) : (g₁ + g₂) a = g₁ a + g₂ a :=
Finsupp.add_apply g₁ g₂ a
noncomputable def single (i : ℕ) : M →+ PolynomialModule R M :=
Finsupp.singleAddHom i
#align polynomial_module.single PolynomialModule.single
theorem single_apply (i : ℕ) (m : M) (n : ℕ) : single R i m n = ite (i = n) m 0 :=
Finsupp.single_apply
#align polynomial_module.single_apply PolynomialModule.single_apply
noncomputable def lsingle (i : ℕ) : M →ₗ[R] PolynomialModule R M :=
Finsupp.lsingle i
#align polynomial_module.lsingle PolynomialModule.lsingle
theorem lsingle_apply (i : ℕ) (m : M) (n : ℕ) : lsingle R i m n = ite (i = n) m 0 :=
Finsupp.single_apply
#align polynomial_module.lsingle_apply PolynomialModule.lsingle_apply
theorem single_smul (i : ℕ) (r : R) (m : M) : single R i (r • m) = r • single R i m :=
(lsingle R i).map_smul r m
#align polynomial_module.single_smul PolynomialModule.single_smul
variable {R}
theorem induction_linear {P : PolynomialModule R M → Prop} (f : PolynomialModule R M) (h0 : P 0)
(hadd : ∀ f g, P f → P g → P (f + g)) (hsingle : ∀ a b, P (single R a b)) : P f :=
Finsupp.induction_linear f h0 hadd hsingle
#align polynomial_module.induction_linear PolynomialModule.induction_linear
noncomputable instance polynomialModule : Module R[X] (PolynomialModule R M) :=
inferInstanceAs (Module R[X] (Module.AEval' (Finsupp.lmapDomain M R Nat.succ)))
#align polynomial_module.polynomial_module PolynomialModule.polynomialModule
lemma smul_def (f : R[X]) (m : PolynomialModule R M) :
f • m = aeval (Finsupp.lmapDomain M R Nat.succ) f m := by
rfl
instance (M : Type u) [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower S R M] :
IsScalarTower S R (PolynomialModule R M) :=
Finsupp.isScalarTower _ _
instance isScalarTower' (M : Type u) [AddCommGroup M] [Module R M] [Module S M]
[IsScalarTower S R M] : IsScalarTower S R[X] (PolynomialModule R M) := by
haveI : IsScalarTower R R[X] (PolynomialModule R M) :=
inferInstanceAs <| IsScalarTower R R[X] <| Module.AEval' <| Finsupp.lmapDomain M R Nat.succ
constructor
intro x y z
rw [← @IsScalarTower.algebraMap_smul S R, ← @IsScalarTower.algebraMap_smul S R, smul_assoc]
#align polynomial_module.is_scalar_tower' PolynomialModule.isScalarTower'
@[simp]
| Mathlib/Algebra/Polynomial/Module/Basic.lean | 123 | 135 | theorem monomial_smul_single (i : ℕ) (r : R) (j : ℕ) (m : M) :
monomial i r • single R j m = single R (i + j) (r • m) := by |
simp only [LinearMap.mul_apply, Polynomial.aeval_monomial, LinearMap.pow_apply,
Module.algebraMap_end_apply, smul_def]
induction i generalizing r j m with
| zero =>
rw [Function.iterate_zero, zero_add]
exact Finsupp.smul_single r j m
| succ n hn =>
rw [Function.iterate_succ, Function.comp_apply, add_assoc, ← hn]
congr 2
rw [Nat.one_add]
exact Finsupp.mapDomain_single
|
import Mathlib.Data.List.Basic
#align_import data.list.join from "leanprover-community/mathlib"@"18a5306c091183ac90884daa9373fa3b178e8607"
-- Make sure we don't import algebra
assert_not_exists Monoid
variable {α β : Type*}
namespace List
attribute [simp] join
-- Porting note (#10618): simp can prove this
-- @[simp]
theorem join_singleton (l : List α) : [l].join = l := by rw [join, join, append_nil]
#align list.join_singleton List.join_singleton
@[simp]
theorem join_eq_nil : ∀ {L : List (List α)}, join L = [] ↔ ∀ l ∈ L, l = []
| [] => iff_of_true rfl (forall_mem_nil _)
| l :: L => by simp only [join, append_eq_nil, join_eq_nil, forall_mem_cons]
#align list.join_eq_nil List.join_eq_nil
@[simp]
theorem join_append (L₁ L₂ : List (List α)) : join (L₁ ++ L₂) = join L₁ ++ join L₂ := by
induction L₁
· rfl
· simp [*]
#align list.join_append List.join_append
theorem join_concat (L : List (List α)) (l : List α) : join (L.concat l) = join L ++ l := by simp
#align list.join_concat List.join_concat
@[simp]
theorem join_filter_not_isEmpty :
∀ {L : List (List α)}, join (L.filter fun l => !l.isEmpty) = L.join
| [] => rfl
| [] :: L => by
simp [join_filter_not_isEmpty (L := L), isEmpty_iff_eq_nil]
| (a :: l) :: L => by
simp [join_filter_not_isEmpty (L := L)]
#align list.join_filter_empty_eq_ff List.join_filter_not_isEmpty
@[deprecated (since := "2024-02-25")] alias join_filter_isEmpty_eq_false := join_filter_not_isEmpty
@[simp]
theorem join_filter_ne_nil [DecidablePred fun l : List α => l ≠ []] {L : List (List α)} :
join (L.filter fun l => l ≠ []) = L.join := by
simp [join_filter_not_isEmpty, ← isEmpty_iff_eq_nil]
#align list.join_filter_ne_nil List.join_filter_ne_nil
theorem join_join (l : List (List (List α))) : l.join.join = (l.map join).join := by
induction l <;> simp [*]
#align list.join_join List.join_join
lemma length_join' (L : List (List α)) : length (join L) = Nat.sum (map length L) := by
induction L <;> [rfl; simp only [*, join, map, Nat.sum_cons, length_append]]
lemma countP_join' (p : α → Bool) :
∀ L : List (List α), countP p L.join = Nat.sum (L.map (countP p))
| [] => rfl
| a :: l => by rw [join, countP_append, map_cons, Nat.sum_cons, countP_join' _ l]
lemma count_join' [BEq α] (L : List (List α)) (a : α) :
L.join.count a = Nat.sum (L.map (count a)) := countP_join' _ _
lemma length_bind' (l : List α) (f : α → List β) :
length (l.bind f) = Nat.sum (map (length ∘ f) l) := by rw [List.bind, length_join', map_map]
lemma countP_bind' (p : β → Bool) (l : List α) (f : α → List β) :
countP p (l.bind f) = Nat.sum (map (countP p ∘ f) l) := by rw [List.bind, countP_join', map_map]
lemma count_bind' [BEq β] (l : List α) (f : α → List β) (x : β) :
count x (l.bind f) = Nat.sum (map (count x ∘ f) l) := countP_bind' _ _ _
@[simp]
theorem bind_eq_nil {l : List α} {f : α → List β} : List.bind l f = [] ↔ ∀ x ∈ l, f x = [] :=
join_eq_nil.trans <| by
simp only [mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]
#align list.bind_eq_nil List.bind_eq_nil
theorem take_sum_join' (L : List (List α)) (i : ℕ) :
L.join.take (Nat.sum ((L.map length).take i)) = (L.take i).join := by
induction L generalizing i
· simp
· cases i <;> simp [take_append, *]
theorem drop_sum_join' (L : List (List α)) (i : ℕ) :
L.join.drop (Nat.sum ((L.map length).take i)) = (L.drop i).join := by
induction L generalizing i
· simp
· cases i <;> simp [drop_append, *]
theorem drop_take_succ_eq_cons_get (L : List α) (i : Fin L.length) :
(L.take (i + 1)).drop i = [get L i] := by
induction' L with head tail ih
· exact (Nat.not_succ_le_zero i i.isLt).elim
rcases i with ⟨_ | i, hi⟩
· simp
· simpa using ih ⟨i, Nat.lt_of_succ_lt_succ hi⟩
set_option linter.deprecated false in
@[deprecated drop_take_succ_eq_cons_get (since := "2023-01-10")]
theorem drop_take_succ_eq_cons_nthLe (L : List α) {i : ℕ} (hi : i < L.length) :
(L.take (i + 1)).drop i = [nthLe L i hi] := by
induction' L with head tail generalizing i
· simp only [length] at hi
exact (Nat.not_succ_le_zero i hi).elim
cases' i with i hi
· simp
rfl
have : i < tail.length := by simpa using hi
simp [*]
rfl
#align list.drop_take_succ_eq_cons_nth_le List.drop_take_succ_eq_cons_nthLe
theorem drop_take_succ_join_eq_get' (L : List (List α)) (i : Fin L.length) :
(L.join.take (Nat.sum ((L.map length).take (i + 1)))).drop (Nat.sum ((L.map length).take i)) =
get L i := by
have : (L.map length).take i = ((L.take (i + 1)).map length).take i := by
simp [map_take, take_take, Nat.min_eq_left]
simp only [this, length_map, take_sum_join', drop_sum_join', drop_take_succ_eq_cons_get,
join, append_nil]
#noalign list.drop_take_succ_join_eq_nth_le
#noalign list.sum_take_map_length_lt1
#noalign list.sum_take_map_length_lt2
#noalign list.nth_le_join
theorem eq_iff_join_eq (L L' : List (List α)) :
L = L' ↔ L.join = L'.join ∧ map length L = map length L' := by
refine ⟨fun H => by simp [H], ?_⟩
rintro ⟨join_eq, length_eq⟩
apply ext_get
· have : length (map length L) = length (map length L') := by rw [length_eq]
simpa using this
· intro n h₁ h₂
rw [← drop_take_succ_join_eq_get', ← drop_take_succ_join_eq_get', join_eq, length_eq]
#align list.eq_iff_join_eq List.eq_iff_join_eq
theorem join_drop_length_sub_one {L : List (List α)} (h : L ≠ []) :
(L.drop (L.length - 1)).join = L.getLast h := by
induction L using List.reverseRecOn
· cases h rfl
· simp
#align list.join_drop_length_sub_one List.join_drop_length_sub_one
| Mathlib/Data/List/Join.lean | 188 | 192 | theorem append_join_map_append (L : List (List α)) (x : List α) :
x ++ (L.map (· ++ x)).join = (L.map (x ++ ·)).join ++ x := by |
induction' L with _ _ ih
· rw [map_nil, join, append_nil, map_nil, join, nil_append]
· rw [map_cons, join, map_cons, join, append_assoc, ih, append_assoc, append_assoc]
|
import Mathlib.Order.PropInstances
#align_import order.heyting.basic from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
open Function OrderDual
universe u
variable {ι α β : Type*}
section
variable (α β)
instance Prod.instHImp [HImp α] [HImp β] : HImp (α × β) :=
⟨fun a b => (a.1 ⇨ b.1, a.2 ⇨ b.2)⟩
instance Prod.instHNot [HNot α] [HNot β] : HNot (α × β) :=
⟨fun a => (¬a.1, ¬a.2)⟩
instance Prod.instSDiff [SDiff α] [SDiff β] : SDiff (α × β) :=
⟨fun a b => (a.1 \ b.1, a.2 \ b.2)⟩
instance Prod.instHasCompl [HasCompl α] [HasCompl β] : HasCompl (α × β) :=
⟨fun a => (a.1ᶜ, a.2ᶜ)⟩
end
@[simp]
theorem fst_himp [HImp α] [HImp β] (a b : α × β) : (a ⇨ b).1 = a.1 ⇨ b.1 :=
rfl
#align fst_himp fst_himp
@[simp]
theorem snd_himp [HImp α] [HImp β] (a b : α × β) : (a ⇨ b).2 = a.2 ⇨ b.2 :=
rfl
#align snd_himp snd_himp
@[simp]
theorem fst_hnot [HNot α] [HNot β] (a : α × β) : (¬a).1 = ¬a.1 :=
rfl
#align fst_hnot fst_hnot
@[simp]
theorem snd_hnot [HNot α] [HNot β] (a : α × β) : (¬a).2 = ¬a.2 :=
rfl
#align snd_hnot snd_hnot
@[simp]
theorem fst_sdiff [SDiff α] [SDiff β] (a b : α × β) : (a \ b).1 = a.1 \ b.1 :=
rfl
#align fst_sdiff fst_sdiff
@[simp]
theorem snd_sdiff [SDiff α] [SDiff β] (a b : α × β) : (a \ b).2 = a.2 \ b.2 :=
rfl
#align snd_sdiff snd_sdiff
@[simp]
theorem fst_compl [HasCompl α] [HasCompl β] (a : α × β) : aᶜ.1 = a.1ᶜ :=
rfl
#align fst_compl fst_compl
@[simp]
theorem snd_compl [HasCompl α] [HasCompl β] (a : α × β) : aᶜ.2 = a.2ᶜ :=
rfl
#align snd_compl snd_compl
class GeneralizedHeytingAlgebra (α : Type*) extends Lattice α, OrderTop α, HImp α where
le_himp_iff (a b c : α) : a ≤ b ⇨ c ↔ a ⊓ b ≤ c
#align generalized_heyting_algebra GeneralizedHeytingAlgebra
#align generalized_heyting_algebra.to_order_top GeneralizedHeytingAlgebra.toOrderTop
class GeneralizedCoheytingAlgebra (α : Type*) extends Lattice α, OrderBot α, SDiff α where
sdiff_le_iff (a b c : α) : a \ b ≤ c ↔ a ≤ b ⊔ c
#align generalized_coheyting_algebra GeneralizedCoheytingAlgebra
#align generalized_coheyting_algebra.to_order_bot GeneralizedCoheytingAlgebra.toOrderBot
class HeytingAlgebra (α : Type*) extends GeneralizedHeytingAlgebra α, OrderBot α, HasCompl α where
himp_bot (a : α) : a ⇨ ⊥ = aᶜ
#align heyting_algebra HeytingAlgebra
class CoheytingAlgebra (α : Type*) extends GeneralizedCoheytingAlgebra α, OrderTop α, HNot α where
top_sdiff (a : α) : ⊤ \ a = ¬a
#align coheyting_algebra CoheytingAlgebra
class BiheytingAlgebra (α : Type*) extends HeytingAlgebra α, SDiff α, HNot α where
sdiff_le_iff (a b c : α) : a \ b ≤ c ↔ a ≤ b ⊔ c
top_sdiff (a : α) : ⊤ \ a = ¬a
#align biheyting_algebra BiheytingAlgebra
-- See note [lower instance priority]
attribute [instance 100] GeneralizedHeytingAlgebra.toOrderTop
attribute [instance 100] GeneralizedCoheytingAlgebra.toOrderBot
-- See note [lower instance priority]
instance (priority := 100) HeytingAlgebra.toBoundedOrder [HeytingAlgebra α] : BoundedOrder α :=
{ bot_le := ‹HeytingAlgebra α›.bot_le }
--#align heyting_algebra.to_bounded_order HeytingAlgebra.toBoundedOrder
-- See note [lower instance priority]
instance (priority := 100) CoheytingAlgebra.toBoundedOrder [CoheytingAlgebra α] : BoundedOrder α :=
{ ‹CoheytingAlgebra α› with }
#align coheyting_algebra.to_bounded_order CoheytingAlgebra.toBoundedOrder
-- See note [lower instance priority]
instance (priority := 100) BiheytingAlgebra.toCoheytingAlgebra [BiheytingAlgebra α] :
CoheytingAlgebra α :=
{ ‹BiheytingAlgebra α› with }
#align biheyting_algebra.to_coheyting_algebra BiheytingAlgebra.toCoheytingAlgebra
-- See note [reducible non-instances]
abbrev HeytingAlgebra.ofHImp [DistribLattice α] [BoundedOrder α] (himp : α → α → α)
(le_himp_iff : ∀ a b c, a ≤ himp b c ↔ a ⊓ b ≤ c) : HeytingAlgebra α :=
{ ‹DistribLattice α›, ‹BoundedOrder α› with
himp,
compl := fun a => himp a ⊥,
le_himp_iff,
himp_bot := fun a => rfl }
#align heyting_algebra.of_himp HeytingAlgebra.ofHImp
-- See note [reducible non-instances]
abbrev HeytingAlgebra.ofCompl [DistribLattice α] [BoundedOrder α] (compl : α → α)
(le_himp_iff : ∀ a b c, a ≤ compl b ⊔ c ↔ a ⊓ b ≤ c) : HeytingAlgebra α where
himp := (compl · ⊔ ·)
compl := compl
le_himp_iff := le_himp_iff
himp_bot _ := sup_bot_eq _
#align heyting_algebra.of_compl HeytingAlgebra.ofCompl
-- See note [reducible non-instances]
abbrev CoheytingAlgebra.ofSDiff [DistribLattice α] [BoundedOrder α] (sdiff : α → α → α)
(sdiff_le_iff : ∀ a b c, sdiff a b ≤ c ↔ a ≤ b ⊔ c) : CoheytingAlgebra α :=
{ ‹DistribLattice α›, ‹BoundedOrder α› with
sdiff,
hnot := fun a => sdiff ⊤ a,
sdiff_le_iff,
top_sdiff := fun a => rfl }
#align coheyting_algebra.of_sdiff CoheytingAlgebra.ofSDiff
-- See note [reducible non-instances]
abbrev CoheytingAlgebra.ofHNot [DistribLattice α] [BoundedOrder α] (hnot : α → α)
(sdiff_le_iff : ∀ a b c, a ⊓ hnot b ≤ c ↔ a ≤ b ⊔ c) : CoheytingAlgebra α where
sdiff a b := a ⊓ hnot b
hnot := hnot
sdiff_le_iff := sdiff_le_iff
top_sdiff _ := top_inf_eq _
#align coheyting_algebra.of_hnot CoheytingAlgebra.ofHNot
section GeneralizedHeytingAlgebra
variable [GeneralizedHeytingAlgebra α] {a b c d : α}
@[simp]
theorem le_himp_iff : a ≤ b ⇨ c ↔ a ⊓ b ≤ c :=
GeneralizedHeytingAlgebra.le_himp_iff _ _ _
#align le_himp_iff le_himp_iff
theorem le_himp_iff' : a ≤ b ⇨ c ↔ b ⊓ a ≤ c := by rw [le_himp_iff, inf_comm]
#align le_himp_iff' le_himp_iff'
theorem le_himp_comm : a ≤ b ⇨ c ↔ b ≤ a ⇨ c := by rw [le_himp_iff, le_himp_iff']
#align le_himp_comm le_himp_comm
theorem le_himp : a ≤ b ⇨ a :=
le_himp_iff.2 inf_le_left
#align le_himp le_himp
theorem le_himp_iff_left : a ≤ a ⇨ b ↔ a ≤ b := by rw [le_himp_iff, inf_idem]
#align le_himp_iff_left le_himp_iff_left
@[simp]
theorem himp_self : a ⇨ a = ⊤ :=
top_le_iff.1 <| le_himp_iff.2 inf_le_right
#align himp_self himp_self
theorem himp_inf_le : (a ⇨ b) ⊓ a ≤ b :=
le_himp_iff.1 le_rfl
#align himp_inf_le himp_inf_le
theorem inf_himp_le : a ⊓ (a ⇨ b) ≤ b := by rw [inf_comm, ← le_himp_iff]
#align inf_himp_le inf_himp_le
@[simp]
theorem inf_himp (a b : α) : a ⊓ (a ⇨ b) = a ⊓ b :=
le_antisymm (le_inf inf_le_left <| by rw [inf_comm, ← le_himp_iff]) <| inf_le_inf_left _ le_himp
#align inf_himp inf_himp
@[simp]
theorem himp_inf_self (a b : α) : (a ⇨ b) ⊓ a = b ⊓ a := by rw [inf_comm, inf_himp, inf_comm]
#align himp_inf_self himp_inf_self
@[simp]
theorem himp_eq_top_iff : a ⇨ b = ⊤ ↔ a ≤ b := by rw [← top_le_iff, le_himp_iff, top_inf_eq]
#align himp_eq_top_iff himp_eq_top_iff
@[simp]
theorem himp_top : a ⇨ ⊤ = ⊤ :=
himp_eq_top_iff.2 le_top
#align himp_top himp_top
@[simp]
theorem top_himp : ⊤ ⇨ a = a :=
eq_of_forall_le_iff fun b => by rw [le_himp_iff, inf_top_eq]
#align top_himp top_himp
theorem himp_himp (a b c : α) : a ⇨ b ⇨ c = a ⊓ b ⇨ c :=
eq_of_forall_le_iff fun d => by simp_rw [le_himp_iff, inf_assoc]
#align himp_himp himp_himp
theorem himp_le_himp_himp_himp : b ⇨ c ≤ (a ⇨ b) ⇨ a ⇨ c := by
rw [le_himp_iff, le_himp_iff, inf_assoc, himp_inf_self, ← inf_assoc, himp_inf_self, inf_assoc]
exact inf_le_left
#align himp_le_himp_himp_himp himp_le_himp_himp_himp
@[simp]
theorem himp_inf_himp_inf_le : (b ⇨ c) ⊓ (a ⇨ b) ⊓ a ≤ c := by
simpa using @himp_le_himp_himp_himp
theorem himp_left_comm (a b c : α) : a ⇨ b ⇨ c = b ⇨ a ⇨ c := by simp_rw [himp_himp, inf_comm]
#align himp_left_comm himp_left_comm
@[simp]
theorem himp_idem : b ⇨ b ⇨ a = b ⇨ a := by rw [himp_himp, inf_idem]
#align himp_idem himp_idem
theorem himp_inf_distrib (a b c : α) : a ⇨ b ⊓ c = (a ⇨ b) ⊓ (a ⇨ c) :=
eq_of_forall_le_iff fun d => by simp_rw [le_himp_iff, le_inf_iff, le_himp_iff]
#align himp_inf_distrib himp_inf_distrib
theorem sup_himp_distrib (a b c : α) : a ⊔ b ⇨ c = (a ⇨ c) ⊓ (b ⇨ c) :=
eq_of_forall_le_iff fun d => by
rw [le_inf_iff, le_himp_comm, sup_le_iff]
simp_rw [le_himp_comm]
#align sup_himp_distrib sup_himp_distrib
theorem himp_le_himp_left (h : a ≤ b) : c ⇨ a ≤ c ⇨ b :=
le_himp_iff.2 <| himp_inf_le.trans h
#align himp_le_himp_left himp_le_himp_left
theorem himp_le_himp_right (h : a ≤ b) : b ⇨ c ≤ a ⇨ c :=
le_himp_iff.2 <| (inf_le_inf_left _ h).trans himp_inf_le
#align himp_le_himp_right himp_le_himp_right
theorem himp_le_himp (hab : a ≤ b) (hcd : c ≤ d) : b ⇨ c ≤ a ⇨ d :=
(himp_le_himp_right hab).trans <| himp_le_himp_left hcd
#align himp_le_himp himp_le_himp
@[simp]
| Mathlib/Order/Heyting/Basic.lean | 366 | 367 | theorem sup_himp_self_left (a b : α) : a ⊔ b ⇨ a = b ⇨ a := by |
rw [sup_himp_distrib, himp_self, top_inf_eq]
|
import Mathlib.Analysis.Analytic.IsolatedZeros
import Mathlib.Analysis.Complex.CauchyIntegral
import Mathlib.Analysis.Complex.AbsMax
#align_import analysis.complex.open_mapping from "leanprover-community/mathlib"@"f9dd3204df14a0749cd456fac1e6849dfe7d2b88"
open Set Filter Metric Complex
open scoped Topology
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {U : Set E} {f : ℂ → ℂ} {g : E → ℂ}
{z₀ w : ℂ} {ε r m : ℝ}
theorem DiffContOnCl.ball_subset_image_closedBall (h : DiffContOnCl ℂ f (ball z₀ r)) (hr : 0 < r)
(hf : ∀ z ∈ sphere z₀ r, ε ≤ ‖f z - f z₀‖) (hz₀ : ∃ᶠ z in 𝓝 z₀, f z ≠ f z₀) :
ball (f z₀) (ε / 2) ⊆ f '' closedBall z₀ r := by
rintro v hv
have h1 : DiffContOnCl ℂ (fun z => f z - v) (ball z₀ r) := h.sub_const v
have h2 : ContinuousOn (fun z => ‖f z - v‖) (closedBall z₀ r) :=
continuous_norm.comp_continuousOn (closure_ball z₀ hr.ne.symm ▸ h1.continuousOn)
have h3 : AnalyticOn ℂ f (ball z₀ r) := h.differentiableOn.analyticOn isOpen_ball
have h4 : ∀ z ∈ sphere z₀ r, ε / 2 ≤ ‖f z - v‖ := fun z hz => by
linarith [hf z hz, show ‖v - f z₀‖ < ε / 2 from mem_ball.mp hv,
norm_sub_sub_norm_sub_le_norm_sub (f z) v (f z₀)]
have h5 : ‖f z₀ - v‖ < ε / 2 := by simpa [← dist_eq_norm, dist_comm] using mem_ball.mp hv
obtain ⟨z, hz1, hz2⟩ : ∃ z ∈ ball z₀ r, IsLocalMin (fun z => ‖f z - v‖) z :=
exists_isLocalMin_mem_ball h2 (mem_closedBall_self hr.le) fun z hz => h5.trans_le (h4 z hz)
refine ⟨z, ball_subset_closedBall hz1, sub_eq_zero.mp ?_⟩
have h6 := h1.differentiableOn.eventually_differentiableAt (isOpen_ball.mem_nhds hz1)
refine (eventually_eq_or_eq_zero_of_isLocalMin_norm h6 hz2).resolve_left fun key => ?_
have h7 : ∀ᶠ w in 𝓝 z, f w = f z := by filter_upwards [key] with h; field_simp
replace h7 : ∃ᶠ w in 𝓝[≠] z, f w = f z := (h7.filter_mono nhdsWithin_le_nhds).frequently
have h8 : IsPreconnected (ball z₀ r) := (convex_ball z₀ r).isPreconnected
have h9 := h3.eqOn_of_preconnected_of_frequently_eq analyticOn_const h8 hz1 h7
have h10 : f z = f z₀ := (h9 (mem_ball_self hr)).symm
exact not_eventually.mpr hz₀ (mem_of_superset (ball_mem_nhds z₀ hr) (h10 ▸ h9))
#align diff_cont_on_cl.ball_subset_image_closed_ball DiffContOnCl.ball_subset_image_closedBall
| Mathlib/Analysis/Complex/OpenMapping.lean | 77 | 106 | theorem AnalyticAt.eventually_constant_or_nhds_le_map_nhds_aux (hf : AnalyticAt ℂ f z₀) :
(∀ᶠ z in 𝓝 z₀, f z = f z₀) ∨ 𝓝 (f z₀) ≤ map f (𝓝 z₀) := by |
/- The function `f` is analytic in a neighborhood of `z₀`; by the isolated zeros principle, if `f`
is not constant in a neighborhood of `z₀`, then it is nonzero, and therefore bounded below, on
every small enough circle around `z₀` and then `DiffContOnCl.ball_subset_image_closedBall`
provides an explicit ball centered at `f z₀` contained in the range of `f`. -/
refine or_iff_not_imp_left.mpr fun h => ?_
refine (nhds_basis_ball.le_basis_iff (nhds_basis_closedBall.map f)).mpr fun R hR => ?_
have h1 := (hf.eventually_eq_or_eventually_ne analyticAt_const).resolve_left h
have h2 : ∀ᶠ z in 𝓝 z₀, AnalyticAt ℂ f z := (isOpen_analyticAt ℂ f).eventually_mem hf
obtain ⟨ρ, hρ, h3, h4⟩ :
∃ ρ > 0, AnalyticOn ℂ f (closedBall z₀ ρ) ∧ ∀ z ∈ closedBall z₀ ρ, z ≠ z₀ → f z ≠ f z₀ := by
simpa only [setOf_and, subset_inter_iff] using
nhds_basis_closedBall.mem_iff.mp (h2.and (eventually_nhdsWithin_iff.mp h1))
replace h3 : DiffContOnCl ℂ f (ball z₀ ρ) :=
⟨h3.differentiableOn.mono ball_subset_closedBall,
(closure_ball z₀ hρ.lt.ne.symm).symm ▸ h3.continuousOn⟩
let r := ρ ⊓ R
have hr : 0 < r := lt_inf_iff.mpr ⟨hρ, hR⟩
have h5 : closedBall z₀ r ⊆ closedBall z₀ ρ := closedBall_subset_closedBall inf_le_left
have h6 : DiffContOnCl ℂ f (ball z₀ r) := h3.mono (ball_subset_ball inf_le_left)
have h7 : ∀ z ∈ sphere z₀ r, f z ≠ f z₀ := fun z hz =>
h4 z (h5 (sphere_subset_closedBall hz)) (ne_of_mem_sphere hz hr.ne.symm)
have h8 : (sphere z₀ r).Nonempty := NormedSpace.sphere_nonempty.mpr hr.le
have h9 : ContinuousOn (fun x => ‖f x - f z₀‖) (sphere z₀ r) := continuous_norm.comp_continuousOn
((h6.sub_const (f z₀)).continuousOn_ball.mono sphere_subset_closedBall)
obtain ⟨x, hx, hfx⟩ := (isCompact_sphere z₀ r).exists_isMinOn h8 h9
refine ⟨‖f x - f z₀‖ / 2, half_pos (norm_sub_pos_iff.mpr (h7 x hx)), ?_⟩
exact (h6.ball_subset_image_closedBall hr (fun z hz => hfx hz) (not_eventually.mp h)).trans
(image_subset f (closedBall_subset_closedBall inf_le_right))
|
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Finset.Sort
import Mathlib.Data.Set.Subsingleton
#align_import combinatorics.composition from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"
open List
variable {n : ℕ}
@[ext]
structure Composition (n : ℕ) where
blocks : List ℕ
blocks_pos : ∀ {i}, i ∈ blocks → 0 < i
blocks_sum : blocks.sum = n
#align composition Composition
@[ext]
structure CompositionAsSet (n : ℕ) where
boundaries : Finset (Fin n.succ)
zero_mem : (0 : Fin n.succ) ∈ boundaries
getLast_mem : Fin.last n ∈ boundaries
#align composition_as_set CompositionAsSet
instance {n : ℕ} : Inhabited (CompositionAsSet n) :=
⟨⟨Finset.univ, Finset.mem_univ _, Finset.mem_univ _⟩⟩
namespace Composition
variable (c : Composition n)
instance (n : ℕ) : ToString (Composition n) :=
⟨fun c => toString c.blocks⟩
abbrev length : ℕ :=
c.blocks.length
#align composition.length Composition.length
theorem blocks_length : c.blocks.length = c.length :=
rfl
#align composition.blocks_length Composition.blocks_length
def blocksFun : Fin c.length → ℕ := c.blocks.get
#align composition.blocks_fun Composition.blocksFun
theorem ofFn_blocksFun : ofFn c.blocksFun = c.blocks :=
ofFn_get _
#align composition.of_fn_blocks_fun Composition.ofFn_blocksFun
theorem sum_blocksFun : ∑ i, c.blocksFun i = n := by
conv_rhs => rw [← c.blocks_sum, ← ofFn_blocksFun, sum_ofFn]
#align composition.sum_blocks_fun Composition.sum_blocksFun
theorem blocksFun_mem_blocks (i : Fin c.length) : c.blocksFun i ∈ c.blocks :=
get_mem _ _ _
#align composition.blocks_fun_mem_blocks Composition.blocksFun_mem_blocks
@[simp]
theorem one_le_blocks {i : ℕ} (h : i ∈ c.blocks) : 1 ≤ i :=
c.blocks_pos h
#align composition.one_le_blocks Composition.one_le_blocks
@[simp]
theorem one_le_blocks' {i : ℕ} (h : i < c.length) : 1 ≤ c.blocks.get ⟨i, h⟩ :=
c.one_le_blocks (get_mem (blocks c) i h)
#align composition.one_le_blocks' Composition.one_le_blocks'
@[simp]
theorem blocks_pos' (i : ℕ) (h : i < c.length) : 0 < c.blocks.get ⟨i, h⟩ :=
c.one_le_blocks' h
#align composition.blocks_pos' Composition.blocks_pos'
theorem one_le_blocksFun (i : Fin c.length) : 1 ≤ c.blocksFun i :=
c.one_le_blocks (c.blocksFun_mem_blocks i)
#align composition.one_le_blocks_fun Composition.one_le_blocksFun
theorem length_le : c.length ≤ n := by
conv_rhs => rw [← c.blocks_sum]
exact length_le_sum_of_one_le _ fun i hi => c.one_le_blocks hi
#align composition.length_le Composition.length_le
theorem length_pos_of_pos (h : 0 < n) : 0 < c.length := by
apply length_pos_of_sum_pos
convert h
exact c.blocks_sum
#align composition.length_pos_of_pos Composition.length_pos_of_pos
def sizeUpTo (i : ℕ) : ℕ :=
(c.blocks.take i).sum
#align composition.size_up_to Composition.sizeUpTo
@[simp]
theorem sizeUpTo_zero : c.sizeUpTo 0 = 0 := by simp [sizeUpTo]
#align composition.size_up_to_zero Composition.sizeUpTo_zero
theorem sizeUpTo_ofLength_le (i : ℕ) (h : c.length ≤ i) : c.sizeUpTo i = n := by
dsimp [sizeUpTo]
convert c.blocks_sum
exact take_all_of_le h
#align composition.size_up_to_of_length_le Composition.sizeUpTo_ofLength_le
@[simp]
theorem sizeUpTo_length : c.sizeUpTo c.length = n :=
c.sizeUpTo_ofLength_le c.length le_rfl
#align composition.size_up_to_length Composition.sizeUpTo_length
theorem sizeUpTo_le (i : ℕ) : c.sizeUpTo i ≤ n := by
conv_rhs => rw [← c.blocks_sum, ← sum_take_add_sum_drop _ i]
exact Nat.le_add_right _ _
#align composition.size_up_to_le Composition.sizeUpTo_le
theorem sizeUpTo_succ {i : ℕ} (h : i < c.length) :
c.sizeUpTo (i + 1) = c.sizeUpTo i + c.blocks.get ⟨i, h⟩ := by
simp only [sizeUpTo]
rw [sum_take_succ _ _ h]
#align composition.size_up_to_succ Composition.sizeUpTo_succ
theorem sizeUpTo_succ' (i : Fin c.length) :
c.sizeUpTo ((i : ℕ) + 1) = c.sizeUpTo i + c.blocksFun i :=
c.sizeUpTo_succ i.2
#align composition.size_up_to_succ' Composition.sizeUpTo_succ'
theorem sizeUpTo_strict_mono {i : ℕ} (h : i < c.length) : c.sizeUpTo i < c.sizeUpTo (i + 1) := by
rw [c.sizeUpTo_succ h]
simp
#align composition.size_up_to_strict_mono Composition.sizeUpTo_strict_mono
theorem monotone_sizeUpTo : Monotone c.sizeUpTo :=
monotone_sum_take _
#align composition.monotone_size_up_to Composition.monotone_sizeUpTo
def boundary : Fin (c.length + 1) ↪o Fin (n + 1) :=
(OrderEmbedding.ofStrictMono fun i => ⟨c.sizeUpTo i, Nat.lt_succ_of_le (c.sizeUpTo_le i)⟩) <|
Fin.strictMono_iff_lt_succ.2 fun ⟨_, hi⟩ => c.sizeUpTo_strict_mono hi
#align composition.boundary Composition.boundary
@[simp]
theorem boundary_zero : c.boundary 0 = 0 := by simp [boundary, Fin.ext_iff]
#align composition.boundary_zero Composition.boundary_zero
@[simp]
theorem boundary_last : c.boundary (Fin.last c.length) = Fin.last n := by
simp [boundary, Fin.ext_iff]
#align composition.boundary_last Composition.boundary_last
def boundaries : Finset (Fin (n + 1)) :=
Finset.univ.map c.boundary.toEmbedding
#align composition.boundaries Composition.boundaries
theorem card_boundaries_eq_succ_length : c.boundaries.card = c.length + 1 := by simp [boundaries]
#align composition.card_boundaries_eq_succ_length Composition.card_boundaries_eq_succ_length
def toCompositionAsSet : CompositionAsSet n where
boundaries := c.boundaries
zero_mem := by
simp only [boundaries, Finset.mem_univ, exists_prop_of_true, Finset.mem_map]
exact ⟨0, And.intro True.intro rfl⟩
getLast_mem := by
simp only [boundaries, Finset.mem_univ, exists_prop_of_true, Finset.mem_map]
exact ⟨Fin.last c.length, And.intro True.intro c.boundary_last⟩
#align composition.to_composition_as_set Composition.toCompositionAsSet
theorem orderEmbOfFin_boundaries :
c.boundaries.orderEmbOfFin c.card_boundaries_eq_succ_length = c.boundary := by
refine (Finset.orderEmbOfFin_unique' _ ?_).symm
exact fun i => (Finset.mem_map' _).2 (Finset.mem_univ _)
#align composition.order_emb_of_fin_boundaries Composition.orderEmbOfFin_boundaries
def embedding (i : Fin c.length) : Fin (c.blocksFun i) ↪o Fin n :=
(Fin.natAddOrderEmb <| c.sizeUpTo i).trans <| Fin.castLEOrderEmb <|
calc
c.sizeUpTo i + c.blocksFun i = c.sizeUpTo (i + 1) := (c.sizeUpTo_succ _).symm
_ ≤ c.sizeUpTo c.length := monotone_sum_take _ i.2
_ = n := c.sizeUpTo_length
#align composition.embedding Composition.embedding
@[simp]
theorem coe_embedding (i : Fin c.length) (j : Fin (c.blocksFun i)) :
(c.embedding i j : ℕ) = c.sizeUpTo i + j :=
rfl
#align composition.coe_embedding Composition.coe_embedding
theorem index_exists {j : ℕ} (h : j < n) : ∃ i : ℕ, j < c.sizeUpTo (i + 1) ∧ i < c.length := by
have n_pos : 0 < n := lt_of_le_of_lt (zero_le j) h
have : 0 < c.blocks.sum := by rwa [← c.blocks_sum] at n_pos
have length_pos : 0 < c.blocks.length := length_pos_of_sum_pos (blocks c) this
refine ⟨c.length - 1, ?_, Nat.pred_lt (ne_of_gt length_pos)⟩
have : c.length - 1 + 1 = c.length := Nat.succ_pred_eq_of_pos length_pos
simp [this, h]
#align composition.index_exists Composition.index_exists
def index (j : Fin n) : Fin c.length :=
⟨Nat.find (c.index_exists j.2), (Nat.find_spec (c.index_exists j.2)).2⟩
#align composition.index Composition.index
theorem lt_sizeUpTo_index_succ (j : Fin n) : (j : ℕ) < c.sizeUpTo (c.index j).succ :=
(Nat.find_spec (c.index_exists j.2)).1
#align composition.lt_size_up_to_index_succ Composition.lt_sizeUpTo_index_succ
theorem sizeUpTo_index_le (j : Fin n) : c.sizeUpTo (c.index j) ≤ j := by
by_contra H
set i := c.index j
push_neg at H
have i_pos : (0 : ℕ) < i := by
by_contra! i_pos
revert H
simp [nonpos_iff_eq_zero.1 i_pos, c.sizeUpTo_zero]
let i₁ := (i : ℕ).pred
have i₁_lt_i : i₁ < i := Nat.pred_lt (ne_of_gt i_pos)
have i₁_succ : i₁ + 1 = i := Nat.succ_pred_eq_of_pos i_pos
have := Nat.find_min (c.index_exists j.2) i₁_lt_i
simp [lt_trans i₁_lt_i (c.index j).2, i₁_succ] at this
exact Nat.lt_le_asymm H this
#align composition.size_up_to_index_le Composition.sizeUpTo_index_le
def invEmbedding (j : Fin n) : Fin (c.blocksFun (c.index j)) :=
⟨j - c.sizeUpTo (c.index j), by
rw [tsub_lt_iff_right, add_comm, ← sizeUpTo_succ']
· exact lt_sizeUpTo_index_succ _ _
· exact sizeUpTo_index_le _ _⟩
#align composition.inv_embedding Composition.invEmbedding
@[simp]
theorem coe_invEmbedding (j : Fin n) : (c.invEmbedding j : ℕ) = j - c.sizeUpTo (c.index j) :=
rfl
#align composition.coe_inv_embedding Composition.coe_invEmbedding
theorem embedding_comp_inv (j : Fin n) : c.embedding (c.index j) (c.invEmbedding j) = j := by
rw [Fin.ext_iff]
apply add_tsub_cancel_of_le (c.sizeUpTo_index_le j)
#align composition.embedding_comp_inv Composition.embedding_comp_inv
theorem mem_range_embedding_iff {j : Fin n} {i : Fin c.length} :
j ∈ Set.range (c.embedding i) ↔ c.sizeUpTo i ≤ j ∧ (j : ℕ) < c.sizeUpTo (i : ℕ).succ := by
constructor
· intro h
rcases Set.mem_range.2 h with ⟨k, hk⟩
rw [Fin.ext_iff] at hk
dsimp at hk
rw [← hk]
simp [sizeUpTo_succ', k.is_lt]
· intro h
apply Set.mem_range.2
refine ⟨⟨j - c.sizeUpTo i, ?_⟩, ?_⟩
· rw [tsub_lt_iff_left, ← sizeUpTo_succ']
· exact h.2
· exact h.1
· rw [Fin.ext_iff]
exact add_tsub_cancel_of_le h.1
#align composition.mem_range_embedding_iff Composition.mem_range_embedding_iff
theorem disjoint_range {i₁ i₂ : Fin c.length} (h : i₁ ≠ i₂) :
Disjoint (Set.range (c.embedding i₁)) (Set.range (c.embedding i₂)) := by
classical
wlog h' : i₁ < i₂
· exact (this c h.symm (h.lt_or_lt.resolve_left h')).symm
by_contra d
obtain ⟨x, hx₁, hx₂⟩ :
∃ x : Fin n, x ∈ Set.range (c.embedding i₁) ∧ x ∈ Set.range (c.embedding i₂) :=
Set.not_disjoint_iff.1 d
have A : (i₁ : ℕ).succ ≤ i₂ := Nat.succ_le_of_lt h'
apply lt_irrefl (x : ℕ)
calc
(x : ℕ) < c.sizeUpTo (i₁ : ℕ).succ := (c.mem_range_embedding_iff.1 hx₁).2
_ ≤ c.sizeUpTo (i₂ : ℕ) := monotone_sum_take _ A
_ ≤ x := (c.mem_range_embedding_iff.1 hx₂).1
#align composition.disjoint_range Composition.disjoint_range
theorem mem_range_embedding (j : Fin n) : j ∈ Set.range (c.embedding (c.index j)) := by
have : c.embedding (c.index j) (c.invEmbedding j) ∈ Set.range (c.embedding (c.index j)) :=
Set.mem_range_self _
rwa [c.embedding_comp_inv j] at this
#align composition.mem_range_embedding Composition.mem_range_embedding
theorem mem_range_embedding_iff' {j : Fin n} {i : Fin c.length} :
j ∈ Set.range (c.embedding i) ↔ i = c.index j := by
constructor
· rw [← not_imp_not]
intro h
exact Set.disjoint_right.1 (c.disjoint_range h) (c.mem_range_embedding j)
· intro h
rw [h]
exact c.mem_range_embedding j
#align composition.mem_range_embedding_iff' Composition.mem_range_embedding_iff'
theorem index_embedding (i : Fin c.length) (j : Fin (c.blocksFun i)) :
c.index (c.embedding i j) = i := by
symm
rw [← mem_range_embedding_iff']
apply Set.mem_range_self
#align composition.index_embedding Composition.index_embedding
theorem invEmbedding_comp (i : Fin c.length) (j : Fin (c.blocksFun i)) :
(c.invEmbedding (c.embedding i j) : ℕ) = j := by
simp_rw [coe_invEmbedding, index_embedding, coe_embedding, add_tsub_cancel_left]
#align composition.inv_embedding_comp Composition.invEmbedding_comp
def blocksFinEquiv : (Σi : Fin c.length, Fin (c.blocksFun i)) ≃ Fin n where
toFun x := c.embedding x.1 x.2
invFun j := ⟨c.index j, c.invEmbedding j⟩
left_inv x := by
rcases x with ⟨i, y⟩
dsimp
congr; · exact c.index_embedding _ _
rw [Fin.heq_ext_iff]
· exact c.invEmbedding_comp _ _
· rw [c.index_embedding]
right_inv j := c.embedding_comp_inv j
#align composition.blocks_fin_equiv Composition.blocksFinEquiv
theorem blocksFun_congr {n₁ n₂ : ℕ} (c₁ : Composition n₁) (c₂ : Composition n₂) (i₁ : Fin c₁.length)
(i₂ : Fin c₂.length) (hn : n₁ = n₂) (hc : c₁.blocks = c₂.blocks) (hi : (i₁ : ℕ) = i₂) :
c₁.blocksFun i₁ = c₂.blocksFun i₂ := by
cases hn
rw [← Composition.ext_iff] at hc
cases hc
congr
rwa [Fin.ext_iff]
#align composition.blocks_fun_congr Composition.blocksFun_congr
theorem sigma_eq_iff_blocks_eq {c : Σn, Composition n} {c' : Σn, Composition n} :
c = c' ↔ c.2.blocks = c'.2.blocks := by
refine ⟨fun H => by rw [H], fun H => ?_⟩
rcases c with ⟨n, c⟩
rcases c' with ⟨n', c'⟩
have : n = n' := by rw [← c.blocks_sum, ← c'.blocks_sum, H]
induction this
congr
ext1
exact H
#align composition.sigma_eq_iff_blocks_eq Composition.sigma_eq_iff_blocks_eq
def ones (n : ℕ) : Composition n :=
⟨replicate n (1 : ℕ), fun {i} hi => by simp [List.eq_of_mem_replicate hi], by simp⟩
#align composition.ones Composition.ones
instance {n : ℕ} : Inhabited (Composition n) :=
⟨Composition.ones n⟩
@[simp]
theorem ones_length (n : ℕ) : (ones n).length = n :=
List.length_replicate n 1
#align composition.ones_length Composition.ones_length
@[simp]
theorem ones_blocks (n : ℕ) : (ones n).blocks = replicate n (1 : ℕ) :=
rfl
#align composition.ones_blocks Composition.ones_blocks
@[simp]
theorem ones_blocksFun (n : ℕ) (i : Fin (ones n).length) : (ones n).blocksFun i = 1 := by
simp only [blocksFun, ones, blocks, i.2, List.get_replicate]
#align composition.ones_blocks_fun Composition.ones_blocksFun
@[simp]
theorem ones_sizeUpTo (n : ℕ) (i : ℕ) : (ones n).sizeUpTo i = min i n := by
simp [sizeUpTo, ones_blocks, take_replicate]
#align composition.ones_size_up_to Composition.ones_sizeUpTo
@[simp]
theorem ones_embedding (i : Fin (ones n).length) (h : 0 < (ones n).blocksFun i) :
(ones n).embedding i ⟨0, h⟩ = ⟨i, lt_of_lt_of_le i.2 (ones n).length_le⟩ := by
ext
simpa using i.2.le
#align composition.ones_embedding Composition.ones_embedding
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
constructor
· rintro rfl
exact fun i => eq_of_mem_replicate
· intro H
ext1
have A : c.blocks = replicate c.blocks.length 1 := eq_replicate_of_mem H
have : c.blocks.length = n := by
conv_rhs => rw [← c.blocks_sum, A]
simp
rw [A, this, ones_blocks]
#align composition.eq_ones_iff Composition.eq_ones_iff
theorem ne_ones_iff {c : Composition n} : c ≠ ones n ↔ ∃ i ∈ c.blocks, 1 < i := by
refine (not_congr eq_ones_iff).trans ?_
have : ∀ j ∈ c.blocks, j = 1 ↔ j ≤ 1 := fun j hj => by simp [le_antisymm_iff, c.one_le_blocks hj]
simp (config := { contextual := true }) [this]
#align composition.ne_ones_iff Composition.ne_ones_iff
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
constructor
· rintro rfl
exact ones_length n
· contrapose
intro H length_n
apply lt_irrefl n
calc
n = ∑ i : Fin c.length, 1 := by simp [length_n]
_ < ∑ i : Fin c.length, c.blocksFun i := by
{
obtain ⟨i, hi, i_blocks⟩ : ∃ i ∈ c.blocks, 1 < i := ne_ones_iff.1 H
rw [← ofFn_blocksFun, mem_ofFn c.blocksFun, Set.mem_range] at hi
obtain ⟨j : Fin c.length, hj : c.blocksFun j = i⟩ := hi
rw [← hj] at i_blocks
exact Finset.sum_lt_sum (fun i _ => one_le_blocksFun c i) ⟨j, Finset.mem_univ _, i_blocks⟩
}
_ = n := c.sum_blocksFun
#align composition.eq_ones_iff_length Composition.eq_ones_iff_length
theorem eq_ones_iff_le_length {c : Composition n} : c = ones n ↔ n ≤ c.length := by
simp [eq_ones_iff_length, le_antisymm_iff, c.length_le]
#align composition.eq_ones_iff_le_length Composition.eq_ones_iff_le_length
def single (n : ℕ) (h : 0 < n) : Composition n :=
⟨[n], by simp [h], by simp⟩
#align composition.single Composition.single
@[simp]
theorem single_length {n : ℕ} (h : 0 < n) : (single n h).length = 1 :=
rfl
#align composition.single_length Composition.single_length
@[simp]
theorem single_blocks {n : ℕ} (h : 0 < n) : (single n h).blocks = [n] :=
rfl
#align composition.single_blocks Composition.single_blocks
@[simp]
theorem single_blocksFun {n : ℕ} (h : 0 < n) (i : Fin (single n h).length) :
(single n h).blocksFun i = n := by simp [blocksFun, single, blocks, i.2]
#align composition.single_blocks_fun Composition.single_blocksFun
@[simp]
theorem single_embedding {n : ℕ} (h : 0 < n) (i : Fin n) :
((single n h).embedding (0 : Fin 1)) i = i := by
ext
simp
#align composition.single_embedding Composition.single_embedding
| Mathlib/Combinatorics/Enumerative/Composition.lean | 577 | 588 | theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
c = single n h ↔ c.length = 1 := by |
constructor
· intro H
rw [H]
exact single_length h
· intro H
ext1
have A : c.blocks.length = 1 := H ▸ c.blocks_length
have B : c.blocks.sum = n := c.blocks_sum
rw [eq_cons_of_length_one A] at B ⊢
simpa [single_blocks] using B
|
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.MeasureTheory.Function.SimpleFunc
import Mathlib.MeasureTheory.Measure.MutuallySingular
import Mathlib.MeasureTheory.Measure.Count
import Mathlib.Topology.IndicatorConstPointwise
import Mathlib.MeasureTheory.Constructions.BorelSpace.Real
#align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
assert_not_exists NormedSpace
set_option autoImplicit true
noncomputable section
open Set hiding restrict restrict_apply
open Filter ENNReal
open Function (support)
open scoped Classical
open Topology NNReal ENNReal MeasureTheory
namespace MeasureTheory
local infixr:25 " →ₛ " => SimpleFunc
variable {α β γ δ : Type*}
section Lintegral
open SimpleFunc
variable {m : MeasurableSpace α} {μ ν : Measure α}
irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ :=
⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ
#align measure_theory.lintegral MeasureTheory.lintegral
@[inherit_doc MeasureTheory.lintegral]
notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r
@[inherit_doc MeasureTheory.lintegral]
notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r
@[inherit_doc MeasureTheory.lintegral]
notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r
@[inherit_doc MeasureTheory.lintegral]
notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r
theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) :
∫⁻ a, f a ∂μ = f.lintegral μ := by
rw [MeasureTheory.lintegral]
exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl)
(le_iSup₂_of_le f le_rfl le_rfl)
#align measure_theory.simple_func.lintegral_eq_lintegral MeasureTheory.SimpleFunc.lintegral_eq_lintegral
@[mono]
theorem lintegral_mono' {m : MeasurableSpace α} ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) ⦃f g : α → ℝ≥0∞⦄
(hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂ν := by
rw [lintegral, lintegral]
exact iSup_mono fun φ => iSup_mono' fun hφ => ⟨le_trans hφ hfg, lintegral_mono (le_refl φ) hμν⟩
#align measure_theory.lintegral_mono' MeasureTheory.lintegral_mono'
-- workaround for the known eta-reduction issue with `@[gcongr]`
@[gcongr] theorem lintegral_mono_fn' ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) (h2 : μ ≤ ν) :
lintegral μ f ≤ lintegral ν g :=
lintegral_mono' h2 hfg
theorem lintegral_mono ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ :=
lintegral_mono' (le_refl μ) hfg
#align measure_theory.lintegral_mono MeasureTheory.lintegral_mono
-- workaround for the known eta-reduction issue with `@[gcongr]`
@[gcongr] theorem lintegral_mono_fn ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) :
lintegral μ f ≤ lintegral μ g :=
lintegral_mono hfg
theorem lintegral_mono_nnreal {f g : α → ℝ≥0} (h : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ :=
lintegral_mono fun a => ENNReal.coe_le_coe.2 (h a)
#align measure_theory.lintegral_mono_nnreal MeasureTheory.lintegral_mono_nnreal
theorem iSup_lintegral_measurable_le_eq_lintegral (f : α → ℝ≥0∞) :
⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ a, g a ∂μ = ∫⁻ a, f a ∂μ := by
apply le_antisymm
· exact iSup_le fun i => iSup_le fun _ => iSup_le fun h'i => lintegral_mono h'i
· rw [lintegral]
refine iSup₂_le fun i hi => le_iSup₂_of_le i i.measurable <| le_iSup_of_le hi ?_
exact le_of_eq (i.lintegral_eq_lintegral _).symm
#align measure_theory.supr_lintegral_measurable_le_eq_lintegral MeasureTheory.iSup_lintegral_measurable_le_eq_lintegral
theorem lintegral_mono_set {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞}
(hst : s ⊆ t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ :=
lintegral_mono' (Measure.restrict_mono hst (le_refl μ)) (le_refl f)
#align measure_theory.lintegral_mono_set MeasureTheory.lintegral_mono_set
theorem lintegral_mono_set' {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞}
(hst : s ≤ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ :=
lintegral_mono' (Measure.restrict_mono' hst (le_refl μ)) (le_refl f)
#align measure_theory.lintegral_mono_set' MeasureTheory.lintegral_mono_set'
theorem monotone_lintegral {_ : MeasurableSpace α} (μ : Measure α) : Monotone (lintegral μ) :=
lintegral_mono
#align measure_theory.monotone_lintegral MeasureTheory.monotone_lintegral
@[simp]
theorem lintegral_const (c : ℝ≥0∞) : ∫⁻ _, c ∂μ = c * μ univ := by
rw [← SimpleFunc.const_lintegral, ← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_const]
rfl
#align measure_theory.lintegral_const MeasureTheory.lintegral_const
theorem lintegral_zero : ∫⁻ _ : α, 0 ∂μ = 0 := by simp
#align measure_theory.lintegral_zero MeasureTheory.lintegral_zero
theorem lintegral_zero_fun : lintegral μ (0 : α → ℝ≥0∞) = 0 :=
lintegral_zero
#align measure_theory.lintegral_zero_fun MeasureTheory.lintegral_zero_fun
-- @[simp] -- Porting note (#10618): simp can prove this
theorem lintegral_one : ∫⁻ _, (1 : ℝ≥0∞) ∂μ = μ univ := by rw [lintegral_const, one_mul]
#align measure_theory.lintegral_one MeasureTheory.lintegral_one
theorem set_lintegral_const (s : Set α) (c : ℝ≥0∞) : ∫⁻ _ in s, c ∂μ = c * μ s := by
rw [lintegral_const, Measure.restrict_apply_univ]
#align measure_theory.set_lintegral_const MeasureTheory.set_lintegral_const
theorem set_lintegral_one (s) : ∫⁻ _ in s, 1 ∂μ = μ s := by rw [set_lintegral_const, one_mul]
#align measure_theory.set_lintegral_one MeasureTheory.set_lintegral_one
theorem set_lintegral_const_lt_top [IsFiniteMeasure μ] (s : Set α) {c : ℝ≥0∞} (hc : c ≠ ∞) :
∫⁻ _ in s, c ∂μ < ∞ := by
rw [lintegral_const]
exact ENNReal.mul_lt_top hc (measure_ne_top (μ.restrict s) univ)
#align measure_theory.set_lintegral_const_lt_top MeasureTheory.set_lintegral_const_lt_top
theorem lintegral_const_lt_top [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _, c ∂μ < ∞ := by
simpa only [Measure.restrict_univ] using set_lintegral_const_lt_top (univ : Set α) hc
#align measure_theory.lintegral_const_lt_top MeasureTheory.lintegral_const_lt_top
section
variable (μ)
theorem exists_measurable_le_lintegral_eq (f : α → ℝ≥0∞) :
∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by
rcases eq_or_ne (∫⁻ a, f a ∂μ) 0 with h₀ | h₀
· exact ⟨0, measurable_zero, zero_le f, h₀.trans lintegral_zero.symm⟩
rcases exists_seq_strictMono_tendsto' h₀.bot_lt with ⟨L, _, hLf, hL_tendsto⟩
have : ∀ n, ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ L n < ∫⁻ a, g a ∂μ := by
intro n
simpa only [← iSup_lintegral_measurable_le_eq_lintegral f, lt_iSup_iff, exists_prop] using
(hLf n).2
choose g hgm hgf hLg using this
refine
⟨fun x => ⨆ n, g n x, measurable_iSup hgm, fun x => iSup_le fun n => hgf n x, le_antisymm ?_ ?_⟩
· refine le_of_tendsto' hL_tendsto fun n => (hLg n).le.trans <| lintegral_mono fun x => ?_
exact le_iSup (fun n => g n x) n
· exact lintegral_mono fun x => iSup_le fun n => hgf n x
#align measure_theory.exists_measurable_le_lintegral_eq MeasureTheory.exists_measurable_le_lintegral_eq
end
theorem lintegral_eq_nnreal {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : Measure α) :
∫⁻ a, f a ∂μ =
⨆ (φ : α →ₛ ℝ≥0) (_ : ∀ x, ↑(φ x) ≤ f x), (φ.map ((↑) : ℝ≥0 → ℝ≥0∞)).lintegral μ := by
rw [lintegral]
refine
le_antisymm (iSup₂_le fun φ hφ => ?_) (iSup_mono' fun φ => ⟨φ.map ((↑) : ℝ≥0 → ℝ≥0∞), le_rfl⟩)
by_cases h : ∀ᵐ a ∂μ, φ a ≠ ∞
· let ψ := φ.map ENNReal.toNNReal
replace h : ψ.map ((↑) : ℝ≥0 → ℝ≥0∞) =ᵐ[μ] φ := h.mono fun a => ENNReal.coe_toNNReal
have : ∀ x, ↑(ψ x) ≤ f x := fun x => le_trans ENNReal.coe_toNNReal_le_self (hφ x)
exact
le_iSup_of_le (φ.map ENNReal.toNNReal) (le_iSup_of_le this (ge_of_eq <| lintegral_congr h))
· have h_meas : μ (φ ⁻¹' {∞}) ≠ 0 := mt measure_zero_iff_ae_nmem.1 h
refine le_trans le_top (ge_of_eq <| (iSup_eq_top _).2 fun b hb => ?_)
obtain ⟨n, hn⟩ : ∃ n : ℕ, b < n * μ (φ ⁻¹' {∞}) := exists_nat_mul_gt h_meas (ne_of_lt hb)
use (const α (n : ℝ≥0)).restrict (φ ⁻¹' {∞})
simp only [lt_iSup_iff, exists_prop, coe_restrict, φ.measurableSet_preimage, coe_const,
ENNReal.coe_indicator, map_coe_ennreal_restrict, SimpleFunc.map_const, ENNReal.coe_natCast,
restrict_const_lintegral]
refine ⟨indicator_le fun x hx => le_trans ?_ (hφ _), hn⟩
simp only [mem_preimage, mem_singleton_iff] at hx
simp only [hx, le_top]
#align measure_theory.lintegral_eq_nnreal MeasureTheory.lintegral_eq_nnreal
theorem exists_simpleFunc_forall_lintegral_sub_lt_of_pos {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞)
{ε : ℝ≥0∞} (hε : ε ≠ 0) :
∃ φ : α →ₛ ℝ≥0,
(∀ x, ↑(φ x) ≤ f x) ∧
∀ ψ : α →ₛ ℝ≥0, (∀ x, ↑(ψ x) ≤ f x) → (map (↑) (ψ - φ)).lintegral μ < ε := by
rw [lintegral_eq_nnreal] at h
have := ENNReal.lt_add_right h hε
erw [ENNReal.biSup_add] at this <;> [skip; exact ⟨0, fun x => zero_le _⟩]
simp_rw [lt_iSup_iff, iSup_lt_iff, iSup_le_iff] at this
rcases this with ⟨φ, hle : ∀ x, ↑(φ x) ≤ f x, b, hbφ, hb⟩
refine ⟨φ, hle, fun ψ hψ => ?_⟩
have : (map (↑) φ).lintegral μ ≠ ∞ := ne_top_of_le_ne_top h (by exact le_iSup₂ (α := ℝ≥0∞) φ hle)
rw [← ENNReal.add_lt_add_iff_left this, ← add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add]
refine (hb _ fun x => le_trans ?_ (max_le (hle x) (hψ x))).trans_lt hbφ
norm_cast
simp only [add_apply, sub_apply, add_tsub_eq_max]
rfl
#align measure_theory.exists_simple_func_forall_lintegral_sub_lt_of_pos MeasureTheory.exists_simpleFunc_forall_lintegral_sub_lt_of_pos
theorem iSup_lintegral_le {ι : Sort*} (f : ι → α → ℝ≥0∞) :
⨆ i, ∫⁻ a, f i a ∂μ ≤ ∫⁻ a, ⨆ i, f i a ∂μ := by
simp only [← iSup_apply]
exact (monotone_lintegral μ).le_map_iSup
#align measure_theory.supr_lintegral_le MeasureTheory.iSup_lintegral_le
theorem iSup₂_lintegral_le {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) :
⨆ (i) (j), ∫⁻ a, f i j a ∂μ ≤ ∫⁻ a, ⨆ (i) (j), f i j a ∂μ := by
convert (monotone_lintegral μ).le_map_iSup₂ f with a
simp only [iSup_apply]
#align measure_theory.supr₂_lintegral_le MeasureTheory.iSup₂_lintegral_le
theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) :
∫⁻ a, ⨅ i, f i a ∂μ ≤ ⨅ i, ∫⁻ a, f i a ∂μ := by
simp only [← iInf_apply]
exact (monotone_lintegral μ).map_iInf_le
#align measure_theory.le_infi_lintegral MeasureTheory.le_iInf_lintegral
theorem le_iInf₂_lintegral {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) :
∫⁻ a, ⨅ (i) (h : ι' i), f i h a ∂μ ≤ ⨅ (i) (h : ι' i), ∫⁻ a, f i h a ∂μ := by
convert (monotone_lintegral μ).map_iInf₂_le f with a
simp only [iInf_apply]
#align measure_theory.le_infi₂_lintegral MeasureTheory.le_iInf₂_lintegral
theorem lintegral_mono_ae {f g : α → ℝ≥0∞} (h : ∀ᵐ a ∂μ, f a ≤ g a) :
∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := by
rcases exists_measurable_superset_of_null h with ⟨t, hts, ht, ht0⟩
have : ∀ᵐ x ∂μ, x ∉ t := measure_zero_iff_ae_nmem.1 ht0
rw [lintegral, lintegral]
refine iSup_le fun s => iSup_le fun hfs => le_iSup_of_le (s.restrict tᶜ) <| le_iSup_of_le ?_ ?_
· intro a
by_cases h : a ∈ t <;>
simp only [restrict_apply s ht.compl, mem_compl_iff, h, not_true, not_false_eq_true,
indicator_of_not_mem, zero_le, not_false_eq_true, indicator_of_mem]
exact le_trans (hfs a) (_root_.by_contradiction fun hnfg => h (hts hnfg))
· refine le_of_eq (SimpleFunc.lintegral_congr <| this.mono fun a hnt => ?_)
by_cases hat : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, hat, not_true,
not_false_eq_true, indicator_of_not_mem, not_false_eq_true, indicator_of_mem]
exact (hnt hat).elim
#align measure_theory.lintegral_mono_ae MeasureTheory.lintegral_mono_ae
theorem set_lintegral_mono_ae {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
lintegral_mono_ae <| (ae_restrict_iff <| measurableSet_le hf hg).2 hfg
#align measure_theory.set_lintegral_mono_ae MeasureTheory.set_lintegral_mono_ae
theorem set_lintegral_mono {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g)
(hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
set_lintegral_mono_ae hf hg (ae_of_all _ hfg)
#align measure_theory.set_lintegral_mono MeasureTheory.set_lintegral_mono
theorem set_lintegral_mono_ae' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
lintegral_mono_ae <| (ae_restrict_iff' hs).2 hfg
theorem set_lintegral_mono' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s)
(hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
set_lintegral_mono_ae' hs (ae_of_all _ hfg)
theorem set_lintegral_le_lintegral (s : Set α) (f : α → ℝ≥0∞) :
∫⁻ x in s, f x ∂μ ≤ ∫⁻ x, f x ∂μ :=
lintegral_mono' Measure.restrict_le_self le_rfl
theorem lintegral_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ :=
le_antisymm (lintegral_mono_ae <| h.le) (lintegral_mono_ae <| h.symm.le)
#align measure_theory.lintegral_congr_ae MeasureTheory.lintegral_congr_ae
theorem lintegral_congr {f g : α → ℝ≥0∞} (h : ∀ a, f a = g a) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by
simp only [h]
#align measure_theory.lintegral_congr MeasureTheory.lintegral_congr
theorem set_lintegral_congr {f : α → ℝ≥0∞} {s t : Set α} (h : s =ᵐ[μ] t) :
∫⁻ x in s, f x ∂μ = ∫⁻ x in t, f x ∂μ := by rw [Measure.restrict_congr_set h]
#align measure_theory.set_lintegral_congr MeasureTheory.set_lintegral_congr
theorem set_lintegral_congr_fun {f g : α → ℝ≥0∞} {s : Set α} (hs : MeasurableSet s)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ := by
rw [lintegral_congr_ae]
rw [EventuallyEq]
rwa [ae_restrict_iff' hs]
#align measure_theory.set_lintegral_congr_fun MeasureTheory.set_lintegral_congr_fun
theorem lintegral_ofReal_le_lintegral_nnnorm (f : α → ℝ) :
∫⁻ x, ENNReal.ofReal (f x) ∂μ ≤ ∫⁻ x, ‖f x‖₊ ∂μ := by
simp_rw [← ofReal_norm_eq_coe_nnnorm]
refine lintegral_mono fun x => ENNReal.ofReal_le_ofReal ?_
rw [Real.norm_eq_abs]
exact le_abs_self (f x)
#align measure_theory.lintegral_of_real_le_lintegral_nnnorm MeasureTheory.lintegral_ofReal_le_lintegral_nnnorm
theorem lintegral_nnnorm_eq_of_ae_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ᵐ[μ] f) :
∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by
apply lintegral_congr_ae
filter_upwards [h_nonneg] with x hx
rw [Real.nnnorm_of_nonneg hx, ENNReal.ofReal_eq_coe_nnreal hx]
#align measure_theory.lintegral_nnnorm_eq_of_ae_nonneg MeasureTheory.lintegral_nnnorm_eq_of_ae_nonneg
theorem lintegral_nnnorm_eq_of_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ f) :
∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ :=
lintegral_nnnorm_eq_of_ae_nonneg (Filter.eventually_of_forall h_nonneg)
#align measure_theory.lintegral_nnnorm_eq_of_nonneg MeasureTheory.lintegral_nnnorm_eq_of_nonneg
theorem lintegral_iSup {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : Monotone f) :
∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
set c : ℝ≥0 → ℝ≥0∞ := (↑)
set F := fun a : α => ⨆ n, f n a
refine le_antisymm ?_ (iSup_lintegral_le _)
rw [lintegral_eq_nnreal]
refine iSup_le fun s => iSup_le fun hsf => ?_
refine ENNReal.le_of_forall_lt_one_mul_le fun a ha => ?_
rcases ENNReal.lt_iff_exists_coe.1 ha with ⟨r, rfl, _⟩
have ha : r < 1 := ENNReal.coe_lt_coe.1 ha
let rs := s.map fun a => r * a
have eq_rs : rs.map c = (const α r : α →ₛ ℝ≥0∞) * map c s := rfl
have eq : ∀ p, rs.map c ⁻¹' {p} = ⋃ n, rs.map c ⁻¹' {p} ∩ { a | p ≤ f n a } := by
intro p
rw [← inter_iUnion]; nth_rw 1 [← inter_univ (map c rs ⁻¹' {p})]
refine Set.ext fun x => and_congr_right fun hx => true_iff_iff.2 ?_
by_cases p_eq : p = 0
· simp [p_eq]
simp only [coe_map, mem_preimage, Function.comp_apply, mem_singleton_iff] at hx
subst hx
have : r * s x ≠ 0 := by rwa [Ne, ← ENNReal.coe_eq_zero]
have : s x ≠ 0 := right_ne_zero_of_mul this
have : (rs.map c) x < ⨆ n : ℕ, f n x := by
refine lt_of_lt_of_le (ENNReal.coe_lt_coe.2 ?_) (hsf x)
suffices r * s x < 1 * s x by simpa
exact mul_lt_mul_of_pos_right ha (pos_iff_ne_zero.2 this)
rcases lt_iSup_iff.1 this with ⟨i, hi⟩
exact mem_iUnion.2 ⟨i, le_of_lt hi⟩
have mono : ∀ r : ℝ≥0∞, Monotone fun n => rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a } := by
intro r i j h
refine inter_subset_inter_right _ ?_
simp_rw [subset_def, mem_setOf]
intro x hx
exact le_trans hx (h_mono h x)
have h_meas : ∀ n, MeasurableSet {a : α | map c rs a ≤ f n a} := fun n =>
measurableSet_le (SimpleFunc.measurable _) (hf n)
calc
(r : ℝ≥0∞) * (s.map c).lintegral μ = ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r}) := by
rw [← const_mul_lintegral, eq_rs, SimpleFunc.lintegral]
_ = ∑ r ∈ (rs.map c).range, r * μ (⋃ n, rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by
simp only [(eq _).symm]
_ = ∑ r ∈ (rs.map c).range, ⨆ n, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) :=
(Finset.sum_congr rfl fun x _ => by
rw [measure_iUnion_eq_iSup (mono x).directed_le, ENNReal.mul_iSup])
_ = ⨆ n, ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by
refine ENNReal.finset_sum_iSup_nat fun p i j h ↦ ?_
gcongr _ * μ ?_
exact mono p h
_ ≤ ⨆ n : ℕ, ((rs.map c).restrict { a | (rs.map c) a ≤ f n a }).lintegral μ := by
gcongr with n
rw [restrict_lintegral _ (h_meas n)]
refine le_of_eq (Finset.sum_congr rfl fun r _ => ?_)
congr 2 with a
refine and_congr_right ?_
simp (config := { contextual := true })
_ ≤ ⨆ n, ∫⁻ a, f n a ∂μ := by
simp only [← SimpleFunc.lintegral_eq_lintegral]
gcongr with n a
simp only [map_apply] at h_meas
simp only [coe_map, restrict_apply _ (h_meas _), (· ∘ ·)]
exact indicator_apply_le id
#align measure_theory.lintegral_supr MeasureTheory.lintegral_iSup
theorem lintegral_iSup' {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ)
(h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
simp_rw [← iSup_apply]
let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Monotone f'
have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_mono
have h_ae_seq_mono : Monotone (aeSeq hf p) := by
intro n m hnm x
by_cases hx : x ∈ aeSeqSet hf p
· exact aeSeq.prop_of_mem_aeSeqSet hf hx hnm
· simp only [aeSeq, hx, if_false, le_rfl]
rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm]
simp_rw [iSup_apply]
rw [lintegral_iSup (aeSeq.measurable hf p) h_ae_seq_mono]
congr with n
exact lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae hf hp n)
#align measure_theory.lintegral_supr' MeasureTheory.lintegral_iSup'
theorem lintegral_tendsto_of_tendsto_of_monotone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞}
(hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x)
(h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 <| F x)) :
Tendsto (fun n => ∫⁻ x, f n x ∂μ) atTop (𝓝 <| ∫⁻ x, F x ∂μ) := by
have : Monotone fun n => ∫⁻ x, f n x ∂μ := fun i j hij =>
lintegral_mono_ae (h_mono.mono fun x hx => hx hij)
suffices key : ∫⁻ x, F x ∂μ = ⨆ n, ∫⁻ x, f n x ∂μ by
rw [key]
exact tendsto_atTop_iSup this
rw [← lintegral_iSup' hf h_mono]
refine lintegral_congr_ae ?_
filter_upwards [h_mono, h_tendsto] with _ hx_mono hx_tendsto using
tendsto_nhds_unique hx_tendsto (tendsto_atTop_iSup hx_mono)
#align measure_theory.lintegral_tendsto_of_tendsto_of_monotone MeasureTheory.lintegral_tendsto_of_tendsto_of_monotone
theorem lintegral_eq_iSup_eapprox_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, f a ∂μ = ⨆ n, (eapprox f n).lintegral μ :=
calc
∫⁻ a, f a ∂μ = ∫⁻ a, ⨆ n, (eapprox f n : α → ℝ≥0∞) a ∂μ := by
congr; ext a; rw [iSup_eapprox_apply f hf]
_ = ⨆ n, ∫⁻ a, (eapprox f n : α → ℝ≥0∞) a ∂μ := by
apply lintegral_iSup
· measurability
· intro i j h
exact monotone_eapprox f h
_ = ⨆ n, (eapprox f n).lintegral μ := by
congr; ext n; rw [(eapprox f n).lintegral_eq_lintegral]
#align measure_theory.lintegral_eq_supr_eapprox_lintegral MeasureTheory.lintegral_eq_iSup_eapprox_lintegral
theorem exists_pos_set_lintegral_lt_of_measure_lt {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞}
(hε : ε ≠ 0) : ∃ δ > 0, ∀ s, μ s < δ → ∫⁻ x in s, f x ∂μ < ε := by
rcases exists_between (pos_iff_ne_zero.mpr hε) with ⟨ε₂, hε₂0, hε₂ε⟩
rcases exists_between hε₂0 with ⟨ε₁, hε₁0, hε₁₂⟩
rcases exists_simpleFunc_forall_lintegral_sub_lt_of_pos h hε₁0.ne' with ⟨φ, _, hφ⟩
rcases φ.exists_forall_le with ⟨C, hC⟩
use (ε₂ - ε₁) / C, ENNReal.div_pos_iff.2 ⟨(tsub_pos_iff_lt.2 hε₁₂).ne', ENNReal.coe_ne_top⟩
refine fun s hs => lt_of_le_of_lt ?_ hε₂ε
simp only [lintegral_eq_nnreal, iSup_le_iff]
intro ψ hψ
calc
(map (↑) ψ).lintegral (μ.restrict s) ≤
(map (↑) φ).lintegral (μ.restrict s) + (map (↑) (ψ - φ)).lintegral (μ.restrict s) := by
rw [← SimpleFunc.add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add]
refine SimpleFunc.lintegral_mono (fun x => ?_) le_rfl
simp only [add_tsub_eq_max, le_max_right, coe_map, Function.comp_apply, SimpleFunc.coe_add,
SimpleFunc.coe_sub, Pi.add_apply, Pi.sub_apply, ENNReal.coe_max (φ x) (ψ x)]
_ ≤ (map (↑) φ).lintegral (μ.restrict s) + ε₁ := by
gcongr
refine le_trans ?_ (hφ _ hψ).le
exact SimpleFunc.lintegral_mono le_rfl Measure.restrict_le_self
_ ≤ (SimpleFunc.const α (C : ℝ≥0∞)).lintegral (μ.restrict s) + ε₁ := by
gcongr
exact SimpleFunc.lintegral_mono (fun x ↦ ENNReal.coe_le_coe.2 (hC x)) le_rfl
_ = C * μ s + ε₁ := by
simp only [← SimpleFunc.lintegral_eq_lintegral, coe_const, lintegral_const,
Measure.restrict_apply, MeasurableSet.univ, univ_inter, Function.const]
_ ≤ C * ((ε₂ - ε₁) / C) + ε₁ := by gcongr
_ ≤ ε₂ - ε₁ + ε₁ := by gcongr; apply mul_div_le
_ = ε₂ := tsub_add_cancel_of_le hε₁₂.le
#align measure_theory.exists_pos_set_lintegral_lt_of_measure_lt MeasureTheory.exists_pos_set_lintegral_lt_of_measure_lt
theorem tendsto_set_lintegral_zero {ι} {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {l : Filter ι}
{s : ι → Set α} (hl : Tendsto (μ ∘ s) l (𝓝 0)) :
Tendsto (fun i => ∫⁻ x in s i, f x ∂μ) l (𝓝 0) := by
simp only [ENNReal.nhds_zero, tendsto_iInf, tendsto_principal, mem_Iio,
← pos_iff_ne_zero] at hl ⊢
intro ε ε0
rcases exists_pos_set_lintegral_lt_of_measure_lt h ε0.ne' with ⟨δ, δ0, hδ⟩
exact (hl δ δ0).mono fun i => hδ _
#align measure_theory.tendsto_set_lintegral_zero MeasureTheory.tendsto_set_lintegral_zero
theorem le_lintegral_add (f g : α → ℝ≥0∞) :
∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ ≤ ∫⁻ a, f a + g a ∂μ := by
simp only [lintegral]
refine ENNReal.biSup_add_biSup_le' (p := fun h : α →ₛ ℝ≥0∞ => h ≤ f)
(q := fun h : α →ₛ ℝ≥0∞ => h ≤ g) ⟨0, zero_le f⟩ ⟨0, zero_le g⟩ fun f' hf' g' hg' => ?_
exact le_iSup₂_of_le (f' + g') (add_le_add hf' hg') (add_lintegral _ _).ge
#align measure_theory.le_lintegral_add MeasureTheory.le_lintegral_add
-- Use stronger lemmas `lintegral_add_left`/`lintegral_add_right` instead
theorem lintegral_add_aux {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
calc
∫⁻ a, f a + g a ∂μ =
∫⁻ a, (⨆ n, (eapprox f n : α → ℝ≥0∞) a) + ⨆ n, (eapprox g n : α → ℝ≥0∞) a ∂μ := by
simp only [iSup_eapprox_apply, hf, hg]
_ = ∫⁻ a, ⨆ n, (eapprox f n + eapprox g n : α → ℝ≥0∞) a ∂μ := by
congr; funext a
rw [ENNReal.iSup_add_iSup_of_monotone]
· simp only [Pi.add_apply]
· intro i j h
exact monotone_eapprox _ h a
· intro i j h
exact monotone_eapprox _ h a
_ = ⨆ n, (eapprox f n).lintegral μ + (eapprox g n).lintegral μ := by
rw [lintegral_iSup]
· congr
funext n
rw [← SimpleFunc.add_lintegral, ← SimpleFunc.lintegral_eq_lintegral]
simp only [Pi.add_apply, SimpleFunc.coe_add]
· measurability
· intro i j h a
dsimp
gcongr <;> exact monotone_eapprox _ h _
_ = (⨆ n, (eapprox f n).lintegral μ) + ⨆ n, (eapprox g n).lintegral μ := by
refine (ENNReal.iSup_add_iSup_of_monotone ?_ ?_).symm <;>
· intro i j h
exact SimpleFunc.lintegral_mono (monotone_eapprox _ h) le_rfl
_ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
rw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral hg]
#align measure_theory.lintegral_add_aux MeasureTheory.lintegral_add_aux
@[simp]
theorem lintegral_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
refine le_antisymm ?_ (le_lintegral_add _ _)
rcases exists_measurable_le_lintegral_eq μ fun a => f a + g a with ⟨φ, hφm, hφ_le, hφ_eq⟩
calc
∫⁻ a, f a + g a ∂μ = ∫⁻ a, φ a ∂μ := hφ_eq
_ ≤ ∫⁻ a, f a + (φ a - f a) ∂μ := lintegral_mono fun a => le_add_tsub
_ = ∫⁻ a, f a ∂μ + ∫⁻ a, φ a - f a ∂μ := lintegral_add_aux hf (hφm.sub hf)
_ ≤ ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
add_le_add_left (lintegral_mono fun a => tsub_le_iff_left.2 <| hφ_le a) _
#align measure_theory.lintegral_add_left MeasureTheory.lintegral_add_left
theorem lintegral_add_left' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (g : α → ℝ≥0∞) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
rw [lintegral_congr_ae hf.ae_eq_mk, ← lintegral_add_left hf.measurable_mk,
lintegral_congr_ae (hf.ae_eq_mk.add (ae_eq_refl g))]
#align measure_theory.lintegral_add_left' MeasureTheory.lintegral_add_left'
theorem lintegral_add_right' (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : AEMeasurable g μ) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
simpa only [add_comm] using lintegral_add_left' hg f
#align measure_theory.lintegral_add_right' MeasureTheory.lintegral_add_right'
@[simp]
theorem lintegral_add_right (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : Measurable g) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
lintegral_add_right' f hg.aemeasurable
#align measure_theory.lintegral_add_right MeasureTheory.lintegral_add_right
@[simp]
theorem lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂c • μ = c * ∫⁻ a, f a ∂μ := by
simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_smul, ENNReal.mul_iSup, smul_eq_mul]
#align measure_theory.lintegral_smul_measure MeasureTheory.lintegral_smul_measure
lemma set_lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) (s : Set α) :
∫⁻ a in s, f a ∂(c • μ) = c * ∫⁻ a in s, f a ∂μ := by
rw [Measure.restrict_smul, lintegral_smul_measure]
@[simp]
theorem lintegral_sum_measure {m : MeasurableSpace α} {ι} (f : α → ℝ≥0∞) (μ : ι → Measure α) :
∫⁻ a, f a ∂Measure.sum μ = ∑' i, ∫⁻ a, f a ∂μ i := by
simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_sum, ENNReal.tsum_eq_iSup_sum]
rw [iSup_comm]
congr; funext s
induction' s using Finset.induction_on with i s hi hs
· simp
simp only [Finset.sum_insert hi, ← hs]
refine (ENNReal.iSup_add_iSup ?_).symm
intro φ ψ
exact
⟨⟨φ ⊔ ψ, fun x => sup_le (φ.2 x) (ψ.2 x)⟩,
add_le_add (SimpleFunc.lintegral_mono le_sup_left le_rfl)
(Finset.sum_le_sum fun j _ => SimpleFunc.lintegral_mono le_sup_right le_rfl)⟩
#align measure_theory.lintegral_sum_measure MeasureTheory.lintegral_sum_measure
theorem hasSum_lintegral_measure {ι} {_ : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : ι → Measure α) :
HasSum (fun i => ∫⁻ a, f a ∂μ i) (∫⁻ a, f a ∂Measure.sum μ) :=
(lintegral_sum_measure f μ).symm ▸ ENNReal.summable.hasSum
#align measure_theory.has_sum_lintegral_measure MeasureTheory.hasSum_lintegral_measure
@[simp]
theorem lintegral_add_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ ν : Measure α) :
∫⁻ a, f a ∂(μ + ν) = ∫⁻ a, f a ∂μ + ∫⁻ a, f a ∂ν := by
simpa [tsum_fintype] using lintegral_sum_measure f fun b => cond b μ ν
#align measure_theory.lintegral_add_measure MeasureTheory.lintegral_add_measure
@[simp]
theorem lintegral_finset_sum_measure {ι} {m : MeasurableSpace α} (s : Finset ι) (f : α → ℝ≥0∞)
(μ : ι → Measure α) : ∫⁻ a, f a ∂(∑ i ∈ s, μ i) = ∑ i ∈ s, ∫⁻ a, f a ∂μ i := by
rw [← Measure.sum_coe_finset, lintegral_sum_measure, ← Finset.tsum_subtype']
simp only [Finset.coe_sort_coe]
#align measure_theory.lintegral_finset_sum_measure MeasureTheory.lintegral_finset_sum_measure
@[simp]
theorem lintegral_zero_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) :
∫⁻ a, f a ∂(0 : Measure α) = 0 := by
simp [lintegral]
#align measure_theory.lintegral_zero_measure MeasureTheory.lintegral_zero_measure
@[simp]
theorem lintegral_of_isEmpty {α} [MeasurableSpace α] [IsEmpty α] (μ : Measure α) (f : α → ℝ≥0∞) :
∫⁻ x, f x ∂μ = 0 := by
have : Subsingleton (Measure α) := inferInstance
convert lintegral_zero_measure f
theorem set_lintegral_empty (f : α → ℝ≥0∞) : ∫⁻ x in ∅, f x ∂μ = 0 := by
rw [Measure.restrict_empty, lintegral_zero_measure]
#align measure_theory.set_lintegral_empty MeasureTheory.set_lintegral_empty
theorem set_lintegral_univ (f : α → ℝ≥0∞) : ∫⁻ x in univ, f x ∂μ = ∫⁻ x, f x ∂μ := by
rw [Measure.restrict_univ]
#align measure_theory.set_lintegral_univ MeasureTheory.set_lintegral_univ
theorem set_lintegral_measure_zero (s : Set α) (f : α → ℝ≥0∞) (hs' : μ s = 0) :
∫⁻ x in s, f x ∂μ = 0 := by
convert lintegral_zero_measure _
exact Measure.restrict_eq_zero.2 hs'
#align measure_theory.set_lintegral_measure_zero MeasureTheory.set_lintegral_measure_zero
theorem lintegral_finset_sum' (s : Finset β) {f : β → α → ℝ≥0∞}
(hf : ∀ b ∈ s, AEMeasurable (f b) μ) :
∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ := by
induction' s using Finset.induction_on with a s has ih
· simp
· simp only [Finset.sum_insert has]
rw [Finset.forall_mem_insert] at hf
rw [lintegral_add_left' hf.1, ih hf.2]
#align measure_theory.lintegral_finset_sum' MeasureTheory.lintegral_finset_sum'
theorem lintegral_finset_sum (s : Finset β) {f : β → α → ℝ≥0∞} (hf : ∀ b ∈ s, Measurable (f b)) :
∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ :=
lintegral_finset_sum' s fun b hb => (hf b hb).aemeasurable
#align measure_theory.lintegral_finset_sum MeasureTheory.lintegral_finset_sum
@[simp]
theorem lintegral_const_mul (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ :=
calc
∫⁻ a, r * f a ∂μ = ∫⁻ a, ⨆ n, (const α r * eapprox f n) a ∂μ := by
congr
funext a
rw [← iSup_eapprox_apply f hf, ENNReal.mul_iSup]
simp
_ = ⨆ n, r * (eapprox f n).lintegral μ := by
rw [lintegral_iSup]
· congr
funext n
rw [← SimpleFunc.const_mul_lintegral, ← SimpleFunc.lintegral_eq_lintegral]
· intro n
exact SimpleFunc.measurable _
· intro i j h a
exact mul_le_mul_left' (monotone_eapprox _ h _) _
_ = r * ∫⁻ a, f a ∂μ := by rw [← ENNReal.mul_iSup, lintegral_eq_iSup_eapprox_lintegral hf]
#align measure_theory.lintegral_const_mul MeasureTheory.lintegral_const_mul
theorem lintegral_const_mul'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) :
∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by
have A : ∫⁻ a, f a ∂μ = ∫⁻ a, hf.mk f a ∂μ := lintegral_congr_ae hf.ae_eq_mk
have B : ∫⁻ a, r * f a ∂μ = ∫⁻ a, r * hf.mk f a ∂μ :=
lintegral_congr_ae (EventuallyEq.fun_comp hf.ae_eq_mk _)
rw [A, B, lintegral_const_mul _ hf.measurable_mk]
#align measure_theory.lintegral_const_mul'' MeasureTheory.lintegral_const_mul''
theorem lintegral_const_mul_le (r : ℝ≥0∞) (f : α → ℝ≥0∞) :
r * ∫⁻ a, f a ∂μ ≤ ∫⁻ a, r * f a ∂μ := by
rw [lintegral, ENNReal.mul_iSup]
refine iSup_le fun s => ?_
rw [ENNReal.mul_iSup, iSup_le_iff]
intro hs
rw [← SimpleFunc.const_mul_lintegral, lintegral]
refine le_iSup_of_le (const α r * s) (le_iSup_of_le (fun x => ?_) le_rfl)
exact mul_le_mul_left' (hs x) _
#align measure_theory.lintegral_const_mul_le MeasureTheory.lintegral_const_mul_le
theorem lintegral_const_mul' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) :
∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by
by_cases h : r = 0
· simp [h]
apply le_antisymm _ (lintegral_const_mul_le r f)
have rinv : r * r⁻¹ = 1 := ENNReal.mul_inv_cancel h hr
have rinv' : r⁻¹ * r = 1 := by
rw [mul_comm]
exact rinv
have := lintegral_const_mul_le (μ := μ) r⁻¹ fun x => r * f x
simp? [(mul_assoc _ _ _).symm, rinv'] at this says
simp only [(mul_assoc _ _ _).symm, rinv', one_mul] at this
simpa [(mul_assoc _ _ _).symm, rinv] using mul_le_mul_left' this r
#align measure_theory.lintegral_const_mul' MeasureTheory.lintegral_const_mul'
theorem lintegral_mul_const (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul r hf]
#align measure_theory.lintegral_mul_const MeasureTheory.lintegral_mul_const
theorem lintegral_mul_const'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) :
∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul'' r hf]
#align measure_theory.lintegral_mul_const'' MeasureTheory.lintegral_mul_const''
theorem lintegral_mul_const_le (r : ℝ≥0∞) (f : α → ℝ≥0∞) :
(∫⁻ a, f a ∂μ) * r ≤ ∫⁻ a, f a * r ∂μ := by
simp_rw [mul_comm, lintegral_const_mul_le r f]
#align measure_theory.lintegral_mul_const_le MeasureTheory.lintegral_mul_const_le
theorem lintegral_mul_const' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) :
∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul' r f hr]
#align measure_theory.lintegral_mul_const' MeasureTheory.lintegral_mul_const'
theorem lintegral_lintegral_mul {β} [MeasurableSpace β] {ν : Measure β} {f : α → ℝ≥0∞}
{g : β → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g ν) :
∫⁻ x, ∫⁻ y, f x * g y ∂ν ∂μ = (∫⁻ x, f x ∂μ) * ∫⁻ y, g y ∂ν := by
simp [lintegral_const_mul'' _ hg, lintegral_mul_const'' _ hf]
#align measure_theory.lintegral_lintegral_mul MeasureTheory.lintegral_lintegral_mul
-- TODO: Need a better way of rewriting inside of an integral
theorem lintegral_rw₁ {f f' : α → β} (h : f =ᵐ[μ] f') (g : β → ℝ≥0∞) :
∫⁻ a, g (f a) ∂μ = ∫⁻ a, g (f' a) ∂μ :=
lintegral_congr_ae <| h.mono fun a h => by dsimp only; rw [h]
#align measure_theory.lintegral_rw₁ MeasureTheory.lintegral_rw₁
-- TODO: Need a better way of rewriting inside of an integral
theorem lintegral_rw₂ {f₁ f₁' : α → β} {f₂ f₂' : α → γ} (h₁ : f₁ =ᵐ[μ] f₁') (h₂ : f₂ =ᵐ[μ] f₂')
(g : β → γ → ℝ≥0∞) : ∫⁻ a, g (f₁ a) (f₂ a) ∂μ = ∫⁻ a, g (f₁' a) (f₂' a) ∂μ :=
lintegral_congr_ae <| h₁.mp <| h₂.mono fun _ h₂ h₁ => by dsimp only; rw [h₁, h₂]
#align measure_theory.lintegral_rw₂ MeasureTheory.lintegral_rw₂
theorem lintegral_indicator_le (f : α → ℝ≥0∞) (s : Set α) :
∫⁻ a, s.indicator f a ∂μ ≤ ∫⁻ a in s, f a ∂μ := by
simp only [lintegral]
apply iSup_le (fun g ↦ (iSup_le (fun hg ↦ ?_)))
have : g ≤ f := hg.trans (indicator_le_self s f)
refine le_iSup_of_le g (le_iSup_of_le this (le_of_eq ?_))
rw [lintegral_restrict, SimpleFunc.lintegral]
congr with t
by_cases H : t = 0
· simp [H]
congr with x
simp only [mem_preimage, mem_singleton_iff, mem_inter_iff, iff_self_and]
rintro rfl
contrapose! H
simpa [H] using hg x
@[simp]
theorem lintegral_indicator (f : α → ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
∫⁻ a, s.indicator f a ∂μ = ∫⁻ a in s, f a ∂μ := by
apply le_antisymm (lintegral_indicator_le f s)
simp only [lintegral, ← restrict_lintegral_eq_lintegral_restrict _ hs, iSup_subtype']
refine iSup_mono' (Subtype.forall.2 fun φ hφ => ?_)
refine ⟨⟨φ.restrict s, fun x => ?_⟩, le_rfl⟩
simp [hφ x, hs, indicator_le_indicator]
#align measure_theory.lintegral_indicator MeasureTheory.lintegral_indicator
theorem lintegral_indicator₀ (f : α → ℝ≥0∞) {s : Set α} (hs : NullMeasurableSet s μ) :
∫⁻ a, s.indicator f a ∂μ = ∫⁻ a in s, f a ∂μ := by
rw [← lintegral_congr_ae (indicator_ae_eq_of_ae_eq_set hs.toMeasurable_ae_eq),
lintegral_indicator _ (measurableSet_toMeasurable _ _),
Measure.restrict_congr_set hs.toMeasurable_ae_eq]
#align measure_theory.lintegral_indicator₀ MeasureTheory.lintegral_indicator₀
theorem lintegral_indicator_const_le (s : Set α) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) a ∂μ ≤ c * μ s :=
(lintegral_indicator_le _ _).trans (set_lintegral_const s c).le
theorem lintegral_indicator_const₀ {s : Set α} (hs : NullMeasurableSet s μ) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) a ∂μ = c * μ s := by
rw [lintegral_indicator₀ _ hs, set_lintegral_const]
theorem lintegral_indicator_const {s : Set α} (hs : MeasurableSet s) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) a ∂μ = c * μ s :=
lintegral_indicator_const₀ hs.nullMeasurableSet c
#align measure_theory.lintegral_indicator_const MeasureTheory.lintegral_indicator_const
theorem set_lintegral_eq_const {f : α → ℝ≥0∞} (hf : Measurable f) (r : ℝ≥0∞) :
∫⁻ x in { x | f x = r }, f x ∂μ = r * μ { x | f x = r } := by
have : ∀ᵐ x ∂μ, x ∈ { x | f x = r } → f x = r := ae_of_all μ fun _ hx => hx
rw [set_lintegral_congr_fun _ this]
· rw [lintegral_const, Measure.restrict_apply MeasurableSet.univ, Set.univ_inter]
· exact hf (measurableSet_singleton r)
#align measure_theory.set_lintegral_eq_const MeasureTheory.set_lintegral_eq_const
theorem lintegral_indicator_one_le (s : Set α) : ∫⁻ a, s.indicator 1 a ∂μ ≤ μ s :=
(lintegral_indicator_const_le _ _).trans <| (one_mul _).le
@[simp]
theorem lintegral_indicator_one₀ (hs : NullMeasurableSet s μ) : ∫⁻ a, s.indicator 1 a ∂μ = μ s :=
(lintegral_indicator_const₀ hs _).trans <| one_mul _
@[simp]
theorem lintegral_indicator_one (hs : MeasurableSet s) : ∫⁻ a, s.indicator 1 a ∂μ = μ s :=
(lintegral_indicator_const hs _).trans <| one_mul _
#align measure_theory.lintegral_indicator_one MeasureTheory.lintegral_indicator_one
theorem lintegral_add_mul_meas_add_le_le_lintegral {f g : α → ℝ≥0∞} (hle : f ≤ᵐ[μ] g)
(hg : AEMeasurable g μ) (ε : ℝ≥0∞) :
∫⁻ a, f a ∂μ + ε * μ { x | f x + ε ≤ g x } ≤ ∫⁻ a, g a ∂μ := by
rcases exists_measurable_le_lintegral_eq μ f with ⟨φ, hφm, hφ_le, hφ_eq⟩
calc
∫⁻ x, f x ∂μ + ε * μ { x | f x + ε ≤ g x } = ∫⁻ x, φ x ∂μ + ε * μ { x | f x + ε ≤ g x } := by
rw [hφ_eq]
_ ≤ ∫⁻ x, φ x ∂μ + ε * μ { x | φ x + ε ≤ g x } := by
gcongr
exact fun x => (add_le_add_right (hφ_le _) _).trans
_ = ∫⁻ x, φ x + indicator { x | φ x + ε ≤ g x } (fun _ => ε) x ∂μ := by
rw [lintegral_add_left hφm, lintegral_indicator₀, set_lintegral_const]
exact measurableSet_le (hφm.nullMeasurable.measurable'.add_const _) hg.nullMeasurable
_ ≤ ∫⁻ x, g x ∂μ := lintegral_mono_ae (hle.mono fun x hx₁ => ?_)
simp only [indicator_apply]; split_ifs with hx₂
exacts [hx₂, (add_zero _).trans_le <| (hφ_le x).trans hx₁]
#align measure_theory.lintegral_add_mul_meas_add_le_le_lintegral MeasureTheory.lintegral_add_mul_meas_add_le_le_lintegral
theorem mul_meas_ge_le_lintegral₀ {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (ε : ℝ≥0∞) :
ε * μ { x | ε ≤ f x } ≤ ∫⁻ a, f a ∂μ := by
simpa only [lintegral_zero, zero_add] using
lintegral_add_mul_meas_add_le_le_lintegral (ae_of_all _ fun x => zero_le (f x)) hf ε
#align measure_theory.mul_meas_ge_le_lintegral₀ MeasureTheory.mul_meas_ge_le_lintegral₀
theorem mul_meas_ge_le_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) (ε : ℝ≥0∞) :
ε * μ { x | ε ≤ f x } ≤ ∫⁻ a, f a ∂μ :=
mul_meas_ge_le_lintegral₀ hf.aemeasurable ε
#align measure_theory.mul_meas_ge_le_lintegral MeasureTheory.mul_meas_ge_le_lintegral
lemma meas_le_lintegral₀ {f : α → ℝ≥0∞} (hf : AEMeasurable f μ)
{s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) : μ s ≤ ∫⁻ a, f a ∂μ := by
apply le_trans _ (mul_meas_ge_le_lintegral₀ hf 1)
rw [one_mul]
exact measure_mono hs
lemma lintegral_le_meas {s : Set α} {f : α → ℝ≥0∞} (hf : ∀ a, f a ≤ 1) (h'f : ∀ a ∈ sᶜ, f a = 0) :
∫⁻ a, f a ∂μ ≤ μ s := by
apply (lintegral_mono (fun x ↦ ?_)).trans (lintegral_indicator_one_le s)
by_cases hx : x ∈ s
· simpa [hx] using hf x
· simpa [hx] using h'f x hx
theorem lintegral_eq_top_of_measure_eq_top_ne_zero {f : α → ℝ≥0∞} (hf : AEMeasurable f μ)
(hμf : μ {x | f x = ∞} ≠ 0) : ∫⁻ x, f x ∂μ = ∞ :=
eq_top_iff.mpr <|
calc
∞ = ∞ * μ { x | ∞ ≤ f x } := by simp [mul_eq_top, hμf]
_ ≤ ∫⁻ x, f x ∂μ := mul_meas_ge_le_lintegral₀ hf ∞
#align measure_theory.lintegral_eq_top_of_measure_eq_top_ne_zero MeasureTheory.lintegral_eq_top_of_measure_eq_top_ne_zero
theorem setLintegral_eq_top_of_measure_eq_top_ne_zero (hf : AEMeasurable f (μ.restrict s))
(hμf : μ ({x ∈ s | f x = ∞}) ≠ 0) : ∫⁻ x in s, f x ∂μ = ∞ :=
lintegral_eq_top_of_measure_eq_top_ne_zero hf <|
mt (eq_bot_mono <| by rw [← setOf_inter_eq_sep]; exact Measure.le_restrict_apply _ _) hμf
#align measure_theory.set_lintegral_eq_top_of_measure_eq_top_ne_zero MeasureTheory.setLintegral_eq_top_of_measure_eq_top_ne_zero
theorem measure_eq_top_of_lintegral_ne_top (hf : AEMeasurable f μ) (hμf : ∫⁻ x, f x ∂μ ≠ ∞) :
μ {x | f x = ∞} = 0 :=
of_not_not fun h => hμf <| lintegral_eq_top_of_measure_eq_top_ne_zero hf h
#align measure_theory.measure_eq_top_of_lintegral_ne_top MeasureTheory.measure_eq_top_of_lintegral_ne_top
theorem measure_eq_top_of_setLintegral_ne_top (hf : AEMeasurable f (μ.restrict s))
(hμf : ∫⁻ x in s, f x ∂μ ≠ ∞) : μ ({x ∈ s | f x = ∞}) = 0 :=
of_not_not fun h => hμf <| setLintegral_eq_top_of_measure_eq_top_ne_zero hf h
#align measure_theory.measure_eq_top_of_set_lintegral_ne_top MeasureTheory.measure_eq_top_of_setLintegral_ne_top
theorem meas_ge_le_lintegral_div {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0)
(hε' : ε ≠ ∞) : μ { x | ε ≤ f x } ≤ (∫⁻ a, f a ∂μ) / ε :=
(ENNReal.le_div_iff_mul_le (Or.inl hε) (Or.inl hε')).2 <| by
rw [mul_comm]
exact mul_meas_ge_le_lintegral₀ hf ε
#align measure_theory.meas_ge_le_lintegral_div MeasureTheory.meas_ge_le_lintegral_div
theorem ae_eq_of_ae_le_of_lintegral_le {f g : α → ℝ≥0∞} (hfg : f ≤ᵐ[μ] g) (hf : ∫⁻ x, f x ∂μ ≠ ∞)
(hg : AEMeasurable g μ) (hgf : ∫⁻ x, g x ∂μ ≤ ∫⁻ x, f x ∂μ) : f =ᵐ[μ] g := by
have : ∀ n : ℕ, ∀ᵐ x ∂μ, g x < f x + (n : ℝ≥0∞)⁻¹ := by
intro n
simp only [ae_iff, not_lt]
have : ∫⁻ x, f x ∂μ + (↑n)⁻¹ * μ { x : α | f x + (n : ℝ≥0∞)⁻¹ ≤ g x } ≤ ∫⁻ x, f x ∂μ :=
(lintegral_add_mul_meas_add_le_le_lintegral hfg hg n⁻¹).trans hgf
rw [(ENNReal.cancel_of_ne hf).add_le_iff_nonpos_right, nonpos_iff_eq_zero, mul_eq_zero] at this
exact this.resolve_left (ENNReal.inv_ne_zero.2 (ENNReal.natCast_ne_top _))
refine hfg.mp ((ae_all_iff.2 this).mono fun x hlt hle => hle.antisymm ?_)
suffices Tendsto (fun n : ℕ => f x + (n : ℝ≥0∞)⁻¹) atTop (𝓝 (f x)) from
ge_of_tendsto' this fun i => (hlt i).le
simpa only [inv_top, add_zero] using
tendsto_const_nhds.add (ENNReal.tendsto_inv_iff.2 ENNReal.tendsto_nat_nhds_top)
#align measure_theory.ae_eq_of_ae_le_of_lintegral_le MeasureTheory.ae_eq_of_ae_le_of_lintegral_le
@[simp]
theorem lintegral_eq_zero_iff' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) :
∫⁻ a, f a ∂μ = 0 ↔ f =ᵐ[μ] 0 :=
have : ∫⁻ _ : α, 0 ∂μ ≠ ∞ := by simp [lintegral_zero, zero_ne_top]
⟨fun h =>
(ae_eq_of_ae_le_of_lintegral_le (ae_of_all _ <| zero_le f) this hf
(h.trans lintegral_zero.symm).le).symm,
fun h => (lintegral_congr_ae h).trans lintegral_zero⟩
#align measure_theory.lintegral_eq_zero_iff' MeasureTheory.lintegral_eq_zero_iff'
@[simp]
theorem lintegral_eq_zero_iff {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a ∂μ = 0 ↔ f =ᵐ[μ] 0 :=
lintegral_eq_zero_iff' hf.aemeasurable
#align measure_theory.lintegral_eq_zero_iff MeasureTheory.lintegral_eq_zero_iff
theorem lintegral_pos_iff_support {f : α → ℝ≥0∞} (hf : Measurable f) :
(0 < ∫⁻ a, f a ∂μ) ↔ 0 < μ (Function.support f) := by
simp [pos_iff_ne_zero, hf, Filter.EventuallyEq, ae_iff, Function.support]
#align measure_theory.lintegral_pos_iff_support MeasureTheory.lintegral_pos_iff_support
theorem setLintegral_pos_iff {f : α → ℝ≥0∞} (hf : Measurable f) {s : Set α} :
0 < ∫⁻ a in s, f a ∂μ ↔ 0 < μ (Function.support f ∩ s) := by
rw [lintegral_pos_iff_support hf, Measure.restrict_apply (measurableSet_support hf)]
theorem lintegral_iSup_ae {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n))
(h_mono : ∀ n, ∀ᵐ a ∂μ, f n a ≤ f n.succ a) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
let ⟨s, hs⟩ := exists_measurable_superset_of_null (ae_iff.1 (ae_all_iff.2 h_mono))
let g n a := if a ∈ s then 0 else f n a
have g_eq_f : ∀ᵐ a ∂μ, ∀ n, g n a = f n a :=
(measure_zero_iff_ae_nmem.1 hs.2.2).mono fun a ha n => if_neg ha
calc
∫⁻ a, ⨆ n, f n a ∂μ = ∫⁻ a, ⨆ n, g n a ∂μ :=
lintegral_congr_ae <| g_eq_f.mono fun a ha => by simp only [ha]
_ = ⨆ n, ∫⁻ a, g n a ∂μ :=
(lintegral_iSup (fun n => measurable_const.piecewise hs.2.1 (hf n))
(monotone_nat_of_le_succ fun n a => ?_))
_ = ⨆ n, ∫⁻ a, f n a ∂μ := by simp only [lintegral_congr_ae (g_eq_f.mono fun _a ha => ha _)]
simp only [g]
split_ifs with h
· rfl
· have := Set.not_mem_subset hs.1 h
simp only [not_forall, not_le, mem_setOf_eq, not_exists, not_lt] at this
exact this n
#align measure_theory.lintegral_supr_ae MeasureTheory.lintegral_iSup_ae
theorem lintegral_sub' {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ) (hg_fin : ∫⁻ a, g a ∂μ ≠ ∞)
(h_le : g ≤ᵐ[μ] f) : ∫⁻ a, f a - g a ∂μ = ∫⁻ a, f a ∂μ - ∫⁻ a, g a ∂μ := by
refine ENNReal.eq_sub_of_add_eq hg_fin ?_
rw [← lintegral_add_right' _ hg]
exact lintegral_congr_ae (h_le.mono fun x hx => tsub_add_cancel_of_le hx)
#align measure_theory.lintegral_sub' MeasureTheory.lintegral_sub'
theorem lintegral_sub {f g : α → ℝ≥0∞} (hg : Measurable g) (hg_fin : ∫⁻ a, g a ∂μ ≠ ∞)
(h_le : g ≤ᵐ[μ] f) : ∫⁻ a, f a - g a ∂μ = ∫⁻ a, f a ∂μ - ∫⁻ a, g a ∂μ :=
lintegral_sub' hg.aemeasurable hg_fin h_le
#align measure_theory.lintegral_sub MeasureTheory.lintegral_sub
theorem lintegral_sub_le' (f g : α → ℝ≥0∞) (hf : AEMeasurable f μ) :
∫⁻ x, g x ∂μ - ∫⁻ x, f x ∂μ ≤ ∫⁻ x, g x - f x ∂μ := by
rw [tsub_le_iff_right]
by_cases hfi : ∫⁻ x, f x ∂μ = ∞
· rw [hfi, add_top]
exact le_top
· rw [← lintegral_add_right' _ hf]
gcongr
exact le_tsub_add
#align measure_theory.lintegral_sub_le' MeasureTheory.lintegral_sub_le'
theorem lintegral_sub_le (f g : α → ℝ≥0∞) (hf : Measurable f) :
∫⁻ x, g x ∂μ - ∫⁻ x, f x ∂μ ≤ ∫⁻ x, g x - f x ∂μ :=
lintegral_sub_le' f g hf.aemeasurable
#align measure_theory.lintegral_sub_le MeasureTheory.lintegral_sub_le
theorem lintegral_strict_mono_of_ae_le_of_frequently_ae_lt {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ)
(hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h_le : f ≤ᵐ[μ] g) (h : ∃ᵐ x ∂μ, f x ≠ g x) :
∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ := by
contrapose! h
simp only [not_frequently, Ne, Classical.not_not]
exact ae_eq_of_ae_le_of_lintegral_le h_le hfi hg h
#align measure_theory.lintegral_strict_mono_of_ae_le_of_frequently_ae_lt MeasureTheory.lintegral_strict_mono_of_ae_le_of_frequently_ae_lt
theorem lintegral_strict_mono_of_ae_le_of_ae_lt_on {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ)
(hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h_le : f ≤ᵐ[μ] g) {s : Set α} (hμs : μ s ≠ 0)
(h : ∀ᵐ x ∂μ, x ∈ s → f x < g x) : ∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ :=
lintegral_strict_mono_of_ae_le_of_frequently_ae_lt hg hfi h_le <|
((frequently_ae_mem_iff.2 hμs).and_eventually h).mono fun _x hx => (hx.2 hx.1).ne
#align measure_theory.lintegral_strict_mono_of_ae_le_of_ae_lt_on MeasureTheory.lintegral_strict_mono_of_ae_le_of_ae_lt_on
theorem lintegral_strict_mono {f g : α → ℝ≥0∞} (hμ : μ ≠ 0) (hg : AEMeasurable g μ)
(hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h : ∀ᵐ x ∂μ, f x < g x) : ∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ := by
rw [Ne, ← Measure.measure_univ_eq_zero] at hμ
refine lintegral_strict_mono_of_ae_le_of_ae_lt_on hg hfi (ae_le_of_ae_lt h) hμ ?_
simpa using h
#align measure_theory.lintegral_strict_mono MeasureTheory.lintegral_strict_mono
theorem set_lintegral_strict_mono {f g : α → ℝ≥0∞} {s : Set α} (hsm : MeasurableSet s)
(hs : μ s ≠ 0) (hg : Measurable g) (hfi : ∫⁻ x in s, f x ∂μ ≠ ∞)
(h : ∀ᵐ x ∂μ, x ∈ s → f x < g x) : ∫⁻ x in s, f x ∂μ < ∫⁻ x in s, g x ∂μ :=
lintegral_strict_mono (by simp [hs]) hg.aemeasurable hfi ((ae_restrict_iff' hsm).mpr h)
#align measure_theory.set_lintegral_strict_mono MeasureTheory.set_lintegral_strict_mono
theorem lintegral_iInf_ae {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n))
(h_mono : ∀ n : ℕ, f n.succ ≤ᵐ[μ] f n) (h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) :
∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ :=
have fn_le_f0 : ∫⁻ a, ⨅ n, f n a ∂μ ≤ ∫⁻ a, f 0 a ∂μ :=
lintegral_mono fun a => iInf_le_of_le 0 le_rfl
have fn_le_f0' : ⨅ n, ∫⁻ a, f n a ∂μ ≤ ∫⁻ a, f 0 a ∂μ := iInf_le_of_le 0 le_rfl
(ENNReal.sub_right_inj h_fin fn_le_f0 fn_le_f0').1 <|
show ∫⁻ a, f 0 a ∂μ - ∫⁻ a, ⨅ n, f n a ∂μ = ∫⁻ a, f 0 a ∂μ - ⨅ n, ∫⁻ a, f n a ∂μ from
calc
∫⁻ a, f 0 a ∂μ - ∫⁻ a, ⨅ n, f n a ∂μ = ∫⁻ a, f 0 a - ⨅ n, f n a ∂μ :=
(lintegral_sub (measurable_iInf h_meas)
(ne_top_of_le_ne_top h_fin <| lintegral_mono fun a => iInf_le _ _)
(ae_of_all _ fun a => iInf_le _ _)).symm
_ = ∫⁻ a, ⨆ n, f 0 a - f n a ∂μ := congr rfl (funext fun a => ENNReal.sub_iInf)
_ = ⨆ n, ∫⁻ a, f 0 a - f n a ∂μ :=
(lintegral_iSup_ae (fun n => (h_meas 0).sub (h_meas n)) fun n =>
(h_mono n).mono fun a ha => tsub_le_tsub le_rfl ha)
_ = ⨆ n, ∫⁻ a, f 0 a ∂μ - ∫⁻ a, f n a ∂μ :=
(have h_mono : ∀ᵐ a ∂μ, ∀ n : ℕ, f n.succ a ≤ f n a := ae_all_iff.2 h_mono
have h_mono : ∀ n, ∀ᵐ a ∂μ, f n a ≤ f 0 a := fun n =>
h_mono.mono fun a h => by
induction' n with n ih
· exact le_rfl
· exact le_trans (h n) ih
congr_arg iSup <|
funext fun n =>
lintegral_sub (h_meas _) (ne_top_of_le_ne_top h_fin <| lintegral_mono_ae <| h_mono n)
(h_mono n))
_ = ∫⁻ a, f 0 a ∂μ - ⨅ n, ∫⁻ a, f n a ∂μ := ENNReal.sub_iInf.symm
#align measure_theory.lintegral_infi_ae MeasureTheory.lintegral_iInf_ae
theorem lintegral_iInf {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n)) (h_anti : Antitone f)
(h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) : ∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ :=
lintegral_iInf_ae h_meas (fun n => ae_of_all _ <| h_anti n.le_succ) h_fin
#align measure_theory.lintegral_infi MeasureTheory.lintegral_iInf
theorem lintegral_iInf' {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, AEMeasurable (f n) μ)
(h_anti : ∀ᵐ a ∂μ, Antitone (fun i ↦ f i a)) (h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) :
∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ := by
simp_rw [← iInf_apply]
let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Antitone f'
have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_anti
have h_ae_seq_mono : Antitone (aeSeq h_meas p) := by
intro n m hnm x
by_cases hx : x ∈ aeSeqSet h_meas p
· exact aeSeq.prop_of_mem_aeSeqSet h_meas hx hnm
· simp only [aeSeq, hx, if_false]
exact le_rfl
rw [lintegral_congr_ae (aeSeq.iInf h_meas hp).symm]
simp_rw [iInf_apply]
rw [lintegral_iInf (aeSeq.measurable h_meas p) h_ae_seq_mono]
· congr
exact funext fun n ↦ lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae h_meas hp n)
· rwa [lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae h_meas hp 0)]
theorem lintegral_iInf_directed_of_measurable {mα : MeasurableSpace α} [Countable β]
{f : β → α → ℝ≥0∞} {μ : Measure α} (hμ : μ ≠ 0) (hf : ∀ b, Measurable (f b))
(hf_int : ∀ b, ∫⁻ a, f b a ∂μ ≠ ∞) (h_directed : Directed (· ≥ ·) f) :
∫⁻ a, ⨅ b, f b a ∂μ = ⨅ b, ∫⁻ a, f b a ∂μ := by
cases nonempty_encodable β
cases isEmpty_or_nonempty β
· simp only [iInf_of_empty, lintegral_const,
ENNReal.top_mul (Measure.measure_univ_ne_zero.mpr hμ)]
inhabit β
have : ∀ a, ⨅ b, f b a = ⨅ n, f (h_directed.sequence f n) a := by
refine fun a =>
le_antisymm (le_iInf fun n => iInf_le _ _)
(le_iInf fun b => iInf_le_of_le (Encodable.encode b + 1) ?_)
exact h_directed.sequence_le b a
-- Porting note: used `∘` below to deal with its reduced reducibility
calc
∫⁻ a, ⨅ b, f b a ∂μ
_ = ∫⁻ a, ⨅ n, (f ∘ h_directed.sequence f) n a ∂μ := by simp only [this, Function.comp_apply]
_ = ⨅ n, ∫⁻ a, (f ∘ h_directed.sequence f) n a ∂μ := by
rw [lintegral_iInf ?_ h_directed.sequence_anti]
· exact hf_int _
· exact fun n => hf _
_ = ⨅ b, ∫⁻ a, f b a ∂μ := by
refine le_antisymm (le_iInf fun b => ?_) (le_iInf fun n => ?_)
· exact iInf_le_of_le (Encodable.encode b + 1) (lintegral_mono <| h_directed.sequence_le b)
· exact iInf_le (fun b => ∫⁻ a, f b a ∂μ) _
#align lintegral_infi_directed_of_measurable MeasureTheory.lintegral_iInf_directed_of_measurable
theorem lintegral_liminf_le' {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, AEMeasurable (f n) μ) :
∫⁻ a, liminf (fun n => f n a) atTop ∂μ ≤ liminf (fun n => ∫⁻ a, f n a ∂μ) atTop :=
calc
∫⁻ a, liminf (fun n => f n a) atTop ∂μ = ∫⁻ a, ⨆ n : ℕ, ⨅ i ≥ n, f i a ∂μ := by
simp only [liminf_eq_iSup_iInf_of_nat]
_ = ⨆ n : ℕ, ∫⁻ a, ⨅ i ≥ n, f i a ∂μ :=
(lintegral_iSup' (fun n => aemeasurable_biInf _ (to_countable _) (fun i _ ↦ h_meas i))
(ae_of_all μ fun a n m hnm => iInf_le_iInf_of_subset fun i hi => le_trans hnm hi))
_ ≤ ⨆ n : ℕ, ⨅ i ≥ n, ∫⁻ a, f i a ∂μ := iSup_mono fun n => le_iInf₂_lintegral _
_ = atTop.liminf fun n => ∫⁻ a, f n a ∂μ := Filter.liminf_eq_iSup_iInf_of_nat.symm
#align measure_theory.lintegral_liminf_le' MeasureTheory.lintegral_liminf_le'
theorem lintegral_liminf_le {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n)) :
∫⁻ a, liminf (fun n => f n a) atTop ∂μ ≤ liminf (fun n => ∫⁻ a, f n a ∂μ) atTop :=
lintegral_liminf_le' fun n => (h_meas n).aemeasurable
#align measure_theory.lintegral_liminf_le MeasureTheory.lintegral_liminf_le
theorem limsup_lintegral_le {f : ℕ → α → ℝ≥0∞} {g : α → ℝ≥0∞} (hf_meas : ∀ n, Measurable (f n))
(h_bound : ∀ n, f n ≤ᵐ[μ] g) (h_fin : ∫⁻ a, g a ∂μ ≠ ∞) :
limsup (fun n => ∫⁻ a, f n a ∂μ) atTop ≤ ∫⁻ a, limsup (fun n => f n a) atTop ∂μ :=
calc
limsup (fun n => ∫⁻ a, f n a ∂μ) atTop = ⨅ n : ℕ, ⨆ i ≥ n, ∫⁻ a, f i a ∂μ :=
limsup_eq_iInf_iSup_of_nat
_ ≤ ⨅ n : ℕ, ∫⁻ a, ⨆ i ≥ n, f i a ∂μ := iInf_mono fun n => iSup₂_lintegral_le _
_ = ∫⁻ a, ⨅ n : ℕ, ⨆ i ≥ n, f i a ∂μ := by
refine (lintegral_iInf ?_ ?_ ?_).symm
· intro n
exact measurable_biSup _ (to_countable _) (fun i _ ↦ hf_meas i)
· intro n m hnm a
exact iSup_le_iSup_of_subset fun i hi => le_trans hnm hi
· refine ne_top_of_le_ne_top h_fin (lintegral_mono_ae ?_)
refine (ae_all_iff.2 h_bound).mono fun n hn => ?_
exact iSup_le fun i => iSup_le fun _ => hn i
_ = ∫⁻ a, limsup (fun n => f n a) atTop ∂μ := by simp only [limsup_eq_iInf_iSup_of_nat]
#align measure_theory.limsup_lintegral_le MeasureTheory.limsup_lintegral_le
theorem tendsto_lintegral_of_dominated_convergence {F : ℕ → α → ℝ≥0∞} {f : α → ℝ≥0∞}
(bound : α → ℝ≥0∞) (hF_meas : ∀ n, Measurable (F n)) (h_bound : ∀ n, F n ≤ᵐ[μ] bound)
(h_fin : ∫⁻ 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 ∂μ)) :=
tendsto_of_le_liminf_of_limsup_le
(calc
∫⁻ a, f a ∂μ = ∫⁻ a, liminf (fun n : ℕ => F n a) atTop ∂μ :=
lintegral_congr_ae <| h_lim.mono fun a h => h.liminf_eq.symm
_ ≤ liminf (fun n => ∫⁻ a, F n a ∂μ) atTop := lintegral_liminf_le hF_meas
)
(calc
limsup (fun n : ℕ => ∫⁻ a, F n a ∂μ) atTop ≤ ∫⁻ a, limsup (fun n => F n a) atTop ∂μ :=
limsup_lintegral_le hF_meas h_bound h_fin
_ = ∫⁻ a, f a ∂μ := lintegral_congr_ae <| h_lim.mono fun a h => h.limsup_eq
)
#align measure_theory.tendsto_lintegral_of_dominated_convergence MeasureTheory.tendsto_lintegral_of_dominated_convergence
theorem tendsto_lintegral_of_dominated_convergence' {F : ℕ → α → ℝ≥0∞} {f : α → ℝ≥0∞}
(bound : α → ℝ≥0∞) (hF_meas : ∀ n, AEMeasurable (F n) μ) (h_bound : ∀ n, F n ≤ᵐ[μ] bound)
(h_fin : ∫⁻ 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
have : ∀ n, ∫⁻ a, F n a ∂μ = ∫⁻ a, (hF_meas n).mk (F n) a ∂μ := fun n =>
lintegral_congr_ae (hF_meas n).ae_eq_mk
simp_rw [this]
apply
tendsto_lintegral_of_dominated_convergence bound (fun n => (hF_meas n).measurable_mk) _ h_fin
· have : ∀ n, ∀ᵐ a ∂μ, (hF_meas n).mk (F n) a = F n a := fun n => (hF_meas n).ae_eq_mk.symm
have : ∀ᵐ a ∂μ, ∀ n, (hF_meas n).mk (F n) a = F n a := ae_all_iff.mpr this
filter_upwards [this, h_lim] with a H H'
simp_rw [H]
exact H'
· intro n
filter_upwards [h_bound n, (hF_meas n).ae_eq_mk] with a H H'
rwa [H'] at H
#align measure_theory.tendsto_lintegral_of_dominated_convergence' MeasureTheory.tendsto_lintegral_of_dominated_convergence'
theorem tendsto_lintegral_filter_of_dominated_convergence {ι} {l : Filter ι}
[l.IsCountablyGenerated] {F : ι → α → ℝ≥0∞} {f : α → ℝ≥0∞} (bound : α → ℝ≥0∞)
(hF_meas : ∀ᶠ n in l, Measurable (F n)) (h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, F n a ≤ bound a)
(h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) l (𝓝 (f a))) :
Tendsto (fun n => ∫⁻ a, F n a ∂μ) l (𝓝 <| ∫⁻ a, f a ∂μ) := by
rw [tendsto_iff_seq_tendsto]
intro x xl
have hxl := by
rw [tendsto_atTop'] at xl
exact xl
have h := inter_mem hF_meas h_bound
replace h := hxl _ h
rcases h with ⟨k, h⟩
rw [← tendsto_add_atTop_iff_nat k]
refine tendsto_lintegral_of_dominated_convergence ?_ ?_ ?_ ?_ ?_
· exact bound
· intro
refine (h _ ?_).1
exact Nat.le_add_left _ _
· intro
refine (h _ ?_).2
exact Nat.le_add_left _ _
· assumption
· refine h_lim.mono fun a h_lim => ?_
apply @Tendsto.comp _ _ _ (fun n => x (n + k)) fun n => F n a
· assumption
rw [tendsto_add_atTop_iff_nat]
assumption
#align measure_theory.tendsto_lintegral_filter_of_dominated_convergence MeasureTheory.tendsto_lintegral_filter_of_dominated_convergence
theorem lintegral_tendsto_of_tendsto_of_antitone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞}
(hf : ∀ n, AEMeasurable (f n) μ) (h_anti : ∀ᵐ x ∂μ, Antitone fun n ↦ f n x)
(h0 : ∫⁻ a, f 0 a ∂μ ≠ ∞)
(h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) :
Tendsto (fun n ↦ ∫⁻ x, f n x ∂μ) atTop (𝓝 (∫⁻ x, F x ∂μ)) := by
have : Antitone fun n ↦ ∫⁻ x, f n x ∂μ := fun i j hij ↦
lintegral_mono_ae (h_anti.mono fun x hx ↦ hx hij)
suffices key : ∫⁻ x, F x ∂μ = ⨅ n, ∫⁻ x, f n x ∂μ by
rw [key]
exact tendsto_atTop_iInf this
rw [← lintegral_iInf' hf h_anti h0]
refine lintegral_congr_ae ?_
filter_upwards [h_anti, h_tendsto] with _ hx_anti hx_tendsto
using tendsto_nhds_unique hx_tendsto (tendsto_atTop_iInf hx_anti)
section
open Encodable
theorem lintegral_iSup_directed_of_measurable [Countable β] {f : β → α → ℝ≥0∞}
(hf : ∀ b, Measurable (f b)) (h_directed : Directed (· ≤ ·) f) :
∫⁻ a, ⨆ b, f b a ∂μ = ⨆ b, ∫⁻ a, f b a ∂μ := by
cases nonempty_encodable β
cases isEmpty_or_nonempty β
· simp [iSup_of_empty]
inhabit β
have : ∀ a, ⨆ b, f b a = ⨆ n, f (h_directed.sequence f n) a := by
intro a
refine le_antisymm (iSup_le fun b => ?_) (iSup_le fun n => le_iSup (fun n => f n a) _)
exact le_iSup_of_le (encode b + 1) (h_directed.le_sequence b a)
calc
∫⁻ a, ⨆ b, f b a ∂μ = ∫⁻ a, ⨆ n, f (h_directed.sequence f n) a ∂μ := by simp only [this]
_ = ⨆ n, ∫⁻ a, f (h_directed.sequence f n) a ∂μ :=
(lintegral_iSup (fun n => hf _) h_directed.sequence_mono)
_ = ⨆ b, ∫⁻ a, f b a ∂μ := by
refine le_antisymm (iSup_le fun n => ?_) (iSup_le fun b => ?_)
· exact le_iSup (fun b => ∫⁻ a, f b a ∂μ) _
· exact le_iSup_of_le (encode b + 1) (lintegral_mono <| h_directed.le_sequence b)
#align measure_theory.lintegral_supr_directed_of_measurable MeasureTheory.lintegral_iSup_directed_of_measurable
theorem lintegral_iSup_directed [Countable β] {f : β → α → ℝ≥0∞} (hf : ∀ b, AEMeasurable (f b) μ)
(h_directed : Directed (· ≤ ·) f) : ∫⁻ a, ⨆ b, f b a ∂μ = ⨆ b, ∫⁻ a, f b a ∂μ := by
simp_rw [← iSup_apply]
let p : α → (β → ENNReal) → Prop := fun x f' => Directed LE.le f'
have hp : ∀ᵐ x ∂μ, p x fun i => f i x := by
filter_upwards [] with x i j
obtain ⟨z, hz₁, hz₂⟩ := h_directed i j
exact ⟨z, hz₁ x, hz₂ x⟩
have h_ae_seq_directed : Directed LE.le (aeSeq hf p) := by
intro b₁ b₂
obtain ⟨z, hz₁, hz₂⟩ := h_directed b₁ b₂
refine ⟨z, ?_, ?_⟩ <;>
· intro x
by_cases hx : x ∈ aeSeqSet hf p
· repeat rw [aeSeq.aeSeq_eq_fun_of_mem_aeSeqSet hf hx]
apply_rules [hz₁, hz₂]
· simp only [aeSeq, hx, if_false]
exact le_rfl
convert lintegral_iSup_directed_of_measurable (aeSeq.measurable hf p) h_ae_seq_directed using 1
· simp_rw [← iSup_apply]
rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm]
· congr 1
ext1 b
rw [lintegral_congr_ae]
apply EventuallyEq.symm
exact aeSeq.aeSeq_n_eq_fun_n_ae hf hp _
#align measure_theory.lintegral_supr_directed MeasureTheory.lintegral_iSup_directed
end
theorem lintegral_tsum [Countable β] {f : β → α → ℝ≥0∞} (hf : ∀ i, AEMeasurable (f i) μ) :
∫⁻ a, ∑' i, f i a ∂μ = ∑' i, ∫⁻ a, f i a ∂μ := by
simp only [ENNReal.tsum_eq_iSup_sum]
rw [lintegral_iSup_directed]
· simp [lintegral_finset_sum' _ fun i _ => hf i]
· intro b
exact Finset.aemeasurable_sum _ fun i _ => hf i
· intro s t
use s ∪ t
constructor
· exact fun a => Finset.sum_le_sum_of_subset Finset.subset_union_left
· exact fun a => Finset.sum_le_sum_of_subset Finset.subset_union_right
#align measure_theory.lintegral_tsum MeasureTheory.lintegral_tsum
open Measure
theorem lintegral_iUnion₀ [Countable β] {s : β → Set α} (hm : ∀ i, NullMeasurableSet (s i) μ)
(hd : Pairwise (AEDisjoint μ on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ = ∑' i, ∫⁻ a in s i, f a ∂μ := by
simp only [Measure.restrict_iUnion_ae hd hm, lintegral_sum_measure]
#align measure_theory.lintegral_Union₀ MeasureTheory.lintegral_iUnion₀
theorem lintegral_iUnion [Countable β] {s : β → Set α} (hm : ∀ i, MeasurableSet (s i))
(hd : Pairwise (Disjoint on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ = ∑' i, ∫⁻ a in s i, f a ∂μ :=
lintegral_iUnion₀ (fun i => (hm i).nullMeasurableSet) hd.aedisjoint f
#align measure_theory.lintegral_Union MeasureTheory.lintegral_iUnion
theorem lintegral_biUnion₀ {t : Set β} {s : β → Set α} (ht : t.Countable)
(hm : ∀ i ∈ t, NullMeasurableSet (s i) μ) (hd : t.Pairwise (AEDisjoint μ on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i ∈ t, s i, f a ∂μ = ∑' i : t, ∫⁻ a in s i, f a ∂μ := by
haveI := ht.toEncodable
rw [biUnion_eq_iUnion, lintegral_iUnion₀ (SetCoe.forall'.1 hm) (hd.subtype _ _)]
#align measure_theory.lintegral_bUnion₀ MeasureTheory.lintegral_biUnion₀
theorem lintegral_biUnion {t : Set β} {s : β → Set α} (ht : t.Countable)
(hm : ∀ i ∈ t, MeasurableSet (s i)) (hd : t.PairwiseDisjoint s) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i ∈ t, s i, f a ∂μ = ∑' i : t, ∫⁻ a in s i, f a ∂μ :=
lintegral_biUnion₀ ht (fun i hi => (hm i hi).nullMeasurableSet) hd.aedisjoint f
#align measure_theory.lintegral_bUnion MeasureTheory.lintegral_biUnion
theorem lintegral_biUnion_finset₀ {s : Finset β} {t : β → Set α}
(hd : Set.Pairwise (↑s) (AEDisjoint μ on t)) (hm : ∀ b ∈ s, NullMeasurableSet (t b) μ)
(f : α → ℝ≥0∞) : ∫⁻ a in ⋃ b ∈ s, t b, f a ∂μ = ∑ b ∈ s, ∫⁻ a in t b, f a ∂μ := by
simp only [← Finset.mem_coe, lintegral_biUnion₀ s.countable_toSet hm hd, ← Finset.tsum_subtype']
#align measure_theory.lintegral_bUnion_finset₀ MeasureTheory.lintegral_biUnion_finset₀
theorem lintegral_biUnion_finset {s : Finset β} {t : β → Set α} (hd : Set.PairwiseDisjoint (↑s) t)
(hm : ∀ b ∈ s, MeasurableSet (t b)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ b ∈ s, t b, f a ∂μ = ∑ b ∈ s, ∫⁻ a in t b, f a ∂μ :=
lintegral_biUnion_finset₀ hd.aedisjoint (fun b hb => (hm b hb).nullMeasurableSet) f
#align measure_theory.lintegral_bUnion_finset MeasureTheory.lintegral_biUnion_finset
theorem lintegral_iUnion_le [Countable β] (s : β → Set α) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ ≤ ∑' i, ∫⁻ a in s i, f a ∂μ := by
rw [← lintegral_sum_measure]
exact lintegral_mono' restrict_iUnion_le le_rfl
#align measure_theory.lintegral_Union_le MeasureTheory.lintegral_iUnion_le
theorem lintegral_union {f : α → ℝ≥0∞} {A B : Set α} (hB : MeasurableSet B) (hAB : Disjoint A B) :
∫⁻ a in A ∪ B, f a ∂μ = ∫⁻ a in A, f a ∂μ + ∫⁻ a in B, f a ∂μ := by
rw [restrict_union hAB hB, lintegral_add_measure]
#align measure_theory.lintegral_union MeasureTheory.lintegral_union
theorem lintegral_union_le (f : α → ℝ≥0∞) (s t : Set α) :
∫⁻ a in s ∪ t, f a ∂μ ≤ ∫⁻ a in s, f a ∂μ + ∫⁻ a in t, f a ∂μ := by
rw [← lintegral_add_measure]
exact lintegral_mono' (restrict_union_le _ _) le_rfl
theorem lintegral_inter_add_diff {B : Set α} (f : α → ℝ≥0∞) (A : Set α) (hB : MeasurableSet B) :
∫⁻ x in A ∩ B, f x ∂μ + ∫⁻ x in A \ B, f x ∂μ = ∫⁻ x in A, f x ∂μ := by
rw [← lintegral_add_measure, restrict_inter_add_diff _ hB]
#align measure_theory.lintegral_inter_add_diff MeasureTheory.lintegral_inter_add_diff
theorem lintegral_add_compl (f : α → ℝ≥0∞) {A : Set α} (hA : MeasurableSet A) :
∫⁻ x in A, f x ∂μ + ∫⁻ x in Aᶜ, f x ∂μ = ∫⁻ x, f x ∂μ := by
rw [← lintegral_add_measure, Measure.restrict_add_restrict_compl hA]
#align measure_theory.lintegral_add_compl MeasureTheory.lintegral_add_compl
theorem lintegral_max {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) :
∫⁻ x, max (f x) (g x) ∂μ =
∫⁻ x in { x | f x ≤ g x }, g x ∂μ + ∫⁻ x in { x | g x < f x }, f x ∂μ := by
have hm : MeasurableSet { x | f x ≤ g x } := measurableSet_le hf hg
rw [← lintegral_add_compl (fun x => max (f x) (g x)) hm]
simp only [← compl_setOf, ← not_le]
refine congr_arg₂ (· + ·) (set_lintegral_congr_fun hm ?_) (set_lintegral_congr_fun hm.compl ?_)
exacts [ae_of_all _ fun x => max_eq_right (a := f x) (b := g x),
ae_of_all _ fun x (hx : ¬ f x ≤ g x) => max_eq_left (not_le.1 hx).le]
#align measure_theory.lintegral_max MeasureTheory.lintegral_max
theorem set_lintegral_max {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (s : Set α) :
∫⁻ x in s, max (f x) (g x) ∂μ =
∫⁻ x in s ∩ { x | f x ≤ g x }, g x ∂μ + ∫⁻ x in s ∩ { x | g x < f x }, f x ∂μ := by
rw [lintegral_max hf hg, restrict_restrict, restrict_restrict, inter_comm s, inter_comm s]
exacts [measurableSet_lt hg hf, measurableSet_le hf hg]
#align measure_theory.set_lintegral_max MeasureTheory.set_lintegral_max
theorem lintegral_map {mβ : MeasurableSpace β} {f : β → ℝ≥0∞} {g : α → β} (hf : Measurable f)
(hg : Measurable g) : ∫⁻ a, f a ∂map g μ = ∫⁻ a, f (g a) ∂μ := by
erw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral (hf.comp hg)]
congr with n : 1
convert SimpleFunc.lintegral_map _ hg
ext1 x; simp only [eapprox_comp hf hg, coe_comp]
#align measure_theory.lintegral_map MeasureTheory.lintegral_map
theorem lintegral_map' {mβ : MeasurableSpace β} {f : β → ℝ≥0∞} {g : α → β}
(hf : AEMeasurable f (Measure.map g μ)) (hg : AEMeasurable g μ) :
∫⁻ a, f a ∂Measure.map g μ = ∫⁻ a, f (g a) ∂μ :=
calc
∫⁻ a, f a ∂Measure.map g μ = ∫⁻ a, hf.mk f a ∂Measure.map g μ :=
lintegral_congr_ae hf.ae_eq_mk
_ = ∫⁻ a, hf.mk f a ∂Measure.map (hg.mk g) μ := by
congr 1
exact Measure.map_congr hg.ae_eq_mk
_ = ∫⁻ a, hf.mk f (hg.mk g a) ∂μ := lintegral_map hf.measurable_mk hg.measurable_mk
_ = ∫⁻ a, hf.mk f (g a) ∂μ := lintegral_congr_ae <| hg.ae_eq_mk.symm.fun_comp _
_ = ∫⁻ a, f (g a) ∂μ := lintegral_congr_ae (ae_eq_comp hg hf.ae_eq_mk.symm)
#align measure_theory.lintegral_map' MeasureTheory.lintegral_map'
theorem lintegral_map_le {mβ : MeasurableSpace β} (f : β → ℝ≥0∞) {g : α → β} (hg : Measurable g) :
∫⁻ a, f a ∂Measure.map g μ ≤ ∫⁻ a, f (g a) ∂μ := by
rw [← iSup_lintegral_measurable_le_eq_lintegral, ← iSup_lintegral_measurable_le_eq_lintegral]
refine iSup₂_le fun i hi => iSup_le fun h'i => ?_
refine le_iSup₂_of_le (i ∘ g) (hi.comp hg) ?_
exact le_iSup_of_le (fun x => h'i (g x)) (le_of_eq (lintegral_map hi hg))
#align measure_theory.lintegral_map_le MeasureTheory.lintegral_map_le
theorem lintegral_comp [MeasurableSpace β] {f : β → ℝ≥0∞} {g : α → β} (hf : Measurable f)
(hg : Measurable g) : lintegral μ (f ∘ g) = ∫⁻ a, f a ∂map g μ :=
(lintegral_map hf hg).symm
#align measure_theory.lintegral_comp MeasureTheory.lintegral_comp
theorem set_lintegral_map [MeasurableSpace β] {f : β → ℝ≥0∞} {g : α → β} {s : Set β}
(hs : MeasurableSet s) (hf : Measurable f) (hg : Measurable g) :
∫⁻ y in s, f y ∂map g μ = ∫⁻ x in g ⁻¹' s, f (g x) ∂μ := by
rw [restrict_map hg hs, lintegral_map hf hg]
#align measure_theory.set_lintegral_map MeasureTheory.set_lintegral_map
theorem lintegral_indicator_const_comp {mβ : MeasurableSpace β} {f : α → β} {s : Set β}
(hf : Measurable f) (hs : MeasurableSet s) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) (f a) ∂μ = c * μ (f ⁻¹' s) := by
erw [lintegral_comp (measurable_const.indicator hs) hf, lintegral_indicator_const hs,
Measure.map_apply hf hs]
#align measure_theory.lintegral_indicator_const_comp MeasureTheory.lintegral_indicator_const_comp
theorem _root_.MeasurableEmbedding.lintegral_map [MeasurableSpace β] {g : α → β}
(hg : MeasurableEmbedding g) (f : β → ℝ≥0∞) : ∫⁻ a, f a ∂map g μ = ∫⁻ a, f (g a) ∂μ := by
rw [lintegral, lintegral]
refine le_antisymm (iSup₂_le fun f₀ hf₀ => ?_) (iSup₂_le fun f₀ hf₀ => ?_)
· rw [SimpleFunc.lintegral_map _ hg.measurable]
have : (f₀.comp g hg.measurable : α → ℝ≥0∞) ≤ f ∘ g := fun x => hf₀ (g x)
exact le_iSup_of_le (comp f₀ g hg.measurable) (by exact le_iSup (α := ℝ≥0∞) _ this)
· rw [← f₀.extend_comp_eq hg (const _ 0), ← SimpleFunc.lintegral_map, ←
SimpleFunc.lintegral_eq_lintegral, ← lintegral]
refine lintegral_mono_ae (hg.ae_map_iff.2 <| eventually_of_forall fun x => ?_)
exact (extend_apply _ _ _ _).trans_le (hf₀ _)
#align measurable_embedding.lintegral_map MeasurableEmbedding.lintegral_map
theorem lintegral_map_equiv [MeasurableSpace β] (f : β → ℝ≥0∞) (g : α ≃ᵐ β) :
∫⁻ a, f a ∂map g μ = ∫⁻ a, f (g a) ∂μ :=
g.measurableEmbedding.lintegral_map f
#align measure_theory.lintegral_map_equiv MeasureTheory.lintegral_map_equiv
protected theorem MeasurePreserving.lintegral_map_equiv [MeasurableSpace β] {ν : Measure β}
(f : β → ℝ≥0∞) (g : α ≃ᵐ β) (hg : MeasurePreserving g μ ν) :
∫⁻ a, f a ∂ν = ∫⁻ a, f (g a) ∂μ := by
rw [← MeasureTheory.lintegral_map_equiv f g, hg.map_eq]
theorem MeasurePreserving.lintegral_comp {mb : MeasurableSpace β} {ν : Measure β} {g : α → β}
(hg : MeasurePreserving g μ ν) {f : β → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, f (g a) ∂μ = ∫⁻ b, f b ∂ν := by rw [← hg.map_eq, lintegral_map hf hg.measurable]
#align measure_theory.measure_preserving.lintegral_comp MeasureTheory.MeasurePreserving.lintegral_comp
theorem MeasurePreserving.lintegral_comp_emb {mb : MeasurableSpace β} {ν : Measure β} {g : α → β}
(hg : MeasurePreserving g μ ν) (hge : MeasurableEmbedding g) (f : β → ℝ≥0∞) :
∫⁻ a, f (g a) ∂μ = ∫⁻ b, f b ∂ν := by rw [← hg.map_eq, hge.lintegral_map]
#align measure_theory.measure_preserving.lintegral_comp_emb MeasureTheory.MeasurePreserving.lintegral_comp_emb
theorem MeasurePreserving.set_lintegral_comp_preimage {mb : MeasurableSpace β} {ν : Measure β}
{g : α → β} (hg : MeasurePreserving g μ ν) {s : Set β} (hs : MeasurableSet s) {f : β → ℝ≥0∞}
(hf : Measurable f) : ∫⁻ a in g ⁻¹' s, f (g a) ∂μ = ∫⁻ b in s, f b ∂ν := by
rw [← hg.map_eq, set_lintegral_map hs hf hg.measurable]
#align measure_theory.measure_preserving.set_lintegral_comp_preimage MeasureTheory.MeasurePreserving.set_lintegral_comp_preimage
theorem MeasurePreserving.set_lintegral_comp_preimage_emb {mb : MeasurableSpace β} {ν : Measure β}
{g : α → β} (hg : MeasurePreserving g μ ν) (hge : MeasurableEmbedding g) (f : β → ℝ≥0∞)
(s : Set β) : ∫⁻ a in g ⁻¹' s, f (g a) ∂μ = ∫⁻ b in s, f b ∂ν := by
rw [← hg.map_eq, hge.restrict_map, hge.lintegral_map]
#align measure_theory.measure_preserving.set_lintegral_comp_preimage_emb MeasureTheory.MeasurePreserving.set_lintegral_comp_preimage_emb
theorem MeasurePreserving.set_lintegral_comp_emb {mb : MeasurableSpace β} {ν : Measure β}
{g : α → β} (hg : MeasurePreserving g μ ν) (hge : MeasurableEmbedding g) (f : β → ℝ≥0∞)
(s : Set α) : ∫⁻ a in s, f (g a) ∂μ = ∫⁻ b in g '' s, f b ∂ν := by
rw [← hg.set_lintegral_comp_preimage_emb hge, preimage_image_eq _ hge.injective]
#align measure_theory.measure_preserving.set_lintegral_comp_emb MeasureTheory.MeasurePreserving.set_lintegral_comp_emb
theorem lintegral_subtype_comap {s : Set α} (hs : MeasurableSet s) (f : α → ℝ≥0∞) :
∫⁻ x : s, f x ∂(μ.comap (↑)) = ∫⁻ x in s, f x ∂μ := by
rw [← (MeasurableEmbedding.subtype_coe hs).lintegral_map, map_comap_subtype_coe hs]
theorem set_lintegral_subtype {s : Set α} (hs : MeasurableSet s) (t : Set s) (f : α → ℝ≥0∞) :
∫⁻ x in t, f x ∂(μ.comap (↑)) = ∫⁻ x in (↑) '' t, f x ∂μ := by
rw [(MeasurableEmbedding.subtype_coe hs).restrict_comap, lintegral_subtype_comap hs,
restrict_restrict hs, inter_eq_right.2 (Subtype.coe_image_subset _ _)]
| Mathlib/MeasureTheory/Integral/Lebesgue.lean | 1,629 | 1,639 | theorem ae_lt_top {f : α → ℝ≥0∞} (hf : Measurable f) (h2f : ∫⁻ x, f x ∂μ ≠ ∞) :
∀ᵐ x ∂μ, f x < ∞ := by |
simp_rw [ae_iff, ENNReal.not_lt_top]
by_contra h
apply h2f.lt_top.not_le
have : (f ⁻¹' {∞}).indicator ⊤ ≤ f := by
intro x
by_cases hx : x ∈ f ⁻¹' {∞} <;> [simpa [indicator_of_mem hx]; simp [indicator_of_not_mem hx]]
convert lintegral_mono this
rw [lintegral_indicator _ (hf (measurableSet_singleton ∞))]
simp [ENNReal.top_mul', preimage, h]
|
import Mathlib.MeasureTheory.Function.AEEqFun.DomAct
import Mathlib.MeasureTheory.Function.LpSpace
set_option autoImplicit true
open MeasureTheory Filter
open scoped ENNReal
namespace DomMulAct
variable {M N α E : Type*} [MeasurableSpace M] [MeasurableSpace N]
[MeasurableSpace α] [NormedAddCommGroup E] {μ : MeasureTheory.Measure α} {p : ℝ≥0∞}
section SMul
variable [SMul M α] [SMulInvariantMeasure M α μ] [MeasurableSMul M α]
@[to_additive]
instance : SMul Mᵈᵐᵃ (Lp E p μ) where
smul c f := Lp.compMeasurePreserving (mk.symm c • ·) (measurePreserving_smul _ _) f
@[to_additive (attr := simp)]
theorem smul_Lp_val (c : Mᵈᵐᵃ) (f : Lp E p μ) : (c • f).1 = c • f.1 := rfl
@[to_additive]
theorem smul_Lp_ae_eq (c : Mᵈᵐᵃ) (f : Lp E p μ) : c • f =ᵐ[μ] (f <| mk.symm c • ·) :=
Lp.coeFn_compMeasurePreserving _ _
@[to_additive]
theorem mk_smul_toLp (c : M) {f : α → E} (hf : Memℒp f p μ) :
mk c • hf.toLp f =
(hf.comp_measurePreserving <| measurePreserving_smul c μ).toLp (f <| c • ·) :=
rfl
@[to_additive (attr := simp)]
theorem smul_Lp_const [IsFiniteMeasure μ] (c : Mᵈᵐᵃ) (a : E) :
c • Lp.const p μ a = Lp.const p μ a :=
rfl
instance [SMul N α] [SMulCommClass M N α] [SMulInvariantMeasure N α μ] [MeasurableSMul N α] :
SMulCommClass Mᵈᵐᵃ Nᵈᵐᵃ (Lp E p μ) :=
Subtype.val_injective.smulCommClass (fun _ _ ↦ rfl) fun _ _ ↦ rfl
instance [NormedRing 𝕜] [Module 𝕜 E] [BoundedSMul 𝕜 E] : SMulCommClass Mᵈᵐᵃ 𝕜 (Lp E p μ) :=
Subtype.val_injective.smulCommClass (fun _ _ ↦ rfl) fun _ _ ↦ rfl
instance [NormedRing 𝕜] [Module 𝕜 E] [BoundedSMul 𝕜 E] : SMulCommClass 𝕜 Mᵈᵐᵃ (Lp E p μ) :=
.symm _ _ _
-- We don't have a typeclass for additive versions of the next few lemmas
-- Should we add `AddDistribAddAction` with `to_additive` both from `MulDistribMulAction`
-- and `DistribMulAction`?
@[to_additive]
theorem smul_Lp_add (c : Mᵈᵐᵃ) : ∀ f g : Lp E p μ, c • (f + g) = c • f + c • g := by
rintro ⟨⟨⟩, _⟩ ⟨⟨⟩, _⟩; rfl
attribute [simp] DomAddAct.vadd_Lp_add
@[to_additive (attr := simp 1001)]
theorem smul_Lp_zero (c : Mᵈᵐᵃ) : c • (0 : Lp E p μ) = 0 := rfl
@[to_additive]
theorem smul_Lp_neg (c : Mᵈᵐᵃ) (f : Lp E p μ) : c • (-f) = -(c • f) := by
rcases f with ⟨⟨_⟩, _⟩; rfl
@[to_additive]
| Mathlib/MeasureTheory/Function/LpSpace/DomAct/Basic.lean | 82 | 83 | theorem smul_Lp_sub (c : Mᵈᵐᵃ) : ∀ f g : Lp E p μ, c • (f - g) = c • f - c • g := by |
rintro ⟨⟨⟩, _⟩ ⟨⟨⟩, _⟩; rfl
|
import Mathlib.Algebra.Order.ZeroLEOne
import Mathlib.Data.List.InsertNth
import Mathlib.Logic.Relation
import Mathlib.Logic.Small.Defs
import Mathlib.Order.GameAdd
#align_import set_theory.game.pgame from "leanprover-community/mathlib"@"8900d545017cd21961daa2a1734bb658ef52c618"
set_option autoImplicit true
namespace SetTheory
open Function Relation
-- We'd like to be able to use multi-character auto-implicits in this file.
set_option relaxedAutoImplicit true
inductive PGame : Type (u + 1)
| mk : ∀ α β : Type u, (α → PGame) → (β → PGame) → PGame
#align pgame SetTheory.PGame
compile_inductive% PGame
namespace PGame
def LeftMoves : PGame → Type u
| mk l _ _ _ => l
#align pgame.left_moves SetTheory.PGame.LeftMoves
def RightMoves : PGame → Type u
| mk _ r _ _ => r
#align pgame.right_moves SetTheory.PGame.RightMoves
def moveLeft : ∀ g : PGame, LeftMoves g → PGame
| mk _l _ L _ => L
#align pgame.move_left SetTheory.PGame.moveLeft
def moveRight : ∀ g : PGame, RightMoves g → PGame
| mk _ _r _ R => R
#align pgame.move_right SetTheory.PGame.moveRight
@[simp]
theorem leftMoves_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).LeftMoves = xl :=
rfl
#align pgame.left_moves_mk SetTheory.PGame.leftMoves_mk
@[simp]
theorem moveLeft_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).moveLeft = xL :=
rfl
#align pgame.move_left_mk SetTheory.PGame.moveLeft_mk
@[simp]
theorem rightMoves_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).RightMoves = xr :=
rfl
#align pgame.right_moves_mk SetTheory.PGame.rightMoves_mk
@[simp]
theorem moveRight_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).moveRight = xR :=
rfl
#align pgame.move_right_mk SetTheory.PGame.moveRight_mk
-- TODO define this at the level of games, as well, and perhaps also for finsets of games.
def ofLists (L R : List PGame.{u}) : PGame.{u} :=
mk (ULift (Fin L.length)) (ULift (Fin R.length)) (fun i => L.get i.down) fun j ↦ R.get j.down
#align pgame.of_lists SetTheory.PGame.ofLists
theorem leftMoves_ofLists (L R : List PGame) : (ofLists L R).LeftMoves = ULift (Fin L.length) :=
rfl
#align pgame.left_moves_of_lists SetTheory.PGame.leftMoves_ofLists
theorem rightMoves_ofLists (L R : List PGame) : (ofLists L R).RightMoves = ULift (Fin R.length) :=
rfl
#align pgame.right_moves_of_lists SetTheory.PGame.rightMoves_ofLists
def toOfListsLeftMoves {L R : List PGame} : Fin L.length ≃ (ofLists L R).LeftMoves :=
((Equiv.cast (leftMoves_ofLists L R).symm).trans Equiv.ulift).symm
#align pgame.to_of_lists_left_moves SetTheory.PGame.toOfListsLeftMoves
def toOfListsRightMoves {L R : List PGame} : Fin R.length ≃ (ofLists L R).RightMoves :=
((Equiv.cast (rightMoves_ofLists L R).symm).trans Equiv.ulift).symm
#align pgame.to_of_lists_right_moves SetTheory.PGame.toOfListsRightMoves
theorem ofLists_moveLeft {L R : List PGame} (i : Fin L.length) :
(ofLists L R).moveLeft (toOfListsLeftMoves i) = L.get i :=
rfl
#align pgame.of_lists_move_left SetTheory.PGame.ofLists_moveLeft
@[simp]
theorem ofLists_moveLeft' {L R : List PGame} (i : (ofLists L R).LeftMoves) :
(ofLists L R).moveLeft i = L.get (toOfListsLeftMoves.symm i) :=
rfl
#align pgame.of_lists_move_left' SetTheory.PGame.ofLists_moveLeft'
theorem ofLists_moveRight {L R : List PGame} (i : Fin R.length) :
(ofLists L R).moveRight (toOfListsRightMoves i) = R.get i :=
rfl
#align pgame.of_lists_move_right SetTheory.PGame.ofLists_moveRight
@[simp]
theorem ofLists_moveRight' {L R : List PGame} (i : (ofLists L R).RightMoves) :
(ofLists L R).moveRight i = R.get (toOfListsRightMoves.symm i) :=
rfl
#align pgame.of_lists_move_right' SetTheory.PGame.ofLists_moveRight'
@[elab_as_elim]
def moveRecOn {C : PGame → Sort*} (x : PGame)
(IH : ∀ y : PGame, (∀ i, C (y.moveLeft i)) → (∀ j, C (y.moveRight j)) → C y) : C x :=
x.recOn fun yl yr yL yR => IH (mk yl yr yL yR)
#align pgame.move_rec_on SetTheory.PGame.moveRecOn
@[mk_iff]
inductive IsOption : PGame → PGame → Prop
| moveLeft {x : PGame} (i : x.LeftMoves) : IsOption (x.moveLeft i) x
| moveRight {x : PGame} (i : x.RightMoves) : IsOption (x.moveRight i) x
#align pgame.is_option SetTheory.PGame.IsOption
theorem IsOption.mk_left {xl xr : Type u} (xL : xl → PGame) (xR : xr → PGame) (i : xl) :
(xL i).IsOption (mk xl xr xL xR) :=
@IsOption.moveLeft (mk _ _ _ _) i
#align pgame.is_option.mk_left SetTheory.PGame.IsOption.mk_left
theorem IsOption.mk_right {xl xr : Type u} (xL : xl → PGame) (xR : xr → PGame) (i : xr) :
(xR i).IsOption (mk xl xr xL xR) :=
@IsOption.moveRight (mk _ _ _ _) i
#align pgame.is_option.mk_right SetTheory.PGame.IsOption.mk_right
theorem wf_isOption : WellFounded IsOption :=
⟨fun x =>
moveRecOn x fun x IHl IHr =>
Acc.intro x fun y h => by
induction' h with _ i _ j
· exact IHl i
· exact IHr j⟩
#align pgame.wf_is_option SetTheory.PGame.wf_isOption
def Subsequent : PGame → PGame → Prop :=
TransGen IsOption
#align pgame.subsequent SetTheory.PGame.Subsequent
instance : IsTrans _ Subsequent :=
inferInstanceAs <| IsTrans _ (TransGen _)
@[trans]
theorem Subsequent.trans {x y z} : Subsequent x y → Subsequent y z → Subsequent x z :=
TransGen.trans
#align pgame.subsequent.trans SetTheory.PGame.Subsequent.trans
theorem wf_subsequent : WellFounded Subsequent :=
wf_isOption.transGen
#align pgame.wf_subsequent SetTheory.PGame.wf_subsequent
instance : WellFoundedRelation PGame :=
⟨_, wf_subsequent⟩
@[simp]
theorem Subsequent.moveLeft {x : PGame} (i : x.LeftMoves) : Subsequent (x.moveLeft i) x :=
TransGen.single (IsOption.moveLeft i)
#align pgame.subsequent.move_left SetTheory.PGame.Subsequent.moveLeft
@[simp]
theorem Subsequent.moveRight {x : PGame} (j : x.RightMoves) : Subsequent (x.moveRight j) x :=
TransGen.single (IsOption.moveRight j)
#align pgame.subsequent.move_right SetTheory.PGame.Subsequent.moveRight
@[simp]
theorem Subsequent.mk_left {xl xr} (xL : xl → PGame) (xR : xr → PGame) (i : xl) :
Subsequent (xL i) (mk xl xr xL xR) :=
@Subsequent.moveLeft (mk _ _ _ _) i
#align pgame.subsequent.mk_left SetTheory.PGame.Subsequent.mk_left
@[simp]
theorem Subsequent.mk_right {xl xr} (xL : xl → PGame) (xR : xr → PGame) (j : xr) :
Subsequent (xR j) (mk xl xr xL xR) :=
@Subsequent.moveRight (mk _ _ _ _) j
#align pgame.subsequent.mk_right SetTheory.PGame.Subsequent.mk_right
macro "pgame_wf_tac" : tactic =>
`(tactic| solve_by_elim (config := { maxDepth := 8 })
[Prod.Lex.left, Prod.Lex.right, PSigma.Lex.left, PSigma.Lex.right,
Subsequent.moveLeft, Subsequent.moveRight, Subsequent.mk_left, Subsequent.mk_right,
Subsequent.trans] )
-- Register some consequences of pgame_wf_tac as simp-lemmas for convenience
-- (which are applied by default for WF goals)
-- This is different from mk_right from the POV of the simplifier,
-- because the unifier can't solve `xr =?= RightMoves (mk xl xr xL xR)` at reducible transparency.
@[simp]
theorem Subsequent.mk_right' (xL : xl → PGame) (xR : xr → PGame) (j : RightMoves (mk xl xr xL xR)) :
Subsequent (xR j) (mk xl xr xL xR) := by
pgame_wf_tac
@[simp] theorem Subsequent.moveRight_mk_left (xL : xl → PGame) (j) :
Subsequent ((xL i).moveRight j) (mk xl xr xL xR) := by
pgame_wf_tac
@[simp] theorem Subsequent.moveRight_mk_right (xR : xr → PGame) (j) :
Subsequent ((xR i).moveRight j) (mk xl xr xL xR) := by
pgame_wf_tac
@[simp] theorem Subsequent.moveLeft_mk_left (xL : xl → PGame) (j) :
Subsequent ((xL i).moveLeft j) (mk xl xr xL xR) := by
pgame_wf_tac
@[simp] theorem Subsequent.moveLeft_mk_right (xR : xr → PGame) (j) :
Subsequent ((xR i).moveLeft j) (mk xl xr xL xR) := by
pgame_wf_tac
-- Porting note: linter claims these lemmas don't simplify?
open Subsequent in attribute [nolint simpNF] mk_left mk_right mk_right'
moveRight_mk_left moveRight_mk_right moveLeft_mk_left moveLeft_mk_right
instance : Zero PGame :=
⟨⟨PEmpty, PEmpty, PEmpty.elim, PEmpty.elim⟩⟩
@[simp]
theorem zero_leftMoves : LeftMoves 0 = PEmpty :=
rfl
#align pgame.zero_left_moves SetTheory.PGame.zero_leftMoves
@[simp]
theorem zero_rightMoves : RightMoves 0 = PEmpty :=
rfl
#align pgame.zero_right_moves SetTheory.PGame.zero_rightMoves
instance isEmpty_zero_leftMoves : IsEmpty (LeftMoves 0) :=
instIsEmptyPEmpty
#align pgame.is_empty_zero_left_moves SetTheory.PGame.isEmpty_zero_leftMoves
instance isEmpty_zero_rightMoves : IsEmpty (RightMoves 0) :=
instIsEmptyPEmpty
#align pgame.is_empty_zero_right_moves SetTheory.PGame.isEmpty_zero_rightMoves
instance : Inhabited PGame :=
⟨0⟩
instance instOnePGame : One PGame :=
⟨⟨PUnit, PEmpty, fun _ => 0, PEmpty.elim⟩⟩
@[simp]
theorem one_leftMoves : LeftMoves 1 = PUnit :=
rfl
#align pgame.one_left_moves SetTheory.PGame.one_leftMoves
@[simp]
theorem one_moveLeft (x) : moveLeft 1 x = 0 :=
rfl
#align pgame.one_move_left SetTheory.PGame.one_moveLeft
@[simp]
theorem one_rightMoves : RightMoves 1 = PEmpty :=
rfl
#align pgame.one_right_moves SetTheory.PGame.one_rightMoves
instance uniqueOneLeftMoves : Unique (LeftMoves 1) :=
PUnit.unique
#align pgame.unique_one_left_moves SetTheory.PGame.uniqueOneLeftMoves
instance isEmpty_one_rightMoves : IsEmpty (RightMoves 1) :=
instIsEmptyPEmpty
#align pgame.is_empty_one_right_moves SetTheory.PGame.isEmpty_one_rightMoves
instance le : LE PGame :=
⟨Sym2.GameAdd.fix wf_isOption fun x y le =>
(∀ i, ¬le y (x.moveLeft i) (Sym2.GameAdd.snd_fst <| IsOption.moveLeft i)) ∧
∀ j, ¬le (y.moveRight j) x (Sym2.GameAdd.fst_snd <| IsOption.moveRight j)⟩
def LF (x y : PGame) : Prop :=
¬y ≤ x
#align pgame.lf SetTheory.PGame.LF
@[inherit_doc]
scoped infixl:50 " ⧏ " => PGame.LF
@[simp]
protected theorem not_le {x y : PGame} : ¬x ≤ y ↔ y ⧏ x :=
Iff.rfl
#align pgame.not_le SetTheory.PGame.not_le
@[simp]
theorem not_lf {x y : PGame} : ¬x ⧏ y ↔ y ≤ x :=
Classical.not_not
#align pgame.not_lf SetTheory.PGame.not_lf
theorem _root_.LE.le.not_gf {x y : PGame} : x ≤ y → ¬y ⧏ x :=
not_lf.2
#align has_le.le.not_gf LE.le.not_gf
theorem LF.not_ge {x y : PGame} : x ⧏ y → ¬y ≤ x :=
id
#align pgame.lf.not_ge SetTheory.PGame.LF.not_ge
theorem le_iff_forall_lf {x y : PGame} :
x ≤ y ↔ (∀ i, x.moveLeft i ⧏ y) ∧ ∀ j, x ⧏ y.moveRight j := by
unfold LE.le le
simp only
rw [Sym2.GameAdd.fix_eq]
rfl
#align pgame.le_iff_forall_lf SetTheory.PGame.le_iff_forall_lf
@[simp]
theorem mk_le_mk {xl xr xL xR yl yr yL yR} :
mk xl xr xL xR ≤ mk yl yr yL yR ↔ (∀ i, xL i ⧏ mk yl yr yL yR) ∧ ∀ j, mk xl xr xL xR ⧏ yR j :=
le_iff_forall_lf
#align pgame.mk_le_mk SetTheory.PGame.mk_le_mk
theorem le_of_forall_lf {x y : PGame} (h₁ : ∀ i, x.moveLeft i ⧏ y) (h₂ : ∀ j, x ⧏ y.moveRight j) :
x ≤ y :=
le_iff_forall_lf.2 ⟨h₁, h₂⟩
#align pgame.le_of_forall_lf SetTheory.PGame.le_of_forall_lf
theorem lf_iff_exists_le {x y : PGame} :
x ⧏ y ↔ (∃ i, x ≤ y.moveLeft i) ∨ ∃ j, x.moveRight j ≤ y := by
rw [LF, le_iff_forall_lf, not_and_or]
simp
#align pgame.lf_iff_exists_le SetTheory.PGame.lf_iff_exists_le
@[simp]
theorem mk_lf_mk {xl xr xL xR yl yr yL yR} :
mk xl xr xL xR ⧏ mk yl yr yL yR ↔ (∃ i, mk xl xr xL xR ≤ yL i) ∨ ∃ j, xR j ≤ mk yl yr yL yR :=
lf_iff_exists_le
#align pgame.mk_lf_mk SetTheory.PGame.mk_lf_mk
theorem le_or_gf (x y : PGame) : x ≤ y ∨ y ⧏ x := by
rw [← PGame.not_le]
apply em
#align pgame.le_or_gf SetTheory.PGame.le_or_gf
theorem moveLeft_lf_of_le {x y : PGame} (h : x ≤ y) (i) : x.moveLeft i ⧏ y :=
(le_iff_forall_lf.1 h).1 i
#align pgame.move_left_lf_of_le SetTheory.PGame.moveLeft_lf_of_le
alias _root_.LE.le.moveLeft_lf := moveLeft_lf_of_le
#align has_le.le.move_left_lf LE.le.moveLeft_lf
theorem lf_moveRight_of_le {x y : PGame} (h : x ≤ y) (j) : x ⧏ y.moveRight j :=
(le_iff_forall_lf.1 h).2 j
#align pgame.lf_move_right_of_le SetTheory.PGame.lf_moveRight_of_le
alias _root_.LE.le.lf_moveRight := lf_moveRight_of_le
#align has_le.le.lf_move_right LE.le.lf_moveRight
theorem lf_of_moveRight_le {x y : PGame} {j} (h : x.moveRight j ≤ y) : x ⧏ y :=
lf_iff_exists_le.2 <| Or.inr ⟨j, h⟩
#align pgame.lf_of_move_right_le SetTheory.PGame.lf_of_moveRight_le
theorem lf_of_le_moveLeft {x y : PGame} {i} (h : x ≤ y.moveLeft i) : x ⧏ y :=
lf_iff_exists_le.2 <| Or.inl ⟨i, h⟩
#align pgame.lf_of_le_move_left SetTheory.PGame.lf_of_le_moveLeft
theorem lf_of_le_mk {xl xr xL xR y} : mk xl xr xL xR ≤ y → ∀ i, xL i ⧏ y :=
moveLeft_lf_of_le
#align pgame.lf_of_le_mk SetTheory.PGame.lf_of_le_mk
theorem lf_of_mk_le {x yl yr yL yR} : x ≤ mk yl yr yL yR → ∀ j, x ⧏ yR j :=
lf_moveRight_of_le
#align pgame.lf_of_mk_le SetTheory.PGame.lf_of_mk_le
theorem mk_lf_of_le {xl xr y j} (xL) {xR : xr → PGame} : xR j ≤ y → mk xl xr xL xR ⧏ y :=
@lf_of_moveRight_le (mk _ _ _ _) y j
#align pgame.mk_lf_of_le SetTheory.PGame.mk_lf_of_le
theorem lf_mk_of_le {x yl yr} {yL : yl → PGame} (yR) {i} : x ≤ yL i → x ⧏ mk yl yr yL yR :=
@lf_of_le_moveLeft x (mk _ _ _ _) i
#align pgame.lf_mk_of_le SetTheory.PGame.lf_mk_of_le
private theorem le_trans_aux {x y z : PGame}
(h₁ : ∀ {i}, y ≤ z → z ≤ x.moveLeft i → y ≤ x.moveLeft i)
(h₂ : ∀ {j}, z.moveRight j ≤ x → x ≤ y → z.moveRight j ≤ y) (hxy : x ≤ y) (hyz : y ≤ z) :
x ≤ z :=
le_of_forall_lf (fun i => PGame.not_le.1 fun h => (h₁ hyz h).not_gf <| hxy.moveLeft_lf i)
fun j => PGame.not_le.1 fun h => (h₂ h hxy).not_gf <| hyz.lf_moveRight j
instance : Preorder PGame :=
{ PGame.le with
le_refl := fun x => by
induction' x with _ _ _ _ IHl IHr
exact
le_of_forall_lf (fun i => lf_of_le_moveLeft (IHl i)) fun i => lf_of_moveRight_le (IHr i)
le_trans := by
suffices
∀ {x y z : PGame},
(x ≤ y → y ≤ z → x ≤ z) ∧ (y ≤ z → z ≤ x → y ≤ x) ∧ (z ≤ x → x ≤ y → z ≤ y) from
fun x y z => this.1
intro x y z
induction' x with xl xr xL xR IHxl IHxr generalizing y z
induction' y with yl yr yL yR IHyl IHyr generalizing z
induction' z with zl zr zL zR IHzl IHzr
exact
⟨le_trans_aux (fun {i} => (IHxl i).2.1) fun {j} => (IHzr j).2.2,
le_trans_aux (fun {i} => (IHyl i).2.2) fun {j} => (IHxr j).1,
le_trans_aux (fun {i} => (IHzl i).1) fun {j} => (IHyr j).2.1⟩
lt := fun x y => x ≤ y ∧ x ⧏ y }
theorem lt_iff_le_and_lf {x y : PGame} : x < y ↔ x ≤ y ∧ x ⧏ y :=
Iff.rfl
#align pgame.lt_iff_le_and_lf SetTheory.PGame.lt_iff_le_and_lf
theorem lt_of_le_of_lf {x y : PGame} (h₁ : x ≤ y) (h₂ : x ⧏ y) : x < y :=
⟨h₁, h₂⟩
#align pgame.lt_of_le_of_lf SetTheory.PGame.lt_of_le_of_lf
theorem lf_of_lt {x y : PGame} (h : x < y) : x ⧏ y :=
h.2
#align pgame.lf_of_lt SetTheory.PGame.lf_of_lt
alias _root_.LT.lt.lf := lf_of_lt
#align has_lt.lt.lf LT.lt.lf
theorem lf_irrefl (x : PGame) : ¬x ⧏ x :=
le_rfl.not_gf
#align pgame.lf_irrefl SetTheory.PGame.lf_irrefl
instance : IsIrrefl _ (· ⧏ ·) :=
⟨lf_irrefl⟩
@[trans]
theorem lf_of_le_of_lf {x y z : PGame} (h₁ : x ≤ y) (h₂ : y ⧏ z) : x ⧏ z := by
rw [← PGame.not_le] at h₂ ⊢
exact fun h₃ => h₂ (h₃.trans h₁)
#align pgame.lf_of_le_of_lf SetTheory.PGame.lf_of_le_of_lf
-- Porting note (#10754): added instance
instance : Trans (· ≤ ·) (· ⧏ ·) (· ⧏ ·) := ⟨lf_of_le_of_lf⟩
@[trans]
theorem lf_of_lf_of_le {x y z : PGame} (h₁ : x ⧏ y) (h₂ : y ≤ z) : x ⧏ z := by
rw [← PGame.not_le] at h₁ ⊢
exact fun h₃ => h₁ (h₂.trans h₃)
#align pgame.lf_of_lf_of_le SetTheory.PGame.lf_of_lf_of_le
-- Porting note (#10754): added instance
instance : Trans (· ⧏ ·) (· ≤ ·) (· ⧏ ·) := ⟨lf_of_lf_of_le⟩
alias _root_.LE.le.trans_lf := lf_of_le_of_lf
#align has_le.le.trans_lf LE.le.trans_lf
alias LF.trans_le := lf_of_lf_of_le
#align pgame.lf.trans_le SetTheory.PGame.LF.trans_le
@[trans]
theorem lf_of_lt_of_lf {x y z : PGame} (h₁ : x < y) (h₂ : y ⧏ z) : x ⧏ z :=
h₁.le.trans_lf h₂
#align pgame.lf_of_lt_of_lf SetTheory.PGame.lf_of_lt_of_lf
@[trans]
theorem lf_of_lf_of_lt {x y z : PGame} (h₁ : x ⧏ y) (h₂ : y < z) : x ⧏ z :=
h₁.trans_le h₂.le
#align pgame.lf_of_lf_of_lt SetTheory.PGame.lf_of_lf_of_lt
alias _root_.LT.lt.trans_lf := lf_of_lt_of_lf
#align has_lt.lt.trans_lf LT.lt.trans_lf
alias LF.trans_lt := lf_of_lf_of_lt
#align pgame.lf.trans_lt SetTheory.PGame.LF.trans_lt
theorem moveLeft_lf {x : PGame} : ∀ i, x.moveLeft i ⧏ x :=
le_rfl.moveLeft_lf
#align pgame.move_left_lf SetTheory.PGame.moveLeft_lf
theorem lf_moveRight {x : PGame} : ∀ j, x ⧏ x.moveRight j :=
le_rfl.lf_moveRight
#align pgame.lf_move_right SetTheory.PGame.lf_moveRight
theorem lf_mk {xl xr} (xL : xl → PGame) (xR : xr → PGame) (i) : xL i ⧏ mk xl xr xL xR :=
@moveLeft_lf (mk _ _ _ _) i
#align pgame.lf_mk SetTheory.PGame.lf_mk
theorem mk_lf {xl xr} (xL : xl → PGame) (xR : xr → PGame) (j) : mk xl xr xL xR ⧏ xR j :=
@lf_moveRight (mk _ _ _ _) j
#align pgame.mk_lf SetTheory.PGame.mk_lf
theorem le_of_forall_lt {x y : PGame} (h₁ : ∀ i, x.moveLeft i < y) (h₂ : ∀ j, x < y.moveRight j) :
x ≤ y :=
le_of_forall_lf (fun i => (h₁ i).lf) fun i => (h₂ i).lf
#align pgame.le_of_forall_lt SetTheory.PGame.le_of_forall_lt
theorem le_def {x y : PGame} :
x ≤ y ↔
(∀ i, (∃ i', x.moveLeft i ≤ y.moveLeft i') ∨ ∃ j, (x.moveLeft i).moveRight j ≤ y) ∧
∀ j, (∃ i, x ≤ (y.moveRight j).moveLeft i) ∨ ∃ j', x.moveRight j' ≤ y.moveRight j := by
rw [le_iff_forall_lf]
conv =>
lhs
simp only [lf_iff_exists_le]
#align pgame.le_def SetTheory.PGame.le_def
theorem lf_def {x y : PGame} :
x ⧏ y ↔
(∃ i, (∀ i', x.moveLeft i' ⧏ y.moveLeft i) ∧ ∀ j, x ⧏ (y.moveLeft i).moveRight j) ∨
∃ j, (∀ i, (x.moveRight j).moveLeft i ⧏ y) ∧ ∀ j', x.moveRight j ⧏ y.moveRight j' := by
rw [lf_iff_exists_le]
conv =>
lhs
simp only [le_iff_forall_lf]
#align pgame.lf_def SetTheory.PGame.lf_def
theorem zero_le_lf {x : PGame} : 0 ≤ x ↔ ∀ j, 0 ⧏ x.moveRight j := by
rw [le_iff_forall_lf]
simp
#align pgame.zero_le_lf SetTheory.PGame.zero_le_lf
theorem le_zero_lf {x : PGame} : x ≤ 0 ↔ ∀ i, x.moveLeft i ⧏ 0 := by
rw [le_iff_forall_lf]
simp
#align pgame.le_zero_lf SetTheory.PGame.le_zero_lf
theorem zero_lf_le {x : PGame} : 0 ⧏ x ↔ ∃ i, 0 ≤ x.moveLeft i := by
rw [lf_iff_exists_le]
simp
#align pgame.zero_lf_le SetTheory.PGame.zero_lf_le
theorem lf_zero_le {x : PGame} : x ⧏ 0 ↔ ∃ j, x.moveRight j ≤ 0 := by
rw [lf_iff_exists_le]
simp
#align pgame.lf_zero_le SetTheory.PGame.lf_zero_le
| Mathlib/SetTheory/Game/PGame.lean | 671 | 673 | theorem zero_le {x : PGame} : 0 ≤ x ↔ ∀ j, ∃ i, 0 ≤ (x.moveRight j).moveLeft i := by |
rw [le_def]
simp
|
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.Data.Finset.NoncommProd
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Nat.GCD.BigOperators
import Mathlib.Order.SupIndep
#align_import group_theory.noncomm_pi_coprod from "leanprover-community/mathlib"@"6f9f36364eae3f42368b04858fd66d6d9ae730d8"
namespace Subgroup
variable {G : Type*} [Group G]
@[to_additive "`Finset.noncommSum` is “injective” in `f` if `f` maps into independent subgroups.
This generalizes (one direction of) `AddSubgroup.disjoint_iff_add_eq_zero`. "]
| Mathlib/GroupTheory/NoncommPiCoprod.lean | 55 | 78 | theorem eq_one_of_noncommProd_eq_one_of_independent {ι : Type*} (s : Finset ι) (f : ι → G) (comm)
(K : ι → Subgroup G) (hind : CompleteLattice.Independent K) (hmem : ∀ x ∈ s, f x ∈ K x)
(heq1 : s.noncommProd f comm = 1) : ∀ i ∈ s, f i = 1 := by |
classical
revert heq1
induction' s using Finset.induction_on with i s hnmem ih
· simp
· have hcomm := comm.mono (Finset.coe_subset.2 <| Finset.subset_insert _ _)
simp only [Finset.forall_mem_insert] at hmem
have hmem_bsupr : s.noncommProd f hcomm ∈ ⨆ i ∈ (s : Set ι), K i := by
refine Subgroup.noncommProd_mem _ _ ?_
intro x hx
have : K x ≤ ⨆ i ∈ (s : Set ι), K i := le_iSup₂ (f := fun i _ => K i) x hx
exact this (hmem.2 x hx)
intro heq1
rw [Finset.noncommProd_insert_of_not_mem _ _ _ _ hnmem] at heq1
have hnmem' : i ∉ (s : Set ι) := by simpa
obtain ⟨heq1i : f i = 1, heq1S : s.noncommProd f _ = 1⟩ :=
Subgroup.disjoint_iff_mul_eq_one.mp (hind.disjoint_biSup hnmem') hmem.1 hmem_bsupr heq1
intro i h
simp only [Finset.mem_insert] at h
rcases h with (rfl | h)
· exact heq1i
· refine ih hcomm hmem.2 heq1S _ h
|
import Mathlib.FieldTheory.Separable
import Mathlib.RingTheory.IntegralDomain
import Mathlib.Algebra.CharP.Reduced
import Mathlib.Tactic.ApplyFun
#align_import field_theory.finite.basic from "leanprover-community/mathlib"@"12a85fac627bea918960da036049d611b1a3ee43"
variable {K : Type*} {R : Type*}
local notation "q" => Fintype.card K
open Finset
open scoped Polynomial
namespace FiniteField
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 (config := { contextual := true }) [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]
#align finite_field.prod_univ_units_id_eq_neg_one FiniteField.prod_univ_units_id_eq_neg_one
set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532
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]
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 [a_mul_emb, h_unchanged, Function.Embedding.coeFn_mk, Function.Embedding.toFun_eq_coe,
mulLeftEmbedding_apply, Submonoid.coe_mul, Subgroup.coe_toSubmonoid, Units.val_mul,
← Finset.mul_sum] 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]
@[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 [ite_true, Subgroup.mem_bot, Fintype.card_ofSubsingleton, Nat.cast_ite, Nat.cast_one,
Nat.cast_zero, univ_unique, Set.default_coe_singleton, sum_singleton, Units.val_one]
· simp only [G_bot, ite_false]
exact sum_subgroup_units_eq_zero G_bot
@[simp]
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
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, Submonoid.coe_mul, Subgroup.coe_toSubmonoid, 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]
simp_rw [SubmonoidClass.coe_pow, Units.val_pow_eq_pow_val, OneMemClass.coe_one, Units.val_one, h]
section
variable [GroupWithZero K] [Fintype K]
theorem pow_card_sub_one_eq_one (a : K) (ha : a ≠ 0) : a ^ (q - 1) = 1 := by
calc
a ^ (Fintype.card K - 1) = (Units.mk0 a ha ^ (Fintype.card K - 1) : Kˣ).1 := by
rw [Units.val_pow_eq_pow_val, Units.val_mk0]
_ = 1 := by
classical
rw [← Fintype.card_units, pow_card_eq_one]
rfl
#align finite_field.pow_card_sub_one_eq_one FiniteField.pow_card_sub_one_eq_one
theorem pow_card (a : K) : a ^ q = a := by
by_cases h : a = 0; · rw [h]; apply zero_pow Fintype.card_ne_zero
rw [← Nat.succ_pred_eq_of_pos Fintype.card_pos, pow_succ, Nat.pred_eq_sub_one,
pow_card_sub_one_eq_one a h, one_mul]
#align finite_field.pow_card FiniteField.pow_card
| Mathlib/FieldTheory/Finite/Basic.lean | 232 | 235 | theorem pow_card_pow (n : ℕ) (a : K) : a ^ q ^ n = a := by |
induction' n with n ih
· simp
· simp [pow_succ, pow_mul, ih, pow_card]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.