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 Michael Jendrusch. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Jendrusch, Scott Morrison, Bhavik Mehta, Jakob von Raumer -/ import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Monoidal.Free.Coherence #align_import category_theory.monoidal.coherence_lemmas from "leanprover-community/mathlib"@"b8b8bf3ea0c625fa1f950034a184e07c67f7bcfe" /-! # Lemmas which are consequences of monoidal coherence These lemmas are all proved `by coherence`. ## Future work Investigate whether these lemmas are really needed, or if they can be replaced by use of the `coherence` tactic. -/ open CategoryTheory Category Iso namespace CategoryTheory.MonoidalCategory variable {C : Type*} [Category C] [MonoidalCategory C] -- See Proposition 2.2.4 of <http://www-math.mit.edu/~etingof/egnobookfinal.pdf> @[reassoc] theorem leftUnitor_tensor'' (X Y : C) : (α_ (𝟙_ C) X Y).hom ≫ (λ_ (X ⊗ Y)).hom = (λ_ X).hom ⊗ 𝟙 Y := by coherence #align category_theory.monoidal_category.left_unitor_tensor' CategoryTheory.MonoidalCategory.leftUnitor_tensor'' @[reassoc] theorem leftUnitor_tensor' (X Y : C) : (λ_ (X ⊗ Y)).hom = (α_ (𝟙_ C) X Y).inv ≫ ((λ_ X).hom ⊗ 𝟙 Y) := by coherence #align category_theory.monoidal_category.left_unitor_tensor CategoryTheory.MonoidalCategory.leftUnitor_tensor' @[reassoc] theorem leftUnitor_tensor_inv' (X Y : C) : (λ_ (X ⊗ Y)).inv = ((λ_ X).inv ⊗ 𝟙 Y) ≫ (α_ (𝟙_ C) X Y).hom := by coherence #align category_theory.monoidal_category.left_unitor_tensor_inv CategoryTheory.MonoidalCategory.leftUnitor_tensor_inv' @[reassoc] theorem id_tensor_rightUnitor_inv (X Y : C) : 𝟙 X ⊗ (ρ_ Y).inv = (ρ_ _).inv ≫ (α_ _ _ _).hom := by coherence #align category_theory.monoidal_category.id_tensor_right_unitor_inv CategoryTheory.MonoidalCategory.id_tensor_rightUnitor_inv @[reassoc] theorem leftUnitor_inv_tensor_id (X Y : C) : (λ_ X).inv ⊗ 𝟙 Y = (λ_ _).inv ≫ (α_ _ _ _).inv := by coherence #align category_theory.monoidal_category.left_unitor_inv_tensor_id CategoryTheory.MonoidalCategory.leftUnitor_inv_tensor_id @[reassoc] theorem pentagon_inv_inv_hom (W X Y Z : C) : (α_ W (X ⊗ Y) Z).inv ≫ ((α_ W X Y).inv ⊗ 𝟙 Z) ≫ (α_ (W ⊗ X) Y Z).hom = (𝟙 W ⊗ (α_ X Y Z).hom) ≫ (α_ W X (Y ⊗ Z)).inv := by coherence #align category_theory.monoidal_category.pentagon_inv_inv_hom CategoryTheory.MonoidalCategory.pentagon_inv_inv_hom theorem unitors_equal : (λ_ (𝟙_ C)).hom = (ρ_ (𝟙_ C)).hom := by coherence #align category_theory.monoidal_category.unitors_equal CategoryTheory.MonoidalCategory.unitors_equal
Mathlib/CategoryTheory/Monoidal/CoherenceLemmas.lean
67
68
theorem unitors_inv_equal : (λ_ (𝟙_ C)).inv = (ρ_ (𝟙_ C)).inv := by
coherence
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Polynomial.Degree.Definitions import Mathlib.Data.ENat.Basic #align_import data.polynomial.degree.trailing_degree from "leanprover-community/mathlib"@"302eab4f46abb63de520828de78c04cb0f9b5836" /-! # Trailing degree of univariate polynomials ## Main definitions * `trailingDegree p`: the multiplicity of `X` in the polynomial `p` * `natTrailingDegree`: a variant of `trailingDegree` that takes values in the natural numbers * `trailingCoeff`: the coefficient at index `natTrailingDegree p` Converts most results about `degree`, `natDegree` and `leadingCoeff` to results about the bottom end of a polynomial -/ noncomputable section open Function Polynomial Finsupp Finset open scoped Polynomial namespace Polynomial universe u v variable {R : Type u} {S : Type v} {a b : R} {n m : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} /-- `trailingDegree p` is the multiplicity of `x` in the polynomial `p`, i.e. the smallest `X`-exponent in `p`. `trailingDegree p = some n` when `p ≠ 0` and `n` is the smallest power of `X` that appears in `p`, otherwise `trailingDegree 0 = ⊤`. -/ def trailingDegree (p : R[X]) : ℕ∞ := p.support.min #align polynomial.trailing_degree Polynomial.trailingDegree theorem trailingDegree_lt_wf : WellFounded fun p q : R[X] => trailingDegree p < trailingDegree q := InvImage.wf trailingDegree wellFounded_lt #align polynomial.trailing_degree_lt_wf Polynomial.trailingDegree_lt_wf /-- `natTrailingDegree p` forces `trailingDegree p` to `ℕ`, by defining `natTrailingDegree ⊤ = 0`. -/ def natTrailingDegree (p : R[X]) : ℕ := (trailingDegree p).getD 0 #align polynomial.nat_trailing_degree Polynomial.natTrailingDegree /-- `trailingCoeff p` gives the coefficient of the smallest power of `X` in `p`-/ def trailingCoeff (p : R[X]) : R := coeff p (natTrailingDegree p) #align polynomial.trailing_coeff Polynomial.trailingCoeff /-- a polynomial is `monic_at` if its trailing coefficient is 1 -/ def TrailingMonic (p : R[X]) := trailingCoeff p = (1 : R) #align polynomial.trailing_monic Polynomial.TrailingMonic theorem TrailingMonic.def : TrailingMonic p ↔ trailingCoeff p = 1 := Iff.rfl #align polynomial.trailing_monic.def Polynomial.TrailingMonic.def instance TrailingMonic.decidable [DecidableEq R] : Decidable (TrailingMonic p) := inferInstanceAs <| Decidable (trailingCoeff p = (1 : R)) #align polynomial.trailing_monic.decidable Polynomial.TrailingMonic.decidable @[simp] theorem TrailingMonic.trailingCoeff {p : R[X]} (hp : p.TrailingMonic) : trailingCoeff p = 1 := hp #align polynomial.trailing_monic.trailing_coeff Polynomial.TrailingMonic.trailingCoeff @[simp] theorem trailingDegree_zero : trailingDegree (0 : R[X]) = ⊤ := rfl #align polynomial.trailing_degree_zero Polynomial.trailingDegree_zero @[simp] theorem trailingCoeff_zero : trailingCoeff (0 : R[X]) = 0 := rfl #align polynomial.trailing_coeff_zero Polynomial.trailingCoeff_zero @[simp] theorem natTrailingDegree_zero : natTrailingDegree (0 : R[X]) = 0 := rfl #align polynomial.nat_trailing_degree_zero Polynomial.natTrailingDegree_zero theorem trailingDegree_eq_top : trailingDegree p = ⊤ ↔ p = 0 := ⟨fun h => support_eq_empty.1 (Finset.min_eq_top.1 h), fun h => by simp [h]⟩ #align polynomial.trailing_degree_eq_top Polynomial.trailingDegree_eq_top theorem trailingDegree_eq_natTrailingDegree (hp : p ≠ 0) : trailingDegree p = (natTrailingDegree p : ℕ∞) := by let ⟨n, hn⟩ := not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt trailingDegree_eq_top.1 hp)) have hn : trailingDegree p = n := Classical.not_not.1 hn rw [natTrailingDegree, hn] rfl #align polynomial.trailing_degree_eq_nat_trailing_degree Polynomial.trailingDegree_eq_natTrailingDegree
Mathlib/Algebra/Polynomial/Degree/TrailingDegree.lean
111
114
theorem trailingDegree_eq_iff_natTrailingDegree_eq {p : R[X]} {n : ℕ} (hp : p ≠ 0) : p.trailingDegree = n ↔ p.natTrailingDegree = n := by
rw [trailingDegree_eq_natTrailingDegree hp] exact WithTop.coe_eq_coe
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Jens Wagemaker, Anne Baanen -/ import Mathlib.Algebra.Associated import Mathlib.Algebra.BigOperators.Group.List import Mathlib.Data.List.Perm #align_import data.list.prime from "leanprover-community/mathlib"@"ccad6d5093bd2f5c6ca621fc74674cce51355af6" /-! # Products of lists of prime elements. This file contains some theorems relating `Prime` and products of `List`s. -/ open List section CommMonoidWithZero variable {M : Type*} [CommMonoidWithZero M] /-- Prime `p` divides the product of a list `L` iff it divides some `a ∈ L` -/ theorem Prime.dvd_prod_iff {p : M} {L : List M} (pp : Prime p) : p ∣ L.prod ↔ ∃ a ∈ L, p ∣ a := by constructor · intro h induction' L with L_hd L_tl L_ih · rw [prod_nil] at h exact absurd h pp.not_dvd_one · rw [prod_cons] at h cases' pp.dvd_or_dvd h with hd hd · exact ⟨L_hd, mem_cons_self L_hd L_tl, hd⟩ · obtain ⟨x, hx1, hx2⟩ := L_ih hd exact ⟨x, mem_cons_of_mem L_hd hx1, hx2⟩ · exact fun ⟨a, ha1, ha2⟩ => dvd_trans ha2 (dvd_prod ha1) #align prime.dvd_prod_iff Prime.dvd_prod_iff theorem Prime.not_dvd_prod {p : M} {L : List M} (pp : Prime p) (hL : ∀ a ∈ L, ¬p ∣ a) : ¬p ∣ L.prod := mt (Prime.dvd_prod_iff pp).1 <| not_exists.2 fun a => not_and.2 (hL a) #align prime.not_dvd_prod Prime.not_dvd_prod end CommMonoidWithZero section CancelCommMonoidWithZero variable {M : Type*} [CancelCommMonoidWithZero M] [Unique (Units M)]
Mathlib/Data/List/Prime.lean
52
55
theorem mem_list_primes_of_dvd_prod {p : M} (hp : Prime p) {L : List M} (hL : ∀ q ∈ L, Prime q) (hpL : p ∣ L.prod) : p ∈ L := by
obtain ⟨x, hx1, hx2⟩ := hp.dvd_prod_iff.mp hpL rwa [(prime_dvd_prime_iff_eq hp (hL x hx1)).mp hx2]
/- Copyright (c) 2018 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Reid Barton -/ import Mathlib.Topology.Bases import Mathlib.Topology.DenseEmbedding #align_import topology.stone_cech from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" /-! # Stone-Čech compactification Construction of the Stone-Čech compactification using ultrafilters. Parts of the formalization are based on "Ultrafilters and Topology" by Marius Stekelenburg, particularly section 5. -/ noncomputable section open Filter Set open Topology universe u v section Ultrafilter /- The set of ultrafilters on α carries a natural topology which makes it the Stone-Čech compactification of α (viewed as a discrete space). -/ /-- Basis for the topology on `Ultrafilter α`. -/ def ultrafilterBasis (α : Type u) : Set (Set (Ultrafilter α)) := range fun s : Set α => { u | s ∈ u } #align ultrafilter_basis ultrafilterBasis variable {α : Type u} instance Ultrafilter.topologicalSpace : TopologicalSpace (Ultrafilter α) := TopologicalSpace.generateFrom (ultrafilterBasis α) #align ultrafilter.topological_space Ultrafilter.topologicalSpace theorem ultrafilterBasis_is_basis : TopologicalSpace.IsTopologicalBasis (ultrafilterBasis α) := ⟨by rintro _ ⟨a, rfl⟩ _ ⟨b, rfl⟩ u ⟨ua, ub⟩ refine ⟨_, ⟨a ∩ b, rfl⟩, inter_mem ua ub, fun v hv => ⟨?_, ?_⟩⟩ <;> apply mem_of_superset hv <;> simp [inter_subset_right], eq_univ_of_univ_subset <| subset_sUnion_of_mem <| ⟨univ, eq_univ_of_forall fun u => univ_mem⟩, rfl⟩ #align ultrafilter_basis_is_basis ultrafilterBasis_is_basis /-- The basic open sets for the topology on ultrafilters are open. -/ theorem ultrafilter_isOpen_basic (s : Set α) : IsOpen { u : Ultrafilter α | s ∈ u } := ultrafilterBasis_is_basis.isOpen ⟨s, rfl⟩ #align ultrafilter_is_open_basic ultrafilter_isOpen_basic /-- The basic open sets for the topology on ultrafilters are also closed. -/ theorem ultrafilter_isClosed_basic (s : Set α) : IsClosed { u : Ultrafilter α | s ∈ u } := by rw [← isOpen_compl_iff] convert ultrafilter_isOpen_basic sᶜ using 1 ext u exact Ultrafilter.compl_mem_iff_not_mem.symm #align ultrafilter_is_closed_basic ultrafilter_isClosed_basic /-- Every ultrafilter `u` on `Ultrafilter α` converges to a unique point of `Ultrafilter α`, namely `joinM u`. -/
Mathlib/Topology/StoneCech.lean
67
77
theorem ultrafilter_converges_iff {u : Ultrafilter (Ultrafilter α)} {x : Ultrafilter α} : ↑u ≤ 𝓝 x ↔ x = joinM u := by
rw [eq_comm, ← Ultrafilter.coe_le_coe] change ↑u ≤ 𝓝 x ↔ ∀ s ∈ x, { v : Ultrafilter α | s ∈ v } ∈ u simp only [TopologicalSpace.nhds_generateFrom, le_iInf_iff, ultrafilterBasis, le_principal_iff, mem_setOf_eq] constructor · intro h a ha exact h _ ⟨ha, a, rfl⟩ · rintro h a ⟨xi, a, rfl⟩ exact h _ xi
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex #align_import measure_theory.function.special_functions.inner from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf" /-! # Measurability of scalar products -/ variable {α : Type*} {𝕜 : Type*} {E : Type*} variable [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y @[aesop safe 20 apply (rule_sets := [Measurable])] theorem Measurable.inner {_ : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {f g : α → E} (hf : Measurable f) (hg : Measurable g) : Measurable fun t => ⟪f t, g t⟫ := Continuous.measurable2 continuous_inner hf hg #align measurable.inner Measurable.inner @[measurability] theorem Measurable.const_inner {_ : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {c : E} {f : α → E} (hf : Measurable f) : Measurable fun t => ⟪c, f t⟫ := Measurable.inner measurable_const hf @[measurability] theorem Measurable.inner_const {_ : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {c : E} {f : α → E} (hf : Measurable f) : Measurable fun t => ⟪f t, c⟫ := Measurable.inner hf measurable_const @[aesop safe 20 apply (rule_sets := [Measurable])]
Mathlib/MeasureTheory/Function/SpecialFunctions/Inner.lean
41
47
theorem AEMeasurable.inner {m : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {μ : MeasureTheory.Measure α} {f g : α → E} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun x => ⟪f x, g x⟫) μ := by
refine ⟨fun x => ⟪hf.mk f x, hg.mk g x⟫, hf.measurable_mk.inner hg.measurable_mk, ?_⟩ refine hf.ae_eq_mk.mp (hg.ae_eq_mk.mono fun x hxg hxf => ?_) dsimp only congr
/- Copyright (c) 2023 Mark Andrew Gerads. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Andrew Gerads, Junyan Xu, Eric Wieser -/ import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Tactic.Ring #align_import data.nat.hyperoperation from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Hyperoperation sequence This file defines the Hyperoperation sequence. `hyperoperation 0 m k = k + 1` `hyperoperation 1 m k = m + k` `hyperoperation 2 m k = m * k` `hyperoperation 3 m k = m ^ k` `hyperoperation (n + 3) m 0 = 1` `hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k)` ## References * <https://en.wikipedia.org/wiki/Hyperoperation> ## Tags hyperoperation -/ /-- Implementation of the hyperoperation sequence where `hyperoperation n m k` is the `n`th hyperoperation between `m` and `k`. -/ def hyperoperation : ℕ → ℕ → ℕ → ℕ | 0, _, k => k + 1 | 1, m, 0 => m | 2, _, 0 => 0 | _ + 3, _, 0 => 1 | n + 1, m, k + 1 => hyperoperation n m (hyperoperation (n + 1) m k) #align hyperoperation hyperoperation -- Basic hyperoperation lemmas @[simp] theorem hyperoperation_zero (m : ℕ) : hyperoperation 0 m = Nat.succ := funext fun k => by rw [hyperoperation, Nat.succ_eq_add_one] #align hyperoperation_zero hyperoperation_zero theorem hyperoperation_ge_three_eq_one (n m : ℕ) : hyperoperation (n + 3) m 0 = 1 := by rw [hyperoperation] #align hyperoperation_ge_three_eq_one hyperoperation_ge_three_eq_one theorem hyperoperation_recursion (n m k : ℕ) : hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k) := by rw [hyperoperation] #align hyperoperation_recursion hyperoperation_recursion -- Interesting hyperoperation lemmas @[simp] theorem hyperoperation_one : hyperoperation 1 = (· + ·) := by ext m k induction' k with bn bih · rw [Nat.add_zero m, hyperoperation] · rw [hyperoperation_recursion, bih, hyperoperation_zero] exact Nat.add_assoc m bn 1 #align hyperoperation_one hyperoperation_one @[simp]
Mathlib/Data/Nat/Hyperoperation.lean
69
78
theorem hyperoperation_two : hyperoperation 2 = (· * ·) := by
ext m k induction' k with bn bih · rw [hyperoperation] exact (Nat.mul_zero m).symm · rw [hyperoperation_recursion, hyperoperation_one, bih] -- Porting note: was `ring` dsimp only nth_rewrite 1 [← mul_one m] rw [← mul_add, add_comm]
/- Copyright (c) 2022 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.Data.Fintype.Basic import Mathlib.ModelTheory.Substructures #align_import model_theory.elementary_maps from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15" /-! # Elementary Maps Between First-Order Structures ## Main Definitions * A `FirstOrder.Language.ElementaryEmbedding` is an embedding that commutes with the realizations of formulas. * The `FirstOrder.Language.elementaryDiagram` of a structure is the set of all sentences with parameters that the structure satisfies. * `FirstOrder.Language.ElementaryEmbedding.ofModelsElementaryDiagram` is the canonical elementary embedding of any structure into a model of its elementary diagram. ## Main Results * The Tarski-Vaught Test for embeddings: `FirstOrder.Language.Embedding.isElementary_of_exists` gives a simple criterion for an embedding to be elementary. -/ open FirstOrder namespace FirstOrder namespace Language open Structure variable (L : Language) (M : Type*) (N : Type*) {P : Type*} {Q : Type*} variable [L.Structure M] [L.Structure N] [L.Structure P] [L.Structure Q] /-- An elementary embedding of first-order structures is an embedding that commutes with the realizations of formulas. -/ structure ElementaryEmbedding where toFun : M → N -- Porting note: -- The autoparam here used to be `obviously`. We would like to replace it with `aesop` -- but that isn't currently sufficient. -- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Aesop.20and.20cases -- If that can be improved, we should change this to `by aesop` and remove the proofs below. map_formula' : ∀ ⦃n⦄ (φ : L.Formula (Fin n)) (x : Fin n → M), φ.Realize (toFun ∘ x) ↔ φ.Realize x := by intros; trivial #align first_order.language.elementary_embedding FirstOrder.Language.ElementaryEmbedding #align first_order.language.elementary_embedding.to_fun FirstOrder.Language.ElementaryEmbedding.toFun #align first_order.language.elementary_embedding.map_formula' FirstOrder.Language.ElementaryEmbedding.map_formula' @[inherit_doc FirstOrder.Language.ElementaryEmbedding] scoped[FirstOrder] notation:25 A " ↪ₑ[" L "] " B => FirstOrder.Language.ElementaryEmbedding L A B variable {L} {M} {N} namespace ElementaryEmbedding attribute [coe] toFun instance instFunLike : FunLike (M ↪ₑ[L] N) M N where coe f := f.toFun coe_injective' f g h := by cases f cases g simp only [ElementaryEmbedding.mk.injEq] ext x exact Function.funext_iff.1 h x #align first_order.language.elementary_embedding.fun_like FirstOrder.Language.ElementaryEmbedding.instFunLike instance : CoeFun (M ↪ₑ[L] N) fun _ => M → N := DFunLike.hasCoeToFun @[simp]
Mathlib/ModelTheory/ElementaryMaps.lean
78
94
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n) (v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
classical rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq] have h := f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _)) (Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm) simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula, iff_eq_eq] at h rw [← Function.comp.assoc _ _ (Fintype.equivFin _).symm, Function.comp.assoc _ (Fintype.equivFin _).symm (Fintype.equivFin _), _root_.Equiv.symm_comp_self, Function.comp_id, Function.comp.assoc, Sum.elim_comp_inl, Function.comp.assoc _ _ Sum.inr, Sum.elim_comp_inr, ← Function.comp.assoc] at h refine h.trans ?_ erw [Function.comp.assoc _ _ (Fintype.equivFin _), _root_.Equiv.symm_comp_self, Function.comp_id, Sum.elim_comp_inl, Sum.elim_comp_inr (v ∘ Subtype.val) xs, ← Set.inclusion_eq_id (s := (BoundedFormula.freeVarFinset φ : Set α)) Set.Subset.rfl, BoundedFormula.realize_restrictFreeVar Set.Subset.rfl]
/- Copyright (c) 2024 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.FieldTheory.PurelyInseparable import Mathlib.FieldTheory.PerfectClosure /-! # `IsPerfectClosure` predicate This file contains `IsPerfectClosure` which asserts that `L` is a perfect closure of `K` under a ring homomorphism `i : K →+* L`, as well as its basic properties. ## Main definitions - `pNilradical`: given a natural number `p`, the `p`-nilradical of a ring is defined to be the nilradical if `p > 1` (`pNilradical_eq_nilradical`), and defined to be the zero ideal if `p ≤ 1` (`pNilradical_eq_bot'`). Equivalently, it is the ideal consisting of elements `x` such that `x ^ p ^ n = 0` for some `n` (`mem_pNilradical`). - `IsPRadical`: a ring homomorphism `i : K →+* L` of characteristic `p` rings is called `p`-radical, if or any element `x` of `L` there is `n : ℕ` such that `x ^ (p ^ n)` is contained in `K`, and the kernel of `i` is contained in the `p`-nilradical of `K`. A generalization of purely inseparable extension for fields. - `IsPerfectClosure`: if `i : K →+* L` is `p`-radical ring homomorphism, then it makes `L` a perfect closure of `K`, if `L` is perfect. Our definition makes it synonymous to `IsPRadical` if `PerfectRing L p` is present. A caveat is that you need to write `[PerfectRing L p] [IsPerfectClosure i p]`. This is similar to `PerfectRing` which has `ExpChar` as a prerequisite. - `PerfectRing.lift`: if a `p`-radical ring homomorphism `K →+* L` is given, `M` is a perfect ring, then any ring homomorphism `K →+* M` can be lifted to `L →+* M`. This is similar to `IsAlgClosed.lift` and `IsSepClosed.lift`. - `PerfectRing.liftEquiv`: `K →+* M` is one-to-one correspondence to `L →+* M`, given by `PerfectRing.lift`. This is a generalization to `PerfectClosure.lift`. - `IsPerfectClosure.equiv`: perfect closures of a ring are isomorphic. ## Main results - `IsPRadical.trans`: composition of `p`-radical ring homomorphisms is also `p`-radical. - `PerfectClosure.isPRadical`: the absolute perfect closure `PerfectClosure` is a `p`-radical extension over the base ring, in particular, it is a perfect closure of the base ring. - `IsPRadical.isPurelyInseparable`, `IsPurelyInseparable.isPRadical`: `p`-radical and purely inseparable are equivalent for fields. - The (relative) perfect closure `perfectClosure` is a perfect closure (inferred from `IsPurelyInseparable.isPRadical` automatically by Lean). ## Tags perfect ring, perfect closure, purely inseparable -/ open scoped Classical Polynomial open FiniteDimensional Polynomial IntermediateField Field noncomputable section /-- Given a natural number `p`, the `p`-nilradical of a ring is defined to be the nilradical if `p > 1` (`pNilradical_eq_nilradical`), and defined to be the zero ideal if `p ≤ 1` (`pNilradical_eq_bot'`). Equivalently, it is the ideal consisting of elements `x` such that `x ^ p ^ n = 0` for some `n` (`mem_pNilradical`). -/ def pNilradical (R : Type*) [CommSemiring R] (p : ℕ) : Ideal R := if 1 < p then nilradical R else ⊥ theorem pNilradical_le_nilradical {R : Type*} [CommSemiring R] {p : ℕ} : pNilradical R p ≤ nilradical R := by by_cases hp : 1 < p · rw [pNilradical, if_pos hp] simp_rw [pNilradical, if_neg hp, bot_le]
Mathlib/FieldTheory/IsPerfectClosure.lean
81
82
theorem pNilradical_eq_nilradical {R : Type*} [CommSemiring R] {p : ℕ} (hp : 1 < p) : pNilradical R p = nilradical R := by
rw [pNilradical, if_pos hp]
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Algebra.CharP.Invertible import Mathlib.Algebra.Order.Interval.Set.Group import Mathlib.Analysis.Convex.Segment import Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional import Mathlib.Tactic.FieldSimp #align_import analysis.convex.between from "leanprover-community/mathlib"@"571e13cacbed7bf042fd3058ce27157101433842" /-! # Betweenness in affine spaces This file defines notions of a point in an affine space being between two given points. ## Main definitions * `affineSegment R x y`: The segment of points weakly between `x` and `y`. * `Wbtw R x y z`: The point `y` is weakly between `x` and `z`. * `Sbtw R x y z`: The point `y` is strictly between `x` and `z`. -/ variable (R : Type*) {V V' P P' : Type*} open AffineEquiv AffineMap section OrderedRing variable [OrderedRing R] [AddCommGroup V] [Module R V] [AddTorsor V P] variable [AddCommGroup V'] [Module R V'] [AddTorsor V' P'] /-- The segment of points weakly between `x` and `y`. When convexity is refactored to support abstract affine combination spaces, this will no longer need to be a separate definition from `segment`. However, lemmas involving `+ᵥ` or `-ᵥ` will still be relevant after such a refactoring, as distinct from versions involving `+` or `-` in a module. -/ def affineSegment (x y : P) := lineMap x y '' Set.Icc (0 : R) 1 #align affine_segment affineSegment theorem affineSegment_eq_segment (x y : V) : affineSegment R x y = segment R x y := by rw [segment_eq_image_lineMap, affineSegment] #align affine_segment_eq_segment affineSegment_eq_segment theorem affineSegment_comm (x y : P) : affineSegment R x y = affineSegment R y x := by refine Set.ext fun z => ?_ constructor <;> · rintro ⟨t, ht, hxy⟩ refine ⟨1 - t, ?_, ?_⟩ · rwa [Set.sub_mem_Icc_iff_right, sub_self, sub_zero] · rwa [lineMap_apply_one_sub] #align affine_segment_comm affineSegment_comm theorem left_mem_affineSegment (x y : P) : x ∈ affineSegment R x y := ⟨0, Set.left_mem_Icc.2 zero_le_one, lineMap_apply_zero _ _⟩ #align left_mem_affine_segment left_mem_affineSegment theorem right_mem_affineSegment (x y : P) : y ∈ affineSegment R x y := ⟨1, Set.right_mem_Icc.2 zero_le_one, lineMap_apply_one _ _⟩ #align right_mem_affine_segment right_mem_affineSegment @[simp] theorem affineSegment_same (x : P) : affineSegment R x x = {x} := by -- Porting note: added as this doesn't do anything in `simp_rw` any more rw [affineSegment] -- Note: when adding "simp made no progress" in lean4#2336, -- had to change `lineMap_same` to `lineMap_same _`. Not sure why? -- Porting note: added `_ _` and `Function.const` simp_rw [lineMap_same _, AffineMap.coe_const _ _, Function.const, (Set.nonempty_Icc.mpr zero_le_one).image_const] #align affine_segment_same affineSegment_same variable {R} @[simp]
Mathlib/Analysis/Convex/Between.lean
80
83
theorem affineSegment_image (f : P →ᵃ[R] P') (x y : P) : f '' affineSegment R x y = affineSegment R (f x) (f y) := by
rw [affineSegment, affineSegment, Set.image_image, ← comp_lineMap] rfl
/- Copyright (c) 2017 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura -/ import Mathlib.Init.Logic import Mathlib.Tactic.AdaptationNote import Mathlib.Tactic.Coe /-! # Lemmas about booleans These are the lemmas about booleans which were present in core Lean 3. See also the file Mathlib.Data.Bool.Basic which contains lemmas about booleans from mathlib 3. -/ set_option autoImplicit true -- We align Lean 3 lemmas with lemmas in `Init.SimpLemmas` in Lean 4. #align band_self Bool.and_self #align band_tt Bool.and_true #align band_ff Bool.and_false #align tt_band Bool.true_and #align ff_band Bool.false_and #align bor_self Bool.or_self #align bor_tt Bool.or_true #align bor_ff Bool.or_false #align tt_bor Bool.true_or #align ff_bor Bool.false_or #align bnot_bnot Bool.not_not namespace Bool #align bool.cond_tt Bool.cond_true #align bool.cond_ff Bool.cond_false #align cond_a_a Bool.cond_self attribute [simp] xor_self #align bxor_self Bool.xor_self #align bxor_tt Bool.xor_true #align bxor_ff Bool.xor_false #align tt_bxor Bool.true_xor #align ff_bxor Bool.false_xor theorem true_eq_false_eq_False : ¬true = false := by decide #align tt_eq_ff_eq_false Bool.true_eq_false_eq_False theorem false_eq_true_eq_False : ¬false = true := by decide #align ff_eq_tt_eq_false Bool.false_eq_true_eq_False theorem eq_false_eq_not_eq_true (b : Bool) : (¬b = true) = (b = false) := by simp #align eq_ff_eq_not_eq_tt Bool.eq_false_eq_not_eq_true theorem eq_true_eq_not_eq_false (b : Bool) : (¬b = false) = (b = true) := by simp #align eq_tt_eq_not_eq_ft Bool.eq_true_eq_not_eq_false theorem eq_false_of_not_eq_true {b : Bool} : ¬b = true → b = false := Eq.mp (eq_false_eq_not_eq_true b) #align eq_ff_of_not_eq_tt Bool.eq_false_of_not_eq_true theorem eq_true_of_not_eq_false {b : Bool} : ¬b = false → b = true := Eq.mp (eq_true_eq_not_eq_false b) #align eq_tt_of_not_eq_ff Bool.eq_true_of_not_eq_false theorem and_eq_true_eq_eq_true_and_eq_true (a b : Bool) : ((a && b) = true) = (a = true ∧ b = true) := by simp #align band_eq_true_eq_eq_tt_and_eq_tt Bool.and_eq_true_eq_eq_true_and_eq_true theorem or_eq_true_eq_eq_true_or_eq_true (a b : Bool) : ((a || b) = true) = (a = true ∨ b = true) := by simp #align bor_eq_true_eq_eq_tt_or_eq_tt Bool.or_eq_true_eq_eq_true_or_eq_true theorem not_eq_true_eq_eq_false (a : Bool) : (not a = true) = (a = false) := by cases a <;> simp #align bnot_eq_true_eq_eq_ff Bool.not_eq_true_eq_eq_false #adaptation_note /-- this is no longer a simp lemma, as after nightly-2024-03-05 the LHS simplifies. -/
Mathlib/Init/Data/Bool/Lemmas.lean
81
83
theorem and_eq_false_eq_eq_false_or_eq_false (a b : Bool) : ((a && b) = false) = (a = false ∨ b = false) := by
cases a <;> cases b <;> simp
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex #align_import analysis.special_functions.trigonometric.arctan from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # The `arctan` function. Inequalities, identities and `Real.tan` as a `PartialHomeomorph` between `(-(π / 2), π / 2)` and the whole line. The result of `arctan x + arctan y` is given by `arctan_add`, `arctan_add_eq_add_pi` or `arctan_add_eq_sub_pi` depending on whether `x * y < 1` and `0 < x`. As an application of `arctan_add` we give four Machin-like formulas (linear combinations of arctangents equal to `π / 4 = arctan 1`), including John Machin's original one at `four_mul_arctan_inv_5_sub_arctan_inv_239`. -/ noncomputable section namespace Real open Set Filter open scoped Topology Real theorem tan_add {x y : ℝ} (h : ((∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) ∨ (∃ k : ℤ, x = (2 * k + 1) * π / 2) ∧ ∃ l : ℤ, y = (2 * l + 1) * π / 2) : tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := by simpa only [← Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div, Complex.ofReal_mul, Complex.ofReal_tan] using @Complex.tan_add (x : ℂ) (y : ℂ) (by convert h <;> norm_cast) #align real.tan_add Real.tan_add theorem tan_add' {x y : ℝ} (h : (∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) : tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := tan_add (Or.inl h) #align real.tan_add' Real.tan_add'
Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean
47
49
theorem tan_two_mul {x : ℝ} : tan (2 * x) = 2 * tan x / (1 - tan x ^ 2) := by
have := @Complex.tan_two_mul x norm_cast at *
/- Copyright (c) 2022 Violeta Hernández Palacios. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Violeta Hernández Palacios -/ import Mathlib.Order.SuccPred.Basic import Mathlib.Order.BoundedOrder #align_import order.succ_pred.limit from "leanprover-community/mathlib"@"1e05171a5e8cf18d98d9cf7b207540acb044acae" /-! # Successor and predecessor limits We define the predicate `Order.IsSuccLimit` for "successor limits", values that don't cover any others. They are so named since they can't be the successors of anything smaller. We define `Order.IsPredLimit` analogously, and prove basic results. ## Todo The plan is to eventually replace `Ordinal.IsLimit` and `Cardinal.IsLimit` with the common predicate `Order.IsSuccLimit`. -/ variable {α : Type*} namespace Order open Function Set OrderDual /-! ### Successor limits -/ section LT variable [LT α] /-- A successor limit is a value that doesn't cover any other. It's so named because in a successor order, a successor limit can't be the successor of anything smaller. -/ def IsSuccLimit (a : α) : Prop := ∀ b, ¬b ⋖ a #align order.is_succ_limit Order.IsSuccLimit theorem not_isSuccLimit_iff_exists_covBy (a : α) : ¬IsSuccLimit a ↔ ∃ b, b ⋖ a := by simp [IsSuccLimit] #align order.not_is_succ_limit_iff_exists_covby Order.not_isSuccLimit_iff_exists_covBy @[simp] theorem isSuccLimit_of_dense [DenselyOrdered α] (a : α) : IsSuccLimit a := fun _ => not_covBy #align order.is_succ_limit_of_dense Order.isSuccLimit_of_dense end LT section Preorder variable [Preorder α] {a : α} protected theorem _root_.IsMin.isSuccLimit : IsMin a → IsSuccLimit a := fun h _ hab => not_isMin_of_lt hab.lt h #align is_min.is_succ_limit IsMin.isSuccLimit theorem isSuccLimit_bot [OrderBot α] : IsSuccLimit (⊥ : α) := IsMin.isSuccLimit isMin_bot #align order.is_succ_limit_bot Order.isSuccLimit_bot variable [SuccOrder α] protected theorem IsSuccLimit.isMax (h : IsSuccLimit (succ a)) : IsMax a := by by_contra H exact h a (covBy_succ_of_not_isMax H) #align order.is_succ_limit.is_max Order.IsSuccLimit.isMax
Mathlib/Order/SuccPred/Limit.lean
75
77
theorem not_isSuccLimit_succ_of_not_isMax (ha : ¬IsMax a) : ¬IsSuccLimit (succ a) := by
contrapose! ha exact ha.isMax
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov -/ import Mathlib.LinearAlgebra.Quotient #align_import linear_algebra.isomorphisms from "leanprover-community/mathlib"@"2738d2ca56cbc63be80c3bd48e9ed90ad94e947d" /-! # Isomorphism theorems for modules. * The Noether's first, second, and third isomorphism theorems for modules are proved as `LinearMap.quotKerEquivRange`, `LinearMap.quotientInfEquivSupQuotient` and `Submodule.quotientQuotientEquivQuotient`. -/ universe u v variable {R M M₂ M₃ : Type*} variable [Ring R] [AddCommGroup M] [AddCommGroup M₂] [AddCommGroup M₃] variable [Module R M] [Module R M₂] [Module R M₃] variable (f : M →ₗ[R] M₂) /-! The first and second isomorphism theorems for modules. -/ namespace LinearMap open Submodule section IsomorphismLaws /-- The **first isomorphism law for modules**. The quotient of `M` by the kernel of `f` is linearly equivalent to the range of `f`. -/ noncomputable def quotKerEquivRange : (M ⧸ LinearMap.ker f) ≃ₗ[R] LinearMap.range f := (LinearEquiv.ofInjective (f.ker.liftQ f <| le_rfl) <| ker_eq_bot.mp <| Submodule.ker_liftQ_eq_bot _ _ _ (le_refl (LinearMap.ker f))).trans (LinearEquiv.ofEq _ _ <| Submodule.range_liftQ _ _ _) #align linear_map.quot_ker_equiv_range LinearMap.quotKerEquivRange /-- The **first isomorphism theorem for surjective linear maps**. -/ noncomputable def quotKerEquivOfSurjective (f : M →ₗ[R] M₂) (hf : Function.Surjective f) : (M ⧸ LinearMap.ker f) ≃ₗ[R] M₂ := f.quotKerEquivRange.trans (LinearEquiv.ofTop (LinearMap.range f) (LinearMap.range_eq_top.2 hf)) #align linear_map.quot_ker_equiv_of_surjective LinearMap.quotKerEquivOfSurjective @[simp] theorem quotKerEquivRange_apply_mk (x : M) : (f.quotKerEquivRange (Submodule.Quotient.mk x) : M₂) = f x := rfl #align linear_map.quot_ker_equiv_range_apply_mk LinearMap.quotKerEquivRange_apply_mk @[simp] theorem quotKerEquivRange_symm_apply_image (x : M) (h : f x ∈ LinearMap.range f) : f.quotKerEquivRange.symm ⟨f x, h⟩ = f.ker.mkQ x := f.quotKerEquivRange.symm_apply_apply (f.ker.mkQ x) #align linear_map.quot_ker_equiv_range_symm_apply_image LinearMap.quotKerEquivRange_symm_apply_image -- Porting note: breaking up original definition of quotientInfToSupQuotient to avoid timing out /-- Linear map from `p` to `p+p'/p'` where `p p'` are submodules of `R` -/ abbrev subToSupQuotient (p p' : Submodule R M) : { x // x ∈ p } →ₗ[R] { x // x ∈ p ⊔ p' } ⧸ comap (Submodule.subtype (p ⊔ p')) p' := (comap (p ⊔ p').subtype p').mkQ.comp (Submodule.inclusion le_sup_left) -- Porting note: breaking up original definition of quotientInfToSupQuotient to avoid timing out theorem comap_leq_ker_subToSupQuotient (p p' : Submodule R M) : comap (Submodule.subtype p) (p ⊓ p') ≤ ker (subToSupQuotient p p') := by rw [LinearMap.ker_comp, Submodule.inclusion, comap_codRestrict, ker_mkQ, map_comap_subtype] exact comap_mono (inf_le_inf_right _ le_sup_left) /-- Canonical linear map from the quotient `p/(p ∩ p')` to `(p+p')/p'`, mapping `x + (p ∩ p')` to `x + p'`, where `p` and `p'` are submodules of an ambient module. -/ def quotientInfToSupQuotient (p p' : Submodule R M) : (↥p) ⧸ (comap p.subtype (p ⊓ p')) →ₗ[R] (↥(p ⊔ p')) ⧸ (comap (p ⊔ p').subtype p') := (comap p.subtype (p ⊓ p')).liftQ (subToSupQuotient p p') (comap_leq_ker_subToSupQuotient p p') #align linear_map.quotient_inf_to_sup_quotient LinearMap.quotientInfToSupQuotient -- Porting note: breaking up original definition of quotientInfEquivSupQuotient to avoid timing out
Mathlib/LinearAlgebra/Isomorphisms.lean
81
85
theorem quotientInfEquivSupQuotient_injective (p p' : Submodule R M) : Function.Injective (quotientInfToSupQuotient p p') := by
rw [← ker_eq_bot, quotientInfToSupQuotient, ker_liftQ_eq_bot] rw [ker_comp, ker_mkQ] exact fun ⟨x, hx1⟩ hx2 => ⟨hx1, hx2⟩
/- 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.SetTheory.Cardinal.Basic import Mathlib.Topology.MetricSpace.Closeds import Mathlib.Topology.MetricSpace.Completion import Mathlib.Topology.MetricSpace.GromovHausdorffRealized import Mathlib.Topology.MetricSpace.Kuratowski #align_import topology.metric_space.gromov_hausdorff from "leanprover-community/mathlib"@"0c1f285a9f6e608ae2bdffa3f993eafb01eba829" /-! # Gromov-Hausdorff distance This file defines the Gromov-Hausdorff distance on the space of nonempty compact metric spaces up to isometry. We introduce the space of all nonempty compact metric spaces, up to isometry, called `GHSpace`, and endow it with a metric space structure. The distance, known as the Gromov-Hausdorff distance, is defined as follows: given two nonempty compact spaces `X` and `Y`, their distance is the minimum Hausdorff distance between all possible isometric embeddings of `X` and `Y` in all metric spaces. To define properly the Gromov-Hausdorff space, we consider the non-empty compact subsets of `ℓ^∞(ℝ)` up to isometry, which is a well-defined type, and define the distance as the infimum of the Hausdorff distance over all embeddings in `ℓ^∞(ℝ)`. We prove that this coincides with the previous description, as all separable metric spaces embed isometrically into `ℓ^∞(ℝ)`, through an embedding called the Kuratowski embedding. To prove that we have a distance, we should show that if spaces can be coupled to be arbitrarily close, then they are isometric. More generally, the Gromov-Hausdorff distance is realized, i.e., there is a coupling for which the Hausdorff distance is exactly the Gromov-Hausdorff distance. This follows from a compactness argument, essentially following from Arzela-Ascoli. ## Main results We prove the most important properties of the Gromov-Hausdorff space: it is a polish space, i.e., it is complete and second countable. We also prove the Gromov compactness criterion. -/ noncomputable section open scoped Classical Topology ENNReal Cardinal set_option linter.uppercaseLean3 false local notation "ℓ_infty_ℝ" => lp (fun n : ℕ => ℝ) ∞ universe u v w open scoped Classical open Set Function TopologicalSpace Filter Metric Quotient Bornology open BoundedContinuousFunction Nat Int kuratowskiEmbedding open Sum (inl inr) attribute [local instance] metricSpaceSum namespace GromovHausdorff /-! In this section, we define the Gromov-Hausdorff space, denoted `GHSpace` as the quotient of nonempty compact subsets of `ℓ^∞(ℝ)` by identifying isometric sets. Using the Kuratwoski embedding, we get a canonical map `toGHSpace` mapping any nonempty compact type to `GHSpace`. -/ section GHSpace /-- Equivalence relation identifying two nonempty compact sets which are isometric -/ private def IsometryRel (x : NonemptyCompacts ℓ_infty_ℝ) (y : NonemptyCompacts ℓ_infty_ℝ) : Prop := Nonempty (x ≃ᵢ y) /-- This is indeed an equivalence relation -/ private theorem equivalence_isometryRel : Equivalence IsometryRel := ⟨fun _ => Nonempty.intro (IsometryEquiv.refl _), fun ⟨e⟩ => ⟨e.symm⟩, fun ⟨e⟩ ⟨f⟩ => ⟨e.trans f⟩⟩ /-- setoid instance identifying two isometric nonempty compact subspaces of ℓ^∞(ℝ) -/ instance IsometryRel.setoid : Setoid (NonemptyCompacts ℓ_infty_ℝ) := Setoid.mk IsometryRel equivalence_isometryRel #align Gromov_Hausdorff.isometry_rel.setoid GromovHausdorff.IsometryRel.setoid /-- The Gromov-Hausdorff space -/ def GHSpace : Type := Quotient IsometryRel.setoid #align Gromov_Hausdorff.GH_space GromovHausdorff.GHSpace /-- Map any nonempty compact type to `GHSpace` -/ def toGHSpace (X : Type u) [MetricSpace X] [CompactSpace X] [Nonempty X] : GHSpace := ⟦NonemptyCompacts.kuratowskiEmbedding X⟧ #align Gromov_Hausdorff.to_GH_space GromovHausdorff.toGHSpace instance : Inhabited GHSpace := ⟨Quot.mk _ ⟨⟨{0}, isCompact_singleton⟩, singleton_nonempty _⟩⟩ /-- A metric space representative of any abstract point in `GHSpace` -/ -- Porting note(#5171): linter not yet ported; removed @[nolint has_nonempty_instance]; why? def GHSpace.Rep (p : GHSpace) : Type := (Quotient.out p : NonemptyCompacts ℓ_infty_ℝ) #align Gromov_Hausdorff.GH_space.rep GromovHausdorff.GHSpace.Rep
Mathlib/Topology/MetricSpace/GromovHausdorff.lean
103
119
theorem eq_toGHSpace_iff {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X] {p : NonemptyCompacts ℓ_infty_ℝ} : ⟦p⟧ = toGHSpace X ↔ ∃ Ψ : X → ℓ_infty_ℝ, Isometry Ψ ∧ range Ψ = p := by
simp only [toGHSpace, Quotient.eq] refine ⟨fun h => ?_, ?_⟩ · rcases Setoid.symm h with ⟨e⟩ have f := (kuratowskiEmbedding.isometry X).isometryEquivOnRange.trans e use fun x => f x, isometry_subtype_coe.comp f.isometry erw [range_comp, f.range_eq_univ, Set.image_univ, Subtype.range_coe] · rintro ⟨Ψ, ⟨isomΨ, rangeΨ⟩⟩ have f := ((kuratowskiEmbedding.isometry X).isometryEquivOnRange.symm.trans isomΨ.isometryEquivOnRange).symm have E : (range Ψ ≃ᵢ NonemptyCompacts.kuratowskiEmbedding X) = (p ≃ᵢ range (kuratowskiEmbedding X)) := by dsimp only [NonemptyCompacts.kuratowskiEmbedding]; rw [rangeΨ]; rfl exact ⟨cast E f⟩
/- 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.Antichain import Mathlib.Order.UpperLower.Basic import Mathlib.Order.Interval.Set.Basic import Mathlib.Order.RelIso.Set #align_import order.minimal from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Minimal/maximal elements of a set This file defines minimal and maximal of a set with respect to an arbitrary relation. ## Main declarations * `maximals r s`: Maximal elements of `s` with respect to `r`. * `minimals r s`: Minimal elements of `s` with respect to `r`. ## TODO Do we need a `Finset` version? -/ open Function Set variable {α : Type*} (r r₁ r₂ : α → α → Prop) (s t : Set α) (a b : α) /-- Turns a set into an antichain by keeping only the "maximal" elements. -/ def maximals : Set α := { a ∈ s | ∀ ⦃b⦄, b ∈ s → r a b → r b a } #align maximals maximals /-- Turns a set into an antichain by keeping only the "minimal" elements. -/ def minimals : Set α := { a ∈ s | ∀ ⦃b⦄, b ∈ s → r b a → r a b } #align minimals minimals theorem maximals_subset : maximals r s ⊆ s := sep_subset _ _ #align maximals_subset maximals_subset theorem minimals_subset : minimals r s ⊆ s := sep_subset _ _ #align minimals_subset minimals_subset @[simp] theorem maximals_empty : maximals r ∅ = ∅ := sep_empty _ #align maximals_empty maximals_empty @[simp] theorem minimals_empty : minimals r ∅ = ∅ := sep_empty _ #align minimals_empty minimals_empty @[simp] theorem maximals_singleton : maximals r {a} = {a} := (maximals_subset _ _).antisymm <| singleton_subset_iff.2 <| ⟨rfl, by rintro b (rfl : b = a) exact id⟩ #align maximals_singleton maximals_singleton @[simp] theorem minimals_singleton : minimals r {a} = {a} := maximals_singleton _ _ #align minimals_singleton minimals_singleton theorem maximals_swap : maximals (swap r) s = minimals r s := rfl #align maximals_swap maximals_swap theorem minimals_swap : minimals (swap r) s = maximals r s := rfl #align minimals_swap minimals_swap section IsAntisymm variable {r s t a b} [IsAntisymm α r] theorem eq_of_mem_maximals (ha : a ∈ maximals r s) (hb : b ∈ s) (h : r a b) : a = b := antisymm h <| ha.2 hb h #align eq_of_mem_maximals eq_of_mem_maximals theorem eq_of_mem_minimals (ha : a ∈ minimals r s) (hb : b ∈ s) (h : r b a) : a = b := antisymm (ha.2 hb h) h #align eq_of_mem_minimals eq_of_mem_minimals set_option autoImplicit true theorem mem_maximals_iff : x ∈ maximals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, y ∈ s → r x y → x = y := by simp only [maximals, Set.mem_sep_iff, and_congr_right_iff] refine fun _ ↦ ⟨fun h y hys hxy ↦ antisymm hxy (h hys hxy), fun h y hys hxy ↦ ?_⟩ convert hxy <;> rw [h hys hxy] theorem mem_maximals_setOf_iff : x ∈ maximals r (setOf P) ↔ P x ∧ ∀ ⦃y⦄, P y → r x y → x = y := mem_maximals_iff theorem mem_minimals_iff : x ∈ minimals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, y ∈ s → r y x → x = y := @mem_maximals_iff _ _ _ (IsAntisymm.swap r) _ theorem mem_minimals_setOf_iff : x ∈ minimals r (setOf P) ↔ P x ∧ ∀ ⦃y⦄, P y → r y x → x = y := mem_minimals_iff /-- This theorem can't be used to rewrite without specifying `rlt`, since `rlt` would have to be guessed. See `mem_minimals_iff_forall_ssubset_not_mem` and `mem_minimals_iff_forall_lt_not_mem` for `⊆` and `≤` versions. -/ theorem mem_minimals_iff_forall_lt_not_mem' (rlt : α → α → Prop) [IsNonstrictStrictOrder α r rlt] : x ∈ minimals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, rlt y x → y ∉ s := by simp [minimals, right_iff_left_not_left_of r rlt, not_imp_not, imp.swap (a := _ ∈ _)] theorem mem_maximals_iff_forall_lt_not_mem' (rlt : α → α → Prop) [IsNonstrictStrictOrder α r rlt] : x ∈ maximals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, rlt x y → y ∉ s := by simp [maximals, right_iff_left_not_left_of r rlt, not_imp_not, imp.swap (a := _ ∈ _)]
Mathlib/Order/Minimal.lean
121
128
theorem minimals_eq_minimals_of_subset_of_forall [IsTrans α r] (hts : t ⊆ s) (h : ∀ x ∈ s, ∃ y ∈ t, r y x) : minimals r s = minimals r t := by
refine Set.ext fun a ↦ ⟨fun ⟨has, hmin⟩ ↦ ⟨?_,fun b hbt ↦ hmin (hts hbt)⟩, fun ⟨hat, hmin⟩ ↦ ⟨hts hat, fun b hbs hba ↦ ?_⟩⟩ · obtain ⟨a', ha', haa'⟩ := h _ has rwa [antisymm (hmin (hts ha') haa') haa'] obtain ⟨b', hb't, hb'b⟩ := h b hbs rwa [antisymm (hmin hb't (Trans.trans hb'b hba)) (Trans.trans hb'b hba)]
/- 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.NatAntidiagonal import Mathlib.Topology.Algebra.InfiniteSum.Constructions import Mathlib.Topology.Algebra.Ring.Basic #align_import topology.algebra.infinite_sum.ring from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd" /-! # Infinite sum in a ring This file provides lemmas about the interaction between infinite sums and multiplication. ## Main results * `tsum_mul_tsum_eq_tsum_sum_antidiagonal`: Cauchy product formula -/ open Filter Finset Function open scoped Classical variable {ι κ R α : Type*} section NonUnitalNonAssocSemiring variable [NonUnitalNonAssocSemiring α] [TopologicalSpace α] [TopologicalSemiring α] {f g : ι → α} {a a₁ a₂ : α} theorem HasSum.mul_left (a₂) (h : HasSum f a₁) : HasSum (fun i ↦ a₂ * f i) (a₂ * a₁) := by simpa only using h.map (AddMonoidHom.mulLeft a₂) (continuous_const.mul continuous_id) #align has_sum.mul_left HasSum.mul_left theorem HasSum.mul_right (a₂) (hf : HasSum f a₁) : HasSum (fun i ↦ f i * a₂) (a₁ * a₂) := by simpa only using hf.map (AddMonoidHom.mulRight a₂) (continuous_id.mul continuous_const) #align has_sum.mul_right HasSum.mul_right theorem Summable.mul_left (a) (hf : Summable f) : Summable fun i ↦ a * f i := (hf.hasSum.mul_left _).summable #align summable.mul_left Summable.mul_left theorem Summable.mul_right (a) (hf : Summable f) : Summable fun i ↦ f i * a := (hf.hasSum.mul_right _).summable #align summable.mul_right Summable.mul_right section tsum variable [T2Space α] theorem Summable.tsum_mul_left (a) (hf : Summable f) : ∑' i, a * f i = a * ∑' i, f i := (hf.hasSum.mul_left _).tsum_eq #align summable.tsum_mul_left Summable.tsum_mul_left theorem Summable.tsum_mul_right (a) (hf : Summable f) : ∑' i, f i * a = (∑' i, f i) * a := (hf.hasSum.mul_right _).tsum_eq #align summable.tsum_mul_right Summable.tsum_mul_right theorem Commute.tsum_right (a) (h : ∀ i, Commute a (f i)) : Commute a (∑' i, f i) := if hf : Summable f then (hf.tsum_mul_left a).symm.trans ((congr_arg _ <| funext h).trans (hf.tsum_mul_right a)) else (tsum_eq_zero_of_not_summable hf).symm ▸ Commute.zero_right _ #align commute.tsum_right Commute.tsum_right theorem Commute.tsum_left (a) (h : ∀ i, Commute (f i) a) : Commute (∑' i, f i) a := (Commute.tsum_right _ fun i ↦ (h i).symm).symm #align commute.tsum_left Commute.tsum_left end tsum end NonUnitalNonAssocSemiring section DivisionSemiring variable [DivisionSemiring α] [TopologicalSpace α] [TopologicalSemiring α] {f g : ι → α} {a a₁ a₂ : α} theorem HasSum.div_const (h : HasSum f a) (b : α) : HasSum (fun i ↦ f i / b) (a / b) := by simp only [div_eq_mul_inv, h.mul_right b⁻¹] #align has_sum.div_const HasSum.div_const theorem Summable.div_const (h : Summable f) (b : α) : Summable fun i ↦ f i / b := (h.hasSum.div_const _).summable #align summable.div_const Summable.div_const theorem hasSum_mul_left_iff (h : a₂ ≠ 0) : HasSum (fun i ↦ a₂ * f i) (a₂ * a₁) ↔ HasSum f a₁ := ⟨fun H ↦ by simpa only [inv_mul_cancel_left₀ h] using H.mul_left a₂⁻¹, HasSum.mul_left _⟩ #align has_sum_mul_left_iff hasSum_mul_left_iff theorem hasSum_mul_right_iff (h : a₂ ≠ 0) : HasSum (fun i ↦ f i * a₂) (a₁ * a₂) ↔ HasSum f a₁ := ⟨fun H ↦ by simpa only [mul_inv_cancel_right₀ h] using H.mul_right a₂⁻¹, HasSum.mul_right _⟩ #align has_sum_mul_right_iff hasSum_mul_right_iff
Mathlib/Topology/Algebra/InfiniteSum/Ring.lean
97
98
theorem hasSum_div_const_iff (h : a₂ ≠ 0) : HasSum (fun i ↦ f i / a₂) (a₁ / a₂) ↔ HasSum f a₁ := by
simpa only [div_eq_mul_inv] using hasSum_mul_right_iff (inv_ne_zero h)
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Robert Y. Lewis -/ import Mathlib.RingTheory.WittVector.InitTail #align_import ring_theory.witt_vector.truncated from "leanprover-community/mathlib"@"acbe099ced8be9c9754d62860110295cde0d7181" /-! # Truncated Witt vectors The ring of truncated Witt vectors (of length `n`) is a quotient of the ring of Witt vectors. It retains the first `n` coefficients of each Witt vector. In this file, we set up the basic quotient API for this ring. The ring of Witt vectors is the projective limit of all the rings of truncated Witt vectors. ## Main declarations - `TruncatedWittVector`: the underlying type of the ring of truncated Witt vectors - `TruncatedWittVector.instCommRing`: the ring structure on truncated Witt vectors - `WittVector.truncate`: the quotient homomorphism that truncates a Witt vector, to obtain a truncated Witt vector - `TruncatedWittVector.truncate`: the homomorphism that truncates a truncated Witt vector of length `n` to one of length `m` (for some `m ≤ n`) - `WittVector.lift`: the unique ring homomorphism into the ring of Witt vectors that is compatible with a family of ring homomorphisms to the truncated Witt vectors: this realizes the ring of Witt vectors as projective limit of the rings of truncated Witt vectors ## References * [Hazewinkel, *Witt Vectors*][Haze09] * [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21] -/ open Function (Injective Surjective) noncomputable section variable {p : ℕ} [hp : Fact p.Prime] (n : ℕ) (R : Type*) local notation "𝕎" => WittVector p -- type as `\bbW` /-- A truncated Witt vector over `R` is a vector of elements of `R`, i.e., the first `n` coefficients of a Witt vector. We will define operations on this type that are compatible with the (untruncated) Witt vector operations. `TruncatedWittVector p n R` takes a parameter `p : ℕ` that is not used in the definition. In practice, this number `p` is assumed to be a prime number, and under this assumption we construct a ring structure on `TruncatedWittVector p n R`. (`TruncatedWittVector p₁ n R` and `TruncatedWittVector p₂ n R` are definitionally equal as types but will have different ring operations.) -/ @[nolint unusedArguments] def TruncatedWittVector (_ : ℕ) (n : ℕ) (R : Type*) := Fin n → R #align truncated_witt_vector TruncatedWittVector instance (p n : ℕ) (R : Type*) [Inhabited R] : Inhabited (TruncatedWittVector p n R) := ⟨fun _ => default⟩ variable {n R} namespace TruncatedWittVector variable (p) /-- Create a `TruncatedWittVector` from a vector `x`. -/ def mk (x : Fin n → R) : TruncatedWittVector p n R := x #align truncated_witt_vector.mk TruncatedWittVector.mk variable {p} /-- `x.coeff i` is the `i`th entry of `x`. -/ def coeff (i : Fin n) (x : TruncatedWittVector p n R) : R := x i #align truncated_witt_vector.coeff TruncatedWittVector.coeff @[ext] theorem ext {x y : TruncatedWittVector p n R} (h : ∀ i, x.coeff i = y.coeff i) : x = y := funext h #align truncated_witt_vector.ext TruncatedWittVector.ext theorem ext_iff {x y : TruncatedWittVector p n R} : x = y ↔ ∀ i, x.coeff i = y.coeff i := ⟨fun h i => by rw [h], ext⟩ #align truncated_witt_vector.ext_iff TruncatedWittVector.ext_iff @[simp] theorem coeff_mk (x : Fin n → R) (i : Fin n) : (mk p x).coeff i = x i := rfl #align truncated_witt_vector.coeff_mk TruncatedWittVector.coeff_mk @[simp] theorem mk_coeff (x : TruncatedWittVector p n R) : (mk p fun i => x.coeff i) = x := by ext i; rw [coeff_mk] #align truncated_witt_vector.mk_coeff TruncatedWittVector.mk_coeff variable [CommRing R] /-- We can turn a truncated Witt vector `x` into a Witt vector by setting all coefficients after `x` to be 0. -/ def out (x : TruncatedWittVector p n R) : 𝕎 R := @WittVector.mk' p _ fun i => if h : i < n then x.coeff ⟨i, h⟩ else 0 #align truncated_witt_vector.out TruncatedWittVector.out @[simp] theorem coeff_out (x : TruncatedWittVector p n R) (i : Fin n) : x.out.coeff i = x.coeff i := by rw [out]; dsimp only; rw [dif_pos i.is_lt, Fin.eta] #align truncated_witt_vector.coeff_out TruncatedWittVector.coeff_out theorem out_injective : Injective (@out p n R _) := by intro x y h ext i rw [WittVector.ext_iff] at h simpa only [coeff_out] using h ↑i #align truncated_witt_vector.out_injective TruncatedWittVector.out_injective end TruncatedWittVector namespace WittVector variable (n) section /-- `truncateFun n x` uses the first `n` entries of `x` to construct a `TruncatedWittVector`, which has the same base `p` as `x`. This function is bundled into a ring homomorphism in `WittVector.truncate` -/ def truncateFun (x : 𝕎 R) : TruncatedWittVector p n R := TruncatedWittVector.mk p fun i => x.coeff i #align witt_vector.truncate_fun WittVector.truncateFun end variable {n} @[simp] theorem coeff_truncateFun (x : 𝕎 R) (i : Fin n) : (truncateFun n x).coeff i = x.coeff i := by rw [truncateFun, TruncatedWittVector.coeff_mk] #align witt_vector.coeff_truncate_fun WittVector.coeff_truncateFun variable [CommRing R] @[simp]
Mathlib/RingTheory/WittVector/Truncated.lean
152
156
theorem out_truncateFun (x : 𝕎 R) : (truncateFun n x).out = init n x := by
ext i dsimp [TruncatedWittVector.out, init, select, coeff_mk] split_ifs with hi; swap; · rfl rw [coeff_truncateFun, Fin.val_mk]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.RCLike.Lemmas import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex #align_import measure_theory.function.special_functions.is_R_or_C from "leanprover-community/mathlib"@"83a66c8775fa14ee5180c85cab98e970956401ad" /-! # Measurability of the basic `RCLike` functions -/ noncomputable section open NNReal ENNReal namespace RCLike variable {𝕜 : Type*} [RCLike 𝕜] @[measurability] theorem measurable_re : Measurable (re : 𝕜 → ℝ) := continuous_re.measurable #align is_R_or_C.measurable_re RCLike.measurable_re @[measurability] theorem measurable_im : Measurable (im : 𝕜 → ℝ) := continuous_im.measurable #align is_R_or_C.measurable_im RCLike.measurable_im end RCLike section RCLikeComposition variable {α 𝕜 : Type*} [RCLike 𝕜] {m : MeasurableSpace α} {f : α → 𝕜} {μ : MeasureTheory.Measure α} @[measurability] theorem Measurable.re (hf : Measurable f) : Measurable fun x => RCLike.re (f x) := RCLike.measurable_re.comp hf #align measurable.re Measurable.re @[measurability] theorem AEMeasurable.re (hf : AEMeasurable f μ) : AEMeasurable (fun x => RCLike.re (f x)) μ := RCLike.measurable_re.comp_aemeasurable hf #align ae_measurable.re AEMeasurable.re @[measurability] theorem Measurable.im (hf : Measurable f) : Measurable fun x => RCLike.im (f x) := RCLike.measurable_im.comp hf #align measurable.im Measurable.im @[measurability] theorem AEMeasurable.im (hf : AEMeasurable f μ) : AEMeasurable (fun x => RCLike.im (f x)) μ := RCLike.measurable_im.comp_aemeasurable hf #align ae_measurable.im AEMeasurable.im end RCLikeComposition section variable {α 𝕜 : Type*} [RCLike 𝕜] [MeasurableSpace α] {f : α → 𝕜} {μ : MeasureTheory.Measure α} @[measurability] theorem RCLike.measurable_ofReal : Measurable ((↑) : ℝ → 𝕜) := RCLike.continuous_ofReal.measurable #align is_R_or_C.measurable_of_real RCLike.measurable_ofReal theorem measurable_of_re_im (hre : Measurable fun x => RCLike.re (f x)) (him : Measurable fun x => RCLike.im (f x)) : Measurable f := by convert Measurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp hre) ((RCLike.measurable_ofReal.comp him).mul_const RCLike.I) exact (RCLike.re_add_im _).symm #align measurable_of_re_im measurable_of_re_im
Mathlib/MeasureTheory/Function/SpecialFunctions/RCLike.lean
80
84
theorem aemeasurable_of_re_im (hre : AEMeasurable (fun x => RCLike.re (f x)) μ) (him : AEMeasurable (fun x => RCLike.im (f x)) μ) : AEMeasurable f μ := by
convert AEMeasurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp_aemeasurable hre) ((RCLike.measurable_ofReal.comp_aemeasurable him).mul_const RCLike.I) exact (RCLike.re_add_im _).symm
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang -/ import Mathlib.RingTheory.GradedAlgebra.Basic import Mathlib.Algebra.GradedMulAction import Mathlib.Algebra.DirectSum.Decomposition import Mathlib.Algebra.Module.BigOperators #align_import algebra.module.graded_module from "leanprover-community/mathlib"@"59cdeb0da2480abbc235b7e611ccd9a7e5603d7c" /-! # Graded Module Given an `R`-algebra `A` graded by `𝓐`, a graded `A`-module `M` is expressed as `DirectSum.Decomposition 𝓜` and `SetLike.GradedSMul 𝓐 𝓜`. Then `⨁ i, 𝓜 i` is an `A`-module and is isomorphic to `M`. ## Tags graded module -/ section open DirectSum variable {ιA ιB : Type*} (A : ιA → Type*) (M : ιB → Type*) namespace DirectSum open GradedMonoid /-- A graded version of `DistribMulAction`. -/ class GdistribMulAction [AddMonoid ιA] [VAdd ιA ιB] [GMonoid A] [∀ i, AddMonoid (M i)] extends GMulAction A M where smul_add {i j} (a : A i) (b c : M j) : smul a (b + c) = smul a b + smul a c smul_zero {i j} (a : A i) : smul a (0 : M j) = 0 #align direct_sum.gdistrib_mul_action DirectSum.GdistribMulAction /-- A graded version of `Module`. -/ class Gmodule [AddMonoid ιA] [VAdd ιA ιB] [∀ i, AddMonoid (A i)] [∀ i, AddMonoid (M i)] [GMonoid A] extends GdistribMulAction A M where add_smul {i j} (a a' : A i) (b : M j) : smul (a + a') b = smul a b + smul a' b zero_smul {i j} (b : M j) : smul (0 : A i) b = 0 #align direct_sum.gmodule DirectSum.Gmodule /-- A graded version of `Semiring.toModule`. -/ instance GSemiring.toGmodule [AddMonoid ιA] [∀ i : ιA, AddCommMonoid (A i)] [h : GSemiring A] : Gmodule A A := { GMonoid.toGMulAction A with smul_add := fun _ _ _ => h.mul_add _ _ _ smul_zero := fun _ => h.mul_zero _ add_smul := fun _ _ => h.add_mul _ _ zero_smul := fun _ => h.zero_mul _ } #align direct_sum.gsemiring.to_gmodule DirectSum.GSemiring.toGmodule variable [AddMonoid ιA] [VAdd ιA ιB] [∀ i : ιA, AddCommMonoid (A i)] [∀ i, AddCommMonoid (M i)] /-- The piecewise multiplication from the `Mul` instance, as a bundled homomorphism. -/ @[simps] def gsmulHom [GMonoid A] [Gmodule A M] {i j} : A i →+ M j →+ M (i +ᵥ j) where toFun a := { toFun := fun b => GSMul.smul a b map_zero' := GdistribMulAction.smul_zero _ map_add' := GdistribMulAction.smul_add _ } map_zero' := AddMonoidHom.ext fun a => Gmodule.zero_smul a map_add' _a₁ _a₂ := AddMonoidHom.ext fun _b => Gmodule.add_smul _ _ _ #align direct_sum.gsmul_hom DirectSum.gsmulHom namespace Gmodule /-- For graded monoid `A` and a graded module `M` over `A`. `Gmodule.smulAddMonoidHom` is the `⨁ᵢ Aᵢ`-scalar multiplication on `⨁ᵢ Mᵢ` induced by `gsmul_hom`. -/ def smulAddMonoidHom [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] : (⨁ i, A i) →+ (⨁ i, M i) →+ ⨁ i, M i := toAddMonoid fun _i => AddMonoidHom.flip <| toAddMonoid fun _j => AddMonoidHom.flip <| (of M _).compHom.comp <| gsmulHom A M #align direct_sum.gmodule.smul_add_monoid_hom DirectSum.Gmodule.smulAddMonoidHom section open GradedMonoid DirectSum Gmodule instance [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] : SMul (⨁ i, A i) (⨁ i, M i) where smul x y := smulAddMonoidHom A M x y @[simp] theorem smul_def [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] (x : ⨁ i, A i) (y : ⨁ i, M i) : x • y = smulAddMonoidHom _ _ x y := rfl #align direct_sum.gmodule.smul_def DirectSum.Gmodule.smul_def @[simp]
Mathlib/Algebra/Module/GradedModule.lean
99
102
theorem smulAddMonoidHom_apply_of_of [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] {i j} (x : A i) (y : M j) : smulAddMonoidHom A M (DirectSum.of A i x) (of M j y) = of M (i +ᵥ j) (GSMul.smul x y) := by
simp [smulAddMonoidHom]
/- Copyright (c) 2021 Bryan Gin-ge Chen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Bryan Gin-ge Chen, Yaël Dillies -/ import Mathlib.Order.BooleanAlgebra import Mathlib.Logic.Equiv.Basic #align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904" /-! # Symmetric difference and bi-implication This file defines the symmetric difference and bi-implication operators in (co-)Heyting algebras. ## Examples Some examples are * The symmetric difference of two sets is the set of elements that are in either but not both. * The symmetric difference on propositions is `Xor'`. * The symmetric difference on `Bool` is `Bool.xor`. * The equivalence of propositions. Two propositions are equivalent if they imply each other. * The symmetric difference translates to addition when considering a Boolean algebra as a Boolean ring. ## Main declarations * `symmDiff`: The symmetric difference operator, defined as `(a \ b) ⊔ (b \ a)` * `bihimp`: The bi-implication operator, defined as `(b ⇨ a) ⊓ (a ⇨ b)` In generalized Boolean algebras, the symmetric difference operator is: * `symmDiff_comm`: commutative, and * `symmDiff_assoc`: associative. ## Notations * `a ∆ b`: `symmDiff a b` * `a ⇔ b`: `bihimp a b` ## References The proof of associativity follows the note "Associativity of the Symmetric Difference of Sets: A Proof from the Book" by John McCuan: * <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf> ## Tags boolean ring, generalized boolean algebra, boolean algebra, symmetric difference, bi-implication, Heyting -/ open Function OrderDual variable {ι α β : Type*} {π : ι → Type*} /-- The symmetric difference operator on a type with `⊔` and `\` is `(A \ B) ⊔ (B \ A)`. -/ def symmDiff [Sup α] [SDiff α] (a b : α) : α := a \ b ⊔ b \ a #align symm_diff symmDiff /-- The Heyting bi-implication is `(b ⇨ a) ⊓ (a ⇨ b)`. This generalizes equivalence of propositions. -/ def bihimp [Inf α] [HImp α] (a b : α) : α := (b ⇨ a) ⊓ (a ⇨ b) #align bihimp bihimp /-- Notation for symmDiff -/ scoped[symmDiff] infixl:100 " ∆ " => symmDiff /-- Notation for bihimp -/ scoped[symmDiff] infixl:100 " ⇔ " => bihimp open scoped symmDiff theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a := rfl #align symm_diff_def symmDiff_def theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) := rfl #align bihimp_def bihimp_def theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q := rfl #align symm_diff_eq_xor symmDiff_eq_Xor' @[simp] theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) := (iff_iff_implies_and_implies _ _).symm.trans Iff.comm #align bihimp_iff_iff bihimp_iff_iff @[simp] theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide #align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor section GeneralizedCoheytingAlgebra variable [GeneralizedCoheytingAlgebra α] (a b c d : α) @[simp] theorem toDual_symmDiff : toDual (a ∆ b) = toDual a ⇔ toDual b := rfl #align to_dual_symm_diff toDual_symmDiff @[simp] theorem ofDual_bihimp (a b : αᵒᵈ) : ofDual (a ⇔ b) = ofDual a ∆ ofDual b := rfl #align of_dual_bihimp ofDual_bihimp theorem symmDiff_comm : a ∆ b = b ∆ a := by simp only [symmDiff, sup_comm] #align symm_diff_comm symmDiff_comm instance symmDiff_isCommutative : Std.Commutative (α := α) (· ∆ ·) := ⟨symmDiff_comm⟩ #align symm_diff_is_comm symmDiff_isCommutative @[simp] theorem symmDiff_self : a ∆ a = ⊥ := by rw [symmDiff, sup_idem, sdiff_self] #align symm_diff_self symmDiff_self @[simp]
Mathlib/Order/SymmDiff.lean
125
125
theorem symmDiff_bot : a ∆ ⊥ = a := by
rw [symmDiff, sdiff_bot, bot_sdiff, sup_bot_eq]
/- Copyright (c) 2021 Bryan Gin-ge Chen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Bryan Gin-ge Chen, Yaël Dillies -/ import Mathlib.Order.BooleanAlgebra import Mathlib.Logic.Equiv.Basic #align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904" /-! # Symmetric difference and bi-implication This file defines the symmetric difference and bi-implication operators in (co-)Heyting algebras. ## Examples Some examples are * The symmetric difference of two sets is the set of elements that are in either but not both. * The symmetric difference on propositions is `Xor'`. * The symmetric difference on `Bool` is `Bool.xor`. * The equivalence of propositions. Two propositions are equivalent if they imply each other. * The symmetric difference translates to addition when considering a Boolean algebra as a Boolean ring. ## Main declarations * `symmDiff`: The symmetric difference operator, defined as `(a \ b) ⊔ (b \ a)` * `bihimp`: The bi-implication operator, defined as `(b ⇨ a) ⊓ (a ⇨ b)` In generalized Boolean algebras, the symmetric difference operator is: * `symmDiff_comm`: commutative, and * `symmDiff_assoc`: associative. ## Notations * `a ∆ b`: `symmDiff a b` * `a ⇔ b`: `bihimp a b` ## References The proof of associativity follows the note "Associativity of the Symmetric Difference of Sets: A Proof from the Book" by John McCuan: * <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf> ## Tags boolean ring, generalized boolean algebra, boolean algebra, symmetric difference, bi-implication, Heyting -/ open Function OrderDual variable {ι α β : Type*} {π : ι → Type*} /-- The symmetric difference operator on a type with `⊔` and `\` is `(A \ B) ⊔ (B \ A)`. -/ def symmDiff [Sup α] [SDiff α] (a b : α) : α := a \ b ⊔ b \ a #align symm_diff symmDiff /-- The Heyting bi-implication is `(b ⇨ a) ⊓ (a ⇨ b)`. This generalizes equivalence of propositions. -/ def bihimp [Inf α] [HImp α] (a b : α) : α := (b ⇨ a) ⊓ (a ⇨ b) #align bihimp bihimp /-- Notation for symmDiff -/ scoped[symmDiff] infixl:100 " ∆ " => symmDiff /-- Notation for bihimp -/ scoped[symmDiff] infixl:100 " ⇔ " => bihimp open scoped symmDiff theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a := rfl #align symm_diff_def symmDiff_def theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) := rfl #align bihimp_def bihimp_def theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q := rfl #align symm_diff_eq_xor symmDiff_eq_Xor' @[simp] theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) := (iff_iff_implies_and_implies _ _).symm.trans Iff.comm #align bihimp_iff_iff bihimp_iff_iff @[simp] theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide #align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor section GeneralizedCoheytingAlgebra variable [GeneralizedCoheytingAlgebra α] (a b c d : α) @[simp] theorem toDual_symmDiff : toDual (a ∆ b) = toDual a ⇔ toDual b := rfl #align to_dual_symm_diff toDual_symmDiff @[simp] theorem ofDual_bihimp (a b : αᵒᵈ) : ofDual (a ⇔ b) = ofDual a ∆ ofDual b := rfl #align of_dual_bihimp ofDual_bihimp
Mathlib/Order/SymmDiff.lean
113
113
theorem symmDiff_comm : a ∆ b = b ∆ a := by
simp only [symmDiff, sup_comm]
/- Copyright (c) 2021 Yury Kudriashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudriashov, Malo Jaffré -/ import Mathlib.Analysis.Convex.Function import Mathlib.Tactic.AdaptationNote import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.Linarith #align_import analysis.convex.slope from "leanprover-community/mathlib"@"a8b2226cfb0a79f5986492053fc49b1a0c6aeffb" /-! # Slopes of convex functions This file relates convexity/concavity of functions in a linearly ordered field and the monotonicity of their slopes. The main use is to show convexity/concavity from monotonicity of the derivative. -/ variable {𝕜 : Type*} [LinearOrderedField 𝕜] {s : Set 𝕜} {f : 𝕜 → 𝕜} #adaptation_note /-- after v4.7.0-rc1, there is a performance problem in `field_simp`. (Part of the code was ignoring the `maxDischargeDepth` setting: now that we have to increase it, other paths become slow.) -/ /-- If `f : 𝕜 → 𝕜` is convex, then for any three points `x < y < z` the slope of the secant line of `f` on `[x, y]` is less than the slope of the secant line of `f` on `[x, z]`. -/ theorem ConvexOn.slope_mono_adjacent (hf : ConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f y - f x) / (y - x) ≤ (f z - f y) / (z - y) := by have hxz := hxy.trans hyz rw [← sub_pos] at hxy hxz hyz suffices f y / (y - x) + f y / (z - y) ≤ f x / (y - x) + f z / (z - y) by ring_nf at this ⊢ linarith set a := (z - y) / (z - x) set b := (y - x) / (z - x) have hy : a • x + b • z = y := by field_simp [a, b]; ring have key := hf.2 hx hz (show 0 ≤ a by apply div_nonneg <;> linarith) (show 0 ≤ b by apply div_nonneg <;> linarith) (show a + b = 1 by field_simp [a, b]) rw [hy] at key replace key := mul_le_mul_of_nonneg_left key hxz.le field_simp [a, b, mul_comm (z - x) _] at key ⊢ rw [div_le_div_right] · linarith · nlinarith #align convex_on.slope_mono_adjacent ConvexOn.slope_mono_adjacent /-- If `f : 𝕜 → 𝕜` is concave, then for any three points `x < y < z` the slope of the secant line of `f` on `[x, y]` is greater than the slope of the secant line of `f` on `[x, z]`. -/ theorem ConcaveOn.slope_anti_adjacent (hf : ConcaveOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f z - f y) / (z - y) ≤ (f y - f x) / (y - x) := by have := neg_le_neg (ConvexOn.slope_mono_adjacent hf.neg hx hz hxy hyz) simp only [Pi.neg_apply, ← neg_div, neg_sub', neg_neg] at this exact this #align concave_on.slope_anti_adjacent ConcaveOn.slope_anti_adjacent /-- If `f : 𝕜 → 𝕜` is strictly convex, then for any three points `x < y < z` the slope of the secant line of `f` on `[x, y]` is strictly less than the slope of the secant line of `f` on `[x, z]`. -/
Mathlib/Analysis/Convex/Slope.lean
63
83
theorem StrictConvexOn.slope_strict_mono_adjacent (hf : StrictConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f y - f x) / (y - x) < (f z - f y) / (z - y) := by
have hxz := hxy.trans hyz have hxz' := hxz.ne rw [← sub_pos] at hxy hxz hyz suffices f y / (y - x) + f y / (z - y) < f x / (y - x) + f z / (z - y) by ring_nf at this ⊢ linarith set a := (z - y) / (z - x) set b := (y - x) / (z - x) have hy : a • x + b • z = y := by field_simp [a, b]; ring have key := hf.2 hx hz hxz' (div_pos hyz hxz) (div_pos hxy hxz) (show a + b = 1 by field_simp [a, b]) rw [hy] at key replace key := mul_lt_mul_of_pos_left key hxz field_simp [mul_comm (z - x) _] at key ⊢ rw [div_lt_div_right] · linarith · nlinarith
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Nat.Factors import Mathlib.Order.Interval.Finset.Nat #align_import number_theory.divisors from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Divisor Finsets This file defines sets of divisors of a natural number. This is particularly useful as background for defining Dirichlet convolution. ## Main Definitions Let `n : ℕ`. All of the following definitions are in the `Nat` namespace: * `divisors n` is the `Finset` of natural numbers that divide `n`. * `properDivisors n` is the `Finset` of natural numbers that divide `n`, other than `n`. * `divisorsAntidiagonal n` is the `Finset` of pairs `(x,y)` such that `x * y = n`. * `Perfect n` is true when `n` is positive and the sum of `properDivisors n` is `n`. ## Implementation details * `divisors 0`, `properDivisors 0`, and `divisorsAntidiagonal 0` are defined to be `∅`. ## Tags divisors, perfect numbers -/ open scoped Classical open Finset namespace Nat variable (n : ℕ) /-- `divisors n` is the `Finset` of divisors of `n`. As a special case, `divisors 0 = ∅`. -/ def divisors : Finset ℕ := Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 (n + 1)) #align nat.divisors Nat.divisors /-- `properDivisors n` is the `Finset` of divisors of `n`, other than `n`. As a special case, `properDivisors 0 = ∅`. -/ def properDivisors : Finset ℕ := Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 n) #align nat.proper_divisors Nat.properDivisors /-- `divisorsAntidiagonal n` is the `Finset` of pairs `(x,y)` such that `x * y = n`. As a special case, `divisorsAntidiagonal 0 = ∅`. -/ def divisorsAntidiagonal : Finset (ℕ × ℕ) := Finset.filter (fun x => x.fst * x.snd = n) (Ico 1 (n + 1) ×ˢ Ico 1 (n + 1)) #align nat.divisors_antidiagonal Nat.divisorsAntidiagonal variable {n} @[simp] theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors := by ext simp only [divisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self] exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt) #align nat.filter_dvd_eq_divisors Nat.filter_dvd_eq_divisors @[simp] theorem filter_dvd_eq_properDivisors (h : n ≠ 0) : (Finset.range n).filter (· ∣ n) = n.properDivisors := by ext simp only [properDivisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self] exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt) #align nat.filter_dvd_eq_proper_divisors Nat.filter_dvd_eq_properDivisors theorem properDivisors.not_self_mem : ¬n ∈ properDivisors n := by simp [properDivisors] #align nat.proper_divisors.not_self_mem Nat.properDivisors.not_self_mem @[simp] theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m := by rcases eq_or_ne m 0 with (rfl | hm); · simp [properDivisors] simp only [and_comm, ← filter_dvd_eq_properDivisors hm, mem_filter, mem_range] #align nat.mem_proper_divisors Nat.mem_properDivisors theorem insert_self_properDivisors (h : n ≠ 0) : insert n (properDivisors n) = divisors n := by rw [divisors, properDivisors, Ico_succ_right_eq_insert_Ico (one_le_iff_ne_zero.2 h), Finset.filter_insert, if_pos (dvd_refl n)] #align nat.insert_self_proper_divisors Nat.insert_self_properDivisors theorem cons_self_properDivisors (h : n ≠ 0) : cons n (properDivisors n) properDivisors.not_self_mem = divisors n := by rw [cons_eq_insert, insert_self_properDivisors h] #align nat.cons_self_proper_divisors Nat.cons_self_properDivisors @[simp]
Mathlib/NumberTheory/Divisors.lean
95
99
theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 := by
rcases eq_or_ne m 0 with (rfl | hm); · simp [divisors] simp only [hm, Ne, not_false_iff, and_true_iff, ← filter_dvd_eq_divisors hm, mem_filter, mem_range, and_iff_right_iff_imp, Nat.lt_succ_iff] exact le_of_dvd hm.bot_lt
/- Copyright (c) 2021 Eric Rodriguez. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Rodriguez -/ import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots import Mathlib.Tactic.ByContra import Mathlib.Topology.Algebra.Polynomial import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Analysis.Complex.Arg #align_import ring_theory.polynomial.cyclotomic.eval from "leanprover-community/mathlib"@"5bfbcca0a7ffdd21cf1682e59106d6c942434a32" /-! # Evaluating cyclotomic polynomials This file states some results about evaluating cyclotomic polynomials in various different ways. ## Main definitions * `Polynomial.eval(₂)_one_cyclotomic_prime(_pow)`: `eval 1 (cyclotomic p^k R) = p`. * `Polynomial.eval_one_cyclotomic_not_prime_pow`: Otherwise, `eval 1 (cyclotomic n R) = 1`. * `Polynomial.cyclotomic_pos` : `∀ x, 0 < eval x (cyclotomic n R)` if `2 < n`. -/ namespace Polynomial open Finset Nat @[simp]
Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean
29
32
theorem eval_one_cyclotomic_prime {R : Type*} [CommRing R] {p : ℕ} [hn : Fact p.Prime] : eval 1 (cyclotomic p R) = p := by
simp only [cyclotomic_prime, eval_X, one_pow, Finset.sum_const, eval_pow, eval_finset_sum, Finset.card_range, smul_one_eq_cast]
/- Copyright (c) 2022 Wrenna Robson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Wrenna Robson -/ import Mathlib.Analysis.Normed.Group.Basic #align_import information_theory.hamming from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" /-! # Hamming spaces The Hamming metric counts the number of places two members of a (finite) Pi type differ. The Hamming norm is the same as the Hamming metric over additive groups, and counts the number of places a member of a (finite) Pi type differs from zero. This is a useful notion in various applications, but in particular it is relevant in coding theory, in which it is fundamental for defining the minimum distance of a code. ## Main definitions * `hammingDist x y`: the Hamming distance between `x` and `y`, the number of entries which differ. * `hammingNorm x`: the Hamming norm of `x`, the number of non-zero entries. * `Hamming β`: a type synonym for `Π i, β i` with `dist` and `norm` provided by the above. * `Hamming.toHamming`, `Hamming.ofHamming`: functions for casting between `Hamming β` and `Π i, β i`. * the Hamming norm forms a normed group on `Hamming β`. -/ section HammingDistNorm open Finset Function variable {α ι : Type*} {β : ι → Type*} [Fintype ι] [∀ i, DecidableEq (β i)] variable {γ : ι → Type*} [∀ i, DecidableEq (γ i)] /-- The Hamming distance function to the naturals. -/ def hammingDist (x y : ∀ i, β i) : ℕ := (univ.filter fun i => x i ≠ y i).card #align hamming_dist hammingDist /-- Corresponds to `dist_self`. -/ @[simp] theorem hammingDist_self (x : ∀ i, β i) : hammingDist x x = 0 := by rw [hammingDist, card_eq_zero, filter_eq_empty_iff] exact fun _ _ H => H rfl #align hamming_dist_self hammingDist_self /-- Corresponds to `dist_nonneg`. -/ theorem hammingDist_nonneg {x y : ∀ i, β i} : 0 ≤ hammingDist x y := zero_le _ #align hamming_dist_nonneg hammingDist_nonneg /-- Corresponds to `dist_comm`. -/ theorem hammingDist_comm (x y : ∀ i, β i) : hammingDist x y = hammingDist y x := by simp_rw [hammingDist, ne_comm] #align hamming_dist_comm hammingDist_comm /-- Corresponds to `dist_triangle`. -/ theorem hammingDist_triangle (x y z : ∀ i, β i) : hammingDist x z ≤ hammingDist x y + hammingDist y z := by classical unfold hammingDist refine le_trans (card_mono ?_) (card_union_le _ _) rw [← filter_or] exact monotone_filter_right _ fun i h ↦ (h.ne_or_ne _).imp_right Ne.symm #align hamming_dist_triangle hammingDist_triangle /-- Corresponds to `dist_triangle_left`. -/ theorem hammingDist_triangle_left (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist z x + hammingDist z y := by rw [hammingDist_comm z] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_left hammingDist_triangle_left /-- Corresponds to `dist_triangle_right`. -/
Mathlib/InformationTheory/Hamming.lean
78
81
theorem hammingDist_triangle_right (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist x z + hammingDist y z := by
rw [hammingDist_comm y] exact hammingDist_triangle _ _ _
/- Copyright (c) 2023 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals import Mathlib.Analysis.Calculus.ParametricIntegral import Mathlib.MeasureTheory.Measure.Haar.NormedSpace #align_import analysis.mellin_transform from "leanprover-community/mathlib"@"917c3c072e487b3cccdbfeff17e75b40e45f66cb" /-! # The Mellin transform We define the Mellin transform of a locally integrable function on `Ioi 0`, and show it is differentiable in a suitable vertical strip. ## Main statements - `mellin` : the Mellin transform `∫ (t : ℝ) in Ioi 0, t ^ (s - 1) • f t`, where `s` is a complex number. - `HasMellin`: shorthand asserting that the Mellin transform exists and has a given value (analogous to `HasSum`). - `mellin_differentiableAt_of_isBigO_rpow` : if `f` is `O(x ^ (-a))` at infinity, and `O(x ^ (-b))` at 0, then `mellin f` is holomorphic on the domain `b < re s < a`. -/ open MeasureTheory Set Filter Asymptotics TopologicalSpace open Real open Complex hiding exp log abs_of_nonneg open scoped Topology noncomputable section section Defs variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] /-- Predicate on `f` and `s` asserting that the Mellin integral is well-defined. -/ def MellinConvergent (f : ℝ → E) (s : ℂ) : Prop := IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (Ioi 0) #align mellin_convergent MellinConvergent
Mathlib/Analysis/MellinTransform.lean
47
50
theorem MellinConvergent.const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s) {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) : MellinConvergent (fun t => c • f t) s := by
simpa only [MellinConvergent, smul_comm] using hf.smul c
/- 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, Floris van Doorn, Sébastien Gouëzel, Alex J. Best -/ import Mathlib.Algebra.Divisibility.Basic import Mathlib.Algebra.Group.Int import Mathlib.Algebra.Group.Nat import Mathlib.Algebra.Group.Opposite import Mathlib.Algebra.Group.Units import Mathlib.Data.List.Perm import Mathlib.Data.List.ProdSigma import Mathlib.Data.List.Range import Mathlib.Data.List.Rotate #align_import data.list.big_operators.basic from "leanprover-community/mathlib"@"6c5f73fd6f6cc83122788a80a27cdd54663609f4" /-! # Sums and products from lists This file provides basic results about `List.prod`, `List.sum`, which calculate the product and sum of elements of a list and `List.alternatingProd`, `List.alternatingSum`, their alternating counterparts. -/ -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub assert_not_exists Ring variable {ι α β M N P G : Type*} namespace List section Defs /-- Product of a list. `List.prod [a, b, c] = ((1 * a) * b) * c` -/ @[to_additive "Sum of a list.\n\n`List.sum [a, b, c] = ((0 + a) + b) + c`"] def prod {α} [Mul α] [One α] : List α → α := foldl (· * ·) 1 #align list.prod List.prod #align list.sum List.sum /-- The alternating sum of a list. -/ def alternatingSum {G : Type*} [Zero G] [Add G] [Neg G] : List G → G | [] => 0 | g :: [] => g | g :: h :: t => g + -h + alternatingSum t #align list.alternating_sum List.alternatingSum /-- The alternating product of a list. -/ @[to_additive existing] def alternatingProd {G : Type*} [One G] [Mul G] [Inv G] : List G → G | [] => 1 | g :: [] => g | g :: h :: t => g * h⁻¹ * alternatingProd t #align list.alternating_prod List.alternatingProd end Defs section MulOneClass variable [MulOneClass M] {l : List M} {a : M} @[to_additive (attr := simp)] theorem prod_nil : ([] : List M).prod = 1 := rfl #align list.prod_nil List.prod_nil #align list.sum_nil List.sum_nil @[to_additive] theorem prod_singleton : [a].prod = a := one_mul a #align list.prod_singleton List.prod_singleton #align list.sum_singleton List.sum_singleton @[to_additive (attr := simp)]
Mathlib/Algebra/BigOperators/Group/List.lean
78
79
theorem prod_one_cons : (1 :: l).prod = l.prod := by
rw [prod, foldl, mul_one]
/- Copyright (c) 2021 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot -/ import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Order.OrderClosed #align_import topology.algebra.with_zero_topology from "leanprover-community/mathlib"@"3e0c4d76b6ebe9dfafb67d16f7286d2731ed6064" /-! # The topology on linearly ordered commutative groups with zero Let `Γ₀` be a linearly ordered commutative group to which we have adjoined a zero element. Then `Γ₀` may naturally be endowed with a topology that turns `Γ₀` into a topological monoid. Neighborhoods of zero are sets containing `{ γ | γ < γ₀ }` for some invertible element `γ₀` and every invertible element is open. In particular the topology is the following: "a subset `U ⊆ Γ₀` is open if `0 ∉ U` or if there is an invertible `γ₀ ∈ Γ₀` such that `{ γ | γ < γ₀ } ⊆ U`", see `WithZeroTopology.isOpen_iff`. We prove this topology is ordered and T₅ (in addition to be compatible with the monoid structure). All this is useful to extend a valuation to a completion. This is an abstract version of how the absolute value (resp. `p`-adic absolute value) on `ℚ` is extended to `ℝ` (resp. `ℚₚ`). ## Implementation notes This topology is defined as a scoped instance since it may not be the desired topology on a linearly ordered commutative group with zero. You can locally activate this topology using `open WithZeroTopology`. -/ open Topology Filter TopologicalSpace Filter Set Function namespace WithZeroTopology variable {α Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] {γ γ₁ γ₂ : Γ₀} {l : Filter α} {f : α → Γ₀} /-- The topology on a linearly ordered commutative group with a zero element adjoined. A subset U is open if 0 ∉ U or if there is an invertible element γ₀ such that {γ | γ < γ₀} ⊆ U. -/ scoped instance (priority := 100) topologicalSpace : TopologicalSpace Γ₀ := nhdsAdjoint 0 <| ⨅ γ ≠ 0, 𝓟 (Iio γ) #align with_zero_topology.topological_space WithZeroTopology.topologicalSpace theorem nhds_eq_update : (𝓝 : Γ₀ → Filter Γ₀) = update pure 0 (⨅ γ ≠ 0, 𝓟 (Iio γ)) := by rw [nhds_nhdsAdjoint, sup_of_le_right] exact le_iInf₂ fun γ hγ ↦ le_principal_iff.2 <| zero_lt_iff.2 hγ #align with_zero_topology.nhds_eq_update WithZeroTopology.nhds_eq_update /-! ### Neighbourhoods of zero -/ theorem nhds_zero : 𝓝 (0 : Γ₀) = ⨅ γ ≠ 0, 𝓟 (Iio γ) := by rw [nhds_eq_update, update_same] #align with_zero_topology.nhds_zero WithZeroTopology.nhds_zero /-- In a linearly ordered group with zero element adjoined, `U` is a neighbourhood of `0` if and only if there exists a nonzero element `γ₀` such that `Iio γ₀ ⊆ U`. -/ theorem hasBasis_nhds_zero : (𝓝 (0 : Γ₀)).HasBasis (fun γ : Γ₀ => γ ≠ 0) Iio := by rw [nhds_zero] refine hasBasis_biInf_principal ?_ ⟨1, one_ne_zero⟩ exact directedOn_iff_directed.2 (Monotone.directed_ge fun a b hab => Iio_subset_Iio hab) #align with_zero_topology.has_basis_nhds_zero WithZeroTopology.hasBasis_nhds_zero theorem Iio_mem_nhds_zero (hγ : γ ≠ 0) : Iio γ ∈ 𝓝 (0 : Γ₀) := hasBasis_nhds_zero.mem_of_mem hγ #align with_zero_topology.Iio_mem_nhds_zero WithZeroTopology.Iio_mem_nhds_zero /-- If `γ` is an invertible element of a linearly ordered group with zero element adjoined, then `Iio (γ : Γ₀)` is a neighbourhood of `0`. -/ theorem nhds_zero_of_units (γ : Γ₀ˣ) : Iio ↑γ ∈ 𝓝 (0 : Γ₀) := Iio_mem_nhds_zero γ.ne_zero #align with_zero_topology.nhds_zero_of_units WithZeroTopology.nhds_zero_of_units theorem tendsto_zero : Tendsto f l (𝓝 (0 : Γ₀)) ↔ ∀ (γ₀) (_ : γ₀ ≠ 0), ∀ᶠ x in l, f x < γ₀ := by simp [nhds_zero] #align with_zero_topology.tendsto_zero WithZeroTopology.tendsto_zero /-! ### Neighbourhoods of non-zero elements -/ /-- The neighbourhood filter of a nonzero element consists of all sets containing that element. -/ @[simp] theorem nhds_of_ne_zero {γ : Γ₀} (h₀ : γ ≠ 0) : 𝓝 γ = pure γ := nhds_nhdsAdjoint_of_ne _ h₀ #align with_zero_topology.nhds_of_ne_zero WithZeroTopology.nhds_of_ne_zero /-- The neighbourhood filter of an invertible element consists of all sets containing that element. -/ theorem nhds_coe_units (γ : Γ₀ˣ) : 𝓝 (γ : Γ₀) = pure (γ : Γ₀) := nhds_of_ne_zero γ.ne_zero #align with_zero_topology.nhds_coe_units WithZeroTopology.nhds_coe_units /-- If `γ` is an invertible element of a linearly ordered group with zero element adjoined, then `{γ}` is a neighbourhood of `γ`. -/
Mathlib/Topology/Algebra/WithZeroTopology.lean
101
101
theorem singleton_mem_nhds_of_units (γ : Γ₀ˣ) : ({↑γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by
simp
/- Copyright (c) 2022 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" /-! # Extending an alternating map to the exterior algebra ## Main definitions * `ExteriorAlgebra.liftAlternating`: construct a linear map out of the exterior algebra given alternating maps (corresponding to maps out of the exterior powers). * `ExteriorAlgebra.liftAlternatingEquiv`: the above as a linear equivalence ## Main results * `ExteriorAlgebra.lhom_ext`: linear maps from the exterior algebra agree if they agree on the exterior powers. -/ variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι /-- Build a map out of the exterior algebra given a collection of alternating maps acting on each exterior power -/ def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) (x : ExteriorAlgebra R M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) = liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by dsimp [liftAlternating] rw [foldl_mul, foldl_ι] rfl #align exterior_algebra.lift_alternating_ι_mul ExteriorAlgebra.liftAlternating_ι_mul @[simp] theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by dsimp [liftAlternating] rw [foldl_one] #align exterior_algebra.lift_alternating_one ExteriorAlgebra.liftAlternating_one @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
96
99
theorem liftAlternating_algebraMap (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (r : R) : liftAlternating (R := R) (M := M) (N := N) f (algebraMap _ (ExteriorAlgebra R M) r) = r • f 0 0 := by
rw [Algebra.algebraMap_eq_smul_one, map_smul, liftAlternating_one]
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.LinearAlgebra.CliffordAlgebra.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.clifford_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" /-! # Results about the grading structure of the clifford algebra The main result is `CliffordAlgebra.gradedAlgebra`, which says that the clifford algebra is a ℤ₂-graded algebra (or "superalgebra"). -/ namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) /-- The even or odd submodule, defined as the supremum of the even or odd powers of `(ι Q).range`. `evenOdd 0` is the even submodule, and `evenOdd 1` is the odd submodule. -/ def evenOdd (i : ZMod 2) : Submodule R (CliffordAlgebra Q) := ⨆ j : { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (j : ℕ) #align clifford_algebra.even_odd CliffordAlgebra.evenOdd theorem one_le_evenOdd_zero : 1 ≤ evenOdd Q 0 := by refine le_trans ?_ (le_iSup _ ⟨0, Nat.cast_zero⟩) exact (pow_zero _).ge #align clifford_algebra.one_le_even_odd_zero CliffordAlgebra.one_le_evenOdd_zero theorem range_ι_le_evenOdd_one : LinearMap.range (ι Q) ≤ evenOdd Q 1 := by refine le_trans ?_ (le_iSup _ ⟨1, Nat.cast_one⟩) exact (pow_one _).ge #align clifford_algebra.range_ι_le_even_odd_one CliffordAlgebra.range_ι_le_evenOdd_one theorem ι_mem_evenOdd_one (m : M) : ι Q m ∈ evenOdd Q 1 := range_ι_le_evenOdd_one Q <| LinearMap.mem_range_self _ m #align clifford_algebra.ι_mem_even_odd_one CliffordAlgebra.ι_mem_evenOdd_one theorem ι_mul_ι_mem_evenOdd_zero (m₁ m₂ : M) : ι Q m₁ * ι Q m₂ ∈ evenOdd Q 0 := Submodule.mem_iSup_of_mem ⟨2, rfl⟩ (by rw [Subtype.coe_mk, pow_two] exact Submodule.mul_mem_mul (LinearMap.mem_range_self (ι Q) m₁) (LinearMap.mem_range_self (ι Q) m₂)) #align clifford_algebra.ι_mul_ι_mem_even_odd_zero CliffordAlgebra.ι_mul_ι_mem_evenOdd_zero
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
58
65
theorem evenOdd_mul_le (i j : ZMod 2) : evenOdd Q i * evenOdd Q j ≤ evenOdd Q (i + j) := by
simp_rw [evenOdd, Submodule.iSup_eq_span, Submodule.span_mul_span] apply Submodule.span_mono simp_rw [Set.iUnion_mul, Set.mul_iUnion, Set.iUnion_subset_iff, Set.mul_subset_iff] rintro ⟨xi, rfl⟩ ⟨yi, rfl⟩ x hx y hy refine Set.mem_iUnion.mpr ⟨⟨xi + yi, Nat.cast_add _ _⟩, ?_⟩ simp only [Subtype.coe_mk, Nat.cast_add, pow_add] exact Submodule.mul_mem_mul hx hy
/- Copyright (c) 2021 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth, Eric Wieser -/ import Mathlib.Analysis.NormedSpace.PiLp import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import analysis.matrix from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Matrices as a normed space In this file we provide the following non-instances for norms on matrices: * The elementwise norm: * `Matrix.seminormedAddCommGroup` * `Matrix.normedAddCommGroup` * `Matrix.normedSpace` * `Matrix.boundedSMul` * The Frobenius norm: * `Matrix.frobeniusSeminormedAddCommGroup` * `Matrix.frobeniusNormedAddCommGroup` * `Matrix.frobeniusNormedSpace` * `Matrix.frobeniusNormedRing` * `Matrix.frobeniusNormedAlgebra` * `Matrix.frobeniusBoundedSMul` * The $L^\infty$ operator norm: * `Matrix.linftyOpSeminormedAddCommGroup` * `Matrix.linftyOpNormedAddCommGroup` * `Matrix.linftyOpNormedSpace` * `Matrix.linftyOpBoundedSMul` * `Matrix.linftyOpNonUnitalSemiNormedRing` * `Matrix.linftyOpSemiNormedRing` * `Matrix.linftyOpNonUnitalNormedRing` * `Matrix.linftyOpNormedRing` * `Matrix.linftyOpNormedAlgebra` These are not declared as instances because there are several natural choices for defining the norm of a matrix. The norm induced by the identification of `Matrix m n 𝕜` with `EuclideanSpace n 𝕜 →L[𝕜] EuclideanSpace m 𝕜` (i.e., the ℓ² operator norm) can be found in `Analysis.NormedSpace.Star.Matrix`. It is separated to avoid extraneous imports in this file. -/ noncomputable section open scoped NNReal Matrix namespace Matrix variable {R l m n α β : Type*} [Fintype l] [Fintype m] [Fintype n] /-! ### The elementwise supremum norm -/ section LinfLinf section SeminormedAddCommGroup variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β] /-- Seminormed group instance (using sup norm of sup norm) for matrices over a seminormed group. Not declared as an instance because there are several natural choices for defining the norm of a matrix. -/ protected def seminormedAddCommGroup : SeminormedAddCommGroup (Matrix m n α) := Pi.seminormedAddCommGroup #align matrix.seminormed_add_comm_group Matrix.seminormedAddCommGroup attribute [local instance] Matrix.seminormedAddCommGroup -- Porting note (#10756): new theorem (along with all the uses of this lemma below) theorem norm_def (A : Matrix m n α) : ‖A‖ = ‖fun i j => A i j‖ := rfl /-- The norm of a matrix is the sup of the sup of the nnnorm of the entries -/ lemma norm_eq_sup_sup_nnnorm (A : Matrix m n α) : ‖A‖ = Finset.sup Finset.univ fun i ↦ Finset.sup Finset.univ fun j ↦ ‖A i j‖₊ := by simp_rw [Matrix.norm_def, Pi.norm_def, Pi.nnnorm_def] -- Porting note (#10756): new theorem (along with all the uses of this lemma below) theorem nnnorm_def (A : Matrix m n α) : ‖A‖₊ = ‖fun i j => A i j‖₊ := rfl theorem norm_le_iff {r : ℝ} (hr : 0 ≤ r) {A : Matrix m n α} : ‖A‖ ≤ r ↔ ∀ i j, ‖A i j‖ ≤ r := by simp_rw [norm_def, pi_norm_le_iff_of_nonneg hr] #align matrix.norm_le_iff Matrix.norm_le_iff theorem nnnorm_le_iff {r : ℝ≥0} {A : Matrix m n α} : ‖A‖₊ ≤ r ↔ ∀ i j, ‖A i j‖₊ ≤ r := by simp_rw [nnnorm_def, pi_nnnorm_le_iff] #align matrix.nnnorm_le_iff Matrix.nnnorm_le_iff theorem norm_lt_iff {r : ℝ} (hr : 0 < r) {A : Matrix m n α} : ‖A‖ < r ↔ ∀ i j, ‖A i j‖ < r := by simp_rw [norm_def, pi_norm_lt_iff hr] #align matrix.norm_lt_iff Matrix.norm_lt_iff theorem nnnorm_lt_iff {r : ℝ≥0} (hr : 0 < r) {A : Matrix m n α} : ‖A‖₊ < r ↔ ∀ i j, ‖A i j‖₊ < r := by simp_rw [nnnorm_def, pi_nnnorm_lt_iff hr] #align matrix.nnnorm_lt_iff Matrix.nnnorm_lt_iff theorem norm_entry_le_entrywise_sup_norm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖ ≤ ‖A‖ := (norm_le_pi_norm (A i) j).trans (norm_le_pi_norm A i) #align matrix.norm_entry_le_entrywise_sup_norm Matrix.norm_entry_le_entrywise_sup_norm theorem nnnorm_entry_le_entrywise_sup_nnnorm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖₊ ≤ ‖A‖₊ := (nnnorm_le_pi_nnnorm (A i) j).trans (nnnorm_le_pi_nnnorm A i) #align matrix.nnnorm_entry_le_entrywise_sup_nnnorm Matrix.nnnorm_entry_le_entrywise_sup_nnnorm @[simp]
Mathlib/Analysis/Matrix.lean
116
118
theorem nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) : ‖A.map f‖₊ = ‖A‖₊ := by
simp only [nnnorm_def, Pi.nnnorm_def, Matrix.map_apply, hf]
/- Copyright (c) 2020 Nicolò Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nicolò Cavalleri, Andrew Yang -/ import Mathlib.RingTheory.Derivation.ToSquareZero import Mathlib.RingTheory.Ideal.Cotangent import Mathlib.RingTheory.IsTensorProduct import Mathlib.Algebra.Exact import Mathlib.Algebra.MvPolynomial.PDeriv import Mathlib.Algebra.Polynomial.Derivation #align_import ring_theory.kaehler from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364" /-! # The module of kaehler differentials ## Main results - `KaehlerDifferential`: The module of kaehler differentials. For an `R`-algebra `S`, we provide the notation `Ω[S⁄R]` for `KaehlerDifferential R S`. Note that the slash is `\textfractionsolidus`. - `KaehlerDifferential.D`: The derivation into the module of kaehler differentials. - `KaehlerDifferential.span_range_derivation`: The image of `D` spans `Ω[S⁄R]` as an `S`-module. - `KaehlerDifferential.linearMapEquivDerivation`: The isomorphism `Hom_R(Ω[S⁄R], M) ≃ₗ[S] Der_R(S, M)`. - `KaehlerDifferential.quotKerTotalEquiv`: An alternative description of `Ω[S⁄R]` as `S` copies of `S` with kernel (`KaehlerDifferential.kerTotal`) generated by the relations: 1. `dx + dy = d(x + y)` 2. `x dy + y dx = d(x * y)` 3. `dr = 0` for `r ∈ R` - `KaehlerDifferential.map`: Given a map between the arrows `R →+* A` and `S →+* B`, we have an `A`-linear map `Ω[A⁄R] → Ω[B⁄S]`. - `KaehlerDifferential.map_surjective`: The sequence `Ω[B⁄R] → Ω[B⁄A] → 0` is exact. - `KaehlerDifferential.exact_mapBaseChange_map`: The sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → Ω[B⁄A]` is exact. ## Future project - Define the `IsKaehlerDifferential` predicate. -/ suppress_compilation section KaehlerDifferential open scoped TensorProduct open Algebra universe u v variable (R : Type u) (S : Type v) [CommRing R] [CommRing S] [Algebra R S] /-- The kernel of the multiplication map `S ⊗[R] S →ₐ[R] S`. -/ abbrev KaehlerDifferential.ideal : Ideal (S ⊗[R] S) := RingHom.ker (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S) #align kaehler_differential.ideal KaehlerDifferential.ideal variable {S} theorem KaehlerDifferential.one_smul_sub_smul_one_mem_ideal (a : S) : (1 : S) ⊗ₜ[R] a - a ⊗ₜ[R] (1 : S) ∈ KaehlerDifferential.ideal R S := by simp [RingHom.mem_ker] #align kaehler_differential.one_smul_sub_smul_one_mem_ideal KaehlerDifferential.one_smul_sub_smul_one_mem_ideal variable {R} variable {M : Type*} [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M] /-- For a `R`-derivation `S → M`, this is the map `S ⊗[R] S →ₗ[S] M` sending `s ⊗ₜ t ↦ s • D t`. -/ def Derivation.tensorProductTo (D : Derivation R S M) : S ⊗[R] S →ₗ[S] M := TensorProduct.AlgebraTensorModule.lift ((LinearMap.lsmul S (S →ₗ[R] M)).flip D.toLinearMap) #align derivation.tensor_product_to Derivation.tensorProductTo theorem Derivation.tensorProductTo_tmul (D : Derivation R S M) (s t : S) : D.tensorProductTo (s ⊗ₜ t) = s • D t := rfl #align derivation.tensor_product_to_tmul Derivation.tensorProductTo_tmul
Mathlib/RingTheory/Kaehler.lean
78
99
theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S) : D.tensorProductTo (x * y) = TensorProduct.lmul' (S := S) R x • D.tensorProductTo y + TensorProduct.lmul' (S := S) R y • D.tensorProductTo x := by
refine TensorProduct.induction_on x ?_ ?_ ?_ · rw [zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero] swap · intro x₁ y₁ h₁ h₂ rw [add_mul, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm] intro x₁ x₂ refine TensorProduct.induction_on y ?_ ?_ ?_ · rw [mul_zero, map_zero, map_zero, zero_smul, smul_zero, add_zero] swap · intro x₁ y₁ h₁ h₂ rw [mul_add, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm] intro x y simp only [TensorProduct.tmul_mul_tmul, Derivation.tensorProductTo, TensorProduct.AlgebraTensorModule.lift_apply, TensorProduct.lift.tmul', TensorProduct.lmul'_apply_tmul] dsimp rw [D.leibniz] simp only [smul_smul, smul_add, mul_comm (x * y) x₁, mul_right_comm x₁ x₂, ← mul_assoc]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Algebra.BigOperators.Group.Multiset import Mathlib.Data.Multiset.Dedup #align_import data.multiset.bind from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # Bind operation for multisets This file defines a few basic operations on `Multiset`, notably the monadic bind. ## Main declarations * `Multiset.join`: The join, aka union or sum, of multisets. * `Multiset.bind`: The bind of a multiset-indexed family of multisets. * `Multiset.product`: Cartesian product of two multisets. * `Multiset.sigma`: Disjoint sum of multisets in a sigma type. -/ assert_not_exists MonoidWithZero assert_not_exists MulAction universe v variable {α : Type*} {β : Type v} {γ δ : Type*} namespace Multiset /-! ### Join -/ /-- `join S`, where `S` is a multiset of multisets, is the lift of the list join operation, that is, the union of all the sets. join {{1, 2}, {1, 2}, {0, 1}} = {0, 1, 1, 1, 2, 2} -/ def join : Multiset (Multiset α) → Multiset α := sum #align multiset.join Multiset.join theorem coe_join : ∀ L : List (List α), join (L.map ((↑) : List α → Multiset α) : Multiset (Multiset α)) = L.join | [] => rfl | l :: L => by exact congr_arg (fun s : Multiset α => ↑l + s) (coe_join L) #align multiset.coe_join Multiset.coe_join @[simp] theorem join_zero : @join α 0 = 0 := rfl #align multiset.join_zero Multiset.join_zero @[simp] theorem join_cons (s S) : @join α (s ::ₘ S) = s + join S := sum_cons _ _ #align multiset.join_cons Multiset.join_cons @[simp] theorem join_add (S T) : @join α (S + T) = join S + join T := sum_add _ _ #align multiset.join_add Multiset.join_add @[simp] theorem singleton_join (a) : join ({a} : Multiset (Multiset α)) = a := sum_singleton _ #align multiset.singleton_join Multiset.singleton_join @[simp] theorem mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s := Multiset.induction_on S (by simp) <| by simp (config := { contextual := true }) [or_and_right, exists_or] #align multiset.mem_join Multiset.mem_join @[simp] theorem card_join (S) : card (@join α S) = sum (map card S) := Multiset.induction_on S (by simp) (by simp) #align multiset.card_join Multiset.card_join @[simp] theorem map_join (f : α → β) (S : Multiset (Multiset α)) : map f (join S) = join (map (map f) S) := by induction S using Multiset.induction with | empty => simp | cons _ _ ih => simp [ih] @[to_additive (attr := simp)] theorem prod_join [CommMonoid α] {S : Multiset (Multiset α)} : prod (join S) = prod (map prod S) := by induction S using Multiset.induction with | empty => simp | cons _ _ ih => simp [ih] theorem rel_join {r : α → β → Prop} {s t} (h : Rel (Rel r) s t) : Rel r s.join t.join := by induction h with | zero => simp | cons hab hst ih => simpa using hab.add ih #align multiset.rel_join Multiset.rel_join /-! ### Bind -/ section Bind variable (a : α) (s t : Multiset α) (f g : α → Multiset β) /-- `s.bind f` is the monad bind operation, defined as `(s.map f).join`. It is the union of `f a` as `a` ranges over `s`. -/ def bind (s : Multiset α) (f : α → Multiset β) : Multiset β := (s.map f).join #align multiset.bind Multiset.bind @[simp]
Mathlib/Data/Multiset/Bind.lean
115
117
theorem coe_bind (l : List α) (f : α → List β) : (@bind α β l fun a => f a) = l.bind f := by
rw [List.bind, ← coe_join, List.map_map] rfl
/- Copyright (c) 2023 Ali Ramsey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ali Ramsey, Eric Wieser -/ import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.Prod import Mathlib.LinearAlgebra.TensorProduct.Basic /-! # Coalgebras In this file we define `Coalgebra`, and provide instances for: * Commutative semirings: `CommSemiring.toCoalgebra` * Binary products: `Prod.instCoalgebra` * Finitely supported functions: `Finsupp.instCoalgebra` ## References * <https://en.wikipedia.org/wiki/Coalgebra> -/ suppress_compilation universe u v w open scoped TensorProduct /-- Data fields for `Coalgebra`, to allow API to be constructed before proving `Coalgebra.coassoc`. See `Coalgebra` for documentation. -/ class CoalgebraStruct (R : Type u) (A : Type v) [CommSemiring R] [AddCommMonoid A] [Module R A] where /-- The comultiplication of the coalgebra -/ comul : A →ₗ[R] A ⊗[R] A /-- The counit of the coalgebra -/ counit : A →ₗ[R] R namespace Coalgebra export CoalgebraStruct (comul counit) end Coalgebra /-- A coalgebra over a commutative (semi)ring `R` is an `R`-module equipped with a coassociative comultiplication `Δ` and a counit `ε` obeying the left and right counitality laws. -/ class Coalgebra (R : Type u) (A : Type v) [CommSemiring R] [AddCommMonoid A] [Module R A] extends CoalgebraStruct R A where /-- The comultiplication is coassociative -/ coassoc : TensorProduct.assoc R A A A ∘ₗ comul.rTensor A ∘ₗ comul = comul.lTensor A ∘ₗ comul /-- The counit satisfies the left counitality law -/ rTensor_counit_comp_comul : counit.rTensor A ∘ₗ comul = TensorProduct.mk R _ _ 1 /-- The counit satisfies the right counitality law -/ lTensor_counit_comp_comul : counit.lTensor A ∘ₗ comul = (TensorProduct.mk R _ _).flip 1 namespace Coalgebra variable {R : Type u} {A : Type v} variable [CommSemiring R] [AddCommMonoid A] [Module R A] [Coalgebra R A] @[simp] theorem coassoc_apply (a : A) : TensorProduct.assoc R A A A (comul.rTensor A (comul a)) = comul.lTensor A (comul a) := LinearMap.congr_fun coassoc a @[simp] theorem coassoc_symm_apply (a : A) : (TensorProduct.assoc R A A A).symm (comul.lTensor A (comul a)) = comul.rTensor A (comul a) := by rw [(TensorProduct.assoc R A A A).symm_apply_eq, coassoc_apply a] @[simp] theorem coassoc_symm : (TensorProduct.assoc R A A A).symm ∘ₗ comul.lTensor A ∘ₗ comul = comul.rTensor A ∘ₗ (comul (R := R)) := LinearMap.ext coassoc_symm_apply @[simp] theorem rTensor_counit_comul (a : A) : counit.rTensor A (comul a) = 1 ⊗ₜ[R] a := LinearMap.congr_fun rTensor_counit_comp_comul a @[simp] theorem lTensor_counit_comul (a : A) : counit.lTensor A (comul a) = a ⊗ₜ[R] 1 := LinearMap.congr_fun lTensor_counit_comp_comul a end Coalgebra section CommSemiring open Coalgebra namespace CommSemiring variable (R : Type u) [CommSemiring R] /-- Every commutative (semi)ring is a coalgebra over itself, with `Δ r = 1 ⊗ₜ r`. -/ instance toCoalgebra : Coalgebra R R where comul := (TensorProduct.mk R R R) 1 counit := .id coassoc := rfl rTensor_counit_comp_comul := by ext; rfl lTensor_counit_comp_comul := by ext; rfl @[simp] theorem comul_apply (r : R) : comul r = 1 ⊗ₜ[R] r := rfl @[simp] theorem counit_apply (r : R) : counit r = r := rfl end CommSemiring namespace Prod variable (R : Type u) (A : Type v) (B : Type w) variable [CommSemiring R] [AddCommMonoid A] [AddCommMonoid B] [Module R A] [Module R B] variable [Coalgebra R A] [Coalgebra R B] open LinearMap instance instCoalgebraStruct : CoalgebraStruct R (A × B) where comul := .coprod (TensorProduct.map (.inl R A B) (.inl R A B) ∘ₗ comul) (TensorProduct.map (.inr R A B) (.inr R A B) ∘ₗ comul) counit := .coprod counit counit @[simp] theorem comul_apply (r : A × B) : comul r = TensorProduct.map (.inl R A B) (.inl R A B) (comul r.1) + TensorProduct.map (.inr R A B) (.inr R A B) (comul r.2) := rfl @[simp] theorem counit_apply (r : A × B) : (counit r : R) = counit r.1 + counit r.2 := rfl theorem comul_comp_inl : comul ∘ₗ inl R A B = TensorProduct.map (.inl R A B) (.inl R A B) ∘ₗ comul := by ext; simp theorem comul_comp_inr : comul ∘ₗ inr R A B = TensorProduct.map (.inr R A B) (.inr R A B) ∘ₗ comul := by ext; simp
Mathlib/RingTheory/Coalgebra/Basic.lean
137
143
theorem comul_comp_fst : comul ∘ₗ .fst R A B = TensorProduct.map (.fst R A B) (.fst R A B) ∘ₗ comul := by
ext : 1 · rw [comp_assoc, fst_comp_inl, comp_id, comp_assoc, comul_comp_inl, ← comp_assoc, ← TensorProduct.map_comp, fst_comp_inl, TensorProduct.map_id, id_comp] · rw [comp_assoc, fst_comp_inr, comp_zero, comp_assoc, comul_comp_inr, ← comp_assoc, ← TensorProduct.map_comp, fst_comp_inr, TensorProduct.map_zero_left, zero_comp]
/- Copyright (c) 2022 Moritz Firsching. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Firsching, Fabian Kruse, Nikolas Kuhn -/ import Mathlib.Analysis.PSeries import Mathlib.Data.Real.Pi.Wallis import Mathlib.Tactic.AdaptationNote #align_import analysis.special_functions.stirling from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Stirling's formula This file proves Stirling's formula for the factorial. It states that $n!$ grows asymptotically like $\sqrt{2\pi n}(\frac{n}{e})^n$. ## Proof outline The proof follows: <https://proofwiki.org/wiki/Stirling%27s_Formula>. We proceed in two parts. **Part 1**: We consider the sequence $a_n$ of fractions $\frac{n!}{\sqrt{2n}(\frac{n}{e})^n}$ and prove that this sequence converges to a real, positive number $a$. For this the two main ingredients are - taking the logarithm of the sequence and - using the series expansion of $\log(1 + x)$. **Part 2**: We use the fact that the series defined in part 1 converges against a real number $a$ and prove that $a = \sqrt{\pi}$. Here the main ingredient is the convergence of Wallis' product formula for `π`. -/ open scoped Topology Real Nat Asymptotics open Finset Filter Nat Real namespace Stirling /-! ### Part 1 https://proofwiki.org/wiki/Stirling%27s_Formula#Part_1 -/ /-- Define `stirlingSeq n` as $\frac{n!}{\sqrt{2n}(\frac{n}{e})^n}$. Stirling's formula states that this sequence has limit $\sqrt(π)$. -/ noncomputable def stirlingSeq (n : ℕ) : ℝ := n ! / (√(2 * n : ℝ) * (n / exp 1) ^ n) #align stirling.stirling_seq Stirling.stirlingSeq @[simp] theorem stirlingSeq_zero : stirlingSeq 0 = 0 := by rw [stirlingSeq, cast_zero, mul_zero, Real.sqrt_zero, zero_mul, div_zero] #align stirling.stirling_seq_zero Stirling.stirlingSeq_zero @[simp] theorem stirlingSeq_one : stirlingSeq 1 = exp 1 / √2 := by rw [stirlingSeq, pow_one, factorial_one, cast_one, mul_one, mul_one_div, one_div_div] #align stirling.stirling_seq_one Stirling.stirlingSeq_one theorem log_stirlingSeq_formula (n : ℕ) : log (stirlingSeq n) = Real.log n ! - 1 / 2 * Real.log (2 * n) - n * log (n / exp 1) := by cases n · simp · rw [stirlingSeq, log_div, log_mul, sqrt_eq_rpow, log_rpow, Real.log_pow, tsub_tsub] <;> positivity -- Porting note: generalized from `n.succ` to `n` #align stirling.log_stirling_seq_formula Stirling.log_stirlingSeq_formulaₓ /-- The sequence `log (stirlingSeq (m + 1)) - log (stirlingSeq (m + 2))` has the series expansion `∑ 1 / (2 * (k + 1) + 1) * (1 / 2 * (m + 1) + 1)^(2 * (k + 1))` -/
Mathlib/Analysis/SpecialFunctions/Stirling.lean
77
93
theorem log_stirlingSeq_diff_hasSum (m : ℕ) : HasSum (fun k : ℕ => (1 : ℝ) / (2 * ↑(k + 1) + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ ↑(k + 1)) (log (stirlingSeq (m + 1)) - log (stirlingSeq (m + 2))) := by
let f (k : ℕ) := (1 : ℝ) / (2 * k + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ k change HasSum (fun k => f (k + 1)) _ rw [hasSum_nat_add_iff] convert (hasSum_log_one_add_inv m.cast_add_one_pos).mul_left ((↑(m + 1) : ℝ) + 1 / 2) using 1 · ext k dsimp only [f] rw [← pow_mul, pow_add] push_cast field_simp ring · have h : ∀ x ≠ (0 : ℝ), 1 + x⁻¹ = (x + 1) / x := fun x hx ↦ by field_simp [hx] simp (disch := positivity) only [log_stirlingSeq_formula, log_div, log_mul, log_exp, factorial_succ, cast_mul, cast_succ, cast_zero, range_one, sum_singleton, h] ring
/- 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.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" /-! # partial equivalences for matrices Using partial equivalences to represent matrices. This file introduces the function `PEquiv.toMatrix`, which returns a matrix containing ones and zeros. For any partial equivalence `f`, `f.toMatrix i j = 1 ↔ f i = some j`. The following important properties of this function are proved `toMatrix_trans : (f.trans g).toMatrix = f.toMatrix * g.toMatrix` `toMatrix_symm : f.symm.toMatrix = f.toMatrixᵀ` `toMatrix_refl : (PEquiv.refl n).toMatrix = 1` `toMatrix_bot : ⊥.toMatrix = 0` This theory gives the matrix representation of projection linear maps, and their right inverses. For example, the matrix `(single (0 : Fin 1) (i : Fin n)).toMatrix` corresponds to the ith projection map from R^n to R. Any injective function `Fin m → Fin n` gives rise to a `PEquiv`, whose matrix is the projection map from R^m → R^n represented by the same function. The transpose of this matrix is the right inverse of this map, sending anything not in the image to zero. ## notations This file uses `ᵀ` for `Matrix.transpose`. -/ namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix /-- `toMatrix` returns a matrix containing ones and zeros. `f.toMatrix i j` is `1` if `f i = some j` and `0` otherwise -/ def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply
Mathlib/Data/Matrix/PEquiv.lean
96
99
theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by
ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id]
/- Copyright (c) 2024 Mitchell Lee. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mitchell Lee -/ import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic /-! # The length function, reduced words, and descents Throughout this file, `B` is a type and `M : CoxeterMatrix B` is a Coxeter matrix. `cs : CoxeterSystem M W` is a Coxeter system; that is, `W` is a group, and `cs` holds the data of a group isomorphism `W ≃* M.group`, where `M.group` refers to the quotient of the free group on `B` by the Coxeter relations given by the matrix `M`. See `Mathlib/GroupTheory/Coxeter/Basic.lean` for more details. Given any element $w \in W$, its *length* (`CoxeterSystem.length`), denoted $\ell(w)$, is the minimum number $\ell$ such that $w$ can be written as a product of a sequence of $\ell$ simple reflections: $$w = s_{i_1} \cdots s_{i_\ell}.$$ We prove for all $w_1, w_2 \in W$ that $\ell (w_1 w_2) \leq \ell (w_1) + \ell (w_2)$ and that $\ell (w_1 w_2)$ has the same parity as $\ell (w_1) + \ell (w_2)$. We define a *reduced word* (`CoxeterSystem.IsReduced`) for an element $w \in W$ to be a way of writing $w$ as a product of exactly $\ell(w)$ simple reflections. Every element of $W$ has a reduced word. We say that $i \in B$ is a *left descent* (`CoxeterSystem.IsLeftDescent`) of $w \in W$ if $\ell(s_i w) < \ell(w)$. We show that if $i$ is a left descent of $w$, then $\ell(s_i w) + 1 = \ell(w)$. On the other hand, if $i$ is not a left descent of $w$, then $\ell(s_i w) = \ell(w) + 1$. We similarly define right descents (`CoxeterSystem.IsRightDescent`) and prove analogous results. ## Main definitions * `cs.length` * `cs.IsReduced` * `cs.IsLeftDescent` * `cs.IsRightDescent` ## References * [A. Björner and F. Brenti, *Combinatorics of Coxeter Groups*](bjorner2005) -/ namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd /-! ### Length -/ private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω /-- The length of `w`; i.e., the minimum number of simple reflections that must be multiplied to form `w`. -/ noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp]
Mathlib/GroupTheory/Coxeter/Length.lean
91
98
theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by
apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Control.Functor import Mathlib.Tactic.Common #align_import control.bifunctor from "leanprover-community/mathlib"@"dc1525fb3ef6eb4348fb1749c302d8abc303d34a" /-! # Functors with two arguments This file defines bifunctors. A bifunctor is a function `F : Type* → Type* → Type*` along with a bimap which turns `F α β`into `F α' β'` given two functions `α → α'` and `β → β'`. It further * respects the identity: `bimap id id = id` * composes in the obvious way: `(bimap f' g') ∘ (bimap f g) = bimap (f' ∘ f) (g' ∘ g)` ## Main declarations * `Bifunctor`: A typeclass for the bare bimap of a bifunctor. * `LawfulBifunctor`: A typeclass asserting this bimap respects the bifunctor laws. -/ universe u₀ u₁ u₂ v₀ v₁ v₂ open Function /-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/ class Bifunctor (F : Type u₀ → Type u₁ → Type u₂) where bimap : ∀ {α α' β β'}, (α → α') → (β → β') → F α β → F α' β' #align bifunctor Bifunctor export Bifunctor (bimap) /-- Bifunctor. This typeclass asserts that a lawless `Bifunctor` is lawful. -/ class LawfulBifunctor (F : Type u₀ → Type u₁ → Type u₂) [Bifunctor F] : Prop where id_bimap : ∀ {α β} (x : F α β), bimap id id x = x bimap_bimap : ∀ {α₀ α₁ α₂ β₀ β₁ β₂} (f : α₀ → α₁) (f' : α₁ → α₂) (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀), bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x #align is_lawful_bifunctor LawfulBifunctor export LawfulBifunctor (id_bimap bimap_bimap) attribute [higher_order bimap_id_id] id_bimap #align is_lawful_bifunctor.bimap_id_id LawfulBifunctor.bimap_id_id attribute [higher_order bimap_comp_bimap] bimap_bimap #align is_lawful_bifunctor.bimap_comp_bimap LawfulBifunctor.bimap_comp_bimap export LawfulBifunctor (bimap_id_id bimap_comp_bimap) variable {F : Type u₀ → Type u₁ → Type u₂} [Bifunctor F] namespace Bifunctor /-- Left map of a bifunctor. -/ abbrev fst {α α' β} (f : α → α') : F α β → F α' β := bimap f id #align bifunctor.fst Bifunctor.fst /-- Right map of a bifunctor. -/ abbrev snd {α β β'} (f : β → β') : F α β → F α β' := bimap id f #align bifunctor.snd Bifunctor.snd variable [LawfulBifunctor F] @[higher_order fst_id] theorem id_fst : ∀ {α β} (x : F α β), fst id x = x := @id_bimap _ _ _ #align bifunctor.id_fst Bifunctor.id_fst #align bifunctor.fst_id Bifunctor.fst_id @[higher_order snd_id] theorem id_snd : ∀ {α β} (x : F α β), snd id x = x := @id_bimap _ _ _ #align bifunctor.id_snd Bifunctor.id_snd #align bifunctor.snd_id Bifunctor.snd_id @[higher_order fst_comp_fst]
Mathlib/Control/Bifunctor.lean
86
87
theorem comp_fst {α₀ α₁ α₂ β} (f : α₀ → α₁) (f' : α₁ → α₂) (x : F α₀ β) : fst f' (fst f x) = fst (f' ∘ f) x := by
simp [fst, bimap_bimap]
/- 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.Algebra.MvPolynomial.Rename #align_import data.mv_polynomial.comap from "leanprover-community/mathlib"@"aba31c938d3243cc671be7091b28a1e0814647ee" /-! # `comap` operation on `MvPolynomial` This file defines the `comap` function on `MvPolynomial`. `MvPolynomial.comap` is a low-tech example of a map of "algebraic varieties," modulo the fact that `mathlib` does not yet define varieties. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) -/ namespace MvPolynomial variable {σ : Type*} {τ : Type*} {υ : Type*} {R : Type*} [CommSemiring R] /-- Given an algebra hom `f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R` and a variable evaluation `v : τ → R`, `comap f v` produces a variable evaluation `σ → R`. -/ noncomputable def comap (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) : (τ → R) → σ → R := fun x i => aeval x (f (X i)) #align mv_polynomial.comap MvPolynomial.comap @[simp] theorem comap_apply (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) (x : τ → R) (i : σ) : comap f x i = aeval x (f (X i)) := rfl #align mv_polynomial.comap_apply MvPolynomial.comap_apply @[simp]
Mathlib/Algebra/MvPolynomial/Comap.lean
48
50
theorem comap_id_apply (x : σ → R) : comap (AlgHom.id R (MvPolynomial σ R)) x = x := by
funext i simp only [comap, AlgHom.id_apply, id, aeval_X]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Eric Wieser -/ import Mathlib.Algebra.Quaternion import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Topology.Algebra.Algebra #align_import analysis.quaternion from "leanprover-community/mathlib"@"07992a1d1f7a4176c6d3f160209608be4e198566" /-! # Quaternions as a normed algebra In this file we define the following structures on the space `ℍ := ℍ[ℝ]` of quaternions: * inner product space; * normed ring; * normed space over `ℝ`. We show that the norm on `ℍ[ℝ]` agrees with the euclidean norm of its components. ## Notation The following notation is available with `open Quaternion` or `open scoped Quaternion`: * `ℍ` : quaternions ## Tags quaternion, normed ring, normed space, normed algebra -/ @[inherit_doc] scoped[Quaternion] notation "ℍ" => Quaternion ℝ open scoped RealInnerProductSpace namespace Quaternion instance : Inner ℝ ℍ := ⟨fun a b => (a * star b).re⟩ theorem inner_self (a : ℍ) : ⟪a, a⟫ = normSq a := rfl #align quaternion.inner_self Quaternion.inner_self theorem inner_def (a b : ℍ) : ⟪a, b⟫ = (a * star b).re := rfl #align quaternion.inner_def Quaternion.inner_def noncomputable instance : NormedAddCommGroup ℍ := @InnerProductSpace.Core.toNormedAddCommGroup ℝ ℍ _ _ _ { toInner := inferInstance conj_symm := fun x y => by simp [inner_def, mul_comm] nonneg_re := fun x => normSq_nonneg definite := fun x => normSq_eq_zero.1 add_left := fun x y z => by simp only [inner_def, add_mul, add_re] smul_left := fun x y r => by simp [inner_def] } noncomputable instance : InnerProductSpace ℝ ℍ := InnerProductSpace.ofCore _
Mathlib/Analysis/Quaternion.lean
65
66
theorem normSq_eq_norm_mul_self (a : ℍ) : normSq a = ‖a‖ * ‖a‖ := by
rw [← inner_self, real_inner_self_eq_norm_mul_norm]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse #align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # The argument of a complex number. We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π], such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`, while `arg 0` defaults to `0` -/ open Filter Metric Set open scoped ComplexConjugate Real Topology namespace Complex variable {a x z : ℂ} /-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`, `arg 0` defaults to `0` -/ noncomputable def arg (x : ℂ) : ℝ := if 0 ≤ x.re then Real.arcsin (x.im / abs x) else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π #align complex.arg Complex.arg theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by unfold arg; split_ifs <;> simp [sub_eq_add_neg, arg, Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2, Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg] #align complex.sin_arg Complex.sin_arg theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by rw [arg] split_ifs with h₁ h₂ · rw [Real.cos_arcsin] field_simp [Real.sqrt_sq, (abs.pos hx).le, *] · rw [Real.cos_add_pi, Real.cos_arcsin] field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, _root_.abs_of_neg (not_le.1 h₁), *] · rw [Real.cos_sub_pi, Real.cos_arcsin] field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, _root_.abs_of_neg (not_le.1 h₁), *] #align complex.cos_arg Complex.cos_arg @[simp] theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by rcases eq_or_ne x 0 with (rfl | hx) · simp · have : abs x ≠ 0 := abs.ne_zero hx apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)] set_option linter.uppercaseLean3 false in #align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I @[simp]
Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean
63
64
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
/- Copyright (c) 2022 Anand Rao, Rémi Bottinelli. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anand Rao, Rémi Bottinelli -/ import Mathlib.CategoryTheory.CofilteredSystem import Mathlib.Combinatorics.SimpleGraph.Connectivity import Mathlib.Data.Finite.Set #align_import combinatorics.simple_graph.ends.defs from "leanprover-community/mathlib"@"b99e2d58a5e6861833fa8de11e51a81144258db4" /-! # Ends This file contains a definition of the ends of a simple graph, as sections of the inverse system assigning, to each finite set of vertices, the connected components of its complement. -/ universe u variable {V : Type u} (G : SimpleGraph V) (K L L' M : Set V) namespace SimpleGraph /-- The components outside a given set of vertices `K` -/ abbrev ComponentCompl := (G.induce Kᶜ).ConnectedComponent #align simple_graph.component_compl SimpleGraph.ComponentCompl variable {G} {K L M} /-- The connected component of `v` in `G.induce Kᶜ`. -/ abbrev componentComplMk (G : SimpleGraph V) {v : V} (vK : v ∉ K) : G.ComponentCompl K := connectedComponentMk (G.induce Kᶜ) ⟨v, vK⟩ #align simple_graph.component_compl_mk SimpleGraph.componentComplMk /-- The set of vertices of `G` making up the connected component `C` -/ def ComponentCompl.supp (C : G.ComponentCompl K) : Set V := { v : V | ∃ h : v ∉ K, G.componentComplMk h = C } #align simple_graph.component_compl.supp SimpleGraph.ComponentCompl.supp @[ext]
Mathlib/Combinatorics/SimpleGraph/Ends/Defs.lean
44
49
theorem ComponentCompl.supp_injective : Function.Injective (ComponentCompl.supp : G.ComponentCompl K → Set V) := by
refine ConnectedComponent.ind₂ ?_ rintro ⟨v, hv⟩ ⟨w, hw⟩ h simp only [Set.ext_iff, ConnectedComponent.eq, Set.mem_setOf_eq, ComponentCompl.supp] at h ⊢ exact ((h v).mp ⟨hv, Reachable.refl _⟩).choose_spec
/- Copyright (c) 2014 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Algebra.Group.Support import Mathlib.Algebra.Order.Monoid.WithTop import Mathlib.Data.Nat.Cast.Field #align_import algebra.char_zero.lemmas from "leanprover-community/mathlib"@"acee671f47b8e7972a1eb6f4eed74b4b3abce829" /-! # Characteristic zero (additional theorems) A ring `R` is called of characteristic zero if every natural number `n` is non-zero when considered as an element of `R`. Since this definition doesn't mention the multiplicative structure of `R` except for the existence of `1` in this file characteristic zero is defined for additive monoids with `1`. ## Main statements * Characteristic zero implies that the additive monoid is infinite. -/ open Function Set namespace Nat variable {R : Type*} [AddMonoidWithOne R] [CharZero R] /-- `Nat.cast` as an embedding into monoids of characteristic `0`. -/ @[simps] def castEmbedding : ℕ ↪ R := ⟨Nat.cast, cast_injective⟩ #align nat.cast_embedding Nat.castEmbedding #align nat.cast_embedding_apply Nat.castEmbedding_apply @[simp] theorem cast_pow_eq_one {R : Type*} [Semiring R] [CharZero R] (q : ℕ) (n : ℕ) (hn : n ≠ 0) : (q : R) ^ n = 1 ↔ q = 1 := by rw [← cast_pow, cast_eq_one] exact pow_eq_one_iff hn #align nat.cast_pow_eq_one Nat.cast_pow_eq_one @[simp, norm_cast] theorem cast_div_charZero {k : Type*} [DivisionSemiring k] [CharZero k] {m n : ℕ} (n_dvd : n ∣ m) : ((m / n : ℕ) : k) = m / n := by rcases eq_or_ne n 0 with (rfl | hn) · simp · exact cast_div n_dvd (cast_ne_zero.2 hn) #align nat.cast_div_char_zero Nat.cast_div_charZero end Nat section AddMonoidWithOne variable {α M : Type*} [AddMonoidWithOne M] [CharZero M] {n : ℕ} instance CharZero.NeZero.two : NeZero (2 : M) := ⟨by have : ((2 : ℕ) : M) ≠ 0 := Nat.cast_ne_zero.2 (by decide) rwa [Nat.cast_two] at this⟩ #align char_zero.ne_zero.two CharZero.NeZero.two namespace Function lemma support_natCast (hn : n ≠ 0) : support (n : α → M) = univ := support_const <| Nat.cast_ne_zero.2 hn #align function.support_nat_cast Function.support_natCast @[deprecated (since := "2024-04-17")] alias support_nat_cast := support_natCast lemma mulSupport_natCast (hn : n ≠ 1) : mulSupport (n : α → M) = univ := mulSupport_const <| Nat.cast_ne_one.2 hn #align function.mul_support_nat_cast Function.mulSupport_natCast @[deprecated (since := "2024-04-17")] alias mulSupport_nat_cast := mulSupport_natCast end Function end AddMonoidWithOne section variable {R : Type*} [NonAssocSemiring R] [NoZeroDivisors R] [CharZero R] {a : R} @[simp]
Mathlib/Algebra/CharZero/Lemmas.lean
88
89
theorem add_self_eq_zero {a : R} : a + a = 0 ↔ a = 0 := by
simp only [(two_mul a).symm, mul_eq_zero, two_ne_zero, false_or_iff]
/- 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.Data.Fintype.Order import Mathlib.Data.Set.Finite import Mathlib.Order.Category.FinPartOrd import Mathlib.Order.Category.LinOrd import Mathlib.CategoryTheory.Limits.Shapes.Images import Mathlib.CategoryTheory.Limits.Shapes.RegularMono import Mathlib.Data.Set.Subsingleton #align_import order.category.NonemptyFinLinOrd from "leanprover-community/mathlib"@"fa4a805d16a9cd9c96e0f8edeb57dc5a07af1a19" /-! # Nonempty finite linear orders This defines `NonemptyFinLinOrd`, the category of nonempty finite linear orders with monotone maps. This is the index category for simplicial objects. Note: `NonemptyFinLinOrd` is *not* a subcategory of `FinBddDistLat` because its morphisms do not preserve `⊥` and `⊤`. -/ universe u v open CategoryTheory CategoryTheory.Limits /-- A typeclass for nonempty finite linear orders. -/ class NonemptyFiniteLinearOrder (α : Type*) extends Fintype α, LinearOrder α where Nonempty : Nonempty α := by infer_instance #align nonempty_fin_lin_ord NonemptyFiniteLinearOrder attribute [instance] NonemptyFiniteLinearOrder.Nonempty instance (priority := 100) NonemptyFiniteLinearOrder.toBoundedOrder (α : Type*) [NonemptyFiniteLinearOrder α] : BoundedOrder α := Fintype.toBoundedOrder α #align nonempty_fin_lin_ord.to_bounded_order NonemptyFiniteLinearOrder.toBoundedOrder instance PUnit.nonemptyFiniteLinearOrder : NonemptyFiniteLinearOrder PUnit where #align punit.nonempty_fin_lin_ord PUnit.nonemptyFiniteLinearOrder instance Fin.nonemptyFiniteLinearOrder (n : ℕ) : NonemptyFiniteLinearOrder (Fin (n + 1)) where #align fin.nonempty_fin_lin_ord Fin.nonemptyFiniteLinearOrder instance ULift.nonemptyFiniteLinearOrder (α : Type u) [NonemptyFiniteLinearOrder α] : NonemptyFiniteLinearOrder (ULift.{v} α) := { LinearOrder.lift' Equiv.ulift (Equiv.injective _) with } #align ulift.nonempty_fin_lin_ord ULift.nonemptyFiniteLinearOrder instance (α : Type*) [NonemptyFiniteLinearOrder α] : NonemptyFiniteLinearOrder αᵒᵈ := { OrderDual.fintype α with } /-- The category of nonempty finite linear orders. -/ def NonemptyFinLinOrd := Bundled NonemptyFiniteLinearOrder set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd NonemptyFinLinOrd namespace NonemptyFinLinOrd instance : BundledHom.ParentProjection @NonemptyFiniteLinearOrder.toLinearOrder := ⟨⟩ deriving instance LargeCategory for NonemptyFinLinOrd -- Porting note: probably see https://github.com/leanprover-community/mathlib4/issues/5020 instance : ConcreteCategory NonemptyFinLinOrd := BundledHom.concreteCategory _ instance : CoeSort NonemptyFinLinOrd Type* := Bundled.coeSort /-- Construct a bundled `NonemptyFinLinOrd` from the underlying type and typeclass. -/ def of (α : Type*) [NonemptyFiniteLinearOrder α] : NonemptyFinLinOrd := Bundled.of α set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.of NonemptyFinLinOrd.of @[simp] theorem coe_of (α : Type*) [NonemptyFiniteLinearOrder α] : ↥(of α) = α := rfl set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.coe_of NonemptyFinLinOrd.coe_of instance : Inhabited NonemptyFinLinOrd := ⟨of PUnit⟩ instance (α : NonemptyFinLinOrd) : NonemptyFiniteLinearOrder α := α.str instance hasForgetToLinOrd : HasForget₂ NonemptyFinLinOrd LinOrd := BundledHom.forget₂ _ _ set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.has_forget_to_LinOrd NonemptyFinLinOrd.hasForgetToLinOrd instance hasForgetToFinPartOrd : HasForget₂ NonemptyFinLinOrd FinPartOrd where forget₂ := { obj := fun X => FinPartOrd.of X map := @fun X Y => id } set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.has_forget_to_FinPartOrd NonemptyFinLinOrd.hasForgetToFinPartOrd /-- Constructs an equivalence between nonempty finite linear orders from an order isomorphism between them. -/ @[simps] def Iso.mk {α β : NonemptyFinLinOrd.{u}} (e : α ≃o β) : α ≅ β where hom := (e : OrderHom _ _) inv := (e.symm : OrderHom _ _) hom_inv_id := by ext x exact e.symm_apply_apply x inv_hom_id := by ext x exact e.apply_symm_apply x set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.iso.mk NonemptyFinLinOrd.Iso.mk /-- `OrderDual` as a functor. -/ @[simps] def dual : NonemptyFinLinOrd ⥤ NonemptyFinLinOrd where obj X := of Xᵒᵈ map := OrderHom.dual set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.dual NonemptyFinLinOrd.dual /-- The equivalence between `NonemptyFinLinOrd` and itself induced by `OrderDual` both ways. -/ @[simps functor inverse] def dualEquiv : NonemptyFinLinOrd ≌ NonemptyFinLinOrd where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.dual_equiv NonemptyFinLinOrd.dualEquiv instance {A B : NonemptyFinLinOrd.{u}} : FunLike (A ⟶ B) A B where coe f := ⇑(show OrderHom A B from f) coe_injective' _ _ h := by ext x exact congr_fun h x -- porting note (#10670): this instance was not necessary in mathlib instance {A B : NonemptyFinLinOrd.{u}} : OrderHomClass (A ⟶ B) A B where map_rel f _ _ h := f.monotone h
Mathlib/Order/Category/NonemptyFinLinOrd.lean
150
163
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) : Mono f ↔ Function.Injective f := by
refine ⟨?_, ConcreteCategory.mono_of_injective f⟩ intro intro a₁ a₂ h let X := NonemptyFinLinOrd.of (ULift (Fin 1)) let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩ let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩ change g₁ (ULift.up (0 : Fin 1)) = g₂ (ULift.up (0 : Fin 1)) have eq : g₁ ≫ f = g₂ ≫ f := by ext exact h rw [cancel_mono] at eq rw [eq]
/- Copyright (c) 2022 Yuyang Zhao. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuyang Zhao -/ import Mathlib.Algebra.Algebra.Tower import Mathlib.Algebra.MvPolynomial.Basic #align_import ring_theory.mv_polynomial.tower from "leanprover-community/mathlib"@"bb168510ef455e9280a152e7f31673cabd3d7496" /-! # Algebra towers for multivariate polynomial This file proves some basic results about the algebra tower structure for the type `MvPolynomial σ R`. This structure itself is provided elsewhere as `MvPolynomial.isScalarTower` When you update this file, you can also try to make a corresponding update in `RingTheory.Polynomial.Tower`. -/ variable (R A B : Type*) {σ : Type*} namespace MvPolynomial section Semiring variable [CommSemiring R] [CommSemiring A] [CommSemiring B] variable [Algebra R A] [Algebra A B] [Algebra R B] variable [IsScalarTower R A B] variable {R B} theorem aeval_map_algebraMap (x : σ → B) (p : MvPolynomial σ R) : aeval x (map (algebraMap R A) p) = aeval x p := by rw [aeval_def, aeval_def, eval₂_map, IsScalarTower.algebraMap_eq R A B] #align mv_polynomial.aeval_map_algebra_map MvPolynomial.aeval_map_algebraMap end Semiring section CommSemiring variable [CommSemiring R] [CommSemiring A] [CommSemiring B] variable [Algebra R A] [Algebra A B] [Algebra R B] [IsScalarTower R A B] variable {R A}
Mathlib/RingTheory/MvPolynomial/Tower.lean
48
53
theorem aeval_algebraMap_apply (x : σ → A) (p : MvPolynomial σ R) : aeval (algebraMap A B ∘ x) p = algebraMap A B (MvPolynomial.aeval x p) := by
rw [aeval_def, aeval_def, ← coe_eval₂Hom, ← coe_eval₂Hom, map_eval₂Hom, ← IsScalarTower.algebraMap_eq] -- Porting note: added simp only [Function.comp]
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Polynomial.Degree.TrailingDegree import Mathlib.Algebra.Polynomial.EraseLead import Mathlib.Algebra.Polynomial.Eval #align_import data.polynomial.reverse from "leanprover-community/mathlib"@"44de64f183393284a16016dfb2a48ac97382f2bd" /-! # Reverse of a univariate polynomial The main definition is `reverse`. Applying `reverse` to a polynomial `f : R[X]` produces the polynomial with a reversed list of coefficients, equivalent to `X^f.natDegree * f(1/X)`. The main result is that `reverse (f * g) = reverse f * reverse g`, provided the leading coefficients of `f` and `g` do not multiply to zero. -/ namespace Polynomial open Polynomial Finsupp Finset open Polynomial section Semiring variable {R : Type*} [Semiring R] {f : R[X]} /-- If `i ≤ N`, then `revAtFun N i` returns `N - i`, otherwise it returns `i`. This is the map used by the embedding `revAt`. -/ def revAtFun (N i : ℕ) : ℕ := ite (i ≤ N) (N - i) i #align polynomial.rev_at_fun Polynomial.revAtFun theorem revAtFun_invol {N i : ℕ} : revAtFun N (revAtFun N i) = i := by unfold revAtFun split_ifs with h j · exact tsub_tsub_cancel_of_le h · exfalso apply j exact Nat.sub_le N i · rfl #align polynomial.rev_at_fun_invol Polynomial.revAtFun_invol theorem revAtFun_inj {N : ℕ} : Function.Injective (revAtFun N) := by intro a b hab rw [← @revAtFun_invol N a, hab, revAtFun_invol] #align polynomial.rev_at_fun_inj Polynomial.revAtFun_inj /-- If `i ≤ N`, then `revAt N i` returns `N - i`, otherwise it returns `i`. Essentially, this embedding is only used for `i ≤ N`. The advantage of `revAt N i` over `N - i` is that `revAt` is an involution. -/ def revAt (N : ℕ) : Function.Embedding ℕ ℕ where toFun i := ite (i ≤ N) (N - i) i inj' := revAtFun_inj #align polynomial.rev_at Polynomial.revAt /-- We prefer to use the bundled `revAt` over unbundled `revAtFun`. -/ @[simp] theorem revAtFun_eq (N i : ℕ) : revAtFun N i = revAt N i := rfl #align polynomial.rev_at_fun_eq Polynomial.revAtFun_eq @[simp] theorem revAt_invol {N i : ℕ} : (revAt N) (revAt N i) = i := revAtFun_invol #align polynomial.rev_at_invol Polynomial.revAt_invol @[simp] theorem revAt_le {N i : ℕ} (H : i ≤ N) : revAt N i = N - i := if_pos H #align polynomial.rev_at_le Polynomial.revAt_le lemma revAt_eq_self_of_lt {N i : ℕ} (h : N < i) : revAt N i = i := by simp [revAt, Nat.not_le.mpr h]
Mathlib/Algebra/Polynomial/Reverse.lean
82
88
theorem revAt_add {N O n o : ℕ} (hn : n ≤ N) (ho : o ≤ O) : revAt (N + O) (n + o) = revAt N n + revAt O o := by
rcases Nat.le.dest hn with ⟨n', rfl⟩ rcases Nat.le.dest ho with ⟨o', rfl⟩ repeat' rw [revAt_le (le_add_right rfl.le)] rw [add_assoc, add_left_comm n' o, ← add_assoc, revAt_le (le_add_right rfl.le)] repeat' rw [add_tsub_cancel_left]
/- Copyright (c) 2019 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.FDeriv.Basic #align_import analysis.calculus.fderiv.restrict_scalars from "leanprover-community/mathlib"@"e3fb84046afd187b710170887195d50bada934ee" /-! # The derivative of the scalar restriction of a linear map For detailed documentation of the Fréchet derivative, see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`. This file contains the usual formulas (and existence assertions) for the derivative of the scalar restriction of a linear map. -/ open Filter Asymptotics ContinuousLinearMap Set Metric open scoped Classical open Topology NNReal Filter Asymptotics ENNReal noncomputable section section RestrictScalars /-! ### Restricting from `ℂ` to `ℝ`, or generally from `𝕜'` to `𝕜` If a function is differentiable over `ℂ`, then it is differentiable over `ℝ`. In this paragraph, we give variants of this statement, in the general situation where `ℂ` and `ℝ` are replaced respectively by `𝕜'` and `𝕜` where `𝕜'` is a normed algebra over `𝕜`. -/ variable (𝕜 : Type*) [NontriviallyNormedField 𝕜] variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedSpace 𝕜' E] variable [IsScalarTower 𝕜 𝕜' E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] [NormedSpace 𝕜' F] variable [IsScalarTower 𝕜 𝕜' F] variable {f : E → F} {f' : E →L[𝕜'] F} {s : Set E} {x : E} @[fun_prop] theorem HasStrictFDerivAt.restrictScalars (h : HasStrictFDerivAt f f' x) : HasStrictFDerivAt f (f'.restrictScalars 𝕜) x := h #align has_strict_fderiv_at.restrict_scalars HasStrictFDerivAt.restrictScalars theorem HasFDerivAtFilter.restrictScalars {L} (h : HasFDerivAtFilter f f' x L) : HasFDerivAtFilter f (f'.restrictScalars 𝕜) x L := .of_isLittleO h.1 #align has_fderiv_at_filter.restrict_scalars HasFDerivAtFilter.restrictScalars @[fun_prop] theorem HasFDerivAt.restrictScalars (h : HasFDerivAt f f' x) : HasFDerivAt f (f'.restrictScalars 𝕜) x := .of_isLittleO h.1 #align has_fderiv_at.restrict_scalars HasFDerivAt.restrictScalars @[fun_prop] theorem HasFDerivWithinAt.restrictScalars (h : HasFDerivWithinAt f f' s x) : HasFDerivWithinAt f (f'.restrictScalars 𝕜) s x := .of_isLittleO h.1 #align has_fderiv_within_at.restrict_scalars HasFDerivWithinAt.restrictScalars @[fun_prop] theorem DifferentiableAt.restrictScalars (h : DifferentiableAt 𝕜' f x) : DifferentiableAt 𝕜 f x := (h.hasFDerivAt.restrictScalars 𝕜).differentiableAt #align differentiable_at.restrict_scalars DifferentiableAt.restrictScalars @[fun_prop] theorem DifferentiableWithinAt.restrictScalars (h : DifferentiableWithinAt 𝕜' f s x) : DifferentiableWithinAt 𝕜 f s x := (h.hasFDerivWithinAt.restrictScalars 𝕜).differentiableWithinAt #align differentiable_within_at.restrict_scalars DifferentiableWithinAt.restrictScalars @[fun_prop] theorem DifferentiableOn.restrictScalars (h : DifferentiableOn 𝕜' f s) : DifferentiableOn 𝕜 f s := fun x hx => (h x hx).restrictScalars 𝕜 #align differentiable_on.restrict_scalars DifferentiableOn.restrictScalars @[fun_prop] theorem Differentiable.restrictScalars (h : Differentiable 𝕜' f) : Differentiable 𝕜 f := fun x => (h x).restrictScalars 𝕜 #align differentiable.restrict_scalars Differentiable.restrictScalars @[fun_prop] theorem HasFDerivWithinAt.of_restrictScalars {g' : E →L[𝕜] F} (h : HasFDerivWithinAt f g' s x) (H : f'.restrictScalars 𝕜 = g') : HasFDerivWithinAt f f' s x := by rw [← H] at h exact .of_isLittleO h.1 #align has_fderiv_within_at_of_restrict_scalars HasFDerivWithinAt.of_restrictScalars @[fun_prop]
Mathlib/Analysis/Calculus/FDeriv/RestrictScalars.lean
99
102
theorem hasFDerivAt_of_restrictScalars {g' : E →L[𝕜] F} (h : HasFDerivAt f g' x) (H : f'.restrictScalars 𝕜 = g') : HasFDerivAt f f' x := by
rw [← H] at h exact .of_isLittleO h.1
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.BoxIntegral.Partition.Additive import Mathlib.MeasureTheory.Measure.Lebesgue.Basic #align_import analysis.box_integral.partition.measure from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Box-additive functions defined by measures In this file we prove a few simple facts about rectangular boxes, partitions, and measures: - given a box `I : Box ι`, its coercion to `Set (ι → ℝ)` and `I.Icc` are measurable sets; - if `μ` is a locally finite measure, then `(I : Set (ι → ℝ))` and `I.Icc` have finite measure; - if `μ` is a locally finite measure, then `fun J ↦ (μ J).toReal` is a box additive function. For the last statement, we both prove it as a proposition and define a bundled `BoxIntegral.BoxAdditiveMap` function. ## Tags rectangular box, measure -/ open Set noncomputable section open scoped ENNReal Classical BoxIntegral variable {ι : Type*} namespace BoxIntegral open MeasureTheory namespace Box variable (I : Box ι) theorem measure_Icc_lt_top (μ : Measure (ι → ℝ)) [IsLocallyFiniteMeasure μ] : μ (Box.Icc I) < ∞ := show μ (Icc I.lower I.upper) < ∞ from I.isCompact_Icc.measure_lt_top #align box_integral.box.measure_Icc_lt_top BoxIntegral.Box.measure_Icc_lt_top theorem measure_coe_lt_top (μ : Measure (ι → ℝ)) [IsLocallyFiniteMeasure μ] : μ I < ∞ := (measure_mono <| coe_subset_Icc).trans_lt (I.measure_Icc_lt_top μ) #align box_integral.box.measure_coe_lt_top BoxIntegral.Box.measure_coe_lt_top section Countable variable [Countable ι] theorem measurableSet_coe : MeasurableSet (I : Set (ι → ℝ)) := by rw [coe_eq_pi] exact MeasurableSet.univ_pi fun i => measurableSet_Ioc #align box_integral.box.measurable_set_coe BoxIntegral.Box.measurableSet_coe theorem measurableSet_Icc : MeasurableSet (Box.Icc I) := _root_.measurableSet_Icc #align box_integral.box.measurable_set_Icc BoxIntegral.Box.measurableSet_Icc theorem measurableSet_Ioo : MeasurableSet (Box.Ioo I) := MeasurableSet.univ_pi fun _ => _root_.measurableSet_Ioo #align box_integral.box.measurable_set_Ioo BoxIntegral.Box.measurableSet_Ioo end Countable variable [Fintype ι]
Mathlib/Analysis/BoxIntegral/Partition/Measure.lean
74
76
theorem coe_ae_eq_Icc : (I : Set (ι → ℝ)) =ᵐ[volume] Box.Icc I := by
rw [coe_eq_pi] exact Measure.univ_pi_Ioc_ae_eq_Icc
/- 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
Mathlib/LinearAlgebra/AffineSpace/Ordered.lean
57
59
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)) _
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Category.GroupCat.Abelian import Mathlib.CategoryTheory.Limits.Shapes.Images #align_import algebra.category.Group.images from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # The category of commutative additive groups has images. Note that we don't need to register any of the constructions here as instances, because we get them from the fact that `AddCommGroupCat` is an abelian category. -/ open CategoryTheory open CategoryTheory.Limits universe u namespace AddCommGroupCat set_option linter.uppercaseLean3 false -- Note that because `injective_of_mono` is currently only proved in `Type 0`, -- we restrict to the lowest universe here for now. variable {G H : AddCommGroupCat.{0}} (f : G ⟶ H) attribute [local ext] Subtype.ext_val section -- implementation details of `IsImage` for `AddCommGroupCat`; use the API, not these /-- the image of a morphism in `AddCommGroupCat` is just the bundling of `AddMonoidHom.range f` -/ def image : AddCommGroupCat := AddCommGroupCat.of (AddMonoidHom.range f) #align AddCommGroup.image AddCommGroupCat.image /-- the inclusion of `image f` into the target -/ def image.ι : image f ⟶ H := f.range.subtype #align AddCommGroup.image.ι AddCommGroupCat.image.ι instance : Mono (image.ι f) := ConcreteCategory.mono_of_injective (image.ι f) Subtype.val_injective /-- the corestriction map to the image -/ def factorThruImage : G ⟶ image f := f.rangeRestrict #align AddCommGroup.factor_thru_image AddCommGroupCat.factorThruImage theorem image.fac : factorThruImage f ≫ image.ι f = f := by ext rfl #align AddCommGroup.image.fac AddCommGroupCat.image.fac attribute [local simp] image.fac variable {f} /-- the universal property for the image factorisation -/ noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I) map_zero' := by haveI := F'.m_mono apply injective_of_mono F'.m change (F'.e ≫ F'.m) _ = _ rw [F'.fac, AddMonoidHom.map_zero] exact (Classical.indefiniteDescription (fun y => f y = 0) _).2 map_add' := by intro x y haveI := F'.m_mono apply injective_of_mono F'.m rw [AddMonoidHom.map_add] change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _ rw [F'.fac] rw [(Classical.indefiniteDescription (fun z => f z = _) _).2] rw [(Classical.indefiniteDescription (fun z => f z = _) _).2] rw [(Classical.indefiniteDescription (fun z => f z = _) _).2] rfl #align AddCommGroup.image.lift AddCommGroupCat.image.lift
Mathlib/Algebra/Category/GroupCat/Images.lean
87
91
theorem image.lift_fac (F' : MonoFactorisation f) : image.lift F' ≫ F'.m = image.ι f := by
ext x change (F'.e ≫ F'.m) _ = _ rw [F'.fac, (Classical.indefiniteDescription _ x.2).2] rfl
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Yaël Dillies -/ import Mathlib.LinearAlgebra.Ray import Mathlib.Analysis.NormedSpace.Real #align_import analysis.normed_space.ray from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" /-! # Rays in a real normed vector space In this file we prove some lemmas about the `SameRay` predicate in case of a real normed space. In this case, for two vectors `x y` in the same ray, the norm of their sum is equal to the sum of their norms and `‖y‖ • x = ‖x‖ • y`. -/ open Real variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] namespace SameRay variable {x y : E} /-- If `x` and `y` are on the same ray, then the triangle inequality becomes the equality: the norm of `x + y` is the sum of the norms of `x` and `y`. The converse is true for a strictly convex space. -/ theorem norm_add (h : SameRay ℝ x y) : ‖x + y‖ = ‖x‖ + ‖y‖ := by rcases h.exists_eq_smul with ⟨u, a, b, ha, hb, -, rfl, rfl⟩ rw [← add_smul, norm_smul_of_nonneg (add_nonneg ha hb), norm_smul_of_nonneg ha, norm_smul_of_nonneg hb, add_mul] #align same_ray.norm_add SameRay.norm_add theorem norm_sub (h : SameRay ℝ x y) : ‖x - y‖ = |‖x‖ - ‖y‖| := by rcases h.exists_eq_smul with ⟨u, a, b, ha, hb, -, rfl, rfl⟩ wlog hab : b ≤ a generalizing a b with H · rw [SameRay.sameRay_comm] at h rw [norm_sub_rev, abs_sub_comm] exact H b a hb ha h (le_of_not_le hab) rw [← sub_nonneg] at hab rw [← sub_smul, norm_smul_of_nonneg hab, norm_smul_of_nonneg ha, norm_smul_of_nonneg hb, ← sub_mul, abs_of_nonneg (mul_nonneg hab (norm_nonneg _))] #align same_ray.norm_sub SameRay.norm_sub theorem norm_smul_eq (h : SameRay ℝ x y) : ‖x‖ • y = ‖y‖ • x := by rcases h.exists_eq_smul with ⟨u, a, b, ha, hb, -, rfl, rfl⟩ simp only [norm_smul_of_nonneg, *, mul_smul] rw [smul_comm, smul_comm b, smul_comm a b u] #align same_ray.norm_smul_eq SameRay.norm_smul_eq end SameRay variable {x y : F}
Mathlib/Analysis/NormedSpace/Ray.lean
59
65
theorem norm_injOn_ray_left (hx : x ≠ 0) : { y | SameRay ℝ x y }.InjOn norm := by
rintro y hy z hz h rcases hy.exists_nonneg_left hx with ⟨r, hr, rfl⟩ rcases hz.exists_nonneg_left hx with ⟨s, hs, rfl⟩ rw [norm_smul, norm_smul, mul_left_inj' (norm_ne_zero_iff.2 hx), norm_of_nonneg hr, norm_of_nonneg hs] at h rw [h]
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Order.Interval.Set.OrdConnectedComponent import Mathlib.Topology.Order.Basic #align_import topology.algebra.order.t5 from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" /-! # Linear order is a completely normal Hausdorff topological space In this file we prove that a linear order with order topology is a completely normal Hausdorff topological space. -/ open Filter Set Function OrderDual Topology Interval variable {X : Type*} [LinearOrder X] [TopologicalSpace X] [OrderTopology X] {a b c : X} {s t : Set X} namespace Set @[simp]
Mathlib/Topology/Order/T5.lean
27
30
theorem ordConnectedComponent_mem_nhds : ordConnectedComponent s a ∈ 𝓝 a ↔ s ∈ 𝓝 a := by
refine ⟨fun h => mem_of_superset h ordConnectedComponent_subset, fun h => ?_⟩ rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩ exact mem_of_superset ha' (subset_ordConnectedComponent ha hs)
/- 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.Data.Int.Bitwise import Mathlib.Data.Int.Order.Lemmas import Mathlib.Data.Set.Function import Mathlib.Order.Interval.Set.Basic #align_import data.int.lemmas from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f" /-! # Miscellaneous lemmas about the integers This file contains lemmas about integers, which require further imports than `Data.Int.Basic` or `Data.Int.Order`. -/ open Nat namespace Int theorem le_natCast_sub (m n : ℕ) : (m - n : ℤ) ≤ ↑(m - n : ℕ) := by by_cases h : m ≥ n · exact le_of_eq (Int.ofNat_sub h).symm · simp [le_of_not_ge h, ofNat_le] #align int.le_coe_nat_sub Int.le_natCast_sub /-! ### `succ` and `pred` -/ -- Porting note (#10618): simp can prove this @[simp] theorem succ_natCast_pos (n : ℕ) : 0 < (n : ℤ) + 1 := lt_add_one_iff.mpr (by simp) #align int.succ_coe_nat_pos Int.succ_natCast_pos /-! ### `natAbs` -/ variable {a b : ℤ} {n : ℕ} theorem natAbs_eq_iff_sq_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a ^ 2 = b ^ 2 := by rw [sq, sq] exact natAbs_eq_iff_mul_self_eq #align int.nat_abs_eq_iff_sq_eq Int.natAbs_eq_iff_sq_eq theorem natAbs_lt_iff_sq_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a ^ 2 < b ^ 2 := by rw [sq, sq] exact natAbs_lt_iff_mul_self_lt #align int.nat_abs_lt_iff_sq_lt Int.natAbs_lt_iff_sq_lt theorem natAbs_le_iff_sq_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a ^ 2 ≤ b ^ 2 := by rw [sq, sq] exact natAbs_le_iff_mul_self_le #align int.nat_abs_le_iff_sq_le Int.natAbs_le_iff_sq_le theorem natAbs_inj_of_nonneg_of_nonneg {a b : ℤ} (ha : 0 ≤ a) (hb : 0 ≤ b) : natAbs a = natAbs b ↔ a = b := by rw [← sq_eq_sq ha hb, ← natAbs_eq_iff_sq_eq] #align int.nat_abs_inj_of_nonneg_of_nonneg Int.natAbs_inj_of_nonneg_of_nonneg theorem natAbs_inj_of_nonpos_of_nonpos {a b : ℤ} (ha : a ≤ 0) (hb : b ≤ 0) : natAbs a = natAbs b ↔ a = b := by simpa only [Int.natAbs_neg, neg_inj] using natAbs_inj_of_nonneg_of_nonneg (neg_nonneg_of_nonpos ha) (neg_nonneg_of_nonpos hb) #align int.nat_abs_inj_of_nonpos_of_nonpos Int.natAbs_inj_of_nonpos_of_nonpos theorem natAbs_inj_of_nonneg_of_nonpos {a b : ℤ} (ha : 0 ≤ a) (hb : b ≤ 0) : natAbs a = natAbs b ↔ a = -b := by simpa only [Int.natAbs_neg] using natAbs_inj_of_nonneg_of_nonneg ha (neg_nonneg_of_nonpos hb) #align int.nat_abs_inj_of_nonneg_of_nonpos Int.natAbs_inj_of_nonneg_of_nonpos theorem natAbs_inj_of_nonpos_of_nonneg {a b : ℤ} (ha : a ≤ 0) (hb : 0 ≤ b) : natAbs a = natAbs b ↔ -a = b := by simpa only [Int.natAbs_neg] using natAbs_inj_of_nonneg_of_nonneg (neg_nonneg_of_nonpos ha) hb #align int.nat_abs_inj_of_nonpos_of_nonneg Int.natAbs_inj_of_nonpos_of_nonneg /-- A specialization of `abs_sub_le_of_nonneg_of_le` for working with the signed subtraction of natural numbers. -/
Mathlib/Data/Int/Lemmas.lean
82
86
theorem natAbs_coe_sub_coe_le_of_le {a b n : ℕ} (a_le_n : a ≤ n) (b_le_n : b ≤ n) : natAbs (a - b : ℤ) ≤ n := by
rw [← Nat.cast_le (α := ℤ), natCast_natAbs] exact abs_sub_le_of_nonneg_of_le (ofNat_nonneg a) (ofNat_le.mpr a_le_n) (ofNat_nonneg b) (ofNat_le.mpr b_le_n)
/- 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.LinearAlgebra.FiniteDimensional import Mathlib.LinearAlgebra.GeneralLinearGroup import Mathlib.LinearAlgebra.Matrix.Reindex import Mathlib.Tactic.FieldSimp import Mathlib.LinearAlgebra.Matrix.NonsingularInverse import Mathlib.LinearAlgebra.Matrix.Basis #align_import linear_algebra.determinant from "leanprover-community/mathlib"@"0c1d80f5a86b36c1db32e021e8d19ae7809d5b79" /-! # Determinant of families of vectors This file defines the determinant of an endomorphism, and of a family of vectors with respect to some basis. For the determinant of a matrix, see the file `LinearAlgebra.Matrix.Determinant`. ## Main definitions In the list below, and in all this file, `R` is a commutative ring (semiring is sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite types used for indexing. * `Basis.det`: the determinant of a family of vectors with respect to a basis, as a multilinear map * `LinearMap.det`: the determinant of an endomorphism `f : End R M` as a multiplicative homomorphism (if `M` does not have a finite `R`-basis, the result is `1` instead) * `LinearEquiv.det`: the determinant of an isomorphism `f : M ≃ₗ[R] M` as a multiplicative homomorphism (if `M` does not have a finite `R`-basis, the result is `1` instead) ## Tags basis, det, determinant -/ noncomputable section open Matrix LinearMap Submodule Set Function universe u v w variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {M' : Type*} [AddCommGroup M'] [Module R M'] variable {ι : Type*} [DecidableEq ι] [Fintype ι] variable (e : Basis ι R M) section Conjugate variable {A : Type*} [CommRing A] variable {m n : Type*} /-- If `R^m` and `R^n` are linearly equivalent, then `m` and `n` are also equivalent. -/ def equivOfPiLEquivPi {R : Type*} [Finite m] [Finite n] [CommRing R] [Nontrivial R] (e : (m → R) ≃ₗ[R] n → R) : m ≃ n := Basis.indexEquiv (Basis.ofEquivFun e.symm) (Pi.basisFun _ _) #align equiv_of_pi_lequiv_pi equivOfPiLEquivPi namespace Matrix variable [Fintype m] [Fintype n] /-- If `M` and `M'` are each other's inverse matrices, they are square matrices up to equivalence of types. -/ def indexEquivOfInv [Nontrivial A] [DecidableEq m] [DecidableEq n] {M : Matrix m n A} {M' : Matrix n m A} (hMM' : M * M' = 1) (hM'M : M' * M = 1) : m ≃ n := equivOfPiLEquivPi (toLin'OfInv hMM' hM'M) #align matrix.index_equiv_of_inv Matrix.indexEquivOfInv theorem det_comm [DecidableEq n] (M N : Matrix n n A) : det (M * N) = det (N * M) := by rw [det_mul, det_mul, mul_comm] #align matrix.det_comm Matrix.det_comm /-- If there exists a two-sided inverse `M'` for `M` (indexed differently), then `det (N * M) = det (M * N)`. -/ theorem det_comm' [DecidableEq m] [DecidableEq n] {M : Matrix n m A} {N : Matrix m n A} {M' : Matrix m n A} (hMM' : M * M' = 1) (hM'M : M' * M = 1) : det (M * N) = det (N * M) := by nontriviality A -- Although `m` and `n` are different a priori, we will show they have the same cardinality. -- This turns the problem into one for square matrices, which is easy. let e := indexEquivOfInv hMM' hM'M rw [← det_submatrix_equiv_self e, ← submatrix_mul_equiv _ _ _ (Equiv.refl n) _, det_comm, submatrix_mul_equiv, Equiv.coe_refl, submatrix_id_id] #align matrix.det_comm' Matrix.det_comm' /-- If `M'` is a two-sided inverse for `M` (indexed differently), `det (M * N * M') = det N`. See `Matrix.det_conj` and `Matrix.det_conj'` for the case when `M' = M⁻¹` or vice versa. -/ theorem det_conj_of_mul_eq_one [DecidableEq m] [DecidableEq n] {M : Matrix m n A} {M' : Matrix n m A} {N : Matrix n n A} (hMM' : M * M' = 1) (hM'M : M' * M = 1) : det (M * N * M') = det N := by rw [← det_comm' hM'M hMM', ← Matrix.mul_assoc, hM'M, Matrix.one_mul] #align matrix.det_conj_of_mul_eq_one Matrix.det_conj_of_mul_eq_one end Matrix end Conjugate namespace LinearMap /-! ### Determinant of a linear map -/ variable {A : Type*} [CommRing A] [Module A M] variable {κ : Type*} [Fintype κ] /-- The determinant of `LinearMap.toMatrix` does not depend on the choice of basis. -/
Mathlib/LinearAlgebra/Determinant.lean
115
119
theorem det_toMatrix_eq_det_toMatrix [DecidableEq κ] (b : Basis ι A M) (c : Basis κ A M) (f : M →ₗ[A] M) : det (LinearMap.toMatrix b b f) = det (LinearMap.toMatrix c c f) := by
rw [← linearMap_toMatrix_mul_basis_toMatrix c b c, ← basis_toMatrix_mul_linearMap_toMatrix b c b, Matrix.det_conj_of_mul_eq_one] <;> rw [Basis.toMatrix_mul_toMatrix, Basis.toMatrix_self]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, Scott Morrison -/ import Mathlib.CategoryTheory.Subobject.Basic import Mathlib.CategoryTheory.Preadditive.Basic #align_import category_theory.subobject.factor_thru from "leanprover-community/mathlib"@"829895f162a1f29d0133f4b3538f4cd1fb5bffd3" /-! # Factoring through subobjects The predicate `h : P.Factors f`, for `P : Subobject Y` and `f : X ⟶ Y` asserts the existence of some `P.factorThru f : X ⟶ (P : C)` making the obvious diagram commute. -/ universe v₁ v₂ u₁ u₂ noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] namespace CategoryTheory namespace MonoOver /-- When `f : X ⟶ Y` and `P : MonoOver Y`, `P.Factors f` expresses that there exists a factorisation of `f` through `P`. Given `h : P.Factors f`, you can recover the morphism as `P.factorThru f h`. -/ def Factors {X Y : C} (P : MonoOver Y) (f : X ⟶ Y) : Prop := ∃ g : X ⟶ (P : C), g ≫ P.arrow = f #align category_theory.mono_over.factors CategoryTheory.MonoOver.Factors theorem factors_congr {X : C} {f g : MonoOver X} {Y : C} (h : Y ⟶ X) (e : f ≅ g) : f.Factors h ↔ g.Factors h := ⟨fun ⟨u, hu⟩ => ⟨u ≫ ((MonoOver.forget _).map e.hom).left, by simp [hu]⟩, fun ⟨u, hu⟩ => ⟨u ≫ ((MonoOver.forget _).map e.inv).left, by simp [hu]⟩⟩ #align category_theory.mono_over.factors_congr CategoryTheory.MonoOver.factors_congr /-- `P.factorThru f h` provides a factorisation of `f : X ⟶ Y` through some `P : MonoOver Y`, given the evidence `h : P.Factors f` that such a factorisation exists. -/ def factorThru {X Y : C} (P : MonoOver Y) (f : X ⟶ Y) (h : Factors P f) : X ⟶ (P : C) := Classical.choose h #align category_theory.mono_over.factor_thru CategoryTheory.MonoOver.factorThru end MonoOver namespace Subobject /-- When `f : X ⟶ Y` and `P : Subobject Y`, `P.Factors f` expresses that there exists a factorisation of `f` through `P`. Given `h : P.Factors f`, you can recover the morphism as `P.factorThru f h`. -/ def Factors {X Y : C} (P : Subobject Y) (f : X ⟶ Y) : Prop := Quotient.liftOn' P (fun P => P.Factors f) (by rintro P Q ⟨h⟩ apply propext constructor · rintro ⟨i, w⟩ exact ⟨i ≫ h.hom.left, by erw [Category.assoc, Over.w h.hom, w]⟩ · rintro ⟨i, w⟩ exact ⟨i ≫ h.inv.left, by erw [Category.assoc, Over.w h.inv, w]⟩) #align category_theory.subobject.factors CategoryTheory.Subobject.Factors @[simp] theorem mk_factors_iff {X Y Z : C} (f : Y ⟶ X) [Mono f] (g : Z ⟶ X) : (Subobject.mk f).Factors g ↔ (MonoOver.mk' f).Factors g := Iff.rfl #align category_theory.subobject.mk_factors_iff CategoryTheory.Subobject.mk_factors_iff theorem mk_factors_self (f : X ⟶ Y) [Mono f] : (mk f).Factors f := ⟨𝟙 _, by simp⟩ #align category_theory.subobject.mk_factors_self CategoryTheory.Subobject.mk_factors_self theorem factors_iff {X Y : C} (P : Subobject Y) (f : X ⟶ Y) : P.Factors f ↔ (representative.obj P).Factors f := Quot.inductionOn P fun _ => MonoOver.factors_congr _ (representativeIso _).symm #align category_theory.subobject.factors_iff CategoryTheory.Subobject.factors_iff theorem factors_self {X : C} (P : Subobject X) : P.Factors P.arrow := (factors_iff _ _).mpr ⟨𝟙 (P : C), by simp⟩ #align category_theory.subobject.factors_self CategoryTheory.Subobject.factors_self theorem factors_comp_arrow {X Y : C} {P : Subobject Y} (f : X ⟶ P) : P.Factors (f ≫ P.arrow) := (factors_iff _ _).mpr ⟨f, rfl⟩ #align category_theory.subobject.factors_comp_arrow CategoryTheory.Subobject.factors_comp_arrow
Mathlib/CategoryTheory/Subobject/FactorThru.lean
96
100
theorem factors_of_factors_right {X Y Z : C} {P : Subobject Z} (f : X ⟶ Y) {g : Y ⟶ Z} (h : P.Factors g) : P.Factors (f ≫ g) := by
induction' P using Quotient.ind' with P obtain ⟨g, rfl⟩ := h exact ⟨f ≫ 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, Jeremy Avigad, Yury Kudryashov -/ import Mathlib.Order.Filter.AtTopBot import Mathlib.Order.Filter.Pi #align_import order.filter.cofinite from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # The cofinite filter In this file we define `Filter.cofinite`: the filter of sets with finite complement and prove its basic properties. In particular, we prove that for `ℕ` it is equal to `Filter.atTop`. ## TODO Define filters for other cardinalities of the complement. -/ open Set Function variable {ι α β : Type*} {l : Filter α} namespace Filter /-- The cofinite filter is the filter of subsets whose complements are finite. -/ def cofinite : Filter α := comk Set.Finite finite_empty (fun _t ht _s hsub ↦ ht.subset hsub) fun _ h _ ↦ h.union #align filter.cofinite Filter.cofinite @[simp] theorem mem_cofinite {s : Set α} : s ∈ @cofinite α ↔ sᶜ.Finite := Iff.rfl #align filter.mem_cofinite Filter.mem_cofinite @[simp] theorem eventually_cofinite {p : α → Prop} : (∀ᶠ x in cofinite, p x) ↔ { x | ¬p x }.Finite := Iff.rfl #align filter.eventually_cofinite Filter.eventually_cofinite theorem hasBasis_cofinite : HasBasis cofinite (fun s : Set α => s.Finite) compl := ⟨fun s => ⟨fun h => ⟨sᶜ, h, (compl_compl s).subset⟩, fun ⟨_t, htf, hts⟩ => htf.subset <| compl_subset_comm.2 hts⟩⟩ #align filter.has_basis_cofinite Filter.hasBasis_cofinite instance cofinite_neBot [Infinite α] : NeBot (@cofinite α) := hasBasis_cofinite.neBot_iff.2 fun hs => hs.infinite_compl.nonempty #align filter.cofinite_ne_bot Filter.cofinite_neBot @[simp] theorem cofinite_eq_bot_iff : @cofinite α = ⊥ ↔ Finite α := by simp [← empty_mem_iff_bot, finite_univ_iff] @[simp] theorem cofinite_eq_bot [Finite α] : @cofinite α = ⊥ := cofinite_eq_bot_iff.2 ‹_› theorem frequently_cofinite_iff_infinite {p : α → Prop} : (∃ᶠ x in cofinite, p x) ↔ Set.Infinite { x | p x } := by simp only [Filter.Frequently, eventually_cofinite, not_not, Set.Infinite] #align filter.frequently_cofinite_iff_infinite Filter.frequently_cofinite_iff_infinite lemma frequently_cofinite_mem_iff_infinite {s : Set α} : (∃ᶠ x in cofinite, x ∈ s) ↔ s.Infinite := frequently_cofinite_iff_infinite alias ⟨_, _root_.Set.Infinite.frequently_cofinite⟩ := frequently_cofinite_mem_iff_infinite @[simp] lemma cofinite_inf_principal_neBot_iff {s : Set α} : (cofinite ⊓ 𝓟 s).NeBot ↔ s.Infinite := frequently_mem_iff_neBot.symm.trans frequently_cofinite_mem_iff_infinite alias ⟨_, _root_.Set.Infinite.cofinite_inf_principal_neBot⟩ := cofinite_inf_principal_neBot_iff theorem _root_.Set.Finite.compl_mem_cofinite {s : Set α} (hs : s.Finite) : sᶜ ∈ @cofinite α := mem_cofinite.2 <| (compl_compl s).symm ▸ hs #align set.finite.compl_mem_cofinite Set.Finite.compl_mem_cofinite theorem _root_.Set.Finite.eventually_cofinite_nmem {s : Set α} (hs : s.Finite) : ∀ᶠ x in cofinite, x ∉ s := hs.compl_mem_cofinite #align set.finite.eventually_cofinite_nmem Set.Finite.eventually_cofinite_nmem theorem _root_.Finset.eventually_cofinite_nmem (s : Finset α) : ∀ᶠ x in cofinite, x ∉ s := s.finite_toSet.eventually_cofinite_nmem #align finset.eventually_cofinite_nmem Finset.eventually_cofinite_nmem theorem _root_.Set.infinite_iff_frequently_cofinite {s : Set α} : Set.Infinite s ↔ ∃ᶠ x in cofinite, x ∈ s := frequently_cofinite_iff_infinite.symm #align set.infinite_iff_frequently_cofinite Set.infinite_iff_frequently_cofinite theorem eventually_cofinite_ne (x : α) : ∀ᶠ a in cofinite, a ≠ x := (Set.finite_singleton x).eventually_cofinite_nmem #align filter.eventually_cofinite_ne Filter.eventually_cofinite_ne
Mathlib/Order/Filter/Cofinite.lean
101
104
theorem le_cofinite_iff_compl_singleton_mem : l ≤ cofinite ↔ ∀ x, {x}ᶜ ∈ l := by
refine ⟨fun h x => h (finite_singleton x).compl_mem_cofinite, fun h s (hs : sᶜ.Finite) => ?_⟩ rw [← compl_compl s, ← biUnion_of_singleton sᶜ, compl_iUnion₂, Filter.biInter_mem hs] exact fun x _ => h x
/- 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.Data.Finset.Lattice import Mathlib.Order.Hom.Basic import Mathlib.Data.Set.Finite import Mathlib.Order.ConditionallyCompleteLattice.Basic #align_import order.partial_sups from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce" /-! # The monotone sequence of partial supremums of a sequence We define `partialSups : (ℕ → α) → ℕ →o α` inductively. For `f : ℕ → α`, `partialSups f` is the sequence `f 0`, `f 0 ⊔ f 1`, `f 0 ⊔ f 1 ⊔ f 2`, ... The point of this definition is that * it doesn't need a `⨆`, as opposed to `⨆ (i ≤ n), f i` (which also means the wrong thing on `ConditionallyCompleteLattice`s). * it doesn't need a `⊥`, as opposed to `(Finset.range (n + 1)).sup f`. * it avoids needing to prove that `Finset.range (n + 1)` is nonempty to use `Finset.sup'`. Equivalence with those definitions is shown by `partialSups_eq_biSup`, `partialSups_eq_sup_range`, and `partialSups_eq_sup'_range` respectively. ## Notes One might dispute whether this sequence should start at `f 0` or `⊥`. We choose the former because : * Starting at `⊥` requires... having a bottom element. * `fun f n ↦ (Finset.range n).sup f` is already effectively the sequence starting at `⊥`. * If we started at `⊥` we wouldn't have the Galois insertion. See `partialSups.gi`. ## TODO One could generalize `partialSups` to any locally finite bot preorder domain, in place of `ℕ`. Necessary for the TODO in the module docstring of `Order.disjointed`. -/ variable {α : Type*} section SemilatticeSup variable [SemilatticeSup α] /-- The monotone sequence whose value at `n` is the supremum of the `f m` where `m ≤ n`. -/ def partialSups (f : ℕ → α) : ℕ →o α := ⟨@Nat.rec (fun _ => α) (f 0) fun (n : ℕ) (a : α) => a ⊔ f (n + 1), monotone_nat_of_le_succ fun _ => le_sup_left⟩ #align partial_sups partialSups @[simp] theorem partialSups_zero (f : ℕ → α) : partialSups f 0 = f 0 := rfl #align partial_sups_zero partialSups_zero @[simp] theorem partialSups_succ (f : ℕ → α) (n : ℕ) : partialSups f (n + 1) = partialSups f n ⊔ f (n + 1) := rfl #align partial_sups_succ partialSups_succ lemma partialSups_iff_forall {f : ℕ → α} (p : α → Prop) (hp : ∀ {a b}, p (a ⊔ b) ↔ p a ∧ p b) : ∀ {n : ℕ}, p (partialSups f n) ↔ ∀ k ≤ n, p (f k) | 0 => by simp | (n + 1) => by simp [hp, partialSups_iff_forall, ← Nat.lt_succ_iff, ← Nat.forall_lt_succ] @[simp] lemma partialSups_le_iff {f : ℕ → α} {n : ℕ} {a : α} : partialSups f n ≤ a ↔ ∀ k ≤ n, f k ≤ a := partialSups_iff_forall (· ≤ a) sup_le_iff theorem le_partialSups_of_le (f : ℕ → α) {m n : ℕ} (h : m ≤ n) : f m ≤ partialSups f n := partialSups_le_iff.1 le_rfl m h #align le_partial_sups_of_le le_partialSups_of_le theorem le_partialSups (f : ℕ → α) : f ≤ partialSups f := fun _n => le_partialSups_of_le f le_rfl #align le_partial_sups le_partialSups theorem partialSups_le (f : ℕ → α) (n : ℕ) (a : α) (w : ∀ m, m ≤ n → f m ≤ a) : partialSups f n ≤ a := partialSups_le_iff.2 w #align partial_sups_le partialSups_le @[simp] lemma upperBounds_range_partialSups (f : ℕ → α) : upperBounds (Set.range (partialSups f)) = upperBounds (Set.range f) := by ext a simp only [mem_upperBounds, Set.forall_mem_range, partialSups_le_iff] exact ⟨fun h _ ↦ h _ _ le_rfl, fun h _ _ _ ↦ h _⟩ @[simp] theorem bddAbove_range_partialSups {f : ℕ → α} : BddAbove (Set.range (partialSups f)) ↔ BddAbove (Set.range f) := .of_eq <| congr_arg Set.Nonempty <| upperBounds_range_partialSups f #align bdd_above_range_partial_sups bddAbove_range_partialSups
Mathlib/Order/PartialSups.lean
97
101
theorem Monotone.partialSups_eq {f : ℕ → α} (hf : Monotone f) : (partialSups f : ℕ → α) = f := by
ext n induction' n with n ih · rfl · rw [partialSups_succ, ih, sup_eq_right.2 (hf (Nat.le_succ _))]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker -/ import Mathlib.Algebra.MonoidAlgebra.Degree import Mathlib.Algebra.Polynomial.Coeff import Mathlib.Algebra.Polynomial.Monomial import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.Nat.WithBot import Mathlib.Data.Nat.Cast.WithTop import Mathlib.Data.Nat.SuccPred #align_import data.polynomial.degree.definitions from "leanprover-community/mathlib"@"808ea4ebfabeb599f21ec4ae87d6dc969597887f" /-! # Theory of univariate polynomials The definitions include `degree`, `Monic`, `leadingCoeff` Results include - `degree_mul` : The degree of the product is the sum of degrees - `leadingCoeff_add_of_degree_eq` and `leadingCoeff_add_of_degree_lt` : The leading_coefficient of a sum is determined by the leading coefficients and degrees -/ -- Porting note: `Mathlib.Data.Nat.Cast.WithTop` should be imported for `Nat.cast_withBot`. set_option linter.uppercaseLean3 false noncomputable section open Finsupp Finset open Polynomial namespace Polynomial universe u v variable {R : Type u} {S : Type v} {a b c d : R} {n m : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} /-- `degree p` is the degree of the polynomial `p`, i.e. the largest `X`-exponent in `p`. `degree p = some n` when `p ≠ 0` and `n` is the highest power of `X` that appears in `p`, otherwise `degree 0 = ⊥`. -/ def degree (p : R[X]) : WithBot ℕ := p.support.max #align polynomial.degree Polynomial.degree theorem supDegree_eq_degree (p : R[X]) : p.toFinsupp.supDegree WithBot.some = p.degree := max_eq_sup_coe theorem degree_lt_wf : WellFounded fun p q : R[X] => degree p < degree q := InvImage.wf degree wellFounded_lt #align polynomial.degree_lt_wf Polynomial.degree_lt_wf instance : WellFoundedRelation R[X] := ⟨_, degree_lt_wf⟩ /-- `natDegree p` forces `degree p` to ℕ, by defining `natDegree 0 = 0`. -/ def natDegree (p : R[X]) : ℕ := (degree p).unbot' 0 #align polynomial.nat_degree Polynomial.natDegree /-- `leadingCoeff p` gives the coefficient of the highest power of `X` in `p`-/ def leadingCoeff (p : R[X]) : R := coeff p (natDegree p) #align polynomial.leading_coeff Polynomial.leadingCoeff /-- a polynomial is `Monic` if its leading coefficient is 1 -/ def Monic (p : R[X]) := leadingCoeff p = (1 : R) #align polynomial.monic Polynomial.Monic @[nontriviality] theorem monic_of_subsingleton [Subsingleton R] (p : R[X]) : Monic p := Subsingleton.elim _ _ #align polynomial.monic_of_subsingleton Polynomial.monic_of_subsingleton theorem Monic.def : Monic p ↔ leadingCoeff p = 1 := Iff.rfl #align polynomial.monic.def Polynomial.Monic.def instance Monic.decidable [DecidableEq R] : Decidable (Monic p) := by unfold Monic; infer_instance #align polynomial.monic.decidable Polynomial.Monic.decidable @[simp] theorem Monic.leadingCoeff {p : R[X]} (hp : p.Monic) : leadingCoeff p = 1 := hp #align polynomial.monic.leading_coeff Polynomial.Monic.leadingCoeff theorem Monic.coeff_natDegree {p : R[X]} (hp : p.Monic) : p.coeff p.natDegree = 1 := hp #align polynomial.monic.coeff_nat_degree Polynomial.Monic.coeff_natDegree @[simp] theorem degree_zero : degree (0 : R[X]) = ⊥ := rfl #align polynomial.degree_zero Polynomial.degree_zero @[simp] theorem natDegree_zero : natDegree (0 : R[X]) = 0 := rfl #align polynomial.nat_degree_zero Polynomial.natDegree_zero @[simp] theorem coeff_natDegree : coeff p (natDegree p) = leadingCoeff p := rfl #align polynomial.coeff_nat_degree Polynomial.coeff_natDegree @[simp] theorem degree_eq_bot : degree p = ⊥ ↔ p = 0 := ⟨fun h => support_eq_empty.1 (Finset.max_eq_bot.1 h), fun h => h.symm ▸ rfl⟩ #align polynomial.degree_eq_bot Polynomial.degree_eq_bot @[nontriviality] theorem degree_of_subsingleton [Subsingleton R] : degree p = ⊥ := by rw [Subsingleton.elim p 0, degree_zero] #align polynomial.degree_of_subsingleton Polynomial.degree_of_subsingleton @[nontriviality] theorem natDegree_of_subsingleton [Subsingleton R] : natDegree p = 0 := by rw [Subsingleton.elim p 0, natDegree_zero] #align polynomial.nat_degree_of_subsingleton Polynomial.natDegree_of_subsingleton theorem degree_eq_natDegree (hp : p ≠ 0) : degree p = (natDegree p : WithBot ℕ) := by let ⟨n, hn⟩ := not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt degree_eq_bot.1 hp)) have hn : degree p = some n := Classical.not_not.1 hn rw [natDegree, hn]; rfl #align polynomial.degree_eq_nat_degree Polynomial.degree_eq_natDegree theorem supDegree_eq_natDegree (p : R[X]) : p.toFinsupp.supDegree id = p.natDegree := by obtain rfl|h := eq_or_ne p 0 · simp apply WithBot.coe_injective rw [← AddMonoidAlgebra.supDegree_withBot_some_comp, Function.comp_id, supDegree_eq_degree, degree_eq_natDegree h, Nat.cast_withBot] rwa [support_toFinsupp, nonempty_iff_ne_empty, Ne, support_eq_empty]
Mathlib/Algebra/Polynomial/Degree/Definitions.lean
146
147
theorem degree_eq_iff_natDegree_eq {p : R[X]} {n : ℕ} (hp : p ≠ 0) : p.degree = n ↔ p.natDegree = n := by
rw [degree_eq_natDegree hp]; exact WithBot.coe_eq_coe
/- Copyright (c) 2024 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Order.Group.Instances import Mathlib.GroupTheory.GroupAction.Pi /-! # Maps (semi)conjugating a shift to a shift Denote by $S^1$ the unit circle `UnitAddCircle`. A common way to study a self-map $f\colon S^1\to S^1$ of degree `1` is to lift it to a map $\tilde f\colon \mathbb R\to \mathbb R$ such that $\tilde f(x + 1) = \tilde f(x)+1$ for all `x`. In this file we define a structure and a typeclass for bundled maps satisfying `f (x + a) = f x + b`. We use parameters `a` and `b` instead of `1` to accomodate for two use cases: - maps between circles of different lengths; - self-maps $f\colon S^1\to S^1$ of degree other than one, including orientation-reversing maps. -/ open Function Set /-- A bundled map `f : G → H` such that `f (x + a) = f x + b` for all `x`. One can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/ structure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where /-- The underlying function of an `AddConstMap`. Use automatic coercion to function instead. -/ protected toFun : G → H /-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/ map_add_const' (x : G) : toFun (x + a) = toFun x + b @[inherit_doc] scoped [AddConstMap] notation:25 G " →+c[" a ", " b "] " H => AddConstMap G H a b /-- Typeclass for maps satisfying `f (x + a) = f x + b`. Note that `a` and `b` are `outParam`s, so one should not add instances like `[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/ class AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H] (a : outParam G) (b : outParam H) extends DFunLike F G fun _ ↦ H where /-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`: `∀ x, f (x + a) = f x + b`. -/ map_add_const (f : F) (x : G) : f (x + a) = f x + b namespace AddConstMapClass /-! ### Properties of `AddConstMapClass` maps In this section we prove properties like `f (x + n • a) = f x + n • b`. -/ attribute [simp] map_add_const variable {F G H : Type*} {a : G} {b : H} protected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) : Semiconj f (· + a) (· + b) := map_add_const f @[simp] theorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b] (f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by simpa using (AddConstMapClass.semiconj f).iterate_right n x @[simp]
Mathlib/Algebra/AddConstMap/Basic.lean
78
79
theorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b] (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by
simp [← map_add_nsmul]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp, Yury Kudryashov -/ import Mathlib.Analysis.Convex.Between import Mathlib.Analysis.Convex.Jensen import Mathlib.Analysis.Convex.Topology import Mathlib.Analysis.Normed.Group.Pointwise import Mathlib.Analysis.NormedSpace.AddTorsor #align_import analysis.convex.normed from "leanprover-community/mathlib"@"a63928c34ec358b5edcda2bf7513c50052a5230f" /-! # Topological and metric properties of convex sets in normed spaces We prove the following facts: * `convexOn_norm`, `convexOn_dist` : norm and distance to a fixed point is convex on any convex set; * `convexOn_univ_norm`, `convexOn_univ_dist` : norm and distance to a fixed point is convex on the whole space; * `convexHull_ediam`, `convexHull_diam` : convex hull of a set has the same (e)metric diameter as the original set; * `bounded_convexHull` : convex hull of a set is bounded if and only if the original set is bounded. -/ variable {ι : Type*} {E P : Type*} open Metric Set open scoped Convex variable [SeminormedAddCommGroup E] [NormedSpace ℝ E] [PseudoMetricSpace P] [NormedAddTorsor E P] variable {s t : Set E} /-- The norm on a real normed space is convex on any convex set. See also `Seminorm.convexOn` and `convexOn_univ_norm`. -/ theorem convexOn_norm (hs : Convex ℝ s) : ConvexOn ℝ s norm := ⟨hs, fun x _ y _ a b ha hb _ => calc ‖a • x + b • y‖ ≤ ‖a • x‖ + ‖b • y‖ := norm_add_le _ _ _ = a * ‖x‖ + b * ‖y‖ := by rw [norm_smul, norm_smul, Real.norm_of_nonneg ha, Real.norm_of_nonneg hb]⟩ #align convex_on_norm convexOn_norm /-- The norm on a real normed space is convex on the whole space. See also `Seminorm.convexOn` and `convexOn_norm`. -/ theorem convexOn_univ_norm : ConvexOn ℝ univ (norm : E → ℝ) := convexOn_norm convex_univ #align convex_on_univ_norm convexOn_univ_norm theorem convexOn_dist (z : E) (hs : Convex ℝ s) : ConvexOn ℝ s fun z' => dist z' z := by simpa [dist_eq_norm, preimage_preimage] using (convexOn_norm (hs.translate (-z))).comp_affineMap (AffineMap.id ℝ E - AffineMap.const ℝ E z) #align convex_on_dist convexOn_dist theorem convexOn_univ_dist (z : E) : ConvexOn ℝ univ fun z' => dist z' z := convexOn_dist z convex_univ #align convex_on_univ_dist convexOn_univ_dist theorem convex_ball (a : E) (r : ℝ) : Convex ℝ (Metric.ball a r) := by simpa only [Metric.ball, sep_univ] using (convexOn_univ_dist a).convex_lt r #align convex_ball convex_ball theorem convex_closedBall (a : E) (r : ℝ) : Convex ℝ (Metric.closedBall a r) := by simpa only [Metric.closedBall, sep_univ] using (convexOn_univ_dist a).convex_le r #align convex_closed_ball convex_closedBall theorem Convex.thickening (hs : Convex ℝ s) (δ : ℝ) : Convex ℝ (thickening δ s) := by rw [← add_ball_zero] exact hs.add (convex_ball 0 _) #align convex.thickening Convex.thickening theorem Convex.cthickening (hs : Convex ℝ s) (δ : ℝ) : Convex ℝ (cthickening δ s) := by obtain hδ | hδ := le_total 0 δ · rw [cthickening_eq_iInter_thickening hδ] exact convex_iInter₂ fun _ _ => hs.thickening _ · rw [cthickening_of_nonpos hδ] exact hs.closure #align convex.cthickening Convex.cthickening /-- Given a point `x` in the convex hull of `s` and a point `y`, there exists a point of `s` at distance at least `dist x y` from `y`. -/ theorem convexHull_exists_dist_ge {s : Set E} {x : E} (hx : x ∈ convexHull ℝ s) (y : E) : ∃ x' ∈ s, dist x y ≤ dist x' y := (convexOn_dist y (convex_convexHull ℝ _)).exists_ge_of_mem_convexHull hx #align convex_hull_exists_dist_ge convexHull_exists_dist_ge /-- Given a point `x` in the convex hull of `s` and a point `y` in the convex hull of `t`, there exist points `x' ∈ s` and `y' ∈ t` at distance at least `dist x y`. -/
Mathlib/Analysis/Convex/Normed.lean
92
97
theorem convexHull_exists_dist_ge2 {s t : Set E} {x y : E} (hx : x ∈ convexHull ℝ s) (hy : y ∈ convexHull ℝ t) : ∃ x' ∈ s, ∃ y' ∈ t, dist x y ≤ dist x' y' := by
rcases convexHull_exists_dist_ge hx y with ⟨x', hx', Hx'⟩ rcases convexHull_exists_dist_ge hy x' with ⟨y', hy', Hy'⟩ use x', hx', y', hy' exact le_trans Hx' (dist_comm y x' ▸ dist_comm y' x' ▸ Hy')
/- Copyright (c) 2019 Neil Strickland. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Neil Strickland -/ import Mathlib.Algebra.BigOperators.Group.Multiset import Mathlib.Data.PNat.Prime import Mathlib.Data.Nat.Factors import Mathlib.Data.Multiset.Sort #align_import data.pnat.factors from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" /-! # Prime factors of nonzero naturals This file defines the factorization of a nonzero natural number `n` as a multiset of primes, the multiplicity of `p` in this factors multiset being the p-adic valuation of `n`. ## Main declarations * `PrimeMultiset`: Type of multisets of prime numbers. * `FactorMultiset n`: Multiset of prime factors of `n`. -/ -- Porting note: `deriving` contained Inhabited, CanonicallyOrderedAddCommMonoid, DistribLattice, -- SemilatticeSup, OrderBot, Sub, OrderedSub /-- The type of multisets of prime numbers. Unique factorization gives an equivalence between this set and ℕ+, as we will formalize below. -/ def PrimeMultiset := Multiset Nat.Primes deriving Inhabited, CanonicallyOrderedAddCommMonoid, DistribLattice, SemilatticeSup, Sub #align prime_multiset PrimeMultiset instance : OrderBot PrimeMultiset where bot_le := by simp only [bot_le, forall_const] instance : OrderedSub PrimeMultiset where tsub_le_iff_right _ _ _ := Multiset.sub_le_iff_le_add namespace PrimeMultiset -- `@[derive]` doesn't work for `meta` instances unsafe instance : Repr PrimeMultiset := by delta PrimeMultiset; infer_instance /-- The multiset consisting of a single prime -/ def ofPrime (p : Nat.Primes) : PrimeMultiset := ({p} : Multiset Nat.Primes) #align prime_multiset.of_prime PrimeMultiset.ofPrime theorem card_ofPrime (p : Nat.Primes) : Multiset.card (ofPrime p) = 1 := rfl #align prime_multiset.card_of_prime PrimeMultiset.card_ofPrime /-- We can forget the primality property and regard a multiset of primes as just a multiset of positive integers, or a multiset of natural numbers. In the opposite direction, if we have a multiset of positive integers or natural numbers, together with a proof that all the elements are prime, then we can regard it as a multiset of primes. The next block of results records obvious properties of these coercions. -/ def toNatMultiset : PrimeMultiset → Multiset ℕ := fun v => v.map Coe.coe #align prime_multiset.to_nat_multiset PrimeMultiset.toNatMultiset instance coeNat : Coe PrimeMultiset (Multiset ℕ) := ⟨toNatMultiset⟩ #align prime_multiset.coe_nat PrimeMultiset.coeNat /-- `PrimeMultiset.coe`, the coercion from a multiset of primes to a multiset of naturals, promoted to an `AddMonoidHom`. -/ def coeNatMonoidHom : PrimeMultiset →+ Multiset ℕ := { Multiset.mapAddMonoidHom Coe.coe with toFun := Coe.coe } #align prime_multiset.coe_nat_monoid_hom PrimeMultiset.coeNatMonoidHom @[simp] theorem coe_coeNatMonoidHom : (coeNatMonoidHom : PrimeMultiset → Multiset ℕ) = Coe.coe := rfl #align prime_multiset.coe_coe_nat_monoid_hom PrimeMultiset.coe_coeNatMonoidHom theorem coeNat_injective : Function.Injective (Coe.coe : PrimeMultiset → Multiset ℕ) := Multiset.map_injective Nat.Primes.coe_nat_injective #align prime_multiset.coe_nat_injective PrimeMultiset.coeNat_injective theorem coeNat_ofPrime (p : Nat.Primes) : (ofPrime p : Multiset ℕ) = {(p : ℕ)} := rfl #align prime_multiset.coe_nat_of_prime PrimeMultiset.coeNat_ofPrime theorem coeNat_prime (v : PrimeMultiset) (p : ℕ) (h : p ∈ (v : Multiset ℕ)) : p.Prime := by rcases Multiset.mem_map.mp h with ⟨⟨_, hp'⟩, ⟨_, h_eq⟩⟩ exact h_eq ▸ hp' #align prime_multiset.coe_nat_prime PrimeMultiset.coeNat_prime /-- Converts a `PrimeMultiset` to a `Multiset ℕ+`. -/ def toPNatMultiset : PrimeMultiset → Multiset ℕ+ := fun v => v.map Coe.coe #align prime_multiset.to_pnat_multiset PrimeMultiset.toPNatMultiset instance coePNat : Coe PrimeMultiset (Multiset ℕ+) := ⟨toPNatMultiset⟩ #align prime_multiset.coe_pnat PrimeMultiset.coePNat /-- `coePNat`, the coercion from a multiset of primes to a multiset of positive naturals, regarded as an `AddMonoidHom`. -/ def coePNatMonoidHom : PrimeMultiset →+ Multiset ℕ+ := { Multiset.mapAddMonoidHom Coe.coe with toFun := Coe.coe } #align prime_multiset.coe_pnat_monoid_hom PrimeMultiset.coePNatMonoidHom @[simp] theorem coe_coePNatMonoidHom : (coePNatMonoidHom : PrimeMultiset → Multiset ℕ+) = Coe.coe := rfl #align prime_multiset.coe_coe_pnat_monoid_hom PrimeMultiset.coe_coePNatMonoidHom theorem coePNat_injective : Function.Injective (Coe.coe : PrimeMultiset → Multiset ℕ+) := Multiset.map_injective Nat.Primes.coe_pnat_injective #align prime_multiset.coe_pnat_injective PrimeMultiset.coePNat_injective theorem coePNat_ofPrime (p : Nat.Primes) : (ofPrime p : Multiset ℕ+) = {(p : ℕ+)} := rfl #align prime_multiset.coe_pnat_of_prime PrimeMultiset.coePNat_ofPrime
Mathlib/Data/PNat/Factors.lean
121
123
theorem coePNat_prime (v : PrimeMultiset) (p : ℕ+) (h : p ∈ (v : Multiset ℕ+)) : p.Prime := by
rcases Multiset.mem_map.mp h with ⟨⟨_, hp'⟩, ⟨_, h_eq⟩⟩ exact h_eq ▸ hp'
/- 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
Mathlib/RepresentationTheory/Character.lean
54
55
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]
/- 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, Scott Morrison -/ import Mathlib.Algebra.BigOperators.Finsupp import Mathlib.Algebra.Module.Basic import Mathlib.Algebra.Regular.SMul import Mathlib.Data.Finset.Preimage import Mathlib.Data.Rat.BigOperators import Mathlib.GroupTheory.GroupAction.Hom import Mathlib.Data.Set.Subsingleton #align_import data.finsupp.basic from "leanprover-community/mathlib"@"f69db8cecc668e2d5894d7e9bfc491da60db3b9f" /-! # Miscellaneous definitions, lemmas, and constructions using finsupp ## Main declarations * `Finsupp.graph`: the finset of input and output pairs with non-zero outputs. * `Finsupp.mapRange.equiv`: `Finsupp.mapRange` as an equiv. * `Finsupp.mapDomain`: maps the domain of a `Finsupp` by a function and by summing. * `Finsupp.comapDomain`: postcomposition of a `Finsupp` with a function injective on the preimage of its support. * `Finsupp.some`: restrict a finitely supported function on `Option α` to a finitely supported function on `α`. * `Finsupp.filter`: `filter p f` is the finitely supported function that is `f a` if `p a` is true and 0 otherwise. * `Finsupp.frange`: the image of a finitely supported function on its support. * `Finsupp.subtype_domain`: the restriction of a finitely supported function `f` to a subtype. ## Implementation notes This file is a `noncomputable theory` and uses classical logic throughout. ## TODO * This file is currently ~1600 lines long and is quite a miscellany of definitions and lemmas, so it should be divided into smaller pieces. * Expand the list of definitions and important lemmas to the module docstring. -/ noncomputable section open Finset Function variable {α β γ ι M M' N P G H R S : Type*} namespace Finsupp /-! ### Declarations about `graph` -/ section Graph variable [Zero M] /-- The graph of a finitely supported function over its support, i.e. the finset of input and output pairs with non-zero outputs. -/ def graph (f : α →₀ M) : Finset (α × M) := f.support.map ⟨fun a => Prod.mk a (f a), fun _ _ h => (Prod.mk.inj h).1⟩ #align finsupp.graph Finsupp.graph theorem mk_mem_graph_iff {a : α} {m : M} {f : α →₀ M} : (a, m) ∈ f.graph ↔ f a = m ∧ m ≠ 0 := by simp_rw [graph, mem_map, mem_support_iff] constructor · rintro ⟨b, ha, rfl, -⟩ exact ⟨rfl, ha⟩ · rintro ⟨rfl, ha⟩ exact ⟨a, ha, rfl⟩ #align finsupp.mk_mem_graph_iff Finsupp.mk_mem_graph_iff @[simp]
Mathlib/Data/Finsupp/Basic.lean
78
80
theorem mem_graph_iff {c : α × M} {f : α →₀ M} : c ∈ f.graph ↔ f c.1 = c.2 ∧ c.2 ≠ 0 := by
cases c exact mk_mem_graph_iff
/- 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.Algebra.MvPolynomial.Rename #align_import data.mv_polynomial.comap from "leanprover-community/mathlib"@"aba31c938d3243cc671be7091b28a1e0814647ee" /-! # `comap` operation on `MvPolynomial` This file defines the `comap` function on `MvPolynomial`. `MvPolynomial.comap` is a low-tech example of a map of "algebraic varieties," modulo the fact that `mathlib` does not yet define varieties. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) -/ namespace MvPolynomial variable {σ : Type*} {τ : Type*} {υ : Type*} {R : Type*} [CommSemiring R] /-- Given an algebra hom `f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R` and a variable evaluation `v : τ → R`, `comap f v` produces a variable evaluation `σ → R`. -/ noncomputable def comap (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) : (τ → R) → σ → R := fun x i => aeval x (f (X i)) #align mv_polynomial.comap MvPolynomial.comap @[simp] theorem comap_apply (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) (x : τ → R) (i : σ) : comap f x i = aeval x (f (X i)) := rfl #align mv_polynomial.comap_apply MvPolynomial.comap_apply @[simp] theorem comap_id_apply (x : σ → R) : comap (AlgHom.id R (MvPolynomial σ R)) x = x := by funext i simp only [comap, AlgHom.id_apply, id, aeval_X] #align mv_polynomial.comap_id_apply MvPolynomial.comap_id_apply variable (σ R) theorem comap_id : comap (AlgHom.id R (MvPolynomial σ R)) = id := by funext x exact comap_id_apply x #align mv_polynomial.comap_id MvPolynomial.comap_id variable {σ R} theorem comap_comp_apply (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) (g : MvPolynomial τ R →ₐ[R] MvPolynomial υ R) (x : υ → R) : comap (g.comp f) x = comap f (comap g x) := by funext i trans aeval x (aeval (fun i => g (X i)) (f (X i))) · apply eval₂Hom_congr rfl rfl rw [AlgHom.comp_apply] suffices g = aeval fun i => g (X i) by rw [← this] exact aeval_unique g · simp only [comap, aeval_eq_eval₂Hom, map_eval₂Hom, AlgHom.comp_apply] refine eval₂Hom_congr ?_ rfl rfl ext r apply aeval_C #align mv_polynomial.comap_comp_apply MvPolynomial.comap_comp_apply theorem comap_comp (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) (g : MvPolynomial τ R →ₐ[R] MvPolynomial υ R) : comap (g.comp f) = comap f ∘ comap g := by funext x exact comap_comp_apply _ _ _ #align mv_polynomial.comap_comp MvPolynomial.comap_comp
Mathlib/Algebra/MvPolynomial/Comap.lean
83
87
theorem comap_eq_id_of_eq_id (f : MvPolynomial σ R →ₐ[R] MvPolynomial σ R) (hf : ∀ φ, f φ = φ) (x : σ → R) : comap f x = x := by
convert comap_id_apply x ext1 φ simp [hf, AlgHom.id_apply]
/- 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.Antichain import Mathlib.Order.UpperLower.Basic import Mathlib.Order.Interval.Set.Basic import Mathlib.Order.RelIso.Set #align_import order.minimal from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Minimal/maximal elements of a set This file defines minimal and maximal of a set with respect to an arbitrary relation. ## Main declarations * `maximals r s`: Maximal elements of `s` with respect to `r`. * `minimals r s`: Minimal elements of `s` with respect to `r`. ## TODO Do we need a `Finset` version? -/ open Function Set variable {α : Type*} (r r₁ r₂ : α → α → Prop) (s t : Set α) (a b : α) /-- Turns a set into an antichain by keeping only the "maximal" elements. -/ def maximals : Set α := { a ∈ s | ∀ ⦃b⦄, b ∈ s → r a b → r b a } #align maximals maximals /-- Turns a set into an antichain by keeping only the "minimal" elements. -/ def minimals : Set α := { a ∈ s | ∀ ⦃b⦄, b ∈ s → r b a → r a b } #align minimals minimals theorem maximals_subset : maximals r s ⊆ s := sep_subset _ _ #align maximals_subset maximals_subset theorem minimals_subset : minimals r s ⊆ s := sep_subset _ _ #align minimals_subset minimals_subset @[simp] theorem maximals_empty : maximals r ∅ = ∅ := sep_empty _ #align maximals_empty maximals_empty @[simp] theorem minimals_empty : minimals r ∅ = ∅ := sep_empty _ #align minimals_empty minimals_empty @[simp] theorem maximals_singleton : maximals r {a} = {a} := (maximals_subset _ _).antisymm <| singleton_subset_iff.2 <| ⟨rfl, by rintro b (rfl : b = a) exact id⟩ #align maximals_singleton maximals_singleton @[simp] theorem minimals_singleton : minimals r {a} = {a} := maximals_singleton _ _ #align minimals_singleton minimals_singleton theorem maximals_swap : maximals (swap r) s = minimals r s := rfl #align maximals_swap maximals_swap theorem minimals_swap : minimals (swap r) s = maximals r s := rfl #align minimals_swap minimals_swap section IsAntisymm variable {r s t a b} [IsAntisymm α r] theorem eq_of_mem_maximals (ha : a ∈ maximals r s) (hb : b ∈ s) (h : r a b) : a = b := antisymm h <| ha.2 hb h #align eq_of_mem_maximals eq_of_mem_maximals theorem eq_of_mem_minimals (ha : a ∈ minimals r s) (hb : b ∈ s) (h : r b a) : a = b := antisymm (ha.2 hb h) h #align eq_of_mem_minimals eq_of_mem_minimals set_option autoImplicit true theorem mem_maximals_iff : x ∈ maximals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, y ∈ s → r x y → x = y := by simp only [maximals, Set.mem_sep_iff, and_congr_right_iff] refine fun _ ↦ ⟨fun h y hys hxy ↦ antisymm hxy (h hys hxy), fun h y hys hxy ↦ ?_⟩ convert hxy <;> rw [h hys hxy] theorem mem_maximals_setOf_iff : x ∈ maximals r (setOf P) ↔ P x ∧ ∀ ⦃y⦄, P y → r x y → x = y := mem_maximals_iff theorem mem_minimals_iff : x ∈ minimals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, y ∈ s → r y x → x = y := @mem_maximals_iff _ _ _ (IsAntisymm.swap r) _ theorem mem_minimals_setOf_iff : x ∈ minimals r (setOf P) ↔ P x ∧ ∀ ⦃y⦄, P y → r y x → x = y := mem_minimals_iff /-- This theorem can't be used to rewrite without specifying `rlt`, since `rlt` would have to be guessed. See `mem_minimals_iff_forall_ssubset_not_mem` and `mem_minimals_iff_forall_lt_not_mem` for `⊆` and `≤` versions. -/
Mathlib/Order/Minimal.lean
113
115
theorem mem_minimals_iff_forall_lt_not_mem' (rlt : α → α → Prop) [IsNonstrictStrictOrder α r rlt] : x ∈ minimals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, rlt y x → y ∉ s := by
simp [minimals, right_iff_left_not_left_of r rlt, not_imp_not, imp.swap (a := _ ∈ _)]
/- Copyright (c) 2021 Alex Kontorovich and Heather Macbeth and Marc Masdeu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alex Kontorovich, Heather Macbeth, Marc Masdeu -/ import Mathlib.Analysis.Complex.UpperHalfPlane.Basic import Mathlib.LinearAlgebra.GeneralLinearGroup import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup import Mathlib.Topology.Instances.Matrix import Mathlib.Topology.Algebra.Module.FiniteDimension #align_import number_theory.modular from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # The action of the modular group SL(2, ℤ) on the upper half-plane We define the action of `SL(2,ℤ)` on `ℍ` (via restriction of the `SL(2,ℝ)` action in `Analysis.Complex.UpperHalfPlane`). We then define the standard fundamental domain (`ModularGroup.fd`, `𝒟`) for this action and show (`ModularGroup.exists_smul_mem_fd`) that any point in `ℍ` can be moved inside `𝒟`. ## Main definitions The standard (closed) fundamental domain of the action of `SL(2,ℤ)` on `ℍ`, denoted `𝒟`: `fd := {z | 1 ≤ (z : ℂ).normSq ∧ |z.re| ≤ (1 : ℝ) / 2}` The standard open fundamental domain of the action of `SL(2,ℤ)` on `ℍ`, denoted `𝒟ᵒ`: `fdo := {z | 1 < (z : ℂ).normSq ∧ |z.re| < (1 : ℝ) / 2}` These notations are localized in the `Modular` locale and can be enabled via `open scoped Modular`. ## Main results Any `z : ℍ` can be moved to `𝒟` by an element of `SL(2,ℤ)`: `exists_smul_mem_fd (z : ℍ) : ∃ g : SL(2,ℤ), g • z ∈ 𝒟` If both `z` and `γ • z` are in the open domain `𝒟ᵒ` then `z = γ • z`: `eq_smul_self_of_mem_fdo_mem_fdo {z : ℍ} {g : SL(2,ℤ)} (hz : z ∈ 𝒟ᵒ) (hg : g • z ∈ 𝒟ᵒ) : z = g • z` # Discussion Standard proofs make use of the identity `g • z = a / c - 1 / (c (cz + d))` for `g = [[a, b], [c, d]]` in `SL(2)`, but this requires separate handling of whether `c = 0`. Instead, our proof makes use of the following perhaps novel identity (see `ModularGroup.smul_eq_lcRow0_add`): `g • z = (a c + b d) / (c^2 + d^2) + (d z - c) / ((c^2 + d^2) (c z + d))` where there is no issue of division by zero. Another feature is that we delay until the very end the consideration of special matrices `T=[[1,1],[0,1]]` (see `ModularGroup.T`) and `S=[[0,-1],[1,0]]` (see `ModularGroup.S`), by instead using abstract theory on the properness of certain maps (phrased in terms of the filters `Filter.cocompact`, `Filter.cofinite`, etc) to deduce existence theorems, first to prove the existence of `g` maximizing `(g•z).im` (see `ModularGroup.exists_max_im`), and then among those, to minimize `|(g•z).re|` (see `ModularGroup.exists_row_one_eq_and_min_re`). -/ open Complex hiding abs_two open Matrix hiding mul_smul open Matrix.SpecialLinearGroup UpperHalfPlane ModularGroup noncomputable section local notation "SL(" n ", " R ")" => SpecialLinearGroup (Fin n) R local macro "↑ₘ" t:term:80 : term => `(term| ($t : Matrix (Fin 2) (Fin 2) ℤ)) open scoped UpperHalfPlane ComplexConjugate namespace ModularGroup variable {g : SL(2, ℤ)} (z : ℍ) section BottomRow /-- The two numbers `c`, `d` in the "bottom_row" of `g=[[*,*],[c,d]]` in `SL(2, ℤ)` are coprime. -/
Mathlib/NumberTheory/Modular.lean
85
89
theorem bottom_row_coprime {R : Type*} [CommRing R] (g : SL(2, R)) : IsCoprime ((↑g : Matrix (Fin 2) (Fin 2) R) 1 0) ((↑g : Matrix (Fin 2) (Fin 2) R) 1 1) := by
use -(↑g : Matrix (Fin 2) (Fin 2) R) 0 1, (↑g : Matrix (Fin 2) (Fin 2) R) 0 0 rw [add_comm, neg_mul, ← sub_eq_add_neg, ← det_fin_two] exact g.det_coe
/- Copyright (c) 2019 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Kenny Lau -/ import Mathlib.Algebra.CharP.Defs import Mathlib.RingTheory.Multiplicity import Mathlib.RingTheory.PowerSeries.Basic #align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60" /-! # Formal power series (in one variable) - Order The `PowerSeries.order` of a formal power series `φ` is the multiplicity of the variable `X` in `φ`. If the coefficients form an integral domain, then `PowerSeries.order` is an additive valuation (`PowerSeries.order_mul`, `PowerSeries.le_order_add`). We prove that if the commutative ring `R` of coefficients is an integral domain, then the ring `R⟦X⟧` of formal power series in one variable over `R` is an integral domain. Given a non-zero power series `f`, `divided_by_X_pow_order f` is the power series obtained by dividing out the largest power of X that divides `f`, that is its order. This is useful when proving that `R⟦X⟧` is a normalization monoid, which is done in `PowerSeries.Inverse`. -/ noncomputable section open Polynomial open Finset (antidiagonal mem_antidiagonal) namespace PowerSeries open Finsupp (single) variable {R : Type*} section OrderBasic open multiplicity variable [Semiring R] {φ : R⟦X⟧} theorem exists_coeff_ne_zero_iff_ne_zero : (∃ n : ℕ, coeff R n φ ≠ 0) ↔ φ ≠ 0 := by refine not_iff_not.mp ?_ push_neg -- FIXME: the `FunLike.coe` doesn't seem to be picked up in the expression after #8386? simp [PowerSeries.ext_iff, (coeff R _).map_zero] #align power_series.exists_coeff_ne_zero_iff_ne_zero PowerSeries.exists_coeff_ne_zero_iff_ne_zero /-- The order of a formal power series `φ` is the greatest `n : PartENat` such that `X^n` divides `φ`. The order is `⊤` if and only if `φ = 0`. -/ def order (φ : R⟦X⟧) : PartENat := letI := Classical.decEq R letI := Classical.decEq R⟦X⟧ if h : φ = 0 then ⊤ else Nat.find (exists_coeff_ne_zero_iff_ne_zero.mpr h) #align power_series.order PowerSeries.order /-- The order of the `0` power series is infinite. -/ @[simp] theorem order_zero : order (0 : R⟦X⟧) = ⊤ := dif_pos rfl #align power_series.order_zero PowerSeries.order_zero theorem order_finite_iff_ne_zero : (order φ).Dom ↔ φ ≠ 0 := by simp only [order] constructor · split_ifs with h <;> intro H · simp only [PartENat.top_eq_none, Part.not_none_dom] at H · exact h · intro h simp [h] #align power_series.order_finite_iff_ne_zero PowerSeries.order_finite_iff_ne_zero /-- If the order of a formal power series is finite, then the coefficient indexed by the order is nonzero. -/ theorem coeff_order (h : (order φ).Dom) : coeff R (φ.order.get h) φ ≠ 0 := by classical simp only [order, order_finite_iff_ne_zero.mp h, not_false_iff, dif_neg, PartENat.get_natCast'] generalize_proofs h exact Nat.find_spec h #align power_series.coeff_order PowerSeries.coeff_order /-- If the `n`th coefficient of a formal power series is nonzero, then the order of the power series is less than or equal to `n`. -/ theorem order_le (n : ℕ) (h : coeff R n φ ≠ 0) : order φ ≤ n := by classical rw [order, dif_neg] · simp only [PartENat.coe_le_coe] exact Nat.find_le h · exact exists_coeff_ne_zero_iff_ne_zero.mp ⟨n, h⟩ #align power_series.order_le PowerSeries.order_le /-- The `n`th coefficient of a formal power series is `0` if `n` is strictly smaller than the order of the power series. -/
Mathlib/RingTheory/PowerSeries/Order.lean
99
101
theorem coeff_of_lt_order (n : ℕ) (h : ↑n < order φ) : coeff R n φ = 0 := by
contrapose! h exact order_le _ h
/- Copyright (c) 2021 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.MeasureTheory.Constructions.Prod.Basic import Mathlib.MeasureTheory.Group.Measure #align_import measure_theory.group.prod from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Measure theory in the product of groups In this file we show properties about measure theory in products of measurable groups and properties of iterated integrals in measurable groups. These lemmas show the uniqueness of left invariant measures on measurable groups, up to scaling. In this file we follow the proof and refer to the book *Measure Theory* by Paul Halmos. The idea of the proof is to use the translation invariance of measures to prove `μ(t) = c * μ(s)` for two sets `s` and `t`, where `c` is a constant that does not depend on `μ`. Let `e` and `f` be the characteristic functions of `s` and `t`. Assume that `μ` and `ν` are left-invariant measures. Then the map `(x, y) ↦ (y * x, x⁻¹)` preserves the measure `μ × ν`, which means that ``` ∫ x, ∫ y, h x y ∂ν ∂μ = ∫ x, ∫ y, h (y * x) x⁻¹ ∂ν ∂μ ``` If we apply this to `h x y := e x * f y⁻¹ / ν ((fun h ↦ h * y⁻¹) ⁻¹' s)`, we can rewrite the RHS to `μ(t)`, and the LHS to `c * μ(s)`, where `c = c(ν)` does not depend on `μ`. Applying this to `μ` and to `ν` gives `μ (t) / μ (s) = ν (t) / ν (s)`, which is the uniqueness up to scalar multiplication. The proof in [Halmos] seems to contain an omission in §60 Th. A, see `MeasureTheory.measure_lintegral_div_measure`. Note that this theory only applies in measurable groups, i.e., when multiplication and inversion are measurable. This is not the case in general in locally compact groups, or even in compact groups, when the topology is not second-countable. For arguments along the same line, but using continuous functions instead of measurable sets and working in the general locally compact setting, see the file `MeasureTheory.Measure.Haar.Unique.lean`. -/ noncomputable section open Set hiding prod_eq open Function MeasureTheory open Filter hiding map open scoped Classical ENNReal Pointwise MeasureTheory variable (G : Type*) [MeasurableSpace G] variable [Group G] [MeasurableMul₂ G] variable (μ ν : Measure G) [SigmaFinite ν] [SigmaFinite μ] {s : Set G} /-- The map `(x, y) ↦ (x, xy)` as a `MeasurableEquiv`. -/ @[to_additive "The map `(x, y) ↦ (x, x + y)` as a `MeasurableEquiv`."] protected def MeasurableEquiv.shearMulRight [MeasurableInv G] : G × G ≃ᵐ G × G := { Equiv.prodShear (Equiv.refl _) Equiv.mulLeft with measurable_toFun := measurable_fst.prod_mk measurable_mul measurable_invFun := measurable_fst.prod_mk <| measurable_fst.inv.mul measurable_snd } #align measurable_equiv.shear_mul_right MeasurableEquiv.shearMulRight #align measurable_equiv.shear_add_right MeasurableEquiv.shearAddRight /-- The map `(x, y) ↦ (x, y / x)` as a `MeasurableEquiv` with as inverse `(x, y) ↦ (x, yx)` -/ @[to_additive "The map `(x, y) ↦ (x, y - x)` as a `MeasurableEquiv` with as inverse `(x, y) ↦ (x, y + x)`."] protected def MeasurableEquiv.shearDivRight [MeasurableInv G] : G × G ≃ᵐ G × G := { Equiv.prodShear (Equiv.refl _) Equiv.divRight with measurable_toFun := measurable_fst.prod_mk <| measurable_snd.div measurable_fst measurable_invFun := measurable_fst.prod_mk <| measurable_snd.mul measurable_fst } #align measurable_equiv.shear_div_right MeasurableEquiv.shearDivRight #align measurable_equiv.shear_sub_right MeasurableEquiv.shearSubRight variable {G} namespace MeasureTheory open Measure section LeftInvariant /-- The multiplicative shear mapping `(x, y) ↦ (x, xy)` preserves the measure `μ × ν`. This condition is part of the definition of a measurable group in [Halmos, §59]. There, the map in this lemma is called `S`. -/ @[to_additive measurePreserving_prod_add " The shear mapping `(x, y) ↦ (x, x + y)` preserves the measure `μ × ν`. "] theorem measurePreserving_prod_mul [IsMulLeftInvariant ν] : MeasurePreserving (fun z : G × G => (z.1, z.1 * z.2)) (μ.prod ν) (μ.prod ν) := (MeasurePreserving.id μ).skew_product measurable_mul <| Filter.eventually_of_forall <| map_mul_left_eq_self ν #align measure_theory.measure_preserving_prod_mul MeasureTheory.measurePreserving_prod_mul #align measure_theory.measure_preserving_prod_add MeasureTheory.measurePreserving_prod_add /-- The map `(x, y) ↦ (y, yx)` sends the measure `μ × ν` to `ν × μ`. This is the map `SR` in [Halmos, §59]. `S` is the map `(x, y) ↦ (x, xy)` and `R` is `Prod.swap`. -/ @[to_additive measurePreserving_prod_add_swap " The map `(x, y) ↦ (y, y + x)` sends the measure `μ × ν` to `ν × μ`. "] theorem measurePreserving_prod_mul_swap [IsMulLeftInvariant μ] : MeasurePreserving (fun z : G × G => (z.2, z.2 * z.1)) (μ.prod ν) (ν.prod μ) := (measurePreserving_prod_mul ν μ).comp measurePreserving_swap #align measure_theory.measure_preserving_prod_mul_swap MeasureTheory.measurePreserving_prod_mul_swap #align measure_theory.measure_preserving_prod_add_swap MeasureTheory.measurePreserving_prod_add_swap @[to_additive]
Mathlib/MeasureTheory/Group/Prod.lean
108
116
theorem measurable_measure_mul_right (hs : MeasurableSet s) : Measurable fun x => μ ((fun y => y * x) ⁻¹' s) := by
suffices Measurable fun y => μ ((fun x => (x, y)) ⁻¹' ((fun z : G × G => ((1 : G), z.1 * z.2)) ⁻¹' univ ×ˢ s)) by convert this using 1; ext1 x; congr 1 with y : 1; simp apply measurable_measure_prod_mk_right apply measurable_const.prod_mk measurable_mul (MeasurableSet.univ.prod hs) infer_instance
/- 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.Topology.Sets.Closeds #align_import topology.noetherian_space from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Noetherian space A Noetherian space is a topological space that satisfies any of the following equivalent conditions: - `WellFounded ((· > ·) : TopologicalSpace.Opens α → TopologicalSpace.Opens α → Prop)` - `WellFounded ((· < ·) : TopologicalSpace.Closeds α → TopologicalSpace.Closeds α → Prop)` - `∀ s : Set α, IsCompact s` - `∀ s : TopologicalSpace.Opens α, IsCompact s` The first is chosen as the definition, and the equivalence is shown in `TopologicalSpace.noetherianSpace_TFAE`. Many examples of noetherian spaces come from algebraic topology. For example, the underlying space of a noetherian scheme (e.g., the spectrum of a noetherian ring) is noetherian. ## Main Results - `TopologicalSpace.NoetherianSpace.set`: Every subspace of a noetherian space is noetherian. - `TopologicalSpace.NoetherianSpace.isCompact`: Every set in a noetherian space is a compact set. - `TopologicalSpace.noetherianSpace_TFAE`: Describes the equivalent definitions of noetherian spaces. - `TopologicalSpace.NoetherianSpace.range`: The image of a noetherian space under a continuous map is noetherian. - `TopologicalSpace.NoetherianSpace.iUnion`: The finite union of noetherian spaces is noetherian. - `TopologicalSpace.NoetherianSpace.discrete`: A noetherian and Hausdorff space is discrete. - `TopologicalSpace.NoetherianSpace.exists_finset_irreducible`: Every closed subset of a noetherian space is a finite union of irreducible closed subsets. - `TopologicalSpace.NoetherianSpace.finite_irreducibleComponents`: The number of irreducible components of a noetherian space is finite. -/ variable (α β : Type*) [TopologicalSpace α] [TopologicalSpace β] namespace TopologicalSpace /-- Type class for noetherian spaces. It is defined to be spaces whose open sets satisfies ACC. -/ @[mk_iff] class NoetherianSpace : Prop where wellFounded_opens : WellFounded ((· > ·) : Opens α → Opens α → Prop) #align topological_space.noetherian_space TopologicalSpace.NoetherianSpace
Mathlib/Topology/NoetherianSpace.lean
53
56
theorem noetherianSpace_iff_opens : NoetherianSpace α ↔ ∀ s : Opens α, IsCompact (s : Set α) := by
rw [noetherianSpace_iff, CompleteLattice.wellFounded_iff_isSupFiniteCompact, CompleteLattice.isSupFiniteCompact_iff_all_elements_compact] exact forall_congr' Opens.isCompactElement_iff
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, Scott Morrison -/ import Mathlib.CategoryTheory.Subobject.Lattice #align_import category_theory.subobject.limits from "leanprover-community/mathlib"@"956af7c76589f444f2e1313911bad16366ea476d" /-! # Specific subobjects We define `equalizerSubobject`, `kernelSubobject` and `imageSubobject`, which are the subobjects represented by the equalizer, kernel and image of (a pair of) morphism(s) and provide conditions for `P.factors f`, where `P` is one of these special subobjects. TODO: Add conditions for when `P` is a pullback subobject. TODO: an iff characterisation of `(imageSubobject f).Factors h` -/ universe v u noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Subobject Opposite variable {C : Type u} [Category.{v} C] {X Y Z : C} namespace CategoryTheory namespace Limits section Equalizer variable (f g : X ⟶ Y) [HasEqualizer f g] /-- The equalizer of morphisms `f g : X ⟶ Y` as a `Subobject X`. -/ abbrev equalizerSubobject : Subobject X := Subobject.mk (equalizer.ι f g) #align category_theory.limits.equalizer_subobject CategoryTheory.Limits.equalizerSubobject /-- The underlying object of `equalizerSubobject f g` is (up to isomorphism!) the same as the chosen object `equalizer f g`. -/ def equalizerSubobjectIso : (equalizerSubobject f g : C) ≅ equalizer f g := Subobject.underlyingIso (equalizer.ι f g) #align category_theory.limits.equalizer_subobject_iso CategoryTheory.Limits.equalizerSubobjectIso @[reassoc (attr := simp)] theorem equalizerSubobject_arrow : (equalizerSubobjectIso f g).hom ≫ equalizer.ι f g = (equalizerSubobject f g).arrow := by simp [equalizerSubobjectIso] #align category_theory.limits.equalizer_subobject_arrow CategoryTheory.Limits.equalizerSubobject_arrow @[reassoc (attr := simp)] theorem equalizerSubobject_arrow' : (equalizerSubobjectIso f g).inv ≫ (equalizerSubobject f g).arrow = equalizer.ι f g := by simp [equalizerSubobjectIso] #align category_theory.limits.equalizer_subobject_arrow' CategoryTheory.Limits.equalizerSubobject_arrow' @[reassoc] theorem equalizerSubobject_arrow_comp : (equalizerSubobject f g).arrow ≫ f = (equalizerSubobject f g).arrow ≫ g := by rw [← equalizerSubobject_arrow, Category.assoc, Category.assoc, equalizer.condition] #align category_theory.limits.equalizer_subobject_arrow_comp CategoryTheory.Limits.equalizerSubobject_arrow_comp theorem equalizerSubobject_factors {W : C} (h : W ⟶ X) (w : h ≫ f = h ≫ g) : (equalizerSubobject f g).Factors h := ⟨equalizer.lift h w, by simp⟩ #align category_theory.limits.equalizer_subobject_factors CategoryTheory.Limits.equalizerSubobject_factors theorem equalizerSubobject_factors_iff {W : C} (h : W ⟶ X) : (equalizerSubobject f g).Factors h ↔ h ≫ f = h ≫ g := ⟨fun w => by rw [← Subobject.factorThru_arrow _ _ w, Category.assoc, equalizerSubobject_arrow_comp, Category.assoc], equalizerSubobject_factors f g h⟩ #align category_theory.limits.equalizer_subobject_factors_iff CategoryTheory.Limits.equalizerSubobject_factors_iff end Equalizer section Kernel variable [HasZeroMorphisms C] (f : X ⟶ Y) [HasKernel f] /-- The kernel of a morphism `f : X ⟶ Y` as a `Subobject X`. -/ abbrev kernelSubobject : Subobject X := Subobject.mk (kernel.ι f) #align category_theory.limits.kernel_subobject CategoryTheory.Limits.kernelSubobject /-- The underlying object of `kernelSubobject f` is (up to isomorphism!) the same as the chosen object `kernel f`. -/ def kernelSubobjectIso : (kernelSubobject f : C) ≅ kernel f := Subobject.underlyingIso (kernel.ι f) #align category_theory.limits.kernel_subobject_iso CategoryTheory.Limits.kernelSubobjectIso @[reassoc (attr := simp), elementwise (attr := simp)]
Mathlib/CategoryTheory/Subobject/Limits.lean
98
100
theorem kernelSubobject_arrow : (kernelSubobjectIso f).hom ≫ kernel.ι f = (kernelSubobject f).arrow := by
simp [kernelSubobjectIso]
/- 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.Set.Pairwise.Basic import Mathlib.Data.Set.Lattice import Mathlib.Data.SetLike.Basic #align_import order.chain from "leanprover-community/mathlib"@"c227d107bbada5d0d9d20287e3282c0a7f1651a0" /-! # Chains and flags This file defines chains for an arbitrary relation and flags for an order and proves Hausdorff's Maximality Principle. ## Main declarations * `IsChain s`: A chain `s` is a set of comparable elements. * `maxChain_spec`: Hausdorff's Maximality Principle. * `Flag`: The type of flags, aka maximal chains, of an order. ## Notes Originally ported from Isabelle/HOL. The [original file](https://isabelle.in.tum.de/dist/library/HOL/HOL/Zorn.html) was written by Jacques D. Fleuriot, Tobias Nipkow, Christian Sternagel. -/ open scoped Classical open Set variable {α β : Type*} /-! ### Chains -/ section Chain variable (r : α → α → Prop) /-- In this file, we use `≺` as a local notation for any relation `r`. -/ local infixl:50 " ≺ " => r /-- A chain is a set `s` satisfying `x ≺ y ∨ x = y ∨ y ≺ x` for all `x y ∈ s`. -/ def IsChain (s : Set α) : Prop := s.Pairwise fun x y => x ≺ y ∨ y ≺ x #align is_chain IsChain /-- `SuperChain s t` means that `t` is a chain that strictly includes `s`. -/ def SuperChain (s t : Set α) : Prop := IsChain r t ∧ s ⊂ t #align super_chain SuperChain /-- A chain `s` is a maximal chain if there does not exists a chain strictly including `s`. -/ def IsMaxChain (s : Set α) : Prop := IsChain r s ∧ ∀ ⦃t⦄, IsChain r t → s ⊆ t → s = t #align is_max_chain IsMaxChain variable {r} {c c₁ c₂ c₃ s t : Set α} {a b x y : α} theorem isChain_empty : IsChain r ∅ := Set.pairwise_empty _ #align is_chain_empty isChain_empty theorem Set.Subsingleton.isChain (hs : s.Subsingleton) : IsChain r s := hs.pairwise _ #align set.subsingleton.is_chain Set.Subsingleton.isChain theorem IsChain.mono : s ⊆ t → IsChain r t → IsChain r s := Set.Pairwise.mono #align is_chain.mono IsChain.mono theorem IsChain.mono_rel {r' : α → α → Prop} (h : IsChain r s) (h_imp : ∀ x y, r x y → r' x y) : IsChain r' s := h.mono' fun x y => Or.imp (h_imp x y) (h_imp y x) #align is_chain.mono_rel IsChain.mono_rel /-- This can be used to turn `IsChain (≥)` into `IsChain (≤)` and vice-versa. -/ theorem IsChain.symm (h : IsChain r s) : IsChain (flip r) s := h.mono' fun _ _ => Or.symm #align is_chain.symm IsChain.symm theorem isChain_of_trichotomous [IsTrichotomous α r] (s : Set α) : IsChain r s := fun a _ b _ hab => (trichotomous_of r a b).imp_right fun h => h.resolve_left hab #align is_chain_of_trichotomous isChain_of_trichotomous protected theorem IsChain.insert (hs : IsChain r s) (ha : ∀ b ∈ s, a ≠ b → a ≺ b ∨ b ≺ a) : IsChain r (insert a s) := hs.insert_of_symmetric (fun _ _ => Or.symm) ha #align is_chain.insert IsChain.insert theorem isChain_univ_iff : IsChain r (univ : Set α) ↔ IsTrichotomous α r := by refine ⟨fun h => ⟨fun a b => ?_⟩, fun h => @isChain_of_trichotomous _ _ h univ⟩ rw [or_left_comm, or_iff_not_imp_left] exact h trivial trivial #align is_chain_univ_iff isChain_univ_iff theorem IsChain.image (r : α → α → Prop) (s : β → β → Prop) (f : α → β) (h : ∀ x y, r x y → s (f x) (f y)) {c : Set α} (hrc : IsChain r c) : IsChain s (f '' c) := fun _ ⟨_, ha₁, ha₂⟩ _ ⟨_, hb₁, hb₂⟩ => ha₂ ▸ hb₂ ▸ fun hxy => (hrc ha₁ hb₁ <| ne_of_apply_ne f hxy).imp (h _ _) (h _ _) #align is_chain.image IsChain.image
Mathlib/Order/Chain.lean
107
110
theorem Monotone.isChain_range [LinearOrder α] [Preorder β] {f : α → β} (hf : Monotone f) : IsChain (· ≤ ·) (range f) := by
rw [← image_univ] exact (isChain_of_trichotomous _).image (· ≤ ·) _ _ hf
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.AlgebraicTopology.DoldKan.Normalized #align_import algebraic_topology.dold_kan.homotopy_equivalence from "leanprover-community/mathlib"@"f951e201d416fb50cc7826171d80aa510ec20747" /-! # The normalized Moore complex and the alternating face map complex are homotopy equivalent In this file, when the category `A` is abelian, we obtain the homotopy equivalence `homotopyEquivNormalizedMooreComplexAlternatingFaceMapComplex` between the normalized Moore complex and the alternating face map complex of a simplicial object in `A`. -/ open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Preadditive Simplicial DoldKan noncomputable section namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] (X : SimplicialObject C) /-- Inductive construction of homotopies from `P q` to `𝟙 _` -/ noncomputable def homotopyPToId : ∀ q : ℕ, Homotopy (P q : K[X] ⟶ _) (𝟙 _) | 0 => Homotopy.refl _ | q + 1 => by refine Homotopy.trans (Homotopy.ofEq ?_) (Homotopy.trans (Homotopy.add (homotopyPToId q) (Homotopy.compLeft (homotopyHσToZero q) (P q))) (Homotopy.ofEq ?_)) · simp only [P_succ, comp_add, comp_id] · simp only [add_zero, comp_zero] set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.homotopy_P_to_id AlgebraicTopology.DoldKan.homotopyPToId /-- The complement projection `Q q` to `P q` is homotopic to zero. -/ def homotopyQToZero (q : ℕ) : Homotopy (Q q : K[X] ⟶ _) 0 := Homotopy.equivSubZero.toFun (homotopyPToId X q).symm set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.homotopy_Q_to_zero AlgebraicTopology.DoldKan.homotopyQToZero
Mathlib/AlgebraicTopology/DoldKan/HomotopyEquivalence.lean
52
58
theorem homotopyPToId_eventually_constant {q n : ℕ} (hqn : n < q) : ((homotopyPToId X (q + 1)).hom n (n + 1) : X _[n] ⟶ X _[n + 1]) = (homotopyPToId X q).hom n (n + 1) := by
simp only [homotopyHσToZero, AlternatingFaceMapComplex.obj_X, Nat.add_eq, Homotopy.trans_hom, Homotopy.ofEq_hom, Pi.zero_apply, Homotopy.add_hom, Homotopy.compLeft_hom, add_zero, Homotopy.nullHomotopy'_hom, ComplexShape.down_Rel, hσ'_eq_zero hqn (c_mk (n + 1) n rfl), dite_eq_ite, ite_self, comp_zero, zero_add, homotopyPToId]
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang, Junyan Xu -/ import Mathlib.Topology.Sheaves.PUnit import Mathlib.Topology.Sheaves.Stalks import Mathlib.Topology.Sheaves.Functors #align_import topology.sheaves.skyscraper from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Skyscraper (pre)sheaves A skyscraper (pre)sheaf `𝓕 : (Pre)Sheaf C X` is the (pre)sheaf with value `A` at point `p₀` that is supported only at open sets contain `p₀`, i.e. `𝓕(U) = A` if `p₀ ∈ U` and `𝓕(U) = *` if `p₀ ∉ U` where `*` is a terminal object of `C`. In terms of stalks, `𝓕` is supported at all specializations of `p₀`, i.e. if `p₀ ⤳ x` then `𝓕ₓ ≅ A` and if `¬ p₀ ⤳ x` then `𝓕ₓ ≅ *`. ## Main definitions * `skyscraperPresheaf`: `skyscraperPresheaf p₀ A` is the skyscraper presheaf at point `p₀` with value `A`. * `skyscraperSheaf`: the skyscraper presheaf satisfies the sheaf condition. ## Main statements * `skyscraperPresheafStalkOfSpecializes`: if `y ∈ closure {p₀}` then the stalk of `skyscraperPresheaf p₀ A` at `y` is `A`. * `skyscraperPresheafStalkOfNotSpecializes`: if `y ∉ closure {p₀}` then the stalk of `skyscraperPresheaf p₀ A` at `y` is `*` the terminal object. TODO: generalize universe level when calculating stalks, after generalizing universe level of stalk. -/ noncomputable section open TopologicalSpace TopCat CategoryTheory CategoryTheory.Limits Opposite universe u v w variable {X : TopCat.{u}} (p₀ : X) [∀ U : Opens X, Decidable (p₀ ∈ U)] section variable {C : Type v} [Category.{w} C] [HasTerminal C] (A : C) /-- A skyscraper presheaf is a presheaf supported at a single point: if `p₀ ∈ X` is a specified point, then the skyscraper presheaf `𝓕` with value `A` is defined by `U ↦ A` if `p₀ ∈ U` and `U ↦ *` if `p₀ ∉ A` where `*` is some terminal object. -/ @[simps] def skyscraperPresheaf : Presheaf C X where obj U := if p₀ ∈ unop U then A else terminal C map {U V} i := if h : p₀ ∈ unop V then eqToHom <| by dsimp; erw [if_pos h, if_pos (leOfHom i.unop h)] else ((if_neg h).symm.ndrec terminalIsTerminal).from _ map_id U := (em (p₀ ∈ U.unop)).elim (fun h => dif_pos h) fun h => ((if_neg h).symm.ndrec terminalIsTerminal).hom_ext _ _ map_comp {U V W} iVU iWV := by by_cases hW : p₀ ∈ unop W · have hV : p₀ ∈ unop V := leOfHom iWV.unop hW simp only [dif_pos hW, dif_pos hV, eqToHom_trans] · dsimp; rw [dif_neg hW]; apply ((if_neg hW).symm.ndrec terminalIsTerminal).hom_ext #align skyscraper_presheaf skyscraperPresheaf
Mathlib/Topology/Sheaves/Skyscraper.lean
68
74
theorem skyscraperPresheaf_eq_pushforward [hd : ∀ U : Opens (TopCat.of PUnit.{u + 1}), Decidable (PUnit.unit ∈ U)] : skyscraperPresheaf p₀ A = ContinuousMap.const (TopCat.of PUnit) p₀ _* skyscraperPresheaf (X := TopCat.of PUnit) PUnit.unit A := by
convert_to @skyscraperPresheaf X p₀ (fun U => hd <| (Opens.map <| ContinuousMap.const _ p₀).obj U) C _ _ A = _ <;> congr
/- Copyright (c) 2022 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.MeasureTheory.Group.Measure /-! # Lebesgue Integration on Groups We develop properties of integrals with a group as domain. This file contains properties about Lebesgue integration. -/ assert_not_exists NormedSpace namespace MeasureTheory open Measure TopologicalSpace open scoped ENNReal variable {G : Type*} [MeasurableSpace G] {μ : Measure G} {g : G} section MeasurableMul variable [Group G] [MeasurableMul G] /-- Translating a function by left-multiplication does not change its Lebesgue integral with respect to a left-invariant measure. -/ @[to_additive "Translating a function by left-addition does not change its Lebesgue integral with respect to a left-invariant measure."] theorem lintegral_mul_left_eq_self [IsMulLeftInvariant μ] (f : G → ℝ≥0∞) (g : G) : (∫⁻ x, f (g * x) ∂μ) = ∫⁻ x, f x ∂μ := by convert (lintegral_map_equiv f <| MeasurableEquiv.mulLeft g).symm simp [map_mul_left_eq_self μ g] #align measure_theory.lintegral_mul_left_eq_self MeasureTheory.lintegral_mul_left_eq_self #align measure_theory.lintegral_add_left_eq_self MeasureTheory.lintegral_add_left_eq_self /-- Translating a function by right-multiplication does not change its Lebesgue integral with respect to a right-invariant measure. -/ @[to_additive "Translating a function by right-addition does not change its Lebesgue integral with respect to a right-invariant measure."]
Mathlib/MeasureTheory/Group/LIntegral.lean
46
49
theorem lintegral_mul_right_eq_self [IsMulRightInvariant μ] (f : G → ℝ≥0∞) (g : G) : (∫⁻ x, f (x * g) ∂μ) = ∫⁻ x, f x ∂μ := by
convert (lintegral_map_equiv f <| MeasurableEquiv.mulRight g).symm using 1 simp [map_mul_right_eq_self μ g]
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky, Chris Hughes -/ import Mathlib.Data.List.Nodup #align_import data.list.duplicate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # List duplicates ## Main definitions * `List.Duplicate x l : Prop` is an inductive property that holds when `x` is a duplicate in `l` ## Implementation details In this file, `x ∈+ l` notation is shorthand for `List.Duplicate x l`. -/ variable {α : Type*} namespace List /-- Property that an element `x : α` of `l : List α` can be found in the list more than once. -/ inductive Duplicate (x : α) : List α → Prop | cons_mem {l : List α} : x ∈ l → Duplicate x (x :: l) | cons_duplicate {y : α} {l : List α} : Duplicate x l → Duplicate x (y :: l) #align list.duplicate List.Duplicate local infixl:50 " ∈+ " => List.Duplicate variable {l : List α} {x : α} theorem Mem.duplicate_cons_self (h : x ∈ l) : x ∈+ x :: l := Duplicate.cons_mem h #align list.mem.duplicate_cons_self List.Mem.duplicate_cons_self theorem Duplicate.duplicate_cons (h : x ∈+ l) (y : α) : x ∈+ y :: l := Duplicate.cons_duplicate h #align list.duplicate.duplicate_cons List.Duplicate.duplicate_cons theorem Duplicate.mem (h : x ∈+ l) : x ∈ l := by induction' h with l' _ y l' _ hm · exact mem_cons_self _ _ · exact mem_cons_of_mem _ hm #align list.duplicate.mem List.Duplicate.mem theorem Duplicate.mem_cons_self (h : x ∈+ x :: l) : x ∈ l := by cases' h with _ h _ _ h · exact h · exact h.mem #align list.duplicate.mem_cons_self List.Duplicate.mem_cons_self @[simp] theorem duplicate_cons_self_iff : x ∈+ x :: l ↔ x ∈ l := ⟨Duplicate.mem_cons_self, Mem.duplicate_cons_self⟩ #align list.duplicate_cons_self_iff List.duplicate_cons_self_iff theorem Duplicate.ne_nil (h : x ∈+ l) : l ≠ [] := fun H => (mem_nil_iff x).mp (H ▸ h.mem) #align list.duplicate.ne_nil List.Duplicate.ne_nil @[simp] theorem not_duplicate_nil (x : α) : ¬x ∈+ [] := fun H => H.ne_nil rfl #align list.not_duplicate_nil List.not_duplicate_nil theorem Duplicate.ne_singleton (h : x ∈+ l) (y : α) : l ≠ [y] := by induction' h with l' h z l' h _ · simp [ne_nil_of_mem h] · simp [ne_nil_of_mem h.mem] #align list.duplicate.ne_singleton List.Duplicate.ne_singleton @[simp] theorem not_duplicate_singleton (x y : α) : ¬x ∈+ [y] := fun H => H.ne_singleton _ rfl #align list.not_duplicate_singleton List.not_duplicate_singleton theorem Duplicate.elim_nil (h : x ∈+ []) : False := not_duplicate_nil x h #align list.duplicate.elim_nil List.Duplicate.elim_nil theorem Duplicate.elim_singleton {y : α} (h : x ∈+ [y]) : False := not_duplicate_singleton x y h #align list.duplicate.elim_singleton List.Duplicate.elim_singleton theorem duplicate_cons_iff {y : α} : x ∈+ y :: l ↔ y = x ∧ x ∈ l ∨ x ∈+ l := by refine ⟨fun h => ?_, fun h => ?_⟩ · cases' h with _ hm _ _ hm · exact Or.inl ⟨rfl, hm⟩ · exact Or.inr hm · rcases h with (⟨rfl | h⟩ | h) · simpa · exact h.cons_duplicate #align list.duplicate_cons_iff List.duplicate_cons_iff
Mathlib/Data/List/Duplicate.lean
98
99
theorem Duplicate.of_duplicate_cons {y : α} (h : x ∈+ y :: l) (hx : x ≠ y) : x ∈+ l := by
simpa [duplicate_cons_iff, hx.symm] using h
/- Copyright (c) 2023 Shogo Saito. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shogo Saito. Adapted for mathlib by Hunter Monroe -/ import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Nat.ModEq import Mathlib.Data.Nat.GCD.BigOperators /-! # Chinese Remainder Theorem This file provides definitions and theorems for the Chinese Remainder Theorem. These are used in Gödel's Beta function, which is used in proving Gödel's incompleteness theorems. ## Main result - `chineseRemainderOfList`: Definition of the Chinese remainder of a list ## Tags Chinese Remainder Theorem, Gödel, beta function -/ namespace Nat variable {ι : Type*} lemma modEq_list_prod_iff {a b} {l : List ℕ} (co : l.Pairwise Coprime) : a ≡ b [MOD l.prod] ↔ ∀ i, a ≡ b [MOD l.get i] := by induction' l with m l ih · simp [modEq_one] · have : Coprime m l.prod := coprime_list_prod_right_iff.mpr (List.pairwise_cons.mp co).1 simp only [List.prod_cons, ← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co), List.length_cons] constructor · rintro ⟨h0, hs⟩ i cases i using Fin.cases <;> simp [h0, hs] · intro h; exact ⟨h 0, fun i => h i.succ⟩ lemma modEq_list_prod_iff' {a b} {s : ι → ℕ} {l : List ι} (co : l.Pairwise (Coprime on s)) : a ≡ b [MOD (l.map s).prod] ↔ ∀ i ∈ l, a ≡ b [MOD s i] := by induction' l with i l ih · simp [modEq_one] · have : Coprime (s i) (l.map s).prod := by simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro j hj exact (List.pairwise_cons.mp co).1 j hj simp [← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co)] variable (a s : ι → ℕ) /-- The natural number less than `(l.map s).prod` congruent to `a i` mod `s i` for all `i ∈ l`. -/ def chineseRemainderOfList : (l : List ι) → l.Pairwise (Coprime on s) → { k // ∀ i ∈ l, k ≡ a i [MOD s i] } | [], _ => ⟨0, by simp⟩ | i :: l, co => by have : Coprime (s i) (l.map s).prod := by simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro j hj exact (List.pairwise_cons.mp co).1 j hj have ih := chineseRemainderOfList l co.of_cons have k := chineseRemainder this (a i) ih use k simp only [List.mem_cons, forall_eq_or_imp, k.prop.1, true_and] intro j hj exact ((modEq_list_prod_iff' co.of_cons).mp k.prop.2 j hj).trans (ih.prop j hj) @[simp] theorem chineseRemainderOfList_nil : (chineseRemainderOfList a s [] List.Pairwise.nil : ℕ) = 0 := rfl theorem chineseRemainderOfList_lt_prod (l : List ι) (co : l.Pairwise (Coprime on s)) (hs : ∀ i ∈ l, s i ≠ 0) : chineseRemainderOfList a s l co < (l.map s).prod := by cases l with | nil => simp | cons i l => simp only [chineseRemainderOfList, List.map_cons, List.prod_cons] have : Coprime (s i) (l.map s).prod := by simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro j hj exact (List.pairwise_cons.mp co).1 j hj refine chineseRemainder_lt_mul this (a i) (chineseRemainderOfList a s l co.of_cons) (hs i (List.mem_cons_self _ l)) ?_ simp only [ne_eq, List.prod_eq_zero_iff, List.mem_map, not_exists, not_and] intro j hj exact hs j (List.mem_cons_of_mem _ hj)
Mathlib/Data/Nat/ChineseRemainder.lean
93
105
theorem chineseRemainderOfList_modEq_unique (l : List ι) (co : l.Pairwise (Coprime on s)) {z} (hz : ∀ i ∈ l, z ≡ a i [MOD s i]) : z ≡ chineseRemainderOfList a s l co [MOD (l.map s).prod] := by
induction' l with i l ih · simp [modEq_one] · simp only [List.map_cons, List.prod_cons, chineseRemainderOfList] have : Coprime (s i) (l.map s).prod := by simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro j hj exact (List.pairwise_cons.mp co).1 j hj exact chineseRemainder_modEq_unique this (hz i (List.mem_cons_self _ _)) (ih co.of_cons (fun j hj => hz j (List.mem_cons_of_mem _ hj)))
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Group.Equiv.TypeTags import Mathlib.GroupTheory.FreeAbelianGroup import Mathlib.GroupTheory.FreeGroup.IsFreeGroup import Mathlib.LinearAlgebra.Dimension.StrongRankCondition #align_import group_theory.free_abelian_group_finsupp from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69" /-! # Isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ` In this file we construct the canonical isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`. We use this to transport the notion of `support` from `Finsupp` to `FreeAbelianGroup`. ## Main declarations - `FreeAbelianGroup.equivFinsupp`: group isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ` - `FreeAbelianGroup.coeff`: the multiplicity of `x : X` in `a : FreeAbelianGroup X` - `FreeAbelianGroup.support`: the finset of `x : X` that occur in `a : FreeAbelianGroup X` -/ noncomputable section variable {X : Type*} /-- The group homomorphism `FreeAbelianGroup X →+ (X →₀ ℤ)`. -/ def FreeAbelianGroup.toFinsupp : FreeAbelianGroup X →+ X →₀ ℤ := FreeAbelianGroup.lift fun x => Finsupp.single x (1 : ℤ) #align free_abelian_group.to_finsupp FreeAbelianGroup.toFinsupp /-- The group homomorphism `(X →₀ ℤ) →+ FreeAbelianGroup X`. -/ def Finsupp.toFreeAbelianGroup : (X →₀ ℤ) →+ FreeAbelianGroup X := Finsupp.liftAddHom fun x => (smulAddHom ℤ (FreeAbelianGroup X)).flip (FreeAbelianGroup.of x) #align finsupp.to_free_abelian_group Finsupp.toFreeAbelianGroup open Finsupp FreeAbelianGroup @[simp] theorem Finsupp.toFreeAbelianGroup_comp_singleAddHom (x : X) : Finsupp.toFreeAbelianGroup.comp (Finsupp.singleAddHom x) = (smulAddHom ℤ (FreeAbelianGroup X)).flip (of x) := by ext simp only [AddMonoidHom.coe_comp, Finsupp.singleAddHom_apply, Function.comp_apply, one_smul, toFreeAbelianGroup, Finsupp.liftAddHom_apply_single] #align finsupp.to_free_abelian_group_comp_single_add_hom Finsupp.toFreeAbelianGroup_comp_singleAddHom @[simp]
Mathlib/GroupTheory/FreeAbelianGroupFinsupp.lean
54
59
theorem FreeAbelianGroup.toFinsupp_comp_toFreeAbelianGroup : toFinsupp.comp toFreeAbelianGroup = AddMonoidHom.id (X →₀ ℤ) := by
ext x y; simp only [AddMonoidHom.id_comp] rw [AddMonoidHom.comp_assoc, Finsupp.toFreeAbelianGroup_comp_singleAddHom] simp only [toFinsupp, AddMonoidHom.coe_comp, Finsupp.singleAddHom_apply, Function.comp_apply, one_smul, lift.of, AddMonoidHom.flip_apply, smulAddHom_apply, AddMonoidHom.id_apply]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax import Mathlib.Algebra.Order.Monoid.WithTop import Mathlib.Data.Finset.Image import Mathlib.Data.Multiset.Fold #align_import data.finset.fold from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # The fold operation for a commutative associative operation over a finset. -/ -- TODO: -- assert_not_exists OrderedCommMonoid assert_not_exists MonoidWithZero namespace Finset open Multiset variable {α β γ : Type*} /-! ### fold -/ section Fold variable (op : β → β → β) [hc : Std.Commutative op] [ha : Std.Associative op] local notation a " * " b => op a b /-- `fold op b f s` folds the commutative associative operation `op` over the `f`-image of `s`, i.e. `fold (+) b f {1,2,3} = f 1 + f 2 + f 3 + b`. -/ def fold (b : β) (f : α → β) (s : Finset α) : β := (s.1.map f).fold op b #align finset.fold Finset.fold variable {op} {f : α → β} {b : β} {s : Finset α} {a : α} @[simp] theorem fold_empty : (∅ : Finset α).fold op b f = b := rfl #align finset.fold_empty Finset.fold_empty @[simp]
Mathlib/Data/Finset/Fold.lean
50
52
theorem fold_cons (h : a ∉ s) : (cons a s h).fold op b f = f a * s.fold op b f := by
dsimp only [fold] rw [cons_val, Multiset.map_cons, fold_cons_left]
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.BoxIntegral.Box.Basic import Mathlib.Analysis.SpecificLimits.Basic #align_import analysis.box_integral.box.subbox_induction from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Induction on subboxes In this file we prove the following induction principle for `BoxIntegral.Box`, see `BoxIntegral.Box.subbox_induction_on`. Let `p` be a predicate on `BoxIntegral.Box ι`, let `I` be a box. Suppose that the following two properties hold true. * Consider a smaller box `J ≤ I`. The hyperplanes passing through the center of `J` split it into `2 ^ n` boxes. If `p` holds true on each of these boxes, then it is true on `J`. * For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within `I.Icc` such that for every box `J ≤ I` such that `z ∈ J.Icc ⊆ U`, if `J` is homothetic to `I` with a coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`. Then `p I` is true. ## Tags rectangular box, induction -/ open Set Finset Function Filter Metric Classical Topology Filter ENNReal noncomputable section namespace BoxIntegral namespace Box variable {ι : Type*} {I J : Box ι} /-- For a box `I`, the hyperplanes passing through its center split `I` into `2 ^ card ι` boxes. `BoxIntegral.Box.splitCenterBox I s` is one of these boxes. See also `BoxIntegral.Partition.splitCenter` for the corresponding `BoxIntegral.Partition`. -/ def splitCenterBox (I : Box ι) (s : Set ι) : Box ι where lower := s.piecewise (fun i ↦ (I.lower i + I.upper i) / 2) I.lower upper := s.piecewise I.upper fun i ↦ (I.lower i + I.upper i) / 2 lower_lt_upper i := by dsimp only [Set.piecewise] split_ifs <;> simp only [left_lt_add_div_two, add_div_two_lt_right, I.lower_lt_upper] #align box_integral.box.split_center_box BoxIntegral.Box.splitCenterBox
Mathlib/Analysis/BoxIntegral/Box/SubboxInduction.lean
53
62
theorem mem_splitCenterBox {s : Set ι} {y : ι → ℝ} : y ∈ I.splitCenterBox s ↔ y ∈ I ∧ ∀ i, (I.lower i + I.upper i) / 2 < y i ↔ i ∈ s := by
simp only [splitCenterBox, mem_def, ← forall_and] refine forall_congr' fun i ↦ ?_ dsimp only [Set.piecewise] split_ifs with hs <;> simp only [hs, iff_true_iff, iff_false_iff, not_lt] exacts [⟨fun H ↦ ⟨⟨(left_lt_add_div_two.2 (I.lower_lt_upper i)).trans H.1, H.2⟩, H.1⟩, fun H ↦ ⟨H.2, H.1.2⟩⟩, ⟨fun H ↦ ⟨⟨H.1, H.2.trans (add_div_two_lt_right.2 (I.lower_lt_upper i)).le⟩, H.2⟩, fun H ↦ ⟨H.1.1, H.2⟩⟩]
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Scott Morrison, Jakob von Raumer, Joël Riou -/ import Mathlib.CategoryTheory.Preadditive.ProjectiveResolution import Mathlib.Algebra.Homology.HomotopyCategory import Mathlib.Tactic.SuppressCompilation /-! # Abelian categories with enough projectives have projective resolutions ## Main results When the underlying category is abelian: * `CategoryTheory.ProjectiveResolution.lift`: Given `P : ProjectiveResolution X` and `Q : ProjectiveResolution Y`, any morphism `X ⟶ Y` admits a lifting to a chain map `P.complex ⟶ Q.complex`. It is a lifting in the sense that `P.ι` intertwines the lift and the original morphism, see `CategoryTheory.ProjectiveResolution.lift_commutes`. * `CategoryTheory.ProjectiveResolution.liftHomotopy`: Any two such descents are homotopic. * `CategoryTheory.ProjectiveResolution.homotopyEquiv`: Any two projective resolutions of the same object are homotopy equivalent. * `CategoryTheory.projectiveResolutions`: If every object admits a projective resolution, we can construct a functor `projectiveResolutions C : C ⥤ HomotopyCategory C (ComplexShape.down ℕ)`. * `CategoryTheory.exact_d_f`: `Projective.d f` and `f` are exact. * `CategoryTheory.ProjectiveResolution.of`: Hence, starting from an epimorphism `P ⟶ X`, where `P` is projective, we can apply `Projective.d` repeatedly to obtain a projective resolution of `X`. -/ suppress_compilation noncomputable section universe v u namespace CategoryTheory variable {C : Type u} [Category.{v} C] open Category Limits Projective set_option linter.uppercaseLean3 false -- `ProjectiveResolution` namespace ProjectiveResolution section variable [HasZeroObject C] [HasZeroMorphisms C] /-- Auxiliary construction for `lift`. -/ def liftFZero {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) : P.complex.X 0 ⟶ Q.complex.X 0 := Projective.factorThru (P.π.f 0 ≫ f) (Q.π.f 0) #align category_theory.ProjectiveResolution.lift_f_zero CategoryTheory.ProjectiveResolution.liftFZero end section Abelian variable [Abelian C] lemma exact₀ {Z : C} (P : ProjectiveResolution Z) : (ShortComplex.mk _ _ P.complex_d_comp_π_f_zero).Exact := ShortComplex.exact_of_g_is_cokernel _ P.isColimitCokernelCofork /-- Auxiliary construction for `lift`. -/ def liftFOne {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) : P.complex.X 1 ⟶ Q.complex.X 1 := Q.exact₀.liftFromProjective (P.complex.d 1 0 ≫ liftFZero f P Q) (by simp [liftFZero]) #align category_theory.ProjectiveResolution.lift_f_one CategoryTheory.ProjectiveResolution.liftFOne @[simp] theorem liftFOne_zero_comm {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) : liftFOne f P Q ≫ Q.complex.d 1 0 = P.complex.d 1 0 ≫ liftFZero f P Q := by apply Q.exact₀.liftFromProjective_comp #align category_theory.ProjectiveResolution.lift_f_one_zero_comm CategoryTheory.ProjectiveResolution.liftFOne_zero_comm /-- Auxiliary construction for `lift`. -/ def liftFSucc {Y Z : C} (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) (n : ℕ) (g : P.complex.X n ⟶ Q.complex.X n) (g' : P.complex.X (n + 1) ⟶ Q.complex.X (n + 1)) (w : g' ≫ Q.complex.d (n + 1) n = P.complex.d (n + 1) n ≫ g) : Σ'g'' : P.complex.X (n + 2) ⟶ Q.complex.X (n + 2), g'' ≫ Q.complex.d (n + 2) (n + 1) = P.complex.d (n + 2) (n + 1) ≫ g' := ⟨(Q.exact_succ n).liftFromProjective (P.complex.d (n + 2) (n + 1) ≫ g') (by simp [w]), (Q.exact_succ n).liftFromProjective_comp _ _⟩ #align category_theory.ProjectiveResolution.lift_f_succ CategoryTheory.ProjectiveResolution.liftFSucc /-- A morphism in `C` lift to a chain map between projective resolutions. -/ def lift {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) : P.complex ⟶ Q.complex := ChainComplex.mkHom _ _ (liftFZero f _ _) (liftFOne f _ _) (liftFOne_zero_comm f P Q) fun n ⟨g, g', w⟩ => ⟨(liftFSucc P Q n g g' w).1, (liftFSucc P Q n g g' w).2⟩ #align category_theory.ProjectiveResolution.lift CategoryTheory.ProjectiveResolution.lift /-- The resolution maps intertwine the lift of a morphism and that morphism. -/ @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Abelian/ProjectiveResolution.lean
99
102
theorem lift_commutes {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) : lift f P Q ≫ Q.π = P.π ≫ (ChainComplex.single₀ C).map f := by
ext simp [lift, liftFZero, liftFOne]
/- Copyright (c) 2020 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov -/ import Mathlib.Order.Filter.AtTopBot #align_import order.filter.indicator_function from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # Indicator function and filters Properties of additive and multiplicative indicator functions involving `=ᶠ` and `≤ᶠ`. ## Tags indicator, characteristic, filter -/ variable {α β M E : Type*} open Set Filter section One variable [One M] {s t : Set α} {f g : α → M} {a : α} {l : Filter α} @[to_additive] theorem mulIndicator_eventuallyEq (hf : f =ᶠ[l ⊓ 𝓟 s] g) (hs : s =ᶠ[l] t) : mulIndicator s f =ᶠ[l] mulIndicator t g := (eventually_inf_principal.1 hf).mp <| hs.mem_iff.mono fun x hst hfg => by_cases (fun hxs : x ∈ s => by simp only [*, hst.1 hxs, mulIndicator_of_mem]) (fun hxs => by simp only [mulIndicator_of_not_mem, hxs, mt hst.2 hxs, not_false_eq_true]) #align indicator_eventually_eq indicator_eventuallyEq end One section Monoid variable [Monoid M] {s t : Set α} {f g : α → M} {a : α} {l : Filter α} @[to_additive] theorem mulIndicator_union_eventuallyEq (h : ∀ᶠ a in l, a ∉ s ∩ t) : mulIndicator (s ∪ t) f =ᶠ[l] mulIndicator s f * mulIndicator t f := h.mono fun _a ha => mulIndicator_union_of_not_mem_inter ha _ #align indicator_union_eventually_eq indicator_union_eventuallyEq end Monoid section Order variable [One β] [Preorder β] {s t : Set α} {f g : α → β} {a : α} {l : Filter α} @[to_additive] theorem mulIndicator_eventuallyLE_mulIndicator (h : f ≤ᶠ[l ⊓ 𝓟 s] g) : mulIndicator s f ≤ᶠ[l] mulIndicator s g := (eventually_inf_principal.1 h).mono fun _ => mulIndicator_rel_mulIndicator le_rfl #align indicator_eventually_le_indicator indicator_eventuallyLE_indicator end Order @[to_additive]
Mathlib/Order/Filter/IndicatorFunction.lean
63
66
theorem Monotone.mulIndicator_eventuallyEq_iUnion {ι} [Preorder ι] [One β] (s : ι → Set α) (hs : Monotone s) (f : α → β) (a : α) : (fun i => mulIndicator (s i) f a) =ᶠ[atTop] fun _ ↦ mulIndicator (⋃ i, s i) f a := by
classical exact hs.piecewise_eventually_eq_iUnion f 1 a
/- Copyright (c) 2019 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" /-! # Neighborhoods and continuity relative to a subset This file defines relative versions * `nhdsWithin` of `nhds` * `ContinuousOn` of `Continuous` * `ContinuousWithinAt` of `ContinuousAt` and proves their basic properties, including the relationships between these restricted notions and the corresponding notions for the subtype equipped with the subspace topology. ## Notation * `𝓝 x`: the filter of neighborhoods of a point `x`; * `𝓟 s`: the principal filter of a set `s`; * `𝓝[s] x`: the filter `nhdsWithin x s` of neighborhoods of a point `x` within a set `s`. -/ open Set Filter Function Topology Filter variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} variable [TopologicalSpace α] @[simp] theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} : (∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} : z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊢ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : α) (s : Set α) : 𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq
Mathlib/Topology/ContinuousOn.lean
75
76
theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by
rw [nhdsWithin, principal_univ, inf_top_eq]
/- Copyright (c) 2024 Josha Dekker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Josha Dekker -/ import Mathlib.Order.Filter.Basic import Mathlib.Order.Filter.CountableInter import Mathlib.SetTheory.Cardinal.Ordinal import Mathlib.SetTheory.Cardinal.Cofinality /-! # Filters with a cardinal intersection property In this file we define `CardinalInterFilter l c` to be the class of filters with the following property: for any collection of sets `s ∈ l` with cardinality strictly less than `c`, their intersection belongs to `l` as well. # Main results * `Filter.cardinalInterFilter_aleph0` establishes that every filter `l` is a `CardinalInterFilter l aleph0` * `CardinalInterFilter.toCountableInterFilter` establishes that every `CardinalInterFilter l c` with `c > aleph0` is a `CountableInterFilter`. * `CountableInterFilter.toCardinalInterFilter` establishes that every `CountableInterFilter l` is a `CardinalInterFilter l aleph1`. * `CardinalInterFilter.of_CardinalInterFilter_of_lt` establishes that we have `CardinalInterFilter l c` → `CardinalInterFilter l a` for all `a < c`. ## Tags filter, cardinal -/ open Set Filter Cardinal universe u variable {ι : Type u} {α β : Type u} {c : Cardinal.{u}} /-- A filter `l` has the cardinal `c` intersection property if for any collection of less than `c` sets `s ∈ l`, their intersection belongs to `l` as well. -/ class CardinalInterFilter (l : Filter α) (c : Cardinal.{u}) : Prop where /-- For a collection of sets `s ∈ l` with cardinality below c, their intersection belongs to `l` as well. -/ cardinal_sInter_mem : ∀ S : Set (Set α), (#S < c) → (∀ s ∈ S, s ∈ l) → ⋂₀ S ∈ l variable {l : Filter α} theorem cardinal_sInter_mem {S : Set (Set α)} [CardinalInterFilter l c] (hSc : #S < c) : ⋂₀ S ∈ l ↔ ∀ s ∈ S, s ∈ l := ⟨fun hS _s hs => mem_of_superset hS (sInter_subset_of_mem hs), CardinalInterFilter.cardinal_sInter_mem _ hSc⟩ /-- Every filter is a CardinalInterFilter with c = aleph0 -/ theorem _root_.Filter.cardinalInterFilter_aleph0 (l : Filter α) : CardinalInterFilter l aleph0 where cardinal_sInter_mem := by simp_all only [aleph_zero, lt_aleph0_iff_subtype_finite, setOf_mem_eq, sInter_mem, implies_true, forall_const] /-- Every CardinalInterFilter with c > aleph0 is a CountableInterFilter -/ theorem CardinalInterFilter.toCountableInterFilter (l : Filter α) [CardinalInterFilter l c] (hc : aleph0 < c) : CountableInterFilter l where countable_sInter_mem S hS a := CardinalInterFilter.cardinal_sInter_mem S (lt_of_le_of_lt (Set.Countable.le_aleph0 hS) hc) a /-- Every CountableInterFilter is a CardinalInterFilter with c = aleph 1-/ instance CountableInterFilter.toCardinalInterFilter (l : Filter α) [CountableInterFilter l] : CardinalInterFilter l (aleph 1) where cardinal_sInter_mem S hS a := CountableInterFilter.countable_sInter_mem S ((countable_iff_lt_aleph_one S).mpr hS) a theorem cardinalInterFilter_aleph_one_iff : CardinalInterFilter l (aleph 1) ↔ CountableInterFilter l := ⟨fun _ ↦ ⟨fun S h a ↦ CardinalInterFilter.cardinal_sInter_mem S ((countable_iff_lt_aleph_one S).1 h) a⟩, fun _ ↦ CountableInterFilter.toCardinalInterFilter l⟩ /-- Every CardinalInterFilter for some c also is a CardinalInterFilter for some a ≤ c -/ theorem CardinalInterFilter.of_cardinalInterFilter_of_le (l : Filter α) [CardinalInterFilter l c] {a : Cardinal.{u}} (hac : a ≤ c) : CardinalInterFilter l a where cardinal_sInter_mem S hS a := CardinalInterFilter.cardinal_sInter_mem S (lt_of_lt_of_le hS hac) a theorem CardinalInterFilter.of_cardinalInterFilter_of_lt (l : Filter α) [CardinalInterFilter l c] {a : Cardinal.{u}} (hac : a < c) : CardinalInterFilter l a := CardinalInterFilter.of_cardinalInterFilter_of_le l (hac.le) namespace Filter variable [CardinalInterFilter l c] theorem cardinal_iInter_mem {s : ι → Set α} (hic : #ι < c) : (⋂ i, s i) ∈ l ↔ ∀ i, s i ∈ l := by rw [← sInter_range _] apply (cardinal_sInter_mem (lt_of_le_of_lt Cardinal.mk_range_le hic)).trans exact forall_mem_range theorem cardinal_bInter_mem {S : Set ι} (hS : #S < c) {s : ∀ i ∈ S, Set α} : (⋂ i, ⋂ hi : i ∈ S, s i ‹_›) ∈ l ↔ ∀ i, ∀ hi : i ∈ S, s i ‹_› ∈ l := by rw [biInter_eq_iInter] exact (cardinal_iInter_mem hS).trans Subtype.forall
Mathlib/Order/Filter/CardinalInter.lean
102
105
theorem eventually_cardinal_forall {p : α → ι → Prop} (hic : #ι < c) : (∀ᶠ x in l, ∀ i, p x i) ↔ ∀ i, ∀ᶠ x in l, p x i := by
simp only [Filter.Eventually, setOf_forall] exact cardinal_iInter_mem hic
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.SetTheory.Cardinal.Ordinal #align_import set_theory.cardinal.continuum from "leanprover-community/mathlib"@"e08a42b2dd544cf11eba72e5fc7bf199d4349925" /-! # Cardinality of continuum In this file we define `Cardinal.continuum` (notation: `𝔠`, localized in `Cardinal`) to be `2 ^ ℵ₀`. We also prove some `simp` lemmas about cardinal arithmetic involving `𝔠`. ## Notation - `𝔠` : notation for `Cardinal.continuum` in locale `Cardinal`. -/ namespace Cardinal universe u v open Cardinal /-- Cardinality of continuum. -/ def continuum : Cardinal.{u} := 2 ^ ℵ₀ #align cardinal.continuum Cardinal.continuum scoped notation "𝔠" => Cardinal.continuum @[simp] theorem two_power_aleph0 : 2 ^ aleph0.{u} = continuum.{u} := rfl #align cardinal.two_power_aleph_0 Cardinal.two_power_aleph0 @[simp] theorem lift_continuum : lift.{v} 𝔠 = 𝔠 := by rw [← two_power_aleph0, lift_two_power, lift_aleph0, two_power_aleph0] #align cardinal.lift_continuum Cardinal.lift_continuum @[simp] theorem continuum_le_lift {c : Cardinal.{u}} : 𝔠 ≤ lift.{v} c ↔ 𝔠 ≤ c := by -- Porting note: added explicit universes rw [← lift_continuum.{u,v}, lift_le] #align cardinal.continuum_le_lift Cardinal.continuum_le_lift @[simp]
Mathlib/SetTheory/Cardinal/Continuum.lean
52
54
theorem lift_le_continuum {c : Cardinal.{u}} : lift.{v} c ≤ 𝔠 ↔ c ≤ 𝔠 := by
-- Porting note: added explicit universes rw [← lift_continuum.{u,v}, lift_le]
/- 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.Data.Nat.Factorization.Basic #align_import data.nat.factorization.prime_pow from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f" /-! # Prime powers and factorizations This file deals with factorizations of prime powers. -/ variable {R : Type*} [CommMonoidWithZero R] (n p : R) (k : ℕ) theorem IsPrimePow.minFac_pow_factorization_eq {n : ℕ} (hn : IsPrimePow n) : n.minFac ^ n.factorization n.minFac = n := by obtain ⟨p, k, hp, hk, rfl⟩ := hn rw [← Nat.prime_iff] at hp rw [hp.pow_minFac hk.ne', hp.factorization_pow, Finsupp.single_eq_same] #align is_prime_pow.min_fac_pow_factorization_eq IsPrimePow.minFac_pow_factorization_eq theorem isPrimePow_of_minFac_pow_factorization_eq {n : ℕ} (h : n.minFac ^ n.factorization n.minFac = n) (hn : n ≠ 1) : IsPrimePow n := by rcases eq_or_ne n 0 with (rfl | hn') · simp_all refine ⟨_, _, (Nat.minFac_prime hn).prime, ?_, h⟩ simp [pos_iff_ne_zero, ← Finsupp.mem_support_iff, Nat.support_factorization, hn', Nat.minFac_prime hn, Nat.minFac_dvd] #align is_prime_pow_of_min_fac_pow_factorization_eq isPrimePow_of_minFac_pow_factorization_eq theorem isPrimePow_iff_minFac_pow_factorization_eq {n : ℕ} (hn : n ≠ 1) : IsPrimePow n ↔ n.minFac ^ n.factorization n.minFac = n := ⟨fun h => h.minFac_pow_factorization_eq, fun h => isPrimePow_of_minFac_pow_factorization_eq h hn⟩ #align is_prime_pow_iff_min_fac_pow_factorization_eq isPrimePow_iff_minFac_pow_factorization_eq theorem isPrimePow_iff_factorization_eq_single {n : ℕ} : IsPrimePow n ↔ ∃ p k : ℕ, 0 < k ∧ n.factorization = Finsupp.single p k := by rw [isPrimePow_nat_iff] refine exists₂_congr fun p k => ?_ constructor · rintro ⟨hp, hk, hn⟩ exact ⟨hk, by rw [← hn, Nat.Prime.factorization_pow hp]⟩ · rintro ⟨hk, hn⟩ have hn0 : n ≠ 0 := by rintro rfl simp_all only [Finsupp.single_eq_zero, eq_comm, Nat.factorization_zero, hk.ne'] rw [Nat.eq_pow_of_factorization_eq_single hn0 hn] exact ⟨Nat.prime_of_mem_primeFactors <| Finsupp.mem_support_iff.2 (by simp [hn, hk.ne'] : n.factorization p ≠ 0), hk, rfl⟩ #align is_prime_pow_iff_factorization_eq_single isPrimePow_iff_factorization_eq_single theorem isPrimePow_iff_card_primeFactors_eq_one {n : ℕ} : IsPrimePow n ↔ n.primeFactors.card = 1 := by simp_rw [isPrimePow_iff_factorization_eq_single, ← Nat.support_factorization, Finsupp.card_support_eq_one', pos_iff_ne_zero] #align is_prime_pow_iff_card_support_factorization_eq_one isPrimePow_iff_card_primeFactors_eq_one
Mathlib/Data/Nat/Factorization/PrimePow.lean
63
73
theorem IsPrimePow.exists_ord_compl_eq_one {n : ℕ} (h : IsPrimePow n) : ∃ p : ℕ, p.Prime ∧ ord_compl[p] n = 1 := by
rcases eq_or_ne n 0 with (rfl | hn0); · cases not_isPrimePow_zero h rcases isPrimePow_iff_factorization_eq_single.mp h with ⟨p, k, hk0, h1⟩ rcases em' p.Prime with (pp | pp) · refine absurd ?_ hk0.ne' simp [← Nat.factorization_eq_zero_of_non_prime n pp, h1] refine ⟨p, pp, ?_⟩ refine Nat.eq_of_factorization_eq (Nat.ord_compl_pos p hn0).ne' (by simp) fun q => ?_ rw [Nat.factorization_ord_compl n p, h1] simp
/- 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
Mathlib/GroupTheory/Solvable.lean
56
59
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
/- 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, Eric Rodriguez -/ import Mathlib.Algebra.Order.Field.Basic import Mathlib.Data.Nat.Cast.Order import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.Cast.Order #align_import data.nat.choose.bounds from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11" /-! # Inequalities for binomial coefficients This file proves exponential bounds on binomial coefficients. We might want to add here the bounds `n^r/r^r ≤ n.choose r ≤ e^r n^r/r^r` in the future. ## Main declarations * `Nat.choose_le_pow`: `n.choose r ≤ n^r / r!` * `Nat.pow_le_choose`: `(n + 1 - r)^r / r! ≤ n.choose r`. Beware of the fishy ℕ-subtraction. -/ open Nat variable {α : Type*} [LinearOrderedSemifield α] namespace Nat
Mathlib/Data/Nat/Choose/Bounds.lean
32
37
theorem choose_le_pow (r n : ℕ) : (n.choose r : α) ≤ (n ^ r : α) / r ! := by
rw [le_div_iff'] · norm_cast rw [← Nat.descFactorial_eq_factorial_mul_choose] exact n.descFactorial_le_pow r exact mod_cast r.factorial_pos
/- Copyright (c) 2020 Thomas Browning and Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning, Patrick Lutz -/ import Mathlib.GroupTheory.Solvable import Mathlib.FieldTheory.PolynomialGaloisGroup import Mathlib.RingTheory.RootsOfUnity.Basic #align_import field_theory.abel_ruffini from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a" /-! # The Abel-Ruffini Theorem This file proves one direction of the Abel-Ruffini theorem, namely that if an element is solvable by radicals, then its minimal polynomial has solvable Galois group. ## Main definitions * `solvableByRad F E` : the intermediate field of solvable-by-radicals elements ## Main results * the Abel-Ruffini Theorem `solvableByRad.isSolvable'` : An irreducible polynomial with a root that is solvable by radicals has a solvable Galois group. -/ noncomputable section open scoped Classical Polynomial IntermediateField open Polynomial IntermediateField section AbelRuffini variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E] theorem gal_zero_isSolvable : IsSolvable (0 : F[X]).Gal := by infer_instance #align gal_zero_is_solvable gal_zero_isSolvable theorem gal_one_isSolvable : IsSolvable (1 : F[X]).Gal := by infer_instance #align gal_one_is_solvable gal_one_isSolvable theorem gal_C_isSolvable (x : F) : IsSolvable (C x).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_C_is_solvable gal_C_isSolvable
Mathlib/FieldTheory/AbelRuffini.lean
49
49
theorem gal_X_isSolvable : IsSolvable (X : F[X]).Gal := by
infer_instance
/- Copyright (c) 2019 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca, Johan Commelin -/ import Mathlib.Algebra.Polynomial.FieldDivision import Mathlib.FieldTheory.Minpoly.Basic import Mathlib.RingTheory.Algebraic #align_import field_theory.minpoly.field from "leanprover-community/mathlib"@"cbdf7b565832144d024caa5a550117c6df0204a5" /-! # Minimal polynomials on an algebra over a field This file specializes the theory of minpoly to the setting of field extensions and derives some well-known properties, amongst which the fact that minimal polynomials are irreducible, and uniquely determined by their defining property. -/ open scoped Classical open Polynomial Set Function minpoly namespace minpoly variable {A B : Type*} variable (A) [Field A] section Ring variable [Ring B] [Algebra A B] (x : B) /-- If an element `x` is a root of a nonzero polynomial `p`, then the degree of `p` is at least the degree of the minimal polynomial of `x`. See also `minpoly.IsIntegrallyClosed.degree_le_of_ne_zero` which relaxes the assumptions on `A` in exchange for stronger assumptions on `B`. -/ theorem degree_le_of_ne_zero {p : A[X]} (pnz : p ≠ 0) (hp : Polynomial.aeval x p = 0) : degree (minpoly A x) ≤ degree p := calc degree (minpoly A x) ≤ degree (p * C (leadingCoeff p)⁻¹) := min A x (monic_mul_leadingCoeff_inv pnz) (by simp [hp]) _ = degree p := degree_mul_leadingCoeff_inv p pnz #align minpoly.degree_le_of_ne_zero minpoly.degree_le_of_ne_zero theorem ne_zero_of_finite (e : B) [FiniteDimensional A B] : minpoly A e ≠ 0 := minpoly.ne_zero <| .of_finite A _ #align minpoly.ne_zero_of_finite_field_extension minpoly.ne_zero_of_finite /-- The minimal polynomial of an element `x` is uniquely characterized by its defining property: if there is another monic polynomial of minimal degree that has `x` as a root, then this polynomial is equal to the minimal polynomial of `x`. See also `minpoly.IsIntegrallyClosed.Minpoly.unique` which relaxes the assumptions on `A` in exchange for stronger assumptions on `B`. -/ theorem unique {p : A[X]} (pmonic : p.Monic) (hp : Polynomial.aeval x p = 0) (pmin : ∀ q : A[X], q.Monic → Polynomial.aeval x q = 0 → degree p ≤ degree q) : p = minpoly A x := by have hx : IsIntegral A x := ⟨p, pmonic, hp⟩ symm; apply eq_of_sub_eq_zero by_contra hnz apply degree_le_of_ne_zero A x hnz (by simp [hp]) |>.not_lt apply degree_sub_lt _ (minpoly.ne_zero hx) · rw [(monic hx).leadingCoeff, pmonic.leadingCoeff] · exact le_antisymm (min A x pmonic hp) (pmin (minpoly A x) (monic hx) (aeval A x)) #align minpoly.unique minpoly.unique /-- If an element `x` is a root of a polynomial `p`, then the minimal polynomial of `x` divides `p`. See also `minpoly.isIntegrallyClosed_dvd` which relaxes the assumptions on `A` in exchange for stronger assumptions on `B`. -/ theorem dvd {p : A[X]} (hp : Polynomial.aeval x p = 0) : minpoly A x ∣ p := by by_cases hp0 : p = 0 · simp only [hp0, dvd_zero] have hx : IsIntegral A x := IsAlgebraic.isIntegral ⟨p, hp0, hp⟩ rw [← modByMonic_eq_zero_iff_dvd (monic hx)] by_contra hnz apply degree_le_of_ne_zero A x hnz ((aeval_modByMonic_eq_self_of_root (monic hx) (aeval _ _)).trans hp) |>.not_lt exact degree_modByMonic_lt _ (monic hx) #align minpoly.dvd minpoly.dvd variable {A x} in lemma dvd_iff {p : A[X]} : minpoly A x ∣ p ↔ Polynomial.aeval x p = 0 := ⟨fun ⟨q, hq⟩ ↦ by rw [hq, map_mul, aeval, zero_mul], minpoly.dvd A x⟩ theorem isRadical [IsReduced B] : IsRadical (minpoly A x) := fun n p dvd ↦ by rw [dvd_iff] at dvd ⊢; rw [map_pow] at dvd; exact IsReduced.eq_zero _ ⟨n, dvd⟩
Mathlib/FieldTheory/Minpoly/Field.lean
86
90
theorem dvd_map_of_isScalarTower (A K : Type*) {R : Type*} [CommRing A] [Field K] [CommRing R] [Algebra A K] [Algebra A R] [Algebra K R] [IsScalarTower A K R] (x : R) : minpoly K x ∣ (minpoly A x).map (algebraMap A K) := by
refine minpoly.dvd K x ?_ rw [aeval_map_algebraMap, minpoly.aeval]
/- Copyright (c) 2020 Fox Thomson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Fox Thomson -/ import Mathlib.SetTheory.Game.Basic import Mathlib.Tactic.NthRewrite #align_import set_theory.game.impartial from "leanprover-community/mathlib"@"2e0975f6a25dd3fbfb9e41556a77f075f6269748" /-! # Basic definitions about impartial (pre-)games We will define an impartial game, one in which left and right can make exactly the same moves. Our definition differs slightly by saying that the game is always equivalent to its negative, no matter what moves are played. This allows for games such as poker-nim to be classified as impartial. -/ universe u namespace SetTheory open scoped PGame namespace PGame /-- The definition for an impartial game, defined using Conway induction. -/ def ImpartialAux : PGame → Prop | G => (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j) termination_by G => G -- Porting note: Added `termination_by` #align pgame.impartial_aux SetTheory.PGame.ImpartialAux
Mathlib/SetTheory/Game/Impartial.lean
35
38
theorem impartialAux_def {G : PGame} : G.ImpartialAux ↔ (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j) := by
rw [ImpartialAux]
/- Copyright (c) 2024 Moritz Doll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Doll -/ import Mathlib.Topology.ContinuousFunction.ZeroAtInfty /-! # ZeroAtInftyContinuousMapClass in normed additive groups In this file we give a characterization of the predicate `zero_at_infty` from `ZeroAtInftyContinuousMapClass`. A continuous map `f` is zero at infinity if and only if for every `ε > 0` there exists a `r : ℝ` such that for all `x : E` with `r < ‖x‖` it holds that `‖f x‖ < ε`. -/ open Topology Filter variable {E F 𝓕 : Type*} variable [SeminormedAddGroup E] [SeminormedAddCommGroup F] variable [FunLike 𝓕 E F] [ZeroAtInftyContinuousMapClass 𝓕 E F]
Mathlib/Analysis/Normed/Group/ZeroAtInfty.lean
24
34
theorem ZeroAtInftyContinuousMapClass.norm_le (f : 𝓕) (ε : ℝ) (hε : 0 < ε) : ∃ (r : ℝ), ∀ (x : E) (_hx : r < ‖x‖), ‖f x‖ < ε := by
have h := zero_at_infty f rw [tendsto_zero_iff_norm_tendsto_zero, tendsto_def] at h specialize h (Metric.ball 0 ε) (Metric.ball_mem_nhds 0 hε) rcases Metric.closedBall_compl_subset_of_mem_cocompact h 0 with ⟨r, hr⟩ use r intro x hr' suffices x ∈ (fun x ↦ ‖f x‖) ⁻¹' Metric.ball 0 ε by aesop apply hr aesop
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax import Mathlib.Algebra.Order.Monoid.WithTop import Mathlib.Data.Finset.Image import Mathlib.Data.Multiset.Fold #align_import data.finset.fold from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # The fold operation for a commutative associative operation over a finset. -/ -- TODO: -- assert_not_exists OrderedCommMonoid assert_not_exists MonoidWithZero namespace Finset open Multiset variable {α β γ : Type*} /-! ### fold -/ section Fold variable (op : β → β → β) [hc : Std.Commutative op] [ha : Std.Associative op] local notation a " * " b => op a b /-- `fold op b f s` folds the commutative associative operation `op` over the `f`-image of `s`, i.e. `fold (+) b f {1,2,3} = f 1 + f 2 + f 3 + b`. -/ def fold (b : β) (f : α → β) (s : Finset α) : β := (s.1.map f).fold op b #align finset.fold Finset.fold variable {op} {f : α → β} {b : β} {s : Finset α} {a : α} @[simp] theorem fold_empty : (∅ : Finset α).fold op b f = b := rfl #align finset.fold_empty Finset.fold_empty @[simp] theorem fold_cons (h : a ∉ s) : (cons a s h).fold op b f = f a * s.fold op b f := by dsimp only [fold] rw [cons_val, Multiset.map_cons, fold_cons_left] #align finset.fold_cons Finset.fold_cons @[simp] theorem fold_insert [DecidableEq α] (h : a ∉ s) : (insert a s).fold op b f = f a * s.fold op b f := by unfold fold rw [insert_val, ndinsert_of_not_mem h, Multiset.map_cons, fold_cons_left] #align finset.fold_insert Finset.fold_insert @[simp] theorem fold_singleton : ({a} : Finset α).fold op b f = f a * b := rfl #align finset.fold_singleton Finset.fold_singleton @[simp] theorem fold_map {g : γ ↪ α} {s : Finset γ} : (s.map g).fold op b f = s.fold op b (f ∘ g) := by simp only [fold, map, Multiset.map_map] #align finset.fold_map Finset.fold_map @[simp] theorem fold_image [DecidableEq α] {g : γ → α} {s : Finset γ} (H : ∀ x ∈ s, ∀ y ∈ s, g x = g y → x = y) : (s.image g).fold op b f = s.fold op b (f ∘ g) := by simp only [fold, image_val_of_injOn H, Multiset.map_map] #align finset.fold_image Finset.fold_image @[congr] theorem fold_congr {g : α → β} (H : ∀ x ∈ s, f x = g x) : s.fold op b f = s.fold op b g := by rw [fold, fold, map_congr rfl H] #align finset.fold_congr Finset.fold_congr
Mathlib/Data/Finset/Fold.lean
83
85
theorem fold_op_distrib {f g : α → β} {b₁ b₂ : β} : (s.fold op (b₁ * b₂) fun x => f x * g x) = s.fold op b₁ f * s.fold op b₂ g := by
simp only [fold, fold_distrib]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Yury Kudryashov -/ import Mathlib.MeasureTheory.Constructions.BorelSpace.Order #align_import measure_theory.constructions.borel_space.basic from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce" /-! # Borel (measurable) spaces ℝ, ℝ≥0, ℝ≥0∞ ## Main statements * `borel_eq_generateFrom_Ixx_rat` (where Ixx is one of {Ioo, Ioi, Iio, Ici, Iic): the Borel sigma algebra on ℝ is generated by intervals with rational endpoints; * `isPiSystem_Ixx_rat` (where Ixx is one of {Ioo, Ioi, Iio, Ici, Iic): intervals with rational endpoints form a pi system on ℝ; * `measurable_real_toNNReal`, `measurable_coe_nnreal_real`, `measurable_coe_nnreal_ennreal`, `ENNReal.measurable_ofReal`, `ENNReal.measurable_toReal`: measurability of various coercions between ℝ, ℝ≥0, and ℝ≥0∞; * `Measurable.real_toNNReal`, `Measurable.coe_nnreal_real`, `Measurable.coe_nnreal_ennreal`, `Measurable.ennreal_ofReal`, `Measurable.ennreal_toNNReal`, `Measurable.ennreal_toReal`: measurability of functions composed with various coercions between ℝ, ℝ≥0, and ℝ≥0∞ (also similar results for a.e.-measurability); * `Measurable.ennreal*` : measurability of special cases for arithmetic operations on `ℝ≥0∞`. -/ open Set Filter MeasureTheory MeasurableSpace open scoped Classical Topology NNReal ENNReal MeasureTheory universe u v w x y variable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α} namespace Real theorem borel_eq_generateFrom_Ioo_rat : borel ℝ = .generateFrom (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) (b : ℝ)}) := isTopologicalBasis_Ioo_rat.borel_eq_generateFrom #align real.borel_eq_generate_from_Ioo_rat Real.borel_eq_generateFrom_Ioo_rat theorem borel_eq_generateFrom_Iio_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Iio (a : ℝ)}) := by rw [borel_eq_generateFrom_Iio] refine le_antisymm (generateFrom_le ?_) (generateFrom_mono <| iUnion_subset fun q ↦ singleton_subset_iff.mpr <| mem_range_self _) rintro _ ⟨a, rfl⟩ have : IsLUB (range ((↑) : ℚ → ℝ) ∩ Iio a) a := by simp [isLUB_iff_le_iff, mem_upperBounds, ← le_iff_forall_rat_lt_imp_le] rw [← this.biUnion_Iio_eq, ← image_univ, ← image_inter_preimage, univ_inter, biUnion_image] exact MeasurableSet.biUnion (to_countable _) fun b _ => GenerateMeasurable.basic (Iio (b : ℝ)) (by simp)
Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean
56
66
theorem borel_eq_generateFrom_Ioi_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Ioi (a : ℝ)}) := by
rw [borel_eq_generateFrom_Ioi] refine le_antisymm (generateFrom_le ?_) (generateFrom_mono <| iUnion_subset fun q ↦ singleton_subset_iff.mpr <| mem_range_self _) rintro _ ⟨a, rfl⟩ have : IsGLB (range ((↑) : ℚ → ℝ) ∩ Ioi a) a := by simp [isGLB_iff_le_iff, mem_lowerBounds, ← le_iff_forall_lt_rat_imp_le] rw [← this.biUnion_Ioi_eq, ← image_univ, ← image_inter_preimage, univ_inter, biUnion_image] exact MeasurableSet.biUnion (to_countable _) fun b _ => GenerateMeasurable.basic (Ioi (b : ℝ)) (by simp)
/- Copyright (c) 2022 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import Mathlib.SetTheory.Cardinal.Finite #align_import data.finite.card from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" /-! # Cardinality of finite types The cardinality of a finite type `α` is given by `Nat.card α`. This function has the "junk value" of `0` for infinite types, but to ensure the function has valid output, one just needs to know that it's possible to produce a `Finite` instance for the type. (Note: we could have defined a `Finite.card` that required you to supply a `Finite` instance, but (a) the function would be `noncomputable` anyway so there is no need to supply the instance and (b) the function would have a more complicated dependent type that easily leads to "motive not type correct" errors.) ## Implementation notes Theorems about `Nat.card` are sometimes incidentally true for both finite and infinite types. If removing a finiteness constraint results in no loss in legibility, we remove it. We generally put such theorems into the `SetTheory.Cardinal.Finite` module. -/ noncomputable section open scoped Classical variable {α β γ : Type*} /-- There is (noncomputably) an equivalence between a finite type `α` and `Fin (Nat.card α)`. -/ def Finite.equivFin (α : Type*) [Finite α] : α ≃ Fin (Nat.card α) := by have := (Finite.exists_equiv_fin α).choose_spec.some rwa [Nat.card_eq_of_equiv_fin this] #align finite.equiv_fin Finite.equivFin /-- Similar to `Finite.equivFin` but with control over the term used for the cardinality. -/ def Finite.equivFinOfCardEq [Finite α] {n : ℕ} (h : Nat.card α = n) : α ≃ Fin n := by subst h apply Finite.equivFin #align finite.equiv_fin_of_card_eq Finite.equivFinOfCardEq theorem Nat.card_eq (α : Type*) : Nat.card α = if h : Finite α then @Fintype.card α (Fintype.ofFinite α) else 0 := by cases finite_or_infinite α · letI := Fintype.ofFinite α simp only [*, Nat.card_eq_fintype_card, dif_pos] · simp only [*, card_eq_zero_of_infinite, not_finite_iff_infinite.mpr, dite_false] #align nat.card_eq Nat.card_eq theorem Finite.card_pos_iff [Finite α] : 0 < Nat.card α ↔ Nonempty α := by haveI := Fintype.ofFinite α rw [Nat.card_eq_fintype_card, Fintype.card_pos_iff] #align finite.card_pos_iff Finite.card_pos_iff theorem Finite.card_pos [Finite α] [h : Nonempty α] : 0 < Nat.card α := Finite.card_pos_iff.mpr h #align finite.card_pos Finite.card_pos namespace Finite theorem cast_card_eq_mk {α : Type*} [Finite α] : ↑(Nat.card α) = Cardinal.mk α := Cardinal.cast_toNat_of_lt_aleph0 (Cardinal.lt_aleph0_of_finite α) #align finite.cast_card_eq_mk Finite.cast_card_eq_mk theorem card_eq [Finite α] [Finite β] : Nat.card α = Nat.card β ↔ Nonempty (α ≃ β) := by haveI := Fintype.ofFinite α haveI := Fintype.ofFinite β simp only [Nat.card_eq_fintype_card, Fintype.card_eq] #align finite.card_eq Finite.card_eq theorem card_le_one_iff_subsingleton [Finite α] : Nat.card α ≤ 1 ↔ Subsingleton α := by haveI := Fintype.ofFinite α simp only [Nat.card_eq_fintype_card, Fintype.card_le_one_iff_subsingleton] #align finite.card_le_one_iff_subsingleton Finite.card_le_one_iff_subsingleton
Mathlib/Data/Finite/Card.lean
83
85
theorem one_lt_card_iff_nontrivial [Finite α] : 1 < Nat.card α ↔ Nontrivial α := by
haveI := Fintype.ofFinite α simp only [Nat.card_eq_fintype_card, Fintype.one_lt_card_iff_nontrivial]
/- Copyright (c) 2014 Robert Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Lewis, Leonardo de Moura, Mario Carneiro, Floris van Doorn -/ import Mathlib.Algebra.Field.Basic import Mathlib.Algebra.GroupWithZero.Units.Equiv import Mathlib.Algebra.Order.Field.Defs import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Order.Bounds.OrderIso import Mathlib.Tactic.Positivity.Core #align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd" /-! # Lemmas about linear ordered (semi)fields -/ open Function OrderDual variable {ι α β : Type*} section LinearOrderedSemifield variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ} /-- `Equiv.mulLeft₀` as an order_iso. -/ @[simps! (config := { simpRhs := true })] def OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_left ha } #align order_iso.mul_left₀ OrderIso.mulLeft₀ #align order_iso.mul_left₀_symm_apply OrderIso.mulLeft₀_symm_apply #align order_iso.mul_left₀_apply OrderIso.mulLeft₀_apply /-- `Equiv.mulRight₀` as an order_iso. -/ @[simps! (config := { simpRhs := true })] def OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulRight₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_right ha } #align order_iso.mul_right₀ OrderIso.mulRight₀ #align order_iso.mul_right₀_symm_apply OrderIso.mulRight₀_symm_apply #align order_iso.mul_right₀_apply OrderIso.mulRight₀_apply /-! ### Relating one division with another term. -/ theorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b := ⟨fun h => div_mul_cancel₀ b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h => calc a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm _ ≤ b * (1 / c) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le _ = b / c := (div_eq_mul_one_div b c).symm ⟩ #align le_div_iff le_div_iff theorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc] #align le_div_iff' le_div_iff' theorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b := ⟨fun h => calc a = a / b * b := by rw [div_mul_cancel₀ _ (ne_of_lt hb).symm] _ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le , fun h => calc a / b = a * (1 / b) := div_eq_mul_one_div a b _ ≤ c * b * (1 / b) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le _ = c * b / b := (div_eq_mul_one_div (c * b) b).symm _ = c := by refine (div_eq_iff (ne_of_gt hb)).mpr rfl ⟩ #align div_le_iff div_le_iff theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by rw [mul_comm, div_le_iff hb] #align div_le_iff' div_le_iff' lemma div_le_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b ≤ c ↔ a / c ≤ b := by rw [div_le_iff hb, div_le_iff' hc] theorem lt_div_iff (hc : 0 < c) : a < b / c ↔ a * c < b := lt_iff_lt_of_le_iff_le <| div_le_iff hc #align lt_div_iff lt_div_iff
Mathlib/Algebra/Order/Field/Basic.lean
86
86
theorem lt_div_iff' (hc : 0 < c) : a < b / c ↔ c * a < b := by
rw [mul_comm, lt_div_iff hc]
/- Copyright (c) 2024 Paul Reichert. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Paul Reichert -/ import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.IsConnected import Mathlib.CategoryTheory.Limits.Final import Mathlib.CategoryTheory.Conj /-! # Colimits of connected index categories This file proves two characterizations of connected categories by means of colimits. ## Characterization of connected categories by means of the unit-valued functor First, it is proved that a category `C` is connected if and only if `colim F` is a singleton, where `F : C ⥤ Type w` and `F.obj _ = PUnit` (for arbitrary `w`). See `isConnected_iff_colimit_constPUnitFunctor_iso_pUnit` for the proof of this characterization and `constPUnitFunctor` for the definition of the constant functor used in the statement. A formulation based on `IsColimit` instead of `colimit` is given in `isConnected_iff_isColimit_pUnitCocone`. The `if` direction is also available directly in several formulations: For connected index categories `C`, `PUnit.{w}` is a colimit of the `constPUnitFunctor`, where `w` is arbitrary. See `instHasColimitConstPUnitFunctor`, `isColimitPUnitCocone` and `colimitConstPUnitIsoPUnit`. ## Final functors preserve connectedness of categories (in both directions) `isConnected_iff_of_final` proves that the domain of a final functor is connected if and only if its codomain is connected. ## Tags unit-valued, singleton, colimit -/ universe w v u namespace CategoryTheory.Limits.Types variable (C : Type u) [Category.{v} C] /-- The functor mapping every object to `PUnit`. -/ def constPUnitFunctor : C ⥤ Type w := (Functor.const C).obj PUnit.{w + 1} /-- The cocone on `constPUnitFunctor` with cone point `PUnit`. -/ @[simps] def pUnitCocone : Cocone (constPUnitFunctor.{w} C) where pt := PUnit ι := { app := fun X => id } /-- If `C` is connected, the cocone on `constPUnitFunctor` with cone point `PUnit` is a colimit cocone. -/ noncomputable def isColimitPUnitCocone [IsConnected C] : IsColimit (pUnitCocone.{w} C) where desc s := s.ι.app Classical.ofNonempty fac s j := by ext ⟨⟩ apply constant_of_preserves_morphisms (s.ι.app · PUnit.unit) intros X Y f exact congrFun (s.ι.naturality f).symm PUnit.unit uniq s m h := by ext ⟨⟩ simp [← h Classical.ofNonempty] instance instHasColimitConstPUnitFunctor [IsConnected C] : HasColimit (constPUnitFunctor.{w} C) := ⟨_, isColimitPUnitCocone _⟩ instance instSubsingletonColimitPUnit [IsPreconnected C] [HasColimit (constPUnitFunctor.{w} C)] : Subsingleton (colimit (constPUnitFunctor.{w} C)) where allEq a b := by obtain ⟨c, ⟨⟩, rfl⟩ := jointly_surjective' a obtain ⟨d, ⟨⟩, rfl⟩ := jointly_surjective' b apply constant_of_preserves_morphisms (colimit.ι (constPUnitFunctor C) · PUnit.unit) exact fun c d f => colimit_sound f rfl /-- Given a connected index category, the colimit of the constant unit-valued functor is `PUnit`. -/ noncomputable def colimitConstPUnitIsoPUnit [IsConnected C] : colimit (constPUnitFunctor.{w} C) ≅ PUnit.{w + 1} := IsColimit.coconePointUniqueUpToIso (colimit.isColimit _) (isColimitPUnitCocone.{w} C) /-- Let `F` be a `Type`-valued functor. If two elements `a : F c` and `b : F d` represent the same element of `colimit F`, then `c` and `d` are related by a `Zigzag`. -/
Mathlib/CategoryTheory/Limits/IsConnected.lean
87
93
theorem zigzag_of_eqvGen_quot_rel (F : C ⥤ Type w) (c d : Σ j, F.obj j) (h : EqvGen (Quot.Rel F) c d) : Zigzag c.1 d.1 := by
induction h with | rel _ _ h => exact Zigzag.of_hom <| Exists.choose h | refl _ => exact Zigzag.refl _ | symm _ _ _ ih => exact zigzag_symmetric ih | trans _ _ _ _ _ ih₁ ih₂ => exact ih₁.trans ih₂
/- Copyright (c) 2021 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Combinatorics.SetFamily.Shadow #align_import combinatorics.set_family.compression.uv from "leanprover-community/mathlib"@"6f8ab7de1c4b78a68ab8cf7dd83d549eb78a68a1" /-! # UV-compressions This file defines UV-compression. It is an operation on a set family that reduces its shadow. UV-compressing `a : α` along `u v : α` means replacing `a` by `(a ⊔ u) \ v` if `a` and `u` are disjoint and `v ≤ a`. In some sense, it's moving `a` from `v` to `u`. UV-compressions are immensely useful to prove the Kruskal-Katona theorem. The idea is that compressing a set family might decrease the size of its shadow, so iterated compressions hopefully minimise the shadow. ## Main declarations * `UV.compress`: `compress u v a` is `a` compressed along `u` and `v`. * `UV.compression`: `compression u v s` is the compression of the set family `s` along `u` and `v`. It is the compressions of the elements of `s` whose compression is not already in `s` along with the element whose compression is already in `s`. This way of splitting into what moves and what does not ensures the compression doesn't squash the set family, which is proved by `UV.card_compression`. * `UV.card_shadow_compression_le`: Compressing reduces the size of the shadow. This is a key fact in the proof of Kruskal-Katona. ## Notation `𝓒` (typed with `\MCC`) is notation for `UV.compression` in locale `FinsetFamily`. ## Notes Even though our emphasis is on `Finset α`, we define UV-compressions more generally in a generalized boolean algebra, so that one can use it for `Set α`. ## References * https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf ## Tags compression, UV-compression, shadow -/ open Finset variable {α : Type*} /-- UV-compression is injective on the elements it moves. See `UV.compress`. -/
Mathlib/Combinatorics/SetFamily/Compression/UV.lean
57
64
theorem sup_sdiff_injOn [GeneralizedBooleanAlgebra α] (u v : α) : { x | Disjoint u x ∧ v ≤ x }.InjOn fun x => (x ⊔ u) \ v := by
rintro a ha b hb hab have h : ((a ⊔ u) \ v) \ u ⊔ v = ((b ⊔ u) \ v) \ u ⊔ v := by dsimp at hab rw [hab] rwa [sdiff_sdiff_comm, ha.1.symm.sup_sdiff_cancel_right, sdiff_sdiff_comm, hb.1.symm.sup_sdiff_cancel_right, sdiff_sup_cancel ha.2, sdiff_sup_cancel hb.2] at h
/- 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]
Mathlib/Data/Int/SuccPred.lean
79
79
theorem sub_one_covBy (z : ℤ) : z - 1 ⋖ z := by
rw [Int.covBy_iff_succ_eq, sub_add_cancel]
/- Copyright (c) 2021 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.CategoryTheory.Limits.Shapes.Multiequalizer import Mathlib.CategoryTheory.Limits.Constructions.EpiMono import Mathlib.CategoryTheory.Limits.Preserves.Limits import Mathlib.CategoryTheory.Limits.Shapes.Types #align_import category_theory.glue_data from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7" /-! # Gluing data We define `GlueData` as a family of data needed to glue topological spaces, schemes, etc. We provide the API to realize it as a multispan diagram, and also state lemmas about its interaction with a functor that preserves certain pullbacks. -/ noncomputable section open CategoryTheory.Limits namespace CategoryTheory universe v u₁ u₂ variable (C : Type u₁) [Category.{v} C] {C' : Type u₂} [Category.{v} C'] /-- A gluing datum consists of 1. An index type `J` 2. An object `U i` for each `i : J`. 3. An object `V i j` for each `i j : J`. 4. A monomorphism `f i j : V i j ⟶ U i` for each `i j : J`. 5. A transition map `t i j : V i j ⟶ V j i` for each `i j : J`. such that 6. `f i i` is an isomorphism. 7. `t i i` is the identity. 8. The pullback for `f i j` and `f i k` exists. 9. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some `t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`. 10. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`. -/ -- Porting note(#5171): linter not ported yet -- @[nolint has_nonempty_instance] structure GlueData where J : Type v U : J → C V : J × J → C f : ∀ i j, V (i, j) ⟶ U i f_mono : ∀ i j, Mono (f i j) := by infer_instance f_hasPullback : ∀ i j k, HasPullback (f i j) (f i k) := by infer_instance f_id : ∀ i, IsIso (f i i) := by infer_instance t : ∀ i j, V (i, j) ⟶ V (j, i) t_id : ∀ i, t i i = 𝟙 _ t' : ∀ i j k, pullback (f i j) (f i k) ⟶ pullback (f j k) (f j i) t_fac : ∀ i j k, t' i j k ≫ pullback.snd = pullback.fst ≫ t i j cocycle : ∀ i j k, t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _ #align category_theory.glue_data CategoryTheory.GlueData attribute [simp] GlueData.t_id attribute [instance] GlueData.f_id GlueData.f_mono GlueData.f_hasPullback attribute [reassoc] GlueData.t_fac GlueData.cocycle namespace GlueData variable {C} variable (D : GlueData C) @[simp] theorem t'_iij (i j : D.J) : D.t' i i j = (pullbackSymmetry _ _).hom := by have eq₁ := D.t_fac i i j have eq₂ := (IsIso.eq_comp_inv (D.f i i)).mpr (@pullback.condition _ _ _ _ _ _ (D.f i j) _) rw [D.t_id, Category.comp_id, eq₂] at eq₁ have eq₃ := (IsIso.eq_comp_inv (D.f i i)).mp eq₁ rw [Category.assoc, ← pullback.condition, ← Category.assoc] at eq₃ exact Mono.right_cancellation _ _ ((Mono.right_cancellation _ _ eq₃).trans (pullbackSymmetry_hom_comp_fst _ _).symm) #align category_theory.glue_data.t'_iij CategoryTheory.GlueData.t'_iij theorem t'_jii (i j : D.J) : D.t' j i i = pullback.fst ≫ D.t j i ≫ inv pullback.snd := by rw [← Category.assoc, ← D.t_fac] simp #align category_theory.glue_data.t'_jii CategoryTheory.GlueData.t'_jii theorem t'_iji (i j : D.J) : D.t' i j i = pullback.fst ≫ D.t i j ≫ inv pullback.snd := by rw [← Category.assoc, ← D.t_fac] simp #align category_theory.glue_data.t'_iji CategoryTheory.GlueData.t'_iji @[reassoc, elementwise (attr := simp)]
Mathlib/CategoryTheory/GlueData.lean
99
105
theorem t_inv (i j : D.J) : D.t i j ≫ D.t j i = 𝟙 _ := by
have eq : (pullbackSymmetry (D.f i i) (D.f i j)).hom = pullback.snd ≫ inv pullback.fst := by simp have := D.cocycle i j i rw [D.t'_iij, D.t'_jii, D.t'_iji, fst_eq_snd_of_mono_eq, eq] at this simp only [Category.assoc, IsIso.inv_hom_id_assoc] at this rw [← IsIso.eq_inv_comp, ← Category.assoc, IsIso.comp_inv_eq] at this simpa using this
/- Copyright (c) 2022 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Tactic.AdaptationNote #align_import geometry.euclidean.inversion from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Inversion in an affine space In this file we define inversion in a sphere in an affine space. This map sends each point `x` to the point `y` such that `y -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c)`, where `c` and `R` are the center and the radius the sphere. In many applications, it is convenient to assume that the inversions swaps the center and the point at infinity. In order to stay in the original affine space, we define the map so that it sends center to itself. Currently, we prove only a few basic lemmas needed to prove Ptolemy's inequality, see `EuclideanGeometry.mul_dist_le_mul_dist_add_mul_dist`. -/ noncomputable section open Metric Function AffineMap Set AffineSubspace open scoped Topology variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] namespace EuclideanGeometry variable {a b c d x y z : P} {r R : ℝ} /-- Inversion in a sphere in an affine space. This map sends each point `x` to the point `y` such that `y -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c)`, where `c` and `R` are the center and the radius the sphere. -/ def inversion (c : P) (R : ℝ) (x : P) : P := (R / dist x c) ^ 2 • (x -ᵥ c) +ᵥ c #align euclidean_geometry.inversion EuclideanGeometry.inversion #adaptation_note /-- nightly-2024-03-16: added to replace simp [inversion] -/ theorem inversion_def : inversion = fun (c : P) (R : ℝ) (x : P) => (R / dist x c) ^ 2 • (x -ᵥ c) +ᵥ c := rfl /-! ### Basic properties In this section we prove that `EuclideanGeometry.inversion c R` is involutive and preserves the sphere `Metric.sphere c R`. We also prove that the distance to the center of the image of `x` under this inversion is given by `R ^ 2 / dist x c`. -/ theorem inversion_eq_lineMap (c : P) (R : ℝ) (x : P) : inversion c R x = lineMap c x ((R / dist x c) ^ 2) := rfl theorem inversion_vsub_center (c : P) (R : ℝ) (x : P) : inversion c R x -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c) := vadd_vsub _ _ #align euclidean_geometry.inversion_vsub_center EuclideanGeometry.inversion_vsub_center @[simp] theorem inversion_self (c : P) (R : ℝ) : inversion c R c = c := by simp [inversion] #align euclidean_geometry.inversion_self EuclideanGeometry.inversion_self @[simp] theorem inversion_zero_radius (c x : P) : inversion c 0 x = c := by simp [inversion]
Mathlib/Geometry/Euclidean/Inversion/Basic.lean
75
78
theorem inversion_mul (c : P) (a R : ℝ) (x : P) : inversion c (a * R) x = homothety c (a ^ 2) (inversion c R x) := by
simp only [inversion_eq_lineMap, ← homothety_eq_lineMap, ← homothety_mul_apply, mul_div_assoc, mul_pow]