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 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}
Mathlib/LinearAlgebra/AffineSpace/Ordered.lean
52
54
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)) _
/- Copyright (c) 2018 Guy Leroy. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sangwoo Jo (aka Jason), Guy Leroy, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Group.Int import Mathlib.Algebra.GroupWithZero.Semiconj import Mathlib.Data.Nat.GCD.Basic import Mathlib.Order.Bounds.Basic #align_import data.int.gcd from "leanprover-community/mathlib"@"47a1a73351de8dd6c8d3d32b569c8e434b03ca47" /-! # Extended GCD and divisibility over ℤ ## Main definitions * Given `x y : ℕ`, `xgcd x y` computes the pair of integers `(a, b)` such that `gcd x y = x * a + y * b`. `gcdA x y` and `gcdB x y` are defined to be `a` and `b`, respectively. ## Main statements * `gcd_eq_gcd_ab`: Bézout's lemma, given `x y : ℕ`, `gcd x y = x * gcdA x y + y * gcdB x y`. ## Tags Bézout's lemma, Bezout's lemma -/ /-! ### Extended Euclidean algorithm -/ namespace Nat /-- Helper function for the extended GCD algorithm (`Nat.xgcd`). -/ def xgcdAux : ℕ → ℤ → ℤ → ℕ → ℤ → ℤ → ℕ × ℤ × ℤ | 0, _, _, r', s', t' => (r', s', t') | succ k, s, t, r', s', t' => let q := r' / succ k xgcdAux (r' % succ k) (s' - q * s) (t' - q * t) (succ k) s t termination_by k => k decreasing_by exact mod_lt _ <| (succ_pos _).gt #align nat.xgcd_aux Nat.xgcdAux @[simp]
Mathlib/Data/Int/GCD.lean
48
48
theorem xgcd_zero_left {s t r' s' t'} : xgcdAux 0 s t r' s' t' = (r', s', t') := by
simp [xgcdAux]
/- Copyright (c) 2020 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Sébastien Gouëzel -/ import Mathlib.MeasureTheory.Measure.Haar.InnerProductSpace import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.measure.haar.normed_space from "leanprover-community/mathlib"@"b84aee748341da06a6d78491367e2c0e9f15e8a5" /-! # Basic properties of Haar measures on real vector spaces -/ noncomputable section open scoped NNReal ENNReal Pointwise Topology open Inv Set Function MeasureTheory.Measure Filter open FiniteDimensional namespace MeasureTheory namespace Measure /- The instance `MeasureTheory.Measure.IsAddHaarMeasure.noAtoms` applies in particular to show that an additive Haar measure on a nontrivial finite-dimensional real vector space has no atom. -/ example {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [Nontrivial E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [IsAddHaarMeasure μ] : NoAtoms μ := by infer_instance section ContinuousLinearEquiv variable {𝕜 G H : Type*} [MeasurableSpace G] [MeasurableSpace H] [NontriviallyNormedField 𝕜] [TopologicalSpace G] [TopologicalSpace H] [AddCommGroup G] [AddCommGroup H] [TopologicalAddGroup G] [TopologicalAddGroup H] [Module 𝕜 G] [Module 𝕜 H] (μ : Measure G) [IsAddHaarMeasure μ] [BorelSpace G] [BorelSpace H] [T2Space H] instance MapContinuousLinearEquiv.isAddHaarMeasure (e : G ≃L[𝕜] H) : IsAddHaarMeasure (μ.map e) := e.toAddEquiv.isAddHaarMeasure_map _ e.continuous e.symm.continuous #align measure_theory.measure.map_continuous_linear_equiv.is_add_haar_measure MeasureTheory.Measure.MapContinuousLinearEquiv.isAddHaarMeasure variable [CompleteSpace 𝕜] [T2Space G] [FiniteDimensional 𝕜 G] [ContinuousSMul 𝕜 G] [ContinuousSMul 𝕜 H] instance MapLinearEquiv.isAddHaarMeasure (e : G ≃ₗ[𝕜] H) : IsAddHaarMeasure (μ.map e) := MapContinuousLinearEquiv.isAddHaarMeasure _ e.toContinuousLinearEquiv #align measure_theory.measure.map_linear_equiv.is_add_haar_measure MeasureTheory.Measure.MapLinearEquiv.isAddHaarMeasure end ContinuousLinearEquiv variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] variable {s : Set E} /-- The integral of `f (R • x)` with respect to an additive Haar measure is a multiple of the integral of `f`. The formula we give works even when `f` is not integrable or `R = 0` thanks to the convention that a non-integrable function has integral zero. -/ theorem integral_comp_smul (f : E → F) (R : ℝ) : ∫ x, f (R • x) ∂μ = |(R ^ finrank ℝ E)⁻¹| • ∫ x, f x ∂μ := by by_cases hF : CompleteSpace F; swap · simp [integral, hF] rcases eq_or_ne R 0 with (rfl | hR) · simp only [zero_smul, integral_const] rcases Nat.eq_zero_or_pos (finrank ℝ E) with (hE | hE) · have : Subsingleton E := finrank_zero_iff.1 hE have : f = fun _ => f 0 := by ext x; rw [Subsingleton.elim x 0] conv_rhs => rw [this] simp only [hE, pow_zero, inv_one, abs_one, one_smul, integral_const] · have : Nontrivial E := finrank_pos_iff.1 hE simp only [zero_pow hE.ne', measure_univ_of_isAddLeftInvariant, ENNReal.top_toReal, zero_smul, inv_zero, abs_zero] · calc (∫ x, f (R • x) ∂μ) = ∫ y, f y ∂Measure.map (fun x => R • x) μ := (integral_map_equiv (Homeomorph.smul (isUnit_iff_ne_zero.2 hR).unit).toMeasurableEquiv f).symm _ = |(R ^ finrank ℝ E)⁻¹| • ∫ x, f x ∂μ := by simp only [map_addHaar_smul μ hR, integral_smul_measure, ENNReal.toReal_ofReal, abs_nonneg] #align measure_theory.measure.integral_comp_smul MeasureTheory.Measure.integral_comp_smul /-- The integral of `f (R • x)` with respect to an additive Haar measure is a multiple of the integral of `f`. The formula we give works even when `f` is not integrable or `R = 0` thanks to the convention that a non-integrable function has integral zero. -/ theorem integral_comp_smul_of_nonneg (f : E → F) (R : ℝ) {hR : 0 ≤ R} : ∫ x, f (R • x) ∂μ = (R ^ finrank ℝ E)⁻¹ • ∫ x, f x ∂μ := by rw [integral_comp_smul μ f R, abs_of_nonneg (inv_nonneg.2 (pow_nonneg hR _))] #align measure_theory.measure.integral_comp_smul_of_nonneg MeasureTheory.Measure.integral_comp_smul_of_nonneg /-- The integral of `f (R⁻¹ • x)` with respect to an additive Haar measure is a multiple of the integral of `f`. The formula we give works even when `f` is not integrable or `R = 0` thanks to the convention that a non-integrable function has integral zero. -/
Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean
97
99
theorem integral_comp_inv_smul (f : E → F) (R : ℝ) : ∫ x, f (R⁻¹ • x) ∂μ = |R ^ finrank ℝ E| • ∫ x, f x ∂μ := by
rw [integral_comp_smul μ f R⁻¹, inv_pow, inv_inv]
/- Copyright (c) 2021 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.Algebra.Category.ModuleCat.EpiMono import Mathlib.Algebra.Category.ModuleCat.Kernels import Mathlib.CategoryTheory.Subobject.WellPowered import Mathlib.CategoryTheory.Subobject.Limits #align_import algebra.category.Module.subobject from "leanprover-community/mathlib"@"6d584f1709bedbed9175bd9350df46599bdd7213" /-! # Subobjects in the category of `R`-modules We construct an explicit order isomorphism between the categorical subobjects of an `R`-module `M` and its submodules. This immediately implies that the category of `R`-modules is well-powered. -/ open CategoryTheory open CategoryTheory.Subobject open CategoryTheory.Limits open ModuleCat universe v u namespace ModuleCat set_option linter.uppercaseLean3 false -- `Module` variable {R : Type u} [Ring R] (M : ModuleCat.{v} R) /-- The categorical subobjects of a module `M` are in one-to-one correspondence with its submodules. -/ noncomputable def subobjectModule : Subobject M ≃o Submodule R M := OrderIso.symm { invFun := fun S => LinearMap.range S.arrow toFun := fun N => Subobject.mk (↾N.subtype) right_inv := fun S => Eq.symm (by fapply eq_mk_of_comm · apply LinearEquiv.toModuleIso'Left apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _) constructor · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict] rw [ker_eq_bot_of_mono] · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self] exact LinearMap.mem_range_self _ · apply LinearMap.ext intro x rfl) left_inv := fun N => by -- Porting note: The type of `↾N.subtype` was ambiguous. Not entirely sure, I made the right -- choice here convert congr_arg LinearMap.range (underlyingIso_arrow (↾N.subtype : of R { x // x ∈ N } ⟶ M)) using 1 · have : -- Porting note: added the `.toLinearEquiv.toLinearMap` (underlyingIso (↾N.subtype : of R _ ⟶ M)).inv = (underlyingIso (↾N.subtype : of R _ ⟶ M)).symm.toLinearEquiv.toLinearMap := by apply LinearMap.ext intro x rfl rw [this, comp_def, LinearEquiv.range_comp] · exact (Submodule.range_subtype _).symm map_rel_iff' := fun {S T} => by refine ⟨fun h => ?_, fun h => mk_le_mk_of_comm (↟(Submodule.inclusion h)) rfl⟩ convert LinearMap.range_comp_le_range (ofMkLEMk _ _ h) (↾T.subtype) · simpa only [← comp_def, ofMkLEMk_comp] using (Submodule.range_subtype _).symm · exact (Submodule.range_subtype _).symm } #align Module.subobject_Module ModuleCat.subobjectModule instance wellPowered_moduleCat : WellPowered (ModuleCat.{v} R) := ⟨fun M => ⟨⟨_, ⟨(subobjectModule M).toEquiv⟩⟩⟩⟩ #align Module.well_powered_Module ModuleCat.wellPowered_moduleCat attribute [local instance] hasKernels_moduleCat /-- Bundle an element `m : M` such that `f m = 0` as a term of `kernelSubobject f`. -/ noncomputable def toKernelSubobject {M N : ModuleCat.{v} R} {f : M ⟶ N} : LinearMap.ker f →ₗ[R] kernelSubobject f := (kernelSubobjectIso f ≪≫ ModuleCat.kernelIsoKer f).inv #align Module.to_kernel_subobject ModuleCat.toKernelSubobject @[simp] theorem toKernelSubobject_arrow {M N : ModuleCat R} {f : M ⟶ N} (x : LinearMap.ker f) : (kernelSubobject f).arrow (toKernelSubobject x) = x.1 := by -- Porting note: The whole proof was just `simp [toKernelSubobject]`. suffices ((arrow ((kernelSubobject f))) ∘ (kernelSubobjectIso f ≪≫ kernelIsoKer f).inv) x = x by convert this rw [Iso.trans_inv, ← coe_comp, Category.assoc] simp only [Category.assoc, kernelSubobject_arrow', kernelIsoKer_inv_kernel_ι] aesop_cat #align Module.to_kernel_subobject_arrow ModuleCat.toKernelSubobject_arrow /-- An extensionality lemma showing that two elements of a cokernel by an image are equal if they differ by an element of the image. The application is for homology: two elements in homology are equal if they differ by a boundary. -/ -- Porting note (#11215): TODO compiler complains that this is marked with `@[ext]`. -- Should this be changed? -- @[ext] this is no longer an ext lemma under the current interpretation see eg -- the conversation beginning at -- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/ -- Goal.20state.20not.20updating.2C.20bugs.2C.20etc.2E/near/338456803
Mathlib/Algebra/Category/ModuleCat/Subobject.lean
111
120
theorem cokernel_π_imageSubobject_ext {L M N : ModuleCat.{v} R} (f : L ⟶ M) [HasImage f] (g : (imageSubobject f : ModuleCat.{v} R) ⟶ N) [HasCokernel g] {x y : N} (l : L) (w : x = y + g (factorThruImageSubobject f l)) : cokernel.π g x = cokernel.π g y := by
subst w -- Porting note: The proof from here used to just be `simp`. simp only [map_add, add_right_eq_self] change ((cokernel.π g) ∘ (g) ∘ (factorThruImageSubobject f)) l = 0 rw [← coe_comp, ← coe_comp, Category.assoc] simp only [cokernel.condition, comp_zero] rfl
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov -/ import Mathlib.Algebra.Module.Equiv import Mathlib.Algebra.Module.Submodule.Basic import Mathlib.Algebra.PUnitInstances import Mathlib.Data.Set.Subsingleton #align_import algebra.module.submodule.lattice from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # The lattice structure on `Submodule`s This file defines the lattice structure on submodules, `Submodule.CompleteLattice`, with `⊥` defined as `{0}` and `⊓` defined as intersection of the underlying carrier. If `p` and `q` are submodules of a module, `p ≤ q` means that `p ⊆ q`. Many results about operations on this lattice structure are defined in `LinearAlgebra/Basic.lean`, most notably those which use `span`. ## Implementation notes This structure should match the `AddSubmonoid.CompleteLattice` structure, and we should try to unify the APIs where possible. -/ universe v variable {R S M : Type*} section AddCommMonoid variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M] [Module S M] variable [SMul S R] [IsScalarTower S R M] variable {p q : Submodule R M} namespace Submodule /-! ## Bottom element of a submodule -/ /-- The set `{0}` is the bottom element of the lattice of submodules. -/ instance : Bot (Submodule R M) := ⟨{ (⊥ : AddSubmonoid M) with carrier := {0} smul_mem' := by simp }⟩ instance inhabited' : Inhabited (Submodule R M) := ⟨⊥⟩ #align submodule.inhabited' Submodule.inhabited' @[simp] theorem bot_coe : ((⊥ : Submodule R M) : Set M) = {0} := rfl #align submodule.bot_coe Submodule.bot_coe @[simp] theorem bot_toAddSubmonoid : (⊥ : Submodule R M).toAddSubmonoid = ⊥ := rfl #align submodule.bot_to_add_submonoid Submodule.bot_toAddSubmonoid @[simp] lemma bot_toAddSubgroup {R M} [Ring R] [AddCommGroup M] [Module R M] : (⊥ : Submodule R M).toAddSubgroup = ⊥ := rfl variable (R) in @[simp] theorem mem_bot {x : M} : x ∈ (⊥ : Submodule R M) ↔ x = 0 := Set.mem_singleton_iff #align submodule.mem_bot Submodule.mem_bot instance uniqueBot : Unique (⊥ : Submodule R M) := ⟨inferInstance, fun x ↦ Subtype.ext <| (mem_bot R).1 x.mem⟩ #align submodule.unique_bot Submodule.uniqueBot instance : OrderBot (Submodule R M) where bot := ⊥ bot_le p x := by simp (config := { contextual := true }) [zero_mem] protected theorem eq_bot_iff (p : Submodule R M) : p = ⊥ ↔ ∀ x ∈ p, x = (0 : M) := ⟨fun h ↦ h.symm ▸ fun _ hx ↦ (mem_bot R).mp hx, fun h ↦ eq_bot_iff.mpr fun x hx ↦ (mem_bot R).mpr (h x hx)⟩ #align submodule.eq_bot_iff Submodule.eq_bot_iff @[ext high] protected theorem bot_ext (x y : (⊥ : Submodule R M)) : x = y := by rcases x with ⟨x, xm⟩; rcases y with ⟨y, ym⟩; congr rw [(Submodule.eq_bot_iff _).mp rfl x xm] rw [(Submodule.eq_bot_iff _).mp rfl y ym] #align submodule.bot_ext Submodule.bot_ext protected theorem ne_bot_iff (p : Submodule R M) : p ≠ ⊥ ↔ ∃ x ∈ p, x ≠ (0 : M) := by simp only [ne_eq, p.eq_bot_iff, not_forall, exists_prop] #align submodule.ne_bot_iff Submodule.ne_bot_iff theorem nonzero_mem_of_bot_lt {p : Submodule R M} (bot_lt : ⊥ < p) : ∃ a : p, a ≠ 0 := let ⟨b, hb₁, hb₂⟩ := p.ne_bot_iff.mp bot_lt.ne' ⟨⟨b, hb₁⟩, hb₂ ∘ congr_arg Subtype.val⟩ #align submodule.nonzero_mem_of_bot_lt Submodule.nonzero_mem_of_bot_lt theorem exists_mem_ne_zero_of_ne_bot {p : Submodule R M} (h : p ≠ ⊥) : ∃ b : M, b ∈ p ∧ b ≠ 0 := let ⟨b, hb₁, hb₂⟩ := p.ne_bot_iff.mp h ⟨b, hb₁, hb₂⟩ #align submodule.exists_mem_ne_zero_of_ne_bot Submodule.exists_mem_ne_zero_of_ne_bot -- FIXME: we default PUnit to PUnit.{1} here without the explicit universe annotation /-- The bottom submodule is linearly equivalent to punit as an `R`-module. -/ @[simps] def botEquivPUnit : (⊥ : Submodule R M) ≃ₗ[R] PUnit.{v+1} where toFun _ := PUnit.unit invFun _ := 0 map_add' _ _ := rfl map_smul' _ _ := rfl left_inv _ := Subsingleton.elim _ _ right_inv _ := rfl #align submodule.bot_equiv_punit Submodule.botEquivPUnit theorem subsingleton_iff_eq_bot : Subsingleton p ↔ p = ⊥ := by rw [subsingleton_iff, Submodule.eq_bot_iff] refine ⟨fun h x hx ↦ by simpa using h ⟨x, hx⟩ ⟨0, p.zero_mem⟩, fun h ⟨x, hx⟩ ⟨y, hy⟩ ↦ by simp [h x hx, h y hy]⟩ theorem eq_bot_of_subsingleton [Subsingleton p] : p = ⊥ := subsingleton_iff_eq_bot.mp inferInstance #align submodule.eq_bot_of_subsingleton Submodule.eq_bot_of_subsingleton
Mathlib/Algebra/Module/Submodule/Lattice.lean
131
132
theorem nontrivial_iff_ne_bot : Nontrivial p ↔ p ≠ ⊥ := by
rw [iff_not_comm, not_nontrivial_iff_subsingleton, subsingleton_iff_eq_bot]
/- Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura, Jeremy Avigad, Mario Carneiro -/ import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Nat.Prime import Mathlib.Data.List.Prime import Mathlib.Data.List.Sort import Mathlib.Data.List.Chain #align_import data.nat.factors from "leanprover-community/mathlib"@"008205aa645b3f194c1da47025c5f110c8406eab" /-! # Prime numbers This file deals with the factors of natural numbers. ## Important declarations - `Nat.factors n`: the prime factorization of `n` - `Nat.factors_unique`: uniqueness of the prime factorisation -/ open Bool Subtype open Nat namespace Nat attribute [instance 0] instBEqNat /-- `factors n` is the prime factorization of `n`, listed in increasing order. -/ def factors : ℕ → List ℕ | 0 => [] | 1 => [] | k + 2 => let m := minFac (k + 2) m :: factors ((k + 2) / m) decreasing_by show (k + 2) / m < (k + 2); exact factors_lemma #align nat.factors Nat.factors @[simp] theorem factors_zero : factors 0 = [] := by rw [factors] #align nat.factors_zero Nat.factors_zero @[simp] theorem factors_one : factors 1 = [] := by rw [factors] #align nat.factors_one Nat.factors_one @[simp] theorem factors_two : factors 2 = [2] := by simp [factors] theorem prime_of_mem_factors {n : ℕ} : ∀ {p : ℕ}, (h : p ∈ factors n) → Prime p := by match n with | 0 => simp | 1 => simp | k + 2 => intro p h let m := minFac (k + 2) have : (k + 2) / m < (k + 2) := factors_lemma have h₁ : p = m ∨ p ∈ factors ((k + 2) / m) := List.mem_cons.1 (by rwa [factors] at h) exact Or.casesOn h₁ (fun h₂ => h₂.symm ▸ minFac_prime (by simp)) prime_of_mem_factors #align nat.prime_of_mem_factors Nat.prime_of_mem_factors theorem pos_of_mem_factors {n p : ℕ} (h : p ∈ factors n) : 0 < p := Prime.pos (prime_of_mem_factors h) #align nat.pos_of_mem_factors Nat.pos_of_mem_factors theorem prod_factors : ∀ {n}, n ≠ 0 → List.prod (factors n) = n | 0 => by simp | 1 => by simp | k + 2 => fun _ => let m := minFac (k + 2) have : (k + 2) / m < (k + 2) := factors_lemma show (factors (k + 2)).prod = (k + 2) by have h₁ : (k + 2) / m ≠ 0 := fun h => by have : (k + 2) = 0 * m := (Nat.div_eq_iff_eq_mul_left (minFac_pos _) (minFac_dvd _)).1 h rw [zero_mul] at this; exact (show k + 2 ≠ 0 by simp) this rw [factors, List.prod_cons, prod_factors h₁, Nat.mul_div_cancel' (minFac_dvd _)] #align nat.prod_factors Nat.prod_factors theorem factors_prime {p : ℕ} (hp : Nat.Prime p) : p.factors = [p] := by have : p = p - 2 + 2 := (tsub_eq_iff_eq_add_of_le hp.two_le).mp rfl rw [this, Nat.factors] simp only [Eq.symm this] have : Nat.minFac p = p := (Nat.prime_def_minFac.mp hp).2 simp only [this, Nat.factors, Nat.div_self (Nat.Prime.pos hp)] #align nat.factors_prime Nat.factors_prime theorem factors_chain {n : ℕ} : ∀ {a}, (∀ p, Prime p → p ∣ n → a ≤ p) → List.Chain (· ≤ ·) a (factors n) := by match n with | 0 => simp | 1 => simp | k + 2 => intro a h let m := minFac (k + 2) have : (k + 2) / m < (k + 2) := factors_lemma rw [factors] refine List.Chain.cons ((le_minFac.2 h).resolve_left (by simp)) (factors_chain ?_) exact fun p pp d => minFac_le_of_dvd pp.two_le (d.trans <| div_dvd_of_dvd <| minFac_dvd _) #align nat.factors_chain Nat.factors_chain theorem factors_chain_2 (n) : List.Chain (· ≤ ·) 2 (factors n) := factors_chain fun _ pp _ => pp.two_le #align nat.factors_chain_2 Nat.factors_chain_2 theorem factors_chain' (n) : List.Chain' (· ≤ ·) (factors n) := @List.Chain'.tail _ _ (_ :: _) (factors_chain_2 _) #align nat.factors_chain' Nat.factors_chain' theorem factors_sorted (n : ℕ) : List.Sorted (· ≤ ·) (factors n) := List.chain'_iff_pairwise.1 (factors_chain' _) #align nat.factors_sorted Nat.factors_sorted /-- `factors` can be constructed inductively by extracting `minFac`, for sufficiently large `n`. -/ theorem factors_add_two (n : ℕ) : factors (n + 2) = minFac (n + 2) :: factors ((n + 2) / minFac (n + 2)) := by rw [factors] #align nat.factors_add_two Nat.factors_add_two @[simp] theorem factors_eq_nil (n : ℕ) : n.factors = [] ↔ n = 0 ∨ n = 1 := by constructor <;> intro h · rcases n with (_ | _ | n) · exact Or.inl rfl · exact Or.inr rfl · rw [factors] at h injection h · rcases h with (rfl | rfl) · exact factors_zero · exact factors_one #align nat.factors_eq_nil Nat.factors_eq_nil open scoped List in
Mathlib/Data/Nat/Factors.lean
138
139
theorem eq_of_perm_factors {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) (h : a.factors ~ b.factors) : a = b := by
simpa [prod_factors ha, prod_factors hb] using List.Perm.prod_eq h
/- Copyright (c) 2021 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.RingTheory.RingHomProperties import Mathlib.RingTheory.IntegralClosure #align_import ring_theory.ring_hom.integral from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0" /-! # The meta properties of integral ring homomorphisms. -/ namespace RingHom open scoped TensorProduct open TensorProduct Algebra.TensorProduct theorem isIntegral_stableUnderComposition : StableUnderComposition fun f => f.IsIntegral := by introv R hf hg; exact hf.trans _ _ hg #align ring_hom.is_integral_stable_under_composition RingHom.isIntegral_stableUnderComposition theorem isIntegral_respectsIso : RespectsIso fun f => f.IsIntegral := by apply isIntegral_stableUnderComposition.respectsIso introv x rw [← e.apply_symm_apply x] apply RingHom.isIntegralElem_map #align ring_hom.is_integral_respects_iso RingHom.isIntegral_respectsIso
Mathlib/RingTheory/RingHom/Integral.lean
35
41
theorem isIntegral_stableUnderBaseChange : StableUnderBaseChange fun f => f.IsIntegral := by
refine StableUnderBaseChange.mk _ isIntegral_respectsIso ?_ introv h x refine TensorProduct.induction_on x ?_ ?_ ?_ · apply isIntegral_zero · intro x y; exact IsIntegral.tmul x (h y) · intro x y hx hy; exact IsIntegral.add hx hy
/- 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.Support import Mathlib.Algebra.Polynomial.Basic import Mathlib.Algebra.Regular.Basic import Mathlib.Data.Nat.Choose.Sum #align_import data.polynomial.coeff from "leanprover-community/mathlib"@"2651125b48fc5c170ab1111afd0817c903b1fc6c" /-! # Theory of univariate polynomials The theorems include formulas for computing coefficients, such as `coeff_add`, `coeff_sum`, `coeff_mul` -/ set_option linter.uppercaseLean3 false noncomputable section open Finsupp Finset AddMonoidAlgebra open Polynomial namespace Polynomial universe u v variable {R : Type u} {S : Type v} {a b : R} {n m : ℕ} variable [Semiring R] {p q r : R[X]} section Coeff @[simp] theorem coeff_add (p q : R[X]) (n : ℕ) : coeff (p + q) n = coeff p n + coeff q n := by rcases p with ⟨⟩ rcases q with ⟨⟩ simp_rw [← ofFinsupp_add, coeff] exact Finsupp.add_apply _ _ _ #align polynomial.coeff_add Polynomial.coeff_add set_option linter.deprecated false in @[simp] theorem coeff_bit0 (p : R[X]) (n : ℕ) : coeff (bit0 p) n = bit0 (coeff p n) := by simp [bit0] #align polynomial.coeff_bit0 Polynomial.coeff_bit0 @[simp] theorem coeff_smul [SMulZeroClass S R] (r : S) (p : R[X]) (n : ℕ) : coeff (r • p) n = r • coeff p n := by rcases p with ⟨⟩ simp_rw [← ofFinsupp_smul, coeff] exact Finsupp.smul_apply _ _ _ #align polynomial.coeff_smul Polynomial.coeff_smul theorem support_smul [SMulZeroClass S R] (r : S) (p : R[X]) : support (r • p) ⊆ support p := by intro i hi simp? [mem_support_iff] at hi ⊢ says simp only [mem_support_iff, coeff_smul, ne_eq] at hi ⊢ contrapose! hi simp [hi] #align polynomial.support_smul Polynomial.support_smul open scoped Pointwise in
Mathlib/Algebra/Polynomial/Coeff.lean
69
74
theorem card_support_mul_le : (p * q).support.card ≤ p.support.card * q.support.card := by
calc (p * q).support.card _ = (p.toFinsupp * q.toFinsupp).support.card := by rw [← support_toFinsupp, toFinsupp_mul] _ ≤ (p.toFinsupp.support + q.toFinsupp.support).card := Finset.card_le_card (AddMonoidAlgebra.support_mul p.toFinsupp q.toFinsupp) _ ≤ p.support.card * q.support.card := Finset.card_image₂_le ..
/- 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.MeasureTheory.Covering.VitaliFamily import Mathlib.MeasureTheory.Measure.Regular import Mathlib.MeasureTheory.Function.AEMeasurableOrder import Mathlib.MeasureTheory.Integral.Lebesgue import Mathlib.MeasureTheory.Integral.Average import Mathlib.MeasureTheory.Decomposition.Lebesgue #align_import measure_theory.covering.differentiation from "leanprover-community/mathlib"@"57ac39bd365c2f80589a700f9fbb664d3a1a30c2" /-! # Differentiation of measures On a second countable metric space with a measure `μ`, consider a Vitali family (i.e., for each `x` one has a family of sets shrinking to `x`, with a good behavior with respect to covering theorems). Consider also another measure `ρ`. Then, for almost every `x`, the ratio `ρ a / μ a` converges when `a` shrinks to `x` along the Vitali family, towards the Radon-Nikodym derivative of `ρ` with respect to `μ`. This is the main theorem on differentiation of measures. This theorem is proved in this file, under the name `VitaliFamily.ae_tendsto_rnDeriv`. Note that, almost surely, `μ a` is eventually positive and finite (see `VitaliFamily.ae_eventually_measure_pos` and `VitaliFamily.eventually_measure_lt_top`), so the ratio really makes sense. For concrete applications, one needs concrete instances of Vitali families, as provided for instance by `Besicovitch.vitaliFamily` (for balls) or by `Vitali.vitaliFamily` (for doubling measures). Specific applications to Lebesgue density points and the Lebesgue differentiation theorem are also derived: * `VitaliFamily.ae_tendsto_measure_inter_div` states that, for almost every point `x ∈ s`, then `μ (s ∩ a) / μ a` tends to `1` as `a` shrinks to `x` along a Vitali family. * `VitaliFamily.ae_tendsto_average_norm_sub` states that, for almost every point `x`, then the average of `y ↦ ‖f y - f x‖` on `a` tends to `0` as `a` shrinks to `x` along a Vitali family. ## Sketch of proof Let `v` be a Vitali family for `μ`. Assume for simplicity that `ρ` is absolutely continuous with respect to `μ`, as the case of a singular measure is easier. It is easy to see that a set `s` on which `liminf ρ a / μ a < q` satisfies `ρ s ≤ q * μ s`, by using a disjoint subcovering provided by the definition of Vitali families. Similarly for the limsup. It follows that a set on which `ρ a / μ a` oscillates has measure `0`, and therefore that `ρ a / μ a` converges almost surely (`VitaliFamily.ae_tendsto_div`). Moreover, on a set where the limit is close to a constant `c`, one gets `ρ s ∼ c μ s`, using again a covering lemma as above. It follows that `ρ` is equal to `μ.withDensity (v.limRatio ρ x)`, where `v.limRatio ρ x` is the limit of `ρ a / μ a` at `x` (which is well defined almost everywhere). By uniqueness of the Radon-Nikodym derivative, one gets `v.limRatio ρ x = ρ.rnDeriv μ x` almost everywhere, completing the proof. There is a difficulty in this sketch: this argument works well when `v.limRatio ρ` is measurable, but there is no guarantee that this is the case, especially if one doesn't make further assumptions on the Vitali family. We use an indirect argument to show that `v.limRatio ρ` is always almost everywhere measurable, again based on the disjoint subcovering argument (see `VitaliFamily.exists_measurable_supersets_limRatio`), and then proceed as sketched above but replacing `v.limRatio ρ` by a measurable version called `v.limRatioMeas ρ`. ## Counterexample The standing assumption in this file is that spaces are second countable. Without this assumption, measures may be zero locally but nonzero globally, which is not compatible with differentiation theory (which deduces global information from local one). Here is an example displaying this behavior. Define a measure `μ` by `μ s = 0` if `s` is covered by countably many balls of radius `1`, and `μ s = ∞` otherwise. This is indeed a countably additive measure, which is moreover locally finite and doubling at small scales. It vanishes on every ball of radius `1`, so all the quantities in differentiation theory (defined as ratios of measures as the radius tends to zero) make no sense. However, the measure is not globally zero if the space is big enough. ## References * [Herbert Federer, Geometric Measure Theory, Chapter 2.9][Federer1996] -/ open MeasureTheory Metric Set Filter TopologicalSpace MeasureTheory.Measure open scoped Filter ENNReal MeasureTheory NNReal Topology variable {α : Type*} [MetricSpace α] {m0 : MeasurableSpace α} {μ : Measure α} (v : VitaliFamily μ) {E : Type*} [NormedAddCommGroup E] namespace VitaliFamily /-- The limit along a Vitali family of `ρ a / μ a` where it makes sense, and garbage otherwise. Do *not* use this definition: it is only a temporary device to show that this ratio tends almost everywhere to the Radon-Nikodym derivative. -/ noncomputable def limRatio (ρ : Measure α) (x : α) : ℝ≥0∞ := limUnder (v.filterAt x) fun a => ρ a / μ a #align vitali_family.lim_ratio VitaliFamily.limRatio /-- For almost every point `x`, sufficiently small sets in a Vitali family around `x` have positive measure. (This is a nontrivial result, following from the covering property of Vitali families). -/
Mathlib/MeasureTheory/Covering/Differentiation.lean
97
113
theorem ae_eventually_measure_pos [SecondCountableTopology α] : ∀ᵐ x ∂μ, ∀ᶠ a in v.filterAt x, 0 < μ a := by
set s := {x | ¬∀ᶠ a in v.filterAt x, 0 < μ a} with hs simp (config := { zeta := false }) only [not_lt, not_eventually, nonpos_iff_eq_zero] at hs change μ s = 0 let f : α → Set (Set α) := fun _ => {a | μ a = 0} have h : v.FineSubfamilyOn f s := by intro x hx ε εpos rw [hs] at hx simp only [frequently_filterAt_iff, exists_prop, gt_iff_lt, mem_setOf_eq] at hx rcases hx ε εpos with ⟨a, a_sets, ax, μa⟩ exact ⟨a, ⟨a_sets, μa⟩, ax⟩ refine le_antisymm ?_ bot_le calc μ s ≤ ∑' x : h.index, μ (h.covering x) := h.measure_le_tsum _ = ∑' x : h.index, 0 := by congr; ext1 x; exact h.covering_mem x.2 _ = 0 := by simp only [tsum_zero, add_zero]
/- Copyright (c) 2021 Ivan Sadofschi Costa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ivan Sadofschi Costa -/ import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.fin from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # `cons` and `tail` for maps `Fin n →₀ M` We interpret maps `Fin n →₀ M` as `n`-tuples of elements of `M`, We define the following operations: * `Finsupp.tail` : the tail of a map `Fin (n + 1) →₀ M`, i.e., its last `n` entries; * `Finsupp.cons` : adding an element at the beginning of an `n`-tuple, to get an `n + 1`-tuple; In this context, we prove some usual properties of `tail` and `cons`, analogous to those of `Data.Fin.Tuple.Basic`. -/ noncomputable section namespace Finsupp variable {n : ℕ} (i : Fin n) {M : Type*} [Zero M] (y : M) (t : Fin (n + 1) →₀ M) (s : Fin n →₀ M) /-- `tail` for maps `Fin (n + 1) →₀ M`. See `Fin.tail` for more details. -/ def tail (s : Fin (n + 1) →₀ M) : Fin n →₀ M := Finsupp.equivFunOnFinite.symm (Fin.tail s) #align finsupp.tail Finsupp.tail /-- `cons` for maps `Fin n →₀ M`. See `Fin.cons` for more details. -/ def cons (y : M) (s : Fin n →₀ M) : Fin (n + 1) →₀ M := Finsupp.equivFunOnFinite.symm (Fin.cons y s : Fin (n + 1) → M) #align finsupp.cons Finsupp.cons theorem tail_apply : tail t i = t i.succ := rfl #align finsupp.tail_apply Finsupp.tail_apply @[simp] theorem cons_zero : cons y s 0 = y := rfl #align finsupp.cons_zero Finsupp.cons_zero @[simp] theorem cons_succ : cons y s i.succ = s i := -- Porting note: was Fin.cons_succ _ _ _ rfl #align finsupp.cons_succ Finsupp.cons_succ @[simp] theorem tail_cons : tail (cons y s) = s := ext fun k => by simp only [tail_apply, cons_succ] #align finsupp.tail_cons Finsupp.tail_cons @[simp] theorem cons_tail : cons (t 0) (tail t) = t := by ext a by_cases c_a : a = 0 · rw [c_a, cons_zero] · rw [← Fin.succ_pred a c_a, cons_succ, ← tail_apply] #align finsupp.cons_tail Finsupp.cons_tail @[simp]
Mathlib/Data/Finsupp/Fin.lean
68
73
theorem cons_zero_zero : cons 0 (0 : Fin n →₀ M) = 0 := by
ext a by_cases c : a = 0 · simp [c] · rw [← Fin.succ_pred a c, cons_succ] simp
/- Copyright (c) 2024 Jeremy Tan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Tan -/ import Mathlib.Analysis.SpecialFunctions.Complex.LogBounds /-! # Complex arctangent This file defines the complex arctangent `Complex.arctan` as $$\arctan z = -\frac i2 \log \frac{1 + zi}{1 - zi}$$ and shows that it extends `Real.arctan` to the complex plane. Its Taylor series expansion $$\arctan z = \frac{(-1)^n}{2n + 1} z^{2n + 1},\ |z|<1$$ is proved in `Complex.hasSum_arctan`. -/ namespace Complex open scoped Real /-- The complex arctangent, defined via the complex logarithm. -/ noncomputable def arctan (z : ℂ) : ℂ := -I / 2 * log ((1 + z * I) / (1 - z * I)) theorem tan_arctan {z : ℂ} (h₁ : z ≠ I) (h₂ : z ≠ -I) : tan (arctan z) = z := by unfold tan sin cos rw [div_div_eq_mul_div, div_mul_cancel₀ _ two_ne_zero, ← div_mul_eq_mul_div, -- multiply top and bottom by `exp (arctan z * I)` ← mul_div_mul_right _ _ (exp_ne_zero (arctan z * I)), sub_mul, add_mul, ← exp_add, neg_mul, add_left_neg, exp_zero, ← exp_add, ← two_mul] have z₁ : 1 + z * I ≠ 0 := by contrapose! h₁ rw [add_eq_zero_iff_neg_eq, ← div_eq_iff I_ne_zero, div_I, neg_one_mul, neg_neg] at h₁ exact h₁.symm have z₂ : 1 - z * I ≠ 0 := by contrapose! h₂ rw [sub_eq_zero, ← div_eq_iff I_ne_zero, div_I, one_mul] at h₂ exact h₂.symm have key : exp (2 * (arctan z * I)) = (1 + z * I) / (1 - z * I) := by rw [arctan, ← mul_rotate, ← mul_assoc, show 2 * (I * (-I / 2)) = 1 by field_simp, one_mul, exp_log] · exact div_ne_zero z₁ z₂ -- multiply top and bottom by `1 - z * I` rw [key, ← mul_div_mul_right _ _ z₂, sub_mul, add_mul, div_mul_cancel₀ _ z₂, one_mul, show _ / _ * I = -(I * I) * z by ring, I_mul_I, neg_neg, one_mul] /-- `cos z` is nonzero when the bounds in `arctan_tan` are met (`z` lies in the vertical strip `-π / 2 < z.re < π / 2` and `z ≠ π / 2`). -/ lemma cos_ne_zero_of_arctan_bounds {z : ℂ} (h₀ : z ≠ π / 2) (h₁ : -(π / 2) < z.re) (h₂ : z.re ≤ π / 2) : cos z ≠ 0 := by refine cos_ne_zero_iff.mpr (fun k ↦ ?_) rw [ne_eq, ext_iff, not_and_or] at h₀ ⊢ norm_cast at h₀ ⊢ cases' h₀ with nr ni · left; contrapose! nr rw [nr, mul_div_assoc, neg_eq_neg_one_mul, mul_lt_mul_iff_of_pos_right (by positivity)] at h₁ rw [nr, ← one_mul (π / 2), mul_div_assoc, mul_le_mul_iff_of_pos_right (by positivity)] at h₂ norm_cast at h₁ h₂ change -1 < _ at h₁ rwa [show 2 * k + 1 = 1 by omega, Int.cast_one, one_mul] at nr · exact Or.inr ni
Mathlib/Analysis/SpecialFunctions/Complex/Arctan.lean
64
77
theorem arctan_tan {z : ℂ} (h₀ : z ≠ π / 2) (h₁ : -(π / 2) < z.re) (h₂ : z.re ≤ π / 2) : arctan (tan z) = z := by
have h := cos_ne_zero_of_arctan_bounds h₀ h₁ h₂ unfold arctan tan -- multiply top and bottom by `cos z` rw [← mul_div_mul_right (1 + _) _ h, add_mul, sub_mul, one_mul, ← mul_rotate, mul_div_cancel₀ _ h] conv_lhs => enter [2, 1, 2] rw [sub_eq_add_neg, ← neg_mul, ← sin_neg, ← cos_neg] rw [← exp_mul_I, ← exp_mul_I, ← exp_sub, show z * I - -z * I = 2 * (I * z) by ring, log_exp, show -I / 2 * (2 * (I * z)) = -(I * I) * z by ring, I_mul_I, neg_neg, one_mul] all_goals set_option tactic.skipAssignedInstances false in norm_num · rwa [← div_lt_iff' two_pos, neg_div] · rwa [← le_div_iff' two_pos]
/- Copyright (c) 2020 Aaron Anderson, Jalex Stark. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jalex Stark -/ import Mathlib.Algebra.Polynomial.Expand import Mathlib.Algebra.Polynomial.Laurent import Mathlib.LinearAlgebra.Matrix.Charpoly.Basic import Mathlib.LinearAlgebra.Matrix.Reindex import Mathlib.RingTheory.Polynomial.Nilpotent #align_import linear_algebra.matrix.charpoly.coeff from "leanprover-community/mathlib"@"9745b093210e9dac443af24da9dba0f9e2b6c912" /-! # Characteristic polynomials We give methods for computing coefficients of the characteristic polynomial. ## Main definitions - `Matrix.charpoly_degree_eq_dim` proves that the degree of the characteristic polynomial over a nonzero ring is the dimension of the matrix - `Matrix.det_eq_sign_charpoly_coeff` proves that the determinant is the constant term of the characteristic polynomial, up to sign. - `Matrix.trace_eq_neg_charpoly_coeff` proves that the trace is the negative of the (d-1)th coefficient of the characteristic polynomial, where d is the dimension of the matrix. For a nonzero ring, this is the second-highest coefficient. - `Matrix.charpolyRev` the reverse of the characteristic polynomial. - `Matrix.reverse_charpoly` characterises the reverse of the characteristic polynomial. -/ noncomputable section -- porting note: whenever there was `∏ i : n, X - C (M i i)`, I replaced it with -- `∏ i : n, (X - C (M i i))`, since otherwise Lean would parse as `(∏ i : n, X) - C (M i i)` universe u v w z open Finset Matrix Polynomial variable {R : Type u} [CommRing R] variable {n G : Type v} [DecidableEq n] [Fintype n] variable {α β : Type v} [DecidableEq α] variable {M : Matrix n n R} namespace Matrix theorem charmatrix_apply_natDegree [Nontrivial R] (i j : n) : (charmatrix M i j).natDegree = ite (i = j) 1 0 := by by_cases h : i = j <;> simp [h, ← degree_eq_iff_natDegree_eq_of_pos (Nat.succ_pos 0)] #align charmatrix_apply_nat_degree Matrix.charmatrix_apply_natDegree theorem charmatrix_apply_natDegree_le (i j : n) : (charmatrix M i j).natDegree ≤ ite (i = j) 1 0 := by split_ifs with h <;> simp [h, natDegree_X_le] #align charmatrix_apply_nat_degree_le Matrix.charmatrix_apply_natDegree_le variable (M) theorem charpoly_sub_diagonal_degree_lt : (M.charpoly - ∏ i : n, (X - C (M i i))).degree < ↑(Fintype.card n - 1) := by rw [charpoly, det_apply', ← insert_erase (mem_univ (Equiv.refl n)), sum_insert (not_mem_erase (Equiv.refl n) univ), add_comm] simp only [charmatrix_apply_eq, one_mul, Equiv.Perm.sign_refl, id, Int.cast_one, Units.val_one, add_sub_cancel_right, Equiv.coe_refl] rw [← mem_degreeLT] apply Submodule.sum_mem (degreeLT R (Fintype.card n - 1)) intro c hc; rw [← C_eq_intCast, C_mul'] apply Submodule.smul_mem (degreeLT R (Fintype.card n - 1)) ↑↑(Equiv.Perm.sign c) rw [mem_degreeLT] apply lt_of_le_of_lt degree_le_natDegree _ rw [Nat.cast_lt] apply lt_of_le_of_lt _ (Equiv.Perm.fixed_point_card_lt_of_ne_one (ne_of_mem_erase hc)) apply le_trans (Polynomial.natDegree_prod_le univ fun i : n => charmatrix M (c i) i) _ rw [card_eq_sum_ones]; rw [sum_filter]; apply sum_le_sum intros apply charmatrix_apply_natDegree_le #align matrix.charpoly_sub_diagonal_degree_lt Matrix.charpoly_sub_diagonal_degree_lt
Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean
81
86
theorem charpoly_coeff_eq_prod_coeff_of_le {k : ℕ} (h : Fintype.card n - 1 ≤ k) : M.charpoly.coeff k = (∏ i : n, (X - C (M i i))).coeff k := by
apply eq_of_sub_eq_zero; rw [← coeff_sub] apply Polynomial.coeff_eq_zero_of_degree_lt apply lt_of_lt_of_le (charpoly_sub_diagonal_degree_lt M) ?_ rw [Nat.cast_le]; apply h
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Finset.Sum import Mathlib.Data.Sum.Order import Mathlib.Order.Interval.Finset.Defs #align_import data.sum.interval from "leanprover-community/mathlib"@"48a058d7e39a80ed56858505719a0b2197900999" /-! # Finite intervals in a disjoint union This file provides the `LocallyFiniteOrder` instance for the disjoint sum and linear sum of two orders and calculates the cardinality of their finite intervals. -/ open Function Sum namespace Finset variable {α₁ α₂ β₁ β₂ γ₁ γ₂ : Type*} section SumLift₂ variable (f f₁ g₁ : α₁ → β₁ → Finset γ₁) (g f₂ g₂ : α₂ → β₂ → Finset γ₂) /-- Lifts maps `α₁ → β₁ → Finset γ₁` and `α₂ → β₂ → Finset γ₂` to a map `α₁ ⊕ α₂ → β₁ ⊕ β₂ → Finset (γ₁ ⊕ γ₂)`. Could be generalized to `Alternative` functors if we can make sure to keep computability and universe polymorphism. -/ @[simp] def sumLift₂ : ∀ (_ : Sum α₁ α₂) (_ : Sum β₁ β₂), Finset (Sum γ₁ γ₂) | inl a, inl b => (f a b).map Embedding.inl | inl _, inr _ => ∅ | inr _, inl _ => ∅ | inr a, inr b => (g a b).map Embedding.inr #align finset.sum_lift₂ Finset.sumLift₂ variable {f f₁ g₁ g f₂ g₂} {a : Sum α₁ α₂} {b : Sum β₁ β₂} {c : Sum γ₁ γ₂} theorem mem_sumLift₂ : c ∈ sumLift₂ f g a b ↔ (∃ a₁ b₁ c₁, a = inl a₁ ∧ b = inl b₁ ∧ c = inl c₁ ∧ c₁ ∈ f a₁ b₁) ∨ ∃ a₂ b₂ c₂, a = inr a₂ ∧ b = inr b₂ ∧ c = inr c₂ ∧ c₂ ∈ g a₂ b₂ := by constructor · cases' a with a a <;> cases' b with b b · rw [sumLift₂, mem_map] rintro ⟨c, hc, rfl⟩ exact Or.inl ⟨a, b, c, rfl, rfl, rfl, hc⟩ · refine fun h ↦ (not_mem_empty _ h).elim · refine fun h ↦ (not_mem_empty _ h).elim · rw [sumLift₂, mem_map] rintro ⟨c, hc, rfl⟩ exact Or.inr ⟨a, b, c, rfl, rfl, rfl, hc⟩ · rintro (⟨a, b, c, rfl, rfl, rfl, h⟩ | ⟨a, b, c, rfl, rfl, rfl, h⟩) <;> exact mem_map_of_mem _ h #align finset.mem_sum_lift₂ Finset.mem_sumLift₂ theorem inl_mem_sumLift₂ {c₁ : γ₁} : inl c₁ ∈ sumLift₂ f g a b ↔ ∃ a₁ b₁, a = inl a₁ ∧ b = inl b₁ ∧ c₁ ∈ f a₁ b₁ := by rw [mem_sumLift₂, or_iff_left] · simp only [inl.injEq, exists_and_left, exists_eq_left'] rintro ⟨_, _, c₂, _, _, h, _⟩ exact inl_ne_inr h #align finset.inl_mem_sum_lift₂ Finset.inl_mem_sumLift₂ theorem inr_mem_sumLift₂ {c₂ : γ₂} : inr c₂ ∈ sumLift₂ f g a b ↔ ∃ a₂ b₂, a = inr a₂ ∧ b = inr b₂ ∧ c₂ ∈ g a₂ b₂ := by rw [mem_sumLift₂, or_iff_right] · simp only [inr.injEq, exists_and_left, exists_eq_left'] rintro ⟨_, _, c₂, _, _, h, _⟩ exact inr_ne_inl h #align finset.inr_mem_sum_lift₂ Finset.inr_mem_sumLift₂ theorem sumLift₂_eq_empty : sumLift₂ f g a b = ∅ ↔ (∀ a₁ b₁, a = inl a₁ → b = inl b₁ → f a₁ b₁ = ∅) ∧ ∀ a₂ b₂, a = inr a₂ → b = inr b₂ → g a₂ b₂ = ∅ := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · constructor <;> · rintro a b rfl rfl exact map_eq_empty.1 h cases a <;> cases b · exact map_eq_empty.2 (h.1 _ _ rfl rfl) · rfl · rfl · exact map_eq_empty.2 (h.2 _ _ rfl rfl) #align finset.sum_lift₂_eq_empty Finset.sumLift₂_eq_empty
Mathlib/Data/Sum/Interval.lean
91
95
theorem sumLift₂_nonempty : (sumLift₂ f g a b).Nonempty ↔ (∃ a₁ b₁, a = inl a₁ ∧ b = inl b₁ ∧ (f a₁ b₁).Nonempty) ∨ ∃ a₂ b₂, a = inr a₂ ∧ b = inr b₂ ∧ (g a₂ b₂).Nonempty := by
simp only [nonempty_iff_ne_empty, Ne, sumLift₂_eq_empty, not_and_or, not_forall, exists_prop]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Kenny Lau, Scott Morrison -/ import Mathlib.Data.List.Chain import Mathlib.Data.List.Enum import Mathlib.Data.List.Nodup import Mathlib.Data.List.Pairwise import Mathlib.Data.List.Zip #align_import data.list.range from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" /-! # Ranges of naturals as lists This file shows basic results about `List.iota`, `List.range`, `List.range'` and defines `List.finRange`. `finRange n` is the list of elements of `Fin n`. `iota n = [n, n - 1, ..., 1]` and `range n = [0, ..., n - 1]` are basic list constructions used for tactics. `range' a b = [a, ..., a + b - 1]` is there to help prove properties about them. Actual maths should use `List.Ico` instead. -/ set_option autoImplicit true universe u open Nat namespace List variable {α : Type u} @[simp] theorem range'_one {step} : range' s 1 step = [s] := rfl #align list.length_range' List.length_range' #align list.range'_eq_nil List.range'_eq_nil #align list.mem_range' List.mem_range'_1 #align list.map_add_range' List.map_add_range' #align list.map_sub_range' List.map_sub_range' #align list.chain_succ_range' List.chain_succ_range' #align list.chain_lt_range' List.chain_lt_range' theorem pairwise_lt_range' : ∀ s n (step := 1) (_ : 0 < step := by simp), Pairwise (· < ·) (range' s n step) | _, 0, _, _ => Pairwise.nil | s, n + 1, _, h => chain_iff_pairwise.1 (chain_lt_range' s n h) #align list.pairwise_lt_range' List.pairwise_lt_range' theorem nodup_range' (s n : ℕ) (step := 1) (h : 0 < step := by simp) : Nodup (range' s n step) := (pairwise_lt_range' s n step h).imp _root_.ne_of_lt #align list.nodup_range' List.nodup_range' #align list.range'_append List.range'_append #align list.range'_sublist_right List.range'_sublist_right #align list.range'_subset_right List.range'_subset_right #align list.nth_range' List.get?_range' set_option linter.deprecated false in @[simp] theorem nthLe_range' {n m step} (i) (H : i < (range' n m step).length) : nthLe (range' n m step) i H = n + step * i := get_range' i H set_option linter.deprecated false in theorem nthLe_range'_1 {n m} (i) (H : i < (range' n m).length) : nthLe (range' n m) i H = n + i := by simp #align list.nth_le_range' List.nthLe_range'_1 #align list.range'_concat List.range'_concat #align list.range_core List.range.loop #align list.range_core_range' List.range_loop_range' #align list.range_eq_range' List.range_eq_range' #align list.range_succ_eq_map List.range_succ_eq_map #align list.range'_eq_map_range List.range'_eq_map_range #align list.length_range List.length_range #align list.range_eq_nil List.range_eq_nil theorem pairwise_lt_range (n : ℕ) : Pairwise (· < ·) (range n) := by simp (config := {decide := true}) only [range_eq_range', pairwise_lt_range'] #align list.pairwise_lt_range List.pairwise_lt_range theorem pairwise_le_range (n : ℕ) : Pairwise (· ≤ ·) (range n) := Pairwise.imp (@le_of_lt ℕ _) (pairwise_lt_range _) #align list.pairwise_le_range List.pairwise_le_range theorem take_range (m n : ℕ) : take m (range n) = range (min m n) := by apply List.ext_get · simp · simp (config := { contextual := true }) [← get_take, Nat.lt_min] theorem nodup_range (n : ℕ) : Nodup (range n) := by simp (config := {decide := true}) only [range_eq_range', nodup_range'] #align list.nodup_range List.nodup_range #align list.range_sublist List.range_sublist #align list.range_subset List.range_subset #align list.mem_range List.mem_range #align list.not_mem_range_self List.not_mem_range_self #align list.self_mem_range_succ List.self_mem_range_succ #align list.nth_range List.get?_range #align list.range_succ List.range_succ #align list.range_zero List.range_zero
Mathlib/Data/List/Range.lean
104
112
theorem chain'_range_succ (r : ℕ → ℕ → Prop) (n : ℕ) : Chain' r (range n.succ) ↔ ∀ m < n, r m m.succ := by
rw [range_succ] induction' n with n hn · simp · rw [range_succ] simp only [append_assoc, singleton_append, chain'_append_cons_cons, chain'_singleton, and_true_iff] rw [hn, forall_lt_succ]
/- 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.Dimension.Finrank import Mathlib.LinearAlgebra.InvariantBasisNumber #align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5" /-! # Lemmas about rank and finrank in rings satisfying strong rank condition. ## Main statements For modules over rings satisfying the rank condition * `Basis.le_span`: the cardinality of a basis is bounded by the cardinality of any spanning set For modules over rings satisfying the strong rank condition * `linearIndependent_le_span`: For any linearly independent family `v : ι → M` and any finite spanning set `w : Set M`, the cardinality of `ι` is bounded by the cardinality of `w`. * `linearIndependent_le_basis`: If `b` is a basis for a module `M`, and `s` is a linearly independent set, then the cardinality of `s` is bounded by the cardinality of `b`. For modules over rings with invariant basis number (including all commutative rings and all noetherian rings) * `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same cardinality. -/ noncomputable section universe u v w w' variable {R : Type u} {M : Type v} [Ring R] [AddCommGroup M] [Module R M] variable {ι : Type w} {ι' : Type w'} open Cardinal Basis Submodule Function Set attribute [local instance] nontrivial_of_invariantBasisNumber section InvariantBasisNumber variable [InvariantBasisNumber R] /-- The dimension theorem: if `v` and `v'` are two bases, their index types have the same cardinalities. -/
Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean
58
83
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) : Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
classical haveI := nontrivial_of_invariantBasisNumber R cases fintypeOrInfinite ι · -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`. -- haveI : Finite (range v) := Set.finite_range v haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v' cases nonempty_fintype ι' -- We clean up a little: rw [Cardinal.mk_fintype, Cardinal.mk_fintype] simp only [Cardinal.lift_natCast, Cardinal.natCast_inj] -- Now we can use invariant basis number to show they have the same cardinality. apply card_eq_of_linearEquiv R exact (Finsupp.linearEquivFunOnFinite R R ι).symm.trans v.repr.symm ≪≫ₗ v'.repr ≪≫ₗ Finsupp.linearEquivFunOnFinite R R ι' · -- `v` is an infinite basis, -- so by `infinite_basis_le_maximal_linearIndependent`, `v'` is at least as big, -- and then applying `infinite_basis_le_maximal_linearIndependent` again -- we see they have the same cardinality. have w₁ := infinite_basis_le_maximal_linearIndependent' v _ v'.linearIndependent v'.maximal rcases Cardinal.lift_mk_le'.mp w₁ with ⟨f⟩ haveI : Infinite ι' := Infinite.of_injective f f.2 have w₂ := infinite_basis_le_maximal_linearIndependent' v' _ v.linearIndependent v.maximal exact le_antisymm w₁ w₂
/- 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, Mitchell Rowett, Scott Morrison, Johan Commelin, Mario Carneiro, Michael Howes -/ import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Deprecated.Submonoid #align_import deprecated.subgroup from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6" /-! # Unbundled subgroups (deprecated) This file is deprecated, and is no longer imported by anything in mathlib other than other deprecated files, and test files. You should not need to import it. This file defines unbundled multiplicative and additive subgroups. Instead of using this file, please use `Subgroup G` and `AddSubgroup A`, defined in `Mathlib.Algebra.Group.Subgroup.Basic`. ## Main definitions `IsAddSubgroup (S : Set A)` : the predicate that `S` is the underlying subset of an additive subgroup of `A`. The bundled variant `AddSubgroup A` should be used in preference to this. `IsSubgroup (S : Set G)` : the predicate that `S` is the underlying subset of a subgroup of `G`. The bundled variant `Subgroup G` should be used in preference to this. ## Tags subgroup, subgroups, IsSubgroup -/ open Set Function variable {G : Type*} {H : Type*} {A : Type*} {a a₁ a₂ b c : G} section Group variable [Group G] [AddGroup A] /-- `s` is an additive subgroup: a set containing 0 and closed under addition and negation. -/ structure IsAddSubgroup (s : Set A) extends IsAddSubmonoid s : Prop where /-- The proposition that `s` is closed under negation. -/ neg_mem {a} : a ∈ s → -a ∈ s #align is_add_subgroup IsAddSubgroup /-- `s` is a subgroup: a set containing 1 and closed under multiplication and inverse. -/ @[to_additive] structure IsSubgroup (s : Set G) extends IsSubmonoid s : Prop where /-- The proposition that `s` is closed under inverse. -/ inv_mem {a} : a ∈ s → a⁻¹ ∈ s #align is_subgroup IsSubgroup @[to_additive]
Mathlib/Deprecated/Subgroup.lean
57
58
theorem IsSubgroup.div_mem {s : Set G} (hs : IsSubgroup s) {x y : G} (hx : x ∈ s) (hy : y ∈ s) : x / y ∈ s := by
simpa only [div_eq_mul_inv] using hs.mul_mem hx (hs.inv_mem hy)
/- Copyright (c) 2021 Alex J. Best. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alex J. Best, Yaël Dillies -/ import Mathlib.Algebra.Bounds import Mathlib.Algebra.Order.Field.Basic -- Porting note: `LinearOrderedField`, etc import Mathlib.Data.Set.Pointwise.SMul #align_import algebra.order.pointwise from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Pointwise operations on ordered algebraic objects This file contains lemmas about the effect of pointwise operations on sets with an order structure. ## TODO `sSup (s • t) = sSup s • sSup t` and `sInf (s • t) = sInf s • sInf t` hold as well but `CovariantClass` is currently not polymorphic enough to state it. -/ open Function Set open Pointwise variable {α : Type*} -- Porting note: Swapped the place of `CompleteLattice` and `ConditionallyCompleteLattice` -- due to simpNF problem between `sSup_xx` `csSup_xx`. section CompleteLattice variable [CompleteLattice α] section One variable [One α] @[to_additive (attr := simp)] theorem sSup_one : sSup (1 : Set α) = 1 := sSup_singleton #align Sup_zero sSup_zero #align Sup_one sSup_one @[to_additive (attr := simp)] theorem sInf_one : sInf (1 : Set α) = 1 := sInf_singleton #align Inf_zero sInf_zero #align Inf_one sInf_one end One section Group variable [Group α] [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (swap (· * ·)) (· ≤ ·)] (s t : Set α) @[to_additive] theorem sSup_inv (s : Set α) : sSup s⁻¹ = (sInf s)⁻¹ := by rw [← image_inv, sSup_image] exact ((OrderIso.inv α).map_sInf _).symm #align Sup_inv sSup_inv #align Sup_neg sSup_neg @[to_additive] theorem sInf_inv (s : Set α) : sInf s⁻¹ = (sSup s)⁻¹ := by rw [← image_inv, sInf_image] exact ((OrderIso.inv α).map_sSup _).symm #align Inf_inv sInf_inv #align Inf_neg sInf_neg @[to_additive] theorem sSup_mul : sSup (s * t) = sSup s * sSup t := (sSup_image2_eq_sSup_sSup fun _ => (OrderIso.mulRight _).to_galoisConnection) fun _ => (OrderIso.mulLeft _).to_galoisConnection #align Sup_mul sSup_mul #align Sup_add sSup_add @[to_additive] theorem sInf_mul : sInf (s * t) = sInf s * sInf t := (sInf_image2_eq_sInf_sInf fun _ => (OrderIso.mulRight _).symm.to_galoisConnection) fun _ => (OrderIso.mulLeft _).symm.to_galoisConnection #align Inf_mul sInf_mul #align Inf_add sInf_add @[to_additive]
Mathlib/Algebra/Order/Pointwise.lean
89
89
theorem sSup_div : sSup (s / t) = sSup s / sInf t := by
simp_rw [div_eq_mul_inv, sSup_mul, sSup_inv]
/- 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.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" /-! # Dropping or taking from lists on the right Taking or removing element from the tail end of a list ## Main definitions - `rdrop n`: drop `n : ℕ` elements from the tail - `rtake n`: take `n : ℕ` elements from the tail - `rdropWhile p`: remove all the elements from the tail of a list until it finds the first element for which `p : α → Bool` returns false. This element and everything before is returned. - `rtakeWhile p`: Returns the longest terminal segment of a list for which `p : α → Bool` returns true. ## Implementation detail The two predicate-based methods operate by performing the regular "from-left" operation on `List.reverse`, followed by another `List.reverse`, so they are not the most performant. The other two rely on `List.length l` so they still traverse the list twice. One could construct another function that takes a `L : ℕ` and use `L - n`. Under a proof condition that `L = l.length`, the function would do the right thing. -/ -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List /-- Drop `n` elements from the tail end of a list. -/ def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp]
Mathlib/Data/List/DropRight.lean
47
47
theorem rdrop_nil : rdrop ([] : List α) n = [] := by
simp [rdrop]
/- Copyright (c) 2024 Jana Göken. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Artur Szafarczyk, Suraj Krishna M S, Jean-Baptiste Stiegler, Isabelle Dubois, Tomáš Jakl, Lorenzo Zanichelli, Alina Yan, Emilie Uthaiwat, Jana Göken, Filippo A. E. Nuccio -/ import Mathlib.Topology.Metrizable.Basic import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Instances.Real /-! # Ternary Cantor Set This file defines the Cantor ternary set and proves a few properties. ## Main Definitions * `preCantorSet n`: The order `n` pre-Cantor set, defined inductively as the union of the images under the functions `(· / 3)` and `((2 + ·) / 3)`, with `preCantorSet 0 := Set.Icc 0 1`, i.e. `preCantorSet 0` is the unit interval [0,1]. * `cantorSet`: The ternary Cantor set, defined as the intersection of all pre-Cantor sets. -/ /-- The order `n` pre-Cantor set, defined starting from `[0, 1]` and successively removing the middle third of each interval. Formally, the order `n + 1` pre-Cantor set is the union of the images under the functions `(· / 3)` and `((2 + ·) / 3)` of `preCantorSet n`. -/ def preCantorSet : ℕ → Set ℝ | 0 => Set.Icc 0 1 | n + 1 => (· / 3) '' preCantorSet n ∪ (fun x ↦ (2 + x) / 3) '' preCantorSet n @[simp] lemma preCantorSet_zero : preCantorSet 0 = Set.Icc 0 1 := rfl @[simp] lemma preCantorSet_succ (n : ℕ) : preCantorSet (n + 1) = (· / 3) '' preCantorSet n ∪ (fun x ↦ (2 + x) / 3) '' preCantorSet n := rfl /-- The Cantor set is the subset of the unit interval obtained as the intersection of all pre-Cantor sets. This means that the Cantor set is obtained by iteratively removing the open middle third of each subinterval, starting from the unit interval `[0, 1]`. -/ def cantorSet : Set ℝ := ⋂ n, preCantorSet n /-! ## Simple Properties -/ lemma quarters_mem_preCantorSet (n : ℕ) : 1/4 ∈ preCantorSet n ∧ 3/4 ∈ preCantorSet n := by induction n with | zero => simp only [preCantorSet_zero, inv_nonneg] refine ⟨⟨ ?_, ?_⟩, ?_, ?_⟩ <;> norm_num | succ n ih => apply And.intro · -- goal: 1 / 4 ∈ preCantorSet (n + 1) -- follows by the inductive hyphothesis, since 3 / 4 ∈ preCantorSet n exact Or.inl ⟨3 / 4, ih.2, by norm_num⟩ · -- goal: 3 / 4 ∈ preCantorSet (n + 1) -- follows by the inductive hyphothesis, since 1 / 4 ∈ preCantorSet n exact Or.inr ⟨1 / 4, ih.1, by norm_num⟩ lemma quarter_mem_preCantorSet (n : ℕ) : 1/4 ∈ preCantorSet n := (quarters_mem_preCantorSet n).1 theorem quarter_mem_cantorSet : 1/4 ∈ cantorSet := Set.mem_iInter.mpr quarter_mem_preCantorSet lemma zero_mem_preCantorSet (n : ℕ) : 0 ∈ preCantorSet n := by induction n with | zero => simp [preCantorSet] | succ n ih => exact Or.inl ⟨0, ih, by simp only [zero_div]⟩
Mathlib/Topology/Instances/CantorSet.lean
75
75
theorem zero_mem_cantorSet : 0 ∈ cantorSet := by
simp [cantorSet, zero_mem_preCantorSet]
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.indicator from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" /-! # Building finitely supported functions off finsets This file defines `Finsupp.indicator` to help create finsupps from finsets. ## Main declarations * `Finsupp.indicator`: Turns a map from a `Finset` into a `Finsupp` from the entire type. -/ noncomputable section open Finset Function variable {ι α : Type*} namespace Finsupp variable [Zero α] {s : Finset ι} (f : ∀ i ∈ s, α) {i : ι} /-- Create an element of `ι →₀ α` from a finset `s` and a function `f` defined on this finset. -/ def indicator (s : Finset ι) (f : ∀ i ∈ s, α) : ι →₀ α where toFun i := haveI := Classical.decEq ι if H : i ∈ s then f i H else 0 support := haveI := Classical.decEq α (s.attach.filter fun i : s => f i.1 i.2 ≠ 0).map (Embedding.subtype _) mem_support_toFun i := by classical simp #align finsupp.indicator Finsupp.indicator theorem indicator_of_mem (hi : i ∈ s) (f : ∀ i ∈ s, α) : indicator s f i = f i hi := @dif_pos _ (id _) hi _ _ _ #align finsupp.indicator_of_mem Finsupp.indicator_of_mem theorem indicator_of_not_mem (hi : i ∉ s) (f : ∀ i ∈ s, α) : indicator s f i = 0 := @dif_neg _ (id _) hi _ _ _ #align finsupp.indicator_of_not_mem Finsupp.indicator_of_not_mem variable (s i) @[simp] theorem indicator_apply [DecidableEq ι] : indicator s f i = if hi : i ∈ s then f i hi else 0 := by simp only [indicator, ne_eq, coe_mk] congr #align finsupp.indicator_apply Finsupp.indicator_apply theorem indicator_injective : Injective fun f : ∀ i ∈ s, α => indicator s f := by intro a b h ext i hi rw [← indicator_of_mem hi a, ← indicator_of_mem hi b] exact DFunLike.congr_fun h i #align finsupp.indicator_injective Finsupp.indicator_injective
Mathlib/Data/Finsupp/Indicator.lean
66
70
theorem support_indicator_subset : ((indicator s f).support : Set ι) ⊆ s := by
intro i hi rw [mem_coe, mem_support_iff] at hi by_contra h exact hi (indicator_of_not_mem h _)
/- Copyright (c) 2019 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.Rat.Denumerable import Mathlib.Data.Set.Pointwise.Interval import Mathlib.SetTheory.Cardinal.Continuum #align_import data.real.cardinality from "leanprover-community/mathlib"@"7e7aaccf9b0182576cabdde36cf1b5ad3585b70d" /-! # The cardinality of the reals This file shows that the real numbers have cardinality continuum, i.e. `#ℝ = 𝔠`. We show that `#ℝ ≤ 𝔠` by noting that every real number is determined by a Cauchy-sequence of the form `ℕ → ℚ`, which has cardinality `𝔠`. To show that `#ℝ ≥ 𝔠` we define an injection from `{0, 1} ^ ℕ` to `ℝ` with `f ↦ Σ n, f n * (1 / 3) ^ n`. We conclude that all intervals with distinct endpoints have cardinality continuum. ## Main definitions * `Cardinal.cantorFunction` is the function that sends `f` in `{0, 1} ^ ℕ` to `ℝ` by `f ↦ Σ' n, f n * (1 / 3) ^ n` ## Main statements * `Cardinal.mk_real : #ℝ = 𝔠`: the reals have cardinality continuum. * `Cardinal.not_countable_real`: the universal set of real numbers is not countable. We can use this same proof to show that all the other sets in this file are not countable. * 8 lemmas of the form `mk_Ixy_real` for `x,y ∈ {i,o,c}` state that intervals on the reals have cardinality continuum. ## Notation * `𝔠` : notation for `Cardinal.Continuum` in locale `Cardinal`, defined in `SetTheory.Continuum`. ## Tags continuum, cardinality, reals, cardinality of the reals -/ open Nat Set open Cardinal noncomputable section namespace Cardinal variable {c : ℝ} {f g : ℕ → Bool} {n : ℕ} /-- The body of the sum in `cantorFunction`. `cantorFunctionAux c f n = c ^ n` if `f n = true`; `cantorFunctionAux c f n = 0` if `f n = false`. -/ def cantorFunctionAux (c : ℝ) (f : ℕ → Bool) (n : ℕ) : ℝ := cond (f n) (c ^ n) 0 #align cardinal.cantor_function_aux Cardinal.cantorFunctionAux @[simp] theorem cantorFunctionAux_true (h : f n = true) : cantorFunctionAux c f n = c ^ n := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_tt Cardinal.cantorFunctionAux_true @[simp] theorem cantorFunctionAux_false (h : f n = false) : cantorFunctionAux c f n = 0 := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_ff Cardinal.cantorFunctionAux_false theorem cantorFunctionAux_nonneg (h : 0 ≤ c) : 0 ≤ cantorFunctionAux c f n := by cases h' : f n <;> simp [h'] apply pow_nonneg h #align cardinal.cantor_function_aux_nonneg Cardinal.cantorFunctionAux_nonneg theorem cantorFunctionAux_eq (h : f n = g n) : cantorFunctionAux c f n = cantorFunctionAux c g n := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_eq Cardinal.cantorFunctionAux_eq theorem cantorFunctionAux_zero (f : ℕ → Bool) : cantorFunctionAux c f 0 = cond (f 0) 1 0 := by cases h : f 0 <;> simp [h] #align cardinal.cantor_function_aux_zero Cardinal.cantorFunctionAux_zero
Mathlib/Data/Real/Cardinality.lean
86
90
theorem cantorFunctionAux_succ (f : ℕ → Bool) : (fun n => cantorFunctionAux c f (n + 1)) = fun n => c * cantorFunctionAux c (fun n => f (n + 1)) n := by
ext n cases h : f (n + 1) <;> simp [h, _root_.pow_succ']
/- Copyright (c) 2019 Minchao Wu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Minchao Wu, Chris Hughes, Mantas Bakšys -/ import Mathlib.Data.List.Basic import Mathlib.Order.MinMax import Mathlib.Order.WithBot #align_import data.list.min_max from "leanprover-community/mathlib"@"6d0adfa76594f304b4650d098273d4366edeb61b" /-! # Minimum and maximum of lists ## Main definitions The main definitions are `argmax`, `argmin`, `minimum` and `maximum` for lists. `argmax f l` returns `some a`, where `a` of `l` that maximises `f a`. If there are `a b` such that `f a = f b`, it returns whichever of `a` or `b` comes first in the list. `argmax f [] = none` `minimum l` returns a `WithTop α`, the smallest element of `l` for nonempty lists, and `⊤` for `[]` -/ namespace List variable {α β : Type*} section ArgAux variable (r : α → α → Prop) [DecidableRel r] {l : List α} {o : Option α} {a m : α} /-- Auxiliary definition for `argmax` and `argmin`. -/ def argAux (a : Option α) (b : α) : Option α := Option.casesOn a (some b) fun c => if r b c then some b else some c #align list.arg_aux List.argAux @[simp] theorem foldl_argAux_eq_none : l.foldl (argAux r) o = none ↔ l = [] ∧ o = none := List.reverseRecOn l (by simp) fun tl hd => by simp only [foldl_append, foldl_cons, argAux, foldl_nil, append_eq_nil, and_false, false_and, iff_false]; cases foldl (argAux r) o tl <;> simp; try split_ifs <;> simp #align list.foldl_arg_aux_eq_none List.foldl_argAux_eq_none private theorem foldl_argAux_mem (l) : ∀ a m : α, m ∈ foldl (argAux r) (some a) l → m ∈ a :: l := List.reverseRecOn l (by simp [eq_comm]) (by intro tl hd ih a m simp only [foldl_append, foldl_cons, foldl_nil, argAux] cases hf : foldl (argAux r) (some a) tl · simp (config := { contextual := true }) · dsimp only split_ifs · simp (config := { contextual := true }) · -- `finish [ih _ _ hf]` closes this goal simp only [List.mem_cons] at ih rcases ih _ _ hf with rfl | H · simp (config := { contextual := true }) only [Option.mem_def, Option.some.injEq, find?, eq_comm, mem_cons, mem_append, mem_singleton, true_or, implies_true] · simp (config := { contextual := true }) [@eq_comm _ _ m, H]) @[simp] theorem argAux_self (hr₀ : Irreflexive r) (a : α) : argAux r (some a) a = a := if_neg <| hr₀ _ #align list.arg_aux_self List.argAux_self
Mathlib/Data/List/MinMax.lean
69
86
theorem not_of_mem_foldl_argAux (hr₀ : Irreflexive r) (hr₁ : Transitive r) : ∀ {a m : α} {o : Option α}, a ∈ l → m ∈ foldl (argAux r) o l → ¬r a m := by
induction' l using List.reverseRecOn with tl a ih · simp intro b m o hb ho rw [foldl_append, foldl_cons, foldl_nil, argAux] at ho cases' hf : foldl (argAux r) o tl with c · rw [hf] at ho rw [foldl_argAux_eq_none] at hf simp_all [hf.1, hf.2, hr₀ _] rw [hf, Option.mem_def] at ho dsimp only at ho split_ifs at ho with hac <;> cases' mem_append.1 hb with h h <;> injection ho with ho <;> subst ho · exact fun hba => ih h hf (hr₁ hba hac) · simp_all [hr₀ _] · exact ih h hf · simp_all
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.LinearAlgebra.TensorAlgebra.Basic import Mathlib.LinearAlgebra.TensorPower #align_import linear_algebra.tensor_algebra.to_tensor_power from "leanprover-community/mathlib"@"d97a0c9f7a7efe6d76d652c5a6b7c9c634b70e0a" /-! # Tensor algebras as direct sums of tensor powers In this file we show that `TensorAlgebra R M` is isomorphic to a direct sum of tensor powers, as `TensorAlgebra.equivDirectSum`. -/ suppress_compilation open scoped DirectSum TensorProduct variable {R M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] namespace TensorPower /-- The canonical embedding from a tensor power to the tensor algebra -/ def toTensorAlgebra {n} : ⨂[R]^n M →ₗ[R] TensorAlgebra R M := PiTensorProduct.lift (TensorAlgebra.tprod R M n) #align tensor_power.to_tensor_algebra TensorPower.toTensorAlgebra @[simp] theorem toTensorAlgebra_tprod {n} (x : Fin n → M) : TensorPower.toTensorAlgebra (PiTensorProduct.tprod R x) = TensorAlgebra.tprod R M n x := PiTensorProduct.lift.tprod _ #align tensor_power.to_tensor_algebra_tprod TensorPower.toTensorAlgebra_tprod @[simp] theorem toTensorAlgebra_gOne : TensorPower.toTensorAlgebra (@GradedMonoid.GOne.one _ (fun n => ⨂[R]^n M) _ _) = 1 := TensorPower.toTensorAlgebra_tprod _ #align tensor_power.to_tensor_algebra_ghas_one TensorPower.toTensorAlgebra_gOne @[simp]
Mathlib/LinearAlgebra/TensorAlgebra/ToTensorPower.lean
44
64
theorem toTensorAlgebra_gMul {i j} (a : (⨂[R]^i) M) (b : (⨂[R]^j) M) : TensorPower.toTensorAlgebra (@GradedMonoid.GMul.mul _ (fun n => ⨂[R]^n M) _ _ _ _ a b) = TensorPower.toTensorAlgebra a * TensorPower.toTensorAlgebra b := by
-- change `a` and `b` to `tprod R a` and `tprod R b` rw [TensorPower.gMul_eq_coe_linearMap, ← LinearMap.compr₂_apply, ← @LinearMap.mul_apply' R, ← LinearMap.compl₂_apply, ← LinearMap.comp_apply] refine LinearMap.congr_fun (LinearMap.congr_fun ?_ a) b clear! a b ext (a b) -- Porting note: pulled the next two lines out of the long `simp only` below. simp only [LinearMap.compMultilinearMap_apply] rw [LinearMap.compr₂_apply, ← gMul_eq_coe_linearMap] simp only [LinearMap.compr₂_apply, LinearMap.mul_apply', LinearMap.compl₂_apply, LinearMap.comp_apply, LinearMap.compMultilinearMap_apply, PiTensorProduct.lift.tprod, TensorPower.tprod_mul_tprod, TensorPower.toTensorAlgebra_tprod, TensorAlgebra.tprod_apply, ← gMul_eq_coe_linearMap] refine Eq.trans ?_ List.prod_append congr -- Porting note: `erw` for `Function.comp` erw [← List.map_ofFn _ (TensorAlgebra.ι R), ← List.map_ofFn _ (TensorAlgebra.ι R), ← List.map_ofFn _ (TensorAlgebra.ι R), ← List.map_append, List.ofFn_fin_append]
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Alex Kontorovich -/ import Mathlib.Order.Filter.Bases #align_import order.filter.pi from "leanprover-community/mathlib"@"ce64cd319bb6b3e82f31c2d38e79080d377be451" /-! # (Co)product of a family of filters In this file we define two filters on `Π i, α i` and prove some basic properties of these filters. * `Filter.pi (f : Π i, Filter (α i))` to be the maximal filter on `Π i, α i` such that `∀ i, Filter.Tendsto (Function.eval i) (Filter.pi f) (f i)`. It is defined as `Π i, Filter.comap (Function.eval i) (f i)`. This is a generalization of `Filter.prod` to indexed products. * `Filter.coprodᵢ (f : Π i, Filter (α i))`: a generalization of `Filter.coprod`; it is the supremum of `comap (eval i) (f i)`. -/ open Set Function open scoped Classical open Filter namespace Filter variable {ι : Type*} {α : ι → Type*} {f f₁ f₂ : (i : ι) → Filter (α i)} {s : (i : ι) → Set (α i)} {p : ∀ i, α i → Prop} section Pi /-- The product of an indexed family of filters. -/ def pi (f : ∀ i, Filter (α i)) : Filter (∀ i, α i) := ⨅ i, comap (eval i) (f i) #align filter.pi Filter.pi instance pi.isCountablyGenerated [Countable ι] [∀ i, IsCountablyGenerated (f i)] : IsCountablyGenerated (pi f) := iInf.isCountablyGenerated _ #align filter.pi.is_countably_generated Filter.pi.isCountablyGenerated theorem tendsto_eval_pi (f : ∀ i, Filter (α i)) (i : ι) : Tendsto (eval i) (pi f) (f i) := tendsto_iInf' i tendsto_comap #align filter.tendsto_eval_pi Filter.tendsto_eval_pi theorem tendsto_pi {β : Type*} {m : β → ∀ i, α i} {l : Filter β} : Tendsto m l (pi f) ↔ ∀ i, Tendsto (fun x => m x i) l (f i) := by simp only [pi, tendsto_iInf, tendsto_comap_iff]; rfl #align filter.tendsto_pi Filter.tendsto_pi /-- If a function tends to a product `Filter.pi f` of filters, then its `i`-th component tends to `f i`. See also `Filter.Tendsto.apply_nhds` for the special case of converging to a point in a product of topological spaces. -/ alias ⟨Tendsto.apply, _⟩ := tendsto_pi theorem le_pi {g : Filter (∀ i, α i)} : g ≤ pi f ↔ ∀ i, Tendsto (eval i) g (f i) := tendsto_pi #align filter.le_pi Filter.le_pi @[mono] theorem pi_mono (h : ∀ i, f₁ i ≤ f₂ i) : pi f₁ ≤ pi f₂ := iInf_mono fun i => comap_mono <| h i #align filter.pi_mono Filter.pi_mono theorem mem_pi_of_mem (i : ι) {s : Set (α i)} (hs : s ∈ f i) : eval i ⁻¹' s ∈ pi f := mem_iInf_of_mem i <| preimage_mem_comap hs #align filter.mem_pi_of_mem Filter.mem_pi_of_mem
Mathlib/Order/Filter/Pi.lean
74
77
theorem pi_mem_pi {I : Set ι} (hI : I.Finite) (h : ∀ i ∈ I, s i ∈ f i) : I.pi s ∈ pi f := by
rw [pi_def, biInter_eq_iInter] refine mem_iInf_of_iInter hI (fun i => ?_) Subset.rfl exact preimage_mem_comap (h i i.2)
/- Copyright (c) 2021 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.FieldTheory.RatFunc.Basic import Mathlib.RingTheory.EuclideanDomain import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Polynomial.Content /-! # Generalities on the polynomial structure of rational functions ## Main definitions - `RatFunc.C` is the constant polynomial - `RatFunc.X` is the indeterminate - `RatFunc.eval` evaluates a rational function given a value for the indeterminate -/ noncomputable section universe u variable {K : Type u} namespace RatFunc section Eval open scoped Classical open scoped nonZeroDivisors Polynomial open RatFunc /-! ### Polynomial structure: `C`, `X`, `eval` -/ section Domain variable [CommRing K] [IsDomain K] /-- `RatFunc.C a` is the constant rational function `a`. -/ def C : K →+* RatFunc K := algebraMap _ _ set_option linter.uppercaseLean3 false in #align ratfunc.C RatFunc.C @[simp] theorem algebraMap_eq_C : algebraMap K (RatFunc K) = C := rfl set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_eq_C RatFunc.algebraMap_eq_C @[simp] theorem algebraMap_C (a : K) : algebraMap K[X] (RatFunc K) (Polynomial.C a) = C a := rfl set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_C RatFunc.algebraMap_C @[simp] theorem algebraMap_comp_C : (algebraMap K[X] (RatFunc K)).comp Polynomial.C = C := rfl set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_comp_C RatFunc.algebraMap_comp_C theorem smul_eq_C_mul (r : K) (x : RatFunc K) : r • x = C r * x := by rw [Algebra.smul_def, algebraMap_eq_C] set_option linter.uppercaseLean3 false in #align ratfunc.smul_eq_C_mul RatFunc.smul_eq_C_mul /-- `RatFunc.X` is the polynomial variable (aka indeterminate). -/ def X : RatFunc K := algebraMap K[X] (RatFunc K) Polynomial.X set_option linter.uppercaseLean3 false in #align ratfunc.X RatFunc.X @[simp] theorem algebraMap_X : algebraMap K[X] (RatFunc K) Polynomial.X = X := rfl set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_X RatFunc.algebraMap_X end Domain section Field variable [Field K] @[simp] theorem num_C (c : K) : num (C c) = Polynomial.C c := num_algebraMap _ set_option linter.uppercaseLean3 false in #align ratfunc.num_C RatFunc.num_C @[simp] theorem denom_C (c : K) : denom (C c) = 1 := denom_algebraMap _ set_option linter.uppercaseLean3 false in #align ratfunc.denom_C RatFunc.denom_C @[simp] theorem num_X : num (X : RatFunc K) = Polynomial.X := num_algebraMap _ set_option linter.uppercaseLean3 false in #align ratfunc.num_X RatFunc.num_X @[simp] theorem denom_X : denom (X : RatFunc K) = 1 := denom_algebraMap _ set_option linter.uppercaseLean3 false in #align ratfunc.denom_X RatFunc.denom_X theorem X_ne_zero : (X : RatFunc K) ≠ 0 := RatFunc.algebraMap_ne_zero Polynomial.X_ne_zero set_option linter.uppercaseLean3 false in #align ratfunc.X_ne_zero RatFunc.X_ne_zero variable {L : Type u} [Field L] /-- Evaluate a rational function `p` given a ring hom `f` from the scalar field to the target and a value `x` for the variable in the target. Fractions are reduced by clearing common denominators before evaluating: `eval id 1 ((X^2 - 1) / (X - 1)) = eval id 1 (X + 1) = 2`, not `0 / 0 = 0`. -/ def eval (f : K →+* L) (a : L) (p : RatFunc K) : L := (num p).eval₂ f a / (denom p).eval₂ f a #align ratfunc.eval RatFunc.eval variable {f : K →+* L} {a : L} theorem eval_eq_zero_of_eval₂_denom_eq_zero {x : RatFunc K} (h : Polynomial.eval₂ f a (denom x) = 0) : eval f a x = 0 := by rw [eval, h, div_zero] #align ratfunc.eval_eq_zero_of_eval₂_denom_eq_zero RatFunc.eval_eq_zero_of_eval₂_denom_eq_zero theorem eval₂_denom_ne_zero {x : RatFunc K} (h : eval f a x ≠ 0) : Polynomial.eval₂ f a (denom x) ≠ 0 := mt eval_eq_zero_of_eval₂_denom_eq_zero h #align ratfunc.eval₂_denom_ne_zero RatFunc.eval₂_denom_ne_zero variable (f a) @[simp] theorem eval_C {c : K} : eval f a (C c) = f c := by simp [eval] set_option linter.uppercaseLean3 false in #align ratfunc.eval_C RatFunc.eval_C @[simp] theorem eval_X : eval f a X = a := by simp [eval] set_option linter.uppercaseLean3 false in #align ratfunc.eval_X RatFunc.eval_X @[simp]
Mathlib/FieldTheory/RatFunc/AsPolynomial.lean
139
139
theorem eval_zero : eval f a 0 = 0 := by
simp [eval]
/- Copyright (c) 2019 Michael Howes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Howes, Newell Jensen -/ import Mathlib.GroupTheory.FreeGroup.Basic import Mathlib.GroupTheory.QuotientGroup #align_import group_theory.presented_group from "leanprover-community/mathlib"@"d90e4e186f1d18e375dcd4e5b5f6364b01cb3e46" /-! # Defining a group given by generators and relations Given a subset `rels` of relations of the free group on a type `α`, this file constructs the group given by generators `x : α` and relations `r ∈ rels`. ## Main definitions * `PresentedGroup rels`: the quotient group of the free group on a type `α` by a subset `rels` of relations of the free group on `α`. * `of`: The canonical map from `α` to a presented group with generators `α`. * `toGroup f`: the canonical group homomorphism `PresentedGroup rels → G`, given a function `f : α → G` from a type `α` to a group `G` which satisfies the relations `rels`. ## Tags generators, relations, group presentations -/ variable {α : Type*} /-- Given a set of relations, `rels`, over a type `α`, `PresentedGroup` constructs the group with generators `x : α` and relations `rels` as a quotient of `FreeGroup α`. -/ def PresentedGroup (rels : Set (FreeGroup α)) := FreeGroup α ⧸ Subgroup.normalClosure rels #align presented_group PresentedGroup namespace PresentedGroup instance (rels : Set (FreeGroup α)) : Group (PresentedGroup rels) := QuotientGroup.Quotient.group _ /-- `of` is the canonical map from `α` to a presented group with generators `x : α`. The term `x` is mapped to the equivalence class of the image of `x` in `FreeGroup α`. -/ def of {rels : Set (FreeGroup α)} (x : α) : PresentedGroup rels := QuotientGroup.mk (FreeGroup.of x) #align presented_group.of PresentedGroup.of /-- The generators of a presented group generate the presented group. That is, the subgroup closure of the set of generators equals `⊤`. -/ @[simp] theorem closure_range_of (rels : Set (FreeGroup α)) : Subgroup.closure (Set.range (PresentedGroup.of : α → PresentedGroup rels)) = ⊤ := by have : (PresentedGroup.of : α → PresentedGroup rels) = QuotientGroup.mk' _ ∘ FreeGroup.of := rfl rw [this, Set.range_comp, ← MonoidHom.map_closure (QuotientGroup.mk' _), FreeGroup.closure_range_of, ← MonoidHom.range_eq_map] exact MonoidHom.range_top_of_surjective _ (QuotientGroup.mk'_surjective _) section ToGroup /- Presented groups satisfy a universal property. If `G` is a group and `f : α → G` is a map such that the images of `f` satisfy all the given relations, then `f` extends uniquely to a group homomorphism from `PresentedGroup rels` to `G`. -/ variable {G : Type*} [Group G] {f : α → G} {rels : Set (FreeGroup α)} local notation "F" => FreeGroup.lift f -- Porting note: `F` has been expanded, because `F r = 1` produces a sorry. variable (h : ∀ r ∈ rels, FreeGroup.lift f r = 1) theorem closure_rels_subset_ker : Subgroup.normalClosure rels ≤ MonoidHom.ker F := Subgroup.normalClosure_le_normal fun x w ↦ (MonoidHom.mem_ker _).2 (h x w) #align presented_group.closure_rels_subset_ker PresentedGroup.closure_rels_subset_ker theorem to_group_eq_one_of_mem_closure : ∀ x ∈ Subgroup.normalClosure rels, F x = 1 := fun _ w ↦ (MonoidHom.mem_ker _).1 <| closure_rels_subset_ker h w #align presented_group.to_group_eq_one_of_mem_closure PresentedGroup.to_group_eq_one_of_mem_closure /-- The extension of a map `f : α → G` that satisfies the given relations to a group homomorphism from `PresentedGroup rels → G`. -/ def toGroup : PresentedGroup rels →* G := QuotientGroup.lift (Subgroup.normalClosure rels) F (to_group_eq_one_of_mem_closure h) #align presented_group.to_group PresentedGroup.toGroup @[simp] theorem toGroup.of {x : α} : toGroup h (of x) = f x := FreeGroup.lift.of #align presented_group.to_group.of PresentedGroup.toGroup.of
Mathlib/GroupTheory/PresentedGroup.lean
93
97
theorem toGroup.unique (g : PresentedGroup rels →* G) (hg : ∀ x : α, g (PresentedGroup.of x) = f x) : ∀ {x}, g x = toGroup h x := by
intro x refine QuotientGroup.induction_on x ?_ exact fun _ ↦ FreeGroup.lift.unique (g.comp (QuotientGroup.mk' _)) hg
/- Copyright (c) 2022 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey, Patrick Stevens, Thomas Browning -/ import Mathlib.Data.Nat.Choose.Central import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Data.Nat.Multiplicity #align_import data.nat.choose.factorization from "leanprover-community/mathlib"@"dc9db541168768af03fe228703e758e649afdbfc" /-! # Factorization of Binomial Coefficients This file contains a few results on the multiplicity of prime factors within certain size bounds in binomial coefficients. These include: * `Nat.factorization_choose_le_log`: a logarithmic upper bound on the multiplicity of a prime in a binomial coefficient. * `Nat.factorization_choose_le_one`: Primes above `sqrt n` appear at most once in the factorization of `n` choose `k`. * `Nat.factorization_centralBinom_of_two_mul_self_lt_three_mul`: Primes from `2 * n / 3` to `n` do not appear in the factorization of the `n`th central binomial coefficient. * `Nat.factorization_choose_eq_zero_of_lt`: Primes greater than `n` do not appear in the factorization of `n` choose `k`. These results appear in the [Erdős proof of Bertrand's postulate](aigner1999proofs). -/ namespace Nat variable {p n k : ℕ} /-- A logarithmic upper bound on the multiplicity of a prime in a binomial coefficient. -/
Mathlib/Data/Nat/Choose/Factorization.lean
36
45
theorem factorization_choose_le_log : (choose n k).factorization p ≤ log p n := by
by_cases h : (choose n k).factorization p = 0 · simp [h] have hp : p.Prime := Not.imp_symm (choose n k).factorization_eq_zero_of_non_prime h have hkn : k ≤ n := by refine le_of_not_lt fun hnk => h ?_ simp [choose_eq_zero_of_lt hnk] rw [factorization_def _ hp, @padicValNat_def _ ⟨hp⟩ _ (choose_pos hkn)] simp only [hp.multiplicity_choose hkn (lt_add_one _), PartENat.get_natCast] exact (Finset.card_filter_le _ _).trans (le_of_eq (Nat.card_Ico _ _))
/- Copyright (c) 2023 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.NumberTheory.NumberField.Embeddings #align_import number_theory.number_field.units from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a" /-! # Units of a number field We prove some basic results on the group `(𝓞 K)ˣ` of units of the ring of integers `𝓞 K` of a number field `K` and its torsion subgroup. ## Main definition * `NumberField.Units.torsion`: the torsion subgroup of a number field. ## Main results * `NumberField.isUnit_iff_norm`: an algebraic integer `x : 𝓞 K` is a unit if and only if `|norm ℚ x| = 1`. * `NumberField.Units.mem_torsion`: a unit `x : (𝓞 K)ˣ` is torsion iff `w x = 1` for all infinite places `w` of `K`. ## Tags number field, units -/ open scoped NumberField noncomputable section open NumberField Units section Rat theorem Rat.RingOfIntegers.isUnit_iff {x : 𝓞 ℚ} : IsUnit x ↔ (x : ℚ) = 1 ∨ (x : ℚ) = -1 := by simp_rw [(isUnit_map_iff (Rat.ringOfIntegersEquiv : 𝓞 ℚ →+* ℤ) x).symm, Int.isUnit_iff, RingEquiv.coe_toRingHom, RingEquiv.map_eq_one_iff, RingEquiv.map_eq_neg_one_iff, ← Subtype.coe_injective.eq_iff]; rfl #align rat.ring_of_integers.is_unit_iff Rat.RingOfIntegers.isUnit_iff end Rat variable (K : Type*) [Field K] section IsUnit variable {K} theorem NumberField.isUnit_iff_norm [NumberField K] {x : 𝓞 K} : IsUnit x ↔ |(RingOfIntegers.norm ℚ x : ℚ)| = 1 := by convert (RingOfIntegers.isUnit_norm ℚ (F := K)).symm rw [← abs_one, abs_eq_abs, ← Rat.RingOfIntegers.isUnit_iff] #align is_unit_iff_norm NumberField.isUnit_iff_norm end IsUnit namespace NumberField.Units section coe instance : CoeHTC (𝓞 K)ˣ K := ⟨fun x => algebraMap _ K (Units.val x)⟩ theorem coe_injective : Function.Injective ((↑) : (𝓞 K)ˣ → K) := RingOfIntegers.coe_injective.comp Units.ext variable {K} theorem coe_coe (u : (𝓞 K)ˣ) : ((u : 𝓞 K) : K) = (u : K) := rfl theorem coe_mul (x y : (𝓞 K)ˣ) : ((x * y : (𝓞 K)ˣ) : K) = (x : K) * (y : K) := rfl
Mathlib/NumberTheory/NumberField/Units/Basic.lean
78
79
theorem coe_pow (x : (𝓞 K)ˣ) (n : ℕ) : ((x ^ n : (𝓞 K)ˣ) : K) = (x : K) ^ n := by
rw [← map_pow, ← val_pow_eq_pow_val]
/- Copyright (c) 2024 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.NumberTheory.ZetaValues import Mathlib.NumberTheory.LSeries.RiemannZeta /-! # Special values of Hurwitz and Riemann zeta functions This file gives the formula for `ζ (2 * k)`, for `k` a non-zero integer, in terms of Bernoulli numbers. More generally, we give formulae for any Hurwitz zeta functions at any (strictly) negative integer in terms of Bernoulli polynomials. (Note that most of the actual work for these formulae is done elsewhere, in `Mathlib.NumberTheory.ZetaValues`. This file has only those results which really need the definition of Hurwitz zeta and related functions, rather than working directly with the defining sums in the convergence range.) ## Main results - `hurwitzZeta_neg_nat`: for `k : ℕ` with `k ≠ 0`, and any `x ∈ ℝ / ℤ`, the special value `hurwitzZeta x (-k)` is equal to `-(Polynomial.bernoulli (k + 1) x) / (k + 1)`. - `riemannZeta_neg_nat_eq_bernoulli` : for any `k ∈ ℕ` we have the formula `riemannZeta (-k) = (-1) ^ k * bernoulli (k + 1) / (k + 1)` - `riemannZeta_two_mul_nat`: formula for `ζ(2 * k)` for `k ∈ ℕ, k ≠ 0` in terms of Bernoulli numbers ## TODO * Extend to cover Dirichlet L-functions. * The formulae are correct for `s = 0` as well, but we do not prove this case, since this requires Fourier series which are only conditionally convergent, which is difficult to approach using the methods in the library at the present time (May 2024). -/ open Complex Real Set open scoped Nat namespace HurwitzZeta variable {k : ℕ} {x : ℝ} /-- Express the value of `cosZeta` at a positive even integer as a value of the Bernoulli polynomial. -/
Mathlib/NumberTheory/LSeries/HurwitzZetaValues.lean
49
67
theorem cosZeta_two_mul_nat (hk : k ≠ 0) (hx : x ∈ Icc 0 1) : cosZeta x (2 * k) = (-1) ^ (k + 1) * (2 * π) ^ (2 * k) / 2 / (2 * k)! * ((Polynomial.bernoulli (2 * k)).map (algebraMap ℚ ℂ)).eval (x : ℂ) := by
rw [← (hasSum_nat_cosZeta x (?_ : 1 < re (2 * k))).tsum_eq] refine Eq.trans ?_ <| (congr_arg ofReal' (hasSum_one_div_nat_pow_mul_cos hk hx).tsum_eq).trans ?_ · rw [ofReal_tsum] refine tsum_congr fun n ↦ ?_ rw [mul_comm (1 / _), mul_one_div, ofReal_div, mul_assoc (2 * π), mul_comm x n, ← mul_assoc, ← Nat.cast_ofNat (R := ℂ), ← Nat.cast_mul, cpow_natCast, ofReal_pow, ofReal_natCast] · simp only [ofReal_mul, ofReal_div, ofReal_pow, ofReal_natCast, ofReal_ofNat, ofReal_neg, ofReal_one] congr 1 have : (Polynomial.bernoulli (2 * k)).map (algebraMap ℚ ℂ) = _ := (Polynomial.map_map (algebraMap ℚ ℝ) ofReal _).symm rw [this, ← ofReal_eq_coe, ← ofReal_eq_coe] apply Polynomial.map_aeval_eq_aeval_map simp only [Algebra.id.map_eq_id, RingHomCompTriple.comp_eq] · rw [← Nat.cast_ofNat, ← Nat.cast_one, ← Nat.cast_mul, natCast_re, Nat.cast_lt] omega
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Kenny Lau, Scott Morrison, Alex Keizer -/ import Mathlib.Data.List.OfFn import Mathlib.Data.List.Range #align_import data.list.fin_range from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Lists of elements of `Fin n` This file develops some results on `finRange n`. -/ universe u namespace List variable {α : Type u} @[simp]
Mathlib/Data/List/FinRange.lean
25
27
theorem map_coe_finRange (n : ℕ) : ((finRange n) : List (Fin n)).map (Fin.val) = List.range n := by
simp_rw [finRange, map_pmap, pmap_eq_map] exact List.map_id _
/- Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel -/ import Mathlib.Topology.MetricSpace.PseudoMetric /-! ## Cauchy sequences in (pseudo-)metric spaces Various results on Cauchy sequences in (pseudo-)metric spaces, including * `Metric.complete_of_cauchySeq_tendsto` A pseudo-metric space is complete iff each Cauchy sequences converges to some limit point. * `cauchySeq_bdd`: a Cauchy sequence on the natural numbers is bounded * various characterisation of Cauchy and uniformly Cauchy sequences ## Tags metric, pseudo_metric, Cauchy sequence -/ open Filter open scoped Uniformity Topology universe u v w variable {α : Type u} {β : Type v} {X ι : Type*} variable [PseudoMetricSpace α] /-- A very useful criterion to show that a space is complete is to show that all sequences which satisfy a bound of the form `dist (u n) (u m) < B N` for all `n m ≥ N` are converging. This is often applied for `B N = 2^{-N}`, i.e., with a very fast convergence to `0`, which makes it possible to use arguments of converging series, while this is impossible to do in general for arbitrary Cauchy sequences. -/ theorem Metric.complete_of_convergent_controlled_sequences (B : ℕ → Real) (hB : ∀ n, 0 < B n) (H : ∀ u : ℕ → α, (∀ N n m : ℕ, N ≤ n → N ≤ m → dist (u n) (u m) < B N) → ∃ x, Tendsto u atTop (𝓝 x)) : CompleteSpace α := UniformSpace.complete_of_convergent_controlled_sequences (fun n => { p : α × α | dist p.1 p.2 < B n }) (fun n => dist_mem_uniformity <| hB n) H #align metric.complete_of_convergent_controlled_sequences Metric.complete_of_convergent_controlled_sequences /-- A pseudo-metric space is complete iff every Cauchy sequence converges. -/ theorem Metric.complete_of_cauchySeq_tendsto : (∀ u : ℕ → α, CauchySeq u → ∃ a, Tendsto u atTop (𝓝 a)) → CompleteSpace α := EMetric.complete_of_cauchySeq_tendsto #align metric.complete_of_cauchy_seq_tendsto Metric.complete_of_cauchySeq_tendsto section CauchySeq variable [Nonempty β] [SemilatticeSup β] /-- In a pseudometric space, Cauchy sequences are characterized by the fact that, eventually, the distance between its elements is arbitrarily small -/ -- Porting note: @[nolint ge_or_gt] doesn't exist theorem Metric.cauchySeq_iff {u : β → α} : CauchySeq u ↔ ∀ ε > 0, ∃ N, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε := uniformity_basis_dist.cauchySeq_iff #align metric.cauchy_seq_iff Metric.cauchySeq_iff /-- A variation around the pseudometric characterization of Cauchy sequences -/ theorem Metric.cauchySeq_iff' {u : β → α} : CauchySeq u ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) (u N) < ε := uniformity_basis_dist.cauchySeq_iff' #align metric.cauchy_seq_iff' Metric.cauchySeq_iff' -- see Note [nolint_ge] /-- In a pseudometric space, uniform Cauchy sequences are characterized by the fact that, eventually, the distance between all its elements is uniformly, arbitrarily small. -/ -- Porting note: no attr @[nolint ge_or_gt]
Mathlib/Topology/MetricSpace/Cauchy.lean
72
91
theorem Metric.uniformCauchySeqOn_iff {γ : Type*} {F : β → γ → α} {s : Set γ} : UniformCauchySeqOn F atTop s ↔ ∀ ε > (0 : ℝ), ∃ N : β, ∀ m ≥ N, ∀ n ≥ N, ∀ x ∈ s, dist (F m x) (F n x) < ε := by
constructor · intro h ε hε let u := { a : α × α | dist a.fst a.snd < ε } have hu : u ∈ 𝓤 α := Metric.mem_uniformity_dist.mpr ⟨ε, hε, by simp [u]⟩ rw [← @Filter.eventually_atTop_prod_self' _ _ _ fun m => ∀ x ∈ s, dist (F m.fst x) (F m.snd x) < ε] specialize h u hu rw [prod_atTop_atTop_eq] at h exact h.mono fun n h x hx => h x hx · intro h u hu rcases Metric.mem_uniformity_dist.mp hu with ⟨ε, hε, hab⟩ rcases h ε hε with ⟨N, hN⟩ rw [prod_atTop_atTop_eq, eventually_atTop] use (N, N) intro b hb x hx rcases hb with ⟨hbl, hbr⟩ exact hab (hN b.fst hbl.ge b.snd hbr.ge x hx)
/- Copyright (c) 2019 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Data.Multiset.Nodup import Mathlib.Data.List.NatAntidiagonal #align_import data.multiset.nat_antidiagonal from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Antidiagonals in ℕ × ℕ as multisets This file defines the antidiagonals of ℕ × ℕ as multisets: the `n`-th antidiagonal is the multiset of pairs `(i, j)` such that `i + j = n`. This is useful for polynomial multiplication and more generally for sums going from `0` to `n`. ## Notes This refines file `Data.List.NatAntidiagonal` and is further refined by file `Data.Finset.NatAntidiagonal`. -/ namespace Multiset namespace Nat /-- The antidiagonal of a natural number `n` is the multiset of pairs `(i, j)` such that `i + j = n`. -/ def antidiagonal (n : ℕ) : Multiset (ℕ × ℕ) := List.Nat.antidiagonal n #align multiset.nat.antidiagonal Multiset.Nat.antidiagonal /-- A pair (i, j) is contained in the antidiagonal of `n` if and only if `i + j = n`. -/ @[simp] theorem mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} : x ∈ antidiagonal n ↔ x.1 + x.2 = n := by rw [antidiagonal, mem_coe, List.Nat.mem_antidiagonal] #align multiset.nat.mem_antidiagonal Multiset.Nat.mem_antidiagonal /-- The cardinality of the antidiagonal of `n` is `n+1`. -/ @[simp] theorem card_antidiagonal (n : ℕ) : card (antidiagonal n) = n + 1 := by rw [antidiagonal, coe_card, List.Nat.length_antidiagonal] #align multiset.nat.card_antidiagonal Multiset.Nat.card_antidiagonal /-- The antidiagonal of `0` is the list `[(0, 0)]` -/ @[simp] theorem antidiagonal_zero : antidiagonal 0 = {(0, 0)} := rfl #align multiset.nat.antidiagonal_zero Multiset.Nat.antidiagonal_zero /-- The antidiagonal of `n` does not contain duplicate entries. -/ @[simp] theorem nodup_antidiagonal (n : ℕ) : Nodup (antidiagonal n) := coe_nodup.2 <| List.Nat.nodup_antidiagonal n #align multiset.nat.nodup_antidiagonal Multiset.Nat.nodup_antidiagonal @[simp] theorem antidiagonal_succ {n : ℕ} : antidiagonal (n + 1) = (0, n + 1) ::ₘ (antidiagonal n).map (Prod.map Nat.succ id) := by simp only [antidiagonal, List.Nat.antidiagonal_succ, map_coe, cons_coe] #align multiset.nat.antidiagonal_succ Multiset.Nat.antidiagonal_succ
Mathlib/Data/Multiset/NatAntidiagonal.lean
64
67
theorem antidiagonal_succ' {n : ℕ} : antidiagonal (n + 1) = (n + 1, 0) ::ₘ (antidiagonal n).map (Prod.map id Nat.succ) := by
rw [antidiagonal, List.Nat.antidiagonal_succ', ← coe_add, add_comm, antidiagonal, map_coe, coe_add, List.singleton_append, cons_coe]
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Abelian import Mathlib.Algebra.Lie.IdealOperations import Mathlib.Order.Hom.Basic #align_import algebra.lie.solvable from "leanprover-community/mathlib"@"a50170a88a47570ed186b809ca754110590f9476" /-! # Solvable Lie algebras Like groups, Lie algebras admit a natural concept of solvability. We define this here via the derived series and prove some related results. We also define the radical of a Lie algebra and prove that it is solvable when the Lie algebra is Noetherian. ## Main definitions * `LieAlgebra.derivedSeriesOfIdeal` * `LieAlgebra.derivedSeries` * `LieAlgebra.IsSolvable` * `LieAlgebra.isSolvableAdd` * `LieAlgebra.radical` * `LieAlgebra.radicalIsSolvable` * `LieAlgebra.derivedLengthOfIdeal` * `LieAlgebra.derivedLength` * `LieAlgebra.derivedAbelianOfIdeal` ## Tags lie algebra, derived series, derived length, solvable, radical -/ universe u v w w₁ w₂ variable (R : Type u) (L : Type v) (M : Type w) {L' : Type w₁} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] variable (I J : LieIdeal R L) {f : L' →ₗ⁅R⁆ L} namespace LieAlgebra /-- A generalisation of the derived series of a Lie algebra, whose zeroth term is a specified ideal. It can be more convenient to work with this generalisation when considering the derived series of an ideal since it provides a type-theoretic expression of the fact that the terms of the ideal's derived series are also ideals of the enclosing algebra. See also `LieIdeal.derivedSeries_eq_derivedSeriesOfIdeal_comap` and `LieIdeal.derivedSeries_eq_derivedSeriesOfIdeal_map` below. -/ def derivedSeriesOfIdeal (k : ℕ) : LieIdeal R L → LieIdeal R L := (fun I => ⁅I, I⁆)^[k] #align lie_algebra.derived_series_of_ideal LieAlgebra.derivedSeriesOfIdeal @[simp] theorem derivedSeriesOfIdeal_zero : derivedSeriesOfIdeal R L 0 I = I := rfl #align lie_algebra.derived_series_of_ideal_zero LieAlgebra.derivedSeriesOfIdeal_zero @[simp] theorem derivedSeriesOfIdeal_succ (k : ℕ) : derivedSeriesOfIdeal R L (k + 1) I = ⁅derivedSeriesOfIdeal R L k I, derivedSeriesOfIdeal R L k I⁆ := Function.iterate_succ_apply' (fun I => ⁅I, I⁆) k I #align lie_algebra.derived_series_of_ideal_succ LieAlgebra.derivedSeriesOfIdeal_succ /-- The derived series of Lie ideals of a Lie algebra. -/ abbrev derivedSeries (k : ℕ) : LieIdeal R L := derivedSeriesOfIdeal R L k ⊤ #align lie_algebra.derived_series LieAlgebra.derivedSeries theorem derivedSeries_def (k : ℕ) : derivedSeries R L k = derivedSeriesOfIdeal R L k ⊤ := rfl #align lie_algebra.derived_series_def LieAlgebra.derivedSeries_def variable {R L} local notation "D" => derivedSeriesOfIdeal R L theorem derivedSeriesOfIdeal_add (k l : ℕ) : D (k + l) I = D k (D l I) := by induction' k with k ih · rw [Nat.zero_add, derivedSeriesOfIdeal_zero] · rw [Nat.succ_add k l, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ, ih] #align lie_algebra.derived_series_of_ideal_add LieAlgebra.derivedSeriesOfIdeal_add @[mono]
Mathlib/Algebra/Lie/Solvable.lean
89
97
theorem derivedSeriesOfIdeal_le {I J : LieIdeal R L} {k l : ℕ} (h₁ : I ≤ J) (h₂ : l ≤ k) : D k I ≤ D l J := by
revert l; induction' k with k ih <;> intro l h₂ · rw [le_zero_iff] at h₂; rw [h₂, derivedSeriesOfIdeal_zero]; exact h₁ · have h : l = k.succ ∨ l ≤ k := by rwa [le_iff_eq_or_lt, Nat.lt_succ_iff] at h₂ cases' h with h h · rw [h, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ] exact LieSubmodule.mono_lie _ _ _ _ (ih (le_refl k)) (ih (le_refl k)) · rw [derivedSeriesOfIdeal_succ]; exact le_trans (LieSubmodule.lie_le_left _ _) (ih h)
/- 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, Alistair Tucker, Wen Yang -/ import Mathlib.Order.Interval.Set.Image import Mathlib.Order.CompleteLatticeIntervals import Mathlib.Topology.Order.DenselyOrdered import Mathlib.Topology.Order.Monotone #align_import topology.algebra.order.intermediate_value from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" /-! # Intermediate Value Theorem In this file we prove the Intermediate Value Theorem: if `f : α → β` is a function defined on a connected set `s` that takes both values `≤ a` and values `≥ a` on `s`, then it is equal to `a` at some point of `s`. We also prove that intervals in a dense conditionally complete order are preconnected and any preconnected set is an interval. Then we specialize IVT to functions continuous on intervals. ## Main results * `IsPreconnected_I??` : all intervals `I??` are preconnected, * `IsPreconnected.intermediate_value`, `intermediate_value_univ` : Intermediate Value Theorem for connected sets and connected spaces, respectively; * `intermediate_value_Icc`, `intermediate_value_Icc'`: Intermediate Value Theorem for functions on closed intervals. ### Miscellaneous facts * `IsClosed.Icc_subset_of_forall_mem_nhdsWithin` : “Continuous induction” principle; if `s ∩ [a, b]` is closed, `a ∈ s`, and for each `x ∈ [a, b) ∩ s` some of its right neighborhoods is included `s`, then `[a, b] ⊆ s`. * `IsClosed.Icc_subset_of_forall_exists_gt`, `IsClosed.mem_of_ge_of_forall_exists_gt` : two other versions of the “continuous induction” principle. * `ContinuousOn.StrictMonoOn_of_InjOn_Ioo` : Every continuous injective `f : (a, b) → δ` is strictly monotone or antitone (increasing or decreasing). ## Tags intermediate value theorem, connected space, connected set -/ open Filter OrderDual TopologicalSpace Function Set open Topology Filter universe u v w /-! ### Intermediate value theorem on a (pre)connected space In this section we prove the following theorem (see `IsPreconnected.intermediate_value₂`): if `f` and `g` are two functions continuous on a preconnected set `s`, `f a ≤ g a` at some `a ∈ s` and `g b ≤ f b` at some `b ∈ s`, then `f c = g c` at some `c ∈ s`. We prove several versions of this statement, including the classical IVT that corresponds to a constant function `g`. -/ section variable {X : Type u} {α : Type v} [TopologicalSpace X] [LinearOrder α] [TopologicalSpace α] [OrderClosedTopology α] /-- Intermediate value theorem for two functions: if `f` and `g` are two continuous functions on a preconnected space and `f a ≤ g a` and `g b ≤ f b`, then for some `x` we have `f x = g x`. -/
Mathlib/Topology/Order/IntermediateValue.lean
70
75
theorem intermediate_value_univ₂ [PreconnectedSpace X] {a b : X} {f g : X → α} (hf : Continuous f) (hg : Continuous g) (ha : f a ≤ g a) (hb : g b ≤ f b) : ∃ x, f x = g x := by
obtain ⟨x, _, hfg, hgf⟩ : (univ ∩ { x | f x ≤ g x ∧ g x ≤ f x }).Nonempty := isPreconnected_closed_iff.1 PreconnectedSpace.isPreconnected_univ _ _ (isClosed_le hf hg) (isClosed_le hg hf) (fun _ _ => le_total _ _) ⟨a, trivial, ha⟩ ⟨b, trivial, hb⟩ exact ⟨x, le_antisymm hfg hgf⟩
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.CharP.ExpChar import Mathlib.GroupTheory.OrderOfElement #align_import algebra.char_p.two from "leanprover-community/mathlib"@"7f1ba1a333d66eed531ecb4092493cd1b6715450" /-! # Lemmas about rings of characteristic two This file contains results about `CharP R 2`, in the `CharTwo` namespace. The lemmas in this file with a `_sq` suffix are just special cases of the `_pow_char` lemmas elsewhere, with a shorter name for ease of discovery, and no need for a `[Fact (Prime 2)]` argument. -/ variable {R ι : Type*} namespace CharTwo section Semiring variable [Semiring R] [CharP R 2] theorem two_eq_zero : (2 : R) = 0 := by rw [← Nat.cast_two, CharP.cast_eq_zero] #align char_two.two_eq_zero CharTwo.two_eq_zero @[simp] theorem add_self_eq_zero (x : R) : x + x = 0 := by rw [← two_smul R x, two_eq_zero, zero_smul] #align char_two.add_self_eq_zero CharTwo.add_self_eq_zero set_option linter.deprecated false in @[simp] theorem bit0_eq_zero : (bit0 : R → R) = 0 := by funext exact add_self_eq_zero _ #align char_two.bit0_eq_zero CharTwo.bit0_eq_zero set_option linter.deprecated false in theorem bit0_apply_eq_zero (x : R) : (bit0 x : R) = 0 := by simp #align char_two.bit0_apply_eq_zero CharTwo.bit0_apply_eq_zero set_option linter.deprecated false in @[simp] theorem bit1_eq_one : (bit1 : R → R) = 1 := by funext simp [bit1] #align char_two.bit1_eq_one CharTwo.bit1_eq_one set_option linter.deprecated false in theorem bit1_apply_eq_one (x : R) : (bit1 x : R) = 1 := by simp #align char_two.bit1_apply_eq_one CharTwo.bit1_apply_eq_one end Semiring section Ring variable [Ring R] [CharP R 2] @[simp] theorem neg_eq (x : R) : -x = x := by rw [neg_eq_iff_add_eq_zero, ← two_smul R x, two_eq_zero, zero_smul] #align char_two.neg_eq CharTwo.neg_eq theorem neg_eq' : Neg.neg = (id : R → R) := funext neg_eq #align char_two.neg_eq' CharTwo.neg_eq' @[simp] theorem sub_eq_add (x y : R) : x - y = x + y := by rw [sub_eq_add_neg, neg_eq] #align char_two.sub_eq_add CharTwo.sub_eq_add theorem sub_eq_add' : HSub.hSub = ((· + ·) : R → R → R) := funext fun x => funext fun y => sub_eq_add x y #align char_two.sub_eq_add' CharTwo.sub_eq_add' end Ring section CommSemiring variable [CommSemiring R] [CharP R 2] theorem add_sq (x y : R) : (x + y) ^ 2 = x ^ 2 + y ^ 2 := add_pow_char _ _ _ #align char_two.add_sq CharTwo.add_sq theorem add_mul_self (x y : R) : (x + y) * (x + y) = x * x + y * y := by rw [← pow_two, ← pow_two, ← pow_two, add_sq] #align char_two.add_mul_self CharTwo.add_mul_self theorem list_sum_sq (l : List R) : l.sum ^ 2 = (l.map (· ^ 2)).sum := list_sum_pow_char _ _ #align char_two.list_sum_sq CharTwo.list_sum_sq
Mathlib/Algebra/CharP/Two.lean
99
100
theorem list_sum_mul_self (l : List R) : l.sum * l.sum = (List.map (fun x => x * x) l).sum := by
simp_rw [← pow_two, list_sum_sq]
/- 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.Complex.Log #align_import analysis.special_functions.pow.complex from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" /-! # Power function on `ℂ` We construct the power functions `x ^ y`, where `x` and `y` are complex numbers. -/ open scoped Classical open Real Topology Filter ComplexConjugate Finset Set namespace Complex /-- The complex power function `x ^ y`, given by `x ^ y = exp(y log x)` (where `log` is the principal determination of the logarithm), unless `x = 0` where one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y ≠ 0`. -/ noncomputable def cpow (x y : ℂ) : ℂ := if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) #align complex.cpow Complex.cpow noncomputable instance : Pow ℂ ℂ := ⟨cpow⟩ @[simp] theorem cpow_eq_pow (x y : ℂ) : cpow x y = x ^ y := rfl #align complex.cpow_eq_pow Complex.cpow_eq_pow theorem cpow_def (x y : ℂ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := rfl #align complex.cpow_def Complex.cpow_def theorem cpow_def_of_ne_zero {x : ℂ} (hx : x ≠ 0) (y : ℂ) : x ^ y = exp (log x * y) := if_neg hx #align complex.cpow_def_of_ne_zero Complex.cpow_def_of_ne_zero @[simp]
Mathlib/Analysis/SpecialFunctions/Pow/Complex.lean
45
45
theorem cpow_zero (x : ℂ) : x ^ (0 : ℂ) = 1 := by
simp [cpow_def]
/- Copyright (c) 2014 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Yury Kudryashov, Neil Strickland -/ import Mathlib.Algebra.Ring.Semiconj import Mathlib.Algebra.Ring.Units import Mathlib.Algebra.Group.Commute.Defs import Mathlib.Data.Bracket #align_import algebra.ring.commute from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" /-! # Semirings and rings This file gives lemmas about semirings, rings and domains. This is analogous to `Mathlib.Algebra.Group.Basic`, the difference being that the former is about `+` and `*` separately, while the present file is about their interaction. For the definitions of semirings and rings see `Mathlib.Algebra.Ring.Defs`. -/ universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace Commute @[simp] theorem add_right [Distrib R] {a b c : R} : Commute a b → Commute a c → Commute a (b + c) := SemiconjBy.add_right #align commute.add_right Commute.add_rightₓ -- for some reason mathport expected `Semiring` instead of `Distrib`? @[simp] theorem add_left [Distrib R] {a b c : R} : Commute a c → Commute b c → Commute (a + b) c := SemiconjBy.add_left #align commute.add_left Commute.add_leftₓ -- for some reason mathport expected `Semiring` instead of `Distrib`? section deprecated set_option linter.deprecated false @[deprecated] theorem bit0_right [Distrib R] {x y : R} (h : Commute x y) : Commute x (bit0 y) := h.add_right h #align commute.bit0_right Commute.bit0_right @[deprecated] theorem bit0_left [Distrib R] {x y : R} (h : Commute x y) : Commute (bit0 x) y := h.add_left h #align commute.bit0_left Commute.bit0_left @[deprecated] theorem bit1_right [NonAssocSemiring R] {x y : R} (h : Commute x y) : Commute x (bit1 y) := h.bit0_right.add_right (Commute.one_right x) #align commute.bit1_right Commute.bit1_right @[deprecated] theorem bit1_left [NonAssocSemiring R] {x y : R} (h : Commute x y) : Commute (bit1 x) y := h.bit0_left.add_left (Commute.one_left y) #align commute.bit1_left Commute.bit1_left end deprecated /-- Representation of a difference of two squares of commuting elements as a product. -/
Mathlib/Algebra/Ring/Commute.lean
72
74
theorem mul_self_sub_mul_self_eq [NonUnitalNonAssocRing R] {a b : R} (h : Commute a b) : a * a - b * b = (a + b) * (a - b) := by
rw [add_mul, mul_sub, mul_sub, h.eq, sub_add_sub_cancel]
/- Copyright (c) 2024 Emilie Burgun. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Emilie Burgun -/ import Mathlib.Algebra.Group.Commute.Basic import Mathlib.GroupTheory.GroupAction.Basic import Mathlib.Dynamics.PeriodicPts import Mathlib.Data.Set.Pointwise.SMul /-! # Properties of `fixedPoints` and `fixedBy` This module contains some useful properties of `MulAction.fixedPoints` and `MulAction.fixedBy` that don't directly belong to `Mathlib.GroupTheory.GroupAction.Basic`. ## Main theorems * `MulAction.fixedBy_mul`: `fixedBy α (g * h) ⊆ fixedBy α g ∪ fixedBy α h` * `MulAction.fixedBy_conj` and `MulAction.smul_fixedBy`: the pointwise group action of `h` on `fixedBy α g` is equal to the `fixedBy` set of the conjugation of `h` with `g` (`fixedBy α (h * g * h⁻¹)`). * `MulAction.set_mem_fixedBy_of_movedBy_subset` shows that if a set `s` is a superset of `(fixedBy α g)ᶜ`, then the group action of `g` cannot send elements of `s` outside of `s`. This is expressed as `s ∈ fixedBy (Set α) g`, and `MulAction.set_mem_fixedBy_iff` allows one to convert the relationship back to `g • x ∈ s ↔ x ∈ s`. * `MulAction.not_commute_of_disjoint_smul_movedBy` allows one to prove that `g` and `h` do not commute from the disjointness of the `(fixedBy α g)ᶜ` set and `h • (fixedBy α g)ᶜ`, which is a property used in the proof of Rubin's theorem. The theorems above are also available for `AddAction`. ## Pointwise group action and `fixedBy (Set α) g` Since `fixedBy α g = { x | g • x = x }` by definition, properties about the pointwise action of a set `s : Set α` can be expressed using `fixedBy (Set α) g`. To properly use theorems using `fixedBy (Set α) g`, you should `open Pointwise` in your file. `s ∈ fixedBy (Set α) g` means that `g • s = s`, which is equivalent to say that `∀ x, g • x ∈ s ↔ x ∈ s` (the translation can be done using `MulAction.set_mem_fixedBy_iff`). `s ∈ fixedBy (Set α) g` is a weaker statement than `s ⊆ fixedBy α g`: the latter requires that all points in `s` are fixed by `g`, whereas the former only requires that `g • x ∈ s`. -/ namespace MulAction open Pointwise variable {α : Type*} variable {G : Type*} [Group G] [MulAction G α] variable {M : Type*} [Monoid M] [MulAction M α] section FixedPoints variable (α) in /-- In a multiplicative group action, the points fixed by `g` are also fixed by `g⁻¹` -/ @[to_additive (attr := simp) "In an additive group action, the points fixed by `g` are also fixed by `g⁻¹`"] theorem fixedBy_inv (g : G) : fixedBy α g⁻¹ = fixedBy α g := by ext rw [mem_fixedBy, mem_fixedBy, inv_smul_eq_iff, eq_comm] @[to_additive] theorem smul_mem_fixedBy_iff_mem_fixedBy {a : α} {g : G} : g • a ∈ fixedBy α g ↔ a ∈ fixedBy α g := by rw [mem_fixedBy, smul_left_cancel_iff] rfl @[to_additive] theorem smul_inv_mem_fixedBy_iff_mem_fixedBy {a : α} {g : G} : g⁻¹ • a ∈ fixedBy α g ↔ a ∈ fixedBy α g := by rw [← fixedBy_inv, smul_mem_fixedBy_iff_mem_fixedBy, fixedBy_inv] @[to_additive minimalPeriod_eq_one_iff_fixedBy] theorem minimalPeriod_eq_one_iff_fixedBy {a : α} {g : G} : Function.minimalPeriod (fun x => g • x) a = 1 ↔ a ∈ fixedBy α g := Function.minimalPeriod_eq_one_iff_isFixedPt variable (α) in @[to_additive] theorem fixedBy_subset_fixedBy_zpow (g : G) (j : ℤ) : fixedBy α g ⊆ fixedBy α (g ^ j) := by intro a a_in_fixedBy rw [mem_fixedBy, zpow_smul_eq_iff_minimalPeriod_dvd, minimalPeriod_eq_one_iff_fixedBy.mpr a_in_fixedBy, Nat.cast_one] exact one_dvd j variable (M α) in @[to_additive (attr := simp)] theorem fixedBy_one_eq_univ : fixedBy α (1 : M) = Set.univ := Set.eq_univ_iff_forall.mpr <| one_smul M variable (α) in @[to_additive] theorem fixedBy_mul (m₁ m₂ : M) : fixedBy α m₁ ∩ fixedBy α m₂ ⊆ fixedBy α (m₁ * m₂) := by intro a ⟨h₁, h₂⟩ rw [mem_fixedBy, mul_smul, h₂, h₁] variable (α) in @[to_additive] theorem smul_fixedBy (g h: G) : h • fixedBy α g = fixedBy α (h * g * h⁻¹) := by ext a simp_rw [Set.mem_smul_set_iff_inv_smul_mem, mem_fixedBy, mul_smul, smul_eq_iff_eq_inv_smul h] end FixedPoints section Pointwise /-! ### `fixedBy` sets of the pointwise group action The theorems below need the `Pointwise` scoped to be opened (using `open Pointwise`) to be used effectively. -/ /-- If a set `s : Set α` is in `fixedBy (Set α) g`, then all points of `s` will stay in `s` after being moved by `g`. -/ @[to_additive "If a set `s : Set α` is in `fixedBy (Set α) g`, then all points of `s` will stay in `s` after being moved by `g`."]
Mathlib/GroupTheory/GroupAction/FixedPoints.lean
124
126
theorem set_mem_fixedBy_iff (s : Set α) (g : G) : s ∈ fixedBy (Set α) g ↔ ∀ x, g • x ∈ s ↔ x ∈ s := by
simp_rw [mem_fixedBy, ← eq_inv_smul_iff, Set.ext_iff, Set.mem_inv_smul_set_iff, Iff.comm]
/- 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.Bind #align_import data.multiset.fold from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # The fold operation for a commutative associative operation over a multiset. -/ namespace Multiset variable {α β : Type*} /-! ### fold -/ section Fold variable (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] local notation a " * " b => op a b /-- `fold op b s` folds a commutative associative operation `op` over the multiset `s`. -/ def fold : α → Multiset α → α := foldr op (left_comm _ hc.comm ha.assoc) #align multiset.fold Multiset.fold theorem fold_eq_foldr (b : α) (s : Multiset α) : fold op b s = foldr op (left_comm _ hc.comm ha.assoc) b s := rfl #align multiset.fold_eq_foldr Multiset.fold_eq_foldr @[simp] theorem coe_fold_r (b : α) (l : List α) : fold op b l = l.foldr op b := rfl #align multiset.coe_fold_r Multiset.coe_fold_r theorem coe_fold_l (b : α) (l : List α) : fold op b l = l.foldl op b := (coe_foldr_swap op _ b l).trans <| by simp [hc.comm] #align multiset.coe_fold_l Multiset.coe_fold_l theorem fold_eq_foldl (b : α) (s : Multiset α) : fold op b s = foldl op (right_comm _ hc.comm ha.assoc) b s := Quot.inductionOn s fun _ => coe_fold_l _ _ _ #align multiset.fold_eq_foldl Multiset.fold_eq_foldl @[simp] theorem fold_zero (b : α) : (0 : Multiset α).fold op b = b := rfl #align multiset.fold_zero Multiset.fold_zero @[simp] theorem fold_cons_left : ∀ (b a : α) (s : Multiset α), (a ::ₘ s).fold op b = a * s.fold op b := foldr_cons _ _ #align multiset.fold_cons_left Multiset.fold_cons_left theorem fold_cons_right (b a : α) (s : Multiset α) : (a ::ₘ s).fold op b = s.fold op b * a := by simp [hc.comm] #align multiset.fold_cons_right Multiset.fold_cons_right
Mathlib/Data/Multiset/Fold.lean
67
68
theorem fold_cons'_right (b a : α) (s : Multiset α) : (a ::ₘ s).fold op b = s.fold op (b * a) := by
rw [fold_eq_foldl, foldl_cons, ← fold_eq_foldl]
/- Copyright (c) 2021 Frédéric Dupuis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Frédéric Dupuis -/ import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Star.Pi #align_import algebra.star.self_adjoint from "leanprover-community/mathlib"@"a6ece35404f60597c651689c1b46ead86de5ac1b" /-! # Self-adjoint, skew-adjoint and normal elements of a star additive group This file defines `selfAdjoint R` (resp. `skewAdjoint R`), where `R` is a star additive group, as the additive subgroup containing the elements that satisfy `star x = x` (resp. `star x = -x`). This includes, for instance, (skew-)Hermitian operators on Hilbert spaces. We also define `IsStarNormal R`, a `Prop` that states that an element `x` satisfies `star x * x = x * star x`. ## Implementation notes * When `R` is a `StarModule R₂ R`, then `selfAdjoint R` has a natural `Module (selfAdjoint R₂) (selfAdjoint R)` structure. However, doing this literally would be undesirable since in the main case of interest (`R₂ = ℂ`) we want `Module ℝ (selfAdjoint R)` and not `Module (selfAdjoint ℂ) (selfAdjoint R)`. We solve this issue by adding the typeclass `[TrivialStar R₃]`, of which `ℝ` is an instance (registered in `Data/Real/Basic`), and then add a `[Module R₃ (selfAdjoint R)]` instance whenever we have `[Module R₃ R] [TrivialStar R₃]`. (Another approach would have been to define `[StarInvariantScalars R₃ R]` to express the fact that `star (x • v) = x • star v`, but this typeclass would have the disadvantage of taking two type arguments.) ## TODO * Define `IsSkewAdjoint` to match `IsSelfAdjoint`. * Define `fun z x => z * x * star z` (i.e. conjugation by `z`) as a monoid action of `R` on `R` (similar to the existing `ConjAct` for groups), and then state the fact that `selfAdjoint R` is invariant under it. -/ open Function variable {R A : Type*} /-- An element is self-adjoint if it is equal to its star. -/ def IsSelfAdjoint [Star R] (x : R) : Prop := star x = x #align is_self_adjoint IsSelfAdjoint /-- An element of a star monoid is normal if it commutes with its adjoint. -/ @[mk_iff] class IsStarNormal [Mul R] [Star R] (x : R) : Prop where /-- A normal element of a star monoid commutes with its adjoint. -/ star_comm_self : Commute (star x) x #align is_star_normal IsStarNormal export IsStarNormal (star_comm_self) theorem star_comm_self' [Mul R] [Star R] (x : R) [IsStarNormal x] : star x * x = x * star x := IsStarNormal.star_comm_self #align star_comm_self' star_comm_self' namespace IsSelfAdjoint -- named to match `Commute.allₓ` /-- All elements are self-adjoint when `star` is trivial. -/ theorem all [Star R] [TrivialStar R] (r : R) : IsSelfAdjoint r := star_trivial _ #align is_self_adjoint.all IsSelfAdjoint.all theorem star_eq [Star R] {x : R} (hx : IsSelfAdjoint x) : star x = x := hx #align is_self_adjoint.star_eq IsSelfAdjoint.star_eq theorem _root_.isSelfAdjoint_iff [Star R] {x : R} : IsSelfAdjoint x ↔ star x = x := Iff.rfl #align is_self_adjoint_iff isSelfAdjoint_iff @[simp]
Mathlib/Algebra/Star/SelfAdjoint.lean
82
83
theorem star_iff [InvolutiveStar R] {x : R} : IsSelfAdjoint (star x) ↔ IsSelfAdjoint x := by
simpa only [IsSelfAdjoint, star_star] using eq_comm
/- Copyright (c) 2020 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import Mathlib.Combinatorics.SimpleGraph.Basic /-! # Darts in graphs A `Dart` or half-edge or bond in a graph is an ordered pair of adjacent vertices, regarded as an oriented edge. This file defines darts and proves some of their basic properties. -/ namespace SimpleGraph variable {V : Type*} (G : SimpleGraph V) /-- A `Dart` is an oriented edge, implemented as an ordered pair of adjacent vertices. This terminology comes from combinatorial maps, and they are also known as "half-edges" or "bonds." -/ structure Dart extends V × V where adj : G.Adj fst snd deriving DecidableEq #align simple_graph.dart SimpleGraph.Dart initialize_simps_projections Dart (+toProd, -fst, -snd) attribute [simp] Dart.adj variable {G} theorem Dart.ext_iff (d₁ d₂ : G.Dart) : d₁ = d₂ ↔ d₁.toProd = d₂.toProd := by cases d₁; cases d₂; simp #align simple_graph.dart.ext_iff SimpleGraph.Dart.ext_iff @[ext] theorem Dart.ext (d₁ d₂ : G.Dart) (h : d₁.toProd = d₂.toProd) : d₁ = d₂ := (Dart.ext_iff d₁ d₂).mpr h #align simple_graph.dart.ext SimpleGraph.Dart.ext -- Porting note: deleted `Dart.fst` and `Dart.snd` since they are now invalid declaration names, -- even though there is not actually a `SimpleGraph.Dart.fst` or `SimpleGraph.Dart.snd`. theorem Dart.toProd_injective : Function.Injective (Dart.toProd : G.Dart → V × V) := Dart.ext #align simple_graph.dart.to_prod_injective SimpleGraph.Dart.toProd_injective instance Dart.fintype [Fintype V] [DecidableRel G.Adj] : Fintype G.Dart := Fintype.ofEquiv (Σ v, G.neighborSet v) { toFun := fun s => ⟨(s.fst, s.snd), s.snd.property⟩ invFun := fun d => ⟨d.fst, d.snd, d.adj⟩ left_inv := fun s => by ext <;> simp right_inv := fun d => by ext <;> simp } #align simple_graph.dart.fintype SimpleGraph.Dart.fintype /-- The edge associated to the dart. -/ def Dart.edge (d : G.Dart) : Sym2 V := Sym2.mk d.toProd #align simple_graph.dart.edge SimpleGraph.Dart.edge @[simp] theorem Dart.edge_mk {p : V × V} (h : G.Adj p.1 p.2) : (Dart.mk p h).edge = Sym2.mk p := rfl #align simple_graph.dart.edge_mk SimpleGraph.Dart.edge_mk @[simp] theorem Dart.edge_mem (d : G.Dart) : d.edge ∈ G.edgeSet := d.adj #align simple_graph.dart.edge_mem SimpleGraph.Dart.edge_mem /-- The dart with reversed orientation from a given dart. -/ @[simps] def Dart.symm (d : G.Dart) : G.Dart := ⟨d.toProd.swap, G.symm d.adj⟩ #align simple_graph.dart.symm SimpleGraph.Dart.symm @[simp] theorem Dart.symm_mk {p : V × V} (h : G.Adj p.1 p.2) : (Dart.mk p h).symm = Dart.mk p.swap h.symm := rfl #align simple_graph.dart.symm_mk SimpleGraph.Dart.symm_mk @[simp] theorem Dart.edge_symm (d : G.Dart) : d.symm.edge = d.edge := Sym2.mk_prod_swap_eq #align simple_graph.dart.edge_symm SimpleGraph.Dart.edge_symm @[simp] theorem Dart.edge_comp_symm : Dart.edge ∘ Dart.symm = (Dart.edge : G.Dart → Sym2 V) := funext Dart.edge_symm #align simple_graph.dart.edge_comp_symm SimpleGraph.Dart.edge_comp_symm @[simp] theorem Dart.symm_symm (d : G.Dart) : d.symm.symm = d := Dart.ext _ _ <| Prod.swap_swap _ #align simple_graph.dart.symm_symm SimpleGraph.Dart.symm_symm @[simp] theorem Dart.symm_involutive : Function.Involutive (Dart.symm : G.Dart → G.Dart) := Dart.symm_symm #align simple_graph.dart.symm_involutive SimpleGraph.Dart.symm_involutive theorem Dart.symm_ne (d : G.Dart) : d.symm ≠ d := ne_of_apply_ne (Prod.snd ∘ Dart.toProd) d.adj.ne #align simple_graph.dart.symm_ne SimpleGraph.Dart.symm_ne theorem dart_edge_eq_iff : ∀ d₁ d₂ : G.Dart, d₁.edge = d₂.edge ↔ d₁ = d₂ ∨ d₁ = d₂.symm := by rintro ⟨p, hp⟩ ⟨q, hq⟩ simp #align simple_graph.dart_edge_eq_iff SimpleGraph.dart_edge_eq_iff
Mathlib/Combinatorics/SimpleGraph/Dart.lean
112
115
theorem dart_edge_eq_mk'_iff : ∀ {d : G.Dart} {p : V × V}, d.edge = Sym2.mk p ↔ d.toProd = p ∨ d.toProd = p.swap := by
rintro ⟨p, h⟩ apply Sym2.mk_eq_mk_iff
/- Copyright (c) 2018 Mitchell Rowett. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mitchell Rowett, Scott Morrison -/ import Mathlib.Algebra.Quotient import Mathlib.Algebra.Group.Subgroup.Actions import Mathlib.Algebra.Group.Subgroup.MulOpposite import Mathlib.GroupTheory.GroupAction.Basic import Mathlib.SetTheory.Cardinal.Finite #align_import group_theory.coset from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Cosets This file develops the basic theory of left and right cosets. When `G` is a group and `a : G`, `s : Set G`, with `open scoped Pointwise` we can write: * the left coset of `s` by `a` as `a • s` * the right coset of `s` by `a` as `MulOpposite.op a • s` (or `op a • s` with `open MulOpposite`) If instead `G` is an additive group, we can write (with `open scoped Pointwise` still) * the left coset of `s` by `a` as `a +ᵥ s` * the right coset of `s` by `a` as `AddOpposite.op a +ᵥ s` (or `op a • s` with `open AddOpposite`) ## Main definitions * `QuotientGroup.quotient s`: the quotient type representing the left cosets with respect to a subgroup `s`, for an `AddGroup` this is `QuotientAddGroup.quotient s`. * `QuotientGroup.mk`: the canonical map from `α` to `α/s` for a subgroup `s` of `α`, for an `AddGroup` this is `QuotientAddGroup.mk`. * `Subgroup.leftCosetEquivSubgroup`: the natural bijection between a left coset and the subgroup, for an `AddGroup` this is `AddSubgroup.leftCosetEquivAddSubgroup`. ## Notation * `G ⧸ H` is the quotient of the (additive) group `G` by the (additive) subgroup `H` ## TODO Properly merge with pointwise actions on sets, by renaming and deduplicating lemmas as appropriate. -/ open Function MulOpposite Set open scoped Pointwise variable {α : Type*} #align left_coset HSMul.hSMul #align left_add_coset HVAdd.hVAdd #noalign right_coset #noalign right_add_coset section CosetMul variable [Mul α] @[to_additive mem_leftAddCoset] theorem mem_leftCoset {s : Set α} {x : α} (a : α) (hxS : x ∈ s) : a * x ∈ a • s := mem_image_of_mem (fun b : α => a * b) hxS #align mem_left_coset mem_leftCoset #align mem_left_add_coset mem_leftAddCoset @[to_additive mem_rightAddCoset] theorem mem_rightCoset {s : Set α} {x : α} (a : α) (hxS : x ∈ s) : x * a ∈ op a • s := mem_image_of_mem (fun b : α => b * a) hxS #align mem_right_coset mem_rightCoset #align mem_right_add_coset mem_rightAddCoset /-- Equality of two left cosets `a * s` and `b * s`. -/ @[to_additive LeftAddCosetEquivalence "Equality of two left cosets `a + s` and `b + s`."] def LeftCosetEquivalence (s : Set α) (a b : α) := a • s = b • s #align left_coset_equivalence LeftCosetEquivalence #align left_add_coset_equivalence LeftAddCosetEquivalence @[to_additive leftAddCosetEquivalence_rel] theorem leftCosetEquivalence_rel (s : Set α) : Equivalence (LeftCosetEquivalence s) := @Equivalence.mk _ (LeftCosetEquivalence s) (fun _ => rfl) Eq.symm Eq.trans #align left_coset_equivalence_rel leftCosetEquivalence_rel #align left_add_coset_equivalence_rel leftAddCosetEquivalence_rel /-- Equality of two right cosets `s * a` and `s * b`. -/ @[to_additive RightAddCosetEquivalence "Equality of two right cosets `s + a` and `s + b`."] def RightCosetEquivalence (s : Set α) (a b : α) := op a • s = op b • s #align right_coset_equivalence RightCosetEquivalence #align right_add_coset_equivalence RightAddCosetEquivalence @[to_additive rightAddCosetEquivalence_rel] theorem rightCosetEquivalence_rel (s : Set α) : Equivalence (RightCosetEquivalence s) := @Equivalence.mk _ (RightCosetEquivalence s) (fun _a => rfl) Eq.symm Eq.trans #align right_coset_equivalence_rel rightCosetEquivalence_rel #align right_add_coset_equivalence_rel rightAddCosetEquivalence_rel end CosetMul section CosetSemigroup variable [Semigroup α] @[to_additive leftAddCoset_assoc] theorem leftCoset_assoc (s : Set α) (a b : α) : a • (b • s) = (a * b) • s := by simp [← image_smul, (image_comp _ _ _).symm, Function.comp, mul_assoc] #align left_coset_assoc leftCoset_assoc #align left_add_coset_assoc leftAddCoset_assoc @[to_additive rightAddCoset_assoc]
Mathlib/GroupTheory/Coset.lean
111
112
theorem rightCoset_assoc (s : Set α) (a b : α) : op b • op a • s = op (a * b) • s := by
simp [← image_smul, (image_comp _ _ _).symm, Function.comp, mul_assoc]
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.indicator from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" /-! # Building finitely supported functions off finsets This file defines `Finsupp.indicator` to help create finsupps from finsets. ## Main declarations * `Finsupp.indicator`: Turns a map from a `Finset` into a `Finsupp` from the entire type. -/ noncomputable section open Finset Function variable {ι α : Type*} namespace Finsupp variable [Zero α] {s : Finset ι} (f : ∀ i ∈ s, α) {i : ι} /-- Create an element of `ι →₀ α` from a finset `s` and a function `f` defined on this finset. -/ def indicator (s : Finset ι) (f : ∀ i ∈ s, α) : ι →₀ α where toFun i := haveI := Classical.decEq ι if H : i ∈ s then f i H else 0 support := haveI := Classical.decEq α (s.attach.filter fun i : s => f i.1 i.2 ≠ 0).map (Embedding.subtype _) mem_support_toFun i := by classical simp #align finsupp.indicator Finsupp.indicator theorem indicator_of_mem (hi : i ∈ s) (f : ∀ i ∈ s, α) : indicator s f i = f i hi := @dif_pos _ (id _) hi _ _ _ #align finsupp.indicator_of_mem Finsupp.indicator_of_mem theorem indicator_of_not_mem (hi : i ∉ s) (f : ∀ i ∈ s, α) : indicator s f i = 0 := @dif_neg _ (id _) hi _ _ _ #align finsupp.indicator_of_not_mem Finsupp.indicator_of_not_mem variable (s i) @[simp]
Mathlib/Data/Finsupp/Indicator.lean
54
56
theorem indicator_apply [DecidableEq ι] : indicator s f i = if hi : i ∈ s then f i hi else 0 := by
simp only [indicator, ne_eq, coe_mk] congr
/- Copyright (c) 2021 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace import Mathlib.Analysis.LocallyConvex.Barrelled import Mathlib.Topology.Baire.CompleteMetrizable #align_import analysis.normed_space.banach_steinhaus from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # The Banach-Steinhaus theorem: Uniform Boundedness Principle Herein we prove the Banach-Steinhaus theorem for normed spaces: any collection of bounded linear maps from a Banach space into a normed space which is pointwise bounded is uniformly bounded. Note that we prove the more general version about barrelled spaces in `Analysis.LocallyConvex.Barrelled`, and the usual version below is indeed deduced from the more general setup. -/ open Set variable {E F 𝕜 𝕜₂ : Type*} [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂] /-- This is the standard Banach-Steinhaus theorem, or Uniform Boundedness Principle. If a family of continuous linear maps from a Banach space into a normed space is pointwise bounded, then the norms of these linear maps are uniformly bounded. See also `WithSeminorms.banach_steinhaus` for the general statement in barrelled spaces. -/
Mathlib/Analysis/NormedSpace/BanachSteinhaus.lean
34
38
theorem banach_steinhaus {ι : Type*} [CompleteSpace E] {g : ι → E →SL[σ₁₂] F} (h : ∀ x, ∃ C, ∀ i, ‖g i x‖ ≤ C) : ∃ C', ∀ i, ‖g i‖ ≤ C' := by
rw [show (∃ C, ∀ i, ‖g i‖ ≤ C) ↔ _ from (NormedSpace.equicontinuous_TFAE g).out 5 2] refine (norm_withSeminorms 𝕜₂ F).banach_steinhaus (fun _ x ↦ ?_) simpa [bddAbove_def, forall_mem_range] using h x
/- Copyright (c) 2023 Peter Nelson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Peter Nelson -/ import Mathlib.SetTheory.Cardinal.Finite #align_import data.set.ncard from "leanprover-community/mathlib"@"74c2af38a828107941029b03839882c5c6f87a04" /-! # Noncomputable Set Cardinality We define the cardinality of set `s` as a term `Set.encard s : ℕ∞` and a term `Set.ncard s : ℕ`. The latter takes the junk value of zero if `s` is infinite. Both functions are noncomputable, and are defined in terms of `PartENat.card` (which takes a type as its argument); this file can be seen as an API for the same function in the special case where the type is a coercion of a `Set`, allowing for smoother interactions with the `Set` API. `Set.encard` never takes junk values, so is more mathematically natural than `Set.ncard`, even though it takes values in a less convenient type. It is probably the right choice in settings where one is concerned with the cardinalities of sets that may or may not be infinite. `Set.ncard` has a nicer codomain, but when using it, `Set.Finite` hypotheses are normally needed to make sure its values are meaningful. More generally, `Set.ncard` is intended to be used over the obvious alternative `Finset.card` when finiteness is 'propositional' rather than 'structural'. When working with sets that are finite by virtue of their definition, then `Finset.card` probably makes more sense. One setting where `Set.ncard` works nicely is in a type `α` with `[Finite α]`, where every set is automatically finite. In this setting, we use default arguments and a simple tactic so that finiteness goals are discharged automatically in `Set.ncard` theorems. ## Main Definitions * `Set.encard s` is the cardinality of the set `s` as an extended natural number, with value `⊤` if `s` is infinite. * `Set.ncard s` is the cardinality of the set `s` as a natural number, provided `s` is Finite. If `s` is Infinite, then `Set.ncard s = 0`. * `toFinite_tac` is a tactic that tries to synthesize a `Set.Finite s` argument with `Set.toFinite`. This will work for `s : Set α` where there is a `Finite α` instance. ## Implementation Notes The theorems in this file are very similar to those in `Data.Finset.Card`, but with `Set` operations instead of `Finset`. We first prove all the theorems for `Set.encard`, and then derive most of the `Set.ncard` results as a consequence. Things are done this way to avoid reliance on the `Finset` API for theorems about infinite sets, and to allow for a refactor that removes or modifies `Set.ncard` in the future. Nearly all the theorems for `Set.ncard` require finiteness of one or more of their arguments. We provide this assumption with a default argument of the form `(hs : s.Finite := by toFinite_tac)`, where `toFinite_tac` will find an `s.Finite` term in the cases where `s` is a set in a `Finite` type. Often, where there are two set arguments `s` and `t`, the finiteness of one follows from the other in the context of the theorem, in which case we only include the ones that are needed, and derive the other inside the proof. A few of the theorems, such as `ncard_union_le` do not require finiteness arguments; they are true by coincidence due to junk values. -/ namespace Set variable {α β : Type*} {s t : Set α} /-- The cardinality of a set as a term in `ℕ∞` -/ noncomputable def encard (s : Set α) : ℕ∞ := PartENat.withTopEquiv (PartENat.card s) @[simp] theorem encard_univ_coe (s : Set α) : encard (univ : Set s) = encard s := by rw [encard, encard, PartENat.card_congr (Equiv.Set.univ ↑s)] theorem encard_univ (α : Type*) : encard (univ : Set α) = PartENat.withTopEquiv (PartENat.card α) := by rw [encard, PartENat.card_congr (Equiv.Set.univ α)]
Mathlib/Data/Set/Card.lean
73
76
theorem Finite.encard_eq_coe_toFinset_card (h : s.Finite) : s.encard = h.toFinset.card := by
have := h.fintype rw [encard, PartENat.card_eq_coe_fintype_card, PartENat.withTopEquiv_natCast, toFinite_toFinset, toFinset_card]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot -/ import Mathlib.GroupTheory.GroupAction.ConjAct import Mathlib.GroupTheory.GroupAction.Quotient import Mathlib.GroupTheory.QuotientGroup import Mathlib.Topology.Algebra.Monoid import Mathlib.Topology.Algebra.Constructions #align_import topology.algebra.group.basic from "leanprover-community/mathlib"@"3b1890e71632be9e3b2086ab512c3259a7e9a3ef" /-! # Topological groups This file defines the following typeclasses: * `TopologicalGroup`, `TopologicalAddGroup`: multiplicative and additive topological groups, i.e., groups with continuous `(*)` and `(⁻¹)` / `(+)` and `(-)`; * `ContinuousSub G` means that `G` has a continuous subtraction operation. There is an instance deducing `ContinuousSub` from `TopologicalGroup` but we use a separate typeclass because, e.g., `ℕ` and `ℝ≥0` have continuous subtraction but are not additive groups. We also define `Homeomorph` versions of several `Equiv`s: `Homeomorph.mulLeft`, `Homeomorph.mulRight`, `Homeomorph.inv`, and prove a few facts about neighbourhood filters in groups. ## Tags topological space, group, topological group -/ open scoped Classical open Set Filter TopologicalSpace Function Topology Pointwise MulOpposite universe u v w x variable {G : Type w} {H : Type x} {α : Type u} {β : Type v} section ContinuousMulGroup /-! ### Groups with continuous multiplication In this section we prove a few statements about groups with continuous `(*)`. -/ variable [TopologicalSpace G] [Group G] [ContinuousMul G] /-- Multiplication from the left in a topological group as a homeomorphism. -/ @[to_additive "Addition from the left in a topological additive group as a homeomorphism."] protected def Homeomorph.mulLeft (a : G) : G ≃ₜ G := { Equiv.mulLeft a with continuous_toFun := continuous_const.mul continuous_id continuous_invFun := continuous_const.mul continuous_id } #align homeomorph.mul_left Homeomorph.mulLeft #align homeomorph.add_left Homeomorph.addLeft @[to_additive (attr := simp)] theorem Homeomorph.coe_mulLeft (a : G) : ⇑(Homeomorph.mulLeft a) = (a * ·) := rfl #align homeomorph.coe_mul_left Homeomorph.coe_mulLeft #align homeomorph.coe_add_left Homeomorph.coe_addLeft @[to_additive] theorem Homeomorph.mulLeft_symm (a : G) : (Homeomorph.mulLeft a).symm = Homeomorph.mulLeft a⁻¹ := by ext rfl #align homeomorph.mul_left_symm Homeomorph.mulLeft_symm #align homeomorph.add_left_symm Homeomorph.addLeft_symm @[to_additive] lemma isOpenMap_mul_left (a : G) : IsOpenMap (a * ·) := (Homeomorph.mulLeft a).isOpenMap #align is_open_map_mul_left isOpenMap_mul_left #align is_open_map_add_left isOpenMap_add_left @[to_additive IsOpen.left_addCoset] theorem IsOpen.leftCoset {U : Set G} (h : IsOpen U) (x : G) : IsOpen (x • U) := isOpenMap_mul_left x _ h #align is_open.left_coset IsOpen.leftCoset #align is_open.left_add_coset IsOpen.left_addCoset @[to_additive] lemma isClosedMap_mul_left (a : G) : IsClosedMap (a * ·) := (Homeomorph.mulLeft a).isClosedMap #align is_closed_map_mul_left isClosedMap_mul_left #align is_closed_map_add_left isClosedMap_add_left @[to_additive IsClosed.left_addCoset] theorem IsClosed.leftCoset {U : Set G} (h : IsClosed U) (x : G) : IsClosed (x • U) := isClosedMap_mul_left x _ h #align is_closed.left_coset IsClosed.leftCoset #align is_closed.left_add_coset IsClosed.left_addCoset /-- Multiplication from the right in a topological group as a homeomorphism. -/ @[to_additive "Addition from the right in a topological additive group as a homeomorphism."] protected def Homeomorph.mulRight (a : G) : G ≃ₜ G := { Equiv.mulRight a with continuous_toFun := continuous_id.mul continuous_const continuous_invFun := continuous_id.mul continuous_const } #align homeomorph.mul_right Homeomorph.mulRight #align homeomorph.add_right Homeomorph.addRight @[to_additive (attr := simp)] lemma Homeomorph.coe_mulRight (a : G) : ⇑(Homeomorph.mulRight a) = (· * a) := rfl #align homeomorph.coe_mul_right Homeomorph.coe_mulRight #align homeomorph.coe_add_right Homeomorph.coe_addRight @[to_additive]
Mathlib/Topology/Algebra/Group/Basic.lean
114
117
theorem Homeomorph.mulRight_symm (a : G) : (Homeomorph.mulRight a).symm = Homeomorph.mulRight a⁻¹ := by
ext rfl
/- Copyright (c) 2014 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura, Jeremy Avigad, Floris van Doorn, Mario Carneiro -/ import Batteries.Tactic.Init import Batteries.Tactic.Alias import Batteries.Tactic.Lint.Misc instance {f : α → β} [DecidablePred p] : DecidablePred (p ∘ f) := inferInstanceAs <| DecidablePred fun x => p (f x) @[deprecated] alias proofIrrel := proof_irrel /-! ## id -/ theorem Function.id_def : @id α = fun x => x := rfl /-! ## exists and forall -/ alias ⟨forall_not_of_not_exists, not_exists_of_forall_not⟩ := not_exists /-! ## decidable -/ protected alias ⟨Decidable.exists_not_of_not_forall, _⟩ := Decidable.not_forall /-! ## classical logic -/ namespace Classical alias ⟨exists_not_of_not_forall, _⟩ := not_forall end Classical /-! ## equality -/ theorem heq_iff_eq : HEq a b ↔ a = b := ⟨eq_of_heq, heq_of_eq⟩ @[simp] theorem eq_rec_constant {α : Sort _} {a a' : α} {β : Sort _} (y : β) (h : a = a') : (@Eq.rec α a (fun α _ => β) y a' h) = y := by cases h; rfl theorem congrArg₂ (f : α → β → γ) {x x' : α} {y y' : β} (hx : x = x') (hy : y = y') : f x y = f x' y' := by subst hx hy; rfl theorem congrFun₂ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {f g : ∀ a b, γ a b} (h : f = g) (a : α) (b : β a) : f a b = g a b := congrFun (congrFun h _) _ theorem congrFun₃ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {δ : ∀ a b, γ a b → Sort _} {f g : ∀ a b c, δ a b c} (h : f = g) (a : α) (b : β a) (c : γ a b) : f a b c = g a b c := congrFun₂ (congrFun h _) _ _ theorem funext₂ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {f g : ∀ a b, γ a b} (h : ∀ a b, f a b = g a b) : f = g := funext fun _ => funext <| h _ theorem funext₃ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {δ : ∀ a b, γ a b → Sort _} {f g : ∀ a b c, δ a b c} (h : ∀ a b c, f a b c = g a b c) : f = g := funext fun _ => funext₂ <| h _ theorem Function.funext_iff {β : α → Sort u} {f₁ f₂ : ∀ x : α, β x} : f₁ = f₂ ↔ ∀ a, f₁ a = f₂ a := ⟨congrFun, funext⟩ theorem ne_of_apply_ne {α β : Sort _} (f : α → β) {x y : α} : f x ≠ f y → x ≠ y := mt <| congrArg _ protected theorem Eq.congr (h₁ : x₁ = y₁) (h₂ : x₂ = y₂) : x₁ = x₂ ↔ y₁ = y₂ := by subst h₁; subst h₂; rfl theorem Eq.congr_left {x y z : α} (h : x = y) : x = z ↔ y = z := by rw [h]
.lake/packages/batteries/Batteries/Logic.lean
74
74
theorem Eq.congr_right {x y z : α} (h : x = y) : z = x ↔ z = y := by
rw [h]
/- Copyright (c) 2023 Mark Andrew Gerads. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Andrew Gerads, Junyan Xu, Eric Wieser -/ import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Tactic.Ring #align_import data.nat.hyperoperation from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Hyperoperation sequence This file defines the Hyperoperation sequence. `hyperoperation 0 m k = k + 1` `hyperoperation 1 m k = m + k` `hyperoperation 2 m k = m * k` `hyperoperation 3 m k = m ^ k` `hyperoperation (n + 3) m 0 = 1` `hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k)` ## References * <https://en.wikipedia.org/wiki/Hyperoperation> ## Tags hyperoperation -/ /-- Implementation of the hyperoperation sequence where `hyperoperation n m k` is the `n`th hyperoperation between `m` and `k`. -/ def hyperoperation : ℕ → ℕ → ℕ → ℕ | 0, _, k => k + 1 | 1, m, 0 => m | 2, _, 0 => 0 | _ + 3, _, 0 => 1 | n + 1, m, k + 1 => hyperoperation n m (hyperoperation (n + 1) m k) #align hyperoperation hyperoperation -- Basic hyperoperation lemmas @[simp] theorem hyperoperation_zero (m : ℕ) : hyperoperation 0 m = Nat.succ := funext fun k => by rw [hyperoperation, Nat.succ_eq_add_one] #align hyperoperation_zero hyperoperation_zero theorem hyperoperation_ge_three_eq_one (n m : ℕ) : hyperoperation (n + 3) m 0 = 1 := by rw [hyperoperation] #align hyperoperation_ge_three_eq_one hyperoperation_ge_three_eq_one theorem hyperoperation_recursion (n m k : ℕ) : hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k) := by rw [hyperoperation] #align hyperoperation_recursion hyperoperation_recursion -- Interesting hyperoperation lemmas @[simp] theorem hyperoperation_one : hyperoperation 1 = (· + ·) := by ext m k induction' k with bn bih · rw [Nat.add_zero m, hyperoperation] · rw [hyperoperation_recursion, bih, hyperoperation_zero] exact Nat.add_assoc m bn 1 #align hyperoperation_one hyperoperation_one @[simp] theorem hyperoperation_two : hyperoperation 2 = (· * ·) := by ext m k induction' k with bn bih · rw [hyperoperation] exact (Nat.mul_zero m).symm · rw [hyperoperation_recursion, hyperoperation_one, bih] -- Porting note: was `ring` dsimp only nth_rewrite 1 [← mul_one m] rw [← mul_add, add_comm] #align hyperoperation_two hyperoperation_two @[simp] theorem hyperoperation_three : hyperoperation 3 = (· ^ ·) := by ext m k induction' k with bn bih · rw [hyperoperation_ge_three_eq_one] exact (pow_zero m).symm · rw [hyperoperation_recursion, hyperoperation_two, bih] exact (pow_succ' m bn).symm #align hyperoperation_three hyperoperation_three theorem hyperoperation_ge_two_eq_self (n m : ℕ) : hyperoperation (n + 2) m 1 = m := by induction' n with nn nih · rw [hyperoperation_two] ring · rw [hyperoperation_recursion, hyperoperation_ge_three_eq_one, nih] #align hyperoperation_ge_two_eq_self hyperoperation_ge_two_eq_self theorem hyperoperation_two_two_eq_four (n : ℕ) : hyperoperation (n + 1) 2 2 = 4 := by induction' n with nn nih · rw [hyperoperation_one] · rw [hyperoperation_recursion, hyperoperation_ge_two_eq_self, nih] #align hyperoperation_two_two_eq_four hyperoperation_two_two_eq_four
Mathlib/Data/Nat/Hyperoperation.lean
104
113
theorem hyperoperation_ge_three_one (n : ℕ) : ∀ k : ℕ, hyperoperation (n + 3) 1 k = 1 := by
induction' n with nn nih · intro k rw [hyperoperation_three] dsimp rw [one_pow] · intro k cases k · rw [hyperoperation_ge_three_eq_one] · rw [hyperoperation_recursion, nih]
/- 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]
Mathlib/Analysis/Normed/Group/Pointwise.lean
46
48
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
/- Copyright (c) 2023 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Order.Filter.CountableInter /-! # Filters with countable intersections and countable separating families In this file we prove some facts about a filter with countable intersections property on a type with a countable family of sets that separates points of the space. The main use case is the `MeasureTheory.ae` filter and a space with countably generated σ-algebra but lemmas apply, e.g., to the `residual` filter and a T₀ topological space with second countable topology. To avoid repetition of lemmas for different families of separating sets (measurable sets, open sets, closed sets), all theorems in this file take a predicate `p : Set α → Prop` as an argument and prove existence of a countable separating family satisfying this predicate by searching for a `HasCountableSeparatingOn` typeclass instance. ## Main definitions - `HasCountableSeparatingOn α p t`: a typeclass saying that there exists a countable set family `S : Set (Set α)` such that all `s ∈ S` satisfy the predicate `p` and any two distinct points `x y ∈ t`, `x ≠ y`, can be separated by a set `s ∈ S`. For technical reasons, we formulate the latter property as "for all `x y ∈ t`, if `x ∈ s ↔ y ∈ s` for all `s ∈ S`, then `x = y`". This typeclass is used in all lemmas in this file to avoid repeating them for open sets, closed sets, and measurable sets. ### Main results #### Filters supported on a (sub)singleton Let `l : Filter α` be a filter with countable intersections property. Let `p : Set α → Prop` be a property such that there exists a countable family of sets satisfying `p` and separating points of `α`. Then `l` is supported on a subsingleton: there exists a subsingleton `t` such that `t ∈ l`. We formalize various versions of this theorem in `Filter.exists_subset_subsingleton_mem_of_forall_separating`, `Filter.exists_mem_singleton_mem_of_mem_of_nonempty_of_forall_separating`, `Filter.exists_singleton_mem_of_mem_of_forall_separating`, `Filter.exists_subsingleton_mem_of_forall_separating`, and `Filter.exists_singleton_mem_of_forall_separating`. #### Eventually constant functions Consider a function `f : α → β`, a filter `l` with countable intersections property, and a countable separating family of sets of `β`. Suppose that for every `U` from the family, either `∀ᶠ x in l, f x ∈ U` or `∀ᶠ x in l, f x ∉ U`. Then `f` is eventually constant along `l`. We formalize three versions of this theorem in `Filter.exists_mem_eventuallyEq_const_of_eventually_mem_of_forall_separating`, `Filter.exists_eventuallyEq_const_of_eventually_mem_of_forall_separating`, and `Filer.exists_eventuallyEq_const_of_forall_separating`. #### Eventually equal functions Two functions are equal along a filter with countable intersections property if the preimages of all sets from a countable separating family of sets are equal along the filter. We formalize several versions of this theorem in `Filter.of_eventually_mem_of_forall_separating_mem_iff`, `Filter.of_forall_separating_mem_iff`, `Filter.of_eventually_mem_of_forall_separating_preimage`, and `Filter.of_forall_separating_preimage`. ## Keywords filter, countable -/ set_option autoImplicit true open Function Set Filter /-- We say that a type `α` has a *countable separating family of sets* satisfying a predicate `p : Set α → Prop` on a set `t` if there exists a countable family of sets `S : Set (Set α)` such that all sets `s ∈ S` satisfy `p` and any two distinct points `x y ∈ t`, `x ≠ y`, can be separated by `s ∈ S`: there exists `s ∈ S` such that exactly one of `x` and `y` belongs to `s`. E.g., if `α` is a `T₀` topological space with second countable topology, then it has a countable separating family of open sets and a countable separating family of closed sets. -/ class HasCountableSeparatingOn (α : Type*) (p : Set α → Prop) (t : Set α) : Prop where exists_countable_separating : ∃ S : Set (Set α), S.Countable ∧ (∀ s ∈ S, p s) ∧ ∀ x ∈ t, ∀ y ∈ t, (∀ s ∈ S, x ∈ s ↔ y ∈ s) → x = y theorem exists_countable_separating (α : Type*) (p : Set α → Prop) (t : Set α) [h : HasCountableSeparatingOn α p t] : ∃ S : Set (Set α), S.Countable ∧ (∀ s ∈ S, p s) ∧ ∀ x ∈ t, ∀ y ∈ t, (∀ s ∈ S, x ∈ s ↔ y ∈ s) → x = y := h.1 theorem exists_nonempty_countable_separating (α : Type*) {p : Set α → Prop} {s₀} (hp : p s₀) (t : Set α) [HasCountableSeparatingOn α p t] : ∃ S : Set (Set α), S.Nonempty ∧ S.Countable ∧ (∀ s ∈ S, p s) ∧ ∀ x ∈ t, ∀ y ∈ t, (∀ s ∈ S, x ∈ s ↔ y ∈ s) → x = y := let ⟨S, hSc, hSp, hSt⟩ := exists_countable_separating α p t ⟨insert s₀ S, insert_nonempty _ _, hSc.insert _, forall_insert_of_forall hSp hp, fun x hx y hy hxy ↦ hSt x hx y hy <| forall_of_forall_insert hxy⟩
Mathlib/Order/Filter/CountableSeparatingOn.lean
103
109
theorem exists_seq_separating (α : Type*) {p : Set α → Prop} {s₀} (hp : p s₀) (t : Set α) [HasCountableSeparatingOn α p t] : ∃ S : ℕ → Set α, (∀ n, p (S n)) ∧ ∀ x ∈ t, ∀ y ∈ t, (∀ n, x ∈ S n ↔ y ∈ S n) → x = y := by
rcases exists_nonempty_countable_separating α hp t with ⟨S, hSne, hSc, hS⟩ rcases hSc.exists_eq_range hSne with ⟨S, rfl⟩ use S simpa only [forall_mem_range] using hS
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.RingTheory.FiniteType #align_import ring_theory.rees_algebra from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Rees algebra The Rees algebra of an ideal `I` is the subalgebra `R[It]` of `R[t]` defined as `R[It] = ⨁ₙ Iⁿ tⁿ`. This is used to prove the Artin-Rees lemma, and will potentially enable us to calculate some blowup in the future. ## Main definition - `reesAlgebra` : The Rees algebra of an ideal `I`, defined as a subalgebra of `R[X]`. - `adjoin_monomial_eq_reesAlgebra` : The Rees algebra is generated by the degree one elements. - `reesAlgebra.fg` : The Rees algebra of a f.g. ideal is of finite type. In particular, this implies that the rees algebra over a noetherian ring is still noetherian. -/ universe u v variable {R M : Type u} [CommRing R] [AddCommGroup M] [Module R M] (I : Ideal R) open Polynomial open Polynomial /-- The Rees algebra of an ideal `I`, defined as the subalgebra of `R[X]` whose `i`-th coefficient falls in `I ^ i`. -/ def reesAlgebra : Subalgebra R R[X] where carrier := { f | ∀ i, f.coeff i ∈ I ^ i } mul_mem' hf hg i := by rw [coeff_mul] apply Ideal.sum_mem rintro ⟨j, k⟩ e rw [← Finset.mem_antidiagonal.mp e, pow_add] exact Ideal.mul_mem_mul (hf j) (hg k) one_mem' i := by rw [coeff_one] split_ifs with h · subst h simp · simp add_mem' hf hg i := by rw [coeff_add] exact Ideal.add_mem _ (hf i) (hg i) zero_mem' i := Ideal.zero_mem _ algebraMap_mem' r i := by rw [algebraMap_apply, coeff_C] split_ifs with h · subst h simp · simp #align rees_algebra reesAlgebra theorem mem_reesAlgebra_iff (f : R[X]) : f ∈ reesAlgebra I ↔ ∀ i, f.coeff i ∈ I ^ i := Iff.rfl #align mem_rees_algebra_iff mem_reesAlgebra_iff theorem mem_reesAlgebra_iff_support (f : R[X]) : f ∈ reesAlgebra I ↔ ∀ i ∈ f.support, f.coeff i ∈ I ^ i := by apply forall_congr' intro a rw [mem_support_iff, Iff.comm, Classical.imp_iff_right_iff, Ne, ← imp_iff_not_or] exact fun e => e.symm ▸ (I ^ a).zero_mem #align mem_rees_algebra_iff_support mem_reesAlgebra_iff_support theorem reesAlgebra.monomial_mem {I : Ideal R} {i : ℕ} {r : R} : monomial i r ∈ reesAlgebra I ↔ r ∈ I ^ i := by simp (config := { contextual := true }) [mem_reesAlgebra_iff_support, coeff_monomial, ← imp_iff_not_or] #align rees_algebra.monomial_mem reesAlgebra.monomial_mem
Mathlib/RingTheory/ReesAlgebra.lean
82
95
theorem monomial_mem_adjoin_monomial {I : Ideal R} {n : ℕ} {r : R} (hr : r ∈ I ^ n) : monomial n r ∈ Algebra.adjoin R (Submodule.map (monomial 1 : R →ₗ[R] R[X]) I : Set R[X]) := by
induction' n with n hn generalizing r · exact Subalgebra.algebraMap_mem _ _ · rw [pow_succ'] at hr apply Submodule.smul_induction_on -- Porting note: did not need help with motive previously (p := fun r => (monomial (Nat.succ n)) r ∈ Algebra.adjoin R (Submodule.map (monomial 1) I)) hr · intro r hr s hs rw [Nat.succ_eq_one_add, smul_eq_mul, ← monomial_mul_monomial] exact Subalgebra.mul_mem _ (Algebra.subset_adjoin (Set.mem_image_of_mem _ hr)) (hn hs) · intro x y hx hy rw [monomial_add] exact Subalgebra.add_mem _ hx hy
/- Copyright (c) 2022 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Order.ConditionallyCompleteLattice.Basic #align_import order.monotone.extension from "leanprover-community/mathlib"@"422e70f7ce183d2900c586a8cda8381e788a0c62" /-! # Extension of a monotone function from a set to the whole space In this file we prove that if a function is monotone and is bounded on a set `s`, then it admits a monotone extension to the whole space. -/ open Set variable {α β : Type*} [LinearOrder α] [ConditionallyCompleteLinearOrder β] {f : α → β} {s : Set α} {a b : α} /-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to the whole space. -/
Mathlib/Order/Monotone/Extension.lean
25
48
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s)) (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
classical /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values of `f` to the left of `x` for `x ≥ a`. -/ rcases hl with ⟨a, ha⟩ have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x => hu.mono (image_subset _ inter_subset_right) let g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s)) have hgs : EqOn f g s := by intro x hx simp only [g] have : IsGreatest (Iic x ∩ s) x := ⟨⟨right_mem_Iic, hx⟩, fun y hy => hy.1⟩ rw [if_neg this.nonempty.not_disjoint, ((h.mono inter_subset_right).map_isGreatest this).csSup_eq] refine ⟨g, fun x y hxy => ?_, hgs⟩ by_cases hx : Disjoint (Iic x) s <;> by_cases hy : Disjoint (Iic y) s <;> simp only [g, if_pos, if_neg, not_false_iff, *, refl] · rcases not_disjoint_iff_nonempty_inter.1 hy with ⟨z, hz⟩ exact le_csSup_of_le (hu' _) (mem_image_of_mem _ hz) (ha <| mem_image_of_mem _ hz.2) · exact (hx <| hy.mono_left <| Iic_subset_Iic.2 hxy).elim · rw [not_disjoint_iff_nonempty_inter] at hx hy refine csSup_le_csSup (hu' _) (hx.image _) (image_subset _ ?_) exact inter_subset_inter_left _ (Iic_subset_Iic.2 hxy)
/- 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, Yury Kudryashov -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Topology.Algebra.InfiniteSum.Order import Mathlib.Topology.Instances.Real import Mathlib.Topology.Instances.ENNReal #align_import topology.algebra.infinite_sum.real from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd" /-! # Infinite sum in the reals This file provides lemmas about Cauchy sequences in terms of infinite sums and infinite sums valued in the reals. -/ open Filter Finset NNReal Topology variable {α β : Type*} [PseudoMetricSpace α] {f : ℕ → α} {a : α} /-- If the distance between consecutive points of a sequence is estimated by a summable series, then the original sequence is a Cauchy sequence. -/
Mathlib/Topology/Algebra/InfiniteSum/Real.lean
26
31
theorem cauchySeq_of_dist_le_of_summable (d : ℕ → ℝ) (hf : ∀ n, dist (f n) (f n.succ) ≤ d n) (hd : Summable d) : CauchySeq f := by
lift d to ℕ → ℝ≥0 using fun n ↦ dist_nonneg.trans (hf n) apply cauchySeq_of_edist_le_of_summable d (α := α) (f := f) · exact_mod_cast hf · exact_mod_cast hd
/- Copyright (c) 2022 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker -/ import Mathlib.Topology.Algebra.UniformConvergence #align_import topology.algebra.module.strong_topology from "leanprover-community/mathlib"@"8905e5ed90859939681a725b00f6063e65096d95" /-! # Strong topologies on the space of continuous linear maps In this file, we define the strong topologies on `E →L[𝕜] F` associated with a family `𝔖 : Set (Set E)` to be the topology of uniform convergence on the elements of `𝔖` (also called the topology of `𝔖`-convergence). The lemma `UniformOnFun.continuousSMul_of_image_bounded` tells us that this is a vector space topology if the continuous linear image of any element of `𝔖` is bounded (in the sense of `Bornology.IsVonNBounded`). We then declare an instance for the case where `𝔖` is exactly the set of all bounded subsets of `E`, giving us the so-called "topology of uniform convergence on bounded sets" (or "topology of bounded convergence"), which coincides with the operator norm topology in the case of `NormedSpace`s. Other useful examples include the weak-* topology (when `𝔖` is the set of finite sets or the set of singletons) and the topology of compact convergence (when `𝔖` is the set of relatively compact sets). ## Main definitions * `UniformConvergenceCLM` is a type synonym for `E →SL[σ] F` equipped with the `𝔖`-topology. * `UniformConvergenceCLM.instTopologicalSpace` is the topology mentioned above for an arbitrary `𝔖`. * `ContinuousLinearMap.topologicalSpace` is the topology of bounded convergence. This is declared as an instance. ## Main statements * `UniformConvergenceCLM.instTopologicalAddGroup` and `UniformConvergenceCLM.instContinuousSMul` show that the strong topology makes `E →L[𝕜] F` a topological vector space, with the assumptions on `𝔖` mentioned above. * `ContinuousLinearMap.topologicalAddGroup` and `ContinuousLinearMap.continuousSMul` register these facts as instances for the special case of bounded convergence. ## References * [N. Bourbaki, *Topological Vector Spaces*][bourbaki1987] ## TODO * Add convergence on compact subsets ## Tags uniform convergence, bounded convergence -/ open scoped Topology UniformConvergence section General /-! ### 𝔖-Topologies -/ variable {𝕜₁ 𝕜₂ : Type*} [NormedField 𝕜₁] [NormedField 𝕜₂] (σ : 𝕜₁ →+* 𝕜₂) {E E' F F' : Type*} [AddCommGroup E] [Module 𝕜₁ E] [AddCommGroup E'] [Module ℝ E'] [AddCommGroup F] [Module 𝕜₂ F] [AddCommGroup F'] [Module ℝ F'] [TopologicalSpace E] [TopologicalSpace E'] (F) /-- Given `E` and `F` two topological vector spaces and `𝔖 : Set (Set E)`, then `UniformConvergenceCLM σ F 𝔖` is a type synonym of `E →SL[σ] F` equipped with the "topology of uniform convergence on the elements of `𝔖`". If the continuous linear image of any element of `𝔖` is bounded, this makes `E →SL[σ] F` a topological vector space. -/ @[nolint unusedArguments] def UniformConvergenceCLM [TopologicalSpace F] [TopologicalAddGroup F] (_ : Set (Set E)) := E →SL[σ] F namespace UniformConvergenceCLM instance instFunLike [TopologicalSpace F] [TopologicalAddGroup F] (𝔖 : Set (Set E)) : FunLike (UniformConvergenceCLM σ F 𝔖) E F := ContinuousLinearMap.funLike instance instContinuousSemilinearMapClass [TopologicalSpace F] [TopologicalAddGroup F] (𝔖 : Set (Set E)) : ContinuousSemilinearMapClass (UniformConvergenceCLM σ F 𝔖) σ E F := ContinuousLinearMap.continuousSemilinearMapClass instance instTopologicalSpace [TopologicalSpace F] [TopologicalAddGroup F] (𝔖 : Set (Set E)) : TopologicalSpace (UniformConvergenceCLM σ F 𝔖) := (@UniformOnFun.topologicalSpace E F (TopologicalAddGroup.toUniformSpace F) 𝔖).induced (DFunLike.coe : (UniformConvergenceCLM σ F 𝔖) → (E →ᵤ[𝔖] F)) #align continuous_linear_map.strong_topology UniformConvergenceCLM.instTopologicalSpace theorem topologicalSpace_eq [UniformSpace F] [UniformAddGroup F] (𝔖 : Set (Set E)) : instTopologicalSpace σ F 𝔖 = TopologicalSpace.induced DFunLike.coe (UniformOnFun.topologicalSpace E F 𝔖) := by rw [instTopologicalSpace] congr exact UniformAddGroup.toUniformSpace_eq /-- The uniform structure associated with `ContinuousLinearMap.strongTopology`. We make sure that this has nice definitional properties. -/ instance instUniformSpace [UniformSpace F] [UniformAddGroup F] (𝔖 : Set (Set E)) : UniformSpace (UniformConvergenceCLM σ F 𝔖) := UniformSpace.replaceTopology ((UniformOnFun.uniformSpace E F 𝔖).comap (DFunLike.coe : (UniformConvergenceCLM σ F 𝔖) → (E →ᵤ[𝔖] F))) (by rw [UniformConvergenceCLM.instTopologicalSpace, UniformAddGroup.toUniformSpace_eq]; rfl) #align continuous_linear_map.strong_uniformity UniformConvergenceCLM.instUniformSpace
Mathlib/Topology/Algebra/Module/StrongTopology.lean
113
115
theorem uniformSpace_eq [UniformSpace F] [UniformAddGroup F] (𝔖 : Set (Set E)) : instUniformSpace σ F 𝔖 = UniformSpace.comap DFunLike.coe (UniformOnFun.uniformSpace E F 𝔖) := by
rw [instUniformSpace, UniformSpace.replaceTopology_eq]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax import Mathlib.Algebra.Order.Monoid.WithTop import Mathlib.Data.Finset.Image import Mathlib.Data.Multiset.Fold #align_import data.finset.fold from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # The fold operation for a commutative associative operation over a finset. -/ -- TODO: -- assert_not_exists OrderedCommMonoid assert_not_exists MonoidWithZero namespace Finset open Multiset variable {α β γ : Type*} /-! ### fold -/ section Fold variable (op : β → β → β) [hc : Std.Commutative op] [ha : Std.Associative op] local notation a " * " b => op a b /-- `fold op b f s` folds the commutative associative operation `op` over the `f`-image of `s`, i.e. `fold (+) b f {1,2,3} = f 1 + f 2 + f 3 + b`. -/ def fold (b : β) (f : α → β) (s : Finset α) : β := (s.1.map f).fold op b #align finset.fold Finset.fold variable {op} {f : α → β} {b : β} {s : Finset α} {a : α} @[simp] theorem fold_empty : (∅ : Finset α).fold op b f = b := rfl #align finset.fold_empty Finset.fold_empty @[simp] theorem fold_cons (h : a ∉ s) : (cons a s h).fold op b f = f a * s.fold op b f := by dsimp only [fold] rw [cons_val, Multiset.map_cons, fold_cons_left] #align finset.fold_cons Finset.fold_cons @[simp] theorem fold_insert [DecidableEq α] (h : a ∉ s) : (insert a s).fold op b f = f a * s.fold op b f := by unfold fold rw [insert_val, ndinsert_of_not_mem h, Multiset.map_cons, fold_cons_left] #align finset.fold_insert Finset.fold_insert @[simp] theorem fold_singleton : ({a} : Finset α).fold op b f = f a * b := rfl #align finset.fold_singleton Finset.fold_singleton @[simp] theorem fold_map {g : γ ↪ α} {s : Finset γ} : (s.map g).fold op b f = s.fold op b (f ∘ g) := by simp only [fold, map, Multiset.map_map] #align finset.fold_map Finset.fold_map @[simp] theorem fold_image [DecidableEq α] {g : γ → α} {s : Finset γ} (H : ∀ x ∈ s, ∀ y ∈ s, g x = g y → x = y) : (s.image g).fold op b f = s.fold op b (f ∘ g) := by simp only [fold, image_val_of_injOn H, Multiset.map_map] #align finset.fold_image Finset.fold_image @[congr] theorem fold_congr {g : α → β} (H : ∀ x ∈ s, f x = g x) : s.fold op b f = s.fold op b g := by rw [fold, fold, map_congr rfl H] #align finset.fold_congr Finset.fold_congr theorem fold_op_distrib {f g : α → β} {b₁ b₂ : β} : (s.fold op (b₁ * b₂) fun x => f x * g x) = s.fold op b₁ f * s.fold op b₂ g := by simp only [fold, fold_distrib] #align finset.fold_op_distrib Finset.fold_op_distrib theorem fold_const [hd : Decidable (s = ∅)] (c : β) (h : op c (op b c) = op b c) : Finset.fold op b (fun _ => c) s = if s = ∅ then b else op b c := by classical induction' s using Finset.induction_on with x s hx IH generalizing hd · simp · simp only [Finset.fold_insert hx, IH, if_false, Finset.insert_ne_empty] split_ifs · rw [hc.comm] · exact h #align finset.fold_const Finset.fold_const theorem fold_hom {op' : γ → γ → γ} [Std.Commutative op'] [Std.Associative op'] {m : β → γ} (hm : ∀ x y, m (op x y) = op' (m x) (m y)) : (s.fold op' (m b) fun x => m (f x)) = m (s.fold op b f) := by rw [fold, fold, ← Multiset.fold_hom op hm, Multiset.map_map] simp only [Function.comp_apply] #align finset.fold_hom Finset.fold_hom theorem fold_disjUnion {s₁ s₂ : Finset α} {b₁ b₂ : β} (h) : (s₁.disjUnion s₂ h).fold op (b₁ * b₂) f = s₁.fold op b₁ f * s₂.fold op b₂ f := (congr_arg _ <| Multiset.map_add _ _ _).trans (Multiset.fold_add _ _ _ _ _) #align finset.fold_disj_union Finset.fold_disjUnion theorem fold_disjiUnion {ι : Type*} {s : Finset ι} {t : ι → Finset α} {b : ι → β} {b₀ : β} (h) : (s.disjiUnion t h).fold op (s.fold op b₀ b) f = s.fold op b₀ fun i => (t i).fold op (b i) f := (congr_arg _ <| Multiset.map_bind _ _ _).trans (Multiset.fold_bind _ _ _ _ _) #align finset.fold_disj_Union Finset.fold_disjiUnion theorem fold_union_inter [DecidableEq α] {s₁ s₂ : Finset α} {b₁ b₂ : β} : ((s₁ ∪ s₂).fold op b₁ f * (s₁ ∩ s₂).fold op b₂ f) = s₁.fold op b₂ f * s₂.fold op b₁ f := by unfold fold rw [← fold_add op, ← Multiset.map_add, union_val, inter_val, union_add_inter, Multiset.map_add, hc.comm, fold_add] #align finset.fold_union_inter Finset.fold_union_inter @[simp]
Mathlib/Data/Finset/Fold.lean
124
129
theorem fold_insert_idem [DecidableEq α] [hi : Std.IdempotentOp op] : (insert a s).fold op b f = f a * s.fold op b f := by
by_cases h : a ∈ s · rw [← insert_erase h] simp [← ha.assoc, hi.idempotent] · apply fold_insert h
/- 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
Mathlib/Analysis/SpecialFunctions/Complex/Log.lean
45
49
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]
/- Copyright (c) 2019 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Yaël Dillies -/ import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Finset.NoncommProd import Mathlib.Data.Fintype.Perm import Mathlib.Data.Int.ModEq import Mathlib.GroupTheory.Perm.List import Mathlib.GroupTheory.Perm.Sign import Mathlib.Logic.Equiv.Fintype import Mathlib.GroupTheory.Perm.Cycle.Basic #align_import group_theory.perm.cycle.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Cycle factors of a permutation Let `β` be a `Fintype` and `f : Equiv.Perm β`. * `Equiv.Perm.cycleOf`: `f.cycleOf x` is the cycle of `f` that `x` belongs to. * `Equiv.Perm.cycleFactors`: `f.cycleFactors` is a list of disjoint cyclic permutations that multiply to `f`. -/ open Equiv Function Finset variable {ι α β : Type*} namespace Equiv.Perm /-! ### `cycleOf` -/ section CycleOf variable [DecidableEq α] [Fintype α] {f g : Perm α} {x y : α} /-- `f.cycleOf x` is the cycle of the permutation `f` to which `x` belongs. -/ def cycleOf (f : Perm α) (x : α) : Perm α := ofSubtype (subtypePerm f fun _ => sameCycle_apply_right.symm : Perm { y // SameCycle f x y }) #align equiv.perm.cycle_of Equiv.Perm.cycleOf theorem cycleOf_apply (f : Perm α) (x y : α) : cycleOf f x y = if SameCycle f x y then f y else y := by dsimp only [cycleOf] split_ifs with h · apply ofSubtype_apply_of_mem exact h · apply ofSubtype_apply_of_not_mem exact h #align equiv.perm.cycle_of_apply Equiv.Perm.cycleOf_apply theorem cycleOf_inv (f : Perm α) (x : α) : (cycleOf f x)⁻¹ = cycleOf f⁻¹ x := Equiv.ext fun y => by rw [inv_eq_iff_eq, cycleOf_apply, cycleOf_apply] split_ifs <;> simp_all [sameCycle_inv, sameCycle_inv_apply_right] #align equiv.perm.cycle_of_inv Equiv.Perm.cycleOf_inv @[simp]
Mathlib/GroupTheory/Perm/Cycle/Factors.lean
65
70
theorem cycleOf_pow_apply_self (f : Perm α) (x : α) : ∀ n : ℕ, (cycleOf f x ^ n) x = (f ^ n) x := by
intro n induction' n with n hn · rfl · rw [pow_succ', mul_apply, cycleOf_apply, hn, if_pos, pow_succ', mul_apply] exact ⟨n, rfl⟩
/- Copyright (c) 2024 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.GroupTheory.Perm.Cycle.Type import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.GroupTheory.OrderOfElement /-! # Fixed-point-free automorphisms This file defines fixed-point-free automorphisms and proves some basic properties. An automorphism `φ` of a group `G` is fixed-point-free if `1 : G` is the only fixed point of `φ`. -/ namespace MonoidHom variable {G : Type*} section Definitions variable (φ : G → G) /-- A function `φ : G → G` is fixed-point-free if `1 : G` is the only fixed point of `φ`. -/ def FixedPointFree [One G] := ∀ g, φ g = g → g = 1 /-- The commutator map `g ↦ g / φ g`. If `φ g = h * g * h⁻¹`, then `g / φ g` is exactly the commutator `[g, h] = g * h * g⁻¹ * h⁻¹`. -/ def commutatorMap [Div G] (g : G) := g / φ g @[simp] theorem commutatorMap_apply [Div G] (g : G) : commutatorMap φ g = g / φ g := rfl end Definitions namespace FixedPointFree -- todo: refactor Mathlib/Algebra/GroupPower/IterateHom to generalize φ to MonoidHomClass variable [Group G] {φ : G →* G} (hφ : FixedPointFree φ) theorem commutatorMap_injective : Function.Injective (commutatorMap φ) := by refine fun x y h ↦ inv_mul_eq_one.mp <| hφ _ ?_ rwa [map_mul, map_inv, eq_inv_mul_iff_mul_eq, ← mul_assoc, ← eq_div_iff_mul_eq', ← division_def] variable [Finite G] theorem commutatorMap_surjective : Function.Surjective (commutatorMap φ) := Finite.surjective_of_injective hφ.commutatorMap_injective theorem prod_pow_eq_one {n : ℕ} (hn : φ^[n] = _root_.id) (g : G) : ((List.range n).map (fun k ↦ φ^[k] g)).prod = 1 := by obtain ⟨g, rfl⟩ := commutatorMap_surjective hφ g simp only [commutatorMap_apply, iterate_map_div, ← Function.iterate_succ_apply] rw [List.prod_range_div', Function.iterate_zero_apply, hn, Function.id_def, div_self'] theorem coe_eq_inv_of_sq_eq_one (h2 : φ^[2] = _root_.id) : ⇑φ = (·⁻¹) := by ext g have key : 1 * g * φ g = 1 := hφ.prod_pow_eq_one h2 g rwa [one_mul, ← inv_eq_iff_mul_eq_one, eq_comm] at key section Involutive variable (h2 : Function.Involutive φ) theorem coe_eq_inv_of_involutive : ⇑φ = (·⁻¹) := coe_eq_inv_of_sq_eq_one hφ (funext h2) theorem commute_all_of_involutive (g h : G) : Commute g h := by have key := map_mul φ g h rwa [hφ.coe_eq_inv_of_involutive h2, inv_eq_iff_eq_inv, mul_inv_rev, inv_inv, inv_inv] at key /-- If a finite group admits a fixed-point-free involution, then it is commutative. -/ def commGroupOfInvolutive : CommGroup G := .mk (hφ.commute_all_of_involutive h2) theorem orderOf_ne_two_of_involutive (g : G) : orderOf g ≠ 2 := by intro hg have key : φ g = g := by rw [hφ.coe_eq_inv_of_involutive h2, inv_eq_iff_mul_eq_one, ← sq, ← hg, pow_orderOf_eq_one] rw [hφ g key, orderOf_one] at hg contradiction
Mathlib/GroupTheory/FixedPointFree.lean
83
88
theorem odd_card_of_involutive : Odd (Nat.card G) := by
have := Fintype.ofFinite G by_contra h rw [← Nat.even_iff_not_odd, even_iff_two_dvd, Nat.card_eq_fintype_card] at h obtain ⟨g, hg⟩ := exists_prime_orderOf_dvd_card 2 h exact hφ.orderOf_ne_two_of_involutive h2 g hg
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.MeasureTheory.Measure.MeasureSpaceDef #align_import measure_theory.measure.ae_disjoint from "leanprover-community/mathlib"@"bc7d81beddb3d6c66f71449c5bc76c38cb77cf9e" /-! # Almost everywhere disjoint sets We say that sets `s` and `t` are `μ`-a.e. disjoint (see `MeasureTheory.AEDisjoint`) if their intersection has measure zero. This assumption can be used instead of `Disjoint` in most theorems in measure theory. -/ open Set Function namespace MeasureTheory variable {ι α : Type*} {m : MeasurableSpace α} (μ : Measure α) /-- Two sets are said to be `μ`-a.e. disjoint if their intersection has measure zero. -/ def AEDisjoint (s t : Set α) := μ (s ∩ t) = 0 #align measure_theory.ae_disjoint MeasureTheory.AEDisjoint variable {μ} {s t u v : Set α} /-- If `s : ι → Set α` is a countable family of pairwise a.e. disjoint sets, then there exists a family of measurable null sets `t i` such that `s i \ t i` are pairwise disjoint. -/
Mathlib/MeasureTheory/Measure/AEDisjoint.lean
34
46
theorem exists_null_pairwise_disjoint_diff [Countable ι] {s : ι → Set α} (hd : Pairwise (AEDisjoint μ on s)) : ∃ t : ι → Set α, (∀ i, MeasurableSet (t i)) ∧ (∀ i, μ (t i) = 0) ∧ Pairwise (Disjoint on fun i => s i \ t i) := by
refine ⟨fun i => toMeasurable μ (s i ∩ ⋃ j ∈ ({i}ᶜ : Set ι), s j), fun i => measurableSet_toMeasurable _ _, fun i => ?_, ?_⟩ · simp only [measure_toMeasurable, inter_iUnion] exact (measure_biUnion_null_iff <| to_countable _).2 fun j hj => hd (Ne.symm hj) · simp only [Pairwise, disjoint_left, onFun, mem_diff, not_and, and_imp, Classical.not_not] intro i j hne x hi hU hj replace hU : x ∉ s i ∩ iUnion fun j ↦ iUnion fun _ ↦ s j := fun h ↦ hU (subset_toMeasurable _ _ h) simp only [mem_inter_iff, mem_iUnion, not_and, not_exists] at hU exact (hU hi j hne.symm hj).elim
/- Copyright (c) 2020 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Algebra.Associated import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.Order.Group.Abs import Mathlib.Algebra.Ring.Divisibility.Basic #align_import ring_theory.prime from "leanprover-community/mathlib"@"008205aa645b3f194c1da47025c5f110c8406eab" /-! # Prime elements in rings This file contains lemmas about prime elements of commutative rings. -/ section CancelCommMonoidWithZero variable {R : Type*} [CancelCommMonoidWithZero R] open Finset /-- If `x * y = a * ∏ i ∈ s, p i` where `p i` is always prime, then `x` and `y` can both be written as a divisor of `a` multiplied by a product over a subset of `s` -/ theorem mul_eq_mul_prime_prod {α : Type*} [DecidableEq α] {x y a : R} {s : Finset α} {p : α → R} (hp : ∀ i ∈ s, Prime (p i)) (hx : x * y = a * ∏ i ∈ s, p i) : ∃ (t u : Finset α) (b c : R), t ∪ u = s ∧ Disjoint t u ∧ a = b * c ∧ (x = b * ∏ i ∈ t, p i) ∧ y = c * ∏ i ∈ u, p i := by induction' s using Finset.induction with i s his ih generalizing x y a · exact ⟨∅, ∅, x, y, by simp [hx]⟩ · rw [prod_insert his, ← mul_assoc] at hx have hpi : Prime (p i) := hp i (mem_insert_self _ _) rcases ih (fun i hi ↦ hp i (mem_insert_of_mem hi)) hx with ⟨t, u, b, c, htus, htu, hbc, rfl, rfl⟩ have hit : i ∉ t := fun hit ↦ his (htus ▸ mem_union_left _ hit) have hiu : i ∉ u := fun hiu ↦ his (htus ▸ mem_union_right _ hiu) obtain ⟨d, rfl⟩ | ⟨d, rfl⟩ : p i ∣ b ∨ p i ∣ c := hpi.dvd_or_dvd ⟨a, by rw [← hbc, mul_comm]⟩ · rw [mul_assoc, mul_comm a, mul_right_inj' hpi.ne_zero] at hbc exact ⟨insert i t, u, d, c, by rw [insert_union, htus], disjoint_insert_left.2 ⟨hiu, htu⟩, by simp [hbc, prod_insert hit, mul_assoc, mul_comm, mul_left_comm]⟩ · rw [← mul_assoc, mul_right_comm b, mul_left_inj' hpi.ne_zero] at hbc exact ⟨t, insert i u, b, d, by rw [union_insert, htus], disjoint_insert_right.2 ⟨hit, htu⟩, by simp [← hbc, prod_insert hiu, mul_assoc, mul_comm, mul_left_comm]⟩ #align mul_eq_mul_prime_prod mul_eq_mul_prime_prod /-- If `x * y = a * p ^ n` where `p` is prime, then `x` and `y` can both be written as the product of a power of `p` and a divisor of `a`. -/
Mathlib/RingTheory/Prime.lean
51
56
theorem mul_eq_mul_prime_pow {x y a p : R} {n : ℕ} (hp : Prime p) (hx : x * y = a * p ^ n) : ∃ (i j : ℕ) (b c : R), i + j = n ∧ a = b * c ∧ x = b * p ^ i ∧ y = c * p ^ j := by
rcases mul_eq_mul_prime_prod (fun _ _ ↦ hp) (show x * y = a * (range n).prod fun _ ↦ p by simpa) with ⟨t, u, b, c, htus, htu, rfl, rfl, rfl⟩ exact ⟨t.card, u.card, b, c, by rw [← card_union_of_disjoint htu, htus, card_range], by simp⟩
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.CategoryTheory.Sites.Grothendieck import Mathlib.CategoryTheory.Sites.Pretopology import Mathlib.CategoryTheory.Limits.Lattice import Mathlib.Topology.Sets.Opens #align_import category_theory.sites.spaces from "leanprover-community/mathlib"@"b6fa3beb29f035598cf0434d919694c5e98091eb" /-! # Grothendieck topology on a topological space Define the Grothendieck topology and the pretopology associated to a topological space, and show that the pretopology induces the topology. The covering (pre)sieves on `X` are those for which the union of domains contains `X`. ## Tags site, Grothendieck topology, space ## References * [nLab, *Grothendieck topology*](https://ncatlab.org/nlab/show/Grothendieck+topology) * [S. MacLane, I. Moerdijk, *Sheaves in Geometry and Logic*][MM92] ## Implementation notes We define the two separately, rather than defining the Grothendieck topology as that generated by the pretopology for the purpose of having nice definitional properties for the sieves. -/ universe u namespace Opens variable (T : Type u) [TopologicalSpace T] open CategoryTheory TopologicalSpace CategoryTheory.Limits /-- The Grothendieck topology associated to a topological space. -/ def grothendieckTopology : GrothendieckTopology (Opens T) where sieves X S := ∀ x ∈ X, ∃ (U : _) (f : U ⟶ X), S f ∧ x ∈ U top_mem' X x hx := ⟨_, 𝟙 _, trivial, hx⟩ pullback_stable' X Y S f hf y hy := by rcases hf y (f.le hy) with ⟨U, g, hg, hU⟩ refine ⟨U ⊓ Y, homOfLE inf_le_right, ?_, hU, hy⟩ apply S.downward_closed hg (homOfLE inf_le_left) transitive' X S hS R hR x hx := by rcases hS x hx with ⟨U, f, hf, hU⟩ rcases hR hf _ hU with ⟨V, g, hg, hV⟩ exact ⟨_, g ≫ f, hg, hV⟩ #align opens.grothendieck_topology Opens.grothendieckTopology /-- The Grothendieck pretopology associated to a topological space. -/ def pretopology : Pretopology (Opens T) where coverings X R := ∀ x ∈ X, ∃ (U : _) (f : U ⟶ X), R f ∧ x ∈ U has_isos X Y f i x hx := ⟨_, _, Presieve.singleton_self _, (inv f).le hx⟩ pullbacks X Y f S hS x hx := by rcases hS _ (f.le hx) with ⟨U, g, hg, hU⟩ refine ⟨_, _, Presieve.pullbackArrows.mk _ _ hg, ?_⟩ have : U ⊓ Y ≤ pullback g f := leOfHom (pullback.lift (homOfLE inf_le_left) (homOfLE inf_le_right) rfl) apply this ⟨hU, hx⟩ transitive X S Ti hS hTi x hx := by rcases hS x hx with ⟨U, f, hf, hU⟩ rcases hTi f hf x hU with ⟨V, g, hg, hV⟩ exact ⟨_, _, ⟨_, g, f, hf, hg, rfl⟩, hV⟩ #align opens.pretopology Opens.pretopology /-- The pretopology associated to a space is the largest pretopology that generates the Grothendieck topology associated to the space. -/ @[simp]
Mathlib/CategoryTheory/Sites/Spaces.lean
78
86
theorem pretopology_ofGrothendieck : Pretopology.ofGrothendieck _ (Opens.grothendieckTopology T) = Opens.pretopology T := by
apply le_antisymm · intro X R hR x hx rcases hR x hx with ⟨U, f, ⟨V, g₁, g₂, hg₂, _⟩, hU⟩ exact ⟨V, g₂, hg₂, g₁.le hU⟩ · intro X R hR x hx rcases hR x hx with ⟨U, f, hf, hU⟩ exact ⟨U, f, Sieve.le_generate R U hf, hU⟩
/- Copyright (c) 2022 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp -/ import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.LinearAlgebra.Matrix.ZPow #align_import linear_algebra.matrix.hermitian from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c" /-! # Hermitian matrices This file defines hermitian matrices and some basic results about them. See also `IsSelfAdjoint`, which generalizes this definition to other star rings. ## Main definition * `Matrix.IsHermitian` : a matrix `A : Matrix n n α` is hermitian if `Aᴴ = A`. ## Tags self-adjoint matrix, hermitian matrix -/ namespace Matrix variable {α β : Type*} {m n : Type*} {A : Matrix n n α} open scoped Matrix local notation "⟪" x ", " y "⟫" => @inner α _ _ x y section Star variable [Star α] [Star β] /-- A matrix is hermitian if it is equal to its conjugate transpose. On the reals, this definition captures symmetric matrices. -/ def IsHermitian (A : Matrix n n α) : Prop := Aᴴ = A #align matrix.is_hermitian Matrix.IsHermitian instance (A : Matrix n n α) [Decidable (Aᴴ = A)] : Decidable (IsHermitian A) := inferInstanceAs <| Decidable (_ = _) theorem IsHermitian.eq {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ = A := h #align matrix.is_hermitian.eq Matrix.IsHermitian.eq protected theorem IsHermitian.isSelfAdjoint {A : Matrix n n α} (h : A.IsHermitian) : IsSelfAdjoint A := h #align matrix.is_hermitian.is_self_adjoint Matrix.IsHermitian.isSelfAdjoint -- @[ext] -- Porting note: incorrect ext, not a structure or a lemma proving x = y theorem IsHermitian.ext {A : Matrix n n α} : (∀ i j, star (A j i) = A i j) → A.IsHermitian := by intro h; ext i j; exact h i j #align matrix.is_hermitian.ext Matrix.IsHermitian.ext theorem IsHermitian.apply {A : Matrix n n α} (h : A.IsHermitian) (i j : n) : star (A j i) = A i j := congr_fun (congr_fun h _) _ #align matrix.is_hermitian.apply Matrix.IsHermitian.apply theorem IsHermitian.ext_iff {A : Matrix n n α} : A.IsHermitian ↔ ∀ i j, star (A j i) = A i j := ⟨IsHermitian.apply, IsHermitian.ext⟩ #align matrix.is_hermitian.ext_iff Matrix.IsHermitian.ext_iff @[simp] theorem IsHermitian.map {A : Matrix n n α} (h : A.IsHermitian) (f : α → β) (hf : Function.Semiconj f star star) : (A.map f).IsHermitian := (conjTranspose_map f hf).symm.trans <| h.eq.symm ▸ rfl #align matrix.is_hermitian.map Matrix.IsHermitian.map theorem IsHermitian.transpose {A : Matrix n n α} (h : A.IsHermitian) : Aᵀ.IsHermitian := by rw [IsHermitian, conjTranspose, transpose_map] exact congr_arg Matrix.transpose h #align matrix.is_hermitian.transpose Matrix.IsHermitian.transpose @[simp] theorem isHermitian_transpose_iff (A : Matrix n n α) : Aᵀ.IsHermitian ↔ A.IsHermitian := ⟨by intro h; rw [← transpose_transpose A]; exact IsHermitian.transpose h, IsHermitian.transpose⟩ #align matrix.is_hermitian_transpose_iff Matrix.isHermitian_transpose_iff theorem IsHermitian.conjTranspose {A : Matrix n n α} (h : A.IsHermitian) : Aᴴ.IsHermitian := h.transpose.map _ fun _ => rfl #align matrix.is_hermitian.conj_transpose Matrix.IsHermitian.conjTranspose @[simp] theorem IsHermitian.submatrix {A : Matrix n n α} (h : A.IsHermitian) (f : m → n) : (A.submatrix f f).IsHermitian := (conjTranspose_submatrix _ _ _).trans (h.symm ▸ rfl) #align matrix.is_hermitian.submatrix Matrix.IsHermitian.submatrix @[simp] theorem isHermitian_submatrix_equiv {A : Matrix n n α} (e : m ≃ n) : (A.submatrix e e).IsHermitian ↔ A.IsHermitian := ⟨fun h => by simpa using h.submatrix e.symm, fun h => h.submatrix _⟩ #align matrix.is_hermitian_submatrix_equiv Matrix.isHermitian_submatrix_equiv end Star section InvolutiveStar variable [InvolutiveStar α] @[simp] theorem isHermitian_conjTranspose_iff (A : Matrix n n α) : Aᴴ.IsHermitian ↔ A.IsHermitian := IsSelfAdjoint.star_iff #align matrix.is_hermitian_conj_transpose_iff Matrix.isHermitian_conjTranspose_iff /-- A block matrix `A.from_blocks B C D` is hermitian, if `A` and `D` are hermitian and `Bᴴ = C`. -/
Mathlib/LinearAlgebra/Matrix/Hermitian.lean
112
117
theorem IsHermitian.fromBlocks {A : Matrix m m α} {B : Matrix m n α} {C : Matrix n m α} {D : Matrix n n α} (hA : A.IsHermitian) (hBC : Bᴴ = C) (hD : D.IsHermitian) : (A.fromBlocks B C D).IsHermitian := by
have hCB : Cᴴ = B := by rw [← hBC, conjTranspose_conjTranspose] unfold Matrix.IsHermitian rw [fromBlocks_conjTranspose, hBC, hCB, hA, hD]
/- Copyright (c) 2021 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Algebra.Algebra.Quasispectrum import Mathlib.FieldTheory.IsAlgClosed.Spectrum import Mathlib.Analysis.Complex.Liouville import Mathlib.Analysis.Complex.Polynomial import Mathlib.Analysis.Analytic.RadiusLiminf import Mathlib.Topology.Algebra.Module.CharacterSpace import Mathlib.Analysis.NormedSpace.Exponential import Mathlib.Analysis.NormedSpace.UnitizationL1 #align_import analysis.normed_space.spectrum from "leanprover-community/mathlib"@"d608fc5d4e69d4cc21885913fb573a88b0deb521" /-! # The spectrum of elements in a complete normed algebra This file contains the basic theory for the resolvent and spectrum of a Banach algebra. ## Main definitions * `spectralRadius : ℝ≥0∞`: supremum of `‖k‖₊` for all `k ∈ spectrum 𝕜 a` * `NormedRing.algEquivComplexOfComplete`: **Gelfand-Mazur theorem** For a complex Banach division algebra, the natural `algebraMap ℂ A` is an algebra isomorphism whose inverse is given by selecting the (unique) element of `spectrum ℂ a` ## Main statements * `spectrum.isOpen_resolventSet`: the resolvent set is open. * `spectrum.isClosed`: the spectrum is closed. * `spectrum.subset_closedBall_norm`: the spectrum is a subset of closed disk of radius equal to the norm. * `spectrum.isCompact`: the spectrum is compact. * `spectrum.spectralRadius_le_nnnorm`: the spectral radius is bounded above by the norm. * `spectrum.hasDerivAt_resolvent`: the resolvent function is differentiable on the resolvent set. * `spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius`: Gelfand's formula for the spectral radius in Banach algebras over `ℂ`. * `spectrum.nonempty`: the spectrum of any element in a complex Banach algebra is nonempty. ## TODO * compute all derivatives of `resolvent a`. -/ open scoped ENNReal NNReal open NormedSpace -- For `NormedSpace.exp`. /-- The *spectral radius* is the supremum of the `nnnorm` (`‖·‖₊`) of elements in the spectrum, coerced into an element of `ℝ≥0∞`. Note that it is possible for `spectrum 𝕜 a = ∅`. In this case, `spectralRadius a = 0`. It is also possible that `spectrum 𝕜 a` be unbounded (though not for Banach algebras, see `spectrum.isBounded`, below). In this case, `spectralRadius a = ∞`. -/ noncomputable def spectralRadius (𝕜 : Type*) {A : Type*} [NormedField 𝕜] [Ring A] [Algebra 𝕜 A] (a : A) : ℝ≥0∞ := ⨆ k ∈ spectrum 𝕜 a, ‖k‖₊ #align spectral_radius spectralRadius variable {𝕜 : Type*} {A : Type*} namespace spectrum section SpectrumCompact open Filter variable [NormedField 𝕜] [NormedRing A] [NormedAlgebra 𝕜 A] local notation "σ" => spectrum 𝕜 local notation "ρ" => resolventSet 𝕜 local notation "↑ₐ" => algebraMap 𝕜 A @[simp] theorem SpectralRadius.of_subsingleton [Subsingleton A] (a : A) : spectralRadius 𝕜 a = 0 := by simp [spectralRadius] #align spectrum.spectral_radius.of_subsingleton spectrum.SpectralRadius.of_subsingleton @[simp]
Mathlib/Analysis/NormedSpace/Spectrum.lean
84
86
theorem spectralRadius_zero : spectralRadius 𝕜 (0 : A) = 0 := by
nontriviality A simp [spectralRadius]
/- Copyright (c) 2021 Hunter Monroe. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Hunter Monroe, Kyle Miller -/ import Mathlib.Combinatorics.SimpleGraph.Dart import Mathlib.Data.FunLike.Fintype /-! # Maps between graphs This file defines two functions and three structures relating graphs. The structures directly correspond to the classification of functions as injective, surjective and bijective, and have corresponding notation. ## Main definitions * `SimpleGraph.map`: the graph obtained by pushing the adjacency relation through an injective function between vertex types. * `SimpleGraph.comap`: the graph obtained by pulling the adjacency relation behind an arbitrary function between vertex types. * `SimpleGraph.induce`: the subgraph induced by the given vertex set, a wrapper around `comap`. * `SimpleGraph.spanningCoe`: the supergraph without any additional edges, a wrapper around `map`. * `SimpleGraph.Hom`, `G →g H`: a graph homomorphism from `G` to `H`. * `SimpleGraph.Embedding`, `G ↪g H`: a graph embedding of `G` in `H`. * `SimpleGraph.Iso`, `G ≃g H`: a graph isomorphism between `G` and `H`. Note that a graph embedding is a stronger notion than an injective graph homomorphism, since its image is an induced subgraph. ## Implementation notes Morphisms of graphs are abbreviations for `RelHom`, `RelEmbedding` and `RelIso`. To make use of pre-existing simp lemmas, definitions involving morphisms are abbreviations as well. -/ open Function namespace SimpleGraph variable {V W X : Type*} (G : SimpleGraph V) (G' : SimpleGraph W) {u v : V} /-! ## Map and comap -/ /-- Given an injective function, there is a covariant induced map on graphs by pushing forward the adjacency relation. This is injective (see `SimpleGraph.map_injective`). -/ protected def map (f : V ↪ W) (G : SimpleGraph V) : SimpleGraph W where Adj := Relation.Map G.Adj f f symm a b := by -- Porting note: `obviously` used to handle this rintro ⟨v, w, h, rfl, rfl⟩ use w, v, h.symm, rfl loopless a := by -- Porting note: `obviously` used to handle this rintro ⟨v, w, h, rfl, h'⟩ exact h.ne (f.injective h'.symm) #align simple_graph.map SimpleGraph.map instance instDecidableMapAdj {f : V ↪ W} {a b} [Decidable (Relation.Map G.Adj f f a b)] : Decidable ((G.map f).Adj a b) := ‹Decidable (Relation.Map G.Adj f f a b)› #align simple_graph.decidable_map SimpleGraph.instDecidableMapAdj @[simp] theorem map_adj (f : V ↪ W) (G : SimpleGraph V) (u v : W) : (G.map f).Adj u v ↔ ∃ u' v' : V, G.Adj u' v' ∧ f u' = u ∧ f v' = v := Iff.rfl #align simple_graph.map_adj SimpleGraph.map_adj lemma map_adj_apply {G : SimpleGraph V} {f : V ↪ W} {a b : V} : (G.map f).Adj (f a) (f b) ↔ G.Adj a b := by simp #align simple_graph.map_adj_apply SimpleGraph.map_adj_apply
Mathlib/Combinatorics/SimpleGraph/Maps.lean
76
78
theorem map_monotone (f : V ↪ W) : Monotone (SimpleGraph.map f) := by
rintro G G' h _ _ ⟨u, v, ha, rfl, rfl⟩ exact ⟨_, _, h ha, rfl, rfl⟩
/- Copyright (c) 2023 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Dynamics.Ergodic.Ergodic import Mathlib.MeasureTheory.Function.AEEqFun /-! # Functions invariant under (quasi)ergodic map In this file we prove that an a.e. strongly measurable function `g : α → X` that is a.e. invariant under a (quasi)ergodic map is a.e. equal to a constant. We prove several versions of this statement with slightly different measurability assumptions. We also formulate a version for `MeasureTheory.AEEqFun` functions with all a.e. equalities replaced with equalities in the quotient space. -/ open Function Set Filter MeasureTheory Topology TopologicalSpace variable {α X : Type*} [MeasurableSpace α] {μ : MeasureTheory.Measure α} /-- Let `f : α → α` be a (quasi)ergodic map. Let `g : α → X` is a null-measurable function from `α` to a nonempty space with a countable family of measurable sets separating points of a set `s` such that `f x ∈ s` for a.e. `x`. If `g` that is a.e.-invariant under `f`, then `g` is a.e. constant. -/ theorem QuasiErgodic.ae_eq_const_of_ae_eq_comp_of_ae_range₀ [Nonempty X] [MeasurableSpace X] {s : Set X} [MeasurableSpace.CountablySeparated s] {f : α → α} {g : α → X} (h : QuasiErgodic f μ) (hs : ∀ᵐ x ∂μ, g x ∈ s) (hgm : NullMeasurable g μ) (hg_eq : g ∘ f =ᵐ[μ] g) : ∃ c, g =ᵐ[μ] const α c := by refine exists_eventuallyEq_const_of_eventually_mem_of_forall_separating MeasurableSet hs ?_ refine fun U hU ↦ h.ae_mem_or_ae_nmem₀ (s := g ⁻¹' U) (hgm hU) ?_b refine (hg_eq.mono fun x hx ↦ ?_).set_eq rw [← preimage_comp, mem_preimage, mem_preimage, hx] section CountableSeparatingOnUniv variable [Nonempty X] [MeasurableSpace X] [MeasurableSpace.CountablySeparated X] {f : α → α} {g : α → X} /-- Let `f : α → α` be a (pre)ergodic map. Let `g : α → X` be a measurable function from `α` to a nonempty measurable space with a countable family of measurable sets separating the points of `X`. If `g` is invariant under `f`, then `g` is a.e. constant. -/ theorem PreErgodic.ae_eq_const_of_ae_eq_comp (h : PreErgodic f μ) (hgm : Measurable g) (hg_eq : g ∘ f = g) : ∃ c, g =ᵐ[μ] const α c := exists_eventuallyEq_const_of_forall_separating MeasurableSet fun U hU ↦ h.ae_mem_or_ae_nmem (s := g ⁻¹' U) (hgm hU) <| by rw [← preimage_comp, hg_eq] /-- Let `f : α → α` be a quasi ergodic map. Let `g : α → X` be a null-measurable function from `α` to a nonempty measurable space with a countable family of measurable sets separating the points of `X`. If `g` is a.e.-invariant under `f`, then `g` is a.e. constant. -/ theorem QuasiErgodic.ae_eq_const_of_ae_eq_comp₀ (h : QuasiErgodic f μ) (hgm : NullMeasurable g μ) (hg_eq : g ∘ f =ᵐ[μ] g) : ∃ c, g =ᵐ[μ] const α c := h.ae_eq_const_of_ae_eq_comp_of_ae_range₀ (s := univ) univ_mem hgm hg_eq /-- Let `f : α → α` be an ergodic map. Let `g : α → X` be a null-measurable function from `α` to a nonempty measurable space with a countable family of measurable sets separating the points of `X`. If `g` is a.e.-invariant under `f`, then `g` is a.e. constant. -/ theorem Ergodic.ae_eq_const_of_ae_eq_comp₀ (h : Ergodic f μ) (hgm : NullMeasurable g μ) (hg_eq : g ∘ f =ᵐ[μ] g) : ∃ c, g =ᵐ[μ] const α c := h.quasiErgodic.ae_eq_const_of_ae_eq_comp₀ hgm hg_eq end CountableSeparatingOnUniv variable [TopologicalSpace X] [MetrizableSpace X] [Nonempty X] {f : α → α} namespace QuasiErgodic /-- Let `f : α → α` be a quasi ergodic map. Let `g : α → X` be an a.e. strongly measurable function from `α` to a nonempty metrizable topological space. If `g` is a.e.-invariant under `f`, then `g` is a.e. constant. -/
Mathlib/Dynamics/Ergodic/Function.lean
77
82
theorem ae_eq_const_of_ae_eq_comp_ae {g : α → X} (h : QuasiErgodic f μ) (hgm : AEStronglyMeasurable g μ) (hg_eq : g ∘ f =ᵐ[μ] g) : ∃ c, g =ᵐ[μ] const α c := by
borelize X rcases hgm.isSeparable_ae_range with ⟨t, ht, hgt⟩ haveI := ht.secondCountableTopology exact h.ae_eq_const_of_ae_eq_comp_of_ae_range₀ hgt hgm.aemeasurable.nullMeasurable hg_eq
/- Copyright (c) 2024 Judith Ludwig, Christian Merten. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Judith Ludwig, Christian Merten -/ import Mathlib.RingTheory.AdicCompletion.Basic import Mathlib.RingTheory.AdicCompletion.Algebra import Mathlib.Algebra.DirectSum.Basic /-! # Functoriality of adic completions In this file we establish functorial properties of the adic completion. ## Main definitions - `LinearMap.adicCauchy I f`: the linear map on `I`-adic cauchy sequences induced by `f` - `LinearMap.adicCompletion I f`: the linear map on `I`-adic completions induced by `f` ## Main results - `sumEquivOfFintype`: adic completion commutes with finite sums - `piEquivOfFintype`: adic completion commutes with finite products -/ variable {R : Type*} [CommRing R] (I : Ideal R) variable {M : Type*} [AddCommGroup M] [Module R M] variable {N : Type*} [AddCommGroup N] [Module R N] variable {P : Type*} [AddCommGroup P] [Module R P] variable {T : Type*} [AddCommGroup T] [Module (AdicCompletion I R) T] namespace LinearMap /-- `R`-linear version of `reduceModIdeal`. -/ private def reduceModIdealAux (f : M →ₗ[R] N) : M ⧸ (I • ⊤ : Submodule R M) →ₗ[R] N ⧸ (I • ⊤ : Submodule R N) := Submodule.mapQ (I • ⊤ : Submodule R M) (I • ⊤ : Submodule R N) f (fun x hx ↦ by refine Submodule.smul_induction_on hx (fun r hr x _ ↦ ?_) (fun x y hx hy ↦ ?_) · simp [Submodule.smul_mem_smul hr Submodule.mem_top] · simp [Submodule.add_mem _ hx hy]) @[local simp] private theorem reduceModIdealAux_apply (f : M →ₗ[R] N) (x : M) : (f.reduceModIdealAux I) (Submodule.Quotient.mk (p := (I • ⊤ : Submodule R M)) x) = Submodule.Quotient.mk (p := (I • ⊤ : Submodule R N)) (f x) := rfl /-- The induced linear map on the quotients mod `I • ⊤`. -/ def reduceModIdeal (f : M →ₗ[R] N) : M ⧸ (I • ⊤ : Submodule R M) →ₗ[R ⧸ I] N ⧸ (I • ⊤ : Submodule R N) where toFun := f.reduceModIdealAux I map_add' := by simp map_smul' r x := by refine Quotient.inductionOn' r (fun r ↦ ?_) refine Quotient.inductionOn' x (fun x ↦ ?_) simp only [Submodule.Quotient.mk''_eq_mk, Ideal.Quotient.mk_eq_mk, Module.Quotient.mk_smul_mk, Submodule.Quotient.mk_smul, LinearMapClass.map_smul, reduceModIdealAux_apply] rfl @[simp] theorem reduceModIdeal_apply (f : M →ₗ[R] N) (x : M) : (f.reduceModIdeal I) (Submodule.Quotient.mk (p := (I • ⊤ : Submodule R M)) x) = Submodule.Quotient.mk (p := (I • ⊤ : Submodule R N)) (f x) := rfl end LinearMap namespace AdicCompletion open LinearMap
Mathlib/RingTheory/AdicCompletion/Functoriality.lean
74
78
theorem transitionMap_comp_reduceModIdeal (f : M →ₗ[R] N) {m n : ℕ} (hmn : m ≤ n) : transitionMap I N hmn ∘ₗ f.reduceModIdeal (I ^ n) = (f.reduceModIdeal (I ^ m) : _ →ₗ[R] _) ∘ₗ transitionMap I M hmn := by
ext x simp
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Finset.Prod import Mathlib.Data.Set.Finite #align_import data.finset.n_ary from "leanprover-community/mathlib"@"eba7871095e834365616b5e43c8c7bb0b37058d0" /-! # N-ary images of finsets This file defines `Finset.image₂`, the binary image of finsets. This is the finset version of `Set.image2`. This is mostly useful to define pointwise operations. ## Notes This file is very similar to `Data.Set.NAry`, `Order.Filter.NAry` and `Data.Option.NAry`. Please keep them in sync. We do not define `Finset.image₃` as its only purpose would be to prove properties of `Finset.image₂` and `Set.image2` already fulfills this task. -/ open Function Set variable {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type*} namespace Finset variable [DecidableEq α'] [DecidableEq β'] [DecidableEq γ] [DecidableEq γ'] [DecidableEq δ] [DecidableEq δ'] [DecidableEq ε] [DecidableEq ε'] {f f' : α → β → γ} {g g' : α → β → γ → δ} {s s' : Finset α} {t t' : Finset β} {u u' : Finset γ} {a a' : α} {b b' : β} {c : γ} /-- The image of a binary function `f : α → β → γ` as a function `Finset α → Finset β → Finset γ`. Mathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/ def image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) : Finset γ := (s ×ˢ t).image <| uncurry f #align finset.image₂ Finset.image₂ @[simp] theorem mem_image₂ : c ∈ image₂ f s t ↔ ∃ a ∈ s, ∃ b ∈ t, f a b = c := by simp [image₂, and_assoc] #align finset.mem_image₂ Finset.mem_image₂ @[simp, norm_cast] theorem coe_image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) : (image₂ f s t : Set γ) = Set.image2 f s t := Set.ext fun _ => mem_image₂ #align finset.coe_image₂ Finset.coe_image₂ theorem card_image₂_le (f : α → β → γ) (s : Finset α) (t : Finset β) : (image₂ f s t).card ≤ s.card * t.card := card_image_le.trans_eq <| card_product _ _ #align finset.card_image₂_le Finset.card_image₂_le theorem card_image₂_iff : (image₂ f s t).card = s.card * t.card ↔ (s ×ˢ t : Set (α × β)).InjOn fun x => f x.1 x.2 := by rw [← card_product, ← coe_product] exact card_image_iff #align finset.card_image₂_iff Finset.card_image₂_iff theorem card_image₂ (hf : Injective2 f) (s : Finset α) (t : Finset β) : (image₂ f s t).card = s.card * t.card := (card_image_of_injective _ hf.uncurry).trans <| card_product _ _ #align finset.card_image₂ Finset.card_image₂ theorem mem_image₂_of_mem (ha : a ∈ s) (hb : b ∈ t) : f a b ∈ image₂ f s t := mem_image₂.2 ⟨a, ha, b, hb, rfl⟩ #align finset.mem_image₂_of_mem Finset.mem_image₂_of_mem theorem mem_image₂_iff (hf : Injective2 f) : f a b ∈ image₂ f s t ↔ a ∈ s ∧ b ∈ t := by rw [← mem_coe, coe_image₂, mem_image2_iff hf, mem_coe, mem_coe] #align finset.mem_image₂_iff Finset.mem_image₂_iff theorem image₂_subset (hs : s ⊆ s') (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s' t' := by rw [← coe_subset, coe_image₂, coe_image₂] exact image2_subset hs ht #align finset.image₂_subset Finset.image₂_subset theorem image₂_subset_left (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s t' := image₂_subset Subset.rfl ht #align finset.image₂_subset_left Finset.image₂_subset_left theorem image₂_subset_right (hs : s ⊆ s') : image₂ f s t ⊆ image₂ f s' t := image₂_subset hs Subset.rfl #align finset.image₂_subset_right Finset.image₂_subset_right theorem image_subset_image₂_left (hb : b ∈ t) : s.image (fun a => f a b) ⊆ image₂ f s t := image_subset_iff.2 fun _ ha => mem_image₂_of_mem ha hb #align finset.image_subset_image₂_left Finset.image_subset_image₂_left theorem image_subset_image₂_right (ha : a ∈ s) : t.image (fun b => f a b) ⊆ image₂ f s t := image_subset_iff.2 fun _ => mem_image₂_of_mem ha #align finset.image_subset_image₂_right Finset.image_subset_image₂_right theorem forall_image₂_iff {p : γ → Prop} : (∀ z ∈ image₂ f s t, p z) ↔ ∀ x ∈ s, ∀ y ∈ t, p (f x y) := by simp_rw [← mem_coe, coe_image₂, forall_image2_iff] #align finset.forall_image₂_iff Finset.forall_image₂_iff @[simp] theorem image₂_subset_iff : image₂ f s t ⊆ u ↔ ∀ x ∈ s, ∀ y ∈ t, f x y ∈ u := forall_image₂_iff #align finset.image₂_subset_iff Finset.image₂_subset_iff
Mathlib/Data/Finset/NAry.lean
108
109
theorem image₂_subset_iff_left : image₂ f s t ⊆ u ↔ ∀ a ∈ s, (t.image fun b => f a b) ⊆ u := by
simp_rw [image₂_subset_iff, image_subset_iff]
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Init.Function #align_import data.option.n_ary from "leanprover-community/mathlib"@"995b47e555f1b6297c7cf16855f1023e355219fb" /-! # Binary map of options This file defines the binary map of `Option`. This is mostly useful to define pointwise operations on intervals. ## Main declarations * `Option.map₂`: Binary map of options. ## Notes This file is very similar to the n-ary section of `Mathlib.Data.Set.Basic`, to `Mathlib.Data.Finset.NAry` and to `Mathlib.Order.Filter.NAry`. Please keep them in sync. (porting note - only some of these may exist right now!) We do not define `Option.map₃` as its only purpose so far would be to prove properties of `Option.map₂` and casing already fulfills this task. -/ universe u open Function namespace Option variable {α β γ δ : Type*} {f : α → β → γ} {a : Option α} {b : Option β} {c : Option γ} /-- The image of a binary function `f : α → β → γ` as a function `Option α → Option β → Option γ`. Mathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/ def map₂ (f : α → β → γ) (a : Option α) (b : Option β) : Option γ := a.bind fun a => b.map <| f a #align option.map₂ Option.map₂ /-- `Option.map₂` in terms of monadic operations. Note that this can't be taken as the definition because of the lack of universe polymorphism. -/ theorem map₂_def {α β γ : Type u} (f : α → β → γ) (a : Option α) (b : Option β) : map₂ f a b = f <$> a <*> b := by cases a <;> rfl #align option.map₂_def Option.map₂_def -- Porting note (#10618): In Lean3, was `@[simp]` but now `simp` can prove it theorem map₂_some_some (f : α → β → γ) (a : α) (b : β) : map₂ f (some a) (some b) = f a b := rfl #align option.map₂_some_some Option.map₂_some_some theorem map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b := rfl #align option.map₂_coe_coe Option.map₂_coe_coe @[simp] theorem map₂_none_left (f : α → β → γ) (b : Option β) : map₂ f none b = none := rfl #align option.map₂_none_left Option.map₂_none_left @[simp] theorem map₂_none_right (f : α → β → γ) (a : Option α) : map₂ f a none = none := by cases a <;> rfl #align option.map₂_none_right Option.map₂_none_right @[simp] theorem map₂_coe_left (f : α → β → γ) (a : α) (b : Option β) : map₂ f a b = b.map fun b => f a b := rfl #align option.map₂_coe_left Option.map₂_coe_left -- Porting note: This proof was `rfl` in Lean3, but now is not. @[simp] theorem map₂_coe_right (f : α → β → γ) (a : Option α) (b : β) : map₂ f a b = a.map fun a => f a b := by cases a <;> rfl #align option.map₂_coe_right Option.map₂_coe_right -- Porting note: Removed the `@[simp]` tag as membership of an `Option` is no-longer simp-normal. theorem mem_map₂_iff {c : γ} : c ∈ map₂ f a b ↔ ∃ a' b', a' ∈ a ∧ b' ∈ b ∧ f a' b' = c := by simp [map₂, bind_eq_some] #align option.mem_map₂_iff Option.mem_map₂_iff @[simp] theorem map₂_eq_none_iff : map₂ f a b = none ↔ a = none ∨ b = none := by cases a <;> cases b <;> simp #align option.map₂_eq_none_iff Option.map₂_eq_none_iff
Mathlib/Data/Option/NAry.lean
87
88
theorem map₂_swap (f : α → β → γ) (a : Option α) (b : Option β) : map₂ f a b = map₂ (fun a b => f b a) b a := by
cases a <;> cases b <;> rfl
/- 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.ContMDiff.Basic /-! ## Smoothness of standard maps associated to the product of manifolds This file contains results about smoothness of standard maps associated to products of manifolds - if `f` and `g` are smooth, so is their point-wise product. - the component projections from a product of manifolds are smooth. - functions into a product (*pi type*) are smooth iff their components are -/ open Set Function Filter ChartedSpace SmoothManifoldWithCorners open scoped Topology Manifold variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] -- declare a smooth manifold `M` over the pair `(E, H)`. {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners 𝕜 E H) {M : Type*} [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] -- declare a smooth manifold `M'` over the pair `(E', H')`. {E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H'] (I' : ModelWithCorners 𝕜 E' H') {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M'] [SmoothManifoldWithCorners I' M'] -- declare a manifold `M''` over the pair `(E'', H'')`. {E'' : Type*} [NormedAddCommGroup E''] [NormedSpace 𝕜 E''] {H'' : Type*} [TopologicalSpace H''] {I'' : ModelWithCorners 𝕜 E'' H''} {M'' : Type*} [TopologicalSpace M''] [ChartedSpace H'' M''] -- declare a smooth manifold `N` over the pair `(F, G)`. {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type*} [TopologicalSpace G] {J : ModelWithCorners 𝕜 F G} {N : Type*} [TopologicalSpace N] [ChartedSpace G N] [SmoothManifoldWithCorners J N] -- declare a smooth manifold `N'` over the pair `(F', G')`. {F' : Type*} [NormedAddCommGroup F'] [NormedSpace 𝕜 F'] {G' : Type*} [TopologicalSpace G'] {J' : ModelWithCorners 𝕜 F' G'} {N' : Type*} [TopologicalSpace N'] [ChartedSpace G' N'] [SmoothManifoldWithCorners J' N'] -- F₁, F₂, F₃, F₄ are normed spaces {F₁ : Type*} [NormedAddCommGroup F₁] [NormedSpace 𝕜 F₁] {F₂ : Type*} [NormedAddCommGroup F₂] [NormedSpace 𝕜 F₂] {F₃ : Type*} [NormedAddCommGroup F₃] [NormedSpace 𝕜 F₃] {F₄ : Type*} [NormedAddCommGroup F₄] [NormedSpace 𝕜 F₄] -- declare functions, sets, points and smoothness indices {e : PartialHomeomorph M H} {e' : PartialHomeomorph M' H'} {f f₁ : M → M'} {s s₁ t : Set M} {x : M} {m n : ℕ∞} variable {I I'} section ProdMk
Mathlib/Geometry/Manifold/ContMDiff/Product.lean
59
63
theorem ContMDiffWithinAt.prod_mk {f : M → M'} {g : M → N'} (hf : ContMDiffWithinAt I I' n f s x) (hg : ContMDiffWithinAt I J' n g s x) : ContMDiffWithinAt I (I'.prod J') n (fun x => (f x, g x)) s x := by
rw [contMDiffWithinAt_iff] at * exact ⟨hf.1.prod hg.1, hf.2.prod hg.2⟩
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot, Yury Kudryashov, Rémy Degenne -/ import Mathlib.Order.Interval.Set.Basic import Mathlib.Order.Hom.Set #align_import data.set.intervals.order_iso from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" /-! # Lemmas about images of intervals under order isomorphisms. -/ open Set namespace OrderIso section Preorder variable {α β : Type*} [Preorder α] [Preorder β] @[simp] theorem preimage_Iic (e : α ≃o β) (b : β) : e ⁻¹' Iic b = Iic (e.symm b) := by ext x simp [← e.le_iff_le] #align order_iso.preimage_Iic OrderIso.preimage_Iic @[simp] theorem preimage_Ici (e : α ≃o β) (b : β) : e ⁻¹' Ici b = Ici (e.symm b) := by ext x simp [← e.le_iff_le] #align order_iso.preimage_Ici OrderIso.preimage_Ici @[simp]
Mathlib/Order/Interval/Set/OrderIso.lean
36
38
theorem preimage_Iio (e : α ≃o β) (b : β) : e ⁻¹' Iio b = Iio (e.symm b) := by
ext x simp [← e.lt_iff_lt]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Fin.Tuple.Basic import Mathlib.Data.List.Join #align_import data.list.of_fn from "leanprover-community/mathlib"@"bf27744463e9620ca4e4ebe951fe83530ae6949b" /-! # Lists from functions Theorems and lemmas for dealing with `List.ofFn`, which converts a function on `Fin n` to a list of length `n`. ## Main Statements The main statements pertain to lists generated using `List.ofFn` - `List.length_ofFn`, which tells us the length of such a list - `List.get?_ofFn`, which tells us the nth element of such a list - `List.equivSigmaTuple`, which is an `Equiv` between lists and the functions that generate them via `List.ofFn`. -/ universe u variable {α : Type u} open Nat namespace List #noalign list.length_of_fn_aux @[simp] theorem length_ofFn_go {n} (f : Fin n → α) (i j h) : length (ofFn.go f i j h) = i := by induction i generalizing j <;> simp_all [ofFn.go] /-- The length of a list converted from a function is the size of the domain. -/ @[simp] theorem length_ofFn {n} (f : Fin n → α) : length (ofFn f) = n := by simp [ofFn, length_ofFn_go] #align list.length_of_fn List.length_ofFn #noalign list.nth_of_fn_aux theorem get_ofFn_go {n} (f : Fin n → α) (i j h) (k) (hk) : get (ofFn.go f i j h) ⟨k, hk⟩ = f ⟨j + k, by simp at hk; omega⟩ := by let i+1 := i cases k <;> simp [ofFn.go, get_ofFn_go (i := i)] congr 2; omega -- Porting note (#10756): new theorem @[simp] theorem get_ofFn {n} (f : Fin n → α) (i) : get (ofFn f) i = f (Fin.cast (by simp) i) := by cases i; simp [ofFn, get_ofFn_go] /-- The `n`th element of a list -/ @[simp] theorem get?_ofFn {n} (f : Fin n → α) (i) : get? (ofFn f) i = ofFnNthVal f i := if h : i < (ofFn f).length then by rw [get?_eq_get h, get_ofFn] · simp only [length_ofFn] at h; simp [ofFnNthVal, h] else by rw [ofFnNthVal, dif_neg] <;> simpa using h #align list.nth_of_fn List.get?_ofFn set_option linter.deprecated false in @[deprecated get_ofFn (since := "2023-01-17")] theorem nthLe_ofFn {n} (f : Fin n → α) (i : Fin n) : nthLe (ofFn f) i ((length_ofFn f).symm ▸ i.2) = f i := by simp [nthLe] #align list.nth_le_of_fn List.nthLe_ofFn set_option linter.deprecated false in @[simp, deprecated get_ofFn (since := "2023-01-17")] theorem nthLe_ofFn' {n} (f : Fin n → α) {i : ℕ} (h : i < (ofFn f).length) : nthLe (ofFn f) i h = f ⟨i, length_ofFn f ▸ h⟩ := nthLe_ofFn f ⟨i, length_ofFn f ▸ h⟩ #align list.nth_le_of_fn' List.nthLe_ofFn' @[simp] theorem map_ofFn {β : Type*} {n : ℕ} (f : Fin n → α) (g : α → β) : map g (ofFn f) = ofFn (g ∘ f) := ext_get (by simp) fun i h h' => by simp #align list.map_of_fn List.map_ofFn -- Porting note: we don't have Array' in mathlib4 -- /-- Arrays converted to lists are the same as `of_fn` on the indexing function of the array. -/ -- theorem array_eq_of_fn {n} (a : Array' n α) : a.toList = ofFn a.read := -- by -- suffices ∀ {m h l}, DArray.revIterateAux a (fun i => cons) m h l = -- ofFnAux (DArray.read a) m h l -- from this -- intros; induction' m with m IH generalizing l; · rfl -- simp only [DArray.revIterateAux, of_fn_aux, IH] -- #align list.array_eq_of_fn List.array_eq_of_fn @[congr]
Mathlib/Data/List/OfFn.lean
105
108
theorem ofFn_congr {m n : ℕ} (h : m = n) (f : Fin m → α) : ofFn f = ofFn fun i : Fin n => f (Fin.cast h.symm i) := by
subst h simp_rw [Fin.cast_refl, id]
/- Copyright (c) 2024 Antoine Chambert-Loir. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Chambert-Loir -/ import Mathlib.Data.Setoid.Partition import Mathlib.GroupTheory.GroupAction.Basic import Mathlib.GroupTheory.GroupAction.Pointwise import Mathlib.GroupTheory.GroupAction.SubMulAction /-! # Blocks Given `SMul G X`, an action of a type `G` on a type `X`, we define - the predicate `IsBlock G B` states that `B : Set X` is a block, which means that the sets `g • B`, for `g ∈ G`, are equal or disjoint. - a bunch of lemmas that give examples of “trivial” blocks : ⊥, ⊤, singletons, and non trivial blocks: orbit of the group, orbit of a normal subgroup… The non-existence of nontrivial blocks is the definition of primitive actions. ## References We follow [wieland1964]. -/ open scoped BigOperators Pointwise namespace MulAction section orbits variable {G : Type*} [Group G] {X : Type*} [MulAction G X] theorem orbit.eq_or_disjoint (a b : X) : orbit G a = orbit G b ∨ Disjoint (orbit G a) (orbit G b) := by apply (em (Disjoint (orbit G a) (orbit G b))).symm.imp _ id simp (config := { contextual := true }) only [Set.not_disjoint_iff, ← orbit_eq_iff, forall_exists_index, and_imp, eq_comm, implies_true] theorem orbit.pairwiseDisjoint : (Set.range fun x : X => orbit G x).PairwiseDisjoint id := by rintro s ⟨x, rfl⟩ t ⟨y, rfl⟩ h contrapose! h exact (orbit.eq_or_disjoint x y).resolve_right h /-- Orbits of an element form a partition -/ theorem IsPartition.of_orbits : Setoid.IsPartition (Set.range fun a : X => orbit G a) := by apply orbit.pairwiseDisjoint.isPartition_of_exists_of_ne_empty · intro x exact ⟨_, ⟨x, rfl⟩, mem_orbit_self x⟩ · rintro ⟨a, ha : orbit G a = ∅⟩ exact (MulAction.orbit_nonempty a).ne_empty ha end orbits section SMul variable (G : Type*) {X : Type*} [SMul G X] -- Change terminology : is_fully_invariant ? /-- For `SMul G X`, a fixed block is a `Set X` which is fully invariant: `g • B = B` for all `g : G` -/ def IsFixedBlock (B : Set X) := ∀ g : G, g • B = B /-- For `SMul G X`, an invariant block is a `Set X` which is stable: `g • B ⊆ B` for all `g : G` -/ def IsInvariantBlock (B : Set X) := ∀ g : G, g • B ⊆ B /-- A trivial block is a `Set X` which is either a subsingleton or ⊤ (it is not necessarily a block…) -/ def IsTrivialBlock (B : Set X) := B.Subsingleton ∨ B = ⊤ /-- `For SMul G X`, a block is a `Set X` whose translates are pairwise disjoint -/ def IsBlock (B : Set X) := (Set.range fun g : G => g • B).PairwiseDisjoint id variable {G} /-- A set B is a block iff for all g, g', the sets g • B and g' • B are either equal or disjoint -/ theorem IsBlock.def {B : Set X} : IsBlock G B ↔ ∀ g g' : G, g • B = g' • B ∨ Disjoint (g • B) (g' • B) := by apply Set.pairwiseDisjoint_range_iff /-- Alternate definition of a block -/ theorem IsBlock.mk_notempty {B : Set X} : IsBlock G B ↔ ∀ g g' : G, g • B ∩ g' • B ≠ ∅ → g • B = g' • B := by simp_rw [IsBlock.def, or_iff_not_imp_right, Set.disjoint_iff_inter_eq_empty] /-- A fixed block is a block -/ theorem IsFixedBlock.isBlock {B : Set X} (hfB : IsFixedBlock G B) : IsBlock G B := by simp [IsBlock.def, hfB _] variable (X) /-- The empty set is a block -/ theorem isBlock_empty : IsBlock G (⊥ : Set X) := by simp [IsBlock.def, Set.bot_eq_empty, Set.smul_set_empty] variable {X} theorem isBlock_singleton (a : X) : IsBlock G ({a} : Set X) := by simp [IsBlock.def, Classical.or_iff_not_imp_left] /-- Subsingletons are (trivial) blocks -/ theorem isBlock_subsingleton {B : Set X} (hB : B.Subsingleton) : IsBlock G B := hB.induction_on (isBlock_empty _) isBlock_singleton end SMul section Group variable {G : Type*} [Group G] {X : Type*} [MulAction G X] theorem IsBlock.smul_eq_or_disjoint {B : Set X} (hB : IsBlock G B) (g : G) : g • B = B ∨ Disjoint (g • B) B := by rw [IsBlock.def] at hB simpa only [one_smul] using hB g 1
Mathlib/GroupTheory/GroupAction/Blocks.lean
126
139
theorem IsBlock.def_one {B : Set X} : IsBlock G B ↔ ∀ g : G, g • B = B ∨ Disjoint (g • B) B := by
refine ⟨IsBlock.smul_eq_or_disjoint, ?_⟩ rw [IsBlock.def] intro hB g g' apply (hB (g'⁻¹ * g)).imp · rw [← smul_smul, ← eq_inv_smul_iff, inv_inv] exact id · intro h rw [Set.disjoint_iff] at h ⊢ rintro x hx suffices g'⁻¹ • x ∈ (g'⁻¹ * g) • B ∩ B by apply h this simp only [Set.mem_inter_iff, ← Set.mem_smul_set_iff_inv_smul_mem, ← smul_smul, smul_inv_smul] exact hx
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho import Mathlib.LinearAlgebra.Orientation #align_import analysis.inner_product_space.orientation from "leanprover-community/mathlib"@"bd65478311e4dfd41f48bf38c7e3b02fb75d0163" /-! # Orientations of real inner product spaces. This file provides definitions and proves lemmas about orientations of real inner product spaces. ## Main definitions * `OrthonormalBasis.adjustToOrientation` takes an orthonormal basis and an orientation, and returns an orthonormal basis with that orientation: either the original orthonormal basis, or one constructed by negating a single (arbitrary) basis vector. * `Orientation.finOrthonormalBasis` is an orthonormal basis, indexed by `Fin n`, with the given orientation. * `Orientation.volumeForm` is a nonvanishing top-dimensional alternating form on an oriented real inner product space, uniquely defined by compatibility with the orientation and inner product structure. ## Main theorems * `Orientation.volumeForm_apply_le` states that the result of applying the volume form to a set of `n` vectors, where `n` is the dimension the inner product space, is bounded by the product of the lengths of the vectors. * `Orientation.abs_volumeForm_apply_of_pairwise_orthogonal` states that the result of applying the volume form to a set of `n` orthogonal vectors, where `n` is the dimension the inner product space, is equal up to sign to the product of the lengths of the vectors. -/ noncomputable section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] open FiniteDimensional open scoped RealInnerProductSpace namespace OrthonormalBasis variable {ι : Type*} [Fintype ι] [DecidableEq ι] [ne : Nonempty ι] (e f : OrthonormalBasis ι ℝ E) (x : Orientation ℝ E ι) /-- The change-of-basis matrix between two orthonormal bases with the same orientation has determinant 1. -/ theorem det_to_matrix_orthonormalBasis_of_same_orientation (h : e.toBasis.orientation = f.toBasis.orientation) : e.toBasis.det f = 1 := by apply (e.det_to_matrix_orthonormalBasis_real f).resolve_right have : 0 < e.toBasis.det f := by rw [e.toBasis.orientation_eq_iff_det_pos] at h simpa using h linarith #align orthonormal_basis.det_to_matrix_orthonormal_basis_of_same_orientation OrthonormalBasis.det_to_matrix_orthonormalBasis_of_same_orientation /-- The change-of-basis matrix between two orthonormal bases with the opposite orientations has determinant -1. -/ theorem det_to_matrix_orthonormalBasis_of_opposite_orientation (h : e.toBasis.orientation ≠ f.toBasis.orientation) : e.toBasis.det f = -1 := by contrapose! h simp [e.toBasis.orientation_eq_iff_det_pos, (e.det_to_matrix_orthonormalBasis_real f).resolve_right h] #align orthonormal_basis.det_to_matrix_orthonormal_basis_of_opposite_orientation OrthonormalBasis.det_to_matrix_orthonormalBasis_of_opposite_orientation variable {e f} /-- Two orthonormal bases with the same orientation determine the same "determinant" top-dimensional form on `E`, and conversely. -/ theorem same_orientation_iff_det_eq_det : e.toBasis.det = f.toBasis.det ↔ e.toBasis.orientation = f.toBasis.orientation := by constructor · intro h dsimp [Basis.orientation] congr · intro h rw [e.toBasis.det.eq_smul_basis_det f.toBasis] simp [e.det_to_matrix_orthonormalBasis_of_same_orientation f h] #align orthonormal_basis.same_orientation_iff_det_eq_det OrthonormalBasis.same_orientation_iff_det_eq_det variable (e f) /-- Two orthonormal bases with opposite orientations determine opposite "determinant" top-dimensional forms on `E`. -/ theorem det_eq_neg_det_of_opposite_orientation (h : e.toBasis.orientation ≠ f.toBasis.orientation) : e.toBasis.det = -f.toBasis.det := by rw [e.toBasis.det.eq_smul_basis_det f.toBasis] -- Porting note: added `neg_one_smul` with explicit type simp [e.det_to_matrix_orthonormalBasis_of_opposite_orientation f h, neg_one_smul ℝ (M := E [⋀^ι]→ₗ[ℝ] ℝ)] #align orthonormal_basis.det_eq_neg_det_of_opposite_orientation OrthonormalBasis.det_eq_neg_det_of_opposite_orientation section AdjustToOrientation /-- `OrthonormalBasis.adjustToOrientation`, applied to an orthonormal basis, preserves the property of orthonormality. -/ theorem orthonormal_adjustToOrientation : Orthonormal ℝ (e.toBasis.adjustToOrientation x) := by apply e.orthonormal.orthonormal_of_forall_eq_or_eq_neg simpa using e.toBasis.adjustToOrientation_apply_eq_or_eq_neg x #align orthonormal_basis.orthonormal_adjust_to_orientation OrthonormalBasis.orthonormal_adjustToOrientation /-- Given an orthonormal basis and an orientation, return an orthonormal basis giving that orientation: either the original basis, or one constructed by negating a single (arbitrary) basis vector. -/ def adjustToOrientation : OrthonormalBasis ι ℝ E := (e.toBasis.adjustToOrientation x).toOrthonormalBasis (e.orthonormal_adjustToOrientation x) #align orthonormal_basis.adjust_to_orientation OrthonormalBasis.adjustToOrientation theorem toBasis_adjustToOrientation : (e.adjustToOrientation x).toBasis = e.toBasis.adjustToOrientation x := (e.toBasis.adjustToOrientation x).toBasis_toOrthonormalBasis _ #align orthonormal_basis.to_basis_adjust_to_orientation OrthonormalBasis.toBasis_adjustToOrientation /-- `adjustToOrientation` gives an orthonormal basis with the required orientation. -/ @[simp] theorem orientation_adjustToOrientation : (e.adjustToOrientation x).toBasis.orientation = x := by rw [e.toBasis_adjustToOrientation] exact e.toBasis.orientation_adjustToOrientation x #align orthonormal_basis.orientation_adjust_to_orientation OrthonormalBasis.orientation_adjustToOrientation /-- Every basis vector from `adjustToOrientation` is either that from the original basis or its negation. -/
Mathlib/Analysis/InnerProductSpace/Orientation.lean
129
132
theorem adjustToOrientation_apply_eq_or_eq_neg (i : ι) : e.adjustToOrientation x i = e i ∨ e.adjustToOrientation x i = -e i := by
simpa [← e.toBasis_adjustToOrientation] using e.toBasis.adjustToOrientation_apply_eq_or_eq_neg x i
/- Copyright (c) 2021 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying -/ import Mathlib.MeasureTheory.Measure.Sub import Mathlib.MeasureTheory.Decomposition.SignedHahn import Mathlib.MeasureTheory.Function.AEEqOfIntegral #align_import measure_theory.decomposition.lebesgue from "leanprover-community/mathlib"@"b2ff9a3d7a15fd5b0f060b135421d6a89a999c2f" /-! # Lebesgue decomposition This file proves the Lebesgue decomposition theorem. The Lebesgue decomposition theorem states that, given two σ-finite measures `μ` and `ν`, there exists a σ-finite measure `ξ` and a measurable function `f` such that `μ = ξ + fν` and `ξ` is mutually singular with respect to `ν`. The Lebesgue decomposition provides the Radon-Nikodym theorem readily. ## Main definitions * `MeasureTheory.Measure.HaveLebesgueDecomposition` : A pair of measures `μ` and `ν` is said to `HaveLebesgueDecomposition` if there exist a measure `ξ` and a measurable function `f`, such that `ξ` is mutually singular with respect to `ν` and `μ = ξ + ν.withDensity f` * `MeasureTheory.Measure.singularPart` : If a pair of measures `HaveLebesgueDecomposition`, then `singularPart` chooses the measure from `HaveLebesgueDecomposition`, otherwise it returns the zero measure. * `MeasureTheory.Measure.rnDeriv`: If a pair of measures `HaveLebesgueDecomposition`, then `rnDeriv` chooses the measurable function from `HaveLebesgueDecomposition`, otherwise it returns the zero function. ## Main results * `MeasureTheory.Measure.haveLebesgueDecomposition_of_sigmaFinite` : the Lebesgue decomposition theorem. * `MeasureTheory.Measure.eq_singularPart` : Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a measurable function such that `μ = s + fν`, then `s = μ.singularPart ν`. * `MeasureTheory.Measure.eq_rnDeriv` : Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a measurable function such that `μ = s + fν`, then `f = μ.rnDeriv ν`. ## Tags Lebesgue decomposition theorem -/ open scoped MeasureTheory NNReal ENNReal open Set namespace MeasureTheory namespace Measure variable {α β : Type*} {m : MeasurableSpace α} {μ ν : Measure α} /-- A pair of measures `μ` and `ν` is said to `HaveLebesgueDecomposition` if there exists a measure `ξ` and a measurable function `f`, such that `ξ` is mutually singular with respect to `ν` and `μ = ξ + ν.withDensity f`. -/ class HaveLebesgueDecomposition (μ ν : Measure α) : Prop where lebesgue_decomposition : ∃ p : Measure α × (α → ℝ≥0∞), Measurable p.2 ∧ p.1 ⟂ₘ ν ∧ μ = p.1 + ν.withDensity p.2 #align measure_theory.measure.have_lebesgue_decomposition MeasureTheory.Measure.HaveLebesgueDecomposition #align measure_theory.measure.have_lebesgue_decomposition.lebesgue_decomposition MeasureTheory.Measure.HaveLebesgueDecomposition.lebesgue_decomposition open Classical in /-- If a pair of measures `HaveLebesgueDecomposition`, then `singularPart` chooses the measure from `HaveLebesgueDecomposition`, otherwise it returns the zero measure. For sigma-finite measures, `μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν)`. -/ noncomputable irreducible_def singularPart (μ ν : Measure α) : Measure α := if h : HaveLebesgueDecomposition μ ν then (Classical.choose h.lebesgue_decomposition).1 else 0 #align measure_theory.measure.singular_part MeasureTheory.Measure.singularPart open Classical in /-- If a pair of measures `HaveLebesgueDecomposition`, then `rnDeriv` chooses the measurable function from `HaveLebesgueDecomposition`, otherwise it returns the zero function. For sigma-finite measures, `μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν)`. -/ noncomputable irreducible_def rnDeriv (μ ν : Measure α) : α → ℝ≥0∞ := if h : HaveLebesgueDecomposition μ ν then (Classical.choose h.lebesgue_decomposition).2 else 0 #align measure_theory.measure.rn_deriv MeasureTheory.Measure.rnDeriv section ByDefinition theorem haveLebesgueDecomposition_spec (μ ν : Measure α) [h : HaveLebesgueDecomposition μ ν] : Measurable (μ.rnDeriv ν) ∧ μ.singularPart ν ⟂ₘ ν ∧ μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν) := by rw [singularPart, rnDeriv, dif_pos h, dif_pos h] exact Classical.choose_spec h.lebesgue_decomposition #align measure_theory.measure.have_lebesgue_decomposition_spec MeasureTheory.Measure.haveLebesgueDecomposition_spec lemma rnDeriv_of_not_haveLebesgueDecomposition (h : ¬ HaveLebesgueDecomposition μ ν) : μ.rnDeriv ν = 0 := by rw [rnDeriv, dif_neg h] lemma singularPart_of_not_haveLebesgueDecomposition (h : ¬ HaveLebesgueDecomposition μ ν) : μ.singularPart ν = 0 := by rw [singularPart, dif_neg h] @[measurability] theorem measurable_rnDeriv (μ ν : Measure α) : Measurable <| μ.rnDeriv ν := by by_cases h : HaveLebesgueDecomposition μ ν · exact (haveLebesgueDecomposition_spec μ ν).1 · rw [rnDeriv_of_not_haveLebesgueDecomposition h] exact measurable_zero #align measure_theory.measure.measurable_rn_deriv MeasureTheory.Measure.measurable_rnDeriv
Mathlib/MeasureTheory/Decomposition/Lebesgue.lean
109
113
theorem mutuallySingular_singularPart (μ ν : Measure α) : μ.singularPart ν ⟂ₘ ν := by
by_cases h : HaveLebesgueDecomposition μ ν · exact (haveLebesgueDecomposition_spec μ ν).2.1 · rw [singularPart_of_not_haveLebesgueDecomposition h] exact MutuallySingular.zero_left
/- Copyright (c) 2022 Yuyang Zhao. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuyang Zhao -/ import Batteries.Classes.Order namespace Batteries.PairingHeapImp /-- A `Heap` is the nodes of the pairing heap. Each node have two pointers: `child` going to the first child of this node, and `sibling` goes to the next sibling of this tree. So it actually encodes a forest where each node has children `node.child`, `node.child.sibling`, `node.child.sibling.sibling`, etc. Each edge in this forest denotes a `le a b` relation that has been checked, so the root is smaller than everything else under it. -/ inductive Heap (α : Type u) where /-- An empty forest, which has depth `0`. -/ | nil : Heap α /-- A forest consists of a root `a`, a forest `child` elements greater than `a`, and another forest `sibling`. -/ | node (a : α) (child sibling : Heap α) : Heap α deriving Repr /-- `O(n)`. The number of elements in the heap. -/ def Heap.size : Heap α → Nat | .nil => 0 | .node _ c s => c.size + 1 + s.size /-- A node containing a single element `a`. -/ def Heap.singleton (a : α) : Heap α := .node a .nil .nil /-- `O(1)`. Is the heap empty? -/ def Heap.isEmpty : Heap α → Bool | .nil => true | _ => false /-- `O(1)`. Merge two heaps. Ignore siblings. -/ @[specialize] def Heap.merge (le : α → α → Bool) : Heap α → Heap α → Heap α | .nil, .nil => .nil | .nil, .node a₂ c₂ _ => .node a₂ c₂ .nil | .node a₁ c₁ _, .nil => .node a₁ c₁ .nil | .node a₁ c₁ _, .node a₂ c₂ _ => if le a₁ a₂ then .node a₁ (.node a₂ c₂ c₁) .nil else .node a₂ (.node a₁ c₁ c₂) .nil /-- Auxiliary for `Heap.deleteMin`: merge the forest in pairs. -/ @[specialize] def Heap.combine (le : α → α → Bool) : Heap α → Heap α | h₁@(.node _ _ h₂@(.node _ _ s)) => merge le (merge le h₁ h₂) (s.combine le) | h => h /-- `O(1)`. Get the smallest element in the heap, including the passed in value `a`. -/ @[inline] def Heap.headD (a : α) : Heap α → α | .nil => a | .node a _ _ => a /-- `O(1)`. Get the smallest element in the heap, if it has an element. -/ @[inline] def Heap.head? : Heap α → Option α | .nil => none | .node a _ _ => some a /-- Amortized `O(log n)`. Find and remove the the minimum element from the heap. -/ @[inline] def Heap.deleteMin (le : α → α → Bool) : Heap α → Option (α × Heap α) | .nil => none | .node a c _ => (a, combine le c) /-- Amortized `O(log n)`. Get the tail of the pairing heap after removing the minimum element. -/ @[inline] def Heap.tail? (le : α → α → Bool) (h : Heap α) : Option (Heap α) := deleteMin le h |>.map (·.snd) /-- Amortized `O(log n)`. Remove the minimum element of the heap. -/ @[inline] def Heap.tail (le : α → α → Bool) (h : Heap α) : Heap α := tail? le h |>.getD .nil /-- A predicate says there is no more than one tree. -/ inductive Heap.NoSibling : Heap α → Prop /-- An empty heap is no more than one tree. -/ | nil : NoSibling .nil /-- Or there is exactly one tree. -/ | node (a c) : NoSibling (.node a c .nil) instance : Decidable (Heap.NoSibling s) := match s with | .nil => isTrue .nil | .node a c .nil => isTrue (.node a c) | .node _ _ (.node _ _ _) => isFalse nofun theorem Heap.noSibling_merge (le) (s₁ s₂ : Heap α) : (s₁.merge le s₂).NoSibling := by unfold merge (split <;> try split) <;> constructor theorem Heap.noSibling_combine (le) (s : Heap α) : (s.combine le).NoSibling := by unfold combine; split · exact noSibling_merge _ _ _ · match s with | nil | node _ _ nil => constructor | node _ _ (node _ _ s) => rename_i h; exact (h _ _ _ _ _ rfl).elim theorem Heap.noSibling_deleteMin {s : Heap α} (eq : s.deleteMin le = some (a, s')) : s'.NoSibling := by cases s with cases eq | node a c => exact noSibling_combine _ _ theorem Heap.noSibling_tail? {s : Heap α} : s.tail? le = some s' → s'.NoSibling := by simp only [Heap.tail?]; intro eq match eq₂ : s.deleteMin le, eq with | some (a, tl), rfl => exact noSibling_deleteMin eq₂ theorem Heap.noSibling_tail (le) (s : Heap α) : (s.tail le).NoSibling := by simp only [Heap.tail] match eq : s.tail? le with | none => cases s with cases eq | nil => constructor | some tl => exact Heap.noSibling_tail? eq theorem Heap.size_merge_node (le) (a₁ : α) (c₁ s₁ : Heap α) (a₂ : α) (c₂ s₂ : Heap α) : (merge le (.node a₁ c₁ s₁) (.node a₂ c₂ s₂)).size = c₁.size + c₂.size + 2 := by unfold merge; dsimp; split <;> simp_arith [size] theorem Heap.size_merge (le) {s₁ s₂ : Heap α} (h₁ : s₁.NoSibling) (h₂ : s₂.NoSibling) : (merge le s₁ s₂).size = s₁.size + s₂.size := by match h₁, h₂ with | .nil, .nil | .nil, .node _ _ | .node _ _, .nil => simp [size] | .node _ _, .node _ _ => unfold merge; dsimp; split <;> simp_arith [size]
.lake/packages/batteries/Batteries/Data/PairingHeap.lean
129
136
theorem Heap.size_combine (le) (s : Heap α) : (s.combine le).size = s.size := by
unfold combine; split · rename_i a₁ c₁ a₂ c₂ s rw [size_merge le (noSibling_merge _ _ _) (noSibling_combine _ _), size_merge_node, size_combine le s] simp_arith [size] · rfl
/- Copyright (c) 2017 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Algebra.Group.Defs import Mathlib.Control.Functor #align_import control.applicative from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" /-! # `applicative` instances This file provides `Applicative` instances for concrete functors: * `id` * `Functor.comp` * `Functor.const` * `Functor.add_const` -/ universe u v w section Lemmas open Function variable {F : Type u → Type v} variable [Applicative F] [LawfulApplicative F] variable {α β γ σ : Type u} theorem Applicative.map_seq_map (f : α → β → γ) (g : σ → β) (x : F α) (y : F σ) : f <$> x <*> g <$> y = ((· ∘ g) ∘ f) <$> x <*> y := by simp [flip, functor_norm] #align applicative.map_seq_map Applicative.map_seq_map
Mathlib/Control/Applicative.lean
36
37
theorem Applicative.pure_seq_eq_map' (f : α → β) : ((pure f : F (α → β)) <*> ·) = (f <$> ·) := by
ext; simp [functor_norm]
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Mario Carneiro, Sean Leather -/ import Mathlib.Data.Finset.Card #align_import data.finset.option from "leanprover-community/mathlib"@"c227d107bbada5d0d9d20287e3282c0a7f1651a0" /-! # Finite sets in `Option α` In this file we define * `Option.toFinset`: construct an empty or singleton `Finset α` from an `Option α`; * `Finset.insertNone`: given `s : Finset α`, lift it to a finset on `Option α` using `Option.some` and then insert `Option.none`; * `Finset.eraseNone`: given `s : Finset (Option α)`, returns `t : Finset α` such that `x ∈ t ↔ some x ∈ s`. Then we prove some basic lemmas about these definitions. ## Tags finset, option -/ variable {α β : Type*} open Function namespace Option /-- Construct an empty or singleton finset from an `Option` -/ def toFinset (o : Option α) : Finset α := o.elim ∅ singleton #align option.to_finset Option.toFinset @[simp] theorem toFinset_none : none.toFinset = (∅ : Finset α) := rfl #align option.to_finset_none Option.toFinset_none @[simp] theorem toFinset_some {a : α} : (some a).toFinset = {a} := rfl #align option.to_finset_some Option.toFinset_some @[simp] theorem mem_toFinset {a : α} {o : Option α} : a ∈ o.toFinset ↔ a ∈ o := by cases o <;> simp [eq_comm] #align option.mem_to_finset Option.mem_toFinset theorem card_toFinset (o : Option α) : o.toFinset.card = o.elim 0 1 := by cases o <;> rfl #align option.card_to_finset Option.card_toFinset end Option namespace Finset /-- Given a finset on `α`, lift it to being a finset on `Option α` using `Option.some` and then insert `Option.none`. -/ def insertNone : Finset α ↪o Finset (Option α) := (OrderEmbedding.ofMapLEIff fun s => cons none (s.map Embedding.some) <| by simp) fun s t => by rw [le_iff_subset, cons_subset_cons, map_subset_map, le_iff_subset] #align finset.insert_none Finset.insertNone @[simp] theorem mem_insertNone {s : Finset α} : ∀ {o : Option α}, o ∈ insertNone s ↔ ∀ a ∈ o, a ∈ s | none => iff_of_true (Multiset.mem_cons_self _ _) fun a h => by cases h | some a => Multiset.mem_cons.trans <| by simp #align finset.mem_insert_none Finset.mem_insertNone lemma forall_mem_insertNone {s : Finset α} {p : Option α → Prop} : (∀ a ∈ insertNone s, p a) ↔ p none ∧ ∀ a ∈ s, p a := by simp [Option.forall] theorem some_mem_insertNone {s : Finset α} {a : α} : some a ∈ insertNone s ↔ a ∈ s := by simp #align finset.some_mem_insert_none Finset.some_mem_insertNone lemma none_mem_insertNone {s : Finset α} : none ∈ insertNone s := by simp @[aesop safe apply (rule_sets := [finsetNonempty])] lemma insertNone_nonempty {s : Finset α} : insertNone s |>.Nonempty := ⟨none, none_mem_insertNone⟩ @[simp] theorem card_insertNone (s : Finset α) : s.insertNone.card = s.card + 1 := by simp [insertNone] #align finset.card_insert_none Finset.card_insertNone /-- Given `s : Finset (Option α)`, `eraseNone s : Finset α` is the set of `x : α` such that `some x ∈ s`. -/ def eraseNone : Finset (Option α) →o Finset α := (Finset.mapEmbedding (Equiv.optionIsSomeEquiv α).toEmbedding).toOrderHom.comp ⟨Finset.subtype _, subtype_mono⟩ #align finset.erase_none Finset.eraseNone @[simp]
Mathlib/Data/Finset/Option.lean
98
99
theorem mem_eraseNone {s : Finset (Option α)} {x : α} : x ∈ eraseNone s ↔ some x ∈ s := by
simp [eraseNone]
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.ContDiff.Basic import Mathlib.Analysis.NormedSpace.FiniteDimension #align_import analysis.calculus.bump_function_inner from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Infinitely smooth "bump" functions A smooth bump function is an infinitely smooth function `f : E → ℝ` supported on a ball that is equal to `1` on a ball of smaller radius. These functions have many uses in real analysis. E.g., - they can be used to construct a smooth partition of unity which is a very useful tool; - they can be used to approximate a continuous function by infinitely smooth functions. There are two classes of spaces where bump functions are guaranteed to exist: inner product spaces and finite dimensional spaces. In this file we define a typeclass `HasContDiffBump` saying that a normed space has a family of smooth bump functions with certain properties. We also define a structure `ContDiffBump` that holds the center and radii of the balls from above. An element `f : ContDiffBump c` can be coerced to a function which is an infinitely smooth function such that - `f` is equal to `1` in `Metric.closedBall c f.rIn`; - `support f = Metric.ball c f.rOut`; - `0 ≤ f x ≤ 1` for all `x`. ## Main Definitions - `ContDiffBump (c : E)`: a structure holding data needed to construct an infinitely smooth bump function. - `ContDiffBumpBase (E : Type*)`: a family of infinitely smooth bump functions that can be used to construct coercion of a `ContDiffBump (c : E)` to a function. - `HasContDiffBump (E : Type*)`: a typeclass saying that `E` has a `ContDiffBumpBase`. Two instances of this typeclass (for inner product spaces and for finite dimensional spaces) are provided elsewhere. ## Keywords smooth function, smooth bump function -/ noncomputable section open Function Set Filter open scoped Topology Filter variable {E X : Type*} /-- `f : ContDiffBump c`, where `c` is a point in a normed vector space, is a bundled smooth function such that - `f` is equal to `1` in `Metric.closedBall c f.rIn`; - `support f = Metric.ball c f.rOut`; - `0 ≤ f x ≤ 1` for all `x`. The structure `ContDiffBump` contains the data required to construct the function: real numbers `rIn`, `rOut`, and proofs of `0 < rIn < rOut`. The function itself is available through `CoeFun` when the space is nice enough, i.e., satisfies the `HasContDiffBump` typeclass. -/ structure ContDiffBump (c : E) where /-- real numbers `0 < rIn < rOut` -/ (rIn rOut : ℝ) rIn_pos : 0 < rIn rIn_lt_rOut : rIn < rOut #align cont_diff_bump ContDiffBump #align cont_diff_bump.r ContDiffBump.rIn set_option linter.uppercaseLean3 false in #align cont_diff_bump.R ContDiffBump.rOut #align cont_diff_bump.r_pos ContDiffBump.rIn_pos set_option linter.uppercaseLean3 false in #align cont_diff_bump.r_lt_R ContDiffBump.rIn_lt_rOut /-- The base function from which one will construct a family of bump functions. One could add more properties if they are useful and satisfied in the examples of inner product spaces and finite dimensional vector spaces, notably derivative norm control in terms of `R - 1`. TODO: do we ever need `f x = 1 ↔ ‖x‖ ≤ 1`? -/ -- Porting note(#5171): linter not yet ported; was @[nolint has_nonempty_instance] structure ContDiffBumpBase (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] where /-- The function underlying this family of bump functions -/ toFun : ℝ → E → ℝ mem_Icc : ∀ (R : ℝ) (x : E), toFun R x ∈ Icc (0 : ℝ) 1 symmetric : ∀ (R : ℝ) (x : E), toFun R (-x) = toFun R x smooth : ContDiffOn ℝ ⊤ (uncurry toFun) (Ioi (1 : ℝ) ×ˢ (univ : Set E)) eq_one : ∀ R : ℝ, 1 < R → ∀ x : E, ‖x‖ ≤ 1 → toFun R x = 1 support : ∀ R : ℝ, 1 < R → Function.support (toFun R) = Metric.ball (0 : E) R #align cont_diff_bump_base ContDiffBumpBase /-- A class registering that a real vector space admits bump functions. This will be instantiated first for inner product spaces, and then for finite-dimensional normed spaces. We use a specific class instead of `Nonempty (ContDiffBumpBase E)` for performance reasons. -/ class HasContDiffBump (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] : Prop where out : Nonempty (ContDiffBumpBase E) #align has_cont_diff_bump HasContDiffBump /-- In a space with `C^∞` bump functions, register some function that will be used as a basis to construct bump functions of arbitrary size around any point. -/ def someContDiffBumpBase (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] [hb : HasContDiffBump E] : ContDiffBumpBase E := Nonempty.some hb.out #align some_cont_diff_bump_base someContDiffBumpBase namespace ContDiffBump theorem rOut_pos {c : E} (f : ContDiffBump c) : 0 < f.rOut := f.rIn_pos.trans f.rIn_lt_rOut set_option linter.uppercaseLean3 false in #align cont_diff_bump.R_pos ContDiffBump.rOut_pos
Mathlib/Analysis/Calculus/BumpFunction/Basic.lean
118
120
theorem one_lt_rOut_div_rIn {c : E} (f : ContDiffBump c) : 1 < f.rOut / f.rIn := by
rw [one_lt_div f.rIn_pos] exact f.rIn_lt_rOut
/- 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 import Mathlib.RingTheory.Ideal.Basic #align_import data.polynomial.induction from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0" /-! # Induction on polynomials This file contains lemmas dealing with different flavours of induction on polynomials. See also `Data/Polynomial/Inductions.lean` (with an `s`!). The main result is `Polynomial.induction_on`. -/ noncomputable section open Finsupp Finset namespace Polynomial open Polynomial universe u v w x y z variable {R : Type u} {S : Type v} {T : Type w} {ι : Type x} {k : Type y} {A : Type z} {a b : R} {m n : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} @[elab_as_elim] protected theorem induction_on {M : R[X] → Prop} (p : R[X]) (h_C : ∀ a, M (C a)) (h_add : ∀ p q, M p → M q → M (p + q)) (h_monomial : ∀ (n : ℕ) (a : R), M (C a * X ^ n) → M (C a * X ^ (n + 1))) : M p := by have A : ∀ {n : ℕ} {a}, M (C a * X ^ n) := by intro n a induction' n with n ih · rw [pow_zero, mul_one]; exact h_C a · exact h_monomial _ _ ih have B : ∀ s : Finset ℕ, M (s.sum fun n : ℕ => C (p.coeff n) * X ^ n) := by apply Finset.induction · convert h_C 0 exact C_0.symm · intro n s ns ih rw [sum_insert ns] exact h_add _ _ A ih rw [← sum_C_mul_X_pow_eq p, Polynomial.sum] exact B (support p) #align polynomial.induction_on Polynomial.induction_on /-- To prove something about polynomials, it suffices to show the condition is closed under taking sums, and it holds for monomials. -/ @[elab_as_elim] protected theorem induction_on' {M : R[X] → Prop} (p : R[X]) (h_add : ∀ p q, M p → M q → M (p + q)) (h_monomial : ∀ (n : ℕ) (a : R), M (monomial n a)) : M p := Polynomial.induction_on p (h_monomial 0) h_add fun n a _h => by rw [C_mul_X_pow_eq_monomial]; exact h_monomial _ _ #align polynomial.induction_on' Polynomial.induction_on' open Submodule Polynomial Set variable {f : R[X]} {I : Ideal R[X]} /-- If the coefficients of a polynomial belong to an ideal, then that ideal contains the ideal spanned by the coefficients of the polynomial. -/ theorem span_le_of_C_coeff_mem (cf : ∀ i : ℕ, C (f.coeff i) ∈ I) : Ideal.span { g | ∃ i, g = C (f.coeff i) } ≤ I := by simp only [@eq_comm _ _ (C _)] exact (Ideal.span_le.trans range_subset_iff).mpr cf set_option linter.uppercaseLean3 false in #align polynomial.span_le_of_C_coeff_mem Polynomial.span_le_of_C_coeff_mem
Mathlib/Algebra/Polynomial/Induction.lean
82
94
theorem mem_span_C_coeff : f ∈ Ideal.span { g : R[X] | ∃ i : ℕ, g = C (coeff f i) } := by
let p := Ideal.span { g : R[X] | ∃ i : ℕ, g = C (coeff f i) } nth_rw 1 [(sum_C_mul_X_pow_eq f).symm] refine Submodule.sum_mem _ fun n _hn => ?_ dsimp have : C (coeff f n) ∈ p := by apply subset_span rw [mem_setOf_eq] use n have : monomial n (1 : R) • C (coeff f n) ∈ p := p.smul_mem _ this convert this using 1 simp only [monomial_mul_C, one_mul, smul_eq_mul] rw [← C_mul_X_pow_eq_monomial]
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov -/ import Mathlib.MeasureTheory.Function.L1Space import Mathlib.Analysis.NormedSpace.IndicatorFunction #align_import measure_theory.integral.integrable_on from "leanprover-community/mathlib"@"8b8ba04e2f326f3f7cf24ad129beda58531ada61" /-! # Functions integrable on a set and at a filter We define `IntegrableOn f s μ := Integrable f (μ.restrict s)` and prove theorems like `integrableOn_union : IntegrableOn f (s ∪ t) μ ↔ IntegrableOn f s μ ∧ IntegrableOn f t μ`. Next we define a predicate `IntegrableAtFilter (f : α → E) (l : Filter α) (μ : Measure α)` saying that `f` is integrable at some set `s ∈ l` and prove that a measurable function is integrable at `l` with respect to `μ` provided that `f` is bounded above at `l ⊓ ae μ` and `μ` is finite at `l`. -/ noncomputable section open Set Filter TopologicalSpace MeasureTheory Function open scoped Classical Topology Interval Filter ENNReal MeasureTheory variable {α β E F : Type*} [MeasurableSpace α] section variable [TopologicalSpace β] {l l' : Filter α} {f g : α → β} {μ ν : Measure α} /-- A function `f` is strongly measurable at a filter `l` w.r.t. a measure `μ` if it is ae strongly measurable w.r.t. `μ.restrict s` for some `s ∈ l`. -/ def StronglyMeasurableAtFilter (f : α → β) (l : Filter α) (μ : Measure α := by volume_tac) := ∃ s ∈ l, AEStronglyMeasurable f (μ.restrict s) #align strongly_measurable_at_filter StronglyMeasurableAtFilter @[simp] theorem stronglyMeasurableAt_bot {f : α → β} : StronglyMeasurableAtFilter f ⊥ μ := ⟨∅, mem_bot, by simp⟩ #align strongly_measurable_at_bot stronglyMeasurableAt_bot protected theorem StronglyMeasurableAtFilter.eventually (h : StronglyMeasurableAtFilter f l μ) : ∀ᶠ s in l.smallSets, AEStronglyMeasurable f (μ.restrict s) := (eventually_smallSets' fun _ _ => AEStronglyMeasurable.mono_set).2 h #align strongly_measurable_at_filter.eventually StronglyMeasurableAtFilter.eventually protected theorem StronglyMeasurableAtFilter.filter_mono (h : StronglyMeasurableAtFilter f l μ) (h' : l' ≤ l) : StronglyMeasurableAtFilter f l' μ := let ⟨s, hsl, hs⟩ := h ⟨s, h' hsl, hs⟩ #align strongly_measurable_at_filter.filter_mono StronglyMeasurableAtFilter.filter_mono protected theorem MeasureTheory.AEStronglyMeasurable.stronglyMeasurableAtFilter (h : AEStronglyMeasurable f μ) : StronglyMeasurableAtFilter f l μ := ⟨univ, univ_mem, by rwa [Measure.restrict_univ]⟩ #align measure_theory.ae_strongly_measurable.strongly_measurable_at_filter MeasureTheory.AEStronglyMeasurable.stronglyMeasurableAtFilter theorem AeStronglyMeasurable.stronglyMeasurableAtFilter_of_mem {s} (h : AEStronglyMeasurable f (μ.restrict s)) (hl : s ∈ l) : StronglyMeasurableAtFilter f l μ := ⟨s, hl, h⟩ #align ae_strongly_measurable.strongly_measurable_at_filter_of_mem AeStronglyMeasurable.stronglyMeasurableAtFilter_of_mem protected theorem MeasureTheory.StronglyMeasurable.stronglyMeasurableAtFilter (h : StronglyMeasurable f) : StronglyMeasurableAtFilter f l μ := h.aestronglyMeasurable.stronglyMeasurableAtFilter #align measure_theory.strongly_measurable.strongly_measurable_at_filter MeasureTheory.StronglyMeasurable.stronglyMeasurableAtFilter end namespace MeasureTheory section NormedAddCommGroup theorem hasFiniteIntegral_restrict_of_bounded [NormedAddCommGroup E] {f : α → E} {s : Set α} {μ : Measure α} {C} (hs : μ s < ∞) (hf : ∀ᵐ x ∂μ.restrict s, ‖f x‖ ≤ C) : HasFiniteIntegral f (μ.restrict s) := haveI : IsFiniteMeasure (μ.restrict s) := ⟨by rwa [Measure.restrict_apply_univ]⟩ hasFiniteIntegral_of_bounded hf #align measure_theory.has_finite_integral_restrict_of_bounded MeasureTheory.hasFiniteIntegral_restrict_of_bounded variable [NormedAddCommGroup E] {f g : α → E} {s t : Set α} {μ ν : Measure α} /-- A function is `IntegrableOn` a set `s` if it is almost everywhere strongly measurable on `s` and if the integral of its pointwise norm over `s` is less than infinity. -/ def IntegrableOn (f : α → E) (s : Set α) (μ : Measure α := by volume_tac) : Prop := Integrable f (μ.restrict s) #align measure_theory.integrable_on MeasureTheory.IntegrableOn theorem IntegrableOn.integrable (h : IntegrableOn f s μ) : Integrable f (μ.restrict s) := h #align measure_theory.integrable_on.integrable MeasureTheory.IntegrableOn.integrable @[simp]
Mathlib/MeasureTheory/Integral/IntegrableOn.lean
99
99
theorem integrableOn_empty : IntegrableOn f ∅ μ := by
simp [IntegrableOn, integrable_zero_measure]
/- Copyright (c) 2024 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.Analysis.Normed.Field.Basic import Mathlib.RingTheory.Valuation.RankOne import Mathlib.Topology.Algebra.Valuation /-! # Correspondence between nontrivial nonarchimedean norms and rank one valuations Nontrivial nonarchimedean norms correspond to rank one valuations. ## Main Definitions * `NormedField.toValued` : the valued field structure on a nonarchimedean normed field `K`, determined by the norm. * `Valued.toNormedField` : the normed field structure determined by a rank one valuation. ## Tags norm, nonarchimedean, nontrivial, valuation, rank one -/ noncomputable section open Filter Set Valuation open scoped NNReal variable {K : Type*} [hK : NormedField K] (h : IsNonarchimedean (norm : K → ℝ)) namespace NormedField /-- The valuation on a nonarchimedean normed field `K` defined as `nnnorm`. -/ def valuation : Valuation K ℝ≥0 where toFun := nnnorm map_zero' := nnnorm_zero map_one' := nnnorm_one map_mul' := nnnorm_mul map_add_le_max' := h theorem valuation_apply (x : K) : valuation h x = ‖x‖₊ := rfl /-- The valued field structure on a nonarchimedean normed field `K`, determined by the norm. -/ def toValued : Valued K ℝ≥0 := { hK.toUniformSpace, @NonUnitalNormedRing.toNormedAddCommGroup K _ with v := valuation h is_topological_valuation := fun U => by rw [Metric.mem_nhds_iff] exact ⟨fun ⟨ε, hε, h⟩ => ⟨Units.mk0 ⟨ε, le_of_lt hε⟩ (ne_of_gt hε), fun x hx ↦ h (mem_ball_zero_iff.mpr hx)⟩, fun ⟨ε, hε⟩ => ⟨(ε : ℝ), NNReal.coe_pos.mpr (Units.zero_lt _), fun x hx ↦ hε (mem_ball_zero_iff.mp hx)⟩⟩ } end NormedField namespace Valued variable {L : Type*} [Field L] {Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] [val : Valued L Γ₀] [hv : RankOne val.v] /-- The norm function determined by a rank one valuation on a field `L`. -/ def norm : L → ℝ := fun x : L => hv.hom (Valued.v x) theorem norm_nonneg (x : L) : 0 ≤ norm x := by simp only [norm, NNReal.zero_le_coe]
Mathlib/Topology/Algebra/NormedValued.lean
70
72
theorem norm_add_le (x y : L) : norm (x + y) ≤ max (norm x) (norm y) := by
simp only [norm, NNReal.coe_le_coe, le_max_iff, StrictMono.le_iff_le hv.strictMono] exact le_max_iff.mp (Valuation.map_add_le_max' val.v _ _)
/- Copyright (c) 2022 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.MeasureTheory.Integral.Bochner import Mathlib.MeasureTheory.Group.Measure #align_import measure_theory.group.integration from "leanprover-community/mathlib"@"ec247d43814751ffceb33b758e8820df2372bf6f" /-! # Bochner Integration on Groups We develop properties of integrals with a group as domain. This file contains properties about integrability and Bochner integration. -/ namespace MeasureTheory open Measure TopologicalSpace open scoped ENNReal variable {𝕜 M α G E F : Type*} [MeasurableSpace G] variable [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [NormedAddCommGroup F] variable {μ : Measure G} {f : G → E} {g : G} section MeasurableInv variable [Group G] [MeasurableInv G] @[to_additive] theorem Integrable.comp_inv [IsInvInvariant μ] {f : G → F} (hf : Integrable f μ) : Integrable (fun t => f t⁻¹) μ := (hf.mono_measure (map_inv_eq_self μ).le).comp_measurable measurable_inv #align measure_theory.integrable.comp_inv MeasureTheory.Integrable.comp_inv #align measure_theory.integrable.comp_neg MeasureTheory.Integrable.comp_neg @[to_additive] theorem integral_inv_eq_self (f : G → E) (μ : Measure G) [IsInvInvariant μ] : ∫ x, f x⁻¹ ∂μ = ∫ x, f x ∂μ := by have h : MeasurableEmbedding fun x : G => x⁻¹ := (MeasurableEquiv.inv G).measurableEmbedding rw [← h.integral_map, map_inv_eq_self] #align measure_theory.integral_inv_eq_self MeasureTheory.integral_inv_eq_self #align measure_theory.integral_neg_eq_self MeasureTheory.integral_neg_eq_self end MeasurableInv section MeasurableMul variable [Group G] [MeasurableMul G] /-- Translating a function by left-multiplication does not change its integral with respect to a left-invariant measure. -/ @[to_additive "Translating a function by left-addition does not change its integral with respect to a left-invariant measure."] -- Porting note: was `@[simp]` theorem integral_mul_left_eq_self [IsMulLeftInvariant μ] (f : G → E) (g : G) : (∫ x, f (g * x) ∂μ) = ∫ x, f x ∂μ := by have h_mul : MeasurableEmbedding fun x => g * x := (MeasurableEquiv.mulLeft g).measurableEmbedding rw [← h_mul.integral_map, map_mul_left_eq_self] #align measure_theory.integral_mul_left_eq_self MeasureTheory.integral_mul_left_eq_self #align measure_theory.integral_add_left_eq_self MeasureTheory.integral_add_left_eq_self /-- Translating a function by right-multiplication does not change its integral with respect to a right-invariant measure. -/ @[to_additive "Translating a function by right-addition does not change its integral with respect to a right-invariant measure."] -- Porting note: was `@[simp]`
Mathlib/MeasureTheory/Group/Integral.lean
70
74
theorem integral_mul_right_eq_self [IsMulRightInvariant μ] (f : G → E) (g : G) : (∫ x, f (x * g) ∂μ) = ∫ x, f x ∂μ := by
have h_mul : MeasurableEmbedding fun x => x * g := (MeasurableEquiv.mulRight g).measurableEmbedding rw [← h_mul.integral_map, map_mul_right_eq_self]
/- Copyright (c) 2022 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey, Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne -/ import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Data.Int.Log #align_import analysis.special_functions.log.base from "leanprover-community/mathlib"@"f23a09ce6d3f367220dc3cecad6b7eb69eb01690" /-! # Real logarithm base `b` In this file we define `Real.logb` to be the logarithm of a real number in a given base `b`. We define this as the division of the natural logarithms of the argument and the base, so that we have a globally defined function with `logb b 0 = 0`, `logb b (-x) = logb b x` `logb 0 x = 0` and `logb (-b) x = logb b x`. We prove some basic properties of this function and its relation to `rpow`. ## Tags logarithm, continuity -/ open Set Filter Function open Topology noncomputable section namespace Real variable {b x y : ℝ} /-- The real logarithm in a given base. As with the natural logarithm, we define `logb b x` to be `logb b |x|` for `x < 0`, and `0` for `x = 0`. -/ -- @[pp_nodot] -- Porting note: removed noncomputable def logb (b x : ℝ) : ℝ := log x / log b #align real.logb Real.logb theorem log_div_log : log x / log b = logb b x := rfl #align real.log_div_log Real.log_div_log @[simp] theorem logb_zero : logb b 0 = 0 := by simp [logb] #align real.logb_zero Real.logb_zero @[simp] theorem logb_one : logb b 1 = 0 := by simp [logb] #align real.logb_one Real.logb_one @[simp] lemma logb_self_eq_one (hb : 1 < b) : logb b b = 1 := div_self (log_pos hb).ne' lemma logb_self_eq_one_iff : logb b b = 1 ↔ b ≠ 0 ∧ b ≠ 1 ∧ b ≠ -1 := Iff.trans ⟨fun h h' => by simp [logb, h'] at h, div_self⟩ log_ne_zero @[simp] theorem logb_abs (x : ℝ) : logb b |x| = logb b x := by rw [logb, logb, log_abs] #align real.logb_abs Real.logb_abs @[simp] theorem logb_neg_eq_logb (x : ℝ) : logb b (-x) = logb b x := by rw [← logb_abs x, ← logb_abs (-x), abs_neg] #align real.logb_neg_eq_logb Real.logb_neg_eq_logb theorem logb_mul (hx : x ≠ 0) (hy : y ≠ 0) : logb b (x * y) = logb b x + logb b y := by simp_rw [logb, log_mul hx hy, add_div] #align real.logb_mul Real.logb_mul theorem logb_div (hx : x ≠ 0) (hy : y ≠ 0) : logb b (x / y) = logb b x - logb b y := by simp_rw [logb, log_div hx hy, sub_div] #align real.logb_div Real.logb_div @[simp] theorem logb_inv (x : ℝ) : logb b x⁻¹ = -logb b x := by simp [logb, neg_div] #align real.logb_inv Real.logb_inv theorem inv_logb (a b : ℝ) : (logb a b)⁻¹ = logb b a := by simp_rw [logb, inv_div] #align real.inv_logb Real.inv_logb theorem inv_logb_mul_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) : (logb (a * b) c)⁻¹ = (logb a c)⁻¹ + (logb b c)⁻¹ := by simp_rw [inv_logb]; exact logb_mul h₁ h₂ #align real.inv_logb_mul_base Real.inv_logb_mul_base theorem inv_logb_div_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) : (logb (a / b) c)⁻¹ = (logb a c)⁻¹ - (logb b c)⁻¹ := by simp_rw [inv_logb]; exact logb_div h₁ h₂ #align real.inv_logb_div_base Real.inv_logb_div_base theorem logb_mul_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) : logb (a * b) c = ((logb a c)⁻¹ + (logb b c)⁻¹)⁻¹ := by rw [← inv_logb_mul_base h₁ h₂ c, inv_inv] #align real.logb_mul_base Real.logb_mul_base
Mathlib/Analysis/SpecialFunctions/Log/Base.lean
101
102
theorem logb_div_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) : logb (a / b) c = ((logb a c)⁻¹ - (logb b c)⁻¹)⁻¹ := by
rw [← inv_logb_div_base h₁ h₂ c, inv_inv]
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.Fintype.List #align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49" /-! # Cycles of a list Lists have an equivalence relation of whether they are rotational permutations of one another. This relation is defined as `IsRotated`. Based on this, we define the quotient of lists by the rotation relation, called `Cycle`. We also define a representation of concrete cycles, available when viewing them in a goal state or via `#eval`, when over representable types. For example, the cycle `(2 1 4 3)` will be shown as `c[2, 1, 4, 3]`. Two equal cycles may be printed differently if their internal representation is different. -/ assert_not_exists MonoidWithZero namespace List variable {α : Type*} [DecidableEq α] /-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/ def nextOr : ∀ (_ : List α) (_ _ : α), α | [], _, default => default | [_], _, default => default -- Handles the not-found and the wraparound case | y :: z :: xs, x, default => if x = y then z else nextOr (z :: xs) x default #align list.next_or List.nextOr @[simp] theorem nextOr_nil (x d : α) : nextOr [] x d = d := rfl #align list.next_or_nil List.nextOr_nil @[simp] theorem nextOr_singleton (x y d : α) : nextOr [y] x d = d := rfl #align list.next_or_singleton List.nextOr_singleton @[simp] theorem nextOr_self_cons_cons (xs : List α) (x y d : α) : nextOr (x :: y :: xs) x d = y := if_pos rfl #align list.next_or_self_cons_cons List.nextOr_self_cons_cons theorem nextOr_cons_of_ne (xs : List α) (y x d : α) (h : x ≠ y) : nextOr (y :: xs) x d = nextOr xs x d := by cases' xs with z zs · rfl · exact if_neg h #align list.next_or_cons_of_ne List.nextOr_cons_of_ne /-- `nextOr` does not depend on the default value, if the next value appears. -/
Mathlib/Data/List/Cycle.lean
62
73
theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x ∈ xs) (x_ne : x ≠ xs.getLast (ne_nil_of_mem x_mem)) : nextOr xs x d = nextOr xs x d' := by
induction' xs with y ys IH · cases x_mem cases' ys with z zs · simp at x_mem x_ne contradiction by_cases h : x = y · rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons] · rw [nextOr, nextOr, IH] · simpa [h] using x_mem · simpa using x_ne
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Sébastien Gouëzel -/ import Mathlib.Analysis.Calculus.FDeriv.Equiv import Mathlib.Analysis.Calculus.InverseFunctionTheorem.ApproximatesLinearOn #align_import analysis.calculus.inverse from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Inverse function theorem In this file we prove the inverse function theorem. It says that if a map `f : E → F` has an invertible strict derivative `f'` at `a`, then it is locally invertible, and the inverse function has derivative `f' ⁻¹`. We define `HasStrictFDerivAt.toPartialHomeomorph` that repacks a function `f` with a `hf : HasStrictFDerivAt f f' a`, `f' : E ≃L[𝕜] F`, into a `PartialHomeomorph`. The `toFun` of this `PartialHomeomorph` is defeq to `f`, so one can apply theorems about `PartialHomeomorph` to `hf.toPartialHomeomorph f`, and get statements about `f`. Then we define `HasStrictFDerivAt.localInverse` to be the `invFun` of this `PartialHomeomorph`, and prove two versions of the inverse function theorem: * `HasStrictFDerivAt.to_localInverse`: if `f` has an invertible derivative `f'` at `a` in the strict sense (`hf`), then `hf.localInverse f f' a` has derivative `f'.symm` at `f a` in the strict sense; * `HasStrictFDerivAt.to_local_left_inverse`: if `f` has an invertible derivative `f'` at `a` in the strict sense and `g` is locally left inverse to `f` near `a`, then `g` has derivative `f'.symm` at `f a` in the strict sense. Some related theorems, providing the derivative and higher regularity assuming that we already know the inverse function, are formulated in the `Analysis/Calculus/FDeriv` and `Analysis/Calculus/Deriv` folders, and in `ContDiff.lean`. ## Tags derivative, strictly differentiable, continuously differentiable, smooth, inverse function -/ open Function Set Filter Metric open scoped Topology Classical NNReal noncomputable section variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] variable {ε : ℝ} open Asymptotics Filter Metric Set open ContinuousLinearMap (id) /-! ### Inverse function theorem Let `f : E → F` be a map defined on a complete vector space `E`. Assume that `f` has an invertible derivative `f' : E ≃L[𝕜] F` at `a : E` in the strict sense. Then `f` approximates `f'` in the sense of `ApproximatesLinearOn` on an open neighborhood of `a`, and we can apply `ApproximatesLinearOn.toPartialHomeomorph` to construct the inverse function. -/ namespace HasStrictFDerivAt /-- If `f` has derivative `f'` at `a` in the strict sense and `c > 0`, then `f` approximates `f'` with constant `c` on some neighborhood of `a`. -/ theorem approximates_deriv_on_nhds {f : E → F} {f' : E →L[𝕜] F} {a : E} (hf : HasStrictFDerivAt f f' a) {c : ℝ≥0} (hc : Subsingleton E ∨ 0 < c) : ∃ s ∈ 𝓝 a, ApproximatesLinearOn f f' s c := by cases' hc with hE hc · refine ⟨univ, IsOpen.mem_nhds isOpen_univ trivial, fun x _ y _ => ?_⟩ simp [@Subsingleton.elim E hE x y] have := hf.def hc rw [nhds_prod_eq, Filter.Eventually, mem_prod_same_iff] at this rcases this with ⟨s, has, hs⟩ exact ⟨s, has, fun x hx y hy => hs (mk_mem_prod hx hy)⟩ #align has_strict_fderiv_at.approximates_deriv_on_nhds HasStrictFDerivAt.approximates_deriv_on_nhds theorem map_nhds_eq_of_surj [CompleteSpace E] [CompleteSpace F] {f : E → F} {f' : E →L[𝕜] F} {a : E} (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) (h : LinearMap.range f' = ⊤) : map f (𝓝 a) = 𝓝 (f a) := by let f'symm := f'.nonlinearRightInverseOfSurjective h set c : ℝ≥0 := f'symm.nnnorm⁻¹ / 2 with hc have f'symm_pos : 0 < f'symm.nnnorm := f'.nonlinearRightInverseOfSurjective_nnnorm_pos h have cpos : 0 < c := by simp [hc, half_pos, inv_pos, f'symm_pos] obtain ⟨s, s_nhds, hs⟩ : ∃ s ∈ 𝓝 a, ApproximatesLinearOn f f' s c := hf.approximates_deriv_on_nhds (Or.inr cpos) apply hs.map_nhds_eq f'symm s_nhds (Or.inr (NNReal.half_lt_self _)) simp [ne_of_gt f'symm_pos] #align has_strict_fderiv_at.map_nhds_eq_of_surj HasStrictFDerivAt.map_nhds_eq_of_surj variable [CompleteSpace E] {f : E → F} {f' : E ≃L[𝕜] F} {a : E}
Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean
101
108
theorem approximates_deriv_on_open_nhds (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) : ∃ s : Set E, a ∈ s ∧ IsOpen s ∧ ApproximatesLinearOn f (f' : E →L[𝕜] F) s (‖(f'.symm : F →L[𝕜] E)‖₊⁻¹ / 2) := by
simp only [← and_assoc] refine ((nhds_basis_opens a).exists_iff fun s t => ApproximatesLinearOn.mono_set).1 ?_ exact hf.approximates_deriv_on_nhds <| f'.subsingleton_or_nnnorm_symm_pos.imp id fun hf' => half_pos <| inv_pos.2 hf'
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Ring.Invertible import Mathlib.Data.Nat.Cast.Order #align_import algebra.order.invertible from "leanprover-community/mathlib"@"ee0c179cd3c8a45aa5bffbf1b41d8dbede452865" /-! # Lemmas about `invOf` in ordered (semi)rings. -/ variable {α : Type*} [LinearOrderedSemiring α] {a : α} @[simp] theorem invOf_pos [Invertible a] : 0 < ⅟ a ↔ 0 < a := haveI : 0 < a * ⅟ a := by simp only [mul_invOf_self, zero_lt_one] ⟨fun h => pos_of_mul_pos_left this h.le, fun h => pos_of_mul_pos_right this h.le⟩ #align inv_of_pos invOf_pos @[simp] theorem invOf_nonpos [Invertible a] : ⅟ a ≤ 0 ↔ a ≤ 0 := by simp only [← not_lt, invOf_pos] #align inv_of_nonpos invOf_nonpos @[simp]
Mathlib/Algebra/Order/Invertible.lean
29
31
theorem invOf_nonneg [Invertible a] : 0 ≤ ⅟ a ↔ 0 ≤ a := haveI : 0 < a * ⅟ a := by
simp only [mul_invOf_self, zero_lt_one] ⟨fun h => (pos_of_mul_pos_left this h).le, fun h => (pos_of_mul_pos_right this h).le⟩
/- Copyright (c) 2023 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.CartanSubalgebra import Mathlib.Algebra.Lie.Weights.Basic /-! # Weights and roots of Lie modules and Lie algebras with respect to Cartan subalgebras Given a Lie algebra `L` which is not necessarily nilpotent, it may be useful to study its representations by restricting them to a nilpotent subalgebra (e.g., a Cartan subalgebra). In the particular case when we view `L` as a module over itself via the adjoint action, the weight spaces of `L` restricted to a nilpotent subalgebra are known as root spaces. Basic definitions and properties of the above ideas are provided in this file. ## Main definitions * `LieAlgebra.rootSpace` * `LieAlgebra.corootSpace` * `LieAlgebra.rootSpaceWeightSpaceProduct` * `LieAlgebra.rootSpaceProduct` * `LieAlgebra.zeroRootSubalgebra_eq_iff_is_cartan` -/ suppress_compilation open Set variable {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] (H : LieSubalgebra R L) [LieAlgebra.IsNilpotent R H] {M : Type*} [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieAlgebra open scoped TensorProduct open TensorProduct.LieModule LieModule /-- Given a nilpotent Lie subalgebra `H ⊆ L`, the root space of a map `χ : H → R` is the weight space of `L` regarded as a module of `H` via the adjoint action. -/ abbrev rootSpace (χ : H → R) : LieSubmodule R H L := weightSpace L χ #align lie_algebra.root_space LieAlgebra.rootSpace theorem zero_rootSpace_eq_top_of_nilpotent [IsNilpotent R L] : rootSpace (⊤ : LieSubalgebra R L) 0 = ⊤ := zero_weightSpace_eq_top_of_nilpotent L #align lie_algebra.zero_root_space_eq_top_of_nilpotent LieAlgebra.zero_rootSpace_eq_top_of_nilpotent @[simp] theorem rootSpace_comap_eq_weightSpace (χ : H → R) : (rootSpace H χ).comap H.incl' = weightSpace H χ := comap_weightSpace_eq_of_injective Subtype.coe_injective #align lie_algebra.root_space_comap_eq_weight_space LieAlgebra.rootSpace_comap_eq_weightSpace variable {H}
Mathlib/Algebra/Lie/Weights/Cartan.lean
61
69
theorem lie_mem_weightSpace_of_mem_weightSpace {χ₁ χ₂ : H → R} {x : L} {m : M} (hx : x ∈ rootSpace H χ₁) (hm : m ∈ weightSpace M χ₂) : ⁅x, m⁆ ∈ weightSpace M (χ₁ + χ₂) := by
rw [weightSpace, LieSubmodule.mem_iInf] intro y replace hx : x ∈ weightSpaceOf L (χ₁ y) y := by rw [rootSpace, weightSpace, LieSubmodule.mem_iInf] at hx; exact hx y replace hm : m ∈ weightSpaceOf M (χ₂ y) y := by rw [weightSpace, LieSubmodule.mem_iInf] at hm; exact hm y exact lie_mem_maxGenEigenspace_toEnd hx hm
/- 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.GCDMonoid.Finset import Mathlib.Algebra.Polynomial.CancelLeads import Mathlib.Algebra.Polynomial.EraseLead import Mathlib.Algebra.Polynomial.FieldDivision #align_import ring_theory.polynomial.content from "leanprover-community/mathlib"@"7a030ab8eb5d99f05a891dccc49c5b5b90c947d3" /-! # GCD structures on polynomials Definitions and basic results about polynomials over GCD domains, particularly their contents and primitive polynomials. ## Main Definitions Let `p : R[X]`. - `p.content` is the `gcd` of the coefficients of `p`. - `p.IsPrimitive` indicates that `p.content = 1`. ## Main Results - `Polynomial.content_mul`: If `p q : R[X]`, then `(p * q).content = p.content * q.content`. - `Polynomial.NormalizedGcdMonoid`: The polynomial ring of a GCD domain is itself a GCD domain. -/ namespace Polynomial open Polynomial section Primitive variable {R : Type*} [CommSemiring R] /-- A polynomial is primitive when the only constant polynomials dividing it are units -/ def IsPrimitive (p : R[X]) : Prop := ∀ r : R, C r ∣ p → IsUnit r #align polynomial.is_primitive Polynomial.IsPrimitive theorem isPrimitive_iff_isUnit_of_C_dvd {p : R[X]} : p.IsPrimitive ↔ ∀ r : R, C r ∣ p → IsUnit r := Iff.rfl set_option linter.uppercaseLean3 false in #align polynomial.is_primitive_iff_is_unit_of_C_dvd Polynomial.isPrimitive_iff_isUnit_of_C_dvd @[simp] theorem isPrimitive_one : IsPrimitive (1 : R[X]) := fun _ h => isUnit_C.mp (isUnit_of_dvd_one h) #align polynomial.is_primitive_one Polynomial.isPrimitive_one theorem Monic.isPrimitive {p : R[X]} (hp : p.Monic) : p.IsPrimitive := by rintro r ⟨q, h⟩ exact isUnit_of_mul_eq_one r (q.coeff p.natDegree) (by rwa [← coeff_C_mul, ← h]) #align polynomial.monic.is_primitive Polynomial.Monic.isPrimitive theorem IsPrimitive.ne_zero [Nontrivial R] {p : R[X]} (hp : p.IsPrimitive) : p ≠ 0 := by rintro rfl exact (hp 0 (dvd_zero (C 0))).ne_zero rfl #align polynomial.is_primitive.ne_zero Polynomial.IsPrimitive.ne_zero theorem isPrimitive_of_dvd {p q : R[X]} (hp : IsPrimitive p) (hq : q ∣ p) : IsPrimitive q := fun a ha => isPrimitive_iff_isUnit_of_C_dvd.mp hp a (dvd_trans ha hq) #align polynomial.is_primitive_of_dvd Polynomial.isPrimitive_of_dvd end Primitive variable {R : Type*} [CommRing R] [IsDomain R] section NormalizedGCDMonoid variable [NormalizedGCDMonoid R] /-- `p.content` is the `gcd` of the coefficients of `p`. -/ def content (p : R[X]) : R := p.support.gcd p.coeff #align polynomial.content Polynomial.content theorem content_dvd_coeff {p : R[X]} (n : ℕ) : p.content ∣ p.coeff n := by by_cases h : n ∈ p.support · apply Finset.gcd_dvd h rw [mem_support_iff, Classical.not_not] at h rw [h] apply dvd_zero #align polynomial.content_dvd_coeff Polynomial.content_dvd_coeff @[simp] theorem content_C {r : R} : (C r).content = normalize r := by rw [content] by_cases h0 : r = 0 · simp [h0] have h : (C r).support = {0} := support_monomial _ h0 simp [h] set_option linter.uppercaseLean3 false in #align polynomial.content_C Polynomial.content_C @[simp] theorem content_zero : content (0 : R[X]) = 0 := by rw [← C_0, content_C, normalize_zero] #align polynomial.content_zero Polynomial.content_zero @[simp] theorem content_one : content (1 : R[X]) = 1 := by rw [← C_1, content_C, normalize_one] #align polynomial.content_one Polynomial.content_one theorem content_X_mul {p : R[X]} : content (X * p) = content p := by rw [content, content, Finset.gcd_def, Finset.gcd_def] refine congr rfl ?_ have h : (X * p).support = p.support.map ⟨Nat.succ, Nat.succ_injective⟩ := by ext a simp only [exists_prop, Finset.mem_map, Function.Embedding.coeFn_mk, Ne, mem_support_iff] cases' a with a · simp [coeff_X_mul_zero, Nat.succ_ne_zero] rw [mul_comm, coeff_mul_X] constructor · intro h use a · rintro ⟨b, ⟨h1, h2⟩⟩ rw [← Nat.succ_injective h2] apply h1 rw [h] simp only [Finset.map_val, Function.comp_apply, Function.Embedding.coeFn_mk, Multiset.map_map] refine congr (congr rfl ?_) rfl ext a rw [mul_comm] simp [coeff_mul_X] set_option linter.uppercaseLean3 false in #align polynomial.content_X_mul Polynomial.content_X_mul @[simp] theorem content_X_pow {k : ℕ} : content ((X : R[X]) ^ k) = 1 := by induction' k with k hi · simp rw [pow_succ', content_X_mul, hi] set_option linter.uppercaseLean3 false in #align polynomial.content_X_pow Polynomial.content_X_pow @[simp] theorem content_X : content (X : R[X]) = 1 := by rw [← mul_one X, content_X_mul, content_one] set_option linter.uppercaseLean3 false in #align polynomial.content_X Polynomial.content_X
Mathlib/RingTheory/Polynomial/Content.lean
146
149
theorem content_C_mul (r : R) (p : R[X]) : (C r * p).content = normalize r * p.content := by
by_cases h0 : r = 0; · simp [h0] rw [content]; rw [content]; rw [← Finset.gcd_mul_left] refine congr (congr rfl ?_) ?_ <;> ext <;> simp [h0, mem_support_iff]
/- Copyright (c) 2021 Patrick Stevens. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Stevens, Thomas Browning -/ import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" /-! # Central binomial coefficients This file proves properties of the central binomial coefficients (that is, `Nat.choose (2 * n) n`). ## Main definition and results * `Nat.centralBinom`: the central binomial coefficient, `(2 * n).choose n`. * `Nat.succ_mul_centralBinom_succ`: the inductive relationship between successive central binomial coefficients. * `Nat.four_pow_lt_mul_centralBinom`: an exponential lower bound on the central binomial coefficient. * `succ_dvd_centralBinom`: The result that `n+1 ∣ n.centralBinom`, ensuring that the explicit definition of the Catalan numbers is integer-valued. -/ namespace Nat /-- The central binomial coefficient, `Nat.choose (2 * n) n`. -/ def centralBinom (n : ℕ) := (2 * n).choose n #align nat.central_binom Nat.centralBinom theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n := rfl #align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n := choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two) #align nat.central_binom_pos Nat.centralBinom_pos theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 := (centralBinom_pos n).ne' #align nat.central_binom_ne_zero Nat.centralBinom_ne_zero @[simp] theorem centralBinom_zero : centralBinom 0 = 1 := choose_zero_right _ #align nat.central_binom_zero Nat.centralBinom_zero /-- The central binomial coefficient is the largest binomial coefficient. -/ theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n := calc (2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n) _ = (2 * n).choose n := by rw [Nat.mul_div_cancel_left n zero_lt_two] #align nat.choose_le_central_binom Nat.choose_le_centralBinom theorem two_le_centralBinom (n : ℕ) (n_pos : 0 < n) : 2 ≤ centralBinom n := calc 2 ≤ 2 * n := Nat.le_mul_of_pos_right _ n_pos _ = (2 * n).choose 1 := (choose_one_right (2 * n)).symm _ ≤ centralBinom n := choose_le_centralBinom 1 n #align nat.two_le_central_binom Nat.two_le_centralBinom /-- An inductive property of the central binomial coefficient. -/ theorem succ_mul_centralBinom_succ (n : ℕ) : (n + 1) * centralBinom (n + 1) = 2 * (2 * n + 1) * centralBinom n := calc (n + 1) * (2 * (n + 1)).choose (n + 1) = (2 * n + 2).choose (n + 1) * (n + 1) := mul_comm _ _ _ = (2 * n + 1).choose n * (2 * n + 2) := by rw [choose_succ_right_eq, choose_mul_succ_eq] _ = 2 * ((2 * n + 1).choose n * (n + 1)) := by ring _ = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n)) := by rw [two_mul n, add_assoc, Nat.add_sub_cancel_left] _ = 2 * ((2 * n).choose n * (2 * n + 1)) := by rw [choose_mul_succ_eq] _ = 2 * (2 * n + 1) * (2 * n).choose n := by rw [mul_assoc, mul_comm (2 * n + 1)] #align nat.succ_mul_central_binom_succ Nat.succ_mul_centralBinom_succ /-- An exponential lower bound on the central binomial coefficient. This bound is of interest because it appears in [Tochiori's refinement of Erdős's proof of Bertrand's postulate](tochiori_bertrand). -/
Mathlib/Data/Nat/Choose/Central.lean
88
98
theorem four_pow_lt_mul_centralBinom (n : ℕ) (n_big : 4 ≤ n) : 4 ^ n < n * centralBinom n := by
induction' n using Nat.strong_induction_on with n IH rcases lt_trichotomy n 4 with (hn | rfl | hn) · clear IH; exact False.elim ((not_lt.2 n_big) hn) · norm_num [centralBinom, choose] obtain ⟨n, rfl⟩ : ∃ m, n = m + 1 := Nat.exists_eq_succ_of_ne_zero (Nat.not_eq_zero_of_lt hn) calc 4 ^ (n + 1) < 4 * (n * centralBinom n) := lt_of_eq_of_lt pow_succ' <| (mul_lt_mul_left <| zero_lt_four' ℕ).mpr (IH n n.lt_succ_self (Nat.le_of_lt_succ hn)) _ ≤ 2 * (2 * n + 1) * centralBinom n := by rw [← mul_assoc]; linarith _ = (n + 1) * centralBinom (n + 1) := (succ_mul_centralBinom_succ n).symm
/- 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.Polynomial.Taylor import Mathlib.FieldTheory.RatFunc.AsPolynomial #align_import field_theory.laurent from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Laurent expansions of rational functions ## Main declarations * `RatFunc.laurent`: the Laurent expansion of the rational function `f` at `r`, as an `AlgHom`. * `RatFunc.laurent_injective`: the Laurent expansion at `r` is unique ## Implementation details Implemented as the quotient of two Taylor expansions, over domains. An auxiliary definition is provided first to make the construction of the `AlgHom` easier, which works on `CommRing` which are not necessarily domains. -/ universe u namespace RatFunc noncomputable section open Polynomial open scoped Classical nonZeroDivisors Polynomial variable {R : Type u} [CommRing R] [hdomain : IsDomain R] (r s : R) (p q : R[X]) (f : RatFunc R) theorem taylor_mem_nonZeroDivisors (hp : p ∈ R[X]⁰) : taylor r p ∈ R[X]⁰ := by rw [mem_nonZeroDivisors_iff] intro x hx have : x = taylor (r - r) x := by simp rwa [this, sub_eq_add_neg, ← taylor_taylor, ← taylor_mul, LinearMap.map_eq_zero_iff _ (taylor_injective _), mul_right_mem_nonZeroDivisors_eq_zero_iff hp, LinearMap.map_eq_zero_iff _ (taylor_injective _)] at hx #align ratfunc.taylor_mem_non_zero_divisors RatFunc.taylor_mem_nonZeroDivisors /-- The Laurent expansion of rational functions about a value. Auxiliary definition, usage when over integral domains should prefer `RatFunc.laurent`. -/ def laurentAux : RatFunc R →+* RatFunc R := RatFunc.mapRingHom ( { toFun := taylor r map_add' := map_add (taylor r) map_mul' := taylor_mul _ map_zero' := map_zero (taylor r) map_one' := taylor_one r } : R[X] →+* R[X]) (taylor_mem_nonZeroDivisors _) #align ratfunc.laurent_aux RatFunc.laurentAux theorem laurentAux_ofFractionRing_mk (q : R[X]⁰) : laurentAux r (ofFractionRing (Localization.mk p q)) = ofFractionRing (.mk (taylor r p) ⟨taylor r q, taylor_mem_nonZeroDivisors r q q.prop⟩) := map_apply_ofFractionRing_mk _ _ _ _ #align ratfunc.laurent_aux_of_fraction_ring_mk RatFunc.laurentAux_ofFractionRing_mk theorem laurentAux_div : laurentAux r (algebraMap _ _ p / algebraMap _ _ q) = algebraMap _ _ (taylor r p) / algebraMap _ _ (taylor r q) := -- Porting note: added `by exact taylor_mem_nonZeroDivisors r` map_apply_div _ (by exact taylor_mem_nonZeroDivisors r) _ _ #align ratfunc.laurent_aux_div RatFunc.laurentAux_div @[simp] theorem laurentAux_algebraMap : laurentAux r (algebraMap _ _ p) = algebraMap _ _ (taylor r p) := by rw [← mk_one, ← mk_one, mk_eq_div, laurentAux_div, mk_eq_div, taylor_one, map_one, map_one] #align ratfunc.laurent_aux_algebra_map RatFunc.laurentAux_algebraMap /-- The Laurent expansion of rational functions about a value. -/ def laurent : RatFunc R →ₐ[R] RatFunc R := RatFunc.mapAlgHom (.ofLinearMap (taylor r) (taylor_one _) (taylor_mul _)) (taylor_mem_nonZeroDivisors _) #align ratfunc.laurent RatFunc.laurent theorem laurent_div : laurent r (algebraMap _ _ p / algebraMap _ _ q) = algebraMap _ _ (taylor r p) / algebraMap _ _ (taylor r q) := laurentAux_div r p q #align ratfunc.laurent_div RatFunc.laurent_div @[simp] theorem laurent_algebraMap : laurent r (algebraMap _ _ p) = algebraMap _ _ (taylor r p) := laurentAux_algebraMap _ _ #align ratfunc.laurent_algebra_map RatFunc.laurent_algebraMap @[simp] theorem laurent_X : laurent r X = X + C r := by rw [← algebraMap_X, laurent_algebraMap, taylor_X, _root_.map_add, algebraMap_C] set_option linter.uppercaseLean3 false in #align ratfunc.laurent_X RatFunc.laurent_X @[simp] theorem laurent_C (x : R) : laurent r (C x) = C x := by rw [← algebraMap_C, laurent_algebraMap, taylor_C] set_option linter.uppercaseLean3 false in #align ratfunc.laurent_C RatFunc.laurent_C @[simp]
Mathlib/FieldTheory/Laurent.lean
108
108
theorem laurent_at_zero : laurent 0 f = f := by
induction f using RatFunc.induction_on; simp
/- Copyright (c) 2020 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Alexey Soloyev, Junyan Xu, Kamila Szewczyk -/ import Mathlib.Data.Real.Irrational import Mathlib.Data.Nat.Fib.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Algebra.LinearRecurrence import Mathlib.Tactic.NormNum.NatFib import Mathlib.Tactic.NormNum.Prime #align_import data.real.golden_ratio from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # The golden ratio and its conjugate This file defines the golden ratio `φ := (1 + √5)/2` and its conjugate `ψ := (1 - √5)/2`, which are the two real roots of `X² - X - 1`. Along with various computational facts about them, we prove their irrationality, and we link them to the Fibonacci sequence by proving Binet's formula. -/ noncomputable section open Polynomial /-- The golden ratio `φ := (1 + √5)/2`. -/ abbrev goldenRatio : ℝ := (1 + √5) / 2 #align golden_ratio goldenRatio /-- The conjugate of the golden ratio `ψ := (1 - √5)/2`. -/ abbrev goldenConj : ℝ := (1 - √5) / 2 #align golden_conj goldenConj @[inherit_doc goldenRatio] scoped[goldenRatio] notation "φ" => goldenRatio @[inherit_doc goldenConj] scoped[goldenRatio] notation "ψ" => goldenConj open Real goldenRatio /-- The inverse of the golden ratio is the opposite of its conjugate. -/ theorem inv_gold : φ⁻¹ = -ψ := by have : 1 + √5 ≠ 0 := ne_of_gt (add_pos (by norm_num) <| Real.sqrt_pos.mpr (by norm_num)) field_simp [sub_mul, mul_add] norm_num #align inv_gold inv_gold /-- The opposite of the golden ratio is the inverse of its conjugate. -/ theorem inv_goldConj : ψ⁻¹ = -φ := by rw [inv_eq_iff_eq_inv, ← neg_inv, ← neg_eq_iff_eq_neg] exact inv_gold.symm #align inv_gold_conj inv_goldConj @[simp] theorem gold_mul_goldConj : φ * ψ = -1 := by field_simp rw [← sq_sub_sq] norm_num #align gold_mul_gold_conj gold_mul_goldConj @[simp] theorem goldConj_mul_gold : ψ * φ = -1 := by rw [mul_comm] exact gold_mul_goldConj #align gold_conj_mul_gold goldConj_mul_gold @[simp] theorem gold_add_goldConj : φ + ψ = 1 := by rw [goldenRatio, goldenConj] ring #align gold_add_gold_conj gold_add_goldConj theorem one_sub_goldConj : 1 - φ = ψ := by linarith [gold_add_goldConj] #align one_sub_gold_conj one_sub_goldConj theorem one_sub_gold : 1 - ψ = φ := by linarith [gold_add_goldConj] #align one_sub_gold one_sub_gold @[simp]
Mathlib/Data/Real/GoldenRatio.lean
84
84
theorem gold_sub_goldConj : φ - ψ = √5 := by
ring
/- Copyright (c) 2021 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.CategoryTheory.GlueData import Mathlib.Topology.Category.TopCat.Limits.Pullbacks import Mathlib.Topology.Category.TopCat.Opens import Mathlib.Tactic.Generalize import Mathlib.CategoryTheory.Elementwise #align_import topology.gluing from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" /-! # Gluing Topological spaces Given a family of gluing data (see `Mathlib/CategoryTheory/GlueData.lean`), we can then glue them together. The construction should be "sealed" and considered as a black box, while only using the API provided. ## Main definitions * `TopCat.GlueData`: A structure containing the family of gluing data. * `CategoryTheory.GlueData.glued`: The glued topological space. This is defined as the multicoequalizer of `∐ V i j ⇉ ∐ U i`, so that the general colimit API can be used. * `CategoryTheory.GlueData.ι`: The immersion `ι i : U i ⟶ glued` for each `i : ι`. * `TopCat.GlueData.Rel`: A relation on `Σ i, D.U i` defined by `⟨i, x⟩ ~ ⟨j, y⟩` iff `⟨i, x⟩ = ⟨j, y⟩` or `t i j x = y`. See `TopCat.GlueData.ι_eq_iff_rel`. * `TopCat.GlueData.mk`: A constructor of `GlueData` whose conditions are stated in terms of elements rather than subobjects and pullbacks. * `TopCat.GlueData.ofOpenSubsets`: Given a family of open sets, we may glue them into a new topological space. This new space embeds into the original space, and is homeomorphic to it if the given family is an open cover (`TopCat.GlueData.openCoverGlueHomeo`). ## Main results * `TopCat.GlueData.isOpen_iff`: A set in `glued` is open iff its preimage along each `ι i` is open. * `TopCat.GlueData.ι_jointly_surjective`: The `ι i`s are jointly surjective. * `TopCat.GlueData.rel_equiv`: `Rel` is an equivalence relation. * `TopCat.GlueData.ι_eq_iff_rel`: `ι i x = ι j y ↔ ⟨i, x⟩ ~ ⟨j, y⟩`. * `TopCat.GlueData.image_inter`: The intersection of the images of `U i` and `U j` in `glued` is `V i j`. * `TopCat.GlueData.preimage_range`: The preimage of the image of `U i` in `U j` is `V i j`. * `TopCat.GlueData.preimage_image_eq_image`: The preimage of the image of some `U ⊆ U i` is given by XXX. * `TopCat.GlueData.ι_openEmbedding`: Each of the `ι i`s are open embeddings. -/ noncomputable section open TopologicalSpace CategoryTheory universe v u open CategoryTheory.Limits namespace TopCat /-- A family of gluing data consists of 1. An index type `J` 2. An object `U i` for each `i : J`. 3. An object `V i j` for each `i j : J`. (Note that this is `J × J → TopCat` rather than `J → J → TopCat` to connect to the limits library easier.) 4. An open embedding `f i j : V i j ⟶ U i` for each `i j : ι`. 5. A transition map `t i j : V i j ⟶ V j i` for each `i j : ι`. such that 6. `f i i` is an isomorphism. 7. `t i i` is the identity. 8. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some `t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`. (This merely means that `V i j ∩ V i k ⊆ t i j ⁻¹' (V j i ∩ V j k)`.) 9. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`. We can then glue the topological spaces `U i` together by identifying `V i j` with `V j i`, such that the `U i`'s are open subspaces of the glued space. Most of the times it would be easier to use the constructor `TopCat.GlueData.mk'` where the conditions are stated in a less categorical way. -/ -- porting note (#5171): removed @[nolint has_nonempty_instance] structure GlueData extends GlueData TopCat where f_open : ∀ i j, OpenEmbedding (f i j) f_mono := fun i j => (TopCat.mono_iff_injective _).mpr (f_open i j).toEmbedding.inj set_option linter.uppercaseLean3 false in #align Top.glue_data TopCat.GlueData namespace GlueData variable (D : GlueData.{u}) local notation "𝖣" => D.toGlueData theorem π_surjective : Function.Surjective 𝖣.π := (TopCat.epi_iff_surjective 𝖣.π).mp inferInstance set_option linter.uppercaseLean3 false in #align Top.glue_data.π_surjective TopCat.GlueData.π_surjective
Mathlib/Topology/Gluing.lean
104
115
theorem isOpen_iff (U : Set 𝖣.glued) : IsOpen U ↔ ∀ i, IsOpen (𝖣.ι i ⁻¹' U) := by
delta CategoryTheory.GlueData.ι simp_rw [← Multicoequalizer.ι_sigmaπ 𝖣.diagram] rw [← (homeoOfIso (Multicoequalizer.isoCoequalizer 𝖣.diagram).symm).isOpen_preimage] rw [coequalizer_isOpen_iff] dsimp only [GlueData.diagram_l, GlueData.diagram_left, GlueData.diagram_r, GlueData.diagram_right, parallelPair_obj_one] rw [colimit_isOpen_iff.{_,u}] -- Porting note: changed `.{u}` to `.{_,u}`. fun fact: the proof -- breaks down if this `rw` is merged with the `rw` above. constructor · intro h j; exact h ⟨j⟩ · intro h j; cases j; apply h
/- 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.Logic.Function.Iterate import Mathlib.Order.Monotone.Basic #align_import order.iterate from "leanprover-community/mathlib"@"2258b40dacd2942571c8ce136215350c702dc78f" /-! # Inequalities on iterates In this file we prove some inequalities comparing `f^[n] x` and `g^[n] x` where `f` and `g` are two self-maps that commute with each other. Current selection of inequalities is motivated by formalization of the rotation number of a circle homeomorphism. -/ open Function open Function (Commute) namespace Monotone variable {α : Type*} [Preorder α] {f : α → α} {x y : ℕ → α} /-! ### Comparison of two sequences If $f$ is a monotone function, then $∀ k, x_{k+1} ≤ f(x_k)$ implies that $x_k$ grows slower than $f^k(x_0)$, and similarly for the reversed inequalities. If $x_k$ and $y_k$ are two sequences such that $x_{k+1} ≤ f(x_k)$ and $y_{k+1} ≥ f(y_k)$ for all $k < n$, then $x_0 ≤ y_0$ implies $x_n ≤ y_n$, see `Monotone.seq_le_seq`. If some of the inequalities in this lemma are strict, then we have $x_n < y_n$. The rest of the lemmas in this section formalize this fact for different inequalities made strict. -/
Mathlib/Order/Iterate.lean
42
48
theorem seq_le_seq (hf : Monotone f) (n : ℕ) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n ≤ y n := by
induction' n with n ihn · exact h₀ · refine (hx _ n.lt_succ_self).trans ((hf <| ihn ?_ ?_).trans (hy _ n.lt_succ_self)) · exact fun k hk => hx _ (hk.trans n.lt_succ_self) · exact fun k hk => hy _ (hk.trans n.lt_succ_self)
/- Copyright (c) 2022 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.Algebra.Module.Zlattice.Basic import Mathlib.NumberTheory.NumberField.Embeddings import Mathlib.NumberTheory.NumberField.FractionalIdeal #align_import number_theory.number_field.canonical_embedding from "leanprover-community/mathlib"@"60da01b41bbe4206f05d34fd70c8dd7498717a30" /-! # Canonical embedding of a number field The canonical embedding of a number field `K` of degree `n` is the ring homomorphism `K →+* ℂ^n` that sends `x ∈ K` to `(φ_₁(x),...,φ_n(x))` where the `φ_i`'s are the complex embeddings of `K`. Note that we do not choose an ordering of the embeddings, but instead map `K` into the type `(K →+* ℂ) → ℂ` of `ℂ`-vectors indexed by the complex embeddings. ## Main definitions and results * `NumberField.canonicalEmbedding`: the ring homomorphism `K →+* ((K →+* ℂ) → ℂ)` defined by sending `x : K` to the vector `(φ x)` indexed by `φ : K →+* ℂ`. * `NumberField.canonicalEmbedding.integerLattice.inter_ball_finite`: the intersection of the image of the ring of integers by the canonical embedding and any ball centered at `0` of finite radius is finite. * `NumberField.mixedEmbedding`: the ring homomorphism from `K →+* ({ w // IsReal w } → ℝ) × ({ w // IsComplex w } → ℂ)` that sends `x ∈ K` to `(φ_w x)_w` where `φ_w` is the embedding associated to the infinite place `w`. In particular, if `w` is real then `φ_w : K →+* ℝ` and, if `w` is complex, `φ_w` is an arbitrary choice between the two complex embeddings defining the place `w`. ## Tags number field, infinite places -/ variable (K : Type*) [Field K] namespace NumberField.canonicalEmbedding open NumberField /-- The canonical embedding of a number field `K` of degree `n` into `ℂ^n`. -/ def _root_.NumberField.canonicalEmbedding : K →+* ((K →+* ℂ) → ℂ) := Pi.ringHom fun φ => φ theorem _root_.NumberField.canonicalEmbedding_injective [NumberField K] : Function.Injective (NumberField.canonicalEmbedding K) := RingHom.injective _ variable {K} @[simp] theorem apply_at (φ : K →+* ℂ) (x : K) : (NumberField.canonicalEmbedding K x) φ = φ x := rfl open scoped ComplexConjugate /-- The image of `canonicalEmbedding` lives in the `ℝ`-submodule of the `x ∈ ((K →+* ℂ) → ℂ)` such that `conj x_φ = x_(conj φ)` for all `∀ φ : K →+* ℂ`. -/ theorem conj_apply {x : ((K →+* ℂ) → ℂ)} (φ : K →+* ℂ) (hx : x ∈ Submodule.span ℝ (Set.range (canonicalEmbedding K))) : conj (x φ) = x (ComplexEmbedding.conjugate φ) := by refine Submodule.span_induction hx ?_ ?_ (fun _ _ hx hy => ?_) (fun a _ hx => ?_) · rintro _ ⟨x, rfl⟩ rw [apply_at, apply_at, ComplexEmbedding.conjugate_coe_eq] · rw [Pi.zero_apply, Pi.zero_apply, map_zero] · rw [Pi.add_apply, Pi.add_apply, map_add, hx, hy] · rw [Pi.smul_apply, Complex.real_smul, map_mul, Complex.conj_ofReal] exact congrArg ((a : ℂ) * ·) hx theorem nnnorm_eq [NumberField K] (x : K) : ‖canonicalEmbedding K x‖₊ = Finset.univ.sup (fun φ : K →+* ℂ => ‖φ x‖₊) := by simp_rw [Pi.nnnorm_def, apply_at]
Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean
76
85
theorem norm_le_iff [NumberField K] (x : K) (r : ℝ) : ‖canonicalEmbedding K x‖ ≤ r ↔ ∀ φ : K →+* ℂ, ‖φ x‖ ≤ r := by
obtain hr | hr := lt_or_le r 0 · obtain ⟨φ⟩ := (inferInstance : Nonempty (K →+* ℂ)) refine iff_of_false ?_ ?_ · exact (hr.trans_le (norm_nonneg _)).not_le · exact fun h => hr.not_le (le_trans (norm_nonneg _) (h φ)) · lift r to NNReal using hr simp_rw [← coe_nnnorm, nnnorm_eq, NNReal.coe_le_coe, Finset.sup_le_iff, Finset.mem_univ, forall_true_left]
/- 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.Analysis.Convex.Function import Mathlib.Analysis.Convex.StrictConvexSpace import Mathlib.MeasureTheory.Function.AEEqOfIntegral import Mathlib.MeasureTheory.Integral.Average #align_import analysis.convex.integral from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Jensen's inequality for integrals In this file we prove several forms of Jensen's inequality for integrals. - for convex sets: `Convex.average_mem`, `Convex.set_average_mem`, `Convex.integral_mem`; - for convex functions: `ConvexOn.average_mem_epigraph`, `ConvexOn.map_average_le`, `ConvexOn.set_average_mem_epigraph`, `ConvexOn.map_set_average_le`, `ConvexOn.map_integral_le`; - for strictly convex sets: `StrictConvex.ae_eq_const_or_average_mem_interior`; - for a closed ball in a strictly convex normed space: `ae_eq_const_or_norm_integral_lt_of_norm_le_const`; - for strictly convex functions: `StrictConvexOn.ae_eq_const_or_map_average_lt`. ## TODO - Use a typeclass for strict convexity of a closed ball. ## Tags convex, integral, center mass, average value, Jensen's inequality -/ open MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function open scoped Topology ENNReal Convex variable {α E F : Type*} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ : Measure α} {s : Set E} {t : Set α} {f : α → E} {g : E → ℝ} {C : ℝ} /-! ### Non-strict Jensen's inequality -/ /-- If `μ` is a probability measure on `α`, `s` is a convex closed set in `E`, and `f` is an integrable function sending `μ`-a.e. points to `s`, then the expected value of `f` belongs to `s`: `∫ x, f x ∂μ ∈ s`. See also `Convex.sum_mem` for a finite sum version of this lemma. -/
Mathlib/Analysis/Convex/Integral.lean
56
81
theorem Convex.integral_mem [IsProbabilityMeasure μ] (hs : Convex ℝ s) (hsc : IsClosed s) (hf : ∀ᵐ x ∂μ, f x ∈ s) (hfi : Integrable f μ) : (∫ x, f x ∂μ) ∈ s := by
borelize E rcases hfi.aestronglyMeasurable with ⟨g, hgm, hfg⟩ haveI : SeparableSpace (range g ∩ s : Set E) := (hgm.isSeparable_range.mono inter_subset_left).separableSpace obtain ⟨y₀, h₀⟩ : (range g ∩ s).Nonempty := by rcases (hf.and hfg).exists with ⟨x₀, h₀⟩ exact ⟨f x₀, by simp only [h₀.2, mem_range_self], h₀.1⟩ rw [integral_congr_ae hfg]; rw [integrable_congr hfg] at hfi have hg : ∀ᵐ x ∂μ, g x ∈ closure (range g ∩ s) := by filter_upwards [hfg.rw (fun _ y => y ∈ s) hf] with x hx apply subset_closure exact ⟨mem_range_self _, hx⟩ set G : ℕ → SimpleFunc α E := SimpleFunc.approxOn _ hgm.measurable (range g ∩ s) y₀ h₀ have : Tendsto (fun n => (G n).integral μ) atTop (𝓝 <| ∫ x, g x ∂μ) := tendsto_integral_approxOn_of_measurable hfi _ hg _ (integrable_const _) refine hsc.mem_of_tendsto this (eventually_of_forall fun n => hs.sum_mem ?_ ?_ ?_) · exact fun _ _ => ENNReal.toReal_nonneg · rw [← ENNReal.toReal_sum, (G n).sum_range_measure_preimage_singleton, measure_univ, ENNReal.one_toReal] exact fun _ _ => measure_ne_top _ _ · simp only [SimpleFunc.mem_range, forall_mem_range] intro x apply (range g).inter_subset_right exact SimpleFunc.approxOn_mem hgm.measurable h₀ _ _
/- Copyright (c) 2021 Frédéric Dupuis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Frédéric Dupuis -/ import Mathlib.Analysis.Normed.Group.Hom import Mathlib.Analysis.NormedSpace.Basic import Mathlib.Analysis.NormedSpace.LinearIsometry import Mathlib.Algebra.Star.SelfAdjoint import Mathlib.Algebra.Star.Subalgebra import Mathlib.Algebra.Star.Unitary import Mathlib.Topology.Algebra.Module.Star #align_import analysis.normed_space.star.basic from "leanprover-community/mathlib"@"aa6669832974f87406a3d9d70fc5707a60546207" /-! # Normed star rings and algebras A normed star group is a normed group with a compatible `star` which is isometric. A C⋆-ring is a normed star group that is also a ring and that verifies the stronger condition `‖x⋆ * x‖ = ‖x‖^2` for all `x`. If a C⋆-ring is also a star algebra, then it is a C⋆-algebra. To get a C⋆-algebra `E` over field `𝕜`, use `[NormedField 𝕜] [StarRing 𝕜] [NormedRing E] [StarRing E] [CstarRing E] [NormedAlgebra 𝕜 E] [StarModule 𝕜 E]`. ## TODO - Show that `‖x⋆ * x‖ = ‖x‖^2` is equivalent to `‖x⋆ * x‖ = ‖x⋆‖ * ‖x‖`, which is used as the definition of C*-algebras in some sources (e.g. Wikipedia). -/ open Topology local postfix:max "⋆" => star /-- A normed star group is a normed group with a compatible `star` which is isometric. -/ class NormedStarGroup (E : Type*) [SeminormedAddCommGroup E] [StarAddMonoid E] : Prop where norm_star : ∀ x : E, ‖x⋆‖ = ‖x‖ #align normed_star_group NormedStarGroup export NormedStarGroup (norm_star) attribute [simp] norm_star variable {𝕜 E α : Type*} section NormedStarGroup variable [SeminormedAddCommGroup E] [StarAddMonoid E] [NormedStarGroup E] @[simp] theorem nnnorm_star (x : E) : ‖star x‖₊ = ‖x‖₊ := Subtype.ext <| norm_star _ #align nnnorm_star nnnorm_star /-- The `star` map in a normed star group is a normed group homomorphism. -/ def starNormedAddGroupHom : NormedAddGroupHom E E := { starAddEquiv with bound' := ⟨1, fun _ => le_trans (norm_star _).le (one_mul _).symm.le⟩ } #align star_normed_add_group_hom starNormedAddGroupHom /-- The `star` map in a normed star group is an isometry -/ theorem star_isometry : Isometry (star : E → E) := show Isometry starAddEquiv from AddMonoidHomClass.isometry_of_norm starAddEquiv (show ∀ x, ‖x⋆‖ = ‖x‖ from norm_star) #align star_isometry star_isometry instance (priority := 100) NormedStarGroup.to_continuousStar : ContinuousStar E := ⟨star_isometry.continuous⟩ #align normed_star_group.to_has_continuous_star NormedStarGroup.to_continuousStar end NormedStarGroup instance RingHomIsometric.starRingEnd [NormedCommRing E] [StarRing E] [NormedStarGroup E] : RingHomIsometric (starRingEnd E) := ⟨@norm_star _ _ _ _⟩ #align ring_hom_isometric.star_ring_end RingHomIsometric.starRingEnd /-- A C*-ring is a normed star ring that satisfies the stronger condition `‖x⋆ * x‖ = ‖x‖^2` for every `x`. -/ class CstarRing (E : Type*) [NonUnitalNormedRing E] [StarRing E] : Prop where norm_star_mul_self : ∀ {x : E}, ‖x⋆ * x‖ = ‖x‖ * ‖x‖ #align cstar_ring CstarRing instance : CstarRing ℝ where norm_star_mul_self {x} := by simp only [star, id, norm_mul] namespace CstarRing section NonUnital variable [NonUnitalNormedRing E] [StarRing E] [CstarRing E] -- see Note [lower instance priority] /-- In a C*-ring, star preserves the norm. -/ instance (priority := 100) to_normedStarGroup : NormedStarGroup E := ⟨by intro x by_cases htriv : x = 0 · simp only [htriv, star_zero] · have hnt : 0 < ‖x‖ := norm_pos_iff.mpr htriv have hnt_star : 0 < ‖x⋆‖ := norm_pos_iff.mpr ((AddEquiv.map_ne_zero_iff starAddEquiv (M := E)).mpr htriv) have h₁ := calc ‖x‖ * ‖x‖ = ‖x⋆ * x‖ := norm_star_mul_self.symm _ ≤ ‖x⋆‖ * ‖x‖ := norm_mul_le _ _ have h₂ := calc ‖x⋆‖ * ‖x⋆‖ = ‖x * x⋆‖ := by rw [← norm_star_mul_self, star_star] _ ≤ ‖x‖ * ‖x⋆‖ := norm_mul_le _ _ exact le_antisymm (le_of_mul_le_mul_right h₂ hnt_star) (le_of_mul_le_mul_right h₁ hnt)⟩ #align cstar_ring.to_normed_star_group CstarRing.to_normedStarGroup
Mathlib/Analysis/NormedSpace/Star/Basic.lean
118
120
theorem norm_self_mul_star {x : E} : ‖x * x⋆‖ = ‖x‖ * ‖x‖ := by
nth_rw 1 [← star_star x] simp only [norm_star_mul_self, norm_star]
/- Copyright (c) 2019 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Yaël Dillies -/ import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Fintype.Perm import Mathlib.GroupTheory.Perm.Finite import Mathlib.GroupTheory.Perm.List #align_import group_theory.perm.cycle.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Cycles of a permutation This file starts the theory of cycles in permutations. ## Main definitions In the following, `f : Equiv.Perm β`. * `Equiv.Perm.SameCycle`: `f.SameCycle x y` when `x` and `y` are in the same cycle of `f`. * `Equiv.Perm.IsCycle`: `f` is a cycle if any two nonfixed points of `f` are related by repeated applications of `f`, and `f` is not the identity. * `Equiv.Perm.IsCycleOn`: `f` is a cycle on a set `s` when any two points of `s` are related by repeated applications of `f`. ## Notes `Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn` are different in three ways: * `IsCycle` is about the entire type while `IsCycleOn` is restricted to a set. * `IsCycle` forbids the identity while `IsCycleOn` allows it (if `s` is a subsingleton). * `IsCycleOn` forbids fixed points on `s` (if `s` is nontrivial), while `IsCycle` allows them. -/ open Equiv Function Finset variable {ι α β : Type*} namespace Equiv.Perm /-! ### `SameCycle` -/ section SameCycle variable {f g : Perm α} {p : α → Prop} {x y z : α} /-- The equivalence relation indicating that two points are in the same cycle of a permutation. -/ def SameCycle (f : Perm α) (x y : α) : Prop := ∃ i : ℤ, (f ^ i) x = y #align equiv.perm.same_cycle Equiv.Perm.SameCycle @[refl] theorem SameCycle.refl (f : Perm α) (x : α) : SameCycle f x x := ⟨0, rfl⟩ #align equiv.perm.same_cycle.refl Equiv.Perm.SameCycle.refl theorem SameCycle.rfl : SameCycle f x x := SameCycle.refl _ _ #align equiv.perm.same_cycle.rfl Equiv.Perm.SameCycle.rfl protected theorem _root_.Eq.sameCycle (h : x = y) (f : Perm α) : f.SameCycle x y := by rw [h] #align eq.same_cycle Eq.sameCycle @[symm] theorem SameCycle.symm : SameCycle f x y → SameCycle f y x := fun ⟨i, hi⟩ => ⟨-i, by rw [zpow_neg, ← hi, inv_apply_self]⟩ #align equiv.perm.same_cycle.symm Equiv.Perm.SameCycle.symm theorem sameCycle_comm : SameCycle f x y ↔ SameCycle f y x := ⟨SameCycle.symm, SameCycle.symm⟩ #align equiv.perm.same_cycle_comm Equiv.Perm.sameCycle_comm @[trans] theorem SameCycle.trans : SameCycle f x y → SameCycle f y z → SameCycle f x z := fun ⟨i, hi⟩ ⟨j, hj⟩ => ⟨j + i, by rw [zpow_add, mul_apply, hi, hj]⟩ #align equiv.perm.same_cycle.trans Equiv.Perm.SameCycle.trans variable (f) in theorem SameCycle.equivalence : Equivalence (SameCycle f) := ⟨SameCycle.refl f, SameCycle.symm, SameCycle.trans⟩ /-- The setoid defined by the `SameCycle` relation. -/ def SameCycle.setoid (f : Perm α) : Setoid α where iseqv := SameCycle.equivalence f @[simp] theorem sameCycle_one : SameCycle 1 x y ↔ x = y := by simp [SameCycle] #align equiv.perm.same_cycle_one Equiv.Perm.sameCycle_one @[simp] theorem sameCycle_inv : SameCycle f⁻¹ x y ↔ SameCycle f x y := (Equiv.neg _).exists_congr_left.trans <| by simp [SameCycle] #align equiv.perm.same_cycle_inv Equiv.Perm.sameCycle_inv alias ⟨SameCycle.of_inv, SameCycle.inv⟩ := sameCycle_inv #align equiv.perm.same_cycle.of_inv Equiv.Perm.SameCycle.of_inv #align equiv.perm.same_cycle.inv Equiv.Perm.SameCycle.inv @[simp] theorem sameCycle_conj : SameCycle (g * f * g⁻¹) x y ↔ SameCycle f (g⁻¹ x) (g⁻¹ y) := exists_congr fun i => by simp [conj_zpow, eq_inv_iff_eq] #align equiv.perm.same_cycle_conj Equiv.Perm.sameCycle_conj theorem SameCycle.conj : SameCycle f x y → SameCycle (g * f * g⁻¹) (g x) (g y) := by simp [sameCycle_conj] #align equiv.perm.same_cycle.conj Equiv.Perm.SameCycle.conj theorem SameCycle.apply_eq_self_iff : SameCycle f x y → (f x = x ↔ f y = y) := fun ⟨i, hi⟩ => by rw [← hi, ← mul_apply, ← zpow_one_add, add_comm, zpow_add_one, mul_apply, (f ^ i).injective.eq_iff] #align equiv.perm.same_cycle.apply_eq_self_iff Equiv.Perm.SameCycle.apply_eq_self_iff theorem SameCycle.eq_of_left (h : SameCycle f x y) (hx : IsFixedPt f x) : x = y := let ⟨_, hn⟩ := h (hx.perm_zpow _).eq.symm.trans hn #align equiv.perm.same_cycle.eq_of_left Equiv.Perm.SameCycle.eq_of_left theorem SameCycle.eq_of_right (h : SameCycle f x y) (hy : IsFixedPt f y) : x = y := h.eq_of_left <| h.apply_eq_self_iff.2 hy #align equiv.perm.same_cycle.eq_of_right Equiv.Perm.SameCycle.eq_of_right @[simp] theorem sameCycle_apply_left : SameCycle f (f x) y ↔ SameCycle f x y := (Equiv.addRight 1).exists_congr_left.trans <| by simp [zpow_sub, SameCycle, Int.add_neg_one, Function.comp] #align equiv.perm.same_cycle_apply_left Equiv.Perm.sameCycle_apply_left @[simp]
Mathlib/GroupTheory/Perm/Cycle/Basic.lean
132
133
theorem sameCycle_apply_right : SameCycle f x (f y) ↔ SameCycle f x y := by
rw [sameCycle_comm, sameCycle_apply_left, sameCycle_comm]
/- 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⟩ theorem commProb_pi {α : Type*} (i : α → Type*) [Fintype α] [∀ a, Mul (i a)] : commProb (∀ a, i a) = ∏ a, commProb (i a) := by simp_rw [commProb_def, Finset.prod_div_distrib, Finset.prod_pow, ← Nat.cast_prod, ← Nat.card_pi, Commute, SemiconjBy, Function.funext_iff] congr 2 exact Nat.card_congr ⟨fun x a => ⟨⟨x.1.1 a, x.1.2 a⟩, x.2 a⟩, fun x => ⟨⟨fun a => (x a).1.1, fun a => (x a).1.2⟩, fun a => (x a).2⟩, fun x => rfl, fun x => rfl⟩ theorem commProb_function {α β : Type*} [Fintype α] [Mul β] : commProb (α → β) = (commProb β) ^ Fintype.card α := by rw [commProb_pi, Finset.prod_const, Finset.card_univ] @[simp] theorem commProb_eq_zero_of_infinite [Infinite M] : commProb M = 0 := div_eq_zero_iff.2 (Or.inl (Nat.cast_eq_zero.2 Nat.card_eq_zero_of_infinite)) variable [Finite M] theorem commProb_pos [h : Nonempty M] : 0 < commProb M := h.elim fun x ↦ div_pos (Nat.cast_pos.mpr (Finite.card_pos_iff.mpr ⟨⟨(x, x), rfl⟩⟩)) (pow_pos (Nat.cast_pos.mpr Finite.card_pos) 2) #align comm_prob_pos commProb_pos theorem commProb_le_one : commProb M ≤ 1 := by refine div_le_one_of_le ?_ (sq_nonneg (Nat.card M : ℚ)) rw [← Nat.cast_pow, Nat.cast_le, sq, ← Nat.card_prod] apply Finite.card_subtype_le #align comm_prob_le_one commProb_le_one variable {M} theorem commProb_eq_one_iff [h : Nonempty M] : commProb M = 1 ↔ Commutative ((· * ·) : M → M → M) := by haveI := Fintype.ofFinite M rw [commProb, ← Set.coe_setOf, Nat.card_eq_fintype_card, Nat.card_eq_fintype_card] rw [div_eq_one_iff_eq, ← Nat.cast_pow, Nat.cast_inj, sq, ← card_prod, set_fintype_card_eq_univ_iff, Set.eq_univ_iff_forall] · exact ⟨fun h x y ↦ h (x, y), fun h x ↦ h x.1 x.2⟩ · exact pow_ne_zero 2 (Nat.cast_ne_zero.mpr card_ne_zero) #align comm_prob_eq_one_iff commProb_eq_one_iff variable (G : Type*) [Group G]
Mathlib/GroupTheory/CommutingProbability.lean
98
102
theorem commProb_def' : commProb G = Nat.card (ConjClasses G) / Nat.card G := by
rw [commProb, card_comm_eq_card_conjClasses_mul_card, Nat.cast_mul, sq] by_cases h : (Nat.card G : ℚ) = 0 · rw [h, zero_mul, div_zero, div_zero] · exact mul_div_mul_right _ _ h
/- Copyright (c) 2018 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Johannes Hölzl, Rémy Degenne -/ import Mathlib.Order.Filter.Cofinite import Mathlib.Order.Hom.CompleteLattice #align_import order.liminf_limsup from "leanprover-community/mathlib"@"ffde2d8a6e689149e44fd95fa862c23a57f8c780" /-! # liminfs and limsups of functions and filters Defines the liminf/limsup of a function taking values in a conditionally complete lattice, with respect to an arbitrary filter. We define `limsSup f` (`limsInf f`) where `f` is a filter taking values in a conditionally complete lattice. `limsSup f` is the smallest element `a` such that, eventually, `u ≤ a` (and vice versa for `limsInf f`). To work with the Limsup along a function `u` use `limsSup (map u f)`. Usually, one defines the Limsup as `inf (sup s)` where the Inf is taken over all sets in the filter. For instance, in ℕ along a function `u`, this is `inf_n (sup_{k ≥ n} u k)` (and the latter quantity decreases with `n`, so this is in fact a limit.). There is however a difficulty: it is well possible that `u` is not bounded on the whole space, only eventually (think of `limsup (fun x ↦ 1/x)` on ℝ. Then there is no guarantee that the quantity above really decreases (the value of the `sup` beforehand is not really well defined, as one can not use ∞), so that the Inf could be anything. So one can not use this `inf sup ...` definition in conditionally complete lattices, and one has to use a less tractable definition. In conditionally complete lattices, the definition is only useful for filters which are eventually bounded above (otherwise, the Limsup would morally be +∞, which does not belong to the space) and which are frequently bounded below (otherwise, the Limsup would morally be -∞, which is not in the space either). We start with definitions of these concepts for arbitrary filters, before turning to the definitions of Limsup and Liminf. In complete lattices, however, it coincides with the `Inf Sup` definition. -/ set_option autoImplicit true open Filter Set Function variable {α β γ ι ι' : Type*} namespace Filter section Relation /-- `f.IsBounded (≺)`: the filter `f` is eventually bounded w.r.t. the relation `≺`, i.e. eventually, it is bounded by some uniform bound. `r` will be usually instantiated with `≤` or `≥`. -/ def IsBounded (r : α → α → Prop) (f : Filter α) := ∃ b, ∀ᶠ x in f, r x b #align filter.is_bounded Filter.IsBounded /-- `f.IsBoundedUnder (≺) u`: the image of the filter `f` under `u` is eventually bounded w.r.t. the relation `≺`, i.e. eventually, it is bounded by some uniform bound. -/ def IsBoundedUnder (r : α → α → Prop) (f : Filter β) (u : β → α) := (map u f).IsBounded r #align filter.is_bounded_under Filter.IsBoundedUnder variable {r : α → α → Prop} {f g : Filter α} /-- `f` is eventually bounded if and only if, there exists an admissible set on which it is bounded. -/ theorem isBounded_iff : f.IsBounded r ↔ ∃ s ∈ f.sets, ∃ b, s ⊆ { x | r x b } := Iff.intro (fun ⟨b, hb⟩ => ⟨{ a | r a b }, hb, b, Subset.refl _⟩) fun ⟨_, hs, b, hb⟩ => ⟨b, mem_of_superset hs hb⟩ #align filter.is_bounded_iff Filter.isBounded_iff /-- A bounded function `u` is in particular eventually bounded. -/ theorem isBoundedUnder_of {f : Filter β} {u : β → α} : (∃ b, ∀ x, r (u x) b) → f.IsBoundedUnder r u | ⟨b, hb⟩ => ⟨b, show ∀ᶠ x in f, r (u x) b from eventually_of_forall hb⟩ #align filter.is_bounded_under_of Filter.isBoundedUnder_of theorem isBounded_bot : IsBounded r ⊥ ↔ Nonempty α := by simp [IsBounded, exists_true_iff_nonempty] #align filter.is_bounded_bot Filter.isBounded_bot theorem isBounded_top : IsBounded r ⊤ ↔ ∃ t, ∀ x, r x t := by simp [IsBounded, eq_univ_iff_forall] #align filter.is_bounded_top Filter.isBounded_top
Mathlib/Order/LiminfLimsup.lean
83
84
theorem isBounded_principal (s : Set α) : IsBounded r (𝓟 s) ↔ ∃ t, ∀ x ∈ s, r x t := by
simp [IsBounded, subset_def]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Anne Baanen -/ import Mathlib.Tactic.Ring.Basic import Mathlib.Tactic.TryThis import Mathlib.Tactic.Conv import Mathlib.Util.Qq /-! # `ring_nf` tactic A tactic which uses `ring` to rewrite expressions. This can be used non-terminally to normalize ring expressions in the goal such as `⊢ P (x + x + x)` ~> `⊢ P (x * 3)`, as well as being able to prove some equations that `ring` cannot because they involve ring reasoning inside a subterm, such as `sin (x + y) + sin (y + x) = 2 * sin (x + y)`. -/ set_option autoImplicit true -- In this file we would like to be able to use multi-character auto-implicits. set_option relaxedAutoImplicit true namespace Mathlib.Tactic open Lean hiding Rat open Qq Meta namespace Ring /-- True if this represents an atomic expression. -/ def ExBase.isAtom : ExBase sα a → Bool | .atom _ => true | _ => false /-- True if this represents an atomic expression. -/ def ExProd.isAtom : ExProd sα a → Bool | .mul va₁ (.const 1 _) (.const 1 _) => va₁.isAtom | _ => false /-- True if this represents an atomic expression. -/ def ExSum.isAtom : ExSum sα a → Bool | .add va₁ va₂ => match va₂ with -- FIXME: this takes a while to compile as one match | .zero => va₁.isAtom | _ => false | _ => false end Ring namespace RingNF open Ring /-- The normalization style for `ring_nf`. -/ inductive RingMode where /-- Sum-of-products form, like `x + x * y * 2 + z ^ 2`. -/ | SOP /-- Raw form: the representation `ring` uses internally. -/ | raw deriving Inhabited, BEq, Repr /-- Configuration for `ring_nf`. -/ structure Config where /-- the reducibility setting to use when comparing atoms for defeq -/ red := TransparencyMode.reducible /-- if true, atoms inside ring expressions will be reduced recursively -/ recursive := true /-- The normalization style. -/ mode := RingMode.SOP deriving Inhabited, BEq, Repr /-- Function elaborating `RingNF.Config`. -/ declare_config_elab elabConfig Config /-- The read-only state of the `RingNF` monad. -/ structure Context where /-- A basically empty simp context, passed to the `simp` traversal in `RingNF.rewrite`. -/ ctx : Simp.Context /-- A cleanup routine, which simplifies normalized polynomials to a more human-friendly format. -/ simp : Simp.Result → SimpM Simp.Result /-- The monad for `RingNF` contains, in addition to the `AtomM` state, a simp context for the main traversal and a simp function (which has another simp context) to simplify normalized polynomials. -/ abbrev M := ReaderT Context AtomM /-- A tactic in the `RingNF.M` monad which will simplify expression `parent` to a normal form. * `root`: true if this is a direct call to the function. `RingNF.M.run` sets this to `false` in recursive mode. -/ def rewrite (parent : Expr) (root := true) : M Simp.Result := fun nctx rctx s ↦ do let pre : Simp.Simproc := fun e => try guard <| root || parent != e -- recursion guard let e ← withReducible <| whnf e guard e.isApp -- all interesting ring expressions are applications let ⟨u, α, e⟩ ← inferTypeQ' e let sα ← synthInstanceQ (q(CommSemiring $α) : Q(Type u)) let c ← mkCache sα let ⟨a, _, pa⟩ ← match ← isAtomOrDerivable sα c e rctx s with | none => eval sα c e rctx s -- `none` indicates that `eval` will find something algebraic. | some none => failure -- No point rewriting atoms | some (some r) => pure r -- Nothing algebraic for `eval` to use, but `norm_num` simplifies. let r ← nctx.simp { expr := a, proof? := pa } if ← withReducible <| isDefEq r.expr e then return .done { expr := r.expr } pure (.done r) catch _ => pure <| .continue let post := Simp.postDefault #[] (·.1) <$> Simp.main parent nctx.ctx (methods := { pre, post }) variable [CommSemiring R] theorem add_assoc_rev (a b c : R) : a + (b + c) = a + b + c := (add_assoc ..).symm theorem mul_assoc_rev (a b c : R) : a * (b * c) = a * b * c := (mul_assoc ..).symm theorem mul_neg {R} [Ring R] (a b : R) : a * -b = -(a * b) := by simp theorem add_neg {R} [Ring R] (a b : R) : a + -b = a - b := (sub_eq_add_neg ..).symm theorem nat_rawCast_0 : (Nat.rawCast 0 : R) = 0 := by simp
Mathlib/Tactic/Ring/RingNF.lean
121
121
theorem nat_rawCast_1 : (Nat.rawCast 1 : R) = 1 := by
simp