Context stringlengths 227 76.5k | target stringlengths 0 11.6k | file_name stringlengths 21 79 | start int64 14 3.67k | end int64 16 3.69k |
|---|---|---|---|---|
/-
Copyright (c) 2019 Jean Lo. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean Lo, Yaël Dillies, Moritz Doll
-/
import Mathlib.Algebra.Order.Pi
import Mathlib.Analysis.Convex.Function
import Mathlib.Analysis.LocallyConvex.Basic
import Mathlib.Data.Real.Pointwise
/-!
# Seminorms
This file defines seminorms.
A seminorm is a function to the reals which is positive-semidefinite, absolutely homogeneous, and
subadditive. They are closely related to convex sets, and a topological vector space is locally
convex if and only if its topology is induced by a family of seminorms.
## Main declarations
For a module over a normed ring:
* `Seminorm`: A function to the reals that is positive-semidefinite, absolutely homogeneous, and
subadditive.
* `normSeminorm ð E`: The norm on `E` as a seminorm.
## References
* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]
## Tags
seminorm, locally convex, LCTVS
-/
assert_not_exists balancedCore
open NormedField Set Filter
open scoped NNReal Pointwise Topology Uniformity
variable {R R' ð ðâ ðâ ð E Eâ Eâ F ι : Type*}
/-- A seminorm on a module over a normed ring is a function to the reals that is positive
semidefinite, positive homogeneous, and subadditive. -/
structure Seminorm (ð : Type*) (E : Type*) [SeminormedRing ð] [AddGroup E] [SMul ð E] extends
AddGroupSeminorm E where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
smul' : â (a : ð) (x : E), toFun (a ⢠x) = âaâ * toFun x
attribute [nolint docBlame] Seminorm.toAddGroupSeminorm
/-- `SeminormClass F ð E` states that `F` is a type of seminorms on the `ð`-module `E`.
You should extend this class when you extend `Seminorm`. -/
class SeminormClass (F : Type*) (ð E : outParam Type*) [SeminormedRing ð] [AddGroup E]
[SMul ð E] [FunLike F E â] : Prop extends AddGroupSeminormClass F E â where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
map_smul_eq_mul (f : F) (a : ð) (x : E) : f (a ⢠x) = âaâ * f x
export SeminormClass (map_smul_eq_mul)
section Of
/-- Alternative constructor for a `Seminorm` on an `AddCommGroup E` that is a module over a
`SeminormedRing ð`. -/
def Seminorm.of [SeminormedRing ð] [AddCommGroup E] [Module ð E] (f : E â â)
(add_le : â x y : E, f (x + y) †f x + f y) (smul : â (a : ð) (x : E), f (a ⢠x) = âaâ * f x) :
Seminorm ð E where
toFun := f
map_zero' := by rw [â zero_smul ð (0 : E), smul, norm_zero, zero_mul]
add_le' := add_le
smul' := smul
neg' x := by rw [â neg_one_smul ð, smul, norm_neg, â smul, one_smul]
/-- Alternative constructor for a `Seminorm` over a normed field `ð` that only assumes `f 0 = 0`
and an inequality for the scalar multiplication. -/
def Seminorm.ofSMulLE [NormedField ð] [AddCommGroup E] [Module ð E] (f : E â â) (map_zero : f 0 = 0)
(add_le : â x y, f (x + y) †f x + f y) (smul_le : â (r : ð) (x), f (r ⢠x) †ârâ * f x) :
Seminorm ð E :=
Seminorm.of f add_le fun r x => by
refine le_antisymm (smul_le r x) ?_
by_cases h : r = 0
· simp [h, map_zero]
rw [â mul_le_mul_left (inv_pos.mpr (norm_pos_iff.mpr h))]
rw [inv_mul_cancel_leftâ (norm_ne_zero_iff.mpr h)]
specialize smul_le râ»Â¹ (r ⢠x)
rw [norm_inv] at smul_le
convert smul_le
simp [h]
end Of
namespace Seminorm
section SeminormedRing
variable [SeminormedRing ð]
section AddGroup
variable [AddGroup E]
section SMul
variable [SMul ð E]
instance instFunLike : FunLike (Seminorm ð E) E â where
coe f := f.toFun
coe_injective' f g h := by
rcases f with âšâš_â©â©
rcases g with âšâš_â©â©
congr
instance instSeminormClass : SeminormClass (Seminorm ð E) ð E where
map_zero f := f.map_zero'
map_add_le_add f := f.add_le'
map_neg_eq_map f := f.neg'
map_smul_eq_mul f := f.smul'
@[ext]
theorem ext {p q : Seminorm ð E} (h : â x, (p : E â â) x = q x) : p = q :=
DFunLike.ext p q h
instance instZero : Zero (Seminorm ð E) :=
âš{ AddGroupSeminorm.instZeroAddGroupSeminorm.zero with
smul' := fun _ _ => (mul_zero _).symm }â©
@[simp]
theorem coe_zero : â(0 : Seminorm ð E) = 0 :=
rfl
@[simp]
theorem zero_apply (x : E) : (0 : Seminorm ð E) x = 0 :=
rfl
instance : Inhabited (Seminorm ð E) :=
âš0â©
variable (p : Seminorm ð E) (x : E) (r : â)
/-- Any action on `â` which factors through `ââ¥0` applies to a seminorm. -/
instance instSMul [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] : SMul R (Seminorm ð E) where
smul r p :=
{ r ⢠p.toAddGroupSeminorm with
toFun := fun x => r ⢠p x
smul' := fun _ _ => by
simp only [â smul_one_smul ââ¥0 r (_ : â), NNReal.smul_def, smul_eq_mul]
rw [map_smul_eq_mul, mul_left_comm] }
instance [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] [SMul R' â] [SMul R' ââ¥0]
[IsScalarTower R' ââ¥0 â] [SMul R R'] [IsScalarTower R R' â] :
IsScalarTower R R' (Seminorm ð E) where
smul_assoc r a p := ext fun x => smul_assoc r a (p x)
theorem coe_smul [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] (r : R) (p : Seminorm ð E) :
â(r ⢠p) = r ⢠âp :=
rfl
@[simp]
theorem smul_apply [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] (r : R) (p : Seminorm ð E)
(x : E) : (r ⢠p) x = r ⢠p x :=
rfl
instance instAdd : Add (Seminorm ð E) where
add p q :=
{ p.toAddGroupSeminorm + q.toAddGroupSeminorm with
toFun := fun x => p x + q x
smul' := fun a x => by simp only [map_smul_eq_mul, map_smul_eq_mul, mul_add] }
theorem coe_add (p q : Seminorm ð E) : â(p + q) = p + q :=
rfl
@[simp]
theorem add_apply (p q : Seminorm ð E) (x : E) : (p + q) x = p x + q x :=
rfl
instance instAddMonoid : AddMonoid (Seminorm ð E) :=
DFunLike.coe_injective.addMonoid _ rfl coe_add fun _ _ => by rfl
instance instAddCommMonoid : AddCommMonoid (Seminorm ð E) :=
DFunLike.coe_injective.addCommMonoid _ rfl coe_add fun _ _ => by rfl
instance instPartialOrder : PartialOrder (Seminorm ð E) :=
PartialOrder.lift _ DFunLike.coe_injective
instance instIsOrderedCancelAddMonoid : IsOrderedCancelAddMonoid (Seminorm ð E) :=
DFunLike.coe_injective.isOrderedCancelAddMonoid _ rfl coe_add fun _ _ => rfl
instance instMulAction [Monoid R] [MulAction R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] :
MulAction R (Seminorm ð E) :=
DFunLike.coe_injective.mulAction _ (by intros; rfl)
variable (ð E)
/-- `coeFn` as an `AddMonoidHom`. Helper definition for showing that `Seminorm ð E` is a module. -/
@[simps]
def coeFnAddMonoidHom : AddMonoidHom (Seminorm ð E) (E â â) where
toFun := (â)
map_zero' := coe_zero
map_add' := coe_add
theorem coeFnAddMonoidHom_injective : Function.Injective (coeFnAddMonoidHom ð E) :=
show @Function.Injective (Seminorm ð E) (E â â) (â) from DFunLike.coe_injective
variable {ð E}
instance instDistribMulAction [Monoid R] [DistribMulAction R â] [SMul R ââ¥0]
[IsScalarTower R ââ¥0 â] : DistribMulAction R (Seminorm ð E) :=
(coeFnAddMonoidHom_injective ð E).distribMulAction _ (by intros; rfl)
instance instModule [Semiring R] [Module R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] :
Module R (Seminorm ð E) :=
(coeFnAddMonoidHom_injective ð E).module R _ (by intros; rfl)
instance instSup : Max (Seminorm ð E) where
max p q :=
{ p.toAddGroupSeminorm â q.toAddGroupSeminorm with
toFun := p â q
smul' := fun x v =>
(congr_argâ max (map_smul_eq_mul p x v) (map_smul_eq_mul q x v)).trans <|
(mul_max_of_nonneg _ _ <| norm_nonneg x).symm }
@[simp]
theorem coe_sup (p q : Seminorm ð E) : â(p â q) = (p : E â â) â (q : E â â) :=
rfl
theorem sup_apply (p q : Seminorm ð E) (x : E) : (p â q) x = p x â q x :=
rfl
theorem smul_sup [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] (r : R) (p q : Seminorm ð E) :
r ⢠(p â q) = r ⢠p â r ⢠q :=
have real.smul_max : â x y : â, r ⢠max x y = max (r ⢠x) (r ⢠y) := fun x y => by
simpa only [â smul_eq_mul, â NNReal.smul_def, smul_one_smul ââ¥0 r (_ : â)] using
mul_max_of_nonneg x y (r ⢠(1 : ââ¥0) : ââ¥0).coe_nonneg
ext fun _ => real.smul_max _ _
@[simp, norm_cast]
theorem coe_le_coe {p q : Seminorm ð E} : (p : E â â) †q â p †q :=
Iff.rfl
@[simp, norm_cast]
theorem coe_lt_coe {p q : Seminorm ð E} : (p : E â â) < q â p < q :=
Iff.rfl
theorem le_def {p q : Seminorm ð E} : p †q â â x, p x †q x :=
Iff.rfl
theorem lt_def {p q : Seminorm ð E} : p < q â p †q â§ â x, p x < q x :=
@Pi.lt_def _ _ _ p q
instance instSemilatticeSup : SemilatticeSup (Seminorm ð E) :=
Function.Injective.semilatticeSup _ DFunLike.coe_injective coe_sup
end SMul
end AddGroup
section Module
variable [SeminormedRing ðâ] [SeminormedRing ðâ]
variable {Ïââ : ð â+* ðâ} [RingHomIsometric Ïââ]
variable {Ïââ : ðâ â+* ðâ} [RingHomIsometric Ïââ]
variable {Ïââ : ð â+* ðâ} [RingHomIsometric Ïââ]
variable [AddCommGroup E] [AddCommGroup Eâ] [AddCommGroup Eâ]
variable [Module ð E] [Module ðâ Eâ] [Module ðâ Eâ]
variable [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â]
/-- Composition of a seminorm with a linear map is a seminorm. -/
def comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) : Seminorm ð E :=
{ p.toAddGroupSeminorm.comp f.toAddMonoidHom with
toFun := fun x => p (f x)
-- Porting note: the `simp only` below used to be part of the `rw`.
-- I'm not sure why this change was needed, and am worried by it!
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to change `map_smulââ` to `map_smulââ _`
smul' := fun _ _ => by simp only [map_smulââ _]; rw [map_smul_eq_mul, RingHomIsometric.is_iso] }
theorem coe_comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) : â(p.comp f) = p â f :=
rfl
@[simp]
theorem comp_apply (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (x : E) : (p.comp f) x = p (f x) :=
rfl
@[simp]
theorem comp_id (p : Seminorm ð E) : p.comp LinearMap.id = p :=
ext fun _ => rfl
@[simp]
theorem comp_zero (p : Seminorm ðâ Eâ) : p.comp (0 : E âââ[Ïââ] Eâ) = 0 :=
ext fun _ => map_zero p
@[simp]
theorem zero_comp (f : E âââ[Ïââ] Eâ) : (0 : Seminorm ðâ Eâ).comp f = 0 :=
ext fun _ => rfl
theorem comp_comp [RingHomCompTriple Ïââ Ïââ Ïââ] (p : Seminorm ðâ Eâ) (g : Eâ âââ[Ïââ] Eâ)
(f : E âââ[Ïââ] Eâ) : p.comp (g.comp f) = (p.comp g).comp f :=
ext fun _ => rfl
theorem add_comp (p q : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) :
(p + q).comp f = p.comp f + q.comp f :=
ext fun _ => rfl
theorem comp_add_le (p : Seminorm ðâ Eâ) (f g : E âââ[Ïââ] Eâ) :
p.comp (f + g) †p.comp f + p.comp g := fun _ => map_add_le_add p _ _
theorem smul_comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (c : R) :
(c ⢠p).comp f = c ⢠p.comp f :=
ext fun _ => rfl
theorem comp_mono {p q : Seminorm ðâ Eâ} (f : E âââ[Ïââ] Eâ) (hp : p †q) : p.comp f †q.comp f :=
fun _ => hp _
/-- The composition as an `AddMonoidHom`. -/
@[simps]
def pullback (f : E âââ[Ïââ] Eâ) : Seminorm ðâ Eâ â+ Seminorm ð E where
toFun := fun p => p.comp f
map_zero' := zero_comp f
map_add' := fun p q => add_comp p q f
instance instOrderBot : OrderBot (Seminorm ð E) where
bot := 0
bot_le := apply_nonneg
@[simp]
theorem coe_bot : â(⥠: Seminorm ð E) = 0 :=
rfl
theorem bot_eq_zero : (⥠: Seminorm ð E) = 0 :=
rfl
theorem smul_le_smul {p q : Seminorm ð E} {a b : ââ¥0} (hpq : p †q) (hab : a †b) :
a ⢠p †b ⢠q := by
simp_rw [le_def]
intro x
exact mul_le_mul hab (hpq x) (apply_nonneg p x) (NNReal.coe_nonneg b)
theorem finset_sup_apply (p : ι â Seminorm ð E) (s : Finset ι) (x : E) :
s.sup p x = â(s.sup fun i => âšp i x, apply_nonneg (p i) xâ© : ââ¥0) := by
induction' s using Finset.cons_induction_on with a s ha ih
· rw [Finset.sup_empty, Finset.sup_empty, coe_bot, _root_.bot_eq_zero, Pi.zero_apply]
norm_cast
· rw [Finset.sup_cons, Finset.sup_cons, coe_sup, Pi.sup_apply, NNReal.coe_max, NNReal.coe_mk, ih]
theorem exists_apply_eq_finset_sup (p : ι â Seminorm ð E) {s : Finset ι} (hs : s.Nonempty) (x : E) :
â i â s, s.sup p x = p i x := by
rcases Finset.exists_mem_eq_sup s hs (fun i ⊠(âšp i x, apply_nonneg _ _â© : ââ¥0)) with âši, hi, hixâ©
rw [finset_sup_apply]
exact âši, hi, congr_arg _ hixâ©
theorem zero_or_exists_apply_eq_finset_sup (p : ι â Seminorm ð E) (s : Finset ι) (x : E) :
s.sup p x = 0 âš â i â s, s.sup p x = p i x := by
rcases Finset.eq_empty_or_nonempty s with (rfl|hs)
· left; rfl
· right; exact exists_apply_eq_finset_sup p hs x
theorem finset_sup_smul (p : ι â Seminorm ð E) (s : Finset ι) (C : ââ¥0) :
s.sup (C ⢠p) = C ⢠s.sup p := by
ext x
rw [smul_apply, finset_sup_apply, finset_sup_apply]
symm
exact congr_arg ((â) : ââ¥0 â â) (NNReal.mul_finset_sup C s (fun i ⊠âšp i x, apply_nonneg _ _â©))
theorem finset_sup_le_sum (p : ι â Seminorm ð E) (s : Finset ι) : s.sup p †â i â s, p i := by
classical
refine Finset.sup_le_iff.mpr ?_
intro i hi
rw [Finset.sum_eq_sum_diff_singleton_add hi, le_add_iff_nonneg_left]
exact bot_le
theorem finset_sup_apply_le {p : ι â Seminorm ð E} {s : Finset ι} {x : E} {a : â} (ha : 0 †a)
(h : â i, i â s â p i x †a) : s.sup p x †a := by
lift a to ââ¥0 using ha
rw [finset_sup_apply, NNReal.coe_le_coe]
exact Finset.sup_le h
theorem le_finset_sup_apply {p : ι â Seminorm ð E} {s : Finset ι} {x : E} {i : ι}
(hi : i â s) : p i x †s.sup p x :=
(Finset.le_sup hi : p i †s.sup p) x
theorem finset_sup_apply_lt {p : ι â Seminorm ð E} {s : Finset ι} {x : E} {a : â} (ha : 0 < a)
(h : â i, i â s â p i x < a) : s.sup p x < a := by
lift a to ââ¥0 using ha.le
rw [finset_sup_apply, NNReal.coe_lt_coe, Finset.sup_lt_iff]
· exact h
· exact NNReal.coe_pos.mpr ha
theorem norm_sub_map_le_sub (p : Seminorm ð E) (x y : E) : âp x - p yâ †p (x - y) :=
abs_sub_map_le_sub p x y
end Module
end SeminormedRing
section SeminormedCommRing
variable [SeminormedRing ð] [SeminormedCommRing ðâ]
variable {Ïââ : ð â+* ðâ} [RingHomIsometric Ïââ]
variable [AddCommGroup E] [AddCommGroup Eâ] [Module ð E] [Module ðâ Eâ]
theorem comp_smul (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (c : ðâ) :
p.comp (c ⢠f) = âcââ ⢠p.comp f :=
ext fun _ => by
rw [comp_apply, smul_apply, LinearMap.smul_apply, map_smul_eq_mul, NNReal.smul_def, coe_nnnorm,
smul_eq_mul, comp_apply]
theorem comp_smul_apply (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (c : ðâ) (x : E) :
p.comp (c ⢠f) x = âcâ * p (f x) :=
map_smul_eq_mul p _ _
end SeminormedCommRing
section NormedField
variable [NormedField ð] [AddCommGroup E] [Module ð E] {p q : Seminorm ð E} {x : E}
/-- Auxiliary lemma to show that the infimum of seminorms is well-defined. -/
theorem bddBelow_range_add : BddBelow (range fun u => p u + q (x - u)) :=
âš0, by
rintro _ âšx, rflâ©
dsimp; positivityâ©
noncomputable instance instInf : Min (Seminorm ð E) where
min p q :=
{ p.toAddGroupSeminorm â q.toAddGroupSeminorm with
toFun := fun x => âš
u : E, p u + q (x - u)
smul' := by
intro a x
obtain rfl | ha := eq_or_ne a 0
· rw [norm_zero, zero_mul, zero_smul]
refine
ciInf_eq_of_forall_ge_of_forall_gt_exists_lt
(fun i => by positivity)
fun x hx => âš0, by rwa [map_zero, sub_zero, map_zero, add_zero]â©
simp_rw [Real.mul_iInf_of_nonneg (norm_nonneg a), mul_add, â map_smul_eq_mul p, â
map_smul_eq_mul q, smul_sub]
refine
Function.Surjective.iInf_congr ((aâ»Â¹ ⢠·) : E â E)
(fun u => âša ⢠u, inv_smul_smulâ ha uâ©) fun u => ?_
rw [smul_inv_smulâ ha] }
@[simp]
theorem inf_apply (p q : Seminorm ð E) (x : E) : (p â q) x = âš
u : E, p u + q (x - u) :=
rfl
noncomputable instance instLattice : Lattice (Seminorm ð E) :=
{ Seminorm.instSemilatticeSup with
inf := (· â ·)
inf_le_left := fun p q x =>
ciInf_le_of_le bddBelow_range_add x <| by
simp only [sub_self, map_zero, add_zero]; rfl
inf_le_right := fun p q x =>
ciInf_le_of_le bddBelow_range_add 0 <| by
simp only [sub_self, map_zero, zero_add, sub_zero]; rfl
le_inf := fun a _ _ hab hac _ =>
le_ciInf fun _ => (le_map_add_map_sub a _ _).trans <| add_le_add (hab _) (hac _) }
theorem smul_inf [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] (r : R) (p q : Seminorm ð E) :
r ⢠(p â q) = r ⢠p â r ⢠q := by
ext
simp_rw [smul_apply, inf_apply, smul_apply, â smul_one_smul ââ¥0 r (_ : â), NNReal.smul_def,
smul_eq_mul, Real.mul_iInf_of_nonneg (NNReal.coe_nonneg _), mul_add]
section Classical
open Classical in
/-- We define the supremum of an arbitrary subset of `Seminorm ð E` as follows:
* if `s` is `BddAbove` *as a set of functions `E â â`* (that is, if `s` is pointwise bounded
above), we take the pointwise supremum of all elements of `s`, and we prove that it is indeed a
seminorm.
* otherwise, we take the zero seminorm `â¥`.
There are two things worth mentioning here:
* First, it is not trivial at first that `s` being bounded above *by a function* implies
being bounded above *as a seminorm*. We show this in `Seminorm.bddAbove_iff` by using
that the `Sup s` as defined here is then a bounding seminorm for `s`. So it is important to make
the case disjunction on `BddAbove ((â) '' s : Set (E â â))` and not `BddAbove s`.
* Since the pointwise `Sup` already gives `0` at points where a family of functions is
not bounded above, one could hope that just using the pointwise `Sup` would work here, without the
need for an additional case disjunction. As discussed on Zulip, this doesn't work because this can
give a function which does *not* satisfy the seminorm axioms (typically sub-additivity).
-/
noncomputable instance instSupSet : SupSet (Seminorm ð E) where
sSup s :=
if h : BddAbove ((â) '' s : Set (E â â)) then
{ toFun := âš p : s, ((p : Seminorm ð E) : E â â)
map_zero' := by
rw [iSup_apply, â @Real.iSup_const_zero s]
congr!
rename_i _ _ _ i
exact map_zero i.1
add_le' := fun x y => by
rcases h with âšq, hqâ©
obtain rfl | h := s.eq_empty_or_nonempty
· simp [Real.iSup_of_isEmpty]
haveI : Nonempty âs := h.coe_sort
simp only [iSup_apply]
refine ciSup_le fun i =>
((i : Seminorm ð E).add_le' x y).trans <| add_le_add
-- Porting note: `f` is provided to force `Subtype.val` to appear.
-- A type ascription on `_` would have also worked, but would have been more verbose.
(le_ciSup (f := fun i => (Subtype.val i : Seminorm ð E).toFun x) âšq x, ?_â© i)
(le_ciSup (f := fun i => (Subtype.val i : Seminorm ð E).toFun y) âšq y, ?_â© i)
<;> rw [mem_upperBounds, forall_mem_range]
<;> exact fun j => hq (mem_image_of_mem _ j.2) _
neg' := fun x => by
simp only [iSup_apply]
congr! 2
rename_i _ _ _ i
exact i.1.neg' _
smul' := fun a x => by
simp only [iSup_apply]
rw [â smul_eq_mul,
Real.smul_iSup_of_nonneg (norm_nonneg a) fun i : s => (i : Seminorm ð E) x]
congr!
rename_i _ _ _ i
exact i.1.smul' a x }
else â¥
protected theorem coe_sSup_eq' {s : Set <| Seminorm ð E}
(hs : BddAbove ((â) '' s : Set (E â â))) : â(sSup s) = âš p : s, ((p : Seminorm ð E) : E â â) :=
congr_arg _ (dif_pos hs)
protected theorem bddAbove_iff {s : Set <| Seminorm ð E} :
BddAbove s â BddAbove ((â) '' s : Set (E â â)) :=
âšfun âšq, hqâ© => âšq, forall_mem_image.2 fun _ hp => hq hpâ©, fun H =>
âšsSup s, fun p hp x => by
dsimp
rw [Seminorm.coe_sSup_eq' H, iSup_apply]
rcases H with âšq, hqâ©
exact
le_ciSup âšq x, forall_mem_range.mpr fun i : s => hq (mem_image_of_mem _ i.2) xâ© âšp, hpâ©â©â©
protected theorem bddAbove_range_iff {ι : Sort*} {p : ι â Seminorm ð E} :
BddAbove (range p) â â x, BddAbove (range fun i ⊠p i x) := by
rw [Seminorm.bddAbove_iff, â range_comp, bddAbove_range_pi]; rfl
protected theorem coe_sSup_eq {s : Set <| Seminorm ð E} (hs : BddAbove s) :
â(sSup s) = âš p : s, ((p : Seminorm ð E) : E â â) :=
Seminorm.coe_sSup_eq' (Seminorm.bddAbove_iff.mp hs)
protected theorem coe_iSup_eq {ι : Sort*} {p : ι â Seminorm ð E} (hp : BddAbove (range p)) :
â(âš i, p i) = âš i, ((p i : Seminorm ð E) : E â â) := by
rw [â sSup_range, Seminorm.coe_sSup_eq hp]
exact iSup_range' (fun p : Seminorm ð E => (p : E â â)) p
protected theorem sSup_apply {s : Set (Seminorm ð E)} (hp : BddAbove s) {x : E} :
(sSup s) x = âš p : s, (p : E â â) x := by
rw [Seminorm.coe_sSup_eq hp, iSup_apply]
protected theorem iSup_apply {ι : Sort*} {p : ι â Seminorm ð E}
(hp : BddAbove (range p)) {x : E} : (âš i, p i) x = âš i, p i x := by
rw [Seminorm.coe_iSup_eq hp, iSup_apply]
protected theorem sSup_empty : sSup (â
: Set (Seminorm ð E)) = ⥠:= by
ext
rw [Seminorm.sSup_apply bddAbove_empty, Real.iSup_of_isEmpty]
rfl
private theorem isLUB_sSup (s : Set (Seminorm ð E)) (hsâ : BddAbove s) (hsâ : s.Nonempty) :
IsLUB s (sSup s) := by
refine âšfun p hp x => ?_, fun p hp x => ?_â© <;> haveI : Nonempty âs := hsâ.coe_sort <;>
dsimp <;> rw [Seminorm.coe_sSup_eq hsâ, iSup_apply]
· rcases hsâ with âšq, hqâ©
exact le_ciSup âšq x, forall_mem_range.mpr fun i : s => hq i.2 xâ© âšp, hpâ©
· exact ciSup_le fun q => hp q.2 x
/-- `Seminorm ð E` is a conditionally complete lattice.
Note that, while `inf`, `sup` and `sSup` have good definitional properties (corresponding to
the instances given here for `Inf`, `Sup` and `SupSet` respectively), `sInf s` is just
defined as the supremum of the lower bounds of `s`, which is not really useful in practice. If you
need to use `sInf` on seminorms, then you should probably provide a more workable definition first,
but this is unlikely to happen so we keep the "bad" definition for now. -/
noncomputable instance instConditionallyCompleteLattice :
ConditionallyCompleteLattice (Seminorm ð E) :=
conditionallyCompleteLatticeOfLatticeOfsSup (Seminorm ð E) Seminorm.isLUB_sSup
end Classical
end NormedField
/-! ### Seminorm ball -/
section SeminormedRing
variable [SeminormedRing ð]
section AddCommGroup
variable [AddCommGroup E]
section SMul
variable [SMul ð E] (p : Seminorm ð E)
/-- The ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y` with
`p (y - x) < r`. -/
def ball (x : E) (r : â) :=
{ y : E | p (y - x) < r }
/-- The closed ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y`
with `p (y - x) †r`. -/
def closedBall (x : E) (r : â) :=
{ y : E | p (y - x) †r }
variable {x y : E} {r : â}
@[simp]
theorem mem_ball : y â ball p x r â p (y - x) < r :=
Iff.rfl
@[simp]
theorem mem_closedBall : y â closedBall p x r â p (y - x) †r :=
Iff.rfl
theorem mem_ball_self (hr : 0 < r) : x â ball p x r := by simp [hr]
theorem mem_closedBall_self (hr : 0 †r) : x â closedBall p x r := by simp [hr]
theorem mem_ball_zero : y â ball p 0 r â p y < r := by rw [mem_ball, sub_zero]
theorem mem_closedBall_zero : y â closedBall p 0 r â p y †r := by rw [mem_closedBall, sub_zero]
theorem ball_zero_eq : ball p 0 r = { y : E | p y < r } :=
Set.ext fun _ => p.mem_ball_zero
theorem closedBall_zero_eq : closedBall p 0 r = { y : E | p y †r } :=
Set.ext fun _ => p.mem_closedBall_zero
theorem ball_subset_closedBall (x r) : ball p x r â closedBall p x r := fun _ h =>
(mem_closedBall _).mpr ((mem_ball _).mp h).le
theorem closedBall_eq_biInter_ball (x r) : closedBall p x r = â Ï > r, ball p x Ï := by
ext y; simp_rw [mem_closedBall, mem_iInterâ, mem_ball, â forall_lt_iff_le']
@[simp]
theorem ball_zero' (x : E) (hr : 0 < r) : ball (0 : Seminorm ð E) x r = Set.univ := by
rw [Set.eq_univ_iff_forall, ball]
simp [hr]
@[simp]
theorem closedBall_zero' (x : E) (hr : 0 < r) : closedBall (0 : Seminorm ð E) x r = Set.univ :=
eq_univ_of_subset (ball_subset_closedBall _ _ _) (ball_zero' x hr)
theorem ball_smul (p : Seminorm ð E) {c : NNReal} (hc : 0 < c) (r : â) (x : E) :
(c ⢠p).ball x r = p.ball x (r / c) := by
ext
rw [mem_ball, mem_ball, smul_apply, NNReal.smul_def, smul_eq_mul, mul_comm,
lt_div_iffâ (NNReal.coe_pos.mpr hc)]
theorem closedBall_smul (p : Seminorm ð E) {c : NNReal} (hc : 0 < c) (r : â) (x : E) :
(c ⢠p).closedBall x r = p.closedBall x (r / c) := by
ext
rw [mem_closedBall, mem_closedBall, smul_apply, NNReal.smul_def, smul_eq_mul, mul_comm,
le_div_iffâ (NNReal.coe_pos.mpr hc)]
theorem ball_sup (p : Seminorm ð E) (q : Seminorm ð E) (e : E) (r : â) :
ball (p â q) e r = ball p e r â© ball q e r := by
simp_rw [ball, â Set.setOf_and, coe_sup, Pi.sup_apply, sup_lt_iff]
theorem closedBall_sup (p : Seminorm ð E) (q : Seminorm ð E) (e : E) (r : â) :
closedBall (p â q) e r = closedBall p e r â© closedBall q e r := by
simp_rw [closedBall, â Set.setOf_and, coe_sup, Pi.sup_apply, sup_le_iff]
theorem ball_finset_sup' (p : ι â Seminorm ð E) (s : Finset ι) (H : s.Nonempty) (e : E) (r : â) :
ball (s.sup' H p) e r = s.inf' H fun i => ball (p i) e r := by
induction H using Finset.Nonempty.cons_induction with
| singleton => simp
| cons _ _ _ hs ih =>
rw [Finset.sup'_cons hs, Finset.inf'_cons hs, ball_sup]
-- Porting note: `rw` can't use `inf_eq_inter` here, but `simp` can?
simp only [inf_eq_inter, ih]
theorem closedBall_finset_sup' (p : ι â Seminorm ð E) (s : Finset ι) (H : s.Nonempty) (e : E)
(r : â) : closedBall (s.sup' H p) e r = s.inf' H fun i => closedBall (p i) e r := by
induction H using Finset.Nonempty.cons_induction with
| singleton => simp
| cons _ _ _ hs ih =>
rw [Finset.sup'_cons hs, Finset.inf'_cons hs, closedBall_sup]
-- Porting note: `rw` can't use `inf_eq_inter` here, but `simp` can?
simp only [inf_eq_inter, ih]
theorem ball_mono {p : Seminorm ð E} {râ râ : â} (h : râ †râ) : p.ball x râ â p.ball x râ :=
fun _ (hx : _ < _) => hx.trans_le h
theorem closedBall_mono {p : Seminorm ð E} {râ râ : â} (h : râ †râ) :
p.closedBall x râ â p.closedBall x râ := fun _ (hx : _ †_) => hx.trans h
theorem ball_antitone {p q : Seminorm ð E} (h : q †p) : p.ball x r â q.ball x r := fun _ =>
(h _).trans_lt
theorem closedBall_antitone {p q : Seminorm ð E} (h : q †p) :
p.closedBall x r â q.closedBall x r := fun _ => (h _).trans
theorem ball_add_ball_subset (p : Seminorm ð E) (râ râ : â) (xâ xâ : E) :
p.ball (xâ : E) râ + p.ball (xâ : E) râ â p.ball (xâ + xâ) (râ + râ) := by
rintro x âšyâ, hyâ, yâ, hyâ, rflâ©
rw [mem_ball, add_sub_add_comm]
exact (map_add_le_add p _ _).trans_lt (add_lt_add hyâ hyâ)
theorem closedBall_add_closedBall_subset (p : Seminorm ð E) (râ râ : â) (xâ xâ : E) :
p.closedBall (xâ : E) râ + p.closedBall (xâ : E) râ â p.closedBall (xâ + xâ) (râ + râ) := by
rintro x âšyâ, hyâ, yâ, hyâ, rflâ©
rw [mem_closedBall, add_sub_add_comm]
exact (map_add_le_add p _ _).trans (add_le_add hyâ hyâ)
theorem sub_mem_ball (p : Seminorm ð E) (xâ xâ y : E) (r : â) :
xâ - xâ â p.ball y r â xâ â p.ball (xâ + y) r := by simp_rw [mem_ball, sub_sub]
theorem sub_mem_closedBall (p : Seminorm ð E) (xâ xâ y : E) (r : â) :
xâ - xâ â p.closedBall y r â xâ â p.closedBall (xâ + y) r := by
simp_rw [mem_closedBall, sub_sub]
/-- The image of a ball under addition with a singleton is another ball. -/
theorem vadd_ball (p : Seminorm ð E) : x +áµ¥ p.ball y r = p.ball (x +áµ¥ y) r :=
letI := AddGroupSeminorm.toSeminormedAddCommGroup p.toAddGroupSeminorm
Metric.vadd_ball x y r
/-- The image of a closed ball under addition with a singleton is another closed ball. -/
theorem vadd_closedBall (p : Seminorm ð E) : x +áµ¥ p.closedBall y r = p.closedBall (x +áµ¥ y) r :=
letI := AddGroupSeminorm.toSeminormedAddCommGroup p.toAddGroupSeminorm
Metric.vadd_closedBall x y r
end SMul
section Module
variable [Module ð E]
variable [SeminormedRing ðâ] [AddCommGroup Eâ] [Module ðâ Eâ]
variable {Ïââ : ð â+* ðâ} [RingHomIsometric Ïââ]
theorem ball_comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (x : E) (r : â) :
(p.comp f).ball x r = f â»Â¹' p.ball (f x) r := by
ext
simp_rw [ball, mem_preimage, comp_apply, Set.mem_setOf_eq, map_sub]
theorem closedBall_comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (x : E) (r : â) :
(p.comp f).closedBall x r = f â»Â¹' p.closedBall (f x) r := by
ext
simp_rw [closedBall, mem_preimage, comp_apply, Set.mem_setOf_eq, map_sub]
variable (p : Seminorm ð E)
theorem preimage_metric_ball {r : â} : p â»Â¹' Metric.ball 0 r = { x | p x < r } := by
ext x
simp only [mem_setOf, mem_preimage, mem_ball_zero_iff, Real.norm_of_nonneg (apply_nonneg p _)]
theorem preimage_metric_closedBall {r : â} : p â»Â¹' Metric.closedBall 0 r = { x | p x †r } := by
ext x
simp only [mem_setOf, mem_preimage, mem_closedBall_zero_iff,
Real.norm_of_nonneg (apply_nonneg p _)]
theorem ball_zero_eq_preimage_ball {r : â} : p.ball 0 r = p â»Â¹' Metric.ball 0 r := by
rw [ball_zero_eq, preimage_metric_ball]
theorem closedBall_zero_eq_preimage_closedBall {r : â} :
p.closedBall 0 r = p â»Â¹' Metric.closedBall 0 r := by
rw [closedBall_zero_eq, preimage_metric_closedBall]
@[simp]
theorem ball_bot {r : â} (x : E) (hr : 0 < r) : ball (⥠: Seminorm ð E) x r = Set.univ :=
ball_zero' x hr
@[simp]
theorem closedBall_bot {r : â} (x : E) (hr : 0 < r) :
closedBall (⥠: Seminorm ð E) x r = Set.univ :=
closedBall_zero' x hr
/-- Seminorm-balls at the origin are balanced. -/
theorem balanced_ball_zero (r : â) : Balanced ð (ball p 0 r) := by
rintro a ha x âšy, hy, hxâ©
rw [mem_ball_zero, â hx, map_smul_eq_mul]
calc
_ †p y := mul_le_of_le_one_left (apply_nonneg p _) ha
_ < r := by rwa [mem_ball_zero] at hy
/-- Closed seminorm-balls at the origin are balanced. -/
theorem balanced_closedBall_zero (r : â) : Balanced ð (closedBall p 0 r) := by
rintro a ha x âšy, hy, hxâ©
rw [mem_closedBall_zero, â hx, map_smul_eq_mul]
calc
_ †p y := mul_le_of_le_one_left (apply_nonneg p _) ha
_ †r := by rwa [mem_closedBall_zero] at hy
theorem ball_finset_sup_eq_iInter (p : ι â Seminorm ð E) (s : Finset ι) (x : E) {r : â}
(hr : 0 < r) : ball (s.sup p) x r = â i â s, ball (p i) x r := by
lift r to NNReal using hr.le
simp_rw [ball, iInter_setOf, finset_sup_apply, NNReal.coe_lt_coe,
Finset.sup_lt_iff (show ⥠< r from hr), â NNReal.coe_lt_coe, NNReal.coe_mk]
theorem closedBall_finset_sup_eq_iInter (p : ι â Seminorm ð E) (s : Finset ι) (x : E) {r : â}
(hr : 0 †r) : closedBall (s.sup p) x r = â i â s, closedBall (p i) x r := by
lift r to NNReal using hr
simp_rw [closedBall, iInter_setOf, finset_sup_apply, NNReal.coe_le_coe, Finset.sup_le_iff, â
NNReal.coe_le_coe, NNReal.coe_mk]
theorem ball_finset_sup (p : ι â Seminorm ð E) (s : Finset ι) (x : E) {r : â} (hr : 0 < r) :
ball (s.sup p) x r = s.inf fun i => ball (p i) x r := by
rw [Finset.inf_eq_iInf]
exact ball_finset_sup_eq_iInter _ _ _ hr
theorem closedBall_finset_sup (p : ι â Seminorm ð E) (s : Finset ι) (x : E) {r : â} (hr : 0 †r) :
closedBall (s.sup p) x r = s.inf fun i => closedBall (p i) x r := by
rw [Finset.inf_eq_iInf]
exact closedBall_finset_sup_eq_iInter _ _ _ hr
@[simp]
theorem ball_eq_emptyset (p : Seminorm ð E) {x : E} {r : â} (hr : r †0) : p.ball x r = â
:= by
ext
rw [Seminorm.mem_ball, Set.mem_empty_iff_false, iff_false, not_lt]
exact hr.trans (apply_nonneg p _)
@[simp]
theorem closedBall_eq_emptyset (p : Seminorm ð E) {x : E} {r : â} (hr : r < 0) :
p.closedBall x r = â
:= by
ext
rw [Seminorm.mem_closedBall, Set.mem_empty_iff_false, iff_false, not_le]
exact hr.trans_le (apply_nonneg _ _)
theorem closedBall_smul_ball (p : Seminorm ð E) {râ : â} (hrâ : râ â 0) (râ : â) :
Metric.closedBall (0 : ð) râ ⢠p.ball 0 râ â p.ball 0 (râ * râ) := by
simp only [smul_subset_iff, mem_ball_zero, mem_closedBall_zero_iff, map_smul_eq_mul]
refine fun a ha b hb ⊠mul_lt_mul' ha hb (apply_nonneg _ _) ?_
exact hrâ.lt_or_lt.resolve_left <| ((norm_nonneg a).trans ha).not_lt
theorem ball_smul_closedBall (p : Seminorm ð E) (râ : â) {râ : â} (hrâ : râ â 0) :
Metric.ball (0 : ð) râ ⢠p.closedBall 0 râ â p.ball 0 (râ * râ) := by
simp only [smul_subset_iff, mem_ball_zero, mem_closedBall_zero, mem_ball_zero_iff,
map_smul_eq_mul]
intro a ha b hb
rw [mul_comm, mul_comm râ]
refine mul_lt_mul' hb ha (norm_nonneg _) (hrâ.lt_or_lt.resolve_left ?_)
exact ((apply_nonneg p b).trans hb).not_lt
theorem ball_smul_ball (p : Seminorm ð E) (râ râ : â) :
Metric.ball (0 : ð) râ ⢠p.ball 0 râ â p.ball 0 (râ * râ) := by
rcases eq_or_ne râ 0 with rfl | hrâ
· simp
· exact (smul_subset_smul_left (ball_subset_closedBall _ _ _)).trans
(ball_smul_closedBall _ _ hrâ)
theorem closedBall_smul_closedBall (p : Seminorm ð E) (râ râ : â) :
Metric.closedBall (0 : ð) râ ⢠p.closedBall 0 râ â p.closedBall 0 (râ * râ) := by
simp only [smul_subset_iff, mem_closedBall_zero, mem_closedBall_zero_iff, map_smul_eq_mul]
intro a ha b hb
gcongr
exact (norm_nonneg _).trans ha
theorem neg_mem_ball_zero {r : â} {x : E} : -x â ball p 0 r â x â ball p 0 r := by
simp only [mem_ball_zero, map_neg_eq_map]
theorem neg_mem_closedBall_zero {r : â} {x : E} : -x â closedBall p 0 r â x â closedBall p 0 r := by
simp only [mem_closedBall_zero, map_neg_eq_map]
@[simp]
theorem neg_ball (p : Seminorm ð E) (r : â) (x : E) : -ball p x r = ball p (-x) r := by
ext
rw [Set.mem_neg, mem_ball, mem_ball, â neg_add', sub_neg_eq_add, map_neg_eq_map]
@[simp]
theorem neg_closedBall (p : Seminorm ð E) (r : â) (x : E) :
-closedBall p x r = closedBall p (-x) r := by
ext
rw [Set.mem_neg, mem_closedBall, mem_closedBall, â neg_add', sub_neg_eq_add, map_neg_eq_map]
end Module
end AddCommGroup
end SeminormedRing
section NormedField
variable [NormedField ð] [AddCommGroup E] [Module ð E] (p : Seminorm ð E) {r : â} {x : E}
theorem closedBall_iSup {ι : Sort*} {p : ι â Seminorm ð E} (hp : BddAbove (range p)) (e : E)
{r : â} (hr : 0 < r) : closedBall (âš i, p i) e r = â i, closedBall (p i) e r := by
cases isEmpty_or_nonempty ι
· rw [iSup_of_empty', iInter_of_empty, Seminorm.sSup_empty]
exact closedBall_bot _ hr
· ext x
have := Seminorm.bddAbove_range_iff.mp hp (x - e)
simp only [mem_closedBall, mem_iInter, Seminorm.iSup_apply hp, ciSup_le_iff this]
theorem ball_norm_mul_subset {p : Seminorm ð E} {k : ð} {r : â} :
p.ball 0 (âkâ * r) â k ⢠p.ball 0 r := by
rcases eq_or_ne k 0 with (rfl | hk)
· rw [norm_zero, zero_mul, ball_eq_emptyset _ le_rfl]
exact empty_subset _
· intro x
rw [Set.mem_smul_set, Seminorm.mem_ball_zero]
refine fun hx => âškâ»Â¹ ⢠x, ?_, ?_â©
· rwa [Seminorm.mem_ball_zero, map_smul_eq_mul, norm_inv, â
mul_lt_mul_left <| norm_pos_iff.mpr hk, â mul_assoc, â div_eq_mul_inv âkâ âkâ,
div_self (ne_of_gt <| norm_pos_iff.mpr hk), one_mul]
rw [â smul_assoc, smul_eq_mul, â div_eq_mul_inv, div_self hk, one_smul]
theorem smul_ball_zero {p : Seminorm ð E} {k : ð} {r : â} (hk : k â 0) :
k ⢠p.ball 0 r = p.ball 0 (âkâ * r) := by
ext
rw [mem_smul_set_iff_inv_smul_memâ hk, p.mem_ball_zero, p.mem_ball_zero, map_smul_eq_mul,
norm_inv, â div_eq_inv_mul, div_lt_iffâ (norm_pos_iff.2 hk), mul_comm]
theorem smul_closedBall_subset {p : Seminorm ð E} {k : ð} {r : â} :
k ⢠p.closedBall 0 r â p.closedBall 0 (âkâ * r) := by
rintro x âšy, hy, hâ©
rw [Seminorm.mem_closedBall_zero, â h, map_smul_eq_mul]
rw [Seminorm.mem_closedBall_zero] at hy
gcongr
theorem smul_closedBall_zero {p : Seminorm ð E} {k : ð} {r : â} (hk : 0 < âkâ) :
k ⢠p.closedBall 0 r = p.closedBall 0 (âkâ * r) := by
refine subset_antisymm smul_closedBall_subset ?_
intro x
rw [Set.mem_smul_set, Seminorm.mem_closedBall_zero]
refine fun hx => âškâ»Â¹ ⢠x, ?_, ?_â©
· rwa [Seminorm.mem_closedBall_zero, map_smul_eq_mul, norm_inv, â mul_le_mul_left hk, â mul_assoc,
â div_eq_mul_inv âkâ âkâ, div_self (ne_of_gt hk), one_mul]
rw [â smul_assoc, smul_eq_mul, â div_eq_mul_inv, div_self (norm_pos_iff.mp hk), one_smul]
theorem ball_zero_absorbs_ball_zero (p : Seminorm ð E) {râ râ : â} (hrâ : 0 < râ) :
Absorbs ð (p.ball 0 râ) (p.ball 0 râ) := by
rcases exists_pos_lt_mul hrâ râ with âšr, hrâ, hrâ©
refine .of_norm âšr, fun a ha x hx => ?_â©
rw [smul_ball_zero (norm_pos_iff.1 <| hrâ.trans_le ha), p.mem_ball_zero]
rw [p.mem_ball_zero] at hx
exact hx.trans (hr.trans_le <| by gcongr)
/-- Seminorm-balls at the origin are absorbent. -/
protected theorem absorbent_ball_zero (hr : 0 < r) : Absorbent ð (ball p (0 : E) r) :=
absorbent_iff_forall_absorbs_singleton.2 fun _ =>
(p.ball_zero_absorbs_ball_zero hr).mono_right <|
singleton_subset_iff.2 <| p.mem_ball_zero.2 <| lt_add_one _
/-- Closed seminorm-balls at the origin are absorbent. -/
protected theorem absorbent_closedBall_zero (hr : 0 < r) : Absorbent ð (closedBall p (0 : E) r) :=
(p.absorbent_ball_zero hr).mono (p.ball_subset_closedBall _ _)
/-- Seminorm-balls containing the origin are absorbent. -/
protected theorem absorbent_ball (hpr : p x < r) : Absorbent ð (ball p x r) := by
refine (p.absorbent_ball_zero <| sub_pos.2 hpr).mono fun y hy => ?_
rw [p.mem_ball_zero] at hy
exact p.mem_ball.2 ((map_sub_le_add p _ _).trans_lt <| add_lt_of_lt_sub_right hy)
/-- Seminorm-balls containing the origin are absorbent. -/
protected theorem absorbent_closedBall (hpr : p x < r) : Absorbent ð (closedBall p x r) := by
refine (p.absorbent_closedBall_zero <| sub_pos.2 hpr).mono fun y hy => ?_
rw [p.mem_closedBall_zero] at hy
exact p.mem_closedBall.2 ((map_sub_le_add p _ _).trans <| add_le_of_le_sub_right hy)
@[simp]
theorem smul_ball_preimage (p : Seminorm ð E) (y : E) (r : â) (a : ð) (ha : a â 0) :
(a ⢠·) â»Â¹' p.ball y r = p.ball (aâ»Â¹ ⢠y) (r / âaâ) :=
Set.ext fun _ => by
rw [mem_preimage, mem_ball, mem_ball, lt_div_iffâ (norm_pos_iff.mpr ha), mul_comm, â
map_smul_eq_mul p, smul_sub, smul_inv_smulâ ha]
@[simp]
theorem smul_closedBall_preimage (p : Seminorm ð E) (y : E) (r : â) (a : ð) (ha : a â 0) :
(a ⢠·) â»Â¹' p.closedBall y r = p.closedBall (aâ»Â¹ ⢠y) (r / âaâ) :=
Set.ext fun _ => by
rw [mem_preimage, mem_closedBall, mem_closedBall, le_div_iffâ (norm_pos_iff.mpr ha), mul_comm, â
map_smul_eq_mul p, smul_sub, smul_inv_smulâ ha]
end NormedField
section Convex
variable [NormedField ð] [AddCommGroup E] [NormedSpace â ð] [Module ð E]
section SMul
variable [SMul â E] [IsScalarTower â ð E] (p : Seminorm ð E)
/-- A seminorm is convex. Also see `convexOn_norm`. -/
protected theorem convexOn : ConvexOn â univ p := by
refine âšconvex_univ, fun x _ y _ a b ha hb _ => ?_â©
calc
p (a ⢠x + b ⢠y) †p (a ⢠x) + p (b ⢠y) := map_add_le_add p _ _
_ = âa ⢠(1 : ð)â * p x + âb ⢠(1 : ð)â * p y := by
rw [â map_smul_eq_mul p, â map_smul_eq_mul p, smul_one_smul, smul_one_smul]
_ = a * p x + b * p y := by
rw [norm_smul, norm_smul, norm_one, mul_one, mul_one, Real.norm_of_nonneg ha,
Real.norm_of_nonneg hb]
end SMul
section Module
variable [Module â E] [IsScalarTower â ð E] (p : Seminorm ð E) (x : E) (r : â)
/-- Seminorm-balls are convex. -/
theorem convex_ball : Convex â (ball p x r) := by
convert (p.convexOn.translate_left (-x)).convex_lt r
ext y
rw [preimage_univ, sep_univ, p.mem_ball, sub_eq_add_neg]
rfl
/-- Closed seminorm-balls are convex. -/
theorem convex_closedBall : Convex â (closedBall p x r) := by
rw [closedBall_eq_biInter_ball]
exact convex_iInterâ fun _ _ => convex_ball _ _ _
end Module
end Convex
section RestrictScalars
variable (ð) {ð' : Type*} [NormedField ð] [SeminormedRing ð'] [NormedAlgebra ð ð']
[NormOneClass ð'] [AddCommGroup E] [Module ð' E] [SMul ð E] [IsScalarTower ð ð' E]
/-- Reinterpret a seminorm over a field `ð'` as a seminorm over a smaller field `ð`. This will
typically be used with `RCLike ð'` and `ð = â`. -/
protected def restrictScalars (p : Seminorm ð' E) : Seminorm ð E :=
{ p with
smul' := fun a x => by rw [â smul_one_smul ð' a x, p.smul', norm_smul, norm_one, mul_one] }
@[simp]
theorem coe_restrictScalars (p : Seminorm ð' E) : (p.restrictScalars ð : E â â) = p :=
rfl
@[simp]
theorem restrictScalars_ball (p : Seminorm ð' E) : (p.restrictScalars ð).ball = p.ball :=
rfl
@[simp]
theorem restrictScalars_closedBall (p : Seminorm ð' E) :
(p.restrictScalars ð).closedBall = p.closedBall :=
rfl
end RestrictScalars
/-! ### Continuity criterions for seminorms -/
section Continuity
variable [NontriviallyNormedField ð] [SeminormedRing ð] [AddCommGroup E] [Module ð E]
variable [Module ð E]
/-- A seminorm is continuous at `0` if `p.closedBall 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuousAt_zero'`. -/
theorem continuousAt_zero_of_forall' [TopologicalSpace E] {p : Seminorm ð E}
(hp : â r > 0, p.closedBall 0 r â (ð 0 : Filter E)) :
ContinuousAt p 0 := by
simp_rw [Seminorm.closedBall_zero_eq_preimage_closedBall] at hp
rwa [ContinuousAt, Metric.nhds_basis_closedBall.tendsto_right_iff, map_zero]
theorem continuousAt_zero' [TopologicalSpace E] [ContinuousConstSMul ð E] {p : Seminorm ð E}
{r : â} (hp : p.closedBall 0 r â (ð 0 : Filter E)) : ContinuousAt p 0 := by
refine continuousAt_zero_of_forall' fun ε hε ⊠?_
obtain âšk, hkâ, hkâ© : â k : ð, 0 < âkâ â§ âkâ * r < ε := by
rcases le_or_lt r 0 with hr | hr
· use 1; simpa using hr.trans_lt hε
· simpa [lt_div_iffâ hr] using exists_norm_lt ð (div_pos hε hr)
rw [â set_smul_mem_nhds_zero_iff (norm_pos_iff.1 hkâ), smul_closedBall_zero hkâ] at hp
exact mem_of_superset hp <| p.closedBall_mono hk.le
/-- A seminorm is continuous at `0` if `p.ball 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuousAt_zero'`. -/
theorem continuousAt_zero_of_forall [TopologicalSpace E] {p : Seminorm ð E}
(hp : â r > 0, p.ball 0 r â (ð 0 : Filter E)) :
ContinuousAt p 0 :=
continuousAt_zero_of_forall'
(fun r hr ⊠Filter.mem_of_superset (hp r hr) <| p.ball_subset_closedBall _ _)
theorem continuousAt_zero [TopologicalSpace E] [ContinuousConstSMul ð E] {p : Seminorm ð E} {r : â}
(hp : p.ball 0 r â (ð 0 : Filter E)) : ContinuousAt p 0 :=
continuousAt_zero' (Filter.mem_of_superset hp <| p.ball_subset_closedBall _ _)
protected theorem uniformContinuous_of_continuousAt_zero [UniformSpace E] [IsUniformAddGroup E]
{p : Seminorm ð E} (hp : ContinuousAt p 0) : UniformContinuous p := by
have hp : Filter.Tendsto p (ð 0) (ð 0) := map_zero p âž hp
rw [UniformContinuous, uniformity_eq_comap_nhds_zero_swapped,
Metric.uniformity_eq_comap_nhds_zero, Filter.tendsto_comap_iff]
exact
tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (hp.comp Filter.tendsto_comap)
(fun xy => dist_nonneg) fun xy => p.norm_sub_map_le_sub _ _
protected theorem continuous_of_continuousAt_zero [TopologicalSpace E] [IsTopologicalAddGroup E]
{p : Seminorm ð E} (hp : ContinuousAt p 0) : Continuous p := by
letI := IsTopologicalAddGroup.toUniformSpace E
haveI : IsUniformAddGroup E := isUniformAddGroup_of_addCommGroup
exact (Seminorm.uniformContinuous_of_continuousAt_zero hp).continuous
/-- A seminorm is uniformly continuous if `p.ball 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.uniformContinuous`. -/
| protected theorem uniformContinuous_of_forall [UniformSpace E] [IsUniformAddGroup E]
{p : Seminorm ð E} (hp : â r > 0, p.ball 0 r â (ð 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero_of_forall hp)
| Mathlib/Analysis/Seminorm.lean | 1,097 | 1,101 |
/-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Algebra.Order.Ring.Unbundled.Rat
/-!
# The rational numbers form a linear ordered field
This file constructs the order on `â` and proves that `â` is a discrete, linearly ordered
commutative ring.
`â` is in fact a linearly ordered field, but this fact is located in `Data.Rat.Field` instead of
here because we need the order on `â` to define `ââ¥0`, which we itself need to define `Field`.
## Tags
rat, rationals, field, â, numerator, denominator, num, denom, order, ordering
-/
assert_not_exists Field Finset Set.Icc GaloisConnection
namespace Rat
instance instIsOrderedAddMonoid : IsOrderedAddMonoid â where
add_le_add_left := fun _ _ ab _ => Rat.add_le_add_left.2 ab
instance instZeroLEOneClass : ZeroLEOneClass â where
zero_le_one := by decide
instance instIsStrictOrderedRing : IsStrictOrderedRing â := .of_mul_pos fun _ _ ha hb âŠ
(Rat.mul_nonneg ha.le hb.le).lt_of_ne' (mul_ne_zero ha.ne' hb.ne')
end Rat
| Mathlib/Algebra/Order/Ring/Rat.lean | 252 | 261 | |
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Robert Y. Lewis
-/
import Mathlib.RingTheory.WittVector.StructurePolynomial
/-!
# Witt vectors
In this file we define the type of `p`-typical Witt vectors and ring operations on it.
The ring axioms are verified in `Mathlib/RingTheory/WittVector/Basic.lean`.
For a fixed commutative ring `R` and prime `p`,
a Witt vector `x : ð R` is an infinite sequence `â â R` of elements of `R`.
However, the ring operations `+` and `*` are not defined in the obvious component-wise way.
Instead, these operations are defined via certain polynomials
using the machinery in `Mathlib/RingTheory/WittVector/StructurePolynomial.lean`.
The `n`th value of the sum of two Witt vectors can depend on the `0`-th through `n`th values
of the summands. This effectively simulates a âcarryingâ operation.
## Main definitions
* `WittVector p R`: the type of `p`-typical Witt vectors with coefficients in `R`.
* `WittVector.coeff x n`: projects the `n`th value of the Witt vector `x`.
## Notation
We use notation `ð R`, entered `\bbW`, for the Witt vectors over `R`.
## References
* [Hazewinkel, *Witt Vectors*][Haze09]
* [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21]
-/
noncomputable section
/-- `WittVector p R` is the ring of `p`-typical Witt vectors over the commutative ring `R`,
where `p` is a prime number.
If `p` is invertible in `R`, this ring is isomorphic to `â â R` (the product of `â` copies of `R`).
If `R` is a ring of characteristic `p`, then `WittVector p R` is a ring of characteristic `0`.
The canonical example is `WittVector p (ZMod p)`,
which is isomorphic to the `p`-adic integers `â€_[p]`. -/
structure WittVector (p : â) (R : Type*) where mk' ::
/-- `x.coeff n` is the `n`th coefficient of the Witt vector `x`.
This concept does not have a standard name in the literature.
-/
coeff : â â R
-- Porting note: added to make the `p` argument explicit
/-- Construct a Witt vector `mk p x : ð R` from a sequence `x` of elements of `R`. -/
def WittVector.mk (p : â) {R : Type*} (coeff : â â R) : WittVector p R := mk' coeff
variable {p : â}
/- We cannot make this `localized` notation, because the `p` on the RHS doesn't occur on the left
Hiding the `p` in the notation is very convenient, so we opt for repeating the `local notation`
in other files that use Witt vectors. -/
local notation "ð" => WittVector p -- type as `\bbW`
namespace WittVector
variable {R : Type*}
@[ext]
theorem ext {x y : ð R} (h : â n, x.coeff n = y.coeff n) : x = y := by
cases x
cases y
simp only at h
simp [funext_iff, h]
variable (p)
theorem coeff_mk (x : â â R) : (mk p x).coeff = x :=
rfl
/- These instances are not needed for the rest of the development,
but it is interesting to establish early on that `WittVector p` is a lawful functor. -/
instance : Functor (WittVector p) where
map f v := mk p (f â v.coeff)
mapConst a _ := mk p fun _ => a
instance : LawfulFunctor (WittVector p) where
map_const := rfl
-- Porting note: no longer needs to deconstruct `v` to conclude `{coeff := v.coeff} = v`
id_map _ := rfl
comp_map _ _ _ := rfl
variable [hp : Fact p.Prime] [CommRing R]
open MvPolynomial
section RingOperations
/-- The polynomials used for defining the element `0` of the ring of Witt vectors. -/
def wittZero : â â MvPolynomial (Fin 0 à â) †:=
wittStructureInt p 0
/-- The polynomials used for defining the element `1` of the ring of Witt vectors. -/
def wittOne : â â MvPolynomial (Fin 0 à â) †:=
wittStructureInt p 1
/-- The polynomials used for defining the addition of the ring of Witt vectors. -/
def wittAdd : â â MvPolynomial (Fin 2 à â) †:=
wittStructureInt p (X 0 + X 1)
/-- The polynomials used for defining repeated addition of the ring of Witt vectors. -/
def wittNSMul (n : â) : â â MvPolynomial (Fin 1 à â) †:=
wittStructureInt p (n ⢠X (0 : (Fin 1)))
/-- The polynomials used for defining repeated addition of the ring of Witt vectors. -/
def wittZSMul (n : â€) : â â MvPolynomial (Fin 1 à â) †:=
wittStructureInt p (n ⢠X (0 : (Fin 1)))
/-- The polynomials used for describing the subtraction of the ring of Witt vectors. -/
def wittSub : â â MvPolynomial (Fin 2 à â) †:=
wittStructureInt p (X 0 - X 1)
/-- The polynomials used for defining the multiplication of the ring of Witt vectors. -/
def wittMul : â â MvPolynomial (Fin 2 à â) †:=
wittStructureInt p (X 0 * X 1)
/-- The polynomials used for defining the negation of the ring of Witt vectors. -/
def wittNeg : â â MvPolynomial (Fin 1 à â) †:=
wittStructureInt p (-X 0)
/-- The polynomials used for defining repeated addition of the ring of Witt vectors. -/
def wittPow (n : â) : â â MvPolynomial (Fin 1 à â) †:=
wittStructureInt p (X 0 ^ n)
variable {p}
/-- An auxiliary definition used in `WittVector.eval`.
Evaluates a polynomial whose variables come from the disjoint union of `k` copies of `â`,
with a curried evaluation `x`.
This can be defined more generally but we use only a specific instance here. -/
def peval {k : â} (Ï : MvPolynomial (Fin k à â) â€) (x : Fin k â â â R) : R :=
aeval (Function.uncurry x) Ï
/-- Let `Ï` be a family of polynomials, indexed by natural numbers, whose variables come from the
disjoint union of `k` copies of `â`, and let `xáµ¢` be a Witt vector for `0 †i < k`.
`eval Ï x` evaluates `Ï` mapping the variable `X_(i, n)` to the `n`th coefficient of `xáµ¢`.
Instantiating `Ï` with certain polynomials defined in
`Mathlib/RingTheory/WittVector/StructurePolynomial.lean` establishes the
ring operations on `ð R`. For example, `WittVector.wittAdd` is such a `Ï` with `k = 2`;
evaluating this at `(xâ, xâ)` gives us the sum of two Witt vectors `xâ + xâ`.
-/
def eval {k : â} (Ï : â â MvPolynomial (Fin k à â) â€) (x : Fin k â ð R) : ð R :=
mk p fun n => peval (Ï n) fun i => (x i).coeff
instance : Zero (ð R) :=
âševal (wittZero p) ![]â©
instance : Inhabited (ð R) :=
âš0â©
instance : One (ð R) :=
âševal (wittOne p) ![]â©
instance : Add (ð R) :=
âšfun x y => eval (wittAdd p) ![x, y]â©
instance : Sub (ð R) :=
âšfun x y => eval (wittSub p) ![x, y]â©
instance hasNatScalar : SMul â (ð R) :=
âšfun n x => eval (wittNSMul p n) ![x]â©
instance hasIntScalar : SMul †(ð R) :=
âšfun n x => eval (wittZSMul p n) ![x]â©
instance : Mul (ð R) :=
âšfun x y => eval (wittMul p) ![x, y]â©
instance : Neg (ð R) :=
âšfun x => eval (wittNeg p) ![x]â©
instance hasNatPow : Pow (ð R) â :=
âšfun x n => eval (wittPow p n) ![x]â©
instance : NatCast (ð R) :=
âšNat.unaryCastâ©
instance : IntCast (ð R) :=
âšInt.castDefâ©
end RingOperations
section WittStructureSimplifications
@[simp]
theorem wittZero_eq_zero (n : â) : wittZero p n = 0 := by
apply MvPolynomial.map_injective (Int.castRingHom â) Int.cast_injective
simp only [wittZero, wittStructureRat, bindâ, aeval_zero', constantCoeff_xInTermsOfW, map_zero,
map_wittStructureInt]
@[simp]
theorem wittOne_zero_eq_one : wittOne p 0 = 1 := by
apply MvPolynomial.map_injective (Int.castRingHom â) Int.cast_injective
simp only [wittOne, wittStructureRat, xInTermsOfW_zero, map_one, bindâ_X_right,
map_wittStructureInt]
@[simp]
theorem wittOne_pos_eq_zero (n : â) (hn : 0 < n) : wittOne p n = 0 := by
apply MvPolynomial.map_injective (Int.castRingHom â) Int.cast_injective
simp only [wittOne, wittStructureRat, RingHom.map_zero, map_one, RingHom.map_one,
map_wittStructureInt]
induction n using Nat.strong_induction_on with | h n IH => ?_
rw [xInTermsOfW_eq]
simp only [map_mul, map_sub, map_sum, map_pow, bindâ_X_right,
bindâ_C_right]
rw [sub_mul, one_mul]
rw [Finset.sum_eq_single 0]
· simp only [invOf_eq_inv, one_mul, inv_pow, tsub_zero, RingHom.map_one, pow_zero]
simp only [one_pow, one_mul, xInTermsOfW_zero, sub_self, bindâ_X_right]
· intro i hin hi0
rw [Finset.mem_range] at hin
rw [IH _ hin (Nat.pos_of_ne_zero hi0), zero_pow (pow_ne_zero _ hp.1.ne_zero), mul_zero]
· rw [Finset.mem_range]; intro; contradiction
@[simp]
theorem wittAdd_zero : wittAdd p 0 = X (0, 0) + X (1, 0) := by
apply MvPolynomial.map_injective (Int.castRingHom â) Int.cast_injective
simp only [wittAdd, wittStructureRat, map_add, rename_X, xInTermsOfW_zero, map_X,
wittPolynomial_zero, bindâ_X_right, map_wittStructureInt]
@[simp]
theorem wittSub_zero : wittSub p 0 = X (0, 0) - X (1, 0) := by
apply MvPolynomial.map_injective (Int.castRingHom â) Int.cast_injective
simp only [wittSub, wittStructureRat, map_sub, rename_X, xInTermsOfW_zero, map_X,
wittPolynomial_zero, bindâ_X_right, map_wittStructureInt]
@[simp]
theorem wittMul_zero : wittMul p 0 = X (0, 0) * X (1, 0) := by
apply MvPolynomial.map_injective (Int.castRingHom â) Int.cast_injective
simp only [wittMul, wittStructureRat, rename_X, xInTermsOfW_zero, map_X, wittPolynomial_zero,
map_mul, bindâ_X_right, map_wittStructureInt]
@[simp]
theorem wittNeg_zero : wittNeg p 0 = -X (0, 0) := by
apply MvPolynomial.map_injective (Int.castRingHom â) Int.cast_injective
simp only [wittNeg, wittStructureRat, rename_X, xInTermsOfW_zero, map_X, wittPolynomial_zero,
map_neg, bindâ_X_right, map_wittStructureInt]
@[simp]
theorem constantCoeff_wittAdd (n : â) : constantCoeff (wittAdd p n) = 0 := by
apply constantCoeff_wittStructureInt p _ _ n
simp only [add_zero, RingHom.map_add, constantCoeff_X]
@[simp]
theorem constantCoeff_wittSub (n : â) : constantCoeff (wittSub p n) = 0 := by
apply constantCoeff_wittStructureInt p _ _ n
simp only [sub_zero, RingHom.map_sub, constantCoeff_X]
@[simp]
theorem constantCoeff_wittMul (n : â) : constantCoeff (wittMul p n) = 0 := by
apply constantCoeff_wittStructureInt p _ _ n
simp only [mul_zero, RingHom.map_mul, constantCoeff_X]
@[simp]
theorem constantCoeff_wittNeg (n : â) : constantCoeff (wittNeg p n) = 0 := by
apply constantCoeff_wittStructureInt p _ _ n
simp only [neg_zero, RingHom.map_neg, constantCoeff_X]
@[simp]
theorem constantCoeff_wittNSMul (m : â) (n : â) : constantCoeff (wittNSMul p m n) = 0 := by
apply constantCoeff_wittStructureInt p _ _ n
simp only [smul_zero, map_nsmul, constantCoeff_X]
@[simp]
theorem constantCoeff_wittZSMul (z : â€) (n : â) : constantCoeff (wittZSMul p z n) = 0 := by
apply constantCoeff_wittStructureInt p _ _ n
simp only [smul_zero, map_zsmul, constantCoeff_X]
end WittStructureSimplifications
section Coeff
variable (R)
@[simp]
theorem zero_coeff (n : â) : (0 : ð R).coeff n = 0 :=
show (aeval _ (wittZero p n) : R) = 0 by simp only [wittZero_eq_zero, map_zero]
@[simp]
theorem one_coeff_zero : (1 : ð R).coeff 0 = 1 :=
show (aeval _ (wittOne p 0) : R) = 1 by simp only [wittOne_zero_eq_one, map_one]
@[simp]
theorem one_coeff_eq_of_pos (n : â) (hn : 0 < n) : coeff (1 : ð R) n = 0 :=
show (aeval _ (wittOne p n) : R) = 0 by simp only [hn, wittOne_pos_eq_zero, map_zero]
variable {p R}
@[simp]
theorem v2_coeff {p' R'} (x y : WittVector p' R') (i : Fin 2) :
(![x, y] i).coeff = ![x.coeff, y.coeff] i := by fin_cases i <;> simp
-- Porting note: the lemmas below needed `coeff_mk` added to the `simp` calls
theorem add_coeff (x y : ð R) (n : â) :
(x + y).coeff n = peval (wittAdd p n) ![x.coeff, y.coeff] := by
simp [(· + ·), Add.add, eval, coeff_mk]
theorem sub_coeff (x y : ð R) (n : â) :
(x - y).coeff n = peval (wittSub p n) ![x.coeff, y.coeff] := by
simp [(· - ·), Sub.sub, eval, coeff_mk]
theorem mul_coeff (x y : ð R) (n : â) :
(x * y).coeff n = peval (wittMul p n) ![x.coeff, y.coeff] := by
simp [(· * ·), Mul.mul, eval, coeff_mk]
theorem neg_coeff (x : ð R) (n : â) : (-x).coeff n = peval (wittNeg p n) ![x.coeff] := by
simp [Neg.neg, eval, Matrix.cons_fin_one, coeff_mk]
theorem nsmul_coeff (m : â) (x : ð R) (n : â) :
(m ⢠x).coeff n = peval (wittNSMul p m n) ![x.coeff] := by
simp [(· ⢠·), SMul.smul, eval, Matrix.cons_fin_one, coeff_mk]
theorem zsmul_coeff (m : â€) (x : ð R) (n : â) :
(m ⢠x).coeff n = peval (wittZSMul p m n) ![x.coeff] := by
simp [(· ⢠·), SMul.smul, eval, Matrix.cons_fin_one, coeff_mk]
theorem pow_coeff (m : â) (x : ð R) (n : â) :
(x ^ m).coeff n = peval (wittPow p m n) ![x.coeff] := by
simp [(· ^ ·), Pow.pow, eval, Matrix.cons_fin_one, coeff_mk]
theorem add_coeff_zero (x y : ð R) : (x + y).coeff 0 = x.coeff 0 + y.coeff 0 := by
simp [add_coeff, peval, Function.uncurry]
|
theorem mul_coeff_zero (x y : ð R) : (x * y).coeff 0 = x.coeff 0 * y.coeff 0 := by
| Mathlib/RingTheory/WittVector/Defs.lean | 338 | 339 |
/-
Copyright (c) 2018 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Johannes Hölzl
-/
import Mathlib.Algebra.Field.Subfield.Defs
import Mathlib.Algebra.Order.Group.Pointwise.Interval
import Mathlib.Analysis.Normed.Ring.Basic
/-!
# Normed division rings and fields
In this file we define normed fields, and (more generally) normed division rings. We also prove
some theorems about these definitions.
Some useful results that relate the topology of the normed field to the discrete topology include:
* `norm_eq_one_iff_ne_zero_of_discrete`
Methods for constructing a normed field instance from a given real absolute value on a field are
given in:
* AbsoluteValue.toNormedField
-/
-- Guard against import creep.
assert_not_exists AddChar comap_norm_atTop DilationEquiv Finset.sup_mul_le_mul_sup_of_nonneg
IsOfFinOrder Isometry.norm_map_of_map_one NNReal.isOpen_Ico_zero Rat.norm_cast_real
RestrictScalars
variable {G α β ι : Type*}
open Filter
open scoped Topology NNReal ENNReal
/-- A normed division ring is a division ring endowed with a seminorm which satisfies the equality
`âx yâ = âxâ âyâ`. -/
class NormedDivisionRing (α : Type*) extends Norm α, DivisionRing α, MetricSpace α where
/-- The distance is induced by the norm. -/
dist_eq : â x y, dist x y = norm (x - y)
/-- The norm is multiplicative. -/
protected norm_mul : â a b, norm (a * b) = norm a * norm b
-- see Note [lower instance priority]
/-- A normed division ring is a normed ring. -/
instance (priority := 100) NormedDivisionRing.toNormedRing [β : NormedDivisionRing α] :
NormedRing α :=
{ β with norm_mul_le a b := (NormedDivisionRing.norm_mul a b).le }
-- see Note [lower instance priority]
/-- The norm on a normed division ring is strictly multiplicative. -/
instance (priority := 100) NormedDivisionRing.toNormMulClass [NormedDivisionRing α] :
NormMulClass α where
norm_mul := NormedDivisionRing.norm_mul
section NormedDivisionRing
variable [NormedDivisionRing α] {a b : α}
instance (priority := 900) NormedDivisionRing.to_normOneClass : NormOneClass α :=
âšmul_left_cancelâ (mt norm_eq_zero.1 (one_ne_zero' α)) <| by rw [â norm_mul, mul_one, mul_one]â©
@[simp]
theorem norm_div (a b : α) : âa / bâ = âaâ / âbâ :=
map_divâ (normHom : α â*â â) a b
@[simp]
theorem nnnorm_div (a b : α) : âa / bââ = âaââ / âbââ :=
map_divâ (nnnormHom : α â*â ââ¥0) a b
@[simp]
theorem norm_inv (a : α) : âaâ»Â¹â = âaââ»Â¹ :=
map_invâ (normHom : α â*â â) a
@[simp]
theorem nnnorm_inv (a : α) : âaâ»Â¹ââ = âaâââ»Â¹ :=
NNReal.eq <| by simp
@[simp]
lemma enorm_inv {a : α} (ha : a â 0) : âaâ»Â¹ââ = âaâââ»Â¹ := by simp [enorm, ENNReal.coe_inv, ha]
@[simp]
theorem norm_zpow : â (a : α) (n : â€), âa ^ nâ = âaâ ^ n :=
map_zpowâ (normHom : α â*â â)
@[simp]
theorem nnnorm_zpow : â (a : α) (n : â€), âa ^ nââ = âaââ ^ n :=
map_zpowâ (nnnormHom : α â*â ââ¥0)
theorem dist_inv_invâ {z w : α} (hz : z â 0) (hw : w â 0) :
dist zâ»Â¹ wâ»Â¹ = dist z w / (âzâ * âwâ) := by
rw [dist_eq_norm, inv_sub_inv' hz hw, norm_mul, norm_mul, norm_inv, norm_inv, mul_comm âzââ»Â¹,
mul_assoc, dist_eq_norm', div_eq_mul_inv, mul_inv]
theorem nndist_inv_invâ {z w : α} (hz : z â 0) (hw : w â 0) :
nndist zâ»Â¹ wâ»Â¹ = nndist z w / (âzââ * âwââ) :=
NNReal.eq <| dist_inv_invâ hz hw
lemma norm_commutator_sub_one_le (ha : a â 0) (hb : b â 0) :
âa * b * aâ»Â¹ * bâ»Â¹ - 1â †2 * âaââ»Â¹ * âbââ»Â¹ * âa - 1â * âb - 1â := by
simpa using norm_commutator_units_sub_one_le (.mk0 a ha) (.mk0 b hb)
lemma nnnorm_commutator_sub_one_le (ha : a â 0) (hb : b â 0) :
âa * b * aâ»Â¹ * bâ»Â¹ - 1ââ †2 * âaâââ»Â¹ * âbâââ»Â¹ * âa - 1ââ * âb - 1ââ := by
simpa using nnnorm_commutator_units_sub_one_le (.mk0 a ha) (.mk0 b hb)
namespace NormedDivisionRing
section Discrete
variable {ð : Type*} [NormedDivisionRing ð] [DiscreteTopology ð]
lemma norm_eq_one_iff_ne_zero_of_discrete {x : ð} : âxâ = 1 â x â 0 := by
constructor <;> intro hx
· contrapose! hx
simp [hx]
· have : IsOpen {(0 : ð)} := isOpen_discrete {0}
simp_rw [Metric.isOpen_singleton_iff, dist_eq_norm, sub_zero] at this
obtain âšÎµ, εpos, h'â© := this
wlog h : âxâ < 1 generalizing ð with H
· push_neg at h
rcases h.eq_or_lt with h|h
· rw [h]
replace h := norm_inv x âž inv_lt_one_of_one_ltâ h
rw [â inv_inj, inv_one, â norm_inv]
exact H (by simpa) h' h
obtain âšk, hkâ© : â k : â, âxâ ^ k < ε := exists_pow_lt_of_lt_one εpos h
rw [â norm_pow] at hk
specialize h' _ hk
simp [hx] at h'
@[simp]
lemma norm_le_one_of_discrete
(x : ð) : âxâ †1 := by
rcases eq_or_ne x 0 with rfl|hx
· simp
· simp [norm_eq_one_iff_ne_zero_of_discrete.mpr hx]
lemma unitClosedBall_eq_univ_of_discrete : (Metric.closedBall 0 1 : Set ð) = Set.univ := by
ext
simp
@[deprecated (since := "2024-12-01")]
alias discreteTopology_unit_closedBall_eq_univ := unitClosedBall_eq_univ_of_discrete
end Discrete
end NormedDivisionRing
end NormedDivisionRing
/-- A normed field is a field with a norm satisfying âx yâ = âxâ âyâ. -/
class NormedField (α : Type*) extends Norm α, Field α, MetricSpace α where
/-- The distance is induced by the norm. -/
dist_eq : â x y, dist x y = norm (x - y)
/-- The norm is multiplicative. -/
protected norm_mul : â a b, norm (a * b) = norm a * norm b
/-- A nontrivially normed field is a normed field in which there is an element of norm different
from `0` and `1`. This makes it possible to bring any element arbitrarily close to `0` by
multiplication by the powers of any element, and thus to relate algebra and topology. -/
class NontriviallyNormedField (α : Type*) extends NormedField α where
/-- The norm attains a value exceeding 1. -/
non_trivial : â x : α, 1 < âxâ
/-- A densely normed field is a normed field for which the image of the norm is dense in `ââ¥0`,
which means it is also nontrivially normed. However, not all nontrivally normed fields are densely
normed; in particular, the `Padic`s exhibit this fact. -/
class DenselyNormedField (α : Type*) extends NormedField α where
/-- The range of the norm is dense in the collection of nonnegative real numbers. -/
lt_norm_lt : â x y : â, 0 †x â x < y â â a : α, x < âaâ â§ âaâ < y
section NormedField
/-- A densely normed field is always a nontrivially normed field.
See note [lower instance priority]. -/
instance (priority := 100) DenselyNormedField.toNontriviallyNormedField [DenselyNormedField α] :
NontriviallyNormedField α where
non_trivial :=
let âša, h, _â© := DenselyNormedField.lt_norm_lt 1 2 zero_le_one one_lt_two
âša, hâ©
variable [NormedField α]
-- see Note [lower instance priority]
instance (priority := 100) NormedField.toNormedDivisionRing : NormedDivisionRing α :=
{ â¹NormedField α⺠with }
-- see Note [lower instance priority]
instance (priority := 100) NormedField.toNormedCommRing : NormedCommRing α :=
{ â¹NormedField α⺠with norm_mul_le a b := (norm_mul a b).le }
end NormedField
namespace NormedField
section Nontrivially
variable (α) [NontriviallyNormedField α]
theorem exists_one_lt_norm : â x : α, 1 < âxâ :=
â¹NontriviallyNormedField αâº.non_trivial
theorem exists_one_lt_nnnorm : â x : α, 1 < âxââ := exists_one_lt_norm α
theorem exists_one_lt_enorm : â x : α, 1 < âxââ :=
exists_one_lt_nnnorm α |>.imp fun _ => ENNReal.coe_lt_coe.mpr
theorem exists_lt_norm (r : â) : â x : α, r < âxâ :=
let âšw, hwâ© := exists_one_lt_norm α
let âšn, hnâ© := pow_unbounded_of_one_lt r hw
âšw ^ n, by rwa [norm_pow]â©
theorem exists_lt_nnnorm (r : ââ¥0) : â x : α, r < âxââ := exists_lt_norm α r
theorem exists_lt_enorm {r : ââ¥0â} (hr : r â â) : â x : α, r < âxââ := by
lift r to ââ¥0 using hr
exact mod_cast exists_lt_nnnorm α r
theorem exists_norm_lt {r : â} (hr : 0 < r) : â x : α, 0 < âxâ â§ âxâ < r :=
let âšw, hwâ© := exists_lt_norm α râ»Â¹
âšwâ»Â¹, by rwa [â Set.mem_Ioo, norm_inv, â Set.mem_inv, Set.inv_Ioo_0_left hr]â©
theorem exists_nnnorm_lt {r : ââ¥0} (hr : 0 < r) : â x : α, 0 < âxââ â§ âxââ < r :=
exists_norm_lt α hr
/-- TODO: merge with `_root_.exists_enorm_lt`. -/
theorem exists_enorm_lt {r : ââ¥0â} (hr : 0 < r) : â x : α, 0 < âxââ â§ âxââ < r :=
match r with
| â => exists_one_lt_enorm α |>.imp fun _ hx => âšzero_le_one.trans_lt hx, ENNReal.coe_lt_topâ©
| (r : ââ¥0) => exists_nnnorm_lt α (ENNReal.coe_pos.mp hr) |>.imp fun _ =>
And.imp ENNReal.coe_pos.mpr ENNReal.coe_lt_coe.mpr
theorem exists_norm_lt_one : â x : α, 0 < âxâ â§ âxâ < 1 :=
exists_norm_lt α one_pos
theorem exists_nnnorm_lt_one : â x : α, 0 < âxââ â§ âxââ < 1 := exists_norm_lt_one _
theorem exists_enorm_lt_one : â x : α, 0 < âxââ â§ âxââ < 1 := exists_enorm_lt _ one_pos
variable {α}
@[instance]
theorem nhdsNE_neBot (x : α) : NeBot (ð[â ] x) := by
rw [â mem_closure_iff_nhdsWithin_neBot, Metric.mem_closure_iff]
rintro ε ε0
rcases exists_norm_lt α ε0 with âšb, hb0, hbεâ©
refine âšx + b, mt (Set.mem_singleton_iff.trans add_eq_left).1 <| norm_pos_iff.1 hb0, ?_â©
rwa [dist_comm, dist_eq_norm, add_sub_cancel_left]
@[deprecated (since := "2025-03-02")]
alias punctured_nhds_neBot := nhdsNE_neBot
@[instance]
theorem nhdsWithin_isUnit_neBot : NeBot (ð[{ x : α | IsUnit x }] 0) := by
simpa only [isUnit_iff_ne_zero] using nhdsNE_neBot (0 : α)
end Nontrivially
section Densely
variable (α) [DenselyNormedField α]
theorem exists_lt_norm_lt {râ râ : â} (hâ : 0 †râ) (h : râ < râ) : â x : α, râ < âxâ â§ âxâ < râ :=
DenselyNormedField.lt_norm_lt râ râ hâ h
theorem exists_lt_nnnorm_lt {râ râ : ââ¥0} (h : râ < râ) : â x : α, râ < âxââ â§ âxââ < râ :=
mod_cast exists_lt_norm_lt α râ.prop h
instance denselyOrdered_range_norm : DenselyOrdered (Set.range (norm : α â â)) where
dense := by
rintro âš-, x, rflâ© âš-, y, rflâ© hxy
let âšz, hâ© := exists_lt_norm_lt α (norm_nonneg _) hxy
exact âšâšâzâ, z, rflâ©, hâ©
instance denselyOrdered_range_nnnorm : DenselyOrdered (Set.range (nnnorm : α â ââ¥0)) where
dense := by
rintro âš-, x, rflâ© âš-, y, rflâ© hxy
let âšz, hâ© := exists_lt_nnnorm_lt α hxy
exact âšâšâzââ, z, rflâ©, hâ©
end Densely
end NormedField
/-- A normed field is nontrivially normed
provided that the norm of some nonzero element is not one. -/
def NontriviallyNormedField.ofNormNeOne {ð : Type*} [h' : NormedField ð]
(h : â x : ð, x â 0 â§ âxâ â 1) : NontriviallyNormedField ð where
toNormedField := h'
non_trivial := by
rcases h with âšx, hx, hx1â©
rcases hx1.lt_or_lt with hlt | hlt
· use xâ»Â¹
rw [norm_inv]
exact (one_lt_invâ (norm_pos_iff.2 hx)).2 hlt
· exact âšx, hltâ©
noncomputable instance Real.normedField : NormedField â :=
{ Real.normedAddCommGroup, Real.field with
norm_mul := abs_mul }
noncomputable instance Real.denselyNormedField : DenselyNormedField â where
lt_norm_lt _ _ hâ hr :=
let âšx, hâ© := exists_between hr
âšx, by rwa [Real.norm_eq_abs, abs_of_nonneg (hâ.trans h.1.le)]â©
namespace Real
theorem toNNReal_mul_nnnorm {x : â} (y : â) (hx : 0 †x) : x.toNNReal * âyââ = âx * yââ := by
ext
simp only [NNReal.coe_mul, nnnorm_mul, coe_nnnorm, Real.toNNReal_of_nonneg, norm_of_nonneg, hx,
NNReal.coe_mk]
theorem nnnorm_mul_toNNReal (x : â) {y : â} (hy : 0 †y) : âxââ * y.toNNReal = âx * yââ := by
rw [mul_comm, mul_comm x, toNNReal_mul_nnnorm x hy]
end Real
/-! ### Induced normed structures -/
section Induced
variable {F : Type*} (R S : Type*) [FunLike F R S]
/-- An injective non-unital ring homomorphism from a `DivisionRing` to a `NormedRing` induces a
`NormedDivisionRing` structure on the domain.
See note [reducible non-instances] -/
abbrev NormedDivisionRing.induced [DivisionRing R] [NormedDivisionRing S]
[NonUnitalRingHomClass F R S] (f : F) (hf : Function.Injective f) : NormedDivisionRing R :=
{ NormedAddCommGroup.induced R S f hf, â¹DivisionRing R⺠with
norm_mul x y := show âf _â = _ from (map_mul f x y).symm âž norm_mul (f x) (f y) }
/-- An injective non-unital ring homomorphism from a `Field` to a `NormedRing` induces a
`NormedField` structure on the domain.
See note [reducible non-instances] -/
abbrev NormedField.induced [Field R] [NormedField S] [NonUnitalRingHomClass F R S] (f : F)
(hf : Function.Injective f) : NormedField R :=
{ NormedDivisionRing.induced R S f hf with
mul_comm := mul_comm }
end Induced
namespace SubfieldClass
variable {S F : Type*} [SetLike S F]
/--
If `s` is a subfield of a normed field `F`, then `s` is equipped with an induced normed
field structure.
-/
instance toNormedField [NormedField F] [SubfieldClass S F] (s : S) : NormedField s :=
NormedField.induced s F (SubringClass.subtype s) Subtype.val_injective
end SubfieldClass
namespace AbsoluteValue
/-- A real absolute value on a field determines a `NormedField` structure. -/
noncomputable def toNormedField {K : Type*} [Field K] (v : AbsoluteValue K â) : NormedField K where
toField := inferInstanceAs (Field K)
__ := v.toNormedRing
norm_mul := v.map_mul
end AbsoluteValue
| Mathlib/Analysis/Normed/Field/Basic.lean | 404 | 406 | |
/-
Copyright (c) 2023 Peter Nelson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Peter Nelson
-/
import Mathlib.SetTheory.Cardinal.Finite
import Mathlib.Data.Set.Finite.Powerset
/-!
# Noncomputable Set Cardinality
We define the cardinality of set `s` as a term `Set.encard s : ââ` and a term `Set.ncard s : â`.
The latter takes the junk value of zero if `s` is infinite. Both functions are noncomputable, and
are defined in terms of `ENat.card` (which takes a type as its argument); this file can be seen
as an API for the same function in the special case where the type is a coercion of a `Set`,
allowing for smoother interactions with the `Set` API.
`Set.encard` never takes junk values, so is more mathematically natural than `Set.ncard`, even
though it takes values in a less convenient type. It is probably the right choice in settings where
one is concerned with the cardinalities of sets that may or may not be infinite.
`Set.ncard` has a nicer codomain, but when using it, `Set.Finite` hypotheses are normally needed to
make sure its values are meaningful. More generally, `Set.ncard` is intended to be used over the
obvious alternative `Finset.card` when finiteness is 'propositional' rather than 'structural'.
When working with sets that are finite by virtue of their definition, then `Finset.card` probably
makes more sense. One setting where `Set.ncard` works nicely is in a type `α` with `[Finite α]`,
where every set is automatically finite. In this setting, we use default arguments and a simple
tactic so that finiteness goals are discharged automatically in `Set.ncard` theorems.
## Main Definitions
* `Set.encard s` is the cardinality of the set `s` as an extended natural number, with value `â€` if
`s` is infinite.
* `Set.ncard s` is the cardinality of the set `s` as a natural number, provided `s` is Finite.
If `s` is Infinite, then `Set.ncard s = 0`.
* `toFinite_tac` is a tactic that tries to synthesize a `Set.Finite s` argument with
`Set.toFinite`. This will work for `s : Set α` where there is a `Finite α` instance.
## Implementation Notes
The theorems in this file are very similar to those in `Data.Finset.Card`, but with `Set` operations
instead of `Finset`. We first prove all the theorems for `Set.encard`, and then derive most of the
`Set.ncard` results as a consequence. Things are done this way to avoid reliance on the `Finset` API
for theorems about infinite sets, and to allow for a refactor that removes or modifies `Set.ncard`
in the future.
Nearly all the theorems for `Set.ncard` require finiteness of one or more of their arguments. We
provide this assumption with a default argument of the form `(hs : s.Finite := by toFinite_tac)`,
where `toFinite_tac` will find an `s.Finite` term in the cases where `s` is a set in a `Finite`
type.
Often, where there are two set arguments `s` and `t`, the finiteness of one follows from the other
in the context of the theorem, in which case we only include the ones that are needed, and derive
the other inside the proof. A few of the theorems, such as `ncard_union_le` do not require
finiteness arguments; they are true by coincidence due to junk values.
-/
namespace Set
variable {α β : Type*} {s t : Set α}
/-- The cardinality of a set as a term in `ââ` -/
noncomputable def encard (s : Set α) : ââ := ENat.card s
@[simp] theorem encard_univ_coe (s : Set α) : encard (univ : Set s) = encard s := by
rw [encard, encard, ENat.card_congr (Equiv.Set.univ âs)]
theorem encard_univ (α : Type*) :
encard (univ : Set α) = ENat.card α := by
rw [encard, ENat.card_congr (Equiv.Set.univ α)]
theorem Finite.encard_eq_coe_toFinset_card (h : s.Finite) : s.encard = h.toFinset.card := by
have := h.fintype
rw [encard, ENat.card_eq_coe_fintype_card, toFinite_toFinset, toFinset_card]
theorem encard_eq_coe_toFinset_card (s : Set α) [Fintype s] : encard s = s.toFinset.card := by
have h := toFinite s
rw [h.encard_eq_coe_toFinset_card, toFinite_toFinset]
@[simp] theorem toENat_cardinalMk (s : Set α) : (Cardinal.mk s).toENat = s.encard := rfl
theorem toENat_cardinalMk_subtype (P : α â Prop) :
(Cardinal.mk {x // P x}).toENat = {x | P x}.encard :=
rfl
@[simp] theorem coe_fintypeCard (s : Set α) [Fintype s] : Fintype.card s = s.encard := by
simp [encard_eq_coe_toFinset_card]
@[simp, norm_cast] theorem encard_coe_eq_coe_finsetCard (s : Finset α) :
encard (s : Set α) = s.card := by
rw [Finite.encard_eq_coe_toFinset_card (Finset.finite_toSet s)]; simp
@[simp] theorem Infinite.encard_eq {s : Set α} (h : s.Infinite) : s.encard = †:= by
have := h.to_subtype
rw [encard, ENat.card_eq_top_of_infinite]
@[simp] theorem encard_eq_zero : s.encard = 0 â s = â
:= by
rw [encard, ENat.card_eq_zero_iff_empty, isEmpty_subtype, eq_empty_iff_forall_not_mem]
@[simp] theorem encard_empty : (â
: Set α).encard = 0 := by
rw [encard_eq_zero]
theorem nonempty_of_encard_ne_zero (h : s.encard â 0) : s.Nonempty := by
rwa [nonempty_iff_ne_empty, Ne, â encard_eq_zero]
theorem encard_ne_zero : s.encard â 0 â s.Nonempty := by
rw [ne_eq, encard_eq_zero, nonempty_iff_ne_empty]
@[simp] theorem encard_pos : 0 < s.encard â s.Nonempty := by
rw [pos_iff_ne_zero, encard_ne_zero]
protected alias âš_, Nonempty.encard_posâ© := encard_pos
@[simp] theorem encard_singleton (e : α) : ({e} : Set α).encard = 1 := by
rw [encard, ENat.card_eq_coe_fintype_card, Fintype.card_ofSubsingleton, Nat.cast_one]
theorem encard_union_eq (h : Disjoint s t) : (s ⪠t).encard = s.encard + t.encard := by
classical
simp [encard, ENat.card_congr (Equiv.Set.union h)]
theorem encard_insert_of_not_mem {a : α} (has : a â s) : (insert a s).encard = s.encard + 1 := by
rw [â union_singleton, encard_union_eq (by simpa), encard_singleton]
theorem Finite.encard_lt_top (h : s.Finite) : s.encard < †:= by
induction s, h using Set.Finite.induction_on with
| empty => simp
| insert hat _ ht' =>
rw [encard_insert_of_not_mem hat]
exact lt_tsub_iff_right.1 ht'
theorem Finite.encard_eq_coe (h : s.Finite) : s.encard = ENat.toNat s.encard :=
(ENat.coe_toNat h.encard_lt_top.ne).symm
theorem Finite.exists_encard_eq_coe (h : s.Finite) : â (n : â), s.encard = n :=
âš_, h.encard_eq_coeâ©
@[simp] theorem encard_lt_top_iff : s.encard < †â s.Finite :=
âšfun h ⊠by_contra fun h' ⊠h.ne (Infinite.encard_eq h'), Finite.encard_lt_topâ©
@[simp] theorem encard_eq_top_iff : s.encard = †â s.Infinite := by
rw [â not_iff_not, â Ne, â lt_top_iff_ne_top, encard_lt_top_iff, not_infinite]
alias âš_, encard_eq_topâ© := encard_eq_top_iff
theorem encard_ne_top_iff : s.encard â †â s.Finite := by
simp
theorem finite_of_encard_le_coe {k : â} (h : s.encard †k) : s.Finite := by
rw [â encard_lt_top_iff]; exact h.trans_lt (WithTop.coe_lt_top _)
theorem finite_of_encard_eq_coe {k : â} (h : s.encard = k) : s.Finite :=
finite_of_encard_le_coe h.le
theorem encard_le_coe_iff {k : â} : s.encard †k â s.Finite â§ â (nâ : â), s.encard = nâ â§ nâ †k :=
âšfun h ⊠âšfinite_of_encard_le_coe h, by rwa [ENat.le_coe_iff] at hâ©,
fun âš_,âšnâ,hs, hleâ©â© ⊠by rwa [hs, Nat.cast_le]â©
@[simp]
theorem encard_prod : (s ÃË¢ t).encard = s.encard * t.encard := by
simp [Set.encard, ENat.card_congr (Equiv.Set.prod ..)]
section Lattice
theorem encard_le_encard (h : s â t) : s.encard †t.encard := by
rw [â union_diff_cancel h, encard_union_eq disjoint_sdiff_right]; exact le_self_add
@[deprecated (since := "2025-01-05")] alias encard_le_card := encard_le_encard
theorem encard_mono {α : Type*} : Monotone (encard : Set α â ââ) :=
fun _ _ ⊠encard_le_encard
theorem encard_diff_add_encard_of_subset (h : s â t) : (t \ s).encard + s.encard = t.encard := by
rw [â encard_union_eq disjoint_sdiff_left, diff_union_self, union_eq_self_of_subset_right h]
@[simp] theorem one_le_encard_iff_nonempty : 1 †s.encard â s.Nonempty := by
rw [nonempty_iff_ne_empty, Ne, â encard_eq_zero, ENat.one_le_iff_ne_zero]
theorem encard_diff_add_encard_inter (s t : Set α) :
(s \ t).encard + (s â© t).encard = s.encard := by
rw [â encard_union_eq (disjoint_of_subset_right inter_subset_right disjoint_sdiff_left),
diff_union_inter]
theorem encard_union_add_encard_inter (s t : Set α) :
(s ⪠t).encard + (s ⩠t).encard = s.encard + t.encard := by
rw [â diff_union_self, encard_union_eq disjoint_sdiff_left, add_right_comm,
encard_diff_add_encard_inter]
theorem encard_eq_encard_iff_encard_diff_eq_encard_diff (h : (s â© t).Finite) :
s.encard = t.encard â (s \ t).encard = (t \ s).encard := by
rw [â encard_diff_add_encard_inter s t, â encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_right_inj h.encard_lt_top.ne]
theorem encard_le_encard_iff_encard_diff_le_encard_diff (h : (s â© t).Finite) :
s.encard †t.encard â (s \ t).encard †(t \ s).encard := by
rw [â encard_diff_add_encard_inter s t, â encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_le_add_iff_right h.encard_lt_top.ne]
theorem encard_lt_encard_iff_encard_diff_lt_encard_diff (h : (s â© t).Finite) :
s.encard < t.encard â (s \ t).encard < (t \ s).encard := by
rw [â encard_diff_add_encard_inter s t, â encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_lt_add_iff_right h.encard_lt_top.ne]
theorem encard_union_le (s t : Set α) : (s ⪠t).encard †s.encard + t.encard := by
rw [â encard_union_add_encard_inter]; exact le_self_add
theorem finite_iff_finite_of_encard_eq_encard (h : s.encard = t.encard) : s.Finite â t.Finite := by
rw [â encard_lt_top_iff, â encard_lt_top_iff, h]
theorem infinite_iff_infinite_of_encard_eq_encard (h : s.encard = t.encard) :
s.Infinite â t.Infinite := by rw [â encard_eq_top_iff, h, encard_eq_top_iff]
theorem Finite.finite_of_encard_le {s : Set α} {t : Set β} (hs : s.Finite)
(h : t.encard †s.encard) : t.Finite :=
encard_lt_top_iff.1 (h.trans_lt hs.encard_lt_top)
lemma Finite.eq_of_subset_of_encard_le' (ht : t.Finite) (hst : s â t) (hts : t.encard †s.encard) :
s = t := by
rw [â zero_add (a := encard s), â encard_diff_add_encard_of_subset hst] at hts
have hdiff := WithTop.le_of_add_le_add_right (ht.subset hst).encard_lt_top.ne hts
rw [nonpos_iff_eq_zero, encard_eq_zero, diff_eq_empty] at hdiff
exact hst.antisymm hdiff
theorem Finite.eq_of_subset_of_encard_le (hs : s.Finite) (hst : s â t)
(hts : t.encard †s.encard) : s = t :=
(hs.finite_of_encard_le hts).eq_of_subset_of_encard_le' hst hts
theorem Finite.encard_lt_encard (hs : s.Finite) (h : s â t) : s.encard < t.encard :=
(encard_mono h.subset).lt_of_ne fun he ⊠h.ne (hs.eq_of_subset_of_encard_le h.subset he.symm.le)
theorem encard_strictMono [Finite α] : StrictMono (encard : Set α â ââ) :=
fun _ _ h ⊠(toFinite _).encard_lt_encard h
theorem encard_diff_add_encard (s t : Set α) : (s \ t).encard + t.encard = (s ⪠t).encard := by
rw [â encard_union_eq disjoint_sdiff_left, diff_union_self]
theorem encard_le_encard_diff_add_encard (s t : Set α) : s.encard †(s \ t).encard + t.encard :=
(encard_mono subset_union_left).trans_eq (encard_diff_add_encard _ _).symm
theorem tsub_encard_le_encard_diff (s t : Set α) : s.encard - t.encard †(s \ t).encard := by
rw [tsub_le_iff_left, add_comm]; apply encard_le_encard_diff_add_encard
theorem encard_add_encard_compl (s : Set α) : s.encard + sá¶.encard = (univ : Set α).encard := by
rw [â encard_union_eq disjoint_compl_right, union_compl_self]
end Lattice
section InsertErase
variable {a b : α}
theorem encard_insert_le (s : Set α) (x : α) : (insert x s).encard †s.encard + 1 := by
rw [â union_singleton, â encard_singleton x]; apply encard_union_le
theorem encard_singleton_inter (s : Set α) (x : α) : ({x} ⩠s).encard †1 := by
rw [â encard_singleton x]; exact encard_le_encard inter_subset_left
theorem encard_diff_singleton_add_one (h : a â s) :
(s \ {a}).encard + 1 = s.encard := by
rw [â encard_insert_of_not_mem (fun h ⊠h.2 rfl), insert_diff_singleton, insert_eq_of_mem h]
|
theorem encard_diff_singleton_of_mem (h : a â s) :
| Mathlib/Data/Set/Card.lean | 260 | 261 |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.Field.NegOnePow
import Mathlib.Algebra.Field.Periodic
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.SpecialFunctions.Exp
/-!
# Trigonometric functions
## Main definitions
This file contains the definition of `Ï`.
See also `Analysis.SpecialFunctions.Trigonometric.Inverse` and
`Analysis.SpecialFunctions.Trigonometric.Arctan` for the inverse trigonometric functions.
See also `Analysis.SpecialFunctions.Complex.Arg` and
`Analysis.SpecialFunctions.Complex.Log` for the complex argument function
and the complex logarithm.
## Main statements
Many basic inequalities on the real trigonometric functions are established.
The continuity of the usual trigonometric functions is proved.
Several facts about the real trigonometric functions have the proofs deferred to
`Analysis.SpecialFunctions.Trigonometric.Complex`,
as they are most easily proved by appealing to the corresponding fact for
complex trigonometric functions.
See also `Analysis.SpecialFunctions.Trigonometric.Chebyshev` for the multiple angle formulas
in terms of Chebyshev polynomials.
## Tags
sin, cos, tan, angle
-/
noncomputable section
open Topology Filter Set
namespace Complex
@[continuity, fun_prop]
theorem continuous_sin : Continuous sin := by
change Continuous fun z => (exp (-z * I) - exp (z * I)) * I / 2
fun_prop
@[fun_prop]
theorem continuousOn_sin {s : Set â} : ContinuousOn sin s :=
continuous_sin.continuousOn
@[continuity, fun_prop]
theorem continuous_cos : Continuous cos := by
change Continuous fun z => (exp (z * I) + exp (-z * I)) / 2
fun_prop
@[fun_prop]
theorem continuousOn_cos {s : Set â} : ContinuousOn cos s :=
continuous_cos.continuousOn
@[continuity, fun_prop]
theorem continuous_sinh : Continuous sinh := by
change Continuous fun z => (exp z - exp (-z)) / 2
fun_prop
@[continuity, fun_prop]
theorem continuous_cosh : Continuous cosh := by
change Continuous fun z => (exp z + exp (-z)) / 2
fun_prop
end Complex
namespace Real
variable {x y z : â}
@[continuity, fun_prop]
theorem continuous_sin : Continuous sin :=
Complex.continuous_re.comp (Complex.continuous_sin.comp Complex.continuous_ofReal)
@[fun_prop]
theorem continuousOn_sin {s} : ContinuousOn sin s :=
continuous_sin.continuousOn
@[continuity, fun_prop]
theorem continuous_cos : Continuous cos :=
Complex.continuous_re.comp (Complex.continuous_cos.comp Complex.continuous_ofReal)
@[fun_prop]
theorem continuousOn_cos {s} : ContinuousOn cos s :=
continuous_cos.continuousOn
@[continuity, fun_prop]
theorem continuous_sinh : Continuous sinh :=
Complex.continuous_re.comp (Complex.continuous_sinh.comp Complex.continuous_ofReal)
@[continuity, fun_prop]
theorem continuous_cosh : Continuous cosh :=
Complex.continuous_re.comp (Complex.continuous_cosh.comp Complex.continuous_ofReal)
end Real
namespace Real
theorem exists_cos_eq_zero : 0 â cos '' Icc (1 : â) 2 :=
intermediate_value_Icc' (by norm_num) continuousOn_cos
âšle_of_lt cos_two_neg, le_of_lt cos_one_posâ©
/-- The number Ï = 3.14159265... Defined here using choice as twice a zero of cos in [1,2], from
which one can derive all its properties. For explicit bounds on Ï, see `Data.Real.Pi.Bounds`.
Denoted `Ï`, once the `Real` namespace is opened. -/
protected noncomputable def pi : â :=
2 * Classical.choose exists_cos_eq_zero
@[inherit_doc]
scoped notation "Ï" => Real.pi
@[simp]
theorem cos_pi_div_two : cos (Ï / 2) = 0 := by
rw [Real.pi, mul_div_cancel_leftâ _ (two_ne_zero' â)]
exact (Classical.choose_spec exists_cos_eq_zero).2
theorem one_le_pi_div_two : (1 : â) â€ Ï / 2 := by
rw [Real.pi, mul_div_cancel_leftâ _ (two_ne_zero' â)]
exact (Classical.choose_spec exists_cos_eq_zero).1.1
theorem pi_div_two_le_two : Ï / 2 †2 := by
rw [Real.pi, mul_div_cancel_leftâ _ (two_ne_zero' â)]
exact (Classical.choose_spec exists_cos_eq_zero).1.2
theorem two_le_pi : (2 : â) â€ Ï :=
(div_le_div_iff_of_pos_right (show (0 : â) < 2 by norm_num)).1
(by rw [div_self (two_ne_zero' â)]; exact one_le_pi_div_two)
theorem pi_le_four : Ï â€ 4 :=
(div_le_div_iff_of_pos_right (show (0 : â) < 2 by norm_num)).1
(calc
Ï / 2 †2 := pi_div_two_le_two
_ = 4 / 2 := by norm_num)
@[bound]
theorem pi_pos : 0 < Ï :=
lt_of_lt_of_le (by norm_num) two_le_pi
@[bound]
theorem pi_nonneg : 0 â€ Ï :=
pi_pos.le
theorem pi_ne_zero : Ï â 0 :=
pi_pos.ne'
theorem pi_div_two_pos : 0 < Ï / 2 :=
half_pos pi_pos
theorem two_pi_pos : 0 < 2 * Ï := by linarith [pi_pos]
end Real
namespace Mathlib.Meta.Positivity
open Lean.Meta Qq
/-- Extension for the `positivity` tactic: `Ï` is always positive. -/
@[positivity Real.pi]
def evalRealPi : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(â), ~q(Real.pi) =>
assertInstancesCommute
pure (.positive q(Real.pi_pos))
| _, _, _ => throwError "not Real.pi"
end Mathlib.Meta.Positivity
namespace NNReal
open Real
open Real NNReal
/-- `Ï` considered as a nonnegative real. -/
noncomputable def pi : ââ¥0 :=
âšÏ, Real.pi_pos.leâ©
@[simp]
theorem coe_real_pi : (pi : â) = Ï :=
rfl
theorem pi_pos : 0 < pi := mod_cast Real.pi_pos
theorem pi_ne_zero : pi â 0 :=
pi_pos.ne'
end NNReal
namespace Real
@[simp]
theorem sin_pi : sin Ï = 0 := by
rw [â mul_div_cancel_leftâ Ï (two_ne_zero' â), two_mul, add_div, sin_add, cos_pi_div_two]; simp
@[simp]
theorem cos_pi : cos Ï = -1 := by
rw [â mul_div_cancel_leftâ Ï (two_ne_zero' â), mul_div_assoc, cos_two_mul, cos_pi_div_two]
norm_num
@[simp]
theorem sin_two_pi : sin (2 * Ï) = 0 := by simp [two_mul, sin_add]
@[simp]
theorem cos_two_pi : cos (2 * Ï) = 1 := by simp [two_mul, cos_add]
theorem sin_antiperiodic : Function.Antiperiodic sin Ï := by simp [sin_add]
theorem sin_periodic : Function.Periodic sin (2 * Ï) :=
sin_antiperiodic.periodic_two_mul
@[simp]
theorem sin_add_pi (x : â) : sin (x + Ï) = -sin x :=
sin_antiperiodic x
@[simp]
theorem sin_add_two_pi (x : â) : sin (x + 2 * Ï) = sin x :=
sin_periodic x
@[simp]
theorem sin_sub_pi (x : â) : sin (x - Ï) = -sin x :=
sin_antiperiodic.sub_eq x
@[simp]
theorem sin_sub_two_pi (x : â) : sin (x - 2 * Ï) = sin x :=
sin_periodic.sub_eq x
@[simp]
theorem sin_pi_sub (x : â) : sin (Ï - x) = sin x :=
neg_neg (sin x) âž sin_neg x âž sin_antiperiodic.sub_eq'
@[simp]
theorem sin_two_pi_sub (x : â) : sin (2 * Ï - x) = -sin x :=
sin_neg x âž sin_periodic.sub_eq'
@[simp]
theorem sin_nat_mul_pi (n : â) : sin (n * Ï) = 0 :=
sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n
@[simp]
theorem sin_int_mul_pi (n : â€) : sin (n * Ï) = 0 :=
sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n
@[simp]
theorem sin_add_nat_mul_two_pi (x : â) (n : â) : sin (x + n * (2 * Ï)) = sin x :=
sin_periodic.nat_mul n x
@[simp]
theorem sin_add_int_mul_two_pi (x : â) (n : â€) : sin (x + n * (2 * Ï)) = sin x :=
sin_periodic.int_mul n x
@[simp]
theorem sin_sub_nat_mul_two_pi (x : â) (n : â) : sin (x - n * (2 * Ï)) = sin x :=
sin_periodic.sub_nat_mul_eq n
@[simp]
theorem sin_sub_int_mul_two_pi (x : â) (n : â€) : sin (x - n * (2 * Ï)) = sin x :=
sin_periodic.sub_int_mul_eq n
@[simp]
theorem sin_nat_mul_two_pi_sub (x : â) (n : â) : sin (n * (2 * Ï) - x) = -sin x :=
sin_neg x âž sin_periodic.nat_mul_sub_eq n
@[simp]
theorem sin_int_mul_two_pi_sub (x : â) (n : â€) : sin (n * (2 * Ï) - x) = -sin x :=
sin_neg x âž sin_periodic.int_mul_sub_eq n
theorem sin_add_int_mul_pi (x : â) (n : â€) : sin (x + n * Ï) = (-1) ^ n * sin x :=
n.cast_negOnePow â âž sin_antiperiodic.add_int_mul_eq n
theorem sin_add_nat_mul_pi (x : â) (n : â) : sin (x + n * Ï) = (-1) ^ n * sin x :=
sin_antiperiodic.add_nat_mul_eq n
theorem sin_sub_int_mul_pi (x : â) (n : â€) : sin (x - n * Ï) = (-1) ^ n * sin x :=
n.cast_negOnePow â âž sin_antiperiodic.sub_int_mul_eq n
theorem sin_sub_nat_mul_pi (x : â) (n : â) : sin (x - n * Ï) = (-1) ^ n * sin x :=
sin_antiperiodic.sub_nat_mul_eq n
theorem sin_int_mul_pi_sub (x : â) (n : â€) : sin (n * Ï - x) = -((-1) ^ n * sin x) := by
simpa only [sin_neg, mul_neg, Int.cast_negOnePow] using sin_antiperiodic.int_mul_sub_eq n
theorem sin_nat_mul_pi_sub (x : â) (n : â) : sin (n * Ï - x) = -((-1) ^ n * sin x) := by
simpa only [sin_neg, mul_neg] using sin_antiperiodic.nat_mul_sub_eq n
theorem cos_antiperiodic : Function.Antiperiodic cos Ï := by simp [cos_add]
theorem cos_periodic : Function.Periodic cos (2 * Ï) :=
cos_antiperiodic.periodic_two_mul
@[simp]
theorem abs_cos_int_mul_pi (k : â€) : |cos (k * Ï)| = 1 := by
simp [abs_cos_eq_sqrt_one_sub_sin_sq]
@[simp]
theorem cos_add_pi (x : â) : cos (x + Ï) = -cos x :=
cos_antiperiodic x
@[simp]
theorem cos_add_two_pi (x : â) : cos (x + 2 * Ï) = cos x :=
cos_periodic x
@[simp]
theorem cos_sub_pi (x : â) : cos (x - Ï) = -cos x :=
cos_antiperiodic.sub_eq x
@[simp]
theorem cos_sub_two_pi (x : â) : cos (x - 2 * Ï) = cos x :=
cos_periodic.sub_eq x
@[simp]
theorem cos_pi_sub (x : â) : cos (Ï - x) = -cos x :=
cos_neg x âž cos_antiperiodic.sub_eq'
@[simp]
theorem cos_two_pi_sub (x : â) : cos (2 * Ï - x) = cos x :=
cos_neg x âž cos_periodic.sub_eq'
@[simp]
theorem cos_nat_mul_two_pi (n : â) : cos (n * (2 * Ï)) = 1 :=
(cos_periodic.nat_mul_eq n).trans cos_zero
@[simp]
theorem cos_int_mul_two_pi (n : â€) : cos (n * (2 * Ï)) = 1 :=
(cos_periodic.int_mul_eq n).trans cos_zero
@[simp]
theorem cos_add_nat_mul_two_pi (x : â) (n : â) : cos (x + n * (2 * Ï)) = cos x :=
cos_periodic.nat_mul n x
@[simp]
theorem cos_add_int_mul_two_pi (x : â) (n : â€) : cos (x + n * (2 * Ï)) = cos x :=
cos_periodic.int_mul n x
@[simp]
theorem cos_sub_nat_mul_two_pi (x : â) (n : â) : cos (x - n * (2 * Ï)) = cos x :=
cos_periodic.sub_nat_mul_eq n
@[simp]
theorem cos_sub_int_mul_two_pi (x : â) (n : â€) : cos (x - n * (2 * Ï)) = cos x :=
cos_periodic.sub_int_mul_eq n
@[simp]
theorem cos_nat_mul_two_pi_sub (x : â) (n : â) : cos (n * (2 * Ï) - x) = cos x :=
cos_neg x âž cos_periodic.nat_mul_sub_eq n
@[simp]
theorem cos_int_mul_two_pi_sub (x : â) (n : â€) : cos (n * (2 * Ï) - x) = cos x :=
cos_neg x âž cos_periodic.int_mul_sub_eq n
theorem cos_add_int_mul_pi (x : â) (n : â€) : cos (x + n * Ï) = (-1) ^ n * cos x :=
n.cast_negOnePow â âž cos_antiperiodic.add_int_mul_eq n
theorem cos_add_nat_mul_pi (x : â) (n : â) : cos (x + n * Ï) = (-1) ^ n * cos x :=
cos_antiperiodic.add_nat_mul_eq n
theorem cos_sub_int_mul_pi (x : â) (n : â€) : cos (x - n * Ï) = (-1) ^ n * cos x :=
n.cast_negOnePow â âž cos_antiperiodic.sub_int_mul_eq n
theorem cos_sub_nat_mul_pi (x : â) (n : â) : cos (x - n * Ï) = (-1) ^ n * cos x :=
cos_antiperiodic.sub_nat_mul_eq n
theorem cos_int_mul_pi_sub (x : â) (n : â€) : cos (n * Ï - x) = (-1) ^ n * cos x :=
n.cast_negOnePow â âž cos_neg x âž cos_antiperiodic.int_mul_sub_eq n
theorem cos_nat_mul_pi_sub (x : â) (n : â) : cos (n * Ï - x) = (-1) ^ n * cos x :=
cos_neg x âž cos_antiperiodic.nat_mul_sub_eq n
theorem cos_nat_mul_two_pi_add_pi (n : â) : cos (n * (2 * Ï) + Ï) = -1 := by
simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic
theorem cos_int_mul_two_pi_add_pi (n : â€) : cos (n * (2 * Ï) + Ï) = -1 := by
simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic
theorem cos_nat_mul_two_pi_sub_pi (n : â) : cos (n * (2 * Ï) - Ï) = -1 := by
simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic
theorem cos_int_mul_two_pi_sub_pi (n : â€) : cos (n * (2 * Ï) - Ï) = -1 := by
simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic
theorem sin_pos_of_pos_of_lt_pi {x : â} (h0x : 0 < x) (hxp : x < Ï) : 0 < sin x :=
if hx2 : x †2 then sin_pos_of_pos_of_le_two h0x hx2
else
have : (2 : â) + 2 = 4 := by norm_num
have : Ï - x †2 :=
sub_le_iff_le_add.2 (le_trans pi_le_four (this âž add_le_add_left (le_of_not_ge hx2) _))
sin_pi_sub x âž sin_pos_of_pos_of_le_two (sub_pos.2 hxp) this
theorem sin_pos_of_mem_Ioo {x : â} (hx : x â Ioo 0 Ï) : 0 < sin x :=
sin_pos_of_pos_of_lt_pi hx.1 hx.2
theorem sin_nonneg_of_mem_Icc {x : â} (hx : x â Icc 0 Ï) : 0 †sin x := by
rw [â closure_Ioo pi_ne_zero.symm] at hx
exact
closure_lt_subset_le continuous_const continuous_sin
(closure_mono (fun y => sin_pos_of_mem_Ioo) hx)
theorem sin_nonneg_of_nonneg_of_le_pi {x : â} (h0x : 0 †x) (hxp : x †Ï) : 0 †sin x :=
sin_nonneg_of_mem_Icc âšh0x, hxpâ©
theorem sin_neg_of_neg_of_neg_pi_lt {x : â} (hx0 : x < 0) (hpx : -Ï < x) : sin x < 0 :=
neg_pos.1 <| sin_neg x âž sin_pos_of_pos_of_lt_pi (neg_pos.2 hx0) (neg_lt.1 hpx)
theorem sin_nonpos_of_nonnpos_of_neg_pi_le {x : â} (hx0 : x †0) (hpx : -Ï â€ x) : sin x †0 :=
neg_nonneg.1 <| sin_neg x âž sin_nonneg_of_nonneg_of_le_pi (neg_nonneg.2 hx0) (neg_le.1 hpx)
@[simp]
theorem sin_pi_div_two : sin (Ï / 2) = 1 :=
have : sin (Ï / 2) = 1 âš sin (Ï / 2) = -1 := by
simpa [sq, mul_self_eq_one_iff] using sin_sq_add_cos_sq (Ï / 2)
this.resolve_right fun h =>
show ¬(0 : â) < -1 by norm_num <|
h âž sin_pos_of_pos_of_lt_pi pi_div_two_pos (half_lt_self pi_pos)
theorem sin_add_pi_div_two (x : â) : sin (x + Ï / 2) = cos x := by simp [sin_add]
theorem sin_sub_pi_div_two (x : â) : sin (x - Ï / 2) = -cos x := by simp [sub_eq_add_neg, sin_add]
theorem sin_pi_div_two_sub (x : â) : sin (Ï / 2 - x) = cos x := by simp [sub_eq_add_neg, sin_add]
theorem cos_add_pi_div_two (x : â) : cos (x + Ï / 2) = -sin x := by simp [cos_add]
theorem cos_sub_pi_div_two (x : â) : cos (x - Ï / 2) = sin x := by simp [sub_eq_add_neg, cos_add]
theorem cos_pi_div_two_sub (x : â) : cos (Ï / 2 - x) = sin x := by
rw [â cos_neg, neg_sub, cos_sub_pi_div_two]
theorem cos_pos_of_mem_Ioo {x : â} (hx : x â Ioo (-(Ï / 2)) (Ï / 2)) : 0 < cos x :=
sin_add_pi_div_two x âž sin_pos_of_mem_Ioo âšby linarith [hx.1], by linarith [hx.2]â©
theorem cos_nonneg_of_mem_Icc {x : â} (hx : x â Icc (-(Ï / 2)) (Ï / 2)) : 0 †cos x :=
sin_add_pi_div_two x âž sin_nonneg_of_mem_Icc âšby linarith [hx.1], by linarith [hx.2]â©
theorem cos_nonneg_of_neg_pi_div_two_le_of_le {x : â} (hl : -(Ï / 2) †x) (hu : x â€ Ï / 2) :
0 †cos x :=
cos_nonneg_of_mem_Icc âšhl, huâ©
theorem cos_neg_of_pi_div_two_lt_of_lt {x : â} (hxâ : Ï / 2 < x) (hxâ : x < Ï + Ï / 2) :
cos x < 0 :=
neg_pos.1 <| cos_pi_sub x âž cos_pos_of_mem_Ioo âšby linarith, by linarithâ©
theorem cos_nonpos_of_pi_div_two_le_of_le {x : â} (hxâ : Ï / 2 †x) (hxâ : x â€ Ï + Ï / 2) :
cos x †0 :=
neg_nonneg.1 <| cos_pi_sub x âž cos_nonneg_of_mem_Icc âšby linarith, by linarithâ©
theorem sin_eq_sqrt_one_sub_cos_sq {x : â} (hl : 0 †x) (hu : x †Ï) :
sin x = â(1 - cos x ^ 2) := by
rw [â abs_sin_eq_sqrt_one_sub_cos_sq, abs_of_nonneg (sin_nonneg_of_nonneg_of_le_pi hl hu)]
theorem cos_eq_sqrt_one_sub_sin_sq {x : â} (hl : -(Ï / 2) †x) (hu : x â€ Ï / 2) :
cos x = â(1 - sin x ^ 2) := by
rw [â abs_cos_eq_sqrt_one_sub_sin_sq, abs_of_nonneg (cos_nonneg_of_mem_Icc âšhl, huâ©)]
lemma cos_half {x : â} (hl : -Ï â€ x) (hr : x †Ï) : cos (x / 2) = sqrt ((1 + cos x) / 2) := by
have : 0 †cos (x / 2) := cos_nonneg_of_mem_Icc <| by constructor <;> linarith
rw [â sqrt_sq this, cos_sq, add_div, two_mul, add_halves]
lemma abs_sin_half (x : â) : |sin (x / 2)| = sqrt ((1 - cos x) / 2) := by
rw [â sqrt_sq_eq_abs, sin_sq_eq_half_sub, two_mul, add_halves, sub_div]
lemma sin_half_eq_sqrt {x : â} (hl : 0 †x) (hr : x †2 * Ï) :
sin (x / 2) = sqrt ((1 - cos x) / 2) := by
rw [â abs_sin_half, abs_of_nonneg]
apply sin_nonneg_of_nonneg_of_le_pi <;> linarith
lemma sin_half_eq_neg_sqrt {x : â} (hl : -(2 * Ï) †x) (hr : x †0) :
sin (x / 2) = -sqrt ((1 - cos x) / 2) := by
rw [â abs_sin_half, abs_of_nonpos, neg_neg]
apply sin_nonpos_of_nonnpos_of_neg_pi_le <;> linarith
theorem sin_eq_zero_iff_of_lt_of_lt {x : â} (hxâ : -Ï < x) (hxâ : x < Ï) : sin x = 0 â x = 0 :=
âšfun h => by
contrapose! h
cases h.lt_or_lt with
| inl h0 => exact (sin_neg_of_neg_of_neg_pi_lt h0 hxâ).ne
| inr h0 => exact (sin_pos_of_pos_of_lt_pi h0 hxâ).ne',
fun h => by simp [h]â©
theorem sin_eq_zero_iff {x : â} : sin x = 0 â â n : â€, (n : â) * Ï = x :=
âšfun h =>
âšâx / Ïâ,
le_antisymm (sub_nonneg.1 (Int.sub_floor_div_mul_nonneg _ pi_pos))
(sub_nonpos.1 <|
le_of_not_gt fun hâ =>
(sin_pos_of_pos_of_lt_pi hâ (Int.sub_floor_div_mul_lt _ pi_pos)).ne
(by simp [sub_eq_add_neg, sin_add, h, sin_int_mul_pi]))â©,
fun âš_, hnâ© => hn âž sin_int_mul_pi _â©
theorem sin_ne_zero_iff {x : â} : sin x â 0 â â n : â€, (n : â) * Ï â x := by
rw [â not_exists, not_iff_not, sin_eq_zero_iff]
theorem sin_eq_zero_iff_cos_eq {x : â} : sin x = 0 â cos x = 1 âš cos x = -1 := by
rw [â mul_self_eq_one_iff, â sin_sq_add_cos_sq x, sq, sq, â sub_eq_iff_eq_add, sub_self]
exact âšfun h => by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero â Eq.symmâ©
theorem cos_eq_one_iff (x : â) : cos x = 1 â â n : â€, (n : â) * (2 * Ï) = x :=
âšfun h =>
let âšn, hnâ© := sin_eq_zero_iff.1 (sin_eq_zero_iff_cos_eq.2 (Or.inl h))
âšn / 2,
(Int.emod_two_eq_zero_or_one n).elim
(fun hn0 => by
rwa [â mul_assoc, â @Int.cast_two â, â Int.cast_mul,
Int.ediv_mul_cancel (Int.dvd_iff_emod_eq_zero.2 hn0)])
fun hn1 => by
rw [â Int.emod_add_ediv n 2, hn1, Int.cast_add, Int.cast_one, add_mul, one_mul, add_comm,
mul_comm (2 : â€), Int.cast_mul, mul_assoc, Int.cast_two] at hn
rw [â hn, cos_int_mul_two_pi_add_pi] at h
exact absurd h (by norm_num)â©,
fun âš_, hnâ© => hn âž cos_int_mul_two_pi _â©
theorem cos_eq_one_iff_of_lt_of_lt {x : â} (hxâ : -(2 * Ï) < x) (hxâ : x < 2 * Ï) :
cos x = 1 â x = 0 :=
âšfun h => by
rcases (cos_eq_one_iff _).1 h with âšn, rflâ©
rw [mul_lt_iff_lt_one_left two_pi_pos] at hxâ
rw [neg_lt, neg_mul_eq_neg_mul, mul_lt_iff_lt_one_left two_pi_pos] at hxâ
norm_cast at hxâ hxâ
obtain rfl : n = 0 := le_antisymm (by omega) (by omega)
simp, fun h => by simp [h]â©
theorem sin_lt_sin_of_lt_of_le_pi_div_two {x y : â} (hxâ : -(Ï / 2) †x) (hyâ : y â€ Ï / 2)
(hxy : x < y) : sin x < sin y := by
rw [â sub_pos, sin_sub_sin]
have : 0 < sin ((y - x) / 2) := by apply sin_pos_of_pos_of_lt_pi <;> linarith
have : 0 < cos ((y + x) / 2) := by refine cos_pos_of_mem_Ioo âš?_, ?_â© <;> linarith
positivity
theorem strictMonoOn_sin : StrictMonoOn sin (Icc (-(Ï / 2)) (Ï / 2)) := fun _ hx _ hy hxy =>
sin_lt_sin_of_lt_of_le_pi_div_two hx.1 hy.2 hxy
theorem cos_lt_cos_of_nonneg_of_le_pi {x y : â} (hxâ : 0 †x) (hyâ : y †Ï) (hxy : x < y) :
cos y < cos x := by
rw [â sin_pi_div_two_sub, â sin_pi_div_two_sub]
apply sin_lt_sin_of_lt_of_le_pi_div_two <;> linarith
theorem cos_lt_cos_of_nonneg_of_le_pi_div_two {x y : â} (hxâ : 0 †x) (hyâ : y â€ Ï / 2)
(hxy : x < y) : cos y < cos x :=
cos_lt_cos_of_nonneg_of_le_pi hxâ (hyâ.trans (by linarith)) hxy
theorem strictAntiOn_cos : StrictAntiOn cos (Icc 0 Ï) := fun _ hx _ hy hxy =>
cos_lt_cos_of_nonneg_of_le_pi hx.1 hy.2 hxy
theorem cos_le_cos_of_nonneg_of_le_pi {x y : â} (hxâ : 0 †x) (hyâ : y †Ï) (hxy : x †y) :
cos y †cos x :=
(strictAntiOn_cos.le_iff_le âšhxâ.trans hxy, hyââ© âšhxâ, hxy.trans hyââ©).2 hxy
theorem sin_le_sin_of_le_of_le_pi_div_two {x y : â} (hxâ : -(Ï / 2) †x) (hyâ : y â€ Ï / 2)
(hxy : x †y) : sin x †sin y :=
(strictMonoOn_sin.le_iff_le âšhxâ, hxy.trans hyââ© âšhxâ.trans hxy, hyââ©).2 hxy
theorem injOn_sin : InjOn sin (Icc (-(Ï / 2)) (Ï / 2)) :=
strictMonoOn_sin.injOn
theorem injOn_cos : InjOn cos (Icc 0 Ï) :=
strictAntiOn_cos.injOn
theorem surjOn_sin : SurjOn sin (Icc (-(Ï / 2)) (Ï / 2)) (Icc (-1) 1) := by
simpa only [sin_neg, sin_pi_div_two] using
intermediate_value_Icc (neg_le_self pi_div_two_pos.le) continuous_sin.continuousOn
theorem surjOn_cos : SurjOn cos (Icc 0 Ï) (Icc (-1) 1) := by
simpa only [cos_zero, cos_pi] using intermediate_value_Icc' pi_pos.le continuous_cos.continuousOn
theorem sin_mem_Icc (x : â) : sin x â Icc (-1 : â) 1 :=
âšneg_one_le_sin x, sin_le_one xâ©
theorem cos_mem_Icc (x : â) : cos x â Icc (-1 : â) 1 :=
âšneg_one_le_cos x, cos_le_one xâ©
theorem mapsTo_sin (s : Set â) : MapsTo sin s (Icc (-1 : â) 1) := fun x _ => sin_mem_Icc x
theorem mapsTo_cos (s : Set â) : MapsTo cos s (Icc (-1 : â) 1) := fun x _ => cos_mem_Icc x
theorem bijOn_sin : BijOn sin (Icc (-(Ï / 2)) (Ï / 2)) (Icc (-1) 1) :=
âšmapsTo_sin _, injOn_sin, surjOn_sinâ©
theorem bijOn_cos : BijOn cos (Icc 0 Ï) (Icc (-1) 1) :=
âšmapsTo_cos _, injOn_cos, surjOn_cosâ©
@[simp]
theorem range_cos : range cos = (Icc (-1) 1 : Set â) :=
Subset.antisymm (range_subset_iff.2 cos_mem_Icc) surjOn_cos.subset_range
@[simp]
theorem range_sin : range sin = (Icc (-1) 1 : Set â) :=
Subset.antisymm (range_subset_iff.2 sin_mem_Icc) surjOn_sin.subset_range
theorem range_cos_infinite : (range Real.cos).Infinite := by
rw [Real.range_cos]
exact Icc_infinite (by norm_num)
theorem range_sin_infinite : (range Real.sin).Infinite := by
rw [Real.range_sin]
exact Icc_infinite (by norm_num)
section CosDivSq
variable (x : â)
/-- the series `sqrtTwoAddSeries x n` is `sqrt(2 + sqrt(2 + ... ))` with `n` square roots,
starting with `x`. We define it here because `cos (pi / 2 ^ (n+1)) = sqrtTwoAddSeries 0 n / 2`
-/
@[simp]
noncomputable def sqrtTwoAddSeries (x : â) : â â â
| 0 => x
| n + 1 => â(2 + sqrtTwoAddSeries x n)
theorem sqrtTwoAddSeries_zero : sqrtTwoAddSeries x 0 = x := by simp
theorem sqrtTwoAddSeries_one : sqrtTwoAddSeries 0 1 = â2 := by simp
theorem sqrtTwoAddSeries_two : sqrtTwoAddSeries 0 2 = â(2 + â2) := by simp
theorem sqrtTwoAddSeries_zero_nonneg : â n : â, 0 †sqrtTwoAddSeries 0 n
| 0 => le_refl 0
| _ + 1 => sqrt_nonneg _
theorem sqrtTwoAddSeries_nonneg {x : â} (h : 0 †x) : â n : â, 0 †sqrtTwoAddSeries x n
| 0 => h
| _ + 1 => sqrt_nonneg _
theorem sqrtTwoAddSeries_lt_two : â n : â, sqrtTwoAddSeries 0 n < 2
| 0 => by norm_num
| n + 1 => by
refine lt_of_lt_of_le ?_ (sqrt_sq zero_lt_two.le).le
rw [sqrtTwoAddSeries, sqrt_lt_sqrt_iff, â lt_sub_iff_add_lt']
· refine (sqrtTwoAddSeries_lt_two n).trans_le ?_
norm_num
· exact add_nonneg zero_le_two (sqrtTwoAddSeries_zero_nonneg n)
theorem sqrtTwoAddSeries_succ (x : â) :
â n : â, sqrtTwoAddSeries x (n + 1) = sqrtTwoAddSeries (â(2 + x)) n
| 0 => rfl
| n + 1 => by rw [sqrtTwoAddSeries, sqrtTwoAddSeries_succ _ _, sqrtTwoAddSeries]
theorem sqrtTwoAddSeries_monotone_left {x y : â} (h : x †y) :
â n : â, sqrtTwoAddSeries x n †sqrtTwoAddSeries y n
| 0 => h
| n + 1 => by
rw [sqrtTwoAddSeries, sqrtTwoAddSeries]
exact sqrt_le_sqrt (add_le_add_left (sqrtTwoAddSeries_monotone_left h _) _)
@[simp]
theorem cos_pi_over_two_pow : â n : â, cos (Ï / 2 ^ (n + 1)) = sqrtTwoAddSeries 0 n / 2
| 0 => by simp
| n + 1 => by
have A : (1 : â) < 2 ^ (n + 1) := one_lt_powâ one_lt_two n.succ_ne_zero
have B : Ï / 2 ^ (n + 1) < Ï := div_lt_self pi_pos A
have C : 0 < Ï / 2 ^ (n + 1) := by positivity
rw [pow_succ, div_mul_eq_div_div, cos_half, cos_pi_over_two_pow n, sqrtTwoAddSeries,
add_div_eq_mul_add_div, one_mul, â div_mul_eq_div_div, sqrt_div, sqrt_mul_self] <;>
linarith [sqrtTwoAddSeries_nonneg le_rfl n]
theorem sin_sq_pi_over_two_pow (n : â) :
sin (Ï / 2 ^ (n + 1)) ^ 2 = 1 - (sqrtTwoAddSeries 0 n / 2) ^ 2 := by
rw [sin_sq, cos_pi_over_two_pow]
theorem sin_sq_pi_over_two_pow_succ (n : â) :
sin (Ï / 2 ^ (n + 2)) ^ 2 = 1 / 2 - sqrtTwoAddSeries 0 n / 4 := by
rw [sin_sq_pi_over_two_pow, sqrtTwoAddSeries, div_pow, sq_sqrt, add_div, â sub_sub]
· congr
· norm_num
· norm_num
· exact add_nonneg two_pos.le (sqrtTwoAddSeries_zero_nonneg _)
@[simp]
theorem sin_pi_over_two_pow_succ (n : â) :
sin (Ï / 2 ^ (n + 2)) = â(2 - sqrtTwoAddSeries 0 n) / 2 := by
rw [eq_div_iff_mul_eq two_ne_zero, eq_comm, sqrt_eq_iff_eq_sq, mul_pow,
sin_sq_pi_over_two_pow_succ, sub_mul]
· congr <;> norm_num
· rw [sub_nonneg]
exact (sqrtTwoAddSeries_lt_two _).le
refine mul_nonneg (sin_nonneg_of_nonneg_of_le_pi ?_ ?_) zero_le_two
· positivity
· exact div_le_self pi_pos.le <| one_le_powâ one_le_two
@[simp]
theorem cos_pi_div_four : cos (Ï / 4) = â2 / 2 := by
trans cos (Ï / 2 ^ 2)
· congr
norm_num
· simp
@[simp]
theorem sin_pi_div_four : sin (Ï / 4) = â2 / 2 := by
trans sin (Ï / 2 ^ 2)
· congr
norm_num
· simp
@[simp]
theorem cos_pi_div_eight : cos (Ï / 8) = â(2 + â2) / 2 := by
trans cos (Ï / 2 ^ 3)
· congr
norm_num
· simp
@[simp]
theorem sin_pi_div_eight : sin (Ï / 8) = â(2 - â2) / 2 := by
trans sin (Ï / 2 ^ 3)
· congr
norm_num
· simp
@[simp]
theorem cos_pi_div_sixteen : cos (Ï / 16) = â(2 + â(2 + â2)) / 2 := by
trans cos (Ï / 2 ^ 4)
· congr
norm_num
· simp
@[simp]
theorem sin_pi_div_sixteen : sin (Ï / 16) = â(2 - â(2 + â2)) / 2 := by
trans sin (Ï / 2 ^ 4)
· congr
norm_num
· simp
@[simp]
theorem cos_pi_div_thirty_two : cos (Ï / 32) = â(2 + â(2 + â(2 + â2))) / 2 := by
trans cos (Ï / 2 ^ 5)
· congr
norm_num
· simp
@[simp]
theorem sin_pi_div_thirty_two : sin (Ï / 32) = â(2 - â(2 + â(2 + â2))) / 2 := by
trans sin (Ï / 2 ^ 5)
· congr
norm_num
· simp
-- This section is also a convenient location for other explicit values of `sin` and `cos`.
/-- The cosine of `Ï / 3` is `1 / 2`. -/
@[simp]
theorem cos_pi_div_three : cos (Ï / 3) = 1 / 2 := by
have hâ : (2 * cos (Ï / 3) - 1) ^ 2 * (2 * cos (Ï / 3) + 2) = 0 := by
have : cos (3 * (Ï / 3)) = cos Ï := by
congr 1
ring
linarith [cos_pi, cos_three_mul (Ï / 3)]
rcases mul_eq_zero.mp hâ with h | h
· linarith [pow_eq_zero h]
· have : cos Ï < cos (Ï / 3) := by
refine cos_lt_cos_of_nonneg_of_le_pi ?_ le_rfl ?_ <;> linarith [pi_pos]
linarith [cos_pi]
/-- The cosine of `Ï / 6` is `â3 / 2`. -/
@[simp]
theorem cos_pi_div_six : cos (Ï / 6) = â3 / 2 := by
rw [show (6 : â) = 3 * 2 by norm_num, div_mul_eq_div_div, cos_half, cos_pi_div_three, one_add_div,
â div_mul_eq_div_div, two_add_one_eq_three, sqrt_div, sqrt_mul_self] <;> linarith [pi_pos]
/-- The square of the cosine of `Ï / 6` is `3 / 4` (this is sometimes more convenient than the
result for cosine itself). -/
theorem sq_cos_pi_div_six : cos (Ï / 6) ^ 2 = 3 / 4 := by
rw [cos_pi_div_six, div_pow, sq_sqrt] <;> norm_num
/-- The sine of `Ï / 6` is `1 / 2`. -/
@[simp]
theorem sin_pi_div_six : sin (Ï / 6) = 1 / 2 := by
rw [â cos_pi_div_two_sub, â cos_pi_div_three]
congr
ring
/-- The square of the sine of `Ï / 3` is `3 / 4` (this is sometimes more convenient than the
result for cosine itself). -/
theorem sq_sin_pi_div_three : sin (Ï / 3) ^ 2 = 3 / 4 := by
rw [â cos_pi_div_two_sub, â sq_cos_pi_div_six]
congr
ring
/-- The sine of `Ï / 3` is `â3 / 2`. -/
@[simp]
theorem sin_pi_div_three : sin (Ï / 3) = â3 / 2 := by
rw [â cos_pi_div_two_sub, â cos_pi_div_six]
congr
ring
theorem quadratic_root_cos_pi_div_five :
letI c := cos (Ï / 5)
4 * c ^ 2 - 2 * c - 1 = 0 := by
set Ξ := Ï / 5 with hΞ
set c := cos Ξ
set s := sin Ξ
suffices 2 * c = 4 * c ^ 2 - 1 by simp [this]
have hs : s â 0 := by
rw [ne_eq, sin_eq_zero_iff, hΞ]
push_neg
intro n hn
replace hn : n * 5 = 1 := by field_simp [mul_comm _ Ï, mul_assoc] at hn; norm_cast at hn
omega
suffices s * (2 * c) = s * (4 * c ^ 2 - 1) from mul_left_cancelâ hs this
calc s * (2 * c) = 2 * s * c := by rw [â mul_assoc, mul_comm 2]
_ = sin (2 * Ξ) := by rw [sin_two_mul]
_ = sin (Ï - 2 * Ξ) := by rw [sin_pi_sub]
_ = sin (2 * Ξ + Ξ) := by congr; field_simp [hΞ]; linarith
_ = sin (2 * Ξ) * c + cos (2 * Ξ) * s := sin_add (2 * Ξ) Ξ
_ = 2 * s * c * c + cos (2 * Ξ) * s := by rw [sin_two_mul]
_ = 2 * s * c * c + (2 * c ^ 2 - 1) * s := by rw [cos_two_mul]
_ = s * (2 * c * c) + s * (2 * c ^ 2 - 1) := by linarith
_ = s * (4 * c ^ 2 - 1) := by linarith
open Polynomial in
theorem Polynomial.isRoot_cos_pi_div_five :
(4 ⢠X ^ 2 - 2 ⢠X - C 1 : â[X]).IsRoot (cos (Ï / 5)) := by
simpa using quadratic_root_cos_pi_div_five
/-- The cosine of `Ï / 5` is `(1 + â5) / 4`. -/
@[simp]
theorem cos_pi_div_five : cos (Ï / 5) = (1 + â5) / 4 := by
set c := cos (Ï / 5)
have : 4 * (c * c) + (-2) * c + (-1) = 0 := by
rw [â sq, neg_mul, â sub_eq_add_neg, â sub_eq_add_neg]
exact quadratic_root_cos_pi_div_five
have hd : discrim 4 (-2) (-1) = (2 * â5) * (2 * â5) := by norm_num [discrim, mul_mul_mul_comm]
rcases (quadratic_eq_zero_iff (by norm_num) hd c).mp this with h | h
· field_simp [h]; linarith
· absurd (show 0 †c from cos_nonneg_of_mem_Icc <| by constructor <;> linarith [pi_pos.le])
rw [not_le, h]
exact div_neg_of_neg_of_pos (by norm_num [lt_sqrt]) (by positivity)
end CosDivSq
/-- `Real.sin` as an `OrderIso` between `[-(Ï / 2), Ï / 2]` and `[-1, 1]`. -/
def sinOrderIso : Icc (-(Ï / 2)) (Ï / 2) âo Icc (-1 : â) 1 :=
(strictMonoOn_sin.orderIso _ _).trans <| OrderIso.setCongr _ _ bijOn_sin.image_eq
@[simp]
theorem coe_sinOrderIso_apply (x : Icc (-(Ï / 2)) (Ï / 2)) : (sinOrderIso x : â) = sin x :=
rfl
theorem sinOrderIso_apply (x : Icc (-(Ï / 2)) (Ï / 2)) : sinOrderIso x = âšsin x, sin_mem_Icc xâ© :=
rfl
@[simp]
theorem tan_pi_div_four : tan (Ï / 4) = 1 := by
rw [tan_eq_sin_div_cos, cos_pi_div_four, sin_pi_div_four]
have h : â2 / 2 > 0 := by positivity
exact div_self (ne_of_gt h)
@[simp]
theorem tan_pi_div_two : tan (Ï / 2) = 0 := by simp [tan_eq_sin_div_cos]
@[simp]
theorem tan_pi_div_six : tan (Ï / 6) = 1 / sqrt 3 := by
rw [tan_eq_sin_div_cos, sin_pi_div_six, cos_pi_div_six]
ring
@[simp]
theorem tan_pi_div_three : tan (Ï / 3) = sqrt 3 := by
rw [tan_eq_sin_div_cos, sin_pi_div_three, cos_pi_div_three]
ring
theorem tan_pos_of_pos_of_lt_pi_div_two {x : â} (h0x : 0 < x) (hxp : x < Ï / 2) : 0 < tan x := by
rw [tan_eq_sin_div_cos]
exact div_pos (sin_pos_of_pos_of_lt_pi h0x (by linarith)) (cos_pos_of_mem_Ioo âšby linarith, hxpâ©)
theorem tan_nonneg_of_nonneg_of_le_pi_div_two {x : â} (h0x : 0 †x) (hxp : x â€ Ï / 2) : 0 †tan x :=
match lt_or_eq_of_le h0x, lt_or_eq_of_le hxp with
| Or.inl hx0, Or.inl hxp => le_of_lt (tan_pos_of_pos_of_lt_pi_div_two hx0 hxp)
| Or.inl _, Or.inr hxp => by simp [hxp, tan_eq_sin_div_cos]
| Or.inr hx0, _ => by simp [hx0.symm]
theorem tan_neg_of_neg_of_pi_div_two_lt {x : â} (hx0 : x < 0) (hpx : -(Ï / 2) < x) : tan x < 0 :=
neg_pos.1 (tan_neg x âž tan_pos_of_pos_of_lt_pi_div_two (by linarith) (by linarith [pi_pos]))
theorem tan_nonpos_of_nonpos_of_neg_pi_div_two_le {x : â} (hx0 : x †0) (hpx : -(Ï / 2) †x) :
tan x †0 :=
neg_nonneg.1 (tan_neg x âž tan_nonneg_of_nonneg_of_le_pi_div_two (by linarith) (by linarith))
theorem strictMonoOn_tan : StrictMonoOn tan (Ioo (-(Ï / 2)) (Ï / 2)) := by
rintro x hx y hy hlt
rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos,
div_lt_div_iffâ (cos_pos_of_mem_Ioo hx) (cos_pos_of_mem_Ioo hy), mul_comm, â sub_pos, â sin_sub]
exact sin_pos_of_pos_of_lt_pi (sub_pos.2 hlt) <| by linarith [hx.1, hy.2]
theorem tan_lt_tan_of_lt_of_lt_pi_div_two {x y : â} (hxâ : -(Ï / 2) < x) (hyâ : y < Ï / 2)
(hxy : x < y) : tan x < tan y :=
strictMonoOn_tan âšhxâ, hxy.trans hyââ© âšhxâ.trans hxy, hyââ© hxy
theorem tan_lt_tan_of_nonneg_of_lt_pi_div_two {x y : â} (hxâ : 0 †x) (hyâ : y < Ï / 2)
(hxy : x < y) : tan x < tan y :=
tan_lt_tan_of_lt_of_lt_pi_div_two (by linarith) hyâ hxy
theorem injOn_tan : InjOn tan (Ioo (-(Ï / 2)) (Ï / 2)) :=
strictMonoOn_tan.injOn
theorem tan_inj_of_lt_of_lt_pi_div_two {x y : â} (hxâ : -(Ï / 2) < x) (hxâ : x < Ï / 2)
(hyâ : -(Ï / 2) < y) (hyâ : y < Ï / 2) (hxy : tan x = tan y) : x = y :=
injOn_tan âšhxâ, hxââ© âšhyâ, hyââ© hxy
theorem tan_periodic : Function.Periodic tan Ï := by
simpa only [Function.Periodic, tan_eq_sin_div_cos] using sin_antiperiodic.div cos_antiperiodic
@[simp]
theorem tan_pi : tan Ï = 0 := by rw [tan_periodic.eq, tan_zero]
theorem tan_add_pi (x : â) : tan (x + Ï) = tan x :=
tan_periodic x
theorem tan_sub_pi (x : â) : tan (x - Ï) = tan x :=
tan_periodic.sub_eq x
theorem tan_pi_sub (x : â) : tan (Ï - x) = -tan x :=
tan_neg x âž tan_periodic.sub_eq'
theorem tan_pi_div_two_sub (x : â) : tan (Ï / 2 - x) = (tan x)â»Â¹ := by
rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos, inv_div, sin_pi_div_two_sub, cos_pi_div_two_sub]
theorem tan_nat_mul_pi (n : â) : tan (n * Ï) = 0 :=
tan_zero âž tan_periodic.nat_mul_eq n
theorem tan_int_mul_pi (n : â€) : tan (n * Ï) = 0 :=
tan_zero âž tan_periodic.int_mul_eq n
theorem tan_add_nat_mul_pi (x : â) (n : â) : tan (x + n * Ï) = tan x :=
tan_periodic.nat_mul n x
theorem tan_add_int_mul_pi (x : â) (n : â€) : tan (x + n * Ï) = tan x :=
tan_periodic.int_mul n x
theorem tan_sub_nat_mul_pi (x : â) (n : â) : tan (x - n * Ï) = tan x :=
tan_periodic.sub_nat_mul_eq n
theorem tan_sub_int_mul_pi (x : â) (n : â€) : tan (x - n * Ï) = tan x :=
tan_periodic.sub_int_mul_eq n
theorem tan_nat_mul_pi_sub (x : â) (n : â) : tan (n * Ï - x) = -tan x :=
tan_neg x âž tan_periodic.nat_mul_sub_eq n
theorem tan_int_mul_pi_sub (x : â) (n : â€) : tan (n * Ï - x) = -tan x :=
tan_neg x âž tan_periodic.int_mul_sub_eq n
theorem tendsto_sin_pi_div_two : Tendsto sin (ð[<] (Ï / 2)) (ð 1) := by
convert continuous_sin.continuousWithinAt.tendsto
simp
theorem tendsto_cos_pi_div_two : Tendsto cos (ð[<] (Ï / 2)) (ð[>] 0) := by
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within
· convert continuous_cos.continuousWithinAt.tendsto
simp
· filter_upwards [Ioo_mem_nhdsLT (neg_lt_self pi_div_two_pos)] with x hx
exact cos_pos_of_mem_Ioo hx
theorem tendsto_tan_pi_div_two : Tendsto tan (ð[<] (Ï / 2)) atTop := by
convert tendsto_cos_pi_div_two.inv_tendsto_nhdsGT_zero.atTop_mul_pos zero_lt_one
tendsto_sin_pi_div_two using 1
simp only [Pi.inv_apply, â div_eq_inv_mul, â tan_eq_sin_div_cos]
theorem tendsto_sin_neg_pi_div_two : Tendsto sin (ð[>] (-(Ï / 2))) (ð (-1)) := by
convert continuous_sin.continuousWithinAt.tendsto using 2
simp
theorem tendsto_cos_neg_pi_div_two : Tendsto cos (ð[>] (-(Ï / 2))) (ð[>] 0) := by
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within
· convert continuous_cos.continuousWithinAt.tendsto
simp
· filter_upwards [Ioo_mem_nhdsGT (neg_lt_self pi_div_two_pos)] with x hx
exact cos_pos_of_mem_Ioo hx
theorem tendsto_tan_neg_pi_div_two : Tendsto tan (ð[>] (-(Ï / 2))) atBot := by
convert tendsto_cos_neg_pi_div_two.inv_tendsto_nhdsGT_zero.atTop_mul_neg (by norm_num)
tendsto_sin_neg_pi_div_two using 1
simp only [Pi.inv_apply, â div_eq_inv_mul, â tan_eq_sin_div_cos]
end Real
namespace Complex
open Real
theorem sin_eq_zero_iff_cos_eq {z : â} : sin z = 0 â cos z = 1 âš cos z = -1 := by
rw [â mul_self_eq_one_iff, â sin_sq_add_cos_sq, sq, sq, â sub_eq_iff_eq_add, sub_self]
exact âšfun h => by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero â Eq.symmâ©
@[simp]
theorem cos_pi_div_two : cos (Ï / 2) = 0 :=
calc
cos (Ï / 2) = Real.cos (Ï / 2) := by rw [ofReal_cos]; simp
_ = 0 := by simp
@[simp]
theorem sin_pi_div_two : sin (Ï / 2) = 1 :=
calc
sin (Ï / 2) = Real.sin (Ï / 2) := by rw [ofReal_sin]; simp
_ = 1 := by simp
@[simp]
theorem sin_pi : sin Ï = 0 := by rw [â ofReal_sin, Real.sin_pi]; simp
@[simp]
theorem cos_pi : cos Ï = -1 := by rw [â ofReal_cos, Real.cos_pi]; simp
@[simp]
theorem sin_two_pi : sin (2 * Ï) = 0 := by simp [two_mul, sin_add]
@[simp]
theorem cos_two_pi : cos (2 * Ï) = 1 := by simp [two_mul, cos_add]
theorem sin_antiperiodic : Function.Antiperiodic sin Ï := by simp [sin_add]
theorem sin_periodic : Function.Periodic sin (2 * Ï) :=
sin_antiperiodic.periodic_two_mul
theorem sin_add_pi (x : â) : sin (x + Ï) = -sin x :=
sin_antiperiodic x
theorem sin_add_two_pi (x : â) : sin (x + 2 * Ï) = sin x :=
sin_periodic x
theorem sin_sub_pi (x : â) : sin (x - Ï) = -sin x :=
sin_antiperiodic.sub_eq x
theorem sin_sub_two_pi (x : â) : sin (x - 2 * Ï) = sin x :=
sin_periodic.sub_eq x
theorem sin_pi_sub (x : â) : sin (Ï - x) = sin x :=
neg_neg (sin x) âž sin_neg x âž sin_antiperiodic.sub_eq'
theorem sin_two_pi_sub (x : â) : sin (2 * Ï - x) = -sin x :=
sin_neg x âž sin_periodic.sub_eq'
theorem sin_nat_mul_pi (n : â) : sin (n * Ï) = 0 :=
sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n
theorem sin_int_mul_pi (n : â€) : sin (n * Ï) = 0 :=
sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n
theorem sin_add_nat_mul_two_pi (x : â) (n : â) : sin (x + n * (2 * Ï)) = sin x :=
sin_periodic.nat_mul n x
theorem sin_add_int_mul_two_pi (x : â) (n : â€) : sin (x + n * (2 * Ï)) = sin x :=
sin_periodic.int_mul n x
theorem sin_sub_nat_mul_two_pi (x : â) (n : â) : sin (x - n * (2 * Ï)) = sin x :=
sin_periodic.sub_nat_mul_eq n
theorem sin_sub_int_mul_two_pi (x : â) (n : â€) : sin (x - n * (2 * Ï)) = sin x :=
sin_periodic.sub_int_mul_eq n
theorem sin_nat_mul_two_pi_sub (x : â) (n : â) : sin (n * (2 * Ï) - x) = -sin x :=
sin_neg x âž sin_periodic.nat_mul_sub_eq n
theorem sin_int_mul_two_pi_sub (x : â) (n : â€) : sin (n * (2 * Ï) - x) = -sin x :=
sin_neg x âž sin_periodic.int_mul_sub_eq n
theorem cos_antiperiodic : Function.Antiperiodic cos Ï := by simp [cos_add]
theorem cos_periodic : Function.Periodic cos (2 * Ï) :=
cos_antiperiodic.periodic_two_mul
theorem cos_add_pi (x : â) : cos (x + Ï) = -cos x :=
cos_antiperiodic x
theorem cos_add_two_pi (x : â) : cos (x + 2 * Ï) = cos x :=
cos_periodic x
theorem cos_sub_pi (x : â) : cos (x - Ï) = -cos x :=
cos_antiperiodic.sub_eq x
theorem cos_sub_two_pi (x : â) : cos (x - 2 * Ï) = cos x :=
cos_periodic.sub_eq x
theorem cos_pi_sub (x : â) : cos (Ï - x) = -cos x :=
cos_neg x âž cos_antiperiodic.sub_eq'
theorem cos_two_pi_sub (x : â) : cos (2 * Ï - x) = cos x :=
cos_neg x âž cos_periodic.sub_eq'
theorem cos_nat_mul_two_pi (n : â) : cos (n * (2 * Ï)) = 1 :=
(cos_periodic.nat_mul_eq n).trans cos_zero
theorem cos_int_mul_two_pi (n : â€) : cos (n * (2 * Ï)) = 1 :=
(cos_periodic.int_mul_eq n).trans cos_zero
theorem cos_add_nat_mul_two_pi (x : â) (n : â) : cos (x + n * (2 * Ï)) = cos x :=
cos_periodic.nat_mul n x
theorem cos_add_int_mul_two_pi (x : â) (n : â€) : cos (x + n * (2 * Ï)) = cos x :=
cos_periodic.int_mul n x
theorem cos_sub_nat_mul_two_pi (x : â) (n : â) : cos (x - n * (2 * Ï)) = cos x :=
cos_periodic.sub_nat_mul_eq n
theorem cos_sub_int_mul_two_pi (x : â) (n : â€) : cos (x - n * (2 * Ï)) = cos x :=
cos_periodic.sub_int_mul_eq n
theorem cos_nat_mul_two_pi_sub (x : â) (n : â) : cos (n * (2 * Ï) - x) = cos x :=
cos_neg x âž cos_periodic.nat_mul_sub_eq n
theorem cos_int_mul_two_pi_sub (x : â) (n : â€) : cos (n * (2 * Ï) - x) = cos x :=
cos_neg x âž cos_periodic.int_mul_sub_eq n
theorem cos_nat_mul_two_pi_add_pi (n : â) : cos (n * (2 * Ï) + Ï) = -1 := by
simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic
theorem cos_int_mul_two_pi_add_pi (n : â€) : cos (n * (2 * Ï) + Ï) = -1 := by
simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic
theorem cos_nat_mul_two_pi_sub_pi (n : â) : cos (n * (2 * Ï) - Ï) = -1 := by
simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic
theorem cos_int_mul_two_pi_sub_pi (n : â€) : cos (n * (2 * Ï) - Ï) = -1 := by
simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic
theorem sin_add_pi_div_two (x : â) : sin (x + Ï / 2) = cos x := by simp [sin_add]
theorem sin_sub_pi_div_two (x : â) : sin (x - Ï / 2) = -cos x := by simp [sub_eq_add_neg, sin_add]
theorem sin_pi_div_two_sub (x : â) : sin (Ï / 2 - x) = cos x := by simp [sub_eq_add_neg, sin_add]
theorem cos_add_pi_div_two (x : â) : cos (x + Ï / 2) = -sin x := by simp [cos_add]
theorem cos_sub_pi_div_two (x : â) : cos (x - Ï / 2) = sin x := by simp [sub_eq_add_neg, cos_add]
theorem cos_pi_div_two_sub (x : â) : cos (Ï / 2 - x) = sin x := by
rw [â cos_neg, neg_sub, cos_sub_pi_div_two]
theorem tan_periodic : Function.Periodic tan Ï := by
simpa only [tan_eq_sin_div_cos] using sin_antiperiodic.div cos_antiperiodic
theorem tan_add_pi (x : â) : tan (x + Ï) = tan x :=
tan_periodic x
theorem tan_sub_pi (x : â) : tan (x - Ï) = tan x :=
tan_periodic.sub_eq x
theorem tan_pi_sub (x : â) : tan (Ï - x) = -tan x :=
tan_neg x âž tan_periodic.sub_eq'
theorem tan_pi_div_two_sub (x : â) : tan (Ï / 2 - x) = (tan x)â»Â¹ := by
rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos, inv_div, sin_pi_div_two_sub, cos_pi_div_two_sub]
theorem tan_nat_mul_pi (n : â) : tan (n * Ï) = 0 :=
| tan_zero âž tan_periodic.nat_mul_eq n
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean | 1,150 | 1,150 |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex
/-!
# The `arctan` function.
Inequalities, identities and `Real.tan` as a `PartialHomeomorph` between `(-(Ï / 2), Ï / 2)`
and the whole line.
The result of `arctan x + arctan y` is given by `arctan_add`, `arctan_add_eq_add_pi` or
`arctan_add_eq_sub_pi` depending on whether `x * y < 1` and `0 < x`. As an application of
`arctan_add` we give four Machin-like formulas (linear combinations of arctangents equal to
`Ï / 4 = arctan 1`), including John Machin's original one at
`four_mul_arctan_inv_5_sub_arctan_inv_239`.
-/
noncomputable section
namespace Real
open Set Filter
open scoped Topology Real
theorem tan_add {x y : â}
(h : ((â k : â€, x â (2 * k + 1) * Ï / 2) â§ â l : â€, y â (2 * l + 1) * Ï / 2) âš
(â k : â€, x = (2 * k + 1) * Ï / 2) â§ â l : â€, y = (2 * l + 1) * Ï / 2) :
tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := by
simpa only [â Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div,
Complex.ofReal_mul, Complex.ofReal_tan] using
@Complex.tan_add (x : â) (y : â) (by convert h <;> norm_cast)
theorem tan_add' {x y : â}
(h : (â k : â€, x â (2 * k + 1) * Ï / 2) â§ â l : â€, y â (2 * l + 1) * Ï / 2) :
tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) :=
tan_add (Or.inl h)
theorem tan_two_mul {x : â} : tan (2 * x) = 2 * tan x / (1 - tan x ^ 2) := by
have := @Complex.tan_two_mul x
norm_cast at *
theorem tan_int_mul_pi_div_two (n : â€) : tan (n * Ï / 2) = 0 :=
tan_eq_zero_iff.mpr (by use n)
theorem continuousOn_tan : ContinuousOn tan {x | cos x â 0} := by
suffices ContinuousOn (fun x => sin x / cos x) {x | cos x â 0} by
have h_eq : (fun x => sin x / cos x) = tan := by ext1 x; rw [tan_eq_sin_div_cos]
rwa [h_eq] at this
exact continuousOn_sin.div continuousOn_cos fun x => id
@[continuity]
theorem continuous_tan : Continuous fun x : {x | cos x â 0} => tan x :=
continuousOn_iff_continuous_restrict.1 continuousOn_tan
theorem continuousOn_tan_Ioo : ContinuousOn tan (Ioo (-(Ï / 2)) (Ï / 2)) := by
refine ContinuousOn.mono continuousOn_tan fun x => ?_
simp only [and_imp, mem_Ioo, mem_setOf_eq, Ne]
rw [cos_eq_zero_iff]
rintro hx_gt hx_lt âšr, hxr_eqâ©
rcases le_or_lt 0 r with h | h
· rw [lt_iff_not_ge] at hx_lt
refine hx_lt ?_
| rw [hxr_eq, â one_mul (Ï / 2), mul_div_assoc, ge_iff_le, mul_le_mul_right (half_pos pi_pos)]
simp [h]
· rw [lt_iff_not_ge] at hx_gt
refine hx_gt ?_
rw [hxr_eq, â one_mul (Ï / 2), mul_div_assoc, ge_iff_le, neg_mul_eq_neg_mul,
mul_le_mul_right (half_pos pi_pos)]
have hr_le : r †-1 := by rwa [Int.lt_iff_add_one_le, â le_neg_iff_add_nonpos_right] at h
rw [â le_sub_iff_add_le, mul_comm, â le_div_iffâ]
· norm_num
rw [â Int.cast_one, â Int.cast_neg]; norm_cast
· exact zero_lt_two
theorem surjOn_tan : SurjOn tan (Ioo (-(Ï / 2)) (Ï / 2)) univ :=
have := neg_lt_self pi_div_two_pos
continuousOn_tan_Ioo.surjOn_of_tendsto (nonempty_Ioo.2 this)
(by rw [tendsto_comp_coe_Ioo_atBot this]; exact tendsto_tan_neg_pi_div_two)
(by rw [tendsto_comp_coe_Ioo_atTop this]; exact tendsto_tan_pi_div_two)
theorem tan_surjective : Function.Surjective tan := fun _ => surjOn_tan.subset_range trivial
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean | 68 | 86 |
/-
Copyright (c) 2019 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import Mathlib.MeasureTheory.Integral.Bochner.Basic
import Mathlib.MeasureTheory.Integral.Bochner.L1
import Mathlib.MeasureTheory.Integral.Bochner.VitaliCaratheodory
deprecated_module (since := "2025-04-13")
| Mathlib/MeasureTheory/Integral/Bochner.lean | 1,143 | 1,163 | |
/-
Copyright (c) 2023 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.Algebra.Homology.ExactSequence
import Mathlib.Algebra.Homology.ShortComplex.Limits
import Mathlib.CategoryTheory.Abelian.Refinements
/-!
# The snake lemma
The snake lemma is a standard tool in homological algebra. The basic situation
is when we have a diagram as follows in an abelian category `C`, with exact rows:
Lâ.Xâ â¶ Lâ.Xâ â¶ Lâ.Xâ â¶ 0
| | |
|vââ.Ïâ |vââ.Ïâ |vââ.Ïâ
v v v
0 â¶ Lâ.Xâ â¶ Lâ.Xâ â¶ Lâ.Xâ
We shall think of this diagram as the datum of a morphism `vââ : Lâ â¶ Lâ` in the
category `ShortComplex C` such that both `Lâ` and `Lâ` are exact, and `Lâ.g` is epi
and `Lâ.f` is a mono (which is equivalent to saying that `Lâ.Xâ` is the cokernel
of `Lâ.f` and `Lâ.Xâ` is the kernel of `Lâ.g`). Then, we may introduce the kernels
and cokernels of the vertical maps. In other words, we may introduce short complexes
`Lâ` and `Lâ` that are respectively the kernel and the cokernel of `vââ`. All these
data constitute a `SnakeInput C`.
Given such a `S : SnakeInput C`, we define a connecting homomorphism
`S.ÎŽ : Lâ.Xâ â¶ Lâ.Xâ` and show that it is part of an exact sequence
`Lâ.Xâ â¶ Lâ.Xâ â¶ Lâ.Xâ â¶ Lâ.Xâ â¶ Lâ.Xâ â¶ Lâ.Xâ`. Each of the four exactness
statement is first stated separately as lemmas `Lâ_exact`, `Lâ'_exact`,
`Lâ'_exact` and `Lâ_exact` and the full 6-term exact sequence is stated
as `snake_lemma`. This sequence can even be extended with an extra `0`
on the left (see `mono_Lâ_f`) if `Lâ.Xâ â¶ Lâ.Xâ` is a mono (i.e. `Lâ` is short exact),
and similarly an extra `0` can be added on the right (`epi_Lâ_g`)
if `Lâ.Xâ â¶ Lâ.Xâ` is an epi (i.e. `Lâ` is short exact).
These results were also obtained in the Liquid Tensor Experiment. The code and the proof
here are slightly easier because of the use of the category `ShortComplex C`,
the use of duality (which allows to construct only half of the sequence, and deducing
the other half by arguing in the opposite category), and the use of "refinements"
(see `CategoryTheory.Abelian.Refinements`) instead of a weak form of pseudo-elements.
-/
namespace CategoryTheory
open Category Limits Preadditive
variable (C : Type*) [Category C] [Abelian C]
namespace ShortComplex
/-- A snake input in an abelian category `C` consists of morphisms
of short complexes `Lâ â¶ Lâ â¶ Lâ â¶ Lâ` (which should be visualized vertically) such
that `Lâ` and `Lâ` are respectively the kernel and the cokernel of `Lâ â¶ Lâ`,
`Lâ` and `Lâ` are exact, `Lâ.g` is epi and `Lâ.f` is mono. -/
structure SnakeInput where
/-- the zeroth row -/
Lâ : ShortComplex C
/-- the first row -/
Lâ : ShortComplex C
/-- the second row -/
Lâ : ShortComplex C
/-- the third row -/
Lâ : ShortComplex C
/-- the morphism from the zeroth row to the first row -/
vââ : Lâ â¶ Lâ
/-- the morphism from the first row to the second row -/
vââ : Lâ â¶ Lâ
/-- the morphism from the second row to the third row -/
vââ : Lâ â¶ Lâ
wââ : vââ â« vââ = 0 := by aesop_cat
wââ : vââ â« vââ = 0 := by aesop_cat
/-- `Lâ` is the kernel of `vââ : Lâ â¶ Lâ`. -/
hâ : IsLimit (KernelFork.ofι _ wââ)
/-- `Lâ` is the cokernel of `vââ : Lâ â¶ Lâ`. -/
hâ : IsColimit (CokernelCofork.ofÏ _ wââ)
Lâ_exact : Lâ.Exact
epi_Lâ_g : Epi Lâ.g
Lâ_exact : Lâ.Exact
mono_Lâ_f : Mono Lâ.f
initialize_simps_projections SnakeInput (-hâ, -hâ)
namespace SnakeInput
attribute [reassoc (attr := simp)] wââ wââ
attribute [instance] epi_Lâ_g
attribute [instance] mono_Lâ_f
variable {C}
variable (S : SnakeInput C)
/-- The snake input in the opposite category that is deduced from a snake input. -/
@[simps]
noncomputable def op : SnakeInput Cáµáµ where
Lâ := S.Lâ.op
Lâ := S.Lâ.op
Lâ := S.Lâ.op
Lâ := S.Lâ.op
epi_Lâ_g := by dsimp; infer_instance
mono_Lâ_f := by dsimp; infer_instance
vââ := opMap S.vââ
vââ := opMap S.vââ
vââ := opMap S.vââ
wââ := congr_arg opMap S.wââ
wââ := congr_arg opMap S.wââ
hâ := isLimitForkMapOfIsLimit' (ShortComplex.opEquiv C).functor _
(CokernelCofork.IsColimit.ofÏOp _ _ S.hâ)
hâ := isColimitCoforkMapOfIsColimit' (ShortComplex.opEquiv C).functor _
(KernelFork.IsLimit.ofιOp _ _ S.hâ)
Lâ_exact := S.Lâ_exact.op
Lâ_exact := S.Lâ_exact.op
@[reassoc (attr := simp)] lemma wââ_Ïâ : S.vââ.Ïâ â« S.vââ.Ïâ = 0 := by
rw [â comp_Ïâ, S.wââ, zero_Ïâ]
@[reassoc (attr := simp)] lemma wââ_Ïâ : S.vââ.Ïâ â« S.vââ.Ïâ = 0 := by
rw [â comp_Ïâ, S.wââ, zero_Ïâ]
@[reassoc (attr := simp)] lemma wââ_Ïâ : S.vââ.Ïâ â« S.vââ.Ïâ = 0 := by
rw [â comp_Ïâ, S.wââ, zero_Ïâ]
@[reassoc (attr := simp)] lemma wââ_Ïâ : S.vââ.Ïâ â« S.vââ.Ïâ = 0 := by
rw [â comp_Ïâ, S.wââ, zero_Ïâ]
@[reassoc (attr := simp)] lemma wââ_Ïâ : S.vââ.Ïâ â« S.vââ.Ïâ = 0 := by
rw [â comp_Ïâ, S.wââ, zero_Ïâ]
@[reassoc (attr := simp)] lemma wââ_Ïâ : S.vââ.Ïâ â« S.vââ.Ïâ = 0 := by
rw [â comp_Ïâ, S.wââ, zero_Ïâ]
/-- `Lâ.Xâ` is the kernel of `vââ.Ïâ : Lâ.Xâ â¶ Lâ.Xâ`. -/
noncomputable def hâÏâ : IsLimit (KernelFork.ofι S.vââ.Ïâ S.wââ_Ïâ) :=
isLimitForkMapOfIsLimit' Ïâ S.wââ S.hâ
/-- `Lâ.Xâ` is the kernel of `vââ.Ïâ : Lâ.Xâ â¶ Lâ.Xâ`. -/
noncomputable def hâÏâ : IsLimit (KernelFork.ofι S.vââ.Ïâ S.wââ_Ïâ) :=
isLimitForkMapOfIsLimit' Ïâ S.wââ S.hâ
/-- `Lâ.Xâ` is the kernel of `vââ.Ïâ : Lâ.Xâ â¶ Lâ.Xâ`. -/
noncomputable def hâÏâ : IsLimit (KernelFork.ofι S.vââ.Ïâ S.wââ_Ïâ) :=
isLimitForkMapOfIsLimit' Ïâ S.wââ S.hâ
instance mono_vââ_Ïâ : Mono S.vââ.Ïâ := mono_of_isLimit_fork S.hâÏâ
instance mono_vââ_Ïâ : Mono S.vââ.Ïâ := mono_of_isLimit_fork S.hâÏâ
instance mono_vââ_Ïâ : Mono S.vââ.Ïâ := mono_of_isLimit_fork S.hâÏâ
/-- The upper part of the first column of the snake diagram is exact. -/
lemma exact_Câ_up : (ShortComplex.mk S.vââ.Ïâ S.vââ.Ïâ
(by rw [â comp_Ïâ, S.wââ, zero_Ïâ])).Exact :=
exact_of_f_is_kernel _ S.hâÏâ
/-- The upper part of the second column of the snake diagram is exact. -/
lemma exact_Câ_up : (ShortComplex.mk S.vââ.Ïâ S.vââ.Ïâ
(by rw [â comp_Ïâ, S.wââ, zero_Ïâ])).Exact :=
exact_of_f_is_kernel _ S.hâÏâ
/-- The upper part of the third column of the snake diagram is exact. -/
lemma exact_Câ_up : (ShortComplex.mk S.vââ.Ïâ S.vââ.Ïâ
(by rw [â comp_Ïâ, S.wââ, zero_Ïâ])).Exact :=
exact_of_f_is_kernel _ S.hâÏâ
instance mono_Lâ_f [Mono S.Lâ.f] : Mono S.Lâ.f := by
have : Mono (S.Lâ.f â« S.vââ.Ïâ) := by
rw [â S.vââ.commââ]
apply mono_comp
exact mono_of_mono _ S.vââ.Ïâ
/-- `Lâ.Xâ` is the cokernel of `vââ.Ïâ : Lâ.Xâ â¶ Lâ.Xâ`. -/
noncomputable def hâÏâ : IsColimit (CokernelCofork.ofÏ S.vââ.Ïâ S.wââ_Ïâ) :=
isColimitCoforkMapOfIsColimit' Ïâ S.wââ S.hâ
/-- `Lâ.Xâ` is the cokernel of `vââ.Ïâ : Lâ.Xâ â¶ Lâ.Xâ`. -/
noncomputable def hâÏâ : IsColimit (CokernelCofork.ofÏ S.vââ.Ïâ S.wââ_Ïâ) :=
isColimitCoforkMapOfIsColimit' Ïâ S.wââ S.hâ
/-- `Lâ.Xâ` is the cokernel of `vââ.Ïâ : Lâ.Xâ â¶ Lâ.Xâ`. -/
noncomputable def hâÏâ : IsColimit (CokernelCofork.ofÏ S.vââ.Ïâ S.wââ_Ïâ) :=
isColimitCoforkMapOfIsColimit' Ïâ S.wââ S.hâ
instance epi_vââ_Ïâ : Epi S.vââ.Ïâ := epi_of_isColimit_cofork S.hâÏâ
instance epi_vââ_Ïâ : Epi S.vââ.Ïâ := epi_of_isColimit_cofork S.hâÏâ
instance epi_vââ_Ïâ : Epi S.vââ.Ïâ := epi_of_isColimit_cofork S.hâÏâ
/-- The lower part of the first column of the snake diagram is exact. -/
lemma exact_Câ_down : (ShortComplex.mk S.vââ.Ïâ S.vââ.Ïâ
(by rw [â comp_Ïâ, S.wââ, zero_Ïâ])).Exact :=
exact_of_g_is_cokernel _ S.hâÏâ
/-- The lower part of the second column of the snake diagram is exact. -/
lemma exact_Câ_down : (ShortComplex.mk S.vââ.Ïâ S.vââ.Ïâ
(by rw [â comp_Ïâ, S.wââ, zero_Ïâ])).Exact :=
exact_of_g_is_cokernel _ S.hâÏâ
/-- The lower part of the third column of the snake diagram is exact. -/
lemma exact_Câ_down : (ShortComplex.mk S.vââ.Ïâ S.vââ.Ïâ
(by rw [â comp_Ïâ, S.wââ, zero_Ïâ])).Exact :=
exact_of_g_is_cokernel _ S.hâÏâ
instance epi_Lâ_g [Epi S.Lâ.g] : Epi S.Lâ.g := by
have : Epi (S.vââ.Ïâ â« S.Lâ.g) := by
rw [S.vââ.commââ]
apply epi_comp
exact epi_of_epi S.vââ.Ïâ _
lemma Lâ_exact : S.Lâ.Exact := by
rw [ShortComplex.exact_iff_exact_up_to_refinements]
intro A xâ hxâ
obtain âšAâ, Ïâ, hÏâ, yâ, hyââ© := S.Lâ_exact.exact_up_to_refinements (xâ â« S.vââ.Ïâ)
(by rw [assoc, S.vââ.commââ, reassoc_of% hxâ, zero_comp])
have hyâ' : yâ â« S.vââ.Ïâ = 0 := by
simp only [â cancel_mono S.Lâ.f, assoc, zero_comp, S.vââ.commââ,
â reassoc_of% hyâ, wââ_Ïâ, comp_zero]
obtain âšxâ, hxââ© : â xâ, xâ â« S.vââ.Ïâ = yâ := âš_, S.exact_Câ_up.lift_f yâ hyâ'â©
refine âšAâ, Ïâ, hÏâ, xâ, ?_â©
simp only [â cancel_mono S.vââ.Ïâ, assoc, â S.vââ.commââ, reassoc_of% hxâ, hyâ]
lemma Lâ_exact : S.Lâ.Exact := S.op.Lâ_exact.unop
/-- The fiber product of `Lâ.Xâ` and `Lâ.Xâ` over `Lâ.Xâ`. This is an auxiliary
object in the construction of the morphism `ÎŽ : Lâ.Xâ â¶ Lâ.Xâ`. -/
noncomputable def P := pullback S.Lâ.g S.vââ.Ïâ
/-- The canonical map `P â¶ Lâ.Xâ`. -/
noncomputable def Ïâ : S.P â¶ S.Lâ.Xâ := pullback.fst _ _ â« S.vââ.Ïâ
@[reassoc (attr := simp)]
lemma lift_Ïâ {A : C} (a : A â¶ S.Lâ.Xâ) (b : A â¶ S.Lâ.Xâ) (h : a â« S.Lâ.g = b â« S.vââ.Ïâ) :
pullback.lift a b h â« S.Ïâ = a â« S.vââ.Ïâ := by
simp [Ïâ]
/-- The canonical map `P â¶ Lâ.Xâ`. -/
noncomputable def Ïâ : S.P â¶ S.Lâ.Xâ :=
S.Lâ_exact.lift S.Ïâ
(by simp only [Ïâ, assoc, S.vââ.commââ, pullback.condition_assoc, wââ_Ïâ, comp_zero])
@[reassoc (attr := simp)] lemma Ïâ_Lâ_f : S.Ïâ â« S.Lâ.f = S.Ïâ := S.Lâ_exact.lift_f _ _
/-- The short complex that is part of an exact sequence `Lâ.Xâ â¶ P â¶ Lâ.Xâ â¶ 0`. -/
noncomputable def Lâ' : ShortComplex C where
Xâ := S.Lâ.Xâ
Xâ := S.P
Xâ := S.Lâ.Xâ
f := pullback.lift S.Lâ.f 0 (by simp)
g := pullback.snd _ _
zero := by simp
@[reassoc (attr := simp)] lemma Lâ_f_Ïâ : S.Lâ'.f â« S.Ïâ = S.vââ.Ïâ := by
dsimp only [Lâ']
simp only [â cancel_mono S.Lâ.f, assoc, Ïâ_Lâ_f, Ïâ, pullback.lift_fst_assoc,
S.vââ.commââ]
instance : Epi S.Lâ'.g := by dsimp only [Lâ']; infer_instance
instance [Mono S.Lâ.f] : Mono S.Lâ'.f :=
mono_of_mono_fac (show S.Lâ'.f â« pullback.fst _ _ = S.Lâ.f by simp [Lâ'])
lemma Lâ'_exact : S.Lâ'.Exact := by
rw [ShortComplex.exact_iff_exact_up_to_refinements]
intro A xâ hxâ
dsimp [Lâ'] at xâ hxâ
obtain âšA', Ï, hÏ, xâ, facâ© := S.Lâ_exact.exact_up_to_refinements (xâ â« pullback.fst _ _)
(by rw [assoc, pullback.condition, reassoc_of% hxâ, zero_comp])
exact âšA', Ï, hÏ, xâ, pullback.hom_ext (by simpa [Lâ'] using fac) (by simp [Lâ', hxâ])â©
/-- The connecting homomorphism `ÎŽ : Lâ.Xâ â¶ Lâ.Xâ`. -/
noncomputable def ÎŽ : S.Lâ.Xâ â¶ S.Lâ.Xâ :=
S.Lâ'_exact.desc (S.Ïâ â« S.vââ.Ïâ) (by simp only [Lâ_f_Ïâ_assoc, wââ_Ïâ])
@[reassoc (attr := simp)]
lemma snd_ÎŽ : (pullback.snd _ _ : S.P â¶ _) â« S.ÎŽ = S.Ïâ â« S.vââ.Ïâ :=
S.Lâ'_exact.g_desc _ _
/-- The pushout of `Lâ.Xâ` and `Lâ.Xâ` along `Lâ.Xâ`. -/
noncomputable def P' := pushout S.Lâ.f S.vââ.Ïâ
lemma snd_ÎŽ_inr : (pullback.snd _ _ : S.P â¶ _) â« S.ÎŽ â« (pushout.inr _ _ : _ â¶ S.P') =
pullback.fst _ _ â« S.vââ.Ïâ â« pushout.inl _ _ := by
simp only [snd_ÎŽ_assoc, â pushout.condition, Ïâ, Ïâ_Lâ_f_assoc, assoc]
/-- The canonical morphism `Lâ.Xâ â¶ P`. -/
@[simp]
noncomputable def LâXâToP : S.Lâ.Xâ â¶ S.P := pullback.lift S.vââ.Ïâ S.Lâ.g S.vââ.commââ
@[reassoc]
lemma LâXâToP_comp_pullback_snd : S.LâXâToP â« pullback.snd _ _ = S.Lâ.g := by simp
@[reassoc]
lemma LâXâToP_comp_Ïâ : S.LâXâToP â« S.Ïâ = 0 := by
simp only [â cancel_mono S.Lâ.f, LâXâToP, assoc, Ïâ, Ïâ_Lâ_f,
pullback.lift_fst_assoc, wââ_Ïâ, zero_comp]
| lemma Lâ_g_ÎŽ : S.Lâ.g â« S.ÎŽ = 0 := by
rw [â LâXâToP_comp_pullback_snd, assoc]
erw [S.Lâ'_exact.g_desc]
| Mathlib/Algebra/Homology/ShortComplex/SnakeLemma.lean | 292 | 294 |
/-
Copyright (c) 2024 Christian Merten. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christian Merten
-/
import Mathlib.CategoryTheory.Limits.Constructions.LimitsOfProductsAndEqualizers
import Mathlib.CategoryTheory.Limits.FintypeCat
import Mathlib.CategoryTheory.Limits.MonoCoprod
import Mathlib.CategoryTheory.Limits.Shapes.ConcreteCategory
import Mathlib.CategoryTheory.Limits.Shapes.Diagonal
import Mathlib.CategoryTheory.SingleObj
import Mathlib.Data.Finite.Card
import Mathlib.Algebra.Equiv.TransferInstance
/-!
# Definition and basic properties of Galois categories
We define the notion of a Galois category and a fiber functor as in SGA1, following
the definitions in Lenstras notes (see below for a reference).
## Main definitions
* `PreGaloisCategory` : defining properties of Galois categories not involving a fiber functor
* `FiberFunctor` : a fiber functor from a `PreGaloisCategory` to `FintypeCat`
* `GaloisCategory` : a `PreGaloisCategory` that admits a `FiberFunctor`
* `IsConnected` : an object of a category is connected if it is not initial
and does not have non-trivial subobjects
## Implementation details
We mostly follow Def 3.1 in Lenstras notes. In axiom (G3)
we omit the factorisation of morphisms in epimorphisms and monomorphisms
as this is not needed for the proof of the fundamental theorem on Galois categories
(and then follows from it).
## References
* [lenstraGSchemes]: H. W. Lenstra. Galois theory for schemes.
-/
universe uâ uâ vâ vâ w t
namespace CategoryTheory
open Limits Functor
/-!
A category `C` is a PreGalois category if it satisfies all properties
of a Galois category in the sense of SGA1 that do not involve a fiber functor.
A Galois category should furthermore admit a fiber functor.
The only difference between `[PreGaloisCategory C] (F : C ⥀ FintypeCat) [FiberFunctor F]` and
`[GaloisCategory C]` is that the former fixes one fiber functor `F`.
-/
/-- Definition of a (Pre)Galois category. Lenstra, Def 3.1, (G1)-(G3) -/
class PreGaloisCategory (C : Type uâ) [Category.{uâ, uâ} C] : Prop where
/-- `C` has a terminal object (G1). -/
hasTerminal : HasTerminal C := by infer_instance
/-- `C` has pullbacks (G1). -/
hasPullbacks : HasPullbacks C := by infer_instance
/-- `C` has finite coproducts (G2). -/
hasFiniteCoproducts : HasFiniteCoproducts C := by infer_instance
/-- `C` has quotients by finite groups (G2). -/
hasQuotientsByFiniteGroups (G : Type uâ) [Group G] [Finite G] :
HasColimitsOfShape (SingleObj G) C := by infer_instance
/-- Every monomorphism in `C` induces an isomorphism on a direct summand (G3). -/
monoInducesIsoOnDirectSummand {X Y : C} (i : X â¶ Y) [Mono i] : â (Z : C) (u : Z â¶ Y),
Nonempty (IsColimit (BinaryCofan.mk i u))
namespace PreGaloisCategory
/-- Definition of a fiber functor from a Galois category. Lenstra, Def 3.1, (G4)-(G6) -/
class FiberFunctor {C : Type uâ} [Category.{uâ, uâ} C] [PreGaloisCategory C]
(F : C ⥀ FintypeCat.{w}) where
/-- `F` preserves terminal objects (G4). -/
preservesTerminalObjects : PreservesLimitsOfShape (CategoryTheory.Discrete PEmpty.{1}) F := by
infer_instance
/-- `F` preserves pullbacks (G4). -/
preservesPullbacks : PreservesLimitsOfShape WalkingCospan F := by infer_instance
/-- `F` preserves finite coproducts (G5). -/
preservesFiniteCoproducts : PreservesFiniteCoproducts F := by infer_instance
/-- `F` preserves epimorphisms (G5). -/
preservesEpis : Functor.PreservesEpimorphisms F := by infer_instance
/-- `F` preserves quotients by finite groups (G5). -/
preservesQuotientsByFiniteGroups (G : Type uâ) [Group G] [Finite G] :
PreservesColimitsOfShape (SingleObj G) F := by infer_instance
/-- `F` reflects isomorphisms (G6). -/
reflectsIsos : F.ReflectsIsomorphisms := by infer_instance
/-- An object of a category `C` is connected if it is not initial
and has no non-trivial subobjects. Lenstra, 3.12. -/
class IsConnected {C : Type uâ} [Category.{uâ, uâ} C] (X : C) : Prop where
/-- `X` is not an initial object. -/
notInitial : IsInitial X â False
/-- `X` has no non-trivial subobjects. -/
noTrivialComponent (Y : C) (i : Y â¶ X) [Mono i] : (IsInitial Y â False) â IsIso i
/-- A functor is said to preserve connectedness if whenever `X : C` is connected,
also `F.obj X` is connected. -/
class PreservesIsConnected {C : Type uâ} [Category.{uâ, uâ} C] {D : Type vâ}
[Category.{vâ, vâ} D] (F : C ⥀ D) : Prop where
/-- `F.obj X` is connected if `X` is connected. -/
preserves : â {X : C} [IsConnected X], IsConnected (F.obj X)
section
variable {C : Type uâ} [Category.{uâ, uâ} C] [PreGaloisCategory C]
attribute [instance] hasTerminal hasPullbacks hasFiniteCoproducts hasQuotientsByFiniteGroups
instance : HasFiniteLimits C := hasFiniteLimits_of_hasTerminal_and_pullbacks
instance : HasBinaryProducts C := hasBinaryProducts_of_hasTerminal_and_pullbacks C
instance : HasEqualizers C := hasEqualizers_of_hasPullbacks_and_binary_products
-- A `PreGaloisCategory` has quotients by finite groups in arbitrary universes. -/
instance {G : Type*} [Group G] [Finite G] : HasColimitsOfShape (SingleObj G) C := by
obtain âšG', hg, hf, âšeâ©â© := Finite.exists_type_univ_nonempty_mulEquiv G
exact Limits.hasColimitsOfShape_of_equivalence e.toSingleObjEquiv.symm
end
namespace FiberFunctor
variable {C : Type uâ} [Category.{uâ, uâ} C] {F : C ⥀ FintypeCat.{w}} [PreGaloisCategory C]
[FiberFunctor F]
attribute [instance] preservesTerminalObjects preservesPullbacks preservesEpis
preservesFiniteCoproducts reflectsIsos preservesQuotientsByFiniteGroups
noncomputable instance : ReflectsLimitsOfShape (Discrete PEmpty.{1}) F :=
reflectsLimitsOfShape_of_reflectsIsomorphisms
noncomputable instance : ReflectsColimitsOfShape (Discrete PEmpty.{1}) F :=
reflectsColimitsOfShape_of_reflectsIsomorphisms
noncomputable instance : PreservesFiniteLimits F :=
preservesFiniteLimits_of_preservesTerminal_and_pullbacks F
/-- Fiber functors preserve quotients by finite groups in arbitrary universes. -/
instance {G : Type*} [Group G] [Finite G] :
PreservesColimitsOfShape (SingleObj G) F := by
choose G' hg hf he using Finite.exists_type_univ_nonempty_mulEquiv G
exact Limits.preservesColimitsOfShape_of_equiv he.some.toSingleObjEquiv.symm F
/-- Fiber functors reflect monomorphisms. -/
instance : ReflectsMonomorphisms F := ReflectsMonomorphisms.mk <| by
intro X Y f _
haveI : IsIso (pullback.fst (F.map f) (F.map f)) :=
isIso_fst_of_mono (F.map f)
haveI : IsIso (F.map (pullback.fst f f)) := by
rw [â PreservesPullback.iso_hom_fst]
exact IsIso.comp_isIso
haveI : IsIso (pullback.fst f f) := isIso_of_reflects_iso (pullback.fst _ _) F
exact (pullback.diagonal_isKernelPair f).mono_of_isIso_fst
/-- Fiber functors are faithful. -/
instance : F.Faithful where
map_injective {X Y} f g h := by
haveI : IsIso (equalizer.ι (F.map f) (F.map g)) := equalizer.ι_of_eq h
haveI : IsIso (F.map (equalizer.ι f g)) := by
rw [â equalizerComparison_comp_Ï f g F]
exact IsIso.comp_isIso
haveI : IsIso (equalizer.ι f g) := isIso_of_reflects_iso _ F
exact eq_of_epi_equalizer
section
/-- If `F` is a fiber functor and `E` is an equivalence between categories of finite types,
then `F â E` is again a fiber functor. -/
lemma comp_right (E : FintypeCat.{w} ⥀ FintypeCat.{t}) [E.IsEquivalence] :
FiberFunctor (F â E) where
preservesQuotientsByFiniteGroups _ := comp_preservesColimitsOfShape F E
end
end FiberFunctor
variable {C : Type uâ} [Category.{uâ, uâ} C]
(F : C ⥀ FintypeCat.{w})
/-- The canonical action of `Aut F` on the fiber of each object. -/
instance (X : C) : MulAction (Aut F) (F.obj X) where
smul Ï x := Ï.hom.app X x
one_smul _ := rfl
mul_smul _ _ _ := rfl
lemma mulAction_def {X : C} (Ï : Aut F) (x : F.obj X) :
Ï â¢ x = Ï.hom.app X x :=
rfl
lemma mulAction_naturality {X Y : C} (Ï : Aut F) (f : X â¶ Y) (x : F.obj X) :
Ï â¢ F.map f x = F.map f (Ï â¢ x) :=
FunctorToFintypeCat.naturality F F Ï.hom f x
/-- An object that is neither initial or connected has a non-trivial subobject. -/
lemma has_non_trivial_subobject_of_not_isConnected_of_not_initial (X : C) (hc : ¬ IsConnected X)
(hi : IsInitial X â False) :
â (Y : C) (v : Y â¶ X), (IsInitial Y â False) â§ Mono v â§ (¬ IsIso v) := by
contrapose! hc
exact âšhi, fun Y i hm hni ⊠hc Y i hni hmâ©
/-- The cardinality of the fiber is preserved under isomorphisms. -/
lemma card_fiber_eq_of_iso {X Y : C} (i : X â
Y) : Nat.card (F.obj X) = Nat.card (F.obj Y) := by
have e : F.obj X â F.obj Y := Iso.toEquiv (mapIso (F â FintypeCat.incl) i)
exact Nat.card_eq_of_bijective e (Equiv.bijective e)
variable [PreGaloisCategory C] [FiberFunctor F]
/-- An object is initial if and only if its fiber is empty. -/
lemma initial_iff_fiber_empty (X : C) : Nonempty (IsInitial X) â IsEmpty (F.obj X) := by
rw [(IsInitial.isInitialIffObj F X).nonempty_congr]
haveI : PreservesFiniteColimits (forget FintypeCat) := by
show PreservesFiniteColimits FintypeCat.incl
infer_instance
haveI : ReflectsColimit (Functor.empty.{0} _) (forget FintypeCat) := by
show ReflectsColimit (Functor.empty.{0} _) FintypeCat.incl
infer_instance
exact Concrete.initial_iff_empty_of_preserves_of_reflects (F.obj X)
/-- An object is not initial if and only if its fiber is nonempty. -/
lemma not_initial_iff_fiber_nonempty (X : C) : (IsInitial X â False) â Nonempty (F.obj X) := by
rw [â not_isEmpty_iff]
refine âšfun h he ⊠?_, fun h hin ⊠h <| (initial_iff_fiber_empty F X).mp âšhinâ©â©
exact Nonempty.elim ((initial_iff_fiber_empty F X).mpr he) h
/-- An object whose fiber is inhabited is not initial. -/
lemma not_initial_of_inhabited {X : C} (x : F.obj X) (h : IsInitial X) : False :=
((initial_iff_fiber_empty F X).mp âšhâ©).false x
/-- The fiber of a connected object is nonempty. -/
instance nonempty_fiber_of_isConnected (X : C) [IsConnected X] : Nonempty (F.obj X) := by
by_contra h
have âšhinâ© : Nonempty (IsInitial X) := (initial_iff_fiber_empty F X).mpr (not_nonempty_iff.mp h)
exact IsConnected.notInitial hin
/-- The fiber of the equalizer of `f g : X â¶ Y` is equivalent to the set of agreement of `f`
and `g`. -/
noncomputable def fiberEqualizerEquiv {X Y : C} (f g : X â¶ Y) :
F.obj (equalizer f g) â { x : F.obj X // F.map f x = F.map g x } :=
(PreservesEqualizer.iso (F â FintypeCat.incl) f g âªâ«
Types.equalizerIso (F.map f) (F.map g)).toEquiv
@[simp]
lemma fiberEqualizerEquiv_symm_ι_apply {X Y : C} {f g : X ⶠY} (x : F.obj X)
(h : F.map f x = F.map g x) :
F.map (equalizer.ι f g) ((fiberEqualizerEquiv F f g).symm âšx, hâ©) = x := by
simp [fiberEqualizerEquiv]
change ((Types.equalizerIso _ _).inv â« _ â« (F â FintypeCat.incl).map (equalizer.ι f g)) _ = _
erw [PreservesEqualizer.iso_inv_ι, Types.equalizerIso_inv_comp_ι]
/-- The fiber of the pullback is the fiber product of the fibers. -/
noncomputable def fiberPullbackEquiv {X A B : C} (f : A â¶ X) (g : B â¶ X) :
F.obj (pullback f g) â { p : F.obj A Ã F.obj B // F.map f p.1 = F.map g p.2 } :=
(PreservesPullback.iso (F â FintypeCat.incl) f g âªâ«
Types.pullbackIsoPullback (F.map f) (F.map g)).toEquiv
@[simp]
lemma fiberPullbackEquiv_symm_fst_apply {X A B : C} {f : A â¶ X} {g : B â¶ X}
(a : F.obj A) (b : F.obj B) (h : F.map f a = F.map g b) :
F.map (pullback.fst f g) ((fiberPullbackEquiv F f g).symm âš(a, b), hâ©) = a := by
simp [fiberPullbackEquiv]
change ((Types.pullbackIsoPullback _ _).inv â« _ â«
(F â FintypeCat.incl).map (pullback.fst f g)) _ = _
erw [PreservesPullback.iso_inv_fst, Types.pullbackIsoPullback_inv_fst]
@[simp]
lemma fiberPullbackEquiv_symm_snd_apply {X A B : C} {f : A â¶ X} {g : B â¶ X}
(a : F.obj A) (b : F.obj B) (h : F.map f a = F.map g b) :
F.map (pullback.snd f g) ((fiberPullbackEquiv F f g).symm âš(a, b), hâ©) = b := by
simp [fiberPullbackEquiv]
change ((Types.pullbackIsoPullback _ _).inv â« _ â«
(F â FintypeCat.incl).map (pullback.snd f g)) _ = _
erw [PreservesPullback.iso_inv_snd, Types.pullbackIsoPullback_inv_snd]
/-- The fiber of the binary product is the binary product of the fibers. -/
noncomputable def fiberBinaryProductEquiv (X Y : C) :
F.obj (X ⚯ Y) â F.obj X à F.obj Y :=
(PreservesLimitPair.iso (F â FintypeCat.incl) X Y âªâ«
Types.binaryProductIso (F.obj X) (F.obj Y)).toEquiv
@[simp]
lemma fiberBinaryProductEquiv_symm_fst_apply {X Y : C} (x : F.obj X) (y : F.obj Y) :
F.map prod.fst ((fiberBinaryProductEquiv F X Y).symm (x, y)) = x := by
simp only [fiberBinaryProductEquiv, comp_obj, FintypeCat.incl_obj, Iso.toEquiv_comp,
Equiv.symm_trans_apply, Iso.toEquiv_symm_fun]
change ((Types.binaryProductIso _ _).inv â« _ â« (F â FintypeCat.incl).map prod.fst) _ = _
erw [PreservesLimitPair.iso_inv_fst, Types.binaryProductIso_inv_comp_fst]
@[simp]
| lemma fiberBinaryProductEquiv_symm_snd_apply {X Y : C} (x : F.obj X) (y : F.obj Y) :
F.map prod.snd ((fiberBinaryProductEquiv F X Y).symm (x, y)) = y := by
simp only [fiberBinaryProductEquiv, comp_obj, FintypeCat.incl_obj, Iso.toEquiv_comp,
Equiv.symm_trans_apply, Iso.toEquiv_symm_fun]
change ((Types.binaryProductIso _ _).inv â« _ â« (F â FintypeCat.incl).map prod.snd) _ = _
| Mathlib/CategoryTheory/Galois/Basic.lean | 293 | 297 |
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Kim Morrison, Adam Topaz
-/
import Mathlib.Topology.Sheaves.SheafOfFunctions
import Mathlib.Topology.Sheaves.Stalks
import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing
/-!
# Functions satisfying a local predicate form a sheaf.
At this stage, in `Mathlib/Topology/Sheaves/SheafOfFunctions.lean`
we've proved that not-necessarily-continuous functions from a topological space
into some type (or type family) form a sheaf.
Why do the continuous functions form a sheaf?
The point is just that continuity is a local condition,
so one can use the lifting condition for functions to provide a candidate lift,
then verify that the lift is actually continuous by using the factorisation condition for the lift
(which guarantees that on each open set it agrees with the functions being lifted,
which were assumed to be continuous).
This file abstracts this argument to work for
any collection of dependent functions on a topological space
satisfying a "local predicate".
As an application, we check that continuity is a local predicate in this sense, and provide
* `TopCat.sheafToTop`: continuous functions into a topological space form a sheaf
A sheaf constructed in this way has a natural map `stalkToFiber` from the stalks
to the types in the ambient type family.
We give conditions sufficient to show that this map is injective and/or surjective.
-/
noncomputable section
variable {X : TopCat}
variable (T : X â Type*)
open TopologicalSpace
open Opposite
open CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.Limits.Types
namespace TopCat
/-- Given a topological space `X : TopCat` and a type family `T : X â Type`,
a `P : PrelocalPredicate T` consists of:
* a family of predicates `P.pred`, one for each `U : Opens X`, of the form `(Î x : U, T x) â Prop`
* a proof that if `f : Î x : V, T x` satisfies the predicate on `V : Opens X`, then
the restriction of `f` to any open subset `U` also satisfies the predicate.
-/
structure PrelocalPredicate where
/-- The underlying predicate of a prelocal predicate -/
pred : â {U : Opens X}, (â x : U, T x) â Prop
/-- The underlying predicate should be invariant under restriction -/
res : â {U V : Opens X} (i : U â¶ V) (f : â x : V, T x) (_ : pred f), pred fun x : U ⊠f (i x)
variable (X)
/-- Continuity is a "prelocal" predicate on functions to a fixed topological space `T`.
-/
@[simps!]
def continuousPrelocal (T) [TopologicalSpace T] : PrelocalPredicate fun _ : X ⊠T where
pred {_} f := Continuous f
res {_ _} i _ h := Continuous.comp h (Opens.isOpenEmbedding_of_le i.le).continuous
/-- Satisfying the inhabited linter. -/
instance inhabitedPrelocalPredicate (T) [TopologicalSpace T] :
Inhabited (PrelocalPredicate fun _ : X ⊠T) :=
âšcontinuousPrelocal X Tâ©
variable {X} in
/-- Given a topological space `X : TopCat` and a type family `T : X â Type`,
a `P : LocalPredicate T` consists of:
* a family of predicates `P.pred`, one for each `U : Opens X`, of the form `(Î x : U, T x) â Prop`
* a proof that if `f : Î x : V, T x` satisfies the predicate on `V : Opens X`, then
the restriction of `f` to any open subset `U` also satisfies the predicate, and
* a proof that given some `f : Î x : U, T x`,
if for every `x : U` we can find an open set `x â V †U`
so that the restriction of `f` to `V` satisfies the predicate,
then `f` itself satisfies the predicate.
-/
structure LocalPredicate extends PrelocalPredicate T where
/-- A local predicate must be local --- provided that it is locally satisfied, it is also globally
satisfied -/
locality :
â {U : Opens X} (f : â x : U, T x)
(_ : â x : U, â (V : Opens X) (_ : x.1 â V) (i : V â¶ U),
pred fun x : V ⊠f (i x : U)), pred f
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T) [TopologicalSpace T] : LocalPredicate fun _ : X ⊠T :=
{ continuousPrelocal X T with
locality := fun {U} f w ⊠by
apply continuous_iff_continuousAt.2
intro x
specialize w x
rcases w with âšV, m, i, wâ©
dsimp at w
rw [continuous_iff_continuousAt] at w
specialize w âšx, mâ©
simpa using (Opens.isOpenEmbedding_of_le i.le).continuousAt_iff.1 w }
/-- Satisfying the inhabited linter. -/
instance inhabitedLocalPredicate (T) [TopologicalSpace T] :
Inhabited (LocalPredicate fun _ : X ⊠T) :=
âšcontinuousLocal X Tâ©
variable {X T}
/-- The conjunction of two prelocal predicates is prelocal. -/
def PrelocalPredicate.and (P Q : PrelocalPredicate T) : PrelocalPredicate T where
pred f := P.pred f â§ Q.pred f
res i f h := âšP.res i f h.1, Q.res i f h.2â©
/-- The conjunction of two prelocal predicates is prelocal. -/
def LocalPredicate.and (P Q : LocalPredicate T) : LocalPredicate T where
__ := P.1.and Q.1
locality f w := by
refine âšP.locality f ?_, Q.locality f ?_â© <;>
(intro x; have âšV, hV, i, hâ© := w x; use V, hV, i)
exacts [h.1, h.2]
/-- The local predicate of being a partial section of a function. -/
def isSection {T} (p : T â X) : LocalPredicate fun _ : X ⊠T where
pred f := p â f = (â)
res _ _ h := funext fun _ ⊠congr_fun h _
locality _ w := funext fun x ⊠have âš_, hV, _, hâ© := w x; congr_fun h âšx, hVâ©
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X â Type*} (P : PrelocalPredicate T) : LocalPredicate T where
pred {U} f := â x : U, â (V : Opens X) (_ : x.1 â V) (i : V â¶ U), P.pred fun x : V ⊠f (i x : U)
res {V U} i f w x := by
specialize w (i x)
rcases w with âšV', m', i', pâ©
exact âšV â V', âšx.2, m'â©, V.infLELeft _, P.res (V.infLERight V') _ pâ©
locality {U} f w x := by
specialize w x
rcases w with âšV, m, i, pâ©
specialize p âšx.1, mâ©
rcases p with âšV', m', i', p'â©
exact âšV', m', i' â« i, p'â©
theorem PrelocalPredicate.sheafifyOf {T : X â Type*} {P : PrelocalPredicate T} {U : Opens X}
{f : â x : U, T x} (h : P.pred f) : P.sheafify.pred f := fun x âŠ
âšU, x.2, ð _, by convert hâ©
|
/-- The subpresheaf of dependent functions on `X` satisfying the "pre-local" predicate `P`.
-/
| Mathlib/Topology/Sheaves/LocalPredicate.lean | 158 | 160 |
/-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear
import Mathlib.Analysis.NormedSpace.OperatorNorm.NNNorm
/-!
# Operators on complete normed spaces
This file contains statements about norms of operators on complete normed spaces, such as a
version of the Banach-Alaoglu theorem (`ContinuousLinearMap.isCompact_image_coe_closedBall`).
-/
suppress_compilation
open Bornology Metric Set Real
open Filter hiding map_smul
open scoped NNReal Topology Uniformity
-- the `â` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {ð ðâ E F Fâ : Type*}
variable [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup Fâ]
variable [NontriviallyNormedField ð] [NontriviallyNormedField ðâ]
[NormedSpace ð E] [NormedSpace ðâ F] [NormedSpace ð Fâ]
{Ïââ : ð â+* ðâ} (f g : E âSL[Ïââ] F)
namespace ContinuousLinearMap
section Completeness
variable {E' : Type*} [SeminormedAddCommGroup E'] [NormedSpace ð E'] [RingHomIsometric Ïââ]
/-- Construct a bundled continuous (semi)linear map from a map `f : E â F` and a proof of the fact
that it belongs to the closure of the image of a bounded set `s : Set (E âSL[Ïââ] F)` under coercion
to function. Coercion to function of the result is definitionally equal to `f`. -/
@[simps! -fullyApplied apply]
def ofMemClosureImageCoeBounded (f : E' â F) {s : Set (E' âSL[Ïââ] F)} (hs : IsBounded s)
(hf : f â closure (((â) : (E' âSL[Ïââ] F) â E' â F) '' s)) : E' âSL[Ïââ] F := by
-- `f` is a linear map due to `linearMapOfMemClosureRangeCoe`
refine (linearMapOfMemClosureRangeCoe f ?_).mkContinuousOfExistsBound ?_
· refine closure_mono (image_subset_iff.2 fun g _ => ?_) hf
exact âšg, rflâ©
· -- We need to show that `f` has bounded norm. Choose `C` such that `âgâ †C` for all `g â s`.
rcases isBounded_iff_forall_norm_le.1 hs with âšC, hCâ©
-- Then `âg xâ †C * âxâ` for all `g â s`, `x : E`, hence `âf xâ †C * âxâ` for all `x`.
have : â x, IsClosed { g : E' â F | âg xâ †C * âxâ } := fun x =>
isClosed_Iic.preimage (@continuous_apply E' (fun _ => F) _ x).norm
refine âšC, fun x => (this x).closure_subset_iff.2 (image_subset_iff.2 fun g hg => ?_) hfâ©
exact g.le_of_opNorm_le (hC _ hg) _
/-- Let `f : E â F` be a map, let `g : α â E âSL[Ïââ] F` be a family of continuous (semi)linear maps
that takes values in a bounded set and converges to `f` pointwise along a nontrivial filter. Then
`f` is a continuous (semi)linear map. -/
@[simps! -fullyApplied apply]
def ofTendstoOfBoundedRange {α : Type*} {l : Filter α} [l.NeBot] (f : E' â F)
(g : α â E' âSL[Ïââ] F) (hf : Tendsto (fun a x => g a x) l (ð f))
(hg : IsBounded (Set.range g)) : E' âSL[Ïââ] F :=
ofMemClosureImageCoeBounded f hg <| mem_closure_of_tendsto hf <|
Eventually.of_forall fun _ => mem_image_of_mem _ <| Set.mem_range_self _
/-- If a Cauchy sequence of continuous linear map converges to a continuous linear map pointwise,
then it converges to the same map in norm. This lemma is used to prove that the space of continuous
linear maps is complete provided that the codomain is a complete space. -/
theorem tendsto_of_tendsto_pointwise_of_cauchySeq {f : â â E' âSL[Ïââ] F} {g : E' âSL[Ïââ] F}
(hg : Tendsto (fun n x => f n x) atTop (ð g)) (hf : CauchySeq f) : Tendsto f atTop (ð g) := by
/- Since `f` is a Cauchy sequence, there exists `b â 0` such that `âf n - f mâ †b N` for any
`m, n ⥠N`. -/
rcases cauchySeq_iff_le_tendsto_0.1 hf with âšb, hbâ, hfb, hb_limâ©
-- Since `b â 0`, it suffices to show that `âf n x - g xâ †b n * âxâ` for all `n` and `x`.
suffices â n x, âf n x - g xâ †b n * âxâ from
tendsto_iff_norm_sub_tendsto_zero.2
(squeeze_zero (fun n => norm_nonneg _) (fun n => opNorm_le_bound _ (hbâ n) (this n)) hb_lim)
intro n x
-- Note that `f m x â g x`, hence `âf n x - f m xâ â âf n x - g xâ` as `m â â`
have : Tendsto (fun m => âf n x - f m xâ) atTop (ð âf n x - g xâ) :=
(tendsto_const_nhds.sub <| tendsto_pi_nhds.1 hg _).norm
-- Thus it suffices to verify `âf n x - f m xâ †b n * âxâ` for `m ⥠n`.
refine le_of_tendsto this (eventually_atTop.2 âšn, fun m hm => ?_â©)
-- This inequality follows from `âf n - f mâ †b n`.
exact (f n - f m).le_of_opNorm_le (hfb _ _ _ le_rfl hm) _
/-- If the target space is complete, the space of continuous linear maps with its norm is also
complete. This works also if the source space is seminormed. -/
instance [CompleteSpace F] : CompleteSpace (E' âSL[Ïââ] F) := by
-- We show that every Cauchy sequence converges.
refine Metric.complete_of_cauchySeq_tendsto fun f hf => ?_
-- The evaluation at any point `v : E` is Cauchy.
have cau : â v, CauchySeq fun n => f n v := fun v => hf.map (lipschitz_apply v).uniformContinuous
-- We assemble the limits points of those Cauchy sequences
-- (which exist as `F` is complete)
-- into a function which we call `G`.
choose G hG using fun v => cauchySeq_tendsto_of_complete (cau v)
-- Next, we show that this `G` is a continuous linear map.
-- This is done in `ContinuousLinearMap.ofTendstoOfBoundedRange`.
set Glin : E' âSL[Ïââ] F :=
ofTendstoOfBoundedRange _ _ (tendsto_pi_nhds.mpr hG) hf.isBounded_range
-- Finally, `f n` converges to `Glin` in norm because of
-- `ContinuousLinearMap.tendsto_of_tendsto_pointwise_of_cauchySeq`
exact âšGlin, tendsto_of_tendsto_pointwise_of_cauchySeq (tendsto_pi_nhds.2 hG) hfâ©
/-- Let `s` be a bounded set in the space of continuous (semi)linear maps `E âSL[Ï] F` taking values
in a proper space. Then `s` interpreted as a set in the space of maps `E â F` with topology of
pointwise convergence is precompact: its closure is a compact set. -/
theorem isCompact_closure_image_coe_of_bounded [ProperSpace F] {s : Set (E' âSL[Ïââ] F)}
(hb : IsBounded s) : IsCompact (closure (((â) : (E' âSL[Ïââ] F) â E' â F) '' s)) :=
have : â x, IsCompact (closure (apply' F Ïââ x '' s)) := fun x =>
((apply' F Ïââ x).lipschitz.isBounded_image hb).isCompact_closure
(isCompact_pi_infinite this).closure_of_subset
(image_subset_iff.2 fun _ hg _ => subset_closure <| mem_image_of_mem _ hg)
/-- Let `s` be a bounded set in the space of continuous (semi)linear maps `E âSL[Ï] F` taking values
in a proper space. If `s` interpreted as a set in the space of maps `E â F` with topology of
pointwise convergence is closed, then it is compact.
TODO: reformulate this in terms of a type synonym with the right topology. -/
theorem isCompact_image_coe_of_bounded_of_closed_image [ProperSpace F] {s : Set (E' âSL[Ïââ] F)}
(hb : IsBounded s) (hc : IsClosed (((â) : (E' âSL[Ïââ] F) â E' â F) '' s)) :
IsCompact (((â) : (E' âSL[Ïââ] F) â E' â F) '' s) :=
hc.closure_eq âž isCompact_closure_image_coe_of_bounded hb
/-- If a set `s` of semilinear functions is bounded and is closed in the weak-* topology, then its
image under coercion to functions `E â F` is a closed set. We don't have a name for `E âSL[Ï] F`
with weak-* topology in `mathlib`, so we use an equivalent condition (see `isClosed_induced_iff'`).
TODO: reformulate this in terms of a type synonym with the right topology. -/
theorem isClosed_image_coe_of_bounded_of_weak_closed {s : Set (E' âSL[Ïââ] F)} (hb : IsBounded s)
(hc : â f : E' âSL[Ïââ] F,
(âf : E' â F) â closure (((â) : (E' âSL[Ïââ] F) â E' â F) '' s) â f â s) :
IsClosed (((â) : (E' âSL[Ïââ] F) â E' â F) '' s) :=
isClosed_of_closure_subset fun f hf =>
âšofMemClosureImageCoeBounded f hb hf, hc (ofMemClosureImageCoeBounded f hb hf) hf, rflâ©
/-- If a set `s` of semilinear functions is bounded and is closed in the weak-* topology, then its
image under coercion to functions `E â F` is a compact set. We don't have a name for `E âSL[Ï] F`
with weak-* topology in `mathlib`, so we use an equivalent condition (see `isClosed_induced_iff'`).
-/
theorem isCompact_image_coe_of_bounded_of_weak_closed [ProperSpace F] {s : Set (E' âSL[Ïââ] F)}
(hb : IsBounded s) (hc : â f : E' âSL[Ïââ] F,
(âf : E' â F) â closure (((â) : (E' âSL[Ïââ] F) â E' â F) '' s) â f â s) :
IsCompact (((â) : (E' âSL[Ïââ] F) â E' â F) '' s) :=
isCompact_image_coe_of_bounded_of_closed_image hb <|
isClosed_image_coe_of_bounded_of_weak_closed hb hc
/-- A closed ball is closed in the weak-* topology. We don't have a name for `E âSL[Ï] F` with
weak-* topology in `mathlib`, so we use an equivalent condition (see `isClosed_induced_iff'`). -/
theorem is_weak_closed_closedBall (fâ : E' âSL[Ïââ] F) (r : â) âŠf : E' âSL[Ïââ] FâŠ
(hf : âf â closure (((â) : (E' âSL[Ïââ] F) â E' â F) '' closedBall fâ r)) :
f â closedBall fâ r := by
have hr : 0 †r := nonempty_closedBall.1 (closure_nonempty_iff.1 âš_, hfâ©).of_image
refine mem_closedBall_iff_norm.2 (opNorm_le_bound _ hr fun x => ?_)
have : IsClosed { g : E' â F | âg x - fâ xâ †r * âxâ } :=
isClosed_Iic.preimage ((@continuous_apply E' (fun _ => F) _ x).sub continuous_const).norm
refine this.closure_subset_iff.2 (image_subset_iff.2 fun g hg => ?_) hf
| exact (g - fâ).le_of_opNorm_le (mem_closedBall_iff_norm.1 hg) _
/-- The set of functions `f : E â F` that represent continuous linear maps `f : E âSL[Ïââ] F`
at distance `†r` from `fâ : E âSL[Ïââ] F` is closed in the topology of pointwise convergence.
This is one of the key steps in the proof of the **Banach-Alaoglu** theorem. -/
theorem isClosed_image_coe_closedBall (fâ : E âSL[Ïââ] F) (r : â) :
IsClosed (((â) : (E âSL[Ïââ] F) â E â F) '' closedBall fâ r) :=
isClosed_image_coe_of_bounded_of_weak_closed isBounded_closedBall (is_weak_closed_closedBall fâ r)
| Mathlib/Analysis/NormedSpace/OperatorNorm/Completeness.lean | 157 | 165 |
/-
Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Bhavik Mehta
-/
import Mathlib.Algebra.BigOperators.Field
import Mathlib.Algebra.Order.Chebyshev
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Order.Partition.Equipartition
/-!
# Numerical bounds for Szemerédi Regularity Lemma
This file gathers the numerical facts required by the proof of Szemerédi's regularity lemma.
This entire file is internal to the proof of Szemerédi Regularity Lemma.
## Main declarations
* `SzemerediRegularity.stepBound`: During the inductive step, a partition of size `n` is blown to
size at most `stepBound n`.
* `SzemerediRegularity.initialBound`: The size of the partition we start the induction with.
* `SzemerediRegularity.bound`: The upper bound on the size of the partition produced by our version
of Szemerédi's regularity lemma.
## References
[Yaël Dillies, Bhavik Mehta, *Formalising Szemerédiâs Regularity Lemma in Lean*][srl_itp]
-/
open Finset Fintype Function Real
namespace SzemerediRegularity
/-- Auxiliary function for Szemerédi's regularity lemma. Blowing up a partition of size `n` during
the induction results in a partition of size at most `stepBound n`. -/
def stepBound (n : â) : â :=
n * 4 ^ n
theorem le_stepBound : id †stepBound := fun n =>
Nat.le_mul_of_pos_right _ <| pow_pos (by norm_num) n
theorem stepBound_mono : Monotone stepBound := fun _ _ h =>
Nat.mul_le_mul h <| Nat.pow_le_pow_right (by norm_num) h
theorem stepBound_pos_iff {n : â} : 0 < stepBound n â 0 < n :=
mul_pos_iff_of_pos_right <| by positivity
alias âš_, stepBound_posâ© := stepBound_pos_iff
@[norm_cast] lemma coe_stepBound {α : Type*} [Semiring α] (n : â) :
(stepBound n : α) = n * 4 ^ n := by unfold stepBound; norm_cast
end SzemerediRegularity
open SzemerediRegularity
variable {α : Type*} [DecidableEq α] [Fintype α] {P : Finpartition (univ : Finset α)}
{u : Finset α} {ε : â}
local notation3 "m" => (card α / stepBound #P.parts : â)
local notation3 "a" => (card α / #P.parts - m * 4 ^ #P.parts : â)
namespace SzemerediRegularity.Positivity
private theorem eps_pos {ε : â} {n : â} (h : 100 †(4 : â) ^ n * ε ^ 5) : 0 < ε :=
(Odd.pow_pos_iff (by decide)).mp
(pos_of_mul_pos_right ((show 0 < (100 : â) by norm_num).trans_le h) (by positivity))
private theorem m_pos [Nonempty α] (hPα : #P.parts * 16 ^ #P.parts †card α) : 0 < m :=
Nat.div_pos (hPα.trans' <| by unfold stepBound; gcongr; norm_num) <|
stepBound_pos (P.parts_nonempty <| univ_nonempty.ne_empty).card_pos
/-- Local extension for the `positivity` tactic: A few facts that are needed many times for the
proof of Szemerédi's regularity lemma. -/
scoped macro "sz_positivity" : tactic =>
`(tactic|
{ try have := m_pos â¹_âº
try have := eps_pos â¹_âº
positivity })
-- Original meta code
/- meta def positivity_szemeredi_regularity : expr â tactic strictness
| `(%%n / step_bound (finpartition.parts %%P).card) := do
p â to_expr
``((finpartition.parts %%P).card * 16^(finpartition.parts %%P).card †%%n)
>>= find_assumption,
positive <$> mk_app ``m_pos [p]
| ε := do
typ â infer_type ε,
unify typ `(â),
p â to_expr ``(100 †4 ^ _ * %%ε ^ 5) >>= find_assumption,
positive <$> mk_app ``eps_pos [p] -/
end SzemerediRegularity.Positivity
namespace SzemerediRegularity
open scoped SzemerediRegularity.Positivity
theorem m_pos [Nonempty α] (hPα : #P.parts * 16 ^ #P.parts †card α) : 0 < m := by
sz_positivity
theorem coe_m_add_one_pos : 0 < (m : â) + 1 := by positivity
theorem one_le_m_coe [Nonempty α] (hPα : #P.parts * 16 ^ #P.parts †card α) : (1 : â) †m :=
Nat.one_le_cast.2 <| m_pos hPα
theorem eps_pow_five_pos (hPε : 100 †(4 : â) ^ #P.parts * ε ^ 5) : â0 < ε ^ 5 :=
pos_of_mul_pos_right ((by norm_num : (0 : â) < 100).trans_le hPε) <| pow_nonneg (by norm_num) _
theorem eps_pos (hPε : 100 †(4 : â) ^ #P.parts * ε ^ 5) : 0 < ε :=
(Odd.pow_pos_iff (by decide)).mp (eps_pow_five_pos hPε)
theorem hundred_div_ε_pow_five_le_m [Nonempty α] (hPα : #P.parts * 16 ^ #P.parts †card α)
(hPε : 100 †(4 : â) ^ #P.parts * ε ^ 5) : 100 / ε ^ 5 †m :=
(div_le_of_le_mulâ (eps_pow_five_pos hPε).le (by positivity) hPε).trans <| by
norm_cast
rwa [Nat.le_div_iff_mul_le (stepBound_pos (P.parts_nonempty <|
univ_nonempty.ne_empty).card_pos), stepBound, mul_left_comm, â mul_pow]
theorem hundred_le_m [Nonempty α] (hPα : #P.parts * 16 ^ #P.parts †card α)
(hPε : 100 †(4 : â) ^ #P.parts * ε ^ 5) (hε : ε †1) : 100 †m :=
mod_cast
(hundred_div_ε_pow_five_le_m hPα hPε).trans'
(le_div_self (by norm_num) (by sz_positivity) <| pow_le_oneâ (by sz_positivity) hε)
theorem a_add_one_le_four_pow_parts_card : a + 1 †4 ^ #P.parts := by
have h : 1 †4 ^ #P.parts := one_le_powâ (by norm_num)
rw [stepBound, â Nat.div_div_eq_div_mul]
conv_rhs => rw [â Nat.sub_add_cancel h]
rw [add_le_add_iff_right, tsub_le_iff_left, â Nat.add_sub_assoc h]
exact Nat.le_sub_one_of_lt (Nat.lt_div_mul_add h)
theorem card_auxâ (hucard : #u = m * 4 ^ #P.parts + a) :
(4 ^ #P.parts - a) * m + a * (m + 1) = #u := by
rw [hucard, mul_add, mul_one, â add_assoc, â add_mul,
Nat.sub_add_cancel ((Nat.le_succ _).trans a_add_one_le_four_pow_parts_card), mul_comm]
theorem card_auxâ (hP : P.IsEquipartition) (hu : u â P.parts) (hucard : #u â m * 4 ^ #P.parts + a) :
(4 ^ #P.parts - (a + 1)) * m + (a + 1) * (m + 1) = #u := by
have : m * 4 ^ #P.parts †card α / #P.parts := by
rw [stepBound, â Nat.div_div_eq_div_mul]
exact Nat.div_mul_le_self _ _
rw [Nat.add_sub_of_le this] at hucard
rw [(hP.card_parts_eq_average hu).resolve_left hucard, mul_add, mul_one, â add_assoc, â add_mul,
Nat.sub_add_cancel a_add_one_le_four_pow_parts_card, â add_assoc, mul_comm,
Nat.add_sub_of_le this, card_univ]
theorem pow_mul_m_le_card_part (hP : P.IsEquipartition) (hu : u â P.parts) :
(4 : â) ^ #P.parts * m †#u := by
norm_cast
rw [stepBound, â Nat.div_div_eq_div_mul]
exact (Nat.mul_div_le _ _).trans (hP.average_le_card_part hu)
variable (P ε) (l : â)
|
/-- Auxiliary function for Szemerédi's regularity lemma. The size of the partition by which we start
blowing. -/
noncomputable def initialBound : â :=
max 7 <| max l <| âlog (100 / ε ^ 5) / log 4ââ + 1
theorem le_initialBound : l †initialBound ε l :=
(le_max_left _ _).trans <| le_max_right _ _
theorem seven_le_initialBound : 7 †initialBound ε l :=
| Mathlib/Combinatorics/SimpleGraph/Regularity/Bound.lean | 159 | 168 |
/-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Calculus.SmoothSeries
import Mathlib.Analysis.NormedSpace.OperatorNorm.Prod
import Mathlib.Analysis.SpecialFunctions.Gaussian.PoissonSummation
import Mathlib.Data.Complex.FiniteDimensional
/-!
# The two-variable Jacobi theta function
This file defines the two-variable Jacobi theta function
$$\theta(z, \tau) = \sum_{n \in \mathbb{Z}} \exp (2 i \pi n z + i \pi n ^ 2 \tau),$$
and proves the functional equation relating the values at `(z, Ï)` and `(z / Ï, -1 / Ï)`,
using Poisson's summation formula. We also show holomorphy (jointly in both variables).
Additionally, we show some analogous results about the derivative (in the `z`-variable)
$$\theta'(z, Ï) = \sum_{n \in \mathbb{Z}} 2 \pi i n \exp (2 i \pi n z + i \pi n ^ 2 \tau).$$
(Note that the Mellin transform of `Ξ` will give us functional equations for `L`-functions
of even Dirichlet characters, and that of `Ξ'` will do the same for odd Dirichlet characters.)
-/
open Complex Real Asymptotics Filter Topology
open scoped ComplexConjugate
noncomputable section
section term_defs
/-!
## Definitions of the summands
-/
/-- Summand in the series for the Jacobi theta function. -/
def jacobiThetaâ_term (n : â€) (z Ï : â) : â := cexp (2 * Ï * I * n * z + Ï * I * n ^ 2 * Ï)
/-- Summand in the series for the Fréchet derivative of the Jacobi theta function. -/
def jacobiThetaâ_term_fderiv (n : â€) (z Ï : â) : â à â âL[â] â :=
cexp (2 * Ï * I * n * z + Ï * I * n ^ 2 * Ï) â¢
((2 * Ï * I * n) ⢠(ContinuousLinearMap.fst â â â) +
(Ï * I * n ^ 2) ⢠(ContinuousLinearMap.snd â â â))
lemma hasFDerivAt_jacobiThetaâ_term (n : â€) (z Ï : â) :
HasFDerivAt (fun p : â à â ⊠jacobiThetaâ_term n p.1 p.2)
(jacobiThetaâ_term_fderiv n z Ï) (z, Ï) := by
let f : â à â â â := fun p ⊠2 * Ï * I * n * p.1 + Ï * I * n ^ 2 * p.2
suffices HasFDerivAt f ((2 * Ï * I * n) ⢠(ContinuousLinearMap.fst â â â)
+ (Ï * I * n ^ 2) ⢠(ContinuousLinearMap.snd â â â)) (z, Ï) from this.cexp
exact (hasFDerivAt_fst.const_mul _).add (hasFDerivAt_snd.const_mul _)
/-- Summand in the series for the `z`-derivative of the Jacobi theta function. -/
def jacobiThetaâ'_term (n : â€) (z Ï : â) := 2 * Ï * I * n * jacobiThetaâ_term n z Ï
end term_defs
section term_bounds
/-!
## Bounds for the summands
We show that the sums of the three functions `jacobiThetaâ_term`, `jacobiThetaâ'_term` and
`jacobiThetaâ_term_fderiv` are locally uniformly convergent in the domain `0 < im Ï`, and diverge
everywhere else.
-/
lemma norm_jacobiThetaâ_term (n : â€) (z Ï : â) :
âjacobiThetaâ_term n z Ïâ = rexp (-Ï * n ^ 2 * Ï.im - 2 * Ï * n * z.im) := by
rw [jacobiThetaâ_term, Complex.norm_exp, (by push_cast; ring :
(2 * Ï : â) * I * n * z + Ï * I * n ^ 2 * Ï = (Ï * (2 * n):) * z * I + (Ï * n ^ 2 :) * Ï * I),
add_re, mul_I_re, im_ofReal_mul, mul_I_re, im_ofReal_mul]
ring_nf
/-- A uniform upper bound for `jacobiThetaâ_term` on compact subsets. -/
lemma norm_jacobiThetaâ_term_le {S T : â} (hT : 0 < T) {z Ï : â}
(hz : |im z| †S) (hÏ : T †im Ï) (n : â€) :
âjacobiThetaâ_term n z Ïâ †rexp (-Ï * (T * n ^ 2 - 2 * S * |n|)) := by
simp_rw [norm_jacobiThetaâ_term, Real.exp_le_exp, sub_eq_add_neg, neg_mul, â neg_add,
neg_le_neg_iff, mul_comm (2 : â), mul_assoc Ï, â mul_add, mul_le_mul_left pi_pos,
mul_comm T, mul_comm S]
refine add_le_add (mul_le_mul le_rfl hÏ hT.le (sq_nonneg _)) ?_
rw [â mul_neg, mul_assoc, mul_assoc, mul_le_mul_left two_pos, mul_comm, neg_mul, â mul_neg]
refine le_trans ?_ (neg_abs_le _)
rw [mul_neg, neg_le_neg_iff, abs_mul, Int.cast_abs]
exact mul_le_mul_of_nonneg_left hz (abs_nonneg _)
/-- A uniform upper bound for `jacobiThetaâ'_term` on compact subsets. -/
lemma norm_jacobiThetaâ'_term_le {S T : â} (hT : 0 < T) {z Ï : â}
(hz : |im z| †S) (hÏ : T †im Ï) (n : â€) :
âjacobiThetaâ'_term n z Ïâ †2 * Ï * |n| * rexp (-Ï * (T * n ^ 2 - 2 * S * |n|)) := by
rw [jacobiThetaâ'_term, norm_mul]
refine mul_le_mul (le_of_eq ?_) (norm_jacobiThetaâ_term_le hT hz hÏ n)
(norm_nonneg _) (by positivity)
simp only [norm_mul, Complex.norm_two, norm_I, Complex.norm_of_nonneg pi_pos.le,
norm_intCast, mul_one, Int.cast_abs]
|
/-- The uniform bound we have given is summable, and remains so after multiplying by any fixed
power of `|n|` (we shall need this for `k = 0, 1, 2`). -/
lemma summable_pow_mul_jacobiThetaâ_term_bound (S : â) {T : â} (hT : 0 < T) (k : â) :
Summable (fun n : †⊠(|n| ^ k : â) * Real.exp (-Ï * (T * n ^ 2 - 2 * S * |n|))) := by
suffices Summable (fun n : â ⊠(n ^ k : â) * Real.exp (-Ï * (T * n ^ 2 - 2 * S * n))) by
apply Summable.of_nat_of_neg <;>
simpa only [Int.cast_neg, neg_sq, abs_neg, Int.cast_natCast, Nat.abs_cast]
apply summable_of_isBigO_nat (summable_pow_mul_exp_neg_nat_mul k zero_lt_one)
apply IsBigO.mul (isBigO_refl _ _)
refine Real.isBigO_exp_comp_exp_comp.mpr (Tendsto.isBoundedUnder_le_atBot ?_)
simp_rw [â tendsto_neg_atTop_iff, Pi.sub_apply]
conv =>
enter [1, n]
rw [show -(-Ï * (T * n ^ 2 - 2 * S * n) - -1 * n) = n * (Ï * T * n - (2 * Ï * S + 1)) by ring]
refine tendsto_natCast_atTop_atTop.atTop_mul_atTopâ (tendsto_atTop_add_const_right _ _ ?_)
| Mathlib/NumberTheory/ModularForms/JacobiTheta/TwoVariable.lean | 100 | 115 |
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Mario Carneiro
-/
import Mathlib.Data.Subtype
import Mathlib.Order.Defs.LinearOrder
import Mathlib.Order.Notation
import Mathlib.Tactic.GCongr.Core
import Mathlib.Tactic.Spread
import Mathlib.Tactic.Convert
import Mathlib.Tactic.Inhabit
import Mathlib.Tactic.SimpRw
/-!
# Basic definitions about `â€` and `<`
This file proves basic results about orders, provides extensive dot notation, defines useful order
classes and allows to transfer order instances.
## Type synonyms
* `OrderDual α` : A type synonym reversing the meaning of all inequalities, with notation `αáµáµ`.
* `AsLinearOrder α`: A type synonym to promote `PartialOrder α` to `LinearOrder α` using
`IsTotal α (â€)`.
### Transferring orders
- `Order.Preimage`, `Preorder.lift`: Transfers a (pre)order on `β` to an order on `α`
using a function `f : α â β`.
- `PartialOrder.lift`, `LinearOrder.lift`: Transfers a partial (resp., linear) order on `β` to a
partial (resp., linear) order on `α` using an injective function `f`.
### Extra class
* `DenselyOrdered`: An order with no gap, i.e. for any two elements `a < b` there exists `c` such
that `a < c < b`.
## Notes
`â€` and `<` are highly favored over `â¥` and `>` in mathlib. The reason is that we can formulate all
lemmas using `â€`/`<`, and `rw` has trouble unifying `â€` and `â¥`. Hence choosing one direction spares
us useless duplication. This is enforced by a linter. See Note [nolint_ge] for more infos.
Dot notation is particularly useful on `â€` (`LE.le`) and `<` (`LT.lt`). To that end, we
provide many aliases to dot notation-less lemmas. For example, `le_trans` is aliased with
`LE.le.trans` and can be used to construct `hab.trans hbc : a †c` when `hab : a †b`,
`hbc : b †c`, `lt_of_le_of_lt` is aliased as `LE.le.trans_lt` and can be used to construct
`hab.trans hbc : a < c` when `hab : a †b`, `hbc : b < c`.
## TODO
- expand module docs
- automatic construction of dual definitions / theorems
## Tags
preorder, order, partial order, poset, linear order, chain
-/
open Function
variable {ι α β : Type*} {Ï : ι â Type*}
/-! ### Bare relations -/
attribute [ext] LE
protected lemma LE.le.ge [LE α] {x y : α} (h : x †y) : y ⥠x := h
protected lemma GE.ge.le [LE α] {x y : α} (h : x ⥠y) : y †x := h
protected lemma LT.lt.gt [LT α] {x y : α} (h : x < y) : y > x := h
protected lemma GT.gt.lt [LT α] {x y : α} (h : x > y) : y < x := h
/-- Given a relation `R` on `β` and a function `f : α â β`, the preimage relation on `α` is defined
by `x †y â f x †f y`. It is the unique relation on `α` making `f` a `RelEmbedding` (assuming `f`
is injective). -/
@[simp]
def Order.Preimage (f : α â β) (s : β â β â Prop) (x y : α) : Prop := s (f x) (f y)
@[inherit_doc] infixl:80 " â»Â¹'o " => Order.Preimage
/-- The preimage of a decidable order is decidable. -/
instance Order.Preimage.decidable (f : α â β) (s : β â β â Prop) [H : DecidableRel s] :
DecidableRel (f â»Â¹'o s) := fun _ _ ⊠H _ _
/-! ### Preorders -/
section Preorder
variable [Preorder α] {a b c d : α}
theorem le_trans' : b †c â a †b â a †c :=
flip le_trans
theorem lt_trans' : b < c â a < b â a < c :=
flip lt_trans
theorem lt_of_le_of_lt' : b †c â a < b â a < c :=
flip lt_of_lt_of_le
theorem lt_of_lt_of_le' : b < c â a †b â a < c :=
flip lt_of_le_of_lt
theorem le_of_le_of_eq' : b †c â a = b â a †c :=
flip le_of_eq_of_le
theorem le_of_eq_of_le' : b = c â a †b â a †c :=
flip le_of_le_of_eq
theorem lt_of_lt_of_eq' : b < c â a = b â a < c :=
flip lt_of_eq_of_lt
theorem lt_of_eq_of_lt' : b = c â a < b â a < c :=
flip lt_of_lt_of_eq
theorem not_lt_iff_not_le_or_ge : ¬a < b â ¬a †b âš b †a := by
rw [lt_iff_le_not_le, Classical.not_and_iff_not_or_not, Classical.not_not]
-- Unnecessary brackets are here for readability
lemma not_lt_iff_le_imp_le : ¬ a < b â (a †b â b †a) := by
simp [not_lt_iff_not_le_or_ge, or_iff_not_imp_left]
/-- If `x = y` then `y †x`. Note: this lemma uses `y †x` instead of `x ⥠y`, because `le` is used
almost exclusively in mathlib. -/
lemma ge_of_eq (h : a = b) : b †a := le_of_eq h.symm
@[simp] lemma lt_self_iff_false (x : α) : x < x â False := âšlt_irrefl x, False.elimâ©
alias LE.le.trans := le_trans
alias LE.le.trans' := le_trans'
alias LT.lt.trans := lt_trans
alias LT.lt.trans' := lt_trans'
alias LE.le.trans_lt := lt_of_le_of_lt
alias LE.le.trans_lt' := lt_of_le_of_lt'
alias LT.lt.trans_le := lt_of_lt_of_le
alias LT.lt.trans_le' := lt_of_lt_of_le'
alias LE.le.trans_eq := le_of_le_of_eq
alias LE.le.trans_eq' := le_of_le_of_eq'
alias LT.lt.trans_eq := lt_of_lt_of_eq
alias LT.lt.trans_eq' := lt_of_lt_of_eq'
alias Eq.trans_le := le_of_eq_of_le
alias Eq.trans_ge := le_of_eq_of_le'
alias Eq.trans_lt := lt_of_eq_of_lt
alias Eq.trans_gt := lt_of_eq_of_lt'
alias LE.le.lt_of_not_le := lt_of_le_not_le
alias LE.le.lt_or_eq_dec := Decidable.lt_or_eq_of_le
alias LT.lt.le := le_of_lt
alias LT.lt.ne := ne_of_lt
alias Eq.le := le_of_eq
@[inherit_doc ge_of_eq] alias Eq.ge := ge_of_eq
alias LT.lt.asymm := lt_asymm
alias LT.lt.not_lt := lt_asymm
theorem ne_of_not_le (h : ¬a †b) : a â b := fun hab ⊠h (le_of_eq hab)
protected lemma Eq.not_lt (hab : a = b) : ¬a < b := fun h' ⊠h'.ne hab
protected lemma Eq.not_gt (hab : a = b) : ¬b < a := hab.symm.not_lt
@[simp] lemma le_of_subsingleton [Subsingleton α] : a †b := (Subsingleton.elim a b).le
-- Making this a @[simp] lemma causes confluence problems downstream.
lemma not_lt_of_subsingleton [Subsingleton α] : ¬a < b := (Subsingleton.elim a b).not_lt
namespace LT.lt
protected theorem false : a < a â False := lt_irrefl a
theorem ne' (h : a < b) : b â a := h.ne.symm
end LT.lt
theorem le_of_forall_le (H : â c, c †a â c †b) : a †b := H _ le_rfl
theorem le_of_forall_ge (H : â c, a †c â b †c) : b †a := H _ le_rfl
@[deprecated (since := "2025-01-30")] alias le_of_forall_le' := le_of_forall_ge
theorem forall_le_iff_le : (â âŠcâŠ, c †a â c †b) â a †b :=
âšle_of_forall_le, fun h _ hca ⊠le_trans hca hâ©
theorem forall_le_iff_ge : (â âŠcâŠ, a †c â b †c) â b †a :=
âšle_of_forall_ge, fun h _ hca ⊠le_trans h hcaâ©
/-- monotonicity of `â€` with respect to `â` -/
theorem le_implies_le_of_le_of_le (hca : c †a) (hbd : b †d) : a †b â c †d :=
fun hab ⊠(hca.trans hab).trans hbd
end Preorder
/-! ### Partial order -/
section PartialOrder
variable [PartialOrder α] {a b : α}
theorem ge_antisymm : a †b â b †a â b = a :=
flip le_antisymm
theorem lt_of_le_of_ne' : a †b â b â a â a < b := fun hâ hâ ⊠lt_of_le_of_ne hâ hâ.symm
theorem Ne.lt_of_le : a â b â a †b â a < b :=
flip lt_of_le_of_ne
theorem Ne.lt_of_le' : b â a â a †b â a < b :=
flip lt_of_le_of_ne'
alias LE.le.antisymm := le_antisymm
alias LE.le.antisymm' := ge_antisymm
alias LE.le.lt_of_ne := lt_of_le_of_ne
alias LE.le.lt_of_ne' := lt_of_le_of_ne'
alias LE.le.lt_or_eq := lt_or_eq_of_le
-- Unnecessary brackets are here for readability
lemma le_imp_eq_iff_le_imp_le : (a †b â b = a) â (a †b â b †a) where
mp h hab := (h hab).le
mpr h hab := (h hab).antisymm hab
-- Unnecessary brackets are here for readability
lemma ge_imp_eq_iff_le_imp_le : (a †b â a = b) â (a †b â b †a) where
mp h hab := (h hab).ge
mpr h hab := hab.antisymm (h hab)
namespace LE.le
theorem lt_iff_ne (h : a †b) : a < b â a â b :=
âšfun h ⊠h.ne, h.lt_of_neâ©
theorem gt_iff_ne (h : a †b) : a < b â b â a :=
âšfun h ⊠h.ne.symm, h.lt_of_ne'â©
theorem not_lt_iff_eq (h : a †b) : ¬a < b â a = b :=
h.lt_iff_ne.not_left
theorem not_gt_iff_eq (h : a †b) : ¬a < b â b = a :=
h.gt_iff_ne.not_left
theorem le_iff_eq (h : a †b) : b †a â b = a :=
âšfun h' ⊠h'.antisymm h, Eq.leâ©
theorem ge_iff_eq (h : a †b) : b †a â a = b :=
âšh.antisymm, Eq.geâ©
end LE.le
-- See Note [decidable namespace]
protected theorem Decidable.le_iff_eq_or_lt [DecidableLE α] : a †b â a = b âš a < b :=
Decidable.le_iff_lt_or_eq.trans or_comm
theorem le_iff_eq_or_lt : a †b â a = b âš a < b := le_iff_lt_or_eq.trans or_comm
theorem lt_iff_le_and_ne : a < b â a †b â§ a â b :=
âšfun h ⊠âšle_of_lt h, ne_of_lt hâ©, fun âšh1, h2⩠⊠h1.lt_of_ne h2â©
lemma eq_iff_not_lt_of_le (hab : a †b) : a = b â ¬ a < b := by simp [hab, lt_iff_le_and_ne]
alias LE.le.eq_iff_not_lt := eq_iff_not_lt_of_le
-- See Note [decidable namespace]
protected theorem Decidable.eq_iff_le_not_lt [DecidableLE α] : a = b â a †b ⧠¬a < b :=
âšfun h ⊠âšh.le, h âž lt_irrefl _â©, fun âšhâ, hââ© âŠ
hâ.antisymm <| Decidable.byContradiction fun hâ ⊠hâ (hâ.lt_of_not_le hâ)â©
theorem eq_iff_le_not_lt : a = b â a †b ⧠¬a < b :=
haveI := Classical.dec
Decidable.eq_iff_le_not_lt
theorem eq_or_lt_of_le (h : a †b) : a = b ⚠a < b := h.lt_or_eq.symm
theorem eq_or_gt_of_le (h : a †b) : b = a ⚠a < b := h.lt_or_eq.symm.imp Eq.symm id
theorem gt_or_eq_of_le (h : a †b) : a < b ⚠b = a := (eq_or_gt_of_le h).symm
alias LE.le.eq_or_lt_dec := Decidable.eq_or_lt_of_le
alias LE.le.eq_or_lt := eq_or_lt_of_le
alias LE.le.eq_or_gt := eq_or_gt_of_le
alias LE.le.gt_or_eq := gt_or_eq_of_le
theorem eq_of_le_of_not_lt (hab : a †b) (hba : ¬a < b) : a = b := hab.eq_or_lt.resolve_right hba
theorem eq_of_ge_of_not_gt (hab : a †b) (hba : ¬a < b) : b = a := (eq_of_le_of_not_lt hab hba).symm
alias LE.le.eq_of_not_lt := eq_of_le_of_not_lt
alias LE.le.eq_of_not_gt := eq_of_ge_of_not_gt
theorem Ne.le_iff_lt (h : a â b) : a †b â a < b := âšfun h' ⊠lt_of_le_of_ne h' h, fun h ⊠h.leâ©
theorem Ne.not_le_or_not_le (h : a â b) : ¬a †b ⚠¬b †a := not_and_or.1 <| le_antisymm_iff.not.1 h
-- See Note [decidable namespace]
protected theorem Decidable.ne_iff_lt_iff_le [DecidableEq α] : (a â b â a < b) â a †b :=
âšfun h ⊠Decidable.byCases le_of_eq (le_of_lt â h.mp), fun h ⊠âšlt_of_le_of_ne h, ne_of_ltâ©â©
@[simp]
theorem ne_iff_lt_iff_le : (a â b â a < b) â a †b :=
haveI := Classical.dec
Decidable.ne_iff_lt_iff_le
lemma eq_of_forall_le_iff (H : â c, c †a â c †b) : a = b :=
((H _).1 le_rfl).antisymm ((H _).2 le_rfl)
lemma eq_of_forall_ge_iff (H : â c, a †c â b †c) : a = b :=
((H _).2 le_rfl).antisymm ((H _).1 le_rfl)
/-- To prove commutativity of a binary operation `â`, we only to check `a â b †b â a` for all `a`,
`b`. -/
lemma commutative_of_le {f : β â β â α} (comm : â a b, f a b †f b a) : â a b, f a b = f b a :=
fun _ _ ⊠(comm _ _).antisymm <| comm _ _
/-- To prove associativity of a commutative binary operation `â`, we only to check
`(a â b) â c †a â (b â c)` for all `a`, `b`, `c`. -/
lemma associative_of_commutative_of_le {f : α â α â α} (comm : Std.Commutative f)
(assoc : â a b c, f (f a b) c †f a (f b c)) : Std.Associative f where
assoc a b c :=
le_antisymm (assoc _ _ _) <| by
rw [comm.comm, comm.comm b, comm.comm _ c, comm.comm a]
exact assoc ..
end PartialOrder
section LinearOrder
variable [LinearOrder α] {a b : α}
namespace LE.le
lemma lt_or_le (h : a †b) (c : α) : a < c ⚠c †b := (lt_or_ge a c).imp id h.trans'
lemma le_or_lt (h : a †b) (c : α) : a †c ⚠c < b := (le_or_gt a c).imp id h.trans_lt'
lemma le_or_le (h : a †b) (c : α) : a †c ⚠c †b := (h.lt_or_le c).imp le_of_lt id
end LE.le
namespace LT.lt
lemma lt_or_lt (h : a < b) (c : α) : a < c ⚠c < b := (le_or_gt b c).imp h.trans_le id
end LT.lt
-- Variant of `min_def` with the branches reversed.
theorem min_def' (a b : α) : min a b = if b †a then b else a := by
rw [min_def]
rcases lt_trichotomy a b with (lt | eq | gt)
· rw [if_pos lt.le, if_neg (not_le.mpr lt)]
· rw [if_pos eq.le, if_pos eq.ge, eq]
· rw [if_neg (not_le.mpr gt.gt), if_pos gt.le]
-- Variant of `min_def` with the branches reversed.
-- This is sometimes useful as it used to be the default.
theorem max_def' (a b : α) : max a b = if b †a then a else b := by
rw [max_def]
rcases lt_trichotomy a b with (lt | eq | gt)
· rw [if_pos lt.le, if_neg (not_le.mpr lt)]
· rw [if_pos eq.le, if_pos eq.ge, eq]
· rw [if_neg (not_le.mpr gt.gt), if_pos gt.le]
theorem lt_of_not_le (h : ¬b †a) : a < b :=
((le_total _ _).resolve_right h).lt_of_not_le h
theorem lt_iff_not_le : a < b â ¬b †a :=
âšnot_le_of_lt, lt_of_not_leâ©
theorem Ne.lt_or_lt (h : a â b) : a < b âš b < a :=
lt_or_gt_of_ne h
/-- A version of `ne_iff_lt_or_gt` with LHS and RHS reversed. -/
@[simp]
theorem lt_or_lt_iff_ne : a < b âš b < a â a â b :=
ne_iff_lt_or_gt.symm
theorem not_lt_iff_eq_or_lt : ¬a < b â a = b âš b < a :=
not_lt.trans <| Decidable.le_iff_eq_or_lt.trans <| or_congr eq_comm Iff.rfl
theorem exists_ge_of_linear (a b : α) : â c, a †c â§ b †c :=
match le_total a b with
| Or.inl h => âš_, h, le_rflâ©
| Or.inr h => âš_, le_rfl, hâ©
lemma exists_forall_ge_and {p q : α â Prop} :
(â i, â j ⥠i, p j) â (â i, â j ⥠i, q j) â â i, â j ⥠i, p j â§ q j
| âša, haâ©, âšb, hbâ© =>
let âšc, hac, hbcâ© := exists_ge_of_linear a b
âšc, fun _d hcd ⊠âšha _ <| hac.trans hcd, hb _ <| hbc.trans hcdâ©â©
theorem le_of_forall_lt (H : â c, c < a â c < b) : a †b :=
le_of_not_lt fun h ⊠lt_irrefl _ (H _ h)
theorem forall_lt_iff_le : (â âŠcâŠ, c < a â c < b) â a †b :=
âšle_of_forall_lt, fun h _ hca ⊠lt_of_lt_of_le hca hâ©
theorem le_of_forall_lt' (H : â c, a < c â b < c) : b †a :=
le_of_not_lt fun h ⊠lt_irrefl _ (H _ h)
theorem forall_lt_iff_le' : (â âŠcâŠ, a < c â b < c) â b †a :=
âšle_of_forall_lt', fun h _ hac ⊠lt_of_le_of_lt h hacâ©
theorem eq_of_forall_lt_iff (h : â c, c < a â c < b) : a = b :=
(le_of_forall_lt fun _ ⊠(h _).1).antisymm <| le_of_forall_lt fun _ ⊠(h _).2
theorem eq_of_forall_gt_iff (h : â c, a < c â b < c) : a = b :=
(le_of_forall_lt' fun _ ⊠(h _).2).antisymm <| le_of_forall_lt' fun _ ⊠(h _).1
section ltByCases
variable {P : Sort*} {x y : α}
@[simp]
lemma ltByCases_lt (h : x < y) {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P} :
ltByCases x y hâ hâ hâ = hâ h := dif_pos h
@[simp]
lemma ltByCases_gt (h : y < x) {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P} :
ltByCases x y hâ hâ hâ = hâ h := (dif_neg h.not_lt).trans (dif_pos h)
@[simp]
lemma ltByCases_eq (h : x = y) {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P} :
ltByCases x y hâ hâ hâ = hâ h := (dif_neg h.not_lt).trans (dif_neg h.not_gt)
lemma ltByCases_not_lt (h : ¬ x < y) {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P}
(p : ¬ y < x â x = y := fun h' => (le_antisymm (le_of_not_gt h') (le_of_not_gt h))) :
ltByCases x y hâ hâ hâ = if h' : y < x then hâ h' else hâ (p h') := dif_neg h
lemma ltByCases_not_gt (h : ¬ y < x) {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P}
(p : ¬ x < y â x = y := fun h' => (le_antisymm (le_of_not_gt h) (le_of_not_gt h'))) :
ltByCases x y hâ hâ hâ = if h' : x < y then hâ h' else hâ (p h') :=
dite_congr rfl (fun _ => rfl) (fun _ => dif_neg h)
lemma ltByCases_ne (h : x â y) {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P}
(p : ¬ x < y â y < x := fun h' => h.lt_or_lt.resolve_left h') :
ltByCases x y hâ hâ hâ = if h' : x < y then hâ h' else hâ (p h') :=
dite_congr rfl (fun _ => rfl) (fun _ => dif_pos _)
lemma ltByCases_comm {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P}
(p : y = x â x = y := fun h' => h'.symm) :
ltByCases x y hâ hâ hâ = ltByCases y x hâ (hâ â p) hâ := by
refine ltByCases x y (fun h => ?_) (fun h => ?_) (fun h => ?_)
· rw [ltByCases_lt h, ltByCases_gt h]
· rw [ltByCases_eq h, ltByCases_eq h.symm, comp_apply]
· rw [ltByCases_lt h, ltByCases_gt h]
lemma eq_iff_eq_of_lt_iff_lt_of_gt_iff_gt {x' y' : α}
(ltc : (x < y) â (x' < y')) (gtc : (y < x) â (y' < x')) :
x = y â x' = y' := by simp_rw [eq_iff_le_not_lt, â not_lt, ltc, gtc]
lemma ltByCases_rec {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P} (p : P)
(hlt : (h : x < y) â hâ h = p) (heq : (h : x = y) â hâ h = p)
(hgt : (h : y < x) â hâ h = p) :
ltByCases x y hâ hâ hâ = p :=
ltByCases x y
(fun h => ltByCases_lt h âž hlt h)
(fun h => ltByCases_eq h âž heq h)
(fun h => ltByCases_gt h âž hgt h)
lemma ltByCases_eq_iff {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P} {p : P} :
ltByCases x y hâ hâ hâ = p â (â h, hâ h = p) âš (â h, hâ h = p) âš (â h, hâ h = p) := by
refine ltByCases x y (fun h => ?_) (fun h => ?_) (fun h => ?_)
· simp only [ltByCases_lt, exists_prop_of_true, h, h.not_lt, not_false_eq_true,
exists_prop_of_false, or_false, h.ne]
· simp only [h, lt_self_iff_false, ltByCases_eq, not_false_eq_true,
exists_prop_of_false, exists_prop_of_true, or_false, false_or]
· simp only [ltByCases_gt, exists_prop_of_true, h, h.not_lt, not_false_eq_true,
exists_prop_of_false, false_or, h.ne']
lemma ltByCases_congr {x' y' : α} {hâ : x < y â P} {hâ : x = y â P} {hâ : y < x â P}
{hâ' : x' < y' â P} {hâ' : x' = y' â P} {hâ' : y' < x' â P} (ltc : (x < y) â (x' < y'))
(gtc : (y < x) â (y' < x')) (hh'â : â (h : x' < y'), hâ (ltc.mpr h) = hâ' h)
(hh'â : â (h : x' = y'), hâ ((eq_iff_eq_of_lt_iff_lt_of_gt_iff_gt ltc gtc).mpr h) = hâ' h)
(hh'â : â (h : y' < x'), hâ (gtc.mpr h) = hâ' h) :
ltByCases x y hâ hâ hâ = ltByCases x' y' hâ' hâ' hâ' := by
refine ltByCases_rec _ (fun h => ?_) (fun h => ?_) (fun h => ?_)
· rw [ltByCases_lt (ltc.mp h), hh'â]
· rw [eq_iff_eq_of_lt_iff_lt_of_gt_iff_gt ltc gtc] at h
rw [ltByCases_eq h, hh'â]
· rw [ltByCases_gt (gtc.mp h), hh'â]
/-- Perform a case-split on the ordering of `x` and `y` in a decidable linear order,
non-dependently. -/
abbrev ltTrichotomy (x y : α) (p q r : P) := ltByCases x y (fun _ => p) (fun _ => q) (fun _ => r)
variable {p q r s : P}
@[simp]
lemma ltTrichotomy_lt (h : x < y) : ltTrichotomy x y p q r = p := ltByCases_lt h
@[simp]
lemma ltTrichotomy_gt (h : y < x) : ltTrichotomy x y p q r = r := ltByCases_gt h
@[simp]
lemma ltTrichotomy_eq (h : x = y) : ltTrichotomy x y p q r = q := ltByCases_eq h
lemma ltTrichotomy_not_lt (h : ¬ x < y) :
ltTrichotomy x y p q r = if y < x then r else q := ltByCases_not_lt h
lemma ltTrichotomy_not_gt (h : ¬ y < x) :
ltTrichotomy x y p q r = if x < y then p else q := ltByCases_not_gt h
lemma ltTrichotomy_ne (h : x â y) :
ltTrichotomy x y p q r = if x < y then p else r := ltByCases_ne h
lemma ltTrichotomy_comm : ltTrichotomy x y p q r = ltTrichotomy y x r q p := ltByCases_comm
lemma ltTrichotomy_self {p : P} : ltTrichotomy x y p p p = p :=
ltByCases_rec p (fun _ => rfl) (fun _ => rfl) (fun _ => rfl)
lemma ltTrichotomy_eq_iff : ltTrichotomy x y p q r = s â
(x < y â§ p = s) âš (x = y â§ q = s) âš (y < x â§ r = s) := by
refine ltByCases x y (fun h => ?_) (fun h => ?_) (fun h => ?_)
· simp only [ltTrichotomy_lt, false_and, true_and, or_false, h, h.not_lt, h.ne]
· simp only [ltTrichotomy_eq, false_and, true_and, or_false, false_or, h, lt_irrefl]
· simp only [ltTrichotomy_gt, false_and, true_and, false_or, h, h.not_lt, h.ne']
lemma ltTrichotomy_congr {x' y' : α} {p' q' r' : P} (ltc : (x < y) â (x' < y'))
(gtc : (y < x) â (y' < x')) (hh'â : x' < y' â p = p')
(hh'â : x' = y' â q = q') (hh'â : y' < x' â r = r') :
ltTrichotomy x y p q r = ltTrichotomy x' y' p' q' r' :=
ltByCases_congr ltc gtc hh'â hh'â hh'â
end ltByCases
/-! #### `min`/`max` recursors -/
section MinMaxRec
variable {p : α â Prop}
lemma min_rec (ha : a †b â p a) (hb : b †a â p b) : p (min a b) := by
obtain hab | hba := le_total a b <;> simp [min_eq_left, min_eq_right, *]
lemma max_rec (ha : b †a â p a) (hb : a †b â p b) : p (max a b) := by
obtain hab | hba := le_total a b <;> simp [max_eq_left, max_eq_right, *]
lemma min_rec' (p : α â Prop) (ha : p a) (hb : p b) : p (min a b) :=
min_rec (fun _ ⊠ha) fun _ ⊠hb
lemma max_rec' (p : α â Prop) (ha : p a) (hb : p b) : p (max a b) :=
max_rec (fun _ ⊠ha) fun _ ⊠hb
lemma min_def_lt (a b : α) : min a b = if a < b then a else b := by
rw [min_comm, min_def, â ite_not]; simp only [not_le]
lemma max_def_lt (a b : α) : max a b = if a < b then b else a := by
rw [max_comm, max_def, â ite_not]; simp only [not_le]
end MinMaxRec
end LinearOrder
/-! ### Implications -/
lemma lt_imp_lt_of_le_imp_le {β} [LinearOrder α] [Preorder β] {a b : α} {c d : β}
(H : a †b â c †d) (h : d < c) : b < a :=
lt_of_not_le fun h' ⊠(H h').not_lt h
lemma le_imp_le_iff_lt_imp_lt {β} [LinearOrder α] [LinearOrder β] {a b : α} {c d : β} :
a †b â c †d â d < c â b < a :=
âšlt_imp_lt_of_le_imp_le, le_imp_le_of_lt_imp_ltâ©
lemma lt_iff_lt_of_le_iff_le' {β} [Preorder α] [Preorder β] {a b : α} {c d : β}
(H : a †b â c †d) (H' : b †a â d †c) : b < a â d < c :=
lt_iff_le_not_le.trans <| (and_congr H' (not_congr H)).trans lt_iff_le_not_le.symm
lemma lt_iff_lt_of_le_iff_le {β} [LinearOrder α] [LinearOrder β] {a b : α} {c d : β}
(H : a †b â c †d) : b < a â d < c := not_le.symm.trans <| (not_congr H).trans <| not_le
lemma le_iff_le_iff_lt_iff_lt {β} [LinearOrder α] [LinearOrder β] {a b : α} {c d : β} :
(a †b â c †d) â (b < a â d < c) :=
âšlt_iff_lt_of_le_iff_le, fun H ⊠not_lt.symm.trans <| (not_congr H).trans <| not_ltâ©
/-- A symmetric relation implies two values are equal, when it implies they're less-equal. -/
lemma rel_imp_eq_of_rel_imp_le [PartialOrder β] (r : α â α â Prop) [IsSymm α r] {f : α â β}
(h : â a b, r a b â f a †f b) {a b : α} : r a b â f a = f b := fun hab âŠ
le_antisymm (h a b hab) (h b a <| symm hab)
/-! ### Extensionality lemmas -/
@[ext]
lemma Preorder.toLE_injective : Function.Injective (@Preorder.toLE α) :=
fun
| { lt := A_lt, lt_iff_le_not_le := A_iff, .. },
{ lt := B_lt, lt_iff_le_not_le := B_iff, .. } => by
rintro âšâ©
have : A_lt = B_lt := by
funext a b
rw [A_iff, B_iff]
cases this
congr
@[ext]
lemma PartialOrder.toPreorder_injective : Function.Injective (@PartialOrder.toPreorder α) := by
rintro âšâ© âšâ© âšâ©; congr
@[ext]
lemma LinearOrder.toPartialOrder_injective : Function.Injective (@LinearOrder.toPartialOrder α) :=
fun
| { le := A_le, lt := A_lt,
toDecidableLE := A_decidableLE, toDecidableEq := A_decidableEq, toDecidableLT := A_decidableLT
min := A_min, max := A_max, min_def := A_min_def, max_def := A_max_def,
compare := A_compare, compare_eq_compareOfLessAndEq := A_compare_canonical, .. },
{ le := B_le, lt := B_lt,
toDecidableLE := B_decidableLE, toDecidableEq := B_decidableEq, toDecidableLT := B_decidableLT
min := B_min, max := B_max, min_def := B_min_def, max_def := B_max_def,
compare := B_compare, compare_eq_compareOfLessAndEq := B_compare_canonical, .. } => by
rintro âšâ©
obtain rfl : A_decidableLE = B_decidableLE := Subsingleton.elim _ _
obtain rfl : A_decidableEq = B_decidableEq := Subsingleton.elim _ _
obtain rfl : A_decidableLT = B_decidableLT := Subsingleton.elim _ _
have : A_min = B_min := by
funext a b
exact (A_min_def _ _).trans (B_min_def _ _).symm
cases this
have : A_max = B_max := by
funext a b
exact (A_max_def _ _).trans (B_max_def _ _).symm
cases this
have : A_compare = B_compare := by
funext a b
exact (A_compare_canonical _ _).trans (B_compare_canonical _ _).symm
congr
lemma Preorder.ext {A B : Preorder α} (H : â x y : α, (haveI := A; x †y) â x †y) : A = B := by
ext x y; exact H x y
lemma PartialOrder.ext {A B : PartialOrder α} (H : â x y : α, (haveI := A; x †y) â x †y) :
A = B := by ext x y; exact H x y
lemma PartialOrder.ext_lt {A B : PartialOrder α} (H : â x y : α, (haveI := A; x < y) â x < y) :
A = B := by ext x y; rw [le_iff_lt_or_eq, @le_iff_lt_or_eq _ A, H]
lemma LinearOrder.ext {A B : LinearOrder α} (H : â x y : α, (haveI := A; x †y) â x †y) :
A = B := by ext x y; exact H x y
lemma LinearOrder.ext_lt {A B : LinearOrder α} (H : â x y : α, (haveI := A; x < y) â x < y) :
A = B := LinearOrder.toPartialOrder_injective (PartialOrder.ext_lt H)
/-! ### Order dual -/
/-- Type synonym to equip a type with the dual order: `â€` means `â¥` and `<` means `>`. `αáµáµ` is
notation for `OrderDual α`. -/
def OrderDual (α : Type*) : Type _ :=
α
@[inherit_doc]
notation:max α "áµáµ" => OrderDual α
namespace OrderDual
instance (α : Type*) [h : Nonempty α] : Nonempty αáµáµ :=
h
instance (α : Type*) [h : Subsingleton α] : Subsingleton αáµáµ :=
h
instance (α : Type*) [LE α] : LE αáµáµ :=
âšfun x y : α ⊠y †xâ©
instance (α : Type*) [LT α] : LT αáµáµ :=
âšfun x y : α ⊠y < xâ©
instance instOrd (α : Type*) [Ord α] : Ord αáµáµ where
compare := fun (a b : α) ⊠compare b a
instance instSup (α : Type*) [Min α] : Max αáµáµ :=
âš((· â ·) : α â α â α)â©
instance instInf (α : Type*) [Max α] : Min αáµáµ :=
âš((· â ·) : α â α â α)â©
instance instPreorder (α : Type*) [Preorder α] : Preorder αáµáµ where
le_refl := fun _ ⊠le_refl _
le_trans := fun _ _ _ hab hbc ⊠hbc.trans hab
lt_iff_le_not_le := fun _ _ ⊠lt_iff_le_not_le
instance instPartialOrder (α : Type*) [PartialOrder α] : PartialOrder αáµáµ where
__ := inferInstanceAs (Preorder αáµáµ)
le_antisymm := fun a b hab hba ⊠@le_antisymm α _ a b hba hab
instance instLinearOrder (α : Type*) [LinearOrder α] : LinearOrder αáµáµ where
__ := inferInstanceAs (PartialOrder αáµáµ)
__ := inferInstanceAs (Ord αáµáµ)
le_total := fun a b : α ⊠le_total b a
max := fun a b ⊠(min a b : α)
min := fun a b ⊠(max a b : α)
min_def := fun a b ⊠show (max .. : α) = _ by rw [max_comm, max_def]; rfl
max_def := fun a b ⊠show (min .. : α) = _ by rw [min_comm, min_def]; rfl
toDecidableLE := (inferInstance : DecidableRel (fun a b : α ⊠b †a))
toDecidableLT := (inferInstance : DecidableRel (fun a b : α ⊠b < a))
toDecidableEq := (inferInstance : DecidableEq α)
compare_eq_compareOfLessAndEq a b := by
simp only [compare, LinearOrder.compare_eq_compareOfLessAndEq, compareOfLessAndEq, eq_comm]
rfl
/-- The opposite linear order to a given linear order -/
def _root_.LinearOrder.swap (α : Type*) (_ : LinearOrder α) : LinearOrder α :=
inferInstanceAs <| LinearOrder (OrderDual α)
instance : â [Inhabited α], Inhabited αáµáµ := fun [x : Inhabited α] => x
theorem Ord.dual_dual (α : Type*) [H : Ord α] : OrderDual.instOrd αáµáµ = H :=
rfl
theorem Preorder.dual_dual (α : Type*) [H : Preorder α] : OrderDual.instPreorder αáµáµ = H :=
rfl
theorem instPartialOrder.dual_dual (α : Type*) [H : PartialOrder α] :
OrderDual.instPartialOrder αáµáµ = H :=
rfl
theorem instLinearOrder.dual_dual (α : Type*) [H : LinearOrder α] :
OrderDual.instLinearOrder αáµáµ = H :=
rfl
end OrderDual
/-! ### `HasCompl` -/
instance Prop.hasCompl : HasCompl Prop :=
âšNotâ©
instance Pi.hasCompl [â i, HasCompl (Ï i)] : HasCompl (â i, Ï i) :=
âšfun x i ⊠(x i)á¶â©
theorem Pi.compl_def [â i, HasCompl (Ï i)] (x : â i, Ï i) :
xᶠ= fun i ⊠(x i)ᶠ:=
rfl
@[simp]
theorem Pi.compl_apply [â i, HasCompl (Ï i)] (x : â i, Ï i) (i : ι) :
xá¶ i = (x i)á¶ :=
rfl
instance IsIrrefl.compl (r) [IsIrrefl α r] : IsRefl α rᶠ:=
âš@irrefl α r _â©
instance IsRefl.compl (r) [IsRefl α r] : IsIrrefl α rᶠ:=
âšfun a ⊠not_not_intro (refl a)â©
theorem compl_lt [LinearOrder α] : (· < · : α â α â _)á¶ = (· ⥠·) := by ext; simp [compl]
theorem compl_le [LinearOrder α] : (· †· : α â α â _)á¶ = (· > ·) := by ext; simp [compl]
theorem compl_gt [LinearOrder α] : (· > · : α â α â _)á¶ = (· †·) := by ext; simp [compl]
theorem compl_ge [LinearOrder α] : (· ⥠· : α â α â _)á¶ = (· < ·) := by ext; simp [compl]
instance Ne.instIsEquiv_compl : IsEquiv α (· â ·)á¶ := by
convert eq_isEquiv α
simp [compl]
/-! ### Order instances on the function space -/
instance Pi.hasLe [â i, LE (Ï i)] :
LE (â i, Ï i) where le x y := â i, x i †y i
theorem Pi.le_def [â i, LE (Ï i)] {x y : â i, Ï i} :
x †y â â i, x i †y i :=
Iff.rfl
instance Pi.preorder [â i, Preorder (Ï i)] : Preorder (â i, Ï i) where
__ := inferInstanceAs (LE (â i, Ï i))
le_refl := fun a i ⊠le_refl (a i)
le_trans := fun _ _ _ hâ hâ i ⊠le_trans (hâ i) (hâ i)
theorem Pi.lt_def [â i, Preorder (Ï i)] {x y : â i, Ï i} :
x < y â x †y â§ â i, x i < y i := by
simp +contextual [lt_iff_le_not_le, Pi.le_def]
instance Pi.partialOrder [â i, PartialOrder (Ï i)] : PartialOrder (â i, Ï i) where
__ := Pi.preorder
le_antisymm := fun _ _ h1 h2 ⊠funext fun b ⊠(h1 b).antisymm (h2 b)
namespace Sum
variable {αâ αâ : Type*} [LE β]
@[simp]
lemma elim_le_elim_iff {uâ vâ : αâ â β} {uâ vâ : αâ â β} :
Sum.elim uâ uâ †Sum.elim vâ vâ â uâ †vâ â§ uâ †vâ :=
Sum.forall
lemma const_le_elim_iff {b : β} {vâ : αâ â β} {vâ : αâ â β} :
Function.const _ b †Sum.elim vâ vâ â Function.const _ b †vâ â§ Function.const _ b †vâ :=
elim_const_const b âž elim_le_elim_iff ..
lemma elim_le_const_iff {b : β} {uâ : αâ â β} {uâ : αâ â β} :
Sum.elim uâ uâ †Function.const _ b â uâ †Function.const _ b â§ uâ †Function.const _ b :=
elim_const_const b âž elim_le_elim_iff ..
end Sum
section Pi
/-- A function `a` is strongly less than a function `b` if `a i < b i` for all `i`. -/
def StrongLT [â i, LT (Ï i)] (a b : â i, Ï i) : Prop :=
â i, a i < b i
@[inherit_doc]
local infixl:50 " ⺠" => StrongLT
variable [â i, Preorder (Ï i)] {a b c : â i, Ï i}
theorem le_of_strongLT (h : a ⺠b) : a †b := fun _ ⊠(h _).le
theorem lt_of_strongLT [Nonempty ι] (h : a ⺠b) : a < b := by
inhabit ι
exact Pi.lt_def.2 âšle_of_strongLT h, default, h _â©
theorem strongLT_of_strongLT_of_le (hab : a ⺠b) (hbc : b †c) : a ⺠c := fun _ âŠ
(hab _).trans_le <| hbc _
theorem strongLT_of_le_of_strongLT (hab : a †b) (hbc : b ⺠c) : a ⺠c := fun _ âŠ
(hab _).trans_lt <| hbc _
alias StrongLT.le := le_of_strongLT
alias StrongLT.lt := lt_of_strongLT
alias StrongLT.trans_le := strongLT_of_strongLT_of_le
alias LE.le.trans_strongLT := strongLT_of_le_of_strongLT
end Pi
section Function
variable [DecidableEq ι] [â i, Preorder (Ï i)] {x y : â i, Ï i} {i : ι} {a b : Ï i}
theorem le_update_iff : x †Function.update y i a â x i †a â§ â (j) (_ : j â i), x j †y j :=
Function.forall_update_iff _ fun j z ⊠x j †z
theorem update_le_iff : Function.update x i a †y â a †y i â§ â (j) (_ : j â i), x j †y j :=
Function.forall_update_iff _ fun j z ⊠z †y j
theorem update_le_update_iff :
Function.update x i a †Function.update y i b â a †b â§ â (j) (_ : j â i), x j †y j := by
simp +contextual [update_le_iff]
@[simp]
theorem update_le_update_iff' : update x i a †update x i b â a †b := by
simp [update_le_update_iff]
@[simp]
theorem update_lt_update_iff : update x i a < update x i b â a < b :=
lt_iff_lt_of_le_iff_le' update_le_update_iff' update_le_update_iff'
@[simp]
theorem le_update_self_iff : x †update x i a â x i †a := by simp [le_update_iff]
@[simp]
theorem update_le_self_iff : update x i a †x â a †x i := by simp [update_le_iff]
@[simp]
theorem lt_update_self_iff : x < update x i a â x i < a := by simp [lt_iff_le_not_le]
@[simp]
theorem update_lt_self_iff : update x i a < x â a < x i := by simp [lt_iff_le_not_le]
end Function
instance Pi.sdiff [â i, SDiff (Ï i)] : SDiff (â i, Ï i) :=
âšfun x y i ⊠x i \ y iâ©
theorem Pi.sdiff_def [â i, SDiff (Ï i)] (x y : â i, Ï i) :
x \ y = fun i ⊠x i \ y i :=
rfl
@[simp]
theorem Pi.sdiff_apply [â i, SDiff (Ï i)] (x y : â i, Ï i) (i : ι) :
(x \ y) i = x i \ y i :=
rfl
namespace Function
variable [Preorder α] [Nonempty β] {a b : α}
@[simp]
theorem const_le_const : const β a †const β b â a †b := by simp [Pi.le_def]
@[simp]
theorem const_lt_const : const β a < const β b â a < b := by simpa [Pi.lt_def] using le_of_lt
end Function
/-! ### Lifts of order instances -/
/-- Transfer a `Preorder` on `β` to a `Preorder` on `α` using a function `f : α â β`.
See note [reducible non-instances]. -/
abbrev Preorder.lift [Preorder β] (f : α â β) : Preorder α where
le x y := f x †f y
le_refl _ := le_rfl
le_trans _ _ _ := _root_.le_trans
lt x y := f x < f y
lt_iff_le_not_le _ _ := _root_.lt_iff_le_not_le
/-- Transfer a `PartialOrder` on `β` to a `PartialOrder` on `α` using an injective
function `f : α â β`. See note [reducible non-instances]. -/
abbrev PartialOrder.lift [PartialOrder β] (f : α â β) (inj : Injective f) : PartialOrder α :=
{ Preorder.lift f with le_antisymm := fun _ _ hâ hâ ⊠inj (hâ.antisymm hâ) }
theorem compare_of_injective_eq_compareOfLessAndEq (a b : α) [LinearOrder β]
[DecidableEq α] (f : α â β) (inj : Injective f)
[Decidable (LT.lt (self := PartialOrder.lift f inj |>.toLT) a b)] :
compare (f a) (f b) =
@compareOfLessAndEq _ a b (PartialOrder.lift f inj |>.toLT) _ _ := by
have h := LinearOrder.compare_eq_compareOfLessAndEq (f a) (f b)
simp only [h, compareOfLessAndEq]
split_ifs <;> try (first | rfl | contradiction)
· have : ¬ f a = f b := by rename_i h; exact inj.ne h
contradiction
· have : f a = f b := by rename_i h; exact congrArg f h
contradiction
/-- Transfer a `LinearOrder` on `β` to a `LinearOrder` on `α` using an injective
function `f : α â β`. This version takes `[Max α]` and `[Min α]` as arguments, then uses
them for `max` and `min` fields. See `LinearOrder.lift'` for a version that autogenerates `min` and
`max` fields, and `LinearOrder.liftWithOrd` for one that does not auto-generate `compare`
fields. See note [reducible non-instances]. -/
abbrev LinearOrder.lift [LinearOrder β] [Max α] [Min α] (f : α â β) (inj : Injective f)
(hsup : â x y, f (x â y) = max (f x) (f y)) (hinf : â x y, f (x â y) = min (f x) (f y)) :
LinearOrder α :=
letI instOrdα : Ord α := âšfun a b ⊠compare (f a) (f b)â©
letI decidableLE := fun x y ⊠(inferInstance : Decidable (f x †f y))
letI decidableLT := fun x y ⊠(inferInstance : Decidable (f x < f y))
letI decidableEq := fun x y ⊠decidable_of_iff (f x = f y) inj.eq_iff
{ PartialOrder.lift f inj, instOrdα with
le_total := fun x y ⊠le_total (f x) (f y)
toDecidableLE := decidableLE
toDecidableLT := decidableLT
toDecidableEq := decidableEq
min := (· â ·)
max := (· â ·)
min_def := by
intros x y
apply inj
rw [apply_ite f]
exact (hinf _ _).trans (min_def _ _)
max_def := by
intros x y
apply inj
rw [apply_ite f]
exact (hsup _ _).trans (max_def _ _)
compare_eq_compareOfLessAndEq := fun a b âŠ
compare_of_injective_eq_compareOfLessAndEq a b f inj }
/-- Transfer a `LinearOrder` on `β` to a `LinearOrder` on `α` using an injective
function `f : α â β`. This version autogenerates `min` and `max` fields. See `LinearOrder.lift`
for a version that takes `[Max α]` and `[Min α]`, then uses them as `max` and `min`. See
`LinearOrder.liftWithOrd'` for a version which does not auto-generate `compare` fields.
See note [reducible non-instances]. -/
abbrev LinearOrder.lift' [LinearOrder β] (f : α â β) (inj : Injective f) : LinearOrder α :=
@LinearOrder.lift α β _ âšfun x y ⊠if f x †f y then y else xâ©
âšfun x y ⊠if f x †f y then x else yâ© f inj
(fun _ _ ⊠(apply_ite f _ _ _).trans (max_def _ _).symm) fun _ _ âŠ
(apply_ite f _ _ _).trans (min_def _ _).symm
/-- Transfer a `LinearOrder` on `β` to a `LinearOrder` on `α` using an injective
function `f : α â β`. This version takes `[Max α]` and `[Min α]` as arguments, then uses
them for `max` and `min` fields. It also takes `[Ord α]` as an argument and uses them for `compare`
fields. See `LinearOrder.lift` for a version that autogenerates `compare` fields, and
`LinearOrder.liftWithOrd'` for one that auto-generates `min` and `max` fields.
fields. See note [reducible non-instances]. -/
abbrev LinearOrder.liftWithOrd [LinearOrder β] [Max α] [Min α] [Ord α] (f : α â β)
(inj : Injective f) (hsup : â x y, f (x â y) = max (f x) (f y))
(hinf : â x y, f (x â y) = min (f x) (f y))
(compare_f : â a b : α, compare a b = compare (f a) (f b)) : LinearOrder α :=
letI decidableLE := fun x y ⊠(inferInstance : Decidable (f x †f y))
letI decidableLT := fun x y ⊠(inferInstance : Decidable (f x < f y))
letI decidableEq := fun x y ⊠decidable_of_iff (f x = f y) inj.eq_iff
{ PartialOrder.lift f inj with
le_total := fun x y ⊠le_total (f x) (f y)
toDecidableLE := decidableLE
toDecidableLT := decidableLT
toDecidableEq := decidableEq
min := (· â ·)
max := (· â ·)
min_def := by
intros x y
apply inj
rw [apply_ite f]
exact (hinf _ _).trans (min_def _ _)
max_def := by
intros x y
apply inj
rw [apply_ite f]
exact (hsup _ _).trans (max_def _ _)
compare_eq_compareOfLessAndEq := fun a b âŠ
(compare_f a b).trans <| compare_of_injective_eq_compareOfLessAndEq a b f inj }
/-- Transfer a `LinearOrder` on `β` to a `LinearOrder` on `α` using an injective
function `f : α â β`. This version auto-generates `min` and `max` fields. It also takes `[Ord α]`
as an argument and uses them for `compare` fields. See `LinearOrder.lift` for a version that
autogenerates `compare` fields, and `LinearOrder.liftWithOrd` for one that doesn't auto-generate
`min` and `max` fields. fields. See note [reducible non-instances]. -/
abbrev LinearOrder.liftWithOrd' [LinearOrder β] [Ord α] (f : α â β)
(inj : Injective f)
(compare_f : â a b : α, compare a b = compare (f a) (f b)) : LinearOrder α :=
@LinearOrder.liftWithOrd α β _ âšfun x y ⊠if f x †f y then y else xâ©
âšfun x y ⊠if f x †f y then x else yâ© _ f inj
(fun _ _ ⊠(apply_ite f _ _ _).trans (max_def _ _).symm)
(fun _ _ ⊠(apply_ite f _ _ _).trans (min_def _ _).symm)
compare_f
/-! ### Subtype of an order -/
namespace Subtype
instance le [LE α] {p : α â Prop} : LE (Subtype p) :=
âšfun x y ⊠(x : α) †yâ©
instance lt [LT α] {p : α â Prop} : LT (Subtype p) :=
âšfun x y ⊠(x : α) < yâ©
@[simp]
theorem mk_le_mk [LE α] {p : α â Prop} {x y : α} {hx : p x} {hy : p y} :
(âšx, hxâ© : Subtype p) †âšy, hyâ© â x †y :=
Iff.rfl
@[simp]
theorem mk_lt_mk [LT α] {p : α â Prop} {x y : α} {hx : p x} {hy : p y} :
(âšx, hxâ© : Subtype p) < âšy, hyâ© â x < y :=
Iff.rfl
@[simp, norm_cast]
theorem coe_le_coe [LE α] {p : α â Prop} {x y : Subtype p} : (x : α) †y â x †y :=
Iff.rfl
@[gcongr] alias âš_, GCongr.coe_le_coeâ© := coe_le_coe
@[simp, norm_cast]
theorem coe_lt_coe [LT α] {p : α â Prop} {x y : Subtype p} : (x : α) < y â x < y :=
Iff.rfl
@[gcongr] alias âš_, GCongr.coe_lt_coeâ© := coe_lt_coe
instance preorder [Preorder α] (p : α â Prop) : Preorder (Subtype p) :=
Preorder.lift (fun (a : Subtype p) ⊠(a : α))
instance partialOrder [PartialOrder α] (p : α â Prop) : PartialOrder (Subtype p) :=
PartialOrder.lift (fun (a : Subtype p) ⊠(a : α)) Subtype.coe_injective
instance decidableLE [Preorder α] [h : DecidableLE α] {p : α â Prop} :
DecidableLE (Subtype p) := fun a b ⊠h a b
instance decidableLT [Preorder α] [h : DecidableLT α] {p : α â Prop} :
DecidableLT (Subtype p) := fun a b ⊠h a b
/-- A subtype of a linear order is a linear order. We explicitly give the proofs of decidable
equality and decidable order in order to ensure the decidability instances are all definitionally
equal. -/
instance instLinearOrder [LinearOrder α] (p : α â Prop) : LinearOrder (Subtype p) :=
@LinearOrder.lift (Subtype p) _ _ âšfun x y ⊠âšmax x y, max_rec' _ x.2 y.2â©â©
âšfun x y ⊠âšmin x y, min_rec' _ x.2 y.2â©â© (fun (a : Subtype p) ⊠(a : α))
Subtype.coe_injective (fun _ _ ⊠rfl) fun _ _ âŠ
rfl
end Subtype
/-!
### Pointwise order on `α à β`
The lexicographic order is defined in `Data.Prod.Lex`, and the instances are available via the
type synonym `α Ãâ β = α à β`.
-/
namespace Prod
section LE
variable [LE α] [LE β] {x y : α à β} {a aâ aâ : α} {b bâ bâ : β}
instance : LE (α à β) where le p q := p.1 †q.1 ⧠p.2 †q.2
instance instDecidableLE [Decidable (x.1 †y.1)] [Decidable (x.2 †y.2)] : Decidable (x †y) :=
inferInstanceAs (Decidable (x.1 †y.1 ⧠x.2 †y.2))
lemma le_def : x †y â x.1 †y.1 â§ x.2 †y.2 := .rfl
@[simp] lemma mk_le_mk : (aâ, bâ) †(aâ, bâ) â aâ †aâ â§ bâ †bâ := .rfl
@[simp] lemma swap_le_swap : x.swap †y.swap â x †y := and_comm
@[simp] lemma swap_le_mk : x.swap †(b, a) â x †(a, b) := and_comm
@[simp] lemma mk_le_swap : (b, a) †x.swap â (a, b) †x := and_comm
end LE
section Preorder
variable [Preorder α] [Preorder β] {a aâ aâ : α} {b bâ bâ : β} {x y : α à β}
instance : Preorder (α à β) where
__ := inferInstanceAs (LE (α à β))
le_refl := fun âša, b⩠⊠âšle_refl a, le_refl bâ©
le_trans := fun âš_, _â© âš_, _â© âš_, _â© âšhac, hbdâ© âšhce, hdf⩠⊠âšle_trans hac hce, le_trans hbd hdfâ©
@[simp]
theorem swap_lt_swap : x.swap < y.swap â x < y :=
and_congr swap_le_swap (not_congr swap_le_swap)
@[simp] lemma swap_lt_mk : x.swap < (b, a) â x < (a, b) := by rw [â swap_lt_swap]; simp
@[simp] lemma mk_lt_swap : (b, a) < x.swap â (a, b) < x := by rw [â swap_lt_swap]; simp
theorem mk_le_mk_iff_left : (aâ, b) †(aâ, b) â aâ †aâ :=
and_iff_left le_rfl
theorem mk_le_mk_iff_right : (a, bâ) †(a, bâ) â bâ †bâ :=
and_iff_right le_rfl
theorem mk_lt_mk_iff_left : (aâ, b) < (aâ, b) â aâ < aâ :=
lt_iff_lt_of_le_iff_le' mk_le_mk_iff_left mk_le_mk_iff_left
theorem mk_lt_mk_iff_right : (a, bâ) < (a, bâ) â bâ < bâ :=
lt_iff_lt_of_le_iff_le' mk_le_mk_iff_right mk_le_mk_iff_right
theorem lt_iff : x < y â x.1 < y.1 â§ x.2 †y.2 âš x.1 †y.1 â§ x.2 < y.2 := by
refine âšfun h ⊠?_, ?_â©
· by_cases hâ : y.1 †x.1
· exact Or.inr âšh.1.1, LE.le.lt_of_not_le h.1.2 fun hâ ⊠h.2 âšhâ, hââ©â©
· exact Or.inl âšLE.le.lt_of_not_le h.1.1 hâ, h.1.2â©
· rintro (âšhâ, hââ© | âšhâ, hââ©)
· exact âšâšhâ.le, hââ©, fun h ⊠hâ.not_le h.1â©
· exact âšâšhâ, hâ.leâ©, fun h ⊠hâ.not_le h.2â©
@[simp]
theorem mk_lt_mk : (aâ, bâ) < (aâ, bâ) â aâ < aâ â§ bâ †bâ âš aâ †aâ â§ bâ < bâ :=
lt_iff
protected lemma lt_of_lt_of_le (hâ : x.1 < y.1) (hâ : x.2 †y.2) : x < y := by simp [lt_iff, *]
protected lemma lt_of_le_of_lt (hâ : x.1 †y.1) (hâ : x.2 < y.2) : x < y := by simp [lt_iff, *]
lemma mk_lt_mk_of_lt_of_le (hâ : aâ < aâ) (hâ : bâ †bâ) : (aâ, bâ) < (aâ, bâ) := by
simp [lt_iff, *]
lemma mk_lt_mk_of_le_of_lt (hâ : aâ †aâ) (hâ : bâ < bâ) : (aâ, bâ) < (aâ, bâ) := by
simp [lt_iff, *]
end Preorder
/-- The pointwise partial order on a product.
(The lexicographic ordering is defined in `Order.Lexicographic`, and the instances are
available via the type synonym `α Ãâ β = α à β`.) -/
instance instPartialOrder (α β : Type*) [PartialOrder α] [PartialOrder β] :
PartialOrder (α à β) where
__ := inferInstanceAs (Preorder (α à β))
le_antisymm := fun _ _ âšhac, hbdâ© âšhca, hdb⩠⊠Prod.ext (hac.antisymm hca) (hbd.antisymm hdb)
end Prod
/-! ### Additional order classes -/
/-- An order is dense if there is an element between any pair of distinct comparable elements. -/
class DenselyOrdered (α : Type*) [LT α] : Prop where
/-- An order is dense if there is an element between any pair of distinct elements. -/
dense : â aâ aâ : α, aâ < aâ â â a, aâ < a â§ a < aâ
theorem exists_between [LT α] [DenselyOrdered α] : â {aâ aâ : α}, aâ < aâ â â a, aâ < a â§ a < aâ :=
DenselyOrdered.dense _ _
instance OrderDual.denselyOrdered (α : Type*) [LT α] [h : DenselyOrdered α] :
DenselyOrdered αáµáµ :=
âšfun _ _ ha ⊠(@exists_between α _ h _ _ ha).imp fun _ ⊠And.symmâ©
@[simp]
theorem denselyOrdered_orderDual [LT α] : DenselyOrdered αáµáµ â DenselyOrdered α :=
âšby convert @OrderDual.denselyOrdered αáµáµ _, @OrderDual.denselyOrdered α _â©
/-- Any ordered subsingleton is densely ordered. Not an instance to avoid a heavy subsingleton
typeclass search. -/
lemma Subsingleton.instDenselyOrdered {X : Type*} [Subsingleton X] [Preorder X] :
DenselyOrdered X :=
âšfun _ _ h ⊠(not_lt_of_subsingleton h).elimâ©
instance [Preorder α] [Preorder β] [DenselyOrdered α] [DenselyOrdered β] : DenselyOrdered (α à β) :=
âšfun a b ⊠by
simp_rw [Prod.lt_iff]
rintro (âšhâ, hââ© | âšhâ, hââ©)
· obtain âšc, ha, hbâ© := exists_between hâ
exact âš(c, _), Or.inl âšha, hââ©, Or.inl âšhb, le_rflâ©â©
· obtain âšc, ha, hbâ© := exists_between hâ
exact âš(_, c), Or.inr âšhâ, haâ©, Or.inr âšle_rfl, hbâ©â©â©
instance [â i, Preorder (Ï i)] [â i, DenselyOrdered (Ï i)] :
DenselyOrdered (â i, Ï i) :=
âšfun a b ⊠by
classical
simp_rw [Pi.lt_def]
rintro âšhab, i, hiâ©
obtain âšc, ha, hbâ© := exists_between hi
exact
âšFunction.update a i c,
âšle_update_iff.2 âšha.le, fun _ _ ⊠le_rflâ©, i, by rwa [update_self]â©,
update_le_iff.2 âšhb.le, fun _ _ ⊠hab _â©, i, by rwa [update_self]â©â©
section LinearOrder
variable [LinearOrder α] [DenselyOrdered α] {aâ aâ : α}
theorem le_of_forall_gt_imp_ge_of_dense (h : â a, aâ < a â aâ †a) : aâ †aâ :=
le_of_not_gt fun ha âŠ
let âša, haâ, haââ© := exists_between ha
lt_irrefl a <| lt_of_lt_of_le â¹a < aâ⺠(h _ â¹aâ < aâº)
lemma forall_gt_imp_ge_iff_le_of_dense : (â a, aâ < a â aâ †a) â aâ †aâ :=
âšle_of_forall_gt_imp_ge_of_dense, fun ha _a haâ ⊠ha.trans haâ.leâ©
lemma eq_of_le_of_forall_lt_imp_le_of_dense (hâ : aâ †aâ) (hâ : â a, aâ < a â aâ †a) : aâ = aâ :=
le_antisymm (le_of_forall_gt_imp_ge_of_dense hâ) hâ
theorem le_of_forall_lt_imp_le_of_dense (h : â a < aâ, a †aâ) : aâ †aâ :=
le_of_not_gt fun ha âŠ
let âša, haâ, haââ© := exists_between ha
lt_irrefl a <| lt_of_le_of_lt (h _ â¹a < aââº) â¹aâ < aâº
lemma forall_lt_imp_le_iff_le_of_dense : (â a < aâ, a †aâ) â aâ †aâ :=
âšle_of_forall_lt_imp_le_of_dense, fun ha _a haâ ⊠haâ.le.trans haâ©
theorem eq_of_le_of_forall_gt_imp_ge_of_dense (hâ : aâ †aâ) (hâ : â a < aâ, a †aâ) : aâ = aâ :=
(le_of_forall_lt_imp_le_of_dense hâ).antisymm hâ
@[deprecated (since := "2025-01-21")]
alias le_of_forall_le_of_dense := le_of_forall_gt_imp_ge_of_dense
@[deprecated (since := "2025-01-21")]
alias le_of_forall_ge_of_dense := le_of_forall_lt_imp_le_of_dense
@[deprecated (since := "2025-01-21")] alias forall_lt_le_iff := forall_lt_imp_le_iff_le_of_dense
@[deprecated (since := "2025-01-21")] alias forall_gt_ge_iff := forall_gt_imp_ge_iff_le_of_dense
@[deprecated (since := "2025-01-21")]
alias eq_of_le_of_forall_le_of_dense := eq_of_le_of_forall_lt_imp_le_of_dense
@[deprecated (since := "2025-01-21")]
alias eq_of_le_of_forall_ge_of_dense := eq_of_le_of_forall_gt_imp_ge_of_dense
end LinearOrder
theorem dense_or_discrete [LinearOrder α] (aâ aâ : α) :
(â a, aâ < a â§ a < aâ) âš (â a, aâ < a â aâ †a) â§ â a < aâ, a †aâ :=
or_iff_not_imp_left.2 fun h âŠ
âšfun a haâ ⊠le_of_not_gt fun haâ ⊠h âša, haâ, haââ©,
fun a haâ ⊠le_of_not_gt fun haâ ⊠h âša, haâ, haââ©â©
/-- If a linear order has no elements `x < y < z`, then it has at most two elements. -/
lemma eq_or_eq_or_eq_of_forall_not_lt_lt [LinearOrder α]
(h : â âŠx y z : αâŠ, x < y â y < z â False) (x y z : α) : x = y âš y = z âš x = z := by
by_contra hne
simp only [not_or, â Ne.eq_def] at hne
rcases hne.1.lt_or_lt with hâ | hâ <;>
rcases hne.2.1.lt_or_lt with hâ | hâ <;>
rcases hne.2.2.lt_or_lt with hâ | hâ
exacts [h hâ hâ, h hâ hâ, h hâ hâ, h hâ hâ, h hâ hâ, h hâ hâ, h hâ hâ, h hâ hâ]
namespace PUnit
variable (a b : PUnit)
instance instLinearOrder : LinearOrder PUnit where
le := fun _ _ ⊠True
lt := fun _ _ ⊠False
max := fun _ _ ⊠unit
min := fun _ _ ⊠unit
toDecidableEq := inferInstance
toDecidableLE := fun _ _ ⊠Decidable.isTrue trivial
toDecidableLT := fun _ _ ⊠Decidable.isFalse id
le_refl := by intros; trivial
le_trans := by intros; trivial
le_total := by intros; exact Or.inl trivial
le_antisymm := by intros; rfl
lt_iff_le_not_le := by simp only [not_true, and_false, forall_const]
theorem max_eq : max a b = unit :=
rfl
theorem min_eq : min a b = unit :=
rfl
protected theorem le : a †b :=
trivial
theorem not_lt : ¬a < b :=
not_false
instance : DenselyOrdered PUnit :=
âšfun _ _ ⊠False.elimâ©
end PUnit
section «Prop»
/-- Propositions form a complete boolean algebra, where the `â€` relation is given by implication. -/
instance Prop.le : LE Prop :=
âš(· â ·)â©
@[simp]
theorem le_Prop_eq : ((· †·) : Prop â Prop â Prop) = (· â ·) :=
rfl
theorem subrelation_iff_le {r s : α â α â Prop} : Subrelation r s â r †s :=
Iff.rfl
instance Prop.partialOrder : PartialOrder Prop where
__ := Prop.le
le_refl _ := id
le_trans _ _ _ f g := g â f
le_antisymm _ _ Hab Hba := propext âšHab, Hbaâ©
end «Prop»
/-! ### Linear order from a total partial order -/
/-- Type synonym to create an instance of `LinearOrder` from a `PartialOrder` and `IsTotal α (â€)` -/
def AsLinearOrder (α : Type*) :=
α
instance [Inhabited α] : Inhabited (AsLinearOrder α) :=
âš(default : α)â©
noncomputable instance AsLinearOrder.linearOrder [PartialOrder α] [IsTotal α (· †·)] :
LinearOrder (AsLinearOrder α) where
__ := inferInstanceAs (PartialOrder α)
le_total := @total_of α (· †·) _
toDecidableLE := Classical.decRel _
| Mathlib/Order/Basic.lean | 1,540 | 1,542 | |
/-
Copyright (c) 2017 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Kim Morrison, Mario Carneiro, Andrew Yang
-/
import Mathlib.Topology.Category.TopCat.Limits.Products
/-!
# Pullbacks and pushouts in the category of topological spaces
-/
open TopologicalSpace Topology
open CategoryTheory
open CategoryTheory.Limits
universe v u w
noncomputable section
namespace TopCat
variable {J : Type v} [Category.{w} J]
section Pullback
variable {X Y Z : TopCat.{u}}
/-- The first projection from the pullback. -/
abbrev pullbackFst (f : X â¶ Z) (g : Y â¶ Z) : TopCat.of { p : X Ã Y // f p.1 = g p.2 } â¶ X :=
ofHom âšProd.fst â Subtype.val, by fun_propâ©
lemma pullbackFst_apply (f : X â¶ Z) (g : Y â¶ Z) (x) : pullbackFst f g x = x.1.1 := rfl
/-- The second projection from the pullback. -/
abbrev pullbackSnd (f : X â¶ Z) (g : Y â¶ Z) : TopCat.of { p : X Ã Y // f p.1 = g p.2 } â¶ Y :=
ofHom âšProd.snd â Subtype.val, by fun_propâ©
lemma pullbackSnd_apply (f : X â¶ Z) (g : Y â¶ Z) (x) : pullbackSnd f g x = x.1.2 := rfl
/-- The explicit pullback cone of `X, Y` given by `{ p : X Ã Y // f p.1 = g p.2 }`. -/
def pullbackCone (f : X â¶ Z) (g : Y â¶ Z) : PullbackCone f g :=
PullbackCone.mk (pullbackFst f g) (pullbackSnd f g)
(by
dsimp [pullbackFst, pullbackSnd, Function.comp_def]
ext âšx, hâ©
simpa)
/-- The constructed cone is a limit. -/
def pullbackConeIsLimit (f : X â¶ Z) (g : Y â¶ Z) : IsLimit (pullbackCone f g) :=
PullbackCone.isLimitAux' _
(by
intro S
constructor; swap
· exact ofHom
{ toFun := fun x =>
âšâšS.fst x, S.snd xâ©, by simpa using ConcreteCategory.congr_hom S.condition xâ©
continuous_toFun := by fun_prop }
refine âš?_, ?_, ?_â©
· delta pullbackCone
ext a
dsimp
· delta pullbackCone
ext a
dsimp
· intro m hâ hâ
ext x
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): used to be `ext x`.
apply Subtype.ext
apply Prod.ext
· simpa using ConcreteCategory.congr_hom hâ x
· simpa using ConcreteCategory.congr_hom hâ x)
/-- The pullback of two maps can be identified as a subspace of `X Ã Y`. -/
def pullbackIsoProdSubtype (f : X â¶ Z) (g : Y â¶ Z) :
pullback f g â
TopCat.of { p : X Ã Y // f p.1 = g p.2 } :=
(limit.isLimit _).conePointUniqueUpToIso (pullbackConeIsLimit f g)
@[reassoc (attr := simp)]
theorem pullbackIsoProdSubtype_inv_fst (f : X â¶ Z) (g : Y â¶ Z) :
(pullbackIsoProdSubtype f g).inv â« pullback.fst _ _ = pullbackFst f g := by
simp [pullbackCone, pullbackIsoProdSubtype]
theorem pullbackIsoProdSubtype_inv_fst_apply (f : X â¶ Z) (g : Y â¶ Z)
(x : { p : X Ã Y // f p.1 = g p.2 }) :
pullback.fst f g ((pullbackIsoProdSubtype f g).inv x) = (x : X Ã Y).fst :=
ConcreteCategory.congr_hom (pullbackIsoProdSubtype_inv_fst f g) x
@[reassoc (attr := simp)]
theorem pullbackIsoProdSubtype_inv_snd (f : X â¶ Z) (g : Y â¶ Z) :
(pullbackIsoProdSubtype f g).inv â« pullback.snd _ _ = pullbackSnd f g := by
simp [pullbackCone, pullbackIsoProdSubtype]
theorem pullbackIsoProdSubtype_inv_snd_apply (f : X â¶ Z) (g : Y â¶ Z)
(x : { p : X Ã Y // f p.1 = g p.2 }) :
pullback.snd f g ((pullbackIsoProdSubtype f g).inv x) = (x : X Ã Y).snd :=
ConcreteCategory.congr_hom (pullbackIsoProdSubtype_inv_snd f g) x
theorem pullbackIsoProdSubtype_hom_fst (f : X â¶ Z) (g : Y â¶ Z) :
(pullbackIsoProdSubtype f g).hom â« pullbackFst f g = pullback.fst _ _ := by
rw [â Iso.eq_inv_comp, pullbackIsoProdSubtype_inv_fst]
theorem pullbackIsoProdSubtype_hom_snd (f : X â¶ Z) (g : Y â¶ Z) :
(pullbackIsoProdSubtype f g).hom â« pullbackSnd f g = pullback.snd _ _ := by
rw [â Iso.eq_inv_comp, pullbackIsoProdSubtype_inv_snd]
theorem pullbackIsoProdSubtype_hom_apply {f : X â¶ Z} {g : Y â¶ Z}
(x : â(pullback f g)) :
(pullbackIsoProdSubtype f g).hom x =
âšâšpullback.fst f g x, pullback.snd f g xâ©, by
simpa using CategoryTheory.congr_fun pullback.condition xâ© := by
apply Subtype.ext; apply Prod.ext
exacts [ConcreteCategory.congr_hom (pullbackIsoProdSubtype_hom_fst f g) x,
ConcreteCategory.congr_hom (pullbackIsoProdSubtype_hom_snd f g) x]
theorem pullback_topology {X Y Z : TopCat.{u}} (f : X â¶ Z) (g : Y â¶ Z) :
(pullback f g).str =
induced (pullback.fst f g) X.str â
induced (pullback.snd f g) Y.str := by
let homeo := homeoOfIso (pullbackIsoProdSubtype f g)
refine homeo.isInducing.eq_induced.trans ?_
change induced homeo (induced _ ( (induced Prod.fst X.str) â (induced Prod.snd Y.str))) = _
simp only [induced_compose, induced_inf]
congr
theorem range_pullback_to_prod {X Y Z : TopCat} (f : X â¶ Z) (g : Y â¶ Z) :
Set.range (prod.lift (pullback.fst f g) (pullback.snd f g)) =
{ x | (Limits.prod.fst â« f) x = (Limits.prod.snd â« g) x } := by
ext x
constructor
· rintro âšy, rflâ©
simp only [â ConcreteCategory.comp_apply, Set.mem_setOf_eq]
simp [pullback.condition]
· rintro (h : f (_, _).1 = g (_, _).2)
use (pullbackIsoProdSubtype f g).inv âšâš_, _â©, hâ©
apply Concrete.limit_ext
rintro âšâšâ©â© <;>
rw [â ConcreteCategory.comp_apply, â ConcreteCategory.comp_apply, limit.lift_Ï] <;>
-- This used to be `simp` before https://github.com/leanprover/lean4/pull/2644
aesop_cat
/-- The pullback along an embedding is (isomorphic to) the preimage. -/
noncomputable
def pullbackHomeoPreimage
{X Y Z : Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z]
(f : X â Z) (hf : Continuous f) (g : Y â Z) (hg : IsEmbedding g) :
{ p : X à Y // f p.1 = g p.2 } ââ f â»Â¹' Set.range g where
toFun := fun x ⊠âšx.1.1, _, x.2.symmâ©
invFun := fun x ⊠âšâšx.1, Exists.choose x.2â©, (Exists.choose_spec x.2).symmâ©
left_inv := by
intro x
ext <;> dsimp
apply hg.injective
convert x.prop
exact Exists.choose_spec (p := fun y ⊠g y = f (âx : X à Y).1) _
right_inv := fun _ ⊠rfl
continuous_toFun := by fun_prop
continuous_invFun := by
apply Continuous.subtype_mk
refine continuous_subtype_val.prodMk <| hg.isInducing.continuous_iff.mpr ?_
convert hf.comp continuous_subtype_val
ext x
exact Exists.choose_spec x.2
theorem isInducing_pullback_to_prod {X Y Z : TopCat.{u}} (f : X â¶ Z) (g : Y â¶ Z) :
IsInducing <| â(prod.lift (pullback.fst f g) (pullback.snd f g)) :=
âšby simp [prod_topology, pullback_topology, induced_compose, â coe_comp]â©
@[deprecated (since := "2024-10-28")] alias inducing_pullback_to_prod := isInducing_pullback_to_prod
theorem isEmbedding_pullback_to_prod {X Y Z : TopCat.{u}} (f : X â¶ Z) (g : Y â¶ Z) :
IsEmbedding <| â(prod.lift (pullback.fst f g) (pullback.snd f g)) :=
âšisInducing_pullback_to_prod f g, (TopCat.mono_iff_injective _).mp inferInstanceâ©
@[deprecated (since := "2024-10-26")]
alias embedding_pullback_to_prod := isEmbedding_pullback_to_prod
/-- If the map `S â¶ T` is mono, then there is a description of the image of `W Ãâ X â¶ Y Ãâ Z`. -/
theorem range_pullback_map {W X Y Z S T : TopCat} (fâ : W â¶ S) (fâ : X â¶ S) (gâ : Y â¶ T)
(gâ : Z â¶ T) (iâ : W â¶ Y) (iâ : X â¶ Z) (iâ : S â¶ T) [Hâ : Mono iâ] (eqâ : fâ â« iâ = iâ â« gâ)
(eqâ : fâ â« iâ = iâ â« gâ) :
Set.range (pullback.map fâ fâ gâ gâ iâ iâ iâ eqâ eqâ) =
(pullback.fst gâ gâ) â»Â¹' Set.range iâ â© (pullback.snd gâ gâ) â»Â¹' Set.range iâ := by
ext
constructor
· rintro âšy, rflâ©
simp only [Set.mem_inter_iff, Set.mem_preimage, Set.mem_range]
rw [â ConcreteCategory.comp_apply, â ConcreteCategory.comp_apply]
simp only [limit.lift_Ï, PullbackCone.mk_pt, PullbackCone.mk_Ï_app]
exact âšexists_apply_eq_apply _ _, exists_apply_eq_apply _ _â©
rintro âšâšxâ, hxââ©, âšxâ, hxââ©â©
have : fâ xâ = fâ xâ := by
apply (TopCat.mono_iff_injective _).mp Hâ
rw [â ConcreteCategory.comp_apply, eqâ, â ConcreteCategory.comp_apply, eqâ,
ConcreteCategory.comp_apply, ConcreteCategory.comp_apply, hxâ, hxâ,
â ConcreteCategory.comp_apply, pullback.condition, ConcreteCategory.comp_apply]
use (pullbackIsoProdSubtype fâ fâ).inv âšâšxâ, xââ©, thisâ©
apply Concrete.limit_ext
rintro (_ | _ | _) <;>
rw [â ConcreteCategory.comp_apply, â ConcreteCategory.comp_apply]
· simp [hxâ, â limit.w _ WalkingCospan.Hom.inl]
· simp [hxâ]
· simp [hxâ]
theorem pullback_fst_range {X Y S : TopCat} (f : X â¶ S) (g : Y â¶ S) :
Set.range (pullback.fst f g) = { x : X | â y : Y, f x = g y } := by
ext x
constructor
· rintro âšy, rflâ©
use pullback.snd f g y
exact CategoryTheory.congr_fun pullback.condition y
· rintro âšy, eqâ©
use (TopCat.pullbackIsoProdSubtype f g).inv âšâšx, yâ©, eqâ©
rw [pullbackIsoProdSubtype_inv_fst_apply]
theorem pullback_snd_range {X Y S : TopCat} (f : X â¶ S) (g : Y â¶ S) :
Set.range (pullback.snd f g) = { y : Y | â x : X, f x = g y } := by
ext y
constructor
· rintro âšx, rflâ©
use pullback.fst f g x
exact CategoryTheory.congr_fun pullback.condition x
· rintro âšx, eqâ©
use (TopCat.pullbackIsoProdSubtype f g).inv âšâšx, yâ©, eqâ©
rw [pullbackIsoProdSubtype_inv_snd_apply]
/-- If there is a diagram where the morphisms `W â¶ Y` and `X â¶ Z` are embeddings,
then the induced morphism `W Ãâ X â¶ Y Ãâ Z` is also an embedding.
```
W â¶ Y
â â
S â¶ T
â â
X â¶ Z
```
-/
theorem pullback_map_isEmbedding {W X Y Z S T : TopCat.{u}} (fâ : W â¶ S) (fâ : X â¶ S)
(gâ : Y â¶ T) (gâ : Z â¶ T) {iâ : W â¶ Y} {iâ : X â¶ Z} (Hâ : IsEmbedding iâ)
(Hâ : IsEmbedding iâ) (iâ : S â¶ T) (eqâ : fâ â« iâ = iâ â« gâ) (eqâ : fâ â« iâ = iâ â« gâ) :
IsEmbedding (pullback.map fâ fâ gâ gâ iâ iâ iâ eqâ eqâ) := by
refine .of_comp (ContinuousMap.continuous_toFun _)
(show Continuous (prod.lift (pullback.fst gâ gâ) (pullback.snd gâ gâ)) from
ContinuousMap.continuous_toFun _)
?_
suffices
IsEmbedding (prod.lift (pullback.fst fâ fâ) (pullback.snd fâ fâ) â« Limits.prod.map iâ iâ) by
simpa [â coe_comp] using this
rw [coe_comp]
exact (isEmbedding_prodMap Hâ Hâ).comp (isEmbedding_pullback_to_prod _ _)
@[deprecated (since := "2024-10-26")]
alias pullback_map_embedding_of_embeddings := pullback_map_isEmbedding
/-- If there is a diagram where the morphisms `W â¶ Y` and `X â¶ Z` are open embeddings, and `S â¶ T`
is mono, then the induced morphism `W Ãâ X â¶ Y Ãâ Z` is also an open embedding.
```
W â¶ Y
â â
S â¶ T
â â
X â¶ Z
```
-/
theorem pullback_map_isOpenEmbedding {W X Y Z S T : TopCat.{u}} (fâ : W â¶ S)
(fâ : X â¶ S) (gâ : Y â¶ T) (gâ : Z â¶ T) {iâ : W â¶ Y} {iâ : X â¶ Z} (Hâ : IsOpenEmbedding iâ)
(Hâ : IsOpenEmbedding iâ) (iâ : S â¶ T) [Hâ : Mono iâ] (eqâ : fâ â« iâ = iâ â« gâ)
(eqâ : fâ â« iâ = iâ â« gâ) : IsOpenEmbedding (pullback.map fâ fâ gâ gâ iâ iâ iâ eqâ eqâ) := by
constructor
· apply
pullback_map_isEmbedding fâ fâ gâ gâ Hâ.isEmbedding Hâ.isEmbedding iâ eqâ eqâ
· rw [range_pullback_map]
apply IsOpen.inter <;> apply Continuous.isOpen_preimage
· apply ContinuousMap.continuous_toFun
· exact Hâ.isOpen_range
· apply ContinuousMap.continuous_toFun
· exact Hâ.isOpen_range
lemma snd_isEmbedding_of_left {X Y S : TopCat} {f : X â¶ S} (H : IsEmbedding f) (g : Y â¶ S) :
| IsEmbedding <| â(pullback.snd f g) := by
convert (homeoOfIso (asIso (pullback.snd (ð S) g))).isEmbedding.comp
(pullback_map_isEmbedding (iâ := ð Y)
f g (ð S) g H (homeoOfIso (Iso.refl _)).isEmbedding (ð _) rfl (by simp))
simp [homeoOfIso, â coe_comp]
@[deprecated (since := "2024-10-26")]
alias snd_embedding_of_left_embedding := snd_isEmbedding_of_left
theorem fst_isEmbedding_of_right {X Y S : TopCat} (f : X â¶ S) {g : Y â¶ S}
(H : IsEmbedding g) : IsEmbedding <| â(pullback.fst f g) := by
convert (homeoOfIso (asIso (pullback.fst f (ð S)))).isEmbedding.comp
(pullback_map_isEmbedding (iâ := ð X)
f g f (ð _) (homeoOfIso (Iso.refl _)).isEmbedding H (ð _) rfl (by simp))
| Mathlib/Topology/Category/TopCat/Limits/Pullbacks.lean | 283 | 296 |
/-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Floris van Doorn
-/
import Mathlib.Geometry.Manifold.MFDeriv.Tangent
import Mathlib.Geometry.Manifold.ContMDiffMap
import Mathlib.Geometry.Manifold.VectorBundle.Hom
/-!
### Interactions between differentiability, smoothness and manifold derivatives
We give the relation between `MDifferentiable`, `ContMDiff`, `mfderiv`, `tangentMap`
and related notions.
## Main statements
* `ContMDiffOn.contMDiffOn_tangentMapWithin` states that the bundled derivative
of a `Câ¿` function in a domain is `Cáµ` when `m + 1 †n`.
* `ContMDiff.contMDiff_tangentMap` states that the bundled derivative
of a `Câ¿` function is `Cáµ` when `m + 1 †n`.
-/
open Set Function Filter ChartedSpace IsManifold Bundle
open scoped Topology Manifold Bundle
/-! ### Definition of `C^n` functions between manifolds -/
variable {ð : Type*} [NontriviallyNormedField ð] {m n : WithTop ââ}
-- declare a charted space `M` over the pair `(E, H)`.
{E : Type*}
[NormedAddCommGroup E] [NormedSpace ð E] {H : Type*} [TopologicalSpace H]
{I : ModelWithCorners ð E H} {M : Type*} [TopologicalSpace M] [ChartedSpace H M]
-- declare a charted space `M'` over the pair `(E', H')`.
{E' : Type*}
[NormedAddCommGroup E'] [NormedSpace ð E'] {H' : Type*} [TopologicalSpace H']
{I' : ModelWithCorners ð E' H'} {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M']
-- declare a `C^n` manifold `N` over the pair `(F, G)`.
{F : Type*}
[NormedAddCommGroup F] [NormedSpace ð F] {G : Type*} [TopologicalSpace G]
{J : ModelWithCorners ð F G} {N : Type*} [TopologicalSpace N] [ChartedSpace G N]
[Js : IsManifold J 1 N]
-- declare a charted space `N'` over the pair `(F', G')`.
{F' : Type*}
[NormedAddCommGroup F'] [NormedSpace ð F'] {G' : Type*} [TopologicalSpace G']
{J' : ModelWithCorners ð F' G'} {N' : Type*} [TopologicalSpace N'] [ChartedSpace G' N']
-- declare functions, sets
{f : M â M'} {s : Set M}
-- Porting note: section about deducing differentiability for `C^n` functions moved to
-- `Geometry.Manifold.MFDeriv.Basic`
/-! ### The derivative of a `C^(n+1)` function is `C^n` -/
section mfderiv
variable [Is : IsManifold I 1 M] [I's : IsManifold I' 1 M']
/-- The function that sends `x` to the `y`-derivative of `f (x, y)` at `g (x)` is `C^m` at `xâ`,
where the derivative is taken as a continuous linear map.
We have to assume that `f` is `C^n` at `(xâ, g(xâ))` for `n ⥠m + 1` and `g` is `C^m` at `xâ`.
We have to insert a coordinate change from `xâ` to `x` to make the derivative sensible.
Version within a set.
-/
protected theorem ContMDiffWithinAt.mfderivWithin {xâ : N} {f : N â M â M'} {g : N â M}
{t : Set N} {u : Set M}
(hf : ContMDiffWithinAt (J.prod I) I' n (Function.uncurry f) (t ÃË¢ u) (xâ, g xâ))
(hg : ContMDiffWithinAt J I m g t xâ) (hxâ : xâ â t)
(hu : MapsTo g t u) (hmn : m + 1 †n) (h'u : UniqueMDiffOn I u) :
ContMDiffWithinAt J ð(ð, E âL[ð] E') m
(inTangentCoordinates I I' g (fun x => f x (g x))
(fun x => mfderivWithin I I' (f x) u (g x)) xâ) t xâ := by
-- first localize the result to a smaller set, to make sure everything happens in chart domains
let t' := t â© g â»Â¹' ((extChartAt I (g xâ)).source)
have ht't : t' â t := inter_subset_left
suffices ContMDiffWithinAt J ð(ð, E âL[ð] E') m
(inTangentCoordinates I I' g (fun x ⊠f x (g x))
(fun x ⊠mfderivWithin I I' (f x) u (g x)) xâ) t' xâ by
apply ContMDiffWithinAt.mono_of_mem_nhdsWithin this
apply inter_mem self_mem_nhdsWithin
exact hg.continuousWithinAt.preimage_mem_nhdsWithin (extChartAt_source_mem_nhds (g xâ))
-- register a few basic facts that maps send suitable neighborhoods to suitable neighborhoods,
-- by continuity
have hxâgxâ : (xâ, g xâ) â t ÃË¢ u := by simp [hxâ, hu hxâ]
have h4f : ContinuousWithinAt (fun x => f x (g x)) t xâ := by
change ContinuousWithinAt ((Function.uncurry f) â (fun x ⊠(x, g x))) t xâ
refine ContinuousWithinAt.comp hf.continuousWithinAt ?_ (fun y hy ⊠by simp [hy, hu hy])
exact (continuousWithinAt_id.prodMk hg.continuousWithinAt)
have h4f := h4f.preimage_mem_nhdsWithin (extChartAt_source_mem_nhds (I := I') (f xâ (g xâ)))
have h3f := (contMDiffWithinAt_iff_contMDiffWithinAt_nhdsWithin (by simp)).mp
(hf.of_le <| (self_le_add_left 1 m).trans hmn)
simp only [Nat.cast_one, hxâgxâ, insert_eq_of_mem] at h3f
have h2f : âá¶ xâ in ð[t] xâ, ContMDiffWithinAt I I' 1 (f xâ) u (g xâ) := by
have : MapsTo (fun x ⊠(x, g x)) t (t ÃË¢ u) := fun y hy ⊠by simp [hy, hu hy]
filter_upwards [((continuousWithinAt_id.prodMk hg.continuousWithinAt)
|>.tendsto_nhdsWithin this).eventually h3f, self_mem_nhdsWithin] with x hx h'x
apply hx.comp (g x) (contMDiffWithinAt_const.prodMk contMDiffWithinAt_id)
exact fun y hy ⊠by simp [h'x, hy]
have h2g : g â»Â¹' (extChartAt I (g xâ)).source â ð[t] xâ :=
hg.continuousWithinAt.preimage_mem_nhdsWithin (extChartAt_source_mem_nhds (g xâ))
-- key point: the derivative of `f` composed with extended charts, at the point `g x` read in the
-- chart, is `C^n` in the vector space sense. This follows from `ContDiffWithinAt.fderivWithin`,
-- which is the vector space analogue of the result we are proving.
have : ContDiffWithinAt ð m (fun x ⊠fderivWithin ð
(extChartAt I' (f xâ (g xâ)) â f ((extChartAt J xâ).symm x) â (extChartAt I (g xâ)).symm)
((extChartAt I (g xâ)).target â© (extChartAt I (g xâ)).symm â»Â¹' u)
(extChartAt I (g xâ) (g ((extChartAt J xâ).symm x))))
((extChartAt J xâ).symm â»Â¹' t' â© range J) (extChartAt J xâ xâ) := by
have hf' := hf.mono (prod_mono_left ht't)
have hg' := hg.mono (show t' â t from inter_subset_left)
rw [contMDiffWithinAt_iff] at hf' hg'
simp_rw [Function.comp_def, uncurry, extChartAt_prod, PartialEquiv.prod_coe_symm,
ModelWithCorners.range_prod] at hf' â¢
apply ContDiffWithinAt.fderivWithin _ _ _ (show (m : WithTop ââ) + 1 †n from mod_cast hmn )
· simp [hxâ, t']
· apply inter_subset_left.trans
rw [preimage_subset_iff]
intro a ha
refine âšPartialEquiv.map_source _ (inter_subset_right ha :), ?_â©
rw [mem_preimage, PartialEquiv.left_inv (extChartAt I (g xâ))]
· exact hu (inter_subset_left ha)
· exact (inter_subset_right ha :)
· have : ((fun p ⊠((extChartAt J xâ).symm p.1, (extChartAt I (g xâ)).symm p.2)) â»Â¹' t' ÃË¢ u
â© range J ÃË¢ (extChartAt I (g xâ)).target)
â ((fun p ⊠((extChartAt J xâ).symm p.1, (extChartAt I (g xâ)).symm p.2)) â»Â¹' t' ÃË¢ u
â© range J ÃË¢ range I) := by
apply inter_subset_inter_right
exact Set.prod_mono_right (extChartAt_target_subset_range (g xâ))
convert hf'.2.mono this
· ext y; simp; tauto
· simp
· exact hg'.2
· exact UniqueMDiffOn.uniqueDiffOn_target_inter h'u (g xâ)
-- reformulate the previous point as `C^n` in the manifold sense (but still for a map between
-- vector spaces)
have :
ContMDiffWithinAt J ð(ð, E âL[ð] E') m
(fun x =>
fderivWithin ð (extChartAt I' (f xâ (g xâ)) â f x â (extChartAt I (g xâ)).symm)
((extChartAt I (g xâ)).target â© (extChartAt I (g xâ)).symm â»Â¹' u)
(extChartAt I (g xâ) (g x))) t' xâ := by
simp_rw [contMDiffWithinAt_iff_source (x := xâ),
contMDiffWithinAt_iff_contDiffWithinAt, Function.comp_def]
exact this
-- finally, argue that the map we control in the previous point coincides locally with the map we
-- want to prove the regularity of, so regularity of the latter follows from regularity of the
-- former.
apply this.congr_of_eventuallyEq_of_mem _ (by simp [t', hxâ])
apply nhdsWithin_mono _ ht't
filter_upwards [h2f, h4f, h2g, self_mem_nhdsWithin] with x hx h'x h2 hxt
have h1 : g x â u := hu hxt
have h3 : UniqueMDiffWithinAt ð(ð, E)
((extChartAt I (g xâ)).target â© (extChartAt I (g xâ)).symm â»Â¹' u)
((extChartAt I (g xâ)) (g x)) := by
apply UniqueDiffWithinAt.uniqueMDiffWithinAt
apply UniqueMDiffOn.uniqueDiffOn_target_inter h'u
refine âšPartialEquiv.map_source _ h2, ?_â©
rwa [mem_preimage, PartialEquiv.left_inv _ h2]
have A : mfderivWithin ð(ð, E) I ((extChartAt I (g xâ)).symm)
(range I) ((extChartAt I (g xâ)) (g x))
= mfderivWithin ð(ð, E) I ((extChartAt I (g xâ)).symm)
((extChartAt I (g xâ)).target â© (extChartAt I (g xâ)).symm â»Â¹' u)
((extChartAt I (g xâ)) (g x)) := by
apply (MDifferentiableWithinAt.mfderivWithin_mono _ h3 _).symm
· apply mdifferentiableWithinAt_extChartAt_symm
exact PartialEquiv.map_source (extChartAt I (g xâ)) h2
· exact inter_subset_left.trans (extChartAt_target_subset_range (g xâ))
rw [inTangentCoordinates_eq_mfderiv_comp, A,
â mfderivWithin_comp_of_eq, â mfderiv_comp_mfderivWithin_of_eq]
· exact mfderivWithin_eq_fderivWithin
· exact mdifferentiableAt_extChartAt (by simpa using h'x)
· apply MDifferentiableWithinAt.comp (I' := I) (u := u) _ _ _ inter_subset_right
· convert hx.mdifferentiableWithinAt le_rfl
exact PartialEquiv.left_inv (extChartAt I (g xâ)) h2
· apply (mdifferentiableWithinAt_extChartAt_symm _).mono
· exact inter_subset_left.trans (extChartAt_target_subset_range (g xâ))
· exact PartialEquiv.map_source (extChartAt I (g xâ)) h2
· exact h3
· simp only [Function.comp_def, PartialEquiv.left_inv (extChartAt I (g xâ)) h2]
· exact hx.mdifferentiableWithinAt le_rfl
· apply (mdifferentiableWithinAt_extChartAt_symm _).mono
· exact inter_subset_left.trans (extChartAt_target_subset_range (g xâ))
· exact PartialEquiv.map_source (extChartAt I (g xâ)) h2
· exact inter_subset_right
· exact h3
· exact PartialEquiv.left_inv (extChartAt I (g xâ)) h2
· simpa using h2
· simpa using h'x
/-- The derivative `D_yf(y)` is `C^m` at `xâ`, where the derivative is taken as a continuous
linear map. We have to assume that `f` is `C^n` at `xâ` for some `n ⥠m + 1`.
We have to insert a coordinate change from `xâ` to `x` to make the derivative sensible.
This is a special case of `ContMDiffWithinAt.mfderivWithin` where `f` does not contain any
parameters and `g = id`.
-/
theorem ContMDiffWithinAt.mfderivWithin_const {xâ : M} {f : M â M'}
(hf : ContMDiffWithinAt I I' n f s xâ)
(hmn : m + 1 †n) (hx : xâ â s) (hs : UniqueMDiffOn I s) :
ContMDiffWithinAt I ð(ð, E âL[ð] E') m
(inTangentCoordinates I I' id f (mfderivWithin I I' f s) xâ) s xâ := by
have : ContMDiffWithinAt (I.prod I) I' n (fun x : M Ã M => f x.2) (s ÃË¢ s) (xâ, xâ) :=
ContMDiffWithinAt.comp (xâ, xâ) hf contMDiffWithinAt_snd mapsTo_snd_prod
exact this.mfderivWithin contMDiffWithinAt_id hx (mapsTo_id _) hmn hs
/-- The function that sends `x` to the `y`-derivative of `f(x,y)` at `g(x)` applied to `gâ(x)` is
`C^n` at `xâ`, where the derivative is taken as a continuous linear map.
We have to assume that `f` is `C^(n+1)` at `(xâ, g(xâ))` and `g` is `C^n` at `xâ`.
We have to insert a coordinate change from `xâ` to `gâ(x)` to make the derivative sensible.
This is similar to `ContMDiffWithinAt.mfderivWithin`, but where the continuous linear map is
applied to a (variable) vector.
-/
theorem ContMDiffWithinAt.mfderivWithin_apply {xâ : N'}
{f : N â M â M'} {g : N â M} {gâ : N' â N} {gâ : N' â E} {t : Set N} {u : Set M} {v : Set N'}
(hf : ContMDiffWithinAt (J.prod I) I' n (Function.uncurry f) (t ÃË¢ u) (gâ xâ, g (gâ xâ)))
(hg : ContMDiffWithinAt J I m g t (gâ xâ)) (hgâ : ContMDiffWithinAt J' J m gâ v xâ)
(hgâ : ContMDiffWithinAt J' ð(ð, E) m gâ v xâ) (hmn : m + 1 †n) (h'gâ : MapsTo gâ v t)
(hgâxâ : gâ xâ â t) (h'g : MapsTo g t u) (hu : UniqueMDiffOn I u) :
ContMDiffWithinAt J' ð(ð, E') m
(fun x => (inTangentCoordinates I I' g (fun x => f x (g x))
(fun x => mfderivWithin I I' (f x) u (g x)) (gâ xâ) (gâ x)) (gâ x)) v xâ :=
((hf.mfderivWithin hg hgâxâ h'g hmn hu).comp_of_eq hgâ h'gâ rfl).clm_apply hgâ
/-- The function that sends `x` to the `y`-derivative of `f (x, y)` at `g (x)` is `C^m` at `xâ`,
where the derivative is taken as a continuous linear map.
We have to assume that `f` is `C^n` at `(xâ, g(xâ))` for `n ⥠m + 1` and `g` is `C^m` at `xâ`.
We have to insert a coordinate change from `xâ` to `x` to make the derivative sensible.
This result is used to show that maps into the 1-jet bundle and cotangent bundle are `C^n`.
`ContMDiffAt.mfderiv_const` is a special case of this.
-/
protected theorem ContMDiffAt.mfderiv {xâ : N} (f : N â M â M') (g : N â M)
(hf : ContMDiffAt (J.prod I) I' n (Function.uncurry f) (xâ, g xâ)) (hg : ContMDiffAt J I m g xâ)
(hmn : m + 1 †n) :
ContMDiffAt J ð(ð, E âL[ð] E') m
(inTangentCoordinates I I' g (fun x ⊠f x (g x)) (fun x ⊠mfderiv I I' (f x) (g x)) xâ)
xâ := by
rw [â contMDiffWithinAt_univ] at hf hg â¢
rw [â univ_prod_univ] at hf
simp_rw [â mfderivWithin_univ]
exact ContMDiffWithinAt.mfderivWithin hf hg (mem_univ _) (mapsTo_univ _ _) hmn
uniqueMDiffOn_univ
/-- The derivative `D_yf(y)` is `C^m` at `xâ`, where the derivative is taken as a continuous
linear map. We have to assume that `f` is `C^n` at `xâ` for some `n ⥠m + 1`.
We have to insert a coordinate change from `xâ` to `x` to make the derivative sensible.
This is a special case of `ContMDiffAt.mfderiv` where `f` does not contain any parameters and
`g = id`.
-/
theorem ContMDiffAt.mfderiv_const {xâ : M} {f : M â M'} (hf : ContMDiffAt I I' n f xâ)
(hmn : m + 1 †n) :
ContMDiffAt I ð(ð, E âL[ð] E') m (inTangentCoordinates I I' id f (mfderiv I I' f) xâ) xâ :=
haveI : ContMDiffAt (I.prod I) I' n (fun x : M Ã M => f x.2) (xâ, xâ) :=
ContMDiffAt.comp (xâ, xâ) hf contMDiffAt_snd
this.mfderiv (fun _ => f) id contMDiffAt_id hmn
/-- The function that sends `x` to the `y`-derivative of `f(x,y)` at `g(x)` applied to `gâ(x)` is
`C^n` at `xâ`, where the derivative is taken as a continuous linear map.
We have to assume that `f` is `C^(n+1)` at `(xâ, g(xâ))` and `g` is `C^n` at `xâ`.
We have to insert a coordinate change from `xâ` to `gâ(x)` to make the derivative sensible.
This is similar to `ContMDiffAt.mfderiv`, but where the continuous linear map is applied to a
(variable) vector.
-/
theorem ContMDiffAt.mfderiv_apply {xâ : N'} (f : N â M â M') (g : N â M) (gâ : N' â N) (gâ : N' â E)
(hf : ContMDiffAt (J.prod I) I' n (Function.uncurry f) (gâ xâ, g (gâ xâ)))
(hg : ContMDiffAt J I m g (gâ xâ)) (hgâ : ContMDiffAt J' J m gâ xâ)
(hgâ : ContMDiffAt J' ð(ð, E) m gâ xâ) (hmn : m + 1 †n) :
ContMDiffAt J' ð(ð, E') m
(fun x => inTangentCoordinates I I' g (fun x => f x (g x))
(fun x => mfderiv I I' (f x) (g x)) (gâ xâ) (gâ x) (gâ x)) xâ :=
((hf.mfderiv f g hg hmn).comp_of_eq hgâ rfl).clm_apply hgâ
end mfderiv
/-! ### The tangent map of a `C^(n+1)` function is `C^n` -/
section tangentMap
variable [Is : IsManifold I 1 M] [I's : IsManifold I' 1 M']
/-- If a function is `C^n` on a domain with unique derivatives, then its bundled derivative
is `C^m` when `m+1 †n`. -/
theorem ContMDiffOn.contMDiffOn_tangentMapWithin
(hf : ContMDiffOn I I' n f s) (hmn : m + 1 †n)
(hs : UniqueMDiffOn I s) :
ContMDiffOn I.tangent I'.tangent m (tangentMapWithin I I' f s)
(Ï E (TangentSpace I) â»Â¹' s) := by
intro xâ hxâ
let s' : Set (TangentBundle I M) := (Ï E (TangentSpace I) â»Â¹' s)
let bâ : TangentBundle I M â M := fun p ⊠p.1
let v : Î (y : TangentBundle I M), TangentSpace I (bâ y) := fun y ⊠y.2
have hv : ContMDiffWithinAt I.tangent I.tangent m (fun y ⊠(v y : TangentBundle I M)) s' xâ :=
contMDiffWithinAt_id
let bâ : TangentBundle I M â M' := f â bâ
have hbâ : ContMDiffWithinAt I.tangent I' m bâ s' xâ :=
((hf (bâ xâ) hxâ).of_le (le_self_add.trans hmn)).comp _
(contMDiffWithinAt_proj (TangentSpace I)) (fun x h ⊠h)
let Ï : Î (y : TangentBundle I M), TangentSpace I (bâ y) âL[ð] TangentSpace I' (bâ y) :=
fun y ⊠mfderivWithin I I' f s (bâ y)
have hÏ : ContMDiffWithinAt I.tangent ð(ð, E âL[ð] E') m
(fun y ⊠ContinuousLinearMap.inCoordinates E (TangentSpace I (M := M)) E'
(TangentSpace I' (M := M')) (bâ xâ) (bâ y) (bâ xâ) (bâ y) (Ï y))
s' xâ := by
have A : ContMDiffWithinAt I ð(ð, E âL[ð] E') m
(fun y ⊠ContinuousLinearMap.inCoordinates E (TangentSpace I (M := M)) E'
(TangentSpace I' (M := M')) (bâ xâ) y (bâ xâ) (f y) (mfderivWithin I I' f s y))
s (bâ xâ) :=
ContMDiffWithinAt.mfderivWithin_const (hf _ hxâ) hmn hxâ hs
exact A.comp _ (contMDiffWithinAt_proj (TangentSpace I)) (fun x h ⊠h)
exact ContMDiffWithinAt.clm_apply_of_inCoordinates hÏ hv hbâ
/-- If a function is `C^n` on a domain with unique derivatives, with `1 †n`, then its bundled
derivative is continuous there. -/
theorem ContMDiffOn.continuousOn_tangentMapWithin (hf : ContMDiffOn I I' n f s) (hmn : 1 †n)
(hs : UniqueMDiffOn I s) :
ContinuousOn (tangentMapWithin I I' f s) (Ï E (TangentSpace I) â»Â¹' s) := by
have :
ContMDiffOn I.tangent I'.tangent 0 (tangentMapWithin I I' f s) (Ï E (TangentSpace I) â»Â¹' s) :=
hf.contMDiffOn_tangentMapWithin hmn hs
exact this.continuousOn
/-- If a function is `C^n`, then its bundled derivative is `C^m` when `m+1 †n`. -/
theorem ContMDiff.contMDiff_tangentMap (hf : ContMDiff I I' n f) (hmn : m + 1 †n) :
ContMDiff I.tangent I'.tangent m (tangentMap I I' f) := by
rw [â contMDiffOn_univ] at hf â¢
convert hf.contMDiffOn_tangentMapWithin hmn uniqueMDiffOn_univ
rw [tangentMapWithin_univ]
/-- If a function is `C^n`, with `1 †n`, then its bundled derivative is continuous. -/
theorem ContMDiff.continuous_tangentMap (hf : ContMDiff I I' n f) (hmn : 1 †n) :
Continuous (tangentMap I I' f) := by
rw [â contMDiffOn_univ] at hf
rw [continuous_iff_continuousOn_univ]
convert hf.continuousOn_tangentMapWithin hmn uniqueMDiffOn_univ
rw [tangentMapWithin_univ]
@[deprecated (since := "2024-11-21")] alias Smooth.tangentMap := ContMDiff.contMDiff_tangentMap
end tangentMap
namespace TangentBundle
| open Bundle
/-- The derivative of the zero section of the tangent bundle maps `âšx, vâ©` to `âšâšx, 0â©, âšv, 0â©â©`.
Note that, as currently framed, this is a statement in coordinates, thus reliant on the choice
of the coordinate system we use on the tangent bundle.
However, the result itself is coordinate-dependent only to the extent that the coordinates
determine a splitting of the tangent bundle. Moreover, there is a canonical splitting at each
point of the zero section (since there is a canonical horizontal space there, the tangent space
to the zero section, in addition to the canonical vertical space which is the kernel of the
derivative of the projection), and this canonical splitting is also the one that comes from the
coordinates on the tangent bundle in our definitions. So this statement is not as crazy as it
may seem.
TODO define splittings of vector bundles; state this result invariantly. -/
theorem tangentMap_tangentBundle_pure [Is : IsManifold I 1 M]
(p : TangentBundle I M) :
tangentMap I I.tangent (zeroSection E (TangentSpace I)) p = âšâšp.proj, 0â©, âšp.2, 0â©â© := by
rcases p with âšx, vâ©
have N : I.symm â»Â¹' (chartAt H x).target â ð (I ((chartAt H x) x)) := by
apply IsOpen.mem_nhds
· apply (PartialHomeomorph.open_target _).preimage I.continuous_invFun
· simp only [mfld_simps]
have A : MDifferentiableAt I I.tangent (fun x => @TotalSpace.mk M E (TangentSpace I) x 0) x :=
haveI : ContMDiff I (I.prod ð(ð, E)) †(zeroSection E (TangentSpace I : M â Type _)) :=
Bundle.contMDiff_zeroSection ð (TangentSpace I : M â Type _)
this.mdifferentiableAt le_top
have B : fderivWithin ð (fun x' : E ⊠(x', (0 : E))) (Set.range I) (I ((chartAt H x) x)) v
= (v, 0) := by
rw [fderivWithin_eq_fderiv, DifferentiableAt.fderiv_prodMk]
· simp
· exact differentiableAt_id'
· exact differentiableAt_const _
· exact ModelWithCorners.uniqueDiffWithinAt_image I
· exact differentiableAt_id'.prodMk (differentiableAt_const _)
simp +unfoldPartialApp only [Bundle.zeroSection, tangentMap, mfderiv, A,
if_pos, chartAt, FiberBundle.chartedSpace_chartAt, TangentBundle.trivializationAt_apply,
tangentBundleCore, Function.comp_def, ContinuousLinearMap.map_zero, mfld_simps]
rw [â fderivWithin_inter N] at B
rw [â fderivWithin_inter N, â B]
congr 1
refine fderivWithin_congr (fun y hy => ?_) ?_
· simp only [mfld_simps] at hy
simp only [hy, Prod.mk_inj, mfld_simps]
· simp only [Prod.mk_inj, mfld_simps]
end TangentBundle
namespace ContMDiffMap
-- These helpers for dot notation have been moved here from
-- `Mathlib/Geometry/Manifold/ContMDiffMap.lean` to avoid needing to import this file there.
-- (However as a consequence we import `Mathlib/Geometry/Manifold/ContMDiffMap.lean` here now.)
-- They could be moved to another file (perhaps a new file) if desired.
open scoped Manifold ContDiff
protected theorem mdifferentiable' (f : C^nâ®I, M; I', M'â¯) (hn : 1 †n) : MDifferentiable I I' f :=
f.contMDiff.mdifferentiable hn
protected theorem mdifferentiable (f : C^ââ®I, M; I', M'â¯) : MDifferentiable I I' f :=
f.contMDiff.mdifferentiable (mod_cast le_top)
protected theorem mdifferentiableAt (f : C^ââ®I, M; I', M'â¯) {x} : MDifferentiableAt I I' f x :=
f.mdifferentiable x
end ContMDiffMap
section EquivTangentBundleProd
variable (I I' M M') in
/-- The tangent bundle of a product is canonically isomorphic to the product of the tangent
bundles. -/
@[simps] def equivTangentBundleProd :
TangentBundle (I.prod I') (M Ã M') â (TangentBundle I M) Ã (TangentBundle I' M') where
toFun p := (âšp.1.1, p.2.1â©, âšp.1.2, p.2.2â©)
invFun p := âš(p.1.1, p.2.1), (p.1.2, p.2.2)â©
left_inv _ := rfl
right_inv _ := rfl
lemma equivTangentBundleProd_eq_tangentMap_prod_tangentMap :
equivTangentBundleProd I M I' M' = fun (p : TangentBundle (I.prod I') (M à M')) âŠ
(tangentMap (I.prod I') I Prod.fst p, tangentMap (I.prod I') I' Prod.snd p) := by
simp only [tangentMap_prodFst, tangentMap_prodSnd]; rfl
variable [IsManifold I 1 M] [IsManifold I' 1 M']
/-- The canonical equivalence between the tangent bundle of a product and the product of
tangent bundles is smooth. -/
lemma contMDiff_equivTangentBundleProd :
ContMDiff (I.prod I').tangent (I.tangent.prod I'.tangent) n
(equivTangentBundleProd I M I' M') := by
rw [equivTangentBundleProd_eq_tangentMap_prod_tangentMap]
exact (contMDiff_fst.contMDiff_tangentMap le_rfl).prodMk
(contMDiff_snd.contMDiff_tangentMap le_rfl)
/-- The canonical equivalence between the product of tangent bundles and the tangent bundle of a
product is smooth. -/
lemma contMDiff_equivTangentBundleProd_symm :
ContMDiff (I.tangent.prod I'.tangent) (I.prod I').tangent n
(equivTangentBundleProd I M I' M').symm := by
/- Contrary to what one might expect, this proof is nontrivial. It is not a formalization issue:
even on paper, I don't have a simple proof of the statement. The reason is that there is no nice
functorial expression for the map from `TM Ã T'M` to `T (M Ã M')`, so I need to come back to
the definition and break things into pieces.
The argument goes as follows. Since we're looking at a map into a vector bundle whose basis map
is smooth, it suffices to check the smoothness of the second component, in a chart. It lands in
a product vector space `E Ã E'`, so it suffices to check that the composition with each projection
to `E` and `E'` is smooth.
We notice that the composition of this map with the first projection coincides with the projection
`TM Ã TM' â TM` read in the target chart, which is smooth, so we're done.
The issue is with checking differentiability everywhere (to justify that the derivative of a
product is the product of the derivatives), and writing down things.
-/
rintro âša, bâ©
have U w w' : UniqueDiffWithinAt ð (Set.range (Prod.map I I')) (I w, I' w') := by
simp only [range_prodMap]
apply UniqueDiffWithinAt.prod
· exact ModelWithCorners.uniqueDiffWithinAt_image I
· exact ModelWithCorners.uniqueDiffWithinAt_image I'
rw [contMDiffAt_totalSpace]
simp only [equivTangentBundleProd, TangentBundle.trivializationAt_apply, mfld_simps,
Equiv.coe_fn_symm_mk]
refine âš?_, (contMDiffAt_prod_module_iff _).2 âš?_, ?_â©â©
· exact ContMDiffAt.prodMap (contMDiffAt_proj (TangentSpace I))
(contMDiffAt_proj (TangentSpace I'))
· /- check that the composition with the first projection in the target chart is smooth.
For this, we check that it coincides locally with the projection `pM : TM Ã TM' â TM` read in
the target chart, which is obviously smooth. -/
have smooth_pM : ContMDiffAt (I.tangent.prod I'.tangent) I.tangent n Prod.fst (a, b) :=
contMDiffAt_fst
apply ((contMDiffAt_totalSpace _ _).1 smooth_pM).2.congr_of_eventuallyEq
filter_upwards [chart_source_mem_nhds (ModelProd (ModelProd H E) (ModelProd H' E')) (a, b)]
with p hp
-- now we have to check that the original map coincides locally with `pM` read in target chart.
simp only [prodChartedSpace_chartAt, PartialHomeomorph.prod_toPartialEquiv,
PartialEquiv.prod_source, Set.mem_prod, TangentBundle.mem_chart_source_iff] at hp
let Ï (x : E) := I ((chartAt H a.proj) ((chartAt H p.1.proj).symm (I.symm x)))
have D0 : DifferentiableWithinAt ð Ï (Set.range I) (I ((chartAt H p.1.proj) p.1.proj)) := by
apply ContDiffWithinAt.differentiableWithinAt (n := 1) _ le_rfl
apply contDiffWithinAt_ext_coord_change
simp [hp.1]
have D (w : TangentBundle I' M') :
DifferentiableWithinAt ð (Ï â (Prod.fst : E Ã E' â E)) (Set.range (Prod.map âI âI'))
(I ((chartAt H p.1.proj) p.1.proj), I' ((chartAt H' w.proj) w.proj)) :=
DifferentiableWithinAt.comp (t := Set.range I) _ (by exact D0)
differentiableWithinAt_fst (by simp [mapsTo_fst_prod])
simp only [range_prodMap, ContinuousLinearMap.prod_apply, comp_def, comp_apply]
rw [DifferentiableWithinAt.fderivWithin_prodMk (by exact D _) ?_ (U _ _)]; swap
· let Ï' (x : E') := I' ((chartAt H' b.proj) ((chartAt H' p.2.proj).symm (I'.symm x)))
have D0' : DifferentiableWithinAt ð Ï' (Set.range I')
(I' ((chartAt H' p.2.proj) p.2.proj)) := by
apply ContDiffWithinAt.differentiableWithinAt (n := 1) _ le_rfl
apply contDiffWithinAt_ext_coord_change
simp [hp.2]
have D' : DifferentiableWithinAt ð (Ï' â Prod.snd) (Set.range (Prod.map I I'))
(I ((chartAt H p.1.proj) p.1.proj), I' ((chartAt H' p.2.proj) p.2.proj)) :=
DifferentiableWithinAt.comp (t := Set.range I') _ (by exact D0')
differentiableWithinAt_snd (by simp [mapsTo_snd_prod])
exact D'
simp only [TangentBundle.trivializationAt_apply, mfld_simps]
change fderivWithin ð (Ï â Prod.fst) _ _ _ = fderivWithin ð Ï _ _ _
rw [range_prodMap] at U
rw [fderivWithin_comp _ (by exact D0) differentiableWithinAt_fst mapsTo_fst_prod (U _ _)]
simp [fderivWithin_fst, U]
· /- check that the composition with the second projection in the target chart is smooth.
For this, we check that it coincides locally with the projection `pM' : TM Ã TM' â TM'` read in
the target chart, which is obviously smooth. -/
have smooth_pM' : ContMDiffAt (I.tangent.prod I'.tangent) I'.tangent n Prod.snd (a, b) :=
contMDiffAt_snd
apply ((contMDiffAt_totalSpace _ _).1 smooth_pM').2.congr_of_eventuallyEq
filter_upwards [chart_source_mem_nhds (ModelProd (ModelProd H E) (ModelProd H' E')) (a, b)]
with p hp
-- now we have to check that the original map coincides locally with `pM'` read in target chart.
simp only [prodChartedSpace_chartAt, PartialHomeomorph.prod_toPartialEquiv,
| Mathlib/Geometry/Manifold/ContMDiffMFDeriv.lean | 344 | 518 |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Yury Kudryashov
-/
import Mathlib.Algebra.Order.Ring.WithTop
import Mathlib.Algebra.Order.Sub.WithTop
import Mathlib.Data.NNReal.Defs
import Mathlib.Order.Interval.Set.WithBotTop
/-!
# Extended non-negative reals
We define `ENNReal = ââ¥0â := WithTop ââ¥0` to be the type of extended nonnegative real numbers,
i.e., the interval `[0, +â]`. This type is used as the codomain of a `MeasureTheory.Measure`,
and of the extended distance `edist` in an `EMetricSpace`.
In this file we set up many of the instances on `ââ¥0â`, and provide relationships between `ââ¥0â` and
`ââ¥0`, and between `ââ¥0â` and `â`. In particular, we provide a coercion from `ââ¥0` to `ââ¥0â` as well
as functions `ENNReal.toNNReal`, `ENNReal.ofReal` and `ENNReal.toReal`, all of which take the value
zero wherever they cannot be the identity. Also included is the relationship between `ââ¥0â` and `â`.
The interaction of these functions, especially `ENNReal.ofReal` and `ENNReal.toReal`, with the
algebraic and lattice structure can be found in `Data.ENNReal.Real`.
This file proves many of the order properties of `ââ¥0â`, with the exception of the ways those relate
to the algebraic structure, which are included in `Data.ENNReal.Operations`.
This file also defines inversion and division: this includes `Inv` and `Div` instances on `ââ¥0â`
making it into a `DivInvOneMonoid`.
As a consequence of being a `DivInvOneMonoid`, `ââ¥0â` inherits a power operation with integer
exponent: this and other properties is shown in `Data.ENNReal.Inv`.
## Main definitions
* `ââ¥0â`: the extended nonnegative real numbers `[0, â]`; defined as `WithTop ââ¥0`; it is
equipped with the following structures:
- coercion from `ââ¥0` defined in the natural way;
- the natural structure of a complete dense linear order: `âp †âq â p †q` and `â a, a †â`;
- `a + b` is defined so that `âp + âq = â(p + q)` for `(p q : ââ¥0)` and `a + â = â + a = â`;
- `a * b` is defined so that `âp * âq = â(p * q)` for `(p q : ââ¥0)`, `0 * â = â * 0 = 0`, and
`a * â = â * a = â` for `a â 0`;
- `a - b` is defined as the minimal `d` such that `a †d + b`; this way we have
`âp - âq = â(p - q)`, `â - âp = â`, `âp - â = â - â = 0`; note that there is no negation, only
subtraction;
The addition and multiplication defined this way together with `0 = â0` and `1 = â1` turn
`ââ¥0â` into a canonically ordered commutative semiring of characteristic zero.
- `aâ»Â¹` is defined as `Inf {b | 1 †a * b}`. This way we have `(âp)â»Â¹ = â(pâ»Â¹)` for
`p : ââ¥0`, `p â 0`, `0â»Â¹ = â`, and `ââ»Â¹ = 0`.
- `a / b` is defined as `a * bâ»Â¹`.
This inversion and division include `Inv` and `Div` instances on `ââ¥0â`,
making it into a `DivInvOneMonoid`. Further properties of these are shown in `Data.ENNReal.Inv`.
* Coercions to/from other types:
- coercion `ââ¥0 â ââ¥0â` is defined as `Coe`, so one can use `(p : ââ¥0)` in a context that
expects `a : ââ¥0â`, and Lean will apply `coe` automatically;
- `ENNReal.toNNReal` sends `âp` to `p` and `â` to `0`;
- `ENNReal.toReal := coe â ENNReal.toNNReal` sends `âp`, `p : ââ¥0` to `(âp : â)` and `â` to `0`;
- `ENNReal.ofReal := coe â Real.toNNReal` sends `x : â` to `ââšmax x 0, _â©`
- `ENNReal.neTopEquivNNReal` is an equivalence between `{a : ââ¥0â // a â 0}` and `ââ¥0`.
## Implementation notes
We define a `CanLift ââ¥0â ââ¥0` instance, so one of the ways to prove theorems about an `ââ¥0â`
number `a` is to consider the cases `a = â` and `a â â`, and use the tactic `lift a to ââ¥0 using ha`
in the second case. This instance is even more useful if one already has `ha : a â â` in the
context, or if we have `(f : α â ââ¥0â) (hf : â x, f x â â)`.
## Notations
* `ââ¥0â`: the type of the extended nonnegative real numbers;
* `ââ¥0`: the type of nonnegative real numbers `[0, â)`; defined in `Data.Real.NNReal`;
* `â`: a localized notation in `ENNReal` for `†: ââ¥0â`.
-/
assert_not_exists Finset
open Function Set NNReal
variable {α : Type*}
/-- The extended nonnegative real numbers. This is usually denoted [0, â],
and is relevant as the codomain of a measure. -/
def ENNReal := WithTop ââ¥0
deriving Zero, Top, AddCommMonoidWithOne, SemilatticeSup, DistribLattice, Nontrivial
@[inherit_doc]
scoped[ENNReal] notation "ââ¥0â" => ENNReal
/-- Notation for infinity as an `ENNReal` number. -/
scoped[ENNReal] notation "â" => (†: ENNReal)
namespace ENNReal
instance : OrderBot ââ¥0â := inferInstanceAs (OrderBot (WithTop ââ¥0))
instance : OrderTop ââ¥0â := inferInstanceAs (OrderTop (WithTop ââ¥0))
instance : BoundedOrder ââ¥0â := inferInstanceAs (BoundedOrder (WithTop ââ¥0))
instance : CharZero ââ¥0â := inferInstanceAs (CharZero (WithTop ââ¥0))
instance : Min ââ¥0â := SemilatticeInf.toMin
instance : Max ââ¥0â := SemilatticeSup.toMax
noncomputable instance : CommSemiring ââ¥0â :=
inferInstanceAs (CommSemiring (WithTop ââ¥0))
instance : PartialOrder ââ¥0â :=
inferInstanceAs (PartialOrder (WithTop ââ¥0))
instance : IsOrderedRing ââ¥0â :=
inferInstanceAs (IsOrderedRing (WithTop ââ¥0))
instance : CanonicallyOrderedAdd ââ¥0â :=
inferInstanceAs (CanonicallyOrderedAdd (WithTop ââ¥0))
instance : NoZeroDivisors ââ¥0â :=
inferInstanceAs (NoZeroDivisors (WithTop ââ¥0))
noncomputable instance : CompleteLinearOrder ââ¥0â :=
inferInstanceAs (CompleteLinearOrder (WithTop ââ¥0))
instance : DenselyOrdered ââ¥0â := inferInstanceAs (DenselyOrdered (WithTop ââ¥0))
instance : AddCommMonoid ââ¥0â :=
inferInstanceAs (AddCommMonoid (WithTop ââ¥0))
noncomputable instance : LinearOrder ââ¥0â :=
inferInstanceAs (LinearOrder (WithTop ââ¥0))
instance : IsOrderedAddMonoid ââ¥0â :=
inferInstanceAs (IsOrderedAddMonoid (WithTop ââ¥0))
instance instSub : Sub ââ¥0â := inferInstanceAs (Sub (WithTop ââ¥0))
instance : OrderedSub ââ¥0â := inferInstanceAs (OrderedSub (WithTop ââ¥0))
noncomputable instance : LinearOrderedAddCommMonoidWithTop ââ¥0â :=
inferInstanceAs (LinearOrderedAddCommMonoidWithTop (WithTop ââ¥0))
-- RFC: redefine using pattern matching?
noncomputable instance : Inv ââ¥0â := âšfun a => sInf { b | 1 †a * b }â©
noncomputable instance : DivInvMonoid ââ¥0â where
variable {a b c d : ââ¥0â} {r p q : ââ¥0}
-- TODO: add a `WithTop` instance and use it here
noncomputable instance : LinearOrderedCommMonoidWithZero ââ¥0â :=
{ inferInstanceAs (LinearOrderedAddCommMonoidWithTop ââ¥0â),
inferInstanceAs (CommSemiring ââ¥0â) with
bot_le _ := bot_le
mul_le_mul_left := fun _ _ => mul_le_mul_left'
zero_le_one := zero_le 1 }
instance : Unique (AddUnits ââ¥0â) where
default := 0
uniq a := AddUnits.ext <| le_zero_iff.1 <| by rw [â a.add_neg]; exact le_self_add
instance : Inhabited ââ¥0â := âš0â©
/-- Coercion from `ââ¥0` to `ââ¥0â`. -/
@[coe, match_pattern] def ofNNReal : ââ¥0 â ââ¥0â := WithTop.some
instance : Coe ââ¥0 ââ¥0â := âšofNNRealâ©
/-- A version of `WithTop.recTopCoe` that uses `ENNReal.ofNNReal`. -/
@[elab_as_elim, induction_eliminator, cases_eliminator]
def recTopCoe {C : ââ¥0â â Sort*} (top : C â) (coe : â x : ââ¥0, C x) (x : ââ¥0â) : C x :=
WithTop.recTopCoe top coe x
instance canLift : CanLift ââ¥0â ââ¥0 ofNNReal (· â â) := WithTop.canLift
@[simp] theorem none_eq_top : (none : ââ¥0â) = â := rfl
@[simp] theorem some_eq_coe (a : ââ¥0) : (Option.some a : ââ¥0â) = (âa : ââ¥0â) := rfl
@[simp] theorem some_eq_coe' (a : ââ¥0) : (WithTop.some a : ââ¥0â) = (âa : ââ¥0â) := rfl
lemma coe_injective : Injective ((â) : ââ¥0 â ââ¥0â) := WithTop.coe_injective
@[simp, norm_cast] lemma coe_inj : (p : ââ¥0â) = q â p = q := coe_injective.eq_iff
lemma coe_ne_coe : (p : ââ¥0â) â q â p â q := coe_inj.not
theorem range_coe' : range ofNNReal = Iio â := WithTop.range_coe
theorem range_coe : range ofNNReal = {â}á¶ := (isCompl_range_some_none ââ¥0).symm.compl_eq.symm
instance : NNRatCast ââ¥0â where
nnratCast r := ofNNReal r
@[norm_cast]
theorem coe_nnratCast (q : ââ¥0) : â(q : ââ¥0) = (q : ââ¥0â) := rfl
/-- `toNNReal x` returns `x` if it is real, otherwise 0. -/
protected def toNNReal : ââ¥0â â ââ¥0 := WithTop.untopD 0
/-- `toReal x` returns `x` if it is real, `0` otherwise. -/
protected def toReal (a : ââ¥0â) : Real := a.toNNReal
/-- `ofReal x` returns `x` if it is nonnegative, `0` otherwise. -/
protected def ofReal (r : Real) : ââ¥0â := r.toNNReal
@[simp, norm_cast] lemma toNNReal_coe (r : ââ¥0) : (r : ââ¥0â).toNNReal = r := rfl
@[simp]
theorem coe_toNNReal : â {a : ââ¥0â}, a â â â âa.toNNReal = a
| ofNNReal _, _ => rfl
| â€, h => (h rfl).elim
@[simp]
theorem coe_comp_toNNReal_comp {ι : Type*} {f : ι â ââ¥0â} (hf : â x, f x â â) :
(fun (x : ââ¥0) => (x : ââ¥0â)) â ENNReal.toNNReal â f = f := by
ext x
simp [coe_toNNReal (hf x)]
@[simp]
theorem ofReal_toReal {a : ââ¥0â} (h : a â â) : ENNReal.ofReal a.toReal = a := by
simp [ENNReal.toReal, ENNReal.ofReal, h]
@[simp]
theorem toReal_ofReal {r : â} (h : 0 †r) : (ENNReal.ofReal r).toReal = r :=
max_eq_left h
theorem toReal_ofReal' {r : â} : (ENNReal.ofReal r).toReal = max r 0 := rfl
theorem coe_toNNReal_le_self : â {a : ââ¥0â}, âa.toNNReal †a
| ofNNReal r => by rw [toNNReal_coe]
| †=> le_top
theorem coe_nnreal_eq (r : ââ¥0) : (r : ââ¥0â) = ENNReal.ofReal r := by
rw [ENNReal.ofReal, Real.toNNReal_coe]
theorem ofReal_eq_coe_nnreal {x : â} (h : 0 †x) :
ENNReal.ofReal x = ofNNReal âšx, hâ© :=
(coe_nnreal_eq âšx, hâ©).symm
theorem ofNNReal_toNNReal (x : â) : (Real.toNNReal x : ââ¥0â) = ENNReal.ofReal x := rfl
@[simp] theorem ofReal_coe_nnreal : ENNReal.ofReal p = p := (coe_nnreal_eq p).symm
@[simp, norm_cast] theorem coe_zero : â(0 : ââ¥0) = (0 : ââ¥0â) := rfl
@[simp, norm_cast] theorem coe_one : â(1 : ââ¥0) = (1 : ââ¥0â) := rfl
@[simp] theorem toReal_nonneg {a : ââ¥0â} : 0 †a.toReal := a.toNNReal.2
@[norm_cast] theorem coe_toNNReal_eq_toReal (z : ââ¥0â) : (z.toNNReal : â) = z.toReal := rfl
@[simp] theorem toNNReal_toReal_eq (z : ââ¥0â) : z.toReal.toNNReal = z.toNNReal := by
ext; simp [coe_toNNReal_eq_toReal]
@[simp] theorem toNNReal_top : â.toNNReal = 0 := rfl
@[deprecated (since := "2025-03-20")] alias top_toNNReal := toNNReal_top
@[simp] theorem toReal_top : â.toReal = 0 := rfl
@[deprecated (since := "2025-03-20")] alias top_toReal := toReal_top
@[simp] theorem toReal_one : (1 : ââ¥0â).toReal = 1 := rfl
@[deprecated (since := "2025-03-20")] alias one_toReal := toReal_one
@[simp] theorem toNNReal_one : (1 : ââ¥0â).toNNReal = 1 := rfl
@[deprecated (since := "2025-03-20")] alias one_toNNReal := toNNReal_one
@[simp] theorem coe_toReal (r : ââ¥0) : (r : ââ¥0â).toReal = r := rfl
@[simp] theorem toNNReal_zero : (0 : ââ¥0â).toNNReal = 0 := rfl
@[deprecated (since := "2025-03-20")] alias zero_toNNReal := toNNReal_zero
@[simp] theorem toReal_zero : (0 : ââ¥0â).toReal = 0 := rfl
@[deprecated (since := "2025-03-20")] alias zero_toReal := toReal_zero
@[simp] theorem ofReal_zero : ENNReal.ofReal (0 : â) = 0 := by simp [ENNReal.ofReal]
@[simp] theorem ofReal_one : ENNReal.ofReal (1 : â) = (1 : ââ¥0â) := by simp [ENNReal.ofReal]
theorem ofReal_toReal_le {a : ââ¥0â} : ENNReal.ofReal a.toReal †a :=
if ha : a = â then ha.symm âž le_top else le_of_eq (ofReal_toReal ha)
theorem forall_ennreal {p : ââ¥0â â Prop} : (â a, p a) â (â r : ââ¥0, p r) â§ p â :=
Option.forall.trans and_comm
theorem forall_ne_top {p : ââ¥0â â Prop} : (â a, a â â â p a) â â r : ââ¥0, p r :=
Option.forall_ne_none
theorem exists_ne_top {p : ââ¥0â â Prop} : (â a â â, p a) â â r : ââ¥0, p r :=
Option.exists_ne_none
theorem toNNReal_eq_zero_iff (x : ââ¥0â) : x.toNNReal = 0 â x = 0 âš x = â :=
WithTop.untopD_eq_self_iff
theorem toReal_eq_zero_iff (x : ââ¥0â) : x.toReal = 0 â x = 0 âš x = â := by
simp [ENNReal.toReal, toNNReal_eq_zero_iff]
theorem toNNReal_ne_zero : a.toNNReal â 0 â a â 0 â§ a â â :=
a.toNNReal_eq_zero_iff.not.trans not_or
theorem toReal_ne_zero : a.toReal â 0 â a â 0 â§ a â â :=
a.toReal_eq_zero_iff.not.trans not_or
theorem toNNReal_eq_one_iff (x : ââ¥0â) : x.toNNReal = 1 â x = 1 :=
WithTop.untopD_eq_iff.trans <| by simp
theorem toReal_eq_one_iff (x : ââ¥0â) : x.toReal = 1 â x = 1 := by
rw [ENNReal.toReal, NNReal.coe_eq_one, ENNReal.toNNReal_eq_one_iff]
theorem toNNReal_ne_one : a.toNNReal â 1 â a â 1 :=
a.toNNReal_eq_one_iff.not
theorem toReal_ne_one : a.toReal â 1 â a â 1 :=
a.toReal_eq_one_iff.not
@[simp, aesop (rule_sets := [finiteness]) safe apply]
theorem coe_ne_top : (r : ââ¥0â) â â := WithTop.coe_ne_top
@[simp] theorem top_ne_coe : â â (r : ââ¥0â) := WithTop.top_ne_coe
@[simp] theorem coe_lt_top : (r : ââ¥0â) < â := WithTop.coe_lt_top r
@[simp, aesop (rule_sets := [finiteness]) safe apply]
theorem ofReal_ne_top {r : â} : ENNReal.ofReal r â â := coe_ne_top
@[simp] theorem ofReal_lt_top {r : â} : ENNReal.ofReal r < â := coe_lt_top
@[simp] theorem top_ne_ofReal {r : â} : â â ENNReal.ofReal r := top_ne_coe
@[simp]
theorem ofReal_toReal_eq_iff : ENNReal.ofReal a.toReal = a â a â †:=
âšfun h => by
rw [â h]
exact ofReal_ne_top, ofReal_toRealâ©
@[simp]
theorem toReal_ofReal_eq_iff {a : â} : (ENNReal.ofReal a).toReal = a â 0 †a :=
âšfun h => by
rw [â h]
exact toReal_nonneg, toReal_ofRealâ©
@[simp, aesop (rule_sets := [finiteness]) safe apply] theorem zero_ne_top : 0 â â := coe_ne_top
@[simp] theorem top_ne_zero : â â 0 := top_ne_coe
@[simp, aesop (rule_sets := [finiteness]) safe apply] theorem one_ne_top : 1 â â := coe_ne_top
@[simp] theorem top_ne_one : â â 1 := top_ne_coe
@[simp] theorem zero_lt_top : 0 < â := coe_lt_top
@[simp, norm_cast] theorem coe_le_coe : (âr : ââ¥0â) †âq â r †q := WithTop.coe_le_coe
@[simp, norm_cast] theorem coe_lt_coe : (âr : ââ¥0â) < âq â r < q := WithTop.coe_lt_coe
-- Needed until `@[gcongr]` accepts iff statements
alias âš_, coe_le_coe_of_leâ© := coe_le_coe
attribute [gcongr] ENNReal.coe_le_coe_of_le
-- Needed until `@[gcongr]` accepts iff statements
alias âš_, coe_lt_coe_of_ltâ© := coe_lt_coe
attribute [gcongr] ENNReal.coe_lt_coe_of_lt
theorem coe_mono : Monotone ofNNReal := fun _ _ => coe_le_coe.2
theorem coe_strictMono : StrictMono ofNNReal := fun _ _ => coe_lt_coe.2
@[simp, norm_cast] theorem coe_eq_zero : (âr : ââ¥0â) = 0 â r = 0 := coe_inj
@[simp, norm_cast] theorem zero_eq_coe : 0 = (âr : ââ¥0â) â 0 = r := coe_inj
@[simp, norm_cast] theorem coe_eq_one : (âr : ââ¥0â) = 1 â r = 1 := coe_inj
@[simp, norm_cast] theorem one_eq_coe : 1 = (âr : ââ¥0â) â 1 = r := coe_inj
@[simp, norm_cast] theorem coe_pos : 0 < (r : ââ¥0â) â 0 < r := coe_lt_coe
theorem coe_ne_zero : (r : ââ¥0â) â 0 â r â 0 := coe_eq_zero.not
lemma coe_ne_one : (r : ââ¥0â) â 1 â r â 1 := coe_eq_one.not
@[simp, norm_cast] lemma coe_add (x y : ââ¥0) : (â(x + y) : ââ¥0â) = x + y := rfl
@[simp, norm_cast] lemma coe_mul (x y : ââ¥0) : (â(x * y) : ââ¥0â) = x * y := rfl
@[norm_cast] lemma coe_nsmul (n : â) (x : ââ¥0) : (â(n ⢠x) : ââ¥0â) = n ⢠x := rfl
@[simp, norm_cast] lemma coe_pow (x : ââ¥0) (n : â) : (â(x ^ n) : ââ¥0â) = x ^ n := rfl
@[simp, norm_cast]
theorem coe_ofNat (n : â) [n.AtLeastTwo] : ((ofNat(n) : ââ¥0) : ââ¥0â) = ofNat(n) := rfl
-- TODO: add lemmas about `OfNat.ofNat` and `<`/`â€`
theorem coe_two : ((2 : ââ¥0) : ââ¥0â) = 2 := rfl
theorem toNNReal_eq_toNNReal_iff (x y : ââ¥0â) :
x.toNNReal = y.toNNReal â x = y âš x = 0 â§ y = †⚠x = †⧠y = 0 :=
WithTop.untopD_eq_untopD_iff
theorem toReal_eq_toReal_iff (x y : ââ¥0â) :
x.toReal = y.toReal â x = y âš x = 0 â§ y = †⚠x = †⧠y = 0 := by
simp only [ENNReal.toReal, NNReal.coe_inj, toNNReal_eq_toNNReal_iff]
theorem toNNReal_eq_toNNReal_iff' {x y : ââ¥0â} (hx : x â â€) (hy : y â â€) :
x.toNNReal = y.toNNReal â x = y := by
simp only [ENNReal.toNNReal_eq_toNNReal_iff x y, hx, hy, and_false, false_and, or_false]
theorem toReal_eq_toReal_iff' {x y : ââ¥0â} (hx : x â â€) (hy : y â â€) :
x.toReal = y.toReal â x = y := by
simp only [ENNReal.toReal, NNReal.coe_inj, toNNReal_eq_toNNReal_iff' hx hy]
theorem one_lt_two : (1 : ââ¥0â) < 2 := Nat.one_lt_ofNat
/-- `(1 : ââ¥0â) †1`, recorded as a `Fact` for use with `Lp` spaces. -/
instance _root_.fact_one_le_one_ennreal : Fact ((1 : ââ¥0â) †1) :=
âšle_rflâ©
/-- `(1 : ââ¥0â) †2`, recorded as a `Fact` for use with `Lp` spaces. -/
instance _root_.fact_one_le_two_ennreal : Fact ((1 : ââ¥0â) †2) :=
âšone_le_twoâ©
/-- `(1 : ââ¥0â) †â`, recorded as a `Fact` for use with `Lp` spaces. -/
instance _root_.fact_one_le_top_ennreal : Fact ((1 : ââ¥0â) †â) :=
âšle_topâ©
/-- The set of numbers in `ââ¥0â` that are not equal to `â` is equivalent to `ââ¥0`. -/
def neTopEquivNNReal : { a | a â â } â ââ¥0 where
toFun x := ENNReal.toNNReal x
invFun x := âšx, coe_ne_topâ©
left_inv := fun x => Subtype.eq <| coe_toNNReal x.2
right_inv := toNNReal_coe
theorem cinfi_ne_top [InfSet α] (f : ââ¥0â â α) : âš
x : { x // x â â }, f x = âš
x : ââ¥0, f x :=
Eq.symm <| neTopEquivNNReal.symm.surjective.iInf_congr _ fun _ => rfl
theorem iInf_ne_top [CompleteLattice α] (f : ââ¥0â â α) :
âš
(x) (_ : x â â), f x = âš
x : ââ¥0, f x := by rw [iInf_subtype', cinfi_ne_top]
theorem csupr_ne_top [SupSet α] (f : ââ¥0â â α) : âš x : { x // x â â }, f x = âš x : ââ¥0, f x :=
@cinfi_ne_top αáµáµ _ _
theorem iSup_ne_top [CompleteLattice α] (f : ââ¥0â â α) :
âš (x) (_ : x â â), f x = âš x : ââ¥0, f x :=
@iInf_ne_top αáµáµ _ _
theorem iInf_ennreal {α : Type*} [CompleteLattice α] {f : ââ¥0â â α} :
âš
n, f n = (âš
n : ââ¥0, f n) â f â :=
(iInf_option f).trans (inf_comm _ _)
theorem iSup_ennreal {α : Type*} [CompleteLattice α] {f : ââ¥0â â α} :
âš n, f n = (âš n : ââ¥0, f n) â f â :=
@iInf_ennreal αáµáµ _ _
/-- Coercion `ââ¥0 â ââ¥0â` as a `RingHom`. -/
def ofNNRealHom : ââ¥0 â+* ââ¥0â where
toFun := some
map_one' := coe_one
map_mul' _ _ := coe_mul _ _
map_zero' := coe_zero
map_add' _ _ := coe_add _ _
@[simp] theorem coe_ofNNRealHom : âofNNRealHom = some := rfl
section Order
theorem bot_eq_zero : (⥠: ââ¥0â) = 0 := rfl
-- `coe_lt_top` moved up
theorem not_top_le_coe : ¬â †âr := WithTop.not_top_le_coe r
@[simp, norm_cast]
theorem one_le_coe_iff : (1 : ââ¥0â) †âr â 1 †r := coe_le_coe
@[simp, norm_cast]
theorem coe_le_one_iff : âr †(1 : ââ¥0â) â r †1 := coe_le_coe
@[simp, norm_cast]
theorem coe_lt_one_iff : (âp : ââ¥0â) < 1 â p < 1 := coe_lt_coe
@[simp, norm_cast]
theorem one_lt_coe_iff : 1 < (âp : ââ¥0â) â 1 < p := coe_lt_coe
@[simp, norm_cast]
theorem coe_natCast (n : â) : ((n : ââ¥0) : ââ¥0â) = n := rfl
@[simp, norm_cast] lemma ofReal_natCast (n : â) : ENNReal.ofReal n = n := by simp [ENNReal.ofReal]
@[simp] theorem ofReal_ofNat (n : â) [n.AtLeastTwo] : ENNReal.ofReal ofNat(n) = ofNat(n) :=
ofReal_natCast n
@[simp, aesop (rule_sets := [finiteness]) safe apply]
theorem natCast_ne_top (n : â) : (n : ââ¥0â) â â := WithTop.natCast_ne_top n
@[simp] theorem natCast_lt_top (n : â) : (n : ââ¥0â) < â := WithTop.natCast_lt_top n
@[simp, aesop (rule_sets := [finiteness]) safe apply]
lemma ofNat_ne_top {n : â} [Nat.AtLeastTwo n] : ofNat(n) â â := natCast_ne_top n
@[simp]
lemma ofNat_lt_top {n : â} [Nat.AtLeastTwo n] : ofNat(n) < â := natCast_lt_top n
@[simp] theorem top_ne_natCast (n : â) : â â n := WithTop.top_ne_natCast n
@[simp] theorem top_ne_ofNat {n : â} [n.AtLeastTwo] : â â ofNat(n) :=
ofNat_ne_top.symm
@[deprecated ofNat_ne_top (since := "2025-01-21")] lemma two_ne_top : (2 : ââ¥0â) â â := coe_ne_top
@[deprecated ofNat_lt_top (since := "2025-01-21")] lemma two_lt_top : (2 : ââ¥0â) < â := coe_lt_top
@[simp] theorem one_lt_top : 1 < â := coe_lt_top
@[simp, norm_cast]
theorem toNNReal_natCast (n : â) : (n : ââ¥0â).toNNReal = n := by
rw [â ENNReal.coe_natCast n, ENNReal.toNNReal_coe]
@[deprecated (since := "2025-02-19")] alias toNNReal_nat := toNNReal_natCast
theorem toNNReal_ofNat (n : â) [n.AtLeastTwo] : ENNReal.toNNReal ofNat(n) = ofNat(n) :=
toNNReal_natCast n
@[simp, norm_cast]
theorem toReal_natCast (n : â) : (n : ââ¥0â).toReal = n := by
rw [â ENNReal.ofReal_natCast n, ENNReal.toReal_ofReal (Nat.cast_nonneg _)]
@[deprecated (since := "2025-02-19")] alias toReal_nat := toReal_natCast
@[simp] theorem toReal_ofNat (n : â) [n.AtLeastTwo] : ENNReal.toReal ofNat(n) = ofNat(n) :=
toReal_natCast n
lemma toNNReal_natCast_eq_toNNReal (n : â) :
(n : ââ¥0â).toNNReal = (n : â).toNNReal := by
rw [Real.toNNReal_of_nonneg (by positivity), ENNReal.toNNReal_natCast, mk_natCast]
theorem le_coe_iff : a †âr â â p : ââ¥0, a = p â§ p †r := WithTop.le_coe_iff
theorem coe_le_iff : âr †a â â p : ââ¥0, a = p â r †p := WithTop.coe_le_iff
theorem lt_iff_exists_coe : a < b â â p : ââ¥0, a = p â§ âp < b :=
WithTop.lt_iff_exists_coe
theorem toReal_le_coe_of_le_coe {a : ââ¥0â} {b : ââ¥0} (h : a †b) : a.toReal †b := by
lift a to ââ¥0 using ne_top_of_le_ne_top coe_ne_top h
simpa using h
@[simp] theorem max_eq_zero_iff : max a b = 0 â a = 0 â§ b = 0 := max_eq_bot
theorem max_zero_left : max 0 a = a :=
max_eq_right (zero_le a)
theorem max_zero_right : max a 0 = a :=
max_eq_left (zero_le a)
theorem lt_iff_exists_rat_btwn :
a < b â â q : â, 0 †q â§ a < Real.toNNReal q â§ (Real.toNNReal q : ââ¥0â) < b :=
âšfun h => by
rcases lt_iff_exists_coe.1 h with âšp, rfl, _â©
rcases exists_between h with âšc, pc, cbâ©
rcases lt_iff_exists_coe.1 cb with âšr, rfl, _â©
rcases (NNReal.lt_iff_exists_rat_btwn _ _).1 (coe_lt_coe.1 pc) with âšq, hq0, pq, qrâ©
exact âšq, hq0, coe_lt_coe.2 pq, lt_trans (coe_lt_coe.2 qr) cbâ©,
fun âš_, _, qa, qbâ© => lt_trans qa qbâ©
theorem lt_iff_exists_real_btwn :
a < b â â r : â, 0 †r â§ a < ENNReal.ofReal r â§ (ENNReal.ofReal r : ââ¥0â) < b :=
âšfun h =>
let âšq, q0, aq, qbâ© := ENNReal.lt_iff_exists_rat_btwn.1 h
âšq, Rat.cast_nonneg.2 q0, aq, qbâ©,
fun âš_, _, qa, qbâ© => lt_trans qa qbâ©
theorem lt_iff_exists_nnreal_btwn : a < b â â r : ââ¥0, a < r â§ (r : ââ¥0â) < b :=
WithTop.lt_iff_exists_coe_btwn
theorem lt_iff_exists_add_pos_lt : a < b â â r : ââ¥0, 0 < r â§ a + r < b := by
refine âšfun hab => ?_, fun âšr, _, hrâ© => lt_of_le_of_lt le_self_add hrâ©
rcases lt_iff_exists_nnreal_btwn.1 hab with âšc, ac, cbâ©
lift a to ââ¥0 using ac.ne_top
rw [coe_lt_coe] at ac
refine âšc - a, tsub_pos_iff_lt.2 ac, ?_â©
rwa [â coe_add, add_tsub_cancel_of_le ac.le]
theorem le_of_forall_pos_le_add (h : â ε : ââ¥0, 0 < ε â b < â â a †b + ε) : a †b := by
contrapose! h
rcases lt_iff_exists_add_pos_lt.1 h with âšr, hr0, hrâ©
exact âšr, hr0, h.trans_le le_top, hrâ©
theorem natCast_lt_coe {n : â} : n < (r : ââ¥0â) â n < r := ENNReal.coe_natCast n âž coe_lt_coe
theorem coe_lt_natCast {n : â} : (r : ââ¥0â) < n â r < n := ENNReal.coe_natCast n âž coe_lt_coe
protected theorem exists_nat_gt {r : ââ¥0â} (h : r â â) : â n : â, r < n := by
lift r to ââ¥0 using h
rcases exists_nat_gt r with âšn, hnâ©
exact âšn, coe_lt_natCast.2 hnâ©
@[simp]
theorem iUnion_Iio_coe_nat : â n : â, Iio (n : ââ¥0â) = {â}á¶ := by
ext x
rw [mem_iUnion]
exact âšfun âšn, hnâ© => ne_top_of_lt hn, ENNReal.exists_nat_gtâ©
@[simp]
theorem iUnion_Iic_coe_nat : â n : â, Iic (n : ââ¥0â) = {â}á¶ :=
Subset.antisymm (iUnion_subset fun n _x hx => ne_top_of_le_ne_top (natCast_ne_top n) hx) <|
iUnion_Iio_coe_nat âž iUnion_mono fun _ => Iio_subset_Iic_self
@[simp]
theorem iUnion_Ioc_coe_nat : â n : â, Ioc a n = Ioi a \ {â} := by
simp only [â Ioi_inter_Iic, â inter_iUnion, iUnion_Iic_coe_nat, diff_eq]
@[simp]
theorem iUnion_Ioo_coe_nat : â n : â, Ioo a n = Ioi a \ {â} := by
simp only [â Ioi_inter_Iio, â inter_iUnion, iUnion_Iio_coe_nat, diff_eq]
@[simp]
theorem iUnion_Icc_coe_nat : â n : â, Icc a n = Ici a \ {â} := by
simp only [â Ici_inter_Iic, â inter_iUnion, iUnion_Iic_coe_nat, diff_eq]
@[simp]
theorem iUnion_Ico_coe_nat : â n : â, Ico a n = Ici a \ {â} := by
simp only [â Ici_inter_Iio, â inter_iUnion, iUnion_Iio_coe_nat, diff_eq]
@[simp]
theorem iInter_Ici_coe_nat : â n : â, Ici (n : ââ¥0â) = {â} := by
simp only [â compl_Iio, â compl_iUnion, iUnion_Iio_coe_nat, compl_compl]
@[simp]
theorem iInter_Ioi_coe_nat : â n : â, Ioi (n : ââ¥0â) = {â} := by
simp only [â compl_Iic, â compl_iUnion, iUnion_Iic_coe_nat, compl_compl]
@[simp, norm_cast]
theorem coe_min (r p : ââ¥0) : ((min r p : ââ¥0) : ââ¥0â) = min (r : ââ¥0â) p := rfl
@[simp, norm_cast]
theorem coe_max (r p : ââ¥0) : ((max r p : ââ¥0) : ââ¥0â) = max (r : ââ¥0â) p := rfl
theorem le_of_top_imp_top_of_toNNReal_le {a b : ââ¥0â} (h : a = †â b = â€)
(h_nnreal : a â †â b â †â a.toNNReal †b.toNNReal) : a †b := by
by_contra! hlt
lift b to ââ¥0 using hlt.ne_top
lift a to ââ¥0 using mt h coe_ne_top
refine hlt.not_le ?_
simpa using h_nnreal
@[simp]
theorem abs_toReal {x : ââ¥0â} : |x.toReal| = x.toReal := by cases x <;> simp
end Order
section CompleteLattice
variable {ι : Sort*} {f : ι â ââ¥0}
theorem coe_sSup {s : Set ââ¥0} : BddAbove s â (â(sSup s) : ââ¥0â) = âš a â s, âa :=
WithTop.coe_sSup
theorem coe_sInf {s : Set ââ¥0} (hs : s.Nonempty) : (â(sInf s) : ââ¥0â) = âš
a â s, âa :=
WithTop.coe_sInf hs (OrderBot.bddBelow s)
theorem coe_iSup {ι : Sort*} {f : ι â ââ¥0} (hf : BddAbove (range f)) :
(â(iSup f) : ââ¥0â) = âš a, â(f a) :=
WithTop.coe_iSup _ hf
@[norm_cast]
theorem coe_iInf {ι : Sort*} [Nonempty ι] (f : ι â ââ¥0) : (â(iInf f) : ââ¥0â) = âš
a, â(f a) :=
WithTop.coe_iInf (OrderBot.bddBelow _)
theorem coe_mem_upperBounds {s : Set ââ¥0} :
âr â upperBounds (ofNNReal '' s) â r â upperBounds s := by
simp +contextual [upperBounds, forall_mem_image, -mem_image, *]
lemma iSup_coe_eq_top : âš i, (f i : ââ¥0â) = †â ¬ BddAbove (range f) := WithTop.iSup_coe_eq_top
lemma iSup_coe_lt_top : âš i, (f i : ââ¥0â) < †â BddAbove (range f) := WithTop.iSup_coe_lt_top
lemma iInf_coe_eq_top : âš
i, (f i : ââ¥0â) = †â IsEmpty ι := WithTop.iInf_coe_eq_top
lemma iInf_coe_lt_top : âš
i, (f i : ââ¥0â) < †â Nonempty ι := WithTop.iInf_coe_lt_top
end CompleteLattice
section Bit
-- TODO: add lemmas about `OfNat.ofNat`
end Bit
end ENNReal
open ENNReal
namespace Set
| namespace OrdConnected
| Mathlib/Data/ENNReal/Basic.lean | 703 | 704 |
/-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Data.Set.Image
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Order.WithBot
/-!
# Intervals in `WithTop α` and `WithBot α`
In this file we prove various lemmas about `Set.image`s and `Set.preimage`s of intervals under
`some : α â WithTop α` and `some : α â WithBot α`.
-/
open Set
variable {α : Type*}
/-! ### `WithTop` -/
namespace WithTop
@[simp]
theorem preimage_coe_top : (some : α â WithTop α) â»Â¹' {â€} = (â
: Set α) :=
eq_empty_of_subset_empty fun _ => coe_ne_top
variable [Preorder α] {a b : α}
theorem range_coe : range (some : α â WithTop α) = Iio †:= by
ext x
rw [mem_Iio, WithTop.lt_top_iff_ne_top, mem_range, ne_top_iff_exists]
@[simp]
theorem preimage_coe_Ioi : (some : α â WithTop α) â»Â¹' Ioi a = Ioi a :=
ext fun _ => coe_lt_coe
@[simp]
theorem preimage_coe_Ici : (some : α â WithTop α) â»Â¹' Ici a = Ici a :=
ext fun _ => coe_le_coe
@[simp]
theorem preimage_coe_Iio : (some : α â WithTop α) â»Â¹' Iio a = Iio a :=
ext fun _ => coe_lt_coe
@[simp]
theorem preimage_coe_Iic : (some : α â WithTop α) â»Â¹' Iic a = Iic a :=
ext fun _ => coe_le_coe
@[simp]
theorem preimage_coe_Icc : (some : α â WithTop α) â»Â¹' Icc a b = Icc a b := by simp [â Ici_inter_Iic]
@[simp]
theorem preimage_coe_Ico : (some : α â WithTop α) â»Â¹' Ico a b = Ico a b := by simp [â Ici_inter_Iio]
@[simp]
theorem preimage_coe_Ioc : (some : α â WithTop α) â»Â¹' Ioc a b = Ioc a b := by simp [â Ioi_inter_Iic]
@[simp]
theorem preimage_coe_Ioo : (some : α â WithTop α) â»Â¹' Ioo a b = Ioo a b := by simp [â Ioi_inter_Iio]
@[simp]
theorem preimage_coe_Iio_top : (some : α â WithTop α) â»Â¹' Iio †= univ := by
rw [â range_coe, preimage_range]
@[simp]
theorem preimage_coe_Ico_top : (some : α â WithTop α) â»Â¹' Ico a †= Ici a := by
simp [â Ici_inter_Iio]
@[simp]
theorem preimage_coe_Ioo_top : (some : α â WithTop α) â»Â¹' Ioo a †= Ioi a := by
simp [â Ioi_inter_Iio]
theorem image_coe_Ioi : (some : α â WithTop α) '' Ioi a = Ioo (a : WithTop α) †:= by
rw [â preimage_coe_Ioi, image_preimage_eq_inter_range, range_coe, Ioi_inter_Iio]
theorem image_coe_Ici : (some : α â WithTop α) '' Ici a = Ico (a : WithTop α) †:= by
rw [â preimage_coe_Ici, image_preimage_eq_inter_range, range_coe, Ici_inter_Iio]
theorem image_coe_Iio : (some : α â WithTop α) '' Iio a = Iio (a : WithTop α) := by
rw [â preimage_coe_Iio, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Iio_subset_Iio le_top)]
theorem image_coe_Iic : (some : α â WithTop α) '' Iic a = Iic (a : WithTop α) := by
rw [â preimage_coe_Iic, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Iic_subset_Iio.2 <| coe_lt_top a)]
theorem image_coe_Icc : (some : α â WithTop α) '' Icc a b = Icc (a : WithTop α) b := by
rw [â preimage_coe_Icc, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left
(Subset.trans Icc_subset_Iic_self <| Iic_subset_Iio.2 <| coe_lt_top b)]
theorem image_coe_Ico : (some : α â WithTop α) '' Ico a b = Ico (a : WithTop α) b := by
rw [â preimage_coe_Ico, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Subset.trans Ico_subset_Iio_self <| Iio_subset_Iio le_top)]
theorem image_coe_Ioc : (some : α â WithTop α) '' Ioc a b = Ioc (a : WithTop α) b := by
rw [â preimage_coe_Ioc, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left
(Subset.trans Ioc_subset_Iic_self <| Iic_subset_Iio.2 <| coe_lt_top b)]
theorem image_coe_Ioo : (some : α â WithTop α) '' Ioo a b = Ioo (a : WithTop α) b := by
rw [â preimage_coe_Ioo, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Subset.trans Ioo_subset_Iio_self <| Iio_subset_Iio le_top)]
end WithTop
/-! ### `WithBot` -/
namespace WithBot
@[simp]
theorem preimage_coe_bot : (some : α â WithBot α) â»Â¹' {â¥} = (â
: Set α) :=
@WithTop.preimage_coe_top αáµáµ
variable [Preorder α] {a b : α}
theorem range_coe : range (some : α â WithBot α) = Ioi ⥠:=
@WithTop.range_coe αáµáµ _
@[simp]
theorem preimage_coe_Ioi : (some : α â WithBot α) â»Â¹' Ioi a = Ioi a :=
ext fun _ => coe_lt_coe
@[simp]
theorem preimage_coe_Ici : (some : α â WithBot α) â»Â¹' Ici a = Ici a :=
ext fun _ => coe_le_coe
@[simp]
theorem preimage_coe_Iio : (some : α â WithBot α) â»Â¹' Iio a = Iio a :=
ext fun _ => coe_lt_coe
@[simp]
theorem preimage_coe_Iic : (some : α â WithBot α) â»Â¹' Iic a = Iic a :=
ext fun _ => coe_le_coe
@[simp]
theorem preimage_coe_Icc : (some : α â WithBot α) â»Â¹' Icc a b = Icc a b := by simp [â Ici_inter_Iic]
@[simp]
theorem preimage_coe_Ico : (some : α â WithBot α) â»Â¹' Ico a b = Ico a b := by simp [â Ici_inter_Iio]
@[simp]
theorem preimage_coe_Ioc : (some : α â WithBot α) â»Â¹' Ioc a b = Ioc a b := by simp [â Ioi_inter_Iic]
@[simp]
theorem preimage_coe_Ioo : (some : α â WithBot α) â»Â¹' Ioo a b = Ioo a b := by simp [â Ioi_inter_Iio]
@[simp]
theorem preimage_coe_Ioi_bot : (some : α â WithBot α) â»Â¹' Ioi ⥠= univ := by
rw [â range_coe, preimage_range]
@[simp]
theorem preimage_coe_Ioc_bot : (some : α â WithBot α) â»Â¹' Ioc ⥠a = Iic a := by
simp [â Ioi_inter_Iic]
@[simp]
theorem preimage_coe_Ioo_bot : (some : α â WithBot α) â»Â¹' Ioo ⥠a = Iio a := by
simp [â Ioi_inter_Iio]
theorem image_coe_Iio : (some : α â WithBot α) '' Iio a = Ioo (⥠: WithBot α) a := by
rw [â preimage_coe_Iio, image_preimage_eq_inter_range, range_coe, inter_comm, Ioi_inter_Iio]
theorem image_coe_Iic : (some : α â WithBot α) '' Iic a = Ioc (⥠: WithBot α) a := by
rw [â preimage_coe_Iic, image_preimage_eq_inter_range, range_coe, inter_comm, Ioi_inter_Iic]
theorem image_coe_Ioi : (some : α â WithBot α) '' Ioi a = Ioi (a : WithBot α) := by
rw [â preimage_coe_Ioi, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Ioi_subset_Ioi bot_le)]
theorem image_coe_Ici : (some : α â WithBot α) '' Ici a = Ici (a : WithBot α) := by
rw [â preimage_coe_Ici, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Ici_subset_Ioi.2 <| bot_lt_coe a)]
theorem image_coe_Icc : (some : α â WithBot α) '' Icc a b = Icc (a : WithBot α) b := by
rw [â preimage_coe_Icc, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left
(Subset.trans Icc_subset_Ici_self <| Ici_subset_Ioi.2 <| bot_lt_coe a)]
theorem image_coe_Ioc : (some : α â WithBot α) '' Ioc a b = Ioc (a : WithBot α) b := by
rw [â preimage_coe_Ioc, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Subset.trans Ioc_subset_Ioi_self <| Ioi_subset_Ioi bot_le)]
theorem image_coe_Ico : (some : α â WithBot α) '' Ico a b = Ico (a : WithBot α) b := by
rw [â preimage_coe_Ico, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left
(Subset.trans Ico_subset_Ici_self <| Ici_subset_Ioi.2 <| bot_lt_coe a)]
theorem image_coe_Ioo : (some : α â WithBot α) '' Ioo a b = Ioo (a : WithBot α) b := by
rw [â preimage_coe_Ioo, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Subset.trans Ioo_subset_Ioi_self <| Ioi_subset_Ioi bot_le)]
end WithBot
| Mathlib/Order/Interval/Set/WithBotTop.lean | 197 | 198 | |
/-
Copyright (c) 2014 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis, Leonardo de Moura, Mario Carneiro, Floris van Doorn
-/
import Mathlib.Algebra.Field.Basic
import Mathlib.Algebra.GroupWithZero.Units.Lemmas
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Order.Bounds.Basic
import Mathlib.Order.Bounds.OrderIso
import Mathlib.Tactic.Positivity.Core
/-!
# Lemmas about linear ordered (semi)fields
-/
open Function OrderDual
variable {ι α β : Type*}
section LinearOrderedSemifield
variable [Semifield α] [LinearOrder α] [IsStrictOrderedRing α] {a b c d e : α} {m n : â€}
/-!
### Relating two divisions.
-/
@[deprecated div_le_div_iff_of_pos_right (since := "2024-11-12")]
theorem div_le_div_right (hc : 0 < c) : a / c †b / c â a †b := div_le_div_iff_of_pos_right hc
@[deprecated div_lt_div_iff_of_pos_right (since := "2024-11-12")]
theorem div_lt_div_right (hc : 0 < c) : a / c < b / c â a < b := div_lt_div_iff_of_pos_right hc
@[deprecated div_lt_div_iff_of_pos_left (since := "2024-11-13")]
theorem div_lt_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b < a / c â c < b :=
div_lt_div_iff_of_pos_left ha hb hc
@[deprecated div_le_div_iff_of_pos_left (since := "2024-11-12")]
theorem div_le_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b †a / c â c †b :=
div_le_div_iff_of_pos_left ha hb hc
@[deprecated div_lt_div_iffâ (since := "2024-11-12")]
theorem div_lt_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b < c / d â a * d < c * b :=
div_lt_div_iffâ b0 d0
@[deprecated div_le_div_iffâ (since := "2024-11-12")]
theorem div_le_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b †c / d â a * d †c * b :=
div_le_div_iffâ b0 d0
@[deprecated div_le_divâ (since := "2024-11-12")]
theorem div_le_div (hc : 0 †c) (hac : a †c) (hd : 0 < d) (hbd : d †b) : a / b †c / d :=
div_le_divâ hc hac hd hbd
@[deprecated div_lt_divâ (since := "2024-11-12")]
theorem div_lt_div (hac : a < c) (hbd : d †b) (c0 : 0 †c) (d0 : 0 < d) : a / b < c / d :=
div_lt_divâ hac hbd c0 d0
@[deprecated div_lt_divâ' (since := "2024-11-12")]
theorem div_lt_div' (hac : a †c) (hbd : d < b) (c0 : 0 < c) (d0 : 0 < d) : a / b < c / d :=
div_lt_divâ' hac hbd c0 d0
/-!
### Relating one division and involving `1`
-/
@[bound]
theorem div_le_self (ha : 0 †a) (hb : 1 †b) : a / b †a := by
simpa only [div_one] using div_le_div_of_nonneg_left ha zero_lt_one hb
@[bound]
theorem div_lt_self (ha : 0 < a) (hb : 1 < b) : a / b < a := by
simpa only [div_one] using div_lt_div_of_pos_left ha zero_lt_one hb
@[bound]
theorem le_div_self (ha : 0 †a) (hbâ : 0 < b) (hbâ : b †1) : a †a / b := by
simpa only [div_one] using div_le_div_of_nonneg_left ha hbâ hbâ
theorem one_le_div (hb : 0 < b) : 1 †a / b â b †a := by rw [le_div_iffâ hb, one_mul]
theorem div_le_one (hb : 0 < b) : a / b †1 â a †b := by rw [div_le_iffâ hb, one_mul]
theorem one_lt_div (hb : 0 < b) : 1 < a / b â b < a := by rw [lt_div_iffâ hb, one_mul]
theorem div_lt_one (hb : 0 < b) : a / b < 1 â a < b := by rw [div_lt_iffâ hb, one_mul]
theorem one_div_le (ha : 0 < a) (hb : 0 < b) : 1 / a †b â 1 / b †a := by
simpa using inv_le_commâ ha hb
theorem one_div_lt (ha : 0 < a) (hb : 0 < b) : 1 / a < b â 1 / b < a := by
simpa using inv_lt_commâ ha hb
theorem le_one_div (ha : 0 < a) (hb : 0 < b) : a †1 / b â b †1 / a := by
simpa using le_inv_commâ ha hb
theorem lt_one_div (ha : 0 < a) (hb : 0 < b) : a < 1 / b â b < 1 / a := by
simpa using lt_inv_commâ ha hb
@[bound] lemma Bound.one_lt_div_of_pos_of_lt (b0 : 0 < b) : b < a â 1 < a / b := (one_lt_div b0).mpr
@[bound] lemma Bound.div_lt_one_of_pos_of_lt (b0 : 0 < b) : a < b â a / b < 1 := (div_lt_one b0).mpr
/-!
### Relating two divisions, involving `1`
-/
theorem one_div_le_one_div_of_le (ha : 0 < a) (h : a †b) : 1 / b †1 / a := by
simpa using inv_antiâ ha h
theorem one_div_lt_one_div_of_lt (ha : 0 < a) (h : a < b) : 1 / b < 1 / a := by
rwa [lt_div_iffâ' ha, â div_eq_mul_one_div, div_lt_one (ha.trans h)]
theorem le_of_one_div_le_one_div (ha : 0 < a) (h : 1 / a †1 / b) : b †a :=
le_imp_le_of_lt_imp_lt (one_div_lt_one_div_of_lt ha) h
theorem lt_of_one_div_lt_one_div (ha : 0 < a) (h : 1 / a < 1 / b) : b < a :=
lt_imp_lt_of_le_imp_le (one_div_le_one_div_of_le ha) h
/-- For the single implications with fewer assumptions, see `one_div_le_one_div_of_le` and
`le_of_one_div_le_one_div` -/
theorem one_div_le_one_div (ha : 0 < a) (hb : 0 < b) : 1 / a †1 / b â b †a :=
div_le_div_iff_of_pos_left zero_lt_one ha hb
/-- For the single implications with fewer assumptions, see `one_div_lt_one_div_of_lt` and
`lt_of_one_div_lt_one_div` -/
theorem one_div_lt_one_div (ha : 0 < a) (hb : 0 < b) : 1 / a < 1 / b â b < a :=
div_lt_div_iff_of_pos_left zero_lt_one ha hb
theorem one_lt_one_div (h1 : 0 < a) (h2 : a < 1) : 1 < 1 / a := by
rwa [lt_one_div (@zero_lt_one α _ _ _ _ _) h1, one_div_one]
theorem one_le_one_div (h1 : 0 < a) (h2 : a †1) : 1 †1 / a := by
rwa [le_one_div (@zero_lt_one α _ _ _ _ _) h1, one_div_one]
/-!
### Results about halving.
The equalities also hold in semifields of characteristic `0`.
-/
theorem half_pos (h : 0 < a) : 0 < a / 2 :=
div_pos h zero_lt_two
theorem one_half_pos : (0 : α) < 1 / 2 :=
half_pos zero_lt_one
@[simp]
theorem half_le_self_iff : a / 2 †a â 0 †a := by
rw [div_le_iffâ (zero_lt_two' α), mul_two, le_add_iff_nonneg_left]
@[simp]
theorem half_lt_self_iff : a / 2 < a â 0 < a := by
rw [div_lt_iffâ (zero_lt_two' α), mul_two, lt_add_iff_pos_left]
alias âš_, half_le_selfâ© := half_le_self_iff
alias âš_, half_lt_selfâ© := half_lt_self_iff
alias div_two_lt_of_pos := half_lt_self
theorem one_half_lt_one : (1 / 2 : α) < 1 :=
half_lt_self zero_lt_one
theorem two_inv_lt_one : (2â»Â¹ : α) < 1 :=
(one_div _).symm.trans_lt one_half_lt_one
theorem left_lt_add_div_two : a < (a + b) / 2 â a < b := by simp [lt_div_iffâ, mul_two]
theorem add_div_two_lt_right : (a + b) / 2 < b â a < b := by simp [div_lt_iffâ, mul_two]
theorem add_thirds (a : α) : a / 3 + a / 3 + a / 3 = a := by
rw [div_add_div_same, div_add_div_same, â two_mul, â add_one_mul 2 a, two_add_one_eq_three,
mul_div_cancel_leftâ a three_ne_zero]
/-!
### Miscellaneous lemmas
-/
@[simp] lemma div_pos_iff_of_pos_left (ha : 0 < a) : 0 < a / b â 0 < b := by
simp only [div_eq_mul_inv, mul_pos_iff_of_pos_left ha, inv_pos]
@[simp] lemma div_pos_iff_of_pos_right (hb : 0 < b) : 0 < a / b â 0 < a := by
simp only [div_eq_mul_inv, mul_pos_iff_of_pos_right (inv_pos.2 hb)]
theorem mul_le_mul_of_mul_div_le (h : a * (b / c) †d) (hc : 0 < c) : b * a †d * c := by
rw [â mul_div_assoc] at h
rwa [mul_comm b, â div_le_iffâ hc]
theorem div_mul_le_div_mul_of_div_le_div (h : a / b †c / d) (he : 0 †e) :
a / (b * e) †c / (d * e) := by
rw [div_mul_eq_div_mul_one_div, div_mul_eq_div_mul_one_div]
exact mul_le_mul_of_nonneg_right h (one_div_nonneg.2 he)
theorem exists_pos_mul_lt {a : α} (h : 0 < a) (b : α) : â c : α, 0 < c â§ b * c < a := by
have : 0 < a / max (b + 1) 1 := div_pos h (lt_max_iff.2 (Or.inr zero_lt_one))
refine âša / max (b + 1) 1, this, ?_â©
rw [â lt_div_iffâ this, div_div_cancelâ h.ne']
exact lt_max_iff.2 (Or.inl <| lt_add_one _)
theorem exists_pos_lt_mul {a : α} (h : 0 < a) (b : α) : â c : α, 0 < c â§ b < c * a :=
let âšc, hcâ, hcâ© := exists_pos_mul_lt h b;
âšcâ»Â¹, inv_pos.2 hcâ, by rwa [â div_eq_inv_mul, lt_div_iffâ hcâ]â©
lemma monotone_div_right_of_nonneg (ha : 0 †a) : Monotone (· / a) :=
fun _b _c hbc ⊠div_le_div_of_nonneg_right hbc ha
lemma strictMono_div_right_of_pos (ha : 0 < a) : StrictMono (· / a) :=
fun _b _c hbc ⊠div_lt_div_of_pos_right hbc ha
theorem Monotone.div_const {β : Type*} [Preorder β] {f : β â α} (hf : Monotone f) {c : α}
(hc : 0 †c) : Monotone fun x => f x / c := (monotone_div_right_of_nonneg hc).comp hf
theorem StrictMono.div_const {β : Type*} [Preorder β] {f : β â α} (hf : StrictMono f) {c : α}
(hc : 0 < c) : StrictMono fun x => f x / c := by
simpa only [div_eq_mul_inv] using hf.mul_const (inv_pos.2 hc)
-- see Note [lower instance priority]
instance (priority := 100) LinearOrderedSemiField.toDenselyOrdered : DenselyOrdered α where
dense aâ aâ h :=
âš(aâ + aâ) / 2,
calc
aâ = (aâ + aâ) / 2 := (add_self_div_two aâ).symm
_ < (aâ + aâ) / 2 := div_lt_div_of_pos_right (add_lt_add_left h _) zero_lt_two
,
calc
(aâ + aâ) / 2 < (aâ + aâ) / 2 := div_lt_div_of_pos_right (add_lt_add_right h _) zero_lt_two
_ = aâ := add_self_div_two aâ
â©
theorem min_div_div_right {c : α} (hc : 0 †c) (a b : α) : min (a / c) (b / c) = min a b / c :=
(monotone_div_right_of_nonneg hc).map_min.symm
| theorem max_div_div_right {c : α} (hc : 0 †c) (a b : α) : max (a / c) (b / c) = max a b / c :=
(monotone_div_right_of_nonneg hc).map_max.symm
| Mathlib/Algebra/Order/Field/Basic.lean | 235 | 236 |
/-
Copyright (c) 2022 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Analysis.InnerProductSpace.Dual
import Mathlib.Analysis.InnerProductSpace.Orientation
import Mathlib.Data.Complex.FiniteDimensional
import Mathlib.Data.Complex.Orientation
import Mathlib.Tactic.LinearCombination
/-!
# Oriented two-dimensional real inner product spaces
This file defines constructions specific to the geometry of an oriented two-dimensional real inner
product space `E`.
## Main declarations
* `Orientation.areaForm`: an antisymmetric bilinear form `E ââ[â] E ââ[â] â` (usual notation `Ï`).
Morally, when `Ï` is evaluated on two vectors, it gives the oriented area of the parallelogram
they span. (But mathlib does not yet have a construction of oriented area, and in fact the
construction of oriented area should pass through `Ï`.)
* `Orientation.rightAngleRotation`: an isometric automorphism `E ââáµ¢[â] E` (usual notation `J`).
This automorphism squares to -1. In a later file, rotations (`Orientation.rotation`) are defined,
in such a way that this automorphism is equal to rotation by 90 degrees.
* `Orientation.basisRightAngleRotation`: for a nonzero vector `x` in `E`, the basis `![x, J x]`
for `E`.
* `Orientation.kahler`: a complex-valued real-bilinear map `E ââ[â] E ââ[â] â`. Its real part is the
inner product and its imaginary part is `Orientation.areaForm`. For vectors `x` and `y` in `E`,
the complex number `o.kahler x y` has modulus `âxâ * âyâ`. In a later file, oriented angles
(`Orientation.oangle`) are defined, in such a way that the argument of `o.kahler x y` is the
oriented angle from `x` to `y`.
## Main results
* `Orientation.rightAngleRotation_rightAngleRotation`: the identity `J (J x) = - x`
* `Orientation.nonneg_inner_and_areaForm_eq_zero_iff_sameRay`: `x`, `y` are in the same ray, if
and only if `0 †âªx, yâ«` and `Ï x y = 0`
* `Orientation.kahler_mul`: the identity `o.kahler x a * o.kahler a y = âaâ ^ 2 * o.kahler x y`
* `Complex.areaForm`, `Complex.rightAngleRotation`, `Complex.kahler`: the concrete
interpretations of `areaForm`, `rightAngleRotation`, `kahler` for the oriented real inner
product space `â`
* `Orientation.areaForm_map_complex`, `Orientation.rightAngleRotation_map_complex`,
`Orientation.kahler_map_complex`: given an orientation-preserving isometry from `E` to `â`,
expressions for `areaForm`, `rightAngleRotation`, `kahler` as the pullback of their concrete
interpretations on `â`
## Implementation notes
Notation `Ï` for `Orientation.areaForm` and `J` for `Orientation.rightAngleRotation` should be
defined locally in each file which uses them, since otherwise one would need a more cumbersome
notation which mentions the orientation explicitly (something like `Ï[o]`). Write
```
local notation "Ï" => o.areaForm
local notation "J" => o.rightAngleRotation
```
-/
noncomputable section
open scoped RealInnerProductSpace ComplexConjugate
open Module
lemma FiniteDimensional.of_fact_finrank_eq_two {K V : Type*} [DivisionRing K]
[AddCommGroup V] [Module K V] [Fact (finrank K V = 2)] : FiniteDimensional K V :=
.of_fact_finrank_eq_succ 1
attribute [local instance] FiniteDimensional.of_fact_finrank_eq_two
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace â E] [Fact (finrank â E = 2)]
(o : Orientation â E (Fin 2))
namespace Orientation
/-- An antisymmetric bilinear form on an oriented real inner product space of dimension 2 (usual
notation `Ï`). When evaluated on two vectors, it gives the oriented area of the parallelogram they
span. -/
irreducible_def areaForm : E ââ[â] E ââ[â] â := by
let z : E [â^Fin 0]ââ[â] â ââ[â] â :=
AlternatingMap.constLinearEquivOfIsEmpty.symm
let y : E [â^Fin 1]ââ[â] â ââ[â] E ââ[â] â :=
LinearMap.llcomp â E (E [â^Fin 0]ââ[â] â) â z ââ AlternatingMap.curryLeftLinearMap
exact y ââ AlternatingMap.curryLeftLinearMap (R' := â) o.volumeForm
local notation "Ï" => o.areaForm
theorem areaForm_to_volumeForm (x y : E) : Ï x y = o.volumeForm ![x, y] := by simp [areaForm]
@[simp]
theorem areaForm_apply_self (x : E) : Ï x x = 0 := by
rw [areaForm_to_volumeForm]
refine o.volumeForm.map_eq_zero_of_eq ![x, x] ?_ (?_ : (0 : Fin 2) â 1)
· simp
· norm_num
theorem areaForm_swap (x y : E) : Ï x y = -Ï y x := by
simp only [areaForm_to_volumeForm]
convert o.volumeForm.map_swap ![y, x] (_ : (0 : Fin 2) â 1)
· ext i
fin_cases i <;> rfl
· norm_num
@[simp]
theorem areaForm_neg_orientation : (-o).areaForm = -o.areaForm := by
ext x y
simp [areaForm_to_volumeForm]
/-- Continuous linear map version of `Orientation.areaForm`, useful for calculus. -/
def areaForm' : E âL[â] E âL[â] â :=
LinearMap.toContinuousLinearMap
(â(LinearMap.toContinuousLinearMap : (E ââ[â] â) ââ[â] E âL[â] â) ââ o.areaForm)
@[simp]
theorem areaForm'_apply (x : E) :
o.areaForm' x = LinearMap.toContinuousLinearMap (o.areaForm x) :=
rfl
theorem abs_areaForm_le (x y : E) : |Ï x y| †âxâ * âyâ := by
simpa [areaForm_to_volumeForm, Fin.prod_univ_succ] using o.abs_volumeForm_apply_le ![x, y]
theorem areaForm_le (x y : E) : Ï x y †âxâ * âyâ := by
simpa [areaForm_to_volumeForm, Fin.prod_univ_succ] using o.volumeForm_apply_le ![x, y]
theorem abs_areaForm_of_orthogonal {x y : E} (h : âªx, yâ« = 0) : |Ï x y| = âxâ * âyâ := by
rw [o.areaForm_to_volumeForm, o.abs_volumeForm_apply_of_pairwise_orthogonal]
· simp [Fin.prod_univ_succ]
intro i j hij
fin_cases i <;> fin_cases j
· simp_all
· simpa using h
· simpa [real_inner_comm] using h
· simp_all
theorem areaForm_map {F : Type*} [NormedAddCommGroup F] [InnerProductSpace â F]
[hF : Fact (finrank â F = 2)] (Ï : E ââáµ¢[â] F) (x y : F) :
(Orientation.map (Fin 2) Ï.toLinearEquiv o).areaForm x y =
o.areaForm (Ï.symm x) (Ï.symm y) := by
have : Ï.symm â ![x, y] = ![Ï.symm x, Ï.symm y] := by
ext i
fin_cases i <;> rfl
simp [areaForm_to_volumeForm, volumeForm_map, this]
/-- The area form is invariant under pullback by a positively-oriented isometric automorphism. -/
theorem areaForm_comp_linearIsometryEquiv (Ï : E ââáµ¢[â] E)
(hÏ : 0 < LinearMap.det (Ï.toLinearEquiv : E ââ[â] E)) (x y : E) :
o.areaForm (Ï x) (Ï y) = o.areaForm x y := by
convert o.areaForm_map Ï (Ï x) (Ï y)
· symm
rwa [â o.map_eq_iff_det_pos Ï.toLinearEquiv] at hÏ
rw [@Fact.out (finrank â E = 2), Fintype.card_fin]
· simp
· simp
/-- Auxiliary construction for `Orientation.rightAngleRotation`, rotation by 90 degrees in an
oriented real inner product space of dimension 2. -/
irreducible_def rightAngleRotationAuxâ : E ââ[â] E :=
let to_dual : E ââ[â] E ââ[â] â :=
(InnerProductSpace.toDual â E).toLinearEquiv âªâ«â LinearMap.toContinuousLinearMap.symm
âto_dual.symm ââ Ï
@[simp]
theorem inner_rightAngleRotationAuxâ_left (x y : E) : âªo.rightAngleRotationAuxâ x, yâ« = Ï x y := by
simp only [rightAngleRotationAuxâ, LinearEquiv.trans_symm, LinearIsometryEquiv.toLinearEquiv_symm,
LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.trans_apply,
LinearIsometryEquiv.coe_toLinearEquiv]
rw [InnerProductSpace.toDual_symm_apply]
norm_cast
@[simp]
theorem inner_rightAngleRotationAuxâ_right (x y : E) :
âªx, o.rightAngleRotationAuxâ yâ« = -Ï x y := by
rw [real_inner_comm]
simp [o.areaForm_swap y x]
/-- Auxiliary construction for `Orientation.rightAngleRotation`, rotation by 90 degrees in an
oriented real inner product space of dimension 2. -/
def rightAngleRotationAuxâ : E ââáµ¢[â] E :=
{ o.rightAngleRotationAuxâ with
norm_map' := fun x => by
refine le_antisymm ?_ ?_
· rcases eq_or_lt_of_le (norm_nonneg (o.rightAngleRotationAuxâ x)) with h | h
· rw [â h]
positivity
refine le_of_mul_le_mul_right ?_ h
rw [â real_inner_self_eq_norm_mul_norm, o.inner_rightAngleRotationAuxâ_left]
exact o.areaForm_le x (o.rightAngleRotationAuxâ x)
· let K : Submodule â E := â â x
have : Nontrivial Ká® := by
apply nontrivial_of_finrank_pos (R := â)
have : finrank â K †Finset.card {x} := by
rw [â Set.toFinset_singleton]
exact finrank_span_le_card ({x} : Set E)
have : Finset.card {x} = 1 := Finset.card_singleton x
have : finrank â K + finrank â Ká® = finrank â E := K.finrank_add_finrank_orthogonal
have : finrank â E = 2 := Fact.out
omega
obtain âšw, hwââ© : â w : Ká®, w â 0 := exists_ne 0
have hw' : âªx, (w : E)â« = 0 := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2
have hw : (w : E) â 0 := fun h => hwâ (Submodule.coe_eq_zero.mp h)
refine le_of_mul_le_mul_right ?_ (by rwa [norm_pos_iff] : 0 < â(w : E)â)
rw [â o.abs_areaForm_of_orthogonal hw']
rw [â o.inner_rightAngleRotationAuxâ_left x w]
exact abs_real_inner_le_norm (o.rightAngleRotationAuxâ x) w }
@[simp]
theorem rightAngleRotationAuxâ_rightAngleRotationAuxâ (x : E) :
o.rightAngleRotationAuxâ (o.rightAngleRotationAuxâ x) = -x := by
apply ext_inner_left â
intro y
have : âªo.rightAngleRotationAuxâ y, o.rightAngleRotationAuxâ xâ« = âªy, xâ« :=
LinearIsometry.inner_map_map o.rightAngleRotationAuxâ y x
rw [o.inner_rightAngleRotationAuxâ_right, â o.inner_rightAngleRotationAuxâ_left, this,
inner_neg_right]
/-- An isometric automorphism of an oriented real inner product space of dimension 2 (usual notation
`J`). This automorphism squares to -1. We will define rotations in such a way that this
automorphism is equal to rotation by 90 degrees. -/
irreducible_def rightAngleRotation : E ââáµ¢[â] E :=
LinearIsometryEquiv.ofLinearIsometry o.rightAngleRotationAuxâ (-o.rightAngleRotationAuxâ)
(by ext; simp [rightAngleRotationAuxâ]) (by ext; simp [rightAngleRotationAuxâ])
local notation "J" => o.rightAngleRotation
@[simp]
theorem inner_rightAngleRotation_left (x y : E) : âªJ x, yâ« = Ï x y := by
rw [rightAngleRotation]
exact o.inner_rightAngleRotationAuxâ_left x y
@[simp]
theorem inner_rightAngleRotation_right (x y : E) : âªx, J yâ« = -Ï x y := by
rw [rightAngleRotation]
exact o.inner_rightAngleRotationAuxâ_right x y
@[simp]
theorem rightAngleRotation_rightAngleRotation (x : E) : J (J x) = -x := by
rw [rightAngleRotation]
exact o.rightAngleRotationAuxâ_rightAngleRotationAuxâ x
@[simp]
theorem rightAngleRotation_symm :
LinearIsometryEquiv.symm J = LinearIsometryEquiv.trans J (LinearIsometryEquiv.neg â) := by
rw [rightAngleRotation]
exact LinearIsometryEquiv.toLinearIsometry_injective rfl
theorem inner_rightAngleRotation_self (x : E) : âªJ x, xâ« = 0 := by simp
theorem inner_rightAngleRotation_swap (x y : E) : âªx, J yâ« = -âªJ x, yâ« := by simp
theorem inner_rightAngleRotation_swap' (x y : E) : âªJ x, yâ« = -âªx, J yâ« := by
simp [o.inner_rightAngleRotation_swap x y]
theorem inner_comp_rightAngleRotation (x y : E) : âªJ x, J yâ« = âªx, yâ« :=
LinearIsometryEquiv.inner_map_map J x y
@[simp]
theorem areaForm_rightAngleRotation_left (x y : E) : Ï (J x) y = -âªx, yâ« := by
rw [â o.inner_comp_rightAngleRotation, o.inner_rightAngleRotation_right, neg_neg]
@[simp]
theorem areaForm_rightAngleRotation_right (x y : E) : Ï x (J y) = âªx, yâ« := by
rw [â o.inner_rightAngleRotation_left, o.inner_comp_rightAngleRotation]
theorem areaForm_comp_rightAngleRotation (x y : E) : Ï (J x) (J y) = Ï x y := by simp
@[simp]
theorem rightAngleRotation_trans_rightAngleRotation :
LinearIsometryEquiv.trans J J = LinearIsometryEquiv.neg â := by ext; simp
theorem rightAngleRotation_neg_orientation (x : E) :
(-o).rightAngleRotation x = -o.rightAngleRotation x := by
apply ext_inner_right â
intro y
rw [inner_rightAngleRotation_left]
simp
@[simp]
theorem rightAngleRotation_trans_neg_orientation :
(-o).rightAngleRotation = o.rightAngleRotation.trans (LinearIsometryEquiv.neg â) :=
LinearIsometryEquiv.ext <| o.rightAngleRotation_neg_orientation
theorem rightAngleRotation_map {F : Type*} [NormedAddCommGroup F] [InnerProductSpace â F]
[hF : Fact (finrank â F = 2)] (Ï : E ââáµ¢[â] F) (x : F) :
(Orientation.map (Fin 2) Ï.toLinearEquiv o).rightAngleRotation x =
Ï (o.rightAngleRotation (Ï.symm x)) := by
apply ext_inner_right â
intro y
rw [inner_rightAngleRotation_left]
trans âªJ (Ï.symm x), Ï.symm yâ«
· simp [o.areaForm_map]
trans âªÏ (J (Ï.symm x)), Ï (Ï.symm y)â«
· rw [Ï.inner_map_map]
· simp
/-- `J` commutes with any positively-oriented isometric automorphism. -/
theorem linearIsometryEquiv_comp_rightAngleRotation (Ï : E ââáµ¢[â] E)
(hÏ : 0 < LinearMap.det (Ï.toLinearEquiv : E ââ[â] E)) (x : E) : Ï (J x) = J (Ï x) := by
convert (o.rightAngleRotation_map Ï (Ï x)).symm
· simp
· symm
rwa [â o.map_eq_iff_det_pos Ï.toLinearEquiv] at hÏ
rw [@Fact.out (finrank â E = 2), Fintype.card_fin]
theorem rightAngleRotation_map' {F : Type*} [NormedAddCommGroup F] [InnerProductSpace â F]
[Fact (finrank â F = 2)] (Ï : E ââáµ¢[â] F) :
(Orientation.map (Fin 2) Ï.toLinearEquiv o).rightAngleRotation =
(Ï.symm.trans o.rightAngleRotation).trans Ï :=
LinearIsometryEquiv.ext <| o.rightAngleRotation_map Ï
/-- `J` commutes with any positively-oriented isometric automorphism. -/
theorem linearIsometryEquiv_comp_rightAngleRotation' (Ï : E ââáµ¢[â] E)
(hÏ : 0 < LinearMap.det (Ï.toLinearEquiv : E ââ[â] E)) :
LinearIsometryEquiv.trans J Ï = Ï.trans J :=
LinearIsometryEquiv.ext <| o.linearIsometryEquiv_comp_rightAngleRotation Ï hÏ
/-- For a nonzero vector `x` in an oriented two-dimensional real inner product space `E`,
`![x, J x]` forms an (orthogonal) basis for `E`. -/
def basisRightAngleRotation (x : E) (hx : x â 0) : Basis (Fin 2) â E :=
@basisOfLinearIndependentOfCardEqFinrank â _ _ _ _ _ _ _ ![x, J x]
(linearIndependent_of_ne_zero_of_inner_eq_zero (fun i => by fin_cases i <;> simp [hx])
(by
intro i j hij
fin_cases i <;> fin_cases j <;> simp_all))
(@Fact.out (finrank â E = 2)).symm
@[simp]
theorem coe_basisRightAngleRotation (x : E) (hx : x â 0) :
â(o.basisRightAngleRotation x hx) = ![x, J x] :=
coe_basisOfLinearIndependentOfCardEqFinrank _ _
/-- For vectors `a x y : E`, the identity `âªa, xâ« * âªa, yâ« + Ï a x * Ï a y = âaâ ^ 2 * âªx, yâ«`. (See
`Orientation.inner_mul_inner_add_areaForm_mul_areaForm` for the "applied" form.) -/
theorem inner_mul_inner_add_areaForm_mul_areaForm' (a x : E) :
âªa, x⫠⢠innerââ â a + Ï a x â¢ Ï a = âaâ ^ 2 ⢠innerââ â x := by
by_cases ha : a = 0
· simp [ha]
apply (o.basisRightAngleRotation a ha).ext
intro i
fin_cases i
· simp [real_inner_self_eq_norm_sq, mul_comm, real_inner_comm]
· simp [real_inner_self_eq_norm_sq, mul_comm, o.areaForm_swap a x]
/-- For vectors `a x y : E`, the identity `âªa, xâ« * âªa, yâ« + Ï a x * Ï a y = âaâ ^ 2 * âªx, yâ«`. -/
theorem inner_mul_inner_add_areaForm_mul_areaForm (a x y : E) :
âªa, xâ« * âªa, yâ« + Ï a x * Ï a y = âaâ ^ 2 * âªx, yâ« :=
congr_arg (fun f : E ââ[â] â => f y) (o.inner_mul_inner_add_areaForm_mul_areaForm' a x)
theorem inner_sq_add_areaForm_sq (a b : E) : âªa, bâ« ^ 2 + Ï a b ^ 2 = âaâ ^ 2 * âbâ ^ 2 := by
simpa [sq, real_inner_self_eq_norm_sq] using o.inner_mul_inner_add_areaForm_mul_areaForm a b b
/-- For vectors `a x y : E`, the identity `âªa, xâ« * Ï a y - Ï a x * âªa, yâ« = âaâ ^ 2 * Ï x y`. (See
`Orientation.inner_mul_areaForm_sub` for the "applied" form.) -/
theorem inner_mul_areaForm_sub' (a x : E) : âªa, xâ« â¢ Ï a - Ï a x ⢠innerââ â a = âaâ ^ 2 â¢ Ï x := by
by_cases ha : a = 0
· simp [ha]
apply (o.basisRightAngleRotation a ha).ext
intro i
fin_cases i
· simp [real_inner_self_eq_norm_sq, mul_comm, o.areaForm_swap a x]
· simp [real_inner_self_eq_norm_sq, mul_comm, real_inner_comm]
/-- For vectors `a x y : E`, the identity `âªa, xâ« * Ï a y - Ï a x * âªa, yâ« = âaâ ^ 2 * Ï x y`. -/
theorem inner_mul_areaForm_sub (a x y : E) : âªa, xâ« * Ï a y - Ï a x * âªa, yâ« = âaâ ^ 2 * Ï x y :=
congr_arg (fun f : E ââ[â] â => f y) (o.inner_mul_areaForm_sub' a x)
theorem nonneg_inner_and_areaForm_eq_zero_iff_sameRay (x y : E) :
0 †âªx, yâ« â§ Ï x y = 0 â SameRay â x y := by
by_cases hx : x = 0
· simp [hx]
constructor
· let a : â := (o.basisRightAngleRotation x hx).repr y 0
let b : â := (o.basisRightAngleRotation x hx).repr y 1
suffices â0 †a * âxâ ^ 2 â§ b * âxâ ^ 2 = 0 â SameRay â x (a ⢠x + b ⢠J x) by
rw [â (o.basisRightAngleRotation x hx).sum_repr y]
simp only [Fin.sum_univ_succ, coe_basisRightAngleRotation, Matrix.cons_val_zero,
Fin.succ_zero_eq_one', Finset.univ_eq_empty, Finset.sum_empty, areaForm_apply_self,
map_smul, map_add, real_inner_smul_right, inner_add_right, Matrix.cons_val_one,
Matrix.head_cons, Algebra.id.smul_eq_mul, areaForm_rightAngleRotation_right,
mul_zero, add_zero, zero_add, neg_zero, inner_rightAngleRotation_right,
real_inner_self_eq_norm_sq, zero_smul, one_smul]
exact this
rintro âšha, hbâ©
have hx' : 0 < âxâ := by simpa using hx
have ha' : 0 †a := nonneg_of_mul_nonneg_left ha (by positivity)
have hb' : b = 0 := eq_zero_of_ne_zero_of_mul_right_eq_zero (pow_ne_zero 2 hx'.ne') hb
exact (SameRay.sameRay_nonneg_smul_right x ha').add_right <| by simp [hb']
· intro h
obtain âšr, hr, rflâ© := h.exists_nonneg_left hx
simp only [inner_smul_right, real_inner_self_eq_norm_sq, LinearMap.map_smulââ,
areaForm_apply_self, Algebra.id.smul_eq_mul, mul_zero, eq_self_iff_true, and_true]
positivity
/-- A complex-valued real-bilinear map on an oriented real inner product space of dimension 2. Its
real part is the inner product and its imaginary part is `Orientation.areaForm`.
On `â` with the standard orientation, `kahler w z = conj w * z`; see `Complex.kahler`. -/
def kahler : E ââ[â] E ââ[â] â :=
LinearMap.llcomp â E â â Complex.ofRealCLM ââ innerââ â +
LinearMap.llcomp â E â â ((LinearMap.lsmul â â).flip Complex.I) ââ Ï
theorem kahler_apply_apply (x y : E) : o.kahler x y = âªx, yâ« + Ï x y ⢠Complex.I :=
rfl
theorem kahler_swap (x y : E) : o.kahler x y = conj (o.kahler y x) := by
simp only [kahler_apply_apply]
rw [real_inner_comm, areaForm_swap]
simp [Complex.conj_ofReal]
@[simp]
theorem kahler_apply_self (x : E) : o.kahler x x = âxâ ^ 2 := by
simp [kahler_apply_apply, real_inner_self_eq_norm_sq]
@[simp]
theorem kahler_rightAngleRotation_left (x y : E) :
o.kahler (J x) y = -Complex.I * o.kahler x y := by
simp only [o.areaForm_rightAngleRotation_left, o.inner_rightAngleRotation_left,
o.kahler_apply_apply, Complex.ofReal_neg, Complex.real_smul]
linear_combination Ï x y * Complex.I_sq
@[simp]
theorem kahler_rightAngleRotation_right (x y : E) :
o.kahler x (J y) = Complex.I * o.kahler x y := by
simp only [o.areaForm_rightAngleRotation_right, o.inner_rightAngleRotation_right,
o.kahler_apply_apply, Complex.ofReal_neg, Complex.real_smul]
linear_combination -Ï x y * Complex.I_sq
-- @[simp] -- Porting note: simp normal form is `kahler_comp_rightAngleRotation'`
theorem kahler_comp_rightAngleRotation (x y : E) : o.kahler (J x) (J y) = o.kahler x y := by
simp only [kahler_rightAngleRotation_left, kahler_rightAngleRotation_right]
linear_combination -o.kahler x y * Complex.I_sq
theorem kahler_comp_rightAngleRotation' (x y : E) :
-(Complex.I * (Complex.I * o.kahler x y)) = o.kahler x y := by
linear_combination -o.kahler x y * Complex.I_sq
|
@[simp]
theorem kahler_neg_orientation (x y : E) : (-o).kahler x y = conj (o.kahler x y) := by
simp [kahler_apply_apply, Complex.conj_ofReal]
theorem kahler_mul (a x y : E) : o.kahler x a * o.kahler a y = âaâ ^ 2 * o.kahler x y := by
trans ((âaâ ^ 2 :) : â) * o.kahler x y
· apply Complex.ext
· simp only [o.kahler_apply_apply, Complex.add_im, Complex.add_re, Complex.I_im, Complex.I_re,
Complex.mul_im, Complex.mul_re, Complex.ofReal_im, Complex.ofReal_re, Complex.real_smul]
rw [real_inner_comm a x, o.areaForm_swap x a]
linear_combination o.inner_mul_inner_add_areaForm_mul_areaForm a x y
· simp only [o.kahler_apply_apply, Complex.add_im, Complex.add_re, Complex.I_im, Complex.I_re,
Complex.mul_im, Complex.mul_re, Complex.ofReal_im, Complex.ofReal_re, Complex.real_smul]
rw [real_inner_comm a x, o.areaForm_swap x a]
linear_combination o.inner_mul_areaForm_sub a x y
· norm_cast
theorem normSq_kahler (x y : E) : Complex.normSq (o.kahler x y) = âxâ ^ 2 * âyâ ^ 2 := by
simpa [kahler_apply_apply, Complex.normSq, sq] using o.inner_sq_add_areaForm_sq x y
theorem norm_kahler (x y : E) : âo.kahler x yâ = âxâ * âyâ := by
rw [â sq_eq_sqâ, Complex.sq_norm]
· linear_combination o.normSq_kahler x y
· positivity
· positivity
| Mathlib/Analysis/InnerProductSpace/TwoDim.lean | 446 | 472 |
/-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Order.Interval.Finset.Nat
import Mathlib.Topology.EMetricSpace.Defs
import Mathlib.Topology.UniformSpace.Compact
import Mathlib.Topology.UniformSpace.LocallyUniformConvergence
import Mathlib.Topology.UniformSpace.UniformEmbedding
/-!
# Extended metric spaces
Further results about extended metric spaces.
-/
open Set Filter
universe u v w
variable {α : Type u} {β : Type v} {X : Type*}
open scoped Uniformity Topology NNReal ENNReal Pointwise
variable [PseudoEMetricSpace α]
/-- The triangle (polygon) inequality for sequences of points; `Finset.Ico` version. -/
theorem edist_le_Ico_sum_edist (f : â â α) {m n} (h : m †n) :
edist (f m) (f n) †â i â Finset.Ico m n, edist (f i) (f (i + 1)) := by
induction n, h using Nat.le_induction with
| base => rw [Finset.Ico_self, Finset.sum_empty, edist_self]
| succ n hle ihn =>
calc
edist (f m) (f (n + 1)) †edist (f m) (f n) + edist (f n) (f (n + 1)) := edist_triangle _ _ _
_ †(â i â Finset.Ico m n, _) + _ := add_le_add ihn le_rfl
_ = â i â Finset.Ico m (n + 1), _ := by
{ rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp }
/-- The triangle (polygon) inequality for sequences of points; `Finset.range` version. -/
theorem edist_le_range_sum_edist (f : â â α) (n : â) :
edist (f 0) (f n) †â i â Finset.range n, edist (f i) (f (i + 1)) :=
Nat.Ico_zero_eq_range âž edist_le_Ico_sum_edist f (Nat.zero_le n)
/-- A version of `edist_le_Ico_sum_edist` with each intermediate distance replaced
with an upper estimate. -/
theorem edist_le_Ico_sum_of_edist_le {f : â â α} {m n} (hmn : m †n) {d : â â ââ¥0â}
(hd : â {k}, m †k â k < n â edist (f k) (f (k + 1)) †d k) :
edist (f m) (f n) †â i â Finset.Ico m n, d i :=
le_trans (edist_le_Ico_sum_edist f hmn) <|
Finset.sum_le_sum fun _k hk => hd (Finset.mem_Ico.1 hk).1 (Finset.mem_Ico.1 hk).2
/-- A version of `edist_le_range_sum_edist` with each intermediate distance replaced
with an upper estimate. -/
theorem edist_le_range_sum_of_edist_le {f : â â α} (n : â) {d : â â ââ¥0â}
(hd : â {k}, k < n â edist (f k) (f (k + 1)) †d k) :
edist (f 0) (f n) †â i â Finset.range n, d i :=
Nat.Ico_zero_eq_range âž edist_le_Ico_sum_of_edist_le (zero_le n) fun _ => hd
namespace EMetric
theorem isUniformInducing_iff [PseudoEMetricSpace β] {f : α â β} :
IsUniformInducing f â UniformContinuous f â§
â ÎŽ > 0, â ε > 0, â {a b : α}, edist (f a) (f b) < ε â edist a b < ÎŽ :=
isUniformInducing_iff'.trans <| Iff.rfl.and <|
((uniformity_basis_edist.comap _).le_basis_iff uniformity_basis_edist).trans <| by
simp only [subset_def, Prod.forall]; rfl
/-- ε-Ύ characterization of uniform embeddings on pseudoemetric spaces -/
nonrec theorem isUniformEmbedding_iff [PseudoEMetricSpace β] {f : α â β} :
IsUniformEmbedding f â Function.Injective f â§ UniformContinuous f â§
â ÎŽ > 0, â ε > 0, â {a b : α}, edist (f a) (f b) < ε â edist a b < ÎŽ :=
(isUniformEmbedding_iff _).trans <| and_comm.trans <| Iff.rfl.and isUniformInducing_iff
/-- If a map between pseudoemetric spaces is a uniform embedding then the edistance between `f x`
and `f y` is controlled in terms of the distance between `x` and `y`.
In fact, this lemma holds for a `IsUniformInducing` map.
TODO: generalize? -/
theorem controlled_of_isUniformEmbedding [PseudoEMetricSpace β] {f : α â β}
(h : IsUniformEmbedding f) :
(â ε > 0, â ÎŽ > 0, â {a b : α}, edist a b < ÎŽ â edist (f a) (f b) < ε) â§
â ÎŽ > 0, â ε > 0, â {a b : α}, edist (f a) (f b) < ε â edist a b < ÎŽ :=
âšuniformContinuous_iff.1 h.uniformContinuous, (isUniformEmbedding_iff.1 h).2.2â©
/-- ε-Ύ characterization of Cauchy sequences on pseudoemetric spaces -/
protected theorem cauchy_iff {f : Filter α} :
Cauchy f â f â ⥠⧠â ε > 0, â t â f, â x, x â t â â y, y â t â edist x y < ε := by
rw [â neBot_iff]; exact uniformity_basis_edist.cauchy_iff
/-- A very useful criterion to show that a space is complete is to show that all sequences
which satisfy a bound of the form `edist (u n) (u m) < B N` for all `n m ⥠N` are
converging. This is often applied for `B N = 2^{-N}`, i.e., with a very fast convergence to
`0`, which makes it possible to use arguments of converging series, while this is impossible
to do in general for arbitrary Cauchy sequences. -/
theorem complete_of_convergent_controlled_sequences (B : â â ââ¥0â) (hB : â n, 0 < B n)
(H : â u : â â α, (â N n m : â, N †n â N †m â edist (u n) (u m) < B N) â
â x, Tendsto u atTop (ð x)) :
CompleteSpace α :=
UniformSpace.complete_of_convergent_controlled_sequences
(fun n => { p : α à α | edist p.1 p.2 < B n }) (fun n => edist_mem_uniformity <| hB n) H
/-- A sequentially complete pseudoemetric space is complete. -/
theorem complete_of_cauchySeq_tendsto :
(â u : â â α, CauchySeq u â â a, Tendsto u atTop (ð a)) â CompleteSpace α :=
UniformSpace.complete_of_cauchySeq_tendsto
/-- Expressing locally uniform convergence on a set using `edist`. -/
theorem tendstoLocallyUniformlyOn_iff {ι : Type*} [TopologicalSpace β] {F : ι â β â α} {f : β â α}
{p : Filter ι} {s : Set β} :
TendstoLocallyUniformlyOn F f p s â
â ε > 0, â x â s, â t â ð[s] x, âá¶ n in p, â y â t, edist (f y) (F n y) < ε := by
refine âšfun H ε hε => H _ (edist_mem_uniformity hε), fun H u hu x hx => ?_â©
rcases mem_uniformity_edist.1 hu with âšÎµ, εpos, hεâ©
rcases H ε εpos x hx with âšt, ht, Htâ©
exact âšt, ht, Ht.mono fun n hs x hx => hε (hs x hx)â©
/-- Expressing uniform convergence on a set using `edist`. -/
theorem tendstoUniformlyOn_iff {ι : Type*} {F : ι â β â α} {f : β â α} {p : Filter ι} {s : Set β} :
TendstoUniformlyOn F f p s â â ε > 0, âá¶ n in p, â x â s, edist (f x) (F n x) < ε := by
refine âšfun H ε hε => H _ (edist_mem_uniformity hε), fun H u hu => ?_â©
rcases mem_uniformity_edist.1 hu with âšÎµ, εpos, hεâ©
exact (H ε εpos).mono fun n hs x hx => hε (hs x hx)
/-- Expressing locally uniform convergence using `edist`. -/
theorem tendstoLocallyUniformly_iff {ι : Type*} [TopologicalSpace β] {F : ι â β â α} {f : β â α}
{p : Filter ι} :
TendstoLocallyUniformly F f p â
â ε > 0, â x : β, â t â ð x, âá¶ n in p, â y â t, edist (f y) (F n y) < ε := by
simp only [â tendstoLocallyUniformlyOn_univ, tendstoLocallyUniformlyOn_iff, mem_univ,
forall_const, exists_prop, nhdsWithin_univ]
/-- Expressing uniform convergence using `edist`. -/
theorem tendstoUniformly_iff {ι : Type*} {F : ι â β â α} {f : β â α} {p : Filter ι} :
TendstoUniformly F f p â â ε > 0, âá¶ n in p, â x, edist (f x) (F n x) < ε := by
simp only [â tendstoUniformlyOn_univ, tendstoUniformlyOn_iff, mem_univ, forall_const]
end EMetric
open EMetric
namespace EMetric
variable {x y z : α} {ε εâ εâ : ââ¥0â} {s t : Set α}
theorem inseparable_iff : Inseparable x y â edist x y = 0 := by
simp [inseparable_iff_mem_closure, mem_closure_iff, edist_comm, forall_lt_iff_le']
alias âš_root_.Inseparable.edist_eq_zero, _â© := EMetric.inseparable_iff
-- see Note [nolint_ge]
/-- In a pseudoemetric space, Cauchy sequences are characterized by the fact that, eventually,
the pseudoedistance between its elements is arbitrarily small -/
theorem cauchySeq_iff [Nonempty β] [SemilatticeSup β] {u : β â α} :
CauchySeq u â â ε > 0, â N, â m, N †m â â n, N †n â edist (u m) (u n) < ε :=
uniformity_basis_edist.cauchySeq_iff
/-- A variation around the emetric characterization of Cauchy sequences -/
theorem cauchySeq_iff' [Nonempty β] [SemilatticeSup β] {u : β â α} :
CauchySeq u â â ε > (0 : ââ¥0â), â N, â n ⥠N, edist (u n) (u N) < ε :=
uniformity_basis_edist.cauchySeq_iff'
/-- A variation of the emetric characterization of Cauchy sequences that deals with
`ââ¥0` upper bounds. -/
theorem cauchySeq_iff_NNReal [Nonempty β] [SemilatticeSup β] {u : β â α} :
CauchySeq u â â ε : ââ¥0, 0 < ε â â N, â n, N †n â edist (u n) (u N) < ε :=
uniformity_basis_edist_nnreal.cauchySeq_iff'
theorem totallyBounded_iff {s : Set α} :
TotallyBounded s â â ε > 0, â t : Set α, t.Finite â§ s â â y â t, ball y ε :=
âšfun H _ε ε0 => H _ (edist_mem_uniformity ε0), fun H _r ru =>
let âšÎµ, ε0, hε⩠:= mem_uniformity_edist.1 ru
let âšt, ft, hâ© := H ε ε0
âšt, ft, h.trans <| iUnionâ_mono fun _ _ _ => hεâ©â©
theorem totallyBounded_iff' {s : Set α} :
TotallyBounded s â â ε > 0, â t, t â s â§ Set.Finite t â§ s â â y â t, ball y ε :=
âšfun H _ε ε0 => (totallyBounded_iff_subset.1 H) _ (edist_mem_uniformity ε0), fun H _r ru =>
let âšÎµ, ε0, hε⩠:= mem_uniformity_edist.1 ru
let âšt, _, ft, hâ© := H ε ε0
âšt, ft, h.trans <| iUnionâ_mono fun _ _ _ => hεâ©â©
section Compact
-- TODO: generalize to metrizable spaces
/-- A compact set in a pseudo emetric space is separable, i.e., it is a subset of the closure of a
countable set. -/
theorem subset_countable_closure_of_compact {s : Set α} (hs : IsCompact s) :
â t, t â s â§ t.Countable â§ s â closure t := by
refine subset_countable_closure_of_almost_dense_set s fun ε hε => ?_
rcases totallyBounded_iff'.1 hs.totallyBounded ε hε with âšt, -, htf, hstâ©
exact âšt, htf.countable, hst.trans <| iUnionâ_mono fun _ _ => ball_subset_closedBallâ©
end Compact
section SecondCountable
open TopologicalSpace
variable (α) in
/-- A sigma compact pseudo emetric space has second countable topology. -/
instance (priority := 90) secondCountable_of_sigmaCompact [SigmaCompactSpace α] :
SecondCountableTopology α := by
suffices SeparableSpace α by exact UniformSpace.secondCountable_of_separable α
choose T _ hTc hsubT using fun n =>
subset_countable_closure_of_compact (isCompact_compactCovering α n)
refine âšâšâ n, T n, countable_iUnion hTc, fun x => ?_â©â©
rcases iUnion_eq_univ_iff.1 (iUnion_compactCovering α) x with âšn, hnâ©
exact closure_mono (subset_iUnion _ n) (hsubT _ hn)
theorem secondCountable_of_almost_dense_set
(hs : â ε > 0, â t : Set α, t.Countable â§ â x â t, closedBall x ε = univ) :
SecondCountableTopology α := by
suffices SeparableSpace α from UniformSpace.secondCountable_of_separable α
have : â ε > 0, â t : Set α, Set.Countable t â§ univ â â x â t, closedBall x ε := by
simpa only [univ_subset_iff] using hs
rcases subset_countable_closure_of_almost_dense_set (univ : Set α) this with âšt, -, htc, htâ©
exact âšâšt, htc, fun x => ht (mem_univ x)â©â©
end SecondCountable
end EMetric
variable {γ : Type w} [EMetricSpace γ]
-- see Note [lower instance priority]
/-- An emetric space is separated -/
instance (priority := 100) EMetricSpace.instT0Space : T0Space γ where
t0 _ _ h := eq_of_edist_eq_zero <| inseparable_iff.1 h
/-- A map between emetric spaces is a uniform embedding if and only if the edistance between `f x`
and `f y` is controlled in terms of the distance between `x` and `y` and conversely. -/
theorem EMetric.isUniformEmbedding_iff' [PseudoEMetricSpace β] {f : γ â β} :
IsUniformEmbedding f â
(â ε > 0, â ÎŽ > 0, â {a b : γ}, edist a b < ÎŽ â edist (f a) (f b) < ε) â§
â ÎŽ > 0, â ε > 0, â {a b : γ}, edist (f a) (f b) < ε â edist a b < ÎŽ := by
rw [isUniformEmbedding_iff_isUniformInducing, isUniformInducing_iff, uniformContinuous_iff]
/-- If a `PseudoEMetricSpace` is a Tâ space, then it is an `EMetricSpace`. -/
-- TODO: make it an instance?
abbrev EMetricSpace.ofT0PseudoEMetricSpace (α : Type*) [PseudoEMetricSpace α] [T0Space α] :
EMetricSpace α :=
{ â¹PseudoEMetricSpace α⺠with
eq_of_edist_eq_zero := fun h => (EMetric.inseparable_iff.2 h).eq }
/-- The product of two emetric spaces, with the max distance, is an extended
metric spaces. We make sure that the uniform structure thus constructed is the one
corresponding to the product of uniform spaces, to avoid diamond problems. -/
instance Prod.emetricSpaceMax [EMetricSpace β] : EMetricSpace (γ à β) :=
.ofT0PseudoEMetricSpace _
namespace EMetric
/-- A compact set in an emetric space is separable, i.e., it is the closure of a countable set. -/
theorem countable_closure_of_compact {s : Set γ} (hs : IsCompact s) :
â t, t â s â§ t.Countable â§ s = closure t := by
rcases subset_countable_closure_of_compact hs with âšt, hts, htc, hsubâ©
exact âšt, hts, htc, hsub.antisymm (closure_minimal hts hs.isClosed)â©
end EMetric
/-!
### Separation quotient
-/
instance [PseudoEMetricSpace X] : EDist (SeparationQuotient X) where
edist := SeparationQuotient.liftâ edist fun _ _ _ _ hx hy =>
edist_congr (EMetric.inseparable_iff.1 hx) (EMetric.inseparable_iff.1 hy)
@[simp] theorem SeparationQuotient.edist_mk [PseudoEMetricSpace X] (x y : X) :
edist (mk x) (mk y) = edist x y :=
rfl
open SeparationQuotient in
instance [PseudoEMetricSpace X] : EMetricSpace (SeparationQuotient X) :=
@EMetricSpace.ofT0PseudoEMetricSpace (SeparationQuotient X)
{ edist_self := surjective_mk.forall.2 edist_self,
edist_comm := surjective_mk.forallâ.2 edist_comm,
edist_triangle := surjective_mk.forallâ.2 edist_triangle,
toUniformSpace := inferInstance,
uniformity_edist := comap_injective (surjective_mk.prodMap surjective_mk) <| by
simp [comap_mk_uniformity, PseudoEMetricSpace.uniformity_edist] } _
namespace TopologicalSpace
section Compact
open Topology
/-- If a set `s` is separable in a (pseudo extended) metric space, then it admits a countable dense
subset. This is not obvious, as the countable set whose closure covers `s` given by the definition
of separability does not need in general to be contained in `s`. -/
theorem IsSeparable.exists_countable_dense_subset
{s : Set α} (hs : IsSeparable s) : â t, t â s â§ t.Countable â§ s â closure t := by
have : â ε > 0, â t : Set α, t.Countable â§ s â â x â t, closedBall x ε := fun ε ε0 => by
rcases hs with âšt, htc, hstâ©
refine âšt, htc, hst.trans fun x hx => ?_â©
rcases mem_closure_iff.1 hx ε ε0 with âšy, hyt, hxyâ©
exact mem_iUnionâ.2 âšy, hyt, mem_closedBall.2 hxy.leâ©
exact subset_countable_closure_of_almost_dense_set _ this
/-- If a set `s` is separable, then the corresponding subtype is separable in a (pseudo extended)
metric space. This is not obvious, as the countable set whose closure covers `s` does not need in
general to be contained in `s`. -/
theorem IsSeparable.separableSpace {s : Set α} (hs : IsSeparable s) :
SeparableSpace s := by
rcases hs.exists_countable_dense_subset with âšt, hts, htc, hstâ©
lift t to Set s using hts
refine âšâšt, countable_of_injective_of_countable_image Subtype.coe_injective.injOn htc, ?_â©â©
rwa [IsInducing.subtypeVal.dense_iff, Subtype.forall]
end Compact
end TopologicalSpace
section LebesgueNumberLemma
variable {s : Set α}
theorem lebesgue_number_lemma_of_emetric {ι : Sort*} {c : ι â Set α} (hs : IsCompact s)
(hcâ : â i, IsOpen (c i)) (hcâ : s â â i, c i) : â ÎŽ > 0, â x â s, â i, ball x ÎŽ â c i := by
simpa only [ball, UniformSpace.ball, preimage_setOf_eq, edist_comm]
using uniformity_basis_edist.lebesgue_number_lemma hs hcâ hcâ
theorem lebesgue_number_lemma_of_emetric_nhds' {c : (x : α) â x â s â Set α} (hs : IsCompact s)
(hc : â x hx, c x hx â ð x) : â ÎŽ > 0, â x â s, â y : s, ball x ÎŽ â c y y.2 := by
simpa only [ball, UniformSpace.ball, preimage_setOf_eq, edist_comm]
using uniformity_basis_edist.lebesgue_number_lemma_nhds' hs hc
theorem lebesgue_number_lemma_of_emetric_nhds {c : α â Set α} (hs : IsCompact s)
(hc : â x â s, c x â ð x) : â ÎŽ > 0, â x â s, â y, ball x ÎŽ â c y := by
simpa only [ball, UniformSpace.ball, preimage_setOf_eq, edist_comm]
using uniformity_basis_edist.lebesgue_number_lemma_nhds hs hc
theorem lebesgue_number_lemma_of_emetric_nhdsWithin' {c : (x : α) â x â s â Set α}
(hs : IsCompact s) (hc : â x hx, c x hx â ð[s] x) :
â ÎŽ > 0, â x â s, â y : s, ball x ÎŽ â© s â c y y.2 := by
simpa only [ball, UniformSpace.ball, preimage_setOf_eq, edist_comm]
using uniformity_basis_edist.lebesgue_number_lemma_nhdsWithin' hs hc
theorem lebesgue_number_lemma_of_emetric_nhdsWithin {c : α â Set α} (hs : IsCompact s)
(hc : â x â s, c x â ð[s] x) : â ÎŽ > 0, â x â s, â y, ball x ÎŽ â© s â c y := by
simpa only [ball, UniformSpace.ball, preimage_setOf_eq, edist_comm]
using uniformity_basis_edist.lebesgue_number_lemma_nhdsWithin hs hc
theorem lebesgue_number_lemma_of_emetric_sUnion {c : Set (Set α)} (hs : IsCompact s)
(hcâ : â t â c, IsOpen t) (hcâ : s â ââ c) : â ÎŽ > 0, â x â s, â t â c, ball x ÎŽ â t := by
rw [sUnion_eq_iUnion] at hcâ; simpa using lebesgue_number_lemma_of_emetric hs (by simpa) hcâ
end LebesgueNumberLemma
| Mathlib/Topology/EMetricSpace/Basic.lean | 963 | 965 | |
/-
Copyright (c) 2019 Kevin Kappelmann. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Kappelmann, Kyle Miller, Mario Carneiro
-/
import Mathlib.Data.Finset.NatAntidiagonal
import Mathlib.Data.Nat.GCD.Basic
import Mathlib.Data.Nat.BinaryRec
import Mathlib.Logic.Function.Iterate
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Zify
import Mathlib.Data.Nat.Choose.Basic
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
/-!
# Fibonacci Numbers
This file defines the fibonacci series, proves results about it and introduces
methods to compute it quickly.
-/
/-!
# The Fibonacci Sequence
## Summary
Definition of the Fibonacci sequence `Fâ = 0, Fâ = 1, Fâââ = Fâ + Fâââ`.
## Main Definitions
- `Nat.fib` returns the stream of Fibonacci numbers.
## Main Statements
- `Nat.fib_add_two`: shows that `fib` indeed satisfies the Fibonacci recurrence `Fâââ = Fâ + Fâââ.`.
- `Nat.fib_gcd`: `fib n` is a strong divisibility sequence.
- `Nat.fib_succ_eq_sum_choose`: `fib` is given by the sum of `Nat.choose` along an antidiagonal.
- `Nat.fib_succ_eq_succ_sum`: shows that `Fâ + Fâ + ⯠+ Fâ = Fâââ - 1`.
- `Nat.fib_two_mul` and `Nat.fib_two_mul_add_one` are the basis for an efficient algorithm to
compute `fib` (see `Nat.fastFib`).
## Implementation Notes
For efficiency purposes, the sequence is defined using `Stream.iterate`.
## Tags
fib, fibonacci
-/
namespace Nat
/-- Implementation of the fibonacci sequence satisfying
`fib 0 = 0, fib 1 = 1, fib (n + 2) = fib n + fib (n + 1)`.
*Note:* We use a stream iterator for better performance when compared to the naive recursive
implementation.
-/
@[pp_nodot]
def fib (n : â) : â :=
((fun p : â Ã â => (p.snd, p.fst + p.snd))^[n] (0, 1)).fst
@[simp]
theorem fib_zero : fib 0 = 0 :=
rfl
@[simp]
theorem fib_one : fib 1 = 1 :=
rfl
@[simp]
theorem fib_two : fib 2 = 1 :=
rfl
/-- Shows that `fib` indeed satisfies the Fibonacci recurrence `Fâââ = Fâ + Fâââ.` -/
theorem fib_add_two {n : â} : fib (n + 2) = fib n + fib (n + 1) := by
simp [fib, Function.iterate_succ_apply']
lemma fib_add_one : â {n}, n â 0 â fib (n + 1) = fib (n - 1) + fib n
| _n + 1, _ => fib_add_two
theorem fib_le_fib_succ {n : â} : fib n †fib (n + 1) := by cases n <;> simp [fib_add_two]
@[mono]
theorem fib_mono : Monotone fib :=
monotone_nat_of_le_succ fun _ => fib_le_fib_succ
@[simp] lemma fib_eq_zero : â {n}, fib n = 0 â n = 0
| 0 => Iff.rfl
| 1 => Iff.rfl
| n + 2 => by simp [fib_add_two, fib_eq_zero]
@[simp] lemma fib_pos {n : â} : 0 < fib n â 0 < n := by simp [pos_iff_ne_zero]
theorem fib_add_two_sub_fib_add_one {n : â} : fib (n + 2) - fib (n + 1) = fib n := by
rw [fib_add_two, add_tsub_cancel_right]
theorem fib_lt_fib_succ {n : â} (hn : 2 †n) : fib n < fib (n + 1) := by
rcases exists_add_of_le hn with âšn, rflâ©
rw [â tsub_pos_iff_lt, add_comm 2, add_right_comm, fib_add_two, add_tsub_cancel_right, fib_pos]
exact succ_pos n
| /-- `fib (n + 2)` is strictly monotone. -/
| Mathlib/Data/Nat/Fib/Basic.lean | 106 | 106 |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Order.Monotone.Odd
import Mathlib.Analysis.Calculus.LogDeriv
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Analysis.Calculus.Deriv.MeanValue
/-!
# Differentiability of trigonometric functions
## Main statements
The differentiability of the usual trigonometric functions is proved, and their derivatives are
computed.
## Tags
sin, cos, tan, angle
-/
noncomputable section
open scoped Topology Filter
open Set
namespace Complex
/-- The complex sine function is everywhere strictly differentiable, with the derivative `cos x`. -/
theorem hasStrictDerivAt_sin (x : â) : HasStrictDerivAt sin (cos x) x := by
simp only [cos, div_eq_mul_inv]
convert ((((hasStrictDerivAt_id x).neg.mul_const I).cexp.sub
((hasStrictDerivAt_id x).mul_const I).cexp).mul_const I).mul_const (2 : â)â»Â¹ using 1
simp only [Function.comp, id]
rw [sub_mul, mul_assoc, mul_assoc, I_mul_I, neg_one_mul, neg_neg, mul_one, one_mul, mul_assoc,
I_mul_I, mul_neg_one, sub_neg_eq_add, add_comm]
/-- The complex sine function is everywhere differentiable, with the derivative `cos x`. -/
theorem hasDerivAt_sin (x : â) : HasDerivAt sin (cos x) x :=
(hasStrictDerivAt_sin x).hasDerivAt
theorem contDiff_sin {n} : ContDiff â n sin :=
(((contDiff_neg.mul contDiff_const).cexp.sub (contDiff_id.mul contDiff_const).cexp).mul
contDiff_const).div_const _
@[simp]
theorem differentiable_sin : Differentiable â sin := fun x => (hasDerivAt_sin x).differentiableAt
@[simp]
theorem differentiableAt_sin {x : â} : DifferentiableAt â sin x :=
differentiable_sin x
@[simp]
theorem deriv_sin : deriv sin = cos :=
funext fun x => (hasDerivAt_sin x).deriv
/-- The complex cosine function is everywhere strictly differentiable, with the derivative
`-sin x`. -/
theorem hasStrictDerivAt_cos (x : â) : HasStrictDerivAt cos (-sin x) x := by
simp only [sin, div_eq_mul_inv, neg_mul_eq_neg_mul]
convert (((hasStrictDerivAt_id x).mul_const I).cexp.add
((hasStrictDerivAt_id x).neg.mul_const I).cexp).mul_const (2 : â)â»Â¹ using 1
simp only [Function.comp, id]
ring
/-- The complex cosine function is everywhere differentiable, with the derivative `-sin x`. -/
theorem hasDerivAt_cos (x : â) : HasDerivAt cos (-sin x) x :=
(hasStrictDerivAt_cos x).hasDerivAt
theorem contDiff_cos {n} : ContDiff â n cos :=
((contDiff_id.mul contDiff_const).cexp.add (contDiff_neg.mul contDiff_const).cexp).div_const _
@[simp]
theorem differentiable_cos : Differentiable â cos := fun x => (hasDerivAt_cos x).differentiableAt
@[simp]
theorem differentiableAt_cos {x : â} : DifferentiableAt â cos x :=
differentiable_cos x
theorem deriv_cos {x : â} : deriv cos x = -sin x :=
(hasDerivAt_cos x).deriv
@[simp]
theorem deriv_cos' : deriv cos = fun x => -sin x :=
funext fun _ => deriv_cos
/-- The complex hyperbolic sine function is everywhere strictly differentiable, with the derivative
`cosh x`. -/
theorem hasStrictDerivAt_sinh (x : â) : HasStrictDerivAt sinh (cosh x) x := by
simp only [cosh, div_eq_mul_inv]
convert ((hasStrictDerivAt_exp x).sub (hasStrictDerivAt_id x).neg.cexp).mul_const (2 : â)â»Â¹
using 1
rw [id, mul_neg_one, sub_eq_add_neg, neg_neg]
/-- The complex hyperbolic sine function is everywhere differentiable, with the derivative
`cosh x`. -/
theorem hasDerivAt_sinh (x : â) : HasDerivAt sinh (cosh x) x :=
(hasStrictDerivAt_sinh x).hasDerivAt
theorem contDiff_sinh {n} : ContDiff â n sinh :=
(contDiff_exp.sub contDiff_neg.cexp).div_const _
@[simp]
theorem differentiable_sinh : Differentiable â sinh := fun x => (hasDerivAt_sinh x).differentiableAt
@[simp]
theorem differentiableAt_sinh {x : â} : DifferentiableAt â sinh x :=
differentiable_sinh x
@[simp]
theorem deriv_sinh : deriv sinh = cosh :=
funext fun x => (hasDerivAt_sinh x).deriv
/-- The complex hyperbolic cosine function is everywhere strictly differentiable, with the
derivative `sinh x`. -/
theorem hasStrictDerivAt_cosh (x : â) : HasStrictDerivAt cosh (sinh x) x := by
simp only [sinh, div_eq_mul_inv]
convert ((hasStrictDerivAt_exp x).add (hasStrictDerivAt_id x).neg.cexp).mul_const (2 : â)â»Â¹
using 1
rw [id, mul_neg_one, sub_eq_add_neg]
/-- The complex hyperbolic cosine function is everywhere differentiable, with the derivative
`sinh x`. -/
theorem hasDerivAt_cosh (x : â) : HasDerivAt cosh (sinh x) x :=
(hasStrictDerivAt_cosh x).hasDerivAt
theorem contDiff_cosh {n} : ContDiff â n cosh :=
(contDiff_exp.add contDiff_neg.cexp).div_const _
@[simp]
theorem differentiable_cosh : Differentiable â cosh := fun x => (hasDerivAt_cosh x).differentiableAt
@[simp]
theorem differentiableAt_cosh {x : â} : DifferentiableAt â cosh x :=
differentiable_cosh x
@[simp]
theorem deriv_cosh : deriv cosh = sinh :=
funext fun x => (hasDerivAt_cosh x).deriv
end Complex
section
/-! ### Simp lemmas for derivatives of `fun x => Complex.cos (f x)` etc., `f : â â â` -/
variable {f : â â â} {f' x : â} {s : Set â}
/-! #### `Complex.cos` -/
theorem HasStrictDerivAt.ccos (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') x :=
(Complex.hasStrictDerivAt_cos (f x)).comp x hf
theorem HasDerivAt.ccos (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') x :=
(Complex.hasDerivAt_cos (f x)).comp x hf
theorem HasDerivWithinAt.ccos (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') s x :=
(Complex.hasDerivAt_cos (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_ccos (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
derivWithin (fun x => Complex.cos (f x)) s x = -Complex.sin (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.ccos.derivWithin hxs
@[simp]
theorem deriv_ccos (hc : DifferentiableAt â f x) :
deriv (fun x => Complex.cos (f x)) x = -Complex.sin (f x) * deriv f x :=
hc.hasDerivAt.ccos.deriv
/-! #### `Complex.sin` -/
theorem HasStrictDerivAt.csin (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') x :=
(Complex.hasStrictDerivAt_sin (f x)).comp x hf
theorem HasDerivAt.csin (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') x :=
(Complex.hasDerivAt_sin (f x)).comp x hf
theorem HasDerivWithinAt.csin (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') s x :=
(Complex.hasDerivAt_sin (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_csin (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
derivWithin (fun x => Complex.sin (f x)) s x = Complex.cos (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.csin.derivWithin hxs
@[simp]
theorem deriv_csin (hc : DifferentiableAt â f x) :
deriv (fun x => Complex.sin (f x)) x = Complex.cos (f x) * deriv f x :=
hc.hasDerivAt.csin.deriv
/-! #### `Complex.cosh` -/
theorem HasStrictDerivAt.ccosh (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') x :=
(Complex.hasStrictDerivAt_cosh (f x)).comp x hf
theorem HasDerivAt.ccosh (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') x :=
(Complex.hasDerivAt_cosh (f x)).comp x hf
theorem HasDerivWithinAt.ccosh (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') s x :=
(Complex.hasDerivAt_cosh (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_ccosh (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
derivWithin (fun x => Complex.cosh (f x)) s x = Complex.sinh (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.ccosh.derivWithin hxs
@[simp]
theorem deriv_ccosh (hc : DifferentiableAt â f x) :
deriv (fun x => Complex.cosh (f x)) x = Complex.sinh (f x) * deriv f x :=
hc.hasDerivAt.ccosh.deriv
/-! #### `Complex.sinh` -/
theorem HasStrictDerivAt.csinh (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') x :=
(Complex.hasStrictDerivAt_sinh (f x)).comp x hf
theorem HasDerivAt.csinh (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') x :=
(Complex.hasDerivAt_sinh (f x)).comp x hf
theorem HasDerivWithinAt.csinh (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') s x :=
(Complex.hasDerivAt_sinh (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_csinh (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
derivWithin (fun x => Complex.sinh (f x)) s x = Complex.cosh (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.csinh.derivWithin hxs
@[simp]
theorem deriv_csinh (hc : DifferentiableAt â f x) :
deriv (fun x => Complex.sinh (f x)) x = Complex.cosh (f x) * deriv f x :=
hc.hasDerivAt.csinh.deriv
end
section
/-! ### Simp lemmas for derivatives of `fun x => Complex.cos (f x)` etc., `f : E â â` -/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace â E] {f : E â â} {f' : E âL[â] â} {x : E}
{s : Set E}
/-! #### `Complex.cos` -/
theorem HasStrictFDerivAt.ccos (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) ⢠f') x :=
(Complex.hasStrictDerivAt_cos (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.ccos (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) ⢠f') x :=
(Complex.hasDerivAt_cos (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.ccos (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) ⢠f') s x :=
(Complex.hasDerivAt_cos (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.ccos (hf : DifferentiableWithinAt â f s x) :
DifferentiableWithinAt â (fun x => Complex.cos (f x)) s x :=
hf.hasFDerivWithinAt.ccos.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.ccos (hc : DifferentiableAt â f x) :
DifferentiableAt â (fun x => Complex.cos (f x)) x :=
hc.hasFDerivAt.ccos.differentiableAt
theorem DifferentiableOn.ccos (hc : DifferentiableOn â f s) :
DifferentiableOn â (fun x => Complex.cos (f x)) s := fun x h => (hc x h).ccos
@[simp, fun_prop]
theorem Differentiable.ccos (hc : Differentiable â f) :
Differentiable â fun x => Complex.cos (f x) := fun x => (hc x).ccos
theorem fderivWithin_ccos (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
fderivWithin â (fun x => Complex.cos (f x)) s x = -Complex.sin (f x) ⢠fderivWithin â f s x :=
hf.hasFDerivWithinAt.ccos.fderivWithin hxs
@[simp]
theorem fderiv_ccos (hc : DifferentiableAt â f x) :
fderiv â (fun x => Complex.cos (f x)) x = -Complex.sin (f x) ⢠fderiv â f x :=
hc.hasFDerivAt.ccos.fderiv
theorem ContDiff.ccos {n} (h : ContDiff â n f) : ContDiff â n fun x => Complex.cos (f x) :=
Complex.contDiff_cos.comp h
theorem ContDiffAt.ccos {n} (hf : ContDiffAt â n f x) :
ContDiffAt â n (fun x => Complex.cos (f x)) x :=
Complex.contDiff_cos.contDiffAt.comp x hf
theorem ContDiffOn.ccos {n} (hf : ContDiffOn â n f s) :
ContDiffOn â n (fun x => Complex.cos (f x)) s :=
Complex.contDiff_cos.comp_contDiffOn hf
theorem ContDiffWithinAt.ccos {n} (hf : ContDiffWithinAt â n f s x) :
ContDiffWithinAt â n (fun x => Complex.cos (f x)) s x :=
Complex.contDiff_cos.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Complex.sin` -/
theorem HasStrictFDerivAt.csin (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) ⢠f') x :=
(Complex.hasStrictDerivAt_sin (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.csin (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) ⢠f') x :=
(Complex.hasDerivAt_sin (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.csin (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.sin (f x)) (Complex.cos (f x) ⢠f') s x :=
(Complex.hasDerivAt_sin (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.csin (hf : DifferentiableWithinAt â f s x) :
DifferentiableWithinAt â (fun x => Complex.sin (f x)) s x :=
hf.hasFDerivWithinAt.csin.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.csin (hc : DifferentiableAt â f x) :
DifferentiableAt â (fun x => Complex.sin (f x)) x :=
hc.hasFDerivAt.csin.differentiableAt
theorem DifferentiableOn.csin (hc : DifferentiableOn â f s) :
DifferentiableOn â (fun x => Complex.sin (f x)) s := fun x h => (hc x h).csin
@[simp, fun_prop]
theorem Differentiable.csin (hc : Differentiable â f) :
Differentiable â fun x => Complex.sin (f x) := fun x => (hc x).csin
theorem fderivWithin_csin (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
fderivWithin â (fun x => Complex.sin (f x)) s x = Complex.cos (f x) ⢠fderivWithin â f s x :=
hf.hasFDerivWithinAt.csin.fderivWithin hxs
@[simp]
theorem fderiv_csin (hc : DifferentiableAt â f x) :
fderiv â (fun x => Complex.sin (f x)) x = Complex.cos (f x) ⢠fderiv â f x :=
hc.hasFDerivAt.csin.fderiv
theorem ContDiff.csin {n} (h : ContDiff â n f) : ContDiff â n fun x => Complex.sin (f x) :=
Complex.contDiff_sin.comp h
theorem ContDiffAt.csin {n} (hf : ContDiffAt â n f x) :
ContDiffAt â n (fun x => Complex.sin (f x)) x :=
Complex.contDiff_sin.contDiffAt.comp x hf
theorem ContDiffOn.csin {n} (hf : ContDiffOn â n f s) :
ContDiffOn â n (fun x => Complex.sin (f x)) s :=
Complex.contDiff_sin.comp_contDiffOn hf
theorem ContDiffWithinAt.csin {n} (hf : ContDiffWithinAt â n f s x) :
ContDiffWithinAt â n (fun x => Complex.sin (f x)) s x :=
Complex.contDiff_sin.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Complex.cosh` -/
theorem HasStrictFDerivAt.ccosh (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) ⢠f') x :=
(Complex.hasStrictDerivAt_cosh (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.ccosh (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) ⢠f') x :=
(Complex.hasDerivAt_cosh (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.ccosh (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) ⢠f') s x :=
(Complex.hasDerivAt_cosh (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.ccosh (hf : DifferentiableWithinAt â f s x) :
DifferentiableWithinAt â (fun x => Complex.cosh (f x)) s x :=
hf.hasFDerivWithinAt.ccosh.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.ccosh (hc : DifferentiableAt â f x) :
DifferentiableAt â (fun x => Complex.cosh (f x)) x :=
hc.hasFDerivAt.ccosh.differentiableAt
theorem DifferentiableOn.ccosh (hc : DifferentiableOn â f s) :
DifferentiableOn â (fun x => Complex.cosh (f x)) s := fun x h => (hc x h).ccosh
@[simp, fun_prop]
theorem Differentiable.ccosh (hc : Differentiable â f) :
Differentiable â fun x => Complex.cosh (f x) := fun x => (hc x).ccosh
theorem fderivWithin_ccosh (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
fderivWithin â (fun x => Complex.cosh (f x)) s x = Complex.sinh (f x) ⢠fderivWithin â f s x :=
hf.hasFDerivWithinAt.ccosh.fderivWithin hxs
@[simp]
theorem fderiv_ccosh (hc : DifferentiableAt â f x) :
fderiv â (fun x => Complex.cosh (f x)) x = Complex.sinh (f x) ⢠fderiv â f x :=
hc.hasFDerivAt.ccosh.fderiv
theorem ContDiff.ccosh {n} (h : ContDiff â n f) : ContDiff â n fun x => Complex.cosh (f x) :=
Complex.contDiff_cosh.comp h
theorem ContDiffAt.ccosh {n} (hf : ContDiffAt â n f x) :
ContDiffAt â n (fun x => Complex.cosh (f x)) x :=
Complex.contDiff_cosh.contDiffAt.comp x hf
theorem ContDiffOn.ccosh {n} (hf : ContDiffOn â n f s) :
ContDiffOn â n (fun x => Complex.cosh (f x)) s :=
Complex.contDiff_cosh.comp_contDiffOn hf
theorem ContDiffWithinAt.ccosh {n} (hf : ContDiffWithinAt â n f s x) :
ContDiffWithinAt â n (fun x => Complex.cosh (f x)) s x :=
Complex.contDiff_cosh.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Complex.sinh` -/
theorem HasStrictFDerivAt.csinh (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) ⢠f') x :=
(Complex.hasStrictDerivAt_sinh (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.csinh (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) ⢠f') x :=
(Complex.hasDerivAt_sinh (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.csinh (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) ⢠f') s x :=
(Complex.hasDerivAt_sinh (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.csinh (hf : DifferentiableWithinAt â f s x) :
DifferentiableWithinAt â (fun x => Complex.sinh (f x)) s x :=
hf.hasFDerivWithinAt.csinh.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.csinh (hc : DifferentiableAt â f x) :
DifferentiableAt â (fun x => Complex.sinh (f x)) x :=
hc.hasFDerivAt.csinh.differentiableAt
theorem DifferentiableOn.csinh (hc : DifferentiableOn â f s) :
DifferentiableOn â (fun x => Complex.sinh (f x)) s := fun x h => (hc x h).csinh
@[simp, fun_prop]
theorem Differentiable.csinh (hc : Differentiable â f) :
Differentiable â fun x => Complex.sinh (f x) := fun x => (hc x).csinh
theorem fderivWithin_csinh (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
fderivWithin â (fun x => Complex.sinh (f x)) s x = Complex.cosh (f x) ⢠fderivWithin â f s x :=
hf.hasFDerivWithinAt.csinh.fderivWithin hxs
@[simp]
theorem fderiv_csinh (hc : DifferentiableAt â f x) :
fderiv â (fun x => Complex.sinh (f x)) x = Complex.cosh (f x) ⢠fderiv â f x :=
hc.hasFDerivAt.csinh.fderiv
theorem ContDiff.csinh {n} (h : ContDiff â n f) : ContDiff â n fun x => Complex.sinh (f x) :=
Complex.contDiff_sinh.comp h
theorem ContDiffAt.csinh {n} (hf : ContDiffAt â n f x) :
ContDiffAt â n (fun x => Complex.sinh (f x)) x :=
Complex.contDiff_sinh.contDiffAt.comp x hf
theorem ContDiffOn.csinh {n} (hf : ContDiffOn â n f s) :
ContDiffOn â n (fun x => Complex.sinh (f x)) s :=
Complex.contDiff_sinh.comp_contDiffOn hf
theorem ContDiffWithinAt.csinh {n} (hf : ContDiffWithinAt â n f s x) :
ContDiffWithinAt â n (fun x => Complex.sinh (f x)) s x :=
Complex.contDiff_sinh.contDiffAt.comp_contDiffWithinAt x hf
end
namespace Real
variable {x y z : â}
theorem hasStrictDerivAt_sin (x : â) : HasStrictDerivAt sin (cos x) x :=
(Complex.hasStrictDerivAt_sin x).real_of_complex
theorem hasDerivAt_sin (x : â) : HasDerivAt sin (cos x) x :=
(hasStrictDerivAt_sin x).hasDerivAt
theorem contDiff_sin {n} : ContDiff â n sin :=
Complex.contDiff_sin.real_of_complex
@[simp]
theorem differentiable_sin : Differentiable â sin := fun x => (hasDerivAt_sin x).differentiableAt
@[simp]
theorem differentiableAt_sin : DifferentiableAt â sin x :=
differentiable_sin x
@[simp]
theorem deriv_sin : deriv sin = cos :=
funext fun x => (hasDerivAt_sin x).deriv
theorem hasStrictDerivAt_cos (x : â) : HasStrictDerivAt cos (-sin x) x :=
(Complex.hasStrictDerivAt_cos x).real_of_complex
theorem hasDerivAt_cos (x : â) : HasDerivAt cos (-sin x) x :=
(Complex.hasDerivAt_cos x).real_of_complex
theorem contDiff_cos {n} : ContDiff â n cos :=
Complex.contDiff_cos.real_of_complex
@[simp]
theorem differentiable_cos : Differentiable â cos := fun x => (hasDerivAt_cos x).differentiableAt
@[simp]
theorem differentiableAt_cos : DifferentiableAt â cos x :=
differentiable_cos x
theorem deriv_cos : deriv cos x = -sin x :=
(hasDerivAt_cos x).deriv
@[simp]
theorem deriv_cos' : deriv cos = fun x => -sin x :=
funext fun _ => deriv_cos
theorem hasStrictDerivAt_sinh (x : â) : HasStrictDerivAt sinh (cosh x) x :=
(Complex.hasStrictDerivAt_sinh x).real_of_complex
theorem hasDerivAt_sinh (x : â) : HasDerivAt sinh (cosh x) x :=
(Complex.hasDerivAt_sinh x).real_of_complex
theorem contDiff_sinh {n} : ContDiff â n sinh :=
Complex.contDiff_sinh.real_of_complex
@[simp]
theorem differentiable_sinh : Differentiable â sinh := fun x => (hasDerivAt_sinh x).differentiableAt
@[simp]
theorem differentiableAt_sinh : DifferentiableAt â sinh x :=
differentiable_sinh x
@[simp]
theorem deriv_sinh : deriv sinh = cosh :=
funext fun x => (hasDerivAt_sinh x).deriv
theorem hasStrictDerivAt_cosh (x : â) : HasStrictDerivAt cosh (sinh x) x :=
(Complex.hasStrictDerivAt_cosh x).real_of_complex
theorem hasDerivAt_cosh (x : â) : HasDerivAt cosh (sinh x) x :=
(Complex.hasDerivAt_cosh x).real_of_complex
theorem contDiff_cosh {n} : ContDiff â n cosh :=
Complex.contDiff_cosh.real_of_complex
@[simp]
theorem differentiable_cosh : Differentiable â cosh := fun x => (hasDerivAt_cosh x).differentiableAt
@[simp]
theorem differentiableAt_cosh : DifferentiableAt â cosh x :=
differentiable_cosh x
@[simp]
theorem deriv_cosh : deriv cosh = sinh :=
funext fun x => (hasDerivAt_cosh x).deriv
/-- `sinh` is strictly monotone. -/
theorem sinh_strictMono : StrictMono sinh :=
strictMono_of_deriv_pos <| by rw [Real.deriv_sinh]; exact cosh_pos
/-- `sinh` is injective, `â a b, sinh a = sinh b â a = b`. -/
theorem sinh_injective : Function.Injective sinh :=
sinh_strictMono.injective
@[simp]
theorem sinh_inj : sinh x = sinh y â x = y :=
sinh_injective.eq_iff
@[simp]
theorem sinh_le_sinh : sinh x †sinh y â x †y :=
sinh_strictMono.le_iff_le
@[simp]
theorem sinh_lt_sinh : sinh x < sinh y â x < y :=
sinh_strictMono.lt_iff_lt
@[simp] lemma sinh_eq_zero : sinh x = 0 â x = 0 := by rw [â @sinh_inj x, sinh_zero]
lemma sinh_ne_zero : sinh x â 0 â x â 0 := sinh_eq_zero.not
@[simp]
theorem sinh_pos_iff : 0 < sinh x â 0 < x := by simpa only [sinh_zero] using @sinh_lt_sinh 0 x
@[simp]
theorem sinh_nonpos_iff : sinh x †0 â x †0 := by simpa only [sinh_zero] using @sinh_le_sinh x 0
@[simp]
theorem sinh_neg_iff : sinh x < 0 â x < 0 := by simpa only [sinh_zero] using @sinh_lt_sinh x 0
@[simp]
theorem sinh_nonneg_iff : 0 †sinh x â 0 †x := by simpa only [sinh_zero] using @sinh_le_sinh 0 x
theorem abs_sinh (x : â) : |sinh x| = sinh |x| := by
cases le_total x 0 <;> simp [abs_of_nonneg, abs_of_nonpos, *]
theorem cosh_strictMonoOn : StrictMonoOn cosh (Ici 0) :=
strictMonoOn_of_deriv_pos (convex_Ici _) continuous_cosh.continuousOn fun x hx => by
rw [interior_Ici, mem_Ioi] at hx; rwa [deriv_cosh, sinh_pos_iff]
@[simp]
theorem cosh_le_cosh : cosh x †cosh y â |x| †|y| :=
cosh_abs x âž cosh_abs y âž cosh_strictMonoOn.le_iff_le (abs_nonneg x) (abs_nonneg y)
@[simp]
theorem cosh_lt_cosh : cosh x < cosh y â |x| < |y| :=
lt_iff_lt_of_le_iff_le cosh_le_cosh
@[simp]
theorem one_le_cosh (x : â) : 1 †cosh x :=
cosh_zero âž cosh_le_cosh.2 (by simp only [_root_.abs_zero, _root_.abs_nonneg])
@[simp]
theorem one_lt_cosh : 1 < cosh x â x â 0 :=
cosh_zero âž cosh_lt_cosh.trans (by simp only [_root_.abs_zero, abs_pos])
theorem sinh_sub_id_strictMono : StrictMono fun x => sinh x - x := by
refine strictMono_of_odd_strictMonoOn_nonneg (fun x => by simp; abel) ?_
refine strictMonoOn_of_deriv_pos (convex_Ici _) ?_ fun x hx => ?_
· exact (continuous_sinh.sub continuous_id).continuousOn
· rw [interior_Ici, mem_Ioi] at hx
rw [deriv_sub, deriv_sinh, deriv_id'', sub_pos, one_lt_cosh]
exacts [hx.ne', differentiableAt_sinh, differentiableAt_id]
@[simp]
theorem self_le_sinh_iff : x †sinh x â 0 †x :=
calc
x †sinh x â sinh 0 - 0 †sinh x - x := by simp
_ â 0 †x := sinh_sub_id_strictMono.le_iff_le
@[simp]
theorem sinh_le_self_iff : sinh x †x â x †0 :=
calc
sinh x †x â sinh x - x †sinh 0 - 0 := by simp
_ â x †0 := sinh_sub_id_strictMono.le_iff_le
@[simp]
theorem self_lt_sinh_iff : x < sinh x â 0 < x :=
lt_iff_lt_of_le_iff_le sinh_le_self_iff
@[simp]
theorem sinh_lt_self_iff : sinh x < x â x < 0 :=
lt_iff_lt_of_le_iff_le self_le_sinh_iff
end Real
section
/-! ### Simp lemmas for derivatives of `fun x => Real.cos (f x)` etc., `f : â â â` -/
variable {f : â â â} {f' x : â} {s : Set â}
/-! #### `Real.cos` -/
theorem HasStrictDerivAt.cos (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Real.cos (f x)) (-Real.sin (f x) * f') x :=
(Real.hasStrictDerivAt_cos (f x)).comp x hf
theorem HasDerivAt.cos (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Real.cos (f x)) (-Real.sin (f x) * f') x :=
(Real.hasDerivAt_cos (f x)).comp x hf
theorem HasDerivWithinAt.cos (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Real.cos (f x)) (-Real.sin (f x) * f') s x :=
(Real.hasDerivAt_cos (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_cos (hf : DifferentiableWithinAt â f s x) (hxs : UniqueDiffWithinAt â s x) :
derivWithin (fun x => Real.cos (f x)) s x = -Real.sin (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.cos.derivWithin hxs
@[simp]
theorem deriv_cos (hc : DifferentiableAt â f x) :
deriv (fun x => Real.cos (f x)) x = -Real.sin (f x) * deriv f x :=
hc.hasDerivAt.cos.deriv
/-! #### `Real.sin` -/
theorem HasStrictDerivAt.sin (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Real.sin (f x)) (Real.cos (f x) * f') x :=
(Real.hasStrictDerivAt_sin (f x)).comp x hf
theorem HasDerivAt.sin (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Real.sin (f x)) (Real.cos (f x) * f') x :=
(Real.hasDerivAt_sin (f x)).comp x hf
theorem HasDerivWithinAt.sin (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Real.sin (f x)) (Real.cos (f x) * f') s x :=
(Real.hasDerivAt_sin (f x)).comp_hasDerivWithinAt x hf
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean | 702 | 702 | |
/-
Copyright (c) 2019 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Sébastien Gouëzel, Frédéric Dupuis
-/
import Mathlib.Analysis.InnerProductSpace.Subspace
import Mathlib.LinearAlgebra.SesquilinearForm
/-!
# Orthogonal complements of submodules
In this file, the `orthogonal` complement of a submodule `K` is defined, and basic API established.
Some of the more subtle results about the orthogonal complement are delayed to
`Analysis.InnerProductSpace.Projection`.
See also `BilinForm.orthogonal` for orthogonality with respect to a general bilinear form.
## Notation
The orthogonal complement of a submodule `K` is denoted by `Ká®`.
The proposition that two submodules are orthogonal, `Submodule.IsOrtho`, is denoted by `U â V`.
Note this is not the same unicode symbol as `â¥` (`Bot`).
-/
variable {ð E F : Type*} [RCLike ð]
variable [NormedAddCommGroup E] [InnerProductSpace ð E]
variable [NormedAddCommGroup F] [InnerProductSpace ð F]
local notation "âª" x ", " y "â«" => @inner ð _ _ x y
namespace Submodule
variable (K : Submodule ð E)
/-- The subspace of vectors orthogonal to a given subspace, denoted `Ká®`. -/
def orthogonal : Submodule ð E where
carrier := { v | â u â K, âªu, vâ« = 0 }
zero_mem' _ _ := inner_zero_right _
add_mem' hx hy u hu := by rw [inner_add_right, hx u hu, hy u hu, add_zero]
smul_mem' c x hx u hu := by rw [inner_smul_right, hx u hu, mul_zero]
@[inherit_doc]
notation:1200 K "á®" => orthogonal K
/-- When a vector is in `Ká®`. -/
theorem mem_orthogonal (v : E) : v â Ká® â â u â K, âªu, vâ« = 0 :=
Iff.rfl
/-- When a vector is in `Ká®`, with the inner product the
other way round. -/
theorem mem_orthogonal' (v : E) : v â Ká® â â u â K, âªv, uâ« = 0 := by
simp_rw [mem_orthogonal, inner_eq_zero_symm]
variable {K}
|
/-- A vector in `K` is orthogonal to one in `Ká®`. -/
| Mathlib/Analysis/InnerProductSpace/Orthogonal.lean | 56 | 57 |
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser, Frédéric Dupuis
-/
import Mathlib.Algebra.Star.SelfAdjoint
import Mathlib.Algebra.Module.Basic
import Mathlib.Algebra.Module.Equiv.Defs
import Mathlib.Algebra.Module.LinearMap.Star
import Mathlib.Algebra.Module.Rat
import Mathlib.LinearAlgebra.Prod
/-!
# The star operation, bundled as a star-linear equiv
We define `starLinearEquiv`, which is the star operation bundled as a star-linear map.
It is defined on a star algebra `A` over the base ring `R`.
This file also provides some lemmas that need `Algebra.Module.Basic` imported to prove.
## TODO
- Define `starLinearEquiv` for noncommutative `R`. We only the commutative case for now since,
in the noncommutative case, the ring hom needs to reverse the order of multiplication. This
requires a ring hom of type `R â+* Ráµáµáµ`, which is very undesirable in the commutative case.
One way out would be to define a new typeclass `IsOp R S` and have an instance `IsOp R R`
for commutative `R`.
- Also note that such a definition involving `Ráµáµáµ` or `is_op R S` would require adding
the appropriate `RingHomInvPair` instances to be able to define the semilinear
equivalence.
-/
section SMulLemmas
variable {R M : Type*}
@[simp]
theorem star_natCast_smul [Semiring R] [AddCommMonoid M] [Module R M] [StarAddMonoid M] (n : â)
(x : M) : star ((n : R) ⢠x) = (n : R) ⢠star x :=
map_natCast_smul (starAddEquiv : M â+ M) R R n x
@[simp]
theorem star_intCast_smul [Ring R] [AddCommGroup M] [Module R M] [StarAddMonoid M] (n : â€)
(x : M) : star ((n : R) ⢠x) = (n : R) ⢠star x :=
map_intCast_smul (starAddEquiv : M â+ M) R R n x
@[simp]
theorem star_inv_natCast_smul [DivisionSemiring R] [AddCommMonoid M] [Module R M] [StarAddMonoid M]
(n : â) (x : M) : star ((nâ»Â¹ : R) ⢠x) = (nâ»Â¹ : R) ⢠star x :=
map_inv_natCast_smul (starAddEquiv : M â+ M) R R n x
@[simp]
theorem star_inv_intCast_smul [DivisionRing R] [AddCommGroup M] [Module R M] [StarAddMonoid M]
(n : â€) (x : M) : star ((nâ»Â¹ : R) ⢠x) = (nâ»Â¹ : R) ⢠star x :=
map_inv_intCast_smul (starAddEquiv : M â+ M) R R n x
@[simp]
theorem star_ratCast_smul [DivisionRing R] [AddCommGroup M] [Module R M] [StarAddMonoid M] (n : â)
(x : M) : star ((n : R) ⢠x) = (n : R) ⢠star x :=
map_ratCast_smul (starAddEquiv : M â+ M) _ _ _ x
/-!
Per the naming convention, these two lemmas call `(q ⢠·)` `nnrat_smul` and `rat_smul` respectively,
rather than `nnqsmul` and `qsmul` because the latter are reserved to the actions coming from
`DivisionSemiring` and `DivisionRing`. We provide aliases with `nnqsmul` and `qsmul` for
discoverability.
-/
/-- Note that this lemma holds for an arbitrary `ââ¥0`-action, rather than merely one coming from a
`DivisionSemiring`. We keep both the `nnqsmul` and `nnrat_smul` naming conventions for
discoverability. See `star_nnqsmul`. -/
@[simp high]
lemma star_nnrat_smul [AddCommMonoid R] [StarAddMonoid R] [Module ââ¥0 R] (q : ââ¥0) (x : R) :
star (q ⢠x) = q ⢠star x := map_nnrat_smul (starAddEquiv : R â+ R) _ _
/-- Note that this lemma holds for an arbitrary `â`-action, rather than merely one coming from a
`DivisionRing`. We keep both the `qsmul` and `rat_smul` naming conventions for discoverability.
See `star_qsmul`. -/
@[simp high] lemma star_rat_smul [AddCommGroup R] [StarAddMonoid R] [Module â R] (q : â) (x : R) :
star (q ⢠x) = q ⢠star x :=
map_rat_smul (starAddEquiv : R â+ R) _ _
/-- Note that this lemma holds for an arbitrary `ââ¥0`-action, rather than merely one coming from a
`DivisionSemiring`. We keep both the `nnqsmul` and `nnrat_smul` naming conventions for
discoverability. See `star_nnrat_smul`. -/
alias star_nnqsmul := star_nnrat_smul
/-- Note that this lemma holds for an arbitrary `â`-action, rather than merely one coming from a
`DivisionRing`. We keep both the `qsmul` and `rat_smul` naming conventions for
discoverability. See `star_rat_smul`. -/
alias star_qsmul := star_rat_smul
instance StarAddMonoid.toStarModuleNNRat [AddCommMonoid R] [Module ââ¥0 R] [StarAddMonoid R] :
StarModule ââ¥0 R where star_smul := star_nnrat_smul
instance StarAddMonoid.toStarModuleRat [AddCommGroup R] [Module â R] [StarAddMonoid R] :
StarModule â R where star_smul := star_rat_smul
end SMulLemmas
/-- If `A` is a module over a commutative `R` with compatible actions,
then `star` is a semilinear equivalence. -/
@[simps]
def starLinearEquiv (R : Type*) {A : Type*} [CommSemiring R] [StarRing R] [AddCommMonoid A]
[StarAddMonoid A] [Module R A] [StarModule R A] : A âââ[R] A :=
{ starAddEquiv with
toFun := star
map_smul' := star_smul }
section SelfSkewAdjoint
variable (R : Type*) (A : Type*) [Semiring R] [StarMul R] [TrivialStar R] [AddCommGroup A]
[Module R A] [StarAddMonoid A] [StarModule R A]
/-- The self-adjoint elements of a star module, as a submodule. -/
def selfAdjoint.submodule : Submodule R A :=
{ selfAdjoint A with smul_mem' := fun _ _ => (IsSelfAdjoint.all _).smul }
/-- The skew-adjoint elements of a star module, as a submodule. -/
def skewAdjoint.submodule : Submodule R A :=
{ skewAdjoint A with smul_mem' := skewAdjoint.smul_mem }
variable {A} [Invertible (2 : R)]
/-- The self-adjoint part of an element of a star module, as a linear map. -/
@[simps]
def selfAdjointPart : A ââ[R] selfAdjoint A where
toFun x :=
âš(â
2 : R) ⢠(x + star x), by
rw [selfAdjoint.mem_iff, star_smul, star_trivial, star_add, star_star, add_comm]â©
map_add' x y := by
ext
simp [add_add_add_comm]
map_smul' r x := by
ext
simp [â mul_smul, show â
2 * r = r * â
2 from Commute.invOf_left <| (2 : â).cast_commute r]
/-- The skew-adjoint part of an element of a star module, as a linear map. -/
@[simps]
def skewAdjointPart : A ââ[R] skewAdjoint A where
toFun x :=
âš(â
2 : R) ⢠(x - star x), by
simp only [skewAdjoint.mem_iff, star_smul, star_sub, star_star, star_trivial, â smul_neg,
neg_sub]â©
map_add' x y := by
ext
simp only [sub_add, â smul_add, sub_sub_eq_add_sub, star_add, AddSubgroup.coe_mk,
AddSubgroup.coe_add]
map_smul' r x := by
ext
simp [â mul_smul, â smul_sub,
show r * â
2 = â
2 * r from Commute.invOf_right <| (2 : â).commute_cast r]
theorem StarModule.selfAdjointPart_add_skewAdjointPart (x : A) :
(selfAdjointPart R x : A) + skewAdjointPart R x = x := by
simp only [smul_sub, selfAdjointPart_apply_coe, smul_add, skewAdjointPart_apply_coe,
add_add_sub_cancel, invOf_two_smul_add_invOf_two_smul]
theorem IsSelfAdjoint.coe_selfAdjointPart_apply {x : A} (hx : IsSelfAdjoint x) :
(selfAdjointPart R x : A) = x := by
rw [selfAdjointPart_apply_coe, hx.star_eq, smul_add, invOf_two_smul_add_invOf_two_smul]
theorem IsSelfAdjoint.selfAdjointPart_apply {x : A} (hx : IsSelfAdjoint x) :
selfAdjointPart R x = âšx, hxâ© :=
Subtype.eq (hx.coe_selfAdjointPart_apply R)
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: make it a `simp`
theorem selfAdjointPart_comp_subtype_selfAdjoint :
(selfAdjointPart R).comp (selfAdjoint.submodule R A).subtype = .id :=
LinearMap.ext fun x ⊠x.2.selfAdjointPart_apply R
theorem IsSelfAdjoint.skewAdjointPart_apply {x : A} (hx : IsSelfAdjoint x) :
skewAdjointPart R x = 0 := Subtype.eq <| by
rw [skewAdjointPart_apply_coe, hx.star_eq, sub_self, smul_zero, ZeroMemClass.coe_zero]
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: make it a `simp`
theorem skewAdjointPart_comp_subtype_selfAdjoint :
(skewAdjointPart R).comp (selfAdjoint.submodule R A).subtype = 0 :=
LinearMap.ext fun x ⊠x.2.skewAdjointPart_apply R
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: make it a `simp`
theorem selfAdjointPart_comp_subtype_skewAdjoint :
| (selfAdjointPart R).comp (skewAdjoint.submodule R A).subtype = 0 :=
LinearMap.ext fun âšx, (hx : _ = _)⩠⊠Subtype.eq <| by simp [hx]
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: make it a `simp`
theorem skewAdjointPart_comp_subtype_skewAdjoint :
| Mathlib/Algebra/Star/Module.lean | 184 | 188 |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Algebra.Order.Group.Unbundled.Int
import Mathlib.Algebra.Ring.Nat
import Mathlib.Data.Int.GCD
/-!
# Congruences modulo a natural number
This file defines the equivalence relation `a â¡ b [MOD n]` on the natural numbers,
and proves basic properties about it such as the Chinese Remainder Theorem
`modEq_and_modEq_iff_modEq_mul`.
## Notations
`a â¡ b [MOD n]` is notation for `nat.ModEq n a b`, which is defined to mean `a % n = b % n`.
## Tags
ModEq, congruence, mod, MOD, modulo
-/
assert_not_exists OrderedAddCommMonoid Function.support
namespace Nat
/-- Modular equality. `n.ModEq a b`, or `a â¡ b [MOD n]`, means that `a - b` is a multiple of `n`. -/
def ModEq (n a b : â) :=
a % n = b % n
@[inherit_doc]
notation:50 a " â¡ " b " [MOD " n "]" => ModEq n a b
variable {m n a b c d : â}
-- Since `ModEq` is semi-reducible, we need to provide the decidable instance manually
instance : Decidable (ModEq n a b) := inferInstanceAs <| Decidable (a % n = b % n)
namespace ModEq
@[refl]
protected theorem refl (a : â) : a â¡ a [MOD n] := rfl
protected theorem rfl : a â¡ a [MOD n] :=
ModEq.refl _
instance : IsRefl _ (ModEq n) :=
âšModEq.reflâ©
@[symm]
protected theorem symm : a â¡ b [MOD n] â b â¡ a [MOD n] :=
Eq.symm
@[trans]
protected theorem trans : a â¡ b [MOD n] â b â¡ c [MOD n] â a â¡ c [MOD n] :=
Eq.trans
instance : Trans (ModEq n) (ModEq n) (ModEq n) where
trans := Nat.ModEq.trans
protected theorem comm : a â¡ b [MOD n] â b â¡ a [MOD n] :=
âšModEq.symm, ModEq.symmâ©
end ModEq
theorem modEq_zero_iff_dvd : a â¡ 0 [MOD n] â n ⣠a := by rw [ModEq, zero_mod, dvd_iff_mod_eq_zero]
theorem _root_.Dvd.dvd.modEq_zero_nat (h : n ⣠a) : a ⡠0 [MOD n] :=
modEq_zero_iff_dvd.2 h
theorem _root_.Dvd.dvd.zero_modEq_nat (h : n ⣠a) : 0 ⡠a [MOD n] :=
h.modEq_zero_nat.symm
theorem modEq_iff_dvd : a â¡ b [MOD n] â (n : â€) ⣠b - a := by
rw [ModEq, eq_comm, â Int.natCast_inj, Int.natCast_mod, Int.natCast_mod,
Int.emod_eq_emod_iff_emod_sub_eq_zero, Int.dvd_iff_emod_eq_zero]
alias âšModEq.dvd, modEq_of_dvdâ© := modEq_iff_dvd
/-- A variant of `modEq_iff_dvd` with `Nat` divisibility -/
theorem modEq_iff_dvd' (h : a †b) : a â¡ b [MOD n] â n ⣠b - a := by
rw [modEq_iff_dvd, â Int.natCast_dvd_natCast, Int.ofNat_sub h]
theorem mod_modEq (a n) : a % n â¡ a [MOD n] :=
mod_mod _ _
namespace ModEq
lemma of_dvd (d : m ⣠n) (h : a ⡠b [MOD n]) : a ⡠b [MOD m] :=
modEq_of_dvd <| Int.ofNat_dvd.mpr d |>.trans h.dvd
protected theorem mul_left' (c : â) (h : a â¡ b [MOD n]) : c * a â¡ c * b [MOD c * n] := by
unfold ModEq at *; rw [mul_mod_mul_left, mul_mod_mul_left, h]
@[gcongr]
protected theorem mul_left (c : â) (h : a â¡ b [MOD n]) : c * a â¡ c * b [MOD n] :=
(h.mul_left' _).of_dvd (dvd_mul_left _ _)
protected theorem mul_right' (c : â) (h : a â¡ b [MOD n]) : a * c â¡ b * c [MOD n * c] := by
rw [mul_comm a, mul_comm b, mul_comm n]; exact h.mul_left' c
@[gcongr]
protected theorem mul_right (c : â) (h : a â¡ b [MOD n]) : a * c â¡ b * c [MOD n] := by
rw [mul_comm a, mul_comm b]; exact h.mul_left c
@[gcongr]
protected theorem mul (hâ : a â¡ b [MOD n]) (hâ : c â¡ d [MOD n]) : a * c â¡ b * d [MOD n] :=
(hâ.mul_left _).trans (hâ.mul_right _)
@[gcongr]
protected theorem pow (m : â) (h : a â¡ b [MOD n]) : a ^ m â¡ b ^ m [MOD n] := by
induction m with
| zero => rfl
| succ d hd =>
rw [Nat.pow_succ, Nat.pow_succ]
exact hd.mul h
@[gcongr]
protected theorem add (hâ : a â¡ b [MOD n]) (hâ : c â¡ d [MOD n]) : a + c â¡ b + d [MOD n] := by
rw [modEq_iff_dvd, Int.natCast_add, Int.natCast_add, add_sub_add_comm]
exact Int.dvd_add hâ.dvd hâ.dvd
@[gcongr]
protected theorem add_left (c : â) (h : a â¡ b [MOD n]) : c + a â¡ c + b [MOD n] :=
ModEq.rfl.add h
@[gcongr]
protected theorem add_right (c : â) (h : a â¡ b [MOD n]) : a + c â¡ b + c [MOD n] :=
h.add ModEq.rfl
protected theorem add_left_cancel (hâ : a â¡ b [MOD n]) (hâ : a + c â¡ b + d [MOD n]) :
c â¡ d [MOD n] := by
simp only [modEq_iff_dvd, Int.natCast_add] at *
rw [add_sub_add_comm] at hâ
convert Int.dvd_sub hâ hâ using 1
rw [add_sub_cancel_left]
protected theorem add_left_cancel' (c : â) (h : c + a â¡ c + b [MOD n]) : a â¡ b [MOD n] :=
ModEq.rfl.add_left_cancel h
protected theorem add_right_cancel (hâ : c â¡ d [MOD n]) (hâ : a + c â¡ b + d [MOD n]) :
a â¡ b [MOD n] := by
rw [add_comm a, add_comm b] at hâ
exact hâ.add_left_cancel hâ
protected theorem add_right_cancel' (c : â) (h : a + c â¡ b + c [MOD n]) : a â¡ b [MOD n] :=
ModEq.rfl.add_right_cancel h
/-- Cancel left multiplication on both sides of the `â¡` and in the modulus.
For cancelling left multiplication in the modulus, see `Nat.ModEq.of_mul_left`. -/
protected theorem mul_left_cancel' {a b c m : â} (hc : c â 0) :
c * a â¡ c * b [MOD c * m] â a â¡ b [MOD m] := by
simp only [modEq_iff_dvd, Int.natCast_mul, â Int.mul_sub]
exact fun h => (Int.dvd_of_mul_dvd_mul_left (Int.ofNat_ne_zero.mpr hc) h)
protected theorem mul_left_cancel_iff' {a b c m : â} (hc : c â 0) :
c * a â¡ c * b [MOD c * m] â a â¡ b [MOD m] :=
âšModEq.mul_left_cancel' hc, ModEq.mul_left' _â©
/-- Cancel right multiplication on both sides of the `â¡` and in the modulus.
For cancelling right multiplication in the modulus, see `Nat.ModEq.of_mul_right`. -/
protected theorem mul_right_cancel' {a b c m : â} (hc : c â 0) :
a * c â¡ b * c [MOD m * c] â a â¡ b [MOD m] := by
simp only [modEq_iff_dvd, Int.natCast_mul, â Int.sub_mul]
exact fun h => (Int.dvd_of_mul_dvd_mul_right (Int.ofNat_ne_zero.mpr hc) h)
protected theorem mul_right_cancel_iff' {a b c m : â} (hc : c â 0) :
a * c â¡ b * c [MOD m * c] â a â¡ b [MOD m] :=
âšModEq.mul_right_cancel' hc, ModEq.mul_right' _â©
/-- Cancel left multiplication in the modulus.
For cancelling left multiplication on both sides of the `â¡`, see `nat.modeq.mul_left_cancel'`. -/
lemma of_mul_left (m : â) (h : a â¡ b [MOD m * n]) : a â¡ b [MOD n] := by
rw [modEq_iff_dvd] at *
exact (dvd_mul_left (n : â€) (m : â€)).trans h
/-- Cancel right multiplication in the modulus.
For cancelling right multiplication on both sides of the `â¡`, see `nat.modeq.mul_right_cancel'`. -/
lemma of_mul_right (m : â) : a â¡ b [MOD n * m] â a â¡ b [MOD n] := mul_comm m n âž of_mul_left _
theorem of_div (h : a / c ⡠b / c [MOD m / c]) (ha : c ⣠a) (ha : c ⣠b) (ha : c ⣠m) :
a â¡ b [MOD m] := by convert h.mul_left' c <;> rwa [Nat.mul_div_cancel']
end ModEq
lemma modEq_sub (h : b †a) : a ⡠b [MOD a - b] := (modEq_of_dvd <| by rw [Int.ofNat_sub h]).symm
lemma modEq_one : a â¡ b [MOD 1] := modEq_of_dvd <| one_dvd _
@[simp] lemma modEq_zero_iff : a â¡ b [MOD 0] â a = b := by rw [ModEq, mod_zero, mod_zero]
@[simp] lemma add_modEq_left : n + a â¡ a [MOD n] := by rw [ModEq, add_mod_left]
@[simp] lemma add_modEq_right : a + n â¡ a [MOD n] := by rw [ModEq, add_mod_right]
namespace ModEq
theorem le_of_lt_add (h1 : a ⡠b [MOD m]) (h2 : a < b + m) : a †b :=
(le_total a b).elim id fun h3 =>
Nat.le_of_sub_eq_zero
(eq_zero_of_dvd_of_lt ((modEq_iff_dvd' h3).mp h1.symm) (by omega))
theorem add_le_of_lt (h1 : a ⡠b [MOD m]) (h2 : a < b) : a + m †b :=
le_of_lt_add (add_modEq_right.trans h1) (by omega)
theorem dvd_iff (h : a â¡ b [MOD m]) (hdm : d ⣠m) : d ⣠a â d ⣠b := by
simp only [â modEq_zero_iff_dvd]
replace h := h.of_dvd hdm
exact âšh.symm.trans, h.transâ©
theorem gcd_eq (h : a â¡ b [MOD m]) : gcd a m = gcd b m := by
have h1 := gcd_dvd_right a m
have h2 := gcd_dvd_right b m
exact
dvd_antisymm (dvd_gcd ((h.dvd_iff h1).mp (gcd_dvd_left a m)) h1)
(dvd_gcd ((h.dvd_iff h2).mpr (gcd_dvd_left b m)) h2)
lemma eq_of_abs_lt (h : a â¡ b [MOD m]) (h2 : |(b : â€) - a| < m) : a = b := by
apply Int.ofNat.inj
rw [eq_comm, â sub_eq_zero]
exact Int.eq_zero_of_abs_lt_dvd h.dvd h2
lemma eq_of_lt_of_lt (h : a â¡ b [MOD m]) (ha : a < m) (hb : b < m) : a = b :=
h.eq_of_abs_lt <| Int.abs_sub_lt_of_lt_lt ha hb
/-- To cancel a common factor `c` from a `ModEq` we must divide the modulus `m` by `gcd m c` -/
lemma cancel_left_div_gcd (hm : 0 < m) (h : c * a â¡ c * b [MOD m]) : a â¡ b [MOD m / gcd m c] := by
let d := gcd m c
have hmd := gcd_dvd_left m c
have hcd := gcd_dvd_right m c
rw [modEq_iff_dvd]
refine @Int.dvd_of_dvd_mul_right_of_gcd_one (m / d) (c / d) (b - a) ?_ ?_
· show (m / d : â€) ⣠c / d * (b - a)
rw [mul_comm, â Int.mul_ediv_assoc (b - a) (Int.natCast_dvd_natCast.mpr hcd), mul_comm]
apply Int.ediv_dvd_ediv (Int.natCast_dvd_natCast.mpr hmd)
rw [Int.mul_sub]
exact modEq_iff_dvd.mp h
· show Int.gcd (m / d) (c / d) = 1
simp only [d, â Int.natCast_div, Int.gcd_natCast_natCast (m / d) (c / d),
gcd_div hmd hcd, Nat.div_self (gcd_pos_of_pos_left c hm)]
/-- To cancel a common factor `c` from a `ModEq` we must divide the modulus `m` by `gcd m c` -/
lemma cancel_right_div_gcd (hm : 0 < m) (h : a * c â¡ b * c [MOD m]) : a â¡ b [MOD m / gcd m c] := by
apply cancel_left_div_gcd hm
simpa [mul_comm] using h
lemma cancel_left_div_gcd' (hm : 0 < m) (hcd : c â¡ d [MOD m]) (h : c * a â¡ d * b [MOD m]) :
a â¡ b [MOD m / gcd m c] :=
(h.trans <| hcd.symm.mul_right b).cancel_left_div_gcd hm
lemma cancel_right_div_gcd' (hm : 0 < m) (hcd : c â¡ d [MOD m]) (h : a * c â¡ b * d [MOD m]) :
a â¡ b [MOD m / gcd m c] :=
(h.trans <| hcd.symm.mul_left b).cancel_right_div_gcd hm
/-- A common factor that's coprime with the modulus can be cancelled from a `ModEq` -/
lemma cancel_left_of_coprime (hmc : gcd m c = 1) (h : c * a â¡ c * b [MOD m]) : a â¡ b [MOD m] := by
rcases m.eq_zero_or_pos with (rfl | hm)
· simp only [gcd_zero_left] at hmc
simp only [gcd_zero_left, hmc, one_mul, modEq_zero_iff] at h
subst h
rfl
simpa [hmc] using h.cancel_left_div_gcd hm
/-- A common factor that's coprime with the modulus can be cancelled from a `ModEq` -/
lemma cancel_right_of_coprime (hmc : gcd m c = 1) (h : a * c â¡ b * c [MOD m]) : a â¡ b [MOD m] :=
cancel_left_of_coprime hmc <| by simpa [mul_comm] using h
end ModEq
/-- The natural number less than `lcm n m` congruent to `a` mod `n` and `b` mod `m` -/
def chineseRemainder' (h : a â¡ b [MOD gcd n m]) : { k // k â¡ a [MOD n] â§ k â¡ b [MOD m] } :=
if hn : n = 0 then âša, by
rw [hn, gcd_zero_left] at h; constructor
· rfl
· exact hâ©
else
if hm : m = 0 then âšb, by
rw [hm, gcd_zero_right] at h; constructor
· exact h.symm
· rflâ©
else
âšlet (c, d) := xgcd n m; Int.toNat ((n * c * b + m * d * a) / gcd n m % lcm n m), by
rw [xgcd_val]
dsimp
rw [modEq_iff_dvd, modEq_iff_dvd,
Int.toNat_of_nonneg (Int.emod_nonneg _ (Int.natCast_ne_zero.2 (lcm_ne_zero hn hm)))]
have hnonzero : (gcd n m : â€) â 0 := by
norm_cast
rw [Nat.gcd_eq_zero_iff, not_and]
exact fun _ => hm
have hcoedvd : â t, (gcd n m : â€) ⣠t * (b - a) := fun t => h.dvd.mul_left _
have := gcd_eq_gcd_ab n m
constructor <;> rw [Int.emod_def, â sub_add] <;>
refine Int.dvd_add ?_ (dvd_mul_of_dvd_left ?_ _) <;>
try norm_cast
· rw [â sub_eq_iff_eq_add'] at this
rw [â this, Int.sub_mul, â add_sub_assoc, add_comm, add_sub_assoc, â Int.mul_sub,
Int.add_ediv_of_dvd_left, Int.mul_ediv_cancel_left _ hnonzero,
Int.mul_ediv_assoc _ h.dvd, â sub_sub, sub_self, zero_sub, Int.dvd_neg, mul_assoc]
· exact dvd_mul_right _ _
norm_cast
exact dvd_mul_right _ _
· exact dvd_lcm_left n m
· rw [â sub_eq_iff_eq_add] at this
rw [â this, Int.sub_mul, sub_add, â Int.mul_sub, Int.sub_ediv_of_dvd,
Int.mul_ediv_cancel_left _ hnonzero, Int.mul_ediv_assoc _ h.dvd, â sub_add, sub_self,
zero_add, mul_assoc]
· exact dvd_mul_right _ _
· exact hcoedvd _
· exact dvd_lcm_right n mâ©
/-- The natural number less than `n*m` congruent to `a` mod `n` and `b` mod `m` -/
def chineseRemainder (co : n.Coprime m) (a b : â) : { k // k â¡ a [MOD n] â§ k â¡ b [MOD m] } :=
chineseRemainder' (by convert @modEq_one a b)
theorem chineseRemainder'_lt_lcm (h : a â¡ b [MOD gcd n m]) (hn : n â 0) (hm : m â 0) :
â(chineseRemainder' h) < lcm n m := by
| dsimp only [chineseRemainder']
rw [dif_neg hn, dif_neg hm, Subtype.coe_mk, xgcd_val, â Int.toNat_natCast (lcm n m)]
have lcm_pos := Int.natCast_pos.mpr (Nat.pos_of_ne_zero (lcm_ne_zero hn hm))
| Mathlib/Data/Nat/ModEq.lean | 325 | 327 |
/-
Copyright (c) 2019 Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Buzzard
-/
import Mathlib.Data.EReal.Basic
deprecated_module (since := "2025-04-13")
| Mathlib/Data/Real/EReal.lean | 1,671 | 1,677 | |
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Batteries.Tactic.Init
import Mathlib.Logic.Function.Defs
/-!
# Binary map of options
This file defines the binary map of `Option`. This is mostly useful to define pointwise operations
on intervals.
## Main declarations
* `Option.mapâ`: Binary map of options.
## Notes
This file is very similar to the n-ary section of `Mathlib.Data.Set.Basic`, to
`Mathlib.Data.Finset.NAry` and to `Mathlib.Order.Filter.NAry`. Please keep them in sync.
We do not define `Option.mapâ` as its only purpose so far would be to prove properties of
`Option.mapâ` and casing already fulfills this task.
-/
universe u
open Function
namespace Option
variable {α β γ ÎŽ : Type*} {f : α â β â γ} {a : Option α} {b : Option β} {c : Option γ}
/-- The image of a binary function `f : α â β â γ` as a function `Option α â Option β â Option γ`.
Mathematically this should be thought of as the image of the corresponding function `α à β â γ`. -/
def mapâ (f : α â β â γ) (a : Option α) (b : Option β) : Option γ :=
a.bind fun a => b.map <| f a
/-- `Option.mapâ` in terms of monadic operations. Note that this can't be taken as the definition
because of the lack of universe polymorphism. -/
theorem mapâ_def {α β γ : Type u} (f : α â β â γ) (a : Option α) (b : Option β) :
mapâ f a b = f <$> a <*> b := by
cases a <;> rfl
@[simp]
theorem mapâ_some_some (f : α â β â γ) (a : α) (b : β) : mapâ f (some a) (some b) = f a b := rfl
theorem mapâ_coe_coe (f : α â β â γ) (a : α) (b : β) : mapâ f a b = f a b := rfl
@[simp]
theorem mapâ_none_left (f : α â β â γ) (b : Option β) : mapâ f none b = none := rfl
@[simp]
theorem mapâ_none_right (f : α â β â γ) (a : Option α) : mapâ f a none = none := by cases a <;> rfl
@[simp]
theorem mapâ_coe_left (f : α â β â γ) (a : α) (b : Option β) : mapâ f a b = b.map fun b => f a b :=
rfl
-- Porting note: This proof was `rfl` in Lean3, but now is not.
@[simp]
theorem mapâ_coe_right (f : α â β â γ) (a : Option α) (b : β) :
mapâ f a b = a.map fun a => f a b := by cases a <;> rfl
theorem mem_mapâ_iff {c : γ} : c â mapâ f a b â â a' b', a' â a â§ b' â b â§ f a' b' = c := by
simp [mapâ, bind_eq_some]
/-- `simp`-normal form of `mem_mapâ_iff`. -/
@[simp]
theorem mapâ_eq_some_iff {c : γ} :
| mapâ f a b = some c â â a' b', a' â a â§ b' â b â§ f a' b' = c := by
simp [mapâ, bind_eq_some]
| Mathlib/Data/Option/NAry.lean | 73 | 74 |
/-
Copyright (c) 2022 Jakob von Raumer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jakob von Raumer, Kevin Klinge, Andrew Yang
-/
import Mathlib.Algebra.Group.Submonoid.DistribMulAction
import Mathlib.GroupTheory.OreLocalization.Basic
import Mathlib.Algebra.GroupWithZero.Defs
/-!
# Localization over left Ore sets.
This file proves results on the localization of rings (monoids with zeros) over a left Ore set.
## References
* <https://ncatlab.org/nlab/show/Ore+localization>
* [Zoran Å koda, *Noncommutative localization in noncommutative geometry*][skoda2006]
## Tags
localization, Ore, non-commutative
-/
assert_not_exists RelIso
universe u
open OreLocalization
namespace OreLocalization
section MonoidWithZero
variable {R : Type*} [MonoidWithZero R] {S : Submonoid R} [OreSet S]
@[simp]
theorem zero_oreDiv' (s : S) : (0 : R) /â s = 0 := by
rw [OreLocalization.zero_def, oreDiv_eq_iff]
exact âšs, 1, by simp [Submonoid.smul_def]â©
instance : MonoidWithZero R[Sâ»Â¹] where
zero_mul x := by
induction' x using OreLocalization.ind with r s
rw [OreLocalization.zero_def, oreDiv_mul_char 0 r 1 s 0 1 (by simp), zero_mul, one_mul]
mul_zero x := by
induction' x using OreLocalization.ind with r s
rw [OreLocalization.zero_def, mul_div_one, mul_zero, zero_oreDiv', zero_oreDiv']
end MonoidWithZero
section CommMonoidWithZero
variable {R : Type*} [CommMonoidWithZero R] {S : Submonoid R} [OreSet S]
instance : CommMonoidWithZero R[Sâ»Â¹] where
__ := inferInstanceAs (MonoidWithZero R[Sâ»Â¹])
__ := inferInstanceAs (CommMonoid R[Sâ»Â¹])
end CommMonoidWithZero
section DistribMulAction
variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S] {X : Type*} [AddMonoid X]
variable [DistribMulAction R X]
private def add'' (râ : X) (sâ : S) (râ : X) (sâ : S) : X[Sâ»Â¹] :=
(oreDenom (sâ : R) sâ ⢠râ + oreNum (sâ : R) sâ ⢠râ) /â (oreDenom (sâ : R) sâ * sâ)
private theorem add''_char (râ : X) (sâ : S) (râ : X) (sâ : S) (rb : R) (sb : R)
(hb : sb * sâ = rb * sâ) (h : sb * sâ â S) :
add'' râ sâ râ sâ = (sb ⢠râ + rb ⢠râ) /â âšsb * sâ, hâ© := by
simp only [add'']
have ha := ore_eq (sâ : R) sâ
generalize oreNum (sâ : R) sâ = ra at *
generalize oreDenom (sâ : R) sâ = sa at *
rw [oreDiv_eq_iff]
rcases oreCondition sb sa with âšrc, sc, hcâ©
have : sc * rb * sâ = rc * ra * sâ := by
rw [mul_assoc rc, â ha, â mul_assoc, â hc, mul_assoc, mul_assoc, hb]
rcases ore_right_cancel _ _ sâ this with âšsd, hdâ©
use sd * sc
use sd * rc
simp only [smul_add, smul_smul, Submonoid.smul_def, Submonoid.coe_mul]
constructor
· rw [mul_assoc _ _ rb, hd, mul_assoc, hc, mul_assoc, mul_assoc]
· rw [mul_assoc, â mul_assoc (sc : R), hc, mul_assoc, mul_assoc]
attribute [local instance] OreLocalization.oreEqv
private def add' (râ : X) (sâ : S) : X[Sâ»Â¹] â X[Sâ»Â¹] :=
(--plus tilde
Quotient.lift
fun râsâ : X Ã S => add'' râsâ.1 râsâ.2 râ sâ) <| by
-- Porting note: `assoc_rw` & `noncomm_ring` were not ported yet
rintro âšrâ', sâ'â© âšrâ, sââ© âšsb, rb, hb, hb'â©
-- s*, r*
rcases oreCondition (sâ' : R) sâ with âšrc, sc, hcâ©
--s~~, r~~
rcases oreCondition rb sc with âšrd, sd, hdâ©
-- s#, r#
dsimp at *
rw [add''_char _ _ _ _ rc sc hc (sc * sâ').2]
have : sd * sb * sâ = rd * rc * sâ := by
rw [mul_assoc, hb', â mul_assoc, hd, mul_assoc, hc, â mul_assoc]
rw [add''_char _ _ _ _ (rd * rc : R) (sd * sb) this (sd * sb * sâ).2]
rw [mul_smul, â Submonoid.smul_def sb, hb, smul_smul, hd, oreDiv_eq_iff]
use 1
use rd
simp only [mul_smul, smul_add, one_smul, OneMemClass.coe_one, one_mul, true_and]
rw [this, hc, mul_assoc]
/-- The addition on the Ore localization. -/
@[irreducible]
private def add : X[Sâ»Â¹] â X[Sâ»Â¹] â X[Sâ»Â¹] := fun x =>
Quotient.lift (fun rs : X Ã S => add' rs.1 rs.2 x)
(by
rintro âšrâ, sââ© âšrâ, sââ© âšsb, rb, hb, hb'â©
induction' x with râ sâ
show add'' _ _ _ _ = add'' _ _ _ _
dsimp only at *
rcases oreCondition (sâ : R) sâ with âšrc, sc, hcâ©
rcases oreCondition rc sb with âšrd, sd, hdâ©
have : rd * rb * sâ = sd * sc * sâ := by
rw [mul_assoc, â hb', â mul_assoc, â hd, mul_assoc, â hc, mul_assoc]
rw [add''_char _ _ _ _ rc sc hc (sc * sâ).2]
rw [add''_char _ _ _ _ _ _ this.symm (sd * sc * sâ).2]
refine oreDiv_eq_iff.mpr ?_
simp only [Submonoid.mk_smul, smul_add]
use sd, 1
simp only [one_smul, one_mul, mul_smul, â hb, Submonoid.smul_def, â mul_assoc, and_true]
simp only [smul_smul, hd])
instance : Add X[Sâ»Â¹] :=
âšaddâ©
theorem oreDiv_add_oreDiv {r r' : X} {s s' : S} :
r /â s + r' /â s' =
(oreDenom (s : R) s' ⢠r + oreNum (s : R) s' ⢠r') /â (oreDenom (s : R) s' * s) := by
with_unfolding_all rfl
theorem oreDiv_add_char' {r r' : X} (s s' : S) (rb : R) (sb : R)
(h : sb * s = rb * s') (h' : sb * s â S) :
r /â s + r' /â s' = (sb ⢠r + rb ⢠r') /â âšsb * s, h'â© := by
with_unfolding_all exact add''_char r s r' s' rb sb h h'
/-- A characterization of the addition on the Ore localizaion, allowing for arbitrary Ore
numerator and Ore denominator. -/
theorem oreDiv_add_char {r r' : X} (s s' : S) (rb : R) (sb : S) (h : sb * s = rb * s') :
r /â s + r' /â s' = (sb ⢠r + rb ⢠r') /â (sb * s) :=
oreDiv_add_char' s s' rb sb h (sb * s).2
/-- Another characterization of the addition on the Ore localization, bundling up all witnesses
and conditions into a sigma type. -/
def oreDivAddChar' (r r' : X) (s s' : S) :
Σ'r'' : R,
Σ's'' : S, s'' * s = r'' * s' â§ r /â s + r' /â s' = (s'' ⢠r + r'' ⢠r') /â (s'' * s) :=
âšoreNum (s : R) s', oreDenom (s : R) s', ore_eq (s : R) s', oreDiv_add_oreDivâ©
@[simp]
theorem add_oreDiv {r r' : X} {s : S} : r /â s + r' /â s = (r + r') /â s := by
simp [oreDiv_add_char s s 1 1 (by simp)]
protected theorem add_assoc (x y z : X[Sâ»Â¹]) : x + y + z = x + (y + z) := by
induction' x with râ sâ
induction' y with râ sâ
induction' z with râ sâ
rcases oreDivAddChar' râ râ sâ sâ with âšra, sa, ha, ha'â©; rw [ha']; clear ha'
rcases oreDivAddChar' (sa ⢠râ + ra ⢠râ) râ (sa * sâ) sâ with âšrc, sc, hc, qâ©; rw [q]; clear q
simp only [smul_add, mul_assoc, add_assoc]
simp_rw [â add_oreDiv, â OreLocalization.expand']
congr 2
· rw [OreLocalization.expand râ sâ ra (ha.symm âž (sa * sâ).2)]; congr; ext; exact ha
· rw [OreLocalization.expand râ sâ rc (hc.symm âž (sc * (sa * sâ)).2)]; congr; ext; exact hc
@[simp]
theorem zero_oreDiv (s : S) : (0 : X) /â s = 0 := by
rw [OreLocalization.zero_def, oreDiv_eq_iff]
exact âšs, 1, by simpâ©
protected theorem zero_add (x : X[Sâ»Â¹]) : 0 + x = x := by
induction x
rw [â zero_oreDiv, add_oreDiv]; simp
protected theorem add_zero (x : X[Sâ»Â¹]) : x + 0 = x := by
induction x
rw [â zero_oreDiv, add_oreDiv]; simp
@[irreducible]
private def nsmul : â â X[Sâ»Â¹] â X[Sâ»Â¹] := nsmulRec
instance : AddMonoid X[Sâ»Â¹] where
add_assoc := OreLocalization.add_assoc
zero_add := OreLocalization.zero_add
add_zero := OreLocalization.add_zero
nsmul := nsmul
nsmul_zero _ := by with_unfolding_all rfl
nsmul_succ _ _ := by with_unfolding_all rfl
protected theorem smul_zero (x : R[Sâ»Â¹]) : x ⢠(0 : X[Sâ»Â¹]) = 0 := by
induction' x with r s
rw [OreLocalization.zero_def, smul_div_one, smul_zero, zero_oreDiv, zero_oreDiv]
protected theorem smul_add (z : R[Sâ»Â¹]) (x y : X[Sâ»Â¹]) :
z ⢠(x + y) = z ⢠x + z ⢠y := by
induction' x with râ sâ
induction' y with râ sâ
induction' z with râ sâ
rcases oreDivAddChar' râ râ sâ sâ with âšra, sa, ha, ha'â©; rw [ha']; clear ha'; norm_cast at ha
rw [OreLocalization.expand' râ sâ sa]
rw [OreLocalization.expand râ sâ ra (by rw [â ha]; apply SetLike.coe_mem)]
rw [â Subtype.coe_eq_of_eq_mk ha]
repeat rw [oreDiv_smul_oreDiv]
simp only [smul_add, add_oreDiv]
instance : DistribMulAction R[Sâ»Â¹] X[Sâ»Â¹] where
smul_zero := OreLocalization.smul_zero
smul_add := OreLocalization.smul_add
instance {Râ} [Monoid Râ] [MulAction Râ X] [MulAction Râ R]
[IsScalarTower Râ R X] [IsScalarTower Râ R R] :
DistribMulAction Râ X[Sâ»Â¹] where
smul_zero _ := by rw [â smul_one_oreDiv_one_smul, smul_zero]
smul_add _ _ _ := by simp only [â smul_one_oreDiv_one_smul, smul_add]
end DistribMulAction
section AddCommMonoid
variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S]
variable {X : Type*} [AddCommMonoid X] [DistribMulAction R X]
protected theorem add_comm (x y : X[Sâ»Â¹]) : x + y = y + x := by
induction' x with r s
induction' y with r' s'
rcases oreDivAddChar' r r' s s' with âšra, sa, ha, ha'â©
rw [ha', oreDiv_add_char' s' s _ _ ha.symm (ha âž (sa * s).2), add_comm]
congr; ext; exact ha
instance instAddCommMonoidOreLocalization : AddCommMonoid X[Sâ»Â¹] where
add_comm := OreLocalization.add_comm
end AddCommMonoid
section AddGroup
variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S]
variable {X : Type*} [AddGroup X] [DistribMulAction R X]
/-- Negation on the Ore localization is defined via negation on the numerator. -/
@[irreducible]
protected def neg : X[Sâ»Â¹] â X[Sâ»Â¹] :=
liftExpand (fun (r : X) (s : S) => -r /â s) fun r t s ht => by
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/12129): additional beta reduction needed
beta_reduce
rw [â smul_neg, â OreLocalization.expand]
instance instNegOreLocalization : Neg X[Sâ»Â¹] :=
âšOreLocalization.negâ©
@[simp]
protected theorem neg_def (r : X) (s : S) : -(r /â s) = -r /â s := by
with_unfolding_all rfl
protected theorem neg_add_cancel (x : X[Sâ»Â¹]) : -x + x = 0 := by
induction' x with r s; simp
/-- `zsmul` of `OreLocalization` -/
@[irreducible]
protected def zsmul : †â X[Sâ»Â¹] â X[Sâ»Â¹] := zsmulRec
unseal OreLocalization.zsmul in
instance instAddGroupOreLocalization : AddGroup X[Sâ»Â¹] where
neg_add_cancel := OreLocalization.neg_add_cancel
zsmul := OreLocalization.zsmul
end AddGroup
section AddCommGroup
variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S]
variable {X : Type*} [AddCommGroup X] [DistribMulAction R X]
instance : AddCommGroup X[Sâ»Â¹] where
__ := inferInstanceAs (AddGroup X[Sâ»Â¹])
__ := inferInstanceAs (AddCommMonoid X[Sâ»Â¹])
end AddCommGroup
end OreLocalization
| Mathlib/RingTheory/OreLocalization/Basic.lean | 377 | 389 | |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Nat.ModEq
import Mathlib.Data.Nat.Prime.Basic
import Mathlib.NumberTheory.Zsqrtd.Basic
/-!
# Pell's equation and Matiyasevic's theorem
This file solves Pell's equation, i.e. integer solutions to `x ^ 2 - d * y ^ 2 = 1`
*in the special case that `d = a ^ 2 - 1`*.
This is then applied to prove Matiyasevic's theorem that the power
function is Diophantine, which is the last key ingredient in the solution to Hilbert's tenth
problem. For the definition of Diophantine function, see `NumberTheory.Dioph`.
For results on Pell's equation for arbitrary (positive, non-square) `d`, see
`NumberTheory.Pell`.
## Main definition
* `pell` is a function assigning to a natural number `n` the `n`-th solution to Pell's equation
constructed recursively from the initial solution `(0, 1)`.
## Main statements
* `eq_pell` shows that every solution to Pell's equation is recursively obtained using `pell`
* `matiyasevic` shows that a certain system of Diophantine equations has a solution if and only if
the first variable is the `x`-component in a solution to Pell's equation - the key step towards
Hilbert's tenth problem in Davis' version of Matiyasevic's theorem.
* `eq_pow_of_pell` shows that the power function is Diophantine.
## Implementation notes
The proof of Matiyasevic's theorem doesn't follow Matiyasevic's original account of using Fibonacci
numbers but instead Davis' variant of using solutions to Pell's equation.
## References
* [M. Carneiro, _A Lean formalization of MatiyaseviÄ's theorem_][carneiro2018matiyasevic]
* [M. Davis, _Hilbert's tenth problem is unsolvable_][MR317916]
## Tags
Pell's equation, Matiyasevic's theorem, Hilbert's tenth problem
-/
namespace Pell
open Nat
section
variable {d : â€}
/-- The property of being a solution to the Pell equation, expressed
as a property of elements of `â€âd`. -/
def IsPell : â€âd â Prop
| âšx, yâ© => x * x - d * y * y = 1
theorem isPell_norm : â {b : â€âd}, IsPell b â b * star b = 1
| âšx, yâ© => by simp [Zsqrtd.ext_iff, IsPell, mul_comm]; ring_nf
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]
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])
theorem isPell_star : â {b : â€âd}, IsPell b â IsPell (star b)
| âšx, yâ© => by simp [IsPell, Zsqrtd.star_mk]
end
section
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)
-- TODO(lint): Fix double namespace issue
/-- The Pell sequences, i.e. the sequence of integer solutions to `x ^ 2 - d * y ^ 2 = 1`, where
`d = a ^ 2 - 1`, defined together in mutual recursion. -/
--@[nolint dup_namespace]
def pell : â â â Ã â
| 0 => (1, 0)
| n+1 => ((pell n).1 * a + d a1 * (pell n).2, (pell n).1 + (pell n).2 * a)
/-- The Pell `x` sequence. -/
def xn (n : â) : â :=
(pell a1 n).1
/-- The Pell `y` sequence. -/
def yn (n : â) : â :=
(pell a1 n).2
@[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
@[simp]
theorem xn_zero : xn a1 0 = 1 :=
rfl
@[simp]
theorem yn_zero : yn a1 0 = 0 :=
rfl
@[simp]
theorem xn_succ (n : â) : xn a1 (n + 1) = xn a1 n * a + d a1 * yn a1 n :=
rfl
@[simp]
theorem yn_succ (n : â) : yn a1 (n + 1) = xn a1 n + yn a1 n * a :=
rfl
theorem xn_one : xn a1 1 = a := by simp
theorem yn_one : yn a1 1 = 1 := by simp
/-- The Pell `x` sequence, considered as an integer sequence. -/
def xz (n : â) : †:=
xn a1 n
/-- The Pell `y` sequence, considered as an integer sequence. -/
def yz (n : â) : †:=
yn a1 n
section
/-- The element `a` such that `d = a ^ 2 - 1`, considered as an integer. -/
def az (a : â) : †:=
a
end
include a1 in
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)
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
@[simp]
theorem xz_succ (n : â) : (xz a1 (n + 1)) = xz a1 n * az a + d a1 * yz a1 n :=
rfl
@[simp]
theorem yz_succ (n : â) : yz a1 (n + 1) = xz a1 n + yz a1 n * az a :=
rfl
/-- The Pell sequence can also be viewed as an element of `â€âd` -/
def pellZd (n : â) : â€â(d a1) :=
âšxn a1 n, yn a1 nâ©
@[simp]
theorem pellZd_re (n : â) : (pellZd a1 n).re = xn a1 n :=
rfl
@[simp]
theorem pellZd_im (n : â) : (pellZd a1 n).im = yn a1 n :=
rfl
theorem isPell_nat {x y : â} : IsPell (âšx, yâ© : â€â(d a1)) â x * x - d a1 * y * y = 1 :=
âšfun h =>
(Nat.cast_inj (R := â€)).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â©
@[simp]
theorem pellZd_succ (n : â) : pellZd a1 (n + 1) = pellZd a1 n * âša, 1â© := by ext <;> simp
theorem isPell_one : IsPell (âša, 1â© : â€â(d a1)) :=
show az a * az a - d a1 * 1 * 1 = 1 by simp [dz_val]
theorem isPell_pellZd : â n : â, IsPell (pellZd a1 n)
| 0 => rfl
| n + 1 => by
let o := isPell_one a1
simpa using Pell.isPell_mul (isPell_pellZd n) o
@[simp]
theorem pell_eqz (n : â) : xz a1 n * xz a1 n - d a1 * yz a1 n * yz a1 n = 1 :=
isPell_pellZd a1 n
@[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.natCast_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 (R := â€)).1 (by rw [Int.ofNat_sub hl]; exact h)
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â©
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 _ _)
theorem n_lt_xn (n) : n < xn a1 n :=
lt_of_lt_of_le (Nat.lt_pow_self a1) (xn_ge_a_pow a1 n)
theorem x_pos (n) : 0 < xn a1 n :=
lt_of_le_of_lt (Nat.zero_le n) (n_lt_xn a1 n)
theorem eq_pell_lem : â (n) (b : â€â(d a1)), 1 †b â IsPell b â
b †pellZd a1 n â â n, b = pellZd a1 n
| 0, _ => 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
obtain âšx, yâ© := b
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)
rw [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
rw [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_neg_cancel,
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
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 _)
/-- Every solution to **Pell's equation** is recursively obtained from the initial solution
`(1,0)` using the recursion `pell`. -/
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â©â©
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]
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]
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]
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]
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)
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)
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 (kx.mul_left _) (ky.mul_left _)
theorem strictMono_y : StrictMono (yn a1)
| _, 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 only [yn_succ, gt_iff_lt]; 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 _)
theorem strictMono_x : StrictMono (xn a1)
| _, 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 only [xn_succ, gt_iff_lt]
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
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)
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 _)
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â©
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 <;> simpa using 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
rcases 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â©
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])
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) _
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
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
rw [Zsqrtd.nsmul_val (2 * a : â)] at this
injection this with hâ hâ
constructor <;> apply Int.ofNat.inj <;> [simpa using hâ; simpa using hâ]
theorem xn_succ_succ (n) : xn a1 (n + 2) + xn a1 n = 2 * a * xn a1 (n + 1) :=
(xy_succ_succ a1 n).1
theorem yn_succ_succ (n) : yn a1 (n + 2) + yn a1 n = 2 * a * yn a1 (n + 1) :=
(xy_succ_succ a1 n).2
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.natCast_add, â Int.natCast_mul, xn_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.natCast_add, â Int.natCast_mul, yn_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))
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
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
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.natCast_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)
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 _ _
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
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
theorem xn_modEq_x2n_sub {n j} (h : j †2 * n) : xn a1 (2 * n - j) + xn a1 j ⡠0 [MOD xn a1 n] :=
(le_total j n).elim (xn_modEq_x2n_sub_lem a1) fun jn => by
have : 2 * n - j + j †n + j := by
rw [tsub_add_cancel_of_le h, two_mul]; exact Nat.add_le_add_left jn _
let t := xn_modEq_x2n_sub_lem a1 (Nat.le_of_add_le_add_right this)
rwa [tsub_tsub_cancel_of_le h, add_comm] at t
theorem xn_modEq_x4n_add (n j) : xn a1 (4 * n + j) â¡ xn a1 j [MOD xn a1 n] :=
ModEq.add_right_cancel' (xn a1 (2 * n + j)) <| by
refine @ModEq.trans _ _ 0 _ ?_ (by rw [add_comm]; exact (xn_modEq_x2n_add _ _ _).symm)
rw [show 4 * n = 2 * n + 2 * n from right_distrib 2 2 n, add_assoc]
apply xn_modEq_x2n_add
theorem xn_modEq_x4n_sub {n j} (h : j †2 * n) : xn a1 (4 * n - j) ⡠xn a1 j [MOD xn a1 n] :=
have h' : j †2 * n := le_trans h (by rw [Nat.succ_mul])
ModEq.add_right_cancel' (xn a1 (2 * n - j)) <| by
refine @ModEq.trans _ _ 0 _ ?_ (by rw [add_comm]; exact (xn_modEq_x2n_sub _ h).symm)
rw [show 4 * n = 2 * n + 2 * n from right_distrib 2 2 n, add_tsub_assoc_of_le h']
apply xn_modEq_x2n_add
theorem eq_of_xn_modEq_lem1 {i n} : â {j}, i < j â j < n â xn a1 i % xn a1 n < xn a1 j % xn a1 n
| 0, ij, _ => absurd ij (Nat.not_lt_zero _)
| j + 1, ij, jn => by
suffices xn a1 j % xn a1 n < xn a1 (j + 1) % xn a1 n from
(lt_or_eq_of_le (Nat.le_of_succ_le_succ ij)).elim
(fun h => lt_trans (eq_of_xn_modEq_lem1 h (le_of_lt jn)) this) fun h => by
rw [h]; exact this
rw [Nat.mod_eq_of_lt (strictMono_x _ (Nat.lt_of_succ_lt jn)),
Nat.mod_eq_of_lt (strictMono_x _ jn)]
exact strictMono_x _ (Nat.lt_succ_self _)
theorem eq_of_xn_modEq_lem2 {n} (h : 2 * xn a1 n = xn a1 (n + 1)) : a = 2 â§ n = 0 := by
rw [xn_succ, mul_comm] at h
have : n = 0 :=
n.eq_zero_or_pos.resolve_right fun np =>
_root_.ne_of_lt
(lt_of_le_of_lt (Nat.mul_le_mul_left _ a1)
(Nat.lt_add_of_pos_right <| mul_pos (d_pos a1) (strictMono_y a1 np)))
h
cases this; simp at h; exact âšh.symm, rflâ©
theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
â {j}, i < j â j †2 * n â j â n â ¬(a = 2 â§ n = 1 â§ i = 0 â§ j = 2) â
xn a1 i % xn a1 n < xn a1 j % xn a1 n
| 0, ij, _, _, _ => absurd ij (Nat.not_lt_zero _)
| j + 1, ij, j2n, jnn, ntriv =>
have lem2 : â k > n, k †2 * n â (â(xn a1 k % xn a1 n) : â€) =
xn a1 n - xn a1 (2 * n - k) := fun k kn k2n => by
let k2nl :=
lt_of_add_lt_add_right <|
show 2 * n - k + k < n + k by
rw [tsub_add_cancel_of_le]
· rw [two_mul]
exact add_lt_add_left kn n
exact k2n
have xle : xn a1 (2 * n - k) †xn a1 n := le_of_lt <| strictMono_x a1 k2nl
suffices xn a1 k % xn a1 n = xn a1 n - xn a1 (2 * n - k) by rw [this, Int.ofNat_sub xle]
rw [â Nat.mod_eq_of_lt (Nat.sub_lt (x_pos a1 n) (x_pos a1 (2 * n - k)))]
apply ModEq.add_right_cancel' (xn a1 (2 * n - k))
rw [tsub_add_cancel_of_le xle]
have t := xn_modEq_x2n_sub_lem a1 k2nl.le
rw [tsub_tsub_cancel_of_le k2n] at t
exact t.trans dvd_rfl.zero_modEq_nat
(lt_trichotomy j n).elim (fun jn : j < n => eq_of_xn_modEq_lem1 _ ij (lt_of_le_of_ne jn jnn))
fun o =>
o.elim
(fun jn : j = n => by
cases jn
apply Int.lt_of_ofNat_lt_ofNat
rw [lem2 (n + 1) (Nat.lt_succ_self _) j2n,
show 2 * n - (n + 1) = n - 1 by
rw [two_mul, tsub_add_eq_tsub_tsub, add_tsub_cancel_right]]
refine lt_sub_left_of_add_lt (Int.ofNat_lt_ofNat_of_lt ?_)
rcases lt_or_eq_of_le <| Nat.le_of_succ_le_succ ij with lin | ein
· rw [Nat.mod_eq_of_lt (strictMono_x _ lin)]
have ll : xn a1 (n - 1) + xn a1 (n - 1) †xn a1 n := by
rw [â two_mul, mul_comm,
show xn a1 n = xn a1 (n - 1 + 1) by rw [tsub_add_cancel_of_le (succ_le_of_lt npos)],
xn_succ]
exact le_trans (Nat.mul_le_mul_left _ a1) (Nat.le_add_right _ _)
have npm : (n - 1).succ = n := Nat.succ_pred_eq_of_pos npos
have il : i †n - 1 := by
apply Nat.le_of_succ_le_succ
rw [npm]
exact lin
rcases lt_or_eq_of_le il with ill | ile
· exact lt_of_lt_of_le (Nat.add_lt_add_left (strictMono_x a1 ill) _) ll
· rw [ile]
apply lt_of_le_of_ne ll
rw [â two_mul]
exact fun e =>
ntriv <| by
let âša2, s1â© :=
@eq_of_xn_modEq_lem2 _ a1 (n - 1)
(by rwa [tsub_add_cancel_of_le (succ_le_of_lt npos)])
have n1 : n = 1 := le_antisymm (tsub_eq_zero_iff_le.mp s1) npos
rw [ile, a2, n1]; exact âšrfl, rfl, rfl, rflâ©
· rw [ein, Nat.mod_self, add_zero]
exact strictMono_x _ (Nat.pred_lt npos.ne'))
fun jn : j > n =>
have lem1 : j â n â xn a1 j % xn a1 n < xn a1 (j + 1) % xn a1 n â
xn a1 i % xn a1 n < xn a1 (j + 1) % xn a1 n :=
fun jn s =>
(lt_or_eq_of_le (Nat.le_of_succ_le_succ ij)).elim
(fun h =>
lt_trans
(eq_of_xn_modEq_lem3 npos h (le_of_lt (Nat.lt_of_succ_le j2n)) jn
fun âš_, n1, _, j2â© => by
rw [n1, j2] at j2n; exact absurd j2n (by decide))
s)
fun h => by rw [h]; exact s
lem1 (_root_.ne_of_gt jn) <|
Int.lt_of_ofNat_lt_ofNat <| by
rw [lem2 j jn (le_of_lt j2n), lem2 (j + 1) (Nat.le_succ_of_le jn) j2n]
refine sub_lt_sub_left (Int.ofNat_lt_ofNat_of_lt <| strictMono_x _ ?_) _
rw [Nat.sub_succ]
exact Nat.pred_lt (_root_.ne_of_gt <| tsub_pos_of_lt j2n)
theorem eq_of_xn_modEq_le {i j n} (ij : i †j) (j2n : j †2 * n)
(h : xn a1 i â¡ xn a1 j [MOD xn a1 n])
(ntriv : ¬(a = 2 ⧠n = 1 ⧠i = 0 ⧠j = 2)) : i = j :=
if npos : n = 0 then by simp_all
else
(lt_or_eq_of_le ij).resolve_left fun ij' =>
if jn : j = n then by
refine _root_.ne_of_gt ?_ h
rw [jn, Nat.mod_self]
have x0 : 0 < xn a1 0 % xn a1 n := by
rw [Nat.mod_eq_of_lt (strictMono_x a1 (Nat.pos_of_ne_zero npos))]
exact Nat.succ_pos _
rcases i with - | i
· exact x0
rw [jn] at ij'
exact
x0.trans
(eq_of_xn_modEq_lem3 _ (Nat.pos_of_ne_zero npos) (Nat.succ_pos _) (le_trans ij j2n)
(_root_.ne_of_lt ij') fun âš_, n1, _, i2â© => by
rw [n1, i2] at ij'; exact absurd ij' (by decide))
else _root_.ne_of_lt (eq_of_xn_modEq_lem3 a1 (Nat.pos_of_ne_zero npos) ij' j2n jn ntriv) h
theorem eq_of_xn_modEq {i j n} (i2n : i †2 * n) (j2n : j †2 * n)
(h : xn a1 i â¡ xn a1 j [MOD xn a1 n])
(ntriv : a = 2 â n = 1 â (i = 0 â j â 2) â§ (i = 2 â j â 0)) : i = j :=
(le_total i j).elim
(fun ij => eq_of_xn_modEq_le a1 ij j2n h fun âša2, n1, i0, j2â© => (ntriv a2 n1).left i0 j2)
fun ij =>
(eq_of_xn_modEq_le a1 ij i2n h.symm fun âša2, n1, j0, i2â© => (ntriv a2 n1).right i2 j0).symm
theorem eq_of_xn_modEq' {i j n} (ipos : 0 < i) (hin : i †n) (j4n : j †4 * n)
(h : xn a1 j â¡ xn a1 i [MOD xn a1 n]) : j = i âš j + i = 4 * n :=
have i2n : i †2 * n := by apply le_trans hin; rw [two_mul]; apply Nat.le_add_left
(le_or_gt j (2 * n)).imp
(fun j2n : j †2 * n =>
eq_of_xn_modEq a1 j2n i2n h fun _ n1 =>
âšfun _ i2 => by rw [n1, i2] at hin; exact absurd hin (by decide), fun _ i0 =>
_root_.ne_of_gt ipos i0â©)
fun j2n : 2 * n < j =>
suffices i = 4 * n - j by rw [this, add_tsub_cancel_of_le j4n]
have j42n : 4 * n - j †2 * n := by omega
eq_of_xn_modEq a1 i2n j42n
(h.symm.trans <| by
let t := xn_modEq_x4n_sub a1 j42n
rwa [tsub_tsub_cancel_of_le j4n] at t)
(by omega)
theorem modEq_of_xn_modEq {i j n} (ipos : 0 < i) (hin : i †n)
(h : xn a1 j â¡ xn a1 i [MOD xn a1 n]) :
j â¡ i [MOD 4 * n] âš j + i â¡ 0 [MOD 4 * n] :=
let j' := j % (4 * n)
have n4 : 0 < 4 * n := mul_pos (by decide) (ipos.trans_le hin)
have jl : j' < 4 * n := Nat.mod_lt _ n4
have jj : j â¡ j' [MOD 4 * n] := by delta ModEq; rw [Nat.mod_eq_of_lt jl]
have : â j q, xn a1 (j + 4 * n * q) â¡ xn a1 j [MOD xn a1 n] := by
intro j q; induction q with
| zero => simp [ModEq.refl]
| succ q IH =>
rw [Nat.mul_succ, â add_assoc, add_comm]
exact (xn_modEq_x4n_add _ _ _).trans IH
Or.imp (fun ji : j' = i => by rwa [â ji])
(fun ji : j' + i = 4 * n =>
(jj.add_right _).trans <| by
rw [ji]
exact dvd_rfl.modEq_zero_nat)
(eq_of_xn_modEq' a1 ipos hin jl.le <|
(h.symm.trans <| by
rw [â Nat.mod_add_div j (4 * n)]
exact this j' _).symm)
end
theorem xy_modEq_of_modEq {a b c} (a1 : 1 < a) (b1 : 1 < b) (h : a â¡ b [MOD c]) :
â n, xn a1 n â¡ xn b1 n [MOD c] â§ yn a1 n â¡ yn b1 n [MOD c]
| 0 => by constructor <;> rfl
| 1 => by simpa using âšh, ModEq.refl 1â©
| n + 2 =>
âš(xy_modEq_of_modEq a1 b1 h n).left.add_right_cancel <| by
rw [xn_succ_succ a1, xn_succ_succ b1]
exact (h.mul_left _).mul (xy_modEq_of_modEq _ _ h (n + 1)).left,
(xy_modEq_of_modEq a1 b1 h n).right.add_right_cancel <| by
rw [yn_succ_succ a1, yn_succ_succ b1]
exact (h.mul_left _).mul (xy_modEq_of_modEq _ _ h (n + 1)).rightâ©
theorem matiyasevic {a k x y} :
(â a1 : 1 < a, xn a1 k = x â§ yn a1 k = y) â
1 < a â§ k †y â§ (x = 1 â§ y = 0 âš
â u v s t b : â,
x * x - (a * a - 1) * y * y = 1 â§ u * u - (a * a - 1) * v * v = 1 â§
s * s - (b * b - 1) * t * t = 1 â§ 1 < b â§ b â¡ 1 [MOD 4 * y] â§
b ⡠a [MOD u] ⧠0 < v ⧠y * y ⣠v ⧠s ⡠x [MOD u] ⧠t ⡠k [MOD 4 * y]) :=
âšfun âša1, hx, hyâ© => by
rw [â hx, â hy]
refine âša1,
(Nat.eq_zero_or_pos k).elim (fun k0 => by rw [k0]; exact âšle_rfl, Or.inl âšrfl, rflâ©â©)
fun kpos => ?_â©
exact
let x := xn a1 k
let y := yn a1 k
let m := 2 * (k * y)
let u := xn a1 m
let v := yn a1 m
have ky : k †y := yn_ge_n a1 k
have yv : y * y ⣠v := (ysq_dvd_yy a1 k).trans <| (y_dvd_iff _ _ _).2 <| dvd_mul_left _ _
have uco : Nat.Coprime u (4 * y) :=
have : 2 ⣠v :=
modEq_zero_iff_dvd.1 <| (yn_modEq_two _ _).trans (dvd_mul_right _ _).modEq_zero_nat
have : Nat.Coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
(this.mul_right this).mul_right <|
(xy_coprime _ _).coprime_dvd_right (dvd_of_mul_left_dvd yv)
let âšb, ba, bm1â© := chineseRemainder uco a 1
have m1 : 1 < m :=
have : 0 < k * y := mul_pos kpos (strictMono_y a1 kpos)
Nat.mul_le_mul_left 2 this
have vp : 0 < v := strictMono_y a1 (lt_trans zero_lt_one m1)
have b1 : 1 < b :=
have : xn a1 1 < u := strictMono_x a1 m1
have : a < u := by simpa using this
lt_of_lt_of_le a1 <| by
delta ModEq at ba; rw [Nat.mod_eq_of_lt this] at ba; rw [â ba]
apply Nat.mod_le
let s := xn b1 k
let t := yn b1 k
have sx : s â¡ x [MOD u] := (xy_modEq_of_modEq b1 a1 ba k).left
have tk : t â¡ k [MOD 4 * y] :=
have : 4 * y ⣠b - 1 :=
Int.natCast_dvd_natCast.1 <| by rw [Int.ofNat_sub (le_of_lt b1)]; exact bm1.symm.dvd
(yn_modEq_a_sub_one _ _).of_dvd this
âšky,
Or.inr
âšu, v, s, t, b, pell_eq _ _, pell_eq _ _, pell_eq _ _, b1, bm1, ba, vp, yv, sx, tkâ©â©,
fun âša1, ky, oâ© =>
âša1,
match o with
| Or.inl âšx1, y0â© => by
rw [y0] at ky; rw [Nat.eq_zero_of_le_zero ky, x1, y0]; exact âšrfl, rflâ©
| Or.inr âšu, v, s, t, b, xy, uv, st, b1, remâ© =>
match x, y, eq_pell a1 xy, u, v, eq_pell a1 uv, s, t, eq_pell b1 st, rem, ky with
| _, _, âši, rfl, rflâ©, _, _, âšn, rfl, rflâ©, _, _, âšj, rfl, rflâ©,
âš(bm1 : b â¡ 1 [MOD 4 * yn a1 i]), (ba : b â¡ a [MOD xn a1 n]), (vp : 0 < yn a1 n),
(yv : yn a1 i * yn a1 i ⣠yn a1 n), (sx : xn b1 j ⡠xn a1 i [MOD xn a1 n]),
(tk : yn b1 j â¡ k [MOD 4 * yn a1 i])â©,
(ky : k †yn a1 i) =>
(Nat.eq_zero_or_pos i).elim
(fun i0 => by
simp only [i0, yn_zero, nonpos_iff_eq_zero] at ky; rw [i0, ky]; exact âšrfl, rflâ©)
| fun ipos => by
suffices i = k by rw [this]; exact âšrfl, rflâ©
clear o rem xy uv st
have iln : i †n :=
le_of_not_gt fun hin =>
not_lt_of_ge (Nat.le_of_dvd vp (dvd_of_mul_left_dvd yv)) (strictMono_y a1 hin)
have yd : 4 * yn a1 i ⣠4 * n := mul_dvd_mul_left _ <| dvd_of_ysq_dvd a1 yv
have jk : j â¡ k [MOD 4 * yn a1 i] :=
have : 4 * yn a1 i ⣠b - 1 :=
Int.natCast_dvd_natCast.1 <| by rw [Int.ofNat_sub (le_of_lt b1)]; exact bm1.symm.dvd
((yn_modEq_a_sub_one b1 _).of_dvd this).symm.trans tk
have ki : k + i < 4 * yn a1 i :=
lt_of_le_of_lt (_root_.add_le_add ky (yn_ge_n a1 i)) <| by
rw [â two_mul]
exact Nat.mul_lt_mul_of_pos_right (by decide) (strictMono_y a1 ipos)
have ji : j â¡ i [MOD 4 * n] :=
have : xn a1 j â¡ xn a1 i [MOD xn a1 n] :=
(xy_modEq_of_modEq b1 a1 ba j).left.symm.trans sx
(modEq_of_xn_modEq a1 ipos iln this).resolve_right
fun ji : j + i â¡ 0 [MOD 4 * n] =>
not_le_of_gt ki <|
| Mathlib/NumberTheory/PellMatiyasevic.lean | 800 | 820 |
/-
Copyright (c) 2019 Jean Lo. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean Lo, Yaël Dillies, Moritz Doll
-/
import Mathlib.Algebra.Order.Pi
import Mathlib.Analysis.Convex.Function
import Mathlib.Analysis.LocallyConvex.Basic
import Mathlib.Data.Real.Pointwise
/-!
# Seminorms
This file defines seminorms.
A seminorm is a function to the reals which is positive-semidefinite, absolutely homogeneous, and
subadditive. They are closely related to convex sets, and a topological vector space is locally
convex if and only if its topology is induced by a family of seminorms.
## Main declarations
For a module over a normed ring:
* `Seminorm`: A function to the reals that is positive-semidefinite, absolutely homogeneous, and
subadditive.
* `normSeminorm ð E`: The norm on `E` as a seminorm.
## References
* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]
## Tags
seminorm, locally convex, LCTVS
-/
assert_not_exists balancedCore
open NormedField Set Filter
open scoped NNReal Pointwise Topology Uniformity
variable {R R' ð ðâ ðâ ð E Eâ Eâ F ι : Type*}
/-- A seminorm on a module over a normed ring is a function to the reals that is positive
semidefinite, positive homogeneous, and subadditive. -/
structure Seminorm (ð : Type*) (E : Type*) [SeminormedRing ð] [AddGroup E] [SMul ð E] extends
AddGroupSeminorm E where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
smul' : â (a : ð) (x : E), toFun (a ⢠x) = âaâ * toFun x
attribute [nolint docBlame] Seminorm.toAddGroupSeminorm
/-- `SeminormClass F ð E` states that `F` is a type of seminorms on the `ð`-module `E`.
You should extend this class when you extend `Seminorm`. -/
class SeminormClass (F : Type*) (ð E : outParam Type*) [SeminormedRing ð] [AddGroup E]
[SMul ð E] [FunLike F E â] : Prop extends AddGroupSeminormClass F E â where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
map_smul_eq_mul (f : F) (a : ð) (x : E) : f (a ⢠x) = âaâ * f x
export SeminormClass (map_smul_eq_mul)
section Of
/-- Alternative constructor for a `Seminorm` on an `AddCommGroup E` that is a module over a
`SeminormedRing ð`. -/
def Seminorm.of [SeminormedRing ð] [AddCommGroup E] [Module ð E] (f : E â â)
(add_le : â x y : E, f (x + y) †f x + f y) (smul : â (a : ð) (x : E), f (a ⢠x) = âaâ * f x) :
Seminorm ð E where
toFun := f
map_zero' := by rw [â zero_smul ð (0 : E), smul, norm_zero, zero_mul]
add_le' := add_le
smul' := smul
neg' x := by rw [â neg_one_smul ð, smul, norm_neg, â smul, one_smul]
/-- Alternative constructor for a `Seminorm` over a normed field `ð` that only assumes `f 0 = 0`
and an inequality for the scalar multiplication. -/
def Seminorm.ofSMulLE [NormedField ð] [AddCommGroup E] [Module ð E] (f : E â â) (map_zero : f 0 = 0)
(add_le : â x y, f (x + y) †f x + f y) (smul_le : â (r : ð) (x), f (r ⢠x) †ârâ * f x) :
Seminorm ð E :=
Seminorm.of f add_le fun r x => by
refine le_antisymm (smul_le r x) ?_
by_cases h : r = 0
· simp [h, map_zero]
rw [â mul_le_mul_left (inv_pos.mpr (norm_pos_iff.mpr h))]
rw [inv_mul_cancel_leftâ (norm_ne_zero_iff.mpr h)]
specialize smul_le râ»Â¹ (r ⢠x)
rw [norm_inv] at smul_le
convert smul_le
simp [h]
end Of
namespace Seminorm
section SeminormedRing
variable [SeminormedRing ð]
section AddGroup
variable [AddGroup E]
section SMul
variable [SMul ð E]
instance instFunLike : FunLike (Seminorm ð E) E â where
coe f := f.toFun
coe_injective' f g h := by
rcases f with âšâš_â©â©
rcases g with âšâš_â©â©
congr
instance instSeminormClass : SeminormClass (Seminorm ð E) ð E where
map_zero f := f.map_zero'
map_add_le_add f := f.add_le'
map_neg_eq_map f := f.neg'
map_smul_eq_mul f := f.smul'
@[ext]
theorem ext {p q : Seminorm ð E} (h : â x, (p : E â â) x = q x) : p = q :=
DFunLike.ext p q h
instance instZero : Zero (Seminorm ð E) :=
âš{ AddGroupSeminorm.instZeroAddGroupSeminorm.zero with
smul' := fun _ _ => (mul_zero _).symm }â©
@[simp]
theorem coe_zero : â(0 : Seminorm ð E) = 0 :=
rfl
@[simp]
theorem zero_apply (x : E) : (0 : Seminorm ð E) x = 0 :=
rfl
instance : Inhabited (Seminorm ð E) :=
âš0â©
variable (p : Seminorm ð E) (x : E) (r : â)
/-- Any action on `â` which factors through `ââ¥0` applies to a seminorm. -/
instance instSMul [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] : SMul R (Seminorm ð E) where
smul r p :=
{ r ⢠p.toAddGroupSeminorm with
toFun := fun x => r ⢠p x
smul' := fun _ _ => by
simp only [â smul_one_smul ââ¥0 r (_ : â), NNReal.smul_def, smul_eq_mul]
rw [map_smul_eq_mul, mul_left_comm] }
instance [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] [SMul R' â] [SMul R' ââ¥0]
[IsScalarTower R' ââ¥0 â] [SMul R R'] [IsScalarTower R R' â] :
IsScalarTower R R' (Seminorm ð E) where
smul_assoc r a p := ext fun x => smul_assoc r a (p x)
theorem coe_smul [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] (r : R) (p : Seminorm ð E) :
â(r ⢠p) = r ⢠âp :=
rfl
@[simp]
theorem smul_apply [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] (r : R) (p : Seminorm ð E)
(x : E) : (r ⢠p) x = r ⢠p x :=
rfl
instance instAdd : Add (Seminorm ð E) where
add p q :=
{ p.toAddGroupSeminorm + q.toAddGroupSeminorm with
toFun := fun x => p x + q x
smul' := fun a x => by simp only [map_smul_eq_mul, map_smul_eq_mul, mul_add] }
theorem coe_add (p q : Seminorm ð E) : â(p + q) = p + q :=
rfl
@[simp]
theorem add_apply (p q : Seminorm ð E) (x : E) : (p + q) x = p x + q x :=
rfl
instance instAddMonoid : AddMonoid (Seminorm ð E) :=
DFunLike.coe_injective.addMonoid _ rfl coe_add fun _ _ => by rfl
instance instAddCommMonoid : AddCommMonoid (Seminorm ð E) :=
DFunLike.coe_injective.addCommMonoid _ rfl coe_add fun _ _ => by rfl
instance instPartialOrder : PartialOrder (Seminorm ð E) :=
PartialOrder.lift _ DFunLike.coe_injective
instance instIsOrderedCancelAddMonoid : IsOrderedCancelAddMonoid (Seminorm ð E) :=
DFunLike.coe_injective.isOrderedCancelAddMonoid _ rfl coe_add fun _ _ => rfl
instance instMulAction [Monoid R] [MulAction R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] :
MulAction R (Seminorm ð E) :=
DFunLike.coe_injective.mulAction _ (by intros; rfl)
variable (ð E)
/-- `coeFn` as an `AddMonoidHom`. Helper definition for showing that `Seminorm ð E` is a module. -/
@[simps]
def coeFnAddMonoidHom : AddMonoidHom (Seminorm ð E) (E â â) where
toFun := (â)
map_zero' := coe_zero
map_add' := coe_add
theorem coeFnAddMonoidHom_injective : Function.Injective (coeFnAddMonoidHom ð E) :=
show @Function.Injective (Seminorm ð E) (E â â) (â) from DFunLike.coe_injective
variable {ð E}
instance instDistribMulAction [Monoid R] [DistribMulAction R â] [SMul R ââ¥0]
[IsScalarTower R ââ¥0 â] : DistribMulAction R (Seminorm ð E) :=
(coeFnAddMonoidHom_injective ð E).distribMulAction _ (by intros; rfl)
instance instModule [Semiring R] [Module R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] :
Module R (Seminorm ð E) :=
(coeFnAddMonoidHom_injective ð E).module R _ (by intros; rfl)
instance instSup : Max (Seminorm ð E) where
max p q :=
{ p.toAddGroupSeminorm â q.toAddGroupSeminorm with
toFun := p â q
smul' := fun x v =>
(congr_argâ max (map_smul_eq_mul p x v) (map_smul_eq_mul q x v)).trans <|
(mul_max_of_nonneg _ _ <| norm_nonneg x).symm }
@[simp]
theorem coe_sup (p q : Seminorm ð E) : â(p â q) = (p : E â â) â (q : E â â) :=
rfl
theorem sup_apply (p q : Seminorm ð E) (x : E) : (p â q) x = p x â q x :=
rfl
theorem smul_sup [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] (r : R) (p q : Seminorm ð E) :
r ⢠(p â q) = r ⢠p â r ⢠q :=
have real.smul_max : â x y : â, r ⢠max x y = max (r ⢠x) (r ⢠y) := fun x y => by
simpa only [â smul_eq_mul, â NNReal.smul_def, smul_one_smul ââ¥0 r (_ : â)] using
mul_max_of_nonneg x y (r ⢠(1 : ââ¥0) : ââ¥0).coe_nonneg
ext fun _ => real.smul_max _ _
@[simp, norm_cast]
theorem coe_le_coe {p q : Seminorm ð E} : (p : E â â) †q â p †q :=
Iff.rfl
@[simp, norm_cast]
theorem coe_lt_coe {p q : Seminorm ð E} : (p : E â â) < q â p < q :=
Iff.rfl
theorem le_def {p q : Seminorm ð E} : p †q â â x, p x †q x :=
Iff.rfl
theorem lt_def {p q : Seminorm ð E} : p < q â p †q â§ â x, p x < q x :=
@Pi.lt_def _ _ _ p q
instance instSemilatticeSup : SemilatticeSup (Seminorm ð E) :=
Function.Injective.semilatticeSup _ DFunLike.coe_injective coe_sup
end SMul
end AddGroup
section Module
variable [SeminormedRing ðâ] [SeminormedRing ðâ]
variable {Ïââ : ð â+* ðâ} [RingHomIsometric Ïââ]
variable {Ïââ : ðâ â+* ðâ} [RingHomIsometric Ïââ]
variable {Ïââ : ð â+* ðâ} [RingHomIsometric Ïââ]
variable [AddCommGroup E] [AddCommGroup Eâ] [AddCommGroup Eâ]
variable [Module ð E] [Module ðâ Eâ] [Module ðâ Eâ]
variable [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â]
/-- Composition of a seminorm with a linear map is a seminorm. -/
def comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) : Seminorm ð E :=
{ p.toAddGroupSeminorm.comp f.toAddMonoidHom with
toFun := fun x => p (f x)
-- Porting note: the `simp only` below used to be part of the `rw`.
-- I'm not sure why this change was needed, and am worried by it!
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to change `map_smulââ` to `map_smulââ _`
smul' := fun _ _ => by simp only [map_smulââ _]; rw [map_smul_eq_mul, RingHomIsometric.is_iso] }
theorem coe_comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) : â(p.comp f) = p â f :=
rfl
@[simp]
theorem comp_apply (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (x : E) : (p.comp f) x = p (f x) :=
rfl
@[simp]
theorem comp_id (p : Seminorm ð E) : p.comp LinearMap.id = p :=
ext fun _ => rfl
@[simp]
theorem comp_zero (p : Seminorm ðâ Eâ) : p.comp (0 : E âââ[Ïââ] Eâ) = 0 :=
ext fun _ => map_zero p
@[simp]
theorem zero_comp (f : E âââ[Ïââ] Eâ) : (0 : Seminorm ðâ Eâ).comp f = 0 :=
ext fun _ => rfl
theorem comp_comp [RingHomCompTriple Ïââ Ïââ Ïââ] (p : Seminorm ðâ Eâ) (g : Eâ âââ[Ïââ] Eâ)
(f : E âââ[Ïââ] Eâ) : p.comp (g.comp f) = (p.comp g).comp f :=
ext fun _ => rfl
theorem add_comp (p q : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) :
(p + q).comp f = p.comp f + q.comp f :=
ext fun _ => rfl
theorem comp_add_le (p : Seminorm ðâ Eâ) (f g : E âââ[Ïââ] Eâ) :
p.comp (f + g) †p.comp f + p.comp g := fun _ => map_add_le_add p _ _
theorem smul_comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (c : R) :
(c ⢠p).comp f = c ⢠p.comp f :=
ext fun _ => rfl
theorem comp_mono {p q : Seminorm ðâ Eâ} (f : E âââ[Ïââ] Eâ) (hp : p †q) : p.comp f †q.comp f :=
fun _ => hp _
/-- The composition as an `AddMonoidHom`. -/
@[simps]
def pullback (f : E âââ[Ïââ] Eâ) : Seminorm ðâ Eâ â+ Seminorm ð E where
toFun := fun p => p.comp f
map_zero' := zero_comp f
map_add' := fun p q => add_comp p q f
instance instOrderBot : OrderBot (Seminorm ð E) where
bot := 0
bot_le := apply_nonneg
@[simp]
theorem coe_bot : â(⥠: Seminorm ð E) = 0 :=
rfl
theorem bot_eq_zero : (⥠: Seminorm ð E) = 0 :=
rfl
theorem smul_le_smul {p q : Seminorm ð E} {a b : ââ¥0} (hpq : p †q) (hab : a †b) :
a ⢠p †b ⢠q := by
simp_rw [le_def]
intro x
exact mul_le_mul hab (hpq x) (apply_nonneg p x) (NNReal.coe_nonneg b)
theorem finset_sup_apply (p : ι â Seminorm ð E) (s : Finset ι) (x : E) :
s.sup p x = â(s.sup fun i => âšp i x, apply_nonneg (p i) xâ© : ââ¥0) := by
induction' s using Finset.cons_induction_on with a s ha ih
· rw [Finset.sup_empty, Finset.sup_empty, coe_bot, _root_.bot_eq_zero, Pi.zero_apply]
norm_cast
· rw [Finset.sup_cons, Finset.sup_cons, coe_sup, Pi.sup_apply, NNReal.coe_max, NNReal.coe_mk, ih]
theorem exists_apply_eq_finset_sup (p : ι â Seminorm ð E) {s : Finset ι} (hs : s.Nonempty) (x : E) :
â i â s, s.sup p x = p i x := by
rcases Finset.exists_mem_eq_sup s hs (fun i ⊠(âšp i x, apply_nonneg _ _â© : ââ¥0)) with âši, hi, hixâ©
rw [finset_sup_apply]
exact âši, hi, congr_arg _ hixâ©
theorem zero_or_exists_apply_eq_finset_sup (p : ι â Seminorm ð E) (s : Finset ι) (x : E) :
s.sup p x = 0 âš â i â s, s.sup p x = p i x := by
rcases Finset.eq_empty_or_nonempty s with (rfl|hs)
· left; rfl
· right; exact exists_apply_eq_finset_sup p hs x
theorem finset_sup_smul (p : ι â Seminorm ð E) (s : Finset ι) (C : ââ¥0) :
s.sup (C ⢠p) = C ⢠s.sup p := by
ext x
rw [smul_apply, finset_sup_apply, finset_sup_apply]
symm
exact congr_arg ((â) : ââ¥0 â â) (NNReal.mul_finset_sup C s (fun i ⊠âšp i x, apply_nonneg _ _â©))
theorem finset_sup_le_sum (p : ι â Seminorm ð E) (s : Finset ι) : s.sup p †â i â s, p i := by
classical
refine Finset.sup_le_iff.mpr ?_
intro i hi
rw [Finset.sum_eq_sum_diff_singleton_add hi, le_add_iff_nonneg_left]
exact bot_le
theorem finset_sup_apply_le {p : ι â Seminorm ð E} {s : Finset ι} {x : E} {a : â} (ha : 0 †a)
(h : â i, i â s â p i x †a) : s.sup p x †a := by
lift a to ââ¥0 using ha
rw [finset_sup_apply, NNReal.coe_le_coe]
exact Finset.sup_le h
theorem le_finset_sup_apply {p : ι â Seminorm ð E} {s : Finset ι} {x : E} {i : ι}
(hi : i â s) : p i x †s.sup p x :=
(Finset.le_sup hi : p i †s.sup p) x
theorem finset_sup_apply_lt {p : ι â Seminorm ð E} {s : Finset ι} {x : E} {a : â} (ha : 0 < a)
(h : â i, i â s â p i x < a) : s.sup p x < a := by
lift a to ââ¥0 using ha.le
rw [finset_sup_apply, NNReal.coe_lt_coe, Finset.sup_lt_iff]
· exact h
· exact NNReal.coe_pos.mpr ha
theorem norm_sub_map_le_sub (p : Seminorm ð E) (x y : E) : âp x - p yâ †p (x - y) :=
abs_sub_map_le_sub p x y
end Module
end SeminormedRing
section SeminormedCommRing
variable [SeminormedRing ð] [SeminormedCommRing ðâ]
variable {Ïââ : ð â+* ðâ} [RingHomIsometric Ïââ]
variable [AddCommGroup E] [AddCommGroup Eâ] [Module ð E] [Module ðâ Eâ]
theorem comp_smul (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (c : ðâ) :
p.comp (c ⢠f) = âcââ ⢠p.comp f :=
ext fun _ => by
rw [comp_apply, smul_apply, LinearMap.smul_apply, map_smul_eq_mul, NNReal.smul_def, coe_nnnorm,
smul_eq_mul, comp_apply]
theorem comp_smul_apply (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (c : ðâ) (x : E) :
p.comp (c ⢠f) x = âcâ * p (f x) :=
map_smul_eq_mul p _ _
end SeminormedCommRing
section NormedField
variable [NormedField ð] [AddCommGroup E] [Module ð E] {p q : Seminorm ð E} {x : E}
/-- Auxiliary lemma to show that the infimum of seminorms is well-defined. -/
theorem bddBelow_range_add : BddBelow (range fun u => p u + q (x - u)) :=
âš0, by
rintro _ âšx, rflâ©
dsimp; positivityâ©
noncomputable instance instInf : Min (Seminorm ð E) where
min p q :=
{ p.toAddGroupSeminorm â q.toAddGroupSeminorm with
toFun := fun x => âš
u : E, p u + q (x - u)
smul' := by
intro a x
obtain rfl | ha := eq_or_ne a 0
· rw [norm_zero, zero_mul, zero_smul]
refine
ciInf_eq_of_forall_ge_of_forall_gt_exists_lt
(fun i => by positivity)
fun x hx => âš0, by rwa [map_zero, sub_zero, map_zero, add_zero]â©
simp_rw [Real.mul_iInf_of_nonneg (norm_nonneg a), mul_add, â map_smul_eq_mul p, â
map_smul_eq_mul q, smul_sub]
refine
Function.Surjective.iInf_congr ((aâ»Â¹ ⢠·) : E â E)
(fun u => âša ⢠u, inv_smul_smulâ ha uâ©) fun u => ?_
rw [smul_inv_smulâ ha] }
@[simp]
theorem inf_apply (p q : Seminorm ð E) (x : E) : (p â q) x = âš
u : E, p u + q (x - u) :=
rfl
noncomputable instance instLattice : Lattice (Seminorm ð E) :=
{ Seminorm.instSemilatticeSup with
inf := (· â ·)
inf_le_left := fun p q x =>
ciInf_le_of_le bddBelow_range_add x <| by
simp only [sub_self, map_zero, add_zero]; rfl
inf_le_right := fun p q x =>
ciInf_le_of_le bddBelow_range_add 0 <| by
simp only [sub_self, map_zero, zero_add, sub_zero]; rfl
le_inf := fun a _ _ hab hac _ =>
le_ciInf fun _ => (le_map_add_map_sub a _ _).trans <| add_le_add (hab _) (hac _) }
theorem smul_inf [SMul R â] [SMul R ââ¥0] [IsScalarTower R ââ¥0 â] (r : R) (p q : Seminorm ð E) :
r ⢠(p â q) = r ⢠p â r ⢠q := by
ext
simp_rw [smul_apply, inf_apply, smul_apply, â smul_one_smul ââ¥0 r (_ : â), NNReal.smul_def,
smul_eq_mul, Real.mul_iInf_of_nonneg (NNReal.coe_nonneg _), mul_add]
section Classical
open Classical in
/-- We define the supremum of an arbitrary subset of `Seminorm ð E` as follows:
* if `s` is `BddAbove` *as a set of functions `E â â`* (that is, if `s` is pointwise bounded
above), we take the pointwise supremum of all elements of `s`, and we prove that it is indeed a
seminorm.
* otherwise, we take the zero seminorm `â¥`.
There are two things worth mentioning here:
* First, it is not trivial at first that `s` being bounded above *by a function* implies
being bounded above *as a seminorm*. We show this in `Seminorm.bddAbove_iff` by using
that the `Sup s` as defined here is then a bounding seminorm for `s`. So it is important to make
the case disjunction on `BddAbove ((â) '' s : Set (E â â))` and not `BddAbove s`.
* Since the pointwise `Sup` already gives `0` at points where a family of functions is
not bounded above, one could hope that just using the pointwise `Sup` would work here, without the
need for an additional case disjunction. As discussed on Zulip, this doesn't work because this can
give a function which does *not* satisfy the seminorm axioms (typically sub-additivity).
-/
noncomputable instance instSupSet : SupSet (Seminorm ð E) where
sSup s :=
if h : BddAbove ((â) '' s : Set (E â â)) then
{ toFun := âš p : s, ((p : Seminorm ð E) : E â â)
map_zero' := by
rw [iSup_apply, â @Real.iSup_const_zero s]
congr!
rename_i _ _ _ i
exact map_zero i.1
add_le' := fun x y => by
rcases h with âšq, hqâ©
obtain rfl | h := s.eq_empty_or_nonempty
· simp [Real.iSup_of_isEmpty]
haveI : Nonempty âs := h.coe_sort
simp only [iSup_apply]
refine ciSup_le fun i =>
((i : Seminorm ð E).add_le' x y).trans <| add_le_add
-- Porting note: `f` is provided to force `Subtype.val` to appear.
-- A type ascription on `_` would have also worked, but would have been more verbose.
(le_ciSup (f := fun i => (Subtype.val i : Seminorm ð E).toFun x) âšq x, ?_â© i)
(le_ciSup (f := fun i => (Subtype.val i : Seminorm ð E).toFun y) âšq y, ?_â© i)
<;> rw [mem_upperBounds, forall_mem_range]
<;> exact fun j => hq (mem_image_of_mem _ j.2) _
neg' := fun x => by
simp only [iSup_apply]
congr! 2
rename_i _ _ _ i
exact i.1.neg' _
smul' := fun a x => by
simp only [iSup_apply]
rw [â smul_eq_mul,
Real.smul_iSup_of_nonneg (norm_nonneg a) fun i : s => (i : Seminorm ð E) x]
congr!
rename_i _ _ _ i
exact i.1.smul' a x }
else â¥
protected theorem coe_sSup_eq' {s : Set <| Seminorm ð E}
(hs : BddAbove ((â) '' s : Set (E â â))) : â(sSup s) = âš p : s, ((p : Seminorm ð E) : E â â) :=
congr_arg _ (dif_pos hs)
protected theorem bddAbove_iff {s : Set <| Seminorm ð E} :
BddAbove s â BddAbove ((â) '' s : Set (E â â)) :=
âšfun âšq, hqâ© => âšq, forall_mem_image.2 fun _ hp => hq hpâ©, fun H =>
âšsSup s, fun p hp x => by
dsimp
rw [Seminorm.coe_sSup_eq' H, iSup_apply]
rcases H with âšq, hqâ©
exact
le_ciSup âšq x, forall_mem_range.mpr fun i : s => hq (mem_image_of_mem _ i.2) xâ© âšp, hpâ©â©â©
protected theorem bddAbove_range_iff {ι : Sort*} {p : ι â Seminorm ð E} :
BddAbove (range p) â â x, BddAbove (range fun i ⊠p i x) := by
rw [Seminorm.bddAbove_iff, â range_comp, bddAbove_range_pi]; rfl
protected theorem coe_sSup_eq {s : Set <| Seminorm ð E} (hs : BddAbove s) :
â(sSup s) = âš p : s, ((p : Seminorm ð E) : E â â) :=
Seminorm.coe_sSup_eq' (Seminorm.bddAbove_iff.mp hs)
protected theorem coe_iSup_eq {ι : Sort*} {p : ι â Seminorm ð E} (hp : BddAbove (range p)) :
â(âš i, p i) = âš i, ((p i : Seminorm ð E) : E â â) := by
rw [â sSup_range, Seminorm.coe_sSup_eq hp]
exact iSup_range' (fun p : Seminorm ð E => (p : E â â)) p
protected theorem sSup_apply {s : Set (Seminorm ð E)} (hp : BddAbove s) {x : E} :
(sSup s) x = âš p : s, (p : E â â) x := by
rw [Seminorm.coe_sSup_eq hp, iSup_apply]
protected theorem iSup_apply {ι : Sort*} {p : ι â Seminorm ð E}
(hp : BddAbove (range p)) {x : E} : (âš i, p i) x = âš i, p i x := by
rw [Seminorm.coe_iSup_eq hp, iSup_apply]
protected theorem sSup_empty : sSup (â
: Set (Seminorm ð E)) = ⥠:= by
ext
rw [Seminorm.sSup_apply bddAbove_empty, Real.iSup_of_isEmpty]
rfl
private theorem isLUB_sSup (s : Set (Seminorm ð E)) (hsâ : BddAbove s) (hsâ : s.Nonempty) :
IsLUB s (sSup s) := by
refine âšfun p hp x => ?_, fun p hp x => ?_â© <;> haveI : Nonempty âs := hsâ.coe_sort <;>
dsimp <;> rw [Seminorm.coe_sSup_eq hsâ, iSup_apply]
· rcases hsâ with âšq, hqâ©
exact le_ciSup âšq x, forall_mem_range.mpr fun i : s => hq i.2 xâ© âšp, hpâ©
· exact ciSup_le fun q => hp q.2 x
/-- `Seminorm ð E` is a conditionally complete lattice.
Note that, while `inf`, `sup` and `sSup` have good definitional properties (corresponding to
the instances given here for `Inf`, `Sup` and `SupSet` respectively), `sInf s` is just
defined as the supremum of the lower bounds of `s`, which is not really useful in practice. If you
need to use `sInf` on seminorms, then you should probably provide a more workable definition first,
but this is unlikely to happen so we keep the "bad" definition for now. -/
noncomputable instance instConditionallyCompleteLattice :
ConditionallyCompleteLattice (Seminorm ð E) :=
conditionallyCompleteLatticeOfLatticeOfsSup (Seminorm ð E) Seminorm.isLUB_sSup
end Classical
end NormedField
/-! ### Seminorm ball -/
section SeminormedRing
variable [SeminormedRing ð]
section AddCommGroup
variable [AddCommGroup E]
section SMul
variable [SMul ð E] (p : Seminorm ð E)
/-- The ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y` with
`p (y - x) < r`. -/
def ball (x : E) (r : â) :=
{ y : E | p (y - x) < r }
/-- The closed ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y`
with `p (y - x) †r`. -/
def closedBall (x : E) (r : â) :=
{ y : E | p (y - x) †r }
variable {x y : E} {r : â}
@[simp]
theorem mem_ball : y â ball p x r â p (y - x) < r :=
Iff.rfl
@[simp]
theorem mem_closedBall : y â closedBall p x r â p (y - x) †r :=
Iff.rfl
theorem mem_ball_self (hr : 0 < r) : x â ball p x r := by simp [hr]
theorem mem_closedBall_self (hr : 0 †r) : x â closedBall p x r := by simp [hr]
theorem mem_ball_zero : y â ball p 0 r â p y < r := by rw [mem_ball, sub_zero]
theorem mem_closedBall_zero : y â closedBall p 0 r â p y †r := by rw [mem_closedBall, sub_zero]
theorem ball_zero_eq : ball p 0 r = { y : E | p y < r } :=
Set.ext fun _ => p.mem_ball_zero
theorem closedBall_zero_eq : closedBall p 0 r = { y : E | p y †r } :=
Set.ext fun _ => p.mem_closedBall_zero
theorem ball_subset_closedBall (x r) : ball p x r â closedBall p x r := fun _ h =>
(mem_closedBall _).mpr ((mem_ball _).mp h).le
theorem closedBall_eq_biInter_ball (x r) : closedBall p x r = â Ï > r, ball p x Ï := by
ext y; simp_rw [mem_closedBall, mem_iInterâ, mem_ball, â forall_lt_iff_le']
@[simp]
theorem ball_zero' (x : E) (hr : 0 < r) : ball (0 : Seminorm ð E) x r = Set.univ := by
rw [Set.eq_univ_iff_forall, ball]
simp [hr]
@[simp]
theorem closedBall_zero' (x : E) (hr : 0 < r) : closedBall (0 : Seminorm ð E) x r = Set.univ :=
eq_univ_of_subset (ball_subset_closedBall _ _ _) (ball_zero' x hr)
theorem ball_smul (p : Seminorm ð E) {c : NNReal} (hc : 0 < c) (r : â) (x : E) :
(c ⢠p).ball x r = p.ball x (r / c) := by
ext
rw [mem_ball, mem_ball, smul_apply, NNReal.smul_def, smul_eq_mul, mul_comm,
lt_div_iffâ (NNReal.coe_pos.mpr hc)]
theorem closedBall_smul (p : Seminorm ð E) {c : NNReal} (hc : 0 < c) (r : â) (x : E) :
(c ⢠p).closedBall x r = p.closedBall x (r / c) := by
ext
rw [mem_closedBall, mem_closedBall, smul_apply, NNReal.smul_def, smul_eq_mul, mul_comm,
le_div_iffâ (NNReal.coe_pos.mpr hc)]
theorem ball_sup (p : Seminorm ð E) (q : Seminorm ð E) (e : E) (r : â) :
ball (p â q) e r = ball p e r â© ball q e r := by
simp_rw [ball, â Set.setOf_and, coe_sup, Pi.sup_apply, sup_lt_iff]
theorem closedBall_sup (p : Seminorm ð E) (q : Seminorm ð E) (e : E) (r : â) :
closedBall (p â q) e r = closedBall p e r â© closedBall q e r := by
simp_rw [closedBall, â Set.setOf_and, coe_sup, Pi.sup_apply, sup_le_iff]
theorem ball_finset_sup' (p : ι â Seminorm ð E) (s : Finset ι) (H : s.Nonempty) (e : E) (r : â) :
ball (s.sup' H p) e r = s.inf' H fun i => ball (p i) e r := by
induction H using Finset.Nonempty.cons_induction with
| singleton => simp
| cons _ _ _ hs ih =>
rw [Finset.sup'_cons hs, Finset.inf'_cons hs, ball_sup]
-- Porting note: `rw` can't use `inf_eq_inter` here, but `simp` can?
simp only [inf_eq_inter, ih]
theorem closedBall_finset_sup' (p : ι â Seminorm ð E) (s : Finset ι) (H : s.Nonempty) (e : E)
(r : â) : closedBall (s.sup' H p) e r = s.inf' H fun i => closedBall (p i) e r := by
induction H using Finset.Nonempty.cons_induction with
| singleton => simp
| cons _ _ _ hs ih =>
rw [Finset.sup'_cons hs, Finset.inf'_cons hs, closedBall_sup]
-- Porting note: `rw` can't use `inf_eq_inter` here, but `simp` can?
simp only [inf_eq_inter, ih]
theorem ball_mono {p : Seminorm ð E} {râ râ : â} (h : râ †râ) : p.ball x râ â p.ball x râ :=
fun _ (hx : _ < _) => hx.trans_le h
theorem closedBall_mono {p : Seminorm ð E} {râ râ : â} (h : râ †râ) :
p.closedBall x râ â p.closedBall x râ := fun _ (hx : _ †_) => hx.trans h
theorem ball_antitone {p q : Seminorm ð E} (h : q †p) : p.ball x r â q.ball x r := fun _ =>
(h _).trans_lt
theorem closedBall_antitone {p q : Seminorm ð E} (h : q †p) :
p.closedBall x r â q.closedBall x r := fun _ => (h _).trans
theorem ball_add_ball_subset (p : Seminorm ð E) (râ râ : â) (xâ xâ : E) :
p.ball (xâ : E) râ + p.ball (xâ : E) râ â p.ball (xâ + xâ) (râ + râ) := by
rintro x âšyâ, hyâ, yâ, hyâ, rflâ©
rw [mem_ball, add_sub_add_comm]
exact (map_add_le_add p _ _).trans_lt (add_lt_add hyâ hyâ)
theorem closedBall_add_closedBall_subset (p : Seminorm ð E) (râ râ : â) (xâ xâ : E) :
p.closedBall (xâ : E) râ + p.closedBall (xâ : E) râ â p.closedBall (xâ + xâ) (râ + râ) := by
rintro x âšyâ, hyâ, yâ, hyâ, rflâ©
rw [mem_closedBall, add_sub_add_comm]
exact (map_add_le_add p _ _).trans (add_le_add hyâ hyâ)
theorem sub_mem_ball (p : Seminorm ð E) (xâ xâ y : E) (r : â) :
xâ - xâ â p.ball y r â xâ â p.ball (xâ + y) r := by simp_rw [mem_ball, sub_sub]
theorem sub_mem_closedBall (p : Seminorm ð E) (xâ xâ y : E) (r : â) :
xâ - xâ â p.closedBall y r â xâ â p.closedBall (xâ + y) r := by
simp_rw [mem_closedBall, sub_sub]
/-- The image of a ball under addition with a singleton is another ball. -/
theorem vadd_ball (p : Seminorm ð E) : x +áµ¥ p.ball y r = p.ball (x +áµ¥ y) r :=
letI := AddGroupSeminorm.toSeminormedAddCommGroup p.toAddGroupSeminorm
Metric.vadd_ball x y r
/-- The image of a closed ball under addition with a singleton is another closed ball. -/
theorem vadd_closedBall (p : Seminorm ð E) : x +áµ¥ p.closedBall y r = p.closedBall (x +áµ¥ y) r :=
letI := AddGroupSeminorm.toSeminormedAddCommGroup p.toAddGroupSeminorm
Metric.vadd_closedBall x y r
end SMul
section Module
variable [Module ð E]
variable [SeminormedRing ðâ] [AddCommGroup Eâ] [Module ðâ Eâ]
variable {Ïââ : ð â+* ðâ} [RingHomIsometric Ïââ]
theorem ball_comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (x : E) (r : â) :
(p.comp f).ball x r = f â»Â¹' p.ball (f x) r := by
ext
simp_rw [ball, mem_preimage, comp_apply, Set.mem_setOf_eq, map_sub]
theorem closedBall_comp (p : Seminorm ðâ Eâ) (f : E âââ[Ïââ] Eâ) (x : E) (r : â) :
(p.comp f).closedBall x r = f â»Â¹' p.closedBall (f x) r := by
ext
simp_rw [closedBall, mem_preimage, comp_apply, Set.mem_setOf_eq, map_sub]
variable (p : Seminorm ð E)
theorem preimage_metric_ball {r : â} : p â»Â¹' Metric.ball 0 r = { x | p x < r } := by
ext x
simp only [mem_setOf, mem_preimage, mem_ball_zero_iff, Real.norm_of_nonneg (apply_nonneg p _)]
theorem preimage_metric_closedBall {r : â} : p â»Â¹' Metric.closedBall 0 r = { x | p x †r } := by
ext x
simp only [mem_setOf, mem_preimage, mem_closedBall_zero_iff,
Real.norm_of_nonneg (apply_nonneg p _)]
theorem ball_zero_eq_preimage_ball {r : â} : p.ball 0 r = p â»Â¹' Metric.ball 0 r := by
rw [ball_zero_eq, preimage_metric_ball]
theorem closedBall_zero_eq_preimage_closedBall {r : â} :
p.closedBall 0 r = p â»Â¹' Metric.closedBall 0 r := by
rw [closedBall_zero_eq, preimage_metric_closedBall]
@[simp]
theorem ball_bot {r : â} (x : E) (hr : 0 < r) : ball (⥠: Seminorm ð E) x r = Set.univ :=
ball_zero' x hr
@[simp]
theorem closedBall_bot {r : â} (x : E) (hr : 0 < r) :
closedBall (⥠: Seminorm ð E) x r = Set.univ :=
closedBall_zero' x hr
/-- Seminorm-balls at the origin are balanced. -/
theorem balanced_ball_zero (r : â) : Balanced ð (ball p 0 r) := by
rintro a ha x âšy, hy, hxâ©
rw [mem_ball_zero, â hx, map_smul_eq_mul]
calc
_ †p y := mul_le_of_le_one_left (apply_nonneg p _) ha
_ < r := by rwa [mem_ball_zero] at hy
/-- Closed seminorm-balls at the origin are balanced. -/
theorem balanced_closedBall_zero (r : â) : Balanced ð (closedBall p 0 r) := by
rintro a ha x âšy, hy, hxâ©
rw [mem_closedBall_zero, â hx, map_smul_eq_mul]
calc
_ †p y := mul_le_of_le_one_left (apply_nonneg p _) ha
_ †r := by rwa [mem_closedBall_zero] at hy
theorem ball_finset_sup_eq_iInter (p : ι â Seminorm ð E) (s : Finset ι) (x : E) {r : â}
(hr : 0 < r) : ball (s.sup p) x r = â i â s, ball (p i) x r := by
lift r to NNReal using hr.le
simp_rw [ball, iInter_setOf, finset_sup_apply, NNReal.coe_lt_coe,
Finset.sup_lt_iff (show ⥠< r from hr), â NNReal.coe_lt_coe, NNReal.coe_mk]
theorem closedBall_finset_sup_eq_iInter (p : ι â Seminorm ð E) (s : Finset ι) (x : E) {r : â}
(hr : 0 †r) : closedBall (s.sup p) x r = â i â s, closedBall (p i) x r := by
lift r to NNReal using hr
simp_rw [closedBall, iInter_setOf, finset_sup_apply, NNReal.coe_le_coe, Finset.sup_le_iff, â
NNReal.coe_le_coe, NNReal.coe_mk]
theorem ball_finset_sup (p : ι â Seminorm ð E) (s : Finset ι) (x : E) {r : â} (hr : 0 < r) :
ball (s.sup p) x r = s.inf fun i => ball (p i) x r := by
rw [Finset.inf_eq_iInf]
exact ball_finset_sup_eq_iInter _ _ _ hr
theorem closedBall_finset_sup (p : ι â Seminorm ð E) (s : Finset ι) (x : E) {r : â} (hr : 0 †r) :
closedBall (s.sup p) x r = s.inf fun i => closedBall (p i) x r := by
rw [Finset.inf_eq_iInf]
exact closedBall_finset_sup_eq_iInter _ _ _ hr
@[simp]
theorem ball_eq_emptyset (p : Seminorm ð E) {x : E} {r : â} (hr : r †0) : p.ball x r = â
:= by
ext
rw [Seminorm.mem_ball, Set.mem_empty_iff_false, iff_false, not_lt]
exact hr.trans (apply_nonneg p _)
@[simp]
theorem closedBall_eq_emptyset (p : Seminorm ð E) {x : E} {r : â} (hr : r < 0) :
p.closedBall x r = â
:= by
ext
rw [Seminorm.mem_closedBall, Set.mem_empty_iff_false, iff_false, not_le]
exact hr.trans_le (apply_nonneg _ _)
theorem closedBall_smul_ball (p : Seminorm ð E) {râ : â} (hrâ : râ â 0) (râ : â) :
Metric.closedBall (0 : ð) râ ⢠p.ball 0 râ â p.ball 0 (râ * râ) := by
simp only [smul_subset_iff, mem_ball_zero, mem_closedBall_zero_iff, map_smul_eq_mul]
refine fun a ha b hb ⊠mul_lt_mul' ha hb (apply_nonneg _ _) ?_
exact hrâ.lt_or_lt.resolve_left <| ((norm_nonneg a).trans ha).not_lt
theorem ball_smul_closedBall (p : Seminorm ð E) (râ : â) {râ : â} (hrâ : râ â 0) :
Metric.ball (0 : ð) râ ⢠p.closedBall 0 râ â p.ball 0 (râ * râ) := by
simp only [smul_subset_iff, mem_ball_zero, mem_closedBall_zero, mem_ball_zero_iff,
map_smul_eq_mul]
intro a ha b hb
rw [mul_comm, mul_comm râ]
refine mul_lt_mul' hb ha (norm_nonneg _) (hrâ.lt_or_lt.resolve_left ?_)
exact ((apply_nonneg p b).trans hb).not_lt
theorem ball_smul_ball (p : Seminorm ð E) (râ râ : â) :
Metric.ball (0 : ð) râ ⢠p.ball 0 râ â p.ball 0 (râ * râ) := by
rcases eq_or_ne râ 0 with rfl | hrâ
· simp
· exact (smul_subset_smul_left (ball_subset_closedBall _ _ _)).trans
(ball_smul_closedBall _ _ hrâ)
theorem closedBall_smul_closedBall (p : Seminorm ð E) (râ râ : â) :
Metric.closedBall (0 : ð) râ ⢠p.closedBall 0 râ â p.closedBall 0 (râ * râ) := by
simp only [smul_subset_iff, mem_closedBall_zero, mem_closedBall_zero_iff, map_smul_eq_mul]
intro a ha b hb
gcongr
exact (norm_nonneg _).trans ha
theorem neg_mem_ball_zero {r : â} {x : E} : -x â ball p 0 r â x â ball p 0 r := by
simp only [mem_ball_zero, map_neg_eq_map]
theorem neg_mem_closedBall_zero {r : â} {x : E} : -x â closedBall p 0 r â x â closedBall p 0 r := by
simp only [mem_closedBall_zero, map_neg_eq_map]
@[simp]
theorem neg_ball (p : Seminorm ð E) (r : â) (x : E) : -ball p x r = ball p (-x) r := by
ext
rw [Set.mem_neg, mem_ball, mem_ball, â neg_add', sub_neg_eq_add, map_neg_eq_map]
@[simp]
theorem neg_closedBall (p : Seminorm ð E) (r : â) (x : E) :
-closedBall p x r = closedBall p (-x) r := by
ext
rw [Set.mem_neg, mem_closedBall, mem_closedBall, â neg_add', sub_neg_eq_add, map_neg_eq_map]
end Module
end AddCommGroup
end SeminormedRing
section NormedField
variable [NormedField ð] [AddCommGroup E] [Module ð E] (p : Seminorm ð E) {r : â} {x : E}
theorem closedBall_iSup {ι : Sort*} {p : ι â Seminorm ð E} (hp : BddAbove (range p)) (e : E)
{r : â} (hr : 0 < r) : closedBall (âš i, p i) e r = â i, closedBall (p i) e r := by
cases isEmpty_or_nonempty ι
· rw [iSup_of_empty', iInter_of_empty, Seminorm.sSup_empty]
exact closedBall_bot _ hr
· ext x
have := Seminorm.bddAbove_range_iff.mp hp (x - e)
simp only [mem_closedBall, mem_iInter, Seminorm.iSup_apply hp, ciSup_le_iff this]
theorem ball_norm_mul_subset {p : Seminorm ð E} {k : ð} {r : â} :
p.ball 0 (âkâ * r) â k ⢠p.ball 0 r := by
rcases eq_or_ne k 0 with (rfl | hk)
· rw [norm_zero, zero_mul, ball_eq_emptyset _ le_rfl]
exact empty_subset _
· intro x
rw [Set.mem_smul_set, Seminorm.mem_ball_zero]
refine fun hx => âškâ»Â¹ ⢠x, ?_, ?_â©
· rwa [Seminorm.mem_ball_zero, map_smul_eq_mul, norm_inv, â
mul_lt_mul_left <| norm_pos_iff.mpr hk, â mul_assoc, â div_eq_mul_inv âkâ âkâ,
div_self (ne_of_gt <| norm_pos_iff.mpr hk), one_mul]
rw [â smul_assoc, smul_eq_mul, â div_eq_mul_inv, div_self hk, one_smul]
theorem smul_ball_zero {p : Seminorm ð E} {k : ð} {r : â} (hk : k â 0) :
k ⢠p.ball 0 r = p.ball 0 (âkâ * r) := by
ext
rw [mem_smul_set_iff_inv_smul_memâ hk, p.mem_ball_zero, p.mem_ball_zero, map_smul_eq_mul,
norm_inv, â div_eq_inv_mul, div_lt_iffâ (norm_pos_iff.2 hk), mul_comm]
theorem smul_closedBall_subset {p : Seminorm ð E} {k : ð} {r : â} :
k ⢠p.closedBall 0 r â p.closedBall 0 (âkâ * r) := by
rintro x âšy, hy, hâ©
rw [Seminorm.mem_closedBall_zero, â h, map_smul_eq_mul]
rw [Seminorm.mem_closedBall_zero] at hy
gcongr
theorem smul_closedBall_zero {p : Seminorm ð E} {k : ð} {r : â} (hk : 0 < âkâ) :
k ⢠p.closedBall 0 r = p.closedBall 0 (âkâ * r) := by
refine subset_antisymm smul_closedBall_subset ?_
intro x
rw [Set.mem_smul_set, Seminorm.mem_closedBall_zero]
refine fun hx => âškâ»Â¹ ⢠x, ?_, ?_â©
· rwa [Seminorm.mem_closedBall_zero, map_smul_eq_mul, norm_inv, â mul_le_mul_left hk, â mul_assoc,
â div_eq_mul_inv âkâ âkâ, div_self (ne_of_gt hk), one_mul]
rw [â smul_assoc, smul_eq_mul, â div_eq_mul_inv, div_self (norm_pos_iff.mp hk), one_smul]
theorem ball_zero_absorbs_ball_zero (p : Seminorm ð E) {râ râ : â} (hrâ : 0 < râ) :
Absorbs ð (p.ball 0 râ) (p.ball 0 râ) := by
rcases exists_pos_lt_mul hrâ râ with âšr, hrâ, hrâ©
refine .of_norm âšr, fun a ha x hx => ?_â©
rw [smul_ball_zero (norm_pos_iff.1 <| hrâ.trans_le ha), p.mem_ball_zero]
rw [p.mem_ball_zero] at hx
exact hx.trans (hr.trans_le <| by gcongr)
/-- Seminorm-balls at the origin are absorbent. -/
protected theorem absorbent_ball_zero (hr : 0 < r) : Absorbent ð (ball p (0 : E) r) :=
absorbent_iff_forall_absorbs_singleton.2 fun _ =>
(p.ball_zero_absorbs_ball_zero hr).mono_right <|
singleton_subset_iff.2 <| p.mem_ball_zero.2 <| lt_add_one _
/-- Closed seminorm-balls at the origin are absorbent. -/
protected theorem absorbent_closedBall_zero (hr : 0 < r) : Absorbent ð (closedBall p (0 : E) r) :=
(p.absorbent_ball_zero hr).mono (p.ball_subset_closedBall _ _)
/-- Seminorm-balls containing the origin are absorbent. -/
protected theorem absorbent_ball (hpr : p x < r) : Absorbent ð (ball p x r) := by
refine (p.absorbent_ball_zero <| sub_pos.2 hpr).mono fun y hy => ?_
rw [p.mem_ball_zero] at hy
exact p.mem_ball.2 ((map_sub_le_add p _ _).trans_lt <| add_lt_of_lt_sub_right hy)
/-- Seminorm-balls containing the origin are absorbent. -/
protected theorem absorbent_closedBall (hpr : p x < r) : Absorbent ð (closedBall p x r) := by
refine (p.absorbent_closedBall_zero <| sub_pos.2 hpr).mono fun y hy => ?_
rw [p.mem_closedBall_zero] at hy
exact p.mem_closedBall.2 ((map_sub_le_add p _ _).trans <| add_le_of_le_sub_right hy)
@[simp]
theorem smul_ball_preimage (p : Seminorm ð E) (y : E) (r : â) (a : ð) (ha : a â 0) :
(a ⢠·) â»Â¹' p.ball y r = p.ball (aâ»Â¹ ⢠y) (r / âaâ) :=
Set.ext fun _ => by
rw [mem_preimage, mem_ball, mem_ball, lt_div_iffâ (norm_pos_iff.mpr ha), mul_comm, â
map_smul_eq_mul p, smul_sub, smul_inv_smulâ ha]
@[simp]
theorem smul_closedBall_preimage (p : Seminorm ð E) (y : E) (r : â) (a : ð) (ha : a â 0) :
(a ⢠·) â»Â¹' p.closedBall y r = p.closedBall (aâ»Â¹ ⢠y) (r / âaâ) :=
Set.ext fun _ => by
rw [mem_preimage, mem_closedBall, mem_closedBall, le_div_iffâ (norm_pos_iff.mpr ha), mul_comm, â
map_smul_eq_mul p, smul_sub, smul_inv_smulâ ha]
end NormedField
section Convex
variable [NormedField ð] [AddCommGroup E] [NormedSpace â ð] [Module ð E]
section SMul
variable [SMul â E] [IsScalarTower â ð E] (p : Seminorm ð E)
/-- A seminorm is convex. Also see `convexOn_norm`. -/
protected theorem convexOn : ConvexOn â univ p := by
refine âšconvex_univ, fun x _ y _ a b ha hb _ => ?_â©
calc
p (a ⢠x + b ⢠y) †p (a ⢠x) + p (b ⢠y) := map_add_le_add p _ _
_ = âa ⢠(1 : ð)â * p x + âb ⢠(1 : ð)â * p y := by
rw [â map_smul_eq_mul p, â map_smul_eq_mul p, smul_one_smul, smul_one_smul]
_ = a * p x + b * p y := by
rw [norm_smul, norm_smul, norm_one, mul_one, mul_one, Real.norm_of_nonneg ha,
Real.norm_of_nonneg hb]
end SMul
section Module
variable [Module â E] [IsScalarTower â ð E] (p : Seminorm ð E) (x : E) (r : â)
/-- Seminorm-balls are convex. -/
theorem convex_ball : Convex â (ball p x r) := by
convert (p.convexOn.translate_left (-x)).convex_lt r
ext y
rw [preimage_univ, sep_univ, p.mem_ball, sub_eq_add_neg]
rfl
/-- Closed seminorm-balls are convex. -/
theorem convex_closedBall : Convex â (closedBall p x r) := by
rw [closedBall_eq_biInter_ball]
exact convex_iInterâ fun _ _ => convex_ball _ _ _
end Module
end Convex
section RestrictScalars
variable (ð) {ð' : Type*} [NormedField ð] [SeminormedRing ð'] [NormedAlgebra ð ð']
[NormOneClass ð'] [AddCommGroup E] [Module ð' E] [SMul ð E] [IsScalarTower ð ð' E]
/-- Reinterpret a seminorm over a field `ð'` as a seminorm over a smaller field `ð`. This will
typically be used with `RCLike ð'` and `ð = â`. -/
protected def restrictScalars (p : Seminorm ð' E) : Seminorm ð E :=
{ p with
smul' := fun a x => by rw [â smul_one_smul ð' a x, p.smul', norm_smul, norm_one, mul_one] }
@[simp]
theorem coe_restrictScalars (p : Seminorm ð' E) : (p.restrictScalars ð : E â â) = p :=
rfl
@[simp]
theorem restrictScalars_ball (p : Seminorm ð' E) : (p.restrictScalars ð).ball = p.ball :=
rfl
@[simp]
theorem restrictScalars_closedBall (p : Seminorm ð' E) :
(p.restrictScalars ð).closedBall = p.closedBall :=
rfl
end RestrictScalars
/-! ### Continuity criterions for seminorms -/
section Continuity
variable [NontriviallyNormedField ð] [SeminormedRing ð] [AddCommGroup E] [Module ð E]
variable [Module ð E]
/-- A seminorm is continuous at `0` if `p.closedBall 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuousAt_zero'`. -/
theorem continuousAt_zero_of_forall' [TopologicalSpace E] {p : Seminorm ð E}
(hp : â r > 0, p.closedBall 0 r â (ð 0 : Filter E)) :
ContinuousAt p 0 := by
simp_rw [Seminorm.closedBall_zero_eq_preimage_closedBall] at hp
rwa [ContinuousAt, Metric.nhds_basis_closedBall.tendsto_right_iff, map_zero]
theorem continuousAt_zero' [TopologicalSpace E] [ContinuousConstSMul ð E] {p : Seminorm ð E}
{r : â} (hp : p.closedBall 0 r â (ð 0 : Filter E)) : ContinuousAt p 0 := by
refine continuousAt_zero_of_forall' fun ε hε ⊠?_
obtain âšk, hkâ, hkâ© : â k : ð, 0 < âkâ â§ âkâ * r < ε := by
rcases le_or_lt r 0 with hr | hr
· use 1; simpa using hr.trans_lt hε
· simpa [lt_div_iffâ hr] using exists_norm_lt ð (div_pos hε hr)
rw [â set_smul_mem_nhds_zero_iff (norm_pos_iff.1 hkâ), smul_closedBall_zero hkâ] at hp
exact mem_of_superset hp <| p.closedBall_mono hk.le
/-- A seminorm is continuous at `0` if `p.ball 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuousAt_zero'`. -/
theorem continuousAt_zero_of_forall [TopologicalSpace E] {p : Seminorm ð E}
(hp : â r > 0, p.ball 0 r â (ð 0 : Filter E)) :
ContinuousAt p 0 :=
continuousAt_zero_of_forall'
(fun r hr ⊠Filter.mem_of_superset (hp r hr) <| p.ball_subset_closedBall _ _)
theorem continuousAt_zero [TopologicalSpace E] [ContinuousConstSMul ð E] {p : Seminorm ð E} {r : â}
(hp : p.ball 0 r â (ð 0 : Filter E)) : ContinuousAt p 0 :=
continuousAt_zero' (Filter.mem_of_superset hp <| p.ball_subset_closedBall _ _)
protected theorem uniformContinuous_of_continuousAt_zero [UniformSpace E] [IsUniformAddGroup E]
{p : Seminorm ð E} (hp : ContinuousAt p 0) : UniformContinuous p := by
have hp : Filter.Tendsto p (ð 0) (ð 0) := map_zero p âž hp
rw [UniformContinuous, uniformity_eq_comap_nhds_zero_swapped,
Metric.uniformity_eq_comap_nhds_zero, Filter.tendsto_comap_iff]
exact
tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (hp.comp Filter.tendsto_comap)
(fun xy => dist_nonneg) fun xy => p.norm_sub_map_le_sub _ _
protected theorem continuous_of_continuousAt_zero [TopologicalSpace E] [IsTopologicalAddGroup E]
{p : Seminorm ð E} (hp : ContinuousAt p 0) : Continuous p := by
letI := IsTopologicalAddGroup.toUniformSpace E
haveI : IsUniformAddGroup E := isUniformAddGroup_of_addCommGroup
exact (Seminorm.uniformContinuous_of_continuousAt_zero hp).continuous
/-- A seminorm is uniformly continuous if `p.ball 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.uniformContinuous`. -/
protected theorem uniformContinuous_of_forall [UniformSpace E] [IsUniformAddGroup E]
{p : Seminorm ð E} (hp : â r > 0, p.ball 0 r â (ð 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero_of_forall hp)
protected theorem uniformContinuous [UniformSpace E] [IsUniformAddGroup E]
[ContinuousConstSMul ð E] {p : Seminorm ð E} {r : â} (hp : p.ball 0 r â (ð 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero hp)
/-- A seminorm is uniformly continuous if `p.closedBall 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.uniformContinuous'`. -/
protected theorem uniformContinuous_of_forall' [UniformSpace E] [IsUniformAddGroup E]
{p : Seminorm ð E} (hp : â r > 0, p.closedBall 0 r â (ð 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero_of_forall' hp)
protected theorem uniformContinuous' [UniformSpace E] [IsUniformAddGroup E]
[ContinuousConstSMul ð E] {p : Seminorm ð E} {r : â}
(hp : p.closedBall 0 r â (ð 0 : Filter E)) : UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero' hp)
/-- A seminorm is continuous if `p.ball 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuous`. -/
protected theorem continuous_of_forall [TopologicalSpace E] [IsTopologicalAddGroup E]
{p : Seminorm ð E} (hp : â r > 0, p.ball 0 r â (ð 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero_of_forall hp)
protected theorem continuous [TopologicalSpace E] [IsTopologicalAddGroup E]
[ContinuousConstSMul ð E] {p : Seminorm ð E} {r : â} (hp : p.ball 0 r â (ð 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero hp)
/-- A seminorm is continuous if `p.closedBall 0 r â ð 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuous'`. -/
protected theorem continuous_of_forall' [TopologicalSpace E] [IsTopologicalAddGroup E]
{p : Seminorm ð E} (hp : â r > 0, p.closedBall 0 r â (ð 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero_of_forall' hp)
protected theorem continuous' [TopologicalSpace E] [IsTopologicalAddGroup E]
[ContinuousConstSMul ð E] {p : Seminorm ð E} {r : â}
(hp : p.closedBall 0 r â (ð 0 : Filter E)) : Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero' hp)
theorem continuous_of_le [TopologicalSpace E] [IsTopologicalAddGroup E]
{p q : Seminorm ð E} (hq : Continuous q) (hpq : p †q) : Continuous p := by
refine Seminorm.continuous_of_forall (fun r hr ⊠Filter.mem_of_superset
(IsOpen.mem_nhds ?_ <| q.mem_ball_self hr) (ball_antitone hpq))
rw [ball_zero_eq]
exact isOpen_lt hq continuous_const
lemma ball_mem_nhds [TopologicalSpace E] {p : Seminorm ð E} (hp : Continuous p) {r : â}
(hr : 0 < r) : p.ball 0 r â (ð 0 : Filter E) :=
have this : Tendsto p (ð 0) (ð 0) := map_zero p âž hp.tendsto 0
by simpa only [p.ball_zero_eq] using this (Iio_mem_nhds hr)
lemma uniformSpace_eq_of_hasBasis
{ι} [UniformSpace E] [IsUniformAddGroup E] [ContinuousConstSMul ð E]
{p' : ι â Prop} {s : ι â Set E} (p : Seminorm ð E) (hb : (ð 0 : Filter E).HasBasis p' s)
| (hâ : â r, p.closedBall 0 r â ð 0) (hâ : â i, p' i â â r > 0, p.ball 0 r â s i) :
â¹UniformSpace E⺠= p.toAddGroupSeminorm.toSeminormedAddGroup.toUniformSpace := by
refine IsUniformAddGroup.ext â¹_âº
p.toAddGroupSeminorm.toSeminormedAddCommGroup.to_isUniformAddGroup ?_
apply le_antisymm
· rw [â @comap_norm_nhds_zero E p.toAddGroupSeminorm.toSeminormedAddGroup, â tendsto_iff_comap]
suffices Continuous p from this.tendsto' 0 _ (map_zero p)
rcases hâ with âšr, hrâ©
exact p.continuous' hr
| Mathlib/Analysis/Seminorm.lean | 1,161 | 1,169 |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot
-/
import Mathlib.Order.Filter.SmallSets
import Mathlib.Topology.UniformSpace.Defs
import Mathlib.Topology.ContinuousOn
/-!
# Basic results on uniform spaces
Uniform spaces are a generalization of metric spaces and topological groups.
## Main definitions
In this file we define a complete lattice structure on the type `UniformSpace X`
of uniform structures on `X`, as well as the pullback (`UniformSpace.comap`) of uniform structures
coming from the pullback of filters.
Like distance functions, uniform structures cannot be pushed forward in general.
## Notations
Localized in `Uniformity`, we have the notation `ð€ X` for the uniformity on a uniform space `X`,
and `â` for composition of relations, seen as terms with type `Set (X Ã X)`.
## References
The formalization uses the books:
* [N. Bourbaki, *General Topology*][bourbaki1966]
* [I. M. James, *Topologies and Uniformities*][james1999]
But it makes a more systematic use of the filter library.
-/
open Set Filter Topology
universe u v ua ub uc ud
/-!
### Relations, seen as `Set (α à α)`
-/
variable {α : Type ua} {β : Type ub} {γ : Type uc} {Ύ : Type ud} {ι : Sort*}
open Uniformity
section UniformSpace
variable [UniformSpace α]
/-- If `s â ð€ α`, then for any natural `n`, for a subset `t` of a sufficiently small set in `ð€ α`,
we have `t â t â ... â t â s` (`n` compositions). -/
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 generalizing s with
| zero => simpa
| succ _ ihn =>
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â©
/-- If `s â ð€ α`, then for a subset `t` of a sufficiently small set in `ð€ α`,
we have `t â t â s`. -/
theorem eventually_uniformity_comp_subset {s : Set (α à α)} (hs : s â ð€ α) :
âá¶ t in (ð€ α).smallSets, t â t â s :=
eventually_uniformity_iterate_comp_subset hs 1
/-!
### Balls in uniform spaces
-/
namespace UniformSpace
open UniformSpace (ball)
lemma isOpen_ball (x : α) {V : Set (α à α)} (hV : IsOpen V) : IsOpen (ball x V) :=
hV.preimage <| .prodMk_right _
lemma isClosed_ball (x : α) {V : Set (α à α)} (hV : IsClosed V) : IsClosed (ball x V) :=
hV.preimage <| .prodMk_right _
/-!
### Neighborhoods in uniform spaces
-/
theorem hasBasis_nhds_prod (x y : α) :
HasBasis (ð (x, y)) (fun s => s â ð€ α â§ IsSymmetricRel s) fun s => ball x s ÃË¢ ball y s := by
rw [nhds_prod_eq]
apply (hasBasis_nhds x).prod_same_index (hasBasis_nhds y)
rintro U V âšU_in, U_symmâ© âšV_in, V_symmâ©
exact
âšU â© V, âš(ð€ α).inter_sets U_in V_in, U_symm.inter V_symmâ©, ball_inter_left x U V,
ball_inter_right y U Vâ©
end UniformSpace
open UniformSpace
theorem nhds_eq_uniformity_prod {a b : α} :
ð (a, b) =
(ð€ α).lift' fun s : Set (α à α) => { y : α | (y, a) â s } ÃË¢ { y : α | (b, y) â s } := by
rw [nhds_prod_eq, nhds_nhds_eq_uniformity_uniformity_prod, lift_lift'_same_eq_lift']
· exact fun s => monotone_const.set_prod monotone_preimage
· refine fun t => Monotone.set_prod ?_ monotone_const
exact monotone_preimage (f := fun y => (y, a))
theorem nhdset_of_mem_uniformity {d : Set (α à α)} (s : Set (α à α)) (hd : d â ð€ α) :
â t : Set (α à α), IsOpen t â§ s â t â§
t â { p | â x y, (p.1, x) â d â§ (x, y) â s â§ (y, p.2) â d } := by
let cl_d := { p : α à α | â x y, (p.1, x) â d â§ (x, y) â s â§ (y, p.2) â d }
have : â p â s, â t, t â cl_d â§ IsOpen t â§ p â t := fun âšx, yâ© hp =>
mem_nhds_iff.mp <|
show cl_d â ð (x, y) by
rw [nhds_eq_uniformity_prod, mem_lift'_sets]
· exact âšd, hd, fun âša, bâ© âšha, hbâ© => âšx, y, ha, hp, hbâ©â©
· exact fun _ _ h _ h' => âšh h'.1, h h'.2â©
choose t ht using this
exact âš(â p : α à α, â h : p â s, t p h : Set (α à α)),
isOpen_iUnion fun p : α à α => isOpen_iUnion fun hp => (ht p hp).right.left,
fun âša, bâ© hp => by
simp only [mem_iUnion, Prod.exists]; exact âša, b, hp, (ht (a, b) hp).right.rightâ©,
iUnion_subset fun p => iUnion_subset fun hp => (ht p hp).leftâ©
/-- Entourages are neighborhoods of the diagonal. -/
theorem nhds_le_uniformity (x : α) : ð (x, x) †ð€ α := by
intro V V_in
rcases comp_symm_mem_uniformity_sets V_in with âšw, w_in, w_symm, w_subâ©
have : ball x w ÃË¢ ball x w â ð (x, x) := by
rw [nhds_prod_eq]
exact prod_mem_prod (ball_mem_nhds x w_in) (ball_mem_nhds x w_in)
apply mem_of_superset this
rintro âšu, vâ© âšu_in, v_inâ©
exact w_sub (mem_comp_of_mem_ball w_symm u_in v_in)
/-- Entourages are neighborhoods of the diagonal. -/
theorem iSup_nhds_le_uniformity : âš x : α, ð (x, x) †ð€ α :=
iSup_le nhds_le_uniformity
/-- Entourages are neighborhoods of the diagonal. -/
theorem nhdsSet_diagonal_le_uniformity : ðË¢ (diagonal α) †ð€ α :=
(nhdsSet_diagonal α).trans_le iSup_nhds_le_uniformity
section
variable (α)
theorem UniformSpace.has_seq_basis [IsCountablyGenerated <| ð€ α] :
â V : â â Set (α à α), HasAntitoneBasis (ð€ α) V â§ â n, IsSymmetricRel (V n) :=
let âšU, hsym, hbasisâ© := (@UniformSpace.hasBasis_symmetric α _).exists_antitone_subbasis
âšU, hbasis, fun n => (hsym n).2â©
end
/-!
### Closure and interior in uniform spaces
-/
theorem closure_eq_uniformity (s : Set <| α à α) :
closure s = â V â { V | V â ð€ α â§ IsSymmetricRel V }, V â s â V := by
ext âšx, yâ©
simp +contextual only
[mem_closure_iff_nhds_basis (UniformSpace.hasBasis_nhds_prod x y), mem_iInter, mem_setOf_eq,
and_imp, mem_comp_comp, exists_prop, â mem_inter_iff, inter_comm, Set.Nonempty]
theorem uniformity_hasBasis_closed :
HasBasis (ð€ α) (fun V : Set (α à α) => V â ð€ α â§ IsClosed V) id := by
refine Filter.hasBasis_self.2 fun t h => ?_
rcases comp_comp_symm_mem_uniformity_sets h with âšw, w_in, w_symm, râ©
refine âšclosure w, mem_of_superset w_in subset_closure, isClosed_closure, ?_â©
refine Subset.trans ?_ r
rw [closure_eq_uniformity]
apply iInter_subset_of_subset
apply iInter_subset
exact âšw_in, w_symmâ©
theorem uniformity_eq_uniformity_closure : ð€ α = (ð€ α).lift' closure :=
Eq.symm <| uniformity_hasBasis_closed.lift'_closure_eq_self fun _ => And.right
theorem Filter.HasBasis.uniformity_closure {p : ι â Prop} {U : ι â Set (α à α)}
(h : (ð€ α).HasBasis p U) : (ð€ α).HasBasis p fun i => closure (U i) :=
(@uniformity_eq_uniformity_closure α _).symm ➠h.lift'_closure
/-- Closed entourages form a basis of the uniformity filter. -/
theorem uniformity_hasBasis_closure : HasBasis (ð€ α) (fun V : Set (α à α) => V â ð€ α) closure :=
(ð€ α).basis_sets.uniformity_closure
theorem closure_eq_inter_uniformity {t : Set (α à α)} : closure t = â d â ð€ α, d â (t â d) :=
calc
closure t = â (V) (_ : V â ð€ α â§ IsSymmetricRel V), V â t â V := closure_eq_uniformity t
_ = â V â ð€ α, V â t â V :=
Eq.symm <|
UniformSpace.hasBasis_symmetric.biInter_mem fun _ _ hV =>
compRel_mono (compRel_mono hV Subset.rfl) hV
_ = â V â ð€ α, V â (t â V) := by simp only [compRel_assoc]
theorem uniformity_eq_uniformity_interior : ð€ α = (ð€ α).lift' interior :=
le_antisymm
(le_iInfâ fun d hd => by
let âšs, hs, hs_compâ© := comp3_mem_uniformity hd
let âšt, ht, hst, ht_compâ© := nhdset_of_mem_uniformity s hs
have : s â interior d :=
calc
s â t := hst
_ â interior d :=
ht.subset_interior_iff.mpr fun x (hx : x â t) =>
let âšx, y, hâ, hâ, hââ© := ht_comp hx
hs_comp âšx, hâ, y, hâ, hââ©
have : interior d â ð€ α := by filter_upwards [hs] using this
simp [this])
fun _ hs => ((ð€ α).lift' interior).sets_of_superset (mem_lift' hs) interior_subset
theorem interior_mem_uniformity {s : Set (α à α)} (hs : s â ð€ α) : interior s â ð€ α := by
rw [uniformity_eq_uniformity_interior]; exact mem_lift' hs
theorem mem_uniformity_isClosed {s : Set (α à α)} (h : s â ð€ α) : â t â ð€ α, IsClosed t â§ t â s :=
let âšt, âšht_mem, htcâ©, htsâ© := uniformity_hasBasis_closed.mem_iff.1 h
âšt, ht_mem, htc, htsâ©
theorem isOpen_iff_isOpen_ball_subset {s : Set α} :
IsOpen s â â x â s, â V â ð€ α, IsOpen V â§ ball x V â s := by
rw [isOpen_iff_ball_subset]
constructor <;> intro h x hx
· obtain âšV, hV, hV'â© := h x hx
exact
âšinterior V, interior_mem_uniformity hV, isOpen_interior,
(ball_mono interior_subset x).trans hV'â©
· obtain âšV, hV, -, hV'â© := h x hx
exact âšV, hV, hV'â©
@[deprecated (since := "2024-11-18")] alias
isOpen_iff_open_ball_subset := isOpen_iff_isOpen_ball_subset
/-- The uniform neighborhoods of all points of a dense set cover the whole space. -/
theorem Dense.biUnion_uniformity_ball {s : Set α} {U : Set (α à α)} (hs : Dense s) (hU : U â ð€ α) :
â x â s, ball x U = univ := by
refine iUnionâ_eq_univ_iff.2 fun y => ?_
rcases hs.inter_nhds_nonempty (mem_nhds_right y hU) with âšx, hxs, hxy : (x, y) â Uâ©
exact âšx, hxs, hxyâ©
/-- The uniform neighborhoods of all points of a dense indexed collection cover the whole space. -/
lemma DenseRange.iUnion_uniformity_ball {ι : Type*} {xs : ι â α}
(xs_dense : DenseRange xs) {U : Set (α à α)} (hU : U â uniformity α) :
â i, UniformSpace.ball (xs i) U = univ := by
rw [â biUnion_range (f := xs) (g := fun x ⊠UniformSpace.ball x U)]
exact Dense.biUnion_uniformity_ball xs_dense hU
/-!
### Uniformity bases
-/
/-- Open elements of `ð€ α` form a basis of `ð€ α`. -/
theorem uniformity_hasBasis_open : HasBasis (ð€ α) (fun V : Set (α à α) => V â ð€ α â§ IsOpen V) id :=
hasBasis_self.2 fun s hs =>
âšinterior s, interior_mem_uniformity hs, isOpen_interior, interior_subsetâ©
theorem Filter.HasBasis.mem_uniformity_iff {p : β â Prop} {s : β â Set (α à α)}
(h : (ð€ α).HasBasis p s) {t : Set (α à α)} :
t â ð€ α â â i, p i â§ â a b, (a, b) â s i â (a, b) â t :=
h.mem_iff.trans <| by simp only [Prod.forall, subset_def]
/-- Open elements `s : Set (α à α)` of `ð€ α` such that `(x, y) â s â (y, x) â s` form a basis
of `ð€ α`. -/
theorem uniformity_hasBasis_open_symmetric :
HasBasis (ð€ α) (fun V : Set (α à α) => V â ð€ α â§ IsOpen V â§ IsSymmetricRel V) id := by
simp only [â and_assoc]
refine uniformity_hasBasis_open.restrict fun s hs => âšsymmetrizeRel s, ?_â©
exact
âšâšsymmetrize_mem_uniformity hs.1, IsOpen.inter hs.2 (hs.2.preimage continuous_swap)â©,
symmetric_symmetrizeRel s, symmetrizeRel_subset_self sâ©
theorem comp_open_symm_mem_uniformity_sets {s : Set (α à α)} (hs : s â ð€ α) :
â t â ð€ α, IsOpen t â§ IsSymmetricRel t â§ t â t â s := by
obtain âšt, htâ, htââ© := comp_mem_uniformity_sets hs
obtain âšu, âšhuâ, huâ, huââ©, huâ : u â tâ© := uniformity_hasBasis_open_symmetric.mem_iff.mp htâ
exact âšu, huâ, huâ, huâ, (compRel_mono huâ huâ).trans htââ©
end UniformSpace
open uniformity
section Constructions
instance : PartialOrder (UniformSpace α) :=
PartialOrder.lift (fun u => ð€[u]) fun _ _ => UniformSpace.ext
protected theorem UniformSpace.le_def {uâ uâ : UniformSpace α} : uâ †uâ â ð€[uâ] †ð€[uâ] := Iff.rfl
instance : InfSet (UniformSpace α) :=
âšfun s =>
UniformSpace.ofCore
{ uniformity := âš
u â s, ð€[u]
refl := le_iInf fun u => le_iInf fun _ => u.toCore.refl
symm := le_iInfâ fun u hu =>
le_trans (map_mono <| iInf_le_of_le _ <| iInf_le _ hu) u.symm
comp := le_iInfâ fun u hu =>
le_trans (lift'_mono (iInf_le_of_le _ <| iInf_le _ hu) <| le_rfl) u.comp }â©
protected theorem UniformSpace.sInf_le {tt : Set (UniformSpace α)} {t : UniformSpace α}
(h : t â tt) : sInf tt †t :=
show âš
u â tt, ð€[u] †ð€[t] from iInfâ_le t h
protected theorem UniformSpace.le_sInf {tt : Set (UniformSpace α)} {t : UniformSpace α}
(h : â t' â tt, t †t') : t †sInf tt :=
show ð€[t] †âš
u â tt, ð€[u] from le_iInfâ h
instance : Top (UniformSpace α) :=
âš@UniformSpace.mk α ††le_top le_top fun x ⊠by simp only [nhds_top, comap_top]â©
instance : Bot (UniformSpace α) :=
âš{ toTopologicalSpace := â¥
uniformity := ð idRel
symm := by simp [Tendsto]
comp := lift'_le (mem_principal_self _) <| principal_mono.2 id_compRel.subset
nhds_eq_comap_uniformity := fun s => by
let _ : TopologicalSpace α := â¥; have := discreteTopology_bot α
simp [idRel] }â©
instance : Min (UniformSpace α) :=
âšfun uâ uâ =>
{ uniformity := ð€[uâ] â ð€[uâ]
symm := uâ.symm.inf uâ.symm
comp := (lift'_inf_le _ _ _).trans <| inf_le_inf uâ.comp uâ.comp
toTopologicalSpace := uâ.toTopologicalSpace â uâ.toTopologicalSpace
nhds_eq_comap_uniformity := fun _ ⊠by
rw [@nhds_inf _ uâ.toTopologicalSpace _, @nhds_eq_comap_uniformity _ uâ,
@nhds_eq_comap_uniformity _ uâ, comap_inf] }â©
instance : CompleteLattice (UniformSpace α) :=
{ inferInstanceAs (PartialOrder (UniformSpace α)) with
sup := fun a b => sInf { x | a †x ⧠b †x }
le_sup_left := fun _ _ => UniformSpace.le_sInf fun _ âšh, _â© => h
le_sup_right := fun _ _ => UniformSpace.le_sInf fun _ âš_, hâ© => h
sup_le := fun _ _ _ hâ hâ => UniformSpace.sInf_le âšhâ, hââ©
inf := (· â ·)
le_inf := fun a _ _ hâ hâ => show a.uniformity †_ from le_inf hâ hâ
inf_le_left := fun a _ => show _ †a.uniformity from inf_le_left
inf_le_right := fun _ b => show _ †b.uniformity from inf_le_right
top := â€
le_top := fun a => show a.uniformity ††from le_top
bot := â¥
bot_le := fun u => u.toCore.refl
sSup := fun tt => sInf { t | â t' â tt, t' †t }
le_sSup := fun _ _ h => UniformSpace.le_sInf fun _ h' => h' _ h
sSup_le := fun _ _ h => UniformSpace.sInf_le h
sInf := sInf
le_sInf := fun _ _ hs => UniformSpace.le_sInf hs
sInf_le := fun _ _ ha => UniformSpace.sInf_le ha }
theorem iInf_uniformity {ι : Sort*} {u : ι â UniformSpace α} : ð€[iInf u] = âš
i, ð€[u i] :=
iInf_range
theorem inf_uniformity {u v : UniformSpace α} : ð€[u â v] = ð€[u] â ð€[v] := rfl
lemma bot_uniformity : ð€[(⥠: UniformSpace α)] = ð idRel := rfl
lemma top_uniformity : ð€[(†: UniformSpace α)] = †:= rfl
instance inhabitedUniformSpace : Inhabited (UniformSpace α) :=
âšâ¥â©
instance inhabitedUniformSpaceCore : Inhabited (UniformSpace.Core α) :=
âš@UniformSpace.toCore _ defaultâ©
instance [Subsingleton α] : Unique (UniformSpace α) where
uniq u := bot_unique <| le_principal_iff.2 <| by
rw [idRel, â diagonal, diagonal_eq_univ]; exact univ_mem
/-- Given `f : α â β` and a uniformity `u` on `β`, the inverse image of `u` under `f`
is the inverse image in the filter sense of the induced function `α à α â β à β`.
See note [reducible non-instances]. -/
abbrev UniformSpace.comap (f : α â β) (u : UniformSpace β) : UniformSpace α where
uniformity := ð€[u].comap fun p : α à α => (f p.1, f p.2)
symm := by
simp only [tendsto_comap_iff, Prod.swap, (· â ·)]
exact tendsto_swap_uniformity.comp tendsto_comap
comp := le_trans
(by
rw [comap_lift'_eq, comap_lift'_eq2]
· exact lift'_mono' fun s _ âšaâ, aââ© âšx, hâ, hââ© => âšf x, hâ, hââ©
· exact monotone_id.compRel monotone_id)
(comap_mono u.comp)
toTopologicalSpace := u.toTopologicalSpace.induced f
nhds_eq_comap_uniformity x := by
simp only [nhds_induced, nhds_eq_comap_uniformity, comap_comap, Function.comp_def]
theorem uniformity_comap {_ : UniformSpace β} (f : α â β) :
ð€[UniformSpace.comap f â¹_âº] = comap (Prod.map f f) (ð€ β) :=
rfl
lemma ball_preimage {f : α â β} {U : Set (β à β)} {x : α} :
UniformSpace.ball x (Prod.map f f â»Â¹' U) = f â»Â¹' UniformSpace.ball (f x) U := by
ext : 1
simp only [UniformSpace.ball, mem_preimage, Prod.map_apply]
@[simp]
theorem uniformSpace_comap_id {α : Type*} : UniformSpace.comap (id : α â α) = id := by
ext : 2
rw [uniformity_comap, Prod.map_id, comap_id]
theorem UniformSpace.comap_comap {α β γ} {uγ : UniformSpace γ} {f : α â β} {g : β â γ} :
UniformSpace.comap (g â f) uγ = UniformSpace.comap f (UniformSpace.comap g uγ) := by
ext1
simp only [uniformity_comap, Filter.comap_comap, Prod.map_comp_map]
theorem UniformSpace.comap_inf {α γ} {uâ uâ : UniformSpace γ} {f : α â γ} :
(uâ â uâ).comap f = uâ.comap f â uâ.comap f :=
UniformSpace.ext Filter.comap_inf
theorem UniformSpace.comap_iInf {ι α γ} {u : ι â UniformSpace γ} {f : α â γ} :
(âš
i, u i).comap f = âš
i, (u i).comap f := by
ext : 1
simp [uniformity_comap, iInf_uniformity]
theorem UniformSpace.comap_mono {α γ} {f : α â γ} :
Monotone fun u : UniformSpace γ => u.comap f := fun _ _ hu =>
Filter.comap_mono hu
theorem uniformContinuous_iff {α β} {uα : UniformSpace α} {uβ : UniformSpace β} {f : α â β} :
UniformContinuous f â uα †uβ.comap f :=
Filter.map_le_iff_le_comap
theorem le_iff_uniformContinuous_id {u v : UniformSpace α} :
u †v â @UniformContinuous _ _ u v id := by
rw [uniformContinuous_iff, uniformSpace_comap_id, id]
theorem uniformContinuous_comap {f : α â β} [u : UniformSpace β] :
@UniformContinuous α β (UniformSpace.comap f u) u f :=
tendsto_comap
theorem uniformContinuous_comap' {f : γ â β} {g : α â γ} [v : UniformSpace β] [u : UniformSpace α]
(h : UniformContinuous (f â g)) : @UniformContinuous α γ u (UniformSpace.comap f v) g :=
tendsto_comap_iff.2 h
namespace UniformSpace
theorem to_nhds_mono {uâ uâ : UniformSpace α} (h : uâ †uâ) (a : α) :
@nhds _ (@UniformSpace.toTopologicalSpace _ uâ) a â€
@nhds _ (@UniformSpace.toTopologicalSpace _ uâ) a := by
rw [@nhds_eq_uniformity α uâ a, @nhds_eq_uniformity α uâ a]; exact lift'_mono h le_rfl
theorem toTopologicalSpace_mono {uâ uâ : UniformSpace α} (h : uâ †uâ) :
@UniformSpace.toTopologicalSpace _ uâ †@UniformSpace.toTopologicalSpace _ uâ :=
le_of_nhds_le_nhds <| to_nhds_mono h
theorem toTopologicalSpace_comap {f : α â β} {u : UniformSpace β} :
@UniformSpace.toTopologicalSpace _ (UniformSpace.comap f u) =
TopologicalSpace.induced f (@UniformSpace.toTopologicalSpace β u) :=
rfl
lemma uniformSpace_eq_bot {u : UniformSpace α} : u = ⥠â idRel â ð€[u] :=
le_bot_iff.symm.trans le_principal_iff
protected lemma _root_.Filter.HasBasis.uniformSpace_eq_bot {ι p} {s : ι â Set (α à α)}
{u : UniformSpace α} (h : ð€[u].HasBasis p s) :
u = ⥠â â i, p i â§ Pairwise fun x y : α ⊠(x, y) â s i := by
simp [uniformSpace_eq_bot, h.mem_iff, subset_def, Pairwise, not_imp_not]
theorem toTopologicalSpace_bot : @UniformSpace.toTopologicalSpace α ⥠= ⥠:= rfl
theorem toTopologicalSpace_top : @UniformSpace.toTopologicalSpace α †= †:= rfl
theorem toTopologicalSpace_iInf {ι : Sort*} {u : ι â UniformSpace α} :
(iInf u).toTopologicalSpace = âš
i, (u i).toTopologicalSpace :=
TopologicalSpace.ext_nhds fun a ⊠by simp only [@nhds_eq_comap_uniformity _ (iInf u), nhds_iInf,
iInf_uniformity, @nhds_eq_comap_uniformity _ (u _), Filter.comap_iInf]
theorem toTopologicalSpace_sInf {s : Set (UniformSpace α)} :
(sInf s).toTopologicalSpace = âš
i â s, @UniformSpace.toTopologicalSpace α i := by
rw [sInf_eq_iInf]
simp only [â toTopologicalSpace_iInf]
theorem toTopologicalSpace_inf {u v : UniformSpace α} :
(u â v).toTopologicalSpace = u.toTopologicalSpace â v.toTopologicalSpace :=
rfl
end UniformSpace
theorem UniformContinuous.continuous [UniformSpace α] [UniformSpace β] {f : α â β}
(hf : UniformContinuous f) : Continuous f :=
continuous_iff_le_induced.mpr <| UniformSpace.toTopologicalSpace_mono <|
uniformContinuous_iff.1 hf
/-- Uniform space structure on `ULift α`. -/
instance ULift.uniformSpace [UniformSpace α] : UniformSpace (ULift α) :=
UniformSpace.comap ULift.down â¹_âº
/-- Uniform space structure on `αáµáµ`. -/
instance OrderDual.instUniformSpace [UniformSpace α] : UniformSpace (αáµáµ) :=
â¹UniformSpace αâº
section UniformContinuousInfi
-- TODO: add an `iff` lemma?
theorem UniformContinuous.inf_rng {f : α â β} {uâ : UniformSpace α} {uâ uâ : UniformSpace β}
(hâ : UniformContinuous[uâ, uâ] f) (hâ : UniformContinuous[uâ, uâ] f) :
UniformContinuous[uâ, uâ â uâ] f :=
tendsto_inf.mpr âšhâ, hââ©
theorem UniformContinuous.inf_dom_left {f : α â β} {uâ uâ : UniformSpace α} {uâ : UniformSpace β}
(hf : UniformContinuous[uâ, uâ] f) : UniformContinuous[uâ â uâ, uâ] f :=
tendsto_inf_left hf
theorem UniformContinuous.inf_dom_right {f : α â β} {uâ uâ : UniformSpace α} {uâ : UniformSpace β}
(hf : UniformContinuous[uâ, uâ] f) : UniformContinuous[uâ â uâ, uâ] f :=
tendsto_inf_right hf
theorem uniformContinuous_sInf_dom {f : α â β} {uâ : Set (UniformSpace α)} {uâ : UniformSpace β}
{u : UniformSpace α} (hâ : u â uâ) (hf : UniformContinuous[u, uâ] f) :
UniformContinuous[sInf uâ, uâ] f := by
delta UniformContinuous
rw [sInf_eq_iInf', iInf_uniformity]
exact tendsto_iInf' âšu, hââ© hf
theorem uniformContinuous_sInf_rng {f : α â β} {uâ : UniformSpace α} {uâ : Set (UniformSpace β)} :
UniformContinuous[uâ, sInf uâ] f â â u â uâ, UniformContinuous[uâ, u] f := by
delta UniformContinuous
rw [sInf_eq_iInf', iInf_uniformity, tendsto_iInf, SetCoe.forall]
theorem uniformContinuous_iInf_dom {f : α â β} {uâ : ι â UniformSpace α} {uâ : UniformSpace β}
{i : ι} (hf : UniformContinuous[uâ i, uâ] f) : UniformContinuous[iInf uâ, uâ] f := by
delta UniformContinuous
rw [iInf_uniformity]
exact tendsto_iInf' i hf
theorem uniformContinuous_iInf_rng {f : α â β} {uâ : UniformSpace α} {uâ : ι â UniformSpace β} :
UniformContinuous[uâ, iInf uâ] f â â i, UniformContinuous[uâ, uâ i] f := by
delta UniformContinuous
rw [iInf_uniformity, tendsto_iInf]
end UniformContinuousInfi
/-- A uniform space with the discrete uniformity has the discrete topology. -/
theorem discreteTopology_of_discrete_uniformity [hα : UniformSpace α] (h : uniformity α = ð idRel) :
DiscreteTopology α :=
âš(UniformSpace.ext h.symm : ⥠= hα) âž rflâ©
instance : UniformSpace Empty := â¥
instance : UniformSpace PUnit := â¥
instance : UniformSpace Bool := â¥
instance : UniformSpace â := â¥
instance : UniformSpace †:= â¥
section
variable [UniformSpace α]
open Additive Multiplicative
instance : UniformSpace (Additive α) := â¹UniformSpace αâº
instance : UniformSpace (Multiplicative α) := â¹UniformSpace αâº
theorem uniformContinuous_ofMul : UniformContinuous (ofMul : α â Additive α) :=
uniformContinuous_id
theorem uniformContinuous_toMul : UniformContinuous (toMul : Additive α â α) :=
uniformContinuous_id
theorem uniformContinuous_ofAdd : UniformContinuous (ofAdd : α â Multiplicative α) :=
uniformContinuous_id
theorem uniformContinuous_toAdd : UniformContinuous (toAdd : Multiplicative α â α) :=
uniformContinuous_id
theorem uniformity_additive : ð€ (Additive α) = (ð€ α).map (Prod.map ofMul ofMul) := rfl
theorem uniformity_multiplicative : ð€ (Multiplicative α) = (ð€ α).map (Prod.map ofAdd ofAdd) := rfl
end
instance instUniformSpaceSubtype {p : α â Prop} [t : UniformSpace α] : UniformSpace (Subtype p) :=
UniformSpace.comap Subtype.val t
theorem uniformity_subtype {p : α â Prop} [UniformSpace α] :
ð€ (Subtype p) = comap (fun q : Subtype p à Subtype p => (q.1.1, q.2.1)) (ð€ α) :=
rfl
theorem uniformity_setCoe {s : Set α} [UniformSpace α] :
ð€ s = comap (Prod.map ((â) : s â α) ((â) : s â α)) (ð€ α) :=
rfl
theorem map_uniformity_set_coe {s : Set α} [UniformSpace α] :
map (Prod.map (â) (â)) (ð€ s) = ð€ α â ð (s ÃË¢ s) := by
rw [uniformity_setCoe, map_comap, range_prodMap, Subtype.range_val]
theorem uniformContinuous_subtype_val {p : α â Prop} [UniformSpace α] :
UniformContinuous (Subtype.val : { a : α // p a } â α) :=
uniformContinuous_comap
theorem UniformContinuous.subtype_mk {p : α â Prop} [UniformSpace α] [UniformSpace β] {f : β â α}
(hf : UniformContinuous f) (h : â x, p (f x)) :
UniformContinuous (fun x => âšf x, h xâ© : β â Subtype p) :=
uniformContinuous_comap' hf
theorem uniformContinuousOn_iff_restrict [UniformSpace α] [UniformSpace β] {f : α â β} {s : Set α} :
UniformContinuousOn f s â UniformContinuous (s.restrict f) := by
delta UniformContinuousOn UniformContinuous
rw [â map_uniformity_set_coe, tendsto_map'_iff]; rfl
theorem tendsto_of_uniformContinuous_subtype [UniformSpace α] [UniformSpace β] {f : α â β}
{s : Set α} {a : α} (hf : UniformContinuous fun x : s => f x.val) (ha : s â ð a) :
Tendsto f (ð a) (ð (f a)) := by
rw [(@map_nhds_subtype_coe_eq_nhds α _ s a (mem_of_mem_nhds ha) ha).symm]
exact tendsto_map' hf.continuous.continuousAt
theorem UniformContinuousOn.continuousOn [UniformSpace α] [UniformSpace β] {f : α â β} {s : Set α}
(h : UniformContinuousOn f s) : ContinuousOn f s := by
rw [uniformContinuousOn_iff_restrict] at h
rw [continuousOn_iff_continuous_restrict]
exact h.continuous
@[to_additive]
instance [UniformSpace α] : UniformSpace αáµáµáµ :=
UniformSpace.comap MulOpposite.unop â¹_âº
@[to_additive]
theorem uniformity_mulOpposite [UniformSpace α] :
ð€ αáµáµáµ = comap (fun q : αáµáµáµ à αáµáµáµ => (q.1.unop, q.2.unop)) (ð€ α) :=
rfl
@[to_additive (attr := simp)]
theorem comap_uniformity_mulOpposite [UniformSpace α] :
comap (fun p : α à α => (MulOpposite.op p.1, MulOpposite.op p.2)) (ð€ αáµáµáµ) = ð€ α := by
simpa [uniformity_mulOpposite, comap_comap, (· â ·)] using comap_id
namespace MulOpposite
@[to_additive]
theorem uniformContinuous_unop [UniformSpace α] : UniformContinuous (unop : αáµáµáµ â α) :=
uniformContinuous_comap
@[to_additive]
theorem uniformContinuous_op [UniformSpace α] : UniformContinuous (op : α â αáµáµáµ) :=
uniformContinuous_comap' uniformContinuous_id
end MulOpposite
section Prod
open UniformSpace
/- a similar product space is possible on the function space (uniformity of pointwise convergence),
but we want to have the uniformity of uniform convergence on function spaces -/
instance instUniformSpaceProd [uâ : UniformSpace α] [uâ : UniformSpace β] : UniformSpace (α à β) :=
uâ.comap Prod.fst â uâ.comap Prod.snd
-- check the above produces no diamond for `simp` and typeclass search
example [UniformSpace α] [UniformSpace β] :
(instTopologicalSpaceProd : TopologicalSpace (α à β)) = UniformSpace.toTopologicalSpace := by
with_reducible_and_instances rfl
theorem uniformity_prod [UniformSpace α] [UniformSpace β] :
ð€ (α à β) =
((ð€ α).comap fun p : (α à β) à α à β => (p.1.1, p.2.1)) â
(ð€ β).comap fun p : (α à β) à α à β => (p.1.2, p.2.2) :=
rfl
instance [UniformSpace α] [IsCountablyGenerated (ð€ α)]
[UniformSpace β] [IsCountablyGenerated (ð€ β)] : IsCountablyGenerated (ð€ (α à β)) := by
rw [uniformity_prod]
infer_instance
theorem uniformity_prod_eq_comap_prod [UniformSpace α] [UniformSpace β] :
ð€ (α à β) =
comap (fun p : (α à β) à α à β => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (ð€ α ÃË¢ ð€ β) := by
simp_rw [uniformity_prod, prod_eq_inf, Filter.comap_inf, Filter.comap_comap, Function.comp_def]
theorem uniformity_prod_eq_prod [UniformSpace α] [UniformSpace β] :
ð€ (α à β) = map (fun p : (α à α) à β à β => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (ð€ α ÃË¢ ð€ β) := by
rw [map_swap4_eq_comap, uniformity_prod_eq_comap_prod]
theorem mem_uniformity_of_uniformContinuous_invariant [UniformSpace α] [UniformSpace β]
{s : Set (β à β)} {f : α â α â β} (hf : UniformContinuous fun p : α à α => f p.1 p.2)
(hs : s â ð€ β) : â u â ð€ α, â a b c, (a, b) â u â (f a c, f b c) â s := by
rw [UniformContinuous, uniformity_prod_eq_prod, tendsto_map'_iff] at hf
rcases mem_prod_iff.1 (mem_map.1 <| hf hs) with âšu, hu, v, hv, huvtâ©
exact âšu, hu, fun a b c hab => @huvt ((_, _), (_, _)) âšhab, refl_mem_uniformity hvâ©â©
/-- An entourage of the diagonal in `α` and an entourage in `β` yield an entourage in `α à β`
once we permute coordinates. -/
def entourageProd (u : Set (α à α)) (v : Set (β à β)) : Set ((α à β) à α à β) :=
{((aâ, bâ),(aâ, bâ)) | (aâ, aâ) â u â§ (bâ, bâ) â v}
theorem mem_entourageProd {u : Set (α à α)} {v : Set (β à β)} {p : (α à β) à α à β} :
p â entourageProd u v â (p.1.1, p.2.1) â u â§ (p.1.2, p.2.2) â v := Iff.rfl
theorem entourageProd_mem_uniformity [tâ : UniformSpace α] [tâ : UniformSpace β] {u : Set (α à α)}
{v : Set (β à β)} (hu : u â ð€ α) (hv : v â ð€ β) :
entourageProd u v â ð€ (α à β) := by
rw [uniformity_prod]; exact inter_mem_inf (preimage_mem_comap hu) (preimage_mem_comap hv)
theorem ball_entourageProd (u : Set (α à α)) (v : Set (β à β)) (x : α à β) :
ball x (entourageProd u v) = ball x.1 u ÃË¢ ball x.2 v := by
ext p; simp only [ball, entourageProd, Set.mem_setOf_eq, Set.mem_prod, Set.mem_preimage]
lemma IsSymmetricRel.entourageProd {u : Set (α à α)} {v : Set (β à β)}
(hu : IsSymmetricRel u) (hv : IsSymmetricRel v) :
IsSymmetricRel (entourageProd u v) :=
Set.ext fun _ ⊠and_congr hu.mk_mem_comm hv.mk_mem_comm
theorem Filter.HasBasis.uniformity_prod {ιa ιb : Type*} [UniformSpace α] [UniformSpace β]
{pa : ιa â Prop} {pb : ιb â Prop} {sa : ιa â Set (α à α)} {sb : ιb â Set (β à β)}
(ha : (ð€ α).HasBasis pa sa) (hb : (ð€ β).HasBasis pb sb) :
(ð€ (α à β)).HasBasis (fun i : ιa à ιb ⊠pa i.1 â§ pb i.2)
(fun i ⊠entourageProd (sa i.1) (sb i.2)) :=
(ha.comap _).inf (hb.comap _)
theorem entourageProd_subset [UniformSpace α] [UniformSpace β]
{s : Set ((α à β) à α à β)} (h : s â ð€ (α à β)) :
â u â ð€ α, â v â ð€ β, entourageProd u v â s := by
rcases (((ð€ α).basis_sets.uniformity_prod (ð€ β).basis_sets).mem_iff' s).1 h with âšw, hwâ©
use w.1, hw.1.1, w.2, hw.1.2, hw.2
theorem tendsto_prod_uniformity_fst [UniformSpace α] [UniformSpace β] :
Tendsto (fun p : (α à β) à α à β => (p.1.1, p.2.1)) (ð€ (α à β)) (ð€ α) :=
le_trans (map_mono inf_le_left) map_comap_le
theorem tendsto_prod_uniformity_snd [UniformSpace α] [UniformSpace β] :
Tendsto (fun p : (α à β) à α à β => (p.1.2, p.2.2)) (ð€ (α à β)) (ð€ β) :=
le_trans (map_mono inf_le_right) map_comap_le
theorem uniformContinuous_fst [UniformSpace α] [UniformSpace β] :
UniformContinuous fun p : α à β => p.1 :=
tendsto_prod_uniformity_fst
theorem uniformContinuous_snd [UniformSpace α] [UniformSpace β] :
UniformContinuous fun p : α à β => p.2 :=
tendsto_prod_uniformity_snd
variable [UniformSpace α] [UniformSpace β] [UniformSpace γ]
theorem UniformContinuous.prodMk {fâ : α â β} {fâ : α â γ} (hâ : UniformContinuous fâ)
(hâ : UniformContinuous fâ) : UniformContinuous fun a => (fâ a, fâ a) := by
rw [UniformContinuous, uniformity_prod]
exact tendsto_inf.2 âštendsto_comap_iff.2 hâ, tendsto_comap_iff.2 hââ©
@[deprecated (since := "2025-03-10")]
alias UniformContinuous.prod_mk := UniformContinuous.prodMk
theorem UniformContinuous.prodMk_left {f : α à β â γ} (h : UniformContinuous f) (b) :
UniformContinuous fun a => f (a, b) :=
h.comp (uniformContinuous_id.prodMk uniformContinuous_const)
@[deprecated (since := "2025-03-10")]
alias UniformContinuous.prod_mk_left := UniformContinuous.prodMk_left
theorem UniformContinuous.prodMk_right {f : α à β â γ} (h : UniformContinuous f) (a) :
UniformContinuous fun b => f (a, b) :=
h.comp (uniformContinuous_const.prodMk uniformContinuous_id)
@[deprecated (since := "2025-03-10")]
alias UniformContinuous.prod_mk_right := UniformContinuous.prodMk_right
theorem UniformContinuous.prodMap [UniformSpace ÎŽ] {f : α â γ} {g : β â ÎŽ}
(hf : UniformContinuous f) (hg : UniformContinuous g) : UniformContinuous (Prod.map f g) :=
(hf.comp uniformContinuous_fst).prodMk (hg.comp uniformContinuous_snd)
theorem toTopologicalSpace_prod {α} {β} [u : UniformSpace α] [v : UniformSpace β] :
@UniformSpace.toTopologicalSpace (α à β) instUniformSpaceProd =
@instTopologicalSpaceProd α β u.toTopologicalSpace v.toTopologicalSpace :=
rfl
/-- A version of `UniformContinuous.inf_dom_left` for binary functions -/
theorem uniformContinuous_inf_dom_leftâ {α β γ} {f : α â β â γ} {ua1 ua2 : UniformSpace α}
{ub1 ub2 : UniformSpace β} {uc1 : UniformSpace γ}
(h : by haveI := ua1; haveI := ub1; exact UniformContinuous fun p : α à β => f p.1 p.2) : by
haveI := ua1 â ua2; haveI := ub1 â ub2
exact UniformContinuous fun p : α à β => f p.1 p.2 := by
-- proof essentially copied from `continuous_inf_dom_leftâ`
have ha := @UniformContinuous.inf_dom_left _ _ id ua1 ua2 ua1 (@uniformContinuous_id _ (id _))
have hb := @UniformContinuous.inf_dom_left _ _ id ub1 ub2 ub1 (@uniformContinuous_id _ (id _))
have h_unif_cont_id :=
@UniformContinuous.prodMap _ _ _ _ (ua1 â ua2) (ub1 â ub2) ua1 ub1 _ _ ha hb
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id
/-- A version of `UniformContinuous.inf_dom_right` for binary functions -/
theorem uniformContinuous_inf_dom_rightâ {α β γ} {f : α â β â γ} {ua1 ua2 : UniformSpace α}
{ub1 ub2 : UniformSpace β} {uc1 : UniformSpace γ}
(h : by haveI := ua2; haveI := ub2; exact UniformContinuous fun p : α à β => f p.1 p.2) : by
haveI := ua1 â ua2; haveI := ub1 â ub2
exact UniformContinuous fun p : α à β => f p.1 p.2 := by
-- proof essentially copied from `continuous_inf_dom_rightâ`
have ha := @UniformContinuous.inf_dom_right _ _ id ua1 ua2 ua2 (@uniformContinuous_id _ (id _))
have hb := @UniformContinuous.inf_dom_right _ _ id ub1 ub2 ub2 (@uniformContinuous_id _ (id _))
have h_unif_cont_id :=
@UniformContinuous.prodMap _ _ _ _ (ua1 â ua2) (ub1 â ub2) ua2 ub2 _ _ ha hb
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id
/-- A version of `uniformContinuous_sInf_dom` for binary functions -/
theorem uniformContinuous_sInf_domâ {α β γ} {f : α â β â γ} {uas : Set (UniformSpace α)}
{ubs : Set (UniformSpace β)} {ua : UniformSpace α} {ub : UniformSpace β} {uc : UniformSpace γ}
(ha : ua â uas) (hb : ub â ubs) (hf : UniformContinuous fun p : α à β => f p.1 p.2) : by
haveI := sInf uas; haveI := sInf ubs
exact @UniformContinuous _ _ _ uc fun p : α à β => f p.1 p.2 := by
-- proof essentially copied from `continuous_sInf_dom`
let _ : UniformSpace (α à β) := instUniformSpaceProd
have ha := uniformContinuous_sInf_dom ha uniformContinuous_id
have hb := uniformContinuous_sInf_dom hb uniformContinuous_id
have h_unif_cont_id := @UniformContinuous.prodMap _ _ _ _ (sInf uas) (sInf ubs) ua ub _ _ ha hb
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ hf h_unif_cont_id
end Prod
section
open UniformSpace Function
variable {Ύ' : Type*} [UniformSpace α] [UniformSpace β] [UniformSpace γ] [UniformSpace Ύ]
[UniformSpace ÎŽ']
local notation f " ââ " g => Function.bicompr f g
/-- Uniform continuity for functions of two variables. -/
def UniformContinuousâ (f : α â β â γ) :=
UniformContinuous (uncurry f)
theorem uniformContinuousâ_def (f : α â β â γ) :
UniformContinuousâ f â UniformContinuous (uncurry f) :=
Iff.rfl
theorem UniformContinuousâ.uniformContinuous {f : α â β â γ} (h : UniformContinuousâ f) :
UniformContinuous (uncurry f) :=
h
theorem uniformContinuousâ_curry (f : α à β â γ) :
UniformContinuousâ (Function.curry f) â UniformContinuous f := by
rw [UniformContinuousâ, uncurry_curry]
theorem UniformContinuousâ.comp {f : α â β â γ} {g : γ â ÎŽ} (hg : UniformContinuous g)
(hf : UniformContinuousâ f) : UniformContinuousâ (g ââ f) :=
hg.comp hf
theorem UniformContinuousâ.bicompl {f : α â β â γ} {ga : ÎŽ â α} {gb : ÎŽ' â β}
(hf : UniformContinuousâ f) (hga : UniformContinuous ga) (hgb : UniformContinuous gb) :
UniformContinuousâ (bicompl f ga gb) :=
hf.uniformContinuous.comp (hga.prodMap hgb)
end
theorem toTopologicalSpace_subtype [u : UniformSpace α] {p : α â Prop} :
@UniformSpace.toTopologicalSpace (Subtype p) instUniformSpaceSubtype =
@instTopologicalSpaceSubtype α p u.toTopologicalSpace :=
rfl
section Sum
variable [UniformSpace α] [UniformSpace β]
open Sum
-- Obsolete auxiliary definitions and lemmas
/-- Uniformity on a disjoint union. Entourages of the diagonal in the union are obtained
| by taking independently an entourage of the diagonal in the first part, and an entourage of
the diagonal in the second part. -/
instance Sum.instUniformSpace : UniformSpace (α â β) where
uniformity := map (fun p : α à α => (inl p.1, inl p.2)) (ð€ α) â
map (fun p : β à β => (inr p.1, inr p.2)) (ð€ β)
| Mathlib/Topology/UniformSpace/Basic.lean | 857 | 861 |
/-
Copyright (c) 2024 Jeremy Tan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Tan
-/
import Mathlib.Data.Int.Interval
import Mathlib.Data.Int.ModEq
import Mathlib.Data.Nat.Count
import Mathlib.Data.Rat.Floor
import Mathlib.Order.Interval.Finset.Nat
/-!
# Counting elements in an interval with given residue
The theorems in this file generalise `Nat.card_multiples` in `Mathlib.Data.Nat.Factorization.Basic`
to all integer intervals and any fixed residue (not just zero, which reduces to the multiples).
Theorems are given for `Ico` and `Ioc` intervals.
-/
open Finset Int
namespace Int
variable (a b : â€) {r : â€}
lemma Ico_filter_modEq_eq (v : â€) :
{x â Ico a b | x â¡ v [ZMOD r]} =
{x â Ico (a - v) (b - v) | r ⣠x}.map âš(· + v), add_left_injective vâ© := by
ext x
simp_rw [mem_map, mem_filter, mem_Ico, Function.Embedding.coeFn_mk, â eq_sub_iff_add_eq,
exists_eq_right, modEq_comm, modEq_iff_dvd, sub_lt_sub_iff_right, sub_le_sub_iff_right]
lemma Ioc_filter_modEq_eq (v : â€) :
{x â Ioc a b | x â¡ v [ZMOD r]} =
{x â Ioc (a - v) (b - v) | r ⣠x}.map âš(· + v), add_left_injective vâ© := by
ext x
simp_rw [mem_map, mem_filter, mem_Ioc, Function.Embedding.coeFn_mk, â eq_sub_iff_add_eq,
exists_eq_right, modEq_comm, modEq_iff_dvd, sub_lt_sub_iff_right, sub_le_sub_iff_right]
variable (hr : 0 < r)
include hr
lemma Ico_filter_dvd_eq :
{x â Ico a b | r ⣠x} =
(Ico âa / (r : â)â âb / (r : â)â).map âš(· * r), mul_left_injectiveâ hr.ne'â© := by
ext x
simp only [mem_map, mem_filter, mem_Ico, ceil_le, lt_ceil, div_le_iffâ, lt_div_iffâ,
dvd_iff_exists_eq_mul_left, cast_pos.2 hr, â cast_mul, cast_lt, cast_le]
aesop
lemma Ioc_filter_dvd_eq :
{x â Ioc a b | r ⣠x} =
(Ioc âa / (r : â)â âb / (r : â)â).map âš(· * r), mul_left_injectiveâ hr.ne'â© := by
ext x
simp only [mem_map, mem_filter, mem_Ioc, floor_lt, le_floor, div_lt_iffâ, le_div_iffâ,
dvd_iff_exists_eq_mul_left, cast_pos.2 hr, â cast_mul, cast_lt, cast_le]
aesop
/-- There are `âb / râ - âa / râ` multiples of `r` in `[a, b)`, if `a †b`. -/
theorem Ico_filter_dvd_card : #{x â Ico a b | r ⣠x} = max (âb / (r : â)â - âa / (r : â)â) 0 := by
rw [Ico_filter_dvd_eq _ _ hr, card_map, card_Ico, toNat_eq_max]
/-- There are `âb / râ - âa / râ` multiples of `r` in `(a, b]`, if `a †b`. -/
theorem Ioc_filter_dvd_card : #{x â Ioc a b | r ⣠x} = max (âb / (r : â)â - âa / (r : â)â) 0 := by
rw [Ioc_filter_dvd_eq _ _ hr, card_map, card_Ioc, toNat_eq_max]
/-- There are `â(b - v) / râ - â(a - v) / râ` numbers congruent to `v` mod `r` in `[a, b)`,
if `a †b`. -/
theorem Ico_filter_modEq_card (v : â€) :
#{x â Ico a b | x â¡ v [ZMOD r]} = max (â(b - v) / (r : â)â - â(a - v) / (r : â)â) 0 := by
simp [Ico_filter_modEq_eq, Ico_filter_dvd_eq, toNat_eq_max, hr]
/-- There are `â(b - v) / râ - â(a - v) / râ` numbers congruent to `v` mod `r` in `(a, b]`,
if `a †b`. -/
theorem Ioc_filter_modEq_card (v : â€) :
#{x â Ioc a b | x â¡ v [ZMOD r]} = max (â(b - v) / (r : â)â - â(a - v) / (r : â)â) 0 := by
simp [Ioc_filter_modEq_eq, Ioc_filter_dvd_eq, toNat_eq_max, hr]
| end Int
namespace Nat
variable (a b : â) {r : â}
lemma Ico_filter_modEq_cast {v : â} :
| Mathlib/Data/Int/CardIntervalMod.lean | 81 | 87 |
/-
Copyright (c) 2020 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot
-/
import Mathlib.Topology.Path
/-!
# Path connectedness
Continuing from `Mathlib.Topology.Path`, this file defines path components and path-connected
spaces.
## Main definitions
In the file the unit interval `[0, 1]` in `â` is denoted by `I`, and `X` is a topological space.
* `Joined (x y : X)` means there is a path between `x` and `y`.
* `Joined.somePath (h : Joined x y)` selects some path between two points `x` and `y`.
* `pathComponent (x : X)` is the set of points joined to `x`.
* `PathConnectedSpace X` is a predicate class asserting that `X` is non-empty and every two
points of `X` are joined.
Then there are corresponding relative notions for `F : Set X`.
* `JoinedIn F (x y : X)` means there is a path `γ` joining `x` to `y` with values in `F`.
* `JoinedIn.somePath (h : JoinedIn F x y)` selects a path from `x` to `y` inside `F`.
* `pathComponentIn F (x : X)` is the set of points joined to `x` in `F`.
* `IsPathConnected F` asserts that `F` is non-empty and every two
points of `F` are joined in `F`.
## Main theorems
* `Joined` is an equivalence relation, while `JoinedIn F` is at least symmetric and transitive.
One can link the absolute and relative version in two directions, using `(univ : Set X)` or the
subtype `â¥F`.
* `pathConnectedSpace_iff_univ : PathConnectedSpace X â IsPathConnected (univ : Set X)`
* `isPathConnected_iff_pathConnectedSpace : IsPathConnected F â PathConnectedSpace â¥F`
Furthermore, it is shown that continuous images and quotients of path-connected sets/spaces are
path-connected, and that every path-connected set/space is also connected.
-/
noncomputable section
open Topology Filter unitInterval Set Function
variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {x y z : X} {ι : Type*}
/-! ### Being joined by a path -/
/-- The relation "being joined by a path". This is an equivalence relation. -/
def Joined (x y : X) : Prop :=
Nonempty (Path x y)
@[refl]
theorem Joined.refl (x : X) : Joined x x :=
âšPath.refl xâ©
/-- When two points are joined, choose some path from `x` to `y`. -/
def Joined.somePath (h : Joined x y) : Path x y :=
Nonempty.some h
@[symm]
theorem Joined.symm {x y : X} (h : Joined x y) : Joined y x :=
âšh.somePath.symmâ©
@[trans]
theorem Joined.trans {x y z : X} (hxy : Joined x y) (hyz : Joined y z) : Joined x z :=
âšhxy.somePath.trans hyz.somePathâ©
variable (X)
/-- The setoid corresponding the equivalence relation of being joined by a continuous path. -/
def pathSetoid : Setoid X where
r := Joined
iseqv := Equivalence.mk Joined.refl Joined.symm Joined.trans
/-- The quotient type of points of a topological space modulo being joined by a continuous path. -/
def ZerothHomotopy :=
Quotient (pathSetoid X)
instance ZerothHomotopy.inhabited : Inhabited (ZerothHomotopy â) :=
âš@Quotient.mk' â (pathSetoid â) 0â©
variable {X}
/-! ### Being joined by a path inside a set -/
/-- The relation "being joined by a path in `F`". Not quite an equivalence relation since it's not
reflexive for points that do not belong to `F`. -/
def JoinedIn (F : Set X) (x y : X) : Prop :=
â γ : Path x y, â t, γ t â F
variable {F : Set X}
theorem JoinedIn.mem (h : JoinedIn F x y) : x â F â§ y â F := by
rcases h with âšÎ³, γ_inâ©
have : γ 0 â F ⧠γ 1 â F := by constructor <;> apply γ_in
simpa using this
theorem JoinedIn.source_mem (h : JoinedIn F x y) : x â F :=
h.mem.1
theorem JoinedIn.target_mem (h : JoinedIn F x y) : y â F :=
h.mem.2
/-- When `x` and `y` are joined in `F`, choose a path from `x` to `y` inside `F` -/
def JoinedIn.somePath (h : JoinedIn F x y) : Path x y :=
Classical.choose h
theorem JoinedIn.somePath_mem (h : JoinedIn F x y) (t : I) : h.somePath t â F :=
Classical.choose_spec h t
/-- If `x` and `y` are joined in the set `F`, then they are joined in the subtype `F`. -/
theorem JoinedIn.joined_subtype (h : JoinedIn F x y) :
Joined (âšx, h.source_memâ© : F) (âšy, h.target_memâ© : F) :=
âš{ toFun := fun t => âšh.somePath t, h.somePath_mem tâ©
continuous_toFun := by fun_prop
source' := by simp
target' := by simp }â©
theorem JoinedIn.ofLine {f : â â X} (hf : ContinuousOn f I) (hâ : f 0 = x) (hâ : f 1 = y)
(hF : f '' I â F) : JoinedIn F x y :=
âšPath.ofLine hf hâ hâ, fun t => hF <| Path.ofLine_mem hf hâ hâ tâ©
theorem JoinedIn.joined (h : JoinedIn F x y) : Joined x y :=
âšh.somePathâ©
theorem joinedIn_iff_joined (x_in : x â F) (y_in : y â F) :
JoinedIn F x y â Joined (âšx, x_inâ© : F) (âšy, y_inâ© : F) :=
âšfun h => h.joined_subtype, fun h => âšh.somePath.map continuous_subtype_val, by simpâ©â©
@[simp]
theorem joinedIn_univ : JoinedIn univ x y â Joined x y := by
simp [JoinedIn, Joined, exists_true_iff_nonempty]
theorem JoinedIn.mono {U V : Set X} (h : JoinedIn U x y) (hUV : U â V) : JoinedIn V x y :=
âšh.somePath, fun t => hUV (h.somePath_mem t)â©
theorem JoinedIn.refl (h : x â F) : JoinedIn F x x :=
âšPath.refl x, fun _t => hâ©
@[symm]
theorem JoinedIn.symm (h : JoinedIn F x y) : JoinedIn F y x := by
obtain âšhx, hyâ© := h.mem
simp_all only [joinedIn_iff_joined]
exact h.symm
theorem JoinedIn.trans (hxy : JoinedIn F x y) (hyz : JoinedIn F y z) : JoinedIn F x z := by
obtain âšhx, hyâ© := hxy.mem
obtain âšhx, hyâ© := hyz.mem
simp_all only [joinedIn_iff_joined]
exact hxy.trans hyz
theorem Specializes.joinedIn (h : x ″ y) (hx : x â F) (hy : y â F) : JoinedIn F x y := by
refine âšâšâšSet.piecewise {1} (const I y) (const I x), ?_â©, by simp, by simpâ©, fun t ⊠?_â©
· exact isClosed_singleton.continuous_piecewise_of_specializes continuous_const continuous_const
fun _ ⊠h
· simp only [Path.coe_mk_mk, piecewise]
split_ifs <;> assumption
theorem Inseparable.joinedIn (h : Inseparable x y) (hx : x â F) (hy : y â F) : JoinedIn F x y :=
h.specializes.joinedIn hx hy
theorem JoinedIn.map_continuousOn (h : JoinedIn F x y) {f : X â Y} (hf : ContinuousOn f F) :
JoinedIn (f '' F) (f x) (f y) :=
let âšÎ³, hγ⩠:= h
âšÎ³.map' <| hf.mono (range_subset_iff.mpr hγ), fun t ⊠mem_image_of_mem _ (hγ t)â©
theorem JoinedIn.map (h : JoinedIn F x y) {f : X â Y} (hf : Continuous f) :
JoinedIn (f '' F) (f x) (f y) :=
h.map_continuousOn hf.continuousOn
theorem Topology.IsInducing.joinedIn_image {f : X â Y} (hf : IsInducing f) (hx : x â F)
(hy : y â F) : JoinedIn (f '' F) (f x) (f y) â JoinedIn F x y := by
refine âš?_, (.map · hf.continuous)â©
rintro âšÎ³, hγâ©
choose γ' hγ'F hγ' using hγ
have hâ : x ″ γ' 0 := by rw [â hf.specializes_iff, hγ', γ.source]
have hâ : γ' 1 ″ y := by rw [â hf.specializes_iff, hγ', γ.target]
have h : JoinedIn F (γ' 0) (γ' 1) := by
refine âšâšâšÎ³', ?_â©, rfl, rflâ©, hγ'Fâ©
simpa only [hf.continuous_iff, comp_def, hγ'] using map_continuous γ
exact (hâ.joinedIn hx (hγ'F _)).trans <| h.trans <| hâ.joinedIn (hγ'F _) hy
@[deprecated (since := "2024-10-28")] alias Inducing.joinedIn_image := IsInducing.joinedIn_image
/-! ### Path component -/
/-- The path component of `x` is the set of points that can be joined to `x`. -/
def pathComponent (x : X) :=
{ y | Joined x y }
theorem mem_pathComponent_iff : x â pathComponent y â Joined y x := .rfl
@[simp]
theorem mem_pathComponent_self (x : X) : x â pathComponent x :=
Joined.refl x
@[simp]
theorem pathComponent.nonempty (x : X) : (pathComponent x).Nonempty :=
âšx, mem_pathComponent_self xâ©
theorem mem_pathComponent_of_mem (h : x â pathComponent y) : y â pathComponent x :=
Joined.symm h
theorem pathComponent_symm : x â pathComponent y â y â pathComponent x :=
âšfun h => mem_pathComponent_of_mem h, fun h => mem_pathComponent_of_mem hâ©
theorem pathComponent_congr (h : x â pathComponent y) : pathComponent x = pathComponent y := by
ext z
constructor
· intro h'
rw [pathComponent_symm]
exact (h.trans h').symm
· intro h'
rw [pathComponent_symm] at h' â¢
exact h'.trans h
theorem pathComponent_subset_component (x : X) : pathComponent x â connectedComponent x :=
fun y h =>
(isConnected_range h.somePath.continuous).subset_connectedComponent âš0, by simpâ© âš1, by simpâ©
/-- The path component of `x` in `F` is the set of points that can be joined to `x` in `F`. -/
def pathComponentIn (x : X) (F : Set X) :=
{ y | JoinedIn F x y }
@[simp]
theorem pathComponentIn_univ (x : X) : pathComponentIn x univ = pathComponent x := by
simp [pathComponentIn, pathComponent, JoinedIn, Joined, exists_true_iff_nonempty]
theorem Joined.mem_pathComponent (hyz : Joined y z) (hxy : y â pathComponent x) :
z â pathComponent x :=
hxy.trans hyz
theorem mem_pathComponentIn_self (h : x â F) : x â pathComponentIn x F :=
JoinedIn.refl h
theorem pathComponentIn_subset : pathComponentIn x F â F :=
fun _ hy ⊠hy.target_mem
theorem pathComponentIn_nonempty_iff : (pathComponentIn x F).Nonempty â x â F :=
âšfun âš_, âšÎ³, hγâ©â© ⊠γ.source âž hγ 0, fun hx ⊠âšx, mem_pathComponentIn_self hxâ©â©
theorem pathComponentIn_congr (h : x â pathComponentIn y F) :
pathComponentIn x F = pathComponentIn y F := by
ext; exact âšh.trans, h.symm.transâ©
@[gcongr]
theorem pathComponentIn_mono {G : Set X} (h : F â G) :
pathComponentIn x F â pathComponentIn x G :=
fun _ âšÎ³, hγ⩠⊠âšÎ³, fun t ⊠h (hγ t)â©
/-! ### Path connected sets -/
/-- A set `F` is path connected if it contains a point that can be joined to all other in `F`. -/
def IsPathConnected (F : Set X) : Prop :=
â x â F, â {y}, y â F â JoinedIn F x y
theorem isPathConnected_iff_eq : IsPathConnected F â â x â F, pathComponentIn x F = F := by
constructor <;> rintro âšx, x_in, hâ© <;> use x, x_in
· ext y
exact âšfun hy => hy.mem.2, hâ©
· intro y y_in
rwa [â h] at y_in
theorem IsPathConnected.joinedIn (h : IsPathConnected F) :
âáµ (x â F) (y â F), JoinedIn F x y := fun _x x_in _y y_in =>
let âš_b, _b_in, hbâ© := h
(hb x_in).symm.trans (hb y_in)
theorem isPathConnected_iff :
IsPathConnected F â F.Nonempty â§ âáµ (x â F) (y â F), JoinedIn F x y :=
âšfun h =>
âšlet âšb, b_in, _hbâ© := h; âšb, b_inâ©, h.joinedInâ©,
fun âšâšb, b_inâ©, hâ© => âšb, b_in, fun x_in => h _ b_in _ x_inâ©â©
/-- If `f` is continuous on `F` and `F` is path-connected, so is `f(F)`. -/
theorem IsPathConnected.image' (hF : IsPathConnected F)
{f : X â Y} (hf : ContinuousOn f F) : IsPathConnected (f '' F) := by
rcases hF with âšx, x_in, hxâ©
use f x, mem_image_of_mem f x_in
rintro _ âšy, y_in, rflâ©
refine âš(hx y_in).somePath.map' ?_, fun t ⊠âš_, (hx y_in).somePath_mem t, rflâ©â©
exact hf.mono (range_subset_iff.2 (hx y_in).somePath_mem)
/-- If `f` is continuous and `F` is path-connected, so is `f(F)`. -/
theorem IsPathConnected.image (hF : IsPathConnected F) {f : X â Y} (hf : Continuous f) :
IsPathConnected (f '' F) :=
hF.image' hf.continuousOn
/-- If `f : X â Y` is an inducing map, `f(F)` is path-connected iff `F` is. -/
nonrec theorem Topology.IsInducing.isPathConnected_iff {f : X â Y} (hf : IsInducing f) :
IsPathConnected F â IsPathConnected (f '' F) := by
simp only [IsPathConnected, forall_mem_image, exists_mem_image]
refine exists_congr fun x ⊠and_congr_right fun hx ⊠forallâ_congr fun y hy ⊠?_
rw [hf.joinedIn_image hx hy]
@[deprecated (since := "2024-10-28")]
alias Inducing.isPathConnected_iff := IsInducing.isPathConnected_iff
/-- If `h : X â Y` is a homeomorphism, `h(s)` is path-connected iff `s` is. -/
@[simp]
theorem Homeomorph.isPathConnected_image {s : Set X} (h : X ââ Y) :
IsPathConnected (h '' s) â IsPathConnected s :=
h.isInducing.isPathConnected_iff.symm
/-- If `h : X â Y` is a homeomorphism, `hâ»Â¹(s)` is path-connected iff `s` is. -/
@[simp]
theorem Homeomorph.isPathConnected_preimage {s : Set Y} (h : X ââ Y) :
IsPathConnected (h â»Â¹' s) â IsPathConnected s := by
rw [â Homeomorph.image_symm]; exact h.symm.isPathConnected_image
theorem IsPathConnected.mem_pathComponent (h : IsPathConnected F) (x_in : x â F) (y_in : y â F) :
y â pathComponent x :=
(h.joinedIn x x_in y y_in).joined
theorem IsPathConnected.subset_pathComponent (h : IsPathConnected F) (x_in : x â F) :
F â pathComponent x := fun _y y_in => h.mem_pathComponent x_in y_in
theorem IsPathConnected.subset_pathComponentIn {s : Set X} (hs : IsPathConnected s)
(hxs : x â s) (hsF : s â F) : s â pathComponentIn x F :=
fun y hys ⊠(hs.joinedIn x hxs y hys).mono hsF
theorem isPathConnected_singleton (x : X) : IsPathConnected ({x} : Set X) := by
refine âšx, rfl, ?_â©
rintro y rfl
exact JoinedIn.refl rfl
theorem isPathConnected_pathComponentIn (h : x â F) : IsPathConnected (pathComponentIn x F) :=
âšx, mem_pathComponentIn_self h, fun âšÎ³, hγ⩠⊠by
refine âšÎ³, fun t âŠ
âš(γ.truncateOfLE t.2.1).cast (γ.extend_zero.symm) (γ.extend_extends' t).symm, fun t' ⊠?_â©â©
dsimp [Path.truncateOfLE, Path.truncate]
exact γ.extend_extends' âšmin (max t'.1 0) t.1, by simp [t.2.1, t.2.2]â© âž hγ _â©
theorem isPathConnected_pathComponent : IsPathConnected (pathComponent x) := by
rw [â pathComponentIn_univ]
exact isPathConnected_pathComponentIn (mem_univ x)
theorem IsPathConnected.union {U V : Set X} (hU : IsPathConnected U) (hV : IsPathConnected V)
(hUV : (U ⩠V).Nonempty) : IsPathConnected (U ⪠V) := by
rcases hUV with âšx, xU, xVâ©
use x, Or.inl xU
rintro y (yU | yV)
· exact (hU.joinedIn x xU y yU).mono subset_union_left
· exact (hV.joinedIn x xV y yV).mono subset_union_right
/-- If a set `W` is path-connected, then it is also path-connected when seen as a set in a smaller
ambient type `U` (when `U` contains `W`). -/
theorem IsPathConnected.preimage_coe {U W : Set X} (hW : IsPathConnected W) (hWU : W â U) :
IsPathConnected (((â) : U â X) â»Â¹' W) := by
rwa [IsInducing.subtypeVal.isPathConnected_iff, Subtype.image_preimage_val, inter_eq_right.2 hWU]
theorem IsPathConnected.exists_path_through_family {n : â}
{s : Set X} (h : IsPathConnected s) (p : Fin (n + 1) â X) (hp : â i, p i â s) :
â γ : Path (p 0) (p n), range γ â s â§ â i, p i â range γ := by
let p' : â â X := fun k => if h : k < n + 1 then p âšk, hâ© else p âš0, n.zero_lt_succâ©
obtain âšÎ³, hγ⩠: â γ : Path (p' 0) (p' n), (â i †n, p' i â range γ) â§ range γ â s := by
have hp' : â i †n, p' i â s := by
intro i hi
simp [p', Nat.lt_succ_of_le hi, hp]
clear_value p'
clear hp p
induction n with
| zero =>
use Path.refl (p' 0)
constructor
· rintro i hi
rw [Nat.le_zero.mp hi]
exact âš0, rflâ©
· rw [range_subset_iff]
rintro _x
exact hp' 0 le_rfl
| succ n hn =>
rcases hn fun i hi => hp' i <| Nat.le_succ_of_le hi with âšÎ³â, hγââ©
rcases h.joinedIn (p' n) (hp' n n.le_succ) (p' <| n + 1) (hp' (n + 1) <| le_rfl) with
âšÎ³â, hγââ©
let γ : Path (p' 0) (p' <| n + 1) := γâ.trans γâ
use γ
have range_eq : range γ = range γâ ⪠range γâ := γâ.trans_range γâ
constructor
· rintro i hi
by_cases hi' : i †n
· rw [range_eq]
left
exact hγâ.1 i hi'
· rw [not_le, â Nat.succ_le_iff] at hi'
have : i = n.succ := le_antisymm hi hi'
rw [this]
use 1
exact γ.target
· rw [range_eq]
apply union_subset hγâ.2
rw [range_subset_iff]
exact hγâ
have hpp' : â k < n + 1, p k = p' k := by
intro k hk
simp only [p', hk, dif_pos]
congr
ext
rw [Fin.val_cast_of_lt hk]
use γ.cast (hpp' 0 n.zero_lt_succ) (hpp' n n.lt_succ_self)
simp only [γ.cast_coe]
refine And.intro hγ.2 ?_
rintro âši, hiâ©
suffices p âši, hiâ© = p' i by convert hγ.1 i (Nat.le_of_lt_succ hi)
rw [â hpp' i hi]
suffices i = i % n.succ by congr
rw [Nat.mod_eq_of_lt hi]
theorem IsPathConnected.exists_path_through_family' {n : â}
{s : Set X} (h : IsPathConnected s) (p : Fin (n + 1) â X) (hp : â i, p i â s) :
â (γ : Path (p 0) (p n)) (t : Fin (n + 1) â I), (â t, γ t â s) â§ â i, γ (t i) = p i := by
rcases h.exists_path_through_family p hp with âšÎ³, hγâ©
rcases hγ with âšhâ, hââ©
simp only [range, mem_setOf_eq] at hâ
rw [range_subset_iff] at hâ
choose! t ht using hâ
exact âšÎ³, t, hâ, htâ©
/-! ### Path connected spaces -/
/-- A topological space is path-connected if it is non-empty and every two points can be
joined by a continuous path. -/
@[mk_iff]
class PathConnectedSpace (X : Type*) [TopologicalSpace X] : Prop where
/-- A path-connected space must be nonempty. -/
nonempty : Nonempty X
/-- Any two points in a path-connected space must be joined by a continuous path. -/
joined : â x y : X, Joined x y
theorem pathConnectedSpace_iff_zerothHomotopy :
PathConnectedSpace X â Nonempty (ZerothHomotopy X) â§ Subsingleton (ZerothHomotopy X) := by
| letI := pathSetoid X
constructor
· intro h
refine âš(nonempty_quotient_iff _).mpr h.1, âš?_â©â©
rintro âšxâ© âšyâ©
| Mathlib/Topology/Connected/PathConnected.lean | 442 | 446 |
/-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Algebra.Algebra.Tower
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Topology.Algebra.Module.StrongTopology
import Mathlib.Analysis.Normed.Operator.LinearIsometry
import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap
import Mathlib.Tactic.SuppressCompilation
/-!
# Operator norm on the space of continuous linear maps
Define the operator (semi)-norm on the space of continuous (semi)linear maps between (semi)-normed
spaces, and prove its basic properties. In particular, show that this space is itself a semi-normed
space.
Since a lot of elementary properties don't require `âxâ = 0 â x = 0` we start setting up the
theory for `SeminormedAddCommGroup`. Later we will specialize to `NormedAddCommGroup` in the
file `NormedSpace.lean`.
Note that most of statements that apply to semilinear maps only hold when the ring homomorphism
is isometric, as expressed by the typeclass `[RingHomIsometric Ï]`.
-/
suppress_compilation
open Bornology
open Filter hiding map_smul
open scoped NNReal Topology Uniformity
-- the `â` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {ð ðâ ðâ E F Fâ G ð : Type*}
section SemiNormed
open Metric ContinuousLinearMap
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] [SeminormedAddCommGroup Fâ]
[SeminormedAddCommGroup G]
variable [NontriviallyNormedField ð] [NontriviallyNormedField ðâ] [NontriviallyNormedField ðâ]
[NormedSpace ð E] [NormedSpace ðâ F] [NormedSpace ð Fâ] [NormedSpace ðâ G]
{Ïââ : ð â+* ðâ} {Ïââ : ðâ â+* ðâ} {Ïââ : ð â+* ðâ} [RingHomCompTriple Ïââ Ïââ Ïââ]
variable [FunLike ð E F]
/-- If `âxâ = 0` and `f` is continuous then `âf xâ = 0`. -/
theorem norm_image_of_norm_zero [SemilinearMapClass ð Ïââ E F] (f : ð) (hf : Continuous f) {x : E}
(hx : âxâ = 0) : âf xâ = 0 := by
rw [â mem_closure_zero_iff_norm, â specializes_iff_mem_closure, â map_zero f] at *
exact hx.map hf
section
variable [RingHomIsometric Ïââ]
theorem SemilinearMapClass.bound_of_shell_semi_normed [SemilinearMapClass ð Ïââ E F] (f : ð)
{ε C : â} (ε_pos : 0 < ε) {c : ð} (hc : 1 < âcâ)
(hf : â x, ε / âcâ †âxâ â âxâ < ε â âf xâ †C * âxâ) {x : E} (hx : âxâ â 0) :
âf xâ †C * âxâ :=
(normSeminorm ð E).bound_of_shell ((normSeminorm ðâ F).comp âšâšf, map_add fâ©, map_smulââ fâ©)
ε_pos hc hf hx
/-- A continuous linear map between seminormed spaces is bounded when the field is nontrivially
normed. The continuity ensures boundedness on a ball of some radius `ε`. The nontriviality of the
norm is then used to rescale any element into an element of norm in `[ε/C, ε]`, whose image has a
controlled norm. The norm control for the original element follows by rescaling. -/
theorem SemilinearMapClass.bound_of_continuous [SemilinearMapClass ð Ïââ E F] (f : ð)
(hf : Continuous f) : â C, 0 < C â§ â x : E, âf xâ †C * âxâ :=
let Ï : E âââ[Ïââ] F := âšâšf, map_add fâ©, map_smulââ fâ©
((normSeminorm ðâ F).comp Ï).bound_of_continuous_normedSpace (continuous_norm.comp hf)
end
namespace ContinuousLinearMap
theorem bound [RingHomIsometric Ïââ] (f : E âSL[Ïââ] F) : â C, 0 < C â§ â x : E, âf xâ †C * âxâ :=
SemilinearMapClass.bound_of_continuous f f.2
section
open Filter
variable (ð E)
/-- Given a unit-length element `x` of a normed space `E` over a field `ð`, the natural linear
isometry map from `ð` to `E` by taking multiples of `x`. -/
def _root_.LinearIsometry.toSpanSingleton {v : E} (hv : âvâ = 1) : ð ââáµ¢[ð] E :=
{ LinearMap.toSpanSingleton ð E v with norm_map' := fun x => by simp [norm_smul, hv] }
variable {ð E}
@[simp]
theorem _root_.LinearIsometry.toSpanSingleton_apply {v : E} (hv : âvâ = 1) (a : ð) :
LinearIsometry.toSpanSingleton ð E hv a = a ⢠v :=
rfl
@[simp]
theorem _root_.LinearIsometry.coe_toSpanSingleton {v : E} (hv : âvâ = 1) :
(LinearIsometry.toSpanSingleton ð E hv).toLinearMap = LinearMap.toSpanSingleton ð E v :=
rfl
end
section OpNorm
open Set Real
/-- The operator norm of a continuous linear map is the inf of all its bounds. -/
def opNorm (f : E âSL[Ïââ] F) :=
sInf { c | 0 †c â§ â x, âf xâ †c * âxâ }
instance hasOpNorm : Norm (E âSL[Ïââ] F) :=
âšopNormâ©
theorem norm_def (f : E âSL[Ïââ] F) : âfâ = sInf { c | 0 †c â§ â x, âf xâ †c * âxâ } :=
rfl
-- So that invocations of `le_csInf` make sense: we show that the set of
-- bounds is nonempty and bounded below.
theorem bounds_nonempty [RingHomIsometric Ïââ] {f : E âSL[Ïââ] F} :
â c, c â { c | 0 †c â§ â x, âf xâ †c * âxâ } :=
let âšM, hMp, hMbâ© := f.bound
âšM, le_of_lt hMp, hMbâ©
theorem bounds_bddBelow {f : E âSL[Ïââ] F} : BddBelow { c | 0 †c â§ â x, âf xâ †c * âxâ } :=
âš0, fun _ âšhn, _â© => hnâ©
theorem isLeast_opNorm [RingHomIsometric Ïââ] (f : E âSL[Ïââ] F) :
IsLeast {c | 0 †c â§ â x, âf xâ †c * âxâ} âfâ := by
refine IsClosed.isLeast_csInf ?_ bounds_nonempty bounds_bddBelow
simp only [setOf_and, setOf_forall]
refine isClosed_Ici.inter <| isClosed_iInter fun _ ⊠isClosed_le ?_ ?_ <;> continuity
/-- If one controls the norm of every `A x`, then one controls the norm of `A`. -/
theorem opNorm_le_bound (f : E âSL[Ïââ] F) {M : â} (hMp : 0 †M) (hM : â x, âf xâ †M * âxâ) :
âfâ †M :=
csInf_le bounds_bddBelow âšhMp, hMâ©
/-- If one controls the norm of every `A x`, `âxâ â 0`, then one controls the norm of `A`. -/
theorem opNorm_le_bound' (f : E âSL[Ïââ] F) {M : â} (hMp : 0 †M)
(hM : â x, âxâ â 0 â âf xâ †M * âxâ) : âfâ †M :=
opNorm_le_bound f hMp fun x =>
(ne_or_eq âxâ 0).elim (hM x) fun h => by
simp only [h, mul_zero, norm_image_of_norm_zero f f.2 h, le_refl]
theorem opNorm_le_of_lipschitz {f : E âSL[Ïââ] F} {K : ââ¥0} (hf : LipschitzWith K f) : âfâ †K :=
f.opNorm_le_bound K.2 fun x => by
simpa only [dist_zero_right, f.map_zero] using hf.dist_le_mul x 0
theorem opNorm_eq_of_bounds {Ï : E âSL[Ïââ] F} {M : â} (M_nonneg : 0 †M)
(h_above : â x, âÏ xâ †M * âxâ) (h_below : â N ⥠0, (â x, âÏ xâ †N * âxâ) â M †N) :
âÏâ = M :=
le_antisymm (Ï.opNorm_le_bound M_nonneg h_above)
((le_csInf_iff ContinuousLinearMap.bounds_bddBelow âšM, M_nonneg, h_aboveâ©).mpr
fun N âšN_nonneg, hNâ© => h_below N N_nonneg hN)
theorem opNorm_neg (f : E âSL[Ïââ] F) : â-fâ = âfâ := by simp only [norm_def, neg_apply, norm_neg]
theorem opNorm_nonneg (f : E âSL[Ïââ] F) : 0 †âfâ :=
Real.sInf_nonneg fun _ ⊠And.left
/-- The norm of the `0` operator is `0`. -/
theorem opNorm_zero : â(0 : E âSL[Ïââ] F)â = 0 :=
le_antisymm (opNorm_le_bound _ le_rfl fun _ ⊠by simp) (opNorm_nonneg _)
/-- The norm of the identity is at most `1`. It is in fact `1`, except when the space is trivial
where it is `0`. It means that one can not do better than an inequality in general. -/
theorem norm_id_le : âid ð Eâ †1 :=
opNorm_le_bound _ zero_le_one fun x => by simp
section
variable [RingHomIsometric Ïââ] [RingHomIsometric Ïââ] (f g : E âSL[Ïââ] F) (h : F âSL[Ïââ] G)
(x : E)
/-- The fundamental property of the operator norm: `âf xâ †âfâ * âxâ`. -/
theorem le_opNorm : âf xâ †âfâ * âxâ := (isLeast_opNorm f).1.2 x
theorem dist_le_opNorm (x y : E) : dist (f x) (f y) †âfâ * dist x y := by
simp_rw [dist_eq_norm, â map_sub, f.le_opNorm]
theorem le_of_opNorm_le_of_le {x} {a b : â} (hf : âfâ †a) (hx : âxâ †b) :
âf xâ †a * b :=
(f.le_opNorm x).trans <| by gcongr; exact (opNorm_nonneg f).trans hf
theorem le_opNorm_of_le {c : â} {x} (h : âxâ †c) : âf xâ †âfâ * c :=
f.le_of_opNorm_le_of_le le_rfl h
theorem le_of_opNorm_le {c : â} (h : âfâ †c) (x : E) : âf xâ †c * âxâ :=
f.le_of_opNorm_le_of_le h le_rfl
| theorem opNorm_le_iff {f : E âSL[Ïââ] F} {M : â} (hMp : 0 †M) :
âfâ †M â â x, âf xâ †M * âxâ :=
| Mathlib/Analysis/NormedSpace/OperatorNorm/Basic.lean | 210 | 211 |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
-/
import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Data.Nat.Factorization.Defs
import Mathlib.Analysis.NormedSpace.Real
import Mathlib.Data.Rat.Cast.CharZero
/-!
# Real logarithm
In this file we define `Real.log` to be the logarithm of a real number. As usual, we extend it from
its domain `(0, +â)` to a globally defined function. We choose to do it so that `log 0 = 0` and
`log (-x) = log x`.
We prove some basic properties of this function and show that it is continuous.
## Tags
logarithm, continuity
-/
open Set Filter Function
open Topology
noncomputable section
namespace Real
variable {x y : â}
/-- The real logarithm function, equal to the inverse of the exponential for `x > 0`,
to `log |x|` for `x < 0`, and to `0` for `0`. We use this unconventional extension to
`(-â, 0]` as it gives the formula `log (x * y) = log x + log y` for all nonzero `x` and `y`, and
the derivative of `log` is `1/x` away from `0`. -/
@[pp_nodot]
noncomputable def log (x : â) : â :=
if hx : x = 0 then 0 else expOrderIso.symm âš|x|, abs_pos.2 hxâ©
theorem log_of_ne_zero (hx : x â 0) : log x = expOrderIso.symm âš|x|, abs_pos.2 hxâ© :=
dif_neg hx
theorem log_of_pos (hx : 0 < x) : log x = expOrderIso.symm âšx, hxâ© := by
rw [log_of_ne_zero hx.ne']
congr
exact abs_of_pos hx
theorem exp_log_eq_abs (hx : x â 0) : exp (log x) = |x| := by
rw [log_of_ne_zero hx, â coe_expOrderIso_apply, OrderIso.apply_symm_apply, Subtype.coe_mk]
theorem exp_log (hx : 0 < x) : exp (log x) = x := by
rw [exp_log_eq_abs hx.ne']
exact abs_of_pos hx
theorem exp_log_of_neg (hx : x < 0) : exp (log x) = -x := by
rw [exp_log_eq_abs (ne_of_lt hx)]
exact abs_of_neg hx
theorem le_exp_log (x : â) : x †exp (log x) := by
by_cases h_zero : x = 0
· rw [h_zero, log, dif_pos rfl, exp_zero]
exact zero_le_one
· rw [exp_log_eq_abs h_zero]
exact le_abs_self _
@[simp]
theorem log_exp (x : â) : log (exp x) = x :=
exp_injective <| exp_log (exp_pos x)
theorem exp_one_mul_le_exp {x : â} : exp 1 * x †exp x := by
by_cases hx0 : x †0
· apply le_trans (mul_nonpos_of_nonneg_of_nonpos (exp_pos 1).le hx0) (exp_nonneg x)
· have h := add_one_le_exp (log x)
rwa [â exp_le_exp, exp_add, exp_log (lt_of_not_le hx0), mul_comm] at h
theorem two_mul_le_exp {x : â} : 2 * x †exp x := by
by_cases hx0 : x < 0
· exact le_trans (mul_nonpos_of_nonneg_of_nonpos (by simp only [Nat.ofNat_nonneg]) hx0.le)
(exp_nonneg x)
· apply le_trans (mul_le_mul_of_nonneg_right _ (le_of_not_lt hx0)) exp_one_mul_le_exp
have := Real.add_one_le_exp 1
rwa [one_add_one_eq_two] at this
theorem surjOn_log : SurjOn log (Ioi 0) univ := fun x _ => âšexp x, exp_pos x, log_exp xâ©
theorem log_surjective : Surjective log := fun x => âšexp x, log_exp xâ©
@[simp]
theorem range_log : range log = univ :=
log_surjective.range_eq
@[simp]
theorem log_zero : log 0 = 0 :=
dif_pos rfl
@[simp]
theorem log_one : log 1 = 0 :=
exp_injective <| by rw [exp_log zero_lt_one, exp_zero]
/-- This holds true for all `x : â` because of the junk values `0 / 0 = 0` and `log 0 = 0`. -/
@[simp] lemma log_div_self (x : â) : log (x / x) = 0 := by
obtain rfl | hx := eq_or_ne x 0 <;> simp [*]
@[simp]
theorem log_abs (x : â) : log |x| = log x := by
by_cases h : x = 0
· simp [h]
· rw [â exp_eq_exp, exp_log_eq_abs h, exp_log_eq_abs (abs_pos.2 h).ne', abs_abs]
@[simp]
theorem log_neg_eq_log (x : â) : log (-x) = log x := by rw [â log_abs x, â log_abs (-x), abs_neg]
theorem sinh_log {x : â} (hx : 0 < x) : sinh (log x) = (x - xâ»Â¹) / 2 := by
rw [sinh_eq, exp_neg, exp_log hx]
theorem cosh_log {x : â} (hx : 0 < x) : cosh (log x) = (x + xâ»Â¹) / 2 := by
rw [cosh_eq, exp_neg, exp_log hx]
theorem surjOn_log' : SurjOn log (Iio 0) univ := fun x _ =>
âš-exp x, neg_lt_zero.2 <| exp_pos x, by rw [log_neg_eq_log, log_exp]â©
theorem log_mul (hx : x â 0) (hy : y â 0) : log (x * y) = log x + log y :=
exp_injective <| by
rw [exp_log_eq_abs (mul_ne_zero hx hy), exp_add, exp_log_eq_abs hx, exp_log_eq_abs hy, abs_mul]
theorem log_div (hx : x â 0) (hy : y â 0) : log (x / y) = log x - log y :=
exp_injective <| by
rw [exp_log_eq_abs (div_ne_zero hx hy), exp_sub, exp_log_eq_abs hx, exp_log_eq_abs hy, abs_div]
@[simp]
theorem log_inv (x : â) : log xâ»Â¹ = -log x := by
by_cases hx : x = 0; · simp [hx]
rw [â exp_eq_exp, exp_log_eq_abs (inv_ne_zero hx), exp_neg, exp_log_eq_abs hx, abs_inv]
theorem log_le_log_iff (h : 0 < x) (hâ : 0 < y) : log x †log y â x †y := by
rw [â exp_le_exp, exp_log h, exp_log hâ]
@[gcongr, bound]
lemma log_le_log (hx : 0 < x) (hxy : x †y) : log x †log y :=
(log_le_log_iff hx (hx.trans_le hxy)).2 hxy
@[gcongr, bound]
theorem log_lt_log (hx : 0 < x) (h : x < y) : log x < log y := by
rwa [â exp_lt_exp, exp_log hx, exp_log (lt_trans hx h)]
theorem log_lt_log_iff (hx : 0 < x) (hy : 0 < y) : log x < log y â x < y := by
rw [â exp_lt_exp, exp_log hx, exp_log hy]
theorem log_le_iff_le_exp (hx : 0 < x) : log x †y â x †exp y := by rw [â exp_le_exp, exp_log hx]
theorem log_lt_iff_lt_exp (hx : 0 < x) : log x < y â x < exp y := by rw [â exp_lt_exp, exp_log hx]
theorem le_log_iff_exp_le (hy : 0 < y) : x †log y â exp x †y := by rw [â exp_le_exp, exp_log hy]
theorem lt_log_iff_exp_lt (hy : 0 < y) : x < log y â exp x < y := by rw [â exp_lt_exp, exp_log hy]
theorem log_pos_iff (hx : 0 †x) : 0 < log x â 1 < x := by
rcases hx.eq_or_lt with (rfl | hx)
· simp [le_refl, zero_le_one]
rw [â log_one]
exact log_lt_log_iff zero_lt_one hx
@[bound]
theorem log_pos (hx : 1 < x) : 0 < log x :=
(log_pos_iff (lt_trans zero_lt_one hx).le).2 hx
theorem log_pos_of_lt_neg_one (hx : x < -1) : 0 < log x := by
rw [â neg_neg x, log_neg_eq_log]
have : 1 < -x := by linarith
exact log_pos this
theorem log_neg_iff (h : 0 < x) : log x < 0 â x < 1 := by
rw [â log_one]
exact log_lt_log_iff h zero_lt_one
@[bound]
theorem log_neg (h0 : 0 < x) (h1 : x < 1) : log x < 0 :=
(log_neg_iff h0).2 h1
theorem log_neg_of_lt_zero (h0 : x < 0) (h1 : -1 < x) : log x < 0 := by
rw [â neg_neg x, log_neg_eq_log]
have h0' : 0 < -x := by linarith
have h1' : -x < 1 := by linarith
exact log_neg h0' h1'
theorem log_nonneg_iff (hx : 0 < x) : 0 †log x â 1 †x := by rw [â not_lt, log_neg_iff hx, not_lt]
@[bound]
theorem log_nonneg (hx : 1 †x) : 0 †log x :=
(log_nonneg_iff (zero_lt_one.trans_le hx)).2 hx
theorem log_nonpos_iff (hx : 0 †x) : log x †0 â x †1 := by
rcases hx.eq_or_lt with (rfl | hx)
· simp [le_refl, zero_le_one]
rw [â not_lt, log_pos_iff hx.le, not_lt]
@[deprecated (since := "2025-01-16")]
alias log_nonpos_iff' := log_nonpos_iff
@[bound]
theorem log_nonpos (hx : 0 †x) (h'x : x †1) : log x †0 :=
(log_nonpos_iff hx).2 h'x
theorem log_natCast_nonneg (n : â) : 0 †log n := by
if hn : n = 0 then
simp [hn]
else
have : (1 : â) †n := mod_cast Nat.one_le_of_lt <| Nat.pos_of_ne_zero hn
exact log_nonneg this
theorem log_neg_natCast_nonneg (n : â) : 0 †log (-n) := by
rw [â log_neg_eq_log, neg_neg]
exact log_natCast_nonneg _
theorem log_intCast_nonneg (n : â€) : 0 †log n := by
cases lt_trichotomy 0 n with
| inl hn =>
have : (1 : â) †n := mod_cast hn
exact log_nonneg this
| inr hn =>
cases hn with
| inl hn => simp [hn.symm]
| inr hn =>
have : (1 : â) †-n := by rw [â neg_zero, â lt_neg] at hn; exact mod_cast hn
rw [â log_neg_eq_log]
exact log_nonneg this
theorem strictMonoOn_log : StrictMonoOn log (Set.Ioi 0) := fun _ hx _ _ hxy => log_lt_log hx hxy
theorem strictAntiOn_log : StrictAntiOn log (Set.Iio 0) := by
rintro x (hx : x < 0) y (hy : y < 0) hxy
rw [â log_abs y, â log_abs x]
refine log_lt_log (abs_pos.2 hy.ne) ?_
rwa [abs_of_neg hy, abs_of_neg hx, neg_lt_neg_iff]
theorem log_injOn_pos : Set.InjOn log (Set.Ioi 0) :=
strictMonoOn_log.injOn
theorem log_lt_sub_one_of_pos (hx1 : 0 < x) (hx2 : x â 1) : log x < x - 1 := by
have h : log x â 0 := by
rwa [â log_one, log_injOn_pos.ne_iff hx1]
exact mem_Ioi.mpr zero_lt_one
linarith [add_one_lt_exp h, exp_log hx1]
theorem eq_one_of_pos_of_log_eq_zero {x : â} (hâ : 0 < x) (hâ : log x = 0) : x = 1 :=
log_injOn_pos (Set.mem_Ioi.2 hâ) (Set.mem_Ioi.2 zero_lt_one) (hâ.trans Real.log_one.symm)
theorem log_ne_zero_of_pos_of_ne_one {x : â} (hx_pos : 0 < x) (hx : x â 1) : log x â 0 :=
mt (eq_one_of_pos_of_log_eq_zero hx_pos) hx
@[simp]
theorem log_eq_zero {x : â} : log x = 0 â x = 0 âš x = 1 âš x = -1 := by
constructor
· intro h
rcases lt_trichotomy x 0 with (x_lt_zero | rfl | x_gt_zero)
· refine Or.inr (Or.inr (neg_eq_iff_eq_neg.mp ?_))
rw [â log_neg_eq_log x] at h
exact eq_one_of_pos_of_log_eq_zero (neg_pos.mpr x_lt_zero) h
· exact Or.inl rfl
· exact Or.inr (Or.inl (eq_one_of_pos_of_log_eq_zero x_gt_zero h))
· rintro (rfl | rfl | rfl) <;> simp only [log_one, log_zero, log_neg_eq_log]
theorem log_ne_zero {x : â} : log x â 0 â x â 0 â§ x â 1 â§ x â -1 := by
simpa only [not_or] using log_eq_zero.not
@[simp]
theorem log_pow (x : â) (n : â) : log (x ^ n) = n * log x := by
induction n with
| zero => simp
| succ n ih =>
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· rw [pow_succ, log_mul (pow_ne_zero _ hx) hx, ih, Nat.cast_succ, add_mul, one_mul]
@[simp]
theorem log_zpow (x : â) (n : â€) : log (x ^ n) = n * log x := by
cases n
· rw [Int.ofNat_eq_coe, zpow_natCast, log_pow, Int.cast_natCast]
· rw [zpow_negSucc, log_inv, log_pow, Int.cast_negSucc, Nat.cast_add_one, neg_mul_eq_neg_mul]
theorem log_sqrt {x : â} (hx : 0 †x) : log (âx) = log x / 2 := by
rw [eq_div_iff, mul_comm, â Nat.cast_two, â log_pow, sq_sqrt hx]
exact two_ne_zero
theorem log_le_sub_one_of_pos {x : â} (hx : 0 < x) : log x †x - 1 := by
rw [le_sub_iff_add_le]
convert add_one_le_exp (log x)
rw [exp_log hx]
lemma one_sub_inv_le_log_of_pos (hx : 0 < x) : 1 - xâ»Â¹ †log x := by
simpa [add_comm] using log_le_sub_one_of_pos (inv_pos.2 hx)
/-- See `Real.log_le_sub_one_of_pos` for the stronger version when `x â 0`. -/
lemma log_le_self (hx : 0 †x) : log x †x := by
obtain rfl | hx := hx.eq_or_lt
· simp
· exact (log_le_sub_one_of_pos hx).trans (by linarith)
/-- See `Real.one_sub_inv_le_log_of_pos` for the stronger version when `x â 0`. -/
lemma neg_inv_le_log (hx : 0 †x) : -xâ»Â¹ †log x := by
rw [neg_le, â log_inv]; exact log_le_self <| inv_nonneg.2 hx
/-- Bound for `|log x * x|` in the interval `(0, 1]`. -/
theorem abs_log_mul_self_lt (x : â) (h1 : 0 < x) (h2 : x †1) : |log x * x| < 1 := by
have : 0 < 1 / x := by simpa only [one_div, inv_pos] using h1
replace := log_le_sub_one_of_pos this
replace : log (1 / x) < 1 / x := by linarith
rw [log_div one_ne_zero h1.ne', log_one, zero_sub, lt_div_iffâ h1] at this
have aux : 0 †-log x * x := by
refine mul_nonneg ?_ h1.le
rw [â log_inv]
apply log_nonneg
rw [â le_inv_commâ h1 zero_lt_one, inv_one]
exact h2
rw [â abs_of_nonneg aux, neg_mul, abs_neg] at this
exact this
/-- The real logarithm function tends to `+â` at `+â`. -/
theorem tendsto_log_atTop : Tendsto log atTop atTop :=
tendsto_comp_exp_atTop.1 <| by simpa only [log_exp] using tendsto_id
lemma tendsto_log_nhdsGT_zero : Tendsto log (ð[>] 0) atBot := by
simpa [â tendsto_comp_exp_atBot] using tendsto_id
@[deprecated (since := "2025-03-18")]
alias tendsto_log_nhdsWithin_zero_right := tendsto_log_nhdsGT_zero
theorem tendsto_log_nhdsNE_zero : Tendsto log (ð[â ] 0) atBot := by
simpa [comp_def] using tendsto_log_nhdsGT_zero.comp tendsto_abs_nhdsNE_zero
@[deprecated (since := "2025-03-18")]
alias tendsto_log_nhdsWithin_zero := tendsto_log_nhdsNE_zero
lemma tendsto_log_nhdsLT_zero : Tendsto log (ð[<] 0) atBot :=
tendsto_log_nhdsNE_zero.mono_left <| nhdsWithin_mono _ fun _ h ⊠ne_of_lt h
@[deprecated (since := "2025-03-18")]
alias tendsto_log_nhdsWithin_zero_left := tendsto_log_nhdsLT_zero
theorem continuousOn_log : ContinuousOn log {0}á¶ := by
simp +unfoldPartialApp only [continuousOn_iff_continuous_restrict,
restrict]
conv in log _ => rw [log_of_ne_zero (show (x : â) â 0 from x.2)]
exact expOrderIso.symm.continuous.comp (continuous_subtype_val.norm.subtype_mk _)
/-- The real logarithm is continuous as a function from nonzero reals. -/
@[fun_prop]
theorem continuous_log : Continuous fun x : { x : â // x â 0 } => log x :=
continuousOn_iff_continuous_restrict.1 <| continuousOn_log.mono fun _ => id
/-- The real logarithm is continuous as a function from positive reals. -/
@[fun_prop]
theorem continuous_log' : Continuous fun x : { x : â // 0 < x } => log x :=
continuousOn_iff_continuous_restrict.1 <| continuousOn_log.mono fun _ hx => ne_of_gt hx
theorem continuousAt_log (hx : x â 0) : ContinuousAt log x :=
(continuousOn_log x hx).continuousAt <| isOpen_compl_singleton.mem_nhds hx
@[simp]
theorem continuousAt_log_iff : ContinuousAt log x â x â 0 := by
refine âš?_, continuousAt_logâ©
rintro h rfl
exact not_tendsto_nhds_of_tendsto_atBot tendsto_log_nhdsNE_zero _ <|
h.tendsto.mono_left nhdsWithin_le_nhds
theorem log_prod {α : Type*} (s : Finset α) (f : α â â) (hf : â x â s, f x â 0) :
log (â i â s, f i) = â i â s, log (f i) := by
induction' s using Finset.cons_induction_on with a s ha ih
· simp
· rw [Finset.forall_mem_cons] at hf
simp [ih hf.2, log_mul hf.1 (Finset.prod_ne_zero_iff.2 hf.2)]
protected theorem _root_.Finsupp.log_prod {α β : Type*} [Zero β] (f : α ââ β) (g : α â β â â)
(hg : â a, g a (f a) = 0 â f a = 0) : log (f.prod g) = f.sum fun a b ⊠log (g a b) :=
| log_prod _ _ fun _x hx hâ ⊠Finsupp.mem_support_iff.1 hx <| hg _ hâ
theorem log_nat_eq_sum_factorization (n : â) :
log n = n.factorization.sum fun p t => t * log p := by
rcases eq_or_ne n 0 with (rfl | hn)
| Mathlib/Analysis/SpecialFunctions/Log/Basic.lean | 378 | 382 |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Finset.Fold
import Mathlib.Data.Multiset.Bind
import Mathlib.Order.SetNotation
/-!
# Unions of finite sets
This file defines the union of a family `t : α â Finset β` of finsets bounded by a finset
`s : Finset α`.
## Main declarations
* `Finset.disjUnion`: Given a hypothesis `h` which states that finsets `s` and `t` are disjoint,
`s.disjUnion t h` is the set such that `a â disjUnion s t h` iff `a â s` or `a â t`; this does
not require decidable equality on the type `α`.
* `Finset.biUnion`: Finite unions of finsets; given an indexing function `f : α â Finset β` and an
`s : Finset α`, `s.biUnion f` is the union of all finsets of the form `f a` for `a â s`.
## TODO
Remove `Finset.biUnion` in favour of `Finset.sup`.
-/
assert_not_exists MonoidWithZero MulAction
variable {α β γ : Type*} {s sâ sâ : Finset α} {t tâ tâ : α â Finset β}
namespace Finset
section DisjiUnion
/-- `disjiUnion s f h` is the set such that `a â disjiUnion s f` iff `a â f i` for some `i â s`.
It is the same as `s.biUnion f`, but it does not require decidable equality on the type. The
hypothesis ensures that the sets are disjoint. -/
def disjiUnion (s : Finset α) (t : α â Finset β) (hf : (s : Set α).PairwiseDisjoint t) : Finset β :=
âšs.val.bind (Finset.val â t), Multiset.nodup_bind.2
âšfun a _ ⊠(t a).nodup, s.nodup.pairwise fun _ ha _ hb hab ⊠disjoint_val.2 <| hf ha hb habâ©â©
@[simp]
lemma disjiUnion_val (s : Finset α) (t : α â Finset β) (h) :
(s.disjiUnion t h).1 = s.1.bind fun a ⊠(t a).1 := rfl
@[simp] lemma disjiUnion_empty (t : α â Finset β) : disjiUnion â
t (by simp) = â
:= rfl
@[simp] lemma mem_disjiUnion {b : β} {h} : b â s.disjiUnion t h â â a â s, b â t a := by
simp only [mem_def, disjiUnion_val, Multiset.mem_bind, exists_prop]
@[simp, norm_cast]
| lemma coe_disjiUnion {h} : (s.disjiUnion t h : Set β) = â x â (s : Set α), t x := by
simp [Set.ext_iff, mem_disjiUnion, Set.mem_iUnion, mem_coe, imp_true_iff]
| Mathlib/Data/Finset/Union.lean | 53 | 54 |
/-
Copyright (c) 2022 Alexander Bentkamp. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alexander Bentkamp, Eric Wieser, Jeremy Avigad, Johan Commelin
-/
import Mathlib.Data.Matrix.Invertible
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
import Mathlib.LinearAlgebra.Matrix.PosDef
/-! # 2Ã2 block matrices and the Schur complement
This file proves properties of 2Ã2 block matrices `[A B; C D]` that relate to the Schur complement
`D - C*Aâ»Â¹*B`.
Some of the results here generalize to 2Ã2 matrices in a category, rather than just a ring. A few
results in this direction can be found in the file `Mathlib.CategoryTheory.Preadditive.Biproducts`,
especially the declarations `CategoryTheory.Biprod.gaussian` and `CategoryTheory.Biprod.isoElim`.
Compare with `Matrix.invertibleOfFromBlocksââInvertible`.
## Main results
* `Matrix.det_fromBlocksââ`, `Matrix.det_fromBlocksââ`: determinant of a block matrix in terms of
the Schur complement.
* `Matrix.invOf_fromBlocks_zeroââ_eq`, `Matrix.invOf_fromBlocks_zeroââ_eq`: the inverse of a
block triangular matrix.
* `Matrix.isUnit_fromBlocks_zeroââ`, `Matrix.isUnit_fromBlocks_zeroââ`: invertibility of a
block triangular matrix.
* `Matrix.det_one_add_mul_comm`: the **WeinsteinâAronszajn identity**.
* `Matrix.PosSemidef.fromBlocksââ` and `Matrix.PosSemidef.fromBlocksââ`: If a matrix `A` is
positive definite, then `[A B; Bᎎ D]` is positive semidefinite if and only if `D - Bᎎ Aâ»Â¹ B` is
positive semidefinite.
-/
variable {l m n α : Type*}
namespace Matrix
open scoped Matrix
section CommRing
variable [Fintype l] [Fintype m] [Fintype n]
variable [DecidableEq l] [DecidableEq m] [DecidableEq n]
variable [CommRing α]
/-- LDU decomposition of a block matrix with an invertible top-left corner, using the
Schur complement. -/
theorem fromBlocks_eq_of_invertibleââ (A : Matrix m m α) (B : Matrix m n α) (C : Matrix l m α)
(D : Matrix l n α) [Invertible A] :
fromBlocks A B C D =
fromBlocks 1 0 (C * â
A) 1 * fromBlocks A 0 0 (D - C * â
A * B) *
fromBlocks 1 (â
A * B) 0 1 := by
simp only [fromBlocks_multiply, Matrix.mul_zero, Matrix.zero_mul, add_zero, zero_add,
Matrix.one_mul, Matrix.mul_one, invOf_mul_self, Matrix.mul_invOf_cancel_left,
Matrix.invOf_mul_cancel_right, Matrix.mul_assoc, add_sub_cancel]
/-- LDU decomposition of a block matrix with an invertible bottom-right corner, using the
Schur complement. -/
theorem fromBlocks_eq_of_invertibleââ (A : Matrix l m α) (B : Matrix l n α) (C : Matrix n m α)
(D : Matrix n n α) [Invertible D] :
fromBlocks A B C D =
fromBlocks 1 (B * â
D) 0 1 * fromBlocks (A - B * â
D * C) 0 0 D *
fromBlocks 1 0 (â
D * C) 1 :=
(Matrix.reindex (Equiv.sumComm _ _) (Equiv.sumComm _ _)).injective <| by
simpa [reindex_apply, Equiv.sumComm_symm, â submatrix_mul_equiv _ _ _ (Equiv.sumComm n m), â
submatrix_mul_equiv _ _ _ (Equiv.sumComm n l), Equiv.sumComm_apply,
fromBlocks_submatrix_sum_swap_sum_swap] using fromBlocks_eq_of_invertibleââ D C B A
section Triangular
/-! #### Block triangular matrices -/
/-- An upper-block-triangular matrix is invertible if its diagonal is. -/
def fromBlocksZeroââInvertible (A : Matrix m m α) (B : Matrix m n α) (D : Matrix n n α)
[Invertible A] [Invertible D] : Invertible (fromBlocks A B 0 D) :=
invertibleOfLeftInverse _ (fromBlocks (â
A) (-(â
A * B * â
D)) 0 (â
D)) <| by
simp_rw [fromBlocks_multiply, Matrix.mul_zero, Matrix.zero_mul, zero_add, add_zero,
Matrix.neg_mul, invOf_mul_self, Matrix.invOf_mul_cancel_right, add_neg_cancel,
fromBlocks_one]
/-- A lower-block-triangular matrix is invertible if its diagonal is. -/
def fromBlocksZeroââInvertible (A : Matrix m m α) (C : Matrix n m α) (D : Matrix n n α)
[Invertible A] [Invertible D] : Invertible (fromBlocks A 0 C D) :=
invertibleOfLeftInverse _
(fromBlocks (â
A) 0 (-(â
D * C * â
A))
(â
D)) <| by -- a symmetry argument is more work than just copying the proof
simp_rw [fromBlocks_multiply, Matrix.mul_zero, Matrix.zero_mul, zero_add, add_zero,
Matrix.neg_mul, invOf_mul_self, Matrix.invOf_mul_cancel_right, neg_add_cancel,
fromBlocks_one]
theorem invOf_fromBlocks_zeroââ_eq (A : Matrix m m α) (B : Matrix m n α) (D : Matrix n n α)
[Invertible A] [Invertible D] [Invertible (fromBlocks A B 0 D)] :
â
(fromBlocks A B 0 D) = fromBlocks (â
A) (-(â
A * B * â
D)) 0 (â
D) := by
letI := fromBlocksZeroââInvertible A B D
convert (rfl : â
(fromBlocks A B 0 D) = _)
theorem invOf_fromBlocks_zeroââ_eq (A : Matrix m m α) (C : Matrix n m α) (D : Matrix n n α)
[Invertible A] [Invertible D] [Invertible (fromBlocks A 0 C D)] :
â
(fromBlocks A 0 C D) = fromBlocks (â
A) 0 (-(â
D * C * â
A)) (â
D) := by
letI := fromBlocksZeroââInvertible A C D
convert (rfl : â
(fromBlocks A 0 C D) = _)
/-- Both diagonal entries of an invertible upper-block-triangular matrix are invertible (by reading
| off the diagonal entries of the inverse). -/
def invertibleOfFromBlocksZeroââInvertible (A : Matrix m m α) (B : Matrix m n α) (D : Matrix n n α)
[Invertible (fromBlocks A B 0 D)] : Invertible A Ã Invertible D where
fst :=
invertibleOfLeftInverse _ (â
(fromBlocks A B 0 D)).toBlocksââ <| by
| Mathlib/LinearAlgebra/Matrix/SchurComplement.lean | 107 | 111 |
/-
Copyright (c) 2021 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import Mathlib.MeasureTheory.Integral.FinMeasAdditive
/-!
# Extension of a linear function from indicators to L1
Given `T : Set α â E âL[â] F` with `DominatedFinMeasAdditive ÎŒ T C`, we construct an extension
of `T` to integrable simple functions, which are finite sums of indicators of measurable sets
with finite measure, then to integrable functions, which are limits of integrable simple functions.
The main result is a continuous linear map `(α ââ[ÎŒ] E) âL[â] F`.
This extension process is used to define the Bochner integral
in the `Mathlib.MeasureTheory.Integral.Bochner.Basic` file
and the conditional expectation of an integrable function
in `Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL1`.
## Main definitions
- `setToL1 (hT : DominatedFinMeasAdditive ÎŒ T C) : (α ââ[ÎŒ] E) âL[â] F`: the extension of `T`
from indicators to L1.
- `setToFun ÎŒ T (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α â E) : F`: a version of the
extension which applies to functions (with value 0 if the function is not integrable).
## Properties
For most properties of `setToFun`, we provide two lemmas. One version uses hypotheses valid on
all sets, like `T = T'`, and a second version which uses a primed name uses hypotheses on
measurable sets with finite measure, like `â s, MeasurableSet s â ÎŒ s < â â T s = T' s`.
The lemmas listed here don't show all hypotheses. Refer to the actual lemmas for details.
Linearity:
- `setToFun_zero_left : setToFun Ό 0 hT f = 0`
- `setToFun_add_left : setToFun Ό (T + T') _ f = setToFun Ό T hT f + setToFun Ό T' hT' f`
- `setToFun_smul_left : setToFun Ό (fun s ⊠c ⢠(T s)) (hT.smul c) f = c ⢠setToFun Ό T hT f`
- `setToFun_zero : setToFun ÎŒ T hT (0 : α â E) = 0`
- `setToFun_neg : setToFun Ό T hT (-f) = - setToFun Ό T hT f`
If `f` and `g` are integrable:
- `setToFun_add : setToFun Ό T hT (f + g) = setToFun Ό T hT f + setToFun Ό T hT g`
- `setToFun_sub : setToFun Ό T hT (f - g) = setToFun Ό T hT f - setToFun Ό T hT g`
If `T` is verifies `â c : ð, â s x, T s (c ⢠x) = c ⢠T s x`:
- `setToFun_smul : setToFun Ό T hT (c ⢠f) = c ⢠setToFun Ό T hT f`
Other:
- `setToFun_congr_ae (h : f =áµ[ÎŒ] g) : setToFun ÎŒ T hT f = setToFun ÎŒ T hT g`
- `setToFun_measure_zero (h : Ό = 0) : setToFun Ό T hT f = 0`
If the space is also an ordered additive group with an order closed topology and `T` is such that
`0 †T s x` for `0 †x`, we also prove order-related properties:
- `setToFun_mono_left (h : â s x, T s x †T' s x) : setToFun ÎŒ T hT f †setToFun ÎŒ T' hT' f`
- `setToFun_nonneg (hf : 0 â€áµ[ÎŒ] f) : 0 †setToFun ÎŒ T hT f`
- `setToFun_mono (hfg : f â€áµ[ÎŒ] g) : setToFun ÎŒ T hT f †setToFun ÎŒ T hT g`
-/
noncomputable section
open scoped Topology NNReal
open Set Filter TopologicalSpace ENNReal
namespace MeasureTheory
variable {α E F F' G ð : Type*} [NormedAddCommGroup E] [NormedSpace â E]
[NormedAddCommGroup F] [NormedSpace â F] [NormedAddCommGroup F'] [NormedSpace â F']
[NormedAddCommGroup G] {m : MeasurableSpace α} {Ό : Measure α}
namespace L1
open AEEqFun Lp.simpleFunc Lp
namespace SimpleFunc
theorem norm_eq_sum_mul (f : α âââ[ÎŒ] G) :
âfâ = â x â (toSimpleFunc f).range, ÎŒ.real (toSimpleFunc f â»Â¹' {x}) * âxâ := by
rw [norm_toSimpleFunc, eLpNorm_one_eq_lintegral_enorm]
have h_eq := SimpleFunc.map_apply (â·ââ) (toSimpleFunc f)
simp_rw [â h_eq, measureReal_def]
rw [SimpleFunc.lintegral_eq_lintegral, SimpleFunc.map_lintegral, ENNReal.toReal_sum]
· congr
ext1 x
rw [ENNReal.toReal_mul, mul_comm, â ofReal_norm_eq_enorm,
ENNReal.toReal_ofReal (norm_nonneg _)]
· intro x _
by_cases hx0 : x = 0
· rw [hx0]; simp
· exact
ENNReal.mul_ne_top ENNReal.coe_ne_top
(SimpleFunc.measure_preimage_lt_top_of_integrable _ (SimpleFunc.integrable f) hx0).ne
section SetToL1S
variable [NormedField ð] [NormedSpace ð E]
attribute [local instance] Lp.simpleFunc.module
attribute [local instance] Lp.simpleFunc.normedSpace
/-- Extend `Set α â (E âL[â] F')` to `(α âââ[ÎŒ] E) â F'`. -/
def setToL1S (T : Set α â E âL[â] F) (f : α âââ[ÎŒ] E) : F :=
(toSimpleFunc f).setToSimpleFunc T
theorem setToL1S_eq_setToSimpleFunc (T : Set α â E âL[â] F) (f : α âââ[ÎŒ] E) :
setToL1S T f = (toSimpleFunc f).setToSimpleFunc T :=
rfl
@[simp]
theorem setToL1S_zero_left (f : α âââ[ÎŒ] E) : setToL1S (0 : Set α â E âL[â] F) f = 0 :=
SimpleFunc.setToSimpleFunc_zero _
theorem setToL1S_zero_left' {T : Set α â E âL[â] F}
(h_zero : â s, MeasurableSet s â ÎŒ s < â â T s = 0) (f : α âââ[ÎŒ] E) : setToL1S T f = 0 :=
SimpleFunc.setToSimpleFunc_zero' h_zero _ (SimpleFunc.integrable f)
theorem setToL1S_congr (T : Set α â E âL[â] F) (h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0)
(h_add : FinMeasAdditive ÎŒ T) {f g : α âââ[ÎŒ] E} (h : toSimpleFunc f =áµ[ÎŒ] toSimpleFunc g) :
setToL1S T f = setToL1S T g :=
SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable f) h
theorem setToL1S_congr_left (T T' : Set α â E âL[â] F)
(h : â s, MeasurableSet s â ÎŒ s < â â T s = T' s) (f : α âââ[ÎŒ] E) :
setToL1S T f = setToL1S T' f :=
SimpleFunc.setToSimpleFunc_congr_left T T' h (simpleFunc.toSimpleFunc f) (SimpleFunc.integrable f)
/-- `setToL1S` does not change if we replace the measure `Ό` by `Ό'` with `Ό ⪠Ό'`. The statement
uses two functions `f` and `f'` because they have to belong to different types, but morally these
are the same function (we have `f =áµ[ÎŒ] f'`). -/
theorem setToL1S_congr_measure {ÎŒ' : Measure α} (T : Set α â E âL[â] F)
(h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0) (h_add : FinMeasAdditive ÎŒ T) (hÎŒ : ÎŒ ⪠Ό')
(f : α âââ[ÎŒ] E) (f' : α âââ[ÎŒ'] E) (h : (f : α â E) =áµ[ÎŒ] f') :
setToL1S T f = setToL1S T f' := by
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable f) ?_
refine (toSimpleFunc_eq_toFun f).trans ?_
suffices (f' : α â E) =áµ[ÎŒ] simpleFunc.toSimpleFunc f' from h.trans this
have goal' : (f' : α â E) =áµ[ÎŒ'] simpleFunc.toSimpleFunc f' := (toSimpleFunc_eq_toFun f').symm
exact hΌ.ae_eq goal'
theorem setToL1S_add_left (T T' : Set α â E âL[â] F) (f : α âââ[ÎŒ] E) :
setToL1S (T + T') f = setToL1S T f + setToL1S T' f :=
SimpleFunc.setToSimpleFunc_add_left T T'
theorem setToL1S_add_left' (T T' T'' : Set α â E âL[â] F)
(h_add : â s, MeasurableSet s â ÎŒ s < â â T'' s = T s + T' s) (f : α âââ[ÎŒ] E) :
setToL1S T'' f = setToL1S T f + setToL1S T' f :=
SimpleFunc.setToSimpleFunc_add_left' T T' T'' h_add (SimpleFunc.integrable f)
theorem setToL1S_smul_left (T : Set α â E âL[â] F) (c : â) (f : α âââ[ÎŒ] E) :
setToL1S (fun s => c ⢠T s) f = c ⢠setToL1S T f :=
SimpleFunc.setToSimpleFunc_smul_left T c _
theorem setToL1S_smul_left' (T T' : Set α â E âL[â] F) (c : â)
(h_smul : â s, MeasurableSet s â ÎŒ s < â â T' s = c ⢠T s) (f : α âââ[ÎŒ] E) :
setToL1S T' f = c ⢠setToL1S T f :=
SimpleFunc.setToSimpleFunc_smul_left' T T' c h_smul (SimpleFunc.integrable f)
theorem setToL1S_add (T : Set α â E âL[â] F) (h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0)
(h_add : FinMeasAdditive ÎŒ T) (f g : α âââ[ÎŒ] E) :
setToL1S T (f + g) = setToL1S T f + setToL1S T g := by
simp_rw [setToL1S]
rw [â SimpleFunc.setToSimpleFunc_add T h_add (SimpleFunc.integrable f)
(SimpleFunc.integrable g)]
exact
SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _)
(add_toSimpleFunc f g)
theorem setToL1S_neg {T : Set α â E âL[â] F} (h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0)
(h_add : FinMeasAdditive ÎŒ T) (f : α âââ[ÎŒ] E) : setToL1S T (-f) = -setToL1S T f := by
simp_rw [setToL1S]
have : simpleFunc.toSimpleFunc (-f) =áµ[ÎŒ] â(-simpleFunc.toSimpleFunc f) :=
neg_toSimpleFunc f
rw [SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) this]
exact SimpleFunc.setToSimpleFunc_neg T h_add (SimpleFunc.integrable f)
theorem setToL1S_sub {T : Set α â E âL[â] F} (h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0)
(h_add : FinMeasAdditive ÎŒ T) (f g : α âââ[ÎŒ] E) :
setToL1S T (f - g) = setToL1S T f - setToL1S T g := by
rw [sub_eq_add_neg, setToL1S_add T h_zero h_add, setToL1S_neg h_zero h_add, sub_eq_add_neg]
theorem setToL1S_smul_real (T : Set α â E âL[â] F)
(h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0) (h_add : FinMeasAdditive ÎŒ T) (c : â)
(f : α âââ[ÎŒ] E) : setToL1S T (c ⢠f) = c ⢠setToL1S T f := by
simp_rw [setToL1S]
rw [â SimpleFunc.setToSimpleFunc_smul_real T h_add c (SimpleFunc.integrable f)]
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact smul_toSimpleFunc c f
theorem setToL1S_smul {E} [NormedAddCommGroup E] [NormedSpace â E] [NormedSpace ð E]
[DistribSMul ð F] (T : Set α â E âL[â] F) (h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0)
(h_add : FinMeasAdditive ÎŒ T) (h_smul : â c : ð, â s x, T s (c ⢠x) = c ⢠T s x) (c : ð)
(f : α âââ[ÎŒ] E) : setToL1S T (c ⢠f) = c ⢠setToL1S T f := by
simp_rw [setToL1S]
rw [â SimpleFunc.setToSimpleFunc_smul T h_add h_smul c (SimpleFunc.integrable f)]
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact smul_toSimpleFunc c f
theorem norm_setToL1S_le (T : Set α â E âL[â] F) {C : â}
(hT_norm : â s, MeasurableSet s â ÎŒ s < â â âT sâ †C * ÎŒ.real s) (f : α âââ[ÎŒ] E) :
âsetToL1S T fâ †C * âfâ := by
rw [setToL1S, norm_eq_sum_mul f]
exact
SimpleFunc.norm_setToSimpleFunc_le_sum_mul_norm_of_integrable T hT_norm _
(SimpleFunc.integrable f)
theorem setToL1S_indicatorConst {T : Set α â E âL[â] F} {s : Set α}
(h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0) (h_add : FinMeasAdditive ÎŒ T)
(hs : MeasurableSet s) (hÎŒs : ÎŒ s < â) (x : E) :
setToL1S T (simpleFunc.indicatorConst 1 hs hÎŒs.ne x) = T s x := by
have h_empty : T â
= 0 := h_zero _ MeasurableSet.empty measure_empty
rw [setToL1S_eq_setToSimpleFunc]
refine Eq.trans ?_ (SimpleFunc.setToSimpleFunc_indicator T h_empty hs x)
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact toSimpleFunc_indicatorConst hs hÎŒs.ne x
theorem setToL1S_const [IsFiniteMeasure ÎŒ] {T : Set α â E âL[â] F}
(h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0) (h_add : FinMeasAdditive ÎŒ T) (x : E) :
setToL1S T (simpleFunc.indicatorConst 1 MeasurableSet.univ (measure_ne_top Ό _) x) = T univ x :=
setToL1S_indicatorConst h_zero h_add MeasurableSet.univ (measure_lt_top _ _) x
section Order
variable {G'' G' : Type*}
[NormedAddCommGroup G'] [PartialOrder G'] [IsOrderedAddMonoid G'] [NormedSpace â G']
[NormedAddCommGroup G''] [PartialOrder G''] [IsOrderedAddMonoid G''] [NormedSpace â G'']
{T : Set α â G'' âL[â] G'}
theorem setToL1S_mono_left {T T' : Set α â E âL[â] G''} (hTT' : â s x, T s x †T' s x)
(f : α âââ[ÎŒ] E) : setToL1S T f †setToL1S T' f :=
SimpleFunc.setToSimpleFunc_mono_left T T' hTT' _
theorem setToL1S_mono_left' {T T' : Set α â E âL[â] G''}
(hTT' : â s, MeasurableSet s â ÎŒ s < â â â x, T s x †T' s x) (f : α âââ[ÎŒ] E) :
setToL1S T f †setToL1S T' f :=
SimpleFunc.setToSimpleFunc_mono_left' T T' hTT' _ (SimpleFunc.integrable f)
omit [IsOrderedAddMonoid G''] in
theorem setToL1S_nonneg (h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0)
(h_add : FinMeasAdditive Ό T)
(hT_nonneg : â s, MeasurableSet s â ÎŒ s < â â â x, 0 †x â 0 †T s x) {f : α âââ[ÎŒ] G''}
(hf : 0 †f) : 0 †setToL1S T f := by
simp_rw [setToL1S]
obtain âšf', hf', hff'â© := exists_simpleFunc_nonneg_ae_eq hf
replace hff' : simpleFunc.toSimpleFunc f =áµ[ÎŒ] f' :=
(Lp.simpleFunc.toSimpleFunc_eq_toFun f).trans hff'
rw [SimpleFunc.setToSimpleFunc_congr _ h_zero h_add (SimpleFunc.integrable _) hff']
exact
SimpleFunc.setToSimpleFunc_nonneg' T hT_nonneg _ hf' ((SimpleFunc.integrable f).congr hff')
theorem setToL1S_mono (h_zero : â s, MeasurableSet s â ÎŒ s = 0 â T s = 0)
(h_add : FinMeasAdditive Ό T)
(hT_nonneg : â s, MeasurableSet s â ÎŒ s < â â â x, 0 †x â 0 †T s x) {f g : α âââ[ÎŒ] G''}
(hfg : f †g) : setToL1S T f †setToL1S T g := by
rw [â sub_nonneg] at hfg â¢
rw [â setToL1S_sub h_zero h_add]
exact setToL1S_nonneg h_zero h_add hT_nonneg hfg
end Order
variable [NormedSpace ð F]
variable (α E ÎŒ ð)
/-- Extend `Set α â E âL[â] F` to `(α âââ[ÎŒ] E) âL[ð] F`. -/
def setToL1SCLM' {T : Set α â E âL[â] F} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C)
(h_smul : â c : ð, â s x, T s (c ⢠x) = c ⢠T s x) : (α âââ[ÎŒ] E) âL[ð] F :=
LinearMap.mkContinuous
âšâšsetToL1S T, setToL1S_add T (fun _ => hT.eq_zero_of_measure_zero) hT.1â©,
setToL1S_smul T (fun _ => hT.eq_zero_of_measure_zero) hT.1 h_smulâ©
C fun f => norm_setToL1S_le T hT.2 f
/-- Extend `Set α â E âL[â] F` to `(α âââ[ÎŒ] E) âL[â] F`. -/
def setToL1SCLM {T : Set α â E âL[â] F} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C) :
(α âââ[ÎŒ] E) âL[â] F :=
LinearMap.mkContinuous
âšâšsetToL1S T, setToL1S_add T (fun _ => hT.eq_zero_of_measure_zero) hT.1â©,
setToL1S_smul_real T (fun _ => hT.eq_zero_of_measure_zero) hT.1â©
C fun f => norm_setToL1S_le T hT.2 f
variable {α E ÎŒ ð}
variable {T T' T'' : Set α â E âL[â] F} {C C' C'' : â}
@[simp]
theorem setToL1SCLM_zero_left (hT : DominatedFinMeasAdditive ÎŒ (0 : Set α â E âL[â] F) C)
(f : α âââ[ÎŒ] E) : setToL1SCLM α E ÎŒ hT f = 0 :=
setToL1S_zero_left _
theorem setToL1SCLM_zero_left' (hT : DominatedFinMeasAdditive Ό T C)
(h_zero : â s, MeasurableSet s â ÎŒ s < â â T s = 0) (f : α âââ[ÎŒ] E) :
setToL1SCLM α E Ό hT f = 0 :=
setToL1S_zero_left' h_zero f
theorem setToL1SCLM_congr_left (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (h : T = T') (f : α âââ[ÎŒ] E) :
setToL1SCLM α E Ό hT f = setToL1SCLM α E Ό hT' f :=
setToL1S_congr_left T T' (fun _ _ _ => by rw [h]) f
theorem setToL1SCLM_congr_left' (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (h : â s, MeasurableSet s â ÎŒ s < â â T s = T' s)
(f : α âââ[ÎŒ] E) : setToL1SCLM α E ÎŒ hT f = setToL1SCLM α E ÎŒ hT' f :=
setToL1S_congr_left T T' h f
theorem setToL1SCLM_congr_measure {Ό' : Measure α} (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ' T C') (hÎŒ : ÎŒ ⪠Ό') (f : α âââ[ÎŒ] E) (f' : α âââ[ÎŒ'] E)
(h : (f : α â E) =áµ[ÎŒ] f') : setToL1SCLM α E ÎŒ hT f = setToL1SCLM α E ÎŒ' hT' f' :=
setToL1S_congr_measure T (fun _ => hT.eq_zero_of_measure_zero) hT.1 hΌ _ _ h
theorem setToL1SCLM_add_left (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (f : α âââ[ÎŒ] E) :
setToL1SCLM α E Ό (hT.add hT') f = setToL1SCLM α E Ό hT f + setToL1SCLM α E Ό hT' f :=
setToL1S_add_left T T' f
theorem setToL1SCLM_add_left' (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive Ό T' C') (hT'' : DominatedFinMeasAdditive Ό T'' C'')
(h_add : â s, MeasurableSet s â ÎŒ s < â â T'' s = T s + T' s) (f : α âââ[ÎŒ] E) :
setToL1SCLM α E Ό hT'' f = setToL1SCLM α E Ό hT f + setToL1SCLM α E Ό hT' f :=
setToL1S_add_left' T T' T'' h_add f
theorem setToL1SCLM_smul_left (c : â) (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α âââ[ÎŒ] E) :
setToL1SCLM α E Ό (hT.smul c) f = c ⢠setToL1SCLM α E Ό hT f :=
setToL1S_smul_left T c f
theorem setToL1SCLM_smul_left' (c : â) (hT : DominatedFinMeasAdditive ÎŒ T C)
(hT' : DominatedFinMeasAdditive Ό T' C')
(h_smul : â s, MeasurableSet s â ÎŒ s < â â T' s = c ⢠T s) (f : α âââ[ÎŒ] E) :
setToL1SCLM α E Ό hT' f = c ⢠setToL1SCLM α E Ό hT f :=
setToL1S_smul_left' T T' c h_smul f
theorem norm_setToL1SCLM_le {T : Set α â E âL[â] F} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C)
(hC : 0 †C) : âsetToL1SCLM α E ÎŒ hTâ †C :=
LinearMap.mkContinuous_norm_le _ hC _
theorem norm_setToL1SCLM_le' {T : Set α â E âL[â] F} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C) :
âsetToL1SCLM α E ÎŒ hTâ †max C 0 :=
LinearMap.mkContinuous_norm_le' _ _
theorem setToL1SCLM_const [IsFiniteMeasure ÎŒ] {T : Set α â E âL[â] F} {C : â}
(hT : DominatedFinMeasAdditive Ό T C) (x : E) :
setToL1SCLM α E Ό hT (simpleFunc.indicatorConst 1 MeasurableSet.univ (measure_ne_top Ό _) x) =
T univ x :=
setToL1S_const (fun _ => hT.eq_zero_of_measure_zero) hT.1 x
section Order
variable {G' G'' : Type*}
[NormedAddCommGroup G''] [PartialOrder G''] [IsOrderedAddMonoid G''] [NormedSpace â G'']
[NormedAddCommGroup G'] [PartialOrder G'] [IsOrderedAddMonoid G'] [NormedSpace â G']
theorem setToL1SCLM_mono_left {T T' : Set α â E âL[â] G''} {C C' : â}
(hT : DominatedFinMeasAdditive Ό T C) (hT' : DominatedFinMeasAdditive Ό T' C')
(hTT' : â s x, T s x †T' s x) (f : α âââ[ÎŒ] E) :
setToL1SCLM α E Ό hT f †setToL1SCLM α E Ό hT' f :=
SimpleFunc.setToSimpleFunc_mono_left T T' hTT' _
theorem setToL1SCLM_mono_left' {T T' : Set α â E âL[â] G''} {C C' : â}
(hT : DominatedFinMeasAdditive Ό T C) (hT' : DominatedFinMeasAdditive Ό T' C')
(hTT' : â s, MeasurableSet s â ÎŒ s < â â â x, T s x †T' s x) (f : α âââ[ÎŒ] E) :
setToL1SCLM α E Ό hT f †setToL1SCLM α E Ό hT' f :=
SimpleFunc.setToSimpleFunc_mono_left' T T' hTT' _ (SimpleFunc.integrable f)
omit [IsOrderedAddMonoid G'] in
theorem setToL1SCLM_nonneg {T : Set α â G' âL[â] G''} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C)
(hT_nonneg : â s, MeasurableSet s â ÎŒ s < â â â x, 0 †x â 0 †T s x) {f : α âââ[ÎŒ] G'}
(hf : 0 †f) : 0 †setToL1SCLM α G' Ό hT f :=
setToL1S_nonneg (fun _ => hT.eq_zero_of_measure_zero) hT.1 hT_nonneg hf
theorem setToL1SCLM_mono {T : Set α â G' âL[â] G''} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C)
(hT_nonneg : â s, MeasurableSet s â ÎŒ s < â â â x, 0 †x â 0 †T s x) {f g : α âââ[ÎŒ] G'}
(hfg : f †g) : setToL1SCLM α G' Ό hT f †setToL1SCLM α G' Ό hT g :=
setToL1S_mono (fun _ => hT.eq_zero_of_measure_zero) hT.1 hT_nonneg hfg
end Order
end SetToL1S
end SimpleFunc
open SimpleFunc
section SetToL1
attribute [local instance] Lp.simpleFunc.module
attribute [local instance] Lp.simpleFunc.normedSpace
variable (ð) [NontriviallyNormedField ð] [NormedSpace ð E] [NormedSpace ð F] [CompleteSpace F]
{T T' T'' : Set α â E âL[â] F} {C C' C'' : â}
/-- Extend `Set α â (E âL[â] F)` to `(α ââ[ÎŒ] E) âL[ð] F`. -/
def setToL1' (hT : DominatedFinMeasAdditive Ό T C)
(h_smul : â c : ð, â s x, T s (c ⢠x) = c ⢠T s x) : (α ââ[ÎŒ] E) âL[ð] F :=
(setToL1SCLM' α E ð ÎŒ hT h_smul).extend (coeToLp α E ð) (simpleFunc.denseRange one_ne_top)
simpleFunc.isUniformInducing
variable {ð}
/-- Extend `Set α â E âL[â] F` to `(α ââ[ÎŒ] E) âL[â] F`. -/
def setToL1 (hT : DominatedFinMeasAdditive ÎŒ T C) : (α ââ[ÎŒ] E) âL[â] F :=
(setToL1SCLM α E ÎŒ hT).extend (coeToLp α E â) (simpleFunc.denseRange one_ne_top)
simpleFunc.isUniformInducing
theorem setToL1_eq_setToL1SCLM (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α âââ[ÎŒ] E) :
setToL1 hT f = setToL1SCLM α E Ό hT f :=
uniformly_extend_of_ind simpleFunc.isUniformInducing (simpleFunc.denseRange one_ne_top)
(setToL1SCLM α E Ό hT).uniformContinuous _
theorem setToL1_eq_setToL1' (hT : DominatedFinMeasAdditive Ό T C)
(h_smul : â c : ð, â s x, T s (c ⢠x) = c ⢠T s x) (f : α ââ[ÎŒ] E) :
setToL1 hT f = setToL1' ð hT h_smul f :=
rfl
@[simp]
theorem setToL1_zero_left (hT : DominatedFinMeasAdditive ÎŒ (0 : Set α â E âL[â] F) C)
(f : α ââ[ÎŒ] E) : setToL1 hT f = 0 := by
suffices setToL1 hT = 0 by rw [this]; simp
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E Ό hT) _ _ _ _ ?_
ext1 f
rw [setToL1SCLM_zero_left hT f, ContinuousLinearMap.zero_comp, ContinuousLinearMap.zero_apply]
theorem setToL1_zero_left' (hT : DominatedFinMeasAdditive Ό T C)
(h_zero : â s, MeasurableSet s â ÎŒ s < â â T s = 0) (f : α ââ[ÎŒ] E) : setToL1 hT f = 0 := by
suffices setToL1 hT = 0 by rw [this]; simp
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E Ό hT) _ _ _ _ ?_
ext1 f
rw [setToL1SCLM_zero_left' hT h_zero f, ContinuousLinearMap.zero_comp,
ContinuousLinearMap.zero_apply]
theorem setToL1_congr_left (T T' : Set α â E âL[â] F) {C C' : â}
(hT : DominatedFinMeasAdditive Ό T C) (hT' : DominatedFinMeasAdditive Ό T' C') (h : T = T')
(f : α ââ[ÎŒ] E) : setToL1 hT f = setToL1 hT' f := by
suffices setToL1 hT = setToL1 hT' by rw [this]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E Ό hT) _ _ _ _ ?_
ext1 f
suffices setToL1 hT' f = setToL1SCLM α E ÎŒ hT f by rw [â this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM]
exact setToL1SCLM_congr_left hT' hT h.symm f
theorem setToL1_congr_left' (T T' : Set α â E âL[â] F) {C C' : â}
(hT : DominatedFinMeasAdditive Ό T C) (hT' : DominatedFinMeasAdditive Ό T' C')
(h : â s, MeasurableSet s â ÎŒ s < â â T s = T' s) (f : α ââ[ÎŒ] E) :
setToL1 hT f = setToL1 hT' f := by
suffices setToL1 hT = setToL1 hT' by rw [this]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E Ό hT) _ _ _ _ ?_
ext1 f
suffices setToL1 hT' f = setToL1SCLM α E ÎŒ hT f by rw [â this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM]
exact (setToL1SCLM_congr_left' hT hT' h f).symm
theorem setToL1_add_left (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (f : α ââ[ÎŒ] E) :
setToL1 (hT.add hT') f = setToL1 hT f + setToL1 hT' f := by
suffices setToL1 (hT.add hT') = setToL1 hT + setToL1 hT' by
rw [this, ContinuousLinearMap.add_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E Ό (hT.add hT')) _ _ _ _ ?_
ext1 f
suffices setToL1 hT f + setToL1 hT' f = setToL1SCLM α E Ό (hT.add hT') f by
rw [â this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM, setToL1_eq_setToL1SCLM, setToL1SCLM_add_left hT hT']
theorem setToL1_add_left' (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive Ό T' C') (hT'' : DominatedFinMeasAdditive Ό T'' C'')
(h_add : â s, MeasurableSet s â ÎŒ s < â â T'' s = T s + T' s) (f : α ââ[ÎŒ] E) :
setToL1 hT'' f = setToL1 hT f + setToL1 hT' f := by
suffices setToL1 hT'' = setToL1 hT + setToL1 hT' by rw [this, ContinuousLinearMap.add_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E Ό hT'') _ _ _ _ ?_
ext1 f
suffices setToL1 hT f + setToL1 hT' f = setToL1SCLM α E ÎŒ hT'' f by rw [â this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM, setToL1_eq_setToL1SCLM,
setToL1SCLM_add_left' hT hT' hT'' h_add]
theorem setToL1_smul_left (hT : DominatedFinMeasAdditive ÎŒ T C) (c : â) (f : α ââ[ÎŒ] E) :
setToL1 (hT.smul c) f = c ⢠setToL1 hT f := by
suffices setToL1 (hT.smul c) = c ⢠setToL1 hT by rw [this, ContinuousLinearMap.smul_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E Ό (hT.smul c)) _ _ _ _ ?_
ext1 f
suffices c ⢠setToL1 hT f = setToL1SCLM α E ÎŒ (hT.smul c) f by rw [â this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM, setToL1SCLM_smul_left c hT]
theorem setToL1_smul_left' (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (c : â)
(h_smul : â s, MeasurableSet s â ÎŒ s < â â T' s = c ⢠T s) (f : α ââ[ÎŒ] E) :
setToL1 hT' f = c ⢠setToL1 hT f := by
suffices setToL1 hT' = c ⢠setToL1 hT by rw [this, ContinuousLinearMap.smul_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E Ό hT') _ _ _ _ ?_
ext1 f
suffices c ⢠setToL1 hT f = setToL1SCLM α E ÎŒ hT' f by rw [â this]; simp [coeToLp]
rw [setToL1_eq_setToL1SCLM, setToL1SCLM_smul_left' c hT hT' h_smul]
theorem setToL1_smul (hT : DominatedFinMeasAdditive Ό T C)
(h_smul : â c : ð, â s x, T s (c ⢠x) = c ⢠T s x) (c : ð) (f : α ââ[ÎŒ] E) :
setToL1 hT (c ⢠f) = c ⢠setToL1 hT f := by
rw [setToL1_eq_setToL1' hT h_smul, setToL1_eq_setToL1' hT h_smul]
exact ContinuousLinearMap.map_smul _ _ _
theorem setToL1_simpleFunc_indicatorConst (hT : DominatedFinMeasAdditive Ό T C) {s : Set α}
(hs : MeasurableSet s) (hÎŒs : ÎŒ s < â) (x : E) :
setToL1 hT (simpleFunc.indicatorConst 1 hs hÎŒs.ne x) = T s x := by
rw [setToL1_eq_setToL1SCLM]
exact setToL1S_indicatorConst (fun s => hT.eq_zero_of_measure_zero) hT.1 hs hÎŒs x
theorem setToL1_indicatorConstLp (hT : DominatedFinMeasAdditive Ό T C) {s : Set α}
(hs : MeasurableSet s) (hÎŒs : ÎŒ s â â) (x : E) :
setToL1 hT (indicatorConstLp 1 hs hÎŒs x) = T s x := by
rw [â Lp.simpleFunc.coe_indicatorConst hs hÎŒs x]
exact setToL1_simpleFunc_indicatorConst hT hs hÎŒs.lt_top x
theorem setToL1_const [IsFiniteMeasure Ό] (hT : DominatedFinMeasAdditive Ό T C) (x : E) :
setToL1 hT (indicatorConstLp 1 MeasurableSet.univ (measure_ne_top _ _) x) = T univ x :=
setToL1_indicatorConstLp hT MeasurableSet.univ (measure_ne_top _ _) x
section Order
variable {G' G'' : Type*}
[NormedAddCommGroup G''] [PartialOrder G''] [OrderClosedTopology G''] [IsOrderedAddMonoid G'']
[NormedSpace â G''] [CompleteSpace G'']
[NormedAddCommGroup G'] [PartialOrder G'] [NormedSpace â G']
theorem setToL1_mono_left' {T T' : Set α â E âL[â] G''} {C C' : â}
(hT : DominatedFinMeasAdditive Ό T C) (hT' : DominatedFinMeasAdditive Ό T' C')
(hTT' : â s, MeasurableSet s â ÎŒ s < â â â x, T s x †T' s x) (f : α ââ[ÎŒ] E) :
setToL1 hT f †setToL1 hT' f := by
induction f using Lp.induction (hp_ne_top := one_ne_top) with
| @indicatorConst c s hs hÎŒs =>
rw [setToL1_simpleFunc_indicatorConst hT hs hÎŒs, setToL1_simpleFunc_indicatorConst hT' hs hÎŒs]
exact hTT' s hs hÎŒs c
| @add f g hf hg _ hf_le hg_le =>
rw [(setToL1 hT).map_add, (setToL1 hT').map_add]
exact add_le_add hf_le hg_le
| isClosed => exact isClosed_le (setToL1 hT).continuous (setToL1 hT').continuous
theorem setToL1_mono_left {T T' : Set α â E âL[â] G''} {C C' : â}
(hT : DominatedFinMeasAdditive Ό T C) (hT' : DominatedFinMeasAdditive Ό T' C')
(hTT' : â s x, T s x †T' s x) (f : α ââ[ÎŒ] E) : setToL1 hT f †setToL1 hT' f :=
setToL1_mono_left' hT hT' (fun s _ _ x => hTT' s x) f
theorem setToL1_nonneg {T : Set α â G' âL[â] G''} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C)
(hT_nonneg : â s, MeasurableSet s â ÎŒ s < â â â x, 0 †x â 0 †T s x) {f : α ââ[ÎŒ] G'}
(hf : 0 †f) : 0 †setToL1 hT f := by
suffices â f : { g : α ââ[ÎŒ] G' // 0 †g }, 0 †setToL1 hT f from
this (âšf, hfâ© : { g : α ââ[ÎŒ] G' // 0 †g })
refine fun g =>
@isClosed_property { g : α âââ[ÎŒ] G' // 0 †g } { g : α ââ[ÎŒ] G' // 0 †g } _ _
(fun g => 0 †setToL1 hT g)
(denseRange_coeSimpleFuncNonnegToLpNonneg 1 Ό G' one_ne_top) ?_ ?_ g
· exact isClosed_le continuous_zero ((setToL1 hT).continuous.comp continuous_induced_dom)
· intro g
have : (coeSimpleFuncNonnegToLpNonneg 1 ÎŒ G' g : α ââ[ÎŒ] G') = (g : α âââ[ÎŒ] G') := rfl
rw [this, setToL1_eq_setToL1SCLM]
exact setToL1S_nonneg (fun s => hT.eq_zero_of_measure_zero) hT.1 hT_nonneg g.2
theorem setToL1_mono [IsOrderedAddMonoid G']
{T : Set α â G' âL[â] G''} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C)
(hT_nonneg : â s, MeasurableSet s â ÎŒ s < â â â x, 0 †x â 0 †T s x) {f g : α ââ[ÎŒ] G'}
(hfg : f †g) : setToL1 hT f †setToL1 hT g := by
rw [â sub_nonneg] at hfg â¢
rw [â (setToL1 hT).map_sub]
exact setToL1_nonneg hT hT_nonneg hfg
end Order
theorem norm_setToL1_le_norm_setToL1SCLM (hT : DominatedFinMeasAdditive Ό T C) :
âsetToL1 hTâ †âsetToL1SCLM α E ÎŒ hTâ :=
calc
âsetToL1 hTâ †(1 : ââ¥0) * âsetToL1SCLM α E ÎŒ hTâ := by
refine
ContinuousLinearMap.opNorm_extend_le (setToL1SCLM α E ÎŒ hT) (coeToLp α E â)
(simpleFunc.denseRange one_ne_top) fun x => le_of_eq ?_
rw [NNReal.coe_one, one_mul]
simp [coeToLp]
_ = âsetToL1SCLM α E ÎŒ hTâ := by rw [NNReal.coe_one, one_mul]
theorem norm_setToL1_le_mul_norm (hT : DominatedFinMeasAdditive Ό T C) (hC : 0 †C)
(f : α ââ[ÎŒ] E) : âsetToL1 hT fâ †C * âfâ :=
calc
âsetToL1 hT fâ †âsetToL1SCLM α E ÎŒ hTâ * âfâ :=
ContinuousLinearMap.le_of_opNorm_le _ (norm_setToL1_le_norm_setToL1SCLM hT) _
_ †C * âfâ := mul_le_mul (norm_setToL1SCLM_le hT hC) le_rfl (norm_nonneg _) hC
theorem norm_setToL1_le_mul_norm' (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α ââ[ÎŒ] E) :
âsetToL1 hT fâ †max C 0 * âfâ :=
calc
âsetToL1 hT fâ †âsetToL1SCLM α E ÎŒ hTâ * âfâ :=
ContinuousLinearMap.le_of_opNorm_le _ (norm_setToL1_le_norm_setToL1SCLM hT) _
_ †max C 0 * âfâ :=
mul_le_mul (norm_setToL1SCLM_le' hT) le_rfl (norm_nonneg _) (le_max_right _ _)
theorem norm_setToL1_le (hT : DominatedFinMeasAdditive ÎŒ T C) (hC : 0 †C) : âsetToL1 hTâ †C :=
ContinuousLinearMap.opNorm_le_bound _ hC (norm_setToL1_le_mul_norm hT hC)
theorem norm_setToL1_le' (hT : DominatedFinMeasAdditive ÎŒ T C) : âsetToL1 hTâ †max C 0 :=
ContinuousLinearMap.opNorm_le_bound _ (le_max_right _ _) (norm_setToL1_le_mul_norm' hT)
theorem setToL1_lipschitz (hT : DominatedFinMeasAdditive Ό T C) :
LipschitzWith (Real.toNNReal C) (setToL1 hT) :=
(setToL1 hT).lipschitz.weaken (norm_setToL1_le' hT)
/-- If `fs i â f` in `L1`, then `setToL1 hT (fs i) â setToL1 hT f`. -/
theorem tendsto_setToL1 (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α ââ[ÎŒ] E) {ι}
(fs : ι â α ââ[ÎŒ] E) {l : Filter ι} (hfs : Tendsto fs l (ð f)) :
Tendsto (fun i => setToL1 hT (fs i)) l (ð <| setToL1 hT f) :=
((setToL1 hT).continuous.tendsto _).comp hfs
end SetToL1
end L1
section Function
variable [CompleteSpace F] {T T' T'' : Set α â E âL[â] F} {C C' C'' : â} {f g : α â E}
variable (Ό T)
open Classical in
/-- Extend `T : Set α â E âL[â] F` to `(α â E) â F` (for integrable functions `α â E`). We set it to
0 if the function is not integrable. -/
def setToFun (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α â E) : F :=
if hf : Integrable f Ό then L1.setToL1 hT (hf.toL1 f) else 0
variable {Ό T}
theorem setToFun_eq (hT : DominatedFinMeasAdditive Ό T C) (hf : Integrable f Ό) :
setToFun Ό T hT f = L1.setToL1 hT (hf.toL1 f) :=
dif_pos hf
theorem L1.setToFun_eq_setToL1 (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α ââ[ÎŒ] E) :
setToFun Ό T hT f = L1.setToL1 hT f := by
rw [setToFun_eq hT (L1.integrable_coeFn f), Integrable.toL1_coeFn]
theorem setToFun_undef (hT : DominatedFinMeasAdditive Ό T C) (hf : ¬Integrable f Ό) :
setToFun Ό T hT f = 0 :=
dif_neg hf
theorem setToFun_non_aestronglyMeasurable (hT : DominatedFinMeasAdditive Ό T C)
(hf : ¬AEStronglyMeasurable f Ό) : setToFun Ό T hT f = 0 :=
setToFun_undef hT (not_and_of_not_left _ hf)
@[deprecated (since := "2025-04-09")]
alias setToFun_non_aEStronglyMeasurable := setToFun_non_aestronglyMeasurable
theorem setToFun_congr_left (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (h : T = T') (f : α â E) :
setToFun Ό T hT f = setToFun Ό T' hT' f := by
by_cases hf : Integrable f Ό
· simp_rw [setToFun_eq _ hf, L1.setToL1_congr_left T T' hT hT' h]
· simp_rw [setToFun_undef _ hf]
theorem setToFun_congr_left' (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (h : â s, MeasurableSet s â ÎŒ s < â â T s = T' s)
(f : α â E) : setToFun ÎŒ T hT f = setToFun ÎŒ T' hT' f := by
by_cases hf : Integrable f Ό
· simp_rw [setToFun_eq _ hf, L1.setToL1_congr_left' T T' hT hT' h]
· simp_rw [setToFun_undef _ hf]
theorem setToFun_add_left (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (f : α â E) :
setToFun Ό (T + T') (hT.add hT') f = setToFun Ό T hT f + setToFun Ό T' hT' f := by
by_cases hf : Integrable f Ό
· simp_rw [setToFun_eq _ hf, L1.setToL1_add_left hT hT']
· simp_rw [setToFun_undef _ hf, add_zero]
theorem setToFun_add_left' (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive Ό T' C') (hT'' : DominatedFinMeasAdditive Ό T'' C'')
(h_add : â s, MeasurableSet s â ÎŒ s < â â T'' s = T s + T' s) (f : α â E) :
setToFun Ό T'' hT'' f = setToFun Ό T hT f + setToFun Ό T' hT' f := by
by_cases hf : Integrable f Ό
· simp_rw [setToFun_eq _ hf, L1.setToL1_add_left' hT hT' hT'' h_add]
· simp_rw [setToFun_undef _ hf, add_zero]
theorem setToFun_smul_left (hT : DominatedFinMeasAdditive ÎŒ T C) (c : â) (f : α â E) :
setToFun Ό (fun s => c ⢠T s) (hT.smul c) f = c ⢠setToFun Ό T hT f := by
by_cases hf : Integrable f Ό
· simp_rw [setToFun_eq _ hf, L1.setToL1_smul_left hT c]
· simp_rw [setToFun_undef _ hf, smul_zero]
theorem setToFun_smul_left' (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ T' C') (c : â)
(h_smul : â s, MeasurableSet s â ÎŒ s < â â T' s = c ⢠T s) (f : α â E) :
setToFun Ό T' hT' f = c ⢠setToFun Ό T hT f := by
by_cases hf : Integrable f Ό
· simp_rw [setToFun_eq _ hf, L1.setToL1_smul_left' hT hT' c h_smul]
· simp_rw [setToFun_undef _ hf, smul_zero]
@[simp]
theorem setToFun_zero (hT : DominatedFinMeasAdditive ÎŒ T C) : setToFun ÎŒ T hT (0 : α â E) = 0 := by
rw [Pi.zero_def, setToFun_eq hT (integrable_zero _ _ _)]
simp only [â Pi.zero_def]
rw [Integrable.toL1_zero, ContinuousLinearMap.map_zero]
@[simp]
theorem setToFun_zero_left {hT : DominatedFinMeasAdditive ÎŒ (0 : Set α â E âL[â] F) C} :
setToFun Ό 0 hT f = 0 := by
by_cases hf : Integrable f Ό
· rw [setToFun_eq hT hf]; exact L1.setToL1_zero_left hT _
· exact setToFun_undef hT hf
theorem setToFun_zero_left' (hT : DominatedFinMeasAdditive Ό T C)
(h_zero : â s, MeasurableSet s â ÎŒ s < â â T s = 0) : setToFun ÎŒ T hT f = 0 := by
by_cases hf : Integrable f Ό
· rw [setToFun_eq hT hf]; exact L1.setToL1_zero_left' hT h_zero _
· exact setToFun_undef hT hf
theorem setToFun_add (hT : DominatedFinMeasAdditive Ό T C) (hf : Integrable f Ό)
(hg : Integrable g Ό) : setToFun Ό T hT (f + g) = setToFun Ό T hT f + setToFun Ό T hT g := by
rw [setToFun_eq hT (hf.add hg), setToFun_eq hT hf, setToFun_eq hT hg, Integrable.toL1_add,
(L1.setToL1 hT).map_add]
theorem setToFun_finset_sum' (hT : DominatedFinMeasAdditive Ό T C) {ι} (s : Finset ι)
{f : ι â α â E} (hf : â i â s, Integrable (f i) ÎŒ) :
setToFun ÎŒ T hT (â i â s, f i) = â i â s, setToFun ÎŒ T hT (f i) := by
classical
revert hf
refine Finset.induction_on s ?_ ?_
· intro _
simp only [setToFun_zero, Finset.sum_empty]
· intro i s his ih hf
simp only [his, Finset.sum_insert, not_false_iff]
rw [setToFun_add hT (hf i (Finset.mem_insert_self i s)) _]
· rw [ih fun i hi => hf i (Finset.mem_insert_of_mem hi)]
· convert integrable_finset_sum s fun i hi => hf i (Finset.mem_insert_of_mem hi) with x
simp
theorem setToFun_finset_sum (hT : DominatedFinMeasAdditive ÎŒ T C) {ι} (s : Finset ι) {f : ι â α â E}
(hf : â i â s, Integrable (f i) ÎŒ) :
(setToFun ÎŒ T hT fun a => â i â s, f i a) = â i â s, setToFun ÎŒ T hT (f i) := by
convert setToFun_finset_sum' hT s hf with a; simp
theorem setToFun_neg (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α â E) :
setToFun Ό T hT (-f) = -setToFun Ό T hT f := by
by_cases hf : Integrable f Ό
· rw [setToFun_eq hT hf, setToFun_eq hT hf.neg, Integrable.toL1_neg,
(L1.setToL1 hT).map_neg]
· rw [setToFun_undef hT hf, setToFun_undef hT, neg_zero]
rwa [â integrable_neg_iff] at hf
theorem setToFun_sub (hT : DominatedFinMeasAdditive Ό T C) (hf : Integrable f Ό)
(hg : Integrable g Ό) : setToFun Ό T hT (f - g) = setToFun Ό T hT f - setToFun Ό T hT g := by
rw [sub_eq_add_neg, sub_eq_add_neg, setToFun_add hT hf hg.neg, setToFun_neg hT g]
theorem setToFun_smul [NontriviallyNormedField ð] [NormedSpace ð E] [NormedSpace ð F]
(hT : DominatedFinMeasAdditive ÎŒ T C) (h_smul : â c : ð, â s x, T s (c ⢠x) = c ⢠T s x) (c : ð)
(f : α â E) : setToFun ÎŒ T hT (c ⢠f) = c ⢠setToFun ÎŒ T hT f := by
by_cases hf : Integrable f Ό
· rw [setToFun_eq hT hf, setToFun_eq hT, Integrable.toL1_smul',
L1.setToL1_smul hT h_smul c _]
· by_cases hr : c = 0
· rw [hr]; simp
· have hf' : ¬Integrable (c ⢠f) Ό := by rwa [integrable_smul_iff hr f]
rw [setToFun_undef hT hf, setToFun_undef hT hf', smul_zero]
theorem setToFun_congr_ae (hT : DominatedFinMeasAdditive ÎŒ T C) (h : f =áµ[ÎŒ] g) :
setToFun Ό T hT f = setToFun Ό T hT g := by
by_cases hfi : Integrable f Ό
· have hgi : Integrable g Ό := hfi.congr h
rw [setToFun_eq hT hfi, setToFun_eq hT hgi, (Integrable.toL1_eq_toL1_iff f g hfi hgi).2 h]
· have hgi : ¬Integrable g Ό := by rw [integrable_congr h] at hfi; exact hfi
rw [setToFun_undef hT hfi, setToFun_undef hT hgi]
theorem setToFun_measure_zero (hT : DominatedFinMeasAdditive Ό T C) (h : Ό = 0) :
setToFun Ό T hT f = 0 := by
have : f =áµ[ÎŒ] 0 := by simp [h, EventuallyEq]
rw [setToFun_congr_ae hT this, setToFun_zero]
theorem setToFun_measure_zero' (hT : DominatedFinMeasAdditive Ό T C)
(h : â s, MeasurableSet s â ÎŒ s < â â ÎŒ s = 0) : setToFun ÎŒ T hT f = 0 :=
setToFun_zero_left' hT fun s hs hÎŒs => hT.eq_zero_of_measure_zero hs (h s hs hÎŒs)
theorem setToFun_toL1 (hT : DominatedFinMeasAdditive Ό T C) (hf : Integrable f Ό) :
setToFun Ό T hT (hf.toL1 f) = setToFun Ό T hT f :=
setToFun_congr_ae hT hf.coeFn_toL1
theorem setToFun_indicator_const (hT : DominatedFinMeasAdditive Ό T C) {s : Set α}
(hs : MeasurableSet s) (hÎŒs : ÎŒ s â â) (x : E) :
setToFun Ό T hT (s.indicator fun _ => x) = T s x := by
rw [setToFun_congr_ae hT (@indicatorConstLp_coeFn _ _ _ 1 _ _ _ hs hÎŒs x).symm]
rw [L1.setToFun_eq_setToL1 hT]
exact L1.setToL1_indicatorConstLp hT hs hÎŒs x
theorem setToFun_const [IsFiniteMeasure Ό] (hT : DominatedFinMeasAdditive Ό T C) (x : E) :
(setToFun Ό T hT fun _ => x) = T univ x := by
have : (fun _ : α => x) = Set.indicator univ fun _ => x := (indicator_univ _).symm
rw [this]
exact setToFun_indicator_const hT MeasurableSet.univ (measure_ne_top _ _) x
section Order
variable {G' G'' : Type*}
[NormedAddCommGroup G''] [PartialOrder G''] [OrderClosedTopology G''] [IsOrderedAddMonoid G'']
[NormedSpace â G''] [CompleteSpace G'']
[NormedAddCommGroup G'] [PartialOrder G'] [NormedSpace â G']
theorem setToFun_mono_left' {T T' : Set α â E âL[â] G''} {C C' : â}
(hT : DominatedFinMeasAdditive Ό T C) (hT' : DominatedFinMeasAdditive Ό T' C')
(hTT' : â s, MeasurableSet s â ÎŒ s < â â â x, T s x †T' s x) (f : α â E) :
setToFun Ό T hT f †setToFun Ό T' hT' f := by
by_cases hf : Integrable f Ό
· simp_rw [setToFun_eq _ hf]; exact L1.setToL1_mono_left' hT hT' hTT' _
· simp_rw [setToFun_undef _ hf, le_rfl]
theorem setToFun_mono_left {T T' : Set α â E âL[â] G''} {C C' : â}
(hT : DominatedFinMeasAdditive Ό T C) (hT' : DominatedFinMeasAdditive Ό T' C')
(hTT' : â s x, T s x †T' s x) (f : α ââ[ÎŒ] E) : setToFun ÎŒ T hT f †setToFun ÎŒ T' hT' f :=
setToFun_mono_left' hT hT' (fun s _ _ x => hTT' s x) f
theorem setToFun_nonneg {T : Set α â G' âL[â] G''} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C)
(hT_nonneg : â s, MeasurableSet s â ÎŒ s < â â â x, 0 †x â 0 †T s x) {f : α â G'}
(hf : 0 â€áµ[ÎŒ] f) : 0 †setToFun ÎŒ T hT f := by
by_cases hfi : Integrable f Ό
· simp_rw [setToFun_eq _ hfi]
refine L1.setToL1_nonneg hT hT_nonneg ?_
rw [â Lp.coeFn_le]
have h0 := Lp.coeFn_zero G' 1 Ό
have h := Integrable.coeFn_toL1 hfi
filter_upwards [h0, h, hf] with _ h0a ha hfa
rw [h0a, ha]
exact hfa
· simp_rw [setToFun_undef _ hfi, le_rfl]
theorem setToFun_mono [IsOrderedAddMonoid G']
{T : Set α â G' âL[â] G''} {C : â} (hT : DominatedFinMeasAdditive ÎŒ T C)
(hT_nonneg : â s, MeasurableSet s â ÎŒ s < â â â x, 0 †x â 0 †T s x) {f g : α â G'}
(hf : Integrable f ÎŒ) (hg : Integrable g ÎŒ) (hfg : f â€áµ[ÎŒ] g) :
setToFun Ό T hT f †setToFun Ό T hT g := by
rw [â sub_nonneg, â setToFun_sub hT hg hf]
refine setToFun_nonneg hT hT_nonneg (hfg.mono fun a ha => ?_)
rw [Pi.sub_apply, Pi.zero_apply, sub_nonneg]
exact ha
end Order
@[continuity]
theorem continuous_setToFun (hT : DominatedFinMeasAdditive Ό T C) :
Continuous fun f : α ââ[ÎŒ] E => setToFun ÎŒ T hT f := by
simp_rw [L1.setToFun_eq_setToL1 hT]; exact ContinuousLinearMap.continuous _
/-- If `F i â f` in `L1`, then `setToFun ÎŒ T hT (F i) â setToFun ÎŒ T hT f`. -/
theorem tendsto_setToFun_of_L1 (hT : DominatedFinMeasAdditive ÎŒ T C) {ι} (f : α â E)
(hfi : Integrable f ÎŒ) {fs : ι â α â E} {l : Filter ι} (hfsi : âá¶ i in l, Integrable (fs i) ÎŒ)
(hfs : Tendsto (fun i => â«â» x, âfs i x - f xââ âÎŒ) l (ð 0)) :
Tendsto (fun i => setToFun ÎŒ T hT (fs i)) l (ð <| setToFun ÎŒ T hT f) := by
classical
let f_lp := hfi.toL1 f
let F_lp i := if hFi : Integrable (fs i) Ό then hFi.toL1 (fs i) else 0
have tendsto_L1 : Tendsto F_lp l (ð f_lp) := by
rw [Lp.tendsto_Lp_iff_tendsto_eLpNorm']
simp_rw [eLpNorm_one_eq_lintegral_enorm, Pi.sub_apply]
refine (tendsto_congr' ?_).mp hfs
filter_upwards [hfsi] with i hi
refine lintegral_congr_ae ?_
filter_upwards [hi.coeFn_toL1, hfi.coeFn_toL1] with x hxi hxf
simp_rw [F_lp, dif_pos hi, hxi, f_lp, hxf]
suffices Tendsto (fun i => setToFun ÎŒ T hT (F_lp i)) l (ð (setToFun ÎŒ T hT f)) by
refine (tendsto_congr' ?_).mp this
filter_upwards [hfsi] with i hi
suffices h_ae_eq : F_lp i =áµ[ÎŒ] fs i from setToFun_congr_ae hT h_ae_eq
simp_rw [F_lp, dif_pos hi]
exact hi.coeFn_toL1
rw [setToFun_congr_ae hT hfi.coeFn_toL1.symm]
exact ((continuous_setToFun hT).tendsto f_lp).comp tendsto_L1
theorem tendsto_setToFun_approxOn_of_measurable (hT : DominatedFinMeasAdditive Ό T C)
[MeasurableSpace E] [BorelSpace E] {f : α â E} {s : Set E} [SeparableSpace s]
(hfi : Integrable f ÎŒ) (hfm : Measurable f) (hs : âáµ x âÎŒ, f x â closure s) {yâ : E}
(hâ : yâ â s) (hâi : Integrable (fun _ => yâ) ÎŒ) :
Tendsto (fun n => setToFun ÎŒ T hT (SimpleFunc.approxOn f hfm s yâ hâ n)) atTop
(ð <| setToFun ÎŒ T hT f) :=
tendsto_setToFun_of_L1 hT _ hfi
(Eventually.of_forall (SimpleFunc.integrable_approxOn hfm hfi hâ hâi))
(SimpleFunc.tendsto_approxOn_L1_enorm hfm _ hs (hfi.sub hâi).2)
theorem tendsto_setToFun_approxOn_of_measurable_of_range_subset
(hT : DominatedFinMeasAdditive ÎŒ T C) [MeasurableSpace E] [BorelSpace E] {f : α â E}
(fmeas : Measurable f) (hf : Integrable f Ό) (s : Set E) [SeparableSpace s]
(hs : range f ⪠{0} â s) :
Tendsto (fun n => setToFun Ό T hT (SimpleFunc.approxOn f fmeas s 0 (hs <| by simp) n)) atTop
(ð <| setToFun ÎŒ T hT f) := by
refine tendsto_setToFun_approxOn_of_measurable hT hf fmeas ?_ _ (integrable_zero _ _ _)
exact Eventually.of_forall fun x => subset_closure (hs (Set.mem_union_left _ (mem_range_self _)))
/-- Auxiliary lemma for `setToFun_congr_measure`: the function sending `f : α ââ[ÎŒ] G` to
`f : α ââ[ÎŒ'] G` is continuous when `ÎŒ' †c' ⢠Ό` for `c' â â`. -/
theorem continuous_L1_toL1 {ÎŒ' : Measure α} (c' : ââ¥0â) (hc' : c' â â) (hÎŒ'_le : ÎŒ' †c' ⢠Ό) :
Continuous fun f : α ââ[ÎŒ] G =>
(Integrable.of_measure_le_smul hc' hΌ'_le (L1.integrable_coeFn f)).toL1 f := by
by_cases hc'0 : c' = 0
· have hÎŒ'0 : ÎŒ' = 0 := by rw [â Measure.nonpos_iff_eq_zero']; refine hÎŒ'_le.trans ?_; simp [hc'0]
have h_im_zero :
(fun f : α ââ[ÎŒ] G =>
(Integrable.of_measure_le_smul hc' hΌ'_le (L1.integrable_coeFn f)).toL1 f) =
0 := by
ext1 f; ext1; simp_rw [hΌ'0]; simp only [ae_zero, EventuallyEq, eventually_bot]
rw [h_im_zero]
exact continuous_zero
rw [Metric.continuous_iff]
intro f ε hε_pos
use ε / 2 / c'.toReal
refine âšdiv_pos (half_pos hε_pos) (toReal_pos hc'0 hc'), ?_â©
intro g hfg
rw [Lp.dist_def] at hfg â¢
let h_int := fun f' : α ââ[ÎŒ] G => (L1.integrable_coeFn f').of_measure_le_smul hc' hÎŒ'_le
have :
eLpNorm (â(Integrable.toL1 g (h_int g)) - â(Integrable.toL1 f (h_int f))) 1 ÎŒ' =
eLpNorm (âg - âf) 1 ÎŒ' :=
eLpNorm_congr_ae ((Integrable.coeFn_toL1 _).sub (Integrable.coeFn_toL1 _))
rw [this]
have h_eLpNorm_ne_top : eLpNorm (âg - âf) 1 ÎŒ â â := by
rw [â eLpNorm_congr_ae (Lp.coeFn_sub _ _)]; exact Lp.eLpNorm_ne_top _
calc
(eLpNorm (âg - âf) 1 ÎŒ').toReal †(c' * eLpNorm (âg - âf) 1 ÎŒ).toReal := by
refine toReal_mono (ENNReal.mul_ne_top hc' h_eLpNorm_ne_top) ?_
refine (eLpNorm_mono_measure (âg - âf) hÎŒ'_le).trans_eq ?_
rw [eLpNorm_smul_measure_of_ne_zero hc'0, smul_eq_mul]
simp
_ = c'.toReal * (eLpNorm (âg - âf) 1 ÎŒ).toReal := toReal_mul
_ †c'.toReal * (ε / 2 / c'.toReal) := by gcongr
_ = ε / 2 := by
refine mul_div_cancelâ (ε / 2) ?_; rw [Ne, toReal_eq_zero_iff]; simp [hc', hc'0]
_ < ε := half_lt_self hε_pos
theorem setToFun_congr_measure_of_integrable {ÎŒ' : Measure α} (c' : ââ¥0â) (hc' : c' â â)
(hΌ'_le : Ό' †c' ⢠Ό) (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ' T C') (f : α â E) (hfÎŒ : Integrable f ÎŒ) :
setToFun Ό T hT f = setToFun Ό' T hT' f := by
-- integrability for `Ό` implies integrability for `Ό'`.
have h_int : â g : α â E, Integrable g ÎŒ â Integrable g ÎŒ' := fun g hg =>
Integrable.of_measure_le_smul hc' hΌ'_le hg
-- We use `Integrable.induction`
apply hfΌ.induction (P := fun f => setToFun Ό T hT f = setToFun Ό' T hT' f)
· intro c s hs hΌs
have hÎŒ's : ÎŒ' s â â := by
refine ((hΌ'_le s).trans_lt ?_).ne
rw [Measure.smul_apply, smul_eq_mul]
exact ENNReal.mul_lt_top hc'.lt_top hÎŒs
rw [setToFun_indicator_const hT hs hΌs.ne, setToFun_indicator_const hT' hs hΌ's]
· intro fâ gâ _ hfâ hgâ h_eq_f h_eq_g
rw [setToFun_add hT hfâ hgâ, setToFun_add hT' (h_int fâ hfâ) (h_int gâ hgâ), h_eq_f, h_eq_g]
· refine isClosed_eq (continuous_setToFun hT) ?_
have :
(fun f : α ââ[ÎŒ] E => setToFun ÎŒ' T hT' f) = fun f : α ââ[ÎŒ] E =>
setToFun Ό' T hT' ((h_int f (L1.integrable_coeFn f)).toL1 f) := by
ext1 f; exact setToFun_congr_ae hT' (Integrable.coeFn_toL1 _).symm
rw [this]
exact (continuous_setToFun hT').comp (continuous_L1_toL1 c' hc' hΌ'_le)
· intro fâ gâ hfg _ hf_eq
have hfg' : fâ =áµ[ÎŒ'] gâ := (Measure.absolutelyContinuous_of_le_smul hÎŒ'_le).ae_eq hfg
rw [â setToFun_congr_ae hT hfg, hf_eq, setToFun_congr_ae hT' hfg']
theorem setToFun_congr_measure {ÎŒ' : Measure α} (c c' : ââ¥0â) (hc : c â â) (hc' : c' â â)
(hΌ_le : Ό †c ⢠Ό') (hΌ'_le : Ό' †c' ⢠Ό) (hT : DominatedFinMeasAdditive Ό T C)
(hT' : DominatedFinMeasAdditive ÎŒ' T C') (f : α â E) :
setToFun Ό T hT f = setToFun Ό' T hT' f := by
by_cases hf : Integrable f Ό
· exact setToFun_congr_measure_of_integrable c' hc' hΌ'_le hT hT' f hf
· -- if `f` is not integrable, both `setToFun` are 0.
have h_int : â g : α â E, ¬Integrable g ÎŒ â ¬Integrable g ÎŒ' := fun g =>
mt fun h => h.of_measure_le_smul hc hΌ_le
simp_rw [setToFun_undef _ hf, setToFun_undef _ (h_int f hf)]
theorem setToFun_congr_measure_of_add_right {Ό' : Measure α}
(hT_add : DominatedFinMeasAdditive (Ό + Ό') T C') (hT : DominatedFinMeasAdditive Ό T C)
(f : α â E) (hf : Integrable f (ÎŒ + ÎŒ')) :
setToFun (Ό + Ό') T hT_add f = setToFun Ό T hT f := by
refine setToFun_congr_measure_of_integrable 1 one_ne_top ?_ hT_add hT f hf
rw [one_smul]
nth_rw 1 [â add_zero ÎŒ]
exact add_le_add le_rfl bot_le
theorem setToFun_congr_measure_of_add_left {Ό' : Measure α}
(hT_add : DominatedFinMeasAdditive (Ό + Ό') T C') (hT : DominatedFinMeasAdditive Ό' T C)
(f : α â E) (hf : Integrable f (ÎŒ + ÎŒ')) :
setToFun (Ό + Ό') T hT_add f = setToFun Ό' T hT f := by
refine setToFun_congr_measure_of_integrable 1 one_ne_top ?_ hT_add hT f hf
rw [one_smul]
nth_rw 1 [â zero_add ÎŒ']
exact add_le_add_right bot_le Ό'
theorem setToFun_top_smul_measure (hT : DominatedFinMeasAdditive (â ⢠Ό) T C) (f : α â E) :
setToFun (â ⢠Ό) T hT f = 0 := by
refine setToFun_measure_zero' hT fun s _ hÎŒs => ?_
rw [lt_top_iff_ne_top] at hÎŒs
simp only [true_and, Measure.smul_apply, ENNReal.mul_eq_top, eq_self_iff_true,
top_ne_zero, Ne, not_false_iff, not_or, Classical.not_not, smul_eq_mul] at hÎŒs
simp only [hÎŒs.right, Measure.smul_apply, mul_zero, smul_eq_mul]
theorem setToFun_congr_smul_measure (c : ââ¥0â) (hc_ne_top : c â â)
(hT : DominatedFinMeasAdditive Ό T C) (hT_smul : DominatedFinMeasAdditive (c ⢠Ό) T C')
(f : α â E) : setToFun ÎŒ T hT f = setToFun (c ⢠Ό) T hT_smul f := by
by_cases hc0 : c = 0
· simp [hc0] at hT_smul
have h : â s, MeasurableSet s â ÎŒ s < â â T s = 0 := fun s hs _ => hT_smul.eq_zero hs
rw [setToFun_zero_left' _ h, setToFun_measure_zero]
simp [hc0]
refine setToFun_congr_measure câ»Â¹ c ?_ hc_ne_top (le_of_eq ?_) le_rfl hT hT_smul f
· simp [hc0]
· rw [smul_smul, ENNReal.inv_mul_cancel hc0 hc_ne_top, one_smul]
theorem norm_setToFun_le_mul_norm (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α ââ[ÎŒ] E)
(hC : 0 †C) : âsetToFun ÎŒ T hT fâ †C * âfâ := by
rw [L1.setToFun_eq_setToL1]; exact L1.norm_setToL1_le_mul_norm hT hC f
theorem norm_setToFun_le_mul_norm' (hT : DominatedFinMeasAdditive ÎŒ T C) (f : α ââ[ÎŒ] E) :
âsetToFun ÎŒ T hT fâ †max C 0 * âfâ := by
rw [L1.setToFun_eq_setToL1]; exact L1.norm_setToL1_le_mul_norm' hT f
theorem norm_setToFun_le (hT : DominatedFinMeasAdditive Ό T C) (hf : Integrable f Ό) (hC : 0 †C) :
âsetToFun ÎŒ T hT fâ †C * âhf.toL1 fâ := by
rw [setToFun_eq hT hf]; exact L1.norm_setToL1_le_mul_norm hT hC _
theorem norm_setToFun_le' (hT : DominatedFinMeasAdditive Ό T C) (hf : Integrable f Ό) :
âsetToFun ÎŒ T hT fâ †max C 0 * âhf.toL1 fâ := by
rw [setToFun_eq hT hf]; exact L1.norm_setToL1_le_mul_norm' hT _
/-- Lebesgue dominated convergence theorem provides sufficient conditions under which almost
everywhere convergence of a sequence of functions implies the convergence of their image by
`setToFun`.
We could weaken the condition `bound_integrable` to require `HasFiniteIntegral bound Ό` instead
(i.e. not requiring that `bound` is measurable), but in all applications proving integrability
is easier. -/
theorem tendsto_setToFun_of_dominated_convergence (hT : DominatedFinMeasAdditive Ό T C)
{fs : â â α â E} {f : α â E} (bound : α â â)
(fs_measurable : â n, AEStronglyMeasurable (fs n) ÎŒ) (bound_integrable : Integrable bound ÎŒ)
(h_bound : â n, âáµ a âÎŒ, âfs n aâ †bound a)
(h_lim : âáµ a âÎŒ, Tendsto (fun n => fs n a) atTop (ð (f a))) :
Tendsto (fun n => setToFun ÎŒ T hT (fs n)) atTop (ð <| setToFun ÎŒ T hT f) := by
-- `f` is a.e.-measurable, since it is the a.e.-pointwise limit of a.e.-measurable functions.
have f_measurable : AEStronglyMeasurable f Ό :=
aestronglyMeasurable_of_tendsto_ae _ fs_measurable h_lim
-- all functions we consider are integrable
have fs_int : â n, Integrable (fs n) ÎŒ := fun n =>
bound_integrable.mono' (fs_measurable n) (h_bound _)
have f_int : Integrable f Ό :=
âšf_measurable,
hasFiniteIntegral_of_dominated_convergence bound_integrable.hasFiniteIntegral h_bound
h_limâ©
-- it suffices to prove the result for the corresponding L1 functions
suffices
Tendsto (fun n => L1.setToL1 hT ((fs_int n).toL1 (fs n))) atTop
(ð (L1.setToL1 hT (f_int.toL1 f))) by
convert this with n
· exact setToFun_eq hT (fs_int n)
· exact setToFun_eq hT f_int
-- the convergence of setToL1 follows from the convergence of the L1 functions
refine L1.tendsto_setToL1 hT _ _ ?_
-- up to some rewriting, what we need to prove is `h_lim`
rw [tendsto_iff_norm_sub_tendsto_zero]
have lintegral_norm_tendsto_zero :
Tendsto (fun n => ENNReal.toReal <| â«â» a, ENNReal.ofReal âfs n a - f aâ âÎŒ) atTop (ð 0) :=
(tendsto_toReal zero_ne_top).comp
(tendsto_lintegral_norm_of_dominated_convergence fs_measurable
bound_integrable.hasFiniteIntegral h_bound h_lim)
convert lintegral_norm_tendsto_zero with n
rw [L1.norm_def]
congr 1
refine lintegral_congr_ae ?_
rw [â Integrable.toL1_sub]
refine ((fs_int n).sub f_int).coeFn_toL1.mono fun x hx => ?_
dsimp only
rw [hx, ofReal_norm_eq_enorm, Pi.sub_apply]
/-- Lebesgue dominated convergence theorem for filters with a countable basis -/
theorem tendsto_setToFun_filter_of_dominated_convergence (hT : DominatedFinMeasAdditive Ό T C) {ι}
{l : Filter ι} [l.IsCountablyGenerated] {fs : ι â α â E} {f : α â E} (bound : α â â)
(hfs_meas : âá¶ n in l, AEStronglyMeasurable (fs n) ÎŒ)
(h_bound : âá¶ n in l, âáµ a âÎŒ, âfs n aâ †bound a) (bound_integrable : Integrable bound ÎŒ)
(h_lim : âáµ a âÎŒ, Tendsto (fun n => fs n a) l (ð (f a))) :
Tendsto (fun n => setToFun ÎŒ T hT (fs n)) l (ð <| setToFun ÎŒ T hT f) := by
rw [tendsto_iff_seq_tendsto]
intro x xl
have hxl : â s â l, â a, â b ⥠a, x b â s := by rwa [tendsto_atTop'] at xl
have h :
{ x : ι | (fun n => AEStronglyMeasurable (fs n) ÎŒ) x } â©
{ x : ι | (fun n => âáµ a âÎŒ, âfs n aâ †bound a) x } â l :=
inter_mem hfs_meas h_bound
obtain âšk, hâ© := hxl _ h
rw [â tendsto_add_atTop_iff_nat k]
refine tendsto_setToFun_of_dominated_convergence hT bound ?_ bound_integrable ?_ ?_
· exact fun n => (h _ (self_le_add_left _ _)).1
· exact fun n => (h _ (self_le_add_left _ _)).2
· filter_upwards [h_lim]
refine fun a h_lin => @Tendsto.comp _ _ _ (fun n => x (n + k)) (fun n => fs n a) _ _ _ h_lin ?_
rwa [tendsto_add_atTop_iff_nat]
variable {X : Type*} [TopologicalSpace X] [FirstCountableTopology X]
theorem continuousWithinAt_setToFun_of_dominated (hT : DominatedFinMeasAdditive Ό T C)
{fs : X â α â E} {xâ : X} {bound : α â â} {s : Set X}
(hfs_meas : âá¶ x in ð[s] xâ, AEStronglyMeasurable (fs x) ÎŒ)
(h_bound : âá¶ x in ð[s] xâ, âáµ a âÎŒ, âfs x aâ †bound a) (bound_integrable : Integrable bound ÎŒ)
(h_cont : âáµ a âÎŒ, ContinuousWithinAt (fun x => fs x a) s xâ) :
ContinuousWithinAt (fun x => setToFun ÎŒ T hT (fs x)) s xâ :=
tendsto_setToFun_filter_of_dominated_convergence hT bound â¹_⺠â¹_⺠â¹_⺠â¹_âº
theorem continuousAt_setToFun_of_dominated (hT : DominatedFinMeasAdditive ÎŒ T C) {fs : X â α â E}
{xâ : X} {bound : α â â} (hfs_meas : âá¶ x in ð xâ, AEStronglyMeasurable (fs x) ÎŒ)
(h_bound : âá¶ x in ð xâ, âáµ a âÎŒ, âfs x aâ †bound a) (bound_integrable : Integrable bound ÎŒ)
(h_cont : âáµ a âÎŒ, ContinuousAt (fun x => fs x a) xâ) :
ContinuousAt (fun x => setToFun ÎŒ T hT (fs x)) xâ :=
tendsto_setToFun_filter_of_dominated_convergence hT bound â¹_⺠â¹_⺠â¹_⺠â¹_âº
theorem continuousOn_setToFun_of_dominated (hT : DominatedFinMeasAdditive ÎŒ T C) {fs : X â α â E}
{bound : α â â} {s : Set X} (hfs_meas : â x â s, AEStronglyMeasurable (fs x) ÎŒ)
(h_bound : â x â s, âáµ a âÎŒ, âfs x aâ †bound a) (bound_integrable : Integrable bound ÎŒ)
(h_cont : âáµ a âÎŒ, ContinuousOn (fun x => fs x a) s) :
ContinuousOn (fun x => setToFun Ό T hT (fs x)) s := by
intro x hx
refine continuousWithinAt_setToFun_of_dominated hT ?_ ?_ bound_integrable ?_
· filter_upwards [self_mem_nhdsWithin] with x hx using hfs_meas x hx
· filter_upwards [self_mem_nhdsWithin] with x hx using h_bound x hx
· filter_upwards [h_cont] with a ha using ha x hx
theorem continuous_setToFun_of_dominated (hT : DominatedFinMeasAdditive ÎŒ T C) {fs : X â α â E}
{bound : α â â} (hfs_meas : â x, AEStronglyMeasurable (fs x) ÎŒ)
(h_bound : â x, âáµ a âÎŒ, âfs x aâ †bound a) (bound_integrable : Integrable bound ÎŒ)
(h_cont : âáµ a âÎŒ, Continuous fun x => fs x a) : Continuous fun x => setToFun ÎŒ T hT (fs x) :=
continuous_iff_continuousAt.mpr fun _ =>
continuousAt_setToFun_of_dominated hT (Eventually.of_forall hfs_meas)
(Eventually.of_forall h_bound) â¹_⺠<|
h_cont.mono fun _ => Continuous.continuousAt
end Function
end MeasureTheory
| Mathlib/MeasureTheory/Integral/SetToL1.lean | 1,396 | 1,405 | |
/-
Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.FDeriv.Linear
import Mathlib.Analysis.Calculus.FDeriv.Comp
/-!
# Additive operations on derivatives
For detailed documentation of the Fréchet derivative,
see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
* sum of finitely many functions
* multiplication of a function by a scalar constant
* negative of a function
* subtraction of two functions
-/
open Filter Asymptotics ContinuousLinearMap
noncomputable section
section
variable {ð : Type*} [NontriviallyNormedField ð]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ð E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ð F]
variable {f g : E â F}
variable {f' g' : E âL[ð] F}
variable {x : E}
variable {s : Set E}
variable {L : Filter E}
section ConstSMul
variable {R : Type*} [Semiring R] [Module R F] [SMulCommClass ð R F] [ContinuousConstSMul R F]
/-! ### Derivative of a function multiplied by a constant -/
@[fun_prop]
theorem HasStrictFDerivAt.const_smul (h : HasStrictFDerivAt f f' x) (c : R) :
HasStrictFDerivAt (fun x => c ⢠f x) (c ⢠f') x :=
(c ⢠(1 : F âL[ð] F)).hasStrictFDerivAt.comp x h
theorem HasFDerivAtFilter.const_smul (h : HasFDerivAtFilter f f' x L) (c : R) :
HasFDerivAtFilter (fun x => c ⢠f x) (c ⢠f') x L :=
(c ⢠(1 : F âL[ð] F)).hasFDerivAtFilter.comp x h tendsto_map
@[fun_prop]
nonrec theorem HasFDerivWithinAt.const_smul (h : HasFDerivWithinAt f f' s x) (c : R) :
HasFDerivWithinAt (fun x => c ⢠f x) (c ⢠f') s x :=
h.const_smul c
@[fun_prop]
nonrec theorem HasFDerivAt.const_smul (h : HasFDerivAt f f' x) (c : R) :
HasFDerivAt (fun x => c ⢠f x) (c ⢠f') x :=
h.const_smul c
@[fun_prop]
theorem DifferentiableWithinAt.const_smul (h : DifferentiableWithinAt ð f s x) (c : R) :
DifferentiableWithinAt ð (fun y => c ⢠f y) s x :=
(h.hasFDerivWithinAt.const_smul c).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.const_smul (h : DifferentiableAt ð f x) (c : R) :
DifferentiableAt ð (fun y => c ⢠f y) x :=
(h.hasFDerivAt.const_smul c).differentiableAt
@[fun_prop]
theorem DifferentiableOn.const_smul (h : DifferentiableOn ð f s) (c : R) :
DifferentiableOn ð (fun y => c ⢠f y) s := fun x hx => (h x hx).const_smul c
@[fun_prop]
theorem Differentiable.const_smul (h : Differentiable ð f) (c : R) :
Differentiable ð fun y => c ⢠f y := fun x => (h x).const_smul c
theorem fderivWithin_const_smul (hxs : UniqueDiffWithinAt ð s x)
(h : DifferentiableWithinAt ð f s x) (c : R) :
fderivWithin ð (fun y => c ⢠f y) s x = c ⢠fderivWithin ð f s x :=
(h.hasFDerivWithinAt.const_smul c).fderivWithin hxs
/-- Version of `fderivWithin_const_smul` written with `c ⢠f` instead of `fun y ⊠c ⢠f y`. -/
theorem fderivWithin_const_smul' (hxs : UniqueDiffWithinAt ð s x)
(h : DifferentiableWithinAt ð f s x) (c : R) :
fderivWithin ð (c ⢠f) s x = c ⢠fderivWithin ð f s x :=
fderivWithin_const_smul hxs h c
theorem fderiv_const_smul (h : DifferentiableAt ð f x) (c : R) :
fderiv ð (fun y => c ⢠f y) x = c ⢠fderiv ð f x :=
(h.hasFDerivAt.const_smul c).fderiv
/-- Version of `fderiv_const_smul` written with `c ⢠f` instead of `fun y ⊠c ⢠f y`. -/
theorem fderiv_const_smul' (h : DifferentiableAt ð f x) (c : R) :
fderiv ð (c ⢠f) x = c ⢠fderiv ð f x :=
(h.hasFDerivAt.const_smul c).fderiv
end ConstSMul
section Add
/-! ### Derivative of the sum of two functions -/
@[fun_prop]
nonrec theorem HasStrictFDerivAt.add (hf : HasStrictFDerivAt f f' x)
(hg : HasStrictFDerivAt g g' x) : HasStrictFDerivAt (fun y => f y + g y) (f' + g') x :=
.of_isLittleO <| (hf.isLittleO.add hg.isLittleO).congr_left fun y => by
simp only [LinearMap.sub_apply, LinearMap.add_apply, map_sub, map_add, add_apply]
abel
theorem HasFDerivAtFilter.add (hf : HasFDerivAtFilter f f' x L)
(hg : HasFDerivAtFilter g g' x L) : HasFDerivAtFilter (fun y => f y + g y) (f' + g') x L :=
.of_isLittleO <| (hf.isLittleO.add hg.isLittleO).congr_left fun _ => by
simp only [LinearMap.sub_apply, LinearMap.add_apply, map_sub, map_add, add_apply]
abel
@[fun_prop]
nonrec theorem HasFDerivWithinAt.add (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt g g' s x) : HasFDerivWithinAt (fun y => f y + g y) (f' + g') s x :=
hf.add hg
@[fun_prop]
nonrec theorem HasFDerivAt.add (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) :
HasFDerivAt (fun x => f x + g x) (f' + g') x :=
hf.add hg
@[fun_prop]
theorem DifferentiableWithinAt.add (hf : DifferentiableWithinAt ð f s x)
(hg : DifferentiableWithinAt ð g s x) : DifferentiableWithinAt ð (fun y => f y + g y) s x :=
(hf.hasFDerivWithinAt.add hg.hasFDerivWithinAt).differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.add (hf : DifferentiableAt ð f x) (hg : DifferentiableAt ð g x) :
DifferentiableAt ð (fun y => f y + g y) x :=
(hf.hasFDerivAt.add hg.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableOn.add (hf : DifferentiableOn ð f s) (hg : DifferentiableOn ð g s) :
DifferentiableOn ð (fun y => f y + g y) s := fun x hx => (hf x hx).add (hg x hx)
@[simp, fun_prop]
theorem Differentiable.add (hf : Differentiable ð f) (hg : Differentiable ð g) :
Differentiable ð fun y => f y + g y := fun x => (hf x).add (hg x)
theorem fderivWithin_add (hxs : UniqueDiffWithinAt ð s x) (hf : DifferentiableWithinAt ð f s x)
(hg : DifferentiableWithinAt ð g s x) :
fderivWithin ð (fun y => f y + g y) s x = fderivWithin ð f s x + fderivWithin ð g s x :=
(hf.hasFDerivWithinAt.add hg.hasFDerivWithinAt).fderivWithin hxs
/-- Version of `fderivWithin_add` where the function is written as `f + g` instead
of `fun y ⊠f y + g y`. -/
theorem fderivWithin_add' (hxs : UniqueDiffWithinAt ð s x) (hf : DifferentiableWithinAt ð f s x)
(hg : DifferentiableWithinAt ð g s x) :
fderivWithin ð (f + g) s x = fderivWithin ð f s x + fderivWithin ð g s x :=
fderivWithin_add hxs hf hg
theorem fderiv_add (hf : DifferentiableAt ð f x) (hg : DifferentiableAt ð g x) :
fderiv ð (fun y => f y + g y) x = fderiv ð f x + fderiv ð g x :=
(hf.hasFDerivAt.add hg.hasFDerivAt).fderiv
/-- Version of `fderiv_add` where the function is written as `f + g` instead
of `fun y ⊠f y + g y`. -/
theorem fderiv_add' (hf : DifferentiableAt ð f x) (hg : DifferentiableAt ð g x) :
fderiv ð (f + g) x = fderiv ð f x + fderiv ð g x :=
fderiv_add hf hg
@[simp]
theorem hasFDerivAtFilter_add_const_iff (c : F) :
HasFDerivAtFilter (f · + c) f' x L â HasFDerivAtFilter f f' x L := by
simp [hasFDerivAtFilter_iff_isLittleOTVS]
alias âš_, HasFDerivAtFilter.add_constâ© := hasFDerivAtFilter_add_const_iff
@[simp]
theorem hasStrictFDerivAt_add_const_iff (c : F) :
HasStrictFDerivAt (f · + c) f' x â HasStrictFDerivAt f f' x := by
simp [hasStrictFDerivAt_iff_isLittleO]
@[fun_prop]
alias âš_, HasStrictFDerivAt.add_constâ© := hasStrictFDerivAt_add_const_iff
@[simp]
theorem hasFDerivWithinAt_add_const_iff (c : F) :
HasFDerivWithinAt (f · + c) f' s x â HasFDerivWithinAt f f' s x :=
hasFDerivAtFilter_add_const_iff c
@[fun_prop]
alias âš_, HasFDerivWithinAt.add_constâ© := hasFDerivWithinAt_add_const_iff
@[simp]
theorem hasFDerivAt_add_const_iff (c : F) : HasFDerivAt (f · + c) f' x â HasFDerivAt f f' x :=
hasFDerivAtFilter_add_const_iff c
@[fun_prop]
alias âš_, HasFDerivAt.add_constâ© := hasFDerivAt_add_const_iff
@[simp]
theorem differentiableWithinAt_add_const_iff (c : F) :
DifferentiableWithinAt ð (fun y => f y + c) s x â DifferentiableWithinAt ð f s x :=
exists_congr fun _ ⊠hasFDerivWithinAt_add_const_iff c
@[fun_prop]
alias âš_, DifferentiableWithinAt.add_constâ© := differentiableWithinAt_add_const_iff
@[simp]
theorem differentiableAt_add_const_iff (c : F) :
DifferentiableAt ð (fun y => f y + c) x â DifferentiableAt ð f x :=
exists_congr fun _ ⊠hasFDerivAt_add_const_iff c
@[fun_prop]
alias âš_, DifferentiableAt.add_constâ© := differentiableAt_add_const_iff
@[simp]
theorem differentiableOn_add_const_iff (c : F) :
DifferentiableOn ð (fun y => f y + c) s â DifferentiableOn ð f s :=
forallâ_congr fun _ _ ⊠differentiableWithinAt_add_const_iff c
@[fun_prop]
alias âš_, DifferentiableOn.add_constâ© := differentiableOn_add_const_iff
@[simp]
theorem differentiable_add_const_iff (c : F) :
(Differentiable ð fun y => f y + c) â Differentiable ð f :=
forall_congr' fun _ ⊠differentiableAt_add_const_iff c
@[fun_prop]
alias âš_, Differentiable.add_constâ© := differentiable_add_const_iff
@[simp]
theorem fderivWithin_add_const (c : F) :
fderivWithin ð (fun y => f y + c) s x = fderivWithin ð f s x := by
classical simp [fderivWithin]
@[simp]
theorem fderiv_add_const (c : F) : fderiv ð (fun y => f y + c) x = fderiv ð f x := by
simp only [â fderivWithin_univ, fderivWithin_add_const]
@[simp]
theorem hasFDerivAtFilter_const_add_iff (c : F) :
HasFDerivAtFilter (c + f ·) f' x L â HasFDerivAtFilter f f' x L := by
simpa only [add_comm] using hasFDerivAtFilter_add_const_iff c
alias âš_, HasFDerivAtFilter.const_addâ© := hasFDerivAtFilter_const_add_iff
@[simp]
theorem hasStrictFDerivAt_const_add_iff (c : F) :
HasStrictFDerivAt (c + f ·) f' x â HasStrictFDerivAt f f' x := by
simpa only [add_comm] using hasStrictFDerivAt_add_const_iff c
@[fun_prop]
alias âš_, HasStrictFDerivAt.const_addâ© := hasStrictFDerivAt_const_add_iff
@[simp]
theorem hasFDerivWithinAt_const_add_iff (c : F) :
HasFDerivWithinAt (c + f ·) f' s x â HasFDerivWithinAt f f' s x :=
hasFDerivAtFilter_const_add_iff c
@[fun_prop]
alias âš_, HasFDerivWithinAt.const_addâ© := hasFDerivWithinAt_const_add_iff
@[simp]
theorem hasFDerivAt_const_add_iff (c : F) : HasFDerivAt (c + f ·) f' x â HasFDerivAt f f' x :=
hasFDerivAtFilter_const_add_iff c
@[fun_prop]
alias âš_, HasFDerivAt.const_addâ© := hasFDerivAt_const_add_iff
@[simp]
theorem differentiableWithinAt_const_add_iff (c : F) :
DifferentiableWithinAt ð (fun y => c + f y) s x â DifferentiableWithinAt ð f s x :=
exists_congr fun _ ⊠hasFDerivWithinAt_const_add_iff c
@[fun_prop]
alias âš_, DifferentiableWithinAt.const_addâ© := differentiableWithinAt_const_add_iff
@[simp]
theorem differentiableAt_const_add_iff (c : F) :
DifferentiableAt ð (fun y => c + f y) x â DifferentiableAt ð f x :=
exists_congr fun _ ⊠hasFDerivAt_const_add_iff c
@[fun_prop]
alias âš_, DifferentiableAt.const_addâ© := differentiableAt_const_add_iff
@[simp]
theorem differentiableOn_const_add_iff (c : F) :
DifferentiableOn ð (fun y => c + f y) s â DifferentiableOn ð f s :=
forallâ_congr fun _ _ ⊠differentiableWithinAt_const_add_iff c
@[fun_prop]
alias âš_, DifferentiableOn.const_addâ© := differentiableOn_const_add_iff
@[simp]
theorem differentiable_const_add_iff (c : F) :
(Differentiable ð fun y => c + f y) â Differentiable ð f :=
forall_congr' fun _ ⊠differentiableAt_const_add_iff c
@[fun_prop]
alias âš_, Differentiable.const_addâ© := differentiable_const_add_iff
@[simp]
theorem fderivWithin_const_add (c : F) :
fderivWithin ð (fun y => c + f y) s x = fderivWithin ð f s x := by
simpa only [add_comm] using fderivWithin_add_const c
@[simp]
| theorem fderiv_const_add (c : F) : fderiv ð (fun y => c + f y) x = fderiv ð f x := by
simp only [add_comm c, fderiv_add_const]
| Mathlib/Analysis/Calculus/FDeriv/Add.lean | 311 | 313 |
/-
Copyright (c) 2018 Ellen Arlt. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin, Lu-Ming Zhang
-/
import Mathlib.Algebra.Algebra.Opposite
import Mathlib.Algebra.Algebra.Pi
import Mathlib.Algebra.BigOperators.RingEquiv
import Mathlib.Data.Finite.Prod
import Mathlib.Data.Matrix.Mul
import Mathlib.LinearAlgebra.Pi
/-!
# Matrices
This file contains basic results on matrices including bundled versions of matrix operators.
## Implementation notes
For convenience, `Matrix m n α` is defined as `m â n â α`, as this allows elements of the matrix
to be accessed with `A i j`. However, it is not advisable to _construct_ matrices using terms of the
form `fun i j ⊠_` or even `(fun i j ⊠_ : Matrix m n α)`, as these are not recognized by Lean
as having the right type. Instead, `Matrix.of` should be used.
## TODO
Under various conditions, multiplication of infinite matrices makes sense.
These have not yet been implemented.
-/
assert_not_exists Star
universe u u' v w
variable {l m n o : Type*} {m' : o â Type*} {n' : o â Type*}
variable {R : Type*} {S : Type*} {α : Type v} {β : Type w} {γ : Type*}
namespace Matrix
instance decidableEq [DecidableEq α] [Fintype m] [Fintype n] : DecidableEq (Matrix m n α) :=
Fintype.decidablePiFintype
instance {n m} [Fintype m] [DecidableEq m] [Fintype n] [DecidableEq n] (α) [Fintype α] :
Fintype (Matrix m n α) := inferInstanceAs (Fintype (m â n â α))
instance {n m} [Finite m] [Finite n] (α) [Finite α] :
Finite (Matrix m n α) := inferInstanceAs (Finite (m â n â α))
section
variable (R)
/-- This is `Matrix.of` bundled as a linear equivalence. -/
def ofLinearEquiv [Semiring R] [AddCommMonoid α] [Module R α] : (m â n â α) ââ[R] Matrix m n α where
__ := ofAddEquiv
map_smul' _ _ := rfl
@[simp] lemma coe_ofLinearEquiv [Semiring R] [AddCommMonoid α] [Module R α] :
â(ofLinearEquiv _ : (m â n â α) ââ[R] Matrix m n α) = of := rfl
@[simp] lemma coe_ofLinearEquiv_symm [Semiring R] [AddCommMonoid α] [Module R α] :
â((ofLinearEquiv _).symm : Matrix m n α ââ[R] (m â n â α)) = of.symm := rfl
end
theorem sum_apply [AddCommMonoid α] (i : m) (j : n) (s : Finset β) (g : β â Matrix m n α) :
(â c â s, g c) i j = â c â s, g c i j :=
(congr_fun (s.sum_apply i g) j).trans (s.sum_apply j _)
end Matrix
open Matrix
namespace Matrix
section Diagonal
variable [DecidableEq n]
variable (n α)
/-- `Matrix.diagonal` as an `AddMonoidHom`. -/
@[simps]
def diagonalAddMonoidHom [AddZeroClass α] : (n â α) â+ Matrix n n α where
toFun := diagonal
map_zero' := diagonal_zero
map_add' x y := (diagonal_add x y).symm
variable (R)
/-- `Matrix.diagonal` as a `LinearMap`. -/
@[simps]
def diagonalLinearMap [Semiring R] [AddCommMonoid α] [Module R α] : (n â α) ââ[R] Matrix n n α :=
{ diagonalAddMonoidHom n α with map_smul' := diagonal_smul }
variable {n α R}
section One
variable [Zero α] [One α]
lemma zero_le_one_elem [Preorder α] [ZeroLEOneClass α] (i j : n) :
0 †(1 : Matrix n n α) i j := by
by_cases hi : i = j
· subst hi
simp
· simp [hi]
lemma zero_le_one_row [Preorder α] [ZeroLEOneClass α] (i : n) :
0 †(1 : Matrix n n α) i :=
zero_le_one_elem i
end One
end Diagonal
section Diag
variable (n α)
/-- `Matrix.diag` as an `AddMonoidHom`. -/
@[simps]
def diagAddMonoidHom [AddZeroClass α] : Matrix n n α â+ n â α where
toFun := diag
map_zero' := diag_zero
map_add' := diag_add
variable (R)
/-- `Matrix.diag` as a `LinearMap`. -/
@[simps]
def diagLinearMap [Semiring R] [AddCommMonoid α] [Module R α] : Matrix n n α ââ[R] n â α :=
{ diagAddMonoidHom n α with map_smul' := diag_smul }
variable {n α R}
@[simp]
theorem diag_list_sum [AddMonoid α] (l : List (Matrix n n α)) : diag l.sum = (l.map diag).sum :=
map_list_sum (diagAddMonoidHom n α) l
@[simp]
theorem diag_multiset_sum [AddCommMonoid α] (s : Multiset (Matrix n n α)) :
diag s.sum = (s.map diag).sum :=
map_multiset_sum (diagAddMonoidHom n α) s
@[simp]
theorem diag_sum {ι} [AddCommMonoid α] (s : Finset ι) (f : ι â Matrix n n α) :
diag (â i â s, f i) = â i â s, diag (f i) :=
map_sum (diagAddMonoidHom n α) f s
end Diag
open Matrix
section AddCommMonoid
variable [AddCommMonoid α] [Mul α]
end AddCommMonoid
section NonAssocSemiring
variable [NonAssocSemiring α]
variable (α n)
/-- `Matrix.diagonal` as a `RingHom`. -/
@[simps]
def diagonalRingHom [Fintype n] [DecidableEq n] : (n â α) â+* Matrix n n α :=
{ diagonalAddMonoidHom n α with
toFun := diagonal
map_one' := diagonal_one
map_mul' := fun _ _ => (diagonal_mul_diagonal' _ _).symm }
end NonAssocSemiring
section Semiring
variable [Semiring α]
theorem diagonal_pow [Fintype n] [DecidableEq n] (v : n â α) (k : â) :
diagonal v ^ k = diagonal (v ^ k) :=
(map_pow (diagonalRingHom n α) v k).symm
/-- The ring homomorphism `α â+* Matrix n n α`
sending `a` to the diagonal matrix with `a` on the diagonal.
-/
def scalar (n : Type u) [DecidableEq n] [Fintype n] : α â+* Matrix n n α :=
(diagonalRingHom n α).comp <| Pi.constRingHom n α
section Scalar
variable [DecidableEq n] [Fintype n]
@[simp]
theorem scalar_apply (a : α) : scalar n a = diagonal fun _ => a :=
rfl
theorem scalar_inj [Nonempty n] {r s : α} : scalar n r = scalar n s â r = s :=
(diagonal_injective.comp Function.const_injective).eq_iff
theorem scalar_commute_iff {r : α} {M : Matrix n n α} :
Commute (scalar n r) M â r ⢠M = MulOpposite.op r ⢠M := by
simp_rw [Commute, SemiconjBy, scalar_apply, â smul_eq_diagonal_mul, â op_smul_eq_mul_diagonal]
theorem scalar_commute (r : α) (hr : â r', Commute r r') (M : Matrix n n α) :
Commute (scalar n r) M := scalar_commute_iff.2 <| ext fun _ _ => hr _
end Scalar
end Semiring
section Algebra
variable [Fintype n] [DecidableEq n]
variable [CommSemiring R] [Semiring α] [Semiring β] [Algebra R α] [Algebra R β]
instance instAlgebra : Algebra R (Matrix n n α) where
algebraMap := (Matrix.scalar n).comp (algebraMap R α)
commutes' _ _ := scalar_commute _ (fun _ => Algebra.commutes _ _) _
smul_def' r x := by ext; simp [Matrix.scalar, Algebra.smul_def r]
theorem algebraMap_matrix_apply {r : R} {i j : n} :
algebraMap R (Matrix n n α) r i j = if i = j then algebraMap R α r else 0 := by
dsimp [algebraMap, Algebra.algebraMap, Matrix.scalar]
split_ifs with h <;> simp [h, Matrix.one_apply_ne]
theorem algebraMap_eq_diagonal (r : R) :
algebraMap R (Matrix n n α) r = diagonal (algebraMap R (n â α) r) := rfl
theorem algebraMap_eq_diagonalRingHom :
algebraMap R (Matrix n n α) = (diagonalRingHom n α).comp (algebraMap R _) := rfl
@[simp]
theorem map_algebraMap (r : R) (f : α â β) (hf : f 0 = 0)
(hfâ : f (algebraMap R α r) = algebraMap R β r) :
(algebraMap R (Matrix n n α) r).map f = algebraMap R (Matrix n n β) r := by
rw [algebraMap_eq_diagonal, algebraMap_eq_diagonal, diagonal_map hf]
simp [hfâ]
variable (R)
/-- `Matrix.diagonal` as an `AlgHom`. -/
@[simps]
def diagonalAlgHom : (n â α) ââ[R] Matrix n n α :=
{ diagonalRingHom n α with
toFun := diagonal
commutes' := fun r => (algebraMap_eq_diagonal r).symm }
end Algebra
section AddHom
variable [Add α]
variable (R α) in
/-- Extracting entries from a matrix as an additive homomorphism. -/
@[simps]
def entryAddHom (i : m) (j : n) : AddHom (Matrix m n α) α where
toFun M := M i j
map_add' _ _ := rfl
-- It is necessary to spell out the name of the coercion explicitly on the RHS
-- for unification to succeed
lemma entryAddHom_eq_comp {i : m} {j : n} :
entryAddHom α i j =
((Pi.evalAddHom (fun _ => α) j).comp (Pi.evalAddHom _ i)).comp
(AddHomClass.toAddHom ofAddEquiv.symm) :=
rfl
end AddHom
section AddMonoidHom
variable [AddZeroClass α]
variable (R α) in
/--
Extracting entries from a matrix as an additive monoid homomorphism. Note this cannot be upgraded to
a ring homomorphism, as it does not respect multiplication.
-/
@[simps]
def entryAddMonoidHom (i : m) (j : n) : Matrix m n α â+ α where
toFun M := M i j
map_add' _ _ := rfl
map_zero' := rfl
-- It is necessary to spell out the name of the coercion explicitly on the RHS
-- for unification to succeed
lemma entryAddMonoidHom_eq_comp {i : m} {j : n} :
entryAddMonoidHom α i j =
((Pi.evalAddMonoidHom (fun _ => α) j).comp (Pi.evalAddMonoidHom _ i)).comp
(AddMonoidHomClass.toAddMonoidHom ofAddEquiv.symm) := by
rfl
@[simp] lemma evalAddMonoidHom_comp_diagAddMonoidHom (i : m) :
(Pi.evalAddMonoidHom _ i).comp (diagAddMonoidHom m α) = entryAddMonoidHom α i i := by
simp [AddMonoidHom.ext_iff]
@[simp] lemma entryAddMonoidHom_toAddHom {i : m} {j : n} :
(entryAddMonoidHom α i j : AddHom _ _) = entryAddHom α i j := rfl
end AddMonoidHom
section LinearMap
variable [Semiring R] [AddCommMonoid α] [Module R α]
variable (R α) in
/--
Extracting entries from a matrix as a linear map. Note this cannot be upgraded to an algebra
homomorphism, as it does not respect multiplication.
-/
@[simps]
def entryLinearMap (i : m) (j : n) :
Matrix m n α ââ[R] α where
toFun M := M i j
map_add' _ _ := rfl
map_smul' _ _ := rfl
-- It is necessary to spell out the name of the coercion explicitly on the RHS
-- for unification to succeed
lemma entryLinearMap_eq_comp {i : m} {j : n} :
entryLinearMap R α i j =
LinearMap.proj j ââ LinearMap.proj i ââ (ofLinearEquiv R).symm.toLinearMap := by
rfl
@[simp] lemma proj_comp_diagLinearMap (i : m) :
LinearMap.proj i ââ diagLinearMap m R α = entryLinearMap R α i i := by
simp [LinearMap.ext_iff]
@[simp] lemma entryLinearMap_toAddMonoidHom {i : m} {j : n} :
(entryLinearMap R α i j : _ â+ _) = entryAddMonoidHom α i j := rfl
@[simp] lemma entryLinearMap_toAddHom {i : m} {j : n} :
(entryLinearMap R α i j : AddHom _ _) = entryAddHom α i j := rfl
end LinearMap
end Matrix
/-!
### Bundled versions of `Matrix.map`
-/
namespace Equiv
/-- The `Equiv` between spaces of matrices induced by an `Equiv` between their
coefficients. This is `Matrix.map` as an `Equiv`. -/
@[simps apply]
def mapMatrix (f : α â β) : Matrix m n α â Matrix m n β where
toFun M := M.map f
invFun M := M.map f.symm
left_inv _ := Matrix.ext fun _ _ => f.symm_apply_apply _
right_inv _ := Matrix.ext fun _ _ => f.apply_symm_apply _
@[simp]
theorem mapMatrix_refl : (Equiv.refl α).mapMatrix = Equiv.refl (Matrix m n α) :=
rfl
@[simp]
theorem mapMatrix_symm (f : α â β) : f.mapMatrix.symm = (f.symm.mapMatrix : Matrix m n β â _) :=
rfl
@[simp]
theorem mapMatrix_trans (f : α â β) (g : β â γ) :
f.mapMatrix.trans g.mapMatrix = ((f.trans g).mapMatrix : Matrix m n α â _) :=
rfl
end Equiv
namespace AddMonoidHom
variable [AddZeroClass α] [AddZeroClass β] [AddZeroClass γ]
/-- The `AddMonoidHom` between spaces of matrices induced by an `AddMonoidHom` between their
coefficients. This is `Matrix.map` as an `AddMonoidHom`. -/
@[simps]
def mapMatrix (f : α â+ β) : Matrix m n α â+ Matrix m n β where
toFun M := M.map f
map_zero' := Matrix.map_zero f f.map_zero
map_add' := Matrix.map_add f f.map_add
@[simp]
theorem mapMatrix_id : (AddMonoidHom.id α).mapMatrix = AddMonoidHom.id (Matrix m n α) :=
rfl
@[simp]
theorem mapMatrix_comp (f : β â+ γ) (g : α â+ β) :
f.mapMatrix.comp g.mapMatrix = ((f.comp g).mapMatrix : Matrix m n α â+ _) :=
rfl
@[simp] lemma entryAddMonoidHom_comp_mapMatrix (f : α â+ β) (i : m) (j : n) :
(entryAddMonoidHom β i j).comp f.mapMatrix = f.comp (entryAddMonoidHom α i j) := rfl
end AddMonoidHom
namespace AddEquiv
variable [Add α] [Add β] [Add γ]
/-- The `AddEquiv` between spaces of matrices induced by an `AddEquiv` between their
coefficients. This is `Matrix.map` as an `AddEquiv`. -/
@[simps apply]
def mapMatrix (f : α â+ β) : Matrix m n α â+ Matrix m n β :=
{ f.toEquiv.mapMatrix with
toFun := fun M => M.map f
invFun := fun M => M.map f.symm
map_add' := Matrix.map_add f (map_add f) }
@[simp]
theorem mapMatrix_refl : (AddEquiv.refl α).mapMatrix = AddEquiv.refl (Matrix m n α) :=
rfl
@[simp]
theorem mapMatrix_symm (f : α â+ β) : f.mapMatrix.symm = (f.symm.mapMatrix : Matrix m n β â+ _) :=
rfl
@[simp]
theorem mapMatrix_trans (f : α â+ β) (g : β â+ γ) :
f.mapMatrix.trans g.mapMatrix = ((f.trans g).mapMatrix : Matrix m n α â+ _) :=
rfl
@[simp] lemma entryAddHom_comp_mapMatrix (f : α â+ β) (i : m) (j : n) :
(entryAddHom β i j).comp (AddHomClass.toAddHom f.mapMatrix) =
(f : AddHom α β).comp (entryAddHom _ i j) := rfl
end AddEquiv
namespace LinearMap
variable [Semiring R] [AddCommMonoid α] [AddCommMonoid β] [AddCommMonoid γ]
variable [Module R α] [Module R β] [Module R γ]
/-- The `LinearMap` between spaces of matrices induced by a `LinearMap` between their
coefficients. This is `Matrix.map` as a `LinearMap`. -/
@[simps]
def mapMatrix (f : α ââ[R] β) : Matrix m n α ââ[R] Matrix m n β where
toFun M := M.map f
map_add' := Matrix.map_add f f.map_add
map_smul' r := Matrix.map_smul f r (f.map_smul r)
@[simp]
theorem mapMatrix_id : LinearMap.id.mapMatrix = (LinearMap.id : Matrix m n α ââ[R] _) :=
rfl
@[simp]
theorem mapMatrix_comp (f : β ââ[R] γ) (g : α ââ[R] β) :
f.mapMatrix.comp g.mapMatrix = ((f.comp g).mapMatrix : Matrix m n α ââ[R] _) :=
rfl
@[simp] lemma entryLinearMap_comp_mapMatrix (f : α ââ[R] β) (i : m) (j : n) :
entryLinearMap R _ i j ââ f.mapMatrix = f ââ entryLinearMap R _ i j := rfl
end LinearMap
namespace LinearEquiv
variable [Semiring R] [AddCommMonoid α] [AddCommMonoid β] [AddCommMonoid γ]
variable [Module R α] [Module R β] [Module R γ]
/-- The `LinearEquiv` between spaces of matrices induced by a `LinearEquiv` between their
coefficients. This is `Matrix.map` as a `LinearEquiv`. -/
@[simps apply]
def mapMatrix (f : α ââ[R] β) : Matrix m n α ââ[R] Matrix m n β :=
{ f.toEquiv.mapMatrix,
f.toLinearMap.mapMatrix with
toFun := fun M => M.map f
invFun := fun M => M.map f.symm }
@[simp]
theorem mapMatrix_refl : (LinearEquiv.refl R α).mapMatrix = LinearEquiv.refl R (Matrix m n α) :=
rfl
@[simp]
theorem mapMatrix_symm (f : α ââ[R] β) :
f.mapMatrix.symm = (f.symm.mapMatrix : Matrix m n β ââ[R] _) :=
rfl
@[simp]
theorem mapMatrix_trans (f : α ââ[R] β) (g : β ââ[R] γ) :
f.mapMatrix.trans g.mapMatrix = ((f.trans g).mapMatrix : Matrix m n α ââ[R] _) :=
rfl
@[simp] lemma mapMatrix_toLinearMap (f : α ââ[R] β) :
(f.mapMatrix : _ ââ[R] Matrix m n β).toLinearMap = f.toLinearMap.mapMatrix := by
rfl
@[simp] lemma entryLinearMap_comp_mapMatrix (f : α ââ[R] β) (i : m) (j : n) :
entryLinearMap R _ i j ââ f.mapMatrix.toLinearMap =
f.toLinearMap ââ entryLinearMap R _ i j := by
simp only [mapMatrix_toLinearMap, LinearMap.entryLinearMap_comp_mapMatrix]
end LinearEquiv
namespace RingHom
variable [Fintype m] [DecidableEq m]
variable [NonAssocSemiring α] [NonAssocSemiring β] [NonAssocSemiring γ]
/-- The `RingHom` between spaces of square matrices induced by a `RingHom` between their
coefficients. This is `Matrix.map` as a `RingHom`. -/
@[simps]
def mapMatrix (f : α â+* β) : Matrix m m α â+* Matrix m m β :=
{ f.toAddMonoidHom.mapMatrix with
toFun := fun M => M.map f
map_one' := by simp
map_mul' := fun _ _ => Matrix.map_mul }
@[simp]
theorem mapMatrix_id : (RingHom.id α).mapMatrix = RingHom.id (Matrix m m α) :=
rfl
@[simp]
theorem mapMatrix_comp (f : β â+* γ) (g : α â+* β) :
f.mapMatrix.comp g.mapMatrix = ((f.comp g).mapMatrix : Matrix m m α â+* _) :=
rfl
end RingHom
namespace RingEquiv
variable [Fintype m] [DecidableEq m]
variable [NonAssocSemiring α] [NonAssocSemiring β] [NonAssocSemiring γ]
/-- The `RingEquiv` between spaces of square matrices induced by a `RingEquiv` between their
coefficients. This is `Matrix.map` as a `RingEquiv`. -/
@[simps apply]
def mapMatrix (f : α â+* β) : Matrix m m α â+* Matrix m m β :=
{ f.toRingHom.mapMatrix,
f.toAddEquiv.mapMatrix with
toFun := fun M => M.map f
invFun := fun M => M.map f.symm }
@[simp]
theorem mapMatrix_refl : (RingEquiv.refl α).mapMatrix = RingEquiv.refl (Matrix m m α) :=
rfl
@[simp]
theorem mapMatrix_symm (f : α â+* β) : f.mapMatrix.symm = (f.symm.mapMatrix : Matrix m m β â+* _) :=
rfl
@[simp]
theorem mapMatrix_trans (f : α â+* β) (g : β â+* γ) :
f.mapMatrix.trans g.mapMatrix = ((f.trans g).mapMatrix : Matrix m m α â+* _) :=
rfl
open MulOpposite in
/--
For any ring `R`, we have ring isomorphism `Matâââ(Ráµáµ) â
(Matâââ(R))áµáµ` given by transpose.
-/
@[simps apply symm_apply]
def mopMatrix : Matrix m m αáµáµáµ â+* (Matrix m m α)áµáµáµ where
toFun M := op (M.transpose.map unop)
invFun M := M.unop.transpose.map op
left_inv _ := by aesop
right_inv _ := by aesop
map_mul' _ _ := unop_injective <| by ext; simp [transpose, mul_apply]
map_add' _ _ := by aesop
end RingEquiv
namespace AlgHom
variable [Fintype m] [DecidableEq m]
variable [CommSemiring R] [Semiring α] [Semiring β] [Semiring γ]
variable [Algebra R α] [Algebra R β] [Algebra R γ]
/-- The `AlgHom` between spaces of square matrices induced by an `AlgHom` between their
coefficients. This is `Matrix.map` as an `AlgHom`. -/
@[simps]
def mapMatrix (f : α ââ[R] β) : Matrix m m α ââ[R] Matrix m m β :=
{ f.toRingHom.mapMatrix with
toFun := fun M => M.map f
commutes' := fun r => Matrix.map_algebraMap r f (map_zero _) (f.commutes r) }
@[simp]
theorem mapMatrix_id : (AlgHom.id R α).mapMatrix = AlgHom.id R (Matrix m m α) :=
rfl
@[simp]
theorem mapMatrix_comp (f : β ââ[R] γ) (g : α ââ[R] β) :
f.mapMatrix.comp g.mapMatrix = ((f.comp g).mapMatrix : Matrix m m α ââ[R] _) :=
rfl
end AlgHom
namespace AlgEquiv
variable [Fintype m] [DecidableEq m]
variable [CommSemiring R] [Semiring α] [Semiring β] [Semiring γ]
variable [Algebra R α] [Algebra R β] [Algebra R γ]
/-- The `AlgEquiv` between spaces of square matrices induced by an `AlgEquiv` between their
coefficients. This is `Matrix.map` as an `AlgEquiv`. -/
@[simps apply]
def mapMatrix (f : α ââ[R] β) : Matrix m m α ââ[R] Matrix m m β :=
{ f.toAlgHom.mapMatrix,
f.toRingEquiv.mapMatrix with
toFun := fun M => M.map f
invFun := fun M => M.map f.symm }
@[simp]
theorem mapMatrix_refl : AlgEquiv.refl.mapMatrix = (AlgEquiv.refl : Matrix m m α ââ[R] _) :=
rfl
@[simp]
theorem mapMatrix_symm (f : α ââ[R] β) :
f.mapMatrix.symm = (f.symm.mapMatrix : Matrix m m β ââ[R] _) :=
rfl
@[simp]
theorem mapMatrix_trans (f : α ââ[R] β) (g : β ââ[R] γ) :
f.mapMatrix.trans g.mapMatrix = ((f.trans g).mapMatrix : Matrix m m α ââ[R] _) :=
rfl
/-- For any algebra `α` over a ring `R`, we have an `R`-algebra isomorphism
`Matâââ(αáµáµ) â
(Matâââ(R))áµáµ` given by transpose. If `α` is commutative,
we can get rid of the `áµáµ` in the left-hand side, see `Matrix.transposeAlgEquiv`. -/
@[simps!] def mopMatrix : Matrix m m αáµáµáµ ââ[R] (Matrix m m α)áµáµáµ where
__ := RingEquiv.mopMatrix
commutes' _ := MulOpposite.unop_injective <| by
ext; simp [algebraMap_matrix_apply, eq_comm, apply_ite MulOpposite.unop]
end AlgEquiv
open Matrix
namespace Matrix
section Transpose
open Matrix
variable (m n α)
/-- `Matrix.transpose` as an `AddEquiv` -/
@[simps apply]
def transposeAddEquiv [Add α] : Matrix m n α â+ Matrix n m α where
toFun := transpose
invFun := transpose
left_inv := transpose_transpose
right_inv := transpose_transpose
map_add' := transpose_add
@[simp]
theorem transposeAddEquiv_symm [Add α] : (transposeAddEquiv m n α).symm = transposeAddEquiv n m α :=
rfl
variable {m n α}
theorem transpose_list_sum [AddMonoid α] (l : List (Matrix m n α)) :
l.sumáµ = (l.map transpose).sum :=
map_list_sum (transposeAddEquiv m n α) l
theorem transpose_multiset_sum [AddCommMonoid α] (s : Multiset (Matrix m n α)) :
s.sumáµ = (s.map transpose).sum :=
(transposeAddEquiv m n α).toAddMonoidHom.map_multiset_sum s
theorem transpose_sum [AddCommMonoid α] {ι : Type*} (s : Finset ι) (M : ι â Matrix m n α) :
(â i â s, M i)áµ = â i â s, (M i)áµ :=
map_sum (transposeAddEquiv m n α) _ s
variable (m n R α)
/-- `Matrix.transpose` as a `LinearMap` -/
@[simps apply]
def transposeLinearEquiv [Semiring R] [AddCommMonoid α] [Module R α] :
Matrix m n α ââ[R] Matrix n m α :=
{ transposeAddEquiv m n α with map_smul' := transpose_smul }
@[simp]
theorem transposeLinearEquiv_symm [Semiring R] [AddCommMonoid α] [Module R α] :
(transposeLinearEquiv m n R α).symm = transposeLinearEquiv n m R α :=
rfl
variable {m n R α}
variable (m α)
/-- `Matrix.transpose` as a `RingEquiv` to the opposite ring -/
@[simps]
def transposeRingEquiv [AddCommMonoid α] [CommSemigroup α] [Fintype m] :
Matrix m m α â+* (Matrix m m α)áµáµáµ :=
{ (transposeAddEquiv m m α).trans MulOpposite.opAddEquiv with
toFun := fun M => MulOpposite.op Máµ
invFun := fun M => M.unopáµ
map_mul' := fun M N =>
(congr_arg MulOpposite.op (transpose_mul M N)).trans (MulOpposite.op_mul _ _)
left_inv := fun M => transpose_transpose M
right_inv := fun M => MulOpposite.unop_injective <| transpose_transpose M.unop }
variable {m α}
@[simp]
theorem transpose_pow [CommSemiring α] [Fintype m] [DecidableEq m] (M : Matrix m m α) (k : â) :
(M ^ k)áµ = Máµ ^ k :=
MulOpposite.op_injective <| map_pow (transposeRingEquiv m α) M k
theorem transpose_list_prod [CommSemiring α] [Fintype m] [DecidableEq m] (l : List (Matrix m m α)) :
l.prodáµ = (l.map transpose).reverse.prod :=
(transposeRingEquiv m α).unop_map_list_prod l
variable (R m α)
/-- `Matrix.transpose` as an `AlgEquiv` to the opposite ring -/
@[simps]
def transposeAlgEquiv [CommSemiring R] [CommSemiring α] [Fintype m] [DecidableEq m] [Algebra R α] :
Matrix m m α ââ[R] (Matrix m m α)áµáµáµ :=
{ (transposeAddEquiv m m α).trans MulOpposite.opAddEquiv,
transposeRingEquiv m α with
toFun := fun M => MulOpposite.op Máµ
commutes' := fun r => by
simp only [algebraMap_eq_diagonal, diagonal_transpose, MulOpposite.algebraMap_apply] }
variable {R m α}
end Transpose
end Matrix
| Mathlib/Data/Matrix/Basic.lean | 1,344 | 1,347 | |
/-
Copyright (c) 2018 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Johannes Hölzl, Yaël Dillies
-/
import Mathlib.Analysis.Normed.Group.Seminorm
import Mathlib.Data.NNReal.Basic
import Mathlib.Topology.Algebra.Support
import Mathlib.Topology.MetricSpace.Basic
import Mathlib.Topology.Order.Real
/-!
# Normed (semi)groups
In this file we define 10 classes:
* `Norm`, `NNNorm`: auxiliary classes endowing a type `α` with a function `norm : α â â`
(notation: `âxâ`) and `nnnorm : α â ââ¥0` (notation: `âxââ`), respectively;
* `Seminormed...Group`: A seminormed (additive) (commutative) group is an (additive) (commutative)
group with a norm and a compatible pseudometric space structure:
`â x y, dist x y = âx / yâ` or `â x y, dist x y = âx - yâ`, depending on the group operation.
* `Normed...Group`: A normed (additive) (commutative) group is an (additive) (commutative) group
with a norm and a compatible metric space structure.
We also prove basic properties of (semi)normed groups and provide some instances.
## Notes
The current convention `dist x y = âx - yâ` means that the distance is invariant under right
addition, but actions in mathlib are usually from the left. This means we might want to change it to
`dist x y = â-x + yâ`.
The normed group hierarchy would lend itself well to a mixin design (that is, having
`SeminormedGroup` and `SeminormedAddGroup` not extend `Group` and `AddGroup`), but we choose not
to for performance concerns.
## Tags
normed group
-/
variable {ð α ι κ E F G : Type*}
open Filter Function Metric Bornology
open ENNReal Filter NNReal Uniformity Pointwise Topology
/-- Auxiliary class, endowing a type `E` with a function `norm : E â â` with notation `âxâ`. This
class is designed to be extended in more interesting classes specifying the properties of the norm.
-/
@[notation_class]
class Norm (E : Type*) where
/-- the `â`-valued norm function. -/
norm : E â â
/-- Auxiliary class, endowing a type `α` with a function `nnnorm : α â ââ¥0` with notation `âxââ`. -/
@[notation_class]
class NNNorm (E : Type*) where
/-- the `ââ¥0`-valued norm function. -/
nnnorm : E â ââ¥0
/-- Auxiliary class, endowing a type `α` with a function `enorm : α â ââ¥0â` with notation `âxââ`. -/
@[notation_class]
class ENorm (E : Type*) where
/-- the `ââ¥0â`-valued norm function. -/
enorm : E â ââ¥0â
export Norm (norm)
export NNNorm (nnnorm)
export ENorm (enorm)
@[inherit_doc] notation "â" e "â" => norm e
@[inherit_doc] notation "â" e "ââ" => nnnorm e
@[inherit_doc] notation "â" e "ââ" => enorm e
section ENorm
variable {E : Type*} [NNNorm E] {x : E} {r : ââ¥0}
instance NNNorm.toENorm : ENorm E where enorm := (â·ââ : E â ââ¥0â)
lemma enorm_eq_nnnorm (x : E) : âxââ = âxââ := rfl
@[simp] lemma toNNReal_enorm (x : E) : âxââ.toNNReal = âxââ := rfl
@[simp, norm_cast] lemma coe_le_enorm : r †âxââ â r †âxââ := by simp [enorm]
@[simp, norm_cast] lemma enorm_le_coe : âxââ †r â âxââ †r := by simp [enorm]
@[simp, norm_cast] lemma coe_lt_enorm : r < âxââ â r < âxââ := by simp [enorm]
@[simp, norm_cast] lemma enorm_lt_coe : âxââ < r â âxââ < r := by simp [enorm]
@[simp] lemma enorm_ne_top : âxââ â â := by simp [enorm]
@[simp] lemma enorm_lt_top : âxââ < â := by simp [enorm]
end ENorm
/-- A type `E` equipped with a continuous map `â·ââ : E â ââ¥0â`
NB. We do not demand that the topology is somehow defined by the enorm:
for ââ¥0â (the motivating example behind this definition), this is not true. -/
class ContinuousENorm (E : Type*) [TopologicalSpace E] extends ENorm E where
continuous_enorm : Continuous enorm
/-- An enormed monoid is an additive monoid endowed with a continuous enorm. -/
class ENormedAddMonoid (E : Type*) [TopologicalSpace E] extends ContinuousENorm E, AddMonoid E where
enorm_eq_zero : â x : E, âxââ = 0 â x = 0
protected enorm_add_le : â x y : E, âx + yââ †âxââ + âyââ
/-- An enormed monoid is a monoid endowed with a continuous enorm. -/
@[to_additive]
class ENormedMonoid (E : Type*) [TopologicalSpace E] extends ContinuousENorm E, Monoid E where
enorm_eq_zero : â x : E, âxââ = 0 â x = 1
enorm_mul_le : â x y : E, âx * yââ †âxââ + âyââ
/-- An enormed commutative monoid is an additive commutative monoid
endowed with a continuous enorm.
We don't have `ENormedAddCommMonoid` extend `EMetricSpace`, since the canonical instance `ââ¥0â`
is not an `EMetricSpace`. This is because `ââ¥0â` carries the order topology, which is distinct from
the topology coming from `edist`. -/
class ENormedAddCommMonoid (E : Type*) [TopologicalSpace E]
extends ENormedAddMonoid E, AddCommMonoid E where
/-- An enormed commutative monoid is a commutative monoid endowed with a continuous enorm. -/
@[to_additive]
class ENormedCommMonoid (E : Type*) [TopologicalSpace E] extends ENormedMonoid E, CommMonoid E where
/-- A seminormed group is an additive group endowed with a norm for which `dist x y = âx - yâ`
defines a pseudometric space structure. -/
class SeminormedAddGroup (E : Type*) extends Norm E, AddGroup E, PseudoMetricSpace E where
dist := fun x y => âx - yâ
/-- The distance function is induced by the norm. -/
dist_eq : â x y, dist x y = âx - yâ := by aesop
/-- A seminormed group is a group endowed with a norm for which `dist x y = âx / yâ` defines a
pseudometric space structure. -/
@[to_additive]
class SeminormedGroup (E : Type*) extends Norm E, Group E, PseudoMetricSpace E where
dist := fun x y => âx / yâ
/-- The distance function is induced by the norm. -/
dist_eq : â x y, dist x y = âx / yâ := by aesop
/-- A normed group is an additive group endowed with a norm for which `dist x y = âx - yâ` defines a
metric space structure. -/
class NormedAddGroup (E : Type*) extends Norm E, AddGroup E, MetricSpace E where
dist := fun x y => âx - yâ
/-- The distance function is induced by the norm. -/
dist_eq : â x y, dist x y = âx - yâ := by aesop
/-- A normed group is a group endowed with a norm for which `dist x y = âx / yâ` defines a metric
space structure. -/
@[to_additive]
class NormedGroup (E : Type*) extends Norm E, Group E, MetricSpace E where
dist := fun x y => âx / yâ
/-- The distance function is induced by the norm. -/
dist_eq : â x y, dist x y = âx / yâ := by aesop
/-- A seminormed group is an additive group endowed with a norm for which `dist x y = âx - yâ`
defines a pseudometric space structure. -/
class SeminormedAddCommGroup (E : Type*) extends Norm E, AddCommGroup E,
PseudoMetricSpace E where
dist := fun x y => âx - yâ
/-- The distance function is induced by the norm. -/
dist_eq : â x y, dist x y = âx - yâ := by aesop
/-- A seminormed group is a group endowed with a norm for which `dist x y = âx / yâ`
defines a pseudometric space structure. -/
@[to_additive]
class SeminormedCommGroup (E : Type*) extends Norm E, CommGroup E, PseudoMetricSpace E where
dist := fun x y => âx / yâ
/-- The distance function is induced by the norm. -/
dist_eq : â x y, dist x y = âx / yâ := by aesop
/-- A normed group is an additive group endowed with a norm for which `dist x y = âx - yâ` defines a
metric space structure. -/
class NormedAddCommGroup (E : Type*) extends Norm E, AddCommGroup E, MetricSpace E where
dist := fun x y => âx - yâ
/-- The distance function is induced by the norm. -/
dist_eq : â x y, dist x y = âx - yâ := by aesop
/-- A normed group is a group endowed with a norm for which `dist x y = âx / yâ` defines a metric
space structure. -/
@[to_additive]
class NormedCommGroup (E : Type*) extends Norm E, CommGroup E, MetricSpace E where
dist := fun x y => âx / yâ
/-- The distance function is induced by the norm. -/
dist_eq : â x y, dist x y = âx / yâ := by aesop
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) NormedGroup.toSeminormedGroup [NormedGroup E] : SeminormedGroup E :=
{ â¹NormedGroup E⺠with }
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) NormedCommGroup.toSeminormedCommGroup [NormedCommGroup E] :
SeminormedCommGroup E :=
{ â¹NormedCommGroup E⺠with }
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) SeminormedCommGroup.toSeminormedGroup [SeminormedCommGroup E] :
SeminormedGroup E :=
{ â¹SeminormedCommGroup E⺠with }
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) NormedCommGroup.toNormedGroup [NormedCommGroup E] : NormedGroup E :=
{ â¹NormedCommGroup E⺠with }
-- See note [reducible non-instances]
/-- Construct a `NormedGroup` from a `SeminormedGroup` satisfying `â x, âxâ = 0 â x = 1`. This
avoids having to go back to the `(Pseudo)MetricSpace` level when declaring a `NormedGroup`
instance as a special case of a more general `SeminormedGroup` instance. -/
@[to_additive "Construct a `NormedAddGroup` from a `SeminormedAddGroup`
satisfying `â x, âxâ = 0 â x = 0`. This avoids having to go back to the `(Pseudo)MetricSpace`
level when declaring a `NormedAddGroup` instance as a special case of a more general
`SeminormedAddGroup` instance."]
abbrev NormedGroup.ofSeparation [SeminormedGroup E] (h : â x : E, âxâ = 0 â x = 1) :
NormedGroup E where
dist_eq := â¹SeminormedGroup Eâº.dist_eq
toMetricSpace :=
{ eq_of_dist_eq_zero := fun hxy =>
div_eq_one.1 <| h _ <| (â¹SeminormedGroup Eâº.dist_eq _ _).symm.trans hxy }
-- See note [reducible non-instances]
/-- Construct a `NormedCommGroup` from a `SeminormedCommGroup` satisfying
`â x, âxâ = 0 â x = 1`. This avoids having to go back to the `(Pseudo)MetricSpace` level when
declaring a `NormedCommGroup` instance as a special case of a more general `SeminormedCommGroup`
instance. -/
@[to_additive "Construct a `NormedAddCommGroup` from a
`SeminormedAddCommGroup` satisfying `â x, âxâ = 0 â x = 0`. This avoids having to go back to the
`(Pseudo)MetricSpace` level when declaring a `NormedAddCommGroup` instance as a special case
of a more general `SeminormedAddCommGroup` instance."]
abbrev NormedCommGroup.ofSeparation [SeminormedCommGroup E] (h : â x : E, âxâ = 0 â x = 1) :
NormedCommGroup E :=
{ â¹SeminormedCommGroup Eâº, NormedGroup.ofSeparation h with }
-- See note [reducible non-instances]
/-- Construct a seminormed group from a multiplication-invariant distance. -/
@[to_additive
"Construct a seminormed group from a translation-invariant distance."]
abbrev SeminormedGroup.ofMulDist [Norm E] [Group E] [PseudoMetricSpace E]
(hâ : â x : E, âxâ = dist x 1) (hâ : â x y z : E, dist x y †dist (x * z) (y * z)) :
SeminormedGroup E where
dist_eq x y := by
rw [hâ]; apply le_antisymm
· simpa only [div_eq_mul_inv, â mul_inv_cancel y] using hâ _ _ _
· simpa only [div_mul_cancel, one_mul] using hâ (x / y) 1 y
-- See note [reducible non-instances]
/-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a seminormed group from a translation-invariant pseudodistance."]
abbrev SeminormedGroup.ofMulDist' [Norm E] [Group E] [PseudoMetricSpace E]
(hâ : â x : E, âxâ = dist x 1) (hâ : â x y z : E, dist (x * z) (y * z) †dist x y) :
SeminormedGroup E where
dist_eq x y := by
rw [hâ]; apply le_antisymm
· simpa only [div_mul_cancel, one_mul] using hâ (x / y) 1 y
· simpa only [div_eq_mul_inv, â mul_inv_cancel y] using hâ _ _ _
-- See note [reducible non-instances]
/-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a seminormed group from a translation-invariant pseudodistance."]
abbrev SeminormedCommGroup.ofMulDist [Norm E] [CommGroup E] [PseudoMetricSpace E]
(hâ : â x : E, âxâ = dist x 1) (hâ : â x y z : E, dist x y †dist (x * z) (y * z)) :
SeminormedCommGroup E :=
{ SeminormedGroup.ofMulDist hâ hâ with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a seminormed group from a translation-invariant pseudodistance."]
abbrev SeminormedCommGroup.ofMulDist' [Norm E] [CommGroup E] [PseudoMetricSpace E]
(hâ : â x : E, âxâ = dist x 1) (hâ : â x y z : E, dist (x * z) (y * z) †dist x y) :
SeminormedCommGroup E :=
{ SeminormedGroup.ofMulDist' hâ hâ with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a normed group from a multiplication-invariant distance. -/
@[to_additive
"Construct a normed group from a translation-invariant distance."]
abbrev NormedGroup.ofMulDist [Norm E] [Group E] [MetricSpace E] (hâ : â x : E, âxâ = dist x 1)
(hâ : â x y z : E, dist x y †dist (x * z) (y * z)) : NormedGroup E :=
{ SeminormedGroup.ofMulDist hâ hâ with
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
-- See note [reducible non-instances]
/-- Construct a normed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a normed group from a translation-invariant pseudodistance."]
abbrev NormedGroup.ofMulDist' [Norm E] [Group E] [MetricSpace E] (hâ : â x : E, âxâ = dist x 1)
(hâ : â x y z : E, dist (x * z) (y * z) †dist x y) : NormedGroup E :=
{ SeminormedGroup.ofMulDist' hâ hâ with
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
-- See note [reducible non-instances]
/-- Construct a normed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a normed group from a translation-invariant pseudodistance."]
abbrev NormedCommGroup.ofMulDist [Norm E] [CommGroup E] [MetricSpace E]
(hâ : â x : E, âxâ = dist x 1) (hâ : â x y z : E, dist x y †dist (x * z) (y * z)) :
NormedCommGroup E :=
{ NormedGroup.ofMulDist hâ hâ with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a normed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a normed group from a translation-invariant pseudodistance."]
abbrev NormedCommGroup.ofMulDist' [Norm E] [CommGroup E] [MetricSpace E]
(hâ : â x : E, âxâ = dist x 1) (hâ : â x y z : E, dist (x * z) (y * z) †dist x y) :
NormedCommGroup E :=
{ NormedGroup.ofMulDist' hâ hâ with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the
pseudometric space structure from the seminorm properties. Note that in most cases this instance
creates bad definitional equalities (e.g., it does not take into account a possibly existing
`UniformSpace` instance on `E`). -/
@[to_additive
"Construct a seminormed group from a seminorm, i.e., registering the pseudodistance
and the pseudometric space structure from the seminorm properties. Note that in most cases this
instance creates bad definitional equalities (e.g., it does not take into account a possibly
existing `UniformSpace` instance on `E`)."]
abbrev GroupSeminorm.toSeminormedGroup [Group E] (f : GroupSeminorm E) : SeminormedGroup E where
dist x y := f (x / y)
norm := f
dist_eq _ _ := rfl
dist_self x := by simp only [div_self', map_one_eq_zero]
dist_triangle := le_map_div_add_map_div f
dist_comm := map_div_rev f
-- See note [reducible non-instances]
/-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the
pseudometric space structure from the seminorm properties. Note that in most cases this instance
creates bad definitional equalities (e.g., it does not take into account a possibly existing
`UniformSpace` instance on `E`). -/
@[to_additive
"Construct a seminormed group from a seminorm, i.e., registering the pseudodistance
and the pseudometric space structure from the seminorm properties. Note that in most cases this
instance creates bad definitional equalities (e.g., it does not take into account a possibly
existing `UniformSpace` instance on `E`)."]
abbrev GroupSeminorm.toSeminormedCommGroup [CommGroup E] (f : GroupSeminorm E) :
SeminormedCommGroup E :=
{ f.toSeminormedGroup with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a normed group from a norm, i.e., registering the distance and the metric space
structure from the norm properties. Note that in most cases this instance creates bad definitional
equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on
`E`). -/
@[to_additive
"Construct a normed group from a norm, i.e., registering the distance and the metric
space structure from the norm properties. Note that in most cases this instance creates bad
definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace`
instance on `E`)."]
abbrev GroupNorm.toNormedGroup [Group E] (f : GroupNorm E) : NormedGroup E :=
{ f.toGroupSeminorm.toSeminormedGroup with
eq_of_dist_eq_zero := fun h => div_eq_one.1 <| eq_one_of_map_eq_zero f h }
-- See note [reducible non-instances]
/-- Construct a normed group from a norm, i.e., registering the distance and the metric space
structure from the norm properties. Note that in most cases this instance creates bad definitional
equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on
`E`). -/
@[to_additive
"Construct a normed group from a norm, i.e., registering the distance and the metric
space structure from the norm properties. Note that in most cases this instance creates bad
definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace`
instance on `E`)."]
abbrev GroupNorm.toNormedCommGroup [CommGroup E] (f : GroupNorm E) : NormedCommGroup E :=
{ f.toNormedGroup with
mul_comm := mul_comm }
section SeminormedGroup
variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E}
{a aâ aâ b c : E} {r râ râ : â}
@[to_additive]
theorem dist_eq_norm_div (a b : E) : dist a b = âa / bâ :=
SeminormedGroup.dist_eq _ _
@[to_additive]
theorem dist_eq_norm_div' (a b : E) : dist a b = âb / aâ := by rw [dist_comm, dist_eq_norm_div]
alias dist_eq_norm := dist_eq_norm_sub
alias dist_eq_norm' := dist_eq_norm_sub'
@[to_additive of_forall_le_norm]
lemma DiscreteTopology.of_forall_le_norm' (hpos : 0 < r) (hr : â x : E, x â 1 â r †âxâ) :
DiscreteTopology E :=
.of_forall_le_dist hpos fun x y hne ⊠by
simp only [dist_eq_norm_div]
exact hr _ (div_ne_one.2 hne)
@[to_additive (attr := simp)]
theorem dist_one_right (a : E) : dist a 1 = âaâ := by rw [dist_eq_norm_div, div_one]
@[to_additive]
theorem inseparable_one_iff_norm {a : E} : Inseparable a 1 â âaâ = 0 := by
rw [Metric.inseparable_iff, dist_one_right]
@[to_additive]
lemma dist_one_left (a : E) : dist 1 a = âaâ := by rw [dist_comm, dist_one_right]
@[to_additive (attr := simp)]
lemma dist_one : dist (1 : E) = norm := funext dist_one_left
@[to_additive]
theorem norm_div_rev (a b : E) : âa / bâ = âb / aâ := by
simpa only [dist_eq_norm_div] using dist_comm a b
@[to_additive (attr := simp) norm_neg]
theorem norm_inv' (a : E) : âaâ»Â¹â = âaâ := by simpa using norm_div_rev 1 a
@[to_additive (attr := simp) norm_abs_zsmul]
theorem norm_zpow_abs (a : E) (n : â€) : âa ^ |n|â = âa ^ nâ := by
rcases le_total 0 n with hn | hn <;> simp [hn, abs_of_nonneg, abs_of_nonpos]
@[to_additive (attr := simp) norm_natAbs_smul]
theorem norm_pow_natAbs (a : E) (n : â€) : âa ^ n.natAbsâ = âa ^ nâ := by
rw [â zpow_natCast, â Int.abs_eq_natAbs, norm_zpow_abs]
@[to_additive norm_isUnit_zsmul]
theorem norm_zpow_isUnit (a : E) {n : â€} (hn : IsUnit n) : âa ^ nâ = âaâ := by
rw [â norm_pow_natAbs, Int.isUnit_iff_natAbs_eq.mp hn, pow_one]
@[simp]
theorem norm_units_zsmul {E : Type*} [SeminormedAddGroup E] (n : â€Ë£) (a : E) : ân ⢠aâ = âaâ :=
norm_isUnit_zsmul a n.isUnit
open scoped symmDiff in
@[to_additive]
theorem dist_mulIndicator (s t : Set α) (f : α â E) (x : α) :
dist (s.mulIndicator f x) (t.mulIndicator f x) = â(s â t).mulIndicator f xâ := by
rw [dist_eq_norm_div, Set.apply_mulIndicator_symmDiff norm_inv']
/-- **Triangle inequality** for the norm. -/
@[to_additive norm_add_le "**Triangle inequality** for the norm."]
theorem norm_mul_le' (a b : E) : âa * bâ †âaâ + âbâ := by
simpa [dist_eq_norm_div] using dist_triangle a 1 bâ»Â¹
/-- **Triangle inequality** for the norm. -/
@[to_additive norm_add_le_of_le "**Triangle inequality** for the norm."]
theorem norm_mul_le_of_le' (hâ : âaââ †râ) (hâ : âaââ †râ) : âaâ * aââ †râ + râ :=
(norm_mul_le' aâ aâ).trans <| add_le_add hâ hâ
/-- **Triangle inequality** for the norm. -/
@[to_additive norm_addâ_le "**Triangle inequality** for the norm."]
lemma norm_mulâ_le' : âa * b * câ †âaâ + âbâ + âcâ := norm_mul_le_of_le' (norm_mul_le' _ _) le_rfl
@[to_additive]
lemma norm_div_le_norm_div_add_norm_div (a b c : E) : âa / câ †âa / bâ + âb / câ := by
simpa only [dist_eq_norm_div] using dist_triangle a b c
@[to_additive (attr := simp) norm_nonneg]
theorem norm_nonneg' (a : E) : 0 †âaâ := by
rw [â dist_one_right]
exact dist_nonneg
attribute [bound] norm_nonneg
@[to_additive (attr := simp) abs_norm]
theorem abs_norm' (z : E) : |âzâ| = âzâ := abs_of_nonneg <| norm_nonneg' _
@[to_additive (attr := simp) norm_zero]
theorem norm_one' : â(1 : E)â = 0 := by rw [â dist_one_right, dist_self]
@[to_additive]
theorem ne_one_of_norm_ne_zero : âaâ â 0 â a â 1 :=
mt <| by
rintro rfl
exact norm_one'
@[to_additive (attr := nontriviality) norm_of_subsingleton]
theorem norm_of_subsingleton' [Subsingleton E] (a : E) : âaâ = 0 := by
rw [Subsingleton.elim a 1, norm_one']
@[to_additive zero_lt_one_add_norm_sq]
theorem zero_lt_one_add_norm_sq' (x : E) : 0 < 1 + âxâ ^ 2 := by
positivity
@[to_additive]
theorem norm_div_le (a b : E) : âa / bâ †âaâ + âbâ := by
simpa [dist_eq_norm_div] using dist_triangle a 1 b
attribute [bound] norm_sub_le
@[to_additive]
theorem norm_div_le_of_le {râ râ : â} (Hâ : âaââ †râ) (Hâ : âaââ †râ) : âaâ / aââ †râ + râ :=
(norm_div_le aâ aâ).trans <| add_le_add Hâ Hâ
@[to_additive dist_le_norm_add_norm]
theorem dist_le_norm_add_norm' (a b : E) : dist a b †âaâ + âbâ := by
rw [dist_eq_norm_div]
apply norm_div_le
@[to_additive abs_norm_sub_norm_le]
theorem abs_norm_sub_norm_le' (a b : E) : |âaâ - âbâ| †âa / bâ := by
simpa [dist_eq_norm_div] using abs_dist_sub_le a b 1
@[to_additive norm_sub_norm_le]
theorem norm_sub_norm_le' (a b : E) : âaâ - âbâ †âa / bâ :=
(le_abs_self _).trans (abs_norm_sub_norm_le' a b)
@[to_additive (attr := bound)]
theorem norm_sub_le_norm_mul (a b : E) : âaâ - âbâ †âa * bâ := by
simpa using norm_mul_le' (a * b) (bâ»Â¹)
@[to_additive dist_norm_norm_le]
theorem dist_norm_norm_le' (a b : E) : dist âaâ âbâ †âa / bâ :=
abs_norm_sub_norm_le' a b
@[to_additive]
theorem norm_le_norm_add_norm_div' (u v : E) : âuâ †âvâ + âu / vâ := by
rw [add_comm]
refine (norm_mul_le' _ _).trans_eq' ?_
rw [div_mul_cancel]
@[to_additive]
theorem norm_le_norm_add_norm_div (u v : E) : âvâ †âuâ + âu / vâ := by
rw [norm_div_rev]
exact norm_le_norm_add_norm_div' v u
alias norm_le_insert' := norm_le_norm_add_norm_sub'
alias norm_le_insert := norm_le_norm_add_norm_sub
@[to_additive]
theorem norm_le_mul_norm_add (u v : E) : âuâ †âu * vâ + âvâ :=
calc
âuâ = âu * v / vâ := by rw [mul_div_cancel_right]
_ †âu * vâ + âvâ := norm_div_le _ _
/-- An analogue of `norm_le_mul_norm_add` for the multiplication from the left. -/
@[to_additive "An analogue of `norm_le_add_norm_add` for the addition from the left."]
theorem norm_le_mul_norm_add' (u v : E) : âvâ †âu * vâ + âuâ :=
calc
âvâ = âuâ»Â¹ * (u * v)â := by rw [â mul_assoc, inv_mul_cancel, one_mul]
_ †âuâ»Â¹â + âu * vâ := norm_mul_le' uâ»Â¹ (u * v)
_ = âu * vâ + âuâ := by rw [norm_inv', add_comm]
@[to_additive]
lemma norm_mul_eq_norm_right {x : E} (y : E) (h : âxâ = 0) : âx * yâ = âyâ := by
apply le_antisymm ?_ ?_
· simpa [h] using norm_mul_le' x y
· simpa [h] using norm_le_mul_norm_add' x y
@[to_additive]
lemma norm_mul_eq_norm_left (x : E) {y : E} (h : âyâ = 0) : âx * yâ = âxâ := by
apply le_antisymm ?_ ?_
· simpa [h] using norm_mul_le' x y
· simpa [h] using norm_le_mul_norm_add x y
@[to_additive]
lemma norm_div_eq_norm_right {x : E} (y : E) (h : âxâ = 0) : âx / yâ = âyâ := by
apply le_antisymm ?_ ?_
· simpa [h] using norm_div_le x y
· simpa [h, norm_div_rev x y] using norm_sub_norm_le' y x
@[to_additive]
lemma norm_div_eq_norm_left (x : E) {y : E} (h : âyâ = 0) : âx / yâ = âxâ := by
apply le_antisymm ?_ ?_
· simpa [h] using norm_div_le x y
· simpa [h] using norm_sub_norm_le' x y
@[to_additive ball_eq]
theorem ball_eq' (y : E) (ε : â) : ball y ε = { x | âx / yâ < ε } :=
Set.ext fun a => by simp [dist_eq_norm_div]
@[to_additive]
theorem ball_one_eq (r : â) : ball (1 : E) r = { x | âxâ < r } :=
Set.ext fun a => by simp
@[to_additive mem_ball_iff_norm]
theorem mem_ball_iff_norm'' : b â ball a r â âb / aâ < r := by rw [mem_ball, dist_eq_norm_div]
@[to_additive mem_ball_iff_norm']
theorem mem_ball_iff_norm''' : b â ball a r â âa / bâ < r := by rw [mem_ball', dist_eq_norm_div]
@[to_additive]
theorem mem_ball_one_iff : a â ball (1 : E) r â âaâ < r := by rw [mem_ball, dist_one_right]
@[to_additive mem_closedBall_iff_norm]
theorem mem_closedBall_iff_norm'' : b â closedBall a r â âb / aâ †r := by
rw [mem_closedBall, dist_eq_norm_div]
@[to_additive]
theorem mem_closedBall_one_iff : a â closedBall (1 : E) r â âaâ †r := by
rw [mem_closedBall, dist_one_right]
@[to_additive mem_closedBall_iff_norm']
theorem mem_closedBall_iff_norm''' : b â closedBall a r â âa / bâ †r := by
rw [mem_closedBall', dist_eq_norm_div]
@[to_additive norm_le_of_mem_closedBall]
theorem norm_le_of_mem_closedBall' (h : b â closedBall a r) : âbâ †âaâ + r :=
(norm_le_norm_add_norm_div' _ _).trans <| add_le_add_left (by rwa [â dist_eq_norm_div]) _
@[to_additive norm_le_norm_add_const_of_dist_le]
theorem norm_le_norm_add_const_of_dist_le' : dist a b †r â âaâ †âbâ + r :=
norm_le_of_mem_closedBall'
@[to_additive norm_lt_of_mem_ball]
theorem norm_lt_of_mem_ball' (h : b â ball a r) : âbâ < âaâ + r :=
(norm_le_norm_add_norm_div' _ _).trans_lt <| add_lt_add_left (by rwa [â dist_eq_norm_div]) _
@[to_additive]
theorem norm_div_sub_norm_div_le_norm_div (u v w : E) : âu / wâ - âv / wâ †âu / vâ := by
simpa only [div_div_div_cancel_right] using norm_sub_norm_le' (u / w) (v / w)
@[to_additive (attr := simp 1001) mem_sphere_iff_norm]
-- Porting note: increase priority so the left-hand side doesn't reduce
theorem mem_sphere_iff_norm' : b â sphere a r â âb / aâ = r := by simp [dist_eq_norm_div]
@[to_additive] -- `simp` can prove this
theorem mem_sphere_one_iff_norm : a â sphere (1 : E) r â âaâ = r := by simp [dist_eq_norm_div]
@[to_additive (attr := simp) norm_eq_of_mem_sphere]
theorem norm_eq_of_mem_sphere' (x : sphere (1 : E) r) : â(x : E)â = r :=
mem_sphere_one_iff_norm.mp x.2
@[to_additive]
theorem ne_one_of_mem_sphere (hr : r â 0) (x : sphere (1 : E) r) : (x : E) â 1 :=
ne_one_of_norm_ne_zero <| by rwa [norm_eq_of_mem_sphere' x]
@[to_additive ne_zero_of_mem_unit_sphere]
theorem ne_one_of_mem_unit_sphere (x : sphere (1 : E) 1) : (x : E) â 1 :=
ne_one_of_mem_sphere one_ne_zero _
variable (E)
/-- The norm of a seminormed group as a group seminorm. -/
@[to_additive "The norm of a seminormed group as an additive group seminorm."]
def normGroupSeminorm : GroupSeminorm E :=
âšnorm, norm_one', norm_mul_le', norm_inv'â©
@[to_additive (attr := simp)]
theorem coe_normGroupSeminorm : â(normGroupSeminorm E) = norm :=
rfl
variable {E}
@[to_additive]
theorem NormedCommGroup.tendsto_nhds_one {f : α â E} {l : Filter α} :
Tendsto f l (ð 1) â â ε > 0, âá¶ x in l, âf xâ < ε :=
Metric.tendsto_nhds.trans <| by simp only [dist_one_right]
@[to_additive]
theorem NormedCommGroup.tendsto_nhds_nhds {f : E â F} {x : E} {y : F} :
Tendsto f (ð x) (ð y) â â ε > 0, â ÎŽ > 0, â x', âx' / xâ < ÎŽ â âf x' / yâ < ε := by
simp_rw [Metric.tendsto_nhds_nhds, dist_eq_norm_div]
@[to_additive]
theorem NormedCommGroup.nhds_basis_norm_lt (x : E) :
(ð x).HasBasis (fun ε : â => 0 < ε) fun ε => { y | ây / xâ < ε } := by
simp_rw [â ball_eq']
exact Metric.nhds_basis_ball
@[to_additive]
theorem NormedCommGroup.nhds_one_basis_norm_lt :
(ð (1 : E)).HasBasis (fun ε : â => 0 < ε) fun ε => { y | âyâ < ε } := by
convert NormedCommGroup.nhds_basis_norm_lt (1 : E)
simp
@[to_additive]
theorem NormedCommGroup.uniformity_basis_dist :
(ð€ E).HasBasis (fun ε : â => 0 < ε) fun ε => { p : E à E | âp.fst / p.sndâ < ε } := by
convert Metric.uniformity_basis_dist (α := E) using 1
simp [dist_eq_norm_div]
open Finset
variable [FunLike ð E F]
section NNNorm
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) SeminormedGroup.toNNNorm : NNNorm E :=
âšfun a => âšâaâ, norm_nonneg' aâ©â©
@[to_additive (attr := simp, norm_cast) coe_nnnorm]
theorem coe_nnnorm' (a : E) : (âaââ : â) = âaâ := rfl
@[to_additive (attr := simp) coe_comp_nnnorm]
theorem coe_comp_nnnorm' : (toReal : ââ¥0 â â) â (nnnorm : E â ââ¥0) = norm :=
rfl
@[to_additive (attr := simp) norm_toNNReal]
theorem norm_toNNReal' : âaâ.toNNReal = âaââ :=
@Real.toNNReal_coe âaââ
@[to_additive (attr := simp) toReal_enorm]
lemma toReal_enorm' (x : E) : âxââ.toReal = âxâ := by simp [enorm]
@[to_additive (attr := simp) ofReal_norm]
lemma ofReal_norm' (x : E) : .ofReal âxâ = âxââ := by
simp [enorm, ENNReal.ofReal, Real.toNNReal, nnnorm]
@[to_additive enorm_eq_iff_norm_eq]
theorem enorm'_eq_iff_norm_eq {x : E} {y : F} : âxââ = âyââ â âxâ = âyâ := by
simp only [â ofReal_norm']
refine âšfun h ⊠?_, fun h ⊠by congrâ©
exact (Real.toNNReal_eq_toNNReal_iff (norm_nonneg' _) (norm_nonneg' _)).mp (ENNReal.coe_inj.mp h)
@[to_additive enorm_le_iff_norm_le]
theorem enorm'_le_iff_norm_le {x : E} {y : F} : âxââ †âyââ â âxâ †âyâ := by
simp only [â ofReal_norm']
refine âšfun h ⊠?_, fun h ⊠by gcongrâ©
rw [ENNReal.ofReal_le_ofReal_iff (norm_nonneg' _)] at h
exact h
@[to_additive]
theorem nndist_eq_nnnorm_div (a b : E) : nndist a b = âa / bââ :=
NNReal.eq <| dist_eq_norm_div _ _
alias nndist_eq_nnnorm := nndist_eq_nnnorm_sub
@[to_additive (attr := simp)]
theorem nndist_one_right (a : E) : nndist a 1 = âaââ := by simp [nndist_eq_nnnorm_div]
@[to_additive (attr := simp)]
lemma edist_one_right (a : E) : edist a 1 = âaââ := by simp [edist_nndist, nndist_one_right, enorm]
@[to_additive (attr := simp) nnnorm_zero]
theorem nnnorm_one' : â(1 : E)ââ = 0 := NNReal.eq norm_one'
@[to_additive]
theorem ne_one_of_nnnorm_ne_zero {a : E} : âaââ â 0 â a â 1 :=
mt <| by
rintro rfl
exact nnnorm_one'
@[to_additive nnnorm_add_le]
theorem nnnorm_mul_le' (a b : E) : âa * bââ †âaââ + âbââ :=
NNReal.coe_le_coe.1 <| norm_mul_le' a b
@[to_additive norm_nsmul_le]
lemma norm_pow_le_mul_norm : â {n : â}, âa ^ nâ †n * âaâ
| 0 => by simp
| n + 1 => by simpa [pow_succ, add_mul] using norm_mul_le_of_le' norm_pow_le_mul_norm le_rfl
@[to_additive nnnorm_nsmul_le]
lemma nnnorm_pow_le_mul_norm {n : â} : âa ^ nââ †n * âaââ := by
simpa only [â NNReal.coe_le_coe, NNReal.coe_mul, NNReal.coe_natCast] using norm_pow_le_mul_norm
@[to_additive (attr := simp) nnnorm_neg]
theorem nnnorm_inv' (a : E) : âaâ»Â¹ââ = âaââ :=
NNReal.eq <| norm_inv' a
@[to_additive (attr := simp) nnnorm_abs_zsmul]
theorem nnnorm_zpow_abs (a : E) (n : â€) : âa ^ |n|ââ = âa ^ nââ :=
NNReal.eq <| norm_zpow_abs a n
@[to_additive (attr := simp) nnnorm_natAbs_smul]
theorem nnnorm_pow_natAbs (a : E) (n : â€) : âa ^ n.natAbsââ = âa ^ nââ :=
NNReal.eq <| norm_pow_natAbs a n
@[to_additive nnnorm_isUnit_zsmul]
theorem nnnorm_zpow_isUnit (a : E) {n : â€} (hn : IsUnit n) : âa ^ nââ = âaââ :=
NNReal.eq <| norm_zpow_isUnit a hn
@[simp]
theorem nnnorm_units_zsmul {E : Type*} [SeminormedAddGroup E] (n : â€Ë£) (a : E) : ân ⢠aââ = âaââ :=
NNReal.eq <| norm_isUnit_zsmul a n.isUnit
@[to_additive (attr := simp)]
theorem nndist_one_left (a : E) : nndist 1 a = âaââ := by simp [nndist_eq_nnnorm_div]
@[to_additive (attr := simp)]
theorem edist_one_left (a : E) : edist 1 a = âaââ := by
rw [edist_nndist, nndist_one_left]
open scoped symmDiff in
@[to_additive]
theorem nndist_mulIndicator (s t : Set α) (f : α â E) (x : α) :
nndist (s.mulIndicator f x) (t.mulIndicator f x) = â(s â t).mulIndicator f xââ :=
NNReal.eq <| dist_mulIndicator s t f x
@[to_additive]
theorem nnnorm_div_le (a b : E) : âa / bââ †âaââ + âbââ :=
NNReal.coe_le_coe.1 <| norm_div_le _ _
@[to_additive]
lemma enorm_div_le : âa / bââ †âaââ + âbââ := by
simpa [enorm, â ENNReal.coe_add] using nnnorm_div_le a b
@[to_additive nndist_nnnorm_nnnorm_le]
theorem nndist_nnnorm_nnnorm_le' (a b : E) : nndist âaââ âbââ †âa / bââ :=
NNReal.coe_le_coe.1 <| dist_norm_norm_le' a b
@[to_additive]
theorem nnnorm_le_nnnorm_add_nnnorm_div (a b : E) : âbââ †âaââ + âa / bââ :=
norm_le_norm_add_norm_div _ _
@[to_additive]
theorem nnnorm_le_nnnorm_add_nnnorm_div' (a b : E) : âaââ †âbââ + âa / bââ :=
norm_le_norm_add_norm_div' _ _
alias nnnorm_le_insert' := nnnorm_le_nnnorm_add_nnnorm_sub'
alias nnnorm_le_insert := nnnorm_le_nnnorm_add_nnnorm_sub
@[to_additive]
theorem nnnorm_le_mul_nnnorm_add (a b : E) : âaââ †âa * bââ + âbââ :=
norm_le_mul_norm_add _ _
/-- An analogue of `nnnorm_le_mul_nnnorm_add` for the multiplication from the left. -/
@[to_additive "An analogue of `nnnorm_le_add_nnnorm_add` for the addition from the left."]
theorem nnnorm_le_mul_nnnorm_add' (a b : E) : âbââ †âa * bââ + âaââ :=
norm_le_mul_norm_add' _ _
@[to_additive]
lemma nnnorm_mul_eq_nnnorm_right {x : E} (y : E) (h : âxââ = 0) : âx * yââ = âyââ :=
NNReal.eq <| norm_mul_eq_norm_right _ <| congr_arg NNReal.toReal h
@[to_additive]
lemma nnnorm_mul_eq_nnnorm_left (x : E) {y : E} (h : âyââ = 0) : âx * yââ = âxââ :=
NNReal.eq <| norm_mul_eq_norm_left _ <| congr_arg NNReal.toReal h
@[to_additive]
lemma nnnorm_div_eq_nnnorm_right {x : E} (y : E) (h : âxââ = 0) : âx / yââ = âyââ :=
NNReal.eq <| norm_div_eq_norm_right _ <| congr_arg NNReal.toReal h
@[to_additive]
lemma nnnorm_div_eq_nnnorm_left (x : E) {y : E} (h : âyââ = 0) : âx / yââ = âxââ :=
NNReal.eq <| norm_div_eq_norm_left _ <| congr_arg NNReal.toReal h
/-- The non negative norm seen as an `ENNReal` and then as a `Real` is equal to the norm. -/
@[to_additive toReal_coe_nnnorm "The non negative norm seen as an `ENNReal` and
then as a `Real` is equal to the norm."]
theorem toReal_coe_nnnorm' (a : E) : (âaââ : ââ¥0â).toReal = âaâ := rfl
open scoped symmDiff in
@[to_additive]
theorem edist_mulIndicator (s t : Set α) (f : α â E) (x : α) :
edist (s.mulIndicator f x) (t.mulIndicator f x) = â(s â t).mulIndicator f xââ := by
rw [edist_nndist, nndist_mulIndicator]
end NNNorm
section ENorm
@[to_additive (attr := simp) enorm_zero]
lemma enorm_one' {E : Type*} [TopologicalSpace E] [ENormedMonoid E] : â(1 : E)ââ = 0 := by
rw [ENormedMonoid.enorm_eq_zero]
@[to_additive exists_enorm_lt]
lemma exists_enorm_lt' (E : Type*) [TopologicalSpace E] [ENormedMonoid E]
[hbot : NeBot (ð[â ] (1 : E))] {c : ââ¥0â} (hc : c â 0) : â x â (1 : E), âxââ < c :=
frequently_iff_neBot.mpr hbot |>.and_eventually
(ContinuousENorm.continuous_enorm.tendsto' 1 0 (by simp) |>.eventually_lt_const hc.bot_lt)
|>.exists
@[to_additive (attr := simp) enorm_neg]
lemma enorm_inv' (a : E) : âaâ»Â¹ââ = âaââ := by simp [enorm]
@[to_additive ofReal_norm_eq_enorm]
lemma ofReal_norm_eq_enorm' (a : E) : .ofReal âaâ = âaââ := ENNReal.ofReal_eq_coe_nnreal _
@[deprecated (since := "2025-01-17")] alias ofReal_norm_eq_coe_nnnorm := ofReal_norm_eq_enorm
@[deprecated (since := "2025-01-17")] alias ofReal_norm_eq_coe_nnnorm' := ofReal_norm_eq_enorm'
instance : ENorm ââ¥0â where
enorm x := x
@[simp] lemma enorm_eq_self (x : ââ¥0â) : âxââ = x := rfl
@[to_additive]
theorem edist_eq_enorm_div (a b : E) : edist a b = âa / bââ := by
rw [edist_dist, dist_eq_norm_div, ofReal_norm_eq_enorm']
@[deprecated (since := "2025-01-17")] alias edist_eq_coe_nnnorm_sub := edist_eq_enorm_sub
@[deprecated (since := "2025-01-17")] alias edist_eq_coe_nnnorm_div := edist_eq_enorm_div
@[to_additive]
theorem edist_one_eq_enorm (x : E) : edist x 1 = âxââ := by rw [edist_eq_enorm_div, div_one]
@[deprecated (since := "2025-01-17")] alias edist_eq_coe_nnnorm := edist_zero_eq_enorm
@[deprecated (since := "2025-01-17")] alias edist_eq_coe_nnnorm' := edist_one_eq_enorm
@[to_additive]
theorem mem_emetric_ball_one_iff {r : ââ¥0â} : a â EMetric.ball 1 r â âaââ < r := by
rw [EMetric.mem_ball, edist_one_eq_enorm]
end ENorm
section ContinuousENorm
variable {E : Type*} [TopologicalSpace E] [ContinuousENorm E]
@[continuity, fun_prop]
lemma continuous_enorm : Continuous fun a : E ⊠âaââ := ContinuousENorm.continuous_enorm
variable {X : Type*} [TopologicalSpace X] {f : X â E} {s : Set X} {a : X}
@[fun_prop]
lemma Continuous.enorm : Continuous f â Continuous (âf ·ââ) :=
continuous_enorm.comp
lemma ContinuousAt.enorm {a : X} (h : ContinuousAt f a) : ContinuousAt (âf ·ââ) a := by fun_prop
@[fun_prop]
lemma ContinuousWithinAt.enorm {s : Set X} {a : X} (h : ContinuousWithinAt f s a) :
ContinuousWithinAt (âf ·ââ) s a :=
(ContinuousENorm.continuous_enorm.continuousWithinAt).comp (t := Set.univ) h
(fun _ _ ⊠by trivial)
@[fun_prop]
lemma ContinuousOn.enorm (h : ContinuousOn f s) : ContinuousOn (âf ·ââ) s :=
(ContinuousENorm.continuous_enorm.continuousOn).comp (t := Set.univ) h <| Set.mapsTo_univ _ _
end ContinuousENorm
section ENormedMonoid
variable {E : Type*} [TopologicalSpace E] [ENormedMonoid E]
@[to_additive enorm_add_le]
lemma enorm_mul_le' (a b : E) : âa * bââ †âaââ + âbââ := ENormedMonoid.enorm_mul_le a b
@[to_additive (attr := simp) enorm_eq_zero]
lemma enorm_eq_zero' {a : E} : âaââ = 0 â a = 1 := by
simp [enorm, ENormedMonoid.enorm_eq_zero]
@[to_additive enorm_ne_zero]
lemma enorm_ne_zero' {a : E} : âaââ â 0 â a â 1 :=
enorm_eq_zero'.ne
@[to_additive (attr := simp) enorm_pos]
lemma enorm_pos' {a : E} : 0 < âaââ â a â 1 :=
pos_iff_ne_zero.trans enorm_ne_zero'
end ENormedMonoid
instance : ENormedAddCommMonoid ââ¥0â where
continuous_enorm := continuous_id
enorm_eq_zero := by simp
enorm_add_le := by simp
open Set in
@[to_additive]
lemma SeminormedGroup.disjoint_nhds (x : E) (f : Filter E) :
Disjoint (ð x) f â â ÎŽ > 0, âá¶ y in f, ÎŽ †ây / xâ := by
simp [NormedCommGroup.nhds_basis_norm_lt x |>.disjoint_iff_left, compl_setOf, eventually_iff]
@[to_additive]
lemma SeminormedGroup.disjoint_nhds_one (f : Filter E) :
Disjoint (ð 1) f â â ÎŽ > 0, âá¶ y in f, ÎŽ †âyâ := by
simpa using disjoint_nhds 1 f
end SeminormedGroup
section Induced
variable (E F)
variable [FunLike ð E F]
-- See note [reducible non-instances]
/-- A group homomorphism from a `Group` to a `SeminormedGroup` induces a `SeminormedGroup`
structure on the domain. -/
@[to_additive "A group homomorphism from an `AddGroup` to a
`SeminormedAddGroup` induces a `SeminormedAddGroup` structure on the domain."]
abbrev SeminormedGroup.induced [Group E] [SeminormedGroup F] [MonoidHomClass ð E F] (f : ð) :
SeminormedGroup E :=
{ PseudoMetricSpace.induced f toPseudoMetricSpace with
norm := fun x => âf xâ
dist_eq := fun x y => by simp only [map_div, â dist_eq_norm_div]; rfl }
-- See note [reducible non-instances]
/-- A group homomorphism from a `CommGroup` to a `SeminormedGroup` induces a
`SeminormedCommGroup` structure on the domain. -/
@[to_additive "A group homomorphism from an `AddCommGroup` to a
`SeminormedAddGroup` induces a `SeminormedAddCommGroup` structure on the domain."]
abbrev SeminormedCommGroup.induced
[CommGroup E] [SeminormedGroup F] [MonoidHomClass ð E F] (f : ð) :
SeminormedCommGroup E :=
{ SeminormedGroup.induced E F f with
mul_comm := mul_comm }
-- See note [reducible non-instances].
/-- An injective group homomorphism from a `Group` to a `NormedGroup` induces a `NormedGroup`
structure on the domain. -/
@[to_additive "An injective group homomorphism from an `AddGroup` to a
`NormedAddGroup` induces a `NormedAddGroup` structure on the domain."]
abbrev NormedGroup.induced
[Group E] [NormedGroup F] [MonoidHomClass ð E F] (f : ð) (h : Injective f) :
NormedGroup E :=
{ SeminormedGroup.induced E F f, MetricSpace.induced f h _ with }
-- See note [reducible non-instances].
/-- An injective group homomorphism from a `CommGroup` to a `NormedGroup` induces a
`NormedCommGroup` structure on the domain. -/
@[to_additive "An injective group homomorphism from a `CommGroup` to a
`NormedCommGroup` induces a `NormedCommGroup` structure on the domain."]
abbrev NormedCommGroup.induced [CommGroup E] [NormedGroup F] [MonoidHomClass ð E F] (f : ð)
(h : Injective f) : NormedCommGroup E :=
{ SeminormedGroup.induced E F f, MetricSpace.induced f h _ with
mul_comm := mul_comm }
end Induced
namespace Real
variable {r : â}
instance norm : Norm â where
norm r := |r|
@[simp]
theorem norm_eq_abs (r : â) : ârâ = |r| :=
rfl
instance normedAddCommGroup : NormedAddCommGroup â :=
âšfun _r _y => rflâ©
theorem norm_of_nonneg (hr : 0 †r) : ârâ = r :=
abs_of_nonneg hr
theorem norm_of_nonpos (hr : r †0) : ârâ = -r :=
abs_of_nonpos hr
theorem le_norm_self (r : â) : r †ârâ :=
le_abs_self r
@[simp 1100] lemma norm_natCast (n : â) : â(n : â)â = n := abs_of_nonneg n.cast_nonneg
@[simp 1100] lemma nnnorm_natCast (n : â) : â(n : â)ââ = n := NNReal.eq <| norm_natCast _
@[simp 1100] lemma enorm_natCast (n : â) : â(n : â)ââ = n := by simp [enorm]
@[simp 1100] lemma norm_ofNat (n : â) [n.AtLeastTwo] :
â(ofNat(n) : â)â = ofNat(n) := norm_natCast n
@[simp 1100] lemma nnnorm_ofNat (n : â) [n.AtLeastTwo] :
â(ofNat(n) : â)ââ = ofNat(n) := nnnorm_natCast n
lemma norm_two : â(2 : â)â = 2 := abs_of_pos zero_lt_two
lemma nnnorm_two : â(2 : â)ââ = 2 := NNReal.eq <| by simp
@[simp 1100, norm_cast]
lemma norm_nnratCast (q : ââ¥0) : â(q : â)â = q := norm_of_nonneg q.cast_nonneg
@[simp 1100, norm_cast]
lemma nnnorm_nnratCast (q : ââ¥0) : â(q : â)ââ = q := by simp [nnnorm, -norm_eq_abs]
theorem nnnorm_of_nonneg (hr : 0 †r) : ârââ = âšr, hrâ© :=
NNReal.eq <| norm_of_nonneg hr
lemma enorm_of_nonneg (hr : 0 †r) : ârââ = .ofReal r := by
simp [enorm, nnnorm_of_nonneg hr, ENNReal.ofReal, toNNReal, hr]
@[simp] lemma nnnorm_abs (r : â) : â|r|ââ = ârââ := by simp [nnnorm]
@[simp] lemma enorm_abs (r : â) : â|r|ââ = ârââ := by simp [enorm]
theorem enorm_eq_ofReal (hr : 0 †r) : ârââ = .ofReal r := by
rw [â ofReal_norm_eq_enorm, norm_of_nonneg hr]
@[deprecated (since := "2025-01-17")] alias ennnorm_eq_ofReal := enorm_eq_ofReal
theorem enorm_eq_ofReal_abs (r : â) : ârââ = ENNReal.ofReal |r| := by
rw [â enorm_eq_ofReal (abs_nonneg _), enorm_abs]
@[deprecated (since := "2025-01-17")] alias ennnorm_eq_ofReal_abs := enorm_eq_ofReal_abs
theorem toNNReal_eq_nnnorm_of_nonneg (hr : 0 †r) : r.toNNReal = ârââ := by
rw [Real.toNNReal_of_nonneg hr]
ext
rw [coe_mk, coe_nnnorm r, Real.norm_eq_abs r, abs_of_nonneg hr]
-- Porting note: this is due to the change from `Subtype.val` to `NNReal.toReal` for the coercion
theorem ofReal_le_enorm (r : â) : ENNReal.ofReal r †ârââ := by
rw [enorm_eq_ofReal_abs]; gcongr; exact le_abs_self _
@[deprecated (since := "2025-01-17")] alias ofReal_le_ennnorm := ofReal_le_enorm
end Real
namespace NNReal
instance : NNNorm ââ¥0 where
nnnorm x := x
@[simp] lemma nnnorm_eq_self (x : ââ¥0) : âxââ = x := rfl
end NNReal
section SeminormedCommGroup
variable [SeminormedCommGroup E] [SeminormedCommGroup F] {a b : E} {r : â}
@[to_additive]
theorem dist_inv (x y : E) : dist xâ»Â¹ y = dist x yâ»Â¹ := by
simp_rw [dist_eq_norm_div, â norm_inv' (xâ»Â¹ / y), inv_div, div_inv_eq_mul, mul_comm]
theorem norm_multiset_sum_le {E} [SeminormedAddCommGroup E] (m : Multiset E) :
âm.sumâ †(m.map fun x => âxâ).sum :=
m.le_sum_of_subadditive norm norm_zero norm_add_le
@[to_additive existing]
theorem norm_multiset_prod_le (m : Multiset E) : âm.prodâ †(m.map fun x => âxâ).sum := by
rw [â Multiplicative.ofAdd_le, ofAdd_multiset_prod, Multiset.map_map]
refine Multiset.le_prod_of_submultiplicative (Multiplicative.ofAdd â norm) ?_ (fun x y => ?_) _
· simp only [comp_apply, norm_one', ofAdd_zero]
· exact norm_mul_le' x y
@[bound]
theorem norm_sum_le {ι E} [SeminormedAddCommGroup E] (s : Finset ι) (f : ι â E) :
ââ i â s, f iâ †â i â s, âf iâ :=
s.le_sum_of_subadditive norm norm_zero norm_add_le f
@[to_additive existing]
theorem norm_prod_le (s : Finset ι) (f : ι â E) : ââ i â s, f iâ †â i â s, âf iâ := by
rw [â Multiplicative.ofAdd_le, ofAdd_sum]
refine Finset.le_prod_of_submultiplicative (Multiplicative.ofAdd â norm) ?_ (fun x y => ?_) _ _
· simp only [comp_apply, norm_one', ofAdd_zero]
· exact norm_mul_le' x y
@[to_additive]
theorem norm_prod_le_of_le (s : Finset ι) {f : ι â E} {n : ι â â} (h : â b â s, âf bâ †n b) :
ââ b â s, f bâ †â b â s, n b :=
(norm_prod_le s f).trans <| Finset.sum_le_sum h
@[to_additive]
theorem dist_prod_prod_le_of_le (s : Finset ι) {f a : ι â E} {d : ι â â}
(h : â b â s, dist (f b) (a b) †d b) :
dist (â b â s, f b) (â b â s, a b) †â b â s, d b := by
simp only [dist_eq_norm_div, â Finset.prod_div_distrib] at *
exact norm_prod_le_of_le s h
@[to_additive]
theorem dist_prod_prod_le (s : Finset ι) (f a : ι â E) :
dist (â b â s, f b) (â b â s, a b) †â b â s, dist (f b) (a b) :=
dist_prod_prod_le_of_le s fun _ _ => le_rfl
@[to_additive]
theorem mul_mem_ball_iff_norm : a * b â ball a r â âbâ < r := by
rw [mem_ball_iff_norm'', mul_div_cancel_left]
@[to_additive]
theorem mul_mem_closedBall_iff_norm : a * b â closedBall a r â âbâ †r := by
rw [mem_closedBall_iff_norm'', mul_div_cancel_left]
@[to_additive (attr := simp 1001)]
-- Porting note: increase priority so that the left-hand side doesn't simplify
theorem preimage_mul_ball (a b : E) (r : â) : (b * ·) â»Â¹' ball a r = ball (a / b) r := by
ext c
simp only [dist_eq_norm_div, Set.mem_preimage, mem_ball, div_div_eq_mul_div, mul_comm]
@[to_additive (attr := simp 1001)]
-- Porting note: increase priority so that the left-hand side doesn't simplify
theorem preimage_mul_closedBall (a b : E) (r : â) :
(b * ·) â»Â¹' closedBall a r = closedBall (a / b) r := by
ext c
simp only [dist_eq_norm_div, Set.mem_preimage, mem_closedBall, div_div_eq_mul_div, mul_comm]
@[to_additive (attr := simp)]
theorem preimage_mul_sphere (a b : E) (r : â) : (b * ·) â»Â¹' sphere a r = sphere (a / b) r := by
ext c
simp only [Set.mem_preimage, mem_sphere_iff_norm', div_div_eq_mul_div, mul_comm]
@[to_additive]
theorem pow_mem_closedBall {n : â} (h : a â closedBall b r) :
a ^ n â closedBall (b ^ n) (n ⢠r) := by
simp only [mem_closedBall, dist_eq_norm_div, â div_pow] at h â¢
refine norm_pow_le_mul_norm.trans ?_
simpa only [nsmul_eq_mul] using mul_le_mul_of_nonneg_left h n.cast_nonneg
@[to_additive]
theorem pow_mem_ball {n : â} (hn : 0 < n) (h : a â ball b r) : a ^ n â ball (b ^ n) (n ⢠r) := by
simp only [mem_ball, dist_eq_norm_div, â div_pow] at h â¢
refine lt_of_le_of_lt norm_pow_le_mul_norm ?_
replace hn : 0 < (n : â) := by norm_cast
rw [nsmul_eq_mul]
nlinarith
@[to_additive]
theorem mul_mem_closedBall_mul_iff {c : E} : a * c â closedBall (b * c) r â a â closedBall b r := by
simp only [mem_closedBall, dist_eq_norm_div, mul_div_mul_right_eq_div]
@[to_additive]
theorem mul_mem_ball_mul_iff {c : E} : a * c â ball (b * c) r â a â ball b r := by
simp only [mem_ball, dist_eq_norm_div, mul_div_mul_right_eq_div]
@[to_additive]
theorem smul_closedBall'' : a ⢠closedBall b r = closedBall (a ⢠b) r := by
ext
simp [mem_closedBall, Set.mem_smul_set, dist_eq_norm_div, div_eq_inv_mul, â
eq_inv_mul_iff_mul_eq, mul_assoc]
@[to_additive]
theorem smul_ball'' : a ⢠ball b r = ball (a ⢠b) r := by
ext
simp [mem_ball, Set.mem_smul_set, dist_eq_norm_div, _root_.div_eq_inv_mul,
â eq_inv_mul_iff_mul_eq, mul_assoc]
@[to_additive]
theorem nnnorm_multiset_prod_le (m : Multiset E) : âm.prodââ †(m.map fun x => âxââ).sum :=
NNReal.coe_le_coe.1 <| by
push_cast
rw [Multiset.map_map]
exact norm_multiset_prod_le _
@[to_additive]
theorem nnnorm_prod_le (s : Finset ι) (f : ι â E) : ââ a â s, f aââ †â a â s, âf aââ :=
NNReal.coe_le_coe.1 <| by
push_cast
exact norm_prod_le _ _
@[to_additive]
theorem nnnorm_prod_le_of_le (s : Finset ι) {f : ι â E} {n : ι â ââ¥0} (h : â b â s, âf bââ †n b) :
ââ b â s, f bââ †â b â s, n b :=
(norm_prod_le_of_le s h).trans_eq (NNReal.coe_sum ..).symm
-- Porting note: increase priority so that the LHS doesn't simplify
@[to_additive (attr := simp 1001) norm_norm]
lemma norm_norm' (x : E) : ââxââ = âxâ := Real.norm_of_nonneg (norm_nonneg' _)
@[to_additive (attr := simp) nnnorm_norm]
lemma nnnorm_norm' (x : E) : ââxâââ = âxââ := by simp [nnnorm]
@[to_additive (attr := simp) enorm_norm]
lemma enorm_norm' (x : E) : ââxâââ = âxââ := by simp [enorm]
lemma enorm_enorm {ε : Type*} [ENorm ε] (x : ε) : ââxââââ = âxââ := by simp [enorm]
end SeminormedCommGroup
section NormedGroup
variable [NormedGroup E] {a b : E}
@[to_additive (attr := simp) norm_le_zero_iff]
lemma norm_le_zero_iff' : âaâ †0 â a = 1 := by rw [â dist_one_right, dist_le_zero]
@[to_additive (attr := simp) norm_pos_iff]
lemma norm_pos_iff' : 0 < âaâ â a â 1 := by rw [â not_le, norm_le_zero_iff']
@[to_additive (attr := simp) norm_eq_zero]
lemma norm_eq_zero' : âaâ = 0 â a = 1 := (norm_nonneg' a).le_iff_eq.symm.trans norm_le_zero_iff'
@[to_additive norm_ne_zero_iff]
lemma norm_ne_zero_iff' : âaâ â 0 â a â 1 := norm_eq_zero'.not
@[deprecated (since := "2024-11-24")] alias norm_le_zero_iff'' := norm_le_zero_iff'
@[deprecated (since := "2024-11-24")] alias norm_le_zero_iff''' := norm_le_zero_iff'
@[deprecated (since := "2024-11-24")] alias norm_pos_iff'' := norm_pos_iff'
@[deprecated (since := "2024-11-24")] alias norm_eq_zero'' := norm_eq_zero'
@[deprecated (since := "2024-11-24")] alias norm_eq_zero''' := norm_eq_zero'
@[to_additive]
theorem norm_div_eq_zero_iff : âa / bâ = 0 â a = b := by rw [norm_eq_zero', div_eq_one]
@[to_additive]
theorem norm_div_pos_iff : 0 < âa / bâ â a â b := by
rw [(norm_nonneg' _).lt_iff_ne, ne_comm]
exact norm_div_eq_zero_iff.not
@[to_additive eq_of_norm_sub_le_zero]
theorem eq_of_norm_div_le_zero (h : âa / bâ †0) : a = b := by
rwa [â div_eq_one, â norm_le_zero_iff']
alias âšeq_of_norm_div_eq_zero, _â© := norm_div_eq_zero_iff
attribute [to_additive] eq_of_norm_div_eq_zero
@[to_additive]
theorem eq_one_or_norm_pos (a : E) : a = 1 âš 0 < âaâ := by
simpa [eq_comm] using (norm_nonneg' a).eq_or_lt
@[to_additive]
theorem eq_one_or_nnnorm_pos (a : E) : a = 1 âš 0 < âaââ :=
eq_one_or_norm_pos a
@[to_additive (attr := simp) nnnorm_eq_zero]
theorem nnnorm_eq_zero' : âaââ = 0 â a = 1 := by
rw [â NNReal.coe_eq_zero, coe_nnnorm', norm_eq_zero']
@[to_additive nnnorm_ne_zero_iff]
theorem nnnorm_ne_zero_iff' : âaââ â 0 â a â 1 :=
nnnorm_eq_zero'.not
@[to_additive (attr := simp) nnnorm_pos]
lemma nnnorm_pos' : 0 < âaââ â a â 1 := pos_iff_ne_zero.trans nnnorm_ne_zero_iff'
variable (E)
/-- The norm of a normed group as a group norm. -/
@[to_additive "The norm of a normed group as an additive group norm."]
def normGroupNorm : GroupNorm E :=
{ normGroupSeminorm _ with eq_one_of_map_eq_zero' := fun _ => norm_eq_zero'.1 }
@[simp]
theorem coe_normGroupNorm : â(normGroupNorm E) = norm :=
rfl
end NormedGroup
section NormedAddGroup
variable [NormedAddGroup E] [TopologicalSpace α] {f : α â E}
/-! Some relations with `HasCompactSupport` -/
theorem hasCompactSupport_norm_iff : (HasCompactSupport fun x => âf xâ) â HasCompactSupport f :=
hasCompactSupport_comp_left norm_eq_zero
alias âš_, HasCompactSupport.normâ© := hasCompactSupport_norm_iff
end NormedAddGroup
lemma tendsto_norm_atTop_atTop : Tendsto (norm : â â â) atTop atTop := tendsto_abs_atTop_atTop
/-! ### `positivity` extensions -/
namespace Mathlib.Meta.Positivity
open Lean Meta Qq Function
/-- Extension for the `positivity` tactic: multiplicative norms are always nonnegative, and positive
on non-one inputs. -/
@[positivity â_â]
def evalMulNorm : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(â), ~q(@Norm.norm $E $_n $a) =>
let _seminormedGroup_E â synthInstanceQ q(SeminormedGroup $E)
assertInstancesCommute
-- Check whether we are in a normed group and whether the context contains a `a â 1` assumption
let o : Option (Q(NormedGroup $E) Ã Q($a â 1)) := â do
let .some normedGroup_E â trySynthInstanceQ q(NormedGroup $E) | return none
let some pa â findLocalDeclWithTypeQ? q($a â 1) | return none
return some (normedGroup_E, pa)
match o with
-- If so, return a proof of `0 < âaâ`
| some (_normedGroup_E, pa) =>
assertInstancesCommute
return .positive q(norm_pos_iff'.2 $pa)
-- Else, return a proof of `0 †âaâ`
| none => return .nonnegative q(norm_nonneg' $a)
| _, _, _ => throwError "not `â·â`"
/-- Extension for the `positivity` tactic: additive norms are always nonnegative, and positive
on non-zero inputs. -/
@[positivity â_â]
def evalAddNorm : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(â), ~q(@Norm.norm $E $_n $a) =>
let _seminormedAddGroup_E â synthInstanceQ q(SeminormedAddGroup $E)
assertInstancesCommute
-- Check whether we are in a normed group and whether the context contains a `a â 0` assumption
let o : Option (Q(NormedAddGroup $E) Ã Q($a â 0)) := â do
let .some normedAddGroup_E â trySynthInstanceQ q(NormedAddGroup $E) | return none
let some pa â findLocalDeclWithTypeQ? q($a â 0) | return none
return some (normedAddGroup_E, pa)
match o with
-- If so, return a proof of `0 < âaâ`
| some (_normedAddGroup_E, pa) =>
assertInstancesCommute
return .positive q(norm_pos_iff.2 $pa)
-- Else, return a proof of `0 †âaâ`
| none => return .nonnegative q(norm_nonneg $a)
| _, _, _ => throwError "not `â·â`"
end Mathlib.Meta.Positivity
| Mathlib/Analysis/Normed/Group/Basic.lean | 1,572 | 1,573 | |
/-
Copyright (c) 2019 Johannes Hölzl, Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Zhouhang Zhou
-/
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.MeasureTheory.Function.StronglyMeasurable.AEStronglyMeasurable
import Mathlib.MeasureTheory.Integral.Lebesgue.Add
import Mathlib.Order.Filter.Germ.Basic
import Mathlib.Topology.ContinuousMap.Algebra
/-!
# Almost everywhere equal functions
We build a space of equivalence classes of functions, where two functions are treated as identical
if they are almost everywhere equal. We form the set of equivalence classes under the relation of
being almost everywhere equal, which is sometimes known as the `Lâ°` space.
To use this space as a basis for the `L^p` spaces and for the Bochner integral, we consider
equivalence classes of strongly measurable functions (or, equivalently, of almost everywhere
strongly measurable functions.)
See `L1Space.lean` for `L¹` space.
## Notation
* `α ââ[ÎŒ] β` is the type of `Lâ°` space, where `α` is a measurable space, `β` is a topological
space, and `ÎŒ` is a measure on `α`. `f : α ââ β` is a "function" in `Lâ°`.
In comments, `[f]` is also used to denote an `Lâ°` function.
`â` can be typed as `\_m`. Sometimes it is shown as a box if font is missing.
## Main statements
* The linear structure of `Lâ°` :
Addition and scalar multiplication are defined on `Lâ°` in the natural way, i.e.,
`[f] + [g] := [f + g]`, `c ⢠[f] := [c ⢠f]`. So defined, `α ââ β` inherits the linear structure
of `β`. For example, if `β` is a module, then `α ââ β` is a module over the same ring.
See `mk_add_mk`, `neg_mk`, `mk_sub_mk`, `smul_mk`,
`add_toFun`, `neg_toFun`, `sub_toFun`, `smul_toFun`
* The order structure of `Lâ°` :
`â€` can be defined in a similar way: `[f] †[g]` if `f a †g a` for almost all `a` in domain.
And `α ââ β` inherits the preorder and partial order of `β`.
TODO: Define `sup` and `inf` on `Lâ°` so that it forms a lattice. It seems that `β` must be a
linear order, since otherwise `f â g` may not be a measurable function.
## Implementation notes
* `f.toFun` : To find a representative of `f : α ââ β`, use the coercion `(f : α â β)`, which
is implemented as `f.toFun`.
For each operation `op` in `Lâ°`, there is a lemma called `coe_fn_op`,
characterizing, say, `(f op g : α â β)`.
* `ae_eq_fun.mk` : To constructs an `Lâ°` function `α ââ β` from an almost everywhere strongly
measurable function `f : α â β`, use `ae_eq_fun.mk`
* `comp` : Use `comp g f` to get `[g â f]` from `g : β â γ` and `[f] : α ââ γ` when `g` is
continuous. Use `comp_measurable` if `g` is only measurable (this requires the
target space to be second countable).
* `compâ` : Use `compâ g fâ fâ` to get `[fun a ⊠g (fâ a) (fâ a)]`.
For example, `[f + g]` is `compâ (+)`
## Tags
function space, almost everywhere equal, `Lâ°`, ae_eq_fun
-/
-- Guard against import creep
assert_not_exists InnerProductSpace
noncomputable section
open Topology Set Filter TopologicalSpace ENNReal EMetric MeasureTheory Function
variable {α β γ Ύ : Type*} [MeasurableSpace α] {Ό Μ : Measure α}
namespace MeasureTheory
section MeasurableSpace
variable [TopologicalSpace β]
variable (β)
/-- The equivalence relation of being almost everywhere equal for almost everywhere strongly
measurable functions. -/
def Measure.aeEqSetoid (ÎŒ : Measure α) : Setoid { f : α â β // AEStronglyMeasurable f ÎŒ } :=
âšfun f g => (f : α â β) =áµ[ÎŒ] g, fun {f} => ae_eq_refl f.val, fun {_ _} => ae_eq_symm,
fun {_ _ _} => ae_eq_transâ©
variable (α)
/-- The space of equivalence classes of almost everywhere strongly measurable functions, where two
strongly measurable functions are equivalent if they agree almost everywhere, i.e.,
they differ on a set of measure `0`. -/
def AEEqFun (Ό : Measure α) : Type _ :=
Quotient (Ό.aeEqSetoid β)
variable {α β}
@[inherit_doc MeasureTheory.AEEqFun]
notation:25 α " ââ[" ÎŒ "] " β => AEEqFun α β ÎŒ
end MeasurableSpace
variable [TopologicalSpace ÎŽ]
namespace AEEqFun
section
variable [TopologicalSpace β]
/-- Construct the equivalence class `[f]` of an almost everywhere measurable function `f`, based
on the equivalence relation of being almost everywhere equal. -/
def mk {β : Type*} [TopologicalSpace β] (f : α â β) (hf : AEStronglyMeasurable f ÎŒ) : α ââ[ÎŒ] β :=
Quotient.mk'' âšf, hfâ©
open scoped Classical in
/-- Coercion from a space of equivalence classes of almost everywhere strongly measurable
functions to functions. We ensure that if `f` has a constant representative,
then we choose that one. -/
@[coe]
def cast (f : α ââ[ÎŒ] β) : α â β :=
if h : â (b : β), f = mk (const α b) aestronglyMeasurable_const then
const α <| Classical.choose h else
AEStronglyMeasurable.mk _ (Quotient.out f : { f : α â β // AEStronglyMeasurable f ÎŒ }).2
/-- A measurable representative of an `AEEqFun` [f] -/
instance instCoeFun : CoeFun (α ââ[ÎŒ] β) fun _ => α â β := âšcastâ©
protected theorem stronglyMeasurable (f : α ââ[ÎŒ] β) : StronglyMeasurable f := by
simp only [cast]
split_ifs with h
· exact stronglyMeasurable_const
· apply AEStronglyMeasurable.stronglyMeasurable_mk
protected theorem aestronglyMeasurable (f : α ââ[ÎŒ] β) : AEStronglyMeasurable f ÎŒ :=
f.stronglyMeasurable.aestronglyMeasurable
protected theorem measurable [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β]
(f : α ââ[ÎŒ] β) : Measurable f :=
f.stronglyMeasurable.measurable
protected theorem aemeasurable [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β]
(f : α ââ[ÎŒ] β) : AEMeasurable f ÎŒ :=
f.measurable.aemeasurable
@[simp]
theorem quot_mk_eq_mk (f : α â β) (hf) :
(Quot.mk (@Setoid.r _ <| ÎŒ.aeEqSetoid β) âšf, hfâ© : α ââ[ÎŒ] β) = mk f hf :=
rfl
@[simp]
theorem mk_eq_mk {f g : α â β} {hf hg} : (mk f hf : α ââ[ÎŒ] β) = mk g hg â f =áµ[ÎŒ] g :=
Quotient.eq''
@[simp]
theorem mk_coeFn (f : α ââ[ÎŒ] β) : mk f f.aestronglyMeasurable = f := by
conv_lhs => simp only [cast]
split_ifs with h
· exact Classical.choose_spec h |>.symm
conv_rhs => rw [â Quotient.out_eq' f]
rw [â mk, mk_eq_mk]
exact (AEStronglyMeasurable.ae_eq_mk _).symm
@[ext]
theorem ext {f g : α ââ[ÎŒ] β} (h : f =áµ[ÎŒ] g) : f = g := by
rwa [â f.mk_coeFn, â g.mk_coeFn, mk_eq_mk]
theorem coeFn_mk (f : α â β) (hf) : (mk f hf : α ââ[ÎŒ] β) =áµ[ÎŒ] f := by
rw [â mk_eq_mk, mk_coeFn]
@[elab_as_elim]
theorem induction_on (f : α ââ[ÎŒ] β) {p : (α ââ[ÎŒ] β) â Prop} (H : â f hf, p (mk f hf)) : p f :=
Quotient.inductionOn' f <| Subtype.forall.2 H
@[elab_as_elim]
theorem induction_onâ {α' β' : Type*} [MeasurableSpace α'] [TopologicalSpace β'] {ÎŒ' : Measure α'}
(f : α ââ[ÎŒ] β) (f' : α' ââ[ÎŒ'] β') {p : (α ââ[ÎŒ] β) â (α' ââ[ÎŒ'] β') â Prop}
(H : â f hf f' hf', p (mk f hf) (mk f' hf')) : p f f' :=
induction_on f fun f hf => induction_on f' <| H f hf
@[elab_as_elim]
theorem induction_onâ {α' β' : Type*} [MeasurableSpace α'] [TopologicalSpace β'] {ÎŒ' : Measure α'}
{α'' β'' : Type*} [MeasurableSpace α''] [TopologicalSpace β''] {Ό'' : Measure α''}
(f : α ââ[ÎŒ] β) (f' : α' ââ[ÎŒ'] β') (f'' : α'' ââ[ÎŒ''] β'')
{p : (α ââ[ÎŒ] β) â (α' ââ[ÎŒ'] β') â (α'' ââ[ÎŒ''] β'') â Prop}
(H : â f hf f' hf' f'' hf'', p (mk f hf) (mk f' hf') (mk f'' hf'')) : p f f' f'' :=
induction_on f fun f hf => induction_onâ f' f'' <| H f hf
end
/-!
### Composition of an a.e. equal function with a (quasi) measure preserving function
-/
section compQuasiMeasurePreserving
variable [TopologicalSpace γ] [MeasurableSpace β] {Μ : MeasureTheory.Measure β} {f : α â β}
open MeasureTheory.Measure (QuasiMeasurePreserving)
/-- Composition of an almost everywhere equal function and a quasi measure preserving function.
See also `AEEqFun.compMeasurePreserving`. -/
def compQuasiMeasurePreserving (g : β ââ[Μ] γ) (f : α â β) (hf : QuasiMeasurePreserving f ÎŒ Μ) :
α ââ[ÎŒ] γ :=
Quotient.liftOn' g (fun g ⊠mk (g â f) <| g.2.comp_quasiMeasurePreserving hf) fun _ _ h âŠ
mk_eq_mk.2 <| h.comp_tendsto hf.tendsto_ae
@[simp]
theorem compQuasiMeasurePreserving_mk {g : β â γ} (hg : AEStronglyMeasurable g Μ)
(hf : QuasiMeasurePreserving f Ό Μ) :
(mk g hg).compQuasiMeasurePreserving f hf = mk (g â f) (hg.comp_quasiMeasurePreserving hf) :=
rfl
theorem compQuasiMeasurePreserving_eq_mk (g : β ââ[Μ] γ) (hf : QuasiMeasurePreserving f ÎŒ Μ) :
g.compQuasiMeasurePreserving f hf =
mk (g â f) (g.aestronglyMeasurable.comp_quasiMeasurePreserving hf) := by
rw [â compQuasiMeasurePreserving_mk g.aestronglyMeasurable hf, mk_coeFn]
theorem coeFn_compQuasiMeasurePreserving (g : β ââ[Μ] γ) (hf : QuasiMeasurePreserving f ÎŒ Μ) :
g.compQuasiMeasurePreserving f hf =áµ[ÎŒ] g â f := by
rw [compQuasiMeasurePreserving_eq_mk]
apply coeFn_mk
end compQuasiMeasurePreserving
section compMeasurePreserving
variable [TopologicalSpace γ] [MeasurableSpace β] {Μ : MeasureTheory.Measure β}
{f : α â β} {g : β â γ}
/-- Composition of an almost everywhere equal function and a quasi measure preserving function.
This is an important special case of `AEEqFun.compQuasiMeasurePreserving`. We use a separate
definition so that lemmas that need `f` to be measure preserving can be `@[simp]` lemmas. -/
def compMeasurePreserving (g : β ââ[Μ] γ) (f : α â β) (hf : MeasurePreserving f ÎŒ Μ) : α ââ[ÎŒ] γ :=
g.compQuasiMeasurePreserving f hf.quasiMeasurePreserving
@[simp]
theorem compMeasurePreserving_mk (hg : AEStronglyMeasurable g Μ) (hf : MeasurePreserving f Ό Μ) :
(mk g hg).compMeasurePreserving f hf =
mk (g â f) (hg.comp_quasiMeasurePreserving hf.quasiMeasurePreserving) :=
rfl
theorem compMeasurePreserving_eq_mk (g : β ââ[Μ] γ) (hf : MeasurePreserving f ÎŒ Μ) :
g.compMeasurePreserving f hf =
mk (g â f) (g.aestronglyMeasurable.comp_quasiMeasurePreserving hf.quasiMeasurePreserving) :=
g.compQuasiMeasurePreserving_eq_mk _
theorem coeFn_compMeasurePreserving (g : β ââ[Μ] γ) (hf : MeasurePreserving f ÎŒ Μ) :
g.compMeasurePreserving f hf =áµ[ÎŒ] g â f :=
g.coeFn_compQuasiMeasurePreserving _
end compMeasurePreserving
variable [TopologicalSpace β] [TopologicalSpace γ]
/-- Given a continuous function `g : β â γ`, and an almost everywhere equal function `[f] : α ââ β`,
return the equivalence class of `g â f`, i.e., the almost everywhere equal function
`[g â f] : α ââ γ`. -/
def comp (g : β â γ) (hg : Continuous g) (f : α ââ[ÎŒ] β) : α ââ[ÎŒ] γ :=
Quotient.liftOn' f (fun f => mk (g â (f : α â β)) (hg.comp_aestronglyMeasurable f.2))
fun _ _ H => mk_eq_mk.2 <| H.fun_comp g
@[simp]
theorem comp_mk (g : β â γ) (hg : Continuous g) (f : α â β) (hf) :
comp g hg (mk f hf : α ââ[ÎŒ] β) = mk (g â f) (hg.comp_aestronglyMeasurable hf) :=
rfl
theorem comp_eq_mk (g : β â γ) (hg : Continuous g) (f : α ââ[ÎŒ] β) :
comp g hg f = mk (g â f) (hg.comp_aestronglyMeasurable f.aestronglyMeasurable) := by
rw [â comp_mk g hg f f.aestronglyMeasurable, mk_coeFn]
theorem coeFn_comp (g : β â γ) (hg : Continuous g) (f : α ââ[ÎŒ] β) : comp g hg f =áµ[ÎŒ] g â f := by
rw [comp_eq_mk]
apply coeFn_mk
theorem comp_compQuasiMeasurePreserving
{β : Type*} [MeasurableSpace β] {Μ} (g : γ â ÎŽ) (hg : Continuous g)
(f : β ââ[Μ] γ) {Ï : α â β} (hÏ : Measure.QuasiMeasurePreserving Ï ÎŒ Μ) :
(comp g hg f).compQuasiMeasurePreserving Ï hÏ =
comp g hg (f.compQuasiMeasurePreserving Ï hÏ) := by
rcases f; rfl
section CompMeasurable
variable [MeasurableSpace β] [PseudoMetrizableSpace β] [BorelSpace β] [MeasurableSpace γ]
[PseudoMetrizableSpace γ] [OpensMeasurableSpace γ] [SecondCountableTopology γ]
/-- Given a measurable function `g : β â γ`, and an almost everywhere equal function `[f] : α ââ β`,
return the equivalence class of `g â f`, i.e., the almost everywhere equal function
`[g â f] : α ââ γ`. This requires that `γ` has a second countable topology. -/
def compMeasurable (g : β â γ) (hg : Measurable g) (f : α ââ[ÎŒ] β) : α ââ[ÎŒ] γ :=
Quotient.liftOn' f
(fun f' => mk (g â (f' : α â β)) (hg.comp_aemeasurable f'.2.aemeasurable).aestronglyMeasurable)
fun _ _ H => mk_eq_mk.2 <| H.fun_comp g
@[simp]
theorem compMeasurable_mk (g : β â γ) (hg : Measurable g) (f : α â β)
(hf : AEStronglyMeasurable f Ό) :
compMeasurable g hg (mk f hf : α ââ[ÎŒ] β) =
mk (g â f) (hg.comp_aemeasurable hf.aemeasurable).aestronglyMeasurable :=
rfl
theorem compMeasurable_eq_mk (g : β â γ) (hg : Measurable g) (f : α ââ[ÎŒ] β) :
compMeasurable g hg f =
mk (g â f) (hg.comp_aemeasurable f.aemeasurable).aestronglyMeasurable := by
rw [â compMeasurable_mk g hg f f.aestronglyMeasurable, mk_coeFn]
theorem coeFn_compMeasurable (g : β â γ) (hg : Measurable g) (f : α ââ[ÎŒ] β) :
compMeasurable g hg f =áµ[ÎŒ] g â f := by
rw [compMeasurable_eq_mk]
apply coeFn_mk
end CompMeasurable
/-- The class of `x ⊠(f x, g x)`. -/
def pair (f : α ââ[ÎŒ] β) (g : α ââ[ÎŒ] γ) : α ââ[ÎŒ] β à γ :=
Quotient.liftOnâ' f g (fun f g => mk (fun x => (f.1 x, g.1 x)) (f.2.prodMk g.2))
fun _f _g _f' _g' Hf Hg => mk_eq_mk.2 <| Hf.prodMk Hg
@[simp]
theorem pair_mk_mk (f : α â β) (hf) (g : α â γ) (hg) :
(mk f hf : α ââ[ÎŒ] β).pair (mk g hg) = mk (fun x => (f x, g x)) (hf.prodMk hg) :=
rfl
theorem pair_eq_mk (f : α ââ[ÎŒ] β) (g : α ââ[ÎŒ] γ) :
f.pair g =
mk (fun x => (f x, g x)) (f.aestronglyMeasurable.prodMk g.aestronglyMeasurable) := by
simp only [â pair_mk_mk, mk_coeFn, f.aestronglyMeasurable, g.aestronglyMeasurable]
theorem coeFn_pair (f : α ââ[ÎŒ] β) (g : α ââ[ÎŒ] γ) : f.pair g =áµ[ÎŒ] fun x => (f x, g x) := by
rw [pair_eq_mk]
apply coeFn_mk
/-- Given a continuous function `g : β â γ â ÎŽ`, and almost everywhere equal functions
`[fâ] : α ââ β` and `[fâ] : α ââ γ`, return the equivalence class of the function
`fun a => g (fâ a) (fâ a)`, i.e., the almost everywhere equal function
`[fun a => g (fâ a) (fâ a)] : α ââ γ` -/
def compâ (g : β â γ â ÎŽ) (hg : Continuous (uncurry g)) (fâ : α ââ[ÎŒ] β) (fâ : α ââ[ÎŒ] γ) :
α ââ[ÎŒ] ÎŽ :=
comp _ hg (fâ.pair fâ)
@[simp]
theorem compâ_mk_mk (g : β â γ â ÎŽ) (hg : Continuous (uncurry g)) (fâ : α â β) (fâ : α â γ)
(hfâ hfâ) :
compâ g hg (mk fâ hfâ : α ââ[ÎŒ] β) (mk fâ hfâ) =
mk (fun a => g (fâ a) (fâ a)) (hg.comp_aestronglyMeasurable (hfâ.prodMk hfâ)) :=
rfl
theorem compâ_eq_pair (g : β â γ â ÎŽ) (hg : Continuous (uncurry g)) (fâ : α ââ[ÎŒ] β)
(fâ : α ââ[ÎŒ] γ) : compâ g hg fâ fâ = comp _ hg (fâ.pair fâ) :=
rfl
theorem compâ_eq_mk (g : β â γ â ÎŽ) (hg : Continuous (uncurry g)) (fâ : α ââ[ÎŒ] β)
(fâ : α ââ[ÎŒ] γ) : compâ g hg fâ fâ = mk (fun a => g (fâ a) (fâ a))
(hg.comp_aestronglyMeasurable (fâ.aestronglyMeasurable.prodMk fâ.aestronglyMeasurable)) := by
rw [compâ_eq_pair, pair_eq_mk, comp_mk]; rfl
theorem coeFn_compâ (g : β â γ â ÎŽ) (hg : Continuous (uncurry g)) (fâ : α ââ[ÎŒ] β)
(fâ : α ââ[ÎŒ] γ) : compâ g hg fâ fâ =áµ[ÎŒ] fun a => g (fâ a) (fâ a) := by
rw [compâ_eq_mk]
apply coeFn_mk
section
variable [MeasurableSpace β] [PseudoMetrizableSpace β] [BorelSpace β]
[MeasurableSpace γ] [PseudoMetrizableSpace γ] [BorelSpace γ] [SecondCountableTopologyEither β γ]
[MeasurableSpace ÎŽ] [PseudoMetrizableSpace ÎŽ] [OpensMeasurableSpace ÎŽ] [SecondCountableTopology ÎŽ]
/-- Given a measurable function `g : β â γ â ÎŽ`, and almost everywhere equal functions
`[fâ] : α ââ β` and `[fâ] : α ââ γ`, return the equivalence class of the function
`fun a => g (fâ a) (fâ a)`, i.e., the almost everywhere equal function
`[fun a => g (fâ a) (fâ a)] : α ââ γ`. This requires `ÎŽ` to have second-countable topology. -/
def compâMeasurable (g : β â γ â ÎŽ) (hg : Measurable (uncurry g)) (fâ : α ââ[ÎŒ] β)
(fâ : α ââ[ÎŒ] γ) : α ââ[ÎŒ] ÎŽ :=
compMeasurable _ hg (fâ.pair fâ)
@[simp]
theorem compâMeasurable_mk_mk (g : β â γ â ÎŽ) (hg : Measurable (uncurry g)) (fâ : α â β)
(fâ : α â γ) (hfâ hfâ) :
compâMeasurable g hg (mk fâ hfâ : α ââ[ÎŒ] β) (mk fâ hfâ) =
mk (fun a => g (fâ a) (fâ a))
(hg.comp_aemeasurable (hfâ.aemeasurable.prodMk hfâ.aemeasurable)).aestronglyMeasurable :=
rfl
theorem compâMeasurable_eq_pair (g : β â γ â ÎŽ) (hg : Measurable (uncurry g)) (fâ : α ââ[ÎŒ] β)
(fâ : α ââ[ÎŒ] γ) : compâMeasurable g hg fâ fâ = compMeasurable _ hg (fâ.pair fâ) :=
rfl
theorem compâMeasurable_eq_mk (g : β â γ â ÎŽ) (hg : Measurable (uncurry g)) (fâ : α ââ[ÎŒ] β)
(fâ : α ââ[ÎŒ] γ) :
compâMeasurable g hg fâ fâ =
mk (fun a => g (fâ a) (fâ a))
(hg.comp_aemeasurable (fâ.aemeasurable.prodMk fâ.aemeasurable)).aestronglyMeasurable := by
rw [compâMeasurable_eq_pair, pair_eq_mk, compMeasurable_mk]; rfl
theorem coeFn_compâMeasurable (g : β â γ â ÎŽ) (hg : Measurable (uncurry g)) (fâ : α ââ[ÎŒ] β)
(fâ : α ââ[ÎŒ] γ) : compâMeasurable g hg fâ fâ =áµ[ÎŒ] fun a => g (fâ a) (fâ a) := by
rw [compâMeasurable_eq_mk]
apply coeFn_mk
end
/-- Interpret `f : α ââ[ÎŒ] β` as a germ at `ae ÎŒ` forgetting that `f` is almost everywhere
strongly measurable. -/
def toGerm (f : α ââ[ÎŒ] β) : Germ (ae ÎŒ) β :=
Quotient.liftOn' f (fun f => ((f : α â β) : Germ (ae ÎŒ) β)) fun _ _ H => Germ.coe_eq.2 H
@[simp]
theorem mk_toGerm (f : α â β) (hf) : (mk f hf : α ââ[ÎŒ] β).toGerm = f :=
rfl
theorem toGerm_eq (f : α ââ[ÎŒ] β) : f.toGerm = (f : α â β) := by rw [â mk_toGerm, mk_coeFn]
theorem toGerm_injective : Injective (toGerm : (α ââ[ÎŒ] β) â Germ (ae ÎŒ) β) := fun f g H =>
ext <| Germ.coe_eq.1 <| by rwa [â toGerm_eq, â toGerm_eq]
@[simp]
theorem compQuasiMeasurePreserving_toGerm {β : Type*} [MeasurableSpace β] {f : α â β} {Μ}
(g : β ââ[Μ] γ) (hf : Measure.QuasiMeasurePreserving f ÎŒ Μ) :
(g.compQuasiMeasurePreserving f hf).toGerm = g.toGerm.compTendsto f hf.tendsto_ae := by
rcases g; rfl
@[simp]
theorem compMeasurePreserving_toGerm {β : Type*} [MeasurableSpace β] {f : α â β} {Μ}
(g : β ââ[Μ] γ) (hf : MeasurePreserving f ÎŒ Μ) :
(g.compMeasurePreserving f hf).toGerm =
g.toGerm.compTendsto f hf.quasiMeasurePreserving.tendsto_ae :=
compQuasiMeasurePreserving_toGerm _ _
theorem comp_toGerm (g : β â γ) (hg : Continuous g) (f : α ââ[ÎŒ] β) :
(comp g hg f).toGerm = f.toGerm.map g :=
induction_on f fun f _ => by simp
theorem compMeasurable_toGerm [MeasurableSpace β] [BorelSpace β] [PseudoMetrizableSpace β]
[PseudoMetrizableSpace γ] [SecondCountableTopology γ] [MeasurableSpace γ]
[OpensMeasurableSpace γ] (g : β â γ) (hg : Measurable g) (f : α ââ[ÎŒ] β) :
(compMeasurable g hg f).toGerm = f.toGerm.map g :=
induction_on f fun f _ => by simp
theorem compâ_toGerm (g : β â γ â ÎŽ) (hg : Continuous (uncurry g)) (fâ : α ââ[ÎŒ] β)
(fâ : α ââ[ÎŒ] γ) : (compâ g hg fâ fâ).toGerm = fâ.toGerm.mapâ g fâ.toGerm :=
induction_onâ fâ fâ fun fâ _ fâ _ => by simp
theorem compâMeasurable_toGerm [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β]
[PseudoMetrizableSpace γ] [SecondCountableTopologyEither β γ]
[MeasurableSpace γ] [BorelSpace γ] [PseudoMetrizableSpace Ύ] [SecondCountableTopology Ύ]
[MeasurableSpace ÎŽ] [OpensMeasurableSpace ÎŽ] (g : β â γ â ÎŽ) (hg : Measurable (uncurry g))
(fâ : α ââ[ÎŒ] β) (fâ : α ââ[ÎŒ] γ) :
(compâMeasurable g hg fâ fâ).toGerm = fâ.toGerm.mapâ g fâ.toGerm :=
induction_onâ fâ fâ fun fâ _ fâ _ => by simp
/-- Given a predicate `p` and an equivalence class `[f]`, return true if `p` holds of `f a`
for almost all `a` -/
def LiftPred (p : β â Prop) (f : α ââ[ÎŒ] β) : Prop :=
f.toGerm.LiftPred p
/-- Given a relation `r` and equivalence class `[f]` and `[g]`, return true if `r` holds of
`(f a, g a)` for almost all `a` -/
def LiftRel (r : β â γ â Prop) (f : α ââ[ÎŒ] β) (g : α ââ[ÎŒ] γ) : Prop :=
f.toGerm.LiftRel r g.toGerm
theorem liftRel_mk_mk {r : β â γ â Prop} {f : α â β} {g : α â γ} {hf hg} :
LiftRel r (mk f hf : α ââ[ÎŒ] β) (mk g hg) â âáµ a âÎŒ, r (f a) (g a) :=
Iff.rfl
| theorem liftRel_iff_coeFn {r : β â γ â Prop} {f : α ââ[ÎŒ] β} {g : α ââ[ÎŒ] γ} :
LiftRel r f g â âáµ a âÎŒ, r (f a) (g a) := by rw [â liftRel_mk_mk, mk_coeFn, mk_coeFn]
section Order
| Mathlib/MeasureTheory/Function/AEEqFun.lean | 472 | 476 |
/-
Copyright (c) 2020 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis, Eric Wieser
-/
import Mathlib.LinearAlgebra.Multilinear.TensorProduct
import Mathlib.Tactic.AdaptationNote
import Mathlib.LinearAlgebra.Multilinear.Curry
/-!
# Tensor product of an indexed family of modules over commutative semirings
We define the tensor product of an indexed family `s : ι â Type*` of modules over commutative
semirings. We denote this space by `âš[R] i, s i` and define it as `FreeAddMonoid (R Ã Î i, s i)`
quotiented by the appropriate equivalence relation. The treatment follows very closely that of the
binary tensor product in `LinearAlgebra/TensorProduct.lean`.
## Main definitions
* `PiTensorProduct R s` with `R` a commutative semiring and `s : ι â Type*` is the tensor product
of all the `s i`'s. This is denoted by `âš[R] i, s i`.
* `tprod R f` with `f : Πi, s i` is the tensor product of the vectors `f i` over all `i : ι`.
This is bundled as a multilinear map from `Î i, s i` to `âš[R] i, s i`.
* `liftAddHom` constructs an `AddMonoidHom` from `(âš[R] i, s i)` to some space `F` from a
function `Ï : (R Ã Î i, s i) â F` with the appropriate properties.
* `lift Ï` with `Ï : MultilinearMap R s E` is the corresponding linear map
`(âš[R] i, s i) ââ[R] E`. This is bundled as a linear equivalence.
* `PiTensorProduct.reindex e` re-indexes the components of `âš[R] i : ι, M` along `e : ι â ιâ`.
* `PiTensorProduct.tmulEquiv` equivalence between a `TensorProduct` of `PiTensorProduct`s and
a single `PiTensorProduct`.
## Notations
* `âš[R] i, s i` is defined as localized notation in locale `TensorProduct`.
* `âšâ[R] i, f i` with `f : â i, s i` is defined globally as the tensor product of all the `f i`'s.
## Implementation notes
* We define it via `FreeAddMonoid (R Ã Î i, s i)` with the `R` representing a "hidden" tensor
factor, rather than `FreeAddMonoid (Πi, s i)` to ensure that, if `ι` is an empty type,
the space is isomorphic to the base ring `R`.
* We have not restricted the index type `ι` to be a `Fintype`, as nothing we do here strictly
requires it. However, problems may arise in the case where `ι` is infinite; use at your own
caution.
* Instead of requiring `DecidableEq ι` as an argument to `PiTensorProduct` itself, we include it
as an argument in the constructors of the relation. A decidability instance still has to come
from somewhere due to the use of `Function.update`, but this hides it from the downstream user.
See the implementation notes for `MultilinearMap` for an extended discussion of this choice.
## TODO
* Define tensor powers, symmetric subspace, etc.
* API for the various ways `ι` can be split into subsets; connect this with the binary
tensor product.
* Include connection with holors.
* Port more of the API from the binary tensor product over to this case.
## Tags
multilinear, tensor, tensor product
-/
suppress_compilation
open Function
section Semiring
variable {ι ιâ ιâ : Type*}
variable {R : Type*} [CommSemiring R]
variable {Râ Râ : Type*}
variable {s : ι â Type*} [â i, AddCommMonoid (s i)] [â i, Module R (s i)]
variable {M : Type*} [AddCommMonoid M] [Module R M]
variable {E : Type*} [AddCommMonoid E] [Module R E]
variable {F : Type*} [AddCommMonoid F]
namespace PiTensorProduct
variable (R) (s)
/-- The relation on `FreeAddMonoid (R Ã Î i, s i)` that generates a congruence whose quotient is
the tensor product. -/
inductive Eqv : FreeAddMonoid (R Ã Î i, s i) â FreeAddMonoid (R Ã Î i, s i) â Prop
| of_zero : â (r : R) (f : Î i, s i) (i : ι) (_ : f i = 0), Eqv (FreeAddMonoid.of (r, f)) 0
| of_zero_scalar : â f : Î i, s i, Eqv (FreeAddMonoid.of (0, f)) 0
| of_add : â (_ : DecidableEq ι) (r : R) (f : Î i, s i) (i : ι) (mâ mâ : s i),
Eqv (FreeAddMonoid.of (r, update f i mâ) + FreeAddMonoid.of (r, update f i mâ))
(FreeAddMonoid.of (r, update f i (mâ + mâ)))
| of_add_scalar : â (r r' : R) (f : Î i, s i),
Eqv (FreeAddMonoid.of (r, f) + FreeAddMonoid.of (r', f)) (FreeAddMonoid.of (r + r', f))
| of_smul : â (_ : DecidableEq ι) (r : R) (f : Î i, s i) (i : ι) (r' : R),
Eqv (FreeAddMonoid.of (r, update f i (r' ⢠f i))) (FreeAddMonoid.of (r' * r, f))
| add_comm : â x y, Eqv (x + y) (y + x)
end PiTensorProduct
variable (R) (s)
/-- `PiTensorProduct R s` with `R` a commutative semiring and `s : ι â Type*` is the tensor
product of all the `s i`'s. This is denoted by `âš[R] i, s i`. -/
def PiTensorProduct : Type _ :=
(addConGen (PiTensorProduct.Eqv R s)).Quotient
variable {R}
unsuppress_compilation in
/-- This enables the notation `âš[R] i : ι, s i` for the pi tensor product `PiTensorProduct`,
given an indexed family of types `s : ι â Type*`. -/
scoped[TensorProduct] notation3:100"âš["R"] "(...)", "r:(scoped f => PiTensorProduct R f) => r
open TensorProduct
namespace PiTensorProduct
section Module
instance : AddCommMonoid (âš[R] i, s i) :=
{ (addConGen (PiTensorProduct.Eqv R s)).addMonoid with
add_comm := fun x y âŠ
AddCon.induction_onâ x y fun _ _ âŠ
Quotient.sound' <| AddConGen.Rel.of _ _ <| Eqv.add_comm _ _ }
instance : Inhabited (âš[R] i, s i) := âš0â©
variable (R) {s}
/-- `tprodCoeff R r f` with `r : R` and `f : Î i, s i` is the tensor product of the vectors `f i`
over all `i : ι`, multiplied by the coefficient `r`. Note that this is meant as an auxiliary
definition for this file alone, and that one should use `tprod` defined below for most purposes. -/
def tprodCoeff (r : R) (f : Î i, s i) : âš[R] i, s i :=
AddCon.mk' _ <| FreeAddMonoid.of (r, f)
variable {R}
theorem zero_tprodCoeff (f : Î i, s i) : tprodCoeff R 0 f = 0 :=
Quotient.sound' <| AddConGen.Rel.of _ _ <| Eqv.of_zero_scalar _
theorem zero_tprodCoeff' (z : R) (f : Πi, s i) (i : ι) (hf : f i = 0) : tprodCoeff R z f = 0 :=
Quotient.sound' <| AddConGen.Rel.of _ _ <| Eqv.of_zero _ _ i hf
theorem add_tprodCoeff [DecidableEq ι] (z : R) (f : Î i, s i) (i : ι) (mâ mâ : s i) :
tprodCoeff R z (update f i mâ) + tprodCoeff R z (update f i mâ) =
tprodCoeff R z (update f i (mâ + mâ)) :=
Quotient.sound' <| AddConGen.Rel.of _ _ (Eqv.of_add _ z f i mâ mâ)
theorem add_tprodCoeff' (zâ zâ : R) (f : Î i, s i) :
tprodCoeff R zâ f + tprodCoeff R zâ f = tprodCoeff R (zâ + zâ) f :=
Quotient.sound' <| AddConGen.Rel.of _ _ (Eqv.of_add_scalar zâ zâ f)
theorem smul_tprodCoeff_aux [DecidableEq ι] (z : R) (f : Πi, s i) (i : ι) (r : R) :
tprodCoeff R z (update f i (r ⢠f i)) = tprodCoeff R (r * z) f :=
Quotient.sound' <| AddConGen.Rel.of _ _ <| Eqv.of_smul _ _ _ _ _
theorem smul_tprodCoeff [DecidableEq ι] (z : R) (f : Î i, s i) (i : ι) (r : Râ) [SMul Râ R]
[IsScalarTower Râ R R] [SMul Râ (s i)] [IsScalarTower Râ R (s i)] :
tprodCoeff R z (update f i (r ⢠f i)) = tprodCoeff R (r ⢠z) f := by
have hâ : r ⢠z = r ⢠(1 : R) * z := by rw [smul_mul_assoc, one_mul]
have hâ : r ⢠f i = (r ⢠(1 : R)) ⢠f i := (smul_one_smul _ _ _).symm
rw [hâ, hâ]
exact smul_tprodCoeff_aux z f i _
/-- Construct an `AddMonoidHom` from `(âš[R] i, s i)` to some space `F` from a function
`Ï : (R Ã Î i, s i) â F` with the appropriate properties. -/
def liftAddHom (Ï : (R Ã Î i, s i) â F)
(C0 : â (r : R) (f : Î i, s i) (i : ι) (_ : f i = 0), Ï (r, f) = 0)
(C0' : â f : Î i, s i, Ï (0, f) = 0)
(C_add : â [DecidableEq ι] (r : R) (f : Î i, s i) (i : ι) (mâ mâ : s i),
Ï (r, update f i mâ) + Ï (r, update f i mâ) = Ï (r, update f i (mâ + mâ)))
(C_add_scalar : â (r r' : R) (f : Î i, s i), Ï (r, f) + Ï (r', f) = Ï (r + r', f))
(C_smul : â [DecidableEq ι] (r : R) (f : Î i, s i) (i : ι) (r' : R),
Ï (r, update f i (r' ⢠f i)) = Ï (r' * r, f)) :
(âš[R] i, s i) â+ F :=
(addConGen (PiTensorProduct.Eqv R s)).lift (FreeAddMonoid.lift Ï) <|
AddCon.addConGen_le fun x y hxy âŠ
match hxy with
| Eqv.of_zero r' f i hf =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, C0 r' f i hf]
| Eqv.of_zero_scalar f =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, C0']
| Eqv.of_add inst z f i mâ mâ =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, @C_add inst]
| Eqv.of_add_scalar zâ zâ f =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, C_add_scalar]
| Eqv.of_smul inst z f i r' =>
(AddCon.ker_rel _).2 <| by simp [FreeAddMonoid.lift_eval_of, @C_smul inst]
| Eqv.add_comm x y =>
(AddCon.ker_rel _).2 <| by simp_rw [AddMonoidHom.map_add, add_comm]
/-- Induct using `tprodCoeff` -/
@[elab_as_elim]
protected theorem induction_on' {motive : (âš[R] i, s i) â Prop} (z : âš[R] i, s i)
(tprodCoeff : â (r : R) (f : Î i, s i), motive (tprodCoeff R r f))
(add : â x y, motive x â motive y â motive (x + y)) :
motive z := by
have C0 : motive 0 := by
have hâ := tprodCoeff 0 0
rwa [zero_tprodCoeff] at hâ
refine AddCon.induction_on z fun x ⊠FreeAddMonoid.recOn x C0 ?_
simp_rw [AddCon.coe_add]
refine fun f y ih ⊠add _ _ ?_ ih
convert tprodCoeff f.1 f.2
section DistribMulAction
variable [Monoid Râ] [DistribMulAction Râ R] [SMulCommClass Râ R R]
variable [Monoid Râ] [DistribMulAction Râ R] [SMulCommClass Râ R R]
-- Most of the time we want the instance below this one, which is easier for typeclass resolution
-- to find.
instance hasSMul' : SMul Râ (âš[R] i, s i) :=
âšfun r âŠ
liftAddHom (fun f : R à Πi, s i ⊠tprodCoeff R (r ⢠f.1) f.2)
(fun r' f i hf ⊠by simp_rw [zero_tprodCoeff' _ f i hf])
(fun f ⊠by simp [zero_tprodCoeff]) (fun r' f i mâ mâ ⊠by simp [add_tprodCoeff])
(fun r' r'' f ⊠by simp [add_tprodCoeff', mul_add]) fun z f i r' ⊠by
simp [smul_tprodCoeff, mul_smul_comm]â©
instance : SMul R (âš[R] i, s i) :=
PiTensorProduct.hasSMul'
theorem smul_tprodCoeff' (r : Râ) (z : R) (f : Î i, s i) :
r ⢠tprodCoeff R z f = tprodCoeff R (r ⢠z) f := rfl
protected theorem smul_add (r : Râ) (x y : âš[R] i, s i) : r ⢠(x + y) = r ⢠x + r ⢠y :=
AddMonoidHom.map_add _ _ _
instance distribMulAction' : DistribMulAction Râ (âš[R] i, s i) where
smul := (· ⢠·)
smul_add _ _ _ := AddMonoidHom.map_add _ _ _
mul_smul r r' x :=
PiTensorProduct.induction_on' x (fun {r'' f} ⊠by simp [smul_tprodCoeff', smul_smul])
fun {x y} ihx ihy ⊠by simp_rw [PiTensorProduct.smul_add, ihx, ihy]
one_smul x :=
PiTensorProduct.induction_on' x (fun {r f} ⊠by rw [smul_tprodCoeff', one_smul])
fun {z y} ihz ihy ⊠by simp_rw [PiTensorProduct.smul_add, ihz, ihy]
smul_zero _ := AddMonoidHom.map_zero _
instance smulCommClass' [SMulCommClass Râ Râ R] : SMulCommClass Râ Râ (âš[R] i, s i) :=
âšfun {r' r''} x âŠ
PiTensorProduct.induction_on' x (fun {xr xf} ⊠by simp only [smul_tprodCoeff', smul_comm])
fun {z y} ihz ihy ⊠by simp_rw [PiTensorProduct.smul_add, ihz, ihy]â©
instance isScalarTower' [SMul Râ Râ] [IsScalarTower Râ Râ R] :
IsScalarTower Râ Râ (âš[R] i, s i) :=
âšfun {r' r''} x âŠ
PiTensorProduct.induction_on' x (fun {xr xf} ⊠by simp only [smul_tprodCoeff', smul_assoc])
fun {z y} ihz ihy ⊠by simp_rw [PiTensorProduct.smul_add, ihz, ihy]â©
end DistribMulAction
-- Most of the time we want the instance below this one, which is easier for typeclass resolution
-- to find.
instance module' [Semiring Râ] [Module Râ R] [SMulCommClass Râ R R] : Module Râ (âš[R] i, s i) :=
{ PiTensorProduct.distribMulAction' with
add_smul := fun r r' x âŠ
PiTensorProduct.induction_on' x
(fun {r f} ⊠by simp_rw [smul_tprodCoeff', add_smul, add_tprodCoeff'])
fun {x y} ihx ihy ⊠by simp_rw [PiTensorProduct.smul_add, ihx, ihy, add_add_add_comm]
zero_smul := fun x âŠ
PiTensorProduct.induction_on' x
(fun {r f} ⊠by simp_rw [smul_tprodCoeff', zero_smul, zero_tprodCoeff])
fun {x y} ihx ihy ⊠by simp_rw [PiTensorProduct.smul_add, ihx, ihy, add_zero] }
-- shortcut instances
instance : Module R (âš[R] i, s i) :=
PiTensorProduct.module'
instance : SMulCommClass R R (âš[R] i, s i) :=
PiTensorProduct.smulCommClass'
instance : IsScalarTower R R (âš[R] i, s i) :=
PiTensorProduct.isScalarTower'
variable (R) in
/-- The canonical `MultilinearMap R s (âš[R] i, s i)`.
`tprod R fun i => f i` has notation `âšâ[R] i, f i`. -/
def tprod : MultilinearMap R s (âš[R] i, s i) where
toFun := tprodCoeff R 1
map_update_add' {_ f} i x y := (add_tprodCoeff (1 : R) f i x y).symm
map_update_smul' {_ f} i r x := by
rw [smul_tprodCoeff', â smul_tprodCoeff (1 : R) _ i, update_idem, update_self]
unsuppress_compilation in
@[inherit_doc tprod]
notation3:100 "âšâ["R"] "(...)", "r:(scoped f => tprod R f) => r
theorem tprod_eq_tprodCoeff_one :
â(tprod R : MultilinearMap R s (âš[R] i, s i)) = tprodCoeff R 1 := rfl
@[simp]
theorem tprodCoeff_eq_smul_tprod (z : R) (f : Πi, s i) : tprodCoeff R z f = z ⢠tprod R f := by
have : z = z ⢠(1 : R) := by simp only [mul_one, Algebra.id.smul_eq_mul]
conv_lhs => rw [this]
rfl
/-- The image of an element `p` of `FreeAddMonoid (R Ã Î i, s i)` in the `PiTensorProduct` is
equal to the sum of `a ⢠âšâ[R] i, m i` over all the entries `(a, m)` of `p`.
-/
lemma _root_.FreeAddMonoid.toPiTensorProduct (p : FreeAddMonoid (R Ã Î i, s i)) :
AddCon.toQuotient (c := addConGen (PiTensorProduct.Eqv R s)) p =
List.sum (List.map (fun x ⊠x.1 ⢠âšâ[R] i, x.2 i) p.toList) := by
-- TODO: this is defeq abuse: `p` is not a `List`.
match p with
| [] => rw [FreeAddMonoid.toList_nil, List.map_nil, List.sum_nil]; rfl
| x :: ps =>
rw [FreeAddMonoid.toList_cons, List.map_cons, List.sum_cons, â List.singleton_append,
â toPiTensorProduct ps, â tprodCoeff_eq_smul_tprod]
rfl
/-- The set of lifts of an element `x` of `âš[R] i, s i` in `FreeAddMonoid (R Ã Î i, s i)`. -/
def lifts (x : âš[R] i, s i) : Set (FreeAddMonoid (R Ã Î i, s i)) :=
{p | AddCon.toQuotient (c := addConGen (PiTensorProduct.Eqv R s)) p = x}
/-- An element `p` of `FreeAddMonoid (R Ã Î i, s i)` lifts an element `x` of `âš[R] i, s i`
if and only if `x` is equal to the sum of `a ⢠âšâ[R] i, m i` over all the entries
`(a, m)` of `p`.
-/
lemma mem_lifts_iff (x : âš[R] i, s i) (p : FreeAddMonoid (R Ã Î i, s i)) :
p â lifts x â List.sum (List.map (fun x ⊠x.1 ⢠âšâ[R] i, x.2 i) p.toList) = x := by
simp only [lifts, Set.mem_setOf_eq, FreeAddMonoid.toPiTensorProduct]
/-- Every element of `âš[R] i, s i` has a lift in `FreeAddMonoid (R Ã Î i, s i)`.
-/
lemma nonempty_lifts (x : âš[R] i, s i) : Set.Nonempty (lifts x) := by
existsi @Quotient.out _ (addConGen (PiTensorProduct.Eqv R s)).toSetoid x
simp only [lifts, Set.mem_setOf_eq]
rw [â AddCon.quot_mk_eq_coe]
erw [Quot.out_eq]
/-- The empty list lifts the element `0` of `âš[R] i, s i`.
-/
lemma lifts_zero : 0 â lifts (0 : âš[R] i, s i) := by
rw [mem_lifts_iff]; erw [List.map_nil]; rw [List.sum_nil]
/-- If elements `p,q` of `FreeAddMonoid (R Ã Î i, s i)` lift elements `x,y` of `âš[R] i, s i`
respectively, then `p + q` lifts `x + y`.
-/
lemma lifts_add {x y : âš[R] i, s i} {p q : FreeAddMonoid (R Ã Î i, s i)}
(hp : p â lifts x) (hq : q â lifts y) : p + q â lifts (x + y) := by
simp only [lifts, Set.mem_setOf_eq, AddCon.coe_add]
rw [hp, hq]
/-- If an element `p` of `FreeAddMonoid (R Ã Î i, s i)` lifts an element `x` of `âš[R] i, s i`,
and if `a` is an element of `R`, then the list obtained by multiplying the first entry of each
element of `p` by `a` lifts `a ⢠x`.
-/
lemma lifts_smul {x : âš[R] i, s i} {p : FreeAddMonoid (R Ã Î i, s i)} (h : p â lifts x) (a : R) :
p.map (fun (y : R à Πi, s i) ⊠(a * y.1, y.2)) â lifts (a ⢠x) := by
rw [mem_lifts_iff] at h â¢
rw [â h]
simp [Function.comp_def, mul_smul, List.smul_sum]
/-- Induct using scaled versions of `PiTensorProduct.tprod`. -/
@[elab_as_elim]
protected theorem induction_on {motive : (âš[R] i, s i) â Prop} (z : âš[R] i, s i)
(smul_tprod : â (r : R) (f : Î i, s i), motive (r ⢠tprod R f))
(add : â x y, motive x â motive y â motive (x + y)) :
motive z := by
simp_rw [â tprodCoeff_eq_smul_tprod] at smul_tprod
exact PiTensorProduct.induction_on' z smul_tprod add
@[ext]
theorem ext {Ïâ Ïâ : (âš[R] i, s i) ââ[R] E}
(H : Ïâ.compMultilinearMap (tprod R) = Ïâ.compMultilinearMap (tprod R)) : Ïâ = Ïâ := by
refine LinearMap.ext ?_
refine fun z âŠ
PiTensorProduct.induction_on' z ?_ fun {x y} hx hy ⊠by rw [Ïâ.map_add, Ïâ.map_add, hx, hy]
· intro r f
rw [tprodCoeff_eq_smul_tprod, Ïâ.map_smul, Ïâ.map_smul]
apply congr_arg
exact MultilinearMap.congr_fun H f
/-- The pure tensors (i.e. the elements of the image of `PiTensorProduct.tprod`) span
the tensor product. -/
theorem span_tprod_eq_top :
Submodule.span R (Set.range (tprod R)) = (†: Submodule R (âš[R] i, s i)) :=
Submodule.eq_top_iff'.mpr fun t ⊠t.induction_on
(fun _ _ ⊠Submodule.smul_mem _ _
(Submodule.subset_span (by simp only [Set.mem_range, exists_apply_eq_apply])))
(fun _ _ hx hy ⊠Submodule.add_mem _ hx hy)
end Module
section Multilinear
open MultilinearMap
variable {s}
section lift
/-- Auxiliary function to constructing a linear map `(âš[R] i, s i) â E` given a
`MultilinearMap R s E` with the property that its composition with the canonical
`MultilinearMap R s (âš[R] i, s i)` is the given multilinear map. -/
def liftAux (Ï : MultilinearMap R s E) : (âš[R] i, s i) â+ E :=
liftAddHom (fun p : R à Πi, s i ⊠p.1 â¢ Ï p.2)
(fun z f i hf ⊠by simp_rw [map_coord_zero Ï i hf, smul_zero])
(fun f ⊠by simp_rw [zero_smul])
(fun z f i mâ mâ ⊠by simp_rw [â smul_add, Ï.map_update_add])
(fun zâ zâ f ⊠by rw [â add_smul])
fun z f i r ⊠by simp [Ï.map_update_smul, smul_smul, mul_comm]
theorem liftAux_tprod (Ï : MultilinearMap R s E) (f : Î i, s i) : liftAux Ï (tprod R f) = Ï f := by
simp only [liftAux, liftAddHom, tprod_eq_tprodCoeff_one, tprodCoeff, AddCon.coe_mk']
-- The end of this proof was very different before https://github.com/leanprover/lean4/pull/2644:
-- rw [FreeAddMonoid.of, FreeAddMonoid.ofList, Equiv.refl_apply, AddCon.lift_coe]
-- dsimp [FreeAddMonoid.lift, FreeAddMonoid.sumAux]
-- show _ ⢠_ = _
-- rw [one_smul]
erw [AddCon.lift_coe]
rw [FreeAddMonoid.of]
dsimp [FreeAddMonoid.ofList]
rw [â one_smul R (Ï f)]
erw [Equiv.refl_apply]
convert one_smul R (Ï f)
simp
theorem liftAux_tprodCoeff (Ï : MultilinearMap R s E) (z : R) (f : Î i, s i) :
liftAux Ï (tprodCoeff R z f) = z â¢ Ï f := rfl
theorem liftAux.smul {Ï : MultilinearMap R s E} (r : R) (x : âš[R] i, s i) :
liftAux Ï (r ⢠x) = r ⢠liftAux Ï x := by
refine PiTensorProduct.induction_on' x ?_ ?_
· intro z f
rw [smul_tprodCoeff' r z f, liftAux_tprodCoeff, liftAux_tprodCoeff, smul_assoc]
· intro z y ihz ihy
rw [smul_add, (liftAux Ï).map_add, ihz, ihy, (liftAux Ï).map_add, smul_add]
/-- Constructing a linear map `(âš[R] i, s i) â E` given a `MultilinearMap R s E` with the
property that its composition with the canonical `MultilinearMap R s E` is
the given multilinear map `Ï`. -/
def lift : MultilinearMap R s E ââ[R] (âš[R] i, s i) ââ[R] E where
toFun Ï := { liftAux Ï with map_smul' := liftAux.smul }
invFun Ï' := Ï'.compMultilinearMap (tprod R)
left_inv Ï := by
ext
simp [liftAux_tprod, LinearMap.compMultilinearMap]
right_inv Ï := by
ext
simp [liftAux_tprod]
map_add' Ïâ Ïâ := by
ext
simp [liftAux_tprod]
map_smul' r Ïâ := by
ext
simp [liftAux_tprod]
variable {Ï : MultilinearMap R s E}
@[simp]
theorem lift.tprod (f : Î i, s i) : lift Ï (tprod R f) = Ï f :=
liftAux_tprod Ï f
theorem lift.unique' {Ï' : (âš[R] i, s i) ââ[R] E}
(H : Ï'.compMultilinearMap (PiTensorProduct.tprod R) = Ï) : Ï' = lift Ï :=
ext <| H.symm âž (lift.symm_apply_apply Ï).symm
theorem lift.unique {Ï' : (âš[R] i, s i) ââ[R] E} (H : â f, Ï' (PiTensorProduct.tprod R f) = Ï f) :
Ï' = lift Ï :=
lift.unique' (MultilinearMap.ext H)
@[simp]
theorem lift_symm (Ï' : (âš[R] i, s i) ââ[R] E) : lift.symm Ï' = Ï'.compMultilinearMap (tprod R) :=
rfl
@[simp]
theorem lift_tprod : lift (tprod R : MultilinearMap R s _) = LinearMap.id :=
Eq.symm <| lift.unique' rfl
end lift
section map
variable {t t' : ι â Type*}
variable [â i, AddCommMonoid (t i)] [â i, Module R (t i)]
variable [â i, AddCommMonoid (t' i)] [â i, Module R (t' i)]
variable (g : Î i, t i ââ[R] t' i) (f : Î i, s i ââ[R] t i)
/--
Let `sáµ¢` and `táµ¢` be two families of `R`-modules.
Let `f` be a family of `R`-linear maps between `sáµ¢` and `táµ¢`, i.e. `f : Î áµ¢ sáµ¢ â táµ¢`,
then there is an induced map `âšáµ¢ sáµ¢ â âšáµ¢ táµ¢` by `âš aáµ¢ ⊠⚠fáµ¢ aáµ¢`.
This is `TensorProduct.map` for an arbitrary family of modules.
-/
def map : (âš[R] i, s i) ââ[R] âš[R] i, t i :=
lift <| (tprod R).compLinearMap f
@[simp] lemma map_tprod (x : Î i, s i) :
map f (tprod R x) = tprod R fun i ⊠f i (x i) :=
lift.tprod _
-- No lemmas about associativity, because we don't have associativity of `PiTensorProduct` yet.
theorem map_range_eq_span_tprod :
LinearMap.range (map f) =
Submodule.span R {t | â (m : Î i, s i), tprod R (fun i ⊠f i (m i)) = t} := by
rw [â Submodule.map_top, â span_tprod_eq_top, Submodule.map_span, â Set.range_comp]
apply congrArg; ext x
simp only [Set.mem_range, comp_apply, map_tprod, Set.mem_setOf_eq]
/-- Given submodules `p i â s i`, this is the natural map: `âš[R] i, p i â âš[R] i, s i`.
This is `TensorProduct.mapIncl` for an arbitrary family of modules.
-/
@[simp]
def mapIncl (p : Î i, Submodule R (s i)) : (âš[R] i, p i) ââ[R] âš[R] i, s i :=
map fun (i : ι) ⊠(p i).subtype
theorem map_comp : map (fun (i : ι) ⊠g i ââ f i) = map g ââ map f := by
ext
simp only [LinearMap.compMultilinearMap_apply, map_tprod, LinearMap.coe_comp, Function.comp_apply]
theorem lift_comp_map (h : MultilinearMap R t E) :
lift h ââ map f = lift (h.compLinearMap f) := by
ext
simp only [LinearMap.compMultilinearMap_apply, LinearMap.coe_comp, Function.comp_apply,
map_tprod, lift.tprod, MultilinearMap.compLinearMap_apply]
attribute [local ext high] ext
@[simp]
theorem map_id : map (fun i ⊠(LinearMap.id : s i ââ[R] s i)) = .id := by
ext
simp only [LinearMap.compMultilinearMap_apply, map_tprod, LinearMap.id_coe, id_eq]
@[simp]
protected theorem map_one : map (fun (i : ι) ⊠(1 : s i ââ[R] s i)) = 1 :=
map_id
protected theorem map_mul (fâ fâ : Î i, s i ââ[R] s i) :
map (fun i ⊠fâ i * fâ i) = map fâ * map fâ :=
map_comp fâ fâ
/-- Upgrading `PiTensorProduct.map` to a `MonoidHom` when `s = t`. -/
@[simps]
def mapMonoidHom : (Î i, s i ââ[R] s i) â* ((âš[R] i, s i) ââ[R] âš[R] i, s i) where
toFun := map
map_one' := PiTensorProduct.map_one
map_mul' := PiTensorProduct.map_mul
@[simp]
protected theorem map_pow (f : Î i, s i ââ[R] s i) (n : â) :
map (f ^ n) = map f ^ n := MonoidHom.map_pow mapMonoidHom _ _
open Function in
private theorem map_add_smul_aux [DecidableEq ι] (i : ι) (x : Î i, s i) (u : s i ââ[R] t i) :
(fun j ⊠update f i u j (x j)) = update (fun j ⊠(f j) (x j)) i (u (x i)) := by
ext j
exact apply_update (fun i F => F (x i)) f i u j
open Function in
protected theorem map_update_add [DecidableEq ι] (i : ι) (u v : s i ââ[R] t i) :
map (update f i (u + v)) = map (update f i u) + map (update f i v) := by
ext x
simp only [LinearMap.compMultilinearMap_apply, map_tprod, map_add_smul_aux, LinearMap.add_apply,
MultilinearMap.map_update_add]
@[deprecated (since := "2024-11-03")] protected alias map_add := PiTensorProduct.map_update_add
open Function in
protected theorem map_update_smul [DecidableEq ι] (i : ι) (c : R) (u : s i ââ[R] t i) :
map (update f i (c ⢠u)) = c ⢠map (update f i u) := by
ext x
simp only [LinearMap.compMultilinearMap_apply, map_tprod, map_add_smul_aux, LinearMap.smul_apply,
MultilinearMap.map_update_smul]
@[deprecated (since := "2024-11-03")] protected alias map_smul := PiTensorProduct.map_update_smul
variable (R s t)
/-- The tensor of a family of linear maps from `sáµ¢` to `táµ¢`, as a multilinear map of
the family.
-/
@[simps]
noncomputable def mapMultilinear :
MultilinearMap R (fun (i : ι) ⊠s i ââ[R] t i) ((âš[R] i, s i) ââ[R] âš[R] i, t i) where
toFun := map
map_update_smul' _ _ _ _ := PiTensorProduct.map_update_smul _ _ _ _
map_update_add' _ _ _ _ := PiTensorProduct.map_update_add _ _ _ _
variable {R s t}
/--
Let `sáµ¢` and `táµ¢` be families of `R`-modules.
Then there is an `R`-linear map between `âšáµ¢ Hom(sáµ¢, táµ¢)` and `Hom(âšáµ¢ sáµ¢, âš táµ¢)` defined by
`âšáµ¢ fáµ¢ ⊠âšáµ¢ aáµ¢ ⊠âšáµ¢ fáµ¢ aáµ¢`.
This is `TensorProduct.homTensorHomMap` for an arbitrary family of modules.
Note that `PiTensorProduct.piTensorHomMap (tprod R f)` is equal to `PiTensorProduct.map f`.
-/
def piTensorHomMap : (âš[R] i, s i ââ[R] t i) ââ[R] (âš[R] i, s i) ââ[R] âš[R] i, t i :=
lift.toLinearMap ââ lift (MultilinearMap.piLinearMap <| tprod R)
@[simp] lemma piTensorHomMap_tprod_tprod (f : Î i, s i ââ[R] t i) (x : Î i, s i) :
piTensorHomMap (tprod R f) (tprod R x) = tprod R fun i ⊠f i (x i) := by
simp [piTensorHomMap]
lemma piTensorHomMap_tprod_eq_map (f : Î i, s i ââ[R] t i) :
piTensorHomMap (tprod R f) = map f := by
ext; simp
/-- If `s i` and `t i` are linearly equivalent for every `i` in `ι`, then `âš[R] i, s i` and
`âš[R] i, t i` are linearly equivalent.
This is the n-ary version of `TensorProduct.congr`
-/
noncomputable def congr (f : Î i, s i ââ[R] t i) :
(âš[R] i, s i) ââ[R] âš[R] i, t i :=
.ofLinear
(map (fun i ⊠f i))
(map (fun i ⊠(f i).symm))
(by ext; simp)
(by ext; simp)
@[simp]
theorem congr_tprod (f : Î i, s i ââ[R] t i) (m : Î i, s i) :
congr f (tprod R m) = tprod R (fun (i : ι) ⊠(f i) (m i)) := by
simp only [congr, LinearEquiv.ofLinear_apply, map_tprod, LinearEquiv.coe_coe]
@[simp]
theorem congr_symm_tprod (f : Î i, s i ââ[R] t i) (p : Î i, t i) :
(congr f).symm (tprod R p) = tprod R (fun (i : ι) ⊠(f i).symm (p i)) := by
simp only [congr, LinearEquiv.ofLinear_symm_apply, map_tprod, LinearEquiv.coe_coe]
/--
Let `sáµ¢`, `táµ¢` and `t'áµ¢` be families of `R`-modules, then `f : Î áµ¢ sáµ¢ â táµ¢ â t'áµ¢` induces an
| element of `Hom(âšáµ¢ sáµ¢, Hom(âš táµ¢, âšáµ¢ t'áµ¢))` defined by `âšáµ¢ aáµ¢ ⊠âšáµ¢ báµ¢ ⊠âšáµ¢ fáµ¢ aáµ¢ báµ¢`.
This is `PiTensorProduct.map` for two arbitrary families of modules.
| Mathlib/LinearAlgebra/PiTensorProduct.lean | 629 | 631 |
/-
Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Topology.MetricSpace.HausdorffDistance
/-!
# Topological study of spaces `Î (n : â), E n`
When `E n` are topological spaces, the space `Î (n : â), E n` is naturally a topological space
(with the product topology). When `E n` are uniform spaces, it also inherits a uniform structure.
However, it does not inherit a canonical metric space structure of the `E n`. Nevertheless, one
can put a noncanonical metric space structure (or rather, several of them). This is done in this
file.
## Main definitions and results
One can define a combinatorial distance on `Î (n : â), E n`, as follows:
* `PiNat.cylinder x n` is the set of points `y` with `x i = y i` for `i < n`.
* `PiNat.firstDiff x y` is the first index at which `x i â y i`.
* `PiNat.dist x y` is equal to `(1/2) ^ (firstDiff x y)`. It defines a distance
on `Î (n : â), E n`, compatible with the topology when the `E n` have the discrete topology.
* `PiNat.metricSpace`: the metric space structure, given by this distance. Not registered as an
instance. This space is a complete metric space.
* `PiNat.metricSpaceOfDiscreteUniformity`: the same metric space structure, but adjusting the
uniformity defeqness when the `E n` already have the discrete uniformity. Not registered as an
instance
* `PiNat.metricSpaceNatNat`: the particular case of `â â â`, not registered as an instance.
These results are used to construct continuous functions on `Î n, E n`:
* `PiNat.exists_retraction_of_isClosed`: given a nonempty closed subset `s` of `Î (n : â), E n`,
there exists a retraction onto `s`, i.e., a continuous map from the whole space to `s`
restricting to the identity on `s`.
* `exists_nat_nat_continuous_surjective_of_completeSpace`: given any nonempty complete metric
space with second-countable topology, there exists a continuous surjection from `â â â` onto
this space.
One can also put distances on `Π(i : ι), E i` when the spaces `E i` are metric spaces (not discrete
in general), and `ι` is countable.
* `PiCountable.dist` is the distance on `Î i, E i` given by
`dist x y = â' i, min (1/2)^(encode i) (dist (x i) (y i))`.
* `PiCountable.metricSpace` is the corresponding metric space structure, adjusted so that
the uniformity is definitionally the product uniformity. Not registered as an instance.
-/
noncomputable section
open Topology TopologicalSpace Set Metric Filter Function
attribute [local simp] pow_le_pow_iff_rightâ one_lt_two inv_le_invâ zero_le_two zero_lt_two
variable {E : â â Type*}
namespace PiNat
/-! ### The firstDiff function -/
open Classical in
/-- In a product space `Î n, E n`, then `firstDiff x y` is the first index at which `x` and `y`
differ. If `x = y`, then by convention we set `firstDiff x x = 0`. -/
irreducible_def firstDiff (x y : â n, E n) : â :=
if h : x â y then Nat.find (ne_iff.1 h) else 0
theorem apply_firstDiff_ne {x y : â n, E n} (h : x â y) :
x (firstDiff x y) â y (firstDiff x y) := by
rw [firstDiff_def, dif_pos h]
classical
exact Nat.find_spec (ne_iff.1 h)
theorem apply_eq_of_lt_firstDiff {x y : â n, E n} {n : â} (hn : n < firstDiff x y) : x n = y n := by
rw [firstDiff_def] at hn
split_ifs at hn with h
· convert Nat.find_min (ne_iff.1 h) hn
simp
· exact (not_lt_zero' hn).elim
theorem firstDiff_comm (x y : â n, E n) : firstDiff x y = firstDiff y x := by
classical
simp only [firstDiff_def, ne_comm]
theorem min_firstDiff_le (x y z : â n, E n) (h : x â z) :
min (firstDiff x y) (firstDiff y z) †firstDiff x z := by
by_contra! H
rw [lt_min_iff] at H
refine apply_firstDiff_ne h ?_
calc
x (firstDiff x z) = y (firstDiff x z) := apply_eq_of_lt_firstDiff H.1
_ = z (firstDiff x z) := apply_eq_of_lt_firstDiff H.2
/-! ### Cylinders -/
/-- In a product space `Î n, E n`, the cylinder set of length `n` around `x`, denoted
`cylinder x n`, is the set of sequences `y` that coincide with `x` on the first `n` symbols, i.e.,
such that `y i = x i` for all `i < n`.
-/
def cylinder (x : â n, E n) (n : â) : Set (â n, E n) :=
{ y | â i, i < n â y i = x i }
theorem cylinder_eq_pi (x : â n, E n) (n : â) :
cylinder x n = Set.pi (Finset.range n : Set â) fun i : â => {x i} := by
ext y
simp [cylinder]
@[simp]
theorem cylinder_zero (x : â n, E n) : cylinder x 0 = univ := by simp [cylinder_eq_pi]
theorem cylinder_anti (x : â n, E n) {m n : â} (h : m †n) : cylinder x n â cylinder x m :=
fun _y hy i hi => hy i (hi.trans_le h)
@[simp]
theorem mem_cylinder_iff {x y : â n, E n} {n : â} : y â cylinder x n â â i < n, y i = x i :=
Iff.rfl
theorem self_mem_cylinder (x : â n, E n) (n : â) : x â cylinder x n := by simp
theorem mem_cylinder_iff_eq {x y : â n, E n} {n : â} :
y â cylinder x n â cylinder y n = cylinder x n := by
constructor
· intro hy
apply Subset.antisymm
· intro z hz i hi
rw [â hy i hi]
exact hz i hi
· intro z hz i hi
rw [hy i hi]
exact hz i hi
· intro h
rw [â h]
exact self_mem_cylinder _ _
theorem mem_cylinder_comm (x y : â n, E n) (n : â) : y â cylinder x n â x â cylinder y n := by
simp [mem_cylinder_iff_eq, eq_comm]
theorem mem_cylinder_iff_le_firstDiff {x y : â n, E n} (hne : x â y) (i : â) :
x â cylinder y i â i †firstDiff x y := by
constructor
· intro h
by_contra!
exact apply_firstDiff_ne hne (h _ this)
· intro hi j hj
exact apply_eq_of_lt_firstDiff (hj.trans_le hi)
theorem mem_cylinder_firstDiff (x y : â n, E n) : x â cylinder y (firstDiff x y) := fun _i hi =>
apply_eq_of_lt_firstDiff hi
theorem cylinder_eq_cylinder_of_le_firstDiff (x y : â n, E n) {n : â} (hn : n †firstDiff x y) :
cylinder x n = cylinder y n := by
rw [â mem_cylinder_iff_eq]
intro i hi
exact apply_eq_of_lt_firstDiff (hi.trans_le hn)
theorem iUnion_cylinder_update (x : â n, E n) (n : â) :
â k, cylinder (update x n k) (n + 1) = cylinder x n := by
ext y
simp only [mem_cylinder_iff, mem_iUnion]
constructor
· rintro âšk, hkâ© i hi
simpa [hi.ne] using hk i (Nat.lt_succ_of_lt hi)
· intro H
refine âšy n, fun i hi => ?_â©
rcases Nat.lt_succ_iff_lt_or_eq.1 hi with (h'i | rfl)
· simp [H i h'i, h'i.ne]
· simp
theorem update_mem_cylinder (x : â n, E n) (n : â) (y : E n) : update x n y â cylinder x n :=
mem_cylinder_iff.2 fun i hi => by simp [hi.ne]
section Res
variable {α : Type*}
open List
/-- In the case where `E` has constant value `α`,
the cylinder `cylinder x n` can be identified with the element of `List α`
consisting of the first `n` entries of `x`. See `cylinder_eq_res`.
We call this list `res x n`, the restriction of `x` to `n`. -/
def res (x : â â α) : â â List α
| 0 => nil
| Nat.succ n => x n :: res x n
@[simp]
theorem res_zero (x : â â α) : res x 0 = @nil α :=
rfl
@[simp]
theorem res_succ (x : â â α) (n : â) : res x n.succ = x n :: res x n :=
rfl
@[simp]
theorem res_length (x : â â α) (n : â) : (res x n).length = n := by induction n <;> simp [*]
/-- The restrictions of `x` and `y` to `n` are equal if and only if `x m = y m` for all `m < n`. -/
theorem res_eq_res {x y : â â α} {n : â} :
res x n = res y n â â âŠmâŠ, m < n â x m = y m := by
constructor <;> intro h
· induction n with
| zero => simp
| succ n ih =>
intro m hm
rw [Nat.lt_succ_iff_lt_or_eq] at hm
simp only [res_succ, cons.injEq] at h
rcases hm with hm | hm
· exact ih h.2 hm
rw [hm]
exact h.1
· induction n with
| zero => simp
| succ n ih =>
simp only [res_succ, cons.injEq]
refine âšh (Nat.lt_succ_self _), ih fun m hm => ?_â©
exact h (hm.trans (Nat.lt_succ_self _))
theorem res_injective : Injective (@res α) := by
intro x y h
ext n
apply res_eq_res.mp _ (Nat.lt_succ_self _)
rw [h]
/-- `cylinder x n` is equal to the set of sequences `y` with the same restriction to `n` as `x`. -/
theorem cylinder_eq_res (x : â â α) (n : â) :
cylinder x n = { y | res y n = res x n } := by
ext y
dsimp [cylinder]
rw [res_eq_res]
end Res
/-!
### A distance function on `Î n, E n`
We define a distance function on `Î n, E n`, given by `dist x y = (1/2)^n` where `n` is the first
index at which `x` and `y` differ. When each `E n` has the discrete topology, this distance will
define the right topology on the product space. We do not record a global `Dist` instance nor
a `MetricSpace` instance, as other distances may be used on these spaces, but we register them as
local instances in this section.
-/
open Classical in
/-- The distance function on a product space `Î n, E n`, given by `dist x y = (1/2)^n` where `n` is
the first index at which `x` and `y` differ. -/
protected def dist : Dist (â n, E n) :=
âšfun x y => if x â y then (1 / 2 : â) ^ firstDiff x y else 0â©
attribute [local instance] PiNat.dist
theorem dist_eq_of_ne {x y : â n, E n} (h : x â y) : dist x y = (1 / 2 : â) ^ firstDiff x y := by
simp [dist, h]
protected theorem dist_self (x : â n, E n) : dist x x = 0 := by simp [dist]
protected theorem dist_comm (x y : â n, E n) : dist x y = dist y x := by
classical
simp [dist, @eq_comm _ x y, firstDiff_comm]
protected theorem dist_nonneg (x y : â n, E n) : 0 †dist x y := by
rcases eq_or_ne x y with (rfl | h)
· simp [dist]
· simp [dist, h, zero_le_two]
theorem dist_triangle_nonarch (x y z : â n, E n) : dist x z †max (dist x y) (dist y z) := by
rcases eq_or_ne x z with (rfl | hxz)
· simp [PiNat.dist_self x, PiNat.dist_nonneg]
rcases eq_or_ne x y with (rfl | hxy)
· simp
rcases eq_or_ne y z with (rfl | hyz)
· simp
simp only [dist_eq_of_ne, hxz, hxy, hyz, inv_le_invâ, one_div, inv_pow, zero_lt_two, Ne,
not_false_iff, le_max_iff, pow_le_pow_iff_rightâ, one_lt_two, pow_pos,
min_le_iff.1 (min_firstDiff_le x y z hxz)]
protected theorem dist_triangle (x y z : â n, E n) : dist x z †dist x y + dist y z :=
calc
dist x z †max (dist x y) (dist y z) := dist_triangle_nonarch x y z
_ †dist x y + dist y z := max_le_add_of_nonneg (PiNat.dist_nonneg _ _) (PiNat.dist_nonneg _ _)
protected theorem eq_of_dist_eq_zero (x y : â n, E n) (hxy : dist x y = 0) : x = y := by
rcases eq_or_ne x y with (rfl | h); · rfl
simp [dist_eq_of_ne h] at hxy
theorem mem_cylinder_iff_dist_le {x y : â n, E n} {n : â} :
y â cylinder x n â dist y x †(1 / 2) ^ n := by
rcases eq_or_ne y x with (rfl | hne)
· simp [PiNat.dist_self]
suffices (â i : â, i < n â y i = x i) â n †firstDiff y x by simpa [dist_eq_of_ne hne]
constructor
· intro hy
by_contra! H
exact apply_firstDiff_ne hne (hy _ H)
· intro h i hi
exact apply_eq_of_lt_firstDiff (hi.trans_le h)
theorem apply_eq_of_dist_lt {x y : â n, E n} {n : â} (h : dist x y < (1 / 2) ^ n) {i : â}
(hi : i †n) : x i = y i := by
rcases eq_or_ne x y with (rfl | hne)
· rfl
have : n < firstDiff x y := by
simpa [dist_eq_of_ne hne, inv_lt_invâ, pow_lt_pow_iff_rightâ, one_lt_two] using h
exact apply_eq_of_lt_firstDiff (hi.trans_lt this)
/-- A function to a pseudo-metric-space is `1`-Lipschitz if and only if points in the same cylinder
of length `n` are sent to points within distance `(1/2)^n`.
Not expressed using `LipschitzWith` as we don't have a metric space structure -/
theorem lipschitz_with_one_iff_forall_dist_image_le_of_mem_cylinder {α : Type*}
[PseudoMetricSpace α] {f : (â n, E n) â α} :
(â x y : â n, E n, dist (f x) (f y) †dist x y) â
â x y n, y â cylinder x n â dist (f x) (f y) †(1 / 2) ^ n := by
constructor
· intro H x y n hxy
apply (H x y).trans
rw [PiNat.dist_comm]
exact mem_cylinder_iff_dist_le.1 hxy
· intro H x y
rcases eq_or_ne x y with (rfl | hne)
· simp [PiNat.dist_nonneg]
rw [dist_eq_of_ne hne]
apply H x y (firstDiff x y)
rw [firstDiff_comm]
exact mem_cylinder_firstDiff _ _
variable (E)
variable [â n, TopologicalSpace (E n)] [â n, DiscreteTopology (E n)]
theorem isOpen_cylinder (x : â n, E n) (n : â) : IsOpen (cylinder x n) := by
rw [PiNat.cylinder_eq_pi]
exact isOpen_set_pi (Finset.range n).finite_toSet fun a _ => isOpen_discrete _
theorem isTopologicalBasis_cylinders :
IsTopologicalBasis { s : Set (â n, E n) | â (x : â n, E n) (n : â), s = cylinder x n } := by
apply isTopologicalBasis_of_isOpen_of_nhds
· rintro u âšx, n, rflâ©
apply isOpen_cylinder
· intro x u hx u_open
obtain âšv, âšU, F, -, rflâ©, xU, Uuâ© :
â v â { S : Set (â i : â, E i) | â (U : â i : â, Set (E i)) (F : Finset â),
(â i : â, i â F â U i â { s : Set (E i) | IsOpen s }) â§ S = (F : Set â).pi U },
x â v â§ v â u :=
(isTopologicalBasis_pi fun n : â => isTopologicalBasis_opens).exists_subset_of_mem_open hx
u_open
rcases Finset.bddAbove F with âšn, hnâ©
refine âšcylinder x (n + 1), âšx, n + 1, rflâ©, self_mem_cylinder _ _, Subset.trans ?_ Uuâ©
intro y hy
suffices â i : â, i â F â y i â U i by simpa
intro i hi
have : y i = x i := mem_cylinder_iff.1 hy i ((hn hi).trans_lt (lt_add_one n))
rw [this]
simp only [Set.mem_pi, Finset.mem_coe] at xU
exact xU i hi
variable {E}
theorem isOpen_iff_dist (s : Set (â n, E n)) :
IsOpen s â â x â s, â ε > 0, â y, dist x y < ε â y â s := by
constructor
· intro hs x hx
obtain âšv, âšy, n, rflâ©, h'x, h'sâ© :
â v â { s | â (x : â n : â, E n) (n : â), s = cylinder x n }, x â v â§ v â s :=
(isTopologicalBasis_cylinders E).exists_subset_of_mem_open hx hs
rw [â mem_cylinder_iff_eq.1 h'x] at h's
exact
âš(1 / 2 : â) ^ n, by simp, fun y hy => h's fun i hi => (apply_eq_of_dist_lt hy hi.le).symmâ©
· intro h
refine (isTopologicalBasis_cylinders E).isOpen_iff.2 fun x hx => ?_
rcases h x hx with âšÎµ, εpos, hεâ©
obtain âšn, hnâ© : â n : â, (1 / 2 : â) ^ n < ε := exists_pow_lt_of_lt_one εpos one_half_lt_one
refine âšcylinder x n, âšx, n, rflâ©, self_mem_cylinder x n, fun y hy => hε y ?_â©
rw [PiNat.dist_comm]
exact (mem_cylinder_iff_dist_le.1 hy).trans_lt hn
/-- Metric space structure on `Î (n : â), E n` when the spaces `E n` have the discrete topology,
where the distance is given by `dist x y = (1/2)^n`, where `n` is the smallest index where `x` and
`y` differ. Not registered as a global instance by default.
Warning: this definition makes sure that the topology is defeq to the original product topology,
but it does not take care of a possible uniformity. If the `E n` have a uniform structure, then
there will be two non-defeq uniform structures on `Î n, E n`, the product one and the one coming
from the metric structure. In this case, use `metricSpaceOfDiscreteUniformity` instead. -/
protected def metricSpace : MetricSpace (â n, E n) :=
MetricSpace.ofDistTopology dist PiNat.dist_self PiNat.dist_comm PiNat.dist_triangle
isOpen_iff_dist PiNat.eq_of_dist_eq_zero
/-- Metric space structure on `Î (n : â), E n` when the spaces `E n` have the discrete uniformity,
where the distance is given by `dist x y = (1/2)^n`, where `n` is the smallest index where `x` and
`y` differ. Not registered as a global instance by default. -/
protected def metricSpaceOfDiscreteUniformity {E : â â Type*} [â n, UniformSpace (E n)]
(h : â n, uniformity (E n) = ð idRel) : MetricSpace (â n, E n) :=
haveI : â n, DiscreteTopology (E n) := fun n => discreteTopology_of_discrete_uniformity (h n)
{ dist_triangle := PiNat.dist_triangle
dist_comm := PiNat.dist_comm
dist_self := PiNat.dist_self
eq_of_dist_eq_zero := PiNat.eq_of_dist_eq_zero _ _
toUniformSpace := Pi.uniformSpace _
uniformity_dist := by
simp only [Pi.uniformity, h, idRel, comap_principal, preimage_setOf_eq]
apply le_antisymm
· simp only [le_iInf_iff, le_principal_iff]
intro ε εpos
obtain âšn, hnâ© : â n, (1 / 2 : â) ^ n < ε := exists_pow_lt_of_lt_one εpos (by norm_num)
apply
@mem_iInf_of_iInter _ _ _ _ _ (Finset.range n).finite_toSet fun i =>
{ p : (â n : â, E n) Ã â n : â, E n | p.fst i = p.snd i }
· simp only [mem_principal, setOf_subset_setOf, imp_self, imp_true_iff]
· rintro âšx, yâ© hxy
simp only [Finset.mem_coe, Finset.mem_range, iInter_coe_set, mem_iInter, mem_setOf_eq]
at hxy
apply lt_of_le_of_lt _ hn
rw [â mem_cylinder_iff_dist_le, mem_cylinder_iff]
exact hxy
· simp only [le_iInf_iff, le_principal_iff]
intro n
refine mem_iInf_of_mem ((1 / 2) ^ n : â) ?_
refine mem_iInf_of_mem (by positivity) ?_
simp only [mem_principal, setOf_subset_setOf, Prod.forall]
intro x y hxy
exact apply_eq_of_dist_lt hxy le_rfl }
/-- Metric space structure on `â â â` where the distance is given by `dist x y = (1/2)^n`,
where `n` is the smallest index where `x` and `y` differ.
Not registered as a global instance by default. -/
def metricSpaceNatNat : MetricSpace (â â â) :=
PiNat.metricSpaceOfDiscreteUniformity fun _ => rfl
attribute [local instance] PiNat.metricSpace
protected theorem completeSpace : CompleteSpace (â n, E n) := by
refine Metric.complete_of_convergent_controlled_sequences (fun n => (1 / 2) ^ n) (by simp) ?_
intro u hu
refine âšfun n => u n n, tendsto_pi_nhds.2 fun i => ?_â©
refine tendsto_const_nhds.congr' ?_
filter_upwards [Filter.Ici_mem_atTop i] with n hn
exact apply_eq_of_dist_lt (hu i i n le_rfl hn) le_rfl
/-!
### Retractions inside product spaces
We show that, in a space `Î (n : â), E n` where each `E n` is discrete, there is a retraction on
any closed nonempty subset `s`, i.e., a continuous map `f` from the whole space to `s` restricting
to the identity on `s`. The map `f` is defined as follows. For `x â s`, let `f x = x`. Otherwise,
consider the longest prefix `w` that `x` shares with an element of `s`, and let `f x = z_w`
where `z_w` is an element of `s` starting with `w`.
-/
theorem exists_disjoint_cylinder {s : Set (â n, E n)} (hs : IsClosed s) {x : â n, E n}
(hx : x â s) : â n, Disjoint s (cylinder x n) := by
rcases eq_empty_or_nonempty s with (rfl | hne)
· exact âš0, by simpâ©
have A : 0 < infDist x s := (hs.not_mem_iff_infDist_pos hne).1 hx
obtain âšn, hnâ© : â n, (1 / 2 : â) ^ n < infDist x s := exists_pow_lt_of_lt_one A one_half_lt_one
refine âšn, disjoint_left.2 fun y ys hy => ?_â©
apply lt_irrefl (infDist x s)
calc
infDist x s †dist x y := infDist_le_dist_of_mem ys
_ †(1 / 2) ^ n := by
rw [mem_cylinder_comm] at hy
exact mem_cylinder_iff_dist_le.1 hy
_ < infDist x s := hn
open Classical in
/-- Given a point `x` in a product space `Î (n : â), E n`, and `s` a subset of this space, then
`shortestPrefixDiff x s` if the smallest `n` for which there is no element of `s` having the same
prefix of length `n` as `x`. If there is no such `n`, then use `0` by convention. -/
def shortestPrefixDiff {E : â â Type*} (x : â n, E n) (s : Set (â n, E n)) : â :=
if h : â n, Disjoint s (cylinder x n) then Nat.find h else 0
theorem firstDiff_lt_shortestPrefixDiff {s : Set (â n, E n)} (hs : IsClosed s) {x y : â n, E n}
(hx : x â s) (hy : y â s) : firstDiff x y < shortestPrefixDiff x s := by
have A := exists_disjoint_cylinder hs hx
rw [shortestPrefixDiff, dif_pos A]
classical
have B := Nat.find_spec A
contrapose! B
rw [not_disjoint_iff_nonempty_inter]
refine âšy, hy, ?_â©
rw [mem_cylinder_comm]
exact cylinder_anti y B (mem_cylinder_firstDiff x y)
theorem shortestPrefixDiff_pos {s : Set (â n, E n)} (hs : IsClosed s) (hne : s.Nonempty)
{x : â n, E n} (hx : x â s) : 0 < shortestPrefixDiff x s := by
rcases hne with âšy, hyâ©
exact (zero_le _).trans_lt (firstDiff_lt_shortestPrefixDiff hs hx hy)
/-- Given a point `x` in a product space `Î (n : â), E n`, and `s` a subset of this space, then
`longestPrefix x s` if the largest `n` for which there is an element of `s` having the same
prefix of length `n` as `x`. If there is no such `n`, use `0` by convention. -/
def longestPrefix {E : â â Type*} (x : â n, E n) (s : Set (â n, E n)) : â :=
shortestPrefixDiff x s - 1
theorem firstDiff_le_longestPrefix {s : Set (â n, E n)} (hs : IsClosed s) {x y : â n, E n}
(hx : x â s) (hy : y â s) : firstDiff x y †longestPrefix x s := by
rw [longestPrefix, le_tsub_iff_right]
· exact firstDiff_lt_shortestPrefixDiff hs hx hy
· exact shortestPrefixDiff_pos hs âšy, hyâ© hx
theorem inter_cylinder_longestPrefix_nonempty {s : Set (â n, E n)} (hs : IsClosed s)
(hne : s.Nonempty) (x : â n, E n) : (s â© cylinder x (longestPrefix x s)).Nonempty := by
by_cases hx : x â s
· exact âšx, hx, self_mem_cylinder _ _â©
have A := exists_disjoint_cylinder hs hx
have B : longestPrefix x s < shortestPrefixDiff x s :=
Nat.pred_lt (shortestPrefixDiff_pos hs hne hx).ne'
rw [longestPrefix, shortestPrefixDiff, dif_pos A] at B â¢
classical
obtain âšy, ys, hyâ© : â y : â n : â, E n, y â s â§ x â cylinder y (Nat.find A - 1) := by
simpa only [not_disjoint_iff, mem_cylinder_comm] using Nat.find_min A B
refine âšy, ys, ?_â©
rw [mem_cylinder_iff_eq] at hy â¢
rw [hy]
theorem disjoint_cylinder_of_longestPrefix_lt {s : Set (â n, E n)} (hs : IsClosed s) {x : â n, E n}
(hx : x â s) {n : â} (hn : longestPrefix x s < n) : Disjoint s (cylinder x n) := by
contrapose! hn
rcases not_disjoint_iff_nonempty_inter.1 hn with âšy, ys, hyâ©
apply le_trans _ (firstDiff_le_longestPrefix hs hx ys)
apply (mem_cylinder_iff_le_firstDiff (ne_of_mem_of_not_mem ys hx).symm _).1
rwa [mem_cylinder_comm]
/-- If two points `x, y` coincide up to length `n`, and the longest common prefix of `x` with `s`
is strictly shorter than `n`, then the longest common prefix of `y` with `s` is the same, and both
cylinders of this length based at `x` and `y` coincide. -/
theorem cylinder_longestPrefix_eq_of_longestPrefix_lt_firstDiff {x y : â n, E n}
{s : Set (â n, E n)} (hs : IsClosed s) (hne : s.Nonempty)
(H : longestPrefix x s < firstDiff x y) (xs : x â s) (ys : y â s) :
cylinder x (longestPrefix x s) = cylinder y (longestPrefix y s) := by
have l_eq : longestPrefix y s = longestPrefix x s := by
rcases lt_trichotomy (longestPrefix y s) (longestPrefix x s) with (L | L | L)
· have Ax : (s ⩠cylinder x (longestPrefix x s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne x
have Z := disjoint_cylinder_of_longestPrefix_lt hs ys L
rw [firstDiff_comm] at H
rw [cylinder_eq_cylinder_of_le_firstDiff _ _ H.le] at Z
exact (Ax.not_disjoint Z).elim
· exact L
· have Ay : (s ⩠cylinder y (longestPrefix y s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne y
have A'y : (s â© cylinder y (longestPrefix x s).succ).Nonempty :=
Ay.mono (inter_subset_inter_right s (cylinder_anti _ L))
have Z := disjoint_cylinder_of_longestPrefix_lt hs xs (Nat.lt_succ_self _)
rw [cylinder_eq_cylinder_of_le_firstDiff _ _ H] at Z
exact (A'y.not_disjoint Z).elim
rw [l_eq, â mem_cylinder_iff_eq]
exact cylinder_anti y H.le (mem_cylinder_firstDiff x y)
/-- Given a closed nonempty subset `s` of `Î (n : â), E n`, there exists a Lipschitz retraction
onto this set, i.e., a Lipschitz map with range equal to `s`, equal to the identity on `s`. -/
theorem exists_lipschitz_retraction_of_isClosed {s : Set (â n, E n)} (hs : IsClosed s)
(hne : s.Nonempty) :
â f : (â n, E n) â â n, E n, (â x â s, f x = x) â§ range f = s â§ LipschitzWith 1 f := by
/- The map `f` is defined as follows. For `x â s`, let `f x = x`. Otherwise, consider the longest
prefix `w` that `x` shares with an element of `s`, and let `f x = z_w` where `z_w` is an element
of `s` starting with `w`. All the desired properties are clear, except the fact that `f` is
`1`-Lipschitz: if two points `x, y` belong to a common cylinder of length `n`, one should show
that their images also belong to a common cylinder of length `n`. This is a case analysis:
* if both `x, y â s`, then this is clear.
* if `x â s` but `y â s`, then the longest prefix `w` of `y` shared by an element of `s` is of
length at least `n` (because of `x`), and then `f y` starts with `w` and therefore stays in the
same length `n` cylinder.
* if `x â s`, `y â s`, let `w` be the longest prefix of `x` shared by an element of `s`. If its
length is `< n`, then it is also the longest prefix of `y`, and we get `f x = f y = z_w`.
Otherwise, `f x` remains in the same `n`-cylinder as `x`. Similarly for `y`. Finally, `f x` and
`f y` are again in the same `n`-cylinder, as desired. -/
classical
set f := fun x => if x â s then x else (inter_cylinder_longestPrefix_nonempty hs hne x).some
have fs : â x â s, f x = x := fun x xs => by simp [f, xs]
refine âšf, fs, ?_, ?_â©
-- check that the range of `f` is `s`.
· apply Subset.antisymm
· rintro x âšy, rflâ©
by_cases hy : y â s
· rwa [fs y hy]
simpa [f, if_neg hy] using (inter_cylinder_longestPrefix_nonempty hs hne y).choose_spec.1
· intro x hx
rw [â fs x hx]
exact mem_range_self _
-- check that `f` is `1`-Lipschitz, by a case analysis.
· refine LipschitzWith.mk_one fun x y => ?_
-- exclude the trivial cases where `x = y`, or `f x = f y`.
rcases eq_or_ne x y with (rfl | hxy)
· simp
rcases eq_or_ne (f x) (f y) with (h' | hfxfy)
· simp [h', dist_nonneg]
have I2 : cylinder x (firstDiff x y) = cylinder y (firstDiff x y) := by
rw [â mem_cylinder_iff_eq]
apply mem_cylinder_firstDiff
suffices firstDiff x y †firstDiff (f x) (f y) by
simpa [dist_eq_of_ne hxy, dist_eq_of_ne hfxfy]
-- case where `x â s`
by_cases xs : x â s
· rw [fs x xs] at hfxfy â¢
-- case where `y â s`, trivial
by_cases ys : y â s
· rw [fs y ys]
-- case where `y â s`
have A : (s â© cylinder y (longestPrefix y s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne y
have fy : f y = A.some := by simp_rw [f, if_neg ys]
have I : cylinder A.some (firstDiff x y) = cylinder y (firstDiff x y) := by
rw [â mem_cylinder_iff_eq, firstDiff_comm]
apply cylinder_anti y _ A.some_mem.2
exact firstDiff_le_longestPrefix hs ys xs
rwa [â fy, â I2, â mem_cylinder_iff_eq, mem_cylinder_iff_le_firstDiff hfxfy.symm,
firstDiff_comm _ x] at I
-- case where `x â s`
· by_cases ys : y â s
-- case where `y â s` (similar to the above)
· have A : (s ⩠cylinder x (longestPrefix x s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne x
have fx : f x = A.some := by simp_rw [f, if_neg xs]
have I : cylinder A.some (firstDiff x y) = cylinder x (firstDiff x y) := by
rw [â mem_cylinder_iff_eq]
apply cylinder_anti x _ A.some_mem.2
apply firstDiff_le_longestPrefix hs xs ys
rw [fs y ys] at hfxfy â¢
rwa [â fx, I2, â mem_cylinder_iff_eq, mem_cylinder_iff_le_firstDiff hfxfy] at I
-- case where `y â s`
· have Ax : (s ⩠cylinder x (longestPrefix x s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne x
have fx : f x = Ax.some := by simp_rw [f, if_neg xs]
have Ay : (s â© cylinder y (longestPrefix y s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne y
have fy : f y = Ay.some := by simp_rw [f, if_neg ys]
-- case where the common prefix to `x` and `s`, or `y` and `s`, is shorter than the
-- common part to `x` and `y` -- then `f x = f y`.
by_cases H : longestPrefix x s < firstDiff x y âš longestPrefix y s < firstDiff x y
· have : cylinder x (longestPrefix x s) = cylinder y (longestPrefix y s) := by
rcases H with H | H
· exact cylinder_longestPrefix_eq_of_longestPrefix_lt_firstDiff hs hne H xs ys
· symm
rw [firstDiff_comm] at H
exact cylinder_longestPrefix_eq_of_longestPrefix_lt_firstDiff hs hne H ys xs
rw [fx, fy] at hfxfy
apply (hfxfy _).elim
congr
-- case where the common prefix to `x` and `s` is long, as well as the common prefix to
-- `y` and `s`. Then all points remain in the same cylinders.
· push_neg at H
have I1 : cylinder Ax.some (firstDiff x y) = cylinder x (firstDiff x y) := by
rw [â mem_cylinder_iff_eq]
exact cylinder_anti x H.1 Ax.some_mem.2
have I3 : cylinder y (firstDiff x y) = cylinder Ay.some (firstDiff x y) := by
rw [eq_comm, â mem_cylinder_iff_eq]
exact cylinder_anti y H.2 Ay.some_mem.2
have : cylinder Ax.some (firstDiff x y) = cylinder Ay.some (firstDiff x y) := by
rw [I1, I2, I3]
rw [â fx, â fy, â mem_cylinder_iff_eq, mem_cylinder_iff_le_firstDiff hfxfy] at this
exact this
/-- Given a closed nonempty subset `s` of `Î (n : â), E n`, there exists a retraction onto this
set, i.e., a continuous map with range equal to `s`, equal to the identity on `s`. -/
theorem exists_retraction_of_isClosed {s : Set (â n, E n)} (hs : IsClosed s) (hne : s.Nonempty) :
â f : (â n, E n) â â n, E n, (â x â s, f x = x) â§ range f = s â§ Continuous f := by
rcases exists_lipschitz_retraction_of_isClosed hs hne with âšf, fs, frange, hfâ©
exact âšf, fs, frange, hf.continuousâ©
theorem exists_retraction_subtype_of_isClosed {s : Set (â n, E n)} (hs : IsClosed s)
(hne : s.Nonempty) :
â f : (â n, E n) â s, (â x : s, f x = x) â§ Surjective f â§ Continuous f := by
obtain âšf, fs, rfl, f_contâ© :
â f : (â n, E n) â â n, E n, (â x â s, f x = x) â§ range f = s â§ Continuous f :=
exists_retraction_of_isClosed hs hne
have A : â x : range f, rangeFactorization f x = x := fun x ⊠Subtype.eq <| fs x x.2
exact âšrangeFactorization f, A, fun x => âšx, A xâ©, f_cont.subtype_mk _â©
end PiNat
open PiNat
/-- Any nonempty complete second countable metric space is the continuous image of the
fundamental space `â â â`. For a version of this theorem in the context of Polish spaces, see
`exists_nat_nat_continuous_surjective_of_polishSpace`. -/
theorem exists_nat_nat_continuous_surjective_of_completeSpace (α : Type*) [MetricSpace α]
[CompleteSpace α] [SecondCountableTopology α] [Nonempty α] :
â f : (â â â) â α, Continuous f â§ Surjective f := by
/- First, we define a surjective map from a closed subset `s` of `â â â`. Then, we compose
this map with a retraction of `â â â` onto `s` to obtain the desired map.
Let us consider a dense sequence `u` in `α`. Then `s` is the set of sequences `xâ` such that the
balls `closedBall (u xâ) (1/2^n)` have a nonempty intersection. This set is closed,
and we define `f x` there to be the unique point in the intersection.
This function is continuous and surjective by design. -/
letI : MetricSpace (â â â) := PiNat.metricSpaceNatNat
have I0 : (0 : â) < 1 / 2 := by norm_num
have I1 : (1 / 2 : â) < 1 := by norm_num
rcases exists_dense_seq α with âšu, huâ©
let s : Set (â â â) := { x | (â n : â, closedBall (u (x n)) ((1 / 2) ^ n)).Nonempty }
let g : s â α := fun x => x.2.some
have A : â (x : s) (n : â), dist (g x) (u ((x : â â â) n)) †(1 / 2) ^ n := fun x n =>
(mem_iInter.1 x.2.some_mem n :)
have g_cont : Continuous g := by
refine continuous_iff_continuousAt.2 fun y => ?_
refine continuousAt_of_locally_lipschitz zero_lt_one 4 fun x hxy => ?_
rcases eq_or_ne x y with (rfl | hne)
· simp
have hne' : x.1 â y.1 := Subtype.coe_injective.ne hne
have dist' : dist x y = dist x.1 y.1 := rfl
let n := firstDiff x.1 y.1 - 1
have diff_pos : 0 < firstDiff x.1 y.1 := by
by_contra! h
apply apply_firstDiff_ne hne'
rw [Nat.le_zero.1 h]
apply apply_eq_of_dist_lt _ le_rfl
rw [pow_zero]
exact hxy
have hn : firstDiff x.1 y.1 = n + 1 := (Nat.succ_pred_eq_of_pos diff_pos).symm
rw [dist', dist_eq_of_ne hne', hn]
have B : x.1 n = y.1 n := mem_cylinder_firstDiff x.1 y.1 n (Nat.pred_lt diff_pos.ne')
calc
dist (g x) (g y) †dist (g x) (u (x.1 n)) + dist (g y) (u (x.1 n)) :=
dist_triangle_right _ _ _
_ = dist (g x) (u (x.1 n)) + dist (g y) (u (y.1 n)) := by rw [â B]
_ †(1 / 2) ^ n + (1 / 2) ^ n := add_le_add (A x n) (A y n)
_ = 4 * (1 / 2) ^ (n + 1) := by ring
have g_surj : Surjective g := fun y ⊠by
have : â n : â, â j, y â closedBall (u j) ((1 / 2) ^ n) := fun n ⊠by
rcases hu.exists_dist_lt y (by simp : (0 : â) < (1 / 2) ^ n) with âšj, hjâ©
exact âšj, hj.leâ©
choose x hx using this
have I : (â n : â, closedBall (u (x n)) ((1 / 2) ^ n)).Nonempty := âšy, mem_iInter.2 hxâ©
refine âšâšx, Iâ©, ?_â©
refine dist_le_zero.1 ?_
have J : â n : â, dist (g âšx, Iâ©) y †(1 / 2) ^ n + (1 / 2) ^ n := fun n =>
calc
dist (g âšx, Iâ©) y †dist (g âšx, Iâ©) (u (x n)) + dist y (u (x n)) :=
dist_triangle_right _ _ _
_ †(1 / 2) ^ n + (1 / 2) ^ n := add_le_add (A âšx, Iâ© n) (hx n)
have L : Tendsto (fun n : â => (1 / 2 : â) ^ n + (1 / 2) ^ n) atTop (ð (0 + 0)) :=
(tendsto_pow_atTop_nhds_zero_of_lt_one I0.le I1).add
(tendsto_pow_atTop_nhds_zero_of_lt_one I0.le I1)
rw [add_zero] at L
exact ge_of_tendsto' L J
have s_closed : IsClosed s := by
refine isClosed_iff_clusterPt.mpr fun x hx ⊠?_
have L : Tendsto (fun n : â => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (ð 0) := by
have : Tendsto (fun n : â => (2 : â) * (1 / 2) ^ n) atTop (ð (2 * 0)) :=
(tendsto_pow_atTop_nhds_zero_of_lt_one I0.le I1).const_mul _
rw [mul_zero] at this
exact
squeeze_zero (fun n => diam_nonneg) (fun n => diam_closedBall (pow_nonneg I0.le _)) this
refine nonempty_iInter_of_nonempty_biInter (fun n => isClosed_closedBall)
(fun n => isBounded_closedBall) (fun N ⊠?_) L
obtain âšy, hxy, ysâ© : â y, y â ball x ((1 / 2) ^ N) â© s :=
clusterPt_principal_iff.1 hx _ (ball_mem_nhds x (pow_pos I0 N))
have E :
â (n : â) (H : n †N), closedBall (u (x n)) ((1 / 2) ^ n) =
â (n : â) (H : n †N), closedBall (u (y n)) ((1 / 2) ^ n) := by
refine iInter_congr fun n ⊠iInter_congr fun hn ⊠?_
have : x n = y n := apply_eq_of_dist_lt (mem_ball'.1 hxy) hn
rw [this]
rw [E]
apply Nonempty.mono _ ys
apply iInter_subset_iInterâ
obtain âšf, -, f_surj, f_contâ© :
â f : (â â â) â s, (â x : s, f x = x) â§ Surjective f â§ Continuous f := by
apply exists_retraction_subtype_of_isClosed s_closed
simpa only [nonempty_coe_sort] using g_surj.nonempty
exact âšg â f, g_cont.comp f_cont, g_surj.comp f_surjâ©
namespace PiCountable
/-!
### Products of (possibly non-discrete) metric spaces
-/
variable {ι : Type*} [Encodable ι] {F : ι â Type*} [â i, MetricSpace (F i)]
open Encodable
/-- Given a countable family of metric spaces, one may put a distance on their product `Î i, E i`.
It is highly non-canonical, though, and therefore not registered as a global instance.
The distance we use here is `dist x y = â' i, min (1/2)^(encode i) (dist (x i) (y i))`. -/
protected def dist : Dist (â i, F i) :=
âšfun x y => â' i : ι, min ((1 / 2) ^ encode i) (dist (x i) (y i))â©
attribute [local instance] PiCountable.dist
theorem dist_eq_tsum (x y : â i, F i) :
dist x y = â' i : ι, min ((1 / 2) ^ encode i : â) (dist (x i) (y i)) :=
rfl
theorem dist_summable (x y : â i, F i) :
Summable fun i : ι => min ((1 / 2) ^ encode i : â) (dist (x i) (y i)) := by
refine .of_nonneg_of_le (fun i => ?_) (fun i => min_le_left _ _)
summable_geometric_two_encode
exact le_min (pow_nonneg (by norm_num) _) dist_nonneg
theorem min_dist_le_dist_pi (x y : â i, F i) (i : ι) :
min ((1 / 2) ^ encode i : â) (dist (x i) (y i)) †dist x y :=
(dist_summable x y).le_tsum i fun j _ => le_min (by simp) dist_nonneg
theorem dist_le_dist_pi_of_dist_lt {x y : â i, F i} {i : ι} (h : dist x y < (1 / 2) ^ encode i) :
dist (x i) (y i) †dist x y := by
simpa only [not_le.2 h, false_or] using min_le_iff.1 (min_dist_le_dist_pi x y i)
open Topology Filter NNReal
variable (E)
/-- Given a countable family of metric spaces, one may put a distance on their product `Î i, E i`,
defining the right topology and uniform structure. It is highly non-canonical, though, and therefore
not registered as a global instance.
The distance we use here is `dist x y = â' n, min (1/2)^(encode i) (dist (x n) (y n))`. -/
protected def metricSpace : MetricSpace (â i, F i) where
dist_self x := by simp [dist_eq_tsum]
dist_comm x y := by simp [dist_eq_tsum, dist_comm]
dist_triangle x y z :=
have I : â i, min ((1 / 2) ^ encode i : â) (dist (x i) (z i)) â€
min ((1 / 2) ^ encode i : â) (dist (x i) (y i)) +
min ((1 / 2) ^ encode i : â) (dist (y i) (z i)) := fun i =>
calc
min ((1 / 2) ^ encode i : â) (dist (x i) (z i)) â€
min ((1 / 2) ^ encode i : â) (dist (x i) (y i) + dist (y i) (z i)) :=
min_le_min le_rfl (dist_triangle _ _ _)
_ = min ((1 / 2) ^ encode i : â) (min ((1 / 2) ^ encode i : â) (dist (x i) (y i)) +
min ((1 / 2) ^ encode i : â) (dist (y i) (z i))) := by
convert congr_arg ((â) : ââ¥0 â â)
(min_add_distrib ((1 / 2 : ââ¥0) ^ encode i) (nndist (x i) (y i))
(nndist (y i) (z i)))
_ †min ((1 / 2) ^ encode i : â) (dist (x i) (y i)) +
min ((1 / 2) ^ encode i : â) (dist (y i) (z i)) :=
min_le_right _ _
calc dist x z †â' i, (min ((1 / 2) ^ encode i : â) (dist (x i) (y i)) +
min ((1 / 2) ^ encode i : â) (dist (y i) (z i))) :=
(dist_summable x z).tsum_le_tsum I ((dist_summable x y).add (dist_summable y z))
_ = dist x y + dist y z := (dist_summable x y).tsum_add (dist_summable y z)
eq_of_dist_eq_zero hxy := by
ext1 n
rw [â dist_le_zero, â hxy]
apply dist_le_dist_pi_of_dist_lt
rw [hxy]
simp
toUniformSpace := Pi.uniformSpace _
uniformity_dist := by
simp only [Pi.uniformity, comap_iInf, gt_iff_lt, preimage_setOf_eq, comap_principal,
PseudoMetricSpace.uniformity_dist]
apply le_antisymm
· simp only [le_iInf_iff, le_principal_iff]
intro ε εpos
classical
| obtain âšK, hKâ© :
â K : Finset ι, (â' i : { j // j â K }, (1 / 2 : â) ^ encode (i : ι)) < ε / 2 :=
((tendsto_order.1 (tendsto_tsum_compl_atTop_zero fun i : ι => (1 / 2 : â) ^ encode i)).2 _
| Mathlib/Topology/MetricSpace/PiNat.lean | 841 | 843 |
/-
Copyright (c) 2021 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import Mathlib.Data.ULift
import Mathlib.Data.ZMod.Defs
import Mathlib.SetTheory.Cardinal.ToNat
import Mathlib.SetTheory.Cardinal.ENat
/-!
# Finite Cardinality Functions
## Main Definitions
* `Nat.card α` is the cardinality of `α` as a natural number.
If `α` is infinite, `Nat.card α = 0`.
* `ENat.card α` is the cardinality of `α` as an extended natural number.
If `α` is infinite, `ENat.card α = â€`.
* `PartENat.card α` is the cardinality of `α` as an extended natural number
(using the legacy definition `PartENat := Part â`). If `α` is infinite, `PartENat.card α = â€`.
-/
assert_not_exists Field
open Cardinal Function
noncomputable section
variable {α β : Type*}
universe u v
namespace Nat
/-- `Nat.card α` is the cardinality of `α` as a natural number.
If `α` is infinite, `Nat.card α = 0`. -/
protected def card (α : Type*) : â :=
toNat (mk α)
@[simp]
theorem card_eq_fintype_card [Fintype α] : Nat.card α = Fintype.card α :=
mk_toNat_eq_card
/-- Because this theorem takes `Fintype α` as a non-instance argument, it can be used in particular
when `Fintype.card` ends up with different instance than the one found by inference -/
theorem _root_.Fintype.card_eq_nat_card {_ : Fintype α} : Fintype.card α = Nat.card α :=
mk_toNat_eq_card.symm
lemma card_eq_finsetCard (s : Finset α) : Nat.card s = s.card := by
simp only [Nat.card_eq_fintype_card, Fintype.card_coe]
lemma card_eq_card_toFinset (s : Set α) [Fintype s] : Nat.card s = s.toFinset.card := by
simp only [â Nat.card_eq_finsetCard, s.mem_toFinset]
lemma card_eq_card_finite_toFinset {s : Set α} (hs : s.Finite) : Nat.card s = hs.toFinset.card := by
simp only [â Nat.card_eq_finsetCard, hs.mem_toFinset]
@[simp] theorem card_of_isEmpty [IsEmpty α] : Nat.card α = 0 := by simp [Nat.card]
@[simp] lemma card_eq_zero_of_infinite [Infinite α] : Nat.card α = 0 := mk_toNat_of_infinite
lemma cast_card [Finite α] : (Nat.card α : Cardinal) = Cardinal.mk α := by
rw [Nat.card, Cardinal.cast_toNat_of_lt_aleph0]
exact Cardinal.lt_aleph0_of_finite _
lemma _root_.Set.Infinite.card_eq_zero {s : Set α} (hs : s.Infinite) : Nat.card s = 0 :=
@card_eq_zero_of_infinite _ hs.to_subtype
lemma card_eq_zero : Nat.card α = 0 â IsEmpty α âš Infinite α := by
simp [Nat.card, mk_eq_zero_iff, aleph0_le_mk_iff]
lemma card_ne_zero : Nat.card α â 0 â Nonempty α â§ Finite α := by simp [card_eq_zero, not_or]
lemma card_pos_iff : 0 < Nat.card α â Nonempty α â§ Finite α := by
simp [Nat.card, mk_eq_zero_iff, mk_lt_aleph0_iff]
@[simp] lemma card_pos [Nonempty α] [Finite α] : 0 < Nat.card α := card_pos_iff.2 âšâ¹_âº, â¹_âºâ©
theorem finite_of_card_ne_zero (h : Nat.card α â 0) : Finite α := (card_ne_zero.1 h).2
theorem card_congr (f : α â β) : Nat.card α = Nat.card β :=
Cardinal.toNat_congr f
lemma card_le_card_of_injective {α : Type u} {β : Type v} [Finite β] (f : α â β)
(hf : Injective f) : Nat.card α †Nat.card β := by
simpa using toNat_le_toNat (lift_mk_le_lift_mk_of_injective hf) (by simp [lt_aleph0_of_finite])
|
lemma card_le_card_of_surjective {α : Type u} {β : Type v} [Finite α] (f : α â β)
(hf : Surjective f) : Nat.card β †Nat.card α := by
have : lift.{u} #β †lift.{v} #α := mk_le_of_surjective (ULift.map_surjective.2 hf)
| Mathlib/SetTheory/Cardinal/Finite.lean | 88 | 91 |
/-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Sébastien Gouëzel
-/
import Mathlib.Analysis.Normed.Operator.Banach
import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace
import Mathlib.Topology.PartialHomeomorph
/-!
# Non-linear maps close to affine maps
In this file we study a map `f` such that `âf x - f y - f' (x - y)â †c * âx - yâ` on an open set
`s`, where `f' : E âL[ð] F` is a continuous linear map and `c` is suitably small. Maps of this type
behave like `f a + f' (x - a)` near each `a â s`.
When `f'` is onto, we show that `f` is locally onto.
When `f'` is a continuous linear equiv, we show that `f` is a homeomorphism
between `s` and `f '' s`. More precisely, we define `ApproximatesLinearOn.toPartialHomeomorph` to
be a `PartialHomeomorph` with `toFun = f`, `source = s`, and `target = f '' s`.
between `s` and `f '' s`. More precisely, we define `ApproximatesLinearOn.toPartialHomeomorph` to
be a `PartialHomeomorph` with `toFun = f`, `source = s`, and `target = f '' s`.
Maps of this type naturally appear in the proof of the inverse function theorem (see next section),
and `ApproximatesLinearOn.toPartialHomeomorph` will imply that the locally inverse function
and `ApproximatesLinearOn.toPartialHomeomorph` will imply that the locally inverse function
exists.
We define this auxiliary notion to split the proof of the inverse function theorem into small
lemmas. This approach makes it possible
- to prove a lower estimate on the size of the domain of the inverse function;
- to reuse parts of the proofs in the case if a function is not strictly differentiable. E.g., for a
function `f : E Ã F â G` with estimates on `f x yâ - f x yâ` but not on `f xâ y - f xâ y`.
## Notations
We introduce some `local notation` to make formulas shorter:
* by `N` we denote `âf'â»Â¹â`;
* by `g` we denote the auxiliary contracting map `x ⊠x + f'.symm (y - f x)` used to prove that
`{x | f x = y}` is nonempty.
-/
open Function Set Filter Metric
open scoped Topology NNReal
noncomputable section
variable {ð : Type*} [NontriviallyNormedField ð]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ð E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ð F]
variable {ε : â}
open Filter Metric Set
open ContinuousLinearMap (id)
/-- We say that `f` approximates a continuous linear map `f'` on `s` with constant `c`,
if `âf x - f y - f' (x - y)â †c * âx - yâ` whenever `x, y â s`.
This predicate is defined to facilitate the splitting of the inverse function theorem into small
lemmas. Some of these lemmas can be useful, e.g., to prove that the inverse function is defined
on a specific set. -/
def ApproximatesLinearOn (f : E â F) (f' : E âL[ð] F) (s : Set E) (c : ââ¥0) : Prop :=
â x â s, â y â s, âf x - f y - f' (x - y)â †c * âx - yâ
@[simp]
theorem approximatesLinearOn_empty (f : E â F) (f' : E âL[ð] F) (c : ââ¥0) :
ApproximatesLinearOn f f' â
c := by simp [ApproximatesLinearOn]
namespace ApproximatesLinearOn
variable {f : E â F}
/-! First we prove some properties of a function that `ApproximatesLinearOn` a (not necessarily
invertible) continuous linear map. -/
section
variable {f' : E âL[ð] F} {s t : Set E} {c c' : ââ¥0}
theorem mono_num (hc : c †c') (hf : ApproximatesLinearOn f f' s c) :
ApproximatesLinearOn f f' s c' := fun x hx y hy =>
le_trans (hf x hx y hy) (mul_le_mul_of_nonneg_right hc <| norm_nonneg _)
theorem mono_set (hst : s â t) (hf : ApproximatesLinearOn f f' t c) :
ApproximatesLinearOn f f' s c := fun x hx y hy => hf x (hst hx) y (hst hy)
theorem approximatesLinearOn_iff_lipschitzOnWith {f : E â F} {f' : E âL[ð] F} {s : Set E}
{c : ââ¥0} : ApproximatesLinearOn f f' s c â LipschitzOnWith c (f - âf') s := by
have : â x y, f x - f y - f' (x - y) = (f - f') x - (f - f') y := fun x y ⊠by
simp only [map_sub, Pi.sub_apply]; abel
simp only [this, lipschitzOnWith_iff_norm_sub_le, ApproximatesLinearOn]
alias âšlipschitzOnWith, _root_.LipschitzOnWith.approximatesLinearOnâ© :=
approximatesLinearOn_iff_lipschitzOnWith
theorem lipschitz_sub (hf : ApproximatesLinearOn f f' s c) :
LipschitzWith c fun x : s => f x - f' x :=
hf.lipschitzOnWith.to_restrict
protected theorem lipschitz (hf : ApproximatesLinearOn f f' s c) :
LipschitzWith (âf'ââ + c) (s.restrict f) := by
simpa only [restrict_apply, add_sub_cancel] using
(f'.lipschitz.restrict s).add hf.lipschitz_sub
protected theorem continuous (hf : ApproximatesLinearOn f f' s c) : Continuous (s.restrict f) :=
hf.lipschitz.continuous
protected theorem continuousOn (hf : ApproximatesLinearOn f f' s c) : ContinuousOn f s :=
continuousOn_iff_continuous_restrict.2 hf.continuous
end
|
section LocallyOnto
/-!
| Mathlib/Analysis/Calculus/InverseFunctionTheorem/ApproximatesLinearOn.lean | 118 | 121 |
/-
Copyright (c) 2017 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Stephen Morgan, Kim Morrison
-/
import Mathlib.CategoryTheory.Equivalence
/-!
# Opposite categories
We provide a category instance on `Cáµáµ`.
The morphisms `X â¶ Y` are defined to be the morphisms `unop Y â¶ unop X` in `C`.
Here `Cáµáµ` is an irreducible typeclass synonym for `C`
(it is the same one used in the algebra library).
We also provide various mechanisms for constructing opposite morphisms, functors,
and natural transformations.
Unfortunately, because we do not have a definitional equality `op (op X) = X`,
there are quite a few variations that are needed in practice.
-/
universe vâ vâ uâ uâ
-- morphism levels before object levels. See note [CategoryTheory universes].
open Opposite
variable {C : Type uâ}
section Quiver
variable [Quiver.{vâ} C]
theorem Quiver.Hom.op_inj {X Y : C} :
Function.Injective (Quiver.Hom.op : (X â¶ Y) â (Opposite.op Y â¶ Opposite.op X)) := fun _ _ H =>
congr_arg Quiver.Hom.unop H
theorem Quiver.Hom.unop_inj {X Y : Cáµáµ} :
Function.Injective (Quiver.Hom.unop : (X â¶ Y) â (Opposite.unop Y â¶ Opposite.unop X)) :=
fun _ _ H => congr_arg Quiver.Hom.op H
@[simp]
theorem Quiver.Hom.unop_op {X Y : C} (f : X â¶ Y) : f.op.unop = f :=
rfl
@[simp]
theorem Quiver.Hom.unop_op' {X Y : Cáµáµ} {x} :
@Quiver.Hom.unop C _ X Y no_index (Opposite.op (unop := x)) = x := rfl
@[simp]
theorem Quiver.Hom.op_unop {X Y : Cáµáµ} (f : X â¶ Y) : f.unop.op = f :=
rfl
@[simp] theorem Quiver.Hom.unop_mk {X Y : Cáµáµ} (f : X â¶ Y) : Quiver.Hom.unop {unop := f} = f := rfl
end Quiver
namespace CategoryTheory
variable [Category.{vâ} C]
/-- The opposite category. -/
@[stacks 001M]
instance Category.opposite : Category.{vâ} Cáµáµ where
comp f g := (g.unop â« f.unop).op
id X := (ð (unop X)).op
@[simp, reassoc]
theorem op_comp {X Y Z : C} {f : X â¶ Y} {g : Y â¶ Z} : (f â« g).op = g.op â« f.op :=
rfl
@[simp]
theorem op_id {X : C} : (ð X).op = ð (op X) :=
rfl
@[simp, reassoc]
theorem unop_comp {X Y Z : Cáµáµ} {f : X â¶ Y} {g : Y â¶ Z} : (f â« g).unop = g.unop â« f.unop :=
rfl
@[simp]
theorem unop_id {X : Cáµáµ} : (ð X).unop = ð (unop X) :=
rfl
@[simp]
theorem unop_id_op {X : C} : (ð (op X)).unop = ð X :=
rfl
@[simp]
theorem op_id_unop {X : Cáµáµ} : (ð (unop X)).op = ð X :=
rfl
section
variable (C)
/-- The functor from the double-opposite of a category to the underlying category. -/
@[simps]
def unopUnop : Cáµáµáµáµ ⥀ C where
obj X := unop (unop X)
map f := f.unop.unop
/-- The functor from a category to its double-opposite. -/
@[simps]
def opOp : C ⥀ Cáµáµáµáµ where
obj X := op (op X)
map f := f.op.op
/-- The double opposite category is equivalent to the original. -/
@[simps]
def opOpEquivalence : Cáµáµáµáµ â C where
functor := unopUnop C
inverse := opOp C
unitIso := Iso.refl (ð Cáµáµáµáµ)
counitIso := Iso.refl (opOp C â unopUnop C)
instance : (opOp C).IsEquivalence :=
(opOpEquivalence C).isEquivalence_inverse
instance : (unopUnop C).IsEquivalence :=
(opOpEquivalence C).isEquivalence_functor
end
/-- If `f` is an isomorphism, so is `f.op` -/
instance isIso_op {X Y : C} (f : X â¶ Y) [IsIso f] : IsIso f.op :=
âšâš(inv f).op, âšQuiver.Hom.unop_inj (by simp), Quiver.Hom.unop_inj (by simp)â©â©â©
/-- If `f.op` is an isomorphism `f` must be too.
(This cannot be an instance as it would immediately loop!)
-/
theorem isIso_of_op {X Y : C} (f : X â¶ Y) [IsIso f.op] : IsIso f :=
âšâš(inv f.op).unop, âšQuiver.Hom.op_inj (by simp), Quiver.Hom.op_inj (by simp)â©â©â©
theorem isIso_op_iff {X Y : C} (f : X â¶ Y) : IsIso f.op â IsIso f :=
âšfun _ => isIso_of_op _, fun _ => inferInstanceâ©
theorem isIso_unop_iff {X Y : Cáµáµ} (f : X â¶ Y) : IsIso f.unop â IsIso f := by
rw [â isIso_op_iff f.unop, Quiver.Hom.op_unop]
instance isIso_unop {X Y : Cáµáµ} (f : X â¶ Y) [IsIso f] : IsIso f.unop :=
(isIso_unop_iff _).2 inferInstance
@[simp]
| theorem op_inv {X Y : C} (f : X â¶ Y) [IsIso f] : (inv f).op = inv f.op := by
apply IsIso.eq_inv_of_hom_inv_id
| Mathlib/CategoryTheory/Opposites.lean | 145 | 146 |
/-
Copyright (c) 2022 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying
-/
import Mathlib.Order.Interval.Set.Monotone
import Mathlib.Probability.Process.HittingTime
import Mathlib.Probability.Martingale.Basic
import Mathlib.Tactic.AdaptationNote
/-!
# Doob's upcrossing estimate
Given a discrete real-valued submartingale $(f_n)_{n \in \mathbb{N}}$, denoting by $U_N(a, b)$ the
number of times $f_n$ crossed from below $a$ to above $b$ before time $N$, Doob's upcrossing
estimate (also known as Doob's inequality) states that
$$(b - a) \mathbb{E}[U_N(a, b)] \le \mathbb{E}[(f_N - a)^+].$$
Doob's upcrossing estimate is an important inequality and is central in proving the martingale
convergence theorems.
## Main definitions
* `MeasureTheory.upperCrossingTime a b f N n`: is the stopping time corresponding to `f`
crossing above `b` the `n`-th time before time `N` (if this does not occur then the value is
taken to be `N`).
* `MeasureTheory.lowerCrossingTime a b f N n`: is the stopping time corresponding to `f`
crossing below `a` the `n`-th time before time `N` (if this does not occur then the value is
taken to be `N`).
* `MeasureTheory.upcrossingStrat a b f N`: is the predictable process which is 1 if `n` is
between a consecutive pair of lower and upper crossings and is 0 otherwise. Intuitively
one might think of the `upcrossingStrat` as the strategy of buying 1 share whenever the process
crosses below `a` for the first time after selling and selling 1 share whenever the process
crosses above `b` for the first time after buying.
* `MeasureTheory.upcrossingsBefore a b f N`: is the number of times `f` crosses from below `a` to
above `b` before time `N`.
* `MeasureTheory.upcrossings a b f`: is the number of times `f` crosses from below `a` to above
`b`. This takes value in `ââ¥0â` and so is allowed to be `â`.
## Main results
* `MeasureTheory.Adapted.isStoppingTime_upperCrossingTime`: `upperCrossingTime` is a
stopping time whenever the process it is associated to is adapted.
* `MeasureTheory.Adapted.isStoppingTime_lowerCrossingTime`: `lowerCrossingTime` is a
stopping time whenever the process it is associated to is adapted.
* `MeasureTheory.Submartingale.mul_integral_upcrossingsBefore_le_integral_pos_part`: Doob's
upcrossing estimate.
* `MeasureTheory.Submartingale.mul_lintegral_upcrossings_le_lintegral_pos_part`: the inequality
obtained by taking the supremum on both sides of Doob's upcrossing estimate.
### References
We mostly follow the proof from [Kallenberg, *Foundations of modern probability*][kallenberg2021]
-/
open TopologicalSpace Filter
open scoped NNReal ENNReal MeasureTheory ProbabilityTheory Topology
namespace MeasureTheory
variable {Ω ι : Type*} {m0 : MeasurableSpace Ω} {Ό : Measure Ω}
/-!
## Proof outline
In this section, we will denote by $U_N(a, b)$ the number of upcrossings of $(f_n)$ from below $a$
to above $b$ before time $N$.
To define $U_N(a, b)$, we will construct two stopping times corresponding to when $(f_n)$ crosses
below $a$ and above $b$. Namely, we define
$$
\sigma_n := \inf \{n \ge \tau_n \mid f_n \le a\} \wedge N;
$$
$$
\tau_{n + 1} := \inf \{n \ge \sigma_n \mid f_n \ge b\} \wedge N.
$$
These are `lowerCrossingTime` and `upperCrossingTime` in our formalization which are defined
using `MeasureTheory.hitting` allowing us to specify a starting and ending time.
Then, we may simply define $U_N(a, b) := \sup \{n \mid \tau_n < N\}$.
Fixing $a < b \in \mathbb{R}$, we will first prove the theorem in the special case that
$0 \le f_0$ and $a \le f_N$. In particular, we will show
$$
(b - a) \mathbb{E}[U_N(a, b)] \le \mathbb{E}[f_N].
$$
This is `MeasureTheory.integral_mul_upcrossingsBefore_le_integral` in our formalization.
To prove this, we use the fact that given a non-negative, bounded, predictable process $(C_n)$
(i.e. $(C_{n + 1})$ is adapted), $(C \bullet f)_n := \sum_{k \le n} C_{k + 1}(f_{k + 1} - f_k)$ is
a submartingale if $(f_n)$ is.
Define $C_n := \sum_{k \le n} \mathbf{1}_{[\sigma_k, \tau_{k + 1})}(n)$. It is easy to see that
$(1 - C_n)$ is non-negative, bounded and predictable, and hence, given a submartingale $(f_n)$,
$(1 - C) \bullet f$ is also a submartingale. Thus, by the submartingale property,
$0 \le \mathbb{E}[((1 - C) \bullet f)_0] \le \mathbb{E}[((1 - C) \bullet f)_N]$ implying
$$
\mathbb{E}[(C \bullet f)_N] \le \mathbb{E}[(1 \bullet f)_N] = \mathbb{E}[f_N] - \mathbb{E}[f_0].
$$
Furthermore,
\begin{align}
(C \bullet f)_N & =
\sum_{n \le N} \sum_{k \le N} \mathbf{1}_{[\sigma_k, \tau_{k + 1})}(n)(f_{n + 1} - f_n)\\
& = \sum_{k \le N} \sum_{n \le N} \mathbf{1}_{[\sigma_k, \tau_{k + 1})}(n)(f_{n + 1} - f_n)\\
& = \sum_{k \le N} (f_{\sigma_k + 1} - f_{\sigma_k} + f_{\sigma_k + 2} - f_{\sigma_k + 1}
+ \cdots + f_{\tau_{k + 1}} - f_{\tau_{k + 1} - 1})\\
& = \sum_{k \le N} (f_{\tau_{k + 1}} - f_{\sigma_k})
\ge \sum_{k < U_N(a, b)} (b - a) = (b - a) U_N(a, b)
\end{align}
where the inequality follows since for all $k < U_N(a, b)$,
$f_{\tau_{k + 1}} - f_{\sigma_k} \ge b - a$ while for all $k > U_N(a, b)$,
$f_{\tau_{k + 1}} = f_{\sigma_k} = f_N$ and
$f_{\tau_{U_N(a, b) + 1}} - f_{\sigma_{U_N(a, b)}} = f_N - a \ge 0$. Hence, we have
$$
(b - a) \mathbb{E}[U_N(a, b)] \le \mathbb{E}[(C \bullet f)_N]
\le \mathbb{E}[f_N] - \mathbb{E}[f_0] \le \mathbb{E}[f_N],
$$
as required.
To obtain the general case, we simply apply the above to $((f_n - a)^+)_n$.
-/
/-- `lowerCrossingTimeAux a f c N` is the first time `f` reached below `a` after time `c` before
time `N`. -/
noncomputable def lowerCrossingTimeAux [Preorder ι] [InfSet ι] (a : â) (f : ι â Ω â â) (c N : ι) :
Ω â ι :=
hitting f (Set.Iic a) c N
/-- `upperCrossingTime a b f N n` is the first time before time `N`, `f` reaches
above `b` after `f` reached below `a` for the `n - 1`-th time. -/
noncomputable def upperCrossingTime [Preorder ι] [OrderBot ι] [InfSet ι] (a b : â) (f : ι â Ω â â)
(N : ι) : â â Ω â ι
| 0 => â¥
| n + 1 => fun Ï =>
hitting f (Set.Ici b) (lowerCrossingTimeAux a f (upperCrossingTime a b f N n Ï) N Ï) N Ï
/-- `lowerCrossingTime a b f N n` is the first time before time `N`, `f` reaches
below `a` after `f` reached above `b` for the `n`-th time. -/
noncomputable def lowerCrossingTime [Preorder ι] [OrderBot ι] [InfSet ι] (a b : â) (f : ι â Ω â â)
(N : ι) (n : â) : Ω â ι := fun Ï => hitting f (Set.Iic a) (upperCrossingTime a b f N n Ï) N Ï
section
variable [Preorder ι] [OrderBot ι] [InfSet ι]
variable {a b : â} {f : ι â Ω â â} {N : ι} {n : â} {Ï : Ω}
@[simp]
theorem upperCrossingTime_zero : upperCrossingTime a b f N 0 = ⥠:=
rfl
@[simp]
theorem lowerCrossingTime_zero : lowerCrossingTime a b f N 0 = hitting f (Set.Iic a) ⥠N :=
rfl
theorem upperCrossingTime_succ : upperCrossingTime a b f N (n + 1) Ï =
hitting f (Set.Ici b) (lowerCrossingTimeAux a f (upperCrossingTime a b f N n Ï) N Ï) N Ï := by
rw [upperCrossingTime]
theorem upperCrossingTime_succ_eq (Ï : Ω) : upperCrossingTime a b f N (n + 1) Ï =
hitting f (Set.Ici b) (lowerCrossingTime a b f N n Ï) N Ï := by
simp only [upperCrossingTime_succ]
rfl
end
section ConditionallyCompleteLinearOrderBot
variable [ConditionallyCompleteLinearOrderBot ι]
variable {a b : â} {f : ι â Ω â â} {N : ι} {n m : â} {Ï : Ω}
theorem upperCrossingTime_le : upperCrossingTime a b f N n Ï â€ N := by
cases n
· simp only [upperCrossingTime_zero, Pi.bot_apply, bot_le]
· simp only [upperCrossingTime_succ, hitting_le]
@[simp]
theorem upperCrossingTime_zero' : upperCrossingTime a b f ⥠n Ï = ⥠:=
eq_bot_iff.2 upperCrossingTime_le
theorem lowerCrossingTime_le : lowerCrossingTime a b f N n Ï â€ N := by
simp only [lowerCrossingTime, hitting_le Ï]
theorem upperCrossingTime_le_lowerCrossingTime :
upperCrossingTime a b f N n Ï â€ lowerCrossingTime a b f N n Ï := by
simp only [lowerCrossingTime, le_hitting upperCrossingTime_le Ï]
theorem lowerCrossingTime_le_upperCrossingTime_succ :
lowerCrossingTime a b f N n Ï â€ upperCrossingTime a b f N (n + 1) Ï := by
rw [upperCrossingTime_succ]
exact le_hitting lowerCrossingTime_le Ï
theorem lowerCrossingTime_mono (hnm : n †m) :
lowerCrossingTime a b f N n Ï â€ lowerCrossingTime a b f N m Ï := by
suffices Monotone fun n => lowerCrossingTime a b f N n Ï by exact this hnm
exact monotone_nat_of_le_succ fun n =>
le_trans lowerCrossingTime_le_upperCrossingTime_succ upperCrossingTime_le_lowerCrossingTime
theorem upperCrossingTime_mono (hnm : n †m) :
upperCrossingTime a b f N n Ï â€ upperCrossingTime a b f N m Ï := by
suffices Monotone fun n => upperCrossingTime a b f N n Ï by exact this hnm
exact monotone_nat_of_le_succ fun n =>
le_trans upperCrossingTime_le_lowerCrossingTime lowerCrossingTime_le_upperCrossingTime_succ
end ConditionallyCompleteLinearOrderBot
variable {a b : â} {f : â â Ω â â} {N : â} {n m : â} {Ï : Ω}
theorem stoppedValue_lowerCrossingTime (h : lowerCrossingTime a b f N n Ï â N) :
stoppedValue f (lowerCrossingTime a b f N n) Ï â€ a := by
obtain âšj, hjâ, hjââ© := (hitting_le_iff_of_lt _ (lt_of_le_of_ne lowerCrossingTime_le h)).1 le_rfl
exact stoppedValue_hitting_mem âšj, âšhjâ.1, le_trans hjâ.2 lowerCrossingTime_leâ©, hjââ©
theorem stoppedValue_upperCrossingTime (h : upperCrossingTime a b f N (n + 1) Ï â N) :
b †stoppedValue f (upperCrossingTime a b f N (n + 1)) Ï := by
obtain âšj, hjâ, hjââ© := (hitting_le_iff_of_lt _ (lt_of_le_of_ne upperCrossingTime_le h)).1 le_rfl
exact stoppedValue_hitting_mem âšj, âšhjâ.1, le_trans hjâ.2 (hitting_le _)â©, hjââ©
theorem upperCrossingTime_lt_lowerCrossingTime (hab : a < b)
(hn : lowerCrossingTime a b f N (n + 1) Ï â N) :
upperCrossingTime a b f N (n + 1) Ï < lowerCrossingTime a b f N (n + 1) Ï := by
refine lt_of_le_of_ne upperCrossingTime_le_lowerCrossingTime fun h =>
not_le.2 hab <| le_trans ?_ (stoppedValue_lowerCrossingTime hn)
simp only [stoppedValue]
rw [â h]
exact stoppedValue_upperCrossingTime (h.symm âž hn)
theorem lowerCrossingTime_lt_upperCrossingTime (hab : a < b)
(hn : upperCrossingTime a b f N (n + 1) Ï â N) :
lowerCrossingTime a b f N n Ï < upperCrossingTime a b f N (n + 1) Ï := by
refine lt_of_le_of_ne lowerCrossingTime_le_upperCrossingTime_succ fun h =>
not_le.2 hab <| le_trans (stoppedValue_upperCrossingTime hn) ?_
simp only [stoppedValue]
rw [â h]
exact stoppedValue_lowerCrossingTime (h.symm âž hn)
| theorem upperCrossingTime_lt_succ (hab : a < b) (hn : upperCrossingTime a b f N (n + 1) Ï â N) :
upperCrossingTime a b f N n Ï < upperCrossingTime a b f N (n + 1) Ï :=
lt_of_le_of_lt upperCrossingTime_le_lowerCrossingTime
(lowerCrossingTime_lt_upperCrossingTime hab hn)
theorem lowerCrossingTime_stabilize (hnm : n †m) (hn : lowerCrossingTime a b f N n Ï = N) :
lowerCrossingTime a b f N m Ï = N :=
le_antisymm lowerCrossingTime_le (le_trans (le_of_eq hn.symm) (lowerCrossingTime_mono hnm))
| Mathlib/Probability/Martingale/Upcrossing.lean | 242 | 249 |
/-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Algebra.Polynomial.Module.AEval
/-!
# Polynomial module
In this file, we define the polynomial module for an `R`-module `M`, i.e. the `R[X]`-module `M[X]`.
This is defined as a type alias `PolynomialModule R M := â ââ M`, since there might be different
module structures on `â ââ M` of interest. See the docstring of `PolynomialModule` for details.
-/
universe u v
open Polynomial
/-- The `R[X]`-module `M[X]` for an `R`-module `M`.
This is isomorphic (as an `R`-module) to `M[X]` when `M` is a ring.
We require all the module instances `Module S (PolynomialModule R M)` to factor through `R` except
`Module R[X] (PolynomialModule R M)`.
In this constraint, we have the following instances for example :
- `R` acts on `PolynomialModule R R[X]`
- `R[X]` acts on `PolynomialModule R R[X]` as `R[Y]` acting on `R[X][Y]`
- `R` acts on `PolynomialModule R[X] R[X]`
- `R[X]` acts on `PolynomialModule R[X] R[X]` as `R[X]` acting on `R[X][Y]`
- `R[X][X]` acts on `PolynomialModule R[X] R[X]` as `R[X][Y]` acting on itself
This is also the reason why `R` is included in the alias, or else there will be two different
instances of `Module R[X] (PolynomialModule R[X])`.
See https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/.2315065.20polynomial.20modules
for the full discussion.
-/
@[nolint unusedArguments]
def PolynomialModule (R M : Type*) [CommRing R] [AddCommGroup M] [Module R M] := â ââ M
variable (R M : Type*) [CommRing R] [AddCommGroup M] [Module R M] (I : Ideal R)
-- The `Inhabited, AddCommGroup` instances should be constructed by a deriving handler.
-- https://github.com/leanprover-community/mathlib4/issues/380
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
/-- This is required to have the `IsScalarTower S R M` instance to avoid diamonds. -/
@[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 :=
inferInstanceAs <| CoeFun (_ ââ _) _
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
/-- The monomial `m * x ^ i`. This is defeq to `Finsupp.singleAddHom`, and is redefined here
so that it has the desired type signature. -/
noncomputable def single (i : â) : M â+ PolynomialModule R M :=
Finsupp.singleAddHom i
theorem single_apply (i : â) (m : M) (n : â) : single R i m n = ite (i = n) m 0 :=
Finsupp.single_apply
/-- `PolynomialModule.single` as a linear map. -/
noncomputable def lsingle (i : â) : M ââ[R] PolynomialModule R M :=
Finsupp.lsingle i
theorem lsingle_apply (i : â) (m : M) (n : â) : lsingle R i m n = ite (i = n) m 0 :=
Finsupp.single_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
variable {R}
@[elab_as_elim]
theorem induction_linear {motive : PolynomialModule R M â Prop} (f : PolynomialModule R M)
(zero : motive 0) (add : â f g, motive f â motive g â motive (f + g))
(single : â a b, motive (single R a b)) : motive f :=
Finsupp.induction_linear f zero add single
noncomputable instance polynomialModule : Module R[X] (PolynomialModule R M) :=
inferInstanceAs (Module R[X] (Module.AEval' (Finsupp.lmapDomain M R Nat.succ)))
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]
@[simp]
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 [Module.End.mul_apply, Polynomial.aeval_monomial, Module.End.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
@[simp]
theorem monomial_smul_apply (i : â) (r : R) (g : PolynomialModule R M) (n : â) :
(monomial i r ⢠g) n = ite (i †n) (r ⢠g (n - i)) 0 := by
induction' g using PolynomialModule.induction_linear with p q hp hq
· simp only [smul_zero, zero_apply, ite_self]
· simp only [smul_add, add_apply, hp, hq]
split_ifs
exacts [rfl, zero_add 0]
· rw [monomial_smul_single, single_apply, single_apply, smul_ite, smul_zero, â ite_and]
congr
rw [eq_iff_iff]
constructor
· rintro rfl
simp
· rintro âše, rflâ©
rw [add_comm, tsub_add_cancel_of_le e]
@[simp]
theorem smul_single_apply (i : â) (f : R[X]) (m : M) (n : â) :
(f ⢠single R i m) n = ite (i †n) (f.coeff (n - i) ⢠m) 0 := by
induction' f using Polynomial.induction_on' with p q hp hq
· rw [add_smul, Finsupp.add_apply, hp, hq, coeff_add, add_smul]
split_ifs
exacts [rfl, zero_add 0]
· rw [monomial_smul_single, single_apply, coeff_monomial, ite_smul, zero_smul]
by_cases h : i †n
· simp_rw [eq_tsub_iff_add_eq_of_le h, if_pos h]
· rw [if_neg h, if_neg]
omega
theorem smul_apply (f : R[X]) (g : PolynomialModule R M) (n : â) :
(f ⢠g) n = â x â Finset.antidiagonal n, f.coeff x.1 ⢠g x.2 := by
induction f using Polynomial.induction_on' with
| add p q hp hq =>
rw [add_smul, Finsupp.add_apply, hp, hq, â Finset.sum_add_distrib]
congr
ext
rw [coeff_add, add_smul]
| monomial f_n f_a =>
rw [Finset.Nat.sum_antidiagonal_eq_sum_range_succ fun i j => (monomial f_n f_a).coeff i ⢠g j,
monomial_smul_apply]
simp_rw [Polynomial.coeff_monomial, â Finset.mem_range_succ_iff]
rw [â Finset.sum_ite_eq (Finset.range (Nat.succ n)) f_n (fun x => f_a ⢠g (n - x))]
congr
ext x
split_ifs
exacts [rfl, (zero_smul R _).symm]
/-- `PolynomialModule R R` is isomorphic to `R[X]` as an `R[X]` module. -/
noncomputable def equivPolynomialSelf : PolynomialModule R R ââ[R[X]] R[X] :=
{ (Polynomial.toFinsuppIso R).symm with
map_smul' := fun r x => by
dsimp
rw [â RingEquiv.coe_toEquiv_symm, RingEquiv.coe_toEquiv]
induction x using induction_linear with
| zero => rw [smul_zero, map_zero, mul_zero]
| add _ _ hp hq => rw [smul_add, map_add, map_add, mul_add, hp, hq]
| single n a =>
ext i
simp only [coeff_ofFinsupp, smul_single_apply, toFinsuppIso_symm_apply, coeff_ofFinsupp,
single_apply, smul_eq_mul, Polynomial.coeff_mul, mul_ite, mul_zero]
split_ifs with hn
· rw [Finset.sum_eq_single (i - n, n)]
· simp only [ite_true]
· rintro âšp, qâ© hpq1 hpq2
rw [Finset.mem_antidiagonal] at hpq1
split_ifs with H
· dsimp at H
exfalso
apply hpq2
rw [â hpq1, H]
simp only [add_le_iff_nonpos_left, nonpos_iff_eq_zero, add_tsub_cancel_right]
· rfl
· intro H
exfalso
apply H
rw [Finset.mem_antidiagonal, tsub_add_cancel_of_le hn]
· symm
rw [Finset.sum_ite_of_false, Finset.sum_const_zero]
simp_rw [Finset.mem_antidiagonal]
intro x hx
contrapose! hn
rw [add_comm, â hn] at hx
exact Nat.le.intro hx }
/-- `PolynomialModule R S` is isomorphic to `S[X]` as an `R` module. -/
noncomputable def equivPolynomial {S : Type*} [CommRing S] [Algebra R S] :
PolynomialModule R S ââ[R] S[X] :=
{ (Polynomial.toFinsuppIso S).symm with map_smul' := fun _ _ => rfl }
@[simp]
lemma equivPolynomialSelf_apply_eq (p : PolynomialModule R R) :
equivPolynomialSelf p = equivPolynomial p := rfl
@[simp]
lemma equivPolynomial_single {S : Type*} [CommRing S] [Algebra R S] (n : â) (x : S) :
equivPolynomial (single R n x) = monomial n x := rfl
variable (R' : Type*) {M' : Type*} [CommRing R'] [AddCommGroup M'] [Module R' M']
variable [Module R M']
/-- The image of a polynomial under a linear map. -/
noncomputable def map (f : M ââ[R] M') : PolynomialModule R M ââ[R] PolynomialModule R' M' :=
Finsupp.mapRange.linearMap f
@[simp]
theorem map_single (f : M ââ[R] M') (i : â) (m : M) : map R' f (single R i m) = single R' i (f m) :=
Finsupp.mapRange_single (hf := f.map_zero)
variable [Algebra R R'] [IsScalarTower R R' M']
theorem map_smul (f : M ââ[R] M') (p : R[X]) (q : PolynomialModule R M) :
map R' f (p ⢠q) = p.map (algebraMap R R') ⢠map R' f q := by
induction q using induction_linear with
| zero => rw [smul_zero, map_zero, smul_zero]
| add f g eâ eâ => rw [smul_add, map_add, eâ, eâ, map_add, smul_add]
| single i m =>
induction p using Polynomial.induction_on' with
| add _ _ eâ eâ => rw [add_smul, map_add, eâ, eâ, Polynomial.map_add, add_smul]
| monomial => rw [monomial_smul_single, map_single, Polynomial.map_monomial, map_single,
monomial_smul_single, f.map_smul, algebraMap_smul]
/-- Evaluate a polynomial `p : PolynomialModule R M` at `r : R`. -/
@[simps! -isSimp]
def eval (r : R) : PolynomialModule R M ââ[R] M where
toFun p := p.sum fun i m => r ^ i ⢠m
map_add' _ _ := Finsupp.sum_add_index' (fun _ => smul_zero _) fun _ _ _ => smul_add _ _ _
map_smul' s m := by
refine (Finsupp.sum_smul_index' ?_).trans ?_
· exact fun i => smul_zero _
· simp_rw [RingHom.id_apply, Finsupp.smul_sum]
congr
ext i c
rw [smul_comm]
@[simp]
theorem eval_single (r : R) (i : â) (m : M) : eval r (single R i m) = r ^ i ⢠m :=
Finsupp.sum_single_index (smul_zero _)
@[simp]
theorem eval_lsingle (r : R) (i : â) (m : M) : eval r (lsingle R i m) = r ^ i ⢠m :=
eval_single r i m
theorem eval_smul (p : R[X]) (q : PolynomialModule R M) (r : R) :
eval r (p ⢠q) = p.eval r ⢠eval r q := by
induction q using induction_linear with
| zero => rw [smul_zero, map_zero, smul_zero]
| add f g eâ eâ => rw [smul_add, map_add, eâ, eâ, map_add, smul_add]
| single i m =>
induction p using Polynomial.induction_on' with
| add _ _ eâ eâ => rw [add_smul, map_add, Polynomial.eval_add, eâ, eâ, add_smul]
| monomial => simp only [monomial_smul_single, Polynomial.eval_monomial, eval_single]; module
| @[simp]
theorem eval_map (f : M ââ[R] M') (q : PolynomialModule R M) (r : R) :
eval (algebraMap R R' r) (map R' f q) = f (eval r q) := by
induction q using induction_linear with
| zero => simp_rw [map_zero]
| add f g eâ eâ => simp_rw [map_add, eâ, eâ]
| single i m => simp only [map_single, eval_single, f.map_smul]; module
@[simp]
theorem eval_map' (f : M ââ[R] M) (q : PolynomialModule R M) (r : R) :
eval r (map R f q) = f (eval r q) :=
| Mathlib/Algebra/Polynomial/Module/Basic.lean | 282 | 292 |
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.TrivSqZeroExt
/-!
# Dual numbers
The dual numbers over `R` are of the form `a + bε`, where `a` and `b` are typically elements of a
commutative ring `R`, and `ε` is a symbol satisfying `ε^2 = 0` that commutes with every other
element. They are a special case of `TrivSqZeroExt R M` with `M = R`.
## Notation
In the `DualNumber` locale:
* `R[ε]` is a shorthand for `DualNumber R`
* `ε` is a shorthand for `DualNumber.eps`
## Main definitions
* `DualNumber`
* `DualNumber.eps`
* `DualNumber.lift`
## Implementation notes
Rather than duplicating the API of `TrivSqZeroExt`, this file reuses the functions there.
## References
* https://en.wikipedia.org/wiki/Dual_number
-/
variable {R A B : Type*}
/-- The type of dual numbers, numbers of the form $a + bε$ where $ε^2 = 0$.
`R[ε]` is notation for `DualNumber R`. -/
abbrev DualNumber (R : Type*) : Type _ :=
TrivSqZeroExt R R
/-- The unit element $ε$ that squares to zero, with notation `ε`. -/
def DualNumber.eps [Zero R] [One R] : DualNumber R :=
TrivSqZeroExt.inr 1
@[inherit_doc]
scoped[DualNumber] notation "ε" => DualNumber.eps
@[inherit_doc]
scoped[DualNumber] postfix:1024 "[ε]" => DualNumber
open DualNumber
namespace DualNumber
open TrivSqZeroExt
@[simp]
theorem fst_eps [Zero R] [One R] : fst ε = (0 : R) :=
fst_inr _ _
@[simp]
theorem snd_eps [Zero R] [One R] : snd ε = (1 : R) :=
snd_inr _ _
/-- A version of `TrivSqZeroExt.snd_mul` with `*` instead of `â¢`. -/
@[simp]
theorem snd_mul [Semiring R] (x y : R[ε]) : snd (x * y) = fst x * snd y + snd x * fst y :=
TrivSqZeroExt.snd_mul _ _
@[simp]
theorem eps_mul_eps [Semiring R] : (ε * ε : R[ε]) = 0 :=
inr_mul_inr _ _ _
@[simp]
theorem inv_eps [DivisionRing R] : (ε : R[ε])â»Â¹ = 0 :=
TrivSqZeroExt.inv_inr 1
@[simp]
theorem inr_eq_smul_eps [MulZeroOneClass R] (r : R) : inr r = (r ⢠ε : R[ε]) :=
ext (mul_zero r).symm (mul_one r).symm
/-- `ε` commutes with every element of the algebra. -/
theorem commute_eps_left [Semiring R] (x : DualNumber R) : Commute ε x := by
ext <;> simp
/-- `ε` commutes with every element of the algebra. -/
theorem commute_eps_right [Semiring R] (x : DualNumber R) : Commute x ε := (commute_eps_left x).symm
variable {A : Type*} [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
/-- For two `R`-algebra morphisms out of `A[ε]` to agree, it suffices for them to agree on the
elements of `A` and the `A`-multiples of `ε`. -/
@[ext 1100]
nonrec theorem algHom_ext' âŠf g : A[ε] ââ[R] BâŠ
(hinl : f.comp (inlAlgHom _ _ _) = g.comp (inlAlgHom _ _ _))
(hinr : f.toLinearMap ââ (LinearMap.toSpanSingleton A A[ε] ε).restrictScalars R =
g.toLinearMap ââ (LinearMap.toSpanSingleton A A[ε] ε).restrictScalars R) :
f = g :=
algHom_ext' hinl (by
ext a
show f (inr a) = g (inr a)
simpa only [inr_eq_smul_eps] using DFunLike.congr_fun hinr a)
/-- For two `R`-algebra morphisms out of `R[ε]` to agree, it suffices for them to agree on `ε`. -/
@[ext 1200]
nonrec theorem algHom_ext âŠf g : R[ε] ââ[R] A⊠(hε : f ε = g ε) : f = g := by
ext
dsimp
simp only [one_smul, hε]
/-- A universal property of the dual numbers, providing a unique `A[ε] ââ[R] B` for every map
`f : A ââ[R] B` and a choice of element `e : B` which squares to `0` and commutes with the range of
`f`.
This isomorphism is named to match the similar `Complex.lift`.
Note that when `f : R ââ[R] B := Algebra.ofId R B`, the commutativity assumption is automatic, and
we are free to choose any element `e : B`. -/
def lift :
{fe : (A ââ[R] B) à B // fe.2 * fe.2 = 0 â§ â a, Commute fe.2 (fe.1 a)} â (A[ε] ââ[R] B) := by
refine Equiv.trans ?_ TrivSqZeroExt.liftEquiv
exact {
toFun := fun fe => âš
(fe.val.1, MulOpposite.op fe.val.2 ⢠fe.val.1.toLinearMap),
fun x y => show (fe.val.1 x * fe.val.2) * (fe.val.1 y * fe.val.2) = 0 by
rw [(fe.prop.2 _).mul_mul_mul_comm, fe.prop.1, mul_zero],
fun r x => show fe.val.1 (r * x) * fe.val.2 = fe.val.1 r * (fe.val.1 x * fe.val.2) by
rw [map_mul, mul_assoc],
fun r x => show fe.val.1 (x * r) * fe.val.2 = (fe.val.1 x * fe.val.2) * fe.val.1 r by
rw [map_mul, (fe.prop.2 _).right_comm]â©
invFun := fun fg => âš
(fg.val.1, fg.val.2 1),
fg.prop.1 _ _,
fun a => show fg.val.2 1 * fg.val.1 a = fg.val.1 a * fg.val.2 1 by
rw [â fg.prop.2.1, â fg.prop.2.2, smul_eq_mul, op_smul_eq_mul, mul_one, one_mul]â©
left_inv := fun fe => Subtype.ext <| Prod.ext rfl <|
show fe.val.1 1 * fe.val.2 = fe.val.2 by
rw [map_one, one_mul]
right_inv := fun fg => Subtype.ext <| Prod.ext rfl <| LinearMap.ext fun x =>
show fg.val.1 x * fg.val.2 1 = fg.val.2 x by
rw [â fg.prop.2.1, smul_eq_mul, mul_one] }
theorem lift_apply_apply (fe : {_fe : (A ââ[R] B) à B // _}) (a : A[ε]) :
lift fe a = fe.val.1 a.fst + fe.val.1 a.snd * fe.val.2 := rfl
@[simp] theorem coe_lift_symm_apply (F : A[ε] ââ[R] B) :
(lift.symm F).val = (F.comp (inlAlgHom _ _ _), F ε) := rfl
#adaptation_note /-- https://github.com/leanprover/lean4/pull/5338
The new unused variable linter flags `{fe : (A ââ[R] B) Ã B // _}`. -/
set_option linter.unusedVariables false in
/-- When applied to `inl`, `DualNumber.lift` applies the map `f : A ââ[R] B`. -/
@[simp] theorem lift_apply_inl (fe : {fe : (A ââ[R] B) Ã B // _}) (a : A) :
lift fe (inl a : A[ε]) = fe.val.1 a := by
rw [lift_apply_apply, fst_inl, snd_inl, map_zero, zero_mul, add_zero]
#adaptation_note /-- https://github.com/leanprover/lean4/pull/5338
The new unused variable linter flags `{fe : (A ââ[R] B) Ã B // _}`. -/
set_option linter.unusedVariables false in
/-- Scaling on the left is sent by `DualNumber.lift` to multiplication on the left -/
| @[simp] theorem lift_smul (fe : {fe : (A ââ[R] B) à B // _}) (a : A) (ad : A[ε]) :
lift fe (a ⢠ad) = fe.val.1 a * lift fe ad := by
rw [â inl_mul_eq_smul, map_mul, lift_apply_inl]
| Mathlib/Algebra/DualNumber.lean | 164 | 166 |
/-
Copyright (c) 2023 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.Algebra.Homology.HomotopyCategory
import Mathlib.Algebra.Ring.NegOnePow
import Mathlib.CategoryTheory.Shift.Quotient
import Mathlib.CategoryTheory.Linear.LinearFunctor
import Mathlib.Tactic.Linarith
/-!
# The shift on cochain complexes and on the homotopy category
In this file, we show that for any preadditive category `C`, the categories
`CochainComplex C â€` and `HomotopyCategory C (ComplexShape.up â€)` are
equipped with a shift by `â€`.
We also show that if `F : C ⥀ D` is an additive functor, then the functors
`F.mapHomologicalComplex (ComplexShape.up â€)` and
`F.mapHomotopyCategory (ComplexShape.up â€)` commute with the shift by `â€`.
-/
assert_not_exists TwoSidedIdeal
universe v v' u u'
open CategoryTheory
variable (C : Type u) [Category.{v} C] [Preadditive C]
{D : Type u'} [Category.{v'} D] [Preadditive D]
namespace CochainComplex
open HomologicalComplex
/-- The shift functor by `n : â€` on `CochainComplex C â€` which sends a cochain
complex `K` to the complex which is `K.X (i + n)` in degree `i`, and which
multiplies the differentials by `(-1)^n`. -/
@[simps]
def shiftFunctor (n : â€) : CochainComplex C †⥀ CochainComplex C †where
obj K :=
{ X := fun i => K.X (i + n)
d := fun _ _ => n.negOnePow ⢠K.d _ _
d_comp_d' := by
intros
simp only [Linear.comp_units_smul, Linear.units_smul_comp, d_comp_d, smul_zero]
shape := fun i j hij => by
rw [K.shape, smul_zero]
intro hij'
apply hij
dsimp at hij' â¢
omega }
map Ï :=
{ f := fun _ => Ï.f _
comm' := by
intros
dsimp
simp only [Linear.comp_units_smul, Hom.comm, Linear.units_smul_comp] }
map_id := by intros; rfl
map_comp := by intros; rfl
instance (n : â€) : (shiftFunctor C n).Additive where
variable {C}
/-- The canonical isomorphism `((shiftFunctor C n).obj K).X i â
K.X m` when `m = i + n`. -/
@[simp]
def shiftFunctorObjXIso (K : CochainComplex C â€) (n i m : â€) (hm : m = i + n) :
((shiftFunctor C n).obj K).X i â
K.X m := K.XIsoOfEq hm.symm
section
variable (C)
attribute [local simp] XIsoOfEq_hom_naturality
/-- The shift functor by `n` on `CochainComplex C â€` identifies to the identity
functor when `n = 0`. -/
@[simps!]
def shiftFunctorZero' (n : â€) (h : n = 0) :
shiftFunctor C n â
ð _ :=
NatIso.ofComponents (fun K => Hom.isoOfComponents
(fun i => K.shiftFunctorObjXIso _ _ _ (by omega))
(fun _ _ _ => by dsimp; simp [h])) (fun _ ⊠by ext; dsimp; simp)
/-- The compatibility of the shift functors on `CochainComplex C â€` with respect
to the addition of integers. -/
@[simps!]
def shiftFunctorAdd' (nâ nâ nââ : â€) (h : nâ + nâ = nââ) :
shiftFunctor C nââ â
shiftFunctor C nâ â shiftFunctor C nâ :=
NatIso.ofComponents (fun K => Hom.isoOfComponents
(fun i => K.shiftFunctorObjXIso _ _ _ (by omega))
(fun _ _ _ => by
subst h
dsimp
simp only [add_comm nâ nâ, Int.negOnePow_add, Linear.units_smul_comp,
Linear.comp_units_smul, d_comp_XIsoOfEq_hom, smul_smul, XIsoOfEq_hom_comp_d]))
(by intros; ext; dsimp; simp)
attribute [local simp] XIsoOfEq
instance : HasShift (CochainComplex C â€) †:= hasShiftMk _ _
{ F := shiftFunctor C
zero := shiftFunctorZero' C _ rfl
add := fun nâ nâ => shiftFunctorAdd' C nâ nâ _ rfl }
instance (n : â€) :
(CategoryTheory.shiftFunctor (HomologicalComplex C (ComplexShape.up â€)) n).Additive :=
(inferInstance : (CochainComplex.shiftFunctor C n).Additive)
end
@[simp]
lemma shiftFunctor_obj_X' (K : CochainComplex C â€) (n p : â€) :
((CategoryTheory.shiftFunctor (CochainComplex C â€) n).obj K).X p = K.X (p + n) := rfl
@[simp]
lemma shiftFunctor_map_f' {K L : CochainComplex C â€} (Ï : K â¶ L) (n p : â€) :
((CategoryTheory.shiftFunctor (CochainComplex C â€) n).map Ï).f p = Ï.f (p + n) := rfl
@[simp]
lemma shiftFunctor_obj_d' (K : CochainComplex C â€) (n i j : â€) :
((CategoryTheory.shiftFunctor (CochainComplex C â€) n).obj K).d i j =
n.negOnePow ⢠K.d _ _ := rfl
lemma shiftFunctorAdd_inv_app_f (K : CochainComplex C â€) (a b n : â€) :
((shiftFunctorAdd (CochainComplex C â€) a b).inv.app K).f n =
(K.XIsoOfEq (by dsimp; rw [add_comm a, add_assoc])).hom := rfl
lemma shiftFunctorAdd_hom_app_f (K : CochainComplex C â€) (a b n : â€) :
((shiftFunctorAdd (CochainComplex C â€) a b).hom.app K).f n =
(K.XIsoOfEq (by dsimp; rw [add_comm a, add_assoc])).hom := by
have : IsIso (((shiftFunctorAdd (CochainComplex C â€) a b).inv.app K).f n) := by
rw [shiftFunctorAdd_inv_app_f]
infer_instance
rw [â cancel_mono (((shiftFunctorAdd (CochainComplex C â€) a b).inv.app K).f n),
â comp_f, Iso.hom_inv_id_app, id_f, shiftFunctorAdd_inv_app_f]
simp only [XIsoOfEq, eqToIso.hom, eqToHom_trans, eqToHom_refl]
lemma shiftFunctorAdd'_inv_app_f' (K : CochainComplex C â€) (a b ab : â€) (h : a + b = ab) (n : â€) :
((CategoryTheory.shiftFunctorAdd' (CochainComplex C â€) a b ab h).inv.app K).f n =
(K.XIsoOfEq (by dsimp; rw [â h, add_assoc, add_comm a])).hom := by
subst h
rw [shiftFunctorAdd'_eq_shiftFunctorAdd, shiftFunctorAdd_inv_app_f]
lemma shiftFunctorAdd'_hom_app_f' (K : CochainComplex C â€) (a b ab : â€) (h : a + b = ab) (n : â€) :
((CategoryTheory.shiftFunctorAdd' (CochainComplex C â€) a b ab h).hom.app K).f n =
(K.XIsoOfEq (by dsimp; rw [â h, add_assoc, add_comm a])).hom := by
subst h
rw [shiftFunctorAdd'_eq_shiftFunctorAdd, shiftFunctorAdd_hom_app_f]
|
lemma shiftFunctorZero_inv_app_f (K : CochainComplex C â€) (n : â€) :
((CategoryTheory.shiftFunctorZero (CochainComplex C â€) â€).inv.app K).f n =
(K.XIsoOfEq (by dsimp; rw [add_zero])).hom := rfl
lemma shiftFunctorZero_hom_app_f (K : CochainComplex C â€) (n : â€) :
((CategoryTheory.shiftFunctorZero (CochainComplex C â€) â€).hom.app K).f n =
(K.XIsoOfEq (by dsimp; rw [add_zero])).hom := by
have : IsIso (((shiftFunctorZero (CochainComplex C â€) â€).inv.app K).f n) := by
| Mathlib/Algebra/Homology/HomotopyCategory/Shift.lean | 153 | 161 |
/-
Copyright (c) 2022 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.CategoryTheory.Abelian.Basic
import Mathlib.CategoryTheory.Adjunction.Limits
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.AbelianImages
import Mathlib.CategoryTheory.Preadditive.Transfer
/-!
# Transferring "abelian-ness" across a functor
If `C` is an additive category, `D` is an abelian category,
we have `F : C ⥀ D` `G : D ⥀ C` (both preserving zero morphisms),
`G` is left exact (that is, preserves finite limits),
and further we have `adj : G ⣠F` and `i : F â G â
ð C`,
then `C` is also abelian.
A particular example is the transfer of `Abelian` instances from a category `C` to `ShrinkHoms C`;
see `ShrinkHoms.abelian`. In this case, we also transfer the `Preadditive` structure.
See <https://stacks.math.columbia.edu/tag/03A3>
## Notes
The hypotheses, following the statement from the Stacks project,
may appear surprising: we don't ask that the counit of the adjunction is an isomorphism,
but just that we have some potentially unrelated isomorphism `i : F â G â
ð C`.
However Lemma A1.1.1 from [Elephant] shows that in this situation the counit itself
must be an isomorphism, and thus that `C` is a reflective subcategory of `D`.
Someone may like to formalize that lemma, and restate this theorem in terms of `Reflective`.
(That lemma has a nice string diagrammatic proof that holds in any bicategory.)
-/
noncomputable section
namespace CategoryTheory
open Limits
universe vâ vâ uâ uâ
namespace AbelianOfAdjunction
variable {C : Type uâ} [Category.{vâ} C] [Preadditive C]
variable {D : Type uâ} [Category.{vâ} D] [Abelian D]
variable (F : C ⥀ D)
variable (G : D ⥀ C) [Functor.PreservesZeroMorphisms G]
/-- No point making this an instance, as it requires `i`. -/
theorem hasKernels [PreservesFiniteLimits G] (i : F â G â
ð C) : HasKernels C :=
{ has_limit := fun f => by
have := NatIso.naturality_1 i f
simp? at this says
simp only [Functor.id_obj, Functor.comp_obj, Functor.comp_map, Functor.id_map] at this
rw [â this]
haveI : HasKernel (G.map (F.map f) â« i.hom.app _) := Limits.hasKernel_comp_mono _ _
apply Limits.hasKernel_iso_comp }
/-- No point making this an instance, as it requires `i` and `adj`. -/
| theorem hasCokernels (i : F â G â
ð C) (adj : G ⣠F) : HasCokernels C :=
{ has_colimit := fun f => by
have : PreservesColimits G := adj.leftAdjoint_preservesColimits
have := NatIso.naturality_1 i f
simp? at this says
simp only [Functor.id_obj, Functor.comp_obj, Functor.comp_map, Functor.id_map] at this
rw [â this]
haveI : HasCokernel (G.map (F.map f) â« i.hom.app _) := Limits.hasCokernel_comp_iso _ _
apply Limits.hasCokernel_epi_comp }
| Mathlib/CategoryTheory/Abelian/Transfer.lean | 64 | 72 |
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.Algebra.Order.BigOperators.Group.List
import Mathlib.Order.WellFoundedSet
/-!
# Pointwise instances on `Submonoid`s and `AddSubmonoid`s
This file provides:
* `Submonoid.inv`
* `AddSubmonoid.neg`
and the actions
* `Submonoid.pointwiseMulAction`
* `AddSubmonoid.pointwiseAddAction`
which matches the action of `Set.mulActionSet`.
## Implementation notes
Most of the lemmas in this file are direct copies of lemmas from
`Mathlib.Algebra.Group.Pointwise.Set.Basic` and `Mathlib.Algebra.Group.Action.Pointwise.Set.Basic`.
While the statements of these lemmas are defeq, we repeat them here due to them not being
syntactically equal. Before adding new lemmas here, consider if they would also apply to the action
on `Set`s.
-/
assert_not_exists GroupWithZero
open Set Pointwise
variable {α G M R A S : Type*}
variable [Monoid M] [AddMonoid A]
@[to_additive (attr := simp, norm_cast)]
lemma coe_mul_coe [SetLike S M] [SubmonoidClass S M] (H : S) : H * H = (H : Set M) := by
aesop (add simp mem_mul)
set_option linter.unusedVariables false in
@[to_additive (attr := simp)]
lemma coe_set_pow [SetLike S M] [SubmonoidClass S M] :
â {n} (hn : n â 0) (H : S), (H ^ n : Set M) = H
| 1, _, H => by simp
| n + 2, _, H => by rw [pow_succ, coe_set_pow n.succ_ne_zero, coe_mul_coe]
/-! Some lemmas about pointwise multiplication and submonoids. Ideally we put these in
`GroupTheory.Submonoid.Basic`, but currently we cannot because that file is imported by this. -/
namespace Submonoid
variable {s t u : Set M}
@[to_additive]
theorem mul_subset {S : Submonoid M} (hs : s â S) (ht : t â S) : s * t â S :=
mul_subset_iff.2 fun _x hx _y hy ⊠mul_mem (hs hx) (ht hy)
@[to_additive]
theorem mul_subset_closure (hs : s â u) (ht : t â u) : s * t â Submonoid.closure u :=
mul_subset (Subset.trans hs Submonoid.subset_closure) (Subset.trans ht Submonoid.subset_closure)
@[to_additive]
theorem coe_mul_self_eq (s : Submonoid M) : (s : Set M) * s = s := by
ext x
refine âš?_, fun h => âšx, h, 1, s.one_mem, mul_one xâ©â©
rintro âša, ha, b, hb, rflâ©
exact s.mul_mem ha hb
@[to_additive]
theorem closure_mul_le (S T : Set M) : closure (S * T) †closure S â closure T :=
sInf_le fun _x âš_s, hs, _t, ht, hxâ© => hx âž
(closure S â closure T).mul_mem (SetLike.le_def.mp le_sup_left <| subset_closure hs)
(SetLike.le_def.mp le_sup_right <| subset_closure ht)
@[to_additive]
lemma closure_pow_le : â {n}, n â 0 â closure (s ^ n) †closure s
| 1, _ => by simp
| n + 2, _ =>
calc
closure (s ^ (n + 2))
_ = closure (s ^ (n + 1) * s) := by rw [pow_succ]
_ †closure (s ^ (n + 1)) â closure s := closure_mul_le ..
_ †closure s â closure s := by gcongr ?_ â _; exact closure_pow_le n.succ_ne_zero
_ = closure s := sup_idem _
@[to_additive]
lemma closure_pow {n : â} (hs : 1 â s) (hn : n â 0) : closure (s ^ n) = closure s :=
(closure_pow_le hn).antisymm <| by gcongr; exact subset_pow hs hn
@[to_additive]
theorem sup_eq_closure_mul (H K : Submonoid M) : H â K = closure ((H : Set M) * (K : Set M)) :=
le_antisymm
(sup_le (fun h hh => subset_closure âšh, hh, 1, K.one_mem, mul_one hâ©) fun k hk =>
subset_closure âš1, H.one_mem, k, hk, one_mul kâ©)
((closure_mul_le _ _).trans <| by rw [closure_eq, closure_eq])
@[to_additive]
theorem pow_smul_mem_closure_smul {N : Type*} [CommMonoid N] [MulAction M N] [IsScalarTower M N N]
(r : M) (s : Set N) {x : N} (hx : x â closure s) : â n : â, r ^ n ⢠x â closure (r ⢠s) := by
induction hx using closure_induction with
| mem x hx => exact âš1, subset_closure âš_, hx, by rw [pow_one]â©â©
| one => exact âš0, by simpa using one_mem _â©
| mul x y _ _ hx hy =>
obtain âšâšnx, hxâ©, âšny, hyâ©â© := And.intro hx hy
use ny + nx
rw [pow_add, mul_smul, â smul_mul_assoc, mul_comm, â smul_mul_assoc]
exact mul_mem hy hx
variable [Group G]
/-- The submonoid with every element inverted. -/
@[to_additive "The additive submonoid with every element negated."]
protected def inv : Inv (Submonoid G) where
inv S :=
{ carrier := (S : Set G)â»Â¹
mul_mem' := fun ha hb => by rw [mem_inv, mul_inv_rev]; exact mul_mem hb ha
one_mem' := mem_inv.2 <| by rw [inv_one]; exact S.one_mem' }
scoped[Pointwise] attribute [instance] Submonoid.inv AddSubmonoid.neg
@[to_additive (attr := simp)]
theorem coe_inv (S : Submonoid G) : âSâ»Â¹ = (S : Set G)â»Â¹ :=
rfl
@[to_additive (attr := simp)]
theorem mem_inv {g : G} {S : Submonoid G} : g â Sâ»Â¹ â gâ»Â¹ â S :=
Iff.rfl
/-- Inversion is involutive on submonoids. -/
@[to_additive "Inversion is involutive on additive submonoids."]
def involutiveInv : InvolutiveInv (Submonoid G) :=
SetLike.coe_injective.involutiveInv _ fun _ => rfl
scoped[Pointwise] attribute [instance] Submonoid.involutiveInv AddSubmonoid.involutiveNeg
@[to_additive (attr := simp)]
theorem inv_le_inv (S T : Submonoid G) : Sâ»Â¹ †Tâ»Â¹ â S †T :=
SetLike.coe_subset_coe.symm.trans Set.inv_subset_inv
@[to_additive]
theorem inv_le (S T : Submonoid G) : Sâ»Â¹ †T â S †Tâ»Â¹ :=
SetLike.coe_subset_coe.symm.trans Set.inv_subset
/-- Pointwise inversion of submonoids as an order isomorphism. -/
@[to_additive (attr := simps!) "Pointwise negation of additive submonoids as an order isomorphism"]
def invOrderIso : Submonoid G âo Submonoid G where
toEquiv := Equiv.inv _
map_rel_iff' := inv_le_inv _ _
@[to_additive]
theorem closure_inv (s : Set G) : closure sâ»Â¹ = (closure s)â»Â¹ := by
apply le_antisymm
· rw [closure_le, coe_inv, â Set.inv_subset, inv_inv]
exact subset_closure
· rw [inv_le, closure_le, coe_inv, â Set.inv_subset]
exact subset_closure
@[to_additive]
lemma mem_closure_inv (s : Set G) (x : G) : x â closure sâ»Â¹ â xâ»Â¹ â closure s := by
rw [closure_inv, mem_inv]
@[to_additive (attr := simp)]
theorem inv_inf (S T : Submonoid G) : (S â T)â»Â¹ = Sâ»Â¹ â Tâ»Â¹ :=
SetLike.coe_injective Set.inter_inv
@[to_additive (attr := simp)]
theorem inv_sup (S T : Submonoid G) : (S â T)â»Â¹ = Sâ»Â¹ â Tâ»Â¹ :=
(invOrderIso : Submonoid G âo Submonoid G).map_sup S T
@[to_additive (attr := simp)]
theorem inv_bot : (⥠: Submonoid G)â»Â¹ = ⥠:=
SetLike.coe_injective <| (Set.inv_singleton 1).trans <| congr_arg _ inv_one
@[to_additive (attr := simp)]
theorem inv_top : (†: Submonoid G)â»Â¹ = †:=
SetLike.coe_injective <| Set.inv_univ
@[to_additive (attr := simp)]
theorem inv_iInf {ι : Sort*} (S : ι â Submonoid G) : (âš
i, S i)â»Â¹ = âš
i, (S i)â»Â¹ :=
(invOrderIso : Submonoid G âo Submonoid G).map_iInf _
@[to_additive (attr := simp)]
theorem inv_iSup {ι : Sort*} (S : ι â Submonoid G) : (âš i, S i)â»Â¹ = âš i, (S i)â»Â¹ :=
(invOrderIso : Submonoid G âo Submonoid G).map_iSup _
end Submonoid
namespace Submonoid
section Monoid
variable [Monoid α] [MulDistribMulAction α M]
-- todo: add `to_additive`?
/-- The action on a submonoid corresponding to applying the action to every element.
This is available as an instance in the `Pointwise` locale. -/
protected def pointwiseMulAction : MulAction α (Submonoid M) where
smul a S := S.map (MulDistribMulAction.toMonoidEnd _ M a)
one_smul S := by
change S.map _ = S
simpa only [map_one] using S.map_id
mul_smul _ _ S :=
(congr_arg (fun f : Monoid.End M => S.map f) (MonoidHom.map_mul _ _ _)).trans
(S.map_map _ _).symm
scoped[Pointwise] attribute [instance] Submonoid.pointwiseMulAction
@[simp]
theorem coe_pointwise_smul (a : α) (S : Submonoid M) : â(a ⢠S) = a ⢠(S : Set M) :=
rfl
theorem smul_mem_pointwise_smul (m : M) (a : α) (S : Submonoid M) : m â S â a ⢠m â a ⢠S :=
(Set.smul_mem_smul_set : _ â _ â a ⢠(S : Set M))
instance : CovariantClass α (Submonoid M) HSMul.hSMul LE.le :=
âšfun _ _ => image_subset _â©
theorem mem_smul_pointwise_iff_exists (m : M) (a : α) (S : Submonoid M) :
m â a ⢠S â â s : M, s â S â§ a ⢠s = m :=
(Set.mem_smul_set : m â a ⢠(S : Set M) â _)
@[simp]
theorem smul_bot (a : α) : a ⢠(⥠: Submonoid M) = ⥠:=
map_bot _
theorem smul_sup (a : α) (S T : Submonoid M) : a ⢠(S â T) = a ⢠S â a ⢠T :=
map_sup _ _ _
theorem smul_closure (a : α) (s : Set M) : a ⢠closure s = closure (a ⢠s) :=
MonoidHom.map_mclosure _ _
lemma pointwise_isCentralScalar [MulDistribMulAction αáµáµáµ M] [IsCentralScalar α M] :
IsCentralScalar α (Submonoid M) :=
âšfun _ S => (congr_arg fun f : Monoid.End M => S.map f) <| MonoidHom.ext <| op_smul_eq_smul _â©
scoped[Pointwise] attribute [instance] Submonoid.pointwise_isCentralScalar
end Monoid
section Group
variable [Group α] [MulDistribMulAction α M]
@[simp]
theorem smul_mem_pointwise_smul_iff {a : α} {S : Submonoid M} {x : M} : a ⢠x â a ⢠S â x â S :=
smul_mem_smul_set_iff
theorem mem_pointwise_smul_iff_inv_smul_mem {a : α} {S : Submonoid M} {x : M} :
x â a ⢠S â aâ»Â¹ ⢠x â S :=
mem_smul_set_iff_inv_smul_mem
theorem mem_inv_pointwise_smul_iff {a : α} {S : Submonoid M} {x : M} : x â aâ»Â¹ ⢠S â a ⢠x â S :=
mem_inv_smul_set_iff
@[simp]
theorem pointwise_smul_le_pointwise_smul_iff {a : α} {S T : Submonoid M} : a ⢠S †a ⢠T â S †T :=
smul_set_subset_smul_set_iff
theorem pointwise_smul_subset_iff {a : α} {S T : Submonoid M} : a ⢠S †T â S †aâ»Â¹ ⢠T :=
smul_set_subset_iff_subset_inv_smul_set
theorem subset_pointwise_smul_iff {a : α} {S T : Submonoid M} : S †a ⢠T â aâ»Â¹ ⢠S †T :=
subset_smul_set_iff
end Group
end Submonoid
namespace Set.IsPWO
variable [CommMonoid α] [PartialOrder α] [IsOrderedCancelMonoid α] {s : Set α}
@[to_additive]
theorem submonoid_closure (hpos : â x : α, x â s â 1 †x) (h : s.IsPWO) :
IsPWO (Submonoid.closure s : Set α) := by
rw [Submonoid.closure_eq_image_prod]
refine (h.partiallyWellOrderedOn_sublistForallâ (· †·)).image_of_monotone_on ?_
exact fun l1 _ l2 hl2 h12 => h12.prod_le_prod' fun x hx => hpos x <| hl2 x hx
end Set.IsPWO
| Mathlib/Algebra/Group/Submonoid/Pointwise.lean | 512 | 516 | |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Algebra.MvPolynomial.Degrees
/-!
# Variables of polynomials
This file establishes many results about the variable sets of a multivariate polynomial.
The *variable set* of a polynomial $P \in R[X]$ is a `Finset` containing each $x \in X$
that appears in a monomial in $P$.
## Main declarations
* `MvPolynomial.vars p` : the finset of variables occurring in `p`.
For example if `p = xâŽy+yz` then `vars p = {x, y, z}`
## Notation
As in other polynomial files, we typically use the notation:
+ `Ï Ï : Type*` (indexing the variables)
+ `R : Type*` `[CommSemiring R]` (the coefficients)
+ `s : Ï ââ â`, a function from `Ï` to `â` which is zero away from a finite set.
This will give rise to a monomial in `MvPolynomial Ï R` which mathematicians might call `X^s`
+ `r : R`
+ `i : Ï`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians
+ `p : MvPolynomial Ï R`
-/
noncomputable section
open Set Function Finsupp AddMonoidAlgebra
universe u v w
variable {R : Type u} {S : Type v}
namespace MvPolynomial
variable {Ï Ï : Type*} {r : R} {e : â} {n m : Ï} {s : Ï ââ â}
section CommSemiring
variable [CommSemiring R] {p q : MvPolynomial Ï R}
section Vars
/-! ### `vars` -/
/-- `vars p` is the set of variables appearing in the polynomial `p` -/
def vars (p : MvPolynomial Ï R) : Finset Ï :=
letI := Classical.decEq Ï
p.degrees.toFinset
theorem vars_def [DecidableEq Ï] (p : MvPolynomial Ï R) : p.vars = p.degrees.toFinset := by
rw [vars]
convert rfl
@[simp]
theorem vars_0 : (0 : MvPolynomial Ï R).vars = â
:= by
classical rw [vars_def, degrees_zero, Multiset.toFinset_zero]
@[simp]
theorem vars_monomial (h : r â 0) : (monomial s r).vars = s.support := by
classical rw [vars_def, degrees_monomial_eq _ _ h, Finsupp.toFinset_toMultiset]
@[simp]
theorem vars_C : (C r : MvPolynomial Ï R).vars = â
:= by
classical rw [vars_def, degrees_C, Multiset.toFinset_zero]
@[simp]
theorem vars_X [Nontrivial R] : (X n : MvPolynomial Ï R).vars = {n} := by
rw [X, vars_monomial (one_ne_zero' R), Finsupp.support_single_ne_zero _ (one_ne_zero' â)]
theorem mem_vars (i : Ï) : i â p.vars â â d â p.support, i â d.support := by
classical simp only [vars_def, Multiset.mem_toFinset, mem_degrees, mem_support_iff, exists_prop]
theorem mem_support_not_mem_vars_zero {f : MvPolynomial Ï R} {x : Ï ââ â} (H : x â f.support)
{v : Ï} (h : v â vars f) : x v = 0 := by
contrapose! h
exact (mem_vars v).mpr âšx, H, Finsupp.mem_support_iff.mpr hâ©
theorem vars_add_subset [DecidableEq Ï] (p q : MvPolynomial Ï R) :
(p + q).vars â p.vars ⪠q.vars := by
intro x hx
simp only [vars_def, Finset.mem_union, Multiset.mem_toFinset] at hx â¢
simpa using Multiset.mem_of_le degrees_add_le hx
theorem vars_add_of_disjoint [DecidableEq Ï] (h : Disjoint p.vars q.vars) :
(p + q).vars = p.vars ⪠q.vars := by
refine (vars_add_subset p q).antisymm fun x hx => ?_
simp only [vars_def, Multiset.disjoint_toFinset] at h hx â¢
rwa [degrees_add_of_disjoint h, Multiset.toFinset_union]
section Mul
theorem vars_mul [DecidableEq Ï] (Ï Ï : MvPolynomial Ï R) : (Ï * Ï).vars â Ï.vars ⪠Ï.vars := by
simp_rw [vars_def, â Multiset.toFinset_add, Multiset.toFinset_subset]
exact Multiset.subset_of_le degrees_mul_le
@[simp]
theorem vars_one : (1 : MvPolynomial Ï R).vars = â
:=
vars_C
theorem vars_pow (Ï : MvPolynomial Ï R) (n : â) : (Ï ^ n).vars â Ï.vars := by
classical
induction n with
| zero => simp
| succ n ih =>
rw [pow_succ']
apply Finset.Subset.trans (vars_mul _ _)
exact Finset.union_subset (Finset.Subset.refl _) ih
/-- The variables of the product of a family of polynomials
are a subset of the union of the sets of variables of each polynomial.
-/
theorem vars_prod {ι : Type*} [DecidableEq Ï] {s : Finset ι} (f : ι â MvPolynomial Ï R) :
(â i â s, f i).vars â s.biUnion fun i => (f i).vars := by
classical
induction s using Finset.induction_on with
| empty => simp
| insert _ _ hs hsub =>
simp only [hs, Finset.biUnion_insert, Finset.prod_insert, not_false_iff]
apply Finset.Subset.trans (vars_mul _ _)
exact Finset.union_subset_union (Finset.Subset.refl _) hsub
section IsDomain
variable {A : Type*} [CommRing A] [NoZeroDivisors A]
theorem vars_C_mul (a : A) (ha : a â 0) (Ï : MvPolynomial Ï A) :
(C a * Ï : MvPolynomial Ï A).vars = Ï.vars := by
ext1 i
simp only [mem_vars, exists_prop, mem_support_iff]
apply exists_congr
intro d
apply and_congr _ Iff.rfl
rw [coeff_C_mul, mul_ne_zero_iff, eq_true ha, true_and]
end IsDomain
end Mul
section Sum
variable {ι : Type*} (t : Finset ι) (Ï : ι â MvPolynomial Ï R)
theorem vars_sum_subset [DecidableEq Ï] :
(â i â t, Ï i).vars â Finset.biUnion t fun i => (Ï i).vars := by
classical
induction t using Finset.induction_on with
| empty => simp
| insert _ _ has hsum =>
rw [Finset.biUnion_insert, Finset.sum_insert has]
refine Finset.Subset.trans
(vars_add_subset _ _) (Finset.union_subset_union (Finset.Subset.refl _) ?_)
assumption
theorem vars_sum_of_disjoint [DecidableEq Ï] (h : Pairwise <| (Disjoint on fun i => (Ï i).vars)) :
(â i â t, Ï i).vars = Finset.biUnion t fun i => (Ï i).vars := by
classical
induction t using Finset.induction_on with
| empty => simp
| insert _ _ has hsum =>
rw [Finset.biUnion_insert, Finset.sum_insert has, vars_add_of_disjoint, hsum]
| unfold Pairwise onFun at h
rw [hsum]
simp only [Finset.disjoint_iff_ne] at h â¢
intro v hv v2 hv2
rw [Finset.mem_biUnion] at hv2
rcases hv2 with âši, his, hiâ©
refine h ?_ _ hv _ hi
rintro rfl
contradiction
| Mathlib/Algebra/MvPolynomial/Variables.lean | 180 | 189 |
/-
Copyright (c) 2023 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.CharP.Basic
import Mathlib.Algebra.CharP.Reduced
import Mathlib.FieldTheory.KummerPolynomial
import Mathlib.FieldTheory.Separable
/-!
# Perfect fields and rings
In this file we define perfect fields, together with a generalisation to (commutative) rings in
prime characteristic.
## Main definitions / statements:
* `PerfectRing`: a ring of characteristic `p` (prime) is said to be perfect in the sense of Serre,
if its absolute Frobenius map `x ⊠xáµ` is bijective.
* `PerfectField`: a field `K` is said to be perfect if every irreducible polynomial over `K` is
separable.
* `PerfectRing.toPerfectField`: a field that is perfect in the sense of Serre is a perfect field.
* `PerfectField.toPerfectRing`: a perfect field of characteristic `p` (prime) is perfect in the
sense of Serre.
* `PerfectField.ofCharZero`: all fields of characteristic zero are perfect.
* `PerfectField.ofFinite`: all finite fields are perfect.
* `PerfectField.separable_iff_squarefree`: a polynomial over a perfect field is separable iff
it is square-free.
* `Algebra.IsAlgebraic.isSeparable_of_perfectField`, `Algebra.IsAlgebraic.perfectField`:
if `L / K` is an algebraic extension, `K` is a perfect field, then `L / K` is separable,
and `L` is also a perfect field.
-/
open Function Polynomial
/-- A perfect ring of characteristic `p` (prime) in the sense of Serre.
NB: This is not related to the concept with the same name introduced by Bass (related to projective
covers of modules). -/
class PerfectRing (R : Type*) (p : â) [CommSemiring R] [ExpChar R p] : Prop where
/-- A ring is perfect if the Frobenius map is bijective. -/
bijective_frobenius : Bijective <| frobenius R p
section PerfectRing
variable (R : Type*) (p m n : â) [CommSemiring R] [ExpChar R p]
/-- For a reduced ring, surjectivity of the Frobenius map is a sufficient condition for perfection.
-/
lemma PerfectRing.ofSurjective (R : Type*) (p : â) [CommRing R] [ExpChar R p]
[IsReduced R] (h : Surjective <| frobenius R p) : PerfectRing R p :=
âšfrobenius_inj R p, hâ©
instance PerfectRing.ofFiniteOfIsReduced (R : Type*) [CommRing R] [ExpChar R p]
[Finite R] [IsReduced R] : PerfectRing R p :=
ofSurjective _ _ <| Finite.surjective_of_injective (frobenius_inj R p)
variable [PerfectRing R p]
@[simp]
theorem bijective_frobenius : Bijective (frobenius R p) := PerfectRing.bijective_frobenius
theorem bijective_iterateFrobenius : Bijective (iterateFrobenius R p n) :=
coe_iterateFrobenius R p n âž (bijective_frobenius R p).iterate n
@[simp]
theorem injective_frobenius : Injective (frobenius R p) := (bijective_frobenius R p).1
@[simp]
theorem surjective_frobenius : Surjective (frobenius R p) := (bijective_frobenius R p).2
/-- The Frobenius automorphism for a perfect ring. -/
@[simps! apply]
noncomputable def frobeniusEquiv : R â+* R :=
RingEquiv.ofBijective (frobenius R p) PerfectRing.bijective_frobenius
@[simp]
theorem coe_frobeniusEquiv : â(frobeniusEquiv R p) = frobenius R p := rfl
theorem frobeniusEquiv_def (x : R) : frobeniusEquiv R p x = x ^ p := rfl
/-- The iterated Frobenius automorphism for a perfect ring. -/
@[simps! apply]
noncomputable def iterateFrobeniusEquiv : R â+* R :=
RingEquiv.ofBijective (iterateFrobenius R p n) (bijective_iterateFrobenius R p n)
@[simp]
theorem coe_iterateFrobeniusEquiv : â(iterateFrobeniusEquiv R p n) = iterateFrobenius R p n := rfl
theorem iterateFrobeniusEquiv_def (x : R) : iterateFrobeniusEquiv R p n x = x ^ p ^ n := rfl
theorem iterateFrobeniusEquiv_add_apply (x : R) : iterateFrobeniusEquiv R p (m + n) x =
iterateFrobeniusEquiv R p m (iterateFrobeniusEquiv R p n x) :=
iterateFrobenius_add_apply R p m n x
theorem iterateFrobeniusEquiv_add : iterateFrobeniusEquiv R p (m + n) =
(iterateFrobeniusEquiv R p n).trans (iterateFrobeniusEquiv R p m) :=
RingEquiv.ext (iterateFrobeniusEquiv_add_apply R p m n)
theorem iterateFrobeniusEquiv_symm_add_apply (x : R) : (iterateFrobeniusEquiv R p (m + n)).symm x =
(iterateFrobeniusEquiv R p m).symm ((iterateFrobeniusEquiv R p n).symm x) :=
(iterateFrobeniusEquiv R p (m + n)).injective <| by rw [RingEquiv.apply_symm_apply, add_comm,
iterateFrobeniusEquiv_add_apply, RingEquiv.apply_symm_apply, RingEquiv.apply_symm_apply]
theorem iterateFrobeniusEquiv_symm_add : (iterateFrobeniusEquiv R p (m + n)).symm =
(iterateFrobeniusEquiv R p n).symm.trans (iterateFrobeniusEquiv R p m).symm :=
RingEquiv.ext (iterateFrobeniusEquiv_symm_add_apply R p m n)
theorem iterateFrobeniusEquiv_zero_apply (x : R) : iterateFrobeniusEquiv R p 0 x = x := by
rw [iterateFrobeniusEquiv_def, pow_zero, pow_one]
theorem iterateFrobeniusEquiv_one_apply (x : R) : iterateFrobeniusEquiv R p 1 x = x ^ p := by
rw [iterateFrobeniusEquiv_def, pow_one]
@[simp]
theorem iterateFrobeniusEquiv_zero : iterateFrobeniusEquiv R p 0 = RingEquiv.refl R :=
RingEquiv.ext (iterateFrobeniusEquiv_zero_apply R p)
@[simp]
theorem iterateFrobeniusEquiv_one : iterateFrobeniusEquiv R p 1 = frobeniusEquiv R p :=
RingEquiv.ext (iterateFrobeniusEquiv_one_apply R p)
theorem iterateFrobeniusEquiv_eq_pow : iterateFrobeniusEquiv R p n = frobeniusEquiv R p ^ n :=
DFunLike.ext' <| show _ = â(RingAut.toPerm _ _) by
rw [map_pow, Equiv.Perm.coe_pow]; exact (pow_iterate p n).symm
theorem iterateFrobeniusEquiv_symm :
(iterateFrobeniusEquiv R p n).symm = (frobeniusEquiv R p).symm ^ n := by
rw [iterateFrobeniusEquiv_eq_pow]; exact (inv_pow _ _).symm
@[simp]
theorem frobeniusEquiv_symm_apply_frobenius (x : R) :
(frobeniusEquiv R p).symm (frobenius R p x) = x :=
leftInverse_surjInv PerfectRing.bijective_frobenius x
@[simp]
theorem frobenius_apply_frobeniusEquiv_symm (x : R) :
frobenius R p ((frobeniusEquiv R p).symm x) = x :=
surjInv_eq _ _
@[simp]
theorem frobenius_comp_frobeniusEquiv_symm :
(frobenius R p).comp (frobeniusEquiv R p).symm = RingHom.id R := by
ext; simp
@[simp]
theorem frobeniusEquiv_symm_comp_frobenius :
((frobeniusEquiv R p).symm : R â+* R).comp (frobenius R p) = RingHom.id R := by
ext; simp
@[simp]
theorem frobeniusEquiv_symm_pow_p (x : R) : ((frobeniusEquiv R p).symm x) ^ p = x :=
frobenius_apply_frobeniusEquiv_symm R p x
theorem injective_pow_p {x y : R} (h : x ^ p = y ^ p) : x = y := (frobeniusEquiv R p).injective h
lemma polynomial_expand_eq (f : R[X]) :
expand R p f = (f.map (frobeniusEquiv R p).symm) ^ p := by
rw [â (f.map (S := R) (frobeniusEquiv R p).symm).expand_char p, map_expand, map_map,
frobenius_comp_frobeniusEquiv_symm, map_id]
@[simp]
theorem not_irreducible_expand (R p) [CommSemiring R] [Fact p.Prime] [CharP R p] [PerfectRing R p]
(f : R[X]) : ¬ Irreducible (expand R p f) := by
rw [polynomial_expand_eq]
exact not_irreducible_pow (Fact.out : p.Prime).ne_one
instance instPerfectRingProd (S : Type*) [CommSemiring S] [ExpChar S p] [PerfectRing S p] :
PerfectRing (R Ã S) p where
bijective_frobenius := (bijective_frobenius R p).prodMap (bijective_frobenius S p)
end PerfectRing
/-- A perfect field.
See also `PerfectRing` for a generalisation in positive characteristic. -/
class PerfectField (K : Type*) [Field K] : Prop where
/-- A field is perfect if every irreducible polynomial is separable. -/
separable_of_irreducible : â {f : K[X]}, Irreducible f â f.Separable
lemma PerfectRing.toPerfectField (K : Type*) (p : â)
[Field K] [ExpChar K p] [PerfectRing K p] : PerfectField K := by
obtain hp | âšhpâ© := â¹ExpChar K pâº
· exact âšIrreducible.separableâ©
refine PerfectField.mk fun hf ⊠?_
rcases separable_or p hf with h | âš-, g, -, rflâ©
· assumption
· exfalso; revert hf; haveI := Fact.mk hp; simp
namespace PerfectField
variable {K : Type*} [Field K]
instance ofCharZero [CharZero K] : PerfectField K := âšIrreducible.separableâ©
instance ofFinite [Finite K] : PerfectField K := by
obtain âšp, _instPâ© := CharP.exists K
have : Fact p.Prime := âšCharP.char_is_prime K pâ©
exact PerfectRing.toPerfectField K p
variable [PerfectField K]
/-- A perfect field of characteristic `p` (prime) is a perfect ring. -/
instance toPerfectRing (p : â) [hp : ExpChar K p] : PerfectRing K p := by
refine PerfectRing.ofSurjective _ _ fun y ⊠?_
rcases hp with _ | hp
· simp [frobenius]
rw [â not_forall_not]
apply mt (X_pow_sub_C_irreducible_of_prime hp)
apply mt separable_of_irreducible
simp [separable_def, isCoprime_zero_right, isUnit_iff_degree_eq_zero,
derivative_X_pow, degree_X_pow_sub_C hp.pos, hp.ne_zero]
theorem separable_iff_squarefree {g : K[X]} : g.Separable â Squarefree g := by
refine âšSeparable.squarefree, fun sqf ⊠isCoprime_of_irreducible_dvd (sqf.ne_zero ·.1) ?_â©
rintro p (h : Irreducible p) âšq, rflâ© (dvd : p ⣠derivative (p * q))
replace dvd : p ⣠q := by
rw [derivative_mul, dvd_add_left (dvd_mul_right p _)] at dvd
exact (separable_of_irreducible h).dvd_of_dvd_mul_left dvd
exact (h.1 : ¬ IsUnit p) (sqf _ <| mul_dvd_mul_left _ dvd)
end PerfectField
/-- If `L / K` is an algebraic extension, `K` is a perfect field, then `L / K` is separable. -/
instance Algebra.IsAlgebraic.isSeparable_of_perfectField {K L : Type*} [Field K] [Field L]
[Algebra K L] [Algebra.IsAlgebraic K L] [PerfectField K] : Algebra.IsSeparable K L :=
âšfun x ⊠PerfectField.separable_of_irreducible <|
minpoly.irreducible (Algebra.IsIntegral.isIntegral x)â©
/-- If `L / K` is an algebraic extension, `K` is a perfect field, then so is `L`. -/
theorem Algebra.IsAlgebraic.perfectField {K L : Type*} [Field K] [Field L] [Algebra K L]
[Algebra.IsAlgebraic K L] [PerfectField K] : PerfectField L := âšfun {f} hf ⊠by
obtain âš_, _, hi, hâ© := hf.exists_dvd_monic_irreducible_of_isIntegral (K := K)
exact (PerfectField.separable_of_irreducible hi).map |>.of_dvd hâ©
namespace Polynomial
variable {R : Type*} [CommRing R] [IsDomain R] (p n : â) [ExpChar R p] (f : R[X])
open Multiset
theorem roots_expand_pow_map_iterateFrobenius_le :
(expand R (p ^ n) f).roots.map (iterateFrobenius R p n) †p ^ n ⢠f.roots := by
classical
refine le_iff_count.2 fun r ⊠?_
by_cases h : â s, r = s ^ p ^ n
· obtain âšs, rflâ© := h
simp_rw [count_nsmul, count_roots, â rootMultiplicity_expand_pow, â count_roots, count_map,
count_eq_card_filter_eq]
exact card_le_card (monotone_filter_right _ fun _ h ⊠iterateFrobenius_inj R p n h)
convert Nat.zero_le _
simp_rw [count_map, card_eq_zero]
exact ext' fun t ⊠count_zero t âž count_filter_of_neg fun h' ⊠h âšt, h'â©
theorem roots_expand_map_frobenius_le :
(expand R p f).roots.map (frobenius R p) †p ⢠f.roots := by
rw [â iterateFrobenius_one]
convert â roots_expand_pow_map_iterateFrobenius_le p 1 f <;> apply pow_one
theorem roots_expand_pow_image_iterateFrobenius_subset [DecidableEq R] :
(expand R (p ^ n) f).roots.toFinset.image (iterateFrobenius R p n) â f.roots.toFinset := by
rw [Finset.image_toFinset, â (roots f).toFinset_nsmul _ (expChar_pow_pos R p n).ne',
toFinset_subset]
exact subset_of_le (roots_expand_pow_map_iterateFrobenius_le p n f)
theorem roots_expand_image_frobenius_subset [DecidableEq R] :
(expand R p f).roots.toFinset.image (frobenius R p) â f.roots.toFinset := by
rw [â iterateFrobenius_one]
convert â roots_expand_pow_image_iterateFrobenius_subset p 1 f
apply pow_one
section PerfectRing
variable {p n f}
variable [PerfectRing R p]
theorem roots_expand_pow :
(expand R (p ^ n) f).roots = p ^ n ⢠f.roots.map (iterateFrobeniusEquiv R p n).symm := by
classical
refine ext' fun r ⊠?_
rw [count_roots, rootMultiplicity_expand_pow, â count_roots, count_nsmul, count_map,
count_eq_card_filter_eq]; congr; ext
exact (iterateFrobeniusEquiv R p n).eq_symm_apply.symm
theorem roots_expand : (expand R p f).roots = p ⢠f.roots.map (frobeniusEquiv R p).symm := by
conv_lhs => rw [â pow_one p, roots_expand_pow, iterateFrobeniusEquiv_eq_pow, pow_one]
rfl
theorem roots_X_pow_char_pow_sub_C {y : R} :
(X ^ p ^ n - C y).roots = p ^ n ⢠{(iterateFrobeniusEquiv R p n).symm y} := by
have H := roots_expand_pow (p := p) (n := n) (f := X - C y)
rwa [roots_X_sub_C, Multiset.map_singleton, map_sub, expand_X, expand_C] at H
theorem roots_X_pow_char_pow_sub_C_pow {y : R} {m : â} :
((X ^ p ^ n - C y) ^ m).roots = (m * p ^ n) ⢠{(iterateFrobeniusEquiv R p n).symm y} := by
rw [roots_pow, roots_X_pow_char_pow_sub_C, mul_smul]
theorem roots_X_pow_char_sub_C {y : R} :
(X ^ p - C y).roots = p ⢠{(frobeniusEquiv R p).symm y} := by
have H := roots_X_pow_char_pow_sub_C (p := p) (n := 1) (y := y)
rwa [pow_one, iterateFrobeniusEquiv_one] at H
theorem roots_X_pow_char_sub_C_pow {y : R} {m : â} :
((X ^ p - C y) ^ m).roots = (m * p) ⢠{(frobeniusEquiv R p).symm y} := by
have H := roots_X_pow_char_pow_sub_C_pow (p := p) (n := 1) (y := y) (m := m)
rwa [pow_one, iterateFrobeniusEquiv_one] at H
theorem roots_expand_pow_map_iterateFrobenius :
(expand R (p ^ n) f).roots.map (iterateFrobenius R p n) = p ^ n ⢠f.roots := by
simp_rw [â coe_iterateFrobeniusEquiv, roots_expand_pow, Multiset.map_nsmul,
Multiset.map_map, comp_apply, RingEquiv.apply_symm_apply, map_id']
theorem roots_expand_map_frobenius : (expand R p f).roots.map (frobenius R p) = p ⢠f.roots := by
simp [roots_expand, Multiset.map_nsmul]
theorem roots_expand_image_iterateFrobenius [DecidableEq R] :
(expand R (p ^ n) f).roots.toFinset.image (iterateFrobenius R p n) = f.roots.toFinset := by
rw [Finset.image_toFinset, roots_expand_pow_map_iterateFrobenius,
(roots f).toFinset_nsmul _ (expChar_pow_pos R p n).ne']
|
theorem roots_expand_image_frobenius [DecidableEq R] :
(expand R p f).roots.toFinset.image (frobenius R p) = f.roots.toFinset := by
rw [Finset.image_toFinset, roots_expand_map_frobenius,
| Mathlib/FieldTheory/Perfect.lean | 321 | 324 |
/-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen
-/
import Mathlib.Algebra.Algebra.Subalgebra.Tower
import Mathlib.Data.Finite.Sum
import Mathlib.Data.Matrix.Block
import Mathlib.Data.Matrix.Notation
import Mathlib.LinearAlgebra.Basis.Basic
import Mathlib.LinearAlgebra.Basis.Fin
import Mathlib.LinearAlgebra.Basis.Prod
import Mathlib.LinearAlgebra.Basis.SMul
import Mathlib.LinearAlgebra.Matrix.StdBasis
import Mathlib.RingTheory.AlgebraTower
import Mathlib.RingTheory.Ideal.Span
/-!
# Linear maps and matrices
This file defines the maps to send matrices to a linear map,
and to send linear maps between modules with a finite bases
to matrices. This defines a linear equivalence between linear maps
between finite-dimensional vector spaces and matrices indexed by
the respective bases.
## Main definitions
In the list below, and in all this file, `R` is a commutative ring (semiring
is sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite
types used for indexing.
* `LinearMap.toMatrix`: given bases `vâ : ι â Mâ` and `vâ : κ â Mâ`,
the `R`-linear equivalence from `Mâ ââ[R] Mâ` to `Matrix κ ι R`
* `Matrix.toLin`: the inverse of `LinearMap.toMatrix`
* `LinearMap.toMatrix'`: the `R`-linear equivalence from `(m â R) ââ[R] (n â R)`
to `Matrix m n R` (with the standard basis on `m â R` and `n â R`)
* `Matrix.toLin'`: the inverse of `LinearMap.toMatrix'`
* `algEquivMatrix`: given a basis indexed by `n`, the `R`-algebra equivalence between
`R`-endomorphisms of `M` and `Matrix n n R`
## Issues
This file was originally written without attention to non-commutative rings,
and so mostly only works in the commutative setting. This should be fixed.
In particular, `Matrix.mulVec` gives us a linear equivalence
`Matrix m n R ââ[R] (n â R) ââ[Ráµáµáµ] (m â R)`
while `Matrix.vecMul` gives us a linear equivalence
`Matrix m n R ââ[Ráµáµáµ] (m â R) ââ[R] (n â R)`.
At present, the first equivalence is developed in detail but only for commutative rings
(and we omit the distinction between `Ráµáµáµ` and `R`),
while the second equivalence is developed only in brief, but for not-necessarily-commutative rings.
Naming is slightly inconsistent between the two developments.
In the original (commutative) development `linear` is abbreviated to `lin`,
although this is not consistent with the rest of mathlib.
In the new (non-commutative) development `linear` is not abbreviated, and declarations use `_right`
to indicate they use the right action of matrices on vectors (via `Matrix.vecMul`).
When the two developments are made uniform, the names should be made uniform, too,
by choosing between `linear` and `lin` consistently,
and (presumably) adding `_left` where necessary.
## Tags
linear_map, matrix, linear_equiv, diagonal, det, trace
-/
noncomputable section
open LinearMap Matrix Set Submodule
section ToMatrixRight
variable {R : Type*} [Semiring R]
variable {l m n : Type*}
/-- `Matrix.vecMul M` is a linear map. -/
def Matrix.vecMulLinear [Fintype m] (M : Matrix m n R) : (m â R) ââ[R] n â R where
toFun x := x áµ¥* M
map_add' _ _ := funext fun _ ⊠add_dotProduct _ _ _
map_smul' _ _ := funext fun _ ⊠smul_dotProduct _ _ _
@[simp] theorem Matrix.vecMulLinear_apply [Fintype m] (M : Matrix m n R) (x : m â R) :
M.vecMulLinear x = x áµ¥* M := rfl
theorem Matrix.coe_vecMulLinear [Fintype m] (M : Matrix m n R) :
(M.vecMulLinear : _ â _) = M.vecMul := rfl
variable [Fintype m]
theorem range_vecMulLinear (M : Matrix m n R) :
LinearMap.range M.vecMulLinear = span R (range M.row) := by
letI := Classical.decEq m
simp_rw [range_eq_map, â iSup_range_single, Submodule.map_iSup, range_eq_map, â
Ideal.span_singleton_one, Ideal.span, Submodule.map_span, image_image, image_singleton,
Matrix.vecMulLinear_apply, iSup_span, range_eq_iUnion, iUnion_singleton_eq_range,
LinearMap.single, LinearMap.coe_mk, AddHom.coe_mk, row_def]
unfold vecMul
simp_rw [single_dotProduct, one_mul]
theorem Matrix.vecMul_injective_iff {R : Type*} [Ring R] {M : Matrix m n R} :
Function.Injective M.vecMul â LinearIndependent R M.row := by
rw [â coe_vecMulLinear]
simp only [â LinearMap.ker_eq_bot, Fintype.linearIndependent_iff, Submodule.eq_bot_iff,
LinearMap.mem_ker, vecMulLinear_apply, row_def]
refine âšfun h c h0 ⊠congr_fun <| h c ?_, fun h c h0 ⊠funext <| h c ?_â©
· rw [â h0]
ext i
simp [vecMul, dotProduct]
· rw [â h0]
ext j
simp [vecMul, dotProduct]
lemma Matrix.linearIndependent_rows_of_isUnit {R : Type*} [Ring R] {A : Matrix m m R}
[DecidableEq m] (ha : IsUnit A) : LinearIndependent R A.row := by
rw [â Matrix.vecMul_injective_iff]
exact Matrix.vecMul_injective_of_isUnit ha
section
variable [DecidableEq m]
/-- Linear maps `(m â R) ââ[R] (n â R)` are linearly equivalent over `Ráµáµáµ` to `Matrix m n R`,
by having matrices act by right multiplication.
-/
def LinearMap.toMatrixRight' : ((m â R) ââ[R] n â R) ââ[Ráµáµáµ] Matrix m n R where
toFun f i j := f (single R (fun _ ⊠R) i 1) j
invFun := Matrix.vecMulLinear
right_inv M := by
ext i j
simp
left_inv f := by
apply (Pi.basisFun R m).ext
intro j; ext i
simp
map_add' f g := by
ext i j
simp only [Pi.add_apply, LinearMap.add_apply, Matrix.add_apply]
map_smul' c f := by
ext i j
simp only [Pi.smul_apply, LinearMap.smul_apply, RingHom.id_apply, Matrix.smul_apply]
/-- A `Matrix m n R` is linearly equivalent over `Ráµáµáµ` to a linear map `(m â R) ââ[R] (n â R)`,
by having matrices act by right multiplication. -/
abbrev Matrix.toLinearMapRight' [DecidableEq m] : Matrix m n R ââ[Ráµáµáµ] (m â R) ââ[R] n â R :=
LinearEquiv.symm LinearMap.toMatrixRight'
@[simp]
theorem Matrix.toLinearMapRight'_apply (M : Matrix m n R) (v : m â R) :
(Matrix.toLinearMapRight') M v = v áµ¥* M := rfl
@[simp]
theorem Matrix.toLinearMapRight'_mul [Fintype l] [DecidableEq l] (M : Matrix l m R)
(N : Matrix m n R) :
Matrix.toLinearMapRight' (M * N) =
(Matrix.toLinearMapRight' N).comp (Matrix.toLinearMapRight' M) :=
LinearMap.ext fun _x ⊠(vecMul_vecMul _ M N).symm
theorem Matrix.toLinearMapRight'_mul_apply [Fintype l] [DecidableEq l] (M : Matrix l m R)
(N : Matrix m n R) (x) :
Matrix.toLinearMapRight' (M * N) x =
Matrix.toLinearMapRight' N (Matrix.toLinearMapRight' M x) :=
(vecMul_vecMul _ M N).symm
@[simp]
theorem Matrix.toLinearMapRight'_one :
Matrix.toLinearMapRight' (1 : Matrix m m R) = LinearMap.id := by
ext
simp [Module.End.one_apply]
/-- If `M` and `M'` are each other's inverse matrices, they provide an equivalence between `n â A`
and `m â A` corresponding to `M.vecMul` and `M'.vecMul`. -/
@[simps]
def Matrix.toLinearEquivRight'OfInv [Fintype n] [DecidableEq n] {M : Matrix m n R}
{M' : Matrix n m R} (hMM' : M * M' = 1) (hM'M : M' * M = 1) : (n â R) ââ[R] m â R :=
{ LinearMap.toMatrixRight'.symm M' with
toFun := Matrix.toLinearMapRight' M'
invFun := Matrix.toLinearMapRight' M
left_inv := fun x ⊠by
rw [â Matrix.toLinearMapRight'_mul_apply, hM'M, Matrix.toLinearMapRight'_one, id_apply]
right_inv := fun x ⊠by
rw [â Matrix.toLinearMapRight'_mul_apply, hMM', Matrix.toLinearMapRight'_one, id_apply] }
end
end ToMatrixRight
/-!
From this point on, we only work with commutative rings,
and fail to distinguish between `Ráµáµáµ` and `R`.
This should eventually be remedied.
-/
section mulVec
variable {R : Type*} [CommSemiring R]
variable {k l m n : Type*}
/-- `Matrix.mulVec M` is a linear map. -/
def Matrix.mulVecLin [Fintype n] (M : Matrix m n R) : (n â R) ââ[R] m â R where
toFun := M.mulVec
map_add' _ _ := funext fun _ ⊠dotProduct_add _ _ _
map_smul' _ _ := funext fun _ ⊠dotProduct_smul _ _ _
theorem Matrix.coe_mulVecLin [Fintype n] (M : Matrix m n R) :
(M.mulVecLin : _ â _) = M.mulVec := rfl
@[simp]
theorem Matrix.mulVecLin_apply [Fintype n] (M : Matrix m n R) (v : n â R) :
M.mulVecLin v = M *áµ¥ v :=
rfl
@[simp]
theorem Matrix.mulVecLin_zero [Fintype n] : Matrix.mulVecLin (0 : Matrix m n R) = 0 :=
LinearMap.ext zero_mulVec
@[simp]
theorem Matrix.mulVecLin_add [Fintype n] (M N : Matrix m n R) :
(M + N).mulVecLin = M.mulVecLin + N.mulVecLin :=
LinearMap.ext fun _ ⊠add_mulVec _ _ _
@[simp] theorem Matrix.mulVecLin_transpose [Fintype m] (M : Matrix m n R) :
Máµ.mulVecLin = M.vecMulLinear := by
ext; simp [mulVec_transpose]
@[simp] theorem Matrix.vecMulLinear_transpose [Fintype n] (M : Matrix m n R) :
Máµ.vecMulLinear = M.mulVecLin := by
ext; simp [vecMul_transpose]
theorem Matrix.mulVecLin_submatrix [Fintype n] [Fintype l] (fâ : m â k) (eâ : n â l)
(M : Matrix k l R) :
(M.submatrix fâ eâ).mulVecLin = funLeft R R fâ ââ M.mulVecLin ââ funLeft _ _ eâ.symm :=
LinearMap.ext fun _ ⊠submatrix_mulVec_equiv _ _ _ _
/-- A variant of `Matrix.mulVecLin_submatrix` that keeps around `LinearEquiv`s. -/
theorem Matrix.mulVecLin_reindex [Fintype n] [Fintype l] (eâ : k â m) (eâ : l â n)
(M : Matrix k l R) :
(reindex eâ eâ M).mulVecLin =
â(LinearEquiv.funCongrLeft R R eâ.symm) ââ
M.mulVecLin ââ â(LinearEquiv.funCongrLeft R R eâ) :=
Matrix.mulVecLin_submatrix _ _ _
variable [Fintype n]
@[simp]
theorem Matrix.mulVecLin_one [DecidableEq n] :
Matrix.mulVecLin (1 : Matrix n n R) = LinearMap.id := by
ext; simp [Matrix.one_apply, Pi.single_apply, eq_comm]
@[simp]
theorem Matrix.mulVecLin_mul [Fintype m] (M : Matrix l m R) (N : Matrix m n R) :
Matrix.mulVecLin (M * N) = (Matrix.mulVecLin M).comp (Matrix.mulVecLin N) :=
LinearMap.ext fun _ ⊠(mulVec_mulVec _ _ _).symm
theorem Matrix.ker_mulVecLin_eq_bot_iff {M : Matrix m n R} :
(LinearMap.ker M.mulVecLin) = ⥠â â v, M *áµ¥ v = 0 â v = 0 := by
simp only [Submodule.eq_bot_iff, LinearMap.mem_ker, Matrix.mulVecLin_apply]
theorem Matrix.range_mulVecLin (M : Matrix m n R) :
LinearMap.range M.mulVecLin = span R (range M.col) := by
rw [â vecMulLinear_transpose, range_vecMulLinear, row_transpose]
theorem Matrix.mulVec_injective_iff {R : Type*} [CommRing R] {M : Matrix m n R} :
Function.Injective M.mulVec â LinearIndependent R M.col := by
change Function.Injective (fun x ⊠_) â _
simp_rw [â M.vecMul_transpose, vecMul_injective_iff, row_transpose]
lemma Matrix.linearIndependent_cols_of_isUnit {R : Type*} [CommRing R] [Fintype m]
{A : Matrix m m R} [DecidableEq m] (ha : IsUnit A) :
LinearIndependent R A.col := by
rw [â Matrix.mulVec_injective_iff]
exact Matrix.mulVec_injective_of_isUnit ha
end mulVec
section ToMatrix'
variable {R : Type*} [CommSemiring R]
variable {k l m n : Type*} [DecidableEq n] [Fintype n]
/-- Linear maps `(n â R) ââ[R] (m â R)` are linearly equivalent to `Matrix m n R`. -/
def LinearMap.toMatrix' : ((n â R) ââ[R] m â R) ââ[R] Matrix m n R where
toFun f := of fun i j ⊠f (Pi.single j 1) i
invFun := Matrix.mulVecLin
right_inv M := by
ext i j
simp only [Matrix.mulVec_single_one, Matrix.mulVecLin_apply, of_apply, transpose_apply]
left_inv f := by
apply (Pi.basisFun R n).ext
intro j; ext i
simp only [Pi.basisFun_apply, Matrix.mulVec_single_one,
Matrix.mulVecLin_apply, of_apply, transpose_apply]
map_add' f g := by
ext i j
simp only [Pi.add_apply, LinearMap.add_apply, of_apply, Matrix.add_apply]
map_smul' c f := by
ext i j
simp only [Pi.smul_apply, LinearMap.smul_apply, RingHom.id_apply, of_apply, Matrix.smul_apply]
/-- A `Matrix m n R` is linearly equivalent to a linear map `(n â R) ââ[R] (m â R)`.
Note that the forward-direction does not require `DecidableEq` and is `Matrix.vecMulLin`. -/
def Matrix.toLin' : Matrix m n R ââ[R] (n â R) ââ[R] m â R :=
LinearMap.toMatrix'.symm
theorem Matrix.toLin'_apply' (M : Matrix m n R) : Matrix.toLin' M = M.mulVecLin :=
rfl
@[simp]
theorem LinearMap.toMatrix'_symm :
(LinearMap.toMatrix'.symm : Matrix m n R ââ[R] _) = Matrix.toLin' :=
rfl
@[simp]
theorem Matrix.toLin'_symm :
(Matrix.toLin'.symm : ((n â R) ââ[R] m â R) ââ[R] _) = LinearMap.toMatrix' :=
rfl
@[simp]
theorem LinearMap.toMatrix'_toLin' (M : Matrix m n R) : LinearMap.toMatrix' (Matrix.toLin' M) = M :=
LinearMap.toMatrix'.apply_symm_apply M
@[simp]
theorem Matrix.toLin'_toMatrix' (f : (n â R) ââ[R] m â R) :
Matrix.toLin' (LinearMap.toMatrix' f) = f :=
Matrix.toLin'.apply_symm_apply f
@[simp]
theorem LinearMap.toMatrix'_apply (f : (n â R) ââ[R] m â R) (i j) :
LinearMap.toMatrix' f i j = f (fun j' ⊠if j' = j then 1 else 0) i := by
simp only [LinearMap.toMatrix', LinearEquiv.coe_mk, of_apply]
congr! with i
split_ifs with h
· rw [h, Pi.single_eq_same]
apply Pi.single_eq_of_ne h
@[simp]
theorem Matrix.toLin'_apply (M : Matrix m n R) (v : n â R) : Matrix.toLin' M v = M *áµ¥ v :=
rfl
@[simp]
theorem Matrix.toLin'_one : Matrix.toLin' (1 : Matrix n n R) = LinearMap.id :=
Matrix.mulVecLin_one
@[simp]
theorem LinearMap.toMatrix'_id : LinearMap.toMatrix' (LinearMap.id : (n â R) ââ[R] n â R) = 1 := by
ext
rw [Matrix.one_apply, LinearMap.toMatrix'_apply, id_apply]
@[simp]
theorem LinearMap.toMatrix'_one : LinearMap.toMatrix' (1 : (n â R) ââ[R] n â R) = 1 :=
LinearMap.toMatrix'_id
@[simp]
theorem Matrix.toLin'_mul [Fintype m] [DecidableEq m] (M : Matrix l m R) (N : Matrix m n R) :
Matrix.toLin' (M * N) = (Matrix.toLin' M).comp (Matrix.toLin' N) :=
Matrix.mulVecLin_mul _ _
@[simp]
theorem Matrix.toLin'_submatrix [Fintype l] [DecidableEq l] (fâ : m â k) (eâ : n â l)
(M : Matrix k l R) :
Matrix.toLin' (M.submatrix fâ eâ) =
funLeft R R fâ ââ (Matrix.toLin' M) ââ funLeft _ _ eâ.symm :=
Matrix.mulVecLin_submatrix _ _ _
/-- A variant of `Matrix.toLin'_submatrix` that keeps around `LinearEquiv`s. -/
theorem Matrix.toLin'_reindex [Fintype l] [DecidableEq l] (eâ : k â m) (eâ : l â n)
(M : Matrix k l R) :
Matrix.toLin' (reindex eâ eâ M) =
â(LinearEquiv.funCongrLeft R R eâ.symm) ââ (Matrix.toLin' M) ââ
â(LinearEquiv.funCongrLeft R R eâ) :=
Matrix.mulVecLin_reindex _ _ _
/-- Shortcut lemma for `Matrix.toLin'_mul` and `LinearMap.comp_apply` -/
theorem Matrix.toLin'_mul_apply [Fintype m] [DecidableEq m] (M : Matrix l m R) (N : Matrix m n R)
(x) : Matrix.toLin' (M * N) x = Matrix.toLin' M (Matrix.toLin' N x) := by
rw [Matrix.toLin'_mul, LinearMap.comp_apply]
theorem LinearMap.toMatrix'_comp [Fintype l] [DecidableEq l] (f : (n â R) ââ[R] m â R)
(g : (l â R) ââ[R] n â R) :
LinearMap.toMatrix' (f.comp g) = LinearMap.toMatrix' f * LinearMap.toMatrix' g := by
suffices f.comp g = Matrix.toLin' (LinearMap.toMatrix' f * LinearMap.toMatrix' g) by
rw [this, LinearMap.toMatrix'_toLin']
rw [Matrix.toLin'_mul, Matrix.toLin'_toMatrix', Matrix.toLin'_toMatrix']
theorem LinearMap.toMatrix'_mul [Fintype m] [DecidableEq m] (f g : (m â R) ââ[R] m â R) :
LinearMap.toMatrix' (f * g) = LinearMap.toMatrix' f * LinearMap.toMatrix' g :=
LinearMap.toMatrix'_comp f g
@[simp]
theorem LinearMap.toMatrix'_algebraMap (x : R) :
LinearMap.toMatrix' (algebraMap R (Module.End R (n â R)) x) = scalar n x := by
simp [Module.algebraMap_end_eq_smul_id, smul_eq_diagonal_mul]
theorem Matrix.ker_toLin'_eq_bot_iff {M : Matrix n n R} :
LinearMap.ker (Matrix.toLin' M) = ⥠â â v, M *áµ¥ v = 0 â v = 0 :=
Matrix.ker_mulVecLin_eq_bot_iff
theorem Matrix.range_toLin' (M : Matrix m n R) :
LinearMap.range (Matrix.toLin' M) = span R (range M.col) :=
Matrix.range_mulVecLin _
/-- If `M` and `M'` are each other's inverse matrices, they provide an equivalence between `m â A`
and `n â A` corresponding to `M.mulVec` and `M'.mulVec`. -/
@[simps]
def Matrix.toLin'OfInv [Fintype m] [DecidableEq m] {M : Matrix m n R} {M' : Matrix n m R}
(hMM' : M * M' = 1) (hM'M : M' * M = 1) : (m â R) ââ[R] n â R :=
{ Matrix.toLin' M' with
toFun := Matrix.toLin' M'
invFun := Matrix.toLin' M
left_inv := fun x ⊠by rw [â Matrix.toLin'_mul_apply, hMM', Matrix.toLin'_one, id_apply]
right_inv := fun x ⊠by
rw [â Matrix.toLin'_mul_apply, hM'M, Matrix.toLin'_one, id_apply] }
/-- Linear maps `(n â R) ââ[R] (n â R)` are algebra equivalent to `Matrix n n R`. -/
def LinearMap.toMatrixAlgEquiv' : ((n â R) ââ[R] n â R) ââ[R] Matrix n n R :=
AlgEquiv.ofLinearEquiv LinearMap.toMatrix' LinearMap.toMatrix'_one LinearMap.toMatrix'_mul
/-- A `Matrix n n R` is algebra equivalent to a linear map `(n â R) ââ[R] (n â R)`. -/
def Matrix.toLinAlgEquiv' : Matrix n n R ââ[R] (n â R) ââ[R] n â R :=
LinearMap.toMatrixAlgEquiv'.symm
@[simp]
theorem LinearMap.toMatrixAlgEquiv'_symm :
(LinearMap.toMatrixAlgEquiv'.symm : Matrix n n R ââ[R] _) = Matrix.toLinAlgEquiv' :=
rfl
@[simp]
theorem Matrix.toLinAlgEquiv'_symm :
(Matrix.toLinAlgEquiv'.symm : ((n â R) ââ[R] n â R) ââ[R] _) = LinearMap.toMatrixAlgEquiv' :=
rfl
@[simp]
theorem LinearMap.toMatrixAlgEquiv'_toLinAlgEquiv' (M : Matrix n n R) :
LinearMap.toMatrixAlgEquiv' (Matrix.toLinAlgEquiv' M) = M :=
LinearMap.toMatrixAlgEquiv'.apply_symm_apply M
@[simp]
theorem Matrix.toLinAlgEquiv'_toMatrixAlgEquiv' (f : (n â R) ââ[R] n â R) :
Matrix.toLinAlgEquiv' (LinearMap.toMatrixAlgEquiv' f) = f :=
Matrix.toLinAlgEquiv'.apply_symm_apply f
@[simp]
theorem LinearMap.toMatrixAlgEquiv'_apply (f : (n â R) ââ[R] n â R) (i j) :
LinearMap.toMatrixAlgEquiv' f i j = f (fun j' ⊠if j' = j then 1 else 0) i := by
simp [LinearMap.toMatrixAlgEquiv']
@[simp]
theorem Matrix.toLinAlgEquiv'_apply (M : Matrix n n R) (v : n â R) :
Matrix.toLinAlgEquiv' M v = M *áµ¥ v :=
rfl
theorem Matrix.toLinAlgEquiv'_one : Matrix.toLinAlgEquiv' (1 : Matrix n n R) = LinearMap.id :=
Matrix.toLin'_one
@[simp]
theorem LinearMap.toMatrixAlgEquiv'_id :
LinearMap.toMatrixAlgEquiv' (LinearMap.id : (n â R) ââ[R] n â R) = 1 :=
LinearMap.toMatrix'_id
theorem LinearMap.toMatrixAlgEquiv'_comp (f g : (n â R) ââ[R] n â R) :
LinearMap.toMatrixAlgEquiv' (f.comp g) =
LinearMap.toMatrixAlgEquiv' f * LinearMap.toMatrixAlgEquiv' g :=
LinearMap.toMatrix'_comp _ _
theorem LinearMap.toMatrixAlgEquiv'_mul (f g : (n â R) ââ[R] n â R) :
LinearMap.toMatrixAlgEquiv' (f * g) =
LinearMap.toMatrixAlgEquiv' f * LinearMap.toMatrixAlgEquiv' g :=
LinearMap.toMatrixAlgEquiv'_comp f g
end ToMatrix'
section ToMatrix
section Finite
variable {R : Type*} [CommSemiring R]
variable {l m n : Type*} [Fintype n] [Finite m] [DecidableEq n]
variable {Mâ Mâ : Type*} [AddCommMonoid Mâ] [AddCommMonoid Mâ] [Module R Mâ] [Module R Mâ]
variable (vâ : Basis n R Mâ) (vâ : Basis m R Mâ)
/-- Given bases of two modules `Mâ` and `Mâ` over a commutative ring `R`, we get a linear
equivalence between linear maps `Mâ ââ Mâ` and matrices over `R` indexed by the bases. -/
def LinearMap.toMatrix : (Mâ ââ[R] Mâ) ââ[R] Matrix m n R :=
LinearEquiv.trans (LinearEquiv.arrowCongr vâ.equivFun vâ.equivFun) LinearMap.toMatrix'
/-- `LinearMap.toMatrix'` is a particular case of `LinearMap.toMatrix`, for the standard basis
`Pi.basisFun R n`. -/
theorem LinearMap.toMatrix_eq_toMatrix' :
LinearMap.toMatrix (Pi.basisFun R n) (Pi.basisFun R n) = LinearMap.toMatrix' :=
rfl
/-- Given bases of two modules `Mâ` and `Mâ` over a commutative ring `R`, we get a linear
equivalence between matrices over `R` indexed by the bases and linear maps `Mâ ââ Mâ`. -/
def Matrix.toLin : Matrix m n R ââ[R] Mâ ââ[R] Mâ :=
(LinearMap.toMatrix vâ vâ).symm
/-- `Matrix.toLin'` is a particular case of `Matrix.toLin`, for the standard basis
`Pi.basisFun R n`. -/
theorem Matrix.toLin_eq_toLin' : Matrix.toLin (Pi.basisFun R n) (Pi.basisFun R m) = Matrix.toLin' :=
rfl
@[simp]
theorem LinearMap.toMatrix_symm : (LinearMap.toMatrix vâ vâ).symm = Matrix.toLin vâ vâ :=
rfl
@[simp]
theorem Matrix.toLin_symm : (Matrix.toLin vâ vâ).symm = LinearMap.toMatrix vâ vâ :=
rfl
@[simp]
theorem Matrix.toLin_toMatrix (f : Mâ ââ[R] Mâ) :
Matrix.toLin vâ vâ (LinearMap.toMatrix vâ vâ f) = f := by
rw [â Matrix.toLin_symm, LinearEquiv.apply_symm_apply]
@[simp]
theorem LinearMap.toMatrix_toLin (M : Matrix m n R) :
LinearMap.toMatrix vâ vâ (Matrix.toLin vâ vâ M) = M := by
rw [â Matrix.toLin_symm, LinearEquiv.symm_apply_apply]
theorem LinearMap.toMatrix_apply (f : Mâ ââ[R] Mâ) (i : m) (j : n) :
LinearMap.toMatrix vâ vâ f i j = vâ.repr (f (vâ j)) i := by
rw [LinearMap.toMatrix, LinearEquiv.trans_apply, LinearMap.toMatrix'_apply,
LinearEquiv.arrowCongr_apply, Basis.equivFun_symm_apply, Finset.sum_eq_single j, if_pos rfl,
one_smul, Basis.equivFun_apply]
· intro j' _ hj'
rw [if_neg hj', zero_smul]
· intro hj
have := Finset.mem_univ j
contradiction
theorem LinearMap.toMatrix_transpose_apply (f : Mâ ââ[R] Mâ) (j : n) :
(LinearMap.toMatrix vâ vâ f)áµ j = vâ.repr (f (vâ j)) :=
funext fun i ⊠f.toMatrix_apply _ _ i j
theorem LinearMap.toMatrix_apply' (f : Mâ ââ[R] Mâ) (i : m) (j : n) :
LinearMap.toMatrix vâ vâ f i j = vâ.repr (f (vâ j)) i :=
LinearMap.toMatrix_apply vâ vâ f i j
theorem LinearMap.toMatrix_transpose_apply' (f : Mâ ââ[R] Mâ) (j : n) :
(LinearMap.toMatrix vâ vâ f)áµ j = vâ.repr (f (vâ j)) :=
LinearMap.toMatrix_transpose_apply vâ vâ f j
/-- This will be a special case of `LinearMap.toMatrix_id_eq_basis_toMatrix`. -/
theorem LinearMap.toMatrix_id : LinearMap.toMatrix vâ vâ id = 1 := by
ext i j
simp [LinearMap.toMatrix_apply, Matrix.one_apply, Finsupp.single_apply, eq_comm]
@[simp]
theorem LinearMap.toMatrix_one : LinearMap.toMatrix vâ vâ 1 = 1 :=
LinearMap.toMatrix_id vâ
@[simp]
lemma LinearMap.toMatrix_singleton {ι : Type*} [Unique ι] (f : R ââ[R] R) (i j : ι) :
f.toMatrix (.singleton ι R) (.singleton ι R) i j = f 1 := by
simp [toMatrix, Subsingleton.elim j default]
@[simp]
theorem Matrix.toLin_one : Matrix.toLin vâ vâ 1 = LinearMap.id := by
rw [â LinearMap.toMatrix_id vâ, Matrix.toLin_toMatrix]
theorem LinearMap.toMatrix_reindexRange [DecidableEq Mâ] (f : Mâ ââ[R] Mâ) (k : m) (i : n) :
LinearMap.toMatrix vâ.reindexRange vâ.reindexRange f âšvâ k, Set.mem_range_self kâ©
âšvâ i, Set.mem_range_self iâ© =
LinearMap.toMatrix vâ vâ f k i := by
simp_rw [LinearMap.toMatrix_apply, Basis.reindexRange_self, Basis.reindexRange_repr]
@[simp]
theorem LinearMap.toMatrix_algebraMap (x : R) :
LinearMap.toMatrix vâ vâ (algebraMap R (Module.End R Mâ) x) = scalar n x := by
simp [Module.algebraMap_end_eq_smul_id, LinearMap.toMatrix_id, smul_eq_diagonal_mul]
theorem LinearMap.toMatrix_mulVec_repr (f : Mâ ââ[R] Mâ) (x : Mâ) :
LinearMap.toMatrix vâ vâ f *áµ¥ vâ.repr x = vâ.repr (f x) := by
ext i
rw [â Matrix.toLin'_apply, LinearMap.toMatrix, LinearEquiv.trans_apply, Matrix.toLin'_toMatrix',
LinearEquiv.arrowCongr_apply, vâ.equivFun_apply]
congr
exact vâ.equivFun.symm_apply_apply x
@[simp]
theorem LinearMap.toMatrix_basis_equiv [Fintype l] [DecidableEq l] (b : Basis l R Mâ)
(b' : Basis l R Mâ) :
LinearMap.toMatrix b' b (b'.equiv b (Equiv.refl l) : Mâ ââ[R] Mâ) = 1 := by
ext i j
simp [LinearMap.toMatrix_apply, Matrix.one_apply, Finsupp.single_apply, eq_comm]
theorem LinearMap.toMatrix_smulBasis_left {G} [Group G] [DistribMulAction G Mâ]
[SMulCommClass G R Mâ] (g : G) (f : Mâ ââ[R] Mâ) :
LinearMap.toMatrix (g ⢠vâ) vâ f =
LinearMap.toMatrix vâ vâ (f ââ DistribMulAction.toLinearMap _ _ g) := by
ext
rw [LinearMap.toMatrix_apply, LinearMap.toMatrix_apply]
dsimp
theorem LinearMap.toMatrix_smulBasis_right {G} [Group G] [DistribMulAction G Mâ]
[SMulCommClass G R Mâ] (g : G) (f : Mâ ââ[R] Mâ) :
LinearMap.toMatrix vâ (g ⢠vâ) f =
LinearMap.toMatrix vâ vâ (DistribMulAction.toLinearMap _ _ gâ»Â¹ ââ f) := by
ext
rw [LinearMap.toMatrix_apply, LinearMap.toMatrix_apply]
dsimp
end Finite
variable {R : Type*} [CommSemiring R]
variable {l m n : Type*} [Fintype n] [Fintype m] [DecidableEq n]
variable {Mâ Mâ : Type*} [AddCommMonoid Mâ] [AddCommMonoid Mâ] [Module R Mâ] [Module R Mâ]
variable (vâ : Basis n R Mâ) (vâ : Basis m R Mâ)
theorem Matrix.toLin_apply (M : Matrix m n R) (v : Mâ) :
Matrix.toLin vâ vâ M v = â j, (M *áµ¥ vâ.repr v) j ⢠vâ j :=
show vâ.equivFun.symm (Matrix.toLin' M (vâ.repr v)) = _ by
rw [Matrix.toLin'_apply, vâ.equivFun_symm_apply]
@[simp]
theorem Matrix.toLin_self (M : Matrix m n R) (i : n) :
Matrix.toLin vâ vâ M (vâ i) = â j, M j i ⢠vâ j := by
rw [Matrix.toLin_apply, Finset.sum_congr rfl fun j _hj ⊠?_]
rw [Basis.repr_self, Matrix.mulVec, dotProduct, Finset.sum_eq_single i, Finsupp.single_eq_same,
mul_one]
· intro i' _ i'_ne
rw [Finsupp.single_eq_of_ne i'_ne.symm, mul_zero]
· intros
have := Finset.mem_univ i
contradiction
variable {Mâ : Type*} [AddCommMonoid Mâ] [Module R Mâ] (vâ : Basis l R Mâ)
theorem LinearMap.toMatrix_comp [Finite l] [DecidableEq m] (f : Mâ ââ[R] Mâ) (g : Mâ ââ[R] Mâ) :
LinearMap.toMatrix vâ vâ (f.comp g) =
LinearMap.toMatrix vâ vâ f * LinearMap.toMatrix vâ vâ g := by
simp_rw [LinearMap.toMatrix, LinearEquiv.trans_apply, LinearEquiv.arrowCongr_comp _ vâ.equivFun,
LinearMap.toMatrix'_comp]
theorem LinearMap.toMatrix_mul (f g : Mâ ââ[R] Mâ) :
LinearMap.toMatrix vâ vâ (f * g) = LinearMap.toMatrix vâ vâ f * LinearMap.toMatrix vâ vâ g := by
rw [Module.End.mul_eq_comp, LinearMap.toMatrix_comp vâ vâ vâ f g]
lemma LinearMap.toMatrix_pow (f : Mâ ââ[R] Mâ) (k : â) :
(toMatrix vâ vâ f) ^ k = toMatrix vâ vâ (f ^ k) := by
induction k with
| zero => simp
| succ k ih => rw [pow_succ, pow_succ, ih, â toMatrix_mul]
theorem Matrix.toLin_mul [Finite l] [DecidableEq m] (A : Matrix l m R) (B : Matrix m n R) :
Matrix.toLin vâ vâ (A * B) = (Matrix.toLin vâ vâ A).comp (Matrix.toLin vâ vâ B) := by
apply (LinearMap.toMatrix vâ vâ).injective
haveI : DecidableEq l := fun _ _ ⊠Classical.propDecidable _
rw [LinearMap.toMatrix_comp vâ vâ vâ]
repeat' rw [LinearMap.toMatrix_toLin]
/-- Shortcut lemma for `Matrix.toLin_mul` and `LinearMap.comp_apply`. -/
theorem Matrix.toLin_mul_apply [Finite l] [DecidableEq m] (A : Matrix l m R) (B : Matrix m n R)
(x) : Matrix.toLin vâ vâ (A * B) x = (Matrix.toLin vâ vâ A) (Matrix.toLin vâ vâ B x) := by
rw [Matrix.toLin_mul vâ vâ, LinearMap.comp_apply]
/-- If `M` and `M` are each other's inverse matrices, `Matrix.toLin M` and `Matrix.toLin M'`
form a linear equivalence. -/
@[simps]
def Matrix.toLinOfInv [DecidableEq m] {M : Matrix m n R} {M' : Matrix n m R} (hMM' : M * M' = 1)
(hM'M : M' * M = 1) : Mâ ââ[R] Mâ :=
{ Matrix.toLin vâ vâ M with
toFun := Matrix.toLin vâ vâ M
invFun := Matrix.toLin vâ vâ M'
left_inv := fun x ⊠by rw [â Matrix.toLin_mul_apply, hM'M, Matrix.toLin_one, id_apply]
right_inv := fun x ⊠by
rw [â Matrix.toLin_mul_apply, hMM', Matrix.toLin_one, id_apply] }
/-- Given a basis of a module `Mâ` over a commutative ring `R`, we get an algebra
equivalence between linear maps `Mâ ââ Mâ` and square matrices over `R` indexed by the basis. -/
def LinearMap.toMatrixAlgEquiv : (Mâ ââ[R] Mâ) ââ[R] Matrix n n R :=
AlgEquiv.ofLinearEquiv
(LinearMap.toMatrix vâ vâ) (LinearMap.toMatrix_one vâ) (LinearMap.toMatrix_mul vâ)
/-- Given a basis of a module `Mâ` over a commutative ring `R`, we get an algebra
equivalence between square matrices over `R` indexed by the basis and linear maps `Mâ ââ Mâ`. -/
def Matrix.toLinAlgEquiv : Matrix n n R ââ[R] Mâ ââ[R] Mâ :=
(LinearMap.toMatrixAlgEquiv vâ).symm
@[simp]
theorem LinearMap.toMatrixAlgEquiv_symm :
(LinearMap.toMatrixAlgEquiv vâ).symm = Matrix.toLinAlgEquiv vâ :=
rfl
@[simp]
theorem Matrix.toLinAlgEquiv_symm :
(Matrix.toLinAlgEquiv vâ).symm = LinearMap.toMatrixAlgEquiv vâ :=
rfl
@[simp]
theorem Matrix.toLinAlgEquiv_toMatrixAlgEquiv (f : Mâ ââ[R] Mâ) :
Matrix.toLinAlgEquiv vâ (LinearMap.toMatrixAlgEquiv vâ f) = f := by
rw [â Matrix.toLinAlgEquiv_symm, AlgEquiv.apply_symm_apply]
@[simp]
theorem LinearMap.toMatrixAlgEquiv_toLinAlgEquiv (M : Matrix n n R) :
LinearMap.toMatrixAlgEquiv vâ (Matrix.toLinAlgEquiv vâ M) = M := by
rw [â Matrix.toLinAlgEquiv_symm, AlgEquiv.symm_apply_apply]
theorem LinearMap.toMatrixAlgEquiv_apply (f : Mâ ââ[R] Mâ) (i j : n) :
LinearMap.toMatrixAlgEquiv vâ f i j = vâ.repr (f (vâ j)) i := by
simp [LinearMap.toMatrixAlgEquiv, LinearMap.toMatrix_apply]
theorem LinearMap.toMatrixAlgEquiv_transpose_apply (f : Mâ ââ[R] Mâ) (j : n) :
(LinearMap.toMatrixAlgEquiv vâ f)áµ j = vâ.repr (f (vâ j)) :=
funext fun i ⊠f.toMatrix_apply _ _ i j
theorem LinearMap.toMatrixAlgEquiv_apply' (f : Mâ ââ[R] Mâ) (i j : n) :
LinearMap.toMatrixAlgEquiv vâ f i j = vâ.repr (f (vâ j)) i :=
LinearMap.toMatrixAlgEquiv_apply vâ f i j
theorem LinearMap.toMatrixAlgEquiv_transpose_apply' (f : Mâ ââ[R] Mâ) (j : n) :
(LinearMap.toMatrixAlgEquiv vâ f)áµ j = vâ.repr (f (vâ j)) :=
LinearMap.toMatrixAlgEquiv_transpose_apply vâ f j
theorem Matrix.toLinAlgEquiv_apply (M : Matrix n n R) (v : Mâ) :
Matrix.toLinAlgEquiv vâ M v = â j, (M *áµ¥ vâ.repr v) j ⢠vâ j :=
show vâ.equivFun.symm (Matrix.toLinAlgEquiv' M (vâ.repr v)) = _ by
rw [Matrix.toLinAlgEquiv'_apply, vâ.equivFun_symm_apply]
@[simp]
theorem Matrix.toLinAlgEquiv_self (M : Matrix n n R) (i : n) :
Matrix.toLinAlgEquiv vâ M (vâ i) = â j, M j i ⢠vâ j :=
Matrix.toLin_self _ _ _ _
theorem LinearMap.toMatrixAlgEquiv_id : LinearMap.toMatrixAlgEquiv vâ id = 1 := by
simp_rw [LinearMap.toMatrixAlgEquiv, AlgEquiv.ofLinearEquiv_apply, LinearMap.toMatrix_id]
theorem Matrix.toLinAlgEquiv_one : Matrix.toLinAlgEquiv vâ 1 = LinearMap.id := by
rw [â LinearMap.toMatrixAlgEquiv_id vâ, Matrix.toLinAlgEquiv_toMatrixAlgEquiv]
theorem LinearMap.toMatrixAlgEquiv_reindexRange [DecidableEq Mâ] (f : Mâ ââ[R] Mâ) (k i : n) :
LinearMap.toMatrixAlgEquiv vâ.reindexRange f
âšvâ k, Set.mem_range_self kâ© âšvâ i, Set.mem_range_self iâ© =
LinearMap.toMatrixAlgEquiv vâ f k i := by
simp_rw [LinearMap.toMatrixAlgEquiv_apply, Basis.reindexRange_self, Basis.reindexRange_repr]
theorem LinearMap.toMatrixAlgEquiv_comp (f g : Mâ ââ[R] Mâ) :
LinearMap.toMatrixAlgEquiv vâ (f.comp g) =
LinearMap.toMatrixAlgEquiv vâ f * LinearMap.toMatrixAlgEquiv vâ g := by
simp [LinearMap.toMatrixAlgEquiv, LinearMap.toMatrix_comp vâ vâ vâ f g]
theorem LinearMap.toMatrixAlgEquiv_mul (f g : Mâ ââ[R] Mâ) :
LinearMap.toMatrixAlgEquiv vâ (f * g) =
LinearMap.toMatrixAlgEquiv vâ f * LinearMap.toMatrixAlgEquiv vâ g := by
rw [Module.End.mul_eq_comp, LinearMap.toMatrixAlgEquiv_comp vâ f g]
theorem Matrix.toLinAlgEquiv_mul (A B : Matrix n n R) :
Matrix.toLinAlgEquiv vâ (A * B) =
(Matrix.toLinAlgEquiv vâ A).comp (Matrix.toLinAlgEquiv vâ B) := by
convert Matrix.toLin_mul vâ vâ vâ A B
@[simp]
theorem Matrix.toLin_finTwoProd_apply (a b c d : R) (x : R Ã R) :
Matrix.toLin (Basis.finTwoProd R) (Basis.finTwoProd R) !![a, b; c, d] x =
(a * x.fst + b * x.snd, c * x.fst + d * x.snd) := by
simp [Matrix.toLin_apply, Matrix.mulVec, dotProduct]
theorem Matrix.toLin_finTwoProd (a b c d : R) :
Matrix.toLin (Basis.finTwoProd R) (Basis.finTwoProd R) !![a, b; c, d] =
(a ⢠LinearMap.fst R R R + b ⢠LinearMap.snd R R R).prod
(c ⢠LinearMap.fst R R R + d ⢠LinearMap.snd R R R) :=
LinearMap.ext <| Matrix.toLin_finTwoProd_apply _ _ _ _
@[simp]
theorem toMatrix_distrib_mul_action_toLinearMap (x : R) :
LinearMap.toMatrix vâ vâ (DistribMulAction.toLinearMap R Mâ x) =
Matrix.diagonal fun _ ⊠x := by
ext
rw [LinearMap.toMatrix_apply, DistribMulAction.toLinearMap_apply, LinearEquiv.map_smul,
Basis.repr_self, Finsupp.smul_single_one, Finsupp.single_eq_pi_single, Matrix.diagonal_apply,
Pi.single_apply]
lemma LinearMap.toMatrix_prodMap [DecidableEq m] [DecidableEq (n â m)]
(Ïâ : Module.End R Mâ) (Ïâ : Module.End R Mâ) :
toMatrix (vâ.prod vâ) (vâ.prod vâ) (Ïâ.prodMap Ïâ) =
Matrix.fromBlocks (toMatrix vâ vâ Ïâ) 0 0 (toMatrix vâ vâ Ïâ) := by
ext (i|i) (j|j) <;> simp [toMatrix]
end ToMatrix
namespace Algebra
section Lmul
variable {R S : Type*} [CommSemiring R] [Semiring S] [Algebra R S]
variable {m : Type*} [Fintype m] [DecidableEq m] (b : Basis m R S)
theorem toMatrix_lmul' (x : S) (i j) :
LinearMap.toMatrix b b (lmul R S x) i j = b.repr (x * b j) i := by
simp only [LinearMap.toMatrix_apply', coe_lmul_eq_mul, LinearMap.mul_apply']
@[simp]
theorem toMatrix_lsmul (x : R) :
LinearMap.toMatrix b b (Algebra.lsmul R R S x) = Matrix.diagonal fun _ ⊠x :=
toMatrix_distrib_mul_action_toLinearMap b x
/-- `leftMulMatrix b x` is the matrix corresponding to the linear map `fun y ⊠x * y`.
`leftMulMatrix_eq_repr_mul` gives a formula for the entries of `leftMulMatrix`.
This definition is useful for doing (more) explicit computations with `LinearMap.mulLeft`,
such as the trace form or norm map for algebras.
-/
noncomputable def leftMulMatrix : S ââ[R] Matrix m m R where
toFun x := LinearMap.toMatrix b b (Algebra.lmul R S x)
map_zero' := by
rw [map_zero, LinearEquiv.map_zero]
map_one' := by
rw [map_one, LinearMap.toMatrix_one]
map_add' x y := by
rw [map_add, LinearEquiv.map_add]
map_mul' x y := by
rw [map_mul, LinearMap.toMatrix_mul]
commutes' r := by
ext
rw [lmul_algebraMap, toMatrix_lsmul, algebraMap_eq_diagonal, Pi.algebraMap_def,
Algebra.id.map_eq_self]
theorem leftMulMatrix_apply (x : S) : leftMulMatrix b x = LinearMap.toMatrix b b (lmul R S x) :=
rfl
theorem leftMulMatrix_eq_repr_mul (x : S) (i j) : leftMulMatrix b x i j = b.repr (x * b j) i := by
-- This is defeq to just `toMatrix_lmul' b x i j`,
-- but the unfolding goes a lot faster with this explicit `rw`.
rw [leftMulMatrix_apply, toMatrix_lmul' b x i j]
theorem leftMulMatrix_mulVec_repr (x y : S) :
leftMulMatrix b x *áµ¥ b.repr y = b.repr (x * y) :=
(LinearMap.mulLeft R x).toMatrix_mulVec_repr b b y
@[simp]
theorem toMatrix_lmul_eq (x : S) :
LinearMap.toMatrix b b (LinearMap.mulLeft R x) = leftMulMatrix b x :=
rfl
theorem leftMulMatrix_injective : Function.Injective (leftMulMatrix b) := fun x x' h âŠ
calc
x = Algebra.lmul R S x 1 := (mul_one x).symm
_ = Algebra.lmul R S x' 1 := by rw [(LinearMap.toMatrix b b).injective h]
_ = x' := mul_one x'
@[simp]
theorem smul_leftMulMatrix {G} [Group G] [DistribMulAction G S]
[SMulCommClass G R S] [SMulCommClass G S S] (g : G) (x) :
leftMulMatrix (g ⢠b) x = leftMulMatrix b x := by
ext
simp_rw [leftMulMatrix_apply, LinearMap.toMatrix_apply, coe_lmul_eq_mul, LinearMap.mul_apply',
Basis.repr_smul, Basis.smul_apply, LinearEquiv.trans_apply,
DistribMulAction.toLinearEquiv_symm_apply, mul_smul_comm, inv_smul_smul]
variable {A M n : Type*} [Fintype n] [DecidableEq n]
[CommSemiring A] [AddCommMonoid M] [Module R M] [Module A M] [Algebra R A] [IsScalarTower R A M]
(bA : Basis m R A) (bM : Basis n A M)
lemma _root_.LinearMap.restrictScalars_toMatrix (f : M ââ[A] M) :
(f.restrictScalars R).toMatrix (bA.smulTower' bM) (bA.smulTower' bM) =
((f.toMatrix bM bM).map (leftMulMatrix bA)).comp _ _ _ _ _ := by
ext; simp [toMatrix, Basis.repr, Algebra.leftMulMatrix_apply,
Basis.smulTower'_repr, Basis.smulTower'_apply, mul_comm]
end Lmul
section LmulTower
variable {R S T : Type*} [CommSemiring R] [CommSemiring S] [Semiring T]
variable [Algebra R S] [Algebra S T] [Algebra R T] [IsScalarTower R S T]
| variable {m n : Type*} [Fintype m] [Fintype n] [DecidableEq m] [DecidableEq n]
variable (b : Basis m R S) (c : Basis n S T)
theorem smulTower_leftMulMatrix (x) (ik jk) :
leftMulMatrix (b.smulTower c) x ik jk =
| Mathlib/LinearAlgebra/Matrix/ToLin.lean | 869 | 873 |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Yakov Pechersky, Eric Wieser
-/
import Mathlib.Data.List.Basic
/-!
# Properties of `List.enum`
## Deprecation note
Many lemmas in this file have been replaced by theorems in Lean4,
in terms of `xs[i]?` and `xs[i]` rather than `get` and `get?`.
The deprecated results here are unused in Mathlib.
Any downstream users who can not easily adapt may remove the deprecations as needed.
-/
namespace List
variable {α : Type*}
theorem forall_mem_zipIdx {l : List α} {n : â} {p : α à â â Prop} :
(â x â l.zipIdx n, p x) â â (i : â) (_ : i < length l), p (l[i], n + i) := by
simp only [forall_mem_iff_getElem, getElem_zipIdx, length_zipIdx]
/-- Variant of `forall_mem_zipIdx` with the `zipIdx` argument specialized to `0`. -/
theorem forall_mem_zipIdx' {l : List α} {p : α à â â Prop} :
(â x â l.zipIdx, p x) â â (i : â) (_ : i < length l), p (l[i], i) :=
forall_mem_zipIdx.trans <| by simp
theorem exists_mem_zipIdx {l : List α} {n : â} {p : α à â â Prop} :
(â x â l.zipIdx n, p x) â â (i : â) (_ : i < length l), p (l[i], n + i) := by
simp only [exists_mem_iff_getElem, getElem_zipIdx, length_zipIdx]
/-- Variant of `exists_mem_zipIdx` with the `zipIdx` argument specialized to `0`. -/
theorem exists_mem_zipIdx' {l : List α} {p : α à â â Prop} :
(â x â l.zipIdx, p x) â â (i : â) (_ : i < length l), p (l[i], i) :=
exists_mem_zipIdx.trans <| by simp
@[deprecated (since := "2025-01-28")]
alias forall_mem_enumFrom := forall_mem_zipIdx
@[deprecated (since := "2025-01-28")]
alias forall_mem_enum := forall_mem_zipIdx'
@[deprecated (since := "2025-01-28")]
alias exists_mem_enumFrom := exists_mem_zipIdx
@[deprecated (since := "2025-01-28")]
alias exists_mem_enum := exists_mem_zipIdx'
end List
| Mathlib/Data/List/Enum.lean | 141 | 142 | |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Topology.Continuous
import Mathlib.Topology.Defs.Induced
/-!
# Ordering on topologies and (co)induced topologies
Topologies on a fixed type `α` are ordered, by reverse inclusion. That is, for topologies `tâ` and
`tâ` on `α`, we write `tâ †tâ` if every set open in `tâ` is also open in `tâ`. (One also calls
`tâ` *finer* than `tâ`, and `tâ` *coarser* than `tâ`.)
Any function `f : α â β` induces
* `TopologicalSpace.induced f : TopologicalSpace β â TopologicalSpace α`;
* `TopologicalSpace.coinduced f : TopologicalSpace α â TopologicalSpace β`.
Continuity, the ordering on topologies and (co)induced topologies are related as follows:
* The identity map `(α, tâ) â (α, tâ)` is continuous iff `tâ †tâ`.
* A map `f : (α, t) â (β, u)` is continuous
* iff `t †TopologicalSpace.induced f u` (`continuous_iff_le_induced`)
* iff `TopologicalSpace.coinduced f t †u` (`continuous_iff_coinduced_le`).
Topologies on `α` form a complete lattice, with `â¥` the discrete topology and `â€` the indiscrete
topology.
For a function `f : α â β`, `(TopologicalSpace.coinduced f, TopologicalSpace.induced f)` is a Galois
connection between topologies on `α` and topologies on `β`.
## Implementation notes
There is a Galois insertion between topologies on `α` (with the inclusion ordering) and all
collections of sets in `α`. The complete lattice structure on topologies on `α` is defined as the
reverse of the one obtained via this Galois insertion. More precisely, we use the corresponding
Galois coinsertion between topologies on `α` (with the reversed inclusion ordering) and collections
of sets in `α` (with the reversed inclusion ordering).
## Tags
finer, coarser, induced topology, coinduced topology
-/
open Function Set Filter Topology
universe u v w
namespace TopologicalSpace
variable {α : Type u}
/-- The open sets of the least topology containing a collection of basic sets. -/
inductive GenerateOpen (g : Set (Set α)) : Set α â Prop
| basic : â s â g, GenerateOpen g s
| univ : GenerateOpen g univ
| inter : â s t, GenerateOpen g s â GenerateOpen g t â GenerateOpen g (s â© t)
| sUnion : â S : Set (Set α), (â s â S, GenerateOpen g s) â GenerateOpen g (ââ S)
/-- The smallest topological space containing the collection `g` of basic sets -/
def generateFrom (g : Set (Set α)) : TopologicalSpace α where
IsOpen := GenerateOpen g
isOpen_univ := GenerateOpen.univ
isOpen_inter := GenerateOpen.inter
isOpen_sUnion := GenerateOpen.sUnion
theorem isOpen_generateFrom_of_mem {g : Set (Set α)} {s : Set α} (hs : s â g) :
IsOpen[generateFrom g] s :=
GenerateOpen.basic s hs
theorem nhds_generateFrom {g : Set (Set α)} {a : α} :
@nhds α (generateFrom g) a = âš
s â { s | a â s â§ s â g }, ð s := by
letI := generateFrom g
rw [nhds_def]
refine le_antisymm (biInf_mono fun s âšas, sgâ© => âšas, .basic _ sgâ©) <| le_iInfâ ?_
rintro s âšha, hsâ©
induction hs with
| basic _ hs => exact iInfâ_le _ âšha, hsâ©
| univ => exact le_top.trans_eq principal_univ.symm
| inter _ _ _ _ hs ht => exact (le_inf (hs ha.1) (ht ha.2)).trans_eq inf_principal
| sUnion _ _ hS =>
let âšt, htS, hatâ© := ha
exact (hS t htS hat).trans (principal_mono.2 <| subset_sUnion_of_mem htS)
lemma tendsto_nhds_generateFrom_iff {β : Type*} {m : α â β} {f : Filter α} {g : Set (Set β)}
{b : β} : Tendsto m f (@nhds β (generateFrom g) b) â â s â g, b â s â m â»Â¹' s â f := by
simp only [nhds_generateFrom, @forall_swap (b â _), tendsto_iInf, mem_setOf_eq, and_imp,
tendsto_principal]; rfl
/-- Construct a topology on α given the filter of neighborhoods of each point of α. -/
protected def mkOfNhds (n : α â Filter α) : TopologicalSpace α where
IsOpen s := â a â s, s â n a
isOpen_univ _ _ := univ_mem
isOpen_inter := fun _s _t hs ht x âšhxs, hxtâ© => inter_mem (hs x hxs) (ht x hxt)
isOpen_sUnion := fun _s hs _a âšx, hx, hxaâ© =>
mem_of_superset (hs x hx _ hxa) (subset_sUnion_of_mem hx)
theorem nhds_mkOfNhds_of_hasBasis {n : α â Filter α} {ι : α â Sort*} {p : â a, ι a â Prop}
{s : â a, ι a â Set α} (hb : â a, (n a).HasBasis (p a) (s a))
(hpure : â a i, p a i â a â s a i) (hopen : â a i, p a i â âá¶ x in n a, s a i â n x) (a : α) :
@nhds α (.mkOfNhds n) a = n a := by
let t : TopologicalSpace α := .mkOfNhds n
apply le_antisymm
· intro U hU
replace hpure : pure †n := fun x ⊠(hb x).ge_iff.2 (hpure x)
refine mem_nhds_iff.2 âš{x | U â n x}, fun x hx ⊠hpure x hx, fun x hx ⊠?_, hUâ©
rcases (hb x).mem_iff.1 hx with âši, hpi, hiâ©
exact (hopen x i hpi).mono fun y hy ⊠mem_of_superset hy hi
· exact (nhds_basis_opens a).ge_iff.2 fun U âšhaU, hUo⩠⊠hUo a haU
theorem nhds_mkOfNhds (n : α â Filter α) (a : α) (hâ : pure †n)
(hâ : â a, â s â n a, âá¶ y in n a, s â n y) :
@nhds α (TopologicalSpace.mkOfNhds n) a = n a :=
nhds_mkOfNhds_of_hasBasis (fun a ⊠(n a).basis_sets) hâ hâ _
theorem nhds_mkOfNhds_single [DecidableEq α] {aâ : α} {l : Filter α} (h : pure aâ †l) (b : α) :
@nhds α (TopologicalSpace.mkOfNhds (update pure aâ l)) b =
(update pure aâ l : α â Filter α) b := by
refine nhds_mkOfNhds _ _ (le_update_iff.mpr âšh, fun _ _ => le_rflâ©) fun a s hs => ?_
rcases eq_or_ne a aâ with (rfl | ha)
· filter_upwards [hs] with b hb
rcases eq_or_ne b a with (rfl | hb)
· exact hs
· rwa [update_of_ne hb]
· simpa only [update_of_ne ha, mem_pure, eventually_pure] using hs
theorem nhds_mkOfNhds_filterBasis (B : α â FilterBasis α) (a : α) (hâ : â x, â n â B x, x â n)
(hâ : â x, â n â B x, â nâ â B x, â x' â nâ, â nâ â B x', nâ â n) :
@nhds α (TopologicalSpace.mkOfNhds fun x => (B x).filter) a = (B a).filter :=
nhds_mkOfNhds_of_hasBasis (fun a ⊠(B a).hasBasis) hâ hâ a
section Lattice
variable {α : Type u} {β : Type v}
/-- The ordering on topologies on the type `α`. `t †s` if every set open in `s` is also open in `t`
(`t` is finer than `s`). -/
instance : PartialOrder (TopologicalSpace α) :=
{ PartialOrder.lift (fun t => OrderDual.toDual IsOpen[t]) (fun _ _ => TopologicalSpace.ext) with
le := fun s t => â U, IsOpen[t] U â IsOpen[s] U }
protected theorem le_def {α} {t s : TopologicalSpace α} : t †s â IsOpen[s] †IsOpen[t] :=
Iff.rfl
theorem le_generateFrom_iff_subset_isOpen {g : Set (Set α)} {t : TopologicalSpace α} :
t †generateFrom g â g â { s | IsOpen[t] s } :=
âšfun ht s hs => ht _ <| .basic s hs, fun hg _s hs =>
hs.recOn (fun _ h => hg h) isOpen_univ (fun _ _ _ _ => IsOpen.inter) fun _ _ => isOpen_sUnionâ©
/-- If `s` equals the collection of open sets in the topology it generates, then `s` defines a
topology. -/
protected def mkOfClosure (s : Set (Set α)) (hs : { u | GenerateOpen s u } = s) :
TopologicalSpace α where
IsOpen u := u â s
isOpen_univ := hs âž TopologicalSpace.GenerateOpen.univ
isOpen_inter := hs âž TopologicalSpace.GenerateOpen.inter
isOpen_sUnion := hs âž TopologicalSpace.GenerateOpen.sUnion
theorem mkOfClosure_sets {s : Set (Set α)} {hs : { u | GenerateOpen s u } = s} :
TopologicalSpace.mkOfClosure s hs = generateFrom s :=
TopologicalSpace.ext hs.symm
theorem gc_generateFrom (α) :
GaloisConnection (fun t : TopologicalSpace α => OrderDual.toDual { s | IsOpen[t] s })
(generateFrom â OrderDual.ofDual) := fun _ _ =>
le_generateFrom_iff_subset_isOpen.symm
/-- The Galois coinsertion between `TopologicalSpace α` and `(Set (Set α))áµáµ` whose lower part sends
a topology to its collection of open subsets, and whose upper part sends a collection of subsets
of `α` to the topology they generate. -/
def gciGenerateFrom (α : Type*) :
GaloisCoinsertion (fun t : TopologicalSpace α => OrderDual.toDual { s | IsOpen[t] s })
(generateFrom â OrderDual.ofDual) where
gc := gc_generateFrom α
u_l_le _ s hs := TopologicalSpace.GenerateOpen.basic s hs
choice g hg := TopologicalSpace.mkOfClosure g
(Subset.antisymm hg <| le_generateFrom_iff_subset_isOpen.1 <| le_rfl)
choice_eq _ _ := mkOfClosure_sets
/-- Topologies on `α` form a complete lattice, with `â¥` the discrete topology
and `â€` the indiscrete topology. The infimum of a collection of topologies
is the topology generated by all their open sets, while the supremum is the
topology whose open sets are those sets open in every member of the collection. -/
instance : CompleteLattice (TopologicalSpace α) := (gciGenerateFrom α).liftCompleteLattice
@[mono, gcongr]
theorem generateFrom_anti {α} {gâ gâ : Set (Set α)} (h : gâ â gâ) :
generateFrom gâ †generateFrom gâ :=
(gc_generateFrom _).monotone_u h
theorem generateFrom_setOf_isOpen (t : TopologicalSpace α) :
generateFrom { s | IsOpen[t] s } = t :=
(gciGenerateFrom α).u_l_eq t
theorem leftInverse_generateFrom :
LeftInverse generateFrom fun t : TopologicalSpace α => { s | IsOpen[t] s } :=
(gciGenerateFrom α).u_l_leftInverse
theorem generateFrom_surjective : Surjective (generateFrom : Set (Set α) â TopologicalSpace α) :=
(gciGenerateFrom α).u_surjective
theorem setOf_isOpen_injective : Injective fun t : TopologicalSpace α => { s | IsOpen[t] s } :=
(gciGenerateFrom α).l_injective
end Lattice
end TopologicalSpace
section Lattice
variable {α : Type*} {t tâ tâ : TopologicalSpace α} {s : Set α}
theorem IsOpen.mono (hs : IsOpen[tâ] s) (h : tâ †tâ) : IsOpen[tâ] s := h s hs
theorem IsClosed.mono (hs : IsClosed[tâ] s) (h : tâ †tâ) : IsClosed[tâ] s :=
(@isOpen_compl_iff α s tâ).mp <| hs.isOpen_compl.mono h
theorem closure.mono (h : tâ †tâ) : closure[tâ] s â closure[tâ] s :=
@closure_minimal _ tâ s (@closure _ tâ s) subset_closure (IsClosed.mono isClosed_closure h)
theorem isOpen_implies_isOpen_iff : (â s, IsOpen[tâ] s â IsOpen[tâ] s) â tâ †tâ :=
Iff.rfl
/-- The only open sets in the indiscrete topology are the empty set and the whole space. -/
theorem TopologicalSpace.isOpen_top_iff {α} (U : Set α) : IsOpen[â€] U â U = â
âš U = univ :=
âšfun h => by
induction h with
| basic _ h => exact False.elim h
| univ => exact .inr rfl
| inter _ _ _ _ hâ hâ =>
rcases hâ with (rfl | rfl) <;> rcases hâ with (rfl | rfl) <;> simp
| sUnion _ _ ih => exact sUnion_mem_empty_univ ih, by
rintro (rfl | rfl)
exacts [@isOpen_empty _ â€, @isOpen_univ _ â€]â©
/-- A topological space is discrete if every set is open, that is,
its topology equals the discrete topology `â¥`. -/
class DiscreteTopology (α : Type*) [t : TopologicalSpace α] : Prop where
/-- The `TopologicalSpace` structure on a type with discrete topology is equal to `â¥`. -/
eq_bot : t = â¥
theorem discreteTopology_bot (α : Type*) : @DiscreteTopology α ⥠:=
@DiscreteTopology.mk α ⥠rfl
section DiscreteTopology
variable [TopologicalSpace α] [DiscreteTopology α] {β : Type*}
@[simp]
theorem isOpen_discrete (s : Set α) : IsOpen s := (@DiscreteTopology.eq_bot α _).symm ➠trivial
@[simp] theorem isClosed_discrete (s : Set α) : IsClosed s := âšisOpen_discrete _â©
theorem closure_discrete (s : Set α) : closure s = s := (isClosed_discrete _).closure_eq
@[simp] theorem dense_discrete {s : Set α} : Dense s â s = univ := by simp [dense_iff_closure_eq]
@[simp]
theorem denseRange_discrete {ι : Type*} {f : ι â α} : DenseRange f â Surjective f := by
rw [DenseRange, dense_discrete, range_eq_univ]
@[nontriviality, continuity, fun_prop]
theorem continuous_of_discreteTopology [TopologicalSpace β] {f : α â β} : Continuous f :=
continuous_def.2 fun _ _ => isOpen_discrete _
/-- A function to a discrete topological space is continuous if and only if the preimage of every
singleton is open. -/
theorem continuous_discrete_rng {α} [TopologicalSpace α] [TopologicalSpace β] [DiscreteTopology β]
{f : α â β} : Continuous f â â b : β, IsOpen (f â»Â¹' {b}) :=
âšfun h _ => (isOpen_discrete _).preimage h, fun h => âšfun s _ => by
rw [â biUnion_of_singleton s, preimage_iUnionâ]
exact isOpen_biUnion fun _ _ => h _â©â©
@[simp]
theorem nhds_discrete (α : Type*) [TopologicalSpace α] [DiscreteTopology α] : @nhds α _ = pure :=
le_antisymm (fun _ s hs => (isOpen_discrete s).mem_nhds hs) pure_le_nhds
theorem mem_nhds_discrete {x : α} {s : Set α} :
s â ð x â x â s := by rw [nhds_discrete, mem_pure]
end DiscreteTopology
theorem le_of_nhds_le_nhds (h : â x, @nhds α tâ x †@nhds α tâ x) : tâ †tâ := fun s => by
rw [@isOpen_iff_mem_nhds _ tâ, @isOpen_iff_mem_nhds _ tâ]
exact fun hs a ha => h _ (hs _ ha)
theorem eq_bot_of_singletons_open {t : TopologicalSpace α} (h : â x, IsOpen[t] {x}) : t = ⥠:=
bot_unique fun s _ => biUnion_of_singleton s âž isOpen_biUnion fun x _ => h x
theorem forall_open_iff_discrete {X : Type*} [TopologicalSpace X] :
(â s : Set X, IsOpen s) â DiscreteTopology X :=
âšfun h => âšeq_bot_of_singletons_open fun _ => h _â©, @isOpen_discrete _ _â©
theorem discreteTopology_iff_forall_isClosed [TopologicalSpace α] :
DiscreteTopology α â â s : Set α, IsClosed s :=
forall_open_iff_discrete.symm.trans <| compl_surjective.forall.trans <| forall_congr' fun _ âŠ
isOpen_compl_iff
theorem singletons_open_iff_discrete {X : Type*} [TopologicalSpace X] :
(â a : X, IsOpen ({a} : Set X)) â DiscreteTopology X :=
âšfun h => âšeq_bot_of_singletons_open hâ©, fun a _ => @isOpen_discrete _ _ a _â©
theorem DiscreteTopology.of_finite_of_isClosed_singleton [TopologicalSpace α] [Finite α]
(h : â a : α, IsClosed {a}) : DiscreteTopology α :=
discreteTopology_iff_forall_isClosed.mpr fun s âŠ
s.iUnion_of_singleton_coe ➠isClosed_iUnion_of_finite fun _ ⊠h _
theorem discreteTopology_iff_singleton_mem_nhds [TopologicalSpace α] :
DiscreteTopology α â â x : α, {x} â ð x := by
simp only [â singletons_open_iff_discrete, isOpen_iff_mem_nhds, mem_singleton_iff, forall_eq]
/-- This lemma characterizes discrete topological spaces as those whose singletons are
neighbourhoods. -/
theorem discreteTopology_iff_nhds [TopologicalSpace α] :
DiscreteTopology α â â x : α, ð x = pure x := by
simp [discreteTopology_iff_singleton_mem_nhds, le_pure_iff]
apply forall_congr' (fun x ⊠?_)
simp [le_antisymm_iff, pure_le_nhds x]
theorem discreteTopology_iff_nhds_ne [TopologicalSpace α] :
DiscreteTopology α â â x : α, ð[â ] x = ⥠:= by
simp only [discreteTopology_iff_singleton_mem_nhds, nhdsWithin, inf_principal_eq_bot, compl_compl]
/-- If the codomain of a continuous injective function has discrete topology,
then so does the domain.
See also `Embedding.discreteTopology` for an important special case. -/
theorem DiscreteTopology.of_continuous_injective
{β : Type*} [TopologicalSpace α] [TopologicalSpace β] [DiscreteTopology β] {f : α â β}
(hc : Continuous f) (hinj : Injective f) : DiscreteTopology α :=
forall_open_iff_discrete.1 fun s ⊠hinj.preimage_image s ➠(isOpen_discrete _).preimage hc
end Lattice
section GaloisConnection
variable {α β γ : Type*}
theorem isOpen_induced_iff [t : TopologicalSpace β] {s : Set α} {f : α â β} :
IsOpen[t.induced f] s â â t, IsOpen t â§ f â»Â¹' t = s :=
Iff.rfl
theorem isClosed_induced_iff [t : TopologicalSpace β] {s : Set α} {f : α â β} :
IsClosed[t.induced f] s â â t, IsClosed t â§ f â»Â¹' t = s := by
letI := t.induced f
simp only [â isOpen_compl_iff, isOpen_induced_iff]
exact compl_surjective.exists.trans (by simp only [preimage_compl, compl_inj_iff])
theorem isOpen_coinduced {t : TopologicalSpace α} {s : Set β} {f : α â β} :
IsOpen[t.coinduced f] s â IsOpen (f â»Â¹' s) :=
Iff.rfl
| theorem isClosed_coinduced {t : TopologicalSpace α} {s : Set β} {f : α â β} :
IsClosed[t.coinduced f] s â IsClosed (f â»Â¹' s) := by
simp only [â isOpen_compl_iff, isOpen_coinduced (f := f), preimage_compl]
| Mathlib/Topology/Order.lean | 355 | 357 |
/-
Copyright (c) 2021 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Kim Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
import Mathlib.Logic.Function.Basic
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `â` or `â€`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι â ι â Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i â¶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i â¶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i â¶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `â`, `â€`, or `Fin n`.
There is a relation `Rel : ι â ι â Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i â¶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι â ι â Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : â {i j j'}, Rel i j â Rel i j' â j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : â {i i' j}, Rel i j â Rel i' j â i = i'
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := rfl
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι â ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr âš_, symm_symm, symm_symmâ©
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
| @[simp]
def trans (câ câ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp câ.Rel câ.Rel
| Mathlib/Algebra/Homology/ComplexShape.lean | 100 | 102 |
/-
Copyright (c) 2023 Andrew Yang, Patrick Lutz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.RingTheory.RootsOfUnity.PrimitiveRoots
import Mathlib.FieldTheory.Galois.Basic
import Mathlib.FieldTheory.KummerPolynomial
import Mathlib.LinearAlgebra.Eigenspace.Minpoly
import Mathlib.RingTheory.Norm.Basic
/-!
# Kummer Extensions
## Main result
- `isCyclic_tfae`:
Suppose `L/K` is a finite extension of dimension `n`, and `K` contains all `n`-th roots of unity.
Then `L/K` is cyclic iff
`L` is a splitting field of some irreducible polynomial of the form `Xâ¿ - a : K[X]` iff
`L = K[α]` for some `α⿠â K`.
- `autEquivRootsOfUnity`:
Given an instance `IsSplittingField K L (X ^ n - C a)`
(perhaps via `isSplittingField_X_pow_sub_C_of_root_adjoin_eq_top`),
then the galois group is isomorphic to `rootsOfUnity n K`, by sending
`Ï âŠ Ï Î± / α` for `α ^ n = a`, and the inverse is given by `ÎŒ ⊠(α ⊠Ό ⢠α)`.
- `autEquivZmod`:
Furthermore, given an explicit choice `ζ` of a primitive `n`-th root of unity, the galois group is
then isomorphic to `Multiplicative (ZMod n)` whose inverse is given by
`i ⊠(α ⊠ζⱠ⢠α)`.
## Other results
Criteria for `X ^ n - C a` to be irreducible is given:
- `X_pow_sub_C_irreducible_iff_of_prime_pow`:
For `n = p ^ k` an odd prime power, `X ^ n - C a` is irreducible iff `a` is not a `p`-power.
- `X_pow_sub_C_irreducible_iff_forall_prime_of_odd`:
For `n` odd, `X ^ n - C a` is irreducible iff `a` is not a `p`-power for all prime `p ⣠n`.
- `X_pow_sub_C_irreducible_iff_of_odd`:
For `n` odd, `X ^ n - C a` is irreducible iff `a` is not a `d`-power for `d ⣠n` and `d â 1`.
TODO: criteria for even `n`. See [serge_lang_algebra] VI,§9.
TODO: relate Kummer extensions of degree 2 with the class `Algebra.IsQuadraticExtension`.
-/
universe u
variable {K : Type u} [Field K]
open Polynomial IntermediateField AdjoinRoot
section Splits
theorem X_pow_sub_C_splits_of_isPrimitiveRoot
{n : â} {ζ : K} (hζ : IsPrimitiveRoot ζ n) {α a : K} (e : α ^ n = a) :
(X ^ n - C a).Splits (RingHom.id _) := by
cases n.eq_zero_or_pos with
| inl hn =>
rw [hn, pow_zero, â C.map_one, â map_sub]
exact splits_C _ _
| inr hn =>
rw [splits_iff_card_roots, â nthRoots, hζ.card_nthRoots, natDegree_X_pow_sub_C, if_pos âšÎ±, eâ©]
-- make this private, as we only use it to prove a strictly more general version
private
theorem X_pow_sub_C_eq_prod'
{n : â} {ζ : K} (hζ : IsPrimitiveRoot ζ n) {α a : K} (hn : 0 < n) (e : α ^ n = a) :
(X ^ n - C a) = â i â Finset.range n, (X - C (ζ ^ i * α)) := by
rw [eq_prod_roots_of_monic_of_splits_id (monic_X_pow_sub_C _ (Nat.pos_iff_ne_zero.mp hn))
(X_pow_sub_C_splits_of_isPrimitiveRoot hζ e), â nthRoots, hζ.nthRoots_eq e, Multiset.map_map]
rfl
lemma X_pow_sub_C_eq_prod {R : Type*} [CommRing R] [IsDomain R]
{n : â} {ζ : R} (hζ : IsPrimitiveRoot ζ n) {α a : R} (hn : 0 < n) (e : α ^ n = a) :
(X ^ n - C a) = â i â Finset.range n, (X - C (ζ ^ i * α)) := by
let K := FractionRing R
let i := algebraMap R K
have h := FaithfulSMul.algebraMap_injective R K
apply_fun Polynomial.map i using map_injective i h
simpa only [Polynomial.map_sub, Polynomial.map_pow, map_X, map_C, map_mul, map_pow,
Polynomial.map_prod, Polynomial.map_mul]
using X_pow_sub_C_eq_prod' (hζ.map_of_injective h) hn <| map_pow i α n ➠congrArg i e
end Splits
section Irreducible
theorem X_pow_mul_sub_C_irreducible
{n m : â} {a : K} (hm : Irreducible (X ^ m - C a))
(hn : â (E : Type u) [Field E] [Algebra K E] (x : E) (_ : minpoly K x = X ^ m - C a),
Irreducible (X ^ n - C (AdjoinSimple.gen K x))) :
Irreducible (X ^ (n * m) - C a) := by
have hm' : m â 0 := by
rintro rfl
rw [pow_zero, â C.map_one, â map_sub] at hm
exact not_irreducible_C _ hm
simpa [pow_mul] using irreducible_comp (monic_X_pow_sub_C a hm') (monic_X_pow n) hm
(by simpa only [Polynomial.map_pow, map_X] using hn)
-- TODO: generalize to even `n`
theorem X_pow_sub_C_irreducible_of_odd
{n : â} (hn : Odd n) {a : K} (ha : â p : â, p.Prime â p ⣠n â â b : K, b ^ p â a) :
Irreducible (X ^ n - C a) := by
induction n using induction_on_primes generalizing K a with
| hâ => simp [â Nat.not_even_iff_odd] at hn
| hâ => simpa using irreducible_X_sub_C a
| h p n hp IH =>
rw [mul_comm]
apply X_pow_mul_sub_C_irreducible
(X_pow_sub_C_irreducible_of_prime hp (ha p hp (dvd_mul_right _ _)))
intro E _ _ x hx
have : IsIntegral K x := not_not.mp fun h ⊠by
simpa only [degree_zero, degree_X_pow_sub_C hp.pos,
WithBot.natCast_ne_bot] using congr_arg degree (hx.symm.trans (dif_neg h))
apply IH (Nat.odd_mul.mp hn).2
intros q hq hqn b hb
apply ha q hq (dvd_mul_of_dvd_right hqn p) (Algebra.norm _ b)
rw [â map_pow, hb, â adjoin.powerBasis_gen this,
Algebra.PowerBasis.norm_gen_eq_coeff_zero_minpoly]
simp [minpoly_gen, hx, hp.ne_zero.symm, (Nat.odd_mul.mp hn).1.neg_pow]
theorem X_pow_sub_C_irreducible_iff_forall_prime_of_odd {n : â} (hn : Odd n) {a : K} :
Irreducible (X ^ n - C a) â (â p : â, p.Prime â p ⣠n â â b : K, b ^ p â a) :=
âšfun e _ hp hpn ⊠pow_ne_of_irreducible_X_pow_sub_C e hpn hp.ne_one,
X_pow_sub_C_irreducible_of_odd hnâ©
theorem X_pow_sub_C_irreducible_iff_of_odd {n : â} (hn : Odd n) {a : K} :
Irreducible (X ^ n - C a) â (â d, d ⣠n â d â 1 â â b : K, b ^ d â a) :=
âšfun e _ ⊠pow_ne_of_irreducible_X_pow_sub_C e,
fun H ⊠X_pow_sub_C_irreducible_of_odd hn fun p hp hpn ⊠(H p hpn hp.ne_one)â©
-- TODO: generalize to `p = 2`
theorem X_pow_sub_C_irreducible_of_prime_pow
{p : â} (hp : p.Prime) (hp' : p â 2) (n : â) {a : K} (ha : â b : K, b ^ p â a) :
Irreducible (X ^ (p ^ n) - C a) := by
apply X_pow_sub_C_irreducible_of_odd (hp.odd_of_ne_two hp').pow
intros q hq hq'
simpa [(Nat.prime_dvd_prime_iff_eq hq hp).mp (hq.dvd_of_dvd_pow hq')] using ha
theorem X_pow_sub_C_irreducible_iff_of_prime_pow
{p : â} (hp : p.Prime) (hp' : p â 2) {n} (hn : n â 0) {a : K} :
Irreducible (X ^ p ^ n - C a) â â b, b ^ p â a :=
âš(pow_ne_of_irreducible_X_pow_sub_C · (dvd_pow dvd_rfl hn) hp.ne_one),
X_pow_sub_C_irreducible_of_prime_pow hp hp' nâ©
end Irreducible
/-!
### Galois Group of `K[nâa]`
We first develop the theory for a specific `K[nâa] := AdjoinRoot (X ^ n - C a)`.
The main result is the description of the galois group: `autAdjoinRootXPowSubCEquiv`.
| -/
variable {n : â} (hζ : (primitiveRoots n K).Nonempty)
variable (a : K) (H : Irreducible (X ^ n - C a))
set_option quotPrecheck false in
scoped[KummerExtension] notation3 "K[" n "â" a "]" => AdjoinRoot (Polynomial.X ^ n - Polynomial.C a)
attribute [nolint docBlame] KummerExtension.«termK[_â_]»
open scoped KummerExtension
section AdjoinRoot
include hζ H in
/-- Also see `Polynomial.separable_X_pow_sub_C_unit` -/
theorem Polynomial.separable_X_pow_sub_C_of_irreducible : (X ^ n - C a).Separable := by
letI := Fact.mk H
letI : Algebra K K[nâa] := inferInstance
have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H)
by_cases hn' : n = 1
· rw [hn', pow_one]; exact separable_X_sub_C
have âšÎ¶, hζ⩠:= hζ
rw [mem_primitiveRoots (Nat.pos_of_ne_zero <| ne_zero_of_irreducible_X_pow_sub_C H)] at hζ
rw [â separable_map (algebraMap K K[nâa]), Polynomial.map_sub, Polynomial.map_pow, map_C, map_X,
AdjoinRoot.algebraMap_eq,
X_pow_sub_C_eq_prod (hζ.map_of_injective (algebraMap K _).injective) hn
(root_X_pow_sub_C_pow n a), separable_prod_X_sub_C_iff']
#adaptation_note /-- https://github.com/leanprover/lean4/pull/5376
| Mathlib/FieldTheory/KummerExtension.lean | 151 | 179 |
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Filippo A. E. Nuccio
-/
import Mathlib.Algebra.EuclideanDomain.Basic
import Mathlib.RingTheory.FractionalIdeal.Basic
import Mathlib.RingTheory.IntegralClosure.IsIntegral.Basic
import Mathlib.RingTheory.LocalRing.Basic
import Mathlib.RingTheory.PrincipalIdealDomain
import Mathlib.Tactic.FieldSimp
/-!
# More operations on fractional ideals
## Main definitions
* `map` is the pushforward of a fractional ideal along an algebra morphism
Let `K` be the localization of `R` at `Râ° = R \ {0}` (i.e. the field of fractions).
* `FractionalIdeal Râ° K` is the type of fractional ideals in the field of fractions
* `Div (FractionalIdeal Râ° K)` instance:
the ideal quotient `I / J` (typically written $I : J$, but a `:` operator cannot be defined)
## Main statement
* `isNoetherian` states that every fractional ideal of a noetherian integral domain is noetherian
## References
* https://en.wikipedia.org/wiki/Fractional_ideal
## Tags
fractional ideal, fractional ideals, invertible ideal
-/
open IsLocalization Pointwise nonZeroDivisors
namespace FractionalIdeal
open Set Submodule
variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P]
variable [Algebra R P]
section
variable {P' : Type*} [CommRing P'] [Algebra R P']
variable {P'' : Type*} [CommRing P''] [Algebra R P'']
theorem _root_.IsFractional.map (g : P ââ[R] P') {I : Submodule R P} :
IsFractional S I â IsFractional S (Submodule.map g.toLinearMap I)
| âša, a_nonzero, hIâ© =>
âša, a_nonzero, fun b hb => by
obtain âšb', b'_mem, hb'â© := Submodule.mem_map.mp hb
rw [AlgHom.toLinearMap_apply] at hb'
obtain âšx, hxâ© := hI b' b'_mem
use x
rw [â g.commutes, hx, map_smul, hb']â©
/-- `I.map g` is the pushforward of the fractional ideal `I` along the algebra morphism `g` -/
def map (g : P ââ[R] P') : FractionalIdeal S P â FractionalIdeal S P' := fun I =>
âšSubmodule.map g.toLinearMap I, I.isFractional.map gâ©
@[simp, norm_cast]
theorem coe_map (g : P ââ[R] P') (I : FractionalIdeal S P) :
â(map g I) = Submodule.map g.toLinearMap I :=
rfl
@[simp]
theorem mem_map {I : FractionalIdeal S P} {g : P ââ[R] P'} {y : P'} :
y â I.map g â â x, x â I â§ g x = y :=
Submodule.mem_map
variable (I J : FractionalIdeal S P) (g : P ââ[R] P')
@[simp]
theorem map_id : I.map (AlgHom.id _ _) = I :=
coeToSubmodule_injective (Submodule.map_id (I : Submodule R P))
@[simp]
theorem map_comp (g' : P' ââ[R] P'') : I.map (g'.comp g) = (I.map g).map g' :=
coeToSubmodule_injective (Submodule.map_comp g.toLinearMap g'.toLinearMap I)
@[simp, norm_cast]
theorem map_coeIdeal (I : Ideal R) : (I : FractionalIdeal S P).map g = I := by
ext x
simp only [mem_coeIdeal]
constructor
· rintro âš_, âšy, hy, rflâ©, rflâ©
exact âšy, hy, (g.commutes y).symmâ©
· rintro âšy, hy, rflâ©
exact âš_, âšy, hy, rflâ©, g.commutes yâ©
@[simp]
protected theorem map_one : (1 : FractionalIdeal S P).map g = 1 :=
map_coeIdeal g â€
@[simp]
protected theorem map_zero : (0 : FractionalIdeal S P).map g = 0 :=
map_coeIdeal g 0
@[simp]
protected theorem map_add : (I + J).map g = I.map g + J.map g :=
coeToSubmodule_injective (Submodule.map_sup _ _ _)
@[simp]
protected theorem map_mul : (I * J).map g = I.map g * J.map g := by
simp only [mul_def]
exact coeToSubmodule_injective (Submodule.map_mul _ _ _)
@[simp]
theorem map_map_symm (g : P ââ[R] P') : (I.map (g : P ââ[R] P')).map (g.symm : P' ââ[R] P) = I := by
rw [â map_comp, g.symm_comp, map_id]
@[simp]
theorem map_symm_map (I : FractionalIdeal S P') (g : P ââ[R] P') :
(I.map (g.symm : P' ââ[R] P)).map (g : P ââ[R] P') = I := by
rw [â map_comp, g.comp_symm, map_id]
theorem map_mem_map {f : P ââ[R] P'} (h : Function.Injective f) {x : P} {I : FractionalIdeal S P} :
f x â map f I â x â I :=
mem_map.trans âšfun âš_, hx', x'_eqâ© => h x'_eq âž hx', fun h => âšx, h, rflâ©â©
theorem map_injective (f : P ââ[R] P') (h : Function.Injective f) :
Function.Injective (map f : FractionalIdeal S P â FractionalIdeal S P') := fun _ _ hIJ =>
ext fun _ => (map_mem_map h).symm.trans (hIJ.symm âž map_mem_map h)
/-- If `g` is an equivalence, `map g` is an isomorphism -/
def mapEquiv (g : P ââ[R] P') : FractionalIdeal S P â+* FractionalIdeal S P' where
toFun := map g
invFun := map g.symm
map_add' I J := FractionalIdeal.map_add I J _
map_mul' I J := FractionalIdeal.map_mul I J _
left_inv I := by rw [â map_comp, AlgEquiv.symm_comp, map_id]
right_inv I := by rw [â map_comp, AlgEquiv.comp_symm, map_id]
@[simp]
theorem coeFun_mapEquiv (g : P ââ[R] P') :
(mapEquiv g : FractionalIdeal S P â FractionalIdeal S P') = map g :=
rfl
@[simp]
theorem mapEquiv_apply (g : P ââ[R] P') (I : FractionalIdeal S P) : mapEquiv g I = map (âg) I :=
rfl
@[simp]
theorem mapEquiv_symm (g : P ââ[R] P') :
((mapEquiv g).symm : FractionalIdeal S P' â+* _) = mapEquiv g.symm :=
rfl
@[simp]
theorem mapEquiv_refl : mapEquiv AlgEquiv.refl = RingEquiv.refl (FractionalIdeal S P) :=
RingEquiv.ext fun x => by simp
theorem isFractional_span_iff {s : Set P} :
IsFractional S (span R s) â â a â S, â b : P, b â s â IsInteger R (a ⢠b) :=
âšfun âša, a_mem, hâ© => âša, a_mem, fun b hb => h b (subset_span hb)â©, fun âša, a_mem, hâ© =>
âša, a_mem, fun _ hb =>
span_induction (hx := hb) h
(by
rw [smul_zero]
exact isInteger_zero)
(fun x y _ _ hx hy => by
rw [smul_add]
exact isInteger_add hx hy)
fun s x _ hx => by
rw [smul_comm]
exact isInteger_smul hxâ©â©
theorem isFractional_of_fg [IsLocalization S P] {I : Submodule R P} (hI : I.FG) :
IsFractional S I := by
rcases hI with âšI, rflâ©
rcases exist_integer_multiples_of_finset S I with âšâšs, hs1â©, hsâ©
rw [isFractional_span_iff]
exact âšs, hs1, hsâ©
theorem mem_span_mul_finite_of_mem_mul {I J : FractionalIdeal S P} {x : P} (hx : x â I * J) :
â T T' : Finset P, (T : Set P) â I â§ (T' : Set P) â J â§ x â span R (T * T' : Set P) :=
Submodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx)
variable (S) in
theorem coeIdeal_fg (inj : Function.Injective (algebraMap R P)) (I : Ideal R) :
FG ((I : FractionalIdeal S P) : Submodule R P) â I.FG :=
coeSubmodule_fg _ inj _
theorem fg_unit (I : (FractionalIdeal S P)Ë£) : FG (I : Submodule R P) :=
Submodule.fg_unit <| Units.map (coeSubmoduleHom S P).toMonoidHom I
theorem fg_of_isUnit (I : FractionalIdeal S P) (h : IsUnit I) : FG (I : Submodule R P) :=
fg_unit h.unit
theorem _root_.Ideal.fg_of_isUnit (inj : Function.Injective (algebraMap R P)) (I : Ideal R)
(h : IsUnit (I : FractionalIdeal S P)) : I.FG := by
rw [â coeIdeal_fg S inj I]
exact FractionalIdeal.fg_of_isUnit (R := R) I h
variable (S P P')
variable [IsLocalization S P] [IsLocalization S P']
/-- `canonicalEquiv f f'` is the canonical equivalence between the fractional
ideals in `P` and in `P'`, which are both localizations of `R` at `S`. -/
noncomputable irreducible_def canonicalEquiv : FractionalIdeal S P â+* FractionalIdeal S P' :=
mapEquiv
{ ringEquivOfRingEquiv P P' (RingEquiv.refl R)
(show S.map _ = S by rw [RingEquiv.toMonoidHom_refl, Submonoid.map_id]) with
commutes' := fun _ => ringEquivOfRingEquiv_eq _ _ }
@[simp]
theorem mem_canonicalEquiv_apply {I : FractionalIdeal S P} {x : P'} :
x â canonicalEquiv S P P' I â
â y â I,
IsLocalization.map P' (RingHom.id R) (fun y (hy : y â S) => show RingHom.id R y â S from hy)
(y : P) =
x := by
rw [canonicalEquiv, mapEquiv_apply, mem_map]
exact âšfun âšy, mem, Eqâ© => âšy, mem, Eqâ©, fun âšy, mem, Eqâ© => âšy, mem, Eqâ©â©
@[simp]
theorem canonicalEquiv_symm : (canonicalEquiv S P P').symm = canonicalEquiv S P' P :=
RingEquiv.ext fun I =>
SetLike.ext_iff.mpr fun x => by
rw [mem_canonicalEquiv_apply, canonicalEquiv, mapEquiv_symm, mapEquiv_apply,
mem_map]
exact âšfun âšy, mem, Eqâ© => âšy, mem, Eqâ©, fun âšy, mem, Eqâ© => âšy, mem, Eqâ©â©
theorem canonicalEquiv_flip (I) : canonicalEquiv S P P' (canonicalEquiv S P' P I) = I := by
rw [â canonicalEquiv_symm, RingEquiv.symm_apply_apply]
@[simp]
theorem canonicalEquiv_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P'']
[IsLocalization S P''] (I : FractionalIdeal S P) :
canonicalEquiv S P' P'' (canonicalEquiv S P P' I) = canonicalEquiv S P P'' I := by
ext
simp only [IsLocalization.map_map, RingHomInvPair.comp_eqâ, mem_canonicalEquiv_apply,
exists_prop, exists_exists_and_eq_and]
theorem canonicalEquiv_trans_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P'']
[IsLocalization S P''] :
(canonicalEquiv S P P').trans (canonicalEquiv S P' P'') = canonicalEquiv S P P'' :=
RingEquiv.ext (canonicalEquiv_canonicalEquiv S P P' P'')
@[simp]
theorem canonicalEquiv_coeIdeal (I : Ideal R) : canonicalEquiv S P P' I = I := by
ext
simp [IsLocalization.map_eq]
@[simp]
theorem canonicalEquiv_self : canonicalEquiv S P P = RingEquiv.refl _ := by
rw [â canonicalEquiv_trans_canonicalEquiv S P P]
convert (canonicalEquiv S P P).symm_trans_self
exact (canonicalEquiv_symm S P P).symm
end
section IsFractionRing
/-!
### `IsFractionRing` section
This section concerns fractional ideals in the field of fractions,
i.e. the type `FractionalIdeal Râ° K` where `IsFractionRing R K`.
-/
variable {K K' : Type*} [Field K] [Field K']
variable [Algebra R K] [IsFractionRing R K] [Algebra R K'] [IsFractionRing R K']
variable {I J : FractionalIdeal Râ° K} (h : K ââ[R] K')
/-- Nonzero fractional ideals contain a nonzero integer. -/
theorem exists_ne_zero_mem_isInteger [Nontrivial R] (hI : I â 0) :
â x, x â 0 â§ algebraMap R K x â I := by
obtain âšy : K, y_mem, y_not_memâ© :=
SetLike.exists_of_lt (by simpa only using bot_lt_iff_ne_bot.mpr hI)
have y_ne_zero : y â 0 := by simpa using y_not_mem
obtain âšz, âšx, hxâ©â© := exists_integer_multiple Râ° y
refine âšx, ?_, ?_â©
· rw [Ne, â @IsFractionRing.to_map_eq_zero_iff R _ K, hx, Algebra.smul_def]
exact mul_ne_zero (IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors z.2) y_ne_zero
· rw [hx]
exact smul_mem _ _ y_mem
theorem map_ne_zero [Nontrivial R] (hI : I â 0) : I.map h â 0 := by
obtain âšx, x_ne_zero, hxâ© := exists_ne_zero_mem_isInteger hI
contrapose! x_ne_zero with map_eq_zero
refine IsFractionRing.to_map_eq_zero_iff.mp (eq_zero_iff.mp map_eq_zero _ (mem_map.mpr ?_))
exact âšalgebraMap R K x, hx, h.commutes xâ©
@[simp]
theorem map_eq_zero_iff [Nontrivial R] : I.map h = 0 â I = 0 :=
âšnot_imp_not.mp (map_ne_zero _), fun hI => hI.symm âž FractionalIdeal.map_zero hâ©
theorem coeIdeal_injective : Function.Injective (fun (I : Ideal R) ⊠(I : FractionalIdeal RⰠK)) :=
coeIdeal_injective' le_rfl
theorem coeIdeal_inj {I J : Ideal R} :
(I : FractionalIdeal Râ° K) = (J : FractionalIdeal Râ° K) â I = J :=
coeIdeal_inj' le_rfl
@[simp]
theorem coeIdeal_eq_zero {I : Ideal R} : (I : FractionalIdeal Râ° K) = 0 â I = ⥠:=
coeIdeal_eq_zero' le_rfl
| theorem coeIdeal_ne_zero {I : Ideal R} : (I : FractionalIdeal Râ° K) â 0 â I â ⥠:=
coeIdeal_ne_zero' le_rfl
@[simp]
theorem coeIdeal_eq_one {I : Ideal R} : (I : FractionalIdeal Râ° K) = 1 â I = 1 := by
simpa only [Ideal.one_eq_top] using coeIdeal_inj
theorem coeIdeal_ne_one {I : Ideal R} : (I : FractionalIdeal Râ° K) â 1 â I â 1 :=
not_iff_not.mpr coeIdeal_eq_one
theorem num_eq_zero_iff [Nontrivial R] {I : FractionalIdeal Râ° K} : I.num = 0 â I = 0 :=
| Mathlib/RingTheory/FractionalIdeal/Operations.lean | 306 | 316 |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Algebra.BigOperators.Group.Finset.Sigma
import Mathlib.Algebra.Order.Interval.Finset.Basic
import Mathlib.Order.Interval.Finset.Nat
import Mathlib.Tactic.Linarith
/-!
# Results about big operators over intervals
We prove results about big operators over intervals.
-/
open Nat
variable {α M : Type*}
namespace Finset
section PartialOrder
variable [PartialOrder α] [CommMonoid M] {f : α â M} {a b : α}
section LocallyFiniteOrder
variable [LocallyFiniteOrder α]
@[to_additive]
lemma mul_prod_Ico_eq_prod_Icc (h : a †b) : f b * â x â Ico a b, f x = â x â Icc a b, f x := by
rw [Icc_eq_cons_Ico h, prod_cons]
@[to_additive]
lemma prod_Ico_mul_eq_prod_Icc (h : a †b) : (â x â Ico a b, f x) * f b = â x â Icc a b, f x := by
rw [mul_comm, mul_prod_Ico_eq_prod_Icc h]
@[to_additive]
lemma mul_prod_Ioc_eq_prod_Icc (h : a †b) : f a * â x â Ioc a b, f x = â x â Icc a b, f x := by
rw [Icc_eq_cons_Ioc h, prod_cons]
@[to_additive]
lemma prod_Ioc_mul_eq_prod_Icc (h : a †b) : (â x â Ioc a b, f x) * f a = â x â Icc a b, f x := by
rw [mul_comm, mul_prod_Ioc_eq_prod_Icc h]
end LocallyFiniteOrder
section LocallyFiniteOrderTop
variable [LocallyFiniteOrderTop α]
@[to_additive]
lemma mul_prod_Ioi_eq_prod_Ici (a : α) : f a * â x â Ioi a, f x = â x â Ici a, f x := by
rw [Ici_eq_cons_Ioi, prod_cons]
@[to_additive]
lemma prod_Ioi_mul_eq_prod_Ici (a : α) : (â x â Ioi a, f x) * f a = â x â Ici a, f x := by
rw [mul_comm, mul_prod_Ioi_eq_prod_Ici]
end LocallyFiniteOrderTop
section LocallyFiniteOrderBot
variable [LocallyFiniteOrderBot α]
@[to_additive]
lemma mul_prod_Iio_eq_prod_Iic (a : α) : f a * â x â Iio a, f x = â x â Iic a, f x := by
rw [Iic_eq_cons_Iio, prod_cons]
@[to_additive]
lemma prod_Iio_mul_eq_prod_Iic (a : α) : (â x â Iio a, f x) * f a = â x â Iic a, f x := by
rw [mul_comm, mul_prod_Iio_eq_prod_Iic]
end LocallyFiniteOrderBot
end PartialOrder
section LinearOrder
variable [Fintype α] [LinearOrder α] [LocallyFiniteOrderTop α] [LocallyFiniteOrderBot α]
[CommMonoid M]
@[to_additive]
lemma prod_prod_Ioi_mul_eq_prod_prod_off_diag (f : α â α â M) :
â i, â j â Ioi i, f j i * f i j = â i, â j â {i}á¶, f j i := by
simp_rw [â Ioi_disjUnion_Iio, prod_disjUnion, prod_mul_distrib]
congr 1
rw [prod_sigma', prod_sigma']
refine prod_nbij' (fun i ⊠âši.2, i.1â©) (fun i ⊠âši.2, i.1â©) ?_ ?_ ?_ ?_ ?_ <;> simp
end LinearOrder
section Generic
variable [CommMonoid M] {sâ sâ s : Finset α} {a : α} {g f : α â M}
@[to_additive]
theorem prod_Ico_add' [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMonoid α]
[ExistsAddOfLE α] [LocallyFiniteOrder α]
(f : α â M) (a b c : α) : (â x â Ico a b, f (x + c)) = â x â Ico (a + c) (b + c), f x := by
rw [â map_add_right_Ico, prod_map]
rfl
@[to_additive]
theorem prod_Ico_add [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMonoid α]
[ExistsAddOfLE α] [LocallyFiniteOrder α]
(f : α â M) (a b c : α) : (â x â Ico a b, f (c + x)) = â x â Ico (a + c) (b + c), f x := by
convert prod_Ico_add' f a b c using 2
rw [add_comm]
@[to_additive (attr := simp)]
theorem prod_Ico_add_right_sub_eq [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMonoid α]
[ExistsAddOfLE α] [LocallyFiniteOrder α] [Sub α] [OrderedSub α] (a b c : α) :
â x â Ico (a + c) (b + c), f (x - c) = â x â Ico a b, f x := by
simp only [â map_add_right_Ico, prod_map, addRightEmbedding_apply, add_tsub_cancel_right]
@[to_additive]
theorem prod_Ico_succ_top {a b : â} (hab : a †b) (f : â â M) :
(â k â Ico a (b + 1), f k) = (â k â Ico a b, f k) * f b := by
rw [Nat.Ico_succ_right_eq_insert_Ico hab, prod_insert right_not_mem_Ico, mul_comm]
@[to_additive]
theorem prod_eq_prod_Ico_succ_bot {a b : â} (hab : a < b) (f : â â M) :
â k â Ico a b, f k = f a * â k â Ico (a + 1) b, f k := by
have ha : a â Ico (a + 1) b := by simp
rw [â prod_insert ha, Nat.Ico_insert_succ_left hab]
@[to_additive]
theorem prod_Ico_consecutive (f : â â M) {m n k : â} (hmn : m †n) (hnk : n †k) :
((â i â Ico m n, f i) * â i â Ico n k, f i) = â i â Ico m k, f i :=
Ico_union_Ico_eq_Ico hmn hnk âž Eq.symm (prod_union (Ico_disjoint_Ico_consecutive m n k))
@[to_additive]
theorem prod_Ioc_consecutive (f : â â M) {m n k : â} (hmn : m †n) (hnk : n †k) :
((â i â Ioc m n, f i) * â i â Ioc n k, f i) = â i â Ioc m k, f i := by
rw [â Ioc_union_Ioc_eq_Ioc hmn hnk, prod_union]
apply disjoint_left.2 fun x hx h'x => _
intros x hx h'x
exact lt_irrefl _ ((mem_Ioc.1 h'x).1.trans_le (mem_Ioc.1 hx).2)
@[to_additive]
theorem prod_Ioc_succ_top {a b : â} (hab : a †b) (f : â â M) :
(â k â Ioc a (b + 1), f k) = (â k â Ioc a b, f k) * f (b + 1) := by
rw [â prod_Ioc_consecutive _ hab (Nat.le_succ b), Nat.Ioc_succ_singleton, prod_singleton]
@[to_additive]
theorem prod_Icc_succ_top {a b : â} (hab : a †b + 1) (f : â â M) :
(â k â Icc a (b + 1), f k) = (â k â Icc a b, f k) * f (b + 1) := by
rw [â Nat.Ico_succ_right, prod_Ico_succ_top hab, Nat.Ico_succ_right]
@[to_additive]
theorem prod_range_mul_prod_Ico (f : â â M) {m n : â} (h : m †n) :
((â k â range m, f k) * â k â Ico m n, f k) = â k â range n, f k :=
Nat.Ico_zero_eq_range âž Nat.Ico_zero_eq_range âž prod_Ico_consecutive f m.zero_le h
@[to_additive]
theorem prod_range_eq_mul_Ico (f : â â M) {n : â} (hn : 0 < n) :
â x â Finset.range n, f x = f 0 * â x â Ico 1 n, f x :=
Finset.range_eq_Ico âž Finset.prod_eq_prod_Ico_succ_bot hn f
@[to_additive]
theorem prod_Ico_eq_mul_inv {ÎŽ : Type*} [CommGroup ÎŽ] (f : â â ÎŽ) {m n : â} (h : m †n) :
â k â Ico m n, f k = (â k â range n, f k) * (â k â range m, f k)â»Â¹ :=
eq_mul_inv_iff_mul_eq.2 <| by (rw [mul_comm]; exact prod_range_mul_prod_Ico f h)
@[to_additive]
theorem prod_Ico_eq_div {ÎŽ : Type*} [CommGroup ÎŽ] (f : â â ÎŽ) {m n : â} (h : m †n) :
â k â Ico m n, f k = (â k â range n, f k) / â k â range m, f k := by
simpa only [div_eq_mul_inv] using prod_Ico_eq_mul_inv f h
@[to_additive]
theorem prod_range_div_prod_range {α : Type*} [CommGroup α] {f : â â α} {n m : â} (hnm : n †m) :
((â k â range m, f k) / â k â range n, f k) = â k â range m with n †k, f k := by
rw [â prod_Ico_eq_div f hnm]
congr
apply Finset.ext
simp only [mem_Ico, mem_filter, mem_range, *]
tauto
/-- The two ways of summing over `(i, j)` in the range `a †i †j < b` are equal. -/
theorem sum_Ico_Ico_comm {M : Type*} [AddCommMonoid M] (a b : â) (f : â â â â M) :
(â i â Finset.Ico a b, â j â Finset.Ico i b, f i j) =
â j â Finset.Ico a b, â i â Finset.Ico a (j + 1), f i j := by
rw [Finset.sum_sigma', Finset.sum_sigma']
refine sum_nbij' (fun x ⊠âšx.2, x.1â©) (fun x ⊠âšx.2, x.1â©) ?_ ?_ (fun _ _ ⊠rfl) (fun _ _ ⊠rfl)
(fun _ _ ⊠rfl) <;>
simp only [Finset.mem_Ico, Sigma.forall, Finset.mem_sigma] <;>
rintro a b âšâšhâ, hââ©, âšhâ, hââ©â© <;>
omega
/-- The two ways of summing over `(i, j)` in the range `a †i < j < b` are equal. -/
theorem sum_Ico_Ico_comm' {M : Type*} [AddCommMonoid M] (a b : â) (f : â â â â M) :
(â i â Finset.Ico a b, â j â Finset.Ico (i + 1) b, f i j) =
â j â Finset.Ico a b, â i â Finset.Ico a j, f i j := by
rw [Finset.sum_sigma', Finset.sum_sigma']
refine sum_nbij' (fun x ⊠âšx.2, x.1â©) (fun x ⊠âšx.2, x.1â©) ?_ ?_ (fun _ _ ⊠rfl) (fun _ _ ⊠rfl)
(fun _ _ ⊠rfl) <;>
simp only [Finset.mem_Ico, Sigma.forall, Finset.mem_sigma] <;>
rintro a b âšâšhâ, hââ©, âšhâ, hââ©â© <;>
omega
@[to_additive]
theorem prod_Ico_eq_prod_range (f : â â M) (m n : â) :
â k â Ico m n, f k = â k â range (n - m), f (m + k) := by
by_cases h : m †n
· rw [â Nat.Ico_zero_eq_range, prod_Ico_add, zero_add, tsub_add_cancel_of_le h]
| · replace h : n †m := le_of_not_ge h
rw [Ico_eq_empty_of_le h, tsub_eq_zero_iff_le.mpr h, range_zero, prod_empty, prod_empty]
theorem prod_Ico_reflect (f : â â M) (k : â) {m n : â} (h : m †n + 1) :
(â j â Ico k m, f (n - j)) = â j â Ico (n + 1 - m) (n + 1 - k), f j := by
have : â i < m, i †n := by
intro i hi
exact (add_le_add_iff_right 1).1 (le_trans (Nat.lt_iff_add_one_le.1 hi) h)
rcases lt_or_le k m with hkm | hkm
| Mathlib/Algebra/BigOperators/Intervals.lean | 200 | 208 |
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Simon Hudon, Mario Carneiro
-/
import Aesop
import Mathlib.Algebra.Group.Defs
import Mathlib.Data.Nat.Init
import Mathlib.Data.Int.Init
import Mathlib.Logic.Function.Iterate
import Mathlib.Tactic.SimpRw
import Mathlib.Tactic.SplitIfs
/-!
# Basic lemmas about semigroups, monoids, and groups
This file lists various basic lemmas about semigroups, monoids, and groups. Most proofs are
one-liners from the corresponding axioms. For the definitions of semigroups, monoids and groups, see
`Algebra/Group/Defs.lean`.
-/
assert_not_exists MonoidWithZero DenselyOrdered
open Function
variable {α β G M : Type*}
section ite
variable [Pow α β]
@[to_additive (attr := simp) dite_smul]
lemma pow_dite (p : Prop) [Decidable p] (a : α) (b : p â β) (c : ¬ p â β) :
a ^ (if h : p then b h else c h) = if h : p then a ^ b h else a ^ c h := by split_ifs <;> rfl
@[to_additive (attr := simp) smul_dite]
lemma dite_pow (p : Prop) [Decidable p] (a : p â α) (b : ¬ p â α) (c : β) :
(if h : p then a h else b h) ^ c = if h : p then a h ^ c else b h ^ c := by split_ifs <;> rfl
@[to_additive (attr := simp) ite_smul]
lemma pow_ite (p : Prop) [Decidable p] (a : α) (b c : β) :
a ^ (if p then b else c) = if p then a ^ b else a ^ c := pow_dite _ _ _ _
@[to_additive (attr := simp) smul_ite]
lemma ite_pow (p : Prop) [Decidable p] (a b : α) (c : β) :
(if p then a else b) ^ c = if p then a ^ c else b ^ c := dite_pow _ _ _ _
set_option linter.existingAttributeWarning false in
attribute [to_additive (attr := simp)] dite_smul smul_dite ite_smul smul_ite
end ite
section Semigroup
variable [Semigroup α]
@[to_additive]
instance Semigroup.to_isAssociative : Std.Associative (α := α) (· * ·) := âšmul_assocâ©
/-- Composing two multiplications on the left by `y` then `x`
is equal to a multiplication on the left by `x * y`.
-/
@[to_additive (attr := simp) "Composing two additions on the left by `y` then `x`
is equal to an addition on the left by `x + y`."]
theorem comp_mul_left (x y : α) : (x * ·) â (y * ·) = (x * y * ·) := by
ext z
simp [mul_assoc]
/-- Composing two multiplications on the right by `y` and `x`
is equal to a multiplication on the right by `y * x`.
-/
@[to_additive (attr := simp) "Composing two additions on the right by `y` and `x`
is equal to an addition on the right by `y + x`."]
theorem comp_mul_right (x y : α) : (· * x) â (· * y) = (· * (y * x)) := by
ext z
simp [mul_assoc]
end Semigroup
@[to_additive]
instance CommMagma.to_isCommutative [CommMagma G] : Std.Commutative (α := G) (· * ·) := âšmul_commâ©
section MulOneClass
variable [MulOneClass M]
@[to_additive]
theorem ite_mul_one {P : Prop} [Decidable P] {a b : M} :
ite P (a * b) 1 = ite P a 1 * ite P b 1 := by
by_cases h : P <;> simp [h]
@[to_additive]
theorem ite_one_mul {P : Prop} [Decidable P] {a b : M} :
ite P 1 (a * b) = ite P 1 a * ite P 1 b := by
by_cases h : P <;> simp [h]
@[to_additive]
theorem eq_one_iff_eq_one_of_mul_eq_one {a b : M} (h : a * b = 1) : a = 1 â b = 1 := by
constructor <;> (rintro rfl; simpa using h)
@[to_additive]
theorem one_mul_eq_id : ((1 : M) * ·) = id :=
funext one_mul
@[to_additive]
theorem mul_one_eq_id : (· * (1 : M)) = id :=
funext mul_one
end MulOneClass
section CommSemigroup
variable [CommSemigroup G]
@[to_additive]
theorem mul_left_comm (a b c : G) : a * (b * c) = b * (a * c) := by
rw [â mul_assoc, mul_comm a, mul_assoc]
@[to_additive]
theorem mul_right_comm (a b c : G) : a * b * c = a * c * b := by
rw [mul_assoc, mul_comm b, mul_assoc]
@[to_additive]
theorem mul_mul_mul_comm (a b c d : G) : a * b * (c * d) = a * c * (b * d) := by
simp only [mul_left_comm, mul_assoc]
@[to_additive]
theorem mul_rotate (a b c : G) : a * b * c = b * c * a := by
simp only [mul_left_comm, mul_comm]
@[to_additive]
theorem mul_rotate' (a b c : G) : a * (b * c) = b * (c * a) := by
simp only [mul_left_comm, mul_comm]
end CommSemigroup
attribute [local simp] mul_assoc sub_eq_add_neg
section Monoid
variable [Monoid M] {a b : M} {m n : â}
@[to_additive boole_nsmul]
lemma pow_boole (P : Prop) [Decidable P] (a : M) :
(a ^ if P then 1 else 0) = if P then a else 1 := by simp only [pow_ite, pow_one, pow_zero]
@[to_additive nsmul_add_sub_nsmul]
lemma pow_mul_pow_sub (a : M) (h : m †n) : a ^ m * a ^ (n - m) = a ^ n := by
rw [â pow_add, Nat.add_comm, Nat.sub_add_cancel h]
@[to_additive sub_nsmul_nsmul_add]
lemma pow_sub_mul_pow (a : M) (h : m †n) : a ^ (n - m) * a ^ m = a ^ n := by
rw [â pow_add, Nat.sub_add_cancel h]
@[to_additive sub_one_nsmul_add]
lemma mul_pow_sub_one (hn : n â 0) (a : M) : a * a ^ (n - 1) = a ^ n := by
rw [â pow_succ', Nat.sub_add_cancel <| Nat.one_le_iff_ne_zero.2 hn]
@[to_additive add_sub_one_nsmul]
lemma pow_sub_one_mul (hn : n â 0) (a : M) : a ^ (n - 1) * a = a ^ n := by
rw [â pow_succ, Nat.sub_add_cancel <| Nat.one_le_iff_ne_zero.2 hn]
/-- If `x ^ n = 1`, then `x ^ m` is the same as `x ^ (m % n)` -/
@[to_additive nsmul_eq_mod_nsmul "If `n ⢠x = 0`, then `m ⢠x` is the same as `(m % n) ⢠x`"]
lemma pow_eq_pow_mod (m : â) (ha : a ^ n = 1) : a ^ m = a ^ (m % n) := by
calc
a ^ m = a ^ (m % n + n * (m / n)) := by rw [Nat.mod_add_div]
_ = a ^ (m % n) := by simp [pow_add, pow_mul, ha]
@[to_additive] lemma pow_mul_pow_eq_one : â n, a * b = 1 â a ^ n * b ^ n = 1
| 0, _ => by simp
| n + 1, h =>
calc
a ^ n.succ * b ^ n.succ = a ^ n * a * (b * b ^ n) := by rw [pow_succ, pow_succ']
_ = a ^ n * (a * b) * b ^ n := by simp only [mul_assoc]
_ = 1 := by simp [h, pow_mul_pow_eq_one]
@[to_additive (attr := simp)]
lemma mul_left_iterate (a : M) : â n : â, (a * ·)^[n] = (a ^ n * ·)
| 0 => by ext; simp
| n + 1 => by ext; simp [pow_succ, mul_left_iterate]
@[to_additive (attr := simp)]
lemma mul_right_iterate (a : M) : â n : â, (· * a)^[n] = (· * a ^ n)
| 0 => by ext; simp
| n + 1 => by ext; simp [pow_succ', mul_right_iterate]
@[to_additive]
lemma mul_left_iterate_apply_one (a : M) : (a * ·)^[n] 1 = a ^ n := by simp [mul_right_iterate]
@[to_additive]
lemma mul_right_iterate_apply_one (a : M) : (· * a)^[n] 1 = a ^ n := by simp [mul_right_iterate]
@[to_additive (attr := simp)]
lemma pow_iterate (k : â) : â n : â, (fun x : M ⊠x ^ k)^[n] = (· ^ k ^ n)
| 0 => by ext; simp
| n + 1 => by ext; simp [pow_iterate, Nat.pow_succ', pow_mul]
end Monoid
section CommMonoid
variable [CommMonoid M] {x y z : M}
@[to_additive]
theorem inv_unique (hy : x * y = 1) (hz : x * z = 1) : y = z :=
left_inv_eq_right_inv (Trans.trans (mul_comm _ _) hy) hz
@[to_additive nsmul_add] lemma mul_pow (a b : M) : â n, (a * b) ^ n = a ^ n * b ^ n
| 0 => by rw [pow_zero, pow_zero, pow_zero, one_mul]
| n + 1 => by rw [pow_succ', pow_succ', pow_succ', mul_pow, mul_mul_mul_comm]
end CommMonoid
section LeftCancelMonoid
variable [Monoid M] [IsLeftCancelMul M] {a b : M}
@[to_additive (attr := simp)]
theorem mul_eq_left : a * b = a â b = 1 := calc
a * b = a â a * b = a * 1 := by rw [mul_one]
_ â b = 1 := mul_left_cancel_iff
@[deprecated (since := "2025-03-05")] alias mul_right_eq_self := mul_eq_left
@[deprecated (since := "2025-03-05")] alias add_right_eq_self := add_eq_left
set_option linter.existingAttributeWarning false in
attribute [to_additive existing] mul_right_eq_self
@[to_additive (attr := simp)]
theorem left_eq_mul : a = a * b â b = 1 :=
eq_comm.trans mul_eq_left
@[deprecated (since := "2025-03-05")] alias self_eq_mul_right := left_eq_mul
@[deprecated (since := "2025-03-05")] alias self_eq_add_right := left_eq_add
set_option linter.existingAttributeWarning false in
attribute [to_additive existing] self_eq_mul_right
@[to_additive]
theorem mul_ne_left : a * b â a â b â 1 := mul_eq_left.not
@[deprecated (since := "2025-03-05")] alias mul_right_ne_self := mul_ne_left
@[deprecated (since := "2025-03-05")] alias add_right_ne_self := add_ne_left
set_option linter.existingAttributeWarning false in
attribute [to_additive existing] mul_right_ne_self
@[to_additive]
theorem left_ne_mul : a â a * b â b â 1 := left_eq_mul.not
@[deprecated (since := "2025-03-05")] alias self_ne_mul_right := left_ne_mul
@[deprecated (since := "2025-03-05")] alias self_ne_add_right := left_ne_add
set_option linter.existingAttributeWarning false in
attribute [to_additive existing] self_ne_mul_right
end LeftCancelMonoid
section RightCancelMonoid
variable [RightCancelMonoid M] {a b : M}
@[to_additive (attr := simp)]
theorem mul_eq_right : a * b = b â a = 1 := calc
a * b = b â a * b = 1 * b := by rw [one_mul]
_ â a = 1 := mul_right_cancel_iff
@[deprecated (since := "2025-03-05")] alias mul_left_eq_self := mul_eq_right
@[deprecated (since := "2025-03-05")] alias add_left_eq_self := add_eq_right
set_option linter.existingAttributeWarning false in
attribute [to_additive existing] mul_left_eq_self
@[to_additive (attr := simp)]
theorem right_eq_mul : b = a * b â a = 1 :=
eq_comm.trans mul_eq_right
@[deprecated (since := "2025-03-05")] alias self_eq_mul_left := right_eq_mul
@[deprecated (since := "2025-03-05")] alias self_eq_add_left := right_eq_add
set_option linter.existingAttributeWarning false in
attribute [to_additive existing] self_eq_mul_left
|
@[to_additive]
theorem mul_ne_right : a * b â b â a â 1 := mul_eq_right.not
@[deprecated (since := "2025-03-05")] alias mul_left_ne_self := mul_ne_right
@[deprecated (since := "2025-03-05")] alias add_left_ne_self := add_ne_right
| Mathlib/Algebra/Group/Basic.lean | 280 | 285 |
/-
Copyright (c) 2022 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import Mathlib.NumberTheory.Cyclotomic.Discriminant
import Mathlib.RingTheory.Polynomial.Eisenstein.IsIntegral
import Mathlib.RingTheory.Ideal.Norm.AbsNorm
import Mathlib.RingTheory.Prime
/-!
# Ring of integers of `p ^ n`-th cyclotomic fields
We gather results about cyclotomic extensions of `â`. In particular, we compute the ring of
integers of a `p ^ n`-th cyclotomic extension of `â`.
## Main results
* `IsCyclotomicExtension.Rat.isIntegralClosure_adjoin_singleton_of_prime_pow`: if `K` is a
`p ^ k`-th cyclotomic extension of `â`, then `(adjoin †{ζ})` is the integral closure of
`â€` in `K`.
* `IsCyclotomicExtension.Rat.cyclotomicRing_isIntegralClosure_of_prime_pow`: the integral
closure of `â€` inside `CyclotomicField (p ^ k) â` is `CyclotomicRing (p ^ k) †â`.
* `IsCyclotomicExtension.Rat.absdiscr_prime_pow` and related results: the absolute discriminant
of cyclotomic fields.
-/
universe u
open Algebra IsCyclotomicExtension Polynomial NumberField
open scoped Cyclotomic Nat
variable {p : â+} {k : â} {K : Type u} [Field K] {ζ : K} [hp : Fact (p : â).Prime]
namespace IsCyclotomicExtension.Rat
variable [CharZero K]
/-- The discriminant of the power basis given by `ζ - 1`. -/
theorem discr_prime_pow_ne_two' [IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) (hk : p ^ (k + 1) â 2) :
discr â (hζ.subOnePowerBasis â).basis =
(-1) ^ ((p ^ (k + 1) : â).totient / 2) * p ^ ((p : â) ^ k * ((p - 1) * (k + 1) - 1)) := by
rw [â discr_prime_pow_ne_two hζ (cyclotomic.irreducible_rat (p ^ (k + 1)).pos) hk]
exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm
theorem discr_odd_prime' [IsCyclotomicExtension {p} â K] (hζ : IsPrimitiveRoot ζ p) (hodd : p â 2) :
discr â (hζ.subOnePowerBasis â).basis = (-1) ^ (((p : â) - 1) / 2) * p ^ ((p : â) - 2) := by
rw [â discr_odd_prime hζ (cyclotomic.irreducible_rat hp.out.pos) hodd]
exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm
/-- The discriminant of the power basis given by `ζ - 1`. Beware that in the cases `p ^ k = 1` and
`p ^ k = 2` the formula uses `1 / 2 = 0` and `0 - 1 = 0`. It is useful only to have a uniform
result. See also `IsCyclotomicExtension.Rat.discr_prime_pow_eq_unit_mul_pow'`. -/
theorem discr_prime_pow' [IsCyclotomicExtension {p ^ k} â K] (hζ : IsPrimitiveRoot ζ â(p ^ k)) :
discr â (hζ.subOnePowerBasis â).basis =
(-1) ^ ((p ^ k : â).totient / 2) * p ^ ((p : â) ^ (k - 1) * ((p - 1) * k - 1)) := by
rw [â discr_prime_pow hζ (cyclotomic.irreducible_rat (p ^ k).pos)]
exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm
/-- If `p` is a prime and `IsCyclotomicExtension {p ^ k} K L`, then there are `u : â€Ë£` and
`n : â` such that the discriminant of the power basis given by `ζ - 1` is `u * p ^ n`. Often this is
enough and less cumbersome to use than `IsCyclotomicExtension.Rat.discr_prime_pow'`. -/
theorem discr_prime_pow_eq_unit_mul_pow' [IsCyclotomicExtension {p ^ k} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ k)) :
â (u : â€Ë£) (n : â), discr â (hζ.subOnePowerBasis â).basis = u * p ^ n := by
rw [hζ.discr_zeta_eq_discr_zeta_sub_one.symm]
exact discr_prime_pow_eq_unit_mul_pow hζ (cyclotomic.irreducible_rat (p ^ k).pos)
/-- If `K` is a `p ^ k`-th cyclotomic extension of `â`, then `(adjoin †{ζ})` is the
integral closure of `â€` in `K`. -/
theorem isIntegralClosure_adjoin_singleton_of_prime_pow [hcycl : IsCyclotomicExtension {p ^ k} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ k)) : IsIntegralClosure (adjoin †({ζ} : Set K)) †K := by
refine âšSubtype.val_injective, @fun x => âšfun h => âšâšx, ?_â©, rflâ©, ?_â©â©
swap
· rintro âšy, rflâ©
exact
IsIntegral.algebraMap
((le_integralClosure_iff_isIntegral.1
(adjoin_le_integralClosure (hζ.isIntegral (p ^ k).pos))).isIntegral _)
let B := hζ.subOnePowerBasis â
have hint : IsIntegral †B.gen := (hζ.isIntegral (p ^ k).pos).sub isIntegral_one
-- Porting note: the following `letI` was not needed because the locale `cyclotomic` set it
-- as instances.
letI := IsCyclotomicExtension.finiteDimensional {p ^ k} â K
have H := discr_mul_isIntegral_mem_adjoin â hint h
obtain âšu, n, hunâ© := discr_prime_pow_eq_unit_mul_pow' hζ
rw [hun] at H
replace H := Subalgebra.smul_mem _ H u.inv
rw [â smul_assoc, â smul_mul_assoc, Units.inv_eq_val_inv, zsmul_eq_mul, â Int.cast_mul,
Units.inv_mul, Int.cast_one, one_mul, smul_def, map_pow] at H
cases k
· haveI : IsCyclotomicExtension {1} â K := by simpa using hcycl
have : x â (⥠: Subalgebra â K) := by
rw [singleton_one â K]
exact mem_top
obtain âšy, rflâ© := mem_bot.1 this
replace h := (isIntegral_algebraMap_iff (algebraMap â K).injective).1 h
obtain âšz, hzâ© := IsIntegrallyClosed.isIntegral_iff.1 h
rw [â hz, â IsScalarTower.algebraMap_apply]
exact Subalgebra.algebraMap_mem _ _
· have hmin : (minpoly †B.gen).IsEisensteinAt (Submodule.span †{((p : â) : â€)}) := by
have hâ := minpoly.isIntegrallyClosed_eq_field_fractions' â hint
have hâ := hζ.minpoly_sub_one_eq_cyclotomic_comp (cyclotomic.irreducible_rat (p ^ _).pos)
rw [IsPrimitiveRoot.subOnePowerBasis_gen] at hâ
rw [hâ, â map_cyclotomic_int, show Int.castRingHom â = algebraMap †â by rfl,
show X + 1 = map (algebraMap †â) (X + 1) by simp, â map_comp] at hâ
rw [IsPrimitiveRoot.subOnePowerBasis_gen,
map_injective (algebraMap †â) (algebraMap †â).injective_int hâ]
exact cyclotomic_prime_pow_comp_X_add_one_isEisensteinAt p _
refine
adjoin_le ?_
(mem_adjoin_of_smul_prime_pow_smul_of_minpoly_isEisensteinAt (n := n)
(Nat.prime_iff_prime_int.1 hp.out) hint h (by simpa using H) hmin)
simp only [Set.singleton_subset_iff, SetLike.mem_coe]
exact Subalgebra.sub_mem _ (self_mem_adjoin_singleton †_) (Subalgebra.one_mem _)
theorem isIntegralClosure_adjoin_singleton_of_prime [hcycl : IsCyclotomicExtension {p} â K]
(hζ : IsPrimitiveRoot ζ âp) : IsIntegralClosure (adjoin †({ζ} : Set K)) †K := by
rw [â pow_one p] at hζ hcycl
exact isIntegralClosure_adjoin_singleton_of_prime_pow hζ
/-- The integral closure of `â€` inside `CyclotomicField (p ^ k) â` is
`CyclotomicRing (p ^ k) †â`. -/
theorem cyclotomicRing_isIntegralClosure_of_prime_pow :
IsIntegralClosure (CyclotomicRing (p ^ k) †â) †(CyclotomicField (p ^ k) â) := by
have hζ := zeta_spec (p ^ k) â (CyclotomicField (p ^ k) â)
refine âšIsFractionRing.injective _ _, @fun x => âšfun h => âšâšx, ?_â©, rflâ©, ?_â©â©
· obtain âšy, rflâ© := (isIntegralClosure_adjoin_singleton_of_prime_pow hζ).isIntegral_iff.1 h
refine adjoin_mono ?_ y.2
simp only [PNat.pow_coe, Set.singleton_subset_iff, Set.mem_setOf_eq]
exact hζ.pow_eq_one
· rintro âšy, rflâ©
exact IsIntegral.algebraMap ((IsCyclotomicExtension.integral {p ^ k} †_).isIntegral _)
theorem cyclotomicRing_isIntegralClosure_of_prime :
IsIntegralClosure (CyclotomicRing p †â) †(CyclotomicField p â) := by
rw [â pow_one p]
exact cyclotomicRing_isIntegralClosure_of_prime_pow
end IsCyclotomicExtension.Rat
section PowerBasis
open IsCyclotomicExtension.Rat
namespace IsPrimitiveRoot
section CharZero
variable [CharZero K]
/-- The algebra isomorphism `adjoin †{ζ} ââ[â€] (ð K)`, where `ζ` is a primitive `p ^ k`-th root of
unity and `K` is a `p ^ k`-th cyclotomic extension of `â`. -/
@[simps!]
noncomputable def _root_.IsPrimitiveRoot.adjoinEquivRingOfIntegers
[IsCyclotomicExtension {p ^ k} â K] (hζ : IsPrimitiveRoot ζ â(p ^ k)) :
adjoin †({ζ} : Set K) ââ[â€] ð K :=
let _ := isIntegralClosure_adjoin_singleton_of_prime_pow hζ
IsIntegralClosure.equiv †(adjoin †({ζ} : Set K)) K (ð K)
/-- The ring of integers of a `p ^ k`-th cyclotomic extension of `â` is a cyclotomic extension. -/
instance IsCyclotomicExtension.ringOfIntegers [IsCyclotomicExtension {p ^ k} â K] :
IsCyclotomicExtension {p ^ k} †(ð K) :=
let _ := (zeta_spec (p ^ k) â K).adjoin_isCyclotomicExtension â€
IsCyclotomicExtension.equiv _ †_ (zeta_spec (p ^ k) â K).adjoinEquivRingOfIntegers
/-- The integral `PowerBasis` of `ð K` given by a primitive root of unity, where `K` is a `p ^ k`
cyclotomic extension of `â`. -/
noncomputable def integralPowerBasis [IsCyclotomicExtension {p ^ k} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ k)) : PowerBasis †(ð K) :=
(Algebra.adjoin.powerBasis' (hζ.isIntegral (p ^ k).pos)).map hζ.adjoinEquivRingOfIntegers
/-- Abbreviation to see a primitive root of unity as a member of the ring of integers. -/
abbrev toInteger {k : â+} (hζ : IsPrimitiveRoot ζ k) : ð K := âšÎ¶, hζ.isIntegral k.posâ©
end CharZero
lemma coe_toInteger {k : â+} (hζ : IsPrimitiveRoot ζ k) : hζ.toInteger.1 = ζ := rfl
/-- `ð K â§ž Ideal.span {ζ - 1}` is finite. -/
lemma finite_quotient_toInteger_sub_one [NumberField K] {k : â+} (hk : 1 < k)
(hζ : IsPrimitiveRoot ζ k) : Finite (ð K â§ž Ideal.span {hζ.toInteger - 1}) := by
refine Ideal.finiteQuotientOfFreeOfNeBot _ (fun h ⊠?_)
simp only [Ideal.span_singleton_eq_bot, sub_eq_zero, â Subtype.coe_inj] at h
exact hζ.ne_one hk (RingOfIntegers.ext_iff.1 h)
/-- We have that `ð K â§ž Ideal.span {ζ - 1}` has cardinality equal to the norm of `ζ - 1`.
See the results below to compute this norm in various cases. -/
lemma card_quotient_toInteger_sub_one [NumberField K] {k : â+} (hζ : IsPrimitiveRoot ζ k) :
Nat.card (ð K â§ž Ideal.span {hζ.toInteger - 1}) =
(Algebra.norm †(hζ.toInteger - 1)).natAbs := by
rw [â Submodule.cardQuot_apply, â Ideal.absNorm_apply, Ideal.absNorm_span_singleton]
lemma toInteger_isPrimitiveRoot {k : â+} (hζ : IsPrimitiveRoot ζ k) :
IsPrimitiveRoot hζ.toInteger k :=
IsPrimitiveRoot.of_map_of_injective (by exact hζ) RingOfIntegers.coe_injective
variable [CharZero K]
@[simp]
theorem integralPowerBasis_gen [hcycl : IsCyclotomicExtension {p ^ k} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ k)) :
hζ.integralPowerBasis.gen = hζ.toInteger :=
Subtype.ext <| show algebraMap _ K hζ.integralPowerBasis.gen = _ by
rw [integralPowerBasis, PowerBasis.map_gen, adjoin.powerBasis'_gen]
simp only [adjoinEquivRingOfIntegers_apply, IsIntegralClosure.algebraMap_lift]
rfl
#adaptation_note /-- https://github.com/leanprover/lean4/pull/5338
We name `hcycl` so it can be used as a named argument,
but since https://github.com/leanprover/lean4/pull/5338, this is considered unused,
so we need to disable the linter. -/
set_option linter.unusedVariables false in
@[simp]
theorem integralPowerBasis_dim [hcycl : IsCyclotomicExtension {p ^ k} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ k)) : hζ.integralPowerBasis.dim = Ï (p ^ k) := by
simp [integralPowerBasis, â cyclotomic_eq_minpoly hζ, natDegree_cyclotomic]
/-- The algebra isomorphism `adjoin †{ζ} ââ[â€] (ð K)`, where `ζ` is a primitive `p`-th root of
unity and `K` is a `p`-th cyclotomic extension of `â`. -/
@[simps!]
noncomputable def _root_.IsPrimitiveRoot.adjoinEquivRingOfIntegers'
[hcycl : IsCyclotomicExtension {p} â K] (hζ : IsPrimitiveRoot ζ p) :
adjoin †({ζ} : Set K) ââ[â€] ð K :=
have : IsCyclotomicExtension {p ^ 1} â K := by convert hcycl; rw [pow_one]
adjoinEquivRingOfIntegers (p := p) (k := 1) (ζ := ζ) (by rwa [pow_one])
/-- The ring of integers of a `p`-th cyclotomic extension of `â` is a cyclotomic extension. -/
instance _root_.IsCyclotomicExtension.ring_of_integers' [IsCyclotomicExtension {p} â K] :
IsCyclotomicExtension {p} †(ð K) :=
let _ := (zeta_spec p â K).adjoin_isCyclotomicExtension â€
IsCyclotomicExtension.equiv _ †_ (zeta_spec p â K).adjoinEquivRingOfIntegers'
/-- The integral `PowerBasis` of `ð K` given by a primitive root of unity, where `K` is a `p`-th
cyclotomic extension of `â`. -/
noncomputable def integralPowerBasis' [hcycl : IsCyclotomicExtension {p} â K]
(hζ : IsPrimitiveRoot ζ p) : PowerBasis †(ð K) :=
have : IsCyclotomicExtension {p ^ 1} â K := by convert hcycl; rw [pow_one]
integralPowerBasis (p := p) (k := 1) (ζ := ζ) (by rwa [pow_one])
@[simp]
theorem integralPowerBasis'_gen [hcycl : IsCyclotomicExtension {p} â K] (hζ : IsPrimitiveRoot ζ p) :
hζ.integralPowerBasis'.gen = hζ.toInteger :=
integralPowerBasis_gen (hcycl := by rwa [pow_one]) (by rwa [pow_one])
@[simp]
theorem power_basis_int'_dim [hcycl : IsCyclotomicExtension {p} â K] (hζ : IsPrimitiveRoot ζ p) :
hζ.integralPowerBasis'.dim = Ï p := by
rw [integralPowerBasis', integralPowerBasis_dim (hcycl := by rwa [pow_one]) (by rwa [pow_one]),
pow_one]
/-- The integral `PowerBasis` of `ð K` given by `ζ - 1`, where `K` is a `p ^ k` cyclotomic
extension of `â`. -/
noncomputable def subOneIntegralPowerBasis [IsCyclotomicExtension {p ^ k} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ k)) : PowerBasis †(ð K) :=
PowerBasis.ofGenMemAdjoin' hζ.integralPowerBasis (RingOfIntegers.isIntegral _)
(by
simp only [integralPowerBasis_gen, toInteger]
convert Subalgebra.add_mem _ (self_mem_adjoin_singleton †(âšÎ¶ - 1, _â© : ð K))
(Subalgebra.one_mem _)
· simp
· exact Subalgebra.sub_mem _ (hζ.isIntegral (by simp)) (Subalgebra.one_mem _))
@[simp]
theorem subOneIntegralPowerBasis_gen [IsCyclotomicExtension {p ^ k} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ k)) :
hζ.subOneIntegralPowerBasis.gen =
âšÎ¶ - 1, Subalgebra.sub_mem _ (hζ.isIntegral (p ^ k).pos) (Subalgebra.one_mem _)â© := by
simp [subOneIntegralPowerBasis]
/-- The integral `PowerBasis` of `ð K` given by `ζ - 1`, where `K` is a `p`-th cyclotomic
extension of `â`. -/
noncomputable def subOneIntegralPowerBasis' [IsCyclotomicExtension {p} â K]
(hζ : IsPrimitiveRoot ζ p) : PowerBasis †(ð K) :=
have : IsCyclotomicExtension {p ^ 1} â K := by rwa [pow_one]
subOneIntegralPowerBasis (p := p) (k := 1) (ζ := ζ) (by rwa [pow_one])
@[simp, nolint unusedHavesSuffices]
theorem subOneIntegralPowerBasis'_gen [IsCyclotomicExtension {p} â K]
(hζ : IsPrimitiveRoot ζ p) :
hζ.subOneIntegralPowerBasis'.gen = hζ.toInteger - 1 :=
-- The `unusedHavesSuffices` linter incorrectly thinks this `have` is unnecessary.
have : IsCyclotomicExtension {p ^ 1} â K := by rwa [pow_one]
subOneIntegralPowerBasis_gen (by rwa [pow_one])
/-- `ζ - 1` is prime if `p â 2` and `ζ` is a primitive `p ^ (k + 1)`-th root of unity.
See `zeta_sub_one_prime` for a general statement. -/
theorem zeta_sub_one_prime_of_ne_two [IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) (hodd : p â 2) :
Prime (hζ.toInteger - 1) := by
letI := IsCyclotomicExtension.numberField {p ^ (k + 1)} â K
refine Ideal.prime_of_irreducible_absNorm_span (fun h ⊠?_) ?_
· apply hζ.pow_ne_one_of_pos_of_lt zero_lt_one (one_lt_powâ hp.out.one_lt (by simp))
rw [sub_eq_zero] at h
simpa using congrArg (algebraMap _ K) h
rw [Nat.irreducible_iff_prime, Ideal.absNorm_span_singleton, â Nat.prime_iff,
â Int.prime_iff_natAbs_prime]
convert Nat.prime_iff_prime_int.1 hp.out
apply RingHom.injective_int (algebraMap †â)
rw [â Algebra.norm_localization (Sâ := K) †(nonZeroDivisors â€)]
simp only [PNat.pow_coe, id.map_eq_id, RingHomCompTriple.comp_eq, RingHom.coe_coe,
Subalgebra.coe_val, algebraMap_int_eq, map_natCast]
exact hζ.norm_sub_one_of_prime_ne_two (Polynomial.cyclotomic.irreducible_rat (PNat.pos _)) hodd
/-- `ζ - 1` is prime if `ζ` is a primitive `2 ^ (k + 1)`-th root of unity.
See `zeta_sub_one_prime` for a general statement. -/
theorem zeta_sub_one_prime_of_two_pow [IsCyclotomicExtension {(2 : â+) ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â((2 : â+) ^ (k + 1))) :
Prime (hζ.toInteger - 1) := by
letI := IsCyclotomicExtension.numberField {(2 : â+) ^ (k + 1)} â K
refine Ideal.prime_of_irreducible_absNorm_span (fun h ⊠?_) ?_
· apply hζ.pow_ne_one_of_pos_of_lt zero_lt_one (one_lt_powâ (by decide) (by simp))
rw [sub_eq_zero] at h
simpa using congrArg (algebraMap _ K) h
rw [Nat.irreducible_iff_prime, Ideal.absNorm_span_singleton, â Nat.prime_iff,
â Int.prime_iff_natAbs_prime]
cases k
· convert Prime.neg Int.prime_two
apply RingHom.injective_int (algebraMap †â)
rw [â Algebra.norm_localization (Sâ := K) †(nonZeroDivisors â€)]
simp only [PNat.pow_coe, id.map_eq_id, RingHomCompTriple.comp_eq, RingHom.coe_coe,
Subalgebra.coe_val, algebraMap_int_eq, map_neg, map_ofNat]
simpa only [zero_add, pow_one, AddSubgroupClass.coe_sub, OneMemClass.coe_one,
pow_zero]
using hζ.norm_pow_sub_one_two (cyclotomic.irreducible_rat
(by simp only [zero_add, pow_one, Nat.ofNat_pos]))
convert Int.prime_two
apply RingHom.injective_int (algebraMap †â)
rw [â Algebra.norm_localization (Sâ := K) †(nonZeroDivisors â€)]
simp only [PNat.pow_coe, id.map_eq_id, RingHomCompTriple.comp_eq, RingHom.coe_coe,
Subalgebra.coe_val, algebraMap_int_eq, map_natCast]
exact hζ.norm_sub_one_two Nat.AtLeastTwo.prop (cyclotomic.irreducible_rat (by simp))
/-- `ζ - 1` is prime if `ζ` is a primitive `p ^ (k + 1)`-th root of unity. -/
theorem zeta_sub_one_prime [IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) : Prime (hζ.toInteger - 1) := by
by_cases htwo : p = 2
· subst htwo
apply hζ.zeta_sub_one_prime_of_two_pow
· apply hζ.zeta_sub_one_prime_of_ne_two htwo
/-- `ζ - 1` is prime if `ζ` is a primitive `p`-th root of unity. -/
theorem zeta_sub_one_prime' [h : IsCyclotomicExtension {p} â K] (hζ : IsPrimitiveRoot ζ p) :
Prime ((hζ.toInteger - 1)) := by
convert zeta_sub_one_prime (k := 0) (by simpa only [zero_add, pow_one])
simpa only [zero_add, pow_one]
theorem subOneIntegralPowerBasis_gen_prime [IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) :
Prime hζ.subOneIntegralPowerBasis.gen := by
simpa only [subOneIntegralPowerBasis_gen] using hζ.zeta_sub_one_prime
theorem subOneIntegralPowerBasis'_gen_prime [IsCyclotomicExtension {p} â K]
(hζ : IsPrimitiveRoot ζ âp) :
Prime hζ.subOneIntegralPowerBasis'.gen := by
simpa only [subOneIntegralPowerBasis'_gen] using hζ.zeta_sub_one_prime'
/-- The norm, relative to `â€`, of `ζ ^ p ^ s - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `â`
is p ^ p ^ s` if `s †k` and `p ^ (k - s + 1) â 2`. -/
lemma norm_toInteger_pow_sub_one_of_prime_pow_ne_two [IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) {s : â} (hs : s †k) (htwo : p ^ (k - s + 1) â 2) :
Algebra.norm †(hζ.toInteger ^ (p : â) ^ s - 1) = p ^ (p : â) ^ s := by
have : NumberField K := IsCyclotomicExtension.numberField {p ^ (k + 1)} â K
rw [Algebra.norm_eq_iff †(Sâ := K) (Râ := â) rfl.le]
simp [hζ.norm_pow_sub_one_of_prime_pow_ne_two
(cyclotomic.irreducible_rat (by simp only [PNat.pow_coe, gt_iff_lt, PNat.pos, pow_pos]))
hs htwo]
/-- The norm, relative to `â€`, of `ζ ^ 2 ^ k - 1` in a `2 ^ (k + 1)`-th cyclotomic extension of `â`
is `(-2) ^ 2 ^ k`. -/
lemma norm_toInteger_pow_sub_one_of_two [IsCyclotomicExtension {2 ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â((2 : â+) ^ (k + 1))) :
Algebra.norm †(hζ.toInteger ^ 2 ^ k - 1) = (-2) ^ (2 : â) ^ k := by
have : NumberField K := IsCyclotomicExtension.numberField {2 ^ (k + 1)} â K
rw [Algebra.norm_eq_iff †(Sâ := K) (Râ := â) rfl.le]
simp [hζ.norm_pow_sub_one_two (cyclotomic.irreducible_rat (pow_pos (by decide) _))]
/-- The norm, relative to `â€`, of `ζ ^ p ^ s - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `â`
is `p ^ p ^ s` if `s †k` and `p â 2`. -/
lemma norm_toInteger_pow_sub_one_of_prime_ne_two [IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) {s : â} (hs : s †k) (hodd : p â 2) :
Algebra.norm †(hζ.toInteger ^ (p : â) ^ s - 1) = p ^ (p : â) ^ s := by
refine hζ.norm_toInteger_pow_sub_one_of_prime_pow_ne_two hs (fun h ⊠hodd ?_)
suffices h : (p : â) = 2 from PNat.coe_injective h
apply eq_of_prime_pow_eq hp.out.prime Nat.prime_two.prime (k - s).succ_pos
rw [pow_one]
exact congr_arg Subtype.val h
/-- The norm, relative to `â€`, of `ζ - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `â` is
`p` if `p â 2`. -/
lemma norm_toInteger_sub_one_of_prime_ne_two [IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) (hodd : p â 2) :
Algebra.norm †(hζ.toInteger - 1) = p := by
simpa only [pow_zero, pow_one] using
hζ.norm_toInteger_pow_sub_one_of_prime_ne_two (Nat.zero_le _) hodd
/-- The norm, relative to `â€`, of `ζ - 1` in a `p`-th cyclotomic extension of `â` is `p` if
`p â 2`. -/
lemma norm_toInteger_sub_one_of_prime_ne_two' [hcycl : IsCyclotomicExtension {p} â K]
(hζ : IsPrimitiveRoot ζ p) (h : p â 2) : Algebra.norm †(hζ.toInteger - 1) = p := by
have : IsCyclotomicExtension {p ^ (0 + 1)} â K := by simpa using hcycl
replace hζ : IsPrimitiveRoot ζ (p ^ (0 + 1)) := by simpa using hζ
exact hζ.norm_toInteger_sub_one_of_prime_ne_two h
/-- The norm, relative to `â€`, of `ζ - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `â` is
a prime if `p ^ (k + 1) â 2`. -/
lemma prime_norm_toInteger_sub_one_of_prime_pow_ne_two [IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) (htwo : p ^ (k + 1) â 2) :
Prime (Algebra.norm †(hζ.toInteger - 1)) := by
have := hζ.norm_toInteger_pow_sub_one_of_prime_pow_ne_two (zero_le _) htwo
simp only [pow_zero, pow_one] at this
rw [this]
exact Nat.prime_iff_prime_int.1 hp.out
/-- The norm, relative to `â€`, of `ζ - 1` in a `p ^ (k + 1)`-th cyclotomic extension of `â` is
a prime if `p â 2`. -/
lemma prime_norm_toInteger_sub_one_of_prime_ne_two [hcycl : IsCyclotomicExtension {p ^ (k + 1)} â K]
(hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) (hodd : p â 2) :
Prime (Algebra.norm †(hζ.toInteger - 1)) := by
have := hζ.norm_toInteger_sub_one_of_prime_ne_two hodd
simp only [pow_zero, pow_one] at this
rw [this]
exact Nat.prime_iff_prime_int.1 hp.out
/-- The norm, relative to `â€`, of `ζ - 1` in a `p`-th cyclotomic extension of `â` is a prime if
`p â 2`. -/
lemma prime_norm_toInteger_sub_one_of_prime_ne_two' [hcycl : IsCyclotomicExtension {p} â K]
(hζ : IsPrimitiveRoot ζ âp) (hodd : p â 2) :
Prime (Algebra.norm †(hζ.toInteger - 1)) := by
have : IsCyclotomicExtension {p ^ (0 + 1)} â K := by simpa using hcycl
replace hζ : IsPrimitiveRoot ζ (p ^ (0 + 1)) := by simpa using hζ
exact hζ.prime_norm_toInteger_sub_one_of_prime_ne_two hodd
/-- In a `p ^ (k + 1)`-th cyclotomic extension of `â `, we have that `ζ` is not congruent to an
integer modulo `p` if `p ^ (k + 1) â 2`. -/
theorem not_exists_int_prime_dvd_sub_of_prime_pow_ne_two
[hcycl : IsCyclotomicExtension {p ^ (k + 1)} â K]
| (hζ : IsPrimitiveRoot ζ â(p ^ (k + 1))) (htwo : p ^ (k + 1) â 2) :
¬(â n : â€, (p : ð K) ⣠(hζ.toInteger - n : ð K)) := by
intro âšn, x, hâ©
-- Let `pB` be the power basis of `ð K` given by powers of `ζ`.
let pB := hζ.integralPowerBasis
have hdim : pB.dim = âp ^ k * (âp - 1) := by
simp [integralPowerBasis_dim, pB, Nat.totient_prime_pow hp.1 (Nat.zero_lt_succ k)]
replace hdim : 1 < pB.dim := by
| Mathlib/NumberTheory/Cyclotomic/Rat.lean | 440 | 447 |
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes Hölzl, Sander Dahmen, Kim Morrison
-/
import Mathlib.Algebra.Algebra.Tower
import Mathlib.LinearAlgebra.LinearIndependent.Basic
import Mathlib.Data.Set.Card
/-!
# Dimension of modules and vector spaces
## Main definitions
* The rank of a module is defined as `Module.rank : Cardinal`.
This is defined as the supremum of the cardinalities of linearly independent subsets.
## Main statements
* `LinearMap.rank_le_of_injective`: the source of an injective linear map has dimension
at most that of the target.
* `LinearMap.rank_le_of_surjective`: the target of a surjective linear map has dimension
at most that of that source.
## Implementation notes
Many theorems in this file are not universe-generic when they relate dimensions
in different universes. They should be as general as they can be without
inserting `lift`s. The types `M`, `M'`, ... all live in different universes,
and `Mâ`, `Mâ`, ... all live in the same universe.
-/
noncomputable section
universe w w' u u' v v'
variable {R : Type u} {R' : Type u'} {M Mâ : Type v} {M' : Type v'}
open Cardinal Submodule Function Set
section Module
section
variable [Semiring R] [AddCommMonoid M] [Module R M]
variable (R M)
/-- The rank of a module, defined as a term of type `Cardinal`.
We define this as the supremum of the cardinalities of linearly independent subsets.
The supremum may not be attained, see https://mathoverflow.net/a/263053.
For a free module over any ring satisfying the strong rank condition
(e.g. left-noetherian rings, commutative rings, and in particular division rings and fields),
this is the same as the dimension of the space (i.e. the cardinality of any basis).
In particular this agrees with the usual notion of the dimension of a vector space.
See also `Module.finrank` for a `â`-valued function which returns the correct value
for a finite-dimensional vector space (but 0 for an infinite-dimensional vector space).
-/
@[stacks 09G3 "first part"]
protected irreducible_def Module.rank : Cardinal :=
⚠ι : { s : Set M // LinearIndepOn R id s }, (#ι.1)
theorem rank_le_card : Module.rank R M †#M :=
(Module.rank_def _ _).trans_le (ciSup_le' fun _ ⊠mk_set_le _)
lemma nonempty_linearIndependent_set : Nonempty {s : Set M // LinearIndepOn R id s } :=
âšâšâ
, linearIndepOn_empty _ _â©â©
end
namespace LinearIndependent
variable [Semiring R] [AddCommMonoid M] [Module R M]
variable [Nontrivial R]
theorem cardinal_lift_le_rank {ι : Type w} {v : ι â M}
(hv : LinearIndependent R v) :
Cardinal.lift.{v} #ι †Cardinal.lift.{w} (Module.rank R M) := by
rw [Module.rank]
refine le_trans ?_ (lift_le.mpr <| le_ciSup (bddAbove_range _) âš_, hv.linearIndepOn_idâ©)
exact lift_mk_le'.mpr âš(Equiv.ofInjective _ hv.injective).toEmbeddingâ©
lemma aleph0_le_rank {ι : Type w} [Infinite ι] {v : ι â M}
(hv : LinearIndependent R v) : âµâ †Module.rank R M :=
aleph0_le_lift.mp <| (aleph0_le_lift.mpr <| aleph0_le_mk ι).trans hv.cardinal_lift_le_rank
theorem cardinal_le_rank {ι : Type v} {v : ι â M}
(hv : LinearIndependent R v) : #ι †Module.rank R M := by
simpa using hv.cardinal_lift_le_rank
theorem cardinal_le_rank' {s : Set M}
(hs : LinearIndependent R (fun x => x : s â M)) : #s †Module.rank R M :=
hs.cardinal_le_rank
theorem _root_.LinearIndepOn.encard_le_toENat_rank {ι : Type*} {v : ι â M} {s : Set ι}
(hs : LinearIndepOn R v s) : s.encard †(Module.rank R M).toENat := by
simpa using OrderHom.mono (β := ââ) Cardinal.toENat hs.linearIndependent.cardinal_lift_le_rank
end LinearIndependent
section SurjectiveInjective
section Semiring
variable [Semiring R] [AddCommMonoid M] [Module R M] [Semiring R']
section
variable [AddCommMonoid M'] [Module R' M']
/-- If `M / R` and `M' / R'` are modules, `i : R' â R` is an injective map
non-zero elements, `j : M â+ M'` is an injective monoid homomorphism, such that the scalar
multiplications on `M` and `M'` are compatible, then the rank of `M / R` is smaller than or equal to
the rank of `M' / R'`. As a special case, taking `R = R'` it is
`LinearMap.lift_rank_le_of_injective`. -/
theorem lift_rank_le_of_injective_injectiveâ (i : R' â R) (j : M â+ M')
(hi : Injective i) (hj : Injective j)
(hc : â (r : R') (m : M), j (i r ⢠m) = r ⢠j m) :
lift.{v'} (Module.rank R M) †lift.{v} (Module.rank R' M') := by
simp_rw [Module.rank, lift_iSup (bddAbove_range _)]
exact ciSup_mono' (bddAbove_range _) fun âšs, h⩠⊠âšâšj '' s,
LinearIndepOn.id_image (h.linearIndependent.map_of_injective_injectiveâ i j hi hj hc)â©,
lift_mk_le'.mpr âš(Equiv.Set.image j s hj).toEmbeddingâ©â©
/-- If `M / R` and `M' / R'` are modules, `i : R â R'` is a surjective map, and
`j : M â+ M'` is an injective monoid homomorphism, such that the scalar multiplications on `M` and
`M'` are compatible, then the rank of `M / R` is smaller than or equal to the rank of `M' / R'`.
As a special case, taking `R = R'` it is `LinearMap.lift_rank_le_of_injective`. -/
theorem lift_rank_le_of_surjective_injective (i : R â R') (j : M â+ M')
(hi : Surjective i) (hj : Injective j) (hc : â (r : R) (m : M), j (r ⢠m) = i r ⢠j m) :
lift.{v'} (Module.rank R M) †lift.{v} (Module.rank R' M') := by
obtain âši', hi'â© := hi.hasRightInverse
refine lift_rank_le_of_injective_injectiveâ i' j (fun _ _ h ⊠?_) hj fun r m ⊠?_
· apply_fun i at h
rwa [hi', hi'] at h
rw [hc (i' r) m, hi']
/-- If `M / R` and `M' / R'` are modules, `i : R â R'` is a bijective map which maps zero to zero,
`j : M â+ M'` is a group isomorphism, such that the scalar multiplications on `M` and `M'` are
compatible, then the rank of `M / R` is equal to the rank of `M' / R'`.
As a special case, taking `R = R'` it is `LinearEquiv.lift_rank_eq`. -/
theorem lift_rank_eq_of_equiv_equiv (i : R â R') (j : M â+ M')
(hi : Bijective i) (hc : â (r : R) (m : M), j (r ⢠m) = i r ⢠j m) :
lift.{v'} (Module.rank R M) = lift.{v} (Module.rank R' M') :=
(lift_rank_le_of_surjective_injective i j hi.2 j.injective hc).antisymm <|
lift_rank_le_of_injective_injectiveâ i j.symm hi.1
j.symm.injective fun _ _ ⊠j.symm_apply_eq.2 <| by erw [hc, j.apply_symm_apply]
end
section
variable [AddCommMonoid Mâ] [Module R' Mâ]
/-- The same-universe version of `lift_rank_le_of_injective_injective`. -/
theorem rank_le_of_injective_injectiveâ (i : R' â R) (j : M â+ Mâ)
(hi : Injective i) (hj : Injective j)
(hc : â (r : R') (m : M), j (i r ⢠m) = r ⢠j m) :
Module.rank R M †Module.rank R' Mâ := by
simpa only [lift_id] using lift_rank_le_of_injective_injectiveâ i j hi hj hc
/-- The same-universe version of `lift_rank_le_of_surjective_injective`. -/
theorem rank_le_of_surjective_injective (i : R â R') (j : M â+ Mâ)
(hi : Surjective i) (hj : Injective j)
(hc : â (r : R) (m : M), j (r ⢠m) = i r ⢠j m) :
Module.rank R M †Module.rank R' Mâ := by
simpa only [lift_id] using lift_rank_le_of_surjective_injective i j hi hj hc
/-- The same-universe version of `lift_rank_eq_of_equiv_equiv`. -/
theorem rank_eq_of_equiv_equiv (i : R â R') (j : M â+ Mâ)
(hi : Bijective i) (hc : â (r : R) (m : M), j (r ⢠m) = i r ⢠j m) :
Module.rank R M = Module.rank R' Mâ := by
simpa only [lift_id] using lift_rank_eq_of_equiv_equiv i j hi hc
end
end Semiring
section Ring
variable [Ring R] [AddCommGroup M] [Module R M] [Ring R']
/-- If `M / R` and `M' / R'` are modules, `i : R' â R` is a map which sends non-zero elements to
non-zero elements, `j : M â+ M'` is an injective group homomorphism, such that the scalar
multiplications on `M` and `M'` are compatible, then the rank of `M / R` is smaller than or equal to
the rank of `M' / R'`. As a special case, taking `R = R'` it is
`LinearMap.lift_rank_le_of_injective`. -/
theorem lift_rank_le_of_injective_injective [AddCommGroup M'] [Module R' M']
(i : R' â R) (j : M â+ M') (hi : â r, i r = 0 â r = 0) (hj : Injective j)
(hc : â (r : R') (m : M), j (i r ⢠m) = r ⢠j m) :
lift.{v'} (Module.rank R M) †lift.{v} (Module.rank R' M') := by
simp_rw [Module.rank, lift_iSup (bddAbove_range _)]
exact ciSup_mono' (bddAbove_range _) fun âšs, hâ© âŠ
âšâšj '' s, LinearIndepOn.id_image <| h.linearIndependent.map_of_injective_injective i j hi
(fun _ _ ⊠hj <| by rwa [j.map_zero]) hcâ©,
lift_mk_le'.mpr âš(Equiv.Set.image j s hj).toEmbeddingâ©â©
/-- The same-universe version of `lift_rank_le_of_injective_injective`. -/
theorem rank_le_of_injective_injective [AddCommGroup Mâ] [Module R' Mâ]
(i : R' â R) (j : M â+ Mâ) (hi : â r, i r = 0 â r = 0) (hj : Injective j)
(hc : â (r : R') (m : M), j (i r ⢠m) = r ⢠j m) :
Module.rank R M †Module.rank R' Mâ := by
simpa only [lift_id] using lift_rank_le_of_injective_injective i j hi hj hc
end Ring
namespace Algebra
variable {R : Type w} {S : Type v} [CommSemiring R] [Semiring S] [Algebra R S]
{R' : Type w'} {S' : Type v'} [CommSemiring R'] [Semiring S'] [Algebra R' S']
/-- If `S / R` and `S' / R'` are algebras, `i : R' â+* R` and `j : S â+* S'` are injective ring
homomorphisms, such that `R' â R â S â S'` and `R' â S'` commute, then the rank of `S / R` is
smaller than or equal to the rank of `S' / R'`. -/
theorem lift_rank_le_of_injective_injective
(i : R' â+* R) (j : S â+* S') (hi : Injective i) (hj : Injective j)
(hc : (j.comp (algebraMap R S)).comp i = algebraMap R' S') :
lift.{v'} (Module.rank R S) †lift.{v} (Module.rank R' S') := by
refine _root_.lift_rank_le_of_injective_injectiveâ i j hi hj fun r _ ⊠?_
have := congr($hc r)
simp only [RingHom.coe_comp, comp_apply] at this
simp_rw [smul_def, AddMonoidHom.coe_coe, map_mul, this]
/-- If `S / R` and `S' / R'` are algebras, `i : R â+* R'` is a surjective ring homomorphism,
`j : S â+* S'` is an injective ring homomorphism, such that `R â R' â S'` and `R â S â S'` commute,
then the rank of `S / R` is smaller than or equal to the rank of `S' / R'`. -/
theorem lift_rank_le_of_surjective_injective
(i : R â+* R') (j : S â+* S') (hi : Surjective i) (hj : Injective j)
(hc : (algebraMap R' S').comp i = j.comp (algebraMap R S)) :
lift.{v'} (Module.rank R S) †lift.{v} (Module.rank R' S') := by
refine _root_.lift_rank_le_of_surjective_injective i j hi hj fun r _ ⊠?_
have := congr($hc r)
simp only [RingHom.coe_comp, comp_apply] at this
simp only [smul_def, AddMonoidHom.coe_coe, map_mul, ZeroHom.coe_coe, this]
/-- If `S / R` and `S' / R'` are algebras, `i : R â+* R'` and `j : S â+* S'` are
| ring isomorphisms, such that `R â R' â S'` and `R â S â S'` commute,
then the rank of `S / R` is equal to the rank of `S' / R'`. -/
theorem lift_rank_eq_of_equiv_equiv (i : R â+* R') (j : S â+* S')
(hc : (algebraMap R' S').comp i.toRingHom = j.toRingHom.comp (algebraMap R S)) :
| Mathlib/LinearAlgebra/Dimension/Basic.lean | 235 | 238 |
/-
Copyright (c) 2022 Chris Birkbeck. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Birkbeck, David Loeffler
-/
import Mathlib.Algebra.Module.Submodule.Basic
import Mathlib.Analysis.Complex.UpperHalfPlane.Topology
import Mathlib.Order.Filter.ZeroAndBoundedAtFilter
/-!
# Bounded at infinity
For complex valued functions on the upper half plane, this file defines the filter
`UpperHalfPlane.atImInfty` required for defining when functions are bounded at infinity and zero at
infinity. Both of which are relevant for defining modular forms.
-/
open Complex Filter
open scoped Topology UpperHalfPlane
noncomputable section
namespace UpperHalfPlane
/-- Filter for approaching `iâ`. -/
def atImInfty :=
Filter.atTop.comap UpperHalfPlane.im
theorem atImInfty_basis : atImInfty.HasBasis (fun _ => True) fun i : â => im â»Â¹' Set.Ici i :=
Filter.HasBasis.comap UpperHalfPlane.im Filter.atTop_basis
theorem atImInfty_mem (S : Set â) : S â atImInfty â â A : â, â z : â, A †im z â z â S := by
simp only [atImInfty_basis.mem_iff, true_and]; rfl
/-- A function `f : â â α` is bounded at infinity if it is bounded along `atImInfty`. -/
def IsBoundedAtImInfty {α : Type*} [Norm α] (f : â â α) : Prop :=
BoundedAtFilter atImInfty f
/-- A function `f : â â α` is zero at infinity it is zero along `atImInfty`. -/
def IsZeroAtImInfty {α : Type*} [Zero α] [TopologicalSpace α] (f : â â α) : Prop :=
ZeroAtFilter atImInfty f
theorem zero_form_isBoundedAtImInfty {α : Type*} [NormedField α] :
IsBoundedAtImInfty (0 : â â α) :=
const_boundedAtFilter atImInfty (0 : α)
/-- Module of functions that are zero at infinity. -/
def zeroAtImInftySubmodule (α : Type*) [NormedField α] : Submodule α (â â α) :=
zeroAtFilterSubmodule _ atImInfty
/-- Subalgebra of functions that are bounded at infinity. -/
def boundedAtImInftySubalgebra (α : Type*) [NormedField α] : Subalgebra α (â â α) :=
boundedFilterSubalgebra _ atImInfty
theorem isBoundedAtImInfty_iff {α : Type*} [Norm α] {f : â â α} :
IsBoundedAtImInfty f â â M A : â, â z : â, A †im z â âf zâ †M := by
simp [IsBoundedAtImInfty, BoundedAtFilter, Asymptotics.isBigO_iff, Filter.Eventually,
atImInfty_mem]
theorem isZeroAtImInfty_iff {α : Type*} [SeminormedAddGroup α] {f : â â α} :
IsZeroAtImInfty f â â ε : â, 0 < ε â â A : â, â z : â, A †im z â âf zâ †ε :=
(atImInfty_basis.tendsto_iff Metric.nhds_basis_closedBall).trans <| by simp
theorem IsZeroAtImInfty.isBoundedAtImInfty {α : Type*} [SeminormedAddGroup α] {f : â â α}
(hf : IsZeroAtImInfty f) : IsBoundedAtImInfty f :=
hf.boundedAtFilter
lemma tendsto_comap_im_ofComplex :
Tendsto ofComplex (comap Complex.im atTop) atImInfty := by
| simp only [atImInfty, tendsto_comap_iff, Function.comp_def]
refine tendsto_comap.congr' ?_
filter_upwards [preimage_mem_comap (Ioi_mem_atTop 0)] with z hz
simp only [ofComplex_apply_of_im_pos hz, â UpperHalfPlane.coe_im, coe_mk_subtype]
| Mathlib/Analysis/Complex/UpperHalfPlane/FunctionsBoundedAtInfty.lean | 71 | 74 |
/-
Copyright (c) 2022 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez, Eric Wieser
-/
import Mathlib.Data.List.Chain
/-!
# Destuttering of Lists
This file proves theorems about `List.destutter` (in `Data.List.Defs`), which greedily removes all
non-related items that are adjacent in a list, e.g. `[2, 2, 3, 3, 2].destutter (â ) = [2, 3, 2]`.
Note that we make no guarantees of being the longest sublist with this property; e.g.,
`[123, 1, 2, 5, 543, 1000].destutter (<) = [123, 543, 1000]`, but a longer ascending chain could be
`[1, 2, 5, 543, 1000]`.
## Main statements
* `List.destutter_sublist`: `l.destutter` is a sublist of `l`.
* `List.destutter_is_chain'`: `l.destutter` satisfies `Chain' R`.
* Analogies of these theorems for `List.destutter'`, which is the `destutter` equivalent of `Chain`.
## Tags
adjacent, chain, duplicates, remove, list, stutter, destutter
-/
open Function
variable {α β : Type*} (l lâ lâ : List α) (R : α â α â Prop) [DecidableRel R] {a b : α}
variable {Râ : β â β â Prop} [DecidableRel Râ]
namespace List
@[simp]
theorem destutter'_nil : destutter' R a [] = [a] :=
rfl
theorem destutter'_cons :
(b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l :=
rfl
variable {R}
@[simp]
theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by
rw [destutter', if_pos h]
@[simp]
theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by
rw [destutter', if_neg h]
variable (R)
@[simp]
theorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by
split_ifs with h <;> simp! [h]
theorem destutter'_sublist (a) : l.destutter' R a <+ a :: l := by
induction' l with b l hl generalizing a
· simp
rw [destutter']
split_ifs
· exact Sublist.consâ a (hl b)
· exact (hl a).trans ((l.sublist_cons_self b).cons_cons a)
theorem mem_destutter' (a) : a â l.destutter' R a := by
induction' l with b l hl
· simp
rw [destutter']
split_ifs
· simp
· assumption
theorem destutter'_is_chain : â l : List α, â {a b}, R a b â (l.destutter' R b).Chain R a
| [], _, _, h => chain_singleton.mpr h
| c :: l, a, b, h => by
rw [destutter']
split_ifs with hbc
· rw [chain_cons]
exact âšh, destutter'_is_chain l hbcâ©
· exact destutter'_is_chain l h
theorem destutter'_is_chain' (a) : (l.destutter' R a).Chain' R := by
induction' l with b l hl generalizing a
· simp
rw [destutter']
split_ifs with h
· exact destutter'_is_chain R l h
· exact hl a
theorem destutter'_of_chain (h : l.Chain R a) : l.destutter' R a = a :: l := by
induction' l with b l hb generalizing a
· simp
obtain âšh, hcâ© := chain_cons.mp h
rw [l.destutter'_cons_pos h, hb hc]
@[simp]
theorem destutter'_eq_self_iff (a) : l.destutter' R a = a :: l â l.Chain R a :=
| âšfun h => by
suffices Chain' R (a::l) by
assumption
rw [â h]
exact l.destutter'_is_chain' R a, destutter'_of_chain _ _â©
| Mathlib/Data/List/Destutter.lean | 101 | 105 |
/-
Copyright (c) 2018 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Patrick Massot, Yury Kudryashov
-/
import Mathlib.Topology.Defs.Sequences
import Mathlib.Topology.UniformSpace.Cauchy
/-!
# Sequences in topological spaces
In this file we prove theorems about relations
between closure/compactness/continuity etc and their sequential counterparts.
## Main definitions
The following notions are defined in `Topology/Defs/Sequences`.
We build theory about these definitions here, so we remind the definitions.
### Set operation
* `seqClosure s`: sequential closure of a set, the set of limits of sequences of points of `s`;
### Predicates
* `IsSeqClosed s`: predicate saying that a set is sequentially closed, i.e., `seqClosure s â s`;
* `SeqContinuous f`: predicate saying that a function is sequentially continuous, i.e.,
for any sequence `u : â â X` that converges to a point `x`, the sequence `f â u` converges to
`f x`;
* `IsSeqCompact s`: predicate saying that a set is sequentially compact, i.e., every sequence
taking values in `s` has a converging subsequence.
### Type classes
* `FrechetUrysohnSpace X`: a typeclass saying that a topological space is a *Fréchet-Urysohn
space*, i.e., the sequential closure of any set is equal to its closure.
* `SequentialSpace X`: a typeclass saying that a topological space is a *sequential space*, i.e.,
any sequentially closed set in this space is closed. This condition is weaker than being a
Fréchet-Urysohn space.
* `SeqCompactSpace X`: a typeclass saying that a topological space is sequentially compact, i.e.,
every sequence in `X` has a converging subsequence.
## Main results
* `seqClosure_subset_closure`: closure of a set includes its sequential closure;
* `IsClosed.isSeqClosed`: a closed set is sequentially closed;
* `IsSeqClosed.seqClosure_eq`: sequential closure of a sequentially closed set `s` is equal
to `s`;
* `seqClosure_eq_closure`: in a Fréchet-Urysohn space, the sequential closure of a set is equal to
its closure;
* `tendsto_nhds_iff_seq_tendsto`, `FrechetUrysohnSpace.of_seq_tendsto_imp_tendsto`: a topological
space is a Fréchet-Urysohn space if and only if sequential convergence implies convergence;
* `FirstCountableTopology.frechetUrysohnSpace`: every topological space with
first countable topology is a Fréchet-Urysohn space;
* `FrechetUrysohnSpace.to_sequentialSpace`: every Fréchet-Urysohn space is a sequential space;
* `IsSeqCompact.isCompact`: a sequentially compact set in a uniform space with countably
generated uniformity is compact.
## Tags
sequentially closed, sequentially compact, sequential space
-/
open Bornology Filter Function Set TopologicalSpace Topology
open scoped Uniformity
variable {X Y : Type*}
/-! ### Sequential closures, sequential continuity, and sequential spaces. -/
section TopologicalSpace
variable [TopologicalSpace X] [TopologicalSpace Y]
theorem subset_seqClosure {s : Set X} : s â seqClosure s := fun p hp =>
âšconst â p, fun _ => hp, tendsto_const_nhdsâ©
/-- The sequential closure of a set is contained in the closure of that set.
The converse is not true. -/
theorem seqClosure_subset_closure {s : Set X} : seqClosure s â closure s := fun _p âš_x, xM, xpâ© =>
mem_closure_of_tendsto xp (univ_mem' xM)
/-- The sequential closure of a sequentially closed set is the set itself. -/
theorem IsSeqClosed.seqClosure_eq {s : Set X} (hs : IsSeqClosed s) : seqClosure s = s :=
Subset.antisymm (fun _p âš_x, hx, hpâ© => hs hx hp) subset_seqClosure
/-- If a set is equal to its sequential closure, then it is sequentially closed. -/
theorem isSeqClosed_of_seqClosure_eq {s : Set X} (hs : seqClosure s = s) : IsSeqClosed s :=
fun x _p hxs hxp => hs âž âšx, hxs, hxpâ©
/-- A set is sequentially closed iff it is equal to its sequential closure. -/
theorem isSeqClosed_iff {s : Set X} : IsSeqClosed s â seqClosure s = s :=
âšIsSeqClosed.seqClosure_eq, isSeqClosed_of_seqClosure_eqâ©
/-- A set is sequentially closed if it is closed. -/
protected theorem IsClosed.isSeqClosed {s : Set X} (hc : IsClosed s) : IsSeqClosed s :=
fun _u _x hu hx => hc.mem_of_tendsto hx (Eventually.of_forall hu)
theorem seqClosure_eq_closure [FrechetUrysohnSpace X] (s : Set X) : seqClosure s = closure s :=
seqClosure_subset_closure.antisymm <| FrechetUrysohnSpace.closure_subset_seqClosure s
/-- In a Fréchet-Urysohn space, a point belongs to the closure of a set iff it is a limit
of a sequence taking values in this set. -/
theorem mem_closure_iff_seq_limit [FrechetUrysohnSpace X] {s : Set X} {a : X} :
a â closure s â â x : â â X, (â n : â, x n â s) â§ Tendsto x atTop (ð a) := by
rw [â seqClosure_eq_closure]
rfl
/-- If the domain of a function `f : α â β` is a Fréchet-Urysohn space, then convergence
is equivalent to sequential convergence. See also `Filter.tendsto_iff_seq_tendsto` for a version
that works for any pair of filters assuming that the filter in the domain is countably generated.
This property is equivalent to the definition of `FrechetUrysohnSpace`, see
`FrechetUrysohnSpace.of_seq_tendsto_imp_tendsto`. -/
theorem tendsto_nhds_iff_seq_tendsto [FrechetUrysohnSpace X] {f : X â Y} {a : X} {b : Y} :
Tendsto f (ð a) (ð b) â â u : â â X, Tendsto u atTop (ð a) â Tendsto (f â u) atTop (ð b) := by
refine
âšfun hf u hu => hf.comp hu, fun h =>
((nhds_basis_closeds _).tendsto_iff (nhds_basis_closeds _)).2 ?_â©
rintro s âšhbs, hscâ©
refine âšclosure (f â»Â¹' s), âšmt ?_ hbs, isClosed_closureâ©, fun x => mt fun hx => subset_closure hxâ©
rw [â seqClosure_eq_closure]
rintro âšu, hus, huâ©
exact hsc.mem_of_tendsto (h u hu) (Eventually.of_forall hus)
/-- An alternative construction for `FrechetUrysohnSpace`: if sequential convergence implies
convergence, then the space is a Fréchet-Urysohn space. -/
theorem FrechetUrysohnSpace.of_seq_tendsto_imp_tendsto
(h : â (f : X â Prop) (a : X),
(â u : â â X, Tendsto u atTop (ð a) â Tendsto (f â u) atTop (ð (f a))) â ContinuousAt f a) :
FrechetUrysohnSpace X := by
refine âšfun s x hcx => ?_â©
by_cases hx : x â s
· exact subset_seqClosure hx
· obtain âšu, hux, husâ© : â u : â â X, Tendsto u atTop (ð x) â§ âá¶ x in atTop, u x â s := by
simpa only [ContinuousAt, hx, tendsto_nhds_true, (· â ·), â not_frequently, exists_prop,
â mem_closure_iff_frequently, hcx, imp_false, not_forall, not_not, not_false_eq_true,
not_true_eq_false] using h (· â s) x
| rcases extraction_of_frequently_atTop hus with âšÏ, Ï_mono, hÏâ©
exact âšu â Ï, hÏ, hux.comp Ï_mono.tendsto_atTopâ©
-- see Note [lower instance priority]
/-- Every first-countable space is a Fréchet-Urysohn space. -/
instance (priority := 100) FirstCountableTopology.frechetUrysohnSpace
[FirstCountableTopology X] : FrechetUrysohnSpace X :=
FrechetUrysohnSpace.of_seq_tendsto_imp_tendsto fun _ _ => tendsto_iff_seq_tendsto.2
-- see Note [lower instance priority]
/-- Every Fréchet-Urysohn space is a sequential space. -/
instance (priority := 100) FrechetUrysohnSpace.to_sequentialSpace [FrechetUrysohnSpace X] :
SequentialSpace X :=
| Mathlib/Topology/Sequences.lean | 139 | 151 |
/-
Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Bhavik Mehta
-/
import Mathlib.Algebra.Order.Group.Unbundled.Int
import Mathlib.Algebra.Order.Nonneg.Basic
import Mathlib.Algebra.Order.Ring.Unbundled.Rat
import Mathlib.Algebra.Ring.Rat
import Mathlib.Data.Set.Operations
import Mathlib.Order.Bounds.Defs
import Mathlib.Order.GaloisConnection.Defs
/-!
# Nonnegative rationals
This file defines the nonnegative rationals as a subtype of `Rat` and provides its basic algebraic
order structure.
Note that `NNRat` is not declared as a `Semifield` here. See `Mathlib.Algebra.Field.Rat` for that
instance.
We also define an instance `CanLift â ââ¥0`. This instance can be used by the `lift` tactic to
replace `x : â` and `hx : 0 †x` in the proof context with `x : ââ¥0` while replacing all occurrences
of `x` with `âx`. This tactic also works for a function `f : α â â` with a hypothesis
`hf : â x, 0 †f x`.
## Notation
`ââ¥0` is notation for `NNRat` in locale `NNRat`.
## Huge warning
Whenever you state a lemma about the coercion `ââ¥0 â â`, check that Lean inserts `NNRat.cast`, not
`Subtype.val`. Else your lemma will never apply.
-/
assert_not_exists CompleteLattice OrderedCommMonoid
library_note "specialised high priority simp lemma" /--
It sometimes happens that a `@[simp]` lemma declared early in the library can be proved by `simp`
using later, more general simp lemmas. In that case, the following reasons might be arguments for
the early lemma to be tagged `@[simp high]` (rather than `@[simp, nolint simpNF]` or
un``@[simp]``ed):
1. There is a significant portion of the library which needs the early lemma to be available via
`simp` and which doesn't have access to the more general lemmas.
2. The more general lemmas have more complicated typeclass assumptions, causing rewrites with them
to be slower.
-/
open Function
instance Rat.instZeroLEOneClass : ZeroLEOneClass â where
zero_le_one := rfl
instance Rat.instPosMulMono : PosMulMono â where
elim := fun r p q h => by
simp only [mul_comm]
simpa [sub_mul, sub_nonneg] using Rat.mul_nonneg (sub_nonneg.2 h) r.2
deriving instance CommSemiring for NNRat
deriving instance LinearOrder for NNRat
deriving instance Sub for NNRat
deriving instance Inhabited for NNRat
namespace NNRat
variable {p q : ââ¥0}
instance instNontrivial : Nontrivial ââ¥0 where exists_pair_ne := âš1, 0, by decideâ©
instance instOrderBot : OrderBot ââ¥0 where
bot := 0
bot_le q := q.2
@[simp] lemma val_eq_cast (q : ââ¥0) : q.1 = q := rfl
instance instCharZero : CharZero ââ¥0 where
cast_injective a b hab := by simpa using congr_arg num hab
instance canLift : CanLift â ââ¥0 (â) fun q ⊠0 †q where
prf q hq := âšâšq, hqâ©, rflâ©
@[ext]
theorem ext : (p : â) = (q : â) â p = q :=
Subtype.ext
protected theorem coe_injective : Injective ((â) : ââ¥0 â â) :=
Subtype.coe_injective
-- See note [specialised high priority simp lemma]
@[simp high, norm_cast]
theorem coe_inj : (p : â) = q â p = q :=
Subtype.coe_inj
theorem ne_iff {x y : ââ¥0} : (x : â) â (y : â) â x â y :=
NNRat.coe_inj.not
-- TODO: We have to write `NNRat.cast` explicitly, else the statement picks up `Subtype.val` instead
@[simp, norm_cast] lemma coe_mk (q : â) (hq) : NNRat.cast âšq, hqâ© = q := rfl
lemma «forall» {p : ââ¥0 â Prop} : (â q, p q) â â q hq, p âšq, hqâ© := Subtype.forall
lemma «exists» {p : ââ¥0 â Prop} : (â q, p q) â â q hq, p âšq, hqâ© := Subtype.exists
/-- Reinterpret a rational number `q` as a non-negative rational number. Returns `0` if `q †0`. -/
def _root_.Rat.toNNRat (q : â) : ââ¥0 :=
âšmax q 0, le_max_right _ _â©
theorem _root_.Rat.coe_toNNRat (q : â) (hq : 0 †q) : (q.toNNRat : â) = q :=
max_eq_left hq
theorem _root_.Rat.le_coe_toNNRat (q : â) : q †q.toNNRat :=
le_max_left _ _
open Rat (toNNRat)
@[simp]
theorem coe_nonneg (q : ââ¥0) : (0 : â) †q :=
q.2
@[simp, norm_cast] lemma coe_zero : ((0 : ââ¥0) : â) = 0 := rfl
@[simp] lemma num_zero : num 0 = 0 := rfl
@[simp] lemma den_zero : den 0 = 1 := rfl
@[simp, norm_cast] lemma coe_one : ((1 : ââ¥0) : â) = 1 := rfl
@[simp] lemma num_one : num 1 = 1 := rfl
@[simp] lemma den_one : den 1 = 1 := rfl
@[simp, norm_cast]
theorem coe_add (p q : ââ¥0) : ((p + q : ââ¥0) : â) = p + q :=
rfl
@[simp, norm_cast]
theorem coe_mul (p q : ââ¥0) : ((p * q : ââ¥0) : â) = p * q :=
rfl
@[simp, norm_cast] lemma coe_pow (q : ââ¥0) (n : â) : (â(q ^ n) : â) = (q : â) ^ n :=
rfl
@[simp] lemma num_pow (q : ââ¥0) (n : â) : (q ^ n).num = q.num ^ n := by simp [num, Int.natAbs_pow]
@[simp] lemma den_pow (q : ââ¥0) (n : â) : (q ^ n).den = q.den ^ n := rfl
@[simp, norm_cast]
theorem coe_sub (h : q †p) : ((p - q : ââ¥0) : â) = p - q :=
max_eq_left <| le_sub_comm.2 <| by rwa [sub_zero]
-- See note [specialised high priority simp lemma]
@[simp high]
theorem coe_eq_zero : (q : â) = 0 â q = 0 := by norm_cast
theorem coe_ne_zero : (q : â) â 0 â q â 0 :=
coe_eq_zero.not
@[norm_cast]
theorem coe_le_coe : (p : â) †q â p †q :=
Iff.rfl
@[norm_cast]
theorem coe_lt_coe : (p : â) < q â p < q :=
Iff.rfl
@[norm_cast]
theorem coe_pos : (0 : â) < q â 0 < q :=
Iff.rfl
theorem coe_mono : Monotone ((â) : ââ¥0 â â) :=
fun _ _ ⊠coe_le_coe.2
theorem toNNRat_mono : Monotone toNNRat :=
fun _ _ h ⊠max_le_max h le_rfl
@[simp]
theorem toNNRat_coe (q : ââ¥0) : toNNRat q = q :=
ext <| max_eq_left q.2
@[simp]
theorem toNNRat_coe_nat (n : â) : toNNRat n = n :=
ext <| by simp only [Nat.cast_nonneg', Rat.coe_toNNRat]; rfl
/-- `toNNRat` and `(â) : ââ¥0 â â` form a Galois insertion. -/
protected def gi : GaloisInsertion toNNRat (â) :=
GaloisInsertion.monotoneIntro coe_mono toNNRat_mono Rat.le_coe_toNNRat toNNRat_coe
/-- Coercion `ââ¥0 â â` as a `RingHom`. -/
def coeHom : ââ¥0 â+* â where
toFun := (â)
map_one' := coe_one
map_mul' := coe_mul
map_zero' := coe_zero
map_add' := coe_add
@[simp, norm_cast] lemma coe_natCast (n : â) : (â(ân : ââ¥0) : â) = n := rfl
@[simp]
theorem mk_natCast (n : â) : @Eq ââ¥0 (âš(n : â), Nat.cast_nonneg' nâ© : ââ¥0) n :=
rfl
@[simp]
theorem coe_coeHom : âcoeHom = ((â) : ââ¥0 â â) :=
rfl
@[norm_cast]
theorem nsmul_coe (q : ââ¥0) (n : â) : â(n ⢠q) = n ⢠(q : â) :=
coeHom.toAddMonoidHom.map_nsmul _ _
theorem bddAbove_coe {s : Set ââ¥0} : BddAbove ((â) '' s : Set â) â BddAbove s :=
âšfun âšb, hbâ© âŠ
âštoNNRat b, fun âšy, _â© hys âŠ
show y †max b 0 from (hb <| Set.mem_image_of_mem _ hys).trans <| le_max_left _ _â©,
fun âšb, hb⩠⊠âšb, fun _ âš_, hx, Eq⩠⊠Eq âž hb hxâ©â©
theorem bddBelow_coe (s : Set ââ¥0) : BddBelow (((â) : ââ¥0 â â) '' s) :=
âš0, fun _ âšq, _, h⩠⊠h âž q.2â©
@[norm_cast]
theorem coe_max (x y : ââ¥0) : ((max x y : ââ¥0) : â) = max (x : â) (y : â) :=
coe_mono.map_max
@[norm_cast]
theorem coe_min (x y : ââ¥0) : ((min x y : ââ¥0) : â) = min (x : â) (y : â) :=
coe_mono.map_min
theorem sub_def (p q : ââ¥0) : p - q = toNNRat (p - q) :=
rfl
@[simp]
theorem abs_coe (q : ââ¥0) : |(q : â)| = q :=
abs_of_nonneg q.2
-- See note [specialised high priority simp lemma]
@[simp high]
theorem nonpos_iff_eq_zero (q : ââ¥0) : q †0 â q = 0 :=
âšfun h => le_antisymm h q.2, fun h => h.symm âž q.2â©
end NNRat
open NNRat
namespace Rat
variable {p q : â}
@[simp]
theorem toNNRat_zero : toNNRat 0 = 0 := rfl
@[simp]
theorem toNNRat_one : toNNRat 1 = 1 := rfl
@[simp]
theorem toNNRat_pos : 0 < toNNRat q â 0 < q := by simp [toNNRat, â coe_lt_coe]
@[simp]
theorem toNNRat_eq_zero : toNNRat q = 0 â q †0 := by
simpa [-toNNRat_pos] using (@toNNRat_pos q).not
alias âš_, toNNRat_of_nonposâ© := toNNRat_eq_zero
@[simp]
theorem toNNRat_le_toNNRat_iff (hp : 0 †p) : toNNRat q †toNNRat p â q †p := by
simp [â coe_le_coe, toNNRat, hp]
@[simp]
theorem toNNRat_lt_toNNRat_iff' : toNNRat q < toNNRat p â q < p â§ 0 < p := by
simp [â coe_lt_coe, toNNRat, lt_irrefl]
theorem toNNRat_lt_toNNRat_iff (h : 0 < p) : toNNRat q < toNNRat p â q < p :=
toNNRat_lt_toNNRat_iff'.trans (and_iff_left h)
theorem toNNRat_lt_toNNRat_iff_of_nonneg (hq : 0 †q) : toNNRat q < toNNRat p â q < p :=
toNNRat_lt_toNNRat_iff'.trans âšAnd.left, fun h ⊠âšh, hq.trans_lt hâ©â©
@[simp]
theorem toNNRat_add (hq : 0 †q) (hp : 0 †p) : toNNRat (q + p) = toNNRat q + toNNRat p :=
NNRat.ext <| by simp [toNNRat, hq, hp, add_nonneg]
theorem toNNRat_add_le : toNNRat (q + p) †toNNRat q + toNNRat p :=
coe_le_coe.1 <| max_le (add_le_add (le_max_left _ _) (le_max_left _ _)) <| coe_nonneg _
theorem toNNRat_le_iff_le_coe {p : ââ¥0} : toNNRat q †p â q †âp :=
NNRat.gi.gc q p
theorem le_toNNRat_iff_coe_le {q : ââ¥0} (hp : 0 †p) : q †toNNRat p â âq †p := by
rw [â coe_le_coe, Rat.coe_toNNRat p hp]
theorem le_toNNRat_iff_coe_le' {q : ââ¥0} (hq : 0 < q) : q †toNNRat p â âq †p :=
(le_or_lt 0 p).elim le_toNNRat_iff_coe_le fun hp ⊠by
simp only [(hp.trans_le q.coe_nonneg).not_le, toNNRat_eq_zero.2 hp.le, hq.not_le]
theorem toNNRat_lt_iff_lt_coe {p : ââ¥0} (hq : 0 †q) : toNNRat q < p â q < âp := by
rw [â coe_lt_coe, Rat.coe_toNNRat q hq]
theorem lt_toNNRat_iff_coe_lt {q : ââ¥0} : q < toNNRat p â âq < p :=
NNRat.gi.gc.lt_iff_lt
theorem toNNRat_mul (hp : 0 †p) : toNNRat (p * q) = toNNRat p * toNNRat q := by
rcases le_total 0 q with hq | hq
· ext; simp [toNNRat, hp, hq, max_eq_left, mul_nonneg]
· have hpq := mul_nonpos_of_nonneg_of_nonpos hp hq
rw [toNNRat_eq_zero.2 hq, toNNRat_eq_zero.2 hpq, mul_zero]
end Rat
/-- The absolute value on `â` as a map to `ââ¥0`. -/
@[pp_nodot]
def Rat.nnabs (x : â) : ââ¥0 :=
âšabs x, abs_nonneg xâ©
@[norm_cast, simp]
theorem Rat.coe_nnabs (x : â) : (Rat.nnabs x : â) = abs x := rfl
/-! ### Numerator and denominator -/
namespace NNRat
variable {p q : ââ¥0}
@[norm_cast] lemma num_coe (q : ââ¥0) : (q : â).num = q.num := by
simp only [num, Int.natCast_natAbs, Rat.num_nonneg, coe_nonneg, abs_of_nonneg]
theorem natAbs_num_coe : (q : â).num.natAbs = q.num := rfl
@[norm_cast] lemma den_coe : (q : â).den = q.den := rfl
@[simp] lemma num_ne_zero : q.num â 0 â q â 0 := by simp [num]
@[simp] lemma num_pos : 0 < q.num â 0 < q := by
simpa [num, -nonpos_iff_eq_zero] using nonpos_iff_eq_zero _ |>.not.symm
@[simp] lemma den_pos (q : ââ¥0) : 0 < q.den := Rat.den_pos _
@[simp] lemma den_ne_zero (q : ââ¥0) : q.den â 0 := Rat.den_ne_zero _
lemma coprime_num_den (q : ââ¥0) : q.num.Coprime q.den := by simpa [num, den] using Rat.reduced _
-- TODO: Rename `Rat.coe_nat_num`, `Rat.intCast_den`, `Rat.ofNat_num`, `Rat.ofNat_den`
@[simp, norm_cast] lemma num_natCast (n : â) : num n = n := rfl
@[simp, norm_cast] lemma den_natCast (n : â) : den n = 1 := rfl
@[simp] lemma num_ofNat (n : â) [n.AtLeastTwo] : num ofNat(n) = OfNat.ofNat n :=
rfl
@[simp] lemma den_ofNat (n : â) [n.AtLeastTwo] : den ofNat(n) = 1 := rfl
theorem ext_num_den (hn : p.num = q.num) (hd : p.den = q.den) : p = q := by
refine ext <| Rat.ext ?_ hd
simpa [num_coe]
theorem ext_num_den_iff : p = q â p.num = q.num â§ p.den = q.den :=
âšby rintro rfl; exact âšrfl, rflâ©, fun h ⊠ext_num_den h.1 h.2â©
/-- Form the quotient `n / d` where `n d : â`.
See also `Rat.divInt` and `mkRat`. -/
def divNat (n d : â) : ââ¥0 :=
âš.divInt n d, Rat.divInt_nonneg (Int.ofNat_zero_le n) (Int.ofNat_zero_le d)â©
variable {nâ nâ dâ dâ : â}
@[simp, norm_cast] lemma coe_divNat (n d : â) : (divNat n d : â) = .divInt n d := rfl
lemma mk_divInt (n d : â) :
âš.divInt n d, Rat.divInt_nonneg (Int.ofNat_zero_le n) (Int.ofNat_zero_le d)â© = divNat n d := rfl
lemma divNat_inj (hâ : dâ â 0) (hâ : dâ â 0) : divNat nâ dâ = divNat nâ dâ â nâ * dâ = nâ * dâ := by
rw [â coe_inj]; simp [Rat.mkRat_eq_iff, hâ, hâ]; norm_cast
@[simp] lemma divNat_zero (n : â) : divNat n 0 = 0 := by simp [divNat]; rfl
@[simp] lemma num_divNat_den (q : ââ¥0) : divNat q.num q.den = q :=
ext <| by rw [â (q : â).mkRat_num_den']; simp [num_coe, den_coe]
lemma natCast_eq_divNat (n : â) : (n : ââ¥0) = divNat n 1 := (num_divNat_den _).symm
lemma divNat_mul_divNat (nâ nâ : â) {dâ dâ} (hdâ : dâ â 0) (hdâ : dâ â 0) :
divNat nâ dâ * divNat nâ dâ = divNat (nâ * nâ) (dâ * dâ) := by
ext; push_cast; exact Rat.divInt_mul_divInt _ _ (mod_cast hdâ) (mod_cast hdâ)
lemma divNat_mul_left {a : â} (ha : a â 0) (n d : â) : divNat (a * n) (a * d) = divNat n d := by
ext; push_cast; exact Rat.divInt_mul_left (mod_cast ha)
lemma divNat_mul_right {a : â} (ha : a â 0) (n d : â) : divNat (n * a) (d * a) = divNat n d := by
ext; push_cast; exact Rat.divInt_mul_right (mod_cast ha)
@[simp] lemma mul_den_eq_num (q : ââ¥0) : q * q.den = q.num := by
ext
push_cast
rw [â Int.cast_natCast, â den_coe, â Int.cast_natCast q.num, â num_coe]
exact Rat.mul_den_eq_num _
@[simp] lemma den_mul_eq_num (q : ââ¥0) : q.den * q = q.num := by rw [mul_comm, mul_den_eq_num]
/-- Define a (dependent) function or prove `â r : â, p r` by dealing with nonnegative rational
numbers of the form `n / d` with `d â 0` and `n`, `d` coprime. -/
@[elab_as_elim]
def numDenCasesOn.{u} {C : ââ¥0 â Sort u} (q) (H : â n d, d â 0 â n.Coprime d â C (divNat n d)) :
C q := by rw [â q.num_divNat_den]; exact H _ _ q.den_ne_zero q.coprime_num_den
lemma add_def (q r : ââ¥0) : q + r = divNat (q.num * r.den + r.num * q.den) (q.den * r.den) := by
ext; simp [Rat.add_def', Rat.mkRat_eq_divInt, num_coe, den_coe]
lemma mul_def (q r : ââ¥0) : q * r = divNat (q.num * r.num) (q.den * r.den) := by
ext; simp [Rat.mul_eq_mkRat, Rat.mkRat_eq_divInt, num_coe, den_coe]
theorem lt_def {p q : ââ¥0} : p < q â p.num * q.den < q.num * p.den := by
rw [â NNRat.coe_lt_coe, Rat.lt_def]; norm_cast
theorem le_def {p q : ââ¥0} : p †q â p.num * q.den †q.num * p.den := by
rw [â NNRat.coe_le_coe, Rat.le_def]; norm_cast
| end NNRat
| Mathlib/Data/NNRat/Defs.lean | 406 | 407 |
/-
Copyright (c) 2021 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying, Rémy Degenne
-/
import Mathlib.MeasureTheory.Constructions.Cylinders
import Mathlib.MeasureTheory.Function.ConditionalExpectation.Real
import Mathlib.MeasureTheory.MeasurableSpace.PreorderRestrict
/-!
# Filtrations
This file defines filtrations of a measurable space and Ï-finite filtrations.
## Main definitions
* `MeasureTheory.Filtration`: a filtration on a measurable space. That is, a monotone sequence of
sub-Ï-algebras.
* `MeasureTheory.SigmaFiniteFiltration`: a filtration `f` is Ï-finite with respect to a measure
`ÎŒ` if for all `i`, `ÎŒ.trim (f.le i)` is Ï-finite.
* `MeasureTheory.Filtration.natural`: the smallest filtration that makes a process adapted. That
notion `adapted` is not defined yet in this file. See `MeasureTheory.adapted`.
## Main results
* `MeasureTheory.Filtration.instCompleteLattice`: filtrations are a complete lattice.
## Tags
filtration, stochastic process
-/
open Filter Order TopologicalSpace
open scoped MeasureTheory NNReal ENNReal Topology
namespace MeasureTheory
/-- A `Filtration` on a measurable space `Ω` with Ï-algebra `m` is a monotone
sequence of sub-Ï-algebras of `m`. -/
structure Filtration {Ω : Type*} (ι : Type*) [Preorder ι] (m : MeasurableSpace Ω) where
/-- The sequence of sub-Ï-algebras of `m` -/
seq : ι â MeasurableSpace Ω
mono' : Monotone seq
le' : â i : ι, seq i †m
attribute [coe] Filtration.seq
variable {Ω β ι : Type*} {m : MeasurableSpace Ω}
instance [Preorder ι] : CoeFun (Filtration ι m) fun _ => ι â MeasurableSpace Ω :=
âšfun f => f.seqâ©
namespace Filtration
variable [Preorder ι]
protected theorem mono {i j : ι} (f : Filtration ι m) (hij : i †j) : f i †f j :=
f.mono' hij
protected theorem le (f : Filtration ι m) (i : ι) : f i †m :=
f.le' i
@[ext]
protected theorem ext {f g : Filtration ι m} (h : (f : ι â MeasurableSpace Ω) = g) : f = g := by
cases f; cases g; congr
variable (ι) in
/-- The constant filtration which is equal to `m` for all `i : ι`. -/
def const (m' : MeasurableSpace Ω) (hm' : m' †m) : Filtration ι m :=
âšfun _ => m', monotone_const, fun _ => hm'â©
@[simp]
theorem const_apply {m' : MeasurableSpace Ω} {hm' : m' †m} (i : ι) : const ι m' hm' i = m' :=
rfl
instance : Inhabited (Filtration ι m) :=
âšconst ι m le_rflâ©
instance : LE (Filtration ι m) :=
âšfun f g => â i, f i †g iâ©
instance : Bot (Filtration ι m) :=
âšconst ι ⥠bot_leâ©
instance : Top (Filtration ι m) :=
âšconst ι m le_rflâ©
instance : Max (Filtration ι m) :=
âšfun f g =>
{ seq := fun i => f i â g i
mono' := fun _ _ hij =>
sup_le ((f.mono hij).trans le_sup_left) ((g.mono hij).trans le_sup_right)
le' := fun i => sup_le (f.le i) (g.le i) }â©
@[norm_cast]
theorem coeFn_sup {f g : Filtration ι m} : â(f â g) = âf â âg :=
rfl
instance : Min (Filtration ι m) :=
âšfun f g =>
{ seq := fun i => f i â g i
mono' := fun _ _ hij =>
le_inf (inf_le_left.trans (f.mono hij)) (inf_le_right.trans (g.mono hij))
le' := fun i => inf_le_left.trans (f.le i) }â©
@[norm_cast]
theorem coeFn_inf {f g : Filtration ι m} : â(f â g) = âf â âg :=
rfl
instance : SupSet (Filtration ι m) :=
âšfun s =>
{ seq := fun i => sSup ((fun f : Filtration ι m => f i) '' s)
mono' := fun i j hij => by
refine sSup_le fun m' hm' => ?_
rw [Set.mem_image] at hm'
obtain âšf, hf_mem, hfm'â© := hm'
rw [â hfm']
refine (f.mono hij).trans ?_
have hfj_mem : f j â (fun g : Filtration ι m => g j) '' s := âšf, hf_mem, rflâ©
exact le_sSup hfj_mem
le' := fun i => by
refine sSup_le fun m' hm' => ?_
rw [Set.mem_image] at hm'
obtain âšf, _, hfm'â© := hm'
rw [â hfm']
exact f.le i }â©
theorem sSup_def (s : Set (Filtration ι m)) (i : ι) :
sSup s i = sSup ((fun f : Filtration ι m => f i) '' s) :=
rfl
open scoped Classical in
noncomputable instance : InfSet (Filtration ι m) :=
âšfun s =>
{ seq := fun i => if Set.Nonempty s then sInf ((fun f : Filtration ι m => f i) '' s) else m
mono' := fun i j hij => by
by_cases h_nonempty : Set.Nonempty s
swap; · simp only [h_nonempty, Set.image_nonempty, if_false, le_refl]
simp only [h_nonempty, if_true, le_sInf_iff, Set.mem_image, forall_exists_index, and_imp,
forall_apply_eq_imp_iffâ]
refine fun f hf_mem => le_trans ?_ (f.mono hij)
have hfi_mem : f i â (fun g : Filtration ι m => g i) '' s := âšf, hf_mem, rflâ©
exact sInf_le hfi_mem
le' := fun i => by
by_cases h_nonempty : Set.Nonempty s
swap; · simp only [h_nonempty, if_false, le_refl]
simp only [h_nonempty, if_true]
obtain âšf, hf_memâ© := h_nonempty
exact le_trans (sInf_le âšf, hf_mem, rflâ©) (f.le i) }â©
open scoped Classical in
theorem sInf_def (s : Set (Filtration ι m)) (i : ι) :
sInf s i = if Set.Nonempty s then sInf ((fun f : Filtration ι m => f i) '' s) else m :=
rfl
noncomputable instance instCompleteLattice : CompleteLattice (Filtration ι m) where
le := (· †·)
le_refl _ _ := le_rfl
le_trans _ _ _ h_fg h_gh i := (h_fg i).trans (h_gh i)
le_antisymm _ _ h_fg h_gf := Filtration.ext <| funext fun i => (h_fg i).antisymm (h_gf i)
sup := (· â ·)
le_sup_left _ _ _ := le_sup_left
le_sup_right _ _ _ := le_sup_right
sup_le _ _ _ h_fh h_gh i := sup_le (h_fh i) (h_gh _)
inf := (· â ·)
inf_le_left _ _ _ := inf_le_left
inf_le_right _ _ _ := inf_le_right
le_inf _ _ _ h_fg h_fh i := le_inf (h_fg i) (h_fh i)
sSup := sSup
le_sSup _ f hf_mem _ := le_sSup âšf, hf_mem, rflâ©
sSup_le s f h_forall i :=
sSup_le fun m' hm' => by
obtain âšg, hg_mem, hfm'â© := hm'
rw [â hfm']
exact h_forall g hg_mem i
sInf := sInf
sInf_le s f hf_mem i := by
have hs : s.Nonempty := âšf, hf_memâ©
simp only [sInf_def, hs, if_true]
exact sInf_le âšf, hf_mem, rflâ©
le_sInf s f h_forall i := by
by_cases hs : s.Nonempty
swap; · simp only [sInf_def, hs, if_false]; exact f.le i
simp only [sInf_def, hs, if_true, le_sInf_iff, Set.mem_image, forall_exists_index, and_imp,
forall_apply_eq_imp_iffâ]
exact fun g hg_mem => h_forall g hg_mem i
top := â€
bot := â¥
le_top f i := f.le' i
bot_le _ _ := bot_le
end Filtration
theorem measurableSet_of_filtration [Preorder ι] {f : Filtration ι m} {s : Set Ω} {i : ι}
(hs : MeasurableSet[f i] s) : MeasurableSet[m] s :=
f.le i s hs
/-- A measure is Ï-finite with respect to filtration if it is Ï-finite with respect
to all the sub-Ï-algebra of the filtration. -/
class SigmaFiniteFiltration [Preorder ι] (Ό : Measure Ω) (f : Filtration ι m) : Prop where
SigmaFinite : â i : ι, SigmaFinite (ÎŒ.trim (f.le i))
instance sigmaFinite_of_sigmaFiniteFiltration [Preorder ι] (Ό : Measure Ω) (f : Filtration ι m)
[hf : SigmaFiniteFiltration Ό f] (i : ι) : SigmaFinite (Ό.trim (f.le i)) :=
hf.SigmaFinite _
instance (priority := 100) IsFiniteMeasure.sigmaFiniteFiltration [Preorder ι] (Ό : Measure Ω)
(f : Filtration ι m) [IsFiniteMeasure Ό] : SigmaFiniteFiltration Ό f :=
âšfun n => by infer_instanceâ©
/-- Given an integrable function `g`, the conditional expectations of `g` with respect to a
filtration is uniformly integrable. -/
theorem Integrable.uniformIntegrable_condExp_filtration [Preorder ι] {Ό : Measure Ω}
[IsFiniteMeasure ÎŒ] {f : Filtration ι m} {g : Ω â â} (hg : Integrable g ÎŒ) :
UniformIntegrable (fun i => Ό[g|f i]) 1 Ό :=
hg.uniformIntegrable_condExp f.le
@[deprecated (since := "2025-01-21")]
alias Integrable.uniformIntegrable_condexp_filtration :=
Integrable.uniformIntegrable_condExp_filtration
theorem Filtration.condExp_condExp [Preorder ι] {E : Type*} [NormedAddCommGroup E]
[NormedSpace â E] [CompleteSpace E] (f : Ω â E) {ÎŒ : Measure Ω} (â± : Filtration ι m)
{i j : ι} (hij : i †j) [SigmaFinite (ÎŒ.trim (â±.le j))] :
ÎŒ[ÎŒ[f|â± j]|â± i] =áµ[ÎŒ] ÎŒ[f|â± i] := condExp_condExp_of_le (â±.mono hij) (â±.le j)
section OfSet
variable [Preorder ι]
/-- Given a sequence of measurable sets `(sâ)`, `filtrationOfSet` is the smallest filtration
such that `sâ` is measurable with respect to the `n`-th sub-Ï-algebra in `filtrationOfSet`. -/
def filtrationOfSet {s : ι â Set Ω} (hsm : â i, MeasurableSet (s i)) : Filtration ι m where
seq i := MeasurableSpace.generateFrom {t | â j †i, s j = t}
mono' _ _ hnm := MeasurableSpace.generateFrom_mono fun _ âšk, hkâ, hkââ© => âšk, hkâ.trans hnm, hkââ©
le' _ := MeasurableSpace.generateFrom_le fun _ âšk, _, hkââ© => hkâ âž hsm k
theorem measurableSet_filtrationOfSet {s : ι â Set Ω} (hsm : â i, MeasurableSet[m] (s i)) (i : ι)
{j : ι} (hj : j †i) : MeasurableSet[filtrationOfSet hsm i] (s j) :=
MeasurableSpace.measurableSet_generateFrom âšj, hj, rflâ©
theorem measurableSet_filtrationOfSet' {s : ι â Set Ω} (hsm : â n, MeasurableSet[m] (s n))
(i : ι) : MeasurableSet[filtrationOfSet hsm i] (s i) :=
measurableSet_filtrationOfSet hsm i le_rfl
end OfSet
namespace Filtration
variable [TopologicalSpace β] [MetrizableSpace β] [mβ : MeasurableSpace β] [BorelSpace β]
[Preorder ι]
/-- Given a sequence of functions, the natural filtration is the smallest sequence
of Ï-algebras such that that sequence of functions is measurable with respect to
the filtration. -/
def natural (u : ι â Ω â β) (hum : â i, StronglyMeasurable (u i)) : Filtration ι m where
seq i := ⚠j †i, MeasurableSpace.comap (u j) mβ
mono' _ _ hij := biSup_mono fun _ => ge_trans hij
le' i := by
refine iSupâ_le ?_
rintro j _ s âšt, ht, rflâ©
exact (hum j).measurable ht
section
open MeasurableSpace
theorem filtrationOfSet_eq_natural [MulZeroOneClass β] [Nontrivial β] {s : ι â Set Ω}
(hsm : â i, MeasurableSet[m] (s i)) :
filtrationOfSet hsm = natural (fun i => (s i).indicator (fun _ => 1 : Ω â β)) fun i =>
stronglyMeasurable_one.indicator (hsm i) := by
simp only [filtrationOfSet, natural, measurableSpace_iSup_eq, exists_prop, mk.injEq]
ext1 i
refine le_antisymm (generateFrom_le ?_) (generateFrom_le ?_)
· rintro _ âšj, hij, rflâ©
refine measurableSet_generateFrom âšj, measurableSet_generateFrom âšhij, ?_â©â©
rw [comap_eq_generateFrom]
refine measurableSet_generateFrom âš{1}, measurableSet_singleton 1, ?_â©
ext x
simp [Set.indicator_const_preimage_eq_union]
· rintro t âšn, htâ©
suffices MeasurableSpace.generateFrom {t | n †i â§
MeasurableSet[MeasurableSpace.comap ((s n).indicator (fun _ => 1 : Ω â β)) mβ] t} â€
MeasurableSpace.generateFrom {t | â (j : ι), j †i â§ s j = t} by
exact this _ ht
refine generateFrom_le ?_
rintro t âšhn, u, _, hu'â©
obtain heq | heq | heq | heq := Set.indicator_const_preimage (s n) u (1 : β)
on_goal 4 => rw [Set.mem_singleton_iff] at heq
all_goals rw [heq] at hu'; rw [â hu']
exacts [MeasurableSet.univ, measurableSet_generateFrom âšn, hn, rflâ©,
MeasurableSet.compl (measurableSet_generateFrom âšn, hn, rflâ©), measurableSet_empty _]
end
section Limit
variable {E : Type*} [Zero E] [TopologicalSpace E] {â± : Filtration ι m} {f : ι â Ω â E}
{Ό : Measure Ω}
open scoped Classical in
/-- Given a process `f` and a filtration `â±`, if `f` converges to some `g` almost everywhere and
`g` is `⚠n, Ⱡn`-measurable, then `limitProcess f ⱠΌ` chooses said `g`, else it returns 0.
This definition is used to phrase the a.e. martingale convergence theorem
`Submartingale.ae_tendsto_limitProcess` where an L¹-bounded submartingale `f` adapted to `â±`
converges to `limitProcess f ⱠΌ` `Ό`-almost everywhere. -/
noncomputable def limitProcess (f : ι â Ω â E) (â± : Filtration ι m)
(Ό : Measure Ω) :=
if h : â g : Ω â E,
StronglyMeasurable[âš n, â± n] g â§ âáµ Ï âÎŒ, Tendsto (fun n => f n Ï) atTop (ð (g Ï)) then
Classical.choose h else 0
theorem stronglyMeasurable_limitProcess : StronglyMeasurable[⚠n, Ⱡn] (limitProcess f ⱠΌ) := by
rw [limitProcess]
split_ifs with h
exacts [(Classical.choose_spec h).1, stronglyMeasurable_zero]
theorem stronglyMeasurable_limit_process' : StronglyMeasurable[m] (limitProcess f ⱠΌ) :=
stronglyMeasurable_limitProcess.mono (sSup_le fun _ âš_, hnâ© => hn âž â±.le _)
theorem memLp_limitProcess_of_eLpNorm_bdd {R : ââ¥0} {p : ââ¥0â} {F : Type*} [NormedAddCommGroup F]
{â± : Filtration â m} {f : â â Ω â F} (hfm : â n, AEStronglyMeasurable (f n) ÎŒ)
(hbdd : â n, eLpNorm (f n) p ÎŒ †R) : MemLp (limitProcess f â± ÎŒ) p ÎŒ := by
rw [limitProcess]
split_ifs with h
· refine âšStronglyMeasurable.aestronglyMeasurable
((Classical.choose_spec h).1.mono (sSup_le fun m âšn, hnâ© => hn âž â±.le _)),
lt_of_le_of_lt (Lp.eLpNorm_lim_le_liminf_eLpNorm hfm _ (Classical.choose_spec h).2)
(lt_of_le_of_lt ?_ (ENNReal.coe_lt_top : âR < â))â©
simp_rw [liminf_eq, eventually_atTop]
exact sSup_le fun b âša, haâ© => (ha a le_rfl).trans (hbdd _)
· exact MemLp.zero
| @[deprecated (since := "2025-02-21")]
alias memâp_limitProcess_of_eLpNorm_bdd := memLp_limitProcess_of_eLpNorm_bdd
end Limit
section piLE
/-! ### Filtration of the first events -/
open MeasurableSpace Preorder
variable {X : ι â Type*} [â i, MeasurableSpace (X i)]
| Mathlib/Probability/Process/Filtration.lean | 338 | 349 |
/-
Copyright (c) 2021 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.LinearAlgebra.Basis.Basic
import Mathlib.LinearAlgebra.Basis.Submodule
import Mathlib.LinearAlgebra.Dimension.Finrank
import Mathlib.LinearAlgebra.InvariantBasisNumber
/-!
# Lemmas about rank and finrank in rings satisfying strong rank condition.
## Main statements
For modules over rings satisfying the rank condition
* `Basis.le_span`:
the cardinality of a basis is bounded by the cardinality of any spanning set
For modules over rings satisfying the strong rank condition
* `linearIndependent_le_span`:
For any linearly independent family `v : ι â M`
and any finite spanning set `w : Set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
* `linearIndependent_le_basis`:
If `b` is a basis for a module `M`,
and `s` is a linearly independent set,
then the cardinality of `s` is bounded by the cardinality of `b`.
For modules over rings with invariant basis number
(including all commutative rings and all noetherian rings)
* `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same
cardinality.
## Additional definition
* `Algebra.IsQuadraticExtension`: An extension of rings `R â S` is quadratic if `S` is a
free `R`-algebra of rank `2`.
-/
noncomputable section
universe u v w w'
variable {R : Type u} {M : Type v} [Semiring R] [AddCommMonoid M] [Module R M]
variable {ι : Type w} {ι' : Type w'}
open Cardinal Basis Submodule Function Set Module
attribute [local instance] nontrivial_of_invariantBasisNumber
section InvariantBasisNumber
variable [InvariantBasisNumber R]
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
classical
haveI := nontrivial_of_invariantBasisNumber R
cases fintypeOrInfinite ι
· -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
-- haveI : Finite (range v) := Set.finite_range v
haveI := basis_finite_of_finite_spans (Set.finite_range v) v.span_eq v'
cases nonempty_fintype ι'
-- We clean up a little:
rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
simp only [Cardinal.lift_natCast, Nat.cast_inj]
-- Now we can use invariant basis number to show they have the same cardinality.
apply card_eq_of_linearEquiv R
exact
(Finsupp.linearEquivFunOnFinite R R ι).symm.trans v.repr.symm âªâ«â v'.repr âªâ«â
Finsupp.linearEquivFunOnFinite R R ι'
· -- `v` is an infinite basis,
-- so by `infinite_basis_le_maximal_linearIndependent`, `v'` is at least as big,
-- and then applying `infinite_basis_le_maximal_linearIndependent` again
-- we see they have the same cardinality.
have wâ := infinite_basis_le_maximal_linearIndependent' v _ v'.linearIndependent v'.maximal
rcases Cardinal.lift_mk_le'.mp wâ with âšfâ©
haveI : Infinite ι' := Infinite.of_injective f f.2
have wâ := infinite_basis_le_maximal_linearIndependent' v' _ v.linearIndependent v.maximal
exact le_antisymm wâ wâ
/-- Given two bases indexed by `ι` and `ι'` of an `R`-module, where `R` satisfies the invariant
basis number property, an equiv `ι â ι'`. -/
def Basis.indexEquiv (v : Basis ι R M) (v' : Basis ι' R M) : ι â ι' :=
(Cardinal.lift_mk_eq'.1 <| mk_eq_mk_of_basis v v').some
theorem mk_eq_mk_of_basis' {ι' : Type w} (v : Basis ι R M) (v' : Basis ι' R M) : #ι = #ι' :=
Cardinal.lift_inj.1 <| mk_eq_mk_of_basis v v'
end InvariantBasisNumber
section RankCondition
variable [RankCondition R]
/-- An auxiliary lemma for `Basis.le_span`.
If `R` satisfies the rank condition,
then for any finite basis `b : Basis ι R M`,
and any finite spanning set `w : Set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
-/
theorem Basis.le_span'' {ι : Type*} [Fintype ι] (b : Basis ι R M) {w : Set M} [Fintype w]
(s : span R w = â€) : Fintype.card ι †Fintype.card w := by
-- We construct a surjective linear map `(w â R) ââ[R] (ι â R)`,
-- by expressing a linear combination in `w` as a linear combination in `ι`.
fapply card_le_of_surjective' R
· exact b.repr.toLinearMap.comp (Finsupp.linearCombination R (â))
· apply Surjective.comp (g := b.repr.toLinearMap)
· apply LinearEquiv.surjective
rw [â LinearMap.range_eq_top, Finsupp.range_linearCombination]
simpa using s
/--
Another auxiliary lemma for `Basis.le_span`, which does not require assuming the basis is finite,
but still assumes we have a finite spanning set.
-/
theorem basis_le_span' {ι : Type*} (b : Basis ι R M) {w : Set M} [Fintype w] (s : span R w = â€) :
#ι †Fintype.card w := by
haveI := nontrivial_of_invariantBasisNumber R
haveI := basis_finite_of_finite_spans w.toFinite s b
cases nonempty_fintype ι
rw [Cardinal.mk_fintype ι]
simp only [Nat.cast_le]
exact Basis.le_span'' b s
-- Note that if `R` satisfies the strong rank condition,
-- this also follows from `linearIndependent_le_span` below.
/-- If `R` satisfies the rank condition,
then the cardinality of any basis is bounded by the cardinality of any spanning set.
-/
theorem Basis.le_span {J : Set M} (v : Basis ι R M) (hJ : span R J = â€) : #(range v) †#J := by
haveI := nontrivial_of_invariantBasisNumber R
cases fintypeOrInfinite J
· rw [â Cardinal.lift_le, Cardinal.mk_range_eq_of_injective v.injective, Cardinal.mk_fintype J]
convert Cardinal.lift_le.{v}.2 (basis_le_span' v hJ)
simp
· let S : J â Set ι := fun j => â(v.repr j).support
let S' : J â Set M := fun j => v '' S j
have hs : range v â â j, S' j := by
intro b hb
rcases mem_range.1 hb with âši, hiâ©
have : span R J †comap v.repr.toLinearMap (Finsupp.supported R R (â j, S j)) :=
span_le.2 fun j hj x hx => âš_, âšâšj, hjâ©, rflâ©, hxâ©
rw [hJ] at this
replace : v.repr (v i) â Finsupp.supported R R (â j, S j) := this trivial
rw [v.repr_self, Finsupp.mem_supported, Finsupp.support_single_ne_zero _ one_ne_zero] at this
· subst b
rcases mem_iUnion.1 (this (Finset.mem_singleton_self _)) with âšj, hjâ©
exact mem_iUnion.2 âšj, (mem_image _ _ _).2 âši, hj, rflâ©â©
refine le_of_not_lt fun IJ => ?_
suffices #(â j, S' j) < #(range v) by exact not_le_of_lt this âšSet.embeddingOfSubset _ _ hsâ©
refine lt_of_le_of_lt (le_trans Cardinal.mk_iUnion_le_sum_mk
(Cardinal.sum_le_sum _ (fun _ => âµâ) ?_)) ?_
· exact fun j => (Cardinal.lt_aleph0_of_finite _).le
· simpa
end RankCondition
section StrongRankCondition
variable [StrongRankCondition R]
open Submodule Finsupp
-- 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.linearCombination
exact fun i => Span.repr R w âšv i, s (mem_range_self i)â©
· intro f g h
apply_fun linearCombination R ((â) : w â M) at h
simp only [linearCombination_linearCombination, Submodule.coe_mk,
Span.finsupp_linearCombination_repr] at h
exact i h
/-- If `R` satisfies the strong rank condition,
then any linearly independent family `v : ι â M`
contained in the span of some finite `w : Set M`,
is itself finite.
-/
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'
/-- If `R` satisfies the strong rank condition,
then for any linearly independent family `v : ι â M`
contained in the span of some finite `w : Set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
-/
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 [Nat.cast_le]
exact linearIndependent_le_span_aux' v i w s
/-- If `R` satisfies the strong rank condition,
then for any linearly independent family `v : ι â M`
and any finite spanning set `w : Set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
-/
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
/-- A version of `linearIndependent_le_span` for `Finset`. -/
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
/-- An auxiliary lemma for `linearIndependent_le_basis`:
we handle the case where the basis `b` is infinite.
-/
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
/-- Over any ring `R` satisfying the strong rank condition,
if `b` is a basis for a module `M`,
and `s` is a linearly independent set,
then the cardinality of `s` is bounded by the cardinality of `b`.
-/
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
/-- `StrongRankCondition` implies that if there is an injective linear map `(α ââ R) ââ[R] β ââ R`,
then the cardinal of `α` is smaller than or equal to the cardinal of `β`.
-/
theorem card_le_of_injective'' {α : Type v} {β : Type v} (f : (α ââ R) ââ[R] β ââ R)
(i : Injective f) : #α †#β := by
let b : Basis β R (β ââ R) := âš1â©
apply linearIndependent_le_basis b (fun (i : α) ⊠f (Finsupp.single i 1))
rw [LinearIndependent]
have : (linearCombination R fun i ⊠f (Finsupp.single i 1)) = f := by ext a b; simp
exact this.symm âž i
/-- If `R` satisfies the strong rank condition, then for any linearly independent family `v : ι â M`
and spanning set `w : Set M`, the cardinality of `ι` is bounded by the cardinality of `w`.
-/
theorem linearIndependent_le_span'' {ι : Type v} {v : ι â M} (i : LinearIndependent R v) (w : Set M)
(s : span R w = â€) : #ι †#w := by
fapply card_le_of_injective'' (R := R)
· apply Finsupp.linearCombination
exact fun i ⊠Span.repr R w âšv i, s âž trivialâ©
· intro f g h
apply_fun linearCombination R ((â) : w â M) at h
simp only [linearCombination_linearCombination, Submodule.coe_mk,
Span.finsupp_linearCombination_repr] at h
exact i h
/-- Let `R` satisfy the strong rank condition. If `m` elements of a free rank `n` `R`-module are
linearly independent, then `m †n`. -/
theorem Basis.card_le_card_of_linearIndependent_aux {R : Type*} [Semiring R] [StrongRankCondition R]
(n : â) {m : â} (v : Fin m â Fin n â R) : LinearIndependent R v â m †n := fun h => by
simpa using linearIndependent_le_basis (Pi.basisFun R (Fin n)) v h
-- When the basis is not infinite this need not be true!
/-- Over any ring `R` satisfying the strong rank condition,
if `b` is an infinite basis for a module `M`,
then every maximal linearly independent set has the same cardinality as `b`.
This proof (along with some of the lemmas above) comes from
[Les familles libres maximales d'un module ont-elles le meme cardinal?][lazarus1973]
-/
theorem maximal_linearIndependent_eq_infinite_basis {ι : Type w} (b : Basis ι R M) [Infinite ι]
{κ : Type w} (v : κ â M) (i : LinearIndependent R v) (m : i.Maximal) : #κ = #ι := by
apply le_antisymm
· exact linearIndependent_le_basis b v i
· haveI : Nontrivial R := nontrivial_of_invariantBasisNumber R
exact infinite_basis_le_maximal_linearIndependent b v i m
theorem Basis.mk_eq_rank'' {ι : Type v} (v : Basis ι R M) : #ι = Module.rank R M := by
haveI := nontrivial_of_invariantBasisNumber R
rw [Module.rank_def]
apply le_antisymm
· trans
swap
· apply le_ciSup (Cardinal.bddAbove_range _)
exact
âšSet.range v, by
rw [LinearIndepOn]
convert v.reindexRange.linearIndependent
simpâ©
· exact (Cardinal.mk_range_eq v v.injective).ge
· apply ciSup_le'
rintro âšs, liâ©
apply linearIndependent_le_basis v _ li
theorem Basis.mk_range_eq_rank (v : Basis ι R M) : #(range v) = Module.rank R M :=
v.reindexRange.mk_eq_rank''
/-- If a vector space has a finite basis, then its dimension (seen as a cardinal) is equal to the
cardinality of the basis. -/
theorem rank_eq_card_basis {ι : Type w} [Fintype ι] (h : Basis ι R M) :
Module.rank R M = Fintype.card ι := by
classical
haveI := nontrivial_of_invariantBasisNumber R
rw [â h.mk_range_eq_rank, Cardinal.mk_fintype, Set.card_range_of_injective h.injective]
theorem Basis.card_le_card_of_linearIndependent {ι : Type*} [Fintype ι] (b : Basis ι R M)
{ι' : Type*} [Fintype ι'] {v : ι' â M} (hv : LinearIndependent R v) :
Fintype.card ι' †Fintype.card ι := by
letI := nontrivial_of_invariantBasisNumber R
simpa [rank_eq_card_basis b, Cardinal.mk_fintype] using hv.cardinal_lift_le_rank
theorem Basis.card_le_card_of_submodule (N : Submodule R M) [Fintype ι] (b : Basis ι R M)
[Fintype ι'] (b' : Basis ι' R N) : Fintype.card ι' †Fintype.card ι :=
b.card_le_card_of_linearIndependent
(b'.linearIndependent.map_injOn N.subtype N.injective_subtype.injOn)
theorem Basis.card_le_card_of_le {N O : Submodule R M} (hNO : N †O) [Fintype ι] (b : Basis ι R O)
[Fintype ι'] (b' : Basis ι' R N) : Fintype.card ι' †Fintype.card ι :=
b.card_le_card_of_linearIndependent
(b'.linearIndependent.map_injOn (inclusion hNO) (N.inclusion_injective _).injOn)
theorem Basis.mk_eq_rank (v : Basis ι R M) :
Cardinal.lift.{v} #ι = Cardinal.lift.{w} (Module.rank R M) := by
haveI := nontrivial_of_invariantBasisNumber R
rw [â v.mk_range_eq_rank, Cardinal.mk_range_eq_of_injective v.injective]
theorem Basis.mk_eq_rank'.{m} (v : Basis ι R M) :
Cardinal.lift.{max v m} #ι = Cardinal.lift.{max w m} (Module.rank R M) :=
Cardinal.lift_umax_eq.{w, v, m}.mpr v.mk_eq_rank
theorem rank_span {v : ι â M} (hv : LinearIndependent R v) :
Module.rank R â(span R (range v)) = #(range v) := by
haveI := nontrivial_of_invariantBasisNumber R
rw [â Cardinal.lift_inj, â (Basis.span hv).mk_eq_rank,
Cardinal.mk_range_eq_of_injective (@LinearIndependent.injective ι R M v _ _ _ _ hv)]
theorem rank_span_set {s : Set M} (hs : LinearIndepOn R id s) : Module.rank R â(span R s) = #s := by
rw [â @setOf_mem_eq _ s, â Subtype.range_coe_subtype]
exact rank_span hs
theorem toENat_rank_span_set {v : ι â M} {s : Set ι} (hs : LinearIndepOn R v s) :
(Module.rank R <| span R <| v '' s).toENat = s.encard := by
rw [image_eq_range, â hs.injOn.encard_image, â toENat_cardinalMk, image_eq_range,
â rank_span hs.linearIndependent]
/-- An induction (and recursion) principle for proving results about all submodules of a fixed
finite free module `M`. A property is true for all submodules of `M` if it satisfies the following
"inductive step": the property is true for a submodule `N` if it's true for all submodules `N'`
of `N` with the property that there exists `0 â x â N` such that the sum `N' + Rx` is direct. -/
def Submodule.inductionOnRank {R M} [Ring R] [StrongRankCondition R] [AddCommGroup M] [Module R M]
[IsDomain R] [Finite ι] (b : Basis ι R M) (P : Submodule R M â Sort*)
(ih : â N : Submodule R M,
(â N' †N, â x â N, (â (c : R), â y â N', c ⢠x + y = (0 : M) â c = 0) â P N') â P N)
(N : Submodule R M) : P N :=
letI := Fintype.ofFinite ι
Submodule.inductionOnRankAux b P ih (Fintype.card ι) N fun hs hli => by
simpa using b.card_le_card_of_linearIndependent hli
/-- If `S` a module-finite free `R`-algebra, then the `R`-rank of a nonzero `R`-free
ideal `I` of `S` is the same as the rank of `S`. -/
theorem Ideal.rank_eq {R S : Type*} [CommRing R] [StrongRankCondition R] [Ring S] [IsDomain S]
[Algebra R S] {n m : Type*} [Fintype n] [Fintype m] (b : Basis n R S) {I : Ideal S}
(hI : I â â¥) (c : Basis m R I) : Fintype.card m = Fintype.card n := by
obtain âša, haâ© := Submodule.nonzero_mem_of_bot_lt (bot_lt_iff_ne_bot.mpr hI)
have : LinearIndependent R fun i => b i ⢠a := by
have hb := b.linearIndependent
rw [Fintype.linearIndependent_iff] at hb â¢
intro g hg
apply hb g
simp only [â smul_assoc, â Finset.sum_smul, smul_eq_zero] at hg
exact hg.resolve_right ha
exact le_antisymm
(b.card_le_card_of_linearIndependent (c.linearIndependent.map' (Submodule.subtype I)
((LinearMap.ker_eq_bot (f := (Submodule.subtype I : I ââ[R] S))).mpr Subtype.coe_injective)))
(c.card_le_card_of_linearIndependent this)
namespace Module
theorem finrank_eq_nat_card_basis (h : Basis ι R M) :
finrank R M = Nat.card ι := by
rw [Nat.card, â toNat_lift.{v}, h.mk_eq_rank, toNat_lift, finrank]
/-- If a vector space (or module) has a finite basis, then its dimension (or rank) is equal to the
cardinality of the basis. -/
theorem finrank_eq_card_basis {ι : Type w} [Fintype ι] (h : Basis ι R M) :
finrank R M = Fintype.card ι :=
finrank_eq_of_rank_eq (rank_eq_card_basis h)
/-- If a free module is of finite rank, then the cardinality of any basis is equal to its
`finrank`. -/
theorem mk_finrank_eq_card_basis [Module.Finite R M] {ι : Type w} (h : Basis ι R M) :
(finrank R M : Cardinal.{w}) = #ι := by
cases @nonempty_fintype _ (Module.Finite.finite_basis h)
rw [Cardinal.mk_fintype, finrank_eq_card_basis h]
/-- If a vector space (or module) has a finite basis, then its dimension (or rank) is equal to the
cardinality of the basis. This lemma uses a `Finset` instead of indexed types. -/
theorem finrank_eq_card_finset_basis {ι : Type w} {b : Finset ι} (h : Basis b R M) :
finrank R M = Finset.card b := by rw [finrank_eq_card_basis h, Fintype.card_coe]
variable (R)
@[simp]
theorem rank_self : Module.rank R R = 1 := by
rw [â Cardinal.lift_inj, â (Basis.singleton PUnit R).mk_eq_rank, Cardinal.mk_punit]
/-- A ring satisfying `StrongRankCondition` (such as a `DivisionRing`) is one-dimensional as a
module over itself. -/
@[simp]
theorem finrank_self : finrank R R = 1 :=
finrank_eq_of_rank_eq (by simp)
/-- Given a basis of a ring over itself indexed by a type `ι`, then `ι` is `Unique`. -/
noncomputable def _root_.Basis.unique {ι : Type*} (b : Basis ι R R) : Unique ι := by
have : Cardinal.mk ι = â(Module.finrank R R) := (Module.mk_finrank_eq_card_basis b).symm
have : Subsingleton ι ⧠Nonempty ι := by simpa [Cardinal.eq_one_iff_unique]
exact Nonempty.some ((unique_iff_subsingleton_and_nonempty _).2 this)
variable (M)
/-- The rank of a finite module is finite. -/
theorem rank_lt_aleph0 [Module.Finite R M] : Module.rank R M < âµâ := by
simp only [Module.rank_def]
obtain âšS, hSâ© := Module.finite_def.mp â¹_âº
refine (ciSup_le' fun i => ?_).trans_lt (nat_lt_aleph0 S.card)
| exact linearIndependent_le_span_finset _ i.prop S hS
noncomputable instance {R M : Type*} [DivisionRing R] [AddCommGroup M] [Module R M]
{s t : Set M} [Module.Finite R (span R t)]
(hs : LinearIndepOn R id s) (hst : s â t) :
Fintype (hs.extend hst) := by
| Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean | 465 | 470 |
/-
Copyright (c) 2022. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison, Yuma Mizuno, Oleksandr Manzyuk
-/
import Mathlib.CategoryTheory.Monoidal.Category
/-!
# Monoidal composition `ââ«` (composition up to associators)
We provide `f ââ« g`, the `monoidalComp` operation,
which automatically inserts associators and unitors as needed
to make the target of `f` match the source of `g`.
## Example
Suppose we have a braiding morphism `R X Y : X â Y â¶ Y â X` in a monoidal category, and that we
want to define the morphism with the type `Vâ â Vâ â Vâ â Vâ â Vâ
â¶ Vâ â Vâ â Vâ â Vâ â Vâ
` that
transposes the second and third components by `R Vâ Vâ`. How to do this? The first guess would be
to use the whiskering operators `â` and `â·`, and define the morphism as `Vâ â R Vâ Vâ â· Vâ â· Vâ
`.
However, this morphism has the type `Vâ â ((Vâ â Vâ) â Vâ) â Vâ
â¶ Vâ â ((Vâ â Vâ) â Vâ) â Vâ
`,
which is not what we need. We should insert suitable associators. The desired associators can,
in principle, be defined by using the primitive three-components associator
`α_ X Y Z : (X â Y) â Z â
X â (Y â Z)` as a building block, but writing down actual definitions
are quite tedious, and we usually don't want to see them.
The monoidal composition `ââ«` is designed to solve such a problem. In this case, we can define the
desired morphism as `ð _ ââ« Vâ â R Vâ Vâ â· Vâ â· Vâ
ââ« ð _`, where the first and the second `ð _`
are completed as `ð (Vâ â Vâ â Vâ â Vâ â Vâ
)` and `ð (Vâ â Vâ â Vâ â Vâ â Vâ
)`, respectively.
-/
universe v u
open CategoryTheory MonoidalCategory
namespace CategoryTheory
variable {C : Type u} [Category.{v} C]
open scoped MonoidalCategory
/--
A typeclass carrying a choice of monoidal structural isomorphism between two objects.
Used by the `ââ«` monoidal composition operator, and the `coherence` tactic.
-/
-- We could likely turn this into a `Prop` valued existential if that proves useful.
class MonoidalCoherence (X Y : C) where
/-- A monoidal structural isomorphism between two objects. -/
iso : X â
Y
/-- Notation for identities up to unitors and associators. -/
scoped[CategoryTheory.MonoidalCategory] notation " âð " =>
MonoidalCoherence.iso -- type as \ot ð
/-- Construct an isomorphism between two objects in a monoidal category
out of unitors and associators. -/
abbrev monoidalIso (X Y : C) [MonoidalCoherence X Y] : X â
Y := MonoidalCoherence.iso
/-- Compose two morphisms in a monoidal category,
inserting unitors and associators between as necessary. -/
def monoidalComp {W X Y Z : C} [MonoidalCoherence X Y] (f : W â¶ X) (g : Y â¶ Z) : W â¶ Z :=
f â« âð.hom â« g
@[inherit_doc monoidalComp]
scoped[CategoryTheory.MonoidalCategory] infixr:80 " ââ« " =>
monoidalComp -- type as \ot \gg
/-- Compose two isomorphisms in a monoidal category,
inserting unitors and associators between as necessary. -/
def monoidalIsoComp {W X Y Z : C} [MonoidalCoherence X Y] (f : W â
X) (g : Y â
Z) : W â
Z :=
f âªâ« âð âªâ« g
@[inherit_doc monoidalIsoComp]
scoped[CategoryTheory.MonoidalCategory] infixr:80 " âªââ« " =>
monoidalIsoComp -- type as \ll \ot \gg
namespace MonoidalCoherence
variable [MonoidalCategory C]
@[simps]
instance refl (X : C) : MonoidalCoherence X X := âšIso.refl _â©
@[simps]
instance whiskerLeft (X Y Z : C) [MonoidalCoherence Y Z] :
MonoidalCoherence (X â Y) (X â Z) :=
âšwhiskerLeftIso X âðâ©
@[simps]
instance whiskerRight (X Y Z : C) [MonoidalCoherence X Y] :
MonoidalCoherence (X â Z) (Y â Z) :=
âšwhiskerRightIso âð Zâ©
@[simps]
instance tensor_right (X Y : C) [MonoidalCoherence (ð_ C) Y] :
MonoidalCoherence X (X â Y) :=
âš(Ï_ X).symm âªâ« (whiskerLeftIso X âð)â©
@[simps]
instance tensor_right' (X Y : C) [MonoidalCoherence Y (ð_ C)] :
MonoidalCoherence (X â Y) X :=
âšwhiskerLeftIso X âð âªâ« (Ï_ X)â©
@[simps]
instance left (X Y : C) [MonoidalCoherence X Y] :
MonoidalCoherence (ð_ C â X) Y :=
âšÎ»_ X âªâ« âðâ©
@[simps]
instance left' (X Y : C) [MonoidalCoherence X Y] :
MonoidalCoherence X (ð_ C â Y) :=
âšâð âªâ« (λ_ Y).symmâ©
@[simps]
instance right (X Y : C) [MonoidalCoherence X Y] :
MonoidalCoherence (X â ð_ C) Y :=
âšÏ_ X âªâ« âðâ©
@[simps]
instance right' (X Y : C) [MonoidalCoherence X Y] :
MonoidalCoherence X (Y â ð_ C) :=
âšâð âªâ« (Ï_ Y).symmâ©
@[simps]
instance assoc (X Y Z W : C) [MonoidalCoherence (X â (Y â Z)) W] :
MonoidalCoherence ((X â Y) â Z) W :=
âšÎ±_ X Y Z âªâ« âðâ©
@[simps]
instance assoc' (W X Y Z : C) [MonoidalCoherence W (X â (Y â Z))] :
MonoidalCoherence W ((X â Y) â Z) :=
âšâð âªâ« (α_ X Y Z).symmâ©
end MonoidalCoherence
@[simp] lemma monoidalComp_refl {X Y Z : C} (f : X â¶ Y) (g : Y â¶ Z) :
f ââ« g = f â« g := by
simp [monoidalComp]
end CategoryTheory
| Mathlib/Tactic/CategoryTheory/MonoidalComp.lean | 142 | 144 | |
/-
Copyright (c) 2018 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Simon Hudon
-/
import Batteries.Data.List.Lemmas
import Mathlib.Tactic.TypeStar
/-!
# The Following Are Equivalent
This file allows to state that all propositions in a list are equivalent. It is used by
`Mathlib.Tactic.Tfae`.
`TFAE l` means `â x â l, â y â l, x â y`. This is equivalent to `Pairwise (â) l`.
-/
namespace List
/-- TFAE: The Following (propositions) Are Equivalent.
The `tfae_have` and `tfae_finish` tactics can be useful in proofs with `TFAE` goals.
-/
def TFAE (l : List Prop) : Prop :=
â x â l, â y â l, x â y
theorem tfae_nil : TFAE [] :=
forall_mem_nil _
@[simp]
theorem tfae_singleton (p) : TFAE [p] := by simp [TFAE, -eq_iff_iff]
theorem tfae_cons_of_mem {a b} {l : List Prop} (h : b â l) : TFAE (a :: l) â (a â b) â§ TFAE l :=
âšfun H => âšH a (by simp) b (Mem.tail a h),
fun _ hp _ hq => H _ (Mem.tail a hp) _ (Mem.tail a hq)â©,
by
rintro âšab, Hâ© p (_ | âš_, hpâ©) q (_ | âš_, hqâ©)
· rfl
· exact ab.trans (H _ h _ hq)
· exact (ab.trans (H _ h _ hp)).symm
· exact H _ hp _ hqâ©
theorem tfae_cons_cons {a b} {l : List Prop} : TFAE (a :: b :: l) â (a â b) â§ TFAE (b :: l) :=
tfae_cons_of_mem (Mem.head _)
@[simp]
theorem tfae_cons_self {a} {l : List Prop} : TFAE (a :: a :: l) â TFAE (a :: l) := by
simp [tfae_cons_cons]
theorem tfae_of_forall (b : Prop) (l : List Prop) (h : â a â l, a â b) : TFAE l :=
fun _aâ hâ _aâ hâ => (h _ hâ).trans (h _ hâ).symm
theorem tfae_of_cycle {a b} {l : List Prop} (h_chain : List.Chain (· â ·) a (b :: l))
(h_last : getLastD l b â a) : TFAE (a :: b :: l) := by
induction l generalizing a b with
| | nil => simp_all [tfae_cons_cons, iff_def]
| cons c l IH =>
| Mathlib/Data/List/TFAE.lean | 56 | 57 |
/-
Copyright (c) 2024 Brendan Murphy. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Brendan Murphy
-/
import Mathlib.RingTheory.Regular.IsSMulRegular
import Mathlib.RingTheory.Artinian.Module
import Mathlib.RingTheory.Nakayama
import Mathlib.Algebra.Equiv.TransferInstance
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.Noetherian.Basic
/-!
# Regular sequences and weakly regular sequences
The notion of a regular sequence is fundamental in commutative algebra.
Properties of regular sequences encode information about singularities of a
ring and regularity of a sequence can be tested homologically.
However the notion of a regular sequence is only really sensible for Noetherian local rings.
TODO: Koszul regular sequences, H_1-regular sequences, quasi-regular sequences, depth.
## Tags
module, regular element, regular sequence, commutative algebra
-/
universe u v
open scoped Pointwise
variable {R S M Mâ Mâ Mâ : Type*}
namespace Ideal
variable [Semiring R] [Semiring S]
/-- The ideal generated by a list of elements. -/
abbrev ofList (rs : List R) := span { r | r â rs }
@[simp] lemma ofList_nil : (ofList [] : Ideal R) = ⥠:=
have : { r | r â [] } = â
:= Set.eq_empty_of_forall_not_mem (fun _ => List.not_mem_nil)
Eq.trans (congrArg span this) span_empty
@[simp] lemma ofList_append (rsâ rsâ : List R) :
ofList (rsâ ++ rsâ) = ofList rsâ â ofList rsâ :=
have : { r | r â rsâ ++ rsâ } = _ := Set.ext (fun _ => List.mem_append)
Eq.trans (congrArg span this) (span_union _ _)
lemma ofList_singleton (r : R) : ofList [r] = span {r} :=
congrArg span (Set.ext fun _ => List.mem_singleton)
@[simp] lemma ofList_cons (r : R) (rs : List R) :
ofList (r::rs) = span {r} â ofList rs :=
Eq.trans (ofList_append [r] rs) (congrArg (· â _) (ofList_singleton r))
@[simp] lemma map_ofList (f : R â+* S) (rs : List R) :
map f (ofList rs) = ofList (rs.map f) :=
Eq.trans (map_span f { r | r â rs }) <| congrArg span <|
Set.ext (fun _ => List.mem_map.symm)
lemma ofList_cons_smul {R} [CommSemiring R] (r : R) (rs : List R) {M}
[AddCommMonoid M] [Module R M] (N : Submodule R M) :
ofList (r :: rs) ⢠N = r ⢠N â ofList rs ⢠N := by
rw [ofList_cons, Submodule.sup_smul, Submodule.ideal_span_singleton_smul]
end Ideal
namespace Submodule
lemma smul_top_le_comap_smul_top [Semiring R] [AddCommMonoid M]
[AddCommMonoid Mâ] [Module R M] [Module R Mâ] (I : Ideal R)
(f : M ââ[R] Mâ) : I ⢠††comap f (I ⢠â€) :=
map_le_iff_le_comap.mp <| le_of_eq_of_le (map_smul'' _ _ _) <|
smul_mono_right _ le_top
variable (M) [CommRing R] [AddCommGroup M] [AddCommGroup Mâ]
[Module R M] [Module R Mâ] (r : R) (rs : List R)
/-- The equivalence between M â§ž (râ, râ, âŠ, râ)M and (M â§ž râM) â§ž (râ, âŠ, râ) (M â§ž râM). -/
def quotOfListConsSMulTopEquivQuotSMulTopInner :
(M â§ž (Ideal.ofList (r :: rs) ⢠†: Submodule R M)) ââ[R]
QuotSMulTop r M ⧞ (Ideal.ofList rs ⢠†: Submodule R (QuotSMulTop r M)) :=
quotEquivOfEq _ _ (Ideal.ofList_cons_smul r rs â€) âªâ«â
(quotientQuotientEquivQuotientSup (r ⢠â€) (Ideal.ofList rs ⢠â€)).symm âªâ«â
quotEquivOfEq _ _ (by rw [map_smul'', map_top, range_mkQ])
/-- The equivalence between M â§ž (râ, râ, âŠ, râ)M and (M â§ž (râ, âŠ, râ)) â§ž râ (M â§ž (râ, âŠ, râ)). -/
def quotOfListConsSMulTopEquivQuotSMulTopOuter :
(M â§ž (Ideal.ofList (r :: rs) ⢠†: Submodule R M)) ââ[R]
QuotSMulTop r (M ⧞ (Ideal.ofList rs ⢠†: Submodule R M)) :=
quotEquivOfEq _ _ (Eq.trans (Ideal.ofList_cons_smul r rs â€) (sup_comm _ _)) âªâ«â
(quotientQuotientEquivQuotientSup (Ideal.ofList rs ⢠â€) (r ⢠â€)).symm âªâ«â
quotEquivOfEq _ _ (by rw [map_pointwise_smul, map_top, range_mkQ])
variable {M}
lemma quotOfListConsSMulTopEquivQuotSMulTopInner_naturality (f : M ââ[R] Mâ) :
(quotOfListConsSMulTopEquivQuotSMulTopInner Mâ r rs).toLinearMap ââ
mapQ _ _ _ (smul_top_le_comap_smul_top (Ideal.ofList (r :: rs)) f) =
mapQ _ _ _ (smul_top_le_comap_smul_top _ (QuotSMulTop.map r f)) ââ
(quotOfListConsSMulTopEquivQuotSMulTopInner M r rs).toLinearMap :=
quot_hom_ext _ _ _ fun _ => rfl
lemma top_eq_ofList_cons_smul_iff :
(†: Submodule R M) = Ideal.ofList (r :: rs) ⢠†â
(†: Submodule R (QuotSMulTop r M)) = Ideal.ofList rs ⢠†:= by
conv => congr <;> rw [eq_comm, â subsingleton_quotient_iff_eq_top]
exact (quotOfListConsSMulTopEquivQuotSMulTopInner M r rs).toEquiv.subsingleton_congr
end Submodule
namespace RingTheory.Sequence
open scoped TensorProduct List
open Function Submodule QuotSMulTop
variable (S M)
section Definitions
/-
In theory, regularity of `rs : List α` on `M` makes sense as soon as
`[Monoid α]`, `[AddCommGroup M]`, and `[DistribMulAction α M]`.
Instead of `Ideal.ofList (rs.take i) ⢠(†: Submodule R M)` we use
`⚠(j : Fin i), rs[j] ⢠(†: AddSubgroup M)`.
However it's not clear that this is a useful generalization.
If we add the assumption `[SMulCommClass α α M]` this is essentially the same
as focusing on the commutative ring case, by passing to the monoid ring
`â€[abelianization of α]`.
-/
variable [CommRing R] [AddCommGroup M] [Module R M]
open Ideal
/-- A sequence `[râ, âŠ, râ]` is weakly regular on `M` iff `ráµ¢` is regular on
`Mâ§ž(râ, âŠ, ráµ¢ââ)M` for all `1 †i †n`. -/
@[mk_iff]
structure IsWeaklyRegular (rs : List R) : Prop where
regular_mod_prev : â i (h : i < rs.length),
IsSMulRegular (M ⧞ (ofList (rs.take i) ⢠†: Submodule R M)) rs[i]
lemma isWeaklyRegular_iff_Fin (rs : List R) :
IsWeaklyRegular M rs â â (i : Fin rs.length),
IsSMulRegular (M ⧞ (ofList (rs.take i) ⢠†: Submodule R M)) rs[i] :=
Iff.trans (isWeaklyRegular_iff M rs) (Iff.symm Fin.forall_iff)
/-- A weakly regular sequence `rs` on `M` is regular if also `M/rsM â 0`. -/
@[mk_iff]
structure IsRegular (rs : List R) : Prop extends IsWeaklyRegular M rs where
top_ne_smul : (†: Submodule R M) â Ideal.ofList rs ⢠â€
end Definitions
section Congr
variable {S M} [CommRing R] [CommRing S] [AddCommGroup M] [AddCommGroup Mâ]
[Module R M] [Module S Mâ]
{Ï : R â+* S} {Ï' : S â+* R} [RingHomInvPair Ï Ï'] [RingHomInvPair Ï' Ï]
open DistribMulAction AddSubgroup in
private lemma _root_.AddHom.map_smul_top_toAddSubgroup_of_surjective
{f : M â+ Mâ} {as : List R} {bs : List S} (hf : Function.Surjective f)
(h : List.Forallâ (fun r s => â x, f (r ⢠x) = s ⢠f x) as bs) :
(Ideal.ofList as ⢠†: Submodule R M).toAddSubgroup.map f =
(Ideal.ofList bs ⢠†: Submodule S Mâ).toAddSubgroup := by
induction h with
| nil =>
convert AddSubgroup.map_bot f using 1 <;>
rw [Ideal.ofList_nil, bot_smul, bot_toAddSubgroup]
| @cons r s _ _ h _ ih =>
conv => congr <;> rw [Ideal.ofList_cons, sup_smul, sup_toAddSubgroup,
ideal_span_singleton_smul, pointwise_smul_toAddSubgroup,
top_toAddSubgroup, pointwise_smul_def]
apply DFunLike.ext (f.comp (toAddMonoidEnd R M r))
((toAddMonoidEnd S Mâ s).comp f) at h
rw [AddSubgroup.map_sup, ih, map_map, h, â map_map,
map_top_of_surjective f hf]
lemma _root_.AddEquiv.isWeaklyRegular_congr {e : M â+ Mâ} {as bs}
(h : List.Forallâ (fun (r : R) (s : S) => â x, e (r ⢠x) = s ⢠e x) as bs) :
IsWeaklyRegular M as â IsWeaklyRegular Mâ bs := by
conv => congr <;> rw [isWeaklyRegular_iff_Fin]
let e' i : (M â§ž (Ideal.ofList (as.take i) ⢠†: Submodule R M)) â+
Mâ â§ž (Ideal.ofList (bs.take i) ⢠†: Submodule S Mâ) :=
QuotientAddGroup.congr _ _ e <|
AddHom.map_smul_top_toAddSubgroup_of_surjective e.surjective <|
List.forallâ_take i h
refine (finCongr h.length_eq).forall_congr @fun _ => (e' _).isSMulRegular_congr ?_
exact (mkQ_surjective _).forall.mpr fun _ => congrArg (mkQ _) (h.get _ _ _)
lemma _root_.LinearEquiv.isWeaklyRegular_congr' (e : M âââ[Ï] Mâ) (rs : List R) :
IsWeaklyRegular M rs â IsWeaklyRegular Mâ (rs.map Ï) :=
e.toAddEquiv.isWeaklyRegular_congr <| List.forallâ_map_right_iff.mpr <|
List.forallâ_same.mpr fun r _ x => e.map_smul' r x
lemma _root_.LinearEquiv.isWeaklyRegular_congr [Module R Mâ] (e : M ââ[R] Mâ) (rs : List R) :
IsWeaklyRegular M rs â IsWeaklyRegular Mâ rs :=
Iff.trans (e.isWeaklyRegular_congr' rs) <| iff_of_eq <| congrArg _ rs.map_id
lemma _root_.AddEquiv.isRegular_congr {e : M â+ Mâ} {as bs}
(h : List.Forallâ (fun (r : R) (s : S) => â x, e (r ⢠x) = s ⢠e x) as bs) :
IsRegular M as â IsRegular Mâ bs := by
conv => congr <;> rw [isRegular_iff, ne_eq, eq_comm,
â subsingleton_quotient_iff_eq_top]
let e' := QuotientAddGroup.congr _ _ e <|
AddHom.map_smul_top_toAddSubgroup_of_surjective e.surjective h
exact and_congr (e.isWeaklyRegular_congr h) e'.subsingleton_congr.not
lemma _root_.LinearEquiv.isRegular_congr' (e : M âââ[Ï] Mâ) (rs : List R) :
IsRegular M rs â IsRegular Mâ (rs.map Ï) :=
e.toAddEquiv.isRegular_congr <| List.forallâ_map_right_iff.mpr <|
List.forallâ_same.mpr fun r _ x => e.map_smul' r x
lemma _root_.LinearEquiv.isRegular_congr [Module R Mâ] (e : M ââ[R] Mâ) (rs : List R) :
IsRegular M rs â IsRegular Mâ rs :=
Iff.trans (e.isRegular_congr' rs) <| iff_of_eq <| congrArg _ rs.map_id
end Congr
lemma isWeaklyRegular_map_algebraMap_iff [CommRing R] [CommRing S]
[Algebra R S] [AddCommGroup M] [Module R M] [Module S M]
[IsScalarTower R S M] (rs : List R) :
IsWeaklyRegular M (rs.map (algebraMap R S)) â IsWeaklyRegular M rs :=
(AddEquiv.refl M).isWeaklyRegular_congr <| List.forallâ_map_left_iff.mpr <|
List.forallâ_same.mpr fun r _ => algebraMap_smul S r
variable [CommRing R] [AddCommGroup M] [AddCommGroup Mâ] [AddCommGroup Mâ]
[AddCommGroup Mâ] [Module R M] [Module R Mâ] [Module R Mâ] [Module R Mâ]
@[simp]
lemma isWeaklyRegular_cons_iff (r : R) (rs : List R) :
IsWeaklyRegular M (r :: rs) â
IsSMulRegular M r â§ IsWeaklyRegular (QuotSMulTop r M) rs :=
have := Eq.trans (congrArg (· ⢠â€) Ideal.ofList_nil) (bot_smul â€)
let e i := quotOfListConsSMulTopEquivQuotSMulTopInner M r (rs.take i)
Iff.trans (isWeaklyRegular_iff_Fin _ _) <| Iff.trans Fin.forall_iff_succ <|
and_congr ((quotEquivOfEqBot _ this).isSMulRegular_congr r) <|
Iff.trans (forall_congr' fun i => (e i).isSMulRegular_congr (rs.get i))
(isWeaklyRegular_iff_Fin _ _).symm
lemma isWeaklyRegular_cons_iff' (r : R) (rs : List R) :
IsWeaklyRegular M (r :: rs) â
IsSMulRegular M r â§
IsWeaklyRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) :=
Iff.trans (isWeaklyRegular_cons_iff M r rs) <| and_congr_right' <|
Iff.symm <| isWeaklyRegular_map_algebraMap_iff (R â§ž Ideal.span {r}) _ rs
@[simp]
lemma isRegular_cons_iff (r : R) (rs : List R) :
IsRegular M (r :: rs) â
IsSMulRegular M r â§ IsRegular (QuotSMulTop r M) rs := by
rw [isRegular_iff, isRegular_iff, isWeaklyRegular_cons_iff M r rs,
ne_eq, top_eq_ofList_cons_smul_iff, and_assoc]
lemma isRegular_cons_iff' (r : R) (rs : List R) :
IsRegular M (r :: rs) â
IsSMulRegular M r â§ IsRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) := by
conv => congr <;> rw [isRegular_iff, ne_eq]
rw [isWeaklyRegular_cons_iff', â restrictScalars_inj R (R â§ž _),
â Ideal.map_ofList, â Ideal.Quotient.algebraMap_eq, Ideal.smul_restrictScalars,
restrictScalars_top, top_eq_ofList_cons_smul_iff, and_assoc]
variable {M}
namespace IsWeaklyRegular
variable (R M) in
@[simp] lemma nil : IsWeaklyRegular M ([] : List R) :=
.mk (False.elim <| Nat.not_lt_zero · ·)
lemma cons {r : R} {rs : List R} (h1 : IsSMulRegular M r)
(h2 : IsWeaklyRegular (QuotSMulTop r M) rs) : IsWeaklyRegular M (r :: rs) :=
(isWeaklyRegular_cons_iff M r rs).mpr âšh1, h2â©
lemma cons' {r : R} {rs : List R} (h1 : IsSMulRegular M r)
(h2 : IsWeaklyRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r})))) :
IsWeaklyRegular M (r :: rs) :=
(isWeaklyRegular_cons_iff' M r rs).mpr âšh1, h2â©
/-- Weakly regular sequences can be inductively characterized by:
* The empty sequence is weakly regular on any module.
* If `r` is regular on `M` and `rs` is a weakly regular sequence on `Mâ§žrM` then
the sequence obtained from `rs` by prepending `r` is weakly regular on `M`.
This is the induction principle produced by the inductive definition above.
The motive will usually be valued in `Prop`, but `Sort*` works too. -/
@[induction_eliminator]
def recIterModByRegular
{motive : (M : Type v) â [AddCommGroup M] â [Module R M] â (rs : List R) â
IsWeaklyRegular M rs â Sort*}
(nil : (M : Type v) â [AddCommGroup M] â [Module R M] â motive M [] (nil R M))
(cons : {M : Type v} â [AddCommGroup M] â [Module R M] â (r : R) â
(rs : List R) â (h1 : IsSMulRegular M r) â
(h2 : IsWeaklyRegular (QuotSMulTop r M) rs) â
(ih : motive (QuotSMulTop r M) rs h2) â motive M (r :: rs) (cons h1 h2)) :
{M : Type v} â [AddCommGroup M] â [Module R M] â {rs : List R} â
(h : IsWeaklyRegular M rs) â motive M rs h
| M, _, _, [], _ => nil M
| M, _, _, r :: rs, h =>
let âšh1, h2â© := (isWeaklyRegular_cons_iff M r rs).mp h
cons r rs h1 h2 (recIterModByRegular nil cons h2)
/-- A simplified version of `IsWeaklyRegular.recIterModByRegular` where the
motive is not allowed to depend on the proof of `IsWeaklyRegular`. -/
def ndrecIterModByRegular
{motive : (M : Type v) â [AddCommGroup M] â [Module R M] â (rs : List R) â Sort*}
(nil : (M : Type v) â [AddCommGroup M] â [Module R M] â motive M [])
(cons : {M : Type v} â [AddCommGroup M] â [Module R M] â (r : R) â
(rs : List R) â IsSMulRegular M r â IsWeaklyRegular (QuotSMulTop r M) rs â
motive (QuotSMulTop r M) rs â motive M (r :: rs))
{M} [AddCommGroup M] [Module R M] {rs} :
IsWeaklyRegular M rs â motive M rs :=
recIterModByRegular (motive := fun M _ _ rs _ => motive M rs) nil cons
/-- An alternate induction principle from `IsWeaklyRegular.recIterModByRegular`
where we mod out by successive elements in both the module and the base ring.
This is useful for propagating certain properties of the initial `M`, e.g.
faithfulness or freeness, throughout the induction. -/
def recIterModByRegularWithRing
{motive : (R : Type u) â [CommRing R] â (M : Type v) â [AddCommGroup M] â
[Module R M] â (rs : List R) â IsWeaklyRegular M rs â Sort*}
(nil : (R : Type u) â [CommRing R] â (M : Type v) â [AddCommGroup M] â
[Module R M] â motive R M [] (nil R M))
(cons : {R : Type u} â [CommRing R] â {M : Type v} â [AddCommGroup M] â
[Module R M] â (r : R) â (rs : List R) â (h1 : IsSMulRegular M r) â
(h2 : IsWeaklyRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r})))) â
(ih : motive (R â§ž Ideal.span {r}) (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) h2) â
motive R M (r :: rs) (cons' h1 h2)) :
{R : Type u} â [CommRing R] â {M : Type v} â [AddCommGroup M] â
[Module R M] â {rs : List R} â (h : IsWeaklyRegular M rs) â motive R M rs h
| R, _, M, _, _, [], _ => nil R M
| _, _, M, _, _, r :: rs, h =>
let âšh1, h2â© := (isWeaklyRegular_cons_iff' M r rs).mp h
cons r rs h1 h2 (recIterModByRegularWithRing nil cons h2)
termination_by _ _ _ _ _ rs => List.length rs
/-- A simplified version of `IsWeaklyRegular.recIterModByRegularWithRing` where
the motive is not allowed to depend on the proof of `IsWeaklyRegular`. -/
def ndrecWithRing
{motive : (R : Type u) â [CommRing R] â (M : Type v) â
[AddCommGroup M] â [Module R M] â (rs : List R) â Sort*}
(nil : (R : Type u) â [CommRing R] â (M : Type v) â
[AddCommGroup M] â [Module R M] â motive R M [])
(cons : {R : Type u} â [CommRing R] â {M : Type v} â [AddCommGroup M] â
[Module R M] â (r : R) â (rs : List R) â IsSMulRegular M r â
IsWeaklyRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) â
motive (R â§ž Ideal.span {r}) (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) â motive R M (r :: rs))
{R} [CommRing R] {M} [AddCommGroup M] [Module R M] {rs} :
IsWeaklyRegular M rs â motive R M rs :=
recIterModByRegularWithRing (motive := fun R _ M _ _ rs _ => motive R M rs)
nil cons
end IsWeaklyRegular
section
variable (M)
lemma isWeaklyRegular_singleton_iff (r : R) :
IsWeaklyRegular M [r] â IsSMulRegular M r :=
Iff.trans (isWeaklyRegular_cons_iff M r []) (and_iff_left (.nil R _))
lemma isWeaklyRegular_append_iff (rsâ rsâ : List R) :
IsWeaklyRegular M (rsâ ++ rsâ) â
IsWeaklyRegular M rsâ â§
IsWeaklyRegular (M â§ž (Ideal.ofList rsâ ⢠†: Submodule R M)) rsâ := by
induction rsâ generalizing M with
| nil =>
refine Iff.symm <| Iff.trans (and_iff_right (.nil R M)) ?_
refine (quotEquivOfEqBot _ ?_).isWeaklyRegular_congr rsâ
rw [Ideal.ofList_nil, bot_smul]
| cons r rsâ ih =>
let e := quotOfListConsSMulTopEquivQuotSMulTopInner M r rsâ
rw [List.cons_append, isWeaklyRegular_cons_iff, isWeaklyRegular_cons_iff,
ih, â and_assoc, â e.isWeaklyRegular_congr rsâ]
lemma isWeaklyRegular_append_iff' (rsâ rsâ : List R) :
IsWeaklyRegular M (rsâ ++ rsâ) â
IsWeaklyRegular M rsâ â§
IsWeaklyRegular (M â§ž (Ideal.ofList rsâ ⢠†: Submodule R M))
(rsâ.map (Ideal.Quotient.mk (Ideal.ofList rsâ))) :=
Iff.trans (isWeaklyRegular_append_iff M rsâ rsâ) <| and_congr_right' <|
Iff.symm <| isWeaklyRegular_map_algebraMap_iff (R â§ž Ideal.ofList rsâ) _ rsâ
end
namespace IsRegular
variable (R M) in
lemma nil [Nontrivial M] : IsRegular M ([] : List R) where
toIsWeaklyRegular := IsWeaklyRegular.nil R M
top_ne_smul h := by
rw [Ideal.ofList_nil, bot_smul, eq_comm, subsingleton_iff_bot_eq_top] at h
exact not_subsingleton M ((Submodule.subsingleton_iff _).mp h)
lemma cons {r : R} {rs : List R} (h1 : IsSMulRegular M r)
(h2 : IsRegular (QuotSMulTop r M) rs) : IsRegular M (r :: rs) :=
(isRegular_cons_iff M r rs).mpr âšh1, h2â©
lemma cons' {r : R} {rs : List R} (h1 : IsSMulRegular M r)
(h2 : IsRegular (QuotSMulTop r M) (rs.map (Ideal.Quotient.mk (Ideal.span {r})))) :
IsRegular M (r :: rs) :=
(isRegular_cons_iff' M r rs).mpr âšh1, h2â©
/-- Regular sequences can be inductively characterized by:
* The empty sequence is regular on any nonzero module.
* If `r` is regular on `M` and `rs` is a regular sequence on `Mâ§žrM` then the
sequence obtained from `rs` by prepending `r` is regular on `M`.
This is the induction principle produced by the inductive definition above.
The motive will usually be valued in `Prop`, but `Sort*` works too. -/
@[induction_eliminator]
def recIterModByRegular
{motive : (M : Type v) â [AddCommGroup M] â [Module R M] â (rs : List R) â
IsRegular M rs â Sort*}
(nil : (M : Type v) â [AddCommGroup M] â [Module R M] â [Nontrivial M] â
motive M [] (nil R M))
(cons : {M : Type v} â [AddCommGroup M] â [Module R M] â (r : R) â
(rs : List R) â (h1 : IsSMulRegular M r) â (h2 : IsRegular (QuotSMulTop r M) rs) â
(ih : motive (QuotSMulTop r M) rs h2) â motive M (r :: rs) (cons h1 h2))
{M} [AddCommGroup M] [Module R M] {rs} (h : IsRegular M rs) : motive M rs h :=
h.toIsWeaklyRegular.recIterModByRegular
(motive := fun N _ _ rs' h' => â h'', motive N rs' âšh', h''â©)
(fun N _ _ h' =>
haveI := (nontrivial_iff R).mp (nontrivial_of_ne _ _ h'); nil N)
(fun r rs' h1 h2 h3 h4 =>
have âšh5, h6â© := (isRegular_cons_iff _ _ _).mp âšh2.cons h1, h4â©
cons r rs' h5 h6 (h3 h6.top_ne_smul))
h.top_ne_smul
/-- A simplified version of `IsRegular.recIterModByRegular` where the motive is
not allowed to depend on the proof of `IsRegular`. -/
def ndrecIterModByRegular
{motive : (M : Type v) â [AddCommGroup M] â [Module R M] â (rs : List R) â Sort*}
(nil : (M : Type v) â [AddCommGroup M] â [Module R M] â [Nontrivial M] â motive M [])
(cons : {M : Type v} â [AddCommGroup M] â [Module R M] â (r : R) â
(rs : List R) â IsSMulRegular M r â IsRegular (QuotSMulTop r M) rs â
motive (QuotSMulTop r M) rs â motive M (r :: rs))
{M} [AddCommGroup M] [Module R M] {rs} : IsRegular M rs â motive M rs :=
recIterModByRegular (motive := fun M _ _ rs _ => motive M rs) nil cons
/-- An alternate induction principle from `IsRegular.recIterModByRegular` where
we mod out by successive elements in both the module and the base ring. This is
useful for propagating certain properties of the initial `M`, e.g. faithfulness
or freeness, throughout the induction. -/
def recIterModByRegularWithRing
{motive : (R : Type u) â [CommRing R] â (M : Type v) â [AddCommGroup M] â
[Module R M] â (rs : List R) â IsRegular M rs â Sort*}
(nil : (R : Type u) â [CommRing R] â (M : Type v) â [AddCommGroup M] â
[Module R M] â [Nontrivial M] â motive R M [] (nil R M))
(cons : {R : Type u} â [CommRing R] â {M : Type v} â [AddCommGroup M] â
[Module R M] â (r : R) â (rs : List R) â (h1 : IsSMulRegular M r) â
(h2 : IsRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r})))) â
(ih : motive (R â§ž Ideal.span {r}) (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) h2) â
motive R M (r :: rs) (cons' h1 h2))
{R} [CommRing R] {M} [AddCommGroup M] [Module R M] {rs}
(h : IsRegular M rs) : motive R M rs h :=
h.toIsWeaklyRegular.recIterModByRegularWithRing
(motive := fun R _ N _ _ rs' h' => â h'', motive R N rs' âšh', h''â©)
(fun R _ N _ _ h' =>
haveI := (nontrivial_iff R).mp (nontrivial_of_ne _ _ h'); nil R N)
(fun r rs' h1 h2 h3 h4 =>
have âšh5, h6â© := (isRegular_cons_iff' _ _ _).mp âšh2.cons' h1, h4â©
cons r rs' h5 h6 <| h3 h6.top_ne_smul)
h.top_ne_smul
/-- A simplified version of `IsRegular.recIterModByRegularWithRing` where the
motive is not allowed to depend on the proof of `IsRegular`. -/
def ndrecIterModByRegularWithRing
{motive : (R : Type u) â [CommRing R] â (M : Type v) â
[AddCommGroup M] â [Module R M] â (rs : List R) â Sort*}
(nil : (R : Type u) â [CommRing R] â (M : Type v) â
[AddCommGroup M] â [Module R M] â [Nontrivial M] â motive R M [])
(cons : {R : Type u} â [CommRing R] â {M : Type v} â
[AddCommGroup M] â [Module R M] â (r : R) â (rs : List R) â
IsSMulRegular M r â
IsRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) â
motive (R â§ž Ideal.span {r}) (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) â
motive R M (r :: rs))
{R} [CommRing R] {M} [AddCommGroup M] [Module R M] {rs} :
IsRegular M rs â motive R M rs :=
recIterModByRegularWithRing (motive := fun R _ M _ _ rs _ => motive R M rs)
nil cons
lemma quot_ofList_smul_nontrivial {rs : List R} (h : IsRegular M rs)
(N : Submodule R M) : Nontrivial (M ⧞ Ideal.ofList rs ⢠N) :=
Submodule.Quotient.nontrivial_of_lt_top _ <|
lt_of_le_of_lt (smul_mono_right _ le_top) h.top_ne_smul.symm.lt_top
lemma nontrivial {rs : List R} (h : IsRegular M rs) : Nontrivial M :=
haveI := quot_ofList_smul_nontrivial h â€
(mkQ_surjective (Ideal.ofList rs ⢠†: Submodule R M)).nontrivial
end IsRegular
lemma isRegular_iff_isWeaklyRegular_of_subset_jacobson_annihilator
[Nontrivial M] [Module.Finite R M] {rs : List R}
(h : â r â rs, r â Ideal.jacobson (Module.annihilator R M)) :
IsRegular M rs â IsWeaklyRegular M rs :=
Iff.trans (isRegular_iff M rs) <| and_iff_left <|
top_ne_ideal_smul_of_le_jacobson_annihilator <| Ideal.span_le.mpr h
lemma _root_.IsLocalRing.isRegular_iff_isWeaklyRegular_of_subset_maximalIdeal
[IsLocalRing R] [Nontrivial M] [Module.Finite R M] {rs : List R}
(h : â r â rs, r â IsLocalRing.maximalIdeal R) :
IsRegular M rs â IsWeaklyRegular M rs :=
have H h' := bot_ne_top.symm <| annihilator_eq_top_iff.mp <|
Eq.trans annihilator_top h'
isRegular_iff_isWeaklyRegular_of_subset_jacobson_annihilator fun r hr =>
IsLocalRing.jacobson_eq_maximalIdeal (Module.annihilator R M) H âž h r hr
open IsWeaklyRegular IsArtinian in
lemma eq_nil_of_isRegular_on_artinian [IsArtinian R M] :
{rs : List R} â IsRegular M rs â rs = []
| [], _ => rfl
| r :: rs, h => by
rw [isRegular_iff, ne_comm, â lt_top_iff_ne_top, Ideal.ofList_cons,
sup_smul, ideal_span_singleton_smul, isWeaklyRegular_cons_iff] at h
refine absurd ?_ (ne_of_lt (lt_of_le_of_lt le_sup_left h.right))
exact Eq.trans (Submodule.map_top _) <| LinearMap.range_eq_top.mpr <|
surjective_of_injective_endomorphism (LinearMap.lsmul R M r) h.left.left
lemma IsWeaklyRegular.isWeaklyRegular_lTensor [Module.Flat R Mâ]
{rs : List R} (h : IsWeaklyRegular M rs) :
IsWeaklyRegular (Mâ â[R] M) rs := by
induction h with
| nil N => exact nil R (Mâ â[R] N)
| @cons N _ _ r rs' h1 _ ih =>
let e := tensorQuotSMulTopEquivQuotSMulTop r Mâ N
exact ((e.isWeaklyRegular_congr rs').mp ih).cons (h1.lTensor Mâ)
lemma IsWeaklyRegular.isWeaklyRegular_rTensor [Module.Flat R Mâ]
{rs : List R} (h : IsWeaklyRegular M rs) :
IsWeaklyRegular (M â[R] Mâ) rs := by
induction h with
| nil N => exact nil R (N â[R] Mâ)
| @cons N _ _ r rs' h1 _ ih =>
let e := quotSMulTopTensorEquivQuotSMulTop r Mâ N
exact ((e.isWeaklyRegular_congr rs').mp ih).cons (h1.rTensor Mâ)
-- TODO: apply the above to localization and completion (Corollary 1.1.3 in B&H)
lemma map_first_exact_on_four_term_right_exact_of_isSMulRegular_last
{rs : List R} {fâ : M ââ[R] Mâ} {fâ : Mâ ââ[R] Mâ} {fâ : Mâ ââ[R] Mâ}
(hââ : Exact fâ fâ) (hââ : Exact fâ fâ) (hâ : Surjective fâ)
(hâ : IsWeaklyRegular Mâ rs) :
Exact (mapQ _ _ _ (smul_top_le_comap_smul_top (Ideal.ofList rs) fâ))
(mapQ _ _ _ (smul_top_le_comap_smul_top (Ideal.ofList rs) fâ)) := by
induction hâ generalizing M Mâ Mâ with
| nil =>
apply (Exact.iff_of_ladder_linearEquiv ?_ ?_).mp hââ
any_goals exact quotEquivOfEqBot _ <|
Eq.trans (congrArg (· ⢠â€) Ideal.ofList_nil) (bot_smul â€)
all_goals exact quot_hom_ext _ _ _ fun _ => rfl
| cons r rs hâ _ ih =>
specialize ih
(map_first_exact_on_four_term_exact_of_isSMulRegular_last hââ hââ hâ)
(map_exact r hââ hâ) (map_surjective r hâ)
have Hâ := quotOfListConsSMulTopEquivQuotSMulTopInner_naturality r rs fâ
have Hâ := quotOfListConsSMulTopEquivQuotSMulTopInner_naturality r rs fâ
exact (Exact.iff_of_ladder_linearEquiv Hâ.symm Hâ.symm).mp ih
-- todo: modding out a complex by a regular sequence (prop 1.1.5 in B&H)
section Perm
open LinearMap in
private lemma IsWeaklyRegular.swap {a b : R} (h1 : IsWeaklyRegular M [a, b])
(h2 : torsionBy R M b = a ⢠torsionBy R M b â torsionBy R M b = â¥) :
IsWeaklyRegular M [b, a] := by
rw [isWeaklyRegular_cons_iff, isWeaklyRegular_singleton_iff] at h1 â¢
obtain âšha, hbâ© := h1
rw [â isSMulRegular_iff_torsionBy_eq_bot] at h2
specialize h2 (le_antisymm ?_ (smul_le_self_of_tower a (torsionBy R M b)))
· refine le_of_eq_of_le ?_ <| smul_top_inf_eq_smul_of_isSMulRegular_on_quot <|
ha.of_injective _ <| ker_eq_bot.mp <| ker_liftQ_eq_bot' _ (lsmul R M b) rfl
rw [â (isSMulRegular_on_quot_iff_lsmul_comap_eq _ _).mp hb]
exact (inf_eq_right.mpr (ker_le_comap _)).symm
· rwa [ha.isSMulRegular_on_quot_iff_smul_top_inf_eq_smul, inf_comm, smul_comm,
â h2.isSMulRegular_on_quot_iff_smul_top_inf_eq_smul, and_iff_left hb]
-- TODO: Equivalence of permutability of regular sequences to regularity of
-- subsequences and regularity on poly ring. See [07DW] in stacks project
-- We need a theory of multivariate polynomial modules first
-- This is needed due to a bug in the linter
set_option linter.unusedVariables false in
lemma IsWeaklyRegular.prototype_perm {rs : List R} (h : IsWeaklyRegular M rs)
{rs'} (h'' : rs ~ rs') (h' : â a b rs', (a :: b :: rs') <+~ rs â
let K := torsionBy R (M ⧞ (Ideal.ofList rs' ⢠†: Submodule R M)) b
K = a ⢠K â K = â¥) : IsWeaklyRegular M rs' :=
have H := LinearEquiv.isWeaklyRegular_congr <| quotEquivOfEqBot _ <|
Eq.trans (congrArg (· ⢠â€) Ideal.ofList_nil) (bot_smul â€)
(H rs').mp <| (aux [] h'' (.refl rs) (h''.symm.subperm)) <| (H rs).mpr h
where aux {rsâ rsâ} (rsâ : List R)
(hââ : rsâ ~ rsâ) (Hâ : rsâ ++ rsâ <+~ rs) (Hâ : rsâ ++ rsâ <+~ rs)
(h : IsWeaklyRegular (M â§ž (Ideal.ofList rsâ ⢠†: Submodule R M)) rsâ) :
IsWeaklyRegular (M â§ž (Ideal.ofList rsâ ⢠†: Submodule R M)) rsâ := by {
induction hââ generalizing rsâ with
| nil => exact .nil R _
| cons r _ ih =>
let e := quotOfListConsSMulTopEquivQuotSMulTopOuter M r rsâ
rw [isWeaklyRegular_cons_iff, â e.isWeaklyRegular_congr] at h â¢
refine h.imp_right (ih (r :: rsâ) ?_ ?_) <;>
exact List.perm_middle.subperm_right.mp â¹_âº
| swap a b t =>
rw [show â x y z, x :: y :: z = [x, y] ++ z from fun _ _ _ => rfl,
isWeaklyRegular_append_iff] at h â¢
have : Ideal.ofList [b, a] = Ideal.ofList [a, b] :=
congrArg Ideal.span <| Set.ext fun _ => (List.Perm.swap a b []).mem_iff
rw [(quotEquivOfEq _ _ (congrArgâ _ this rfl)).isWeaklyRegular_congr] at h
rw [List.append_cons, List.append_cons, List.append_assoc _ [b] [a]] at Hâ
apply (List.sublist_append_left (rsâ ++ [b, a]) _).subperm.trans at Hâ
apply List.perm_append_comm.subperm.trans at Hâ
exact h.imp_left (swap · (h' b a rsâ Hâ))
| trans hââ _ ihââ ihââ =>
have Hâ := (hââ.append_left rsâ).subperm_right.mp Hâ
exact ihââ rsâ Hâ Hâ (ihââ rsâ Hâ Hâ h) }
-- putting `{rs' : List R}` and `h2` after `h3` would be better for partial
-- application, but this argument order seems nicer overall
lemma IsWeaklyRegular.of_perm_of_subset_jacobson_annihilator [IsNoetherian R M]
{rs rs' : List R} (h1 : IsWeaklyRegular M rs) (h2 : List.Perm rs rs')
(h3 : â r â rs, r â (Module.annihilator R M).jacobson) :
IsWeaklyRegular M rs' :=
h1.prototype_perm h2 fun r _ _ h h' =>
eq_bot_of_eq_pointwise_smul_of_mem_jacobson_annihilator
(IsNoetherian.noetherian _) h'
(Ideal.jacobson_mono
(le_trans
-- The named argument `(R := R)` below isn't necessary, but
-- typechecking is much slower without it
(LinearMap.annihilator_le_of_surjective (R := R) _ (mkQ_surjective _))
(LinearMap.annihilator_le_of_injective _ (injective_subtype _)))
(h3 r (h.subset List.mem_cons_self)))
end Perm
lemma IsRegular.of_perm_of_subset_jacobson_annihilator [IsNoetherian R M]
{rs rs' : List R} (h1 : IsRegular M rs) (h2 : List.Perm rs rs')
(h3 : â r â rs, r â (Module.annihilator R M).jacobson) : IsRegular M rs' :=
âšh1.toIsWeaklyRegular.of_perm_of_subset_jacobson_annihilator h2 h3,
letI := h1.nontrivial
top_ne_ideal_smul_of_le_jacobson_annihilator <|
Ideal.span_le.mpr (h3 · <| h2.mem_iff.mpr ·)â©
lemma _root_.IsLocalRing.isWeaklyRegular_of_perm_of_subset_maximalIdeal
[IsLocalRing R] [IsNoetherian R M] {rs rs' : List R}
(h1 : IsWeaklyRegular M rs) (h2 : List.Perm rs rs')
| (h3 : â r â rs, r â IsLocalRing.maximalIdeal R) : IsWeaklyRegular M rs' :=
IsWeaklyRegular.of_perm_of_subset_jacobson_annihilator h1 h2 fun r hr =>
IsLocalRing.maximalIdeal_le_jacobson _ (h3 r hr)
lemma _root_.IsLocalRing.isRegular_of_perm [IsLocalRing R] [IsNoetherian R M]
{rs rs' : List R} (h1 : IsRegular M rs) (h2 : List.Perm rs rs') :
IsRegular M rs' := by
obtain âšh3, h4â© := h1
refine âšIsLocalRing.isWeaklyRegular_of_perm_of_subset_maximalIdeal h3 h2 ?_, ?_â©
· intro x (h6 : x â { r | r â rs })
| Mathlib/RingTheory/Regular/RegularSequence.lean | 661 | 670 |
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.Lie.Ideal
/-!
# Ideal operations for Lie algebras
Given a Lie module `M` over a Lie algebra `L`, there is a natural action of the Lie ideals of `L`
on the Lie submodules of `M`. In the special case that `M = L` with the adjoint action, this
provides a pairing of Lie ideals which is especially important. For example, it can be used to
define solvability / nilpotency of a Lie algebra via the derived / lower-central series.
## Main definitions
* `LieSubmodule.hasBracket`
* `LieSubmodule.lieIdeal_oper_eq_linear_span`
* `LieIdeal.map_bracket_le`
* `LieIdeal.comap_bracket_le`
## Notation
Given a Lie module `M` over a Lie algebra `L`, together with a Lie submodule `N â M` and a Lie
ideal `I â L`, we introduce the notation `â
I, Nâ` for the Lie submodule of `M` corresponding to
the action defined in this file.
## Tags
lie algebra, ideal operation
-/
universe u v w wâ wâ
namespace LieSubmodule
variable {R : Type u} {L : Type v} {M : Type w} {Mâ : Type wâ}
variable [CommRing R] [LieRing L]
variable [AddCommGroup M] [Module R M] [LieRingModule L M]
variable [AddCommGroup Mâ] [Module R Mâ] [LieRingModule L Mâ]
variable (N N' : LieSubmodule R L M) (Nâ : LieSubmodule R L Mâ)
variable (f : M âââ
R,Lâ Mâ)
section LieIdealOperations
theorem map_comap_le : map f (comap f Nâ) †Nâ :=
(Nâ : Set Mâ).image_preimage_subset f
theorem map_comap_eq (hf : Nâ †f.range) : map f (comap f Nâ) = Nâ := by
rw [SetLike.ext'_iff]
exact Set.image_preimage_eq_of_subset hf
theorem le_comap_map : N †comap f (map f N) :=
(N : Set M).subset_preimage_image f
theorem comap_map_eq (hf : f.ker = â¥) : comap f (map f N) = N := by
rw [SetLike.ext'_iff]
exact (N : Set M).preimage_image_eq (f.ker_eq_bot.mp hf)
@[simp]
theorem map_comap_incl : map N.incl (comap N.incl N') = N â N' := by
rw [â toSubmodule_inj]
exact (N : Submodule R M).map_comap_subtype N'
variable [LieAlgebra R L] [LieModule R L Mâ] (I J : LieIdeal R L)
/-- Given a Lie module `M` over a Lie algebra `L`, the set of Lie ideals of `L` acts on the set
of submodules of `M`. -/
instance hasBracket : Bracket (LieIdeal R L) (LieSubmodule R L M) :=
âšfun I N => lieSpan R L { â
(x : L), (n : M)â | (x : I) (n : N) }â©
theorem lieIdeal_oper_eq_span :
â
I, Nâ = lieSpan R L { â
(x : L), (n : M)â | (x : I) (n : N) } :=
rfl
/-- See also `LieSubmodule.lieIdeal_oper_eq_linear_span'` and
`LieSubmodule.lieIdeal_oper_eq_tensor_map_range`. -/
theorem lieIdeal_oper_eq_linear_span [LieModule R L M] :
(ââ
I, Nâ : Submodule R M) = Submodule.span R { â
(x : L), (n : M)â | (x : I) (n : N) } := by
apply le_antisymm
· let s := { â
(x : L), (n : M)â | (x : I) (n : N) }
have aux : â (y : L), â m' â Submodule.span R s, â
y, m'â â Submodule.span R s := by
intro y m' hm'
refine Submodule.span_induction (R := R) (M := M) (s := s)
(p := fun m' _ ⊠â
y, m'â â Submodule.span R s) ?_ ?_ ?_ ?_ hm'
· rintro m'' âšx, n, hm''â©; rw [â hm'', leibniz_lie]
refine Submodule.add_mem _ ?_ ?_ <;> apply Submodule.subset_span
· use âšâ
y, âxâ, I.lie_mem x.propertyâ©, n
· use x, âšâ
y, ânâ, N.lie_mem n.propertyâ©
· simp only [lie_zero, Submodule.zero_mem]
· intro mâ mâ _ _ hmâ hmâ; rw [lie_add]; exact Submodule.add_mem _ hmâ hmâ
· intro t m'' _ hm''; rw [lie_smul]; exact Submodule.smul_mem _ t hm''
change _ †({ Submodule.span R s with lie_mem := fun hm' => aux _ _ hm' } : LieSubmodule R L M)
rw [lieIdeal_oper_eq_span, lieSpan_le]
exact Submodule.subset_span
· rw [lieIdeal_oper_eq_span]; apply submodule_span_le_lieSpan
theorem lieIdeal_oper_eq_linear_span' [LieModule R L M] :
(ââ
I, Nâ : Submodule R M) = Submodule.span R { â
x, nâ | (x â I) (n â N) } := by
rw [lieIdeal_oper_eq_linear_span]
congr
ext m
constructor
· rintro âšâšx, hxâ©, âšn, hnâ©, rflâ©
exact âšx, hx, n, hn, rflâ©
· rintro âšx, hx, n, hn, rflâ©
exact âšâšx, hxâ©, âšn, hnâ©, rflâ©
theorem lie_le_iff : â
I, Nâ †N' â â x â I, â m â N, â
x, mâ â N' := by
rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le]
refine âšfun h x hx m hm => h âšâšx, hxâ©, âšm, hmâ©, rflâ©, ?_â©
rintro h _ âšâšx, hxâ©, âšm, hmâ©, rflâ©
exact h x hx m hm
variable {N I} in
theorem lie_coe_mem_lie (x : I) (m : N) : â
(x : L), (m : M)â â â
I, Nâ := by
rw [lieIdeal_oper_eq_span]; apply subset_lieSpan; use x, m
variable {N I} in
theorem lie_mem_lie {x : L} {m : M} (hx : x â I) (hm : m â N) : â
x, mâ â â
I, Nâ :=
lie_coe_mem_lie âšx, hxâ© âšm, hmâ©
theorem lie_comm : â
I, Jâ = â
J, Iâ := by
suffices â I J : LieIdeal R L, â
I, Jâ †â
J, Iâ by exact le_antisymm (this I J) (this J I)
| clear! I J; intro I J
| Mathlib/Algebra/Lie/IdealOperations.lean | 127 | 127 |
/-
Copyright (c) 2023 Chris Birkbeck. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Birkbeck, Ruben Van de Velde
-/
import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Shift
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
/-!
# One-dimensional iterated derivatives
This file contains a number of further results on `iteratedDerivWithin` that need more imports
than are available in `Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean`.
-/
section one_dimensional
variable
{ð : Type*} [NontriviallyNormedField ð]
{F : Type*} [NormedAddCommGroup F] [NormedSpace ð F]
{R : Type*} [Semiring R] [Module R F] [SMulCommClass ð R F] [ContinuousConstSMul R F]
{n : â} {x : ð} {s : Set ð} (hx : x â s) (h : UniqueDiffOn ð s) {f g : ð â F}
section
theorem iteratedDerivWithin_congr (hfg : Set.EqOn f g s) :
Set.EqOn (iteratedDerivWithin n f s) (iteratedDerivWithin n g s) s := by
induction n generalizing f g with
| zero => rwa [iteratedDerivWithin_zero]
| succ n IH =>
intro y hy
rw [iteratedDerivWithin_succ, iteratedDerivWithin_succ]
exact derivWithin_congr (IH hfg) (IH hfg hy)
include h hx in
theorem iteratedDerivWithin_add
(hf : ContDiffWithinAt ð n f s x) (hg : ContDiffWithinAt ð n g s x) :
iteratedDerivWithin n (f + g) s x =
iteratedDerivWithin n f s x + iteratedDerivWithin n g s x := by
simp_rw [iteratedDerivWithin, iteratedFDerivWithin_add_apply hf hg h hx,
ContinuousMultilinearMap.add_apply]
theorem iteratedDerivWithin_const_add (hn : 0 < n) (c : F) :
iteratedDerivWithin n (fun z => c + f z) s x = iteratedDerivWithin n f s x := by
obtain âšn, rflâ© := n.exists_eq_succ_of_ne_zero hn.ne'
rw [iteratedDerivWithin_succ', iteratedDerivWithin_succ']
congr with y
exact derivWithin_const_add _
theorem iteratedDerivWithin_const_sub (hn : 0 < n) (c : F) :
iteratedDerivWithin n (fun z => c - f z) s x = iteratedDerivWithin n (fun z => -f z) s x := by
obtain âšn, rflâ© := n.exists_eq_succ_of_ne_zero hn.ne'
rw [iteratedDerivWithin_succ', iteratedDerivWithin_succ']
congr with y
rw [derivWithin.neg]
exact derivWithin_const_sub _
@[deprecated (since := "2024-12-10")]
alias iteratedDerivWithin_const_neg := iteratedDerivWithin_const_sub
include h hx in
theorem iteratedDerivWithin_const_smul (c : R) (hf : ContDiffWithinAt ð n f s x) :
iteratedDerivWithin n (c ⢠f) s x = c ⢠iteratedDerivWithin n f s x := by
simp_rw [iteratedDerivWithin]
rw [iteratedFDerivWithin_const_smul_apply hf h hx]
simp only [ContinuousMultilinearMap.smul_apply]
include h hx in
theorem iteratedDerivWithin_const_mul (c : ð) {f : ð â ð} (hf : ContDiffWithinAt ð n f s x) :
iteratedDerivWithin n (fun z => c * f z) s x = c * iteratedDerivWithin n f s x := by
simpa using iteratedDerivWithin_const_smul (F := ð) hx h c hf
variable (f) in
omit h hx in
theorem iteratedDerivWithin_neg :
iteratedDerivWithin n (-f) s x = -iteratedDerivWithin n f s x := by
induction n generalizing x with
| zero => simp
| succ n IH =>
simp only [iteratedDerivWithin_succ, derivWithin_neg]
rw [â derivWithin.neg]
congr with y
exact IH
variable (f) in
theorem iteratedDerivWithin_neg' :
iteratedDerivWithin n (fun z => -f z) s x = -iteratedDerivWithin n f s x :=
iteratedDerivWithin_neg f
include h hx
theorem iteratedDerivWithin_sub
(hf : ContDiffWithinAt ð n f s x) (hg : ContDiffWithinAt ð n g s x) :
iteratedDerivWithin n (f - g) s x =
iteratedDerivWithin n f s x - iteratedDerivWithin n g s x := by
rw [sub_eq_add_neg, sub_eq_add_neg, Pi.neg_def, iteratedDerivWithin_add hx h hf hg.neg,
iteratedDerivWithin_neg']
theorem iteratedDerivWithin_comp_const_smul (hf : ContDiffOn ð n f s) (c : ð)
| (hs : Set.MapsTo (c * ·) s s) :
iteratedDerivWithin n (fun x => f (c * x)) s x = c ^ n ⢠iteratedDerivWithin n f s (c * x) := by
induction n generalizing x with
| Mathlib/Analysis/Calculus/IteratedDeriv/Lemmas.lean | 102 | 104 |
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.RingTheory.IsTensorProduct
/-!
# Base change of polynomial algebras
Given `[CommSemiring R] [Semiring A] [Algebra R A]` we show `A[X] ââ[R] (A â[R] R[X])`.
-/
-- This file should not become entangled with `RingTheory/MatrixAlgebra`.
assert_not_exists Matrix
universe u v w
open Polynomial TensorProduct
open Algebra.TensorProduct (algHomOfLinearMapTensorProduct includeLeft)
noncomputable section
variable (R A : Type*)
variable [CommSemiring R]
variable [Semiring A] [Algebra R A]
namespace PolyEquivTensor
/-- (Implementation detail).
The function underlying `A â[R] R[X] ââ[R] A[X]`,
as a bilinear function of two arguments.
-/
def toFunBilinear : A ââ[A] R[X] ââ[R] A[X] :=
LinearMap.toSpanSingleton A _ (aeval (Polynomial.X : A[X])).toLinearMap
theorem toFunBilinear_apply_apply (a : A) (p : R[X]) :
toFunBilinear R A a p = a ⢠(aeval X) p := rfl
@[simp] theorem toFunBilinear_apply_eq_smul (a : A) (p : R[X]) :
toFunBilinear R A a p = a ⢠p.map (algebraMap R A) := rfl
theorem toFunBilinear_apply_eq_sum (a : A) (p : R[X]) :
toFunBilinear R A a p = p.sum fun n r ⊠monomial n (a * algebraMap R A r) := by
conv_lhs => rw [toFunBilinear_apply_eq_smul, â p.sum_monomial_eq, sum, Polynomial.map_sum]
simp [Finset.smul_sum, sum, â smul_eq_mul]
/-- (Implementation detail).
The function underlying `A â[R] R[X] ââ[R] A[X]`,
as a linear map.
-/
def toFunLinear : A â[R] R[X] ââ[R] A[X] :=
TensorProduct.lift (toFunBilinear R A)
@[simp]
theorem toFunLinear_tmul_apply (a : A) (p : R[X]) :
toFunLinear R A (a ââ[R] p) = toFunBilinear R A a p :=
rfl
-- We apparently need to provide the decidable instance here
-- in order to successfully rewrite by this lemma.
theorem toFunLinear_mul_tmul_mul_aux_1 (p : R[X]) (k : â) (h : Decidable ¬p.coeff k = 0) (a : A) :
ite (¬coeff p k = 0) (a * (algebraMap R A) (coeff p k)) 0 =
a * (algebraMap R A) (coeff p k) := by classical split_ifs <;> simp [*]
theorem toFunLinear_mul_tmul_mul_aux_2 (k : â) (aâ aâ : A) (pâ pâ : R[X]) :
aâ * aâ * (algebraMap R A) ((pâ * pâ).coeff k) =
(Finset.antidiagonal k).sum fun x =>
aâ * (algebraMap R A) (coeff pâ x.1) * (aâ * (algebraMap R A) (coeff pâ x.2)) := by
simp_rw [mul_assoc, Algebra.commutes, â Finset.mul_sum, mul_assoc, â Finset.mul_sum]
congr
simp_rw [Algebra.commutes (coeff pâ _), coeff_mul, map_sum, RingHom.map_mul]
theorem toFunLinear_mul_tmul_mul (aâ aâ : A) (pâ pâ : R[X]) :
(toFunLinear R A) ((aâ * aâ) ââ[R] (pâ * pâ)) =
(toFunLinear R A) (aâ ââ[R] pâ) * (toFunLinear R A) (aâ ââ[R] pâ) := by
classical
simp only [toFunLinear_tmul_apply, toFunBilinear_apply_eq_sum]
ext k
simp_rw [coeff_sum, coeff_monomial, sum_def, Finset.sum_ite_eq', mem_support_iff, Ne]
conv_rhs => rw [coeff_mul]
simp_rw [finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', mem_support_iff, Ne, mul_ite,
mul_zero, ite_mul, zero_mul]
simp_rw [â ite_zero_mul (¬coeff pâ _ = 0) (aâ * (algebraMap R A) (coeff pâ _))]
simp_rw [â mul_ite_zero (¬coeff pâ _ = 0) _ (_ * _)]
simp_rw [toFunLinear_mul_tmul_mul_aux_1, toFunLinear_mul_tmul_mul_aux_2]
theorem toFunLinear_one_tmul_one :
toFunLinear R A (1 ââ[R] 1) = 1 := by
rw [toFunLinear_tmul_apply, toFunBilinear_apply_apply, Polynomial.aeval_one, one_smul]
/-- (Implementation detail).
The algebra homomorphism `A â[R] R[X] ââ[R] A[X]`.
-/
def toFunAlgHom : A â[R] R[X] ââ[R] A[X] :=
algHomOfLinearMapTensorProduct (toFunLinear R A) (toFunLinear_mul_tmul_mul R A)
(toFunLinear_one_tmul_one R A)
@[simp] theorem toFunAlgHom_apply_tmul_eq_smul (a : A) (p : R[X]) :
toFunAlgHom R A (a ââ[R] p) = a ⢠p.map (algebraMap R A) := rfl
theorem toFunAlgHom_apply_tmul (a : A) (p : R[X]) :
toFunAlgHom R A (a ââ[R] p) = p.sum fun n r => monomial n (a * (algebraMap R A) r) :=
toFunBilinear_apply_eq_sum R A _ _
/-- (Implementation detail.)
The bare function `A[X] â A â[R] R[X]`.
(We don't need to show that it's an algebra map, thankfully --- just that it's an inverse.)
-/
def invFun (p : A[X]) : A â[R] R[X] :=
p.evalâ (includeLeft : A ââ[R] A â[R] R[X]) ((1 : A) ââ[R] (X : R[X]))
@[simp]
theorem invFun_add {p q} : invFun R A (p + q) = invFun R A p + invFun R A q := by
simp only [invFun, evalâ_add]
theorem invFun_monomial (n : â) (a : A) :
invFun R A (monomial n a) = (a ââ[R] 1) * 1 ââ[R] X ^ n :=
evalâ_monomial _ _
theorem left_inv (x : A â R[X]) : invFun R A ((toFunAlgHom R A) x) = x := by
refine TensorProduct.induction_on x ?_ ?_ ?_
· simp [invFun]
· intro a p
dsimp only [invFun]
rw [toFunAlgHom_apply_tmul, evalâ_sum]
simp_rw [evalâ_monomial, AlgHom.coe_toRingHom, Algebra.TensorProduct.tmul_pow, one_pow,
Algebra.TensorProduct.includeLeft_apply, Algebra.TensorProduct.tmul_mul_tmul, mul_one,
one_mul, â Algebra.commutes, â Algebra.smul_def, smul_tmul, sum_def, â tmul_sum]
conv_rhs => rw [â sum_C_mul_X_pow_eq p]
simp only [Algebra.smul_def]
rfl
· intro p q hp hq
simp only [map_add, invFun_add, hp, hq]
theorem right_inv (x : A[X]) : (toFunAlgHom R A) (invFun R A x) = x := by
refine Polynomial.induction_on' x ?_ ?_
· intro p q hp hq
simp only [invFun_add, map_add, hp, hq]
· intro n a
rw [invFun_monomial, Algebra.TensorProduct.tmul_pow,
one_pow, Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul, toFunAlgHom_apply_tmul,
X_pow_eq_monomial, sum_monomial_index] <;>
simp
/-- (Implementation detail)
The equivalence, ignoring the algebra structure, `(A â[R] R[X]) â A[X]`.
-/
def equiv : A â[R] R[X] â A[X] where
toFun := toFunAlgHom R A
invFun := invFun R A
left_inv := left_inv R A
right_inv := right_inv R A
end PolyEquivTensor
open PolyEquivTensor
/-- The `R`-algebra isomorphism `A[X] ââ[R] (A â[R] R[X])`.
-/
def polyEquivTensor : A[X] ââ[R] A â[R] R[X] :=
AlgEquiv.symm { PolyEquivTensor.toFunAlgHom R A, PolyEquivTensor.equiv R A with }
@[simp]
theorem polyEquivTensor_apply (p : A[X]) :
polyEquivTensor R A p =
p.evalâ (includeLeft : A ââ[R] A â[R] R[X]) ((1 : A) ââ[R] (X : R[X])) :=
rfl
@[simp]
theorem polyEquivTensor_symm_apply_tmul_eq_smul (a : A) (p : R[X]) :
(polyEquivTensor R A).symm (a ââ p) = a ⢠p.map (algebraMap R A) := rfl
theorem polyEquivTensor_symm_apply_tmul (a : A) (p : R[X]) :
(polyEquivTensor R A).symm (a ââ p) = p.sum fun n r => monomial n (a * algebraMap R A r) :=
toFunAlgHom_apply_tmul _ _ _ _
section
variable (A : Type*) [CommSemiring A] [Algebra R A]
/-- The `A`-algebra isomorphism `A[X] ââ[A] A â[R] R[X]` (when `A` is commutative). -/
def polyEquivTensor' : A[X] ââ[A] A â[R] R[X] where
__ := polyEquivTensor R A
commutes' a := by simp
/-- `polyEquivTensor' R A` is the same as `polyEquivTensor R A` as a function. -/
@[simp] theorem coe_polyEquivTensor' : â(polyEquivTensor' R A) = polyEquivTensor R A := rfl
@[simp] theorem coe_polyEquivTensor'_symm :
â(polyEquivTensor' R A).symm = (polyEquivTensor R A).symm := rfl
end
/-- If `A` is an `R`-algebra, then `A[X]` is an `R[X]` algebra.
This gives a diamond for `Algebra R[X] R[X][X]`, so this is not a global instance. -/
@[reducible] def Polynomial.algebra : Algebra R[X] A[X] :=
(mapRingHom (algebraMap R A)).toAlgebra' fun _ _ ⊠by
ext; rw [coeff_mul, â Finset.Nat.sum_antidiagonal_swap, coeff_mul]; simp [Algebra.commutes]
attribute [local instance] Polynomial.algebra
@[simp]
theorem Polynomial.algebraMap_def : algebraMap R[X] A[X] = mapRingHom (algebraMap R A) := rfl
instance : IsScalarTower R R[X] A[X] := .of_algebraMap_eq' (mapRingHom_comp_C _).symm
instance [FaithfulSMul R A] : FaithfulSMul R[X] A[X] :=
(faithfulSMul_iff_algebraMap_injective ..).mpr
(map_injective _ <| FaithfulSMul.algebraMap_injective ..)
variable {S : Type*} [CommSemiring S] [Algebra R S]
instance : Algebra.IsPushout R S R[X] S[X] where
out := .of_equiv (polyEquivTensor' R S).symm fun _ âŠ
(polyEquivTensor_symm_apply_tmul_eq_smul ..).trans <| one_smul ..
instance : Algebra.IsPushout R R[X] S S[X] := .symm inferInstance
| Mathlib/RingTheory/PolynomialAlgebra.lean | 307 | 314 | |
/-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Group.PUnit
import Mathlib.Algebra.Group.Subgroup.Ker
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.GroupTheory.Congruence.Basic
/-!
# Coproduct (free product) of two monoids or groups
In this file we define `Monoid.Coprod M N` (notation: `M â N`)
to be the coproduct (a.k.a. free product) of two monoids.
The same type is used for the coproduct of two monoids and for the coproduct of two groups.
The coproduct `M â N` has the following universal property:
for any monoid `P` and homomorphisms `f : M â* P`, `g : N â* P`,
there exists a unique homomorphism `fg : M â N â* P`
such that `fg â Monoid.Coprod.inl = f` and `fg â Monoid.Coprod.inr = g`,
where `Monoid.Coprod.inl : M â* M â N`
and `Monoid.Coprod.inr : N â* M â N` are canonical embeddings.
This homomorphism `fg` is given by `Monoid.Coprod.lift f g`.
We also define some homomorphisms and isomorphisms about `M â N`,
and provide additive versions of all definitions and theorems.
## Main definitions
### Types
* `Monoid.Coprod M N` (a.k.a. `M â N`):
the free product (a.k.a. coproduct) of two monoids `M` and `N`.
* `AddMonoid.Coprod M N` (no notation): the additive version of `Monoid.Coprod`.
In other sections, we only list multiplicative definitions.
### Instances
* `MulOneClass`, `Monoid`, and `Group` structures on the coproduct `M â N`.
### Monoid homomorphisms
* `Monoid.Coprod.mk`: the projection `FreeMonoid (M â N) â* M â N`.
* `Monoid.Coprod.inl`, `Monoid.Coprod.inr`: canonical embeddings `M â* M â N` and `N â* M â N`.
* `Monoid.Coprod.lift`: construct a monoid homomorphism `M â N â* P`
from homomorphisms `M â* P` and `N â* P`; see also `Monoid.Coprod.liftEquiv`.
* `Monoid.Coprod.clift`: a constructor for homomorphisms `M â N â* P`
that allows the user to control the computational behavior.
* `Monoid.Coprod.map`: combine two homomorphisms `f : M â* N` and `g : M' â* N'`
into `M â M' â* N â N'`.
* `Monoid.Coprod.swap`: the natural homomorphism `M â N â* N â M`.
* `Monoid.Coprod.fst`, `Monoid.Coprod.snd`, and `Monoid.Coprod.toProd`:
natural projections `M â N â* M`, `M â N â* N`, and `M â N â* M Ã N`.
### Monoid isomorphisms
* `MulEquiv.coprodCongr`: a `MulEquiv` version of `Monoid.Coprod.map`.
* `MulEquiv.coprodComm`: a `MulEquiv` version of `Monoid.Coprod.swap`.
* `MulEquiv.coprodAssoc`: associativity of the coproduct.
* `MulEquiv.coprodPUnit`, `MulEquiv.punitCoprod`:
free product by `PUnit` on the left or on the right is isomorphic to the original monoid.
## Main results
The universal property of the coproduct
is given by the definition `Monoid.Coprod.lift` and the lemma `Monoid.Coprod.lift_unique`.
We also prove a slightly more general extensionality lemma `Monoid.Coprod.hom_ext`
for homomorphisms `M â N â* P` and prove lots of basic lemmas like `Monoid.Coprod.fst_comp_inl`.
## Implementation details
The definition of the coproduct of an indexed family of monoids is formalized in `Monoid.CoprodI`.
While mathematically `M â N` is a particular case
of the coproduct of an indexed family of monoids,
it is easier to build API from scratch instead of using something like
```
def Monoid.Coprod M N := Monoid.CoprodI ![M, N]
```
or
```
def Monoid.Coprod M N := Monoid.CoprodI (fun b : Bool => cond b M N)
```
There are several reasons to build an API from scratch.
- API about `Con` makes it easy to define the required type and prove the universal property,
so there is little overhead compared to transferring API from `Monoid.CoprodI`.
- If `M` and `N` live in different universes, then the definition has to add `ULift`s;
this makes it harder to transfer API and definitions.
- As of now, we have no way
to automatically build an instance of `(k : Fin 2) â Monoid (![M, N] k)`
from `[Monoid M]` and `[Monoid N]`,
not even speaking about more advanced typeclass assumptions that involve both `M` and `N`.
- Using a list of `M â N` instead of, e.g., a list of `Σ k : Fin 2, ![M, N] k`
as the underlying type makes it possible to write computationally effective code
(though this point is not tested yet).
## TODO
- Prove `Monoid.CoprodI (f : Fin 2 â Type*) â* f 0 â f 1` and
`Monoid.CoprodI (f : Bool â Type*) â* f false â f true`.
## Tags
group, monoid, coproduct, free product
-/
assert_not_exists MonoidWithZero
open FreeMonoid Function List Set
namespace Monoid
/-- The minimal congruence relation `c` on `FreeMonoid (M â N)`
such that `FreeMonoid.of â Sum.inl` and `FreeMonoid.of â Sum.inr` are monoid homomorphisms
to the quotient by `c`. -/
@[to_additive "The minimal additive congruence relation `c` on `FreeAddMonoid (M â N)`
such that `FreeAddMonoid.of â Sum.inl` and `FreeAddMonoid.of â Sum.inr`
are additive monoid homomorphisms to the quotient by `c`."]
def coprodCon (M N : Type*) [MulOneClass M] [MulOneClass N] : Con (FreeMonoid (M â N)) :=
sInf {c |
(â x y : M, c (of (Sum.inl (x * y))) (of (Sum.inl x) * of (Sum.inl y)))
â§ (â x y : N, c (of (Sum.inr (x * y))) (of (Sum.inr x) * of (Sum.inr y)))
â§ c (of <| Sum.inl 1) 1 â§ c (of <| Sum.inr 1) 1}
/-- Coproduct of two monoids or groups. -/
@[to_additive "Coproduct of two additive monoids or groups."]
def Coprod (M N : Type*) [MulOneClass M] [MulOneClass N] := (coprodCon M N).Quotient
namespace Coprod
@[inherit_doc]
scoped infix:30 " â " => Coprod
section MulOneClass
variable {M N M' N' P : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass M'] [MulOneClass N']
[MulOneClass P]
@[to_additive] protected instance : MulOneClass (M â N) := Con.mulOneClass _
/-- The natural projection `FreeMonoid (M â N) â* M â N`. -/
@[to_additive "The natural projection `FreeAddMonoid (M â N) â+ AddMonoid.Coprod M N`."]
def mk : FreeMonoid (M â N) â* M â N := Con.mk' _
@[to_additive (attr := simp)]
theorem con_ker_mk : Con.ker mk = coprodCon M N := Con.mk'_ker _
@[to_additive]
theorem mk_surjective : Surjective (@mk M N _ _) := Quot.mk_surjective
@[to_additive (attr := simp)]
theorem mrange_mk : MonoidHom.mrange (@mk M N _ _) = †:= Con.mrange_mk'
@[to_additive]
theorem mk_eq_mk {wâ wâ : FreeMonoid (M â N)} : mk wâ = mk wâ â coprodCon M N wâ wâ := Con.eq _
/-- The natural embedding `M â* M â N`. -/
@[to_additive "The natural embedding `M â+ AddMonoid.Coprod M N`."]
def inl : M â* M â N where
toFun := fun x => mk (of (.inl x))
map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.1
map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.1 x y
/-- The natural embedding `N â* M â N`. -/
@[to_additive "The natural embedding `N â+ AddMonoid.Coprod M N`."]
def inr : N â* M â N where
toFun := fun x => mk (of (.inr x))
map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.2
map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.2.1 x y
@[to_additive (attr := simp)]
theorem mk_of_inl (x : M) : (mk (of (.inl x)) : M â N) = inl x := rfl
@[to_additive (attr := simp)]
theorem mk_of_inr (x : N) : (mk (of (.inr x)) : M â N) = inr x := rfl
@[to_additive (attr := elab_as_elim)]
theorem induction_on' {C : M â N â Prop} (m : M â N)
(one : C 1)
(inl_mul : â m x, C x â C (inl m * x))
(inr_mul : â n x, C x â C (inr n * x)) : C m := by
rcases mk_surjective m with âšx, rflâ©
induction x using FreeMonoid.inductionOn' with
| one => exact one
| mul_of x xs ih =>
cases x with
| inl m => simpa using inl_mul m _ ih
| inr n => simpa using inr_mul n _ ih
@[to_additive (attr := elab_as_elim)]
theorem induction_on {C : M â N â Prop} (m : M â N)
(inl : â m, C (inl m)) (inr : â n, C (inr n)) (mul : â x y, C x â C y â C (x * y)) : C m :=
induction_on' m (by simpa using inl 1) (fun _ _ ⊠mul _ _ (inl _)) fun _ _ ⊠mul _ _ (inr _)
/-- Lift a monoid homomorphism `FreeMonoid (M â N) â* P` satisfying additional properties to
`M â N â* P`. In many cases, `Coprod.lift` is more convenient.
Compared to `Coprod.lift`,
this definition allows a user to provide a custom computational behavior.
Also, it only needs `MulOneclass` assumptions while `Coprod.lift` needs a `Monoid` structure.
-/
@[to_additive "Lift an additive monoid homomorphism `FreeAddMonoid (M â N) â+ P` satisfying
additional properties to `AddMonoid.Coprod M N â+ P`.
Compared to `AddMonoid.Coprod.lift`,
this definition allows a user to provide a custom computational behavior.
Also, it only needs `AddZeroclass` assumptions
while `AddMonoid.Coprod.lift` needs an `AddMonoid` structure. "]
def clift (f : FreeMonoid (M â N) â* P)
(hMâ : f (of (.inl 1)) = 1) (hNâ : f (of (.inr 1)) = 1)
(hM : â x y, f (of (.inl (x * y))) = f (of (.inl x) * of (.inl y)))
(hN : â x y, f (of (.inr (x * y))) = f (of (.inr x) * of (.inr y))) :
M â N â* P :=
Con.lift _ f <| sInf_le âšhM, hN, hMâ.trans (map_one f).symm, hNâ.trans (map_one f).symmâ©
@[to_additive (attr := simp)]
theorem clift_apply_inl (f : FreeMonoid (M â N) â* P) (hMâ hNâ hM hN) (x : M) :
clift f hMâ hNâ hM hN (inl x) = f (of (.inl x)) :=
rfl
@[to_additive (attr := simp)]
theorem clift_apply_inr (f : FreeMonoid (M â N) â* P) (hMâ hNâ hM hN) (x : N) :
clift f hMâ hNâ hM hN (inr x) = f (of (.inr x)) :=
rfl
@[to_additive (attr := simp)]
theorem clift_apply_mk (f : FreeMonoid (M â N) â* P) (hMâ hNâ hM hN w) :
clift f hMâ hNâ hM hN (mk w) = f w :=
rfl
@[to_additive (attr := simp)]
theorem clift_comp_mk (f : FreeMonoid (M â N) â* P) (hMâ hNâ hM hN) :
(clift f hMâ hNâ hM hN).comp mk = f :=
DFunLike.ext' rfl
@[to_additive (attr := simp)]
theorem mclosure_range_inl_union_inr :
Submonoid.closure (range (inl : M â* M â N) ⪠range (inr : N â* M â N)) = †:= by
rw [â mrange_mk, MonoidHom.mrange_eq_map, â closure_range_of, MonoidHom.map_mclosure,
â range_comp, Sum.range_eq]; rfl
@[to_additive (attr := simp)] theorem mrange_inl_sup_mrange_inr :
MonoidHom.mrange (inl : M â* M â N) â MonoidHom.mrange (inr : N â* M â N) = †:= by
rw [â mclosure_range_inl_union_inr, Submonoid.closure_union, â MonoidHom.coe_mrange,
â MonoidHom.coe_mrange, Submonoid.closure_eq, Submonoid.closure_eq]
@[to_additive]
theorem codisjoint_mrange_inl_mrange_inr :
Codisjoint (MonoidHom.mrange (inl : M â* M â N)) (MonoidHom.mrange inr) :=
codisjoint_iff.2 mrange_inl_sup_mrange_inr
@[to_additive] theorem mrange_eq (f : M â N â* P) :
MonoidHom.mrange f = MonoidHom.mrange (f.comp inl) â MonoidHom.mrange (f.comp inr) := by
rw [MonoidHom.mrange_eq_map, â mrange_inl_sup_mrange_inr, Submonoid.map_sup, MonoidHom.map_mrange,
MonoidHom.map_mrange]
/-- Extensionality lemma for monoid homomorphisms `M â N â* P`.
If two homomorphisms agree on the ranges of `Monoid.Coprod.inl` and `Monoid.Coprod.inr`,
then they are equal. -/
@[to_additive (attr := ext 1100)
"Extensionality lemma for additive monoid homomorphisms `AddMonoid.Coprod M N â+ P`.
If two homomorphisms agree on the ranges of `AddMonoid.Coprod.inl` and `AddMonoid.Coprod.inr`,
then they are equal."]
theorem hom_ext {f g : M â N â* P} (hâ : f.comp inl = g.comp inl) (hâ : f.comp inr = g.comp inr) :
f = g :=
MonoidHom.eq_of_eqOn_denseM mclosure_range_inl_union_inr <| eqOn_union.2
âšeqOn_range.2 <| DFunLike.ext'_iff.1 hâ, eqOn_range.2 <| DFunLike.ext'_iff.1 hââ©
@[to_additive (attr := simp)]
theorem clift_mk :
clift (mk : FreeMonoid (M â N) â* M â N) (map_one inl) (map_one inr) (map_mul inl)
(map_mul inr) = .id _ :=
hom_ext rfl rfl
/-- Map `M â N` to `M' â N'` by applying `Sum.map f g` to each element of the underlying list. -/
@[to_additive "Map `AddMonoid.Coprod M N` to `AddMonoid.Coprod M' N'`
by applying `Sum.map f g` to each element of the underlying list."]
def map (f : M â* M') (g : N â* N') : M â N â* M' â N' :=
clift (mk.comp <| FreeMonoid.map <| Sum.map f g)
(by simp only [MonoidHom.comp_apply, map_of, Sum.map_inl, map_one, mk_of_inl])
(by simp only [MonoidHom.comp_apply, map_of, Sum.map_inr, map_one, mk_of_inr])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.map_inl, map_mul, mk_of_inl])
fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.map_inr, map_mul, mk_of_inr]
@[to_additive (attr := simp)]
theorem map_mk_ofList (f : M â* M') (g : N â* N') (l : List (M â N)) :
map f g (mk (ofList l)) = mk (ofList (l.map (Sum.map f g))) :=
rfl
@[to_additive (attr := simp)]
theorem map_apply_inl (f : M â* M') (g : N â* N') (x : M) : map f g (inl x) = inl (f x) := rfl
@[to_additive (attr := simp)]
theorem map_apply_inr (f : M â* M') (g : N â* N') (x : N) : map f g (inr x) = inr (g x) := rfl
@[to_additive (attr := simp)]
theorem map_comp_inl (f : M â* M') (g : N â* N') : (map f g).comp inl = inl.comp f := rfl
@[to_additive (attr := simp)]
theorem map_comp_inr (f : M â* M') (g : N â* N') : (map f g).comp inr = inr.comp g := rfl
@[to_additive (attr := simp)]
theorem map_id_id : map (.id M) (.id N) = .id (M â N) := hom_ext rfl rfl
@[to_additive]
theorem map_comp_map {M'' N''} [MulOneClass M''] [MulOneClass N''] (f' : M' â* M'') (g' : N' â* N'')
(f : M â* M') (g : N â* N') : (map f' g').comp (map f g) = map (f'.comp f) (g'.comp g) :=
hom_ext rfl rfl
@[to_additive]
theorem map_map {M'' N''} [MulOneClass M''] [MulOneClass N''] (f' : M' â* M'') (g' : N' â* N'')
(f : M â* M') (g : N â* N') (x : M â N) :
map f' g' (map f g x) = map (f'.comp f) (g'.comp g) x :=
DFunLike.congr_fun (map_comp_map f' g' f g) x
variable (M N)
/-- Map `M â N` to `N â M` by applying `Sum.swap` to each element of the underlying list.
See also `MulEquiv.coprodComm` for a `MulEquiv` version. -/
@[to_additive "Map `AddMonoid.Coprod M N` to `AddMonoid.Coprod N M`
by applying `Sum.swap` to each element of the underlying list.
See also `AddEquiv.coprodComm` for an `AddEquiv` version."]
def swap : M â N â* N â M :=
clift (mk.comp <| FreeMonoid.map Sum.swap)
(by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inl, mk_of_inr, map_one])
(by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inr, mk_of_inl, map_one])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inl, mk_of_inr, map_mul])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inr, mk_of_inl, map_mul])
@[to_additive (attr := simp)]
theorem swap_comp_swap : (swap M N).comp (swap N M) = .id _ := hom_ext rfl rfl
variable {M N}
@[to_additive (attr := simp)]
theorem swap_swap (x : M â N) : swap N M (swap M N x) = x :=
DFunLike.congr_fun (swap_comp_swap _ _) x
@[to_additive]
theorem swap_comp_map (f : M â* M') (g : N â* N') :
(swap M' N').comp (map f g) = (map g f).comp (swap M N) :=
hom_ext rfl rfl
@[to_additive]
theorem swap_map (f : M â* M') (g : N â* N') (x : M â N) :
swap M' N' (map f g x) = map g f (swap M N x) :=
DFunLike.congr_fun (swap_comp_map f g) x
@[to_additive (attr := simp)] theorem swap_comp_inl : (swap M N).comp inl = inr := rfl
@[to_additive (attr := simp)] theorem swap_inl (x : M) : swap M N (inl x) = inr x := rfl
@[to_additive (attr := simp)] theorem swap_comp_inr : (swap M N).comp inr = inl := rfl
@[to_additive (attr := simp)] theorem swap_inr (x : N) : swap M N (inr x) = inl x := rfl
@[to_additive]
theorem swap_injective : Injective (swap M N) := LeftInverse.injective swap_swap
@[to_additive (attr := simp)]
theorem swap_inj {x y : M â N} : swap M N x = swap M N y â x = y := swap_injective.eq_iff
@[to_additive (attr := simp)]
theorem swap_eq_one {x : M â N} : swap M N x = 1 â x = 1 := swap_injective.eq_iff' (map_one _)
@[to_additive]
theorem swap_surjective : Surjective (swap M N) := LeftInverse.surjective swap_swap
@[to_additive]
theorem swap_bijective : Bijective (swap M N) := âšswap_injective, swap_surjectiveâ©
@[to_additive (attr := simp)]
theorem mker_swap : MonoidHom.mker (swap M N) = ⥠:= Submonoid.ext fun _ ⊠swap_eq_one
@[to_additive (attr := simp)]
theorem mrange_swap : MonoidHom.mrange (swap M N) = †:=
MonoidHom.mrange_eq_top_of_surjective _ swap_surjective
end MulOneClass
section Lift
variable {M N P : Type*} [MulOneClass M] [MulOneClass N] [Monoid P]
/-- Lift a pair of monoid homomorphisms `f : M â* P`, `g : N â* P`
to a monoid homomorphism `M â N â* P`.
See also `Coprod.clift` for a version that allows custom computational behavior
and works for a `MulOneClass` codomain.
-/
@[to_additive "Lift a pair of additive monoid homomorphisms `f : M â+ P`, `g : N â+ P`
to an additive monoid homomorphism `AddMonoid.Coprod M N â+ P`.
See also `AddMonoid.Coprod.clift` for a version that allows custom computational behavior
and works for an `AddZeroClass` codomain."]
def lift (f : M â* P) (g : N â* P) : (M â N) â* P :=
clift (FreeMonoid.lift <| Sum.elim f g) (map_one f) (map_one g) (map_mul f) (map_mul g)
@[to_additive (attr := simp)]
theorem lift_apply_mk (f : M â* P) (g : N â* P) (x : FreeMonoid (M â N)) :
lift f g (mk x) = FreeMonoid.lift (Sum.elim f g) x :=
rfl
@[to_additive (attr := simp)]
theorem lift_apply_inl (f : M â* P) (g : N â* P) (x : M) : lift f g (inl x) = f x :=
rfl
@[to_additive]
theorem lift_unique {f : M â* P} {g : N â* P} {fg : M â N â* P} (hâ : fg.comp inl = f)
(hâ : fg.comp inr = g) : fg = lift f g :=
hom_ext hâ hâ
@[to_additive (attr := simp)]
theorem lift_comp_inl (f : M â* P) (g : N â* P) : (lift f g).comp inl = f := rfl
@[to_additive (attr := simp)]
theorem lift_apply_inr (f : M â* P) (g : N â* P) (x : N) : lift f g (inr x) = g x :=
rfl
@[to_additive (attr := simp)]
theorem lift_comp_inr (f : M â* P) (g : N â* P) : (lift f g).comp inr = g := rfl
@[to_additive (attr := simp)]
theorem lift_comp_swap (f : M â* P) (g : N â* P) : (lift f g).comp (swap N M) = lift g f :=
hom_ext rfl rfl
@[to_additive (attr := simp)]
theorem lift_swap (f : M â* P) (g : N â* P) (x : N â M) : lift f g (swap N M x) = lift g f x :=
DFunLike.congr_fun (lift_comp_swap f g) x
@[to_additive]
theorem comp_lift {P' : Type*} [Monoid P'] (f : P â* P') (gâ : M â* P) (gâ : N â* P) :
f.comp (lift gâ gâ) = lift (f.comp gâ) (f.comp gâ) :=
hom_ext (by rw [MonoidHom.comp_assoc, lift_comp_inl, lift_comp_inl]) <| by
rw [MonoidHom.comp_assoc, lift_comp_inr, lift_comp_inr]
/-- `Coprod.lift` as an equivalence. -/
@[to_additive "`AddMonoid.Coprod.lift` as an equivalence."]
def liftEquiv : (M â* P) Ã (N â* P) â (M â N â* P) where
toFun fg := lift fg.1 fg.2
invFun f := (f.comp inl, f.comp inr)
left_inv _ := rfl
right_inv _ := Eq.symm <| lift_unique rfl rfl
@[to_additive (attr := simp)]
theorem mrange_lift (f : M â* P) (g : N â* P) :
MonoidHom.mrange (lift f g) = MonoidHom.mrange f â MonoidHom.mrange g := by
simp [mrange_eq]
end Lift
section ToProd
variable {M N : Type*} [Monoid M] [Monoid N]
@[to_additive] instance : Monoid (M â N) :=
{ mul_assoc := (Con.monoid _).mul_assoc
one_mul := (Con.monoid _).one_mul
mul_one := (Con.monoid _).mul_one }
/-- The natural projection `M â N â* M`. -/
@[to_additive "The natural projection `AddMonoid.Coprod M N â+ M`."]
def fst : M â N â* M := lift (.id M) 1
/-- The natural projection `M â N â* N`. -/
@[to_additive "The natural projection `AddMonoid.Coprod M N â+ N`."]
def snd : M â N â* N := lift 1 (.id N)
/-- The natural projection `M â N â* M Ã N`. -/
@[to_additive toProd "The natural projection `AddMonoid.Coprod M N â+ M Ã N`."]
def toProd : M â N â* M Ã N := lift (.inl _ _) (.inr _ _)
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.toSum := AddMonoid.Coprod.toProd
@[to_additive (attr := simp)] theorem fst_comp_inl : (fst : M â N â* M).comp inl = .id _ := rfl
@[to_additive (attr := simp)] theorem fst_apply_inl (x : M) : fst (inl x : M â N) = x := rfl
@[to_additive (attr := simp)] theorem fst_comp_inr : (fst : M â N â* M).comp inr = 1 := rfl
@[to_additive (attr := simp)] theorem fst_apply_inr (x : N) : fst (inr x : M â N) = 1 := rfl
@[to_additive (attr := simp)] theorem snd_comp_inl : (snd : M â N â* N).comp inl = 1 := rfl
@[to_additive (attr := simp)] theorem snd_apply_inl (x : M) : snd (inl x : M â N) = 1 := rfl
@[to_additive (attr := simp)] theorem snd_comp_inr : (snd : M â N â* N).comp inr = .id _ := rfl
@[to_additive (attr := simp)] theorem snd_apply_inr (x : N) : snd (inr x : M â N) = x := rfl
@[to_additive (attr := simp) toProd_comp_inl]
theorem toProd_comp_inl : (toProd : M â N â* M Ã N).comp inl = .inl _ _ := rfl
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.toSum_comp_inl := AddMonoid.Coprod.toProd_comp_inl
@[to_additive (attr := simp) toProd_comp_inr]
theorem toProd_comp_inr : (toProd : M â N â* M Ã N).comp inr = .inr _ _ := rfl
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.toSum_comp_inr := AddMonoid.Coprod.toProd_comp_inr
@[to_additive (attr := simp) toProd_apply_inl]
theorem toProd_apply_inl (x : M) : toProd (inl x : M â N) = (x, 1) := rfl
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.toSum_apply_inl := AddMonoid.Coprod.toProd_apply_inl
@[to_additive (attr := simp) toProd_apply_inr]
theorem toProd_apply_inr (x : N) : toProd (inr x : M â N) = (1, x) := rfl
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.toSum_apply_inr := AddMonoid.Coprod.toProd_apply_inr
@[to_additive (attr := simp) fst_prod_snd]
theorem fst_prod_snd : (fst : M â N â* M).prod snd = toProd := by ext1 <;> rfl
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.fst_sum_snd := AddMonoid.Coprod.fst_prod_snd
@[to_additive (attr := simp) prod_mk_fst_snd]
theorem prod_mk_fst_snd (x : M â N) : (fst x, snd x) = toProd x := by
rw [â fst_prod_snd, MonoidHom.prod_apply]
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.sum_mk_fst_snd := AddMonoid.Coprod.prod_mk_fst_snd
@[to_additive (attr := simp) fst_comp_toProd]
theorem fst_comp_toProd : (MonoidHom.fst M N).comp toProd = fst := by
rw [â fst_prod_snd, MonoidHom.fst_comp_prod]
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.fst_comp_toSum := AddMonoid.Coprod.fst_comp_toProd
@[to_additive (attr := simp) fst_toProd]
theorem fst_toProd (x : M â N) : (toProd x).1 = fst x := by
rw [â fst_comp_toProd]; rfl
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.fst_toSum := AddMonoid.Coprod.fst_toProd
@[to_additive (attr := simp) snd_comp_toProd]
theorem snd_comp_toProd : (MonoidHom.snd M N).comp toProd = snd := by
rw [â fst_prod_snd, MonoidHom.snd_comp_prod]
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.snd_comp_toSum := AddMonoid.Coprod.snd_comp_toProd
@[to_additive (attr := simp) snd_toProd]
theorem snd_toProd (x : M â N) : (toProd x).2 = snd x := by
rw [â snd_comp_toProd]; rfl
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.snd_toSum := AddMonoid.Coprod.snd_toProd
@[to_additive (attr := simp)]
theorem fst_comp_swap : fst.comp (swap M N) = snd := lift_comp_swap _ _
@[to_additive (attr := simp)]
theorem fst_swap (x : M â N) : fst (swap M N x) = snd x := lift_swap _ _ _
@[to_additive (attr := simp)]
theorem snd_comp_swap : snd.comp (swap M N) = fst := lift_comp_swap _ _
@[to_additive (attr := simp)]
theorem snd_swap (x : M â N) : snd (swap M N x) = fst x := lift_swap _ _ _
@[to_additive (attr := simp)]
theorem lift_inr_inl : lift (inr : M â* N â M) inl = swap M N := hom_ext rfl rfl
@[to_additive (attr := simp)]
theorem lift_inl_inr : lift (inl : M â* M â N) inr = .id _ := hom_ext rfl rfl
@[to_additive]
theorem inl_injective : Injective (inl : M â* M â N) := LeftInverse.injective fst_apply_inl
@[to_additive]
theorem inr_injective : Injective (inr : N â* M â N) := LeftInverse.injective snd_apply_inr
@[to_additive]
theorem fst_surjective : Surjective (fst : M â N â* M) := LeftInverse.surjective fst_apply_inl
@[to_additive]
theorem snd_surjective : Surjective (snd : M â N â* N) := LeftInverse.surjective snd_apply_inr
@[to_additive toProd_surjective]
theorem toProd_surjective : Surjective (toProd : M â N â* M Ã N) := fun x =>
âšinl x.1 * inr x.2, by rw [map_mul, toProd_apply_inl, toProd_apply_inr, Prod.fst_mul_snd]â©
@[deprecated (since := "2025-03-11")]
alias _root_.AddMonoid.Coprod.toSum_surjective := AddMonoid.Coprod.toProd_surjective
end ToProd
section Group
variable {G H : Type*} [Group G] [Group H]
@[to_additive]
theorem mk_of_inv_mul : â x : G â H, mk (of (x.map Inv.inv Inv.inv)) * mk (of x) = 1
| Sum.inl _ => map_mul_eq_one inl (inv_mul_cancel _)
| Sum.inr _ => map_mul_eq_one inr (inv_mul_cancel _)
@[to_additive]
theorem con_inv_mul_cancel (x : FreeMonoid (G â H)) :
coprodCon G H (ofList (x.toList.map (Sum.map Inv.inv Inv.inv)).reverse * x) 1 := by
rw [â mk_eq_mk, map_mul, map_one]
induction x using FreeMonoid.inductionOn' with
| one => simp
| mul_of x xs ihx =>
simp only [toList_of_mul, map_cons, reverse_cons, ofList_append, map_mul, ihx, ofList_singleton]
rwa [mul_assoc, â mul_assoc (mk (of _)), mk_of_inv_mul, one_mul]
@[to_additive]
| instance : Inv (G â H) where
inv := Quotient.map' (fun w => ofList (w.toList.map (Sum.map Inv.inv Inv.inv)).reverse) fun _ _ âŠ
(coprodCon G H).map_of_mul_left_rel_one _ con_inv_mul_cancel
| Mathlib/GroupTheory/Coprod/Basic.lean | 621 | 623 |
/-
Copyright (c) 2019 Rohan Mitta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rohan Mitta, Kevin Buzzard, Alistair Tucker, Johannes Hölzl, Yury Kudryashov
-/
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.Setoid.Basic
import Mathlib.Dynamics.FixedPoints.Topology
import Mathlib.Topology.MetricSpace.Lipschitz
/-!
# Contracting maps
A Lipschitz continuous self-map with Lipschitz constant `K < 1` is called a *contracting map*.
In this file we prove the Banach fixed point theorem, some explicit estimates on the rate
of convergence, and some properties of the map sending a contracting map to its fixed point.
## Main definitions
* `ContractingWith K f` : a Lipschitz continuous self-map with `K < 1`;
* `efixedPoint` : given a contracting map `f` on a complete emetric space and a point `x`
such that `edist x (f x) â â`, `efixedPoint f hf x hx` is the unique fixed point of `f`
in `EMetric.ball x â`;
* `fixedPoint` : the unique fixed point of a contracting map on a complete nonempty metric space.
## Tags
contracting map, fixed point, Banach fixed point theorem
-/
open NNReal Topology ENNReal Filter Function
variable {α : Type*}
/-- A map is said to be `ContractingWith K`, if `K < 1` and `f` is `LipschitzWith K`. -/
def ContractingWith [EMetricSpace α] (K : ââ¥0) (f : α â α) :=
K < 1 â§ LipschitzWith K f
namespace ContractingWith
variable [EMetricSpace α] {K : ââ¥0} {f : α â α}
open EMetric Set
theorem toLipschitzWith (hf : ContractingWith K f) : LipschitzWith K f := hf.2
theorem one_sub_K_pos' (hf : ContractingWith K f) : (0 : ââ¥0â) < 1 - K := by simp [hf.1]
theorem one_sub_K_ne_zero (hf : ContractingWith K f) : (1 : ââ¥0â) - K â 0 :=
ne_of_gt hf.one_sub_K_pos'
theorem one_sub_K_ne_top : (1 : ââ¥0â) - K â â := by
norm_cast
exact ENNReal.coe_ne_top
theorem edist_inequality (hf : ContractingWith K f) {x y} (h : edist x y â â) :
edist x y †(edist x (f x) + edist y (f y)) / (1 - K) :=
suffices edist x y †edist x (f x) + edist y (f y) + K * edist x y by
rwa [ENNReal.le_div_iff_mul_le (Or.inl hf.one_sub_K_ne_zero) (Or.inl one_sub_K_ne_top),
mul_comm, ENNReal.sub_mul fun _ _ ⊠h, one_mul, tsub_le_iff_right]
calc
| edist x y †edist x (f x) + edist (f x) (f y) + edist (f y) y := edist_triangle4 _ _ _ _
_ = edist x (f x) + edist y (f y) + edist (f x) (f y) := by rw [edist_comm y, add_right_comm]
_ †edist x (f x) + edist y (f y) + K * edist x y := add_le_add le_rfl (hf.2 _ _)
| Mathlib/Topology/MetricSpace/Contracting.lean | 62 | 64 |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes Hölzl, Patrick Massot
-/
import Mathlib.Data.Set.Image
import Mathlib.Data.SProd
/-!
# Sets in product and pi types
This file proves basic properties of product of sets in `α à β` and in `Πi, α i`, and of the
diagonal of a type.
## Main declarations
This file contains basic results on the following notions, which are defined in `Set.Operations`.
* `Set.prod`: Binary product of sets. For `s : Set α`, `t : Set β`, we have
`s.prod t : Set (α à β)`. Denoted by `s ÃË¢ t`.
* `Set.diagonal`: Diagonal of a type. `Set.diagonal α = {(x, x) | x : α}`.
* `Set.offDiag`: Off-diagonal. `s ÃË¢ s` without the diagonal.
* `Set.pi`: Arbitrary product of sets.
-/
open Function
namespace Set
/-! ### Cartesian binary product of sets -/
section Prod
variable {α β γ ÎŽ : Type*} {s sâ sâ : Set α} {t tâ tâ : Set β} {a : α} {b : β}
theorem Subsingleton.prod (hs : s.Subsingleton) (ht : t.Subsingleton) :
(s ÃË¢ t).Subsingleton := fun _x hx _y hy âŠ
Prod.ext (hs hx.1 hy.1) (ht hx.2 hy.2)
noncomputable instance decidableMemProd [DecidablePred (· â s)] [DecidablePred (· â t)] :
DecidablePred (· â s ÃË¢ t) := fun x => inferInstanceAs (Decidable (x.1 â s â§ x.2 â t))
@[gcongr]
theorem prod_mono (hs : sâ â sâ) (ht : tâ â tâ) : sâ ÃË¢ tâ â sâ ÃË¢ tâ :=
fun _ âšhâ, hââ© => âšhs hâ, ht hââ©
@[gcongr]
theorem prod_mono_left (hs : sâ â sâ) : sâ ÃË¢ t â sâ ÃË¢ t :=
prod_mono hs Subset.rfl
@[gcongr]
theorem prod_mono_right (ht : tâ â tâ) : s ÃË¢ tâ â s ÃË¢ tâ :=
prod_mono Subset.rfl ht
@[simp]
theorem prod_self_subset_prod_self : sâ ÃË¢ sâ â sâ ÃË¢ sâ â sâ â sâ :=
âšfun h _ hx => (h (mk_mem_prod hx hx)).1, fun h _ hx => âšh hx.1, h hx.2â©â©
@[simp]
theorem prod_self_ssubset_prod_self : sâ ÃË¢ sâ â sâ ÃË¢ sâ â sâ â sâ :=
and_congr prod_self_subset_prod_self <| not_congr prod_self_subset_prod_self
theorem prod_subset_iff {P : Set (α à β)} : s ÃË¢ t â P â â x â s, â y â t, (x, y) â P :=
âšfun h _ hx _ hy => h (mk_mem_prod hx hy), fun h âš_, _â© hp => h _ hp.1 _ hp.2â©
theorem forall_prod_set {p : α à β â Prop} : (â x â s ÃË¢ t, p x) â â x â s, â y â t, p (x, y) :=
prod_subset_iff
theorem exists_prod_set {p : α à β â Prop} : (â x â s ÃË¢ t, p x) â â x â s, â y â t, p (x, y) := by
simp [and_assoc]
@[simp]
theorem prod_empty : s ÃË¢ (â
: Set β) = â
:= by
ext
exact iff_of_eq (and_false _)
@[simp]
theorem empty_prod : (â
: Set α) ÃË¢ t = â
:= by
ext
exact iff_of_eq (false_and _)
@[simp, mfld_simps]
theorem univ_prod_univ : @univ α ÃË¢ @univ β = univ := by
ext
exact iff_of_eq (true_and _)
theorem univ_prod {t : Set β} : (univ : Set α) ÃË¢ t = Prod.snd â»Â¹' t := by simp [prod_eq]
theorem prod_univ {s : Set α} : s ÃË¢ (univ : Set β) = Prod.fst â»Â¹' s := by simp [prod_eq]
@[simp] lemma prod_eq_univ [Nonempty α] [Nonempty β] : s ÃË¢ t = univ â s = univ â§ t = univ := by
simp [eq_univ_iff_forall, forall_and]
theorem singleton_prod : ({a} : Set α) ÃË¢ t = Prod.mk a '' t := by
ext âšx, yâ©
simp [and_left_comm, eq_comm]
theorem prod_singleton : s ÃË¢ ({b} : Set β) = (fun a => (a, b)) '' s := by
ext âšx, yâ©
simp [and_left_comm, eq_comm]
@[simp]
theorem singleton_prod_singleton : ({a} : Set α) ÃË¢ ({b} : Set β) = {(a, b)} := by ext âšc, dâ©; simp
@[simp]
theorem union_prod : (sâ ⪠sâ) ÃË¢ t = sâ ÃË¢ t ⪠sâ ÃË¢ t := by
ext âšx, yâ©
simp [or_and_right]
|
@[simp]
theorem prod_union : s ÃË¢ (tâ ⪠tâ) = s ÃË¢ tâ ⪠s ÃË¢ tâ := by
| Mathlib/Data/Set/Prod.lean | 111 | 113 |
/-
Copyright (c) 2023 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Slope
/-!
# Line derivatives
We define the line derivative of a function `f : E â F`, at a point `x : E` along a vector `v : E`,
as the element `f' : F` such that `f (x + t ⢠v) = f x + t ⢠f' + o (t)` as `t` tends to `0` in
the scalar field `ð`, if it exists. It is denoted by `lineDeriv ð f x v`.
This notion is generally less well behaved than the full Fréchet derivative (for instance, the
composition of functions which are line-differentiable is not line-differentiable in general).
The Fréchet derivative should therefore be favored over this one in general, although the line
derivative may sometimes prove handy.
The line derivative in direction `v` is also called the Gateaux derivative in direction `v`,
although the term "Gateaux derivative" is sometimes reserved for the situation where there is
such a derivative in all directions, for the map `v ⊠lineDeriv ð f x v` (which doesn't have to be
linear in general).
## Main definition and results
We mimic the definitions and statements for the Fréchet derivative and the one-dimensional
derivative. We define in particular the following objects:
* `LineDifferentiableWithinAt ð f s x v`
* `LineDifferentiableAt ð f x v`
* `HasLineDerivWithinAt ð f f' s x v`
* `HasLineDerivAt ð f s x v`
* `lineDerivWithin ð f s x v`
* `lineDeriv ð f x v`
and develop about them a basic API inspired by the one for the Fréchet derivative.
We depart from the Fréchet derivative in two places, as the dependence of the following predicates
on the direction would make them barely usable:
* We do not define an analogue of the predicate `UniqueDiffOn`;
* We do not define `LineDifferentiableOn` nor `LineDifferentiable`.
-/
noncomputable section
open scoped Topology Filter ENNReal NNReal
open Filter Asymptotics Set
variable {ð : Type*} [NontriviallyNormedField ð]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ð F]
section Module
/-!
Results that do not rely on a topological structure on `E`
-/
variable (ð)
variable {E : Type*} [AddCommGroup E] [Module ð E]
/-- `f` has the derivative `f'` at the point `x` along the direction `v` in the set `s`.
That is, `f (x + t v) = f x + t ⢠f' + o (t)` when `t` tends to `0` and `x + t v â s`.
Note that this definition is less well behaved than the total Fréchet derivative, which
should generally be favored over this one. -/
def HasLineDerivWithinAt (f : E â F) (f' : F) (s : Set E) (x : E) (v : E) :=
HasDerivWithinAt (fun t ⊠f (x + t ⢠v)) f' ((fun t ⊠x + t ⢠v) â»Â¹' s) (0 : ð)
/-- `f` has the derivative `f'` at the point `x` along the direction `v`.
That is, `f (x + t v) = f x + t ⢠f' + o (t)` when `t` tends to `0`.
Note that this definition is less well behaved than the total Fréchet derivative, which
should generally be favored over this one. -/
def HasLineDerivAt (f : E â F) (f' : F) (x : E) (v : E) :=
HasDerivAt (fun t ⊠f (x + t ⢠v)) f' (0 : ð)
/-- `f` is line-differentiable at the point `x` in the direction `v` in the set `s` if there
exists `f'` such that `f (x + t v) = f x + t ⢠f' + o (t)` when `t` tends to `0` and `x + t v â s`.
-/
def LineDifferentiableWithinAt (f : E â F) (s : Set E) (x : E) (v : E) : Prop :=
DifferentiableWithinAt ð (fun t ⊠f (x + t ⢠v)) ((fun t ⊠x + t ⢠v) â»Â¹' s) (0 : ð)
/-- `f` is line-differentiable at the point `x` in the direction `v` if there
exists `f'` such that `f (x + t v) = f x + t ⢠f' + o (t)` when `t` tends to `0`. -/
def LineDifferentiableAt (f : E â F) (x : E) (v : E) : Prop :=
DifferentiableAt ð (fun t ⊠f (x + t ⢠v)) (0 : ð)
/-- Line derivative of `f` at the point `x` in the direction `v` within the set `s`, if it exists.
Zero otherwise.
If the line derivative exists (i.e., `â f', HasLineDerivWithinAt ð f f' s x v`), then
`f (x + t v) = f x + t lineDerivWithin ð f s x v + o (t)` when `t` tends to `0` and `x + t v â s`.
-/
def lineDerivWithin (f : E â F) (s : Set E) (x : E) (v : E) : F :=
derivWithin (fun t ⊠f (x + t ⢠v)) ((fun t ⊠x + t ⢠v) â»Â¹' s) (0 : ð)
/-- Line derivative of `f` at the point `x` in the direction `v`, if it exists. Zero otherwise.
If the line derivative exists (i.e., `â f', HasLineDerivAt ð f f' x v`), then
`f (x + t v) = f x + t lineDeriv ð f x v + o (t)` when `t` tends to `0`.
-/
def lineDeriv (f : E â F) (x : E) (v : E) : F :=
deriv (fun t ⊠f (x + t ⢠v)) (0 : ð)
variable {ð}
variable {f fâ : E â F} {f' fâ' fâ' : F} {s t : Set E} {x v : E}
lemma HasLineDerivWithinAt.mono (hf : HasLineDerivWithinAt ð f f' s x v) (hst : t â s) :
HasLineDerivWithinAt ð f f' t x v :=
HasDerivWithinAt.mono hf (preimage_mono hst)
lemma HasLineDerivAt.hasLineDerivWithinAt (hf : HasLineDerivAt ð f f' x v) (s : Set E) :
HasLineDerivWithinAt ð f f' s x v :=
HasDerivAt.hasDerivWithinAt hf
lemma HasLineDerivWithinAt.lineDifferentiableWithinAt (hf : HasLineDerivWithinAt ð f f' s x v) :
LineDifferentiableWithinAt ð f s x v :=
HasDerivWithinAt.differentiableWithinAt hf
theorem HasLineDerivAt.lineDifferentiableAt (hf : HasLineDerivAt ð f f' x v) :
LineDifferentiableAt ð f x v :=
HasDerivAt.differentiableAt hf
theorem LineDifferentiableWithinAt.hasLineDerivWithinAt (h : LineDifferentiableWithinAt ð f s x v) :
HasLineDerivWithinAt ð f (lineDerivWithin ð f s x v) s x v :=
DifferentiableWithinAt.hasDerivWithinAt h
theorem LineDifferentiableAt.hasLineDerivAt (h : LineDifferentiableAt ð f x v) :
HasLineDerivAt ð f (lineDeriv ð f x v) x v :=
DifferentiableAt.hasDerivAt h
@[simp] lemma hasLineDerivWithinAt_univ :
HasLineDerivWithinAt ð f f' univ x v â HasLineDerivAt ð f f' x v := by
simp only [HasLineDerivWithinAt, HasLineDerivAt, preimage_univ, hasDerivWithinAt_univ]
theorem lineDerivWithin_zero_of_not_lineDifferentiableWithinAt
(h : ¬LineDifferentiableWithinAt ð f s x v) :
lineDerivWithin ð f s x v = 0 :=
derivWithin_zero_of_not_differentiableWithinAt h
theorem lineDeriv_zero_of_not_lineDifferentiableAt (h : ¬LineDifferentiableAt ð f x v) :
lineDeriv ð f x v = 0 :=
deriv_zero_of_not_differentiableAt h
| theorem hasLineDerivAt_iff_isLittleO_nhds_zero :
HasLineDerivAt ð f f' x v â
(fun t : ð => f (x + t ⢠v) - f x - t ⢠f') =o[ð 0] fun t => t := by
simp only [HasLineDerivAt, hasDerivAt_iff_isLittleO_nhds_zero, zero_add, zero_smul, add_zero]
| Mathlib/Analysis/Calculus/LineDeriv/Basic.lean | 147 | 150 |
/-
Copyright (c) 2020 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser, Utensil Song
-/
import Mathlib.Algebra.RingQuot
import Mathlib.LinearAlgebra.TensorAlgebra.Basic
import Mathlib.LinearAlgebra.QuadraticForm.Isometry
import Mathlib.LinearAlgebra.QuadraticForm.IsometryEquiv
/-!
# Clifford Algebras
We construct the Clifford algebra of a module `M` over a commutative ring `R`, equipped with
a quadratic form `Q`.
## Notation
The Clifford algebra of the `R`-module `M` equipped with a quadratic form `Q` is
an `R`-algebra denoted `CliffordAlgebra Q`.
Given a linear morphism `f : M â A` from a module `M` to another `R`-algebra `A`, such that
`cond : â m, f m * f m = algebraMap _ _ (Q m)`, there is a (unique) lift of `f` to an `R`-algebra
morphism from `CliffordAlgebra Q` to `A`, which is denoted `CliffordAlgebra.lift Q f cond`.
The canonical linear map `M â CliffordAlgebra Q` is denoted `CliffordAlgebra.ι Q`.
## Theorems
The main theorems proved ensure that `CliffordAlgebra Q` satisfies the universal property
of the Clifford algebra.
1. `ι_comp_lift` is the fact that the composition of `ι Q` with `lift Q f cond` agrees with `f`.
2. `lift_unique` ensures the uniqueness of `lift Q f cond` with respect to 1.
## Implementation details
The Clifford algebra of `M` is constructed as a quotient of the tensor algebra, as follows.
1. We define a relation `CliffordAlgebra.Rel Q` on `TensorAlgebra R M`.
This is the smallest relation which identifies squares of elements of `M` with `Q m`.
2. The Clifford algebra is the quotient of the tensor algebra by this relation.
This file is almost identical to `Mathlib/LinearAlgebra/ExteriorAlgebra/Basic.lean`.
-/
variable {R : Type*} [CommRing R]
variable {M : Type*} [AddCommGroup M] [Module R M]
variable (Q : QuadraticForm R M)
namespace CliffordAlgebra
open TensorAlgebra
/-- `Rel` relates each `ι m * ι m`, for `m : M`, with `Q m`.
The Clifford algebra of `M` is defined as the quotient modulo this relation.
-/
inductive Rel : TensorAlgebra R M â TensorAlgebra R M â Prop
| of (m : M) : Rel (ι R m * ι R m) (algebraMap R _ (Q m))
end CliffordAlgebra
/-- The Clifford algebra of an `R`-module `M` equipped with a quadratic_form `Q`.
-/
def CliffordAlgebra :=
RingQuot (CliffordAlgebra.Rel Q)
namespace CliffordAlgebra
-- The `Inhabited, Semiring, Algebra` instances should be constructed by a deriving handler.
-- https://github.com/leanprover-community/mathlib4/issues/380
instance instInhabited : Inhabited (CliffordAlgebra Q) := RingQuot.instInhabited _
instance instRing : Ring (CliffordAlgebra Q) := RingQuot.instRing _
instance (priority := 900) instAlgebra' {R A M} [CommSemiring R] [AddCommGroup M] [CommRing A]
[Algebra R A] [Module R M] [Module A M] (Q : QuadraticForm A M)
[IsScalarTower R A M] :
Algebra R (CliffordAlgebra Q) :=
RingQuot.instAlgebra _
-- verify there are no diamonds
-- but doesn't work at `reducible_and_instances` https://github.com/leanprover-community/mathlib4/issues/10906
example : (Semiring.toNatAlgebra : Algebra â (CliffordAlgebra Q)) = instAlgebra' _ := rfl
-- but doesn't work at `reducible_and_instances` https://github.com/leanprover-community/mathlib4/issues/10906
example : (Ring.toIntAlgebra _ : Algebra †(CliffordAlgebra Q)) = instAlgebra' _ := rfl
-- shortcut instance, as the other instance is slow
instance instAlgebra : Algebra R (CliffordAlgebra Q) := instAlgebra' _
instance {R S A M} [CommSemiring R] [CommSemiring S] [AddCommGroup M] [CommRing A]
[Algebra R A] [Algebra S A] [Module R M] [Module S M] [Module A M] (Q : QuadraticForm A M)
[IsScalarTower R A M] [IsScalarTower S A M] :
SMulCommClass R S (CliffordAlgebra Q) :=
RingQuot.instSMulCommClass _
instance {R S A M} [CommSemiring R] [CommSemiring S] [AddCommGroup M] [CommRing A]
[SMul R S] [Algebra R A] [Algebra S A] [Module R M] [Module S M] [Module A M]
[IsScalarTower R A M] [IsScalarTower S A M] [IsScalarTower R S A] (Q : QuadraticForm A M) :
IsScalarTower R S (CliffordAlgebra Q) :=
RingQuot.instIsScalarTower _
/-- The canonical linear map `M ââ[R] CliffordAlgebra Q`.
-/
def ι : M ââ[R] CliffordAlgebra Q :=
(RingQuot.mkAlgHom R _).toLinearMap.comp (TensorAlgebra.ι R)
/-- As well as being linear, `ι Q` squares to the quadratic form -/
@[simp]
theorem ι_sq_scalar (m : M) : ι Q m * ι Q m = algebraMap R _ (Q m) := by
rw [ι]
erw [LinearMap.comp_apply]
rw [AlgHom.toLinearMap_apply, â map_mul (RingQuot.mkAlgHom R (Rel Q)),
RingQuot.mkAlgHom_rel R (Rel.of m), AlgHom.commutes]
rfl
variable {Q} {A : Type*} [Semiring A] [Algebra R A]
@[simp]
theorem comp_ι_sq_scalar (g : CliffordAlgebra Q ââ[R] A) (m : M) :
g (ι Q m) * g (ι Q m) = algebraMap _ _ (Q m) := by
rw [â map_mul, ι_sq_scalar, AlgHom.commutes]
variable (Q) in
/-- Given a linear map `f : M ââ[R] A` into an `R`-algebra `A`, which satisfies the condition:
`cond : â m : M, f m * f m = Q(m)`, this is the canonical lift of `f` to a morphism of `R`-algebras
from `CliffordAlgebra Q` to `A`.
-/
@[simps symm_apply]
def lift :
{ f : M ââ[R] A // â m, f m * f m = algebraMap _ _ (Q m) } â (CliffordAlgebra Q ââ[R] A) where
toFun f :=
RingQuot.liftAlgHom R
âšTensorAlgebra.lift R (f : M ââ[R] A), fun x y (h : Rel Q x y) => by
induction h
rw [AlgHom.commutes, map_mul, TensorAlgebra.lift_ι_apply, f.prop]â©
invFun F :=
âšF.toLinearMap.comp (ι Q), fun m => by
rw [LinearMap.comp_apply, AlgHom.toLinearMap_apply, comp_ι_sq_scalar]â©
left_inv f := by
ext x
exact (RingQuot.liftAlgHom_mkAlgHom_apply _ _ _ _).trans (TensorAlgebra.lift_ι_apply _ x)
right_inv F :=
RingQuot.ringQuot_ext' _ _ _ <|
TensorAlgebra.hom_ext <|
LinearMap.ext fun x âŠ
(RingQuot.liftAlgHom_mkAlgHom_apply _ _ _ _).trans (TensorAlgebra.lift_ι_apply _ _)
@[simp]
theorem ι_comp_lift (f : M ââ[R] A) (cond : â m, f m * f m = algebraMap _ _ (Q m)) :
(lift Q âšf, condâ©).toLinearMap.comp (ι Q) = f :=
Subtype.mk_eq_mk.mp <| (lift Q).symm_apply_apply âšf, condâ©
@[simp]
theorem lift_ι_apply (f : M ââ[R] A) (cond : â m, f m * f m = algebraMap _ _ (Q m)) (x) :
lift Q âšf, condâ© (ι Q x) = f x :=
(LinearMap.ext_iff.mp <| ι_comp_lift f cond) x
@[simp]
theorem lift_unique (f : M ââ[R] A) (cond : â m : M, f m * f m = algebraMap _ _ (Q m))
(g : CliffordAlgebra Q ââ[R] A) : g.toLinearMap.comp (ι Q) = f â g = lift Q âšf, condâ© := by
convert (lift Q : _ â (CliffordAlgebra Q ââ[R] A)).symm_apply_eq
rw [lift_symm_apply, Subtype.mk_eq_mk]
@[simp]
theorem lift_comp_ι (g : CliffordAlgebra Q ââ[R] A) :
lift Q âšg.toLinearMap.comp (ι Q), comp_ι_sq_scalar _â© = g := by
exact (lift Q : _ â (CliffordAlgebra Q ââ[R] A)).apply_symm_apply g
/-- See note [partially-applied ext lemmas]. -/
@[ext high]
theorem hom_ext {A : Type*} [Semiring A] [Algebra R A] {f g : CliffordAlgebra Q ââ[R] A} :
f.toLinearMap.comp (ι Q) = g.toLinearMap.comp (ι Q) â f = g := by
intro h
apply (lift Q).symm.injective
rw [lift_symm_apply, lift_symm_apply]
simp only [h]
-- This proof closely follows `TensorAlgebra.induction`
/-- If `C` holds for the `algebraMap` of `r : R` into `CliffordAlgebra Q`, the `ι` of `x : M`,
and is preserved under addition and multiplication, then it holds for all of `CliffordAlgebra Q`.
See also the stronger `CliffordAlgebra.left_induction` and `CliffordAlgebra.right_induction`.
-/
@[elab_as_elim]
theorem induction {C : CliffordAlgebra Q â Prop}
(algebraMap : â r, C (algebraMap R (CliffordAlgebra Q) r)) (ι : â x, C (ι Q x))
(mul : â a b, C a â C b â C (a * b)) (add : â a b, C a â C b â C (a + b))
(a : CliffordAlgebra Q) : C a := by
-- the arguments are enough to construct a subalgebra, and a mapping into it from M
let s : Subalgebra R (CliffordAlgebra Q) :=
{ carrier := C
mul_mem' := @mul
add_mem' := @add
algebraMap_mem' := algebraMap }
let of : { f : M ââ[R] s // â m, f m * f m = _root_.algebraMap _ _ (Q m) } :=
âš(CliffordAlgebra.ι Q).codRestrict (Subalgebra.toSubmodule s) ι,
fun m => Subtype.eq <| ι_sq_scalar Q mâ©
-- the mapping through the subalgebra is the identity
have of_id : s.val.comp (lift Q of) = AlgHom.id R (CliffordAlgebra Q) := by
ext x
simp [of]
-- porting note: `simp` should fire with the following lemma automatically
have := LinearMap.codRestrict_apply s.toSubmodule (CliffordAlgebra.ι Q) x (h := ι)
exact this
-- finding a proof is finding an element of the subalgebra
rw [â AlgHom.id_apply (R := R) a, â of_id]
exact (lift Q of a).prop
theorem mul_add_swap_eq_polar_of_forall_mul_self_eq {A : Type*} [Ring A] [Algebra R A]
(f : M ââ[R] A) (hf : â x, f x * f x = algebraMap _ _ (Q x)) (a b : M) :
f a * f b + f b * f a = algebraMap R _ (QuadraticMap.polar Q a b) :=
calc
f a * f b + f b * f a = f (a + b) * f (a + b) - f a * f a - f b * f b := by
rw [f.map_add, mul_add, add_mul, add_mul]; abel
_ = algebraMap R _ (Q (a + b)) - algebraMap R _ (Q a) - algebraMap R _ (Q b) := by
rw [hf, hf, hf]
_ = algebraMap R _ (Q (a + b) - Q a - Q b) := by rw [â RingHom.map_sub, â RingHom.map_sub]
_ = algebraMap R _ (QuadraticMap.polar Q a b) := rfl
/-- An alternative way to provide the argument to `CliffordAlgebra.lift` when `2` is invertible.
To show a function squares to the quadratic form, it suffices to show that
`f x * f y + f y * f x = algebraMap _ _ (polar Q x y)` -/
theorem forall_mul_self_eq_iff {A : Type*} [Ring A] [Algebra R A] (h2 : IsUnit (2 : A))
(f : M ââ[R] A) :
(â x, f x * f x = algebraMap _ _ (Q x)) â
(LinearMap.mul R A).complâ f ââ f + (LinearMap.mul R A).flip.complâ f ââ f =
Q.polarBilin.comprâ (Algebra.linearMap R A) := by
simp_rw [DFunLike.ext_iff]
refine âšmul_add_swap_eq_polar_of_forall_mul_self_eq _, fun h x => ?_â©
change â x y : M, f x * f y + f y * f x = algebraMap R A (QuadraticMap.polar Q x y) at h
apply h2.mul_left_cancel
rw [two_mul, two_mul, h x x, QuadraticMap.polar_self, two_smul, map_add]
/-- The symmetric product of vectors is a scalar -/
theorem ι_mul_ι_add_swap (a b : M) :
ι Q a * ι Q b + ι Q b * ι Q a = algebraMap R _ (QuadraticMap.polar Q a b) :=
mul_add_swap_eq_polar_of_forall_mul_self_eq _ (ι_sq_scalar _) _ _
theorem ι_mul_ι_comm (a b : M) :
ι Q a * ι Q b = algebraMap R _ (QuadraticMap.polar Q a b) - ι Q b * ι Q a :=
eq_sub_of_add_eq (ι_mul_ι_add_swap a b)
section isOrtho
@[simp] theorem ι_mul_ι_add_swap_of_isOrtho {a b : M} (h : Q.IsOrtho a b) :
ι Q a * ι Q b + ι Q b * ι Q a = 0 := by
rw [ι_mul_ι_add_swap, h.polar_eq_zero]
simp
theorem ι_mul_ι_comm_of_isOrtho {a b : M} (h : Q.IsOrtho a b) :
ι Q a * ι Q b = -(ι Q b * ι Q a) :=
eq_neg_of_add_eq_zero_left <| ι_mul_ι_add_swap_of_isOrtho h
theorem mul_ι_mul_ι_of_isOrtho (x : CliffordAlgebra Q) {a b : M} (h : Q.IsOrtho a b) :
x * ι Q a * ι Q b = -(x * ι Q b * ι Q a) := by
rw [mul_assoc, ι_mul_ι_comm_of_isOrtho h, mul_neg, mul_assoc]
theorem ι_mul_ι_mul_of_isOrtho (x : CliffordAlgebra Q) {a b : M} (h : Q.IsOrtho a b) :
ι Q a * (ι Q b * x) = -(ι Q b * (ι Q a * x)) := by
rw [â mul_assoc, ι_mul_ι_comm_of_isOrtho h, neg_mul, mul_assoc]
end isOrtho
/-- $aba$ is a vector. -/
theorem ι_mul_ι_mul_ι (a b : M) :
ι Q a * ι Q b * ι Q a = ι Q (QuadraticMap.polar Q a b ⢠a - Q a ⢠b) := by
rw [ι_mul_ι_comm, sub_mul, mul_assoc, ι_sq_scalar, â Algebra.smul_def, â Algebra.commutes, â
Algebra.smul_def, â map_smul, â map_smul, â map_sub]
@[simp]
theorem ι_range_map_lift (f : M ââ[R] A) (cond : â m, f m * f m = algebraMap _ _ (Q m)) :
(LinearMap.range (ι Q)).map (lift Q âšf, condâ©).toLinearMap = LinearMap.range f := by
rw [â LinearMap.range_comp, ι_comp_lift]
section Map
variable {Mâ Mâ Mâ : Type*}
variable [AddCommGroup Mâ] [AddCommGroup Mâ] [AddCommGroup Mâ]
variable [Module R Mâ] [Module R Mâ] [Module R Mâ]
variable {Qâ : QuadraticForm R Mâ} {Qâ : QuadraticForm R Mâ} {Qâ : QuadraticForm R Mâ}
/-- Any linear map that preserves the quadratic form lifts to an `AlgHom` between algebras.
See `CliffordAlgebra.equivOfIsometry` for the case when `f` is a `QuadraticForm.IsometryEquiv`. -/
def map (f : Qâ âqáµ¢ Qâ) :
CliffordAlgebra Qâ ââ[R] CliffordAlgebra Qâ :=
CliffordAlgebra.lift Qâ
âšÎ¹ Qâ ââ f.toLinearMap, fun m => (ι_sq_scalar _ _).trans <| RingHom.congr_arg _ <| f.map_app mâ©
| @[simp]
theorem map_comp_ι (f : Qâ âqáµ¢ Qâ) :
(map f).toLinearMap ââ ι Qâ = ι Qâ ââ f.toLinearMap :=
ι_comp_lift _ _
| Mathlib/LinearAlgebra/CliffordAlgebra/Basic.lean | 292 | 295 |
/-
Copyright (c) 2024 Thomas Browning, Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning, Junyan Xu
-/
import Mathlib.Algebra.Group.Subgroup.Ker
import Mathlib.GroupTheory.GroupAction.Basic
import Mathlib.GroupTheory.GroupAction.FixedPoints
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Data.Set.Finite.Basic
/-!
# Subgroups generated by transpositions
This file studies subgroups generated by transpositions.
## Main results
- `swap_mem_closure_isSwap` : If a subgroup is generated by transpositions, then a transposition
`swap x y` lies in the subgroup if and only if `x` lies in the same orbit as `y`.
- `mem_closure_isSwap` : If a subgroup is generated by transpositions, then a permutation `f`
lies in the subgroup if and only if `f` has finite support and `f x` always lies in the same
orbit as `x`.
-/
open Equiv List MulAction Pointwise Set Subgroup
variable {G α : Type*} [Group G] [MulAction G α]
/-- If the support of each element in a generating set of a permutation group is finite,
then the support of every element in the group is finite. -/
theorem finite_compl_fixedBy_closure_iff {S : Set G} :
(â g â closure S, (fixedBy α g)á¶.Finite) â â g â S, (fixedBy α g)á¶.Finite :=
âšfun h g hg ⊠h g (subset_closure hg), fun h g hg ⊠by
refine closure_induction h (by simp) (fun g g' _ _ hg hg' ⊠(hg.union hg').subset ?_)
| (by simp) hg
simp_rw [â compl_inter, compl_subset_compl, fixedBy_mul]â©
| Mathlib/GroupTheory/Perm/ClosureSwap.lean | 37 | 39 |
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison, Andrew Yang
-/
import Mathlib.CategoryTheory.Monoidal.Functor
/-!
# Endofunctors as a monoidal category.
We give the monoidal category structure on `C ⥀ C`,
and show that when `C` itself is monoidal, it embeds via a monoidal functor into `C ⥀ C`.
## TODO
Can we use this to show coherence results, e.g. a cheap proof that `λ_ (ð_ C) = Ï_ (ð_ C)`?
I suspect this is harder than is usually made out.
-/
universe v u
namespace CategoryTheory
open Functor.LaxMonoidal Functor.OplaxMonoidal Functor.Monoidal
variable (C : Type u) [Category.{v} C]
/-- The category of endofunctors of any category is a monoidal category,
with tensor product given by composition of functors
(and horizontal composition of natural transformations).
-/
def endofunctorMonoidalCategory : MonoidalCategory (C ⥀ C) where
tensorObj F G := F â G
whiskerLeft X _ _ F := whiskerLeft X F
whiskerRight F X := whiskerRight F X
tensorHom α β := α ⫠β
tensorUnit := ð C
associator F G H := Functor.associator F G H
leftUnitor F := Functor.leftUnitor F
rightUnitor F := Functor.rightUnitor F
open CategoryTheory.MonoidalCategory
attribute [local instance] endofunctorMonoidalCategory
@[simp] theorem endofunctorMonoidalCategory_tensorUnit_obj (X : C) :
(ð_ (C ⥀ C)).obj X = X := rfl
@[simp] theorem endofunctorMonoidalCategory_tensorUnit_map {X Y : C} (f : X â¶ Y) :
(ð_ (C ⥀ C)).map f = f := rfl
@[simp] theorem endofunctorMonoidalCategory_tensorObj_obj (F G : C ⥀ C) (X : C) :
(F â G).obj X = G.obj (F.obj X) := rfl
@[simp] theorem endofunctorMonoidalCategory_tensorObj_map (F G : C ⥀ C) {X Y : C} (f : X ⶠY) :
(F â G).map f = G.map (F.map f) := rfl
@[simp] theorem endofunctorMonoidalCategory_tensorMap_app
{F G H K : C ⥀ C} {α : F ⶠG} {β : H ⶠK} (X : C) :
(α â β).app X = β.app (F.obj X) â« K.map (α.app X) := rfl
@[simp] theorem endofunctorMonoidalCategory_whiskerLeft_app
{F H K : C ⥀ C} {β : H ⶠK} (X : C) :
(F â β).app X = β.app (F.obj X) := rfl
@[simp] theorem endofunctorMonoidalCategory_whiskerRight_app
{F G H : C ⥀ C} {α : F ⶠG} (X : C) :
(α ⷠH).app X = H.map (α.app X) := rfl
@[simp] theorem endofunctorMonoidalCategory_associator_hom_app (F G H : C ⥀ C) (X : C) :
(α_ F G H).hom.app X = ð _ := rfl
@[simp] theorem endofunctorMonoidalCategory_associator_inv_app (F G H : C ⥀ C) (X : C) :
(α_ F G H).inv.app X = ð _ := rfl
@[simp] theorem endofunctorMonoidalCategory_leftUnitor_hom_app (F : C ⥀ C) (X : C) :
(λ_ F).hom.app X = ð _ := rfl
@[simp] theorem endofunctorMonoidalCategory_leftUnitor_inv_app (F : C ⥀ C) (X : C) :
(λ_ F).inv.app X = ð _ := rfl
@[simp] theorem endofunctorMonoidalCategory_rightUnitor_hom_app (F : C ⥀ C) (X : C) :
(Ï_ F).hom.app X = ð _ := rfl
@[simp] theorem endofunctorMonoidalCategory_rightUnitor_inv_app (F : C ⥀ C) (X : C) :
(Ï_ F).inv.app X = ð _ := rfl
namespace MonoidalCategory
variable [MonoidalCategory C]
/-- Tensoring on the right gives a monoidal functor from `C` into endofunctors of `C`.
-/
instance : (tensoringRight C).Monoidal :=
Functor.CoreMonoidal.toMonoidal
{ εIso := (rightUnitorNatIso C).symm
ÎŒIso := fun X Y => (isoWhiskerRight (curriedAssociatorNatIso C)
((evaluation C (C ⥀ C)).obj X â (evaluation C C).obj Y)) }
@[simp] lemma tensoringRight_ε :
ε (tensoringRight C) = (rightUnitorNatIso C).inv := rfl
@[simp] lemma tensoringRight_η :
η (tensoringRight C) = (rightUnitorNatIso C).hom := rfl
@[simp] lemma tensoringRight_Ό (X Y : C) (Z : C) :
(Ό (tensoringRight C) X Y).app Z = (α_ Z X Y).hom := rfl
@[simp] lemma tensoringRight_ÎŽ (X Y : C) (Z : C) :
(Ύ (tensoringRight C) X Y).app Z = (α_ Z X Y).inv := rfl
end MonoidalCategory
variable {C}
variable {M : Type*} [Category M] [MonoidalCategory M] (F : M ⥀ (C ⥀ C))
@[reassoc (attr := simp)]
theorem Ό_Ύ_app (i j : M) (X : C) [F.Monoidal] :
(ÎŒ F i j).app X â« (ÎŽ F i j).app X = ð _ :=
(ÎŒIso F i j).hom_inv_id_app X
@[reassoc (attr := simp)]
theorem Ύ_Ό_app (i j : M) (X : C) [F.Monoidal] :
(ÎŽ F i j).app X â« (ÎŒ F i j).app X = ð _ :=
(ÎŒIso F i j).inv_hom_id_app X
@[reassoc (attr := simp)]
theorem ε_η_app (X : C) [F.Monoidal] : (ε F).app X â« (η F).app X = ð _ :=
(εIso F).hom_inv_id_app X
@[reassoc (attr := simp)]
theorem η_ε_app (X : C) [F.Monoidal] : (η F).app X â« (ε F).app X = ð _ :=
(εIso F).inv_hom_id_app X
@[reassoc (attr := simp)]
theorem ε_naturality {X Y : C} (f : X ⶠY) [F.LaxMonoidal] :
(ε F).app X â« (F.obj (ð_ M)).map f = f â« (ε F).app Y :=
((ε F).naturality f).symm
@[reassoc (attr := simp)]
theorem η_naturality {X Y : C} (f : X ⶠY) [F.OplaxMonoidal]:
(η F).app X â« (ð_ (C ⥀ C)).map f = (η F).app X â« f := by
simp
@[reassoc (attr := simp)]
theorem Ό_naturality {m n : M} {X Y : C} (f : X ⶠY) [F.LaxMonoidal] :
(F.obj n).map ((F.obj m).map f) ⫠(Ό F m n).app Y = (Ό F m n).app X ⫠(F.obj _).map f :=
(Ό F m n).naturality f
-- This is a simp lemma in the reverse direction via `NatTrans.naturality`.
@[reassoc]
theorem ÎŽ_naturality {m n : M} {X Y : C} (f : X â¶ Y) [F.OplaxMonoidal]:
(ÎŽ F m n).app X â« (F.obj n).map ((F.obj m).map f) =
(F.obj _).map f â« (ÎŽ F m n).app Y := by simp
-- This is not a simp lemma since it could be proved by the lemmas later.
@[reassoc]
theorem ÎŒ_naturalityâ {m n m' n' : M} (f : m â¶ m') (g : n â¶ n') (X : C) [F.LaxMonoidal] :
(F.map g).app ((F.obj m).obj X) ⫠(F.obj n').map ((F.map f).app X) ⫠(Ό F m' n').app X =
(ÎŒ F m n).app X â« (F.map (f â g)).app X := by
have := congr_app (Ό_natural F f g) X
dsimp at this
simpa using this
@[reassoc (attr := simp)]
theorem ÎŒ_naturalityâ {m n m' : M} (f : m â¶ m') (X : C) [F.LaxMonoidal]:
(F.obj n).map ((F.map f).app X) ⫠(Ό F m' n).app X =
(Ό F m n).app X ⫠(F.map (f ⷠn)).app X := by
rw [â tensorHom_id, â ÎŒ_naturalityâ F f (ð n) X]
simp
@[reassoc (attr := simp)]
theorem Ό_naturalityᵣ {m n n' : M} (g : n ⶠn') (X : C) [F.LaxMonoidal] :
(F.map g).app ((F.obj m).obj X) ⫠(Ό F m n').app X =
(ÎŒ F m n).app X â« (F.map (m â g)).app X := by
rw [â id_tensorHom, â ÎŒ_naturalityâ F (ð m) g X]
simp
@[reassoc (attr := simp)]
theorem ÎŽ_naturalityâ {m n m' : M} (f : m â¶ m') (X : C) [F.OplaxMonoidal] :
(ÎŽ F m n).app X â« (F.obj n).map ((F.map f).app X) =
(F.map (f â· n)).app X â« (ÎŽ F m' n).app X :=
congr_app (ÎŽ_natural_left F f n) X
@[reassoc (attr := simp)]
theorem ÎŽ_naturalityáµ£ {m n n' : M} (g : n â¶ n') (X : C) [F.OplaxMonoidal]:
(ÎŽ F m n).app X â« (F.map g).app ((F.obj m).obj X) =
(F.map (m â g)).app X â« (ÎŽ F m n').app X :=
congr_app (ÎŽ_natural_right F m g) X
@[reassoc]
theorem left_unitality_app (n : M) (X : C) [F.LaxMonoidal]:
(F.obj n).map ((ε F).app X) â« (ÎŒ F (ð_ M) n).app X â« (F.map (λ_ n).hom).app X = ð _ :=
congr_app (left_unitality F n).symm X
@[simp, reassoc]
theorem obj_ε_app (n : M) (X : C) [F.Monoidal]:
(F.obj n).map ((ε F).app X) = (F.map (λ_ n).inv).app X â« (ÎŽ F (ð_ M) n).app X := by
rw [map_leftUnitor_inv]
dsimp
simp only [Category.id_comp, Category.assoc, Ό_Ύ_app, endofunctorMonoidalCategory_tensorObj_obj,
Category.comp_id]
@[simp, reassoc]
theorem obj_η_app (n : M) (X : C) [F.Monoidal] :
(F.obj n).map ((η F).app X) = (ÎŒ F (ð_ M) n).app X â« (F.map (λ_ n).hom).app X := by
rw [â cancel_mono ((F.obj n).map ((ε F).app X)), â Functor.map_comp]
simp
@[reassoc]
theorem right_unitality_app (n : M) (X : C) [F.Monoidal] :
(ε F).app ((F.obj n).obj X) â« (ÎŒ F n (ð_ M)).app X â« (F.map (Ï_ n).hom).app X = ð _ :=
congr_app (Functor.LaxMonoidal.right_unitality F n).symm X
@[simp]
theorem ε_app_obj (n : M) (X : C) [F.Monoidal] :
(ε F).app ((F.obj n).obj X) = (F.map (Ï_ n).inv).app X â« (ÎŽ F n (ð_ M)).app X := by
rw [map_rightUnitor_inv]
dsimp
simp only [Category.id_comp, Category.assoc, Ό_Ύ_app,
endofunctorMonoidalCategory_tensorObj_obj, Category.comp_id]
@[simp]
theorem η_app_obj (n : M) (X : C) [F.Monoidal] :
(η F).app ((F.obj n).obj X) = (ÎŒ F n (ð_ M)).app X â« (F.map (Ï_ n).hom).app X := by
rw [map_rightUnitor]
dsimp
simp only [Category.comp_id, Ό_Ύ_app_assoc]
@[reassoc]
theorem associativity_app (mâ mâ mâ : M) (X : C) [F.LaxMonoidal] :
(F.obj mâ).map ((ÎŒ F mâ mâ).app X) â«
(ÎŒ F (mâ â mâ) mâ).app X â« (F.map (α_ mâ mâ mâ).hom).app X =
| (ÎŒ F mâ mâ).app ((F.obj mâ).obj X) â« (ÎŒ F mâ (mâ â mâ)).app X := by
have := congr_app (associativity F mâ mâ mâ) X
dsimp at this
simpa using this
| Mathlib/CategoryTheory/Monoidal/End.lean | 235 | 238 |
/-
Copyright (c) 2023 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Lorenzo Luccioli, Rémy Degenne, Alexander Bentkamp
-/
import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform
import Mathlib.Probability.Moments.ComplexMGF
/-!
# Gaussian distributions over â
We define a Gaussian measure over the reals.
## Main definitions
* `gaussianPDFReal`: the function `Ό v x ⊠(1 / (sqrt (2 * pi * v))) * exp (- (x - Ό)^2 / (2 * v))`,
which is the probability density function of a Gaussian distribution with mean `Ό` and
variance `v` (when `v â 0`).
* `gaussianPDF`: `ââ¥0â`-valued pdf, `gaussianPDF ÎŒ v x = ENNReal.ofReal (gaussianPDFReal ÎŒ v x)`.
* `gaussianReal`: a Gaussian measure on `â`, parametrized by its mean `ÎŒ` and variance `v`.
If `v = 0`, this is `dirac Ό`, otherwise it is defined as the measure with density
`gaussianPDF Ό v` with respect to the Lebesgue measure.
## Main results
* `gaussianReal_add_const`: if `X` is a random variable with Gaussian distribution with mean `Ό` and
variance `v`, then `X + y` is Gaussian with mean `Ό + y` and variance `v`.
* `gaussianReal_const_mul`: if `X` is a random variable with Gaussian distribution with mean `Ό` and
variance `v`, then `c * X` is Gaussian with mean `c * Ό` and variance `c^2 * v`.
-/
open scoped ENNReal NNReal Real Complex
open MeasureTheory
namespace ProbabilityTheory
section GaussianPDF
/-- Probability density function of the gaussian distribution with mean `Ό` and variance `v`. -/
noncomputable
def gaussianPDFReal (ÎŒ : â) (v : ââ¥0) (x : â) : â :=
(â(2 * Ï * v))â»Â¹ * rexp (- (x - ÎŒ)^2 / (2 * v))
lemma gaussianPDFReal_def (ÎŒ : â) (v : ââ¥0) :
gaussianPDFReal Ό v =
fun x ⊠(Real.sqrt (2 * Ï * v))â»Â¹ * rexp (- (x - ÎŒ)^2 / (2 * v)) := rfl
@[simp]
lemma gaussianPDFReal_zero_var (m : â) : gaussianPDFReal m 0 = 0 := by
ext1 x
simp [gaussianPDFReal]
/-- The gaussian pdf is positive when the variance is not zero. -/
lemma gaussianPDFReal_pos (ÎŒ : â) (v : ââ¥0) (x : â) (hv : v â 0) : 0 < gaussianPDFReal ÎŒ v x := by
rw [gaussianPDFReal]
positivity
/-- The gaussian pdf is nonnegative. -/
lemma gaussianPDFReal_nonneg (ÎŒ : â) (v : ââ¥0) (x : â) : 0 †gaussianPDFReal ÎŒ v x := by
rw [gaussianPDFReal]
positivity
/-- The gaussian pdf is measurable. -/
lemma measurable_gaussianPDFReal (ÎŒ : â) (v : ââ¥0) : Measurable (gaussianPDFReal ÎŒ v) :=
(((measurable_id.add_const _).pow_const _).neg.div_const _).exp.const_mul _
/-- The gaussian pdf is strongly measurable. -/
lemma stronglyMeasurable_gaussianPDFReal (ÎŒ : â) (v : ââ¥0) :
StronglyMeasurable (gaussianPDFReal Ό v) :=
(measurable_gaussianPDFReal Ό v).stronglyMeasurable
@[fun_prop]
lemma integrable_gaussianPDFReal (ÎŒ : â) (v : ââ¥0) :
Integrable (gaussianPDFReal Ό v) := by
rw [gaussianPDFReal_def]
by_cases hv : v = 0
· simp [hv]
let g : â â â := fun x ⊠(â(2 * Ï * v))â»Â¹ * rexp (- x ^ 2 / (2 * v))
have hg : Integrable g := by
suffices g = fun x ⊠(â(2 * Ï * v))â»Â¹ * rexp (- (2 * v)â»Â¹ * x ^ 2) by
rw [this]
refine (integrable_exp_neg_mul_sq ?_).const_mul (â(2 * Ï * v))â»Â¹
simp [lt_of_le_of_ne (zero_le _) (Ne.symm hv)]
ext x
simp only [g, zero_lt_two, mul_nonneg_iff_of_pos_left, NNReal.zero_le_coe, Real.sqrt_mul',
mul_inv_rev, NNReal.coe_mul, NNReal.coe_inv, NNReal.coe_ofNat, neg_mul, mul_eq_mul_left_iff,
Real.exp_eq_exp, mul_eq_zero, inv_eq_zero, Real.sqrt_eq_zero, NNReal.coe_eq_zero, hv,
false_or]
rw [mul_comm]
left
field_simp
exact Integrable.comp_sub_right hg Ό
/-- The gaussian distribution pdf integrates to 1 when the variance is not zero. -/
lemma lintegral_gaussianPDFReal_eq_one (ÎŒ : â) {v : ââ¥0} (h : v â 0) :
â«â» x, ENNReal.ofReal (gaussianPDFReal ÎŒ v x) = 1 := by
rw [â ENNReal.toReal_eq_one_iff]
have hfm : AEStronglyMeasurable (gaussianPDFReal Ό v) volume :=
(stronglyMeasurable_gaussianPDFReal Ό v).aestronglyMeasurable
have hf : 0 â€ââ gaussianPDFReal ÎŒ v := ae_of_all _ (gaussianPDFReal_nonneg ÎŒ v)
rw [â integral_eq_lintegral_of_nonneg_ae hf hfm]
simp only [gaussianPDFReal, zero_lt_two, mul_nonneg_iff_of_pos_right, one_div,
Nat.cast_ofNat, integral_const_mul]
rw [integral_sub_right_eq_self (ÎŒ := volume) (fun a ⊠rexp (-a ^ 2 / ((2 : â) * v))) ÎŒ]
simp only [zero_lt_two, mul_nonneg_iff_of_pos_right, div_eq_inv_mul, mul_inv_rev,
mul_neg]
simp_rw [â neg_mul]
rw [neg_mul, integral_gaussian, â Real.sqrt_inv, â Real.sqrt_mul]
· field_simp
ring
· positivity
| /-- The gaussian distribution pdf integrates to 1 when the variance is not zero. -/
lemma integral_gaussianPDFReal_eq_one (ÎŒ : â) {v : ââ¥0} (hv : v â 0) :
⫠x, gaussianPDFReal Ό v x = 1 := by
have h := lintegral_gaussianPDFReal_eq_one Ό hv
rw [â ofReal_integral_eq_lintegral_ofReal (integrable_gaussianPDFReal _ _)
(ae_of_all _ (gaussianPDFReal_nonneg _ _)), â ENNReal.ofReal_one] at h
rwa [â ENNReal.ofReal_eq_ofReal_iff (integral_nonneg (gaussianPDFReal_nonneg _ _)) zero_le_one]
| Mathlib/Probability/Distributions/Gaussian.lean | 115 | 121 |
/-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Edward Ayers
-/
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.HasPullback
import Mathlib.Data.Set.BooleanAlgebra
/-!
# Theory of sieves
- For an object `X` of a category `C`, a `Sieve X` is a set of morphisms to `X`
which is closed under left-composition.
- The complete lattice structure on sieves is given, as well as the Galois insertion
given by downward-closing.
- A `Sieve X` (functorially) induces a presheaf on `C` together with a monomorphism to
the yoneda embedding of `X`.
## Tags
sieve, pullback
-/
universe vâ vâ vâ uâ uâ uâ
namespace CategoryTheory
open Category Limits
variable {C : Type uâ} [Category.{vâ} C] {D : Type uâ} [Category.{vâ} D] (F : C ⥀ D)
variable {X Y Z : C} (f : Y â¶ X)
/-- A set of arrows all with codomain `X`. -/
def Presieve (X : C) :=
â âŠYâŠ, Set (Y â¶ X)-- deriving CompleteLattice
instance : CompleteLattice (Presieve X) := by
dsimp [Presieve]
infer_instance
namespace Presieve
noncomputable instance : Inhabited (Presieve X) :=
âšâ€â©
/-- The full subcategory of the over category `C/X` consisting of arrows which belong to a
presieve on `X`. -/
abbrev category {X : C} (P : Presieve X) :=
ObjectProperty.FullSubcategory fun f : Over X => P f.hom
/-- Construct an object of `P.category`. -/
abbrev categoryMk {X : C} (P : Presieve X) {Y : C} (f : Y â¶ X) (hf : P f) : P.category :=
âšOver.mk f, hfâ©
/-- Given a sieve `S` on `X : C`, its associated diagram `S.diagram` is defined to be
the natural functor from the full subcategory of the over category `C/X` consisting
of arrows in `S` to `C`. -/
abbrev diagram (S : Presieve X) : S.category ⥀ C :=
ObjectProperty.ι _ â Over.forget X
/-- Given a sieve `S` on `X : C`, its associated cocone `S.cocone` is defined to be
the natural cocone over the diagram defined above with cocone point `X`. -/
abbrev cocone (S : Presieve X) : Cocone S.diagram :=
(Over.forgetCocone X).whisker (ObjectProperty.ι _)
/-- Given a set of arrows `S` all with codomain `X`, and a set of arrows with codomain `Y` for each
`f : Y â¶ X` in `S`, produce a set of arrows with codomain `X`:
`{ g â« f | (f : Y â¶ X) â S, (g : Z â¶ Y) â R f }`.
-/
def bind (S : Presieve X) (R : â âŠY⊠âŠf : Y â¶ XâŠ, S f â Presieve Y) : Presieve X := fun Z h =>
â (Y : C) (g : Z â¶ Y) (f : Y â¶ X) (H : S f), R H g â§ g â« f = h
/-- Structure which contains the data and properties for a morphism `h` satisfying
`Presieve.bind S R h`. -/
structure BindStruct (S : Presieve X) (R : â âŠY⊠âŠf : Y â¶ XâŠ, S f â Presieve Y)
{Z : C} (h : Z â¶ X) where
/-- the intermediate object -/
Y : C
/-- a morphism in the family of presieves `R` -/
g : Z â¶ Y
/-- a morphism in the presieve `S` -/
f : Y â¶ X
hf : S f
hg : R hf g
fac : g â« f = h
attribute [reassoc (attr := simp)] BindStruct.fac
/-- If a morphism `h` satisfies `Presieve.bind S R h`, this is a choice of a structure
in `BindStruct S R h`. -/
noncomputable def bind.bindStruct {S : Presieve X} {R : â âŠY⊠âŠf : Y â¶ XâŠ, S f â Presieve Y}
{Z : C} {h : Z â¶ X} (H : bind S R h) : BindStruct S R h :=
Nonempty.some (by
obtain âšY, g, f, hf, hg, facâ© := H
exact âš{ hf := hf, hg := hg, fac := fac, .. }â©)
lemma BindStruct.bind {S : Presieve X} {R : â âŠY⊠âŠf : Y â¶ XâŠ, S f â Presieve Y}
{Z : C} {h : Z â¶ X} (b : BindStruct S R h) : bind S R h :=
âšb.Y, b.g, b.f, b.hf, b.hg, b.facâ©
@[simp]
theorem bind_comp {S : Presieve X} {R : â âŠY : C⊠âŠf : Y â¶ XâŠ, S f â Presieve Y} {g : Z â¶ Y}
(hâ : S f) (hâ : R hâ g) : bind S R (g â« f) :=
âš_, _, _, hâ, hâ, rflâ©
-- Porting note: it seems the definition of `Presieve` must be unfolded in order to define
-- this inductive type, it was thus renamed `singleton'`
-- Note we can't make this into `HasSingleton` because of the out-param.
/-- The singleton presieve. -/
inductive singleton' : âŠY : C⊠â (Y â¶ X) â Prop
| mk : singleton' f
/-- The singleton presieve. -/
def singleton : Presieve X := singleton' f
lemma singleton.mk {f : Y â¶ X} : singleton f f := singleton'.mk
@[simp]
theorem singleton_eq_iff_domain (f g : Y â¶ X) : singleton f g â f = g := by
constructor
· rintro âša, rflâ©
rfl
· rintro rfl
apply singleton.mk
theorem singleton_self : singleton f f :=
singleton.mk
/-- Pullback a set of arrows with given codomain along a fixed map, by taking the pullback in the
category.
This is not the same as the arrow set of `Sieve.pullback`, but there is a relation between them
in `pullbackArrows_comm`.
-/
inductive pullbackArrows [HasPullbacks C] (R : Presieve X) : Presieve Y
| mk (Z : C) (h : Z â¶ X) : R h â pullbackArrows _ (pullback.snd h f)
theorem pullback_singleton [HasPullbacks C] (g : Z â¶ X) :
pullbackArrows f (singleton g) = singleton (pullback.snd g f) := by
funext W
ext h
constructor
· rintro âšW, _, _, _â©
exact singleton.mk
· rintro âš_â©
exact pullbackArrows.mk Z g singleton.mk
/-- Construct the presieve given by the family of arrows indexed by `ι`. -/
inductive ofArrows {ι : Type*} (Y : ι â C) (f : â i, Y i â¶ X) : Presieve X
| mk (i : ι) : ofArrows _ _ (f i)
theorem ofArrows_pUnit : (ofArrows _ fun _ : PUnit => f) = singleton f := by
funext Y
ext g
constructor
· rintro âš_â©
apply singleton.mk
· rintro âš_â©
exact ofArrows.mk PUnit.unit
theorem ofArrows_pullback [HasPullbacks C] {ι : Type*} (Z : ι â C) (g : â i : ι, Z i â¶ X) :
(ofArrows (fun i => pullback (g i) f) fun _ => pullback.snd _ _) =
pullbackArrows f (ofArrows Z g) := by
funext T
ext h
constructor
· rintro âšhkâ©
exact pullbackArrows.mk _ _ (ofArrows.mk hk)
· rintro âšW, k, âš_â©â©
apply ofArrows.mk
theorem ofArrows_bind {ι : Type*} (Z : ι â C) (g : â i : ι, Z i â¶ X)
(j : â âŠY⊠(f : Y â¶ X), ofArrows Z g f â Type*) (W : â âŠY⊠(f : Y â¶ X) (H), j f H â C)
(k : â âŠY⊠(f : Y â¶ X) (H i), W f H i â¶ Y) :
((ofArrows Z g).bind fun _ f H => ofArrows (W f H) (k f H)) =
ofArrows (fun i : Σi, j _ (ofArrows.mk i) => W (g i.1) _ i.2) fun ij =>
k (g ij.1) _ ij.2 â« g ij.1 := by
funext Y
ext f
constructor
· rintro âš_, _, _, âšiâ©, âši'â©, rflâ©
exact ofArrows.mk (Sigma.mk _ _)
· rintro âšiâ©
exact bind_comp _ (ofArrows.mk _) (ofArrows.mk _)
theorem ofArrows_surj {ι : Type*} {Y : ι â C} (f : â i, Y i â¶ X) {Z : C} (g : Z â¶ X)
(hg : ofArrows Y f g) : â (i : ι) (h : Y i = Z),
g = eqToHom h.symm â« f i := by
obtain âšiâ© := hg
exact âši, rfl, by simp only [eqToHom_refl, id_comp]â©
/-- Given a presieve on `F(X)`, we can define a presieve on `X` by taking the preimage via `F`. -/
def functorPullback (R : Presieve (F.obj X)) : Presieve X := fun _ f => R (F.map f)
@[simp]
theorem functorPullback_mem (R : Presieve (F.obj X)) {Y} (f : Y â¶ X) :
R.functorPullback F f â R (F.map f) :=
Iff.rfl
@[simp]
theorem functorPullback_id (R : Presieve X) : R.functorPullback (ð _) = R :=
rfl
/-- Given a presieve `R` on `X`, the predicate `R.hasPullbacks` means that for all arrows `f` and
`g` in `R`, the pullback of `f` and `g` exists. -/
class hasPullbacks (R : Presieve X) : Prop where
/-- For all arrows `f` and `g` in `R`, the pullback of `f` and `g` exists. -/
has_pullbacks : â {Y Z} {f : Y â¶ X} (_ : R f) {g : Z â¶ X} (_ : R g), HasPullback f g
instance (R : Presieve X) [HasPullbacks C] : R.hasPullbacks := âšfun _ _ ⊠inferInstanceâ©
instance {α : Type vâ} {X : α â C} {B : C} (Ï : (a : α) â X a â¶ B)
[(Presieve.ofArrows X Ï).hasPullbacks] (a b : α) : HasPullback (Ï a) (Ï b) :=
Presieve.hasPullbacks.has_pullbacks (Presieve.ofArrows.mk _) (Presieve.ofArrows.mk _)
section FunctorPushforward
variable {E : Type uâ} [Category.{vâ} E] (G : D ⥀ E)
/-- Given a presieve on `X`, we can define a presieve on `F(X)` (which is actually a sieve)
by taking the sieve generated by the image via `F`.
-/
def functorPushforward (S : Presieve X) : Presieve (F.obj X) := fun Y f =>
â (Z : C) (g : Z â¶ X) (h : Y â¶ F.obj Z), S g â§ f = h â« F.map g
/-- An auxiliary definition in order to fix the choice of the preimages between various definitions.
-/
structure FunctorPushforwardStructure (S : Presieve X) {Y} (f : Y â¶ F.obj X) where
/-- an object in the source category -/
preobj : C
/-- a map in the source category which has to be in the presieve -/
premap : preobj â¶ X
/-- the morphism which appear in the factorisation -/
lift : Y â¶ F.obj preobj
/-- the condition that `premap` is in the presieve -/
cover : S premap
/-- the factorisation of the morphism -/
fac : f = lift â« F.map premap
/-- The fixed choice of a preimage. -/
noncomputable def getFunctorPushforwardStructure {F : C ⥀ D} {S : Presieve X} {Y : D}
{f : Y â¶ F.obj X} (h : S.functorPushforward F f) : FunctorPushforwardStructure F S f := by
choose Z f' g hâ h using h
exact âšZ, f', g, hâ, hâ©
theorem functorPushforward_comp (R : Presieve X) :
R.functorPushforward (F â G) = (R.functorPushforward F).functorPushforward G := by
funext x
ext f
constructor
· rintro âšX, fâ, gâ, hâ, rflâ©
exact âšF.obj X, F.map fâ, gâ, âšX, fâ, ð _, hâ, by simpâ©, rflâ©
· rintro âšX, fâ, gâ, âšX', fâ, gâ, hâ, rflâ©, rflâ©
exact âšX', fâ, gâ â« G.map gâ, hâ, by simpâ©
theorem image_mem_functorPushforward (R : Presieve X) {f : Y â¶ X} (h : R f) :
R.functorPushforward F (F.map f) :=
âšY, f, ð _, h, by simpâ©
end FunctorPushforward
end Presieve
/--
For an object `X` of a category `C`, a `Sieve X` is a set of morphisms to `X` which is closed under
left-composition.
-/
structure Sieve {C : Type uâ} [Category.{vâ} C] (X : C) where
/-- the underlying presieve -/
arrows : Presieve X
/-- stability by precomposition -/
downward_closed : â {Y Z f} (_ : arrows f) (g : Z â¶ Y), arrows (g â« f)
namespace Sieve
instance : CoeFun (Sieve X) fun _ => Presieve X :=
âšSieve.arrowsâ©
initialize_simps_projections Sieve (arrows â apply)
variable {S R : Sieve X}
attribute [simp] downward_closed
theorem arrows_ext : â {R S : Sieve X}, R.arrows = S.arrows â R = S := by
rintro âš_, _â© âš_, _â© rfl
rfl
@[ext]
protected theorem ext {R S : Sieve X} (h : â âŠY⊠(f : Y â¶ X), R f â S f) : R = S :=
arrows_ext <| funext fun _ => funext fun f => propext <| h f
open Lattice
/-- The supremum of a collection of sieves: the union of them all. -/
protected def sup (ð® : Set (Sieve X)) : Sieve X where
arrows _ := { f | â S â ð®, Sieve.arrows S f }
downward_closed {_ _ f} hf _ := by
obtain âšS, hS, hfâ© := hf
exact âšS, hS, S.downward_closed hf _â©
/-- The infimum of a collection of sieves: the intersection of them all. -/
protected def inf (ð® : Set (Sieve X)) : Sieve X where
arrows _ := { f | â S â ð®, Sieve.arrows S f }
downward_closed {_ _ _} hf g S H := S.downward_closed (hf S H) g
/-- The union of two sieves is a sieve. -/
protected def union (S R : Sieve X) : Sieve X where
arrows _ f := S f âš R f
downward_closed := by rintro _ _ _ (h | h) g <;> simp [h]
/-- The intersection of two sieves is a sieve. -/
protected def inter (S R : Sieve X) : Sieve X where
arrows _ f := S f â§ R f
downward_closed := by
rintro _ _ _ âšhâ, hââ© g
simp [hâ, hâ]
/-- Sieves on an object `X` form a complete lattice.
We generate this directly rather than using the galois insertion for nicer definitional properties.
-/
instance : CompleteLattice (Sieve X) where
le S R := â âŠY⊠(f : Y â¶ X), S f â R f
le_refl _ _ _ := id
le_trans _ _ _ Sââ Sââ _ _ h := Sââ _ (Sââ _ h)
le_antisymm _ _ p q := Sieve.ext fun _ _ => âšp _, q _â©
top :=
{ arrows := fun _ => Set.univ
downward_closed := fun _ _ => âšâ© }
bot :=
{ arrows := fun _ => â
downward_closed := False.elim }
sup := Sieve.union
inf := Sieve.inter
sSup := Sieve.sup
sInf := Sieve.inf
le_sSup _ S hS _ _ hf := âšS, hS, hfâ©
sSup_le := fun _ _ ha _ _ âšb, hb, hfâ© => (ha b hb) _ hf
sInf_le _ _ hS _ _ h := h _ hS
le_sInf _ _ hS _ _ hf _ hR := hS _ hR _ hf
le_sup_left _ _ _ _ := Or.inl
le_sup_right _ _ _ _ := Or.inr
sup_le _ _ _ hâ hâ _ f := by--â° S hS Y f := by
rintro (hf | hf)
· exact hâ _ hf
· exact hâ _ hf
inf_le_left _ _ _ _ := And.left
inf_le_right _ _ _ _ := And.right
le_inf _ _ _ p q _ _ z := âšp _ z, q _ zâ©
le_top _ _ _ _ := trivial
bot_le _ _ _ := False.elim
/-- The maximal sieve always exists. -/
instance sieveInhabited : Inhabited (Sieve X) :=
âšâ€â©
@[simp]
theorem sInf_apply {Ss : Set (Sieve X)} {Y} (f : Y â¶ X) :
sInf Ss f â â (S : Sieve X) (_ : S â Ss), S f :=
Iff.rfl
@[simp]
theorem sSup_apply {Ss : Set (Sieve X)} {Y} (f : Y â¶ X) :
sSup Ss f â â (S : Sieve X) (_ : S â Ss), S f := by
simp [sSup, Sieve.sup, setOf]
@[simp]
theorem inter_apply {R S : Sieve X} {Y} (f : Y â¶ X) : (R â S) f â R f â§ S f :=
Iff.rfl
@[simp]
theorem union_apply {R S : Sieve X} {Y} (f : Y â¶ X) : (R â S) f â R f âš S f :=
Iff.rfl
@[simp]
theorem top_apply (f : Y ⶠX) : (†: Sieve X) f :=
trivial
/-- Generate the smallest sieve containing the given set of arrows. -/
@[simps]
def generate (R : Presieve X) : Sieve X where
arrows Z f := â (Y : _) (h : Z â¶ Y) (g : Y â¶ X), R g â§ h â« g = f
downward_closed := by
rintro Y Z _ âšW, g, f, hf, rflâ© h
exact âš_, h â« g, _, hf, by simpâ©
/-- Given a presieve on `X`, and a sieve on each domain of an arrow in the presieve, we can bind to
produce a sieve on `X`.
-/
@[simps]
def bind (S : Presieve X) (R : â âŠY⊠âŠf : Y â¶ XâŠ, S f â Sieve Y) : Sieve X where
arrows := S.bind fun _ _ h => R h
downward_closed := by
rintro Y Z f âšW, f, h, hh, hf, rflâ© g
exact âš_, g â« f, _, hh, by simp [hf]â©
/-- Structure which contains the data and properties for a morphism `h` satisfying
`Sieve.bind S R h`. -/
abbrev BindStruct (S : Presieve X) (R : â âŠY⊠âŠf : Y â¶ XâŠ, S f â Sieve Y)
{Z : C} (h : Z â¶ X) :=
Presieve.BindStruct S (fun _ _ hf ⊠R hf) h
open Order Lattice
theorem generate_le_iff (R : Presieve X) (S : Sieve X) : generate R †S â R †S :=
âšfun H _ _ hg => H _ âš_, ð _, _, hg, id_comp _â©, fun ss Y f => by
rintro âšZ, f, g, hg, rflâ©
exact S.downward_closed (ss Z hg) fâ©
/-- Show that there is a galois insertion (generate, set_over). -/
def giGenerate : GaloisInsertion (generate : Presieve X â Sieve X) arrows where
gc := generate_le_iff
choice ð¢ _ := generate ð¢
choice_eq _ _ := rfl
le_l_u _ _ _ hf := âš_, ð _, _, hf, id_comp _â©
theorem le_generate (R : Presieve X) : R †generate R :=
giGenerate.gc.le_u_l R
@[simp]
theorem generate_sieve (S : Sieve X) : generate S = S :=
giGenerate.l_u_eq S
/-- If the identity arrow is in a sieve, the sieve is maximal. -/
theorem id_mem_iff_eq_top : S (ð X) â S = †:=
âšfun h => top_unique fun Y f _ => by simpa using downward_closed _ h f, fun h => h.symm âž trivialâ©
/-- If an arrow set contains a split epi, it generates the maximal sieve. -/
theorem generate_of_contains_isSplitEpi {R : Presieve X} (f : Y â¶ X) [IsSplitEpi f] (hf : R f) :
generate R = †:= by
rw [â id_mem_iff_eq_top]
exact âš_, section_ f, f, hf, by simpâ©
@[simp]
theorem generate_of_singleton_isSplitEpi (f : Y â¶ X) [IsSplitEpi f] :
generate (Presieve.singleton f) = †:=
generate_of_contains_isSplitEpi f (Presieve.singleton_self _)
@[simp]
theorem generate_top : generate (†: Presieve X) = †:=
generate_of_contains_isSplitEpi (ð _) âšâ©
@[simp]
lemma comp_mem_iff (i : X â¶ Y) (f : Y â¶ Z) [IsIso i] (S : Sieve Z) :
S (i â« f) â S f := by
refine âšfun H ⊠?_, fun H ⊠S.downward_closed H _â©
convert S.downward_closed H (inv i)
simp
section
variable {I : Type*} {X : C} (Y : I â C) (f : â i, Y i â¶ X)
/-- The sieve of `X` generated by family of morphisms `Y i â¶ X`. -/
abbrev ofArrows : Sieve X := generate (Presieve.ofArrows Y f)
lemma ofArrows_mk (i : I) : ofArrows Y f (f i) :=
âš_, ð _, _, âšiâ©, by simpâ©
lemma mem_ofArrows_iff {W : C} (g : W â¶ X) :
ofArrows Y f g â â (i : I) (a : W â¶ Y i), g = a â« f i := by
constructor
· rintro âšT, a, b, âšiâ©, rflâ©
exact âši, a, rflâ©
· rintro âši, a, rflâ©
apply downward_closed _ (ofArrows_mk Y f i)
variable {Y f} {W : C} {g : W â¶ X} (hg : ofArrows Y f g)
include hg in
lemma ofArrows.exists : â (i : I) (h : W â¶ Y i), g = h â« f i := by
obtain âš_, h, _, âšiâ©, rflâ© := hg
exact âši, h, rflâ©
/-- When `hg : Sieve.ofArrows Y f g`, this is a choice of `i` such that `g`
factors through `f i`. -/
noncomputable def ofArrows.i : I := (ofArrows.exists hg).choose
/-- When `hg : Sieve.ofArrows Y f g`, this is a morphism `h : W â¶ Y (i hg)` such
that `h â« f (i hg) = g`. -/
noncomputable def ofArrows.h : W â¶ Y (i hg) := (ofArrows.exists hg).choose_spec.choose
@[reassoc (attr := simp)]
lemma ofArrows.fac : h hg â« f (i hg) = g :=
(ofArrows.exists hg).choose_spec.choose_spec.symm
end
/-- The sieve generated by two morphisms. -/
abbrev ofTwoArrows {U V X : C} (i : U â¶ X) (j : V â¶ X) : Sieve X :=
Sieve.ofArrows (Y := pairFunction U V) (fun k ⊠WalkingPair.casesOn k i j)
/-- The sieve of `X : C` that is generated by a family of objects `Y : I â C`:
it consists of morphisms to `X` which factor through at least one of the `Y i`. -/
def ofObjects {I : Type*} (Y : I â C) (X : C) : Sieve X where
arrows Z _ := â (i : I), Nonempty (Z â¶ Y i)
downward_closed := by
rintro Zâ Zâ p âši, âšfâ©â© g
exact âši, âšg â« fâ©â©
lemma mem_ofObjects_iff {I : Type*} (Y : I â C) {Z X : C} (g : Z â¶ X) :
ofObjects Y X g â â (i : I), Nonempty (Z â¶ Y i) := by rfl
lemma ofArrows_le_ofObjects
{I : Type*} (Y : I â C) {X : C} (f : â i, Y i â¶ X) :
Sieve.ofArrows Y f †Sieve.ofObjects Y X := by
intro W g hg
rw [mem_ofArrows_iff] at hg
obtain âši, a, rflâ© := hg
exact âši, âšaâ©â©
lemma ofArrows_eq_ofObjects {X : C} (hX : IsTerminal X)
{I : Type*} (Y : I â C) (f : â i, Y i â¶ X) :
ofArrows Y f = ofObjects Y X := by
refine le_antisymm (ofArrows_le_ofObjects Y f) (fun W g => ?_)
rw [mem_ofArrows_iff, mem_ofObjects_iff]
rintro âši, âšhâ©â©
exact âši, h, hX.hom_ext _ _â©
/-- Given a morphism `h : Y â¶ X`, send a sieve S on X to a sieve on Y
as the inverse image of S with `_ â« h`.
That is, `Sieve.pullback S h := (â« h) 'â»Â¹ S`. -/
@[simps]
def pullback (h : Y â¶ X) (S : Sieve X) : Sieve Y where
arrows _ sl := S (sl â« h)
downward_closed g := by simp [g]
@[simp]
theorem pullback_id : S.pullback (ð _) = S := by simp [Sieve.ext_iff]
@[simp]
theorem pullback_top {f : Y ⶠX} : (†: Sieve X).pullback f = †:=
top_unique fun _ _ => id
theorem pullback_comp {f : Y â¶ X} {g : Z â¶ Y} (S : Sieve X) :
S.pullback (g â« f) = (S.pullback f).pullback g := by simp [Sieve.ext_iff]
@[simp]
theorem pullback_inter {f : Y â¶ X} (S R : Sieve X) :
(S â R).pullback f = S.pullback f â R.pullback f := by simp [Sieve.ext_iff]
theorem mem_iff_pullback_eq_top (f : Y â¶ X) : S f â S.pullback f = †:= by
rw [â id_mem_iff_eq_top, pullback_apply, id_comp]
@[deprecated (since := "2025-02-28")]
alias pullback_eq_top_iff_mem := mem_iff_pullback_eq_top
theorem pullback_eq_top_of_mem (S : Sieve X) {f : Y â¶ X} : S f â S.pullback f = †:=
(mem_iff_pullback_eq_top f).1
lemma pullback_ofObjects_eq_top
{I : Type*} (Y : I â C) {X : C} {i : I} (g : X â¶ Y i) :
ofObjects Y X = †:= by
ext Z h
simp only [top_apply, iff_true]
rw [mem_ofObjects_iff ]
exact âši, âšh â« gâ©â©
/-- Push a sieve `R` on `Y` forward along an arrow `f : Y â¶ X`: `gf : Z â¶ X` is in the sieve if `gf`
factors through some `g : Z â¶ Y` which is in `R`.
-/
@[simps]
def pushforward (f : Y â¶ X) (R : Sieve Y) : Sieve X where
arrows _ gf := â g, g â« f = gf â§ R g
downward_closed := fun âšj, k, zâ© h => âšh â« j, by simp [k], by simp [z]â©
theorem pushforward_apply_comp {R : Sieve Y} {Z : C} {g : Z â¶ Y} (hg : R g) (f : Y â¶ X) :
R.pushforward f (g â« f) :=
âšg, rfl, hgâ©
theorem pushforward_comp {f : Y â¶ X} {g : Z â¶ Y} (R : Sieve Z) :
R.pushforward (g â« f) = (R.pushforward g).pushforward f :=
Sieve.ext fun W h =>
âšfun âšfâ, hq, hfââ© => âšfâ â« g, by simpa, fâ, rfl, hfââ©, fun âšy, hy, z, hR, hzâ© =>
âšz, by rw [â Category.assoc, hR]; tautoâ©â©
theorem galoisConnection (f : Y â¶ X) : GaloisConnection (Sieve.pushforward f) (Sieve.pullback f) :=
fun _ _ => âšfun hR _ g hg => hR _ âšg, rfl, hgâ©, fun hS _ _ âšh, hg, hhâ© => hg âž hS h hhâ©
theorem pullback_monotone (f : Y â¶ X) : Monotone (Sieve.pullback f) :=
(galoisConnection f).monotone_u
theorem pushforward_monotone (f : Y â¶ X) : Monotone (Sieve.pushforward f) :=
(galoisConnection f).monotone_l
theorem le_pushforward_pullback (f : Y ⶠX) (R : Sieve Y) : R †(R.pushforward f).pullback f :=
(galoisConnection f).le_u_l _
theorem pullback_pushforward_le (f : Y ⶠX) (R : Sieve X) : (R.pullback f).pushforward f †R :=
(galoisConnection f).l_u_le _
theorem pushforward_union {f : Y â¶ X} (S R : Sieve Y) :
(S â R).pushforward f = S.pushforward f â R.pushforward f :=
(galoisConnection f).l_sup
theorem pushforward_le_bind_of_mem (S : Presieve X) (R : â âŠY : C⊠âŠf : Y â¶ XâŠ, S f â Sieve Y)
(f : Y ⶠX) (h : S f) : (R h).pushforward f †bind S R := by
rintro Z _ âšg, rfl, hgâ©
exact âš_, g, f, h, hg, rflâ©
theorem le_pullback_bind (S : Presieve X) (R : â âŠY : C⊠âŠf : Y â¶ XâŠ, S f â Sieve Y) (f : Y â¶ X)
(h : S f) : R h †(bind S R).pullback f := by
rw [â galoisConnection f]
apply pushforward_le_bind_of_mem
/-- If `f` is a monomorphism, the pushforward-pullback adjunction on sieves is coreflective. -/
def galoisCoinsertionOfMono (f : Y â¶ X) [Mono f] :
GaloisCoinsertion (Sieve.pushforward f) (Sieve.pullback f) := by
apply (galoisConnection f).toGaloisCoinsertion
rintro S Z g âšgâ, hf, hgââ©
rw [cancel_mono f] at hf
rwa [â hf]
/-- If `f` is a split epi, the pushforward-pullback adjunction on sieves is reflective. -/
def galoisInsertionOfIsSplitEpi (f : Y â¶ X) [IsSplitEpi f] :
GaloisInsertion (Sieve.pushforward f) (Sieve.pullback f) := by
apply (galoisConnection f).toGaloisInsertion
intro S Z g hg
exact âšg â« section_ f, by simpaâ©
theorem pullbackArrows_comm [HasPullbacks C] {X Y : C} (f : Y â¶ X) (R : Presieve X) :
Sieve.generate (R.pullbackArrows f) = (Sieve.generate R).pullback f := by
ext W g
constructor
· rintro âš_, h, k, âšW, g, hgâ©, rflâ©
rw [Sieve.pullback_apply, assoc, â pullback.condition, â assoc]
exact Sieve.downward_closed _ (by exact Sieve.le_generate R W hg) (h â« pullback.fst g f)
· rintro âšW, h, k, hk, commâ©
exact âš_, _, _, Presieve.pullbackArrows.mk _ _ hk, pullback.lift_snd _ _ commâ©
section Functor
variable {E : Type uâ} [Category.{vâ} E] (G : D ⥀ E)
/--
If `R` is a sieve, then the `CategoryTheory.Presieve.functorPullback` of `R` is actually a sieve.
-/
@[simps]
def functorPullback (R : Sieve (F.obj X)) : Sieve X where
arrows := Presieve.functorPullback F R
downward_closed := by
intro _ _ f hf g
unfold Presieve.functorPullback
rw [F.map_comp]
exact R.downward_closed hf (F.map g)
@[simp]
theorem functorPullback_arrows (R : Sieve (F.obj X)) :
(R.functorPullback F).arrows = R.arrows.functorPullback F :=
rfl
@[simp]
theorem functorPullback_id (R : Sieve X) : R.functorPullback (ð _) = R := by
ext
rfl
theorem functorPullback_comp (R : Sieve ((F â G).obj X)) :
R.functorPullback (F â G) = (R.functorPullback G).functorPullback F := by
ext
rfl
theorem functorPushforward_extend_eq {R : Presieve X} :
(generate R).arrows.functorPushforward F = R.functorPushforward F := by
funext Y
ext f
constructor
| · rintro âšX', g, f', âšX'', g', f'', hâ, rflâ©, rflâ©
exact âšX'', f'', f' â« F.map g', hâ, by simpâ©
· rintro âšX', g, f', hâ, hââ©
| Mathlib/CategoryTheory/Sites/Sieves.lean | 667 | 669 |
/-
Copyright (c) 2023 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Equivalence
/-!
# 2-commutative squares of functors
Similarly as `CommSq.lean` defines the notion of commutative squares,
this file introduces the notion of 2-commutative squares of functors.
If `T : Câ ⥀ Câ`, `L : Câ ⥀ Câ`, `R : Câ ⥀ Câ`, `B : Câ ⥀ Câ` are functors,
then `[CatCommSq T L R B]` contains the datum of an isomorphism `T â R â
L â B`.
Future work: using this notion in the development of the localization of categories
(e.g. localization of adjunctions).
-/
namespace CategoryTheory
open Category
variable {Câ Câ Câ Câ Câ
Câ : Type*} [Category Câ] [Category Câ] [Category Câ] [Category Câ]
[Category Câ
] [Category Câ]
(T : Câ ⥀ Câ) (L : Câ ⥀ Câ) (R : Câ ⥀ Câ) (B : Câ ⥀ Câ)
/-- `CatCommSq T L R B` expresses that there is a 2-commutative square of functors, where
the functors `T`, `L`, `R` and `B` are respectively the left, top, right and bottom functors
of the square. -/
@[ext]
class CatCommSq where
/-- the isomorphism corresponding to a 2-commutative diagram -/
iso' : T â R â
L â B
namespace CatCommSq
/-- Assuming `[CatCommSq T L R B]`, `iso T L R B` is the isomorphism `T â R â
L â B`
given by the 2-commutative square. -/
-- This only exists to change the explicitness of the binders of the `iso'` field.
abbrev iso [h : CatCommSq T L R B] : T â R â
L â B := h.iso'
/-- Horizontal composition of 2-commutative squares -/
@[simps! iso'_hom_app iso'_inv_app]
def hComp (Tâ : Câ ⥀ Câ) (Tâ : Câ ⥀ Câ) (Vâ : Câ ⥀ Câ) (Vâ : Câ ⥀ Câ
) (Vâ : Câ ⥀ Câ)
(Bâ : Câ ⥀ Câ
) (Bâ : Câ
⥀ Câ) [CatCommSq Tâ Vâ Vâ Bâ] [CatCommSq Tâ Vâ Vâ Bâ] :
CatCommSq (Tâ â Tâ) Vâ Vâ (Bâ â Bâ) where
iso' := Functor.associator _ _ _ âªâ« isoWhiskerLeft Tâ (iso Tâ Vâ Vâ Bâ) âªâ«
(Functor.associator _ _ _).symm âªâ« isoWhiskerRight (iso Tâ Vâ Vâ Bâ) Bâ âªâ«
Functor.associator _ _ _
/-- Vertical composition of 2-commutative squares -/
@[simps! iso'_hom_app iso'_inv_app]
def vComp (Lâ : Câ ⥀ Câ) (Lâ : Câ ⥀ Câ) (Hâ : Câ ⥀ Câ) (Hâ : Câ ⥀ Câ
) (Hâ : Câ ⥀ Câ)
(Râ : Câ ⥀ Câ
) (Râ : Câ
⥀ Câ) [CatCommSq Hâ Lâ Râ Hâ] [CatCommSq Hâ Lâ Râ Hâ] :
CatCommSq Hâ (Lâ â Lâ) (Râ â Râ) Hâ where
iso' := (Functor.associator _ _ _).symm âªâ« isoWhiskerRight (iso Hâ Lâ Râ Hâ) Râ âªâ«
Functor.associator _ _ _ âªâ« isoWhiskerLeft Lâ (iso Hâ Lâ Râ Hâ) âªâ«
(Functor.associator _ _ _).symm
section
variable (T : Câ â Câ) (L : Câ ⥀ Câ) (R : Câ ⥀ Câ) (B : Câ â Câ)
/-- Horizontal inverse of a 2-commutative square -/
@[simps! iso'_hom_app iso'_inv_app]
def hInv (_ : CatCommSq T.functor L R B.functor) : CatCommSq T.inverse R L B.inverse where
iso' := isoWhiskerLeft _ (L.rightUnitor.symm âªâ« isoWhiskerLeft L B.unitIso âªâ«
(Functor.associator _ _ _).symm âªâ«
isoWhiskerRight (iso T.functor L R B.functor).symm B.inverse âªâ«
Functor.associator _ _ _ ) âªâ« (Functor.associator _ _ _).symm âªâ«
isoWhiskerRight T.counitIso _ âªâ« Functor.leftUnitor _
|
lemma hInv_hInv (h : CatCommSq T.functor L R B.functor) :
hInv T.symm R L B.symm (hInv T L R B h) = h := by
ext X
rw [â cancel_mono (B.functor.map (L.map (T.unitIso.hom.app X)))]
rw [â Functor.comp_map]
erw [â h.iso'.hom.naturality (T.unitIso.hom.app X)]
rw [hInv_iso'_hom_app]
simp only [Equivalence.symm_functor]
rw [hInv_iso'_inv_app]
dsimp
| Mathlib/CategoryTheory/CatCommSq.lean | 75 | 85 |
/-
Copyright (c) 2018 Michael Jendrusch. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Jendrusch, Kim Morrison, Bhavik Mehta, Jakob von Raumer
-/
import Mathlib.CategoryTheory.EqToHom
import Mathlib.CategoryTheory.Functor.Trifunctor
import Mathlib.CategoryTheory.Products.Basic
/-!
# Monoidal categories
A monoidal category is a category equipped with a tensor product, unitors, and an associator.
In the definition, we provide the tensor product as a pair of functions
* `tensorObj : C â C â C`
* `tensorHom : (Xâ â¶ Yâ) â (Xâ â¶ Yâ) â ((Xâ â Xâ) â¶ (Yâ â Yâ))`
and allow use of the overloaded notation `â` for both.
The unitors and associator are provided componentwise.
The tensor product can be expressed as a functor via `tensor : C à C ⥀ C`.
The unitors and associator are gathered together as natural
isomorphisms in `leftUnitor_nat_iso`, `rightUnitor_nat_iso` and `associator_nat_iso`.
Some consequences of the definition are proved in other files after proving the coherence theorem,
e.g. `(λ_ (ð_ C)).hom = (Ï_ (ð_ C)).hom` in `CategoryTheory.Monoidal.CoherenceLemmas`.
## Implementation notes
In the definition of monoidal categories, we also provide the whiskering operators:
* `whiskerLeft (X : C) {Yâ Yâ : C} (f : Yâ â¶ Yâ) : X â Yâ â¶ X â Yâ`, denoted by `X â f`,
* `whiskerRight {Xâ Xâ : C} (f : Xâ â¶ Xâ) (Y : C) : Xâ â Y â¶ Xâ â Y`, denoted by `f â· Y`.
These are products of an object and a morphism (the terminology "whiskering"
is borrowed from 2-category theory). The tensor product of morphisms `tensorHom` can be defined
in terms of the whiskerings. There are two possible such definitions, which are related by
the exchange property of the whiskerings. These two definitions are accessed by `tensorHom_def`
and `tensorHom_def'`. By default, `tensorHom` is defined so that `tensorHom_def` holds
definitionally.
If you want to provide `tensorHom` and define `whiskerLeft` and `whiskerRight` in terms of it,
you can use the alternative constructor `CategoryTheory.MonoidalCategory.ofTensorHom`.
The whiskerings are useful when considering simp-normal forms of morphisms in monoidal categories.
### Simp-normal form for morphisms
Rewriting involving associators and unitors could be very complicated. We try to ease this
complexity by putting carefully chosen simp lemmas that rewrite any morphisms into the simp-normal
form defined below. Rewriting into simp-normal form is especially useful in preprocessing
performed by the `coherence` tactic.
The simp-normal form of morphisms is defined to be an expression that has the minimal number of
parentheses. More precisely,
1. it is a composition of morphisms like `fâ â« fâ â« fâ â« fâ â« fâ
` such that each `fáµ¢` is
either a structural morphisms (morphisms made up only of identities, associators, unitors)
or non-structural morphisms, and
2. each non-structural morphism in the composition is of the form `Xâ â Xâ â Xâ â f â· Xâ â· Xâ
`,
where each `Xáµ¢` is a object that is not the identity or a tensor and `f` is a non-structural
morphisms that is not the identity or a composite.
Note that `Xâ â Xâ â Xâ â f â· Xâ â· Xâ
` is actually `Xâ â (Xâ â (Xâ â ((f â· Xâ) â· Xâ
)))`.
Currently, the simp lemmas don't rewrite `ð X â f` and `f â ð Y` into `X â f` and `f â· Y`,
respectively, since it requires a huge refactoring. We hope to add these simp lemmas soon.
## References
* Tensor categories, Etingof, Gelaki, Nikshych, Ostrik,
http://www-math.mit.edu/~etingof/egnobookfinal.pdf
* <https://stacks.math.columbia.edu/tag/0FFK>.
-/
universe v u
open CategoryTheory.Category
open CategoryTheory.Iso
namespace CategoryTheory
/-- Auxiliary structure to carry only the data fields of (and provide notation for)
`MonoidalCategory`. -/
class MonoidalCategoryStruct (C : Type u) [ð : Category.{v} C] where
/-- curried tensor product of objects -/
tensorObj : C â C â C
/-- left whiskering for morphisms -/
whiskerLeft (X : C) {Yâ Yâ : C} (f : Yâ â¶ Yâ) : tensorObj X Yâ â¶ tensorObj X Yâ
/-- right whiskering for morphisms -/
whiskerRight {Xâ Xâ : C} (f : Xâ â¶ Xâ) (Y : C) : tensorObj Xâ Y â¶ tensorObj Xâ Y
/-- Tensor product of identity maps is the identity: `(ð Xâ â ð Xâ) = ð (Xâ â Xâ)` -/
-- By default, it is defined in terms of whiskerings.
tensorHom {Xâ Yâ Xâ Yâ : C} (f : Xâ â¶ Yâ) (g : Xâ â¶ Yâ) : (tensorObj Xâ Xâ â¶ tensorObj Yâ Yâ) :=
whiskerRight f Xâ â« whiskerLeft Yâ g
/-- The tensor unity in the monoidal structure `ð_ C` -/
tensorUnit (C) : C
/-- The associator isomorphism `(X â Y) â Z â X â (Y â Z)` -/
associator : â X Y Z : C, tensorObj (tensorObj X Y) Z â
tensorObj X (tensorObj Y Z)
/-- The left unitor: `ð_ C â X â X` -/
leftUnitor : â X : C, tensorObj tensorUnit X â
X
/-- The right unitor: `X â ð_ C â X` -/
rightUnitor : â X : C, tensorObj X tensorUnit â
X
namespace MonoidalCategory
export MonoidalCategoryStruct
(tensorObj whiskerLeft whiskerRight tensorHom tensorUnit associator leftUnitor rightUnitor)
end MonoidalCategory
namespace MonoidalCategory
/-- Notation for `tensorObj`, the tensor product of objects in a monoidal category -/
scoped infixr:70 " â " => MonoidalCategoryStruct.tensorObj
/-- Notation for the `whiskerLeft` operator of monoidal categories -/
scoped infixr:81 " â " => MonoidalCategoryStruct.whiskerLeft
/-- Notation for the `whiskerRight` operator of monoidal categories -/
scoped infixl:81 " â· " => MonoidalCategoryStruct.whiskerRight
/-- Notation for `tensorHom`, the tensor product of morphisms in a monoidal category -/
scoped infixr:70 " â " => MonoidalCategoryStruct.tensorHom
/-- Notation for `tensorUnit`, the two-sided identity of `â` -/
scoped notation "ð_ " C:arg => MonoidalCategoryStruct.tensorUnit C
/-- Notation for the monoidal `associator`: `(X â Y) â Z â X â (Y â Z)` -/
scoped notation "α_" => MonoidalCategoryStruct.associator
/-- Notation for the `leftUnitor`: `ð_C â X â X` -/
scoped notation "λ_" => MonoidalCategoryStruct.leftUnitor
/-- Notation for the `rightUnitor`: `X â ð_C â X` -/
scoped notation "Ï_" => MonoidalCategoryStruct.rightUnitor
/-- The property that the pentagon relation is satisfied by four objects
in a category equipped with a `MonoidalCategoryStruct`. -/
def Pentagon {C : Type u} [Category.{v} C] [MonoidalCategoryStruct C]
(Yâ Yâ Yâ Yâ : C) : Prop :=
(α_ Yâ Yâ Yâ).hom â· Yâ â« (α_ Yâ (Yâ â Yâ) Yâ).hom â« Yâ â (α_ Yâ Yâ Yâ).hom =
(α_ (Yâ â Yâ) Yâ Yâ).hom â« (α_ Yâ Yâ (Yâ â Yâ)).hom
end MonoidalCategory
open MonoidalCategory
/--
In a monoidal category, we can take the tensor product of objects, `X â Y` and of morphisms `f â g`.
Tensor product does not need to be strictly associative on objects, but there is a
specified associator, `α_ X Y Z : (X â Y) â Z â
X â (Y â Z)`. There is a tensor unit `ð_ C`,
with specified left and right unitor isomorphisms `λ_ X : ð_ C â X â
X` and `Ï_ X : X â ð_ C â
X`.
These associators and unitors satisfy the pentagon and triangle equations. -/
@[stacks 0FFK]
-- Porting note: The Mathport did not translate the temporary notation
class MonoidalCategory (C : Type u) [ð : Category.{v} C] extends MonoidalCategoryStruct C where
tensorHom_def {Xâ Yâ Xâ Yâ : C} (f : Xâ â¶ Yâ) (g : Xâ â¶ Yâ) :
f â g = (f â· Xâ) â« (Yâ â g) := by
aesop_cat
/-- Tensor product of identity maps is the identity: `(ð Xâ â ð Xâ) = ð (Xâ â Xâ)` -/
tensor_id : â Xâ Xâ : C, ð Xâ â ð Xâ = ð (Xâ â Xâ) := by aesop_cat
/--
Tensor product of compositions is composition of tensor products:
`(fâ â« gâ) â (fâ â« gâ) = (fâ â fâ) â« (gâ â gâ)`
-/
tensor_comp :
â {Xâ Yâ Zâ Xâ Yâ Zâ : C} (fâ : Xâ â¶ Yâ) (fâ : Xâ â¶ Yâ) (gâ : Yâ â¶ Zâ) (gâ : Yâ â¶ Zâ),
(fâ â« gâ) â (fâ â« gâ) = (fâ â fâ) â« (gâ â gâ) := by
aesop_cat
whiskerLeft_id : â (X Y : C), X â ð Y = ð (X â Y) := by
aesop_cat
id_whiskerRight : â (X Y : C), ð X â· Y = ð (X â Y) := by
aesop_cat
/-- Naturality of the associator isomorphism: `(fâ â fâ) â fâ â fâ â (fâ â fâ)` -/
associator_naturality :
â {Xâ Xâ Xâ Yâ Yâ Yâ : C} (fâ : Xâ â¶ Yâ) (fâ : Xâ â¶ Yâ) (fâ : Xâ â¶ Yâ),
((fâ â fâ) â fâ) â« (α_ Yâ Yâ Yâ).hom = (α_ Xâ Xâ Xâ).hom â« (fâ â (fâ â fâ)) := by
aesop_cat
/--
Naturality of the left unitor, commutativity of `ð_ C â X â¶ ð_ C â Y â¶ Y` and `ð_ C â X â¶ X â¶ Y`
-/
leftUnitor_naturality :
â {X Y : C} (f : X â¶ Y), ð_ _ â f â« (λ_ Y).hom = (λ_ X).hom â« f := by
aesop_cat
/--
Naturality of the right unitor: commutativity of `X â ð_ C â¶ Y â ð_ C â¶ Y` and `X â ð_ C â¶ X â¶ Y`
-/
rightUnitor_naturality :
â {X Y : C} (f : X â¶ Y), f â· ð_ _ â« (Ï_ Y).hom = (Ï_ X).hom â« f := by
aesop_cat
/--
The pentagon identity relating the isomorphism between `X â (Y â (Z â W))` and `((X â Y) â Z) â W`
-/
pentagon :
â W X Y Z : C,
(α_ W X Y).hom â· Z â« (α_ W (X â Y) Z).hom â« W â (α_ X Y Z).hom =
(α_ (W â X) Y Z).hom â« (α_ W X (Y â Z)).hom := by
aesop_cat
/--
The identity relating the isomorphisms between `X â (ð_ C â Y)`, `(X â ð_ C) â Y` and `X â Y`
-/
triangle :
â X Y : C, (α_ X (ð_ _) Y).hom â« X â (λ_ Y).hom = (Ï_ X).hom â· Y := by
aesop_cat
attribute [reassoc] MonoidalCategory.tensorHom_def
attribute [reassoc, simp] MonoidalCategory.whiskerLeft_id
attribute [reassoc, simp] MonoidalCategory.id_whiskerRight
attribute [reassoc] MonoidalCategory.tensor_comp
attribute [simp] MonoidalCategory.tensor_comp
attribute [reassoc] MonoidalCategory.associator_naturality
attribute [reassoc] MonoidalCategory.leftUnitor_naturality
attribute [reassoc] MonoidalCategory.rightUnitor_naturality
attribute [reassoc (attr := simp)] MonoidalCategory.pentagon
attribute [reassoc (attr := simp)] MonoidalCategory.triangle
namespace MonoidalCategory
variable {C : Type u} [ð : Category.{v} C] [MonoidalCategory C]
@[simp]
theorem id_tensorHom (X : C) {Yâ Yâ : C} (f : Yâ â¶ Yâ) :
ð X â f = X â f := by
simp [tensorHom_def]
@[simp]
theorem tensorHom_id {Xâ Xâ : C} (f : Xâ â¶ Xâ) (Y : C) :
f â ð Y = f â· Y := by
simp [tensorHom_def]
@[reassoc, simp]
theorem whiskerLeft_comp (W : C) {X Y Z : C} (f : X â¶ Y) (g : Y â¶ Z) :
W â (f â« g) = W â f â« W â g := by
simp only [â id_tensorHom, â tensor_comp, comp_id]
@[reassoc, simp]
theorem id_whiskerLeft {X Y : C} (f : X â¶ Y) :
ð_ C â f = (λ_ X).hom â« f â« (λ_ Y).inv := by
rw [â assoc, â leftUnitor_naturality]; simp [id_tensorHom]
@[reassoc, simp]
theorem tensor_whiskerLeft (X Y : C) {Z Z' : C} (f : Z â¶ Z') :
(X â Y) â f = (α_ X Y Z).hom â« X â Y â f â« (α_ X Y Z').inv := by
simp only [â id_tensorHom, â tensorHom_id]
rw [â assoc, â associator_naturality]
simp
@[reassoc, simp]
theorem comp_whiskerRight {W X Y : C} (f : W â¶ X) (g : X â¶ Y) (Z : C) :
(f â« g) â· Z = f â· Z â« g â· Z := by
simp only [â tensorHom_id, â tensor_comp, id_comp]
@[reassoc, simp]
theorem whiskerRight_id {X Y : C} (f : X â¶ Y) :
f â· ð_ C = (Ï_ X).hom â« f â« (Ï_ Y).inv := by
rw [â assoc, â rightUnitor_naturality]; simp [tensorHom_id]
@[reassoc, simp]
theorem whiskerRight_tensor {X X' : C} (f : X â¶ X') (Y Z : C) :
f â· (Y â Z) = (α_ X Y Z).inv â« f â· Y â· Z â« (α_ X' Y Z).hom := by
simp only [â id_tensorHom, â tensorHom_id]
rw [associator_naturality]
simp [tensor_id]
@[reassoc, simp]
theorem whisker_assoc (X : C) {Y Y' : C} (f : Y â¶ Y') (Z : C) :
(X â f) â· Z = (α_ X Y Z).hom â« X â f â· Z â« (α_ X Y' Z).inv := by
simp only [â id_tensorHom, â tensorHom_id]
rw [â assoc, â associator_naturality]
simp
@[reassoc]
theorem whisker_exchange {W X Y Z : C} (f : W â¶ X) (g : Y â¶ Z) :
W â g â« f â· Z = f â· Y â« X â g := by
simp only [â id_tensorHom, â tensorHom_id, â tensor_comp, id_comp, comp_id]
@[reassoc]
theorem tensorHom_def' {Xâ Yâ Xâ Yâ : C} (f : Xâ â¶ Yâ) (g : Xâ â¶ Yâ) :
f â g = Xâ â g â« f â· Yâ :=
whisker_exchange f g âž tensorHom_def f g
@[reassoc (attr := simp)]
theorem whiskerLeft_hom_inv (X : C) {Y Z : C} (f : Y â
Z) :
X â f.hom â« X â f.inv = ð (X â Y) := by
rw [â whiskerLeft_comp, hom_inv_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem hom_inv_whiskerRight {X Y : C} (f : X â
Y) (Z : C) :
f.hom â· Z â« f.inv â· Z = ð (X â Z) := by
rw [â comp_whiskerRight, hom_inv_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_inv_hom (X : C) {Y Z : C} (f : Y â
Z) :
X â f.inv â« X â f.hom = ð (X â Z) := by
rw [â whiskerLeft_comp, inv_hom_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem inv_hom_whiskerRight {X Y : C} (f : X â
Y) (Z : C) :
f.inv â· Z â« f.hom â· Z = ð (Y â Z) := by
rw [â comp_whiskerRight, inv_hom_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_hom_inv' (X : C) {Y Z : C} (f : Y â¶ Z) [IsIso f] :
X â f â« X â inv f = ð (X â Y) := by
rw [â whiskerLeft_comp, IsIso.hom_inv_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem hom_inv_whiskerRight' {X Y : C} (f : X â¶ Y) [IsIso f] (Z : C) :
f â· Z â« inv f â· Z = ð (X â Z) := by
rw [â comp_whiskerRight, IsIso.hom_inv_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_inv_hom' (X : C) {Y Z : C} (f : Y â¶ Z) [IsIso f] :
X â inv f â« X â f = ð (X â Z) := by
rw [â whiskerLeft_comp, IsIso.inv_hom_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem inv_hom_whiskerRight' {X Y : C} (f : X â¶ Y) [IsIso f] (Z : C) :
inv f â· Z â« f â· Z = ð (Y â Z) := by
rw [â comp_whiskerRight, IsIso.inv_hom_id, id_whiskerRight]
/-- The left whiskering of an isomorphism is an isomorphism. -/
@[simps]
def whiskerLeftIso (X : C) {Y Z : C} (f : Y â
Z) : X â Y â
X â Z where
hom := X â f.hom
inv := X â f.inv
instance whiskerLeft_isIso (X : C) {Y Z : C} (f : Y â¶ Z) [IsIso f] : IsIso (X â f) :=
(whiskerLeftIso X (asIso f)).isIso_hom
@[simp]
theorem inv_whiskerLeft (X : C) {Y Z : C} (f : Y â¶ Z) [IsIso f] :
inv (X â f) = X â inv f := by
aesop_cat
@[simp]
lemma whiskerLeftIso_refl (W X : C) :
whiskerLeftIso W (Iso.refl X) = Iso.refl (W â X) :=
Iso.ext (whiskerLeft_id W X)
@[simp]
lemma whiskerLeftIso_trans (W : C) {X Y Z : C} (f : X â
Y) (g : Y â
Z) :
whiskerLeftIso W (f âªâ« g) = whiskerLeftIso W f âªâ« whiskerLeftIso W g :=
Iso.ext (whiskerLeft_comp W f.hom g.hom)
@[simp]
lemma whiskerLeftIso_symm (W : C) {X Y : C} (f : X â
Y) :
(whiskerLeftIso W f).symm = whiskerLeftIso W f.symm := rfl
/-- The right whiskering of an isomorphism is an isomorphism. -/
@[simps!]
def whiskerRightIso {X Y : C} (f : X â
Y) (Z : C) : X â Z â
Y â Z where
hom := f.hom â· Z
inv := f.inv â· Z
instance whiskerRight_isIso {X Y : C} (f : X â¶ Y) (Z : C) [IsIso f] : IsIso (f â· Z) :=
(whiskerRightIso (asIso f) Z).isIso_hom
@[simp]
theorem inv_whiskerRight {X Y : C} (f : X â¶ Y) (Z : C) [IsIso f] :
inv (f â· Z) = inv f â· Z := by
aesop_cat
@[simp]
lemma whiskerRightIso_refl (X W : C) :
whiskerRightIso (Iso.refl X) W = Iso.refl (X â W) :=
Iso.ext (id_whiskerRight X W)
@[simp]
lemma whiskerRightIso_trans {X Y Z : C} (f : X â
Y) (g : Y â
Z) (W : C) :
whiskerRightIso (f âªâ« g) W = whiskerRightIso f W âªâ« whiskerRightIso g W :=
Iso.ext (comp_whiskerRight f.hom g.hom W)
@[simp]
lemma whiskerRightIso_symm {X Y : C} (f : X â
Y) (W : C) :
(whiskerRightIso f W).symm = whiskerRightIso f.symm W := rfl
/-- The tensor product of two isomorphisms is an isomorphism. -/
@[simps]
def tensorIso {X Y X' Y' : C} (f : X â
Y)
(g : X' â
Y') : X â X' â
Y â Y' where
hom := f.hom â g.hom
inv := f.inv â g.inv
hom_inv_id := by rw [â tensor_comp, Iso.hom_inv_id, Iso.hom_inv_id, â tensor_id]
inv_hom_id := by rw [â tensor_comp, Iso.inv_hom_id, Iso.inv_hom_id, â tensor_id]
/-- Notation for `tensorIso`, the tensor product of isomorphisms -/
scoped infixr:70 " â " => tensorIso
theorem tensorIso_def {X Y X' Y' : C} (f : X â
Y) (g : X' â
Y') :
f â g = whiskerRightIso f X' âªâ« whiskerLeftIso Y g :=
Iso.ext (tensorHom_def f.hom g.hom)
theorem tensorIso_def' {X Y X' Y' : C} (f : X â
Y) (g : X' â
Y') :
f â g = whiskerLeftIso X g âªâ« whiskerRightIso f Y' :=
Iso.ext (tensorHom_def' f.hom g.hom)
instance tensor_isIso {W X Y Z : C} (f : W â¶ X) [IsIso f] (g : Y â¶ Z) [IsIso g] : IsIso (f â g) :=
(asIso f â asIso g).isIso_hom
@[simp]
theorem inv_tensor {W X Y Z : C} (f : W â¶ X) [IsIso f] (g : Y â¶ Z) [IsIso g] :
inv (f â g) = inv f â inv g := by
simp [tensorHom_def ,whisker_exchange]
variable {W X Y Z : C}
theorem whiskerLeft_dite {P : Prop} [Decidable P]
(X : C) {Y Z : C} (f : P â (Y â¶ Z)) (f' : ¬P â (Y â¶ Z)) :
X â (if h : P then f h else f' h) = if h : P then X â f h else X â f' h := by
split_ifs <;> rfl
theorem dite_whiskerRight {P : Prop} [Decidable P]
{X Y : C} (f : P â (X â¶ Y)) (f' : ¬P â (X â¶ Y)) (Z : C) :
(if h : P then f h else f' h) â· Z = if h : P then f h â· Z else f' h â· Z := by
split_ifs <;> rfl
theorem tensor_dite {P : Prop} [Decidable P] {W X Y Z : C} (f : W â¶ X) (g : P â (Y â¶ Z))
(g' : ¬P â (Y â¶ Z)) : (f â if h : P then g h else g' h) =
if h : P then f â g h else f â g' h := by split_ifs <;> rfl
theorem dite_tensor {P : Prop} [Decidable P] {W X Y Z : C} (f : W â¶ X) (g : P â (Y â¶ Z))
(g' : ¬P â (Y â¶ Z)) : (if h : P then g h else g' h) â f =
if h : P then g h â f else g' h â f := by split_ifs <;> rfl
@[simp]
theorem whiskerLeft_eqToHom (X : C) {Y Z : C} (f : Y = Z) :
X â eqToHom f = eqToHom (congr_argâ tensorObj rfl f) := by
cases f
simp only [whiskerLeft_id, eqToHom_refl]
@[simp]
theorem eqToHom_whiskerRight {X Y : C} (f : X = Y) (Z : C) :
eqToHom f â· Z = eqToHom (congr_argâ tensorObj f rfl) := by
cases f
simp only [id_whiskerRight, eqToHom_refl]
@[reassoc]
theorem associator_naturality_left {X X' : C} (f : X â¶ X') (Y Z : C) :
f â· Y â· Z â« (α_ X' Y Z).hom = (α_ X Y Z).hom â« f â· (Y â Z) := by simp
@[reassoc]
theorem associator_inv_naturality_left {X X' : C} (f : X â¶ X') (Y Z : C) :
f â· (Y â Z) â« (α_ X' Y Z).inv = (α_ X Y Z).inv â« f â· Y â· Z := by simp
@[reassoc]
theorem whiskerRight_tensor_symm {X X' : C} (f : X â¶ X') (Y Z : C) :
f â· Y â· Z = (α_ X Y Z).hom â« f â· (Y â Z) â« (α_ X' Y Z).inv := by simp
@[reassoc]
theorem associator_naturality_middle (X : C) {Y Y' : C} (f : Y â¶ Y') (Z : C) :
(X â f) â· Z â« (α_ X Y' Z).hom = (α_ X Y Z).hom â« X â f â· Z := by simp
@[reassoc]
theorem associator_inv_naturality_middle (X : C) {Y Y' : C} (f : Y â¶ Y') (Z : C) :
X â f â· Z â« (α_ X Y' Z).inv = (α_ X Y Z).inv â« (X â f) â· Z := by simp
@[reassoc]
theorem whisker_assoc_symm (X : C) {Y Y' : C} (f : Y â¶ Y') (Z : C) :
X â f â· Z = (α_ X Y Z).inv â« (X â f) â· Z â« (α_ X Y' Z).hom := by simp
@[reassoc]
theorem associator_naturality_right (X Y : C) {Z Z' : C} (f : Z â¶ Z') :
(X â Y) â f â« (α_ X Y Z').hom = (α_ X Y Z).hom â« X â Y â f := by simp
@[reassoc]
theorem associator_inv_naturality_right (X Y : C) {Z Z' : C} (f : Z â¶ Z') :
X â Y â f â« (α_ X Y Z').inv = (α_ X Y Z).inv â« (X â Y) â f := by simp
@[reassoc]
theorem tensor_whiskerLeft_symm (X Y : C) {Z Z' : C} (f : Z â¶ Z') :
X â Y â f = (α_ X Y Z).inv â« (X â Y) â f â« (α_ X Y Z').hom := by simp
@[reassoc]
theorem leftUnitor_inv_naturality {X Y : C} (f : X â¶ Y) :
f â« (λ_ Y).inv = (λ_ X).inv â« _ â f := by simp
@[reassoc]
theorem id_whiskerLeft_symm {X X' : C} (f : X â¶ X') :
f = (λ_ X).inv â« ð_ C â f â« (λ_ X').hom := by
simp only [id_whiskerLeft, assoc, inv_hom_id, comp_id, inv_hom_id_assoc]
@[reassoc]
theorem rightUnitor_inv_naturality {X X' : C} (f : X â¶ X') :
f â« (Ï_ X').inv = (Ï_ X).inv â« f â· _ := by simp
@[reassoc]
theorem whiskerRight_id_symm {X Y : C} (f : X â¶ Y) :
f = (Ï_ X).inv â« f â· ð_ C â« (Ï_ Y).hom := by
simp
theorem whiskerLeft_iff {X Y : C} (f g : X â¶ Y) : ð_ C â f = ð_ C â g â f = g := by simp
theorem whiskerRight_iff {X Y : C} (f g : X â¶ Y) : f â· ð_ C = g â· ð_ C â f = g := by simp
/-! The lemmas in the next section are true by coherence,
but we prove them directly as they are used in proving the coherence theorem. -/
section
@[reassoc (attr := simp)]
theorem pentagon_inv :
W â (α_ X Y Z).inv â« (α_ W (X â Y) Z).inv â« (α_ W X Y).inv â· Z =
(α_ W X (Y â Z)).inv â« (α_ (W â X) Y Z).inv :=
eq_of_inv_eq_inv (by simp)
| @[reassoc (attr := simp)]
theorem pentagon_inv_inv_hom_hom_inv :
| Mathlib/CategoryTheory/Monoidal/Category.lean | 504 | 505 |
/-
Copyright (c) 2024 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Group.Action.Pi
import Mathlib.Algebra.Group.End
import Mathlib.Algebra.Module.NatInt
import Mathlib.Algebra.Order.Archimedean.Basic
/-!
# Maps (semi)conjugating a shift to a shift
Denote by $S^1$ the unit circle `UnitAddCircle`.
A common way to study a self-map $f\colon S^1\to S^1$ of degree `1`
is to lift it to a map $\tilde f\colon \mathbb R\to \mathbb R$
such that $\tilde f(x + 1) = \tilde f(x)+1$ for all `x`.
In this file we define a structure and a typeclass
for bundled maps satisfying `f (x + a) = f x + b`.
We use parameters `a` and `b` instead of `1` to accommodate for two use cases:
- maps between circles of different lengths;
- self-maps $f\colon S^1\to S^1$ of degree other than one,
including orientation-reversing maps.
-/
assert_not_exists Finset
open Function Set
/-- A bundled map `f : G â H` such that `f (x + a) = f x + b` for all `x`,
denoted as `f: G â+c[a, b] H`.
One can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/
structure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where
/-- The underlying function of an `AddConstMap`.
Use automatic coercion to function instead. -/
protected toFun : G â H
/-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/
map_add_const' (x : G) : toFun (x + a) = toFun x + b
@[inherit_doc]
scoped [AddConstMap] notation:25 G " â+c[" a ", " b "] " H => AddConstMap G H a b
/-- Typeclass for maps satisfying `f (x + a) = f x + b`.
Note that `a` and `b` are `outParam`s,
so one should not add instances like
`[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/
class AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H]
(a : outParam G) (b : outParam H) [FunLike F G H] : Prop where
/-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`:
`â x, f (x + a) = f x + b`. -/
map_add_const (f : F) (x : G) : f (x + a) = f x + b
namespace AddConstMapClass
/-!
### Properties of `AddConstMapClass` maps
In this section we prove properties like `f (x + n ⢠a) = f x + n ⢠b`.
-/
scoped [AddConstMapClass] attribute [simp] map_add_const
variable {F G H : Type*} [FunLike F G H] {a : G} {b : H}
protected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) :
Semiconj f (· + a) (· + b) :=
map_add_const f
@[scoped simp]
theorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]
(f : F) (x : G) (n : â) : f (x + n ⢠a) = f x + n ⢠b := by
simpa using (AddConstMapClass.semiconj f).iterate_right n x
@[scoped simp]
theorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : â) : f (x + n) = f x + n ⢠b := by simp [â map_add_nsmul]
theorem map_add_one [AddMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) : f (x + 1) = f x + b := map_add_const f x
@[scoped simp]
theorem map_add_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : â) [n.AtLeastTwo] :
f (x + ofNat(n)) = f x + (ofNat(n) : â) ⢠b :=
map_add_nat' f x n
theorem map_add_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (x : G) (n : â) : f (x + n) = f x + n := by simp
theorem map_add_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (x : G) (n : â) [n.AtLeastTwo] :
f (x + ofNat(n)) = f x + ofNat(n) := map_add_nat f x n
@[scoped simp]
theorem map_const [AddZeroClass G] [Add H] [AddConstMapClass F G H a b] (f : F) :
f a = f 0 + b := by
simpa using map_add_const f 0
theorem map_one [AddZeroClass G] [One G] [Add H] [AddConstMapClass F G H 1 b] (f : F) :
f 1 = f 0 + b :=
map_const f
@[scoped simp]
theorem map_nsmul_const [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]
(f : F) (n : â) : f (n ⢠a) = f 0 + n ⢠b := by
simpa using map_add_nsmul f 0 n
@[scoped simp]
theorem map_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (n : â) : f n = f 0 + n ⢠b := by
simpa using map_add_nat' f 0 n
theorem map_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (n : â) [n.AtLeastTwo] :
f (ofNat(n)) = f 0 + (ofNat(n) : â) ⢠b :=
map_nat' f n
theorem map_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : â) : f n = f 0 + n := by simp
theorem map_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : â) [n.AtLeastTwo] :
f ofNat(n) = f 0 + ofNat(n) := map_nat f n
@[scoped simp]
theorem map_const_add [AddCommMagma G] [Add H] [AddConstMapClass F G H a b]
(f : F) (x : G) : f (a + x) = f x + b := by
rw [add_comm, map_add_const]
theorem map_one_add [AddCommMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) : f (1 + x) = f x + b := map_const_add f x
@[scoped simp]
theorem map_nsmul_add [AddCommMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]
(f : F) (n : â) (x : G) : f (n ⢠a + x) = f x + n ⢠b := by
rw [add_comm, map_add_nsmul]
@[scoped simp]
theorem map_nat_add' [AddCommMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (n : â) (x : G) : f (ân + x) = f x + n ⢠b := by
simpa using map_nsmul_add f n x
theorem map_ofNat_add' [AddCommMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (n : â) [n.AtLeastTwo] (x : G) :
f (ofNat(n) + x) = f x + ofNat(n) ⢠b :=
map_nat_add' f n x
theorem map_nat_add [AddCommMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : â) (x : G) : f (ân + x) = f x + n := by simp
theorem map_ofNat_add [AddCommMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : â) [n.AtLeastTwo] (x : G) :
f (ofNat(n) + x) = f x + ofNat(n) :=
map_nat_add f n x
@[scoped simp]
theorem map_sub_nsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (x : G) (n : â) : f (x - n ⢠a) = f x - n ⢠b := by
conv_rhs => rw [â sub_add_cancel x (n ⢠a), map_add_nsmul, add_sub_cancel_right]
@[scoped simp]
theorem map_sub_const [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (x : G) : f (x - a) = f x - b := by
simpa using map_sub_nsmul f x 1
theorem map_sub_one [AddGroup G] [One G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) : f (x - 1) = f x - b :=
map_sub_const f x
@[scoped simp]
theorem map_sub_nat' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : â) : f (x - n) = f x - n ⢠b := by
simpa using map_sub_nsmul f x n
@[scoped simp]
theorem map_sub_ofNat' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : â) [n.AtLeastTwo] :
f (x - ofNat(n)) = f x - ofNat(n) ⢠b :=
map_sub_nat' f x n
@[scoped simp]
theorem map_add_zsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (x : G) : â n : â€, f (x + n ⢠a) = f x + n ⢠b
| (n : â) => by simp
| .negSucc n => by simp [â sub_eq_add_neg]
@[scoped simp]
theorem map_zsmul_const [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (n : â€) : f (n ⢠a) = f 0 + n ⢠b := by
simpa using map_add_zsmul f 0 n
@[scoped simp]
theorem map_add_int' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : â€) : f (x + n) = f x + n ⢠b := by
rw [â map_add_zsmul f x n, zsmul_one]
theorem map_add_int [AddGroupWithOne G] [AddGroupWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (x : G) (n : â€) : f (x + n) = f x + n := by simp
@[scoped simp]
theorem map_sub_zsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (x : G) (n : â€) : f (x - n ⢠a) = f x - n ⢠b := by
simpa [sub_eq_add_neg] using map_add_zsmul f x (-n)
@[scoped simp]
theorem map_sub_int' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : â€) : f (x - n) = f x - n ⢠b := by
rw [â map_sub_zsmul, zsmul_one]
|
theorem map_sub_int [AddGroupWithOne G] [AddGroupWithOne H] [AddConstMapClass F G H 1 1]
| Mathlib/Algebra/AddConstMap/Basic.lean | 214 | 215 |
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-/
import Mathlib.Data.Finset.Sym
import Mathlib.LinearAlgebra.BilinearMap
import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.LinearAlgebra.Matrix.SesquilinearForm
import Mathlib.LinearAlgebra.Matrix.Symmetric
/-!
# Quadratic maps
This file defines quadratic maps on an `R`-module `M`, taking values in an `R`-module `N`.
An `N`-valued quadratic map on a module `M` over a commutative ring `R` is a map `Q : M â N` such
that:
* `QuadraticMap.map_smul`: `Q (a ⢠x) = (a * a) ⢠Q x`
* `QuadraticMap.polar_add_left`, `QuadraticMap.polar_add_right`,
`QuadraticMap.polar_smul_left`, `QuadraticMap.polar_smul_right`:
the map `QuadraticMap.polar Q := fun x y ⊠Q (x + y) - Q x - Q y` is bilinear.
This notion generalizes to commutative semirings using the approach in [izhakian2016][] which
requires that there be a (possibly non-unique) companion bilinear map `B` such that
`â x y, Q (x + y) = Q x + Q y + B x y`. Over a ring, this `B` is precisely `QuadraticMap.polar Q`.
To build a `QuadraticMap` from the `polar` axioms, use `QuadraticMap.ofPolar`.
Quadratic maps come with a scalar multiplication, `(a ⢠Q) x = a ⢠Q x`,
and composition with linear maps `f`, `Q.comp f x = Q (f x)`.
## Main definitions
* `QuadraticMap.ofPolar`: a more familiar constructor that works on rings
* `QuadraticMap.associated`: associated bilinear map
* `QuadraticMap.PosDef`: positive definite quadratic maps
* `QuadraticMap.Anisotropic`: anisotropic quadratic maps
* `QuadraticMap.discr`: discriminant of a quadratic map
* `QuadraticMap.IsOrtho`: orthogonality of vectors with respect to a quadratic map.
## Main statements
* `QuadraticMap.associated_left_inverse`,
* `QuadraticMap.associated_rightInverse`: in a commutative ring where 2 has
an inverse, there is a correspondence between quadratic maps and symmetric
bilinear forms
* `LinearMap.BilinForm.exists_orthogonal_basis`: There exists an orthogonal basis with
respect to any nondegenerate, symmetric bilinear map `B`.
## Notation
In this file, the variable `R` is used when a `CommSemiring` structure is available.
The variable `S` is used when `R` itself has a `â¢` action.
## Implementation notes
While the definition and many results make sense if we drop commutativity assumptions,
the correct definition of a quadratic maps in the noncommutative setting would require
substantial refactors from the current version, such that $Q(rm) = rQ(m)r^*$ for some
suitable conjugation $r^*$.
The [Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/Quadratic.20Maps/near/395529867)
has some further discussion.
## References
* https://en.wikipedia.org/wiki/Quadratic_form
* https://en.wikipedia.org/wiki/Discriminant#Quadratic_forms
## Tags
quadratic map, homogeneous polynomial, quadratic polynomial
-/
universe u v w
variable {S T : Type*}
variable {R : Type*} {M N P A : Type*}
open LinearMap (BilinMap BilinForm)
section Polar
variable [CommRing R] [AddCommGroup M] [AddCommGroup N]
namespace QuadraticMap
/-- Up to a factor 2, `Q.polar` is the associated bilinear map for a quadratic map `Q`.
Source of this name: https://en.wikipedia.org/wiki/Quadratic_form#Generalization
-/
def polar (f : M â N) (x y : M) :=
f (x + y) - f x - f y
protected theorem map_add (f : M â N) (x y : M) :
f (x + y) = f x + f y + polar f x y := by
rw [polar]
abel
theorem polar_add (f g : M â N) (x y : M) : polar (f + g) x y = polar f x y + polar g x y := by
simp only [polar, Pi.add_apply]
abel
theorem polar_neg (f : M â N) (x y : M) : polar (-f) x y = -polar f x y := by
simp only [polar, Pi.neg_apply, sub_eq_add_neg, neg_add]
theorem polar_smul [Monoid S] [DistribMulAction S N] (f : M â N) (s : S) (x y : M) :
polar (s ⢠f) x y = s ⢠polar f x y := by simp only [polar, Pi.smul_apply, smul_sub]
theorem polar_comm (f : M â N) (x y : M) : polar f x y = polar f y x := by
rw [polar, polar, add_comm, sub_sub, sub_sub, add_comm (f x) (f y)]
/-- Auxiliary lemma to express bilinearity of `QuadraticMap.polar` without subtraction. -/
theorem polar_add_left_iff {f : M â N} {x x' y : M} :
polar f (x + x') y = polar f x y + polar f x' y â
f (x + x' + y) + (f x + f x' + f y) = f (x + x') + f (x' + y) + f (y + x) := by
simp only [â add_assoc]
simp only [polar, sub_eq_iff_eq_add, eq_sub_iff_add_eq, sub_add_eq_add_sub, add_sub]
simp only [add_right_comm _ (f y) _, add_right_comm _ (f x') (f x)]
rw [add_comm y x, add_right_comm _ _ (f (x + y)), add_comm _ (f (x + y)),
add_right_comm (f (x + y)), add_left_inj]
theorem polar_comp {F : Type*} [AddCommGroup S] [FunLike F N S] [AddMonoidHomClass F N S]
(f : M â N) (g : F) (x y : M) :
polar (g â f) x y = g (polar f x y) := by
simp only [polar, Pi.smul_apply, Function.comp_apply, map_sub]
/-- `QuadraticMap.polar` as a function from `Sym2`. -/
def polarSym2 (f : M â N) : Sym2 M â N :=
Sym2.lift âšpolar f, polar_comm _â©
@[simp]
lemma polarSym2_sym2Mk (f : M â N) (xy : M Ã M) : polarSym2 f (.mk xy) = polar f xy.1 xy.2 := rfl
end QuadraticMap
end Polar
/-- A quadratic map on a module.
For a more familiar constructor when `R` is a ring, see `QuadraticMap.ofPolar`. -/
structure QuadraticMap (R : Type u) (M : Type v) (N : Type w) [CommSemiring R] [AddCommMonoid M]
[Module R M] [AddCommMonoid N] [Module R N] where
toFun : M â N
toFun_smul : â (a : R) (x : M), toFun (a ⢠x) = (a * a) ⢠toFun x
exists_companion' : â B : BilinMap R M N, â x y, toFun (x + y) = toFun x + toFun y + B x y
section QuadraticForm
variable (R : Type u) (M : Type v) [CommSemiring R] [AddCommMonoid M] [Module R M]
/-- A quadratic form on a module. -/
abbrev QuadraticForm : Type _ := QuadraticMap R M R
end QuadraticForm
namespace QuadraticMap
section DFunLike
variable [CommSemiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
variable {Q Q' : QuadraticMap R M N}
instance instFunLike : FunLike (QuadraticMap R M N) M N where
coe := toFun
coe_injective' x y h := by cases x; cases y; congr
variable (Q)
/-- The `simp` normal form for a quadratic map is `DFunLike.coe`, not `toFun`. -/
@[simp]
theorem toFun_eq_coe : Q.toFun = âQ :=
rfl
-- this must come after the coe_to_fun definition
initialize_simps_projections QuadraticMap (toFun â apply)
variable {Q}
@[ext]
theorem ext (H : â x : M, Q x = Q' x) : Q = Q' :=
DFunLike.ext _ _ H
theorem congr_fun (h : Q = Q') (x : M) : Q x = Q' x :=
DFunLike.congr_fun h _
/-- Copy of a `QuadraticMap` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (Q : QuadraticMap R M N) (Q' : M â N) (h : Q' = âQ) : QuadraticMap R M N where
toFun := Q'
toFun_smul := h.symm âž Q.toFun_smul
exists_companion' := h.symm âž Q.exists_companion'
@[simp]
theorem coe_copy (Q : QuadraticMap R M N) (Q' : M â N) (h : Q' = âQ) : â(Q.copy Q' h) = Q' :=
rfl
theorem copy_eq (Q : QuadraticMap R M N) (Q' : M â N) (h : Q' = âQ) : Q.copy Q' h = Q :=
DFunLike.ext' h
end DFunLike
section CommSemiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
variable (Q : QuadraticMap R M N)
protected theorem map_smul (a : R) (x : M) : Q (a ⢠x) = (a * a) ⢠Q x :=
Q.toFun_smul a x
theorem exists_companion : â B : BilinMap R M N, â x y, Q (x + y) = Q x + Q y + B x y :=
Q.exists_companion'
theorem map_add_add_add_map (x y z : M) :
Q (x + y + z) + (Q x + Q y + Q z) = Q (x + y) + Q (y + z) + Q (z + x) := by
obtain âšB, hâ© := Q.exists_companion
rw [add_comm z x]
simp only [h, LinearMap.map_addâ]
abel
theorem map_add_self (x : M) : Q (x + x) = 4 ⢠Q x := by
rw [â two_smul R x, Q.map_smul, â Nat.cast_smul_eq_nsmul R]
norm_num
-- not @[simp] because it is superseded by `ZeroHomClass.map_zero`
protected theorem map_zero : Q 0 = 0 := by
rw [â @zero_smul R _ _ _ _ (0 : M), Q.map_smul, zero_mul, zero_smul]
instance zeroHomClass : ZeroHomClass (QuadraticMap R M N) M N :=
{ QuadraticMap.instFunLike (R := R) (M := M) (N := N) with map_zero := QuadraticMap.map_zero }
theorem map_smul_of_tower [CommSemiring S] [Algebra S R] [SMul S M] [IsScalarTower S R M]
[Module S N] [IsScalarTower S R N] (a : S)
(x : M) : Q (a ⢠x) = (a * a) ⢠Q x := by
rw [â IsScalarTower.algebraMap_smul R a x, Q.map_smul, â RingHom.map_mul, algebraMap_smul]
end CommSemiring
section CommRing
variable [CommRing R] [AddCommGroup M] [AddCommGroup N]
variable [Module R M] [Module R N] (Q : QuadraticMap R M N)
@[simp]
protected theorem map_neg (x : M) : Q (-x) = Q x := by
rw [â @neg_one_smul R _ _ _ _ x, Q.map_smul, neg_one_mul, neg_neg, one_smul]
protected theorem map_sub (x y : M) : Q (x - y) = Q (y - x) := by rw [â neg_sub, Q.map_neg]
@[simp]
theorem polar_zero_left (y : M) : polar Q 0 y = 0 := by
simp only [polar, zero_add, QuadraticMap.map_zero, sub_zero, sub_self]
@[simp]
theorem polar_add_left (x x' y : M) : polar Q (x + x') y = polar Q x y + polar Q x' y :=
polar_add_left_iff.mpr <| Q.map_add_add_add_map x x' y
@[simp]
theorem polar_smul_left (a : R) (x y : M) : polar Q (a ⢠x) y = a ⢠polar Q x y := by
obtain âšB, hâ© := Q.exists_companion
simp_rw [polar, h, Q.map_smul, LinearMap.map_smulâ, sub_sub, add_sub_cancel_left]
@[simp]
theorem polar_neg_left (x y : M) : polar Q (-x) y = -polar Q x y := by
rw [â neg_one_smul R x, polar_smul_left, neg_one_smul]
@[simp]
theorem polar_sub_left (x x' y : M) : polar Q (x - x') y = polar Q x y - polar Q x' y := by
rw [sub_eq_add_neg, sub_eq_add_neg, polar_add_left, polar_neg_left]
@[simp]
theorem polar_zero_right (y : M) : polar Q y 0 = 0 := by
simp only [add_zero, polar, QuadraticMap.map_zero, sub_self]
@[simp]
theorem polar_add_right (x y y' : M) : polar Q x (y + y') = polar Q x y + polar Q x y' := by
rw [polar_comm Q x, polar_comm Q x, polar_comm Q x, polar_add_left]
@[simp]
theorem polar_smul_right (a : R) (x y : M) : polar Q x (a ⢠y) = a ⢠polar Q x y := by
rw [polar_comm Q x, polar_comm Q x, polar_smul_left]
@[simp]
theorem polar_neg_right (x y : M) : polar Q x (-y) = -polar Q x y := by
rw [â neg_one_smul R y, polar_smul_right, neg_one_smul]
@[simp]
theorem polar_sub_right (x y y' : M) : polar Q x (y - y') = polar Q x y - polar Q x y' := by
rw [sub_eq_add_neg, sub_eq_add_neg, polar_add_right, polar_neg_right]
@[simp]
theorem polar_self (x : M) : polar Q x x = 2 ⢠Q x := by
rw [polar, map_add_self, sub_sub, sub_eq_iff_eq_add, â two_smul â, â two_smul â, â mul_smul]
norm_num
/-- `QuadraticMap.polar` as a bilinear map -/
@[simps!]
def polarBilin : BilinMap R M N :=
LinearMap.mkâ R (polar Q) (polar_add_left Q) (polar_smul_left Q) (polar_add_right Q)
(polar_smul_right Q)
lemma polarSym2_map_smul {ι} (Q : QuadraticMap R M N) (g : ι â M) (l : ι â R) (p : Sym2 ι) :
polarSym2 Q (p.map (l ⢠g)) = (p.map l).mul ⢠polarSym2 Q (p.map g) := by
obtain âš_, _â© := p; simp [â smul_assoc, mul_comm]
variable [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] [Module S N]
[IsScalarTower S R N]
@[simp]
theorem polar_smul_left_of_tower (a : S) (x y : M) : polar Q (a ⢠x) y = a ⢠polar Q x y := by
rw [â IsScalarTower.algebraMap_smul R a x, polar_smul_left, algebraMap_smul]
@[simp]
theorem polar_smul_right_of_tower (a : S) (x y : M) : polar Q x (a ⢠y) = a ⢠polar Q x y := by
rw [â IsScalarTower.algebraMap_smul R a y, polar_smul_right, algebraMap_smul]
/-- An alternative constructor to `QuadraticMap.mk`, for rings where `polar` can be used. -/
@[simps]
def ofPolar (toFun : M â N) (toFun_smul : â (a : R) (x : M), toFun (a ⢠x) = (a * a) ⢠toFun x)
(polar_add_left : â x x' y : M, polar toFun (x + x') y = polar toFun x y + polar toFun x' y)
(polar_smul_left : â (a : R) (x y : M), polar toFun (a ⢠x) y = a ⢠polar toFun x y) :
QuadraticMap R M N :=
{ toFun
toFun_smul
exists_companion' := âšLinearMap.mkâ R (polar toFun) (polar_add_left) (polar_smul_left)
(fun x _ _ ⊠by simp_rw [polar_comm _ x, polar_add_left])
(fun _ _ _ ⊠by rw [polar_comm, polar_smul_left, polar_comm]),
fun _ _ ⊠by
simp only [LinearMap.mkâ_apply]
rw [polar, sub_sub, add_sub_cancel]â© }
/-- In a ring the companion bilinear form is unique and equal to `QuadraticMap.polar`. -/
theorem choose_exists_companion : Q.exists_companion.choose = polarBilin Q :=
LinearMap.extâ fun x y => by
rw [polarBilin_apply_apply, polar, Q.exists_companion.choose_spec, sub_sub,
add_sub_cancel_left]
protected theorem map_sum {ι} [DecidableEq ι] (Q : QuadraticMap R M N) (s : Finset ι) (f : ι â M) :
Q (â i â s, f i) = â i â s, Q (f i)
+ â ij â s.sym2 with ¬ ij.IsDiag, polarSym2 Q (ij.map f) := by
induction s using Finset.cons_induction with
| empty => simp
| cons a s ha ih =>
simp_rw [Finset.sum_cons, QuadraticMap.map_add, ih, add_assoc, Finset.sym2_cons,
Finset.sum_filter, Finset.sum_disjUnion, Finset.sum_map, Finset.sum_cons,
Sym2.mkEmbedding_apply, Sym2.isDiag_iff_proj_eq, not_true, if_false, zero_add,
Sym2.map_pair_eq, polarSym2_sym2Mk, â polarBilin_apply_apply, _root_.map_sum,
polarBilin_apply_apply]
congr 2
rw [add_comm]
congr! with i hi
rw [if_pos (ne_of_mem_of_not_mem hi ha).symm]
protected theorem map_sum' {ι} (Q : QuadraticMap R M N) (s : Finset ι) (f : ι â M) :
Q (â i â s, f i) = â ij â s.sym2, polarSym2 Q (ij.map f) - â i â s, Q (f i) := by
induction s using Finset.cons_induction with
| empty => simp
| cons a s ha ih =>
simp_rw [Finset.sum_cons, QuadraticMap.map_add Q, ih, add_assoc, Finset.sym2_cons,
Finset.sum_disjUnion, Finset.sum_map, Finset.sum_cons, Sym2.mkEmbedding_apply,
Sym2.map_pair_eq, polarSym2_sym2Mk, â polarBilin_apply_apply, _root_.map_sum,
polarBilin_apply_apply, polar_self]
abel_nf
end CommRing
section SemiringOperators
variable [CommSemiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
section SMul
variable [Monoid S] [Monoid T] [DistribMulAction S N] [DistribMulAction T N]
variable [SMulCommClass S R N] [SMulCommClass T R N]
/-- `QuadraticMap R M N` inherits the scalar action from any algebra over `R`.
This provides an `R`-action via `Algebra.id`. -/
instance : SMul S (QuadraticMap R M N) :=
âšfun a Q =>
{ toFun := a ⢠âQ
toFun_smul := fun b x => by
rw [Pi.smul_apply, Q.map_smul, Pi.smul_apply, smul_comm]
exists_companion' :=
let âšB, hâ© := Q.exists_companion
letI := SMulCommClass.symm S R N
âša ⢠B, by simp [h]â© }â©
@[simp]
theorem coeFn_smul (a : S) (Q : QuadraticMap R M N) : â(a ⢠Q) = a ⢠âQ :=
rfl
@[simp]
theorem smul_apply (a : S) (Q : QuadraticMap R M N) (x : M) : (a ⢠Q) x = a ⢠Q x :=
rfl
instance [SMulCommClass S T N] : SMulCommClass S T (QuadraticMap R M N) where
smul_comm _s _t _q := ext fun _ => smul_comm _ _ _
instance [SMul S T] [IsScalarTower S T N] : IsScalarTower S T (QuadraticMap R M N) where
smul_assoc _s _t _q := ext fun _ => smul_assoc _ _ _
end SMul
instance : Zero (QuadraticMap R M N) :=
âš{ toFun := fun _ => 0
toFun_smul := fun a _ => by simp only [smul_zero]
exists_companion' := âš0, fun _ _ => by simp only [add_zero, LinearMap.zero_apply]â© }â©
@[simp]
theorem coeFn_zero : â(0 : QuadraticMap R M N) = 0 :=
rfl
@[simp]
theorem zero_apply (x : M) : (0 : QuadraticMap R M N) x = 0 :=
rfl
instance : Inhabited (QuadraticMap R M N) :=
âš0â©
instance : Add (QuadraticMap R M N) :=
âšfun Q Q' =>
{ toFun := Q + Q'
toFun_smul := fun a x => by simp only [Pi.add_apply, smul_add, QuadraticMap.map_smul]
exists_companion' :=
let âšB, hâ© := Q.exists_companion
let âšB', h'â© := Q'.exists_companion
âšB + B', fun x y => by
simp_rw [Pi.add_apply, h, h', LinearMap.add_apply, add_add_add_comm]â© }â©
@[simp]
theorem coeFn_add (Q Q' : QuadraticMap R M N) : â(Q + Q') = Q + Q' :=
rfl
@[simp]
theorem add_apply (Q Q' : QuadraticMap R M N) (x : M) : (Q + Q') x = Q x + Q' x :=
rfl
instance : AddCommMonoid (QuadraticMap R M N) :=
DFunLike.coe_injective.addCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _
/-- `@CoeFn (QuadraticMap R M)` as an `AddMonoidHom`.
This API mirrors `AddMonoidHom.coeFn`. -/
@[simps apply]
def coeFnAddMonoidHom : QuadraticMap R M N â+ M â N where
toFun := DFunLike.coe
map_zero' := coeFn_zero
map_add' := coeFn_add
/-- Evaluation on a particular element of the module `M` is an additive map on quadratic maps. -/
@[simps! apply]
def evalAddMonoidHom (m : M) : QuadraticMap R M N â+ N :=
(Pi.evalAddMonoidHom _ m).comp coeFnAddMonoidHom
section Sum
@[simp]
theorem coeFn_sum {ι : Type*} (Q : ι â QuadraticMap R M N) (s : Finset ι) :
â(â i â s, Q i) = â i â s, â(Q i) :=
map_sum coeFnAddMonoidHom Q s
@[simp]
theorem sum_apply {ι : Type*} (Q : ι â QuadraticMap R M N) (s : Finset ι) (x : M) :
(â i â s, Q i) x = â i â s, Q i x :=
map_sum (evalAddMonoidHom x : _ â+ N) Q s
end Sum
instance [Monoid S] [DistribMulAction S N] [SMulCommClass S R N] :
DistribMulAction S (QuadraticMap R M N) where
mul_smul a b Q := ext fun x => by simp only [smul_apply, mul_smul]
one_smul Q := ext fun x => by simp only [QuadraticMap.smul_apply, one_smul]
smul_add a Q Q' := by
ext
simp only [add_apply, smul_apply, smul_add]
smul_zero a := by
ext
simp only [zero_apply, smul_apply, smul_zero]
instance [Semiring S] [Module S N] [SMulCommClass S R N] :
Module S (QuadraticMap R M N) where
zero_smul Q := by
ext
simp only [zero_apply, smul_apply, zero_smul]
add_smul a b Q := by
ext
simp only [add_apply, smul_apply, add_smul]
end SemiringOperators
section RingOperators
variable [CommRing R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
instance : Neg (QuadraticMap R M N) :=
âšfun Q =>
{ toFun := -Q
toFun_smul := fun a x => by simp only [Pi.neg_apply, Q.map_smul, smul_neg]
exists_companion' :=
let âšB, hâ© := Q.exists_companion
âš-B, fun x y => by simp_rw [Pi.neg_apply, h, LinearMap.neg_apply, neg_add]â© }â©
@[simp]
theorem coeFn_neg (Q : QuadraticMap R M N) : â(-Q) = -Q :=
rfl
@[simp]
theorem neg_apply (Q : QuadraticMap R M N) (x : M) : (-Q) x = -Q x :=
rfl
instance : Sub (QuadraticMap R M N) :=
âšfun Q Q' => (Q + -Q').copy (Q - Q') (sub_eq_add_neg _ _)â©
@[simp]
theorem coeFn_sub (Q Q' : QuadraticMap R M N) : â(Q - Q') = Q - Q' :=
rfl
@[simp]
theorem sub_apply (Q Q' : QuadraticMap R M N) (x : M) : (Q - Q') x = Q x - Q' x :=
rfl
instance : AddCommGroup (QuadraticMap R M N) :=
DFunLike.coe_injective.addCommGroup _ coeFn_zero coeFn_add coeFn_neg coeFn_sub
(fun _ _ => coeFn_smul _ _) fun _ _ => coeFn_smul _ _
end RingOperators
section restrictScalars
variable [CommSemiring R] [CommSemiring S] [AddCommMonoid M] [Module R M] [AddCommMonoid N]
[Module R N] [Module S M] [Module S N] [Algebra S R]
variable [IsScalarTower S R M] [IsScalarTower S R N]
/-- If `Q : M â N` is a quadratic map of `R`-modules and `R` is an `S`-algebra,
then the restriction of scalars is a quadratic map of `S`-modules. -/
@[simps!]
def restrictScalars (Q : QuadraticMap R M N) : QuadraticMap S M N where
toFun x := Q x
toFun_smul a x := by
simp [map_smul_of_tower]
exists_companion' :=
let âšB, hâ© := Q.exists_companion
âšB.restrictScalarsââ (S := R) (R' := S) (S' := S), fun x y => by
simp only [LinearMap.restrictScalarsââ_apply_apply, h]â©
end restrictScalars
section Comp
variable [CommSemiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
variable [AddCommMonoid P] [Module R P]
/-- Compose the quadratic map with a linear function on the right. -/
def comp (Q : QuadraticMap R N P) (f : M ââ[R] N) : QuadraticMap R M P where
toFun x := Q (f x)
toFun_smul a x := by simp only [Q.map_smul, map_smul]
exists_companion' :=
let âšB, hâ© := Q.exists_companion
âšB.complââ f f, fun x y => by simp_rw [f.map_add]; exact h (f x) (f y)â©
@[simp]
theorem comp_apply (Q : QuadraticMap R N P) (f : M ââ[R] N) (x : M) : (Q.comp f) x = Q (f x) :=
rfl
/-- Compose a quadratic map with a linear function on the left. -/
@[simps +simpRhs]
def _root_.LinearMap.compQuadraticMap (f : N ââ[R] P) (Q : QuadraticMap R M N) :
QuadraticMap R M P where
toFun x := f (Q x)
toFun_smul b x := by simp only [Q.map_smul, map_smul]
exists_companion' :=
let âšB, hâ© := Q.exists_companion
âšB.comprâ f, fun x y => by simp only [h, map_add, LinearMap.comprâ_apply]â©
/-- Compose a quadratic map with a linear function on the left. -/
@[simps! +simpRhs]
def _root_.LinearMap.compQuadraticMap' [CommSemiring S] [Algebra S R] [Module S N] [Module S M]
[IsScalarTower S R N] [IsScalarTower S R M] [Module S P]
(f : N ââ[S] P) (Q : QuadraticMap R M N) : QuadraticMap S M P :=
_root_.LinearMap.compQuadraticMap f Q.restrictScalars
/-- When `N` and `P` are equivalent, quadratic maps on `M` into `N` are equivalent to quadratic
maps on `M` into `P`.
See `LinearMap.BilinMap.congrâ` for the bilinear map version. -/
@[simps]
def _root_.LinearEquiv.congrQuadraticMap (e : N ââ[R] P) :
QuadraticMap R M N ââ[R] QuadraticMap R M P where
toFun Q := e.compQuadraticMap Q
invFun Q := e.symm.compQuadraticMap Q
left_inv _ := ext fun _ => e.symm_apply_apply _
right_inv _ := ext fun _ => e.apply_symm_apply _
map_add' _ _ := ext fun _ => map_add e _ _
map_smul' _ _ := ext fun _ => e.map_smul _ _
@[simp]
theorem _root_.LinearEquiv.congrQuadraticMap_refl :
LinearEquiv.congrQuadraticMap (.refl R N) = .refl R (QuadraticMap R M N) := rfl
@[simp]
theorem _root_.LinearEquiv.congrQuadraticMap_symm (e : N ââ[R] P) :
(LinearEquiv.congrQuadraticMap e (M := M)).symm = e.symm.congrQuadraticMap := rfl
end Comp
section NonUnitalNonAssocSemiring
variable [CommSemiring R] [NonUnitalNonAssocSemiring A] [AddCommMonoid M] [Module R M]
variable [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]
/-- The product of linear maps into an `R`-algebra is a quadratic map. -/
def linMulLin (f g : M ââ[R] A) : QuadraticMap R M A where
toFun := f * g
toFun_smul a x := by
rw [Pi.mul_apply, Pi.mul_apply, LinearMap.map_smulââ, RingHom.id_apply, LinearMap.map_smulââ,
RingHom.id_apply, smul_mul_assoc, mul_smul_comm, â smul_assoc, smul_eq_mul]
exists_companion' :=
âš(LinearMap.mul R A).complââ f g + (LinearMap.mul R A).flip.complââ g f, fun x y => by
simp only [Pi.mul_apply, map_add, left_distrib, right_distrib, LinearMap.add_apply,
LinearMap.complââ_apply, LinearMap.mul_apply', LinearMap.flip_apply]
abel_nfâ©
@[simp]
theorem linMulLin_apply (f g : M ââ[R] A) (x) : linMulLin f g x = f x * g x :=
rfl
@[simp]
theorem add_linMulLin (f g h : M ââ[R] A) : linMulLin (f + g) h = linMulLin f h + linMulLin g h :=
ext fun _ => add_mul _ _ _
@[simp]
theorem linMulLin_add (f g h : M ââ[R] A) : linMulLin f (g + h) = linMulLin f g + linMulLin f h :=
ext fun _ => mul_add _ _ _
variable {N' : Type*} [AddCommMonoid N'] [Module R N']
@[simp]
theorem linMulLin_comp (f g : M ââ[R] A) (h : N' ââ[R] M) :
(linMulLin f g).comp h = linMulLin (f.comp h) (g.comp h) :=
rfl
variable {n : Type*}
/-- `sq` is the quadratic map sending the vector `x : A` to `x * x` -/
@[simps!]
def sq : QuadraticMap R A A :=
linMulLin LinearMap.id LinearMap.id
/-- `proj i j` is the quadratic map sending the vector `x : n â R` to `x i * x j` -/
def proj (i j : n) : QuadraticMap R (n â A) A :=
linMulLin (@LinearMap.proj _ _ _ (fun _ => A) _ _ i) (@LinearMap.proj _ _ _ (fun _ => A) _ _ j)
@[simp]
theorem proj_apply (i j : n) (x : n â A) : proj (R := R) i j x = x i * x j :=
rfl
end NonUnitalNonAssocSemiring
end QuadraticMap
/-!
### Associated bilinear maps
If multiplication by 2 is invertible on the target module `N` of
`QuadraticMap R M N`, then there is a linear bijection `QuadraticMap.associated`
between quadratic maps `Q` over `R` from `M` to `N` and symmetric bilinear maps
`B : M ââ[R] M ââ[R] â N` such that `BilinMap.toQuadraticMap B = Q`
(see `QuadraticMap.associated_rightInverse`). The associated bilinear map is half
`Q.polarBilin` (see `QuadraticMap.two_nsmul_associated`); this is where the invertibility condition
comes from. We spell the condition as `[Invertible (2 : Module.End R N)]`.
Note that this makes the bijection available in more cases than the simpler condition
`Invertible (2 : R)`, e.g., when `R = â€` and `N = â`.
-/
namespace LinearMap
namespace BilinMap
open QuadraticMap
open LinearMap (BilinMap)
section Semiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
variable {N' : Type*} [AddCommMonoid N'] [Module R N']
/-- A bilinear map gives a quadratic map by applying the argument twice. -/
def toQuadraticMap (B : BilinMap R M N) : QuadraticMap R M N where
toFun x := B x x
toFun_smul a x := by simp only [map_smul, LinearMap.smul_apply, smul_smul]
exists_companion' := âšB + LinearMap.flip B, fun x y => by simp [add_add_add_comm, add_comm]â©
@[simp]
theorem toQuadraticMap_apply (B : BilinMap R M N) (x : M) : B.toQuadraticMap x = B x x :=
rfl
theorem toQuadraticMap_comp_same (B : BilinMap R M N) (f : N' ââ[R] M) :
BilinMap.toQuadraticMap (B.complââ f f) = B.toQuadraticMap.comp f := rfl
section
variable (R M)
@[simp]
theorem toQuadraticMap_zero : (0 : BilinMap R M N).toQuadraticMap = 0 :=
rfl
end
@[simp]
theorem toQuadraticMap_add (Bâ Bâ : BilinMap R M N) :
(Bâ + Bâ).toQuadraticMap = Bâ.toQuadraticMap + Bâ.toQuadraticMap :=
rfl
@[simp]
theorem toQuadraticMap_smul [Monoid S] [DistribMulAction S N] [SMulCommClass S R N]
[SMulCommClass R S N] (a : S)
(B : BilinMap R M N) : (a ⢠B).toQuadraticMap = a ⢠B.toQuadraticMap :=
rfl
section
variable (S R M)
/-- `LinearMap.BilinMap.toQuadraticMap` as an additive homomorphism -/
@[simps]
def toQuadraticMapAddMonoidHom : (BilinMap R M N) â+ QuadraticMap R M N where
toFun := toQuadraticMap
map_zero' := toQuadraticMap_zero _ _
map_add' := toQuadraticMap_add
/-- `LinearMap.BilinMap.toQuadraticMap` as a linear map -/
@[simps!]
def toQuadraticMapLinearMap [Semiring S] [Module S N] [SMulCommClass S R N] [SMulCommClass R S N] :
(BilinMap R M N) ââ[S] QuadraticMap R M N where
toFun := toQuadraticMap
map_smul' := toQuadraticMap_smul
map_add' := toQuadraticMap_add
end
@[simp]
theorem toQuadraticMap_list_sum (B : List (BilinMap R M N)) :
B.sum.toQuadraticMap = (B.map toQuadraticMap).sum :=
map_list_sum (toQuadraticMapAddMonoidHom R M) B
@[simp]
theorem toQuadraticMap_multiset_sum (B : Multiset (BilinMap R M N)) :
B.sum.toQuadraticMap = (B.map toQuadraticMap).sum :=
map_multiset_sum (toQuadraticMapAddMonoidHom R M) B
@[simp]
theorem toQuadraticMap_sum {ι : Type*} (s : Finset ι) (B : ι â (BilinMap R M N)) :
(â i â s, B i).toQuadraticMap = â i â s, (B i).toQuadraticMap :=
map_sum (toQuadraticMapAddMonoidHom R M) B s
@[simp]
theorem toQuadraticMap_eq_zero {B : BilinMap R M N} :
B.toQuadraticMap = 0 â B.IsAlt :=
QuadraticMap.ext_iff
end Semiring
section Ring
variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [Module R M] [Module R N]
variable {B : BilinMap R M N}
@[simp]
theorem toQuadraticMap_neg (B : BilinMap R M N) : (-B).toQuadraticMap = -B.toQuadraticMap :=
rfl
@[simp]
theorem toQuadraticMap_sub (Bâ Bâ : BilinMap R M N) :
(Bâ - Bâ).toQuadraticMap = Bâ.toQuadraticMap - Bâ.toQuadraticMap :=
rfl
theorem polar_toQuadraticMap (x y : M) : polar (toQuadraticMap B) x y = B x y + B y x := by
simp only [polar, toQuadraticMap_apply, map_add, add_apply, add_assoc, add_comm (B y x) _,
add_sub_cancel_left, sub_eq_add_neg _ (B y y), add_neg_cancel_left]
theorem polarBilin_toQuadraticMap : polarBilin (toQuadraticMap B) = B + flip B :=
LinearMap.extâ polar_toQuadraticMap
@[simp] theorem _root_.QuadraticMap.toQuadraticMap_polarBilin (Q : QuadraticMap R M N) :
toQuadraticMap (polarBilin Q) = 2 ⢠Q :=
QuadraticMap.ext fun x => (polar_self _ x).trans <| by simp
theorem _root_.QuadraticMap.polarBilin_injective (h : IsUnit (2 : R)) :
Function.Injective (polarBilin : QuadraticMap R M N â _) := by
intro Qâ Qâ hââ
apply h.smul_left_cancel.mp
rw [show (2 : R) = (2 : â) by rfl]
simp_rw [Nat.cast_smul_eq_nsmul R, â QuadraticMap.toQuadraticMap_polarBilin]
exact congrArg toQuadraticMap hââ
section
variable {N' : Type*} [AddCommGroup N'] [Module R N']
theorem _root_.QuadraticMap.polarBilin_comp (Q : QuadraticMap R N' N) (f : M ââ[R] N') :
polarBilin (Q.comp f) = LinearMap.complââ (polarBilin Q) f f :=
LinearMap.extâ <| fun x y => by simp [polar]
end
variable {N' : Type*} [AddCommGroup N']
theorem _root_.LinearMap.compQuadraticMap_polar [CommSemiring S] [Algebra S R] [Module S N]
[Module S N'] [IsScalarTower S R N] [Module S M] [IsScalarTower S R M] (f : N ââ[S] N')
(Q : QuadraticMap R M N) (x y : M) : polar (f.compQuadraticMap' Q) x y = f (polar Q x y) := by
simp [polar]
variable [Module R N']
theorem _root_.LinearMap.compQuadraticMap_polarBilin (f : N ââ[R] N') (Q : QuadraticMap R M N) :
(f.compQuadraticMap' Q).polarBilin = Q.polarBilin.comprâ f := by
ext
rw [polarBilin_apply_apply, comprâ_apply, polarBilin_apply_apply,
LinearMap.compQuadraticMap_polar]
end Ring
end BilinMap
end LinearMap
namespace QuadraticMap
open LinearMap (BilinMap)
section
variable [Semiring R] [AddCommMonoid M] [Module R M]
instance : SMulCommClass R (Submonoid.center R) M where
smul_comm r r' m := by
simp_rw [Submonoid.smul_def, smul_smul, (Set.mem_center_iff.1 r'.prop).1]
/-- If `2` is invertible in `R`, then it is also invertible in `End R M`. -/
instance [Invertible (2 : R)] : Invertible (2 : Module.End R M) where
invOf := (âšâ
2, Set.invOf_mem_center (Set.ofNat_mem_center _ _)â© : Submonoid.center R) â¢
(1 : Module.End R M)
invOf_mul_self := by
ext m
dsimp [Submonoid.smul_def]
rw [â ofNat_smul_eq_nsmul R, invOf_smul_smul (2 : R) m]
mul_invOf_self := by
ext m
dsimp [Submonoid.smul_def]
rw [â ofNat_smul_eq_nsmul R, smul_invOf_smul (2 : R) m]
/-- If `2` is invertible in `R`, then applying the inverse of `2` in `End R M` to an element
of `M` is the same as multiplying by the inverse of `2` in `R`. -/
@[simp]
lemma half_moduleEnd_apply_eq_half_smul [Invertible (2 : R)] (x : M) :
â
(2 : Module.End R M) x = â
(2 : R) ⢠x :=
rfl
end
section AssociatedHom
variable [CommRing R] [AddCommGroup M] [Module R M]
variable [AddCommGroup N] [Module R N]
variable (S) [CommSemiring S] [Algebra S R] [Module S N] [IsScalarTower S R N]
-- the requirement that multiplication by `2` is invertible on the target module `N`
variable [Invertible (2 : Module.End R N)]
/-- `associatedHom` is the map that sends a quadratic map on a module `M` over `R` to its
associated symmetric bilinear map. As provided here, this has the structure of an `S`-linear map
where `S` is a commutative ring and `R` is an `S`-algebra.
Over a commutative ring, use `QuadraticMap.associated`, which gives an `R`-linear map. Over a
general ring with no nontrivial distinguished commutative subring, use `QuadraticMap.associated'`,
which gives an additive homomorphism (or more precisely a `â€`-linear map.) -/
def associatedHom : QuadraticMap R M N ââ[S] (BilinMap R M N) where
toFun Q := â
(2 : Module.End R N) ⢠polarBilin Q
map_add' _ _ := LinearMap.extâ fun _ _ ⊠by simp [polar_add]
map_smul' _ _ := LinearMap.extâ fun _ _ ⊠by simp [polar_smul]
variable (Q : QuadraticMap R M N)
@[simp]
theorem associated_apply (x y : M) :
associatedHom S Q x y = â
(2 : Module.End R N) ⢠(Q (x + y) - Q x - Q y) :=
rfl
/-- Twice the associated bilinear map of `Q` is the same as the polar of `Q`. -/
@[simp] theorem two_nsmul_associated : 2 ⢠associatedHom S Q = Q.polarBilin := by
ext
dsimp
rw [â LinearMap.smul_apply, nsmul_eq_mul, Nat.cast_ofNat, mul_invOf_self', Module.End.one_apply,
polar]
theorem associated_isSymm (Q : QuadraticMap R M N) (x y : M) :
associatedHom S Q x y = associatedHom S Q y x := by
simp only [associated_apply, sub_eq_add_neg, add_assoc, add_comm, add_left_comm]
theorem _root_.QuadraticForm.associated_isSymm (Q : QuadraticForm R M) [Invertible (2 : R)] :
(associatedHom S Q).IsSymm :=
QuadraticMap.associated_isSymm S Q
/-- A version of `QuadraticMap.associated_isSymm` for general targets
(using `flip` because `IsSymm` does not apply here). -/
lemma associated_flip : (associatedHom S Q).flip = associatedHom S Q := by
ext
simp only [LinearMap.flip_apply, associated_apply, add_comm, sub_eq_add_neg, add_left_comm,
add_assoc]
@[simp]
theorem associated_comp {N' : Type*} [AddCommGroup N'] [Module R N'] (f : N' ââ[R] M) :
associatedHom S (Q.comp f) = (associatedHom S Q).complââ f f := by
ext
simp only [associated_apply, comp_apply, map_add, LinearMap.complââ_apply]
theorem associated_toQuadraticMap (B : BilinMap R M N) (x y : M) :
associatedHom S B.toQuadraticMap x y = â
(2 : Module.End R N) ⢠(B x y + B y x) := by
simp only [associated_apply, BilinMap.toQuadraticMap_apply, map_add, LinearMap.add_apply,
Module.End.smul_def, map_sub]
abel_nf
theorem associated_left_inverse {Bâ : BilinMap R M N} (h : â x y, Bâ x y = Bâ y x) :
associatedHom S Bâ.toQuadraticMap = Bâ :=
LinearMap.extâ fun x y ⊠by
rw [associated_toQuadraticMap, â h x y, â two_smul R, invOf_smul_eq_iff, two_smul, two_smul]
/-- A version of `QuadraticMap.associated_left_inverse` for general targets. -/
lemma associated_left_inverse' {Bâ : BilinMap R M N} (hBâ : Bâ.flip = Bâ) :
associatedHom S Bâ.toQuadraticMap = Bâ := by
ext _ y
rw [associated_toQuadraticMap, â LinearMap.flip_apply _ y, hBâ, invOf_smul_eq_iff, two_smul]
theorem associated_eq_self_apply (x : M) : associatedHom S Q x x = Q x := by
rw [associated_apply, map_add_self, â three_add_one_eq_four, â two_add_one_eq_three, add_smul,
add_smul, one_smul, add_sub_cancel_right, add_sub_cancel_right, two_smul, â two_smul R,
invOf_smul_eq_iff, two_smul, two_smul]
theorem toQuadraticMap_associated : (associatedHom S Q).toQuadraticMap = Q :=
QuadraticMap.ext <| associated_eq_self_apply S Q
-- note: usually `rightInverse` lemmas are named the other way around, but this is consistent
-- with historical naming in this file.
theorem associated_rightInverse :
Function.RightInverse (associatedHom S) (BilinMap.toQuadraticMap : _ â QuadraticMap R M N) :=
toQuadraticMap_associated S
/-- `associated'` is the `â€`-linear map that sends a quadratic form on a module `M` over `R` to its
associated symmetric bilinear form. -/
abbrev associated' : QuadraticMap R M N ââ[â€] BilinMap R M N :=
associatedHom â€
/-- Symmetric bilinear forms can be lifted to quadratic forms -/
instance canLift [Invertible (2 : R)] :
CanLift (BilinMap R M R) (QuadraticForm R M) (associatedHom â) LinearMap.IsSymm where
prf B hB := âšB.toQuadraticMap, associated_left_inverse _ hBâ©
/-- Symmetric bilinear maps can be lifted to quadratic maps -/
instance canLift' :
CanLift (BilinMap R M N) (QuadraticMap R M N) (associatedHom â) fun B ⊠B.flip = B where
prf B hB := âšB.toQuadraticMap, associated_left_inverse' _ hBâ©
/-- There exists a non-null vector with respect to any quadratic form `Q` whose associated
bilinear form is non-zero, i.e. there exists `x` such that `Q x â 0`. -/
theorem exists_quadraticMap_ne_zero {Q : QuadraticMap R M N}
-- Porting note: added implicit argument
(hBâ : associated' (N := N) Q â 0) :
â x, Q x â 0 := by
rw [â not_forall]
intro h
apply hBâ
rw [(QuadraticMap.ext h : Q = 0), LinearMap.map_zero]
end AssociatedHom
section Associated
variable [CommSemiring S] [CommRing R] [AddCommGroup M] [Algebra S R] [Module R M]
variable [AddCommGroup N] [Module R N] [Module S N] [IsScalarTower S R N]
variable [Invertible (2 : Module.End R N)]
-- Note: When possible, rather than writing lemmas about `associated`, write a lemma applying to
-- the more general `associatedHom` and place it in the previous section.
/-- `associated` is the linear map that sends a quadratic map over a commutative ring to its
associated symmetric bilinear map. -/
abbrev associated : QuadraticMap R M N ââ[R] BilinMap R M N :=
associatedHom R
variable (S) in
theorem coe_associatedHom :
â(associatedHom S : QuadraticMap R M N ââ[S] BilinMap R M N) = associated :=
rfl
open LinearMap in
@[simp]
theorem associated_linMulLin [Invertible (2 : R)] (f g : M ââ[R] R) :
associated (R := R) (N := R) (linMulLin f g) =
â
(2 : R) ⢠((mul R R).complââ f g + (mul R R).complââ g f) := by
ext
simp only [associated_apply, linMulLin_apply, map_add, smul_add, LinearMap.add_apply,
LinearMap.smul_apply, complââ_apply, mul_apply', smul_eq_mul, invOf_smul_eq_iff]
simp only [smul_add, Module.End.smul_def, Module.End.ofNat_apply, nsmul_eq_mul, Nat.cast_ofNat,
mul_invOf_cancel_left']
ring_nf
open LinearMap in
@[simp]
lemma associated_sq [Invertible (2 : R)] : associated (R := R) sq = mul R R :=
(associated_linMulLin (id) (id)).trans <|
by simp only [smul_add, invOf_two_smul_add_invOf_two_smul]; rfl
end Associated
section IsOrtho
/-! ### Orthogonality -/
section CommSemiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
{Q : QuadraticMap R M N}
/-- The proposition that two elements of a quadratic map space are orthogonal. -/
def IsOrtho (Q : QuadraticMap R M N) (x y : M) : Prop :=
Q (x + y) = Q x + Q y
theorem isOrtho_def {Q : QuadraticMap R M N} {x y : M} : Q.IsOrtho x y â Q (x + y) = Q x + Q y :=
Iff.rfl
theorem IsOrtho.all (x y : M) : IsOrtho (0 : QuadraticMap R M N) x y := (zero_add _).symm
theorem IsOrtho.zero_left (x : M) : IsOrtho Q (0 : M) x := by simp [isOrtho_def]
theorem IsOrtho.zero_right (x : M) : IsOrtho Q x (0 : M) := by simp [isOrtho_def]
theorem ne_zero_of_not_isOrtho_self {Q : QuadraticMap R M N} (x : M) (hxâ : ¬Q.IsOrtho x x) :
x â 0 :=
fun hxâ => hxâ (hxâ.symm âž .zero_left _)
theorem isOrtho_comm {x y : M} : IsOrtho Q x y â IsOrtho Q y x := by simp_rw [isOrtho_def, add_comm]
alias âšIsOrtho.symm, _â© := isOrtho_comm
theorem _root_.LinearMap.BilinForm.toQuadraticMap_isOrtho [IsCancelAdd R]
[NoZeroDivisors R] [CharZero R] {B : BilinMap R M R} {x y : M} (h : B.IsSymm) :
B.toQuadraticMap.IsOrtho x y â B.IsOrtho x y := by
letI : AddCancelMonoid R := { â¹IsCancelAdd Râº, (inferInstanceAs <| AddCommMonoid R) with }
simp_rw [isOrtho_def, LinearMap.isOrtho_def, B.toQuadraticMap_apply, map_add,
LinearMap.add_apply, add_comm _ (B y y), add_add_add_comm _ _ (B y y), add_comm (B y y)]
rw [add_eq_left (a := B x x + B y y), â h, RingHom.id_apply, add_self_eq_zero]
end CommSemiring
section CommRing
variable [CommRing R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
{Q : QuadraticMap R M N}
@[simp]
theorem isOrtho_polarBilin {x y : M} : Q.polarBilin.IsOrtho x y â IsOrtho Q x y := by
simp_rw [isOrtho_def, LinearMap.isOrtho_def, polarBilin_apply_apply, polar, sub_sub, sub_eq_zero]
theorem IsOrtho.polar_eq_zero {x y : M} (h : IsOrtho Q x y) : polar Q x y = 0 :=
isOrtho_polarBilin.mpr h
@[simp]
theorem associated_isOrtho [Invertible (2 : R)] {x y : M} :
Q.associated.IsOrtho x y â Q.IsOrtho x y := by
simp_rw [isOrtho_def, LinearMap.isOrtho_def, associated_apply, invOf_smul_eq_iff,
smul_zero, sub_sub, sub_eq_zero]
end CommRing
end IsOrtho
section Anisotropic
section Semiring
variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N]
/-- An anisotropic quadratic map is zero only on zero vectors. -/
def Anisotropic (Q : QuadraticMap R M N) : Prop :=
â x, Q x = 0 â x = 0
theorem not_anisotropic_iff_exists (Q : QuadraticMap R M N) :
¬Anisotropic Q â â x, x â 0 â§ Q x = 0 := by
simp only [Anisotropic, not_forall, exists_prop, and_comm]
theorem Anisotropic.eq_zero_iff {Q : QuadraticMap R M N} (h : Anisotropic Q) {x : M} :
Q x = 0 â x = 0 :=
âšh x, fun h => h.symm âž map_zero Qâ©
end Semiring
section Ring
variable [CommRing R] [AddCommGroup M] [Module R M]
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
theorem separatingLeft_of_anisotropic [Invertible (2 : R)] (Q : QuadraticMap R M R)
(hB : Q.Anisotropic) :
-- Porting note: added implicit argument
(QuadraticMap.associated' (N := R) Q).SeparatingLeft := fun x hx ⊠hB _ <| by
rw [â hx x]
exact (associated_eq_self_apply _ _ x).symm
end Ring
end Anisotropic
section PosDef
variable {Râ : Type u} [CommSemiring Râ] [AddCommMonoid M] [Module Râ M]
variable [PartialOrder N] [AddCommMonoid N] [Module Râ N]
variable {Qâ : QuadraticMap Râ M N}
/-- A positive definite quadratic form is positive on nonzero vectors. -/
def PosDef (Qâ : QuadraticMap Râ M N) : Prop :=
| â x, x â 0 â 0 < Qâ x
theorem PosDef.smul {R} [CommSemiring R] [PartialOrder R]
| Mathlib/LinearAlgebra/QuadraticForm/Basic.lean | 1,125 | 1,128 |
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Data.Finset.NAry
import Mathlib.Data.Finset.Slice
import Mathlib.Data.Set.Sups
/-!
# Set family operations
This file defines a few binary operations on `Finset α` for use in set family combinatorics.
## Main declarations
* `Finset.sups s t`: Finset of elements of the form `a â b` where `a â s`, `b â t`.
* `Finset.infs s t`: Finset of elements of the form `a â b` where `a â s`, `b â t`.
* `Finset.disjSups s t`: Finset of elements of the form `a â b` where `a â s`, `b â t` and `a`
and `b` are disjoint.
* `Finset.diffs`: Finset of elements of the form `a \ b` where `a â s`, `b â t`.
* `Finset.compls`: Finset of elements of the form `aá¶` where `a â s`.
## Notation
We define the following notation in locale `FinsetFamily`:
* `s â» t` for `Finset.sups`
* `s ⌠t` for `Finset.infs`
* `s â t` for `Finset.disjSups s t`
* `s \\ t` for `Finset.diffs`
* `sá¶Ë¢` for `Finset.compls`
## References
[B. Bollobás, *Combinatorics*][bollobas1986]
-/
open Function
open SetFamily
variable {F α β : Type*}
namespace Finset
section Sups
variable [DecidableEq α] [DecidableEq β]
variable [SemilatticeSup α] [SemilatticeSup β] [FunLike F α β] [SupHomClass F α β]
variable (s sâ sâ t tâ tâ u v : Finset α)
/-- `s â» t` is the finset of elements of the form `a â b` where `a â s`, `b â t`. -/
protected def hasSups : HasSups (Finset α) :=
âšimageâ (· â ·)â©
scoped[FinsetFamily] attribute [instance] Finset.hasSups
open FinsetFamily
variable {s t} {a b c : α}
@[simp]
theorem mem_sups : c â s â» t â â a â s, â b â t, a â b = c := by simp [(· ⻠·)]
variable (s t)
@[simp, norm_cast]
theorem coe_sups : (â(s â» t) : Set α) = âs â» ât :=
coe_imageâ _ _ _
theorem card_sups_le : #(s â» t) †#s * #t := card_imageâ_le _ _ _
theorem card_sups_iff : #(s â» t) = #s * #t â (s ÃË¢ t : Set (α à α)).InjOn fun x => x.1 â x.2 :=
card_imageâ_iff
variable {s sâ sâ t tâ tâ u}
theorem sup_mem_sups : a â s â b â t â a â b â s â» t :=
mem_imageâ_of_mem
theorem sups_subset : sâ â sâ â tâ â tâ â sâ â» tâ â sâ â» tâ :=
imageâ_subset
theorem sups_subset_left : tâ â tâ â s â» tâ â s â» tâ :=
imageâ_subset_left
theorem sups_subset_right : sâ â sâ â sâ â» t â sâ â» t :=
imageâ_subset_right
lemma image_subset_sups_left : b â t â s.image (· â b) â s â» t := image_subset_imageâ_left
lemma image_subset_sups_right : a â s â t.image (a â ·) â s â» t := image_subset_imageâ_right
theorem forall_sups_iff {p : α â Prop} : (â c â s â» t, p c) â â a â s, â b â t, p (a â b) :=
forall_mem_imageâ
@[simp]
theorem sups_subset_iff : s â» t â u â â a â s, â b â t, a â b â u :=
imageâ_subset_iff
@[simp]
theorem sups_nonempty : (s â» t).Nonempty â s.Nonempty â§ t.Nonempty :=
imageâ_nonempty_iff
@[aesop safe apply (rule_sets := [finsetNonempty])]
protected theorem Nonempty.sups : s.Nonempty â t.Nonempty â (s â» t).Nonempty :=
Nonempty.imageâ
theorem Nonempty.of_sups_left : (s â» t).Nonempty â s.Nonempty :=
Nonempty.of_imageâ_left
theorem Nonempty.of_sups_right : (s â» t).Nonempty â t.Nonempty :=
Nonempty.of_imageâ_right
@[simp]
theorem empty_sups : â
â» t = â
:=
imageâ_empty_left
@[simp]
theorem sups_empty : s â» â
= â
:=
imageâ_empty_right
@[simp]
theorem sups_eq_empty : s â» t = â
â s = â
âš t = â
:=
imageâ_eq_empty_iff
@[simp] lemma singleton_sups : {a} â» t = t.image (a â ·) := imageâ_singleton_left
@[simp] lemma sups_singleton : s â» {b} = s.image (· â b) := imageâ_singleton_right
theorem singleton_sups_singleton : ({a} â» {b} : Finset α) = {a â b} :=
imageâ_singleton
theorem sups_union_left : (sâ ⪠sâ) â» t = sâ â» t ⪠sâ â» t :=
imageâ_union_left
theorem sups_union_right : s â» (tâ ⪠tâ) = s â» tâ ⪠s â» tâ :=
imageâ_union_right
theorem sups_inter_subset_left : (sâ â© sâ) â» t â sâ â» t â© sâ â» t :=
imageâ_inter_subset_left
theorem sups_inter_subset_right : s â» (tâ â© tâ) â s â» tâ â© s â» tâ :=
imageâ_inter_subset_right
theorem subset_sups {s t : Set α} :
âu â s â» t â â s' t' : Finset α, âs' â s â§ ât' â t â§ u â s' â» t' :=
subset_set_imageâ
lemma image_sups (f : F) (s t : Finset α) : image f (s ⻠t) = image f s ⻠image f t :=
image_imageâ_distrib <| map_sup f
lemma map_sups (f : F) (hf) (s t : Finset α) :
map âšf, hfâ© (s â» t) = map âšf, hfâ© s â» map âšf, hfâ© t := by
simpa [map_eq_image] using image_sups f s t
lemma subset_sups_self : s â s â» s := fun _a ha ⊠mem_sups.2 âš_, ha, _, ha, sup_idem _â©
lemma sups_subset_self : s â» s â s â SupClosed (s : Set α) := sups_subset_iff
@[simp] lemma sups_eq_self : s â» s = s â SupClosed (s : Set α) := by simp [â coe_inj]
@[simp] lemma univ_sups_univ [Fintype α] : (univ : Finset α) ⻠univ = univ := by simp
lemma filter_sups_le [DecidableLE α] (s t : Finset α) (a : α) :
{b â s â» t | b †a} = {b â s | b †a} â» {b â t | b †a} := by
simp only [â coe_inj, coe_filter, coe_sups, â mem_coe, Set.sep_sups_le]
variable (s t u)
lemma biUnion_image_sup_left : s.biUnion (fun a ⊠t.image (a â ·)) = s â» t := biUnion_image_left
lemma biUnion_image_sup_right : t.biUnion (fun b ⊠s.image (· â b)) = s â» t := biUnion_image_right
theorem image_sup_product (s t : Finset α) : (s ÃË¢ t).image (uncurry (· â ·)) = s â» t :=
image_uncurry_product _ _ _
theorem sups_assoc : s â» t â» u = s â» (t â» u) := imageâ_assoc sup_assoc
theorem sups_comm : s â» t = t â» s := imageâ_comm sup_comm
theorem sups_left_comm : s â» (t â» u) = t â» (s â» u) :=
imageâ_left_comm sup_left_comm
theorem sups_right_comm : s â» t â» u = s â» u â» t :=
imageâ_right_comm sup_right_comm
theorem sups_sups_sups_comm : s â» t â» (u â» v) = s â» u â» (t â» v) :=
imageâ_imageâ_imageâ_comm sup_sup_sup_comm
end Sups
section Infs
variable [DecidableEq α] [DecidableEq β]
variable [SemilatticeInf α] [SemilatticeInf β] [FunLike F α β] [InfHomClass F α β]
variable (s sâ sâ t tâ tâ u v : Finset α)
/-- `s ⌠t` is the finset of elements of the form `a â b` where `a â s`, `b â t`. -/
protected def hasInfs : HasInfs (Finset α) :=
âšimageâ (· â ·)â©
scoped[FinsetFamily] attribute [instance] Finset.hasInfs
open FinsetFamily
variable {s t} {a b c : α}
@[simp]
theorem mem_infs : c â s ⌠t â â a â s, â b â t, a â b = c := by simp [(· ⌠·)]
variable (s t)
@[simp, norm_cast]
theorem coe_infs : (â(s ⌠t) : Set α) = âs ⌠ât :=
coe_imageâ _ _ _
theorem card_infs_le : #(s ⌠t) †#s * #t := card_imageâ_le _ _ _
theorem card_infs_iff : #(s ⌠t) = #s * #t â (s ÃË¢ t : Set (α à α)).InjOn fun x => x.1 â x.2 :=
card_imageâ_iff
variable {s sâ sâ t tâ tâ u}
theorem inf_mem_infs : a â s â b â t â a â b â s ⌠t :=
mem_imageâ_of_mem
theorem infs_subset : sâ â sâ â tâ â tâ â sâ ⌠tâ â sâ ⌠tâ :=
imageâ_subset
theorem infs_subset_left : tâ â tâ â s ⌠tâ â s ⌠tâ :=
imageâ_subset_left
theorem infs_subset_right : sâ â sâ â sâ ⌠t â sâ ⌠t :=
imageâ_subset_right
lemma image_subset_infs_left : b â t â s.image (· â b) â s ⌠t := image_subset_imageâ_left
lemma image_subset_infs_right : a â s â t.image (a â ·) â s ⌠t := image_subset_imageâ_right
theorem forall_infs_iff {p : α â Prop} : (â c â s ⌠t, p c) â â a â s, â b â t, p (a â b) :=
forall_mem_imageâ
@[simp]
theorem infs_subset_iff : s ⌠t â u â â a â s, â b â t, a â b â u :=
imageâ_subset_iff
@[simp]
theorem infs_nonempty : (s ⌠t).Nonempty â s.Nonempty â§ t.Nonempty :=
imageâ_nonempty_iff
@[aesop safe apply (rule_sets := [finsetNonempty])]
protected theorem Nonempty.infs : s.Nonempty â t.Nonempty â (s ⌠t).Nonempty :=
Nonempty.imageâ
theorem Nonempty.of_infs_left : (s ⌠t).Nonempty â s.Nonempty :=
Nonempty.of_imageâ_left
theorem Nonempty.of_infs_right : (s ⌠t).Nonempty â t.Nonempty :=
Nonempty.of_imageâ_right
@[simp]
theorem empty_infs : â
⌠t = â
:=
imageâ_empty_left
@[simp]
theorem infs_empty : s ⌠â
= â
:=
imageâ_empty_right
@[simp]
theorem infs_eq_empty : s ⌠t = â
â s = â
âš t = â
:=
imageâ_eq_empty_iff
@[simp] lemma singleton_infs : {a} ⌠t = t.image (a â ·) := imageâ_singleton_left
@[simp] lemma infs_singleton : s ⌠{b} = s.image (· â b) := imageâ_singleton_right
theorem singleton_infs_singleton : ({a} ⌠{b} : Finset α) = {a â b} :=
imageâ_singleton
theorem infs_union_left : (sâ ⪠sâ) ⌠t = sâ ⌠t ⪠sâ ⌠t :=
imageâ_union_left
theorem infs_union_right : s ⌠(tâ ⪠tâ) = s ⌠tâ ⪠s ⌠tâ :=
imageâ_union_right
theorem infs_inter_subset_left : (sâ â© sâ) ⌠t â sâ ⌠t â© sâ ⌠t :=
imageâ_inter_subset_left
theorem infs_inter_subset_right : s ⌠(tâ â© tâ) â s ⌠tâ â© s ⌠tâ :=
imageâ_inter_subset_right
theorem subset_infs {s t : Set α} :
âu â s ⌠t â â s' t' : Finset α, âs' â s â§ ât' â t â§ u â s' ⌠t' :=
subset_set_imageâ
lemma image_infs (f : F) (s t : Finset α) : image f (s ⌠t) = image f s ⌠image f t :=
image_imageâ_distrib <| map_inf f
lemma map_infs (f : F) (hf) (s t : Finset α) :
map âšf, hfâ© (s ⌠t) = map âšf, hfâ© s ⌠map âšf, hfâ© t := by
simpa [map_eq_image] using image_infs f s t
lemma subset_infs_self : s â s ⌠s := fun _a ha ⊠mem_infs.2 âš_, ha, _, ha, inf_idem _â©
lemma infs_self_subset : s ⌠s â s â InfClosed (s : Set α) := infs_subset_iff
@[simp] lemma infs_self : s ⌠s = s â InfClosed (s : Set α) := by simp [â coe_inj]
@[simp] lemma univ_infs_univ [Fintype α] : (univ : Finset α) ⌠univ = univ := by simp
lemma filter_infs_le [DecidableLE α] (s t : Finset α) (a : α) :
{b â s ⌠t | a †b} = {b â s | a †b} ⌠{b â t | a †b} := by
simp only [â coe_inj, coe_filter, coe_infs, â mem_coe, Set.sep_infs_le]
variable (s t u)
lemma biUnion_image_inf_left : s.biUnion (fun a ⊠t.image (a â ·)) = s ⌠t := biUnion_image_left
lemma biUnion_image_inf_right : t.biUnion (fun b ⊠s.image (· â b)) = s ⌠t := biUnion_image_right
theorem image_inf_product (s t : Finset α) : (s ÃË¢ t).image (uncurry (· â ·)) = s ⌠t :=
image_uncurry_product _ _ _
theorem infs_assoc : s ⌠t ⌠u = s ⌠(t ⌠u) := imageâ_assoc inf_assoc
theorem infs_comm : s ⌠t = t ⌠s := imageâ_comm inf_comm
theorem infs_left_comm : s ⌠(t ⌠u) = t ⌠(s ⌠u) :=
imageâ_left_comm inf_left_comm
theorem infs_right_comm : s ⌠t ⌠u = s ⌠u ⌠t :=
imageâ_right_comm inf_right_comm
theorem infs_infs_infs_comm : s ⌠t ⌠(u ⌠v) = s ⌠u ⌠(t ⌠v) :=
imageâ_imageâ_imageâ_comm inf_inf_inf_comm
end Infs
open FinsetFamily
section DistribLattice
variable [DecidableEq α]
variable [DistribLattice α] (s t u : Finset α)
theorem sups_infs_subset_left : s â» t ⌠u â (s â» t) ⌠(s â» u) :=
imageâ_distrib_subset_left sup_inf_left
theorem sups_infs_subset_right : t ⌠u â» s â (t â» s) ⌠(u â» s) :=
imageâ_distrib_subset_right sup_inf_right
theorem infs_sups_subset_left : s ⌠(t â» u) â s ⌠t â» s ⌠u :=
imageâ_distrib_subset_left inf_sup_left
theorem infs_sups_subset_right : (t â» u) ⌠s â t ⌠s â» u ⌠s :=
imageâ_distrib_subset_right inf_sup_right
end DistribLattice
section Finset
variable [DecidableEq α]
variable {ð ⬠: Finset (Finset α)} {s t : Finset α}
@[simp] lemma powerset_union (s t : Finset α) : (s ⪠t).powerset = s.powerset ⻠t.powerset := by
ext u
simp only [mem_sups, mem_powerset, le_eq_subset, sup_eq_union]
refine âšfun h ⊠âš_, inter_subset_left (sâ := u), _, inter_subset_left (sâ := u), ?_â©, ?_â©
· rwa [â union_inter_distrib_right, inter_eq_right]
· rintro âšv, hv, w, hw, rflâ©
exact union_subset_union hv hw
@[simp] lemma powerset_inter (s t : Finset α) : (s ⩠t).powerset = s.powerset ⌠t.powerset := by
ext u
simp only [mem_infs, mem_powerset, le_eq_subset, inf_eq_inter]
refine âšfun h ⊠âš_, inter_subset_left (sâ := u), _, inter_subset_left (sâ := u), ?_â©, ?_â©
· rwa [â inter_inter_distrib_right, inter_eq_right]
· rintro âšv, hv, w, hw, rflâ©
exact inter_subset_inter hv hw
@[simp] lemma powerset_sups_powerset_self (s : Finset α) :
s.powerset â» s.powerset = s.powerset := by simp [â powerset_union]
@[simp] lemma powerset_infs_powerset_self (s : Finset α) :
s.powerset ⌠s.powerset = s.powerset := by simp [â powerset_inter]
lemma union_mem_sups : s â ð â t â ⬠â s ⪠t â ð ⻠⬠:= sup_mem_sups
lemma inter_mem_infs : s â ð â t â ⬠â s â© t â ð ⌠⬠:= inf_mem_infs
end Finset
section DisjSups
variable [DecidableEq α]
variable [SemilatticeSup α] [OrderBot α] [DecidableRel (α := α) Disjoint]
(s sâ sâ t tâ tâ u : Finset α)
/-- The finset of elements of the form `a â b` where `a â s`, `b â t` and `a` and `b` are disjoint.
-/
def disjSups : Finset α := {ab â s ÃË¢ t | Disjoint ab.1 ab.2}.image fun ab => ab.1 â ab.2
@[inherit_doc]
scoped[FinsetFamily] infixl:74 " â " => Finset.disjSups
open FinsetFamily
variable {s t u} {a b c : α}
@[simp]
theorem mem_disjSups : c â s â t â â a â s, â b â t, Disjoint a b â§ a â b = c := by
simp [disjSups, and_assoc]
theorem disjSups_subset_sups : s â t â s â» t := by
simp_rw [subset_iff, mem_sups, mem_disjSups]
exact fun c âša, b, ha, hb, _, hcâ© => âša, b, ha, hb, hcâ©
variable (s t)
theorem card_disjSups_le : #(s â t) †#s * #t :=
(card_le_card disjSups_subset_sups).trans <| card_sups_le _ _
variable {s sâ sâ t tâ tâ}
theorem disjSups_subset (hs : sâ â sâ) (ht : tâ â tâ) : sâ â tâ â sâ â tâ :=
image_subset_image <| filter_subset_filter _ <| product_subset_product hs ht
theorem disjSups_subset_left (ht : tâ â tâ) : s â tâ â s â tâ :=
disjSups_subset Subset.rfl ht
theorem disjSups_subset_right (hs : sâ â sâ) : sâ â t â sâ â t :=
disjSups_subset hs Subset.rfl
theorem forall_disjSups_iff {p : α â Prop} :
(â c â s â t, p c) â â a â s, â b â t, Disjoint a b â p (a â b) := by
simp_rw [mem_disjSups]
refine âšfun h a ha b hb hab => h _ âš_, ha, _, hb, hab, rflâ©, ?_â©
rintro h _ âša, ha, b, hb, hab, rflâ©
exact h _ ha _ hb hab
@[simp]
theorem disjSups_subset_iff : s â t â u â â a â s, â b â t, Disjoint a b â a â b â u :=
forall_disjSups_iff
theorem Nonempty.of_disjSups_left : (s â t).Nonempty â s.Nonempty := by
simp_rw [Finset.Nonempty, mem_disjSups]
exact fun âš_, a, ha, _â© => âša, haâ©
theorem Nonempty.of_disjSups_right : (s â t).Nonempty â t.Nonempty := by
simp_rw [Finset.Nonempty, mem_disjSups]
exact fun âš_, _, _, b, hb, _â© => âšb, hbâ©
@[simp]
theorem disjSups_empty_left : â
â t = â
:= by simp [disjSups]
@[simp]
theorem disjSups_empty_right : s â â
= â
:= by simp [disjSups]
theorem disjSups_singleton : ({a} â {b} : Finset α) = if Disjoint a b then {a â b} else â
:= by
split_ifs with h <;> simp [disjSups, filter_singleton, h]
theorem disjSups_union_left : (sâ ⪠sâ) â t = sâ â t ⪠sâ â t := by
simp [disjSups, filter_union, image_union]
theorem disjSups_union_right : s â (tâ ⪠tâ) = s â tâ ⪠s â tâ := by
simp [disjSups, filter_union, image_union]
theorem disjSups_inter_subset_left : (sâ â© sâ) â t â sâ â t â© sâ â t := by
simpa only [disjSups, inter_product, filter_inter_distrib] using image_inter_subset _ _ _
theorem disjSups_inter_subset_right : s â (tâ â© tâ) â s â tâ â© s â tâ := by
simpa only [disjSups, product_inter, filter_inter_distrib] using image_inter_subset _ _ _
variable (s t)
theorem disjSups_comm : s â t = t â s := by
aesop (add simp disjoint_comm, simp sup_comm)
instance : @Std.Commutative (Finset α) (· â ·) := âšdisjSups_commâ©
end DisjSups
open FinsetFamily
section DistribLattice
variable [DecidableEq α]
variable [DistribLattice α] [OrderBot α] [DecidableRel (α := α) Disjoint] (s t u v : Finset α)
theorem disjSups_assoc : â s t u : Finset α, s â t â u = s â (t â u) := by
refine (associative_of_commutative_of_le inferInstance ?_).assoc
simp only [le_eq_subset, disjSups_subset_iff, mem_disjSups]
rintro s t u _ âša, ha, b, hb, hab, rflâ© c hc habc
rw [disjoint_sup_left] at habc
exact âša, ha, _, âšb, hb, c, hc, habc.2, rflâ©, hab.sup_right habc.1, (sup_assoc ..).symmâ©
instance : @Std.Associative (Finset α) (· â ·) := âšdisjSups_assocâ©
theorem disjSups_left_comm : s â (t â u) = t â (s â u) := by
simp_rw [â disjSups_assoc, disjSups_comm s]
theorem disjSups_right_comm : s â t â u = s â u â t := by simp_rw [disjSups_assoc, disjSups_comm]
theorem disjSups_disjSups_disjSups_comm : s â t â (u â v) = s â u â (t â v) := by
simp_rw [â disjSups_assoc, disjSups_right_comm]
end DistribLattice
section Diffs
variable [DecidableEq α]
variable [GeneralizedBooleanAlgebra α] (s sâ sâ t tâ tâ u : Finset α)
/-- `s \\ t` is the finset of elements of the form `a \ b` where `a â s`, `b â t`. -/
def diffs : Finset α â Finset α â Finset α := imageâ (· \ ·)
@[inherit_doc]
scoped[FinsetFamily] infixl:74 " \\\\ " => Finset.diffs
-- This notation is meant to have higher precedence than `\` and `â`, but still within the
-- realm of other binary notation
open FinsetFamily
variable {s t} {a b c : α}
@[simp] lemma mem_diffs : c â s \\ t â â a â s, â b â t, a \ b = c := by simp [(· \\ ·)]
variable (s t)
@[simp, norm_cast] lemma coe_diffs : (â(s \\ t) : Set α) = Set.image2 (· \ ·) s t :=
coe_imageâ _ _ _
lemma card_diffs_le : #(s \\ t) †#s * #t := card_imageâ_le _ _ _
lemma card_diffs_iff : #(s \\ t) = #s * #t â (s ÃË¢ t : Set (α à α)).InjOn fun x ⊠x.1 \ x.2 :=
card_imageâ_iff
variable {s sâ sâ t tâ tâ u}
lemma sdiff_mem_diffs : a â s â b â t â a \ b â s \\ t := mem_imageâ_of_mem
lemma diffs_subset : sâ â sâ â tâ â tâ â sâ \\ tâ â sâ \\ tâ := imageâ_subset
lemma diffs_subset_left : tâ â tâ â s \\ tâ â s \\ tâ := imageâ_subset_left
lemma diffs_subset_right : sâ â sâ â sâ \\ t â sâ \\ t := imageâ_subset_right
lemma image_subset_diffs_left : b â t â s.image (· \ b) â s \\ t := image_subset_imageâ_left
lemma image_subset_diffs_right : a â s â t.image (a \ ·) â s \\ t := image_subset_imageâ_right
lemma forall_mem_diffs {p : α â Prop} : (â c â s \\ t, p c) â â a â s, â b â t, p (a \ b) :=
forall_mem_imageâ
@[simp] lemma diffs_subset_iff : s \\ t â u â â a â s, â b â t, a \ b â u := imageâ_subset_iff
@[simp]
lemma diffs_nonempty : (s \\ t).Nonempty â s.Nonempty â§ t.Nonempty := imageâ_nonempty_iff
@[aesop safe apply (rule_sets := [finsetNonempty])]
protected lemma Nonempty.diffs : s.Nonempty â t.Nonempty â (s \\ t).Nonempty := Nonempty.imageâ
lemma Nonempty.of_diffs_left : (s \\ t).Nonempty â s.Nonempty := Nonempty.of_imageâ_left
lemma Nonempty.of_diffs_right : (s \\ t).Nonempty â t.Nonempty := Nonempty.of_imageâ_right
@[simp] lemma empty_diffs : â
\\ t = â
:= imageâ_empty_left
@[simp] lemma diffs_empty : s \\ â
= â
:= imageâ_empty_right
@[simp] lemma diffs_eq_empty : s \\ t = â
â s = â
âš t = â
:= imageâ_eq_empty_iff
@[simp] lemma singleton_diffs : {a} \\ t = t.image (a \ ·) := imageâ_singleton_left
@[simp] lemma diffs_singleton : s \\ {b} = s.image (· \ b) := imageâ_singleton_right
lemma singleton_diffs_singleton : ({a} \\ {b} : Finset α) = {a \ b} := imageâ_singleton
lemma diffs_union_left : (sâ ⪠sâ) \\ t = sâ \\ t ⪠sâ \\ t := imageâ_union_left
lemma diffs_union_right : s \\ (tâ ⪠tâ) = s \\ tâ ⪠s \\ tâ := imageâ_union_right
lemma diffs_inter_subset_left : (sâ â© sâ) \\ t â sâ \\ t â© sâ \\ t := imageâ_inter_subset_left
lemma diffs_inter_subset_right : s \\ (tâ â© tâ) â s \\ tâ â© s \\ tâ := imageâ_inter_subset_right
lemma subset_diffs {s t : Set α} :
âu â Set.image2 (· \ ·) s t â â s' t' : Finset α, âs' â s â§ ât' â t â§ u â s' \\ t' :=
subset_set_imageâ
variable (s t u)
lemma biUnion_image_sdiff_left : s.biUnion (fun a ⊠t.image (a \ ·)) = s \\ t := biUnion_image_left
lemma biUnion_image_sdiff_right : t.biUnion (fun b ⊠s.image (· \ b)) = s \\ t :=
biUnion_image_right
lemma image_sdiff_product (s t : Finset α) : (s ÃË¢ t).image (uncurry (· \ ·)) = s \\ t :=
image_uncurry_product _ _ _
lemma diffs_right_comm : s \\ t \\ u = s \\ u \\ t := imageâ_right_comm sdiff_right_comm
end Diffs
section Compls
variable [BooleanAlgebra α] (s sâ sâ t : Finset α)
/-- `sá¶Ë¢` is the finset of elements of the form `aá¶` where `a â s`. -/
def compls : Finset α â Finset α := map âšcompl, compl_injectiveâ©
@[inherit_doc]
scoped[FinsetFamily] postfix:max "á¶Ë¢" => Finset.compls
open FinsetFamily
variable {s t} {a : α}
|
@[simp] lemma mem_compls : a â sá¶Ë¢ â aá¶ â s := by
| Mathlib/Data/Finset/Sups.lean | 598 | 599 |
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes Hölzl
-/
import Mathlib.MeasureTheory.Integral.Lebesgue.Basic
import Mathlib.MeasureTheory.Integral.Lebesgue.Countable
import Mathlib.MeasureTheory.Integral.Lebesgue.MeasurePreserving
import Mathlib.MeasureTheory.Integral.Lebesgue.Norm
deprecated_module (since := "2025-04-13")
| Mathlib/MeasureTheory/Integral/Lebesgue.lean | 231 | 247 | |
/-
Copyright (c) 2022 Rémi Bottinelli. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémi Bottinelli, Junyan Xu
-/
import Mathlib.Algebra.Group.Subgroup.Defs
import Mathlib.CategoryTheory.Groupoid.VertexGroup
import Mathlib.CategoryTheory.Groupoid.Basic
import Mathlib.CategoryTheory.Groupoid
import Mathlib.Data.Set.Lattice
/-!
# Subgroupoid
This file defines subgroupoids as `structure`s containing the subsets of arrows and their
stability under composition and inversion.
Also defined are:
* containment of subgroupoids is a complete lattice;
* images and preimages of subgroupoids under a functor;
* the notion of normality of subgroupoids and its stability under intersection and preimage;
* compatibility of the above with `CategoryTheory.Groupoid.vertexGroup`.
## Main definitions
Given a type `C` with associated `groupoid C` instance.
* `CategoryTheory.Subgroupoid C` is the type of subgroupoids of `C`
* `CategoryTheory.Subgroupoid.IsNormal` is the property that the subgroupoid is stable under
conjugation by arbitrary arrows, _and_ that all identity arrows are contained in the subgroupoid.
* `CategoryTheory.Subgroupoid.comap` is the "preimage" map of subgroupoids along a functor.
* `CategoryTheory.Subgroupoid.map` is the "image" map of subgroupoids along a functor _injective on
objects_.
* `CategoryTheory.Subgroupoid.vertexSubgroup` is the subgroup of the *vertex group* at a given
vertex `v`, assuming `v` is contained in the `CategoryTheory.Subgroupoid` (meaning, by definition,
that the arrow `ð v` is contained in the subgroupoid).
## Implementation details
The structure of this file is copied from/inspired by `Mathlib/GroupTheory/Subgroup/Basic.lean`
and `Mathlib/Combinatorics/SimpleGraph/Subgraph.lean`.
## TODO
* Equivalent inductive characterization of generated (normal) subgroupoids.
* Characterization of normal subgroupoids as kernels.
* Prove that `CategoryTheory.Subgroupoid.full` and `CategoryTheory.Subgroupoid.disconnect` preserve
intersections (and `CategoryTheory.Subgroupoid.disconnect` also unions)
## Tags
category theory, groupoid, subgroupoid
-/
namespace CategoryTheory
open Set Groupoid
universe u v
variable {C : Type u} [Groupoid C]
/-- A sugroupoid of `C` consists of a choice of arrows for each pair of vertices, closed
under composition and inverses.
-/
@[ext]
structure Subgroupoid (C : Type u) [Groupoid C] where
/-- The arrow choice for each pair of vertices -/
arrows : â c d : C, Set (c â¶ d)
protected inv : â {c d} {p : c â¶ d}, p â arrows c d â Groupoid.inv p â arrows d c
protected mul : â {c d e} {p}, p â arrows c d â â {q}, q â arrows d e â p â« q â arrows c e
namespace Subgroupoid
variable (S : Subgroupoid C)
theorem inv_mem_iff {c d : C} (f : c â¶ d) :
Groupoid.inv f â S.arrows d c â f â S.arrows c d := by
constructor
· intro h
simpa only [inv_eq_inv, IsIso.inv_inv] using S.inv h
· apply S.inv
theorem mul_mem_cancel_left {c d e : C} {f : c â¶ d} {g : d â¶ e} (hf : f â S.arrows c d) :
f â« g â S.arrows c e â g â S.arrows d e := by
constructor
· rintro h
suffices Groupoid.inv f â« f â« g â S.arrows d e by
simpa only [inv_eq_inv, IsIso.inv_hom_id_assoc] using this
apply S.mul (S.inv hf) h
· apply S.mul hf
theorem mul_mem_cancel_right {c d e : C} {f : c â¶ d} {g : d â¶ e} (hg : g â S.arrows d e) :
f â« g â S.arrows c e â f â S.arrows c d := by
constructor
· rintro h
suffices (f â« g) â« Groupoid.inv g â S.arrows c d by
simpa only [inv_eq_inv, IsIso.hom_inv_id, Category.comp_id, Category.assoc] using this
apply S.mul h (S.inv hg)
· exact fun hf => S.mul hf hg
/-- The vertices of `C` on which `S` has non-trivial isotropy -/
def objs : Set C :=
{c : C | (S.arrows c c).Nonempty}
theorem mem_objs_of_src {c d : C} {f : c â¶ d} (h : f â S.arrows c d) : c â S.objs :=
âšf â« Groupoid.inv f, S.mul h (S.inv h)â©
theorem mem_objs_of_tgt {c d : C} {f : c â¶ d} (h : f â S.arrows c d) : d â S.objs :=
âšGroupoid.inv f â« f, S.mul (S.inv h) hâ©
theorem id_mem_of_nonempty_isotropy (c : C) : c â objs S â ð c â S.arrows c c := by
rintro âšÎ³, hγâ©
convert S.mul hγ (S.inv hγ)
simp only [inv_eq_inv, IsIso.hom_inv_id]
theorem id_mem_of_src {c d : C} {f : c â¶ d} (h : f â S.arrows c d) : ð c â S.arrows c c :=
id_mem_of_nonempty_isotropy S c (mem_objs_of_src S h)
theorem id_mem_of_tgt {c d : C} {f : c â¶ d} (h : f â S.arrows c d) : ð d â S.arrows d d :=
id_mem_of_nonempty_isotropy S d (mem_objs_of_tgt S h)
/-- A subgroupoid seen as a quiver on vertex set `C` -/
def asWideQuiver : Quiver C :=
âšfun c d => Subtype <| S.arrows c dâ©
/-- The coercion of a subgroupoid as a groupoid -/
@[simps comp_coe, simps -isSimp inv_coe]
instance coe : Groupoid S.objs where
Hom a b := S.arrows a.val b.val
id a := âšð a.val, id_mem_of_nonempty_isotropy S a.val a.propâ©
comp p q := âšp.val â« q.val, S.mul p.prop q.propâ©
inv p := âšGroupoid.inv p.val, S.inv p.propâ©
@[simp]
theorem coe_inv_coe' {c d : S.objs} (p : c â¶ d) :
(CategoryTheory.inv p).val = CategoryTheory.inv p.val := by
simp only [â inv_eq_inv, coe_inv_coe]
/-- The embedding of the coerced subgroupoid to its parent -/
def hom : S.objs ⥀ C where
obj c := c.val
map f := f.val
map_id _ := rfl
map_comp _ _ := rfl
theorem hom.inj_on_objects : Function.Injective (hom S).obj := by
rintro âšc, hcâ© âšd, hdâ© hcd
simp only [Subtype.mk_eq_mk]; exact hcd
theorem hom.faithful : â c d, Function.Injective fun f : c â¶ d => (hom S).map f := by
rintro âšc, hcâ© âšd, hdâ© âšf, hfâ© âšg, hgâ© hfg; exact Subtype.eq hfg
/-- The subgroup of the vertex group at `c` given by the subgroupoid -/
def vertexSubgroup {c : C} (hc : c â S.objs) : Subgroup (c â¶ c) where
carrier := S.arrows c c
mul_mem' hf hg := S.mul hf hg
one_mem' := id_mem_of_nonempty_isotropy _ _ hc
inv_mem' hf := S.inv hf
/-- The set of all arrows of a subgroupoid, as a set in `Σ c d : C, c ⶠd`. -/
@[coe] def toSet (S : Subgroupoid C) : Set (Σ c d : C, c ⶠd) :=
{F | F.2.2 â S.arrows F.1 F.2.1}
instance : SetLike (Subgroupoid C) (Σ c d : C, c ⶠd) where
coe := toSet
coe_injective' := fun âšS, _, _â© âšT, _, _â© h => by ext c d f; apply Set.ext_iff.1 h âšc, d, fâ©
theorem mem_iff (S : Subgroupoid C) (F : Σ c d, c â¶ d) : F â S â F.2.2 â S.arrows F.1 F.2.1 :=
Iff.rfl
theorem le_iff (S T : Subgroupoid C) : S †T â â {c d}, S.arrows c d â T.arrows c d := by
rw [SetLike.le_def, Sigma.forall]; exact forall_congr' fun c => Sigma.forall
instance : Top (Subgroupoid C) :=
âš{ arrows := fun _ _ => Set.univ
mul := by intros; trivial
inv := by intros; trivial }â©
theorem mem_top {c d : C} (f : c â¶ d) : f â (†: Subgroupoid C).arrows c d :=
trivial
theorem mem_top_objs (c : C) : c â (†: Subgroupoid C).objs := by
dsimp [Top.top, objs]
simp only [univ_nonempty]
instance : Bot (Subgroupoid C) :=
âš{ arrows := fun _ _ => â
mul := False.elim
inv := False.elim }â©
instance : Inhabited (Subgroupoid C) :=
âšâ€â©
instance : Min (Subgroupoid C) :=
âšfun S T =>
{ arrows := fun c d => S.arrows c d â© T.arrows c d
inv := fun hp ⊠âšS.inv hp.1, T.inv hp.2â©
mul := fun hp _ hq ⊠âšS.mul hp.1 hq.1, T.mul hp.2 hq.2â© }â©
instance : InfSet (Subgroupoid C) :=
âšfun s =>
{ arrows := fun c d => â S â s, Subgroupoid.arrows S c d
inv := fun hp ⊠by rw [mem_iInterâ] at hp â¢; exact fun S hS => S.inv (hp S hS)
mul := fun hp _ hq ⊠by
rw [mem_iInterâ] at hp hq â¢
exact fun S hS => S.mul (hp S hS) (hq S hS) }â©
theorem mem_sInf_arrows {s : Set (Subgroupoid C)} {c d : C} {p : c â¶ d} :
p â (sInf s).arrows c d â â S â s, p â S.arrows c d :=
mem_iInterâ
theorem mem_sInf {s : Set (Subgroupoid C)} {p : Σ c d : C, c ⶠd} :
p â sInf s â â S â s, p â S :=
mem_sInf_arrows
instance : CompleteLattice (Subgroupoid C) :=
{ completeLatticeOfInf (Subgroupoid C) (by
refine fun s => âšfun S Ss F => ?_, fun T Tl F fT => ?_â© <;> simp only [mem_sInf]
exacts [fun hp => hp S Ss, fun S Ss => Tl Ss fT]) with
bot := â¥
bot_le := fun _ => empty_subset _
top := â€
le_top := fun _ => subset_univ _
inf := (· â ·)
le_inf := fun _ _ _ RS RT _ pR => âšRS pR, RT pRâ©
inf_le_left := fun _ _ _ => And.left
inf_le_right := fun _ _ _ => And.right }
theorem le_objs {S T : Subgroupoid C} (h : S †T) : S.objs â T.objs := fun s âšÎ³, hγ⩠=>
âšÎ³, @h âšs, s, γ⩠hγâ©
/-- The functor associated to the embedding of subgroupoids -/
def inclusion {S T : Subgroupoid C} (h : S †T) : S.objs ⥀ T.objs where
obj s := âšs.val, le_objs h s.propâ©
map f := âšf.val, @h âš_, _, f.valâ© f.propâ©
map_id _ := rfl
map_comp _ _ := rfl
theorem inclusion_inj_on_objects {S T : Subgroupoid C} (h : S †T) :
Function.Injective (inclusion h).obj := fun âšs, hsâ© âšt, htâ© => by
simpa only [inclusion, Subtype.mk_eq_mk] using id
theorem inclusion_faithful {S T : Subgroupoid C} (h : S †T) (s t : S.objs) :
Function.Injective fun f : s â¶ t => (inclusion h).map f := fun âšf, hfâ© âšg, hgâ© => by
-- Porting note: was `...; simpa only [Subtype.mk_eq_mk] using id`
dsimp only [inclusion]; rw [Subtype.mk_eq_mk, Subtype.mk_eq_mk]; exact id
theorem inclusion_refl {S : Subgroupoid C} : inclusion (le_refl S) = ð S.objs :=
Functor.hext (fun _ => rfl) fun _ _ _ => HEq.refl _
theorem inclusion_trans {R S T : Subgroupoid C} (k : R †S) (h : S †T) :
inclusion (k.trans h) = inclusion k â inclusion h :=
rfl
theorem inclusion_comp_embedding {S T : Subgroupoid C} (h : S †T) : inclusion h â T.hom = S.hom :=
rfl
/-- The family of arrows of the discrete groupoid -/
inductive Discrete.Arrows : â c d : C, (c â¶ d) â Prop
| id (c : C) : Discrete.Arrows c c (ð c)
/-- The only arrows of the discrete groupoid are the identity arrows. -/
def discrete : Subgroupoid C where
arrows c d := {p | Discrete.Arrows c d p}
inv := by rintro _ _ _ âšâ©; simp only [inv_eq_inv, IsIso.inv_id]; constructor
mul := by rintro _ _ _ _ âšâ© _ âšâ©; rw [Category.comp_id]; constructor
theorem mem_discrete_iff {c d : C} (f : c â¶ d) :
f â discrete.arrows c d â â h : c = d, f = eqToHom h :=
âšby rintro âšâ©; exact âšrfl, rflâ©, by rintro âšrfl, rflâ©; constructorâ©
/-- A subgroupoid is wide if its carrier set is all of `C`. -/
structure IsWide : Prop where
wide : â c, ð c â S.arrows c c
theorem isWide_iff_objs_eq_univ : S.IsWide â S.objs = Set.univ := by
constructor
· rintro h
ext x; constructor <;> simp only [top_eq_univ, mem_univ, imp_true_iff, forall_true_left]
apply mem_objs_of_src S (h.wide x)
· rintro h
refine âšfun c => ?_â©
obtain âšÎ³, γSâ© := (le_of_eq h.symm : †â S.objs) (Set.mem_univ c)
exact id_mem_of_src S γS
theorem IsWide.id_mem {S : Subgroupoid C} (Sw : S.IsWide) (c : C) : ð c â S.arrows c c :=
Sw.wide c
theorem IsWide.eqToHom_mem {S : Subgroupoid C} (Sw : S.IsWide) {c d : C} (h : c = d) :
eqToHom h â S.arrows c d := by cases h; simp only [eqToHom_refl]; apply Sw.id_mem c
/-- A subgroupoid is normal if it is wide and satisfies the expected stability under conjugacy. -/
structure IsNormal : Prop extends IsWide S where
conj : â {c d} (p : c â¶ d) {γ : c â¶ c}, γ â S.arrows c c â Groupoid.inv p ⫠γ â« p â S.arrows d d
theorem IsNormal.conj' {S : Subgroupoid C} (Sn : IsNormal S) :
â {c d} (p : d â¶ c) {γ : c â¶ c}, γ â S.arrows c c â p ⫠γ â« Groupoid.inv p â S.arrows d d :=
fun p γ hs => by convert Sn.conj (Groupoid.inv p) hs; simp
theorem IsNormal.conjugation_bij (Sn : IsNormal S) {c d} (p : c â¶ d) :
Set.BijOn (fun γ : c ⶠc => Groupoid.inv p ⫠γ ⫠p) (S.arrows c c) (S.arrows d d) := by
refine âšfun γ γS => Sn.conj p γS, fun γâ _ γâ _ h => ?_, fun ÎŽ ÎŽS =>
âšp â« ÎŽ â« Groupoid.inv p, Sn.conj' p ÎŽS, ?_â©â©
· simpa only [inv_eq_inv, Category.assoc, IsIso.hom_inv_id, Category.comp_id,
IsIso.hom_inv_id_assoc] using p â«= h =â« inv p
· simp only [inv_eq_inv, Category.assoc, IsIso.inv_hom_id, Category.comp_id,
IsIso.inv_hom_id_assoc]
theorem top_isNormal : IsNormal (†: Subgroupoid C) :=
{ wide := fun _ => trivial
conj := fun _ _ _ => trivial }
theorem sInf_isNormal (s : Set <| Subgroupoid C) (sn : â S â s, IsNormal S) : IsNormal (sInf s) :=
{ wide := by simp_rw [sInf, mem_iInterâ]; exact fun c S Ss => (sn S Ss).wide c
conj := by simp_rw [sInf, mem_iInterâ]; exact fun p γ hγ S Ss => (sn S Ss).conj p (hγ S Ss) }
theorem discrete_isNormal : (@discrete C _).IsNormal :=
{ wide := fun c => by constructor
conj := fun f γ hγ => by
cases hγ
simp only [inv_eq_inv, Category.id_comp, IsIso.inv_hom_id]; constructor }
theorem IsNormal.vertexSubgroup (Sn : IsNormal S) (c : C) (cS : c â S.objs) :
(S.vertexSubgroup cS).Normal where
conj_mem x hx y := by rw [mul_assoc]; exact Sn.conj' y hx
section GeneratedSubgroupoid
-- TODO: proof that generated is just "words in X" and generatedNormal is similarly
variable (X : â c d : C, Set (c â¶ d))
/-- The subgropoid generated by the set of arrows `X` -/
def generated : Subgroupoid C :=
sInf {S : Subgroupoid C | â c d, X c d â S.arrows c d}
theorem subset_generated (c d : C) : X c d â (generated X).arrows c d := by
dsimp only [generated, sInf]
simp only [subset_iInterâ_iff]
exact fun S hS f fS => hS _ _ fS
/-- The normal sugroupoid generated by the set of arrows `X` -/
def generatedNormal : Subgroupoid C :=
sInf {S : Subgroupoid C | (â c d, X c d â S.arrows c d) â§ S.IsNormal}
theorem generated_le_generatedNormal : generated X †generatedNormal X := by
apply @sInf_le_sInf (Subgroupoid C) _
exact fun S âšh, _â© => h
theorem generatedNormal_isNormal : (generatedNormal X).IsNormal :=
sInf_isNormal _ fun _ h => h.right
theorem IsNormal.generatedNormal_le {S : Subgroupoid C} (Sn : S.IsNormal) :
generatedNormal X †S â â c d, X c d â S.arrows c d := by
constructor
· rintro h c d
have h' := generated_le_generatedNormal X
rw [le_iff] at h h'
exact ((subset_generated X c d).trans (@h' c d)).trans (@h c d)
· rintro h
apply @sInf_le (Subgroupoid C) _
exact âšh, Snâ©
end GeneratedSubgroupoid
section Hom
variable {D : Type*} [Groupoid D] (Ï : C ⥀ D)
/-- A functor between groupoid defines a map of subgroupoids in the reverse direction
by taking preimages.
-/
def comap (S : Subgroupoid D) : Subgroupoid C where
arrows c d := {f : c â¶ d | Ï.map f â S.arrows (Ï.obj c) (Ï.obj d)}
inv hp := by rw [mem_setOf, inv_eq_inv, Ï.map_inv, â inv_eq_inv]; exact S.inv hp
mul := by
intros
simp only [mem_setOf, Functor.map_comp]
apply S.mul <;> assumption
theorem comap_mono (S T : Subgroupoid D) : S †T â comap Ï S †comap Ï T := fun ST _ =>
@ST âš_, _, _â©
theorem isNormal_comap {S : Subgroupoid D} (Sn : IsNormal S) : IsNormal (comap Ï S) where
wide c := by rw [comap, mem_setOf, Functor.map_id]; apply Sn.wide
conj f γ hγ := by
simp_rw [inv_eq_inv f, comap, mem_setOf, Functor.map_comp, Functor.map_inv, â inv_eq_inv]
exact Sn.conj _ hγ
@[simp]
theorem comap_comp {E : Type*} [Groupoid E] (Ï : D ⥀ E) : comap (Ï â Ï) = comap Ï â comap Ï :=
rfl
/-- The kernel of a functor between subgroupoid is the preimage. -/
def ker : Subgroupoid C :=
comap Ï discrete
theorem mem_ker_iff {c d : C} (f : c â¶ d) :
f â (ker Ï).arrows c d â â h : Ï.obj c = Ï.obj d, Ï.map f = eqToHom h :=
mem_discrete_iff (Ï.map f)
theorem ker_isNormal : (ker Ï).IsNormal :=
isNormal_comap Ï discrete_isNormal
@[simp]
theorem ker_comp {E : Type*} [Groupoid E] (Ï : D ⥀ E) : ker (Ï â Ï) = comap Ï (ker Ï) :=
rfl
/-- The family of arrows of the image of a subgroupoid under a functor injective on objects -/
inductive Map.Arrows (hÏ : Function.Injective Ï.obj) (S : Subgroupoid C) : â c d : D, (c â¶ d) â Prop
| im {c d : C} (f : c â¶ d) (hf : f â S.arrows c d) : Map.Arrows hÏ S (Ï.obj c) (Ï.obj d) (Ï.map f)
theorem Map.arrows_iff (hÏ : Function.Injective Ï.obj) (S : Subgroupoid C) {c d : D} (f : c â¶ d) :
Map.Arrows Ï hÏ S c d f â
â (a b : C) (g : a â¶ b) (ha : Ï.obj a = c) (hb : Ï.obj b = d) (_hg : g â S.arrows a b),
f = eqToHom ha.symm â« Ï.map g â« eqToHom hb := by
constructor
· rintro âšg, hgâ©; exact âš_, _, g, rfl, rfl, hg, eq_conj_eqToHom _â©
· rintro âša, b, g, rfl, rfl, hg, rflâ©; rw [â eq_conj_eqToHom]; constructor; exact hg
/-- The "forward" image of a subgroupoid under a functor injective on objects -/
def map (hÏ : Function.Injective Ï.obj) (S : Subgroupoid C) : Subgroupoid D where
arrows c d := {x | Map.Arrows Ï hÏ S c d x}
inv := by
rintro _ _ _ âšâ©
rw [inv_eq_inv, â Functor.map_inv, â inv_eq_inv]
constructor; apply S.inv; assumption
mul := by
rintro _ _ _ _ âšf, hfâ© q hq
obtain âšcâ, câ, g, he, rfl, hg, gqâ© := (Map.arrows_iff Ï hÏ S q).mp hq
cases hÏ he; rw [gq, â eq_conj_eqToHom, â Ï.map_comp]
constructor; exact S.mul hf hg
theorem mem_map_iff (hÏ : Function.Injective Ï.obj) (S : Subgroupoid C) {c d : D} (f : c â¶ d) :
f â (map Ï hÏ S).arrows c d â
â (a b : C) (g : a â¶ b) (ha : Ï.obj a = c) (hb : Ï.obj b = d) (_hg : g â S.arrows a b),
f = eqToHom ha.symm â« Ï.map g â« eqToHom hb :=
Map.arrows_iff Ï hÏ S f
theorem galoisConnection_map_comap (hÏ : Function.Injective Ï.obj) :
GaloisConnection (map Ï hÏ) (comap Ï) := by
rintro S T; simp_rw [le_iff]; constructor
· exact fun h c d f fS => h (Map.Arrows.im f fS)
· rintro h _ _ g âša, gÏSâ©
exact h gÏS
theorem map_mono (hÏ : Function.Injective Ï.obj) (S T : Subgroupoid C) :
S †T â map Ï hÏ S †map Ï hÏ T := fun h => (galoisConnection_map_comap Ï hÏ).monotone_l h
theorem le_comap_map (hÏ : Function.Injective Ï.obj) (S : Subgroupoid C) :
S †comap Ï (map Ï hÏ S) :=
(galoisConnection_map_comap Ï hÏ).le_u_l S
theorem map_comap_le (hÏ : Function.Injective Ï.obj) (T : Subgroupoid D) :
map Ï hÏ (comap Ï T) †T :=
(galoisConnection_map_comap Ï hÏ).l_u_le T
theorem map_le_iff_le_comap (hÏ : Function.Injective Ï.obj) (S : Subgroupoid C)
(T : Subgroupoid D) : map Ï hÏ S †T â S †comap Ï T :=
(galoisConnection_map_comap Ï hÏ).le_iff_le
theorem mem_map_objs_iff (hÏ : Function.Injective Ï.obj) (d : D) :
d â (map Ï hÏ S).objs â â c â S.objs, Ï.obj c = d := by
dsimp [objs, map]
constructor
· rintro âšf, hfâ©
change Map.Arrows Ï hÏ S d d f at hf; rw [Map.arrows_iff] at hf
obtain âšc, d, g, ec, ed, eg, gS, egâ© := hf
exact âšc, âšmem_objs_of_src S eg, ecâ©â©
· rintro âšc, âšÎ³, γSâ©, rflâ©
exact âšÏ.map γ, âšÎ³, γSâ©â©
@[simp]
theorem map_objs_eq (hÏ : Function.Injective Ï.obj) : (map Ï hÏ S).objs = Ï.obj '' S.objs := by
ext x; convert mem_map_objs_iff S Ï hÏ x
/-- The image of a functor injective on objects -/
def im (hÏ : Function.Injective Ï.obj) :=
map Ï hÏ â€
theorem mem_im_iff (hÏ : Function.Injective Ï.obj) {c d : D} (f : c â¶ d) :
f â (im Ï hÏ).arrows c d â
â (a b : C) (g : a â¶ b) (ha : Ï.obj a = c) (hb : Ï.obj b = d),
f = eqToHom ha.symm â« Ï.map g â« eqToHom hb := by
convert Map.arrows_iff Ï hÏ â€ f; simp only [Top.top, mem_univ, exists_true_left]
theorem mem_im_objs_iff (hÏ : Function.Injective Ï.obj) (d : D) :
d â (im Ï hÏ).objs â â c : C, Ï.obj c = d := by
simp only [im, mem_map_objs_iff, mem_top_objs, true_and]
theorem obj_surjective_of_im_eq_top (hÏ : Function.Injective Ï.obj) (hÏ' : im Ï hÏ = â€) :
Function.Surjective Ï.obj := by
rintro d
rw [â mem_im_objs_iff, hÏ']
apply mem_top_objs
theorem isNormal_map (hÏ : Function.Injective Ï.obj) (hÏ' : im Ï hÏ = â€) (Sn : S.IsNormal) :
(map Ï hÏ S).IsNormal :=
{ wide := fun d => by
obtain âšc, rflâ© := obj_surjective_of_im_eq_top Ï hÏ hÏ' d
change Map.Arrows Ï hÏ S _ _ (ð _); rw [â Functor.map_id]
constructor; exact Sn.wide c
conj := fun {d d'} g ÎŽ hÎŽ => by
rw [mem_map_iff] at hÎŽ
obtain âšc, c', γ, cd, cd', γS, hγ⩠:= hÎŽ; subst_vars; cases hÏ cd'
have : d' â (im Ï hÏ).objs := by rw [hÏ']; apply mem_top_objs
rw [mem_im_objs_iff] at this
obtain âšc', rflâ© := this
have : g â (im Ï hÏ).arrows (Ï.obj c) (Ï.obj c') := by rw [hÏ']; trivial
rw [mem_im_iff] at this
obtain âšb, b', f, hb, hb', _, hfâ© := this; cases hÏ hb; cases hÏ hb'
change Map.Arrows Ï hÏ S (Ï.obj c') (Ï.obj c') _
simp only [eqToHom_refl, Category.comp_id, Category.id_comp, inv_eq_inv]
suffices Map.Arrows Ï hÏ S (Ï.obj c') (Ï.obj c') (Ï.map <| Groupoid.inv f ⫠γ â« f) by
simp only [inv_eq_inv, Functor.map_comp, Functor.map_inv] at this; exact this
constructor; apply Sn.conj f γS }
end Hom
section Thin
/-- A subgroupoid is thin (`CategoryTheory.Subgroupoid.IsThin`) if it has at most one arrow between
any two vertices. -/
abbrev IsThin :=
Quiver.IsThin S.objs
nonrec theorem isThin_iff : S.IsThin â â c : S.objs, Subsingleton (S.arrows c c) := isThin_iff _
end Thin
section Disconnected
/-- A subgroupoid `IsTotallyDisconnected` if it has only isotropy arrows. -/
nonrec abbrev IsTotallyDisconnected :=
IsTotallyDisconnected S.objs
theorem isTotallyDisconnected_iff :
S.IsTotallyDisconnected â â c d, (S.arrows c d).Nonempty â c = d := by
constructor
· rintro h c d âšf, fSâ©
exact congr_arg Subtype.val <| h âšc, mem_objs_of_src S fSâ© âšd, mem_objs_of_tgt S fSâ© âšf, fSâ©
· rintro h âšc, hcâ© âšd, hdâ© âšf, fSâ©
simp only [Subtype.mk_eq_mk]
exact h c d âšf, fSâ©
/-- The isotropy subgroupoid of `S` -/
def disconnect : Subgroupoid C where
arrows c d := {f | c = d â§ f â S.arrows c d}
inv := by rintro _ _ _ âšrfl, hâ©; exact âšrfl, S.inv hâ©
mul := by rintro _ _ _ _ âšrfl, hâ© _ âšrfl, h'â©; exact âšrfl, S.mul h h'â©
theorem disconnect_le : S.disconnect †S := by rw [le_iff]; rintro _ _ _ âšâ©; assumption
theorem disconnect_normal (Sn : S.IsNormal) : S.disconnect.IsNormal :=
{ wide := fun c => âšrfl, Sn.wide câ©
conj := fun _ _ âš_, h'â© => âšrfl, Sn.conj _ h'â© }
@[simp]
theorem mem_disconnect_objs_iff {c : C} : c â S.disconnect.objs â c â S.objs :=
âšfun âšÎ³, _, γSâ© => âšÎ³, γSâ©, fun âšÎ³, γSâ© => âšÎ³, rfl, γSâ©â©
theorem disconnect_objs : S.disconnect.objs = S.objs := Set.ext fun _ ⊠mem_disconnect_objs_iff _
|
theorem disconnect_isTotallyDisconnected : S.disconnect.IsTotallyDisconnected := by
rw [isTotallyDisconnected_iff]; exact fun c d âš_, h, _â© => h
end Disconnected
| Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean | 565 | 569 |
/-
Copyright (c) 2021 Alex Kontorovich and Heather Macbeth and Marc Masdeu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alex Kontorovich, Heather Macbeth, Marc Masdeu
-/
import Mathlib.Analysis.Complex.UpperHalfPlane.Basic
import Mathlib.LinearAlgebra.GeneralLinearGroup
import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup.Basic
import Mathlib.Topology.Instances.Matrix
import Mathlib.Topology.Algebra.Module.FiniteDimension
import Mathlib.Topology.Instances.ZMultiples
/-!
# The action of the modular group SL(2, â€) on the upper half-plane
We define the action of `SL(2,â€)` on `â` (via restriction of the `SL(2,â)` action in
`Analysis.Complex.UpperHalfPlane`). We then define the standard fundamental domain
(`ModularGroup.fd`, `ð`) for this action and show
(`ModularGroup.exists_smul_mem_fd`) that any point in `â` can be
moved inside `ð`.
## Main definitions
The standard (closed) fundamental domain of the action of `SL(2,â€)` on `â`, denoted `ð`:
`fd := {z | 1 †(z : â).normSq â§ |z.re| †(1 : â) / 2}`
The standard open fundamental domain of the action of `SL(2,â€)` on `â`, denoted `ðáµ`:
`fdo := {z | 1 < (z : â).normSq â§ |z.re| < (1 : â) / 2}`
These notations are localized in the `Modular` locale and can be enabled via `open scoped Modular`.
## Main results
Any `z : â` can be moved to `ð` by an element of `SL(2,â€)`:
`exists_smul_mem_fd (z : â) : â g : SL(2,â€), g ⢠z â ð`
If both `z` and `γ ⢠z` are in the open domain `ðáµ` then `z = γ ⢠z`:
`eq_smul_self_of_mem_fdo_mem_fdo {z : â} {g : SL(2,â€)} (hz : z â ðáµ) (hg : g ⢠z â ðáµ) : z = g ⢠z`
# Discussion
Standard proofs make use of the identity
`g ⢠z = a / c - 1 / (c (cz + d))`
for `g = [[a, b], [c, d]]` in `SL(2)`, but this requires separate handling of whether `c = 0`.
Instead, our proof makes use of the following perhaps novel identity (see
`ModularGroup.smul_eq_lcRow0_add`):
`g ⢠z = (a c + b d) / (c^2 + d^2) + (d z - c) / ((c^2 + d^2) (c z + d))`
where there is no issue of division by zero.
Another feature is that we delay until the very end the consideration of special matrices
`T=[[1,1],[0,1]]` (see `ModularGroup.T`) and `S=[[0,-1],[1,0]]` (see `ModularGroup.S`), by
instead using abstract theory on the properness of certain maps (phrased in terms of the filters
`Filter.cocompact`, `Filter.cofinite`, etc) to deduce existence theorems, first to prove the
existence of `g` maximizing `(gâ¢z).im` (see `ModularGroup.exists_max_im`), and then among
those, to minimize `|(gâ¢z).re|` (see `ModularGroup.exists_row_one_eq_and_min_re`).
-/
open Complex hiding abs_two
open Matrix hiding mul_smul
open Matrix.SpecialLinearGroup UpperHalfPlane ModularGroup Topology
noncomputable section
open scoped ComplexConjugate MatrixGroups
namespace ModularGroup
variable {g : SL(2, â€)} (z : â)
section BottomRow
/-- The two numbers `c`, `d` in the "bottom_row" of `g=[[*,*],[c,d]]` in `SL(2, â€)` are coprime. -/
theorem bottom_row_coprime {R : Type*} [CommRing R] (g : SL(2, R)) :
IsCoprime ((âg : Matrix (Fin 2) (Fin 2) R) 1 0) ((âg : Matrix (Fin 2) (Fin 2) R) 1 1) := by
use -(âg : Matrix (Fin 2) (Fin 2) R) 0 1, (âg : Matrix (Fin 2) (Fin 2) R) 0 0
rw [add_comm, neg_mul, â sub_eq_add_neg, â det_fin_two]
exact g.det_coe
/-- Every pair `![c, d]` of coprime integers is the "bottom_row" of some element `g=[[*,*],[c,d]]`
of `SL(2,â€)`. -/
theorem bottom_row_surj {R : Type*} [CommRing R] :
Set.SurjOn (fun g : SL(2, R) => (âg : Matrix (Fin 2) (Fin 2) R) 1) Set.univ
{cd | IsCoprime (cd 0) (cd 1)} := by
rintro cd âšbâ, a, gcd_eqnâ©
let A := of ![![a, -bâ], cd]
have det_A_1 : det A = 1 := by
convert gcd_eqn
rw [det_fin_two]
simp [A, (by ring : a * cd 1 + bâ * cd 0 = bâ * cd 0 + a * cd 1)]
refine âšâšA, det_A_1â©, Set.mem_univ _, ?_â©
ext; simp [A]
end BottomRow
section TendstoLemmas
open Filter ContinuousLinearMap
attribute [local simp] ContinuousLinearMap.coe_smul
/-- The function `(c,d) â |cz+d|^2` is proper, that is, preimages of bounded-above sets are finite.
-/
theorem tendsto_normSq_coprime_pair :
Filter.Tendsto (fun p : Fin 2 â †=> normSq ((p 0 : â) * z + p 1)) cofinite atTop := by
-- using this instance rather than the automatic `Function.module` makes unification issues in
-- `LinearEquiv.isClosedEmbedding_of_injective` less bad later in the proof.
letI : Module â (Fin 2 â â) := NormedSpace.toModule
let Ïâ : (Fin 2 â â) ââ[â] â := LinearMap.proj 0
let Ïâ : (Fin 2 â â) ââ[â] â := LinearMap.proj 1
let f : (Fin 2 â â) ââ[â] â := Ïâ.smulRight (z : â) + Ïâ.smulRight 1
have f_def : âf = fun p : Fin 2 â â => (p 0 : â) * âz + p 1 := by
ext1
dsimp only [Ïâ, Ïâ, f, LinearMap.coe_proj, real_smul, LinearMap.coe_smulRight,
LinearMap.add_apply]
rw [mul_one]
have :
(fun p : Fin 2 â †=> normSq ((p 0 : â) * âz + â(p 1))) =
normSq â f â fun p : Fin 2 â †=> ((â) : †â â) â p := by
ext1
rw [f_def]
dsimp only [Function.comp_def]
rw [ofReal_intCast, ofReal_intCast]
rw [this]
have hf : LinearMap.ker f = ⥠:= by
let g : â ââ[â] Fin 2 â â :=
LinearMap.pi ![imLm, imLm.comp ((z : â) ⢠((conjAe : â ââ[â] â) : â ââ[â] â))]
suffices ((z : â).imâ»Â¹ ⢠g).comp f = LinearMap.id by exact LinearMap.ker_eq_bot_of_inverse this
apply LinearMap.ext
intro c
have hz : (z : â).im â 0 := z.2.ne'
rw [LinearMap.comp_apply, LinearMap.smul_apply, LinearMap.id_apply]
ext i
dsimp only [Pi.smul_apply, LinearMap.pi_apply, smul_eq_mul]
fin_cases i
· show (z : â).imâ»Â¹ * (f c).im = c 0
rw [f_def, add_im, im_ofReal_mul, ofReal_im, add_zero, mul_left_comm, inv_mul_cancelâ hz,
mul_one]
· show (z : â).imâ»Â¹ * ((z : â) * conj (f c)).im = c 1
rw [f_def, RingHom.map_add, RingHom.map_mul, mul_add, mul_left_comm, mul_conj, conj_ofReal,
conj_ofReal, â ofReal_mul, add_im, ofReal_im, zero_add, inv_mul_eq_iff_eq_mulâ hz]
simp only [ofReal_im, ofReal_re, mul_im, zero_add, mul_zero]
have hf' : IsClosedEmbedding f := f.isClosedEmbedding_of_injective hf
have hâ : Tendsto (fun p : Fin 2 â †=> ((â) : †â â) â p) cofinite (cocompact _) := by
convert Tendsto.pi_map_coprodáµ¢ fun _ => Int.tendsto_coe_cofinite
· rw [coprodᵢ_cofinite]
· rw [coprodᵢ_cocompact]
exact tendsto_normSq_cocompact_atTop.comp (hf'.tendsto_cocompact.comp hâ)
/-- Given `coprime_pair` `p=(c,d)`, the matrix `[[a,b],[*,*]]` is sent to `a*c+b*d`.
This is the linear map version of this operation.
-/
def lcRow0 (p : Fin 2 â â€) : Matrix (Fin 2) (Fin 2) â ââ[â] â :=
((p 0 : â) ⢠LinearMap.proj (0 : Fin 2) +
(p 1 : â) ⢠LinearMap.proj (1 : Fin 2) : (Fin 2 â â) ââ[â] â).comp
(LinearMap.proj 0)
@[simp]
theorem lcRow0_apply (p : Fin 2 â â€) (g : Matrix (Fin 2) (Fin 2) â) :
lcRow0 p g = p 0 * g 0 0 + p 1 * g 0 1 :=
rfl
/-- Linear map sending the matrix [a, b; c, d] to the matrix [acâ + bdâ, - adâ + bcâ; c, d], for
some fixed `(câ, dâ)`. -/
@[simps!]
def lcRow0Extend {cd : Fin 2 â â€} (hcd : IsCoprime (cd 0) (cd 1)) :
Matrix (Fin 2) (Fin 2) â ââ[â] Matrix (Fin 2) (Fin 2) â :=
LinearEquiv.piCongrRight
![by
refine
LinearMap.GeneralLinearGroup.generalLinearEquiv â (Fin 2 â â)
(GeneralLinearGroup.toLin (planeConformalMatrix (cd 0 : â) (-(cd 1 : â)) ?_))
norm_cast
rw [neg_sq]
exact hcd.sq_add_sq_ne_zero, LinearEquiv.refl â (Fin 2 â â)]
/-- The map `lcRow0` is proper, that is, preimages of cocompact sets are finite in
`[[* , *], [c, d]]`. -/
theorem tendsto_lcRow0 {cd : Fin 2 â â€} (hcd : IsCoprime (cd 0) (cd 1)) :
Tendsto (fun g : { g : SL(2, â€) // g 1 = cd } => lcRow0 cd â(âg : SL(2, â))) cofinite
(cocompact â) := by
let mB : â â Matrix (Fin 2) (Fin 2) â := fun t => of ![![t, (-(1 : â€) : â)], (â) â cd]
have hmB : Continuous mB := by
refine continuous_matrix ?_
simp only [mB, Fin.forall_fin_two, continuous_const, continuous_id', of_apply, cons_val_zero,
cons_val_one, and_self_iff]
refine Filter.Tendsto.of_tendsto_comp ?_ (comap_cocompact_le hmB)
let fâ : SL(2, â€) â Matrix (Fin 2) (Fin 2) â := fun g =>
Matrix.map (âg : Matrix _ _ â€) ((â) : †â â)
have cocompact_â_to_cofinite_â€_matrix :
Tendsto (fun m : Matrix (Fin 2) (Fin 2) †=> Matrix.map m ((â) : †â â)) cofinite
(cocompact _) := by
simpa only [coprodáµ¢_cofinite, coprodáµ¢_cocompact] using
Tendsto.pi_map_coprodáµ¢ fun _ : Fin 2 =>
Tendsto.pi_map_coprodáµ¢ fun _ : Fin 2 => Int.tendsto_coe_cofinite
have hfâ : Tendsto fâ cofinite (cocompact _) :=
cocompact_â_to_cofinite_â€_matrix.comp Subtype.coe_injective.tendsto_cofinite
have hfâ : IsClosedEmbedding (lcRow0Extend hcd) :=
(lcRow0Extend hcd).toContinuousLinearEquiv.toHomeomorph.isClosedEmbedding
convert hfâ.tendsto_cocompact.comp (hfâ.comp Subtype.coe_injective.tendsto_cofinite) using 1
ext âšg, rflâ© i j : 3
fin_cases i <;> [fin_cases j; skip]
-- the following are proved by `simp`, but it is replaced by `simp only` to avoid timeouts.
· simp only [Fin.isValue, Int.cast_one, map_apply_coe, RingHom.mapMatrix_apply,
Int.coe_castRingHom, lcRow0_apply, map_apply, Fin.zero_eta, id_eq, Function.comp_apply,
of_apply, cons_val', cons_val_zero, empty_val', cons_val_fin_one, lcRow0Extend_apply,
LinearMap.GeneralLinearGroup.coeFn_generalLinearEquiv, GeneralLinearGroup.coe_toLin,
val_planeConformalMatrix, neg_neg, mulVecLin_apply, mulVec, dotProduct, Fin.sum_univ_two,
cons_val_one, head_cons, mB, fâ]
· convert congr_arg (fun n : †=> (-n : â)) g.det_coe.symm using 1
simp only [Fin.zero_eta, id_eq, Function.comp_apply, lcRow0Extend_apply, cons_val_zero,
LinearMap.GeneralLinearGroup.coeFn_generalLinearEquiv, GeneralLinearGroup.coe_toLin,
mulVecLin_apply, mulVec, dotProduct, det_fin_two, fâ]
simp only [Fin.isValue, Fin.mk_one, val_planeConformalMatrix, neg_neg, of_apply, cons_val',
empty_val', cons_val_fin_one, cons_val_one, head_fin_const, map_apply, Fin.sum_univ_two,
cons_val_zero, neg_mul, head_cons, Int.cast_sub, Int.cast_mul, neg_sub]
ring
· rfl
/-- This replaces `(gâ¢z).re = a/c + *` in the standard theory with the following novel identity:
`g ⢠z = (a c + b d) / (c^2 + d^2) + (d z - c) / ((c^2 + d^2) (c z + d))`
which does not need to be decomposed depending on whether `c = 0`. -/
theorem smul_eq_lcRow0_add {p : Fin 2 â â€} (hp : IsCoprime (p 0) (p 1)) (hg : g 1 = p) :
â(g ⢠z) =
(lcRow0 p â(g : SL(2, â)) : â) / ((p 0 : â) ^ 2 + (p 1 : â) ^ 2) +
((p 1 : â) * z - p 0) / (((p 0 : â) ^ 2 + (p 1 : â) ^ 2) * (p 0 * z + p 1)) := by
have nonZ1 : (p 0 : â) ^ 2 + (p 1 : â) ^ 2 â 0 := mod_cast hp.sq_add_sq_ne_zero
have : ((â) : †â â) â p â 0 := fun h => hp.ne_zero (by ext i; simpa using congr_fun h i)
have nonZ2 : (p 0 : â) * z + p 1 â 0 := by simpa using linear_ne_zero _ z this
field_simp [nonZ1, nonZ2, denom_ne_zero, num]
rw [(by simp :
(p 1 : â) * z - p 0 = (p 1 * z - p 0) * â(Matrix.det (âg : Matrix (Fin 2) (Fin 2) â€)))]
rw [â hg, det_fin_two]
simp only [Int.coe_castRingHom, coe_matrix_coe, Int.cast_mul, ofReal_intCast, map_apply, denom,
Int.cast_sub, coe_GLPos_coe_GL_coe_matrix, coe_apply_complex]
ring
theorem tendsto_abs_re_smul {p : Fin 2 â â€} (hp : IsCoprime (p 0) (p 1)) :
Tendsto
(fun g : { g : SL(2, â€) // g 1 = p } => |((g : SL(2, â€)) ⢠z).re|) cofinite atTop := by
suffices
Tendsto (fun g : (fun g : SL(2, â€) => g 1) â»Â¹' {p} => ((g : SL(2, â€)) ⢠z).re) cofinite
(cocompact â)
by exact tendsto_norm_cocompact_atTop.comp this
have : ((p 0 : â) ^ 2 + (p 1 : â) ^ 2)â»Â¹ â 0 := by
apply inv_ne_zero
exact mod_cast hp.sq_add_sq_ne_zero
let f := Homeomorph.mulRightâ _ this
let ff := Homeomorph.addRight
(((p 1 : â) * z - p 0) / (((p 0 : â) ^ 2 + (p 1 : â) ^ 2) * (p 0 * z + p 1))).re
convert (f.trans ff).isClosedEmbedding.tendsto_cocompact.comp (tendsto_lcRow0 hp) with _ _ g
| change
((g : SL(2, â€)) ⢠z).re =
lcRow0 p â(âg : SL(2, â)) / ((p 0 : â) ^ 2 + (p 1 : â) ^ 2) +
Complex.re (((p 1 : â) * z - p 0) / (((p 0 : â) ^ 2 + (p 1 : â) ^ 2) * (p 0 * z + p 1)))
exact mod_cast congr_arg Complex.re (smul_eq_lcRow0_add z hp g.2)
end TendstoLemmas
section FundamentalDomain
attribute [local simp] UpperHalfPlane.coe_smul re_smul
/-- For `z : â`, there is a `g : SL(2,â€)` maximizing `(gâ¢z).im` -/
theorem exists_max_im : â g : SL(2, â€), â g' : SL(2, â€), (g' ⢠z).im †(g ⢠z).im := by
classical
let s : Set (Fin 2 â â€) := {cd | IsCoprime (cd 0) (cd 1)}
have hs : s.Nonempty := âš![1, 1], isCoprime_one_leftâ©
obtain âšp, hp_coprime, hpâ© :=
| Mathlib/NumberTheory/Modular.lean | 258 | 276 |
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Julian Kuelshammer
-/
import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Algebra.Group.Pointwise.Set.Finite
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Algebra.Module.NatInt
import Mathlib.Algebra.Order.Group.Action
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Data.Int.ModEq
import Mathlib.Dynamics.PeriodicPts.Lemmas
import Mathlib.GroupTheory.Index
import Mathlib.NumberTheory.Divisors
import Mathlib.Order.Interval.Set.Infinite
/-!
# Order of an element
This file defines the order of an element of a finite group. For a finite group `G` the order of
`x â G` is the minimal `n ⥠1` such that `x ^ n = 1`.
## Main definitions
* `IsOfFinOrder` is a predicate on an element `x` of a monoid `G` saying that `x` is of finite
order.
* `IsOfFinAddOrder` is the additive analogue of `IsOfFinOrder`.
* `orderOf x` defines the order of an element `x` of a monoid `G`, by convention its value is `0`
if `x` has infinite order.
* `addOrderOf` is the additive analogue of `orderOf`.
## Tags
order of an element
-/
assert_not_exists Field
open Function Fintype Nat Pointwise Subgroup Submonoid
open scoped Finset
variable {G H A α β : Type*}
section Monoid
variable [Monoid G] {a b x y : G} {n m : â}
section IsOfFinOrder
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/12129): additional beta reduction needed
@[to_additive]
theorem isPeriodicPt_mul_iff_pow_eq_one (x : G) : IsPeriodicPt (x * ·) n 1 â x ^ n = 1 := by
rw [IsPeriodicPt, IsFixedPt, mul_left_iterate]; beta_reduce; rw [mul_one]
/-- `IsOfFinOrder` is a predicate on an element `x` of a monoid to be of finite order, i.e. there
exists `n ⥠1` such that `x ^ n = 1`. -/
@[to_additive "`IsOfFinAddOrder` is a predicate on an element `a` of an
additive monoid to be of finite order, i.e. there exists `n ⥠1` such that `n ⢠a = 0`."]
def IsOfFinOrder (x : G) : Prop :=
(1 : G) â periodicPts (x * ·)
theorem isOfFinAddOrder_ofMul_iff : IsOfFinAddOrder (Additive.ofMul x) â IsOfFinOrder x :=
Iff.rfl
theorem isOfFinOrder_ofAdd_iff {α : Type*} [AddMonoid α] {x : α} :
IsOfFinOrder (Multiplicative.ofAdd x) â IsOfFinAddOrder x := Iff.rfl
@[to_additive]
theorem isOfFinOrder_iff_pow_eq_one : IsOfFinOrder x â â n, 0 < n â§ x ^ n = 1 := by
simp [IsOfFinOrder, mem_periodicPts, isPeriodicPt_mul_iff_pow_eq_one]
@[to_additive] alias âšIsOfFinOrder.exists_pow_eq_one, _â© := isOfFinOrder_iff_pow_eq_one
@[to_additive]
lemma isOfFinOrder_iff_zpow_eq_one {G} [DivisionMonoid G] {x : G} :
IsOfFinOrder x â â (n : â€), n â 0 â§ x ^ n = 1 := by
rw [isOfFinOrder_iff_pow_eq_one]
refine âšfun âšn, hn, hn'⩠⊠âšn, Int.natCast_ne_zero_iff_pos.mpr hn, zpow_natCast x n âž hn'â©,
fun âšn, hn, hn'⩠⊠âšn.natAbs, Int.natAbs_pos.mpr hn, ?_â©â©
rcases (Int.natAbs_eq_iff (a := n)).mp rfl with h | h
· rwa [h, zpow_natCast] at hn'
· rwa [h, zpow_neg, inv_eq_one, zpow_natCast] at hn'
/-- See also `injective_pow_iff_not_isOfFinOrder`. -/
@[to_additive "See also `injective_nsmul_iff_not_isOfFinAddOrder`."]
theorem not_isOfFinOrder_of_injective_pow {x : G} (h : Injective fun n : â => x ^ n) :
¬IsOfFinOrder x := by
simp_rw [isOfFinOrder_iff_pow_eq_one, not_exists, not_and]
intro n hn_pos hnx
rw [â pow_zero x] at hnx
rw [h hnx] at hn_pos
exact irrefl 0 hn_pos
/-- 1 is of finite order in any monoid. -/
@[to_additive (attr := simp) "0 is of finite order in any additive monoid."]
theorem IsOfFinOrder.one : IsOfFinOrder (1 : G) :=
isOfFinOrder_iff_pow_eq_one.mpr âš1, Nat.one_pos, one_pow 1â©
@[to_additive]
lemma IsOfFinOrder.pow {n : â} : IsOfFinOrder a â IsOfFinOrder (a ^ n) := by
simp_rw [isOfFinOrder_iff_pow_eq_one]
rintro âšm, hm, haâ©
exact âšm, hm, by simp [pow_right_comm _ n, ha]â©
@[to_additive]
lemma IsOfFinOrder.of_pow {n : â} (h : IsOfFinOrder (a ^ n)) (hn : n â 0) : IsOfFinOrder a := by
rw [isOfFinOrder_iff_pow_eq_one] at *
rcases h with âšm, hm, haâ©
exact âšn * m, mul_pos hn.bot_lt hm, by rwa [pow_mul]â©
@[to_additive (attr := simp)]
lemma isOfFinOrder_pow {n : â} : IsOfFinOrder (a ^ n) â IsOfFinOrder a âš n = 0 := by
rcases Decidable.eq_or_ne n 0 with rfl | hn
· simp
· exact âšfun h ⊠.inl <| h.of_pow hn, fun h ⊠(h.resolve_right hn).powâ©
/-- Elements of finite order are of finite order in submonoids. -/
@[to_additive "Elements of finite order are of finite order in submonoids."]
theorem Submonoid.isOfFinOrder_coe {H : Submonoid G} {x : H} :
IsOfFinOrder (x : G) â IsOfFinOrder x := by
rw [isOfFinOrder_iff_pow_eq_one, isOfFinOrder_iff_pow_eq_one]
norm_cast
theorem IsConj.isOfFinOrder (h : IsConj x y) : IsOfFinOrder x â IsOfFinOrder y := by
simp_rw [isOfFinOrder_iff_pow_eq_one]
rintro âšn, n_gt_0, eq'â©
exact âšn, n_gt_0, by rw [â isConj_one_right, â eq']; exact h.pow nâ©
/-- The image of an element of finite order has finite order. -/
@[to_additive "The image of an element of finite additive order has finite additive order."]
theorem MonoidHom.isOfFinOrder [Monoid H] (f : G â* H) {x : G} (h : IsOfFinOrder x) :
IsOfFinOrder <| f x :=
isOfFinOrder_iff_pow_eq_one.mpr <| by
obtain âšn, npos, hnâ© := h.exists_pow_eq_one
exact âšn, npos, by rw [â f.map_pow, hn, f.map_one]â©
/-- If a direct product has finite order then so does each component. -/
@[to_additive "If a direct product has finite additive order then so does each component."]
theorem IsOfFinOrder.apply {η : Type*} {Gs : η â Type*} [â i, Monoid (Gs i)] {x : â i, Gs i}
(h : IsOfFinOrder x) : â i, IsOfFinOrder (x i) := by
obtain âšn, npos, hnâ© := h.exists_pow_eq_one
exact fun _ => isOfFinOrder_iff_pow_eq_one.mpr âšn, npos, (congr_fun hn.symm _).symmâ©
/-- The submonoid generated by an element is a group if that element has finite order. -/
@[to_additive "The additive submonoid generated by an element is
an additive group if that element has finite order."]
noncomputable abbrev IsOfFinOrder.groupPowers (hx : IsOfFinOrder x) :
Group (Submonoid.powers x) := by
obtain âšhpos, hxâ© := hx.exists_pow_eq_one.choose_spec
exact Submonoid.groupPowers hpos hx
end IsOfFinOrder
/-- `orderOf x` is the order of the element `x`, i.e. the `n ⥠1`, s.t. `x ^ n = 1` if it exists.
Otherwise, i.e. if `x` is of infinite order, then `orderOf x` is `0` by convention. -/
@[to_additive
"`addOrderOf a` is the order of the element `a`, i.e. the `n ⥠1`, s.t. `n ⢠a = 0` if it
exists. Otherwise, i.e. if `a` is of infinite order, then `addOrderOf a` is `0` by convention."]
noncomputable def orderOf (x : G) : â :=
minimalPeriod (x * ·) 1
@[simp]
theorem addOrderOf_ofMul_eq_orderOf (x : G) : addOrderOf (Additive.ofMul x) = orderOf x :=
rfl
@[simp]
lemma orderOf_ofAdd_eq_addOrderOf {α : Type*} [AddMonoid α] (a : α) :
orderOf (Multiplicative.ofAdd a) = addOrderOf a := rfl
@[to_additive]
protected lemma IsOfFinOrder.orderOf_pos (h : IsOfFinOrder x) : 0 < orderOf x :=
minimalPeriod_pos_of_mem_periodicPts h
@[to_additive addOrderOf_nsmul_eq_zero]
theorem pow_orderOf_eq_one (x : G) : x ^ orderOf x = 1 := by
convert Eq.trans _ (isPeriodicPt_minimalPeriod (x * ·) 1)
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/12129): additional beta reduction needed in the middle of the rewrite
rw [orderOf, mul_left_iterate]; beta_reduce; rw [mul_one]
@[to_additive]
theorem orderOf_eq_zero (h : ¬IsOfFinOrder x) : orderOf x = 0 := by
rwa [orderOf, minimalPeriod, dif_neg]
@[to_additive]
theorem orderOf_eq_zero_iff : orderOf x = 0 â ¬IsOfFinOrder x :=
âšfun h H ⊠H.orderOf_pos.ne' h, orderOf_eq_zeroâ©
@[to_additive]
theorem orderOf_eq_zero_iff' : orderOf x = 0 â â n : â, 0 < n â x ^ n â 1 := by
simp_rw [orderOf_eq_zero_iff, isOfFinOrder_iff_pow_eq_one, not_exists, not_and]
@[to_additive]
theorem orderOf_eq_iff {n} (h : 0 < n) :
orderOf x = n â x ^ n = 1 â§ â m, m < n â 0 < m â x ^ m â 1 := by
simp_rw [Ne, â isPeriodicPt_mul_iff_pow_eq_one, orderOf, minimalPeriod]
split_ifs with h1
· classical
rw [find_eq_iff]
simp only [h, true_and]
push_neg
rfl
· rw [iff_false_left h.ne]
rintro âšh', -â©
exact h1 âšn, h, h'â©
/-- A group element has finite order iff its order is positive. -/
@[to_additive
"A group element has finite additive order iff its order is positive."]
theorem orderOf_pos_iff : 0 < orderOf x â IsOfFinOrder x := by
rw [iff_not_comm.mp orderOf_eq_zero_iff, pos_iff_ne_zero]
@[to_additive]
theorem IsOfFinOrder.mono [Monoid β] {y : β} (hx : IsOfFinOrder x) (h : orderOf y ⣠orderOf x) :
IsOfFinOrder y := by rw [â orderOf_pos_iff] at hx â¢; exact Nat.pos_of_dvd_of_pos h hx
@[to_additive]
theorem pow_ne_one_of_lt_orderOf (n0 : n â 0) (h : n < orderOf x) : x ^ n â 1 := fun j =>
not_isPeriodicPt_of_pos_of_lt_minimalPeriod n0 h ((isPeriodicPt_mul_iff_pow_eq_one x).mpr j)
@[to_additive]
theorem orderOf_le_of_pow_eq_one (hn : 0 < n) (h : x ^ n = 1) : orderOf x †n :=
IsPeriodicPt.minimalPeriod_le hn (by rwa [isPeriodicPt_mul_iff_pow_eq_one])
@[to_additive (attr := simp)]
theorem orderOf_one : orderOf (1 : G) = 1 := by
rw [orderOf, â minimalPeriod_id (x := (1 : G)), â one_mul_eq_id]
@[to_additive (attr := simp) AddMonoid.addOrderOf_eq_one_iff]
theorem orderOf_eq_one_iff : orderOf x = 1 â x = 1 := by
rw [orderOf, minimalPeriod_eq_one_iff_isFixedPt, IsFixedPt, mul_one]
@[to_additive (attr := simp) mod_addOrderOf_nsmul]
lemma pow_mod_orderOf (x : G) (n : â) : x ^ (n % orderOf x) = x ^ n :=
calc
x ^ (n % orderOf x) = x ^ (n % orderOf x + orderOf x * (n / orderOf x)) := by
simp [pow_add, pow_mul, pow_orderOf_eq_one]
_ = x ^ n := by rw [Nat.mod_add_div]
@[to_additive]
theorem orderOf_dvd_of_pow_eq_one (h : x ^ n = 1) : orderOf x ⣠n :=
IsPeriodicPt.minimalPeriod_dvd ((isPeriodicPt_mul_iff_pow_eq_one _).mpr h)
@[to_additive]
theorem orderOf_dvd_iff_pow_eq_one {n : â} : orderOf x ⣠n â x ^ n = 1 :=
âšfun h => by rw [â pow_mod_orderOf, Nat.mod_eq_zero_of_dvd h, _root_.pow_zero],
orderOf_dvd_of_pow_eq_oneâ©
@[to_additive addOrderOf_smul_dvd]
theorem orderOf_pow_dvd (n : â) : orderOf (x ^ n) ⣠orderOf x := by
rw [orderOf_dvd_iff_pow_eq_one, pow_right_comm, pow_orderOf_eq_one, one_pow]
@[to_additive]
lemma pow_injOn_Iio_orderOf : (Set.Iio <| orderOf x).InjOn (x ^ ·) := by
simpa only [mul_left_iterate, mul_one]
using iterate_injOn_Iio_minimalPeriod (f := (x * ·)) (x := 1)
@[to_additive]
protected lemma IsOfFinOrder.mem_powers_iff_mem_range_orderOf [DecidableEq G]
(hx : IsOfFinOrder x) :
y â Submonoid.powers x â y â (Finset.range (orderOf x)).image (x ^ ·) :=
Finset.mem_range_iff_mem_finset_range_of_mod_eq' hx.orderOf_pos <| pow_mod_orderOf _
@[to_additive]
protected lemma IsOfFinOrder.powers_eq_image_range_orderOf [DecidableEq G] (hx : IsOfFinOrder x) :
(Submonoid.powers x : Set G) = (Finset.range (orderOf x)).image (x ^ ·) :=
Set.ext fun _ ⊠hx.mem_powers_iff_mem_range_orderOf
@[to_additive]
theorem pow_eq_one_iff_modEq : x ^ n = 1 â n â¡ 0 [MOD orderOf x] := by
rw [modEq_zero_iff_dvd, orderOf_dvd_iff_pow_eq_one]
@[to_additive]
theorem orderOf_map_dvd {H : Type*} [Monoid H] (Ï : G â* H) (x : G) :
orderOf (Ï x) ⣠orderOf x := by
apply orderOf_dvd_of_pow_eq_one
rw [â map_pow, pow_orderOf_eq_one]
apply map_one
@[to_additive]
theorem exists_pow_eq_self_of_coprime (h : n.Coprime (orderOf x)) : â m : â, (x ^ n) ^ m = x := by
by_cases h0 : orderOf x = 0
· rw [h0, coprime_zero_right] at h
exact âš1, by rw [h, pow_one, pow_one]â©
by_cases h1 : orderOf x = 1
· exact âš0, by rw [orderOf_eq_one_iff.mp h1, one_pow, one_pow]â©
obtain âšm, hâ© := exists_mul_emod_eq_one_of_coprime h (one_lt_iff_ne_zero_and_ne_one.mpr âšh0, h1â©)
exact âšm, by rw [â pow_mul, â pow_mod_orderOf, h, pow_one]â©
/-- If `x^n = 1`, but `x^(n/p) â 1` for all prime factors `p` of `n`,
then `x` has order `n` in `G`. -/
@[to_additive addOrderOf_eq_of_nsmul_and_div_prime_nsmul "If `n * x = 0`, but `n/p * x â 0` for
all prime factors `p` of `n`, then `x` has order `n` in `G`."]
theorem orderOf_eq_of_pow_and_pow_div_prime (hn : 0 < n) (hx : x ^ n = 1)
(hd : â p : â, p.Prime â p ⣠n â x ^ (n / p) â 1) : orderOf x = n := by
-- Let `a` be `n/(orderOf x)`, and show `a = 1`
obtain âša, haâ© := exists_eq_mul_right_of_dvd (orderOf_dvd_of_pow_eq_one hx)
suffices a = 1 by simp [this, ha]
-- Assume `a` is not one...
by_contra h
have a_min_fac_dvd_p_sub_one : a.minFac ⣠n := by
obtain âšb, hbâ© : â b : â, a = b * a.minFac := exists_eq_mul_left_of_dvd a.minFac_dvd
rw [hb, â mul_assoc] at ha
exact Dvd.intro_left (orderOf x * b) ha.symm
-- Use the minimum prime factor of `a` as `p`.
refine hd a.minFac (Nat.minFac_prime h) a_min_fac_dvd_p_sub_one ?_
rw [â orderOf_dvd_iff_pow_eq_one, Nat.dvd_div_iff_mul_dvd a_min_fac_dvd_p_sub_one, ha, mul_comm,
Nat.mul_dvd_mul_iff_left (IsOfFinOrder.orderOf_pos _)]
· exact Nat.minFac_dvd a
· rw [isOfFinOrder_iff_pow_eq_one]
exact Exists.intro n (id âšhn, hxâ©)
@[to_additive]
theorem orderOf_eq_orderOf_iff {H : Type*} [Monoid H] {y : H} :
orderOf x = orderOf y â â n : â, x ^ n = 1 â y ^ n = 1 := by
simp_rw [â isPeriodicPt_mul_iff_pow_eq_one, â minimalPeriod_eq_minimalPeriod_iff, orderOf]
/-- An injective homomorphism of monoids preserves orders of elements. -/
@[to_additive "An injective homomorphism of additive monoids preserves orders of elements."]
theorem orderOf_injective {H : Type*} [Monoid H] (f : G â* H) (hf : Function.Injective f) (x : G) :
orderOf (f x) = orderOf x := by
simp_rw [orderOf_eq_orderOf_iff, â f.map_pow, â f.map_one, hf.eq_iff, forall_const]
/-- A multiplicative equivalence preserves orders of elements. -/
@[to_additive (attr := simp) "An additive equivalence preserves orders of elements."]
lemma MulEquiv.orderOf_eq {H : Type*} [Monoid H] (e : G â* H) (x : G) :
orderOf (e x) = orderOf x :=
orderOf_injective e.toMonoidHom e.injective x
@[to_additive]
theorem Function.Injective.isOfFinOrder_iff [Monoid H] {f : G â* H} (hf : Injective f) :
IsOfFinOrder (f x) â IsOfFinOrder x := by
rw [â orderOf_pos_iff, orderOf_injective f hf x, â orderOf_pos_iff]
@[to_additive (attr := norm_cast, simp)]
theorem orderOf_submonoid {H : Submonoid G} (y : H) : orderOf (y : G) = orderOf y :=
orderOf_injective H.subtype Subtype.coe_injective y
@[to_additive]
theorem orderOf_units {y : GË£} : orderOf (y : G) = orderOf y :=
orderOf_injective (Units.coeHom G) Units.ext y
/-- If the order of `x` is finite, then `x` is a unit with inverse `x ^ (orderOf x - 1)`. -/
@[to_additive (attr := simps) "If the additive order of `x` is finite, then `x` is an additive
unit with inverse `(addOrderOf x - 1) ⢠x`. "]
noncomputable def IsOfFinOrder.unit {M} [Monoid M] {x : M} (hx : IsOfFinOrder x) : MË£ :=
âšx, x ^ (orderOf x - 1),
by rw [â _root_.pow_succ', tsub_add_cancel_of_le (by exact hx.orderOf_pos), pow_orderOf_eq_one],
by rw [â _root_.pow_succ, tsub_add_cancel_of_le (by exact hx.orderOf_pos), pow_orderOf_eq_one]â©
@[to_additive]
lemma IsOfFinOrder.isUnit {M} [Monoid M] {x : M} (hx : IsOfFinOrder x) : IsUnit x := âšhx.unit, rflâ©
variable (x)
@[to_additive]
theorem orderOf_pow' (h : n â 0) : orderOf (x ^ n) = orderOf x / gcd (orderOf x) n := by
unfold orderOf
rw [â minimalPeriod_iterate_eq_div_gcd h, mul_left_iterate]
@[to_additive]
lemma orderOf_pow_of_dvd {x : G} {n : â} (hn : n â 0) (dvd : n ⣠orderOf x) :
orderOf (x ^ n) = orderOf x / n := by rw [orderOf_pow' _ hn, Nat.gcd_eq_right dvd]
@[to_additive]
lemma orderOf_pow_orderOf_div {x : G} {n : â} (hx : orderOf x â 0) (hn : n ⣠orderOf x) :
orderOf (x ^ (orderOf x / n)) = n := by
rw [orderOf_pow_of_dvd _ (Nat.div_dvd_of_dvd hn), Nat.div_div_self hn hx]
rw [â Nat.div_mul_cancel hn] at hx; exact left_ne_zero_of_mul hx
variable (n)
@[to_additive]
protected lemma IsOfFinOrder.orderOf_pow (h : IsOfFinOrder x) :
orderOf (x ^ n) = orderOf x / gcd (orderOf x) n := by
unfold orderOf
rw [â minimalPeriod_iterate_eq_div_gcd' h, mul_left_iterate]
@[to_additive]
lemma Nat.Coprime.orderOf_pow (h : (orderOf y).Coprime m) : orderOf (y ^ m) = orderOf y := by
by_cases hg : IsOfFinOrder y
· rw [hg.orderOf_pow y m , h.gcd_eq_one, Nat.div_one]
· rw [m.coprime_zero_left.1 (orderOf_eq_zero hg ➠h), pow_one]
@[to_additive]
lemma IsOfFinOrder.natCard_powers_le_orderOf (ha : IsOfFinOrder a) :
Nat.card (powers a : Set G) †orderOf a := by
classical
simpa [ha.powers_eq_image_range_orderOf, Finset.card_range, Nat.Iio_eq_range]
using Finset.card_image_le (s := Finset.range (orderOf a))
@[to_additive]
lemma IsOfFinOrder.finite_powers (ha : IsOfFinOrder a) : (powers a : Set G).Finite := by
classical rw [ha.powers_eq_image_range_orderOf]; exact Finset.finite_toSet _
namespace Commute
variable {x}
@[to_additive]
theorem orderOf_mul_dvd_lcm (h : Commute x y) :
orderOf (x * y) ⣠Nat.lcm (orderOf x) (orderOf y) := by
rw [orderOf, â comp_mul_left]
exact Function.Commute.minimalPeriod_of_comp_dvd_lcm h.function_commute_mul_left
@[to_additive]
theorem orderOf_dvd_lcm_mul (h : Commute x y):
orderOf y ⣠Nat.lcm (orderOf x) (orderOf (x * y)) := by
by_cases h0 : orderOf x = 0
· rw [h0, lcm_zero_left]
apply dvd_zero
conv_lhs =>
rw [â one_mul y, â pow_orderOf_eq_one x, â succ_pred_eq_of_pos (Nat.pos_of_ne_zero h0),
_root_.pow_succ, mul_assoc]
exact
(((Commute.refl x).mul_right h).pow_left _).orderOf_mul_dvd_lcm.trans
(lcm_dvd_iff.2 âš(orderOf_pow_dvd _).trans (dvd_lcm_left _ _), dvd_lcm_right _ _â©)
@[to_additive addOrderOf_add_dvd_mul_addOrderOf]
theorem orderOf_mul_dvd_mul_orderOf (h : Commute x y):
orderOf (x * y) ⣠orderOf x * orderOf y :=
dvd_trans h.orderOf_mul_dvd_lcm (lcm_dvd_mul _ _)
@[to_additive addOrderOf_add_eq_mul_addOrderOf_of_coprime]
theorem orderOf_mul_eq_mul_orderOf_of_coprime (h : Commute x y)
(hco : (orderOf x).Coprime (orderOf y)) : orderOf (x * y) = orderOf x * orderOf y := by
rw [orderOf, â comp_mul_left]
exact h.function_commute_mul_left.minimalPeriod_of_comp_eq_mul_of_coprime hco
/-- Commuting elements of finite order are closed under multiplication. -/
@[to_additive "Commuting elements of finite additive order are closed under addition."]
theorem isOfFinOrder_mul (h : Commute x y) (hx : IsOfFinOrder x) (hy : IsOfFinOrder y) :
IsOfFinOrder (x * y) :=
orderOf_pos_iff.mp <|
pos_of_dvd_of_pos h.orderOf_mul_dvd_mul_orderOf <| mul_pos hx.orderOf_pos hy.orderOf_pos
/-- If each prime factor of `orderOf x` has higher multiplicity in `orderOf y`, and `x` commutes
with `y`, then `x * y` has the same order as `y`. -/
@[to_additive addOrderOf_add_eq_right_of_forall_prime_mul_dvd
"If each prime factor of
`addOrderOf x` has higher multiplicity in `addOrderOf y`, and `x` commutes with `y`,
then `x + y` has the same order as `y`."]
theorem orderOf_mul_eq_right_of_forall_prime_mul_dvd (h : Commute x y) (hy : IsOfFinOrder y)
(hdvd : â p : â, p.Prime â p ⣠orderOf x â p * orderOf x ⣠orderOf y) :
orderOf (x * y) = orderOf y := by
have hoy := hy.orderOf_pos
have hxy := dvd_of_forall_prime_mul_dvd hdvd
apply orderOf_eq_of_pow_and_pow_div_prime hoy <;> simp only [Ne, â orderOf_dvd_iff_pow_eq_one]
· exact h.orderOf_mul_dvd_lcm.trans (lcm_dvd hxy dvd_rfl)
refine fun p hp hpy hd => hp.ne_one ?_
rw [â Nat.dvd_one, â mul_dvd_mul_iff_right hoy.ne', one_mul, â dvd_div_iff_mul_dvd hpy]
refine (orderOf_dvd_lcm_mul h).trans (lcm_dvd ((dvd_div_iff_mul_dvd hpy).2 ?_) hd)
by_cases h : p ⣠orderOf x
exacts [hdvd p hp h, (hp.coprime_iff_not_dvd.2 h).mul_dvd_of_dvd_of_dvd hpy hxy]
end Commute
section PPrime
variable {x n} {p : â} [hp : Fact p.Prime]
@[to_additive]
theorem orderOf_eq_prime_iff : orderOf x = p â x ^ p = 1 â§ x â 1 := by
rw [orderOf, minimalPeriod_eq_prime_iff, isPeriodicPt_mul_iff_pow_eq_one, IsFixedPt, mul_one]
/-- The backward direction of `orderOf_eq_prime_iff`. -/
@[to_additive "The backward direction of `addOrderOf_eq_prime_iff`."]
theorem orderOf_eq_prime (hg : x ^ p = 1) (hg1 : x â 1) : orderOf x = p :=
orderOf_eq_prime_iff.mpr âšhg, hg1â©
@[to_additive addOrderOf_eq_prime_pow]
theorem orderOf_eq_prime_pow (hnot : ¬x ^ p ^ n = 1) (hfin : x ^ p ^ (n + 1) = 1) :
orderOf x = p ^ (n + 1) := by
apply minimalPeriod_eq_prime_pow <;> rwa [isPeriodicPt_mul_iff_pow_eq_one]
@[to_additive exists_addOrderOf_eq_prime_pow_iff]
theorem exists_orderOf_eq_prime_pow_iff :
(â k : â, orderOf x = p ^ k) â â m : â, x ^ (p : â) ^ m = 1 :=
âšfun âšk, hkâ© => âšk, by rw [â hk, pow_orderOf_eq_one]â©, fun âš_, hmâ© => by
obtain âšk, _, hkâ© := (Nat.dvd_prime_pow hp.elim).mp (orderOf_dvd_of_pow_eq_one hm)
exact âšk, hkâ©â©
end PPrime
/-- The equivalence between `Fin (orderOf x)` and `Submonoid.powers x`, sending `i` to `x ^ i` -/
@[to_additive "The equivalence between `Fin (addOrderOf a)` and
`AddSubmonoid.multiples a`, sending `i` to `i ⢠a`"]
noncomputable def finEquivPowers {x : G} (hx : IsOfFinOrder x) : Fin (orderOf x) â powers x :=
Equiv.ofBijective (fun n ⊠âšx ^ (n : â), âšn, rflâ©â©) âšfun âš_, hââ© âš_, hââ© ij âŠ
Fin.ext (pow_injOn_Iio_orderOf hâ hâ (Subtype.mk_eq_mk.1 ij)), fun âš_, i, rflâ© âŠ
âšâši % orderOf x, mod_lt _ hx.orderOf_posâ©, Subtype.eq <| pow_mod_orderOf _ _â©â©
@[to_additive (attr := simp)]
lemma finEquivPowers_apply {x : G} (hx : IsOfFinOrder x) {n : Fin (orderOf x)} :
finEquivPowers hx n = âšx ^ (n : â), n, rflâ© := rfl
@[to_additive (attr := simp)]
lemma finEquivPowers_symm_apply {x : G} (hx : IsOfFinOrder x) (n : â) :
(finEquivPowers hx).symm âšx ^ n, _, rflâ© = âšn % orderOf x, Nat.mod_lt _ hx.orderOf_posâ© := by
rw [Equiv.symm_apply_eq, finEquivPowers_apply, Subtype.mk_eq_mk, â pow_mod_orderOf, Fin.val_mk]
variable {x n} (hx : IsOfFinOrder x)
include hx
@[to_additive]
theorem IsOfFinOrder.pow_eq_pow_iff_modEq : x ^ n = x ^ m â n â¡ m [MOD orderOf x] := by
wlog hmn : m †n generalizing m n
· rw [eq_comm, ModEq.comm, this (le_of_not_le hmn)]
obtain âšk, rflâ© := Nat.exists_eq_add_of_le hmn
rw [pow_add, (hx.isUnit.pow _).mul_eq_left, pow_eq_one_iff_modEq]
exact âšfun h ⊠Nat.ModEq.add_left _ h, fun h ⊠Nat.ModEq.add_left_cancel' _ hâ©
@[to_additive]
lemma IsOfFinOrder.pow_inj_mod {n m : â} : x ^ n = x ^ m â n % orderOf x = m % orderOf x :=
hx.pow_eq_pow_iff_modEq
end Monoid
section CancelMonoid
variable [LeftCancelMonoid G] {x y : G} {a : G} {m n : â}
@[to_additive]
theorem pow_eq_pow_iff_modEq : x ^ n = x ^ m â n â¡ m [MOD orderOf x] := by
wlog hmn : m †n generalizing m n
· rw [eq_comm, ModEq.comm, this (le_of_not_le hmn)]
obtain âšk, rflâ© := Nat.exists_eq_add_of_le hmn
rw [â mul_one (x ^ m), pow_add, mul_left_cancel_iff, pow_eq_one_iff_modEq]
exact âšfun h => Nat.ModEq.add_left _ h, fun h => Nat.ModEq.add_left_cancel' _ hâ©
@[to_additive (attr := simp)]
lemma injective_pow_iff_not_isOfFinOrder : Injective (fun n : â ⊠x ^ n) â ¬IsOfFinOrder x := by
refine âšfun h => not_isOfFinOrder_of_injective_pow h, fun h n m hnm => ?_â©
rwa [pow_eq_pow_iff_modEq, orderOf_eq_zero_iff.mpr h, modEq_zero_iff] at hnm
@[to_additive]
lemma pow_inj_mod {n m : â} : x ^ n = x ^ m â n % orderOf x = m % orderOf x := pow_eq_pow_iff_modEq
@[to_additive]
theorem pow_inj_iff_of_orderOf_eq_zero (h : orderOf x = 0) {n m : â} : x ^ n = x ^ m â n = m := by
rw [pow_eq_pow_iff_modEq, h, modEq_zero_iff]
@[to_additive]
theorem infinite_not_isOfFinOrder {x : G} (h : ¬IsOfFinOrder x) :
{ y : G | ¬IsOfFinOrder y }.Infinite := by
let s := { n | 0 < n }.image fun n : â => x ^ n
have hs : s â { y : G | ¬IsOfFinOrder y } := by
rintro - âšn, hn : 0 < n, rflâ© (contra : IsOfFinOrder (x ^ n))
apply h
rw [isOfFinOrder_iff_pow_eq_one] at contra â¢
obtain âšm, hm, hm'â© := contra
exact âšn * m, mul_pos hn hm, by rwa [pow_mul]â©
suffices s.Infinite by exact this.mono hs
contrapose! h
have : ¬Injective fun n : â => x ^ n := by
have := Set.not_injOn_infinite_finite_image (Set.Ioi_infinite 0) (Set.not_infinite.mp h)
contrapose! this
exact Set.injOn_of_injective this
rwa [injective_pow_iff_not_isOfFinOrder, Classical.not_not] at this
@[to_additive (attr := simp)]
lemma finite_powers : (powers a : Set G).Finite â IsOfFinOrder a := by
refine âšfun h ⊠?_, IsOfFinOrder.finite_powersâ©
obtain âšm, n, hmn, haâ© := h.exists_lt_map_eq_of_forall_mem (f := fun n : â ⊠a ^ n)
(fun n ⊠by simp [mem_powers_iff])
refine isOfFinOrder_iff_pow_eq_one.2 âšn - m, tsub_pos_iff_lt.2 hmn, ?_â©
rw [â mul_left_cancel_iff (a := a ^ m), â pow_add, add_tsub_cancel_of_le hmn.le, ha, mul_one]
@[to_additive (attr := simp)]
lemma infinite_powers : (powers a : Set G).Infinite â ¬ IsOfFinOrder a := finite_powers.not
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive "See also `addOrder_eq_card_multiples`."]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
classical
by_cases ha : IsOfFinOrder a
· exact (Nat.card_congr (finEquivPowers ha).symm).trans <| by simp
· have := (infinite_powers.2 ha).to_subtype
rw [orderOf_eq_zero ha, Nat.card_eq_zero_of_infinite]
end CancelMonoid
section Group
|
variable [Group G] {x y : G} {i : â€}
| Mathlib/GroupTheory/OrderOfElement.lean | 580 | 581 |
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Combinatorics.SetFamily.Compression.Down
import Mathlib.Data.Fintype.Powerset
import Mathlib.Order.Interval.Finset.Nat
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
/-!
# Shattering families
This file defines the shattering property and VC-dimension of set families.
## Main declarations
* `Finset.Shatters`: The shattering property.
* `Finset.shatterer`: The set family of sets shattered by a set family.
* `Finset.vcDim`: The Vapnik-Chervonenkis dimension.
## TODO
* Order-shattering
* Strong shattering
-/
open scoped FinsetFamily
namespace Finset
variable {α : Type*} [DecidableEq α] {ð ⬠: Finset (Finset α)} {s t : Finset α} {a : α}
/-- A set family `ð` shatters a set `s` if all subsets of `s` can be obtained as the intersection
of `s` and some element of the set family, and we denote this `ð.Shatters s`. We also say that `s`
is *traced* by `ð`. -/
def Shatters (ð : Finset (Finset α)) (s : Finset α) : Prop := â âŠtâŠ, t â s â â u â ð, s â© u = t
instance : DecidablePred ð.Shatters := fun _s ⊠decidableForallOfDecidableSubsets
lemma Shatters.exists_inter_eq_singleton (hs : Shatters ð s) (ha : a â s) : â t â ð, s â© t = {a} :=
hs <| singleton_subset_iff.2 ha
lemma Shatters.mono_left (h : ð â â¬) (hð : ð.Shatters s) : â¬.Shatters s :=
fun _t ht ⊠let âšu, hu, hutâ© := hð ht; âšu, h hu, hutâ©
lemma Shatters.mono_right (h : t â s) (hs : ð.Shatters s) : ð.Shatters t := fun u hu ⊠by
obtain âšv, hv, rflâ© := hs (hu.trans h); exact âšv, hv, inf_congr_right hu <| inf_le_of_left_le hâ©
lemma Shatters.exists_superset (h : ð.Shatters s) : â t â ð, s â t :=
let âšt, ht, hstâ© := h Subset.rfl; âšt, ht, inter_eq_left.1 hstâ©
lemma shatters_of_forall_subset (h : â t, t â s â t â ð) : ð.Shatters s :=
fun t ht ⊠âšt, h _ ht, inter_eq_right.2 htâ©
protected lemma Shatters.nonempty (h : ð.Shatters s) : ð.Nonempty :=
let âšt, ht, _â© := h Subset.rfl; âšt, htâ©
@[simp] lemma shatters_empty : ð.Shatters â
â ð.Nonempty :=
âšShatters.nonempty, fun âšs, hsâ© t ht ⊠âšs, hs, by rwa [empty_inter, eq_comm, â subset_empty]â©â©
protected lemma Shatters.subset_iff (h : ð.Shatters s) : t â s â â u â ð, s â© u = t :=
âšfun ht ⊠h ht, by rintro âšu, _, rflâ©; exact inter_subset_leftâ©
lemma shatters_iff : ð.Shatters s â ð.image (fun t ⊠s â© t) = s.powerset :=
âšfun h ⊠by ext t; rw [mem_image, mem_powerset, h.subset_iff],
fun h t ht ⊠by rwa [â mem_powerset, â h, mem_image] at htâ©
lemma univ_shatters [Fintype α] : univ.Shatters s :=
shatters_of_forall_subset fun _ _ ⊠mem_univ _
| @[simp] lemma shatters_univ [Fintype α] : ð.Shatters univ â ð = univ := by
rw [shatters_iff, powerset_univ]; simp_rw [univ_inter, image_id']
| Mathlib/Combinatorics/SetFamily/Shatter.lean | 71 | 72 |
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura
-/
import Batteries.Data.Nat.Gcd
import Mathlib.Algebra.Group.Nat.Units
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.GroupWithZero.Nat
/-!
# Properties of `Nat.gcd`, `Nat.lcm`, and `Nat.Coprime`
Definitions are provided in batteries.
Generalizations of these are provided in a later file as `GCDMonoid.gcd` and
`GCDMonoid.lcm`.
Note that the global `IsCoprime` is not a straightforward generalization of `Nat.Coprime`, see
`Nat.isCoprime_iff_coprime` for the connection between the two.
Most of this file could be moved to batteries as well.
-/
assert_not_exists OrderedCommMonoid
namespace Nat
variable {a aâ aâ b bâ bâ c : â}
/-! ### `gcd` -/
theorem gcd_greatest {a b d : â} (hda : d ⣠a) (hdb : d ⣠b) (hd : â e : â, e ⣠a â e ⣠b â e ⣠d) :
d = a.gcd b :=
(dvd_antisymm (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) (dvd_gcd hda hdb)).symm
/-! Lemmas where one argument consists of addition of a multiple of the other -/
@[simp]
theorem pow_sub_one_mod_pow_sub_one (a b c : â) : (a ^ c - 1) % (a ^ b - 1) = a ^ (c % b) - 1 := by
rcases eq_zero_or_pos a with rfl | ha0
· simp [zero_pow_eq]; split_ifs <;> simp
rcases Nat.eq_or_lt_of_le ha0 with rfl | ha1
· simp
rcases eq_zero_or_pos b with rfl | hb0
· simp
rcases lt_or_le c b with h | h
· rw [mod_eq_of_lt, mod_eq_of_lt h]
rwa [Nat.sub_lt_sub_iff_right (one_le_pow c a ha0), Nat.pow_lt_pow_iff_right ha1]
· suffices a ^ (c - b + b) - 1 = a ^ (c - b) * (a ^ b - 1) + (a ^ (c - b) - 1) by
rw [â Nat.sub_add_cancel h, add_mod_right, this, add_mod, mul_mod, mod_self,
mul_zero, zero_mod, zero_add, mod_mod, pow_sub_one_mod_pow_sub_one]
rw [â Nat.add_sub_assoc (one_le_pow (c - b) a ha0), â mul_add_one, pow_add,
Nat.sub_add_cancel (one_le_pow b a ha0)]
@[simp]
theorem pow_sub_one_gcd_pow_sub_one (a b c : â) :
gcd (a ^ b - 1) (a ^ c - 1) = a ^ gcd b c - 1 := by
rcases eq_zero_or_pos b with rfl | hb
· simp
replace hb : c % b < b := mod_lt c hb
rw [gcd_rec, pow_sub_one_mod_pow_sub_one, pow_sub_one_gcd_pow_sub_one, â gcd_rec]
/-! ### `lcm` -/
theorem lcm_dvd_mul (m n : â) : lcm m n ⣠m * n :=
lcm_dvd (dvd_mul_right _ _) (dvd_mul_left _ _)
theorem lcm_dvd_iff {m n k : â} : lcm m n ⣠k â m ⣠k â§ n ⣠k :=
âšfun h => âš(dvd_lcm_left _ _).trans h, (dvd_lcm_right _ _).trans hâ©, and_imp.2 lcm_dvdâ©
theorem lcm_pos {m n : â} : 0 < m â 0 < n â 0 < m.lcm n := by
simp_rw [Nat.pos_iff_ne_zero]
exact lcm_ne_zero
theorem lcm_mul_left {m n k : â} : (m * n).lcm (m * k) = m * n.lcm k := by
apply dvd_antisymm
· exact lcm_dvd (mul_dvd_mul_left m (dvd_lcm_left n k)) (mul_dvd_mul_left m (dvd_lcm_right n k))
· have h : m ⣠lcm (m * n) (m * k) := (dvd_mul_right m n).trans (dvd_lcm_left (m * n) (m * k))
rw [â dvd_div_iff_mul_dvd h, lcm_dvd_iff, dvd_div_iff_mul_dvd h, dvd_div_iff_mul_dvd h,
â lcm_dvd_iff]
theorem lcm_mul_right {m n k : â} : (m * n).lcm (k * n) = m.lcm k * n := by
rw [mul_comm, mul_comm k n, lcm_mul_left, mul_comm]
/-!
### `Coprime`
See also `Nat.coprime_of_dvd` and `Nat.coprime_of_dvd'` to prove `Nat.Coprime m n`.
-/
theorem Coprime.lcm_eq_mul {m n : â} (h : Coprime m n) : lcm m n = m * n := by
rw [â one_mul (lcm m n), â h.gcd_eq_one, gcd_mul_lcm]
theorem Coprime.symmetric : Symmetric Coprime := fun _ _ => Coprime.symm
theorem Coprime.dvd_mul_right {m n k : â} (H : Coprime k n) : k ⣠m * n â k ⣠m :=
âšH.dvd_of_dvd_mul_right, fun h => dvd_mul_of_dvd_left h nâ©
theorem Coprime.dvd_mul_left {m n k : â} (H : Coprime k m) : k ⣠m * n â k ⣠n :=
âšH.dvd_of_dvd_mul_left, fun h => dvd_mul_of_dvd_right h mâ©
@[simp]
theorem coprime_add_self_right {m n : â} : Coprime m (n + m) â Coprime m n := by
rw [Coprime, Coprime, gcd_add_self_right]
@[simp]
theorem coprime_self_add_right {m n : â} : Coprime m (m + n) â Coprime m n := by
rw [add_comm, coprime_add_self_right]
@[simp]
theorem coprime_add_self_left {m n : â} : Coprime (m + n) n â Coprime m n := by
rw [Coprime, Coprime, gcd_add_self_left]
@[simp]
theorem coprime_self_add_left {m n : â} : Coprime (m + n) m â Coprime n m := by
rw [Coprime, Coprime, gcd_self_add_left]
@[simp]
theorem coprime_add_mul_right_right (m n k : â) : Coprime m (n + k * m) â Coprime m n := by
rw [Coprime, Coprime, gcd_add_mul_right_right]
@[simp]
theorem coprime_add_mul_left_right (m n k : â) : Coprime m (n + m * k) â Coprime m n := by
rw [Coprime, Coprime, gcd_add_mul_left_right]
@[simp]
theorem coprime_mul_right_add_right (m n k : â) : Coprime m (k * m + n) â Coprime m n := by
rw [Coprime, Coprime, gcd_mul_right_add_right]
@[simp]
theorem coprime_mul_left_add_right (m n k : â) : Coprime m (m * k + n) â Coprime m n := by
rw [Coprime, Coprime, gcd_mul_left_add_right]
@[simp]
theorem coprime_add_mul_right_left (m n k : â) : Coprime (m + k * n) n â Coprime m n := by
rw [Coprime, Coprime, gcd_add_mul_right_left]
@[simp]
theorem coprime_add_mul_left_left (m n k : â) : Coprime (m + n * k) n â Coprime m n := by
| rw [Coprime, Coprime, gcd_add_mul_left_left]
| Mathlib/Data/Nat/GCD/Basic.lean | 140 | 141 |
/-
Copyright (c) 2022 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Patrick Massot, Yury Kudryashov, Kevin H. Wilson, Heather Macbeth
-/
import Mathlib.Order.Filter.Tendsto
/-!
# Product and coproduct filters
In this file we define `Filter.prod f g` (notation: `f ÃË¢ g`) and `Filter.coprod f g`. The product
of two filters is the largest filter `l` such that `Filter.Tendsto Prod.fst l f` and
`Filter.Tendsto Prod.snd l g`.
## Implementation details
The product filter cannot be defined using the monad structure on filters. For example:
```lean
F := do {x â seq, y â top, return (x, y)}
G := do {y â top, x â seq, return (x, y)}
```
hence:
```lean
s â F â â n, [n..â] Ã univ â s
s â G â â i:â, â n, [n..â] Ã {i} â s
```
Now `â i, [i..â] Ã {i}` is in `G` but not in `F`.
As product filter we want to have `F` as result.
## Notations
* `f ÃË¢ g` : `Filter.prod f g`, localized in `Filter`.
-/
open Set
open Filter
namespace Filter
variable {α β γ Ύ : Type*} {ι : Sort*}
section Prod
variable {s : Set α} {t : Set β} {f : Filter α} {g : Filter β}
theorem prod_mem_prod (hs : s â f) (ht : t â g) : s ÃË¢ t â f ÃË¢ g :=
inter_mem_inf (preimage_mem_comap hs) (preimage_mem_comap ht)
theorem mem_prod_iff {s : Set (α à β)} {f : Filter α} {g : Filter β} :
s â f ÃË¢ g â â tâ â f, â tâ â g, tâ ÃË¢ tâ â s := by
constructor
· rintro âštâ, âšsâ, hsâ, htsââ©, tâ, âšsâ, hsâ, htsââ©, rflâ©
exact âšsâ, hsâ, sâ, hsâ, fun p âšh, h'â© => âšhtsâ h, htsâ h'â©â©
· rintro âštâ, htâ, tâ, htâ, hâ©
exact mem_inf_of_inter (preimage_mem_comap htâ) (preimage_mem_comap htâ) h
@[simp]
theorem compl_diagonal_mem_prod {lâ lâ : Filter α} : (diagonal α)á¶ â lâ ÃË¢ lâ â Disjoint lâ lâ := by
simp only [mem_prod_iff, Filter.disjoint_iff, prod_subset_compl_diagonal_iff_disjoint]
@[simp]
theorem prod_mem_prod_iff [f.NeBot] [g.NeBot] : s ÃË¢ t â f ÃË¢ g â s â f â§ t â g :=
âšfun h =>
let âš_s', hs', _t', ht', Hâ© := mem_prod_iff.1 h
(prod_subset_prod_iff.1 H).elim
(fun âšhs's, ht'tâ© => âšmem_of_superset hs' hs's, mem_of_superset ht' ht'tâ©) fun h =>
h.elim (fun hs'e => absurd hs'e (nonempty_of_mem hs').ne_empty) fun ht'e =>
absurd ht'e (nonempty_of_mem ht').ne_empty,
fun h => prod_mem_prod h.1 h.2â©
theorem mem_prod_principal {s : Set (α à β)} :
s â f ÃË¢ ð t â { a | â b â t, (a, b) â s } â f := by
rw [â @exists_mem_subset_iff _ f, mem_prod_iff]
refine exists_congr fun u => Iff.rfl.and âš?_, fun h => âšt, mem_principal_self t, ?_â©â©
· rintro âšv, v_in, hvâ© a a_in b b_in
exact hv (mk_mem_prod a_in <| v_in b_in)
· rintro âšx, yâ© âšhx, hyâ©
exact h hx y hy
theorem mem_prod_top {s : Set (α à β)} :
s â f ÃË¢ (†: Filter β) â { a | â b, (a, b) â s } â f := by
rw [â principal_univ, mem_prod_principal]
simp only [mem_univ, forall_true_left]
theorem eventually_prod_principal_iff {p : α à β â Prop} {s : Set β} :
(âá¶ x : α à β in f ÃË¢ ð s, p x) â âá¶ x : α in f, â y : β, y â s â p (x, y) := by
rw [eventually_iff, eventually_iff, mem_prod_principal]
simp only [mem_setOf_eq]
theorem comap_prod (f : α â β à γ) (b : Filter β) (c : Filter γ) :
comap f (b ÃË¢ c) = comap (Prod.fst â f) b â comap (Prod.snd â f) c := by
rw [prod_eq_inf, comap_inf, Filter.comap_comap, Filter.comap_comap]
theorem comap_prodMap_prod (f : α â β) (g : γ â ÎŽ) (lb : Filter β) (ld : Filter ÎŽ) :
comap (Prod.map f g) (lb ÃË¢ ld) = comap f lb ÃË¢ comap g ld := by
simp [prod_eq_inf, comap_comap, Function.comp_def]
theorem prod_top : f ÃË¢ (†: Filter β) = f.comap Prod.fst := by
rw [prod_eq_inf, comap_top, inf_top_eq]
theorem top_prod : (†: Filter α) ÃË¢ g = g.comap Prod.snd := by
rw [prod_eq_inf, comap_top, top_inf_eq]
theorem sup_prod (fâ fâ : Filter α) (g : Filter β) : (fâ â fâ) ÃË¢ g = (fâ ÃË¢ g) â (fâ ÃË¢ g) := by
simp only [prod_eq_inf, comap_sup, inf_sup_right]
theorem prod_sup (f : Filter α) (gâ gâ : Filter β) : f ÃË¢ (gâ â gâ) = (f ÃË¢ gâ) â (f ÃË¢ gâ) := by
simp only [prod_eq_inf, comap_sup, inf_sup_left]
theorem eventually_prod_iff {p : α à β â Prop} :
(âá¶ x in f ÃË¢ g, p x) â
â pa : α â Prop, (âá¶ x in f, pa x) â§ â pb : β â Prop, (âá¶ y in g, pb y) â§
â {x}, pa x â â {y}, pb y â p (x, y) := by
simpa only [Set.prod_subset_iff] using @mem_prod_iff α β p f g
theorem tendsto_fst : Tendsto Prod.fst (f ÃË¢ g) f :=
tendsto_inf_left tendsto_comap
theorem tendsto_snd : Tendsto Prod.snd (f ÃË¢ g) g :=
tendsto_inf_right tendsto_comap
/-- If a function tends to a product `g ÃË¢ h` of filters, then its first component tends to
`g`. See also `Filter.Tendsto.fst_nhds` for the special case of converging to a point in a
product of two topological spaces. -/
theorem Tendsto.fst {h : Filter γ} {m : α â β à γ} (H : Tendsto m f (g ÃË¢ h)) :
Tendsto (fun a ⊠(m a).1) f g :=
tendsto_fst.comp H
/-- If a function tends to a product `g ÃË¢ h` of filters, then its second component tends to
`h`. See also `Filter.Tendsto.snd_nhds` for the special case of converging to a point in a
product of two topological spaces. -/
theorem Tendsto.snd {h : Filter γ} {m : α â β à γ} (H : Tendsto m f (g ÃË¢ h)) :
Tendsto (fun a ⊠(m a).2) f h :=
tendsto_snd.comp H
theorem Tendsto.prodMk {h : Filter γ} {mâ : α â β} {mâ : α â γ}
(hâ : Tendsto mâ f g) (hâ : Tendsto mâ f h) : Tendsto (fun x => (mâ x, mâ x)) f (g ÃË¢ h) :=
tendsto_inf.2 âštendsto_comap_iff.2 hâ, tendsto_comap_iff.2 hââ©
@[deprecated (since := "2025-03-10")]
alias Tendsto.prod_mk := Tendsto.prodMk
theorem tendsto_prod_swap : Tendsto (Prod.swap : α à β â β à α) (f ÃË¢ g) (g ÃË¢ f) :=
tendsto_snd.prodMk tendsto_fst
theorem Eventually.prod_inl {la : Filter α} {p : α â Prop} (h : âá¶ x in la, p x) (lb : Filter β) :
âá¶ x in la ÃË¢ lb, p (x : α à β).1 :=
tendsto_fst.eventually h
theorem Eventually.prod_inr {lb : Filter β} {p : β â Prop} (h : âá¶ x in lb, p x) (la : Filter α) :
âá¶ x in la ÃË¢ lb, p (x : α à β).2 :=
tendsto_snd.eventually h
theorem Eventually.prod_mk {la : Filter α} {pa : α â Prop} (ha : âá¶ x in la, pa x) {lb : Filter β}
{pb : β â Prop} (hb : âá¶ y in lb, pb y) : âá¶ p in la ÃË¢ lb, pa (p : α à β).1 â§ pb p.2 :=
(ha.prod_inl lb).and (hb.prod_inr la)
theorem EventuallyEq.prodMap {ÎŽ} {la : Filter α} {fa ga : α â γ} (ha : fa =á¶ [la] ga)
{lb : Filter β} {fb gb : β â ÎŽ} (hb : fb =á¶ [lb] gb) :
Prod.map fa fb =á¶ [la ÃË¢ lb] Prod.map ga gb :=
(Eventually.prod_mk ha hb).mono fun _ h => Prod.ext h.1 h.2
@[deprecated (since := "2025-03-10")]
alias EventuallyEq.prod_map := EventuallyEq.prodMap
theorem EventuallyLE.prodMap {ÎŽ} [LE γ] [LE ÎŽ] {la : Filter α} {fa ga : α â γ} (ha : fa â€á¶ [la] ga)
{lb : Filter β} {fb gb : β â ÎŽ} (hb : fb â€á¶ [lb] gb) :
Prod.map fa fb â€á¶ [la ÃË¢ lb] Prod.map ga gb :=
Eventually.prod_mk ha hb
@[deprecated (since := "2025-03-10")]
alias EventuallyLE.prod_map := EventuallyLE.prodMap
theorem Eventually.curry {la : Filter α} {lb : Filter β} {p : α à β â Prop}
(h : âá¶ x in la ÃË¢ lb, p x) : âá¶ x in la, âá¶ y in lb, p (x, y) := by
rcases eventually_prod_iff.1 h with âšpa, ha, pb, hb, hâ©
exact ha.mono fun a ha => hb.mono fun b hb => h ha hb
protected lemma Frequently.uncurry {la : Filter α} {lb : Filter β} {p : α â β â Prop}
(h : âá¶ x in la, âá¶ y in lb, p x y) : âá¶ xy in la ÃË¢ lb, p xy.1 xy.2 :=
mt (fun h ⊠by simpa only [not_frequently] using h.curry) h
lemma Frequently.of_curry {la : Filter α} {lb : Filter β} {p : α à β â Prop}
(h : âá¶ x in la, âá¶ y in lb, p (x, y)) : âá¶ xy in la ÃË¢ lb, p xy :=
h.uncurry
/-- A fact that is eventually true about all pairs `l ÃË¢ l` is eventually true about
all diagonal pairs `(i, i)` -/
theorem Eventually.diag_of_prod {p : α à α â Prop} (h : âá¶ i in f ÃË¢ f, p i) :
âá¶ i in f, p (i, i) := by
obtain âšt, ht, s, hs, hstâ© := eventually_prod_iff.1 h
apply (ht.and hs).mono fun x hx => hst hx.1 hx.2
theorem Eventually.diag_of_prod_left {f : Filter α} {g : Filter γ} {p : (α à α) à γ â Prop} :
(âá¶ x in (f ÃË¢ f) ÃË¢ g, p x) â âá¶ x : α à γ in f ÃË¢ g, p ((x.1, x.1), x.2) := by
intro h
obtain âšt, ht, s, hs, hstâ© := eventually_prod_iff.1 h
exact (ht.diag_of_prod.prod_mk hs).mono fun x hx => by simp only [hst hx.1 hx.2]
theorem Eventually.diag_of_prod_right {f : Filter α} {g : Filter γ} {p : α à γ à γ â Prop} :
(âá¶ x in f ÃË¢ (g ÃË¢ g), p x) â âá¶ x : α à γ in f ÃË¢ g, p (x.1, x.2, x.2) := by
intro h
obtain âšt, ht, s, hs, hstâ© := eventually_prod_iff.1 h
exact (ht.prod_mk hs.diag_of_prod).mono fun x hx => by simp only [hst hx.1 hx.2]
theorem tendsto_diag : Tendsto (fun i => (i, i)) f (f ÃË¢ f) :=
tendsto_iff_eventually.mpr fun _ hpr => hpr.diag_of_prod
theorem prod_iInf_left [Nonempty ι] {f : ι â Filter α} {g : Filter β} :
(âš
i, f i) ÃË¢ g = âš
i, f i ÃË¢ g := by
simp only [prod_eq_inf, comap_iInf, iInf_inf]
theorem prod_iInf_right [Nonempty ι] {f : Filter α} {g : ι â Filter β} :
(f ÃË¢ âš
i, g i) = âš
i, f ÃË¢ g i := by
simp only [prod_eq_inf, comap_iInf, inf_iInf]
@[mono, gcongr]
theorem prod_mono {fâ fâ : Filter α} {gâ gâ : Filter β} (hf : fâ †fâ) (hg : gâ †gâ) :
fâ ÃË¢ gâ †fâ ÃË¢ gâ :=
inf_le_inf (comap_mono hf) (comap_mono hg)
@[gcongr]
theorem prod_mono_left (g : Filter β) {fâ fâ : Filter α} (hf : fâ †fâ) : fâ ÃË¢ g †fâ ÃË¢ g :=
Filter.prod_mono hf rfl.le
@[gcongr]
theorem prod_mono_right (f : Filter α) {gâ gâ : Filter β} (hf : gâ †gâ) : f ÃË¢ gâ †f ÃË¢ gâ :=
Filter.prod_mono rfl.le hf
theorem prod_comap_comap_eq.{u, v, w, x} {αâ : Type u} {αâ : Type v} {βâ : Type w} {βâ : Type x}
{fâ : Filter αâ} {fâ : Filter αâ} {mâ : βâ â αâ} {mâ : βâ â αâ} :
comap mâ fâ ÃË¢ comap mâ fâ = comap (fun p : βâ à βâ => (mâ p.1, mâ p.2)) (fâ ÃË¢ fâ) := by
simp only [prod_eq_inf, comap_comap, comap_inf, Function.comp_def]
theorem prod_comm' : f ÃË¢ g = comap Prod.swap (g ÃË¢ f) := by
simp only [prod_eq_inf, comap_comap, Function.comp_def, inf_comm, Prod.swap, comap_inf]
theorem prod_comm : f ÃË¢ g = map (fun p : β à α => (p.2, p.1)) (g ÃË¢ f) := by
rw [prod_comm', â map_swap_eq_comap_swap]
rfl
theorem mem_prod_iff_left {s : Set (α à β)} :
s â f ÃË¢ g â â t â f, âá¶ y in g, â x â t, (x, y) â s := by
simp only [mem_prod_iff, prod_subset_iff]
refine exists_congr fun _ => Iff.rfl.and <| Iff.trans ?_ exists_mem_subset_iff
exact exists_congr fun _ => Iff.rfl.and forallâ_swap
theorem mem_prod_iff_right {s : Set (α à β)} :
s â f ÃË¢ g â â t â g, âá¶ x in f, â y â t, (x, y) â s := by
rw [prod_comm, mem_map, mem_prod_iff_left]; rfl
@[simp]
theorem map_fst_prod (f : Filter α) (g : Filter β) [NeBot g] : map Prod.fst (f ÃË¢ g) = f := by
ext s
simp only [mem_map, mem_prod_iff_left, mem_preimage, eventually_const, â subset_def,
exists_mem_subset_iff]
@[simp]
theorem map_snd_prod (f : Filter α) (g : Filter β) [NeBot f] : map Prod.snd (f ÃË¢ g) = g := by
rw [prod_comm, map_map]; apply map_fst_prod
@[simp]
theorem prod_le_prod {fâ fâ : Filter α} {gâ gâ : Filter β} [NeBot fâ] [NeBot gâ] :
fâ ÃË¢ gâ †fâ ÃË¢ gâ â fâ †fâ â§ gâ †gâ :=
âšfun h =>
âšmap_fst_prod fâ gâ âž tendsto_fst.mono_left h, map_snd_prod fâ gâ âž tendsto_snd.mono_left hâ©,
fun h => prod_mono h.1 h.2â©
@[simp]
theorem prod_inj {fâ fâ : Filter α} {gâ gâ : Filter β} [NeBot fâ] [NeBot gâ] :
fâ ÃË¢ gâ = fâ ÃË¢ gâ â fâ = fâ â§ gâ = gâ := by
refine âšfun h => ?_, fun h => h.1 âž h.2 âž rflâ©
have hle : fâ †fâ â§ gâ †gâ := prod_le_prod.1 h.le
haveI := neBot_of_le hle.1; haveI := neBot_of_le hle.2
exact âšhle.1.antisymm <| (prod_le_prod.1 h.ge).1, hle.2.antisymm <| (prod_le_prod.1 h.ge).2â©
theorem eventually_swap_iff {p : α à β â Prop} :
(âá¶ x : α à β in f ÃË¢ g, p x) â âá¶ y : β à α in g ÃË¢ f, p y.swap := by
rw [prod_comm]; rfl
theorem prod_assoc (f : Filter α) (g : Filter β) (h : Filter γ) :
map (Equiv.prodAssoc α β γ) ((f ÃË¢ g) ÃË¢ h) = f ÃË¢ (g ÃË¢ h) := by
simp_rw [â comap_equiv_symm, prod_eq_inf, comap_inf, comap_comap, inf_assoc,
Function.comp_def, Equiv.prodAssoc_symm_apply]
theorem prod_assoc_symm (f : Filter α) (g : Filter β) (h : Filter γ) :
map (Equiv.prodAssoc α β γ).symm (f ÃË¢ (g ÃË¢ h)) = (f ÃË¢ g) ÃË¢ h := by
simp_rw [map_equiv_symm, prod_eq_inf, comap_inf, comap_comap, inf_assoc,
Function.comp_def, Equiv.prodAssoc_apply]
theorem tendsto_prodAssoc {h : Filter γ} :
Tendsto (Equiv.prodAssoc α β γ) ((f ÃË¢ g) ÃË¢ h) (f ÃË¢ (g ÃË¢ h)) :=
(prod_assoc f g h).le
theorem tendsto_prodAssoc_symm {h : Filter γ} :
Tendsto (Equiv.prodAssoc α β γ).symm (f ÃË¢ (g ÃË¢ h)) ((f ÃË¢ g) ÃË¢ h) :=
(prod_assoc_symm f g h).le
/-- A useful lemma when dealing with uniformities. -/
theorem map_swap4_prod {h : Filter γ} {k : Filter Ύ} :
map (fun p : (α à β) à γ à Ύ => ((p.1.1, p.2.1), (p.1.2, p.2.2))) ((f ÃË¢ g) ÃË¢ (h ÃË¢ k)) =
(f ÃË¢ h) ÃË¢ (g ÃË¢ k) := by
simp_rw [map_swap4_eq_comap, prod_eq_inf, comap_inf, comap_comap]; ac_rfl
theorem tendsto_swap4_prod {h : Filter γ} {k : Filter Ύ} :
Tendsto (fun p : (α à β) à γ à Ύ => ((p.1.1, p.2.1), (p.1.2, p.2.2))) ((f ÃË¢ g) ÃË¢ (h ÃË¢ k))
((f ÃË¢ h) ÃË¢ (g ÃË¢ k)) :=
map_swap4_prod.le
theorem prod_map_map_eq.{u, v, w, x} {αâ : Type u} {αâ : Type v} {βâ : Type w} {βâ : Type x}
{fâ : Filter αâ} {fâ : Filter αâ} {mâ : αâ â βâ} {mâ : αâ â βâ} :
map mâ fâ ÃË¢ map mâ fâ = map (fun p : αâ à αâ => (mâ p.1, mâ p.2)) (fâ ÃË¢ fâ) :=
le_antisymm
(fun s hs =>
let âšsâ, hsâ, sâ, hsâ, hâ© := mem_prod_iff.mp hs
mem_of_superset (prod_mem_prod (image_mem_map hsâ) (image_mem_map hsâ)) <|
by rwa [prod_image_image_eq, image_subset_iff])
((tendsto_map.comp tendsto_fst).prodMk (tendsto_map.comp tendsto_snd))
theorem prod_map_map_eq' {αâ : Type*} {αâ : Type*} {βâ : Type*} {βâ : Type*} (f : αâ â αâ)
(g : βâ â βâ) (F : Filter αâ) (G : Filter βâ) :
map f F ÃË¢ map g G = map (Prod.map f g) (F ÃË¢ G) :=
prod_map_map_eq
theorem prod_map_left (f : α â β) (F : Filter α) (G : Filter γ) :
map f F ÃË¢ G = map (Prod.map f id) (F ÃË¢ G) := by
rw [â prod_map_map_eq', map_id]
theorem prod_map_right (f : β â γ) (F : Filter α) (G : Filter β) :
F ÃË¢ map f G = map (Prod.map id f) (F ÃË¢ G) := by
rw [â prod_map_map_eq', map_id]
theorem le_prod_map_fst_snd {f : Filter (α à β)} : f †map Prod.fst f ÃË¢ map Prod.snd f :=
le_inf le_comap_map le_comap_map
theorem Tendsto.prodMap {ÎŽ : Type*} {f : α â γ} {g : β â ÎŽ} {a : Filter α} {b : Filter β}
{c : Filter γ} {d : Filter Ύ} (hf : Tendsto f a c) (hg : Tendsto g b d) :
Tendsto (Prod.map f g) (a ÃË¢ b) (c ÃË¢ d) := by
rw [Tendsto, Prod.map_def, â prod_map_map_eq]
exact Filter.prod_mono hf hg
@[deprecated (since := "2025-03-10")]
alias Tendsto.prod_map := Tendsto.prodMap
protected theorem map_prod (m : α à β â γ) (f : Filter α) (g : Filter β) :
map m (f ÃË¢ g) = (f.map fun a b => m (a, b)).seq g := by
simp only [Filter.ext_iff, mem_map, mem_prod_iff, mem_map_seq_iff, exists_and_left]
intro s
constructor
· exact fun âšt, ht, s, hs, hâ© => âšs, hs, t, ht, fun x hx y hy => @h âšx, yâ© âšhx, hyâ©â©
· exact fun âšs, hs, t, ht, hâ© => âšt, ht, s, hs, fun âšx, yâ© âšhx, hyâ© => h x hx y hyâ©
theorem prod_eq : f ÃË¢ g = (f.map Prod.mk).seq g := f.map_prod id g
theorem prod_inf_prod {fâ fâ : Filter α} {gâ gâ : Filter β} :
(fâ ÃË¢ gâ) â (fâ ÃË¢ gâ) = (fâ â fâ) ÃË¢ (gâ â gâ) := by
simp only [prod_eq_inf, comap_inf, inf_comm, inf_assoc, inf_left_comm]
theorem inf_prod {fâ fâ : Filter α} : (fâ â fâ) ÃË¢ g = (fâ ÃË¢ g) â (fâ ÃË¢ g) := by
rw [prod_inf_prod, inf_idem]
theorem prod_inf {gâ gâ : Filter β} : f ÃË¢ (gâ â gâ) = (f ÃË¢ gâ) â (f ÃË¢ gâ) := by
rw [prod_inf_prod, inf_idem]
@[simp]
theorem prod_principal_principal {s : Set α} {t : Set β} : ð s ÃË¢ ð t = ð (s ÃË¢ t) := by
simp only [prod_eq_inf, comap_principal, principal_eq_iff_eq, comap_principal, inf_principal]; rfl
@[simp]
theorem pure_prod {a : α} {f : Filter β} : pure a ÃË¢ f = map (Prod.mk a) f := by
rw [prod_eq, map_pure, pure_seq_eq_map]
theorem map_pure_prod (f : α â β â γ) (a : α) (B : Filter β) :
map (Function.uncurry f) (pure a ÃË¢ B) = map (f a) B := by
rw [Filter.pure_prod]; rfl
@[simp]
theorem prod_pure {b : β} : f ÃË¢ pure b = map (fun a => (a, b)) f := by
rw [prod_eq, seq_pure, map_map]; rfl
theorem prod_pure_pure {a : α} {b : β} :
(pure a : Filter α) ÃË¢ (pure b : Filter β) = pure (a, b) := by simp
@[simp]
theorem prod_eq_bot : f ÃË¢ g = ⥠â f = ⥠⚠g = ⥠:= by
simp_rw [â empty_mem_iff_bot, mem_prod_iff, subset_empty_iff, prod_eq_empty_iff, â exists_prop,
Subtype.exists', exists_or, exists_const, Subtype.exists, exists_prop, exists_eq_right]
@[simp] theorem prod_bot : f ÃË¢ (⥠: Filter β) = ⥠:= prod_eq_bot.2 <| Or.inr rfl
@[simp] theorem bot_prod : (⥠: Filter α) ÃË¢ g = ⥠:= prod_eq_bot.2 <| Or.inl rfl
theorem prod_neBot : NeBot (f ÃË¢ g) â NeBot f â§ NeBot g := by
simp only [neBot_iff, Ne, prod_eq_bot, not_or]
protected theorem NeBot.prod (hf : NeBot f) (hg : NeBot g) : NeBot (f ÃË¢ g) := prod_neBot.2 âšhf, hgâ©
instance prod.instNeBot [hf : NeBot f] [hg : NeBot g] : NeBot (f ÃË¢ g) := hf.prod hg
@[simp]
lemma disjoint_prod {f' : Filter α} {g' : Filter β} :
Disjoint (f ÃË¢ g) (f' ÃË¢ g') â Disjoint f f' âš Disjoint g g' := by
simp only [disjoint_iff, prod_inf_prod, prod_eq_bot]
/-- `p â§ q` occurs frequently along the product of two filters
iff both `p` and `q` occur frequently along the corresponding filters. -/
theorem frequently_prod_and {p : α â Prop} {q : β â Prop} :
(âá¶ x in f ÃË¢ g, p x.1 â§ q x.2) â (âá¶ a in f, p a) â§ âá¶ b in g, q b := by
simp only [frequently_iff_neBot, â prod_neBot, â prod_inf_prod, prod_principal_principal]
rfl
theorem tendsto_prod_iff {f : α à β â γ} {x : Filter α} {y : Filter β} {z : Filter γ} :
Tendsto f (x ÃË¢ y) z â â W â z, â U â x, â V â y, â x y, x â U â y â V â f (x, y) â W := by
simp only [tendsto_def, mem_prod_iff, prod_sub_preimage_iff, exists_prop]
theorem tendsto_prod_iff' {g' : Filter γ} {s : α â β à γ} :
Tendsto s f (g ÃË¢ g') â Tendsto (fun n => (s n).1) f g â§ Tendsto (fun n => (s n).2) f g' := by
simp only [prod_eq_inf, tendsto_inf, tendsto_comap_iff, Function.comp_def]
theorem le_prod {f : Filter (α à β)} {g : Filter α} {g' : Filter β} :
(f †g ÃË¢ g') â Tendsto Prod.fst f g â§ Tendsto Prod.snd f g' :=
tendsto_prod_iff'
end Prod
/-! ### Coproducts of filters -/
section Coprod
variable {f : Filter α} {g : Filter β}
theorem coprod_eq_prod_top_sup_top_prod (f : Filter α) (g : Filter β) :
Filter.coprod f g = f ÃË¢ †â †ÃË¢ g := by
rw [prod_top, top_prod]
rfl
theorem mem_coprod_iff {s : Set (α à β)} {f : Filter α} {g : Filter β} :
s â f.coprod g â (â tâ â f, Prod.fst â»Â¹' tâ â s) â§ â tâ â g, Prod.snd â»Â¹' tâ â s := by
simp [Filter.coprod]
@[simp]
theorem bot_coprod (l : Filter β) : (⥠: Filter α).coprod l = comap Prod.snd l := by
simp [Filter.coprod]
@[simp]
theorem coprod_bot (l : Filter α) : l.coprod (⥠: Filter β) = comap Prod.fst l := by
simp [Filter.coprod]
theorem bot_coprod_bot : (⥠: Filter α).coprod (⥠: Filter β) = ⥠:= by simp
theorem compl_mem_coprod {s : Set (α à β)} {la : Filter α} {lb : Filter β} :
sá¶ â la.coprod lb â (Prod.fst '' s)á¶ â la â§ (Prod.snd '' s)á¶ â lb := by
simp only [Filter.coprod, mem_sup, compl_mem_comap]
@[mono]
theorem coprod_mono {fâ fâ : Filter α} {gâ gâ : Filter β} (hf : fâ †fâ) (hg : gâ †gâ) :
fâ.coprod gâ †fâ.coprod gâ :=
sup_le_sup (comap_mono hf) (comap_mono hg)
theorem coprod_neBot_iff : (f.coprod g).NeBot â f.NeBot â§ Nonempty β âš Nonempty α â§ g.NeBot := by
simp [Filter.coprod]
@[instance]
theorem coprod_neBot_left [NeBot f] [Nonempty β] : (f.coprod g).NeBot :=
coprod_neBot_iff.2 (Or.inl âšâ¹_âº, â¹_âºâ©)
@[instance]
theorem coprod_neBot_right [NeBot g] [Nonempty α] : (f.coprod g).NeBot :=
coprod_neBot_iff.2 (Or.inr âšâ¹_âº, â¹_âºâ©)
theorem coprod_inf_prod_le (fâ fâ : Filter α) (gâ gâ : Filter β) :
fâ.coprod gâ â fâ ÃË¢ gâ †fâ ÃË¢ gâ â fâ ÃË¢ gâ := calc
fâ.coprod gâ â fâ ÃË¢ gâ
_ = (fâ ÃË¢ †â †ÃË¢ gâ) â fâ ÃË¢ gâ := by rw [coprod_eq_prod_top_sup_top_prod]
_ = fâ ÃË¢ †â fâ ÃË¢ gâ â †ÃË¢ gâ â fâ ÃË¢ gâ := inf_sup_right _ _ _
_ = (fâ â fâ) ÃË¢ gâ â fâ ÃË¢ (gâ â gâ) := by simp [prod_inf_prod]
_ †fâ ÃË¢ gâ â fâ ÃË¢ gâ :=
sup_le_sup (prod_mono inf_le_left le_rfl) (prod_mono le_rfl inf_le_left)
theorem principal_coprod_principal (s : Set α) (t : Set β) :
(ð s).coprod (ð t) = ð (sá¶ ÃË¢ tá¶)á¶ := by
rw [Filter.coprod, comap_principal, comap_principal, sup_principal, Set.prod_eq, compl_inter,
preimage_compl, preimage_compl, compl_compl, compl_compl]
-- this inequality can be strict; see `map_const_principal_coprod_map_id_principal` and
-- `map_prodMap_const_id_principal_coprod_principal` below.
theorem map_prodMap_coprod_le.{u, v, w, x} {αâ : Type u} {αâ : Type v} {βâ : Type w} {βâ : Type x}
{fâ : Filter αâ} {fâ : Filter αâ} {mâ : αâ â βâ} {mâ : αâ â βâ} :
map (Prod.map mâ mâ) (fâ.coprod fâ) †(map mâ fâ).coprod (map mâ fâ) := by
intro s
simp only [mem_map, mem_coprod_iff]
rintro âšâšuâ, huâ, hââ©, uâ, huâ, hââ©
refine âšâšmâ â»Â¹' uâ, huâ, fun _ hx => hâ ?_â©, âšmâ â»Â¹' uâ, huâ, fun _ hx => hâ ?_â©â© <;> convert hx
@[deprecated (since := "2025-03-10")]
alias map_prod_map_coprod_le := map_prodMap_coprod_le
/-- Characterization of the coproduct of the `Filter.map`s of two principal filters `ð {a}` and
`ð {i}`, the first under the constant function `fun a => b` and the second under the identity
function. Together with the next lemma, `map_prodMap_const_id_principal_coprod_principal`, this
provides an example showing that the inequality in the lemma `map_prodMap_coprod_le` can be strict.
-/
theorem map_const_principal_coprod_map_id_principal {α β ι : Type*} (a : α) (b : β) (i : ι) :
(map (fun _ => b) (ð {a})).coprod (map id (ð {i})) =
ð ((({b} : Set β) ÃË¢ univ) ⪠(univ ÃË¢ ({i} : Set ι))) := by
simp only [map_principal, Filter.coprod, comap_principal, sup_principal, image_singleton,
image_id, prod_univ, univ_prod, id]
/-- Characterization of the `Filter.map` of the coproduct of two principal filters `ð {a}` and
`ð {i}`, under the `Prod.map` of two functions, respectively the constant function `fun a => b` and
the identity function. Together with the previous lemma,
`map_const_principal_coprod_map_id_principal`, this provides an example showing that the inequality
in the lemma `map_prodMap_coprod_le` can be strict. -/
theorem map_prodMap_const_id_principal_coprod_principal {α β ι : Type*} (a : α) (b : β) (i : ι) :
map (Prod.map (fun _ : α => b) id) ((ð {a}).coprod (ð {i})) =
ð (({b} : Set β) ÃË¢ (univ : Set ι)) := by
rw [principal_coprod_principal, map_principal]
congr
ext âšb', i'â©
constructor
· rintro âšâša'', i''â©, _, hâ, hââ©
simp
· rintro âšhâ, _â©
use (a, i')
simpa using hâ.symm
@[deprecated (since := "2025-03-10")]
alias map_prod_map_const_id_principal_coprod_principal :=
map_prodMap_const_id_principal_coprod_principal
theorem Tendsto.prodMap_coprod {ÎŽ : Type*} {f : α â γ} {g : β â ÎŽ} {a : Filter α} {b : Filter β}
{c : Filter γ} {d : Filter Ύ} (hf : Tendsto f a c) (hg : Tendsto g b d) :
Tendsto (Prod.map f g) (a.coprod b) (c.coprod d) :=
| map_prodMap_coprod_le.trans (coprod_mono hf hg)
| Mathlib/Order/Filter/Prod.lean | 537 | 538 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.