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) 2022 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.ModelTheory.Substructures #align_import model_theory.finitely_generated from "leanprover-community/mathlib"@"0602c59878ff3d5f71dea69c2d32ccf2e93e5398" /-! # Finitely Generated First-Order Structures This file defines what it means for a first-order (sub)structure to be finitely or countably generated, similarly to other finitely-generated objects in the algebra library. ## Main Definitions * `FirstOrder.Language.Substructure.FG` indicates that a substructure is finitely generated. * `FirstOrder.Language.Structure.FG` indicates that a structure is finitely generated. * `FirstOrder.Language.Substructure.CG` indicates that a substructure is countably generated. * `FirstOrder.Language.Structure.CG` indicates that a structure is countably generated. ## TODO Develop a more unified definition of finite generation using the theory of closure operators, or use this definition of finite generation to define the others. -/ open FirstOrder Set namespace FirstOrder namespace Language open Structure variable {L : Language} {M : Type*} [L.Structure M] namespace Substructure /-- A substructure of `M` is finitely generated if it is the closure of a finite subset of `M`. -/ def FG (N : L.Substructure M) : Prop := ∃ S : Finset M, closure L S = N #align first_order.language.substructure.fg FirstOrder.Language.Substructure.FG theorem fg_def {N : L.Substructure M} : N.FG ↔ ∃ S : Set M, S.Finite ∧ closure L S = N := ⟨fun ⟨t, h⟩ => ⟨_, Finset.finite_toSet t, h⟩, by rintro ⟨t', h, rfl⟩ rcases Finite.exists_finset_coe h with ⟨t, rfl⟩ exact ⟨t, rfl⟩⟩ #align first_order.language.substructure.fg_def FirstOrder.Language.Substructure.fg_def theorem fg_iff_exists_fin_generating_family {N : L.Substructure M} : N.FG ↔ ∃ (n : ℕ) (s : Fin n → M), closure L (range s) = N := by rw [fg_def] constructor · rintro ⟨S, Sfin, hS⟩ obtain ⟨n, f, rfl⟩ := Sfin.fin_embedding exact ⟨n, f, hS⟩ · rintro ⟨n, s, hs⟩ exact ⟨range s, finite_range s, hs⟩ #align first_order.language.substructure.fg_iff_exists_fin_generating_family FirstOrder.Language.Substructure.fg_iff_exists_fin_generating_family theorem fg_bot : (⊥ : L.Substructure M).FG := ⟨∅, by rw [Finset.coe_empty, closure_empty]⟩ #align first_order.language.substructure.fg_bot FirstOrder.Language.Substructure.fg_bot theorem fg_closure {s : Set M} (hs : s.Finite) : FG (closure L s) := ⟨hs.toFinset, by rw [hs.coe_toFinset]⟩ #align first_order.language.substructure.fg_closure FirstOrder.Language.Substructure.fg_closure theorem fg_closure_singleton (x : M) : FG (closure L ({x} : Set M)) := fg_closure (finite_singleton x) #align first_order.language.substructure.fg_closure_singleton FirstOrder.Language.Substructure.fg_closure_singleton theorem FG.sup {N₁ N₂ : L.Substructure M} (hN₁ : N₁.FG) (hN₂ : N₂.FG) : (N₁ ⊔ N₂).FG := let ⟨t₁, ht₁⟩ := fg_def.1 hN₁ let ⟨t₂, ht₂⟩ := fg_def.1 hN₂ fg_def.2 ⟨t₁ ∪ t₂, ht₁.1.union ht₂.1, by rw [closure_union, ht₁.2, ht₂.2]⟩ #align first_order.language.substructure.fg.sup FirstOrder.Language.Substructure.FG.sup theorem FG.map {N : Type*} [L.Structure N] (f : M →[L] N) {s : L.Substructure M} (hs : s.FG) : (s.map f).FG := let ⟨t, ht⟩ := fg_def.1 hs fg_def.2 ⟨f '' t, ht.1.image _, by rw [closure_image, ht.2]⟩ #align first_order.language.substructure.fg.map FirstOrder.Language.Substructure.FG.map
Mathlib/ModelTheory/FinitelyGenerated.lean
87
98
theorem FG.of_map_embedding {N : Type*} [L.Structure N] (f : M ↪[L] N) {s : L.Substructure M} (hs : (s.map f.toHom).FG) : s.FG := by
rcases hs with ⟨t, h⟩ rw [fg_def] refine ⟨f ⁻¹' t, t.finite_toSet.preimage f.injective.injOn, ?_⟩ have hf : Function.Injective f.toHom := f.injective refine map_injective_of_injective hf ?_ rw [← h, map_closure, Embedding.coe_toHom, image_preimage_eq_of_subset] intro x hx have h' := subset_closure (L := L) hx rw [h] at h' exact Hom.map_le_range h'
/- Copyright (c) 2020 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau -/ import Mathlib.Algebra.DirectLimit import Mathlib.Algebra.CharP.Algebra import Mathlib.FieldTheory.IsAlgClosed.Basic import Mathlib.FieldTheory.SplittingField.Construction #align_import field_theory.is_alg_closed.algebraic_closure from "leanprover-community/mathlib"@"df76f43357840485b9d04ed5dee5ab115d420e87" /-! # Algebraic Closure In this file we construct the algebraic closure of a field ## Main Definitions - `AlgebraicClosure k` is an algebraic closure of `k` (in the same universe). It is constructed by taking the polynomial ring generated by indeterminates `x_f` corresponding to monic irreducible polynomials `f` with coefficients in `k`, and quotienting out by a maximal ideal containing every `f(x_f)`, and then repeating this step countably many times. See Exercise 1.13 in Atiyah--Macdonald. ## Tags algebraic closure, algebraically closed -/ universe u v w noncomputable section open scoped Classical Polynomial open Polynomial variable (k : Type u) [Field k] namespace AlgebraicClosure open MvPolynomial /-- The subtype of monic irreducible polynomials -/ abbrev MonicIrreducible : Type u := { f : k[X] // Monic f ∧ Irreducible f } #align algebraic_closure.monic_irreducible AlgebraicClosure.MonicIrreducible /-- Sends a monic irreducible polynomial `f` to `f(x_f)` where `x_f` is a formal indeterminate. -/ def evalXSelf (f : MonicIrreducible k) : MvPolynomial (MonicIrreducible k) k := Polynomial.eval₂ MvPolynomial.C (X f) f set_option linter.uppercaseLean3 false in #align algebraic_closure.eval_X_self AlgebraicClosure.evalXSelf /-- The span of `f(x_f)` across monic irreducible polynomials `f` where `x_f` is an indeterminate. -/ def spanEval : Ideal (MvPolynomial (MonicIrreducible k) k) := Ideal.span <| Set.range <| evalXSelf k #align algebraic_closure.span_eval AlgebraicClosure.spanEval /-- Given a finset of monic irreducible polynomials, construct an algebra homomorphism to the splitting field of the product of the polynomials sending each indeterminate `x_f` represented by the polynomial `f` in the finset to a root of `f`. -/ def toSplittingField (s : Finset (MonicIrreducible k)) : MvPolynomial (MonicIrreducible k) k →ₐ[k] SplittingField (∏ x ∈ s, x : k[X]) := MvPolynomial.aeval fun f => if hf : f ∈ s then rootOfSplits _ ((splits_prod_iff _ fun (j : MonicIrreducible k) _ => j.2.2.ne_zero).1 (SplittingField.splits _) f hf) (mt isUnit_iff_degree_eq_zero.2 f.2.2.not_unit) else 37 #align algebraic_closure.to_splitting_field AlgebraicClosure.toSplittingField
Mathlib/FieldTheory/IsAlgClosed/AlgebraicClosure.lean
77
81
theorem toSplittingField_evalXSelf {s : Finset (MonicIrreducible k)} {f} (hf : f ∈ s) : toSplittingField k s (evalXSelf k f) = 0 := by
rw [toSplittingField, evalXSelf, ← AlgHom.coe_toRingHom, hom_eval₂, AlgHom.coe_toRingHom, MvPolynomial.aeval_X, dif_pos hf, ← MvPolynomial.algebraMap_eq, AlgHom.comp_algebraMap] exact map_rootOfSplits _ _ _
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp, Yury Kudryashov -/ import Mathlib.Analysis.Convex.Between import Mathlib.Analysis.Convex.Jensen import Mathlib.Analysis.Convex.Topology import Mathlib.Analysis.Normed.Group.Pointwise import Mathlib.Analysis.NormedSpace.AddTorsor #align_import analysis.convex.normed from "leanprover-community/mathlib"@"a63928c34ec358b5edcda2bf7513c50052a5230f" /-! # Topological and metric properties of convex sets in normed spaces We prove the following facts: * `convexOn_norm`, `convexOn_dist` : norm and distance to a fixed point is convex on any convex set; * `convexOn_univ_norm`, `convexOn_univ_dist` : norm and distance to a fixed point is convex on the whole space; * `convexHull_ediam`, `convexHull_diam` : convex hull of a set has the same (e)metric diameter as the original set; * `bounded_convexHull` : convex hull of a set is bounded if and only if the original set is bounded. -/ variable {ι : Type*} {E P : Type*} open Metric Set open scoped Convex variable [SeminormedAddCommGroup E] [NormedSpace ℝ E] [PseudoMetricSpace P] [NormedAddTorsor E P] variable {s t : Set E} /-- The norm on a real normed space is convex on any convex set. See also `Seminorm.convexOn` and `convexOn_univ_norm`. -/ theorem convexOn_norm (hs : Convex ℝ s) : ConvexOn ℝ s norm := ⟨hs, fun x _ y _ a b ha hb _ => calc ‖a • x + b • y‖ ≤ ‖a • x‖ + ‖b • y‖ := norm_add_le _ _ _ = a * ‖x‖ + b * ‖y‖ := by rw [norm_smul, norm_smul, Real.norm_of_nonneg ha, Real.norm_of_nonneg hb]⟩ #align convex_on_norm convexOn_norm /-- The norm on a real normed space is convex on the whole space. See also `Seminorm.convexOn` and `convexOn_norm`. -/ theorem convexOn_univ_norm : ConvexOn ℝ univ (norm : E → ℝ) := convexOn_norm convex_univ #align convex_on_univ_norm convexOn_univ_norm
Mathlib/Analysis/Convex/Normed.lean
53
55
theorem convexOn_dist (z : E) (hs : Convex ℝ s) : ConvexOn ℝ s fun z' => dist z' z := by
simpa [dist_eq_norm, preimage_preimage] using (convexOn_norm (hs.translate (-z))).comp_affineMap (AffineMap.id ℝ E - AffineMap.const ℝ E z)
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Michael Stoll -/ import Mathlib.NumberTheory.LegendreSymbol.Basic import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.GaussSum #align_import number_theory.legendre_symbol.quadratic_reciprocity from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" /-! # Quadratic reciprocity. ## Main results We prove the law of quadratic reciprocity, see `legendreSym.quadratic_reciprocity` and `legendreSym.quadratic_reciprocity'`, as well as the interpretations in terms of existence of square roots depending on the congruence mod 4, `ZMod.exists_sq_eq_prime_iff_of_mod_four_eq_one` and `ZMod.exists_sq_eq_prime_iff_of_mod_four_eq_three`. We also prove the supplementary laws that give conditions for when `2` or `-2` is a square modulo a prime `p`: `legendreSym.at_two` and `ZMod.exists_sq_eq_two_iff` for `2` and `legendreSym.at_neg_two` and `ZMod.exists_sq_eq_neg_two_iff` for `-2`. ## Implementation notes The proofs use results for quadratic characters on arbitrary finite fields from `NumberTheory.LegendreSymbol.QuadraticChar.GaussSum`, which in turn are based on properties of quadratic Gauss sums as provided by `NumberTheory.LegendreSymbol.GaussSum`. ## Tags quadratic residue, quadratic nonresidue, Legendre symbol, quadratic reciprocity -/ open Nat section Values variable {p : ℕ} [Fact p.Prime] open ZMod /-! ### The value of the Legendre symbol at `2` and `-2` See `jacobiSym.at_two` and `jacobiSym.at_neg_two` for the corresponding statements for the Jacobi symbol. -/ namespace legendreSym variable (hp : p ≠ 2) /-- `legendreSym p 2` is given by `χ₈ p`. -/ theorem at_two : legendreSym p 2 = χ₈ p := by have : (2 : ZMod p) = (2 : ℤ) := by norm_cast rw [legendreSym, ← this, quadraticChar_two ((ringChar_zmod_n p).substr hp), card p] #align legendre_sym.at_two legendreSym.at_two /-- `legendreSym p (-2)` is given by `χ₈' p`. -/
Mathlib/NumberTheory/LegendreSymbol/QuadraticReciprocity.lean
66
68
theorem at_neg_two : legendreSym p (-2) = χ₈' p := by
have : (-2 : ZMod p) = (-2 : ℤ) := by norm_cast rw [legendreSym, ← this, quadraticChar_neg_two ((ringChar_zmod_n p).substr hp), card p]
/- Copyright (c) 2018 Louis Carlin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Louis Carlin, Mario Carneiro -/ import Mathlib.Algebra.Divisibility.Basic import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Ring.Defs #align_import algebra.euclidean_domain.defs from "leanprover-community/mathlib"@"ee7b9f9a9ac2a8d9f04ea39bbfe6b1a3be053b38" /-! # Euclidean domains This file introduces Euclidean domains and provides the extended Euclidean algorithm. To be precise, a slightly more general version is provided which is sometimes called a transfinite Euclidean domain and differs in the fact that the degree function need not take values in `ℕ` but can take values in any well-ordered set. Transfinite Euclidean domains were introduced by Motzkin and examples which don't satisfy the classical notion were provided independently by Hiblot and Nagata. ## Main definitions * `EuclideanDomain`: Defines Euclidean domain with functions `quotient` and `remainder`. Instances of `Div` and `Mod` are provided, so that one can write `a = b * (a / b) + a % b`. * `gcd`: defines the greatest common divisors of two elements of a Euclidean domain. * `xgcd`: given two elements `a b : R`, `xgcd a b` defines the pair `(x, y)` such that `x * a + y * b = gcd a b`. * `lcm`: defines the lowest common multiple of two elements `a` and `b` of a Euclidean domain as `a * b / (gcd a b)` ## Main statements See `Algebra.EuclideanDomain.Basic` for most of the theorems about Euclidean domains, including Bézout's lemma. See `Algebra.EuclideanDomain.Instances` for the fact that `ℤ` is a Euclidean domain, as is any field. ## Notation `≺` denotes the well founded relation on the Euclidean domain, e.g. in the example of the polynomial ring over a field, `p ≺ q` for polynomials `p` and `q` if and only if the degree of `p` is less than the degree of `q`. ## Implementation details Instead of working with a valuation, `EuclideanDomain` is implemented with the existence of a well founded relation `r` on the integral domain `R`, which in the example of `ℤ` would correspond to setting `i ≺ j` for integers `i` and `j` if the absolute value of `i` is smaller than the absolute value of `j`. ## References * [Th. Motzkin, *The Euclidean algorithm*][MR32592] * [J.-J. Hiblot, *Des anneaux euclidiens dont le plus petit algorithme n'est pas à valeurs finies*] [MR399081] * [M. Nagata, *On Euclid algorithm*][MR541021] ## Tags Euclidean domain, transfinite Euclidean domain, Bézout's lemma -/ universe u /-- A `EuclideanDomain` is a non-trivial commutative ring with a division and a remainder, satisfying `b * (a / b) + a % b = a`. The definition of a Euclidean domain usually includes a valuation function `R → ℕ`. This definition is slightly generalised to include a well founded relation `r` with the property that `r (a % b) b`, instead of a valuation. -/ class EuclideanDomain (R : Type u) extends CommRing R, Nontrivial R where /-- A division function (denoted `/`) on `R`. This satisfies the property `b * (a / b) + a % b = a`, where `%` denotes `remainder`. -/ protected quotient : R → R → R /-- Division by zero should always give zero by convention. -/ protected quotient_zero : ∀ a, quotient a 0 = 0 /-- A remainder function (denoted `%`) on `R`. This satisfies the property `b * (a / b) + a % b = a`, where `/` denotes `quotient`. -/ protected remainder : R → R → R /-- The property that links the quotient and remainder functions. This allows us to compute GCDs and LCMs. -/ protected quotient_mul_add_remainder_eq : ∀ a b, b * quotient a b + remainder a b = a /-- A well-founded relation on `R`, satisfying `r (a % b) b`. This ensures that the GCD algorithm always terminates. -/ protected r : R → R → Prop /-- The relation `r` must be well-founded. This ensures that the GCD algorithm always terminates. -/ r_wellFounded : WellFounded r /-- The relation `r` satisfies `r (a % b) b`. -/ protected remainder_lt : ∀ (a) {b}, b ≠ 0 → r (remainder a b) b /-- An additional constraint on `r`. -/ mul_left_not_lt : ∀ (a) {b}, b ≠ 0 → ¬r (a * b) a #align euclidean_domain EuclideanDomain #align euclidean_domain.quotient EuclideanDomain.quotient #align euclidean_domain.quotient_zero EuclideanDomain.quotient_zero #align euclidean_domain.remainder EuclideanDomain.remainder #align euclidean_domain.quotient_mul_add_remainder_eq EuclideanDomain.quotient_mul_add_remainder_eq #align euclidean_domain.r EuclideanDomain.r #align euclidean_domain.r_well_founded EuclideanDomain.r_wellFounded #align euclidean_domain.remainder_lt EuclideanDomain.remainder_lt #align euclidean_domain.mul_left_not_lt EuclideanDomain.mul_left_not_lt namespace EuclideanDomain variable {R : Type u} [EuclideanDomain R] /-- Abbreviated notation for the well-founded relation `r` in a Euclidean domain. -/ local infixl:50 " ≺ " => EuclideanDomain.r local instance wellFoundedRelation : WellFoundedRelation R where wf := r_wellFounded -- see Note [lower instance priority] instance (priority := 70) : Div R := ⟨EuclideanDomain.quotient⟩ -- see Note [lower instance priority] instance (priority := 70) : Mod R := ⟨EuclideanDomain.remainder⟩ theorem div_add_mod (a b : R) : b * (a / b) + a % b = a := EuclideanDomain.quotient_mul_add_remainder_eq _ _ #align euclidean_domain.div_add_mod EuclideanDomain.div_add_mod theorem mod_add_div (a b : R) : a % b + b * (a / b) = a := (add_comm _ _).trans (div_add_mod _ _) #align euclidean_domain.mod_add_div EuclideanDomain.mod_add_div theorem mod_add_div' (m k : R) : m % k + m / k * k = m := by rw [mul_comm] exact mod_add_div _ _ #align euclidean_domain.mod_add_div' EuclideanDomain.mod_add_div' theorem div_add_mod' (m k : R) : m / k * k + m % k = m := by rw [mul_comm] exact div_add_mod _ _ #align euclidean_domain.div_add_mod' EuclideanDomain.div_add_mod'
Mathlib/Algebra/EuclideanDomain/Defs.lean
141
144
theorem mod_eq_sub_mul_div {R : Type*} [EuclideanDomain R] (a b : R) : a % b = a - b * (a / b) := calc a % b = b * (a / b) + a % b - b * (a / b) := (add_sub_cancel_left _ _).symm _ = a - b * (a / b) := by
rw [div_add_mod]
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.CategoryTheory.EffectiveEpi.Comp import Mathlib.Data.Fintype.Card /-! # Functors preserving effective epimorphisms This file concerns functors which preserve and/or reflect effective epimorphisms and effective epimorphic families. ## TODO - Find nice sufficient conditions in terms of preserving/reflecting (co)limits, to preserve/reflect effective epis, similar to `CategoryTheory.preserves_epi_of_preservesColimit`. -/ universe u namespace CategoryTheory open Limits variable {C : Type*} [Category C] noncomputable section Equivalence variable {D : Type*} [Category D] (e : C ≌ D) {B : C} variable {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) [EffectiveEpiFamily X π]
Mathlib/CategoryTheory/EffectiveEpi/Preserves.lean
34
42
theorem effectiveEpiFamilyStructOfEquivalence_aux {W : D} (ε : (a : α) → e.functor.obj (X a) ⟶ W) (h : ∀ {Z : D} (a₁ a₂ : α) (g₁ : Z ⟶ e.functor.obj (X a₁)) (g₂ : Z ⟶ e.functor.obj (X a₂)), g₁ ≫ e.functor.map (π a₁) = g₂ ≫ e.functor.map (π a₂) → g₁ ≫ ε a₁ = g₂ ≫ ε a₂) {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂) (hg : g₁ ≫ π a₁ = g₂ ≫ π a₂) : g₁ ≫ (fun a ↦ e.unit.app (X a) ≫ e.inverse.map (ε a)) a₁ = g₂ ≫ (fun a ↦ e.unit.app (X a) ≫ e.inverse.map (ε a)) a₂ := by
have := h a₁ a₂ (e.functor.map g₁) (e.functor.map g₂) simp only [← Functor.map_comp, hg] at this simpa using congrArg e.inverse.map (this (by trivial))
/- Copyright (c) 2024 Sophie Morel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sophie Morel -/ import Mathlib.Analysis.NormedSpace.Multilinear.Basic import Mathlib.LinearAlgebra.PiTensorProduct /-! # Projective seminorm on the tensor of a finite family of normed spaces. Let `𝕜` be a nontrivially normed field and `E` be a family of normed `𝕜`-vector spaces `Eᵢ`, indexed by a finite type `ι`. We define a seminorm on `⨂[𝕜] i, Eᵢ`, which we call the "projective seminorm". For `x` an element of `⨂[𝕜] i, Eᵢ`, its projective seminorm is the infimum over all expressions of `x` as `∑ j, ⨂ₜ[𝕜] mⱼ i` (with the `mⱼ` ∈ `Π i, Eᵢ`) of `∑ j, Π i, ‖mⱼ i‖`. In particular, every norm `‖.‖` on `⨂[𝕜] i, Eᵢ` satisfying `‖⨂ₜ[𝕜] i, m i‖ ≤ Π i, ‖m i‖` for every `m` in `Π i, Eᵢ` is bounded above by the projective seminorm. ## Main definitions * `PiTensorProduct.projectiveSeminorm`: The projective seminorm on `⨂[𝕜] i, Eᵢ`. ## Main results * `PiTensorProduct.norm_eval_le_projectiveSeminorm`: If `f` is a continuous multilinear map on `E = Π i, Eᵢ` and `x` is in `⨂[𝕜] i, Eᵢ`, then `‖f.lift x‖ ≤ projectiveSeminorm x * ‖f‖`. ## TODO * If the base field is `ℝ` or `ℂ` (or more generally if the injection of `Eᵢ` into its bidual is an isometry for every `i`), then we have `projectiveSeminorm ⨂ₜ[𝕜] i, mᵢ = Π i, ‖mᵢ‖`. * The functoriality. -/ universe uι u𝕜 uE uF variable {ι : Type uι} [Fintype ι] variable {𝕜 : Type u𝕜} [NontriviallyNormedField 𝕜] variable {E : ι → Type uE} [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] variable {F : Type uF} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F] open scoped TensorProduct namespace PiTensorProduct /-- A lift of the projective seminorm to `FreeAddMonoid (𝕜 × Π i, Eᵢ)`, useful to prove the properties of `projectiveSeminorm`. -/ def projectiveSeminormAux : FreeAddMonoid (𝕜 × Π i, E i) → ℝ := List.sum ∘ (List.map (fun p ↦ ‖p.1‖ * ∏ i, ‖p.2 i‖)) theorem projectiveSeminormAux_nonneg (p : FreeAddMonoid (𝕜 × Π i, E i)) : 0 ≤ projectiveSeminormAux p := by simp only [projectiveSeminormAux, Function.comp_apply] refine List.sum_nonneg ?_ intro a simp only [Multiset.map_coe, Multiset.mem_coe, List.mem_map, Prod.exists, forall_exists_index, and_imp] intro x m _ h rw [← h] exact mul_nonneg (norm_nonneg _) (Finset.prod_nonneg (fun _ _ ↦ norm_nonneg _)) theorem projectiveSeminormAux_add_le (p q : FreeAddMonoid (𝕜 × Π i, E i)) : projectiveSeminormAux (p + q) ≤ projectiveSeminormAux p + projectiveSeminormAux q := by simp only [projectiveSeminormAux, Function.comp_apply, Multiset.map_coe, Multiset.sum_coe] erw [List.map_append] rw [List.sum_append] rfl
Mathlib/Analysis/NormedSpace/PiTensorProduct/ProjectiveSeminorm.lean
73
82
theorem projectiveSeminormAux_smul (p : FreeAddMonoid (𝕜 × Π i, E i)) (a : 𝕜) : projectiveSeminormAux (List.map (fun (y : 𝕜 × Π i, E i) ↦ (a * y.1, y.2)) p) = ‖a‖ * projectiveSeminormAux p := by
simp only [projectiveSeminormAux, Function.comp_apply, Multiset.map_coe, List.map_map, Multiset.sum_coe] rw [← smul_eq_mul, List.smul_sum, ← List.comp_map] congr 2 ext x simp only [Function.comp_apply, norm_mul, smul_eq_mul] rw [mul_assoc]
/- 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.Data.Set.Pointwise.SMul #align_import algebra.add_torsor from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Torsors of additive group actions This file defines torsors of additive group actions. ## Notations The group elements are referred to as acting on points. This file defines the notation `+ᵥ` for adding a group element to a point and `-ᵥ` for subtracting two points to produce a group element. ## Implementation notes Affine spaces are the motivating example of torsors of additive group actions. It may be appropriate to refactor in terms of the general definition of group actions, via `to_additive`, when there is a use for multiplicative torsors (currently mathlib only develops the theory of group actions for multiplicative group actions). ## Notations * `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid; * `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor as an element of the corresponding additive group; ## References * https://en.wikipedia.org/wiki/Principal_homogeneous_space * https://en.wikipedia.org/wiki/Affine_space -/ /-- An `AddTorsor G P` gives a structure to the nonempty type `P`, acted on by an `AddGroup G` with a transitive and free action given by the `+ᵥ` operation and a corresponding subtraction given by the `-ᵥ` operation. In the case of a vector space, it is an affine space. -/ class AddTorsor (G : outParam Type*) (P : Type*) [AddGroup G] extends AddAction G P, VSub G P where [nonempty : Nonempty P] /-- Torsor subtraction and addition with the same element cancels out. -/ vsub_vadd' : ∀ p₁ p₂ : P, (p₁ -ᵥ p₂ : G) +ᵥ p₂ = p₁ /-- Torsor addition and subtraction with the same element cancels out. -/ vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g #align add_torsor AddTorsor -- Porting note(#12096): removed `nolint instance_priority`; lint not ported yet attribute [instance 100] AddTorsor.nonempty -- Porting note(#12094): removed nolint; dangerous_instance linter not ported yet --attribute [nolint dangerous_instance] AddTorsor.toVSub /-- An `AddGroup G` is a torsor for itself. -/ -- Porting note(#12096): linter not ported yet --@[nolint instance_priority] instance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G where vsub := Sub.sub vsub_vadd' := sub_add_cancel vadd_vsub' := add_sub_cancel_right #align add_group_is_add_torsor addGroupIsAddTorsor /-- Simplify subtraction for a torsor for an `AddGroup G` over itself. -/ @[simp] theorem vsub_eq_sub {G : Type*} [AddGroup G] (g₁ g₂ : G) : g₁ -ᵥ g₂ = g₁ - g₂ := rfl #align vsub_eq_sub vsub_eq_sub section General variable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P] /-- Adding the result of subtracting from another point produces that point. -/ @[simp] theorem vsub_vadd (p₁ p₂ : P) : p₁ -ᵥ p₂ +ᵥ p₂ = p₁ := AddTorsor.vsub_vadd' p₁ p₂ #align vsub_vadd vsub_vadd /-- Adding a group element then subtracting the original point produces that group element. -/ @[simp] theorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g := AddTorsor.vadd_vsub' g p #align vadd_vsub vadd_vsub /-- If the same point added to two group elements produces equal results, those group elements are equal. -/
Mathlib/Algebra/AddTorsor.lean
98
100
theorem vadd_right_cancel {g₁ g₂ : G} (p : P) (h : g₁ +ᵥ p = g₂ +ᵥ p) : g₁ = g₂ := by
-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p rw [← vadd_vsub g₁ p, h, vadd_vsub]
/- 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]
Mathlib/Data/Option/NAry.lean
73
74
theorem map₂_coe_right (f : α → β → γ) (a : Option α) (b : β) : map₂ f a b = a.map fun a => f a b := by
cases a <;> rfl
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Sébastien Gouëzel, Yury G. Kudryashov, Dylan MacKenzie, Patrick Massot -/ import Mathlib.Algebra.BigOperators.Module import Mathlib.Algebra.Order.Field.Basic import Mathlib.Order.Filter.ModEq import Mathlib.Analysis.Asymptotics.Asymptotics import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.List.TFAE import Mathlib.Analysis.NormedSpace.Basic #align_import analysis.specific_limits.normed from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # A collection of specific limit computations This file contains important specific limit computations in (semi-)normed groups/rings/spaces, as well as such computations in `ℝ` when the natural proof passes through a fact about normed spaces. -/ noncomputable section open scoped Classical open Set Function Filter Finset Metric Asymptotics open scoped Classical open Topology Nat uniformity NNReal ENNReal variable {α : Type*} {β : Type*} {ι : Type*} theorem tendsto_norm_atTop_atTop : Tendsto (norm : ℝ → ℝ) atTop atTop := tendsto_abs_atTop_atTop #align tendsto_norm_at_top_at_top tendsto_norm_atTop_atTop theorem summable_of_absolute_convergence_real {f : ℕ → ℝ} : (∃ r, Tendsto (fun n ↦ ∑ i ∈ range n, |f i|) atTop (𝓝 r)) → Summable f | ⟨r, hr⟩ => by refine .of_norm ⟨r, (hasSum_iff_tendsto_nat_of_nonneg ?_ _).2 ?_⟩ · exact fun i ↦ norm_nonneg _ · simpa only using hr #align summable_of_absolute_convergence_real summable_of_absolute_convergence_real /-! ### Powers -/ theorem tendsto_norm_zero' {𝕜 : Type*} [NormedAddCommGroup 𝕜] : Tendsto (norm : 𝕜 → ℝ) (𝓝[≠] 0) (𝓝[>] 0) := tendsto_norm_zero.inf <| tendsto_principal_principal.2 fun _ hx ↦ norm_pos_iff.2 hx #align tendsto_norm_zero' tendsto_norm_zero' namespace NormedField theorem tendsto_norm_inverse_nhdsWithin_0_atTop {𝕜 : Type*} [NormedDivisionRing 𝕜] : Tendsto (fun x : 𝕜 ↦ ‖x⁻¹‖) (𝓝[≠] 0) atTop := (tendsto_inv_zero_atTop.comp tendsto_norm_zero').congr fun x ↦ (norm_inv x).symm #align normed_field.tendsto_norm_inverse_nhds_within_0_at_top NormedField.tendsto_norm_inverse_nhdsWithin_0_atTop theorem tendsto_norm_zpow_nhdsWithin_0_atTop {𝕜 : Type*} [NormedDivisionRing 𝕜] {m : ℤ} (hm : m < 0) : Tendsto (fun x : 𝕜 ↦ ‖x ^ m‖) (𝓝[≠] 0) atTop := by rcases neg_surjective m with ⟨m, rfl⟩ rw [neg_lt_zero] at hm; lift m to ℕ using hm.le; rw [Int.natCast_pos] at hm simp only [norm_pow, zpow_neg, zpow_natCast, ← inv_pow] exact (tendsto_pow_atTop hm.ne').comp NormedField.tendsto_norm_inverse_nhdsWithin_0_atTop #align normed_field.tendsto_norm_zpow_nhds_within_0_at_top NormedField.tendsto_norm_zpow_nhdsWithin_0_atTop /-- The (scalar) product of a sequence that tends to zero with a bounded one also tends to zero. -/ theorem tendsto_zero_smul_of_tendsto_zero_of_bounded {ι 𝕜 𝔸 : Type*} [NormedDivisionRing 𝕜] [NormedAddCommGroup 𝔸] [Module 𝕜 𝔸] [BoundedSMul 𝕜 𝔸] {l : Filter ι} {ε : ι → 𝕜} {f : ι → 𝔸} (hε : Tendsto ε l (𝓝 0)) (hf : Filter.IsBoundedUnder (· ≤ ·) l (norm ∘ f)) : Tendsto (ε • f) l (𝓝 0) := by rw [← isLittleO_one_iff 𝕜] at hε ⊢ simpa using IsLittleO.smul_isBigO hε (hf.isBigO_const (one_ne_zero : (1 : 𝕜) ≠ 0)) #align normed_field.tendsto_zero_smul_of_tendsto_zero_of_bounded NormedField.tendsto_zero_smul_of_tendsto_zero_of_bounded @[simp] theorem continuousAt_zpow {𝕜 : Type*} [NontriviallyNormedField 𝕜] {m : ℤ} {x : 𝕜} : ContinuousAt (fun x ↦ x ^ m) x ↔ x ≠ 0 ∨ 0 ≤ m := by refine ⟨?_, continuousAt_zpow₀ _ _⟩ contrapose!; rintro ⟨rfl, hm⟩ hc exact not_tendsto_atTop_of_tendsto_nhds (hc.tendsto.mono_left nhdsWithin_le_nhds).norm (tendsto_norm_zpow_nhdsWithin_0_atTop hm) #align normed_field.continuous_at_zpow NormedField.continuousAt_zpow @[simp]
Mathlib/Analysis/SpecificLimits/Normed.lean
90
92
theorem continuousAt_inv {𝕜 : Type*} [NontriviallyNormedField 𝕜] {x : 𝕜} : ContinuousAt Inv.inv x ↔ x ≠ 0 := by
simpa [(zero_lt_one' ℤ).not_le] using @continuousAt_zpow _ _ (-1) x
/- 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.Algebra.MvPolynomial.Equiv import Mathlib.Algebra.MvPolynomial.Supported import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.RingTheory.Adjoin.Basic import Mathlib.RingTheory.Algebraic import Mathlib.RingTheory.MvPolynomial.Basic #align_import ring_theory.algebraic_independent from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69" /-! # Algebraic Independence This file defines algebraic independence of a family of element of an `R` algebra. ## Main definitions * `AlgebraicIndependent` - `AlgebraicIndependent R x` states the family of elements `x` is algebraically independent over `R`, meaning that the canonical map out of the multivariable polynomial ring is injective. * `AlgebraicIndependent.repr` - The canonical map from the subalgebra generated by an algebraic independent family into the polynomial ring. ## References * [Stacks: Transcendence](https://stacks.math.columbia.edu/tag/030D) ## TODO Define the transcendence degree and show it is independent of the choice of a transcendence basis. ## Tags transcendence basis, transcendence degree, transcendence -/ noncomputable section open Function Set Subalgebra MvPolynomial Algebra open scoped Classical universe x u v w variable {ι : Type*} {ι' : Type*} (R : Type*) {K : Type*} variable {A : Type*} {A' A'' : Type*} {V : Type u} {V' : Type*} variable (x : ι → A) variable [CommRing R] [CommRing A] [CommRing A'] [CommRing A''] variable [Algebra R A] [Algebra R A'] [Algebra R A''] variable {a b : R} /-- `AlgebraicIndependent R x` states the family of elements `x` is algebraically independent over `R`, meaning that the canonical map out of the multivariable polynomial ring is injective. -/ def AlgebraicIndependent : Prop := Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A) #align algebraic_independent AlgebraicIndependent variable {R} {x} theorem algebraicIndependent_iff_ker_eq_bot : AlgebraicIndependent R x ↔ RingHom.ker (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A).toRingHom = ⊥ := RingHom.injective_iff_ker_eq_bot _ #align algebraic_independent_iff_ker_eq_bot algebraicIndependent_iff_ker_eq_bot theorem algebraicIndependent_iff : AlgebraicIndependent R x ↔ ∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 := injective_iff_map_eq_zero _ #align algebraic_independent_iff algebraicIndependent_iff theorem AlgebraicIndependent.eq_zero_of_aeval_eq_zero (h : AlgebraicIndependent R x) : ∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 := algebraicIndependent_iff.1 h #align algebraic_independent.eq_zero_of_aeval_eq_zero AlgebraicIndependent.eq_zero_of_aeval_eq_zero theorem algebraicIndependent_iff_injective_aeval : AlgebraicIndependent R x ↔ Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A) := Iff.rfl #align algebraic_independent_iff_injective_aeval algebraicIndependent_iff_injective_aeval @[simp]
Mathlib/RingTheory/AlgebraicIndependent.lean
90
96
theorem algebraicIndependent_empty_type_iff [IsEmpty ι] : AlgebraicIndependent R x ↔ Injective (algebraMap R A) := by
have : aeval x = (Algebra.ofId R A).comp (@isEmptyAlgEquiv R ι _ _).toAlgHom := by ext i exact IsEmpty.elim' ‹IsEmpty ι› i rw [AlgebraicIndependent, this, ← Injective.of_comp_iff' _ (@isEmptyAlgEquiv R ι _ _).bijective] rfl
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Lu-Ming Zhang -/ import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Combinatorics.SimpleGraph.Connectivity import Mathlib.LinearAlgebra.Matrix.Trace import Mathlib.LinearAlgebra.Matrix.Symmetric #align_import combinatorics.simple_graph.adj_matrix from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" /-! # Adjacency Matrices This module defines the adjacency matrix of a graph, and provides theorems connecting graph properties to computational properties of the matrix. ## Main definitions * `Matrix.IsAdjMatrix`: `A : Matrix V V α` is qualified as an "adjacency matrix" if (1) every entry of `A` is `0` or `1`, (2) `A` is symmetric, (3) every diagonal entry of `A` is `0`. * `Matrix.IsAdjMatrix.to_graph`: for `A : Matrix V V α` and `h : A.IsAdjMatrix`, `h.to_graph` is the simple graph induced by `A`. * `Matrix.compl`: for `A : Matrix V V α`, `A.compl` is supposed to be the adjacency matrix of the complement graph of the graph induced by `A`. * `SimpleGraph.adjMatrix`: the adjacency matrix of a `SimpleGraph`. * `SimpleGraph.adjMatrix_pow_apply_eq_card_walk`: each entry of the `n`th power of a graph's adjacency matrix counts the number of length-`n` walks between the corresponding pair of vertices. -/ open Matrix open Finset Matrix SimpleGraph variable {V α β : Type*} namespace Matrix /-- `A : Matrix V V α` is qualified as an "adjacency matrix" if (1) every entry of `A` is `0` or `1`, (2) `A` is symmetric, (3) every diagonal entry of `A` is `0`. -/ structure IsAdjMatrix [Zero α] [One α] (A : Matrix V V α) : Prop where zero_or_one : ∀ i j, A i j = 0 ∨ A i j = 1 := by aesop symm : A.IsSymm := by aesop apply_diag : ∀ i, A i i = 0 := by aesop #align matrix.is_adj_matrix Matrix.IsAdjMatrix namespace IsAdjMatrix variable {A : Matrix V V α} @[simp] theorem apply_diag_ne [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i : V) : ¬A i i = 1 := by simp [h.apply_diag i] #align matrix.is_adj_matrix.apply_diag_ne Matrix.IsAdjMatrix.apply_diag_ne @[simp] theorem apply_ne_one_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) : ¬A i j = 1 ↔ A i j = 0 := by obtain h | h := h.zero_or_one i j <;> simp [h] #align matrix.is_adj_matrix.apply_ne_one_iff Matrix.IsAdjMatrix.apply_ne_one_iff @[simp] theorem apply_ne_zero_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) : ¬A i j = 0 ↔ A i j = 1 := by rw [← apply_ne_one_iff h, Classical.not_not] #align matrix.is_adj_matrix.apply_ne_zero_iff Matrix.IsAdjMatrix.apply_ne_zero_iff /-- For `A : Matrix V V α` and `h : IsAdjMatrix A`, `h.toGraph` is the simple graph whose adjacency matrix is `A`. -/ @[simps] def toGraph [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) : SimpleGraph V where Adj i j := A i j = 1 symm i j hij := by simp only; rwa [h.symm.apply i j] loopless i := by simp [h] #align matrix.is_adj_matrix.to_graph Matrix.IsAdjMatrix.toGraph instance [MulZeroOneClass α] [Nontrivial α] [DecidableEq α] (h : IsAdjMatrix A) : DecidableRel h.toGraph.Adj := by simp only [toGraph] infer_instance end IsAdjMatrix /-- For `A : Matrix V V α`, `A.compl` is supposed to be the adjacency matrix of the complement graph of the graph induced by `A.adjMatrix`. -/ def compl [Zero α] [One α] [DecidableEq α] [DecidableEq V] (A : Matrix V V α) : Matrix V V α := fun i j => ite (i = j) 0 (ite (A i j = 0) 1 0) #align matrix.compl Matrix.compl section Compl variable [DecidableEq α] [DecidableEq V] (A : Matrix V V α) @[simp] theorem compl_apply_diag [Zero α] [One α] (i : V) : A.compl i i = 0 := by simp [compl] #align matrix.compl_apply_diag Matrix.compl_apply_diag @[simp] theorem compl_apply [Zero α] [One α] (i j : V) : A.compl i j = 0 ∨ A.compl i j = 1 := by unfold compl split_ifs <;> simp #align matrix.compl_apply Matrix.compl_apply @[simp] theorem isSymm_compl [Zero α] [One α] (h : A.IsSymm) : A.compl.IsSymm := by ext simp [compl, h.apply, eq_comm] #align matrix.is_symm_compl Matrix.isSymm_compl @[simp]
Mathlib/Combinatorics/SimpleGraph/AdjMatrix.lean
121
122
theorem isAdjMatrix_compl [Zero α] [One α] (h : A.IsSymm) : IsAdjMatrix A.compl := { symm := by
simp [h] }
/- Copyright (c) 2021 Bryan Gin-ge Chen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bryan Gin-ge Chen, Yury Kudryashov -/ import Mathlib.Algebra.Group.Hom.Defs #align_import algebra.group.ext from "leanprover-community/mathlib"@"e574b1a4e891376b0ef974b926da39e05da12a06" /-! # Extensionality lemmas for monoid and group structures In this file we prove extensionality lemmas for `Monoid` and higher algebraic structures with one binary operation. Extensionality lemmas for structures that are lower in the hierarchy can be found in `Algebra.Group.Defs`. ## Implementation details To get equality of `npow` etc, we define a monoid homomorphism between two monoid structures on the same type, then apply lemmas like `MonoidHom.map_div`, `MonoidHom.map_pow` etc. To refer to the `*` operator of a particular instance `i`, we use `(letI := i; HMul.hMul : M → M → M)` instead of `i.mul` (which elaborates to `Mul.mul`), as the former uses `HMul.hMul` which is the canonical spelling. ## Tags monoid, group, extensionality -/ assert_not_exists MonoidWithZero assert_not_exists DenselyOrdered open Function universe u @[to_additive (attr := ext)] theorem Monoid.ext {M : Type u} ⦃m₁ m₂ : Monoid M⦄ (h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) : m₁ = m₂ := by have : m₁.toMulOneClass = m₂.toMulOneClass := MulOneClass.ext h_mul have h₁ : m₁.one = m₂.one := congr_arg (·.one) this let f : @MonoidHom M M m₁.toMulOneClass m₂.toMulOneClass := @MonoidHom.mk _ _ (_) _ (@OneHom.mk _ _ (_) _ id h₁) (fun x y => congr_fun (congr_fun h_mul x) y) have : m₁.npow = m₂.npow := by ext n x exact @MonoidHom.map_pow M M m₁ m₂ f x n rcases m₁ with @⟨@⟨⟨_⟩⟩, ⟨_⟩⟩ rcases m₂ with @⟨@⟨⟨_⟩⟩, ⟨_⟩⟩ congr #align monoid.ext Monoid.ext #align add_monoid.ext AddMonoid.ext @[to_additive] theorem CommMonoid.toMonoid_injective {M : Type u} : Function.Injective (@CommMonoid.toMonoid M) := by rintro ⟨⟩ ⟨⟩ h congr #align comm_monoid.to_monoid_injective CommMonoid.toMonoid_injective #align add_comm_monoid.to_add_monoid_injective AddCommMonoid.toAddMonoid_injective @[to_additive (attr := ext)] theorem CommMonoid.ext {M : Type*} ⦃m₁ m₂ : CommMonoid M⦄ (h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) : m₁ = m₂ := CommMonoid.toMonoid_injective <| Monoid.ext h_mul #align comm_monoid.ext CommMonoid.ext #align add_comm_monoid.ext AddCommMonoid.ext @[to_additive] theorem LeftCancelMonoid.toMonoid_injective {M : Type u} : Function.Injective (@LeftCancelMonoid.toMonoid M) := by rintro @⟨@⟨⟩⟩ @⟨@⟨⟩⟩ h congr <;> injection h #align left_cancel_monoid.to_monoid_injective LeftCancelMonoid.toMonoid_injective #align add_left_cancel_monoid.to_add_monoid_injective AddLeftCancelMonoid.toAddMonoid_injective @[to_additive (attr := ext)] theorem LeftCancelMonoid.ext {M : Type u} ⦃m₁ m₂ : LeftCancelMonoid M⦄ (h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) : m₁ = m₂ := LeftCancelMonoid.toMonoid_injective <| Monoid.ext h_mul #align left_cancel_monoid.ext LeftCancelMonoid.ext #align add_left_cancel_monoid.ext AddLeftCancelMonoid.ext @[to_additive]
Mathlib/Algebra/Group/Ext.lean
87
90
theorem RightCancelMonoid.toMonoid_injective {M : Type u} : Function.Injective (@RightCancelMonoid.toMonoid M) := by
rintro @⟨@⟨⟩⟩ @⟨@⟨⟩⟩ h congr <;> injection h
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.GCDMonoid.Multiset import Mathlib.Combinatorics.Enumerative.Partition import Mathlib.Data.List.Rotate import Mathlib.GroupTheory.Perm.Cycle.Factors import Mathlib.GroupTheory.Perm.Closure import Mathlib.Algebra.GCDMonoid.Nat import Mathlib.Tactic.NormNum.GCD #align_import group_theory.perm.cycle.type from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722" /-! # Cycle Types In this file we define the cycle type of a permutation. ## Main definitions - `Equiv.Perm.cycleType σ` where `σ` is a permutation of a `Fintype` - `Equiv.Perm.partition σ` where `σ` is a permutation of a `Fintype` ## Main results - `sum_cycleType` : The sum of `σ.cycleType` equals `σ.support.card` - `lcm_cycleType` : The lcm of `σ.cycleType` equals `orderOf σ` - `isConj_iff_cycleType_eq` : Two permutations are conjugate if and only if they have the same cycle type. - `exists_prime_orderOf_dvd_card`: For every prime `p` dividing the order of a finite group `G` there exists an element of order `p` in `G`. This is known as Cauchy's theorem. -/ namespace Equiv.Perm open Equiv List Multiset variable {α : Type*} [Fintype α] section CycleType variable [DecidableEq α] /-- The cycle type of a permutation -/ def cycleType (σ : Perm α) : Multiset ℕ := σ.cycleFactorsFinset.1.map (Finset.card ∘ support) #align equiv.perm.cycle_type Equiv.Perm.cycleType theorem cycleType_def (σ : Perm α) : σ.cycleType = σ.cycleFactorsFinset.1.map (Finset.card ∘ support) := rfl #align equiv.perm.cycle_type_def Equiv.Perm.cycleType_def theorem cycleType_eq' {σ : Perm α} (s : Finset (Perm α)) (h1 : ∀ f : Perm α, f ∈ s → f.IsCycle) (h2 : (s : Set (Perm α)).Pairwise Disjoint) (h0 : s.noncommProd id (h2.imp fun _ _ => Disjoint.commute) = σ) : σ.cycleType = s.1.map (Finset.card ∘ support) := by rw [cycleType_def] congr rw [cycleFactorsFinset_eq_finset] exact ⟨h1, h2, h0⟩ #align equiv.perm.cycle_type_eq' Equiv.Perm.cycleType_eq' theorem cycleType_eq {σ : Perm α} (l : List (Perm α)) (h0 : l.prod = σ) (h1 : ∀ σ : Perm α, σ ∈ l → σ.IsCycle) (h2 : l.Pairwise Disjoint) : σ.cycleType = l.map (Finset.card ∘ support) := by have hl : l.Nodup := nodup_of_pairwise_disjoint_cycles h1 h2 rw [cycleType_eq' l.toFinset] · simp [List.dedup_eq_self.mpr hl, (· ∘ ·)] · simpa using h1 · simpa [hl] using h2 · simp [hl, h0] #align equiv.perm.cycle_type_eq Equiv.Perm.cycleType_eq @[simp] -- Porting note: new attr theorem cycleType_eq_zero {σ : Perm α} : σ.cycleType = 0 ↔ σ = 1 := by simp [cycleType_def, cycleFactorsFinset_eq_empty_iff] #align equiv.perm.cycle_type_eq_zero Equiv.Perm.cycleType_eq_zero @[simp] -- Porting note: new attr theorem cycleType_one : (1 : Perm α).cycleType = 0 := cycleType_eq_zero.2 rfl #align equiv.perm.cycle_type_one Equiv.Perm.cycleType_one
Mathlib/GroupTheory/Perm/Cycle/Type.lean
87
88
theorem card_cycleType_eq_zero {σ : Perm α} : Multiset.card σ.cycleType = 0 ↔ σ = 1 := by
rw [card_eq_zero, cycleType_eq_zero]
/- 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.MeasurableSpace.Basic import Mathlib.MeasureTheory.Measure.MeasureSpaceDef #align_import measure_theory.function.ae_measurable_sequence from "leanprover-community/mathlib"@"d003c55042c3cd08aefd1ae9a42ef89441cdaaf3" /-! # Sequence of measurable functions associated to a sequence of a.e.-measurable functions We define here tools to prove statements about limits (infi, supr...) of sequences of `AEMeasurable` functions. Given a sequence of a.e.-measurable functions `f : ι → α → β` with hypothesis `hf : ∀ i, AEMeasurable (f i) μ`, and a pointwise property `p : α → (ι → β) → Prop` such that we have `hp : ∀ᵐ x ∂μ, p x (fun n ↦ f n x)`, we define a sequence of measurable functions `aeSeq hf p` and a measurable set `aeSeqSet hf p`, such that * `μ (aeSeqSet hf p)ᶜ = 0` * `x ∈ aeSeqSet hf p → ∀ i : ι, aeSeq hf hp i x = f i x` * `x ∈ aeSeqSet hf p → p x (fun n ↦ f n x)` -/ open MeasureTheory open scoped Classical variable {ι : Sort*} {α β γ : Type*} [MeasurableSpace α] [MeasurableSpace β] {f : ι → α → β} {μ : Measure α} {p : α → (ι → β) → Prop} /-- If we have the additional hypothesis `∀ᵐ x ∂μ, p x (fun n ↦ f n x)`, this is a measurable set whose complement has measure 0 such that for all `x ∈ aeSeqSet`, `f i x` is equal to `(hf i).mk (f i) x` for all `i` and we have the pointwise property `p x (fun n ↦ f n x)`. -/ def aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : Set α := (toMeasurable μ { x | (∀ i, f i x = (hf i).mk (f i) x) ∧ p x fun n => f n x }ᶜ)ᶜ #align ae_seq_set aeSeqSet /-- A sequence of measurable functions that are equal to `f` and verify property `p` on the measurable set `aeSeqSet hf p`. -/ noncomputable def aeSeq (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : ι → α → β := fun i x => ite (x ∈ aeSeqSet hf p) ((hf i).mk (f i) x) (⟨f i x⟩ : Nonempty β).some #align ae_seq aeSeq namespace aeSeq section MemAESeqSet theorem mk_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : (hf i).mk (f i) x = f i x := haveI h_ss : aeSeqSet hf p ⊆ { x | ∀ i, f i x = (hf i).mk (f i) x } := by rw [aeSeqSet, ← compl_compl { x | ∀ i, f i x = (hf i).mk (f i) x }, Set.compl_subset_compl] refine Set.Subset.trans (Set.compl_subset_compl.mpr fun x h => ?_) (subset_toMeasurable _ _) exact h.1 (h_ss hx i).symm #align ae_seq.mk_eq_fun_of_mem_ae_seq_set aeSeq.mk_eq_fun_of_mem_aeSeqSet theorem aeSeq_eq_mk_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = (hf i).mk (f i) x := by simp only [aeSeq, hx, if_true] #align ae_seq.ae_seq_eq_mk_of_mem_ae_seq_set aeSeq.aeSeq_eq_mk_of_mem_aeSeqSet
Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean
64
66
theorem aeSeq_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = f i x := by
simp only [aeSeq_eq_mk_of_mem_aeSeqSet hf hx i, mk_eq_fun_of_mem_aeSeqSet hf hx i]
/- 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.Topology.Order.Basic /-! # Set neighborhoods of intervals In this file we prove basic theorems about `𝓝ˢ s`, where `s` is one of the intervals `Set.Ici`, `Set.Iic`, `Set.Ioi`, `Set.Iio`, `Set.Ico`, `Set.Ioc`, `Set.Ioo`, and `Set.Icc`. First, we prove lemmas in terms of filter equalities. Then we prove lemmas about `s ∈ 𝓝ˢ t`, where both `s` and `t` are intervals. Finally, we prove a few lemmas about filter bases of `𝓝ˢ (Iic a)` and `𝓝ˢ (Ici a)`. -/ open Set Filter OrderDual open scoped Topology section OrderClosedTopology variable {α : Type*} [LinearOrder α] [TopologicalSpace α] [OrderClosedTopology α] {a b c d : α} /-! # Formulae for `𝓝ˢ` of intervals -/ @[simp] theorem nhdsSet_Ioi : 𝓝ˢ (Ioi a) = 𝓟 (Ioi a) := isOpen_Ioi.nhdsSet_eq @[simp] theorem nhdsSet_Iio : 𝓝ˢ (Iio a) = 𝓟 (Iio a) := isOpen_Iio.nhdsSet_eq @[simp] theorem nhdsSet_Ioo : 𝓝ˢ (Ioo a b) = 𝓟 (Ioo a b) := isOpen_Ioo.nhdsSet_eq theorem nhdsSet_Ici : 𝓝ˢ (Ici a) = 𝓝 a ⊔ 𝓟 (Ioi a) := by rw [← Ioi_insert, nhdsSet_insert, nhdsSet_Ioi] theorem nhdsSet_Iic : 𝓝ˢ (Iic a) = 𝓝 a ⊔ 𝓟 (Iio a) := nhdsSet_Ici (α := αᵒᵈ) theorem nhdsSet_Ico (h : a < b) : 𝓝ˢ (Ico a b) = 𝓝 a ⊔ 𝓟 (Ioo a b) := by rw [← Ioo_insert_left h, nhdsSet_insert, nhdsSet_Ioo] theorem nhdsSet_Ioc (h : a < b) : 𝓝ˢ (Ioc a b) = 𝓝 b ⊔ 𝓟 (Ioo a b) := by rw [← Ioo_insert_right h, nhdsSet_insert, nhdsSet_Ioo] theorem nhdsSet_Icc (h : a ≤ b) : 𝓝ˢ (Icc a b) = 𝓝 a ⊔ 𝓝 b ⊔ 𝓟 (Ioo a b) := by rcases h.eq_or_lt with rfl | hlt · simp · rw [← Ioc_insert_left h, nhdsSet_insert, nhdsSet_Ioc hlt, sup_assoc] /-! ### Lemmas about `Ixi _ ∈ 𝓝ˢ (Set.Ici _)` -/ @[simp]
Mathlib/Topology/Order/NhdsSet.lean
57
58
theorem Ioi_mem_nhdsSet_Ici_iff : Ioi a ∈ 𝓝ˢ (Ici b) ↔ a < b := by
rw [isOpen_Ioi.mem_nhdsSet, Ici_subset_Ioi]
/- Copyright (c) 2020 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis -/ import Mathlib.Algebra.Field.Basic import Mathlib.Algebra.Order.Field.Defs import Mathlib.Data.Tree.Basic import Mathlib.Logic.Basic import Mathlib.Tactic.NormNum.Core import Mathlib.Util.SynthesizeUsing import Mathlib.Util.Qq /-! # A tactic for canceling numeric denominators This file defines tactics that cancel numeric denominators from field Expressions. As an example, we want to transform a comparison `5*(a/3 + b/4) < c/3` into the equivalent `5*(4*a + 3*b) < 4*c`. ## Implementation notes The tooling here was originally written for `linarith`, not intended as an interactive tactic. The interactive version has been split off because it is sometimes convenient to use on its own. There are likely some rough edges to it. Improving this tactic would be a good project for someone interested in learning tactic programming. -/ open Lean Parser Tactic Mathlib Meta NormNum Qq initialize registerTraceClass `CancelDenoms namespace CancelDenoms /-! ### Lemmas used in the procedure -/ theorem mul_subst {α} [CommRing α] {n1 n2 k e1 e2 t1 t2 : α} (h1 : n1 * e1 = t1) (h2 : n2 * e2 = t2) (h3 : n1 * n2 = k) : k * (e1 * e2) = t1 * t2 := by rw [← h3, mul_comm n1, mul_assoc n2, ← mul_assoc n1, h1, ← mul_assoc n2, mul_comm n2, mul_assoc, h2] #align cancel_factors.mul_subst CancelDenoms.mul_subst theorem div_subst {α} [Field α] {n1 n2 k e1 e2 t1 : α} (h1 : n1 * e1 = t1) (h2 : n2 / e2 = 1) (h3 : n1 * n2 = k) : k * (e1 / e2) = t1 := by rw [← h3, mul_assoc, mul_div_left_comm, h2, ← mul_assoc, h1, mul_comm, one_mul] #align cancel_factors.div_subst CancelDenoms.div_subst theorem cancel_factors_eq_div {α} [Field α] {n e e' : α} (h : n * e = e') (h2 : n ≠ 0) : e = e' / n := eq_div_of_mul_eq h2 <| by rwa [mul_comm] at h #align cancel_factors.cancel_factors_eq_div CancelDenoms.cancel_factors_eq_div theorem add_subst {α} [Ring α] {n e1 e2 t1 t2 : α} (h1 : n * e1 = t1) (h2 : n * e2 = t2) : n * (e1 + e2) = t1 + t2 := by simp [left_distrib, *] #align cancel_factors.add_subst CancelDenoms.add_subst theorem sub_subst {α} [Ring α] {n e1 e2 t1 t2 : α} (h1 : n * e1 = t1) (h2 : n * e2 = t2) : n * (e1 - e2) = t1 - t2 := by simp [left_distrib, *, sub_eq_add_neg] #align cancel_factors.sub_subst CancelDenoms.sub_subst theorem neg_subst {α} [Ring α] {n e t : α} (h1 : n * e = t) : n * -e = -t := by simp [*] #align cancel_factors.neg_subst CancelDenoms.neg_subst
Mathlib/Tactic/CancelDenoms/Core.lean
66
68
theorem pow_subst {α} [CommRing α] {n e1 t1 k l : α} {e2 : ℕ} (h1 : n * e1 = t1) (h2 : l * n ^ e2 = k) : k * (e1 ^ e2) = l * t1 ^ e2 := by
rw [← h2, ← h1, mul_pow, mul_assoc]
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.MetricSpace.Isometry #align_import topology.metric_space.gluing from "leanprover-community/mathlib"@"e1a7bdeb4fd826b7e71d130d34988f0a2d26a177" /-! # Metric space gluing Gluing two metric spaces along a common subset. Formally, we are given ``` Φ Z ---> X | |Ψ v Y ``` where `hΦ : Isometry Φ` and `hΨ : Isometry Ψ`. We want to complete the square by a space `GlueSpacescan hΦ hΨ` and two isometries `toGlueL hΦ hΨ` and `toGlueR hΦ hΨ` that make the square commute. We start by defining a predistance on the disjoint union `X ⊕ Y`, for which points `Φ p` and `Ψ p` are at distance 0. The (quotient) metric space associated to this predistance is the desired space. This is an instance of a more general construction, where `Φ` and `Ψ` do not have to be isometries, but the distances in the image almost coincide, up to `2ε` say. Then one can almost glue the two spaces so that the images of a point under `Φ` and `Ψ` are `ε`-close. If `ε > 0`, this yields a metric space structure on `X ⊕ Y`, without the need to take a quotient. In particular, this gives a natural metric space structure on `X ⊕ Y`, where the basepoints are at distance 1, say, and the distances between other points are obtained by going through the two basepoints. (We also register the same metric space structure on a general disjoint union `Σ i, E i`). We also define the inductive limit of metric spaces. Given ``` f 0 f 1 f 2 f 3 X 0 -----> X 1 -----> X 2 -----> X 3 -----> ... ``` where the `X n` are metric spaces and `f n` isometric embeddings, we define the inductive limit of the `X n`, also known as the increasing union of the `X n` in this context, if we identify `X n` and `X (n+1)` through `f n`. This is a metric space in which all `X n` embed isometrically and in a way compatible with `f n`. -/ noncomputable section universe u v w open Function Set Uniformity Topology namespace Metric section ApproxGluing variable {X : Type u} {Y : Type v} {Z : Type w} variable [MetricSpace X] [MetricSpace Y] {Φ : Z → X} {Ψ : Z → Y} {ε : ℝ} /-- Define a predistance on `X ⊕ Y`, for which `Φ p` and `Ψ p` are at distance `ε` -/ def glueDist (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) : Sum X Y → Sum X Y → ℝ | .inl x, .inl y => dist x y | .inr x, .inr y => dist x y | .inl x, .inr y => (⨅ p, dist x (Φ p) + dist y (Ψ p)) + ε | .inr x, .inl y => (⨅ p, dist y (Φ p) + dist x (Ψ p)) + ε #align metric.glue_dist Metric.glueDist private theorem glueDist_self (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) : ∀ x, glueDist Φ Ψ ε x x = 0 | .inl _ => dist_self _ | .inr _ => dist_self _
Mathlib/Topology/MetricSpace/Gluing.lean
76
85
theorem glueDist_glued_points [Nonempty Z] (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) (p : Z) : glueDist Φ Ψ ε (.inl (Φ p)) (.inr (Ψ p)) = ε := by
have : ⨅ q, dist (Φ p) (Φ q) + dist (Ψ p) (Ψ q) = 0 := by have A : ∀ q, 0 ≤ dist (Φ p) (Φ q) + dist (Ψ p) (Ψ q) := fun _ => add_nonneg dist_nonneg dist_nonneg refine le_antisymm ?_ (le_ciInf A) have : 0 = dist (Φ p) (Φ p) + dist (Ψ p) (Ψ p) := by simp rw [this] exact ciInf_le ⟨0, forall_mem_range.2 A⟩ p simp only [glueDist, this, zero_add]
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.LinearAlgebra.Dimension.Free import Mathlib.Algebra.Homology.ShortComplex.ModuleCat /-! # Exact sequences with free modules This file proves results about linear independence and span in exact sequences of modules. ## Main theorems * `linearIndependent_shortExact`: Given a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and linearly independent families `v : ι → X₁` and `w : ι' → X₃`, we get a linearly independent family `ι ⊕ ι' → X₂` * `span_rightExact`: Given an exact sequence `X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and spanning families `v : ι → X₁` and `w : ι' → X₃`, we get a spanning family `ι ⊕ ι' → X₂` * Using `linearIndependent_shortExact` and `span_rightExact`, we prove `free_shortExact`: In a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` where `X₁` and `X₃` are free, `X₂` is free as well. ## Tags linear algebra, module, free -/ open CategoryTheory namespace ModuleCat variable {ι ι' R : Type*} [Ring R] {S : ShortComplex (ModuleCat R)} (hS : S.Exact) (hS' : S.ShortExact) {v : ι → S.X₁} open CategoryTheory Submodule Set section LinearIndependent variable (hv : LinearIndependent R v) {u : ι ⊕ ι' → S.X₂} (hw : LinearIndependent R (S.g ∘ u ∘ Sum.inr)) (hm : Mono S.f) (huv : u ∘ Sum.inl = S.f ∘ v) theorem disjoint_span_sum : Disjoint (span R (range (u ∘ Sum.inl))) (span R (range (u ∘ Sum.inr))) := by rw [huv, disjoint_comm] refine Disjoint.mono_right (span_mono (range_comp_subset_range _ _)) ?_ rw [← LinearMap.range_coe, span_eq (LinearMap.range S.f), hS.moduleCat_range_eq_ker] exact range_ker_disjoint hw /-- In the commutative diagram ``` f g 0 --→ X₁ --→ X₂ --→ X₃ ↑ ↑ ↑ v| u| w| ι → ι ⊕ ι' ← ι' ``` where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and `Sum.inr`. If `u` is injective and `v` and `w` are linearly independent, then `u` is linearly independent. -/ theorem linearIndependent_leftExact : LinearIndependent R u := by rw [linearIndependent_sum] refine ⟨?_, LinearIndependent.of_comp S.g hw, disjoint_span_sum hS hw huv⟩ rw [huv, LinearMap.linearIndependent_iff S.f]; swap · rw [LinearMap.ker_eq_bot, ← mono_iff_injective] infer_instance exact hv /-- Given a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and linearly independent families `v : ι → N` and `w : ι' → P`, we get a linearly independent family `ι ⊕ ι' → M` -/ theorem linearIndependent_shortExact {w : ι' → S.X₃} (hw : LinearIndependent R w) : LinearIndependent R (Sum.elim (S.f ∘ v) (S.g.toFun.invFun ∘ w)) := by apply linearIndependent_leftExact hS'.exact hv _ hS'.mono_f rfl dsimp convert hw ext apply Function.rightInverse_invFun ((epi_iff_surjective _).mp hS'.epi_g) end LinearIndependent section Span /-- In the commutative diagram ``` f g X₁ --→ X₂ --→ X₃ ↑ ↑ ↑ v| u| w| ι → ι ⊕ ι' ← ι' ``` where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and `Sum.inr`. If `v` spans `X₁` and `w` spans `X₃`, then `u` spans `X₂`. -/
Mathlib/Algebra/Category/ModuleCat/Free.lean
94
125
theorem span_exact {β : Type*} {u : ι ⊕ β → S.X₂} (huv : u ∘ Sum.inl = S.f ∘ v) (hv : ⊤ ≤ span R (range v)) (hw : ⊤ ≤ span R (range (S.g ∘ u ∘ Sum.inr))) : ⊤ ≤ span R (range u) := by
intro m _ have hgm : S.g m ∈ span R (range (S.g ∘ u ∘ Sum.inr)) := hw mem_top rw [Finsupp.mem_span_range_iff_exists_finsupp] at hgm obtain ⟨cm, hm⟩ := hgm let m' : S.X₂ := Finsupp.sum cm fun j a ↦ a • (u (Sum.inr j)) have hsub : m - m' ∈ LinearMap.range S.f := by rw [hS.moduleCat_range_eq_ker] simp only [LinearMap.mem_ker, map_sub, sub_eq_zero] rw [← hm, map_finsupp_sum] simp only [Function.comp_apply, map_smul] obtain ⟨n, hnm⟩ := hsub have hn : n ∈ span R (range v) := hv mem_top rw [Finsupp.mem_span_range_iff_exists_finsupp] at hn obtain ⟨cn, hn⟩ := hn rw [← hn, map_finsupp_sum] at hnm rw [← sub_add_cancel m m', ← hnm,] simp only [map_smul] have hn' : (Finsupp.sum cn fun a b ↦ b • S.f (v a)) = (Finsupp.sum cn fun a b ↦ b • u (Sum.inl a)) := by congr; ext a b; rw [← Function.comp_apply (f := S.f), ← huv, Function.comp_apply] rw [hn'] apply add_mem · rw [Finsupp.mem_span_range_iff_exists_finsupp] use cn.mapDomain (Sum.inl) rw [Finsupp.sum_mapDomain_index_inj Sum.inl_injective] · rw [Finsupp.mem_span_range_iff_exists_finsupp] use cm.mapDomain (Sum.inr) rw [Finsupp.sum_mapDomain_index_inj Sum.inr_injective]
/- 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. -/
Mathlib/Topology/Connected/TotallyDisconnected.lean
108
119
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)
/- Copyright (c) 2023 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Probability.Kernel.Composition import Mathlib.MeasureTheory.Integral.SetIntegral #align_import probability.kernel.integral_comp_prod from "leanprover-community/mathlib"@"c0d694db494dd4f9aa57f2714b6e4c82b4ebc113" /-! # Bochner integral of a function against the composition-product of two kernels We prove properties of the composition-product of two kernels. If `κ` is an s-finite kernel from `α` to `β` and `η` is an s-finite kernel from `α × β` to `γ`, we can form their composition-product `κ ⊗ₖ η : kernel α (β × γ)`. We proved in `ProbabilityTheory.kernel.lintegral_compProd` that it verifies `∫⁻ bc, f bc ∂((κ ⊗ₖ η) a) = ∫⁻ b, ∫⁻ c, f (b, c) ∂(η (a, b)) ∂(κ a)`. In this file, we prove the same equality for the Bochner integral. ## Main statements * `ProbabilityTheory.integral_compProd`: the integral against the composition-product is `∫ z, f z ∂((κ ⊗ₖ η) a) = ∫ x, ∫ y, f (x, y) ∂(η (a, x)) ∂(κ a)` ## Implementation details This file is to a large extent a copy of part of `Mathlib/MeasureTheory/Constructions/Prod/Basic.lean`. The product of two measures is a particular case of composition-product of kernels and it turns out that once the measurablity of the Lebesgue integral of a kernel is proved, almost all proofs about integrals against products of measures extend with minimal modifications to the composition-product of two kernels. -/ noncomputable section open scoped Topology ENNReal MeasureTheory ProbabilityTheory open Set Function Real ENNReal MeasureTheory Filter ProbabilityTheory ProbabilityTheory.kernel variable {α β γ E : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} [NormedAddCommGroup E] {κ : kernel α β} [IsSFiniteKernel κ] {η : kernel (α × β) γ} [IsSFiniteKernel η] {a : α} namespace ProbabilityTheory
Mathlib/Probability/Kernel/IntegralCompProd.lean
48
61
theorem hasFiniteIntegral_prod_mk_left (a : α) {s : Set (β × γ)} (h2s : (κ ⊗ₖ η) a s ≠ ∞) : HasFiniteIntegral (fun b => (η (a, b) (Prod.mk b ⁻¹' s)).toReal) (κ a) := by
let t := toMeasurable ((κ ⊗ₖ η) a) s simp_rw [HasFiniteIntegral, ennnorm_eq_ofReal toReal_nonneg] calc ∫⁻ b, ENNReal.ofReal (η (a, b) (Prod.mk b ⁻¹' s)).toReal ∂κ a _ ≤ ∫⁻ b, η (a, b) (Prod.mk b ⁻¹' t) ∂κ a := by refine lintegral_mono_ae ?_ filter_upwards [ae_kernel_lt_top a h2s] with b hb rw [ofReal_toReal hb.ne] exact measure_mono (preimage_mono (subset_toMeasurable _ _)) _ ≤ (κ ⊗ₖ η) a t := le_compProd_apply _ _ _ _ _ = (κ ⊗ₖ η) a s := measure_toMeasurable s _ < ⊤ := h2s.lt_top
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Complex.Arg import Mathlib.Analysis.SpecialFunctions.Log.Basic #align_import analysis.special_functions.complex.log from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # The complex `log` function Basic properties, relationship with `exp`. -/ noncomputable section namespace Complex open Set Filter Bornology open scoped Real Topology ComplexConjugate /-- Inverse of the `exp` function. Returns values such that `(log x).im > - π` and `(log x).im ≤ π`. `log 0 = 0`-/ -- Porting note: @[pp_nodot] does not exist in mathlib4 noncomputable def log (x : ℂ) : ℂ := x.abs.log + arg x * I #align complex.log Complex.log theorem log_re (x : ℂ) : x.log.re = x.abs.log := by simp [log] #align complex.log_re Complex.log_re theorem log_im (x : ℂ) : x.log.im = x.arg := by simp [log] #align complex.log_im Complex.log_im theorem neg_pi_lt_log_im (x : ℂ) : -π < (log x).im := by simp only [log_im, neg_pi_lt_arg] #align complex.neg_pi_lt_log_im Complex.neg_pi_lt_log_im theorem log_im_le_pi (x : ℂ) : (log x).im ≤ π := by simp only [log_im, arg_le_pi] #align complex.log_im_le_pi Complex.log_im_le_pi theorem exp_log {x : ℂ} (hx : x ≠ 0) : exp (log x) = x := by rw [log, exp_add_mul_I, ← ofReal_sin, sin_arg, ← ofReal_cos, cos_arg hx, ← ofReal_exp, Real.exp_log (abs.pos hx), mul_add, ofReal_div, ofReal_div, mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), ← mul_assoc, mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), re_add_im] #align complex.exp_log Complex.exp_log @[simp] theorem range_exp : Set.range exp = {0}ᶜ := Set.ext fun x => ⟨by rintro ⟨x, rfl⟩ exact exp_ne_zero x, fun hx => ⟨log x, exp_log hx⟩⟩ #align complex.range_exp Complex.range_exp theorem log_exp {x : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) : log (exp x) = x := by rw [log, abs_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, ← ofReal_exp, arg_mul_cos_add_sin_mul_I (Real.exp_pos _) ⟨hx₁, hx₂⟩, re_add_im] #align complex.log_exp Complex.log_exp theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) (hy₁ : -π < y.im) (hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y := by rw [← log_exp hx₁ hx₂, ← log_exp hy₁ hy₂, hxy] #align complex.exp_inj_of_neg_pi_lt_of_le_pi Complex.exp_inj_of_neg_pi_lt_of_le_pi theorem ofReal_log {x : ℝ} (hx : 0 ≤ x) : (x.log : ℂ) = log x := Complex.ext (by rw [log_re, ofReal_re, abs_of_nonneg hx]) (by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx]) #align complex.of_real_log Complex.ofReal_log @[simp, norm_cast] lemma natCast_log {n : ℕ} : Real.log n = log n := ofReal_natCast n ▸ ofReal_log n.cast_nonneg @[simp] lemma ofNat_log {n : ℕ} [n.AtLeastTwo] : Real.log (no_index (OfNat.ofNat n)) = log (OfNat.ofNat n) := natCast_log
Mathlib/Analysis/SpecialFunctions/Complex/Log.lean
83
83
theorem log_ofReal_re (x : ℝ) : (log (x : ℂ)).re = Real.log x := by
simp [log_re]
/- Copyright (c) 2017 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura -/ import Mathlib.Init.Algebra.Classes import Mathlib.Init.Data.Ordering.Basic #align_import init.data.ordering.lemmas from "leanprover-community/lean"@"4bd314f7bd5e0c9e813fc201f1279a23f13f9f1d" /-! # Some `Ordering` lemmas -/ universe u namespace Ordering @[simp] theorem ite_eq_lt_distrib (c : Prop) [Decidable c] (a b : Ordering) : ((if c then a else b) = Ordering.lt) = if c then a = Ordering.lt else b = Ordering.lt := by by_cases c <;> simp [*] #align ordering.ite_eq_lt_distrib Ordering.ite_eq_lt_distrib @[simp] theorem ite_eq_eq_distrib (c : Prop) [Decidable c] (a b : Ordering) : ((if c then a else b) = Ordering.eq) = if c then a = Ordering.eq else b = Ordering.eq := by by_cases c <;> simp [*] #align ordering.ite_eq_eq_distrib Ordering.ite_eq_eq_distrib @[simp] theorem ite_eq_gt_distrib (c : Prop) [Decidable c] (a b : Ordering) : ((if c then a else b) = Ordering.gt) = if c then a = Ordering.gt else b = Ordering.gt := by by_cases c <;> simp [*] #align ordering.ite_eq_gt_distrib Ordering.ite_eq_gt_distrib end Ordering section variable {α : Type u} {lt : α → α → Prop} [DecidableRel lt] attribute [local simp] cmpUsing @[simp]
Mathlib/Init/Data/Ordering/Lemmas.lean
46
47
theorem cmpUsing_eq_lt (a b : α) : (cmpUsing lt a b = Ordering.lt) = lt a b := by
simp only [cmpUsing, Ordering.ite_eq_lt_distrib, ite_self, if_false_right, and_true]
/- Copyright (c) 2018 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad -/ import Mathlib.Order.CompleteLattice import Mathlib.Order.GaloisConnection import Mathlib.Data.Set.Lattice import Mathlib.Tactic.AdaptationNote #align_import data.rel from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2" /-! # Relations This file defines bundled relations. A relation between `α` and `β` is a function `α → β → Prop`. Relations are also known as set-valued functions, or partial multifunctions. ## Main declarations * `Rel α β`: Relation between `α` and `β`. * `Rel.inv`: `r.inv` is the `Rel β α` obtained by swapping the arguments of `r`. * `Rel.dom`: Domain of a relation. `x ∈ r.dom` iff there exists `y` such that `r x y`. * `Rel.codom`: Codomain, aka range, of a relation. `y ∈ r.codom` iff there exists `x` such that `r x y`. * `Rel.comp`: Relation composition. Note that the arguments order follows the `CategoryTheory/` one, so `r.comp s x z ↔ ∃ y, r x y ∧ s y z`. * `Rel.image`: Image of a set under a relation. `r.image s` is the set of `f x` over all `x ∈ s`. * `Rel.preimage`: Preimage of a set under a relation. Note that `r.preimage = r.inv.image`. * `Rel.core`: Core of a set. For `s : Set β`, `r.core s` is the set of `x : α` such that all `y` related to `x` are in `s`. * `Rel.restrict_domain`: Domain-restriction of a relation to a subtype. * `Function.graph`: Graph of a function as a relation. ## TODOs The `Rel.comp` function uses the notation `r • s`, rather than the more common `r ∘ s` for things named `comp`. This is because the latter is already used for function composition, and causes a clash. A better notation should be found, perhaps a variant of `r ∘r s` or `r; s`. -/ variable {α β γ : Type*} /-- A relation on `α` and `β`, aka a set-valued function, aka a partial multifunction -/ def Rel (α β : Type*) := α → β → Prop -- deriving CompleteLattice, Inhabited #align rel Rel -- Porting note: `deriving` above doesn't work. instance : CompleteLattice (Rel α β) := show CompleteLattice (α → β → Prop) from inferInstance instance : Inhabited (Rel α β) := show Inhabited (α → β → Prop) from inferInstance namespace Rel variable (r : Rel α β) -- Porting note: required for later theorems. @[ext] theorem ext {r s : Rel α β} : (∀ a, r a = s a) → r = s := funext /-- The inverse relation : `r.inv x y ↔ r y x`. Note that this is *not* a groupoid inverse. -/ def inv : Rel β α := flip r #align rel.inv Rel.inv theorem inv_def (x : α) (y : β) : r.inv y x ↔ r x y := Iff.rfl #align rel.inv_def Rel.inv_def theorem inv_inv : inv (inv r) = r := by ext x y rfl #align rel.inv_inv Rel.inv_inv /-- Domain of a relation -/ def dom := { x | ∃ y, r x y } #align rel.dom Rel.dom theorem dom_mono {r s : Rel α β} (h : r ≤ s) : dom r ⊆ dom s := fun a ⟨b, hx⟩ => ⟨b, h a b hx⟩ #align rel.dom_mono Rel.dom_mono /-- Codomain aka range of a relation -/ def codom := { y | ∃ x, r x y } #align rel.codom Rel.codom theorem codom_inv : r.inv.codom = r.dom := by ext x rfl #align rel.codom_inv Rel.codom_inv theorem dom_inv : r.inv.dom = r.codom := by ext x rfl #align rel.dom_inv Rel.dom_inv /-- Composition of relation; note that it follows the `CategoryTheory/` order of arguments. -/ def comp (r : Rel α β) (s : Rel β γ) : Rel α γ := fun x z => ∃ y, r x y ∧ s y z #align rel.comp Rel.comp -- Porting note: the original `∘` syntax can't be overloaded here, lean considers it ambiguous. /-- Local syntax for composition of relations. -/ local infixr:90 " • " => Rel.comp theorem comp_assoc {δ : Type*} (r : Rel α β) (s : Rel β γ) (t : Rel γ δ) : (r • s) • t = r • (s • t) := by unfold comp; ext (x w); constructor · rintro ⟨z, ⟨y, rxy, syz⟩, tzw⟩; exact ⟨y, rxy, z, syz, tzw⟩ · rintro ⟨y, rxy, z, syz, tzw⟩; exact ⟨z, ⟨y, rxy, syz⟩, tzw⟩ #align rel.comp_assoc Rel.comp_assoc @[simp] theorem comp_right_id (r : Rel α β) : r • @Eq β = r := by unfold comp ext y simp #align rel.comp_right_id Rel.comp_right_id @[simp] theorem comp_left_id (r : Rel α β) : @Eq α • r = r := by unfold comp ext x simp #align rel.comp_left_id Rel.comp_left_id @[simp] theorem comp_right_bot (r : Rel α β) : r • (⊥ : Rel β γ) = ⊥ := by ext x y simp [comp, Bot.bot] @[simp]
Mathlib/Data/Rel.lean
131
133
theorem comp_left_bot (r : Rel α β) : (⊥ : Rel γ α) • r = ⊥ := by
ext x y simp [comp, Bot.bot]
/- 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.BigOperators.Fin import Mathlib.Algebra.GeomSum import Mathlib.LinearAlgebra.Matrix.Block import Mathlib.LinearAlgebra.Matrix.Determinant.Basic import Mathlib.LinearAlgebra.Matrix.Nondegenerate #align_import linear_algebra.vandermonde from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Vandermonde matrix This file defines the `vandermonde` matrix and gives its determinant. ## Main definitions - `vandermonde v`: a square matrix with the `i, j`th entry equal to `v i ^ j`. ## Main results - `det_vandermonde`: `det (vandermonde v)` is the product of `v i - v j`, where `(i, j)` ranges over the unordered pairs. -/ variable {R : Type*} [CommRing R] open Equiv Finset open Matrix namespace Matrix /-- `vandermonde v` is the square matrix with `i`th row equal to `1, v i, v i ^ 2, v i ^ 3, ...`. -/ def vandermonde {n : ℕ} (v : Fin n → R) : Matrix (Fin n) (Fin n) R := fun i j => v i ^ (j : ℕ) #align matrix.vandermonde Matrix.vandermonde @[simp] theorem vandermonde_apply {n : ℕ} (v : Fin n → R) (i j) : vandermonde v i j = v i ^ (j : ℕ) := rfl #align matrix.vandermonde_apply Matrix.vandermonde_apply @[simp] theorem vandermonde_cons {n : ℕ} (v0 : R) (v : Fin n → R) : vandermonde (Fin.cons v0 v : Fin n.succ → R) = Fin.cons (fun (j : Fin n.succ) => v0 ^ (j : ℕ)) fun i => Fin.cons 1 fun j => v i * vandermonde v i j := by ext i j refine Fin.cases (by simp) (fun i => ?_) i refine Fin.cases (by simp) (fun j => ?_) j simp [pow_succ'] #align matrix.vandermonde_cons Matrix.vandermonde_cons theorem vandermonde_succ {n : ℕ} (v : Fin n.succ → R) : vandermonde v = Fin.cons (fun (j : Fin n.succ) => v 0 ^ (j : ℕ)) fun i => Fin.cons 1 fun j => v i.succ * vandermonde (Fin.tail v) i j := by conv_lhs => rw [← Fin.cons_self_tail v, vandermonde_cons] rfl #align matrix.vandermonde_succ Matrix.vandermonde_succ
Mathlib/LinearAlgebra/Vandermonde.lean
67
69
theorem vandermonde_mul_vandermonde_transpose {n : ℕ} (v w : Fin n → R) (i j) : (vandermonde v * (vandermonde w)ᵀ) i j = ∑ k : Fin n, (v i * w j) ^ (k : ℕ) := by
simp only [vandermonde_apply, Matrix.mul_apply, Matrix.transpose_apply, mul_pow]
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Order.Group.Int import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Algebra.Ring.Rat import Mathlib.Data.PNat.Defs #align_import data.rat.lemmas from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11" /-! # Further lemmas for the Rational Numbers -/ namespace Rat open Rat theorem num_dvd (a) {b : ℤ} (b0 : b ≠ 0) : (a /. b).num ∣ a := by cases' e : a /. b with n d h c rw [Rat.mk'_eq_divInt, divInt_eq_iff b0 (mod_cast h)] at e refine Int.natAbs_dvd.1 <| Int.dvd_natAbs.1 <| Int.natCast_dvd_natCast.2 <| c.dvd_of_dvd_mul_right ?_ have := congr_arg Int.natAbs e simp only [Int.natAbs_mul, Int.natAbs_ofNat] at this; simp [this] #align rat.num_dvd Rat.num_dvd theorem den_dvd (a b : ℤ) : ((a /. b).den : ℤ) ∣ b := by by_cases b0 : b = 0; · simp [b0] cases' e : a /. b with n d h c rw [mk'_eq_divInt, divInt_eq_iff b0 (ne_of_gt (Int.natCast_pos.2 (Nat.pos_of_ne_zero h)))] at e refine Int.dvd_natAbs.1 <| Int.natCast_dvd_natCast.2 <| c.symm.dvd_of_dvd_mul_left ?_ rw [← Int.natAbs_mul, ← Int.natCast_dvd_natCast, Int.dvd_natAbs, ← e]; simp #align rat.denom_dvd Rat.den_dvd theorem num_den_mk {q : ℚ} {n d : ℤ} (hd : d ≠ 0) (qdf : q = n /. d) : ∃ c : ℤ, n = c * q.num ∧ d = c * q.den := by obtain rfl | hn := eq_or_ne n 0 · simp [qdf] have : q.num * d = n * ↑q.den := by refine (divInt_eq_iff ?_ hd).mp ?_ · exact Int.natCast_ne_zero.mpr (Rat.den_nz _) · rwa [num_divInt_den] have hqdn : q.num ∣ n := by rw [qdf] exact Rat.num_dvd _ hd refine ⟨n / q.num, ?_, ?_⟩ · rw [Int.ediv_mul_cancel hqdn] · refine Int.eq_mul_div_of_mul_eq_mul_of_dvd_left ?_ hqdn this rw [qdf] exact Rat.num_ne_zero.2 ((divInt_ne_zero hd).mpr hn) #align rat.num_denom_mk Rat.num_den_mk #noalign rat.mk_pnat_num #noalign rat.mk_pnat_denom
Mathlib/Data/Rat/Lemmas.lean
62
68
theorem num_mk (n d : ℤ) : (n /. d).num = d.sign * n / n.gcd d := by
have (m : ℕ) : Int.natAbs (m + 1) = m + 1 := by rw [← Nat.cast_one, ← Nat.cast_add, Int.natAbs_cast] rcases d with ((_ | _) | _) <;> rw [← Int.div_eq_ediv_of_dvd] <;> simp [divInt, mkRat, Rat.normalize, Nat.succPNat, Int.sign, Int.gcd, Int.zero_ediv, Int.ofNat_dvd_left, Nat.gcd_dvd_left, this]
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen, Antoine Labelle -/ import Mathlib.LinearAlgebra.Contraction import Mathlib.LinearAlgebra.Matrix.Charpoly.Coeff #align_import linear_algebra.trace from "leanprover-community/mathlib"@"4cf7ca0e69e048b006674cf4499e5c7d296a89e0" /-! # Trace of a linear map This file defines the trace of a linear map. See also `LinearAlgebra/Matrix/Trace.lean` for the trace of a matrix. ## Tags linear_map, trace, diagonal -/ noncomputable section universe u v w namespace LinearMap open Matrix open FiniteDimensional open TensorProduct section variable (R : Type u) [CommSemiring R] {M : Type v} [AddCommMonoid M] [Module R M] variable {ι : Type w} [DecidableEq ι] [Fintype ι] variable {κ : Type*} [DecidableEq κ] [Fintype κ] variable (b : Basis ι R M) (c : Basis κ R M) /-- The trace of an endomorphism given a basis. -/ def traceAux : (M →ₗ[R] M) →ₗ[R] R := Matrix.traceLinearMap ι R R ∘ₗ ↑(LinearMap.toMatrix b b) #align linear_map.trace_aux LinearMap.traceAux -- Can't be `simp` because it would cause a loop. theorem traceAux_def (b : Basis ι R M) (f : M →ₗ[R] M) : traceAux R b f = Matrix.trace (LinearMap.toMatrix b b f) := rfl #align linear_map.trace_aux_def LinearMap.traceAux_def theorem traceAux_eq : traceAux R b = traceAux R c := LinearMap.ext fun f => calc Matrix.trace (LinearMap.toMatrix b b f) = Matrix.trace (LinearMap.toMatrix b b ((LinearMap.id.comp f).comp LinearMap.id)) := by rw [LinearMap.id_comp, LinearMap.comp_id] _ = Matrix.trace (LinearMap.toMatrix c b LinearMap.id * LinearMap.toMatrix c c f * LinearMap.toMatrix b c LinearMap.id) := by rw [LinearMap.toMatrix_comp _ c, LinearMap.toMatrix_comp _ c] _ = Matrix.trace (LinearMap.toMatrix c c f * LinearMap.toMatrix b c LinearMap.id * LinearMap.toMatrix c b LinearMap.id) := by rw [Matrix.mul_assoc, Matrix.trace_mul_comm] _ = Matrix.trace (LinearMap.toMatrix c c ((f.comp LinearMap.id).comp LinearMap.id)) := by rw [LinearMap.toMatrix_comp _ b, LinearMap.toMatrix_comp _ c] _ = Matrix.trace (LinearMap.toMatrix c c f) := by rw [LinearMap.comp_id, LinearMap.comp_id] #align linear_map.trace_aux_eq LinearMap.traceAux_eq open scoped Classical variable (M) /-- Trace of an endomorphism independent of basis. -/ def trace : (M →ₗ[R] M) →ₗ[R] R := if H : ∃ s : Finset M, Nonempty (Basis s R M) then traceAux R H.choose_spec.some else 0 #align linear_map.trace LinearMap.trace variable {M} /-- Auxiliary lemma for `trace_eq_matrix_trace`. -/
Mathlib/LinearAlgebra/Trace.lean
84
89
theorem trace_eq_matrix_trace_of_finset {s : Finset M} (b : Basis s R M) (f : M →ₗ[R] M) : trace R M f = Matrix.trace (LinearMap.toMatrix b b f) := by
have : ∃ s : Finset M, Nonempty (Basis s R M) := ⟨s, ⟨b⟩⟩ rw [trace, dif_pos this, ← traceAux_def] congr 1 apply traceAux_eq
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Group.Center import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of rings -/ variable {M : Type*} namespace Set variable (M) @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_natCast, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_natCast, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_natCast, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[simp]
Mathlib/Algebra/Ring/Center.lean
72
77
theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by
rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Bhavik Mehta, Stuart Presnell -/ import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Order.Monotone.Basic #align_import data.nat.choose.basic from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4" /-! # Binomial coefficients This file defines binomial coefficients and proves simple lemmas (i.e. those not requiring more imports). ## Main definition and results * `Nat.choose`: binomial coefficients, defined inductively * `Nat.choose_eq_factorial_div_factorial`: a proof that `choose n k = n! / (k! * (n - k)!)` * `Nat.choose_symm`: symmetry of binomial coefficients * `Nat.choose_le_succ_of_lt_half_left`: `choose n k` is increasing for small values of `k` * `Nat.choose_le_middle`: `choose n r` is maximised when `r` is `n/2` * `Nat.descFactorial_eq_factorial_mul_choose`: Relates binomial coefficients to the descending factorial. This is used to prove `Nat.choose_le_pow` and variants. We provide similar statements for the ascending factorial. * `Nat.multichoose`: whereas `choose` counts combinations, `multichoose` counts multicombinations. The fact that this is indeed the correct counting function for multisets is proved in `Sym.card_sym_eq_multichoose` in `Data.Sym.Card`. * `Nat.multichoose_eq` : a proof that `multichoose n k = (n + k - 1).choose k`. This is central to the "stars and bars" technique in informal mathematics, where we switch between counting multisets of size `k` over an alphabet of size `n` to counting strings of `k` elements ("stars") separated by `n-1` dividers ("bars"). See `Data.Sym.Card` for more detail. ## Tags binomial coefficient, combination, multicombination, stars and bars -/ open Nat namespace Nat /-- `choose n k` is the number of `k`-element subsets in an `n`-element set. Also known as binomial coefficients. -/ def choose : ℕ → ℕ → ℕ | _, 0 => 1 | 0, _ + 1 => 0 | n + 1, k + 1 => choose n k + choose n (k + 1) #align nat.choose Nat.choose @[simp]
Mathlib/Data/Nat/Choose/Basic.lean
54
54
theorem choose_zero_right (n : ℕ) : choose n 0 = 1 := by
cases n <;> rfl
/- Copyright (c) 2021 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot -/ import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Order.OrderClosed #align_import topology.algebra.with_zero_topology from "leanprover-community/mathlib"@"3e0c4d76b6ebe9dfafb67d16f7286d2731ed6064" /-! # The topology on linearly ordered commutative groups with zero Let `Γ₀` be a linearly ordered commutative group to which we have adjoined a zero element. Then `Γ₀` may naturally be endowed with a topology that turns `Γ₀` into a topological monoid. Neighborhoods of zero are sets containing `{ γ | γ < γ₀ }` for some invertible element `γ₀` and every invertible element is open. In particular the topology is the following: "a subset `U ⊆ Γ₀` is open if `0 ∉ U` or if there is an invertible `γ₀ ∈ Γ₀` such that `{ γ | γ < γ₀ } ⊆ U`", see `WithZeroTopology.isOpen_iff`. We prove this topology is ordered and T₅ (in addition to be compatible with the monoid structure). All this is useful to extend a valuation to a completion. This is an abstract version of how the absolute value (resp. `p`-adic absolute value) on `ℚ` is extended to `ℝ` (resp. `ℚₚ`). ## Implementation notes This topology is defined as a scoped instance since it may not be the desired topology on a linearly ordered commutative group with zero. You can locally activate this topology using `open WithZeroTopology`. -/ open Topology Filter TopologicalSpace Filter Set Function namespace WithZeroTopology variable {α Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] {γ γ₁ γ₂ : Γ₀} {l : Filter α} {f : α → Γ₀} /-- The topology on a linearly ordered commutative group with a zero element adjoined. A subset U is open if 0 ∉ U or if there is an invertible element γ₀ such that {γ | γ < γ₀} ⊆ U. -/ scoped instance (priority := 100) topologicalSpace : TopologicalSpace Γ₀ := nhdsAdjoint 0 <| ⨅ γ ≠ 0, 𝓟 (Iio γ) #align with_zero_topology.topological_space WithZeroTopology.topologicalSpace theorem nhds_eq_update : (𝓝 : Γ₀ → Filter Γ₀) = update pure 0 (⨅ γ ≠ 0, 𝓟 (Iio γ)) := by rw [nhds_nhdsAdjoint, sup_of_le_right] exact le_iInf₂ fun γ hγ ↦ le_principal_iff.2 <| zero_lt_iff.2 hγ #align with_zero_topology.nhds_eq_update WithZeroTopology.nhds_eq_update /-! ### Neighbourhoods of zero -/
Mathlib/Topology/Algebra/WithZeroTopology.lean
56
57
theorem nhds_zero : 𝓝 (0 : Γ₀) = ⨅ γ ≠ 0, 𝓟 (Iio γ) := by
rw [nhds_eq_update, update_same]
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Analysis.SpecialFunctions.Bernstein import Mathlib.Topology.Algebra.Algebra #align_import topology.continuous_function.weierstrass from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" /-! # The Weierstrass approximation theorem for continuous functions on `[a,b]` We've already proved the Weierstrass approximation theorem in the sense that we've shown that the Bernstein approximations to a continuous function on `[0,1]` converge uniformly. Here we rephrase this more abstractly as `polynomialFunctions_closure_eq_top' : (polynomialFunctions I).topologicalClosure = ⊤` and then, by precomposing with suitable affine functions, `polynomialFunctions_closure_eq_top : (polynomialFunctions (Set.Icc a b)).topologicalClosure = ⊤` -/ open ContinuousMap Filter open scoped unitInterval /-- The special case of the Weierstrass approximation theorem for the interval `[0,1]`. This is just a matter of unravelling definitions and using the Bernstein approximations. -/ theorem polynomialFunctions_closure_eq_top' : (polynomialFunctions I).topologicalClosure = ⊤ := by rw [eq_top_iff] rintro f - refine Filter.Frequently.mem_closure ?_ refine Filter.Tendsto.frequently (bernsteinApproximation_uniform f) ?_ apply frequently_of_forall intro n simp only [SetLike.mem_coe] apply Subalgebra.sum_mem rintro n - apply Subalgebra.smul_mem dsimp [bernstein, polynomialFunctions] simp #align polynomial_functions_closure_eq_top' polynomialFunctions_closure_eq_top' /-- The **Weierstrass Approximation Theorem**: polynomials functions on `[a, b] ⊆ ℝ` are dense in `C([a,b],ℝ)` (While we could deduce this as an application of the Stone-Weierstrass theorem, our proof of that relies on the fact that `abs` is in the closure of polynomials on `[-M, M]`, so we may as well get this done first.) -/ theorem polynomialFunctions_closure_eq_top (a b : ℝ) : (polynomialFunctions (Set.Icc a b)).topologicalClosure = ⊤ := by cases' lt_or_le a b with h h -- (Otherwise it's easy; we'll deal with that later.) · -- We can pullback continuous functions on `[a,b]` to continuous functions on `[0,1]`, -- by precomposing with an affine map. let W : C(Set.Icc a b, ℝ) →ₐ[ℝ] C(I, ℝ) := compRightAlgHom ℝ ℝ (iccHomeoI a b h).symm.toContinuousMap -- This operation is itself a homeomorphism -- (with respect to the norm topologies on continuous functions). let W' : C(Set.Icc a b, ℝ) ≃ₜ C(I, ℝ) := compRightHomeomorph ℝ (iccHomeoI a b h).symm have w : (W : C(Set.Icc a b, ℝ) → C(I, ℝ)) = W' := rfl -- Thus we take the statement of the Weierstrass approximation theorem for `[0,1]`, have p := polynomialFunctions_closure_eq_top' -- and pullback both sides, obtaining an equation between subalgebras of `C([a,b], ℝ)`. apply_fun fun s => s.comap W at p simp only [Algebra.comap_top] at p -- Since the pullback operation is continuous, it commutes with taking `topologicalClosure`, rw [Subalgebra.topologicalClosure_comap_homeomorph _ W W' w] at p -- and precomposing with an affine map takes polynomial functions to polynomial functions. rw [polynomialFunctions.comap_compRightAlgHom_iccHomeoI] at p -- 🎉 exact p · -- Otherwise, `b ≤ a`, and the interval is a subsingleton, have : Subsingleton (Set.Icc a b) := (Set.subsingleton_Icc_of_ge h).coe_sort apply Subsingleton.elim #align polynomial_functions_closure_eq_top polynomialFunctions_closure_eq_top /-- An alternative statement of Weierstrass' theorem. Every real-valued continuous function on `[a,b]` is a uniform limit of polynomials. -/ theorem continuousMap_mem_polynomialFunctions_closure (a b : ℝ) (f : C(Set.Icc a b, ℝ)) : f ∈ (polynomialFunctions (Set.Icc a b)).topologicalClosure := by rw [polynomialFunctions_closure_eq_top _ _] simp #align continuous_map_mem_polynomial_functions_closure continuousMap_mem_polynomialFunctions_closure open scoped Polynomial /-- An alternative statement of Weierstrass' theorem, for those who like their epsilons. Every real-valued continuous function on `[a,b]` is within any `ε > 0` of some polynomial. -/ theorem exists_polynomial_near_continuousMap (a b : ℝ) (f : C(Set.Icc a b, ℝ)) (ε : ℝ) (pos : 0 < ε) : ∃ p : ℝ[X], ‖p.toContinuousMapOn _ - f‖ < ε := by have w := mem_closure_iff_frequently.mp (continuousMap_mem_polynomialFunctions_closure _ _ f) rw [Metric.nhds_basis_ball.frequently_iff] at w obtain ⟨-, H, ⟨m, ⟨-, rfl⟩⟩⟩ := w ε pos rw [Metric.mem_ball, dist_eq_norm] at H exact ⟨m, H⟩ #align exists_polynomial_near_continuous_map exists_polynomial_near_continuousMap /-- Another alternative statement of Weierstrass's theorem, for those who like epsilons, but not bundled continuous functions. Every real-valued function `ℝ → ℝ` which is continuous on `[a,b]` can be approximated to within any `ε > 0` on `[a,b]` by some polynomial. -/
Mathlib/Topology/ContinuousFunction/Weierstrass.lean
114
122
theorem exists_polynomial_near_of_continuousOn (a b : ℝ) (f : ℝ → ℝ) (c : ContinuousOn f (Set.Icc a b)) (ε : ℝ) (pos : 0 < ε) : ∃ p : ℝ[X], ∀ x ∈ Set.Icc a b, |p.eval x - f x| < ε := by
let f' : C(Set.Icc a b, ℝ) := ⟨fun x => f x, continuousOn_iff_continuous_restrict.mp c⟩ obtain ⟨p, b⟩ := exists_polynomial_near_continuousMap a b f' ε pos use p rw [norm_lt_iff _ pos] at b intro x m exact b ⟨x, m⟩
/- 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.Algebra.CharP.Invertible import Mathlib.Algebra.Order.Interval.Set.Group import Mathlib.Analysis.Convex.Segment import Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional import Mathlib.Tactic.FieldSimp #align_import analysis.convex.between from "leanprover-community/mathlib"@"571e13cacbed7bf042fd3058ce27157101433842" /-! # Betweenness in affine spaces This file defines notions of a point in an affine space being between two given points. ## Main definitions * `affineSegment R x y`: The segment of points weakly between `x` and `y`. * `Wbtw R x y z`: The point `y` is weakly between `x` and `z`. * `Sbtw R x y z`: The point `y` is strictly between `x` and `z`. -/ variable (R : Type*) {V V' P P' : Type*} open AffineEquiv AffineMap section OrderedRing variable [OrderedRing R] [AddCommGroup V] [Module R V] [AddTorsor V P] variable [AddCommGroup V'] [Module R V'] [AddTorsor V' P'] /-- The segment of points weakly between `x` and `y`. When convexity is refactored to support abstract affine combination spaces, this will no longer need to be a separate definition from `segment`. However, lemmas involving `+ᵥ` or `-ᵥ` will still be relevant after such a refactoring, as distinct from versions involving `+` or `-` in a module. -/ def affineSegment (x y : P) := lineMap x y '' Set.Icc (0 : R) 1 #align affine_segment affineSegment theorem affineSegment_eq_segment (x y : V) : affineSegment R x y = segment R x y := by rw [segment_eq_image_lineMap, affineSegment] #align affine_segment_eq_segment affineSegment_eq_segment
Mathlib/Analysis/Convex/Between.lean
49
55
theorem affineSegment_comm (x y : P) : affineSegment R x y = affineSegment R y x := by
refine Set.ext fun z => ?_ constructor <;> · rintro ⟨t, ht, hxy⟩ refine ⟨1 - t, ?_, ?_⟩ · rwa [Set.sub_mem_Icc_iff_right, sub_self, sub_zero] · rwa [lineMap_apply_one_sub]
/- 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.MeasureTheory.Constructions.Pi import Mathlib.MeasureTheory.Constructions.Prod.Integral /-! # Integration with respect to a finite product of measures On a finite product of measure spaces, we show that a product of integrable functions each depending on a single coordinate is integrable, in `MeasureTheory.integrable_fintype_prod`, and that its integral is the product of the individual integrals, in `MeasureTheory.integral_fintype_prod_eq_prod`. -/ open Fintype MeasureTheory MeasureTheory.Measure variable {𝕜 : Type*} [RCLike 𝕜] namespace MeasureTheory /-- On a finite product space in `n` variables, for a natural number `n`, a product of integrable functions depending on each coordinate is integrable. -/ theorem Integrable.fin_nat_prod {n : ℕ} {E : Fin n → Type*} [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))] {f : (i : Fin n) → E i → 𝕜} (hf : ∀ i, Integrable (f i)) : Integrable (fun (x : (i : Fin n) → E i) ↦ ∏ i, f i (x i)) := by induction n with | zero => simp only [Nat.zero_eq, Finset.univ_eq_empty, Finset.prod_empty, volume_pi, integrable_const_iff, one_ne_zero, pi_empty_univ, ENNReal.one_lt_top, or_true] | succ n n_ih => have := ((measurePreserving_piFinSuccAbove (fun i => (volume : Measure (E i))) 0).symm) rw [volume_pi, ← this.integrable_comp_emb (MeasurableEquiv.measurableEmbedding _)] simp_rw [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.prod_univ_succ, Fin.insertNth_zero] simp only [Fin.zero_succAbove, cast_eq, Function.comp_def, Fin.cons_zero, Fin.cons_succ] have : Integrable (fun (x : (j : Fin n) → E (Fin.succ j)) ↦ ∏ j, f (Fin.succ j) (x j)) := n_ih (fun i ↦ hf _) exact Integrable.prod_mul (hf 0) this /-- On a finite product space, a product of integrable functions depending on each coordinate is integrable. Version with dependent target. -/ theorem Integrable.fintype_prod_dep {ι : Type*} [Fintype ι] {E : ι → Type*} {f : (i : ι) → E i → 𝕜} [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))] (hf : ∀ i, Integrable (f i)) : Integrable (fun (x : (i : ι) → E i) ↦ ∏ i, f i (x i)) := by let e := (equivFin ι).symm simp_rw [← (volume_measurePreserving_piCongrLeft _ e).integrable_comp_emb (MeasurableEquiv.measurableEmbedding _), ← e.prod_comp, MeasurableEquiv.coe_piCongrLeft, Function.comp_def, Equiv.piCongrLeft_apply_apply] exact .fin_nat_prod (fun i ↦ hf _) /-- On a finite product space, a product of integrable functions depending on each coordinate is integrable. -/ theorem Integrable.fintype_prod {ι : Type*} [Fintype ι] {E : Type*} {f : ι → E → 𝕜} [MeasureSpace E] [SigmaFinite (volume : Measure E)] (hf : ∀ i, Integrable (f i)) : Integrable (fun (x : ι → E) ↦ ∏ i, f i (x i)) := Integrable.fintype_prod_dep hf /-- A version of **Fubini's theorem** in `n` variables, for a natural number `n`. -/
Mathlib/MeasureTheory/Integral/Pi.lean
65
84
theorem integral_fin_nat_prod_eq_prod {n : ℕ} {E : Fin n → Type*} [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))] (f : (i : Fin n) → E i → 𝕜) : ∫ x : (i : Fin n) → E i, ∏ i, f i (x i) = ∏ i, ∫ x, f i x := by
induction n with | zero => simp only [Nat.zero_eq, volume_pi, Finset.univ_eq_empty, Finset.prod_empty, integral_const, pi_empty_univ, ENNReal.one_toReal, smul_eq_mul, mul_one, pow_zero, one_smul] | succ n n_ih => calc _ = ∫ x : E 0 × ((i : Fin n) → E (Fin.succ i)), f 0 x.1 * ∏ i : Fin n, f (Fin.succ i) (x.2 i) := by rw [volume_pi, ← ((measurePreserving_piFinSuccAbove (fun i => (volume : Measure (E i))) 0).symm).integral_comp'] simp_rw [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.prod_univ_succ, Fin.insertNth_zero, Fin.cons_succ, volume_eq_prod, volume_pi, Fin.zero_succAbove, cast_eq, Fin.cons_zero] _ = (∫ x, f 0 x) * ∏ i : Fin n, ∫ (x : E (Fin.succ i)), f (Fin.succ i) x := by rw [← n_ih, ← integral_prod_mul, volume_eq_prod] _ = ∏ i, ∫ x, f i x := by rw [Fin.prod_univ_succ]
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou -/ import Mathlib.MeasureTheory.Function.LpOrder #align_import measure_theory.function.l1_space from "leanprover-community/mathlib"@"ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f" /-! # Integrable functions and `L¹` space In the first part of this file, the predicate `Integrable` is defined and basic properties of integrable functions are proved. Such a predicate is already available under the name `Memℒp 1`. We give a direct definition which is easier to use, and show that it is equivalent to `Memℒp 1` In the second part, we establish an API between `Integrable` and the space `L¹` of equivalence classes of integrable functions, already defined as a special case of `L^p` spaces for `p = 1`. ## Notation * `α →₁[μ] β` is the type of `L¹` space, where `α` is a `MeasureSpace` and `β` is a `NormedAddCommGroup` with a `SecondCountableTopology`. `f : α →ₘ β` is a "function" in `L¹`. In comments, `[f]` is also used to denote an `L¹` function. `₁` can be typed as `\1`. ## Main definitions * Let `f : α → β` be a function, where `α` is a `MeasureSpace` and `β` a `NormedAddCommGroup`. Then `HasFiniteIntegral f` means `(∫⁻ a, ‖f a‖₊) < ∞`. * If `β` is moreover a `MeasurableSpace` then `f` is called `Integrable` if `f` is `Measurable` and `HasFiniteIntegral f` holds. ## Implementation notes To prove something for an arbitrary integrable function, a useful theorem is `Integrable.induction` in the file `SetIntegral`. ## Tags integrable, function space, l1 -/ noncomputable section open scoped Classical open Topology ENNReal MeasureTheory NNReal open Set Filter TopologicalSpace ENNReal EMetric MeasureTheory variable {α β γ δ : Type*} {m : MeasurableSpace α} {μ ν : Measure α} [MeasurableSpace δ] variable [NormedAddCommGroup β] variable [NormedAddCommGroup γ] namespace MeasureTheory /-! ### Some results about the Lebesgue integral involving a normed group -/ theorem lintegral_nnnorm_eq_lintegral_edist (f : α → β) : ∫⁻ a, ‖f a‖₊ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [edist_eq_coe_nnnorm] #align measure_theory.lintegral_nnnorm_eq_lintegral_edist MeasureTheory.lintegral_nnnorm_eq_lintegral_edist theorem lintegral_norm_eq_lintegral_edist (f : α → β) : ∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [ofReal_norm_eq_coe_nnnorm, edist_eq_coe_nnnorm] #align measure_theory.lintegral_norm_eq_lintegral_edist MeasureTheory.lintegral_norm_eq_lintegral_edist
Mathlib/MeasureTheory/Function/L1Space.lean
75
80
theorem lintegral_edist_triangle {f g h : α → β} (hf : AEStronglyMeasurable f μ) (hh : AEStronglyMeasurable h μ) : (∫⁻ a, edist (f a) (g a) ∂μ) ≤ (∫⁻ a, edist (f a) (h a) ∂μ) + ∫⁻ a, edist (g a) (h a) ∂μ := by
rw [← lintegral_add_left' (hf.edist hh)] refine lintegral_mono fun a => ?_ apply edist_triangle_right
/- Copyright (c) 2023 Luke Mantle. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Luke Mantle -/ import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Factorial.DoubleFactorial #align_import ring_theory.polynomial.hermite.basic from "leanprover-community/mathlib"@"938d3db9c278f8a52c0f964a405806f0f2b09b74" /-! # Hermite polynomials This file defines `Polynomial.hermite n`, the `n`th probabilists' Hermite polynomial. ## Main definitions * `Polynomial.hermite n`: the `n`th probabilists' Hermite polynomial, defined recursively as a `Polynomial ℤ` ## Results * `Polynomial.hermite_succ`: the recursion `hermite (n+1) = (x - d/dx) (hermite n)` * `Polynomial.coeff_hermite_explicit`: a closed formula for (nonvanishing) coefficients in terms of binomial coefficients and double factorials. * `Polynomial.coeff_hermite_of_odd_add`: for `n`,`k` where `n+k` is odd, `(hermite n).coeff k` is zero. * `Polynomial.coeff_hermite_of_even_add`: a closed formula for `(hermite n).coeff k` when `n+k` is even, equivalent to `Polynomial.coeff_hermite_explicit`. * `Polynomial.monic_hermite`: for all `n`, `hermite n` is monic. * `Polynomial.degree_hermite`: for all `n`, `hermite n` has degree `n`. ## References * [Hermite Polynomials](https://en.wikipedia.org/wiki/Hermite_polynomials) -/ noncomputable section open Polynomial namespace Polynomial /-- the probabilists' Hermite polynomials. -/ noncomputable def hermite : ℕ → Polynomial ℤ | 0 => 1 | n + 1 => X * hermite n - derivative (hermite n) #align polynomial.hermite Polynomial.hermite /-- The recursion `hermite (n+1) = (x - d/dx) (hermite n)` -/ @[simp] theorem hermite_succ (n : ℕ) : hermite (n + 1) = X * hermite n - derivative (hermite n) := by rw [hermite] #align polynomial.hermite_succ Polynomial.hermite_succ theorem hermite_eq_iterate (n : ℕ) : hermite n = (fun p => X * p - derivative p)^[n] 1 := by induction' n with n ih · rfl · rw [Function.iterate_succ_apply', ← ih, hermite_succ] #align polynomial.hermite_eq_iterate Polynomial.hermite_eq_iterate @[simp] theorem hermite_zero : hermite 0 = C 1 := rfl #align polynomial.hermite_zero Polynomial.hermite_zero -- Porting note (#10618): There was initially @[simp] on this line but it was removed -- because simp can prove this theorem theorem hermite_one : hermite 1 = X := by rw [hermite_succ, hermite_zero] simp only [map_one, mul_one, derivative_one, sub_zero] #align polynomial.hermite_one Polynomial.hermite_one /-! ### Lemmas about `Polynomial.coeff` -/ section coeff theorem coeff_hermite_succ_zero (n : ℕ) : coeff (hermite (n + 1)) 0 = -coeff (hermite n) 1 := by simp [coeff_derivative] #align polynomial.coeff_hermite_succ_zero Polynomial.coeff_hermite_succ_zero
Mathlib/RingTheory/Polynomial/Hermite/Basic.lean
86
89
theorem coeff_hermite_succ_succ (n k : ℕ) : coeff (hermite (n + 1)) (k + 1) = coeff (hermite n) k - (k + 2) * coeff (hermite n) (k + 2) := by
rw [hermite_succ, coeff_sub, coeff_X_mul, coeff_derivative, mul_comm] norm_cast
/- 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)
Mathlib/RingTheory/Polynomial/Chebyshev.lean
93
94
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)
/- 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
Mathlib/Init/Order/LinearOrder.lean
47
51
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₂
/- Copyright (c) 2022 Antoine Labelle. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Labelle -/ import Mathlib.Algebra.Group.Equiv.TypeTags import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Module.LinearMap.Basic import Mathlib.Algebra.MonoidAlgebra.Basic import Mathlib.LinearAlgebra.Dual import Mathlib.LinearAlgebra.Contraction import Mathlib.RingTheory.TensorProduct.Basic #align_import representation_theory.basic from "leanprover-community/mathlib"@"c04bc6e93e23aa0182aba53661a2211e80b6feac" /-! # Monoid representations This file introduces monoid representations and their characters and defines a few ways to construct representations. ## Main definitions * Representation.Representation * Representation.character * Representation.tprod * Representation.linHom * Representation.dual ## Implementation notes Representations of a monoid `G` on a `k`-module `V` are implemented as homomorphisms `G →* (V →ₗ[k] V)`. We use the abbreviation `Representation` for this hom space. The theorem `asAlgebraHom_def` constructs a module over the group `k`-algebra of `G` (implemented as `MonoidAlgebra k G`) corresponding to a representation. If `ρ : Representation k G V`, this module can be accessed via `ρ.asModule`. Conversely, given a `MonoidAlgebra k G-module `M` `M.ofModule` is the associociated representation seen as a homomorphism. -/ open MonoidAlgebra (lift of) open LinearMap section variable (k G V : Type*) [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V] /-- A representation of `G` on the `k`-module `V` is a homomorphism `G →* (V →ₗ[k] V)`. -/ abbrev Representation := G →* V →ₗ[k] V #align representation Representation end namespace Representation section trivial variable (k : Type*) {G V : Type*} [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V] /-- The trivial representation of `G` on a `k`-module V. -/ def trivial : Representation k G V := 1 #align representation.trivial Representation.trivial -- Porting note: why is `V` implicit theorem trivial_def (g : G) (v : V) : trivial k (V := V) g v = v := rfl #align representation.trivial_def Representation.trivial_def variable {k} /-- A predicate for representations that fix every element. -/ class IsTrivial (ρ : Representation k G V) : Prop where out : ∀ g x, ρ g x = x := by aesop instance : IsTrivial (trivial k (G := G) (V := V)) where @[simp] theorem apply_eq_self (ρ : Representation k G V) (g : G) (x : V) [h : IsTrivial ρ] : ρ g x = x := h.out g x end trivial section MonoidAlgebra variable {k G V : Type*} [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V] variable (ρ : Representation k G V) /-- A `k`-linear representation of `G` on `V` can be thought of as an algebra map from `MonoidAlgebra k G` into the `k`-linear endomorphisms of `V`. -/ noncomputable def asAlgebraHom : MonoidAlgebra k G →ₐ[k] Module.End k V := (lift k G _) ρ #align representation.as_algebra_hom Representation.asAlgebraHom theorem asAlgebraHom_def : asAlgebraHom ρ = (lift k G _) ρ := rfl #align representation.as_algebra_hom_def Representation.asAlgebraHom_def @[simp]
Mathlib/RepresentationTheory/Basic.lean
106
107
theorem asAlgebraHom_single (g : G) (r : k) : asAlgebraHom ρ (Finsupp.single g r) = r • ρ g := by
simp only [asAlgebraHom_def, MonoidAlgebra.lift_single]
/- Copyright (c) 2022 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca, Eric Rodriguez -/ import Mathlib.NumberTheory.NumberField.Basic import Mathlib.RingTheory.Localization.NormTrace #align_import number_theory.number_field.norm from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a" /-! # Norm in number fields Given a finite extension of number fields, we define the norm morphism as a function between the rings of integers. ## Main definitions * `RingOfIntegers.norm K` : `Algebra.norm` as a morphism `(𝓞 L) →* (𝓞 K)`. ## Main results * `RingOfIntegers.dvd_norm` : if `L/K` is a finite Galois extension of fields, then, for all `(x : 𝓞 L)` we have that `x ∣ algebraMap (𝓞 K) (𝓞 L) (norm K x)`. -/ open scoped NumberField open Finset NumberField Algebra FiniteDimensional section Rat variable {K : Type*} [Field K] [NumberField K] (x : 𝓞 K) theorem Algebra.coe_norm_int : (Algebra.norm ℤ x : ℚ) = Algebra.norm ℚ (x : K) := (Algebra.norm_localization (R := ℤ) (Rₘ := ℚ) (S := 𝓞 K) (Sₘ := K) (nonZeroDivisors ℤ) x).symm theorem Algebra.coe_trace_int : (Algebra.trace ℤ _ x : ℚ) = Algebra.trace ℚ K (x : K) := (Algebra.trace_localization (R := ℤ) (Rₘ := ℚ) (S := 𝓞 K) (Sₘ := K) (nonZeroDivisors ℤ) x).symm end Rat namespace RingOfIntegers variable {L : Type*} (K : Type*) [Field K] [Field L] [Algebra K L] [FiniteDimensional K L] /-- `Algebra.norm` as a morphism betwen the rings of integers. -/ noncomputable def norm [IsSeparable K L] : 𝓞 L →* 𝓞 K := RingOfIntegers.restrict_monoidHom ((Algebra.norm K).comp (algebraMap (𝓞 L) L : (𝓞 L) →* L)) fun x => isIntegral_norm K x.2 #align ring_of_integers.norm RingOfIntegers.norm @[simp] lemma coe_norm [IsSeparable K L] (x : 𝓞 L) : norm K x = Algebra.norm K (x : L) := rfl theorem coe_algebraMap_norm [IsSeparable K L] (x : 𝓞 L) : (algebraMap (𝓞 K) (𝓞 L) (norm K x) : L) = algebraMap K L (Algebra.norm K (x : L)) := rfl #align ring_of_integers.coe_algebra_map_norm RingOfIntegers.coe_algebraMap_norm theorem algebraMap_norm_algebraMap [IsSeparable K L] (x : 𝓞 K) : algebraMap _ K (norm K (algebraMap (𝓞 K) (𝓞 L) x)) = Algebra.norm K (algebraMap K L (algebraMap _ _ x)) := rfl #align ring_of_integers.coe_norm_algebra_map RingOfIntegers.algebraMap_norm_algebraMap
Mathlib/NumberTheory/NumberField/Norm.lean
65
69
theorem norm_algebraMap [IsSeparable K L] (x : 𝓞 K) : norm K (algebraMap (𝓞 K) (𝓞 L) x) = x ^ finrank K L := by
rw [RingOfIntegers.ext_iff, RingOfIntegers.coe_eq_algebraMap, RingOfIntegers.algebraMap_norm_algebraMap, Algebra.norm_algebraMap, RingOfIntegers.coe_eq_algebraMap, map_pow]
/- Copyright (c) 2023 Josha Dekker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Josha Dekker -/ import Mathlib.Topology.Bases import Mathlib.Order.Filter.CountableInter import Mathlib.Topology.Compactness.SigmaCompact /-! # Lindelöf sets and Lindelöf spaces ## Main definitions We define the following properties for sets in a topological space: * `IsLindelof s`: Two definitions are possible here. The more standard definition is that every open cover that contains `s` contains a countable subcover. We choose for the equivalent definition where we require that every nontrivial filter on `s` with the countable intersection property has a clusterpoint. Equivalence is established in `isLindelof_iff_countable_subcover`. * `LindelofSpace X`: `X` is Lindelöf if it is Lindelöf as a set. * `NonLindelofSpace`: a space that is not a Lindëlof space, e.g. the Long Line. ## Main results * `isLindelof_iff_countable_subcover`: A set is Lindelöf iff every open cover has a countable subcover. ## Implementation details * This API is mainly based on the API for IsCompact and follows notation and style as much as possible. -/ open Set Filter Topology TopologicalSpace universe u v variable {X : Type u} {Y : Type v} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} section Lindelof /-- A set `s` is Lindelöf if every nontrivial filter `f` with the countable intersection property that contains `s`, has a clusterpoint in `s`. The filter-free definition is given by `isLindelof_iff_countable_subcover`. -/ def IsLindelof (s : Set X) := ∀ ⦃f⦄ [NeBot f] [CountableInterFilter f], f ≤ 𝓟 s → ∃ x ∈ s, ClusterPt x f /-- The complement to a Lindelöf set belongs to a filter `f` with the countable intersection property if it belongs to each filter `𝓝 x ⊓ f`, `x ∈ s`. -/ theorem IsLindelof.compl_mem_sets (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f] (hf : ∀ x ∈ s, sᶜ ∈ 𝓝 x ⊓ f) : sᶜ ∈ f := by contrapose! hf simp only [not_mem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf ⊢ exact hs inf_le_right /-- The complement to a Lindelöf set belongs to a filter `f` with the countable intersection property if each `x ∈ s` has a neighborhood `t` within `s` such that `tᶜ` belongs to `f`. -/ theorem IsLindelof.compl_mem_sets_of_nhdsWithin (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f] (hf : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, tᶜ ∈ f) : sᶜ ∈ f := by refine hs.compl_mem_sets fun x hx ↦ ?_ rw [← disjoint_principal_right, disjoint_right_comm, (basis_sets _).disjoint_iff_left] exact hf x hx /-- If `p : Set X → Prop` is stable under restriction and union, and each point `x` of a Lindelöf set `s` has a neighborhood `t` within `s` such that `p t`, then `p s` holds. -/ @[elab_as_elim] theorem IsLindelof.induction_on (hs : IsLindelof s) {p : Set X → Prop} (hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s) (hcountable_union : ∀ (S : Set (Set X)), S.Countable → (∀ s ∈ S, p s) → p (⋃₀ S)) (hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by let f : Filter X := ofCountableUnion p hcountable_union (fun t ht _ hsub ↦ hmono hsub ht) have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds) rwa [← compl_compl s] /-- The intersection of a Lindelöf set and a closed set is a Lindelöf set. -/
Mathlib/Topology/Compactness/Lindelof.lean
78
83
theorem IsLindelof.inter_right (hs : IsLindelof s) (ht : IsClosed t) : IsLindelof (s ∩ t) := by
intro f hnf _ hstf rw [← inf_principal, le_inf_iff] at hstf obtain ⟨x, hsx, hx⟩ : ∃ x ∈ s, ClusterPt x f := hs hstf.1 have hxt : x ∈ t := ht.mem_of_nhdsWithin_neBot <| hx.mono hstf.2 exact ⟨x, ⟨hsx, hxt⟩, hx⟩
/- Copyright (c) 2023 Ziyu Wang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ziyu Wang, Chenyi Li, Sébastien Gouëzel, Penghao Yu, Zhipeng Cao -/ import Mathlib.Analysis.InnerProductSpace.Dual import Mathlib.Analysis.Calculus.FDeriv.Basic import Mathlib.Analysis.Calculus.Deriv.Basic /-! # Gradient ## Main Definitions Let `f` be a function from a Hilbert Space `F` to `𝕜` (`𝕜` is `ℝ` or `ℂ`) , `x` be a point in `F` and `f'` be a vector in F. Then `HasGradientWithinAt f f' s x` says that `f` has a gradient `f'` at `x`, where the domain of interest is restricted to `s`. We also have `HasGradientAt f f' x := HasGradientWithinAt f f' x univ` ## Main results This file contains the following parts of gradient. * the definition of gradient. * the theorems translating between `HasGradientAtFilter` and `HasFDerivAtFilter`, `HasGradientWithinAt` and `HasFDerivWithinAt`, `HasGradientAt` and `HasFDerivAt`, `Gradient` and `fderiv`. * theorems the Uniqueness of Gradient. * the theorems translating between `HasGradientAtFilter` and `HasDerivAtFilter`, `HasGradientAt` and `HasDerivAt`, `Gradient` and `deriv` when `F = 𝕜`. * the theorems about the congruence of the gradient. * the theorems about the gradient of constant function. * the theorems about the continuity of a function admitting a gradient. -/ open Topology InnerProductSpace Set noncomputable section variable {𝕜 F : Type*} [RCLike 𝕜] variable [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [CompleteSpace F] variable {f : F → 𝕜} {f' x : F} /-- A function `f` has the gradient `f'` as derivative along the filter `L` if `f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` when `x'` converges along the filter `L`. -/ def HasGradientAtFilter (f : F → 𝕜) (f' x : F) (L : Filter F) := HasFDerivAtFilter f (toDual 𝕜 F f') x L /-- `f` has the gradient `f'` at the point `x` within the subset `s` if `f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` where `x'` converges to `x` inside `s`. -/ def HasGradientWithinAt (f : F → 𝕜) (f' : F) (s : Set F) (x : F) := HasGradientAtFilter f f' x (𝓝[s] x) /-- `f` has the gradient `f'` at the point `x` if `f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` where `x'` converges to `x`. -/ def HasGradientAt (f : F → 𝕜) (f' x : F) := HasGradientAtFilter f f' x (𝓝 x) /-- Gradient of `f` at the point `x` within the set `s`, if it exists. Zero otherwise. If the derivative exists (i.e., `∃ f', HasGradientWithinAt f f' s x`), then `f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` where `x'` converges to `x` inside `s`. -/ def gradientWithin (f : F → 𝕜) (s : Set F) (x : F) : F := (toDual 𝕜 F).symm (fderivWithin 𝕜 f s x) /-- Gradient of `f` at the point `x`, if it exists. Zero otherwise. If the derivative exists (i.e., `∃ f', HasGradientAt f f' x`), then `f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` where `x'` converges to `x`. -/ def gradient (f : F → 𝕜) (x : F) : F := (toDual 𝕜 F).symm (fderiv 𝕜 f x) @[inherit_doc] scoped[Gradient] notation "∇" => gradient local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y open scoped Gradient variable {s : Set F} {L : Filter F} theorem hasGradientWithinAt_iff_hasFDerivWithinAt {s : Set F} : HasGradientWithinAt f f' s x ↔ HasFDerivWithinAt f (toDual 𝕜 F f') s x := Iff.rfl theorem hasFDerivWithinAt_iff_hasGradientWithinAt {frechet : F →L[𝕜] 𝕜} {s : Set F} : HasFDerivWithinAt f frechet s x ↔ HasGradientWithinAt f ((toDual 𝕜 F).symm frechet) s x := by rw [hasGradientWithinAt_iff_hasFDerivWithinAt, (toDual 𝕜 F).apply_symm_apply frechet] theorem hasGradientAt_iff_hasFDerivAt : HasGradientAt f f' x ↔ HasFDerivAt f (toDual 𝕜 F f') x := Iff.rfl theorem hasFDerivAt_iff_hasGradientAt {frechet : F →L[𝕜] 𝕜} : HasFDerivAt f frechet x ↔ HasGradientAt f ((toDual 𝕜 F).symm frechet) x := by rw [hasGradientAt_iff_hasFDerivAt, (toDual 𝕜 F).apply_symm_apply frechet] alias ⟨HasGradientWithinAt.hasFDerivWithinAt, _⟩ := hasGradientWithinAt_iff_hasFDerivWithinAt alias ⟨HasFDerivWithinAt.hasGradientWithinAt, _⟩ := hasFDerivWithinAt_iff_hasGradientWithinAt alias ⟨HasGradientAt.hasFDerivAt, _⟩ := hasGradientAt_iff_hasFDerivAt alias ⟨HasFDerivAt.hasGradientAt, _⟩ := hasFDerivAt_iff_hasGradientAt theorem gradient_eq_zero_of_not_differentiableAt (h : ¬DifferentiableAt 𝕜 f x) : ∇ f x = 0 := by rw [gradient, fderiv_zero_of_not_differentiableAt h, map_zero] theorem HasGradientAt.unique {gradf gradg : F} (hf : HasGradientAt f gradf x) (hg : HasGradientAt f gradg x) : gradf = gradg := (toDual 𝕜 F).injective (hf.hasFDerivAt.unique hg.hasFDerivAt)
Mathlib/Analysis/Calculus/Gradient/Basic.lean
118
121
theorem DifferentiableAt.hasGradientAt (h : DifferentiableAt 𝕜 f x) : HasGradientAt f (∇ f x) x := by
rw [hasGradientAt_iff_hasFDerivAt, gradient, (toDual 𝕜 F).apply_symm_apply (fderiv 𝕜 f x)] exact h.hasFDerivAt
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.Polynomial.RingDivision #align_import data.polynomial.mirror from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # "Mirror" of a univariate polynomial In this file we define `Polynomial.mirror`, a variant of `Polynomial.reverse`. The difference between `reverse` and `mirror` is that `reverse` will decrease the degree if the polynomial is divisible by `X`. ## Main definitions - `Polynomial.mirror` ## Main results - `Polynomial.mirror_mul_of_domain`: `mirror` preserves multiplication. - `Polynomial.irreducible_of_mirror`: an irreducibility criterion involving `mirror` -/ namespace Polynomial open Polynomial section Semiring variable {R : Type*} [Semiring R] (p q : R[X]) /-- mirror of a polynomial: reverses the coefficients while preserving `Polynomial.natDegree` -/ noncomputable def mirror := p.reverse * X ^ p.natTrailingDegree #align polynomial.mirror Polynomial.mirror @[simp] theorem mirror_zero : (0 : R[X]).mirror = 0 := by simp [mirror] #align polynomial.mirror_zero Polynomial.mirror_zero theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a := by classical by_cases ha : a = 0 · rw [ha, monomial_zero_right, mirror_zero] · rw [mirror, reverse, natDegree_monomial n a, if_neg ha, natTrailingDegree_monomial ha, ← C_mul_X_pow_eq_monomial, reflect_C_mul_X_pow, revAt_le (le_refl n), tsub_self, pow_zero, mul_one] #align polynomial.mirror_monomial Polynomial.mirror_monomial theorem mirror_C (a : R) : (C a).mirror = C a := mirror_monomial 0 a set_option linter.uppercaseLean3 false in #align polynomial.mirror_C Polynomial.mirror_C theorem mirror_X : X.mirror = (X : R[X]) := mirror_monomial 1 (1 : R) set_option linter.uppercaseLean3 false in #align polynomial.mirror_X Polynomial.mirror_X
Mathlib/Algebra/Polynomial/Mirror.lean
66
72
theorem mirror_natDegree : p.mirror.natDegree = p.natDegree := by
by_cases hp : p = 0 · rw [hp, mirror_zero] nontriviality R rw [mirror, natDegree_mul', reverse_natDegree, natDegree_X_pow, tsub_add_cancel_of_le p.natTrailingDegree_le_natDegree] rwa [leadingCoeff_X_pow, mul_one, reverse_leadingCoeff, Ne, trailingCoeff_eq_zero]
/- 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.Data.Stream.Init import Mathlib.Tactic.ApplyFun import Mathlib.Control.Fix import Mathlib.Order.OmegaCompletePartialOrder #align_import control.lawful_fix from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" /-! # Lawful fixed point operators This module defines the laws required of a `Fix` instance, using the theory of omega complete partial orders (ωCPO). Proofs of the lawfulness of all `Fix` instances in `Control.Fix` are provided. ## Main definition * class `LawfulFix` -/ universe u v open scoped Classical variable {α : Type*} {β : α → Type*} open OmegaCompletePartialOrder /- Porting note: in `#align`s, mathport is putting some `fix`es where `Fix`es should be. -/ /-- Intuitively, a fixed point operator `fix` is lawful if it satisfies `fix f = f (fix f)` for all `f`, but this is inconsistent / uninteresting in most cases due to the existence of "exotic" functions `f`, such as the function that is defined iff its argument is not, familiar from the halting problem. Instead, this requirement is limited to only functions that are `Continuous` in the sense of `ω`-complete partial orders, which excludes the example because it is not monotone (making the input argument less defined can make `f` more defined). -/ class LawfulFix (α : Type*) [OmegaCompletePartialOrder α] extends Fix α where fix_eq : ∀ {f : α →o α}, Continuous f → Fix.fix f = f (Fix.fix f) #align lawful_fix LawfulFix theorem LawfulFix.fix_eq' {α} [OmegaCompletePartialOrder α] [LawfulFix α] {f : α → α} (hf : Continuous' f) : Fix.fix f = f (Fix.fix f) := LawfulFix.fix_eq (hf.to_bundled _) #align lawful_fix.fix_eq' LawfulFix.fix_eq' namespace Part open Part Nat Nat.Upto namespace Fix variable (f : ((a : _) → Part <| β a) →o (a : _) → Part <| β a) theorem approx_mono' {i : ℕ} : Fix.approx f i ≤ Fix.approx f (succ i) := by induction i with | zero => dsimp [approx]; apply @bot_le _ _ _ (f ⊥) | succ _ i_ih => intro; apply f.monotone; apply i_ih #align part.fix.approx_mono' Part.Fix.approx_mono' theorem approx_mono ⦃i j : ℕ⦄ (hij : i ≤ j) : approx f i ≤ approx f j := by induction' j with j ih · cases hij exact le_rfl cases hij; · exact le_rfl exact le_trans (ih ‹_›) (approx_mono' f) #align part.fix.approx_mono Part.Fix.approx_mono
Mathlib/Control/LawfulFix.lean
71
91
theorem mem_iff (a : α) (b : β a) : b ∈ Part.fix f a ↔ ∃ i, b ∈ approx f i a := by
by_cases h₀ : ∃ i : ℕ, (approx f i a).Dom · simp only [Part.fix_def f h₀] constructor <;> intro hh · exact ⟨_, hh⟩ have h₁ := Nat.find_spec h₀ rw [dom_iff_mem] at h₁ cases' h₁ with y h₁ replace h₁ := approx_mono' f _ _ h₁ suffices y = b by subst this exact h₁ cases' hh with i hh revert h₁; generalize succ (Nat.find h₀) = j; intro h₁ wlog case : i ≤ j · rcases le_total i j with H | H <;> [skip; symm] <;> apply_assumption <;> assumption replace hh := approx_mono f case _ _ hh apply Part.mem_unique h₁ hh · simp only [fix_def' (⇑f) h₀, not_exists, false_iff_iff, not_mem_none] simp only [dom_iff_mem, not_exists] at h₀ intro; apply h₀
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Chris Hughes -/ import Mathlib.Algebra.GeomSum import Mathlib.Algebra.Polynomial.Roots import Mathlib.GroupTheory.SpecificGroups.Cyclic #align_import ring_theory.integral_domain from "leanprover-community/mathlib"@"6e70e0d419bf686784937d64ed4bfde866ff229e" /-! # Integral domains Assorted theorems about integral domains. ## Main theorems * `isCyclic_of_subgroup_isDomain`: A finite subgroup of the units of an integral domain is cyclic. * `Fintype.fieldOfDomain`: A finite integral domain is a field. ## Notes Wedderburn's little theorem, which shows that all finite division rings are actually fields, is in `Mathlib.RingTheory.LittleWedderburn`. ## Tags integral domain, finite integral domain, finite field -/ section open Finset Polynomial Function Nat section CancelMonoidWithZero -- There doesn't seem to be a better home for these right now variable {M : Type*} [CancelMonoidWithZero M] [Finite M] theorem mul_right_bijective_of_finite₀ {a : M} (ha : a ≠ 0) : Bijective fun b => a * b := Finite.injective_iff_bijective.1 <| mul_right_injective₀ ha #align mul_right_bijective_of_finite₀ mul_right_bijective_of_finite₀ theorem mul_left_bijective_of_finite₀ {a : M} (ha : a ≠ 0) : Bijective fun b => b * a := Finite.injective_iff_bijective.1 <| mul_left_injective₀ ha #align mul_left_bijective_of_finite₀ mul_left_bijective_of_finite₀ /-- Every finite nontrivial cancel_monoid_with_zero is a group_with_zero. -/ def Fintype.groupWithZeroOfCancel (M : Type*) [CancelMonoidWithZero M] [DecidableEq M] [Fintype M] [Nontrivial M] : GroupWithZero M := { ‹Nontrivial M›, ‹CancelMonoidWithZero M› with inv := fun a => if h : a = 0 then 0 else Fintype.bijInv (mul_right_bijective_of_finite₀ h) 1 mul_inv_cancel := fun a ha => by simp only [Inv.inv, dif_neg ha] exact Fintype.rightInverse_bijInv _ _ inv_zero := by simp [Inv.inv, dif_pos rfl] } #align fintype.group_with_zero_of_cancel Fintype.groupWithZeroOfCancel theorem exists_eq_pow_of_mul_eq_pow_of_coprime {R : Type*} [CommSemiring R] [IsDomain R] [GCDMonoid R] [Unique Rˣ] {a b c : R} {n : ℕ} (cp : IsCoprime a b) (h : a * b = c ^ n) : ∃ d : R, a = d ^ n := by refine exists_eq_pow_of_mul_eq_pow (isUnit_of_dvd_one ?_) h obtain ⟨x, y, hxy⟩ := cp rw [← hxy] exact -- Porting note: added `GCDMonoid.` twice dvd_add (dvd_mul_of_dvd_right (GCDMonoid.gcd_dvd_left _ _) _) (dvd_mul_of_dvd_right (GCDMonoid.gcd_dvd_right _ _) _) #align exists_eq_pow_of_mul_eq_pow_of_coprime exists_eq_pow_of_mul_eq_pow_of_coprime nonrec
Mathlib/RingTheory/IntegralDomain.lean
73
84
theorem Finset.exists_eq_pow_of_mul_eq_pow_of_coprime {ι R : Type*} [CommSemiring R] [IsDomain R] [GCDMonoid R] [Unique Rˣ] {n : ℕ} {c : R} {s : Finset ι} {f : ι → R} (h : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsCoprime (f i) (f j)) (hprod : ∏ i ∈ s, f i = c ^ n) : ∀ i ∈ s, ∃ d : R, f i = d ^ n := by
classical intro i hi rw [← insert_erase hi, prod_insert (not_mem_erase i s)] at hprod refine exists_eq_pow_of_mul_eq_pow_of_coprime (IsCoprime.prod_right fun j hj => h i hi j (erase_subset i s hj) fun hij => ?_) hprod rw [hij] at hj exact (s.not_mem_erase _) hj
/- 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. -/ 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 @[simp] lemma withDensity_zero_left (f : α → ℝ≥0∞) : (0 : Measure α).withDensity f = 0 := by ext s hs rw [withDensity_apply _ hs] simp
Mathlib/MeasureTheory/Measure/WithDensity.lean
83
87
theorem withDensity_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : μ.withDensity f = μ.withDensity g := by
refine Measure.ext fun s hs => ?_ rw [withDensity_apply _ hs, withDensity_apply _ hs] exact lintegral_congr_ae (ae_restrict_of_ae h)
/- 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) theorem T_two : T R 2 = 2 * X ^ 2 - 1 := by simpa [pow_two, mul_assoc] using T_add_two R 0 #align polynomial.chebyshev.T_two Polynomial.Chebyshev.T_two @[simp] theorem T_neg (n : ℤ) : T R (-n) = T R n := by induction n using Polynomial.Chebyshev.induct with | zero => rfl | one => show 2 * X * 1 - X = X; ring | add_two n ih1 ih2 => have h₁ := T_add_two R n have h₂ := T_sub_two R (-n) linear_combination (norm := ring_nf) (2 * (X:R[X])) * ih1 - ih2 - h₁ + h₂ | neg_add_one n ih1 ih2 => have h₁ := T_add_one R n have h₂ := T_sub_one R (-n) linear_combination (norm := ring_nf) (2 * (X:R[X])) * ih1 - ih2 + h₁ - h₂ theorem T_natAbs (n : ℤ) : T R n.natAbs = T R n := by obtain h | h := Int.natAbs_eq n <;> nth_rw 2 [h]; simp
Mathlib/RingTheory/Polynomial/Chebyshev.lean
134
134
theorem T_neg_two : T R (-2) = 2 * X ^ 2 - 1 := by
simp [T_two]
/- Copyright (c) 2020 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.Algebra.Module.Opposites #align_import linear_algebra.clifford_algebra.conjugation from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" /-! # Conjugations This file defines the grade reversal and grade involution functions on multivectors, `reverse` and `involute`. Together, these operations compose to form the "Clifford conjugate", hence the name of this file. https://en.wikipedia.org/wiki/Clifford_algebra#Antiautomorphisms ## Main definitions * `CliffordAlgebra.involute`: the grade involution, negating each basis vector * `CliffordAlgebra.reverse`: the grade reversion, reversing the order of a product of vectors ## Main statements * `CliffordAlgebra.involute_involutive` * `CliffordAlgebra.reverse_involutive` * `CliffordAlgebra.reverse_involute_commute` * `CliffordAlgebra.involute_mem_evenOdd_iff` * `CliffordAlgebra.reverse_mem_evenOdd_iff` -/ variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra section Involute /-- Grade involution, inverting the sign of each basis vector. -/ def involute : CliffordAlgebra Q →ₐ[R] CliffordAlgebra Q := CliffordAlgebra.lift Q ⟨-ι Q, fun m => by simp⟩ #align clifford_algebra.involute CliffordAlgebra.involute @[simp] theorem involute_ι (m : M) : involute (ι Q m) = -ι Q m := lift_ι_apply _ _ m #align clifford_algebra.involute_ι CliffordAlgebra.involute_ι @[simp] theorem involute_comp_involute : involute.comp involute = AlgHom.id R (CliffordAlgebra Q) := by ext; simp #align clifford_algebra.involute_comp_involute CliffordAlgebra.involute_comp_involute theorem involute_involutive : Function.Involutive (involute : _ → CliffordAlgebra Q) := AlgHom.congr_fun involute_comp_involute #align clifford_algebra.involute_involutive CliffordAlgebra.involute_involutive @[simp] theorem involute_involute : ∀ a : CliffordAlgebra Q, involute (involute a) = a := involute_involutive #align clifford_algebra.involute_involute CliffordAlgebra.involute_involute /-- `CliffordAlgebra.involute` as an `AlgEquiv`. -/ @[simps!] def involuteEquiv : CliffordAlgebra Q ≃ₐ[R] CliffordAlgebra Q := AlgEquiv.ofAlgHom involute involute (AlgHom.ext <| involute_involute) (AlgHom.ext <| involute_involute) #align clifford_algebra.involute_equiv CliffordAlgebra.involuteEquiv end Involute section Reverse open MulOpposite /-- `CliffordAlgebra.reverse` as an `AlgHom` to the opposite algebra -/ def reverseOp : CliffordAlgebra Q →ₐ[R] (CliffordAlgebra Q)ᵐᵒᵖ := CliffordAlgebra.lift Q ⟨(MulOpposite.opLinearEquiv R).toLinearMap ∘ₗ ι Q, fun m => unop_injective <| by simp⟩ @[simp] theorem reverseOp_ι (m : M) : reverseOp (ι Q m) = op (ι Q m) := lift_ι_apply _ _ _ /-- `CliffordAlgebra.reverseEquiv` as an `AlgEquiv` to the opposite algebra -/ @[simps! apply] def reverseOpEquiv : CliffordAlgebra Q ≃ₐ[R] (CliffordAlgebra Q)ᵐᵒᵖ := AlgEquiv.ofAlgHom reverseOp (AlgHom.opComm reverseOp) (AlgHom.unop.injective <| hom_ext <| LinearMap.ext fun _ => by simp) (hom_ext <| LinearMap.ext fun _ => by simp) @[simp] theorem reverseOpEquiv_opComm : AlgEquiv.opComm (reverseOpEquiv (Q := Q)) = reverseOpEquiv.symm := rfl /-- Grade reversion, inverting the multiplication order of basis vectors. Also called *transpose* in some literature. -/ def reverse : CliffordAlgebra Q →ₗ[R] CliffordAlgebra Q := (opLinearEquiv R).symm.toLinearMap.comp reverseOp.toLinearMap #align clifford_algebra.reverse CliffordAlgebra.reverse @[simp] theorem unop_reverseOp (x : CliffordAlgebra Q) : (reverseOp x).unop = reverse x := rfl @[simp] theorem op_reverse (x : CliffordAlgebra Q) : op (reverse x) = reverseOp x := rfl @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Conjugation.lean
111
111
theorem reverse_ι (m : M) : reverse (ι Q m) = ι Q m := by
simp [reverse]
/- 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.Ideal.IsPrimary import Mathlib.RingTheory.Localization.AtPrime import Mathlib.Order.Minimal #align_import ring_theory.ideal.minimal_prime from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Minimal primes We provide various results concerning the minimal primes above an ideal ## Main results - `Ideal.minimalPrimes`: `I.minimalPrimes` is the set of ideals that are minimal primes over `I`. - `minimalPrimes`: `minimalPrimes R` is the set of minimal primes of `R`. - `Ideal.exists_minimalPrimes_le`: Every prime ideal over `I` contains a minimal prime over `I`. - `Ideal.radical_minimalPrimes`: The minimal primes over `I.radical` are precisely the minimal primes over `I`. - `Ideal.sInf_minimalPrimes`: The intersection of minimal primes over `I` is `I.radical`. - `Ideal.exists_minimalPrimes_comap_eq` If `p` is a minimal prime over `f ⁻¹ I`, then it is the preimage of some minimal prime over `I`. - `Ideal.minimalPrimes_eq_comap`: The minimal primes over `I` are precisely the preimages of minimal primes of `R ⧸ I`. - `Localization.AtPrime.prime_unique_of_minimal`: When localizing at a minimal prime ideal `I`, the resulting ring only has a single prime ideal. -/ section variable {R S : Type*} [CommSemiring R] [CommSemiring S] (I J : Ideal R) /-- `I.minimalPrimes` is the set of ideals that are minimal primes over `I`. -/ protected def Ideal.minimalPrimes : Set (Ideal R) := minimals (· ≤ ·) { p | p.IsPrime ∧ I ≤ p } #align ideal.minimal_primes Ideal.minimalPrimes variable (R) in /-- `minimalPrimes R` is the set of minimal primes of `R`. This is defined as `Ideal.minimalPrimes ⊥`. -/ def minimalPrimes : Set (Ideal R) := Ideal.minimalPrimes ⊥ #align minimal_primes minimalPrimes lemma minimalPrimes_eq_minimals : minimalPrimes R = minimals (· ≤ ·) (setOf Ideal.IsPrime) := congr_arg (minimals (· ≤ ·)) (by simp) variable {I J}
Mathlib/RingTheory/Ideal/MinimalPrime.lean
56
74
theorem Ideal.exists_minimalPrimes_le [J.IsPrime] (e : I ≤ J) : ∃ p ∈ I.minimalPrimes, p ≤ J := by
suffices ∃ m ∈ { p : (Ideal R)ᵒᵈ | Ideal.IsPrime p ∧ I ≤ OrderDual.ofDual p }, OrderDual.toDual J ≤ m ∧ ∀ z ∈ { p : (Ideal R)ᵒᵈ | Ideal.IsPrime p ∧ I ≤ p }, m ≤ z → z = m by obtain ⟨p, h₁, h₂, h₃⟩ := this simp_rw [← @eq_comm _ p] at h₃ exact ⟨p, ⟨h₁, fun a b c => le_of_eq (h₃ a b c)⟩, h₂⟩ apply zorn_nonempty_partialOrder₀ swap · refine ⟨show J.IsPrime by infer_instance, e⟩ rintro (c : Set (Ideal R)) hc hc' J' hJ' refine ⟨OrderDual.toDual (sInf c), ⟨Ideal.sInf_isPrime_of_isChain ⟨J', hJ'⟩ hc'.symm fun x hx => (hc hx).1, ?_⟩, ?_⟩ · rw [OrderDual.ofDual_toDual, le_sInf_iff] exact fun _ hx => (hc hx).2 · rintro z hz rw [OrderDual.le_toDual] exact sInf_le hz
/- Copyright (c) 2022 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Probability.Variance #align_import probability.moments from "leanprover-community/mathlib"@"85453a2a14be8da64caf15ca50930cf4c6e5d8de" /-! # Moments and moment generating function ## Main definitions * `ProbabilityTheory.moment X p μ`: `p`th moment of a real random variable `X` with respect to measure `μ`, `μ[X^p]` * `ProbabilityTheory.centralMoment X p μ`:`p`th central moment of `X` with respect to measure `μ`, `μ[(X - μ[X])^p]` * `ProbabilityTheory.mgf X μ t`: moment generating function of `X` with respect to measure `μ`, `μ[exp(t*X)]` * `ProbabilityTheory.cgf X μ t`: cumulant generating function, logarithm of the moment generating function ## Main results * `ProbabilityTheory.IndepFun.mgf_add`: if two real random variables `X` and `Y` are independent and their mgfs are defined at `t`, then `mgf (X + Y) μ t = mgf X μ t * mgf Y μ t` * `ProbabilityTheory.IndepFun.cgf_add`: if two real random variables `X` and `Y` are independent and their cgfs are defined at `t`, then `cgf (X + Y) μ t = cgf X μ t + cgf Y μ t` * `ProbabilityTheory.measure_ge_le_exp_cgf` and `ProbabilityTheory.measure_le_le_exp_cgf`: Chernoff bound on the upper (resp. lower) tail of a random variable. For `t` nonnegative such that the cgf exists, `ℙ(ε ≤ X) ≤ exp(- t*ε + cgf X ℙ t)`. See also `ProbabilityTheory.measure_ge_le_exp_mul_mgf` and `ProbabilityTheory.measure_le_le_exp_mul_mgf` for versions of these results using `mgf` instead of `cgf`. -/ open MeasureTheory Filter Finset Real noncomputable section open scoped MeasureTheory ProbabilityTheory ENNReal NNReal namespace ProbabilityTheory variable {Ω ι : Type*} {m : MeasurableSpace Ω} {X : Ω → ℝ} {p : ℕ} {μ : Measure Ω} /-- Moment of a real random variable, `μ[X ^ p]`. -/ def moment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ := μ[X ^ p] #align probability_theory.moment ProbabilityTheory.moment /-- Central moment of a real random variable, `μ[(X - μ[X]) ^ p]`. -/ def centralMoment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ := by have m := fun (x : Ω) => μ[X] -- Porting note: Lean deems `μ[(X - fun x => μ[X]) ^ p]` ambiguous exact μ[(X - m) ^ p] #align probability_theory.central_moment ProbabilityTheory.centralMoment @[simp] theorem moment_zero (hp : p ≠ 0) : moment 0 p μ = 0 := by simp only [moment, hp, zero_pow, Ne, not_false_iff, Pi.zero_apply, integral_const, smul_eq_mul, mul_zero, integral_zero] #align probability_theory.moment_zero ProbabilityTheory.moment_zero @[simp] theorem centralMoment_zero (hp : p ≠ 0) : centralMoment 0 p μ = 0 := by simp only [centralMoment, hp, Pi.zero_apply, integral_const, smul_eq_mul, mul_zero, zero_sub, Pi.pow_apply, Pi.neg_apply, neg_zero, zero_pow, Ne, not_false_iff] #align probability_theory.central_moment_zero ProbabilityTheory.centralMoment_zero theorem centralMoment_one' [IsFiniteMeasure μ] (h_int : Integrable X μ) : centralMoment X 1 μ = (1 - (μ Set.univ).toReal) * μ[X] := by simp only [centralMoment, Pi.sub_apply, pow_one] rw [integral_sub h_int (integrable_const _)] simp only [sub_mul, integral_const, smul_eq_mul, one_mul] #align probability_theory.central_moment_one' ProbabilityTheory.centralMoment_one' @[simp]
Mathlib/Probability/Moments.lean
81
91
theorem centralMoment_one [IsProbabilityMeasure μ] : centralMoment X 1 μ = 0 := by
by_cases h_int : Integrable X μ · rw [centralMoment_one' h_int] simp only [measure_univ, ENNReal.one_toReal, sub_self, zero_mul] · simp only [centralMoment, Pi.sub_apply, pow_one] have : ¬Integrable (fun x => X x - integral μ X) μ := by refine fun h_sub => h_int ?_ have h_add : X = (fun x => X x - integral μ X) + fun _ => integral μ X := by ext1 x; simp rw [h_add] exact h_sub.add (integrable_const _) rw [integral_undef this]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne -/ import Mathlib.Analysis.Complex.RealDeriv import Mathlib.Analysis.Calculus.ContDiff.RCLike import Mathlib.Analysis.Calculus.IteratedDeriv.Lemmas #align_import analysis.special_functions.exp_deriv from "leanprover-community/mathlib"@"6a5c85000ab93fe5dcfdf620676f614ba8e18c26" /-! # Complex and real exponential In this file we prove that `Complex.exp` and `Real.exp` are infinitely smooth functions. ## Tags exp, derivative -/ noncomputable section open Filter Asymptotics Set Function open scoped Classical Topology /-! ## `Complex.exp` -/ namespace Complex variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedAlgebra 𝕜 ℂ] /-- The complex exponential is everywhere differentiable, with the derivative `exp x`. -/
Mathlib/Analysis/SpecialFunctions/ExpDeriv.lean
36
42
theorem hasDerivAt_exp (x : ℂ) : HasDerivAt exp (exp x) x := by
rw [hasDerivAt_iff_isLittleO_nhds_zero] have : (1 : ℕ) < 2 := by norm_num refine (IsBigO.of_bound ‖exp x‖ ?_).trans_isLittleO (isLittleO_pow_id this) filter_upwards [Metric.ball_mem_nhds (0 : ℂ) zero_lt_one] simp only [Metric.mem_ball, dist_zero_right, norm_pow] exact fun z hz => exp_bound_sq x z hz.le
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Tactic.Positivity.Core import Mathlib.Algebra.Ring.NegOnePow #align_import analysis.special_functions.trigonometric.basic from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Trigonometric functions ## Main definitions This file contains the definition of `π`. See also `Analysis.SpecialFunctions.Trigonometric.Inverse` and `Analysis.SpecialFunctions.Trigonometric.Arctan` for the inverse trigonometric functions. See also `Analysis.SpecialFunctions.Complex.Arg` and `Analysis.SpecialFunctions.Complex.Log` for the complex argument function and the complex logarithm. ## Main statements Many basic inequalities on the real trigonometric functions are established. The continuity of the usual trigonometric functions is proved. Several facts about the real trigonometric functions have the proofs deferred to `Analysis.SpecialFunctions.Trigonometric.Complex`, as they are most easily proved by appealing to the corresponding fact for complex trigonometric functions. See also `Analysis.SpecialFunctions.Trigonometric.Chebyshev` for the multiple angle formulas in terms of Chebyshev polynomials. ## Tags sin, cos, tan, angle -/ noncomputable section open scoped Classical open Topology Filter Set namespace Complex @[continuity, fun_prop] theorem continuous_sin : Continuous sin := by change Continuous fun z => (exp (-z * I) - exp (z * I)) * I / 2 continuity #align complex.continuous_sin Complex.continuous_sin @[fun_prop] theorem continuousOn_sin {s : Set ℂ} : ContinuousOn sin s := continuous_sin.continuousOn #align complex.continuous_on_sin Complex.continuousOn_sin @[continuity, fun_prop] theorem continuous_cos : Continuous cos := by change Continuous fun z => (exp (z * I) + exp (-z * I)) / 2 continuity #align complex.continuous_cos Complex.continuous_cos @[fun_prop] theorem continuousOn_cos {s : Set ℂ} : ContinuousOn cos s := continuous_cos.continuousOn #align complex.continuous_on_cos Complex.continuousOn_cos @[continuity, fun_prop] theorem continuous_sinh : Continuous sinh := by change Continuous fun z => (exp z - exp (-z)) / 2 continuity #align complex.continuous_sinh Complex.continuous_sinh @[continuity, fun_prop] theorem continuous_cosh : Continuous cosh := by change Continuous fun z => (exp z + exp (-z)) / 2 continuity #align complex.continuous_cosh Complex.continuous_cosh end Complex namespace Real variable {x y z : ℝ} @[continuity, fun_prop] theorem continuous_sin : Continuous sin := Complex.continuous_re.comp (Complex.continuous_sin.comp Complex.continuous_ofReal) #align real.continuous_sin Real.continuous_sin @[fun_prop] theorem continuousOn_sin {s} : ContinuousOn sin s := continuous_sin.continuousOn #align real.continuous_on_sin Real.continuousOn_sin @[continuity, fun_prop] theorem continuous_cos : Continuous cos := Complex.continuous_re.comp (Complex.continuous_cos.comp Complex.continuous_ofReal) #align real.continuous_cos Real.continuous_cos @[fun_prop] theorem continuousOn_cos {s} : ContinuousOn cos s := continuous_cos.continuousOn #align real.continuous_on_cos Real.continuousOn_cos @[continuity, fun_prop] theorem continuous_sinh : Continuous sinh := Complex.continuous_re.comp (Complex.continuous_sinh.comp Complex.continuous_ofReal) #align real.continuous_sinh Real.continuous_sinh @[continuity, fun_prop] theorem continuous_cosh : Continuous cosh := Complex.continuous_re.comp (Complex.continuous_cosh.comp Complex.continuous_ofReal) #align real.continuous_cosh Real.continuous_cosh end Real namespace Real theorem exists_cos_eq_zero : 0 ∈ cos '' Icc (1 : ℝ) 2 := intermediate_value_Icc' (by norm_num) continuousOn_cos ⟨le_of_lt cos_two_neg, le_of_lt cos_one_pos⟩ #align real.exists_cos_eq_zero Real.exists_cos_eq_zero /-- The number π = 3.14159265... Defined here using choice as twice a zero of cos in [1,2], from which one can derive all its properties. For explicit bounds on π, see `Data.Real.Pi.Bounds`. -/ protected noncomputable def pi : ℝ := 2 * Classical.choose exists_cos_eq_zero #align real.pi Real.pi @[inherit_doc] scoped notation "π" => Real.pi @[simp] theorem cos_pi_div_two : cos (π / 2) = 0 := by rw [Real.pi, mul_div_cancel_left₀ _ (two_ne_zero' ℝ)] exact (Classical.choose_spec exists_cos_eq_zero).2 #align real.cos_pi_div_two Real.cos_pi_div_two theorem one_le_pi_div_two : (1 : ℝ) ≤ π / 2 := by rw [Real.pi, mul_div_cancel_left₀ _ (two_ne_zero' ℝ)] exact (Classical.choose_spec exists_cos_eq_zero).1.1 #align real.one_le_pi_div_two Real.one_le_pi_div_two theorem pi_div_two_le_two : π / 2 ≤ 2 := by rw [Real.pi, mul_div_cancel_left₀ _ (two_ne_zero' ℝ)] exact (Classical.choose_spec exists_cos_eq_zero).1.2 #align real.pi_div_two_le_two Real.pi_div_two_le_two theorem two_le_pi : (2 : ℝ) ≤ π := (div_le_div_right (show (0 : ℝ) < 2 by norm_num)).1 (by rw [div_self (two_ne_zero' ℝ)]; exact one_le_pi_div_two) #align real.two_le_pi Real.two_le_pi
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean
162
166
theorem pi_le_four : π ≤ 4 := (div_le_div_right (show (0 : ℝ) < 2 by norm_num)).1 (calc π / 2 ≤ 2 := pi_div_two_le_two _ = 4 / 2 := by
norm_num)
/- Copyright (c) 2022 Antoine Labelle. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Labelle -/ import Mathlib.RepresentationTheory.Basic import Mathlib.RepresentationTheory.FdRep #align_import representation_theory.invariants from "leanprover-community/mathlib"@"55b3f8206b8596db8bb1804d8a92814a0b6670c9" /-! # Subspace of invariants a group representation This file introduces the subspace of invariants of a group representation and proves basic results about it. The main tool used is the average of all elements of the group, seen as an element of `MonoidAlgebra k G`. The action of this special element gives a projection onto the subspace of invariants. In order for the definition of the average element to make sense, we need to assume for most of the results that the order of `G` is invertible in `k` (e. g. `k` has characteristic `0`). -/ suppress_compilation open MonoidAlgebra open Representation namespace GroupAlgebra variable (k G : Type*) [CommSemiring k] [Group G] variable [Fintype G] [Invertible (Fintype.card G : k)] /-- The average of all elements of the group `G`, considered as an element of `MonoidAlgebra k G`. -/ noncomputable def average : MonoidAlgebra k G := ⅟ (Fintype.card G : k) • ∑ g : G, of k G g #align group_algebra.average GroupAlgebra.average /-- `average k G` is invariant under left multiplication by elements of `G`. -/ @[simp] theorem mul_average_left (g : G) : ↑(Finsupp.single g 1) * average k G = average k G := by simp only [mul_one, Finset.mul_sum, Algebra.mul_smul_comm, average, MonoidAlgebra.of_apply, Finset.sum_congr, MonoidAlgebra.single_mul_single] set f : G → MonoidAlgebra k G := fun x => Finsupp.single x 1 show ⅟ (Fintype.card G : k) • ∑ x : G, f (g * x) = ⅟ (Fintype.card G : k) • ∑ x : G, f x rw [Function.Bijective.sum_comp (Group.mulLeft_bijective g) _] #align group_algebra.mul_average_left GroupAlgebra.mul_average_left /-- `average k G` is invariant under right multiplication by elements of `G`. -/ @[simp] theorem mul_average_right (g : G) : average k G * ↑(Finsupp.single g 1) = average k G := by simp only [mul_one, Finset.sum_mul, Algebra.smul_mul_assoc, average, MonoidAlgebra.of_apply, Finset.sum_congr, MonoidAlgebra.single_mul_single] set f : G → MonoidAlgebra k G := fun x => Finsupp.single x 1 show ⅟ (Fintype.card G : k) • ∑ x : G, f (x * g) = ⅟ (Fintype.card G : k) • ∑ x : G, f x rw [Function.Bijective.sum_comp (Group.mulRight_bijective g) _] #align group_algebra.mul_average_right GroupAlgebra.mul_average_right end GroupAlgebra namespace Representation section Invariants open GroupAlgebra variable {k G V : Type*} [CommSemiring k] [Group G] [AddCommMonoid V] [Module k V] variable (ρ : Representation k G V) /-- The subspace of invariants, consisting of the vectors fixed by all elements of `G`. -/ def invariants : Submodule k V where carrier := setOf fun v => ∀ g : G, ρ g v = v zero_mem' g := by simp only [map_zero] add_mem' hv hw g := by simp only [hv g, hw g, map_add] smul_mem' r v hv g := by simp only [hv g, LinearMap.map_smulₛₗ, RingHom.id_apply] #align representation.invariants Representation.invariants @[simp]
Mathlib/RepresentationTheory/Invariants.lean
83
83
theorem mem_invariants (v : V) : v ∈ invariants ρ ↔ ∀ g : G, ρ g v = v := by
rfl
/- 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]
Mathlib/Data/Int/GCD.lean
74
76
theorem gcdA_zero_left {s : ℕ} : gcdA 0 s = 0 := by
unfold gcdA rw [xgcd, xgcd_zero_left]
/- Copyright (c) 2020 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne, Eric Wieser -/ import Mathlib.MeasureTheory.Function.LpSeminorm.Basic import Mathlib.MeasureTheory.Integral.MeanInequalities #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" /-! # Compare Lp seminorms for different values of `p` In this file we compare `MeasureTheory.snorm'` and `MeasureTheory.snorm` for different exponents. -/ open Filter open scoped ENNReal Topology namespace MeasureTheory section SameSpace variable {α E : Type*} {m : MeasurableSpace α} [NormedAddCommGroup E] {μ : Measure α} {f : α → E} theorem snorm'_le_snorm'_mul_rpow_measure_univ {p q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q) (hf : AEStronglyMeasurable f μ) : snorm' f p μ ≤ snorm' f q μ * μ Set.univ ^ (1 / p - 1 / q) := by have hq0_lt : 0 < q := lt_of_lt_of_le hp0_lt hpq by_cases hpq_eq : p = q · rw [hpq_eq, sub_self, ENNReal.rpow_zero, mul_one] have hpq : p < q := lt_of_le_of_ne hpq hpq_eq let g := fun _ : α => (1 : ℝ≥0∞) have h_rw : (∫⁻ a, (‖f a‖₊ : ℝ≥0∞) ^ p ∂μ) = ∫⁻ a, ((‖f a‖₊ : ℝ≥0∞) * g a) ^ p ∂μ := lintegral_congr fun a => by simp [g] repeat' rw [snorm'] rw [h_rw] let r := p * q / (q - p) have hpqr : 1 / p = 1 / q + 1 / r := by field_simp [r, hp0_lt.ne', hq0_lt.ne'] calc (∫⁻ a : α, (↑‖f a‖₊ * g a) ^ p ∂μ) ^ (1 / p) ≤ (∫⁻ a : α, ↑‖f a‖₊ ^ q ∂μ) ^ (1 / q) * (∫⁻ a : α, g a ^ r ∂μ) ^ (1 / r) := ENNReal.lintegral_Lp_mul_le_Lq_mul_Lr hp0_lt hpq hpqr μ hf.ennnorm aemeasurable_const _ = (∫⁻ a : α, ↑‖f a‖₊ ^ q ∂μ) ^ (1 / q) * μ Set.univ ^ (1 / p - 1 / q) := by rw [hpqr]; simp [r, g] #align measure_theory.snorm'_le_snorm'_mul_rpow_measure_univ MeasureTheory.snorm'_le_snorm'_mul_rpow_measure_univ
Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean
48
58
theorem snorm'_le_snormEssSup_mul_rpow_measure_univ {q : ℝ} (hq_pos : 0 < q) : snorm' f q μ ≤ snormEssSup f μ * μ Set.univ ^ (1 / q) := by
have h_le : (∫⁻ a : α, (‖f a‖₊ : ℝ≥0∞) ^ q ∂μ) ≤ ∫⁻ _ : α, snormEssSup f μ ^ q ∂μ := by refine lintegral_mono_ae ?_ have h_nnnorm_le_snorm_ess_sup := coe_nnnorm_ae_le_snormEssSup f μ exact h_nnnorm_le_snorm_ess_sup.mono fun x hx => by gcongr rw [snorm', ← ENNReal.rpow_one (snormEssSup f μ)] nth_rw 2 [← mul_inv_cancel (ne_of_lt hq_pos).symm] rw [ENNReal.rpow_mul, one_div, ← ENNReal.mul_rpow_of_nonneg _ _ (by simp [hq_pos.le] : 0 ≤ q⁻¹)] gcongr rwa [lintegral_const] at h_le
/- Copyright (c) 2022 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis, Heather Macbeth -/ import Mathlib.Algebra.MvPolynomial.Supported import Mathlib.RingTheory.WittVector.Truncated #align_import ring_theory.witt_vector.mul_coeff from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Leading terms of Witt vector multiplication The goal of this file is to study the leading terms of the formula for the `n+1`st coefficient of a product of Witt vectors `x` and `y` over a ring of characteristic `p`. We aim to isolate the `n+1`st coefficients of `x` and `y`, and express the rest of the product in terms of a function of the lower coefficients. For most of this file we work with terms of type `MvPolynomial (Fin 2 × ℕ) ℤ`. We will eventually evaluate them in `k`, but first we must take care of a calculation that needs to happen in characteristic 0. ## Main declarations * `WittVector.nth_mul_coeff`: expresses the coefficient of a product of Witt vectors in terms of the previous coefficients of the multiplicands. -/ noncomputable section namespace WittVector variable (p : ℕ) [hp : Fact p.Prime] variable {k : Type*} [CommRing k] local notation "𝕎" => WittVector p -- Porting note: new notation local notation "𝕄" => MvPolynomial (Fin 2 × ℕ) ℤ open Finset MvPolynomial /-- ``` (∑ i ∈ range n, (y.coeff i)^(p^(n-i)) * p^i.val) * (∑ i ∈ range n, (y.coeff i)^(p^(n-i)) * p^i.val) ``` -/ def wittPolyProd (n : ℕ) : 𝕄 := rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ n) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ n) #align witt_vector.witt_poly_prod WittVector.wittPolyProd theorem wittPolyProd_vars (n : ℕ) : (wittPolyProd p n).vars ⊆ univ ×ˢ range (n + 1) := by rw [wittPolyProd] apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ <;> · refine Subset.trans (vars_rename _ _) ?_ simp [wittPolynomial_vars, image_subset_iff] #align witt_vector.witt_poly_prod_vars WittVector.wittPolyProd_vars /-- The "remainder term" of `WittVector.wittPolyProd`. See `mul_polyOfInterest_aux2`. -/ def wittPolyProdRemainder (n : ℕ) : 𝕄 := ∑ i ∈ range n, (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i) #align witt_vector.witt_poly_prod_remainder WittVector.wittPolyProdRemainder theorem wittPolyProdRemainder_vars (n : ℕ) : (wittPolyProdRemainder p n).vars ⊆ univ ×ˢ range n := by rw [wittPolyProdRemainder] refine Subset.trans (vars_sum_subset _ _) ?_ rw [biUnion_subset] intro x hx apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ · apply Subset.trans (vars_pow _ _) have : (p : 𝕄) = C (p : ℤ) := by simp only [Int.cast_natCast, eq_intCast] rw [this, vars_C] apply empty_subset · apply Subset.trans (vars_pow _ _) apply Subset.trans (wittMul_vars _ _) apply product_subset_product (Subset.refl _) simp only [mem_range, range_subset] at hx ⊢ exact hx #align witt_vector.witt_poly_prod_remainder_vars WittVector.wittPolyProdRemainder_vars /-- `remainder p n` represents the remainder term from `mul_polyOfInterest_aux3`. `wittPolyProd p (n+1)` will have variables up to `n+1`, but `remainder` will only have variables up to `n`. -/ def remainder (n : ℕ) : 𝕄 := (∑ x ∈ range (n + 1), (rename (Prod.mk 0)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x))) * ∑ x ∈ range (n + 1), (rename (Prod.mk 1)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x)) #align witt_vector.remainder WittVector.remainder
Mathlib/RingTheory/WittVector/MulCoeff.lean
99
110
theorem remainder_vars (n : ℕ) : (remainder p n).vars ⊆ univ ×ˢ range (n + 1) := by
rw [remainder] apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ <;> · refine Subset.trans (vars_sum_subset _ _) ?_ rw [biUnion_subset] intro x hx rw [rename_monomial, vars_monomial, Finsupp.mapDomain_single] · apply Subset.trans Finsupp.support_single_subset simpa using mem_range.mp hx · apply pow_ne_zero exact mod_cast hp.out.ne_zero
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Polynomial.BigOperators import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Choose.Cast import Mathlib.Data.Nat.Choose.Vandermonde import Mathlib.Tactic.FieldSimp #align_import data.polynomial.hasse_deriv from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64" /-! # Hasse derivative of polynomials The `k`th Hasse derivative of a polynomial `∑ a_i X^i` is `∑ (i.choose k) a_i X^(i-k)`. It is a variant of the usual derivative, and satisfies `k! * (hasseDeriv k f) = derivative^[k] f`. The main benefit is that is gives an atomic way of talking about expressions such as `(derivative^[k] f).eval r / k!`, that occur in Taylor expansions, for example. ## Main declarations In the following, we write `D k` for the `k`-th Hasse derivative `hasse_deriv k`. * `Polynomial.hasseDeriv`: the `k`-th Hasse derivative of a polynomial * `Polynomial.hasseDeriv_zero`: the `0`th Hasse derivative is the identity * `Polynomial.hasseDeriv_one`: the `1`st Hasse derivative is the usual derivative * `Polynomial.factorial_smul_hasseDeriv`: the identity `k! • (D k f) = derivative^[k] f` * `Polynomial.hasseDeriv_comp`: the identity `(D k).comp (D l) = (k+l).choose k • D (k+l)` * `Polynomial.hasseDeriv_mul`: the "Leibniz rule" `D k (f * g) = ∑ ij ∈ antidiagonal k, D ij.1 f * D ij.2 g` For the identity principle, see `Polynomial.eq_zero_of_hasseDeriv_eq_zero` in `Data/Polynomial/Taylor.lean`. ## Reference https://math.fontein.de/2009/08/12/the-hasse-derivative/ -/ noncomputable section namespace Polynomial open Nat Polynomial open Function variable {R : Type*} [Semiring R] (k : ℕ) (f : R[X]) /-- The `k`th Hasse derivative of a polynomial `∑ a_i X^i` is `∑ (i.choose k) a_i X^(i-k)`. It satisfies `k! * (hasse_deriv k f) = derivative^[k] f`. -/ def hasseDeriv (k : ℕ) : R[X] →ₗ[R] R[X] := lsum fun i => monomial (i - k) ∘ₗ DistribMulAction.toLinearMap R R (i.choose k) #align polynomial.hasse_deriv Polynomial.hasseDeriv theorem hasseDeriv_apply : hasseDeriv k f = f.sum fun i r => monomial (i - k) (↑(i.choose k) * r) := by dsimp [hasseDeriv] congr; ext; congr apply nsmul_eq_mul #align polynomial.hasse_deriv_apply Polynomial.hasseDeriv_apply theorem hasseDeriv_coeff (n : ℕ) : (hasseDeriv k f).coeff n = (n + k).choose k * f.coeff (n + k) := by rw [hasseDeriv_apply, coeff_sum, sum_def, Finset.sum_eq_single (n + k), coeff_monomial] · simp only [if_true, add_tsub_cancel_right, eq_self_iff_true] · intro i _hi hink rw [coeff_monomial] by_cases hik : i < k · simp only [Nat.choose_eq_zero_of_lt hik, ite_self, Nat.cast_zero, zero_mul] · push_neg at hik rw [if_neg] contrapose! hink exact (tsub_eq_iff_eq_add_of_le hik).mp hink · intro h simp only [not_mem_support_iff.mp h, monomial_zero_right, mul_zero, coeff_zero] #align polynomial.hasse_deriv_coeff Polynomial.hasseDeriv_coeff theorem hasseDeriv_zero' : hasseDeriv 0 f = f := by simp only [hasseDeriv_apply, tsub_zero, Nat.choose_zero_right, Nat.cast_one, one_mul, sum_monomial_eq] #align polynomial.hasse_deriv_zero' Polynomial.hasseDeriv_zero' @[simp] theorem hasseDeriv_zero : @hasseDeriv R _ 0 = LinearMap.id := LinearMap.ext <| hasseDeriv_zero' #align polynomial.hasse_deriv_zero Polynomial.hasseDeriv_zero theorem hasseDeriv_eq_zero_of_lt_natDegree (p : R[X]) (n : ℕ) (h : p.natDegree < n) : hasseDeriv n p = 0 := by rw [hasseDeriv_apply, sum_def] refine Finset.sum_eq_zero fun x hx => ?_ simp [Nat.choose_eq_zero_of_lt ((le_natDegree_of_mem_supp _ hx).trans_lt h)] #align polynomial.hasse_deriv_eq_zero_of_lt_nat_degree Polynomial.hasseDeriv_eq_zero_of_lt_natDegree theorem hasseDeriv_one' : hasseDeriv 1 f = derivative f := by simp only [hasseDeriv_apply, derivative_apply, ← C_mul_X_pow_eq_monomial, Nat.choose_one_right, (Nat.cast_commute _ _).eq] #align polynomial.hasse_deriv_one' Polynomial.hasseDeriv_one' @[simp] theorem hasseDeriv_one : @hasseDeriv R _ 1 = derivative := LinearMap.ext <| hasseDeriv_one' #align polynomial.hasse_deriv_one Polynomial.hasseDeriv_one @[simp]
Mathlib/Algebra/Polynomial/HasseDeriv.lean
111
124
theorem hasseDeriv_monomial (n : ℕ) (r : R) : hasseDeriv k (monomial n r) = monomial (n - k) (↑(n.choose k) * r) := by
ext i simp only [hasseDeriv_coeff, coeff_monomial] by_cases hnik : n = i + k · rw [if_pos hnik, if_pos, ← hnik] apply tsub_eq_of_eq_add_rev rwa [add_comm] · rw [if_neg hnik, mul_zero] by_cases hkn : k ≤ n · rw [← tsub_eq_iff_eq_add_of_le hkn] at hnik rw [if_neg hnik] · push_neg at hkn rw [Nat.choose_eq_zero_of_lt hkn, Nat.cast_zero, zero_mul, ite_self]
/- Copyright (c) 2024 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey, Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro -/ import Mathlib.Data.List.Defs import Mathlib.Data.Option.Basic import Mathlib.Data.Nat.Defs import Mathlib.Init.Data.List.Basic import Mathlib.Util.AssertExists /-! # getD and getI This file provides theorems for working with the `getD` and `getI` functions. These are used to access an element of a list by numerical index, with a default value as a fallback when the index is out of range. -/ -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub namespace List universe u v variable {α : Type u} {β : Type v} (l : List α) (x : α) (xs : List α) (n : ℕ) section getD variable (d : α) #align list.nthd_nil List.getD_nilₓ -- argument order #align list.nthd_cons_zero List.getD_cons_zeroₓ -- argument order #align list.nthd_cons_succ List.getD_cons_succₓ -- argument order theorem getD_eq_get {n : ℕ} (hn : n < l.length) : l.getD n d = l.get ⟨n, hn⟩ := by induction l generalizing n with | nil => simp at hn | cons head tail ih => cases n · exact getD_cons_zero · exact ih _ @[simp] theorem getD_map {n : ℕ} (f : α → β) : (map f l).getD n (f d) = f (l.getD n d) := by induction l generalizing n with | nil => rfl | cons head tail ih => cases n · rfl · simp [ih] #align list.nthd_eq_nth_le List.getD_eq_get theorem getD_eq_default {n : ℕ} (hn : l.length ≤ n) : l.getD n d = d := by induction l generalizing n with | nil => exact getD_nil | cons head tail ih => cases n · simp at hn · exact ih (Nat.le_of_succ_le_succ hn) #align list.nthd_eq_default List.getD_eq_defaultₓ -- argument order /-- An empty list can always be decidably checked for the presence of an element. Not an instance because it would clash with `DecidableEq α`. -/ def decidableGetDNilNe (a : α) : DecidablePred fun i : ℕ => getD ([] : List α) i a ≠ a := fun _ => isFalse fun H => H getD_nil #align list.decidable_nthd_nil_ne List.decidableGetDNilNeₓ -- argument order @[simp]
Mathlib/Data/List/GetD.lean
73
73
theorem getD_singleton_default_eq (n : ℕ) : [d].getD n d = d := by
cases n <;> simp
/- Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura, Jeremy Avigad, Mario Carneiro -/ import Mathlib.Algebra.Associated import Mathlib.Algebra.Order.Monoid.Unbundled.Pow import Mathlib.Algebra.Ring.Int import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Order.Bounds.Basic #align_import data.nat.prime from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # Prime numbers This file deals with prime numbers: natural numbers `p ≥ 2` whose only divisors are `p` and `1`. ## Important declarations - `Nat.Prime`: the predicate that expresses that a natural number `p` is prime - `Nat.Primes`: the subtype of natural numbers that are prime - `Nat.minFac n`: the minimal prime factor of a natural number `n ≠ 1` - `Nat.exists_infinite_primes`: Euclid's theorem that there exist infinitely many prime numbers. This also appears as `Nat.not_bddAbove_setOf_prime` and `Nat.infinite_setOf_prime` (the latter in `Data.Nat.PrimeFin`). - `Nat.prime_iff`: `Nat.Prime` coincides with the general definition of `Prime` - `Nat.irreducible_iff_nat_prime`: a non-unit natural number is only divisible by `1` iff it is prime -/ open Bool Subtype open Nat namespace Nat variable {n : ℕ} /-- `Nat.Prime p` means that `p` is a prime number, that is, a natural number at least 2 whose only divisors are `p` and `1`. -/ -- Porting note (#11180): removed @[pp_nodot] def Prime (p : ℕ) := Irreducible p #align nat.prime Nat.Prime theorem irreducible_iff_nat_prime (a : ℕ) : Irreducible a ↔ Nat.Prime a := Iff.rfl #align irreducible_iff_nat_prime Nat.irreducible_iff_nat_prime @[aesop safe destruct] theorem not_prime_zero : ¬Prime 0 | h => h.ne_zero rfl #align nat.not_prime_zero Nat.not_prime_zero @[aesop safe destruct] theorem not_prime_one : ¬Prime 1 | h => h.ne_one rfl #align nat.not_prime_one Nat.not_prime_one theorem Prime.ne_zero {n : ℕ} (h : Prime n) : n ≠ 0 := Irreducible.ne_zero h #align nat.prime.ne_zero Nat.Prime.ne_zero theorem Prime.pos {p : ℕ} (pp : Prime p) : 0 < p := Nat.pos_of_ne_zero pp.ne_zero #align nat.prime.pos Nat.Prime.pos theorem Prime.two_le : ∀ {p : ℕ}, Prime p → 2 ≤ p | 0, h => (not_prime_zero h).elim | 1, h => (not_prime_one h).elim | _ + 2, _ => le_add_self #align nat.prime.two_le Nat.Prime.two_le theorem Prime.one_lt {p : ℕ} : Prime p → 1 < p := Prime.two_le #align nat.prime.one_lt Nat.Prime.one_lt lemma Prime.one_le {p : ℕ} (hp : p.Prime) : 1 ≤ p := hp.one_lt.le instance Prime.one_lt' (p : ℕ) [hp : Fact p.Prime] : Fact (1 < p) := ⟨hp.1.one_lt⟩ #align nat.prime.one_lt' Nat.Prime.one_lt' theorem Prime.ne_one {p : ℕ} (hp : p.Prime) : p ≠ 1 := hp.one_lt.ne' #align nat.prime.ne_one Nat.Prime.ne_one
Mathlib/Data/Nat/Prime.lean
89
96
theorem Prime.eq_one_or_self_of_dvd {p : ℕ} (pp : p.Prime) (m : ℕ) (hm : m ∣ p) : m = 1 ∨ m = p := by
obtain ⟨n, hn⟩ := hm have := pp.isUnit_or_isUnit hn rw [Nat.isUnit_iff, Nat.isUnit_iff] at this apply Or.imp_right _ this rintro rfl rw [hn, mul_one]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Johannes Hölzl, Yury G. Kudryashov, Patrick Massot -/ import Mathlib.Algebra.GeomSum import Mathlib.Order.Filter.Archimedean import Mathlib.Order.Iterate import Mathlib.Topology.Algebra.Algebra import Mathlib.Topology.Algebra.InfiniteSum.Real #align_import analysis.specific_limits.basic from "leanprover-community/mathlib"@"57ac39bd365c2f80589a700f9fbb664d3a1a30c2" /-! # A collection of specific limit computations This file, by design, is independent of `NormedSpace` in the import hierarchy. It contains important specific limit computations in metric spaces, in ordered rings/fields, and in specific instances of these such as `ℝ`, `ℝ≥0` and `ℝ≥0∞`. -/ noncomputable section open scoped Classical open Set Function Filter Finset Metric open scoped Classical open Topology Nat uniformity NNReal ENNReal variable {α : Type*} {β : Type*} {ι : Type*} theorem tendsto_inverse_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ (n : ℝ)⁻¹) atTop (𝓝 0) := tendsto_inv_atTop_zero.comp tendsto_natCast_atTop_atTop #align tendsto_inverse_at_top_nhds_0_nat tendsto_inverse_atTop_nhds_zero_nat @[deprecated (since := "2024-01-31")] alias tendsto_inverse_atTop_nhds_0_nat := tendsto_inverse_atTop_nhds_zero_nat theorem tendsto_const_div_atTop_nhds_zero_nat (C : ℝ) : Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by simpa only [mul_zero] using tendsto_const_nhds.mul tendsto_inverse_atTop_nhds_zero_nat #align tendsto_const_div_at_top_nhds_0_nat tendsto_const_div_atTop_nhds_zero_nat @[deprecated (since := "2024-01-31")] alias tendsto_const_div_atTop_nhds_0_nat := tendsto_const_div_atTop_nhds_zero_nat theorem tendsto_one_div_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ 1/(n : ℝ)) atTop (𝓝 0) := tendsto_const_div_atTop_nhds_zero_nat 1 @[deprecated (since := "2024-01-31")] alias tendsto_one_div_atTop_nhds_0_nat := tendsto_one_div_atTop_nhds_zero_nat
Mathlib/Analysis/SpecificLimits/Basic.lean
51
54
theorem NNReal.tendsto_inverse_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ (n : ℝ≥0)⁻¹) atTop (𝓝 0) := by
rw [← NNReal.tendsto_coe] exact _root_.tendsto_inverse_atTop_nhds_zero_nat
/- Copyright (c) 2023 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.RingTheory.DedekindDomain.Dvr import Mathlib.RingTheory.DedekindDomain.Ideal #align_import ring_theory.dedekind_domain.pid from "leanprover-community/mathlib"@"6010cf523816335f7bae7f8584cb2edaace73940" /-! # Criteria under which a Dedekind domain is a PID This file contains some results that we can use to test wether all ideals in a Dedekind domain are principal. ## Main results * `Ideal.IsPrincipal.of_finite_maximals_of_isUnit`: an invertible ideal in a commutative ring with finitely many maximal ideals, is a principal ideal. * `IsPrincipalIdealRing.of_finite_primes`: if a Dedekind domain has finitely many prime ideals, it is a principal ideal domain. -/ variable {R : Type*} [CommRing R] open Ideal open UniqueFactorizationMonoid open scoped nonZeroDivisors open UniqueFactorizationMonoid /-- Let `P` be a prime ideal, `x ∈ P \ P²` and `x ∉ Q` for all prime ideals `Q ≠ P`. Then `P` is generated by `x`. -/ theorem Ideal.eq_span_singleton_of_mem_of_not_mem_sq_of_not_mem_prime_ne {P : Ideal R} (hP : P.IsPrime) [IsDedekindDomain R] {x : R} (x_mem : x ∈ P) (hxP2 : x ∉ P ^ 2) (hxQ : ∀ Q : Ideal R, IsPrime Q → Q ≠ P → x ∉ Q) : P = Ideal.span {x} := by letI := Classical.decEq (Ideal R) have hx0 : x ≠ 0 := by rintro rfl exact hxP2 (zero_mem _) by_cases hP0 : P = ⊥ · subst hP0 -- Porting note: was `simpa using hxP2` but that hypothesis didn't even seem relevant in Lean 3 rwa [eq_comm, span_singleton_eq_bot, ← mem_bot] have hspan0 : span ({x} : Set R) ≠ ⊥ := mt Ideal.span_singleton_eq_bot.mp hx0 have span_le := (Ideal.span_singleton_le_iff_mem _).mpr x_mem refine associated_iff_eq.mp ((associated_iff_normalizedFactors_eq_normalizedFactors hP0 hspan0).mpr (le_antisymm ((dvd_iff_normalizedFactors_le_normalizedFactors hP0 hspan0).mp ?_) ?_)) · rwa [Ideal.dvd_iff_le, Ideal.span_singleton_le_iff_mem] simp only [normalizedFactors_irreducible (Ideal.prime_of_isPrime hP0 hP).irreducible, normalize_eq, Multiset.le_iff_count, Multiset.count_singleton] intro Q split_ifs with hQ · subst hQ refine (Ideal.count_normalizedFactors_eq ?_ ?_).le <;> simp only [Ideal.span_singleton_le_iff_mem, pow_one] <;> assumption by_cases hQp : IsPrime Q · refine (Ideal.count_normalizedFactors_eq ?_ ?_).le <;> -- Porting note: included `zero_add` in the simp arguments simp only [Ideal.span_singleton_le_iff_mem, zero_add, pow_one, pow_zero, one_eq_top, Submodule.mem_top] exact hxQ _ hQp hQ · exact (Multiset.count_eq_zero.mpr fun hQi => hQp (isPrime_of_prime (irreducible_iff_prime.mp (irreducible_of_normalized_factor _ hQi)))).le #align ideal.eq_span_singleton_of_mem_of_not_mem_sq_of_not_mem_prime_ne Ideal.eq_span_singleton_of_mem_of_not_mem_sq_of_not_mem_prime_ne -- Porting note: replaced three implicit coercions of `I` with explicit `(I : Submodule R A)`
Mathlib/RingTheory/DedekindDomain/PID.lean
78
102
theorem FractionalIdeal.isPrincipal_of_unit_of_comap_mul_span_singleton_eq_top {R A : Type*} [CommRing R] [CommRing A] [Algebra R A] {S : Submonoid R} [IsLocalization S A] (I : (FractionalIdeal S A)ˣ) {v : A} (hv : v ∈ (↑I⁻¹ : FractionalIdeal S A)) (h : Submodule.comap (Algebra.linearMap R A) ((I : Submodule R A) * Submodule.span R {v}) = ⊤) : Submodule.IsPrincipal (I : Submodule R A) := by
have hinv := I.mul_inv set J := Submodule.comap (Algebra.linearMap R A) ((I : Submodule R A) * Submodule.span R {v}) have hJ : IsLocalization.coeSubmodule A J = ↑I * Submodule.span R {v} := by -- Porting note: had to insert `val_eq_coe` into this rewrite. -- Arguably this is because `Subtype.ext_iff` is breaking the `FractionalIdeal` API. rw [Subtype.ext_iff, val_eq_coe, coe_mul, val_eq_coe, coe_one] at hinv apply Submodule.map_comap_eq_self rw [← Submodule.one_eq_range, ← hinv] exact Submodule.mul_le_mul_right ((Submodule.span_singleton_le_iff_mem _ _).2 hv) have : (1 : A) ∈ ↑I * Submodule.span R {v} := by rw [← hJ, h, IsLocalization.coeSubmodule_top, Submodule.mem_one] exact ⟨1, (algebraMap R _).map_one⟩ obtain ⟨w, hw, hvw⟩ := Submodule.mem_mul_span_singleton.1 this refine ⟨⟨w, ?_⟩⟩ rw [← FractionalIdeal.coe_spanSingleton S, ← inv_inv I, eq_comm] refine congr_arg coeToSubmodule (Units.eq_inv_of_mul_eq_one_left (le_antisymm ?_ ?_)) · conv_rhs => rw [← hinv, mul_comm] apply FractionalIdeal.mul_le_mul_left (FractionalIdeal.spanSingleton_le_iff_mem.mpr hw) · rw [FractionalIdeal.one_le, ← hvw, mul_comm] exact FractionalIdeal.mul_mem_mul hv (FractionalIdeal.mem_spanSingleton_self _ _)
/- 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]
Mathlib/MeasureTheory/Measure/Trim.lean
37
38
theorem trim_eq_self [MeasurableSpace α] {μ : Measure α} : μ.trim le_rfl = μ := by
simp [Measure.trim]
/- Copyright (c) 2020 James Arthur. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: James Arthur, Chris Hughes, Shing Tak Lam -/ import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv import Mathlib.Analysis.SpecialFunctions.Log.Basic #align_import analysis.special_functions.arsinh from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Inverse of the sinh function In this file we prove that sinh is bijective and hence has an inverse, arsinh. ## Main definitions - `Real.arsinh`: The inverse function of `Real.sinh`. - `Real.sinhEquiv`, `Real.sinhOrderIso`, `Real.sinhHomeomorph`: `Real.sinh` as an `Equiv`, `OrderIso`, and `Homeomorph`, respectively. ## Main Results - `Real.sinh_surjective`, `Real.sinh_bijective`: `Real.sinh` is surjective and bijective; - `Real.arsinh_injective`, `Real.arsinh_surjective`, `Real.arsinh_bijective`: `Real.arsinh` is injective, surjective, and bijective; - `Real.continuous_arsinh`, `Real.differentiable_arsinh`, `Real.contDiff_arsinh`: `Real.arsinh` is continuous, differentiable, and continuously differentiable; we also provide dot notation convenience lemmas like `Filter.Tendsto.arsinh` and `ContDiffAt.arsinh`. ## Tags arsinh, arcsinh, argsinh, asinh, sinh injective, sinh bijective, sinh surjective -/ noncomputable section open Function Filter Set open scoped Topology namespace Real variable {x y : ℝ} /-- `arsinh` is defined using a logarithm, `arsinh x = log (x + sqrt(1 + x^2))`. -/ -- @[pp_nodot] is no longer needed def arsinh (x : ℝ) := log (x + √(1 + x ^ 2)) #align real.arsinh Real.arsinh theorem exp_arsinh (x : ℝ) : exp (arsinh x) = x + √(1 + x ^ 2) := by apply exp_log rw [← neg_lt_iff_pos_add'] apply lt_sqrt_of_sq_lt simp #align real.exp_arsinh Real.exp_arsinh @[simp] theorem arsinh_zero : arsinh 0 = 0 := by simp [arsinh] #align real.arsinh_zero Real.arsinh_zero @[simp] theorem arsinh_neg (x : ℝ) : arsinh (-x) = -arsinh x := by rw [← exp_eq_exp, exp_arsinh, exp_neg, exp_arsinh] apply eq_inv_of_mul_eq_one_left rw [neg_sq, neg_add_eq_sub, add_comm x, mul_comm, ← sq_sub_sq, sq_sqrt, add_sub_cancel_right] exact add_nonneg zero_le_one (sq_nonneg _) #align real.arsinh_neg Real.arsinh_neg /-- `arsinh` is the right inverse of `sinh`. -/ @[simp] theorem sinh_arsinh (x : ℝ) : sinh (arsinh x) = x := by rw [sinh_eq, ← arsinh_neg, exp_arsinh, exp_arsinh, neg_sq]; field_simp #align real.sinh_arsinh Real.sinh_arsinh @[simp]
Mathlib/Analysis/SpecialFunctions/Arsinh.lean
83
84
theorem cosh_arsinh (x : ℝ) : cosh (arsinh x) = √(1 + x ^ 2) := by
rw [← sqrt_sq (cosh_pos _).le, cosh_sq', sinh_arsinh]
/- 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, Yury Kudryashov -/ import Mathlib.Topology.Order.LeftRightNhds /-! # Properties of LUB and GLB in an order topology -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) variable {α β γ : Type*} section OrderTopology variable [TopologicalSpace α] [TopologicalSpace β] [LinearOrder α] [LinearOrder β] [OrderTopology α] [OrderTopology β]
Mathlib/Topology/Order/IsLUB.lean
24
32
theorem IsLUB.frequently_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝[≤] a, x ∈ s := by
rcases hs with ⟨a', ha'⟩ intro h rcases (ha.1 ha').eq_or_lt with (rfl | ha'a) · exact h.self_of_nhdsWithin le_rfl ha' · rcases (mem_nhdsWithin_Iic_iff_exists_Ioc_subset' ha'a).1 h with ⟨b, hba, hb⟩ rcases ha.exists_between hba with ⟨b', hb's, hb'⟩ exact hb hb' hb's
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Fintype.Card import Mathlib.Data.Finset.Option #align_import data.fintype.option from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" /-! # fintype instances for option -/ assert_not_exists MonoidWithZero assert_not_exists MulAction open Function open Nat universe u v variable {α β γ : Type*} open Finset Function instance {α : Type*} [Fintype α] : Fintype (Option α) := ⟨Finset.insertNone univ, fun a => by simp⟩ theorem univ_option (α : Type*) [Fintype α] : (univ : Finset (Option α)) = insertNone univ := rfl #align univ_option univ_option @[simp] theorem Fintype.card_option {α : Type*} [Fintype α] : Fintype.card (Option α) = Fintype.card α + 1 := (Finset.card_cons (by simp)).trans <| congr_arg₂ _ (card_map _) rfl #align fintype.card_option Fintype.card_option /-- If `Option α` is a `Fintype` then so is `α` -/ def fintypeOfOption {α : Type*} [Fintype (Option α)] : Fintype α := ⟨Finset.eraseNone (Fintype.elems (α := Option α)), fun x => mem_eraseNone.mpr (Fintype.complete (some x))⟩ #align fintype_of_option fintypeOfOption /-- A type is a `Fintype` if its successor (using `Option`) is a `Fintype`. -/ def fintypeOfOptionEquiv [Fintype α] (f : α ≃ Option β) : Fintype β := haveI := Fintype.ofEquiv _ f fintypeOfOption #align fintype_of_option_equiv fintypeOfOptionEquiv namespace Fintype /-- A recursor principle for finite types, analogous to `Nat.rec`. It effectively says that every `Fintype` is either `Empty` or `Option α`, up to an `Equiv`. -/ def truncRecEmptyOption {P : Type u → Sort v} (of_equiv : ∀ {α β}, α ≃ β → P α → P β) (h_empty : P PEmpty) (h_option : ∀ {α} [Fintype α] [DecidableEq α], P α → P (Option α)) (α : Type u) [Fintype α] [DecidableEq α] : Trunc (P α) := by suffices ∀ n : ℕ, Trunc (P (ULift <| Fin n)) by apply Trunc.bind (this (Fintype.card α)) intro h apply Trunc.map _ (Fintype.truncEquivFin α) intro e exact of_equiv (Equiv.ulift.trans e.symm) h apply ind where -- Porting note: do a manual recursion, instead of `induction` tactic, -- to ensure the result is computable /-- Internal induction hypothesis -/ ind : ∀ n : ℕ, Trunc (P (ULift <| Fin n)) | Nat.zero => by have : card PEmpty = card (ULift (Fin 0)) := by simp only [card_fin, card_pempty, card_ulift] apply Trunc.bind (truncEquivOfCardEq this) intro e apply Trunc.mk exact of_equiv e h_empty | Nat.succ n => by have : card (Option (ULift (Fin n))) = card (ULift (Fin n.succ)) := by simp only [card_fin, card_option, card_ulift] apply Trunc.bind (truncEquivOfCardEq this) intro e apply Trunc.map _ (ind n) intro ih exact of_equiv e (h_option ih) #align fintype.trunc_rec_empty_option Fintype.truncRecEmptyOption -- Porting note: due to instance inference issues in `SetTheory.Cardinal.Basic` -- I had to explicitly name `h_fintype` in order to access it manually. -- was `[Fintype α]` /-- An induction principle for finite types, analogous to `Nat.rec`. It effectively says that every `Fintype` is either `Empty` or `Option α`, up to an `Equiv`. -/ @[elab_as_elim]
Mathlib/Data/Fintype/Option.lean
94
106
theorem induction_empty_option {P : ∀ (α : Type u) [Fintype α], Prop} (of_equiv : ∀ (α β) [Fintype β] (e : α ≃ β), @P α (@Fintype.ofEquiv α β ‹_› e.symm) → @P β ‹_›) (h_empty : P PEmpty) (h_option : ∀ (α) [Fintype α], P α → P (Option α)) (α : Type u) [h_fintype : Fintype α] : P α := by
obtain ⟨p⟩ := let f_empty := fun i => by convert h_empty let h_option : ∀ {α : Type u} [Fintype α] [DecidableEq α], (∀ (h : Fintype α), P α) → ∀ (h : Fintype (Option α)), P (Option α) := by rintro α hα - Pα hα' convert h_option α (Pα _) @truncRecEmptyOption (fun α => ∀ h, @P α h) (@fun α β e hα hβ => @of_equiv α β hβ e (hα _)) f_empty h_option α _ (Classical.decEq α) exact p _
/- Copyright (c) 2018 Kevin Buzzard, Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard, Patrick Massot This file is to a certain extent based on `quotient_module.lean` by Johannes Hölzl. -/ import Mathlib.Algebra.Group.Subgroup.Finite import Mathlib.Algebra.Group.Subgroup.Pointwise import Mathlib.GroupTheory.Congruence.Basic import Mathlib.GroupTheory.Coset #align_import group_theory.quotient_group from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Quotients of groups by normal subgroups This files develops the basic theory of quotients of groups by normal subgroups. In particular it proves Noether's first and second isomorphism theorems. ## Main definitions * `mk'`: the canonical group homomorphism `G →* G/N` given a normal subgroup `N` of `G`. * `lift φ`: the group homomorphism `G/N →* H` given a group homomorphism `φ : G →* H` such that `N ⊆ ker φ`. * `map f`: the group homomorphism `G/N →* H/M` given a group homomorphism `f : G →* H` such that `N ⊆ f⁻¹(M)`. ## Main statements * `QuotientGroup.quotientKerEquivRange`: Noether's first isomorphism theorem, an explicit isomorphism `G/ker φ → range φ` for every group homomorphism `φ : G →* H`. * `QuotientGroup.quotientInfEquivProdNormalQuotient`: Noether's second isomorphism theorem, an explicit isomorphism between `H/(H ∩ N)` and `(HN)/N` given a subgroup `H` and a normal subgroup `N` of a group `G`. * `QuotientGroup.quotientQuotientEquivQuotient`: Noether's third isomorphism theorem, the canonical isomorphism between `(G / N) / (M / N)` and `G / M`, where `N ≤ M`. ## Tags isomorphism theorems, quotient groups -/ open Function open scoped Pointwise universe u v w x namespace QuotientGroup variable {G : Type u} [Group G] (N : Subgroup G) [nN : N.Normal] {H : Type v} [Group H] {M : Type x} [Monoid M] /-- The congruence relation generated by a normal subgroup. -/ @[to_additive "The additive congruence relation generated by a normal additive subgroup."] protected def con : Con G where toSetoid := leftRel N mul' := @fun a b c d hab hcd => by rw [leftRel_eq] at hab hcd ⊢ dsimp only calc (a * c)⁻¹ * (b * d) = c⁻¹ * (a⁻¹ * b) * c⁻¹⁻¹ * (c⁻¹ * d) := by simp only [mul_inv_rev, mul_assoc, inv_mul_cancel_left] _ ∈ N := N.mul_mem (nN.conj_mem _ hab _) hcd #align quotient_group.con QuotientGroup.con #align quotient_add_group.con QuotientAddGroup.con @[to_additive] instance Quotient.group : Group (G ⧸ N) := (QuotientGroup.con N).group #align quotient_group.quotient.group QuotientGroup.Quotient.group #align quotient_add_group.quotient.add_group QuotientAddGroup.Quotient.addGroup /-- The group homomorphism from `G` to `G/N`. -/ @[to_additive "The additive group homomorphism from `G` to `G/N`."] def mk' : G →* G ⧸ N := MonoidHom.mk' QuotientGroup.mk fun _ _ => rfl #align quotient_group.mk' QuotientGroup.mk' #align quotient_add_group.mk' QuotientAddGroup.mk' @[to_additive (attr := simp)] theorem coe_mk' : (mk' N : G → G ⧸ N) = mk := rfl #align quotient_group.coe_mk' QuotientGroup.coe_mk' #align quotient_add_group.coe_mk' QuotientAddGroup.coe_mk' @[to_additive (attr := simp)] theorem mk'_apply (x : G) : mk' N x = x := rfl #align quotient_group.mk'_apply QuotientGroup.mk'_apply #align quotient_add_group.mk'_apply QuotientAddGroup.mk'_apply @[to_additive] theorem mk'_surjective : Surjective <| mk' N := @mk_surjective _ _ N #align quotient_group.mk'_surjective QuotientGroup.mk'_surjective #align quotient_add_group.mk'_surjective QuotientAddGroup.mk'_surjective @[to_additive] theorem mk'_eq_mk' {x y : G} : mk' N x = mk' N y ↔ ∃ z ∈ N, x * z = y := QuotientGroup.eq'.trans <| by simp only [← _root_.eq_inv_mul_iff_mul_eq, exists_prop, exists_eq_right] #align quotient_group.mk'_eq_mk' QuotientGroup.mk'_eq_mk' #align quotient_add_group.mk'_eq_mk' QuotientAddGroup.mk'_eq_mk' open scoped Pointwise in @[to_additive]
Mathlib/GroupTheory/QuotientGroup.lean
108
113
theorem sound (U : Set (G ⧸ N)) (g : N.op) : g • (mk' N) ⁻¹' U = (mk' N) ⁻¹' U := by
ext x simp only [Set.mem_preimage, Set.mem_smul_set_iff_inv_smul_mem] congr! 1 exact Quotient.sound ⟨g⁻¹, rfl⟩
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov, Heather Macbeth -/ import Mathlib.MeasureTheory.Function.SimpleFunc import Mathlib.MeasureTheory.Constructions.BorelSpace.Metrizable #align_import measure_theory.function.simple_func_dense from "leanprover-community/mathlib"@"7317149f12f55affbc900fc873d0d422485122b9" /-! # Density of simple functions Show that each Borel measurable function can be approximated pointwise by a sequence of simple functions. ## Main definitions * `MeasureTheory.SimpleFunc.nearestPt (e : ℕ → α) (N : ℕ) : α →ₛ ℕ`: the `SimpleFunc` sending each `x : α` to the point `e k` which is the nearest to `x` among `e 0`, ..., `e N`. * `MeasureTheory.SimpleFunc.approxOn (f : β → α) (hf : Measurable f) (s : Set α) (y₀ : α) (h₀ : y₀ ∈ s) [SeparableSpace s] (n : ℕ) : β →ₛ α` : a simple function that takes values in `s` and approximates `f`. ## Main results * `tendsto_approxOn` (pointwise convergence): If `f x ∈ s`, then the sequence of simple approximations `MeasureTheory.SimpleFunc.approxOn f hf s y₀ h₀ n`, evaluated at `x`, tends to `f x` as `n` tends to `∞`. ## Notations * `α →ₛ β` (local notation): the type of simple functions `α → β`. -/ open Set Function Filter TopologicalSpace ENNReal EMetric Finset open scoped Classical open Topology ENNReal MeasureTheory variable {α β ι E F 𝕜 : Type*} noncomputable section namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc /-! ### Pointwise approximation by simple functions -/ variable [MeasurableSpace α] [PseudoEMetricSpace α] [OpensMeasurableSpace α] /-- `nearestPtInd e N x` is the index `k` such that `e k` is the nearest point to `x` among the points `e 0`, ..., `e N`. If more than one point are at the same distance from `x`, then `nearestPtInd e N x` returns the least of their indexes. -/ noncomputable def nearestPtInd (e : ℕ → α) : ℕ → α →ₛ ℕ | 0 => const α 0 | N + 1 => piecewise (⋂ k ≤ N, { x | edist (e (N + 1)) x < edist (e k) x }) (MeasurableSet.iInter fun _ => MeasurableSet.iInter fun _ => measurableSet_lt measurable_edist_right measurable_edist_right) (const α <| N + 1) (nearestPtInd e N) #align measure_theory.simple_func.nearest_pt_ind MeasureTheory.SimpleFunc.nearestPtInd /-- `nearestPt e N x` is the nearest point to `x` among the points `e 0`, ..., `e N`. If more than one point are at the same distance from `x`, then `nearestPt e N x` returns the point with the least possible index. -/ noncomputable def nearestPt (e : ℕ → α) (N : ℕ) : α →ₛ α := (nearestPtInd e N).map e #align measure_theory.simple_func.nearest_pt MeasureTheory.SimpleFunc.nearestPt @[simp] theorem nearestPtInd_zero (e : ℕ → α) : nearestPtInd e 0 = const α 0 := rfl #align measure_theory.simple_func.nearest_pt_ind_zero MeasureTheory.SimpleFunc.nearestPtInd_zero @[simp] theorem nearestPt_zero (e : ℕ → α) : nearestPt e 0 = const α (e 0) := rfl #align measure_theory.simple_func.nearest_pt_zero MeasureTheory.SimpleFunc.nearestPt_zero theorem nearestPtInd_succ (e : ℕ → α) (N : ℕ) (x : α) : nearestPtInd e (N + 1) x = if ∀ k ≤ N, edist (e (N + 1)) x < edist (e k) x then N + 1 else nearestPtInd e N x := by simp only [nearestPtInd, coe_piecewise, Set.piecewise] congr simp #align measure_theory.simple_func.nearest_pt_ind_succ MeasureTheory.SimpleFunc.nearestPtInd_succ theorem nearestPtInd_le (e : ℕ → α) (N : ℕ) (x : α) : nearestPtInd e N x ≤ N := by induction' N with N ihN; · simp simp only [nearestPtInd_succ] split_ifs exacts [le_rfl, ihN.trans N.le_succ] #align measure_theory.simple_func.nearest_pt_ind_le MeasureTheory.SimpleFunc.nearestPtInd_le
Mathlib/MeasureTheory/Function/SimpleFuncDense.lean
102
113
theorem edist_nearestPt_le (e : ℕ → α) (x : α) {k N : ℕ} (hk : k ≤ N) : edist (nearestPt e N x) x ≤ edist (e k) x := by
induction' N with N ihN generalizing k · simp [nonpos_iff_eq_zero.1 hk, le_refl] · simp only [nearestPt, nearestPtInd_succ, map_apply] split_ifs with h · rcases hk.eq_or_lt with (rfl | hk) exacts [le_rfl, (h k (Nat.lt_succ_iff.1 hk)).le] · push_neg at h rcases h with ⟨l, hlN, hxl⟩ rcases hk.eq_or_lt with (rfl | hk) exacts [(ihN hlN).trans hxl, ihN (Nat.lt_succ_iff.1 hk)]
/- Copyright (c) 2020 Johan Commelin, Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Robert Y. Lewis -/ import Mathlib.NumberTheory.Padics.PadicIntegers import Mathlib.RingTheory.ZMod #align_import number_theory.padics.ring_homs from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" /-! # Relating `ℤ_[p]` to `ZMod (p ^ n)` In this file we establish connections between the `p`-adic integers $\mathbb{Z}_p$ and the integers modulo powers of `p`, $\mathbb{Z}/p^n\mathbb{Z}$. ## Main declarations We show that $\mathbb{Z}_p$ has a ring hom to $\mathbb{Z}/p^n\mathbb{Z}$ for each `n`. The case for `n = 1` is handled separately, since it is used in the general construction and we may want to use it without the `^1` getting in the way. * `PadicInt.toZMod`: ring hom to `ZMod p` * `PadicInt.toZModPow`: ring hom to `ZMod (p^n)` * `PadicInt.ker_toZMod` / `PadicInt.ker_toZModPow`: the kernels of these maps are the ideals generated by `p^n` We also establish the universal property of $\mathbb{Z}_p$ as a projective limit. Given a family of compatible ring homs $f_k : R \to \mathbb{Z}/p^n\mathbb{Z}$, there is a unique limit $R \to \mathbb{Z}_p$. * `PadicInt.lift`: the limit function * `PadicInt.lift_spec` / `PadicInt.lift_unique`: the universal property ## Implementation notes The ring hom constructions go through an auxiliary constructor `PadicInt.toZModHom`, which removes some boilerplate code. -/ noncomputable section open scoped Classical open Nat LocalRing Padic namespace PadicInt variable {p : ℕ} [hp_prime : Fact p.Prime] section RingHoms /-! ### Ring homomorphisms to `ZMod p` and `ZMod (p ^ n)` -/ variable (p) (r : ℚ) /-- `modPart p r` is an integer that satisfies `‖(r - modPart p r : ℚ_[p])‖ < 1` when `‖(r : ℚ_[p])‖ ≤ 1`, see `PadicInt.norm_sub_modPart`. It is the unique non-negative integer that is `< p` with this property. (Note that this definition assumes `r : ℚ`. See `PadicInt.zmodRepr` for a version that takes values in `ℕ` and works for arbitrary `x : ℤ_[p]`.) -/ def modPart : ℤ := r.num * gcdA r.den p % p #align padic_int.mod_part PadicInt.modPart variable {p} theorem modPart_lt_p : modPart p r < p := by convert Int.emod_lt _ _ · simp · exact mod_cast hp_prime.1.ne_zero #align padic_int.mod_part_lt_p PadicInt.modPart_lt_p theorem modPart_nonneg : 0 ≤ modPart p r := Int.emod_nonneg _ <| mod_cast hp_prime.1.ne_zero #align padic_int.mod_part_nonneg PadicInt.modPart_nonneg theorem isUnit_den (r : ℚ) (h : ‖(r : ℚ_[p])‖ ≤ 1) : IsUnit (r.den : ℤ_[p]) := by rw [isUnit_iff] apply le_antisymm (r.den : ℤ_[p]).2 rw [← not_lt, coe_natCast] intro norm_denom_lt have hr : ‖(r * r.den : ℚ_[p])‖ = ‖(r.num : ℚ_[p])‖ := by congr rw_mod_cast [@Rat.mul_den_eq_num r] rw [padicNormE.mul] at hr have key : ‖(r.num : ℚ_[p])‖ < 1 := by calc _ = _ := hr.symm _ < 1 * 1 := mul_lt_mul' h norm_denom_lt (norm_nonneg _) zero_lt_one _ = 1 := mul_one 1 have : ↑p ∣ r.num ∧ (p : ℤ) ∣ r.den := by simp only [← norm_int_lt_one_iff_dvd, ← padic_norm_e_of_padicInt] exact ⟨key, norm_denom_lt⟩ apply hp_prime.1.not_dvd_one rwa [← r.reduced.gcd_eq_one, Nat.dvd_gcd_iff, ← Int.natCast_dvd, ← Int.natCast_dvd_natCast] #align padic_int.is_unit_denom PadicInt.isUnit_den theorem norm_sub_modPart_aux (r : ℚ) (h : ‖(r : ℚ_[p])‖ ≤ 1) : ↑p ∣ r.num - r.num * r.den.gcdA p % p * ↑r.den := by rw [← ZMod.intCast_zmod_eq_zero_iff_dvd] simp only [Int.cast_natCast, ZMod.natCast_mod, Int.cast_mul, Int.cast_sub] have := congr_arg (fun x => x % p : ℤ → ZMod p) (gcd_eq_gcd_ab r.den p) simp only [Int.cast_natCast, CharP.cast_eq_zero, EuclideanDomain.mod_zero, Int.cast_add, Int.cast_mul, zero_mul, add_zero] at this push_cast rw [mul_right_comm, mul_assoc, ← this] suffices rdcp : r.den.Coprime p by rw [rdcp.gcd_eq_one] simp only [mul_one, cast_one, sub_self] apply Coprime.symm apply (coprime_or_dvd_of_prime hp_prime.1 _).resolve_right rw [← Int.natCast_dvd_natCast, ← norm_int_lt_one_iff_dvd, not_lt] apply ge_of_eq rw [← isUnit_iff] exact isUnit_den r h #align padic_int.norm_sub_mod_part_aux PadicInt.norm_sub_modPart_aux
Mathlib/NumberTheory/Padics/RingHoms.lean
124
134
theorem norm_sub_modPart (h : ‖(r : ℚ_[p])‖ ≤ 1) : ‖(⟨r, h⟩ - modPart p r : ℤ_[p])‖ < 1 := by
let n := modPart p r rw [norm_lt_one_iff_dvd, ← (isUnit_den r h).dvd_mul_right] suffices ↑p ∣ r.num - n * r.den by convert (Int.castRingHom ℤ_[p]).map_dvd this simp only [sub_mul, Int.cast_natCast, eq_intCast, Int.cast_mul, sub_left_inj, Int.cast_sub] apply Subtype.coe_injective simp only [coe_mul, Subtype.coe_mk, coe_natCast] rw_mod_cast [@Rat.mul_den_eq_num r] rfl exact norm_sub_modPart_aux r h
/- Copyright (c) 2023 Lawrence Wu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Lawrence Wu -/ import Mathlib.Algebra.Module.Submodule.Lattice import Mathlib.Data.ZMod.Basic import Mathlib.Order.OmegaCompletePartialOrder /-! # The `ZMod n`-module structure on Abelian groups whose elements have order dividing `n` -/ variable {n : ℕ} {M M₁ : Type*} /-- The `ZMod n`-module structure on commutative monoids whose elements have order dividing `n ≠ 0`. Also implies a group structure via `Module.addCommMonoidToAddCommGroup`. See note [reducible non-instances]. -/ abbrev AddCommMonoid.zmodModule [NeZero n] [AddCommMonoid M] (h : ∀ (x : M), n • x = 0) : Module (ZMod n) M := by have h_mod (c : ℕ) (x : M) : (c % n) • x = c • x := by suffices (c % n + c / n * n) • x = c • x by rwa [add_nsmul, mul_nsmul, h, add_zero] at this rw [Nat.mod_add_div'] have := NeZero.ne n match n with | n + 1 => exact { smul := fun (c : Fin _) x ↦ c.val • x smul_zero := fun _ ↦ nsmul_zero _ zero_smul := fun _ ↦ zero_nsmul _ smul_add := fun _ _ _ ↦ nsmul_add _ _ _ one_smul := fun _ ↦ (h_mod _ _).trans <| one_nsmul _ add_smul := fun _ _ _ ↦ (h_mod _ _).trans <| add_nsmul _ _ _ mul_smul := fun _ _ _ ↦ (h_mod _ _).trans <| mul_nsmul' _ _ _ } /-- The `ZMod n`-module structure on Abelian groups whose elements have order dividing `n`. See note [reducible non-instances]. -/ abbrev AddCommGroup.zmodModule {G : Type*} [AddCommGroup G] (h : ∀ (x : G), n • x = 0) : Module (ZMod n) G := match n with | 0 => AddCommGroup.intModule G | _ + 1 => AddCommMonoid.zmodModule h variable {F S : Type*} [AddCommGroup M] [AddCommGroup M₁] [FunLike F M M₁] [AddMonoidHomClass F M M₁] [Module (ZMod n) M] [Module (ZMod n) M₁] [SetLike S M] [AddSubgroupClass S M] {x : M} {K : S} namespace ZMod theorem map_smul (f : F) (c : ZMod n) (x : M) : f (c • x) = c • f x := by rw [← ZMod.intCast_zmod_cast c] exact map_intCast_smul f _ _ (cast c) x
Mathlib/Data/ZMod/Module.lean
54
56
theorem smul_mem (hx : x ∈ K) (c : ZMod n) : c • x ∈ K := by
rw [← ZMod.intCast_zmod_cast c, ← zsmul_eq_smul_cast] exact zsmul_mem hx (cast c)
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.MeasureTheory.Measure.MeasureSpace import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic #align_import measure_theory.measure.open_pos from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Measures positive on nonempty opens In this file we define a typeclass for measures that are positive on nonempty opens, see `MeasureTheory.Measure.IsOpenPosMeasure`. Examples include (additive) Haar measures, as well as measures that have positive density with respect to a Haar measure. We also prove some basic facts about these measures. -/ open Topology ENNReal MeasureTheory open Set Function Filter namespace MeasureTheory namespace Measure section Basic variable {X Y : Type*} [TopologicalSpace X] {m : MeasurableSpace X} [TopologicalSpace Y] [T2Space Y] (μ ν : Measure X) /-- A measure is said to be `IsOpenPosMeasure` if it is positive on nonempty open sets. -/ class IsOpenPosMeasure : Prop where open_pos : ∀ U : Set X, IsOpen U → U.Nonempty → μ U ≠ 0 #align measure_theory.measure.is_open_pos_measure MeasureTheory.Measure.IsOpenPosMeasure variable [IsOpenPosMeasure μ] {s U F : Set X} {x : X} theorem _root_.IsOpen.measure_ne_zero (hU : IsOpen U) (hne : U.Nonempty) : μ U ≠ 0 := IsOpenPosMeasure.open_pos U hU hne #align is_open.measure_ne_zero IsOpen.measure_ne_zero theorem _root_.IsOpen.measure_pos (hU : IsOpen U) (hne : U.Nonempty) : 0 < μ U := (hU.measure_ne_zero μ hne).bot_lt #align is_open.measure_pos IsOpen.measure_pos instance (priority := 100) [Nonempty X] : NeZero μ := ⟨measure_univ_pos.mp <| isOpen_univ.measure_pos μ univ_nonempty⟩ theorem _root_.IsOpen.measure_pos_iff (hU : IsOpen U) : 0 < μ U ↔ U.Nonempty := ⟨fun h => nonempty_iff_ne_empty.2 fun he => h.ne' <| he.symm ▸ measure_empty, hU.measure_pos μ⟩ #align is_open.measure_pos_iff IsOpen.measure_pos_iff
Mathlib/MeasureTheory/Measure/OpenPos.lean
57
59
theorem _root_.IsOpen.measure_eq_zero_iff (hU : IsOpen U) : μ U = 0 ↔ U = ∅ := by
simpa only [not_lt, nonpos_iff_eq_zero, not_nonempty_iff_eq_empty] using not_congr (hU.measure_pos_iff μ)
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.Deriv.Pow import Mathlib.Analysis.Calculus.Deriv.Inv #align_import analysis.calculus.deriv.zpow from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Derivatives of `x ^ m`, `m : ℤ` In this file we prove theorems about (iterated) derivatives of `x ^ m`, `m : ℤ`. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `analysis/calculus/deriv/basic`. ## Keywords derivative, power -/ universe u v w open scoped Classical open Topology Filter open Filter Asymptotics Set variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] variable {E : Type v} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {x : 𝕜} variable {s : Set 𝕜} variable {m : ℤ} /-! ### Derivative of `x ↦ x^m` for `m : ℤ` -/ theorem hasStrictDerivAt_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) : HasStrictDerivAt (fun x => x ^ m) ((m : 𝕜) * x ^ (m - 1)) x := by have : ∀ m : ℤ, 0 < m → HasStrictDerivAt (· ^ m) ((m : 𝕜) * x ^ (m - 1)) x := fun m hm ↦ by lift m to ℕ using hm.le simp only [zpow_natCast, Int.cast_natCast] convert hasStrictDerivAt_pow m x using 2 rw [← Int.ofNat_one, ← Int.ofNat_sub, zpow_natCast] norm_cast at hm rcases lt_trichotomy m 0 with (hm | hm | hm) · have hx : x ≠ 0 := h.resolve_right hm.not_le have := (hasStrictDerivAt_inv ?_).scomp _ (this (-m) (neg_pos.2 hm)) <;> [skip; exact zpow_ne_zero _ hx] simp only [(· ∘ ·), zpow_neg, one_div, inv_inv, smul_eq_mul] at this convert this using 1 rw [sq, mul_inv, inv_inv, Int.cast_neg, neg_mul, neg_mul_neg, ← zpow_add₀ hx, mul_assoc, ← zpow_add₀ hx] congr abel · simp only [hm, zpow_zero, Int.cast_zero, zero_mul, hasStrictDerivAt_const] · exact this m hm #align has_strict_deriv_at_zpow hasStrictDerivAt_zpow theorem hasDerivAt_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) : HasDerivAt (fun x => x ^ m) ((m : 𝕜) * x ^ (m - 1)) x := (hasStrictDerivAt_zpow m x h).hasDerivAt #align has_deriv_at_zpow hasDerivAt_zpow theorem hasDerivWithinAt_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) (s : Set 𝕜) : HasDerivWithinAt (fun x => x ^ m) ((m : 𝕜) * x ^ (m - 1)) s x := (hasDerivAt_zpow m x h).hasDerivWithinAt #align has_deriv_within_at_zpow hasDerivWithinAt_zpow theorem differentiableAt_zpow : DifferentiableAt 𝕜 (fun x => x ^ m) x ↔ x ≠ 0 ∨ 0 ≤ m := ⟨fun H => NormedField.continuousAt_zpow.1 H.continuousAt, fun H => (hasDerivAt_zpow m x H).differentiableAt⟩ #align differentiable_at_zpow differentiableAt_zpow theorem differentiableWithinAt_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) : DifferentiableWithinAt 𝕜 (fun x => x ^ m) s x := (differentiableAt_zpow.mpr h).differentiableWithinAt #align differentiable_within_at_zpow differentiableWithinAt_zpow theorem differentiableOn_zpow (m : ℤ) (s : Set 𝕜) (h : (0 : 𝕜) ∉ s ∨ 0 ≤ m) : DifferentiableOn 𝕜 (fun x => x ^ m) s := fun x hxs => differentiableWithinAt_zpow m x <| h.imp_left <| ne_of_mem_of_not_mem hxs #align differentiable_on_zpow differentiableOn_zpow
Mathlib/Analysis/Calculus/Deriv/ZPow.lean
86
92
theorem deriv_zpow (m : ℤ) (x : 𝕜) : deriv (fun x => x ^ m) x = m * x ^ (m - 1) := by
by_cases H : x ≠ 0 ∨ 0 ≤ m · exact (hasDerivAt_zpow m x H).deriv · rw [deriv_zero_of_not_differentiableAt (mt differentiableAt_zpow.1 H)] push_neg at H rcases H with ⟨rfl, hm⟩ rw [zero_zpow _ ((sub_one_lt _).trans hm).ne, mul_zero]
/- Copyright (c) 2022 Yuyang Zhao. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuyang Zhao -/ import Batteries.Classes.Order namespace Batteries.PairingHeapImp /-- A `Heap` is the nodes of the pairing heap. Each node have two pointers: `child` going to the first child of this node, and `sibling` goes to the next sibling of this tree. So it actually encodes a forest where each node has children `node.child`, `node.child.sibling`, `node.child.sibling.sibling`, etc. Each edge in this forest denotes a `le a b` relation that has been checked, so the root is smaller than everything else under it. -/ inductive Heap (α : Type u) where /-- An empty forest, which has depth `0`. -/ | nil : Heap α /-- A forest consists of a root `a`, a forest `child` elements greater than `a`, and another forest `sibling`. -/ | node (a : α) (child sibling : Heap α) : Heap α deriving Repr /-- `O(n)`. The number of elements in the heap. -/ def Heap.size : Heap α → Nat | .nil => 0 | .node _ c s => c.size + 1 + s.size /-- A node containing a single element `a`. -/ def Heap.singleton (a : α) : Heap α := .node a .nil .nil /-- `O(1)`. Is the heap empty? -/ def Heap.isEmpty : Heap α → Bool | .nil => true | _ => false /-- `O(1)`. Merge two heaps. Ignore siblings. -/ @[specialize] def Heap.merge (le : α → α → Bool) : Heap α → Heap α → Heap α | .nil, .nil => .nil | .nil, .node a₂ c₂ _ => .node a₂ c₂ .nil | .node a₁ c₁ _, .nil => .node a₁ c₁ .nil | .node a₁ c₁ _, .node a₂ c₂ _ => if le a₁ a₂ then .node a₁ (.node a₂ c₂ c₁) .nil else .node a₂ (.node a₁ c₁ c₂) .nil /-- Auxiliary for `Heap.deleteMin`: merge the forest in pairs. -/ @[specialize] def Heap.combine (le : α → α → Bool) : Heap α → Heap α | h₁@(.node _ _ h₂@(.node _ _ s)) => merge le (merge le h₁ h₂) (s.combine le) | h => h /-- `O(1)`. Get the smallest element in the heap, including the passed in value `a`. -/ @[inline] def Heap.headD (a : α) : Heap α → α | .nil => a | .node a _ _ => a /-- `O(1)`. Get the smallest element in the heap, if it has an element. -/ @[inline] def Heap.head? : Heap α → Option α | .nil => none | .node a _ _ => some a /-- Amortized `O(log n)`. Find and remove the the minimum element from the heap. -/ @[inline] def Heap.deleteMin (le : α → α → Bool) : Heap α → Option (α × Heap α) | .nil => none | .node a c _ => (a, combine le c) /-- Amortized `O(log n)`. Get the tail of the pairing heap after removing the minimum element. -/ @[inline] def Heap.tail? (le : α → α → Bool) (h : Heap α) : Option (Heap α) := deleteMin le h |>.map (·.snd) /-- Amortized `O(log n)`. Remove the minimum element of the heap. -/ @[inline] def Heap.tail (le : α → α → Bool) (h : Heap α) : Heap α := tail? le h |>.getD .nil /-- A predicate says there is no more than one tree. -/ inductive Heap.NoSibling : Heap α → Prop /-- An empty heap is no more than one tree. -/ | nil : NoSibling .nil /-- Or there is exactly one tree. -/ | node (a c) : NoSibling (.node a c .nil) instance : Decidable (Heap.NoSibling s) := match s with | .nil => isTrue .nil | .node a c .nil => isTrue (.node a c) | .node _ _ (.node _ _ _) => isFalse nofun
.lake/packages/batteries/Batteries/Data/PairingHeap.lean
90
93
theorem Heap.noSibling_merge (le) (s₁ s₂ : Heap α) : (s₁.merge le s₂).NoSibling := by
unfold merge (split <;> try split) <;> constructor
/- 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 -/ import Mathlib.Algebra.Group.Even import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Algebra.Order.Sub.Defs #align_import algebra.order.sub.canonical from "leanprover-community/mathlib"@"62a5626868683c104774de8d85b9855234ac807c" /-! # Lemmas about subtraction in canonically ordered monoids -/ variable {α : Type*} section ExistsAddOfLE variable [AddCommSemigroup α] [PartialOrder α] [ExistsAddOfLE α] [CovariantClass α α (· + ·) (· ≤ ·)] [Sub α] [OrderedSub α] {a b c d : α} @[simp] theorem add_tsub_cancel_of_le (h : a ≤ b) : a + (b - a) = b := by refine le_antisymm ?_ le_add_tsub obtain ⟨c, rfl⟩ := exists_add_of_le h exact add_le_add_left add_tsub_le_left a #align add_tsub_cancel_of_le add_tsub_cancel_of_le theorem tsub_add_cancel_of_le (h : a ≤ b) : b - a + a = b := by rw [add_comm] exact add_tsub_cancel_of_le h #align tsub_add_cancel_of_le tsub_add_cancel_of_le theorem add_le_of_le_tsub_right_of_le (h : b ≤ c) (h2 : a ≤ c - b) : a + b ≤ c := (add_le_add_right h2 b).trans_eq <| tsub_add_cancel_of_le h #align add_le_of_le_tsub_right_of_le add_le_of_le_tsub_right_of_le theorem add_le_of_le_tsub_left_of_le (h : a ≤ c) (h2 : b ≤ c - a) : a + b ≤ c := (add_le_add_left h2 a).trans_eq <| add_tsub_cancel_of_le h #align add_le_of_le_tsub_left_of_le add_le_of_le_tsub_left_of_le theorem tsub_le_tsub_iff_right (h : c ≤ b) : a - c ≤ b - c ↔ a ≤ b := by rw [tsub_le_iff_right, tsub_add_cancel_of_le h] #align tsub_le_tsub_iff_right tsub_le_tsub_iff_right theorem tsub_left_inj (h1 : c ≤ a) (h2 : c ≤ b) : a - c = b - c ↔ a = b := by simp_rw [le_antisymm_iff, tsub_le_tsub_iff_right h1, tsub_le_tsub_iff_right h2] #align tsub_left_inj tsub_left_inj theorem tsub_inj_left (h₁ : a ≤ b) (h₂ : a ≤ c) : b - a = c - a → b = c := (tsub_left_inj h₁ h₂).1 #align tsub_inj_left tsub_inj_left /-- See `lt_of_tsub_lt_tsub_right` for a stronger statement in a linear order. -/
Mathlib/Algebra/Order/Sub/Canonical.lean
57
60
theorem lt_of_tsub_lt_tsub_right_of_le (h : c ≤ b) (h2 : a - c < b - c) : a < b := by
refine ((tsub_le_tsub_iff_right h).mp h2.le).lt_of_ne ?_ rintro rfl exact h2.false
/- Copyright (c) 2021 Ashvni Narayanan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ashvni Narayanan, David Loeffler -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Choose.Cast import Mathlib.NumberTheory.Bernoulli #align_import number_theory.bernoulli_polynomials from "leanprover-community/mathlib"@"ca3d21f7f4fd613c2a3c54ac7871163e1e5ecb3a" /-! # Bernoulli polynomials The [Bernoulli polynomials](https://en.wikipedia.org/wiki/Bernoulli_polynomials) are an important tool obtained from Bernoulli numbers. ## Mathematical overview The $n$-th Bernoulli polynomial is defined as $$ B_n(X) = ∑_{k = 0}^n {n \choose k} (-1)^k B_k X^{n - k} $$ where $B_k$ is the $k$-th Bernoulli number. The Bernoulli polynomials are generating functions, $$ \frac{t e^{tX} }{ e^t - 1} = ∑_{n = 0}^{\infty} B_n(X) \frac{t^n}{n!} $$ ## Implementation detail Bernoulli polynomials are defined using `bernoulli`, the Bernoulli numbers. ## Main theorems - `sum_bernoulli`: The sum of the $k^\mathrm{th}$ Bernoulli polynomial with binomial coefficients up to `n` is `(n + 1) * X^n`. - `Polynomial.bernoulli_generating_function`: The Bernoulli polynomials act as generating functions for the exponential. ## TODO - `bernoulli_eval_one_neg` : $$ B_n(1 - x) = (-1)^n B_n(x) $$ -/ noncomputable section open Nat Polynomial open Nat Finset namespace Polynomial /-- The Bernoulli polynomials are defined in terms of the negative Bernoulli numbers. -/ def bernoulli (n : ℕ) : ℚ[X] := ∑ i ∈ range (n + 1), Polynomial.monomial (n - i) (_root_.bernoulli i * choose n i) #align polynomial.bernoulli Polynomial.bernoulli theorem bernoulli_def (n : ℕ) : bernoulli n = ∑ i ∈ range (n + 1), Polynomial.monomial i (_root_.bernoulli (n - i) * choose n i) := by rw [← sum_range_reflect, add_succ_sub_one, add_zero, bernoulli] apply sum_congr rfl rintro x hx rw [mem_range_succ_iff] at hx rw [choose_symm hx, tsub_tsub_cancel_of_le hx] #align polynomial.bernoulli_def Polynomial.bernoulli_def /- ### examples -/ section Examples @[simp] theorem bernoulli_zero : bernoulli 0 = 1 := by simp [bernoulli] #align polynomial.bernoulli_zero Polynomial.bernoulli_zero @[simp]
Mathlib/NumberTheory/BernoulliPolynomials.lean
76
82
theorem bernoulli_eval_zero (n : ℕ) : (bernoulli n).eval 0 = _root_.bernoulli n := by
rw [bernoulli, eval_finset_sum, sum_range_succ] have : ∑ x ∈ range n, _root_.bernoulli x * n.choose x * 0 ^ (n - x) = 0 := by apply sum_eq_zero fun x hx => _ intros x hx simp [tsub_eq_zero_iff_le, mem_range.1 hx] simp [this]
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen, Filippo A. E. Nuccio -/ import Mathlib.RingTheory.Localization.Integer import Mathlib.RingTheory.Localization.Submodule #align_import ring_theory.fractional_ideal from "leanprover-community/mathlib"@"ed90a7d327c3a5caf65a6faf7e8a0d63c4605df7" /-! # Fractional ideals This file defines fractional ideals of an integral domain and proves basic facts about them. ## Main definitions Let `S` be a submonoid of an integral domain `R` and `P` the localization of `R` at `S`. * `IsFractional` defines which `R`-submodules of `P` are fractional ideals * `FractionalIdeal S P` is the type of fractional ideals in `P` * a coercion `coeIdeal : Ideal R → FractionalIdeal S P` * `CommSemiring (FractionalIdeal S P)` instance: the typical ideal operations generalized to fractional ideals * `Lattice (FractionalIdeal S P)` instance ## Main statements * `mul_left_mono` and `mul_right_mono` state that ideal multiplication is monotone * `mul_div_self_cancel_iff` states that `1 / I` is the inverse of `I` if one exists ## Implementation notes Fractional ideals are considered equal when they contain the same elements, independent of the denominator `a : R` such that `a I ⊆ R`. Thus, we define `FractionalIdeal` to be the subtype of the predicate `IsFractional`, instead of having `FractionalIdeal` be a structure of which `a` is a field. Most definitions in this file specialize operations from submodules to fractional ideals, proving that the result of this operation is fractional if the input is fractional. Exceptions to this rule are defining `(+) := (⊔)` and `⊥ := 0`, in order to re-use their respective proof terms. We can still use `simp` to show `↑I + ↑J = ↑(I + J)` and `↑⊥ = ↑0`. Many results in fact do not need that `P` is a localization, only that `P` is an `R`-algebra. We omit the `IsLocalization` parameter whenever this is practical. Similarly, we don't assume that the localization is a field until we need it to define ideal quotients. When this assumption is needed, we replace `S` with `R⁰`, making the localization a field. ## References * https://en.wikipedia.org/wiki/Fractional_ideal ## Tags fractional ideal, fractional ideals, invertible ideal -/ open IsLocalization Pointwise nonZeroDivisors section Defs variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P] variable [Algebra R P] variable (S) /-- A submodule `I` is a fractional ideal if `a I ⊆ R` for some `a ≠ 0`. -/ def IsFractional (I : Submodule R P) := ∃ a ∈ S, ∀ b ∈ I, IsInteger R (a • b) #align is_fractional IsFractional variable (P) /-- The fractional ideals of a domain `R` are ideals of `R` divided by some `a ∈ R`. More precisely, let `P` be a localization of `R` at some submonoid `S`, then a fractional ideal `I ⊆ P` is an `R`-submodule of `P`, such that there is a nonzero `a : R` with `a I ⊆ R`. -/ def FractionalIdeal := { I : Submodule R P // IsFractional S I } #align fractional_ideal FractionalIdeal end Defs namespace FractionalIdeal open Set Submodule variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P] variable [Algebra R P] [loc : IsLocalization S P] /-- Map a fractional ideal `I` to a submodule by forgetting that `∃ a, a I ⊆ R`. This implements the coercion `FractionalIdeal S P → Submodule R P`. -/ @[coe] def coeToSubmodule (I : FractionalIdeal S P) : Submodule R P := I.val /-- Map a fractional ideal `I` to a submodule by forgetting that `∃ a, a I ⊆ R`. This coercion is typically called `coeToSubmodule` in lemma names (or `coe` when the coercion is clear from the context), not to be confused with `IsLocalization.coeSubmodule : Ideal R → Submodule R P` (which we use to define `coe : Ideal R → FractionalIdeal S P`). -/ instance : CoeOut (FractionalIdeal S P) (Submodule R P) := ⟨coeToSubmodule⟩ protected theorem isFractional (I : FractionalIdeal S P) : IsFractional S (I : Submodule R P) := I.prop #align fractional_ideal.is_fractional FractionalIdeal.isFractional /-- An element of `S` such that `I.den • I = I.num`, see `FractionalIdeal.num` and `FractionalIdeal.den_mul_self_eq_num`. -/ noncomputable def den (I : FractionalIdeal S P) : S := ⟨I.2.choose, I.2.choose_spec.1⟩ /-- An ideal of `R` such that `I.den • I = I.num`, see `FractionalIdeal.den` and `FractionalIdeal.den_mul_self_eq_num`. -/ noncomputable def num (I : FractionalIdeal S P) : Ideal R := (I.den • (I : Submodule R P)).comap (Algebra.linearMap R P)
Mathlib/RingTheory/FractionalIdeal/Basic.lean
125
130
theorem den_mul_self_eq_num (I : FractionalIdeal S P) : I.den • (I : Submodule R P) = Submodule.map (Algebra.linearMap R P) I.num := by
rw [den, num, Submodule.map_comap_eq] refine (inf_of_le_right ?_).symm rintro _ ⟨a, ha, rfl⟩ exact I.2.choose_spec.2 a ha
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # List of booleans In this file we prove lemmas about the number of `false`s and `true`s in a list of booleans. First we prove that the number of `false`s plus the number of `true` equals the length of the list. Then we prove that in a list with alternating `true`s and `false`s, the number of `true`s differs from the number of `false`s by at most one. We provide several versions of these statements. -/ namespace List @[simp] theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by -- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl #align list.count_bnot_add_count List.count_not_add_count @[simp] theorem count_add_count_not (l : List Bool) (b : Bool) : count b l + count (!b) l = length l := by rw [add_comm, count_not_add_count] #align list.count_add_count_bnot List.count_add_count_not @[simp] theorem count_false_add_count_true (l : List Bool) : count false l + count true l = length l := count_not_add_count l true #align list.count_ff_add_count_tt List.count_false_add_count_true @[simp] theorem count_true_add_count_false (l : List Bool) : count true l + count false l = length l := count_not_add_count l false #align list.count_tt_add_count_ff List.count_true_add_count_false theorem Chain.count_not : ∀ {b : Bool} {l : List Bool}, Chain (· ≠ ·) b l → count (!b) l = count b l + length l % 2 | b, [], _h => rfl | b, x :: l, h => by obtain rfl : b = !x := Bool.eq_not_iff.2 (rel_of_chain_cons h) rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, Chain.count_not (chain_of_chain_cons h), length, add_assoc, Nat.mod_two_add_succ_mod_two] #align list.chain.count_bnot List.Chain.count_not namespace Chain' variable {l : List Bool} theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : count (!b) l = count b l := by cases' l with x l · rfl rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2 suffices count (!x) (x :: l) = count x (x :: l) by -- Porting note: old proof is -- cases b <;> cases x <;> try exact this; cases b <;> cases x <;> revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;> (try exact this) <;> exact this.symm rw [count_cons_of_ne x.not_ne_self, hl.count_not, h2, count_cons_self] #align list.chain'.count_bnot_eq_count List.Chain'.count_not_eq_count theorem count_false_eq_count_true (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) : count false l = count true l := hl.count_not_eq_count h2 true #align list.chain'.count_ff_eq_count_tt List.Chain'.count_false_eq_count_true
Mathlib/Data/Bool/Count.lean
79
87
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) : count (!b) l ≤ count b l + 1 := by
cases' l with x l · exact zero_le _ obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em] · rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc] exact add_le_add_left (Nat.mod_lt _ two_pos).le _ · rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, hl.count_not] exact add_le_add_right (le_add_right le_rfl) _
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Eric Rodriguez -/ import Mathlib.Algebra.BigOperators.Finprod import Mathlib.Algebra.Group.ConjFinite import Mathlib.Algebra.Group.Subgroup.Finite import Mathlib.Data.Set.Card import Mathlib.GroupTheory.Subgroup.Center /-! # Class Equation This file establishes the class equation for finite groups. ## Main statements * `Group.card_center_add_sum_card_noncenter_eq_card`: The **class equation** for finite groups. The cardinality of a group is equal to the size of its center plus the sum of the size of all its nontrivial conjugacy classes. Also `Group.nat_card_center_add_sum_card_noncenter_eq_card`. -/ open MulAction ConjClasses variable (G : Type*) [Group G] /-- Conjugacy classes form a partition of G, stated in terms of cardinality. -/ theorem sum_conjClasses_card_eq_card [Fintype <| ConjClasses G] [Fintype G] [∀ x : ConjClasses G, Fintype x.carrier] : ∑ x : ConjClasses G, x.carrier.toFinset.card = Fintype.card G := by suffices (Σ x : ConjClasses G, x.carrier) ≃ G by simpa using (Fintype.card_congr this) simpa [carrier_eq_preimage_mk] using Equiv.sigmaFiberEquiv ConjClasses.mk /-- Conjugacy classes form a partition of G, stated in terms of cardinality. -/ theorem Group.sum_card_conj_classes_eq_card [Finite G] : ∑ᶠ x : ConjClasses G, x.carrier.ncard = Nat.card G := by classical cases nonempty_fintype G rw [Nat.card_eq_fintype_card, ← sum_conjClasses_card_eq_card, finsum_eq_sum_of_fintype] simp [Set.ncard_eq_toFinset_card'] /-- The **class equation** for finite groups. The cardinality of a group is equal to the size of its center plus the sum of the size of all its nontrivial conjugacy classes. -/ theorem Group.nat_card_center_add_sum_card_noncenter_eq_card [Finite G] : Nat.card (Subgroup.center G) + ∑ᶠ x ∈ noncenter G, Nat.card x.carrier = Nat.card G := by classical cases nonempty_fintype G rw [@Nat.card_eq_fintype_card G, ← sum_conjClasses_card_eq_card, ← Finset.sum_sdiff (ConjClasses.noncenter G).toFinset.subset_univ] simp only [Nat.card_eq_fintype_card, Set.toFinset_card] congr 1 swap · convert finsum_cond_eq_sum_of_cond_iff _ _ simp [Set.mem_toFinset] calc Fintype.card (Subgroup.center G) = Fintype.card ((noncenter G)ᶜ : Set _) := Fintype.card_congr ((mk_bijOn G).equiv _) _ = Finset.card (Finset.univ \ (noncenter G).toFinset) := by rw [← Set.toFinset_card, Set.toFinset_compl, Finset.compl_eq_univ_sdiff] _ = _ := ?_ rw [Finset.card_eq_sum_ones] refine Finset.sum_congr rfl ?_ rintro ⟨g⟩ hg simp only [noncenter, Set.not_subsingleton_iff, Set.toFinset_setOf, Finset.mem_univ, true_and, forall_true_left, Finset.mem_sdiff, Finset.mem_filter, Set.not_nontrivial_iff] at hg rw [eq_comm, ← Set.toFinset_card, Finset.card_eq_one] exact ⟨g, Finset.coe_injective <| by simpa using hg.eq_singleton_of_mem mem_carrier_mk⟩
Mathlib/GroupTheory/ClassEquation.lean
72
81
theorem Group.card_center_add_sum_card_noncenter_eq_card (G) [Group G] [∀ x : ConjClasses G, Fintype x.carrier] [Fintype G] [Fintype <| Subgroup.center G] [Fintype <| noncenter G] : Fintype.card (Subgroup.center G) + ∑ x ∈ (noncenter G).toFinset, x.carrier.toFinset.card = Fintype.card G := by
convert Group.nat_card_center_add_sum_card_noncenter_eq_card G using 2 · simp · rw [← finsum_set_coe_eq_finsum_mem (noncenter G), finsum_eq_sum_of_fintype, ← Finset.sum_set_coe] simp · simp
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.NormedSpace.Multilinear.Curry #align_import analysis.calculus.formal_multilinear_series from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Formal multilinear series In this file we define `FormalMultilinearSeries 𝕜 E F` to be a family of `n`-multilinear maps for all `n`, designed to model the sequence of derivatives of a function. In other files we use this notion to define `C^n` functions (called `contDiff` in `mathlib`) and analytic functions. ## Notations We use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives. ## Tags multilinear, formal series -/ noncomputable section open Set Fin Topology -- Porting note: added explicit universes to fix compile universe u u' v w x variable {𝕜 : Type u} {𝕜' : Type u'} {E : Type v} {F : Type w} {G : Type x} section variable [Ring 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E] [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] [TopologicalAddGroup F] [ContinuousConstSMul 𝕜 F] [AddCommGroup G] [Module 𝕜 G] [TopologicalSpace G] [TopologicalAddGroup G] [ContinuousConstSMul 𝕜 G] /-- A formal multilinear series over a field `𝕜`, from `E` to `F`, is given by a family of multilinear maps from `E^n` to `F` for all `n`. -/ @[nolint unusedArguments] def FormalMultilinearSeries (𝕜 : Type*) (E : Type*) (F : Type*) [Ring 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E] [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] [TopologicalAddGroup F] [ContinuousConstSMul 𝕜 F] := ∀ n : ℕ, E[×n]→L[𝕜] F #align formal_multilinear_series FormalMultilinearSeries -- Porting note: was `deriving` instance : AddCommGroup (FormalMultilinearSeries 𝕜 E F) := inferInstanceAs <| AddCommGroup <| ∀ n : ℕ, E[×n]→L[𝕜] F instance : Inhabited (FormalMultilinearSeries 𝕜 E F) := ⟨0⟩ section Module instance (𝕜') [Semiring 𝕜'] [Module 𝕜' F] [ContinuousConstSMul 𝕜' F] [SMulCommClass 𝕜 𝕜' F] : Module 𝕜' (FormalMultilinearSeries 𝕜 E F) := inferInstanceAs <| Module 𝕜' <| ∀ n : ℕ, E[×n]→L[𝕜] F end Module namespace FormalMultilinearSeries @[simp] -- Porting note (#10756): new theorem; was not needed in Lean 3 theorem zero_apply (n : ℕ) : (0 : FormalMultilinearSeries 𝕜 E F) n = 0 := rfl @[simp] -- Porting note (#10756): new theorem; was not needed in Lean 3 theorem neg_apply (f : FormalMultilinearSeries 𝕜 E F) (n : ℕ) : (-f) n = - f n := rfl @[ext] -- Porting note (#10756): new theorem protected theorem ext {p q : FormalMultilinearSeries 𝕜 E F} (h : ∀ n, p n = q n) : p = q := funext h protected theorem ext_iff {p q : FormalMultilinearSeries 𝕜 E F} : p = q ↔ ∀ n, p n = q n := Function.funext_iff #align formal_multilinear_series.ext_iff FormalMultilinearSeries.ext_iff protected theorem ne_iff {p q : FormalMultilinearSeries 𝕜 E F} : p ≠ q ↔ ∃ n, p n ≠ q n := Function.ne_iff #align formal_multilinear_series.ne_iff FormalMultilinearSeries.ne_iff /-- Cartesian product of two formal multilinear series (with the same field `𝕜` and the same source space, but possibly different target spaces). -/ def prod (p : FormalMultilinearSeries 𝕜 E F) (q : FormalMultilinearSeries 𝕜 E G) : FormalMultilinearSeries 𝕜 E (F × G) | n => (p n).prod (q n) /-- Killing the zeroth coefficient in a formal multilinear series -/ def removeZero (p : FormalMultilinearSeries 𝕜 E F) : FormalMultilinearSeries 𝕜 E F | 0 => 0 | n + 1 => p (n + 1) #align formal_multilinear_series.remove_zero FormalMultilinearSeries.removeZero @[simp] theorem removeZero_coeff_zero (p : FormalMultilinearSeries 𝕜 E F) : p.removeZero 0 = 0 := rfl #align formal_multilinear_series.remove_zero_coeff_zero FormalMultilinearSeries.removeZero_coeff_zero @[simp] theorem removeZero_coeff_succ (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) : p.removeZero (n + 1) = p (n + 1) := rfl #align formal_multilinear_series.remove_zero_coeff_succ FormalMultilinearSeries.removeZero_coeff_succ
Mathlib/Analysis/Calculus/FormalMultilinearSeries.lean
111
114
theorem removeZero_of_pos (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (h : 0 < n) : p.removeZero n = p n := by
rw [← Nat.succ_pred_eq_of_pos h] rfl
/- Copyright (c) 2022 Jannis Limperg. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jannis Limperg -/ import Batteries.Data.UInt @[ext] theorem Char.ext : {a b : Char} → a.val = b.val → a = b | ⟨_,_⟩, ⟨_,_⟩, rfl => rfl theorem Char.ext_iff {x y : Char} : x = y ↔ x.val = y.val := ⟨congrArg _, Char.ext⟩ theorem Char.le_antisymm_iff {x y : Char} : x = y ↔ x ≤ y ∧ y ≤ x := Char.ext_iff.trans UInt32.le_antisymm_iff theorem Char.le_antisymm {x y : Char} (h1 : x ≤ y) (h2 : y ≤ x) : x = y := Char.le_antisymm_iff.2 ⟨h1, h2⟩ instance : Batteries.LawfulOrd Char := .compareOfLessAndEq (fun _ => Nat.lt_irrefl _) Nat.lt_trans Nat.not_lt Char.le_antisymm namespace String private theorem csize_eq (c) : csize c = 1 ∨ csize c = 2 ∨ csize c = 3 ∨ csize c = 4 := by simp only [csize, Char.utf8Size] repeat (first | split | (solve | simp (config := {decide := true}))) theorem csize_pos (c) : 0 < csize c := by rcases csize_eq c with _|_|_|_ <;> simp_all (config := {decide := true})
.lake/packages/batteries/Batteries/Data/Char.lean
33
34
theorem csize_le_4 (c) : csize c ≤ 4 := by
rcases csize_eq c with _|_|_|_ <;> simp_all (config := {decide := true})
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Minchao Wu -/ import Mathlib.Order.BoundedOrder #align_import data.prod.lex from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" /-! # Lexicographic order This file defines the lexicographic relation for pairs of orders, partial orders and linear orders. ## Main declarations * `Prod.Lex.<pre/partial/linear>Order`: Instances lifting the orders on `α` and `β` to `α ×ₗ β`. ## Notation * `α ×ₗ β`: `α × β` equipped with the lexicographic order ## 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`. * `Data.Sigma.Order`: Lexicographic order on `Σ i, α i`. -/ variable {α β γ : Type*} namespace Prod.Lex @[inherit_doc] notation:35 α " ×ₗ " β:34 => Lex (Prod α β) instance decidableEq (α β : Type*) [DecidableEq α] [DecidableEq β] : DecidableEq (α ×ₗ β) := instDecidableEqProd #align prod.lex.decidable_eq Prod.Lex.decidableEq instance inhabited (α β : Type*) [Inhabited α] [Inhabited β] : Inhabited (α ×ₗ β) := instInhabitedProd #align prod.lex.inhabited Prod.Lex.inhabited /-- Dictionary / lexicographic ordering on pairs. -/ instance instLE (α β : Type*) [LT α] [LE β] : LE (α ×ₗ β) where le := Prod.Lex (· < ·) (· ≤ ·) #align prod.lex.has_le Prod.Lex.instLE instance instLT (α β : Type*) [LT α] [LT β] : LT (α ×ₗ β) where lt := Prod.Lex (· < ·) (· < ·) #align prod.lex.has_lt Prod.Lex.instLT theorem le_iff [LT α] [LE β] (a b : α × β) : toLex a ≤ toLex b ↔ a.1 < b.1 ∨ a.1 = b.1 ∧ a.2 ≤ b.2 := Prod.lex_def (· < ·) (· ≤ ·) #align prod.lex.le_iff Prod.Lex.le_iff theorem lt_iff [LT α] [LT β] (a b : α × β) : toLex a < toLex b ↔ a.1 < b.1 ∨ a.1 = b.1 ∧ a.2 < b.2 := Prod.lex_def (· < ·) (· < ·) #align prod.lex.lt_iff Prod.Lex.lt_iff example (x : α) (y : β) : toLex (x, y) = toLex (x, y) := rfl /-- Dictionary / lexicographic preorder for pairs. -/ instance preorder (α β : Type*) [Preorder α] [Preorder β] : Preorder (α ×ₗ β) := { Prod.Lex.instLE α β, Prod.Lex.instLT α β with le_refl := refl_of <| Prod.Lex _ _, le_trans := fun _ _ _ => trans_of <| Prod.Lex _ _, lt_iff_le_not_le := fun x₁ x₂ => match x₁, x₂ with | (a₁, b₁), (a₂, b₂) => by constructor · rintro (⟨_, _, hlt⟩ | ⟨_, hlt⟩) · constructor · exact left _ _ hlt · rintro ⟨⟩ · apply lt_asymm hlt; assumption · exact lt_irrefl _ hlt · constructor · right rw [lt_iff_le_not_le] at hlt exact hlt.1 · rintro ⟨⟩ · apply lt_irrefl a₁ assumption · rw [lt_iff_le_not_le] at hlt apply hlt.2 assumption · rintro ⟨⟨⟩, h₂r⟩ · left assumption · right rw [lt_iff_le_not_le] constructor · assumption · intro h apply h₂r right exact h } #align prod.lex.preorder Prod.Lex.preorder theorem monotone_fst [Preorder α] [LE β] (t c : α ×ₗ β) (h : t ≤ c) : (ofLex t).1 ≤ (ofLex c).1 := by cases (Prod.Lex.le_iff t c).mp h with | inl h' => exact h'.le | inr h' => exact h'.1.le section Preorder variable [PartialOrder α] [Preorder β] theorem toLex_mono : Monotone (toLex : α × β → α ×ₗ β) := by rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ ⟨ha, hb⟩ obtain rfl | ha : a₁ = a₂ ∨ _ := ha.eq_or_lt · exact right _ hb · exact left _ _ ha #align prod.lex.to_lex_mono Prod.Lex.toLex_mono
Mathlib/Data/Prod/Lex.lean
122
126
theorem toLex_strictMono : StrictMono (toLex : α × β → α ×ₗ β) := by
rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ h obtain rfl | ha : a₁ = a₂ ∨ _ := h.le.1.eq_or_lt · exact right _ (Prod.mk_lt_mk_iff_right.1 h) · exact left _ _ ha
/- Copyright (c) 2021 Bhavik Mehta, Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, Alena Gusakov, Yaël Dillies -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Order.Antichain import Mathlib.Order.Interval.Finset.Nat #align_import data.finset.slice from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # `r`-sets and slice This file defines the `r`-th slice of a set family and provides a way to say that a set family is made of `r`-sets. An `r`-set is a finset of cardinality `r` (aka of *size* `r`). The `r`-th slice of a set family is the set family made of its `r`-sets. ## Main declarations * `Set.Sized`: `A.Sized r` means that `A` only contains `r`-sets. * `Finset.slice`: `A.slice r` is the set of `r`-sets in `A`. ## Notation `A # r` is notation for `A.slice r` in locale `finset_family`. -/ open Finset Nat variable {α : Type*} {ι : Sort*} {κ : ι → Sort*} namespace Set variable {A B : Set (Finset α)} {s : Finset α} {r : ℕ} /-! ### Families of `r`-sets -/ /-- `Sized r A` means that every Finset in `A` has size `r`. -/ def Sized (r : ℕ) (A : Set (Finset α)) : Prop := ∀ ⦃x⦄, x ∈ A → card x = r #align set.sized Set.Sized theorem Sized.mono (h : A ⊆ B) (hB : B.Sized r) : A.Sized r := fun _x hx => hB <| h hx #align set.sized.mono Set.Sized.mono @[simp] lemma sized_empty : (∅ : Set (Finset α)).Sized r := by simp [Sized] @[simp] lemma sized_singleton : ({s} : Set (Finset α)).Sized r ↔ s.card = r := by simp [Sized] theorem sized_union : (A ∪ B).Sized r ↔ A.Sized r ∧ B.Sized r := ⟨fun hA => ⟨hA.mono subset_union_left, hA.mono subset_union_right⟩, fun hA _x hx => hx.elim (fun h => hA.1 h) fun h => hA.2 h⟩ #align set.sized_union Set.sized_union alias ⟨_, sized.union⟩ := sized_union #align set.sized.union Set.sized.union --TODO: A `forall_iUnion` lemma would be handy here. @[simp] theorem sized_iUnion {f : ι → Set (Finset α)} : (⋃ i, f i).Sized r ↔ ∀ i, (f i).Sized r := by simp_rw [Set.Sized, Set.mem_iUnion, forall_exists_index] exact forall_swap #align set.sized_Union Set.sized_iUnion -- @[simp] -- Porting note: left hand side is not simp-normal form. theorem sized_iUnion₂ {f : ∀ i, κ i → Set (Finset α)} : (⋃ (i) (j), f i j).Sized r ↔ ∀ i j, (f i j).Sized r := by simp only [Set.sized_iUnion] #align set.sized_Union₂ Set.sized_iUnion₂ protected theorem Sized.isAntichain (hA : A.Sized r) : IsAntichain (· ⊆ ·) A := fun _s hs _t ht h hst => h <| Finset.eq_of_subset_of_card_le hst ((hA ht).trans (hA hs).symm).le #align set.sized.is_antichain Set.Sized.isAntichain protected theorem Sized.subsingleton (hA : A.Sized 0) : A.Subsingleton := subsingleton_of_forall_eq ∅ fun _s hs => card_eq_zero.1 <| hA hs #align set.sized.subsingleton Set.Sized.subsingleton theorem Sized.subsingleton' [Fintype α] (hA : A.Sized (Fintype.card α)) : A.Subsingleton := subsingleton_of_forall_eq Finset.univ fun s hs => s.card_eq_iff_eq_univ.1 <| hA hs #align set.sized.subsingleton' Set.Sized.subsingleton' theorem Sized.empty_mem_iff (hA : A.Sized r) : ∅ ∈ A ↔ A = {∅} := hA.isAntichain.bot_mem_iff #align set.sized.empty_mem_iff Set.Sized.empty_mem_iff theorem Sized.univ_mem_iff [Fintype α] (hA : A.Sized r) : Finset.univ ∈ A ↔ A = {Finset.univ} := hA.isAntichain.top_mem_iff #align set.sized.univ_mem_iff Set.Sized.univ_mem_iff theorem sized_powersetCard (s : Finset α) (r : ℕ) : (powersetCard r s : Set (Finset α)).Sized r := fun _t ht => (mem_powersetCard.1 ht).2 #align set.sized_powerset_len Set.sized_powersetCard end Set namespace Finset section Sized variable [Fintype α] {𝒜 : Finset (Finset α)} {s : Finset α} {r : ℕ} theorem subset_powersetCard_univ_iff : 𝒜 ⊆ powersetCard r univ ↔ (𝒜 : Set (Finset α)).Sized r := forall_congr' fun A => by rw [mem_powersetCard_univ, mem_coe] #align finset.subset_powerset_len_univ_iff Finset.subset_powersetCard_univ_iff alias ⟨_, _root_.Set.Sized.subset_powersetCard_univ⟩ := subset_powersetCard_univ_iff #align set.sized.subset_powerset_len_univ Set.Sized.subset_powersetCard_univ
Mathlib/Data/Finset/Slice.lean
114
117
theorem _root_.Set.Sized.card_le (h𝒜 : (𝒜 : Set (Finset α)).Sized r) : card 𝒜 ≤ (Fintype.card α).choose r := by
rw [Fintype.card, ← card_powersetCard] exact card_le_card (subset_powersetCard_univ_iff.mpr h𝒜)
/- Copyright (c) 2017 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura -/ import Mathlib.Init.Logic import Mathlib.Tactic.AdaptationNote import Mathlib.Tactic.Coe /-! # Lemmas about booleans These are the lemmas about booleans which were present in core Lean 3. See also the file Mathlib.Data.Bool.Basic which contains lemmas about booleans from mathlib 3. -/ set_option autoImplicit true -- We align Lean 3 lemmas with lemmas in `Init.SimpLemmas` in Lean 4. #align band_self Bool.and_self #align band_tt Bool.and_true #align band_ff Bool.and_false #align tt_band Bool.true_and #align ff_band Bool.false_and #align bor_self Bool.or_self #align bor_tt Bool.or_true #align bor_ff Bool.or_false #align tt_bor Bool.true_or #align ff_bor Bool.false_or #align bnot_bnot Bool.not_not namespace Bool #align bool.cond_tt Bool.cond_true #align bool.cond_ff Bool.cond_false #align cond_a_a Bool.cond_self attribute [simp] xor_self #align bxor_self Bool.xor_self #align bxor_tt Bool.xor_true #align bxor_ff Bool.xor_false #align tt_bxor Bool.true_xor #align ff_bxor Bool.false_xor theorem true_eq_false_eq_False : ¬true = false := by decide #align tt_eq_ff_eq_false Bool.true_eq_false_eq_False theorem false_eq_true_eq_False : ¬false = true := by decide #align ff_eq_tt_eq_false Bool.false_eq_true_eq_False theorem eq_false_eq_not_eq_true (b : Bool) : (¬b = true) = (b = false) := by simp #align eq_ff_eq_not_eq_tt Bool.eq_false_eq_not_eq_true theorem eq_true_eq_not_eq_false (b : Bool) : (¬b = false) = (b = true) := by simp #align eq_tt_eq_not_eq_ft Bool.eq_true_eq_not_eq_false theorem eq_false_of_not_eq_true {b : Bool} : ¬b = true → b = false := Eq.mp (eq_false_eq_not_eq_true b) #align eq_ff_of_not_eq_tt Bool.eq_false_of_not_eq_true theorem eq_true_of_not_eq_false {b : Bool} : ¬b = false → b = true := Eq.mp (eq_true_eq_not_eq_false b) #align eq_tt_of_not_eq_ff Bool.eq_true_of_not_eq_false theorem and_eq_true_eq_eq_true_and_eq_true (a b : Bool) : ((a && b) = true) = (a = true ∧ b = true) := by simp #align band_eq_true_eq_eq_tt_and_eq_tt Bool.and_eq_true_eq_eq_true_and_eq_true theorem or_eq_true_eq_eq_true_or_eq_true (a b : Bool) : ((a || b) = true) = (a = true ∨ b = true) := by simp #align bor_eq_true_eq_eq_tt_or_eq_tt Bool.or_eq_true_eq_eq_true_or_eq_true theorem not_eq_true_eq_eq_false (a : Bool) : (not a = true) = (a = false) := by cases a <;> simp #align bnot_eq_true_eq_eq_ff Bool.not_eq_true_eq_eq_false #adaptation_note /-- this is no longer a simp lemma, as after nightly-2024-03-05 the LHS simplifies. -/ theorem and_eq_false_eq_eq_false_or_eq_false (a b : Bool) : ((a && b) = false) = (a = false ∨ b = false) := by cases a <;> cases b <;> simp #align band_eq_false_eq_eq_ff_or_eq_ff Bool.and_eq_false_eq_eq_false_or_eq_false theorem or_eq_false_eq_eq_false_and_eq_false (a b : Bool) : ((a || b) = false) = (a = false ∧ b = false) := by cases a <;> cases b <;> simp #align bor_eq_false_eq_eq_ff_and_eq_ff Bool.or_eq_false_eq_eq_false_and_eq_false theorem not_eq_false_eq_eq_true (a : Bool) : (not a = false) = (a = true) := by cases a <;> simp #align bnot_eq_ff_eq_eq_tt Bool.not_eq_false_eq_eq_true
Mathlib/Init/Data/Bool/Lemmas.lean
94
94
theorem coe_false : ↑false = False := by
simp
/- 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.FreeModule.PID import Mathlib.MeasureTheory.Group.FundamentalDomain import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar import Mathlib.RingTheory.Localization.Module #align_import algebra.module.zlattice from "leanprover-community/mathlib"@"a3e83f0fa4391c8740f7d773a7a9b74e311ae2a3" /-! # ℤ-lattices Let `E` be a finite dimensional vector space over a `NormedLinearOrderedField` `K` with a solid norm that is also a `FloorRing`, e.g. `ℝ`. A (full) `ℤ`-lattice `L` of `E` is a discrete subgroup of `E` such that `L` spans `E` over `K`. A `ℤ`-lattice `L` can be defined in two ways: * For `b` a basis of `E`, then `L = Submodule.span ℤ (Set.range b)` is a ℤ-lattice of `E` * As an `AddSubgroup E` with the additional properties: * `DiscreteTopology L`, that is `L` is discrete * `Submodule.span ℝ (L : Set E) = ⊤`, that is `L` spans `E` over `K`. Results about the first point of view are in the `Zspan` namespace and results about the second point of view are in the `Zlattice` namespace. ## Main results * `Zspan.isAddFundamentalDomain`: for a ℤ-lattice `Submodule.span ℤ (Set.range b)`, proves that the set defined by `Zspan.fundamentalDomain` is a fundamental domain. * `Zlattice.module_free`: an AddSubgroup of `E` that is discrete and spans `E` over `K` is a free `ℤ`-module * `Zlattice.rank`: an AddSubgroup of `E` that is discrete and spans `E` over `K` is a free `ℤ`-module of `ℤ`-rank equal to the `K`-rank of `E` -/ noncomputable section namespace Zspan open MeasureTheory MeasurableSet Submodule Bornology variable {E ι : Type*} section NormedLatticeField variable {K : Type*} [NormedLinearOrderedField K] variable [NormedAddCommGroup E] [NormedSpace K E] variable (b : Basis ι K E)
Mathlib/Algebra/Module/Zlattice/Basic.lean
54
54
theorem span_top : span K (span ℤ (Set.range b) : Set E) = ⊤ := by
simp [span_span_of_tower]
/- Copyright (c) 2018 Rohan Mitta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rohan Mitta, Kevin Buzzard, Alistair Tucker, Johannes Hölzl, Yury Kudryashov -/ import Mathlib.Order.Interval.Set.ProjIcc import Mathlib.Topology.Algebra.Order.Field import Mathlib.Topology.Bornology.Hom import Mathlib.Topology.EMetricSpace.Lipschitz import Mathlib.Topology.MetricSpace.Basic import Mathlib.Topology.MetricSpace.Bounded #align_import topology.metric_space.lipschitz from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328" /-! # Lipschitz continuous functions A map `f : α → β` between two (extended) metric spaces is called *Lipschitz continuous* with constant `K ≥ 0` if for all `x, y` we have `edist (f x) (f y) ≤ K * edist x y`. For a metric space, the latter inequality is equivalent to `dist (f x) (f y) ≤ K * dist x y`. There is also a version asserting this inequality only for `x` and `y` in some set `s`. Finally, `f : α → β` is called *locally Lipschitz continuous* if each `x : α` has a neighbourhood on which `f` is Lipschitz continuous (with some constant). In this file we specialize various facts about Lipschitz continuous maps to the case of (pseudo) metric spaces. ## Implementation notes The parameter `K` has type `ℝ≥0`. This way we avoid conjunction in the definition and have coercions both to `ℝ` and `ℝ≥0∞`. Constructors whose names end with `'` take `K : ℝ` as an argument, and return `LipschitzWith (Real.toNNReal K) f`. -/ universe u v w x open Filter Function Set Topology NNReal ENNReal Bornology variable {α : Type u} {β : Type v} {γ : Type w} {ι : Type x} theorem lipschitzWith_iff_dist_le_mul [PseudoMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0} {f : α → β} : LipschitzWith K f ↔ ∀ x y, dist (f x) (f y) ≤ K * dist x y := by simp only [LipschitzWith, edist_nndist, dist_nndist] norm_cast #align lipschitz_with_iff_dist_le_mul lipschitzWith_iff_dist_le_mul alias ⟨LipschitzWith.dist_le_mul, LipschitzWith.of_dist_le_mul⟩ := lipschitzWith_iff_dist_le_mul #align lipschitz_with.dist_le_mul LipschitzWith.dist_le_mul #align lipschitz_with.of_dist_le_mul LipschitzWith.of_dist_le_mul
Mathlib/Topology/MetricSpace/Lipschitz.lean
51
55
theorem lipschitzOnWith_iff_dist_le_mul [PseudoMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0} {s : Set α} {f : α → β} : LipschitzOnWith K f s ↔ ∀ x ∈ s, ∀ y ∈ s, dist (f x) (f y) ≤ K * dist x y := by
simp only [LipschitzOnWith, edist_nndist, dist_nndist] norm_cast
/- Copyright (c) 2022 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Analysis.NormedSpace.Star.Basic import Mathlib.Analysis.NormedSpace.Spectrum import Mathlib.Analysis.SpecialFunctions.Exponential import Mathlib.Algebra.Star.StarAlgHom #align_import analysis.normed_space.star.spectrum from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Spectral properties in C⋆-algebras In this file, we establish various properties related to the spectrum of elements in C⋆-algebras. -/ local postfix:max "⋆" => star section open scoped Topology ENNReal open Filter ENNReal spectrum CstarRing NormedSpace section UnitarySpectrum variable {𝕜 : Type*} [NormedField 𝕜] {E : Type*} [NormedRing E] [StarRing E] [CstarRing E] [NormedAlgebra 𝕜 E] [CompleteSpace E] theorem unitary.spectrum_subset_circle (u : unitary E) : spectrum 𝕜 (u : E) ⊆ Metric.sphere 0 1 := by nontriviality E refine fun k hk => mem_sphere_zero_iff_norm.mpr (le_antisymm ?_ ?_) · simpa only [CstarRing.norm_coe_unitary u] using norm_le_norm_of_mem hk · rw [← unitary.val_toUnits_apply u] at hk have hnk := ne_zero_of_mem_of_unit hk rw [← inv_inv (unitary.toUnits u), ← spectrum.map_inv, Set.mem_inv] at hk have : ‖k‖⁻¹ ≤ ‖(↑(unitary.toUnits u)⁻¹ : E)‖ := by simpa only [norm_inv] using norm_le_norm_of_mem hk simpa using inv_le_of_inv_le (norm_pos_iff.mpr hnk) this #align unitary.spectrum_subset_circle unitary.spectrum_subset_circle theorem spectrum.subset_circle_of_unitary {u : E} (h : u ∈ unitary E) : spectrum 𝕜 u ⊆ Metric.sphere 0 1 := unitary.spectrum_subset_circle ⟨u, h⟩ #align spectrum.subset_circle_of_unitary spectrum.subset_circle_of_unitary end UnitarySpectrum section ComplexScalars open Complex variable {A : Type*} [NormedRing A] [NormedAlgebra ℂ A] [CompleteSpace A] [StarRing A] [CstarRing A] local notation "↑ₐ" => algebraMap ℂ A theorem IsSelfAdjoint.spectralRadius_eq_nnnorm {a : A} (ha : IsSelfAdjoint a) : spectralRadius ℂ a = ‖a‖₊ := by have hconst : Tendsto (fun _n : ℕ => (‖a‖₊ : ℝ≥0∞)) atTop _ := tendsto_const_nhds refine tendsto_nhds_unique ?_ hconst convert (spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a : A)).comp (Nat.tendsto_pow_atTop_atTop_of_one_lt one_lt_two) using 1 refine funext fun n => ?_ rw [Function.comp_apply, ha.nnnorm_pow_two_pow, ENNReal.coe_pow, ← rpow_natCast, ← rpow_mul] simp #align is_self_adjoint.spectral_radius_eq_nnnorm IsSelfAdjoint.spectralRadius_eq_nnnorm theorem IsStarNormal.spectralRadius_eq_nnnorm (a : A) [IsStarNormal a] : spectralRadius ℂ a = ‖a‖₊ := by refine (ENNReal.pow_strictMono two_ne_zero).injective ?_ have heq : (fun n : ℕ => (‖(a⋆ * a) ^ n‖₊ : ℝ≥0∞) ^ (1 / n : ℝ)) = (fun x => x ^ 2) ∘ fun n : ℕ => (‖a ^ n‖₊ : ℝ≥0∞) ^ (1 / n : ℝ) := by funext n rw [Function.comp_apply, ← rpow_natCast, ← rpow_mul, mul_comm, rpow_mul, rpow_natCast, ← coe_pow, sq, ← nnnorm_star_mul_self, Commute.mul_pow (star_comm_self' a), star_pow] have h₂ := ((ENNReal.continuous_pow 2).tendsto (spectralRadius ℂ a)).comp (spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius a) rw [← heq] at h₂ convert tendsto_nhds_unique h₂ (pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a⋆ * a)) rw [(IsSelfAdjoint.star_mul_self a).spectralRadius_eq_nnnorm, sq, nnnorm_star_mul_self, coe_mul] #align is_star_normal.spectral_radius_eq_nnnorm IsStarNormal.spectralRadius_eq_nnnorm /-- Any element of the spectrum of a selfadjoint is real. -/
Mathlib/Analysis/NormedSpace/Star/Spectrum.lean
90
100
theorem IsSelfAdjoint.mem_spectrum_eq_re [StarModule ℂ A] {a : A} (ha : IsSelfAdjoint a) {z : ℂ} (hz : z ∈ spectrum ℂ a) : z = z.re := by
have hu := exp_mem_unitary_of_mem_skewAdjoint ℂ (ha.smul_mem_skewAdjoint conj_I) let Iu := Units.mk0 I I_ne_zero have : NormedSpace.exp ℂ (I • z) ∈ spectrum ℂ (NormedSpace.exp ℂ (I • a)) := by simpa only [Units.smul_def, Units.val_mk0] using spectrum.exp_mem_exp (Iu • a) (smul_mem_smul_iff.mpr hz) exact Complex.ext (ofReal_re _) <| by simpa only [← Complex.exp_eq_exp_ℂ, mem_sphere_zero_iff_norm, norm_eq_abs, abs_exp, Real.exp_eq_one_iff, smul_eq_mul, I_mul, neg_eq_zero] using spectrum.subset_circle_of_unitary hu this
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa, Alex Meiburg -/ import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Polynomial.Degree.Lemmas #align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448" /-! # Erase the leading term of a univariate polynomial ## Definition * `eraseLead f`: the polynomial `f - leading term of f` `eraseLead` serves as reduction step in an induction, shaving off one monomial from a polynomial. The definition is set up so that it does not mention subtraction in the definition, and thus works for polynomials over semirings as well as rings. -/ noncomputable section open Polynomial open Polynomial Finset namespace Polynomial variable {R : Type*} [Semiring R] {f : R[X]} /-- `eraseLead f` for a polynomial `f` is the polynomial obtained by subtracting from `f` the leading term of `f`. -/ def eraseLead (f : R[X]) : R[X] := Polynomial.erase f.natDegree f #align polynomial.erase_lead Polynomial.eraseLead section EraseLead theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by simp only [eraseLead, support_erase] #align polynomial.erase_lead_support Polynomial.eraseLead_support theorem eraseLead_coeff (i : ℕ) : f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by simp only [eraseLead, coeff_erase] #align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff @[simp]
Mathlib/Algebra/Polynomial/EraseLead.lean
52
52
theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by
simp [eraseLead_coeff]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Algebra.MvPolynomial.Variables #align_import data.mv_polynomial.comm_ring from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Multivariate polynomials over a ring Many results about polynomials hold when the coefficient ring is a commutative semiring. Some stronger results can be derived when we assume this semiring is a ring. This file does not define any new operations, but proves some of these stronger results. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommRing R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` -/ noncomputable section open Set Function Finsupp AddMonoidAlgebra universe u v variable {R : Type u} {S : Type v} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ} section CommRing variable [CommRing R] variable {p q : MvPolynomial σ R} instance instCommRingMvPolynomial : CommRing (MvPolynomial σ R) := AddMonoidAlgebra.commRing variable (σ a a') -- @[simp] -- Porting note (#10618): simp can prove this theorem C_sub : (C (a - a') : MvPolynomial σ R) = C a - C a' := RingHom.map_sub _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.C_sub MvPolynomial.C_sub -- @[simp] -- Porting note (#10618): simp can prove this theorem C_neg : (C (-a) : MvPolynomial σ R) = -C a := RingHom.map_neg _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.C_neg MvPolynomial.C_neg @[simp] theorem coeff_neg (m : σ →₀ ℕ) (p : MvPolynomial σ R) : coeff m (-p) = -coeff m p := Finsupp.neg_apply _ _ #align mv_polynomial.coeff_neg MvPolynomial.coeff_neg @[simp] theorem coeff_sub (m : σ →₀ ℕ) (p q : MvPolynomial σ R) : coeff m (p - q) = coeff m p - coeff m q := Finsupp.sub_apply _ _ _ #align mv_polynomial.coeff_sub MvPolynomial.coeff_sub @[simp] theorem support_neg : (-p).support = p.support := Finsupp.support_neg p #align mv_polynomial.support_neg MvPolynomial.support_neg theorem support_sub [DecidableEq σ] (p q : MvPolynomial σ R) : (p - q).support ⊆ p.support ∪ q.support := Finsupp.support_sub #align mv_polynomial.support_sub MvPolynomial.support_sub variable {σ} (p) section Degrees theorem degrees_neg (p : MvPolynomial σ R) : (-p).degrees = p.degrees := by rw [degrees, support_neg]; rfl #align mv_polynomial.degrees_neg MvPolynomial.degrees_neg
Mathlib/Algebra/MvPolynomial/CommRing.lean
100
102
theorem degrees_sub [DecidableEq σ] (p q : MvPolynomial σ R) : (p - q).degrees ≤ p.degrees ⊔ q.degrees := by
simpa only [sub_eq_add_neg] using le_trans (degrees_add p (-q)) (by rw [degrees_neg])
/- Copyright (c) 2024 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Order.Group.Instances import Mathlib.GroupTheory.GroupAction.Pi /-! # Maps (semi)conjugating a shift to a shift Denote by $S^1$ the unit circle `UnitAddCircle`. A common way to study a self-map $f\colon S^1\to S^1$ of degree `1` is to lift it to a map $\tilde f\colon \mathbb R\to \mathbb R$ such that $\tilde f(x + 1) = \tilde f(x)+1$ for all `x`. In this file we define a structure and a typeclass for bundled maps satisfying `f (x + a) = f x + b`. We use parameters `a` and `b` instead of `1` to accomodate for two use cases: - maps between circles of different lengths; - self-maps $f\colon S^1\to S^1$ of degree other than one, including orientation-reversing maps. -/ open Function Set /-- A bundled map `f : G → H` such that `f (x + a) = f x + b` for all `x`. One can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/ structure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where /-- The underlying function of an `AddConstMap`. Use automatic coercion to function instead. -/ protected toFun : G → H /-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/ map_add_const' (x : G) : toFun (x + a) = toFun x + b @[inherit_doc] scoped [AddConstMap] notation:25 G " →+c[" a ", " b "] " H => AddConstMap G H a b /-- Typeclass for maps satisfying `f (x + a) = f x + b`. Note that `a` and `b` are `outParam`s, so one should not add instances like `[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/ class AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H] (a : outParam G) (b : outParam H) extends DFunLike F G fun _ ↦ H where /-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`: `∀ x, f (x + a) = f x + b`. -/ map_add_const (f : F) (x : G) : f (x + a) = f x + b namespace AddConstMapClass /-! ### Properties of `AddConstMapClass` maps In this section we prove properties like `f (x + n • a) = f x + n • b`. -/ attribute [simp] map_add_const variable {F G H : Type*} {a : G} {b : H} protected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) : Semiconj f (· + a) (· + b) := map_add_const f @[simp] theorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b] (f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by simpa using (AddConstMapClass.semiconj f).iterate_right n x @[simp] theorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b] (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by simp [← map_add_nsmul] theorem map_add_one [AddMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b] (f : F) (x : G) : f (x + 1) = f x + b := map_add_const f x @[simp] theorem map_add_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b] (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] : f (x + no_index (OfNat.ofNat n)) = f x + (OfNat.ofNat n : ℕ) • b := map_add_nat' f x n theorem map_add_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1] (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n := by simp theorem map_add_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1] (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] : f (x + OfNat.ofNat n) = f x + OfNat.ofNat n := map_add_nat f x n @[simp] theorem map_const [AddZeroClass G] [Add H] [AddConstMapClass F G H a b] (f : F) : f a = f 0 + b := by simpa using map_add_const f 0 theorem map_one [AddZeroClass G] [One G] [Add H] [AddConstMapClass F G H 1 b] (f : F) : f 1 = f 0 + b := map_const f @[simp]
Mathlib/Algebra/AddConstMap/Basic.lean
107
109
theorem map_nsmul_const [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b] (f : F) (n : ℕ) : f (n • a) = f 0 + n • b := by
simpa using map_add_nsmul f 0 n
/- 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.Algebra.Group.NatPowAssoc import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Induction import Mathlib.Algebra.Polynomial.Eval /-! # Scalar-multiple polynomial evaluation This file defines polynomial evaluation via scalar multiplication. Our polynomials have coefficients in a semiring `R`, and we evaluate at a weak form of `R`-algebra, namely an additive commutative monoid with an action of `R` and a notion of natural number power. This is a generalization of `Algebra.Polynomial.Eval`. ## Main definitions * `Polynomial.smeval`: function for evaluating a polynomial with coefficients in a `Semiring` `R` at an element `x` of an `AddCommMonoid` `S` that has natural number powers and an `R`-action. * `smeval.linearMap`: the `smeval` function as an `R`-linear map, when `S` is an `R`-module. * `smeval.algebraMap`: the `smeval` function as an `R`-algebra map, when `S` is an `R`-algebra. ## Main results * `smeval_monomial`: monomials evaluate as we expect. * `smeval_add`, `smeval_smul`: linearity of evaluation, given an `R`-module. * `smeval_mul`, `smeval_comp`: multiplicativity of evaluation, given power-associativity. * `eval₂_eq_smeval`, `leval_eq_smeval.linearMap`, `aeval = smeval.algebraMap`, etc.: comparisons ## To do * `smeval_neg` and `smeval_intCast` for `R` a ring and `S` an `AddCommGroup`. * Nonunital evaluation for polynomials with vanishing constant term for `Pow S ℕ+` (different file?) -/ namespace Polynomial section MulActionWithZero variable {R : Type*} [Semiring R] (r : R) (p : R[X]) {S : Type*} [AddCommMonoid S] [Pow S ℕ] [MulActionWithZero R S] (x : S) /-- Scalar multiplication together with taking a natural number power. -/ def smul_pow : ℕ → R → S := fun n r => r • x^n /-- Evaluate a polynomial `p` in the scalar semiring `R` at an element `x` in the target `S` using scalar multiple `R`-action. -/ irreducible_def smeval : S := p.sum (smul_pow x) theorem smeval_eq_sum : p.smeval x = p.sum (smul_pow x) := by rw [smeval_def] @[simp]
Mathlib/Algebra/Polynomial/Smeval.lean
57
58
theorem smeval_C : (C r).smeval x = r • x ^ 0 := by
simp only [smeval_eq_sum, smul_pow, zero_smul, sum_C_index]
/- 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.Degree.Definitions import Mathlib.Algebra.Polynomial.Eval import Mathlib.Algebra.Polynomial.Monic import Mathlib.Algebra.Polynomial.RingDivision import Mathlib.Tactic.Abel #align_import ring_theory.polynomial.pochhammer from "leanprover-community/mathlib"@"53b216bcc1146df1c4a0a86877890ea9f1f01589" /-! # The Pochhammer polynomials We define and prove some basic relations about `ascPochhammer S n : S[X] := X * (X + 1) * ... * (X + n - 1)` which is also known as the rising factorial and about `descPochhammer R n : R[X] := X * (X - 1) * ... * (X - n + 1)` which is also known as the falling factorial. Versions of this definition that are focused on `Nat` can be found in `Data.Nat.Factorial` as `Nat.ascFactorial` and `Nat.descFactorial`. ## Implementation As with many other families of polynomials, even though the coefficients are always in `ℕ` or `ℤ` , we define the polynomial with coefficients in any `[Semiring S]` or `[Ring R]`. ## TODO There is lots more in this direction: * q-factorials, q-binomials, q-Pochhammer. -/ universe u v open Polynomial open Polynomial section Semiring variable (S : Type u) [Semiring S] /-- `ascPochhammer S n` is the polynomial `X * (X + 1) * ... * (X + n - 1)`, with coefficients in the semiring `S`. -/ noncomputable def ascPochhammer : ℕ → S[X] | 0 => 1 | n + 1 => X * (ascPochhammer n).comp (X + 1) #align pochhammer ascPochhammer @[simp] theorem ascPochhammer_zero : ascPochhammer S 0 = 1 := rfl #align pochhammer_zero ascPochhammer_zero @[simp] theorem ascPochhammer_one : ascPochhammer S 1 = X := by simp [ascPochhammer] #align pochhammer_one ascPochhammer_one theorem ascPochhammer_succ_left (n : ℕ) : ascPochhammer S (n + 1) = X * (ascPochhammer S n).comp (X + 1) := by rw [ascPochhammer] #align pochhammer_succ_left ascPochhammer_succ_left theorem monic_ascPochhammer (n : ℕ) [Nontrivial S] [NoZeroDivisors S] : Monic <| ascPochhammer S n := by induction' n with n hn · simp · have : leadingCoeff (X + 1 : S[X]) = 1 := leadingCoeff_X_add_C 1 rw [ascPochhammer_succ_left, Monic.def, leadingCoeff_mul, leadingCoeff_comp (ne_zero_of_eq_one <| natDegree_X_add_C 1 : natDegree (X + 1) ≠ 0), hn, monic_X, one_mul, one_mul, this, one_pow] section variable {S} {T : Type v} [Semiring T] @[simp] theorem ascPochhammer_map (f : S →+* T) (n : ℕ) : (ascPochhammer S n).map f = ascPochhammer T n := by induction' n with n ih · simp · simp [ih, ascPochhammer_succ_left, map_comp] #align pochhammer_map ascPochhammer_map theorem ascPochhammer_eval₂ (f : S →+* T) (n : ℕ) (t : T) : (ascPochhammer T n).eval t = (ascPochhammer S n).eval₂ f t := by rw [← ascPochhammer_map f] exact eval_map f t theorem ascPochhammer_eval_comp {R : Type*} [CommSemiring R] (n : ℕ) (p : R[X]) [Algebra R S] (x : S) : ((ascPochhammer S n).comp (p.map (algebraMap R S))).eval x = (ascPochhammer S n).eval (p.eval₂ (algebraMap R S) x) := by rw [ascPochhammer_eval₂ (algebraMap R S), ← eval₂_comp', ← ascPochhammer_map (algebraMap R S), ← map_comp, eval_map] end @[simp, norm_cast] theorem ascPochhammer_eval_cast (n k : ℕ) : (((ascPochhammer ℕ n).eval k : ℕ) : S) = ((ascPochhammer S n).eval k : S) := by rw [← ascPochhammer_map (algebraMap ℕ S), eval_map, ← eq_natCast (algebraMap ℕ S), eval₂_at_natCast,Nat.cast_id] #align pochhammer_eval_cast ascPochhammer_eval_cast theorem ascPochhammer_eval_zero {n : ℕ} : (ascPochhammer S n).eval 0 = if n = 0 then 1 else 0 := by cases n · simp · simp [X_mul, Nat.succ_ne_zero, ascPochhammer_succ_left] #align pochhammer_eval_zero ascPochhammer_eval_zero
Mathlib/RingTheory/Polynomial/Pochhammer.lean
116
116
theorem ascPochhammer_zero_eval_zero : (ascPochhammer S 0).eval 0 = 1 := by
simp
/- Copyright (c) 2023 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.GroupTheory.Coprod.Basic import Mathlib.GroupTheory.Complement /-! ## HNN Extensions of Groups This file defines the HNN extension of a group `G`, `HNNExtension G A B φ`. Given a group `G`, subgroups `A` and `B` and an isomorphism `φ` of `A` and `B`, we adjoin a letter `t` to `G`, such that for any `a ∈ A`, the conjugate of `of a` by `t` is `of (φ a)`, where `of` is the canonical map from `G` into the `HNNExtension`. This construction is named after Graham Higman, Bernhard Neumann and Hanna Neumann. ## Main definitions - `HNNExtension G A B φ` : The HNN Extension of a group `G`, where `A` and `B` are subgroups and `φ` is an isomorphism between `A` and `B`. - `HNNExtension.of` : The canonical embedding of `G` into `HNNExtension G A B φ`. - `HNNExtension.t` : The stable letter of the HNN extension. - `HNNExtension.lift` : Define a function `HNNExtension G A B φ →* H`, by defining it on `G` and `t` - `HNNExtension.of_injective` : The canonical embedding `G →* HNNExtension G A B φ` is injective. - `HNNExtension.ReducedWord.toList_eq_nil_of_mem_of_range` : Britton's Lemma. If an element of `G` is represented by a reduced word, then this reduced word does not contain `t`. -/ open Monoid Coprod Multiplicative Subgroup Function /-- The relation we quotient the coproduct by to form an `HNNExtension`. -/ def HNNExtension.con (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Con (G ∗ Multiplicative ℤ) := conGen (fun x y => ∃ (a : A), x = inr (ofAdd 1) * inl (a : G) ∧ y = inl (φ a : G) * inr (ofAdd 1)) /-- The HNN Extension of a group `G`, `HNNExtension G A B φ`. Given a group `G`, subgroups `A` and `B` and an isomorphism `φ` of `A` and `B`, we adjoin a letter `t` to `G`, such that for any `a ∈ A`, the conjugate of `of a` by `t` is `of (φ a)`, where `of` is the canonical map from `G` into the `HNNExtension`. -/ def HNNExtension (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Type _ := (HNNExtension.con G A B φ).Quotient variable {G : Type*} [Group G] {A B : Subgroup G} {φ : A ≃* B} {H : Type*} [Group H] {M : Type*} [Monoid M] instance : Group (HNNExtension G A B φ) := by delta HNNExtension; infer_instance namespace HNNExtension /-- The canonical embedding `G →* HNNExtension G A B φ` -/ def of : G →* HNNExtension G A B φ := (HNNExtension.con G A B φ).mk'.comp inl /-- The stable letter of the `HNNExtension` -/ def t : HNNExtension G A B φ := (HNNExtension.con G A B φ).mk'.comp inr (ofAdd 1) theorem t_mul_of (a : A) : t * (of (a : G) : HNNExtension G A B φ) = of (φ a : G) * t := (Con.eq _).2 <| ConGen.Rel.of _ _ <| ⟨a, by simp⟩
Mathlib/GroupTheory/HNNExtension.lean
69
71
theorem of_mul_t (b : B) : (of (b : G) : HNNExtension G A B φ) * t = t * of (φ.symm b : G) := by
rw [t_mul_of]; simp
/- 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.Algebra.DualNumber import Mathlib.Analysis.NormedSpace.TrivSqZeroExt #align_import analysis.normed_space.dual_number from "leanprover-community/mathlib"@"806c0bb86f6128cfa2f702285727518eb5244390" /-! # Results on `DualNumber R` related to the norm These are just restatements of similar statements about `TrivSqZeroExt R M`. ## Main results * `exp_eps` -/ open NormedSpace -- For `NormedSpace.exp`. namespace DualNumber open TrivSqZeroExt variable (𝕜 : Type*) {R : Type*} variable [Field 𝕜] [CharZero 𝕜] [CommRing R] [Algebra 𝕜 R] variable [UniformSpace R] [TopologicalRing R] [CompleteSpace R] [T2Space R] @[simp] theorem exp_eps : exp 𝕜 (eps : DualNumber R) = 1 + eps := exp_inr _ _ #align dual_number.exp_eps DualNumber.exp_eps @[simp]
Mathlib/Analysis/NormedSpace/DualNumber.lean
38
39
theorem exp_smul_eps (r : R) : exp 𝕜 (r • eps : DualNumber R) = 1 + r • eps := by
rw [eps, ← inr_smul, exp_inr]
/- Copyright (c) 2022 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.ModelTheory.Satisfiability #align_import model_theory.types from "leanprover-community/mathlib"@"98bd247d933fb581ff37244a5998bd33d81dd46d" /-! # Type Spaces This file defines the space of complete types over a first-order theory. (Note that types in model theory are different from types in type theory.) ## Main Definitions * `FirstOrder.Language.Theory.CompleteType`: `T.CompleteType α` consists of complete types over the theory `T` with variables `α`. * `FirstOrder.Language.Theory.typeOf` is the type of a given tuple. * `FirstOrder.Language.Theory.realizedTypes`: `T.realizedTypes M α` is the set of types in `T.CompleteType α` that are realized in `M` - that is, the type of some tuple in `M`. ## Main Results * `FirstOrder.Language.Theory.CompleteType.nonempty_iff`: The space `T.CompleteType α` is nonempty exactly when `T` is satisfiable. * `FirstOrder.Language.Theory.CompleteType.exists_modelType_is_realized_in`: Every type is realized in some model. ## Implementation Notes * Complete types are implemented as maximal consistent theories in an expanded language. More frequently they are described as maximal consistent sets of formulas, but this is equivalent. ## TODO * Connect `T.CompleteType α` to sets of formulas `L.Formula α`. -/ set_option linter.uppercaseLean3 false universe u v w w' open Cardinal Set open scoped Classical open Cardinal FirstOrder namespace FirstOrder namespace Language namespace Theory variable {L : Language.{u, v}} (T : L.Theory) (α : Type w) /-- A complete type over a given theory in a certain type of variables is a maximally consistent (with the theory) set of formulas in that type. -/ structure CompleteType where toTheory : L[[α]].Theory subset' : (L.lhomWithConstants α).onTheory T ⊆ toTheory isMaximal' : toTheory.IsMaximal #align first_order.language.Theory.complete_type FirstOrder.Language.Theory.CompleteType #align first_order.language.Theory.complete_type.to_Theory FirstOrder.Language.Theory.CompleteType.toTheory #align first_order.language.Theory.complete_type.subset' FirstOrder.Language.Theory.CompleteType.subset' #align first_order.language.Theory.complete_type.is_maximal' FirstOrder.Language.Theory.CompleteType.isMaximal' variable {T α} namespace CompleteType attribute [coe] CompleteType.toTheory instance Sentence.instSetLike : SetLike (T.CompleteType α) (L[[α]].Sentence) := ⟨fun p => p.toTheory, fun p q h => by cases p cases q congr ⟩ #align first_order.language.Theory.complete_type.sentence.set_like FirstOrder.Language.Theory.CompleteType.Sentence.instSetLike theorem isMaximal (p : T.CompleteType α) : IsMaximal (p : L[[α]].Theory) := p.isMaximal' #align first_order.language.Theory.complete_type.is_maximal FirstOrder.Language.Theory.CompleteType.isMaximal theorem subset (p : T.CompleteType α) : (L.lhomWithConstants α).onTheory T ⊆ (p : L[[α]].Theory) := p.subset' #align first_order.language.Theory.complete_type.subset FirstOrder.Language.Theory.CompleteType.subset theorem mem_or_not_mem (p : T.CompleteType α) (φ : L[[α]].Sentence) : φ ∈ p ∨ φ.not ∈ p := p.isMaximal.mem_or_not_mem φ #align first_order.language.Theory.complete_type.mem_or_not_mem FirstOrder.Language.Theory.CompleteType.mem_or_not_mem theorem mem_of_models (p : T.CompleteType α) {φ : L[[α]].Sentence} (h : (L.lhomWithConstants α).onTheory T ⊨ᵇ φ) : φ ∈ p := (p.mem_or_not_mem φ).resolve_right fun con => ((models_iff_not_satisfiable _).1 h) (p.isMaximal.1.mono (union_subset p.subset (singleton_subset_iff.2 con))) #align first_order.language.Theory.complete_type.mem_of_models FirstOrder.Language.Theory.CompleteType.mem_of_models theorem not_mem_iff (p : T.CompleteType α) (φ : L[[α]].Sentence) : φ.not ∈ p ↔ ¬φ ∈ p := ⟨fun hf ht => by have h : ¬IsSatisfiable ({φ, φ.not} : L[[α]].Theory) := by rintro ⟨@⟨_, _, h, _⟩⟩ simp only [model_iff, mem_insert_iff, mem_singleton_iff, forall_eq_or_imp, forall_eq] at h exact h.2 h.1 refine h (p.isMaximal.1.mono ?_) rw [insert_subset_iff, singleton_subset_iff] exact ⟨ht, hf⟩, (p.mem_or_not_mem φ).resolve_left⟩ #align first_order.language.Theory.complete_type.not_mem_iff FirstOrder.Language.Theory.CompleteType.not_mem_iff @[simp] theorem compl_setOf_mem {φ : L[[α]].Sentence} : { p : T.CompleteType α | φ ∈ p }ᶜ = { p : T.CompleteType α | φ.not ∈ p } := ext fun _ => (not_mem_iff _ _).symm #align first_order.language.Theory.complete_type.compl_set_of_mem FirstOrder.Language.Theory.CompleteType.compl_setOf_mem theorem setOf_subset_eq_empty_iff (S : L[[α]].Theory) : { p : T.CompleteType α | S ⊆ ↑p } = ∅ ↔ ¬((L.lhomWithConstants α).onTheory T ∪ S).IsSatisfiable := by rw [iff_not_comm, ← not_nonempty_iff_eq_empty, Classical.not_not, Set.Nonempty] refine ⟨fun h => ⟨⟨L[[α]].completeTheory h.some, (subset_union_left (t := S)).trans completeTheory.subset, completeTheory.isMaximal (L[[α]]) h.some⟩, (((L.lhomWithConstants α).onTheory T).subset_union_right).trans completeTheory.subset⟩, ?_⟩ rintro ⟨p, hp⟩ exact p.isMaximal.1.mono (union_subset p.subset hp) #align first_order.language.Theory.complete_type.set_of_subset_eq_empty_iff FirstOrder.Language.Theory.CompleteType.setOf_subset_eq_empty_iff
Mathlib/ModelTheory/Types.lean
129
132
theorem setOf_mem_eq_univ_iff (φ : L[[α]].Sentence) : { p : T.CompleteType α | φ ∈ p } = Set.univ ↔ (L.lhomWithConstants α).onTheory T ⊨ᵇ φ := by
rw [models_iff_not_satisfiable, ← compl_empty_iff, compl_setOf_mem, ← setOf_subset_eq_empty_iff] simp
/- 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.Algebra.Order.Ring.Defs import Mathlib.Algebra.Ring.Invertible import Mathlib.Data.Nat.Cast.Order #align_import algebra.order.invertible from "leanprover-community/mathlib"@"ee0c179cd3c8a45aa5bffbf1b41d8dbede452865" /-! # Lemmas about `invOf` in ordered (semi)rings. -/ variable {α : Type*} [LinearOrderedSemiring α] {a : α} @[simp] theorem invOf_pos [Invertible a] : 0 < ⅟ a ↔ 0 < a := haveI : 0 < a * ⅟ a := by simp only [mul_invOf_self, zero_lt_one] ⟨fun h => pos_of_mul_pos_left this h.le, fun h => pos_of_mul_pos_right this h.le⟩ #align inv_of_pos invOf_pos @[simp] theorem invOf_nonpos [Invertible a] : ⅟ a ≤ 0 ↔ a ≤ 0 := by simp only [← not_lt, invOf_pos] #align inv_of_nonpos invOf_nonpos @[simp] theorem invOf_nonneg [Invertible a] : 0 ≤ ⅟ a ↔ 0 ≤ a := haveI : 0 < a * ⅟ a := by simp only [mul_invOf_self, zero_lt_one] ⟨fun h => (pos_of_mul_pos_left this h).le, fun h => (pos_of_mul_pos_right this h).le⟩ #align inv_of_nonneg invOf_nonneg @[simp]
Mathlib/Algebra/Order/Invertible.lean
35
35
theorem invOf_lt_zero [Invertible a] : ⅟ a < 0 ↔ a < 0 := by
simp only [← not_le, invOf_nonneg]
/- 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.Algebra.Module.Defs import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Data.Int.Cast.Lemmas import Mathlib.GroupTheory.GroupAction.Units #align_import data.int.absolute_value from "leanprover-community/mathlib"@"9aba7801eeecebb61f58a5763c2b6dd1b47dc6ef" /-! # Absolute values and the integers This file contains some results on absolute values applied to integers. ## Main results * `AbsoluteValue.map_units_int`: an absolute value sends all units of `ℤ` to `1` * `Int.natAbsHom`: `Int.natAbs` bundled as a `MonoidWithZeroHom` -/ variable {R S : Type*} [Ring R] [LinearOrderedCommRing S] @[simp]
Mathlib/Data/Int/AbsoluteValue.lean
28
29
theorem AbsoluteValue.map_units_int (abv : AbsoluteValue ℤ S) (x : ℤˣ) : abv x = 1 := by
rcases Int.units_eq_one_or x with (rfl | rfl) <;> simp
/- Copyright (c) 2019 Gabriel Ebner. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Gabriel Ebner, Anatole Dedecker, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Mul import Mathlib.Analysis.Calculus.FDeriv.Add #align_import analysis.calculus.deriv.mul from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Derivative of `f x * g x` In this file we prove formulas for `(f x * g x)'` and `(f x • g x)'`. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative, multiplication -/ universe u v w noncomputable section open scoped Classical Topology Filter ENNReal open Filter Asymptotics Set open ContinuousLinearMap (smulRight smulRight_one_eq_iff) variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] variable {f f₀ f₁ g : 𝕜 → F} variable {f' f₀' f₁' g' : F} variable {x : 𝕜} variable {s t : Set 𝕜} variable {L L₁ L₂ : Filter 𝕜} /-! ### Derivative of bilinear maps -/ namespace ContinuousLinearMap variable {B : E →L[𝕜] F →L[𝕜] G} {u : 𝕜 → E} {v : 𝕜 → F} {u' : E} {v' : F} theorem hasDerivWithinAt_of_bilinear (hu : HasDerivWithinAt u u' s x) (hv : HasDerivWithinAt v v' s x) : HasDerivWithinAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) s x := by simpa using (B.hasFDerivWithinAt_of_bilinear hu.hasFDerivWithinAt hv.hasFDerivWithinAt).hasDerivWithinAt theorem hasDerivAt_of_bilinear (hu : HasDerivAt u u' x) (hv : HasDerivAt v v' x) : HasDerivAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) x := by simpa using (B.hasFDerivAt_of_bilinear hu.hasFDerivAt hv.hasFDerivAt).hasDerivAt theorem hasStrictDerivAt_of_bilinear (hu : HasStrictDerivAt u u' x) (hv : HasStrictDerivAt v v' x) : HasStrictDerivAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) x := by simpa using (B.hasStrictFDerivAt_of_bilinear hu.hasStrictFDerivAt hv.hasStrictFDerivAt).hasStrictDerivAt theorem derivWithin_of_bilinear (hxs : UniqueDiffWithinAt 𝕜 s x) (hu : DifferentiableWithinAt 𝕜 u s x) (hv : DifferentiableWithinAt 𝕜 v s x) : derivWithin (fun y => B (u y) (v y)) s x = B (u x) (derivWithin v s x) + B (derivWithin u s x) (v x) := (B.hasDerivWithinAt_of_bilinear hu.hasDerivWithinAt hv.hasDerivWithinAt).derivWithin hxs theorem deriv_of_bilinear (hu : DifferentiableAt 𝕜 u x) (hv : DifferentiableAt 𝕜 v x) : deriv (fun y => B (u y) (v y)) x = B (u x) (deriv v x) + B (deriv u x) (v x) := (B.hasDerivAt_of_bilinear hu.hasDerivAt hv.hasDerivAt).deriv end ContinuousLinearMap section SMul /-! ### Derivative of the multiplication of a scalar function and a vector function -/ variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' F] [IsScalarTower 𝕜 𝕜' F] {c : 𝕜 → 𝕜'} {c' : 𝕜'} theorem HasDerivWithinAt.smul (hc : HasDerivWithinAt c c' s x) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun y => c y • f y) (c x • f' + c' • f x) s x := by simpa using (HasFDerivWithinAt.smul hc hf).hasDerivWithinAt #align has_deriv_within_at.smul HasDerivWithinAt.smul
Mathlib/Analysis/Calculus/Deriv/Mul.lean
92
95
theorem HasDerivAt.smul (hc : HasDerivAt c c' x) (hf : HasDerivAt f f' x) : HasDerivAt (fun y => c y • f y) (c x • f' + c' • f x) x := by
rw [← hasDerivWithinAt_univ] at * exact hc.smul hf
/- 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, Jeremy Avigad -/ import Mathlib.Order.Filter.Lift import Mathlib.Topology.Defs.Filter #align_import topology.basic from "leanprover-community/mathlib"@"e354e865255654389cc46e6032160238df2e0f40" /-! # Basic theory of topological spaces. The main definition is the type class `TopologicalSpace X` which endows a type `X` with a topology. Then `Set X` gets predicates `IsOpen`, `IsClosed` and functions `interior`, `closure` and `frontier`. Each point `x` of `X` gets a neighborhood filter `𝓝 x`. A filter `F` on `X` has `x` as a cluster point if `ClusterPt x F : 𝓝 x ⊓ F ≠ ⊥`. A map `f : α → X` clusters at `x` along `F : Filter α` if `MapClusterPt x F f : ClusterPt x (map f F)`. In particular the notion of cluster point of a sequence `u` is `MapClusterPt x atTop u`. For topological spaces `X` and `Y`, a function `f : X → Y` and a point `x : X`, `ContinuousAt f x` means `f` is continuous at `x`, and global continuity is `Continuous f`. There is also a version of continuity `PContinuous` for partially defined functions. ## Notation The following notation is introduced elsewhere and it heavily used in this file. * `𝓝 x`: the filter `nhds x` 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`; * `𝓝[≠] x`: the filter `nhdsWithin x {x}ᶜ` of punctured neighborhoods of `x`. ## Implementation notes Topology in mathlib heavily uses filters (even more than in Bourbaki). See explanations in <https://leanprover-community.github.io/theories/topology.html>. ## References * [N. Bourbaki, *General Topology*][bourbaki1966] * [I. M. James, *Topologies and Uniformities*][james1999] ## Tags topological space, interior, closure, frontier, neighborhood, continuity, continuous function -/ noncomputable section open Set Filter universe u v w x /-! ### Topological spaces -/ /-- A constructor for topologies by specifying the closed sets, and showing that they satisfy the appropriate conditions. -/ def TopologicalSpace.ofClosed {X : Type u} (T : Set (Set X)) (empty_mem : ∅ ∈ T) (sInter_mem : ∀ A, A ⊆ T → ⋂₀ A ∈ T) (union_mem : ∀ A, A ∈ T → ∀ B, B ∈ T → A ∪ B ∈ T) : TopologicalSpace X where IsOpen X := Xᶜ ∈ T isOpen_univ := by simp [empty_mem] isOpen_inter s t hs ht := by simpa only [compl_inter] using union_mem sᶜ hs tᶜ ht isOpen_sUnion s hs := by simp only [Set.compl_sUnion] exact sInter_mem (compl '' s) fun z ⟨y, hy, hz⟩ => hz ▸ hs y hy #align topological_space.of_closed TopologicalSpace.ofClosed section TopologicalSpace variable {X : Type u} {Y : Type v} {ι : Sort w} {α β : Type*} {x : X} {s s₁ s₂ t : Set X} {p p₁ p₂ : X → Prop} open Topology lemma isOpen_mk {p h₁ h₂ h₃} : IsOpen[⟨p, h₁, h₂, h₃⟩] s ↔ p s := Iff.rfl #align is_open_mk isOpen_mk @[ext] protected theorem TopologicalSpace.ext : ∀ {f g : TopologicalSpace X}, IsOpen[f] = IsOpen[g] → f = g | ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl #align topological_space_eq TopologicalSpace.ext section variable [TopologicalSpace X] end protected theorem TopologicalSpace.ext_iff {t t' : TopologicalSpace X} : t = t' ↔ ∀ s, IsOpen[t] s ↔ IsOpen[t'] s := ⟨fun h s => h ▸ Iff.rfl, fun h => by ext; exact h _⟩ #align topological_space_eq_iff TopologicalSpace.ext_iff theorem isOpen_fold {t : TopologicalSpace X} : t.IsOpen s = IsOpen[t] s := rfl #align is_open_fold isOpen_fold variable [TopologicalSpace X] theorem isOpen_iUnion {f : ι → Set X} (h : ∀ i, IsOpen (f i)) : IsOpen (⋃ i, f i) := isOpen_sUnion (forall_mem_range.2 h) #align is_open_Union isOpen_iUnion theorem isOpen_biUnion {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) : IsOpen (⋃ i ∈ s, f i) := isOpen_iUnion fun i => isOpen_iUnion fun hi => h i hi #align is_open_bUnion isOpen_biUnion
Mathlib/Topology/Basic.lean
115
116
theorem IsOpen.union (h₁ : IsOpen s₁) (h₂ : IsOpen s₂) : IsOpen (s₁ ∪ s₂) := by
rw [union_eq_iUnion]; exact isOpen_iUnion (Bool.forall_bool.2 ⟨h₂, h₁⟩)
/- 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 α]
Mathlib/Init/Order/LinearOrder.lean
25
26
theorem min_def (a b : α) : min a b = if a ≤ b then a else b := by
rw [LinearOrder.min_def a]
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.MeasureTheory.Measure.MeasureSpaceDef #align_import measure_theory.measure.ae_disjoint from "leanprover-community/mathlib"@"bc7d81beddb3d6c66f71449c5bc76c38cb77cf9e" /-! # Almost everywhere disjoint sets We say that sets `s` and `t` are `μ`-a.e. disjoint (see `MeasureTheory.AEDisjoint`) if their intersection has measure zero. This assumption can be used instead of `Disjoint` in most theorems in measure theory. -/ open Set Function namespace MeasureTheory variable {ι α : Type*} {m : MeasurableSpace α} (μ : Measure α) /-- Two sets are said to be `μ`-a.e. disjoint if their intersection has measure zero. -/ def AEDisjoint (s t : Set α) := μ (s ∩ t) = 0 #align measure_theory.ae_disjoint MeasureTheory.AEDisjoint variable {μ} {s t u v : Set α} /-- If `s : ι → Set α` is a countable family of pairwise a.e. disjoint sets, then there exists a family of measurable null sets `t i` such that `s i \ t i` are pairwise disjoint. -/ theorem exists_null_pairwise_disjoint_diff [Countable ι] {s : ι → Set α} (hd : Pairwise (AEDisjoint μ on s)) : ∃ t : ι → Set α, (∀ i, MeasurableSet (t i)) ∧ (∀ i, μ (t i) = 0) ∧ Pairwise (Disjoint on fun i => s i \ t i) := by refine ⟨fun i => toMeasurable μ (s i ∩ ⋃ j ∈ ({i}ᶜ : Set ι), s j), fun i => measurableSet_toMeasurable _ _, fun i => ?_, ?_⟩ · simp only [measure_toMeasurable, inter_iUnion] exact (measure_biUnion_null_iff <| to_countable _).2 fun j hj => hd (Ne.symm hj) · simp only [Pairwise, disjoint_left, onFun, mem_diff, not_and, and_imp, Classical.not_not] intro i j hne x hi hU hj replace hU : x ∉ s i ∩ iUnion fun j ↦ iUnion fun _ ↦ s j := fun h ↦ hU (subset_toMeasurable _ _ h) simp only [mem_inter_iff, mem_iUnion, not_and, not_exists] at hU exact (hU hi j hne.symm hj).elim #align measure_theory.exists_null_pairwise_disjoint_diff MeasureTheory.exists_null_pairwise_disjoint_diff namespace AEDisjoint protected theorem eq (h : AEDisjoint μ s t) : μ (s ∩ t) = 0 := h #align measure_theory.ae_disjoint.eq MeasureTheory.AEDisjoint.eq @[symm] protected theorem symm (h : AEDisjoint μ s t) : AEDisjoint μ t s := by rwa [AEDisjoint, inter_comm] #align measure_theory.ae_disjoint.symm MeasureTheory.AEDisjoint.symm protected theorem symmetric : Symmetric (AEDisjoint μ) := fun _ _ => AEDisjoint.symm #align measure_theory.ae_disjoint.symmetric MeasureTheory.AEDisjoint.symmetric protected theorem comm : AEDisjoint μ s t ↔ AEDisjoint μ t s := ⟨AEDisjoint.symm, AEDisjoint.symm⟩ #align measure_theory.ae_disjoint.comm MeasureTheory.AEDisjoint.comm protected theorem _root_.Disjoint.aedisjoint (h : Disjoint s t) : AEDisjoint μ s t := by rw [AEDisjoint, disjoint_iff_inter_eq_empty.1 h, measure_empty] #align disjoint.ae_disjoint Disjoint.aedisjoint protected theorem _root_.Pairwise.aedisjoint {f : ι → Set α} (hf : Pairwise (Disjoint on f)) : Pairwise (AEDisjoint μ on f) := hf.mono fun _i _j h => h.aedisjoint #align pairwise.ae_disjoint Pairwise.aedisjoint protected theorem _root_.Set.PairwiseDisjoint.aedisjoint {f : ι → Set α} {s : Set ι} (hf : s.PairwiseDisjoint f) : s.Pairwise (AEDisjoint μ on f) := hf.mono' fun _i _j h => h.aedisjoint #align set.pairwise_disjoint.ae_disjoint Set.PairwiseDisjoint.aedisjoint theorem mono_ae (h : AEDisjoint μ s t) (hu : u ≤ᵐ[μ] s) (hv : v ≤ᵐ[μ] t) : AEDisjoint μ u v := measure_mono_null_ae (hu.inter hv) h #align measure_theory.ae_disjoint.mono_ae MeasureTheory.AEDisjoint.mono_ae protected theorem mono (h : AEDisjoint μ s t) (hu : u ⊆ s) (hv : v ⊆ t) : AEDisjoint μ u v := mono_ae h (HasSubset.Subset.eventuallyLE hu) (HasSubset.Subset.eventuallyLE hv) #align measure_theory.ae_disjoint.mono MeasureTheory.AEDisjoint.mono protected theorem congr (h : AEDisjoint μ s t) (hu : u =ᵐ[μ] s) (hv : v =ᵐ[μ] t) : AEDisjoint μ u v := mono_ae h (Filter.EventuallyEq.le hu) (Filter.EventuallyEq.le hv) #align measure_theory.ae_disjoint.congr MeasureTheory.AEDisjoint.congr @[simp]
Mathlib/MeasureTheory/Measure/AEDisjoint.lean
94
96
theorem iUnion_left_iff [Countable ι] {s : ι → Set α} : AEDisjoint μ (⋃ i, s i) t ↔ ∀ i, AEDisjoint μ (s i) t := by
simp only [AEDisjoint, iUnion_inter, measure_iUnion_null_iff]
/- Copyright (c) 2021 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.LinearAlgebra.Basis import Mathlib.LinearAlgebra.Multilinear.Basic #align_import linear_algebra.multilinear.basis from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" /-! # Multilinear maps in relation to bases. This file proves lemmas about the action of multilinear maps on basis vectors. ## TODO * Refactor the proofs in terms of bases of tensor products, once there is an equivalent of `Basis.tensorProduct` for `pi_tensor_product`. -/ open MultilinearMap variable {R : Type*} {ι : Type*} {n : ℕ} {M : Fin n → Type*} {M₂ : Type*} {M₃ : Type*} variable [CommSemiring R] [AddCommMonoid M₂] [AddCommMonoid M₃] [∀ i, AddCommMonoid (M i)] variable [∀ i, Module R (M i)] [Module R M₂] [Module R M₃] /-- Two multilinear maps indexed by `Fin n` are equal if they are equal when all arguments are basis vectors. -/
Mathlib/LinearAlgebra/Multilinear/Basis.lean
32
49
theorem Basis.ext_multilinear_fin {f g : MultilinearMap R M M₂} {ι₁ : Fin n → Type*} (e : ∀ i, Basis (ι₁ i) R (M i)) (h : ∀ v : ∀ i, ι₁ i, (f fun i => e i (v i)) = g fun i => e i (v i)) : f = g := by
induction' n with m hm · ext x convert h finZeroElim · apply Function.LeftInverse.injective uncurry_curryLeft refine Basis.ext (e 0) ?_ intro i apply hm (Fin.tail e) intro j convert h (Fin.cons i j) iterate 2 rw [curryLeft_apply] congr 1 with x refine Fin.cases rfl (fun x => ?_) x dsimp [Fin.tail] rw [Fin.cons_succ, Fin.cons_succ]
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.Complex.Basic import Mathlib.Topology.FiberBundle.IsHomeomorphicTrivialBundle #align_import analysis.complex.re_im_topology from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6" /-! # Closure, interior, and frontier of preimages under `re` and `im` In this fact we use the fact that `ℂ` is naturally homeomorphic to `ℝ × ℝ` to deduce some topological properties of `Complex.re` and `Complex.im`. ## Main statements Each statement about `Complex.re` listed below has a counterpart about `Complex.im`. * `Complex.isHomeomorphicTrivialFiberBundle_re`: `Complex.re` turns `ℂ` into a trivial topological fiber bundle over `ℝ`; * `Complex.isOpenMap_re`, `Complex.quotientMap_re`: in particular, `Complex.re` is an open map and is a quotient map; * `Complex.interior_preimage_re`, `Complex.closure_preimage_re`, `Complex.frontier_preimage_re`: formulas for `interior (Complex.re ⁻¹' s)` etc; * `Complex.interior_setOf_re_le` etc: particular cases of the above formulas in the cases when `s` is one of the infinite intervals `Set.Ioi a`, `Set.Ici a`, `Set.Iio a`, and `Set.Iic a`, formulated as `interior {z : ℂ | z.re ≤ a} = {z | z.re < a}` etc. ## Tags complex, real part, imaginary part, closure, interior, frontier -/ open Set noncomputable section namespace Complex /-- `Complex.re` turns `ℂ` into a trivial topological fiber bundle over `ℝ`. -/ theorem isHomeomorphicTrivialFiberBundle_re : IsHomeomorphicTrivialFiberBundle ℝ re := ⟨equivRealProdCLM.toHomeomorph, fun _ => rfl⟩ #align complex.is_homeomorphic_trivial_fiber_bundle_re Complex.isHomeomorphicTrivialFiberBundle_re /-- `Complex.im` turns `ℂ` into a trivial topological fiber bundle over `ℝ`. -/ theorem isHomeomorphicTrivialFiberBundle_im : IsHomeomorphicTrivialFiberBundle ℝ im := ⟨equivRealProdCLM.toHomeomorph.trans (Homeomorph.prodComm ℝ ℝ), fun _ => rfl⟩ #align complex.is_homeomorphic_trivial_fiber_bundle_im Complex.isHomeomorphicTrivialFiberBundle_im theorem isOpenMap_re : IsOpenMap re := isHomeomorphicTrivialFiberBundle_re.isOpenMap_proj #align complex.is_open_map_re Complex.isOpenMap_re theorem isOpenMap_im : IsOpenMap im := isHomeomorphicTrivialFiberBundle_im.isOpenMap_proj #align complex.is_open_map_im Complex.isOpenMap_im theorem quotientMap_re : QuotientMap re := isHomeomorphicTrivialFiberBundle_re.quotientMap_proj #align complex.quotient_map_re Complex.quotientMap_re theorem quotientMap_im : QuotientMap im := isHomeomorphicTrivialFiberBundle_im.quotientMap_proj #align complex.quotient_map_im Complex.quotientMap_im theorem interior_preimage_re (s : Set ℝ) : interior (re ⁻¹' s) = re ⁻¹' interior s := (isOpenMap_re.preimage_interior_eq_interior_preimage continuous_re _).symm #align complex.interior_preimage_re Complex.interior_preimage_re theorem interior_preimage_im (s : Set ℝ) : interior (im ⁻¹' s) = im ⁻¹' interior s := (isOpenMap_im.preimage_interior_eq_interior_preimage continuous_im _).symm #align complex.interior_preimage_im Complex.interior_preimage_im theorem closure_preimage_re (s : Set ℝ) : closure (re ⁻¹' s) = re ⁻¹' closure s := (isOpenMap_re.preimage_closure_eq_closure_preimage continuous_re _).symm #align complex.closure_preimage_re Complex.closure_preimage_re theorem closure_preimage_im (s : Set ℝ) : closure (im ⁻¹' s) = im ⁻¹' closure s := (isOpenMap_im.preimage_closure_eq_closure_preimage continuous_im _).symm #align complex.closure_preimage_im Complex.closure_preimage_im theorem frontier_preimage_re (s : Set ℝ) : frontier (re ⁻¹' s) = re ⁻¹' frontier s := (isOpenMap_re.preimage_frontier_eq_frontier_preimage continuous_re _).symm #align complex.frontier_preimage_re Complex.frontier_preimage_re theorem frontier_preimage_im (s : Set ℝ) : frontier (im ⁻¹' s) = im ⁻¹' frontier s := (isOpenMap_im.preimage_frontier_eq_frontier_preimage continuous_im _).symm #align complex.frontier_preimage_im Complex.frontier_preimage_im @[simp]
Mathlib/Analysis/Complex/ReImTopology.lean
94
95
theorem interior_setOf_re_le (a : ℝ) : interior { z : ℂ | z.re ≤ a } = { z | z.re < a } := by
simpa only [interior_Iic] using interior_preimage_re (Iic a)