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) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.SpecialFunctions.ExpDeriv #align_import analysis.ODE.gronwall from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Grönwall's inequality The main technical result of this file is the Grönwall-like inequality `norm_le_gronwallBound_of_norm_deriv_right_le`. It states that if `f : ℝ → E` satisfies `‖f a‖ ≤ δ` and `∀ x ∈ [a, b), ‖f' x‖ ≤ K * ‖f x‖ + ε`, then for all `x ∈ [a, b]` we have `‖f x‖ ≤ δ * exp (K * x) + (ε / K) * (exp (K * x) - 1)`. Then we use this inequality to prove some estimates on the possible rate of growth of the distance between two approximate or exact solutions of an ordinary differential equation. The proofs are based on [Hubbard and West, *Differential Equations: A Dynamical Systems Approach*, Sec. 4.5][HubbardWest-ode], where `norm_le_gronwallBound_of_norm_deriv_right_le` is called “Fundamental Inequality”. ## TODO - Once we have FTC, prove an inequality for a function satisfying `‖f' x‖ ≤ K x * ‖f x‖ + ε`, or more generally `liminf_{y→x+0} (f y - f x)/(y - x) ≤ K x * f x + ε` with any sign of `K x` and `f x`. -/ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] open Metric Set Asymptotics Filter Real open scoped Classical Topology NNReal /-! ### Technical lemmas about `gronwallBound` -/ /-- Upper bound used in several Grönwall-like inequalities. -/ noncomputable def gronwallBound (δ K ε x : ℝ) : ℝ := if K = 0 then δ + ε * x else δ * exp (K * x) + ε / K * (exp (K * x) - 1) #align gronwall_bound gronwallBound theorem gronwallBound_K0 (δ ε : ℝ) : gronwallBound δ 0 ε = fun x => δ + ε * x := funext fun _ => if_pos rfl set_option linter.uppercaseLean3 false in #align gronwall_bound_K0 gronwallBound_K0 theorem gronwallBound_of_K_ne_0 {δ K ε : ℝ} (hK : K ≠ 0) : gronwallBound δ K ε = fun x => δ * exp (K * x) + ε / K * (exp (K * x) - 1) := funext fun _ => if_neg hK set_option linter.uppercaseLean3 false in #align gronwall_bound_of_K_ne_0 gronwallBound_of_K_ne_0 theorem hasDerivAt_gronwallBound (δ K ε x : ℝ) : HasDerivAt (gronwallBound δ K ε) (K * gronwallBound δ K ε x + ε) x := by by_cases hK : K = 0 · subst K simp only [gronwallBound_K0, zero_mul, zero_add] convert ((hasDerivAt_id x).const_mul ε).const_add δ rw [mul_one] · simp only [gronwallBound_of_K_ne_0 hK] convert (((hasDerivAt_id x).const_mul K).exp.const_mul δ).add ((((hasDerivAt_id x).const_mul K).exp.sub_const 1).const_mul (ε / K)) using 1 simp only [id, mul_add, (mul_assoc _ _ _).symm, mul_comm _ K, mul_div_cancel₀ _ hK] ring #align has_deriv_at_gronwall_bound hasDerivAt_gronwallBound theorem hasDerivAt_gronwallBound_shift (δ K ε x a : ℝ) : HasDerivAt (fun y => gronwallBound δ K ε (y - a)) (K * gronwallBound δ K ε (x - a) + ε) x := by convert (hasDerivAt_gronwallBound δ K ε _).comp x ((hasDerivAt_id x).sub_const a) using 1 rw [id, mul_one] #align has_deriv_at_gronwall_bound_shift hasDerivAt_gronwallBound_shift
Mathlib/Analysis/ODE/Gronwall.lean
79
83
theorem gronwallBound_x0 (δ K ε : ℝ) : gronwallBound δ K ε 0 = δ := by
by_cases hK : K = 0 · simp only [gronwallBound, if_pos hK, mul_zero, add_zero] · simp only [gronwallBound, if_neg hK, mul_zero, exp_zero, sub_self, mul_one, add_zero]
/- 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. -/ 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] #align basis.ext_multilinear_fin Basis.ext_multilinear_fin /-- Two multilinear maps indexed by a `Fintype` are equal if they are equal when all arguments are basis vectors. Unlike `Basis.ext_multilinear_fin`, this only uses a single basis; a dependently-typed version would still be true, but the proof would need a dependently-typed version of `dom_dom_congr`. -/
Mathlib/LinearAlgebra/Multilinear/Basis.lean
56
61
theorem Basis.ext_multilinear [Finite ι] {f g : MultilinearMap R (fun _ : ι => M₂) M₃} {ι₁ : Type*} (e : Basis ι₁ R M₂) (h : ∀ v : ι → ι₁, (f fun i => e (v i)) = g fun i => e (v i)) : f = g := by
cases nonempty_fintype ι exact (domDomCongr_eq_iff (Fintype.equivFin ι) f g).mp (Basis.ext_multilinear_fin (fun _ => e) fun i => h (i ∘ _))
/- Copyright (c) 2022 María Inés de Frutos-Fernández. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: María Inés de Frutos-Fernández -/ import Mathlib.RingTheory.DedekindDomain.Ideal #align_import ring_theory.dedekind_domain.factorization from "leanprover-community/mathlib"@"2f588be38bb5bec02f218ba14f82fc82eb663f87" /-! # Factorization of ideals and fractional ideals of Dedekind domains Every nonzero ideal `I` of a Dedekind domain `R` can be factored as a product `∏_v v^{n_v}` over the maximal ideals of `R`, where the exponents `n_v` are natural numbers. Similarly, every nonzero fractional ideal `I` of a Dedekind domain `R` can be factored as a product `∏_v v^{n_v}` over the maximal ideals of `R`, where the exponents `n_v` are integers. We define `FractionalIdeal.count K v I` (abbreviated as `val_v(I)` in the documentation) to be `n_v`, and we prove some of its properties. If `I = 0`, we define `val_v(I) = 0`. ## Main definitions - `FractionalIdeal.count` : If `I` is a nonzero fractional ideal, `a ∈ R`, and `J` is an ideal of `R` such that `I = a⁻¹J`, then we define `val_v(I)` as `(val_v(J) - val_v(a))`. If `I = 0`, we set `val_v(I) = 0`. ## Main results - `Ideal.finite_factors` : Only finitely many maximal ideals of `R` divide a given nonzero ideal. - `Ideal.finprod_heightOneSpectrum_factorization` : The ideal `I` equals the finprod `∏_v v^(val_v(I))`, where `val_v(I)` denotes the multiplicity of `v` in the factorization of `I` and `v` runs over the maximal ideals of `R`. - `FractionalIdeal.finprod_heightOneSpectrum_factorization` : If `I` is a nonzero fractional ideal, `a ∈ R`, and `J` is an ideal of `R` such that `I = a⁻¹J`, then `I` is equal to the product `∏_v v^(val_v(J) - val_v(a))`. - `FractionalIdeal.finprod_heightOneSpectrum_factorization'` : If `I` is a nonzero fractional ideal, then `I` is equal to the product `∏_v v^(val_v(I))`. - `FractionalIdeal.finprod_heightOneSpectrum_factorization_principal` : For a nonzero `k = r/s ∈ K`, the fractional ideal `(k)` is equal to the product `∏_v v^(val_v(r) - val_v(s))`. - `FractionalIdeal.finite_factors` : If `I ≠ 0`, then `val_v(I) = 0` for all but finitely many maximal ideals of `R`. ## Implementation notes Since we are only interested in the factorization of nonzero fractional ideals, we define `val_v(0) = 0` so that every `val_v` is in `ℤ` and we can avoid having to use `WithTop ℤ`. ## Tags dedekind domain, fractional ideal, ideal, factorization -/ noncomputable section open scoped Classical nonZeroDivisors open Set Function UniqueFactorizationMonoid IsDedekindDomain IsDedekindDomain.HeightOneSpectrum Classical variable {R : Type*} [CommRing R] {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K] /-! ### Factorization of ideals of Dedekind domains -/ variable [IsDedekindDomain R] (v : HeightOneSpectrum R) /-- Given a maximal ideal `v` and an ideal `I` of `R`, `maxPowDividing` returns the maximal power of `v` dividing `I`. -/ def IsDedekindDomain.HeightOneSpectrum.maxPowDividing (I : Ideal R) : Ideal R := v.asIdeal ^ (Associates.mk v.asIdeal).count (Associates.mk I).factors #align is_dedekind_domain.height_one_spectrum.max_pow_dividing IsDedekindDomain.HeightOneSpectrum.maxPowDividing /-- Only finitely many maximal ideals of `R` divide a given nonzero ideal. -/ theorem Ideal.finite_factors {I : Ideal R} (hI : I ≠ 0) : {v : HeightOneSpectrum R | v.asIdeal ∣ I}.Finite := by rw [← Set.finite_coe_iff, Set.coe_setOf] haveI h_fin := fintypeSubtypeDvd I hI refine Finite.of_injective (fun v => (⟨(v : HeightOneSpectrum R).asIdeal, v.2⟩ : { x // x ∣ I })) ?_ intro v w hvw simp? at hvw says simp only [Subtype.mk.injEq] at hvw exact Subtype.coe_injective ((HeightOneSpectrum.ext_iff (R := R) ↑v ↑w).mpr hvw) #align ideal.finite_factors Ideal.finite_factors /-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that the multiplicity of `v` in the factorization of `I`, denoted `val_v(I)`, is nonzero. -/
Mathlib/RingTheory/DedekindDomain/Factorization.lean
81
90
theorem Associates.finite_factors {I : Ideal R} (hI : I ≠ 0) : ∀ᶠ v : HeightOneSpectrum R in Filter.cofinite, ((Associates.mk v.asIdeal).count (Associates.mk I).factors : ℤ) = 0 := by
have h_supp : {v : HeightOneSpectrum R | ¬((Associates.mk v.asIdeal).count (Associates.mk I).factors : ℤ) = 0} = {v : HeightOneSpectrum R | v.asIdeal ∣ I} := by ext v simp_rw [Int.natCast_eq_zero] exact Associates.count_ne_zero_iff_dvd hI v.irreducible rw [Filter.eventually_cofinite, h_supp] exact Ideal.finite_factors hI
/- Copyright (c) 2023 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.LinearAlgebra.Dual /-! # Perfect pairings of modules A perfect pairing of two (left) modules may be defined either as: 1. A bilinear map `M × N → R` such that the induced maps `M → Dual R N` and `N → Dual R M` are both bijective. It follows from this that both `M` and `N` are reflexive modules. 2. A linear equivalence `N ≃ Dual R M` for which `M` is reflexive. (It then follows that `N` is reflexive.) In this file we provide a `PerfectPairing` definition corresponding to 1 above, together with logic to connect 1 and 2. ## Main definitions * `PerfectPairing` * `PerfectPairing.flip` * `PerfectPairing.toDualLeft` * `PerfectPairing.toDualRight` * `LinearEquiv.flip` * `LinearEquiv.isReflexive_of_equiv_dual_of_isReflexive` * `LinearEquiv.toPerfectPairing` -/ open Function Module variable (R M N : Type*) [CommRing R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] /-- A perfect pairing of two (left) modules over a commutative ring. -/ structure PerfectPairing := toLin : M →ₗ[R] N →ₗ[R] R bijectiveLeft : Bijective toLin bijectiveRight : Bijective toLin.flip attribute [nolint docBlame] PerfectPairing.toLin variable {R M N} namespace PerfectPairing instance instFunLike : FunLike (PerfectPairing R M N) M (N →ₗ[R] R) where coe f := f.toLin coe_injective' x y h := by cases x; cases y; simpa using h variable (p : PerfectPairing R M N) /-- Given a perfect pairing between `M` and `N`, we may interchange the roles of `M` and `N`. -/ protected def flip : PerfectPairing R N M where toLin := p.toLin.flip bijectiveLeft := p.bijectiveRight bijectiveRight := p.bijectiveLeft @[simp] lemma flip_flip : p.flip.flip = p := rfl /-- The linear equivalence from `M` to `Dual R N` induced by a perfect pairing. -/ noncomputable def toDualLeft : M ≃ₗ[R] Dual R N := LinearEquiv.ofBijective p.toLin p.bijectiveLeft @[simp] theorem toDualLeft_apply (a : M) : p.toDualLeft a = p a := rfl @[simp] theorem apply_toDualLeft_symm_apply (f : Dual R N) (x : N) : p (p.toDualLeft.symm f) x = f x := by have h := LinearEquiv.apply_symm_apply p.toDualLeft f rw [toDualLeft_apply] at h exact congrFun (congrArg DFunLike.coe h) x /-- The linear equivalence from `N` to `Dual R M` induced by a perfect pairing. -/ noncomputable def toDualRight : N ≃ₗ[R] Dual R M := toDualLeft p.flip @[simp] theorem toDualRight_apply (a : N) : p.toDualRight a = p.flip a := rfl @[simp] theorem apply_apply_toDualRight_symm (x : M) (f : Dual R M) : (p x) (p.toDualRight.symm f) = f x := by have h := LinearEquiv.apply_symm_apply p.toDualRight f rw [toDualRight_apply] at h exact congrFun (congrArg DFunLike.coe h) x theorem toDualLeft_of_toDualRight_symm (x : M) (f : Dual R M) : (p.toDualLeft x) (p.toDualRight.symm f) = f x := by rw [@toDualLeft_apply] exact apply_apply_toDualRight_symm p x f theorem toDualRight_symm_toDualLeft (x : M) : p.toDualRight.symm.dualMap (p.toDualLeft x) = Dual.eval R M x := by ext f simp only [LinearEquiv.dualMap_apply, Dual.eval_apply] exact toDualLeft_of_toDualRight_symm p x f theorem toDualRight_symm_comp_toDualLeft : p.toDualRight.symm.dualMap ∘ₗ (p.toDualLeft : M →ₗ[R] Dual R N) = Dual.eval R M := by ext1 x exact p.toDualRight_symm_toDualLeft x theorem bijective_toDualRight_symm_toDualLeft : Bijective (fun x => p.toDualRight.symm.dualMap (p.toDualLeft x)) := Bijective.comp (LinearEquiv.bijective p.toDualRight.symm.dualMap) (LinearEquiv.bijective p.toDualLeft)
Mathlib/LinearAlgebra/PerfectPairing.lean
112
115
theorem reflexive_left : IsReflexive R M where bijective_dual_eval' := by
rw [← p.toDualRight_symm_comp_toDualLeft] exact p.bijective_toDualRight_symm_toDualLeft
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Algebra.QuadraticDiscriminant import Mathlib.Analysis.Convex.SpecificFunctions.Deriv import Mathlib.Analysis.SpecialFunctions.Pow.Complex #align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92" /-! # Complex trigonometric functions Basic facts and derivatives for the complex trigonometric functions. Several facts about the real trigonometric functions have the proofs deferred here, rather than `Analysis.SpecialFunctions.Trigonometric.Basic`, as they are most easily proved by appealing to the corresponding fact for complex trigonometric functions, or require additional imports which are not available in that file. -/ noncomputable section namespace Complex open Set Filter open scoped Real theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul, add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub] ring_nf rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm] refine exists_congr fun x => ?_ refine (iff_of_eq <| congr_arg _ ?_).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero) field_simp; ring #align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by rw [← not_exists, not_iff_not, cos_eq_zero_iff] #align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff] constructor · rintro ⟨k, hk⟩ use k + 1 field_simp [eq_add_of_sub_eq hk] ring · rintro ⟨k, rfl⟩ use k - 1 field_simp ring #align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by rw [← not_exists, not_iff_not, sin_eq_zero_iff] #align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff /-- The tangent of a complex number is equal to zero iff this number is equal to `k * π / 2` for an integer `k`. Note that this lemma takes into account that we use zero as the junk value for division by zero. See also `Complex.tan_eq_zero_iff'`. -/
Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean
69
72
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, k * π / 2 = θ := by
rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← mul_right_inj' two_ne_zero, mul_zero, ← mul_assoc, ← sin_two_mul, sin_eq_zero_iff] field_simp [mul_comm, eq_comm]
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Order.Ring.Rat import Mathlib.Data.Rat.Cast.CharZero import Mathlib.Tactic.Positivity.Core import Mathlib.Algebra.Order.Field.Basic #align_import data.rat.cast from "leanprover-community/mathlib"@"acebd8d49928f6ed8920e502a6c90674e75bd441" /-! # Casts of rational numbers into linear ordered fields. -/ variable {F ι α β : Type*} namespace Rat variable {p q : ℚ} @[simp] theorem castHom_rat : castHom ℚ = RingHom.id ℚ := RingHom.ext cast_id #align rat.cast_hom_rat Rat.castHom_rat section LinearOrderedField variable {K : Type*} [LinearOrderedField K]
Mathlib/Data/Rat/Cast/Order.lean
31
33
theorem cast_pos_of_pos (hq : 0 < q) : (0 : K) < q := by
rw [Rat.cast_def] exact div_pos (Int.cast_pos.2 <| num_pos.2 hq) (Nat.cast_pos.2 q.pos)
/- Copyright (c) 2020 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.List.Basic /-! # Properties of `List.reduceOption` In this file we prove basic lemmas about `List.reduceOption`. -/ namespace List variable {α β : Type*} @[simp] theorem reduceOption_cons_of_some (x : α) (l : List (Option α)) : reduceOption (some x :: l) = x :: l.reduceOption := by simp only [reduceOption, filterMap, id, eq_self_iff_true, and_self_iff] #align list.reduce_option_cons_of_some List.reduceOption_cons_of_some @[simp] theorem reduceOption_cons_of_none (l : List (Option α)) : reduceOption (none :: l) = l.reduceOption := by simp only [reduceOption, filterMap, id] #align list.reduce_option_cons_of_none List.reduceOption_cons_of_none @[simp] theorem reduceOption_nil : @reduceOption α [] = [] := rfl #align list.reduce_option_nil List.reduceOption_nil @[simp] theorem reduceOption_map {l : List (Option α)} {f : α → β} : reduceOption (map (Option.map f) l) = map f (reduceOption l) := by induction' l with hd tl hl · simp only [reduceOption_nil, map_nil] · cases hd <;> simpa [true_and_iff, Option.map_some', map, eq_self_iff_true, reduceOption_cons_of_some] using hl #align list.reduce_option_map List.reduceOption_map theorem reduceOption_append (l l' : List (Option α)) : (l ++ l').reduceOption = l.reduceOption ++ l'.reduceOption := filterMap_append l l' id #align list.reduce_option_append List.reduceOption_append theorem reduceOption_length_eq {l : List (Option α)} : l.reduceOption.length = (l.filter Option.isSome).length := by induction' l with hd tl hl · simp_rw [reduceOption_nil, filter_nil, length] · cases hd <;> simp [hl] theorem length_eq_reduceOption_length_add_filter_none {l : List (Option α)} : l.length = l.reduceOption.length + (l.filter Option.isNone).length := by simp_rw [reduceOption_length_eq, l.length_eq_length_filter_add Option.isSome, Option.bnot_isSome] theorem reduceOption_length_le (l : List (Option α)) : l.reduceOption.length ≤ l.length := by rw [length_eq_reduceOption_length_add_filter_none] apply Nat.le_add_right #align list.reduce_option_length_le List.reduceOption_length_le
Mathlib/Data/List/ReduceOption.lean
64
66
theorem reduceOption_length_eq_iff {l : List (Option α)} : l.reduceOption.length = l.length ↔ ∀ x ∈ l, Option.isSome x := by
rw [reduceOption_length_eq, List.filter_length_eq_length]
/- Copyright (c) 2023 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals import Mathlib.Analysis.Calculus.ParametricIntegral import Mathlib.MeasureTheory.Measure.Haar.NormedSpace #align_import analysis.mellin_transform from "leanprover-community/mathlib"@"917c3c072e487b3cccdbfeff17e75b40e45f66cb" /-! # The Mellin transform We define the Mellin transform of a locally integrable function on `Ioi 0`, and show it is differentiable in a suitable vertical strip. ## Main statements - `mellin` : the Mellin transform `∫ (t : ℝ) in Ioi 0, t ^ (s - 1) • f t`, where `s` is a complex number. - `HasMellin`: shorthand asserting that the Mellin transform exists and has a given value (analogous to `HasSum`). - `mellin_differentiableAt_of_isBigO_rpow` : if `f` is `O(x ^ (-a))` at infinity, and `O(x ^ (-b))` at 0, then `mellin f` is holomorphic on the domain `b < re s < a`. -/ open MeasureTheory Set Filter Asymptotics TopologicalSpace open Real open Complex hiding exp log abs_of_nonneg open scoped Topology noncomputable section section Defs variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] /-- Predicate on `f` and `s` asserting that the Mellin integral is well-defined. -/ def MellinConvergent (f : ℝ → E) (s : ℂ) : Prop := IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (Ioi 0) #align mellin_convergent MellinConvergent theorem MellinConvergent.const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s) {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) : MellinConvergent (fun t => c • f t) s := by simpa only [MellinConvergent, smul_comm] using hf.smul c #align mellin_convergent.const_smul MellinConvergent.const_smul theorem MellinConvergent.cpow_smul {f : ℝ → E} {s a : ℂ} : MellinConvergent (fun t => (t : ℂ) ^ a • f t) s ↔ MellinConvergent f (s + a) := by refine integrableOn_congr_fun (fun t ht => ?_) measurableSet_Ioi simp_rw [← sub_add_eq_add_sub, cpow_add _ _ (ofReal_ne_zero.2 <| ne_of_gt ht), mul_smul] #align mellin_convergent.cpow_smul MellinConvergent.cpow_smul nonrec theorem MellinConvergent.div_const {f : ℝ → ℂ} {s : ℂ} (hf : MellinConvergent f s) (a : ℂ) : MellinConvergent (fun t => f t / a) s := by simpa only [MellinConvergent, smul_eq_mul, ← mul_div_assoc] using hf.div_const a #align mellin_convergent.div_const MellinConvergent.div_const theorem MellinConvergent.comp_mul_left {f : ℝ → E} {s : ℂ} {a : ℝ} (ha : 0 < a) : MellinConvergent (fun t => f (a * t)) s ↔ MellinConvergent f s := by have := integrableOn_Ioi_comp_mul_left_iff (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) 0 ha rw [mul_zero] at this have h1 : EqOn (fun t : ℝ => (↑(a * t) : ℂ) ^ (s - 1) • f (a * t)) ((a : ℂ) ^ (s - 1) • fun t : ℝ => (t : ℂ) ^ (s - 1) • f (a * t)) (Ioi 0) := fun t ht ↦ by simp only [ofReal_mul, mul_cpow_ofReal_nonneg ha.le (le_of_lt ht), mul_smul, Pi.smul_apply] have h2 : (a : ℂ) ^ (s - 1) ≠ 0 := by rw [Ne, cpow_eq_zero_iff, not_and_or, ofReal_eq_zero] exact Or.inl ha.ne' rw [MellinConvergent, MellinConvergent, ← this, integrableOn_congr_fun h1 measurableSet_Ioi, IntegrableOn, IntegrableOn, integrable_smul_iff h2] #align mellin_convergent.comp_mul_left MellinConvergent.comp_mul_left
Mathlib/Analysis/MellinTransform.lean
78
87
theorem MellinConvergent.comp_rpow {f : ℝ → E} {s : ℂ} {a : ℝ} (ha : a ≠ 0) : MellinConvergent (fun t => f (t ^ a)) s ↔ MellinConvergent f (s / a) := by
refine Iff.trans ?_ (integrableOn_Ioi_comp_rpow_iff' _ ha) rw [MellinConvergent] refine integrableOn_congr_fun (fun t ht => ?_) measurableSet_Ioi dsimp only [Pi.smul_apply] rw [← Complex.coe_smul (t ^ (a - 1)), ← mul_smul, ← cpow_mul_ofReal_nonneg (le_of_lt ht), ofReal_cpow (le_of_lt ht), ← cpow_add _ _ (ofReal_ne_zero.mpr (ne_of_gt ht)), ofReal_sub, ofReal_one, mul_sub, mul_div_cancel₀ _ (ofReal_ne_zero.mpr ha), mul_one, add_comm, ← add_sub_assoc, sub_add_cancel]
/- 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
Mathlib/Init/Order/LinearOrder.lean
29
30
theorem max_def (a b : α) : max a b = if a ≤ b then b else a := by
rw [LinearOrder.max_def a]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Yakov Pechersky, Eric Wieser -/ import Mathlib.Data.List.Basic /-! # Properties of `List.enum` -/ namespace List variable {α β : Type*} #align list.length_enum_from List.enumFrom_length #align list.length_enum List.enum_length @[simp] theorem get?_enumFrom : ∀ n (l : List α) m, get? (enumFrom n l) m = (get? l m).map fun a => (n + m, a) | n, [], m => rfl | n, a :: l, 0 => rfl | n, a :: l, m + 1 => (get?_enumFrom (n + 1) l m).trans <| by rw [Nat.add_right_comm]; rfl #align list.enum_from_nth List.get?_enumFrom @[deprecated (since := "2024-04-06")] alias enumFrom_get? := get?_enumFrom @[simp] theorem get?_enum (l : List α) (n) : get? (enum l) n = (get? l n).map fun a => (n, a) := by rw [enum, get?_enumFrom, Nat.zero_add] #align list.enum_nth List.get?_enum @[deprecated (since := "2024-04-06")] alias enum_get? := get?_enum @[simp] theorem enumFrom_map_snd : ∀ (n) (l : List α), map Prod.snd (enumFrom n l) = l | _, [] => rfl | _, _ :: _ => congr_arg (cons _) (enumFrom_map_snd _ _) #align list.enum_from_map_snd List.enumFrom_map_snd @[simp] theorem enum_map_snd (l : List α) : map Prod.snd (enum l) = l := enumFrom_map_snd _ _ #align list.enum_map_snd List.enum_map_snd @[simp] theorem get_enumFrom (l : List α) (n) (i : Fin (l.enumFrom n).length) : (l.enumFrom n).get i = (n + i, l.get (i.cast enumFrom_length)) := by simp [get_eq_get?] #align list.nth_le_enum_from List.get_enumFrom @[simp]
Mathlib/Data/List/Enum.lean
54
56
theorem get_enum (l : List α) (i : Fin l.enum.length) : l.enum.get i = (i.1, l.get (i.cast enum_length)) := by
simp [enum]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Algebra.CharP.Two import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Data.Nat.Periodic import Mathlib.Data.ZMod.Basic import Mathlib.Tactic.Monotonicity #align_import data.nat.totient from "leanprover-community/mathlib"@"5cc2dfdd3e92f340411acea4427d701dc7ed26f8" /-! # Euler's totient function This file defines [Euler's totient function](https://en.wikipedia.org/wiki/Euler's_totient_function) `Nat.totient n` which counts the number of naturals less than `n` that are coprime with `n`. We prove the divisor sum formula, namely that `n` equals `φ` summed over the divisors of `n`. See `sum_totient`. We also prove two lemmas to help compute totients, namely `totient_mul` and `totient_prime_pow`. -/ open Finset namespace Nat /-- Euler's totient function. This counts the number of naturals strictly less than `n` which are coprime with `n`. -/ def totient (n : ℕ) : ℕ := ((range n).filter n.Coprime).card #align nat.totient Nat.totient @[inherit_doc] scoped notation "φ" => Nat.totient @[simp] theorem totient_zero : φ 0 = 0 := rfl #align nat.totient_zero Nat.totient_zero @[simp] theorem totient_one : φ 1 = 1 := rfl #align nat.totient_one Nat.totient_one theorem totient_eq_card_coprime (n : ℕ) : φ n = ((range n).filter n.Coprime).card := rfl #align nat.totient_eq_card_coprime Nat.totient_eq_card_coprime /-- A characterisation of `Nat.totient` that avoids `Finset`. -/
Mathlib/Data/Nat/Totient.lean
51
57
theorem totient_eq_card_lt_and_coprime (n : ℕ) : φ n = Nat.card { m | m < n ∧ n.Coprime m } := by
let e : { m | m < n ∧ n.Coprime m } ≃ Finset.filter n.Coprime (Finset.range n) := { toFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩ invFun := fun m => ⟨m, by simpa only [Finset.mem_filter, Finset.mem_range] using m.property⟩ left_inv := fun m => by simp only [Subtype.coe_mk, Subtype.coe_eta] right_inv := fun m => by simp only [Subtype.coe_mk, Subtype.coe_eta] } rw [totient_eq_card_coprime, card_congr e, card_eq_fintype_card, Fintype.card_coe]
/- 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.Variables #align_import data.mv_polynomial.supported from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Polynomials supported by a set of variables This file contains the definition and lemmas about `MvPolynomial.supported`. ## Main definitions * `MvPolynomial.supported` : Given a set `s : Set σ`, `supported R s` is the subalgebra of `MvPolynomial σ R` consisting of polynomials whose set of variables is contained in `s`. This subalgebra is isomorphic to `MvPolynomial s R`. ## Tags variables, polynomial, vars -/ universe u v w namespace MvPolynomial variable {σ τ : Type*} {R : Type u} {S : Type v} {r : R} {e : ℕ} {n m : σ} section CommSemiring variable [CommSemiring R] {p q : MvPolynomial σ R} variable (R) /-- The set of polynomials whose variables are contained in `s` as a `Subalgebra` over `R`. -/ noncomputable def supported (s : Set σ) : Subalgebra R (MvPolynomial σ R) := Algebra.adjoin R (X '' s) #align mv_polynomial.supported MvPolynomial.supported variable {R} open Algebra theorem supported_eq_range_rename (s : Set σ) : supported R s = (rename ((↑) : s → σ)).range := by rw [supported, Set.image_eq_range, adjoin_range_eq_range_aeval, rename] congr #align mv_polynomial.supported_eq_range_rename MvPolynomial.supported_eq_range_rename /-- The isomorphism between the subalgebra of polynomials supported by `s` and `MvPolynomial s R`. -/ noncomputable def supportedEquivMvPolynomial (s : Set σ) : supported R s ≃ₐ[R] MvPolynomial s R := (Subalgebra.equivOfEq _ _ (supported_eq_range_rename s)).trans (AlgEquiv.ofInjective (rename ((↑) : s → σ)) (rename_injective _ Subtype.val_injective)).symm #align mv_polynomial.supported_equiv_mv_polynomial MvPolynomial.supportedEquivMvPolynomial @[simp, nolint simpNF] -- Porting note: the `simpNF` linter complained about this lemma. theorem supportedEquivMvPolynomial_symm_C (s : Set σ) (x : R) : (supportedEquivMvPolynomial s).symm (C x) = algebraMap R (supported R s) x := by ext1 simp [supportedEquivMvPolynomial, MvPolynomial.algebraMap_eq] set_option linter.uppercaseLean3 false in #align mv_polynomial.supported_equiv_mv_polynomial_symm_C MvPolynomial.supportedEquivMvPolynomial_symm_C @[simp, nolint simpNF] -- Porting note: the `simpNF` linter complained about this lemma. theorem supportedEquivMvPolynomial_symm_X (s : Set σ) (i : s) : (↑((supportedEquivMvPolynomial s).symm (X i : MvPolynomial s R)) : MvPolynomial σ R) = X ↑i := by simp [supportedEquivMvPolynomial] set_option linter.uppercaseLean3 false in #align mv_polynomial.supported_equiv_mv_polynomial_symm_X MvPolynomial.supportedEquivMvPolynomial_symm_X variable {s t : Set σ} theorem mem_supported : p ∈ supported R s ↔ ↑p.vars ⊆ s := by classical rw [supported_eq_range_rename, AlgHom.mem_range] constructor · rintro ⟨p, rfl⟩ refine _root_.trans (Finset.coe_subset.2 (vars_rename _ _)) ?_ simp · intro hs exact exists_rename_eq_of_vars_subset_range p ((↑) : s → σ) Subtype.val_injective (by simpa) #align mv_polynomial.mem_supported MvPolynomial.mem_supported theorem supported_eq_vars_subset : (supported R s : Set (MvPolynomial σ R)) = { p | ↑p.vars ⊆ s } := Set.ext fun _ ↦ mem_supported #align mv_polynomial.supported_eq_vars_subset MvPolynomial.supported_eq_vars_subset @[simp] theorem mem_supported_vars (p : MvPolynomial σ R) : p ∈ supported R (↑p.vars : Set σ) := by rw [mem_supported] #align mv_polynomial.mem_supported_vars MvPolynomial.mem_supported_vars variable (s) theorem supported_eq_adjoin_X : supported R s = Algebra.adjoin R (X '' s) := rfl set_option linter.uppercaseLean3 false in #align mv_polynomial.supported_eq_adjoin_X MvPolynomial.supported_eq_adjoin_X @[simp] theorem supported_univ : supported R (Set.univ : Set σ) = ⊤ := by simp [Algebra.eq_top_iff, mem_supported] #align mv_polynomial.supported_univ MvPolynomial.supported_univ @[simp] theorem supported_empty : supported R (∅ : Set σ) = ⊥ := by simp [supported_eq_adjoin_X] #align mv_polynomial.supported_empty MvPolynomial.supported_empty variable {s} theorem supported_mono (st : s ⊆ t) : supported R s ≤ supported R t := Algebra.adjoin_mono (Set.image_subset _ st) #align mv_polynomial.supported_mono MvPolynomial.supported_mono @[simp] theorem X_mem_supported [Nontrivial R] {i : σ} : X i ∈ supported R s ↔ i ∈ s := by simp [mem_supported] set_option linter.uppercaseLean3 false in #align mv_polynomial.X_mem_supported MvPolynomial.X_mem_supported @[simp]
Mathlib/Algebra/MvPolynomial/Supported.lean
123
127
theorem supported_le_supported_iff [Nontrivial R] : supported R s ≤ supported R t ↔ s ⊆ t := by
constructor · intro h i simpa using @h (X i) · exact supported_mono
/- Copyright (c) 2020 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Monic #align_import data.polynomial.lifts from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0" /-! # Polynomials that lift Given semirings `R` and `S` with a morphism `f : R →+* S`, we define a subsemiring `lifts` of `S[X]` by the image of `RingHom.of (map f)`. Then, we prove that a polynomial that lifts can always be lifted to a polynomial of the same degree and that a monic polynomial that lifts can be lifted to a monic polynomial (of the same degree). ## Main definition * `lifts (f : R →+* S)` : the subsemiring of polynomials that lift. ## Main results * `lifts_and_degree_eq` : A polynomial lifts if and only if it can be lifted to a polynomial of the same degree. * `lifts_and_degree_eq_and_monic` : A monic polynomial lifts if and only if it can be lifted to a monic polynomial of the same degree. * `lifts_iff_alg` : if `R` is commutative, a polynomial lifts if and only if it is in the image of `mapAlg`, where `mapAlg : R[X] →ₐ[R] S[X]` is the only `R`-algebra map that sends `X` to `X`. ## Implementation details In general `R` and `S` are semiring, so `lifts` is a semiring. In the case of rings, see `lifts_iff_lifts_ring`. Since we do not assume `R` to be commutative, we cannot say in general that the set of polynomials that lift is a subalgebra. (By `lift_iff` this is true if `R` is commutative.) -/ open Polynomial noncomputable section namespace Polynomial universe u v w section Semiring variable {R : Type u} [Semiring R] {S : Type v} [Semiring S] {f : R →+* S} /-- We define the subsemiring of polynomials that lifts as the image of `RingHom.of (map f)`. -/ def lifts (f : R →+* S) : Subsemiring S[X] := RingHom.rangeS (mapRingHom f) #align polynomial.lifts Polynomial.lifts theorem mem_lifts (p : S[X]) : p ∈ lifts f ↔ ∃ q : R[X], map f q = p := by simp only [coe_mapRingHom, lifts, RingHom.mem_rangeS] #align polynomial.mem_lifts Polynomial.mem_lifts theorem lifts_iff_set_range (p : S[X]) : p ∈ lifts f ↔ p ∈ Set.range (map f) := by simp only [coe_mapRingHom, lifts, Set.mem_range, RingHom.mem_rangeS] #align polynomial.lifts_iff_set_range Polynomial.lifts_iff_set_range theorem lifts_iff_ringHom_rangeS (p : S[X]) : p ∈ lifts f ↔ p ∈ (mapRingHom f).rangeS := by simp only [coe_mapRingHom, lifts, Set.mem_range, RingHom.mem_rangeS] #align polynomial.lifts_iff_ring_hom_srange Polynomial.lifts_iff_ringHom_rangeS theorem lifts_iff_coeff_lifts (p : S[X]) : p ∈ lifts f ↔ ∀ n : ℕ, p.coeff n ∈ Set.range f := by rw [lifts_iff_ringHom_rangeS, mem_map_rangeS f] rfl #align polynomial.lifts_iff_coeff_lifts Polynomial.lifts_iff_coeff_lifts /-- If `(r : R)`, then `C (f r)` lifts. -/ theorem C_mem_lifts (f : R →+* S) (r : R) : C (f r) ∈ lifts f := ⟨C r, by simp only [coe_mapRingHom, map_C, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true, and_self_iff]⟩ set_option linter.uppercaseLean3 false in #align polynomial.C_mem_lifts Polynomial.C_mem_lifts /-- If `(s : S)` is in the image of `f`, then `C s` lifts. -/
Mathlib/Algebra/Polynomial/Lifts.lean
87
91
theorem C'_mem_lifts {f : R →+* S} {s : S} (h : s ∈ Set.range f) : C s ∈ lifts f := by
obtain ⟨r, rfl⟩ := Set.mem_range.1 h use C r simp only [coe_mapRingHom, map_C, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true, and_self_iff]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Multiset.Nodup #align_import data.multiset.dedup from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Erasing duplicates in a multiset. -/ namespace Multiset open List variable {α β : Type*} [DecidableEq α] /-! ### dedup -/ /-- `dedup s` removes duplicates from `s`, yielding a `nodup` multiset. -/ def dedup (s : Multiset α) : Multiset α := Quot.liftOn s (fun l => (l.dedup : Multiset α)) fun _ _ p => Quot.sound p.dedup #align multiset.dedup Multiset.dedup @[simp] theorem coe_dedup (l : List α) : @dedup α _ l = l.dedup := rfl #align multiset.coe_dedup Multiset.coe_dedup @[simp] theorem dedup_zero : @dedup α _ 0 = 0 := rfl #align multiset.dedup_zero Multiset.dedup_zero @[simp] theorem mem_dedup {a : α} {s : Multiset α} : a ∈ dedup s ↔ a ∈ s := Quot.induction_on s fun _ => List.mem_dedup #align multiset.mem_dedup Multiset.mem_dedup @[simp] theorem dedup_cons_of_mem {a : α} {s : Multiset α} : a ∈ s → dedup (a ::ₘ s) = dedup s := Quot.induction_on s fun _ m => @congr_arg _ _ _ _ ofList <| List.dedup_cons_of_mem m #align multiset.dedup_cons_of_mem Multiset.dedup_cons_of_mem @[simp] theorem dedup_cons_of_not_mem {a : α} {s : Multiset α} : a ∉ s → dedup (a ::ₘ s) = a ::ₘ dedup s := Quot.induction_on s fun _ m => congr_arg ofList <| List.dedup_cons_of_not_mem m #align multiset.dedup_cons_of_not_mem Multiset.dedup_cons_of_not_mem theorem dedup_le (s : Multiset α) : dedup s ≤ s := Quot.induction_on s fun _ => (dedup_sublist _).subperm #align multiset.dedup_le Multiset.dedup_le theorem dedup_subset (s : Multiset α) : dedup s ⊆ s := subset_of_le <| dedup_le _ #align multiset.dedup_subset Multiset.dedup_subset theorem subset_dedup (s : Multiset α) : s ⊆ dedup s := fun _ => mem_dedup.2 #align multiset.subset_dedup Multiset.subset_dedup @[simp] theorem dedup_subset' {s t : Multiset α} : dedup s ⊆ t ↔ s ⊆ t := ⟨Subset.trans (subset_dedup _), Subset.trans (dedup_subset _)⟩ #align multiset.dedup_subset' Multiset.dedup_subset' @[simp] theorem subset_dedup' {s t : Multiset α} : s ⊆ dedup t ↔ s ⊆ t := ⟨fun h => Subset.trans h (dedup_subset _), fun h => Subset.trans h (subset_dedup _)⟩ #align multiset.subset_dedup' Multiset.subset_dedup' @[simp] theorem nodup_dedup (s : Multiset α) : Nodup (dedup s) := Quot.induction_on s List.nodup_dedup #align multiset.nodup_dedup Multiset.nodup_dedup theorem dedup_eq_self {s : Multiset α} : dedup s = s ↔ Nodup s := ⟨fun e => e ▸ nodup_dedup s, Quot.induction_on s fun _ h => congr_arg ofList h.dedup⟩ #align multiset.dedup_eq_self Multiset.dedup_eq_self alias ⟨_, Nodup.dedup⟩ := dedup_eq_self #align multiset.nodup.dedup Multiset.Nodup.dedup theorem count_dedup (m : Multiset α) (a : α) : m.dedup.count a = if a ∈ m then 1 else 0 := Quot.induction_on m fun _ => by simp only [quot_mk_to_coe'', coe_dedup, mem_coe, List.mem_dedup, coe_nodup, coe_count] apply List.count_dedup _ _ #align multiset.count_dedup Multiset.count_dedup @[simp] theorem dedup_idem {m : Multiset α} : m.dedup.dedup = m.dedup := Quot.induction_on m fun _ => @congr_arg _ _ _ _ ofList List.dedup_idem #align multiset.dedup_idempotent Multiset.dedup_idem theorem dedup_eq_zero {s : Multiset α} : dedup s = 0 ↔ s = 0 := ⟨fun h => eq_zero_of_subset_zero <| h ▸ subset_dedup _, fun h => h.symm ▸ dedup_zero⟩ #align multiset.dedup_eq_zero Multiset.dedup_eq_zero @[simp] theorem dedup_singleton {a : α} : dedup ({a} : Multiset α) = {a} := (nodup_singleton _).dedup #align multiset.dedup_singleton Multiset.dedup_singleton theorem le_dedup {s t : Multiset α} : s ≤ dedup t ↔ s ≤ t ∧ Nodup s := ⟨fun h => ⟨le_trans h (dedup_le _), nodup_of_le h (nodup_dedup _)⟩, fun ⟨l, d⟩ => (le_iff_subset d).2 <| Subset.trans (subset_of_le l) (subset_dedup _)⟩ #align multiset.le_dedup Multiset.le_dedup theorem le_dedup_self {s : Multiset α} : s ≤ dedup s ↔ Nodup s := by rw [le_dedup, and_iff_right le_rfl] #align multiset.le_dedup_self Multiset.le_dedup_self theorem dedup_ext {s t : Multiset α} : dedup s = dedup t ↔ ∀ a, a ∈ s ↔ a ∈ t := by simp [Nodup.ext] #align multiset.dedup_ext Multiset.dedup_ext
Mathlib/Data/Multiset/Dedup.lean
120
122
theorem dedup_map_dedup_eq [DecidableEq β] (f : α → β) (s : Multiset α) : dedup (map f (dedup s)) = dedup (map f s) := by
simp [dedup_ext]
/- 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.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.BigOperators.Pi import Mathlib.CategoryTheory.Limits.Shapes.Biproducts import Mathlib.CategoryTheory.Preadditive.Basic import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.Data.Matrix.DMatrix import Mathlib.Data.Matrix.Basic import Mathlib.CategoryTheory.FintypeCat import Mathlib.CategoryTheory.Preadditive.SingleObj import Mathlib.Algebra.Opposites #align_import category_theory.preadditive.Mat from "leanprover-community/mathlib"@"829895f162a1f29d0133f4b3538f4cd1fb5bffd3" /-! # Matrices over a category. When `C` is a preadditive category, `Mat_ C` is the preadditive category whose objects are finite tuples of objects in `C`, and whose morphisms are matrices of morphisms from `C`. There is a functor `Mat_.embedding : C ⥤ Mat_ C` sending morphisms to one-by-one matrices. `Mat_ C` has finite biproducts. ## The additive envelope We show that this construction is the "additive envelope" of `C`, in the sense that any additive functor `F : C ⥤ D` to a category `D` with biproducts lifts to a functor `Mat_.lift F : Mat_ C ⥤ D`, Moreover, this functor is unique (up to natural isomorphisms) amongst functors `L : Mat_ C ⥤ D` such that `embedding C ⋙ L ≅ F`. (As we don't have 2-category theory, we can't explicitly state that `Mat_ C` is the initial object in the 2-category of categories under `C` which have biproducts.) As a consequence, when `C` already has finite biproducts we have `Mat_ C ≌ C`. ## Future work We should provide a more convenient `Mat R`, when `R` is a ring, as a category with objects `n : FinType`, and whose morphisms are matrices with components in `R`. Ideally this would conveniently interact with both `Mat_` and `Matrix`. -/ open CategoryTheory CategoryTheory.Preadditive open scoped Classical noncomputable section namespace CategoryTheory universe w v₁ v₂ u₁ u₂ variable (C : Type u₁) [Category.{v₁} C] [Preadditive C] /-- An object in `Mat_ C` is a finite tuple of objects in `C`. -/ structure Mat_ where ι : Type [fintype : Fintype ι] X : ι → C set_option linter.uppercaseLean3 false in #align category_theory.Mat_ CategoryTheory.Mat_ attribute [instance] Mat_.fintype namespace Mat_ variable {C} -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- A morphism in `Mat_ C` is a dependently typed matrix of morphisms. -/ def Hom (M N : Mat_ C) : Type v₁ := DMatrix M.ι N.ι fun i j => M.X i ⟶ N.X j set_option linter.uppercaseLean3 false in #align category_theory.Mat_.hom CategoryTheory.Mat_.Hom namespace Hom /-- The identity matrix consists of identity morphisms on the diagonal, and zeros elsewhere. -/ def id (M : Mat_ C) : Hom M M := fun i j => if h : i = j then eqToHom (congr_arg M.X h) else 0 set_option linter.uppercaseLean3 false in #align category_theory.Mat_.hom.id CategoryTheory.Mat_.Hom.id /-- Composition of matrices using matrix multiplication. -/ def comp {M N K : Mat_ C} (f : Hom M N) (g : Hom N K) : Hom M K := fun i k => ∑ j : N.ι, f i j ≫ g j k set_option linter.uppercaseLean3 false in #align category_theory.Mat_.hom.comp CategoryTheory.Mat_.Hom.comp end Hom section attribute [local simp] Hom.id Hom.comp instance : Category.{v₁} (Mat_ C) where Hom := Hom id := Hom.id comp f g := f.comp g id_comp f := by simp (config := { unfoldPartialApp := true }) [dite_comp] comp_id f := by simp (config := { unfoldPartialApp := true }) [comp_dite] assoc f g h := by apply DMatrix.ext intros simp_rw [Hom.comp, sum_comp, comp_sum, Category.assoc] rw [Finset.sum_comm] -- Porting note: added because `DMatrix.ext` is not triggered automatically -- See https://github.com/leanprover-community/mathlib4/issues/5229 @[ext] theorem hom_ext {M N : Mat_ C} (f g : M ⟶ N) (H : ∀ i j, f i j = g i j) : f = g := DMatrix.ext_iff.mp H theorem id_def (M : Mat_ C) : (𝟙 M : Hom M M) = fun i j => if h : i = j then eqToHom (congr_arg M.X h) else 0 := rfl set_option linter.uppercaseLean3 false in #align category_theory.Mat_.id_def CategoryTheory.Mat_.id_def theorem id_apply (M : Mat_ C) (i j : M.ι) : (𝟙 M : Hom M M) i j = if h : i = j then eqToHom (congr_arg M.X h) else 0 := rfl set_option linter.uppercaseLean3 false in #align category_theory.Mat_.id_apply CategoryTheory.Mat_.id_apply @[simp] theorem id_apply_self (M : Mat_ C) (i : M.ι) : (𝟙 M : Hom M M) i i = 𝟙 _ := by simp [id_apply] set_option linter.uppercaseLean3 false in #align category_theory.Mat_.id_apply_self CategoryTheory.Mat_.id_apply_self @[simp]
Mathlib/CategoryTheory/Preadditive/Mat.lean
142
143
theorem id_apply_of_ne (M : Mat_ C) (i j : M.ι) (h : i ≠ j) : (𝟙 M : Hom M M) i j = 0 := by
simp [id_apply, h]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Devon Tuma -/ import Mathlib.Probability.ProbabilityMassFunction.Monad #align_import probability.probability_mass_function.constructions from "leanprover-community/mathlib"@"4ac69b290818724c159de091daa3acd31da0ee6d" /-! # Specific Constructions of Probability Mass Functions This file gives a number of different `PMF` constructions for common probability distributions. `map` and `seq` allow pushing a `PMF α` along a function `f : α → β` (or distribution of functions `f : PMF (α → β)`) to get a `PMF β`. `ofFinset` and `ofFintype` simplify the construction of a `PMF α` from a function `f : α → ℝ≥0∞`, by allowing the "sum equals 1" constraint to be in terms of `Finset.sum` instead of `tsum`. `normalize` constructs a `PMF α` by normalizing a function `f : α → ℝ≥0∞` by its sum, and `filter` uses this to filter the support of a `PMF` and re-normalize the new distribution. `bernoulli` represents the bernoulli distribution on `Bool`. -/ universe u namespace PMF noncomputable section variable {α β γ : Type*} open scoped Classical open NNReal ENNReal section Map /-- The functorial action of a function on a `PMF`. -/ def map (f : α → β) (p : PMF α) : PMF β := bind p (pure ∘ f) #align pmf.map PMF.map variable (f : α → β) (p : PMF α) (b : β) theorem monad_map_eq_map {α β : Type u} (f : α → β) (p : PMF α) : f <$> p = p.map f := rfl #align pmf.monad_map_eq_map PMF.monad_map_eq_map @[simp] theorem map_apply : (map f p) b = ∑' a, if b = f a then p a else 0 := by simp [map] #align pmf.map_apply PMF.map_apply @[simp] theorem support_map : (map f p).support = f '' p.support := Set.ext fun b => by simp [map, @eq_comm β b] #align pmf.support_map PMF.support_map theorem mem_support_map_iff : b ∈ (map f p).support ↔ ∃ a ∈ p.support, f a = b := by simp #align pmf.mem_support_map_iff PMF.mem_support_map_iff theorem bind_pure_comp : bind p (pure ∘ f) = map f p := rfl #align pmf.bind_pure_comp PMF.bind_pure_comp theorem map_id : map id p = p := bind_pure _ #align pmf.map_id PMF.map_id theorem map_comp (g : β → γ) : (p.map f).map g = p.map (g ∘ f) := by simp [map, Function.comp] #align pmf.map_comp PMF.map_comp theorem pure_map (a : α) : (pure a).map f = pure (f a) := pure_bind _ _ #align pmf.pure_map PMF.pure_map theorem map_bind (q : α → PMF β) (f : β → γ) : (p.bind q).map f = p.bind fun a => (q a).map f := bind_bind _ _ _ #align pmf.map_bind PMF.map_bind @[simp] theorem bind_map (p : PMF α) (f : α → β) (q : β → PMF γ) : (p.map f).bind q = p.bind (q ∘ f) := (bind_bind _ _ _).trans (congr_arg _ (funext fun _ => pure_bind _ _)) #align pmf.bind_map PMF.bind_map @[simp] theorem map_const : p.map (Function.const α b) = pure b := by simp only [map, Function.comp, bind_const, Function.const] #align pmf.map_const PMF.map_const section Measure variable (s : Set β) @[simp] theorem toOuterMeasure_map_apply : (p.map f).toOuterMeasure s = p.toOuterMeasure (f ⁻¹' s) := by simp [map, Set.indicator, toOuterMeasure_apply p (f ⁻¹' s)] #align pmf.to_outer_measure_map_apply PMF.toOuterMeasure_map_apply @[simp] theorem toMeasure_map_apply [MeasurableSpace α] [MeasurableSpace β] (hf : Measurable f) (hs : MeasurableSet s) : (p.map f).toMeasure s = p.toMeasure (f ⁻¹' s) := by rw [toMeasure_apply_eq_toOuterMeasure_apply _ s hs, toMeasure_apply_eq_toOuterMeasure_apply _ (f ⁻¹' s) (measurableSet_preimage hf hs)] exact toOuterMeasure_map_apply f p s #align pmf.to_measure_map_apply PMF.toMeasure_map_apply end Measure end Map section Seq /-- The monadic sequencing operation for `PMF`. -/ def seq (q : PMF (α → β)) (p : PMF α) : PMF β := q.bind fun m => p.bind fun a => pure (m a) #align pmf.seq PMF.seq variable (q : PMF (α → β)) (p : PMF α) (b : β) theorem monad_seq_eq_seq {α β : Type u} (q : PMF (α → β)) (p : PMF α) : q <*> p = q.seq p := rfl #align pmf.monad_seq_eq_seq PMF.monad_seq_eq_seq @[simp]
Mathlib/Probability/ProbabilityMassFunction/Constructions.lean
125
128
theorem seq_apply : (seq q p) b = ∑' (f : α → β) (a : α), if b = f a then q f * p a else 0 := by
simp only [seq, mul_boole, bind_apply, pure_apply] refine tsum_congr fun f => ENNReal.tsum_mul_left.symm.trans (tsum_congr fun a => ?_) simpa only [mul_zero] using mul_ite (b = f a) (q f) (p a) 0
/- Copyright (c) 2020 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.RingTheory.Ideal.Maps #align_import ring_theory.ideal.prod from "leanprover-community/mathlib"@"052f6013363326d50cb99c6939814a4b8eb7b301" /-! # Ideals in product rings For commutative rings `R` and `S` and ideals `I ≤ R`, `J ≤ S`, we define `Ideal.prod I J` as the product `I × J`, viewed as an ideal of `R × S`. In `ideal_prod_eq` we show that every ideal of `R × S` is of this form. Furthermore, we show that every prime ideal of `R × S` is of the form `p × S` or `R × p`, where `p` is a prime ideal. -/ universe u v variable {R : Type u} {S : Type v} [Semiring R] [Semiring S] (I I' : Ideal R) (J J' : Ideal S) namespace Ideal /-- `I × J` as an ideal of `R × S`. -/ def prod : Ideal (R × S) where carrier := { x | x.fst ∈ I ∧ x.snd ∈ J } zero_mem' := by simp add_mem' := by rintro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨ha₁, ha₂⟩ ⟨hb₁, hb₂⟩ exact ⟨I.add_mem ha₁ hb₁, J.add_mem ha₂ hb₂⟩ smul_mem' := by rintro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨hb₁, hb₂⟩ exact ⟨I.mul_mem_left _ hb₁, J.mul_mem_left _ hb₂⟩ #align ideal.prod Ideal.prod @[simp] theorem mem_prod {r : R} {s : S} : (⟨r, s⟩ : R × S) ∈ prod I J ↔ r ∈ I ∧ s ∈ J := Iff.rfl #align ideal.mem_prod Ideal.mem_prod @[simp] theorem prod_top_top : prod (⊤ : Ideal R) (⊤ : Ideal S) = ⊤ := Ideal.ext <| by simp #align ideal.prod_top_top Ideal.prod_top_top /-- Every ideal of the product ring is of the form `I × J`, where `I` and `J` can be explicitly given as the image under the projection maps. -/ theorem ideal_prod_eq (I : Ideal (R × S)) : I = Ideal.prod (map (RingHom.fst R S) I : Ideal R) (map (RingHom.snd R S) I) := by apply Ideal.ext rintro ⟨r, s⟩ rw [mem_prod, mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective, mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective] refine ⟨fun h => ⟨⟨_, ⟨h, rfl⟩⟩, ⟨_, ⟨h, rfl⟩⟩⟩, ?_⟩ rintro ⟨⟨⟨r, s'⟩, ⟨h₁, rfl⟩⟩, ⟨⟨r', s⟩, ⟨h₂, rfl⟩⟩⟩ simpa using I.add_mem (I.mul_mem_left (1, 0) h₁) (I.mul_mem_left (0, 1) h₂) #align ideal.ideal_prod_eq Ideal.ideal_prod_eq @[simp] theorem map_fst_prod (I : Ideal R) (J : Ideal S) : map (RingHom.fst R S) (prod I J) = I := by ext x rw [mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective] exact ⟨by rintro ⟨x, ⟨h, rfl⟩⟩ exact h.1, fun h => ⟨⟨x, 0⟩, ⟨⟨h, Ideal.zero_mem _⟩, rfl⟩⟩⟩ #align ideal.map_fst_prod Ideal.map_fst_prod @[simp] theorem map_snd_prod (I : Ideal R) (J : Ideal S) : map (RingHom.snd R S) (prod I J) = J := by ext x rw [mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective] exact ⟨by rintro ⟨x, ⟨h, rfl⟩⟩ exact h.2, fun h => ⟨⟨0, x⟩, ⟨⟨Ideal.zero_mem _, h⟩, rfl⟩⟩⟩ #align ideal.map_snd_prod Ideal.map_snd_prod @[simp] theorem map_prodComm_prod : map ((RingEquiv.prodComm : R × S ≃+* S × R) : R × S →+* S × R) (prod I J) = prod J I := by refine Trans.trans (ideal_prod_eq _) ?_ simp [map_map] #align ideal.map_prod_comm_prod Ideal.map_prodComm_prod /-- Ideals of `R × S` are in one-to-one correspondence with pairs of ideals of `R` and ideals of `S`. -/ def idealProdEquiv : Ideal (R × S) ≃ Ideal R × Ideal S where toFun I := ⟨map (RingHom.fst R S) I, map (RingHom.snd R S) I⟩ invFun I := prod I.1 I.2 left_inv I := (ideal_prod_eq I).symm right_inv := fun ⟨I, J⟩ => by simp #align ideal.ideal_prod_equiv Ideal.idealProdEquiv @[simp] theorem idealProdEquiv_symm_apply (I : Ideal R) (J : Ideal S) : idealProdEquiv.symm ⟨I, J⟩ = prod I J := rfl #align ideal.ideal_prod_equiv_symm_apply Ideal.idealProdEquiv_symm_apply
Mathlib/RingTheory/Ideal/Prod.lean
103
105
theorem prod.ext_iff {I I' : Ideal R} {J J' : Ideal S} : prod I J = prod I' J' ↔ I = I' ∧ J = J' := by
simp only [← idealProdEquiv_symm_apply, idealProdEquiv.symm.injective.eq_iff, Prod.mk.inj_iff]
/- Copyright (c) 2019 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Kenny Lau -/ import Mathlib.Algebra.CharP.Defs import Mathlib.RingTheory.Multiplicity import Mathlib.RingTheory.PowerSeries.Basic #align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60" /-! # Formal power series (in one variable) - Order The `PowerSeries.order` of a formal power series `φ` is the multiplicity of the variable `X` in `φ`. If the coefficients form an integral domain, then `PowerSeries.order` is an additive valuation (`PowerSeries.order_mul`, `PowerSeries.le_order_add`). We prove that if the commutative ring `R` of coefficients is an integral domain, then the ring `R⟦X⟧` of formal power series in one variable over `R` is an integral domain. Given a non-zero power series `f`, `divided_by_X_pow_order f` is the power series obtained by dividing out the largest power of X that divides `f`, that is its order. This is useful when proving that `R⟦X⟧` is a normalization monoid, which is done in `PowerSeries.Inverse`. -/ noncomputable section open Polynomial open Finset (antidiagonal mem_antidiagonal) namespace PowerSeries open Finsupp (single) variable {R : Type*} section OrderBasic open multiplicity variable [Semiring R] {φ : R⟦X⟧} theorem exists_coeff_ne_zero_iff_ne_zero : (∃ n : ℕ, coeff R n φ ≠ 0) ↔ φ ≠ 0 := by refine not_iff_not.mp ?_ push_neg -- FIXME: the `FunLike.coe` doesn't seem to be picked up in the expression after #8386? simp [PowerSeries.ext_iff, (coeff R _).map_zero] #align power_series.exists_coeff_ne_zero_iff_ne_zero PowerSeries.exists_coeff_ne_zero_iff_ne_zero /-- The order of a formal power series `φ` is the greatest `n : PartENat` such that `X^n` divides `φ`. The order is `⊤` if and only if `φ = 0`. -/ def order (φ : R⟦X⟧) : PartENat := letI := Classical.decEq R letI := Classical.decEq R⟦X⟧ if h : φ = 0 then ⊤ else Nat.find (exists_coeff_ne_zero_iff_ne_zero.mpr h) #align power_series.order PowerSeries.order /-- The order of the `0` power series is infinite. -/ @[simp] theorem order_zero : order (0 : R⟦X⟧) = ⊤ := dif_pos rfl #align power_series.order_zero PowerSeries.order_zero theorem order_finite_iff_ne_zero : (order φ).Dom ↔ φ ≠ 0 := by simp only [order] constructor · split_ifs with h <;> intro H · simp only [PartENat.top_eq_none, Part.not_none_dom] at H · exact h · intro h simp [h] #align power_series.order_finite_iff_ne_zero PowerSeries.order_finite_iff_ne_zero /-- If the order of a formal power series is finite, then the coefficient indexed by the order is nonzero. -/ theorem coeff_order (h : (order φ).Dom) : coeff R (φ.order.get h) φ ≠ 0 := by classical simp only [order, order_finite_iff_ne_zero.mp h, not_false_iff, dif_neg, PartENat.get_natCast'] generalize_proofs h exact Nat.find_spec h #align power_series.coeff_order PowerSeries.coeff_order /-- If the `n`th coefficient of a formal power series is nonzero, then the order of the power series is less than or equal to `n`. -/ theorem order_le (n : ℕ) (h : coeff R n φ ≠ 0) : order φ ≤ n := by classical rw [order, dif_neg] · simp only [PartENat.coe_le_coe] exact Nat.find_le h · exact exists_coeff_ne_zero_iff_ne_zero.mp ⟨n, h⟩ #align power_series.order_le PowerSeries.order_le /-- The `n`th coefficient of a formal power series is `0` if `n` is strictly smaller than the order of the power series. -/ theorem coeff_of_lt_order (n : ℕ) (h : ↑n < order φ) : coeff R n φ = 0 := by contrapose! h exact order_le _ h #align power_series.coeff_of_lt_order PowerSeries.coeff_of_lt_order /-- The `0` power series is the unique power series with infinite order. -/ @[simp] theorem order_eq_top {φ : R⟦X⟧} : φ.order = ⊤ ↔ φ = 0 := PartENat.not_dom_iff_eq_top.symm.trans order_finite_iff_ne_zero.not_left #align power_series.order_eq_top PowerSeries.order_eq_top /-- The order of a formal power series is at least `n` if the `i`th coefficient is `0` for all `i < n`. -/ theorem nat_le_order (φ : R⟦X⟧) (n : ℕ) (h : ∀ i < n, coeff R i φ = 0) : ↑n ≤ order φ := by by_contra H; rw [not_le] at H have : (order φ).Dom := PartENat.dom_of_le_natCast H.le rw [← PartENat.natCast_get this, PartENat.coe_lt_coe] at H exact coeff_order this (h _ H) #align power_series.nat_le_order PowerSeries.nat_le_order /-- The order of a formal power series is at least `n` if the `i`th coefficient is `0` for all `i < n`. -/
Mathlib/RingTheory/PowerSeries/Order.lean
121
129
theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) : n ≤ order φ := by
induction n using PartENat.casesOn · show _ ≤ _ rw [top_le_iff, order_eq_top] ext i exact h _ (PartENat.natCast_lt_top i) · apply nat_le_order simpa only [PartENat.coe_lt_coe] using h
/- Copyright (c) 2022 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying, Rémy Degenne -/ import Mathlib.Probability.Process.Stopping import Mathlib.Tactic.AdaptationNote #align_import probability.process.hitting_time from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Hitting time Given a stochastic process, the hitting time provides the first time the process "hits" some subset of the state space. The hitting time is a stopping time in the case that the time index is discrete and the process is adapted (this is true in a far more general setting however we have only proved it for the discrete case so far). ## Main definition * `MeasureTheory.hitting`: the hitting time of a stochastic process ## Main results * `MeasureTheory.hitting_isStoppingTime`: a discrete hitting time of an adapted process is a stopping time ## Implementation notes In the definition of the hitting time, we bound the hitting time by an upper and lower bound. This is to ensure that our result is meaningful in the case we are taking the infimum of an empty set or the infimum of a set which is unbounded from below. With this, we can talk about hitting times indexed by the natural numbers or the reals. By taking the bounds to be `⊤` and `⊥`, we obtain the standard definition in the case that the index is `ℕ∞` or `ℝ≥0∞`. -/ open Filter Order TopologicalSpace open scoped Classical MeasureTheory NNReal ENNReal Topology namespace MeasureTheory variable {Ω β ι : Type*} {m : MeasurableSpace Ω} /-- Hitting time: given a stochastic process `u` and a set `s`, `hitting u s n m` is the first time `u` is in `s` after time `n` and before time `m` (if `u` does not hit `s` after time `n` and before `m` then the hitting time is simply `m`). The hitting time is a stopping time if the process is adapted and discrete. -/ noncomputable def hitting [Preorder ι] [InfSet ι] (u : ι → Ω → β) (s : Set β) (n m : ι) : Ω → ι := fun x => if ∃ j ∈ Set.Icc n m, u j x ∈ s then sInf (Set.Icc n m ∩ {i : ι | u i x ∈ s}) else m #align measure_theory.hitting MeasureTheory.hitting #adaptation_note /-- nightly-2024-03-16: added to replace simp [hitting] -/ theorem hitting_def [Preorder ι] [InfSet ι] (u : ι → Ω → β) (s : Set β) (n m : ι) : hitting u s n m = fun x => if ∃ j ∈ Set.Icc n m, u j x ∈ s then sInf (Set.Icc n m ∩ {i : ι | u i x ∈ s}) else m := rfl section Inequalities variable [ConditionallyCompleteLinearOrder ι] {u : ι → Ω → β} {s : Set β} {n i : ι} {ω : Ω} /-- This lemma is strictly weaker than `hitting_of_le`. -/ theorem hitting_of_lt {m : ι} (h : m < n) : hitting u s n m ω = m := by simp_rw [hitting] have h_not : ¬∃ (j : ι) (_ : j ∈ Set.Icc n m), u j ω ∈ s := by push_neg intro j rw [Set.Icc_eq_empty_of_lt h] simp only [Set.mem_empty_iff_false, IsEmpty.forall_iff] simp only [exists_prop] at h_not simp only [h_not, if_false] #align measure_theory.hitting_of_lt MeasureTheory.hitting_of_lt
Mathlib/Probability/Process/HittingTime.lean
78
84
theorem hitting_le {m : ι} (ω : Ω) : hitting u s n m ω ≤ m := by
simp only [hitting] split_ifs with h · obtain ⟨j, hj₁, hj₂⟩ := h change j ∈ {i | u i ω ∈ s} at hj₂ exact (csInf_le (BddBelow.inter_of_left bddBelow_Icc) (Set.mem_inter hj₁ hj₂)).trans hj₁.2 · exact le_rfl
/- 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 -/ import Mathlib.Data.Finset.Image #align_import data.finset.card from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Cardinality of a finite set This defines the cardinality of a `Finset` and provides induction principles for finsets. ## Main declarations * `Finset.card`: `s.card : ℕ` returns the cardinality of `s : Finset α`. ### Induction principles * `Finset.strongInduction`: Strong induction * `Finset.strongInductionOn` * `Finset.strongDownwardInduction` * `Finset.strongDownwardInductionOn` * `Finset.case_strong_induction_on` * `Finset.Nonempty.strong_induction` -/ assert_not_exists MonoidWithZero -- TODO: After a lot more work, -- assert_not_exists OrderedCommMonoid open Function Multiset Nat variable {α β R : Type*} namespace Finset variable {s t : Finset α} {a b : α} /-- `s.card` is the number of elements of `s`, aka its cardinality. -/ def card (s : Finset α) : ℕ := Multiset.card s.1 #align finset.card Finset.card theorem card_def (s : Finset α) : s.card = Multiset.card s.1 := rfl #align finset.card_def Finset.card_def @[simp] lemma card_val (s : Finset α) : Multiset.card s.1 = s.card := rfl #align finset.card_val Finset.card_val @[simp] theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = Multiset.card m := rfl #align finset.card_mk Finset.card_mk @[simp] theorem card_empty : card (∅ : Finset α) = 0 := rfl #align finset.card_empty Finset.card_empty @[gcongr] theorem card_le_card : s ⊆ t → s.card ≤ t.card := Multiset.card_le_card ∘ val_le_iff.mpr #align finset.card_le_of_subset Finset.card_le_card @[mono] theorem card_mono : Monotone (@card α) := by apply card_le_card #align finset.card_mono Finset.card_mono @[simp] lemma card_eq_zero : s.card = 0 ↔ s = ∅ := card_eq_zero.trans val_eq_zero lemma card_ne_zero : s.card ≠ 0 ↔ s.Nonempty := card_eq_zero.ne.trans nonempty_iff_ne_empty.symm lemma card_pos : 0 < s.card ↔ s.Nonempty := Nat.pos_iff_ne_zero.trans card_ne_zero #align finset.card_eq_zero Finset.card_eq_zero #align finset.card_pos Finset.card_pos alias ⟨_, Nonempty.card_pos⟩ := card_pos alias ⟨_, Nonempty.card_ne_zero⟩ := card_ne_zero #align finset.nonempty.card_pos Finset.Nonempty.card_pos theorem card_ne_zero_of_mem (h : a ∈ s) : s.card ≠ 0 := (not_congr card_eq_zero).2 <| ne_empty_of_mem h #align finset.card_ne_zero_of_mem Finset.card_ne_zero_of_mem @[simp] theorem card_singleton (a : α) : card ({a} : Finset α) = 1 := Multiset.card_singleton _ #align finset.card_singleton Finset.card_singleton theorem card_singleton_inter [DecidableEq α] : ({a} ∩ s).card ≤ 1 := by cases' Finset.decidableMem a s with h h · simp [Finset.singleton_inter_of_not_mem h] · simp [Finset.singleton_inter_of_mem h] #align finset.card_singleton_inter Finset.card_singleton_inter @[simp] theorem card_cons (h : a ∉ s) : (s.cons a h).card = s.card + 1 := Multiset.card_cons _ _ #align finset.card_cons Finset.card_cons section InsertErase variable [DecidableEq α] @[simp] theorem card_insert_of_not_mem (h : a ∉ s) : (insert a s).card = s.card + 1 := by rw [← cons_eq_insert _ _ h, card_cons] #align finset.card_insert_of_not_mem Finset.card_insert_of_not_mem theorem card_insert_of_mem (h : a ∈ s) : card (insert a s) = s.card := by rw [insert_eq_of_mem h] #align finset.card_insert_of_mem Finset.card_insert_of_mem theorem card_insert_le (a : α) (s : Finset α) : card (insert a s) ≤ s.card + 1 := by by_cases h : a ∈ s · rw [insert_eq_of_mem h] exact Nat.le_succ _ · rw [card_insert_of_not_mem h] #align finset.card_insert_le Finset.card_insert_le section variable {a b c d e f : α} theorem card_le_two : card {a, b} ≤ 2 := card_insert_le _ _ theorem card_le_three : card {a, b, c} ≤ 3 := (card_insert_le _ _).trans (Nat.succ_le_succ card_le_two) theorem card_le_four : card {a, b, c, d} ≤ 4 := (card_insert_le _ _).trans (Nat.succ_le_succ card_le_three) theorem card_le_five : card {a, b, c, d, e} ≤ 5 := (card_insert_le _ _).trans (Nat.succ_le_succ card_le_four) theorem card_le_six : card {a, b, c, d, e, f} ≤ 6 := (card_insert_le _ _).trans (Nat.succ_le_succ card_le_five) end /-- If `a ∈ s` is known, see also `Finset.card_insert_of_mem` and `Finset.card_insert_of_not_mem`. -/ theorem card_insert_eq_ite : card (insert a s) = if a ∈ s then s.card else s.card + 1 := by by_cases h : a ∈ s · rw [card_insert_of_mem h, if_pos h] · rw [card_insert_of_not_mem h, if_neg h] #align finset.card_insert_eq_ite Finset.card_insert_eq_ite @[simp]
Mathlib/Data/Finset/Card.lean
150
152
theorem card_pair_eq_one_or_two : ({a,b} : Finset α).card = 1 ∨ ({a,b} : Finset α).card = 2 := by
simp [card_insert_eq_ite] tauto
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Yury Kudryashov -/ import Mathlib.MeasureTheory.OuterMeasure.Basic /-! # The “almost everywhere” filter of co-null sets. If `μ` is an outer measure or a measure on `α`, then `MeasureTheory.ae μ` is the filter of co-null sets: `s ∈ ae μ ↔ μ sᶜ = 0`. In this file we define the filter and prove some basic theorems about it. ## Notation - `∀ᵐ x ∂μ, p x`: the predicate `p` holds for `μ`-a.e. all `x`; - `∃ᶠ x ∂μ, p x`: the predicate `p` holds on a set of nonzero measure; - `f =ᵐ[μ] g`: `f x = g x` for `μ`-a.e. all `x`; - `f ≤ᵐ[μ] g`: `f x ≤ g x` for `μ`-a.e. all `x`. ## Implementation details All notation introduced in this file reducibly unfolds to the corresponding definitions about filters, so generic lemmas about `Filter.Eventually`, `Filter.EventuallyEq` etc apply. However, we restate some lemmas specifically for `ae`. ## Tags outer measure, measure, almost everywhere -/ open Filter Set open scoped ENNReal namespace MeasureTheory variable {α β F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α} /-- The “almost everywhere” filter of co-null sets. -/ def ae (μ : F) : Filter α := .ofCountableUnion (μ · = 0) (fun _S hSc ↦ (measure_sUnion_null_iff hSc).2) fun _t ht _s hs ↦ measure_mono_null hs ht #align measure_theory.measure.ae MeasureTheory.ae /-- `∀ᵐ a ∂μ, p a` means that `p a` for a.e. `a`, i.e. `p` holds true away from a null set. This is notation for `Filter.Eventually p (MeasureTheory.ae μ)`. -/ notation3 "∀ᵐ "(...)" ∂"μ", "r:(scoped p => Filter.Eventually p <| MeasureTheory.ae μ) => r /-- `∃ᵐ a ∂μ, p a` means that `p` holds `∂μ`-frequently, i.e. `p` holds on a set of positive measure. This is notation for `Filter.Frequently p (MeasureTheory.ae μ)`. -/ notation3 "∃ᵐ "(...)" ∂"μ", "r:(scoped P => Filter.Frequently P <| MeasureTheory.ae μ) => r /-- `f =ᵐ[μ] g` means `f` and `g` are eventually equal along the a.e. filter, i.e. `f=g` away from a null set. This is notation for `Filter.EventuallyEq (MeasureTheory.ae μ) f g`. -/ notation:50 f " =ᵐ[" μ:50 "] " g:50 => Filter.EventuallyEq (MeasureTheory.ae μ) f g /-- `f ≤ᵐ[μ] g` means `f` is eventually less than `g` along the a.e. filter, i.e. `f ≤ g` away from a null set. This is notation for `Filter.EventuallyLE (MeasureTheory.ae μ) f g`. -/ notation:50 f " ≤ᵐ[" μ:50 "] " g:50 => Filter.EventuallyLE (MeasureTheory.ae μ) f g theorem mem_ae_iff {s : Set α} : s ∈ ae μ ↔ μ sᶜ = 0 := Iff.rfl #align measure_theory.mem_ae_iff MeasureTheory.mem_ae_iff theorem ae_iff {p : α → Prop} : (∀ᵐ a ∂μ, p a) ↔ μ { a | ¬p a } = 0 := Iff.rfl #align measure_theory.ae_iff MeasureTheory.ae_iff theorem compl_mem_ae_iff {s : Set α} : sᶜ ∈ ae μ ↔ μ s = 0 := by simp only [mem_ae_iff, compl_compl] #align measure_theory.compl_mem_ae_iff MeasureTheory.compl_mem_ae_iff theorem frequently_ae_iff {p : α → Prop} : (∃ᵐ a ∂μ, p a) ↔ μ { a | p a } ≠ 0 := not_congr compl_mem_ae_iff #align measure_theory.frequently_ae_iff MeasureTheory.frequently_ae_iff theorem frequently_ae_mem_iff {s : Set α} : (∃ᵐ a ∂μ, a ∈ s) ↔ μ s ≠ 0 := not_congr compl_mem_ae_iff #align measure_theory.frequently_ae_mem_iff MeasureTheory.frequently_ae_mem_iff theorem measure_zero_iff_ae_nmem {s : Set α} : μ s = 0 ↔ ∀ᵐ a ∂μ, a ∉ s := compl_mem_ae_iff.symm #align measure_theory.measure_zero_iff_ae_nmem MeasureTheory.measure_zero_iff_ae_nmem theorem ae_of_all {p : α → Prop} (μ : F) : (∀ a, p a) → ∀ᵐ a ∂μ, p a := eventually_of_forall #align measure_theory.ae_of_all MeasureTheory.ae_of_all instance instCountableInterFilter : CountableInterFilter (ae μ) := by unfold ae; infer_instance #align measure_theory.measure.ae.countable_Inter_filter MeasureTheory.instCountableInterFilter theorem ae_all_iff {ι : Sort*} [Countable ι] {p : α → ι → Prop} : (∀ᵐ a ∂μ, ∀ i, p a i) ↔ ∀ i, ∀ᵐ a ∂μ, p a i := eventually_countable_forall #align measure_theory.ae_all_iff MeasureTheory.ae_all_iff
Mathlib/MeasureTheory/OuterMeasure/AE.lean
107
109
theorem all_ae_of {ι : Sort*} {p : α → ι → Prop} (hp : ∀ᵐ a ∂μ, ∀ i, p a i) (i : ι) : ∀ᵐ a ∂μ, p a i := by
filter_upwards [hp] with a ha using ha i
/- Copyright (c) 2022 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth -/ import Mathlib.Order.ConditionallyCompleteLattice.Basic import Mathlib.Order.LatticeIntervals import Mathlib.Order.Interval.Set.OrdConnected #align_import order.complete_lattice_intervals from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432" /-! # Subtypes of conditionally complete linear orders In this file we give conditions on a subset of a conditionally complete linear order, to ensure that the subtype is itself conditionally complete. We check that an `OrdConnected` set satisfies these conditions. ## TODO Add appropriate instances for all `Set.Ixx`. This requires a refactor that will allow different default values for `sSup` and `sInf`. -/ open scoped Classical open Set variable {ι : Sort*} {α : Type*} (s : Set α) section SupSet variable [Preorder α] [SupSet α] /-- `SupSet` structure on a nonempty subset `s` of a preorder with `SupSet`. This definition is non-canonical (it uses `default s`); it should be used only as here, as an auxiliary instance in the construction of the `ConditionallyCompleteLinearOrder` structure. -/ noncomputable def subsetSupSet [Inhabited s] : SupSet s where sSup t := if ht : t.Nonempty ∧ BddAbove t ∧ sSup ((↑) '' t : Set α) ∈ s then ⟨sSup ((↑) '' t : Set α), ht.2.2⟩ else default #align subset_has_Sup subsetSupSet attribute [local instance] subsetSupSet @[simp] theorem subset_sSup_def [Inhabited s] : @sSup s _ = fun t => if ht : t.Nonempty ∧ BddAbove t ∧ sSup ((↑) '' t : Set α) ∈ s then ⟨sSup ((↑) '' t : Set α), ht.2.2⟩ else default := rfl #align subset_Sup_def subset_sSup_def theorem subset_sSup_of_within [Inhabited s] {t : Set s} (h' : t.Nonempty) (h'' : BddAbove t) (h : sSup ((↑) '' t : Set α) ∈ s) : sSup ((↑) '' t : Set α) = (@sSup s _ t : α) := by simp [dif_pos, h, h', h''] #align subset_Sup_of_within subset_sSup_of_within
Mathlib/Order/CompleteLatticeIntervals.lean
62
64
theorem subset_sSup_emptyset [Inhabited s] : sSup (∅ : Set s) = default := by
simp [sSup]
/- Copyright (c) 2024 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.RingTheory.PrincipalIdealDomain #align_import ring_theory.ideal.basic from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Principal Ideals This file deals with the set of principal ideals of a `CommRing R`. ## Main definitions and results * `Ideal.isPrincipalSubmonoid`: the submonoid of `Ideal R` formed by the principal ideals of `R`. * `Ideal.associatesMulEquivIsPrincipal`: the `MulEquiv` between the monoid of `Associates R` and the submonoid of principal ideals of `R`. -/ variable {R : Type*} [CommRing R] namespace Ideal open Submodule variable (R) in /-- The principal ideals of `R` form a submonoid of `Ideal R`. -/ def isPrincipalSubmonoid : Submonoid (Ideal R) where carrier := {I | IsPrincipal I} mul_mem' := by rintro _ _ ⟨x, rfl⟩ ⟨y, rfl⟩ exact ⟨x * y, Ideal.span_singleton_mul_span_singleton x y⟩ one_mem' := ⟨1, one_eq_span⟩ theorem mem_isPrincipalSubmonoid_iff {I : Ideal R} : I ∈ isPrincipalSubmonoid R ↔ IsPrincipal I := Iff.rfl theorem span_singleton_mem_isPrincipalSubmonoid (a : R) : span {a} ∈ isPrincipalSubmonoid R := mem_isPrincipalSubmonoid_iff.mpr ⟨a, rfl⟩ variable [IsDomain R] variable (R) in /-- The equivalence between `Associates R` and the principal ideals of `R` defined by sending the class of `x` to the principal ideal generated by `x`. -/ noncomputable def associatesEquivIsPrincipal : Associates R ≃ {I : Ideal R // IsPrincipal I} where toFun := Quotient.lift (fun x ↦ ⟨span {x}, x, rfl⟩) (fun _ _ _ ↦ by simpa [span_singleton_eq_span_singleton]) invFun I := Associates.mk I.2.generator left_inv := Quotient.ind fun _ ↦ by simpa using Ideal.span_singleton_eq_span_singleton.mp (@Ideal.span_singleton_generator _ _ _ ⟨_, rfl⟩) right_inv I := by simp only [Quotient.lift_mk, span_singleton_generator, Subtype.coe_eta] @[simp] theorem associatesEquivIsPrincipal_apply (x : R) : associatesEquivIsPrincipal R (Associates.mk x) = span {x} := rfl @[simp] theorem associatesEquivIsPrincipal_symm_apply {I : Ideal R} (hI : IsPrincipal I) : (associatesEquivIsPrincipal R).symm ⟨I, hI⟩ = Associates.mk hI.generator := rfl theorem associatesEquivIsPrincipal_mul (x y : Associates R) : (associatesEquivIsPrincipal R (x * y) : Ideal R) = (associatesEquivIsPrincipal R x) * (associatesEquivIsPrincipal R y) := by rw [← Associates.quot_out x, ← Associates.quot_out y] simp_rw [Associates.mk_mul_mk, ← Associates.quotient_mk_eq_mk, associatesEquivIsPrincipal_apply, span_singleton_mul_span_singleton] @[simp]
Mathlib/RingTheory/Ideal/IsPrincipal.lean
75
78
theorem associatesEquivIsPrincipal_map_zero : (associatesEquivIsPrincipal R 0 : Ideal R) = 0 := by
rw [← Associates.mk_zero, ← Associates.quotient_mk_eq_mk, associatesEquivIsPrincipal_apply, Set.singleton_zero, span_zero, zero_eq_bot]
/- Copyright (c) 2021 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth, Eric Wieser -/ import Mathlib.Analysis.NormedSpace.PiLp import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import analysis.matrix from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Matrices as a normed space In this file we provide the following non-instances for norms on matrices: * The elementwise norm: * `Matrix.seminormedAddCommGroup` * `Matrix.normedAddCommGroup` * `Matrix.normedSpace` * `Matrix.boundedSMul` * The Frobenius norm: * `Matrix.frobeniusSeminormedAddCommGroup` * `Matrix.frobeniusNormedAddCommGroup` * `Matrix.frobeniusNormedSpace` * `Matrix.frobeniusNormedRing` * `Matrix.frobeniusNormedAlgebra` * `Matrix.frobeniusBoundedSMul` * The $L^\infty$ operator norm: * `Matrix.linftyOpSeminormedAddCommGroup` * `Matrix.linftyOpNormedAddCommGroup` * `Matrix.linftyOpNormedSpace` * `Matrix.linftyOpBoundedSMul` * `Matrix.linftyOpNonUnitalSemiNormedRing` * `Matrix.linftyOpSemiNormedRing` * `Matrix.linftyOpNonUnitalNormedRing` * `Matrix.linftyOpNormedRing` * `Matrix.linftyOpNormedAlgebra` These are not declared as instances because there are several natural choices for defining the norm of a matrix. The norm induced by the identification of `Matrix m n 𝕜` with `EuclideanSpace n 𝕜 →L[𝕜] EuclideanSpace m 𝕜` (i.e., the ℓ² operator norm) can be found in `Analysis.NormedSpace.Star.Matrix`. It is separated to avoid extraneous imports in this file. -/ noncomputable section open scoped NNReal Matrix namespace Matrix variable {R l m n α β : Type*} [Fintype l] [Fintype m] [Fintype n] /-! ### The elementwise supremum norm -/ section LinfLinf section SeminormedAddCommGroup variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β] /-- Seminormed group instance (using sup norm of sup norm) for matrices over a seminormed group. Not declared as an instance because there are several natural choices for defining the norm of a matrix. -/ protected def seminormedAddCommGroup : SeminormedAddCommGroup (Matrix m n α) := Pi.seminormedAddCommGroup #align matrix.seminormed_add_comm_group Matrix.seminormedAddCommGroup attribute [local instance] Matrix.seminormedAddCommGroup -- Porting note (#10756): new theorem (along with all the uses of this lemma below) theorem norm_def (A : Matrix m n α) : ‖A‖ = ‖fun i j => A i j‖ := rfl /-- The norm of a matrix is the sup of the sup of the nnnorm of the entries -/ lemma norm_eq_sup_sup_nnnorm (A : Matrix m n α) : ‖A‖ = Finset.sup Finset.univ fun i ↦ Finset.sup Finset.univ fun j ↦ ‖A i j‖₊ := by simp_rw [Matrix.norm_def, Pi.norm_def, Pi.nnnorm_def] -- Porting note (#10756): new theorem (along with all the uses of this lemma below) theorem nnnorm_def (A : Matrix m n α) : ‖A‖₊ = ‖fun i j => A i j‖₊ := rfl
Mathlib/Analysis/Matrix.lean
90
91
theorem norm_le_iff {r : ℝ} (hr : 0 ≤ r) {A : Matrix m n α} : ‖A‖ ≤ r ↔ ∀ i j, ‖A i j‖ ≤ r := by
simp_rw [norm_def, pi_norm_le_iff_of_nonneg hr]
/- 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.LinearAlgebra.Quotient import Mathlib.Algebra.Category.ModuleCat.Basic #align_import algebra.category.Module.epi_mono from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Monomorphisms in `Module R` This file shows that an `R`-linear map is a monomorphism in the category of `R`-modules if and only if it is injective, and similarly an epimorphism if and only if it is surjective. -/ universe v u open CategoryTheory namespace ModuleCat variable {R : Type u} [Ring R] {X Y : ModuleCat.{v} R} (f : X ⟶ Y) variable {M : Type v} [AddCommGroup M] [Module R M] theorem ker_eq_bot_of_mono [Mono f] : LinearMap.ker f = ⊥ := LinearMap.ker_eq_bot_of_cancel fun u v => (@cancel_mono _ _ _ _ _ f _ (↟u) (↟v)).1 set_option linter.uppercaseLean3 false in #align Module.ker_eq_bot_of_mono ModuleCat.ker_eq_bot_of_mono theorem range_eq_top_of_epi [Epi f] : LinearMap.range f = ⊤ := LinearMap.range_eq_top_of_cancel fun u v => (@cancel_epi _ _ _ _ _ f _ (↟u) (↟v)).1 set_option linter.uppercaseLean3 false in #align Module.range_eq_top_of_epi ModuleCat.range_eq_top_of_epi theorem mono_iff_ker_eq_bot : Mono f ↔ LinearMap.ker f = ⊥ := ⟨fun hf => ker_eq_bot_of_mono _, fun hf => ConcreteCategory.mono_of_injective _ <| by convert LinearMap.ker_eq_bot.1 hf⟩ set_option linter.uppercaseLean3 false in #align Module.mono_iff_ker_eq_bot ModuleCat.mono_iff_ker_eq_bot
Mathlib/Algebra/Category/ModuleCat/EpiMono.lean
44
45
theorem mono_iff_injective : Mono f ↔ Function.Injective f := by
rw [mono_iff_ker_eq_bot, LinearMap.ker_eq_bot]
/- Copyright (c) 2020 Thomas Browning, Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning, Patrick Lutz -/ import Mathlib.Algebra.Algebra.Subalgebra.Directed import Mathlib.FieldTheory.IntermediateField import Mathlib.FieldTheory.Separable import Mathlib.FieldTheory.SplittingField.IsSplittingField import Mathlib.RingTheory.TensorProduct.Basic #align_import field_theory.adjoin from "leanprover-community/mathlib"@"df76f43357840485b9d04ed5dee5ab115d420e87" /-! # Adjoining Elements to Fields In this file we introduce the notion of adjoining elements to fields. This isn't quite the same as adjoining elements to rings. For example, `Algebra.adjoin K {x}` might not include `x⁻¹`. ## Main results - `adjoin_adjoin_left`: adjoining S and then T is the same as adjoining `S ∪ T`. - `bot_eq_top_of_rank_adjoin_eq_one`: if `F⟮x⟯` has dimension `1` over `F` for every `x` in `E` then `F = E` ## Notation - `F⟮α⟯`: adjoin a single element `α` to `F` (in scope `IntermediateField`). -/ set_option autoImplicit true open FiniteDimensional Polynomial open scoped Classical Polynomial namespace IntermediateField section AdjoinDef variable (F : Type*) [Field F] {E : Type*} [Field E] [Algebra F E] (S : Set E) -- Porting note: not adding `neg_mem'` causes an error. /-- `adjoin F S` extends a field `F` by adjoining a set `S ⊆ E`. -/ def adjoin : IntermediateField F E := { Subfield.closure (Set.range (algebraMap F E) ∪ S) with algebraMap_mem' := fun x => Subfield.subset_closure (Or.inl (Set.mem_range_self x)) } #align intermediate_field.adjoin IntermediateField.adjoin variable {S} theorem mem_adjoin_iff (x : E) : x ∈ adjoin F S ↔ ∃ r s : MvPolynomial S F, x = MvPolynomial.aeval Subtype.val r / MvPolynomial.aeval Subtype.val s := by simp only [adjoin, mem_mk, Subring.mem_toSubsemiring, Subfield.mem_toSubring, Subfield.mem_closure_iff, ← Algebra.adjoin_eq_ring_closure, Subalgebra.mem_toSubring, Algebra.adjoin_eq_range, AlgHom.mem_range, exists_exists_eq_and] tauto
Mathlib/FieldTheory/Adjoin.lean
62
67
theorem mem_adjoin_simple_iff {α : E} (x : E) : x ∈ adjoin F {α} ↔ ∃ r s : F[X], x = aeval α r / aeval α s := by
simp only [adjoin, mem_mk, Subring.mem_toSubsemiring, Subfield.mem_toSubring, Subfield.mem_closure_iff, ← Algebra.adjoin_eq_ring_closure, Subalgebra.mem_toSubring, Algebra.adjoin_singleton_eq_range_aeval, AlgHom.mem_range, exists_exists_eq_and] tauto
/- 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⟩ 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 theorem equiv_eq_conj (a : A) : (of (φ a : G) : HNNExtension G A B φ) = t * of (a : G) * t⁻¹ := by rw [t_mul_of]; simp theorem equiv_symm_eq_conj (b : B) : (of (φ.symm b : G) : HNNExtension G A B φ) = t⁻¹ * of (b : G) * t := by rw [mul_assoc, of_mul_t]; simp theorem inv_t_mul_of (b : B) : t⁻¹ * (of (b : G) : HNNExtension G A B φ) = of (φ.symm b : G) * t⁻¹ := by rw [equiv_symm_eq_conj]; simp theorem of_mul_inv_t (a : A) : (of (a : G) : HNNExtension G A B φ) * t⁻¹ = t⁻¹ * of (φ a : G) := by rw [equiv_eq_conj]; simp [mul_assoc] /-- Define a function `HNNExtension G A B φ →* H`, by defining it on `G` and `t` -/ def lift (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) : HNNExtension G A B φ →* H := Con.lift _ (Coprod.lift f (zpowersHom H x)) (Con.conGen_le <| by rintro _ _ ⟨a, rfl, rfl⟩ simp [hx]) @[simp] theorem lift_t (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) : lift f x hx t = x := by delta HNNExtension; simp [lift, t] @[simp]
Mathlib/GroupTheory/HNNExtension.lean
102
104
theorem lift_of (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) (g : G) : lift f x hx (of g) = f g := by
delta HNNExtension; simp [lift, of]
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Topology.Sheaves.Presheaf import Mathlib.CategoryTheory.Adjunction.FullyFaithful #align_import algebraic_geometry.presheafed_space from "leanprover-community/mathlib"@"d39590fc8728fbf6743249802486f8c91ffe07bc" /-! # Presheafed spaces Introduces the category of topological spaces equipped with a presheaf (taking values in an arbitrary target category `C`.) We further describe how to apply functors and natural transformations to the values of the presheaves. -/ open Opposite CategoryTheory CategoryTheory.Category CategoryTheory.Functor TopCat TopologicalSpace variable (C : Type*) [Category C] -- Porting note: we used to have: -- local attribute [tidy] tactic.auto_cases_opens -- We would replace this by: -- attribute [local aesop safe cases (rule_sets := [CategoryTheory])] Opens -- although it doesn't appear to help in this file, in any case. -- Porting note: we used to have: -- local attribute [tidy] tactic.op_induction' -- A possible replacement would be: -- attribute [local aesop safe cases (rule_sets := [CategoryTheory])] Opposite -- but this would probably require https://github.com/JLimperg/aesop/issues/59 -- In any case, it doesn't seem necessary here. namespace AlgebraicGeometry -- Porting note: `PresheafSpace.{w} C` is the type of topological spaces in `Type w` equipped -- with a presheaf with values in `C`; then there is a total of three universe parameters -- in `PresheafSpace.{w, v, u} C`, where `C : Type u` and `Category.{v} C`. -- In mathlib3, some definitions in this file unnecessarily assumed `w=v`. This restriction -- has been removed. /-- A `PresheafedSpace C` is a topological space equipped with a presheaf of `C`s. -/ structure PresheafedSpace where carrier : TopCat protected presheaf : carrier.Presheaf C set_option linter.uppercaseLean3 false in #align algebraic_geometry.PresheafedSpace AlgebraicGeometry.PresheafedSpace variable {C} namespace PresheafedSpace -- Porting note: using `Coe` here triggers an error, `CoeOut` seems an acceptable alternative instance coeCarrier : CoeOut (PresheafedSpace C) TopCat where coe X := X.carrier set_option linter.uppercaseLean3 false in #align algebraic_geometry.PresheafedSpace.coe_carrier AlgebraicGeometry.PresheafedSpace.coeCarrier attribute [coe] PresheafedSpace.carrier -- Porting note: we add this instance, as Lean does not reliably use the `CoeOut` instance above -- in downstream files. instance : CoeSort (PresheafedSpace C) Type* where coe := fun X => X.carrier -- Porting note: the following lemma is removed because it is a syntactic tauto /-@[simp] theorem as_coe (X : PresheafedSpace.{w, v, u} C) : X.carrier = (X : TopCat.{w}) := rfl-/ set_option linter.uppercaseLean3 false in #noalign algebraic_geometry.PresheafedSpace.as_coe -- Porting note: removed @[simp] as the `simpVarHead` linter complains -- @[simp] theorem mk_coe (carrier) (presheaf) : (({ carrier presheaf } : PresheafedSpace C) : TopCat) = carrier := rfl set_option linter.uppercaseLean3 false in #align algebraic_geometry.PresheafedSpace.mk_coe AlgebraicGeometry.PresheafedSpace.mk_coe instance (X : PresheafedSpace C) : TopologicalSpace X := X.carrier.str /-- The constant presheaf on `X` with value `Z`. -/ def const (X : TopCat) (Z : C) : PresheafedSpace C where carrier := X presheaf := (Functor.const _).obj Z set_option linter.uppercaseLean3 false in #align algebraic_geometry.PresheafedSpace.const AlgebraicGeometry.PresheafedSpace.const instance [Inhabited C] : Inhabited (PresheafedSpace C) := ⟨const (TopCat.of PEmpty) default⟩ /-- A morphism between presheafed spaces `X` and `Y` consists of a continuous map `f` between the underlying topological spaces, and a (notice contravariant!) map from the presheaf on `Y` to the pushforward of the presheaf on `X` via `f`. -/ structure Hom (X Y : PresheafedSpace C) where base : (X : TopCat) ⟶ (Y : TopCat) c : Y.presheaf ⟶ base _* X.presheaf set_option linter.uppercaseLean3 false in #align algebraic_geometry.PresheafedSpace.hom AlgebraicGeometry.PresheafedSpace.Hom -- Porting note: eventually, the ext lemma shall be applied to terms in `X ⟶ Y` -- rather than `Hom X Y`, this one was renamed `Hom.ext` instead of `ext`, -- and the more practical lemma `ext` is defined just after the definition -- of the `Category` instance @[ext] theorem Hom.ext {X Y : PresheafedSpace C} (α β : Hom X Y) (w : α.base = β.base) (h : α.c ≫ whiskerRight (eqToHom (by rw [w])) _ = β.c) : α = β := by rcases α with ⟨base, c⟩ rcases β with ⟨base', c'⟩ dsimp at w subst w dsimp at h erw [whiskerRight_id', comp_id] at h subst h rfl set_option linter.uppercaseLean3 false in #align algebraic_geometry.PresheafedSpace.ext AlgebraicGeometry.PresheafedSpace.Hom.ext -- TODO including `injections` would make tidy work earlier.
Mathlib/Geometry/RingedSpace/PresheafedSpace.lean
126
130
theorem hext {X Y : PresheafedSpace C} (α β : Hom X Y) (w : α.base = β.base) (h : HEq α.c β.c) : α = β := by
cases α cases β congr
/- Copyright (c) 2024 Arend Mellendijk. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Arend Mellendijk -/ import Mathlib.Analysis.SpecialFunctions.Integrals import Mathlib.Analysis.SumIntegralComparisons import Mathlib.NumberTheory.Harmonic.Defs /-! This file proves $\log(n+1) \le H_n \le 1 + \log(n)$ for all natural numbers $n$. -/ theorem log_add_one_le_harmonic (n : ℕ) : Real.log ↑(n+1) ≤ harmonic n := by calc _ = ∫ x in (1:ℕ)..↑(n+1), x⁻¹ := ?_ _ ≤ ∑ d ∈ Finset.Icc 1 n, (d:ℝ)⁻¹ := ?_ _ = harmonic n := ?_ · rw [Nat.cast_one, integral_inv (by simp [(show ¬ (1 : ℝ) ≤ 0 by norm_num)]), div_one] · exact (inv_antitoneOn_Icc_right <| by norm_num).integral_le_sum_Ico (Nat.le_add_left 1 n) · simp only [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast] theorem harmonic_le_one_add_log (n : ℕ) : harmonic n ≤ 1 + Real.log n := by by_cases hn0 : n = 0 · simp [hn0] have hn : 1 ≤ n := Nat.one_le_iff_ne_zero.mpr hn0 simp_rw [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast] rw [← Finset.sum_erase_add (Finset.Icc 1 n) _ (Finset.left_mem_Icc.mpr hn), add_comm, Nat.cast_one, inv_one] refine add_le_add_left ?_ 1 simp only [Nat.lt_one_iff, Finset.mem_Icc, Finset.Icc_erase_left] calc ∑ d ∈ .Ico 2 (n + 1), (d : ℝ)⁻¹ _ = ∑ d ∈ .Ico 2 (n + 1), (↑(d + 1) - 1)⁻¹ := ?_ _ ≤ ∫ x in (2).. ↑(n + 1), (x - 1)⁻¹ := ?_ _ = ∫ x in (1)..n, x⁻¹ := ?_ _ = Real.log ↑n := ?_ · simp_rw [Nat.cast_add, Nat.cast_one, add_sub_cancel_right] · exact @AntitoneOn.sum_le_integral_Ico 2 (n + 1) (fun x : ℝ ↦ (x - 1)⁻¹) (by linarith [hn]) <| sub_inv_antitoneOn_Icc_right (by norm_num) · convert intervalIntegral.integral_comp_sub_right _ 1 · norm_num · simp only [Nat.cast_add, Nat.cast_one, add_sub_cancel_right] · convert integral_inv _ · rw [div_one] · simp only [Nat.one_le_cast, hn, Set.uIcc_of_le, Set.mem_Icc, Nat.cast_nonneg, and_true, not_le, zero_lt_one]
Mathlib/NumberTheory/Harmonic/Bounds.lean
52
62
theorem log_le_harmonic_floor (y : ℝ) (hy : 0 ≤ y) : Real.log y ≤ harmonic ⌊y⌋₊ := by
by_cases h0 : y = 0 · simp [h0] · calc _ ≤ Real.log ↑(Nat.floor y + 1) := ?_ _ ≤ _ := log_add_one_le_harmonic _ gcongr apply (Nat.le_ceil y).trans norm_cast exact Nat.ceil_le_floor_add_one y
/- 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 theorem lintegral_edist_triangle {f g h : α → β} (hf : AEStronglyMeasurable f μ) (hh : AEStronglyMeasurable h μ) : (∫⁻ a, edist (f a) (g a) ∂μ) ≤ (∫⁻ a, edist (f a) (h a) ∂μ) + ∫⁻ a, edist (g a) (h a) ∂μ := by rw [← lintegral_add_left' (hf.edist hh)] refine lintegral_mono fun a => ?_ apply edist_triangle_right #align measure_theory.lintegral_edist_triangle MeasureTheory.lintegral_edist_triangle
Mathlib/MeasureTheory/Function/L1Space.lean
83
83
theorem lintegral_nnnorm_zero : (∫⁻ _ : α, ‖(0 : β)‖₊ ∂μ) = 0 := by
simp
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.CategoryTheory.Abelian.Basic #align_import category_theory.idempotents.basic from "leanprover-community/mathlib"@"3a061790136d13594ec10c7c90d202335ac5d854" /-! # Idempotent complete categories In this file, we define the notion of idempotent complete categories (also known as Karoubian categories, or pseudoabelian in the case of preadditive categories). ## Main definitions - `IsIdempotentComplete C` expresses that `C` is idempotent complete, i.e. all idempotents in `C` split. Other characterisations of idempotent completeness are given by `isIdempotentComplete_iff_hasEqualizer_of_id_and_idempotent` and `isIdempotentComplete_iff_idempotents_have_kernels`. - `isIdempotentComplete_of_abelian` expresses that abelian categories are idempotent complete. - `isIdempotentComplete_iff_ofEquivalence` expresses that if two categories `C` and `D` are equivalent, then `C` is idempotent complete iff `D` is. - `isIdempotentComplete_iff_opposite` expresses that `Cᵒᵖ` is idempotent complete iff `C` is. ## References * [Stacks: Karoubian categories] https://stacks.math.columbia.edu/tag/09SF -/ open CategoryTheory open CategoryTheory.Category open CategoryTheory.Limits open CategoryTheory.Preadditive open Opposite namespace CategoryTheory variable (C : Type*) [Category C] /-- A category is idempotent complete iff all idempotent endomorphisms `p` split as a composition `p = e ≫ i` with `i ≫ e = 𝟙 _` -/ class IsIdempotentComplete : Prop where /-- A category is idempotent complete iff all idempotent endomorphisms `p` split as a composition `p = e ≫ i` with `i ≫ e = 𝟙 _` -/ idempotents_split : ∀ (X : C) (p : X ⟶ X), p ≫ p = p → ∃ (Y : C) (i : Y ⟶ X) (e : X ⟶ Y), i ≫ e = 𝟙 Y ∧ e ≫ i = p #align category_theory.is_idempotent_complete CategoryTheory.IsIdempotentComplete namespace Idempotents /-- A category is idempotent complete iff for all idempotent endomorphisms, the equalizer of the identity and this idempotent exists. -/ theorem isIdempotentComplete_iff_hasEqualizer_of_id_and_idempotent : IsIdempotentComplete C ↔ ∀ (X : C) (p : X ⟶ X), p ≫ p = p → HasEqualizer (𝟙 X) p := by constructor · intro intro X p hp rcases IsIdempotentComplete.idempotents_split X p hp with ⟨Y, i, e, ⟨h₁, h₂⟩⟩ exact ⟨Nonempty.intro { cone := Fork.ofι i (show i ≫ 𝟙 X = i ≫ p by rw [comp_id, ← h₂, ← assoc, h₁, id_comp]) isLimit := by apply Fork.IsLimit.mk' intro s refine ⟨s.ι ≫ e, ?_⟩ constructor · erw [assoc, h₂, ← Limits.Fork.condition s, comp_id] · intro m hm rw [Fork.ι_ofι] at hm rw [← hm] simp only [← hm, assoc, h₁] exact (comp_id m).symm }⟩ · intro h refine ⟨?_⟩ intro X p hp haveI : HasEqualizer (𝟙 X) p := h X p hp refine ⟨equalizer (𝟙 X) p, equalizer.ι (𝟙 X) p, equalizer.lift p (show p ≫ 𝟙 X = p ≫ p by rw [hp, comp_id]), ?_, equalizer.lift_ι _ _⟩ ext simp only [assoc, limit.lift_π, Eq.ndrec, id_eq, eq_mpr_eq_cast, Fork.ofι_pt, Fork.ofι_π_app, id_comp] rw [← equalizer.condition, comp_id] #align category_theory.idempotents.is_idempotent_complete_iff_has_equalizer_of_id_and_idempotent CategoryTheory.Idempotents.isIdempotentComplete_iff_hasEqualizer_of_id_and_idempotent variable {C} /-- In a preadditive category, when `p : X ⟶ X` is idempotent, then `𝟙 X - p` is also idempotent. -/ theorem idem_of_id_sub_idem [Preadditive C] {X : C} (p : X ⟶ X) (hp : p ≫ p = p) : (𝟙 _ - p) ≫ (𝟙 _ - p) = 𝟙 _ - p := by simp only [comp_sub, sub_comp, id_comp, comp_id, hp, sub_self, sub_zero] #align category_theory.idempotents.idem_of_id_sub_idem CategoryTheory.Idempotents.idem_of_id_sub_idem variable (C) /-- A preadditive category is pseudoabelian iff all idempotent endomorphisms have a kernel. -/
Mathlib/CategoryTheory/Idempotents/Basic.lean
107
117
theorem isIdempotentComplete_iff_idempotents_have_kernels [Preadditive C] : IsIdempotentComplete C ↔ ∀ (X : C) (p : X ⟶ X), p ≫ p = p → HasKernel p := by
rw [isIdempotentComplete_iff_hasEqualizer_of_id_and_idempotent] constructor · intro h X p hp haveI : HasEqualizer (𝟙 X) (𝟙 X - p) := h X (𝟙 _ - p) (idem_of_id_sub_idem p hp) convert hasKernel_of_hasEqualizer (𝟙 X) (𝟙 X - p) rw [sub_sub_cancel] · intro h X p hp haveI : HasKernel (𝟙 _ - p) := h X (𝟙 _ - p) (idem_of_id_sub_idem p hp) apply Preadditive.hasEqualizer_of_hasKernel
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl, Simon Hudon, Kenny Lau -/ import Mathlib.Data.Multiset.Bind import Mathlib.Control.Traversable.Lemmas import Mathlib.Control.Traversable.Instances #align_import data.multiset.functor from "leanprover-community/mathlib"@"1f0096e6caa61e9c849ec2adbd227e960e9dff58" /-! # Functoriality of `Multiset`. -/ universe u namespace Multiset open List instance functor : Functor Multiset where map := @map @[simp] theorem fmap_def {α' β'} {s : Multiset α'} (f : α' → β') : f <$> s = s.map f := rfl #align multiset.fmap_def Multiset.fmap_def instance : LawfulFunctor Multiset where id_map := by simp comp_map := by simp map_const {_ _} := rfl open LawfulTraversable CommApplicative variable {F : Type u → Type u} [Applicative F] [CommApplicative F] variable {α' β' : Type u} (f : α' → F β') /-- Map each element of a `Multiset` to an action, evaluate these actions in order, and collect the results. -/ def traverse : Multiset α' → F (Multiset β') := by refine Quotient.lift (Functor.map Coe.coe ∘ Traversable.traverse f) ?_ introv p; unfold Function.comp induction p with | nil => rfl | @cons x l₁ l₂ _ h => have : Multiset.cons <$> f x <*> Coe.coe <$> Traversable.traverse f l₁ = Multiset.cons <$> f x <*> Coe.coe <$> Traversable.traverse f l₂ := by rw [h] simpa [functor_norm] using this | swap x y l => have : (fun a b (l : List β') ↦ (↑(a :: b :: l) : Multiset β')) <$> f y <*> f x = (fun a b l ↦ ↑(a :: b :: l)) <$> f x <*> f y := by rw [CommApplicative.commutative_map] congr funext a b l simpa [flip] using Perm.swap a b l simp [(· ∘ ·), this, functor_norm, Coe.coe] | trans => simp [*] #align multiset.traverse Multiset.traverse instance : Monad Multiset := { Multiset.functor with pure := fun x ↦ {x} bind := @bind } @[simp] theorem pure_def {α} : (pure : α → Multiset α) = singleton := rfl #align multiset.pure_def Multiset.pure_def @[simp] theorem bind_def {α β} : (· >>= ·) = @bind α β := rfl #align multiset.bind_def Multiset.bind_def instance : LawfulMonad Multiset := LawfulMonad.mk' (bind_pure_comp := fun _ _ ↦ by simp only [pure_def, bind_def, bind_singleton, fmap_def]) (id_map := fun _ ↦ by simp only [fmap_def, id_eq, map_id']) (pure_bind := fun _ _ ↦ by simp only [pure_def, bind_def, singleton_bind]) (bind_assoc := @bind_assoc) open Functor open Traversable LawfulTraversable @[simp] theorem lift_coe {α β : Type*} (x : List α) (f : List α → β) (h : ∀ a b : List α, a ≈ b → f a = f b) : Quotient.lift f h (x : Multiset α) = f x := Quotient.lift_mk _ _ _ #align multiset.lift_coe Multiset.lift_coe @[simp]
Mathlib/Data/Multiset/Functor.lean
97
99
theorem map_comp_coe {α β} (h : α → β) : Functor.map h ∘ Coe.coe = (Coe.coe ∘ Functor.map h : List α → Multiset β) := by
funext; simp only [Function.comp_apply, Coe.coe, fmap_def, map_coe, List.map_eq_map]
/- Copyright (c) 2019 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne -/ import Mathlib.Analysis.Convex.Jensen import Mathlib.Analysis.Convex.SpecificFunctions.Basic import Mathlib.Analysis.SpecialFunctions.Pow.NNReal import Mathlib.Data.Real.ConjExponents #align_import analysis.mean_inequalities from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92" /-! # Mean value inequalities In this file we prove several inequalities for finite sums, including AM-GM inequality, Young's inequality, Hölder inequality, and Minkowski inequality. Versions for integrals of some of these inequalities are available in `MeasureTheory.MeanInequalities`. ## Main theorems ### AM-GM inequality: The inequality says that the geometric mean of a tuple of non-negative numbers is less than or equal to their arithmetic mean. We prove the weighted version of this inequality: if $w$ and $z$ are two non-negative vectors and $\sum_{i\in s} w_i=1$, then $$ \prod_{i\in s} z_i^{w_i} ≤ \sum_{i\in s} w_iz_i. $$ The classical version is a special case of this inequality for $w_i=\frac{1}{n}$. We prove a few versions of this inequality. Each of the following lemmas comes in two versions: a version for real-valued non-negative functions is in the `Real` namespace, and a version for `NNReal`-valued functions is in the `NNReal` namespace. - `geom_mean_le_arith_mean_weighted` : weighted version for functions on `Finset`s; - `geom_mean_le_arith_mean2_weighted` : weighted version for two numbers; - `geom_mean_le_arith_mean3_weighted` : weighted version for three numbers; - `geom_mean_le_arith_mean4_weighted` : weighted version for four numbers. ### Young's inequality Young's inequality says that for non-negative numbers `a`, `b`, `p`, `q` such that $\frac{1}{p}+\frac{1}{q}=1$ we have $$ ab ≤ \frac{a^p}{p} + \frac{b^q}{q}. $$ This inequality is a special case of the AM-GM inequality. It is then used to prove Hölder's inequality (see below). ### Hölder's inequality The inequality says that for two conjugate exponents `p` and `q` (i.e., for two positive numbers such that $\frac{1}{p}+\frac{1}{q}=1$) and any two non-negative vectors their inner product is less than or equal to the product of the $L_p$ norm of the first vector and the $L_q$ norm of the second vector: $$ \sum_{i\in s} a_ib_i ≤ \sqrt[p]{\sum_{i\in s} a_i^p}\sqrt[q]{\sum_{i\in s} b_i^q}. $$ We give versions of this result in `ℝ`, `ℝ≥0` and `ℝ≥0∞`. There are at least two short proofs of this inequality. In our proof we prenormalize both vectors, then apply Young's inequality to each $a_ib_i$. Another possible proof would be to deduce this inequality from the generalized mean inequality for well-chosen vectors and weights. ### Minkowski's inequality The inequality says that for `p ≥ 1` the function $$ \|a\|_p=\sqrt[p]{\sum_{i\in s} a_i^p} $$ satisfies the triangle inequality $\|a+b\|_p\le \|a\|_p+\|b\|_p$. We give versions of this result in `Real`, `ℝ≥0` and `ℝ≥0∞`. We deduce this inequality from Hölder's inequality. Namely, Hölder inequality implies that $\|a\|_p$ is the maximum of the inner product $\sum_{i\in s}a_ib_i$ over `b` such that $\|b\|_q\le 1$. Now Minkowski's inequality follows from the fact that the maximum value of the sum of two functions is less than or equal to the sum of the maximum values of the summands. ## TODO - each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them is to define `StrictConvexOn` functions. - generalized mean inequality with any `p ≤ q`, including negative numbers; - prove that the power mean tends to the geometric mean as the exponent tends to zero. -/ universe u v open scoped Classical open Finset NNReal ENNReal set_option linter.uppercaseLean3 false noncomputable section variable {ι : Type u} (s : Finset ι) section GeomMeanLEArithMean /-! ### AM-GM inequality -/ namespace Real /-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted version for real-valued nonnegative functions. -/
Mathlib/Analysis/MeanInequalities.lean
113
134
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) : ∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i := by
-- If some number `z i` equals zero and has non-zero weight, then LHS is 0 and RHS is nonnegative. by_cases A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0 · rcases A with ⟨i, his, hzi, hwi⟩ rw [prod_eq_zero his] · exact sum_nonneg fun j hj => mul_nonneg (hw j hj) (hz j hj) · rw [hzi] exact zero_rpow hwi -- If all numbers `z i` with non-zero weight are positive, then we apply Jensen's inequality -- for `exp` and numbers `log (z i)` with weights `w i`. · simp only [not_exists, not_and, Ne, Classical.not_not] at A have := convexOn_exp.map_sum_le hw hw' fun i _ => Set.mem_univ <| log (z i) simp only [exp_sum, (· ∘ ·), smul_eq_mul, mul_comm (w _) (log _)] at this convert this using 1 <;> [apply prod_congr rfl;apply sum_congr rfl] <;> intro i hi · cases' eq_or_lt_of_le (hz i hi) with hz hz · simp [A i hi hz.symm] · exact rpow_def_of_pos hz _ · cases' eq_or_lt_of_le (hz i hi) with hz hz · simp [A i hi hz.symm] · rw [exp_log hz]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker -/ import Mathlib.Algebra.MonoidAlgebra.Degree import Mathlib.Algebra.Polynomial.Coeff import Mathlib.Algebra.Polynomial.Monomial import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.Nat.WithBot import Mathlib.Data.Nat.Cast.WithTop import Mathlib.Data.Nat.SuccPred #align_import data.polynomial.degree.definitions from "leanprover-community/mathlib"@"808ea4ebfabeb599f21ec4ae87d6dc969597887f" /-! # Theory of univariate polynomials The definitions include `degree`, `Monic`, `leadingCoeff` Results include - `degree_mul` : The degree of the product is the sum of degrees - `leadingCoeff_add_of_degree_eq` and `leadingCoeff_add_of_degree_lt` : The leading_coefficient of a sum is determined by the leading coefficients and degrees -/ -- Porting note: `Mathlib.Data.Nat.Cast.WithTop` should be imported for `Nat.cast_withBot`. set_option linter.uppercaseLean3 false noncomputable section open Finsupp Finset open Polynomial namespace Polynomial universe u v variable {R : Type u} {S : Type v} {a b c d : R} {n m : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} /-- `degree p` is the degree of the polynomial `p`, i.e. the largest `X`-exponent in `p`. `degree p = some n` when `p ≠ 0` and `n` is the highest power of `X` that appears in `p`, otherwise `degree 0 = ⊥`. -/ def degree (p : R[X]) : WithBot ℕ := p.support.max #align polynomial.degree Polynomial.degree theorem supDegree_eq_degree (p : R[X]) : p.toFinsupp.supDegree WithBot.some = p.degree := max_eq_sup_coe theorem degree_lt_wf : WellFounded fun p q : R[X] => degree p < degree q := InvImage.wf degree wellFounded_lt #align polynomial.degree_lt_wf Polynomial.degree_lt_wf instance : WellFoundedRelation R[X] := ⟨_, degree_lt_wf⟩ /-- `natDegree p` forces `degree p` to ℕ, by defining `natDegree 0 = 0`. -/ def natDegree (p : R[X]) : ℕ := (degree p).unbot' 0 #align polynomial.nat_degree Polynomial.natDegree /-- `leadingCoeff p` gives the coefficient of the highest power of `X` in `p`-/ def leadingCoeff (p : R[X]) : R := coeff p (natDegree p) #align polynomial.leading_coeff Polynomial.leadingCoeff /-- a polynomial is `Monic` if its leading coefficient is 1 -/ def Monic (p : R[X]) := leadingCoeff p = (1 : R) #align polynomial.monic Polynomial.Monic @[nontriviality] theorem monic_of_subsingleton [Subsingleton R] (p : R[X]) : Monic p := Subsingleton.elim _ _ #align polynomial.monic_of_subsingleton Polynomial.monic_of_subsingleton theorem Monic.def : Monic p ↔ leadingCoeff p = 1 := Iff.rfl #align polynomial.monic.def Polynomial.Monic.def instance Monic.decidable [DecidableEq R] : Decidable (Monic p) := by unfold Monic; infer_instance #align polynomial.monic.decidable Polynomial.Monic.decidable @[simp] theorem Monic.leadingCoeff {p : R[X]} (hp : p.Monic) : leadingCoeff p = 1 := hp #align polynomial.monic.leading_coeff Polynomial.Monic.leadingCoeff theorem Monic.coeff_natDegree {p : R[X]} (hp : p.Monic) : p.coeff p.natDegree = 1 := hp #align polynomial.monic.coeff_nat_degree Polynomial.Monic.coeff_natDegree @[simp] theorem degree_zero : degree (0 : R[X]) = ⊥ := rfl #align polynomial.degree_zero Polynomial.degree_zero @[simp] theorem natDegree_zero : natDegree (0 : R[X]) = 0 := rfl #align polynomial.nat_degree_zero Polynomial.natDegree_zero @[simp] theorem coeff_natDegree : coeff p (natDegree p) = leadingCoeff p := rfl #align polynomial.coeff_nat_degree Polynomial.coeff_natDegree @[simp] theorem degree_eq_bot : degree p = ⊥ ↔ p = 0 := ⟨fun h => support_eq_empty.1 (Finset.max_eq_bot.1 h), fun h => h.symm ▸ rfl⟩ #align polynomial.degree_eq_bot Polynomial.degree_eq_bot @[nontriviality]
Mathlib/Algebra/Polynomial/Degree/Definitions.lean
123
124
theorem degree_of_subsingleton [Subsingleton R] : degree p = ⊥ := by
rw [Subsingleton.elim p 0, degree_zero]
/- Copyright (c) 2021 Jakob Scholbach. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jakob Scholbach -/ import Mathlib.Algebra.CharP.Basic import Mathlib.Algebra.CharP.Algebra import Mathlib.Data.Nat.Prime #align_import algebra.char_p.exp_char from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Exponential characteristic This file defines the exponential characteristic, which is defined to be 1 for a ring with characteristic 0 and the same as the ordinary characteristic, if the ordinary characteristic is prime. This concept is useful to simplify some theorem statements. This file establishes a few basic results relating it to the (ordinary characteristic). The definition is stated for a semiring, but the actual results are for nontrivial rings (as far as exponential characteristic one is concerned), respectively a ring without zero-divisors (for prime characteristic). ## Main results - `ExpChar`: the definition of exponential characteristic - `expChar_is_prime_or_one`: the exponential characteristic is a prime or one - `char_eq_expChar_iff`: the characteristic equals the exponential characteristic iff the characteristic is prime ## Tags exponential characteristic, characteristic -/ universe u variable (R : Type u) section Semiring variable [Semiring R] /-- The definition of the exponential characteristic of a semiring. -/ class inductive ExpChar (R : Type u) [Semiring R] : ℕ → Prop | zero [CharZero R] : ExpChar R 1 | prime {q : ℕ} (hprime : q.Prime) [hchar : CharP R q] : ExpChar R q #align exp_char ExpChar #align exp_char.prime ExpChar.prime instance expChar_prime (p) [CharP R p] [Fact p.Prime] : ExpChar R p := ExpChar.prime Fact.out instance expChar_zero [CharZero R] : ExpChar R 1 := ExpChar.zero instance (S : Type*) [Semiring S] (p) [ExpChar R p] [ExpChar S p] : ExpChar (R × S) p := by obtain hp | ⟨hp⟩ := ‹ExpChar R p› · have := Prod.charZero_of_left R S; exact .zero obtain _ | _ := ‹ExpChar S p› · exact (Nat.not_prime_one hp).elim · have := Prod.charP R S p; exact .prime hp variable {R} in /-- The exponential characteristic is unique. -/ theorem ExpChar.eq {p q : ℕ} (hp : ExpChar R p) (hq : ExpChar R q) : p = q := by cases' hp with hp _ hp' hp · cases' hq with hq _ hq' hq exacts [rfl, False.elim (Nat.not_prime_zero (CharP.eq R hq (CharP.ofCharZero R) ▸ hq'))] · cases' hq with hq _ hq' hq exacts [False.elim (Nat.not_prime_zero (CharP.eq R hp (CharP.ofCharZero R) ▸ hp')), CharP.eq R hp hq] theorem ExpChar.congr {p : ℕ} (q : ℕ) [hq : ExpChar R q] (h : q = p) : ExpChar R p := h ▸ hq /-- Noncomputable function that outputs the unique exponential characteristic of a semiring. -/ noncomputable def ringExpChar (R : Type*) [NonAssocSemiring R] : ℕ := max (ringChar R) 1
Mathlib/Algebra/CharP/ExpChar.lean
74
79
theorem ringExpChar.eq (q : ℕ) [h : ExpChar R q] : ringExpChar R = q := by
cases' h with _ _ h _ · haveI := CharP.ofCharZero R rw [ringExpChar, ringChar.eq R 0]; rfl rw [ringExpChar, ringChar.eq R q] exact Nat.max_eq_left h.one_lt.le
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker -/ import Mathlib.Algebra.Polynomial.Basic #align_import data.polynomial.monomial from "leanprover-community/mathlib"@"220f71ba506c8958c9b41bd82226b3d06b0991e8" /-! # Univariate monomials Preparatory lemmas for degree_basic. -/ noncomputable section namespace Polynomial open Polynomial universe u variable {R : Type u} {a b : R} {m n : ℕ} variable [Semiring R] {p q r : R[X]} theorem monomial_one_eq_iff [Nontrivial R] {i j : ℕ} : (monomial i 1 : R[X]) = monomial j 1 ↔ i = j := by -- Porting note: `ofFinsupp.injEq` is required. simp_rw [← ofFinsupp_single, ofFinsupp.injEq] exact AddMonoidAlgebra.of_injective.eq_iff #align polynomial.monomial_one_eq_iff Polynomial.monomial_one_eq_iff instance infinite [Nontrivial R] : Infinite R[X] := Infinite.of_injective (fun i => monomial i 1) fun m n h => by simpa [monomial_one_eq_iff] using h #align polynomial.infinite Polynomial.infinite theorem card_support_le_one_iff_monomial {f : R[X]} : Finset.card f.support ≤ 1 ↔ ∃ n a, f = monomial n a := by constructor · intro H rw [Finset.card_le_one_iff_subset_singleton] at H rcases H with ⟨n, hn⟩ refine ⟨n, f.coeff n, ?_⟩ ext i by_cases hi : i = n · simp [hi, coeff_monomial] · have : f.coeff i = 0 := by rw [← not_mem_support_iff] exact fun hi' => hi (Finset.mem_singleton.1 (hn hi')) simp [this, Ne.symm hi, coeff_monomial] · rintro ⟨n, a, rfl⟩ rw [← Finset.card_singleton n] apply Finset.card_le_card exact support_monomial' _ _ #align polynomial.card_support_le_one_iff_monomial Polynomial.card_support_le_one_iff_monomial
Mathlib/Algebra/Polynomial/Monomial.lean
59
80
theorem ringHom_ext {S} [Semiring S] {f g : R[X] →+* S} (h₁ : ∀ a, f (C a) = g (C a)) (h₂ : f X = g X) : f = g := by
set f' := f.comp (toFinsuppIso R).symm.toRingHom with hf' set g' := g.comp (toFinsuppIso R).symm.toRingHom with hg' have A : f' = g' := by -- Porting note: Was `ext; simp [..]; simpa [..] using h₂`. ext : 1 · ext simp [f', g', h₁, RingEquiv.toRingHom_eq_coe] · refine MonoidHom.ext_mnat ?_ simpa [RingEquiv.toRingHom_eq_coe] using h₂ have B : f = f'.comp (toFinsuppIso R) := by rw [hf', RingHom.comp_assoc] ext x simp only [RingEquiv.toRingHom_eq_coe, RingEquiv.symm_apply_apply, Function.comp_apply, RingHom.coe_comp, RingEquiv.coe_toRingHom] have C' : g = g'.comp (toFinsuppIso R) := by rw [hg', RingHom.comp_assoc] ext x simp only [RingEquiv.toRingHom_eq_coe, RingEquiv.symm_apply_apply, Function.comp_apply, RingHom.coe_comp, RingEquiv.coe_toRingHom] rw [B, C', A]
/- Copyright (c) 2023 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure import Mathlib.FieldTheory.Galois /-! # Separably Closed Field In this file we define the typeclass for separably closed fields and separable closures, and prove some of their properties. ## Main Definitions - `IsSepClosed k` is the typeclass saying `k` is a separably closed field, i.e. every separable polynomial in `k` splits. - `IsSepClosure k K` is the typeclass saying `K` is a separable closure of `k`, where `k` is a field. This means that `K` is separably closed and separable over `k`. - `IsSepClosed.lift` is a map from a separable extension `L` of `K`, into any separably closed extension `M` of `K`. - `IsSepClosure.equiv` is a proof that any two separable closures of the same field are isomorphic. - `IsSepClosure.isAlgClosure_of_perfectField`, `IsSepClosure.of_isAlgClosure_of_perfectField`: if `k` is a perfect field, then its separable closure coincides with its algebraic closure. ## Tags separable closure, separably closed ## Related - `separableClosure`: maximal separable subextension of `K/k`, consisting of all elements of `K` which are separable over `k`. - `separableClosure.isSepClosure`: if `K` is a separably closed field containing `k`, then the maximal separable subextension of `K/k` is a separable closure of `k`. - In particular, a separable closure (`SeparableClosure`) exists. - `Algebra.IsAlgebraic.isPurelyInseparable_of_isSepClosed`: an algebraic extension of a separably closed field is purely inseparable. -/ universe u v w open scoped Classical Polynomial open Polynomial variable (k : Type u) [Field k] (K : Type v) [Field K] /-- Typeclass for separably closed fields. To show `Polynomial.Splits p f` for an arbitrary ring homomorphism `f`, see `IsSepClosed.splits_codomain` and `IsSepClosed.splits_domain`. -/ class IsSepClosed : Prop where splits_of_separable : ∀ p : k[X], p.Separable → (p.Splits <| RingHom.id k) /-- An algebraically closed field is also separably closed. -/ instance IsSepClosed.of_isAlgClosed [IsAlgClosed k] : IsSepClosed k := ⟨fun p _ ↦ IsAlgClosed.splits p⟩ variable {k} {K} /-- Every separable polynomial splits in the field extension `f : k →+* K` if `K` is separably closed. See also `IsSepClosed.splits_domain` for the case where `k` is separably closed. -/
Mathlib/FieldTheory/IsSepClosed.lean
78
80
theorem IsSepClosed.splits_codomain [IsSepClosed K] {f : k →+* K} (p : k[X]) (h : p.Separable) : p.Splits f := by
convert IsSepClosed.splits_of_separable (p.map f) (Separable.map h); simp [splits_map_iff]
/- Copyright (c) 2020 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth -/ import Mathlib.Order.Interval.Set.Basic import Mathlib.Data.Set.Function #align_import data.set.intervals.surj_on from "leanprover-community/mathlib"@"a59dad53320b73ef180174aae867addd707ef00e" /-! # Monotone surjective functions are surjective on intervals A monotone surjective function sends any interval in the domain onto the interval with corresponding endpoints in the range. This is expressed in this file using `Set.surjOn`, and provided for all permutations of interval endpoints. -/ variable {α : Type*} {β : Type*} [LinearOrder α] [PartialOrder β] {f : α → β} open Set Function open OrderDual (toDual) theorem surjOn_Ioo_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) (a b : α) : SurjOn f (Ioo a b) (Ioo (f a) (f b)) := by intro p hp rcases h_surj p with ⟨x, rfl⟩ refine ⟨x, mem_Ioo.2 ?_, rfl⟩ contrapose! hp exact fun h => h.2.not_le (h_mono <| hp <| h_mono.reflect_lt h.1) #align surj_on_Ioo_of_monotone_surjective surjOn_Ioo_of_monotone_surjective theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by obtain hab | hab := lt_or_le a b · intro p hp rcases eq_left_or_mem_Ioo_of_mem_Ico hp with (rfl | hp') · exact mem_image_of_mem f (left_mem_Ico.mpr hab) · have := surjOn_Ioo_of_monotone_surjective h_mono h_surj a b hp' exact image_subset f Ioo_subset_Ico_self this · rw [Ico_eq_empty (h_mono hab).not_lt] exact surjOn_empty f _ #align surj_on_Ico_of_monotone_surjective surjOn_Ico_of_monotone_surjective theorem surjOn_Ioc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) (a b : α) : SurjOn f (Ioc a b) (Ioc (f a) (f b)) := by simpa using surjOn_Ico_of_monotone_surjective h_mono.dual h_surj (toDual b) (toDual a) #align surj_on_Ioc_of_monotone_surjective surjOn_Ioc_of_monotone_surjective -- to see that the hypothesis `a ≤ b` is necessary, consider a constant function theorem surjOn_Icc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) {a b : α} (hab : a ≤ b) : SurjOn f (Icc a b) (Icc (f a) (f b)) := by intro p hp rcases eq_endpoints_or_mem_Ioo_of_mem_Icc hp with (rfl | rfl | hp') · exact ⟨a, left_mem_Icc.mpr hab, rfl⟩ · exact ⟨b, right_mem_Icc.mpr hab, rfl⟩ · have := surjOn_Ioo_of_monotone_surjective h_mono h_surj a b hp' exact image_subset f Ioo_subset_Icc_self this #align surj_on_Icc_of_monotone_surjective surjOn_Icc_of_monotone_surjective
Mathlib/Order/Interval/Set/SurjOn.lean
63
67
theorem surjOn_Ioi_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) (a : α) : SurjOn f (Ioi a) (Ioi (f a)) := by
rw [← compl_Iic, ← compl_compl (Ioi (f a))] refine MapsTo.surjOn_compl ?_ h_surj exact fun x hx => (h_mono hx).not_lt
/- Copyright (c) 2021 Eric Rodriguez. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Rodriguez -/ import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots import Mathlib.Tactic.ByContra import Mathlib.Topology.Algebra.Polynomial import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Analysis.Complex.Arg #align_import ring_theory.polynomial.cyclotomic.eval from "leanprover-community/mathlib"@"5bfbcca0a7ffdd21cf1682e59106d6c942434a32" /-! # Evaluating cyclotomic polynomials This file states some results about evaluating cyclotomic polynomials in various different ways. ## Main definitions * `Polynomial.eval(₂)_one_cyclotomic_prime(_pow)`: `eval 1 (cyclotomic p^k R) = p`. * `Polynomial.eval_one_cyclotomic_not_prime_pow`: Otherwise, `eval 1 (cyclotomic n R) = 1`. * `Polynomial.cyclotomic_pos` : `∀ x, 0 < eval x (cyclotomic n R)` if `2 < n`. -/ namespace Polynomial open Finset Nat @[simp] theorem eval_one_cyclotomic_prime {R : Type*} [CommRing R] {p : ℕ} [hn : Fact p.Prime] : eval 1 (cyclotomic p R) = p := by simp only [cyclotomic_prime, eval_X, one_pow, Finset.sum_const, eval_pow, eval_finset_sum, Finset.card_range, smul_one_eq_cast] #align polynomial.eval_one_cyclotomic_prime Polynomial.eval_one_cyclotomic_prime -- @[simp] -- Porting note (#10618): simp already proves this theorem eval₂_one_cyclotomic_prime {R S : Type*} [CommRing R] [Semiring S] (f : R →+* S) {p : ℕ} [Fact p.Prime] : eval₂ f 1 (cyclotomic p R) = p := by simp #align polynomial.eval₂_one_cyclotomic_prime Polynomial.eval₂_one_cyclotomic_prime @[simp] theorem eval_one_cyclotomic_prime_pow {R : Type*} [CommRing R] {p : ℕ} (k : ℕ) [hn : Fact p.Prime] : eval 1 (cyclotomic (p ^ (k + 1)) R) = p := by simp only [cyclotomic_prime_pow_eq_geom_sum hn.out, eval_X, one_pow, Finset.sum_const, eval_pow, eval_finset_sum, Finset.card_range, smul_one_eq_cast] #align polynomial.eval_one_cyclotomic_prime_pow Polynomial.eval_one_cyclotomic_prime_pow -- @[simp] -- Porting note (#10618): simp already proves this
Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean
48
49
theorem eval₂_one_cyclotomic_prime_pow {R S : Type*} [CommRing R] [Semiring S] (f : R →+* S) {p : ℕ} (k : ℕ) [Fact p.Prime] : eval₂ f 1 (cyclotomic (p ^ (k + 1)) R) = p := by
simp
/- Copyright (c) 2024 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.FieldTheory.Minpoly.Field import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.Algebra.Polynomial.Module.AEval /-! # Polynomial modules in finite dimensions This file is a place to collect results about the `R[X]`-module structure induced on an `R`-module by an `R`-linear endomorphism, which require the concept of finite-dimensionality. ## Main results: * `Module.AEval.isTorsion_of_finiteDimensional`: if a vector space `M` with coefficients in a field `K` carries a natural `K`-linear endomorphism which belongs to a finite-dimensional algebra over `K`, then the induced `K[X]`-module structure on `M` is pure torsion. -/ open Polynomial variable {R K M A : Type*} {a : A} namespace Module.AEval
Mathlib/Algebra/Polynomial/Module/FiniteDimensional.lean
29
34
theorem isTorsion_of_aeval_eq_zero [CommSemiring R] [NoZeroDivisors R] [Semiring A] [Algebra R A] [AddCommMonoid M] [Module A M] [Module R M] [IsScalarTower R A M] {p : R[X]} (h : aeval a p = 0) (h' : p ≠ 0) : IsTorsion R[X] (AEval R M a) := by
have hp : p ∈ nonZeroDivisors R[X] := fun q hq ↦ Or.resolve_right (mul_eq_zero.mp hq) h' exact fun x ↦ ⟨⟨p, hp⟩, (of R M a).symm.injective <| by simp [h]⟩
/- Copyright (c) 2018 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Simon Hudon -/ import Mathlib.Data.PFunctor.Multivariate.Basic #align_import data.pfunctor.multivariate.W from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # The W construction as a multivariate polynomial functor. W types are well-founded tree-like structures. They are defined as the least fixpoint of a polynomial functor. ## Main definitions * `W_mk` - constructor * `W_dest - destructor * `W_rec` - recursor: basis for defining functions by structural recursion on `P.W α` * `W_rec_eq` - defining equation for `W_rec` * `W_ind` - induction principle for `P.W α` ## Implementation notes Three views of M-types: * `wp`: polynomial functor * `W`: data type inductively defined by a triple: shape of the root, data in the root and children of the root * `W`: least fixed point of a polynomial functor Specifically, we define the polynomial functor `wp` as: * A := a tree-like structure without information in the nodes * B := given the tree-like structure `t`, `B t` is a valid path (specified inductively by `W_path`) from the root of `t` to any given node. As a result `wp α` is made of a dataless tree and a function from its valid paths to values of `α` ## Reference * Jeremy Avigad, Mario M. Carneiro and Simon Hudon. [*Data Types as Quotients of Polynomial Functors*][avigad-carneiro-hudon2019] -/ universe u v namespace MvPFunctor open TypeVec open MvFunctor variable {n : ℕ} (P : MvPFunctor.{u} (n + 1)) /-- A path from the root of a tree to one of its node -/ inductive WPath : P.last.W → Fin2 n → Type u | root (a : P.A) (f : P.last.B a → P.last.W) (i : Fin2 n) (c : P.drop.B a i) : WPath ⟨a, f⟩ i | child (a : P.A) (f : P.last.B a → P.last.W) (i : Fin2 n) (j : P.last.B a) (c : WPath (f j) i) : WPath ⟨a, f⟩ i set_option linter.uppercaseLean3 false in #align mvpfunctor.W_path MvPFunctor.WPath instance WPath.inhabited (x : P.last.W) {i} [I : Inhabited (P.drop.B x.head i)] : Inhabited (WPath P x i) := ⟨match x, I with | ⟨a, f⟩, I => WPath.root a f i (@default _ I)⟩ set_option linter.uppercaseLean3 false in #align mvpfunctor.W_path.inhabited MvPFunctor.WPath.inhabited /-- Specialized destructor on `WPath` -/ def wPathCasesOn {α : TypeVec n} {a : P.A} {f : P.last.B a → P.last.W} (g' : P.drop.B a ⟹ α) (g : ∀ j : P.last.B a, P.WPath (f j) ⟹ α) : P.WPath ⟨a, f⟩ ⟹ α := by intro i x; match x with | WPath.root _ _ i c => exact g' i c | WPath.child _ _ i j c => exact g j i c set_option linter.uppercaseLean3 false in #align mvpfunctor.W_path_cases_on MvPFunctor.wPathCasesOn /-- Specialized destructor on `WPath` -/ def wPathDestLeft {α : TypeVec n} {a : P.A} {f : P.last.B a → P.last.W} (h : P.WPath ⟨a, f⟩ ⟹ α) : P.drop.B a ⟹ α := fun i c => h i (WPath.root a f i c) set_option linter.uppercaseLean3 false in #align mvpfunctor.W_path_dest_left MvPFunctor.wPathDestLeft /-- Specialized destructor on `WPath` -/ def wPathDestRight {α : TypeVec n} {a : P.A} {f : P.last.B a → P.last.W} (h : P.WPath ⟨a, f⟩ ⟹ α) : ∀ j : P.last.B a, P.WPath (f j) ⟹ α := fun j i c => h i (WPath.child a f i j c) set_option linter.uppercaseLean3 false in #align mvpfunctor.W_path_dest_right MvPFunctor.wPathDestRight theorem wPathDestLeft_wPathCasesOn {α : TypeVec n} {a : P.A} {f : P.last.B a → P.last.W} (g' : P.drop.B a ⟹ α) (g : ∀ j : P.last.B a, P.WPath (f j) ⟹ α) : P.wPathDestLeft (P.wPathCasesOn g' g) = g' := rfl set_option linter.uppercaseLean3 false in #align mvpfunctor.W_path_dest_left_W_path_cases_on MvPFunctor.wPathDestLeft_wPathCasesOn theorem wPathDestRight_wPathCasesOn {α : TypeVec n} {a : P.A} {f : P.last.B a → P.last.W} (g' : P.drop.B a ⟹ α) (g : ∀ j : P.last.B a, P.WPath (f j) ⟹ α) : P.wPathDestRight (P.wPathCasesOn g' g) = g := rfl set_option linter.uppercaseLean3 false in #align mvpfunctor.W_path_dest_right_W_path_cases_on MvPFunctor.wPathDestRight_wPathCasesOn theorem wPathCasesOn_eta {α : TypeVec n} {a : P.A} {f : P.last.B a → P.last.W} (h : P.WPath ⟨a, f⟩ ⟹ α) : P.wPathCasesOn (P.wPathDestLeft h) (P.wPathDestRight h) = h := by ext i x; cases x <;> rfl set_option linter.uppercaseLean3 false in #align mvpfunctor.W_path_cases_on_eta MvPFunctor.wPathCasesOn_eta
Mathlib/Data/PFunctor/Multivariate/W.lean
115
118
theorem comp_wPathCasesOn {α β : TypeVec n} (h : α ⟹ β) {a : P.A} {f : P.last.B a → P.last.W} (g' : P.drop.B a ⟹ α) (g : ∀ j : P.last.B a, P.WPath (f j) ⟹ α) : h ⊚ P.wPathCasesOn g' g = P.wPathCasesOn (h ⊚ g') fun i => h ⊚ g i := by
ext i x; cases x <;> rfl
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Johannes Hölzl -/ import Mathlib.Dynamics.FixedPoints.Basic import Mathlib.Topology.Separation #align_import dynamics.fixed_points.topology from "leanprover-community/mathlib"@"d90e4e186f1d18e375dcd4e5b5f6364b01cb3e46" /-! # Topological properties of fixed points Currently this file contains two lemmas: - `isFixedPt_of_tendsto_iterate`: if `f^n(x) → y` and `f` is continuous at `y`, then `f y = y`; - `isClosed_fixedPoints`: the set of fixed points of a continuous map is a closed set. ## TODO fixed points, iterates -/ variable {α : Type*} [TopologicalSpace α] [T2Space α] {f : α → α} open Function Filter open Topology /-- If the iterates `f^[n] x` converge to `y` and `f` is continuous at `y`, then `y` is a fixed point for `f`. -/
Mathlib/Dynamics/FixedPoints/Topology.lean
33
37
theorem isFixedPt_of_tendsto_iterate {x y : α} (hy : Tendsto (fun n => f^[n] x) atTop (𝓝 y)) (hf : ContinuousAt f y) : IsFixedPt f y := by
refine tendsto_nhds_unique ((tendsto_add_atTop_iff_nat 1).1 ?_) hy simp only [iterate_succ' f] exact hf.tendsto.comp hy
/- Copyright (c) 2019 Gabriel Ebner. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Gabriel Ebner, Sébastien Gouëzel, Yury Kudryashov, Anatole Dedecker -/ import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Add #align_import analysis.calculus.deriv.add from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # One-dimensional derivatives of sums etc In this file we prove formulas about derivatives of `f + g`, `-f`, `f - g`, and `∑ i, f i x` for functions from the base field to a normed space over this field. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative -/ universe u v w open scoped Classical open Topology Filter ENNReal open Filter Asymptotics Set variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {f f₀ f₁ g : 𝕜 → F} variable {f' f₀' f₁' g' : F} variable {x : 𝕜} variable {s t : Set 𝕜} variable {L : Filter 𝕜} section Add /-! ### Derivative of the sum of two functions -/ nonrec theorem HasDerivAtFilter.add (hf : HasDerivAtFilter f f' x L) (hg : HasDerivAtFilter g g' x L) : HasDerivAtFilter (fun y => f y + g y) (f' + g') x L := by simpa using (hf.add hg).hasDerivAtFilter #align has_deriv_at_filter.add HasDerivAtFilter.add nonrec theorem HasStrictDerivAt.add (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x) : HasStrictDerivAt (fun y => f y + g y) (f' + g') x := by simpa using (hf.add hg).hasStrictDerivAt #align has_strict_deriv_at.add HasStrictDerivAt.add nonrec theorem HasDerivWithinAt.add (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x) : HasDerivWithinAt (fun y => f y + g y) (f' + g') s x := hf.add hg #align has_deriv_within_at.add HasDerivWithinAt.add nonrec theorem HasDerivAt.add (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) : HasDerivAt (fun x => f x + g x) (f' + g') x := hf.add hg #align has_deriv_at.add HasDerivAt.add theorem derivWithin_add (hxs : UniqueDiffWithinAt 𝕜 s x) (hf : DifferentiableWithinAt 𝕜 f s x) (hg : DifferentiableWithinAt 𝕜 g s x) : derivWithin (fun y => f y + g y) s x = derivWithin f s x + derivWithin g s x := (hf.hasDerivWithinAt.add hg.hasDerivWithinAt).derivWithin hxs #align deriv_within_add derivWithin_add @[simp] theorem deriv_add (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : deriv (fun y => f y + g y) x = deriv f x + deriv g x := (hf.hasDerivAt.add hg.hasDerivAt).deriv #align deriv_add deriv_add -- Porting note (#10756): new theorem theorem HasStrictDerivAt.add_const (c : F) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun y ↦ f y + c) f' x := add_zero f' ▸ hf.add (hasStrictDerivAt_const x c) theorem HasDerivAtFilter.add_const (hf : HasDerivAtFilter f f' x L) (c : F) : HasDerivAtFilter (fun y => f y + c) f' x L := add_zero f' ▸ hf.add (hasDerivAtFilter_const x L c) #align has_deriv_at_filter.add_const HasDerivAtFilter.add_const nonrec theorem HasDerivWithinAt.add_const (hf : HasDerivWithinAt f f' s x) (c : F) : HasDerivWithinAt (fun y => f y + c) f' s x := hf.add_const c #align has_deriv_within_at.add_const HasDerivWithinAt.add_const nonrec theorem HasDerivAt.add_const (hf : HasDerivAt f f' x) (c : F) : HasDerivAt (fun x => f x + c) f' x := hf.add_const c #align has_deriv_at.add_const HasDerivAt.add_const theorem derivWithin_add_const (hxs : UniqueDiffWithinAt 𝕜 s x) (c : F) : derivWithin (fun y => f y + c) s x = derivWithin f s x := by simp only [derivWithin, fderivWithin_add_const hxs] #align deriv_within_add_const derivWithin_add_const theorem deriv_add_const (c : F) : deriv (fun y => f y + c) x = deriv f x := by simp only [deriv, fderiv_add_const] #align deriv_add_const deriv_add_const @[simp] theorem deriv_add_const' (c : F) : (deriv fun y => f y + c) = deriv f := funext fun _ => deriv_add_const c #align deriv_add_const' deriv_add_const' -- Porting note (#10756): new theorem theorem HasStrictDerivAt.const_add (c : F) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun y ↦ c + f y) f' x := zero_add f' ▸ (hasStrictDerivAt_const x c).add hf theorem HasDerivAtFilter.const_add (c : F) (hf : HasDerivAtFilter f f' x L) : HasDerivAtFilter (fun y => c + f y) f' x L := zero_add f' ▸ (hasDerivAtFilter_const x L c).add hf #align has_deriv_at_filter.const_add HasDerivAtFilter.const_add nonrec theorem HasDerivWithinAt.const_add (c : F) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun y => c + f y) f' s x := hf.const_add c #align has_deriv_within_at.const_add HasDerivWithinAt.const_add nonrec theorem HasDerivAt.const_add (c : F) (hf : HasDerivAt f f' x) : HasDerivAt (fun x => c + f x) f' x := hf.const_add c #align has_deriv_at.const_add HasDerivAt.const_add
Mathlib/Analysis/Calculus/Deriv/Add.lean
131
133
theorem derivWithin_const_add (hxs : UniqueDiffWithinAt 𝕜 s x) (c : F) : derivWithin (fun y => c + f y) s x = derivWithin f s x := by
simp only [derivWithin, fderivWithin_const_add hxs]
/- Copyright (c) 2014 Robert Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Field.Defs import Mathlib.Algebra.GroupWithZero.Units.Lemmas import Mathlib.Algebra.Ring.Commute import Mathlib.Algebra.Ring.Invertible import Mathlib.Order.Synonym #align_import algebra.field.basic from "leanprover-community/mathlib"@"05101c3df9d9cfe9430edc205860c79b6d660102" /-! # Lemmas about division (semi)rings and (semi)fields -/ open Function OrderDual Set universe u variable {α β K : Type*} section DivisionSemiring variable [DivisionSemiring α] {a b c d : α} theorem add_div (a b c : α) : (a + b) / c = a / c + b / c := by simp_rw [div_eq_mul_inv, add_mul] #align add_div add_div @[field_simps] theorem div_add_div_same (a b c : α) : a / c + b / c = (a + b) / c := (add_div _ _ _).symm #align div_add_div_same div_add_div_same theorem same_add_div (h : b ≠ 0) : (b + a) / b = 1 + a / b := by rw [← div_self h, add_div] #align same_add_div same_add_div
Mathlib/Algebra/Field/Basic.lean
40
40
theorem div_add_same (h : b ≠ 0) : (a + b) / b = a / b + 1 := by
rw [← div_self h, add_div]
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Markus Himmel -/ import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Zero #align_import category_theory.limits.shapes.kernels from "leanprover-community/mathlib"@"956af7c76589f444f2e1313911bad16366ea476d" /-! # Kernels and cokernels In a category with zero morphisms, the kernel of a morphism `f : X ⟶ Y` is the equalizer of `f` and `0 : X ⟶ Y`. (Similarly the cokernel is the coequalizer.) The basic definitions are * `kernel : (X ⟶ Y) → C` * `kernel.ι : kernel f ⟶ X` * `kernel.condition : kernel.ι f ≫ f = 0` and * `kernel.lift (k : W ⟶ X) (h : k ≫ f = 0) : W ⟶ kernel f` (as well as the dual versions) ## Main statements Besides the definition and lifts, we prove * `kernel.ιZeroIsIso`: a kernel map of a zero morphism is an isomorphism * `kernel.eq_zero_of_epi_kernel`: if `kernel.ι f` is an epimorphism, then `f = 0` * `kernel.ofMono`: the kernel of a monomorphism is the zero object * `kernel.liftMono`: the lift of a monomorphism `k : W ⟶ X` such that `k ≫ f = 0` is still a monomorphism * `kernel.isLimitConeZeroCone`: if our category has a zero object, then the map from the zero object is a kernel map of any monomorphism * `kernel.ιOfZero`: `kernel.ι (0 : X ⟶ Y)` is an isomorphism and the corresponding dual statements. ## Future work * TODO: connect this with existing work in the group theory and ring theory libraries. ## Implementation notes As with the other special shapes in the limits library, all the definitions here are given as `abbreviation`s of the general statements for limits, so all the `simp` lemmas and theorems about general limits can be used. ## References * [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2] -/ noncomputable section universe v v₂ u u' u₂ open CategoryTheory open CategoryTheory.Limits.WalkingParallelPair namespace CategoryTheory.Limits variable {C : Type u} [Category.{v} C] variable [HasZeroMorphisms C] /-- A morphism `f` has a kernel if the functor `ParallelPair f 0` has a limit. -/ abbrev HasKernel {X Y : C} (f : X ⟶ Y) : Prop := HasLimit (parallelPair f 0) #align category_theory.limits.has_kernel CategoryTheory.Limits.HasKernel /-- A morphism `f` has a cokernel if the functor `ParallelPair f 0` has a colimit. -/ abbrev HasCokernel {X Y : C} (f : X ⟶ Y) : Prop := HasColimit (parallelPair f 0) #align category_theory.limits.has_cokernel CategoryTheory.Limits.HasCokernel variable {X Y : C} (f : X ⟶ Y) section /-- A kernel fork is just a fork where the second morphism is a zero morphism. -/ abbrev KernelFork := Fork f 0 #align category_theory.limits.kernel_fork CategoryTheory.Limits.KernelFork variable {f} @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Limits/Shapes/Kernels.lean
86
87
theorem KernelFork.condition (s : KernelFork f) : Fork.ι s ≫ f = 0 := by
erw [Fork.condition, HasZeroMorphisms.comp_zero]
/- 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.Data.PFunctor.Univariate.M #align_import data.qpf.univariate.basic from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7" /-! # Quotients of Polynomial Functors We assume the following: * `P`: a polynomial functor * `W`: its W-type * `M`: its M-type * `F`: a functor We define: * `q`: `QPF` data, representing `F` as a quotient of `P` The main goal is to construct: * `Fix`: the initial algebra with structure map `F Fix → Fix`. * `Cofix`: the final coalgebra with structure map `Cofix → F Cofix` We also show that the composition of qpfs is a qpf, and that the quotient of a qpf is a qpf. The present theory focuses on the univariate case for qpfs ## References * [Jeremy Avigad, Mario M. Carneiro and Simon Hudon, *Data Types as Quotients of Polynomial Functors*][avigad-carneiro-hudon2019] -/ universe u /-- Quotients of polynomial functors. Roughly speaking, saying that `F` is a quotient of a polynomial functor means that for each `α`, elements of `F α` are represented by pairs `⟨a, f⟩`, where `a` is the shape of the object and `f` indexes the relevant elements of `α`, in a suitably natural manner. -/ class QPF (F : Type u → Type u) [Functor F] where P : PFunctor.{u} abs : ∀ {α}, P α → F α repr : ∀ {α}, F α → P α abs_repr : ∀ {α} (x : F α), abs (repr x) = x abs_map : ∀ {α β} (f : α → β) (p : P α), abs (P.map f p) = f <$> abs p #align qpf QPF namespace QPF variable {F : Type u → Type u} [Functor F] [q : QPF F] open Functor (Liftp Liftr) /- Show that every qpf is a lawful functor. Note: every functor has a field, `map_const`, and `lawfulFunctor` has the defining characterization. We can only propagate the assumption. -/
Mathlib/Data/QPF/Univariate/Basic.lean
71
75
theorem id_map {α : Type _} (x : F α) : id <$> x = x := by
rw [← abs_repr x] cases' repr x with a f rw [← abs_map] rfl
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Manuel Candales -/ import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse #align_import geometry.euclidean.angle.unoriented.basic from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Angles between vectors This file defines unoriented angles in real inner product spaces. ## Main definitions * `InnerProductGeometry.angle` is the undirected angle between two vectors. ## TODO Prove the triangle inequality for the angle. -/ assert_not_exists HasFDerivAt assert_not_exists ConformalAt noncomputable section open Real Set open Real open RealInnerProductSpace namespace InnerProductGeometry variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] {x y : V} /-- The undirected angle between two vectors. If either vector is 0, this is π/2. See `Orientation.oangle` for the corresponding oriented angle definition. -/ def angle (x y : V) : ℝ := Real.arccos (⟪x, y⟫ / (‖x‖ * ‖y‖)) #align inner_product_geometry.angle InnerProductGeometry.angle theorem continuousAt_angle {x : V × V} (hx1 : x.1 ≠ 0) (hx2 : x.2 ≠ 0) : ContinuousAt (fun y : V × V => angle y.1 y.2) x := Real.continuous_arccos.continuousAt.comp <| continuous_inner.continuousAt.div ((continuous_norm.comp continuous_fst).mul (continuous_norm.comp continuous_snd)).continuousAt (by simp [hx1, hx2]) #align inner_product_geometry.continuous_at_angle InnerProductGeometry.continuousAt_angle theorem angle_smul_smul {c : ℝ} (hc : c ≠ 0) (x y : V) : angle (c • x) (c • y) = angle x y := by have : c * c ≠ 0 := mul_ne_zero hc hc rw [angle, angle, real_inner_smul_left, inner_smul_right, norm_smul, norm_smul, Real.norm_eq_abs, mul_mul_mul_comm _ ‖x‖, abs_mul_abs_self, ← mul_assoc c c, mul_div_mul_left _ _ this] #align inner_product_geometry.angle_smul_smul InnerProductGeometry.angle_smul_smul @[simp]
Mathlib/Geometry/Euclidean/Angle/Unoriented/Basic.lean
64
67
theorem _root_.LinearIsometry.angle_map {E F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] [InnerProductSpace ℝ E] [InnerProductSpace ℝ F] (f : E →ₗᵢ[ℝ] F) (u v : E) : angle (f u) (f v) = angle u v := by
rw [angle, angle, f.inner_map_map, f.norm_map, f.norm_map]
/- Copyright (c) 2020 Devon Tuma. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Devon Tuma -/ import Mathlib.Probability.ProbabilityMassFunction.Basic #align_import probability.probability_mass_function.monad from "leanprover-community/mathlib"@"4ac69b290818724c159de091daa3acd31da0ee6d" /-! # Monad Operations for Probability Mass Functions This file constructs two operations on `PMF` that give it a monad structure. `pure a` is the distribution where a single value `a` has probability `1`. `bind pa pb : PMF β` is the distribution given by sampling `a : α` from `pa : PMF α`, and then sampling from `pb a : PMF β` to get a final result `b : β`. `bindOnSupport` generalizes `bind` to allow binding to a partial function, so that the second argument only needs to be defined on the support of the first argument. -/ noncomputable section variable {α β γ : Type*} open scoped Classical open NNReal ENNReal open MeasureTheory namespace PMF section Pure /-- The pure `PMF` is the `PMF` where all the mass lies in one point. The value of `pure a` is `1` at `a` and `0` elsewhere. -/ def pure (a : α) : PMF α := ⟨fun a' => if a' = a then 1 else 0, hasSum_ite_eq _ _⟩ #align pmf.pure PMF.pure variable (a a' : α) @[simp] theorem pure_apply : pure a a' = if a' = a then 1 else 0 := rfl #align pmf.pure_apply PMF.pure_apply @[simp] theorem support_pure : (pure a).support = {a} := Set.ext fun a' => by simp [mem_support_iff] #align pmf.support_pure PMF.support_pure theorem mem_support_pure_iff : a' ∈ (pure a).support ↔ a' = a := by simp #align pmf.mem_support_pure_iff PMF.mem_support_pure_iff -- @[simp] -- Porting note (#10618): simp can prove this theorem pure_apply_self : pure a a = 1 := if_pos rfl #align pmf.pure_apply_self PMF.pure_apply_self theorem pure_apply_of_ne (h : a' ≠ a) : pure a a' = 0 := if_neg h #align pmf.pure_apply_of_ne PMF.pure_apply_of_ne instance [Inhabited α] : Inhabited (PMF α) := ⟨pure default⟩ section Measure variable (s : Set α) @[simp] theorem toOuterMeasure_pure_apply : (pure a).toOuterMeasure s = if a ∈ s then 1 else 0 := by refine (toOuterMeasure_apply (pure a) s).trans ?_ split_ifs with ha · refine (tsum_congr fun b => ?_).trans (tsum_ite_eq a 1) exact ite_eq_left_iff.2 fun hb => symm (ite_eq_right_iff.2 fun h => (hb <| h.symm ▸ ha).elim) · refine (tsum_congr fun b => ?_).trans tsum_zero exact ite_eq_right_iff.2 fun hb => ite_eq_right_iff.2 fun h => (ha <| h ▸ hb).elim #align pmf.to_outer_measure_pure_apply PMF.toOuterMeasure_pure_apply variable [MeasurableSpace α] /-- The measure of a set under `pure a` is `1` for sets containing `a` and `0` otherwise. -/ @[simp] theorem toMeasure_pure_apply (hs : MeasurableSet s) : (pure a).toMeasure s = if a ∈ s then 1 else 0 := (toMeasure_apply_eq_toOuterMeasure_apply (pure a) s hs).trans (toOuterMeasure_pure_apply a s) #align pmf.to_measure_pure_apply PMF.toMeasure_pure_apply theorem toMeasure_pure : (pure a).toMeasure = Measure.dirac a := Measure.ext fun s hs => by rw [toMeasure_pure_apply a s hs, Measure.dirac_apply' a hs]; rfl #align pmf.to_measure_pure PMF.toMeasure_pure @[simp] theorem toPMF_dirac [Countable α] [h : MeasurableSingletonClass α] : (Measure.dirac a).toPMF = pure a := by rw [toPMF_eq_iff_toMeasure_eq, toMeasure_pure] #align pmf.to_pmf_dirac PMF.toPMF_dirac end Measure end Pure section Bind /-- The monadic bind operation for `PMF`. -/ def bind (p : PMF α) (f : α → PMF β) : PMF β := ⟨fun b => ∑' a, p a * f a b, ENNReal.summable.hasSum_iff.2 (ENNReal.tsum_comm.trans <| by simp only [ENNReal.tsum_mul_left, tsum_coe, mul_one])⟩ #align pmf.bind PMF.bind variable (p : PMF α) (f : α → PMF β) (g : β → PMF γ) @[simp] theorem bind_apply (b : β) : p.bind f b = ∑' a, p a * f a b := rfl #align pmf.bind_apply PMF.bind_apply @[simp] theorem support_bind : (p.bind f).support = ⋃ a ∈ p.support, (f a).support := Set.ext fun b => by simp [mem_support_iff, ENNReal.tsum_eq_zero, not_or] #align pmf.support_bind PMF.support_bind
Mathlib/Probability/ProbabilityMassFunction/Monad.lean
126
128
theorem mem_support_bind_iff (b : β) : b ∈ (p.bind f).support ↔ ∃ a ∈ p.support, b ∈ (f a).support := by
simp only [support_bind, Set.mem_iUnion, Set.mem_setOf_eq, exists_prop]
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.AlgebraicTopology.SplitSimplicialObject import Mathlib.AlgebraicTopology.DoldKan.PInfty #align_import algebraic_topology.dold_kan.functor_gamma from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" /-! # Construction of the inverse functor of the Dold-Kan equivalence In this file, we construct the functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C` which shall be the inverse functor of the Dold-Kan equivalence in the case of abelian categories, and more generally pseudoabelian categories. By definition, when `K` is a chain_complex, `Γ₀.obj K` is a simplicial object which sends `Δ : SimplexCategoryᵒᵖ` to a certain coproduct indexed by the set `Splitting.IndexSet Δ` whose elements consists of epimorphisms `e : Δ.unop ⟶ Δ'.unop` (with `Δ' : SimplexCategoryᵒᵖ`); the summand attached to such an `e` is `K.X Δ'.unop.len`. By construction, `Γ₀.obj K` is a split simplicial object whose splitting is `Γ₀.splitting K`. We also construct `Γ₂ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)` which shall be an equivalence for any additive category `C`. (See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.) -/ noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits SimplexCategory SimplicialObject Opposite CategoryTheory.Idempotents Simplicial DoldKan namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] (K K' : ChainComplex C ℕ) (f : K ⟶ K') {Δ Δ' Δ'' : SimplexCategory} /-- `Isδ₀ i` is a simple condition used to check whether a monomorphism `i` in `SimplexCategory` identifies to the coface map `δ 0`. -/ @[nolint unusedArguments] def Isδ₀ {Δ Δ' : SimplexCategory} (i : Δ' ⟶ Δ) [Mono i] : Prop := Δ.len = Δ'.len + 1 ∧ i.toOrderHom 0 ≠ 0 #align algebraic_topology.dold_kan.is_δ₀ AlgebraicTopology.DoldKan.Isδ₀ namespace Isδ₀ theorem iff {j : ℕ} {i : Fin (j + 2)} : Isδ₀ (SimplexCategory.δ i) ↔ i = 0 := by constructor · rintro ⟨_, h₂⟩ by_contra h exact h₂ (Fin.succAbove_ne_zero_zero h) · rintro rfl exact ⟨rfl, by dsimp; exact Fin.succ_ne_zero (0 : Fin (j + 1))⟩ #align algebraic_topology.dold_kan.is_δ₀.iff AlgebraicTopology.DoldKan.Isδ₀.iff theorem eq_δ₀ {n : ℕ} {i : ([n] : SimplexCategory) ⟶ [n + 1]} [Mono i] (hi : Isδ₀ i) : i = SimplexCategory.δ 0 := by obtain ⟨j, rfl⟩ := SimplexCategory.eq_δ_of_mono i rw [iff] at hi rw [hi] #align algebraic_topology.dold_kan.is_δ₀.eq_δ₀ AlgebraicTopology.DoldKan.Isδ₀.eq_δ₀ end Isδ₀ namespace Γ₀ namespace Obj /-- In the definition of `(Γ₀.obj K).obj Δ` as a direct sum indexed by `A : Splitting.IndexSet Δ`, the summand `summand K Δ A` is `K.X A.1.len`. -/ def summand (Δ : SimplexCategoryᵒᵖ) (A : Splitting.IndexSet Δ) : C := K.X A.1.unop.len #align algebraic_topology.dold_kan.Γ₀.obj.summand AlgebraicTopology.DoldKan.Γ₀.Obj.summand /-- The functor `Γ₀` sends a chain complex `K` to the simplicial object which sends `Δ` to the direct sum of the objects `summand K Δ A` for all `A : Splitting.IndexSet Δ` -/ def obj₂ (K : ChainComplex C ℕ) (Δ : SimplexCategoryᵒᵖ) [HasFiniteCoproducts C] : C := ∐ fun A : Splitting.IndexSet Δ => summand K Δ A #align algebraic_topology.dold_kan.Γ₀.obj.obj₂ AlgebraicTopology.DoldKan.Γ₀.Obj.obj₂ namespace Termwise /-- A monomorphism `i : Δ' ⟶ Δ` induces a morphism `K.X Δ.len ⟶ K.X Δ'.len` which is the identity if `Δ = Δ'`, the differential on the complex `K` if `i = δ 0`, and zero otherwise. -/ def mapMono (K : ChainComplex C ℕ) {Δ' Δ : SimplexCategory} (i : Δ' ⟶ Δ) [Mono i] : K.X Δ.len ⟶ K.X Δ'.len := by by_cases Δ = Δ' · exact eqToHom (by congr) · by_cases Isδ₀ i · exact K.d Δ.len Δ'.len · exact 0 #align algebraic_topology.dold_kan.Γ₀.obj.termwise.map_mono AlgebraicTopology.DoldKan.Γ₀.Obj.Termwise.mapMono variable (Δ)
Mathlib/AlgebraicTopology/DoldKan/FunctorGamma.lean
105
107
theorem mapMono_id : mapMono K (𝟙 Δ) = 𝟙 _ := by
unfold mapMono simp only [eq_self_iff_true, eqToHom_refl, dite_eq_ite, if_true]
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Jujian Zhang -/ import Mathlib.RingTheory.IsTensorProduct import Mathlib.RingTheory.Localization.Module /-! # Localized Module Given a commutative semiring `R`, a multiplicative subset `S ⊆ R` and an `R`-module `M`, we can localize `M` by `S`. This gives us a `Localization S`-module. ## Main definition * `isLocalizedModule_iff_isBaseChange` : A localization of modules corresponds to a base change. -/ variable {R : Type*} [CommSemiring R] (S : Submonoid R) (A : Type*) [CommRing A] [Algebra R A] [IsLocalization S A] {M : Type*} [AddCommMonoid M] [Module R M] [Module A M] [IsScalarTower R A M] {M' : Type*} [AddCommMonoid M'] [Module R M'] [Module A M'] [IsScalarTower R A M'] (f : M →ₗ[R] M') /-- The forward direction of `isLocalizedModule_iff_isBaseChange`. It is also used to prove the other direction. -/ theorem IsLocalizedModule.isBaseChange [IsLocalizedModule S f] : IsBaseChange A f := .of_lift_unique _ fun Q _ _ _ _ g ↦ by obtain ⟨ℓ, rfl, h₂⟩ := IsLocalizedModule.is_universal S f g fun s ↦ by rw [← (Algebra.lsmul R (A := A) R Q).commutes]; exact (IsLocalization.map_units A s).map _ refine ⟨ℓ.extendScalarsOfIsLocalization S A, by simp, fun g'' h ↦ ?_⟩ cases h₂ (LinearMap.restrictScalars R g'') h; rfl /-- The map `(f : M →ₗ[R] M')` is a localization of modules iff the map `(localization S) × M → N, (s, m) ↦ s • f m` is the tensor product (insomuch as it is the universal bilinear map). In particular, there is an isomorphism between `LocalizedModule S M` and `(Localization S) ⊗[R] M` given by `m/s ↦ (1/s) ⊗ₜ m`. -/
Mathlib/RingTheory/Localization/BaseChange.lean
41
49
theorem isLocalizedModule_iff_isBaseChange : IsLocalizedModule S f ↔ IsBaseChange A f := by
refine ⟨fun _ ↦ IsLocalizedModule.isBaseChange S A f, fun h ↦ ?_⟩ have : IsBaseChange A (LocalizedModule.mkLinearMap S M) := IsLocalizedModule.isBaseChange S A _ let e := (this.equiv.symm.trans h.equiv).restrictScalars R convert IsLocalizedModule.of_linearEquiv S (LocalizedModule.mkLinearMap S M) e ext rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.restrictScalars_apply, LinearEquiv.trans_apply, IsBaseChange.equiv_symm_apply, IsBaseChange.equiv_tmul, one_smul]
/- Copyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta, Huỳnh Trần Khanh, Stuart Presnell -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Finset.Sym import Mathlib.Data.Fintype.Sum import Mathlib.Data.Fintype.Prod #align_import data.sym.card from "leanprover-community/mathlib"@"0bd2ea37bcba5769e14866170f251c9bc64e35d7" /-! # Stars and bars In this file, we prove (in `Sym.card_sym_eq_multichoose`) that the function `multichoose n k` defined in `Data/Nat/Choose/Basic` counts the number of multisets of cardinality `k` over an alphabet of cardinality `n`. In conjunction with `Nat.multichoose_eq` proved in `Data/Nat/Choose/Basic`, which shows that `multichoose n k = choose (n + k - 1) k`, this is central to the "stars and bars" technique in combinatorics, 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"). ## Informal statement Many problems in mathematics are of the form of (or can be reduced to) putting `k` indistinguishable objects into `n` distinguishable boxes; for example, the problem of finding natural numbers `x1, ..., xn` whose sum is `k`. This is equivalent to forming a multiset of cardinality `k` from an alphabet of cardinality `n` -- for each box `i ∈ [1, n]` the multiset contains as many copies of `i` as there are items in the `i`th box. The "stars and bars" technique arises from another way of presenting the same problem. Instead of putting `k` items into `n` boxes, we take a row of `k` items (the "stars") and separate them by inserting `n-1` dividers (the "bars"). For example, the pattern `*|||**|*|` exhibits 4 items distributed into 6 boxes -- note that any box, including the first and last, may be empty. Such arrangements of `k` stars and `n-1` bars are in 1-1 correspondence with multisets of size `k` over an alphabet of size `n`, and are counted by `choose (n + k - 1) k`. Note that this problem is one component of Gian-Carlo Rota's "Twelvefold Way" https://en.wikipedia.org/wiki/Twelvefold_way ## Formal statement Here we generalise the alphabet to an arbitrary fintype `α`, and we use `Sym α k` as the type of multisets of size `k` over `α`. Thus the statement that these are counted by `multichoose` is: `Sym.card_sym_eq_multichoose : card (Sym α k) = multichoose (card α) k` while the "stars and bars" technique gives `Sym.card_sym_eq_choose : card (Sym α k) = choose (card α + k - 1) k` ## Tags stars and bars, multichoose -/ open Finset Fintype Function Sum Nat variable {α β : Type*} namespace Sym section Sym variable (α) (n : ℕ) /-- Over `Fin (n + 1)`, the multisets of size `k + 1` containing `0` are equivalent to those of size `k`, as demonstrated by respectively erasing or appending `0`. -/ protected def e1 {n k : ℕ} : { s : Sym (Fin (n + 1)) (k + 1) // ↑0 ∈ s } ≃ Sym (Fin n.succ) k where toFun s := s.1.erase 0 s.2 invFun s := ⟨cons 0 s, mem_cons_self 0 s⟩ left_inv s := by simp right_inv s := by simp set_option linter.uppercaseLean3 false in #align sym.E1 Sym.e1 /-- The multisets of size `k` over `Fin n+2` not containing `0` are equivalent to those of size `k` over `Fin n+1`, as demonstrated by respectively decrementing or incrementing every element of the multiset. -/ protected def e2 {n k : ℕ} : { s : Sym (Fin n.succ.succ) k // ↑0 ∉ s } ≃ Sym (Fin n.succ) k where toFun s := map (Fin.predAbove 0) s.1 invFun s := ⟨map (Fin.succAbove 0) s, (mt mem_map.1) (not_exists.2 fun t => not_and.2 fun _ => Fin.succAbove_ne _ t)⟩ left_inv s := by ext1 simp only [map_map] refine (Sym.map_congr fun v hv ↦ ?_).trans (map_id' _) exact Fin.succAbove_predAbove (ne_of_mem_of_not_mem hv s.2) right_inv s := by simp only [map_map, comp_apply, ← Fin.castSucc_zero, Fin.predAbove_succAbove, map_id'] set_option linter.uppercaseLean3 false in #align sym.E2 Sym.e2 -- Porting note: use eqn compiler instead of `pincerRecursion` to make cases more readable theorem card_sym_fin_eq_multichoose : ∀ n k : ℕ, card (Sym (Fin n) k) = multichoose n k | n, 0 => by simp | 0, k + 1 => by rw [multichoose_zero_succ]; exact card_eq_zero | 1, k + 1 => by simp | n + 2, k + 1 => by rw [multichoose_succ_succ, ← card_sym_fin_eq_multichoose (n + 1) (k + 1), ← card_sym_fin_eq_multichoose (n + 2) k, add_comm (Fintype.card _), ← card_sum] refine Fintype.card_congr (Equiv.symm ?_) apply (Sym.e1.symm.sumCongr Sym.e2.symm).trans apply Equiv.sumCompl #align sym.card_sym_fin_eq_multichoose Sym.card_sym_fin_eq_multichoose /-- For any fintype `α` of cardinality `n`, `card (Sym α k) = multichoose (card α) k`. -/
Mathlib/Data/Sym/Card.lean
110
115
theorem card_sym_eq_multichoose (α : Type*) (k : ℕ) [Fintype α] [Fintype (Sym α k)] : card (Sym α k) = multichoose (card α) k := by
rw [← card_sym_fin_eq_multichoose] -- FIXME: Without the `Fintype` namespace, why does it complain about `Finset.card_congr` being -- deprecated? exact Fintype.card_congr (equivCongr (equivFin α))
/- Copyright (c) 2021 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz -/ import Mathlib.CategoryTheory.Limits.Creates import Mathlib.CategoryTheory.Sites.Sheafification import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts #align_import category_theory.sites.limits from "leanprover-community/mathlib"@"95e83ced9542828815f53a1096a4d373c1b08a77" /-! # Limits and colimits of sheaves ## Limits We prove that the forgetful functor from `Sheaf J D` to presheaves creates limits. If the target category `D` has limits (of a certain shape), this then implies that `Sheaf J D` has limits of the same shape and that the forgetful functor preserves these limits. ## Colimits Given a diagram `F : K ⥤ Sheaf J D` of sheaves, and a colimit cocone on the level of presheaves, we show that the cocone obtained by sheafifying the cocone point is a colimit cocone of sheaves. This allows us to show that `Sheaf J D` has colimits (of a certain shape) as soon as `D` does. -/ namespace CategoryTheory namespace Sheaf open CategoryTheory.Limits open Opposite universe w w' v u z z' u₁ u₂ variable {C : Type u} [Category.{v} C] {J : GrothendieckTopology C} variable {D : Type w} [Category.{w'} D] variable {K : Type z} [Category.{z'} K] section Limits noncomputable section section /-- An auxiliary definition to be used below. Whenever `E` is a cone of shape `K` of sheaves, and `S` is the multifork associated to a covering `W` of an object `X`, with respect to the cone point `E.X`, this provides a cone of shape `K` of objects in `D`, with cone point `S.X`. See `isLimitMultiforkOfIsLimit` for more on how this definition is used. -/ def multiforkEvaluationCone (F : K ⥤ Sheaf J D) (E : Cone (F ⋙ sheafToPresheaf J D)) (X : C) (W : J.Cover X) (S : Multifork (W.index E.pt)) : Cone (F ⋙ sheafToPresheaf J D ⋙ (evaluation Cᵒᵖ D).obj (op X)) where pt := S.pt π := { app := fun k => (Presheaf.isLimitOfIsSheaf J (F.obj k).1 W (F.obj k).2).lift <| Multifork.ofι _ S.pt (fun i => S.ι i ≫ (E.π.app k).app (op i.Y)) (by intro i simp only [Category.assoc] erw [← (E.π.app k).naturality, ← (E.π.app k).naturality] dsimp simp only [← Category.assoc] congr 1 apply S.condition) naturality := by intro i j f dsimp [Presheaf.isLimitOfIsSheaf] rw [Category.id_comp] apply Presheaf.IsSheaf.hom_ext (F.obj j).2 W intro ii rw [Presheaf.IsSheaf.amalgamate_map, Category.assoc, ← (F.map f).val.naturality, ← Category.assoc, Presheaf.IsSheaf.amalgamate_map] dsimp [Multifork.ofι] erw [Category.assoc, ← E.w f] aesop_cat } set_option linter.uppercaseLean3 false in #align category_theory.Sheaf.multifork_evaluation_cone CategoryTheory.Sheaf.multiforkEvaluationCone variable [HasLimitsOfShape K D] /-- If `E` is a cone of shape `K` of sheaves, which is a limit on the level of presheaves, this definition shows that the limit presheaf satisfies the multifork variant of the sheaf condition, at a given covering `W`. This is used below in `isSheaf_of_isLimit` to show that the limit presheaf is indeed a sheaf. -/ def isLimitMultiforkOfIsLimit (F : K ⥤ Sheaf J D) (E : Cone (F ⋙ sheafToPresheaf J D)) (hE : IsLimit E) (X : C) (W : J.Cover X) : IsLimit (W.multifork E.pt) := Multifork.IsLimit.mk _ (fun S => (isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).lift <| multiforkEvaluationCone F E X W S) (by intro S i apply (isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op i.Y)) hE).hom_ext intro k dsimp [Multifork.ofι] erw [Category.assoc, (E.π.app k).naturality] dsimp rw [← Category.assoc] erw [(isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).fac (multiforkEvaluationCone F E X W S)] dsimp [multiforkEvaluationCone, Presheaf.isLimitOfIsSheaf] erw [Presheaf.IsSheaf.amalgamate_map] rfl) (by intro S m hm apply (isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).hom_ext intro k dsimp erw [(isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).fac] apply Presheaf.IsSheaf.hom_ext (F.obj k).2 W intro i dsimp only [multiforkEvaluationCone, Presheaf.isLimitOfIsSheaf] rw [(F.obj k).cond.amalgamate_map] dsimp [Multifork.ofι] change _ = S.ι i ≫ _ erw [← hm, Category.assoc, ← (E.π.app k).naturality, Category.assoc] rfl) set_option linter.uppercaseLean3 false in #align category_theory.Sheaf.is_limit_multifork_of_is_limit CategoryTheory.Sheaf.isLimitMultiforkOfIsLimit /-- If `E` is a cone which is a limit on the level of presheaves, then the limit presheaf is again a sheaf. This is used to show that the forgetful functor from sheaves to presheaves creates limits. -/
Mathlib/CategoryTheory/Sites/Limits.lean
138
142
theorem isSheaf_of_isLimit (F : K ⥤ Sheaf J D) (E : Cone (F ⋙ sheafToPresheaf J D)) (hE : IsLimit E) : Presheaf.IsSheaf J E.pt := by
rw [Presheaf.isSheaf_iff_multifork] intro X S exact ⟨isLimitMultiforkOfIsLimit _ _ hE _ _⟩
/- Copyright (c) 2021 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth -/ import Mathlib.Algebra.CharP.Invertible import Mathlib.Analysis.NormedSpace.LinearIsometry import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.Analysis.NormedSpace.Basic import Mathlib.LinearAlgebra.AffineSpace.Restrict import Mathlib.Tactic.FailIfNoProgress #align_import analysis.normed_space.affine_isometry from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Affine isometries In this file we define `AffineIsometry 𝕜 P P₂` to be an affine isometric embedding of normed add-torsors `P` into `P₂` over normed `𝕜`-spaces and `AffineIsometryEquiv` to be an affine isometric equivalence between `P` and `P₂`. We also prove basic lemmas and provide convenience constructors. The choice of these lemmas and constructors is closely modelled on those for the `LinearIsometry` and `AffineMap` theories. Since many elementary properties don't require `‖x‖ = 0 → x = 0` we initially set up the theory for `SeminormedAddCommGroup` and specialize to `NormedAddCommGroup` only when needed. ## Notation We introduce the notation `P →ᵃⁱ[𝕜] P₂` for `AffineIsometry 𝕜 P P₂`, and `P ≃ᵃⁱ[𝕜] P₂` for `AffineIsometryEquiv 𝕜 P P₂`. In contrast with the notation `→ₗᵢ` for linear isometries, `≃ᵢ` for isometric equivalences, etc., the "i" here is a superscript. This is for aesthetic reasons to match the superscript "a" (note that in mathlib `→ᵃ` is an affine map, since `→ₐ` has been taken by algebra-homomorphisms.) -/ open Function Set variable (𝕜 : Type*) {V V₁ V₁' V₂ V₃ V₄ : Type*} {P₁ P₁' : Type*} (P P₂ : Type*) {P₃ P₄ : Type*} [NormedField 𝕜] [SeminormedAddCommGroup V] [NormedSpace 𝕜 V] [PseudoMetricSpace P] [NormedAddTorsor V P] [SeminormedAddCommGroup V₁] [NormedSpace 𝕜 V₁] [PseudoMetricSpace P₁] [NormedAddTorsor V₁ P₁] [SeminormedAddCommGroup V₁'] [NormedSpace 𝕜 V₁'] [MetricSpace P₁'] [NormedAddTorsor V₁' P₁'] [SeminormedAddCommGroup V₂] [NormedSpace 𝕜 V₂] [PseudoMetricSpace P₂] [NormedAddTorsor V₂ P₂] [SeminormedAddCommGroup V₃] [NormedSpace 𝕜 V₃] [PseudoMetricSpace P₃] [NormedAddTorsor V₃ P₃] [SeminormedAddCommGroup V₄] [NormedSpace 𝕜 V₄] [PseudoMetricSpace P₄] [NormedAddTorsor V₄ P₄] /-- A `𝕜`-affine isometric embedding of one normed add-torsor over a normed `𝕜`-space into another. -/ structure AffineIsometry extends P →ᵃ[𝕜] P₂ where norm_map : ∀ x : V, ‖linear x‖ = ‖x‖ #align affine_isometry AffineIsometry variable {𝕜 P P₂} @[inherit_doc] notation:25 -- `→ᵃᵢ` would be more consistent with the linear isometry notation, but it is uglier P " →ᵃⁱ[" 𝕜:25 "] " P₂:0 => AffineIsometry 𝕜 P P₂ namespace AffineIsometry variable (f : P →ᵃⁱ[𝕜] P₂) /-- The underlying linear map of an affine isometry is in fact a linear isometry. -/ protected def linearIsometry : V →ₗᵢ[𝕜] V₂ := { f.linear with norm_map' := f.norm_map } #align affine_isometry.linear_isometry AffineIsometry.linearIsometry @[simp] theorem linear_eq_linearIsometry : f.linear = f.linearIsometry.toLinearMap := by ext rfl #align affine_isometry.linear_eq_linear_isometry AffineIsometry.linear_eq_linearIsometry instance : FunLike (P →ᵃⁱ[𝕜] P₂) P P₂ := { coe := fun f => f.toFun, coe_injective' := fun f g => by cases f; cases g; simp } @[simp] theorem coe_toAffineMap : ⇑f.toAffineMap = f := by rfl #align affine_isometry.coe_to_affine_map AffineIsometry.coe_toAffineMap theorem toAffineMap_injective : Injective (toAffineMap : (P →ᵃⁱ[𝕜] P₂) → P →ᵃ[𝕜] P₂) := by rintro ⟨f, _⟩ ⟨g, _⟩ rfl rfl #align affine_isometry.to_affine_map_injective AffineIsometry.toAffineMap_injective theorem coeFn_injective : @Injective (P →ᵃⁱ[𝕜] P₂) (P → P₂) (↑) := AffineMap.coeFn_injective.comp toAffineMap_injective #align affine_isometry.coe_fn_injective AffineIsometry.coeFn_injective @[ext] theorem ext {f g : P →ᵃⁱ[𝕜] P₂} (h : ∀ x, f x = g x) : f = g := coeFn_injective <| funext h #align affine_isometry.ext AffineIsometry.ext end AffineIsometry namespace LinearIsometry variable (f : V →ₗᵢ[𝕜] V₂) /-- Reinterpret a linear isometry as an affine isometry. -/ def toAffineIsometry : V →ᵃⁱ[𝕜] V₂ := { f.toLinearMap.toAffineMap with norm_map := f.norm_map } #align linear_isometry.to_affine_isometry LinearIsometry.toAffineIsometry @[simp] theorem coe_toAffineIsometry : ⇑(f.toAffineIsometry : V →ᵃⁱ[𝕜] V₂) = f := rfl #align linear_isometry.coe_to_affine_isometry LinearIsometry.coe_toAffineIsometry @[simp]
Mathlib/Analysis/NormedSpace/AffineIsometry.lean
117
119
theorem toAffineIsometry_linearIsometry : f.toAffineIsometry.linearIsometry = f := by
ext rfl
/- Copyright (c) 2021 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Regular.Basic import Mathlib.GroupTheory.GroupAction.Hom #align_import algebra.regular.smul from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11" /-! # Action of regular elements on a module We introduce `M`-regular elements, in the context of an `R`-module `M`. The corresponding predicate is called `IsSMulRegular`. There are very limited typeclass assumptions on `R` and `M`, but the "mathematical" case of interest is a commutative ring `R` acting on a module `M`. Since the properties are "multiplicative", there is no actual requirement of having an addition, but there is a zero in both `R` and `M`. SMultiplications involving `0` are, of course, all trivial. The defining property is that an element `a ∈ R` is `M`-regular if the smultiplication map `M → M`, defined by `m ↦ a • m`, is injective. This property is the direct generalization to modules of the property `IsLeftRegular` defined in `Algebra/Regular`. Lemma `isLeftRegular_iff` shows that indeed the two notions coincide. -/ variable {R S : Type*} (M : Type*) {a b : R} {s : S} /-- An `M`-regular element is an element `c` such that multiplication on the left by `c` is an injective map `M → M`. -/ def IsSMulRegular [SMul R M] (c : R) := Function.Injective ((c • ·) : M → M) #align is_smul_regular IsSMulRegular theorem IsLeftRegular.isSMulRegular [Mul R] {c : R} (h : IsLeftRegular c) : IsSMulRegular R c := h #align is_left_regular.is_smul_regular IsLeftRegular.isSMulRegular /-- Left-regular multiplication on `R` is equivalent to `R`-regularity of `R` itself. -/ theorem isLeftRegular_iff [Mul R] {a : R} : IsLeftRegular a ↔ IsSMulRegular R a := Iff.rfl #align is_left_regular_iff isLeftRegular_iff theorem IsRightRegular.isSMulRegular [Mul R] {c : R} (h : IsRightRegular c) : IsSMulRegular R (MulOpposite.op c) := h #align is_right_regular.is_smul_regular IsRightRegular.isSMulRegular /-- Right-regular multiplication on `R` is equivalent to `Rᵐᵒᵖ`-regularity of `R` itself. -/ theorem isRightRegular_iff [Mul R] {a : R} : IsRightRegular a ↔ IsSMulRegular R (MulOpposite.op a) := Iff.rfl #align is_right_regular_iff isRightRegular_iff namespace IsSMulRegular variable {M} section SMul variable [SMul R M] [SMul R S] [SMul S M] [IsScalarTower R S M] /-- The product of `M`-regular elements is `M`-regular. -/ theorem smul (ra : IsSMulRegular M a) (rs : IsSMulRegular M s) : IsSMulRegular M (a • s) := fun _ _ ab => rs (ra ((smul_assoc _ _ _).symm.trans (ab.trans (smul_assoc _ _ _)))) #align is_smul_regular.smul IsSMulRegular.smul /-- If an element `b` becomes `M`-regular after multiplying it on the left by an `M`-regular element, then `b` is `M`-regular. -/ theorem of_smul (a : R) (ab : IsSMulRegular M (a • s)) : IsSMulRegular M s := @Function.Injective.of_comp _ _ _ (fun m : M => a • m) _ fun c d cd => by dsimp only [Function.comp_def] at cd rw [← smul_assoc, ← smul_assoc] at cd exact ab cd #align is_smul_regular.of_smul IsSMulRegular.of_smul /-- An element is `M`-regular if and only if multiplying it on the left by an `M`-regular element is `M`-regular. -/ @[simp] theorem smul_iff (b : S) (ha : IsSMulRegular M a) : IsSMulRegular M (a • b) ↔ IsSMulRegular M b := ⟨of_smul _, ha.smul⟩ #align is_smul_regular.smul_iff IsSMulRegular.smul_iff theorem isLeftRegular [Mul R] {a : R} (h : IsSMulRegular R a) : IsLeftRegular a := h #align is_smul_regular.is_left_regular IsSMulRegular.isLeftRegular theorem isRightRegular [Mul R] {a : R} (h : IsSMulRegular R (MulOpposite.op a)) : IsRightRegular a := h #align is_smul_regular.is_right_regular IsSMulRegular.isRightRegular theorem mul [Mul R] [IsScalarTower R R M] (ra : IsSMulRegular M a) (rb : IsSMulRegular M b) : IsSMulRegular M (a * b) := ra.smul rb #align is_smul_regular.mul IsSMulRegular.mul theorem of_mul [Mul R] [IsScalarTower R R M] (ab : IsSMulRegular M (a * b)) : IsSMulRegular M b := by rw [← smul_eq_mul] at ab exact ab.of_smul _ #align is_smul_regular.of_mul IsSMulRegular.of_mul @[simp] theorem mul_iff_right [Mul R] [IsScalarTower R R M] (ha : IsSMulRegular M a) : IsSMulRegular M (a * b) ↔ IsSMulRegular M b := ⟨of_mul, ha.mul⟩ #align is_smul_regular.mul_iff_right IsSMulRegular.mul_iff_right /-- Two elements `a` and `b` are `M`-regular if and only if both products `a * b` and `b * a` are `M`-regular. -/
Mathlib/Algebra/Regular/SMul.lean
116
122
theorem mul_and_mul_iff [Mul R] [IsScalarTower R R M] : IsSMulRegular M (a * b) ∧ IsSMulRegular M (b * a) ↔ IsSMulRegular M a ∧ IsSMulRegular M b := by
refine ⟨?_, ?_⟩ · rintro ⟨ab, ba⟩ exact ⟨ba.of_mul, ab.of_mul⟩ · rintro ⟨ha, hb⟩ exact ⟨ha.mul hb, hb.mul ha⟩
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.FieldTheory.SplittingField.Construction import Mathlib.RingTheory.Int.Basic import Mathlib.RingTheory.Localization.Integral import Mathlib.RingTheory.IntegrallyClosed #align_import ring_theory.polynomial.gauss_lemma from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a" /-! # Gauss's Lemma Gauss's Lemma is one of a few results pertaining to irreducibility of primitive polynomials. ## Main Results - `IsIntegrallyClosed.eq_map_mul_C_of_dvd`: if `R` is integrally closed, `K = Frac(R)` and `g : K[X]` divides a monic polynomial with coefficients in `R`, then `g * (C g.leadingCoeff⁻¹)` has coefficients in `R` - `Polynomial.Monic.irreducible_iff_irreducible_map_fraction_map`: A monic polynomial over an integrally closed domain is irreducible iff it is irreducible in a fraction field - `isIntegrallyClosed_iff'`: Integrally closed domains are precisely the domains for in which Gauss's lemma holds for monic polynomials - `Polynomial.IsPrimitive.irreducible_iff_irreducible_map_fraction_map`: A primitive polynomial over a GCD domain is irreducible iff it is irreducible in a fraction field - `Polynomial.IsPrimitive.Int.irreducible_iff_irreducible_map_cast`: A primitive polynomial over `ℤ` is irreducible iff it is irreducible over `ℚ`. - `Polynomial.IsPrimitive.dvd_iff_fraction_map_dvd_fraction_map`: Two primitive polynomials over a GCD domain divide each other iff they do in a fraction field. - `Polynomial.IsPrimitive.Int.dvd_iff_map_cast_dvd_map_cast`: Two primitive polynomials over `ℤ` divide each other if they do in `ℚ`. -/ open scoped nonZeroDivisors Polynomial variable {R : Type*} [CommRing R] section IsIntegrallyClosed open Polynomial open integralClosure open IsIntegrallyClosed variable (K : Type*) [Field K] [Algebra R K] theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic) {g : K[X]} (hg : g.Monic) (hd : g ∣ f.map (algebraMap R K)) : g ∈ lifts (algebraMap (integralClosure R K) K) := by have := mem_lift_of_splits_of_roots_mem_range (integralClosure R g.SplittingField) ((splits_id_iff_splits _).2 <| SplittingField.splits g) (hg.map _) fun a ha => (SetLike.ext_iff.mp (integralClosure R g.SplittingField).range_algebraMap _).mpr <| roots_mem_integralClosure hf ?_ · rw [lifts_iff_coeff_lifts, ← RingHom.coe_range, Subalgebra.range_algebraMap] at this refine (lifts_iff_coeff_lifts _).2 fun n => ?_ rw [← RingHom.coe_range, Subalgebra.range_algebraMap] obtain ⟨p, hp, he⟩ := SetLike.mem_coe.mp (this n); use p, hp rw [IsScalarTower.algebraMap_eq R K, coeff_map, ← eval₂_map, eval₂_at_apply] at he rw [eval₂_eq_eval_map]; apply (injective_iff_map_eq_zero _).1 _ _ he apply RingHom.injective rw [aroots_def, IsScalarTower.algebraMap_eq R K _, ← map_map] refine Multiset.mem_of_le (roots.le_of_dvd ((hf.map _).map _).ne_zero ?_) ha exact map_dvd (algebraMap K g.SplittingField) hd #align integral_closure.mem_lifts_of_monic_of_dvd_map integralClosure.mem_lifts_of_monic_of_dvd_map variable [IsDomain R] [IsFractionRing R K] /-- If `K = Frac(R)` and `g : K[X]` divides a monic polynomial with coefficients in `R`, then `g * (C g.leadingCoeff⁻¹)` has coefficients in `R` -/
Mathlib/RingTheory/Polynomial/GaussLemma.lean
77
102
theorem IsIntegrallyClosed.eq_map_mul_C_of_dvd [IsIntegrallyClosed R] {f : R[X]} (hf : f.Monic) {g : K[X]} (hg : g ∣ f.map (algebraMap R K)) : ∃ g' : R[X], g'.map (algebraMap R K) * (C <| leadingCoeff g) = g := by
have g_ne_0 : g ≠ 0 := ne_zero_of_dvd_ne_zero (Monic.ne_zero <| hf.map (algebraMap R K)) hg suffices lem : ∃ g' : R[X], g'.map (algebraMap R K) = g * C g.leadingCoeff⁻¹ by obtain ⟨g', hg'⟩ := lem use g' rw [hg', mul_assoc, ← C_mul, inv_mul_cancel (leadingCoeff_ne_zero.mpr g_ne_0), C_1, mul_one] have g_mul_dvd : g * C g.leadingCoeff⁻¹ ∣ f.map (algebraMap R K) := by rwa [Associated.dvd_iff_dvd_left (show Associated (g * C g.leadingCoeff⁻¹) g from _)] rw [associated_mul_isUnit_left_iff] exact isUnit_C.mpr (inv_ne_zero <| leadingCoeff_ne_zero.mpr g_ne_0).isUnit let algeq := (Subalgebra.equivOfEq _ _ <| integralClosure_eq_bot R _).trans (Algebra.botEquivOfInjective <| IsFractionRing.injective R <| K) have : (algebraMap R _).comp algeq.toAlgHom.toRingHom = (integralClosure R _).toSubring.subtype := by ext x; (conv_rhs => rw [← algeq.symm_apply_apply x]); rfl have H := (mem_lifts _).1 (integralClosure.mem_lifts_of_monic_of_dvd_map K hf (monic_mul_leadingCoeff_inv g_ne_0) g_mul_dvd) refine ⟨map algeq.toAlgHom.toRingHom ?_, ?_⟩ · use! Classical.choose H · rw [map_map, this] exact Classical.choose_spec H
/- Copyright (c) 2021 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Yaël Dillies -/ import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.MetricSpace.Thickening import Mathlib.Topology.MetricSpace.IsometricSMul #align_import analysis.normed.group.pointwise from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328" /-! # Properties of pointwise addition of sets in normed groups We explore the relationships between pointwise addition of sets in normed groups, and the norm. Notably, we show that the sum of bounded sets remain bounded. -/ open Metric Set Pointwise Topology variable {E : Type*} section SeminormedGroup variable [SeminormedGroup E] {ε δ : ℝ} {s t : Set E} {x y : E} -- note: we can't use `LipschitzOnWith.isBounded_image2` here without adding `[IsometricSMul E E]` @[to_additive] theorem Bornology.IsBounded.mul (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s * t) := by obtain ⟨Rs, hRs⟩ : ∃ R, ∀ x ∈ s, ‖x‖ ≤ R := hs.exists_norm_le' obtain ⟨Rt, hRt⟩ : ∃ R, ∀ x ∈ t, ‖x‖ ≤ R := ht.exists_norm_le' refine isBounded_iff_forall_norm_le'.2 ⟨Rs + Rt, ?_⟩ rintro z ⟨x, hx, y, hy, rfl⟩ exact norm_mul_le_of_le (hRs x hx) (hRt y hy) #align metric.bounded.mul Bornology.IsBounded.mul #align metric.bounded.add Bornology.IsBounded.add @[to_additive] theorem Bornology.IsBounded.of_mul (hst : IsBounded (s * t)) : IsBounded s ∨ IsBounded t := AntilipschitzWith.isBounded_of_image2_left _ (fun x => (isometry_mul_right x).antilipschitz) hst #align metric.bounded.of_mul Bornology.IsBounded.of_mul #align metric.bounded.of_add Bornology.IsBounded.of_add @[to_additive] theorem Bornology.IsBounded.inv : IsBounded s → IsBounded s⁻¹ := by simp_rw [isBounded_iff_forall_norm_le', ← image_inv, forall_mem_image, norm_inv'] exact id #align metric.bounded.inv Bornology.IsBounded.inv #align metric.bounded.neg Bornology.IsBounded.neg @[to_additive] theorem Bornology.IsBounded.div (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s / t) := div_eq_mul_inv s t ▸ hs.mul ht.inv #align metric.bounded.div Bornology.IsBounded.div #align metric.bounded.sub Bornology.IsBounded.sub end SeminormedGroup section SeminormedCommGroup variable [SeminormedCommGroup E] {ε δ : ℝ} {s t : Set E} {x y : E} section EMetric open EMetric @[to_additive (attr := simp)] theorem infEdist_inv_inv (x : E) (s : Set E) : infEdist x⁻¹ s⁻¹ = infEdist x s := by rw [← image_inv, infEdist_image isometry_inv] #align inf_edist_inv_inv infEdist_inv_inv #align inf_edist_neg_neg infEdist_neg_neg @[to_additive] theorem infEdist_inv (x : E) (s : Set E) : infEdist x⁻¹ s = infEdist x s⁻¹ := by rw [← infEdist_inv_inv, inv_inv] #align inf_edist_inv infEdist_inv #align inf_edist_neg infEdist_neg @[to_additive] theorem ediam_mul_le (x y : Set E) : EMetric.diam (x * y) ≤ EMetric.diam x + EMetric.diam y := (LipschitzOnWith.ediam_image2_le (· * ·) _ _ (fun _ _ => (isometry_mul_right _).lipschitz.lipschitzOnWith _) fun _ _ => (isometry_mul_left _).lipschitz.lipschitzOnWith _).trans_eq <| by simp only [ENNReal.coe_one, one_mul] #align ediam_mul_le ediam_mul_le #align ediam_add_le ediam_add_le end EMetric variable (ε δ s t x y) @[to_additive (attr := simp)] theorem inv_thickening : (thickening δ s)⁻¹ = thickening δ s⁻¹ := by simp_rw [thickening, ← infEdist_inv] rfl #align inv_thickening inv_thickening #align neg_thickening neg_thickening @[to_additive (attr := simp)] theorem inv_cthickening : (cthickening δ s)⁻¹ = cthickening δ s⁻¹ := by simp_rw [cthickening, ← infEdist_inv] rfl #align inv_cthickening inv_cthickening #align neg_cthickening neg_cthickening @[to_additive (attr := simp)] theorem inv_ball : (ball x δ)⁻¹ = ball x⁻¹ δ := (IsometryEquiv.inv E).preimage_ball x δ #align inv_ball inv_ball #align neg_ball neg_ball @[to_additive (attr := simp)] theorem inv_closedBall : (closedBall x δ)⁻¹ = closedBall x⁻¹ δ := (IsometryEquiv.inv E).preimage_closedBall x δ #align inv_closed_ball inv_closedBall #align neg_closed_ball neg_closedBall @[to_additive] theorem singleton_mul_ball : {x} * ball y δ = ball (x * y) δ := by simp only [preimage_mul_ball, image_mul_left, singleton_mul, div_inv_eq_mul, mul_comm y x] #align singleton_mul_ball singleton_mul_ball #align singleton_add_ball singleton_add_ball @[to_additive] theorem singleton_div_ball : {x} / ball y δ = ball (x / y) δ := by simp_rw [div_eq_mul_inv, inv_ball, singleton_mul_ball] #align singleton_div_ball singleton_div_ball #align singleton_sub_ball singleton_sub_ball @[to_additive]
Mathlib/Analysis/Normed/Group/Pointwise.lean
131
132
theorem ball_mul_singleton : ball x δ * {y} = ball (x * y) δ := by
rw [mul_comm, singleton_mul_ball, mul_comm y]
/- 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.Polynomial.Eval import Mathlib.RingTheory.Ideal.Quotient #align_import linear_algebra.smodeq from "leanprover-community/mathlib"@"146d3d1fa59c091fedaad8a4afa09d6802886d24" /-! # modular equivalence for submodule -/ open Submodule open Polynomial variable {R : Type*} [Ring R] variable {A : Type*} [CommRing A] variable {M : Type*} [AddCommGroup M] [Module R M] (U U₁ U₂ : Submodule R M) variable {x x₁ x₂ y y₁ y₂ z z₁ z₂ : M} variable {N : Type*} [AddCommGroup N] [Module R N] (V V₁ V₂ : Submodule R N) set_option backward.isDefEq.lazyWhnfCore false in -- See https://github.com/leanprover-community/mathlib4/issues/12534 /-- A predicate saying two elements of a module are equivalent modulo a submodule. -/ def SModEq (x y : M) : Prop := (Submodule.Quotient.mk x : M ⧸ U) = Submodule.Quotient.mk y #align smodeq SModEq notation:50 x " ≡ " y " [SMOD " N "]" => SModEq N x y variable {U U₁ U₂} set_option backward.isDefEq.lazyWhnfCore false in -- See https://github.com/leanprover-community/mathlib4/issues/12534 protected theorem SModEq.def : x ≡ y [SMOD U] ↔ (Submodule.Quotient.mk x : M ⧸ U) = Submodule.Quotient.mk y := Iff.rfl #align smodeq.def SModEq.def namespace SModEq theorem sub_mem : x ≡ y [SMOD U] ↔ x - y ∈ U := by rw [SModEq.def, Submodule.Quotient.eq] #align smodeq.sub_mem SModEq.sub_mem @[simp] theorem top : x ≡ y [SMOD (⊤ : Submodule R M)] := (Submodule.Quotient.eq ⊤).2 mem_top #align smodeq.top SModEq.top @[simp] theorem bot : x ≡ y [SMOD (⊥ : Submodule R M)] ↔ x = y := by rw [SModEq.def, Submodule.Quotient.eq, mem_bot, sub_eq_zero] #align smodeq.bot SModEq.bot @[mono] theorem mono (HU : U₁ ≤ U₂) (hxy : x ≡ y [SMOD U₁]) : x ≡ y [SMOD U₂] := (Submodule.Quotient.eq U₂).2 <| HU <| (Submodule.Quotient.eq U₁).1 hxy #align smodeq.mono SModEq.mono @[refl] protected theorem refl (x : M) : x ≡ x [SMOD U] := @rfl _ _ #align smodeq.refl SModEq.refl protected theorem rfl : x ≡ x [SMOD U] := SModEq.refl _ #align smodeq.rfl SModEq.rfl instance : IsRefl _ (SModEq U) := ⟨SModEq.refl⟩ @[symm] nonrec theorem symm (hxy : x ≡ y [SMOD U]) : y ≡ x [SMOD U] := hxy.symm #align smodeq.symm SModEq.symm @[trans] nonrec theorem trans (hxy : x ≡ y [SMOD U]) (hyz : y ≡ z [SMOD U]) : x ≡ z [SMOD U] := hxy.trans hyz #align smodeq.trans SModEq.trans instance instTrans : Trans (SModEq U) (SModEq U) (SModEq U) where trans := trans theorem add (hxy₁ : x₁ ≡ y₁ [SMOD U]) (hxy₂ : x₂ ≡ y₂ [SMOD U]) : x₁ + x₂ ≡ y₁ + y₂ [SMOD U] := by rw [SModEq.def] at hxy₁ hxy₂ ⊢ simp_rw [Quotient.mk_add, hxy₁, hxy₂] #align smodeq.add SModEq.add theorem smul (hxy : x ≡ y [SMOD U]) (c : R) : c • x ≡ c • y [SMOD U] := by rw [SModEq.def] at hxy ⊢ simp_rw [Quotient.mk_smul, hxy] #align smodeq.smul SModEq.smul
Mathlib/LinearAlgebra/SModEq.lean
97
100
theorem mul {I : Ideal A} {x₁ x₂ y₁ y₂ : A} (hxy₁ : x₁ ≡ y₁ [SMOD I]) (hxy₂ : x₂ ≡ y₂ [SMOD I]) : x₁ * x₂ ≡ y₁ * y₂ [SMOD I] := by
simp only [SModEq.def, Ideal.Quotient.mk_eq_mk, map_mul] at hxy₁ hxy₂ ⊢ rw [hxy₁, hxy₂]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Yury Kudryashov -/ import Mathlib.Data.ENNReal.Inv #align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" /-! # Maps between real and extended non-negative real numbers This file focuses on the functions `ENNReal.toReal : ℝ≥0∞ → ℝ` and `ENNReal.ofReal : ℝ → ℝ≥0∞` which were defined in `Data.ENNReal.Basic`. It collects all the basic results of the interactions between these functions and the algebraic and lattice operations, although a few may appear in earlier files. This file provides a `positivity` extension for `ENNReal.ofReal`. # Main theorems - `trichotomy (p : ℝ≥0∞) : p = 0 ∨ p = ∞ ∨ 0 < p.toReal`: often used for `WithLp` and `lp` - `dichotomy (p : ℝ≥0∞) [Fact (1 ≤ p)] : p = ∞ ∨ 1 ≤ p.toReal`: often used for `WithLp` and `lp` - `toNNReal_iInf` through `toReal_sSup`: these declarations allow for easy conversions between indexed or set infima and suprema in `ℝ`, `ℝ≥0` and `ℝ≥0∞`. This is especially useful because `ℝ≥0∞` is a complete lattice. -/ open Set NNReal ENNReal namespace ENNReal section Real variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}
Mathlib/Data/ENNReal/Real.lean
37
40
theorem toReal_add (ha : a ≠ ∞) (hb : b ≠ ∞) : (a + b).toReal = a.toReal + b.toReal := by
lift a to ℝ≥0 using ha lift b to ℝ≥0 using hb rfl
/- Copyright (c) 2021 Hanting Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Hanting Zhang -/ import Mathlib.Analysis.SpecialFunctions.Integrals #align_import data.real.pi.wallis from "leanprover-community/mathlib"@"980755c33b9168bc82f774f665eaa27878140fac" /-! # The Wallis formula for Pi This file establishes the Wallis product for `π` (`Real.tendsto_prod_pi_div_two`). Our proof is largely about analyzing the behaviour of the sequence `∫ x in 0..π, sin x ^ n` as `n → ∞`. See: https://en.wikipedia.org/wiki/Wallis_product The proof can be broken down into two pieces. The first step (carried out in `Analysis.SpecialFunctions.Integrals`) is to use repeated integration by parts to obtain an explicit formula for this integral, which is rational if `n` is odd and a rational multiple of `π` if `n` is even. The second step, carried out here, is to estimate the ratio `∫ (x : ℝ) in 0..π, sin x ^ (2 * k + 1) / ∫ (x : ℝ) in 0..π, sin x ^ (2 * k)` and prove that it converges to one using the squeeze theorem. The final product for `π` is obtained after some algebraic manipulation. ## Main statements * `Real.Wallis.W`: the product of the first `k` terms in Wallis' formula for `π`. * `Real.Wallis.W_eq_integral_sin_pow_div_integral_sin_pow`: express `W n` as a ratio of integrals. * `Real.Wallis.W_le` and `Real.Wallis.le_W`: upper and lower bounds for `W n`. * `Real.tendsto_prod_pi_div_two`: the Wallis product formula. -/ open scoped Real Topology Nat open Filter Finset intervalIntegral namespace Real namespace Wallis set_option linter.uppercaseLean3 false /-- The product of the first `k` terms in Wallis' formula for `π`. -/ noncomputable def W (k : ℕ) : ℝ := ∏ i ∈ range k, (2 * i + 2) / (2 * i + 1) * ((2 * i + 2) / (2 * i + 3)) #align real.wallis.W Real.Wallis.W theorem W_succ (k : ℕ) : W (k + 1) = W k * ((2 * k + 2) / (2 * k + 1) * ((2 * k + 2) / (2 * k + 3))) := prod_range_succ _ _ #align real.wallis.W_succ Real.Wallis.W_succ theorem W_pos (k : ℕ) : 0 < W k := by induction' k with k hk · unfold W; simp · rw [W_succ] refine mul_pos hk (mul_pos (div_pos ?_ ?_) (div_pos ?_ ?_)) <;> positivity #align real.wallis.W_pos Real.Wallis.W_pos theorem W_eq_factorial_ratio (n : ℕ) : W n = 2 ^ (4 * n) * n ! ^ 4 / ((2 * n)! ^ 2 * (2 * n + 1)) := by induction' n with n IH · simp only [W, prod_range_zero, Nat.factorial_zero, mul_zero, pow_zero, algebraMap.coe_one, one_pow, mul_one, algebraMap.coe_zero, zero_add, div_self, Ne, one_ne_zero, not_false_iff] norm_num · unfold W at IH ⊢ rw [prod_range_succ, IH, _root_.div_mul_div_comm, _root_.div_mul_div_comm] refine (div_eq_div_iff ?_ ?_).mpr ?_ any_goals exact ne_of_gt (by positivity) simp_rw [Nat.mul_succ, Nat.factorial_succ, pow_succ] push_cast ring_nf #align real.wallis.W_eq_factorial_ratio Real.Wallis.W_eq_factorial_ratio theorem W_eq_integral_sin_pow_div_integral_sin_pow (k : ℕ) : (π / 2)⁻¹ * W k = (∫ x : ℝ in (0)..π, sin x ^ (2 * k + 1)) / ∫ x : ℝ in (0)..π, sin x ^ (2 * k) := by rw [integral_sin_pow_even, integral_sin_pow_odd, mul_div_mul_comm, ← prod_div_distrib, inv_div] simp_rw [div_div_div_comm, div_div_eq_mul_div, mul_div_assoc] rfl #align real.wallis.W_eq_integral_sin_pow_div_integral_sin_pow Real.Wallis.W_eq_integral_sin_pow_div_integral_sin_pow theorem W_le (k : ℕ) : W k ≤ π / 2 := by rw [← div_le_one pi_div_two_pos, div_eq_inv_mul] rw [W_eq_integral_sin_pow_div_integral_sin_pow, div_le_one (integral_sin_pow_pos _)] apply integral_sin_pow_succ_le #align real.wallis.W_le Real.Wallis.W_le
Mathlib/Data/Real/Pi/Wallis.lean
91
98
theorem le_W (k : ℕ) : ((2 : ℝ) * k + 1) / (2 * k + 2) * (π / 2) ≤ W k := by
rw [← le_div_iff pi_div_two_pos, div_eq_inv_mul (W k) _] rw [W_eq_integral_sin_pow_div_integral_sin_pow, le_div_iff (integral_sin_pow_pos _)] convert integral_sin_pow_succ_le (2 * k + 1) rw [integral_sin_pow (2 * k)] simp only [sin_zero, ne_eq, add_eq_zero, and_false, not_false_eq_true, zero_pow, cos_zero, mul_one, sin_pi, cos_pi, mul_neg, neg_zero, sub_self, zero_div, zero_add] norm_cast
/- 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] theorem smeval_C : (C r).smeval x = r • x ^ 0 := by simp only [smeval_eq_sum, smul_pow, zero_smul, sum_C_index] @[simp] theorem smeval_monomial (n : ℕ) : (monomial n r).smeval x = r • x ^ n := by simp only [smeval_eq_sum, smul_pow, zero_smul, sum_monomial_index] theorem eval_eq_smeval : p.eval r = p.smeval r := by rw [eval_eq_sum, smeval_eq_sum] rfl theorem eval₂_eq_smeval (R : Type*) [Semiring R] {S : Type*} [Semiring S] (f : R →+* S) (p : R[X]) (x: S) : letI : Module R S := RingHom.toModule f p.eval₂ f x = p.smeval x := by letI : Module R S := RingHom.toModule f rw [smeval_eq_sum, eval₂_eq_sum] rfl variable (R) @[simp] theorem smeval_zero : (0 : R[X]).smeval x = 0 := by simp only [smeval_eq_sum, smul_pow, sum_zero_index] @[simp] theorem smeval_one : (1 : R[X]).smeval x = 1 • x ^ 0 := by rw [← C_1, smeval_C] simp only [Nat.cast_one, one_smul] @[simp] theorem smeval_X : (X : R[X]).smeval x = x ^ 1 := by simp only [smeval_eq_sum, smul_pow, zero_smul, sum_X_index, one_smul] @[simp] theorem smeval_X_pow {n : ℕ} : (X ^ n : R[X]).smeval x = x ^ n := by simp only [smeval_eq_sum, smul_pow, X_pow_eq_monomial, zero_smul, sum_monomial_index, one_smul] end MulActionWithZero section Module variable (R : Type*) [Semiring R] (p q : R[X]) {S : Type*} [AddCommMonoid S] [Pow S ℕ] [Module R S] (x : S) @[simp] theorem smeval_add : (p + q).smeval x = p.smeval x + q.smeval x := by simp only [smeval_eq_sum, smul_pow] refine sum_add_index p q (smul_pow x) (fun _ ↦ ?_) (fun _ _ _ ↦ ?_) · rw [smul_pow, zero_smul] · rw [smul_pow, smul_pow, smul_pow, add_smul] theorem smeval_natCast (n : ℕ) : (n : R[X]).smeval x = n • x ^ 0 := by induction' n with n ih · simp only [smeval_zero, Nat.cast_zero, Nat.zero_eq, zero_smul] · rw [n.cast_succ, smeval_add, ih, smeval_one, ← add_nsmul] @[deprecated (since := "2024-04-17")] alias smeval_nat_cast := smeval_natCast @[simp]
Mathlib/Algebra/Polynomial/Smeval.lean
120
125
theorem smeval_smul (r : R) : (r • p).smeval x = r • p.smeval x := by
induction p using Polynomial.induction_on' with | h_add p q ph qh => rw [smul_add, smeval_add, ph, qh, ← smul_add, smeval_add] | h_monomial n a => rw [smul_monomial, smeval_monomial, smeval_monomial, smul_assoc]
/- Copyright (c) 2023 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.FieldTheory.SeparableDegree import Mathlib.FieldTheory.IsSepClosed /-! # Separable closure This file contains basics about the (relative) separable closure of a field extension. ## Main definitions - `separableClosure`: the relative separable closure of `F` in `E`, or called maximal separable subextension of `E / F`, is defined to be the intermediate field of `E / F` consisting of all separable elements. - `SeparableClosure`: the absolute separable closure, defined to be the relative separable closure inside the algebraic closure. - `Field.sepDegree F E`: the (infinite) separable degree $[E:F]_s$ of an algebraic extension `E / F` of fields, defined to be the degree of `separableClosure F E / F`. Later we will show that (`Field.finSepDegree_eq`, not in this file), if `Field.Emb F E` is finite, then this coincides with `Field.finSepDegree F E`. - `Field.insepDegree F E`: the (infinite) inseparable degree $[E:F]_i$ of an algebraic extension `E / F` of fields, defined to be the degree of `E / separableClosure F E`. - `Field.finInsepDegree F E`: the finite inseparable degree $[E:F]_i$ of an algebraic extension `E / F` of fields, defined to be the degree of `E / separableClosure F E` as a natural number. It is zero if such field extension is not finite. ## Main results - `le_separableClosure_iff`: an intermediate field of `E / F` is contained in the separable closure of `F` in `E` if and only if it is separable over `F`. - `separableClosure.normalClosure_eq_self`: the normal closure of the separable closure of `F` in `E` is equal to itself. - `separableClosure.isGalois`: the separable closure in a normal extension is Galois (namely, normal and separable). - `separableClosure.isSepClosure`: the separable closure in a separably closed extension is a separable closure of the base field. - `IntermediateField.isSeparable_adjoin_iff_separable`: `F(S) / F` is a separable extension if and only if all elements of `S` are separable elements. - `separableClosure.eq_top_iff`: the separable closure of `F` in `E` is equal to `E` if and only if `E / F` is separable. ## Tags separable degree, degree, separable closure -/ open scoped Classical Polynomial open FiniteDimensional Polynomial IntermediateField Field noncomputable section universe u v w variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] variable (K : Type w) [Field K] [Algebra F K] section separableClosure /-- The (relative) separable closure of `F` in `E`, or called maximal separable subextension of `E / F`, is defined to be the intermediate field of `E / F` consisting of all separable elements. The previous results prove that these elements are closed under field operations. -/ def separableClosure : IntermediateField F E where carrier := {x | (minpoly F x).Separable} mul_mem' := separable_mul add_mem' := separable_add algebraMap_mem' := separable_algebraMap E inv_mem' := separable_inv variable {F E K} /-- An element is contained in the separable closure of `F` in `E` if and only if it is a separable element. -/ theorem mem_separableClosure_iff {x : E} : x ∈ separableClosure F E ↔ (minpoly F x).Separable := Iff.rfl /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then `i x` is contained in `separableClosure F K` if and only if `x` is contained in `separableClosure F E`. -/ theorem map_mem_separableClosure_iff (i : E →ₐ[F] K) {x : E} : i x ∈ separableClosure F K ↔ x ∈ separableClosure F E := by simp_rw [mem_separableClosure_iff, minpoly.algHom_eq i i.injective] /-- If `i` is an `F`-algebra homomorphism from `E` to `K`, then the preimage of `separableClosure F K` under the map `i` is equal to `separableClosure F E`. -/
Mathlib/FieldTheory/SeparableClosure.lean
100
103
theorem separableClosure.comap_eq_of_algHom (i : E →ₐ[F] K) : (separableClosure F K).comap i = separableClosure F E := by
ext x exact map_mem_separableClosure_iff i
/- Copyright (c) 2018 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Reid Barton -/ import Mathlib.Data.TypeMax import Mathlib.Logic.UnivLE import Mathlib.CategoryTheory.Limits.Shapes.Images #align_import category_theory.limits.types from "leanprover-community/mathlib"@"4aa2a2e17940311e47007f087c9df229e7f12942" /-! # Limits in the category of types. We show that the category of types has all (co)limits, by providing the usual concrete models. Next, we prove the category of types has categorical images, and that these agree with the range of a function. Finally, we give the natural isomorphism between cones on `F` with cone point `X` and the type `lim Hom(X, F·)`, and similarly the natural isomorphism between cocones on `F` with cocone point `X` and the type `lim Hom(F·, X)`. -/ open CategoryTheory CategoryTheory.Limits universe v u w namespace CategoryTheory.Limits namespace Types section limit_characterization variable {J : Type v} [Category.{w} J] {F : J ⥤ Type u} /-- Given a section of a functor F into `Type*`, construct a cone over F with `PUnit` as the cone point. -/ def coneOfSection {s} (hs : s ∈ F.sections) : Cone F where pt := PUnit π := { app := fun j _ ↦ s j, naturality := fun i j f ↦ by ext; exact (hs f).symm } /-- Given a cone over a functor F into `Type*` and an element in the cone point, construct a section of F. -/ def sectionOfCone (c : Cone F) (x : c.pt) : F.sections := ⟨fun j ↦ c.π.app j x, fun f ↦ congr_fun (c.π.naturality f).symm x⟩ theorem isLimit_iff (c : Cone F) : Nonempty (IsLimit c) ↔ ∀ s ∈ F.sections, ∃! x : c.pt, ∀ j, c.π.app j x = s j := by refine ⟨fun ⟨t⟩ s hs ↦ ?_, fun h ↦ ⟨?_⟩⟩ · let cs := coneOfSection hs exact ⟨t.lift cs ⟨⟩, fun j ↦ congr_fun (t.fac cs j) ⟨⟩, fun x hx ↦ congr_fun (t.uniq cs (fun _ ↦ x) fun j ↦ funext fun _ ↦ hx j) ⟨⟩⟩ · choose x hx using fun c y ↦ h _ (sectionOfCone c y).2 exact ⟨x, fun c j ↦ funext fun y ↦ (hx c y).1 j, fun c f hf ↦ funext fun y ↦ (hx c y).2 (f y) (fun j ↦ congr_fun (hf j) y)⟩
Mathlib/CategoryTheory/Limits/Types.lean
62
65
theorem isLimit_iff_bijective_sectionOfCone (c : Cone F) : Nonempty (IsLimit c) ↔ (Types.sectionOfCone c).Bijective := by
simp_rw [isLimit_iff, Function.bijective_iff_existsUnique, Subtype.forall, F.sections_ext_iff, sectionOfCone]
/- Copyright (c) 2018 Andreas Swerdlow. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andreas Swerdlow, Kexing Ying -/ import Mathlib.LinearAlgebra.BilinearMap import Mathlib.LinearAlgebra.BilinearForm.Basic import Mathlib.LinearAlgebra.Basis import Mathlib.Algebra.Algebra.Bilinear /-! # Bilinear form and linear maps This file describes the relation between bilinear forms and linear maps. ## TODO A lot of this file is now redundant following the replacement of the dedicated `_root_.BilinForm` structure with `LinearMap.BilinForm`, which is just an alias for `M →ₗ[R] M →ₗ[R] R`. For example `LinearMap.BilinForm.toLinHom` is now just the identity map. This redundant code should be removed. ## Notations Given any term `B` of type `BilinForm`, due to a coercion, can use the notation `B x y` to refer to the function field, ie. `B x y = B.bilin x y`. In this file we use the following type variables: - `M`, `M'`, ... are modules over the commutative semiring `R`, - `M₁`, `M₁'`, ... are modules over the commutative ring `R₁`, - `V`, ... is a vector space over the field `K`. ## References * <https://en.wikipedia.org/wiki/Bilinear_form> ## Tags Bilinear form, -/ open LinearMap (BilinForm) universe u v w variable {R : Type*} {M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] variable {R₁ : Type*} {M₁ : Type*} [CommRing R₁] [AddCommGroup M₁] [Module R₁ M₁] variable {V : Type*} {K : Type*} [Field K] [AddCommGroup V] [Module K V] variable {B : BilinForm R M} {B₁ : BilinForm R₁ M₁} namespace LinearMap namespace BilinForm section ToLin' /-- Auxiliary definition to define `toLinHom`; see below. -/ def toLinHomAux₁ (A : BilinForm R M) (x : M) : M →ₗ[R] R := A x #align bilin_form.to_lin_hom_aux₁ LinearMap.BilinForm.toLinHomAux₁ /-- Auxiliary definition to define `toLinHom`; see below. -/ @[deprecated (since := "2024-04-26")] def toLinHomAux₂ (A : BilinForm R M) : M →ₗ[R] M →ₗ[R] R := A #align bilin_form.to_lin_hom_aux₂ LinearMap.BilinForm.toLinHomAux₂ /-- The linear map obtained from a `BilinForm` by fixing the left co-ordinate and evaluating in the right. -/ @[deprecated (since := "2024-04-26")] def toLinHom : BilinForm R M →ₗ[R] M →ₗ[R] M →ₗ[R] R := LinearMap.id #align bilin_form.to_lin_hom LinearMap.BilinForm.toLinHom set_option linter.deprecated false in @[deprecated (since := "2024-04-26")] theorem toLin'_apply (A : BilinForm R M) (x : M) : toLinHom (M := M) A x = A x := rfl #align bilin_form.to_lin'_apply LinearMap.BilinForm.toLin'_apply variable (B) theorem sum_left {α} (t : Finset α) (g : α → M) (w : M) : B (∑ i ∈ t, g i) w = ∑ i ∈ t, B (g i) w := B.map_sum₂ t g w #align bilin_form.sum_left LinearMap.BilinForm.sum_left variable (w : M) theorem sum_right {α} (t : Finset α) (w : M) (g : α → M) : B w (∑ i ∈ t, g i) = ∑ i ∈ t, B w (g i) := map_sum _ _ _ #align bilin_form.sum_right LinearMap.BilinForm.sum_right
Mathlib/LinearAlgebra/BilinearForm/Hom.lean
90
92
theorem sum_apply {α} (t : Finset α) (B : α → BilinForm R M) (v w : M) : (∑ i ∈ t, B i) v w = ∑ i ∈ t, B i v w := by
simp only [coeFn_sum, Finset.sum_apply]
/- 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 -/ import Mathlib.Algebra.Polynomial.Monic #align_import algebra.polynomial.big_operators from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722" /-! # Lemmas for the interaction between polynomials and `∑` and `∏`. Recall that `∑` and `∏` are notation for `Finset.sum` and `Finset.prod` respectively. ## Main results - `Polynomial.natDegree_prod_of_monic` : the degree of a product of monic polynomials is the product of degrees. We prove this only for `[CommSemiring R]`, but it ought to be true for `[Semiring R]` and `List.prod`. - `Polynomial.natDegree_prod` : for polynomials over an integral domain, the degree of the product is the sum of degrees. - `Polynomial.leadingCoeff_prod` : for polynomials over an integral domain, the leading coefficient is the product of leading coefficients. - `Polynomial.prod_X_sub_C_coeff_card_pred` carries most of the content for computing the second coefficient of the characteristic polynomial. -/ open Finset open Multiset open Polynomial universe u w variable {R : Type u} {ι : Type w} namespace Polynomial variable (s : Finset ι) section Semiring variable {S : Type*} [Semiring S] set_option backward.isDefEq.lazyProjDelta false in -- See https://github.com/leanprover-community/mathlib4/issues/12535 theorem natDegree_list_sum_le (l : List S[X]) : natDegree l.sum ≤ (l.map natDegree).foldr max 0 := List.sum_le_foldr_max natDegree (by simp) natDegree_add_le _ #align polynomial.nat_degree_list_sum_le Polynomial.natDegree_list_sum_le theorem natDegree_multiset_sum_le (l : Multiset S[X]) : natDegree l.sum ≤ (l.map natDegree).foldr max max_left_comm 0 := Quotient.inductionOn l (by simpa using natDegree_list_sum_le) #align polynomial.nat_degree_multiset_sum_le Polynomial.natDegree_multiset_sum_le theorem natDegree_sum_le (f : ι → S[X]) : natDegree (∑ i ∈ s, f i) ≤ s.fold max 0 (natDegree ∘ f) := by simpa using natDegree_multiset_sum_le (s.val.map f) #align polynomial.nat_degree_sum_le Polynomial.natDegree_sum_le lemma natDegree_sum_le_of_forall_le {n : ℕ} (f : ι → S[X]) (h : ∀ i ∈ s, natDegree (f i) ≤ n) : natDegree (∑ i ∈ s, f i) ≤ n := le_trans (natDegree_sum_le s f) <| (Finset.fold_max_le n).mpr <| by simpa
Mathlib/Algebra/Polynomial/BigOperators.lean
66
77
theorem degree_list_sum_le (l : List S[X]) : degree l.sum ≤ (l.map natDegree).maximum := by
by_cases h : l.sum = 0 · simp [h] · rw [degree_eq_natDegree h] suffices (l.map natDegree).maximum = ((l.map natDegree).foldr max 0 : ℕ) by rw [this] simpa using natDegree_list_sum_le l rw [← List.foldr_max_of_ne_nil] · congr contrapose! h rw [List.map_eq_nil] at h simp [h]
/- Copyright (c) 2019 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov Some proofs and docs came from `algebra/commute` (c) Neil Strickland -/ import Mathlib.Algebra.Group.Semiconj.Defs import Mathlib.Algebra.Group.Units #align_import algebra.group.semiconj from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64" /-! # Semiconjugate elements of a semigroup ## Main definitions We say that `x` is semiconjugate to `y` by `a` (`SemiconjBy a x y`), if `a * x = y * a`. In this file we provide operations on `SemiconjBy _ _ _`. In the names of these operations, we treat `a` as the “left” argument, and both `x` and `y` as “right” arguments. This way most names in this file agree with the names of the corresponding lemmas for `Commute a b = SemiconjBy a b b`. As a side effect, some lemmas have only `_right` version. Lean does not immediately recognise these terms as equations, so for rewriting we need syntax like `rw [(h.pow_right 5).eq]` rather than just `rw [h.pow_right 5]`. This file provides only basic operations (`mul_left`, `mul_right`, `inv_right` etc). Other operations (`pow_right`, field inverse etc) are in the files that define corresponding notions. -/ assert_not_exists MonoidWithZero assert_not_exists DenselyOrdered open scoped Int variable {M G : Type*} namespace SemiconjBy section Monoid variable [Monoid M] /-- If `a` semiconjugates a unit `x` to a unit `y`, then it semiconjugates `x⁻¹` to `y⁻¹`. -/ @[to_additive "If `a` semiconjugates an additive unit `x` to an additive unit `y`, then it semiconjugates `-x` to `-y`."]
Mathlib/Algebra/Group/Semiconj/Units.lean
48
51
theorem units_inv_right {a : M} {x y : Mˣ} (h : SemiconjBy a x y) : SemiconjBy a ↑x⁻¹ ↑y⁻¹ := calc a * ↑x⁻¹ = ↑y⁻¹ * (y * a) * ↑x⁻¹ := by
rw [Units.inv_mul_cancel_left] _ = ↑y⁻¹ * a := by rw [← h.eq, mul_assoc, Units.mul_inv_cancel_right]
/- Copyright (c) 2019 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Yury Kudryashov -/ import Mathlib.Data.Set.Lattice #align_import data.set.intervals.disjoint from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432" /-! # Extra lemmas about intervals This file contains lemmas about intervals that cannot be included into `Order.Interval.Set.Basic` because this would create an `import` cycle. Namely, lemmas in this file can use definitions from `Data.Set.Lattice`, including `Disjoint`. We consider various intersections and unions of half infinite intervals. -/ universe u v w variable {ι : Sort u} {α : Type v} {β : Type w} open Set open OrderDual (toDual) namespace Set section Preorder variable [Preorder α] {a b c : α} @[simp] theorem Iic_disjoint_Ioi (h : a ≤ b) : Disjoint (Iic a) (Ioi b) := disjoint_left.mpr fun _ ha hb => (h.trans_lt hb).not_le ha #align set.Iic_disjoint_Ioi Set.Iic_disjoint_Ioi @[simp] theorem Iio_disjoint_Ici (h : a ≤ b) : Disjoint (Iio a) (Ici b) := disjoint_left.mpr fun _ ha hb => (h.trans_lt' ha).not_le hb @[simp] theorem Iic_disjoint_Ioc (h : a ≤ b) : Disjoint (Iic a) (Ioc b c) := (Iic_disjoint_Ioi h).mono le_rfl Ioc_subset_Ioi_self #align set.Iic_disjoint_Ioc Set.Iic_disjoint_Ioc @[simp] theorem Ioc_disjoint_Ioc_same : Disjoint (Ioc a b) (Ioc b c) := (Iic_disjoint_Ioc le_rfl).mono Ioc_subset_Iic_self le_rfl #align set.Ioc_disjoint_Ioc_same Set.Ioc_disjoint_Ioc_same @[simp] theorem Ico_disjoint_Ico_same : Disjoint (Ico a b) (Ico b c) := disjoint_left.mpr fun _ hab hbc => hab.2.not_le hbc.1 #align set.Ico_disjoint_Ico_same Set.Ico_disjoint_Ico_same @[simp]
Mathlib/Order/Interval/Set/Disjoint.lean
60
61
theorem Ici_disjoint_Iic : Disjoint (Ici a) (Iic b) ↔ ¬a ≤ b := by
rw [Set.disjoint_iff_inter_eq_empty, Ici_inter_Iic, Icc_eq_empty_iff]
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Patrick Massot -/ import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Data.Set.Function import Mathlib.Order.Interval.Set.Basic #align_import data.set.intervals.monoid from "leanprover-community/mathlib"@"aba57d4d3dae35460225919dcd82fe91355162f9" /-! # Images of intervals under `(+ d)` The lemmas in this file state that addition maps intervals bijectively. The typeclass `ExistsAddOfLE` is defined specifically to make them work when combined with `OrderedCancelAddCommMonoid`; the lemmas below therefore apply to all `OrderedAddCommGroup`, but also to `ℕ` and `ℝ≥0`, which are not groups. -/ namespace Set variable {M : Type*} [OrderedCancelAddCommMonoid M] [ExistsAddOfLE M] (a b c d : M) theorem Ici_add_bij : BijOn (· + d) (Ici a) (Ici (a + d)) := by refine ⟨fun x h => add_le_add_right (mem_Ici.mp h) _, (add_left_injective d).injOn, fun _ h => ?_⟩ obtain ⟨c, rfl⟩ := exists_add_of_le (mem_Ici.mp h) rw [mem_Ici, add_right_comm, add_le_add_iff_right] at h exact ⟨a + c, h, by rw [add_right_comm]⟩ #align set.Ici_add_bij Set.Ici_add_bij theorem Ioi_add_bij : BijOn (· + d) (Ioi a) (Ioi (a + d)) := by refine ⟨fun x h => add_lt_add_right (mem_Ioi.mp h) _, fun _ _ _ _ h => add_right_cancel h, fun _ h => ?_⟩ obtain ⟨c, rfl⟩ := exists_add_of_le (mem_Ioi.mp h).le rw [mem_Ioi, add_right_comm, add_lt_add_iff_right] at h exact ⟨a + c, h, by rw [add_right_comm]⟩ #align set.Ioi_add_bij Set.Ioi_add_bij theorem Icc_add_bij : BijOn (· + d) (Icc a b) (Icc (a + d) (b + d)) := by rw [← Ici_inter_Iic, ← Ici_inter_Iic] exact (Ici_add_bij a d).inter_mapsTo (fun x hx => add_le_add_right hx _) fun x hx => le_of_add_le_add_right hx.2 #align set.Icc_add_bij Set.Icc_add_bij theorem Ioo_add_bij : BijOn (· + d) (Ioo a b) (Ioo (a + d) (b + d)) := by rw [← Ioi_inter_Iio, ← Ioi_inter_Iio] exact (Ioi_add_bij a d).inter_mapsTo (fun x hx => add_lt_add_right hx _) fun x hx => lt_of_add_lt_add_right hx.2 #align set.Ioo_add_bij Set.Ioo_add_bij theorem Ioc_add_bij : BijOn (· + d) (Ioc a b) (Ioc (a + d) (b + d)) := by rw [← Ioi_inter_Iic, ← Ioi_inter_Iic] exact (Ioi_add_bij a d).inter_mapsTo (fun x hx => add_le_add_right hx _) fun x hx => le_of_add_le_add_right hx.2 #align set.Ioc_add_bij Set.Ioc_add_bij
Mathlib/Algebra/Order/Interval/Set/Monoid.lean
65
69
theorem Ico_add_bij : BijOn (· + d) (Ico a b) (Ico (a + d) (b + d)) := by
rw [← Ici_inter_Iio, ← Ici_inter_Iio] exact (Ici_add_bij a d).inter_mapsTo (fun x hx => add_lt_add_right hx _) fun x hx => lt_of_add_lt_add_right hx.2
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel, Rémy Degenne, David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics #align_import analysis.special_functions.pow.continuity from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8" /-! # Continuity of power functions This file contains lemmas about continuity of the power functions on `ℂ`, `ℝ`, `ℝ≥0`, and `ℝ≥0∞`. -/ noncomputable section open scoped Classical open Real Topology NNReal ENNReal Filter ComplexConjugate open Filter Finset Set section CpowLimits /-! ## Continuity for complex powers -/ open Complex variable {α : Type*} theorem zero_cpow_eq_nhds {b : ℂ} (hb : b ≠ 0) : (fun x : ℂ => (0 : ℂ) ^ x) =ᶠ[𝓝 b] 0 := by suffices ∀ᶠ x : ℂ in 𝓝 b, x ≠ 0 from this.mono fun x hx ↦ by dsimp only rw [zero_cpow hx, Pi.zero_apply] exact IsOpen.eventually_mem isOpen_ne hb #align zero_cpow_eq_nhds zero_cpow_eq_nhds theorem cpow_eq_nhds {a b : ℂ} (ha : a ≠ 0) : (fun x => x ^ b) =ᶠ[𝓝 a] fun x => exp (log x * b) := by suffices ∀ᶠ x : ℂ in 𝓝 a, x ≠ 0 from this.mono fun x hx ↦ by dsimp only rw [cpow_def_of_ne_zero hx] exact IsOpen.eventually_mem isOpen_ne ha #align cpow_eq_nhds cpow_eq_nhds theorem cpow_eq_nhds' {p : ℂ × ℂ} (hp_fst : p.fst ≠ 0) : (fun x => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) := by suffices ∀ᶠ x : ℂ × ℂ in 𝓝 p, x.1 ≠ 0 from this.mono fun x hx ↦ by dsimp only rw [cpow_def_of_ne_zero hx] refine IsOpen.eventually_mem ?_ hp_fst change IsOpen { x : ℂ × ℂ | x.1 = 0 }ᶜ rw [isOpen_compl_iff] exact isClosed_eq continuous_fst continuous_const #align cpow_eq_nhds' cpow_eq_nhds' -- Continuity of `fun x => a ^ x`: union of these two lemmas is optimal. theorem continuousAt_const_cpow {a b : ℂ} (ha : a ≠ 0) : ContinuousAt (fun x : ℂ => a ^ x) b := by have cpow_eq : (fun x : ℂ => a ^ x) = fun x => exp (log a * x) := by ext1 b rw [cpow_def_of_ne_zero ha] rw [cpow_eq] exact continuous_exp.continuousAt.comp (ContinuousAt.mul continuousAt_const continuousAt_id) #align continuous_at_const_cpow continuousAt_const_cpow
Mathlib/Analysis/SpecialFunctions/Pow/Continuity.lean
74
78
theorem continuousAt_const_cpow' {a b : ℂ} (h : b ≠ 0) : ContinuousAt (fun x : ℂ => a ^ x) b := by
by_cases ha : a = 0 · rw [ha, continuousAt_congr (zero_cpow_eq_nhds h)] exact continuousAt_const · exact continuousAt_const_cpow ha
/- Copyright (c) 2022 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.MeasureTheory.Integral.Asymptotics import Mathlib.MeasureTheory.Integral.IntervalIntegral import Mathlib.MeasureTheory.Integral.IntegralEqImproper #align_import measure_theory.integral.exp_decay from "leanprover-community/mathlib"@"d4817f8867c368d6c5571f7379b3888aaec1d95a" /-! # Integrals with exponential decay at ∞ As easy special cases of general theorems in the library, we prove the following test for integrability: * `integrable_of_isBigO_exp_neg`: If `f` is continuous on `[a,∞)`, for some `a ∈ ℝ`, and there exists `b > 0` such that `f(x) = O(exp(-b x))` as `x → ∞`, then `f` is integrable on `(a, ∞)`. -/ noncomputable section open Real intervalIntegral MeasureTheory Set Filter open scoped Topology /-- `exp (-b * x)` is integrable on `(a, ∞)`. -/
Mathlib/MeasureTheory/Integral/ExpDecay.lean
30
36
theorem exp_neg_integrableOn_Ioi (a : ℝ) {b : ℝ} (h : 0 < b) : IntegrableOn (fun x : ℝ => exp (-b * x)) (Ioi a) := by
have : Tendsto (fun x => -exp (-b * x) / b) atTop (𝓝 (-0 / b)) := by refine Tendsto.div_const (Tendsto.neg ?_) _ exact tendsto_exp_atBot.comp (tendsto_id.const_mul_atTop_of_neg (neg_neg_iff_pos.2 h)) refine integrableOn_Ioi_deriv_of_nonneg' (fun x _ => ?_) (fun x _ => (exp_pos _).le) this simpa [h.ne'] using ((hasDerivAt_id x).const_mul b).neg.exp.neg.div_const b
/- 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.Calculus.InverseFunctionTheorem.Deriv import Mathlib.Analysis.SpecialFunctions.Complex.Log import Mathlib.Analysis.SpecialFunctions.ExpDeriv #align_import analysis.special_functions.complex.log_deriv from "leanprover-community/mathlib"@"6a5c85000ab93fe5dcfdf620676f614ba8e18c26" /-! # Differentiability of the complex `log` function -/ open Set Filter open scoped Real Topology namespace Complex theorem isOpenMap_exp : IsOpenMap exp := isOpenMap_of_hasStrictDerivAt hasStrictDerivAt_exp exp_ne_zero #align complex.is_open_map_exp Complex.isOpenMap_exp /-- `Complex.exp` as a `PartialHomeomorph` with `source = {z | -π < im z < π}` and `target = {z | 0 < re z} ∪ {z | im z ≠ 0}`. This definition is used to prove that `Complex.log` is complex differentiable at all points but the negative real semi-axis. -/ noncomputable def expPartialHomeomorph : PartialHomeomorph ℂ ℂ := PartialHomeomorph.ofContinuousOpen { toFun := exp invFun := log source := {z : ℂ | z.im ∈ Ioo (-π) π} target := slitPlane map_source' := by rintro ⟨x, y⟩ ⟨h₁ : -π < y, h₂ : y < π⟩ refine (not_or_of_imp fun hz => ?_).symm obtain rfl : y = 0 := by rw [exp_im] at hz simpa [(Real.exp_pos _).ne', Real.sin_eq_zero_iff_of_lt_of_lt h₁ h₂] using hz rw [← ofReal_def, exp_ofReal_re] exact Real.exp_pos x map_target' := fun z h => by simp only [mem_setOf, log_im, mem_Ioo, neg_pi_lt_arg, arg_lt_pi_iff, true_and] exact h.imp_left le_of_lt left_inv' := fun x hx => log_exp hx.1 (le_of_lt hx.2) right_inv' := fun x hx => exp_log <| slitPlane_ne_zero hx } continuous_exp.continuousOn isOpenMap_exp (isOpen_Ioo.preimage continuous_im) #align complex.exp_local_homeomorph Complex.expPartialHomeomorph theorem hasStrictDerivAt_log {x : ℂ} (h : x ∈ slitPlane) : HasStrictDerivAt log x⁻¹ x := have h0 : x ≠ 0 := slitPlane_ne_zero h expPartialHomeomorph.hasStrictDerivAt_symm h h0 <| by simpa [exp_log h0] using hasStrictDerivAt_exp (log x) #align complex.has_strict_deriv_at_log Complex.hasStrictDerivAt_log lemma hasDerivAt_log {z : ℂ} (hz : z ∈ slitPlane) : HasDerivAt log z⁻¹ z := HasStrictDerivAt.hasDerivAt <| hasStrictDerivAt_log hz lemma differentiableAt_log {z : ℂ} (hz : z ∈ slitPlane) : DifferentiableAt ℂ log z := (hasDerivAt_log hz).differentiableAt theorem hasStrictFDerivAt_log_real {x : ℂ} (h : x ∈ slitPlane) : HasStrictFDerivAt log (x⁻¹ • (1 : ℂ →L[ℝ] ℂ)) x := (hasStrictDerivAt_log h).complexToReal_fderiv #align complex.has_strict_fderiv_at_log_real Complex.hasStrictFDerivAt_log_real theorem contDiffAt_log {x : ℂ} (h : x ∈ slitPlane) {n : ℕ∞} : ContDiffAt ℂ n log x := expPartialHomeomorph.contDiffAt_symm_deriv (exp_ne_zero <| log x) h (hasDerivAt_exp _) contDiff_exp.contDiffAt #align complex.cont_diff_at_log Complex.contDiffAt_log end Complex section LogDeriv open Complex Filter open scoped Topology variable {α : Type*} [TopologicalSpace α] {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] theorem HasStrictFDerivAt.clog {f : E → ℂ} {f' : E →L[ℂ] ℂ} {x : E} (h₁ : HasStrictFDerivAt f f' x) (h₂ : f x ∈ slitPlane) : HasStrictFDerivAt (fun t => log (f t)) ((f x)⁻¹ • f') x := (hasStrictDerivAt_log h₂).comp_hasStrictFDerivAt x h₁ #align has_strict_fderiv_at.clog HasStrictFDerivAt.clog theorem HasStrictDerivAt.clog {f : ℂ → ℂ} {f' x : ℂ} (h₁ : HasStrictDerivAt f f' x) (h₂ : f x ∈ slitPlane) : HasStrictDerivAt (fun t => log (f t)) (f' / f x) x := by rw [div_eq_inv_mul]; exact (hasStrictDerivAt_log h₂).comp x h₁ #align has_strict_deriv_at.clog HasStrictDerivAt.clog
Mathlib/Analysis/SpecialFunctions/Complex/LogDeriv.lean
95
97
theorem HasStrictDerivAt.clog_real {f : ℝ → ℂ} {x : ℝ} {f' : ℂ} (h₁ : HasStrictDerivAt f f' x) (h₂ : f x ∈ slitPlane) : HasStrictDerivAt (fun t => log (f t)) (f' / f x) x := by
simpa only [div_eq_inv_mul] using (hasStrictFDerivAt_log_real h₂).comp_hasStrictDerivAt x h₁
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.FieldTheory.SplittingField.IsSplittingField import Mathlib.Algebra.CharP.Algebra #align_import field_theory.splitting_field.construction from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a" /-! # Splitting fields In this file we prove the existence and uniqueness of splitting fields. ## Main definitions * `Polynomial.SplittingField f`: A fixed splitting field of the polynomial `f`. ## Main statements * `Polynomial.IsSplittingField.algEquiv`: Every splitting field of a polynomial `f` is isomorphic to `SplittingField f` and thus, being a splitting field is unique up to isomorphism. ## Implementation details We construct a `SplittingFieldAux` without worrying about whether the instances satisfy nice definitional equalities. Then the actual `SplittingField` is defined to be a quotient of a `MvPolynomial` ring by the kernel of the obvious map into `SplittingFieldAux`. Because the actual `SplittingField` will be a quotient of a `MvPolynomial`, it has nice instances on it. -/ noncomputable section open scoped Classical Polynomial universe u v w variable {F : Type u} {K : Type v} {L : Type w} namespace Polynomial variable [Field K] [Field L] [Field F] open Polynomial section SplittingField /-- Non-computably choose an irreducible factor from a polynomial. -/ def factor (f : K[X]) : K[X] := if H : ∃ g, Irreducible g ∧ g ∣ f then Classical.choose H else X #align polynomial.factor Polynomial.factor theorem irreducible_factor (f : K[X]) : Irreducible (factor f) := by rw [factor] split_ifs with H · exact (Classical.choose_spec H).1 · exact irreducible_X #align polynomial.irreducible_factor Polynomial.irreducible_factor /-- See note [fact non-instances]. -/ theorem fact_irreducible_factor (f : K[X]) : Fact (Irreducible (factor f)) := ⟨irreducible_factor f⟩ #align polynomial.fact_irreducible_factor Polynomial.fact_irreducible_factor attribute [local instance] fact_irreducible_factor
Mathlib/FieldTheory/SplittingField/Construction.lean
69
72
theorem factor_dvd_of_not_isUnit {f : K[X]} (hf1 : ¬IsUnit f) : factor f ∣ f := by
by_cases hf2 : f = 0; · rw [hf2]; exact dvd_zero _ rw [factor, dif_pos (WfDvdMonoid.exists_irreducible_factor hf1 hf2)] exact (Classical.choose_spec <| WfDvdMonoid.exists_irreducible_factor hf1 hf2).2
/- Copyright (c) 2022 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Finsupp.Defs import Mathlib.Data.Finset.Pairwise #align_import data.finsupp.big_operators from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Sums of collections of Finsupp, and their support This file provides results about the `Finsupp.support` of sums of collections of `Finsupp`, including sums of `List`, `Multiset`, and `Finset`. The support of the sum is a subset of the union of the supports: * `List.support_sum_subset` * `Multiset.support_sum_subset` * `Finset.support_sum_subset` The support of the sum of pairwise disjoint finsupps is equal to the union of the supports * `List.support_sum_eq` * `Multiset.support_sum_eq` * `Finset.support_sum_eq` Member in the support of the indexed union over a collection iff it is a member of the support of a member of the collection: * `List.mem_foldr_sup_support_iff` * `Multiset.mem_sup_map_support_iff` * `Finset.mem_sup_support_iff` -/ variable {ι M : Type*} [DecidableEq ι] theorem List.support_sum_subset [AddMonoid M] (l : List (ι →₀ M)) : l.sum.support ⊆ l.foldr (Finsupp.support · ⊔ ·) ∅ := by induction' l with hd tl IH · simp · simp only [List.sum_cons, Finset.union_comm] refine Finsupp.support_add.trans (Finset.union_subset_union ?_ IH) rfl #align list.support_sum_subset List.support_sum_subset theorem Multiset.support_sum_subset [AddCommMonoid M] (s : Multiset (ι →₀ M)) : s.sum.support ⊆ (s.map Finsupp.support).sup := by induction s using Quot.inductionOn simpa only [Multiset.quot_mk_to_coe'', Multiset.sum_coe, Multiset.map_coe, Multiset.sup_coe, List.foldr_map] using List.support_sum_subset _ #align multiset.support_sum_subset Multiset.support_sum_subset theorem Finset.support_sum_subset [AddCommMonoid M] (s : Finset (ι →₀ M)) : (s.sum id).support ⊆ Finset.sup s Finsupp.support := by classical convert Multiset.support_sum_subset s.1; simp #align finset.support_sum_subset Finset.support_sum_subset theorem List.mem_foldr_sup_support_iff [Zero M] {l : List (ι →₀ M)} {x : ι} : x ∈ l.foldr (Finsupp.support · ⊔ ·) ∅ ↔ ∃ f ∈ l, x ∈ f.support := by simp only [Finset.sup_eq_union, List.foldr_map, Finsupp.mem_support_iff, exists_prop] induction' l with hd tl IH · simp · simp only [foldr, Function.comp_apply, Finset.mem_union, Finsupp.mem_support_iff, ne_eq, IH, find?, mem_cons, exists_eq_or_imp] #align list.mem_foldr_sup_support_iff List.mem_foldr_sup_support_iff theorem Multiset.mem_sup_map_support_iff [Zero M] {s : Multiset (ι →₀ M)} {x : ι} : x ∈ (s.map Finsupp.support).sup ↔ ∃ f ∈ s, x ∈ f.support := Quot.inductionOn s fun _ ↦ by simpa only [Multiset.quot_mk_to_coe'', Multiset.map_coe, Multiset.sup_coe, List.foldr_map] using List.mem_foldr_sup_support_iff #align multiset.mem_sup_map_support_iff Multiset.mem_sup_map_support_iff theorem Finset.mem_sup_support_iff [Zero M] {s : Finset (ι →₀ M)} {x : ι} : x ∈ s.sup Finsupp.support ↔ ∃ f ∈ s, x ∈ f.support := Multiset.mem_sup_map_support_iff #align finset.mem_sup_support_iff Finset.mem_sup_support_iff theorem List.support_sum_eq [AddMonoid M] (l : List (ι →₀ M)) (hl : l.Pairwise (_root_.Disjoint on Finsupp.support)) : l.sum.support = l.foldr (Finsupp.support · ⊔ ·) ∅ := by induction' l with hd tl IH · simp · simp only [List.pairwise_cons] at hl simp only [List.sum_cons, List.foldr_cons, Function.comp_apply] rw [Finsupp.support_add_eq, IH hl.right, Finset.sup_eq_union] suffices _root_.Disjoint hd.support (tl.foldr (fun x y ↦ (Finsupp.support x ⊔ y)) ∅) by exact Finset.disjoint_of_subset_right (List.support_sum_subset _) this rw [← List.foldr_map, ← Finset.bot_eq_empty, List.foldr_sup_eq_sup_toFinset, Finset.disjoint_sup_right] intro f hf simp only [List.mem_toFinset, List.mem_map] at hf obtain ⟨f, hf, rfl⟩ := hf exact hl.left _ hf #align list.support_sum_eq List.support_sum_eq
Mathlib/Data/Finsupp/BigOperators.lean
99
111
theorem Multiset.support_sum_eq [AddCommMonoid M] (s : Multiset (ι →₀ M)) (hs : s.Pairwise (_root_.Disjoint on Finsupp.support)) : s.sum.support = (s.map Finsupp.support).sup := by
induction' s using Quot.inductionOn with a obtain ⟨l, hl, hd⟩ := hs suffices a.Pairwise (_root_.Disjoint on Finsupp.support) by convert List.support_sum_eq a this · simp only [Multiset.quot_mk_to_coe'', Multiset.sum_coe] · dsimp only [Function.comp_def] simp only [quot_mk_to_coe'', map_coe, sup_coe, ge_iff_le, Finset.le_eq_subset, Finset.sup_eq_union, Finset.bot_eq_empty, List.foldr_map] simp only [Multiset.quot_mk_to_coe'', Multiset.map_coe, Multiset.coe_eq_coe] at hl exact hl.symm.pairwise hd fun h ↦ _root_.Disjoint.symm h
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Alexander Bentkamp, Anne Baanen -/ import Mathlib.Algebra.BigOperators.Fin import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.Prod import Mathlib.SetTheory.Cardinal.Basic import Mathlib.Tactic.FinCases import Mathlib.Tactic.LinearCombination import Mathlib.Lean.Expr.ExtraRecognizers import Mathlib.Data.Set.Subsingleton #align_import linear_algebra.linear_independent from "leanprover-community/mathlib"@"9d684a893c52e1d6692a504a118bfccbae04feeb" /-! # Linear independence This file defines linear independence in a module or vector space. It is inspired by Isabelle/HOL's linear algebra, and hence indirectly by HOL Light. We define `LinearIndependent R v` as `ker (Finsupp.total ι M R v) = ⊥`. Here `Finsupp.total` is the linear map sending a function `f : ι →₀ R` with finite support to the linear combination of vectors from `v` with these coefficients. Then we prove that several other statements are equivalent to this one, including injectivity of `Finsupp.total ι M R v` and some versions with explicitly written linear combinations. ## Main definitions All definitions are given for families of vectors, i.e. `v : ι → M` where `M` is the module or vector space and `ι : Type*` is an arbitrary indexing type. * `LinearIndependent R v` states that the elements of the family `v` are linearly independent. * `LinearIndependent.repr hv x` returns the linear combination representing `x : span R (range v)` on the linearly independent vectors `v`, given `hv : LinearIndependent R v` (using classical choice). `LinearIndependent.repr hv` is provided as a linear map. ## Main statements We prove several specialized tests for linear independence of families of vectors and of sets of vectors. * `Fintype.linearIndependent_iff`: if `ι` is a finite type, then any function `f : ι → R` has finite support, so we can reformulate the statement using `∑ i : ι, f i • v i` instead of a sum over an auxiliary `s : Finset ι`; * `linearIndependent_empty_type`: a family indexed by an empty type is linearly independent; * `linearIndependent_unique_iff`: if `ι` is a singleton, then `LinearIndependent K v` is equivalent to `v default ≠ 0`; * `linearIndependent_option`, `linearIndependent_sum`, `linearIndependent_fin_cons`, `linearIndependent_fin_succ`: type-specific tests for linear independence of families of vector fields; * `linearIndependent_insert`, `linearIndependent_union`, `linearIndependent_pair`, `linearIndependent_singleton`: linear independence tests for set operations. In many cases we additionally provide dot-style operations (e.g., `LinearIndependent.union`) to make the linear independence tests usable as `hv.insert ha` etc. We also prove that, when working over a division ring, any family of vectors includes a linear independent subfamily spanning the same subspace. ## Implementation notes We use families instead of sets because it allows us to say that two identical vectors are linearly dependent. If you want to use sets, use the family `(fun x ↦ x : s → M)` given a set `s : Set M`. The lemmas `LinearIndependent.to_subtype_range` and `LinearIndependent.of_subtype_range` connect those two worlds. ## Tags linearly dependent, linear dependence, linearly independent, linear independence -/ noncomputable section open Function Set Submodule open Cardinal universe u' u variable {ι : Type u'} {ι' : Type*} {R : Type*} {K : Type*} variable {M : Type*} {M' M'' : Type*} {V : Type u} {V' : Type*} section Module variable {v : ι → M} variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M'] [AddCommMonoid M''] variable [Module R M] [Module R M'] [Module R M''] variable {a b : R} {x y : M} variable (R) (v) /-- `LinearIndependent R v` states the family of vectors `v` is linearly independent over `R`. -/ def LinearIndependent : Prop := LinearMap.ker (Finsupp.total ι M R v) = ⊥ #align linear_independent LinearIndependent open Lean PrettyPrinter.Delaborator SubExpr in /-- Delaborator for `LinearIndependent` that suggests pretty printing with type hints in case the family of vectors is over a `Set`. Type hints look like `LinearIndependent fun (v : ↑s) => ↑v` or `LinearIndependent (ι := ↑s) f`, depending on whether the family is a lambda expression or not. -/ @[delab app.LinearIndependent] def delabLinearIndependent : Delab := whenPPOption getPPNotation <| whenNotPPOption getPPAnalysisSkip <| withOptionAtCurrPos `pp.analysis.skip true do let e ← getExpr guard <| e.isAppOfArity ``LinearIndependent 7 let some _ := (e.getArg! 0).coeTypeSet? | failure let optionsPerPos ← if (e.getArg! 3).isLambda then withNaryArg 3 do return (← read).optionsPerPos.setBool (← getPos) pp.funBinderTypes.name true else withNaryArg 0 do return (← read).optionsPerPos.setBool (← getPos) `pp.analysis.namedArg true withTheReader Context ({· with optionsPerPos}) delab variable {R} {v} theorem linearIndependent_iff : LinearIndependent R v ↔ ∀ l, Finsupp.total ι M R v l = 0 → l = 0 := by simp [LinearIndependent, LinearMap.ker_eq_bot'] #align linear_independent_iff linearIndependent_iff
Mathlib/LinearAlgebra/LinearIndependent.lean
131
151
theorem linearIndependent_iff' : LinearIndependent R v ↔ ∀ s : Finset ι, ∀ g : ι → R, ∑ i ∈ s, g i • v i = 0 → ∀ i ∈ s, g i = 0 := linearIndependent_iff.trans ⟨fun hf s g hg i his => have h := hf (∑ i ∈ s, Finsupp.single i (g i)) <| by simpa only [map_sum, Finsupp.total_single] using hg calc g i = (Finsupp.lapply i : (ι →₀ R) →ₗ[R] R) (Finsupp.single i (g i)) := by
{ rw [Finsupp.lapply_apply, Finsupp.single_eq_same] } _ = ∑ j ∈ s, (Finsupp.lapply i : (ι →₀ R) →ₗ[R] R) (Finsupp.single j (g j)) := Eq.symm <| Finset.sum_eq_single i (fun j _hjs hji => by rw [Finsupp.lapply_apply, Finsupp.single_eq_of_ne hji]) fun hnis => hnis.elim his _ = (∑ j ∈ s, Finsupp.single j (g j)) i := (map_sum ..).symm _ = 0 := DFunLike.ext_iff.1 h i, fun hf l hl => Finsupp.ext fun i => _root_.by_contradiction fun hni => hni <| hf _ _ hl _ <| Finsupp.mem_support_iff.2 hni⟩
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl -/ import Mathlib.Algebra.Order.Group.Abs import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax #align_import algebra.order.group.min_max from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" /-! # `min` and `max` in linearly ordered groups. -/ section variable {α : Type*} [Group α] [LinearOrder α] [CovariantClass α α (· * ·) (· ≤ ·)] -- TODO: This duplicates `oneLePart_div_leOnePart` @[to_additive (attr := simp)] theorem max_one_div_max_inv_one_eq_self (a : α) : max a 1 / max a⁻¹ 1 = a := by rcases le_total a 1 with (h | h) <;> simp [h] #align max_one_div_max_inv_one_eq_self max_one_div_max_inv_one_eq_self #align max_zero_sub_max_neg_zero_eq_self max_zero_sub_max_neg_zero_eq_self alias max_zero_sub_eq_self := max_zero_sub_max_neg_zero_eq_self #align max_zero_sub_eq_self max_zero_sub_eq_self @[to_additive] lemma max_inv_one (a : α) : max a⁻¹ 1 = a⁻¹ * max a 1 := by rw [eq_inv_mul_iff_mul_eq, ← eq_div_iff_mul_eq', max_one_div_max_inv_one_eq_self] end section LinearOrderedCommGroup variable {α : Type*} [LinearOrderedCommGroup α] {a b c : α} @[to_additive min_neg_neg] theorem min_inv_inv' (a b : α) : min a⁻¹ b⁻¹ = (max a b)⁻¹ := Eq.symm <| (@Monotone.map_max α αᵒᵈ _ _ Inv.inv a b) fun _ _ => -- Porting note: Explicit `α` necessary to infer `CovariantClass` instance (@inv_le_inv_iff α _ _ _).mpr #align min_inv_inv' min_inv_inv' #align min_neg_neg min_neg_neg @[to_additive max_neg_neg] theorem max_inv_inv' (a b : α) : max a⁻¹ b⁻¹ = (min a b)⁻¹ := Eq.symm <| (@Monotone.map_min α αᵒᵈ _ _ Inv.inv a b) fun _ _ => -- Porting note: Explicit `α` necessary to infer `CovariantClass` instance (@inv_le_inv_iff α _ _ _).mpr #align max_inv_inv' max_inv_inv' #align max_neg_neg max_neg_neg @[to_additive min_sub_sub_right]
Mathlib/Algebra/Order/Group/MinMax.lean
57
58
theorem min_div_div_right' (a b c : α) : min (a / c) (b / c) = min a b / c := by
simpa only [div_eq_mul_inv] using min_mul_mul_right a b c⁻¹
/- Copyright (c) 2021 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies [`data.finset.sym`@`98e83c3d541c77cdb7da20d79611a780ff8e7d90`..`02ba8949f486ebecf93fe7460f1ed0564b5e442c`](https://leanprover-community.github.io/mathlib-port-status/file/data/finset/sym?range=98e83c3d541c77cdb7da20d79611a780ff8e7d90..02ba8949f486ebecf93fe7460f1ed0564b5e442c) -/ import Mathlib.Data.Finset.Lattice import Mathlib.Data.Fintype.Vector import Mathlib.Data.Multiset.Sym #align_import data.finset.sym from "leanprover-community/mathlib"@"02ba8949f486ebecf93fe7460f1ed0564b5e442c" /-! # Symmetric powers of a finset This file defines the symmetric powers of a finset as `Finset (Sym α n)` and `Finset (Sym2 α)`. ## Main declarations * `Finset.sym`: The symmetric power of a finset. `s.sym n` is all the multisets of cardinality `n` whose elements are in `s`. * `Finset.sym2`: The symmetric square of a finset. `s.sym2` is all the pairs whose elements are in `s`. * A `Fintype (Sym2 α)` instance that does not require `DecidableEq α`. ## TODO `Finset.sym` forms a Galois connection between `Finset α` and `Finset (Sym α n)`. Similar for `Finset.sym2`. -/ namespace Finset variable {α : Type*} /-- `s.sym2` is the finset of all unordered pairs of elements from `s`. It is the image of `s ×ˢ s` under the quotient `α × α → Sym2 α`. -/ @[simps] protected def sym2 (s : Finset α) : Finset (Sym2 α) := ⟨s.1.sym2, s.2.sym2⟩ #align finset.sym2 Finset.sym2 section variable {s t : Finset α} {a b : α} theorem mk_mem_sym2_iff : s(a, b) ∈ s.sym2 ↔ a ∈ s ∧ b ∈ s := by rw [mem_mk, sym2_val, Multiset.mk_mem_sym2_iff, mem_mk, mem_mk] #align finset.mk_mem_sym2_iff Finset.mk_mem_sym2_iff @[simp] theorem mem_sym2_iff {m : Sym2 α} : m ∈ s.sym2 ↔ ∀ a ∈ m, a ∈ s := by rw [mem_mk, sym2_val, Multiset.mem_sym2_iff] simp only [mem_val] #align finset.mem_sym2_iff Finset.mem_sym2_iff instance _root_.Sym2.instFintype [Fintype α] : Fintype (Sym2 α) where elems := Finset.univ.sym2 complete := fun x ↦ by rw [mem_sym2_iff]; exact (fun a _ ↦ mem_univ a) -- Note(kmill): Using a default argument to make this simp lemma more general. @[simp] theorem sym2_univ [Fintype α] (inst : Fintype (Sym2 α) := Sym2.instFintype) : (univ : Finset α).sym2 = univ := by ext simp only [mem_sym2_iff, mem_univ, implies_true] #align finset.sym2_univ Finset.sym2_univ @[simp, mono] theorem sym2_mono (h : s ⊆ t) : s.sym2 ⊆ t.sym2 := by rw [← val_le_iff, sym2_val, sym2_val] apply Multiset.sym2_mono rwa [val_le_iff] #align finset.sym2_mono Finset.sym2_mono theorem monotone_sym2 : Monotone (Finset.sym2 : Finset α → _) := fun _ _ => sym2_mono
Mathlib/Data/Finset/Sym.lean
77
80
theorem injective_sym2 : Function.Injective (Finset.sym2 : Finset α → _) := by
intro s t h ext x simpa using congr(s(x, x) ∈ $h)
/- 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.Lattice #align_import data.fintype.lattice from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" /-! # Lemmas relating fintypes and order/lattice structure. -/ open Function open Nat universe u v variable {ι α β : Type*} namespace Finset variable [Fintype α] {s : Finset α} /-- A special case of `Finset.sup_eq_iSup` that omits the useless `x ∈ univ` binder. -/ theorem sup_univ_eq_iSup [CompleteLattice β] (f : α → β) : Finset.univ.sup f = iSup f := (sup_eq_iSup _ f).trans <| congr_arg _ <| funext fun _ => iSup_pos (mem_univ _) #align finset.sup_univ_eq_supr Finset.sup_univ_eq_iSup /-- A special case of `Finset.inf_eq_iInf` that omits the useless `x ∈ univ` binder. -/ theorem inf_univ_eq_iInf [CompleteLattice β] (f : α → β) : Finset.univ.inf f = iInf f := @sup_univ_eq_iSup _ βᵒᵈ _ _ (f : α → βᵒᵈ) #align finset.inf_univ_eq_infi Finset.inf_univ_eq_iInf @[simp] theorem fold_inf_univ [SemilatticeInf α] [OrderBot α] (a : α) : -- Porting note: added `haveI` haveI : Std.Commutative (α := α) (· ⊓ ·) := inferInstance (Finset.univ.fold (· ⊓ ·) a fun x => x) = ⊥ := eq_bot_iff.2 <| ((Finset.fold_op_rel_iff_and <| @le_inf_iff α _).1 le_rfl).2 ⊥ <| Finset.mem_univ _ #align finset.fold_inf_univ Finset.fold_inf_univ @[simp] theorem fold_sup_univ [SemilatticeSup α] [OrderTop α] (a : α) : -- Porting note: added `haveI` haveI : Std.Commutative (α := α) (· ⊔ ·) := inferInstance (Finset.univ.fold (· ⊔ ·) a fun x => x) = ⊤ := @fold_inf_univ αᵒᵈ _ _ _ _ #align finset.fold_sup_univ Finset.fold_sup_univ lemma mem_inf [DecidableEq α] {s : Finset ι} {f : ι → Finset α} {a : α} : a ∈ s.inf f ↔ ∀ i ∈ s, a ∈ f i := by induction' s using Finset.cons_induction <;> simp [*] end Finset open Finset Function theorem Finite.exists_max [Finite α] [Nonempty α] [LinearOrder β] (f : α → β) : ∃ x₀ : α, ∀ x, f x ≤ f x₀ := by cases nonempty_fintype α simpa using exists_max_image univ f univ_nonempty #align finite.exists_max Finite.exists_max
Mathlib/Data/Fintype/Lattice.lean
68
71
theorem Finite.exists_min [Finite α] [Nonempty α] [LinearOrder β] (f : α → β) : ∃ x₀ : α, ∀ x, f x₀ ≤ f x := by
cases nonempty_fintype α simpa using exists_min_image univ f univ_nonempty
/- 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.List.Basic #align_import data.bool.all_any from "leanprover-community/mathlib"@"5a3e819569b0f12cbec59d740a2613018e7b8eec" /-! # Boolean quantifiers This proves a few properties about `List.all` and `List.any`, which are the `Bool` universal and existential quantifiers. Their definitions are in core Lean. -/ variable {α : Type*} {p : α → Prop} [DecidablePred p] {l : List α} {a : α} namespace List -- Porting note: in Batteries #align list.all_nil List.all_nil #align list.all_cons List.all_consₓ
Mathlib/Data/Bool/AllAny.lean
27
30
theorem all_iff_forall {p : α → Bool} : all l p ↔ ∀ a ∈ l, p a := by
induction' l with a l ih · exact iff_of_true rfl (forall_mem_nil _) simp only [all_cons, Bool.and_eq_true_iff, ih, forall_mem_cons]
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Floris van Doorn -/ import Mathlib.Analysis.Calculus.ContDiff.Defs import Mathlib.Analysis.Calculus.FDeriv.Add import Mathlib.Analysis.Calculus.FDeriv.Mul import Mathlib.Analysis.Calculus.Deriv.Inverse #align_import analysis.calculus.cont_diff from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Higher differentiability of usual operations We prove that the usual operations (addition, multiplication, difference, composition, and so on) preserve `C^n` functions. We also expand the API around `C^n` functions. ## Main results * `ContDiff.comp` states that the composition of two `C^n` functions is `C^n`. Similar results are given for `C^n` functions on domains. ## 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. In this file, we denote `⊤ : ℕ∞` with `∞`. ## Tags derivative, differentiability, higher derivative, `C^n`, multilinear, Taylor series, formal series -/ noncomputable section open scoped Classical NNReal Nat local notation "∞" => (⊤ : ℕ∞) universe u v w uD uE uF uG attribute [local instance 1001] NormedAddCommGroup.toAddCommGroup NormedSpace.toModule' AddCommGroup.toAddCommMonoid open Set Fin Filter Function open scoped Topology variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {D : Type uD} [NormedAddCommGroup D] [NormedSpace 𝕜 D] {E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G] {X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] {s s₁ t u : Set E} {f f₁ : E → F} {g : F → G} {x x₀ : E} {c : F} {b : E × F → G} {m n : ℕ∞} {p : E → FormalMultilinearSeries 𝕜 E F} /-! ### Constants -/ @[simp] theorem iteratedFDerivWithin_zero_fun (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {i : ℕ} : iteratedFDerivWithin 𝕜 i (fun _ : E ↦ (0 : F)) s x = 0 := by induction i generalizing x with | zero => ext; simp | succ i IH => ext m rw [iteratedFDerivWithin_succ_apply_left, fderivWithin_congr (fun _ ↦ IH) (IH hx)] rw [fderivWithin_const_apply _ (hs x hx)] rfl @[simp] theorem iteratedFDeriv_zero_fun {n : ℕ} : (iteratedFDeriv 𝕜 n fun _ : E ↦ (0 : F)) = 0 := funext fun x ↦ by simpa [← iteratedFDerivWithin_univ] using iteratedFDerivWithin_zero_fun uniqueDiffOn_univ (mem_univ x) #align iterated_fderiv_zero_fun iteratedFDeriv_zero_fun theorem contDiff_zero_fun : ContDiff 𝕜 n fun _ : E => (0 : F) := contDiff_of_differentiable_iteratedFDeriv fun m _ => by rw [iteratedFDeriv_zero_fun] exact differentiable_const (0 : E[×m]→L[𝕜] F) #align cont_diff_zero_fun contDiff_zero_fun /-- Constants are `C^∞`. -/ theorem contDiff_const {c : F} : ContDiff 𝕜 n fun _ : E => c := by suffices h : ContDiff 𝕜 ∞ fun _ : E => c from h.of_le le_top rw [contDiff_top_iff_fderiv] refine ⟨differentiable_const c, ?_⟩ rw [fderiv_const] exact contDiff_zero_fun #align cont_diff_const contDiff_const theorem contDiffOn_const {c : F} {s : Set E} : ContDiffOn 𝕜 n (fun _ : E => c) s := contDiff_const.contDiffOn #align cont_diff_on_const contDiffOn_const theorem contDiffAt_const {c : F} : ContDiffAt 𝕜 n (fun _ : E => c) x := contDiff_const.contDiffAt #align cont_diff_at_const contDiffAt_const theorem contDiffWithinAt_const {c : F} : ContDiffWithinAt 𝕜 n (fun _ : E => c) s x := contDiffAt_const.contDiffWithinAt #align cont_diff_within_at_const contDiffWithinAt_const @[nontriviality]
Mathlib/Analysis/Calculus/ContDiff/Basic.lean
107
108
theorem contDiff_of_subsingleton [Subsingleton F] : ContDiff 𝕜 n f := by
rw [Subsingleton.elim f fun _ => 0]; exact contDiff_const
/- Copyright (c) 2020 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.CharP.Invertible import Mathlib.Algebra.Order.Invertible import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.Algebra.Order.Group.Instances import Mathlib.LinearAlgebra.AffineSpace.Slope import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.Tactic.FieldSimp #align_import linear_algebra.affine_space.ordered from "leanprover-community/mathlib"@"78261225eb5cedc61c5c74ecb44e5b385d13b733" /-! # Ordered modules as affine spaces In this file we prove some theorems about `slope` and `lineMap` in the case when the module `E` acting on the codomain `PE` of a function is an ordered module over its domain `k`. We also prove inequalities that can be used to link convexity of a function on an interval to monotonicity of the slope, see section docstring below for details. ## Implementation notes We do not introduce the notion of ordered affine spaces (yet?). Instead, we prove various theorems for an ordered module interpreted as an affine space. ## Tags affine space, ordered module, slope -/ open AffineMap variable {k E PE : Type*} /-! ### Monotonicity of `lineMap` In this section we prove that `lineMap a b r` is monotone (strictly or not) in its arguments if other arguments belong to specific domains. -/ section OrderedRing variable [OrderedRing k] [OrderedAddCommGroup E] [Module k E] [OrderedSMul k E] variable {a a' b b' : E} {r r' : k} theorem lineMap_mono_left (ha : a ≤ a') (hr : r ≤ 1) : lineMap a b r ≤ lineMap a' b r := by simp only [lineMap_apply_module] exact add_le_add_right (smul_le_smul_of_nonneg_left ha (sub_nonneg.2 hr)) _ #align line_map_mono_left lineMap_mono_left theorem lineMap_strict_mono_left (ha : a < a') (hr : r < 1) : lineMap a b r < lineMap a' b r := by simp only [lineMap_apply_module] exact add_lt_add_right (smul_lt_smul_of_pos_left ha (sub_pos.2 hr)) _ #align line_map_strict_mono_left lineMap_strict_mono_left
Mathlib/LinearAlgebra/AffineSpace/Ordered.lean
62
64
theorem lineMap_mono_right (hb : b ≤ b') (hr : 0 ≤ r) : lineMap a b r ≤ lineMap a b' r := by
simp only [lineMap_apply_module] exact add_le_add_left (smul_le_smul_of_nonneg_left hb hr) _
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.MeasureTheory.Measure.Dirac /-! # Counting measure In this file we define the counting measure `MeasurTheory.Measure.count` as `MeasureTheory.Measure.sum MeasureTheory.Measure.dirac` and prove basic properties of this measure. -/ set_option autoImplicit true open Set open scoped ENNReal Classical variable [MeasurableSpace α] [MeasurableSpace β] {s : Set α} noncomputable section namespace MeasureTheory.Measure /-- Counting measure on any measurable space. -/ def count : Measure α := sum dirac #align measure_theory.measure.count MeasureTheory.Measure.count theorem le_count_apply : ∑' _ : s, (1 : ℝ≥0∞) ≤ count s := calc (∑' _ : s, 1 : ℝ≥0∞) = ∑' i, indicator s 1 i := tsum_subtype s 1 _ ≤ ∑' i, dirac i s := ENNReal.tsum_le_tsum fun _ => le_dirac_apply _ ≤ count s := le_sum_apply _ _ #align measure_theory.measure.le_count_apply MeasureTheory.Measure.le_count_apply theorem count_apply (hs : MeasurableSet s) : count s = ∑' i : s, 1 := by simp only [count, sum_apply, hs, dirac_apply', ← tsum_subtype s (1 : α → ℝ≥0∞), Pi.one_apply] #align measure_theory.measure.count_apply MeasureTheory.Measure.count_apply -- @[simp] -- Porting note (#10618): simp can prove this theorem count_empty : count (∅ : Set α) = 0 := by rw [count_apply MeasurableSet.empty, tsum_empty] #align measure_theory.measure.count_empty MeasureTheory.Measure.count_empty @[simp]
Mathlib/MeasureTheory/Measure/Count.lean
48
53
theorem count_apply_finset' {s : Finset α} (s_mble : MeasurableSet (s : Set α)) : count (↑s : Set α) = s.card := calc count (↑s : Set α) = ∑' i : (↑s : Set α), 1 := count_apply s_mble _ = ∑ i ∈ s, 1 := s.tsum_subtype 1 _ = s.card := by
simp
/- Copyright (c) 2021 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.Instances.Real import Mathlib.Order.Filter.Archimedean #align_import analysis.subadditive from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Convergence of subadditive sequences A subadditive sequence `u : ℕ → ℝ` is a sequence satisfying `u (m + n) ≤ u m + u n` for all `m, n`. We define this notion as `Subadditive u`, and prove in `Subadditive.tendsto_lim` that, if `u n / n` is bounded below, then it converges to a limit (that we denote by `Subadditive.lim` for convenience). This result is known as Fekete's lemma in the literature. ## TODO Define a bundled `SubadditiveHom`, use it. -/ noncomputable section open Set Filter Topology /-- A real-valued sequence is subadditive if it satisfies the inequality `u (m + n) ≤ u m + u n` for all `m, n`. -/ def Subadditive (u : ℕ → ℝ) : Prop := ∀ m n, u (m + n) ≤ u m + u n #align subadditive Subadditive namespace Subadditive variable {u : ℕ → ℝ} (h : Subadditive u) /-- The limit of a bounded-below subadditive sequence. The fact that the sequence indeed tends to this limit is given in `Subadditive.tendsto_lim` -/ @[nolint unusedArguments] -- Porting note: was irreducible protected def lim (_h : Subadditive u) := sInf ((fun n : ℕ => u n / n) '' Ici 1) #align subadditive.lim Subadditive.lim theorem lim_le_div (hbdd : BddBelow (range fun n => u n / n)) {n : ℕ} (hn : n ≠ 0) : h.lim ≤ u n / n := by rw [Subadditive.lim] exact csInf_le (hbdd.mono <| image_subset_range _ _) ⟨n, hn.bot_lt, rfl⟩ #align subadditive.lim_le_div Subadditive.lim_le_div theorem apply_mul_add_le (k n r) : u (k * n + r) ≤ k * u n + u r := by induction k with | zero => simp only [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_add]; rfl | succ k IH => calc u ((k + 1) * n + r) = u (n + (k * n + r)) := by congr 1; ring _ ≤ u n + u (k * n + r) := h _ _ _ ≤ u n + (k * u n + u r) := add_le_add_left IH _ _ = (k + 1 : ℕ) * u n + u r := by simp; ring #align subadditive.apply_mul_add_le Subadditive.apply_mul_add_le theorem eventually_div_lt_of_div_lt {L : ℝ} {n : ℕ} (hn : n ≠ 0) (hL : u n / n < L) : ∀ᶠ p in atTop, u p / p < L := by /- It suffices to prove the statement for each arithmetic progression `(n * · + r)`. -/ refine .atTop_of_arithmetic hn fun r _ => ?_ /- `(k * u n + u r) / (k * n + r)` tends to `u n / n < L`, hence `(k * u n + u r) / (k * n + r) < L` for sufficiently large `k`. -/ have A : Tendsto (fun x : ℝ => (u n + u r / x) / (n + r / x)) atTop (𝓝 ((u n + 0) / (n + 0))) := (tendsto_const_nhds.add <| tendsto_const_nhds.div_atTop tendsto_id).div (tendsto_const_nhds.add <| tendsto_const_nhds.div_atTop tendsto_id) <| by simpa have B : Tendsto (fun x => (x * u n + u r) / (x * n + r)) atTop (𝓝 (u n / n)) := by rw [add_zero, add_zero] at A refine A.congr' <| (eventually_ne_atTop 0).mono fun x hx => ?_ simp only [(· ∘ ·), add_div' _ _ _ hx, div_div_div_cancel_right _ hx, mul_comm] refine ((B.comp tendsto_natCast_atTop_atTop).eventually (gt_mem_nhds hL)).mono fun k hk => ?_ /- Finally, we use an upper estimate on `u (k * n + r)` to get an estimate on `u (k * n + r) / (k * n + r)`. -/ rw [mul_comm] refine lt_of_le_of_lt ?_ hk simp only [(· ∘ ·), ← Nat.cast_add, ← Nat.cast_mul] exact div_le_div_of_nonneg_right (h.apply_mul_add_le _ _ _) (Nat.cast_nonneg _) #align subadditive.eventually_div_lt_of_div_lt Subadditive.eventually_div_lt_of_div_lt /-- Fekete's lemma: a subadditive sequence which is bounded below converges. -/
Mathlib/Analysis/Subadditive.lean
85
95
theorem tendsto_lim (hbdd : BddBelow (range fun n => u n / n)) : Tendsto (fun n => u n / n) atTop (𝓝 h.lim) := by
refine tendsto_order.2 ⟨fun l hl => ?_, fun L hL => ?_⟩ · refine eventually_atTop.2 ⟨1, fun n hn => hl.trans_le (h.lim_le_div hbdd (zero_lt_one.trans_le hn).ne')⟩ · obtain ⟨n, npos, hn⟩ : ∃ n : ℕ, 0 < n ∧ u n / n < L := by rw [Subadditive.lim] at hL rcases exists_lt_of_csInf_lt (by simp) hL with ⟨x, hx, xL⟩ rcases (mem_image _ _ _).1 hx with ⟨n, hn, rfl⟩ exact ⟨n, zero_lt_one.trans_le hn, xL⟩ exact h.eventually_div_lt_of_div_lt npos.ne' hn
/- 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.Order.SuccPred.Basic import Mathlib.Topology.Order.Basic import Mathlib.Topology.Metrizable.Uniformity #align_import topology.instances.discrete from "leanprover-community/mathlib"@"bcfa726826abd57587355b4b5b7e78ad6527b7e4" /-! # Instances related to the discrete topology We prove that the discrete topology is * first-countable, * second-countable for an encodable type, * equal to the order topology in linear orders which are also `PredOrder` and `SuccOrder`, * metrizable. When importing this file and `Data.Nat.SuccPred`, the instances `SecondCountableTopology ℕ` and `OrderTopology ℕ` become available. -/ open Order Set TopologicalSpace Filter variable {α : Type*} [TopologicalSpace α] instance (priority := 100) DiscreteTopology.firstCountableTopology [DiscreteTopology α] : FirstCountableTopology α where nhds_generated_countable := by rw [nhds_discrete]; exact isCountablyGenerated_pure #align discrete_topology.first_countable_topology DiscreteTopology.firstCountableTopology instance (priority := 100) DiscreteTopology.secondCountableTopology_of_countable [hd : DiscreteTopology α] [Countable α] : SecondCountableTopology α := haveI : ∀ i : α, SecondCountableTopology (↥({i} : Set α)) := fun i => { is_open_generated_countable := ⟨{univ}, countable_singleton _, by simp only [eq_iff_true_of_subsingleton]⟩ } secondCountableTopology_of_countable_cover (singletons_open_iff_discrete.mpr hd) (iUnion_of_singleton α) #align discrete_topology.second_countable_topology_of_encodable DiscreteTopology.secondCountableTopology_of_countable @[deprecated DiscreteTopology.secondCountableTopology_of_countable (since := "2024-03-11")] theorem DiscreteTopology.secondCountableTopology_of_encodable {α : Type*} [TopologicalSpace α] [DiscreteTopology α] [Countable α] : SecondCountableTopology α := DiscreteTopology.secondCountableTopology_of_countable #align discrete_topology.second_countable_topology_of_countable DiscreteTopology.secondCountableTopology_of_countable
Mathlib/Topology/Instances/Discrete.lean
51
63
theorem bot_topologicalSpace_eq_generateFrom_of_pred_succOrder [PartialOrder α] [PredOrder α] [SuccOrder α] [NoMinOrder α] [NoMaxOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by
refine (eq_bot_of_singletons_open fun a => ?_).symm have h_singleton_eq_inter : {a} = Iio (succ a) ∩ Ioi (pred a) := by suffices h_singleton_eq_inter' : {a} = Iic a ∩ Ici a by rw [h_singleton_eq_inter', ← Ioi_pred, ← Iio_succ] rw [inter_comm, Ici_inter_Iic, Icc_self a] rw [h_singleton_eq_inter] letI := Preorder.topology α apply IsOpen.inter · exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩ · exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Julian Kuelshammer -/ import Mathlib.Algebra.CharP.Defs import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Data.Int.ModEq import Mathlib.Data.Set.Pointwise.Basic import Mathlib.Dynamics.PeriodicPts import Mathlib.GroupTheory.Index import Mathlib.Order.Interval.Finset.Nat import Mathlib.Order.Interval.Set.Infinite #align_import group_theory.order_of_element from "leanprover-community/mathlib"@"d07245fd37786daa997af4f1a73a49fa3b748408" /-! # Order of an element This file defines the order of an element of a finite group. For a finite group `G` the order of `x ∈ G` is the minimal `n ≥ 1` such that `x ^ n = 1`. ## Main definitions * `IsOfFinOrder` is a predicate on an element `x` of a monoid `G` saying that `x` is of finite order. * `IsOfFinAddOrder` is the additive analogue of `IsOfFinOrder`. * `orderOf x` defines the order of an element `x` of a monoid `G`, by convention its value is `0` if `x` has infinite order. * `addOrderOf` is the additive analogue of `orderOf`. ## Tags order of an element -/ open Function Fintype Nat Pointwise Subgroup Submonoid variable {G H A α β : Type*} section Monoid variable [Monoid G] {a b x y : G} {n m : ℕ} section IsOfFinOrder -- Porting note(#12129): additional beta reduction needed @[to_additive] theorem isPeriodicPt_mul_iff_pow_eq_one (x : G) : IsPeriodicPt (x * ·) n 1 ↔ x ^ n = 1 := by rw [IsPeriodicPt, IsFixedPt, mul_left_iterate]; beta_reduce; rw [mul_one] #align is_periodic_pt_mul_iff_pow_eq_one isPeriodicPt_mul_iff_pow_eq_one #align is_periodic_pt_add_iff_nsmul_eq_zero isPeriodicPt_add_iff_nsmul_eq_zero /-- `IsOfFinOrder` is a predicate on an element `x` of a monoid to be of finite order, i.e. there exists `n ≥ 1` such that `x ^ n = 1`. -/ @[to_additive "`IsOfFinAddOrder` is a predicate on an element `a` of an additive monoid to be of finite order, i.e. there exists `n ≥ 1` such that `n • a = 0`."] def IsOfFinOrder (x : G) : Prop := (1 : G) ∈ periodicPts (x * ·) #align is_of_fin_order IsOfFinOrder #align is_of_fin_add_order IsOfFinAddOrder theorem isOfFinAddOrder_ofMul_iff : IsOfFinAddOrder (Additive.ofMul x) ↔ IsOfFinOrder x := Iff.rfl #align is_of_fin_add_order_of_mul_iff isOfFinAddOrder_ofMul_iff theorem isOfFinOrder_ofAdd_iff {α : Type*} [AddMonoid α] {x : α} : IsOfFinOrder (Multiplicative.ofAdd x) ↔ IsOfFinAddOrder x := Iff.rfl #align is_of_fin_order_of_add_iff isOfFinOrder_ofAdd_iff @[to_additive]
Mathlib/GroupTheory/OrderOfElement.lean
71
72
theorem isOfFinOrder_iff_pow_eq_one : IsOfFinOrder x ↔ ∃ n, 0 < n ∧ x ^ n = 1 := by
simp [IsOfFinOrder, mem_periodicPts, isPeriodicPt_mul_iff_pow_eq_one]
/- Copyright (c) 2023 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.NumberTheory.ModularForms.JacobiTheta.TwoVariable import Mathlib.Analysis.Complex.UpperHalfPlane.Basic #align_import number_theory.modular_forms.jacobi_theta.basic from "leanprover-community/mathlib"@"57f9349f2fe19d2de7207e99b0341808d977cdcf" /-! # Jacobi's theta function This file defines the one-variable Jacobi theta function $$\theta(\tau) = \sum_{n \in \mathbb{Z}} \exp (i \pi n ^ 2 \tau),$$ and proves the modular transformation properties `θ (τ + 2) = θ τ` and `θ (-1 / τ) = (-I * τ) ^ (1 / 2) * θ τ`, using Poisson's summation formula for the latter. We also show that `θ` is differentiable on `ℍ`, and `θ(τ) - 1` has exponential decay as `im τ → ∞`. -/ open Complex Real Asymptotics Filter Topology open scoped Real UpperHalfPlane /-- Jacobi's one-variable theta function `∑' (n : ℤ), exp (π * I * n ^ 2 * τ)`. -/ noncomputable def jacobiTheta (τ : ℂ) : ℂ := ∑' n : ℤ, cexp (π * I * (n : ℂ) ^ 2 * τ) #align jacobi_theta jacobiTheta lemma jacobiTheta_eq_jacobiTheta₂ (τ : ℂ) : jacobiTheta τ = jacobiTheta₂ 0 τ := tsum_congr (by simp [jacobiTheta₂_term]) theorem jacobiTheta_two_add (τ : ℂ) : jacobiTheta (2 + τ) = jacobiTheta τ := by simp_rw [jacobiTheta_eq_jacobiTheta₂, add_comm, jacobiTheta₂_add_right] #align jacobi_theta_two_add jacobiTheta_two_add
Mathlib/NumberTheory/ModularForms/JacobiTheta/OneVariable.lean
37
41
theorem jacobiTheta_T_sq_smul (τ : ℍ) : jacobiTheta (ModularGroup.T ^ 2 • τ :) = jacobiTheta τ := by
suffices (ModularGroup.T ^ 2 • τ :) = (2 : ℂ) + ↑τ by simp_rw [this, jacobiTheta_two_add] have : ModularGroup.T ^ (2 : ℕ) = ModularGroup.T ^ (2 : ℤ) := rfl simp_rw [this, UpperHalfPlane.modular_T_zpow_smul, UpperHalfPlane.coe_vadd] norm_cast
/- Copyright (c) 2019 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Topology.Constructions import Mathlib.Topology.Algebra.Monoid import Mathlib.Order.Filter.ListTraverse import Mathlib.Tactic.AdaptationNote #align_import topology.list from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" /-! # Topology on lists and vectors -/ open TopologicalSpace Set Filter open Topology Filter variable {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] instance : TopologicalSpace (List α) := TopologicalSpace.mkOfNhds (traverse nhds) theorem nhds_list (as : List α) : 𝓝 as = traverse 𝓝 as := by refine nhds_mkOfNhds _ _ ?_ ?_ · intro l induction l with | nil => exact le_rfl | cons a l ih => suffices List.cons <$> pure a <*> pure l ≤ List.cons <$> 𝓝 a <*> traverse 𝓝 l by simpa only [functor_norm] using this exact Filter.seq_mono (Filter.map_mono <| pure_le_nhds a) ih · intro l s hs rcases (mem_traverse_iff _ _).1 hs with ⟨u, hu, hus⟩ clear as hs have : ∃ v : List (Set α), l.Forall₂ (fun a s => IsOpen s ∧ a ∈ s) v ∧ sequence v ⊆ s := by induction hu generalizing s with | nil => exists [] simp only [List.forall₂_nil_left_iff, exists_eq_left] exact ⟨trivial, hus⟩ -- porting note -- renamed reordered variables based on previous types | cons ht _ ih => rcases mem_nhds_iff.1 ht with ⟨u, hut, hu⟩ rcases ih _ Subset.rfl with ⟨v, hv, hvss⟩ exact ⟨u::v, List.Forall₂.cons hu hv, Subset.trans (Set.seq_mono (Set.image_subset _ hut) hvss) hus⟩ rcases this with ⟨v, hv, hvs⟩ have : sequence v ∈ traverse 𝓝 l := mem_traverse _ _ <| hv.imp fun a s ⟨hs, ha⟩ => IsOpen.mem_nhds hs ha refine mem_of_superset this fun u hu ↦ ?_ have hu := (List.mem_traverse _ _).1 hu have : List.Forall₂ (fun a s => IsOpen s ∧ a ∈ s) u v := by refine List.Forall₂.flip ?_ replace hv := hv.flip #adaptation_note /-- nightly-2024-03-16: simp was simp only [List.forall₂_and_left, flip] at hv ⊢ -/ simp only [List.forall₂_and_left, Function.flip_def] at hv ⊢ exact ⟨hv.1, hu.flip⟩ refine mem_of_superset ?_ hvs exact mem_traverse _ _ (this.imp fun a s ⟨hs, ha⟩ => IsOpen.mem_nhds hs ha) #align nhds_list nhds_list @[simp] theorem nhds_nil : 𝓝 ([] : List α) = pure [] := by rw [nhds_list, List.traverse_nil _] #align nhds_nil nhds_nil theorem nhds_cons (a : α) (l : List α) : 𝓝 (a::l) = List.cons <$> 𝓝 a <*> 𝓝 l := by rw [nhds_list, List.traverse_cons _, ← nhds_list] #align nhds_cons nhds_cons
Mathlib/Topology/List.lean
78
80
theorem List.tendsto_cons {a : α} {l : List α} : Tendsto (fun p : α × List α => List.cons p.1 p.2) (𝓝 a ×ˢ 𝓝 l) (𝓝 (a::l)) := by
rw [nhds_cons, Tendsto, Filter.map_prod]; exact le_rfl
/- 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)
Mathlib/Algebra/Polynomial/Smeval.lean
54
54
theorem smeval_eq_sum : p.smeval x = p.sum (smul_pow x) := by
rw [smeval_def]
/- 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 theorem log_ofReal_re (x : ℝ) : (log (x : ℂ)).re = Real.log x := by simp [log_re] #align complex.log_of_real_re Complex.log_ofReal_re theorem log_ofReal_mul {r : ℝ} (hr : 0 < r) {x : ℂ} (hx : x ≠ 0) : log (r * x) = Real.log r + log x := by replace hx := Complex.abs.ne_zero_iff.mpr hx simp_rw [log, map_mul, abs_ofReal, arg_real_mul _ hr, abs_of_pos hr, Real.log_mul hr.ne' hx, ofReal_add, add_assoc] #align complex.log_of_real_mul Complex.log_ofReal_mul theorem log_mul_ofReal (r : ℝ) (hr : 0 < r) (x : ℂ) (hx : x ≠ 0) : log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx] #align complex.log_mul_of_real Complex.log_mul_ofReal lemma log_mul_eq_add_log_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) : log (x * y) = log x + log y ↔ arg x + arg y ∈ Set.Ioc (-π) π := by refine ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hx₀ hy₀ simp_rw [add_re, add_im, log_re, log_im, AbsoluteValue.map_mul, Real.log_mul (abs.ne_zero hx₀) (abs.ne_zero hy₀), true_and] alias ⟨_, log_mul⟩ := log_mul_eq_add_log_iff @[simp] theorem log_zero : log 0 = 0 := by simp [log] #align complex.log_zero Complex.log_zero @[simp] theorem log_one : log 1 = 0 := by simp [log] #align complex.log_one Complex.log_one
Mathlib/Analysis/SpecialFunctions/Complex/Log.lean
113
113
theorem log_neg_one : log (-1) = π * I := by
simp [log]
/- Copyright (c) 2022 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.Group.ConjFinite import Mathlib.GroupTheory.Abelianization import Mathlib.GroupTheory.GroupAction.ConjAct import Mathlib.GroupTheory.GroupAction.Quotient import Mathlib.GroupTheory.Index import Mathlib.GroupTheory.SpecificGroups.Dihedral import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.LinearCombination import Mathlib.Tactic.Qify #align_import group_theory.commuting_probability from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Commuting Probability This file introduces the commuting probability of finite groups. ## Main definitions * `commProb`: The commuting probability of a finite type with a multiplication operation. ## Todo * Neumann's theorem. -/ noncomputable section open scoped Classical open Fintype variable (M : Type*) [Mul M] /-- The commuting probability of a finite type with a multiplication operation. -/ def commProb : ℚ := Nat.card { p : M × M // Commute p.1 p.2 } / (Nat.card M : ℚ) ^ 2 #align comm_prob commProb theorem commProb_def : commProb M = Nat.card { p : M × M // Commute p.1 p.2 } / (Nat.card M : ℚ) ^ 2 := rfl #align comm_prob_def commProb_def theorem commProb_prod (M' : Type*) [Mul M'] : commProb (M × M') = commProb M * commProb M' := by simp_rw [commProb_def, div_mul_div_comm, Nat.card_prod, Nat.cast_mul, mul_pow, ← Nat.cast_mul, ← Nat.card_prod, Commute, SemiconjBy, Prod.ext_iff] congr 2 exact Nat.card_congr ⟨fun x => ⟨⟨⟨x.1.1.1, x.1.2.1⟩, x.2.1⟩, ⟨⟨x.1.1.2, x.1.2.2⟩, x.2.2⟩⟩, fun x => ⟨⟨⟨x.1.1.1, x.2.1.1⟩, ⟨x.1.1.2, x.2.1.2⟩⟩, ⟨x.1.2, x.2.2⟩⟩, fun x => rfl, fun x => rfl⟩
Mathlib/GroupTheory/CommutingProbability.lean
54
60
theorem commProb_pi {α : Type*} (i : α → Type*) [Fintype α] [∀ a, Mul (i a)] : commProb (∀ a, i a) = ∏ a, commProb (i a) := by
simp_rw [commProb_def, Finset.prod_div_distrib, Finset.prod_pow, ← Nat.cast_prod, ← Nat.card_pi, Commute, SemiconjBy, Function.funext_iff] congr 2 exact Nat.card_congr ⟨fun x a => ⟨⟨x.1.1 a, x.1.2 a⟩, x.2 a⟩, fun x => ⟨⟨fun a => (x a).1.1, fun a => (x a).1.2⟩, fun a => (x a).2⟩, fun x => rfl, fun x => rfl⟩
/- Copyright (c) 2022 Julian Berman. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Julian Berman -/ import Mathlib.Algebra.Group.Submonoid.Operations import Mathlib.GroupTheory.Exponent import Mathlib.GroupTheory.OrderOfElement import Mathlib.GroupTheory.PGroup import Mathlib.GroupTheory.QuotientGroup #align_import group_theory.torsion from "leanprover-community/mathlib"@"1f4705ccdfe1e557fc54a0ce081a05e33d2e6240" /-! # Torsion groups This file defines torsion groups, i.e. groups where all elements have finite order. ## Main definitions * `Monoid.IsTorsion` a predicate asserting `G` is torsion, i.e. that all elements are of finite order. * `CommGroup.torsion G`, the torsion subgroup of an abelian group `G` * `CommMonoid.torsion G`, the above stated for commutative monoids * `Monoid.IsTorsionFree`, asserting no nontrivial elements have finite order in `G` * `AddMonoid.IsTorsion` and `AddMonoid.IsTorsionFree` the additive versions of the above ## Implementation All torsion monoids are really groups (which is proven here as `Monoid.IsTorsion.group`), but since the definition can be stated on monoids it is implemented on `Monoid` to match other declarations in the group theory library. ## Tags periodic group, aperiodic group, torsion subgroup, torsion abelian group ## Future work * generalize to π-torsion(-free) groups for a set of primes π * free, free solvable and free abelian groups are torsion free * complete direct and free products of torsion free groups are torsion free * groups which are residually finite p-groups with respect to 2 distinct primes are torsion free -/ variable {G H : Type*} namespace Monoid variable (G) [Monoid G] /-- A predicate on a monoid saying that all elements are of finite order. -/ @[to_additive "A predicate on an additive monoid saying that all elements are of finite order."] def IsTorsion := ∀ g : G, IsOfFinOrder g #align monoid.is_torsion Monoid.IsTorsion #align add_monoid.is_torsion AddMonoid.IsTorsion /-- A monoid is not a torsion monoid if it has an element of infinite order. -/ @[to_additive (attr := simp) "An additive monoid is not a torsion monoid if it has an element of infinite order."]
Mathlib/GroupTheory/Torsion.lean
63
64
theorem not_isTorsion_iff : ¬IsTorsion G ↔ ∃ g : G, ¬IsOfFinOrder g := by
rw [IsTorsion, not_forall]
/- Copyright (c) 2022 Alex J. Best. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alex J. Best -/ import Mathlib.Algebra.Squarefree.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.PrincipalIdealDomain #align_import ring_theory.zmod from "leanprover-community/mathlib"@"00d163e35035c3577c1c79fa53b68de17781ffc1" /-! # Ring theoretic facts about `ZMod n` We collect a few facts about `ZMod n` that need some ring theory to be proved/stated. ## Main statements * `ZMod.ker_intCastRingHom`: the ring homomorphism `ℤ → ZMod n` has kernel generated by `n`. * `ZMod.ringHom_eq_of_ker_eq`: two ring homomorphisms into `ZMod n` with equal kernels are equal. * `isReduced_zmod`: `ZMod n` is reduced for all squarefree `n`. -/ /-- The ring homomorphism `ℤ → ZMod n` has kernel generated by `n`. -/ theorem ZMod.ker_intCastRingHom (n : ℕ) : RingHom.ker (Int.castRingHom (ZMod n)) = Ideal.span ({(n : ℤ)} : Set ℤ) := by ext rw [Ideal.mem_span_singleton, RingHom.mem_ker, Int.coe_castRingHom, ZMod.intCast_zmod_eq_zero_iff_dvd] #align zmod.ker_int_cast_ring_hom ZMod.ker_intCastRingHom /-- Two ring homomorphisms into `ZMod n` with equal kernels are equal. -/
Mathlib/RingTheory/ZMod.lean
33
37
theorem ZMod.ringHom_eq_of_ker_eq {n : ℕ} {R : Type*} [CommRing R] (f g : R →+* ZMod n) (h : RingHom.ker f = RingHom.ker g) : f = g := by
have := f.liftOfRightInverse_comp _ (ZMod.ringHom_rightInverse f) ⟨g, le_of_eq h⟩ rw [Subtype.coe_mk] at this rw [← this, RingHom.ext_zmod (f.liftOfRightInverse _ _ ⟨g, _⟩) _, RingHom.id_comp]
/- 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.MonoidAlgebra.Basic import Mathlib.RingTheory.Ideal.Basic #align_import algebra.monoid_algebra.ideal from "leanprover-community/mathlib"@"72c366d0475675f1309d3027d3d7d47ee4423951" /-! # Lemmas about ideals of `MonoidAlgebra` and `AddMonoidAlgebra` -/ variable {k A G : Type*} /-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of `x` factors through an element of `s`. We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse. -/
Mathlib/Algebra/MonoidAlgebra/Ideal.lean
23
58
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G} {x : MonoidAlgebra k G} : x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
let RHS : Ideal (MonoidAlgebra k G) := { carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' } add_mem' := fun {x y} hx hy m hm => by classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m) zero_mem' := fun m hm => by cases hm smul_mem' := fun x y hy m hm => by classical rw [smul_eq_mul, mul_def] at hm replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm) obtain ⟨xm, -, hm⟩ := hm replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm) obtain ⟨ym, hym, hm⟩ := hm obtain rfl := Finset.mem_singleton.mp (Finsupp.support_single_subset hm) refine (hy _ hym).imp fun sm p => And.imp_right ?_ p rintro ⟨d, rfl⟩ exact ⟨xm * d, (mul_assoc _ _ _).symm⟩ } change _ ↔ x ∈ RHS constructor · revert x rw [← SetLike.le_def] -- Porting note: refine needs this even though it's defeq? refine Ideal.span_le.2 ?_ rintro _ ⟨i, hi, rfl⟩ m hm refine ⟨_, hi, 1, ?_⟩ obtain rfl := Finset.mem_singleton.mp (Finsupp.support_single_subset hm) exact (one_mul _).symm · intro hx rw [← Finsupp.sum_single x] refine Ideal.sum_mem _ fun i hi => ?_ -- Porting note: changed `apply` to `refine` obtain ⟨d, hd, d2, rfl⟩ := hx _ hi convert Ideal.mul_mem_left _ (id <| Finsupp.single d2 <| x (d2 * d) : MonoidAlgebra k G) _ pick_goal 3 · exact Ideal.subset_span ⟨_, hd, rfl⟩ rw [id, MonoidAlgebra.of_apply, MonoidAlgebra.single_mul_single, mul_one]
/- 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.MeasureTheory.Constructions.BorelSpace.Order #align_import measure_theory.function.floor from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf" /-! # Measurability of `⌊x⌋` etc In this file we prove that `Int.floor`, `Int.ceil`, `Int.fract`, `Nat.floor`, and `Nat.ceil` are measurable under some assumptions on the (semi)ring. -/ open Set section FloorRing variable {α R : Type*} [MeasurableSpace α] [LinearOrderedRing R] [FloorRing R] [TopologicalSpace R] [OrderTopology R] [MeasurableSpace R] theorem Int.measurable_floor [OpensMeasurableSpace R] : Measurable (Int.floor : R → ℤ) := measurable_to_countable fun x => by simpa only [Int.preimage_floor_singleton] using measurableSet_Ico #align int.measurable_floor Int.measurable_floor @[measurability] theorem Measurable.floor [OpensMeasurableSpace R] {f : α → R} (hf : Measurable f) : Measurable fun x => ⌊f x⌋ := Int.measurable_floor.comp hf #align measurable.floor Measurable.floor theorem Int.measurable_ceil [OpensMeasurableSpace R] : Measurable (Int.ceil : R → ℤ) := measurable_to_countable fun x => by simpa only [Int.preimage_ceil_singleton] using measurableSet_Ioc #align int.measurable_ceil Int.measurable_ceil @[measurability] theorem Measurable.ceil [OpensMeasurableSpace R] {f : α → R} (hf : Measurable f) : Measurable fun x => ⌈f x⌉ := Int.measurable_ceil.comp hf #align measurable.ceil Measurable.ceil theorem measurable_fract [BorelSpace R] : Measurable (Int.fract : R → R) := by intro s hs rw [Int.preimage_fract] exact MeasurableSet.iUnion fun z => measurable_id.sub_const _ (hs.inter measurableSet_Ico) #align measurable_fract measurable_fract @[measurability] theorem Measurable.fract [BorelSpace R] {f : α → R} (hf : Measurable f) : Measurable fun x => Int.fract (f x) := measurable_fract.comp hf #align measurable.fract Measurable.fract
Mathlib/MeasureTheory/Function/Floor.lean
59
62
theorem MeasurableSet.image_fract [BorelSpace R] {s : Set R} (hs : MeasurableSet s) : MeasurableSet (Int.fract '' s) := by
simp only [Int.image_fract, sub_eq_add_neg, image_add_right'] exact MeasurableSet.iUnion fun m => (measurable_add_const _ hs).inter measurableSet_Ico
/- 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.Prod import Mathlib.Data.Fintype.Sum import Mathlib.SetTheory.Cardinal.Finite #align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" /-! # fintype instances relating to units -/ variable {α : Type*} instance UnitsInt.fintype : Fintype ℤˣ := ⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> simp [*]⟩ #align units_int.fintype UnitsInt.fintype @[simp] theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl #align units_int.univ UnitsInt.univ @[simp] theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl #align fintype.card_units_int Fintype.card_units_int instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ := Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
Mathlib/Data/Fintype/Units.lean
36
40
theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] : Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr unitsEquivNeZero] have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α))) rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this
/- Copyright (c) 2021 Benjamin Davidson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Benjamin Davidson -/ import Mathlib.MeasureTheory.Integral.FundThmCalculus import Mathlib.Analysis.SpecialFunctions.Trigonometric.ArctanDeriv import Mathlib.Analysis.SpecialFunctions.NonIntegrable import Mathlib.Analysis.SpecialFunctions.Pow.Deriv #align_import analysis.special_functions.integrals from "leanprover-community/mathlib"@"011cafb4a5bc695875d186e245d6b3df03bf6c40" /-! # Integration of specific interval integrals This file contains proofs of the integrals of various specific functions. This includes: * Integrals of simple functions, such as `id`, `pow`, `inv`, `exp`, `log` * Integrals of some trigonometric functions, such as `sin`, `cos`, `1 / (1 + x^2)` * The integral of `cos x ^ 2 - sin x ^ 2` * Reduction formulae for the integrals of `sin x ^ n` and `cos x ^ n` for `n ≥ 2` * The computation of `∫ x in 0..π, sin x ^ n` as a product for even and odd `n` (used in proving the Wallis product for pi) * Integrals of the form `sin x ^ m * cos x ^ n` With these lemmas, many simple integrals can be computed by `simp` or `norm_num`. See `test/integration.lean` for specific examples. This file also contains some facts about the interval integrability of specific functions. This file is still being developed. ## Tags integrate, integration, integrable, integrability -/ open Real Nat Set Finset open scoped Real Interval variable {a b : ℝ} (n : ℕ) namespace intervalIntegral open MeasureTheory variable {f : ℝ → ℝ} {μ ν : Measure ℝ} [IsLocallyFiniteMeasure μ] (c d : ℝ) /-! ### Interval integrability -/ @[simp] theorem intervalIntegrable_pow : IntervalIntegrable (fun x => x ^ n) μ a b := (continuous_pow n).intervalIntegrable a b #align interval_integral.interval_integrable_pow intervalIntegral.intervalIntegrable_pow theorem intervalIntegrable_zpow {n : ℤ} (h : 0 ≤ n ∨ (0 : ℝ) ∉ [[a, b]]) : IntervalIntegrable (fun x => x ^ n) μ a b := (continuousOn_id.zpow₀ n fun _ hx => h.symm.imp (ne_of_mem_of_not_mem hx) id).intervalIntegrable #align interval_integral.interval_integrable_zpow intervalIntegral.intervalIntegrable_zpow /-- See `intervalIntegrable_rpow'` for a version with a weaker hypothesis on `r`, but assuming the measure is volume. -/ theorem intervalIntegrable_rpow {r : ℝ} (h : 0 ≤ r ∨ (0 : ℝ) ∉ [[a, b]]) : IntervalIntegrable (fun x => x ^ r) μ a b := (continuousOn_id.rpow_const fun _ hx => h.symm.imp (ne_of_mem_of_not_mem hx) id).intervalIntegrable #align interval_integral.interval_integrable_rpow intervalIntegral.intervalIntegrable_rpow /-- See `intervalIntegrable_rpow` for a version applying to any locally finite measure, but with a stronger hypothesis on `r`. -/
Mathlib/Analysis/SpecialFunctions/Integrals.lean
73
95
theorem intervalIntegrable_rpow' {r : ℝ} (h : -1 < r) : IntervalIntegrable (fun x => x ^ r) volume a b := by
suffices ∀ c : ℝ, IntervalIntegrable (fun x => x ^ r) volume 0 c by exact IntervalIntegrable.trans (this a).symm (this b) have : ∀ c : ℝ, 0 ≤ c → IntervalIntegrable (fun x => x ^ r) volume 0 c := by intro c hc rw [intervalIntegrable_iff, uIoc_of_le hc] have hderiv : ∀ x ∈ Ioo 0 c, HasDerivAt (fun x : ℝ => x ^ (r + 1) / (r + 1)) (x ^ r) x := by intro x hx convert (Real.hasDerivAt_rpow_const (p := r + 1) (Or.inl hx.1.ne')).div_const (r + 1) using 1 field_simp [(by linarith : r + 1 ≠ 0)] apply integrableOn_deriv_of_nonneg _ hderiv · intro x hx; apply rpow_nonneg hx.1.le · refine (continuousOn_id.rpow_const ?_).div_const _; intro x _; right; linarith intro c; rcases le_total 0 c with (hc | hc) · exact this c hc · rw [IntervalIntegrable.iff_comp_neg, neg_zero] have m := (this (-c) (by linarith)).smul (cos (r * π)) rw [intervalIntegrable_iff] at m ⊢ refine m.congr_fun ?_ measurableSet_Ioc; intro x hx rw [uIoc_of_le (by linarith : 0 ≤ -c)] at hx simp only [Pi.smul_apply, Algebra.id.smul_eq_mul, log_neg_eq_log, mul_comm, rpow_def_of_pos hx.1, rpow_def_of_neg (by linarith [hx.1] : -x < 0)]
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Floris van Doorn -/ import Mathlib.Geometry.Manifold.MFDeriv.Basic /-! ### Relations between vector space derivative and manifold derivative The manifold derivative `mfderiv`, when considered on the model vector space with its trivial manifold structure, coincides with the usual Frechet derivative `fderiv`. In this section, we prove this and related statements. -/ noncomputable section open scoped Manifold variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {f : E → E'} {s : Set E} {x : E} section MFDerivFderiv theorem uniqueMDiffWithinAt_iff_uniqueDiffWithinAt : UniqueMDiffWithinAt 𝓘(𝕜, E) s x ↔ UniqueDiffWithinAt 𝕜 s x := by simp only [UniqueMDiffWithinAt, mfld_simps] #align unique_mdiff_within_at_iff_unique_diff_within_at uniqueMDiffWithinAt_iff_uniqueDiffWithinAt alias ⟨UniqueMDiffWithinAt.uniqueDiffWithinAt, UniqueDiffWithinAt.uniqueMDiffWithinAt⟩ := uniqueMDiffWithinAt_iff_uniqueDiffWithinAt #align unique_mdiff_within_at.unique_diff_within_at UniqueMDiffWithinAt.uniqueDiffWithinAt #align unique_diff_within_at.unique_mdiff_within_at UniqueDiffWithinAt.uniqueMDiffWithinAt
Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean
36
37
theorem uniqueMDiffOn_iff_uniqueDiffOn : UniqueMDiffOn 𝓘(𝕜, E) s ↔ UniqueDiffOn 𝕜 s := by
simp [UniqueMDiffOn, UniqueDiffOn, uniqueMDiffWithinAt_iff_uniqueDiffWithinAt]
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Nat.Factors import Mathlib.Order.Interval.Finset.Nat #align_import number_theory.divisors from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Divisor Finsets This file defines sets of divisors of a natural number. This is particularly useful as background for defining Dirichlet convolution. ## Main Definitions Let `n : ℕ`. All of the following definitions are in the `Nat` namespace: * `divisors n` is the `Finset` of natural numbers that divide `n`. * `properDivisors n` is the `Finset` of natural numbers that divide `n`, other than `n`. * `divisorsAntidiagonal n` is the `Finset` of pairs `(x,y)` such that `x * y = n`. * `Perfect n` is true when `n` is positive and the sum of `properDivisors n` is `n`. ## Implementation details * `divisors 0`, `properDivisors 0`, and `divisorsAntidiagonal 0` are defined to be `∅`. ## Tags divisors, perfect numbers -/ open scoped Classical open Finset namespace Nat variable (n : ℕ) /-- `divisors n` is the `Finset` of divisors of `n`. As a special case, `divisors 0 = ∅`. -/ def divisors : Finset ℕ := Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 (n + 1)) #align nat.divisors Nat.divisors /-- `properDivisors n` is the `Finset` of divisors of `n`, other than `n`. As a special case, `properDivisors 0 = ∅`. -/ def properDivisors : Finset ℕ := Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 n) #align nat.proper_divisors Nat.properDivisors /-- `divisorsAntidiagonal n` is the `Finset` of pairs `(x,y)` such that `x * y = n`. As a special case, `divisorsAntidiagonal 0 = ∅`. -/ def divisorsAntidiagonal : Finset (ℕ × ℕ) := Finset.filter (fun x => x.fst * x.snd = n) (Ico 1 (n + 1) ×ˢ Ico 1 (n + 1)) #align nat.divisors_antidiagonal Nat.divisorsAntidiagonal variable {n} @[simp] theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors := by ext simp only [divisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self] exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt) #align nat.filter_dvd_eq_divisors Nat.filter_dvd_eq_divisors @[simp] theorem filter_dvd_eq_properDivisors (h : n ≠ 0) : (Finset.range n).filter (· ∣ n) = n.properDivisors := by ext simp only [properDivisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self] exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt) #align nat.filter_dvd_eq_proper_divisors Nat.filter_dvd_eq_properDivisors theorem properDivisors.not_self_mem : ¬n ∈ properDivisors n := by simp [properDivisors] #align nat.proper_divisors.not_self_mem Nat.properDivisors.not_self_mem @[simp] theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m := by rcases eq_or_ne m 0 with (rfl | hm); · simp [properDivisors] simp only [and_comm, ← filter_dvd_eq_properDivisors hm, mem_filter, mem_range] #align nat.mem_proper_divisors Nat.mem_properDivisors theorem insert_self_properDivisors (h : n ≠ 0) : insert n (properDivisors n) = divisors n := by rw [divisors, properDivisors, Ico_succ_right_eq_insert_Ico (one_le_iff_ne_zero.2 h), Finset.filter_insert, if_pos (dvd_refl n)] #align nat.insert_self_proper_divisors Nat.insert_self_properDivisors theorem cons_self_properDivisors (h : n ≠ 0) : cons n (properDivisors n) properDivisors.not_self_mem = divisors n := by rw [cons_eq_insert, insert_self_properDivisors h] #align nat.cons_self_proper_divisors Nat.cons_self_properDivisors @[simp] theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 := by rcases eq_or_ne m 0 with (rfl | hm); · simp [divisors] simp only [hm, Ne, not_false_iff, and_true_iff, ← filter_dvd_eq_divisors hm, mem_filter, mem_range, and_iff_right_iff_imp, Nat.lt_succ_iff] exact le_of_dvd hm.bot_lt #align nat.mem_divisors Nat.mem_divisors theorem one_mem_divisors : 1 ∈ divisors n ↔ n ≠ 0 := by simp #align nat.one_mem_divisors Nat.one_mem_divisors theorem mem_divisors_self (n : ℕ) (h : n ≠ 0) : n ∈ n.divisors := mem_divisors.2 ⟨dvd_rfl, h⟩ #align nat.mem_divisors_self Nat.mem_divisors_self
Mathlib/NumberTheory/Divisors.lean
109
112
theorem dvd_of_mem_divisors {m : ℕ} (h : n ∈ divisors m) : n ∣ m := by
cases m · apply dvd_zero · simp [mem_divisors.1 h]
/- Copyright (c) 2023 Matthew Robert Ballard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Matthew Robert Ballard -/ import Mathlib.Algebra.Divisibility.Units import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Tactic.Common /-! # The maximal power of one natural number dividing another Here we introduce `p.maxPowDiv n` which returns the maximal `k : ℕ` for which `p ^ k ∣ n` with the convention that `maxPowDiv 1 n = 0` for all `n`. We prove enough about `maxPowDiv` in this file to show equality with `Nat.padicValNat` in `padicValNat.padicValNat_eq_maxPowDiv`. The implementation of `maxPowDiv` improves on the speed of `padicValNat`. -/ namespace Nat open Nat /-- Tail recursive function which returns the largest `k : ℕ` such that `p ^ k ∣ n` for any `p : ℕ`. `padicValNat_eq_maxPowDiv` allows the code generator to use this definition for `padicValNat` -/ def maxPowDiv (p n : ℕ) : ℕ := go 0 p n where go (k p n : ℕ) : ℕ := if 1 < p ∧ 0 < n ∧ n % p = 0 then go (k+1) p (n / p) else k termination_by n decreasing_by apply Nat.div_lt_self <;> tauto attribute [inherit_doc maxPowDiv] maxPowDiv.go end Nat namespace Nat.maxPowDiv theorem go_succ {k p n : ℕ} : go (k+1) p n = go k p n + 1 := by induction k, p, n using go.induct case case1 h ih => unfold go simp only [if_pos h] exact ih case case2 h => unfold go simp only [if_neg h] @[simp] theorem zero_base {n : ℕ} : maxPowDiv 0 n = 0 := by dsimp [maxPowDiv] rw [maxPowDiv.go] simp @[simp] theorem zero {p : ℕ} : maxPowDiv p 0 = 0 := by dsimp [maxPowDiv] rw [maxPowDiv.go] simp theorem base_mul_eq_succ {p n : ℕ} (hp : 1 < p) (hn : 0 < n) : p.maxPowDiv (p*n) = p.maxPowDiv n + 1 := by have : 0 < p := lt_trans (b := 1) (by simp) hp dsimp [maxPowDiv] rw [maxPowDiv.go, if_pos, mul_div_right _ this] · apply go_succ · refine ⟨hp, ?_, by simp⟩ apply Nat.mul_pos this hn theorem base_pow_mul {p n exp : ℕ} (hp : 1 < p) (hn : 0 < n) : p.maxPowDiv (p ^ exp * n) = p.maxPowDiv n + exp := by match exp with | 0 => simp | e + 1 => rw [Nat.pow_succ, mul_assoc, mul_comm, mul_assoc, base_mul_eq_succ hp, mul_comm, base_pow_mul hp hn] · ac_rfl · apply Nat.mul_pos hn <| pow_pos (pos_of_gt hp) e
Mathlib/Data/Nat/MaxPowDiv.lean
87
99
theorem pow_dvd (p n : ℕ) : p ^ (p.maxPowDiv n) ∣ n := by
dsimp [maxPowDiv] rw [go] by_cases h : (1 < p ∧ 0 < n ∧ n % p = 0) · have : n / p < n := by apply Nat.div_lt_self <;> aesop rw [if_pos h] have ⟨c,hc⟩ := pow_dvd p (n / p) rw [go_succ, pow_succ] nth_rw 2 [← mod_add_div' n p] rw [h.right.right, zero_add] exact ⟨c,by nth_rw 1 [hc]; ac_rfl⟩ · rw [if_neg h] simp
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel, Rémy Degenne, David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.Pow.Complex import Qq #align_import analysis.special_functions.pow.real from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" /-! # Power function on `ℝ` We construct the power functions `x ^ y`, where `x` and `y` are real numbers. -/ noncomputable section open scoped Classical open Real ComplexConjugate open Finset Set /- ## Definitions -/ namespace Real variable {x y z : ℝ} /-- The real power function `x ^ y`, defined as the real part of the complex power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for `y ≠ 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (π y)`. -/ noncomputable def rpow (x y : ℝ) := ((x : ℂ) ^ (y : ℂ)).re #align real.rpow Real.rpow noncomputable instance : Pow ℝ ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x y : ℝ) : rpow x y = x ^ y := rfl #align real.rpow_eq_pow Real.rpow_eq_pow theorem rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl #align real.rpow_def Real.rpow_def theorem rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by simp only [rpow_def, Complex.cpow_def]; split_ifs <;> simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul, -RCLike.ofReal_mul, (Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero] #align real.rpow_def_of_nonneg Real.rpow_def_of_nonneg theorem rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) := by rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)] #align real.rpow_def_of_pos Real.rpow_def_of_pos theorem exp_mul (x y : ℝ) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp] #align real.exp_mul Real.exp_mul @[simp, norm_cast] theorem rpow_intCast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by simp only [rpow_def, ← Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast, Complex.ofReal_re] #align real.rpow_int_cast Real.rpow_intCast @[deprecated (since := "2024-04-17")] alias rpow_int_cast := rpow_intCast @[simp, norm_cast]
Mathlib/Analysis/SpecialFunctions/Pow/Real.lean
73
73
theorem rpow_natCast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by
simpa using rpow_intCast x n
/- Copyright (c) 2020 Kenji Nakagawa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenji Nakagawa, Anne Baanen, Filippo A. E. Nuccio -/ import Mathlib.Algebra.Algebra.Subalgebra.Pointwise import Mathlib.AlgebraicGeometry.PrimeSpectrum.Maximal import Mathlib.AlgebraicGeometry.PrimeSpectrum.Noetherian import Mathlib.RingTheory.ChainOfDivisors import Mathlib.RingTheory.DedekindDomain.Basic import Mathlib.RingTheory.FractionalIdeal.Operations #align_import ring_theory.dedekind_domain.ideal from "leanprover-community/mathlib"@"2bbc7e3884ba234309d2a43b19144105a753292e" /-! # Dedekind domains and ideals In this file, we show a ring is a Dedekind domain iff all fractional ideals are invertible. Then we prove some results on the unique factorization monoid structure of the ideals. ## Main definitions - `IsDedekindDomainInv` alternatively defines a Dedekind domain as an integral domain where every nonzero fractional ideal is invertible. - `isDedekindDomainInv_iff` shows that this does note depend on the choice of field of fractions. - `IsDedekindDomain.HeightOneSpectrum` defines the type of nonzero prime ideals of `R`. ## Main results: - `isDedekindDomain_iff_isDedekindDomainInv` - `Ideal.uniqueFactorizationMonoid` ## Implementation notes The definitions that involve a field of fractions choose a canonical field of fractions, but are independent of that choice. The `..._iff` lemmas express this independence. Often, definitions assume that Dedekind domains are not fields. We found it more practical to add a `(h : ¬ IsField A)` assumption whenever this is explicitly needed. ## References * [D. Marcus, *Number Fields*][marcus1977number] * [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic] * [J. Neukirch, *Algebraic Number Theory*][Neukirch1992] ## Tags dedekind domain, dedekind ring -/ variable (R A K : Type*) [CommRing R] [CommRing A] [Field K] open scoped nonZeroDivisors Polynomial section Inverse namespace FractionalIdeal variable {R₁ : Type*} [CommRing R₁] [IsDomain R₁] [Algebra R₁ K] [IsFractionRing R₁ K] variable {I J : FractionalIdeal R₁⁰ K} noncomputable instance : Inv (FractionalIdeal R₁⁰ K) := ⟨fun I => 1 / I⟩ theorem inv_eq : I⁻¹ = 1 / I := rfl #align fractional_ideal.inv_eq FractionalIdeal.inv_eq theorem inv_zero' : (0 : FractionalIdeal R₁⁰ K)⁻¹ = 0 := div_zero #align fractional_ideal.inv_zero' FractionalIdeal.inv_zero' theorem inv_nonzero {J : FractionalIdeal R₁⁰ K} (h : J ≠ 0) : J⁻¹ = ⟨(1 : FractionalIdeal R₁⁰ K) / J, fractional_div_of_nonzero h⟩ := div_nonzero h #align fractional_ideal.inv_nonzero FractionalIdeal.inv_nonzero
Mathlib/RingTheory/DedekindDomain/Ideal.lean
76
78
theorem coe_inv_of_nonzero {J : FractionalIdeal R₁⁰ K} (h : J ≠ 0) : (↑J⁻¹ : Submodule R₁ K) = IsLocalization.coeSubmodule K ⊤ / (J : Submodule R₁ K) := by
simp_rw [inv_nonzero _ h, coe_one, coe_mk, IsLocalization.coeSubmodule_top]
/- Copyright (c) 2023 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Sym.Sym2 /-! # Unordered tuples of elements of a list Defines `List.sym` and the specialized `List.sym2` for computing lists of all unordered n-tuples from a given list. These are list versions of `Nat.multichoose`. ## Main declarations * `List.sym`: `xs.sym n` is a list of all unordered n-tuples of elements from `xs`, with multiplicity. The list's values are in `Sym α n`. * `List.sym2`: `xs.sym2` is a list of all unordered pairs of elements from `xs`, with multiplicity. The list's values are in `Sym2 α`. ## Todo * Prove `protected theorem Perm.sym (n : ℕ) {xs ys : List α} (h : xs ~ ys) : xs.sym n ~ ys.sym n` and lift the result to `Multiset` and `Finset`. -/ namespace List variable {α : Type*} section Sym2 /-- `xs.sym2` is a list of all unordered pairs of elements from `xs`. If `xs` has no duplicates then neither does `xs.sym2`. -/ protected def sym2 : List α → List (Sym2 α) | [] => [] | x :: xs => (x :: xs).map (fun y => s(x, y)) ++ xs.sym2 theorem mem_sym2_cons_iff {x : α} {xs : List α} {z : Sym2 α} : z ∈ (x :: xs).sym2 ↔ z = s(x, x) ∨ (∃ y, y ∈ xs ∧ z = s(x, y)) ∨ z ∈ xs.sym2 := by simp only [List.sym2, map_cons, cons_append, mem_cons, mem_append, mem_map] simp only [eq_comm] @[simp] theorem sym2_eq_nil_iff {xs : List α} : xs.sym2 = [] ↔ xs = [] := by cases xs <;> simp [List.sym2]
Mathlib/Data/List/Sym.lean
49
61
theorem left_mem_of_mk_mem_sym2 {xs : List α} {a b : α} (h : s(a, b) ∈ xs.sym2) : a ∈ xs := by
induction xs with | nil => exact (not_mem_nil _ h).elim | cons x xs ih => rw [mem_cons] rw [mem_sym2_cons_iff] at h obtain (h | ⟨c, hc, h⟩ | h) := h · rw [Sym2.eq_iff, ← and_or_left] at h exact .inl h.1 · rw [Sym2.eq_iff] at h obtain (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩) := h <;> simp [hc] · exact .inr <| ih h