Context
stringlengths
285
6.98k
file_name
stringlengths
21
79
start
int64
14
184
end
int64
18
184
theorem
stringlengths
25
1.34k
proof
stringlengths
5
3.43k
/- Copyright (c) 2023 Amelia Livingston. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Amelia Livingston -/ import Mathlib.FieldTheory.Fixed import Mathlib.RepresentationTheory.GroupCohomology.LowDegree import Mathlib.LinearAlgebra.LinearIndependent /-! # Hilbert's Theorem 90 Let `L/K` be a finite extension of fields. Then this file proves Noether's generalization of Hilbert's Theorem 90: that the 1st group cohomology $H^1(Aut_K(L), Lˣ)$ is trivial. We state it both in terms of $H^1$ and in terms of cocycles being coboundaries. Hilbert's original statement was that if $L/K$ is Galois, and $Gal(L/K)$ is cyclic, generated by an element `σ`, then for every `x : L` such that $N_{L/K}(x) = 1,$ there exists `y : L` such that $x = y/σ(y).$ This can be deduced from the fact that the function $Gal(L/K) → L^\times$ sending $σ^i \mapsto xσ(x)σ^2(x)...σ^{i-1}(x)$ is a 1-cocycle. Alternatively, we can derive it by analyzing the cohomology of finite cyclic groups in general. Noether's generalization also holds for infinite Galois extensions. ## Main statements * `groupCohomology.isMulOneCoboundary_of_isMulOneCocycle_of_aut_to_units`: Noether's generalization of Hilbert's Theorem 90: for all $f: Aut_K(L) \to L^\times$ satisfying the 1-cocycle condition, there exists `β : Lˣ` such that $g(β)/β = f(g)$ for all `g : Aut_K(L)`. * `groupCohomology.H1ofAutOnUnitsUnique`: Noether's generalization of Hilbert's Theorem 90: $H^1(Aut_K(L), L^\times)$ is trivial. ## Implementation notes Given a commutative ring `k` and a group `G`, group cohomology is developed in terms of `k`-linear `G`-representations on `k`-modules. Therefore stating Noether's generalization of Hilbert 90 in terms of `H¹` requires us to turn the natural action of `Aut_K(L)` on `Lˣ` into a morphism `Aut_K(L) →* (Additive Lˣ →ₗ[ℤ] Additive Lˣ)`. Thus we provide the non-`H¹` version too, as its statement is clearer. ## TODO * The original Hilbert's Theorem 90, deduced from the cohomology of general finite cyclic groups. * Develop Galois cohomology to extend Noether's result to infinite Galois extensions. * "Additive Hilbert 90": let `L/K` be a finite Galois extension. Then $H^n(Gal(L/K), L)$ is trivial for all $1 ≤ n.$ -/ namespace groupCohomology namespace Hilbert90 variable {K L : Type*} [Field K] [Field L] [Algebra K L] [FiniteDimensional K L] /-- Given `f : Aut_K(L) → Lˣ`, the sum `∑ f(φ) • φ` for `φ ∈ Aut_K(L)`, as a function `L → L`. -/ noncomputable def aux (f : (L ≃ₐ[K] L) → Lˣ) : L → L := Finsupp.total (L ≃ₐ[K] L) (L → L) L (fun φ => φ) (Finsupp.equivFunOnFinite.symm (fun φ => (f φ : L))) theorem aux_ne_zero (f : (L ≃ₐ[K] L) → Lˣ) : aux f ≠ 0 := /- the set `Aut_K(L)` is linearly independent in the `L`-vector space `L → L`, by Dedekind's linear independence of characters -/ have : LinearIndependent L (fun (f : L ≃ₐ[K] L) => (f : L → L)) := LinearIndependent.comp (ι' := L ≃ₐ[K] L) (linearIndependent_monoidHom L L) (fun f => f) (fun x y h => by ext; exact DFunLike.ext_iff.1 h _) have h := linearIndependent_iff.1 this (Finsupp.equivFunOnFinite.symm (fun φ => (f φ : L))) fun H => Units.ne_zero (f 1) (DFunLike.ext_iff.1 (h H) 1) end Hilbert90 section open Hilbert90 variable {K L : Type*} [Field K] [Field L] [Algebra K L] [FiniteDimensional K L] /-- Noether's generalization of Hilbert's Theorem 90: given a finite extension of fields and a function `f : Aut_K(L) → Lˣ` satisfying `f(gh) = g(f(h)) * f(g)` for all `g, h : Aut_K(L)`, there exists `β : Lˣ` such that `g(β)/β = f(g)` for all `g : Aut_K(L).` -/
Mathlib/RepresentationTheory/GroupCohomology/Hilbert90.lean
80
96
theorem isMulOneCoboundary_of_isMulOneCocycle_of_aut_to_units (f : (L ≃ₐ[K] L) → Lˣ) (hf : IsMulOneCocycle f) : IsMulOneCoboundary f := by
/- Let `z : L` be such that `∑ f(h) * h(z) ≠ 0`, for `h ∈ Aut_K(L)` -/ obtain ⟨z, hz⟩ : ∃ z, aux f z ≠ 0 := not_forall.1 (fun H => aux_ne_zero f <| funext <| fun x => H x) have : aux f z = ∑ h, f h * h z := by simp [aux, Finsupp.total, Finsupp.sum_fintype] /- Let `β = (∑ f(h) * h(z))⁻¹.` -/ use (Units.mk0 (aux f z) hz)⁻¹ intro g /- Then the equality follows from the hypothesis that `f` is a 1-cocycle. -/ simp only [IsMulOneCocycle, IsMulOneCoboundary, AlgEquiv.smul_units_def, map_inv, div_inv_eq_mul, inv_mul_eq_iff_eq_mul, Units.ext_iff, this, Units.val_mul, Units.coe_map, Units.val_mk0, MonoidHom.coe_coe] at hf ⊢ simp_rw [map_sum, map_mul, Finset.sum_mul, mul_assoc, mul_comm _ (f _ : L), ← mul_assoc, ← hf g] exact eq_comm.1 (Fintype.sum_bijective (fun i => g * i) (Group.mulLeft_bijective g) _ _ (fun i => rfl))
/- Copyright (c) 2024 Mitchell Lee. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mitchell Lee -/ import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity /-! # Reflections, inversions, and inversion sequences Throughout this file, `B` is a type and `M : CoxeterMatrix B` is a Coxeter matrix. `cs : CoxeterSystem M W` is a Coxeter system; that is, `W` is a group, and `cs` holds the data of a group isomorphism `W ≃* M.group`, where `M.group` refers to the quotient of the free group on `B` by the Coxeter relations given by the matrix `M`. See `Mathlib/GroupTheory/Coxeter/Basic.lean` for more details. We define a *reflection* (`CoxeterSystem.IsReflection`) to be an element of the form $t = u s_i u^{-1}$, where $u \in W$ and $s_i$ is a simple reflection. We say that a reflection $t$ is a *left inversion* (`CoxeterSystem.IsLeftInversion`) of an element $w \in W$ if $\ell(t w) < \ell(w)$, and we say it is a *right inversion* (`CoxeterSystem.IsRightInversion`) of $w$ if $\ell(w t) > \ell(w)$. Here $\ell$ is the length function (see `Mathlib/GroupTheory/Coxeter/Length.lean`). Given a word, we define its *left inversion sequence* (`CoxeterSystem.leftInvSeq`) and its *right inversion sequence* (`CoxeterSystem.rightInvSeq`). We prove that if a word is reduced, then both of its inversion sequences contain no duplicates. In fact, the right (respectively, left) inversion sequence of a reduced word for $w$ consists of all of the right (respectively, left) inversions of $w$ in some order, but we do not prove that in this file. ## Main definitions * `CoxeterSystem.IsReflection` * `CoxeterSystem.IsLeftInversion` * `CoxeterSystem.IsRightInversion` * `CoxeterSystem.leftInvSeq` * `CoxeterSystem.rightInvSeq` ## References * [A. Björner and F. Brenti, *Combinatorics of Coxeter Groups*](bjorner2005) -/ namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length /-- `t : W` is a *reflection* of the Coxeter system `cs` if it is of the form $w s_i w^{-1}$, where $w \in W$ and $s_i$ is a simple reflection. -/ def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t) theorem pow_two : t ^ 2 = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem mul_self : t * t = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem inv : t⁻¹ = t := by rcases ht with ⟨w, i, rfl⟩ simp [mul_assoc] theorem isReflection_inv : cs.IsReflection t⁻¹ := by rwa [ht.inv] theorem odd_length : Odd (ℓ t) := by suffices cs.lengthParity t = Multiplicative.ofAdd 1 by simpa [lengthParity_eq_ofAdd_length, ZMod.eq_one_iff_odd] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple]
Mathlib/GroupTheory/Coxeter/Inversion.lean
88
93
theorem length_mul_left_ne (w : W) : ℓ (w * t) ≠ ℓ w := by
suffices cs.lengthParity (w * t) ≠ cs.lengthParity w by contrapose! this simp only [lengthParity_eq_ofAdd_length, this] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple]
/- 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.LinearAlgebra.ExteriorAlgebra.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.exterior_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" /-! # Results about the grading structure of the exterior algebra Many of these results are copied with minimal modification from the tensor algebra. The main result is `ExteriorAlgebra.gradedAlgebra`, which says that the exterior algebra is a ℕ-graded algebra. -/ namespace ExteriorAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable (R M) open scoped DirectSum /-- A version of `ExteriorAlgebra.ι` that maps directly into the graded structure. This is primarily an auxiliary construction used to provide `ExteriorAlgebra.gradedAlgebra`. -/ -- Porting note: protected protected def GradedAlgebra.ι : M →ₗ[R] ⨁ i : ℕ, ⋀[R]^i M := DirectSum.lof R ℕ (fun i => ⋀[R]^i M) 1 ∘ₗ (ι R).codRestrict _ fun m => by simpa only [pow_one] using LinearMap.mem_range_self _ m #align exterior_algebra.graded_algebra.ι ExteriorAlgebra.GradedAlgebra.ι theorem GradedAlgebra.ι_apply (m : M) : GradedAlgebra.ι R M m = DirectSum.of (fun i : ℕ => ⋀[R]^i M) 1 ⟨ι R m, by simpa only [pow_one] using LinearMap.mem_range_self _ m⟩ := rfl #align exterior_algebra.graded_algebra.ι_apply ExteriorAlgebra.GradedAlgebra.ι_apply -- Defining this instance manually, because Lean doesn't seem to be able to synthesize it. -- Strangely, this problem only appears when we use the abbreviation or notation for the -- exterior powers. instance : SetLike.GradedMonoid fun i : ℕ ↦ ⋀[R]^i M := Submodule.nat_power_gradedMonoid (LinearMap.range (ι R : M →ₗ[R] ExteriorAlgebra R M)) -- Porting note: Lean needs to be reminded of this instance otherwise it cannot -- synthesize 0 in the next theorem attribute [local instance 1100] MulZeroClass.toZero in theorem GradedAlgebra.ι_sq_zero (m : M) : GradedAlgebra.ι R M m * GradedAlgebra.ι R M m = 0 := by rw [GradedAlgebra.ι_apply, DirectSum.of_mul_of] exact DFinsupp.single_eq_zero.mpr (Subtype.ext <| ExteriorAlgebra.ι_sq_zero _) #align exterior_algebra.graded_algebra.ι_sq_zero ExteriorAlgebra.GradedAlgebra.ι_sq_zero /-- `ExteriorAlgebra.GradedAlgebra.ι` lifted to exterior algebra. This is primarily an auxiliary construction used to provide `ExteriorAlgebra.gradedAlgebra`. -/ def GradedAlgebra.liftι : ExteriorAlgebra R M →ₐ[R] ⨁ i : ℕ, ⋀[R]^i M := lift R ⟨by apply GradedAlgebra.ι R M, GradedAlgebra.ι_sq_zero R M⟩ #align exterior_algebra.graded_algebra.lift_ι ExteriorAlgebra.GradedAlgebra.liftι
Mathlib/LinearAlgebra/ExteriorAlgebra/Grading.lean
64
80
theorem GradedAlgebra.liftι_eq (i : ℕ) (x : ⋀[R]^i M) : GradedAlgebra.liftι R M x = DirectSum.of (fun i => ⋀[R]^i M) i x := by
cases' x with x hx dsimp only [Subtype.coe_mk, DirectSum.lof_eq_of] -- Porting note: original statement was -- refine Submodule.pow_induction_on_left' _ (fun r => ?_) (fun x y i hx hy ihx ihy => ?_) -- (fun m hm i x hx ih => ?_) hx -- but it created invalid goals induction hx using Submodule.pow_induction_on_left' with | algebraMap => simp_rw [AlgHom.commutes, DirectSum.algebraMap_apply]; rfl -- FIXME: specialized `map_add` to avoid a (whole-declaration) timeout | add _ _ _ _ _ ihx ihy => simp_rw [AlgHom.map_add, ihx, ihy, ← AddMonoidHom.map_add]; rfl | mem_mul _ hm _ _ _ ih => obtain ⟨_, rfl⟩ := hm simp_rw [AlgHom.map_mul, ih, GradedAlgebra.liftι, lift_ι_apply, GradedAlgebra.ι_apply R M, DirectSum.of_mul_of] exact DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext (add_comm _ _) rfl)
/- Copyright (c) 2021 Justus Springer. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Justus Springer, Andrew Yang -/ import Mathlib.Algebra.Category.Ring.FilteredColimits import Mathlib.Geometry.RingedSpace.SheafedSpace import Mathlib.Topology.Sheaves.Stalks import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.Algebra.Category.Ring.Limits #align_import algebraic_geometry.ringed_space from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Ringed spaces We introduce the category of ringed spaces, as an alias for `SheafedSpace CommRingCat`. The facts collected in this file are typically stated for locally ringed spaces, but never actually make use of the locality of stalks. See for instance <https://stacks.math.columbia.edu/tag/01HZ>. -/ universe v u open CategoryTheory open TopologicalSpace open Opposite open TopCat open TopCat.Presheaf namespace AlgebraicGeometry /-- The type of Ringed spaces, as an abbreviation for `SheafedSpace CommRingCat`. -/ abbrev RingedSpace : TypeMax.{u+1, v+1} := SheafedSpace.{_, v, u} CommRingCat.{v} set_option linter.uppercaseLean3 false in #align algebraic_geometry.RingedSpace AlgebraicGeometry.RingedSpace namespace RingedSpace open SheafedSpace variable (X : RingedSpace) -- Porting note (#10670): this was not necessary in mathlib3 instance : CoeSort RingedSpace Type* where coe X := X.carrier /-- If the germ of a section `f` is a unit in the stalk at `x`, then `f` must be a unit on some small neighborhood around `x`. -/
Mathlib/Geometry/RingedSpace/Basic.lean
58
79
theorem isUnit_res_of_isUnit_germ (U : Opens X) (f : X.presheaf.obj (op U)) (x : U) (h : IsUnit (X.presheaf.germ x f)) : ∃ (V : Opens X) (i : V ⟶ U) (_ : x.1 ∈ V), IsUnit (X.presheaf.map i.op f) := by
obtain ⟨g', heq⟩ := h.exists_right_inv obtain ⟨V, hxV, g, rfl⟩ := X.presheaf.germ_exist x.1 g' let W := U ⊓ V have hxW : x.1 ∈ W := ⟨x.2, hxV⟩ -- Porting note: `erw` can't write into `HEq`, so this is replaced with another `HEq` in the -- desired form replace heq : (X.presheaf.germ ⟨x.val, hxW⟩) ((X.presheaf.map (U.infLELeft V).op) f * (X.presheaf.map (U.infLERight V).op) g) = (X.presheaf.germ ⟨x.val, hxW⟩) 1 := by dsimp [germ] erw [map_mul, map_one, show X.presheaf.germ ⟨x, hxW⟩ ((X.presheaf.map (U.infLELeft V).op) f) = X.presheaf.germ x f from X.presheaf.germ_res_apply (Opens.infLELeft U V) ⟨x.1, hxW⟩ f, show X.presheaf.germ ⟨x, hxW⟩ (X.presheaf.map (U.infLERight V).op g) = X.presheaf.germ ⟨x, hxV⟩ g from X.presheaf.germ_res_apply (Opens.infLERight U V) ⟨x.1, hxW⟩ g] exact heq obtain ⟨W', hxW', i₁, i₂, heq'⟩ := X.presheaf.germ_eq x.1 hxW hxW _ _ heq use W', i₁ ≫ Opens.infLELeft U V, hxW' rw [(X.presheaf.map i₂.op).map_one, (X.presheaf.map i₁.op).map_mul] at heq' rw [← comp_apply, ← X.presheaf.map_comp, ← comp_apply, ← X.presheaf.map_comp, ← op_comp] at heq' exact isUnit_of_mul_eq_one _ _ heq'
/- Copyright (c) 2024 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.Algebra.Module.Submodule.Ker /-! # Iterate maps and comaps of submodules Some preliminary work for establishing the strong rank condition for noetherian rings. Given two linear maps `f i : N →ₗ[R] M` and a submodule `K : Submodule R N`, we can define `LinearMap.iterateMapComap f i n K : Submodule R N` to be `f⁻¹(i(⋯(f⁻¹(i(K)))))` (`n` times). If `f(K) ≤ i(K)`, then this sequence is non-decreasing (`LinearMap.iterateMapComap_le_succ`). On the other hand, if `f` is surjective, `i` is injective, and there exists some `m` such that `LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`, then for any `n`, `LinearMap.iterateMapComap f i n K = LinearMap.iterateMapComap f i (n + 1) K`. In particular, by taking `n = 0`, the kernel of `f` is contained in `K` (`LinearMap.ker_le_of_iterateMapComap_eq_succ`), which is a consequence of `LinearMap.ker_le_comap`. As a special case, if one can take `K` to be zero, then `f` is injective. This is the key result for establishing the strong rank condition for noetherian rings. The construction here is adapted from the proof in Djoković's paper *Epimorphisms of modules which must be isomorphisms* [djokovic1973]. -/ open Function Submodule namespace LinearMap variable {R N M : Type*} [Semiring R] [AddCommMonoid N] [Module R N] [AddCommMonoid M] [Module R M] (f i : N →ₗ[R] M) /-- The `LinearMap.iterateMapComap f i n K : Submodule R N` is `f⁻¹(i(⋯(f⁻¹(i(K)))))` (`n` times). -/ def iterateMapComap (n : ℕ) := (fun K : Submodule R N ↦ (K.map i).comap f)^[n] /-- If `f(K) ≤ i(K)`, then `LinearMap.iterateMapComap` is not decreasing. -/ theorem iterateMapComap_le_succ (K : Submodule R N) (h : K.map f ≤ K.map i) (n : ℕ) : f.iterateMapComap i n K ≤ f.iterateMapComap i (n + 1) K := by nth_rw 2 [iterateMapComap] rw [iterate_succ', Function.comp_apply, ← iterateMapComap, ← map_le_iff_le_comap] induction n with | zero => exact h | succ n ih => simp_rw [iterateMapComap, iterate_succ', Function.comp_apply] calc _ ≤ (f.iterateMapComap i n K).map i := map_comap_le _ _ _ ≤ (((f.iterateMapComap i n K).map f).comap f).map i := map_mono (le_comap_map _ _) _ ≤ _ := map_mono (comap_mono ih) /-- If `f` is surjective, `i` is injective, and there exists some `m` such that `LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`, then for any `n`, `LinearMap.iterateMapComap f i n K = LinearMap.iterateMapComap f i (n + 1) K`. In particular, by taking `n = 0`, the kernel of `f` is contained in `K` (`LinearMap.ker_le_of_iterateMapComap_eq_succ`), which is a consequence of `LinearMap.ker_le_comap`. -/
Mathlib/Algebra/Module/Submodule/IterateMapComap.lean
65
79
theorem iterateMapComap_eq_succ (K : Submodule R N) (m : ℕ) (heq : f.iterateMapComap i m K = f.iterateMapComap i (m + 1) K) (hf : Surjective f) (hi : Injective i) (n : ℕ) : f.iterateMapComap i n K = f.iterateMapComap i (n + 1) K := by
induction n with | zero => contrapose! heq induction m with | zero => exact heq | succ m ih => rw [iterateMapComap, iterateMapComap, iterate_succ', iterate_succ'] exact fun H ↦ ih (map_injective_of_injective hi (comap_injective_of_surjective hf H)) | succ n ih => rw [iterateMapComap, iterateMapComap, iterate_succ', iterate_succ', Function.comp_apply, Function.comp_apply, ← iterateMapComap, ← iterateMapComap, ih]
/- Copyright (c) 2019 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot -/ import Mathlib.Topology.UniformSpace.UniformEmbedding import Mathlib.Topology.UniformSpace.Equiv #align_import topology.uniform_space.abstract_completion from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Abstract theory of Hausdorff completions of uniform spaces This file characterizes Hausdorff completions of a uniform space α as complete Hausdorff spaces equipped with a map from α which has dense image and induce the original uniform structure on α. Assuming these properties we "extend" uniformly continuous maps from α to complete Hausdorff spaces to the completions of α. This is the universal property expected from a completion. It is then used to extend uniformly continuous maps from α to α' to maps between completions of α and α'. This file does not construct any such completion, it only study consequences of their existence. The first advantage is that formal properties are clearly highlighted without interference from construction details. The second advantage is that this framework can then be used to compare different completion constructions. See `Topology/UniformSpace/CompareReals` for an example. Of course the comparison comes from the universal property as usual. A general explicit construction of completions is done in `UniformSpace/Completion`, leading to a functor from uniform spaces to complete Hausdorff uniform spaces that is left adjoint to the inclusion, see `UniformSpace/UniformSpaceCat` for the category packaging. ## Implementation notes A tiny technical advantage of using a characteristic predicate such as the properties listed in `AbstractCompletion` instead of stating the universal property is that the universal property derived from the predicate is more universe polymorphic. ## References We don't know any traditional text discussing this. Real world mathematics simply silently identify the results of any two constructions that lead to something one could reasonably call a completion. ## Tags uniform spaces, completion, universal property -/ noncomputable section attribute [local instance] Classical.propDecidable open Filter Set Function universe u /-- A completion of `α` is the data of a complete separated uniform space (from the same universe) and a map from `α` with dense range and inducing the original uniform structure on `α`. -/ structure AbstractCompletion (α : Type u) [UniformSpace α] where /-- The underlying space of the completion. -/ space : Type u /-- A map from a space to its completion. -/ coe : α → space /-- The completion carries a uniform structure. -/ uniformStruct : UniformSpace space /-- The completion is complete. -/ complete : CompleteSpace space /-- The completion is a T₀ space. -/ separation : T0Space space /-- The map into the completion is uniform-inducing. -/ uniformInducing : UniformInducing coe /-- The map into the completion has dense range. -/ dense : DenseRange coe #align abstract_completion AbstractCompletion attribute [local instance] AbstractCompletion.uniformStruct AbstractCompletion.complete AbstractCompletion.separation namespace AbstractCompletion variable {α : Type*} [UniformSpace α] (pkg : AbstractCompletion α) local notation "hatα" => pkg.space local notation "ι" => pkg.coe /-- If `α` is complete, then it is an abstract completion of itself. -/ def ofComplete [T0Space α] [CompleteSpace α] : AbstractCompletion α := mk α id inferInstance inferInstance inferInstance uniformInducing_id denseRange_id #align abstract_completion.of_complete AbstractCompletion.ofComplete theorem closure_range : closure (range ι) = univ := pkg.dense.closure_range #align abstract_completion.closure_range AbstractCompletion.closure_range theorem denseInducing : DenseInducing ι := ⟨pkg.uniformInducing.inducing, pkg.dense⟩ #align abstract_completion.dense_inducing AbstractCompletion.denseInducing theorem uniformContinuous_coe : UniformContinuous ι := UniformInducing.uniformContinuous pkg.uniformInducing #align abstract_completion.uniform_continuous_coe AbstractCompletion.uniformContinuous_coe theorem continuous_coe : Continuous ι := pkg.uniformContinuous_coe.continuous #align abstract_completion.continuous_coe AbstractCompletion.continuous_coe @[elab_as_elim] theorem induction_on {p : hatα → Prop} (a : hatα) (hp : IsClosed { a | p a }) (ih : ∀ a, p (ι a)) : p a := isClosed_property pkg.dense hp ih a #align abstract_completion.induction_on AbstractCompletion.induction_on variable {β : Type*} protected theorem funext [TopologicalSpace β] [T2Space β] {f g : hatα → β} (hf : Continuous f) (hg : Continuous g) (h : ∀ a, f (ι a) = g (ι a)) : f = g := funext fun a => pkg.induction_on a (isClosed_eq hf hg) h #align abstract_completion.funext AbstractCompletion.funext variable [UniformSpace β] section Extend /-- Extension of maps to completions -/ protected def extend (f : α → β) : hatα → β := if UniformContinuous f then pkg.denseInducing.extend f else fun x => f (pkg.dense.some x) #align abstract_completion.extend AbstractCompletion.extend variable {f : α → β} theorem extend_def (hf : UniformContinuous f) : pkg.extend f = pkg.denseInducing.extend f := if_pos hf #align abstract_completion.extend_def AbstractCompletion.extend_def theorem extend_coe [T2Space β] (hf : UniformContinuous f) (a : α) : (pkg.extend f) (ι a) = f a := by rw [pkg.extend_def hf] exact pkg.denseInducing.extend_eq hf.continuous a #align abstract_completion.extend_coe AbstractCompletion.extend_coe variable [CompleteSpace β] theorem uniformContinuous_extend : UniformContinuous (pkg.extend f) := by by_cases hf : UniformContinuous f · rw [pkg.extend_def hf] exact uniformContinuous_uniformly_extend pkg.uniformInducing pkg.dense hf · change UniformContinuous (ite _ _ _) rw [if_neg hf] exact uniformContinuous_of_const fun a b => by congr 1 #align abstract_completion.uniform_continuous_extend AbstractCompletion.uniformContinuous_extend theorem continuous_extend : Continuous (pkg.extend f) := pkg.uniformContinuous_extend.continuous #align abstract_completion.continuous_extend AbstractCompletion.continuous_extend variable [T0Space β]
Mathlib/Topology/UniformSpace/AbstractCompletion.lean
158
161
theorem extend_unique (hf : UniformContinuous f) {g : hatα → β} (hg : UniformContinuous g) (h : ∀ a : α, f a = g (ι a)) : pkg.extend f = g := by
apply pkg.funext pkg.continuous_extend hg.continuous simpa only [pkg.extend_coe hf] using h
/- Copyright (c) 2022 Yuyang Zhao. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuyang Zhao -/ import Mathlib.Algebra.Order.Floor import Mathlib.Data.Nat.Prime /-! # Existence of a sufficiently large prime for which `a * c ^ p / (p - 1)! < 1` This is a technical result used in the proof of the Lindemann-Weierstrass theorem. -/ namespace FloorRing open scoped Nat variable {K : Type*} theorem exists_prime_mul_pow_lt_factorial [LinearOrderedRing K] [FloorRing K] (n : ℕ) (a c : K) : ∃ p > n, p.Prime ∧ a * c ^ p < (p - 1)! := by obtain ⟨p, pn, pp, h⟩ := n.exists_prime_mul_pow_lt_factorial ⌈|a|⌉.natAbs ⌈|c|⌉.natAbs use p, pn, pp calc a * c ^ p _ ≤ |a * c ^ p| := le_abs_self _ _ ≤ ⌈|a|⌉ * (⌈|c|⌉ : K) ^ p := ?_ _ = ↑(Int.natAbs ⌈|a|⌉ * Int.natAbs ⌈|c|⌉ ^ p) := ?_ _ < ↑(p - 1)! := Nat.cast_lt.mpr h · rw [abs_mul, abs_pow] gcongr <;> try first | positivity | apply Int.le_ceil · simp_rw [Nat.cast_mul, Nat.cast_pow, Int.cast_natAbs, abs_eq_self.mpr (Int.ceil_nonneg (abs_nonneg (_ : K)))]
Mathlib/Algebra/Order/Floor/Prime.lean
36
40
theorem exists_prime_mul_pow_div_factorial_lt_one [LinearOrderedField K] [FloorRing K] (n : ℕ) (a c : K) : ∃ p > n, p.Prime ∧ a * c ^ p / (p - 1)! < 1 := by
simp_rw [div_lt_one (α := K) (Nat.cast_pos.mpr (Nat.factorial_pos _))] exact exists_prime_mul_pow_lt_factorial ..
/- Copyright (c) 2020 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.List.Basic /-! # Properties of `List.reduceOption` In this file we prove basic lemmas about `List.reduceOption`. -/ namespace List variable {α β : Type*} @[simp] theorem reduceOption_cons_of_some (x : α) (l : List (Option α)) : reduceOption (some x :: l) = x :: l.reduceOption := by simp only [reduceOption, filterMap, id, eq_self_iff_true, and_self_iff] #align list.reduce_option_cons_of_some List.reduceOption_cons_of_some @[simp] theorem reduceOption_cons_of_none (l : List (Option α)) : reduceOption (none :: l) = l.reduceOption := by simp only [reduceOption, filterMap, id] #align list.reduce_option_cons_of_none List.reduceOption_cons_of_none @[simp] theorem reduceOption_nil : @reduceOption α [] = [] := rfl #align list.reduce_option_nil List.reduceOption_nil @[simp] theorem reduceOption_map {l : List (Option α)} {f : α → β} : reduceOption (map (Option.map f) l) = map f (reduceOption l) := by induction' l with hd tl hl · simp only [reduceOption_nil, map_nil] · cases hd <;> simpa [true_and_iff, Option.map_some', map, eq_self_iff_true, reduceOption_cons_of_some] using hl #align list.reduce_option_map List.reduceOption_map theorem reduceOption_append (l l' : List (Option α)) : (l ++ l').reduceOption = l.reduceOption ++ l'.reduceOption := filterMap_append l l' id #align list.reduce_option_append List.reduceOption_append theorem reduceOption_length_eq {l : List (Option α)} : l.reduceOption.length = (l.filter Option.isSome).length := by induction' l with hd tl hl · simp_rw [reduceOption_nil, filter_nil, length] · cases hd <;> simp [hl] theorem length_eq_reduceOption_length_add_filter_none {l : List (Option α)} : l.length = l.reduceOption.length + (l.filter Option.isNone).length := by simp_rw [reduceOption_length_eq, l.length_eq_length_filter_add Option.isSome, Option.bnot_isSome]
Mathlib/Data/List/ReduceOption.lean
59
61
theorem reduceOption_length_le (l : List (Option α)) : l.reduceOption.length ≤ l.length := by
rw [length_eq_reduceOption_length_add_filter_none] apply Nat.le_add_right
/- Copyright (c) 2020 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Matrix import Mathlib.LinearAlgebra.Matrix.SesquilinearForm import Mathlib.Tactic.NoncommRing #align_import algebra.lie.skew_adjoint from "leanprover-community/mathlib"@"075b3f7d19b9da85a0b54b3e33055a74fc388dec" /-! # Lie algebras of skew-adjoint endomorphisms of a bilinear form When a module carries a bilinear form, the Lie algebra of endomorphisms of the module contains a distinguished Lie subalgebra: the skew-adjoint endomorphisms. Such subalgebras are important because they provide a simple, explicit construction of the so-called classical Lie algebras. This file defines the Lie subalgebra of skew-adjoint endomorphisms cut out by a bilinear form on a module and proves some basic related results. It also provides the corresponding definitions and results for the Lie algebra of square matrices. ## Main definitions * `skewAdjointLieSubalgebra` * `skewAdjointLieSubalgebraEquiv` * `skewAdjointMatricesLieSubalgebra` * `skewAdjointMatricesLieSubalgebraEquiv` ## Tags lie algebra, skew-adjoint, bilinear form -/ universe u v w w₁ section SkewAdjointEndomorphisms open LinearMap (BilinForm) variable {R : Type u} {M : Type v} [CommRing R] [AddCommGroup M] [Module R M] variable (B : BilinForm R M) -- Porting note: Changed `(f g)` to `{f g}` for convenience in `skewAdjointLieSubalgebra` theorem LinearMap.BilinForm.isSkewAdjoint_bracket {f g : Module.End R M} (hf : f ∈ B.skewAdjointSubmodule) (hg : g ∈ B.skewAdjointSubmodule) : ⁅f, g⁆ ∈ B.skewAdjointSubmodule := by rw [mem_skewAdjointSubmodule] at * have hfg : IsAdjointPair B B (f * g) (g * f) := by rw [← neg_mul_neg g f]; exact hf.mul hg have hgf : IsAdjointPair B B (g * f) (f * g) := by rw [← neg_mul_neg f g]; exact hg.mul hf change IsAdjointPair B B (f * g - g * f) (-(f * g - g * f)); rw [neg_sub] exact hfg.sub hgf #align bilin_form.is_skew_adjoint_bracket LinearMap.BilinForm.isSkewAdjoint_bracket /-- Given an `R`-module `M`, equipped with a bilinear form, the skew-adjoint endomorphisms form a Lie subalgebra of the Lie algebra of endomorphisms. -/ def skewAdjointLieSubalgebra : LieSubalgebra R (Module.End R M) := { B.skewAdjointSubmodule with lie_mem' := B.isSkewAdjoint_bracket } #align skew_adjoint_lie_subalgebra skewAdjointLieSubalgebra variable {N : Type w} [AddCommGroup N] [Module R N] (e : N ≃ₗ[R] M) /-- An equivalence of modules with bilinear forms gives equivalence of Lie algebras of skew-adjoint endomorphisms. -/ def skewAdjointLieSubalgebraEquiv : skewAdjointLieSubalgebra (B.compl₁₂ (↑e : N →ₗ[R] M) ↑e) ≃ₗ⁅R⁆ skewAdjointLieSubalgebra B := by apply LieEquiv.ofSubalgebras _ _ e.lieConj ext f simp only [LieSubalgebra.mem_coe, Submodule.mem_map_equiv, LieSubalgebra.mem_map_submodule, LinearEquiv.coe_coe] exact (LinearMap.isPairSelfAdjoint_equiv (B := -B) (F := B) e f).symm #align skew_adjoint_lie_subalgebra_equiv skewAdjointLieSubalgebraEquiv @[simp] theorem skewAdjointLieSubalgebraEquiv_apply (f : skewAdjointLieSubalgebra (B.compl₁₂ (Qₗ := N) (Qₗ' := N) ↑e ↑e)) : ↑(skewAdjointLieSubalgebraEquiv B e f) = e.lieConj f := by simp [skewAdjointLieSubalgebraEquiv] #align skew_adjoint_lie_subalgebra_equiv_apply skewAdjointLieSubalgebraEquiv_apply @[simp] theorem skewAdjointLieSubalgebraEquiv_symm_apply (f : skewAdjointLieSubalgebra B) : ↑((skewAdjointLieSubalgebraEquiv B e).symm f) = e.symm.lieConj f := by simp [skewAdjointLieSubalgebraEquiv] #align skew_adjoint_lie_subalgebra_equiv_symm_apply skewAdjointLieSubalgebraEquiv_symm_apply end SkewAdjointEndomorphisms section SkewAdjointMatrices open scoped Matrix variable {R : Type u} {n : Type w} [CommRing R] [DecidableEq n] [Fintype n] variable (J : Matrix n n R) theorem Matrix.lie_transpose (A B : Matrix n n R) : ⁅A, B⁆ᵀ = ⁅Bᵀ, Aᵀ⁆ := show (A * B - B * A)ᵀ = Bᵀ * Aᵀ - Aᵀ * Bᵀ by simp #align matrix.lie_transpose Matrix.lie_transpose -- Porting note: Changed `(A B)` to `{A B}` for convenience in `skewAdjointMatricesLieSubalgebra`
Mathlib/Algebra/Lie/SkewAdjoint.lean
103
112
theorem Matrix.isSkewAdjoint_bracket {A B : Matrix n n R} (hA : A ∈ skewAdjointMatricesSubmodule J) (hB : B ∈ skewAdjointMatricesSubmodule J) : ⁅A, B⁆ ∈ skewAdjointMatricesSubmodule J := by
simp only [mem_skewAdjointMatricesSubmodule] at * change ⁅A, B⁆ᵀ * J = J * (-⁅A, B⁆) change Aᵀ * J = J * (-A) at hA change Bᵀ * J = J * (-B) at hB rw [Matrix.lie_transpose, LieRing.of_associative_ring_bracket, LieRing.of_associative_ring_bracket, sub_mul, mul_assoc, mul_assoc, hA, hB, ← mul_assoc, ← mul_assoc, hA, hB] noncomm_ring
/- Copyright (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura -/ import Mathlib.Init.Order.Defs #align_import init.algebra.functions from "leanprover-community/lean"@"c2bcdbcbe741ed37c361a30d38e179182b989f76" /-! # Basic lemmas about linear orders. The contents of this file came from `init.algebra.functions` in Lean 3, and it would be good to find everything a better home. -/ universe u section open Decidable variable {α : Type u} [LinearOrder α] theorem min_def (a b : α) : min a b = if a ≤ b then a else b := by rw [LinearOrder.min_def a] #align min_def min_def theorem max_def (a b : α) : max a b = if a ≤ b then b else a := by rw [LinearOrder.max_def a] #align max_def max_def theorem min_le_left (a b : α) : min a b ≤ a := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h, le_refl] else simp [min_def, if_neg h]; exact le_of_not_le h #align min_le_left min_le_left theorem min_le_right (a b : α) : min a b ≤ b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h]; exact h else simp [min_def, if_neg h, le_refl] #align min_le_right min_le_right theorem le_min {a b c : α} (h₁ : c ≤ a) (h₂ : c ≤ b) : c ≤ min a b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h]; exact h₁ else simp [min_def, if_neg h]; exact h₂ #align le_min le_min
Mathlib/Init/Order/LinearOrder.lean
54
58
theorem le_max_left (a b : α) : a ≤ max a b := by
-- Porting note: no `min_tac` tactic if h : a ≤ b then simp [max_def, if_pos h]; exact h else simp [max_def, if_neg h, le_refl]
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.LinearAlgebra.CliffordAlgebra.Grading import Mathlib.LinearAlgebra.TensorProduct.Graded.Internal import Mathlib.LinearAlgebra.QuadraticForm.Prod /-! # Clifford algebras of a direct sum of two vector spaces We show that the Clifford algebra of a direct sum is the graded tensor product of the Clifford algebras, as `CliffordAlgebra.equivProd`. ## Main definitions: * `CliffordAlgebra.equivProd : CliffordAlgebra (Q₁.prod Q₂) ≃ₐ[R] (evenOdd Q₁ ᵍ⊗[R] evenOdd Q₂)` ## TODO: Introduce morphisms and equivalences of graded algebas, and upgrade `CliffordAlgebra.equivProd` to a graded algebra equivalence. -/ suppress_compilation variable {R M₁ M₂ N : Type*} variable [CommRing R] [AddCommGroup M₁] [AddCommGroup M₂] [AddCommGroup N] variable [Module R M₁] [Module R M₂] [Module R N] variable (Q₁ : QuadraticForm R M₁) (Q₂ : QuadraticForm R M₂) (Qₙ : QuadraticForm R N) open scoped TensorProduct namespace CliffordAlgebra section map_mul_map variable {Q₁ Q₂ Qₙ} variable (f₁ : Q₁ →qᵢ Qₙ) (f₂ : Q₂ →qᵢ Qₙ) (hf : ∀ x y, Qₙ.IsOrtho (f₁ x) (f₂ y)) variable (m₁ : CliffordAlgebra Q₁) (m₂ : CliffordAlgebra Q₂) /-- If `m₁` and `m₂` are both homogenous, and the quadratic spaces `Q₁` and `Q₂` map into orthogonal subspaces of `Qₙ` (for instance, when `Qₙ = Q₁.prod Q₂`), then the product of the embedding in `CliffordAlgebra Q` commutes up to a sign factor. -/ nonrec theorem map_mul_map_of_isOrtho_of_mem_evenOdd {i₁ i₂ : ZMod 2} (hm₁ : m₁ ∈ evenOdd Q₁ i₁) (hm₂ : m₂ ∈ evenOdd Q₂ i₂) : map f₁ m₁ * map f₂ m₂ = (-1 : ℤˣ) ^ (i₂ * i₁) • (map f₂ m₂ * map f₁ m₁) := by -- the strategy; for each variable, induct on powers of `ι`, then on the exponent of each -- power. induction hm₁ using Submodule.iSup_induction' with | zero => rw [map_zero, zero_mul, mul_zero, smul_zero] | add _ _ _ _ ihx ihy => rw [map_add, add_mul, mul_add, ihx, ihy, smul_add] | mem i₁' m₁' hm₁ => obtain ⟨i₁n, rfl⟩ := i₁' dsimp only at * induction hm₁ using Submodule.pow_induction_on_left' with | algebraMap => rw [AlgHom.commutes, Nat.cast_zero, mul_zero, uzpow_zero, one_smul, Algebra.commutes] | add _ _ _ _ _ ihx ihy => rw [map_add, add_mul, mul_add, ihx, ihy, smul_add] | mem_mul m₁ hm₁ i x₁ _hx₁ ih₁ => obtain ⟨v₁, rfl⟩ := hm₁ -- this is the first interesting goal rw [map_mul, mul_assoc, ih₁, mul_smul_comm, map_apply_ι, Nat.cast_succ, mul_add_one, uzpow_add, mul_smul, ← mul_assoc, ← mul_assoc, ← smul_mul_assoc ((-1) ^ i₂)] clear ih₁ congr 2 induction hm₂ using Submodule.iSup_induction' with | zero => rw [map_zero, zero_mul, mul_zero, smul_zero] | add _ _ _ _ ihx ihy => rw [map_add, add_mul, mul_add, ihx, ihy, smul_add] | mem i₂' m₂' hm₂ => clear m₂ obtain ⟨i₂n, rfl⟩ := i₂' dsimp only at * induction hm₂ using Submodule.pow_induction_on_left' with | algebraMap => rw [AlgHom.commutes, Nat.cast_zero, uzpow_zero, one_smul, Algebra.commutes] | add _ _ _ _ _ ihx ihy => rw [map_add, add_mul, mul_add, ihx, ihy, smul_add] | mem_mul m₂ hm₂ i x₂ _hx₂ ih₂ => obtain ⟨v₂, rfl⟩ := hm₂ -- this is the second interesting goal rw [map_mul, map_apply_ι, Nat.cast_succ, ← mul_assoc, ι_mul_ι_comm_of_isOrtho (hf _ _), neg_mul, mul_assoc, ih₂, mul_smul_comm, ← mul_assoc, ← Units.neg_smul, uzpow_add, uzpow_one, mul_neg_one] theorem commute_map_mul_map_of_isOrtho_of_mem_evenOdd_zero_left {i₂ : ZMod 2} (hm₁ : m₁ ∈ evenOdd Q₁ 0) (hm₂ : m₂ ∈ evenOdd Q₂ i₂) : Commute (map f₁ m₁) (map f₂ m₂) := (map_mul_map_of_isOrtho_of_mem_evenOdd _ _ hf _ _ hm₁ hm₂).trans <| by simp theorem commute_map_mul_map_of_isOrtho_of_mem_evenOdd_zero_right {i₁ : ZMod 2} (hm₁ : m₁ ∈ evenOdd Q₁ i₁) (hm₂ : m₂ ∈ evenOdd Q₂ 0) : Commute (map f₁ m₁) (map f₂ m₂) := (map_mul_map_of_isOrtho_of_mem_evenOdd _ _ hf _ _ hm₁ hm₂).trans <| by simp
Mathlib/LinearAlgebra/CliffordAlgebra/Prod.lean
101
104
theorem map_mul_map_eq_neg_of_isOrtho_of_mem_evenOdd_one (hm₁ : m₁ ∈ evenOdd Q₁ 1) (hm₂ : m₂ ∈ evenOdd Q₂ 1) : map f₁ m₁ * map f₂ m₂ = - map f₂ m₂ * map f₁ m₁ := by
simp [map_mul_map_of_isOrtho_of_mem_evenOdd _ _ hf _ _ hm₁ hm₂]
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Kevin Buzzard -/ import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.GeomSum import Mathlib.Data.Fintype.BigOperators import Mathlib.RingTheory.PowerSeries.Inverse import Mathlib.RingTheory.PowerSeries.WellKnown import Mathlib.Tactic.FieldSimp #align_import number_theory.bernoulli from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # Bernoulli numbers The Bernoulli numbers are a sequence of rational numbers that frequently show up in number theory. ## Mathematical overview The Bernoulli numbers $(B_0, B_1, B_2, \ldots)=(1, -1/2, 1/6, 0, -1/30, \ldots)$ are a sequence of rational numbers. They show up in the formula for the sums of $k$th powers. They are related to the Taylor series expansions of $x/\tan(x)$ and of $\coth(x)$, and also show up in the values that the Riemann Zeta function takes both at both negative and positive integers (and hence in the theory of modular forms). For example, if $1 \leq n$ is even then $$\zeta(2n)=\sum_{t\geq1}t^{-2n}=(-1)^{n+1}\frac{(2\pi)^{2n}B_{2n}}{2(2n)!}.$$ Note however that this result is not yet formalised in Lean. The Bernoulli numbers can be formally defined using the power series $$\sum B_n\frac{t^n}{n!}=\frac{t}{1-e^{-t}}$$ although that happens to not be the definition in mathlib (this is an *implementation detail* and need not concern the mathematician). Note that $B_1=-1/2$, meaning that we are using the $B_n^-$ of [from Wikipedia](https://en.wikipedia.org/wiki/Bernoulli_number). ## Implementation detail The Bernoulli numbers are defined using well-founded induction, by the formula $$B_n=1-\sum_{k\lt n}\frac{\binom{n}{k}}{n-k+1}B_k.$$ This formula is true for all $n$ and in particular $B_0=1$. Note that this is the definition for positive Bernoulli numbers, which we call `bernoulli'`. The negative Bernoulli numbers are then defined as `bernoulli := (-1)^n * bernoulli'`. ## Main theorems `sum_bernoulli : ∑ k ∈ Finset.range n, (n.choose k : ℚ) * bernoulli k = if n = 1 then 1 else 0` -/ open Nat Finset Finset.Nat PowerSeries variable (A : Type*) [CommRing A] [Algebra ℚ A] /-! ### Definitions -/ /-- The Bernoulli numbers: the $n$-th Bernoulli number $B_n$ is defined recursively via $$B_n = 1 - \sum_{k < n} \binom{n}{k}\frac{B_k}{n+1-k}$$ -/ def bernoulli' : ℕ → ℚ := WellFounded.fix Nat.lt_wfRel.wf fun n bernoulli' => 1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k k.2 #align bernoulli' bernoulli' theorem bernoulli'_def' (n : ℕ) : bernoulli' n = 1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k := WellFounded.fix_eq _ _ _ #align bernoulli'_def' bernoulli'_def'
Mathlib/NumberTheory/Bernoulli.lean
78
80
theorem bernoulli'_def (n : ℕ) : bernoulli' n = 1 - ∑ k ∈ range n, n.choose k / (n - k + 1) * bernoulli' k := by
rw [bernoulli'_def', ← Fin.sum_univ_eq_sum_range]
/- Copyright (c) 2023 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.LinearAlgebra.Matrix.Gershgorin import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.ConvexBody import Mathlib.NumberTheory.NumberField.Units.Basic import Mathlib.RingTheory.RootsOfUnity.Basic #align_import number_theory.number_field.units from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a" /-! # Dirichlet theorem on the group of units of a number field This file is devoted to the proof of Dirichlet unit theorem that states that the group of units `(𝓞 K)ˣ` of units of the ring of integers `𝓞 K` of a number field `K` modulo its torsion subgroup is a free `ℤ`-module of rank `card (InfinitePlace K) - 1`. ## Main definitions * `NumberField.Units.rank`: the unit rank of the number field `K`. * `NumberField.Units.fundSystem`: a fundamental system of units of `K`. * `NumberField.Units.basisModTorsion`: a `ℤ`-basis of `(𝓞 K)ˣ ⧸ (torsion K)` as an additive `ℤ`-module. ## Main results * `NumberField.Units.rank_modTorsion`: the `ℤ`-rank of `(𝓞 K)ˣ ⧸ (torsion K)` is equal to `card (InfinitePlace K) - 1`. * `NumberField.Units.exist_unique_eq_mul_prod`: **Dirichlet Unit Theorem**. Any unit of `𝓞 K` can be written uniquely as the product of a root of unity and powers of the units of the fundamental system `fundSystem`. ## Tags number field, units, Dirichlet unit theorem -/ open scoped NumberField noncomputable section open NumberField NumberField.InfinitePlace NumberField.Units BigOperators variable (K : Type*) [Field K] [NumberField K] namespace NumberField.Units.dirichletUnitTheorem /-! ### Dirichlet Unit Theorem We define a group morphism from `(𝓞 K)ˣ` to `{w : InfinitePlace K // w ≠ w₀} → ℝ` where `w₀` is a distinguished (arbitrary) infinite place, prove that its kernel is the torsion subgroup (see `logEmbedding_eq_zero_iff`) and that its image, called `unitLattice`, is a full `ℤ`-lattice. It follows that `unitLattice` is a free `ℤ`-module (see `instModuleFree_unitLattice`) of rank `card (InfinitePlaces K) - 1` (see `unitLattice_rank`). To prove that the `unitLattice` is a full `ℤ`-lattice, we need to prove that it is discrete (see `unitLattice_inter_ball_finite`) and that it spans the full space over `ℝ` (see `unitLattice_span_eq_top`); this is the main part of the proof, see the section `span_top` below for more details. -/ open scoped Classical open Finset variable {K} /-- The distinguished infinite place. -/ def w₀ : InfinitePlace K := (inferInstance : Nonempty (InfinitePlace K)).some variable (K) /-- The logarithmic embedding of the units (seen as an `Additive` group). -/ def logEmbedding : Additive ((𝓞 K)ˣ) →+ ({w : InfinitePlace K // w ≠ w₀} → ℝ) := { toFun := fun x w => mult w.val * Real.log (w.val ↑(Additive.toMul x)) map_zero' := by simp; rfl map_add' := fun _ _ => by simp [Real.log_mul, mul_add]; rfl } variable {K} @[simp] theorem logEmbedding_component (x : (𝓞 K)ˣ) (w : {w : InfinitePlace K // w ≠ w₀}) : (logEmbedding K x) w = mult w.val * Real.log (w.val x) := rfl theorem sum_logEmbedding_component (x : (𝓞 K)ˣ) : ∑ w, logEmbedding K x w = - mult (w₀ : InfinitePlace K) * Real.log (w₀ (x : K)) := by have h := congr_arg Real.log (prod_eq_abs_norm (x : K)) rw [show |(Algebra.norm ℚ) (x : K)| = 1 from isUnit_iff_norm.mp x.isUnit, Rat.cast_one, Real.log_one, Real.log_prod] at h · simp_rw [Real.log_pow] at h rw [← insert_erase (mem_univ w₀), sum_insert (not_mem_erase w₀ univ), add_comm, add_eq_zero_iff_eq_neg] at h convert h using 1 · refine (sum_subtype _ (fun w => ?_) (fun w => (mult w) * (Real.log (w (x : K))))).symm exact ⟨ne_of_mem_erase, fun h => mem_erase_of_ne_of_mem h (mem_univ w)⟩ · norm_num · exact fun w _ => pow_ne_zero _ (AbsoluteValue.ne_zero _ (coe_ne_zero x))
Mathlib/NumberTheory/NumberField/Units/DirichletTheorem.lean
100
106
theorem mult_log_place_eq_zero {x : (𝓞 K)ˣ} {w : InfinitePlace K} : mult w * Real.log (w x) = 0 ↔ w x = 1 := by
rw [mul_eq_zero, or_iff_right, Real.log_eq_zero, or_iff_right, or_iff_left] · linarith [(apply_nonneg _ _ : 0 ≤ w x)] · simp only [ne_eq, map_eq_zero, coe_ne_zero x, not_false_eq_true] · refine (ne_of_gt ?_) rw [mult]; split_ifs <;> norm_num
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Patrick Massot, Yury Kudryashov -/ import Mathlib.Topology.Connected.Basic /-! # Totally disconnected and totally separated topological spaces ## Main definitions We define the following properties for sets in a topological space: * `IsTotallyDisconnected`: all of its connected components are singletons. * `IsTotallySeparated`: any two points can be separated by two disjoint opens that cover the set. For both of these definitions, we also have a class stating that the whole space satisfies that property: `TotallyDisconnectedSpace`, `TotallySeparatedSpace`. -/ open Set Function universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section TotallyDisconnected /-- A set `s` is called totally disconnected if every subset `t ⊆ s` which is preconnected is a subsingleton, ie either empty or a singleton. -/ def IsTotallyDisconnected (s : Set α) : Prop := ∀ t, t ⊆ s → IsPreconnected t → t.Subsingleton #align is_totally_disconnected IsTotallyDisconnected theorem isTotallyDisconnected_empty : IsTotallyDisconnected (∅ : Set α) := fun _ ht _ _ x_in _ _ => (ht x_in).elim #align is_totally_disconnected_empty isTotallyDisconnected_empty theorem isTotallyDisconnected_singleton {x} : IsTotallyDisconnected ({x} : Set α) := fun _ ht _ => subsingleton_singleton.anti ht #align is_totally_disconnected_singleton isTotallyDisconnected_singleton /-- A space is totally disconnected if all of its connected components are singletons. -/ @[mk_iff] class TotallyDisconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where /-- The universal set `Set.univ` in a totally disconnected space is totally disconnected. -/ isTotallyDisconnected_univ : IsTotallyDisconnected (univ : Set α) #align totally_disconnected_space TotallyDisconnectedSpace theorem IsPreconnected.subsingleton [TotallyDisconnectedSpace α] {s : Set α} (h : IsPreconnected s) : s.Subsingleton := TotallyDisconnectedSpace.isTotallyDisconnected_univ s (subset_univ s) h #align is_preconnected.subsingleton IsPreconnected.subsingleton instance Pi.totallyDisconnectedSpace {α : Type*} {β : α → Type*} [∀ a, TopologicalSpace (β a)] [∀ a, TotallyDisconnectedSpace (β a)] : TotallyDisconnectedSpace (∀ a : α, β a) := ⟨fun t _ h2 => have this : ∀ a, IsPreconnected ((fun x : ∀ a, β a => x a) '' t) := fun a => h2.image (fun x => x a) (continuous_apply a).continuousOn fun x x_in y y_in => funext fun a => (this a).subsingleton ⟨x, x_in, rfl⟩ ⟨y, y_in, rfl⟩⟩ #align pi.totally_disconnected_space Pi.totallyDisconnectedSpace instance Prod.totallyDisconnectedSpace [TopologicalSpace β] [TotallyDisconnectedSpace α] [TotallyDisconnectedSpace β] : TotallyDisconnectedSpace (α × β) := ⟨fun t _ h2 => have H1 : IsPreconnected (Prod.fst '' t) := h2.image Prod.fst continuous_fst.continuousOn have H2 : IsPreconnected (Prod.snd '' t) := h2.image Prod.snd continuous_snd.continuousOn fun x hx y hy => Prod.ext (H1.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩) (H2.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)⟩ #align prod.totally_disconnected_space Prod.totallyDisconnectedSpace instance [TopologicalSpace β] [TotallyDisconnectedSpace α] [TotallyDisconnectedSpace β] : TotallyDisconnectedSpace (Sum α β) := by refine ⟨fun s _ hs => ?_⟩ obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isPreconnected_iff.1 hs · exact ht.subsingleton.image _ · exact ht.subsingleton.image _ instance [∀ i, TopologicalSpace (π i)] [∀ i, TotallyDisconnectedSpace (π i)] : TotallyDisconnectedSpace (Σi, π i) := by refine ⟨fun s _ hs => ?_⟩ obtain rfl | h := s.eq_empty_or_nonempty · exact subsingleton_empty · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩ exact ht.isPreconnected.subsingleton.image _ -- Porting note: reformulated using `Pairwise` /-- Let `X` be a topological space, and suppose that for all distinct `x,y ∈ X`, there is some clopen set `U` such that `x ∈ U` and `y ∉ U`. Then `X` is totally disconnected. -/ theorem isTotallyDisconnected_of_isClopen_set {X : Type*} [TopologicalSpace X] (hX : Pairwise fun x y => ∃ (U : Set X), IsClopen U ∧ x ∈ U ∧ y ∉ U) : IsTotallyDisconnected (Set.univ : Set X) := by rintro S - hS unfold Set.Subsingleton by_contra! h_contra rcases h_contra with ⟨x, hx, y, hy, hxy⟩ obtain ⟨U, hU, hxU, hyU⟩ := hX hxy specialize hS U Uᶜ hU.2 hU.compl.2 (fun a _ => em (a ∈ U)) ⟨x, hx, hxU⟩ ⟨y, hy, hyU⟩ rw [inter_compl_self, Set.inter_empty] at hS exact Set.not_nonempty_empty hS #align is_totally_disconnected_of_clopen_set isTotallyDisconnected_of_isClopen_set /-- A space is totally disconnected iff its connected components are subsingletons. -/ theorem totallyDisconnectedSpace_iff_connectedComponent_subsingleton : TotallyDisconnectedSpace α ↔ ∀ x : α, (connectedComponent x).Subsingleton := by constructor · intro h x apply h.1 · exact subset_univ _ exact isPreconnected_connectedComponent intro h; constructor intro s s_sub hs rcases eq_empty_or_nonempty s with (rfl | ⟨x, x_in⟩) · exact subsingleton_empty · exact (h x).anti (hs.subset_connectedComponent x_in) #align totally_disconnected_space_iff_connected_component_subsingleton totallyDisconnectedSpace_iff_connectedComponent_subsingleton /-- A space is totally disconnected iff its connected components are singletons. -/
Mathlib/Topology/Connected/TotallyDisconnected.lean
123
128
theorem totallyDisconnectedSpace_iff_connectedComponent_singleton : TotallyDisconnectedSpace α ↔ ∀ x : α, connectedComponent x = {x} := by
rw [totallyDisconnectedSpace_iff_connectedComponent_subsingleton] refine forall_congr' fun x => ?_ rw [subsingleton_iff_singleton] exact mem_connectedComponent
/- Copyright (c) 2019 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" /-! # Neighborhoods and continuity relative to a subset This file defines relative versions * `nhdsWithin` of `nhds` * `ContinuousOn` of `Continuous` * `ContinuousWithinAt` of `ContinuousAt` and proves their basic properties, including the relationships between these restricted notions and the corresponding notions for the subtype equipped with the subspace topology. ## Notation * `𝓝 x`: the filter of neighborhoods of a point `x`; * `𝓟 s`: the principal filter of a set `s`; * `𝓝[s] x`: the filter `nhdsWithin x s` of neighborhoods of a point `x` within a set `s`. -/ open Set Filter Function Topology Filter variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} variable [TopologicalSpace α] @[simp] theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} : (∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} : z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊢ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : α) (s : Set α) : 𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by rw [nhdsWithin, principal_univ, inf_top_eq] #align nhds_within_univ nhdsWithin_univ theorem nhdsWithin_hasBasis {p : β → Prop} {s : β → Set α} {a : α} (h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t := h.inf_principal t #align nhds_within_has_basis nhdsWithin_hasBasis theorem nhdsWithin_basis_open (a : α) (t : Set α) : (𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t := nhdsWithin_hasBasis (nhds_basis_opens a) t #align nhds_within_basis_open nhdsWithin_basis_open theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff #align mem_nhds_within mem_nhdsWithin theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t := (nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff #align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) : s \ t ∈ 𝓝[tᶜ] x := diff_mem_inf_principal_compl hs t #align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl
Mathlib/Topology/ContinuousOn.lean
104
107
theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) : s \ t' ∈ 𝓝[t \ t'] x := by
rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc] exact inter_mem_inf hs (mem_principal_self _)
/- Copyright (c) 2020 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Alexey Soloyev, Junyan Xu, Kamila Szewczyk -/ import Mathlib.Data.Real.Irrational import Mathlib.Data.Nat.Fib.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Algebra.LinearRecurrence import Mathlib.Tactic.NormNum.NatFib import Mathlib.Tactic.NormNum.Prime #align_import data.real.golden_ratio from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # The golden ratio and its conjugate This file defines the golden ratio `φ := (1 + √5)/2` and its conjugate `ψ := (1 - √5)/2`, which are the two real roots of `X² - X - 1`. Along with various computational facts about them, we prove their irrationality, and we link them to the Fibonacci sequence by proving Binet's formula. -/ noncomputable section open Polynomial /-- The golden ratio `φ := (1 + √5)/2`. -/ abbrev goldenRatio : ℝ := (1 + √5) / 2 #align golden_ratio goldenRatio /-- The conjugate of the golden ratio `ψ := (1 - √5)/2`. -/ abbrev goldenConj : ℝ := (1 - √5) / 2 #align golden_conj goldenConj @[inherit_doc goldenRatio] scoped[goldenRatio] notation "φ" => goldenRatio @[inherit_doc goldenConj] scoped[goldenRatio] notation "ψ" => goldenConj open Real goldenRatio /-- The inverse of the golden ratio is the opposite of its conjugate. -/ theorem inv_gold : φ⁻¹ = -ψ := by have : 1 + √5 ≠ 0 := ne_of_gt (add_pos (by norm_num) <| Real.sqrt_pos.mpr (by norm_num)) field_simp [sub_mul, mul_add] norm_num #align inv_gold inv_gold /-- The opposite of the golden ratio is the inverse of its conjugate. -/ theorem inv_goldConj : ψ⁻¹ = -φ := by rw [inv_eq_iff_eq_inv, ← neg_inv, ← neg_eq_iff_eq_neg] exact inv_gold.symm #align inv_gold_conj inv_goldConj @[simp] theorem gold_mul_goldConj : φ * ψ = -1 := by field_simp rw [← sq_sub_sq] norm_num #align gold_mul_gold_conj gold_mul_goldConj @[simp] theorem goldConj_mul_gold : ψ * φ = -1 := by rw [mul_comm] exact gold_mul_goldConj #align gold_conj_mul_gold goldConj_mul_gold @[simp] theorem gold_add_goldConj : φ + ψ = 1 := by rw [goldenRatio, goldenConj] ring #align gold_add_gold_conj gold_add_goldConj theorem one_sub_goldConj : 1 - φ = ψ := by linarith [gold_add_goldConj] #align one_sub_gold_conj one_sub_goldConj theorem one_sub_gold : 1 - ψ = φ := by linarith [gold_add_goldConj] #align one_sub_gold one_sub_gold @[simp] theorem gold_sub_goldConj : φ - ψ = √5 := by ring #align gold_sub_gold_conj gold_sub_goldConj theorem gold_pow_sub_gold_pow (n : ℕ) : φ ^ (n + 2) - φ ^ (n + 1) = φ ^ n := by rw [goldenRatio]; ring_nf; norm_num; ring @[simp 1200] theorem gold_sq : φ ^ 2 = φ + 1 := by rw [goldenRatio, ← sub_eq_zero] ring_nf rw [Real.sq_sqrt] <;> norm_num #align gold_sq gold_sq @[simp 1200] theorem goldConj_sq : ψ ^ 2 = ψ + 1 := by rw [goldenConj, ← sub_eq_zero] ring_nf rw [Real.sq_sqrt] <;> norm_num #align gold_conj_sq goldConj_sq theorem gold_pos : 0 < φ := mul_pos (by apply add_pos <;> norm_num) <| inv_pos.2 zero_lt_two #align gold_pos gold_pos theorem gold_ne_zero : φ ≠ 0 := ne_of_gt gold_pos #align gold_ne_zero gold_ne_zero theorem one_lt_gold : 1 < φ := by refine lt_of_mul_lt_mul_left ?_ (le_of_lt gold_pos) simp [← sq, gold_pos, zero_lt_one, - div_pow] -- Porting note: Added `- div_pow` #align one_lt_gold one_lt_gold theorem gold_lt_two : φ < 2 := by calc (1 + sqrt 5) / 2 < (1 + 3) / 2 := by gcongr; rw [sqrt_lt'] <;> norm_num _ = 2 := by norm_num theorem goldConj_neg : ψ < 0 := by linarith [one_sub_goldConj, one_lt_gold] #align gold_conj_neg goldConj_neg theorem goldConj_ne_zero : ψ ≠ 0 := ne_of_lt goldConj_neg #align gold_conj_ne_zero goldConj_ne_zero
Mathlib/Data/Real/GoldenRatio.lean
129
131
theorem neg_one_lt_goldConj : -1 < ψ := by
rw [neg_lt, ← inv_gold] exact inv_lt_one one_lt_gold
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel, Rémy Degenne, David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.Pow.Real #align_import analysis.special_functions.pow.nnreal from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" /-! # Power function on `ℝ≥0` and `ℝ≥0∞` We construct the power functions `x ^ y` where * `x` is a nonnegative real number and `y` is a real number; * `x` is a number from `[0, +∞]` (a.k.a. `ℝ≥0∞`) and `y` is a real number. We also prove basic properties of these functions. -/ noncomputable section open scoped Classical open Real NNReal ENNReal ComplexConjugate open Finset Function Set namespace NNReal variable {w x y z : ℝ} /-- The nonnegative real power function `x^y`, defined for `x : ℝ≥0` and `y : ℝ` as the restriction of the real power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y ≠ 0`. -/ noncomputable def rpow (x : ℝ≥0) (y : ℝ) : ℝ≥0 := ⟨(x : ℝ) ^ y, Real.rpow_nonneg x.2 y⟩ #align nnreal.rpow NNReal.rpow noncomputable instance : Pow ℝ≥0 ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x : ℝ≥0) (y : ℝ) : rpow x y = x ^ y := rfl #align nnreal.rpow_eq_pow NNReal.rpow_eq_pow @[simp, norm_cast] theorem coe_rpow (x : ℝ≥0) (y : ℝ) : ((x ^ y : ℝ≥0) : ℝ) = (x : ℝ) ^ y := rfl #align nnreal.coe_rpow NNReal.coe_rpow @[simp] theorem rpow_zero (x : ℝ≥0) : x ^ (0 : ℝ) = 1 := NNReal.eq <| Real.rpow_zero _ #align nnreal.rpow_zero NNReal.rpow_zero @[simp] theorem rpow_eq_zero_iff {x : ℝ≥0} {y : ℝ} : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by rw [← NNReal.coe_inj, coe_rpow, ← NNReal.coe_eq_zero] exact Real.rpow_eq_zero_iff_of_nonneg x.2 #align nnreal.rpow_eq_zero_iff NNReal.rpow_eq_zero_iff @[simp] theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ≥0) ^ x = 0 := NNReal.eq <| Real.zero_rpow h #align nnreal.zero_rpow NNReal.zero_rpow @[simp] theorem rpow_one (x : ℝ≥0) : x ^ (1 : ℝ) = x := NNReal.eq <| Real.rpow_one _ #align nnreal.rpow_one NNReal.rpow_one @[simp] theorem one_rpow (x : ℝ) : (1 : ℝ≥0) ^ x = 1 := NNReal.eq <| Real.one_rpow _ #align nnreal.one_rpow NNReal.one_rpow theorem rpow_add {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z := NNReal.eq <| Real.rpow_add (pos_iff_ne_zero.2 hx) _ _ #align nnreal.rpow_add NNReal.rpow_add theorem rpow_add' (x : ℝ≥0) {y z : ℝ} (h : y + z ≠ 0) : x ^ (y + z) = x ^ y * x ^ z := NNReal.eq <| Real.rpow_add' x.2 h #align nnreal.rpow_add' NNReal.rpow_add' /-- Variant of `NNReal.rpow_add'` that avoids having to prove `y + z = w` twice. -/ lemma rpow_of_add_eq (x : ℝ≥0) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by rw [← h, rpow_add']; rwa [h] theorem rpow_mul (x : ℝ≥0) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z := NNReal.eq <| Real.rpow_mul x.2 y z #align nnreal.rpow_mul NNReal.rpow_mul theorem rpow_neg (x : ℝ≥0) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ := NNReal.eq <| Real.rpow_neg x.2 _ #align nnreal.rpow_neg NNReal.rpow_neg theorem rpow_neg_one (x : ℝ≥0) : x ^ (-1 : ℝ) = x⁻¹ := by simp [rpow_neg] #align nnreal.rpow_neg_one NNReal.rpow_neg_one theorem rpow_sub {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y - z) = x ^ y / x ^ z := NNReal.eq <| Real.rpow_sub (pos_iff_ne_zero.2 hx) y z #align nnreal.rpow_sub NNReal.rpow_sub theorem rpow_sub' (x : ℝ≥0) {y z : ℝ} (h : y - z ≠ 0) : x ^ (y - z) = x ^ y / x ^ z := NNReal.eq <| Real.rpow_sub' x.2 h #align nnreal.rpow_sub' NNReal.rpow_sub'
Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean
108
109
theorem rpow_inv_rpow_self {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ y) ^ (1 / y) = x := by
field_simp [← rpow_mul]
/- 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, Kevin Buzzard, Yury Kudryashov, Eric Wieser -/ import Mathlib.Algebra.Algebra.Prod import Mathlib.LinearAlgebra.Basic import Mathlib.LinearAlgebra.Span import Mathlib.Order.PartialSups #align_import linear_algebra.prod from "leanprover-community/mathlib"@"cd391184c85986113f8c00844cfe6dda1d34be3d" /-! ### Products of modules This file defines constructors for linear maps whose domains or codomains are products. It contains theorems relating these to each other, as well as to `Submodule.prod`, `Submodule.map`, `Submodule.comap`, `LinearMap.range`, and `LinearMap.ker`. ## Main definitions - products in the domain: - `LinearMap.fst` - `LinearMap.snd` - `LinearMap.coprod` - `LinearMap.prod_ext` - products in the codomain: - `LinearMap.inl` - `LinearMap.inr` - `LinearMap.prod` - products in both domain and codomain: - `LinearMap.prodMap` - `LinearEquiv.prodMap` - `LinearEquiv.skewProd` -/ universe u v w x y z u' v' w' y' variable {R : Type u} {K : Type u'} {M : Type v} {V : Type v'} {M₂ : Type w} {V₂ : Type w'} variable {M₃ : Type y} {V₃ : Type y'} {M₄ : Type z} {ι : Type x} variable {M₅ M₆ : Type*} section Prod namespace LinearMap variable (S : Type*) [Semiring R] [Semiring S] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] [AddCommMonoid M₄] variable [AddCommMonoid M₅] [AddCommMonoid M₆] variable [Module R M] [Module R M₂] [Module R M₃] [Module R M₄] variable [Module R M₅] [Module R M₆] variable (f : M →ₗ[R] M₂) section variable (R M M₂) /-- The first projection of a product is a linear map. -/ def fst : M × M₂ →ₗ[R] M where toFun := Prod.fst map_add' _x _y := rfl map_smul' _x _y := rfl #align linear_map.fst LinearMap.fst /-- The second projection of a product is a linear map. -/ def snd : M × M₂ →ₗ[R] M₂ where toFun := Prod.snd map_add' _x _y := rfl map_smul' _x _y := rfl #align linear_map.snd LinearMap.snd end @[simp] theorem fst_apply (x : M × M₂) : fst R M M₂ x = x.1 := rfl #align linear_map.fst_apply LinearMap.fst_apply @[simp] theorem snd_apply (x : M × M₂) : snd R M M₂ x = x.2 := rfl #align linear_map.snd_apply LinearMap.snd_apply theorem fst_surjective : Function.Surjective (fst R M M₂) := fun x => ⟨(x, 0), rfl⟩ #align linear_map.fst_surjective LinearMap.fst_surjective theorem snd_surjective : Function.Surjective (snd R M M₂) := fun x => ⟨(0, x), rfl⟩ #align linear_map.snd_surjective LinearMap.snd_surjective /-- The prod of two linear maps is a linear map. -/ @[simps] def prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : M →ₗ[R] M₂ × M₃ where toFun := Pi.prod f g map_add' x y := by simp only [Pi.prod, Prod.mk_add_mk, map_add] map_smul' c x := by simp only [Pi.prod, Prod.smul_mk, map_smul, RingHom.id_apply] #align linear_map.prod LinearMap.prod theorem coe_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : ⇑(f.prod g) = Pi.prod f g := rfl #align linear_map.coe_prod LinearMap.coe_prod @[simp] theorem fst_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : (fst R M₂ M₃).comp (prod f g) = f := rfl #align linear_map.fst_prod LinearMap.fst_prod @[simp] theorem snd_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : (snd R M₂ M₃).comp (prod f g) = g := rfl #align linear_map.snd_prod LinearMap.snd_prod @[simp] theorem pair_fst_snd : prod (fst R M M₂) (snd R M M₂) = LinearMap.id := rfl #align linear_map.pair_fst_snd LinearMap.pair_fst_snd theorem prod_comp (f : M₂ →ₗ[R] M₃) (g : M₂ →ₗ[R] M₄) (h : M →ₗ[R] M₂) : (f.prod g).comp h = (f.comp h).prod (g.comp h) := rfl /-- Taking the product of two maps with the same domain is equivalent to taking the product of their codomains. See note [bundled maps over different rings] for why separate `R` and `S` semirings are used. -/ @[simps] def prodEquiv [Module S M₂] [Module S M₃] [SMulCommClass R S M₂] [SMulCommClass R S M₃] : ((M →ₗ[R] M₂) × (M →ₗ[R] M₃)) ≃ₗ[S] M →ₗ[R] M₂ × M₃ where toFun f := f.1.prod f.2 invFun f := ((fst _ _ _).comp f, (snd _ _ _).comp f) left_inv f := by ext <;> rfl right_inv f := by ext <;> rfl map_add' a b := rfl map_smul' r a := rfl #align linear_map.prod_equiv LinearMap.prodEquiv section variable (R M M₂) /-- The left injection into a product is a linear map. -/ def inl : M →ₗ[R] M × M₂ := prod LinearMap.id 0 #align linear_map.inl LinearMap.inl /-- The right injection into a product is a linear map. -/ def inr : M₂ →ₗ[R] M × M₂ := prod 0 LinearMap.id #align linear_map.inr LinearMap.inr
Mathlib/LinearAlgebra/Prod.lean
148
155
theorem range_inl : range (inl R M M₂) = ker (snd R M M₂) := by
ext x simp only [mem_ker, mem_range] constructor · rintro ⟨y, rfl⟩ rfl · intro h exact ⟨x.fst, Prod.ext rfl h.symm⟩
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics import Mathlib.NumberTheory.Liouville.Basic import Mathlib.Topology.Instances.Irrational #align_import number_theory.liouville.liouville_with from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8" /-! # Liouville numbers with a given exponent We say that a real number `x` is a Liouville number with exponent `p : ℝ` if there exists a real number `C` such that for infinitely many denominators `n` there exists a numerator `m` such that `x ≠ m / n` and `|x - m / n| < C / n ^ p`. A number is a Liouville number in the sense of `Liouville` if it is `LiouvilleWith` any real exponent, see `forall_liouvilleWith_iff`. * If `p ≤ 1`, then this condition is trivial. * If `1 < p ≤ 2`, then this condition is equivalent to `Irrational x`. The forward implication does not require `p ≤ 2` and is formalized as `LiouvilleWith.irrational`; the other implication follows from approximations by continued fractions and is not formalized yet. * If `p > 2`, then this is a non-trivial condition on irrational numbers. In particular, [Thue–Siegel–Roth theorem](https://en.wikipedia.org/wiki/Roth's_theorem) states that such numbers must be transcendental. In this file we define the predicate `LiouvilleWith` and prove some basic facts about this predicate. ## Tags Liouville number, irrational, irrationality exponent -/ open Filter Metric Real Set open scoped Filter Topology /-- We say that a real number `x` is a Liouville number with exponent `p : ℝ` if there exists a real number `C` such that for infinitely many denominators `n` there exists a numerator `m` such that `x ≠ m / n` and `|x - m / n| < C / n ^ p`. A number is a Liouville number in the sense of `Liouville` if it is `LiouvilleWith` any real exponent. -/ def LiouvilleWith (p x : ℝ) : Prop := ∃ C, ∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p #align liouville_with LiouvilleWith /-- For `p = 1` (hence, for any `p ≤ 1`), the condition `LiouvilleWith p x` is trivial. -/ theorem liouvilleWith_one (x : ℝ) : LiouvilleWith 1 x := by use 2 refine ((eventually_gt_atTop 0).mono fun n hn => ?_).frequently have hn' : (0 : ℝ) < n := by simpa have : x < ↑(⌊x * ↑n⌋ + 1) / ↑n := by rw [lt_div_iff hn', Int.cast_add, Int.cast_one]; exact Int.lt_floor_add_one _ refine ⟨⌊x * n⌋ + 1, this.ne, ?_⟩ rw [abs_sub_comm, abs_of_pos (sub_pos.2 this), rpow_one, sub_lt_iff_lt_add', add_div_eq_mul_add_div _ _ hn'.ne'] gcongr calc _ ≤ x * n + 1 := by push_cast; gcongr; apply Int.floor_le _ < x * n + 2 := by linarith #align liouville_with_one liouvilleWith_one namespace LiouvilleWith variable {p q x y : ℝ} {r : ℚ} {m : ℤ} {n : ℕ} /-- The constant `C` provided by the definition of `LiouvilleWith` can be made positive. We also add `1 ≤ n` to the list of assumptions about the denominator. While it is equivalent to the original statement, the case `n = 0` breaks many arguments. -/ theorem exists_pos (h : LiouvilleWith p x) : ∃ (C : ℝ) (_h₀ : 0 < C), ∃ᶠ n : ℕ in atTop, 1 ≤ n ∧ ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p := by rcases h with ⟨C, hC⟩ refine ⟨max C 1, zero_lt_one.trans_le <| le_max_right _ _, ?_⟩ refine ((eventually_ge_atTop 1).and_frequently hC).mono ?_ rintro n ⟨hle, m, hne, hlt⟩ refine ⟨hle, m, hne, hlt.trans_le ?_⟩ gcongr apply le_max_left #align liouville_with.exists_pos LiouvilleWith.exists_pos /-- If a number is Liouville with exponent `p`, then it is Liouville with any smaller exponent. -/ theorem mono (h : LiouvilleWith p x) (hle : q ≤ p) : LiouvilleWith q x := by rcases h.exists_pos with ⟨C, hC₀, hC⟩ refine ⟨C, hC.mono ?_⟩; rintro n ⟨hn, m, hne, hlt⟩ refine ⟨m, hne, hlt.trans_le <| ?_⟩ gcongr exact_mod_cast hn #align liouville_with.mono LiouvilleWith.mono /-- If `x` satisfies Liouville condition with exponent `p` and `q < p`, then `x` satisfies Liouville condition with exponent `q` and constant `1`. -/
Mathlib/NumberTheory/Liouville/LiouvilleWith.lean
99
110
theorem frequently_lt_rpow_neg (h : LiouvilleWith p x) (hlt : q < p) : ∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < n ^ (-q) := by
rcases h.exists_pos with ⟨C, _hC₀, hC⟩ have : ∀ᶠ n : ℕ in atTop, C < n ^ (p - q) := by simpa only [(· ∘ ·), neg_sub, one_div] using ((tendsto_rpow_atTop (sub_pos.2 hlt)).comp tendsto_natCast_atTop_atTop).eventually (eventually_gt_atTop C) refine (this.and_frequently hC).mono ?_ rintro n ⟨hnC, hn, m, hne, hlt⟩ replace hn : (0 : ℝ) < n := Nat.cast_pos.2 hn refine ⟨m, hne, hlt.trans <| (div_lt_iff <| rpow_pos_of_pos hn _).2 ?_⟩ rwa [mul_comm, ← rpow_add hn, ← sub_eq_add_neg]
/- Copyright (c) 2021 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.Sigma.Lex import Mathlib.Order.BoundedOrder import Mathlib.Mathport.Notation import Mathlib.Data.Sigma.Basic #align_import data.sigma.order from "leanprover-community/mathlib"@"1fc36cc9c8264e6e81253f88be7fb2cb6c92d76a" /-! # Orders on a sigma type This file defines two orders on a sigma type: * The disjoint sum of orders. `a` is less `b` iff `a` and `b` are in the same summand and `a` is less than `b` there. * The lexicographical order. `a` is less than `b` if its summand is strictly less than the summand of `b` or they are in the same summand and `a` is less than `b` there. We make the disjoint sum of orders the default set of instances. The lexicographic order goes on a type synonym. ## Notation * `_root_.Lex (Sigma α)`: Sigma type equipped with the lexicographic order. Type synonym of `Σ i, α i`. ## See also Related files are: * `Data.Finset.CoLex`: Colexicographic order on finite sets. * `Data.List.Lex`: Lexicographic order on lists. * `Data.Pi.Lex`: Lexicographic order on `Πₗ i, α i`. * `Data.PSigma.Order`: Lexicographic order on `Σₗ' i, α i`. Basically a twin of this file. * `Data.Prod.Lex`: Lexicographic order on `α × β`. ## TODO Upgrade `Equiv.sigma_congr_left`, `Equiv.sigma_congr`, `Equiv.sigma_assoc`, `Equiv.sigma_prod_of_equiv`, `Equiv.sigma_equiv_prod`, ... to order isomorphisms. -/ namespace Sigma variable {ι : Type*} {α : ι → Type*} /-! ### Disjoint sum of orders on `Sigma` -/ -- Porting note: I made this `le` instead of `LE` because the output type is `Prop` /-- Disjoint sum of orders. `⟨i, a⟩ ≤ ⟨j, b⟩` iff `i = j` and `a ≤ b`. -/ protected inductive le [∀ i, LE (α i)] : ∀ _a _b : Σ i, α i, Prop | fiber (i : ι) (a b : α i) : a ≤ b → Sigma.le ⟨i, a⟩ ⟨i, b⟩ #align sigma.le Sigma.le /-- Disjoint sum of orders. `⟨i, a⟩ < ⟨j, b⟩` iff `i = j` and `a < b`. -/ protected inductive lt [∀ i, LT (α i)] : ∀ _a _b : Σi, α i, Prop | fiber (i : ι) (a b : α i) : a < b → Sigma.lt ⟨i, a⟩ ⟨i, b⟩ #align sigma.lt Sigma.lt protected instance LE [∀ i, LE (α i)] : LE (Σi, α i) where le := Sigma.le protected instance LT [∀ i, LT (α i)] : LT (Σi, α i) where lt := Sigma.lt @[simp] theorem mk_le_mk_iff [∀ i, LE (α i)] {i : ι} {a b : α i} : (⟨i, a⟩ : Sigma α) ≤ ⟨i, b⟩ ↔ a ≤ b := ⟨fun ⟨_, _, _, h⟩ => h, Sigma.le.fiber _ _ _⟩ #align sigma.mk_le_mk_iff Sigma.mk_le_mk_iff @[simp] theorem mk_lt_mk_iff [∀ i, LT (α i)] {i : ι} {a b : α i} : (⟨i, a⟩ : Sigma α) < ⟨i, b⟩ ↔ a < b := ⟨fun ⟨_, _, _, h⟩ => h, Sigma.lt.fiber _ _ _⟩ #align sigma.mk_lt_mk_iff Sigma.mk_lt_mk_iff theorem le_def [∀ i, LE (α i)] {a b : Σi, α i} : a ≤ b ↔ ∃ h : a.1 = b.1, h.rec a.2 ≤ b.2 := by constructor · rintro ⟨i, a, b, h⟩ exact ⟨rfl, h⟩ · obtain ⟨i, a⟩ := a obtain ⟨j, b⟩ := b rintro ⟨rfl : i = j, h⟩ exact le.fiber _ _ _ h #align sigma.le_def Sigma.le_def
Mathlib/Data/Sigma/Order.lean
89
96
theorem lt_def [∀ i, LT (α i)] {a b : Σi, α i} : a < b ↔ ∃ h : a.1 = b.1, h.rec a.2 < b.2 := by
constructor · rintro ⟨i, a, b, h⟩ exact ⟨rfl, h⟩ · obtain ⟨i, a⟩ := a obtain ⟨j, b⟩ := b rintro ⟨rfl : i = j, h⟩ exact lt.fiber _ _ _ h
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.List.Cycle import Mathlib.GroupTheory.Perm.Cycle.Type import Mathlib.GroupTheory.Perm.List #align_import group_theory.perm.cycle.concrete from "leanprover-community/mathlib"@"00638177efd1b2534fc5269363ebf42a7871df9a" /-! # Properties of cyclic permutations constructed from lists/cycles In the following, `{α : Type*} [Fintype α] [DecidableEq α]`. ## Main definitions * `Cycle.formPerm`: the cyclic permutation created by looping over a `Cycle α` * `Equiv.Perm.toList`: the list formed by iterating application of a permutation * `Equiv.Perm.toCycle`: the cycle formed by iterating application of a permutation * `Equiv.Perm.isoCycle`: the equivalence between cyclic permutations `f : Perm α` and the terms of `Cycle α` that correspond to them * `Equiv.Perm.isoCycle'`: the same equivalence as `Equiv.Perm.isoCycle` but with evaluation via choosing over fintypes * The notation `c[1, 2, 3]` to emulate notation of cyclic permutations `(1 2 3)` * A `Repr` instance for any `Perm α`, by representing the `Finset` of `Cycle α` that correspond to the cycle factors. ## Main results * `List.isCycle_formPerm`: a nontrivial list without duplicates, when interpreted as a permutation, is cyclic * `Equiv.Perm.IsCycle.existsUnique_cycle`: there is only one nontrivial `Cycle α` corresponding to each cyclic `f : Perm α` ## Implementation details The forward direction of `Equiv.Perm.isoCycle'` uses `Fintype.choose` of the uniqueness result, relying on the `Fintype` instance of a `Cycle.nodup` subtype. It is unclear if this works faster than the `Equiv.Perm.toCycle`, which relies on recursion over `Finset.univ`. Running `#eval` on even a simple noncyclic permutation `c[(1 : Fin 7), 2, 3] * c[0, 5]` to show it takes a long time. TODO: is this because computing the cycle factors is slow? -/ open Equiv Equiv.Perm List variable {α : Type*} namespace List variable [DecidableEq α] {l l' : List α}
Mathlib/GroupTheory/Perm/Cycle/Concrete.lean
58
70
theorem formPerm_disjoint_iff (hl : Nodup l) (hl' : Nodup l') (hn : 2 ≤ l.length) (hn' : 2 ≤ l'.length) : Perm.Disjoint (formPerm l) (formPerm l') ↔ l.Disjoint l' := by
rw [disjoint_iff_eq_or_eq, List.Disjoint] constructor · rintro h x hx hx' specialize h x rw [formPerm_apply_mem_eq_self_iff _ hl _ hx, formPerm_apply_mem_eq_self_iff _ hl' _ hx'] at h omega · intro h x by_cases hx : x ∈ l on_goal 1 => by_cases hx' : x ∈ l' · exact (h hx hx').elim all_goals have := formPerm_eq_self_of_not_mem _ _ ‹_›; tauto
/- Copyright (c) 2022 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.Algebra.IsPrimePow import Mathlib.NumberTheory.ArithmeticFunction import Mathlib.Analysis.SpecialFunctions.Log.Basic #align_import number_theory.von_mangoldt from "leanprover-community/mathlib"@"c946d6097a6925ad16d7ec55677bbc977f9846de" /-! # The von Mangoldt Function In this file we define the von Mangoldt function: the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. ## Main Results The main definition for this file is - `ArithmeticFunction.vonMangoldt`: The von Mangoldt function `Λ`. We then prove the classical summation property of the von Mangoldt function in `ArithmeticFunction.vonMangoldt_sum`, that `∑ i ∈ n.divisors, Λ i = Real.log n`, and use this to deduce alternative expressions for the von Mangoldt function via Möbius inversion, see `ArithmeticFunction.sum_moebius_mul_log_eq`. ## Notation We use the standard notation `Λ` to represent the von Mangoldt function. It is accessible in the locales `ArithmeticFunction` (like the notations for other arithmetic functions) and also in the locale `ArithmeticFunction.vonMangoldt`. -/ namespace ArithmeticFunction open Finset Nat open scoped ArithmeticFunction /-- `log` as an arithmetic function `ℕ → ℝ`. Note this is in the `ArithmeticFunction` namespace to indicate that it is bundled as an `ArithmeticFunction` rather than being the usual real logarithm. -/ noncomputable def log : ArithmeticFunction ℝ := ⟨fun n => Real.log n, by simp⟩ #align nat.arithmetic_function.log ArithmeticFunction.log @[simp] theorem log_apply {n : ℕ} : log n = Real.log n := rfl #align nat.arithmetic_function.log_apply ArithmeticFunction.log_apply /-- The `vonMangoldt` function is the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. In the case when `n` is a prime power, `min_fac` will give the appropriate prime, as it is the smallest prime factor. In the `ArithmeticFunction` locale, we have the notation `Λ` for this function. This is also available in the `ArithmeticFunction.vonMangoldt` locale, allowing for selective access to the notation. -/ noncomputable def vonMangoldt : ArithmeticFunction ℝ := ⟨fun n => if IsPrimePow n then Real.log (minFac n) else 0, if_neg not_isPrimePow_zero⟩ #align nat.arithmetic_function.von_mangoldt ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction] notation "Λ" => ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction.vonMangoldt] notation "Λ" => ArithmeticFunction.vonMangoldt theorem vonMangoldt_apply {n : ℕ} : Λ n = if IsPrimePow n then Real.log (minFac n) else 0 := rfl #align nat.arithmetic_function.von_mangoldt_apply ArithmeticFunction.vonMangoldt_apply @[simp]
Mathlib/NumberTheory/VonMangoldt.lean
79
79
theorem vonMangoldt_apply_one : Λ 1 = 0 := by
simp [vonMangoldt_apply]
/- Copyright (c) 2019 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.GeomSum import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Data.Nat.Bitwise import Mathlib.Data.Nat.Log import Mathlib.Data.Nat.Prime import Mathlib.Data.Nat.Digits import Mathlib.RingTheory.Multiplicity #align_import data.nat.multiplicity from "leanprover-community/mathlib"@"ceb887ddf3344dab425292e497fa2af91498437c" /-! # Natural number multiplicity This file contains lemmas about the multiplicity function (the maximum prime power dividing a number) when applied to naturals, in particular calculating it for factorials and binomial coefficients. ## Multiplicity calculations * `Nat.Prime.multiplicity_factorial`: Legendre's Theorem. The multiplicity of `p` in `n!` is `n / p + ... + n / p ^ b` for any `b` such that `n / p ^ (b + 1) = 0`. See `padicValNat_factorial` for this result stated in the language of `p`-adic valuations and `sub_one_mul_padicValNat_factorial` for a related result. * `Nat.Prime.multiplicity_factorial_mul`: The multiplicity of `p` in `(p * n)!` is `n` more than that of `n!`. * `Nat.Prime.multiplicity_choose`: Kummer's Theorem. The multiplicity of `p` in `n.choose k` is the number of carries when `k` and `n - k` are added in base `p`. See `padicValNat_choose` for the same result but stated in the language of `p`-adic valuations and `sub_one_mul_padicValNat_choose_eq_sub_sum_digits` for a related result. ## Other declarations * `Nat.multiplicity_eq_card_pow_dvd`: The multiplicity of `m` in `n` is the number of positive natural numbers `i` such that `m ^ i` divides `n`. * `Nat.multiplicity_two_factorial_lt`: The multiplicity of `2` in `n!` is strictly less than `n`. * `Nat.Prime.multiplicity_something`: Specialization of `multiplicity.something` to a prime in the naturals. Avoids having to provide `p ≠ 1` and other trivialities, along with translating between `Prime` and `Nat.Prime`. ## Tags Legendre, p-adic -/ open Finset Nat multiplicity open Nat namespace Nat /-- The multiplicity of `m` in `n` is the number of positive natural numbers `i` such that `m ^ i` divides `n`. This set is expressed by filtering `Ico 1 b` where `b` is any bound greater than `log m n`. -/
Mathlib/Data/Nat/Multiplicity.lean
61
77
theorem multiplicity_eq_card_pow_dvd {m n b : ℕ} (hm : m ≠ 1) (hn : 0 < n) (hb : log m n < b) : multiplicity m n = ↑((Finset.Ico 1 b).filter fun i => m ^ i ∣ n).card := calc multiplicity m n = ↑(Ico 1 <| (multiplicity m n).get (finite_nat_iff.2 ⟨hm, hn⟩) + 1).card := by
simp _ = ↑((Finset.Ico 1 b).filter fun i => m ^ i ∣ n).card := congr_arg _ <| congr_arg card <| Finset.ext fun i => by rw [mem_filter, mem_Ico, mem_Ico, Nat.lt_succ_iff, ← @PartENat.coe_le_coe i, PartENat.natCast_get, ← pow_dvd_iff_le_multiplicity, and_right_comm] refine (and_iff_left_of_imp fun h => lt_of_le_of_lt ?_ hb).symm cases' m with m · rw [zero_pow, zero_dvd_iff] at h exacts [(hn.ne' h.2).elim, one_le_iff_ne_zero.1 h.1] exact le_log_of_pow_le (one_lt_iff_ne_zero_and_ne_one.2 ⟨m.succ_ne_zero, hm⟩) (le_of_dvd hn h.2)
/- Copyright (c) 2022 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Analysis.Complex.AbsMax import Mathlib.Analysis.Complex.RemovableSingularity #align_import analysis.complex.schwarz from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b" /-! # Schwarz lemma In this file we prove several versions of the Schwarz lemma. * `Complex.norm_deriv_le_div_of_mapsTo_ball`, `Complex.abs_deriv_le_div_of_mapsTo_ball`: if `f : ℂ → E` sends an open disk with center `c` and a positive radius `R₁` to an open ball with center `f c` and radius `R₂`, then the absolute value of the derivative of `f` at `c` is at most the ratio `R₂ / R₁`; * `Complex.dist_le_div_mul_dist_of_mapsTo_ball`: if `f : ℂ → E` sends an open disk with center `c` and radius `R₁` to an open disk with center `f c` and radius `R₂`, then for any `z` in the former disk we have `dist (f z) (f c) ≤ (R₂ / R₁) * dist z c`; * `Complex.abs_deriv_le_one_of_mapsTo_ball`: if `f : ℂ → ℂ` sends an open disk of positive radius to itself and the center of this disk to itself, then the absolute value of the derivative of `f` at the center of this disk is at most `1`; * `Complex.dist_le_dist_of_mapsTo_ball_self`: if `f : ℂ → ℂ` sends an open disk to itself and the center `c` of this disk to itself, then for any point `z` of this disk we have `dist (f z) c ≤ dist z c`; * `Complex.abs_le_abs_of_mapsTo_ball_self`: if `f : ℂ → ℂ` sends an open disk with center `0` to itself, then for any point `z` of this disk we have `abs (f z) ≤ abs z`. ## Implementation notes We prove some versions of the Schwarz lemma for a map `f : ℂ → E` taking values in any normed space over complex numbers. ## TODO * Prove that these inequalities are strict unless `f` is an affine map. * Prove that any diffeomorphism of the unit disk to itself is a Möbius map. ## Tags Schwarz lemma -/ open Metric Set Function Filter TopologicalSpace open scoped Topology namespace Complex section Space variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {R R₁ R₂ : ℝ} {f : ℂ → E} {c z z₀ : ℂ} /-- An auxiliary lemma for `Complex.norm_dslope_le_div_of_mapsTo_ball`. -/
Mathlib/Analysis/Complex/Schwarz.lean
65
88
theorem schwarz_aux {f : ℂ → ℂ} (hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) : ‖dslope f c z‖ ≤ R₂ / R₁ := by
have hR₁ : 0 < R₁ := nonempty_ball.1 ⟨z, hz⟩ suffices ∀ᶠ r in 𝓝[<] R₁, ‖dslope f c z‖ ≤ R₂ / r by refine ge_of_tendsto ?_ this exact (tendsto_const_nhds.div tendsto_id hR₁.ne').mono_left nhdsWithin_le_nhds rw [mem_ball] at hz filter_upwards [Ioo_mem_nhdsWithin_Iio ⟨hz, le_rfl⟩] with r hr have hr₀ : 0 < r := dist_nonneg.trans_lt hr.1 replace hd : DiffContOnCl ℂ (dslope f c) (ball c r) := by refine DifferentiableOn.diffContOnCl ?_ rw [closure_ball c hr₀.ne'] exact ((differentiableOn_dslope <| ball_mem_nhds _ hR₁).mpr hd).mono (closedBall_subset_ball hr.2) refine norm_le_of_forall_mem_frontier_norm_le isBounded_ball hd ?_ ?_ · rw [frontier_ball c hr₀.ne'] intro z hz have hz' : z ≠ c := ne_of_mem_sphere hz hr₀.ne' rw [dslope_of_ne _ hz', slope_def_module, norm_smul, norm_inv, mem_sphere_iff_norm.1 hz, ← div_eq_inv_mul, div_le_div_right hr₀, ← dist_eq_norm] exact le_of_lt (h_maps (mem_ball.2 (by rw [mem_sphere.1 hz]; exact hr.2))) · rw [closure_ball c hr₀.ne', mem_closedBall] exact hr.1.le
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Control.Applicative import Mathlib.Control.Traversable.Basic #align_import control.traversable.lemmas from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" /-! # Traversing collections This file proves basic properties of traversable and applicative functors and defines `PureTransformation F`, the natural applicative transformation from the identity functor to `F`. ## References Inspired by [The Essence of the Iterator Pattern][gibbons2009]. -/ universe u open LawfulTraversable open Function hiding comp open Functor attribute [functor_norm] LawfulTraversable.naturality attribute [simp] LawfulTraversable.id_traverse namespace Traversable variable {t : Type u → Type u} variable [Traversable t] [LawfulTraversable t] variable (F G : Type u → Type u) variable [Applicative F] [LawfulApplicative F] variable [Applicative G] [LawfulApplicative G] variable {α β γ : Type u} variable (g : α → F β) variable (h : β → G γ) variable (f : β → γ) /-- The natural applicative transformation from the identity functor to `F`, defined by `pure : Π {α}, α → F α`. -/ def PureTransformation : ApplicativeTransformation Id F where app := @pure F _ preserves_pure' x := rfl preserves_seq' f x := by simp only [map_pure, seq_pure] rfl #align traversable.pure_transformation Traversable.PureTransformation @[simp] theorem pureTransformation_apply {α} (x : id α) : PureTransformation F x = pure x := rfl #align traversable.pure_transformation_apply Traversable.pureTransformation_apply variable {F G} (x : t β) -- Porting note: need to specify `m/F/G := Id` because `id` no longer has a `Monad` instance theorem map_eq_traverse_id : map (f := t) f = traverse (m := Id) (pure ∘ f) := funext fun y => (traverse_eq_map_id f y).symm #align traversable.map_eq_traverse_id Traversable.map_eq_traverse_id theorem map_traverse (x : t α) : map f <$> traverse g x = traverse (map f ∘ g) x := by rw [map_eq_traverse_id f] refine (comp_traverse (pure ∘ f) g x).symm.trans ?_ congr; apply Comp.applicative_comp_id #align traversable.map_traverse Traversable.map_traverse
Mathlib/Control/Traversable/Lemmas.lean
76
80
theorem traverse_map (f : β → F γ) (g : α → β) (x : t α) : traverse f (g <$> x) = traverse (f ∘ g) x := by
rw [@map_eq_traverse_id t _ _ _ _ g] refine (comp_traverse (G := Id) f (pure ∘ g) x).symm.trans ?_ congr; apply Comp.applicative_id_comp
/- Copyright (c) 2023 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.MvPolynomial.Equiv import Mathlib.Algebra.Polynomial.Eval #align_import data.mv_polynomial.polynomial from "leanprover-community/mathlib"@"0b89934139d3be96f9dab477f10c20f9f93da580" /-! # Some lemmas relating polynomials and multivariable polynomials. -/ namespace MvPolynomial variable {R S σ : Type*} theorem polynomial_eval_eval₂ [CommSemiring R] [CommSemiring S] {x : S} (f : R →+* Polynomial S) (g : σ → Polynomial S) (p : MvPolynomial σ R) : Polynomial.eval x (eval₂ f g p) = eval₂ ((Polynomial.evalRingHom x).comp f) (fun s => Polynomial.eval x (g s)) p := by apply induction_on p · simp · intro p q hp hq simp [hp, hq] · intro p n hp simp [hp]
Mathlib/Algebra/MvPolynomial/Polynomial.lean
30
40
theorem eval_polynomial_eval_finSuccEquiv {n : ℕ} {x : Fin n → R} [CommSemiring R] (f : MvPolynomial (Fin (n + 1)) R) (q : MvPolynomial (Fin n) R) : (eval x) (Polynomial.eval q (finSuccEquiv R n f)) = eval (Fin.cases (eval x q) x) f := by
simp only [finSuccEquiv_apply, coe_eval₂Hom, polynomial_eval_eval₂, eval_eval₂] conv in RingHom.comp _ _ => refine @RingHom.ext _ _ _ _ _ (RingHom.id _) fun r => ?_ simp simp only [eval₂_id] congr funext i refine Fin.cases (by simp) (by simp) i
/- Copyright (c) 2019 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johan Commelin -/ import Mathlib.RingTheory.IntegralClosure #align_import field_theory.minpoly.basic from "leanprover-community/mathlib"@"df0098f0db291900600f32070f6abb3e178be2ba" /-! # Minimal polynomials This file defines the minimal polynomial of an element `x` of an `A`-algebra `B`, under the assumption that x is integral over `A`, and derives some basic properties such as irreducibility under the assumption `B` is a domain. -/ open scoped Classical open Polynomial Set Function variable {A B B' : Type*} section MinPolyDef variable (A) [CommRing A] [Ring B] [Algebra A B] /-- Suppose `x : B`, where `B` is an `A`-algebra. The minimal polynomial `minpoly A x` of `x` is a monic polynomial with coefficients in `A` of smallest degree that has `x` as its root, if such exists (`IsIntegral A x`) or zero otherwise. For example, if `V` is a `𝕜`-vector space for some field `𝕜` and `f : V →ₗ[𝕜] V` then the minimal polynomial of `f` is `minpoly 𝕜 f`. -/ noncomputable def minpoly (x : B) : A[X] := if hx : IsIntegral A x then degree_lt_wf.min _ hx else 0 #align minpoly minpoly end MinPolyDef namespace minpoly section Ring variable [CommRing A] [Ring B] [Ring B'] [Algebra A B] [Algebra A B'] variable {x : B} /-- A minimal polynomial is monic. -/ theorem monic (hx : IsIntegral A x) : Monic (minpoly A x) := by delta minpoly rw [dif_pos hx] exact (degree_lt_wf.min_mem _ hx).1 #align minpoly.monic minpoly.monic /-- A minimal polynomial is nonzero. -/ theorem ne_zero [Nontrivial A] (hx : IsIntegral A x) : minpoly A x ≠ 0 := (monic hx).ne_zero #align minpoly.ne_zero minpoly.ne_zero theorem eq_zero (hx : ¬IsIntegral A x) : minpoly A x = 0 := dif_neg hx #align minpoly.eq_zero minpoly.eq_zero
Mathlib/FieldTheory/Minpoly/Basic.lean
67
70
theorem algHom_eq (f : B →ₐ[A] B') (hf : Function.Injective f) (x : B) : minpoly A (f x) = minpoly A x := by
refine dif_ctx_congr (isIntegral_algHom_iff _ hf) (fun _ => ?_) fun _ => rfl simp_rw [← Polynomial.aeval_def, aeval_algHom, AlgHom.comp_apply, _root_.map_eq_zero_iff f hf]
/- Copyright (c) 2021 Jon Eugster. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jon Eugster, Eric Wieser -/ import Mathlib.Algebra.CharP.Defs import Mathlib.Algebra.FreeAlgebra import Mathlib.RingTheory.Localization.FractionRing #align_import algebra.char_p.algebra from "leanprover-community/mathlib"@"96782a2d6dcded92116d8ac9ae48efb41d46a27c" /-! # Characteristics of algebras In this file we describe the characteristic of `R`-algebras. In particular we are interested in the characteristic of free algebras over `R` and the fraction field `FractionRing R`. ## Main results - `charP_of_injective_algebraMap` If `R →+* A` is an injective algebra map then `A` has the same characteristic as `R`. Instances constructed from this result: - Any `FreeAlgebra R X` has the same characteristic as `R`. - The `FractionRing R` of an integral domain `R` has the same characteristic as `R`. -/ /-- If a ring homomorphism `R →+* A` is injective then `A` has the same characteristic as `R`. -/ theorem charP_of_injective_ringHom {R A : Type*} [NonAssocSemiring R] [NonAssocSemiring A] {f : R →+* A} (h : Function.Injective f) (p : ℕ) [CharP R p] : CharP A p where cast_eq_zero_iff' x := by rw [← CharP.cast_eq_zero_iff R p x, ← map_natCast f x, map_eq_zero_iff f h] /-- If the algebra map `R →+* A` is injective then `A` has the same characteristic as `R`. -/ theorem charP_of_injective_algebraMap {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] (h : Function.Injective (algebraMap R A)) (p : ℕ) [CharP R p] : CharP A p := charP_of_injective_ringHom h p #align char_p_of_injective_algebra_map charP_of_injective_algebraMap theorem charP_of_injective_algebraMap' (R A : Type*) [Field R] [Semiring A] [Algebra R A] [Nontrivial A] (p : ℕ) [CharP R p] : CharP A p := charP_of_injective_algebraMap (algebraMap R A).injective p #align char_p_of_injective_algebra_map' charP_of_injective_algebraMap' /-- If a ring homomorphism `R →+* A` is injective and `R` has characteristic zero then so does `A`. -/ theorem charZero_of_injective_ringHom {R A : Type*} [NonAssocSemiring R] [NonAssocSemiring A] {f : R →+* A} (h : Function.Injective f) [CharZero R] : CharZero A where cast_injective _ _ _ := CharZero.cast_injective <| h <| by simpa only [map_natCast f] /-- If the algebra map `R →+* A` is injective and `R` has characteristic zero then so does `A`. -/ theorem charZero_of_injective_algebraMap {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] (h : Function.Injective (algebraMap R A)) [CharZero R] : CharZero A := charZero_of_injective_ringHom h #align char_zero_of_injective_algebra_map charZero_of_injective_algebraMap /-- If `R →+* A` is injective, and `A` is of characteristic `p`, then `R` is also of characteristic `p`. Similar to `RingHom.charZero`. -/
Mathlib/Algebra/CharP/Algebra.lean
64
67
theorem RingHom.charP {R A : Type*} [NonAssocSemiring R] [NonAssocSemiring A] (f : R →+* A) (H : Function.Injective f) (p : ℕ) [CharP A p] : CharP R p := by
obtain ⟨q, h⟩ := CharP.exists R exact CharP.eq _ (charP_of_injective_ringHom H q) ‹CharP A p› ▸ h
/- 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.Order.BooleanAlgebra import Mathlib.Tactic.Common #align_import order.heyting.boundary from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" /-! # Co-Heyting boundary The boundary of an element of a co-Heyting algebra is the intersection of its Heyting negation with itself. The boundary in the co-Heyting algebra of closed sets coincides with the topological boundary. ## Main declarations * `Coheyting.boundary`: Co-Heyting boundary. `Coheyting.boundary a = a ⊓ ¬a` ## Notation `∂ a` is notation for `Coheyting.boundary a` in locale `Heyting`. -/ variable {α : Type*} namespace Coheyting variable [CoheytingAlgebra α] {a b : α} /-- The boundary of an element of a co-Heyting algebra is the intersection of its Heyting negation with itself. Note that this is always `⊥` for a boolean algebra. -/ def boundary (a : α) : α := a ⊓ ¬a #align coheyting.boundary Coheyting.boundary /-- The boundary of an element of a co-Heyting algebra. -/ scoped[Heyting] prefix:120 "∂ " => Coheyting.boundary -- Porting note: Should the notation be automatically included in the current scope? open Heyting -- Porting note: Should hnot be named hNot? theorem inf_hnot_self (a : α) : a ⊓ ¬a = ∂ a := rfl #align coheyting.inf_hnot_self Coheyting.inf_hnot_self theorem boundary_le : ∂ a ≤ a := inf_le_left #align coheyting.boundary_le Coheyting.boundary_le theorem boundary_le_hnot : ∂ a ≤ ¬a := inf_le_right #align coheyting.boundary_le_hnot Coheyting.boundary_le_hnot @[simp] theorem boundary_bot : ∂ (⊥ : α) = ⊥ := bot_inf_eq _ #align coheyting.boundary_bot Coheyting.boundary_bot @[simp] theorem boundary_top : ∂ (⊤ : α) = ⊥ := by rw [boundary, hnot_top, inf_bot_eq] #align coheyting.boundary_top Coheyting.boundary_top theorem boundary_hnot_le (a : α) : ∂ (¬a) ≤ ∂ a := (inf_comm _ _).trans_le <| inf_le_inf_right _ hnot_hnot_le #align coheyting.boundary_hnot_le Coheyting.boundary_hnot_le @[simp] theorem boundary_hnot_hnot (a : α) : ∂ (¬¬a) = ∂ (¬a) := by simp_rw [boundary, hnot_hnot_hnot, inf_comm] #align coheyting.boundary_hnot_hnot Coheyting.boundary_hnot_hnot @[simp]
Mathlib/Order/Heyting/Boundary.lean
76
76
theorem hnot_boundary (a : α) : ¬∂ a = ⊤ := by
rw [boundary, hnot_inf_distrib, sup_hnot_self]
/- Copyright (c) 2023 Richard M. Hill. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Richard M. Hill -/ import Mathlib.RingTheory.PowerSeries.Trunc import Mathlib.RingTheory.PowerSeries.Inverse import Mathlib.RingTheory.Derivation.Basic /-! # Definitions In this file we define an operation `derivative` (formal differentiation) on the ring of formal power series in one variable (over an arbitrary commutative semiring). Under suitable assumptions, we prove that two power series are equal if their derivatives are equal and their constant terms are equal. This will give us a simple tool for proving power series identities. For example, one can easily prove the power series identity $\exp ( \log (1+X)) = 1+X$ by differentiating twice. ## Main Definition - `PowerSeries.derivative R : Derivation R R⟦X⟧ R⟦X⟧` the formal derivative operation. This is abbreviated `d⁄dX R`. -/ namespace PowerSeries open Polynomial Derivation Nat section CommutativeSemiring variable {R} [CommSemiring R] /-- The formal derivative of a power series in one variable. This is defined here as a function, but will be packaged as a derivation `derivative` on `R⟦X⟧`. -/ noncomputable def derivativeFun (f : R⟦X⟧) : R⟦X⟧ := mk fun n ↦ coeff R (n + 1) f * (n + 1) theorem coeff_derivativeFun (f : R⟦X⟧) (n : ℕ) : coeff R n f.derivativeFun = coeff R (n + 1) f * (n + 1) := by rw [derivativeFun, coeff_mk] theorem derivativeFun_coe (f : R[X]) : (f : R⟦X⟧).derivativeFun = derivative f := by ext rw [coeff_derivativeFun, coeff_coe, coeff_coe, coeff_derivative] theorem derivativeFun_add (f g : R⟦X⟧) : derivativeFun (f + g) = derivativeFun f + derivativeFun g := by ext rw [coeff_derivativeFun, map_add, map_add, coeff_derivativeFun, coeff_derivativeFun, add_mul] theorem derivativeFun_C (r : R) : derivativeFun (C R r) = 0 := by ext n -- Note that `map_zero` didn't get picked up, apparently due to a missing `FunLike.coe` rw [coeff_derivativeFun, coeff_succ_C, zero_mul, (coeff R n).map_zero] theorem trunc_derivativeFun (f : R⟦X⟧) (n : ℕ) : trunc n f.derivativeFun = derivative (trunc (n + 1) f) := by ext d rw [coeff_trunc] split_ifs with h · have : d + 1 < n + 1 := succ_lt_succ_iff.2 h rw [coeff_derivativeFun, coeff_derivative, coeff_trunc, if_pos this] · have : ¬d + 1 < n + 1 := by rwa [succ_lt_succ_iff] rw [coeff_derivative, coeff_trunc, if_neg this, zero_mul] --A special case of `derivativeFun_mul`, used in its proof. private theorem derivativeFun_coe_mul_coe (f g : R[X]) : derivativeFun (f * g : R⟦X⟧) = f * derivative g + g * derivative f := by rw [← coe_mul, derivativeFun_coe, derivative_mul, add_comm, mul_comm _ g, ← coe_mul, ← coe_mul, Polynomial.coe_add] /-- **Leibniz rule for formal power series**. -/ theorem derivativeFun_mul (f g : R⟦X⟧) : derivativeFun (f * g) = f • g.derivativeFun + g • f.derivativeFun := by ext n have h₁ : n < n + 1 := lt_succ_self n have h₂ : n < n + 1 + 1 := Nat.lt_add_right _ h₁ rw [coeff_derivativeFun, map_add, coeff_mul_eq_coeff_trunc_mul_trunc _ _ (lt_succ_self _), smul_eq_mul, smul_eq_mul, coeff_mul_eq_coeff_trunc_mul_trunc₂ g f.derivativeFun h₂ h₁, coeff_mul_eq_coeff_trunc_mul_trunc₂ f g.derivativeFun h₂ h₁, trunc_derivativeFun, trunc_derivativeFun, ← map_add, ← derivativeFun_coe_mul_coe, coeff_derivativeFun] theorem derivativeFun_one : derivativeFun (1 : R⟦X⟧) = 0 := by rw [← map_one (C R), derivativeFun_C (1 : R)]
Mathlib/RingTheory/PowerSeries/Derivative.lean
90
92
theorem derivativeFun_smul (r : R) (f : R⟦X⟧) : derivativeFun (r • f) = r • derivativeFun f := by
rw [smul_eq_C_mul, smul_eq_C_mul, derivativeFun_mul, derivativeFun_C, smul_zero, add_zero, smul_eq_mul]
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Alex J. Best -/ import Mathlib.MeasureTheory.Group.Arithmetic #align_import measure_theory.group.pointwise from "leanprover-community/mathlib"@"66f7114a1d5cba41c47d417a034bbb2e96cf564a" /-! # Pointwise set operations on `MeasurableSet`s In this file we prove several versions of the following fact: if `s` is a measurable set, then so is `a • s`. Note that the pointwise product of two measurable sets need not be measurable, so there is no `MeasurableSet.mul` etc. -/ open Pointwise open Set @[to_additive] theorem MeasurableSet.const_smul {G α : Type*} [Group G] [MulAction G α] [MeasurableSpace G] [MeasurableSpace α] [MeasurableSMul G α] {s : Set α} (hs : MeasurableSet s) (a : G) : MeasurableSet (a • s) := by rw [← preimage_smul_inv] exact measurable_const_smul _ hs #align measurable_set.const_smul MeasurableSet.const_smul #align measurable_set.const_vadd MeasurableSet.const_vadd
Mathlib/MeasureTheory/Group/Pointwise.lean
32
36
theorem MeasurableSet.const_smul_of_ne_zero {G₀ α : Type*} [GroupWithZero G₀] [MulAction G₀ α] [MeasurableSpace G₀] [MeasurableSpace α] [MeasurableSMul G₀ α] {s : Set α} (hs : MeasurableSet s) {a : G₀} (ha : a ≠ 0) : MeasurableSet (a • s) := by
rw [← preimage_smul_inv₀ ha] exact measurable_const_smul _ hs
/- Copyright (c) 2020 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Topology.Basic import Mathlib.Order.UpperLower.Basic import Mathlib.Order.OmegaCompletePartialOrder #align_import topology.omega_complete_partial_order from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9" /-! # Scott Topological Spaces A type of topological spaces whose notion of continuity is equivalent to continuity in ωCPOs. ## Reference * https://ncatlab.org/nlab/show/Scott+topology -/ open Set OmegaCompletePartialOrder open scoped Classical universe u -- "Scott", "ωSup" set_option linter.uppercaseLean3 false namespace Scott /-- `x` is an `ω`-Sup of a chain `c` if it is the least upper bound of the range of `c`. -/ def IsωSup {α : Type u} [Preorder α] (c : Chain α) (x : α) : Prop := (∀ i, c i ≤ x) ∧ ∀ y, (∀ i, c i ≤ y) → x ≤ y #align Scott.is_ωSup Scott.IsωSup
Mathlib/Topology/OmegaCompletePartialOrder.lean
41
43
theorem isωSup_iff_isLUB {α : Type u} [Preorder α] {c : Chain α} {x : α} : IsωSup c x ↔ IsLUB (range c) x := by
simp [IsωSup, IsLUB, IsLeast, upperBounds, lowerBounds]
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.Algebra.CharP.Defs #align_import algebra.char_p.invertible from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Invertibility of elements given a characteristic This file includes some instances of `Invertible` for specific numbers in characteristic zero. Some more cases are given as a `def`, to be included only when needed. To construct instances for concrete numbers, `invertibleOfNonzero` is a useful definition. -/ variable {K : Type*} section Field variable [Field K] /-- A natural number `t` is invertible in a field `K` if the characteristic of `K` does not divide `t`. -/ def invertibleOfRingCharNotDvd {t : ℕ} (not_dvd : ¬ringChar K ∣ t) : Invertible (t : K) := invertibleOfNonzero fun h => not_dvd ((ringChar.spec K t).mp h) #align invertible_of_ring_char_not_dvd invertibleOfRingCharNotDvd
Mathlib/Algebra/CharP/Invertible.lean
32
34
theorem not_ringChar_dvd_of_invertible {t : ℕ} [Invertible (t : K)] : ¬ringChar K ∣ t := by
rw [← ringChar.spec, ← Ne] exact nonzero_of_invertible (t : K)
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics import Mathlib.NumberTheory.Liouville.Basic import Mathlib.Topology.Instances.Irrational #align_import number_theory.liouville.liouville_with from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8" /-! # Liouville numbers with a given exponent We say that a real number `x` is a Liouville number with exponent `p : ℝ` if there exists a real number `C` such that for infinitely many denominators `n` there exists a numerator `m` such that `x ≠ m / n` and `|x - m / n| < C / n ^ p`. A number is a Liouville number in the sense of `Liouville` if it is `LiouvilleWith` any real exponent, see `forall_liouvilleWith_iff`. * If `p ≤ 1`, then this condition is trivial. * If `1 < p ≤ 2`, then this condition is equivalent to `Irrational x`. The forward implication does not require `p ≤ 2` and is formalized as `LiouvilleWith.irrational`; the other implication follows from approximations by continued fractions and is not formalized yet. * If `p > 2`, then this is a non-trivial condition on irrational numbers. In particular, [Thue–Siegel–Roth theorem](https://en.wikipedia.org/wiki/Roth's_theorem) states that such numbers must be transcendental. In this file we define the predicate `LiouvilleWith` and prove some basic facts about this predicate. ## Tags Liouville number, irrational, irrationality exponent -/ open Filter Metric Real Set open scoped Filter Topology /-- We say that a real number `x` is a Liouville number with exponent `p : ℝ` if there exists a real number `C` such that for infinitely many denominators `n` there exists a numerator `m` such that `x ≠ m / n` and `|x - m / n| < C / n ^ p`. A number is a Liouville number in the sense of `Liouville` if it is `LiouvilleWith` any real exponent. -/ def LiouvilleWith (p x : ℝ) : Prop := ∃ C, ∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p #align liouville_with LiouvilleWith /-- For `p = 1` (hence, for any `p ≤ 1`), the condition `LiouvilleWith p x` is trivial. -/ theorem liouvilleWith_one (x : ℝ) : LiouvilleWith 1 x := by use 2 refine ((eventually_gt_atTop 0).mono fun n hn => ?_).frequently have hn' : (0 : ℝ) < n := by simpa have : x < ↑(⌊x * ↑n⌋ + 1) / ↑n := by rw [lt_div_iff hn', Int.cast_add, Int.cast_one]; exact Int.lt_floor_add_one _ refine ⟨⌊x * n⌋ + 1, this.ne, ?_⟩ rw [abs_sub_comm, abs_of_pos (sub_pos.2 this), rpow_one, sub_lt_iff_lt_add', add_div_eq_mul_add_div _ _ hn'.ne'] gcongr calc _ ≤ x * n + 1 := by push_cast; gcongr; apply Int.floor_le _ < x * n + 2 := by linarith #align liouville_with_one liouvilleWith_one namespace LiouvilleWith variable {p q x y : ℝ} {r : ℚ} {m : ℤ} {n : ℕ} /-- The constant `C` provided by the definition of `LiouvilleWith` can be made positive. We also add `1 ≤ n` to the list of assumptions about the denominator. While it is equivalent to the original statement, the case `n = 0` breaks many arguments. -/ theorem exists_pos (h : LiouvilleWith p x) : ∃ (C : ℝ) (_h₀ : 0 < C), ∃ᶠ n : ℕ in atTop, 1 ≤ n ∧ ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p := by rcases h with ⟨C, hC⟩ refine ⟨max C 1, zero_lt_one.trans_le <| le_max_right _ _, ?_⟩ refine ((eventually_ge_atTop 1).and_frequently hC).mono ?_ rintro n ⟨hle, m, hne, hlt⟩ refine ⟨hle, m, hne, hlt.trans_le ?_⟩ gcongr apply le_max_left #align liouville_with.exists_pos LiouvilleWith.exists_pos /-- If a number is Liouville with exponent `p`, then it is Liouville with any smaller exponent. -/
Mathlib/NumberTheory/Liouville/LiouvilleWith.lean
89
94
theorem mono (h : LiouvilleWith p x) (hle : q ≤ p) : LiouvilleWith q x := by
rcases h.exists_pos with ⟨C, hC₀, hC⟩ refine ⟨C, hC.mono ?_⟩; rintro n ⟨hn, m, hne, hlt⟩ refine ⟨m, hne, hlt.trans_le <| ?_⟩ gcongr exact_mod_cast hn
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.LinearAlgebra.Finsupp import Mathlib.RingTheory.Ideal.Over import Mathlib.RingTheory.Ideal.Prod import Mathlib.RingTheory.Ideal.MinimalPrime import Mathlib.RingTheory.Localization.Away.Basic import Mathlib.RingTheory.Nilpotent.Lemmas import Mathlib.Topology.Sets.Closeds import Mathlib.Topology.Sober #align_import algebraic_geometry.prime_spectrum.basic from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0" /-! # Prime spectrum of a commutative (semi)ring The prime spectrum of a commutative (semi)ring is the type of all prime ideals. It is naturally endowed with a topology: the Zariski topology. (It is also naturally endowed with a sheaf of rings, which is constructed in `AlgebraicGeometry.StructureSheaf`.) ## Main definitions * `PrimeSpectrum R`: The prime spectrum of a commutative (semi)ring `R`, i.e., the set of all prime ideals of `R`. * `zeroLocus s`: The zero locus of a subset `s` of `R` is the subset of `PrimeSpectrum R` consisting of all prime ideals that contain `s`. * `vanishingIdeal t`: The vanishing ideal of a subset `t` of `PrimeSpectrum R` is the intersection of points in `t` (viewed as prime ideals). ## Conventions We denote subsets of (semi)rings with `s`, `s'`, etc... whereas we denote subsets of prime spectra with `t`, `t'`, etc... ## Inspiration/contributors The contents of this file draw inspiration from <https://github.com/ramonfmir/lean-scheme> which has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau, and Chris Hughes (on an earlier repository). -/ noncomputable section open scoped Classical universe u v variable (R : Type u) (S : Type v) /-- The prime spectrum of a commutative (semi)ring `R` is the type of all prime ideals of `R`. It is naturally endowed with a topology (the Zariski topology), and a sheaf of commutative rings (see `AlgebraicGeometry.StructureSheaf`). It is a fundamental building block in algebraic geometry. -/ @[ext] structure PrimeSpectrum [CommSemiring R] where asIdeal : Ideal R IsPrime : asIdeal.IsPrime #align prime_spectrum PrimeSpectrum attribute [instance] PrimeSpectrum.IsPrime namespace PrimeSpectrum section CommSemiRing variable [CommSemiring R] [CommSemiring S] variable {R S} instance [Nontrivial R] : Nonempty <| PrimeSpectrum R := let ⟨I, hI⟩ := Ideal.exists_maximal R ⟨⟨I, hI.isPrime⟩⟩ /-- The prime spectrum of the zero ring is empty. -/ instance [Subsingleton R] : IsEmpty (PrimeSpectrum R) := ⟨fun x ↦ x.IsPrime.ne_top <| SetLike.ext' <| Subsingleton.eq_univ_of_nonempty x.asIdeal.nonempty⟩ #noalign prime_spectrum.punit variable (R S) /-- The map from the direct sum of prime spectra to the prime spectrum of a direct product. -/ @[simp] def primeSpectrumProdOfSum : Sum (PrimeSpectrum R) (PrimeSpectrum S) → PrimeSpectrum (R × S) | Sum.inl ⟨I, _⟩ => ⟨Ideal.prod I ⊤, Ideal.isPrime_ideal_prod_top⟩ | Sum.inr ⟨J, _⟩ => ⟨Ideal.prod ⊤ J, Ideal.isPrime_ideal_prod_top'⟩ #align prime_spectrum.prime_spectrum_prod_of_sum PrimeSpectrum.primeSpectrumProdOfSum /-- The prime spectrum of `R × S` is in bijection with the disjoint unions of the prime spectrum of `R` and the prime spectrum of `S`. -/ noncomputable def primeSpectrumProd : PrimeSpectrum (R × S) ≃ Sum (PrimeSpectrum R) (PrimeSpectrum S) := Equiv.symm <| Equiv.ofBijective (primeSpectrumProdOfSum R S) (by constructor · rintro (⟨I, hI⟩ | ⟨J, hJ⟩) (⟨I', hI'⟩ | ⟨J', hJ'⟩) h <;> simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h · simp only [h] · exact False.elim (hI.ne_top h.left) · exact False.elim (hJ.ne_top h.right) · simp only [h] · rintro ⟨I, hI⟩ rcases (Ideal.ideal_prod_prime I).mp hI with (⟨p, ⟨hp, rfl⟩⟩ | ⟨p, ⟨hp, rfl⟩⟩) · exact ⟨Sum.inl ⟨p, hp⟩, rfl⟩ · exact ⟨Sum.inr ⟨p, hp⟩, rfl⟩) #align prime_spectrum.prime_spectrum_prod PrimeSpectrum.primeSpectrumProd variable {R S} @[simp] theorem primeSpectrumProd_symm_inl_asIdeal (x : PrimeSpectrum R) : ((primeSpectrumProd R S).symm <| Sum.inl x).asIdeal = Ideal.prod x.asIdeal ⊤ := by cases x rfl #align prime_spectrum.prime_spectrum_prod_symm_inl_as_ideal PrimeSpectrum.primeSpectrumProd_symm_inl_asIdeal @[simp]
Mathlib/AlgebraicGeometry/PrimeSpectrum/Basic.lean
123
126
theorem primeSpectrumProd_symm_inr_asIdeal (x : PrimeSpectrum S) : ((primeSpectrumProd R S).symm <| Sum.inr x).asIdeal = Ideal.prod ⊤ x.asIdeal := by
cases x rfl
/- 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, Bryan Gin-ge Chen -/ import Mathlib.Order.Heyting.Basic #align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4" /-! # (Generalized) Boolean algebras A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras generalize the (classical) logic of propositions and the lattice of subsets of a set. Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary (not-necessarily-finite) type `α`. `GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`). For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra` so that it is also bundled with a `\` operator. (A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do not yet have relative complements for arbitrary intervals, as we do not even have lattice intervals.) ## Main declarations * `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras * `BooleanAlgebra`: a type class for Boolean algebras. * `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop` ## Implementation notes The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in `GeneralizedBooleanAlgebra` are taken from [Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations). [Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution `x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`. ## References * <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations> * [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935] * [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011] ## Tags generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl -/ open Function OrderDual universe u v variable {α : Type u} {β : Type*} {w x y z : α} /-! ### Generalized Boolean algebras Some of the lemmas in this section are from: * [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011] * <https://ncatlab.org/nlab/show/relative+complement> * <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf> -/ /-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and `(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`. This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary (not-necessarily-`Fintype`) `α`. -/ class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where /-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/ sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a /-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/ inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥ #align generalized_boolean_algebra GeneralizedBooleanAlgebra -- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`, -- however we'd need another type class for lattices with bot, and all the API for that. section GeneralizedBooleanAlgebra variable [GeneralizedBooleanAlgebra α] @[simp] theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x := GeneralizedBooleanAlgebra.sup_inf_sdiff _ _ #align sup_inf_sdiff sup_inf_sdiff @[simp] theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ := GeneralizedBooleanAlgebra.inf_inf_sdiff _ _ #align inf_inf_sdiff inf_inf_sdiff @[simp] theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff] #align sup_sdiff_inf sup_sdiff_inf @[simp] theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff] #align inf_sdiff_inf inf_sdiff_inf -- see Note [lower instance priority] instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α where __ := GeneralizedBooleanAlgebra.toBot bot_le a := by rw [← inf_inf_sdiff a a, inf_assoc] exact inf_le_left #align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) := disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le #align disjoint_inf_sdiff disjoint_inf_sdiff -- TODO: in distributive lattices, relative complements are unique when they exist
Mathlib/Order/BooleanAlgebra.lean
127
132
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm] rw [sup_comm] at s conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm] rw [inf_comm] at i exact (eq_of_inf_eq_sup_eq i s).symm
/- Copyright (c) 2023 Michael Stoll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Stoll -/ import Mathlib.NumberTheory.DirichletCharacter.Bounds import Mathlib.NumberTheory.EulerProduct.Basic import Mathlib.NumberTheory.LSeries.Basic import Mathlib.NumberTheory.LSeries.RiemannZeta /-! # The Euler Product for the Riemann Zeta Function and Dirichlet L-Series The first main result of this file is the Euler Product formula for the Riemann ζ function $$\prod_p \frac{1}{1 - p^{-s}} = \lim_{n \to \infty} \prod_{p < n} \frac{1}{1 - p^{-s}} = \zeta(s)$$ for $s$ with real part $> 1$ ($p$ runs through the primes). `riemannZeta_eulerProduct` is the second equality above. There are versions `riemannZeta_eulerProduct_hasProd` and `riemannZeta_eulerProduct_tprod` in terms of `HasProd` and `tprod`, respectively. The second result is `dirichletLSeries_eulerProduct` (with variants `dirichletLSeries_eulerProduct_hasProd` and `dirichletLSeries_eulerProduct_tprod`), which is the analogous statement for Dirichlet L-series. -/ open Complex variable {s : ℂ} /-- When `s ≠ 0`, the map `n ↦ n^(-s)` is completely multiplicative and vanishes at zero. -/ noncomputable def riemannZetaSummandHom (hs : s ≠ 0) : ℕ →*₀ ℂ where toFun n := (n : ℂ) ^ (-s) map_zero' := by simp [hs] map_one' := by simp map_mul' m n := by simpa only [Nat.cast_mul, ofReal_natCast] using mul_cpow_ofReal_nonneg m.cast_nonneg n.cast_nonneg _ /-- When `χ` is a Dirichlet character and `s ≠ 0`, the map `n ↦ χ n * n^(-s)` is completely multiplicative and vanishes at zero. -/ noncomputable def dirichletSummandHom {n : ℕ} (χ : DirichletCharacter ℂ n) (hs : s ≠ 0) : ℕ →*₀ ℂ where toFun n := χ n * (n : ℂ) ^ (-s) map_zero' := by simp [hs] map_one' := by simp map_mul' m n := by simp_rw [← ofReal_natCast] simpa only [Nat.cast_mul, IsUnit.mul_iff, not_and, map_mul, ofReal_mul, mul_cpow_ofReal_nonneg m.cast_nonneg n.cast_nonneg _] using mul_mul_mul_comm .. /-- When `s.re > 1`, the map `n ↦ n^(-s)` is norm-summable. -/ lemma summable_riemannZetaSummand (hs : 1 < s.re) : Summable (fun n ↦ ‖riemannZetaSummandHom (ne_zero_of_one_lt_re hs) n‖) := by simp only [riemannZetaSummandHom, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] convert Real.summable_nat_rpow_inv.mpr hs with n rw [← ofReal_natCast, Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_nonneg (Nat.cast_nonneg n) <| re_neg_ne_zero_of_one_lt_re hs, neg_re, Real.rpow_neg <| Nat.cast_nonneg n] lemma tsum_riemannZetaSummand (hs : 1 < s.re) : ∑' (n : ℕ), riemannZetaSummandHom (ne_zero_of_one_lt_re hs) n = riemannZeta s := by have hsum := summable_riemannZetaSummand hs rw [zeta_eq_tsum_one_div_nat_add_one_cpow hs, tsum_eq_zero_add hsum.of_norm, map_zero, zero_add] simp only [riemannZetaSummandHom, cpow_neg, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, Nat.cast_add, Nat.cast_one, one_div] /-- When `s.re > 1`, the map `n ↦ χ(n) * n^(-s)` is norm-summable. -/ lemma summable_dirichletSummand {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : 1 < s.re) : Summable (fun n ↦ ‖dirichletSummandHom χ (ne_zero_of_one_lt_re hs) n‖) := by simp only [dirichletSummandHom, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, norm_mul] exact (summable_riemannZetaSummand hs).of_nonneg_of_le (fun _ ↦ by positivity) (fun n ↦ mul_le_of_le_one_left (norm_nonneg _) <| χ.norm_le_one n) open scoped LSeries.notation in lemma tsum_dirichletSummand {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : 1 < s.re) : ∑' (n : ℕ), dirichletSummandHom χ (ne_zero_of_one_lt_re hs) n = L ↗χ s := by simp only [LSeries, LSeries.term, dirichletSummandHom] refine tsum_congr (fun n ↦ ?_) rcases eq_or_ne n 0 with rfl | hn · simp only [map_zero, ↓reduceIte] · simp only [cpow_neg, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, hn, ↓reduceIte, Field.div_eq_mul_inv] open Filter Nat Topology EulerProduct /-- The Euler product for the Riemann ζ function, valid for `s.re > 1`. This version is stated in terms of `HasProd`. -/ theorem riemannZeta_eulerProduct_hasProd (hs : 1 < s.re) : HasProd (fun p : Primes ↦ (1 - (p : ℂ) ^ (-s))⁻¹) (riemannZeta s) := by rw [← tsum_riemannZetaSummand hs] apply eulerProduct_completely_multiplicative_hasProd <| summable_riemannZetaSummand hs /-- The Euler product for the Riemann ζ function, valid for `s.re > 1`. This version is stated in terms of `tprod`. -/ theorem riemannZeta_eulerProduct_tprod (hs : 1 < s.re) : ∏' p : Primes, (1 - (p : ℂ) ^ (-s))⁻¹ = riemannZeta s := (riemannZeta_eulerProduct_hasProd hs).tprod_eq /-- The Euler product for the Riemann ζ function, valid for `s.re > 1`. This version is stated in the form of convergence of finite partial products. -/
Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean
104
108
theorem riemannZeta_eulerProduct (hs : 1 < s.re) : Tendsto (fun n : ℕ ↦ ∏ p ∈ primesBelow n, (1 - (p : ℂ) ^ (-s))⁻¹) atTop (𝓝 (riemannZeta s)) := by
rw [← tsum_riemannZetaSummand hs] apply eulerProduct_completely_multiplicative <| summable_riemannZetaSummand hs
/- 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.RingTheory.PrincipalIdealDomain #align_import ring_theory.bezout from "leanprover-community/mathlib"@"6623e6af705e97002a9054c1c05a980180276fc1" /-! # Bézout rings A Bézout ring (Bezout ring) is a ring whose finitely generated ideals are principal. Notable examples include principal ideal rings, valuation rings, and the ring of algebraic integers. ## Main results - `IsBezout.iff_span_pair_isPrincipal`: It suffices to verify every `span {x, y}` is principal. - `IsBezout.TFAE`: For a Bézout domain, noetherian ↔ PID ↔ UFD ↔ ACCP -/ universe u v variable {R : Type u} [CommRing R] namespace IsBezout
Mathlib/RingTheory/Bezout.lean
30
39
theorem iff_span_pair_isPrincipal : IsBezout R ↔ ∀ x y : R, (Ideal.span {x, y} : Ideal R).IsPrincipal := by
classical constructor · intro H x y; infer_instance · intro H constructor apply Submodule.fg_induction · exact fun _ => ⟨⟨_, rfl⟩⟩ · rintro _ _ ⟨⟨x, rfl⟩⟩ ⟨⟨y, rfl⟩⟩; rw [← Submodule.span_insert]; exact H _ _
/- Copyright (c) 2022 Chris Birkbeck. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Birkbeck -/ import Mathlib.Data.Complex.Basic import Mathlib.MeasureTheory.Integral.CircleIntegral #align_import measure_theory.integral.circle_transform from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15" /-! # Circle integral transform In this file we define the circle integral transform of a function `f` with complex domain. This is defined as $(2πi)^{-1}\frac{f(x)}{x-w}$ where `x` moves along a circle. We then prove some basic facts about these functions. These results are useful for proving that the uniform limit of a sequence of holomorphic functions is holomorphic. -/ open Set MeasureTheory Metric Filter Function open scoped Interval Real noncomputable section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] (R : ℝ) (z w : ℂ) namespace Complex /-- Given a function `f : ℂ → E`, `circleTransform R z w f` is the function mapping `θ` to `(2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • ((circleMap z R θ) - w)⁻¹ • f (circleMap z R θ)`. If `f` is differentiable and `w` is in the interior of the ball, then the integral from `0` to `2 * π` of this gives the value `f(w)`. -/ def circleTransform (f : ℂ → E) (θ : ℝ) : E := (2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • (circleMap z R θ - w)⁻¹ • f (circleMap z R θ) #align complex.circle_transform Complex.circleTransform /-- The derivative of `circleTransform` w.r.t `w`. -/ def circleTransformDeriv (f : ℂ → E) (θ : ℝ) : E := (2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • ((circleMap z R θ - w) ^ 2)⁻¹ • f (circleMap z R θ) #align complex.circle_transform_deriv Complex.circleTransformDeriv theorem circleTransformDeriv_periodic (f : ℂ → E) : Periodic (circleTransformDeriv R z w f) (2 * π) := by have := periodic_circleMap simp_rw [Periodic] at * intro x simp_rw [circleTransformDeriv, this] congr 2 simp [this] #align complex.circle_transform_deriv_periodic Complex.circleTransformDeriv_periodic theorem circleTransformDeriv_eq (f : ℂ → E) : circleTransformDeriv R z w f = fun θ => (circleMap z R θ - w)⁻¹ • circleTransform R z w f θ := by ext simp_rw [circleTransformDeriv, circleTransform, ← mul_smul, ← mul_assoc] ring_nf rw [inv_pow] congr ring #align complex.circle_transform_deriv_eq Complex.circleTransformDeriv_eq theorem integral_circleTransform (f : ℂ → E) : (∫ θ : ℝ in (0)..2 * π, circleTransform R z w f θ) = (2 * ↑π * I)⁻¹ • ∮ z in C(z, R), (z - w)⁻¹ • f z := by simp_rw [circleTransform, circleIntegral, deriv_circleMap, circleMap] simp #align complex.integral_circle_transform Complex.integral_circleTransform theorem continuous_circleTransform {R : ℝ} (hR : 0 < R) {f : ℂ → E} {z w : ℂ} (hf : ContinuousOn f <| sphere z R) (hw : w ∈ ball z R) : Continuous (circleTransform R z w f) := by apply_rules [Continuous.smul, continuous_const] · simp_rw [deriv_circleMap] apply_rules [Continuous.mul, continuous_circleMap 0 R, continuous_const] · exact continuous_circleMap_inv hw · apply ContinuousOn.comp_continuous hf (continuous_circleMap z R) exact fun _ => (circleMap_mem_sphere _ hR.le) _ #align complex.continuous_circle_transform Complex.continuous_circleTransform theorem continuous_circleTransformDeriv {R : ℝ} (hR : 0 < R) {f : ℂ → E} {z w : ℂ} (hf : ContinuousOn f (sphere z R)) (hw : w ∈ ball z R) : Continuous (circleTransformDeriv R z w f) := by rw [circleTransformDeriv_eq] exact (continuous_circleMap_inv hw).smul (continuous_circleTransform hR hf hw) #align complex.continuous_circle_transform_deriv Complex.continuous_circleTransformDeriv /-- A useful bound for circle integrals (with complex codomain)-/ def circleTransformBoundingFunction (R : ℝ) (z : ℂ) (w : ℂ × ℝ) : ℂ := circleTransformDeriv R z w.1 (fun _ => 1) w.2 #align complex.circle_transform_bounding_function Complex.circleTransformBoundingFunction
Mathlib/MeasureTheory/Integral/CircleTransform.lean
98
106
theorem continuousOn_prod_circle_transform_function {R r : ℝ} (hr : r < R) {z : ℂ} : ContinuousOn (fun w : ℂ × ℝ => (circleMap z R w.snd - w.fst)⁻¹ ^ 2) (closedBall z r ×ˢ univ) := by
simp_rw [← one_div] apply_rules [ContinuousOn.pow, ContinuousOn.div, continuousOn_const] · exact ((continuous_circleMap z R).comp_continuousOn continuousOn_snd).sub continuousOn_fst · rintro ⟨a, b⟩ ⟨ha, -⟩ have ha2 : a ∈ ball z R := closedBall_subset_ball hr ha exact sub_ne_zero.2 (circleMap_ne_mem_ball ha2 b)
/- 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.MeasureTheory.Measure.Haar.Basic import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import measure_theory.measure.haar.of_basis from "leanprover-community/mathlib"@"92bd7b1ffeb306a89f450bee126ddd8a284c259d" /-! # Additive Haar measure constructed from a basis Given a basis of a finite-dimensional real vector space, we define the corresponding Lebesgue measure, which gives measure `1` to the parallelepiped spanned by the basis. ## Main definitions * `parallelepiped v` is the parallelepiped spanned by a finite family of vectors. * `Basis.parallelepiped` is the parallelepiped associated to a basis, seen as a compact set with nonempty interior. * `Basis.addHaar` is the Lebesgue measure associated to a basis, giving measure `1` to the corresponding parallelepiped. In particular, we declare a `MeasureSpace` instance on any finite-dimensional inner product space, by using the Lebesgue measure associated to some orthonormal basis (which is in fact independent of the basis). -/ open Set TopologicalSpace MeasureTheory MeasureTheory.Measure FiniteDimensional open scoped Pointwise noncomputable section variable {ι ι' E F : Type*} section Fintype variable [Fintype ι] [Fintype ι'] section AddCommGroup variable [AddCommGroup E] [Module ℝ E] [AddCommGroup F] [Module ℝ F] /-- The closed parallelepiped spanned by a finite family of vectors. -/ def parallelepiped (v : ι → E) : Set E := (fun t : ι → ℝ => ∑ i, t i • v i) '' Icc 0 1 #align parallelepiped parallelepiped theorem mem_parallelepiped_iff (v : ι → E) (x : E) : x ∈ parallelepiped v ↔ ∃ t ∈ Icc (0 : ι → ℝ) 1, x = ∑ i, t i • v i := by simp [parallelepiped, eq_comm] #align mem_parallelepiped_iff mem_parallelepiped_iff theorem parallelepiped_basis_eq (b : Basis ι ℝ E) : parallelepiped b = {x | ∀ i, b.repr x i ∈ Set.Icc 0 1} := by classical ext x simp_rw [mem_parallelepiped_iff, mem_setOf_eq, b.ext_elem_iff, _root_.map_sum, _root_.map_smul, Finset.sum_apply', Basis.repr_self, Finsupp.smul_single, smul_eq_mul, mul_one, Finsupp.single_apply, Finset.sum_ite_eq', Finset.mem_univ, ite_true, mem_Icc, Pi.le_def, Pi.zero_apply, Pi.one_apply, ← forall_and] aesop theorem image_parallelepiped (f : E →ₗ[ℝ] F) (v : ι → E) : f '' parallelepiped v = parallelepiped (f ∘ v) := by simp only [parallelepiped, ← image_comp] congr 1 with t simp only [Function.comp_apply, _root_.map_sum, LinearMap.map_smulₛₗ, RingHom.id_apply] #align image_parallelepiped image_parallelepiped /-- Reindexing a family of vectors does not change their parallelepiped. -/ @[simp]
Mathlib/MeasureTheory/Measure/Haar/OfBasis.lean
76
94
theorem parallelepiped_comp_equiv (v : ι → E) (e : ι' ≃ ι) : parallelepiped (v ∘ e) = parallelepiped v := by
simp only [parallelepiped] let K : (ι' → ℝ) ≃ (ι → ℝ) := Equiv.piCongrLeft' (fun _a : ι' => ℝ) e have : Icc (0 : ι → ℝ) 1 = K '' Icc (0 : ι' → ℝ) 1 := by rw [← Equiv.preimage_eq_iff_eq_image] ext x simp only [K, mem_preimage, mem_Icc, Pi.le_def, Pi.zero_apply, Equiv.piCongrLeft'_apply, Pi.one_apply] refine ⟨fun h => ⟨fun i => ?_, fun i => ?_⟩, fun h => ⟨fun i => h.1 (e.symm i), fun i => h.2 (e.symm i)⟩⟩ · simpa only [Equiv.symm_apply_apply] using h.1 (e i) · simpa only [Equiv.symm_apply_apply] using h.2 (e i) rw [this, ← image_comp] congr 1 with x have := fun z : ι' → ℝ => e.symm.sum_comp fun i => z i • v (e i) simp_rw [Equiv.apply_symm_apply] at this simp_rw [Function.comp_apply, mem_image, mem_Icc, K, Equiv.piCongrLeft'_apply, this]
/- Copyright (c) 2018 Michael Jendrusch. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Jendrusch, Scott Morrison, Bhavik Mehta, Jakob von Raumer -/ import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Monoidal.Free.Coherence #align_import category_theory.monoidal.coherence_lemmas from "leanprover-community/mathlib"@"b8b8bf3ea0c625fa1f950034a184e07c67f7bcfe" /-! # Lemmas which are consequences of monoidal coherence These lemmas are all proved `by coherence`. ## Future work Investigate whether these lemmas are really needed, or if they can be replaced by use of the `coherence` tactic. -/ open CategoryTheory Category Iso namespace CategoryTheory.MonoidalCategory variable {C : Type*} [Category C] [MonoidalCategory C] -- See Proposition 2.2.4 of <http://www-math.mit.edu/~etingof/egnobookfinal.pdf> @[reassoc] theorem leftUnitor_tensor'' (X Y : C) : (α_ (𝟙_ C) X Y).hom ≫ (λ_ (X ⊗ Y)).hom = (λ_ X).hom ⊗ 𝟙 Y := by coherence #align category_theory.monoidal_category.left_unitor_tensor' CategoryTheory.MonoidalCategory.leftUnitor_tensor'' @[reassoc]
Mathlib/CategoryTheory/Monoidal/CoherenceLemmas.lean
36
38
theorem leftUnitor_tensor' (X Y : C) : (λ_ (X ⊗ Y)).hom = (α_ (𝟙_ C) X Y).inv ≫ ((λ_ X).hom ⊗ 𝟙 Y) := by
coherence
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Joël Riou -/ import Mathlib.Algebra.Homology.Homotopy import Mathlib.Algebra.Homology.SingleHomology import Mathlib.CategoryTheory.Abelian.Homology #align_import algebra.homology.quasi_iso from "leanprover-community/mathlib"@"956af7c76589f444f2e1313911bad16366ea476d" /-! # Quasi-isomorphisms A chain map is a quasi-isomorphism if it induces isomorphisms on homology. ## Future work Define the derived category as the localization at quasi-isomorphisms? (TODO @joelriou) -/ open CategoryTheory Limits universe v u variable {ι : Type*} section variable {V : Type u} [Category.{v} V] [HasZeroMorphisms V] [HasZeroObject V] variable [HasEqualizers V] [HasImages V] [HasImageMaps V] [HasCokernels V] variable {c : ComplexShape ι} {C D E : HomologicalComplex V c} /-- A chain map is a quasi-isomorphism if it induces isomorphisms on homology. -/ class QuasiIso' (f : C ⟶ D) : Prop where isIso : ∀ i, IsIso ((homology'Functor V c i).map f) #align quasi_iso QuasiIso' attribute [instance] QuasiIso'.isIso instance (priority := 100) quasiIso'_of_iso (f : C ⟶ D) [IsIso f] : QuasiIso' f where isIso i := by change IsIso ((homology'Functor V c i).mapIso (asIso f)).hom infer_instance #align quasi_iso_of_iso quasiIso'_of_iso instance quasiIso'_comp (f : C ⟶ D) [QuasiIso' f] (g : D ⟶ E) [QuasiIso' g] : QuasiIso' (f ≫ g) where isIso i := by rw [Functor.map_comp] infer_instance #align quasi_iso_comp quasiIso'_comp theorem quasiIso'_of_comp_left (f : C ⟶ D) [QuasiIso' f] (g : D ⟶ E) [QuasiIso' (f ≫ g)] : QuasiIso' g := { isIso := fun i => IsIso.of_isIso_fac_left ((homology'Functor V c i).map_comp f g).symm } #align quasi_iso_of_comp_left quasiIso'_of_comp_left theorem quasiIso'_of_comp_right (f : C ⟶ D) (g : D ⟶ E) [QuasiIso' g] [QuasiIso' (f ≫ g)] : QuasiIso' f := { isIso := fun i => IsIso.of_isIso_fac_right ((homology'Functor V c i).map_comp f g).symm } #align quasi_iso_of_comp_right quasiIso'_of_comp_right namespace HomotopyEquiv section variable {W : Type*} [Category W] [Preadditive W] [HasCokernels W] [HasImages W] [HasEqualizers W] [HasZeroObject W] [HasImageMaps W] /-- A homotopy equivalence is a quasi-isomorphism. -/ theorem toQuasiIso' {C D : HomologicalComplex W c} (e : HomotopyEquiv C D) : QuasiIso' e.hom := ⟨fun i => by refine ⟨⟨(homology'Functor W c i).map e.inv, ?_⟩⟩ simp only [← Functor.map_comp, ← (homology'Functor W c i).map_id] constructor <;> apply homology'_map_eq_of_homotopy exacts [e.homotopyHomInvId, e.homotopyInvHomId]⟩ #align homotopy_equiv.to_quasi_iso HomotopyEquiv.toQuasiIso'
Mathlib/Algebra/Homology/QuasiIso.lean
82
87
theorem toQuasiIso'_inv {C D : HomologicalComplex W c} (e : HomotopyEquiv C D) (i : ι) : (@asIso _ _ _ _ _ (e.toQuasiIso'.1 i)).inv = (homology'Functor W c i).map e.inv := by
symm haveI := e.toQuasiIso'.1 i -- Porting note: Added this to get `asIso_hom` to work. simp only [← Iso.hom_comp_eq_id, asIso_hom, ← Functor.map_comp, ← (homology'Functor W c i).map_id, homology'_map_eq_of_homotopy e.homotopyHomInvId _]
/- Copyright (c) 2021 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Order.Lattice import Mathlib.Data.List.Sort import Mathlib.Logic.Equiv.Fin import Mathlib.Logic.Equiv.Functor import Mathlib.Data.Fintype.Card import Mathlib.Order.RelSeries #align_import order.jordan_holder from "leanprover-community/mathlib"@"91288e351d51b3f0748f0a38faa7613fb0ae2ada" /-! # Jordan-Hölder Theorem This file proves the Jordan Hölder theorem for a `JordanHolderLattice`, a class also defined in this file. Examples of `JordanHolderLattice` include `Subgroup G` if `G` is a group, and `Submodule R M` if `M` is an `R`-module. Using this approach the theorem need not be proved separately for both groups and modules, the proof in this file can be applied to both. ## Main definitions The main definitions in this file are `JordanHolderLattice` and `CompositionSeries`, and the relation `Equivalent` on `CompositionSeries` A `JordanHolderLattice` is the class for which the Jordan Hölder theorem is proved. A Jordan Hölder lattice is a lattice equipped with a notion of maximality, `IsMaximal`, and a notion of isomorphism of pairs `Iso`. In the example of subgroups of a group, `IsMaximal H K` means that `H` is a maximal normal subgroup of `K`, and `Iso (H₁, K₁) (H₂, K₂)` means that the quotient `H₁ / K₁` is isomorphic to the quotient `H₂ / K₂`. `Iso` must be symmetric and transitive and must satisfy the second isomorphism theorem `Iso (H, H ⊔ K) (H ⊓ K, K)`. A `CompositionSeries X` is a finite nonempty series of elements of the lattice `X` such that each element is maximal inside the next. The length of a `CompositionSeries X` is one less than the number of elements in the series. Note that there is no stipulation that a series start from the bottom of the lattice and finish at the top. For a composition series `s`, `s.last` is the largest element of the series, and `s.head` is the least element. Two `CompositionSeries X`, `s₁` and `s₂` are equivalent if there is a bijection `e : Fin s₁.length ≃ Fin s₂.length` such that for any `i`, `Iso (s₁ i, s₁ i.succ) (s₂ (e i), s₂ (e i.succ))` ## Main theorems The main theorem is `CompositionSeries.jordan_holder`, which says that if two composition series have the same least element and the same largest element, then they are `Equivalent`. ## TODO Provide instances of `JordanHolderLattice` for subgroups, and potentially for modular lattices. It is not entirely clear how this should be done. Possibly there should be no global instances of `JordanHolderLattice`, and the instances should only be defined locally in order to prove the Jordan-Hölder theorem for modules/groups and the API should be transferred because many of the theorems in this file will have stronger versions for modules. There will also need to be an API for mapping composition series across homomorphisms. It is also probably possible to provide an instance of `JordanHolderLattice` for any `ModularLattice`, and in this case the Jordan-Hölder theorem will say that there is a well defined notion of length of a modular lattice. However an instance of `JordanHolderLattice` for a modular lattice will not be able to contain the correct notion of isomorphism for modules, so a separate instance for modules will still be required and this will clash with the instance for modular lattices, and so at least one of these instances should not be a global instance. > [!NOTE] > The previous paragraph indicates that the instance of `JordanHolderLattice` for submodules should > be obtained via `ModularLattice`. This is not the case in `mathlib4`. > See `JordanHolderModule.instJordanHolderLattice`. -/ universe u open Set RelSeries /-- A `JordanHolderLattice` is the class for which the Jordan Hölder theorem is proved. A Jordan Hölder lattice is a lattice equipped with a notion of maximality, `IsMaximal`, and a notion of isomorphism of pairs `Iso`. In the example of subgroups of a group, `IsMaximal H K` means that `H` is a maximal normal subgroup of `K`, and `Iso (H₁, K₁) (H₂, K₂)` means that the quotient `H₁ / K₁` is isomorphic to the quotient `H₂ / K₂`. `Iso` must be symmetric and transitive and must satisfy the second isomorphism theorem `Iso (H, H ⊔ K) (H ⊓ K, K)`. Examples include `Subgroup G` if `G` is a group, and `Submodule R M` if `M` is an `R`-module. -/ class JordanHolderLattice (X : Type u) [Lattice X] where IsMaximal : X → X → Prop lt_of_isMaximal : ∀ {x y}, IsMaximal x y → x < y sup_eq_of_isMaximal : ∀ {x y z}, IsMaximal x z → IsMaximal y z → x ≠ y → x ⊔ y = z isMaximal_inf_left_of_isMaximal_sup : ∀ {x y}, IsMaximal x (x ⊔ y) → IsMaximal y (x ⊔ y) → IsMaximal (x ⊓ y) x Iso : X × X → X × X → Prop iso_symm : ∀ {x y}, Iso x y → Iso y x iso_trans : ∀ {x y z}, Iso x y → Iso y z → Iso x z second_iso : ∀ {x y}, IsMaximal x (x ⊔ y) → Iso (x, x ⊔ y) (x ⊓ y, y) #align jordan_holder_lattice JordanHolderLattice namespace JordanHolderLattice variable {X : Type u} [Lattice X] [JordanHolderLattice X] theorem isMaximal_inf_right_of_isMaximal_sup {x y : X} (hxz : IsMaximal x (x ⊔ y)) (hyz : IsMaximal y (x ⊔ y)) : IsMaximal (x ⊓ y) y := by rw [inf_comm] rw [sup_comm] at hxz hyz exact isMaximal_inf_left_of_isMaximal_sup hyz hxz #align jordan_holder_lattice.is_maximal_inf_right_of_is_maximal_sup JordanHolderLattice.isMaximal_inf_right_of_isMaximal_sup
Mathlib/Order/JordanHolder.lean
109
113
theorem isMaximal_of_eq_inf (x b : X) {a y : X} (ha : x ⊓ y = a) (hxy : x ≠ y) (hxb : IsMaximal x b) (hyb : IsMaximal y b) : IsMaximal a y := by
have hb : x ⊔ y = b := sup_eq_of_isMaximal hxb hyb hxy substs a b exact isMaximal_inf_right_of_isMaximal_sup hxb hyb
/- 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.Init.Function #align_import data.option.n_ary from "leanprover-community/mathlib"@"995b47e555f1b6297c7cf16855f1023e355219fb" /-! # 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. (porting note - only some of these may exist right now!) 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 #align option.map₂ Option.map₂ /-- `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 #align option.map₂_def Option.map₂_def -- Porting note (#10618): In Lean3, was `@[simp]` but now `simp` can prove it theorem map₂_some_some (f : α → β → γ) (a : α) (b : β) : map₂ f (some a) (some b) = f a b := rfl #align option.map₂_some_some Option.map₂_some_some theorem map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b := rfl #align option.map₂_coe_coe Option.map₂_coe_coe @[simp] theorem map₂_none_left (f : α → β → γ) (b : Option β) : map₂ f none b = none := rfl #align option.map₂_none_left Option.map₂_none_left @[simp] theorem map₂_none_right (f : α → β → γ) (a : Option α) : map₂ f a none = none := by cases a <;> rfl #align option.map₂_none_right Option.map₂_none_right @[simp] theorem map₂_coe_left (f : α → β → γ) (a : α) (b : Option β) : map₂ f a b = b.map fun b => f a b := rfl #align option.map₂_coe_left Option.map₂_coe_left -- 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 #align option.map₂_coe_right Option.map₂_coe_right -- Porting note: Removed the `@[simp]` tag as membership of an `Option` is no-longer simp-normal. 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] #align option.mem_map₂_iff Option.mem_map₂_iff @[simp] theorem map₂_eq_none_iff : map₂ f a b = none ↔ a = none ∨ b = none := by cases a <;> cases b <;> simp #align option.map₂_eq_none_iff Option.map₂_eq_none_iff theorem map₂_swap (f : α → β → γ) (a : Option α) (b : Option β) : map₂ f a b = map₂ (fun a b => f b a) b a := by cases a <;> cases b <;> rfl #align option.map₂_swap Option.map₂_swap theorem map_map₂ (f : α → β → γ) (g : γ → δ) : (map₂ f a b).map g = map₂ (fun a b => g (f a b)) a b := by cases a <;> cases b <;> rfl #align option.map_map₂ Option.map_map₂ theorem map₂_map_left (f : γ → β → δ) (g : α → γ) : map₂ f (a.map g) b = map₂ (fun a b => f (g a) b) a b := by cases a <;> rfl #align option.map₂_map_left Option.map₂_map_left theorem map₂_map_right (f : α → γ → δ) (g : β → γ) : map₂ f a (b.map g) = map₂ (fun a b => f a (g b)) a b := by cases b <;> rfl #align option.map₂_map_right Option.map₂_map_right @[simp] theorem map₂_curry (f : α × β → γ) (a : Option α) (b : Option β) : map₂ (curry f) a b = Option.map f (map₂ Prod.mk a b) := (map_map₂ _ _).symm #align option.map₂_curry Option.map₂_curry @[simp] theorem map_uncurry (f : α → β → γ) (x : Option (α × β)) : x.map (uncurry f) = map₂ f (x.map Prod.fst) (x.map Prod.snd) := by cases x <;> rfl #align option.map_uncurry Option.map_uncurry /-! ### Algebraic replacement rules A collection of lemmas to transfer associativity, commutativity, distributivity, ... of operations to the associativity, commutativity, distributivity, ... of `Option.map₂` of those operations. The proof pattern is `map₂_lemma operation_lemma`. For example, `map₂_comm mul_comm` proves that `map₂ (*) a b = map₂ (*) g f` in a `CommSemigroup`. -/ variable {α' β' δ' ε ε' : Type*}
Mathlib/Data/Option/NAry.lean
124
127
theorem map₂_assoc {f : δ → γ → ε} {g : α → β → δ} {f' : α → ε' → ε} {g' : β → γ → ε'} (h_assoc : ∀ a b c, f (g a b) c = f' a (g' b c)) : map₂ f (map₂ g a b) c = map₂ f' a (map₂ g' b c) := by
cases a <;> cases b <;> cases c <;> simp [h_assoc]
/- Copyright (c) 2018 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Reid Barton -/ import Mathlib.Topology.Bases import Mathlib.Topology.DenseEmbedding #align_import topology.stone_cech from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" /-! # Stone-Čech compactification Construction of the Stone-Čech compactification using ultrafilters. Parts of the formalization are based on "Ultrafilters and Topology" by Marius Stekelenburg, particularly section 5. -/ noncomputable section open Filter Set open Topology universe u v section Ultrafilter /- The set of ultrafilters on α carries a natural topology which makes it the Stone-Čech compactification of α (viewed as a discrete space). -/ /-- Basis for the topology on `Ultrafilter α`. -/ def ultrafilterBasis (α : Type u) : Set (Set (Ultrafilter α)) := range fun s : Set α => { u | s ∈ u } #align ultrafilter_basis ultrafilterBasis variable {α : Type u} instance Ultrafilter.topologicalSpace : TopologicalSpace (Ultrafilter α) := TopologicalSpace.generateFrom (ultrafilterBasis α) #align ultrafilter.topological_space Ultrafilter.topologicalSpace theorem ultrafilterBasis_is_basis : TopologicalSpace.IsTopologicalBasis (ultrafilterBasis α) := ⟨by rintro _ ⟨a, rfl⟩ _ ⟨b, rfl⟩ u ⟨ua, ub⟩ refine ⟨_, ⟨a ∩ b, rfl⟩, inter_mem ua ub, fun v hv => ⟨?_, ?_⟩⟩ <;> apply mem_of_superset hv <;> simp [inter_subset_right], eq_univ_of_univ_subset <| subset_sUnion_of_mem <| ⟨univ, eq_univ_of_forall fun u => univ_mem⟩, rfl⟩ #align ultrafilter_basis_is_basis ultrafilterBasis_is_basis /-- The basic open sets for the topology on ultrafilters are open. -/ theorem ultrafilter_isOpen_basic (s : Set α) : IsOpen { u : Ultrafilter α | s ∈ u } := ultrafilterBasis_is_basis.isOpen ⟨s, rfl⟩ #align ultrafilter_is_open_basic ultrafilter_isOpen_basic /-- The basic open sets for the topology on ultrafilters are also closed. -/
Mathlib/Topology/StoneCech.lean
58
62
theorem ultrafilter_isClosed_basic (s : Set α) : IsClosed { u : Ultrafilter α | s ∈ u } := by
rw [← isOpen_compl_iff] convert ultrafilter_isOpen_basic sᶜ using 1 ext u exact Ultrafilter.compl_mem_iff_not_mem.symm
/- Copyright (c) 2018 Guy Leroy. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sangwoo Jo (aka Jason), Guy Leroy, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Group.Int import Mathlib.Algebra.GroupWithZero.Semiconj import Mathlib.Data.Nat.GCD.Basic import Mathlib.Order.Bounds.Basic #align_import data.int.gcd from "leanprover-community/mathlib"@"47a1a73351de8dd6c8d3d32b569c8e434b03ca47" /-! # Extended GCD and divisibility over ℤ ## Main definitions * Given `x y : ℕ`, `xgcd x y` computes the pair of integers `(a, b)` such that `gcd x y = x * a + y * b`. `gcdA x y` and `gcdB x y` are defined to be `a` and `b`, respectively. ## Main statements * `gcd_eq_gcd_ab`: Bézout's lemma, given `x y : ℕ`, `gcd x y = x * gcdA x y + y * gcdB x y`. ## Tags Bézout's lemma, Bezout's lemma -/ /-! ### Extended Euclidean algorithm -/ namespace Nat /-- Helper function for the extended GCD algorithm (`Nat.xgcd`). -/ def xgcdAux : ℕ → ℤ → ℤ → ℕ → ℤ → ℤ → ℕ × ℤ × ℤ | 0, _, _, r', s', t' => (r', s', t') | succ k, s, t, r', s', t' => let q := r' / succ k xgcdAux (r' % succ k) (s' - q * s) (t' - q * t) (succ k) s t termination_by k => k decreasing_by exact mod_lt _ <| (succ_pos _).gt #align nat.xgcd_aux Nat.xgcdAux @[simp] theorem xgcd_zero_left {s t r' s' t'} : xgcdAux 0 s t r' s' t' = (r', s', t') := by simp [xgcdAux] #align nat.xgcd_zero_left Nat.xgcd_zero_left theorem xgcdAux_rec {r s t r' s' t'} (h : 0 < r) : xgcdAux r s t r' s' t' = xgcdAux (r' % r) (s' - r' / r * s) (t' - r' / r * t) r s t := by obtain ⟨r, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h.ne' simp [xgcdAux] #align nat.xgcd_aux_rec Nat.xgcdAux_rec /-- Use the extended GCD algorithm to generate the `a` and `b` values satisfying `gcd x y = x * a + y * b`. -/ def xgcd (x y : ℕ) : ℤ × ℤ := (xgcdAux x 1 0 y 0 1).2 #align nat.xgcd Nat.xgcd /-- The extended GCD `a` value in the equation `gcd x y = x * a + y * b`. -/ def gcdA (x y : ℕ) : ℤ := (xgcd x y).1 #align nat.gcd_a Nat.gcdA /-- The extended GCD `b` value in the equation `gcd x y = x * a + y * b`. -/ def gcdB (x y : ℕ) : ℤ := (xgcd x y).2 #align nat.gcd_b Nat.gcdB @[simp] theorem gcdA_zero_left {s : ℕ} : gcdA 0 s = 0 := by unfold gcdA rw [xgcd, xgcd_zero_left] #align nat.gcd_a_zero_left Nat.gcdA_zero_left @[simp] theorem gcdB_zero_left {s : ℕ} : gcdB 0 s = 1 := by unfold gcdB rw [xgcd, xgcd_zero_left] #align nat.gcd_b_zero_left Nat.gcdB_zero_left @[simp] theorem gcdA_zero_right {s : ℕ} (h : s ≠ 0) : gcdA s 0 = 1 := by unfold gcdA xgcd obtain ⟨s, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h rw [xgcdAux] simp #align nat.gcd_a_zero_right Nat.gcdA_zero_right @[simp] theorem gcdB_zero_right {s : ℕ} (h : s ≠ 0) : gcdB s 0 = 0 := by unfold gcdB xgcd obtain ⟨s, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h rw [xgcdAux] simp #align nat.gcd_b_zero_right Nat.gcdB_zero_right @[simp] theorem xgcdAux_fst (x y) : ∀ s t s' t', (xgcdAux x s t y s' t').1 = gcd x y := gcd.induction x y (by simp) fun x y h IH s t s' t' => by simp only [h, xgcdAux_rec, IH] rw [← gcd_rec] #align nat.xgcd_aux_fst Nat.xgcdAux_fst
Mathlib/Data/Int/GCD.lean
108
109
theorem xgcdAux_val (x y) : xgcdAux x 1 0 y 0 1 = (gcd x y, xgcd x y) := by
rw [xgcd, ← xgcdAux_fst x y 1 0 0 1]
/- Copyright (c) 2024 Josha Dekker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Josha Dekker -/ import Mathlib.Order.Filter.Cofinite import Mathlib.Order.Filter.CountableInter import Mathlib.Order.Filter.CardinalInter import Mathlib.SetTheory.Cardinal.Ordinal import Mathlib.SetTheory.Cardinal.Cofinality import Mathlib.Order.Filter.Bases /-! # The cocardinal filter In this file we define `Filter.cocardinal hc`: the filter of sets with cardinality less than a regular cardinal `c` that satisfies `Cardinal.aleph0 < c`. Such filters are `CardinalInterFilter` with cardinality `c`. -/ open Set Filter Cardinal universe u variable {ι : Type u} {α β : Type u} variable {c : Cardinal.{u}} {hreg : c.IsRegular} variable {l : Filter α} namespace Filter variable (α) in /-- The filter defined by all sets that have a complement with at most cardinality `c`. For a union of `c` sets of `c` elements to have `c` elements, we need that `c` is a regular cardinal. -/ def cocardinal (hreg : c.IsRegular) : Filter α := by apply ofCardinalUnion {s | Cardinal.mk s < c} (lt_of_lt_of_le (nat_lt_aleph0 2) hreg.aleph0_le) · refine fun s hS hSc ↦ lt_of_le_of_lt (mk_sUnion_le _) <| mul_lt_of_lt hreg.aleph0_le hS ?_ exact iSup_lt_of_isRegular hreg hS fun i ↦ hSc i i.property · exact fun _ hSc _ ht ↦ lt_of_le_of_lt (mk_le_mk_of_subset ht) hSc @[simp] theorem mem_cocardinal {s : Set α} : s ∈ cocardinal α hreg ↔ Cardinal.mk (sᶜ : Set α) < c := Iff.rfl @[simp] lemma cocardinal_aleph0_eq_cofinite : cocardinal (α := α) isRegular_aleph0 = cofinite := by aesop instance instCardinalInterFilter_cocardinal : CardinalInterFilter (cocardinal (α := α) hreg) c where cardinal_sInter_mem S hS hSs := by rw [mem_cocardinal, Set.compl_sInter] apply lt_of_le_of_lt (mk_sUnion_le _) apply mul_lt_of_lt hreg.aleph0_le (lt_of_le_of_lt mk_image_le hS) apply iSup_lt_of_isRegular hreg <| lt_of_le_of_lt mk_image_le hS intro i aesop @[simp] theorem eventually_cocardinal {p : α → Prop} : (∀ᶠ x in cocardinal α hreg, p x) ↔ #{ x | ¬p x } < c := Iff.rfl
Mathlib/Order/Filter/Cocardinal.lean
61
68
theorem hasBasis_cocardinal : HasBasis (cocardinal α hreg) {s : Set α | #s < c} compl := ⟨fun s => ⟨fun h => ⟨sᶜ, h, (compl_compl s).subset⟩, fun ⟨_t, htf, hts⟩ => by have : #↑sᶜ < c := by
apply lt_of_le_of_lt _ htf rw [compl_subset_comm] at hts apply Cardinal.mk_le_mk_of_subset hts simp_all only [mem_cocardinal] ⟩⟩
/- Copyright (c) 2024 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.FieldTheory.PurelyInseparable import Mathlib.FieldTheory.PerfectClosure /-! # `IsPerfectClosure` predicate This file contains `IsPerfectClosure` which asserts that `L` is a perfect closure of `K` under a ring homomorphism `i : K →+* L`, as well as its basic properties. ## Main definitions - `pNilradical`: given a natural number `p`, the `p`-nilradical of a ring is defined to be the nilradical if `p > 1` (`pNilradical_eq_nilradical`), and defined to be the zero ideal if `p ≤ 1` (`pNilradical_eq_bot'`). Equivalently, it is the ideal consisting of elements `x` such that `x ^ p ^ n = 0` for some `n` (`mem_pNilradical`). - `IsPRadical`: a ring homomorphism `i : K →+* L` of characteristic `p` rings is called `p`-radical, if or any element `x` of `L` there is `n : ℕ` such that `x ^ (p ^ n)` is contained in `K`, and the kernel of `i` is contained in the `p`-nilradical of `K`. A generalization of purely inseparable extension for fields. - `IsPerfectClosure`: if `i : K →+* L` is `p`-radical ring homomorphism, then it makes `L` a perfect closure of `K`, if `L` is perfect. Our definition makes it synonymous to `IsPRadical` if `PerfectRing L p` is present. A caveat is that you need to write `[PerfectRing L p] [IsPerfectClosure i p]`. This is similar to `PerfectRing` which has `ExpChar` as a prerequisite. - `PerfectRing.lift`: if a `p`-radical ring homomorphism `K →+* L` is given, `M` is a perfect ring, then any ring homomorphism `K →+* M` can be lifted to `L →+* M`. This is similar to `IsAlgClosed.lift` and `IsSepClosed.lift`. - `PerfectRing.liftEquiv`: `K →+* M` is one-to-one correspondence to `L →+* M`, given by `PerfectRing.lift`. This is a generalization to `PerfectClosure.lift`. - `IsPerfectClosure.equiv`: perfect closures of a ring are isomorphic. ## Main results - `IsPRadical.trans`: composition of `p`-radical ring homomorphisms is also `p`-radical. - `PerfectClosure.isPRadical`: the absolute perfect closure `PerfectClosure` is a `p`-radical extension over the base ring, in particular, it is a perfect closure of the base ring. - `IsPRadical.isPurelyInseparable`, `IsPurelyInseparable.isPRadical`: `p`-radical and purely inseparable are equivalent for fields. - The (relative) perfect closure `perfectClosure` is a perfect closure (inferred from `IsPurelyInseparable.isPRadical` automatically by Lean). ## Tags perfect ring, perfect closure, purely inseparable -/ open scoped Classical Polynomial open FiniteDimensional Polynomial IntermediateField Field noncomputable section /-- Given a natural number `p`, the `p`-nilradical of a ring is defined to be the nilradical if `p > 1` (`pNilradical_eq_nilradical`), and defined to be the zero ideal if `p ≤ 1` (`pNilradical_eq_bot'`). Equivalently, it is the ideal consisting of elements `x` such that `x ^ p ^ n = 0` for some `n` (`mem_pNilradical`). -/ def pNilradical (R : Type*) [CommSemiring R] (p : ℕ) : Ideal R := if 1 < p then nilradical R else ⊥ theorem pNilradical_le_nilradical {R : Type*} [CommSemiring R] {p : ℕ} : pNilradical R p ≤ nilradical R := by by_cases hp : 1 < p · rw [pNilradical, if_pos hp] simp_rw [pNilradical, if_neg hp, bot_le] theorem pNilradical_eq_nilradical {R : Type*} [CommSemiring R] {p : ℕ} (hp : 1 < p) : pNilradical R p = nilradical R := by rw [pNilradical, if_pos hp] theorem pNilradical_eq_bot {R : Type*} [CommSemiring R] {p : ℕ} (hp : ¬ 1 < p) : pNilradical R p = ⊥ := by rw [pNilradical, if_neg hp] theorem pNilradical_eq_bot' {R : Type*} [CommSemiring R] {p : ℕ} (hp : p ≤ 1) : pNilradical R p = ⊥ := pNilradical_eq_bot (not_lt.2 hp) theorem pNilradical_prime {R : Type*} [CommSemiring R] {p : ℕ} (hp : p.Prime) : pNilradical R p = nilradical R := pNilradical_eq_nilradical hp.one_lt theorem pNilradical_one {R : Type*} [CommSemiring R] : pNilradical R 1 = ⊥ := pNilradical_eq_bot' rfl.le theorem mem_pNilradical {R : Type*} [CommSemiring R] {p : ℕ} {x : R} : x ∈ pNilradical R p ↔ ∃ n : ℕ, x ^ p ^ n = 0 := by by_cases hp : 1 < p · rw [pNilradical_eq_nilradical hp] refine ⟨fun ⟨n, h⟩ ↦ ⟨n, ?_⟩, fun ⟨n, h⟩ ↦ ⟨p ^ n, h⟩⟩ rw [← Nat.sub_add_cancel ((Nat.lt_pow_self hp n).le), pow_add, h, mul_zero] rw [pNilradical_eq_bot hp, Ideal.mem_bot] refine ⟨fun h ↦ ⟨0, by rw [pow_zero, pow_one, h]⟩, fun ⟨n, h⟩ ↦ ?_⟩ rcases Nat.le_one_iff_eq_zero_or_eq_one.1 (not_lt.1 hp) with hp | hp · by_cases hn : n = 0 · rwa [hn, pow_zero, pow_one] at h rw [hp, zero_pow hn, pow_zero] at h haveI := subsingleton_of_zero_eq_one h.symm exact Subsingleton.elim _ _ rwa [hp, one_pow, pow_one] at h
Mathlib/FieldTheory/IsPerfectClosure.lean
112
114
theorem sub_mem_pNilradical_iff_pow_expChar_pow_eq {R : Type*} [CommRing R] {p : ℕ} [ExpChar R p] {x y : R} : x - y ∈ pNilradical R p ↔ ∃ n : ℕ, x ^ p ^ n = y ^ p ^ n := by
simp_rw [mem_pNilradical, sub_pow_expChar_pow, sub_eq_zero]
/- Copyright (c) 2022 Michael Stoll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Stoll -/ import Mathlib.Data.Fintype.Parity import Mathlib.NumberTheory.LegendreSymbol.ZModChar import Mathlib.FieldTheory.Finite.Basic #align_import number_theory.legendre_symbol.quadratic_char.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" /-! # Quadratic characters of finite fields This file defines the quadratic character on a finite field `F` and proves some basic statements about it. ## Tags quadratic character -/ /-! ### Definition of the quadratic character We define the quadratic character of a finite field `F` with values in ℤ. -/ section Define /-- Define the quadratic character with values in ℤ on a monoid with zero `α`. It takes the value zero at zero; for non-zero argument `a : α`, it is `1` if `a` is a square, otherwise it is `-1`. This only deserves the name "character" when it is multiplicative, e.g., when `α` is a finite field. See `quadraticCharFun_mul`. We will later define `quadraticChar` to be a multiplicative character of type `MulChar F ℤ`, when the domain is a finite field `F`. -/ def quadraticCharFun (α : Type*) [MonoidWithZero α] [DecidableEq α] [DecidablePred (IsSquare : α → Prop)] (a : α) : ℤ := if a = 0 then 0 else if IsSquare a then 1 else -1 #align quadratic_char_fun quadraticCharFun end Define /-! ### Basic properties of the quadratic character We prove some properties of the quadratic character. We work with a finite field `F` here. The interesting case is when the characteristic of `F` is odd. -/ section quadraticChar open MulChar variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] /-- Some basic API lemmas -/ theorem quadraticCharFun_eq_zero_iff {a : F} : quadraticCharFun F a = 0 ↔ a = 0 := by simp only [quadraticCharFun] by_cases ha : a = 0 · simp only [ha, eq_self_iff_true, if_true] · simp only [ha, if_false, iff_false_iff] split_ifs <;> simp only [neg_eq_zero, one_ne_zero, not_false_iff] #align quadratic_char_fun_eq_zero_iff quadraticCharFun_eq_zero_iff @[simp] theorem quadraticCharFun_zero : quadraticCharFun F 0 = 0 := by simp only [quadraticCharFun, eq_self_iff_true, if_true, id] #align quadratic_char_fun_zero quadraticCharFun_zero @[simp] theorem quadraticCharFun_one : quadraticCharFun F 1 = 1 := by simp only [quadraticCharFun, one_ne_zero, isSquare_one, if_true, if_false, id] #align quadratic_char_fun_one quadraticCharFun_one /-- If `ringChar F = 2`, then `quadraticCharFun F` takes the value `1` on nonzero elements. -/ theorem quadraticCharFun_eq_one_of_char_two (hF : ringChar F = 2) {a : F} (ha : a ≠ 0) : quadraticCharFun F a = 1 := by simp only [quadraticCharFun, ha, if_false, ite_eq_left_iff] exact fun h => (h (FiniteField.isSquare_of_char_two hF a)).elim #align quadratic_char_fun_eq_one_of_char_two quadraticCharFun_eq_one_of_char_two /-- If `ringChar F` is odd, then `quadraticCharFun F a` can be computed in terms of `a ^ (Fintype.card F / 2)`. -/ theorem quadraticCharFun_eq_pow_of_char_ne_two (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) : quadraticCharFun F a = if a ^ (Fintype.card F / 2) = 1 then 1 else -1 := by simp only [quadraticCharFun, ha, if_false] simp_rw [FiniteField.isSquare_iff hF ha] #align quadratic_char_fun_eq_pow_of_char_ne_two quadraticCharFun_eq_pow_of_char_ne_two /-- The quadratic character is multiplicative. -/
Mathlib/NumberTheory/LegendreSymbol/QuadraticChar/Basic.lean
100
122
theorem quadraticCharFun_mul (a b : F) : quadraticCharFun F (a * b) = quadraticCharFun F a * quadraticCharFun F b := by
by_cases ha : a = 0 · rw [ha, zero_mul, quadraticCharFun_zero, zero_mul] -- now `a ≠ 0` by_cases hb : b = 0 · rw [hb, mul_zero, quadraticCharFun_zero, mul_zero] -- now `a ≠ 0` and `b ≠ 0` have hab := mul_ne_zero ha hb by_cases hF : ringChar F = 2 ·-- case `ringChar F = 2` rw [quadraticCharFun_eq_one_of_char_two hF ha, quadraticCharFun_eq_one_of_char_two hF hb, quadraticCharFun_eq_one_of_char_two hF hab, mul_one] · -- case of odd characteristic rw [quadraticCharFun_eq_pow_of_char_ne_two hF ha, quadraticCharFun_eq_pow_of_char_ne_two hF hb, quadraticCharFun_eq_pow_of_char_ne_two hF hab, mul_pow] cases' FiniteField.pow_dichotomy hF hb with hb' hb' · simp only [hb', mul_one, eq_self_iff_true, if_true] · have h := Ring.neg_one_ne_one_of_char_ne_two hF -- `-1 ≠ 1` simp only [hb', h, mul_neg, mul_one, if_false, ite_mul, neg_mul] cases' FiniteField.pow_dichotomy hF ha with ha' ha' <;> simp only [ha', h, neg_neg, eq_self_iff_true, if_true, if_false]
/- Copyright (c) 2020 Shing Tak Lam. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shing Tak Lam -/ import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Exponent #align_import group_theory.specific_groups.dihedral from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Dihedral Groups We define the dihedral groups `DihedralGroup n`, with elements `r i` and `sr i` for `i : ZMod n`. For `n ≠ 0`, `DihedralGroup n` represents the symmetry group of the regular `n`-gon. `r i` represents the rotations of the `n`-gon by `2πi/n`, and `sr i` represents the reflections of the `n`-gon. `DihedralGroup 0` corresponds to the infinite dihedral group. -/ /-- For `n ≠ 0`, `DihedralGroup n` represents the symmetry group of the regular `n`-gon. `r i` represents the rotations of the `n`-gon by `2πi/n`, and `sr i` represents the reflections of the `n`-gon. `DihedralGroup 0` corresponds to the infinite dihedral group. -/ inductive DihedralGroup (n : ℕ) : Type | r : ZMod n → DihedralGroup n | sr : ZMod n → DihedralGroup n deriving DecidableEq #align dihedral_group DihedralGroup namespace DihedralGroup variable {n : ℕ} /-- Multiplication of the dihedral group. -/ private def mul : DihedralGroup n → DihedralGroup n → DihedralGroup n | r i, r j => r (i + j) | r i, sr j => sr (j - i) | sr i, r j => sr (i + j) | sr i, sr j => r (j - i) /-- The identity `1` is the rotation by `0`. -/ private def one : DihedralGroup n := r 0 instance : Inhabited (DihedralGroup n) := ⟨one⟩ /-- The inverse of an element of the dihedral group. -/ private def inv : DihedralGroup n → DihedralGroup n | r i => r (-i) | sr i => sr i /-- The group structure on `DihedralGroup n`. -/ instance : Group (DihedralGroup n) where mul := mul mul_assoc := by rintro (a | a) (b | b) (c | c) <;> simp only [(· * ·), mul] <;> ring_nf one := one one_mul := by rintro (a | a) · exact congr_arg r (zero_add a) · exact congr_arg sr (sub_zero a) mul_one := by rintro (a | a) · exact congr_arg r (add_zero a) · exact congr_arg sr (add_zero a) inv := inv mul_left_inv := by rintro (a | a) · exact congr_arg r (neg_add_self a) · exact congr_arg r (sub_self a) @[simp] theorem r_mul_r (i j : ZMod n) : r i * r j = r (i + j) := rfl #align dihedral_group.r_mul_r DihedralGroup.r_mul_r @[simp] theorem r_mul_sr (i j : ZMod n) : r i * sr j = sr (j - i) := rfl #align dihedral_group.r_mul_sr DihedralGroup.r_mul_sr @[simp] theorem sr_mul_r (i j : ZMod n) : sr i * r j = sr (i + j) := rfl #align dihedral_group.sr_mul_r DihedralGroup.sr_mul_r @[simp] theorem sr_mul_sr (i j : ZMod n) : sr i * sr j = r (j - i) := rfl #align dihedral_group.sr_mul_sr DihedralGroup.sr_mul_sr theorem one_def : (1 : DihedralGroup n) = r 0 := rfl #align dihedral_group.one_def DihedralGroup.one_def private def fintypeHelper : Sum (ZMod n) (ZMod n) ≃ DihedralGroup n where invFun i := match i with | r j => Sum.inl j | sr j => Sum.inr j toFun i := match i with | Sum.inl j => r j | Sum.inr j => sr j left_inv := by rintro (x | x) <;> rfl right_inv := by rintro (x | x) <;> rfl /-- If `0 < n`, then `DihedralGroup n` is a finite group. -/ instance [NeZero n] : Fintype (DihedralGroup n) := Fintype.ofEquiv _ fintypeHelper instance : Infinite (DihedralGroup 0) := DihedralGroup.fintypeHelper.infinite_iff.mp inferInstance instance : Nontrivial (DihedralGroup n) := ⟨⟨r 0, sr 0, by simp_rw [ne_eq, not_false_eq_true]⟩⟩ /-- If `0 < n`, then `DihedralGroup n` has `2n` elements. -/
Mathlib/GroupTheory/SpecificGroups/Dihedral.lean
125
126
theorem card [NeZero n] : Fintype.card (DihedralGroup n) = 2 * n := by
rw [← Fintype.card_eq.mpr ⟨fintypeHelper⟩, Fintype.card_sum, ZMod.card, two_mul]
/- Copyright (c) 2019 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.Rat.Denumerable import Mathlib.Data.Set.Pointwise.Interval import Mathlib.SetTheory.Cardinal.Continuum #align_import data.real.cardinality from "leanprover-community/mathlib"@"7e7aaccf9b0182576cabdde36cf1b5ad3585b70d" /-! # The cardinality of the reals This file shows that the real numbers have cardinality continuum, i.e. `#ℝ = 𝔠`. We show that `#ℝ ≤ 𝔠` by noting that every real number is determined by a Cauchy-sequence of the form `ℕ → ℚ`, which has cardinality `𝔠`. To show that `#ℝ ≥ 𝔠` we define an injection from `{0, 1} ^ ℕ` to `ℝ` with `f ↦ Σ n, f n * (1 / 3) ^ n`. We conclude that all intervals with distinct endpoints have cardinality continuum. ## Main definitions * `Cardinal.cantorFunction` is the function that sends `f` in `{0, 1} ^ ℕ` to `ℝ` by `f ↦ Σ' n, f n * (1 / 3) ^ n` ## Main statements * `Cardinal.mk_real : #ℝ = 𝔠`: the reals have cardinality continuum. * `Cardinal.not_countable_real`: the universal set of real numbers is not countable. We can use this same proof to show that all the other sets in this file are not countable. * 8 lemmas of the form `mk_Ixy_real` for `x,y ∈ {i,o,c}` state that intervals on the reals have cardinality continuum. ## Notation * `𝔠` : notation for `Cardinal.Continuum` in locale `Cardinal`, defined in `SetTheory.Continuum`. ## Tags continuum, cardinality, reals, cardinality of the reals -/ open Nat Set open Cardinal noncomputable section namespace Cardinal variable {c : ℝ} {f g : ℕ → Bool} {n : ℕ} /-- The body of the sum in `cantorFunction`. `cantorFunctionAux c f n = c ^ n` if `f n = true`; `cantorFunctionAux c f n = 0` if `f n = false`. -/ def cantorFunctionAux (c : ℝ) (f : ℕ → Bool) (n : ℕ) : ℝ := cond (f n) (c ^ n) 0 #align cardinal.cantor_function_aux Cardinal.cantorFunctionAux @[simp] theorem cantorFunctionAux_true (h : f n = true) : cantorFunctionAux c f n = c ^ n := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_tt Cardinal.cantorFunctionAux_true @[simp] theorem cantorFunctionAux_false (h : f n = false) : cantorFunctionAux c f n = 0 := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_ff Cardinal.cantorFunctionAux_false theorem cantorFunctionAux_nonneg (h : 0 ≤ c) : 0 ≤ cantorFunctionAux c f n := by cases h' : f n <;> simp [h'] apply pow_nonneg h #align cardinal.cantor_function_aux_nonneg Cardinal.cantorFunctionAux_nonneg theorem cantorFunctionAux_eq (h : f n = g n) : cantorFunctionAux c f n = cantorFunctionAux c g n := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_eq Cardinal.cantorFunctionAux_eq theorem cantorFunctionAux_zero (f : ℕ → Bool) : cantorFunctionAux c f 0 = cond (f 0) 1 0 := by cases h : f 0 <;> simp [h] #align cardinal.cantor_function_aux_zero Cardinal.cantorFunctionAux_zero theorem cantorFunctionAux_succ (f : ℕ → Bool) : (fun n => cantorFunctionAux c f (n + 1)) = fun n => c * cantorFunctionAux c (fun n => f (n + 1)) n := by ext n cases h : f (n + 1) <;> simp [h, _root_.pow_succ'] #align cardinal.cantor_function_aux_succ Cardinal.cantorFunctionAux_succ
Mathlib/Data/Real/Cardinality.lean
93
96
theorem summable_cantor_function (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) : Summable (cantorFunctionAux c f) := by
apply (summable_geometric_of_lt_one h1 h2).summable_of_eq_zero_or_self intro n; cases h : f n <;> simp [h]
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine import Mathlib.Geometry.Euclidean.Angle.Unoriented.RightAngle #align_import geometry.euclidean.angle.oriented.right_angle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Oriented angles in right-angled triangles. This file proves basic geometrical results about distances and oriented angles in (possibly degenerate) right-angled triangles in real inner product spaces and Euclidean affine spaces. -/ noncomputable section open scoped EuclideanGeometry open scoped Real open scoped RealInnerProductSpace namespace Orientation open FiniteDimensional variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] variable [hd2 : Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2)) /-- An angle in a right-angled triangle expressed using `arccos`. -/ theorem oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arccos_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two /-- An angle in a right-angled triangle expressed using `arccos`. -/
Mathlib/Geometry/Euclidean/Angle/Oriented/RightAngle.lean
46
50
theorem oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arccos (‖y‖ / ‖x + y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two h
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Conj import Mathlib.CategoryTheory.Functor.ReflectsIso #align_import category_theory.adjunction.reflective from "leanprover-community/mathlib"@"239d882c4fb58361ee8b3b39fb2091320edef10a" /-! # Reflective functors Basic properties of reflective functors, especially those relating to their essential image. Note properties of reflective functors relating to limits and colimits are included in `CategoryTheory.Monad.Limits`. -/ universe v₁ v₂ v₃ u₁ u₂ u₃ noncomputable section namespace CategoryTheory open Category Adjunction variable {C : Type u₁} {D : Type u₂} {E : Type u₃} variable [Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E] /-- A functor is *reflective*, or *a reflective inclusion*, if it is fully faithful and right adjoint. -/ class Reflective (R : D ⥤ C) extends R.Full, R.Faithful where /-- a choice of a left adjoint to `R` -/ L : C ⥤ D /-- `R` is a right adjoint -/ adj : L ⊣ R #align category_theory.reflective CategoryTheory.Reflective variable (i : D ⥤ C) /-- The reflector `C ⥤ D` when `R : D ⥤ C` is reflective. -/ def reflector [Reflective i] : C ⥤ D := Reflective.L (R := i) /-- The adjunction `reflector i ⊣ i` when `i` is reflective. -/ def reflectorAdjunction [Reflective i] : reflector i ⊣ i := Reflective.adj instance [Reflective i] : i.IsRightAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩ instance [Reflective i] : (reflector i).IsLeftAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩ /-- A reflective functor is fully faithful. -/ def Functor.fullyFaithfulOfReflective [Reflective i] : i.FullyFaithful := (reflectorAdjunction i).fullyFaithfulROfIsIsoCounit -- TODO: This holds more generally for idempotent adjunctions, not just reflective adjunctions. /-- For a reflective functor `i` (with left adjoint `L`), with unit `η`, we have `η_iL = iL η`. -/ theorem unit_obj_eq_map_unit [Reflective i] (X : C) : (reflectorAdjunction i).unit.app (i.obj ((reflector i).obj X)) = i.map ((reflector i).map ((reflectorAdjunction i).unit.app X)) := by rw [← cancel_mono (i.map ((reflectorAdjunction i).counit.app ((reflector i).obj X))), ← i.map_comp] simp #align category_theory.unit_obj_eq_map_unit CategoryTheory.unit_obj_eq_map_unit /-- When restricted to objects in `D` given by `i : D ⥤ C`, the unit is an isomorphism. In other words, `η_iX` is an isomorphism for any `X` in `D`. More generally this applies to objects essentially in the reflective subcategory, see `Functor.essImage.unit_isIso`. -/ example [Reflective i] {B : D} : IsIso ((reflectorAdjunction i).unit.app (i.obj B)) := inferInstance variable {i} /-- If `A` is essentially in the image of a reflective functor `i`, then `η_A` is an isomorphism. This gives that the "witness" for `A` being in the essential image can instead be given as the reflection of `A`, with the isomorphism as `η_A`. (For any `B` in the reflective subcategory, we automatically have that `ε_B` is an iso.) -/ theorem Functor.essImage.unit_isIso [Reflective i] {A : C} (h : A ∈ i.essImage) : IsIso ((reflectorAdjunction i).unit.app A) := by rwa [isIso_unit_app_iff_mem_essImage] #align category_theory.functor.ess_image.unit_is_iso CategoryTheory.Functor.essImage.unit_isIso /-- If `η_A` is an isomorphism, then `A` is in the essential image of `i`. -/ theorem mem_essImage_of_unit_isIso {L : C ⥤ D} (adj : L ⊣ i) (A : C) [IsIso (adj.unit.app A)] : A ∈ i.essImage := ⟨L.obj A, ⟨(asIso (adj.unit.app A)).symm⟩⟩ #align category_theory.mem_ess_image_of_unit_is_iso CategoryTheory.mem_essImage_of_unit_isIso /-- If `η_A` is a split monomorphism, then `A` is in the reflective subcategory. -/
Mathlib/CategoryTheory/Adjunction/Reflective.lean
99
109
theorem mem_essImage_of_unit_isSplitMono [Reflective i] {A : C} [IsSplitMono ((reflectorAdjunction i).unit.app A)] : A ∈ i.essImage := by
let η : 𝟭 C ⟶ reflector i ⋙ i := (reflectorAdjunction i).unit haveI : IsIso (η.app (i.obj ((reflector i).obj A))) := Functor.essImage.unit_isIso ((i.obj_mem_essImage _)) have : Epi (η.app A) := by refine @epi_of_epi _ _ _ _ _ (retraction (η.app A)) (η.app A) ?_ rw [show retraction _ ≫ η.app A = _ from η.naturality (retraction (η.app A))] apply epi_comp (η.app (i.obj ((reflector i).obj A))) haveI := isIso_of_epi_of_isSplitMono (η.app A) exact mem_essImage_of_unit_isIso (reflectorAdjunction i) A
/- 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.RingTheory.HahnSeries.Multiplication import Mathlib.RingTheory.PowerSeries.Basic import Mathlib.Data.Finsupp.PWO #align_import ring_theory.hahn_series from "leanprover-community/mathlib"@"a484a7d0eade4e1268f4fb402859b6686037f965" /-! # Comparison between Hahn series and power series If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of formal series over `Γ` with coefficients in `R`, whose supports are partially well-ordered. With further structure on `R` and `Γ`, we can add further structure on `HahnSeries Γ R`. When `R` is a semiring and `Γ = ℕ`, then we get the more familiar semiring of formal power series with coefficients in `R`. ## Main Definitions * `toPowerSeries` the isomorphism from `HahnSeries ℕ R` to `PowerSeries R`. * `ofPowerSeries` the inverse, casting a `PowerSeries R` to a `HahnSeries ℕ R`. ## TODO * Build an API for the variable `X` (defined to be `single 1 1 : HahnSeries Γ R`) in analogy to `X : R[X]` and `X : PowerSeries R` ## References - [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven] -/ set_option linter.uppercaseLean3 false open Finset Function open scoped Classical open Pointwise Polynomial noncomputable section variable {Γ : Type*} {R : Type*} namespace HahnSeries section Semiring variable [Semiring R] /-- The ring `HahnSeries ℕ R` is isomorphic to `PowerSeries R`. -/ @[simps] def toPowerSeries : HahnSeries ℕ R ≃+* PowerSeries R where toFun f := PowerSeries.mk f.coeff invFun f := ⟨fun n => PowerSeries.coeff R n f, (Nat.lt_wfRel.wf.isWF _).isPWO⟩ left_inv f := by ext simp right_inv f := by ext simp map_add' f g := by ext simp map_mul' f g := by ext n simp only [PowerSeries.coeff_mul, PowerSeries.coeff_mk, mul_coeff, isPWO_support] classical refine (sum_filter_ne_zero _).symm.trans <| (sum_congr ?_ fun _ _ ↦ rfl).trans <| sum_filter_ne_zero _ ext m simp only [mem_antidiagonal, mem_addAntidiagonal, and_congr_left_iff, mem_filter, mem_support] rintro h rw [and_iff_right (left_ne_zero_of_mul h), and_iff_right (right_ne_zero_of_mul h)] #align hahn_series.to_power_series HahnSeries.toPowerSeries theorem coeff_toPowerSeries {f : HahnSeries ℕ R} {n : ℕ} : PowerSeries.coeff R n (toPowerSeries f) = f.coeff n := PowerSeries.coeff_mk _ _ #align hahn_series.coeff_to_power_series HahnSeries.coeff_toPowerSeries theorem coeff_toPowerSeries_symm {f : PowerSeries R} {n : ℕ} : (HahnSeries.toPowerSeries.symm f).coeff n = PowerSeries.coeff R n f := rfl #align hahn_series.coeff_to_power_series_symm HahnSeries.coeff_toPowerSeries_symm variable (Γ R) [StrictOrderedSemiring Γ] /-- Casts a power series as a Hahn series with coefficients from a `StrictOrderedSemiring`. -/ def ofPowerSeries : PowerSeries R →+* HahnSeries Γ R := (HahnSeries.embDomainRingHom (Nat.castAddMonoidHom Γ) Nat.strictMono_cast.injective fun _ _ => Nat.cast_le).comp (RingEquiv.toRingHom toPowerSeries.symm) #align hahn_series.of_power_series HahnSeries.ofPowerSeries variable {Γ} {R} theorem ofPowerSeries_injective : Function.Injective (ofPowerSeries Γ R) := embDomain_injective.comp toPowerSeries.symm.injective #align hahn_series.of_power_series_injective HahnSeries.ofPowerSeries_injective /-@[simp] Porting note: removing simp. RHS is more complicated and it makes linter failures elsewhere-/ theorem ofPowerSeries_apply (x : PowerSeries R) : ofPowerSeries Γ R x = HahnSeries.embDomain ⟨⟨((↑) : ℕ → Γ), Nat.strictMono_cast.injective⟩, by simp only [Function.Embedding.coeFn_mk] exact Nat.cast_le⟩ (toPowerSeries.symm x) := rfl #align hahn_series.of_power_series_apply HahnSeries.ofPowerSeries_apply theorem ofPowerSeries_apply_coeff (x : PowerSeries R) (n : ℕ) : (ofPowerSeries Γ R x).coeff n = PowerSeries.coeff R n x := by simp [ofPowerSeries_apply] #align hahn_series.of_power_series_apply_coeff HahnSeries.ofPowerSeries_apply_coeff @[simp]
Mathlib/RingTheory/HahnSeries/PowerSeries.lean
117
128
theorem ofPowerSeries_C (r : R) : ofPowerSeries Γ R (PowerSeries.C R r) = HahnSeries.C r := by
ext n simp only [ofPowerSeries_apply, C, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk, ne_eq, single_coeff] split_ifs with hn · subst hn convert @embDomain_coeff ℕ R _ _ Γ _ _ _ 0 <;> simp · rw [embDomain_notin_image_support] simp only [not_exists, Set.mem_image, toPowerSeries_symm_apply_coeff, mem_support, PowerSeries.coeff_C] intro simp (config := { contextual := true }) [Ne.symm hn]
/- Copyright (c) 2024 Miyahara Kō. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Miyahara Kō -/ import Mathlib.Data.List.Range import Mathlib.Algebra.Order.Ring.Nat /-! # iterate Proves various lemmas about `List.iterate`. -/ variable {α : Type*} namespace List @[simp]
Mathlib/Data/List/Iterate.lean
21
22
theorem length_iterate (f : α → α) (a : α) (n : ℕ) : length (iterate f a n) = n := by
induction n generalizing a <;> simp [*]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Geometry.RingedSpace.PresheafedSpace import Mathlib.Topology.Category.TopCat.Limits.Basic import Mathlib.Topology.Sheaves.Limits import Mathlib.CategoryTheory.ConcreteCategory.Elementwise #align_import algebraic_geometry.presheafed_space.has_colimits from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" /-! # `PresheafedSpace C` has colimits. If `C` has limits, then the category `PresheafedSpace C` has colimits, and the forgetful functor to `TopCat` preserves these colimits. When restricted to a diagram where the underlying continuous maps are open embeddings, this says that we can glue presheaved spaces. Given a diagram `F : J ⥤ PresheafedSpace C`, we first build the colimit of the underlying topological spaces, as `colimit (F ⋙ PresheafedSpace.forget C)`. Call that colimit space `X`. Our strategy is to push each of the presheaves `F.obj j` forward along the continuous map `colimit.ι (F ⋙ PresheafedSpace.forget C) j` to `X`. Since pushforward is functorial, we obtain a diagram `J ⥤ (presheaf C X)ᵒᵖ` of presheaves on a single space `X`. (Note that the arrows now point the other direction, because this is the way `PresheafedSpace C` is set up.) The limit of this diagram then constitutes the colimit presheaf. -/ noncomputable section universe v' u' v u open CategoryTheory Opposite CategoryTheory.Category CategoryTheory.Functor CategoryTheory.Limits TopCat TopCat.Presheaf TopologicalSpace variable {J : Type u'} [Category.{v'} J] {C : Type u} [Category.{v} C] namespace AlgebraicGeometry namespace PresheafedSpace attribute [local simp] eqToHom_map -- Porting note: we used to have: -- local attribute [tidy] tactic.auto_cases_opens -- We would replace this by: -- attribute [local aesop safe cases (rule_sets := [CategoryTheory])] Opens -- although it doesn't appear to help in this file, in any case. @[simp] theorem map_id_c_app (F : J ⥤ PresheafedSpace.{_, _, v} C) (j) (U) : (F.map (𝟙 j)).c.app (op U) = (Pushforward.id (F.obj j).presheaf).inv.app (op U) ≫ (pushforwardEq (by simp) (F.obj j).presheaf).hom.app (op U) := by cases U simp [PresheafedSpace.congr_app (F.map_id j)] set_option linter.uppercaseLean3 false in #align algebraic_geometry.PresheafedSpace.map_id_c_app AlgebraicGeometry.PresheafedSpace.map_id_c_app @[simp]
Mathlib/Geometry/RingedSpace/PresheafedSpace/HasColimits.lean
70
79
theorem map_comp_c_app (F : J ⥤ PresheafedSpace.{_, _, v} C) {j₁ j₂ j₃} (f : j₁ ⟶ j₂) (g : j₂ ⟶ j₃) (U) : (F.map (f ≫ g)).c.app (op U) = (F.map g).c.app (op U) ≫ (pushforwardMap (F.map g).base (F.map f).c).app (op U) ≫ (Pushforward.comp (F.obj j₁).presheaf (F.map f).base (F.map g).base).inv.app (op U) ≫ (pushforwardEq (by rw [F.map_comp]; rfl) _).hom.app _ := by
cases U simp [PresheafedSpace.congr_app (F.map_comp f g)]
/- Copyright (c) 2021 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.FieldTheory.RatFunc.AsPolynomial import Mathlib.RingTheory.EuclideanDomain import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Polynomial.Content /-! # The degree of rational functions ## Main definitions We define the degree of a rational function, with values in `ℤ`: - `intDegree` is the degree of a rational function, defined as the difference between the `natDegree` of its numerator and the `natDegree` of its denominator. In particular, `intDegree 0 = 0`. -/ noncomputable section universe u variable {K : Type u} namespace RatFunc section IntDegree open Polynomial variable [Field K] /-- `intDegree x` is the degree of the rational function `x`, defined as the difference between the `natDegree` of its numerator and the `natDegree` of its denominator. In particular, `intDegree 0 = 0`. -/ def intDegree (x : RatFunc K) : ℤ := natDegree x.num - natDegree x.denom #align ratfunc.int_degree RatFunc.intDegree @[simp] theorem intDegree_zero : intDegree (0 : RatFunc K) = 0 := by rw [intDegree, num_zero, natDegree_zero, denom_zero, natDegree_one, sub_self] #align ratfunc.int_degree_zero RatFunc.intDegree_zero @[simp] theorem intDegree_one : intDegree (1 : RatFunc K) = 0 := by rw [intDegree, num_one, denom_one, sub_self] #align ratfunc.int_degree_one RatFunc.intDegree_one @[simp] theorem intDegree_C (k : K) : intDegree (C k) = 0 := by rw [intDegree, num_C, natDegree_C, denom_C, natDegree_one, sub_self] set_option linter.uppercaseLean3 false in #align ratfunc.int_degree_C RatFunc.intDegree_C @[simp] theorem intDegree_X : intDegree (X : RatFunc K) = 1 := by rw [intDegree, num_X, Polynomial.natDegree_X, denom_X, Polynomial.natDegree_one, Int.ofNat_one, Int.ofNat_zero, sub_zero] set_option linter.uppercaseLean3 false in #align ratfunc.int_degree_X RatFunc.intDegree_X @[simp] theorem intDegree_polynomial {p : K[X]} : intDegree (algebraMap K[X] (RatFunc K) p) = natDegree p := by rw [intDegree, RatFunc.num_algebraMap, RatFunc.denom_algebraMap, Polynomial.natDegree_one, Int.ofNat_zero, sub_zero] #align ratfunc.int_degree_polynomial RatFunc.intDegree_polynomial
Mathlib/FieldTheory/RatFunc/Degree.lean
71
81
theorem intDegree_mul {x y : RatFunc K} (hx : x ≠ 0) (hy : y ≠ 0) : intDegree (x * y) = intDegree x + intDegree y := by
simp only [intDegree, add_sub, sub_add, sub_sub_eq_add_sub, sub_sub, sub_eq_sub_iff_add_eq_add] norm_cast rw [← Polynomial.natDegree_mul x.denom_ne_zero y.denom_ne_zero, ← Polynomial.natDegree_mul (RatFunc.num_ne_zero (mul_ne_zero hx hy)) (mul_ne_zero x.denom_ne_zero y.denom_ne_zero), ← Polynomial.natDegree_mul (RatFunc.num_ne_zero hx) (RatFunc.num_ne_zero hy), ← Polynomial.natDegree_mul (mul_ne_zero (RatFunc.num_ne_zero hx) (RatFunc.num_ne_zero hy)) (x * y).denom_ne_zero, RatFunc.num_denom_mul]
/- Copyright (c) 2022 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker -/ import Mathlib.Analysis.InnerProductSpace.Adjoint #align_import analysis.inner_product_space.positive from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c" /-! # Positive operators In this file we define positive operators in a Hilbert space. We follow Bourbaki's choice of requiring self adjointness in the definition. ## Main definitions * `IsPositive` : a continuous linear map is positive if it is self adjoint and `∀ x, 0 ≤ re ⟪T x, x⟫` ## Main statements * `ContinuousLinearMap.IsPositive.conj_adjoint` : if `T : E →L[𝕜] E` is positive, then for any `S : E →L[𝕜] F`, `S ∘L T ∘L S†` is also positive. * `ContinuousLinearMap.isPositive_iff_complex` : in a ***complex*** Hilbert space, checking that `⟪T x, x⟫` is a nonnegative real number for all `x` suffices to prove that `T` is positive ## References * [Bourbaki, *Topological Vector Spaces*][bourbaki1987] ## Tags Positive operator -/ open InnerProductSpace RCLike ContinuousLinearMap open scoped InnerProduct ComplexConjugate namespace ContinuousLinearMap variable {𝕜 E F : Type*} [RCLike 𝕜] variable [NormedAddCommGroup E] [NormedAddCommGroup F] variable [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 F] variable [CompleteSpace E] [CompleteSpace F] local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y /-- A continuous linear endomorphism `T` of a Hilbert space is **positive** if it is self adjoint and `∀ x, 0 ≤ re ⟪T x, x⟫`. -/ def IsPositive (T : E →L[𝕜] E) : Prop := IsSelfAdjoint T ∧ ∀ x, 0 ≤ T.reApplyInnerSelf x #align continuous_linear_map.is_positive ContinuousLinearMap.IsPositive theorem IsPositive.isSelfAdjoint {T : E →L[𝕜] E} (hT : IsPositive T) : IsSelfAdjoint T := hT.1 #align continuous_linear_map.is_positive.is_self_adjoint ContinuousLinearMap.IsPositive.isSelfAdjoint theorem IsPositive.inner_nonneg_left {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) : 0 ≤ re ⟪T x, x⟫ := hT.2 x #align continuous_linear_map.is_positive.inner_nonneg_left ContinuousLinearMap.IsPositive.inner_nonneg_left theorem IsPositive.inner_nonneg_right {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) : 0 ≤ re ⟪x, T x⟫ := by rw [inner_re_symm]; exact hT.inner_nonneg_left x #align continuous_linear_map.is_positive.inner_nonneg_right ContinuousLinearMap.IsPositive.inner_nonneg_right theorem isPositive_zero : IsPositive (0 : E →L[𝕜] E) := by refine ⟨isSelfAdjoint_zero _, fun x => ?_⟩ change 0 ≤ re ⟪_, _⟫ rw [zero_apply, inner_zero_left, ZeroHomClass.map_zero] #align continuous_linear_map.is_positive_zero ContinuousLinearMap.isPositive_zero theorem isPositive_one : IsPositive (1 : E →L[𝕜] E) := ⟨isSelfAdjoint_one _, fun _ => inner_self_nonneg⟩ #align continuous_linear_map.is_positive_one ContinuousLinearMap.isPositive_one theorem IsPositive.add {T S : E →L[𝕜] E} (hT : T.IsPositive) (hS : S.IsPositive) : (T + S).IsPositive := by refine ⟨hT.isSelfAdjoint.add hS.isSelfAdjoint, fun x => ?_⟩ rw [reApplyInnerSelf, add_apply, inner_add_left, map_add] exact add_nonneg (hT.inner_nonneg_left x) (hS.inner_nonneg_left x) #align continuous_linear_map.is_positive.add ContinuousLinearMap.IsPositive.add theorem IsPositive.conj_adjoint {T : E →L[𝕜] E} (hT : T.IsPositive) (S : E →L[𝕜] F) : (S ∘L T ∘L S†).IsPositive := by refine ⟨hT.isSelfAdjoint.conj_adjoint S, fun x => ?_⟩ rw [reApplyInnerSelf, comp_apply, ← adjoint_inner_right] exact hT.inner_nonneg_left _ #align continuous_linear_map.is_positive.conj_adjoint ContinuousLinearMap.IsPositive.conj_adjoint
Mathlib/Analysis/InnerProductSpace/Positive.lean
95
98
theorem IsPositive.adjoint_conj {T : E →L[𝕜] E} (hT : T.IsPositive) (S : F →L[𝕜] E) : (S† ∘L T ∘L S).IsPositive := by
convert hT.conj_adjoint (S†) rw [adjoint_adjoint]
/- 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.Dynamics.BirkhoffSum.Basic import Mathlib.Algebra.Module.Basic /-! # Birkhoff average In this file we define `birkhoffAverage f g n x` to be $$ \frac{1}{n}\sum_{k=0}^{n-1}g(f^{[k]}(x)), $$ where `f : α → α` is a self-map on some type `α`, `g : α → M` is a function from `α` to a module over a division semiring `R`, and `R` is used to formalize division by `n` as `(n : R)⁻¹ • _`. While we need an auxiliary division semiring `R` to define `birkhoffAverage`, the definition does not depend on the choice of `R`, see `birkhoffAverage_congr_ring`. -/ open Finset section birkhoffAverage variable (R : Type*) {α M : Type*} [DivisionSemiring R] [AddCommMonoid M] [Module R M] /-- The average value of `g` on the first `n` points of the orbit of `x` under `f`, i.e. the Birkhoff sum `∑ k ∈ Finset.range n, g (f^[k] x)` divided by `n`. This average appears in many ergodic theorems which say that `(birkhoffAverage R f g · x)` converges to the "space average" `⨍ x, g x ∂μ` as `n → ∞`. We use an auxiliary `[DivisionSemiring R]` to define division by `n`. However, the definition does not depend on the choice of `R`, see `birkhoffAverage_congr_ring`. -/ def birkhoffAverage (f : α → α) (g : α → M) (n : ℕ) (x : α) : M := (n : R)⁻¹ • birkhoffSum f g n x theorem birkhoffAverage_zero (f : α → α) (g : α → M) (x : α) : birkhoffAverage R f g 0 x = 0 := by simp [birkhoffAverage] @[simp] theorem birkhoffAverage_zero' (f : α → α) (g : α → M) : birkhoffAverage R f g 0 = 0 := funext <| birkhoffAverage_zero _ _ _
Mathlib/Dynamics/BirkhoffSum/Average.lean
50
51
theorem birkhoffAverage_one (f : α → α) (g : α → M) (x : α) : birkhoffAverage R f g 1 x = g x := by
simp [birkhoffAverage]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Data.Set.Function import Mathlib.Logic.Function.Iterate import Mathlib.GroupTheory.Perm.Basic #align_import dynamics.fixed_points.basic from "leanprover-community/mathlib"@"b86832321b586c6ac23ef8cdef6a7a27e42b13bd" /-! # Fixed points of a self-map In this file we define * the predicate `IsFixedPt f x := f x = x`; * the set `fixedPoints f` of fixed points of a self-map `f`. We also prove some simple lemmas about `IsFixedPt` and `∘`, `iterate`, and `Semiconj`. ## Tags fixed point -/ open Equiv universe u v variable {α : Type u} {β : Type v} {f fa g : α → α} {x y : α} {fb : β → β} {m n k : ℕ} {e : Perm α} namespace Function open Function (Commute) /-- A point `x` is a fixed point of `f : α → α` if `f x = x`. -/ def IsFixedPt (f : α → α) (x : α) := f x = x #align function.is_fixed_pt Function.IsFixedPt /-- Every point is a fixed point of `id`. -/ theorem isFixedPt_id (x : α) : IsFixedPt id x := (rfl : _) #align function.is_fixed_pt_id Function.isFixedPt_id namespace IsFixedPt instance decidable [h : DecidableEq α] {f : α → α} {x : α} : Decidable (IsFixedPt f x) := h (f x) x /-- If `x` is a fixed point of `f`, then `f x = x`. This is useful, e.g., for `rw` or `simp`. -/ protected theorem eq (hf : IsFixedPt f x) : f x = x := hf #align function.is_fixed_pt.eq Function.IsFixedPt.eq /-- If `x` is a fixed point of `f` and `g`, then it is a fixed point of `f ∘ g`. -/ protected theorem comp (hf : IsFixedPt f x) (hg : IsFixedPt g x) : IsFixedPt (f ∘ g) x := calc f (g x) = f x := congr_arg f hg _ = x := hf #align function.is_fixed_pt.comp Function.IsFixedPt.comp /-- If `x` is a fixed point of `f`, then it is a fixed point of `f^[n]`. -/ protected theorem iterate (hf : IsFixedPt f x) (n : ℕ) : IsFixedPt f^[n] x := iterate_fixed hf n #align function.is_fixed_pt.iterate Function.IsFixedPt.iterate /-- If `x` is a fixed point of `f ∘ g` and `g`, then it is a fixed point of `f`. -/ theorem left_of_comp (hfg : IsFixedPt (f ∘ g) x) (hg : IsFixedPt g x) : IsFixedPt f x := calc f x = f (g x) := congr_arg f hg.symm _ = x := hfg #align function.is_fixed_pt.left_of_comp Function.IsFixedPt.left_of_comp /-- If `x` is a fixed point of `f` and `g` is a left inverse of `f`, then `x` is a fixed point of `g`. -/ theorem to_leftInverse (hf : IsFixedPt f x) (h : LeftInverse g f) : IsFixedPt g x := calc g x = g (f x) := congr_arg g hf.symm _ = x := h x #align function.is_fixed_pt.to_left_inverse Function.IsFixedPt.to_leftInverse /-- If `g` (semi)conjugates `fa` to `fb`, then it sends fixed points of `fa` to fixed points of `fb`. -/ protected theorem map {x : α} (hx : IsFixedPt fa x) {g : α → β} (h : Semiconj g fa fb) : IsFixedPt fb (g x) := calc fb (g x) = g (fa x) := (h.eq x).symm _ = g x := congr_arg g hx #align function.is_fixed_pt.map Function.IsFixedPt.map protected theorem apply {x : α} (hx : IsFixedPt f x) : IsFixedPt f (f x) := by convert hx #align function.is_fixed_pt.apply Function.IsFixedPt.apply
Mathlib/Dynamics/FixedPoints/Basic.lean
97
100
theorem preimage_iterate {s : Set α} (h : IsFixedPt (Set.preimage f) s) (n : ℕ) : IsFixedPt (Set.preimage f^[n]) s := by
rw [Set.preimage_iterate_eq] exact h.iterate n
/- Copyright (c) 2021 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca -/ import Mathlib.RingTheory.Finiteness import Mathlib.LinearAlgebra.FreeModule.Basic #align_import linear_algebra.free_module.finite.basic from "leanprover-community/mathlib"@"59628387770d82eb6f6dd7b7107308aa2509ec95" /-! # Finite and free modules We provide some instances for finite and free modules. ## Main results * `Module.Free.ChooseBasisIndex.fintype` : If a free module is finite, then any basis is finite. * `Module.Finite.of_basis` : A free module with a basis indexed by a `Fintype` is finite. -/ universe u v w variable (R : Type u) (M : Type v) (N : Type w) namespace Module.Free section Ring variable [Ring R] [AddCommGroup M] [Module R M] [Module.Free R M] /-- If a free module is finite, then the arbitrary basis is finite. -/ noncomputable instance ChooseBasisIndex.fintype [Module.Finite R M] : Fintype (Module.Free.ChooseBasisIndex R M) := by refine @Fintype.ofFinite _ ?_ cases subsingleton_or_nontrivial R · have := Module.subsingleton R M rw [ChooseBasisIndex] infer_instance · exact Module.Finite.finite_basis (chooseBasis _ _) #align module.free.choose_basis_index.fintype Module.Free.ChooseBasisIndex.fintype end Ring section CommRing variable [CommRing R] [AddCommGroup M] [Module R M] [Module.Free R M] variable [AddCommGroup N] [Module R N] [Module.Free R N] variable {R} /-- A free module with a basis indexed by a `Fintype` is finite. -/
Mathlib/LinearAlgebra/FreeModule/Finite/Basic.lean
53
58
theorem _root_.Module.Finite.of_basis {R M ι : Type*} [Semiring R] [AddCommMonoid M] [Module R M] [_root_.Finite ι] (b : Basis ι R M) : Module.Finite R M := by
cases nonempty_fintype ι classical refine ⟨⟨Finset.univ.image b, ?_⟩⟩ simp only [Set.image_univ, Finset.coe_univ, Finset.coe_image, Basis.span_eq]
/- 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.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" /-! # Basis on a quaternion-like algebra ## Main definitions * `QuaternionAlgebra.Basis A c₁ c₂`: a basis for a subspace of an `R`-algebra `A` that has the same algebra structure as `ℍ[R,c₁,c₂]`. * `QuaternionAlgebra.Basis.self R`: the canonical basis for `ℍ[R,c₁,c₂]`. * `QuaternionAlgebra.Basis.compHom b f`: transform a basis `b` by an AlgHom `f`. * `QuaternionAlgebra.lift`: Define an `AlgHom` out of `ℍ[R,c₁,c₂]` by its action on the basis elements `i`, `j`, and `k`. In essence, this is a universal property. Analogous to `Complex.lift`, but takes a bundled `QuaternionAlgebra.Basis` instead of just a `Subtype` as the amount of data / proves is non-negligible. -/ open Quaternion namespace QuaternionAlgebra /-- A quaternion basis contains the information both sufficient and necessary to construct an `R`-algebra homomorphism from `ℍ[R,c₁,c₂]` to `A`; or equivalently, a surjective `R`-algebra homomorphism from `ℍ[R,c₁,c₂]` to an `R`-subalgebra of `A`. Note that for definitional convenience, `k` is provided as a field even though `i_mul_j` fully determines it. -/ structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis /-- Since `k` is redundant, it is not necessary to show `q₁.k = q₂.k` when showing `q₁ = q₂`. -/ @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) /-- There is a natural quaternionic basis for the `QuaternionAlgebra`. -/ @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp]
Mathlib/Algebra/QuaternionBasis.lean
99
100
theorem j_mul_k : q.j * q.k = -c₂ • q.i := by
rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul]
/- Copyright (c) 2014 Floris van Doorn (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Leonardo de Moura, Jeremy Avigad, Mario Carneiro -/ import Mathlib.Data.Nat.Bits import Mathlib.Order.Lattice #align_import data.nat.size from "leanprover-community/mathlib"@"18a5306c091183ac90884daa9373fa3b178e8607" /-! Lemmas about `size`. -/ namespace Nat /-! ### `shiftLeft` and `shiftRight` -/ section set_option linter.deprecated false theorem shiftLeft_eq_mul_pow (m) : ∀ n, m <<< n = m * 2 ^ n := shiftLeft_eq _ #align nat.shiftl_eq_mul_pow Nat.shiftLeft_eq_mul_pow theorem shiftLeft'_tt_eq_mul_pow (m) : ∀ n, shiftLeft' true m n + 1 = (m + 1) * 2 ^ n | 0 => by simp [shiftLeft', pow_zero, Nat.one_mul] | k + 1 => by change bit1 (shiftLeft' true m k) + 1 = (m + 1) * (2 ^ k * 2) rw [bit1_val] change 2 * (shiftLeft' true m k + 1) = _ rw [shiftLeft'_tt_eq_mul_pow m k, mul_left_comm, mul_comm 2] #align nat.shiftl'_tt_eq_mul_pow Nat.shiftLeft'_tt_eq_mul_pow end #align nat.one_shiftl Nat.one_shiftLeft #align nat.zero_shiftl Nat.zero_shiftLeft #align nat.shiftr_eq_div_pow Nat.shiftRight_eq_div_pow theorem shiftLeft'_ne_zero_left (b) {m} (h : m ≠ 0) (n) : shiftLeft' b m n ≠ 0 := by induction n <;> simp [bit_ne_zero, shiftLeft', *] #align nat.shiftl'_ne_zero_left Nat.shiftLeft'_ne_zero_left theorem shiftLeft'_tt_ne_zero (m) : ∀ {n}, (n ≠ 0) → shiftLeft' true m n ≠ 0 | 0, h => absurd rfl h | succ _, _ => Nat.bit1_ne_zero _ #align nat.shiftl'_tt_ne_zero Nat.shiftLeft'_tt_ne_zero /-! ### `size` -/ @[simp] theorem size_zero : size 0 = 0 := by simp [size] #align nat.size_zero Nat.size_zero @[simp] theorem size_bit {b n} (h : bit b n ≠ 0) : size (bit b n) = succ (size n) := by rw [size] conv => lhs rw [binaryRec] simp [h] rw [div2_bit] #align nat.size_bit Nat.size_bit section set_option linter.deprecated false @[simp] theorem size_bit0 {n} (h : n ≠ 0) : size (bit0 n) = succ (size n) := @size_bit false n (Nat.bit0_ne_zero h) #align nat.size_bit0 Nat.size_bit0 @[simp] theorem size_bit1 (n) : size (bit1 n) = succ (size n) := @size_bit true n (Nat.bit1_ne_zero n) #align nat.size_bit1 Nat.size_bit1 @[simp] theorem size_one : size 1 = 1 := show size (bit1 0) = 1 by rw [size_bit1, size_zero] #align nat.size_one Nat.size_one end @[simp]
Mathlib/Data/Nat/Size.lean
85
97
theorem size_shiftLeft' {b m n} (h : shiftLeft' b m n ≠ 0) : size (shiftLeft' b m n) = size m + n := by
induction' n with n IH <;> simp [shiftLeft'] at h ⊢ rw [size_bit h, Nat.add_succ] by_cases s0 : shiftLeft' b m n = 0 <;> [skip; rw [IH s0]] rw [s0] at h ⊢ cases b; · exact absurd rfl h have : shiftLeft' true m n + 1 = 1 := congr_arg (· + 1) s0 rw [shiftLeft'_tt_eq_mul_pow] at this obtain rfl := succ.inj (eq_one_of_dvd_one ⟨_, this.symm⟩) simp only [zero_add, one_mul] at this obtain rfl : n = 0 := not_ne_iff.1 fun hn ↦ ne_of_gt (Nat.one_lt_pow hn (by decide)) this rfl
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Topology.MetricSpace.Lipschitz import Mathlib.Analysis.SpecialFunctions.Pow.Continuity #align_import topology.metric_space.holder from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8" /-! # Hölder continuous functions In this file we define Hölder continuity on a set and on the whole space. We also prove some basic properties of Hölder continuous functions. ## Main definitions * `HolderOnWith`: `f : X → Y` is said to be *Hölder continuous* with constant `C : ℝ≥0` and exponent `r : ℝ≥0` on a set `s`, if `edist (f x) (f y) ≤ C * edist x y ^ r` for all `x y ∈ s`; * `HolderWith`: `f : X → Y` is said to be *Hölder continuous* with constant `C : ℝ≥0` and exponent `r : ℝ≥0`, if `edist (f x) (f y) ≤ C * edist x y ^ r` for all `x y : X`. ## Implementation notes We use the type `ℝ≥0` (a.k.a. `NNReal`) for `C` because this type has coercion both to `ℝ` and `ℝ≥0∞`, so it can be easily used both in inequalities about `dist` and `edist`. We also use `ℝ≥0` for `r` to ensure that `d ^ r` is monotone in `d`. It might be a good idea to use `ℝ>0` for `r` but we don't have this type in `mathlib` (yet). ## Tags Hölder continuity, Lipschitz continuity -/ variable {X Y Z : Type*} open Filter Set open NNReal ENNReal Topology section Emetric variable [PseudoEMetricSpace X] [PseudoEMetricSpace Y] [PseudoEMetricSpace Z] /-- A function `f : X → Y` between two `PseudoEMetricSpace`s is Hölder continuous with constant `C : ℝ≥0` and exponent `r : ℝ≥0`, if `edist (f x) (f y) ≤ C * edist x y ^ r` for all `x y : X`. -/ def HolderWith (C r : ℝ≥0) (f : X → Y) : Prop := ∀ x y, edist (f x) (f y) ≤ (C : ℝ≥0∞) * edist x y ^ (r : ℝ) #align holder_with HolderWith /-- A function `f : X → Y` between two `PseudoEMetricSpace`s is Hölder continuous with constant `C : ℝ≥0` and exponent `r : ℝ≥0` on a set `s : Set X`, if `edist (f x) (f y) ≤ C * edist x y ^ r` for all `x y ∈ s`. -/ def HolderOnWith (C r : ℝ≥0) (f : X → Y) (s : Set X) : Prop := ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) ≤ (C : ℝ≥0∞) * edist x y ^ (r : ℝ) #align holder_on_with HolderOnWith @[simp] theorem holderOnWith_empty (C r : ℝ≥0) (f : X → Y) : HolderOnWith C r f ∅ := fun _ hx => hx.elim #align holder_on_with_empty holderOnWith_empty @[simp] theorem holderOnWith_singleton (C r : ℝ≥0) (f : X → Y) (x : X) : HolderOnWith C r f {x} := by rintro a (rfl : a = x) b (rfl : b = a) rw [edist_self] exact zero_le _ #align holder_on_with_singleton holderOnWith_singleton theorem Set.Subsingleton.holderOnWith {s : Set X} (hs : s.Subsingleton) (C r : ℝ≥0) (f : X → Y) : HolderOnWith C r f s := hs.induction_on (holderOnWith_empty C r f) (holderOnWith_singleton C r f) #align set.subsingleton.holder_on_with Set.Subsingleton.holderOnWith theorem holderOnWith_univ {C r : ℝ≥0} {f : X → Y} : HolderOnWith C r f univ ↔ HolderWith C r f := by simp only [HolderOnWith, HolderWith, mem_univ, true_imp_iff] #align holder_on_with_univ holderOnWith_univ @[simp]
Mathlib/Topology/MetricSpace/Holder.lean
82
84
theorem holderOnWith_one {C : ℝ≥0} {f : X → Y} {s : Set X} : HolderOnWith C 1 f s ↔ LipschitzOnWith C f s := by
simp only [HolderOnWith, LipschitzOnWith, NNReal.coe_one, ENNReal.rpow_one]
/- Copyright (c) 2022 Yaël Dillies, George Shakan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, George Shakan -/ import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Data.Finset.Pointwise import Mathlib.Tactic.GCongr #align_import combinatorics.additive.pluennecke_ruzsa from "leanprover-community/mathlib"@"4aab2abced69a9e579b1e6dc2856ed3db48e2cbd" /-! # The Plünnecke-Ruzsa inequality This file proves Ruzsa's triangle inequality, the Plünnecke-Petridis lemma, and the Plünnecke-Ruzsa inequality. ## Main declarations * `Finset.card_sub_mul_le_card_sub_mul_card_sub`: Ruzsa's triangle inequality, difference version. * `Finset.card_add_mul_le_card_add_mul_card_add`: Ruzsa's triangle inequality, sum version. * `Finset.pluennecke_petridis`: The Plünnecke-Petridis lemma. * `Finset.card_smul_div_smul_le`: The Plünnecke-Ruzsa inequality. ## References * [Giorgis Petridis, *The Plünnecke-Ruzsa inequality: an overview*][petridis2014] * [Terrence Tao, Van Vu, *Additive Combinatorics][tao-vu] -/ open Nat open NNRat Pointwise namespace Finset variable {α : Type*} [CommGroup α] [DecidableEq α] {A B C : Finset α} /-- **Ruzsa's triangle inequality**. Division version. -/ @[to_additive card_sub_mul_le_card_sub_mul_card_sub "**Ruzsa's triangle inequality**. Subtraction version."] theorem card_div_mul_le_card_div_mul_card_div (A B C : Finset α) : (A / C).card * B.card ≤ (A / B).card * (B / C).card := by rw [← card_product (A / B), ← mul_one ((A / B) ×ˢ (B / C)).card] refine card_mul_le_card_mul (fun b ac ↦ ac.1 * ac.2 = b) (fun x hx ↦ ?_) fun x _ ↦ card_le_one_iff.2 fun hu hv ↦ ((mem_bipartiteBelow _).1 hu).2.symm.trans ?_ obtain ⟨a, ha, c, hc, rfl⟩ := mem_div.1 hx refine card_le_card_of_inj_on (fun b ↦ (a / b, b / c)) (fun b hb ↦ ?_) fun b₁ _ b₂ _ h ↦ ?_ · rw [mem_bipartiteAbove] exact ⟨mk_mem_product (div_mem_div ha hb) (div_mem_div hb hc), div_mul_div_cancel' _ _ _⟩ · exact div_right_injective (Prod.ext_iff.1 h).1 · exact ((mem_bipartiteBelow _).1 hv).2 #align finset.card_div_mul_le_card_div_mul_card_div Finset.card_div_mul_le_card_div_mul_card_div #align finset.card_sub_mul_le_card_sub_mul_card_sub Finset.card_sub_mul_le_card_sub_mul_card_sub /-- **Ruzsa's triangle inequality**. Div-mul-mul version. -/ @[to_additive card_sub_mul_le_card_add_mul_card_add "**Ruzsa's triangle inequality**. Sub-add-add version."] theorem card_div_mul_le_card_mul_mul_card_mul (A B C : Finset α) : (A / C).card * B.card ≤ (A * B).card * (B * C).card := by rw [← div_inv_eq_mul, ← card_inv B, ← card_inv (B * C), mul_inv, ← div_eq_mul_inv] exact card_div_mul_le_card_div_mul_card_div _ _ _ #align finset.card_div_mul_le_card_mul_mul_card_mul Finset.card_div_mul_le_card_mul_mul_card_mul #align finset.card_sub_mul_le_card_add_mul_card_add Finset.card_sub_mul_le_card_add_mul_card_add /-- **Ruzsa's triangle inequality**. Mul-div-div version. -/ @[to_additive card_add_mul_le_card_sub_mul_card_add "**Ruzsa's triangle inequality**. Add-sub-sub version."]
Mathlib/Combinatorics/Additive/PluenneckeRuzsa.lean
73
76
theorem card_mul_mul_le_card_div_mul_card_mul (A B C : Finset α) : (A * C).card * B.card ≤ (A / B).card * (B * C).card := by
rw [← div_inv_eq_mul, ← div_inv_eq_mul B] exact card_div_mul_le_card_div_mul_card_div _ _ _
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.Calculus.ContDiff.RCLike import Mathlib.MeasureTheory.Measure.Hausdorff #align_import topology.metric_space.hausdorff_dimension from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92" /-! # Hausdorff dimension The Hausdorff dimension of a set `X` in an (extended) metric space is the unique number `dimH s : ℝ≥0∞` such that for any `d : ℝ≥0` we have - `μH[d] s = 0` if `dimH s < d`, and - `μH[d] s = ∞` if `d < dimH s`. In this file we define `dimH s` to be the Hausdorff dimension of `s`, then prove some basic properties of Hausdorff dimension. ## Main definitions * `MeasureTheory.dimH`: the Hausdorff dimension of a set. For the Hausdorff dimension of the whole space we use `MeasureTheory.dimH (Set.univ : Set X)`. ## Main results ### Basic properties of Hausdorff dimension * `hausdorffMeasure_of_lt_dimH`, `dimH_le_of_hausdorffMeasure_ne_top`, `le_dimH_of_hausdorffMeasure_eq_top`, `hausdorffMeasure_of_dimH_lt`, `measure_zero_of_dimH_lt`, `le_dimH_of_hausdorffMeasure_ne_zero`, `dimH_of_hausdorffMeasure_ne_zero_ne_top`: various forms of the characteristic property of the Hausdorff dimension; * `dimH_union`: the Hausdorff dimension of the union of two sets is the maximum of their Hausdorff dimensions. * `dimH_iUnion`, `dimH_bUnion`, `dimH_sUnion`: the Hausdorff dimension of a countable union of sets is the supremum of their Hausdorff dimensions; * `dimH_empty`, `dimH_singleton`, `Set.Subsingleton.dimH_zero`, `Set.Countable.dimH_zero` : `dimH s = 0` whenever `s` is countable; ### (Pre)images under (anti)lipschitz and Hölder continuous maps * `HolderWith.dimH_image_le` etc: if `f : X → Y` is Hölder continuous with exponent `r > 0`, then for any `s`, `dimH (f '' s) ≤ dimH s / r`. We prove versions of this statement for `HolderWith`, `HolderOnWith`, and locally Hölder maps, as well as for `Set.image` and `Set.range`. * `LipschitzWith.dimH_image_le` etc: Lipschitz continuous maps do not increase the Hausdorff dimension of sets. * for a map that is known to be both Lipschitz and antilipschitz (e.g., for an `Isometry` or a `ContinuousLinearEquiv`) we also prove `dimH (f '' s) = dimH s`. ### Hausdorff measure in `ℝⁿ` * `Real.dimH_of_nonempty_interior`: if `s` is a set in a finite dimensional real vector space `E` with nonempty interior, then the Hausdorff dimension of `s` is equal to the dimension of `E`. * `dense_compl_of_dimH_lt_finrank`: if `s` is a set in a finite dimensional real vector space `E` with Hausdorff dimension strictly less than the dimension of `E`, the `s` has a dense complement. * `ContDiff.dense_compl_range_of_finrank_lt_finrank`: the complement to the range of a `C¹` smooth map is dense provided that the dimension of the domain is strictly less than the dimension of the codomain. ## Notations We use the following notation localized in `MeasureTheory`. It is defined in `MeasureTheory.Measure.Hausdorff`. - `μH[d]` : `MeasureTheory.Measure.hausdorffMeasure d` ## Implementation notes * The definition of `dimH` explicitly uses `borel X` as a measurable space structure. This way we can formulate lemmas about Hausdorff dimension without assuming that the environment has a `[MeasurableSpace X]` instance that is equal but possibly not defeq to `borel X`. Lemma `dimH_def` unfolds this definition using whatever `[MeasurableSpace X]` instance we have in the environment (as long as it is equal to `borel X`). * The definition `dimH` is irreducible; use API lemmas or `dimH_def` instead. ## Tags Hausdorff measure, Hausdorff dimension, dimension -/ open scoped MeasureTheory ENNReal NNReal Topology open MeasureTheory MeasureTheory.Measure Set TopologicalSpace FiniteDimensional Filter variable {ι X Y : Type*} [EMetricSpace X] [EMetricSpace Y] /-- Hausdorff dimension of a set in an (e)metric space. -/ @[irreducible] noncomputable def dimH (s : Set X) : ℝ≥0∞ := by borelize X; exact ⨆ (d : ℝ≥0) (_ : @hausdorffMeasure X _ _ ⟨rfl⟩ d s = ∞), d set_option linter.uppercaseLean3 false in #align dimH dimH /-! ### Basic properties -/ section Measurable variable [MeasurableSpace X] [BorelSpace X] /-- Unfold the definition of `dimH` using `[MeasurableSpace X] [BorelSpace X]` from the environment. -/
Mathlib/Topology/MetricSpace/HausdorffDimension.lean
110
111
theorem dimH_def (s : Set X) : dimH s = ⨆ (d : ℝ≥0) (_ : μH[d] s = ∞), (d : ℝ≥0∞) := by
borelize X; rw [dimH]
/- Copyright (c) 2021 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.Data.Matrix.Basis import Mathlib.Data.Matrix.DMatrix import Mathlib.LinearAlgebra.Matrix.Determinant.Basic import Mathlib.LinearAlgebra.Matrix.Reindex import Mathlib.Tactic.FieldSimp #align_import linear_algebra.matrix.transvection from "leanprover-community/mathlib"@"0e2aab2b0d521f060f62a14d2cf2e2c54e8491d6" /-! # Transvections Transvections are matrices of the form `1 + StdBasisMatrix i j c`, where `StdBasisMatrix i j c` is the basic matrix with a `c` at position `(i, j)`. Multiplying by such a transvection on the left (resp. on the right) amounts to adding `c` times the `j`-th row to the `i`-th row (resp `c` times the `i`-th column to the `j`-th column). Therefore, they are useful to present algorithms operating on rows and columns. Transvections are a special case of *elementary matrices* (according to most references, these also contain the matrices exchanging rows, and the matrices multiplying a row by a constant). We show that, over a field, any matrix can be written as `L * D * L'`, where `L` and `L'` are products of transvections and `D` is diagonal. In other words, one can reduce a matrix to diagonal form by operations on its rows and columns, a variant of Gauss' pivot algorithm. ## Main definitions and results * `Transvection i j c` is the matrix equal to `1 + StdBasisMatrix i j c`. * `TransvectionStruct n R` is a structure containing the data of `i, j, c` and a proof that `i ≠ j`. These are often easier to manipulate than straight matrices, especially in inductive arguments. * `exists_list_transvec_mul_diagonal_mul_list_transvec` states that any matrix `M` over a field can be written in the form `t_1 * ... * t_k * D * t'_1 * ... * t'_l`, where `D` is diagonal and the `t_i`, `t'_j` are transvections. * `diagonal_transvection_induction` shows that a property which is true for diagonal matrices and transvections, and invariant under product, is true for all matrices. * `diagonal_transvection_induction_of_det_ne_zero` is the same statement over invertible matrices. ## Implementation details The proof of the reduction results is done inductively on the size of the matrices, reducing an `(r + 1) × (r + 1)` matrix to a matrix whose last row and column are zeroes, except possibly for the last diagonal entry. This step is done as follows. If all the coefficients on the last row and column are zero, there is nothing to do. Otherwise, one can put a nonzero coefficient in the last diagonal entry by a row or column operation, and then subtract this last diagonal entry from the other entries in the last row and column to make them vanish. This step is done in the type `Fin r ⊕ Unit`, where `Fin r` is useful to choose arbitrarily some order in which we cancel the coefficients, and the sum structure is useful to use the formalism of block matrices. To proceed with the induction, we reindex our matrices to reduce to the above situation. -/ universe u₁ u₂ namespace Matrix open Matrix variable (n p : Type*) (R : Type u₂) {𝕜 : Type*} [Field 𝕜] variable [DecidableEq n] [DecidableEq p] variable [CommRing R] section Transvection variable {R n} (i j : n) /-- The transvection matrix `Transvection i j c` is equal to the identity plus `c` at position `(i, j)`. Multiplying by it on the left (as in `Transvection i j c * M`) corresponds to adding `c` times the `j`-th line of `M` to its `i`-th line. Multiplying by it on the right corresponds to adding `c` times the `i`-th column to the `j`-th column. -/ def transvection (c : R) : Matrix n n R := 1 + Matrix.stdBasisMatrix i j c #align matrix.transvection Matrix.transvection @[simp] theorem transvection_zero : transvection i j (0 : R) = 1 := by simp [transvection] #align matrix.transvection_zero Matrix.transvection_zero section /-- A transvection matrix is obtained from the identity by adding `c` times the `j`-th row to the `i`-th row. -/ theorem updateRow_eq_transvection [Finite n] (c : R) : updateRow (1 : Matrix n n R) i ((1 : Matrix n n R) i + c • (1 : Matrix n n R) j) = transvection i j c := by cases nonempty_fintype n ext a b by_cases ha : i = a · by_cases hb : j = b · simp only [updateRow_self, transvection, ha, hb, Pi.add_apply, StdBasisMatrix.apply_same, one_apply_eq, Pi.smul_apply, mul_one, Algebra.id.smul_eq_mul, add_apply] · simp only [updateRow_self, transvection, ha, hb, StdBasisMatrix.apply_of_ne, Pi.add_apply, Ne, not_false_iff, Pi.smul_apply, and_false_iff, one_apply_ne, Algebra.id.smul_eq_mul, mul_zero, add_apply] · simp only [updateRow_ne, transvection, ha, Ne.symm ha, StdBasisMatrix.apply_of_ne, add_zero, Algebra.id.smul_eq_mul, Ne, not_false_iff, DMatrix.add_apply, Pi.smul_apply, mul_zero, false_and_iff, add_apply] #align matrix.update_row_eq_transvection Matrix.updateRow_eq_transvection variable [Fintype n] theorem transvection_mul_transvection_same (h : i ≠ j) (c d : R) : transvection i j c * transvection i j d = transvection i j (c + d) := by simp [transvection, Matrix.add_mul, Matrix.mul_add, h, h.symm, add_smul, add_assoc, stdBasisMatrix_add] #align matrix.transvection_mul_transvection_same Matrix.transvection_mul_transvection_same @[simp]
Mathlib/LinearAlgebra/Matrix/Transvection.lean
120
121
theorem transvection_mul_apply_same (b : n) (c : R) (M : Matrix n n R) : (transvection i j c * M) i b = M i b + c * M j b := by
simp [transvection, Matrix.add_mul]
/- Copyright (c) 2020 Thomas Browning and Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning, Patrick Lutz -/ import Mathlib.GroupTheory.Solvable import Mathlib.FieldTheory.PolynomialGaloisGroup import Mathlib.RingTheory.RootsOfUnity.Basic #align_import field_theory.abel_ruffini from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a" /-! # The Abel-Ruffini Theorem This file proves one direction of the Abel-Ruffini theorem, namely that if an element is solvable by radicals, then its minimal polynomial has solvable Galois group. ## Main definitions * `solvableByRad F E` : the intermediate field of solvable-by-radicals elements ## Main results * the Abel-Ruffini Theorem `solvableByRad.isSolvable'` : An irreducible polynomial with a root that is solvable by radicals has a solvable Galois group. -/ noncomputable section open scoped Classical Polynomial IntermediateField open Polynomial IntermediateField section AbelRuffini variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E] theorem gal_zero_isSolvable : IsSolvable (0 : F[X]).Gal := by infer_instance #align gal_zero_is_solvable gal_zero_isSolvable theorem gal_one_isSolvable : IsSolvable (1 : F[X]).Gal := by infer_instance #align gal_one_is_solvable gal_one_isSolvable theorem gal_C_isSolvable (x : F) : IsSolvable (C x).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_C_is_solvable gal_C_isSolvable theorem gal_X_isSolvable : IsSolvable (X : F[X]).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_X_is_solvable gal_X_isSolvable theorem gal_X_sub_C_isSolvable (x : F) : IsSolvable (X - C x).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_X_sub_C_is_solvable gal_X_sub_C_isSolvable theorem gal_X_pow_isSolvable (n : ℕ) : IsSolvable (X ^ n : F[X]).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_X_pow_is_solvable gal_X_pow_isSolvable theorem gal_mul_isSolvable {p q : F[X]} (_ : IsSolvable p.Gal) (_ : IsSolvable q.Gal) : IsSolvable (p * q).Gal := solvable_of_solvable_injective (Gal.restrictProd_injective p q) #align gal_mul_is_solvable gal_mul_isSolvable theorem gal_prod_isSolvable {s : Multiset F[X]} (hs : ∀ p ∈ s, IsSolvable (Gal p)) : IsSolvable s.prod.Gal := by apply Multiset.induction_on' s · exact gal_one_isSolvable · intro p t hps _ ht rw [Multiset.insert_eq_cons, Multiset.prod_cons] exact gal_mul_isSolvable (hs p hps) ht #align gal_prod_is_solvable gal_prod_isSolvable theorem gal_isSolvable_of_splits {p q : F[X]} (_ : Fact (p.Splits (algebraMap F q.SplittingField))) (hq : IsSolvable q.Gal) : IsSolvable p.Gal := haveI : IsSolvable (q.SplittingField ≃ₐ[F] q.SplittingField) := hq solvable_of_surjective (AlgEquiv.restrictNormalHom_surjective q.SplittingField) #align gal_is_solvable_of_splits gal_isSolvable_of_splits
Mathlib/FieldTheory/AbelRuffini.lean
82
93
theorem gal_isSolvable_tower (p q : F[X]) (hpq : p.Splits (algebraMap F q.SplittingField)) (hp : IsSolvable p.Gal) (hq : IsSolvable (q.map (algebraMap F p.SplittingField)).Gal) : IsSolvable q.Gal := by
let K := p.SplittingField let L := q.SplittingField haveI : Fact (p.Splits (algebraMap F L)) := ⟨hpq⟩ let ϕ : (L ≃ₐ[K] L) ≃* (q.map (algebraMap F K)).Gal := (IsSplittingField.algEquiv L (q.map (algebraMap F K))).autCongr have ϕ_inj : Function.Injective ϕ.toMonoidHom := ϕ.injective haveI : IsSolvable (K ≃ₐ[F] K) := hp haveI : IsSolvable (L ≃ₐ[K] L) := solvable_of_solvable_injective ϕ_inj exact isSolvable_of_isScalarTower F p.SplittingField q.SplittingField
/- Copyright (c) 2021 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Sébastien Gouëzel -/ import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.MeasureTheory.Group.Pointwise import Mathlib.MeasureTheory.Measure.Lebesgue.Basic import Mathlib.MeasureTheory.Measure.Haar.Basic import Mathlib.MeasureTheory.Measure.Doubling import Mathlib.MeasureTheory.Constructions.BorelSpace.Metric #align_import measure_theory.measure.lebesgue.eq_haar from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Relationship between the Haar and Lebesgue measures We prove that the Haar measure and Lebesgue measure are equal on `ℝ` and on `ℝ^ι`, in `MeasureTheory.addHaarMeasure_eq_volume` and `MeasureTheory.addHaarMeasure_eq_volume_pi`. We deduce basic properties of any Haar measure on a finite dimensional real vector space: * `map_linearMap_addHaar_eq_smul_addHaar`: a linear map rescales the Haar measure by the absolute value of its determinant. * `addHaar_preimage_linearMap` : when `f` is a linear map with nonzero determinant, the measure of `f ⁻¹' s` is the measure of `s` multiplied by the absolute value of the inverse of the determinant of `f`. * `addHaar_image_linearMap` : when `f` is a linear map, the measure of `f '' s` is the measure of `s` multiplied by the absolute value of the determinant of `f`. * `addHaar_submodule` : a strict submodule has measure `0`. * `addHaar_smul` : the measure of `r • s` is `|r| ^ dim * μ s`. * `addHaar_ball`: the measure of `ball x r` is `r ^ dim * μ (ball 0 1)`. * `addHaar_closedBall`: the measure of `closedBall x r` is `r ^ dim * μ (ball 0 1)`. * `addHaar_sphere`: spheres have zero measure. This makes it possible to associate a Lebesgue measure to an `n`-alternating map in dimension `n`. This measure is called `AlternatingMap.measure`. Its main property is `ω.measure_parallelepiped v`, stating that the associated measure of the parallelepiped spanned by vectors `v₁, ..., vₙ` is given by `|ω v|`. We also show that a Lebesgue density point `x` of a set `s` (with respect to closed balls) has density one for the rescaled copies `{x} + r • t` of a given set `t` with positive measure, in `tendsto_addHaar_inter_smul_one_of_density_one`. In particular, `s` intersects `{x} + r • t` for small `r`, see `eventually_nonempty_inter_smul_of_density_one`. Statements on integrals of functions with respect to an additive Haar measure can be found in `MeasureTheory.Measure.Haar.NormedSpace`. -/ assert_not_exists MeasureTheory.integral open TopologicalSpace Set Filter Metric Bornology open scoped ENNReal Pointwise Topology NNReal /-- The interval `[0,1]` as a compact set with non-empty interior. -/ def TopologicalSpace.PositiveCompacts.Icc01 : PositiveCompacts ℝ where carrier := Icc 0 1 isCompact' := isCompact_Icc interior_nonempty' := by simp_rw [interior_Icc, nonempty_Ioo, zero_lt_one] #align topological_space.positive_compacts.Icc01 TopologicalSpace.PositiveCompacts.Icc01 universe u /-- The set `[0,1]^ι` as a compact set with non-empty interior. -/ def TopologicalSpace.PositiveCompacts.piIcc01 (ι : Type*) [Finite ι] : PositiveCompacts (ι → ℝ) where carrier := pi univ fun _ => Icc 0 1 isCompact' := isCompact_univ_pi fun _ => isCompact_Icc interior_nonempty' := by simp only [interior_pi_set, Set.toFinite, interior_Icc, univ_pi_nonempty_iff, nonempty_Ioo, imp_true_iff, zero_lt_one] #align topological_space.positive_compacts.pi_Icc01 TopologicalSpace.PositiveCompacts.piIcc01 /-- The parallelepiped formed from the standard basis for `ι → ℝ` is `[0,1]^ι` -/ theorem Basis.parallelepiped_basisFun (ι : Type*) [Fintype ι] : (Pi.basisFun ℝ ι).parallelepiped = TopologicalSpace.PositiveCompacts.piIcc01 ι := SetLike.coe_injective <| by refine Eq.trans ?_ ((uIcc_of_le ?_).trans (Set.pi_univ_Icc _ _).symm) · classical convert parallelepiped_single (ι := ι) 1 · exact zero_le_one #align basis.parallelepiped_basis_fun Basis.parallelepiped_basisFun /-- A parallelepiped can be expressed on the standard basis. -/
Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean
84
91
theorem Basis.parallelepiped_eq_map {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] [NormedSpace ℝ E] (b : Basis ι ℝ E) : b.parallelepiped = (PositiveCompacts.piIcc01 ι).map b.equivFun.symm b.equivFunL.symm.continuous b.equivFunL.symm.isOpenMap := by
classical rw [← Basis.parallelepiped_basisFun, ← Basis.parallelepiped_map] congr with x simp
/- 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, Jens Wagemaker, Aaron Anderson -/ import Mathlib.Algebra.GCDMonoid.Basic import Mathlib.Algebra.Order.Ring.Int import Mathlib.Data.Int.GCD /-! # ℕ and ℤ are normalized GCD monoids. ## Main statements * ℕ is a `GCDMonoid` * ℕ is a `NormalizedGCDMonoid` * ℤ is a `NormalizationMonoid` * ℤ is a `GCDMonoid` * ℤ is a `NormalizedGCDMonoid` ## Tags natural numbers, integers, normalization monoid, gcd monoid, greatest common divisor -/ /-- `ℕ` is a gcd_monoid. -/ instance : GCDMonoid ℕ where gcd := Nat.gcd lcm := Nat.lcm gcd_dvd_left := Nat.gcd_dvd_left gcd_dvd_right := Nat.gcd_dvd_right dvd_gcd := Nat.dvd_gcd gcd_mul_lcm a b := by rw [Nat.gcd_mul_lcm]; rfl lcm_zero_left := Nat.lcm_zero_left lcm_zero_right := Nat.lcm_zero_right theorem gcd_eq_nat_gcd (m n : ℕ) : gcd m n = Nat.gcd m n := rfl #align gcd_eq_nat_gcd gcd_eq_nat_gcd theorem lcm_eq_nat_lcm (m n : ℕ) : lcm m n = Nat.lcm m n := rfl #align lcm_eq_nat_lcm lcm_eq_nat_lcm instance : NormalizedGCDMonoid ℕ := { (inferInstance : GCDMonoid ℕ), (inferInstance : NormalizationMonoid ℕ) with normalize_gcd := fun _ _ => normalize_eq _ normalize_lcm := fun _ _ => normalize_eq _ } namespace Int section NormalizationMonoid instance normalizationMonoid : NormalizationMonoid ℤ where normUnit a := if 0 ≤ a then 1 else -1 normUnit_zero := if_pos le_rfl normUnit_mul {a b} hna hnb := by cases' hna.lt_or_lt with ha ha <;> cases' hnb.lt_or_lt with hb hb <;> simp [mul_nonneg_iff, ha.le, ha.not_le, hb.le, hb.not_le] normUnit_coe_units u := (units_eq_one_or u).elim (fun eq => eq.symm ▸ if_pos zero_le_one) fun eq => eq.symm ▸ if_neg (not_le_of_gt <| show (-1 : ℤ) < 0 by decide) -- Porting note: added theorem normUnit_eq (z : ℤ) : normUnit z = if 0 ≤ z then 1 else -1 := rfl
Mathlib/Algebra/GCDMonoid/Nat.lean
67
68
theorem normalize_of_nonneg {z : ℤ} (h : 0 ≤ z) : normalize z = z := by
rw [normalize_apply, normUnit_eq, if_pos h, Units.val_one, mul_one]
/- Copyright (c) 2020 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import Mathlib.Data.Finset.Prod import Mathlib.Data.Sym.Basic import Mathlib.Data.Sym.Sym2.Init import Mathlib.Data.SetLike.Basic #align_import data.sym.sym2 from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # The symmetric square This file defines the symmetric square, which is `α × α` modulo swapping. This is also known as the type of unordered pairs. More generally, the symmetric square is the second symmetric power (see `Data.Sym.Basic`). The equivalence is `Sym2.equivSym`. From the point of view that an unordered pair is equivalent to a multiset of cardinality two (see `Sym2.equivMultiset`), there is a `Mem` instance `Sym2.Mem`, which is a `Prop`-valued membership test. Given `h : a ∈ z` for `z : Sym2 α`, then `Mem.other h` is the other element of the pair, defined using `Classical.choice`. If `α` has decidable equality, then `h.other'` computably gives the other element. The universal property of `Sym2` is provided as `Sym2.lift`, which states that functions from `Sym2 α` are equivalent to symmetric two-argument functions from `α`. Recall that an undirected graph (allowing self loops, but no multiple edges) is equivalent to a symmetric relation on the vertex type `α`. Given a symmetric relation on `α`, the corresponding edge set is constructed by `Sym2.fromRel` which is a special case of `Sym2.lift`. ## Notation The element `Sym2.mk (a, b)` can be written as `s(a, b)` for short. ## Tags symmetric square, unordered pairs, symmetric powers -/ assert_not_exists MonoidWithZero open Finset Function Sym universe u variable {α β γ : Type*} namespace Sym2 /-- This is the relation capturing the notion of pairs equivalent up to permutations. -/ @[aesop (rule_sets := [Sym2]) [safe [constructors, cases], norm]] inductive Rel (α : Type u) : α × α → α × α → Prop | refl (x y : α) : Rel _ (x, y) (x, y) | swap (x y : α) : Rel _ (x, y) (y, x) #align sym2.rel Sym2.Rel #align sym2.rel.refl Sym2.Rel.refl #align sym2.rel.swap Sym2.Rel.swap attribute [refl] Rel.refl @[symm] theorem Rel.symm {x y : α × α} : Rel α x y → Rel α y x := by aesop (rule_sets := [Sym2]) #align sym2.rel.symm Sym2.Rel.symm @[trans] theorem Rel.trans {x y z : α × α} (a : Rel α x y) (b : Rel α y z) : Rel α x z := by aesop (rule_sets := [Sym2]) #align sym2.rel.trans Sym2.Rel.trans theorem Rel.is_equivalence : Equivalence (Rel α) := { refl := fun (x, y) ↦ Rel.refl x y, symm := Rel.symm, trans := Rel.trans } #align sym2.rel.is_equivalence Sym2.Rel.is_equivalence /-- One can use `attribute [local instance] Sym2.Rel.setoid` to temporarily make `Quotient` functionality work for `α × α`. -/ def Rel.setoid (α : Type u) : Setoid (α × α) := ⟨Rel α, Rel.is_equivalence⟩ #align sym2.rel.setoid Sym2.Rel.setoid @[simp] theorem rel_iff' {p q : α × α} : Rel α p q ↔ p = q ∨ p = q.swap := by aesop (rule_sets := [Sym2])
Mathlib/Data/Sym/Sym2.lean
91
92
theorem rel_iff {x y z w : α} : Rel α (x, y) (z, w) ↔ x = z ∧ y = w ∨ x = w ∧ y = z := by
simp
/- Copyright (c) 2020 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou -/ import Mathlib.Algebra.Group.Pi.Lemmas import Mathlib.Algebra.Group.Support #align_import algebra.indicator_function from "leanprover-community/mathlib"@"2445c98ae4b87eabebdde552593519b9b6dc350c" /-! # Indicator function - `Set.indicator (s : Set α) (f : α → β) (a : α)` is `f a` if `a ∈ s` and is `0` otherwise. - `Set.mulIndicator (s : Set α) (f : α → β) (a : α)` is `f a` if `a ∈ s` and is `1` otherwise. ## Implementation note In mathematics, an indicator function or a characteristic function is a function used to indicate membership of an element in a set `s`, having the value `1` for all elements of `s` and the value `0` otherwise. But since it is usually used to restrict a function to a certain set `s`, we let the indicator function take the value `f x` for some function `f`, instead of `1`. If the usual indicator function is needed, just set `f` to be the constant function `fun _ ↦ 1`. The indicator function is implemented non-computably, to avoid having to pass around `Decidable` arguments. This is in contrast with the design of `Pi.single` or `Set.piecewise`. ## Tags indicator, characteristic -/ assert_not_exists MonoidWithZero open Function variable {α β ι M N : Type*} namespace Set section One variable [One M] [One N] {s t : Set α} {f g : α → M} {a : α} /-- `Set.mulIndicator s f a` is `f a` if `a ∈ s`, `1` otherwise. -/ @[to_additive "`Set.indicator s f a` is `f a` if `a ∈ s`, `0` otherwise."] noncomputable def mulIndicator (s : Set α) (f : α → M) (x : α) : M := haveI := Classical.decPred (· ∈ s) if x ∈ s then f x else 1 #align set.mul_indicator Set.mulIndicator @[to_additive (attr := simp)] theorem piecewise_eq_mulIndicator [DecidablePred (· ∈ s)] : s.piecewise f 1 = s.mulIndicator f := funext fun _ => @if_congr _ _ _ _ (id _) _ _ _ _ Iff.rfl rfl rfl #align set.piecewise_eq_mul_indicator Set.piecewise_eq_mulIndicator #align set.piecewise_eq_indicator Set.piecewise_eq_indicator -- Porting note: needed unfold for mulIndicator @[to_additive]
Mathlib/Algebra/Group/Indicator.lean
61
64
theorem mulIndicator_apply (s : Set α) (f : α → M) (a : α) [Decidable (a ∈ s)] : mulIndicator s f a = if a ∈ s then f a else 1 := by
unfold mulIndicator congr
/- Copyright (c) 2020 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.MeasureTheory.Measure.Content import Mathlib.MeasureTheory.Group.Prod import Mathlib.Topology.Algebra.Group.Compact #align_import measure_theory.measure.haar.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Haar measure In this file we prove the existence of Haar measure for a locally compact Hausdorff topological group. We follow the write-up by Jonathan Gleason, *Existence and Uniqueness of Haar Measure*. This is essentially the same argument as in https://en.wikipedia.org/wiki/Haar_measure#A_construction_using_compact_subsets. We construct the Haar measure first on compact sets. For this we define `(K : U)` as the (smallest) number of left-translates of `U` that are needed to cover `K` (`index` in the formalization). Then we define a function `h` on compact sets as `lim_U (K : U) / (K₀ : U)`, where `U` becomes a smaller and smaller open neighborhood of `1`, and `K₀` is a fixed compact set with nonempty interior. This function is `chaar` in the formalization, and we define the limit formally using Tychonoff's theorem. This function `h` forms a content, which we can extend to an outer measure and then a measure (`haarMeasure`). We normalize the Haar measure so that the measure of `K₀` is `1`. Note that `μ` need not coincide with `h` on compact sets, according to [halmos1950measure, ch. X, §53 p.233]. However, we know that `h(K)` lies between `μ(Kᵒ)` and `μ(K)`, where `ᵒ` denotes the interior. We also give a form of uniqueness of Haar measure, for σ-finite measures on second-countable locally compact groups. For more involved statements not assuming second-countability, see the file `MeasureTheory.Measure.Haar.Unique`. ## Main Declarations * `haarMeasure`: the Haar measure on a locally compact Hausdorff group. This is a left invariant regular measure. It takes as argument a compact set of the group (with non-empty interior), and is normalized so that the measure of the given set is 1. * `haarMeasure_self`: the Haar measure is normalized. * `isMulLeftInvariant_haarMeasure`: the Haar measure is left invariant. * `regular_haarMeasure`: the Haar measure is a regular measure. * `isHaarMeasure_haarMeasure`: the Haar measure satisfies the `IsHaarMeasure` typeclass, i.e., it is invariant and gives finite mass to compact sets and positive mass to nonempty open sets. * `haar` : some choice of a Haar measure, on a locally compact Hausdorff group, constructed as `haarMeasure K` where `K` is some arbitrary choice of a compact set with nonempty interior. * `haarMeasure_unique`: Every σ-finite left invariant measure on a second-countable locally compact Hausdorff group is a scalar multiple of the Haar measure. ## References * Paul Halmos (1950), Measure Theory, §53 * Jonathan Gleason, Existence and Uniqueness of Haar Measure - Note: step 9, page 8 contains a mistake: the last defined `μ` does not extend the `μ` on compact sets, see Halmos (1950) p. 233, bottom of the page. This makes some other steps (like step 11) invalid. * https://en.wikipedia.org/wiki/Haar_measure -/ noncomputable section open Set Inv Function TopologicalSpace MeasurableSpace open scoped NNReal Classical ENNReal Pointwise Topology namespace MeasureTheory namespace Measure section Group variable {G : Type*} [Group G] /-! We put the internal functions in the construction of the Haar measure in a namespace, so that the chosen names don't clash with other declarations. We first define a couple of the functions before proving the properties (that require that `G` is a topological group). -/ namespace haar -- Porting note: Even in `noncomputable section`, a definition with `to_additive` require -- `noncomputable` to generate an additive definition. -- Please refer to leanprover/lean4#2077. /-- The index or Haar covering number or ratio of `K` w.r.t. `V`, denoted `(K : V)`: it is the smallest number of (left) translates of `V` that is necessary to cover `K`. It is defined to be 0 if no finite number of translates cover `K`. -/ @[to_additive addIndex "additive version of `MeasureTheory.Measure.haar.index`"] noncomputable def index (K V : Set G) : ℕ := sInf <| Finset.card '' { t : Finset G | K ⊆ ⋃ g ∈ t, (fun h => g * h) ⁻¹' V } #align measure_theory.measure.haar.index MeasureTheory.Measure.haar.index #align measure_theory.measure.haar.add_index MeasureTheory.Measure.haar.addIndex @[to_additive addIndex_empty] theorem index_empty {V : Set G} : index ∅ V = 0 := by simp only [index, Nat.sInf_eq_zero]; left; use ∅ simp only [Finset.card_empty, empty_subset, mem_setOf_eq, eq_self_iff_true, and_self_iff] #align measure_theory.measure.haar.index_empty MeasureTheory.Measure.haar.index_empty #align measure_theory.measure.haar.add_index_empty MeasureTheory.Measure.haar.addIndex_empty variable [TopologicalSpace G] /-- `prehaar K₀ U K` is a weighted version of the index, defined as `(K : U)/(K₀ : U)`. In the applications `K₀` is compact with non-empty interior, `U` is open containing `1`, and `K` is any compact set. The argument `K` is a (bundled) compact set, so that we can consider `prehaar K₀ U` as an element of `haarProduct` (below). -/ @[to_additive "additive version of `MeasureTheory.Measure.haar.prehaar`"] noncomputable def prehaar (K₀ U : Set G) (K : Compacts G) : ℝ := (index (K : Set G) U : ℝ) / index K₀ U #align measure_theory.measure.haar.prehaar MeasureTheory.Measure.haar.prehaar #align measure_theory.measure.haar.add_prehaar MeasureTheory.Measure.haar.addPrehaar @[to_additive]
Mathlib/MeasureTheory/Measure/Haar/Basic.lean
122
123
theorem prehaar_empty (K₀ : PositiveCompacts G) {U : Set G} : prehaar (K₀ : Set G) U ⊥ = 0 := by
rw [prehaar, Compacts.coe_bot, index_empty, Nat.cast_zero, zero_div]
/- Copyright (c) 2023 Luke Mantle. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Luke Mantle, Jake Levinson -/ import Mathlib.RingTheory.Polynomial.Hermite.Basic import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.Calculus.Deriv.Polynomial import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Analysis.SpecialFunctions.ExpDeriv #align_import ring_theory.polynomial.hermite.gaussian from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Hermite polynomials and Gaussians This file shows that the Hermite polynomial `hermite n` is (up to sign) the polynomial factor occurring in the `n`th derivative of a gaussian. ## Results * `Polynomial.deriv_gaussian_eq_hermite_mul_gaussian`: The Hermite polynomial is (up to sign) the polynomial factor occurring in the `n`th derivative of a gaussian. ## References * [Hermite Polynomials](https://en.wikipedia.org/wiki/Hermite_polynomials) -/ noncomputable section open Polynomial namespace Polynomial /-- `hermite n` is (up to sign) the factor appearing in `deriv^[n]` of a gaussian -/ theorem deriv_gaussian_eq_hermite_mul_gaussian (n : ℕ) (x : ℝ) : deriv^[n] (fun y => Real.exp (-(y ^ 2 / 2))) x = (-1 : ℝ) ^ n * aeval x (hermite n) * Real.exp (-(x ^ 2 / 2)) := by rw [mul_assoc] induction' n with n ih generalizing x · rw [Function.iterate_zero_apply, pow_zero, one_mul, hermite_zero, C_1, map_one, one_mul] · replace ih : deriv^[n] _ = _ := _root_.funext ih have deriv_gaussian : deriv (fun y => Real.exp (-(y ^ 2 / 2))) x = -x * Real.exp (-(x ^ 2 / 2)) := by -- porting note (#10745): was `simp [mul_comm, ← neg_mul]` rw [deriv_exp (by simp)]; simp; ring rw [Function.iterate_succ_apply', ih, deriv_const_mul_field, deriv_mul, pow_succ (-1 : ℝ), deriv_gaussian, hermite_succ, map_sub, map_mul, aeval_X, Polynomial.deriv_aeval] · ring · apply Polynomial.differentiable_aeval · apply DifferentiableAt.exp; simp -- Porting note: was just `simp` #align polynomial.deriv_gaussian_eq_hermite_mul_gaussian Polynomial.deriv_gaussian_eq_hermite_mul_gaussian theorem hermite_eq_deriv_gaussian (n : ℕ) (x : ℝ) : aeval x (hermite n) = (-1 : ℝ) ^ n * deriv^[n] (fun y => Real.exp (-(y ^ 2 / 2))) x / Real.exp (-(x ^ 2 / 2)) := by rw [deriv_gaussian_eq_hermite_mul_gaussian] field_simp [Real.exp_ne_zero] rw [← @smul_eq_mul ℝ _ ((-1) ^ n), ← inv_smul_eq_iff₀, mul_assoc, smul_eq_mul, ← inv_pow, ← neg_inv, inv_one] exact pow_ne_zero _ (by norm_num) #align polynomial.hermite_eq_deriv_gaussian Polynomial.hermite_eq_deriv_gaussian
Mathlib/RingTheory/Polynomial/Hermite/Gaussian.lean
67
70
theorem hermite_eq_deriv_gaussian' (n : ℕ) (x : ℝ) : aeval x (hermite n) = (-1 : ℝ) ^ n * deriv^[n] (fun y => Real.exp (-(y ^ 2 / 2))) x * Real.exp (x ^ 2 / 2) := by
rw [hermite_eq_deriv_gaussian, Real.exp_neg] field_simp [Real.exp_ne_zero]
/- Copyright (c) 2023 Scott Carnahan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Carnahan -/ import Mathlib.GroupTheory.GroupAction.Prod import Mathlib.Algebra.Ring.Int import Mathlib.Data.Nat.Cast.Basic /-! # Typeclasses for power-associative structures In this file we define power-associativity for algebraic structures with a multiplication operation. The class is a Prop-valued mixin named `NatPowAssoc`. ## Results - `npow_add` a defining property: `x ^ (k + n) = x ^ k * x ^ n` - `npow_one` a defining property: `x ^ 1 = x` - `npow_assoc` strictly positive powers of an element have associative multiplication. - `npow_comm` `x ^ m * x ^ n = x ^ n * x ^ m` for strictly positive `m` and `n`. - `npow_mul` `x ^ (m * n) = (x ^ m) ^ n` for strictly positive `m` and `n`. - `npow_eq_pow` monoid exponentiation coincides with semigroup exponentiation. ## Instances We also produce the following instances: - `NatPowAssoc` for Monoids, Pi types and products. ## Todo * to_additive? -/ assert_not_exists DenselyOrdered variable {M : Type*} /-- A mixin for power-associative multiplication. -/ class NatPowAssoc (M : Type*) [MulOneClass M] [Pow M ℕ] : Prop where /-- Multiplication is power-associative. -/ protected npow_add : ∀ (k n: ℕ) (x : M), x ^ (k + n) = x ^ k * x ^ n /-- Exponent zero is one. -/ protected npow_zero : ∀ (x : M), x ^ 0 = 1 /-- Exponent one is identity. -/ protected npow_one : ∀ (x : M), x ^ 1 = x section MulOneClass variable [MulOneClass M] [Pow M ℕ] [NatPowAssoc M] theorem npow_add (k n : ℕ) (x : M) : x ^ (k + n) = x ^ k * x ^ n := NatPowAssoc.npow_add k n x @[simp] theorem npow_zero (x : M) : x ^ 0 = 1 := NatPowAssoc.npow_zero x @[simp] theorem npow_one (x : M) : x ^ 1 = x := NatPowAssoc.npow_one x theorem npow_mul_assoc (k m n : ℕ) (x : M) : (x ^ k * x ^ m) * x ^ n = x ^ k * (x ^ m * x ^ n) := by simp only [← npow_add, add_assoc] theorem npow_mul_comm (m n : ℕ) (x : M) : x ^ m * x ^ n = x ^ n * x ^ m := by simp only [← npow_add, add_comm] theorem npow_mul (x : M) (m n : ℕ) : x ^ (m * n) = (x ^ m) ^ n := by induction n with | zero => rw [npow_zero, Nat.mul_zero, npow_zero] | succ n ih => rw [mul_add, npow_add, ih, mul_one, npow_add, npow_one] theorem npow_mul' (x : M) (m n : ℕ) : x ^ (m * n) = (x ^ n) ^ m := by rw [mul_comm] exact npow_mul x n m end MulOneClass section Neg
Mathlib/Algebra/Group/NatPowAssoc.lean
85
91
theorem neg_npow_assoc {R : Type*} [NonAssocRing R] [Pow R ℕ] [NatPowAssoc R] (a b : R) (k : ℕ) : (-1)^k * a * b = (-1)^k * (a * b) := by
induction k with | zero => simp only [npow_zero, one_mul] | succ k ih => rw [npow_add, npow_one, ← neg_mul_comm, mul_one] simp only [neg_mul, ih]
/- 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.NumberTheory.ModularForms.JacobiTheta.TwoVariable import Mathlib.Analysis.Complex.UpperHalfPlane.Basic #align_import number_theory.modular_forms.jacobi_theta.basic from "leanprover-community/mathlib"@"57f9349f2fe19d2de7207e99b0341808d977cdcf" /-! # Jacobi's theta function This file defines the one-variable Jacobi theta function $$\theta(\tau) = \sum_{n \in \mathbb{Z}} \exp (i \pi n ^ 2 \tau),$$ and proves the modular transformation properties `θ (τ + 2) = θ τ` and `θ (-1 / τ) = (-I * τ) ^ (1 / 2) * θ τ`, using Poisson's summation formula for the latter. We also show that `θ` is differentiable on `ℍ`, and `θ(τ) - 1` has exponential decay as `im τ → ∞`. -/ open Complex Real Asymptotics Filter Topology open scoped Real UpperHalfPlane /-- Jacobi's one-variable theta function `∑' (n : ℤ), exp (π * I * n ^ 2 * τ)`. -/ noncomputable def jacobiTheta (τ : ℂ) : ℂ := ∑' n : ℤ, cexp (π * I * (n : ℂ) ^ 2 * τ) #align jacobi_theta jacobiTheta lemma jacobiTheta_eq_jacobiTheta₂ (τ : ℂ) : jacobiTheta τ = jacobiTheta₂ 0 τ := tsum_congr (by simp [jacobiTheta₂_term])
Mathlib/NumberTheory/ModularForms/JacobiTheta/OneVariable.lean
33
34
theorem jacobiTheta_two_add (τ : ℂ) : jacobiTheta (2 + τ) = jacobiTheta τ := by
simp_rw [jacobiTheta_eq_jacobiTheta₂, add_comm, jacobiTheta₂_add_right]
/- 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 /-! # Measure with a given density with respect to another measure For a measure `μ` on `α` and a function `f : α → ℝ≥0∞`, we define a new measure `μ.withDensity f`. On a measurable set `s`, that measure has value `∫⁻ a in s, f a ∂μ`. An important result about `withDensity` is the Radon-Nikodym theorem. It states that, given measures `μ, ν`, if `HaveLebesgueDecomposition μ ν` then `μ` is absolutely continuous with respect to `ν` if and only if there exists a measurable function `f : α → ℝ≥0∞` such that `μ = ν.withDensity f`. See `MeasureTheory.Measure.absolutelyContinuous_iff_withDensity_rnDeriv_eq`. -/ open Set hiding restrict restrict_apply open Filter ENNReal NNReal MeasureTheory.Measure namespace MeasureTheory variable {α : Type*} {m0 : MeasurableSpace α} {μ : Measure α} /-- Given a measure `μ : Measure α` and a function `f : α → ℝ≥0∞`, `μ.withDensity f` is the measure such that for a measurable set `s` we have `μ.withDensity f s = ∫⁻ a in s, f a ∂μ`. -/ noncomputable def Measure.withDensity {m : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : Measure α := Measure.ofMeasurable (fun s _ => ∫⁻ a in s, f a ∂μ) (by simp) fun s hs hd => lintegral_iUnion hs hd _ #align measure_theory.measure.with_density MeasureTheory.Measure.withDensity @[simp] theorem withDensity_apply (f : α → ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) : μ.withDensity f s = ∫⁻ a in s, f a ∂μ := Measure.ofMeasurable_apply s hs #align measure_theory.with_density_apply MeasureTheory.withDensity_apply theorem withDensity_apply_le (f : α → ℝ≥0∞) (s : Set α) : ∫⁻ a in s, f a ∂μ ≤ μ.withDensity f s := by let t := toMeasurable (μ.withDensity f) s calc ∫⁻ a in s, f a ∂μ ≤ ∫⁻ a in t, f a ∂μ := lintegral_mono_set (subset_toMeasurable (withDensity μ f) s) _ = μ.withDensity f t := (withDensity_apply f (measurableSet_toMeasurable (withDensity μ f) s)).symm _ = μ.withDensity f s := measure_toMeasurable s /-! In the next theorem, the s-finiteness assumption is necessary. Here is a counterexample without this assumption. Let `α` be an uncountable space, let `x₀` be some fixed point, and consider the σ-algebra made of those sets which are countable and do not contain `x₀`, and of their complements. This is the σ-algebra generated by the sets `{x}` for `x ≠ x₀`. Define a measure equal to `+∞` on nonempty sets. Let `s = {x₀}` and `f` the indicator of `sᶜ`. Then * `∫⁻ a in s, f a ∂μ = 0`. Indeed, consider a simple function `g ≤ f`. It vanishes on `s`. Then `∫⁻ a in s, g a ∂μ = 0`. Taking the supremum over `g` gives the claim. * `μ.withDensity f s = +∞`. Indeed, this is the infimum of `μ.withDensity f t` over measurable sets `t` containing `s`. As `s` is not measurable, such a set `t` contains a point `x ≠ x₀`. Then `μ.withDensity f t ≥ μ.withDensity f {x} = ∫⁻ a in {x}, f a ∂μ = μ {x} = +∞`. One checks that `μ.withDensity f = μ`, while `μ.restrict s` gives zero mass to sets not containing `x₀`, and infinite mass to those that contain it. -/
Mathlib/MeasureTheory/Measure/WithDensity.lean
68
75
theorem withDensity_apply' [SFinite μ] (f : α → ℝ≥0∞) (s : Set α) : μ.withDensity f s = ∫⁻ a in s, f a ∂μ := by
apply le_antisymm ?_ (withDensity_apply_le f s) let t := toMeasurable μ s calc μ.withDensity f s ≤ μ.withDensity f t := measure_mono (subset_toMeasurable μ s) _ = ∫⁻ a in t, f a ∂μ := withDensity_apply f (measurableSet_toMeasurable μ s) _ = ∫⁻ a in s, f a ∂μ := by congr 1; exact restrict_toMeasurable_of_sFinite s
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.Algebra.Algebra.Bilinear import Mathlib.LinearAlgebra.Basis import Mathlib.RingTheory.Ideal.Basic #align_import ring_theory.ideal.operations from "leanprover-community/mathlib"@"e7f0ddbf65bd7181a85edb74b64bdc35ba4bdc74" /-! # The basis of ideals Some results involving `Ideal` and `Basis`. -/ namespace Ideal variable {ι R S : Type*} [CommSemiring R] [CommRing S] [IsDomain S] [Algebra R S] /-- A basis on `S` gives a basis on `Ideal.span {x}`, by multiplying everything by `x`. -/ noncomputable def basisSpanSingleton (b : Basis ι R S) {x : S} (hx : x ≠ 0) : Basis ι R (span ({x} : Set S)) := b.map <| LinearEquiv.ofInjective (Algebra.lmul R S x) (LinearMap.mul_injective hx) ≪≫ₗ LinearEquiv.ofEq _ _ (by ext simp [mem_span_singleton', mul_comm]) ≪≫ₗ (Submodule.restrictScalarsEquiv R S S (Ideal.span ({x} : Set S))).restrictScalars R #align ideal.basis_span_singleton Ideal.basisSpanSingleton @[simp]
Mathlib/RingTheory/Ideal/Basis.lean
35
39
theorem basisSpanSingleton_apply (b : Basis ι R S) {x : S} (hx : x ≠ 0) (i : ι) : (basisSpanSingleton b hx i : S) = x * b i := by
simp only [basisSpanSingleton, Basis.map_apply, LinearEquiv.trans_apply, Submodule.restrictScalarsEquiv_apply, LinearEquiv.ofInjective_apply, LinearEquiv.coe_ofEq_apply, LinearEquiv.restrictScalars_apply, Algebra.coe_lmul_eq_mul, LinearMap.mul_apply']
/- Copyright (c) 2020 Devon Tuma. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Devon Tuma -/ import Mathlib.Probability.ProbabilityMassFunction.Basic #align_import probability.probability_mass_function.monad from "leanprover-community/mathlib"@"4ac69b290818724c159de091daa3acd31da0ee6d" /-! # Monad Operations for Probability Mass Functions This file constructs two operations on `PMF` that give it a monad structure. `pure a` is the distribution where a single value `a` has probability `1`. `bind pa pb : PMF β` is the distribution given by sampling `a : α` from `pa : PMF α`, and then sampling from `pb a : PMF β` to get a final result `b : β`. `bindOnSupport` generalizes `bind` to allow binding to a partial function, so that the second argument only needs to be defined on the support of the first argument. -/ noncomputable section variable {α β γ : Type*} open scoped Classical open NNReal ENNReal open MeasureTheory namespace PMF section Pure /-- The pure `PMF` is the `PMF` where all the mass lies in one point. The value of `pure a` is `1` at `a` and `0` elsewhere. -/ def pure (a : α) : PMF α := ⟨fun a' => if a' = a then 1 else 0, hasSum_ite_eq _ _⟩ #align pmf.pure PMF.pure variable (a a' : α) @[simp] theorem pure_apply : pure a a' = if a' = a then 1 else 0 := rfl #align pmf.pure_apply PMF.pure_apply @[simp] theorem support_pure : (pure a).support = {a} := Set.ext fun a' => by simp [mem_support_iff] #align pmf.support_pure PMF.support_pure theorem mem_support_pure_iff : a' ∈ (pure a).support ↔ a' = a := by simp #align pmf.mem_support_pure_iff PMF.mem_support_pure_iff -- @[simp] -- Porting note (#10618): simp can prove this theorem pure_apply_self : pure a a = 1 := if_pos rfl #align pmf.pure_apply_self PMF.pure_apply_self theorem pure_apply_of_ne (h : a' ≠ a) : pure a a' = 0 := if_neg h #align pmf.pure_apply_of_ne PMF.pure_apply_of_ne instance [Inhabited α] : Inhabited (PMF α) := ⟨pure default⟩ section Measure variable (s : Set α) @[simp] theorem toOuterMeasure_pure_apply : (pure a).toOuterMeasure s = if a ∈ s then 1 else 0 := by refine (toOuterMeasure_apply (pure a) s).trans ?_ split_ifs with ha · refine (tsum_congr fun b => ?_).trans (tsum_ite_eq a 1) exact ite_eq_left_iff.2 fun hb => symm (ite_eq_right_iff.2 fun h => (hb <| h.symm ▸ ha).elim) · refine (tsum_congr fun b => ?_).trans tsum_zero exact ite_eq_right_iff.2 fun hb => ite_eq_right_iff.2 fun h => (ha <| h ▸ hb).elim #align pmf.to_outer_measure_pure_apply PMF.toOuterMeasure_pure_apply variable [MeasurableSpace α] /-- The measure of a set under `pure a` is `1` for sets containing `a` and `0` otherwise. -/ @[simp] theorem toMeasure_pure_apply (hs : MeasurableSet s) : (pure a).toMeasure s = if a ∈ s then 1 else 0 := (toMeasure_apply_eq_toOuterMeasure_apply (pure a) s hs).trans (toOuterMeasure_pure_apply a s) #align pmf.to_measure_pure_apply PMF.toMeasure_pure_apply theorem toMeasure_pure : (pure a).toMeasure = Measure.dirac a := Measure.ext fun s hs => by rw [toMeasure_pure_apply a s hs, Measure.dirac_apply' a hs]; rfl #align pmf.to_measure_pure PMF.toMeasure_pure @[simp] theorem toPMF_dirac [Countable α] [h : MeasurableSingletonClass α] : (Measure.dirac a).toPMF = pure a := by rw [toPMF_eq_iff_toMeasure_eq, toMeasure_pure] #align pmf.to_pmf_dirac PMF.toPMF_dirac end Measure end Pure section Bind /-- The monadic bind operation for `PMF`. -/ def bind (p : PMF α) (f : α → PMF β) : PMF β := ⟨fun b => ∑' a, p a * f a b, ENNReal.summable.hasSum_iff.2 (ENNReal.tsum_comm.trans <| by simp only [ENNReal.tsum_mul_left, tsum_coe, mul_one])⟩ #align pmf.bind PMF.bind variable (p : PMF α) (f : α → PMF β) (g : β → PMF γ) @[simp] theorem bind_apply (b : β) : p.bind f b = ∑' a, p a * f a b := rfl #align pmf.bind_apply PMF.bind_apply @[simp] theorem support_bind : (p.bind f).support = ⋃ a ∈ p.support, (f a).support := Set.ext fun b => by simp [mem_support_iff, ENNReal.tsum_eq_zero, not_or] #align pmf.support_bind PMF.support_bind theorem mem_support_bind_iff (b : β) : b ∈ (p.bind f).support ↔ ∃ a ∈ p.support, b ∈ (f a).support := by simp only [support_bind, Set.mem_iUnion, Set.mem_setOf_eq, exists_prop] #align pmf.mem_support_bind_iff PMF.mem_support_bind_iff @[simp]
Mathlib/Probability/ProbabilityMassFunction/Monad.lean
132
136
theorem pure_bind (a : α) (f : α → PMF β) : (pure a).bind f = f a := by
have : ∀ b a', ite (a' = a) (f a' b) 0 = ite (a' = a) (f a b) 0 := fun b a' => by split_ifs with h <;> simp [h] ext b simp [this]
/- Copyright (c) 2022 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import Mathlib.SetTheory.Cardinal.Finite #align_import data.finite.card from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" /-! # Cardinality of finite types The cardinality of a finite type `α` is given by `Nat.card α`. This function has the "junk value" of `0` for infinite types, but to ensure the function has valid output, one just needs to know that it's possible to produce a `Finite` instance for the type. (Note: we could have defined a `Finite.card` that required you to supply a `Finite` instance, but (a) the function would be `noncomputable` anyway so there is no need to supply the instance and (b) the function would have a more complicated dependent type that easily leads to "motive not type correct" errors.) ## Implementation notes Theorems about `Nat.card` are sometimes incidentally true for both finite and infinite types. If removing a finiteness constraint results in no loss in legibility, we remove it. We generally put such theorems into the `SetTheory.Cardinal.Finite` module. -/ noncomputable section open scoped Classical variable {α β γ : Type*} /-- There is (noncomputably) an equivalence between a finite type `α` and `Fin (Nat.card α)`. -/ def Finite.equivFin (α : Type*) [Finite α] : α ≃ Fin (Nat.card α) := by have := (Finite.exists_equiv_fin α).choose_spec.some rwa [Nat.card_eq_of_equiv_fin this] #align finite.equiv_fin Finite.equivFin /-- Similar to `Finite.equivFin` but with control over the term used for the cardinality. -/ def Finite.equivFinOfCardEq [Finite α] {n : ℕ} (h : Nat.card α = n) : α ≃ Fin n := by subst h apply Finite.equivFin #align finite.equiv_fin_of_card_eq Finite.equivFinOfCardEq theorem Nat.card_eq (α : Type*) : Nat.card α = if h : Finite α then @Fintype.card α (Fintype.ofFinite α) else 0 := by cases finite_or_infinite α · letI := Fintype.ofFinite α simp only [*, Nat.card_eq_fintype_card, dif_pos] · simp only [*, card_eq_zero_of_infinite, not_finite_iff_infinite.mpr, dite_false] #align nat.card_eq Nat.card_eq
Mathlib/Data/Finite/Card.lean
57
59
theorem Finite.card_pos_iff [Finite α] : 0 < Nat.card α ↔ Nonempty α := by
haveI := Fintype.ofFinite α rw [Nat.card_eq_fintype_card, Fintype.card_pos_iff]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Data.Matrix.Basis import Mathlib.Data.Matrix.DMatrix import Mathlib.RingTheory.MatrixAlgebra #align_import ring_theory.polynomial_algebra from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" /-! # Algebra isomorphism between matrices of polynomials and polynomials of matrices Given `[CommRing R] [Ring A] [Algebra R A]` we show `A[X] ≃ₐ[R] (A ⊗[R] R[X])`. Combining this with the isomorphism `Matrix n n A ≃ₐ[R] (A ⊗[R] Matrix n n R)` proved earlier in `RingTheory.MatrixAlgebra`, we obtain the algebra isomorphism ``` def matPolyEquiv : Matrix n n R[X] ≃ₐ[R] (Matrix n n R)[X] ``` which is characterized by ``` coeff (matPolyEquiv m) k i j = coeff (m i j) k ``` We will use this algebra isomorphism to prove the Cayley-Hamilton theorem. -/ 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. -/ -- Porting note: was `@[simps apply_apply]` @[simps! apply_apply] def toFunBilinear : A →ₗ[A] R[X] →ₗ[R] A[X] := LinearMap.toSpanSingleton A _ (aeval (Polynomial.X : A[X])).toLinearMap #align poly_equiv_tensor.to_fun_bilinear PolyEquivTensor.toFunBilinear 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 simp only [toFunBilinear_apply_apply, aeval_def, eval₂_eq_sum, Polynomial.sum, Finset.smul_sum] congr with i : 1 rw [← Algebra.smul_def, ← C_mul', mul_smul_comm, C_mul_X_pow_eq_monomial, ← Algebra.commutes, ← Algebra.smul_def, smul_monomial] #align poly_equiv_tensor.to_fun_bilinear_apply_eq_sum PolyEquivTensor.toFunBilinear_apply_eq_sum /-- (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) #align poly_equiv_tensor.to_fun_linear PolyEquivTensor.toFunLinear @[simp] theorem toFunLinear_tmul_apply (a : A) (p : R[X]) : toFunLinear R A (a ⊗ₜ[R] p) = toFunBilinear R A a p := rfl #align poly_equiv_tensor.to_fun_linear_tmul_apply PolyEquivTensor.toFunLinear_tmul_apply -- 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 [*] #align poly_equiv_tensor.to_fun_linear_mul_tmul_mul_aux_1 PolyEquivTensor.toFunLinear_mul_tmul_mul_aux_1 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] #align poly_equiv_tensor.to_fun_linear_mul_tmul_mul_aux_2 PolyEquivTensor.toFunLinear_mul_tmul_mul_aux_2
Mathlib/RingTheory/PolynomialAlgebra.lean
94
106
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]
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.Function.LpSeminorm.Basic #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" /-! # Lp seminorm with respect to trimmed measure In this file we prove basic properties of the Lp-seminorm of a function with respect to the restriction of a measure to a sub-σ-algebra. -/ namespace MeasureTheory open Filter open scoped ENNReal variable {α E : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ : Measure α} [NormedAddCommGroup E]
Mathlib/MeasureTheory/Function/LpSeminorm/Trim.lean
25
32
theorem snorm'_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snorm' f q (μ.trim hm) = snorm' f q μ := by
simp_rw [snorm'] congr 1 refine lintegral_trim hm ?_ refine @Measurable.pow_const _ _ _ _ _ _ _ m _ (@Measurable.coe_nnreal_ennreal _ m _ ?_) q apply @StronglyMeasurable.measurable exact @StronglyMeasurable.nnnorm α m _ _ _ hf
/- Copyright (c) 2014 Parikshit Khanna. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro -/ import Mathlib.Data.List.Basic /-! # insertNth Proves various lemmas about `List.insertNth`. -/ open Function open Nat hiding one_pos assert_not_exists Set.range namespace List universe u v w variable {ι : Type*} {α : Type u} {β : Type v} {γ : Type w} {l₁ l₂ : List α} section InsertNth variable {a : α} @[simp] theorem insertNth_zero (s : List α) (x : α) : insertNth 0 x s = x :: s := rfl #align list.insert_nth_zero List.insertNth_zero @[simp] theorem insertNth_succ_nil (n : ℕ) (a : α) : insertNth (n + 1) a [] = [] := rfl #align list.insert_nth_succ_nil List.insertNth_succ_nil @[simp] theorem insertNth_succ_cons (s : List α) (hd x : α) (n : ℕ) : insertNth (n + 1) x (hd :: s) = hd :: insertNth n x s := rfl #align list.insert_nth_succ_cons List.insertNth_succ_cons theorem length_insertNth : ∀ n as, n ≤ length as → length (insertNth n a as) = length as + 1 | 0, _, _ => rfl | _ + 1, [], h => (Nat.not_succ_le_zero _ h).elim | n + 1, _ :: as, h => congr_arg Nat.succ <| length_insertNth n as (Nat.le_of_succ_le_succ h) #align list.length_insert_nth List.length_insertNth
Mathlib/Data/List/InsertNth.lean
52
54
theorem eraseIdx_insertNth (n : ℕ) (l : List α) : (l.insertNth n a).eraseIdx n = l := by
rw [eraseIdx_eq_modifyNthTail, insertNth, modifyNthTail_modifyNthTail_same] exact modifyNthTail_id _ _
/- Copyright (c) 2022 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Patrick Massot -/ import Mathlib.Topology.Basic #align_import topology.nhds_set from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Neighborhoods of a set In this file we define the filter `𝓝ˢ s` or `nhdsSet s` consisting of all neighborhoods of a set `s`. ## Main Properties There are a couple different notions equivalent to `s ∈ 𝓝ˢ t`: * `s ⊆ interior t` using `subset_interior_iff_mem_nhdsSet` * `∀ x : X, x ∈ t → s ∈ 𝓝 x` using `mem_nhdsSet_iff_forall` * `∃ U : Set X, IsOpen U ∧ t ⊆ U ∧ U ⊆ s` using `mem_nhdsSet_iff_exists` Furthermore, we have the following results: * `monotone_nhdsSet`: `𝓝ˢ` is monotone * In T₁-spaces, `𝓝ˢ`is strictly monotone and hence injective: `strict_mono_nhdsSet`/`injective_nhdsSet`. These results are in `Mathlib.Topology.Separation`. -/ open Set Filter Topology variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {f : Filter X} {s t s₁ s₂ t₁ t₂ : Set X} {x : X} theorem nhdsSet_diagonal (X) [TopologicalSpace (X × X)] : 𝓝ˢ (diagonal X) = ⨆ (x : X), 𝓝 (x, x) := by rw [nhdsSet, ← range_diag, ← range_comp] rfl #align nhds_set_diagonal nhdsSet_diagonal theorem mem_nhdsSet_iff_forall : s ∈ 𝓝ˢ t ↔ ∀ x : X, x ∈ t → s ∈ 𝓝 x := by simp_rw [nhdsSet, Filter.mem_sSup, forall_mem_image] #align mem_nhds_set_iff_forall mem_nhdsSet_iff_forall lemma nhdsSet_le : 𝓝ˢ s ≤ f ↔ ∀ x ∈ s, 𝓝 x ≤ f := by simp [nhdsSet] theorem bUnion_mem_nhdsSet {t : X → Set X} (h : ∀ x ∈ s, t x ∈ 𝓝 x) : (⋃ x ∈ s, t x) ∈ 𝓝ˢ s := mem_nhdsSet_iff_forall.2 fun x hx => mem_of_superset (h x hx) <| subset_iUnion₂ (s := fun x _ => t x) x hx -- Porting note: fails to find `s` #align bUnion_mem_nhds_set bUnion_mem_nhdsSet
Mathlib/Topology/NhdsSet.lean
52
53
theorem subset_interior_iff_mem_nhdsSet : s ⊆ interior t ↔ t ∈ 𝓝ˢ s := by
simp_rw [mem_nhdsSet_iff_forall, subset_interior_iff_nhds]
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.CategoryTheory.Closed.Cartesian import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts import Mathlib.CategoryTheory.Adjunction.FullyFaithful #align_import category_theory.closed.functor from "leanprover-community/mathlib"@"cea27692b3fdeb328a2ddba6aabf181754543184" /-! # Cartesian closed functors Define the exponential comparison morphisms for a functor which preserves binary products, and use them to define a cartesian closed functor: one which (naturally) preserves exponentials. Define the Frobenius morphism, and show it is an isomorphism iff the exponential comparison is an isomorphism. ## TODO Some of the results here are true more generally for closed objects and for closed monoidal categories, and these could be generalised. ## References https://ncatlab.org/nlab/show/cartesian+closed+functor https://ncatlab.org/nlab/show/Frobenius+reciprocity ## Tags Frobenius reciprocity, cartesian closed functor -/ noncomputable section namespace CategoryTheory open Category Limits CartesianClosed universe v u u' variable {C : Type u} [Category.{v} C] variable {D : Type u'} [Category.{v} D] variable [HasFiniteProducts C] [HasFiniteProducts D] variable (F : C ⥤ D) {L : D ⥤ C} /-- The Frobenius morphism for an adjunction `L ⊣ F` at `A` is given by the morphism L(FA ⨯ B) ⟶ LFA ⨯ LB ⟶ A ⨯ LB natural in `B`, where the first morphism is the product comparison and the latter uses the counit of the adjunction. We will show that if `C` and `D` are cartesian closed, then this morphism is an isomorphism for all `A` iff `F` is a cartesian closed functor, i.e. it preserves exponentials. -/ def frobeniusMorphism (h : L ⊣ F) (A : C) : prod.functor.obj (F.obj A) ⋙ L ⟶ L ⋙ prod.functor.obj A := prodComparisonNatTrans L (F.obj A) ≫ whiskerLeft _ (prod.functor.map (h.counit.app _)) #align category_theory.frobenius_morphism CategoryTheory.frobeniusMorphism /-- If `F` is full and faithful and has a left adjoint `L` which preserves binary products, then the Frobenius morphism is an isomorphism. -/ instance frobeniusMorphism_iso_of_preserves_binary_products (h : L ⊣ F) (A : C) [PreservesLimitsOfShape (Discrete WalkingPair) L] [F.Full] [F.Faithful] : IsIso (frobeniusMorphism F h A) := suffices ∀ (X : D), IsIso ((frobeniusMorphism F h A).app X) from NatIso.isIso_of_isIso_app _ fun B ↦ by dsimp [frobeniusMorphism]; infer_instance #align category_theory.frobenius_morphism_iso_of_preserves_binary_products CategoryTheory.frobeniusMorphism_iso_of_preserves_binary_products variable [CartesianClosed C] [CartesianClosed D] variable [PreservesLimitsOfShape (Discrete WalkingPair) F] /-- The exponential comparison map. `F` is a cartesian closed functor if this is an iso for all `A`. -/ def expComparison (A : C) : exp A ⋙ F ⟶ F ⋙ exp (F.obj A) := transferNatTrans (exp.adjunction A) (exp.adjunction (F.obj A)) (prodComparisonNatIso F A).inv #align category_theory.exp_comparison CategoryTheory.expComparison theorem expComparison_ev (A B : C) : Limits.prod.map (𝟙 (F.obj A)) ((expComparison F A).app B) ≫ (exp.ev (F.obj A)).app (F.obj B) = inv (prodComparison F _ _) ≫ F.map ((exp.ev _).app _) := by convert transferNatTrans_counit _ _ (prodComparisonNatIso F A).inv B using 2 apply IsIso.inv_eq_of_hom_inv_id -- Porting note: was `ext` simp only [Limits.prodComparisonNatIso_inv, asIso_inv, NatIso.isIso_inv_app, IsIso.hom_inv_id] #align category_theory.exp_comparison_ev CategoryTheory.expComparison_ev theorem coev_expComparison (A B : C) : F.map ((exp.coev A).app B) ≫ (expComparison F A).app (A ⨯ B) = (exp.coev _).app (F.obj B) ≫ (exp (F.obj A)).map (inv (prodComparison F A B)) := by convert unit_transferNatTrans _ _ (prodComparisonNatIso F A).inv B using 3 apply IsIso.inv_eq_of_hom_inv_id -- Porting note: was `ext` dsimp simp #align category_theory.coev_exp_comparison CategoryTheory.coev_expComparison theorem uncurry_expComparison (A B : C) : CartesianClosed.uncurry ((expComparison F A).app B) = inv (prodComparison F _ _) ≫ F.map ((exp.ev _).app _) := by rw [uncurry_eq, expComparison_ev] #align category_theory.uncurry_exp_comparison CategoryTheory.uncurry_expComparison /-- The exponential comparison map is natural in `A`. -/
Mathlib/CategoryTheory/Closed/Functor.lean
107
116
theorem expComparison_whiskerLeft {A A' : C} (f : A' ⟶ A) : expComparison F A ≫ whiskerLeft _ (pre (F.map f)) = whiskerRight (pre f) _ ≫ expComparison F A' := by
ext B dsimp apply uncurry_injective rw [uncurry_natural_left, uncurry_natural_left, uncurry_expComparison, uncurry_pre, prod.map_swap_assoc, ← F.map_id, expComparison_ev, ← F.map_id, ← prodComparison_inv_natural_assoc, ← prodComparison_inv_natural_assoc, ← F.map_comp, ← F.map_comp, prod_map_pre_app_comp_ev]
/- Copyright (c) 2022 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.MonoidAlgebra.Basic import Mathlib.Data.Finset.Pointwise #align_import algebra.monoid_algebra.support from "leanprover-community/mathlib"@"16749fc4661828cba18cd0f4e3c5eb66a8e80598" /-! # Lemmas about the support of a finitely supported function -/ open scoped Pointwise universe u₁ u₂ u₃ namespace MonoidAlgebra open Finset Finsupp variable {k : Type u₁} {G : Type u₂} [Semiring k] theorem support_mul [Mul G] [DecidableEq G] (a b : MonoidAlgebra k G) : (a * b).support ⊆ a.support * b.support := by rw [MonoidAlgebra.mul_def] exact support_sum.trans <| biUnion_subset.2 fun _x hx ↦ support_sum.trans <| biUnion_subset.2 fun _y hy ↦ support_single_subset.trans <| singleton_subset_iff.2 <| mem_image₂_of_mem hx hy #align monoid_algebra.support_mul MonoidAlgebra.support_mul theorem support_single_mul_subset [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) (r : k) (a : G) : (single a r * f : MonoidAlgebra k G).support ⊆ Finset.image (a * ·) f.support := (support_mul _ _).trans <| (Finset.image₂_subset_right support_single_subset).trans <| by rw [Finset.image₂_singleton_left] #align monoid_algebra.support_single_mul_subset MonoidAlgebra.support_single_mul_subset theorem support_mul_single_subset [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) (r : k) (a : G) : (f * single a r).support ⊆ Finset.image (· * a) f.support := (support_mul _ _).trans <| (Finset.image₂_subset_left support_single_subset).trans <| by rw [Finset.image₂_singleton_right] #align monoid_algebra.support_mul_single_subset MonoidAlgebra.support_mul_single_subset theorem support_single_mul_eq_image [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) {r : k} (hr : ∀ y, r * y = 0 ↔ y = 0) {x : G} (lx : IsLeftRegular x) : (single x r * f : MonoidAlgebra k G).support = Finset.image (x * ·) f.support := by refine subset_antisymm (support_single_mul_subset f _ _) fun y hy => ?_ obtain ⟨y, yf, rfl⟩ : ∃ a : G, a ∈ f.support ∧ x * a = y := by simpa only [Finset.mem_image, exists_prop] using hy simp only [mul_apply, mem_support_iff.mp yf, hr, mem_support_iff, sum_single_index, Finsupp.sum_ite_eq', Ne, not_false_iff, if_true, zero_mul, ite_self, sum_zero, lx.eq_iff] #align monoid_algebra.support_single_mul_eq_image MonoidAlgebra.support_single_mul_eq_image theorem support_mul_single_eq_image [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) {r : k} (hr : ∀ y, y * r = 0 ↔ y = 0) {x : G} (rx : IsRightRegular x) : (f * single x r).support = Finset.image (· * x) f.support := by refine subset_antisymm (support_mul_single_subset f _ _) fun y hy => ?_ obtain ⟨y, yf, rfl⟩ : ∃ a : G, a ∈ f.support ∧ a * x = y := by simpa only [Finset.mem_image, exists_prop] using hy simp only [mul_apply, mem_support_iff.mp yf, hr, mem_support_iff, sum_single_index, Finsupp.sum_ite_eq', Ne, not_false_iff, if_true, mul_zero, ite_self, sum_zero, rx.eq_iff] #align monoid_algebra.support_mul_single_eq_image MonoidAlgebra.support_mul_single_eq_image theorem support_mul_single [Mul G] [IsRightCancelMul G] (f : MonoidAlgebra k G) (r : k) (hr : ∀ y, y * r = 0 ↔ y = 0) (x : G) : (f * single x r).support = f.support.map (mulRightEmbedding x) := by classical ext simp only [support_mul_single_eq_image f hr (IsRightRegular.all x), mem_image, mem_map, mulRightEmbedding_apply] #align monoid_algebra.support_mul_single MonoidAlgebra.support_mul_single
Mathlib/Algebra/MonoidAlgebra/Support.lean
74
80
theorem support_single_mul [Mul G] [IsLeftCancelMul G] (f : MonoidAlgebra k G) (r : k) (hr : ∀ y, r * y = 0 ↔ y = 0) (x : G) : (single x r * f : MonoidAlgebra k G).support = f.support.map (mulLeftEmbedding x) := by
classical ext simp only [support_single_mul_eq_image f hr (IsLeftRegular.all x), mem_image, mem_map, mulLeftEmbedding_apply]
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Yury Kudryashov -/ import Mathlib.Algebra.CharP.Invertible import Mathlib.Analysis.NormedSpace.Basic import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace import Mathlib.Topology.Instances.RealVectorSpace #align_import analysis.normed_space.add_torsor from "leanprover-community/mathlib"@"837f72de63ad6cd96519cde5f1ffd5ed8d280ad0" /-! # Torsors of normed space actions. This file contains lemmas about normed additive torsors over normed spaces. -/ noncomputable section open NNReal Topology open Filter variable {α V P W Q : Type*} [SeminormedAddCommGroup V] [PseudoMetricSpace P] [NormedAddTorsor V P] [NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q] section NormedSpace variable {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 V] [NormedSpace 𝕜 W] open AffineMap theorem AffineSubspace.isClosed_direction_iff (s : AffineSubspace 𝕜 Q) : IsClosed (s.direction : Set W) ↔ IsClosed (s : Set Q) := by rcases s.eq_bot_or_nonempty with (rfl | ⟨x, hx⟩); · simp [isClosed_singleton] rw [← (IsometryEquiv.vaddConst x).toHomeomorph.symm.isClosed_image, AffineSubspace.coe_direction_eq_vsub_set_right hx] rfl #align affine_subspace.is_closed_direction_iff AffineSubspace.isClosed_direction_iff @[simp] theorem dist_center_homothety (p₁ p₂ : P) (c : 𝕜) : dist p₁ (homothety p₁ c p₂) = ‖c‖ * dist p₁ p₂ := by simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm] #align dist_center_homothety dist_center_homothety @[simp] theorem nndist_center_homothety (p₁ p₂ : P) (c : 𝕜) : nndist p₁ (homothety p₁ c p₂) = ‖c‖₊ * nndist p₁ p₂ := NNReal.eq <| dist_center_homothety _ _ _ #align nndist_center_homothety nndist_center_homothety @[simp] theorem dist_homothety_center (p₁ p₂ : P) (c : 𝕜) : dist (homothety p₁ c p₂) p₁ = ‖c‖ * dist p₁ p₂ := by rw [dist_comm, dist_center_homothety] #align dist_homothety_center dist_homothety_center @[simp] theorem nndist_homothety_center (p₁ p₂ : P) (c : 𝕜) : nndist (homothety p₁ c p₂) p₁ = ‖c‖₊ * nndist p₁ p₂ := NNReal.eq <| dist_homothety_center _ _ _ #align nndist_homothety_center nndist_homothety_center @[simp] theorem dist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) : dist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = dist c₁ c₂ * dist p₁ p₂ := by rw [dist_comm p₁ p₂] simp only [lineMap_apply, dist_eq_norm_vsub, vadd_vsub_vadd_cancel_right, ← sub_smul, norm_smul, vsub_eq_sub] #align dist_line_map_line_map dist_lineMap_lineMap @[simp] theorem nndist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) : nndist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = nndist c₁ c₂ * nndist p₁ p₂ := NNReal.eq <| dist_lineMap_lineMap _ _ _ _ #align nndist_line_map_line_map nndist_lineMap_lineMap theorem lipschitzWith_lineMap (p₁ p₂ : P) : LipschitzWith (nndist p₁ p₂) (lineMap p₁ p₂ : 𝕜 → P) := LipschitzWith.of_dist_le_mul fun c₁ c₂ => ((dist_lineMap_lineMap p₁ p₂ c₁ c₂).trans (mul_comm _ _)).le #align lipschitz_with_line_map lipschitzWith_lineMap @[simp]
Mathlib/Analysis/NormedSpace/AddTorsor.lean
87
88
theorem dist_lineMap_left (p₁ p₂ : P) (c : 𝕜) : dist (lineMap p₁ p₂ c) p₁ = ‖c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_zero, dist_zero_right] using dist_lineMap_lineMap p₁ p₂ c 0
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Julian Kuelshammer, Heather Macbeth, Mitchell Lee -/ import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Tactic.LinearCombination #align_import ring_theory.polynomial.chebyshev from "leanprover-community/mathlib"@"d774451114d6045faeb6751c396bea1eb9058946" /-! # Chebyshev polynomials The Chebyshev polynomials are families of polynomials indexed by `ℤ`, with integral coefficients. ## Main definitions * `Polynomial.Chebyshev.T`: the Chebyshev polynomials of the first kind. * `Polynomial.Chebyshev.U`: the Chebyshev polynomials of the second kind. ## Main statements * The formal derivative of the Chebyshev polynomials of the first kind is a scalar multiple of the Chebyshev polynomials of the second kind. * `Polynomial.Chebyshev.mul_T`, twice the product of the `m`-th and `k`-th Chebyshev polynomials of the first kind is the sum of the `m + k`-th and `m - k`-th Chebyshev polynomials of the first kind. * `Polynomial.Chebyshev.T_mul`, the `(m * n)`-th Chebyshev polynomial of the first kind is the composition of the `m`-th and `n`-th Chebyshev polynomials of the first kind. ## Implementation details Since Chebyshev polynomials have interesting behaviour over the complex numbers and modulo `p`, we define them to have coefficients in an arbitrary commutative ring, even though technically `ℤ` would suffice. The benefit of allowing arbitrary coefficient rings, is that the statements afterwards are clean, and do not have `map (Int.castRingHom R)` interfering all the time. ## References [Lionel Ponton, _Roots of the Chebyshev polynomials: A purely algebraic approach_] [ponton2020chebyshev] ## TODO * Redefine and/or relate the definition of Chebyshev polynomials to `LinearRecurrence`. * Add explicit formula involving square roots for Chebyshev polynomials * Compute zeroes and extrema of Chebyshev polynomials. * Prove that the roots of the Chebyshev polynomials (except 0) are irrational. * Prove minimax properties of Chebyshev polynomials. -/ namespace Polynomial.Chebyshev set_option linter.uppercaseLean3 false -- `T` `U` `X` open Polynomial variable (R S : Type*) [CommRing R] [CommRing S] /-- `T n` is the `n`-th Chebyshev polynomial of the first kind. -/ -- Well-founded definitions are now irreducible by default; -- as this was implemented before this change, -- we just set it back to semireducible to avoid needing to change any proofs. @[semireducible] noncomputable def T : ℤ → R[X] | 0 => 1 | 1 => X | (n : ℕ) + 2 => 2 * X * T (n + 1) - T n | -((n : ℕ) + 1) => 2 * X * T (-n) - T (-n + 1) termination_by n => Int.natAbs n + Int.natAbs (n - 1) #align polynomial.chebyshev.T Polynomial.Chebyshev.T /-- Induction principle used for proving facts about Chebyshev polynomials. -/ @[elab_as_elim] protected theorem induct (motive : ℤ → Prop) (zero : motive 0) (one : motive 1) (add_two : ∀ (n : ℕ), motive (↑n + 1) → motive ↑n → motive (↑n + 2)) (neg_add_one : ∀ (n : ℕ), motive (-↑n) → motive (-↑n + 1) → motive (-↑n - 1)) : ∀ (a : ℤ), motive a := T.induct Unit motive zero one add_two fun n hn hnm => by simpa only [Int.negSucc_eq, neg_add] using neg_add_one n hn hnm @[simp] theorem T_add_two : ∀ n, T R (n + 2) = 2 * X * T R (n + 1) - T R n | (k : ℕ) => T.eq_3 R k | -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) T.eq_4 R k #align polynomial.chebyshev.T_add_two Polynomial.Chebyshev.T_add_two theorem T_add_one (n : ℤ) : T R (n + 1) = 2 * X * T R n - T R (n - 1) := by linear_combination (norm := ring_nf) T_add_two R (n - 1) theorem T_sub_two (n : ℤ) : T R (n - 2) = 2 * X * T R (n - 1) - T R n := by linear_combination (norm := ring_nf) T_add_two R (n - 2) theorem T_sub_one (n : ℤ) : T R (n - 1) = 2 * X * T R n - T R (n + 1) := by linear_combination (norm := ring_nf) T_add_two R (n - 1) theorem T_eq (n : ℤ) : T R n = 2 * X * T R (n - 1) - T R (n - 2) := by linear_combination (norm := ring_nf) T_add_two R (n - 2) #align polynomial.chebyshev.T_of_two_le Polynomial.Chebyshev.T_eq @[simp] theorem T_zero : T R 0 = 1 := rfl #align polynomial.chebyshev.T_zero Polynomial.Chebyshev.T_zero @[simp] theorem T_one : T R 1 = X := rfl #align polynomial.chebyshev.T_one Polynomial.Chebyshev.T_one theorem T_neg_one : T R (-1) = X := (by ring : 2 * X * 1 - X = X)
Mathlib/RingTheory/Polynomial/Chebyshev.lean
113
114
theorem T_two : T R 2 = 2 * X ^ 2 - 1 := by
simpa [pow_two, mul_assoc] using T_add_two R 0
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Associated import Mathlib.Algebra.GeomSum import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.SMulWithZero import Mathlib.Data.Nat.Choose.Sum import Mathlib.Data.Nat.Lattice import Mathlib.RingTheory.Nilpotent.Defs #align_import ring_theory.nilpotent from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" /-! # Nilpotent elements This file develops the basic theory of nilpotent elements. In particular it shows that the nilpotent elements are closed under many operations. For the definition of `nilradical`, see `Mathlib.RingTheory.Nilpotent.Lemmas`. ## Main definitions * `isNilpotent_neg_iff` * `Commute.isNilpotent_add` * `Commute.isNilpotent_sub` -/ universe u v open Function Set variable {R S : Type*} {x y : R} theorem IsNilpotent.neg [Ring R] (h : IsNilpotent x) : IsNilpotent (-x) := by obtain ⟨n, hn⟩ := h use n rw [neg_pow, hn, mul_zero] #align is_nilpotent.neg IsNilpotent.neg @[simp] theorem isNilpotent_neg_iff [Ring R] : IsNilpotent (-x) ↔ IsNilpotent x := ⟨fun h => neg_neg x ▸ h.neg, fun h => h.neg⟩ #align is_nilpotent_neg_iff isNilpotent_neg_iff lemma IsNilpotent.smul [MonoidWithZero R] [MonoidWithZero S] [MulActionWithZero R S] [SMulCommClass R S S] [IsScalarTower R S S] {a : S} (ha : IsNilpotent a) (t : R) : IsNilpotent (t • a) := by obtain ⟨k, ha⟩ := ha use k rw [smul_pow, ha, smul_zero] theorem IsNilpotent.isUnit_sub_one [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by obtain ⟨n, hn⟩ := hnil refine ⟨⟨r - 1, -∑ i ∈ Finset.range n, r ^ i, ?_, ?_⟩, rfl⟩ · simp [mul_geom_sum, hn] · simp [geom_sum_mul, hn]
Mathlib/RingTheory/Nilpotent/Basic.lean
64
66
theorem IsNilpotent.isUnit_one_sub [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (1 - r) := by
rw [← IsUnit.neg_iff, neg_sub] exact isUnit_sub_one hnil
/- 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 -/ import Mathlib.MeasureTheory.Measure.Dirac /-! # Counting measure In this file we define the counting measure `MeasurTheory.Measure.count` as `MeasureTheory.Measure.sum MeasureTheory.Measure.dirac` and prove basic properties of this measure. -/ set_option autoImplicit true open Set open scoped ENNReal Classical variable [MeasurableSpace α] [MeasurableSpace β] {s : Set α} noncomputable section namespace MeasureTheory.Measure /-- Counting measure on any measurable space. -/ def count : Measure α := sum dirac #align measure_theory.measure.count MeasureTheory.Measure.count theorem le_count_apply : ∑' _ : s, (1 : ℝ≥0∞) ≤ count s := calc (∑' _ : s, 1 : ℝ≥0∞) = ∑' i, indicator s 1 i := tsum_subtype s 1 _ ≤ ∑' i, dirac i s := ENNReal.tsum_le_tsum fun _ => le_dirac_apply _ ≤ count s := le_sum_apply _ _ #align measure_theory.measure.le_count_apply MeasureTheory.Measure.le_count_apply theorem count_apply (hs : MeasurableSet s) : count s = ∑' i : s, 1 := by simp only [count, sum_apply, hs, dirac_apply', ← tsum_subtype s (1 : α → ℝ≥0∞), Pi.one_apply] #align measure_theory.measure.count_apply MeasureTheory.Measure.count_apply -- @[simp] -- Porting note (#10618): simp can prove this theorem count_empty : count (∅ : Set α) = 0 := by rw [count_apply MeasurableSet.empty, tsum_empty] #align measure_theory.measure.count_empty MeasureTheory.Measure.count_empty @[simp] theorem count_apply_finset' {s : Finset α} (s_mble : MeasurableSet (s : Set α)) : count (↑s : Set α) = s.card := calc count (↑s : Set α) = ∑' i : (↑s : Set α), 1 := count_apply s_mble _ = ∑ i ∈ s, 1 := s.tsum_subtype 1 _ = s.card := by simp #align measure_theory.measure.count_apply_finset' MeasureTheory.Measure.count_apply_finset' @[simp] theorem count_apply_finset [MeasurableSingletonClass α] (s : Finset α) : count (↑s : Set α) = s.card := count_apply_finset' s.measurableSet #align measure_theory.measure.count_apply_finset MeasureTheory.Measure.count_apply_finset theorem count_apply_finite' {s : Set α} (s_fin : s.Finite) (s_mble : MeasurableSet s) : count s = s_fin.toFinset.card := by simp [← @count_apply_finset' _ _ s_fin.toFinset (by simpa only [Finite.coe_toFinset] using s_mble)] #align measure_theory.measure.count_apply_finite' MeasureTheory.Measure.count_apply_finite' theorem count_apply_finite [MeasurableSingletonClass α] (s : Set α) (hs : s.Finite) : count s = hs.toFinset.card := by rw [← count_apply_finset, Finite.coe_toFinset] #align measure_theory.measure.count_apply_finite MeasureTheory.Measure.count_apply_finite /-- `count` measure evaluates to infinity at infinite sets. -/ theorem count_apply_infinite (hs : s.Infinite) : count s = ∞ := by refine top_unique (le_of_tendsto' ENNReal.tendsto_nat_nhds_top fun n => ?_) rcases hs.exists_subset_card_eq n with ⟨t, ht, rfl⟩ calc (t.card : ℝ≥0∞) = ∑ i ∈ t, 1 := by simp _ = ∑' i : (t : Set α), 1 := (t.tsum_subtype 1).symm _ ≤ count (t : Set α) := le_count_apply _ ≤ count s := measure_mono ht #align measure_theory.measure.count_apply_infinite MeasureTheory.Measure.count_apply_infinite @[simp]
Mathlib/MeasureTheory/Measure/Count.lean
84
88
theorem count_apply_eq_top' (s_mble : MeasurableSet s) : count s = ∞ ↔ s.Infinite := by
by_cases hs : s.Finite · simp [Set.Infinite, hs, count_apply_finite' hs s_mble] · change s.Infinite at hs simp [hs, count_apply_infinite]
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.Measure.Typeclasses /-! # Restriction of a measure to a sub-σ-algebra ## Main definitions * `MeasureTheory.Measure.trim`: restriction of a measure to a sub-sigma algebra. -/ open scoped ENNReal namespace MeasureTheory variable {α : Type*} /-- Restriction of a measure to a sub-σ-algebra. It is common to see a measure `μ` on a measurable space structure `m0` as being also a measure on any `m ≤ m0`. Since measures in mathlib have to be trimmed to the measurable space, `μ` itself cannot be a measure on `m`, hence the definition of `μ.trim hm`. This notion is related to `OuterMeasure.trim`, see the lemma `toOuterMeasure_trim_eq_trim_toOuterMeasure`. -/ noncomputable def Measure.trim {m m0 : MeasurableSpace α} (μ : @Measure α m0) (hm : m ≤ m0) : @Measure α m := @OuterMeasure.toMeasure α m μ.toOuterMeasure (hm.trans (le_toOuterMeasure_caratheodory μ)) #align measure_theory.measure.trim MeasureTheory.Measure.trim @[simp] theorem trim_eq_self [MeasurableSpace α] {μ : Measure α} : μ.trim le_rfl = μ := by simp [Measure.trim] #align measure_theory.trim_eq_self MeasureTheory.trim_eq_self variable {m m0 : MeasurableSpace α} {μ : Measure α} {s : Set α} theorem toOuterMeasure_trim_eq_trim_toOuterMeasure (μ : Measure α) (hm : m ≤ m0) : @Measure.toOuterMeasure _ m (μ.trim hm) = @OuterMeasure.trim _ m μ.toOuterMeasure := by rw [Measure.trim, toMeasure_toOuterMeasure (ms := m)] #align measure_theory.to_outer_measure_trim_eq_trim_to_outer_measure MeasureTheory.toOuterMeasure_trim_eq_trim_toOuterMeasure @[simp] theorem zero_trim (hm : m ≤ m0) : (0 : Measure α).trim hm = (0 : @Measure α m) := by simp [Measure.trim, @OuterMeasure.toMeasure_zero _ m] #align measure_theory.zero_trim MeasureTheory.zero_trim theorem trim_measurableSet_eq (hm : m ≤ m0) (hs : @MeasurableSet α m s) : μ.trim hm s = μ s := by rw [Measure.trim, toMeasure_apply (ms := m) _ _ hs, Measure.coe_toOuterMeasure] #align measure_theory.trim_measurable_set_eq MeasureTheory.trim_measurableSet_eq theorem le_trim (hm : m ≤ m0) : μ s ≤ μ.trim hm s := by simp_rw [Measure.trim] exact @le_toMeasure_apply _ m _ _ _ #align measure_theory.le_trim MeasureTheory.le_trim theorem measure_eq_zero_of_trim_eq_zero (hm : m ≤ m0) (h : μ.trim hm s = 0) : μ s = 0 := le_antisymm ((le_trim hm).trans (le_of_eq h)) (zero_le _) #align measure_theory.measure_eq_zero_of_trim_eq_zero MeasureTheory.measure_eq_zero_of_trim_eq_zero theorem measure_trim_toMeasurable_eq_zero {hm : m ≤ m0} (hs : μ.trim hm s = 0) : μ (@toMeasurable α m (μ.trim hm) s) = 0 := measure_eq_zero_of_trim_eq_zero hm (by rwa [@measure_toMeasurable _ m]) #align measure_theory.measure_trim_to_measurable_eq_zero MeasureTheory.measure_trim_toMeasurable_eq_zero theorem ae_of_ae_trim (hm : m ≤ m0) {μ : Measure α} {P : α → Prop} (h : ∀ᵐ x ∂μ.trim hm, P x) : ∀ᵐ x ∂μ, P x := measure_eq_zero_of_trim_eq_zero hm h #align measure_theory.ae_of_ae_trim MeasureTheory.ae_of_ae_trim theorem ae_eq_of_ae_eq_trim {E} {hm : m ≤ m0} {f₁ f₂ : α → E} (h12 : f₁ =ᵐ[μ.trim hm] f₂) : f₁ =ᵐ[μ] f₂ := measure_eq_zero_of_trim_eq_zero hm h12 #align measure_theory.ae_eq_of_ae_eq_trim MeasureTheory.ae_eq_of_ae_eq_trim theorem ae_le_of_ae_le_trim {E} [LE E] {hm : m ≤ m0} {f₁ f₂ : α → E} (h12 : f₁ ≤ᵐ[μ.trim hm] f₂) : f₁ ≤ᵐ[μ] f₂ := measure_eq_zero_of_trim_eq_zero hm h12 #align measure_theory.ae_le_of_ae_le_trim MeasureTheory.ae_le_of_ae_le_trim theorem trim_trim {m₁ m₂ : MeasurableSpace α} {hm₁₂ : m₁ ≤ m₂} {hm₂ : m₂ ≤ m0} : (μ.trim hm₂).trim hm₁₂ = μ.trim (hm₁₂.trans hm₂) := by refine @Measure.ext _ m₁ _ _ (fun t ht => ?_) rw [trim_measurableSet_eq hm₁₂ ht, trim_measurableSet_eq (hm₁₂.trans hm₂) ht, trim_measurableSet_eq hm₂ (hm₁₂ t ht)] #align measure_theory.trim_trim MeasureTheory.trim_trim
Mathlib/MeasureTheory/Measure/Trim.lean
93
98
theorem restrict_trim (hm : m ≤ m0) (μ : Measure α) (hs : @MeasurableSet α m s) : @Measure.restrict α m (μ.trim hm) s = (μ.restrict s).trim hm := by
refine @Measure.ext _ m _ _ (fun t ht => ?_) rw [@Measure.restrict_apply α m _ _ _ ht, trim_measurableSet_eq hm ht, Measure.restrict_apply (hm t ht), trim_measurableSet_eq hm (@MeasurableSet.inter α m t s ht hs)]
/- Copyright (c) 2022 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.Algebra.IsPrimePow import Mathlib.NumberTheory.ArithmeticFunction import Mathlib.Analysis.SpecialFunctions.Log.Basic #align_import number_theory.von_mangoldt from "leanprover-community/mathlib"@"c946d6097a6925ad16d7ec55677bbc977f9846de" /-! # The von Mangoldt Function In this file we define the von Mangoldt function: the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. ## Main Results The main definition for this file is - `ArithmeticFunction.vonMangoldt`: The von Mangoldt function `Λ`. We then prove the classical summation property of the von Mangoldt function in `ArithmeticFunction.vonMangoldt_sum`, that `∑ i ∈ n.divisors, Λ i = Real.log n`, and use this to deduce alternative expressions for the von Mangoldt function via Möbius inversion, see `ArithmeticFunction.sum_moebius_mul_log_eq`. ## Notation We use the standard notation `Λ` to represent the von Mangoldt function. It is accessible in the locales `ArithmeticFunction` (like the notations for other arithmetic functions) and also in the locale `ArithmeticFunction.vonMangoldt`. -/ namespace ArithmeticFunction open Finset Nat open scoped ArithmeticFunction /-- `log` as an arithmetic function `ℕ → ℝ`. Note this is in the `ArithmeticFunction` namespace to indicate that it is bundled as an `ArithmeticFunction` rather than being the usual real logarithm. -/ noncomputable def log : ArithmeticFunction ℝ := ⟨fun n => Real.log n, by simp⟩ #align nat.arithmetic_function.log ArithmeticFunction.log @[simp] theorem log_apply {n : ℕ} : log n = Real.log n := rfl #align nat.arithmetic_function.log_apply ArithmeticFunction.log_apply /-- The `vonMangoldt` function is the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. In the case when `n` is a prime power, `min_fac` will give the appropriate prime, as it is the smallest prime factor. In the `ArithmeticFunction` locale, we have the notation `Λ` for this function. This is also available in the `ArithmeticFunction.vonMangoldt` locale, allowing for selective access to the notation. -/ noncomputable def vonMangoldt : ArithmeticFunction ℝ := ⟨fun n => if IsPrimePow n then Real.log (minFac n) else 0, if_neg not_isPrimePow_zero⟩ #align nat.arithmetic_function.von_mangoldt ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction] notation "Λ" => ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction.vonMangoldt] notation "Λ" => ArithmeticFunction.vonMangoldt theorem vonMangoldt_apply {n : ℕ} : Λ n = if IsPrimePow n then Real.log (minFac n) else 0 := rfl #align nat.arithmetic_function.von_mangoldt_apply ArithmeticFunction.vonMangoldt_apply @[simp] theorem vonMangoldt_apply_one : Λ 1 = 0 := by simp [vonMangoldt_apply] #align nat.arithmetic_function.von_mangoldt_apply_one ArithmeticFunction.vonMangoldt_apply_one @[simp] theorem vonMangoldt_nonneg {n : ℕ} : 0 ≤ Λ n := by rw [vonMangoldt_apply] split_ifs · exact Real.log_nonneg (one_le_cast.2 (Nat.minFac_pos n)) rfl #align nat.arithmetic_function.von_mangoldt_nonneg ArithmeticFunction.vonMangoldt_nonneg theorem vonMangoldt_apply_pow {n k : ℕ} (hk : k ≠ 0) : Λ (n ^ k) = Λ n := by simp only [vonMangoldt_apply, isPrimePow_pow_iff hk, pow_minFac hk] #align nat.arithmetic_function.von_mangoldt_apply_pow ArithmeticFunction.vonMangoldt_apply_pow theorem vonMangoldt_apply_prime {p : ℕ} (hp : p.Prime) : Λ p = Real.log p := by rw [vonMangoldt_apply, Prime.minFac_eq hp, if_pos hp.prime.isPrimePow] #align nat.arithmetic_function.von_mangoldt_apply_prime ArithmeticFunction.vonMangoldt_apply_prime
Mathlib/NumberTheory/VonMangoldt.lean
98
100
theorem vonMangoldt_ne_zero_iff {n : ℕ} : Λ n ≠ 0 ↔ IsPrimePow n := by
rcases eq_or_ne n 1 with (rfl | hn); · simp [not_isPrimePow_one] exact (Real.log_pos (one_lt_cast.2 (minFac_prime hn).one_lt)).ne'.ite_ne_right_iff
/- 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.BigOperators.Group.Multiset import Mathlib.Data.Multiset.Dedup #align_import data.multiset.bind from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # Bind operation for multisets This file defines a few basic operations on `Multiset`, notably the monadic bind. ## Main declarations * `Multiset.join`: The join, aka union or sum, of multisets. * `Multiset.bind`: The bind of a multiset-indexed family of multisets. * `Multiset.product`: Cartesian product of two multisets. * `Multiset.sigma`: Disjoint sum of multisets in a sigma type. -/ assert_not_exists MonoidWithZero assert_not_exists MulAction universe v variable {α : Type*} {β : Type v} {γ δ : Type*} namespace Multiset /-! ### Join -/ /-- `join S`, where `S` is a multiset of multisets, is the lift of the list join operation, that is, the union of all the sets. join {{1, 2}, {1, 2}, {0, 1}} = {0, 1, 1, 1, 2, 2} -/ def join : Multiset (Multiset α) → Multiset α := sum #align multiset.join Multiset.join theorem coe_join : ∀ L : List (List α), join (L.map ((↑) : List α → Multiset α) : Multiset (Multiset α)) = L.join | [] => rfl | l :: L => by exact congr_arg (fun s : Multiset α => ↑l + s) (coe_join L) #align multiset.coe_join Multiset.coe_join @[simp] theorem join_zero : @join α 0 = 0 := rfl #align multiset.join_zero Multiset.join_zero @[simp] theorem join_cons (s S) : @join α (s ::ₘ S) = s + join S := sum_cons _ _ #align multiset.join_cons Multiset.join_cons @[simp] theorem join_add (S T) : @join α (S + T) = join S + join T := sum_add _ _ #align multiset.join_add Multiset.join_add @[simp] theorem singleton_join (a) : join ({a} : Multiset (Multiset α)) = a := sum_singleton _ #align multiset.singleton_join Multiset.singleton_join @[simp] theorem mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s := Multiset.induction_on S (by simp) <| by simp (config := { contextual := true }) [or_and_right, exists_or] #align multiset.mem_join Multiset.mem_join @[simp] theorem card_join (S) : card (@join α S) = sum (map card S) := Multiset.induction_on S (by simp) (by simp) #align multiset.card_join Multiset.card_join @[simp] theorem map_join (f : α → β) (S : Multiset (Multiset α)) : map f (join S) = join (map (map f) S) := by induction S using Multiset.induction with | empty => simp | cons _ _ ih => simp [ih] @[to_additive (attr := simp)] theorem prod_join [CommMonoid α] {S : Multiset (Multiset α)} : prod (join S) = prod (map prod S) := by induction S using Multiset.induction with | empty => simp | cons _ _ ih => simp [ih] theorem rel_join {r : α → β → Prop} {s t} (h : Rel (Rel r) s t) : Rel r s.join t.join := by induction h with | zero => simp | cons hab hst ih => simpa using hab.add ih #align multiset.rel_join Multiset.rel_join /-! ### Bind -/ section Bind variable (a : α) (s t : Multiset α) (f g : α → Multiset β) /-- `s.bind f` is the monad bind operation, defined as `(s.map f).join`. It is the union of `f a` as `a` ranges over `s`. -/ def bind (s : Multiset α) (f : α → Multiset β) : Multiset β := (s.map f).join #align multiset.bind Multiset.bind @[simp] theorem coe_bind (l : List α) (f : α → List β) : (@bind α β l fun a => f a) = l.bind f := by rw [List.bind, ← coe_join, List.map_map] rfl #align multiset.coe_bind Multiset.coe_bind @[simp] theorem zero_bind : bind 0 f = 0 := rfl #align multiset.zero_bind Multiset.zero_bind @[simp]
Mathlib/Data/Multiset/Bind.lean
126
126
theorem cons_bind : (a ::ₘ s).bind f = f a + s.bind f := by
simp [bind]
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.LinearAlgebra.Isomorphisms import Mathlib.LinearAlgebra.Projection import Mathlib.Order.JordanHolder import Mathlib.Order.CompactlyGenerated.Intervals import Mathlib.LinearAlgebra.FiniteDimensional #align_import ring_theory.simple_module from "leanprover-community/mathlib"@"cce7f68a7eaadadf74c82bbac20721cdc03a1cc1" /-! # Simple Modules ## Main Definitions * `IsSimpleModule` indicates that a module has no proper submodules (the only submodules are `⊥` and `⊤`). * `IsSemisimpleModule` indicates that every submodule has a complement, or equivalently, the module is a direct sum of simple modules. * A `DivisionRing` structure on the endomorphism ring of a simple module. ## Main Results * Schur's Lemma: `bijective_or_eq_zero` shows that a linear map between simple modules is either bijective or 0, leading to a `DivisionRing` structure on the endomorphism ring. * `isSimpleModule_iff_quot_maximal`: a module is simple iff it's isomorphic to the quotient of the ring by a maximal left ideal. * `sSup_simples_eq_top_iff_isSemisimpleModule`: a module is semisimple iff it is generated by its simple submodules. * `IsSemisimpleModule.annihilator_isRadical`: the annihilator of a semisimple module over a commutative ring is a radical ideal. * `IsSemisimpleModule.submodule`, `IsSemisimpleModule.quotient`: any submodule or quotient module of a semisimple module is semisimple. * `isSemisimpleModule_of_isSemisimpleModule_submodule`: a module generated by semisimple submodules is itself semisimple. * `IsSemisimpleRing.isSemisimpleModule`: every module over a semisimple ring is semisimple. * `instIsSemisimpleRingForAllRing`: a finite product of semisimple rings is semisimple. * `RingHom.isSemisimpleRing_of_surjective`: any quotient of a semisimple ring is semisimple. ## TODO * Artin-Wedderburn Theory * Unify with the work on Schur's Lemma in a category theory context -/ variable {ι : Type*} (R S : Type*) [Ring R] [Ring S] (M : Type*) [AddCommGroup M] [Module R M] /-- A module is simple when it has only two submodules, `⊥` and `⊤`. -/ abbrev IsSimpleModule := IsSimpleOrder (Submodule R M) #align is_simple_module IsSimpleModule /-- A module is semisimple when every submodule has a complement, or equivalently, the module is a direct sum of simple modules. -/ abbrev IsSemisimpleModule := ComplementedLattice (Submodule R M) #align is_semisimple_module IsSemisimpleModule /-- A ring is semisimple if it is semisimple as a module over itself. -/ abbrev IsSemisimpleRing := IsSemisimpleModule R R theorem RingEquiv.isSemisimpleRing (e : R ≃+* S) [IsSemisimpleRing R] : IsSemisimpleRing S := (Submodule.orderIsoMapComap e.toSemilinearEquiv).complementedLattice -- Making this an instance causes the linter to complain of "dangerous instances" theorem IsSimpleModule.nontrivial [IsSimpleModule R M] : Nontrivial M := ⟨⟨0, by have h : (⊥ : Submodule R M) ≠ ⊤ := bot_ne_top contrapose! h ext x simp [Submodule.mem_bot, Submodule.mem_top, h x]⟩⟩ #align is_simple_module.nontrivial IsSimpleModule.nontrivial variable {m : Submodule R M} {N : Type*} [AddCommGroup N] [Module R N] {R S M} theorem LinearMap.isSimpleModule_iff_of_bijective [Module S N] {σ : R →+* S} [RingHomSurjective σ] (l : M →ₛₗ[σ] N) (hl : Function.Bijective l) : IsSimpleModule R M ↔ IsSimpleModule S N := (Submodule.orderIsoMapComapOfBijective l hl).isSimpleOrder_iff theorem IsSimpleModule.congr (l : M ≃ₗ[R] N) [IsSimpleModule R N] : IsSimpleModule R M := (Submodule.orderIsoMapComap l).isSimpleOrder #align is_simple_module.congr IsSimpleModule.congr theorem isSimpleModule_iff_isAtom : IsSimpleModule R m ↔ IsAtom m := by rw [← Set.isSimpleOrder_Iic_iff_isAtom] exact m.mapIic.isSimpleOrder_iff #align is_simple_module_iff_is_atom isSimpleModule_iff_isAtom
Mathlib/RingTheory/SimpleModule.lean
91
94
theorem isSimpleModule_iff_isCoatom : IsSimpleModule R (M ⧸ m) ↔ IsCoatom m := by
rw [← Set.isSimpleOrder_Ici_iff_isCoatom] apply OrderIso.isSimpleOrder_iff exact Submodule.comapMkQRelIso m
/- 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.Abelian import Mathlib.Algebra.Lie.IdealOperations import Mathlib.Order.Hom.Basic #align_import algebra.lie.solvable from "leanprover-community/mathlib"@"a50170a88a47570ed186b809ca754110590f9476" /-! # Solvable Lie algebras Like groups, Lie algebras admit a natural concept of solvability. We define this here via the derived series and prove some related results. We also define the radical of a Lie algebra and prove that it is solvable when the Lie algebra is Noetherian. ## Main definitions * `LieAlgebra.derivedSeriesOfIdeal` * `LieAlgebra.derivedSeries` * `LieAlgebra.IsSolvable` * `LieAlgebra.isSolvableAdd` * `LieAlgebra.radical` * `LieAlgebra.radicalIsSolvable` * `LieAlgebra.derivedLengthOfIdeal` * `LieAlgebra.derivedLength` * `LieAlgebra.derivedAbelianOfIdeal` ## Tags lie algebra, derived series, derived length, solvable, radical -/ universe u v w w₁ w₂ variable (R : Type u) (L : Type v) (M : Type w) {L' : Type w₁} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] variable (I J : LieIdeal R L) {f : L' →ₗ⁅R⁆ L} namespace LieAlgebra /-- A generalisation of the derived series of a Lie algebra, whose zeroth term is a specified ideal. It can be more convenient to work with this generalisation when considering the derived series of an ideal since it provides a type-theoretic expression of the fact that the terms of the ideal's derived series are also ideals of the enclosing algebra. See also `LieIdeal.derivedSeries_eq_derivedSeriesOfIdeal_comap` and `LieIdeal.derivedSeries_eq_derivedSeriesOfIdeal_map` below. -/ def derivedSeriesOfIdeal (k : ℕ) : LieIdeal R L → LieIdeal R L := (fun I => ⁅I, I⁆)^[k] #align lie_algebra.derived_series_of_ideal LieAlgebra.derivedSeriesOfIdeal @[simp] theorem derivedSeriesOfIdeal_zero : derivedSeriesOfIdeal R L 0 I = I := rfl #align lie_algebra.derived_series_of_ideal_zero LieAlgebra.derivedSeriesOfIdeal_zero @[simp] theorem derivedSeriesOfIdeal_succ (k : ℕ) : derivedSeriesOfIdeal R L (k + 1) I = ⁅derivedSeriesOfIdeal R L k I, derivedSeriesOfIdeal R L k I⁆ := Function.iterate_succ_apply' (fun I => ⁅I, I⁆) k I #align lie_algebra.derived_series_of_ideal_succ LieAlgebra.derivedSeriesOfIdeal_succ /-- The derived series of Lie ideals of a Lie algebra. -/ abbrev derivedSeries (k : ℕ) : LieIdeal R L := derivedSeriesOfIdeal R L k ⊤ #align lie_algebra.derived_series LieAlgebra.derivedSeries theorem derivedSeries_def (k : ℕ) : derivedSeries R L k = derivedSeriesOfIdeal R L k ⊤ := rfl #align lie_algebra.derived_series_def LieAlgebra.derivedSeries_def variable {R L} local notation "D" => derivedSeriesOfIdeal R L theorem derivedSeriesOfIdeal_add (k l : ℕ) : D (k + l) I = D k (D l I) := by induction' k with k ih · rw [Nat.zero_add, derivedSeriesOfIdeal_zero] · rw [Nat.succ_add k l, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ, ih] #align lie_algebra.derived_series_of_ideal_add LieAlgebra.derivedSeriesOfIdeal_add @[mono] theorem derivedSeriesOfIdeal_le {I J : LieIdeal R L} {k l : ℕ} (h₁ : I ≤ J) (h₂ : l ≤ k) : D k I ≤ D l J := by revert l; induction' k with k ih <;> intro l h₂ · rw [le_zero_iff] at h₂; rw [h₂, derivedSeriesOfIdeal_zero]; exact h₁ · have h : l = k.succ ∨ l ≤ k := by rwa [le_iff_eq_or_lt, Nat.lt_succ_iff] at h₂ cases' h with h h · rw [h, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ] exact LieSubmodule.mono_lie _ _ _ _ (ih (le_refl k)) (ih (le_refl k)) · rw [derivedSeriesOfIdeal_succ]; exact le_trans (LieSubmodule.lie_le_left _ _) (ih h) #align lie_algebra.derived_series_of_ideal_le LieAlgebra.derivedSeriesOfIdeal_le theorem derivedSeriesOfIdeal_succ_le (k : ℕ) : D (k + 1) I ≤ D k I := derivedSeriesOfIdeal_le (le_refl I) k.le_succ #align lie_algebra.derived_series_of_ideal_succ_le LieAlgebra.derivedSeriesOfIdeal_succ_le theorem derivedSeriesOfIdeal_le_self (k : ℕ) : D k I ≤ I := derivedSeriesOfIdeal_le (le_refl I) (zero_le k) #align lie_algebra.derived_series_of_ideal_le_self LieAlgebra.derivedSeriesOfIdeal_le_self theorem derivedSeriesOfIdeal_mono {I J : LieIdeal R L} (h : I ≤ J) (k : ℕ) : D k I ≤ D k J := derivedSeriesOfIdeal_le h (le_refl k) #align lie_algebra.derived_series_of_ideal_mono LieAlgebra.derivedSeriesOfIdeal_mono theorem derivedSeriesOfIdeal_antitone {k l : ℕ} (h : l ≤ k) : D k I ≤ D l I := derivedSeriesOfIdeal_le (le_refl I) h #align lie_algebra.derived_series_of_ideal_antitone LieAlgebra.derivedSeriesOfIdeal_antitone
Mathlib/Algebra/Lie/Solvable.lean
116
124
theorem derivedSeriesOfIdeal_add_le_add (J : LieIdeal R L) (k l : ℕ) : D (k + l) (I + J) ≤ D k I + D l J := by
let D₁ : LieIdeal R L →o LieIdeal R L := { toFun := fun I => ⁅I, I⁆ monotone' := fun I J h => LieSubmodule.mono_lie I J I J h h } have h₁ : ∀ I J : LieIdeal R L, D₁ (I ⊔ J) ≤ D₁ I ⊔ J := by simp [D₁, LieSubmodule.lie_le_right, LieSubmodule.lie_le_left, le_sup_of_le_right] rw [← D₁.iterate_sup_le_sup_iff] at h₁ exact h₁ k l I J
/- 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.Prod import Mathlib.Data.Set.Finite #align_import data.finset.n_ary from "leanprover-community/mathlib"@"eba7871095e834365616b5e43c8c7bb0b37058d0" /-! # N-ary images of finsets This file defines `Finset.image₂`, the binary image of finsets. This is the finset version of `Set.image2`. This is mostly useful to define pointwise operations. ## Notes This file is very similar to `Data.Set.NAry`, `Order.Filter.NAry` and `Data.Option.NAry`. Please keep them in sync. We do not define `Finset.image₃` as its only purpose would be to prove properties of `Finset.image₂` and `Set.image2` already fulfills this task. -/ open Function Set variable {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type*} namespace Finset variable [DecidableEq α'] [DecidableEq β'] [DecidableEq γ] [DecidableEq γ'] [DecidableEq δ] [DecidableEq δ'] [DecidableEq ε] [DecidableEq ε'] {f f' : α → β → γ} {g g' : α → β → γ → δ} {s s' : Finset α} {t t' : Finset β} {u u' : Finset γ} {a a' : α} {b b' : β} {c : γ} /-- The image of a binary function `f : α → β → γ` as a function `Finset α → Finset β → Finset γ`. Mathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/ def image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) : Finset γ := (s ×ˢ t).image <| uncurry f #align finset.image₂ Finset.image₂ @[simp] theorem mem_image₂ : c ∈ image₂ f s t ↔ ∃ a ∈ s, ∃ b ∈ t, f a b = c := by simp [image₂, and_assoc] #align finset.mem_image₂ Finset.mem_image₂ @[simp, norm_cast] theorem coe_image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) : (image₂ f s t : Set γ) = Set.image2 f s t := Set.ext fun _ => mem_image₂ #align finset.coe_image₂ Finset.coe_image₂ theorem card_image₂_le (f : α → β → γ) (s : Finset α) (t : Finset β) : (image₂ f s t).card ≤ s.card * t.card := card_image_le.trans_eq <| card_product _ _ #align finset.card_image₂_le Finset.card_image₂_le theorem card_image₂_iff : (image₂ f s t).card = s.card * t.card ↔ (s ×ˢ t : Set (α × β)).InjOn fun x => f x.1 x.2 := by rw [← card_product, ← coe_product] exact card_image_iff #align finset.card_image₂_iff Finset.card_image₂_iff theorem card_image₂ (hf : Injective2 f) (s : Finset α) (t : Finset β) : (image₂ f s t).card = s.card * t.card := (card_image_of_injective _ hf.uncurry).trans <| card_product _ _ #align finset.card_image₂ Finset.card_image₂ theorem mem_image₂_of_mem (ha : a ∈ s) (hb : b ∈ t) : f a b ∈ image₂ f s t := mem_image₂.2 ⟨a, ha, b, hb, rfl⟩ #align finset.mem_image₂_of_mem Finset.mem_image₂_of_mem
Mathlib/Data/Finset/NAry.lean
73
74
theorem mem_image₂_iff (hf : Injective2 f) : f a b ∈ image₂ f s t ↔ a ∈ s ∧ b ∈ t := by
rw [← mem_coe, coe_image₂, mem_image2_iff hf, mem_coe, mem_coe]
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Control.Applicative import Mathlib.Control.Traversable.Basic #align_import control.traversable.lemmas from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" /-! # Traversing collections This file proves basic properties of traversable and applicative functors and defines `PureTransformation F`, the natural applicative transformation from the identity functor to `F`. ## References Inspired by [The Essence of the Iterator Pattern][gibbons2009]. -/ universe u open LawfulTraversable open Function hiding comp open Functor attribute [functor_norm] LawfulTraversable.naturality attribute [simp] LawfulTraversable.id_traverse namespace Traversable variable {t : Type u → Type u} variable [Traversable t] [LawfulTraversable t] variable (F G : Type u → Type u) variable [Applicative F] [LawfulApplicative F] variable [Applicative G] [LawfulApplicative G] variable {α β γ : Type u} variable (g : α → F β) variable (h : β → G γ) variable (f : β → γ) /-- The natural applicative transformation from the identity functor to `F`, defined by `pure : Π {α}, α → F α`. -/ def PureTransformation : ApplicativeTransformation Id F where app := @pure F _ preserves_pure' x := rfl preserves_seq' f x := by simp only [map_pure, seq_pure] rfl #align traversable.pure_transformation Traversable.PureTransformation @[simp] theorem pureTransformation_apply {α} (x : id α) : PureTransformation F x = pure x := rfl #align traversable.pure_transformation_apply Traversable.pureTransformation_apply variable {F G} (x : t β) -- Porting note: need to specify `m/F/G := Id` because `id` no longer has a `Monad` instance theorem map_eq_traverse_id : map (f := t) f = traverse (m := Id) (pure ∘ f) := funext fun y => (traverse_eq_map_id f y).symm #align traversable.map_eq_traverse_id Traversable.map_eq_traverse_id theorem map_traverse (x : t α) : map f <$> traverse g x = traverse (map f ∘ g) x := by rw [map_eq_traverse_id f] refine (comp_traverse (pure ∘ f) g x).symm.trans ?_ congr; apply Comp.applicative_comp_id #align traversable.map_traverse Traversable.map_traverse theorem traverse_map (f : β → F γ) (g : α → β) (x : t α) : traverse f (g <$> x) = traverse (f ∘ g) x := by rw [@map_eq_traverse_id t _ _ _ _ g] refine (comp_traverse (G := Id) f (pure ∘ g) x).symm.trans ?_ congr; apply Comp.applicative_id_comp #align traversable.traverse_map Traversable.traverse_map theorem pure_traverse (x : t α) : traverse pure x = (pure x : F (t α)) := by have : traverse pure x = pure (traverse (m := Id) pure x) := (naturality (PureTransformation F) pure x).symm rwa [id_traverse] at this #align traversable.pure_traverse Traversable.pure_traverse theorem id_sequence (x : t α) : sequence (f := Id) (pure <$> x) = pure x := by simp [sequence, traverse_map, id_traverse] #align traversable.id_sequence Traversable.id_sequence theorem comp_sequence (x : t (F (G α))) : sequence (Comp.mk <$> x) = Comp.mk (sequence <$> sequence x) := by simp only [sequence, traverse_map, id_comp]; rw [← comp_traverse]; simp [map_id] #align traversable.comp_sequence Traversable.comp_sequence
Mathlib/Control/Traversable/Lemmas.lean
98
99
theorem naturality' (η : ApplicativeTransformation F G) (x : t (F α)) : η (sequence x) = sequence (@η _ <$> x) := by
simp [sequence, naturality, traverse_map]
/- Copyright (c) 2021 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Combinatorics.SetFamily.Shadow #align_import combinatorics.set_family.compression.uv from "leanprover-community/mathlib"@"6f8ab7de1c4b78a68ab8cf7dd83d549eb78a68a1" /-! # UV-compressions This file defines UV-compression. It is an operation on a set family that reduces its shadow. UV-compressing `a : α` along `u v : α` means replacing `a` by `(a ⊔ u) \ v` if `a` and `u` are disjoint and `v ≤ a`. In some sense, it's moving `a` from `v` to `u`. UV-compressions are immensely useful to prove the Kruskal-Katona theorem. The idea is that compressing a set family might decrease the size of its shadow, so iterated compressions hopefully minimise the shadow. ## Main declarations * `UV.compress`: `compress u v a` is `a` compressed along `u` and `v`. * `UV.compression`: `compression u v s` is the compression of the set family `s` along `u` and `v`. It is the compressions of the elements of `s` whose compression is not already in `s` along with the element whose compression is already in `s`. This way of splitting into what moves and what does not ensures the compression doesn't squash the set family, which is proved by `UV.card_compression`. * `UV.card_shadow_compression_le`: Compressing reduces the size of the shadow. This is a key fact in the proof of Kruskal-Katona. ## Notation `𝓒` (typed with `\MCC`) is notation for `UV.compression` in locale `FinsetFamily`. ## Notes Even though our emphasis is on `Finset α`, we define UV-compressions more generally in a generalized boolean algebra, so that one can use it for `Set α`. ## References * https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf ## Tags compression, UV-compression, shadow -/ open Finset variable {α : Type*} /-- UV-compression is injective on the elements it moves. See `UV.compress`. -/ theorem sup_sdiff_injOn [GeneralizedBooleanAlgebra α] (u v : α) : { x | Disjoint u x ∧ v ≤ x }.InjOn fun x => (x ⊔ u) \ v := by rintro a ha b hb hab have h : ((a ⊔ u) \ v) \ u ⊔ v = ((b ⊔ u) \ v) \ u ⊔ v := by dsimp at hab rw [hab] rwa [sdiff_sdiff_comm, ha.1.symm.sup_sdiff_cancel_right, sdiff_sdiff_comm, hb.1.symm.sup_sdiff_cancel_right, sdiff_sup_cancel ha.2, sdiff_sup_cancel hb.2] at h #align sup_sdiff_inj_on sup_sdiff_injOn -- The namespace is here to distinguish from other compressions. namespace UV /-! ### UV-compression in generalized boolean algebras -/ section GeneralizedBooleanAlgebra variable [GeneralizedBooleanAlgebra α] [DecidableRel (@Disjoint α _ _)] [DecidableRel ((· ≤ ·) : α → α → Prop)] {s : Finset α} {u v a b : α} /-- UV-compressing `a` means removing `v` from it and adding `u` if `a` and `u` are disjoint and `v ≤ a` (it replaces the `v` part of `a` by the `u` part). Else, UV-compressing `a` doesn't do anything. This is most useful when `u` and `v` are disjoint finsets of the same size. -/ def compress (u v a : α) : α := if Disjoint u a ∧ v ≤ a then (a ⊔ u) \ v else a #align uv.compress UV.compress theorem compress_of_disjoint_of_le (hua : Disjoint u a) (hva : v ≤ a) : compress u v a = (a ⊔ u) \ v := if_pos ⟨hua, hva⟩ #align uv.compress_of_disjoint_of_le UV.compress_of_disjoint_of_le theorem compress_of_disjoint_of_le' (hva : Disjoint v a) (hua : u ≤ a) : compress u v ((a ⊔ v) \ u) = a := by rw [compress_of_disjoint_of_le disjoint_sdiff_self_right (le_sdiff.2 ⟨(le_sup_right : v ≤ a ⊔ v), hva.mono_right hua⟩), sdiff_sup_cancel (le_sup_of_le_left hua), hva.symm.sup_sdiff_cancel_right] #align uv.compress_of_disjoint_of_le' UV.compress_of_disjoint_of_le' @[simp]
Mathlib/Combinatorics/SetFamily/Compression/UV.lean
98
102
theorem compress_self (u a : α) : compress u u a = a := by
unfold compress split_ifs with h · exact h.1.symm.sup_sdiff_cancel_right · rfl
/- Copyright (c) 2022 Michael Stoll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Stoll -/ import Mathlib.Data.Fintype.Parity import Mathlib.NumberTheory.LegendreSymbol.ZModChar import Mathlib.FieldTheory.Finite.Basic #align_import number_theory.legendre_symbol.quadratic_char.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" /-! # Quadratic characters of finite fields This file defines the quadratic character on a finite field `F` and proves some basic statements about it. ## Tags quadratic character -/ /-! ### Definition of the quadratic character We define the quadratic character of a finite field `F` with values in ℤ. -/ section Define /-- Define the quadratic character with values in ℤ on a monoid with zero `α`. It takes the value zero at zero; for non-zero argument `a : α`, it is `1` if `a` is a square, otherwise it is `-1`. This only deserves the name "character" when it is multiplicative, e.g., when `α` is a finite field. See `quadraticCharFun_mul`. We will later define `quadraticChar` to be a multiplicative character of type `MulChar F ℤ`, when the domain is a finite field `F`. -/ def quadraticCharFun (α : Type*) [MonoidWithZero α] [DecidableEq α] [DecidablePred (IsSquare : α → Prop)] (a : α) : ℤ := if a = 0 then 0 else if IsSquare a then 1 else -1 #align quadratic_char_fun quadraticCharFun end Define /-! ### Basic properties of the quadratic character We prove some properties of the quadratic character. We work with a finite field `F` here. The interesting case is when the characteristic of `F` is odd. -/ section quadraticChar open MulChar variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] /-- Some basic API lemmas -/ theorem quadraticCharFun_eq_zero_iff {a : F} : quadraticCharFun F a = 0 ↔ a = 0 := by simp only [quadraticCharFun] by_cases ha : a = 0 · simp only [ha, eq_self_iff_true, if_true] · simp only [ha, if_false, iff_false_iff] split_ifs <;> simp only [neg_eq_zero, one_ne_zero, not_false_iff] #align quadratic_char_fun_eq_zero_iff quadraticCharFun_eq_zero_iff @[simp] theorem quadraticCharFun_zero : quadraticCharFun F 0 = 0 := by simp only [quadraticCharFun, eq_self_iff_true, if_true, id] #align quadratic_char_fun_zero quadraticCharFun_zero @[simp]
Mathlib/NumberTheory/LegendreSymbol/QuadraticChar/Basic.lean
80
81
theorem quadraticCharFun_one : quadraticCharFun F 1 = 1 := by
simp only [quadraticCharFun, one_ne_zero, isSquare_one, if_true, if_false, id]
/- Copyright (c) 2022 George Peter Banyard, Yaël Dillies, Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: George Peter Banyard, Yaël Dillies, Kyle Miller -/ import Mathlib.Combinatorics.SimpleGraph.Connectivity #align_import combinatorics.simple_graph.prod from "leanprover-community/mathlib"@"2985fa3c31a27274aed06c433510bc14b73d6488" /-! # Graph products This file defines the box product of graphs and other product constructions. The box product of `G` and `H` is the graph on the product of the vertices such that `x` and `y` are related iff they agree on one component and the other one is related via either `G` or `H`. For example, the box product of two edges is a square. ## Main declarations * `SimpleGraph.boxProd`: The box product. ## Notation * `G □ H`: The box product of `G` and `H`. ## TODO Define all other graph products! -/ variable {α β γ : Type*} namespace SimpleGraph -- Porting note: pruned variables to keep things out of local contexts, which -- can impact how generalization works, or what aesop does. variable {G : SimpleGraph α} {H : SimpleGraph β} /-- Box product of simple graphs. It relates `(a₁, b)` and `(a₂, b)` if `G` relates `a₁` and `a₂`, and `(a, b₁)` and `(a, b₂)` if `H` relates `b₁` and `b₂`. -/ def boxProd (G : SimpleGraph α) (H : SimpleGraph β) : SimpleGraph (α × β) where Adj x y := G.Adj x.1 y.1 ∧ x.2 = y.2 ∨ H.Adj x.2 y.2 ∧ x.1 = y.1 symm x y := by simp [and_comm, or_comm, eq_comm, adj_comm] loopless x := by simp #align simple_graph.box_prod SimpleGraph.boxProd /-- Box product of simple graphs. It relates `(a₁, b)` and `(a₂, b)` if `G` relates `a₁` and `a₂`, and `(a, b₁)` and `(a, b₂)` if `H` relates `b₁` and `b₂`. -/ infixl:70 " □ " => boxProd set_option autoImplicit true in @[simp] theorem boxProd_adj : (G □ H).Adj x y ↔ G.Adj x.1 y.1 ∧ x.2 = y.2 ∨ H.Adj x.2 y.2 ∧ x.1 = y.1 := Iff.rfl #align simple_graph.box_prod_adj SimpleGraph.boxProd_adj set_option autoImplicit true in --@[simp] Porting note (#10618): `simp` can prove
Mathlib/Combinatorics/SimpleGraph/Prod.lean
59
60
theorem boxProd_adj_left : (G □ H).Adj (a₁, b) (a₂, b) ↔ G.Adj a₁ a₂ := by
simp only [boxProd_adj, and_true, SimpleGraph.irrefl, false_and, or_false]