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) 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
Mathlib/Data/List/Range.lean
66
67
theorem nthLe_range'_1 {n m} (i) (H : i < (range' n m).length) : nthLe (range' n m) i H = n + i := by
simp
/- Copyright (c) 2021 Aaron Anderson, Jesse Michael Han, Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jesse Michael Han, Floris van Doorn -/ import Mathlib.Data.Set.Prod import Mathlib.Logic.Equiv.Fin import Mathlib.ModelTheory.LanguageMap #align_import model_theory.syntax from "leanprover-community/mathlib"@"d565b3df44619c1498326936be16f1a935df0728" /-! # Basics on First-Order Syntax This file defines first-order terms, formulas, sentences, and theories in a style inspired by the [Flypitch project](https://flypitch.github.io/). ## Main Definitions * A `FirstOrder.Language.Term` is defined so that `L.Term α` is the type of `L`-terms with free variables indexed by `α`. * A `FirstOrder.Language.Formula` is defined so that `L.Formula α` is the type of `L`-formulas with free variables indexed by `α`. * A `FirstOrder.Language.Sentence` is a formula with no free variables. * A `FirstOrder.Language.Theory` is a set of sentences. * The variables of terms and formulas can be relabelled with `FirstOrder.Language.Term.relabel`, `FirstOrder.Language.BoundedFormula.relabel`, and `FirstOrder.Language.Formula.relabel`. * Given an operation on terms and an operation on relations, `FirstOrder.Language.BoundedFormula.mapTermRel` gives an operation on formulas. * `FirstOrder.Language.BoundedFormula.castLE` adds more `Fin`-indexed variables. * `FirstOrder.Language.BoundedFormula.liftAt` raises the indexes of the `Fin`-indexed variables above a particular index. * `FirstOrder.Language.Term.subst` and `FirstOrder.Language.BoundedFormula.subst` substitute variables with given terms. * Language maps can act on syntactic objects with functions such as `FirstOrder.Language.LHom.onFormula`. * `FirstOrder.Language.Term.constantsVarsEquiv` and `FirstOrder.Language.BoundedFormula.constantsVarsEquiv` switch terms and formulas between having constants in the language and having extra variables indexed by the same type. ## Implementation Notes * Formulas use a modified version of de Bruijn variables. Specifically, a `L.BoundedFormula α n` is a formula with some variables indexed by a type `α`, which cannot be quantified over, and some indexed by `Fin n`, which can. For any `φ : L.BoundedFormula α (n + 1)`, we define the formula `∀' φ : L.BoundedFormula α n` by universally quantifying over the variable indexed by `n : Fin (n + 1)`. ## References For the Flypitch project: - [J. Han, F. van Doorn, *A formal proof of the independence of the continuum hypothesis*] [flypitch_cpp] - [J. Han, F. van Doorn, *A formalization of forcing and the unprovability of the continuum hypothesis*][flypitch_itp] -/ universe u v w u' v' namespace FirstOrder namespace Language variable (L : Language.{u, v}) {L' : Language} variable {M : Type w} {N P : Type*} [L.Structure M] [L.Structure N] [L.Structure P] variable {α : Type u'} {β : Type v'} {γ : Type*} open FirstOrder open Structure Fin /-- A term on `α` is either a variable indexed by an element of `α` or a function symbol applied to simpler terms. -/ inductive Term (α : Type u') : Type max u u' | var : α → Term α | func : ∀ {l : ℕ} (_f : L.Functions l) (_ts : Fin l → Term α), Term α #align first_order.language.term FirstOrder.Language.Term export Term (var func) variable {L} namespace Term open Finset /-- The `Finset` of variables used in a given term. -/ @[simp] def varFinset [DecidableEq α] : L.Term α → Finset α | var i => {i} | func _f ts => univ.biUnion fun i => (ts i).varFinset #align first_order.language.term.var_finset FirstOrder.Language.Term.varFinset -- Porting note: universes in different order /-- The `Finset` of variables from the left side of a sum used in a given term. -/ @[simp] def varFinsetLeft [DecidableEq α] : L.Term (Sum α β) → Finset α | var (Sum.inl i) => {i} | var (Sum.inr _i) => ∅ | func _f ts => univ.biUnion fun i => (ts i).varFinsetLeft #align first_order.language.term.var_finset_left FirstOrder.Language.Term.varFinsetLeft -- Porting note: universes in different order @[simp] def relabel (g : α → β) : L.Term α → L.Term β | var i => var (g i) | func f ts => func f fun {i} => (ts i).relabel g #align first_order.language.term.relabel FirstOrder.Language.Term.relabel theorem relabel_id (t : L.Term α) : t.relabel id = t := by induction' t with _ _ _ _ ih · rfl · simp [ih] #align first_order.language.term.relabel_id FirstOrder.Language.Term.relabel_id @[simp] theorem relabel_id_eq_id : (Term.relabel id : L.Term α → L.Term α) = id := funext relabel_id #align first_order.language.term.relabel_id_eq_id FirstOrder.Language.Term.relabel_id_eq_id @[simp]
Mathlib/ModelTheory/Syntax.lean
119
123
theorem relabel_relabel (f : α → β) (g : β → γ) (t : L.Term α) : (t.relabel f).relabel g = t.relabel (g ∘ f) := by
induction' t with _ _ _ _ ih · rfl · simp [ih]
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen -/ import Mathlib.RingTheory.Ideal.QuotientOperations import Mathlib.RingTheory.Localization.Basic #align_import ring_theory.localization.ideal from "leanprover-community/mathlib"@"e7f0ddbf65bd7181a85edb74b64bdc35ba4bdc74" /-! # Ideals in localizations of commutative rings ## Implementation notes See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview. ## Tags localization, ring localization, commutative ring localization, characteristic predicate, commutative ring, field of fractions -/ namespace IsLocalization section CommSemiring variable {R : Type*} [CommSemiring R] (M : Submonoid R) (S : Type*) [CommSemiring S] variable [Algebra R S] [IsLocalization M S] /-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`. In practice, this ideal differs only in that the carrier set is defined explicitly. This definition is only meant to be used in proving `mem_map_algebraMap_iff`, and any proof that needs to refer to the explicit carrier set should use that theorem. -/ private def map_ideal (I : Ideal R) : Ideal S where carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 } zero_mem' := ⟨⟨0, 1⟩, by simp⟩ add_mem' := by rintro a b ⟨a', ha⟩ ⟨b', hb⟩ let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R), I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩ use ⟨Z, a'.2 * b'.2⟩ simp only [RingHom.map_add, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul] rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ← mul_assoc b, hb] ring smul_mem' := by rintro c x ⟨x', hx⟩ obtain ⟨c', hc⟩ := IsLocalization.surj M c let Z : { x // x ∈ I } := ⟨c'.1 * x'.1, I.mul_mem_left c'.1 x'.1.2⟩ use ⟨Z, c'.2 * x'.2⟩ simp only [← hx, ← hc, smul_eq_mul, Submodule.coe_mk, Submonoid.coe_mul, RingHom.map_mul] ring -- Porting note: removed #align declaration since it is a private def
Mathlib/RingTheory/Localization/Ideal.lean
53
64
theorem mem_map_algebraMap_iff {I : Ideal R} {z} : z ∈ Ideal.map (algebraMap R S) I ↔ ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 := by
constructor · change _ → z ∈ map_ideal M S I refine fun h => Ideal.mem_sInf.1 h fun z hz => ?_ obtain ⟨y, hy⟩ := hz let Z : { x // x ∈ I } := ⟨y, hy.left⟩ use ⟨Z, 1⟩ simp [hy.right] · rintro ⟨⟨a, s⟩, h⟩ rw [← Ideal.unit_mul_mem_iff_mem _ (map_units S s), mul_comm] exact h.symm ▸ Ideal.mem_map_of_mem _ a.2
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Algebra.CharP.Invertible import Mathlib.Algebra.Order.Invertible import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.Algebra.Order.Group.Instances import Mathlib.LinearAlgebra.AffineSpace.Slope import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.Tactic.FieldSimp #align_import linear_algebra.affine_space.ordered from "leanprover-community/mathlib"@"78261225eb5cedc61c5c74ecb44e5b385d13b733" /-! # Ordered modules as affine spaces In this file we prove some theorems about `slope` and `lineMap` in the case when the module `E` acting on the codomain `PE` of a function is an ordered module over its domain `k`. We also prove inequalities that can be used to link convexity of a function on an interval to monotonicity of the slope, see section docstring below for details. ## Implementation notes We do not introduce the notion of ordered affine spaces (yet?). Instead, we prove various theorems for an ordered module interpreted as an affine space. ## Tags affine space, ordered module, slope -/ open AffineMap variable {k E PE : Type*} /-! ### Monotonicity of `lineMap` In this section we prove that `lineMap a b r` is monotone (strictly or not) in its arguments if other arguments belong to specific domains. -/ section OrderedRing variable [OrderedRing k] [OrderedAddCommGroup E] [Module k E] [OrderedSMul k E] variable {a a' b b' : E} {r r' : k} theorem lineMap_mono_left (ha : a ≤ a') (hr : r ≤ 1) : lineMap a b r ≤ lineMap a' b r := by simp only [lineMap_apply_module] exact add_le_add_right (smul_le_smul_of_nonneg_left ha (sub_nonneg.2 hr)) _ #align line_map_mono_left lineMap_mono_left theorem lineMap_strict_mono_left (ha : a < a') (hr : r < 1) : lineMap a b r < lineMap a' b r := by simp only [lineMap_apply_module] exact add_lt_add_right (smul_lt_smul_of_pos_left ha (sub_pos.2 hr)) _ #align line_map_strict_mono_left lineMap_strict_mono_left theorem lineMap_mono_right (hb : b ≤ b') (hr : 0 ≤ r) : lineMap a b r ≤ lineMap a b' r := by simp only [lineMap_apply_module] exact add_le_add_left (smul_le_smul_of_nonneg_left hb hr) _ #align line_map_mono_right lineMap_mono_right theorem lineMap_strict_mono_right (hb : b < b') (hr : 0 < r) : lineMap a b r < lineMap a b' r := by simp only [lineMap_apply_module] exact add_lt_add_left (smul_lt_smul_of_pos_left hb hr) _ #align line_map_strict_mono_right lineMap_strict_mono_right theorem lineMap_mono_endpoints (ha : a ≤ a') (hb : b ≤ b') (h₀ : 0 ≤ r) (h₁ : r ≤ 1) : lineMap a b r ≤ lineMap a' b' r := (lineMap_mono_left ha h₁).trans (lineMap_mono_right hb h₀) #align line_map_mono_endpoints lineMap_mono_endpoints
Mathlib/LinearAlgebra/AffineSpace/Ordered.lean
77
80
theorem lineMap_strict_mono_endpoints (ha : a < a') (hb : b < b') (h₀ : 0 ≤ r) (h₁ : r ≤ 1) : lineMap a b r < lineMap a' b' r := by
rcases h₀.eq_or_lt with (rfl | h₀); · simpa exact (lineMap_mono_left ha.le h₁).trans_lt (lineMap_strict_mono_right hb h₀)
/- Copyright (c) 2020 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.Data.List.Nodup #align_import data.prod.tprod from "leanprover-community/mathlib"@"c227d107bbada5d0d9d20287e3282c0a7f1651a0" /-! # Finite products of types This file defines the product of types over a list. For `l : List ι` and `α : ι → Type v` we define `List.TProd α l = l.foldr (fun i β ↦ α i × β) PUnit`. This type should not be used if `∀ i, α i` or `∀ i ∈ l, α i` can be used instead (in the last expression, we could also replace the list `l` by a set or a finset). This type is used as an intermediary between binary products and finitary products. The application of this type is finitary product measures, but it could be used in any construction/theorem that is easier to define/prove on binary products than on finitary products. * Once we have the construction on binary products (like binary product measures in `MeasureTheory.prod`), we can easily define a finitary version on the type `TProd l α` by iterating. Properties can also be easily extended from the binary case to the finitary case by iterating. * Then we can use the equivalence `List.TProd.piEquivTProd` below (or enhanced versions of it, like a `MeasurableEquiv` for product measures) to get the construction on `∀ i : ι, α i`, at least when assuming `[Fintype ι] [Encodable ι]` (using `Encodable.sortedUniv`). Using `attribute [local instance] Fintype.toEncodable` we can get rid of the argument `[Encodable ι]`. ## Main definitions * We have the equivalence `TProd.piEquivTProd : (∀ i, α i) ≃ TProd α l` if `l` contains every element of `ι` exactly once. * The product of sets is `Set.tprod : (∀ i, Set (α i)) → Set (TProd α l)`. -/ open List Function universe u v variable {ι : Type u} {α : ι → Type v} {i j : ι} {l : List ι} {f : ∀ i, α i} namespace List variable (α) /-- The product of a family of types over a list. -/ abbrev TProd (l : List ι) : Type v := l.foldr (fun i β => α i × β) PUnit #align list.tprod List.TProd variable {α} namespace TProd open List /-- Turning a function `f : ∀ i, α i` into an element of the iterated product `TProd α l`. -/ protected def mk : ∀ (l : List ι) (_f : ∀ i, α i), TProd α l | [] => fun _ => PUnit.unit | i :: is => fun f => (f i, TProd.mk is f) #align list.tprod.mk List.TProd.mk instance [∀ i, Inhabited (α i)] : Inhabited (TProd α l) := ⟨TProd.mk l default⟩ @[simp] theorem fst_mk (i : ι) (l : List ι) (f : ∀ i, α i) : (TProd.mk (i :: l) f).1 = f i := rfl #align list.tprod.fst_mk List.TProd.fst_mk @[simp] theorem snd_mk (i : ι) (l : List ι) (f : ∀ i, α i) : (TProd.mk.{u,v} (i :: l) f).2 = TProd.mk.{u,v} l f := rfl #align list.tprod.snd_mk List.TProd.snd_mk variable [DecidableEq ι] /-- Given an element of the iterated product `l.Prod α`, take a projection into direction `i`. If `i` appears multiple times in `l`, this chooses the first component in direction `i`. -/ protected def elim : ∀ {l : List ι} (_ : TProd α l) {i : ι} (_ : i ∈ l), α i | i :: is, v, j, hj => if hji : j = i then by subst hji exact v.1 else TProd.elim v.2 ((List.mem_cons.mp hj).resolve_left hji) #align list.tprod.elim List.TProd.elim @[simp] theorem elim_self (v : TProd α (i :: l)) : v.elim (l.mem_cons_self i) = v.1 := by simp [TProd.elim] #align list.tprod.elim_self List.TProd.elim_self @[simp]
Mathlib/Data/Prod/TProd.lean
94
95
theorem elim_of_ne (hj : j ∈ i :: l) (hji : j ≠ i) (v : TProd α (i :: l)) : v.elim hj = TProd.elim v.2 ((List.mem_cons.mp hj).resolve_left hji) := by
simp [TProd.elim, hji]
/- Copyright (c) 2019 Gabriel Ebner. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Gabriel Ebner, Anatole Dedecker, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Mul import Mathlib.Analysis.Calculus.FDeriv.Add #align_import analysis.calculus.deriv.mul from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Derivative of `f x * g x` In this file we prove formulas for `(f x * g x)'` and `(f x • g x)'`. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative, multiplication -/ universe u v w noncomputable section open scoped Classical Topology Filter ENNReal open Filter Asymptotics Set open ContinuousLinearMap (smulRight smulRight_one_eq_iff) variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] variable {f f₀ f₁ g : 𝕜 → F} variable {f' f₀' f₁' g' : F} variable {x : 𝕜} variable {s t : Set 𝕜} variable {L L₁ L₂ : Filter 𝕜} /-! ### Derivative of bilinear maps -/ namespace ContinuousLinearMap variable {B : E →L[𝕜] F →L[𝕜] G} {u : 𝕜 → E} {v : 𝕜 → F} {u' : E} {v' : F} theorem hasDerivWithinAt_of_bilinear (hu : HasDerivWithinAt u u' s x) (hv : HasDerivWithinAt v v' s x) : HasDerivWithinAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) s x := by simpa using (B.hasFDerivWithinAt_of_bilinear hu.hasFDerivWithinAt hv.hasFDerivWithinAt).hasDerivWithinAt
Mathlib/Analysis/Calculus/Deriv/Mul.lean
58
60
theorem hasDerivAt_of_bilinear (hu : HasDerivAt u u' x) (hv : HasDerivAt v v' x) : HasDerivAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) x := by
simpa using (B.hasFDerivAt_of_bilinear hu.hasFDerivAt hv.hasFDerivAt).hasDerivAt
/- 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.SetTheory.Ordinal.Arithmetic import Mathlib.SetTheory.Ordinal.Exponential #align_import set_theory.ordinal.cantor_normal_form from "leanprover-community/mathlib"@"991ff3b5269848f6dd942ae8e9dd3c946035dc8b" /-! # Cantor Normal Form The Cantor normal form of an ordinal is generally defined as its base `ω` expansion, with its non-zero exponents in decreasing order. Here, we more generally define a base `b` expansion `Ordinal.CNF` in this manner, which is well-behaved for any `b ≥ 2`. # Implementation notes We implement `Ordinal.CNF` as an association list, where keys are exponents and values are coefficients. This is because this structure intrinsically reflects two key properties of the Cantor normal form: - It is ordered. - It has finitely many entries. # Todo - Add API for the coefficients of the Cantor normal form. - Prove the basic results relating the CNF to the arithmetic operations on ordinals. -/ noncomputable section universe u open List namespace Ordinal /-- Inducts on the base `b` expansion of an ordinal. -/ @[elab_as_elim] noncomputable def CNFRec (b : Ordinal) {C : Ordinal → Sort*} (H0 : C 0) (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : ∀ o, C o := fun o ↦ by by_cases h : o = 0 · rw [h]; exact H0 · exact H o h (CNFRec _ H0 H (o % b ^ log b o)) termination_by o => o decreasing_by exact mod_opow_log_lt_self b h set_option linter.uppercaseLean3 false in #align ordinal.CNF_rec Ordinal.CNFRec @[simp] theorem CNFRec_zero {C : Ordinal → Sort*} (b : Ordinal) (H0 : C 0) (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : @CNFRec b C H0 H 0 = H0 := by rw [CNFRec, dif_pos rfl] rfl set_option linter.uppercaseLean3 false in #align ordinal.CNF_rec_zero Ordinal.CNFRec_zero theorem CNFRec_pos (b : Ordinal) {o : Ordinal} {C : Ordinal → Sort*} (ho : o ≠ 0) (H0 : C 0) (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : @CNFRec b C H0 H o = H o ho (@CNFRec b C H0 H _) := by rw [CNFRec, dif_neg ho] set_option linter.uppercaseLean3 false in #align ordinal.CNF_rec_pos Ordinal.CNFRec_pos -- Porting note: unknown attribute @[pp_nodot] /-- The Cantor normal form of an ordinal `o` is the list of coefficients and exponents in the base-`b` expansion of `o`. We special-case `CNF 0 o = CNF 1 o = [(0, o)]` for `o ≠ 0`. `CNF b (b ^ u₁ * v₁ + b ^ u₂ * v₂) = [(u₁, v₁), (u₂, v₂)]` -/ def CNF (b o : Ordinal) : List (Ordinal × Ordinal) := CNFRec b [] (fun o _ho IH ↦ (log b o, o / b ^ log b o)::IH) o set_option linter.uppercaseLean3 false in #align ordinal.CNF Ordinal.CNF @[simp] theorem CNF_zero (b : Ordinal) : CNF b 0 = [] := CNFRec_zero b _ _ set_option linter.uppercaseLean3 false in #align ordinal.CNF_zero Ordinal.CNF_zero /-- Recursive definition for the Cantor normal form. -/ theorem CNF_ne_zero {b o : Ordinal} (ho : o ≠ 0) : CNF b o = (log b o, o / b ^ log b o)::CNF b (o % b ^ log b o) := CNFRec_pos b ho _ _ set_option linter.uppercaseLean3 false in #align ordinal.CNF_ne_zero Ordinal.CNF_ne_zero
Mathlib/SetTheory/Ordinal/CantorNormalForm.lean
93
93
theorem zero_CNF {o : Ordinal} (ho : o ≠ 0) : CNF 0 o = [⟨0, o⟩] := by
simp [CNF_ne_zero ho]
/- 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.LinearAlgebra.AffineSpace.AffineMap import Mathlib.Tactic.FieldSimp #align_import linear_algebra.affine_space.slope from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Slope of a function In this file we define the slope of a function `f : k → PE` taking values in an affine space over `k` and prove some basic theorems about `slope`. The `slope` function naturally appears in the Mean Value Theorem, and in the proof of the fact that a function with nonnegative second derivative on an interval is convex on this interval. ## Tags affine space, slope -/ open AffineMap variable {k E PE : Type*} [Field k] [AddCommGroup E] [Module k E] [AddTorsor E PE] /-- `slope f a b = (b - a)⁻¹ • (f b -ᵥ f a)` is the slope of a function `f` on the interval `[a, b]`. Note that `slope f a a = 0`, not the derivative of `f` at `a`. -/ def slope (f : k → PE) (a b : k) : E := (b - a)⁻¹ • (f b -ᵥ f a) #align slope slope theorem slope_fun_def (f : k → PE) : slope f = fun a b => (b - a)⁻¹ • (f b -ᵥ f a) := rfl #align slope_fun_def slope_fun_def theorem slope_def_field (f : k → k) (a b : k) : slope f a b = (f b - f a) / (b - a) := (div_eq_inv_mul _ _).symm #align slope_def_field slope_def_field theorem slope_fun_def_field (f : k → k) (a : k) : slope f a = fun b => (f b - f a) / (b - a) := (div_eq_inv_mul _ _).symm #align slope_fun_def_field slope_fun_def_field @[simp] theorem slope_same (f : k → PE) (a : k) : (slope f a a : E) = 0 := by rw [slope, sub_self, inv_zero, zero_smul] #align slope_same slope_same theorem slope_def_module (f : k → E) (a b : k) : slope f a b = (b - a)⁻¹ • (f b - f a) := rfl #align slope_def_module slope_def_module @[simp] theorem sub_smul_slope (f : k → PE) (a b : k) : (b - a) • slope f a b = f b -ᵥ f a := by rcases eq_or_ne a b with (rfl | hne) · rw [sub_self, zero_smul, vsub_self] · rw [slope, smul_inv_smul₀ (sub_ne_zero.2 hne.symm)] #align sub_smul_slope sub_smul_slope theorem sub_smul_slope_vadd (f : k → PE) (a b : k) : (b - a) • slope f a b +ᵥ f a = f b := by rw [sub_smul_slope, vsub_vadd] #align sub_smul_slope_vadd sub_smul_slope_vadd @[simp]
Mathlib/LinearAlgebra/AffineSpace/Slope.lean
67
69
theorem slope_vadd_const (f : k → E) (c : PE) : (slope fun x => f x +ᵥ c) = slope f := by
ext a b simp only [slope, vadd_vsub_vadd_cancel_right, vsub_eq_sub]
/- 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
Mathlib/Data/Finset/NAry.lean
58
61
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
/- Copyright (c) 2023 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Probability.Kernel.CondDistrib #align_import probability.kernel.condexp from "leanprover-community/mathlib"@"00abe0695d8767201e6d008afa22393978bb324d" /-! # Kernel associated with a conditional expectation We define `condexpKernel μ m`, a kernel from `Ω` to `Ω` such that for all integrable functions `f`, `μ[f | m] =ᵐ[μ] fun ω => ∫ y, f y ∂(condexpKernel μ m ω)`. This kernel is defined if `Ω` is a standard Borel space. In general, `μ⟦s | m⟧` maps a measurable set `s` to a function `Ω → ℝ≥0∞`, and for all `s` that map is unique up to a `μ`-null set. For all `a`, the map from sets to `ℝ≥0∞` that we obtain that way verifies some of the properties of a measure, but the fact that the `μ`-null set depends on `s` can prevent us from finding versions of the conditional expectation that combine into a true measure. The standard Borel space assumption on `Ω` allows us to do so. ## Main definitions * `condexpKernel μ m`: kernel such that `μ[f | m] =ᵐ[μ] fun ω => ∫ y, f y ∂(condexpKernel μ m ω)`. ## Main statements * `condexp_ae_eq_integral_condexpKernel`: `μ[f | m] =ᵐ[μ] fun ω => ∫ y, f y ∂(condexpKernel μ m ω)`. -/ open MeasureTheory Set Filter TopologicalSpace open scoped ENNReal MeasureTheory ProbabilityTheory namespace ProbabilityTheory section AuxLemmas variable {Ω F : Type*} {m mΩ : MeasurableSpace Ω} {μ : Measure Ω} {f : Ω → F} theorem _root_.MeasureTheory.AEStronglyMeasurable.comp_snd_map_prod_id [TopologicalSpace F] (hm : m ≤ mΩ) (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun x : Ω × Ω => f x.2) (@Measure.map Ω (Ω × Ω) (m.prod mΩ) mΩ (fun ω => (id ω, id ω)) μ) := by rw [← aestronglyMeasurable_comp_snd_map_prod_mk_iff (measurable_id'' hm)] at hf simp_rw [id] at hf ⊢ exact hf #align measure_theory.ae_strongly_measurable.comp_snd_map_prod_id MeasureTheory.AEStronglyMeasurable.comp_snd_map_prod_id theorem _root_.MeasureTheory.Integrable.comp_snd_map_prod_id [NormedAddCommGroup F] (hm : m ≤ mΩ) (hf : Integrable f μ) : Integrable (fun x : Ω × Ω => f x.2) (@Measure.map Ω (Ω × Ω) (m.prod mΩ) mΩ (fun ω => (id ω, id ω)) μ) := by rw [← integrable_comp_snd_map_prod_mk_iff (measurable_id'' hm)] at hf simp_rw [id] at hf ⊢ exact hf #align measure_theory.integrable.comp_snd_map_prod_id MeasureTheory.Integrable.comp_snd_map_prod_id end AuxLemmas variable {Ω F : Type*} {m : MeasurableSpace Ω} [mΩ : MeasurableSpace Ω] [StandardBorelSpace Ω] [Nonempty Ω] {μ : Measure Ω} [IsFiniteMeasure μ] /-- Kernel associated with the conditional expectation with respect to a σ-algebra. It satisfies `μ[f | m] =ᵐ[μ] fun ω => ∫ y, f y ∂(condexpKernel μ m ω)`. It is defined as the conditional distribution of the identity given the identity, where the second identity is understood as a map from `Ω` with the σ-algebra `mΩ` to `Ω` with σ-algebra `m ⊓ mΩ`. We use `m ⊓ mΩ` instead of `m` to ensure that it is a sub-σ-algebra of `mΩ`. We then use `kernel.comap` to get a kernel from `m` to `mΩ` instead of from `m ⊓ mΩ` to `mΩ`. -/ noncomputable irreducible_def condexpKernel (μ : Measure Ω) [IsFiniteMeasure μ] (m : MeasurableSpace Ω) : @kernel Ω Ω m mΩ := kernel.comap (@condDistrib Ω Ω Ω mΩ _ _ mΩ (m ⊓ mΩ) id id μ _) id (measurable_id'' (inf_le_left : m ⊓ mΩ ≤ m)) #align probability_theory.condexp_kernel ProbabilityTheory.condexpKernel lemma condexpKernel_apply_eq_condDistrib {ω : Ω} : condexpKernel μ m ω = @condDistrib Ω Ω Ω mΩ _ _ mΩ (m ⊓ mΩ) id id μ _ (id ω) := by simp_rw [condexpKernel, kernel.comap_apply] instance : IsMarkovKernel (condexpKernel μ m) := by simp only [condexpKernel]; infer_instance section Measurability variable [NormedAddCommGroup F] {f : Ω → F} theorem measurable_condexpKernel {s : Set Ω} (hs : MeasurableSet s) : Measurable[m] fun ω => condexpKernel μ m ω s := by simp_rw [condexpKernel_apply_eq_condDistrib] refine Measurable.mono ?_ (inf_le_left : m ⊓ mΩ ≤ m) le_rfl convert measurable_condDistrib (μ := μ) hs rw [MeasurableSpace.comap_id] #align probability_theory.measurable_condexp_kernel ProbabilityTheory.measurable_condexpKernel theorem stronglyMeasurable_condexpKernel {s : Set Ω} (hs : MeasurableSet s) : StronglyMeasurable[m] fun ω => condexpKernel μ m ω s := Measurable.stronglyMeasurable (measurable_condexpKernel hs)
Mathlib/Probability/Kernel/Condexp.lean
99
105
theorem _root_.MeasureTheory.AEStronglyMeasurable.integral_condexpKernel [NormedSpace ℝ F] (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun ω => ∫ y, f y ∂condexpKernel μ m ω) μ := by
simp_rw [condexpKernel_apply_eq_condDistrib] exact AEStronglyMeasurable.integral_condDistrib (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) aemeasurable_id (hf.comp_snd_map_prod_id inf_le_right)
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou -/ import Mathlib.MeasureTheory.Function.LpOrder #align_import measure_theory.function.l1_space from "leanprover-community/mathlib"@"ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f" /-! # Integrable functions and `L¹` space In the first part of this file, the predicate `Integrable` is defined and basic properties of integrable functions are proved. Such a predicate is already available under the name `Memℒp 1`. We give a direct definition which is easier to use, and show that it is equivalent to `Memℒp 1` In the second part, we establish an API between `Integrable` and the space `L¹` of equivalence classes of integrable functions, already defined as a special case of `L^p` spaces for `p = 1`. ## Notation * `α →₁[μ] β` is the type of `L¹` space, where `α` is a `MeasureSpace` and `β` is a `NormedAddCommGroup` with a `SecondCountableTopology`. `f : α →ₘ β` is a "function" in `L¹`. In comments, `[f]` is also used to denote an `L¹` function. `₁` can be typed as `\1`. ## Main definitions * Let `f : α → β` be a function, where `α` is a `MeasureSpace` and `β` a `NormedAddCommGroup`. Then `HasFiniteIntegral f` means `(∫⁻ a, ‖f a‖₊) < ∞`. * If `β` is moreover a `MeasurableSpace` then `f` is called `Integrable` if `f` is `Measurable` and `HasFiniteIntegral f` holds. ## Implementation notes To prove something for an arbitrary integrable function, a useful theorem is `Integrable.induction` in the file `SetIntegral`. ## Tags integrable, function space, l1 -/ noncomputable section open scoped Classical open Topology ENNReal MeasureTheory NNReal open Set Filter TopologicalSpace ENNReal EMetric MeasureTheory variable {α β γ δ : Type*} {m : MeasurableSpace α} {μ ν : Measure α} [MeasurableSpace δ] variable [NormedAddCommGroup β] variable [NormedAddCommGroup γ] namespace MeasureTheory /-! ### Some results about the Lebesgue integral involving a normed group -/
Mathlib/MeasureTheory/Function/L1Space.lean
66
67
theorem lintegral_nnnorm_eq_lintegral_edist (f : α → β) : ∫⁻ a, ‖f a‖₊ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by
simp only [edist_eq_coe_nnnorm]
/- Copyright (c) 2022 Michael Stoll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Stoll -/ import Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol #align_import number_theory.legendre_symbol.norm_num from "leanprover-community/mathlib"@"e2621d935895abe70071ab828a4ee6e26a52afe4" /-! # A `norm_num` extension for Jacobi and Legendre symbols We extend the `norm_num` tactic so that it can be used to provably compute the value of the Jacobi symbol `J(a | b)` or the Legendre symbol `legendreSym p a` when the arguments are numerals. ## Implementation notes We use the Law of Quadratic Reciprocity for the Jacobi symbol to compute the value of `J(a | b)` efficiently, roughly comparable in effort with the euclidean algorithm for the computation of the gcd of `a` and `b`. More precisely, the computation is done in the following steps. * Use `J(a | 0) = 1` (an artifact of the definition) and `J(a | 1) = 1` to deal with corner cases. * Use `J(a | b) = J(a % b | b)` to reduce to the case that `a` is a natural number. We define a version of the Jacobi symbol restricted to natural numbers for use in the following steps; see `NormNum.jacobiSymNat`. (But we'll continue to write `J(a | b)` in this description.) * Remove powers of two from `b`. This is done via `J(2a | 2b) = 0` and `J(2a+1 | 2b) = J(2a+1 | b)` (another artifact of the definition). * Now `0 ≤ a < b` and `b` is odd. If `b = 1`, then the value is `1`. If `a = 0` (and `b > 1`), then the value is `0`. Otherwise, we remove powers of two from `a` via `J(4a | b) = J(a | b)` and `J(2a | b) = ±J(a | b)`, where the sign is determined by the residue class of `b` mod 8, to reduce to `a` odd. * Once `a` is odd, we use Quadratic Reciprocity (QR) in the form `J(a | b) = ±J(b % a | a)`, where the sign is determined by the residue classes of `a` and `b` mod 4. We are then back in the previous case. We provide customized versions of these results for the various reduction steps, where we encode the residue classes mod 2, mod 4, or mod 8 by using hypotheses like `a % n = b`. In this way, the only divisions we have to compute and prove are the ones occurring in the use of QR above. -/ section Lemmas namespace Mathlib.Meta.NormNum /-- The Jacobi symbol restricted to natural numbers in both arguments. -/ def jacobiSymNat (a b : ℕ) : ℤ := jacobiSym a b #align norm_num.jacobi_sym_nat Mathlib.Meta.NormNum.jacobiSymNat /-! ### API Lemmas We repeat part of the API for `jacobiSym` with `NormNum.jacobiSymNat` and without implicit arguments, in a form that is suitable for constructing proofs in `norm_num`. -/ /-- Base cases: `b = 0`, `b = 1`, `a = 0`, `a = 1`. -/ theorem jacobiSymNat.zero_right (a : ℕ) : jacobiSymNat a 0 = 1 := by rw [jacobiSymNat, jacobiSym.zero_right] #align norm_num.jacobi_sym_nat.zero_right Mathlib.Meta.NormNum.jacobiSymNat.zero_right
Mathlib/Tactic/NormNum/LegendreSymbol.lean
72
73
theorem jacobiSymNat.one_right (a : ℕ) : jacobiSymNat a 1 = 1 := by
rw [jacobiSymNat, jacobiSym.one_right]
/- Copyright (c) 2022 Christopher Hoskin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Christopher Hoskin -/ import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Group.Commute.Defs import Mathlib.Algebra.Ring.Defs import Mathlib.Data.Subtype import Mathlib.Order.Notation #align_import algebra.ring.idempotents from "leanprover-community/mathlib"@"655994e298904d7e5bbd1e18c95defd7b543eb94" /-! # Idempotents This file defines idempotents for an arbitrary multiplication and proves some basic results, including: * `IsIdempotentElem.mul_of_commute`: In a semigroup, the product of two commuting idempotents is an idempotent; * `IsIdempotentElem.one_sub_iff`: In a (non-associative) ring, `p` is an idempotent if and only if `1-p` is an idempotent. * `IsIdempotentElem.pow_succ_eq`: In a monoid `p ^ (n+1) = p` for `p` an idempotent and `n` a natural number. ## Tags projection, idempotent -/ variable {M N S M₀ M₁ R G G₀ : Type*} variable [Mul M] [Monoid N] [Semigroup S] [MulZeroClass M₀] [MulOneClass M₁] [NonAssocRing R] [Group G] [CancelMonoidWithZero G₀] /-- An element `p` is said to be idempotent if `p * p = p` -/ def IsIdempotentElem (p : M) : Prop := p * p = p #align is_idempotent_elem IsIdempotentElem namespace IsIdempotentElem theorem of_isIdempotent [Std.IdempotentOp (α := M) (· * ·)] (a : M) : IsIdempotentElem a := Std.IdempotentOp.idempotent a #align is_idempotent_elem.of_is_idempotent IsIdempotentElem.of_isIdempotent theorem eq {p : M} (h : IsIdempotentElem p) : p * p = p := h #align is_idempotent_elem.eq IsIdempotentElem.eq theorem mul_of_commute {p q : S} (h : Commute p q) (h₁ : IsIdempotentElem p) (h₂ : IsIdempotentElem q) : IsIdempotentElem (p * q) := by rw [IsIdempotentElem, mul_assoc, ← mul_assoc q, ← h.eq, mul_assoc p, h₂.eq, ← mul_assoc, h₁.eq] #align is_idempotent_elem.mul_of_commute IsIdempotentElem.mul_of_commute theorem zero : IsIdempotentElem (0 : M₀) := mul_zero _ #align is_idempotent_elem.zero IsIdempotentElem.zero theorem one : IsIdempotentElem (1 : M₁) := mul_one _ #align is_idempotent_elem.one IsIdempotentElem.one
Mathlib/Algebra/Ring/Idempotents.lean
66
67
theorem one_sub {p : R} (h : IsIdempotentElem p) : IsIdempotentElem (1 - p) := by
rw [IsIdempotentElem, mul_sub, mul_one, sub_mul, one_mul, h.eq, sub_self, sub_zero]
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Yury Kudryashov -/ import Mathlib.Algebra.Order.Archimedean import Mathlib.Order.Filter.AtTopBot import Mathlib.Tactic.GCongr #align_import order.filter.archimedean from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # `Filter.atTop` filter and archimedean (semi)rings/fields In this file we prove that for a linear ordered archimedean semiring `R` and a function `f : α → ℕ`, the function `Nat.cast ∘ f : α → R` tends to `Filter.atTop` along a filter `l` if and only if so does `f`. We also prove that `Nat.cast : ℕ → R` tends to `Filter.atTop` along `Filter.atTop`, as well as version of these two results for `ℤ` (and a ring `R`) and `ℚ` (and a field `R`). -/ variable {α R : Type*} open Filter Set Function @[simp] theorem Nat.comap_cast_atTop [StrictOrderedSemiring R] [Archimedean R] : comap ((↑) : ℕ → R) atTop = atTop := comap_embedding_atTop (fun _ _ => Nat.cast_le) exists_nat_ge #align nat.comap_coe_at_top Nat.comap_cast_atTop theorem tendsto_natCast_atTop_iff [StrictOrderedSemiring R] [Archimedean R] {f : α → ℕ} {l : Filter α} : Tendsto (fun n => (f n : R)) l atTop ↔ Tendsto f l atTop := tendsto_atTop_embedding (fun _ _ => Nat.cast_le) exists_nat_ge #align tendsto_coe_nat_at_top_iff tendsto_natCast_atTop_iff @[deprecated (since := "2024-04-17")] alias tendsto_nat_cast_atTop_iff := tendsto_natCast_atTop_iff theorem tendsto_natCast_atTop_atTop [OrderedSemiring R] [Archimedean R] : Tendsto ((↑) : ℕ → R) atTop atTop := Nat.mono_cast.tendsto_atTop_atTop exists_nat_ge #align tendsto_coe_nat_at_top_at_top tendsto_natCast_atTop_atTop @[deprecated (since := "2024-04-17")] alias tendsto_nat_cast_atTop_atTop := tendsto_natCast_atTop_atTop theorem Filter.Eventually.natCast_atTop [OrderedSemiring R] [Archimedean R] {p : R → Prop} (h : ∀ᶠ (x:R) in atTop, p x) : ∀ᶠ (n:ℕ) in atTop, p n := tendsto_natCast_atTop_atTop.eventually h @[deprecated (since := "2024-04-17")] alias Filter.Eventually.nat_cast_atTop := Filter.Eventually.natCast_atTop @[simp] theorem Int.comap_cast_atTop [StrictOrderedRing R] [Archimedean R] : comap ((↑) : ℤ → R) atTop = atTop := comap_embedding_atTop (fun _ _ => Int.cast_le) fun r => let ⟨n, hn⟩ := exists_nat_ge r; ⟨n, mod_cast hn⟩ #align int.comap_coe_at_top Int.comap_cast_atTop @[simp] theorem Int.comap_cast_atBot [StrictOrderedRing R] [Archimedean R] : comap ((↑) : ℤ → R) atBot = atBot := comap_embedding_atBot (fun _ _ => Int.cast_le) fun r => let ⟨n, hn⟩ := exists_nat_ge (-r) ⟨-n, by simpa [neg_le] using hn⟩ #align int.comap_coe_at_bot Int.comap_cast_atBot theorem tendsto_intCast_atTop_iff [StrictOrderedRing R] [Archimedean R] {f : α → ℤ} {l : Filter α} : Tendsto (fun n => (f n : R)) l atTop ↔ Tendsto f l atTop := by rw [← @Int.comap_cast_atTop R, tendsto_comap_iff]; rfl #align tendsto_coe_int_at_top_iff tendsto_intCast_atTop_iff @[deprecated (since := "2024-04-17")] alias tendsto_int_cast_atTop_iff := tendsto_intCast_atTop_iff
Mathlib/Order/Filter/Archimedean.lean
77
79
theorem tendsto_intCast_atBot_iff [StrictOrderedRing R] [Archimedean R] {f : α → ℤ} {l : Filter α} : Tendsto (fun n => (f n : R)) l atBot ↔ Tendsto f l atBot := by
rw [← @Int.comap_cast_atBot R, tendsto_comap_iff]; rfl
/- 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.CategoryTheory.Subobject.Limits #align_import algebra.homology.image_to_kernel from "leanprover-community/mathlib"@"618ea3d5c99240cd7000d8376924906a148bf9ff" /-! # Image-to-kernel comparison maps Whenever `f : A ⟶ B` and `g : B ⟶ C` satisfy `w : f ≫ g = 0`, we have `image_le_kernel f g w : imageSubobject f ≤ kernelSubobject g` (assuming the appropriate images and kernels exist). `imageToKernel f g w` is the corresponding morphism between objects in `C`. We define `homology' f g w` of such a pair as the cokernel of `imageToKernel f g w`. Note: As part of the transition to the new homology API, `homology` is temporarily renamed `homology'`. It is planned that this definition shall be removed and replaced by `ShortComplex.homology`. -/ universe v u w open CategoryTheory CategoryTheory.Limits variable {ι : Type*} variable {V : Type u} [Category.{v} V] [HasZeroMorphisms V] open scoped Classical noncomputable section section variable {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g] theorem image_le_kernel (w : f ≫ g = 0) : imageSubobject f ≤ kernelSubobject g := imageSubobject_le_mk _ _ (kernel.lift _ _ w) (by simp) #align image_le_kernel image_le_kernel /-- The canonical morphism `imageSubobject f ⟶ kernelSubobject g` when `f ≫ g = 0`. -/ def imageToKernel (w : f ≫ g = 0) : (imageSubobject f : V) ⟶ (kernelSubobject g : V) := Subobject.ofLE _ _ (image_le_kernel _ _ w) #align image_to_kernel imageToKernel instance (w : f ≫ g = 0) : Mono (imageToKernel f g w) := by dsimp only [imageToKernel] infer_instance /-- Prefer `imageToKernel`. -/ @[simp] theorem subobject_ofLE_as_imageToKernel (w : f ≫ g = 0) (h) : Subobject.ofLE (imageSubobject f) (kernelSubobject g) h = imageToKernel f g w := rfl #align subobject_of_le_as_image_to_kernel subobject_ofLE_as_imageToKernel attribute [local instance] ConcreteCategory.instFunLike -- Porting note: removed elementwise attribute which does not seem to be helpful here -- a more suitable lemma is added below @[reassoc (attr := simp)] theorem imageToKernel_arrow (w : f ≫ g = 0) : imageToKernel f g w ≫ (kernelSubobject g).arrow = (imageSubobject f).arrow := by simp [imageToKernel] #align image_to_kernel_arrow imageToKernel_arrow @[simp] lemma imageToKernel_arrow_apply [ConcreteCategory V] (w : f ≫ g = 0) (x : (forget V).obj (Subobject.underlying.obj (imageSubobject f))) : (kernelSubobject g).arrow (imageToKernel f g w x) = (imageSubobject f).arrow x := by rw [← comp_apply, imageToKernel_arrow] -- This is less useful as a `simp` lemma than it initially appears, -- as it "loses" the information the morphism factors through the image. theorem factorThruImageSubobject_comp_imageToKernel (w : f ≫ g = 0) : factorThruImageSubobject f ≫ imageToKernel f g w = factorThruKernelSubobject g f w := by ext simp #align factor_thru_image_subobject_comp_image_to_kernel factorThruImageSubobject_comp_imageToKernel end section variable {A B C : V} (f : A ⟶ B) (g : B ⟶ C) @[simp] theorem imageToKernel_zero_left [HasKernels V] [HasZeroObject V] {w} : imageToKernel (0 : A ⟶ B) g w = 0 := by ext simp #align image_to_kernel_zero_left imageToKernel_zero_left
Mathlib/Algebra/Homology/ImageToKernel.lean
101
105
theorem imageToKernel_zero_right [HasImages V] {w} : imageToKernel f (0 : B ⟶ C) w = (imageSubobject f).arrow ≫ inv (kernelSubobject (0 : B ⟶ C)).arrow := by
ext simp
/- Copyright (c) 2021 Yourong Zang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yourong Zang -/ import Mathlib.Analysis.Calculus.Conformal.NormedSpace import Mathlib.Analysis.InnerProductSpace.ConformalLinearMap #align_import analysis.calculus.conformal.inner_product from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Conformal maps between inner product spaces A function between inner product spaces which has a derivative at `x` is conformal at `x` iff the derivative preserves inner products up to a scalar multiple. -/ noncomputable section variable {E F : Type*} variable [NormedAddCommGroup E] [NormedAddCommGroup F] variable [InnerProductSpace ℝ E] [InnerProductSpace ℝ F] open RealInnerProductSpace /-- A real differentiable map `f` is conformal at point `x` if and only if its differential `fderiv ℝ f x` at that point scales every inner product by a positive scalar. -/
Mathlib/Analysis/Calculus/Conformal/InnerProduct.lean
29
31
theorem conformalAt_iff' {f : E → F} {x : E} : ConformalAt f x ↔ ∃ c : ℝ, 0 < c ∧ ∀ u v : E, ⟪fderiv ℝ f x u, fderiv ℝ f x v⟫ = c * ⟪u, v⟫ := by
rw [conformalAt_iff_isConformalMap_fderiv, isConformalMap_iff]
/- 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
Mathlib/LinearAlgebra/Matrix/Hermitian.lean
74
76
theorem IsHermitian.transpose {A : Matrix n n α} (h : A.IsHermitian) : Aᵀ.IsHermitian := by
rw [IsHermitian, conjTranspose, transpose_map] exact congr_arg Matrix.transpose h
/- Copyright (c) 2021 Vladimir Goryachev. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Vladimir Goryachev, Kyle Miller, Scott Morrison, Eric Rodriguez -/ import Mathlib.SetTheory.Cardinal.Basic import Mathlib.Tactic.Ring #align_import data.nat.count from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Counting on ℕ This file defines the `count` function, which gives, for any predicate on the natural numbers, "how many numbers under `k` satisfy this predicate?". We then prove several expected lemmas about `count`, relating it to the cardinality of other objects, and helping to evaluate it for specific `k`. -/ open Finset namespace Nat variable (p : ℕ → Prop) section Count variable [DecidablePred p] /-- Count the number of naturals `k < n` satisfying `p k`. -/ def count (n : ℕ) : ℕ := (List.range n).countP p #align nat.count Nat.count @[simp] theorem count_zero : count p 0 = 0 := by rw [count, List.range_zero, List.countP, List.countP.go] #align nat.count_zero Nat.count_zero /-- A fintype instance for the set relevant to `Nat.count`. Locally an instance in locale `count` -/ def CountSet.fintype (n : ℕ) : Fintype { i // i < n ∧ p i } := by apply Fintype.ofFinset ((Finset.range n).filter p) intro x rw [mem_filter, mem_range] rfl #align nat.count_set.fintype Nat.CountSet.fintype scoped[Count] attribute [instance] Nat.CountSet.fintype open Count theorem count_eq_card_filter_range (n : ℕ) : count p n = ((range n).filter p).card := by rw [count, List.countP_eq_length_filter] rfl #align nat.count_eq_card_filter_range Nat.count_eq_card_filter_range /-- `count p n` can be expressed as the cardinality of `{k // k < n ∧ p k}`. -/ theorem count_eq_card_fintype (n : ℕ) : count p n = Fintype.card { k : ℕ // k < n ∧ p k } := by rw [count_eq_card_filter_range, ← Fintype.card_ofFinset, ← CountSet.fintype] rfl #align nat.count_eq_card_fintype Nat.count_eq_card_fintype
Mathlib/Data/Nat/Count.lean
65
66
theorem count_succ (n : ℕ) : count p (n + 1) = count p n + if p n then 1 else 0 := by
split_ifs with h <;> simp [count, List.range_succ, h]
/- Copyright (c) 2024 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.LinearAlgebra.Dimension.Free import Mathlib.LinearAlgebra.Dimension.Finite import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition /-! # Some results on the ranks of subalgebras This file contains some results on the ranks of subalgebras, which are corollaries of `rank_mul_rank`. Since their proof essentially depends on the fact that a non-trivial commutative ring satisfies strong rank condition, we put them into a separate file. -/ open FiniteDimensional namespace Subalgebra variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] (A B : Subalgebra R S) [Module.Free R A] [Module.Free R B] [Module.Free A (Algebra.adjoin A (B : Set S))] [Module.Free B (Algebra.adjoin B (A : Set S))]
Mathlib/Algebra/Algebra/Subalgebra/Rank.lean
30
41
theorem rank_sup_eq_rank_left_mul_rank_of_free : Module.rank R ↥(A ⊔ B) = Module.rank R A * Module.rank A (Algebra.adjoin A (B : Set S)) := by
rcases subsingleton_or_nontrivial R with _ | _ · haveI := Module.subsingleton R S; simp nontriviality S using rank_subsingleton' letI : Algebra A (Algebra.adjoin A (B : Set S)) := Subalgebra.algebra _ letI : SMul A (Algebra.adjoin A (B : Set S)) := Algebra.toSMul haveI : IsScalarTower R A (Algebra.adjoin A (B : Set S)) := IsScalarTower.of_algebraMap_eq (congrFun rfl) rw [rank_mul_rank R A (Algebra.adjoin A (B : Set S))] change _ = Module.rank R ((Algebra.adjoin A (B : Set S)).restrictScalars R) rw [Algebra.restrictScalars_adjoin]; rfl
/- Copyright (c) 2021 David Wärn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Wärn, Antoine Labelle, Rémi Bottinelli -/ import Mathlib.Combinatorics.Quiver.Path import Mathlib.Combinatorics.Quiver.Push #align_import combinatorics.quiver.symmetric from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2" /-! ## Symmetric quivers and arrow reversal This file contains constructions related to symmetric quivers: * `Symmetrify V` adds formal inverses to each arrow of `V`. * `HasReverse` is the class of quivers where each arrow has an assigned formal inverse. * `HasInvolutiveReverse` extends `HasReverse` by requiring that the reverse of the reverse is equal to the original arrow. * `Prefunctor.PreserveReverse` is the class of prefunctors mapping reverses to reverses. * `Symmetrify.of`, `Symmetrify.lift`, and the associated lemmas witness the universal property of `Symmetrify`. -/ universe v u w v' namespace Quiver /-- A type synonym for the symmetrized quiver (with an arrow both ways for each original arrow). NB: this does not work for `Prop`-valued quivers. It requires `[Quiver.{v+1} V]`. -/ -- Porting note: no hasNonemptyInstance linter yet def Symmetrify (V : Type*) := V #align quiver.symmetrify Quiver.Symmetrify instance symmetrifyQuiver (V : Type u) [Quiver V] : Quiver (Symmetrify V) := ⟨fun a b : V ↦ Sum (a ⟶ b) (b ⟶ a)⟩ variable (U V W : Type*) [Quiver.{u + 1} U] [Quiver.{v + 1} V] [Quiver.{w + 1} W] /-- A quiver `HasReverse` if we can reverse an arrow `p` from `a` to `b` to get an arrow `p.reverse` from `b` to `a`. -/ class HasReverse where /-- the map which sends an arrow to its reverse -/ reverse' : ∀ {a b : V}, (a ⟶ b) → (b ⟶ a) #align quiver.has_reverse Quiver.HasReverse /-- Reverse the direction of an arrow. -/ def reverse {V} [Quiver.{v + 1} V] [HasReverse V] {a b : V} : (a ⟶ b) → (b ⟶ a) := HasReverse.reverse' #align quiver.reverse Quiver.reverse /-- A quiver `HasInvolutiveReverse` if reversing twice is the identity. -/ class HasInvolutiveReverse extends HasReverse V where /-- `reverse` is involutive -/ inv' : ∀ {a b : V} (f : a ⟶ b), reverse (reverse f) = f #align quiver.has_involutive_reverse Quiver.HasInvolutiveReverse variable {U V W} @[simp]
Mathlib/Combinatorics/Quiver/Symmetric.lean
61
62
theorem reverse_reverse [h : HasInvolutiveReverse V] {a b : V} (f : a ⟶ b) : reverse (reverse f) = f := by
apply h.inv'
/- Copyright (c) 2022 Chris Birkbeck. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Birkbeck -/ import Mathlib.NumberTheory.ModularForms.SlashActions #align_import number_theory.modular_forms.slash_invariant_forms from "leanprover-community/mathlib"@"738054fa93d43512da144ec45ce799d18fd44248" /-! # Slash invariant forms This file defines functions that are invariant under a `SlashAction` which forms the basis for defining `ModularForm` and `CuspForm`. We prove several instances for such spaces, in particular that they form a module. -/ open Complex UpperHalfPlane open scoped UpperHalfPlane ModularForm noncomputable section local notation "GL(" n ", " R ")" "⁺" => Matrix.GLPos (Fin n) R local notation "SL(" n ", " R ")" => Matrix.SpecialLinearGroup (Fin n) R local notation:1024 "↑ₘ" A:1024 => (((A : GL(2, ℝ)⁺) : GL (Fin 2) ℝ) : Matrix (Fin 2) (Fin 2) _) -- like `↑ₘ`, but allows the user to specify the ring `R`. Useful to help Lean elaborate. local notation:1024 "↑ₘ[" R "]" A:1024 => ((A : GL (Fin 2) R) : Matrix (Fin 2) (Fin 2) R) section SlashInvariantForms open ModularForm variable (F : Type*) (Γ : outParam <| Subgroup SL(2, ℤ)) (k : outParam ℤ) /-- Functions `ℍ → ℂ` that are invariant under the `SlashAction`. -/ structure SlashInvariantForm where toFun : ℍ → ℂ slash_action_eq' : ∀ γ : Γ, toFun ∣[k] γ = toFun #align slash_invariant_form SlashInvariantForm /-- `SlashInvariantFormClass F Γ k` asserts `F` is a type of bundled functions that are invariant under the `SlashAction`. -/ class SlashInvariantFormClass [FunLike F ℍ ℂ] : Prop where slash_action_eq : ∀ (f : F) (γ : Γ), (f : ℍ → ℂ) ∣[k] γ = f #align slash_invariant_form_class SlashInvariantFormClass instance (priority := 100) SlashInvariantForm.funLike : FunLike (SlashInvariantForm Γ k) ℍ ℂ where coe := SlashInvariantForm.toFun coe_injective' f g h := by cases f; cases g; congr instance (priority := 100) SlashInvariantFormClass.slashInvariantForm : SlashInvariantFormClass (SlashInvariantForm Γ k) Γ k where slash_action_eq := SlashInvariantForm.slash_action_eq' #align slash_invariant_form_class.slash_invariant_form SlashInvariantFormClass.slashInvariantForm variable {F Γ k} @[simp] theorem SlashInvariantForm.toFun_eq_coe {f : SlashInvariantForm Γ k} : f.toFun = (f : ℍ → ℂ) := rfl #align slash_invariant_form_to_fun_eq_coe SlashInvariantForm.toFun_eq_coe @[simp] theorem SlashInvariantForm.coe_mk (f : ℍ → ℂ) (hf : ∀ γ : Γ, f ∣[k] γ = f) : ⇑(mk f hf) = f := rfl @[ext] theorem SlashInvariantForm.ext {f g : SlashInvariantForm Γ k} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h #align slash_invariant_form_ext SlashInvariantForm.ext /-- Copy of a `SlashInvariantForm` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ protected def SlashInvariantForm.copy (f : SlashInvariantForm Γ k) (f' : ℍ → ℂ) (h : f' = ⇑f) : SlashInvariantForm Γ k where toFun := f' slash_action_eq' := h.symm ▸ f.slash_action_eq' #align slash_invariant_form.copy SlashInvariantForm.copy end SlashInvariantForms namespace SlashInvariantForm open SlashInvariantForm variable {F : Type*} {Γ : Subgroup SL(2, ℤ)} {k : ℤ} [FunLike F ℍ ℂ] -- @[simp] -- Porting note: simpNF says LHS simplifies to something more complex theorem slash_action_eqn [SlashInvariantFormClass F Γ k] (f : F) (γ : Γ) : ↑f ∣[k] γ = ⇑f := SlashInvariantFormClass.slash_action_eq f γ #align slash_invariant_form.slash_action_eqn SlashInvariantForm.slash_action_eqn
Mathlib/NumberTheory/ModularForms/SlashInvariantForms.lean
100
102
theorem slash_action_eqn' (k : ℤ) (Γ : Subgroup SL(2, ℤ)) [SlashInvariantFormClass F Γ k] (f : F) (γ : Γ) (z : ℍ) : f (γ • z) = ((↑ₘ[ℤ] γ 1 0 : ℂ) * z + (↑ₘ[ℤ] γ 1 1 : ℂ)) ^ k * f z := by
rw [← ModularForm.slash_action_eq'_iff, slash_action_eqn]
/- Copyright (c) 2019 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.FieldTheory.Finiteness import Mathlib.LinearAlgebra.Dimension.FreeAndStrongRankCondition import Mathlib.LinearAlgebra.Dimension.DivisionRing #align_import linear_algebra.finite_dimensional from "leanprover-community/mathlib"@"e95e4f92c8f8da3c7f693c3ec948bcf9b6683f51" /-! # Finite dimensional vector spaces Definition and basic properties of finite dimensional vector spaces, of their dimensions, and of linear maps on such spaces. ## Main definitions Assume `V` is a vector space over a division ring `K`. There are (at least) three equivalent definitions of finite-dimensionality of `V`: - it admits a finite basis. - it is finitely generated. - it is noetherian, i.e., every subspace is finitely generated. We introduce a typeclass `FiniteDimensional K V` capturing this property. For ease of transfer of proof, it is defined using the second point of view, i.e., as `Finite`. However, we prove that all these points of view are equivalent, with the following lemmas (in the namespace `FiniteDimensional`): - `fintypeBasisIndex` states that a finite-dimensional vector space has a finite basis - `FiniteDimensional.finBasis` and `FiniteDimensional.finBasisOfFinrankEq` are bases for finite dimensional vector spaces, where the index type is `Fin` - `of_fintype_basis` states that the existence of a basis indexed by a finite type implies finite-dimensionality - `of_finite_basis` states that the existence of a basis indexed by a finite set implies finite-dimensionality - `IsNoetherian.iff_fg` states that the space is finite-dimensional if and only if it is noetherian We make use of `finrank`, the dimension of a finite dimensional space, returning a `Nat`, as opposed to `Module.rank`, which returns a `Cardinal`. When the space has infinite dimension, its `finrank` is by convention set to `0`. `finrank` is not defined using `FiniteDimensional`. For basic results that do not need the `FiniteDimensional` class, import `Mathlib.LinearAlgebra.Finrank`. Preservation of finite-dimensionality and formulas for the dimension are given for - submodules - quotients (for the dimension of a quotient, see `finrank_quotient_add_finrank`) - linear equivs, in `LinearEquiv.finiteDimensional` - image under a linear map (the rank-nullity formula is in `finrank_range_add_finrank_ker`) Basic properties of linear maps of a finite-dimensional vector space are given. Notably, the equivalence of injectivity and surjectivity is proved in `LinearMap.injective_iff_surjective`, and the equivalence between left-inverse and right-inverse in `LinearMap.mul_eq_one_comm` and `LinearMap.comp_eq_id_comm`. ## Implementation notes Most results are deduced from the corresponding results for the general dimension (as a cardinal), in `Mathlib.LinearAlgebra.Dimension`. Not all results have been ported yet. You should not assume that there has been any effort to state lemmas as generally as possible. Plenty of the results hold for general fg modules or notherian modules, and they can be found in `Mathlib.LinearAlgebra.FreeModule.Finite.Rank` and `Mathlib.RingTheory.Noetherian`. -/ universe u v v' w open Cardinal Submodule Module Function /-- `FiniteDimensional` vector spaces are defined to be finite modules. Use `FiniteDimensional.of_fintype_basis` to prove finite dimension from another definition. -/ abbrev FiniteDimensional (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V] := Module.Finite K V #align finite_dimensional FiniteDimensional variable {K : Type u} {V : Type v} namespace FiniteDimensional open IsNoetherian section DivisionRing variable [DivisionRing K] [AddCommGroup V] [Module K V] {V₂ : Type v'} [AddCommGroup V₂] [Module K V₂] /-- If the codomain of an injective linear map is finite dimensional, the domain must be as well. -/ theorem of_injective (f : V →ₗ[K] V₂) (w : Function.Injective f) [FiniteDimensional K V₂] : FiniteDimensional K V := have : IsNoetherian K V₂ := IsNoetherian.iff_fg.mpr ‹_› Module.Finite.of_injective f w #align finite_dimensional.of_injective FiniteDimensional.of_injective /-- If the domain of a surjective linear map is finite dimensional, the codomain must be as well. -/ theorem of_surjective (f : V →ₗ[K] V₂) (w : Function.Surjective f) [FiniteDimensional K V] : FiniteDimensional K V₂ := Module.Finite.of_surjective f w #align finite_dimensional.of_surjective FiniteDimensional.of_surjective variable (K V) instance finiteDimensional_pi {ι : Type*} [Finite ι] : FiniteDimensional K (ι → K) := Finite.pi #align finite_dimensional.finite_dimensional_pi FiniteDimensional.finiteDimensional_pi instance finiteDimensional_pi' {ι : Type*} [Finite ι] (M : ι → Type*) [∀ i, AddCommGroup (M i)] [∀ i, Module K (M i)] [∀ i, FiniteDimensional K (M i)] : FiniteDimensional K (∀ i, M i) := Finite.pi #align finite_dimensional.finite_dimensional_pi' FiniteDimensional.finiteDimensional_pi' /-- A finite dimensional vector space over a finite field is finite -/ noncomputable def fintypeOfFintype [Fintype K] [FiniteDimensional K V] : Fintype V := Module.fintypeOfFintype (@finsetBasis K V _ _ _ (iff_fg.2 inferInstance)) #align finite_dimensional.fintype_of_fintype FiniteDimensional.fintypeOfFintype
Mathlib/LinearAlgebra/FiniteDimensional.lean
123
126
theorem finite_of_finite [Finite K] [FiniteDimensional K V] : Finite V := by
cases nonempty_fintype K haveI := fintypeOfFintype K V infer_instance
/- Copyright (c) 2024 Sophie Morel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sophie Morel -/ import Mathlib.Analysis.NormedSpace.Multilinear.Basic import Mathlib.LinearAlgebra.PiTensorProduct /-! # Projective seminorm on the tensor of a finite family of normed spaces. Let `𝕜` be a nontrivially normed field and `E` be a family of normed `𝕜`-vector spaces `Eᵢ`, indexed by a finite type `ι`. We define a seminorm on `⨂[𝕜] i, Eᵢ`, which we call the "projective seminorm". For `x` an element of `⨂[𝕜] i, Eᵢ`, its projective seminorm is the infimum over all expressions of `x` as `∑ j, ⨂ₜ[𝕜] mⱼ i` (with the `mⱼ` ∈ `Π i, Eᵢ`) of `∑ j, Π i, ‖mⱼ i‖`. In particular, every norm `‖.‖` on `⨂[𝕜] i, Eᵢ` satisfying `‖⨂ₜ[𝕜] i, m i‖ ≤ Π i, ‖m i‖` for every `m` in `Π i, Eᵢ` is bounded above by the projective seminorm. ## Main definitions * `PiTensorProduct.projectiveSeminorm`: The projective seminorm on `⨂[𝕜] i, Eᵢ`. ## Main results * `PiTensorProduct.norm_eval_le_projectiveSeminorm`: If `f` is a continuous multilinear map on `E = Π i, Eᵢ` and `x` is in `⨂[𝕜] i, Eᵢ`, then `‖f.lift x‖ ≤ projectiveSeminorm x * ‖f‖`. ## TODO * If the base field is `ℝ` or `ℂ` (or more generally if the injection of `Eᵢ` into its bidual is an isometry for every `i`), then we have `projectiveSeminorm ⨂ₜ[𝕜] i, mᵢ = Π i, ‖mᵢ‖`. * The functoriality. -/ universe uι u𝕜 uE uF variable {ι : Type uι} [Fintype ι] variable {𝕜 : Type u𝕜} [NontriviallyNormedField 𝕜] variable {E : ι → Type uE} [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] variable {F : Type uF} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F] open scoped TensorProduct namespace PiTensorProduct /-- A lift of the projective seminorm to `FreeAddMonoid (𝕜 × Π i, Eᵢ)`, useful to prove the properties of `projectiveSeminorm`. -/ def projectiveSeminormAux : FreeAddMonoid (𝕜 × Π i, E i) → ℝ := List.sum ∘ (List.map (fun p ↦ ‖p.1‖ * ∏ i, ‖p.2 i‖)) theorem projectiveSeminormAux_nonneg (p : FreeAddMonoid (𝕜 × Π i, E i)) : 0 ≤ projectiveSeminormAux p := by simp only [projectiveSeminormAux, Function.comp_apply] refine List.sum_nonneg ?_ intro a simp only [Multiset.map_coe, Multiset.mem_coe, List.mem_map, Prod.exists, forall_exists_index, and_imp] intro x m _ h rw [← h] exact mul_nonneg (norm_nonneg _) (Finset.prod_nonneg (fun _ _ ↦ norm_nonneg _))
Mathlib/Analysis/NormedSpace/PiTensorProduct/ProjectiveSeminorm.lean
66
71
theorem projectiveSeminormAux_add_le (p q : FreeAddMonoid (𝕜 × Π i, E i)) : projectiveSeminormAux (p + q) ≤ projectiveSeminormAux p + projectiveSeminormAux q := by
simp only [projectiveSeminormAux, Function.comp_apply, Multiset.map_coe, Multiset.sum_coe] erw [List.map_append] rw [List.sum_append] rfl
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, E. W. Ayers -/ import Mathlib.CategoryTheory.Comma.Over import Mathlib.CategoryTheory.Limits.Shapes.Pullbacks import Mathlib.CategoryTheory.Yoneda import Mathlib.Data.Set.Lattice import Mathlib.Order.CompleteLattice #align_import category_theory.sites.sieves from "leanprover-community/mathlib"@"239d882c4fb58361ee8b3b39fb2091320edef10a" /-! # Theory of sieves - For an object `X` of a category `C`, a `Sieve X` is a set of morphisms to `X` which is closed under left-composition. - The complete lattice structure on sieves is given, as well as the Galois insertion given by downward-closing. - A `Sieve X` (functorially) induces a presheaf on `C` together with a monomorphism to the yoneda embedding of `X`. ## Tags sieve, pullback -/ universe v₁ v₂ v₃ u₁ u₂ u₃ namespace CategoryTheory open Category Limits variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] (F : C ⥤ D) variable {X Y Z : C} (f : Y ⟶ X) /-- A set of arrows all with codomain `X`. -/ def Presieve (X : C) := ∀ ⦃Y⦄, Set (Y ⟶ X)-- deriving CompleteLattice #align category_theory.presieve CategoryTheory.Presieve instance : CompleteLattice (Presieve X) := by dsimp [Presieve] infer_instance namespace Presieve noncomputable instance : Inhabited (Presieve X) := ⟨⊤⟩ /-- The full subcategory of the over category `C/X` consisting of arrows which belong to a presieve on `X`. -/ abbrev category {X : C} (P : Presieve X) := FullSubcategory fun f : Over X => P f.hom /-- Construct an object of `P.category`. -/ abbrev categoryMk {X : C} (P : Presieve X) {Y : C} (f : Y ⟶ X) (hf : P f) : P.category := ⟨Over.mk f, hf⟩ /-- Given a sieve `S` on `X : C`, its associated diagram `S.diagram` is defined to be the natural functor from the full subcategory of the over category `C/X` consisting of arrows in `S` to `C`. -/ abbrev diagram (S : Presieve X) : S.category ⥤ C := fullSubcategoryInclusion _ ⋙ Over.forget X #align category_theory.presieve.diagram CategoryTheory.Presieve.diagram /-- Given a sieve `S` on `X : C`, its associated cocone `S.cocone` is defined to be the natural cocone over the diagram defined above with cocone point `X`. -/ abbrev cocone (S : Presieve X) : Cocone S.diagram := (Over.forgetCocone X).whisker (fullSubcategoryInclusion _) #align category_theory.presieve.cocone CategoryTheory.Presieve.cocone /-- Given a set of arrows `S` all with codomain `X`, and a set of arrows with codomain `Y` for each `f : Y ⟶ X` in `S`, produce a set of arrows with codomain `X`: `{ g ≫ f | (f : Y ⟶ X) ∈ S, (g : Z ⟶ Y) ∈ R f }`. -/ def bind (S : Presieve X) (R : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → Presieve Y) : Presieve X := fun Z h => ∃ (Y : C) (g : Z ⟶ Y) (f : Y ⟶ X) (H : S f), R H g ∧ g ≫ f = h #align category_theory.presieve.bind CategoryTheory.Presieve.bind @[simp] theorem bind_comp {S : Presieve X} {R : ∀ ⦃Y : C⦄ ⦃f : Y ⟶ X⦄, S f → Presieve Y} {g : Z ⟶ Y} (h₁ : S f) (h₂ : R h₁ g) : bind S R (g ≫ f) := ⟨_, _, _, h₁, h₂, rfl⟩ #align category_theory.presieve.bind_comp CategoryTheory.Presieve.bind_comp -- Porting note: it seems the definition of `Presieve` must be unfolded in order to define -- this inductive type, it was thus renamed `singleton'` -- Note we can't make this into `HasSingleton` because of the out-param. /-- The singleton presieve. -/ inductive singleton' : ⦃Y : C⦄ → (Y ⟶ X) → Prop | mk : singleton' f /-- The singleton presieve. -/ def singleton : Presieve X := singleton' f lemma singleton.mk {f : Y ⟶ X} : singleton f f := singleton'.mk #align category_theory.presieve.singleton CategoryTheory.Presieve.singleton @[simp]
Mathlib/CategoryTheory/Sites/Sieves.lean
104
109
theorem singleton_eq_iff_domain (f g : Y ⟶ X) : singleton f g ↔ f = g := by
constructor · rintro ⟨a, rfl⟩ rfl · rintro rfl apply singleton.mk
/- 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, Jeremy Avigad, Yury Kudryashov -/ import Mathlib.Order.Filter.Cofinite import Mathlib.Order.ZornAtoms #align_import order.filter.ultrafilter from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # Ultrafilters An ultrafilter is a minimal (maximal in the set order) proper filter. In this file we define * `Ultrafilter.of`: an ultrafilter that is less than or equal to a given filter; * `Ultrafilter`: subtype of ultrafilters; * `pure x : Ultrafilter α`: `pure x` as an `Ultrafilter`; * `Ultrafilter.map`, `Ultrafilter.bind`, `Ultrafilter.comap` : operations on ultrafilters; * `hyperfilter`: the ultrafilter extending the cofinite filter. -/ universe u v variable {α : Type u} {β : Type v} {γ : Type*} open Set Filter Function open scoped Classical open Filter /-- `Filter α` is an atomic type: for every filter there exists an ultrafilter that is less than or equal to this filter. -/ instance : IsAtomic (Filter α) := IsAtomic.of_isChain_bounded fun c hc hne hb => ⟨sInf c, (sInf_neBot_of_directed' hne (show IsChain (· ≥ ·) c from hc.symm).directedOn hb).ne, fun _ hx => sInf_le hx⟩ /-- An ultrafilter is a minimal (maximal in the set order) proper filter. -/ structure Ultrafilter (α : Type*) extends Filter α where /-- An ultrafilter is nontrivial. -/ protected neBot' : NeBot toFilter /-- If `g` is a nontrivial filter that is less than or equal to an ultrafilter, then it is greater than or equal to the ultrafilter. -/ protected le_of_le : ∀ g, Filter.NeBot g → g ≤ toFilter → toFilter ≤ g #align ultrafilter Ultrafilter namespace Ultrafilter variable {f g : Ultrafilter α} {s t : Set α} {p q : α → Prop} attribute [coe] Ultrafilter.toFilter instance : CoeTC (Ultrafilter α) (Filter α) := ⟨Ultrafilter.toFilter⟩ instance : Membership (Set α) (Ultrafilter α) := ⟨fun s f => s ∈ (f : Filter α)⟩ theorem unique (f : Ultrafilter α) {g : Filter α} (h : g ≤ f) (hne : NeBot g := by infer_instance) : g = f := le_antisymm h <| f.le_of_le g hne h #align ultrafilter.unique Ultrafilter.unique instance neBot (f : Ultrafilter α) : NeBot (f : Filter α) := f.neBot' #align ultrafilter.ne_bot Ultrafilter.neBot protected theorem isAtom (f : Ultrafilter α) : IsAtom (f : Filter α) := ⟨f.neBot.ne, fun _ hgf => by_contra fun hg => hgf.ne <| f.unique hgf.le ⟨hg⟩⟩ #align ultrafilter.is_atom Ultrafilter.isAtom @[simp, norm_cast] theorem mem_coe : s ∈ (f : Filter α) ↔ s ∈ f := Iff.rfl #align ultrafilter.mem_coe Ultrafilter.mem_coe theorem coe_injective : Injective ((↑) : Ultrafilter α → Filter α) | ⟨f, h₁, h₂⟩, ⟨g, _, _⟩, _ => by congr #align ultrafilter.coe_injective Ultrafilter.coe_injective theorem eq_of_le {f g : Ultrafilter α} (h : (f : Filter α) ≤ g) : f = g := coe_injective (g.unique h) #align ultrafilter.eq_of_le Ultrafilter.eq_of_le @[simp, norm_cast] theorem coe_le_coe {f g : Ultrafilter α} : (f : Filter α) ≤ g ↔ f = g := ⟨fun h => eq_of_le h, fun h => h ▸ le_rfl⟩ #align ultrafilter.coe_le_coe Ultrafilter.coe_le_coe @[simp, norm_cast] theorem coe_inj : (f : Filter α) = g ↔ f = g := coe_injective.eq_iff #align ultrafilter.coe_inj Ultrafilter.coe_inj @[ext] theorem ext ⦃f g : Ultrafilter α⦄ (h : ∀ s, s ∈ f ↔ s ∈ g) : f = g := coe_injective <| Filter.ext h #align ultrafilter.ext Ultrafilter.ext theorem le_of_inf_neBot (f : Ultrafilter α) {g : Filter α} (hg : NeBot (↑f ⊓ g)) : ↑f ≤ g := le_of_inf_eq (f.unique inf_le_left hg) #align ultrafilter.le_of_inf_ne_bot Ultrafilter.le_of_inf_neBot theorem le_of_inf_neBot' (f : Ultrafilter α) {g : Filter α} (hg : NeBot (g ⊓ f)) : ↑f ≤ g := f.le_of_inf_neBot <| by rwa [inf_comm] #align ultrafilter.le_of_inf_ne_bot' Ultrafilter.le_of_inf_neBot' theorem inf_neBot_iff {f : Ultrafilter α} {g : Filter α} : NeBot (↑f ⊓ g) ↔ ↑f ≤ g := ⟨le_of_inf_neBot f, fun h => (inf_of_le_left h).symm ▸ f.neBot⟩ #align ultrafilter.inf_ne_bot_iff Ultrafilter.inf_neBot_iff
Mathlib/Order/Filter/Ultrafilter.lean
115
116
theorem disjoint_iff_not_le {f : Ultrafilter α} {g : Filter α} : Disjoint (↑f) g ↔ ¬↑f ≤ g := by
rw [← inf_neBot_iff, neBot_iff, Ne, not_not, disjoint_iff]
/- Copyright (c) 2021 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker -/ import Mathlib.Topology.ContinuousOn #align_import topology.algebra.order.left_right from "leanprover-community/mathlib"@"bcfa726826abd57587355b4b5b7e78ad6527b7e4" /-! # Left and right continuity In this file we prove a few lemmas about left and right continuous functions: * `continuousWithinAt_Ioi_iff_Ici`: two definitions of right continuity (with `(a, ∞)` and with `[a, ∞)`) are equivalent; * `continuousWithinAt_Iio_iff_Iic`: two definitions of left continuity (with `(-∞, a)` and with `(-∞, a]`) are equivalent; * `continuousAt_iff_continuous_left_right`, `continuousAt_iff_continuous_left'_right'` : a function is continuous at `a` if and only if it is left and right continuous at `a`. ## Tags left continuous, right continuous -/ open Set Filter Topology section Preorder variable {α : Type*} [TopologicalSpace α] [Preorder α] lemma frequently_lt_nhds (a : α) [NeBot (𝓝[<] a)] : ∃ᶠ x in 𝓝 a, x < a := frequently_iff_neBot.2 ‹_› lemma frequently_gt_nhds (a : α) [NeBot (𝓝[>] a)] : ∃ᶠ x in 𝓝 a, a < x := frequently_iff_neBot.2 ‹_› theorem Filter.Eventually.exists_lt {a : α} [NeBot (𝓝[<] a)] {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∃ b < a, p b := ((frequently_lt_nhds a).and_eventually h).exists #align filter.eventually.exists_lt Filter.Eventually.exists_lt theorem Filter.Eventually.exists_gt {a : α} [NeBot (𝓝[>] a)] {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∃ b > a, p b := ((frequently_gt_nhds a).and_eventually h).exists #align filter.eventually.exists_gt Filter.Eventually.exists_gt theorem nhdsWithin_Ici_neBot {a b : α} (H₂ : a ≤ b) : NeBot (𝓝[Ici a] b) := nhdsWithin_neBot_of_mem H₂ #align nhds_within_Ici_ne_bot nhdsWithin_Ici_neBot instance nhdsWithin_Ici_self_neBot (a : α) : NeBot (𝓝[≥] a) := nhdsWithin_Ici_neBot (le_refl a) #align nhds_within_Ici_self_ne_bot nhdsWithin_Ici_self_neBot theorem nhdsWithin_Iic_neBot {a b : α} (H : a ≤ b) : NeBot (𝓝[Iic b] a) := nhdsWithin_neBot_of_mem H #align nhds_within_Iic_ne_bot nhdsWithin_Iic_neBot instance nhdsWithin_Iic_self_neBot (a : α) : NeBot (𝓝[≤] a) := nhdsWithin_Iic_neBot (le_refl a) #align nhds_within_Iic_self_ne_bot nhdsWithin_Iic_self_neBot theorem nhds_left'_le_nhds_ne (a : α) : 𝓝[<] a ≤ 𝓝[≠] a := nhdsWithin_mono a fun _ => ne_of_lt #align nhds_left'_le_nhds_ne nhds_left'_le_nhds_ne theorem nhds_right'_le_nhds_ne (a : α) : 𝓝[>] a ≤ 𝓝[≠] a := nhdsWithin_mono a fun _ => ne_of_gt #align nhds_right'_le_nhds_ne nhds_right'_le_nhds_ne -- TODO: add instances for `NeBot (𝓝[<] x)` on (indexed) product types lemma IsAntichain.interior_eq_empty [∀ x : α, (𝓝[<] x).NeBot] {s : Set α} (hs : IsAntichain (· ≤ ·) s) : interior s = ∅ := by refine eq_empty_of_forall_not_mem fun x hx ↦ ?_ have : ∀ᶠ y in 𝓝 x, y ∈ s := mem_interior_iff_mem_nhds.1 hx rcases this.exists_lt with ⟨y, hyx, hys⟩ exact hs hys (interior_subset hx) hyx.ne hyx.le #align is_antichain.interior_eq_empty IsAntichain.interior_eq_empty lemma IsAntichain.interior_eq_empty' [∀ x : α, (𝓝[>] x).NeBot] {s : Set α} (hs : IsAntichain (· ≤ ·) s) : interior s = ∅ := have : ∀ x : αᵒᵈ, NeBot (𝓝[<] x) := ‹_› hs.to_dual.interior_eq_empty end Preorder section PartialOrder variable {α β : Type*} [TopologicalSpace α] [PartialOrder α] [TopologicalSpace β] theorem continuousWithinAt_Ioi_iff_Ici {a : α} {f : α → β} : ContinuousWithinAt f (Ioi a) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [← Ici_diff_left, continuousWithinAt_diff_self] #align continuous_within_at_Ioi_iff_Ici continuousWithinAt_Ioi_iff_Ici theorem continuousWithinAt_Iio_iff_Iic {a : α} {f : α → β} : ContinuousWithinAt f (Iio a) a ↔ ContinuousWithinAt f (Iic a) a := @continuousWithinAt_Ioi_iff_Ici αᵒᵈ _ _ _ _ _ f #align continuous_within_at_Iio_iff_Iic continuousWithinAt_Iio_iff_Iic end PartialOrder section TopologicalSpace variable {α β : Type*} [TopologicalSpace α] [LinearOrder α] [TopologicalSpace β] theorem nhds_left_sup_nhds_right (a : α) : 𝓝[≤] a ⊔ 𝓝[≥] a = 𝓝 a := by rw [← nhdsWithin_union, Iic_union_Ici, nhdsWithin_univ] #align nhds_left_sup_nhds_right nhds_left_sup_nhds_right
Mathlib/Topology/Order/LeftRight.lean
115
116
theorem nhds_left'_sup_nhds_right (a : α) : 𝓝[<] a ⊔ 𝓝[≥] a = 𝓝 a := by
rw [← nhdsWithin_union, Iio_union_Ici, nhdsWithin_univ]
/- Copyright (c) 2021 Jordan Brown, Thomas Browning, Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jordan Brown, Thomas Browning, Patrick Lutz -/ import Mathlib.Data.Fin.VecNotation import Mathlib.GroupTheory.Abelianization import Mathlib.GroupTheory.Perm.ViaEmbedding import Mathlib.GroupTheory.Subgroup.Simple import Mathlib.SetTheory.Cardinal.Basic #align_import group_theory.solvable from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Solvable Groups In this file we introduce the notion of a solvable group. We define a solvable group as one whose derived series is eventually trivial. This requires defining the commutator of two subgroups and the derived series of a group. ## Main definitions * `derivedSeries G n` : the `n`th term in the derived series of `G`, defined by iterating `general_commutator` starting with the top subgroup * `IsSolvable G` : the group `G` is solvable -/ open Subgroup variable {G G' : Type*} [Group G] [Group G'] {f : G →* G'} section derivedSeries variable (G) /-- The derived series of the group `G`, obtained by starting from the subgroup `⊤` and repeatedly taking the commutator of the previous subgroup with itself for `n` times. -/ def derivedSeries : ℕ → Subgroup G | 0 => ⊤ | n + 1 => ⁅derivedSeries n, derivedSeries n⁆ #align derived_series derivedSeries @[simp] theorem derivedSeries_zero : derivedSeries G 0 = ⊤ := rfl #align derived_series_zero derivedSeries_zero @[simp] theorem derivedSeries_succ (n : ℕ) : derivedSeries G (n + 1) = ⁅derivedSeries G n, derivedSeries G n⁆ := rfl #align derived_series_succ derivedSeries_succ -- Porting note: had to provide inductive hypothesis explicitly theorem derivedSeries_normal (n : ℕ) : (derivedSeries G n).Normal := by induction' n with n ih · exact (⊤ : Subgroup G).normal_of_characteristic · exact @Subgroup.commutator_normal G _ (derivedSeries G n) (derivedSeries G n) ih ih #align derived_series_normal derivedSeries_normal -- Porting note: higher simp priority to restore Lean 3 behavior @[simp 1100] theorem derivedSeries_one : derivedSeries G 1 = commutator G := rfl #align derived_series_one derivedSeries_one end derivedSeries section CommutatorMap section DerivedSeriesMap variable (f) theorem map_derivedSeries_le_derivedSeries (n : ℕ) : (derivedSeries G n).map f ≤ derivedSeries G' n := by induction' n with n ih · exact le_top · simp only [derivedSeries_succ, map_commutator, commutator_mono, ih] #align map_derived_series_le_derived_series map_derivedSeries_le_derivedSeries variable {f} theorem derivedSeries_le_map_derivedSeries (hf : Function.Surjective f) (n : ℕ) : derivedSeries G' n ≤ (derivedSeries G n).map f := by induction' n with n ih · exact (map_top_of_surjective f hf).ge · exact commutator_le_map_commutator ih ih #align derived_series_le_map_derived_series derivedSeries_le_map_derivedSeries theorem map_derivedSeries_eq (hf : Function.Surjective f) (n : ℕ) : (derivedSeries G n).map f = derivedSeries G' n := le_antisymm (map_derivedSeries_le_derivedSeries f n) (derivedSeries_le_map_derivedSeries hf n) #align map_derived_series_eq map_derivedSeries_eq end DerivedSeriesMap end CommutatorMap section Solvable variable (G) /-- A group `G` is solvable if its derived series is eventually trivial. We use this definition because it's the most convenient one to work with. -/ @[mk_iff isSolvable_def] class IsSolvable : Prop where /-- A group `G` is solvable if its derived series is eventually trivial. -/ solvable : ∃ n : ℕ, derivedSeries G n = ⊥ #align is_solvable IsSolvable #align is_solvable_def isSolvable_def instance (priority := 100) CommGroup.isSolvable {G : Type*} [CommGroup G] : IsSolvable G := ⟨⟨1, le_bot_iff.mp (Abelianization.commutator_subset_ker (MonoidHom.id G))⟩⟩ #align comm_group.is_solvable CommGroup.isSolvable theorem isSolvable_of_comm {G : Type*} [hG : Group G] (h : ∀ a b : G, a * b = b * a) : IsSolvable G := by letI hG' : CommGroup G := { hG with mul_comm := h } cases hG exact CommGroup.isSolvable #align is_solvable_of_comm isSolvable_of_comm theorem isSolvable_of_top_eq_bot (h : (⊤ : Subgroup G) = ⊥) : IsSolvable G := ⟨⟨0, h⟩⟩ #align is_solvable_of_top_eq_bot isSolvable_of_top_eq_bot instance (priority := 100) isSolvable_of_subsingleton [Subsingleton G] : IsSolvable G := isSolvable_of_top_eq_bot G (by simp [eq_iff_true_of_subsingleton]) #align is_solvable_of_subsingleton isSolvable_of_subsingleton variable {G}
Mathlib/GroupTheory/Solvable.lean
135
145
theorem solvable_of_ker_le_range {G' G'' : Type*} [Group G'] [Group G''] (f : G' →* G) (g : G →* G'') (hfg : g.ker ≤ f.range) [hG' : IsSolvable G'] [hG'' : IsSolvable G''] : IsSolvable G := by
obtain ⟨n, hn⟩ := id hG'' obtain ⟨m, hm⟩ := id hG' refine ⟨⟨n + m, le_bot_iff.mp (Subgroup.map_bot f ▸ hm ▸ ?_)⟩⟩ clear hm induction' m with m hm · exact f.range_eq_map ▸ ((derivedSeries G n).map_eq_bot_iff.mp (le_bot_iff.mp ((map_derivedSeries_le_derivedSeries g n).trans hn.le))).trans hfg · exact commutator_le_map_commutator hm hm
/- Copyright (c) 2020 Aaron Anderson, Jalex Stark, Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Alena Gusakov -/ import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Data.Sym.Card /-! # Definitions for finite and locally finite graphs This file defines finite versions of `edgeSet`, `neighborSet` and `incidenceSet` and proves some of their basic properties. It also defines the notion of a locally finite graph, which is one whose vertices have finite degree. The design for finiteness is that each definition takes the smallest finiteness assumption necessary. For example, `SimpleGraph.neighborFinset v` only requires that `v` have finitely many neighbors. ## Main definitions * `SimpleGraph.edgeFinset` is the `Finset` of edges in a graph, if `edgeSet` is finite * `SimpleGraph.neighborFinset` is the `Finset` of vertices adjacent to a given vertex, if `neighborSet` is finite * `SimpleGraph.incidenceFinset` is the `Finset` of edges containing a given vertex, if `incidenceSet` is finite ## Naming conventions If the vertex type of a graph is finite, we refer to its cardinality as `CardVerts` or `card_verts`. ## Implementation notes * A locally finite graph is one with instances `Π v, Fintype (G.neighborSet v)`. * Given instances `DecidableRel G.Adj` and `Fintype V`, then the graph is locally finite, too. -/ open Finset Function namespace SimpleGraph variable {V : Type*} (G : SimpleGraph V) {e : Sym2 V} section EdgeFinset variable {G₁ G₂ : SimpleGraph V} [Fintype G.edgeSet] [Fintype G₁.edgeSet] [Fintype G₂.edgeSet] /-- The `edgeSet` of the graph as a `Finset`. -/ abbrev edgeFinset : Finset (Sym2 V) := Set.toFinset G.edgeSet #align simple_graph.edge_finset SimpleGraph.edgeFinset @[norm_cast] theorem coe_edgeFinset : (G.edgeFinset : Set (Sym2 V)) = G.edgeSet := Set.coe_toFinset _ #align simple_graph.coe_edge_finset SimpleGraph.coe_edgeFinset variable {G} theorem mem_edgeFinset : e ∈ G.edgeFinset ↔ e ∈ G.edgeSet := Set.mem_toFinset #align simple_graph.mem_edge_finset SimpleGraph.mem_edgeFinset theorem not_isDiag_of_mem_edgeFinset : e ∈ G.edgeFinset → ¬e.IsDiag := not_isDiag_of_mem_edgeSet _ ∘ mem_edgeFinset.1 #align simple_graph.not_is_diag_of_mem_edge_finset SimpleGraph.not_isDiag_of_mem_edgeFinset theorem edgeFinset_inj : G₁.edgeFinset = G₂.edgeFinset ↔ G₁ = G₂ := by simp #align simple_graph.edge_finset_inj SimpleGraph.edgeFinset_inj
Mathlib/Combinatorics/SimpleGraph/Finite.lean
75
75
theorem edgeFinset_subset_edgeFinset : G₁.edgeFinset ⊆ G₂.edgeFinset ↔ G₁ ≤ G₂ := by
simp
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.Order.Interval.Finset import Mathlib.Order.Interval.Finset.Nat import Mathlib.Tactic.Linarith #align_import algebra.big_operators.intervals from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Results about big operators over intervals We prove results about big operators over intervals. -/ open Nat variable {α M : Type*} namespace Finset section PartialOrder variable [PartialOrder α] [CommMonoid M] {f : α → M} {a b : α} section LocallyFiniteOrder variable [LocallyFiniteOrder α] @[to_additive] lemma mul_prod_Ico_eq_prod_Icc (h : a ≤ b) : f b * ∏ x ∈ Ico a b, f x = ∏ x ∈ Icc a b, f x := by rw [Icc_eq_cons_Ico h, prod_cons] @[to_additive] lemma prod_Ico_mul_eq_prod_Icc (h : a ≤ b) : (∏ x ∈ Ico a b, f x) * f b = ∏ x ∈ Icc a b, f x := by rw [mul_comm, mul_prod_Ico_eq_prod_Icc h] @[to_additive] lemma mul_prod_Ioc_eq_prod_Icc (h : a ≤ b) : f a * ∏ x ∈ Ioc a b, f x = ∏ x ∈ Icc a b, f x := by rw [Icc_eq_cons_Ioc h, prod_cons] @[to_additive] lemma prod_Ioc_mul_eq_prod_Icc (h : a ≤ b) : (∏ x ∈ Ioc a b, f x) * f a = ∏ x ∈ Icc a b, f x := by rw [mul_comm, mul_prod_Ioc_eq_prod_Icc h] end LocallyFiniteOrder section LocallyFiniteOrderTop variable [LocallyFiniteOrderTop α] @[to_additive] lemma mul_prod_Ioi_eq_prod_Ici (a : α) : f a * ∏ x ∈ Ioi a, f x = ∏ x ∈ Ici a, f x := by rw [Ici_eq_cons_Ioi, prod_cons] @[to_additive] lemma prod_Ioi_mul_eq_prod_Ici (a : α) : (∏ x ∈ Ioi a, f x) * f a = ∏ x ∈ Ici a, f x := by rw [mul_comm, mul_prod_Ioi_eq_prod_Ici] end LocallyFiniteOrderTop section LocallyFiniteOrderBot variable [LocallyFiniteOrderBot α] @[to_additive] lemma mul_prod_Iio_eq_prod_Iic (a : α) : f a * ∏ x ∈ Iio a, f x = ∏ x ∈ Iic a, f x := by rw [Iic_eq_cons_Iio, prod_cons] @[to_additive] lemma prod_Iio_mul_eq_prod_Iic (a : α) : (∏ x ∈ Iio a, f x) * f a = ∏ x ∈ Iic a, f x := by rw [mul_comm, mul_prod_Iio_eq_prod_Iic] end LocallyFiniteOrderBot end PartialOrder section LinearOrder variable [Fintype α] [LinearOrder α] [LocallyFiniteOrderTop α] [LocallyFiniteOrderBot α] [CommMonoid M] @[to_additive] lemma prod_prod_Ioi_mul_eq_prod_prod_off_diag (f : α → α → M) : ∏ i, ∏ j ∈ Ioi i, f j i * f i j = ∏ i, ∏ j ∈ {i}ᶜ, f j i := by simp_rw [← Ioi_disjUnion_Iio, prod_disjUnion, prod_mul_distrib] congr 1 rw [prod_sigma', prod_sigma'] refine prod_nbij' (fun i ↦ ⟨i.2, i.1⟩) (fun i ↦ ⟨i.2, i.1⟩) ?_ ?_ ?_ ?_ ?_ <;> simp #align finset.prod_prod_Ioi_mul_eq_prod_prod_off_diag Finset.prod_prod_Ioi_mul_eq_prod_prod_off_diag #align finset.sum_sum_Ioi_add_eq_sum_sum_off_diag Finset.sum_sum_Ioi_add_eq_sum_sum_off_diag end LinearOrder section Generic variable [CommMonoid M] {s₂ s₁ s : Finset α} {a : α} {g f : α → M} @[to_additive] theorem prod_Ico_add' [OrderedCancelAddCommMonoid α] [ExistsAddOfLE α] [LocallyFiniteOrder α] (f : α → M) (a b c : α) : (∏ x ∈ Ico a b, f (x + c)) = ∏ x ∈ Ico (a + c) (b + c), f x := by rw [← map_add_right_Ico, prod_map] rfl #align finset.prod_Ico_add' Finset.prod_Ico_add' #align finset.sum_Ico_add' Finset.sum_Ico_add' @[to_additive] theorem prod_Ico_add [OrderedCancelAddCommMonoid α] [ExistsAddOfLE α] [LocallyFiniteOrder α] (f : α → M) (a b c : α) : (∏ x ∈ Ico a b, f (c + x)) = ∏ x ∈ Ico (a + c) (b + c), f x := by convert prod_Ico_add' f a b c using 2 rw [add_comm] #align finset.prod_Ico_add Finset.prod_Ico_add #align finset.sum_Ico_add Finset.sum_Ico_add @[to_additive]
Mathlib/Algebra/BigOperators/Intervals.lean
111
113
theorem prod_Ico_succ_top {a b : ℕ} (hab : a ≤ b) (f : ℕ → M) : (∏ k ∈ Ico a (b + 1), f k) = (∏ k ∈ Ico a b, f k) * f b := by
rw [Nat.Ico_succ_right_eq_insert_Ico hab, prod_insert right_not_mem_Ico, mul_comm]
/- Copyright (c) 2022 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Patrick Massot -/ import Mathlib.Topology.Basic #align_import topology.nhds_set from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Neighborhoods of a set In this file we define the filter `𝓝ˢ s` or `nhdsSet s` consisting of all neighborhoods of a set `s`. ## Main Properties There are a couple different notions equivalent to `s ∈ 𝓝ˢ t`: * `s ⊆ interior t` using `subset_interior_iff_mem_nhdsSet` * `∀ x : X, x ∈ t → s ∈ 𝓝 x` using `mem_nhdsSet_iff_forall` * `∃ U : Set X, IsOpen U ∧ t ⊆ U ∧ U ⊆ s` using `mem_nhdsSet_iff_exists` Furthermore, we have the following results: * `monotone_nhdsSet`: `𝓝ˢ` is monotone * In T₁-spaces, `𝓝ˢ`is strictly monotone and hence injective: `strict_mono_nhdsSet`/`injective_nhdsSet`. These results are in `Mathlib.Topology.Separation`. -/ open Set Filter Topology variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {f : Filter X} {s t s₁ s₂ t₁ t₂ : Set X} {x : X} theorem nhdsSet_diagonal (X) [TopologicalSpace (X × X)] : 𝓝ˢ (diagonal X) = ⨆ (x : X), 𝓝 (x, x) := by rw [nhdsSet, ← range_diag, ← range_comp] rfl #align nhds_set_diagonal nhdsSet_diagonal theorem mem_nhdsSet_iff_forall : s ∈ 𝓝ˢ t ↔ ∀ x : X, x ∈ t → s ∈ 𝓝 x := by simp_rw [nhdsSet, Filter.mem_sSup, forall_mem_image] #align mem_nhds_set_iff_forall mem_nhdsSet_iff_forall lemma nhdsSet_le : 𝓝ˢ s ≤ f ↔ ∀ x ∈ s, 𝓝 x ≤ f := by simp [nhdsSet] theorem bUnion_mem_nhdsSet {t : X → Set X} (h : ∀ x ∈ s, t x ∈ 𝓝 x) : (⋃ x ∈ s, t x) ∈ 𝓝ˢ s := mem_nhdsSet_iff_forall.2 fun x hx => mem_of_superset (h x hx) <| subset_iUnion₂ (s := fun x _ => t x) x hx -- Porting note: fails to find `s` #align bUnion_mem_nhds_set bUnion_mem_nhdsSet theorem subset_interior_iff_mem_nhdsSet : s ⊆ interior t ↔ t ∈ 𝓝ˢ s := by simp_rw [mem_nhdsSet_iff_forall, subset_interior_iff_nhds] #align subset_interior_iff_mem_nhds_set subset_interior_iff_mem_nhdsSet theorem disjoint_principal_nhdsSet : Disjoint (𝓟 s) (𝓝ˢ t) ↔ Disjoint (closure s) t := by rw [disjoint_principal_left, ← subset_interior_iff_mem_nhdsSet, interior_compl, subset_compl_iff_disjoint_left]
Mathlib/Topology/NhdsSet.lean
60
61
theorem disjoint_nhdsSet_principal : Disjoint (𝓝ˢ s) (𝓟 t) ↔ Disjoint s (closure t) := by
rw [disjoint_comm, disjoint_principal_nhdsSet, disjoint_comm]
/- Copyright (c) 2022 Felix Weilacher. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Felix Weilacher -/ import Mathlib.Topology.Separation /-! # Perfect Sets In this file we define perfect subsets of a topological space, and prove some basic properties, including a version of the Cantor-Bendixson Theorem. ## Main Definitions * `Perfect C`: A set `C` is perfect, meaning it is closed and every point of it is an accumulation point of itself. * `PerfectSpace X`: A topological space `X` is perfect if its universe is a perfect set. ## Main Statements * `Perfect.splitting`: A perfect nonempty set contains two disjoint perfect nonempty subsets. The main inductive step in the construction of an embedding from the Cantor space to a perfect nonempty complete metric space. * `exists_countable_union_perfect_of_isClosed`: One version of the **Cantor-Bendixson Theorem**: A closed set in a second countable space can be written as the union of a countable set and a perfect set. ## Implementation Notes We do not require perfect sets to be nonempty. We define a nonstandard predicate, `Preperfect`, which drops the closed-ness requirement from the definition of perfect. In T1 spaces, this is equivalent to having a perfect closure, see `preperfect_iff_perfect_closure`. ## See also `Mathlib.Topology.MetricSpace.Perfect`, for properties of perfect sets in metric spaces, namely Polish spaces. ## References * [kechris1995] (Chapters 6-7) ## Tags accumulation point, perfect set, cantor-bendixson. -/ open Topology Filter Set TopologicalSpace section Basic variable {α : Type*} [TopologicalSpace α] {C : Set α} /-- If `x` is an accumulation point of a set `C` and `U` is a neighborhood of `x`, then `x` is an accumulation point of `U ∩ C`. -/ theorem AccPt.nhds_inter {x : α} {U : Set α} (h_acc : AccPt x (𝓟 C)) (hU : U ∈ 𝓝 x) : AccPt x (𝓟 (U ∩ C)) := by have : 𝓝[≠] x ≤ 𝓟 U := by rw [le_principal_iff] exact mem_nhdsWithin_of_mem_nhds hU rw [AccPt, ← inf_principal, ← inf_assoc, inf_of_le_left this] exact h_acc #align acc_pt.nhds_inter AccPt.nhds_inter /-- A set `C` is preperfect if all of its points are accumulation points of itself. If `C` is nonempty and `α` is a T1 space, this is equivalent to the closure of `C` being perfect. See `preperfect_iff_perfect_closure`. -/ def Preperfect (C : Set α) : Prop := ∀ x ∈ C, AccPt x (𝓟 C) #align preperfect Preperfect /-- A set `C` is called perfect if it is closed and all of its points are accumulation points of itself. Note that we do not require `C` to be nonempty. -/ @[mk_iff perfect_def] structure Perfect (C : Set α) : Prop where closed : IsClosed C acc : Preperfect C #align perfect Perfect theorem preperfect_iff_nhds : Preperfect C ↔ ∀ x ∈ C, ∀ U ∈ 𝓝 x, ∃ y ∈ U ∩ C, y ≠ x := by simp only [Preperfect, accPt_iff_nhds] #align preperfect_iff_nhds preperfect_iff_nhds section PerfectSpace variable (α) /-- A topological space `X` is said to be perfect if its universe is a perfect set. Equivalently, this means that `𝓝[≠] x ≠ ⊥` for every point `x : X`. -/ @[mk_iff perfectSpace_def] class PerfectSpace : Prop := univ_preperfect : Preperfect (Set.univ : Set α) theorem PerfectSpace.univ_perfect [PerfectSpace α] : Perfect (Set.univ : Set α) := ⟨isClosed_univ, PerfectSpace.univ_preperfect⟩ end PerfectSpace section Preperfect /-- The intersection of a preperfect set and an open set is preperfect. -/ theorem Preperfect.open_inter {U : Set α} (hC : Preperfect C) (hU : IsOpen U) : Preperfect (U ∩ C) := by rintro x ⟨xU, xC⟩ apply (hC _ xC).nhds_inter exact hU.mem_nhds xU #align preperfect.open_inter Preperfect.open_inter /-- The closure of a preperfect set is perfect. For a converse, see `preperfect_iff_perfect_closure`. -/
Mathlib/Topology/Perfect.lean
120
128
theorem Preperfect.perfect_closure (hC : Preperfect C) : Perfect (closure C) := by
constructor; · exact isClosed_closure intro x hx by_cases h : x ∈ C <;> apply AccPt.mono _ (principal_mono.mpr subset_closure) · exact hC _ h have : {x}ᶜ ∩ C = C := by simp [h] rw [AccPt, nhdsWithin, inf_assoc, inf_principal, this] rw [closure_eq_cluster_pts] at hx exact hx
/- 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, Yury Kudryashov -/ import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" /-! # Relation chain This file provides basic results about `List.Chain` (definition in `Data.List.Defs`). A list `[a₂, ..., aₙ]` is a `Chain` starting at `a₁` with respect to the relation `r` if `r a₁ a₂` and `r a₂ a₃` and ... and `r aₙ₋₁ aₙ`. We write it `Chain r a₁ [a₂, ..., aₙ]`. A graph-specialized version is in development and will hopefully be added under `combinatorics.` sometime soon. -/ -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : α} {l : List α} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by simp only [chain_cons, Chain.nil, and_true_iff] #align list.chain_singleton List.chain_singleton
Mathlib/Data/List/Chain.lean
62
65
theorem chain_split {a b : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by
induction' l₁ with x l₁ IH generalizing a <;> simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc]
/- Copyright (c) 2023 Mantas Bakšys, Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mantas Bakšys, Yaël Dillies -/ import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Rearrangement import Mathlib.Algebra.Order.Ring.Basic import Mathlib.GroupTheory.Perm.Cycle.Basic #align_import algebra.order.chebyshev from "leanprover-community/mathlib"@"b7399344324326918d65d0c74e9571e3a8cb9199" /-! # Chebyshev's sum inequality This file proves the Chebyshev sum inequality. Chebyshev's inequality states `(∑ i ∈ s, f i) * (∑ i ∈ s, g i) ≤ s.card * ∑ i ∈ s, f i * g i` when `f g : ι → α` monovary, and the reverse inequality when `f` and `g` antivary. ## Main declarations * `MonovaryOn.sum_mul_sum_le_card_mul_sum`: Chebyshev's inequality. * `AntivaryOn.card_mul_sum_le_sum_mul_sum`: Chebyshev's inequality, dual version. * `sq_sum_le_card_mul_sum_sq`: Special case of Chebyshev's inequality when `f = g`. ## Implementation notes In fact, we don't need much compatibility between the addition and multiplication of `α`, so we can actually decouple them by replacing multiplication with scalar multiplication and making `f` and `g` land in different types. As a bonus, this makes the dual statement trivial. The multiplication versions are provided for convenience. The case for `Monotone`/`Antitone` pairs of functions over a `LinearOrder` is not deduced in this file because it is easily deducible from the `Monovary` API. -/ open Equiv Equiv.Perm Finset Function OrderDual variable {ι α β : Type*} /-! ### Scalar multiplication versions -/ section SMul variable [LinearOrderedRing α] [LinearOrderedAddCommGroup β] [Module α β] [OrderedSMul α β] {s : Finset ι} {σ : Perm ι} {f : ι → α} {g : ι → β} /-- **Chebyshev's Sum Inequality**: When `f` and `g` monovary together (eg they are both monotone/antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem MonovaryOn.sum_smul_sum_le_card_smul_sum (hfg : MonovaryOn f g s) : ((∑ i ∈ s, f i) • ∑ i ∈ s, g i) ≤ s.card • ∑ i ∈ s, f i • g i := by classical obtain ⟨σ, hσ, hs⟩ := s.countable_toSet.exists_cycleOn rw [← card_range s.card, sum_smul_sum_eq_sum_perm hσ] exact sum_le_card_nsmul _ _ _ fun n _ => hfg.sum_smul_comp_perm_le_sum_smul fun x hx => hs fun h => hx <| IsFixedPt.perm_pow h _ #align monovary_on.sum_smul_sum_le_card_smul_sum MonovaryOn.sum_smul_sum_le_card_smul_sum /-- **Chebyshev's Sum Inequality**: When `f` and `g` antivary together (eg one is monotone, the other is antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem AntivaryOn.card_smul_sum_le_sum_smul_sum (hfg : AntivaryOn f g s) : (s.card • ∑ i ∈ s, f i • g i) ≤ (∑ i ∈ s, f i) • ∑ i ∈ s, g i := by exact hfg.dual_right.sum_smul_sum_le_card_smul_sum #align antivary_on.card_smul_sum_le_sum_smul_sum AntivaryOn.card_smul_sum_le_sum_smul_sum variable [Fintype ι] /-- **Chebyshev's Sum Inequality**: When `f` and `g` monovary together (eg they are both monotone/antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem Monovary.sum_smul_sum_le_card_smul_sum (hfg : Monovary f g) : ((∑ i, f i) • ∑ i, g i) ≤ Fintype.card ι • ∑ i, f i • g i := (hfg.monovaryOn _).sum_smul_sum_le_card_smul_sum #align monovary.sum_smul_sum_le_card_smul_sum Monovary.sum_smul_sum_le_card_smul_sum /-- **Chebyshev's Sum Inequality**: When `f` and `g` antivary together (eg one is monotone, the other is antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/
Mathlib/Algebra/Order/Chebyshev.lean
88
90
theorem Antivary.card_smul_sum_le_sum_smul_sum (hfg : Antivary f g) : (Fintype.card ι • ∑ i, f i • g i) ≤ (∑ i, f i) • ∑ i, g i := by
exact (hfg.dual_right.monovaryOn _).sum_smul_sum_le_card_smul_sum
/- 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.Module.Equiv import Mathlib.Data.DFinsupp.Basic import Mathlib.Data.Finsupp.Basic #align_import data.finsupp.to_dfinsupp from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Conversion between `Finsupp` and homogenous `DFinsupp` This module provides conversions between `Finsupp` and `DFinsupp`. It is in its own file since neither `Finsupp` or `DFinsupp` depend on each other. ## Main definitions * "identity" maps between `Finsupp` and `DFinsupp`: * `Finsupp.toDFinsupp : (ι →₀ M) → (Π₀ i : ι, M)` * `DFinsupp.toFinsupp : (Π₀ i : ι, M) → (ι →₀ M)` * Bundled equiv versions of the above: * `finsuppEquivDFinsupp : (ι →₀ M) ≃ (Π₀ i : ι, M)` * `finsuppAddEquivDFinsupp : (ι →₀ M) ≃+ (Π₀ i : ι, M)` * `finsuppLequivDFinsupp R : (ι →₀ M) ≃ₗ[R] (Π₀ i : ι, M)` * stronger versions of `Finsupp.split`: * `sigmaFinsuppEquivDFinsupp : ((Σ i, η i) →₀ N) ≃ (Π₀ i, (η i →₀ N))` * `sigmaFinsuppAddEquivDFinsupp : ((Σ i, η i) →₀ N) ≃+ (Π₀ i, (η i →₀ N))` * `sigmaFinsuppLequivDFinsupp : ((Σ i, η i) →₀ N) ≃ₗ[R] (Π₀ i, (η i →₀ N))` ## Theorems The defining features of these operations is that they preserve the function and support: * `Finsupp.toDFinsupp_coe` * `Finsupp.toDFinsupp_support` * `DFinsupp.toFinsupp_coe` * `DFinsupp.toFinsupp_support` and therefore map `Finsupp.single` to `DFinsupp.single` and vice versa: * `Finsupp.toDFinsupp_single` * `DFinsupp.toFinsupp_single` as well as preserving arithmetic operations. For the bundled equivalences, we provide lemmas that they reduce to `Finsupp.toDFinsupp`: * `finsupp_add_equiv_dfinsupp_apply` * `finsupp_lequiv_dfinsupp_apply` * `finsupp_add_equiv_dfinsupp_symm_apply` * `finsupp_lequiv_dfinsupp_symm_apply` ## Implementation notes We provide `DFinsupp.toFinsupp` and `finsuppEquivDFinsupp` computably by adding `[DecidableEq ι]` and `[Π m : M, Decidable (m ≠ 0)]` arguments. To aid with definitional unfolding, these arguments are also present on the `noncomputable` equivs. -/ variable {ι : Type*} {R : Type*} {M : Type*} /-! ### Basic definitions and lemmas -/ section Defs /-- Interpret a `Finsupp` as a homogenous `DFinsupp`. -/ def Finsupp.toDFinsupp [Zero M] (f : ι →₀ M) : Π₀ _ : ι, M where toFun := f support' := Trunc.mk ⟨f.support.1, fun i => (Classical.em (f i = 0)).symm.imp_left Finsupp.mem_support_iff.mpr⟩ #align finsupp.to_dfinsupp Finsupp.toDFinsupp @[simp] theorem Finsupp.toDFinsupp_coe [Zero M] (f : ι →₀ M) : ⇑f.toDFinsupp = f := rfl #align finsupp.to_dfinsupp_coe Finsupp.toDFinsupp_coe section variable [DecidableEq ι] [Zero M] @[simp] theorem Finsupp.toDFinsupp_single (i : ι) (m : M) : (Finsupp.single i m).toDFinsupp = DFinsupp.single i m := by ext simp [Finsupp.single_apply, DFinsupp.single_apply] #align finsupp.to_dfinsupp_single Finsupp.toDFinsupp_single variable [∀ m : M, Decidable (m ≠ 0)] @[simp]
Mathlib/Data/Finsupp/ToDFinsupp.lean
97
99
theorem toDFinsupp_support (f : ι →₀ M) : f.toDFinsupp.support = f.support := by
ext simp
/- 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]
Mathlib/Data/Finset/Option.lean
87
87
theorem card_insertNone (s : Finset α) : s.insertNone.card = s.card + 1 := by
simp [insertNone]
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.GCDMonoid.Multiset import Mathlib.Combinatorics.Enumerative.Partition import Mathlib.Data.List.Rotate import Mathlib.GroupTheory.Perm.Cycle.Factors import Mathlib.GroupTheory.Perm.Closure import Mathlib.Algebra.GCDMonoid.Nat import Mathlib.Tactic.NormNum.GCD #align_import group_theory.perm.cycle.type from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722" /-! # Cycle Types In this file we define the cycle type of a permutation. ## Main definitions - `Equiv.Perm.cycleType σ` where `σ` is a permutation of a `Fintype` - `Equiv.Perm.partition σ` where `σ` is a permutation of a `Fintype` ## Main results - `sum_cycleType` : The sum of `σ.cycleType` equals `σ.support.card` - `lcm_cycleType` : The lcm of `σ.cycleType` equals `orderOf σ` - `isConj_iff_cycleType_eq` : Two permutations are conjugate if and only if they have the same cycle type. - `exists_prime_orderOf_dvd_card`: For every prime `p` dividing the order of a finite group `G` there exists an element of order `p` in `G`. This is known as Cauchy's theorem. -/ namespace Equiv.Perm open Equiv List Multiset variable {α : Type*} [Fintype α] section CycleType variable [DecidableEq α] /-- The cycle type of a permutation -/ def cycleType (σ : Perm α) : Multiset ℕ := σ.cycleFactorsFinset.1.map (Finset.card ∘ support) #align equiv.perm.cycle_type Equiv.Perm.cycleType theorem cycleType_def (σ : Perm α) : σ.cycleType = σ.cycleFactorsFinset.1.map (Finset.card ∘ support) := rfl #align equiv.perm.cycle_type_def Equiv.Perm.cycleType_def theorem cycleType_eq' {σ : Perm α} (s : Finset (Perm α)) (h1 : ∀ f : Perm α, f ∈ s → f.IsCycle) (h2 : (s : Set (Perm α)).Pairwise Disjoint) (h0 : s.noncommProd id (h2.imp fun _ _ => Disjoint.commute) = σ) : σ.cycleType = s.1.map (Finset.card ∘ support) := by rw [cycleType_def] congr rw [cycleFactorsFinset_eq_finset] exact ⟨h1, h2, h0⟩ #align equiv.perm.cycle_type_eq' Equiv.Perm.cycleType_eq' theorem cycleType_eq {σ : Perm α} (l : List (Perm α)) (h0 : l.prod = σ) (h1 : ∀ σ : Perm α, σ ∈ l → σ.IsCycle) (h2 : l.Pairwise Disjoint) : σ.cycleType = l.map (Finset.card ∘ support) := by have hl : l.Nodup := nodup_of_pairwise_disjoint_cycles h1 h2 rw [cycleType_eq' l.toFinset] · simp [List.dedup_eq_self.mpr hl, (· ∘ ·)] · simpa using h1 · simpa [hl] using h2 · simp [hl, h0] #align equiv.perm.cycle_type_eq Equiv.Perm.cycleType_eq @[simp] -- Porting note: new attr theorem cycleType_eq_zero {σ : Perm α} : σ.cycleType = 0 ↔ σ = 1 := by simp [cycleType_def, cycleFactorsFinset_eq_empty_iff] #align equiv.perm.cycle_type_eq_zero Equiv.Perm.cycleType_eq_zero @[simp] -- Porting note: new attr theorem cycleType_one : (1 : Perm α).cycleType = 0 := cycleType_eq_zero.2 rfl #align equiv.perm.cycle_type_one Equiv.Perm.cycleType_one theorem card_cycleType_eq_zero {σ : Perm α} : Multiset.card σ.cycleType = 0 ↔ σ = 1 := by rw [card_eq_zero, cycleType_eq_zero] #align equiv.perm.card_cycle_type_eq_zero Equiv.Perm.card_cycleType_eq_zero theorem card_cycleType_pos {σ : Perm α} : 0 < Multiset.card σ.cycleType ↔ σ ≠ 1 := pos_iff_ne_zero.trans card_cycleType_eq_zero.not
Mathlib/GroupTheory/Perm/Cycle/Type.lean
94
98
theorem two_le_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : 2 ≤ n := by
simp only [cycleType_def, ← Finset.mem_def, Function.comp_apply, Multiset.mem_map, mem_cycleFactorsFinset_iff] at h obtain ⟨_, ⟨hc, -⟩, rfl⟩ := h exact hc.two_le_card_support
/- Copyright (c) 2022 Michael Stoll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Stoll -/ import Mathlib.Data.Fintype.Parity import Mathlib.NumberTheory.LegendreSymbol.ZModChar import Mathlib.FieldTheory.Finite.Basic #align_import number_theory.legendre_symbol.quadratic_char.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" /-! # Quadratic characters of finite fields This file defines the quadratic character on a finite field `F` and proves some basic statements about it. ## Tags quadratic character -/ /-! ### Definition of the quadratic character We define the quadratic character of a finite field `F` with values in ℤ. -/ section Define /-- Define the quadratic character with values in ℤ on a monoid with zero `α`. It takes the value zero at zero; for non-zero argument `a : α`, it is `1` if `a` is a square, otherwise it is `-1`. This only deserves the name "character" when it is multiplicative, e.g., when `α` is a finite field. See `quadraticCharFun_mul`. We will later define `quadraticChar` to be a multiplicative character of type `MulChar F ℤ`, when the domain is a finite field `F`. -/ def quadraticCharFun (α : Type*) [MonoidWithZero α] [DecidableEq α] [DecidablePred (IsSquare : α → Prop)] (a : α) : ℤ := if a = 0 then 0 else if IsSquare a then 1 else -1 #align quadratic_char_fun quadraticCharFun end Define /-! ### Basic properties of the quadratic character We prove some properties of the quadratic character. We work with a finite field `F` here. The interesting case is when the characteristic of `F` is odd. -/ section quadraticChar open MulChar variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] /-- Some basic API lemmas -/
Mathlib/NumberTheory/LegendreSymbol/QuadraticChar/Basic.lean
66
71
theorem quadraticCharFun_eq_zero_iff {a : F} : quadraticCharFun F a = 0 ↔ a = 0 := by
simp only [quadraticCharFun] by_cases ha : a = 0 · simp only [ha, eq_self_iff_true, if_true] · simp only [ha, if_false, iff_false_iff] split_ifs <;> simp only [neg_eq_zero, one_ne_zero, not_false_iff]
/- Copyright (c) 2024 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Chambert-Loir, Oliver Nash -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Identities import Mathlib.RingTheory.Nilpotent.Lemmas import Mathlib.RingTheory.Polynomial.Nilpotent import Mathlib.RingTheory.Polynomial.Tower /-! # Newton-Raphson method Given a single-variable polynomial `P` with derivative `P'`, Newton's method concerns iteration of the rational map: `x ↦ x - P(x) / P'(x)`. Over a field it can serve as a root-finding algorithm. It is also useful tool in certain proofs such as Hensel's lemma and Jordan-Chevalley decomposition. ## Main definitions / results: * `Polynomial.newtonMap`: the map `x ↦ x - P(x) / P'(x)`, where `P'` is the derivative of the polynomial `P`. * `Polynomial.isFixedPt_newtonMap_of_isUnit_iff`: `x` is a fixed point for Newton iteration iff it is a root of `P` (provided `P'(x)` is a unit). * `Polynomial.exists_unique_nilpotent_sub_and_aeval_eq_zero`: if `x` is almost a root of `P` in the sense that `P(x)` is nilpotent (and `P'(x)` is a unit) then we may write `x` as a sum `x = n + r` where `n` is nilpotent and `r` is a root of `P`. This can be used to prove the Jordan-Chevalley decomposition of linear endomorphims. -/ open Set Function noncomputable section namespace Polynomial variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] (P : R[X]) {x : S} /-- Given a single-variable polynomial `P` with derivative `P'`, this is the map: `x ↦ x - P(x) / P'(x)`. When `P'(x)` is not a unit we use a junk-value pattern and send `x ↦ x`. -/ def newtonMap (x : S) : S := x - (Ring.inverse <| aeval x (derivative P)) * aeval x P theorem newtonMap_apply : P.newtonMap x = x - (Ring.inverse <| aeval x (derivative P)) * (aeval x P) := rfl variable {P} theorem newtonMap_apply_of_isUnit (h : IsUnit <| aeval x (derivative P)) : P.newtonMap x = x - h.unit⁻¹ * aeval x P := by simp [newtonMap_apply, Ring.inverse, h] theorem newtonMap_apply_of_not_isUnit (h : ¬ (IsUnit <| aeval x (derivative P))) : P.newtonMap x = x := by simp [newtonMap_apply, Ring.inverse, h] theorem isNilpotent_iterate_newtonMap_sub_of_isNilpotent (h : IsNilpotent <| aeval x P) (n : ℕ) : IsNilpotent <| P.newtonMap^[n] x - x := by induction n with | zero => simp | succ n ih => rw [iterate_succ', comp_apply, newtonMap_apply, sub_right_comm] refine (Commute.all _ _).isNilpotent_sub ih <| (Commute.all _ _).isNilpotent_mul_right ?_ simpa using Commute.isNilpotent_add (Commute.all _ _) (isNilpotent_aeval_sub_of_isNilpotent_sub P ih) h
Mathlib/Dynamics/Newton.lean
71
73
theorem isFixedPt_newtonMap_of_aeval_eq_zero (h : aeval x P = 0) : IsFixedPt P.newtonMap x := by
rw [IsFixedPt, newtonMap_apply, h, mul_zero, sub_zero]
/- 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, Johannes Hölzl -/ import Mathlib.Order.ConditionallyCompleteLattice.Basic import Mathlib.Order.RelIso.Basic #align_import order.ord_continuous from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432" /-! # Order continuity We say that a function is *left order continuous* if it sends all least upper bounds to least upper bounds. The order dual notion is called *right order continuity*. For monotone functions `ℝ → ℝ` these notions correspond to the usual left and right continuity. We prove some basic lemmas (`map_sup`, `map_sSup` etc) and prove that a `RelIso` is both left and right order continuous. -/ universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} open Function OrderDual Set /-! ### Definitions -/ /-- A function `f` between preorders is left order continuous if it preserves all suprema. We define it using `IsLUB` instead of `sSup` so that the proof works both for complete lattices and conditionally complete lattices. -/ def LeftOrdContinuous [Preorder α] [Preorder β] (f : α → β) := ∀ ⦃s : Set α⦄ ⦃x⦄, IsLUB s x → IsLUB (f '' s) (f x) #align left_ord_continuous LeftOrdContinuous /-- A function `f` between preorders is right order continuous if it preserves all infima. We define it using `IsGLB` instead of `sInf` so that the proof works both for complete lattices and conditionally complete lattices. -/ def RightOrdContinuous [Preorder α] [Preorder β] (f : α → β) := ∀ ⦃s : Set α⦄ ⦃x⦄, IsGLB s x → IsGLB (f '' s) (f x) #align right_ord_continuous RightOrdContinuous namespace LeftOrdContinuous section Preorder variable (α) [Preorder α] [Preorder β] [Preorder γ] {g : β → γ} {f : α → β} protected theorem id : LeftOrdContinuous (id : α → α) := fun s x h => by simpa only [image_id] using h #align left_ord_continuous.id LeftOrdContinuous.id variable {α} -- Porting note: not sure what is the correct name for this protected theorem order_dual : LeftOrdContinuous f → RightOrdContinuous (toDual ∘ f ∘ ofDual) := id #align left_ord_continuous.order_dual LeftOrdContinuous.order_dual theorem map_isGreatest (hf : LeftOrdContinuous f) {s : Set α} {x : α} (h : IsGreatest s x) : IsGreatest (f '' s) (f x) := ⟨mem_image_of_mem f h.1, (hf h.isLUB).1⟩ #align left_ord_continuous.map_is_greatest LeftOrdContinuous.map_isGreatest theorem mono (hf : LeftOrdContinuous f) : Monotone f := fun a₁ a₂ h => have : IsGreatest {a₁, a₂} a₂ := ⟨Or.inr rfl, by simp [*]⟩ (hf.map_isGreatest this).2 <| mem_image_of_mem _ (Or.inl rfl) #align left_ord_continuous.mono LeftOrdContinuous.mono theorem comp (hg : LeftOrdContinuous g) (hf : LeftOrdContinuous f) : LeftOrdContinuous (g ∘ f) := fun s x h => by simpa only [image_image] using hg (hf h) #align left_ord_continuous.comp LeftOrdContinuous.comp -- Porting note: how to do this in non-tactic mode? protected theorem iterate {f : α → α} (hf : LeftOrdContinuous f) (n : ℕ) : LeftOrdContinuous f^[n] := by induction n with | zero => exact LeftOrdContinuous.id α | succ n ihn => exact ihn.comp hf #align left_ord_continuous.iterate LeftOrdContinuous.iterate end Preorder section SemilatticeSup variable [SemilatticeSup α] [SemilatticeSup β] {f : α → β} theorem map_sup (hf : LeftOrdContinuous f) (x y : α) : f (x ⊔ y) = f x ⊔ f y := (hf isLUB_pair).unique <| by simp only [image_pair, isLUB_pair] #align left_ord_continuous.map_sup LeftOrdContinuous.map_sup theorem le_iff (hf : LeftOrdContinuous f) (h : Injective f) {x y} : f x ≤ f y ↔ x ≤ y := by simp only [← sup_eq_right, ← hf.map_sup, h.eq_iff] #align left_ord_continuous.le_iff LeftOrdContinuous.le_iff theorem lt_iff (hf : LeftOrdContinuous f) (h : Injective f) {x y} : f x < f y ↔ x < y := by simp only [lt_iff_le_not_le, hf.le_iff h] #align left_ord_continuous.lt_iff LeftOrdContinuous.lt_iff variable (f) /-- Convert an injective left order continuous function to an order embedding. -/ def toOrderEmbedding (hf : LeftOrdContinuous f) (h : Injective f) : α ↪o β := ⟨⟨f, h⟩, hf.le_iff h⟩ #align left_ord_continuous.to_order_embedding LeftOrdContinuous.toOrderEmbedding variable {f} @[simp] theorem coe_toOrderEmbedding (hf : LeftOrdContinuous f) (h : Injective f) : ⇑(hf.toOrderEmbedding f h) = f := rfl #align left_ord_continuous.coe_to_order_embedding LeftOrdContinuous.coe_toOrderEmbedding end SemilatticeSup section CompleteLattice variable [CompleteLattice α] [CompleteLattice β] {f : α → β} theorem map_sSup' (hf : LeftOrdContinuous f) (s : Set α) : f (sSup s) = sSup (f '' s) := (hf <| isLUB_sSup s).sSup_eq.symm #align left_ord_continuous.map_Sup' LeftOrdContinuous.map_sSup' theorem map_sSup (hf : LeftOrdContinuous f) (s : Set α) : f (sSup s) = ⨆ x ∈ s, f x := by rw [hf.map_sSup', sSup_image] #align left_ord_continuous.map_Sup LeftOrdContinuous.map_sSup
Mathlib/Order/OrdContinuous.lean
135
137
theorem map_iSup (hf : LeftOrdContinuous f) (g : ι → α) : f (⨆ i, g i) = ⨆ i, f (g i) := by
simp only [iSup, hf.map_sSup', ← range_comp] rfl
/- Copyright (c) 2019 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau -/ import Mathlib.Algebra.MvPolynomial.Basic import Mathlib.RingTheory.Polynomial.Basic import Mathlib.RingTheory.PrincipalIdealDomain #align_import ring_theory.adjoin.fg from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23" /-! # Adjoining elements to form subalgebras This file develops the basic theory of finitely-generated subalgebras. ## Definitions * `FG (S : Subalgebra R A)` : A predicate saying that the subalgebra is finitely-generated as an A-algebra ## Tags adjoin, algebra, finitely-generated algebra -/ universe u v w open Subsemiring Ring Submodule open Pointwise namespace Algebra variable {R : Type u} {A : Type v} {B : Type w} [CommSemiring R] [CommSemiring A] [Algebra R A] {s t : Set A}
Mathlib/RingTheory/Adjoin/FG.lean
40
80
theorem fg_trans (h1 : (adjoin R s).toSubmodule.FG) (h2 : (adjoin (adjoin R s) t).toSubmodule.FG) : (adjoin R (s ∪ t)).toSubmodule.FG := by
rcases fg_def.1 h1 with ⟨p, hp, hp'⟩ rcases fg_def.1 h2 with ⟨q, hq, hq'⟩ refine fg_def.2 ⟨p * q, hp.mul hq, le_antisymm ?_ ?_⟩ · rw [span_le, Set.mul_subset_iff] intro x hx y hy change x * y ∈ adjoin R (s ∪ t) refine Subalgebra.mul_mem _ ?_ ?_ · have : x ∈ Subalgebra.toSubmodule (adjoin R s) := by rw [← hp'] exact subset_span hx exact adjoin_mono Set.subset_union_left this have : y ∈ Subalgebra.toSubmodule (adjoin (adjoin R s) t) := by rw [← hq'] exact subset_span hy change y ∈ adjoin R (s ∪ t) rwa [adjoin_union_eq_adjoin_adjoin] · intro r hr change r ∈ adjoin R (s ∪ t) at hr rw [adjoin_union_eq_adjoin_adjoin] at hr change r ∈ Subalgebra.toSubmodule (adjoin (adjoin R s) t) at hr rw [← hq', ← Set.image_id q, Finsupp.mem_span_image_iff_total (adjoin R s)] at hr rcases hr with ⟨l, hlq, rfl⟩ have := @Finsupp.total_apply A A (adjoin R s) rw [this, Finsupp.sum] refine sum_mem ?_ intro z hz change (l z).1 * _ ∈ _ have : (l z).1 ∈ Subalgebra.toSubmodule (adjoin R s) := (l z).2 rw [← hp', ← Set.image_id p, Finsupp.mem_span_image_iff_total R] at this rcases this with ⟨l2, hlp, hl⟩ have := @Finsupp.total_apply A A R rw [this] at hl rw [← hl, Finsupp.sum_mul] refine sum_mem ?_ intro t ht change _ * _ ∈ _ rw [smul_mul_assoc] refine smul_mem _ _ ?_ exact subset_span ⟨t, hlp ht, z, hlq hz, rfl⟩
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.LinearAlgebra.Quotient import Mathlib.Algebra.Category.ModuleCat.Basic #align_import algebra.category.Module.epi_mono from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Monomorphisms in `Module R` This file shows that an `R`-linear map is a monomorphism in the category of `R`-modules if and only if it is injective, and similarly an epimorphism if and only if it is surjective. -/ universe v u open CategoryTheory namespace ModuleCat variable {R : Type u} [Ring R] {X Y : ModuleCat.{v} R} (f : X ⟶ Y) variable {M : Type v} [AddCommGroup M] [Module R M] theorem ker_eq_bot_of_mono [Mono f] : LinearMap.ker f = ⊥ := LinearMap.ker_eq_bot_of_cancel fun u v => (@cancel_mono _ _ _ _ _ f _ (↟u) (↟v)).1 set_option linter.uppercaseLean3 false in #align Module.ker_eq_bot_of_mono ModuleCat.ker_eq_bot_of_mono theorem range_eq_top_of_epi [Epi f] : LinearMap.range f = ⊤ := LinearMap.range_eq_top_of_cancel fun u v => (@cancel_epi _ _ _ _ _ f _ (↟u) (↟v)).1 set_option linter.uppercaseLean3 false in #align Module.range_eq_top_of_epi ModuleCat.range_eq_top_of_epi theorem mono_iff_ker_eq_bot : Mono f ↔ LinearMap.ker f = ⊥ := ⟨fun hf => ker_eq_bot_of_mono _, fun hf => ConcreteCategory.mono_of_injective _ <| by convert LinearMap.ker_eq_bot.1 hf⟩ set_option linter.uppercaseLean3 false in #align Module.mono_iff_ker_eq_bot ModuleCat.mono_iff_ker_eq_bot theorem mono_iff_injective : Mono f ↔ Function.Injective f := by rw [mono_iff_ker_eq_bot, LinearMap.ker_eq_bot] set_option linter.uppercaseLean3 false in #align Module.mono_iff_injective ModuleCat.mono_iff_injective theorem epi_iff_range_eq_top : Epi f ↔ LinearMap.range f = ⊤ := ⟨fun _ => range_eq_top_of_epi _, fun hf => ConcreteCategory.epi_of_surjective _ <| LinearMap.range_eq_top.1 hf⟩ set_option linter.uppercaseLean3 false in #align Module.epi_iff_range_eq_top ModuleCat.epi_iff_range_eq_top
Mathlib/Algebra/Category/ModuleCat/EpiMono.lean
55
56
theorem epi_iff_surjective : Epi f ↔ Function.Surjective f := by
rw [epi_iff_range_eq_top, LinearMap.range_eq_top]
/- Copyright (c) 2022 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.Algebra.IsPrimePow import Mathlib.NumberTheory.ArithmeticFunction import Mathlib.Analysis.SpecialFunctions.Log.Basic #align_import number_theory.von_mangoldt from "leanprover-community/mathlib"@"c946d6097a6925ad16d7ec55677bbc977f9846de" /-! # The von Mangoldt Function In this file we define the von Mangoldt function: the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. ## Main Results The main definition for this file is - `ArithmeticFunction.vonMangoldt`: The von Mangoldt function `Λ`. We then prove the classical summation property of the von Mangoldt function in `ArithmeticFunction.vonMangoldt_sum`, that `∑ i ∈ n.divisors, Λ i = Real.log n`, and use this to deduce alternative expressions for the von Mangoldt function via Möbius inversion, see `ArithmeticFunction.sum_moebius_mul_log_eq`. ## Notation We use the standard notation `Λ` to represent the von Mangoldt function. It is accessible in the locales `ArithmeticFunction` (like the notations for other arithmetic functions) and also in the locale `ArithmeticFunction.vonMangoldt`. -/ namespace ArithmeticFunction open Finset Nat open scoped ArithmeticFunction /-- `log` as an arithmetic function `ℕ → ℝ`. Note this is in the `ArithmeticFunction` namespace to indicate that it is bundled as an `ArithmeticFunction` rather than being the usual real logarithm. -/ noncomputable def log : ArithmeticFunction ℝ := ⟨fun n => Real.log n, by simp⟩ #align nat.arithmetic_function.log ArithmeticFunction.log @[simp] theorem log_apply {n : ℕ} : log n = Real.log n := rfl #align nat.arithmetic_function.log_apply ArithmeticFunction.log_apply /-- The `vonMangoldt` function is the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. In the case when `n` is a prime power, `min_fac` will give the appropriate prime, as it is the smallest prime factor. In the `ArithmeticFunction` locale, we have the notation `Λ` for this function. This is also available in the `ArithmeticFunction.vonMangoldt` locale, allowing for selective access to the notation. -/ noncomputable def vonMangoldt : ArithmeticFunction ℝ := ⟨fun n => if IsPrimePow n then Real.log (minFac n) else 0, if_neg not_isPrimePow_zero⟩ #align nat.arithmetic_function.von_mangoldt ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction] notation "Λ" => ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction.vonMangoldt] notation "Λ" => ArithmeticFunction.vonMangoldt theorem vonMangoldt_apply {n : ℕ} : Λ n = if IsPrimePow n then Real.log (minFac n) else 0 := rfl #align nat.arithmetic_function.von_mangoldt_apply ArithmeticFunction.vonMangoldt_apply @[simp] theorem vonMangoldt_apply_one : Λ 1 = 0 := by simp [vonMangoldt_apply] #align nat.arithmetic_function.von_mangoldt_apply_one ArithmeticFunction.vonMangoldt_apply_one @[simp] theorem vonMangoldt_nonneg {n : ℕ} : 0 ≤ Λ n := by rw [vonMangoldt_apply] split_ifs · exact Real.log_nonneg (one_le_cast.2 (Nat.minFac_pos n)) rfl #align nat.arithmetic_function.von_mangoldt_nonneg ArithmeticFunction.vonMangoldt_nonneg theorem vonMangoldt_apply_pow {n k : ℕ} (hk : k ≠ 0) : Λ (n ^ k) = Λ n := by simp only [vonMangoldt_apply, isPrimePow_pow_iff hk, pow_minFac hk] #align nat.arithmetic_function.von_mangoldt_apply_pow ArithmeticFunction.vonMangoldt_apply_pow
Mathlib/NumberTheory/VonMangoldt.lean
94
95
theorem vonMangoldt_apply_prime {p : ℕ} (hp : p.Prime) : Λ p = Real.log p := by
rw [vonMangoldt_apply, Prime.minFac_eq hp, if_pos hp.prime.isPrimePow]
/- Copyright (c) 2022 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic #align_import measure_theory.function.strongly_measurable.lp from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Finitely strongly measurable functions in `Lp` Functions in `Lp` for `0 < p < ∞` are finitely strongly measurable. ## Main statements * `Memℒp.aefinStronglyMeasurable`: if `Memℒp f p μ` with `0 < p < ∞`, then `AEFinStronglyMeasurable f μ`. * `Lp.finStronglyMeasurable`: for `0 < p < ∞`, `Lp` functions are finitely strongly measurable. ## References * Hytönen, Tuomas, Jan Van Neerven, Mark Veraar, and Lutz Weis. Analysis in Banach spaces. Springer, 2016. -/ open MeasureTheory Filter TopologicalSpace Function open scoped ENNReal Topology MeasureTheory namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc variable {α G : Type*} {p : ℝ≥0∞} {m m0 : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup G] {f : α → G}
Mathlib/MeasureTheory/Function/StronglyMeasurable/Lp.lean
40
54
theorem Memℒp.finStronglyMeasurable_of_stronglyMeasurable (hf : Memℒp f p μ) (hf_meas : StronglyMeasurable f) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : FinStronglyMeasurable f μ := by
borelize G haveI : SeparableSpace (Set.range f ∪ {0} : Set G) := hf_meas.separableSpace_range_union_singleton let fs := SimpleFunc.approxOn f hf_meas.measurable (Set.range f ∪ {0}) 0 (by simp) refine ⟨fs, ?_, ?_⟩ · have h_fs_Lp : ∀ n, Memℒp (fs n) p μ := SimpleFunc.memℒp_approxOn_range hf_meas.measurable hf exact fun n => (fs n).measure_support_lt_top_of_memℒp (h_fs_Lp n) hp_ne_zero hp_ne_top · intro x apply SimpleFunc.tendsto_approxOn apply subset_closure simp
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.RingTheory.WittVector.Frobenius import Mathlib.RingTheory.WittVector.Verschiebung import Mathlib.RingTheory.WittVector.MulP #align_import ring_theory.witt_vector.identities from "leanprover-community/mathlib"@"0798037604b2d91748f9b43925fb7570a5f3256c" /-! ## Identities between operations on the ring of Witt vectors In this file we derive common identities between the Frobenius and Verschiebung operators. ## Main declarations * `frobenius_verschiebung`: the composition of Frobenius and Verschiebung is multiplication by `p` * `verschiebung_mul_frobenius`: the “projection formula”: `V(x * F y) = V x * y` * `iterate_verschiebung_mul_coeff`: an identity from [Haze09] 6.2 ## References * [Hazewinkel, *Witt Vectors*][Haze09] * [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21] -/ namespace WittVector variable {p : ℕ} {R : Type*} [hp : Fact p.Prime] [CommRing R] -- type as `\bbW` local notation "𝕎" => WittVector p noncomputable section -- Porting note: `ghost_calc` failure: `simp only []` and the manual instances had to be added. /-- The composition of Frobenius and Verschiebung is multiplication by `p`. -/ theorem frobenius_verschiebung (x : 𝕎 R) : frobenius (verschiebung x) = x * p := by have : IsPoly p fun {R} [CommRing R] x ↦ frobenius (verschiebung x) := IsPoly.comp (hg := frobenius_isPoly p) (hf := verschiebung_isPoly) have : IsPoly p fun {R} [CommRing R] x ↦ x * p := mulN_isPoly p p ghost_calc x ghost_simp [mul_comm] #align witt_vector.frobenius_verschiebung WittVector.frobenius_verschiebung /-- Verschiebung is the same as multiplication by `p` on the ring of Witt vectors of `ZMod p`. -/
Mathlib/RingTheory/WittVector/Identities.lean
51
52
theorem verschiebung_zmod (x : 𝕎 (ZMod p)) : verschiebung x = x * p := by
rw [← frobenius_verschiebung, frobenius_zmodp]
/- Copyright (c) 2022 Moritz Doll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Doll -/ import Mathlib.Algebra.Polynomial.Module.Basic import Mathlib.Analysis.Calculus.Deriv.Pow import Mathlib.Analysis.Calculus.IteratedDeriv.Defs import Mathlib.Analysis.Calculus.MeanValue #align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14" /-! # Taylor's theorem This file defines the Taylor polynomial of a real function `f : ℝ → E`, where `E` is a normed vector space over `ℝ` and proves Taylor's theorem, which states that if `f` is sufficiently smooth, then `f` can be approximated by the Taylor polynomial up to an explicit error term. ## Main definitions * `taylorCoeffWithin`: the Taylor coefficient using `iteratedDerivWithin` * `taylorWithin`: the Taylor polynomial using `iteratedDerivWithin` ## Main statements * `taylor_mean_remainder`: Taylor's theorem with the general form of the remainder term * `taylor_mean_remainder_lagrange`: Taylor's theorem with the Lagrange remainder * `taylor_mean_remainder_cauchy`: Taylor's theorem with the Cauchy remainder * `exists_taylor_mean_remainder_bound`: Taylor's theorem for vector valued functions with a polynomial bound on the remainder ## TODO * the Peano form of the remainder * the integral form of the remainder * Generalization to higher dimensions ## Tags Taylor polynomial, Taylor's theorem -/ open scoped Interval Topology Nat open Set variable {𝕜 E F : Type*} variable [NormedAddCommGroup E] [NormedSpace ℝ E] /-- The `k`th coefficient of the Taylor polynomial. -/ noncomputable def taylorCoeffWithin (f : ℝ → E) (k : ℕ) (s : Set ℝ) (x₀ : ℝ) : E := (k ! : ℝ)⁻¹ • iteratedDerivWithin k f s x₀ #align taylor_coeff_within taylorCoeffWithin /-- The Taylor polynomial with derivatives inside of a set `s`. The Taylor polynomial is given by $$∑_{k=0}^n \frac{(x - x₀)^k}{k!} f^{(k)}(x₀),$$ where $f^{(k)}(x₀)$ denotes the iterated derivative in the set `s`. -/ noncomputable def taylorWithin (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : PolynomialModule ℝ E := (Finset.range (n + 1)).sum fun k => PolynomialModule.comp (Polynomial.X - Polynomial.C x₀) (PolynomialModule.single ℝ k (taylorCoeffWithin f k s x₀)) #align taylor_within taylorWithin /-- The Taylor polynomial with derivatives inside of a set `s` considered as a function `ℝ → E`-/ noncomputable def taylorWithinEval (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : E := PolynomialModule.eval x (taylorWithin f n s x₀) #align taylor_within_eval taylorWithinEval theorem taylorWithin_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : taylorWithin f (n + 1) s x₀ = taylorWithin f n s x₀ + PolynomialModule.comp (Polynomial.X - Polynomial.C x₀) (PolynomialModule.single ℝ (n + 1) (taylorCoeffWithin f (n + 1) s x₀)) := by dsimp only [taylorWithin] rw [Finset.sum_range_succ] #align taylor_within_succ taylorWithin_succ @[simp]
Mathlib/Analysis/Calculus/Taylor.lean
83
92
theorem taylorWithinEval_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : taylorWithinEval f (n + 1) s x₀ x = taylorWithinEval f n s x₀ x + (((n + 1 : ℝ) * n !)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀ := by
simp_rw [taylorWithinEval, taylorWithin_succ, LinearMap.map_add, PolynomialModule.comp_eval] congr simp only [Polynomial.eval_sub, Polynomial.eval_X, Polynomial.eval_C, PolynomialModule.eval_single, mul_inv_rev] dsimp only [taylorCoeffWithin] rw [← mul_smul, mul_comm, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, mul_inv_rev]
/- Copyright (c) 2022 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca -/ import Mathlib.RingTheory.EisensteinCriterion import Mathlib.RingTheory.Polynomial.ScaleRoots #align_import ring_theory.polynomial.eisenstein.basic from "leanprover-community/mathlib"@"2032a878972d5672e7c27c957e7a6e297b044973" /-! # Eisenstein polynomials Given an ideal `𝓟` of a commutative semiring `R`, we say that a polynomial `f : R[X]` is *Eisenstein at `𝓟`* if `f.leadingCoeff ∉ 𝓟`, `∀ n, n < f.natDegree → f.coeff n ∈ 𝓟` and `f.coeff 0 ∉ 𝓟 ^ 2`. In this file we gather miscellaneous results about Eisenstein polynomials. ## Main definitions * `Polynomial.IsEisensteinAt f 𝓟`: the property of being Eisenstein at `𝓟`. ## Main results * `Polynomial.IsEisensteinAt.irreducible`: if a primitive `f` satisfies `f.IsEisensteinAt 𝓟`, where `𝓟.IsPrime`, then `f` is irreducible. ## Implementation details We also define a notion `IsWeaklyEisensteinAt` requiring only that `∀ n < f.natDegree → f.coeff n ∈ 𝓟`. This makes certain results slightly more general and it is useful since it is sometimes better behaved (for example it is stable under `Polynomial.map`). -/ universe u v w z variable {R : Type u} open Ideal Algebra Finset open Polynomial namespace Polynomial /-- Given an ideal `𝓟` of a commutative semiring `R`, we say that a polynomial `f : R[X]` is *weakly Eisenstein at `𝓟`* if `∀ n, n < f.natDegree → f.coeff n ∈ 𝓟`. -/ @[mk_iff] structure IsWeaklyEisensteinAt [CommSemiring R] (f : R[X]) (𝓟 : Ideal R) : Prop where mem : ∀ {n}, n < f.natDegree → f.coeff n ∈ 𝓟 #align polynomial.is_weakly_eisenstein_at Polynomial.IsWeaklyEisensteinAt /-- Given an ideal `𝓟` of a commutative semiring `R`, we say that a polynomial `f : R[X]` is *Eisenstein at `𝓟`* if `f.leadingCoeff ∉ 𝓟`, `∀ n, n < f.natDegree → f.coeff n ∈ 𝓟` and `f.coeff 0 ∉ 𝓟 ^ 2`. -/ @[mk_iff] structure IsEisensteinAt [CommSemiring R] (f : R[X]) (𝓟 : Ideal R) : Prop where leading : f.leadingCoeff ∉ 𝓟 mem : ∀ {n}, n < f.natDegree → f.coeff n ∈ 𝓟 not_mem : f.coeff 0 ∉ 𝓟 ^ 2 #align polynomial.is_eisenstein_at Polynomial.IsEisensteinAt namespace IsWeaklyEisensteinAt section CommSemiring variable [CommSemiring R] {𝓟 : Ideal R} {f : R[X]} (hf : f.IsWeaklyEisensteinAt 𝓟) theorem map {A : Type v} [CommRing A] (φ : R →+* A) : (f.map φ).IsWeaklyEisensteinAt (𝓟.map φ) := by refine (isWeaklyEisensteinAt_iff _ _).2 fun hn => ?_ rw [coeff_map] exact mem_map_of_mem _ (hf.mem (lt_of_lt_of_le hn (natDegree_map_le _ _))) #align polynomial.is_weakly_eisenstein_at.map Polynomial.IsWeaklyEisensteinAt.map end CommSemiring section CommRing variable [CommRing R] {𝓟 : Ideal R} {f : R[X]} (hf : f.IsWeaklyEisensteinAt 𝓟) variable {S : Type v} [CommRing S] [Algebra R S] section Principal variable {p : R} theorem exists_mem_adjoin_mul_eq_pow_natDegree {x : S} (hx : aeval x f = 0) (hmo : f.Monic) (hf : f.IsWeaklyEisensteinAt (Submodule.span R {p})) : ∃ y ∈ adjoin R ({x} : Set S), (algebraMap R S) p * y = x ^ (f.map (algebraMap R S)).natDegree := by rw [aeval_def, Polynomial.eval₂_eq_eval_map, eval_eq_sum_range, range_add_one, sum_insert not_mem_range_self, sum_range, (hmo.map (algebraMap R S)).coeff_natDegree, one_mul] at hx replace hx := eq_neg_of_add_eq_zero_left hx have : ∀ n < f.natDegree, p ∣ f.coeff n := by intro n hn exact mem_span_singleton.1 (by simpa using hf.mem hn) choose! φ hφ using this conv_rhs at hx => congr congr · skip ext i rw [coeff_map, hφ i.1 (lt_of_lt_of_le i.2 (natDegree_map_le _ _)), RingHom.map_mul, mul_assoc] rw [hx, ← mul_sum, neg_eq_neg_one_mul, ← mul_assoc (-1 : S), mul_comm (-1 : S), mul_assoc] refine ⟨-1 * ∑ i : Fin (f.map (algebraMap R S)).natDegree, (algebraMap R S) (φ i.1) * x ^ i.1, ?_, rfl⟩ exact Subalgebra.mul_mem _ (Subalgebra.neg_mem _ (Subalgebra.one_mem _)) (Subalgebra.sum_mem _ fun i _ => Subalgebra.mul_mem _ (Subalgebra.algebraMap_mem _ _) (Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton x)) _)) #align polynomial.is_weakly_eisenstein_at.exists_mem_adjoin_mul_eq_pow_nat_degree Polynomial.IsWeaklyEisensteinAt.exists_mem_adjoin_mul_eq_pow_natDegree
Mathlib/RingTheory/Polynomial/Eisenstein/Basic.lean
111
121
theorem exists_mem_adjoin_mul_eq_pow_natDegree_le {x : S} (hx : aeval x f = 0) (hmo : f.Monic) (hf : f.IsWeaklyEisensteinAt (Submodule.span R {p})) : ∀ i, (f.map (algebraMap R S)).natDegree ≤ i → ∃ y ∈ adjoin R ({x} : Set S), (algebraMap R S) p * y = x ^ i := by
intro i hi obtain ⟨k, hk⟩ := exists_add_of_le hi rw [hk, pow_add] obtain ⟨y, hy, H⟩ := exists_mem_adjoin_mul_eq_pow_natDegree hx hmo hf refine ⟨y * x ^ k, ?_, ?_⟩ · exact Subalgebra.mul_mem _ hy (Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton x)) _) · rw [← mul_assoc _ y, H]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Topology.Separation import Mathlib.Algebra.BigOperators.Finprod #align_import topology.algebra.infinite_sum.basic from "leanprover-community/mathlib"@"3b52265189f3fb43aa631edffce5d060fafaf82f" /-! # Infinite sum and product over a topological monoid This file defines unconditionally convergent sums over a commutative topological additive monoid. For Euclidean spaces (finite dimensional Banach spaces) this is equivalent to absolute convergence. We also define unconditionally convergent products over a commutative topological multiplicative monoid. Note: There are summable sequences which are not unconditionally convergent! The other way holds generally, see `HasSum.tendsto_sum_nat`. ## Implementation notes We say that a function `f : β → α` has an unconditional product of `a` if the function `fun s : Finset β ↦ ∏ b ∈ s, f b` converges to `a` on the `atTop` filter on `Finset β`. In other words, for every neighborhood `U` of `a`, there exists a finite set `s : Finset β` of indices such that `∏ b ∈ s', f b ∈ U` for any finite set `s'` which is a superset of `s`. This may yield some unexpected results. For example, according to this definition, the product `∏' n : ℕ, (1 : ℝ) / 2` unconditionally exists and is equal to `0`. More strikingly, the product `∏' n : ℕ, (n : ℝ)` unconditionally exists and is equal to `0`, because one of its terms is `0` (even though the product of the remaining terms diverges). Users who would prefer that these products be considered not to exist can carry them out in the unit group `ℝˣ` rather than in `ℝ`. ## References * Bourbaki: General Topology (1995), Chapter 3 §5 (Infinite sums in commutative groups) -/ /- **NOTE**. This file is intended to be kept short, just enough to state the basic definitions and six key lemmas relating them together, namely `Summable.hasSum`, `Multipliable.hasProd`, `HasSum.tsum_eq`, `HasProd.tprod_eq`, `Summable.hasSum_iff`, and `Multipliable.hasProd_iff`. Do not add further lemmas here -- add them to `InfiniteSum.Basic` or (preferably) another, more specific file. -/ noncomputable section open Filter Function open scoped Topology variable {α β γ : Type*} section HasProd variable [CommMonoid α] [TopologicalSpace α] /-- Infinite product on a topological monoid The `atTop` filter on `Finset β` is the limit of all finite sets towards the entire type. So we take the product over bigger and bigger sets. This product operation is invariant under reordering. For the definition and many statements, `α` does not need to be a topological monoid. We only add this assumption later, for the lemmas where it is relevant. These are defined in an identical way to infinite sums (`HasSum`). For example, we say that the function `ℕ → ℝ` sending `n` to `1 / 2` has a product of `0`, rather than saying that it does not converge as some authors would. -/ @[to_additive "Infinite sum on a topological monoid The `atTop` filter on `Finset β` is the limit of all finite sets towards the entire type. So we sum up bigger and bigger sets. This sum operation is invariant under reordering. In particular, the function `ℕ → ℝ` sending `n` to `(-1)^n / (n+1)` does not have a sum for this definition, but a series which is absolutely convergent will have the correct sum. This is based on Mario Carneiro's [infinite sum `df-tsms` in Metamath](http://us.metamath.org/mpeuni/df-tsms.html). For the definition and many statements, `α` does not need to be a topological monoid. We only add this assumption later, for the lemmas where it is relevant."] def HasProd (f : β → α) (a : α) : Prop := Tendsto (fun s : Finset β ↦ ∏ b ∈ s, f b) atTop (𝓝 a) #align has_sum HasSum /-- `Multipliable f` means that `f` has some (infinite) product. Use `tprod` to get the value. -/ @[to_additive "`Summable f` means that `f` has some (infinite) sum. Use `tsum` to get the value."] def Multipliable (f : β → α) : Prop := ∃ a, HasProd f a #align summable Summable open scoped Classical in /-- `∏' i, f i` is the product of `f` it exists, or 1 otherwise. -/ @[to_additive "`∑' i, f i` is the sum of `f` it exists, or 0 otherwise."] noncomputable irreducible_def tprod {β} (f : β → α) := if h : Multipliable f then /- Note that the product might not be uniquely defined if the topology is not separated. When the multiplicative support of `f` is finite, we make the most reasonable choice to use the product over the multiplicative support. Otherwise, we choose arbitrarily an `a` satisfying `HasProd f a`. -/ if (mulSupport f).Finite then finprod f else h.choose else 1 #align tsum tsum -- see Note [operator precedence of big operators] @[inherit_doc tprod] notation3 "∏' "(...)", "r:67:(scoped f => tprod f) => r @[inherit_doc tsum] notation3 "∑' "(...)", "r:67:(scoped f => tsum f) => r variable {f g : β → α} {a b : α} {s : Finset β} @[to_additive] theorem HasProd.multipliable (h : HasProd f a) : Multipliable f := ⟨a, h⟩ #align has_sum.summable HasSum.summable @[to_additive]
Mathlib/Topology/Algebra/InfiniteSum/Defs.lean
124
125
theorem tprod_eq_one_of_not_multipliable (h : ¬Multipliable f) : ∏' b, f b = 1 := by
simp [tprod_def, h]
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Data.Option.Defs import Mathlib.Control.Functor #align_import control.traversable.basic from "leanprover-community/mathlib"@"1fc36cc9c8264e6e81253f88be7fb2cb6c92d76a" /-! # Traversable type class Type classes for traversing collections. The concepts and laws are taken from <http://hackage.haskell.org/package/base-4.11.1.0/docs/Data-Traversable.html> Traversable collections are a generalization of functors. Whereas functors (such as `List`) allow us to apply a function to every element, it does not allow functions which external effects encoded in a monad. Consider for instance a functor `invite : email → IO response` that takes an email address, sends an email and waits for a response. If we have a list `guests : List email`, using calling `invite` using `map` gives us the following: `map invite guests : List (IO response)`. It is not what we need. We need something of type `IO (List response)`. Instead of using `map`, we can use `traverse` to send all the invites: `traverse invite guests : IO (List response)`. `traverse` applies `invite` to every element of `guests` and combines all the resulting effects. In the example, the effect is encoded in the monad `IO` but any applicative functor is accepted by `traverse`. For more on how to use traversable, consider the Haskell tutorial: <https://en.wikibooks.org/wiki/Haskell/Traversable> ## Main definitions * `Traversable` type class - exposes the `traverse` function * `sequence` - based on `traverse`, turns a collection of effects into an effect returning a collection * `LawfulTraversable` - laws for a traversable functor * `ApplicativeTransformation` - the notion of a natural transformation for applicative functors ## Tags traversable iterator functor applicative ## References * "Applicative Programming with Effects", by Conor McBride and Ross Paterson, Journal of Functional Programming 18:1 (2008) 1-13, online at <http://www.soi.city.ac.uk/~ross/papers/Applicative.html> * "The Essence of the Iterator Pattern", by Jeremy Gibbons and Bruno Oliveira, in Mathematically-Structured Functional Programming, 2006, online at <http://web.comlab.ox.ac.uk/oucl/work/jeremy.gibbons/publications/#iterator> * "An Investigation of the Laws of Traversals", by Mauro Jaskelioff and Ondrej Rypacek, in Mathematically-Structured Functional Programming, 2012, online at <http://arxiv.org/pdf/1202.2919> -/ open Function hiding comp universe u v w section ApplicativeTransformation variable (F : Type u → Type v) [Applicative F] [LawfulApplicative F] variable (G : Type u → Type w) [Applicative G] [LawfulApplicative G] /-- A transformation between applicative functors. It is a natural transformation such that `app` preserves the `Pure.pure` and `Functor.map` (`<*>`) operations. See `ApplicativeTransformation.preserves_map` for naturality. -/ structure ApplicativeTransformation : Type max (u + 1) v w where /-- The function on objects defined by an `ApplicativeTransformation`. -/ app : ∀ α : Type u, F α → G α /-- An `ApplicativeTransformation` preserves `pure`. -/ preserves_pure' : ∀ {α : Type u} (x : α), app _ (pure x) = pure x /-- An `ApplicativeTransformation` intertwines `seq`. -/ preserves_seq' : ∀ {α β : Type u} (x : F (α → β)) (y : F α), app _ (x <*> y) = app _ x <*> app _ y #align applicative_transformation ApplicativeTransformation end ApplicativeTransformation namespace ApplicativeTransformation variable (F : Type u → Type v) [Applicative F] [LawfulApplicative F] variable (G : Type u → Type w) [Applicative G] [LawfulApplicative G] instance : CoeFun (ApplicativeTransformation F G) fun _ => ∀ {α}, F α → G α := ⟨fun η ↦ η.app _⟩ variable {F G} -- This cannot be a `simp` lemma, as the RHS is a coercion which contains `η.app`. theorem app_eq_coe (η : ApplicativeTransformation F G) : η.app = η := rfl #align applicative_transformation.app_eq_coe ApplicativeTransformation.app_eq_coe @[simp] theorem coe_mk (f : ∀ α : Type u, F α → G α) (pp ps) : (ApplicativeTransformation.mk f @pp @ps) = f := rfl #align applicative_transformation.coe_mk ApplicativeTransformation.coe_mk protected theorem congr_fun (η η' : ApplicativeTransformation F G) (h : η = η') {α : Type u} (x : F α) : η x = η' x := congrArg (fun η'' : ApplicativeTransformation F G => η'' x) h #align applicative_transformation.congr_fun ApplicativeTransformation.congr_fun protected theorem congr_arg (η : ApplicativeTransformation F G) {α : Type u} {x y : F α} (h : x = y) : η x = η y := congrArg (fun z : F α => η z) h #align applicative_transformation.congr_arg ApplicativeTransformation.congr_arg
Mathlib/Control/Traversable/Basic.lean
113
117
theorem coe_inj ⦃η η' : ApplicativeTransformation F G⦄ (h : (η : ∀ α, F α → G α) = η') : η = η' := by
cases η cases η' congr
/- Copyright (c) 2020 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import Mathlib.Data.Finset.Prod import Mathlib.Data.Sym.Basic import Mathlib.Data.Sym.Sym2.Init import Mathlib.Data.SetLike.Basic #align_import data.sym.sym2 from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # The symmetric square This file defines the symmetric square, which is `α × α` modulo swapping. This is also known as the type of unordered pairs. More generally, the symmetric square is the second symmetric power (see `Data.Sym.Basic`). The equivalence is `Sym2.equivSym`. From the point of view that an unordered pair is equivalent to a multiset of cardinality two (see `Sym2.equivMultiset`), there is a `Mem` instance `Sym2.Mem`, which is a `Prop`-valued membership test. Given `h : a ∈ z` for `z : Sym2 α`, then `Mem.other h` is the other element of the pair, defined using `Classical.choice`. If `α` has decidable equality, then `h.other'` computably gives the other element. The universal property of `Sym2` is provided as `Sym2.lift`, which states that functions from `Sym2 α` are equivalent to symmetric two-argument functions from `α`. Recall that an undirected graph (allowing self loops, but no multiple edges) is equivalent to a symmetric relation on the vertex type `α`. Given a symmetric relation on `α`, the corresponding edge set is constructed by `Sym2.fromRel` which is a special case of `Sym2.lift`. ## Notation The element `Sym2.mk (a, b)` can be written as `s(a, b)` for short. ## Tags symmetric square, unordered pairs, symmetric powers -/ assert_not_exists MonoidWithZero open Finset Function Sym universe u variable {α β γ : Type*} namespace Sym2 /-- This is the relation capturing the notion of pairs equivalent up to permutations. -/ @[aesop (rule_sets := [Sym2]) [safe [constructors, cases], norm]] inductive Rel (α : Type u) : α × α → α × α → Prop | refl (x y : α) : Rel _ (x, y) (x, y) | swap (x y : α) : Rel _ (x, y) (y, x) #align sym2.rel Sym2.Rel #align sym2.rel.refl Sym2.Rel.refl #align sym2.rel.swap Sym2.Rel.swap attribute [refl] Rel.refl @[symm] theorem Rel.symm {x y : α × α} : Rel α x y → Rel α y x := by aesop (rule_sets := [Sym2]) #align sym2.rel.symm Sym2.Rel.symm @[trans] theorem Rel.trans {x y z : α × α} (a : Rel α x y) (b : Rel α y z) : Rel α x z := by aesop (rule_sets := [Sym2]) #align sym2.rel.trans Sym2.Rel.trans theorem Rel.is_equivalence : Equivalence (Rel α) := { refl := fun (x, y) ↦ Rel.refl x y, symm := Rel.symm, trans := Rel.trans } #align sym2.rel.is_equivalence Sym2.Rel.is_equivalence /-- One can use `attribute [local instance] Sym2.Rel.setoid` to temporarily make `Quotient` functionality work for `α × α`. -/ def Rel.setoid (α : Type u) : Setoid (α × α) := ⟨Rel α, Rel.is_equivalence⟩ #align sym2.rel.setoid Sym2.Rel.setoid @[simp]
Mathlib/Data/Sym/Sym2.lean
88
89
theorem rel_iff' {p q : α × α} : Rel α p q ↔ p = q ∨ p = q.swap := by
aesop (rule_sets := [Sym2])
/- Copyright (c) 2019 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Yury Kudryashov -/ import Mathlib.Analysis.Normed.Group.InfiniteSum import Mathlib.Analysis.Normed.MulAction import Mathlib.Topology.Algebra.Order.LiminfLimsup import Mathlib.Topology.PartialHomeomorph #align_import analysis.asymptotics.asymptotics from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Asymptotics We introduce these relations: * `IsBigOWith c l f g` : "f is big O of g along l with constant c"; * `f =O[l] g` : "f is big O of g along l"; * `f =o[l] g` : "f is little o of g along l". Here `l` is any filter on the domain of `f` and `g`, which are assumed to be the same. The codomains of `f` and `g` do not need to be the same; all that is needed that there is a norm associated with these types, and it is the norm that is compared asymptotically. The relation `IsBigOWith c` is introduced to factor out common algebraic arguments in the proofs of similar properties of `IsBigO` and `IsLittleO`. Usually proofs outside of this file should use `IsBigO` instead. Often the ranges of `f` and `g` will be the real numbers, in which case the norm is the absolute value. In general, we have `f =O[l] g ↔ (fun x ↦ ‖f x‖) =O[l] (fun x ↦ ‖g x‖)`, and similarly for `IsLittleO`. But our setup allows us to use the notions e.g. with functions to the integers, rationals, complex numbers, or any normed vector space without mentioning the norm explicitly. If `f` and `g` are functions to a normed field like the reals or complex numbers and `g` is always nonzero, we have `f =o[l] g ↔ Tendsto (fun x ↦ f x / (g x)) l (𝓝 0)`. In fact, the right-to-left direction holds without the hypothesis on `g`, and in the other direction it suffices to assume that `f` is zero wherever `g` is. (This generalization is useful in defining the Fréchet derivative.) -/ open Filter Set open scoped Classical open Topology Filter NNReal namespace Asymptotics set_option linter.uppercaseLean3 false variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*} {F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {E''' : Type*} {R : Type*} {R' : Type*} {𝕜 : Type*} {𝕜' : Type*} variable [Norm E] [Norm F] [Norm G] variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G'] [NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R] [SeminormedAddGroup E'''] [SeminormedRing R'] variable [NormedDivisionRing 𝕜] [NormedDivisionRing 𝕜'] variable {c c' c₁ c₂ : ℝ} {f : α → E} {g : α → F} {k : α → G} variable {f' : α → E'} {g' : α → F'} {k' : α → G'} variable {f'' : α → E''} {g'' : α → F''} {k'' : α → G''} variable {l l' : Filter α} section Defs /-! ### Definitions -/ /-- This version of the Landau notation `IsBigOWith C l f g` where `f` and `g` are two functions on a type `α` and `l` is a filter on `α`, means that eventually for `l`, `‖f‖` is bounded by `C * ‖g‖`. In other words, `‖f‖ / ‖g‖` is eventually bounded by `C`, modulo division by zero issues that are avoided by this definition. Probably you want to use `IsBigO` instead of this relation. -/ irreducible_def IsBigOWith (c : ℝ) (l : Filter α) (f : α → E) (g : α → F) : Prop := ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ #align asymptotics.is_O_with Asymptotics.IsBigOWith /-- Definition of `IsBigOWith`. We record it in a lemma as `IsBigOWith` is irreducible. -/
Mathlib/Analysis/Asymptotics/Asymptotics.lean
89
89
theorem isBigOWith_iff : IsBigOWith c l f g ↔ ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by
rw [IsBigOWith_def]
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.GDelta #align_import topology.metric_space.baire from "leanprover-community/mathlib"@"b9e46fe101fc897fb2e7edaf0bf1f09ea49eb81a" /-! # Baire spaces A topological space is called a *Baire space* if a countable intersection of dense open subsets is dense. Baire theorems say that all completely metrizable spaces and all locally compact regular spaces are Baire spaces. We prove the theorems in `Mathlib/Topology/Baire/CompleteMetrizable` and `Mathlib/Topology/Baire/LocallyCompactRegular`. In this file we prove various corollaries of Baire theorems. The good concept underlying the theorems is that of a Gδ set, i.e., a countable intersection of open sets. Then Baire theorem can also be formulated as the fact that a countable intersection of dense Gδ sets is a dense Gδ set. We deduce this version from Baire property. We also prove the important consequence that, if the space is covered by a countable union of closed sets, then the union of their interiors is dense. We also prove that in Baire spaces, the `residual` sets are exactly those containing a dense Gδ set. -/ noncomputable section open scoped Topology open Filter Set TopologicalSpace variable {X α : Type*} {ι : Sort*} section BaireTheorem variable [TopologicalSpace X] [BaireSpace X] /-- Definition of a Baire space. -/ theorem dense_iInter_of_isOpen_nat {f : ℕ → Set X} (ho : ∀ n, IsOpen (f n)) (hd : ∀ n, Dense (f n)) : Dense (⋂ n, f n) := BaireSpace.baire_property f ho hd #align dense_Inter_of_open_nat dense_iInter_of_isOpen_nat /-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
Mathlib/Topology/Baire/Lemmas.lean
50
55
theorem dense_sInter_of_isOpen {S : Set (Set X)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable) (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
rcases S.eq_empty_or_nonempty with h | h · simp [h] · rcases hS.exists_eq_range h with ⟨f, rfl⟩ exact dense_iInter_of_isOpen_nat (forall_mem_range.1 ho) (forall_mem_range.1 hd)
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen -/ import Mathlib.Data.Matrix.Block import Mathlib.Data.Matrix.RowCol #align_import linear_algebra.matrix.trace from "leanprover-community/mathlib"@"32b08ef840dd25ca2e47e035c5da03ce16d2dc3c" /-! # Trace of a matrix This file defines the trace of a matrix, the map sending a matrix to the sum of its diagonal entries. See also `LinearAlgebra.Trace` for the trace of an endomorphism. ## Tags matrix, trace, diagonal -/ open Matrix namespace Matrix variable {ι m n p : Type*} {α R S : Type*} variable [Fintype m] [Fintype n] [Fintype p] section AddCommMonoid variable [AddCommMonoid R] /-- The trace of a square matrix. For more bundled versions, see: * `Matrix.traceAddMonoidHom` * `Matrix.traceLinearMap` -/ def trace (A : Matrix n n R) : R := ∑ i, diag A i #align matrix.trace Matrix.trace lemma trace_diagonal {o} [Fintype o] [DecidableEq o] (d : o → R) : trace (diagonal d) = ∑ i, d i := by simp only [trace, diag_apply, diagonal_apply_eq] variable (n R) @[simp] theorem trace_zero : trace (0 : Matrix n n R) = 0 := (Finset.sum_const (0 : R)).trans <| smul_zero _ #align matrix.trace_zero Matrix.trace_zero variable {n R} @[simp] lemma trace_eq_zero_of_isEmpty [IsEmpty n] (A : Matrix n n R) : trace A = 0 := by simp [trace] @[simp] theorem trace_add (A B : Matrix n n R) : trace (A + B) = trace A + trace B := Finset.sum_add_distrib #align matrix.trace_add Matrix.trace_add @[simp] theorem trace_smul [Monoid α] [DistribMulAction α R] (r : α) (A : Matrix n n R) : trace (r • A) = r • trace A := Finset.smul_sum.symm #align matrix.trace_smul Matrix.trace_smul @[simp] theorem trace_transpose (A : Matrix n n R) : trace Aᵀ = trace A := rfl #align matrix.trace_transpose Matrix.trace_transpose @[simp] theorem trace_conjTranspose [StarAddMonoid R] (A : Matrix n n R) : trace Aᴴ = star (trace A) := (star_sum _ _).symm #align matrix.trace_conj_transpose Matrix.trace_conjTranspose variable (n α R) /-- `Matrix.trace` as an `AddMonoidHom` -/ @[simps] def traceAddMonoidHom : Matrix n n R →+ R where toFun := trace map_zero' := trace_zero n R map_add' := trace_add #align matrix.trace_add_monoid_hom Matrix.traceAddMonoidHom /-- `Matrix.trace` as a `LinearMap` -/ @[simps] def traceLinearMap [Semiring α] [Module α R] : Matrix n n R →ₗ[α] R where toFun := trace map_add' := trace_add map_smul' := trace_smul #align matrix.trace_linear_map Matrix.traceLinearMap variable {n α R} @[simp] theorem trace_list_sum (l : List (Matrix n n R)) : trace l.sum = (l.map trace).sum := map_list_sum (traceAddMonoidHom n R) l #align matrix.trace_list_sum Matrix.trace_list_sum @[simp] theorem trace_multiset_sum (s : Multiset (Matrix n n R)) : trace s.sum = (s.map trace).sum := map_multiset_sum (traceAddMonoidHom n R) s #align matrix.trace_multiset_sum Matrix.trace_multiset_sum @[simp] theorem trace_sum (s : Finset ι) (f : ι → Matrix n n R) : trace (∑ i ∈ s, f i) = ∑ i ∈ s, trace (f i) := map_sum (traceAddMonoidHom n R) f s #align matrix.trace_sum Matrix.trace_sum theorem _root_.AddMonoidHom.map_trace [AddCommMonoid S] (f : R →+ S) (A : Matrix n n R) : f (trace A) = trace (f.mapMatrix A) := map_sum f (fun i => diag A i) Finset.univ lemma trace_blockDiagonal [DecidableEq p] (M : p → Matrix n n R) : trace (blockDiagonal M) = ∑ i, trace (M i) := by simp [blockDiagonal, trace, Finset.sum_comm (γ := n)] lemma trace_blockDiagonal' [DecidableEq p] {m : p → Type*} [∀ i, Fintype (m i)] (M : ∀ i, Matrix (m i) (m i) R) : trace (blockDiagonal' M) = ∑ i, trace (M i) := by simp [blockDiagonal', trace, Finset.sum_sigma'] end AddCommMonoid section AddCommGroup variable [AddCommGroup R] @[simp] theorem trace_sub (A B : Matrix n n R) : trace (A - B) = trace A - trace B := Finset.sum_sub_distrib #align matrix.trace_sub Matrix.trace_sub @[simp] theorem trace_neg (A : Matrix n n R) : trace (-A) = -trace A := Finset.sum_neg_distrib #align matrix.trace_neg Matrix.trace_neg end AddCommGroup section One variable [DecidableEq n] [AddCommMonoidWithOne R] @[simp] theorem trace_one : trace (1 : Matrix n n R) = Fintype.card n := by simp_rw [trace, diag_one, Pi.one_def, Finset.sum_const, nsmul_one, Finset.card_univ] #align matrix.trace_one Matrix.trace_one end One section Mul @[simp] theorem trace_transpose_mul [AddCommMonoid R] [Mul R] (A : Matrix m n R) (B : Matrix n m R) : trace (Aᵀ * Bᵀ) = trace (A * B) := Finset.sum_comm #align matrix.trace_transpose_mul Matrix.trace_transpose_mul theorem trace_mul_comm [AddCommMonoid R] [CommSemigroup R] (A : Matrix m n R) (B : Matrix n m R) : trace (A * B) = trace (B * A) := by rw [← trace_transpose, ← trace_transpose_mul, transpose_mul] #align matrix.trace_mul_comm Matrix.trace_mul_comm
Mathlib/LinearAlgebra/Matrix/Trace.lean
172
174
theorem trace_mul_cycle [NonUnitalCommSemiring R] (A : Matrix m n R) (B : Matrix n p R) (C : Matrix p m R) : trace (A * B * C) = trace (C * A * B) := by
rw [trace_mul_comm, Matrix.mul_assoc]
/- Copyright (c) 2021 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying, Yury Kudryashov -/ import Mathlib.MeasureTheory.Measure.Restrict #align_import measure_theory.measure.mutually_singular from "leanprover-community/mathlib"@"70a4f2197832bceab57d7f41379b2592d1110570" /-! # Mutually singular measures Two measures `μ`, `ν` are said to be mutually singular (`MeasureTheory.Measure.MutuallySingular`, localized notation `μ ⟂ₘ ν`) if there exists a measurable set `s` such that `μ s = 0` and `ν sᶜ = 0`. The measurability of `s` is an unnecessary assumption (see `MeasureTheory.Measure.MutuallySingular.mk`) but we keep it because this way `rcases (h : μ ⟂ₘ ν)` gives us a measurable set and usually it is easy to prove measurability. In this file we define the predicate `MeasureTheory.Measure.MutuallySingular` and prove basic facts about it. ## Tags measure, mutually singular -/ open Set open MeasureTheory NNReal ENNReal namespace MeasureTheory namespace Measure variable {α : Type*} {m0 : MeasurableSpace α} {μ μ₁ μ₂ ν ν₁ ν₂ : Measure α} /-- Two measures `μ`, `ν` are said to be mutually singular if there exists a measurable set `s` such that `μ s = 0` and `ν sᶜ = 0`. -/ def MutuallySingular {_ : MeasurableSpace α} (μ ν : Measure α) : Prop := ∃ s : Set α, MeasurableSet s ∧ μ s = 0 ∧ ν sᶜ = 0 #align measure_theory.measure.mutually_singular MeasureTheory.Measure.MutuallySingular @[inherit_doc MeasureTheory.Measure.MutuallySingular] scoped[MeasureTheory] infixl:60 " ⟂ₘ " => MeasureTheory.Measure.MutuallySingular namespace MutuallySingular theorem mk {s t : Set α} (hs : μ s = 0) (ht : ν t = 0) (hst : univ ⊆ s ∪ t) : MutuallySingular μ ν := by use toMeasurable μ s, measurableSet_toMeasurable _ _, (measure_toMeasurable _).trans hs refine measure_mono_null (fun x hx => (hst trivial).resolve_left fun hxs => hx ?_) ht exact subset_toMeasurable _ _ hxs #align measure_theory.measure.mutually_singular.mk MeasureTheory.Measure.MutuallySingular.mk /-- A set such that `μ h.nullSet = 0` and `ν h.nullSetᶜ = 0`. -/ def nullSet (h : μ ⟂ₘ ν) : Set α := h.choose lemma measurableSet_nullSet (h : μ ⟂ₘ ν) : MeasurableSet h.nullSet := h.choose_spec.1 @[simp] lemma measure_nullSet (h : μ ⟂ₘ ν) : μ h.nullSet = 0 := h.choose_spec.2.1 @[simp] lemma measure_compl_nullSet (h : μ ⟂ₘ ν) : ν h.nullSetᶜ = 0 := h.choose_spec.2.2 -- TODO: this is proved by simp, but is not simplified in other contexts without the @[simp] -- attribute. Also, the linter does not complain about that attribute. @[simp] lemma restrict_nullSet (h : μ ⟂ₘ ν) : μ.restrict h.nullSet = 0 := by simp -- TODO: this is proved by simp, but is not simplified in other contexts without the @[simp] -- attribute. Also, the linter does not complain about that attribute. @[simp] lemma restrict_compl_nullSet (h : μ ⟂ₘ ν) : ν.restrict h.nullSetᶜ = 0 := by simp @[simp] theorem zero_right : μ ⟂ₘ 0 := ⟨∅, MeasurableSet.empty, measure_empty, rfl⟩ #align measure_theory.measure.mutually_singular.zero_right MeasureTheory.Measure.MutuallySingular.zero_right @[symm] theorem symm (h : ν ⟂ₘ μ) : μ ⟂ₘ ν := let ⟨i, hi, his, hit⟩ := h ⟨iᶜ, hi.compl, hit, (compl_compl i).symm ▸ his⟩ #align measure_theory.measure.mutually_singular.symm MeasureTheory.Measure.MutuallySingular.symm theorem comm : μ ⟂ₘ ν ↔ ν ⟂ₘ μ := ⟨fun h => h.symm, fun h => h.symm⟩ #align measure_theory.measure.mutually_singular.comm MeasureTheory.Measure.MutuallySingular.comm @[simp] theorem zero_left : 0 ⟂ₘ μ := zero_right.symm #align measure_theory.measure.mutually_singular.zero_left MeasureTheory.Measure.MutuallySingular.zero_left theorem mono_ac (h : μ₁ ⟂ₘ ν₁) (hμ : μ₂ ≪ μ₁) (hν : ν₂ ≪ ν₁) : μ₂ ⟂ₘ ν₂ := let ⟨s, hs, h₁, h₂⟩ := h ⟨s, hs, hμ h₁, hν h₂⟩ #align measure_theory.measure.mutually_singular.mono_ac MeasureTheory.Measure.MutuallySingular.mono_ac theorem mono (h : μ₁ ⟂ₘ ν₁) (hμ : μ₂ ≤ μ₁) (hν : ν₂ ≤ ν₁) : μ₂ ⟂ₘ ν₂ := h.mono_ac hμ.absolutelyContinuous hν.absolutelyContinuous #align measure_theory.measure.mutually_singular.mono MeasureTheory.Measure.MutuallySingular.mono @[simp] lemma self_iff (μ : Measure α) : μ ⟂ₘ μ ↔ μ = 0 := by refine ⟨?_, fun h ↦ by (rw [h]; exact zero_left)⟩ rintro ⟨s, hs, hμs, hμs_compl⟩ suffices μ Set.univ = 0 by rwa [measure_univ_eq_zero] at this rw [← Set.union_compl_self s, measure_union disjoint_compl_right hs.compl, hμs, hμs_compl, add_zero] @[simp]
Mathlib/MeasureTheory/Measure/MutuallySingular.lean
114
120
theorem sum_left {ι : Type*} [Countable ι] {μ : ι → Measure α} : sum μ ⟂ₘ ν ↔ ∀ i, μ i ⟂ₘ ν := by
refine ⟨fun h i => h.mono (le_sum _ _) le_rfl, fun H => ?_⟩ choose s hsm hsμ hsν using H refine ⟨⋂ i, s i, MeasurableSet.iInter hsm, ?_, ?_⟩ · rw [sum_apply _ (MeasurableSet.iInter hsm), ENNReal.tsum_eq_zero] exact fun i => measure_mono_null (iInter_subset _ _) (hsμ i) · rwa [compl_iInter, measure_iUnion_null_iff]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl, Sander Dahmen, Scott Morrison, Chris Hughes, Anne Baanen, Junyan Xu -/ import Mathlib.LinearAlgebra.Basis.VectorSpace import Mathlib.LinearAlgebra.Dimension.Finite import Mathlib.SetTheory.Cardinal.Subfield import Mathlib.LinearAlgebra.Dimension.RankNullity #align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5" /-! # Dimension of vector spaces In this file we provide results about `Module.rank` and `FiniteDimensional.finrank` of vector spaces over division rings. ## Main statements For vector spaces (i.e. modules over a field), we have * `rank_quotient_add_rank_of_divisionRing`: if `V₁` is a submodule of `V`, then `Module.rank (V/V₁) + Module.rank V₁ = Module.rank V`. * `rank_range_add_rank_ker`: the rank-nullity theorem. * `rank_dual_eq_card_dual_of_aleph0_le_rank`: The **Erdős-Kaplansky Theorem** which says that the dimension of an infinite-dimensional dual space over a division ring has dimension equal to its cardinality. -/ noncomputable section universe u₀ u v v' v'' u₁' w w' variable {K R : Type u} {V V₁ V₂ V₃ : Type v} {V' V'₁ : Type v'} {V'' : Type v''} variable {ι : Type w} {ι' : Type w'} {η : Type u₁'} {φ : η → Type*} open Cardinal Basis Submodule Function Set section Module section DivisionRing variable [DivisionRing K] variable [AddCommGroup V] [Module K V] variable [AddCommGroup V'] [Module K V'] variable [AddCommGroup V₁] [Module K V₁] /-- If a vector space has a finite dimension, the index set of `Basis.ofVectorSpace` is finite. -/ theorem Basis.finite_ofVectorSpaceIndex_of_rank_lt_aleph0 (h : Module.rank K V < ℵ₀) : (Basis.ofVectorSpaceIndex K V).Finite := finite_def.2 <| (Basis.ofVectorSpace K V).nonempty_fintype_index_of_rank_lt_aleph0 h #align basis.finite_of_vector_space_index_of_rank_lt_aleph_0 Basis.finite_ofVectorSpaceIndex_of_rank_lt_aleph0 /-- Also see `rank_quotient_add_rank`. -/ theorem rank_quotient_add_rank_of_divisionRing (p : Submodule K V) : Module.rank K (V ⧸ p) + Module.rank K p = Module.rank K V := by classical let ⟨f⟩ := quotient_prod_linearEquiv p exact rank_prod'.symm.trans f.rank_eq instance DivisionRing.hasRankNullity : HasRankNullity.{u₀} K where rank_quotient_add_rank := rank_quotient_add_rank_of_divisionRing exists_set_linearIndependent V _ _ := by let b := Module.Free.chooseBasis K V refine ⟨range b, ?_, b.linearIndependent.to_subtype_range⟩ rw [← lift_injective.eq_iff, mk_range_eq_of_injective b.injective, Module.Free.rank_eq_card_chooseBasisIndex] section variable [AddCommGroup V₂] [Module K V₂] variable [AddCommGroup V₃] [Module K V₃] open LinearMap /-- This is mostly an auxiliary lemma for `Submodule.rank_sup_add_rank_inf_eq`. -/
Mathlib/LinearAlgebra/Dimension/DivisionRing.lean
81
108
theorem rank_add_rank_split (db : V₂ →ₗ[K] V) (eb : V₃ →ₗ[K] V) (cd : V₁ →ₗ[K] V₂) (ce : V₁ →ₗ[K] V₃) (hde : ⊤ ≤ LinearMap.range db ⊔ LinearMap.range eb) (hgd : ker cd = ⊥) (eq : db.comp cd = eb.comp ce) (eq₂ : ∀ d e, db d = eb e → ∃ c, cd c = d ∧ ce c = e) : Module.rank K V + Module.rank K V₁ = Module.rank K V₂ + Module.rank K V₃ := by
have hf : Surjective (coprod db eb) := by rwa [← range_eq_top, range_coprod, eq_top_iff] conv => rhs rw [← rank_prod', rank_eq_of_surjective hf] congr 1 apply LinearEquiv.rank_eq let L : V₁ →ₗ[K] ker (coprod db eb) := by -- Porting note: this is needed to avoid a timeout refine LinearMap.codRestrict _ (prod cd (-ce)) ?_ · intro c simp only [add_eq_zero_iff_eq_neg, LinearMap.prod_apply, mem_ker, Pi.prod, coprod_apply, neg_neg, map_neg, neg_apply] exact LinearMap.ext_iff.1 eq c refine LinearEquiv.ofBijective L ⟨?_, ?_⟩ · rw [← ker_eq_bot, ker_codRestrict, ker_prod, hgd, bot_inf_eq] · rw [← range_eq_top, eq_top_iff, range_codRestrict, ← map_le_iff_le_comap, Submodule.map_top, range_subtype] rintro ⟨d, e⟩ have h := eq₂ d (-e) simp only [add_eq_zero_iff_eq_neg, LinearMap.prod_apply, mem_ker, SetLike.mem_coe, Prod.mk.inj_iff, coprod_apply, map_neg, neg_apply, LinearMap.mem_range, Pi.prod] at h ⊢ intro hde rcases h hde with ⟨c, h₁, h₂⟩ refine ⟨c, h₁, ?_⟩ rw [h₂, _root_.neg_neg]
/- Copyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Analysis.Convex.Combination import Mathlib.Analysis.Convex.Extreme #align_import analysis.convex.independent from "leanprover-community/mathlib"@"fefd8a38be7811574cd2ec2f77d3a393a407f112" /-! # Convex independence This file defines convex independent families of points. Convex independence is closely related to affine independence. In both cases, no point can be written as a combination of others. When the combination is affine (that is, any coefficients), this yields affine independence. When the combination is convex (that is, all coefficients are nonnegative), then this yields convex independence. In particular, affine independence implies convex independence. ## Main declarations * `ConvexIndependent p`: Convex independence of the indexed family `p : ι → E`. Every point of the family only belongs to convex hulls of sets of the family containing it. * `convexIndependent_iff_finset`: Carathéodory's theorem allows us to only check finsets to conclude convex independence. * `Convex.convexIndependent_extremePoints`: Extreme points of a convex set are convex independent. ## References * https://en.wikipedia.org/wiki/Convex_position ## TODO Prove `AffineIndependent.convexIndependent`. This requires some glue between `affineCombination` and `Finset.centerMass`. ## Tags independence, convex position -/ open scoped Classical open Affine open Finset Function variable {𝕜 E ι : Type*} section OrderedSemiring variable (𝕜) [OrderedSemiring 𝕜] [AddCommGroup E] [Module 𝕜 E] {s t : Set E} /-- An indexed family is said to be convex independent if every point only belongs to convex hulls of sets containing it. -/ def ConvexIndependent (p : ι → E) : Prop := ∀ (s : Set ι) (x : ι), p x ∈ convexHull 𝕜 (p '' s) → x ∈ s #align convex_independent ConvexIndependent variable {𝕜} /-- A family with at most one point is convex independent. -/
Mathlib/Analysis/Convex/Independent.lean
65
69
theorem Subsingleton.convexIndependent [Subsingleton ι] (p : ι → E) : ConvexIndependent 𝕜 p := by
intro s x hx have : (convexHull 𝕜 (p '' s)).Nonempty := ⟨p x, hx⟩ rw [convexHull_nonempty_iff, Set.image_nonempty] at this rwa [Subsingleton.mem_iff_nonempty]
/- Copyright (c) 2014 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Simon Hudon, Mario Carneiro -/ import Aesop import Mathlib.Algebra.Group.Defs import Mathlib.Data.Nat.Defs import Mathlib.Data.Int.Defs import Mathlib.Logic.Function.Basic import Mathlib.Tactic.Cases import Mathlib.Tactic.SimpRw import Mathlib.Tactic.SplitIfs #align_import algebra.group.basic from "leanprover-community/mathlib"@"a07d750983b94c530ab69a726862c2ab6802b38c" /-! # Basic lemmas about semigroups, monoids, and groups This file lists various basic lemmas about semigroups, monoids, and groups. Most proofs are one-liners from the corresponding axioms. For the definitions of semigroups, monoids and groups, see `Algebra/Group/Defs.lean`. -/ assert_not_exists MonoidWithZero assert_not_exists DenselyOrdered open Function universe u variable {α β G M : Type*} section ite variable [Pow α β] @[to_additive (attr := simp) dite_smul] lemma pow_dite (p : Prop) [Decidable p] (a : α) (b : p → β) (c : ¬ p → β) : a ^ (if h : p then b h else c h) = if h : p then a ^ b h else a ^ c h := by split_ifs <;> rfl @[to_additive (attr := simp) smul_dite] lemma dite_pow (p : Prop) [Decidable p] (a : p → α) (b : ¬ p → α) (c : β) : (if h : p then a h else b h) ^ c = if h : p then a h ^ c else b h ^ c := by split_ifs <;> rfl @[to_additive (attr := simp) ite_smul] lemma pow_ite (p : Prop) [Decidable p] (a : α) (b c : β) : a ^ (if p then b else c) = if p then a ^ b else a ^ c := pow_dite _ _ _ _ @[to_additive (attr := simp) smul_ite] lemma ite_pow (p : Prop) [Decidable p] (a b : α) (c : β) : (if p then a else b) ^ c = if p then a ^ c else b ^ c := dite_pow _ _ _ _ set_option linter.existingAttributeWarning false in attribute [to_additive (attr := simp)] dite_smul smul_dite ite_smul smul_ite end ite section IsLeftCancelMul variable [Mul G] [IsLeftCancelMul G] @[to_additive] theorem mul_right_injective (a : G) : Injective (a * ·) := fun _ _ ↦ mul_left_cancel #align mul_right_injective mul_right_injective #align add_right_injective add_right_injective @[to_additive (attr := simp)] theorem mul_right_inj (a : G) {b c : G} : a * b = a * c ↔ b = c := (mul_right_injective a).eq_iff #align mul_right_inj mul_right_inj #align add_right_inj add_right_inj @[to_additive] theorem mul_ne_mul_right (a : G) {b c : G} : a * b ≠ a * c ↔ b ≠ c := (mul_right_injective a).ne_iff #align mul_ne_mul_right mul_ne_mul_right #align add_ne_add_right add_ne_add_right end IsLeftCancelMul section IsRightCancelMul variable [Mul G] [IsRightCancelMul G] @[to_additive] theorem mul_left_injective (a : G) : Function.Injective (· * a) := fun _ _ ↦ mul_right_cancel #align mul_left_injective mul_left_injective #align add_left_injective add_left_injective @[to_additive (attr := simp)] theorem mul_left_inj (a : G) {b c : G} : b * a = c * a ↔ b = c := (mul_left_injective a).eq_iff #align mul_left_inj mul_left_inj #align add_left_inj add_left_inj @[to_additive] theorem mul_ne_mul_left (a : G) {b c : G} : b * a ≠ c * a ↔ b ≠ c := (mul_left_injective a).ne_iff #align mul_ne_mul_left mul_ne_mul_left #align add_ne_add_left add_ne_add_left end IsRightCancelMul section Semigroup variable [Semigroup α] @[to_additive] instance Semigroup.to_isAssociative : Std.Associative (α := α) (· * ·) := ⟨mul_assoc⟩ #align semigroup.to_is_associative Semigroup.to_isAssociative #align add_semigroup.to_is_associative AddSemigroup.to_isAssociative /-- Composing two multiplications on the left by `y` then `x` is equal to a multiplication on the left by `x * y`. -/ @[to_additive (attr := simp) "Composing two additions on the left by `y` then `x` is equal to an addition on the left by `x + y`."] theorem comp_mul_left (x y : α) : (x * ·) ∘ (y * ·) = (x * y * ·) := by ext z simp [mul_assoc] #align comp_mul_left comp_mul_left #align comp_add_left comp_add_left /-- Composing two multiplications on the right by `y` and `x` is equal to a multiplication on the right by `y * x`. -/ @[to_additive (attr := simp) "Composing two additions on the right by `y` and `x` is equal to an addition on the right by `y + x`."]
Mathlib/Algebra/Group/Basic.lean
128
130
theorem comp_mul_right (x y : α) : (· * x) ∘ (· * y) = (· * (y * x)) := by
ext z simp [mul_assoc]
/- Copyright (c) 2023 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.NormedSpace.HahnBanach.Extension import Mathlib.Analysis.NormedSpace.HahnBanach.Separation import Mathlib.LinearAlgebra.Dual import Mathlib.Analysis.NormedSpace.BoundedLinearMaps /-! # Spaces with separating dual We introduce a typeclass `SeparatingDual R V`, registering that the points of the topological module `V` over `R` can be separated by continuous linear forms. This property is satisfied for normed spaces over `ℝ` or `ℂ` (by the analytic Hahn-Banach theorem) and for locally convex topological spaces over `ℝ` (by the geometric Hahn-Banach theorem). Under the assumption `SeparatingDual R V`, we show in `SeparatingDual.exists_continuousLinearMap_apply_eq` that the group of continuous linear equivalences acts transitively on the set of nonzero vectors. -/ /-- When `E` is a topological module over a topological ring `R`, the class `SeparatingDual R E` registers that continuous linear forms on `E` separate points of `E`. -/ @[mk_iff separatingDual_def] class SeparatingDual (R V : Type*) [Ring R] [AddCommGroup V] [TopologicalSpace V] [TopologicalSpace R] [Module R V] : Prop := /-- Any nonzero vector can be mapped by a continuous linear map to a nonzero scalar. -/ exists_ne_zero' : ∀ (x : V), x ≠ 0 → ∃ f : V →L[R] R, f x ≠ 0 instance {E : Type*} [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E] [Module ℝ E] [ContinuousSMul ℝ E] [LocallyConvexSpace ℝ E] [T1Space E] : SeparatingDual ℝ E := ⟨fun x hx ↦ by rcases geometric_hahn_banach_point_point hx.symm with ⟨f, hf⟩ simp only [map_zero] at hf exact ⟨f, hf.ne'⟩⟩ instance {E 𝕜 : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] : SeparatingDual 𝕜 E := ⟨fun x hx ↦ by rcases exists_dual_vector 𝕜 x hx with ⟨f, -, hf⟩ refine ⟨f, ?_⟩ simpa [hf] using hx⟩ namespace SeparatingDual section Ring variable {R V : Type*} [Ring R] [AddCommGroup V] [TopologicalSpace V] [TopologicalSpace R] [Module R V] [SeparatingDual R V] lemma exists_ne_zero {x : V} (hx : x ≠ 0) : ∃ f : V →L[R] R, f x ≠ 0 := exists_ne_zero' x hx theorem exists_separating_of_ne {x y : V} (h : x ≠ y) : ∃ f : V →L[R] R, f x ≠ f y := by rcases exists_ne_zero (R := R) (sub_ne_zero_of_ne h) with ⟨f, hf⟩ exact ⟨f, by simpa [sub_ne_zero] using hf⟩ protected theorem t1Space [T1Space R] : T1Space V := by apply t1Space_iff_exists_open.2 (fun x y hxy ↦ ?_) rcases exists_separating_of_ne (R := R) hxy with ⟨f, hf⟩ exact ⟨f ⁻¹' {f y}ᶜ, isOpen_compl_singleton.preimage f.continuous, hf, by simp⟩ protected theorem t2Space [T2Space R] : T2Space V := by apply (t2Space_iff _).2 (fun {x} {y} hxy ↦ ?_) rcases exists_separating_of_ne (R := R) hxy with ⟨f, hf⟩ exact separated_by_continuous f.continuous hf end Ring section Field variable {R V : Type*} [Field R] [AddCommGroup V] [TopologicalSpace R] [TopologicalSpace V] [TopologicalRing R] [TopologicalAddGroup V] [Module R V] [SeparatingDual R V] -- TODO (@alreadydone): this could generalize to CommRing R if we were to add a section theorem _root_.separatingDual_iff_injective : SeparatingDual R V ↔ Function.Injective (ContinuousLinearMap.coeLM (R := R) R (M := V) (N₃ := R)).flip := by simp_rw [separatingDual_def, Ne, injective_iff_map_eq_zero] congrm ∀ v, ?_ rw [not_imp_comm, LinearMap.ext_iff] push_neg; rfl open Function in /-- Given a finite-dimensional subspace `W` of a space `V` with separating dual, any linear functional on `W` extends to a continuous linear functional on `V`. This is stated more generally for an injective linear map from `W` to `V`. -/ theorem dualMap_surjective_iff {W} [AddCommGroup W] [Module R W] [FiniteDimensional R W] {f : W →ₗ[R] V} : Surjective (f.dualMap ∘ ContinuousLinearMap.toLinearMap) ↔ Injective f := by constructor <;> intro hf · exact LinearMap.dualMap_surjective_iff.mp hf.of_comp have := (separatingDual_iff_injective.mp ‹_›).comp hf rw [← LinearMap.coe_comp] at this exact LinearMap.flip_surjective_iff₁.mpr this lemma exists_eq_one {x : V} (hx : x ≠ 0) : ∃ f : V →L[R] R, f x = 1 := by rcases exists_ne_zero (R := R) hx with ⟨f, hf⟩ exact ⟨(f x)⁻¹ • f, inv_mul_cancel hf⟩
Mathlib/Analysis/NormedSpace/HahnBanach/SeparatingDual.lean
104
112
theorem exists_eq_one_ne_zero_of_ne_zero_pair {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : ∃ f : V →L[R] R, f x = 1 ∧ f y ≠ 0 := by
obtain ⟨u, ux⟩ : ∃ u : V →L[R] R, u x = 1 := exists_eq_one hx rcases ne_or_eq (u y) 0 with uy|uy · exact ⟨u, ux, uy⟩ obtain ⟨v, vy⟩ : ∃ v : V →L[R] R, v y = 1 := exists_eq_one hy rcases ne_or_eq (v x) 0 with vx|vx · exact ⟨(v x)⁻¹ • v, inv_mul_cancel vx, show (v x)⁻¹ * v y ≠ 0 by simp [vx, vy]⟩ · exact ⟨u + v, by simp [ux, vx], by simp [uy, vy]⟩
/- 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 -/ import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.ContDiff.Defs #align_import analysis.calculus.iterated_deriv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # One-dimensional iterated derivatives We define the `n`-th derivative of a function `f : 𝕜 → F` as a function `iteratedDeriv n f : 𝕜 → F`, as well as a version on domains `iteratedDerivWithin n f s : 𝕜 → F`, and prove their basic properties. ## Main definitions and results Let `𝕜` be a nontrivially normed field, and `F` a normed vector space over `𝕜`. Let `f : 𝕜 → F`. * `iteratedDeriv n f` is the `n`-th derivative of `f`, seen as a function from `𝕜` to `F`. It is defined as the `n`-th Fréchet derivative (which is a multilinear map) applied to the vector `(1, ..., 1)`, to take advantage of all the existing framework, but we show that it coincides with the naive iterative definition. * `iteratedDeriv_eq_iterate` states that the `n`-th derivative of `f` is obtained by starting from `f` and differentiating it `n` times. * `iteratedDerivWithin n f s` is the `n`-th derivative of `f` within the domain `s`. It only behaves well when `s` has the unique derivative property. * `iteratedDerivWithin_eq_iterate` states that the `n`-th derivative of `f` in the domain `s` is obtained by starting from `f` and differentiating it `n` times within `s`. This only holds when `s` has the unique derivative property. ## Implementation details The results are deduced from the corresponding results for the more general (multilinear) iterated Fréchet derivative. For this, we write `iteratedDeriv n f` as the composition of `iteratedFDeriv 𝕜 n f` and a continuous linear equiv. As continuous linear equivs respect differentiability and commute with differentiation, this makes it possible to prove readily that the derivative of the `n`-th derivative is the `n+1`-th derivative in `iteratedDerivWithin_succ`, by translating the corresponding result `iteratedFDerivWithin_succ_apply_left` for the iterated Fréchet derivative. -/ noncomputable section open scoped Classical Topology open Filter Asymptotics Set variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] /-- The `n`-th iterated derivative of a function from `𝕜` to `F`, as a function from `𝕜` to `F`. -/ def iteratedDeriv (n : ℕ) (f : 𝕜 → F) (x : 𝕜) : F := (iteratedFDeriv 𝕜 n f x : (Fin n → 𝕜) → F) fun _ : Fin n => 1 #align iterated_deriv iteratedDeriv /-- The `n`-th iterated derivative of a function from `𝕜` to `F` within a set `s`, as a function from `𝕜` to `F`. -/ def iteratedDerivWithin (n : ℕ) (f : 𝕜 → F) (s : Set 𝕜) (x : 𝕜) : F := (iteratedFDerivWithin 𝕜 n f s x : (Fin n → 𝕜) → F) fun _ : Fin n => 1 #align iterated_deriv_within iteratedDerivWithin variable {n : ℕ} {f : 𝕜 → F} {s : Set 𝕜} {x : 𝕜}
Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean
69
71
theorem iteratedDerivWithin_univ : iteratedDerivWithin n f univ = iteratedDeriv n f := by
ext x rw [iteratedDerivWithin, iteratedDeriv, iteratedFDerivWithin_univ]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Init.Classical import Mathlib.Order.FixedPoints import Mathlib.Order.Zorn #align_import set_theory.cardinal.schroeder_bernstein from "leanprover-community/mathlib"@"1e05171a5e8cf18d98d9cf7b207540acb044acae" /-! # Schröder-Bernstein theorem, well-ordering of cardinals This file proves the Schröder-Bernstein theorem (see `schroeder_bernstein`), the well-ordering of cardinals (see `min_injective`) and the totality of their order (see `total`). ## Notes Cardinals are naturally ordered by `α ≤ β ↔ ∃ f : a → β, Injective f`: * `schroeder_bernstein` states that, given injections `α → β` and `β → α`, one can get a bijection `α → β`. This corresponds to the antisymmetry of the order. * The order is also well-founded: any nonempty set of cardinals has a minimal element. `min_injective` states that by saying that there exists an element of the set that injects into all others. Cardinals are defined and further developed in the folder `SetTheory.Cardinal`. -/ open Set Function open scoped Classical universe u v namespace Function namespace Embedding section antisymm variable {α : Type u} {β : Type v} /-- **The Schröder-Bernstein Theorem**: Given injections `α → β` and `β → α`, we can get a bijection `α → β`. -/
Mathlib/SetTheory/Cardinal/SchroederBernstein.lean
47
76
theorem schroeder_bernstein {f : α → β} {g : β → α} (hf : Function.Injective f) (hg : Function.Injective g) : ∃ h : α → β, Bijective h := by
cases' isEmpty_or_nonempty β with hβ hβ · have : IsEmpty α := Function.isEmpty f exact ⟨_, ((Equiv.equivEmpty α).trans (Equiv.equivEmpty β).symm).bijective⟩ set F : Set α →o Set α := { toFun := fun s => (g '' (f '' s)ᶜ)ᶜ monotone' := fun s t hst => compl_subset_compl.mpr <| image_subset _ <| compl_subset_compl.mpr <| image_subset _ hst } -- Porting note: dot notation `F.lfp` doesn't work here set s : Set α := OrderHom.lfp F have hs : (g '' (f '' s)ᶜ)ᶜ = s := F.map_lfp have hns : g '' (f '' s)ᶜ = sᶜ := compl_injective (by simp [hs]) set g' := invFun g have g'g : LeftInverse g' g := leftInverse_invFun hg have hg'ns : g' '' sᶜ = (f '' s)ᶜ := by rw [← hns, g'g.image_image] set h : α → β := s.piecewise f g' have : Surjective h := by rw [← range_iff_surjective, range_piecewise, hg'ns, union_compl_self] have : Injective h := by refine (injective_piecewise_iff _).2 ⟨hf.injOn, ?_, ?_⟩ · intro x hx y hy hxy obtain ⟨x', _, rfl⟩ : x ∈ g '' (f '' s)ᶜ := by rwa [hns] obtain ⟨y', _, rfl⟩ : y ∈ g '' (f '' s)ᶜ := by rwa [hns] rw [g'g _, g'g _] at hxy rw [hxy] · intro x hx y hy hxy obtain ⟨y', hy', rfl⟩ : y ∈ g '' (f '' s)ᶜ := by rwa [hns] rw [g'g _] at hxy exact hy' ⟨x, hx, hxy⟩ exact ⟨h, ‹Injective h›, ‹Surjective h›⟩
/- Copyright (c) 2022 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Dynamics.Ergodic.MeasurePreserving #align_import dynamics.ergodic.ergodic from "leanprover-community/mathlib"@"809e920edfa343283cea507aedff916ea0f1bd88" /-! # Ergodic maps and measures Let `f : α → α` be measure preserving with respect to a measure `μ`. We say `f` is ergodic with respect to `μ` (or `μ` is ergodic with respect to `f`) if the only measurable sets `s` such that `f⁻¹' s = s` are either almost empty or full. In this file we define ergodic maps / measures together with quasi-ergodic maps / measures and provide some basic API. Quasi-ergodicity is a weaker condition than ergodicity for which the measure preserving condition is relaxed to quasi measure preserving. # Main definitions: * `PreErgodic`: the ergodicity condition without the measure preserving condition. This exists to share code between the `Ergodic` and `QuasiErgodic` definitions. * `Ergodic`: the definition of ergodic maps / measures. * `QuasiErgodic`: the definition of quasi ergodic maps / measures. * `Ergodic.quasiErgodic`: an ergodic map / measure is quasi ergodic. * `QuasiErgodic.ae_empty_or_univ'`: when the map is quasi measure preserving, one may relax the strict invariance condition to almost invariance in the ergodicity condition. -/ open Set Function Filter MeasureTheory MeasureTheory.Measure open ENNReal variable {α : Type*} {m : MeasurableSpace α} (f : α → α) {s : Set α} /-- A map `f : α → α` is said to be pre-ergodic with respect to a measure `μ` if any measurable strictly invariant set is either almost empty or full. -/ structure PreErgodic (μ : Measure α := by volume_tac) : Prop where ae_empty_or_univ : ∀ ⦃s⦄, MeasurableSet s → f ⁻¹' s = s → s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ #align pre_ergodic PreErgodic /-- A map `f : α → α` is said to be ergodic with respect to a measure `μ` if it is measure preserving and pre-ergodic. -/ -- porting note (#5171): removed @[nolint has_nonempty_instance] structure Ergodic (μ : Measure α := by volume_tac) extends MeasurePreserving f μ μ, PreErgodic f μ : Prop #align ergodic Ergodic /-- A map `f : α → α` is said to be quasi ergodic with respect to a measure `μ` if it is quasi measure preserving and pre-ergodic. -/ -- porting note (#5171): removed @[nolint has_nonempty_instance] structure QuasiErgodic (μ : Measure α := by volume_tac) extends QuasiMeasurePreserving f μ μ, PreErgodic f μ : Prop #align quasi_ergodic QuasiErgodic variable {f} {μ : Measure α} namespace PreErgodic theorem measure_self_or_compl_eq_zero (hf : PreErgodic f μ) (hs : MeasurableSet s) (hs' : f ⁻¹' s = s) : μ s = 0 ∨ μ sᶜ = 0 := by simpa using hf.ae_empty_or_univ hs hs' #align pre_ergodic.measure_self_or_compl_eq_zero PreErgodic.measure_self_or_compl_eq_zero theorem ae_mem_or_ae_nmem (hf : PreErgodic f μ) (hsm : MeasurableSet s) (hs : f ⁻¹' s = s) : (∀ᵐ x ∂μ, x ∈ s) ∨ ∀ᵐ x ∂μ, x ∉ s := (hf.ae_empty_or_univ hsm hs).symm.imp eventuallyEq_univ.1 eventuallyEq_empty.1 /-- On a probability space, the (pre)ergodicity condition is a zero one law. -/ theorem prob_eq_zero_or_one [IsProbabilityMeasure μ] (hf : PreErgodic f μ) (hs : MeasurableSet s) (hs' : f ⁻¹' s = s) : μ s = 0 ∨ μ s = 1 := by simpa [hs] using hf.measure_self_or_compl_eq_zero hs hs' #align pre_ergodic.prob_eq_zero_or_one PreErgodic.prob_eq_zero_or_one theorem of_iterate (n : ℕ) (hf : PreErgodic f^[n] μ) : PreErgodic f μ := ⟨fun _ hs hs' => hf.ae_empty_or_univ hs <| IsFixedPt.preimage_iterate hs' n⟩ #align pre_ergodic.of_iterate PreErgodic.of_iterate end PreErgodic namespace MeasureTheory.MeasurePreserving variable {β : Type*} {m' : MeasurableSpace β} {μ' : Measure β} {s' : Set β} {g : α → β}
Mathlib/Dynamics/Ergodic/Ergodic.lean
89
96
theorem preErgodic_of_preErgodic_conjugate (hg : MeasurePreserving g μ μ') (hf : PreErgodic f μ) {f' : β → β} (h_comm : g ∘ f = f' ∘ g) : PreErgodic f' μ' := ⟨by intro s hs₀ hs₁ replace hs₁ : f ⁻¹' (g ⁻¹' s) = g ⁻¹' s := by
rw [← preimage_comp, h_comm, preimage_comp, hs₁] cases' hf.ae_empty_or_univ (hg.measurable hs₀) hs₁ with hs₂ hs₂ <;> [left; right] · simpa only [ae_eq_empty, hg.measure_preimage hs₀] using hs₂ · simpa only [ae_eq_univ, ← preimage_compl, hg.measure_preimage hs₀.compl] using hs₂⟩
/- Copyright (c) 2020 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.MeasureTheory.Measure.Content import Mathlib.MeasureTheory.Group.Prod import Mathlib.Topology.Algebra.Group.Compact #align_import measure_theory.measure.haar.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Haar measure In this file we prove the existence of Haar measure for a locally compact Hausdorff topological group. We follow the write-up by Jonathan Gleason, *Existence and Uniqueness of Haar Measure*. This is essentially the same argument as in https://en.wikipedia.org/wiki/Haar_measure#A_construction_using_compact_subsets. We construct the Haar measure first on compact sets. For this we define `(K : U)` as the (smallest) number of left-translates of `U` that are needed to cover `K` (`index` in the formalization). Then we define a function `h` on compact sets as `lim_U (K : U) / (K₀ : U)`, where `U` becomes a smaller and smaller open neighborhood of `1`, and `K₀` is a fixed compact set with nonempty interior. This function is `chaar` in the formalization, and we define the limit formally using Tychonoff's theorem. This function `h` forms a content, which we can extend to an outer measure and then a measure (`haarMeasure`). We normalize the Haar measure so that the measure of `K₀` is `1`. Note that `μ` need not coincide with `h` on compact sets, according to [halmos1950measure, ch. X, §53 p.233]. However, we know that `h(K)` lies between `μ(Kᵒ)` and `μ(K)`, where `ᵒ` denotes the interior. We also give a form of uniqueness of Haar measure, for σ-finite measures on second-countable locally compact groups. For more involved statements not assuming second-countability, see the file `MeasureTheory.Measure.Haar.Unique`. ## Main Declarations * `haarMeasure`: the Haar measure on a locally compact Hausdorff group. This is a left invariant regular measure. It takes as argument a compact set of the group (with non-empty interior), and is normalized so that the measure of the given set is 1. * `haarMeasure_self`: the Haar measure is normalized. * `isMulLeftInvariant_haarMeasure`: the Haar measure is left invariant. * `regular_haarMeasure`: the Haar measure is a regular measure. * `isHaarMeasure_haarMeasure`: the Haar measure satisfies the `IsHaarMeasure` typeclass, i.e., it is invariant and gives finite mass to compact sets and positive mass to nonempty open sets. * `haar` : some choice of a Haar measure, on a locally compact Hausdorff group, constructed as `haarMeasure K` where `K` is some arbitrary choice of a compact set with nonempty interior. * `haarMeasure_unique`: Every σ-finite left invariant measure on a second-countable locally compact Hausdorff group is a scalar multiple of the Haar measure. ## References * Paul Halmos (1950), Measure Theory, §53 * Jonathan Gleason, Existence and Uniqueness of Haar Measure - Note: step 9, page 8 contains a mistake: the last defined `μ` does not extend the `μ` on compact sets, see Halmos (1950) p. 233, bottom of the page. This makes some other steps (like step 11) invalid. * https://en.wikipedia.org/wiki/Haar_measure -/ noncomputable section open Set Inv Function TopologicalSpace MeasurableSpace open scoped NNReal Classical ENNReal Pointwise Topology namespace MeasureTheory namespace Measure section Group variable {G : Type*} [Group G] /-! We put the internal functions in the construction of the Haar measure in a namespace, so that the chosen names don't clash with other declarations. We first define a couple of the functions before proving the properties (that require that `G` is a topological group). -/ namespace haar -- Porting note: Even in `noncomputable section`, a definition with `to_additive` require -- `noncomputable` to generate an additive definition. -- Please refer to leanprover/lean4#2077. /-- The index or Haar covering number or ratio of `K` w.r.t. `V`, denoted `(K : V)`: it is the smallest number of (left) translates of `V` that is necessary to cover `K`. It is defined to be 0 if no finite number of translates cover `K`. -/ @[to_additive addIndex "additive version of `MeasureTheory.Measure.haar.index`"] noncomputable def index (K V : Set G) : ℕ := sInf <| Finset.card '' { t : Finset G | K ⊆ ⋃ g ∈ t, (fun h => g * h) ⁻¹' V } #align measure_theory.measure.haar.index MeasureTheory.Measure.haar.index #align measure_theory.measure.haar.add_index MeasureTheory.Measure.haar.addIndex @[to_additive addIndex_empty] theorem index_empty {V : Set G} : index ∅ V = 0 := by simp only [index, Nat.sInf_eq_zero]; left; use ∅ simp only [Finset.card_empty, empty_subset, mem_setOf_eq, eq_self_iff_true, and_self_iff] #align measure_theory.measure.haar.index_empty MeasureTheory.Measure.haar.index_empty #align measure_theory.measure.haar.add_index_empty MeasureTheory.Measure.haar.addIndex_empty variable [TopologicalSpace G] /-- `prehaar K₀ U K` is a weighted version of the index, defined as `(K : U)/(K₀ : U)`. In the applications `K₀` is compact with non-empty interior, `U` is open containing `1`, and `K` is any compact set. The argument `K` is a (bundled) compact set, so that we can consider `prehaar K₀ U` as an element of `haarProduct` (below). -/ @[to_additive "additive version of `MeasureTheory.Measure.haar.prehaar`"] noncomputable def prehaar (K₀ U : Set G) (K : Compacts G) : ℝ := (index (K : Set G) U : ℝ) / index K₀ U #align measure_theory.measure.haar.prehaar MeasureTheory.Measure.haar.prehaar #align measure_theory.measure.haar.add_prehaar MeasureTheory.Measure.haar.addPrehaar @[to_additive] theorem prehaar_empty (K₀ : PositiveCompacts G) {U : Set G} : prehaar (K₀ : Set G) U ⊥ = 0 := by rw [prehaar, Compacts.coe_bot, index_empty, Nat.cast_zero, zero_div] #align measure_theory.measure.haar.prehaar_empty MeasureTheory.Measure.haar.prehaar_empty #align measure_theory.measure.haar.add_prehaar_empty MeasureTheory.Measure.haar.addPrehaar_empty @[to_additive]
Mathlib/MeasureTheory/Measure/Haar/Basic.lean
128
129
theorem prehaar_nonneg (K₀ : PositiveCompacts G) {U : Set G} (K : Compacts G) : 0 ≤ prehaar (K₀ : Set G) U K := by
apply div_nonneg <;> norm_cast <;> apply zero_le
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad -/ import Mathlib.Algebra.Group.Int import Mathlib.Algebra.Order.Group.Abs #align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # The integers form a linear ordered group This file contains the linear ordered group instance on the integers. See note [foundational algebra order theory]. ## Recursors * `Int.rec`: Sign disjunction. Something is true/defined on `ℤ` if it's true/defined for nonnegative and for negative values. (Defined in core Lean 3) * `Int.inductionOn`: Simple growing induction on positive numbers, plus simple decreasing induction on negative numbers. Note that this recursor is currently only `Prop`-valued. * `Int.inductionOn'`: Simple growing induction for numbers greater than `b`, plus simple decreasing induction on numbers less than `b`. -/ -- We should need only a minimal development of sets in order to get here. assert_not_exists Set.Subsingleton assert_not_exists Ring open Function Nat namespace Int theorem natCast_strictMono : StrictMono (· : ℕ → ℤ) := fun _ _ ↦ Int.ofNat_lt.2 #align int.coe_nat_strict_mono Int.natCast_strictMono @[deprecated (since := "2024-05-25")] alias coe_nat_strictMono := natCast_strictMono instance linearOrderedAddCommGroup : LinearOrderedAddCommGroup ℤ where __ := instLinearOrder __ := instAddCommGroup add_le_add_left _ _ := Int.add_le_add_left /-! ### Miscellaneous lemmas -/ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a | (n : ℕ) => abs_of_nonneg <| ofNat_zero_le _ | -[_+1] => abs_of_nonpos <| le_of_lt <| negSucc_lt_zero _ #align int.abs_eq_nat_abs Int.abs_eq_natAbs @[simp, norm_cast] lemma natCast_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| := n.abs_eq_natAbs.symm #align int.coe_nat_abs Int.natCast_natAbs theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs]; rfl #align int.nat_abs_abs Int.natAbs_abs theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by rw [abs_eq_natAbs, sign_mul_natAbs a] #align int.sign_mul_abs Int.sign_mul_abs lemma natAbs_le_self_sq (a : ℤ) : (Int.natAbs a : ℤ) ≤ a ^ 2 := by rw [← Int.natAbs_sq a, sq] norm_cast apply Nat.le_mul_self #align int.abs_le_self_sq Int.natAbs_le_self_sq alias natAbs_le_self_pow_two := natAbs_le_self_sq lemma le_self_sq (b : ℤ) : b ≤ b ^ 2 := le_trans le_natAbs (natAbs_le_self_sq _) #align int.le_self_sq Int.le_self_sq alias le_self_pow_two := le_self_sq #align int.le_self_pow_two Int.le_self_pow_two @[norm_cast] lemma abs_natCast (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (natCast_nonneg n) #align int.abs_coe_nat Int.abs_natCast
Mathlib/Algebra/Order/Group/Int.lean
81
82
theorem natAbs_sub_pos_iff {i j : ℤ} : 0 < natAbs (i - j) ↔ i ≠ j := by
rw [natAbs_pos, ne_eq, sub_eq_zero]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Scott Morrison -/ import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms import Mathlib.CategoryTheory.Limits.Shapes.Kernels import Mathlib.CategoryTheory.Abelian.Basic import Mathlib.CategoryTheory.Subobject.Lattice import Mathlib.Order.Atoms #align_import category_theory.simple from "leanprover-community/mathlib"@"4ed0bcaef698011b0692b93a042a2282f490f6b6" /-! # Simple objects We define simple objects in any category with zero morphisms. A simple object is an object `Y` such that any monomorphism `f : X ⟶ Y` is either an isomorphism or zero (but not both). This is formalized as a `Prop` valued typeclass `Simple X`. In some contexts, especially representation theory, simple objects are called "irreducibles". If a morphism `f` out of a simple object is nonzero and has a kernel, then that kernel is zero. (We state this as `kernel.ι f = 0`, but should add `kernel f ≅ 0`.) When the category is abelian, being simple is the same as being cosimple (although we do not state a separate typeclass for this). As a consequence, any nonzero epimorphism out of a simple object is an isomorphism, and any nonzero morphism into a simple object has trivial cokernel. We show that any simple object is indecomposable. -/ noncomputable section open CategoryTheory.Limits namespace CategoryTheory universe v u variable {C : Type u} [Category.{v} C] section variable [HasZeroMorphisms C] /-- An object is simple if monomorphisms into it are (exclusively) either isomorphisms or zero. -/ class Simple (X : C) : Prop where mono_isIso_iff_nonzero : ∀ {Y : C} (f : Y ⟶ X) [Mono f], IsIso f ↔ f ≠ 0 #align category_theory.simple CategoryTheory.Simple /-- A nonzero monomorphism to a simple object is an isomorphism. -/ theorem isIso_of_mono_of_nonzero {X Y : C} [Simple Y] {f : X ⟶ Y} [Mono f] (w : f ≠ 0) : IsIso f := (Simple.mono_isIso_iff_nonzero f).mpr w #align category_theory.is_iso_of_mono_of_nonzero CategoryTheory.isIso_of_mono_of_nonzero theorem Simple.of_iso {X Y : C} [Simple Y] (i : X ≅ Y) : Simple X := { mono_isIso_iff_nonzero := fun f m => by haveI : Mono (f ≫ i.hom) := mono_comp _ _ constructor · intro h w have j : IsIso (f ≫ i.hom) := by infer_instance rw [Simple.mono_isIso_iff_nonzero] at j subst w simp at j · intro h have j : IsIso (f ≫ i.hom) := by apply isIso_of_mono_of_nonzero intro w apply h simpa using (cancel_mono i.inv).2 w rw [← Category.comp_id f, ← i.hom_inv_id, ← Category.assoc] infer_instance } #align category_theory.simple.of_iso CategoryTheory.Simple.of_iso theorem Simple.iff_of_iso {X Y : C} (i : X ≅ Y) : Simple X ↔ Simple Y := ⟨fun _ => Simple.of_iso i.symm, fun _ => Simple.of_iso i⟩ #align category_theory.simple.iff_of_iso CategoryTheory.Simple.iff_of_iso theorem kernel_zero_of_nonzero_from_simple {X Y : C} [Simple X] {f : X ⟶ Y} [HasKernel f] (w : f ≠ 0) : kernel.ι f = 0 := by classical by_contra h haveI := isIso_of_mono_of_nonzero h exact w (eq_zero_of_epi_kernel f) #align category_theory.kernel_zero_of_nonzero_from_simple CategoryTheory.kernel_zero_of_nonzero_from_simple -- See also `mono_of_nonzero_from_simple`, which requires `Preadditive C`. /-- A nonzero morphism `f` to a simple object is an epimorphism (assuming `f` has an image, and `C` has equalizers). -/ theorem epi_of_nonzero_to_simple [HasEqualizers C] {X Y : C} [Simple Y] {f : X ⟶ Y} [HasImage f] (w : f ≠ 0) : Epi f := by rw [← image.fac f] haveI : IsIso (image.ι f) := isIso_of_mono_of_nonzero fun h => w (eq_zero_of_image_eq_zero h) apply epi_comp #align category_theory.epi_of_nonzero_to_simple CategoryTheory.epi_of_nonzero_to_simple theorem mono_to_simple_zero_of_not_iso {X Y : C} [Simple Y] {f : X ⟶ Y} [Mono f] (w : IsIso f → False) : f = 0 := by classical by_contra h exact w (isIso_of_mono_of_nonzero h) #align category_theory.mono_to_simple_zero_of_not_iso CategoryTheory.mono_to_simple_zero_of_not_iso theorem id_nonzero (X : C) [Simple.{v} X] : 𝟙 X ≠ 0 := (Simple.mono_isIso_iff_nonzero (𝟙 X)).mp (by infer_instance) #align category_theory.id_nonzero CategoryTheory.id_nonzero instance (X : C) [Simple.{v} X] : Nontrivial (End X) := nontrivial_of_ne 1 _ (id_nonzero X) section
Mathlib/CategoryTheory/Simple.lean
119
120
theorem Simple.not_isZero (X : C) [Simple X] : ¬IsZero X := by
simpa [Limits.IsZero.iff_id_eq_zero] using id_nonzero X
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Data.Matrix.Basis import Mathlib.LinearAlgebra.Basis import Mathlib.LinearAlgebra.Pi #align_import linear_algebra.std_basis from "leanprover-community/mathlib"@"13bce9a6b6c44f6b4c91ac1c1d2a816e2533d395" /-! # The standard basis This file defines the standard basis `Pi.basis (s : ∀ j, Basis (ι j) R (M j))`, which is the `Σ j, ι j`-indexed basis of `Π j, M j`. The basis vectors are given by `Pi.basis s ⟨j, i⟩ j' = LinearMap.stdBasis R M j' (s j) i = if j = j' then s i else 0`. The standard basis on `R^η`, i.e. `η → R` is called `Pi.basisFun`. To give a concrete example, `LinearMap.stdBasis R (fun (i : Fin 3) ↦ R) i 1` gives the `i`th unit basis vector in `R³`, and `Pi.basisFun R (Fin 3)` proves this is a basis over `Fin 3 → R`. ## Main definitions - `LinearMap.stdBasis R M`: if `x` is a basis vector of `M i`, then `LinearMap.stdBasis R M i x` is the `i`th standard basis vector of `Π i, M i`. - `Pi.basis s`: given a basis `s i` for each `M i`, the standard basis on `Π i, M i` - `Pi.basisFun R η`: the standard basis on `R^η`, i.e. `η → R`, given by `Pi.basisFun R η i j = if i = j then 1 else 0`. - `Matrix.stdBasis R n m`: the standard basis on `Matrix n m R`, given by `Matrix.stdBasis R n m (i, j) i' j' = if (i, j) = (i', j') then 1 else 0`. -/ open Function Set Submodule namespace LinearMap variable (R : Type*) {ι : Type*} [Semiring R] (φ : ι → Type*) [∀ i, AddCommMonoid (φ i)] [∀ i, Module R (φ i)] [DecidableEq ι] /-- The standard basis of the product of `φ`. -/ def stdBasis : ∀ i : ι, φ i →ₗ[R] ∀ i, φ i := single #align linear_map.std_basis LinearMap.stdBasis theorem stdBasis_apply (i : ι) (b : φ i) : stdBasis R φ i b = update (0 : (a : ι) → φ a) i b := rfl #align linear_map.std_basis_apply LinearMap.stdBasis_apply @[simp] theorem stdBasis_apply' (i i' : ι) : (stdBasis R (fun _x : ι => R) i) 1 i' = ite (i = i') 1 0 := by rw [LinearMap.stdBasis_apply, Function.update_apply, Pi.zero_apply] congr 1; rw [eq_iff_iff, eq_comm] #align linear_map.std_basis_apply' LinearMap.stdBasis_apply' theorem coe_stdBasis (i : ι) : ⇑(stdBasis R φ i) = Pi.single i := rfl #align linear_map.coe_std_basis LinearMap.coe_stdBasis @[simp] theorem stdBasis_same (i : ι) (b : φ i) : stdBasis R φ i b i = b := Pi.single_eq_same i b #align linear_map.std_basis_same LinearMap.stdBasis_same theorem stdBasis_ne (i j : ι) (h : j ≠ i) (b : φ i) : stdBasis R φ i b j = 0 := Pi.single_eq_of_ne h b #align linear_map.std_basis_ne LinearMap.stdBasis_ne theorem stdBasis_eq_pi_diag (i : ι) : stdBasis R φ i = pi (diag i) := by ext x j -- Porting note: made types explicit convert (update_apply (R := R) (φ := φ) (ι := ι) 0 x i j _).symm rfl #align linear_map.std_basis_eq_pi_diag LinearMap.stdBasis_eq_pi_diag theorem ker_stdBasis (i : ι) : ker (stdBasis R φ i) = ⊥ := ker_eq_bot_of_injective <| Pi.single_injective _ _ #align linear_map.ker_std_basis LinearMap.ker_stdBasis
Mathlib/LinearAlgebra/StdBasis.lean
84
85
theorem proj_comp_stdBasis (i j : ι) : (proj i).comp (stdBasis R φ j) = diag j i := by
rw [stdBasis_eq_pi_diag, proj_pi]
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Geometry.Euclidean.Angle.Oriented.RightAngle import Mathlib.Geometry.Euclidean.Circumcenter #align_import geometry.euclidean.angle.sphere from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Angles in circles and sphere. This file proves results about angles in circles and spheres. -/ noncomputable section open FiniteDimensional Complex open scoped EuclideanGeometry Real RealInnerProductSpace ComplexConjugate namespace Orientation variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] variable [Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2)) /-- Angle at center of a circle equals twice angle at circumference, oriented vector angle form. -/
Mathlib/Geometry/Euclidean/Angle/Sphere.lean
32
48
theorem oangle_eq_two_zsmul_oangle_sub_of_norm_eq {x y z : V} (hxyne : x ≠ y) (hxzne : x ≠ z) (hxy : ‖x‖ = ‖y‖) (hxz : ‖x‖ = ‖z‖) : o.oangle y z = (2 : ℤ) • o.oangle (y - x) (z - x) := by
have hy : y ≠ 0 := by rintro rfl rw [norm_zero, norm_eq_zero] at hxy exact hxyne hxy have hx : x ≠ 0 := norm_ne_zero_iff.1 (hxy.symm ▸ norm_ne_zero_iff.2 hy) have hz : z ≠ 0 := norm_ne_zero_iff.1 (hxz ▸ norm_ne_zero_iff.2 hx) calc o.oangle y z = o.oangle x z - o.oangle x y := (o.oangle_sub_left hx hy hz).symm _ = π - (2 : ℤ) • o.oangle (x - z) x - (π - (2 : ℤ) • o.oangle (x - y) x) := by rw [o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq hxzne.symm hxz.symm, o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq hxyne.symm hxy.symm] _ = (2 : ℤ) • (o.oangle (x - y) x - o.oangle (x - z) x) := by abel _ = (2 : ℤ) • o.oangle (x - y) (x - z) := by rw [o.oangle_sub_right (sub_ne_zero_of_ne hxyne) (sub_ne_zero_of_ne hxzne) hx] _ = (2 : ℤ) • o.oangle (y - x) (z - x) := by rw [← oangle_neg_neg, neg_sub, neg_sub]
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.RingTheory.WittVector.IsPoly #align_import ring_theory.witt_vector.mul_p from "leanprover-community/mathlib"@"7abfbc92eec87190fba3ed3d5ec58e7c167e7144" /-! ## Multiplication by `n` in the ring of Witt vectors In this file we show that multiplication by `n` in the ring of Witt vectors is a polynomial function. We then use this fact to show that the composition of Frobenius and Verschiebung is equal to multiplication by `p`. ### Main declarations * `mulN_isPoly`: multiplication by `n` is a polynomial function ## References * [Hazewinkel, *Witt Vectors*][Haze09] * [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21] -/ namespace WittVector variable {p : ℕ} {R : Type*} [hp : Fact p.Prime] [CommRing R] local notation "𝕎" => WittVector p -- type as `\bbW` open MvPolynomial noncomputable section variable (p) /-- `wittMulN p n` is the family of polynomials that computes the coefficients of `x * n` in terms of the coefficients of the Witt vector `x`. -/ noncomputable def wittMulN : ℕ → ℕ → MvPolynomial ℕ ℤ | 0 => 0 | n + 1 => fun k => bind₁ (Function.uncurry <| ![wittMulN n, X]) (wittAdd p k) #align witt_vector.witt_mul_n WittVector.wittMulN variable {p}
Mathlib/RingTheory/WittVector/MulP.lean
50
60
theorem mulN_coeff (n : ℕ) (x : 𝕎 R) (k : ℕ) : (x * n).coeff k = aeval x.coeff (wittMulN p n k) := by
induction' n with n ih generalizing k · simp only [Nat.zero_eq, Nat.cast_zero, mul_zero, zero_coeff, wittMulN, AlgHom.map_zero, Pi.zero_apply] · rw [wittMulN, Nat.cast_add, Nat.cast_one, mul_add, mul_one, aeval_bind₁, add_coeff] apply eval₂Hom_congr (RingHom.ext_int _ _) _ rfl ext1 ⟨b, i⟩ fin_cases b · simp [Function.uncurry, Matrix.cons_val_zero, ih] · simp [Function.uncurry, Matrix.cons_val_one, Matrix.head_cons, aeval_X]
/- 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.Fintype.Option import Mathlib.Data.Fintype.Prod import Mathlib.Data.Fintype.Pi import Mathlib.Data.Vector.Basic import Mathlib.Data.PFun import Mathlib.Logic.Function.Iterate import Mathlib.Order.Basic import Mathlib.Tactic.ApplyFun #align_import computability.turing_machine from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" /-! # Turing machines This file defines a sequence of simple machine languages, starting with Turing machines and working up to more complex languages based on Wang B-machines. ## Naming conventions Each model of computation in this file shares a naming convention for the elements of a model of computation. These are the parameters for the language: * `Γ` is the alphabet on the tape. * `Λ` is the set of labels, or internal machine states. * `σ` is the type of internal memory, not on the tape. This does not exist in the TM0 model, and later models achieve this by mixing it into `Λ`. * `K` is used in the TM2 model, which has multiple stacks, and denotes the number of such stacks. All of these variables denote "essentially finite" types, but for technical reasons it is convenient to allow them to be infinite anyway. When using an infinite type, we will be interested to prove that only finitely many values of the type are ever interacted with. Given these parameters, there are a few common structures for the model that arise: * `Stmt` is the set of all actions that can be performed in one step. For the TM0 model this set is finite, and for later models it is an infinite inductive type representing "possible program texts". * `Cfg` is the set of instantaneous configurations, that is, the state of the machine together with its environment. * `Machine` is the set of all machines in the model. Usually this is approximately a function `Λ → Stmt`, although different models have different ways of halting and other actions. * `step : Cfg → Option Cfg` is the function that describes how the state evolves over one step. If `step c = none`, then `c` is a terminal state, and the result of the computation is read off from `c`. Because of the type of `step`, these models are all deterministic by construction. * `init : Input → Cfg` sets up the initial state. The type `Input` depends on the model; in most cases it is `List Γ`. * `eval : Machine → Input → Part Output`, given a machine `M` and input `i`, starts from `init i`, runs `step` until it reaches an output, and then applies a function `Cfg → Output` to the final state to obtain the result. The type `Output` depends on the model. * `Supports : Machine → Finset Λ → Prop` asserts that a machine `M` starts in `S : Finset Λ`, and can only ever jump to other states inside `S`. This implies that the behavior of `M` on any input cannot depend on its values outside `S`. We use this to allow `Λ` to be an infinite set when convenient, and prove that only finitely many of these states are actually accessible. This formalizes "essentially finite" mentioned above. -/ assert_not_exists MonoidWithZero open Relation open Nat (iterate) open Function (update iterate_succ iterate_succ_apply iterate_succ' iterate_succ_apply' iterate_zero_apply) namespace Turing /-- The `BlankExtends` partial order holds of `l₁` and `l₂` if `l₂` is obtained by adding blanks (`default : Γ`) to the end of `l₁`. -/ def BlankExtends {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : Prop := ∃ n, l₂ = l₁ ++ List.replicate n default #align turing.blank_extends Turing.BlankExtends @[refl] theorem BlankExtends.refl {Γ} [Inhabited Γ] (l : List Γ) : BlankExtends l l := ⟨0, by simp⟩ #align turing.blank_extends.refl Turing.BlankExtends.refl @[trans] theorem BlankExtends.trans {Γ} [Inhabited Γ] {l₁ l₂ l₃ : List Γ} : BlankExtends l₁ l₂ → BlankExtends l₂ l₃ → BlankExtends l₁ l₃ := by rintro ⟨i, rfl⟩ ⟨j, rfl⟩ exact ⟨i + j, by simp [List.replicate_add]⟩ #align turing.blank_extends.trans Turing.BlankExtends.trans
Mathlib/Computability/TuringMachine.lean
91
95
theorem BlankExtends.below_of_le {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} : BlankExtends l l₁ → BlankExtends l l₂ → l₁.length ≤ l₂.length → BlankExtends l₁ l₂ := by
rintro ⟨i, rfl⟩ ⟨j, rfl⟩ h; use j - i simp only [List.length_append, Nat.add_le_add_iff_left, List.length_replicate] at h simp only [← List.replicate_add, Nat.add_sub_cancel' h, List.append_assoc]
/- Copyright (c) 2022 Antoine Labelle. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Labelle -/ import Mathlib.RepresentationTheory.FdRep import Mathlib.LinearAlgebra.Trace import Mathlib.RepresentationTheory.Invariants #align_import representation_theory.character from "leanprover-community/mathlib"@"55b3f8206b8596db8bb1804d8a92814a0b6670c9" /-! # Characters of representations This file introduces characters of representation and proves basic lemmas about how characters behave under various operations on representations. A key result is the orthogonality of characters for irreducible representations of finite group over an algebraically closed field whose characteristic doesn't divide the order of the group. It is the theorem `char_orthonormal` # Implementation notes Irreducible representations are implemented categorically, using the `Simple` class defined in `Mathlib.CategoryTheory.Simple` # TODO * Once we have the monoidal closed structure on `FdRep k G` and a better API for the rigid structure, `char_dual` and `char_linHom` should probably be stated in terms of `Vᘁ` and `ihom V W`. -/ noncomputable section universe u open CategoryTheory LinearMap CategoryTheory.MonoidalCategory Representation FiniteDimensional variable {k : Type u} [Field k] namespace FdRep set_option linter.uppercaseLean3 false -- `FdRep` section Monoid variable {G : Type u} [Monoid G] /-- The character of a representation `V : FdRep k G` is the function associating to `g : G` the trace of the linear map `V.ρ g`. -/ def character (V : FdRep k G) (g : G) := LinearMap.trace k V (V.ρ g) #align fdRep.character FdRep.character theorem char_mul_comm (V : FdRep k G) (g : G) (h : G) : V.character (h * g) = V.character (g * h) := by simp only [trace_mul_comm, character, map_mul] #align fdRep.char_mul_comm FdRep.char_mul_comm @[simp] theorem char_one (V : FdRep k G) : V.character 1 = FiniteDimensional.finrank k V := by simp only [character, map_one, trace_one] #align fdRep.char_one FdRep.char_one /-- The character is multiplicative under the tensor product. -/ theorem char_tensor (V W : FdRep k G) : (V ⊗ W).character = V.character * W.character := by ext g; convert trace_tensorProduct' (V.ρ g) (W.ρ g) #align fdRep.char_tensor FdRep.char_tensor -- Porting note: adding variant of `char_tensor` to make the simp-set confluent @[simp] theorem char_tensor' (V W : FdRep k G) : character (Action.FunctorCategoryEquivalence.inverse.obj (Action.FunctorCategoryEquivalence.functor.obj V ⊗ Action.FunctorCategoryEquivalence.functor.obj W)) = V.character * W.character := by simp [← char_tensor] /-- The character of isomorphic representations is the same. -/ theorem char_iso {V W : FdRep k G} (i : V ≅ W) : V.character = W.character := by ext g; simp only [character, FdRep.Iso.conj_ρ i]; exact (trace_conj' (V.ρ g) _).symm #align fdRep.char_iso FdRep.char_iso end Monoid section Group variable {G : Type u} [Group G] /-- The character of a representation is constant on conjugacy classes. -/ @[simp]
Mathlib/RepresentationTheory/Character.lean
89
90
theorem char_conj (V : FdRep k G) (g : G) (h : G) : V.character (h * g * h⁻¹) = V.character g := by
rw [char_mul_comm, inv_mul_cancel_left]
/- Copyright (c) 2022 Moritz Doll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Doll -/ import Mathlib.Algebra.Polynomial.Module.Basic import Mathlib.Analysis.Calculus.Deriv.Pow import Mathlib.Analysis.Calculus.IteratedDeriv.Defs import Mathlib.Analysis.Calculus.MeanValue #align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14" /-! # Taylor's theorem This file defines the Taylor polynomial of a real function `f : ℝ → E`, where `E` is a normed vector space over `ℝ` and proves Taylor's theorem, which states that if `f` is sufficiently smooth, then `f` can be approximated by the Taylor polynomial up to an explicit error term. ## Main definitions * `taylorCoeffWithin`: the Taylor coefficient using `iteratedDerivWithin` * `taylorWithin`: the Taylor polynomial using `iteratedDerivWithin` ## Main statements * `taylor_mean_remainder`: Taylor's theorem with the general form of the remainder term * `taylor_mean_remainder_lagrange`: Taylor's theorem with the Lagrange remainder * `taylor_mean_remainder_cauchy`: Taylor's theorem with the Cauchy remainder * `exists_taylor_mean_remainder_bound`: Taylor's theorem for vector valued functions with a polynomial bound on the remainder ## TODO * the Peano form of the remainder * the integral form of the remainder * Generalization to higher dimensions ## Tags Taylor polynomial, Taylor's theorem -/ open scoped Interval Topology Nat open Set variable {𝕜 E F : Type*} variable [NormedAddCommGroup E] [NormedSpace ℝ E] /-- The `k`th coefficient of the Taylor polynomial. -/ noncomputable def taylorCoeffWithin (f : ℝ → E) (k : ℕ) (s : Set ℝ) (x₀ : ℝ) : E := (k ! : ℝ)⁻¹ • iteratedDerivWithin k f s x₀ #align taylor_coeff_within taylorCoeffWithin /-- The Taylor polynomial with derivatives inside of a set `s`. The Taylor polynomial is given by $$∑_{k=0}^n \frac{(x - x₀)^k}{k!} f^{(k)}(x₀),$$ where $f^{(k)}(x₀)$ denotes the iterated derivative in the set `s`. -/ noncomputable def taylorWithin (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : PolynomialModule ℝ E := (Finset.range (n + 1)).sum fun k => PolynomialModule.comp (Polynomial.X - Polynomial.C x₀) (PolynomialModule.single ℝ k (taylorCoeffWithin f k s x₀)) #align taylor_within taylorWithin /-- The Taylor polynomial with derivatives inside of a set `s` considered as a function `ℝ → E`-/ noncomputable def taylorWithinEval (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : E := PolynomialModule.eval x (taylorWithin f n s x₀) #align taylor_within_eval taylorWithinEval theorem taylorWithin_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : taylorWithin f (n + 1) s x₀ = taylorWithin f n s x₀ + PolynomialModule.comp (Polynomial.X - Polynomial.C x₀) (PolynomialModule.single ℝ (n + 1) (taylorCoeffWithin f (n + 1) s x₀)) := by dsimp only [taylorWithin] rw [Finset.sum_range_succ] #align taylor_within_succ taylorWithin_succ @[simp] theorem taylorWithinEval_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : taylorWithinEval f (n + 1) s x₀ x = taylorWithinEval f n s x₀ x + (((n + 1 : ℝ) * n !)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀ := by simp_rw [taylorWithinEval, taylorWithin_succ, LinearMap.map_add, PolynomialModule.comp_eval] congr simp only [Polynomial.eval_sub, Polynomial.eval_X, Polynomial.eval_C, PolynomialModule.eval_single, mul_inv_rev] dsimp only [taylorCoeffWithin] rw [← mul_smul, mul_comm, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, mul_inv_rev] #align taylor_within_eval_succ taylorWithinEval_succ /-- The Taylor polynomial of order zero evaluates to `f x`. -/ @[simp] theorem taylor_within_zero_eval (f : ℝ → E) (s : Set ℝ) (x₀ x : ℝ) : taylorWithinEval f 0 s x₀ x = f x₀ := by dsimp only [taylorWithinEval] dsimp only [taylorWithin] dsimp only [taylorCoeffWithin] simp #align taylor_within_zero_eval taylor_within_zero_eval /-- Evaluating the Taylor polynomial at `x = x₀` yields `f x`. -/ @[simp] theorem taylorWithinEval_self (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : taylorWithinEval f n s x₀ x₀ = f x₀ := by induction' n with k hk · exact taylor_within_zero_eval _ _ _ _ simp [hk] #align taylor_within_eval_self taylorWithinEval_self
Mathlib/Analysis/Calculus/Taylor.lean
114
120
theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : taylorWithinEval f n s x₀ x = ∑ k ∈ Finset.range (n + 1), ((k ! : ℝ)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀ := by
induction' n with k hk · simp rw [taylorWithinEval_succ, Finset.sum_range_succ, hk] simp [Nat.factorial]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Algebra.Group.Prod import Mathlib.Order.Cover #align_import algebra.support from "leanprover-community/mathlib"@"29cb56a7b35f72758b05a30490e1f10bd62c35c1" /-! # Support of a function In this file we define `Function.support f = {x | f x ≠ 0}` and prove its basic properties. We also define `Function.mulSupport f = {x | f x ≠ 1}`. -/ assert_not_exists MonoidWithZero open Set namespace Function variable {α β A B M N P G : Type*} section One variable [One M] [One N] [One P] /-- `mulSupport` of a function is the set of points `x` such that `f x ≠ 1`. -/ @[to_additive "`support` of a function is the set of points `x` such that `f x ≠ 0`."] def mulSupport (f : α → M) : Set α := {x | f x ≠ 1} #align function.mul_support Function.mulSupport #align function.support Function.support @[to_additive] theorem mulSupport_eq_preimage (f : α → M) : mulSupport f = f ⁻¹' {1}ᶜ := rfl #align function.mul_support_eq_preimage Function.mulSupport_eq_preimage #align function.support_eq_preimage Function.support_eq_preimage @[to_additive] theorem nmem_mulSupport {f : α → M} {x : α} : x ∉ mulSupport f ↔ f x = 1 := not_not #align function.nmem_mul_support Function.nmem_mulSupport #align function.nmem_support Function.nmem_support @[to_additive] theorem compl_mulSupport {f : α → M} : (mulSupport f)ᶜ = { x | f x = 1 } := ext fun _ => nmem_mulSupport #align function.compl_mul_support Function.compl_mulSupport #align function.compl_support Function.compl_support @[to_additive (attr := simp)] theorem mem_mulSupport {f : α → M} {x : α} : x ∈ mulSupport f ↔ f x ≠ 1 := Iff.rfl #align function.mem_mul_support Function.mem_mulSupport #align function.mem_support Function.mem_support @[to_additive (attr := simp)] theorem mulSupport_subset_iff {f : α → M} {s : Set α} : mulSupport f ⊆ s ↔ ∀ x, f x ≠ 1 → x ∈ s := Iff.rfl #align function.mul_support_subset_iff Function.mulSupport_subset_iff #align function.support_subset_iff Function.support_subset_iff @[to_additive] theorem mulSupport_subset_iff' {f : α → M} {s : Set α} : mulSupport f ⊆ s ↔ ∀ x ∉ s, f x = 1 := forall_congr' fun _ => not_imp_comm #align function.mul_support_subset_iff' Function.mulSupport_subset_iff' #align function.support_subset_iff' Function.support_subset_iff' @[to_additive]
Mathlib/Algebra/Group/Support.lean
73
76
theorem mulSupport_eq_iff {f : α → M} {s : Set α} : mulSupport f = s ↔ (∀ x, x ∈ s → f x ≠ 1) ∧ ∀ x, x ∉ s → f x = 1 := by
simp (config := { contextual := true }) only [ext_iff, mem_mulSupport, ne_eq, iff_def, not_imp_comm, and_comm, forall_and]
/- 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.Measure.Trim import Mathlib.MeasureTheory.MeasurableSpace.CountablyGenerated #align_import measure_theory.measure.ae_measurable from "leanprover-community/mathlib"@"3310acfa9787aa171db6d4cba3945f6f275fe9f2" /-! # Almost everywhere measurable functions A function is almost everywhere measurable if it coincides almost everywhere with a measurable function. This property, called `AEMeasurable f μ`, is defined in the file `MeasureSpaceDef`. We discuss several of its properties that are analogous to properties of measurable functions. -/ open scoped Classical open MeasureTheory MeasureTheory.Measure Filter Set Function ENNReal variable {ι α β γ δ R : Type*} {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ] [MeasurableSpace δ] {f g : α → β} {μ ν : Measure α} section @[nontriviality, measurability] theorem Subsingleton.aemeasurable [Subsingleton α] : AEMeasurable f μ := Subsingleton.measurable.aemeasurable #align subsingleton.ae_measurable Subsingleton.aemeasurable @[nontriviality, measurability] theorem aemeasurable_of_subsingleton_codomain [Subsingleton β] : AEMeasurable f μ := (measurable_of_subsingleton_codomain f).aemeasurable #align ae_measurable_of_subsingleton_codomain aemeasurable_of_subsingleton_codomain @[simp, measurability]
Mathlib/MeasureTheory/Measure/AEMeasurable.lean
38
40
theorem aemeasurable_zero_measure : AEMeasurable f (0 : Measure α) := by
nontriviality α; inhabit α exact ⟨fun _ => f default, measurable_const, rfl⟩
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Order.GaloisConnection #align_import order.heyting.regular from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f" /-! # Heyting regular elements This file defines Heyting regular elements, elements of a Heyting algebra that are their own double complement, and proves that they form a boolean algebra. From a logic standpoint, this means that we can perform classical logic within intuitionistic logic by simply double-negating all propositions. This is practical for synthetic computability theory. ## Main declarations * `IsRegular`: `a` is Heyting-regular if `aᶜᶜ = a`. * `Regular`: The subtype of Heyting-regular elements. * `Regular.BooleanAlgebra`: Heyting-regular elements form a boolean algebra. ## References * [Francis Borceux, *Handbook of Categorical Algebra III*][borceux-vol3] -/ open Function variable {α : Type*} namespace Heyting section HasCompl variable [HasCompl α] {a : α} /-- An element of a Heyting algebra is regular if its double complement is itself. -/ def IsRegular (a : α) : Prop := aᶜᶜ = a #align heyting.is_regular Heyting.IsRegular protected theorem IsRegular.eq : IsRegular a → aᶜᶜ = a := id #align heyting.is_regular.eq Heyting.IsRegular.eq instance IsRegular.decidablePred [DecidableEq α] : @DecidablePred α IsRegular := fun _ => ‹DecidableEq α› _ _ #align heyting.is_regular.decidable_pred Heyting.IsRegular.decidablePred end HasCompl section HeytingAlgebra variable [HeytingAlgebra α] {a b : α} theorem isRegular_bot : IsRegular (⊥ : α) := by rw [IsRegular, compl_bot, compl_top] #align heyting.is_regular_bot Heyting.isRegular_bot theorem isRegular_top : IsRegular (⊤ : α) := by rw [IsRegular, compl_top, compl_bot] #align heyting.is_regular_top Heyting.isRegular_top
Mathlib/Order/Heyting/Regular.lean
66
67
theorem IsRegular.inf (ha : IsRegular a) (hb : IsRegular b) : IsRegular (a ⊓ b) := by
rw [IsRegular, compl_compl_inf_distrib, ha.eq, hb.eq]
/- Copyright (c) 2022 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Heather Macbeth -/ import Mathlib.Topology.Algebra.UniformGroup import Mathlib.Topology.UniformSpace.Pi import Mathlib.Data.Matrix.Basic #align_import topology.uniform_space.matrix from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Uniform space structure on matrices -/ open Uniformity Topology variable (m n 𝕜 : Type*) [UniformSpace 𝕜] namespace Matrix instance instUniformSpace : UniformSpace (Matrix m n 𝕜) := (by infer_instance : UniformSpace (m → n → 𝕜)) instance instUniformAddGroup [AddGroup 𝕜] [UniformAddGroup 𝕜] : UniformAddGroup (Matrix m n 𝕜) := inferInstanceAs <| UniformAddGroup (m → n → 𝕜)
Mathlib/Topology/UniformSpace/Matrix.lean
30
34
theorem uniformity : 𝓤 (Matrix m n 𝕜) = ⨅ (i : m) (j : n), (𝓤 𝕜).comap fun a => (a.1 i j, a.2 i j) := by
erw [Pi.uniformity] simp_rw [Pi.uniformity, Filter.comap_iInf, Filter.comap_comap] rfl
/- 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.Data.ENat.Lattice import Mathlib.Order.OrderIsoNat import Mathlib.Tactic.TFAE #align_import order.height from "leanprover-community/mathlib"@"bf27744463e9620ca4e4ebe951fe83530ae6949b" /-! # Maximal length of chains This file contains lemmas to work with the maximal length of strictly descending finite sequences (chains) in a partial order. ## Main definition - `Set.subchain`: The set of strictly ascending lists of `α` contained in a `Set α`. - `Set.chainHeight`: The maximal length of a strictly ascending sequence in a partial order. This is defined as the maximum of the lengths of `Set.subchain`s, valued in `ℕ∞`. ## Main results - `Set.exists_chain_of_le_chainHeight`: For each `n : ℕ` such that `n ≤ s.chainHeight`, there exists `s.subchain` of length `n`. - `Set.chainHeight_mono`: If `s ⊆ t` then `s.chainHeight ≤ t.chainHeight`. - `Set.chainHeight_image`: If `f` is an order embedding, then `(f '' s).chainHeight = s.chainHeight`. - `Set.chainHeight_insert_of_forall_lt`: If `∀ y ∈ s, y < x`, then `(insert x s).chainHeight = s.chainHeight + 1`. - `Set.chainHeight_insert_of_forall_gt`: If `∀ y ∈ s, x < y`, then `(insert x s).chainHeight = s.chainHeight + 1`. - `Set.chainHeight_union_eq`: If `∀ x ∈ s, ∀ y ∈ t, s ≤ t`, then `(s ∪ t).chainHeight = s.chainHeight + t.chainHeight`. - `Set.wellFoundedGT_of_chainHeight_ne_top`: If `s` has finite height, then `>` is well-founded on `s`. - `Set.wellFoundedLT_of_chainHeight_ne_top`: If `s` has finite height, then `<` is well-founded on `s`. -/ open List hiding le_antisymm open OrderDual universe u v variable {α β : Type*} namespace Set section LT variable [LT α] [LT β] (s t : Set α) /-- The set of strictly ascending lists of `α` contained in a `Set α`. -/ def subchain : Set (List α) := { l | l.Chain' (· < ·) ∧ ∀ i ∈ l, i ∈ s } #align set.subchain Set.subchain @[simp] -- porting note: new `simp` theorem nil_mem_subchain : [] ∈ s.subchain := ⟨trivial, fun _ ↦ nofun⟩ #align set.nil_mem_subchain Set.nil_mem_subchain variable {s} {l : List α} {a : α}
Mathlib/Order/Height.lean
70
73
theorem cons_mem_subchain_iff : (a::l) ∈ s.subchain ↔ a ∈ s ∧ l ∈ s.subchain ∧ ∀ b ∈ l.head?, a < b := by
simp only [subchain, mem_setOf_eq, forall_mem_cons, chain'_cons', and_left_comm, and_comm, and_assoc]
/- 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.Eval #align_import data.polynomial.degree.lemmas from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f" /-! # Theory of degrees of polynomials Some of the main results include - `natDegree_comp_le` : The degree of the composition is at most the product of degrees -/ noncomputable section open Polynomial open Finsupp Finset namespace Polynomial universe u v w variable {R : Type u} {S : Type v} {ι : Type w} {a b : R} {m n : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} section Degree
Mathlib/Algebra/Polynomial/Degree/Lemmas.lean
37
61
theorem natDegree_comp_le : natDegree (p.comp q) ≤ natDegree p * natDegree q := letI := Classical.decEq R if h0 : p.comp q = 0 then by rw [h0, natDegree_zero]; exact Nat.zero_le _ else WithBot.coe_le_coe.1 <| calc ↑(natDegree (p.comp q)) = degree (p.comp q) := (degree_eq_natDegree h0).symm _ = _ := congr_arg degree comp_eq_sum_left _ ≤ _ := degree_sum_le _ _ _ ≤ _ := Finset.sup_le fun n hn => calc degree (C (coeff p n) * q ^ n) ≤ degree (C (coeff p n)) + degree (q ^ n) := degree_mul_le _ _ _ ≤ natDegree (C (coeff p n)) + n • degree q := (add_le_add degree_le_natDegree (degree_pow_le _ _)) _ ≤ natDegree (C (coeff p n)) + n • ↑(natDegree q) := (add_le_add_left (nsmul_le_nsmul_right (@degree_le_natDegree _ _ q) n) _) _ = (n * natDegree q : ℕ) := by
rw [natDegree_C, Nat.cast_zero, zero_add, nsmul_eq_mul]; simp _ ≤ (natDegree p * natDegree q : ℕ) := WithBot.coe_le_coe.2 <| mul_le_mul_of_nonneg_right (le_natDegree_of_ne_zero (mem_support_iff.1 hn)) (Nat.zero_le _)
/- Copyright (c) 2022 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Tactic.NormNum.Basic import Mathlib.Data.Rat.Cast.CharZero import Mathlib.Algebra.Field.Basic /-! # `norm_num` plugins for `Rat.cast` and `⁻¹`. -/ set_option autoImplicit true namespace Mathlib.Meta.NormNum open Lean.Meta Qq /-- Helper function to synthesize a typed `CharZero α` expression given `Ring α`. -/ def inferCharZeroOfRing {α : Q(Type u)} (_i : Q(Ring $α) := by with_reducible assumption) : MetaM Q(CharZero $α) := return ← synthInstanceQ (q(CharZero $α) : Q(Prop)) <|> throwError "not a characteristic zero ring" /-- Helper function to synthesize a typed `CharZero α` expression given `Ring α`, if it exists. -/ def inferCharZeroOfRing? {α : Q(Type u)} (_i : Q(Ring $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) := return (← trySynthInstanceQ (q(CharZero $α) : Q(Prop))).toOption /-- Helper function to synthesize a typed `CharZero α` expression given `AddMonoidWithOne α`. -/ def inferCharZeroOfAddMonoidWithOne {α : Q(Type u)} (_i : Q(AddMonoidWithOne $α) := by with_reducible assumption) : MetaM Q(CharZero $α) := return ← synthInstanceQ (q(CharZero $α) : Q(Prop)) <|> throwError "not a characteristic zero AddMonoidWithOne" /-- Helper function to synthesize a typed `CharZero α` expression given `AddMonoidWithOne α`, if it exists. -/ def inferCharZeroOfAddMonoidWithOne? {α : Q(Type u)} (_i : Q(AddMonoidWithOne $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) := return (← trySynthInstanceQ (q(CharZero $α) : Q(Prop))).toOption /-- Helper function to synthesize a typed `CharZero α` expression given `DivisionRing α`. -/ def inferCharZeroOfDivisionRing {α : Q(Type u)} (_i : Q(DivisionRing $α) := by with_reducible assumption) : MetaM Q(CharZero $α) := return ← synthInstanceQ (q(CharZero $α) : Q(Prop)) <|> throwError "not a characteristic zero division ring" /-- Helper function to synthesize a typed `CharZero α` expression given `DivisionRing α`, if it exists. -/ def inferCharZeroOfDivisionRing? {α : Q(Type u)} (_i : Q(DivisionRing $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) := return (← trySynthInstanceQ (q(CharZero $α) : Q(Prop))).toOption theorem isRat_mkRat : {a na n : ℤ} → {b nb d : ℕ} → IsInt a na → IsNat b nb → IsRat (na / nb : ℚ) n d → IsRat (mkRat a b) n d | _, _, _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, ⟨_, h⟩ => by rw [Rat.mkRat_eq_div]; exact ⟨_, h⟩ /-- The `norm_num` extension which identifies expressions of the form `mkRat a b`, such that `norm_num` successfully recognises both `a` and `b`, and returns `a / b`. -/ @[norm_num mkRat _ _] def evalMkRat : NormNumExt where eval {u α} (e : Q(ℚ)) : MetaM (Result e) := do let .app (.app (.const ``mkRat _) (a : Q(ℤ))) (b : Q(ℕ)) ← whnfR e | failure haveI' : $e =Q mkRat $a $b := ⟨⟩ let ra ← derive a let some ⟨_, na, pa⟩ := ra.toInt (q(Int.instRing) : Q(Ring Int)) | failure let ⟨nb, pb⟩ ← deriveNat q($b) q(AddCommMonoidWithOne.toAddMonoidWithOne) let rab ← derive q($na / $nb : Rat) let ⟨q, n, d, p⟩ ← rab.toRat' q(Rat.instDivisionRing) return .isRat' _ q n d q(isRat_mkRat $pa $pb $p) theorem isNat_ratCast [DivisionRing R] : {q : ℚ} → {n : ℕ} → IsNat q n → IsNat (q : R) n | _, _, ⟨rfl⟩ => ⟨by simp⟩ theorem isInt_ratCast [DivisionRing R] : {q : ℚ} → {n : ℤ} → IsInt q n → IsInt (q : R) n | _, _, ⟨rfl⟩ => ⟨by simp⟩ theorem isRat_ratCast [DivisionRing R] [CharZero R] : {q : ℚ} → {n : ℤ} → {d : ℕ} → IsRat q n d → IsRat (q : R) n d | _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only []; norm_cast⟩ /-- The `norm_num` extension which identifies an expression `RatCast.ratCast q` where `norm_num` recognizes `q`, returning the cast of `q`. -/ @[norm_num Rat.cast _, RatCast.ratCast _] def evalRatCast : NormNumExt where eval {u α} e := do let dα ← inferDivisionRing α let .app r (a : Q(ℚ)) ← whnfR e | failure guard <|← withNewMCtxDepth <| isDefEq r q(Rat.cast (K := $α)) let r ← derive q($a) haveI' : $e =Q Rat.cast $a := ⟨⟩ match r with | .isNat _ na pa => assumeInstancesCommute return .isNat _ na q(isNat_ratCast $pa) | .isNegNat _ na pa => assumeInstancesCommute return .isNegNat _ na q(isInt_ratCast $pa) | .isRat _ qa na da pa => assumeInstancesCommute let i ← inferCharZeroOfDivisionRing dα return .isRat dα qa na da q(isRat_ratCast $pa) | _ => failure
Mathlib/Tactic/NormNum/Inv.lean
106
110
theorem isRat_inv_pos {α} [DivisionRing α] [CharZero α] {a : α} {n d : ℕ} : IsRat a (.ofNat (Nat.succ n)) d → IsRat a⁻¹ (.ofNat d) (Nat.succ n) := by
rintro ⟨_, rfl⟩ have := invertibleOfNonzero (α := α) (Nat.cast_ne_zero.2 (Nat.succ_ne_zero n)) exact ⟨this, by simp⟩
/- Copyright (c) 2020 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.CategoryTheory.Balanced import Mathlib.CategoryTheory.LiftingProperties.Basic #align_import category_theory.limits.shapes.strong_epi from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514" /-! # Strong epimorphisms In this file, we define strong epimorphisms. A strong epimorphism is an epimorphism `f` which has the (unique) left lifting property with respect to monomorphisms. Similarly, a strong monomorphisms in a monomorphism which has the (unique) right lifting property with respect to epimorphisms. ## Main results Besides the definition, we show that * the composition of two strong epimorphisms is a strong epimorphism, * if `f ≫ g` is a strong epimorphism, then so is `g`, * if `f` is both a strong epimorphism and a monomorphism, then it is an isomorphism We also define classes `StrongMonoCategory` and `StrongEpiCategory` for categories in which every monomorphism or epimorphism is strong, and deduce that these categories are balanced. ## TODO Show that the dual of a strong epimorphism is a strong monomorphism, and vice versa. ## References * [F. Borceux, *Handbook of Categorical Algebra 1*][borceux-vol1] -/ universe v u namespace CategoryTheory variable {C : Type u} [Category.{v} C] variable {P Q : C} /-- A strong epimorphism `f` is an epimorphism which has the left lifting property with respect to monomorphisms. -/ class StrongEpi (f : P ⟶ Q) : Prop where /-- The epimorphism condition on `f` -/ epi : Epi f /-- The left lifting property with respect to all monomorphism -/ llp : ∀ ⦃X Y : C⦄ (z : X ⟶ Y) [Mono z], HasLiftingProperty f z #align category_theory.strong_epi CategoryTheory.StrongEpi #align category_theory.strong_epi.epi CategoryTheory.StrongEpi.epi theorem StrongEpi.mk' {f : P ⟶ Q} [Epi f] (hf : ∀ (X Y : C) (z : X ⟶ Y) (_ : Mono z) (u : P ⟶ X) (v : Q ⟶ Y) (sq : CommSq u f z v), sq.HasLift) : StrongEpi f := { epi := inferInstance llp := fun {X Y} z hz => ⟨fun {u v} sq => hf X Y z hz u v sq⟩ } #align category_theory.strong_epi.mk' CategoryTheory.StrongEpi.mk' /-- A strong monomorphism `f` is a monomorphism which has the right lifting property with respect to epimorphisms. -/ class StrongMono (f : P ⟶ Q) : Prop where /-- The monomorphism condition on `f` -/ mono : Mono f /-- The right lifting property with respect to all epimorphisms -/ rlp : ∀ ⦃X Y : C⦄ (z : X ⟶ Y) [Epi z], HasLiftingProperty z f #align category_theory.strong_mono CategoryTheory.StrongMono theorem StrongMono.mk' {f : P ⟶ Q} [Mono f] (hf : ∀ (X Y : C) (z : X ⟶ Y) (_ : Epi z) (u : X ⟶ P) (v : Y ⟶ Q) (sq : CommSq u z f v), sq.HasLift) : StrongMono f where mono := inferInstance rlp := fun {X Y} z hz => ⟨fun {u v} sq => hf X Y z hz u v sq⟩ #align category_theory.strong_mono.mk' CategoryTheory.StrongMono.mk' attribute [instance 100] StrongEpi.llp attribute [instance 100] StrongMono.rlp instance (priority := 100) epi_of_strongEpi (f : P ⟶ Q) [StrongEpi f] : Epi f := StrongEpi.epi #align category_theory.epi_of_strong_epi CategoryTheory.epi_of_strongEpi instance (priority := 100) mono_of_strongMono (f : P ⟶ Q) [StrongMono f] : Mono f := StrongMono.mono #align category_theory.mono_of_strong_mono CategoryTheory.mono_of_strongMono section variable {R : C} (f : P ⟶ Q) (g : Q ⟶ R) /-- The composition of two strong epimorphisms is a strong epimorphism. -/ theorem strongEpi_comp [StrongEpi f] [StrongEpi g] : StrongEpi (f ≫ g) := { epi := epi_comp _ _ llp := by intros infer_instance } #align category_theory.strong_epi_comp CategoryTheory.strongEpi_comp /-- The composition of two strong monomorphisms is a strong monomorphism. -/ theorem strongMono_comp [StrongMono f] [StrongMono g] : StrongMono (f ≫ g) := { mono := mono_comp _ _ rlp := by intros infer_instance } #align category_theory.strong_mono_comp CategoryTheory.strongMono_comp /-- If `f ≫ g` is a strong epimorphism, then so is `g`. -/ theorem strongEpi_of_strongEpi [StrongEpi (f ≫ g)] : StrongEpi g := { epi := epi_of_epi f g llp := fun {X Y} z _ => by constructor intro u v sq have h₀ : (f ≫ u) ≫ z = (f ≫ g) ≫ v := by simp only [Category.assoc, sq.w] exact CommSq.HasLift.mk' ⟨(CommSq.mk h₀).lift, by simp only [← cancel_mono z, Category.assoc, CommSq.fac_right, sq.w], by simp⟩ } #align category_theory.strong_epi_of_strong_epi CategoryTheory.strongEpi_of_strongEpi /-- If `f ≫ g` is a strong monomorphism, then so is `f`. -/
Mathlib/CategoryTheory/Limits/Shapes/StrongEpi.lean
127
135
theorem strongMono_of_strongMono [StrongMono (f ≫ g)] : StrongMono f := { mono := mono_of_mono f g rlp := fun {X Y} z => by intros constructor intro u v sq have h₀ : u ≫ f ≫ g = z ≫ v ≫ g := by
rw [← Category.assoc, eq_whisker sq.w, Category.assoc] exact CommSq.HasLift.mk' ⟨(CommSq.mk h₀).lift, by simp, by simp [← cancel_epi z, sq.w]⟩ }
/- Copyright (c) 2020 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Data.Stream.Init import Mathlib.Tactic.ApplyFun import Mathlib.Control.Fix import Mathlib.Order.OmegaCompletePartialOrder #align_import control.lawful_fix from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" /-! # Lawful fixed point operators This module defines the laws required of a `Fix` instance, using the theory of omega complete partial orders (ωCPO). Proofs of the lawfulness of all `Fix` instances in `Control.Fix` are provided. ## Main definition * class `LawfulFix` -/ universe u v open scoped Classical variable {α : Type*} {β : α → Type*} open OmegaCompletePartialOrder /- Porting note: in `#align`s, mathport is putting some `fix`es where `Fix`es should be. -/ /-- Intuitively, a fixed point operator `fix` is lawful if it satisfies `fix f = f (fix f)` for all `f`, but this is inconsistent / uninteresting in most cases due to the existence of "exotic" functions `f`, such as the function that is defined iff its argument is not, familiar from the halting problem. Instead, this requirement is limited to only functions that are `Continuous` in the sense of `ω`-complete partial orders, which excludes the example because it is not monotone (making the input argument less defined can make `f` more defined). -/ class LawfulFix (α : Type*) [OmegaCompletePartialOrder α] extends Fix α where fix_eq : ∀ {f : α →o α}, Continuous f → Fix.fix f = f (Fix.fix f) #align lawful_fix LawfulFix theorem LawfulFix.fix_eq' {α} [OmegaCompletePartialOrder α] [LawfulFix α] {f : α → α} (hf : Continuous' f) : Fix.fix f = f (Fix.fix f) := LawfulFix.fix_eq (hf.to_bundled _) #align lawful_fix.fix_eq' LawfulFix.fix_eq' namespace Part open Part Nat Nat.Upto namespace Fix variable (f : ((a : _) → Part <| β a) →o (a : _) → Part <| β a) theorem approx_mono' {i : ℕ} : Fix.approx f i ≤ Fix.approx f (succ i) := by induction i with | zero => dsimp [approx]; apply @bot_le _ _ _ (f ⊥) | succ _ i_ih => intro; apply f.monotone; apply i_ih #align part.fix.approx_mono' Part.Fix.approx_mono' theorem approx_mono ⦃i j : ℕ⦄ (hij : i ≤ j) : approx f i ≤ approx f j := by induction' j with j ih · cases hij exact le_rfl cases hij; · exact le_rfl exact le_trans (ih ‹_›) (approx_mono' f) #align part.fix.approx_mono Part.Fix.approx_mono theorem mem_iff (a : α) (b : β a) : b ∈ Part.fix f a ↔ ∃ i, b ∈ approx f i a := by by_cases h₀ : ∃ i : ℕ, (approx f i a).Dom · simp only [Part.fix_def f h₀] constructor <;> intro hh · exact ⟨_, hh⟩ have h₁ := Nat.find_spec h₀ rw [dom_iff_mem] at h₁ cases' h₁ with y h₁ replace h₁ := approx_mono' f _ _ h₁ suffices y = b by subst this exact h₁ cases' hh with i hh revert h₁; generalize succ (Nat.find h₀) = j; intro h₁ wlog case : i ≤ j · rcases le_total i j with H | H <;> [skip; symm] <;> apply_assumption <;> assumption replace hh := approx_mono f case _ _ hh apply Part.mem_unique h₁ hh · simp only [fix_def' (⇑f) h₀, not_exists, false_iff_iff, not_mem_none] simp only [dom_iff_mem, not_exists] at h₀ intro; apply h₀ #align part.fix.mem_iff Part.Fix.mem_iff theorem approx_le_fix (i : ℕ) : approx f i ≤ Part.fix f := fun a b hh ↦ by rw [mem_iff f] exact ⟨_, hh⟩ #align part.fix.approx_le_fix Part.Fix.approx_le_fix
Mathlib/Control/LawfulFix.lean
99
112
theorem exists_fix_le_approx (x : α) : ∃ i, Part.fix f x ≤ approx f i x := by
by_cases hh : ∃ i b, b ∈ approx f i x · rcases hh with ⟨i, b, hb⟩ exists i intro b' h' have hb' := approx_le_fix f i _ _ hb obtain rfl := Part.mem_unique h' hb' exact hb · simp only [not_exists] at hh exists 0 intro b' h' simp only [mem_iff f] at h' cases' h' with i h' cases hh _ _ h'
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen -/ import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Localization.Ideal import Mathlib.RingTheory.Noetherian #align_import ring_theory.localization.submodule from "leanprover-community/mathlib"@"1ebb20602a8caef435ce47f6373e1aa40851a177" /-! # Submodules in localizations of commutative rings ## Implementation notes See `RingTheory/Localization/Basic.lean` for a design overview. ## Tags localization, ring localization, commutative ring localization, characteristic predicate, commutative ring, field of fractions -/ variable {R : Type*} [CommRing R] (M : Submonoid R) (S : Type*) [CommRing S] variable [Algebra R S] {P : Type*} [CommRing P] namespace IsLocalization -- This was previously a `hasCoe` instance, but if `S = R` then this will loop. -- It could be a `hasCoeT` instance, but we keep it explicit here to avoid slowing down -- the rest of the library. /-- Map from ideals of `R` to submodules of `S` induced by `f`. -/ def coeSubmodule (I : Ideal R) : Submodule R S := Submodule.map (Algebra.linearMap R S) I #align is_localization.coe_submodule IsLocalization.coeSubmodule theorem mem_coeSubmodule (I : Ideal R) {x : S} : x ∈ coeSubmodule S I ↔ ∃ y : R, y ∈ I ∧ algebraMap R S y = x := Iff.rfl #align is_localization.mem_coe_submodule IsLocalization.mem_coeSubmodule theorem coeSubmodule_mono {I J : Ideal R} (h : I ≤ J) : coeSubmodule S I ≤ coeSubmodule S J := Submodule.map_mono h #align is_localization.coe_submodule_mono IsLocalization.coeSubmodule_mono @[simp] theorem coeSubmodule_bot : coeSubmodule S (⊥ : Ideal R) = ⊥ := by rw [coeSubmodule, Submodule.map_bot] #align is_localization.coe_submodule_bot IsLocalization.coeSubmodule_bot @[simp]
Mathlib/RingTheory/Localization/Submodule.lean
53
54
theorem coeSubmodule_top : coeSubmodule S (⊤ : Ideal R) = 1 := by
rw [coeSubmodule, Submodule.map_top, Submodule.one_eq_range]
/- Copyright (c) 2023 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Calculus.LineDeriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Measurable /-! # Measurability of the line derivative We prove in `measurable_lineDeriv` that the line derivative of a function (with respect to a locally compact scalar field) is measurable, provided the function is continuous. In `measurable_lineDeriv_uncurry`, assuming additionally that the source space is second countable, we show that `(x, v) ↦ lineDeriv 𝕜 f x v` is also measurable. An assumption such as continuity is necessary, as otherwise one could alternate in a non-measurable way between differentiable and non-differentiable functions along the various lines directed by `v`. -/ open MeasureTheory variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [LocallyCompactSpace 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [MeasurableSpace E] [OpensMeasurableSpace E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] [CompleteSpace F] {f : E → F} {v : E} /-! Measurability of the line derivative `lineDeriv 𝕜 f x v` with respect to a fixed direction `v`. -/
Mathlib/Analysis/Calculus/LineDeriv/Measurable.lean
33
38
theorem measurableSet_lineDifferentiableAt (hf : Continuous f) : MeasurableSet {x : E | LineDifferentiableAt 𝕜 f x v} := by
borelize 𝕜 let g : E → 𝕜 → F := fun x t ↦ f (x + t • v) have hg : Continuous g.uncurry := by apply hf.comp; continuity exact measurable_prod_mk_right (measurableSet_of_differentiableAt_with_param 𝕜 hg)
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Topology.Instances.RealVectorSpace import Mathlib.Analysis.NormedSpace.AffineIsometry #align_import analysis.normed_space.mazur_ulam from "leanprover-community/mathlib"@"78261225eb5cedc61c5c74ecb44e5b385d13b733" /-! # Mazur-Ulam Theorem Mazur-Ulam theorem states that an isometric bijection between two normed affine spaces over `ℝ` is affine. We formalize it in three definitions: * `IsometryEquiv.toRealLinearIsometryEquivOfMapZero` : given `E ≃ᵢ F` sending `0` to `0`, returns `E ≃ₗᵢ[ℝ] F` with the same `toFun` and `invFun`; * `IsometryEquiv.toRealLinearIsometryEquiv` : given `f : E ≃ᵢ F`, returns a linear isometry equivalence `g : E ≃ₗᵢ[ℝ] F` with `g x = f x - f 0`. * `IsometryEquiv.toRealAffineIsometryEquiv` : given `f : PE ≃ᵢ PF`, returns an affine isometry equivalence `g : PE ≃ᵃⁱ[ℝ] PF` whose underlying `IsometryEquiv` is `f` The formalization is based on [Jussi Väisälä, *A Proof of the Mazur-Ulam Theorem*][Vaisala_2003]. ## Tags isometry, affine map, linear map -/ variable {E PE F PF : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MetricSpace PE] [NormedAddTorsor E PE] [NormedAddCommGroup F] [NormedSpace ℝ F] [MetricSpace PF] [NormedAddTorsor F PF] open Set AffineMap AffineIsometryEquiv noncomputable section namespace IsometryEquiv /-- If an isometric self-homeomorphism of a normed vector space over `ℝ` fixes `x` and `y`, then it fixes the midpoint of `[x, y]`. This is a lemma for a more general Mazur-Ulam theorem, see below. -/ theorem midpoint_fixed {x y : PE} : ∀ e : PE ≃ᵢ PE, e x = x → e y = y → e (midpoint ℝ x y) = midpoint ℝ x y := by set z := midpoint ℝ x y -- Consider the set of `e : E ≃ᵢ E` such that `e x = x` and `e y = y` set s := { e : PE ≃ᵢ PE | e x = x ∧ e y = y } haveI : Nonempty s := ⟨⟨IsometryEquiv.refl PE, rfl, rfl⟩⟩ -- On the one hand, `e` cannot send the midpoint `z` of `[x, y]` too far have h_bdd : BddAbove (range fun e : s => dist ((e : PE ≃ᵢ PE) z) z) := by refine ⟨dist x z + dist x z, forall_mem_range.2 <| Subtype.forall.2 ?_⟩ rintro e ⟨hx, _⟩ calc dist (e z) z ≤ dist (e z) x + dist x z := dist_triangle (e z) x z _ = dist (e x) (e z) + dist x z := by rw [hx, dist_comm] _ = dist x z + dist x z := by erw [e.dist_eq x z] -- On the other hand, consider the map `f : (E ≃ᵢ E) → (E ≃ᵢ E)` -- sending each `e` to `R ∘ e⁻¹ ∘ R ∘ e`, where `R` is the point reflection in the -- midpoint `z` of `[x, y]`. set R : PE ≃ᵢ PE := (pointReflection ℝ z).toIsometryEquiv set f : PE ≃ᵢ PE → PE ≃ᵢ PE := fun e => ((e.trans R).trans e.symm).trans R -- Note that `f` doubles the value of `dist (e z) z` have hf_dist : ∀ e, dist (f e z) z = 2 * dist (e z) z := by intro e dsimp [f, R] rw [dist_pointReflection_fixed, ← e.dist_eq, e.apply_symm_apply, dist_pointReflection_self_real, dist_comm] -- Also note that `f` maps `s` to itself have hf_maps_to : MapsTo f s s := by rintro e ⟨hx, hy⟩ constructor <;> simp [f, R, z, hx, hy, e.symm_apply_eq.2 hx.symm, e.symm_apply_eq.2 hy.symm] -- Therefore, `dist (e z) z = 0` for all `e ∈ s`. set c := ⨆ e : s, dist ((e : PE ≃ᵢ PE) z) z have : c ≤ c / 2 := by apply ciSup_le rintro ⟨e, he⟩ simp only [Subtype.coe_mk, le_div_iff' (zero_lt_two' ℝ), ← hf_dist] exact le_ciSup h_bdd ⟨f e, hf_maps_to he⟩ replace : c ≤ 0 := by linarith refine fun e hx hy => dist_le_zero.1 (le_trans ?_ this) exact le_ciSup h_bdd ⟨e, hx, hy⟩ #align isometry_equiv.midpoint_fixed IsometryEquiv.midpoint_fixed /-- A bijective isometry sends midpoints to midpoints. -/
Mathlib/Analysis/NormedSpace/MazurUlam.lean
87
96
theorem map_midpoint (f : PE ≃ᵢ PF) (x y : PE) : f (midpoint ℝ x y) = midpoint ℝ (f x) (f y) := by
set e : PE ≃ᵢ PE := ((f.trans <| (pointReflection ℝ <| midpoint ℝ (f x) (f y)).toIsometryEquiv).trans f.symm).trans (pointReflection ℝ <| midpoint ℝ x y).toIsometryEquiv have hx : e x = x := by simp [e] have hy : e y = y := by simp [e] have hm := e.midpoint_fixed hx hy simp only [e, trans_apply] at hm rwa [← eq_symm_apply, toIsometryEquiv_symm, pointReflection_symm, coe_toIsometryEquiv, coe_toIsometryEquiv, pointReflection_self, symm_apply_eq, @pointReflection_fixed_iff] at hm
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.CategoryTheory.Monoidal.Transport import Mathlib.Algebra.Category.AlgebraCat.Basic import Mathlib.Algebra.Category.ModuleCat.Monoidal.Basic import Mathlib.RingTheory.TensorProduct.Basic /-! # The monoidal category structure on R-algebras -/ open CategoryTheory open scoped MonoidalCategory universe v u variable {R : Type u} [CommRing R] namespace AlgebraCat noncomputable section namespace instMonoidalCategory open scoped TensorProduct /-- Auxiliary definition used to fight a timeout when building `AlgebraCat.instMonoidalCategory`. -/ @[simps!] noncomputable abbrev tensorObj (X Y : AlgebraCat.{u} R) : AlgebraCat.{u} R := of R (X ⊗[R] Y) /-- Auxiliary definition used to fight a timeout when building `AlgebraCat.instMonoidalCategory`. -/ noncomputable abbrev tensorHom {W X Y Z : AlgebraCat.{u} R} (f : W ⟶ X) (g : Y ⟶ Z) : tensorObj W Y ⟶ tensorObj X Z := Algebra.TensorProduct.map f g open MonoidalCategory end instMonoidalCategory open instMonoidalCategory instance : MonoidalCategoryStruct (AlgebraCat.{u} R) where tensorObj := instMonoidalCategory.tensorObj whiskerLeft X _ _ f := tensorHom (𝟙 X) f whiskerRight {X₁ X₂} (f : X₁ ⟶ X₂) Y := tensorHom f (𝟙 Y) tensorHom := tensorHom tensorUnit := of R R associator X Y Z := (Algebra.TensorProduct.assoc R X Y Z).toAlgebraIso leftUnitor X := (Algebra.TensorProduct.lid R X).toAlgebraIso rightUnitor X := (Algebra.TensorProduct.rid R R X).toAlgebraIso theorem forget₂_map_associator_hom (X Y Z : AlgebraCat.{u} R) : (forget₂ (AlgebraCat R) (ModuleCat R)).map (α_ X Y Z).hom = (α_ (forget₂ _ (ModuleCat R) |>.obj X) (forget₂ _ (ModuleCat R) |>.obj Y) (forget₂ _ (ModuleCat R) |>.obj Z)).hom := by rfl
Mathlib/Algebra/Category/AlgebraCat/Monoidal.lean
66
72
theorem forget₂_map_associator_inv (X Y Z : AlgebraCat.{u} R) : (forget₂ (AlgebraCat R) (ModuleCat R)).map (α_ X Y Z).inv = (α_ (forget₂ _ (ModuleCat R) |>.obj X) (forget₂ _ (ModuleCat R) |>.obj Y) (forget₂ _ (ModuleCat R) |>.obj Z)).inv := by
rfl
/- Copyright (c) 2023 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.GroupTheory.Coprod.Basic import Mathlib.GroupTheory.Complement /-! ## HNN Extensions of Groups This file defines the HNN extension of a group `G`, `HNNExtension G A B φ`. Given a group `G`, subgroups `A` and `B` and an isomorphism `φ` of `A` and `B`, we adjoin a letter `t` to `G`, such that for any `a ∈ A`, the conjugate of `of a` by `t` is `of (φ a)`, where `of` is the canonical map from `G` into the `HNNExtension`. This construction is named after Graham Higman, Bernhard Neumann and Hanna Neumann. ## Main definitions - `HNNExtension G A B φ` : The HNN Extension of a group `G`, where `A` and `B` are subgroups and `φ` is an isomorphism between `A` and `B`. - `HNNExtension.of` : The canonical embedding of `G` into `HNNExtension G A B φ`. - `HNNExtension.t` : The stable letter of the HNN extension. - `HNNExtension.lift` : Define a function `HNNExtension G A B φ →* H`, by defining it on `G` and `t` - `HNNExtension.of_injective` : The canonical embedding `G →* HNNExtension G A B φ` is injective. - `HNNExtension.ReducedWord.toList_eq_nil_of_mem_of_range` : Britton's Lemma. If an element of `G` is represented by a reduced word, then this reduced word does not contain `t`. -/ open Monoid Coprod Multiplicative Subgroup Function /-- The relation we quotient the coproduct by to form an `HNNExtension`. -/ def HNNExtension.con (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Con (G ∗ Multiplicative ℤ) := conGen (fun x y => ∃ (a : A), x = inr (ofAdd 1) * inl (a : G) ∧ y = inl (φ a : G) * inr (ofAdd 1)) /-- The HNN Extension of a group `G`, `HNNExtension G A B φ`. Given a group `G`, subgroups `A` and `B` and an isomorphism `φ` of `A` and `B`, we adjoin a letter `t` to `G`, such that for any `a ∈ A`, the conjugate of `of a` by `t` is `of (φ a)`, where `of` is the canonical map from `G` into the `HNNExtension`. -/ def HNNExtension (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Type _ := (HNNExtension.con G A B φ).Quotient variable {G : Type*} [Group G] {A B : Subgroup G} {φ : A ≃* B} {H : Type*} [Group H] {M : Type*} [Monoid M] instance : Group (HNNExtension G A B φ) := by delta HNNExtension; infer_instance namespace HNNExtension /-- The canonical embedding `G →* HNNExtension G A B φ` -/ def of : G →* HNNExtension G A B φ := (HNNExtension.con G A B φ).mk'.comp inl /-- The stable letter of the `HNNExtension` -/ def t : HNNExtension G A B φ := (HNNExtension.con G A B φ).mk'.comp inr (ofAdd 1) theorem t_mul_of (a : A) : t * (of (a : G) : HNNExtension G A B φ) = of (φ a : G) * t := (Con.eq _).2 <| ConGen.Rel.of _ _ <| ⟨a, by simp⟩ theorem of_mul_t (b : B) : (of (b : G) : HNNExtension G A B φ) * t = t * of (φ.symm b : G) := by rw [t_mul_of]; simp theorem equiv_eq_conj (a : A) : (of (φ a : G) : HNNExtension G A B φ) = t * of (a : G) * t⁻¹ := by rw [t_mul_of]; simp theorem equiv_symm_eq_conj (b : B) : (of (φ.symm b : G) : HNNExtension G A B φ) = t⁻¹ * of (b : G) * t := by rw [mul_assoc, of_mul_t]; simp theorem inv_t_mul_of (b : B) : t⁻¹ * (of (b : G) : HNNExtension G A B φ) = of (φ.symm b : G) * t⁻¹ := by rw [equiv_symm_eq_conj]; simp theorem of_mul_inv_t (a : A) : (of (a : G) : HNNExtension G A B φ) * t⁻¹ = t⁻¹ * of (φ a : G) := by rw [equiv_eq_conj]; simp [mul_assoc] /-- Define a function `HNNExtension G A B φ →* H`, by defining it on `G` and `t` -/ def lift (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) : HNNExtension G A B φ →* H := Con.lift _ (Coprod.lift f (zpowersHom H x)) (Con.conGen_le <| by rintro _ _ ⟨a, rfl, rfl⟩ simp [hx]) @[simp]
Mathlib/GroupTheory/HNNExtension.lean
97
99
theorem lift_t (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) : lift f x hx t = x := by
delta HNNExtension; simp [lift, t]
/- Copyright (c) 2024 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.CategoryTheory.Sites.Coherent.Comparison import Mathlib.CategoryTheory.Sites.Coherent.ExtensiveSheaves import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPrecoherent import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPreregular import Mathlib.CategoryTheory.Sites.InducedTopology import Mathlib.CategoryTheory.Sites.Whiskering /-! # Categories of coherent sheaves Given a fully faithful functor `F : C ⥤ D` into a precoherent category, which preserves and reflects finite effective epi families, and satisfies the property `F.EffectivelyEnough` (meaning that to every object in `C` there is an effective epi from an object in the image of `F`), the categories of coherent sheaves on `C` and `D` are equivalent (see `CategoryTheory.coherentTopology.equivalence`). The main application of this equivalence is the characterisation of condensed sets as coherent sheaves on either `CompHaus`, `Profinite` or `Stonean`. See the file `Condensed/Equivalence.lean` We give the corresonding result for the regular topology as well (see `CategoryTheory.regularTopology.equivalence`). -/ universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄ namespace CategoryTheory open Limits Functor regularTopology variable {C D : Type*} [Category C] [Category D] (F : C ⥤ D) namespace coherentTopology variable [F.PreservesFiniteEffectiveEpiFamilies] [F.ReflectsFiniteEffectiveEpiFamilies] [F.Full] [F.Faithful] [F.EffectivelyEnough] [Precoherent D] instance : F.IsCoverDense (coherentTopology _) := by refine F.isCoverDense_of_generate_singleton_functor_π_mem _ fun B ↦ ⟨_, F.effectiveEpiOver B, ?_⟩ apply Coverage.saturate.of refine ⟨Unit, inferInstance, fun _ => F.effectiveEpiOverObj B, fun _ => F.effectiveEpiOver B, ?_ , ?_⟩ · funext; ext -- Do we want `Presieve.ext`? refine ⟨fun ⟨⟩ ↦ ⟨()⟩, ?_⟩ rintro ⟨⟩ simp · rw [← effectiveEpi_iff_effectiveEpiFamily] infer_instance
Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean
55
76
theorem exists_effectiveEpiFamily_iff_mem_induced (X : C) (S : Sieve X) : (∃ (α : Type) (_ : Finite α) (Y : α → C) (π : (a : α) → (Y a ⟶ X)), EffectiveEpiFamily Y π ∧ (∀ a : α, (S.arrows) (π a)) ) ↔ (S ∈ F.inducedTopologyOfIsCoverDense (coherentTopology _) X) := by
refine ⟨fun ⟨α, _, Y, π, ⟨H₁, H₂⟩⟩ ↦ ?_, fun hS ↦ ?_⟩ · apply (mem_sieves_iff_hasEffectiveEpiFamily (Sieve.functorPushforward _ S)).mpr refine ⟨α, inferInstance, fun i => F.obj (Y i), fun i => F.map (π i), ⟨?_, fun a => Sieve.image_mem_functorPushforward F S (H₂ a)⟩⟩ exact F.map_finite_effectiveEpiFamily _ _ · obtain ⟨α, _, Y, π, ⟨H₁, H₂⟩⟩ := (mem_sieves_iff_hasEffectiveEpiFamily _).mp hS refine ⟨α, inferInstance, ?_⟩ let Z : α → C := fun a ↦ (Functor.EffectivelyEnough.presentation (F := F) (Y a)).some.p let g₀ : (a : α) → F.obj (Z a) ⟶ Y a := fun a ↦ F.effectiveEpiOver (Y a) have : EffectiveEpiFamily _ (fun a ↦ g₀ a ≫ π a) := inferInstance refine ⟨Z , fun a ↦ F.preimage (g₀ a ≫ π a), ?_, fun a ↦ (?_ : S.arrows (F.preimage _))⟩ · refine F.finite_effectiveEpiFamily_of_map _ _ ?_ simpa using this · obtain ⟨W, g₁, g₂, h₁, h₂⟩ := H₂ a rw [h₂] convert S.downward_closed h₁ (F.preimage (g₀ a ≫ g₂)) exact F.map_injective (by simp)
/- Copyright (c) 2019 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp, Yury Kudryashov, Yaël Dillies -/ import Mathlib.Algebra.Order.Invertible import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.LinearAlgebra.Ray import Mathlib.Tactic.GCongr #align_import analysis.convex.segment from "leanprover-community/mathlib"@"c5773405394e073885e2a144c9ca14637e8eb963" /-! # Segments in vector spaces In a 𝕜-vector space, we define the following objects and properties. * `segment 𝕜 x y`: Closed segment joining `x` and `y`. * `openSegment 𝕜 x y`: Open segment joining `x` and `y`. ## Notations We provide the following notation: * `[x -[𝕜] y] = segment 𝕜 x y` in locale `Convex` ## TODO Generalize all this file to affine spaces. Should we rename `segment` and `openSegment` to `convex.Icc` and `convex.Ioo`? Should we also define `clopenSegment`/`convex.Ico`/`convex.Ioc`? -/ variable {𝕜 E F G ι : Type*} {π : ι → Type*} open Function Set open Pointwise Convex section OrderedSemiring variable [OrderedSemiring 𝕜] [AddCommMonoid E] section SMul variable (𝕜) [SMul 𝕜 E] {s : Set E} {x y : E} /-- Segments in a vector space. -/ def segment (x y : E) : Set E := { z : E | ∃ a b : 𝕜, 0 ≤ a ∧ 0 ≤ b ∧ a + b = 1 ∧ a • x + b • y = z } #align segment segment /-- Open segment in a vector space. Note that `openSegment 𝕜 x x = {x}` instead of being `∅` when the base semiring has some element between `0` and `1`. -/ def openSegment (x y : E) : Set E := { z : E | ∃ a b : 𝕜, 0 < a ∧ 0 < b ∧ a + b = 1 ∧ a • x + b • y = z } #align open_segment openSegment @[inherit_doc] scoped[Convex] notation (priority := high) "[" x "-[" 𝕜 "]" y "]" => segment 𝕜 x y
Mathlib/Analysis/Convex/Segment.lean
62
65
theorem segment_eq_image₂ (x y : E) : [x -[𝕜] y] = (fun p : 𝕜 × 𝕜 => p.1 • x + p.2 • y) '' { p | 0 ≤ p.1 ∧ 0 ≤ p.2 ∧ p.1 + p.2 = 1 } := by
simp only [segment, image, Prod.exists, mem_setOf_eq, exists_prop, and_assoc]
/- Copyright (c) 2022 Frédéric Dupuis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shing Tak Lam, Frédéric Dupuis -/ import Mathlib.Algebra.Group.Submonoid.Operations import Mathlib.Algebra.Star.SelfAdjoint #align_import algebra.star.unitary from "leanprover-community/mathlib"@"247a102b14f3cebfee126293341af5f6bed00237" /-! # Unitary elements of a star monoid This file defines `unitary R`, where `R` is a star monoid, as the submonoid made of the elements that satisfy `star U * U = 1` and `U * star U = 1`, and these form a group. This includes, for instance, unitary operators on Hilbert spaces. See also `Matrix.UnitaryGroup` for specializations to `unitary (Matrix n n R)`. ## Tags unitary -/ /-- In a *-monoid, `unitary R` is the submonoid consisting of all the elements `U` of `R` such that `star U * U = 1` and `U * star U = 1`. -/ def unitary (R : Type*) [Monoid R] [StarMul R] : Submonoid R where carrier := { U | star U * U = 1 ∧ U * star U = 1 } one_mem' := by simp only [mul_one, and_self_iff, Set.mem_setOf_eq, star_one] mul_mem' := @fun U B ⟨hA₁, hA₂⟩ ⟨hB₁, hB₂⟩ => by refine ⟨?_, ?_⟩ · calc star (U * B) * (U * B) = star B * star U * U * B := by simp only [mul_assoc, star_mul] _ = star B * (star U * U) * B := by rw [← mul_assoc] _ = 1 := by rw [hA₁, mul_one, hB₁] · calc U * B * star (U * B) = U * B * (star B * star U) := by rw [star_mul] _ = U * (B * star B) * star U := by simp_rw [← mul_assoc] _ = 1 := by rw [hB₂, mul_one, hA₂] #align unitary unitary variable {R : Type*} namespace unitary section Monoid variable [Monoid R] [StarMul R] theorem mem_iff {U : R} : U ∈ unitary R ↔ star U * U = 1 ∧ U * star U = 1 := Iff.rfl #align unitary.mem_iff unitary.mem_iff @[simp] theorem star_mul_self_of_mem {U : R} (hU : U ∈ unitary R) : star U * U = 1 := hU.1 #align unitary.star_mul_self_of_mem unitary.star_mul_self_of_mem @[simp] theorem mul_star_self_of_mem {U : R} (hU : U ∈ unitary R) : U * star U = 1 := hU.2 #align unitary.mul_star_self_of_mem unitary.mul_star_self_of_mem theorem star_mem {U : R} (hU : U ∈ unitary R) : star U ∈ unitary R := ⟨by rw [star_star, mul_star_self_of_mem hU], by rw [star_star, star_mul_self_of_mem hU]⟩ #align unitary.star_mem unitary.star_mem @[simp] theorem star_mem_iff {U : R} : star U ∈ unitary R ↔ U ∈ unitary R := ⟨fun h => star_star U ▸ star_mem h, star_mem⟩ #align unitary.star_mem_iff unitary.star_mem_iff instance : Star (unitary R) := ⟨fun U => ⟨star U, star_mem U.prop⟩⟩ @[simp, norm_cast] theorem coe_star {U : unitary R} : ↑(star U) = (star U : R) := rfl #align unitary.coe_star unitary.coe_star theorem coe_star_mul_self (U : unitary R) : (star U : R) * U = 1 := star_mul_self_of_mem U.prop #align unitary.coe_star_mul_self unitary.coe_star_mul_self theorem coe_mul_star_self (U : unitary R) : (U : R) * star U = 1 := mul_star_self_of_mem U.prop #align unitary.coe_mul_star_self unitary.coe_mul_star_self @[simp] theorem star_mul_self (U : unitary R) : star U * U = 1 := Subtype.ext <| coe_star_mul_self U #align unitary.star_mul_self unitary.star_mul_self @[simp] theorem mul_star_self (U : unitary R) : U * star U = 1 := Subtype.ext <| coe_mul_star_self U #align unitary.mul_star_self unitary.mul_star_self instance : Group (unitary R) := { Submonoid.toMonoid _ with inv := star mul_left_inv := star_mul_self } instance : InvolutiveStar (unitary R) := ⟨by intro x ext rw [coe_star, coe_star, star_star]⟩ instance : StarMul (unitary R) := ⟨by intro x y ext rw [coe_star, Submonoid.coe_mul, Submonoid.coe_mul, coe_star, coe_star, star_mul]⟩ instance : Inhabited (unitary R) := ⟨1⟩ theorem star_eq_inv (U : unitary R) : star U = U⁻¹ := rfl #align unitary.star_eq_inv unitary.star_eq_inv theorem star_eq_inv' : (star : unitary R → unitary R) = Inv.inv := rfl #align unitary.star_eq_inv' unitary.star_eq_inv' /-- The unitary elements embed into the units. -/ @[simps] def toUnits : unitary R →* Rˣ where toFun x := ⟨x, ↑x⁻¹, coe_mul_star_self x, coe_star_mul_self x⟩ map_one' := Units.ext rfl map_mul' _ _ := Units.ext rfl #align unitary.to_units unitary.toUnits theorem toUnits_injective : Function.Injective (toUnits : unitary R → Rˣ) := fun _ _ h => Subtype.ext <| Units.ext_iff.mp h #align unitary.to_units_injective unitary.toUnits_injective
Mathlib/Algebra/Star/Unitary.lean
141
145
theorem _root_.IsUnit.mem_unitary_of_star_mul_self {u : R} (hu : IsUnit u) (h_mul : star u * u = 1) : u ∈ unitary R := by
refine unitary.mem_iff.mpr ⟨h_mul, ?_⟩ lift u to Rˣ using hu exact left_inv_eq_right_inv h_mul u.mul_inv ▸ u.mul_inv
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Yaël Dillies, Bhavik Mehta -/ import Mathlib.Data.Finset.Lattice import Mathlib.Data.Set.Sigma #align_import data.finset.sigma from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Finite sets in a sigma type This file defines a few `Finset` constructions on `Σ i, α i`. ## Main declarations * `Finset.sigma`: Given a finset `s` in `ι` and finsets `t i` in each `α i`, `s.sigma t` is the finset of the dependent sum `Σ i, α i` * `Finset.sigmaLift`: Lifts maps `α i → β i → Finset (γ i)` to a map `Σ i, α i → Σ i, β i → Finset (Σ i, γ i)`. ## TODO `Finset.sigmaLift` can be generalized to any alternative functor. But to make the generalization worth it, we must first refactor the functor library so that the `alternative` instance for `Finset` is computable and universe-polymorphic. -/ open Function Multiset variable {ι : Type*} namespace Finset section Sigma variable {α : ι → Type*} {β : Type*} (s s₁ s₂ : Finset ι) (t t₁ t₂ : ∀ i, Finset (α i)) /-- `s.sigma t` is the finset of dependent pairs `⟨i, a⟩` such that `i ∈ s` and `a ∈ t i`. -/ protected def sigma : Finset (Σi, α i) := ⟨_, s.nodup.sigma fun i => (t i).nodup⟩ #align finset.sigma Finset.sigma variable {s s₁ s₂ t t₁ t₂} @[simp] theorem mem_sigma {a : Σi, α i} : a ∈ s.sigma t ↔ a.1 ∈ s ∧ a.2 ∈ t a.1 := Multiset.mem_sigma #align finset.mem_sigma Finset.mem_sigma @[simp, norm_cast] theorem coe_sigma (s : Finset ι) (t : ∀ i, Finset (α i)) : (s.sigma t : Set (Σ i, α i)) = (s : Set ι).sigma fun i ↦ (t i : Set (α i)) := Set.ext fun _ => mem_sigma #align finset.coe_sigma Finset.coe_sigma @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem sigma_nonempty : (s.sigma t).Nonempty ↔ ∃ i ∈ s, (t i).Nonempty := by simp [Finset.Nonempty] #align finset.sigma_nonempty Finset.sigma_nonempty @[simp] theorem sigma_eq_empty : s.sigma t = ∅ ↔ ∀ i ∈ s, t i = ∅ := by simp only [← not_nonempty_iff_eq_empty, sigma_nonempty, not_exists, not_and] #align finset.sigma_eq_empty Finset.sigma_eq_empty @[mono] theorem sigma_mono (hs : s₁ ⊆ s₂) (ht : ∀ i, t₁ i ⊆ t₂ i) : s₁.sigma t₁ ⊆ s₂.sigma t₂ := fun ⟨i, _⟩ h => let ⟨hi, ha⟩ := mem_sigma.1 h mem_sigma.2 ⟨hs hi, ht i ha⟩ #align finset.sigma_mono Finset.sigma_mono theorem pairwiseDisjoint_map_sigmaMk : (s : Set ι).PairwiseDisjoint fun i => (t i).map (Embedding.sigmaMk i) := by intro i _ j _ hij rw [Function.onFun, disjoint_left] simp_rw [mem_map, Function.Embedding.sigmaMk_apply] rintro _ ⟨y, _, rfl⟩ ⟨z, _, hz'⟩ exact hij (congr_arg Sigma.fst hz'.symm) #align finset.pairwise_disjoint_map_sigma_mk Finset.pairwiseDisjoint_map_sigmaMk @[simp] theorem disjiUnion_map_sigma_mk : s.disjiUnion (fun i => (t i).map (Embedding.sigmaMk i)) pairwiseDisjoint_map_sigmaMk = s.sigma t := rfl #align finset.disj_Union_map_sigma_mk Finset.disjiUnion_map_sigma_mk theorem sigma_eq_biUnion [DecidableEq (Σi, α i)] (s : Finset ι) (t : ∀ i, Finset (α i)) : s.sigma t = s.biUnion fun i => (t i).map <| Embedding.sigmaMk i := by ext ⟨x, y⟩ simp [and_left_comm] #align finset.sigma_eq_bUnion Finset.sigma_eq_biUnion variable (s t) (f : (Σi, α i) → β) theorem sup_sigma [SemilatticeSup β] [OrderBot β] : (s.sigma t).sup f = s.sup fun i => (t i).sup fun b => f ⟨i, b⟩ := by simp only [le_antisymm_iff, Finset.sup_le_iff, mem_sigma, and_imp, Sigma.forall] exact ⟨fun i a hi ha => (le_sup hi).trans' <| le_sup (f := fun a => f ⟨i, a⟩) ha, fun i hi a ha => le_sup <| mem_sigma.2 ⟨hi, ha⟩⟩ #align finset.sup_sigma Finset.sup_sigma theorem inf_sigma [SemilatticeInf β] [OrderTop β] : (s.sigma t).inf f = s.inf fun i => (t i).inf fun b => f ⟨i, b⟩ := @sup_sigma _ _ βᵒᵈ _ _ _ _ _ #align finset.inf_sigma Finset.inf_sigma
Mathlib/Data/Finset/Sigma.lean
112
114
theorem _root_.biSup_finsetSigma [CompleteLattice β] (s : Finset ι) (t : ∀ i, Finset (α i)) (f : Sigma α → β) : ⨆ ij ∈ s.sigma t, f ij = ⨆ (i ∈ s) (j ∈ t i), f ⟨i, j⟩ := by
simp_rw [← Finset.iSup_coe, Finset.coe_sigma, biSup_sigma]
/- 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.InjSurj import Mathlib.Algebra.Group.Units.Hom import Mathlib.Algebra.Ring.Hom.Defs #align_import algebra.ring.units from "leanprover-community/mathlib"@"2ed7e4aec72395b6a7c3ac4ac7873a7a43ead17c" /-! # Units in semirings and rings -/ universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace Units section HasDistribNeg variable [Monoid α] [HasDistribNeg α] {a b : α} /-- Each element of the group of units of a ring has an additive inverse. -/ instance : Neg αˣ := ⟨fun u => ⟨-↑u, -↑u⁻¹, by simp, by simp⟩⟩ /-- Representing an element of a ring's unit group as an element of the ring commutes with mapping this element to its additive inverse. -/ @[simp, norm_cast] protected theorem val_neg (u : αˣ) : (↑(-u) : α) = -u := rfl #align units.coe_neg Units.val_neg @[simp, norm_cast] protected theorem coe_neg_one : ((-1 : αˣ) : α) = -1 := rfl #align units.coe_neg_one Units.coe_neg_one instance : HasDistribNeg αˣ := Units.ext.hasDistribNeg _ Units.val_neg Units.val_mul @[field_simps] theorem neg_divp (a : α) (u : αˣ) : -(a /ₚ u) = -a /ₚ u := by simp only [divp, neg_mul] #align units.neg_divp Units.neg_divp end HasDistribNeg section Ring variable [Ring α] {a b : α} -- Needs to have higher simp priority than divp_add_divp. 1000 is the default priority. @[field_simps 1010] theorem divp_add_divp_same (a b : α) (u : αˣ) : a /ₚ u + b /ₚ u = (a + b) /ₚ u := by simp only [divp, add_mul] #align units.divp_add_divp_same Units.divp_add_divp_same -- Needs to have higher simp priority than divp_sub_divp. 1000 is the default priority. @[field_simps 1010] theorem divp_sub_divp_same (a b : α) (u : αˣ) : a /ₚ u - b /ₚ u = (a - b) /ₚ u := by rw [sub_eq_add_neg, sub_eq_add_neg, neg_divp, divp_add_divp_same] #align units.divp_sub_divp_same Units.divp_sub_divp_same @[field_simps] theorem add_divp (a b : α) (u : αˣ) : a + b /ₚ u = (a * u + b) /ₚ u := by simp only [divp, add_mul, Units.mul_inv_cancel_right] #align units.add_divp Units.add_divp @[field_simps] theorem sub_divp (a b : α) (u : αˣ) : a - b /ₚ u = (a * u - b) /ₚ u := by simp only [divp, sub_mul, Units.mul_inv_cancel_right] #align units.sub_divp Units.sub_divp @[field_simps] theorem divp_add (a b : α) (u : αˣ) : a /ₚ u + b = (a + b * u) /ₚ u := by simp only [divp, add_mul, Units.mul_inv_cancel_right] #align units.divp_add Units.divp_add @[field_simps]
Mathlib/Algebra/Ring/Units.lean
87
89
theorem divp_sub (a b : α) (u : αˣ) : a /ₚ u - b = (a - b * u) /ₚ u := by
simp only [divp, sub_mul, sub_right_inj] rw [mul_assoc, Units.mul_inv, mul_one]
/- 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.Topology.Algebra.Polynomial import Mathlib.Topology.ContinuousFunction.Algebra import Mathlib.Topology.UnitInterval import Mathlib.Algebra.Star.Subalgebra #align_import topology.continuous_function.polynomial from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64" /-! # Constructions relating polynomial functions and continuous functions. ## Main definitions * `Polynomial.toContinuousMapOn p X`: for `X : Set R`, interprets a polynomial `p` as a bundled continuous function in `C(X, R)`. * `Polynomial.toContinuousMapOnAlgHom`: the same, as an `R`-algebra homomorphism. * `polynomialFunctions (X : Set R) : Subalgebra R C(X, R)`: polynomial functions as a subalgebra. * `polynomialFunctions_separatesPoints (X : Set R) : (polynomialFunctions X).SeparatesPoints`: the polynomial functions separate points. -/ variable {R : Type*} open Polynomial namespace Polynomial section variable [Semiring R] [TopologicalSpace R] [TopologicalSemiring R] /-- Every polynomial with coefficients in a topological semiring gives a (bundled) continuous function. -/ @[simps] def toContinuousMap (p : R[X]) : C(R, R) := ⟨fun x : R => p.eval x, by fun_prop⟩ #align polynomial.to_continuous_map Polynomial.toContinuousMap open ContinuousMap in lemma toContinuousMap_X_eq_id : X.toContinuousMap = .id R := by ext; simp /-- A polynomial as a continuous function, with domain restricted to some subset of the semiring of coefficients. (This is particularly useful when restricting to compact sets, e.g. `[0,1]`.) -/ @[simps] def toContinuousMapOn (p : R[X]) (X : Set R) : C(X, R) := -- Porting note: Old proof was `⟨fun x : X => p.toContinuousMap x, by continuity⟩` ⟨fun x : X => p.toContinuousMap x, Continuous.comp (by continuity) (by continuity)⟩ #align polynomial.to_continuous_map_on Polynomial.toContinuousMapOn open ContinuousMap in lemma toContinuousMapOn_X_eq_restrict_id (s : Set R) : X.toContinuousMapOn s = restrict s (.id R) := by ext; simp -- TODO some lemmas about when `toContinuousMapOn` is injective? end section variable {α : Type*} [TopologicalSpace α] [CommSemiring R] [TopologicalSpace R] [TopologicalSemiring R] @[simp] theorem aeval_continuousMap_apply (g : R[X]) (f : C(α, R)) (x : α) : ((Polynomial.aeval f) g) x = g.eval (f x) := by refine Polynomial.induction_on' g ?_ ?_ · intro p q hp hq simp [hp, hq] · intro n a simp [Pi.pow_apply] #align polynomial.aeval_continuous_map_apply Polynomial.aeval_continuousMap_apply end noncomputable section variable [CommSemiring R] [TopologicalSpace R] [TopologicalSemiring R] /-- The algebra map from `R[X]` to continuous functions `C(R, R)`. -/ @[simps] def toContinuousMapAlgHom : R[X] →ₐ[R] C(R, R) where toFun p := p.toContinuousMap map_zero' := by ext simp map_add' _ _ := by ext simp map_one' := by ext simp map_mul' _ _ := by ext simp commutes' _ := by ext simp [Algebra.algebraMap_eq_smul_one] #align polynomial.to_continuous_map_alg_hom Polynomial.toContinuousMapAlgHom /-- The algebra map from `R[X]` to continuous functions `C(X, R)`, for any subset `X` of `R`. -/ @[simps] def toContinuousMapOnAlgHom (X : Set R) : R[X] →ₐ[R] C(X, R) where toFun p := p.toContinuousMapOn X map_zero' := by ext simp map_add' _ _ := by ext simp map_one' := by ext simp map_mul' _ _ := by ext simp commutes' _ := by ext simp [Algebra.algebraMap_eq_smul_one] #align polynomial.to_continuous_map_on_alg_hom Polynomial.toContinuousMapOnAlgHom end end Polynomial section variable [CommSemiring R] [TopologicalSpace R] [TopologicalSemiring R] /-- The subalgebra of polynomial functions in `C(X, R)`, for `X` a subset of some topological semiring `R`. -/ noncomputable -- Porting note: added noncomputable def polynomialFunctions (X : Set R) : Subalgebra R C(X, R) := (⊤ : Subalgebra R R[X]).map (Polynomial.toContinuousMapOnAlgHom X) #align polynomial_functions polynomialFunctions @[simp]
Mathlib/Topology/ContinuousFunction/Polynomial.lean
153
156
theorem polynomialFunctions_coe (X : Set R) : (polynomialFunctions X : Set C(X, R)) = Set.range (Polynomial.toContinuousMapOnAlgHom X) := by
ext simp [polynomialFunctions]
/- Copyright (c) 2020 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.Integral.Lebesgue import Mathlib.Analysis.MeanInequalities import Mathlib.Analysis.MeanInequalitiesPow import Mathlib.MeasureTheory.Function.SpecialFunctions.Basic #align_import measure_theory.integral.mean_inequalities from "leanprover-community/mathlib"@"13bf7613c96a9fd66a81b9020a82cad9a6ea1fcf" /-! # Mean value inequalities for integrals In this file we prove several inequalities on integrals, notably the Hölder inequality and the Minkowski inequality. The versions for finite sums are in `Analysis.MeanInequalities`. ## Main results Hölder's inequality for the Lebesgue integral of `ℝ≥0∞` and `ℝ≥0` functions: we prove `∫ (f * g) ∂μ ≤ (∫ f^p ∂μ) ^ (1/p) * (∫ g^q ∂μ) ^ (1/q)` for `p`, `q` conjugate real exponents and `α → (E)NNReal` functions in two cases, * `ENNReal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0∞ functions, * `NNReal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0 functions. `ENNReal.lintegral_mul_norm_pow_le` is a variant where the exponents are not reciprocals: `∫ (f ^ p * g ^ q) ∂μ ≤ (∫ f ∂μ) ^ p * (∫ g ∂μ) ^ q` where `p, q ≥ 0` and `p + q = 1`. `ENNReal.lintegral_prod_norm_pow_le` generalizes this to a finite family of functions: `∫ (∏ i, f i ^ p i) ∂μ ≤ ∏ i, (∫ f i ∂μ) ^ p i` when the `p` is a collection of nonnegative weights with sum 1. Minkowski's inequality for the Lebesgue integral of measurable functions with `ℝ≥0∞` values: we prove `(∫ (f + g)^p ∂μ) ^ (1/p) ≤ (∫ f^p ∂μ) ^ (1/p) + (∫ g^p ∂μ) ^ (1/p)` for `1 ≤ p`. -/ section LIntegral /-! ### Hölder's inequality for the Lebesgue integral of ℝ≥0∞ and ℝ≥0 functions We prove `∫ (f * g) ∂μ ≤ (∫ f^p ∂μ) ^ (1/p) * (∫ g^q ∂μ) ^ (1/q)` for `p`, `q` conjugate real exponents and `α → (E)NNReal` functions in several cases, the first two being useful only to prove the more general results: * `ENNReal.lintegral_mul_le_one_of_lintegral_rpow_eq_one` : ℝ≥0∞ functions for which the integrals on the right are equal to 1, * `ENNReal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top` : ℝ≥0∞ functions for which the integrals on the right are neither ⊤ nor 0, * `ENNReal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0∞ functions, * `NNReal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0 functions. -/ noncomputable section open scoped Classical open NNReal ENNReal MeasureTheory Finset set_option linter.uppercaseLean3 false variable {α : Type*} [MeasurableSpace α] {μ : Measure α} namespace ENNReal theorem lintegral_mul_le_one_of_lintegral_rpow_eq_one {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_norm : ∫⁻ a, f a ^ p ∂μ = 1) (hg_norm : ∫⁻ a, g a ^ q ∂μ = 1) : (∫⁻ a, (f * g) a ∂μ) ≤ 1 := by calc (∫⁻ a : α, (f * g) a ∂μ) ≤ ∫⁻ a : α, f a ^ p / ENNReal.ofReal p + g a ^ q / ENNReal.ofReal q ∂μ := lintegral_mono fun a => young_inequality (f a) (g a) hpq _ = 1 := by simp only [div_eq_mul_inv] rw [lintegral_add_left'] · rw [lintegral_mul_const'' _ (hf.pow_const p), lintegral_mul_const', hf_norm, hg_norm, one_mul, one_mul, hpq.inv_add_inv_conj_ennreal] simp [hpq.symm.pos] · exact (hf.pow_const _).mul_const _ #align ennreal.lintegral_mul_le_one_of_lintegral_rpow_eq_one ENNReal.lintegral_mul_le_one_of_lintegral_rpow_eq_one /-- Function multiplied by the inverse of its p-seminorm `(∫⁻ f^p ∂μ) ^ 1/p`-/ def funMulInvSnorm (f : α → ℝ≥0∞) (p : ℝ) (μ : Measure α) : α → ℝ≥0∞ := fun a => f a * ((∫⁻ c, f c ^ p ∂μ) ^ (1 / p))⁻¹ #align ennreal.fun_mul_inv_snorm ENNReal.funMulInvSnorm
Mathlib/MeasureTheory/Integral/MeanInequalities.lean
87
90
theorem fun_eq_funMulInvSnorm_mul_snorm {p : ℝ} (f : α → ℝ≥0∞) (hf_nonzero : (∫⁻ a, f a ^ p ∂μ) ≠ 0) (hf_top : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) {a : α} : f a = funMulInvSnorm f p μ a * (∫⁻ c, f c ^ p ∂μ) ^ (1 / p) := by
simp [funMulInvSnorm, mul_assoc, ENNReal.inv_mul_cancel, hf_nonzero, hf_top]
/- Copyright (c) 2023 Adrian Wüthrich. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adrian Wüthrich -/ import Mathlib.Combinatorics.SimpleGraph.AdjMatrix import Mathlib.LinearAlgebra.Matrix.PosDef /-! # Laplacian Matrix This module defines the Laplacian matrix of a graph, and proves some of its elementary properties. ## Main definitions & Results * `SimpleGraph.degMatrix`: The degree matrix of a simple graph * `SimpleGraph.lapMatrix`: The Laplacian matrix of a simple graph, defined as the difference between the degree matrix and the adjacency matrix. * `isPosSemidef_lapMatrix`: The Laplacian matrix is positive semidefinite. * `rank_ker_lapMatrix_eq_card_ConnectedComponent`: The number of connected components in `G` is the dimension of the nullspace of its Laplacian matrix. -/ open Finset Matrix namespace SimpleGraph variable {V : Type*} (R : Type*) variable [Fintype V] [DecidableEq V] (G : SimpleGraph V) [DecidableRel G.Adj] /-- The diagonal matrix consisting of the degrees of the vertices in the graph. -/ def degMatrix [AddMonoidWithOne R] : Matrix V V R := Matrix.diagonal (G.degree ·) /-- The *Laplacian matrix* `lapMatrix G R` of a graph `G` is the matrix `L = D - A` where `D` is the degree and `A` the adjacency matrix of `G`. -/ def lapMatrix [AddGroupWithOne R] : Matrix V V R := G.degMatrix R - G.adjMatrix R variable {R} theorem isSymm_degMatrix [AddMonoidWithOne R] : (G.degMatrix R).IsSymm := isSymm_diagonal _ theorem isSymm_lapMatrix [AddGroupWithOne R] : (G.lapMatrix R).IsSymm := (isSymm_degMatrix _).sub (isSymm_adjMatrix _) theorem degMatrix_mulVec_apply [NonAssocSemiring R] (v : V) (vec : V → R) : (G.degMatrix R *ᵥ vec) v = G.degree v * vec v := by rw [degMatrix, mulVec_diagonal] theorem lapMatrix_mulVec_apply [NonAssocRing R] (v : V) (vec : V → R) : (G.lapMatrix R *ᵥ vec) v = G.degree v * vec v - ∑ u ∈ G.neighborFinset v, vec u := by simp_rw [lapMatrix, sub_mulVec, Pi.sub_apply, degMatrix_mulVec_apply, adjMatrix_mulVec_apply] theorem lapMatrix_mulVec_const_eq_zero [Ring R] : mulVec (G.lapMatrix R) (fun _ ↦ 1) = 0 := by ext1 i rw [lapMatrix_mulVec_apply] simp theorem dotProduct_mulVec_degMatrix [CommRing R] (x : V → R) : x ⬝ᵥ (G.degMatrix R *ᵥ x) = ∑ i : V, G.degree i * x i * x i := by simp only [dotProduct, degMatrix, mulVec_diagonal, ← mul_assoc, mul_comm] variable (R) theorem degree_eq_sum_if_adj [AddCommMonoidWithOne R] (i : V) : (G.degree i : R) = ∑ j : V, if G.Adj i j then 1 else 0 := by unfold degree neighborFinset neighborSet rw [sum_boole, Set.toFinset_setOf] /-- Let $L$ be the graph Laplacian and let $x \in \mathbb{R}$, then $$x^{\top} L x = \sum_{i \sim j} (x_{i}-x_{j})^{2}$$, where $\sim$ denotes the adjacency relation -/ theorem lapMatrix_toLinearMap₂' [Field R] [CharZero R] (x : V → R) : toLinearMap₂' (G.lapMatrix R) x x = (∑ i : V, ∑ j : V, if G.Adj i j then (x i - x j)^2 else 0) / 2 := by simp_rw [toLinearMap₂'_apply', lapMatrix, sub_mulVec, dotProduct_sub, dotProduct_mulVec_degMatrix, dotProduct_mulVec_adjMatrix, ← sum_sub_distrib, degree_eq_sum_if_adj, sum_mul, ite_mul, one_mul, zero_mul, ← sum_sub_distrib, ite_sub_ite, sub_zero] rw [← half_add_self (∑ x_1 : V, ∑ x_2 : V, _)] conv_lhs => enter [1,2,2,i,2,j]; rw [if_congr (adj_comm G i j) rfl rfl] conv_lhs => enter [1,2]; rw [Finset.sum_comm] simp_rw [← sum_add_distrib, ite_add_ite] congr 2 with i congr 2 with j ring_nf /-- The Laplacian matrix is positive semidefinite -/ theorem posSemidef_lapMatrix [LinearOrderedField R] [StarRing R] [StarOrderedRing R] [TrivialStar R] : PosSemidef (G.lapMatrix R) := by constructor · rw [IsHermitian, conjTranspose_eq_transpose_of_trivial, isSymm_lapMatrix] · intro x rw [star_trivial, ← toLinearMap₂'_apply', lapMatrix_toLinearMap₂'] positivity theorem lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_adj [LinearOrderedField R] (x : V → R) : Matrix.toLinearMap₂' (G.lapMatrix R) x x = 0 ↔ ∀ i j : V, G.Adj i j → x i = x j := by simp (disch := intros; positivity) [lapMatrix_toLinearMap₂', sum_eq_zero_iff_of_nonneg, sub_eq_zero] theorem lapMatrix_toLin'_apply_eq_zero_iff_forall_adj (x : V → ℝ) : Matrix.toLin' (G.lapMatrix ℝ) x = 0 ↔ ∀ i j : V, G.Adj i j → x i = x j := by rw [← (posSemidef_lapMatrix ℝ G).toLinearMap₂'_zero_iff, star_trivial, lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_adj] theorem lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_reachable (x : V → ℝ) : Matrix.toLinearMap₂' (G.lapMatrix ℝ) x x = 0 ↔ ∀ i j : V, G.Reachable i j → x i = x j := by rw [lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_adj] refine ⟨?_, fun h i j hA ↦ h i j hA.reachable⟩ intro h i j ⟨w⟩ induction' w with w i j _ hA _ h' · rfl · exact (h i j hA).trans h'
Mathlib/Combinatorics/SimpleGraph/LapMatrix.lean
117
120
theorem lapMatrix_toLin'_apply_eq_zero_iff_forall_reachable (x : V → ℝ) : Matrix.toLin' (G.lapMatrix ℝ) x = 0 ↔ ∀ i j : V, G.Reachable i j → x i = x j := by
rw [← (posSemidef_lapMatrix ℝ G).toLinearMap₂'_zero_iff, star_trivial, lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_reachable]
/- Copyright (c) 2022 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Calculus.FDeriv.Add import Mathlib.Analysis.Calculus.FDeriv.Equiv import Mathlib.Analysis.Calculus.FDeriv.Prod import Mathlib.Analysis.Calculus.Monotone import Mathlib.Data.Set.Function import Mathlib.Algebra.Group.Basic import Mathlib.Tactic.WLOG #align_import analysis.bounded_variation from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Functions of bounded variation We study functions of bounded variation. In particular, we show that a bounded variation function is a difference of monotone functions, and differentiable almost everywhere. This implies that Lipschitz functions from the real line into finite-dimensional vector space are also differentiable almost everywhere. ## Main definitions and results * `eVariationOn f s` is the total variation of the function `f` on the set `s`, in `ℝ≥0∞`. * `BoundedVariationOn f s` registers that the variation of `f` on `s` is finite. * `LocallyBoundedVariationOn f s` registers that `f` has finite variation on any compact subinterval of `s`. * `variationOnFromTo f s a b` is the signed variation of `f` on `s ∩ Icc a b`, converted to `ℝ`. * `eVariationOn.Icc_add_Icc` states that the variation of `f` on `[a, c]` is the sum of its variations on `[a, b]` and `[b, c]`. * `LocallyBoundedVariationOn.exists_monotoneOn_sub_monotoneOn` proves that a function with locally bounded variation is the difference of two monotone functions. * `LipschitzWith.locallyBoundedVariationOn` shows that a Lipschitz function has locally bounded variation. * `LocallyBoundedVariationOn.ae_differentiableWithinAt` shows that a bounded variation function into a finite dimensional real vector space is differentiable almost everywhere. * `LipschitzOnWith.ae_differentiableWithinAt` is the same result for Lipschitz functions. We also give several variations around these results. ## Implementation We define the variation as an extended nonnegative real, to allow for infinite variation. This makes it possible to use the complete linear order structure of `ℝ≥0∞`. The proofs would be much more tedious with an `ℝ`-valued or `ℝ≥0`-valued variation, since one would always need to check that the sets one uses are nonempty and bounded above as these are only conditionally complete. -/ open scoped NNReal ENNReal Topology UniformConvergence open Set MeasureTheory Filter -- Porting note: sectioned variables because a `wlog` was broken due to extra variables in context variable {α : Type*} [LinearOrder α] {E : Type*} [PseudoEMetricSpace E] /-- The (extended real valued) variation of a function `f` on a set `s` inside a linear order is the supremum of the sum of `edist (f (u (i+1))) (f (u i))` over all finite increasing sequences `u` in `s`. -/ noncomputable def eVariationOn (f : α → E) (s : Set α) : ℝ≥0∞ := ⨆ p : ℕ × { u : ℕ → α // Monotone u ∧ ∀ i, u i ∈ s }, ∑ i ∈ Finset.range p.1, edist (f (p.2.1 (i + 1))) (f (p.2.1 i)) #align evariation_on eVariationOn /-- A function has bounded variation on a set `s` if its total variation there is finite. -/ def BoundedVariationOn (f : α → E) (s : Set α) := eVariationOn f s ≠ ∞ #align has_bounded_variation_on BoundedVariationOn /-- A function has locally bounded variation on a set `s` if, given any interval `[a, b]` with endpoints in `s`, then the function has finite variation on `s ∩ [a, b]`. -/ def LocallyBoundedVariationOn (f : α → E) (s : Set α) := ∀ a b, a ∈ s → b ∈ s → BoundedVariationOn f (s ∩ Icc a b) #align has_locally_bounded_variation_on LocallyBoundedVariationOn /-! ## Basic computations of variation -/ namespace eVariationOn theorem nonempty_monotone_mem {s : Set α} (hs : s.Nonempty) : Nonempty { u // Monotone u ∧ ∀ i : ℕ, u i ∈ s } := by obtain ⟨x, hx⟩ := hs exact ⟨⟨fun _ => x, fun i j _ => le_rfl, fun _ => hx⟩⟩ #align evariation_on.nonempty_monotone_mem eVariationOn.nonempty_monotone_mem
Mathlib/Analysis/BoundedVariation.lean
89
94
theorem eq_of_edist_zero_on {f f' : α → E} {s : Set α} (h : ∀ ⦃x⦄, x ∈ s → edist (f x) (f' x) = 0) : eVariationOn f s = eVariationOn f' s := by
dsimp only [eVariationOn] congr 1 with p : 1 congr 1 with i : 1 rw [edist_congr_right (h <| p.snd.prop.2 (i + 1)), edist_congr_left (h <| p.snd.prop.2 i)]
/- Copyright (c) 2021 Ashwin Iyengar. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard, Johan Commelin, Ashwin Iyengar, Patrick Massot -/ import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Topology.Algebra.OpenSubgroup import Mathlib.Topology.Algebra.Ring.Basic #align_import topology.algebra.nonarchimedean.basic from "leanprover-community/mathlib"@"83f81aea33931a1edb94ce0f32b9a5d484de6978" /-! # Nonarchimedean Topology In this file we set up the theory of nonarchimedean topological groups and rings. A nonarchimedean group is a topological group whose topology admits a basis of open neighborhoods of the identity element in the group consisting of open subgroups. A nonarchimedean ring is a topological ring whose underlying topological (additive) group is nonarchimedean. ## Definitions - `NonarchimedeanAddGroup`: nonarchimedean additive group. - `NonarchimedeanGroup`: nonarchimedean multiplicative group. - `NonarchimedeanRing`: nonarchimedean ring. -/ open scoped Pointwise Topology /-- A topological additive group is nonarchimedean if every neighborhood of 0 contains an open subgroup. -/ class NonarchimedeanAddGroup (G : Type*) [AddGroup G] [TopologicalSpace G] extends TopologicalAddGroup G : Prop where is_nonarchimedean : ∀ U ∈ 𝓝 (0 : G), ∃ V : OpenAddSubgroup G, (V : Set G) ⊆ U #align nonarchimedean_add_group NonarchimedeanAddGroup /-- A topological group is nonarchimedean if every neighborhood of 1 contains an open subgroup. -/ @[to_additive] class NonarchimedeanGroup (G : Type*) [Group G] [TopologicalSpace G] extends TopologicalGroup G : Prop where is_nonarchimedean : ∀ U ∈ 𝓝 (1 : G), ∃ V : OpenSubgroup G, (V : Set G) ⊆ U #align nonarchimedean_group NonarchimedeanGroup /-- A topological ring is nonarchimedean if its underlying topological additive group is nonarchimedean. -/ class NonarchimedeanRing (R : Type*) [Ring R] [TopologicalSpace R] extends TopologicalRing R : Prop where is_nonarchimedean : ∀ U ∈ 𝓝 (0 : R), ∃ V : OpenAddSubgroup R, (V : Set R) ⊆ U #align nonarchimedean_ring NonarchimedeanRing -- see Note [lower instance priority] /-- Every nonarchimedean ring is naturally a nonarchimedean additive group. -/ instance (priority := 100) NonarchimedeanRing.to_nonarchimedeanAddGroup (R : Type*) [Ring R] [TopologicalSpace R] [t : NonarchimedeanRing R] : NonarchimedeanAddGroup R := { t with } #align nonarchimedean_ring.to_nonarchimedean_add_group NonarchimedeanRing.to_nonarchimedeanAddGroup namespace NonarchimedeanGroup variable {G : Type*} [Group G] [TopologicalSpace G] [NonarchimedeanGroup G] variable {H : Type*} [Group H] [TopologicalSpace H] [TopologicalGroup H] variable {K : Type*} [Group K] [TopologicalSpace K] [NonarchimedeanGroup K] /-- If a topological group embeds into a nonarchimedean group, then it is nonarchimedean. -/ @[to_additive]
Mathlib/Topology/Algebra/Nonarchimedean/Basic.lean
69
75
theorem nonarchimedean_of_emb (f : G →* H) (emb : OpenEmbedding f) : NonarchimedeanGroup H := { is_nonarchimedean := fun U hU => have h₁ : f ⁻¹' U ∈ 𝓝 (1 : G) := by
apply emb.continuous.tendsto rwa [f.map_one] let ⟨V, hV⟩ := is_nonarchimedean (f ⁻¹' U) h₁ ⟨{ Subgroup.map f V with isOpen' := emb.isOpenMap _ V.isOpen }, Set.image_subset_iff.2 hV⟩ }
/- Copyright (c) 2021 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Algebra.Order.Ring.Int import Mathlib.Data.Nat.SuccPred #align_import data.int.succ_pred from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Successors and predecessors of integers In this file, we show that `ℤ` is both an archimedean `SuccOrder` and an archimedean `PredOrder`. -/ open Function Order namespace Int -- so that Lean reads `Int.succ` through `SuccOrder.succ` @[instance] abbrev instSuccOrder : SuccOrder ℤ := { SuccOrder.ofSuccLeIff succ fun {_ _} => Iff.rfl with succ := succ } -- so that Lean reads `Int.pred` through `PredOrder.pred` @[instance] abbrev instPredOrder : PredOrder ℤ where pred := pred pred_le _ := (sub_one_lt_of_le le_rfl).le min_of_le_pred ha := ((sub_one_lt_of_le le_rfl).not_le ha).elim le_pred_of_lt {_ _} := le_sub_one_of_lt le_of_pred_lt {_ _} := le_of_sub_one_lt @[simp] theorem succ_eq_succ : Order.succ = succ := rfl #align int.succ_eq_succ Int.succ_eq_succ @[simp] theorem pred_eq_pred : Order.pred = pred := rfl #align int.pred_eq_pred Int.pred_eq_pred theorem pos_iff_one_le {a : ℤ} : 0 < a ↔ 1 ≤ a := Order.succ_le_iff.symm #align int.pos_iff_one_le Int.pos_iff_one_le theorem succ_iterate (a : ℤ) : ∀ n, succ^[n] a = a + n | 0 => (add_zero a).symm | n + 1 => by rw [Function.iterate_succ', Int.ofNat_succ, ← add_assoc] exact congr_arg _ (succ_iterate a n) #align int.succ_iterate Int.succ_iterate theorem pred_iterate (a : ℤ) : ∀ n, pred^[n] a = a - n | 0 => (sub_zero a).symm | n + 1 => by rw [Function.iterate_succ', Int.ofNat_succ, ← sub_sub] exact congr_arg _ (pred_iterate a n) #align int.pred_iterate Int.pred_iterate instance : IsSuccArchimedean ℤ := ⟨fun {a b} h => ⟨(b - a).toNat, by rw [succ_eq_succ, succ_iterate, toNat_sub_of_le h, ← add_sub_assoc, add_sub_cancel_left]⟩⟩ instance : IsPredArchimedean ℤ := ⟨fun {a b} h => ⟨(b - a).toNat, by rw [pred_eq_pred, pred_iterate, toNat_sub_of_le h, sub_sub_cancel]⟩⟩ /-! ### Covering relation -/ protected theorem covBy_iff_succ_eq {m n : ℤ} : m ⋖ n ↔ m + 1 = n := succ_eq_iff_covBy.symm #align int.covby_iff_succ_eq Int.covBy_iff_succ_eq @[simp] theorem sub_one_covBy (z : ℤ) : z - 1 ⋖ z := by rw [Int.covBy_iff_succ_eq, sub_add_cancel] #align int.sub_one_covby Int.sub_one_covBy @[simp] theorem covBy_add_one (z : ℤ) : z ⋖ z + 1 := Int.covBy_iff_succ_eq.mpr rfl #align int.covby_add_one Int.covBy_add_one @[simp, norm_cast]
Mathlib/Data/Int/SuccPred.lean
88
90
theorem natCast_covBy {a b : ℕ} : (a : ℤ) ⋖ b ↔ a ⋖ b := by
rw [Nat.covBy_iff_succ_eq, Int.covBy_iff_succ_eq] exact Int.natCast_inj
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Antoine Chambert-Loir -/ import Mathlib.Algebra.DirectSum.Finsupp import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.DirectSum.TensorProduct #align_import linear_algebra.direct_sum.finsupp from "leanprover-community/mathlib"@"9b9d125b7be0930f564a68f1d73ace10cf46064d" /-! # Results on finitely supported functions. * `TensorProduct.finsuppLeft`, the tensor product of `ι →₀ M` and `N` is linearly equivalent to `ι →₀ M ⊗[R] N` * `TensorProduct.finsuppScalarLeft`, the tensor product of `ι →₀ R` and `N` is linearly equivalent to `ι →₀ N` * `TensorProduct.finsuppRight`, the tensor product of `M` and `ι →₀ N` is linearly equivalent to `ι →₀ M ⊗[R] N` * `TensorProduct.finsuppScalarRight`, the tensor product of `M` and `ι →₀ R` is linearly equivalent to `ι →₀ N` * `TensorProduct.finsuppLeft'`, if `M` is an `S`-module, then the tensor product of `ι →₀ M` and `N` is `S`-linearly equivalent to `ι →₀ M ⊗[R] N` * `finsuppTensorFinsupp`, the tensor product of `ι →₀ M` and `κ →₀ N` is linearly equivalent to `(ι × κ) →₀ (M ⊗ N)`. ## Case of MvPolynomial These functions apply to `MvPolynomial`, one can define ``` noncomputable def MvPolynomial.rTensor' : MvPolynomial σ S ⊗[R] N ≃ₗ[S] (σ →₀ ℕ) →₀ (S ⊗[R] N) := TensorProduct.finsuppLeft' noncomputable def MvPolynomial.rTensor : MvPolynomial σ R ⊗[R] N ≃ₗ[R] (σ →₀ ℕ) →₀ N := TensorProduct.finsuppScalarLeft ``` However, to be actually usable, these definitions need lemmas to be given in companion PR. ## Case of `Polynomial` `Polynomial` is a structure containing a `Finsupp`, so these functions can't be applied directly to `Polynomial`. Some linear equivs need to be added to mathlib for that. This belongs to a companion PR. ## TODO * generalize to `MonoidAlgebra`, `AlgHom ` * reprove `TensorProduct.finsuppLeft'` using existing heterobasic version of `TensorProduct.congr` -/ noncomputable section open DirectSum TensorProduct open Set LinearMap Submodule section TensorProduct variable (R : Type*) [CommSemiring R] (M : Type*) [AddCommMonoid M] [Module R M] (N : Type*) [AddCommMonoid N] [Module R N] namespace TensorProduct variable (ι : Type*) [DecidableEq ι] /-- The tensor product of `ι →₀ M` and `N` is linearly equivalent to `ι →₀ M ⊗[R] N` -/ noncomputable def finsuppLeft : (ι →₀ M) ⊗[R] N ≃ₗ[R] ι →₀ M ⊗[R] N := congr (finsuppLEquivDirectSum R M ι) (.refl R N) ≪≫ₗ directSumLeft R (fun _ ↦ M) N ≪≫ₗ (finsuppLEquivDirectSum R _ ι).symm variable {R M N ι} lemma finsuppLeft_apply_tmul (p : ι →₀ M) (n : N) : finsuppLeft R M N ι (p ⊗ₜ[R] n) = p.sum fun i m ↦ Finsupp.single i (m ⊗ₜ[R] n) := by apply p.induction_linear · simp · intros f g hf hg; simp [add_tmul, map_add, hf, hg, Finsupp.sum_add_index] · simp [finsuppLeft] @[simp] lemma finsuppLeft_apply_tmul_apply (p : ι →₀ M) (n : N) (i : ι) : finsuppLeft R M N ι (p ⊗ₜ[R] n) i = p i ⊗ₜ[R] n := by rw [finsuppLeft_apply_tmul, Finsupp.sum_apply, Finsupp.sum_eq_single i (fun _ _ ↦ Finsupp.single_eq_of_ne) (by simp), Finsupp.single_eq_same]
Mathlib/LinearAlgebra/DirectSum/Finsupp.lean
102
107
theorem finsuppLeft_apply (t : (ι →₀ M) ⊗[R] N) (i : ι) : finsuppLeft R M N ι t i = rTensor N (Finsupp.lapply i) t := by
induction t using TensorProduct.induction_on with | zero => simp | tmul f n => simp only [finsuppLeft_apply_tmul_apply, rTensor_tmul, Finsupp.lapply_apply] | add x y hx hy => simp [map_add, hx, hy]
/- Copyright (c) 2022 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Finsupp.Defs import Mathlib.Data.Finset.Pairwise #align_import data.finsupp.big_operators from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Sums of collections of Finsupp, and their support This file provides results about the `Finsupp.support` of sums of collections of `Finsupp`, including sums of `List`, `Multiset`, and `Finset`. The support of the sum is a subset of the union of the supports: * `List.support_sum_subset` * `Multiset.support_sum_subset` * `Finset.support_sum_subset` The support of the sum of pairwise disjoint finsupps is equal to the union of the supports * `List.support_sum_eq` * `Multiset.support_sum_eq` * `Finset.support_sum_eq` Member in the support of the indexed union over a collection iff it is a member of the support of a member of the collection: * `List.mem_foldr_sup_support_iff` * `Multiset.mem_sup_map_support_iff` * `Finset.mem_sup_support_iff` -/ variable {ι M : Type*} [DecidableEq ι] theorem List.support_sum_subset [AddMonoid M] (l : List (ι →₀ M)) : l.sum.support ⊆ l.foldr (Finsupp.support · ⊔ ·) ∅ := by induction' l with hd tl IH · simp · simp only [List.sum_cons, Finset.union_comm] refine Finsupp.support_add.trans (Finset.union_subset_union ?_ IH) rfl #align list.support_sum_subset List.support_sum_subset theorem Multiset.support_sum_subset [AddCommMonoid M] (s : Multiset (ι →₀ M)) : s.sum.support ⊆ (s.map Finsupp.support).sup := by induction s using Quot.inductionOn simpa only [Multiset.quot_mk_to_coe'', Multiset.sum_coe, Multiset.map_coe, Multiset.sup_coe, List.foldr_map] using List.support_sum_subset _ #align multiset.support_sum_subset Multiset.support_sum_subset theorem Finset.support_sum_subset [AddCommMonoid M] (s : Finset (ι →₀ M)) : (s.sum id).support ⊆ Finset.sup s Finsupp.support := by classical convert Multiset.support_sum_subset s.1; simp #align finset.support_sum_subset Finset.support_sum_subset
Mathlib/Data/Finsupp/BigOperators.lean
60
66
theorem List.mem_foldr_sup_support_iff [Zero M] {l : List (ι →₀ M)} {x : ι} : x ∈ l.foldr (Finsupp.support · ⊔ ·) ∅ ↔ ∃ f ∈ l, x ∈ f.support := by
simp only [Finset.sup_eq_union, List.foldr_map, Finsupp.mem_support_iff, exists_prop] induction' l with hd tl IH · simp · simp only [foldr, Function.comp_apply, Finset.mem_union, Finsupp.mem_support_iff, ne_eq, IH, find?, mem_cons, exists_eq_or_imp]
/- Copyright (c) 2022 Michael Stoll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Stoll -/ import Mathlib.Data.Int.Range import Mathlib.Data.ZMod.Basic import Mathlib.NumberTheory.MulChar.Basic #align_import number_theory.legendre_symbol.zmod_char from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Quadratic characters on ℤ/nℤ This file defines some quadratic characters on the rings ℤ/4ℤ and ℤ/8ℤ. We set them up to be of type `MulChar (ZMod n) ℤ`, where `n` is `4` or `8`. ## Tags quadratic character, zmod -/ /-! ### Quadratic characters mod 4 and 8 We define the primitive quadratic characters `χ₄`on `ZMod 4` and `χ₈`, `χ₈'` on `ZMod 8`. -/ namespace ZMod section QuadCharModP /-- Define the nontrivial quadratic character on `ZMod 4`, `χ₄`. It corresponds to the extension `ℚ(√-1)/ℚ`. -/ @[simps] def χ₄ : MulChar (ZMod 4) ℤ where toFun := (![0, 1, 0, -1] : ZMod 4 → ℤ) map_one' := rfl map_mul' := by decide map_nonunit' := by decide #align zmod.χ₄ ZMod.χ₄ /-- `χ₄` takes values in `{0, 1, -1}` -/ theorem isQuadratic_χ₄ : χ₄.IsQuadratic := by intro a -- Porting note (#11043): was `decide!` fin_cases a all_goals decide #align zmod.is_quadratic_χ₄ ZMod.isQuadratic_χ₄ /-- The value of `χ₄ n`, for `n : ℕ`, depends only on `n % 4`. -/ theorem χ₄_nat_mod_four (n : ℕ) : χ₄ n = χ₄ (n % 4 : ℕ) := by rw [← ZMod.natCast_mod n 4] #align zmod.χ₄_nat_mod_four ZMod.χ₄_nat_mod_four /-- The value of `χ₄ n`, for `n : ℤ`, depends only on `n % 4`. -/ theorem χ₄_int_mod_four (n : ℤ) : χ₄ n = χ₄ (n % 4 : ℤ) := by rw [← ZMod.intCast_mod n 4] norm_cast #align zmod.χ₄_int_mod_four ZMod.χ₄_int_mod_four /-- An explicit description of `χ₄` on integers / naturals -/ theorem χ₄_int_eq_if_mod_four (n : ℤ) : χ₄ n = if n % 2 = 0 then 0 else if n % 4 = 1 then 1 else -1 := by have help : ∀ m : ℤ, 0 ≤ m → m < 4 → χ₄ m = if m % 2 = 0 then 0 else if m = 1 then 1 else -1 := by decide rw [← Int.emod_emod_of_dvd n (by decide : (2 : ℤ) ∣ 4), ← ZMod.intCast_mod n 4] exact help (n % 4) (Int.emod_nonneg n (by norm_num)) (Int.emod_lt n (by norm_num)) #align zmod.χ₄_int_eq_if_mod_four ZMod.χ₄_int_eq_if_mod_four theorem χ₄_nat_eq_if_mod_four (n : ℕ) : χ₄ n = if n % 2 = 0 then 0 else if n % 4 = 1 then 1 else -1 := mod_cast χ₄_int_eq_if_mod_four n #align zmod.χ₄_nat_eq_if_mod_four ZMod.χ₄_nat_eq_if_mod_four /-- Alternative description of `χ₄ n` for odd `n : ℕ` in terms of powers of `-1` -/ theorem χ₄_eq_neg_one_pow {n : ℕ} (hn : n % 2 = 1) : χ₄ n = (-1) ^ (n / 2) := by rw [χ₄_nat_eq_if_mod_four] simp only [hn, Nat.one_ne_zero, if_false] conv_rhs => -- Porting note: was `nth_rw` arg 2; rw [← Nat.div_add_mod n 4] enter [1, 1, 1]; rw [(by norm_num : 4 = 2 * 2)] rw [mul_assoc, add_comm, Nat.add_mul_div_left _ _ (by norm_num : 0 < 2), pow_add, pow_mul, neg_one_sq, one_pow, mul_one] have help : ∀ m : ℕ, m < 4 → m % 2 = 1 → ite (m = 1) (1 : ℤ) (-1) = (-1) ^ (m / 2) := by decide exact help (n % 4) (Nat.mod_lt n (by norm_num)) ((Nat.mod_mod_of_dvd n (by decide : 2 ∣ 4)).trans hn) #align zmod.χ₄_eq_neg_one_pow ZMod.χ₄_eq_neg_one_pow /-- If `n % 4 = 1`, then `χ₄ n = 1`. -/ theorem χ₄_nat_one_mod_four {n : ℕ} (hn : n % 4 = 1) : χ₄ n = 1 := by rw [χ₄_nat_mod_four, hn] rfl #align zmod.χ₄_nat_one_mod_four ZMod.χ₄_nat_one_mod_four /-- If `n % 4 = 3`, then `χ₄ n = -1`. -/
Mathlib/NumberTheory/LegendreSymbol/ZModChar.lean
101
103
theorem χ₄_nat_three_mod_four {n : ℕ} (hn : n % 4 = 3) : χ₄ n = -1 := by
rw [χ₄_nat_mod_four, hn] rfl
/- Copyright (c) 2023 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Patrick Massot -/ import Mathlib.LinearAlgebra.Basis import Mathlib.LinearAlgebra.Dual import Mathlib.Data.Fin.FlagRange /-! # Flag of submodules defined by a basis In this file we define `Basis.flag b k`, where `b : Basis (Fin n) R M`, `k : Fin (n + 1)`, to be the subspace spanned by the first `k` vectors of the basis `b`. We also prove some lemmas about this definition. -/ open Set Submodule namespace Basis section Semiring variable {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] {n : ℕ} /-- The subspace spanned by the first `k` vectors of the basis `b`. -/ def flag (b : Basis (Fin n) R M) (k : Fin (n + 1)) : Submodule R M := .span R <| b '' {i | i.castSucc < k} @[simp] theorem flag_zero (b : Basis (Fin n) R M) : b.flag 0 = ⊥ := by simp [flag] @[simp] theorem flag_last (b : Basis (Fin n) R M) : b.flag (.last n) = ⊤ := by simp [flag, Fin.castSucc_lt_last] theorem flag_le_iff (b : Basis (Fin n) R M) {k p} : b.flag k ≤ p ↔ ∀ i : Fin n, i.castSucc < k → b i ∈ p := span_le.trans forall_mem_image
Mathlib/LinearAlgebra/Basis/Flag.lean
42
45
theorem flag_succ (b : Basis (Fin n) R M) (k : Fin n) : b.flag k.succ = (R ∙ b k) ⊔ b.flag k.castSucc := by
simp only [flag, Fin.castSucc_lt_castSucc_iff] simp [Fin.castSucc_lt_iff_succ_le, le_iff_eq_or_lt, setOf_or, image_insert_eq, span_insert]
/- Copyright (c) 2021 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth, Frédéric Dupuis -/ import Mathlib.Analysis.InnerProductSpace.Calculus import Mathlib.Analysis.InnerProductSpace.Dual import Mathlib.Analysis.InnerProductSpace.Adjoint import Mathlib.Analysis.Calculus.LagrangeMultipliers import Mathlib.LinearAlgebra.Eigenspace.Basic #align_import analysis.inner_product_space.rayleigh from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1" /-! # The Rayleigh quotient The Rayleigh quotient of a self-adjoint operator `T` on an inner product space `E` is the function `fun x ↦ ⟪T x, x⟫ / ‖x‖ ^ 2`. The main results of this file are `IsSelfAdjoint.hasEigenvector_of_isMaxOn` and `IsSelfAdjoint.hasEigenvector_of_isMinOn`, which state that if `E` is complete, and if the Rayleigh quotient attains its global maximum/minimum over some sphere at the point `x₀`, then `x₀` is an eigenvector of `T`, and the `iSup`/`iInf` of `fun x ↦ ⟪T x, x⟫ / ‖x‖ ^ 2` is the corresponding eigenvalue. The corollaries `LinearMap.IsSymmetric.hasEigenvalue_iSup_of_finiteDimensional` and `LinearMap.IsSymmetric.hasEigenvalue_iSup_of_finiteDimensional` state that if `E` is finite-dimensional and nontrivial, then `T` has some (nonzero) eigenvectors with eigenvalue the `iSup`/`iInf` of `fun x ↦ ⟪T x, x⟫ / ‖x‖ ^ 2`. ## TODO A slightly more elaborate corollary is that if `E` is complete and `T` is a compact operator, then `T` has some (nonzero) eigenvector with eigenvalue either `⨆ x, ⟪T x, x⟫ / ‖x‖ ^ 2` or `⨅ x, ⟪T x, x⟫ / ‖x‖ ^ 2` (not necessarily both). -/ variable {𝕜 : Type*} [RCLike 𝕜] variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y open scoped NNReal open Module.End Metric namespace ContinuousLinearMap variable (T : E →L[𝕜] E) /-- The *Rayleigh quotient* of a continuous linear map `T` (over `ℝ` or `ℂ`) at a vector `x` is the quantity `re ⟪T x, x⟫ / ‖x‖ ^ 2`. -/ noncomputable abbrev rayleighQuotient (x : E) := T.reApplyInnerSelf x / ‖(x : E)‖ ^ 2
Mathlib/Analysis/InnerProductSpace/Rayleigh.lean
57
64
theorem rayleigh_smul (x : E) {c : 𝕜} (hc : c ≠ 0) : rayleighQuotient T (c • x) = rayleighQuotient T x := by
by_cases hx : x = 0 · simp [hx] have : ‖c‖ ≠ 0 := by simp [hc] have : ‖x‖ ≠ 0 := by simp [hx] field_simp [norm_smul, T.reApplyInnerSelf_smul] ring
/- 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
Mathlib/Algebra/Polynomial/Coeff.lean
60
65
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]