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) 2021 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Yaël Dillies -/ import Mathlib.Analysis.Normed.Group.Pointwise import Mathlib.Analysis.NormedSpace.Real #align_import analysis.normed_space.pointwise from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156" /-! # Properties of pointwise scalar multiplication of sets in normed spaces. We explore the relationships between scalar multiplication of sets in vector spaces, and the norm. Notably, we express arbitrary balls as rescaling of other balls, and we show that the multiplication of bounded sets remain bounded. -/ open Metric Set open Pointwise Topology variable {𝕜 E : Type*} section SMulZeroClass variable [SeminormedAddCommGroup 𝕜] [SeminormedAddCommGroup E] variable [SMulZeroClass 𝕜 E] [BoundedSMul 𝕜 E] theorem ediam_smul_le (c : 𝕜) (s : Set E) : EMetric.diam (c • s) ≤ ‖c‖₊ • EMetric.diam s := (lipschitzWith_smul c).ediam_image_le s #align ediam_smul_le ediam_smul_le end SMulZeroClass section DivisionRing variable [NormedDivisionRing 𝕜] [SeminormedAddCommGroup E] variable [Module 𝕜 E] [BoundedSMul 𝕜 E]
Mathlib/Analysis/NormedSpace/Pointwise.lean
42
50
theorem ediam_smul₀ (c : 𝕜) (s : Set E) : EMetric.diam (c • s) = ‖c‖₊ • EMetric.diam s := by
refine le_antisymm (ediam_smul_le c s) ?_ obtain rfl | hc := eq_or_ne c 0 · obtain rfl | hs := s.eq_empty_or_nonempty · simp simp [zero_smul_set hs, ← Set.singleton_zero] · have := (lipschitzWith_smul c⁻¹).ediam_image_le (c • s) rwa [← smul_eq_mul, ← ENNReal.smul_def, Set.image_smul, inv_smul_smul₀ hc s, nnnorm_inv, le_inv_smul_iff_of_pos (nnnorm_pos.2 hc)] at this
/- 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.Order.Interval.Multiset #align_import data.nat.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" /-! # Finite intervals of naturals This file proves that `ℕ` is a `LocallyFiniteOrder` and calculates the cardinality of its intervals as finsets and fintypes. ## TODO Some lemmas can be generalized using `OrderedGroup`, `CanonicallyOrderedCommMonoid` or `SuccOrder` and subsequently be moved upstream to `Order.Interval.Finset`. -/ -- TODO -- assert_not_exists Ring open Finset Nat variable (a b c : ℕ) namespace Nat instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ where finsetIcc a b := ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩ finsetIco a b := ⟨List.range' a (b - a), List.nodup_range' _ _⟩ finsetIoc a b := ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩ finsetIoo a b := ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩ finset_mem_Icc a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ico a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ioc a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ioo a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega theorem Icc_eq_range' : Icc a b = ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩ := rfl #align nat.Icc_eq_range' Nat.Icc_eq_range' theorem Ico_eq_range' : Ico a b = ⟨List.range' a (b - a), List.nodup_range' _ _⟩ := rfl #align nat.Ico_eq_range' Nat.Ico_eq_range' theorem Ioc_eq_range' : Ioc a b = ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩ := rfl #align nat.Ioc_eq_range' Nat.Ioc_eq_range' theorem Ioo_eq_range' : Ioo a b = ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩ := rfl #align nat.Ioo_eq_range' Nat.Ioo_eq_range' theorem uIcc_eq_range' : uIcc a b = ⟨List.range' (min a b) (max a b + 1 - min a b), List.nodup_range' _ _⟩ := rfl #align nat.uIcc_eq_range' Nat.uIcc_eq_range' theorem Iio_eq_range : Iio = range := by ext b x rw [mem_Iio, mem_range] #align nat.Iio_eq_range Nat.Iio_eq_range @[simp] theorem Ico_zero_eq_range : Ico 0 = range := by rw [← Nat.bot_eq_zero, ← Iio_eq_Ico, Iio_eq_range] #align nat.Ico_zero_eq_range Nat.Ico_zero_eq_range lemma range_eq_Icc_zero_sub_one (n : ℕ) (hn : n ≠ 0): range n = Icc 0 (n - 1) := by ext b simp_all only [mem_Icc, zero_le, true_and, mem_range] exact lt_iff_le_pred (zero_lt_of_ne_zero hn) theorem _root_.Finset.range_eq_Ico : range = Ico 0 := Ico_zero_eq_range.symm #align finset.range_eq_Ico Finset.range_eq_Ico @[simp] theorem card_Icc : (Icc a b).card = b + 1 - a := List.length_range' _ _ _ #align nat.card_Icc Nat.card_Icc @[simp] theorem card_Ico : (Ico a b).card = b - a := List.length_range' _ _ _ #align nat.card_Ico Nat.card_Ico @[simp] theorem card_Ioc : (Ioc a b).card = b - a := List.length_range' _ _ _ #align nat.card_Ioc Nat.card_Ioc @[simp] theorem card_Ioo : (Ioo a b).card = b - a - 1 := List.length_range' _ _ _ #align nat.card_Ioo Nat.card_Ioo @[simp] theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := (card_Icc _ _).trans $ by rw [← Int.natCast_inj, sup_eq_max, inf_eq_min, Int.ofNat_sub] <;> omega #align nat.card_uIcc Nat.card_uIcc @[simp] lemma card_Iic : (Iic b).card = b + 1 := by rw [Iic_eq_Icc, card_Icc, Nat.bot_eq_zero, Nat.sub_zero] #align nat.card_Iic Nat.card_Iic @[simp] theorem card_Iio : (Iio b).card = b := by rw [Iio_eq_Ico, card_Ico, Nat.bot_eq_zero, Nat.sub_zero] #align nat.card_Iio Nat.card_Iio -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIcc : Fintype.card (Set.Icc a b) = b + 1 - a := by rw [Fintype.card_ofFinset, card_Icc] #align nat.card_fintype_Icc Nat.card_fintypeIcc -- Porting note (#10618): simp can prove this -- @[simp]
Mathlib/Order/Interval/Finset/Nat.lean
120
121
theorem card_fintypeIco : Fintype.card (Set.Ico a b) = b - a := by
rw [Fintype.card_ofFinset, card_Ico]
/- Copyright (c) 2022 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler, Yaël Dillies -/ import Mathlib.Analysis.SpecialFunctions.Trigonometric.ArctanDeriv #align_import analysis.special_functions.trigonometric.bounds from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Polynomial bounds for trigonometric functions ## Main statements This file contains upper and lower bounds for real trigonometric functions in terms of polynomials. See `Trigonometric.Basic` for more elementary inequalities, establishing the ranges of these functions, and their monotonicity in suitable intervals. Here we prove the following: * `sin_lt`: for `x > 0` we have `sin x < x`. * `sin_gt_sub_cube`: For `0 < x ≤ 1` we have `x - x ^ 3 / 4 < sin x`. * `lt_tan`: for `0 < x < π/2` we have `x < tan x`. * `cos_le_one_div_sqrt_sq_add_one` and `cos_lt_one_div_sqrt_sq_add_one`: for `-3 * π / 2 ≤ x ≤ 3 * π / 2`, we have `cos x ≤ 1 / sqrt (x ^ 2 + 1)`, with strict inequality if `x ≠ 0`. (This bound is not quite optimal, but not far off) ## Tags sin, cos, tan, angle -/ open Set namespace Real variable {x : ℝ} /-- For 0 < x, we have sin x < x. -/
Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean
39
49
theorem sin_lt (h : 0 < x) : sin x < x := by
cases' lt_or_le 1 x with h' h' · exact (sin_le_one x).trans_lt h' have hx : |x| = x := abs_of_nonneg h.le have := le_of_abs_le (sin_bound <| show |x| ≤ 1 by rwa [hx]) rw [sub_le_iff_le_add', hx] at this apply this.trans_lt rw [sub_add, sub_lt_self_iff, sub_pos, div_eq_mul_inv (x ^ 3)] refine mul_lt_mul' ?_ (by norm_num) (by norm_num) (pow_pos h 3) apply pow_le_pow_of_le_one h.le h' norm_num
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Aaron Anderson, Yakov Pechersky -/ import Mathlib.Algebra.Group.Commute.Basic import Mathlib.Data.Fintype.Card import Mathlib.GroupTheory.Perm.Basic #align_import group_theory.perm.support from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # support of a permutation ## Main definitions In the following, `f g : Equiv.Perm α`. * `Equiv.Perm.Disjoint`: two permutations `f` and `g` are `Disjoint` if every element is fixed either by `f`, or by `g`. Equivalently, `f` and `g` are `Disjoint` iff their `support` are disjoint. * `Equiv.Perm.IsSwap`: `f = swap x y` for `x ≠ y`. * `Equiv.Perm.support`: the elements `x : α` that are not fixed by `f`. Assume `α` is a Fintype: * `Equiv.Perm.fixed_point_card_lt_of_ne_one f` says that `f` has strictly less than `Fintype.card α - 1` fixed points, unless `f = 1`. (Equivalently, `f.support` has at least 2 elements.) -/ open Equiv Finset namespace Equiv.Perm variable {α : Type*} section Disjoint /-- Two permutations `f` and `g` are `Disjoint` if their supports are disjoint, i.e., every element is fixed either by `f`, or by `g`. -/ def Disjoint (f g : Perm α) := ∀ x, f x = x ∨ g x = x #align equiv.perm.disjoint Equiv.Perm.Disjoint variable {f g h : Perm α} @[symm] theorem Disjoint.symm : Disjoint f g → Disjoint g f := by simp only [Disjoint, or_comm, imp_self] #align equiv.perm.disjoint.symm Equiv.Perm.Disjoint.symm theorem Disjoint.symmetric : Symmetric (@Disjoint α) := fun _ _ => Disjoint.symm #align equiv.perm.disjoint.symmetric Equiv.Perm.Disjoint.symmetric instance : IsSymm (Perm α) Disjoint := ⟨Disjoint.symmetric⟩ theorem disjoint_comm : Disjoint f g ↔ Disjoint g f := ⟨Disjoint.symm, Disjoint.symm⟩ #align equiv.perm.disjoint_comm Equiv.Perm.disjoint_comm theorem Disjoint.commute (h : Disjoint f g) : Commute f g := Equiv.ext fun x => (h x).elim (fun hf => (h (g x)).elim (fun hg => by simp [mul_apply, hf, hg]) fun hg => by simp [mul_apply, hf, g.injective hg]) fun hg => (h (f x)).elim (fun hf => by simp [mul_apply, f.injective hf, hg]) fun hf => by simp [mul_apply, hf, hg] #align equiv.perm.disjoint.commute Equiv.Perm.Disjoint.commute @[simp] theorem disjoint_one_left (f : Perm α) : Disjoint 1 f := fun _ => Or.inl rfl #align equiv.perm.disjoint_one_left Equiv.Perm.disjoint_one_left @[simp] theorem disjoint_one_right (f : Perm α) : Disjoint f 1 := fun _ => Or.inr rfl #align equiv.perm.disjoint_one_right Equiv.Perm.disjoint_one_right theorem disjoint_iff_eq_or_eq : Disjoint f g ↔ ∀ x : α, f x = x ∨ g x = x := Iff.rfl #align equiv.perm.disjoint_iff_eq_or_eq Equiv.Perm.disjoint_iff_eq_or_eq @[simp]
Mathlib/GroupTheory/Perm/Support.lean
87
90
theorem disjoint_refl_iff : Disjoint f f ↔ f = 1 := by
refine ⟨fun h => ?_, fun h => h.symm ▸ disjoint_one_left 1⟩ ext x cases' h x with hx hx <;> simp [hx]
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Patrick Massot -/ import Mathlib.Order.Interval.Set.UnorderedInterval import Mathlib.Algebra.Order.Interval.Set.Monoid import Mathlib.Data.Set.Pointwise.Basic import Mathlib.Algebra.Order.Field.Basic import Mathlib.Algebra.Order.Group.MinMax #align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # (Pre)images of intervals In this file we prove a bunch of trivial lemmas like “if we add `a` to all points of `[b, c]`, then we get `[a + b, a + c]`”. For the functions `x ↦ x ± a`, `x ↦ a ± x`, and `x ↦ -x` we prove lemmas about preimages and images of all intervals. We also prove a few lemmas about images under `x ↦ a * x`, `x ↦ x * a` and `x ↦ x⁻¹`. -/ open Interval Pointwise variable {α : Type*} namespace Set /-! ### Binary pointwise operations Note that the subset operations below only cover the cases with the largest possible intervals on the LHS: to conclude that `Ioo a b * Ioo c d ⊆ Ioo (a * c) (c * d)`, you can use monotonicity of `*` and `Set.Ico_mul_Ioc_subset`. TODO: repeat these lemmas for the generality of `mul_le_mul` (which assumes nonnegativity), which the unprimed names have been reserved for -/ section ContravariantLE variable [Mul α] [Preorder α] variable [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (Function.swap HMul.hMul) LE.le] @[to_additive Icc_add_Icc_subset] theorem Icc_mul_Icc_subset' (a b c d : α) : Icc a b * Icc c d ⊆ Icc (a * c) (b * d) := by rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_le_mul' hya hzc, mul_le_mul' hyb hzd⟩ @[to_additive Iic_add_Iic_subset] theorem Iic_mul_Iic_subset' (a b : α) : Iic a * Iic b ⊆ Iic (a * b) := by rintro x ⟨y, hya, z, hzb, rfl⟩ exact mul_le_mul' hya hzb @[to_additive Ici_add_Ici_subset] theorem Ici_mul_Ici_subset' (a b : α) : Ici a * Ici b ⊆ Ici (a * b) := by rintro x ⟨y, hya, z, hzb, rfl⟩ exact mul_le_mul' hya hzb end ContravariantLE section ContravariantLT variable [Mul α] [PartialOrder α] variable [CovariantClass α α (· * ·) (· < ·)] [CovariantClass α α (Function.swap HMul.hMul) LT.lt] @[to_additive Icc_add_Ico_subset] theorem Icc_mul_Ico_subset' (a b c d : α) : Icc a b * Ico c d ⊆ Ico (a * c) (b * d) := by haveI := covariantClass_le_of_lt rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_le_mul' hya hzc, mul_lt_mul_of_le_of_lt hyb hzd⟩ @[to_additive Ico_add_Icc_subset] theorem Ico_mul_Icc_subset' (a b c d : α) : Ico a b * Icc c d ⊆ Ico (a * c) (b * d) := by haveI := covariantClass_le_of_lt rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_le_mul' hya hzc, mul_lt_mul_of_lt_of_le hyb hzd⟩ @[to_additive Ioc_add_Ico_subset] theorem Ioc_mul_Ico_subset' (a b c d : α) : Ioc a b * Ico c d ⊆ Ioo (a * c) (b * d) := by haveI := covariantClass_le_of_lt rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_lt_mul_of_lt_of_le hya hzc, mul_lt_mul_of_le_of_lt hyb hzd⟩ @[to_additive Ico_add_Ioc_subset]
Mathlib/Data/Set/Pointwise/Interval.lean
86
89
theorem Ico_mul_Ioc_subset' (a b c d : α) : Ico a b * Ioc c d ⊆ Ioo (a * c) (b * d) := by
haveI := covariantClass_le_of_lt rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_lt_mul_of_le_of_lt hya hzc, mul_lt_mul_of_lt_of_le hyb hzd⟩
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Patrick Massot -/ import Mathlib.Data.Set.Function import Mathlib.Order.Interval.Set.OrdConnected #align_import data.set.intervals.proj_Icc from "leanprover-community/mathlib"@"4e24c4bfcff371c71f7ba22050308aa17815626c" /-! # Projection of a line onto a closed interval Given a linearly ordered type `α`, in this file we define * `Set.projIci (a : α)` to be the map `α → [a, ∞)` sending `(-∞, a]` to `a`, and each point `x ∈ [a, ∞)` to itself; * `Set.projIic (b : α)` to be the map `α → (-∞, b[` sending `[b, ∞)` to `b`, and each point `x ∈ (-∞, b]` to itself; * `Set.projIcc (a b : α) (h : a ≤ b)` to be the map `α → [a, b]` sending `(-∞, a]` to `a`, `[b, ∞)` to `b`, and each point `x ∈ [a, b]` to itself; * `Set.IccExtend {a b : α} (h : a ≤ b) (f : Icc a b → β)` to be the extension of `f` to `α` defined as `f ∘ projIcc a b h`. * `Set.IciExtend {a : α} (f : Ici a → β)` to be the extension of `f` to `α` defined as `f ∘ projIci a`. * `Set.IicExtend {b : α} (f : Iic b → β)` to be the extension of `f` to `α` defined as `f ∘ projIic b`. We also prove some trivial properties of these maps. -/ variable {α β : Type*} [LinearOrder α] open Function namespace Set /-- Projection of `α` to the closed interval `[a, ∞)`. -/ def projIci (a x : α) : Ici a := ⟨max a x, le_max_left _ _⟩ #align set.proj_Ici Set.projIci /-- Projection of `α` to the closed interval `(-∞, b]`. -/ def projIic (b x : α) : Iic b := ⟨min b x, min_le_left _ _⟩ #align set.proj_Iic Set.projIic /-- Projection of `α` to the closed interval `[a, b]`. -/ def projIcc (a b : α) (h : a ≤ b) (x : α) : Icc a b := ⟨max a (min b x), le_max_left _ _, max_le h (min_le_left _ _)⟩ #align set.proj_Icc Set.projIcc variable {a b : α} (h : a ≤ b) {x : α} @[norm_cast] theorem coe_projIci (a x : α) : (projIci a x : α) = max a x := rfl #align set.coe_proj_Ici Set.coe_projIci @[norm_cast] theorem coe_projIic (b x : α) : (projIic b x : α) = min b x := rfl #align set.coe_proj_Iic Set.coe_projIic @[norm_cast] theorem coe_projIcc (a b : α) (h : a ≤ b) (x : α) : (projIcc a b h x : α) = max a (min b x) := rfl #align set.coe_proj_Icc Set.coe_projIcc theorem projIci_of_le (hx : x ≤ a) : projIci a x = ⟨a, le_rfl⟩ := Subtype.ext <| max_eq_left hx #align set.proj_Ici_of_le Set.projIci_of_le theorem projIic_of_le (hx : b ≤ x) : projIic b x = ⟨b, le_rfl⟩ := Subtype.ext <| min_eq_left hx #align set.proj_Iic_of_le Set.projIic_of_le theorem projIcc_of_le_left (hx : x ≤ a) : projIcc a b h x = ⟨a, left_mem_Icc.2 h⟩ := by simp [projIcc, hx, hx.trans h] #align set.proj_Icc_of_le_left Set.projIcc_of_le_left theorem projIcc_of_right_le (hx : b ≤ x) : projIcc a b h x = ⟨b, right_mem_Icc.2 h⟩ := by simp [projIcc, hx, h] #align set.proj_Icc_of_right_le Set.projIcc_of_right_le @[simp] theorem projIci_self (a : α) : projIci a a = ⟨a, le_rfl⟩ := projIci_of_le le_rfl #align set.proj_Ici_self Set.projIci_self @[simp] theorem projIic_self (b : α) : projIic b b = ⟨b, le_rfl⟩ := projIic_of_le le_rfl #align set.proj_Iic_self Set.projIic_self @[simp] theorem projIcc_left : projIcc a b h a = ⟨a, left_mem_Icc.2 h⟩ := projIcc_of_le_left h le_rfl #align set.proj_Icc_left Set.projIcc_left @[simp] theorem projIcc_right : projIcc a b h b = ⟨b, right_mem_Icc.2 h⟩ := projIcc_of_right_le h le_rfl #align set.proj_Icc_right Set.projIcc_right theorem projIci_eq_self : projIci a x = ⟨a, le_rfl⟩ ↔ x ≤ a := by simp [projIci, Subtype.ext_iff] #align set.proj_Ici_eq_self Set.projIci_eq_self
Mathlib/Order/Interval/Set/ProjIcc.lean
102
102
theorem projIic_eq_self : projIic b x = ⟨b, le_rfl⟩ ↔ b ≤ x := by
simp [projIic, Subtype.ext_iff]
/- 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.Algebra.Category.GroupCat.EquivalenceGroupAddGroup import Mathlib.GroupTheory.QuotientGroup #align_import algebra.category.Group.epi_mono from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Monomorphisms and epimorphisms in `Group` In this file, we prove monomorphisms in the category of groups are injective homomorphisms and epimorphisms are surjective homomorphisms. -/ noncomputable section open scoped Pointwise universe u v namespace MonoidHom open QuotientGroup variable {A : Type u} {B : Type v} section variable [Group A] [Group B] @[to_additive] theorem ker_eq_bot_of_cancel {f : A →* B} (h : ∀ u v : f.ker →* A, f.comp u = f.comp v → u = v) : f.ker = ⊥ := by simpa using _root_.congr_arg range (h f.ker.subtype 1 (by aesop_cat)) #align monoid_hom.ker_eq_bot_of_cancel MonoidHom.ker_eq_bot_of_cancel #align add_monoid_hom.ker_eq_bot_of_cancel AddMonoidHom.ker_eq_bot_of_cancel end section variable [CommGroup A] [CommGroup B] @[to_additive] theorem range_eq_top_of_cancel {f : A →* B} (h : ∀ u v : B →* B ⧸ f.range, u.comp f = v.comp f → u = v) : f.range = ⊤ := by specialize h 1 (QuotientGroup.mk' _) _ · ext1 x simp only [one_apply, coe_comp, coe_mk', Function.comp_apply] rw [show (1 : B ⧸ f.range) = (1 : B) from QuotientGroup.mk_one _, QuotientGroup.eq, inv_one, one_mul] exact ⟨x, rfl⟩ replace h : (QuotientGroup.mk' f.range).ker = (1 : B →* B ⧸ f.range).ker := by rw [h] rwa [ker_one, QuotientGroup.ker_mk'] at h #align monoid_hom.range_eq_top_of_cancel MonoidHom.range_eq_top_of_cancel #align add_monoid_hom.range_eq_top_of_cancel AddMonoidHom.range_eq_top_of_cancel end end MonoidHom section open CategoryTheory namespace GroupCat set_option linter.uppercaseLean3 false -- Porting note: already have Group G but Lean can't use that @[to_additive] instance (G : GroupCat) : Group G.α := G.str variable {A B : GroupCat.{u}} (f : A ⟶ B) @[to_additive] theorem ker_eq_bot_of_mono [Mono f] : f.ker = ⊥ := MonoidHom.ker_eq_bot_of_cancel fun u _ => (@cancel_mono _ _ _ _ _ f _ (show GroupCat.of f.ker ⟶ A from u) _).1 #align Group.ker_eq_bot_of_mono GroupCat.ker_eq_bot_of_mono #align AddGroup.ker_eq_bot_of_mono AddGroupCat.ker_eq_bot_of_mono @[to_additive] theorem mono_iff_ker_eq_bot : Mono f ↔ f.ker = ⊥ := ⟨fun _ => ker_eq_bot_of_mono f, fun h => ConcreteCategory.mono_of_injective _ <| (MonoidHom.ker_eq_bot_iff f).1 h⟩ #align Group.mono_iff_ker_eq_bot GroupCat.mono_iff_ker_eq_bot #align AddGroup.mono_iff_ker_eq_bot AddGroupCat.mono_iff_ker_eq_bot @[to_additive] theorem mono_iff_injective : Mono f ↔ Function.Injective f := Iff.trans (mono_iff_ker_eq_bot f) <| MonoidHom.ker_eq_bot_iff f #align Group.mono_iff_injective GroupCat.mono_iff_injective #align AddGroup.mono_iff_injective AddGroupCat.mono_iff_injective namespace SurjectiveOfEpiAuxs set_option quotPrecheck false in local notation "X" => Set.range (· • (f.range : Set B) : B → Set B) /-- Define `X'` to be the set of all left cosets with an extra point at "infinity". -/ inductive XWithInfinity | fromCoset : Set.range (· • (f.range : Set B) : B → Set B) → XWithInfinity | infinity : XWithInfinity #align Group.surjective_of_epi_auxs.X_with_infinity GroupCat.SurjectiveOfEpiAuxs.XWithInfinity open XWithInfinity Equiv.Perm local notation "X'" => XWithInfinity f local notation "∞" => XWithInfinity.infinity local notation "SX'" => Equiv.Perm X' instance : SMul B X' where smul b x := match x with | fromCoset y => fromCoset ⟨b • y, by rw [← y.2.choose_spec, leftCoset_assoc] -- Porting note: should we make `Bundled.α` reducible? let b' : B := y.2.choose use b * b'⟩ | ∞ => ∞ theorem mul_smul (b b' : B) (x : X') : (b * b') • x = b • b' • x := match x with | fromCoset y => by change fromCoset _ = fromCoset _ simp only [leftCoset_assoc] | ∞ => rfl #align Group.surjective_of_epi_auxs.mul_smul GroupCat.SurjectiveOfEpiAuxs.mul_smul theorem one_smul (x : X') : (1 : B) • x = x := match x with | fromCoset y => by change fromCoset _ = fromCoset _ simp only [one_leftCoset, Subtype.ext_iff_val] | ∞ => rfl #align Group.surjective_of_epi_auxs.one_smul GroupCat.SurjectiveOfEpiAuxs.one_smul
Mathlib/Algebra/Category/GroupCat/EpiMono.lean
145
152
theorem fromCoset_eq_of_mem_range {b : B} (hb : b ∈ f.range) : fromCoset ⟨b • ↑f.range, b, rfl⟩ = fromCoset ⟨f.range, 1, one_leftCoset _⟩ := by
congr let b : B.α := b change b • (f.range : Set B) = f.range nth_rw 2 [show (f.range : Set B.α) = (1 : B) • f.range from (one_leftCoset _).symm] rw [leftCoset_eq_iff, mul_one] exact Subgroup.inv_mem _ hb
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot, Yury Kudryashov, Rémy Degenne -/ import Mathlib.Order.Interval.Set.Basic import Mathlib.Order.Hom.Set #align_import data.set.intervals.order_iso from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" /-! # Lemmas about images of intervals under order isomorphisms. -/ open Set namespace OrderIso section Preorder variable {α β : Type*} [Preorder α] [Preorder β] @[simp] theorem preimage_Iic (e : α ≃o β) (b : β) : e ⁻¹' Iic b = Iic (e.symm b) := by ext x simp [← e.le_iff_le] #align order_iso.preimage_Iic OrderIso.preimage_Iic @[simp] theorem preimage_Ici (e : α ≃o β) (b : β) : e ⁻¹' Ici b = Ici (e.symm b) := by ext x simp [← e.le_iff_le] #align order_iso.preimage_Ici OrderIso.preimage_Ici @[simp] theorem preimage_Iio (e : α ≃o β) (b : β) : e ⁻¹' Iio b = Iio (e.symm b) := by ext x simp [← e.lt_iff_lt] #align order_iso.preimage_Iio OrderIso.preimage_Iio @[simp] theorem preimage_Ioi (e : α ≃o β) (b : β) : e ⁻¹' Ioi b = Ioi (e.symm b) := by ext x simp [← e.lt_iff_lt] #align order_iso.preimage_Ioi OrderIso.preimage_Ioi @[simp] theorem preimage_Icc (e : α ≃o β) (a b : β) : e ⁻¹' Icc a b = Icc (e.symm a) (e.symm b) := by simp [← Ici_inter_Iic] #align order_iso.preimage_Icc OrderIso.preimage_Icc @[simp] theorem preimage_Ico (e : α ≃o β) (a b : β) : e ⁻¹' Ico a b = Ico (e.symm a) (e.symm b) := by simp [← Ici_inter_Iio] #align order_iso.preimage_Ico OrderIso.preimage_Ico @[simp] theorem preimage_Ioc (e : α ≃o β) (a b : β) : e ⁻¹' Ioc a b = Ioc (e.symm a) (e.symm b) := by simp [← Ioi_inter_Iic] #align order_iso.preimage_Ioc OrderIso.preimage_Ioc @[simp] theorem preimage_Ioo (e : α ≃o β) (a b : β) : e ⁻¹' Ioo a b = Ioo (e.symm a) (e.symm b) := by simp [← Ioi_inter_Iio] #align order_iso.preimage_Ioo OrderIso.preimage_Ioo @[simp] theorem image_Iic (e : α ≃o β) (a : α) : e '' Iic a = Iic (e a) := by rw [e.image_eq_preimage, e.symm.preimage_Iic, e.symm_symm] #align order_iso.image_Iic OrderIso.image_Iic @[simp] theorem image_Ici (e : α ≃o β) (a : α) : e '' Ici a = Ici (e a) := e.dual.image_Iic a #align order_iso.image_Ici OrderIso.image_Ici @[simp] theorem image_Iio (e : α ≃o β) (a : α) : e '' Iio a = Iio (e a) := by rw [e.image_eq_preimage, e.symm.preimage_Iio, e.symm_symm] #align order_iso.image_Iio OrderIso.image_Iio @[simp] theorem image_Ioi (e : α ≃o β) (a : α) : e '' Ioi a = Ioi (e a) := e.dual.image_Iio a #align order_iso.image_Ioi OrderIso.image_Ioi @[simp] theorem image_Ioo (e : α ≃o β) (a b : α) : e '' Ioo a b = Ioo (e a) (e b) := by rw [e.image_eq_preimage, e.symm.preimage_Ioo, e.symm_symm] #align order_iso.image_Ioo OrderIso.image_Ioo @[simp] theorem image_Ioc (e : α ≃o β) (a b : α) : e '' Ioc a b = Ioc (e a) (e b) := by rw [e.image_eq_preimage, e.symm.preimage_Ioc, e.symm_symm] #align order_iso.image_Ioc OrderIso.image_Ioc @[simp] theorem image_Ico (e : α ≃o β) (a b : α) : e '' Ico a b = Ico (e a) (e b) := by rw [e.image_eq_preimage, e.symm.preimage_Ico, e.symm_symm] #align order_iso.image_Ico OrderIso.image_Ico @[simp]
Mathlib/Order/Interval/Set/OrderIso.lean
103
104
theorem image_Icc (e : α ≃o β) (a b : α) : e '' Icc a b = Icc (e a) (e b) := by
rw [e.image_eq_preimage, e.symm.preimage_Icc, e.symm_symm]
/- Copyright (c) 2023 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Topology.Order.Basic /-! # Set neighborhoods of intervals In this file we prove basic theorems about `𝓝ˢ s`, where `s` is one of the intervals `Set.Ici`, `Set.Iic`, `Set.Ioi`, `Set.Iio`, `Set.Ico`, `Set.Ioc`, `Set.Ioo`, and `Set.Icc`. First, we prove lemmas in terms of filter equalities. Then we prove lemmas about `s ∈ 𝓝ˢ t`, where both `s` and `t` are intervals. Finally, we prove a few lemmas about filter bases of `𝓝ˢ (Iic a)` and `𝓝ˢ (Ici a)`. -/ open Set Filter OrderDual open scoped Topology section OrderClosedTopology variable {α : Type*} [LinearOrder α] [TopologicalSpace α] [OrderClosedTopology α] {a b c d : α} /-! # Formulae for `𝓝ˢ` of intervals -/ @[simp] theorem nhdsSet_Ioi : 𝓝ˢ (Ioi a) = 𝓟 (Ioi a) := isOpen_Ioi.nhdsSet_eq @[simp] theorem nhdsSet_Iio : 𝓝ˢ (Iio a) = 𝓟 (Iio a) := isOpen_Iio.nhdsSet_eq @[simp] theorem nhdsSet_Ioo : 𝓝ˢ (Ioo a b) = 𝓟 (Ioo a b) := isOpen_Ioo.nhdsSet_eq theorem nhdsSet_Ici : 𝓝ˢ (Ici a) = 𝓝 a ⊔ 𝓟 (Ioi a) := by rw [← Ioi_insert, nhdsSet_insert, nhdsSet_Ioi] theorem nhdsSet_Iic : 𝓝ˢ (Iic a) = 𝓝 a ⊔ 𝓟 (Iio a) := nhdsSet_Ici (α := αᵒᵈ) theorem nhdsSet_Ico (h : a < b) : 𝓝ˢ (Ico a b) = 𝓝 a ⊔ 𝓟 (Ioo a b) := by rw [← Ioo_insert_left h, nhdsSet_insert, nhdsSet_Ioo]
Mathlib/Topology/Order/NhdsSet.lean
44
45
theorem nhdsSet_Ioc (h : a < b) : 𝓝ˢ (Ioc a b) = 𝓝 b ⊔ 𝓟 (Ioo a b) := by
rw [← Ioo_insert_right h, nhdsSet_insert, nhdsSet_Ioo]
/- Copyright (c) 2022 Antoine Labelle, Rémi Bottinelli. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Labelle, Rémi Bottinelli -/ import Mathlib.Combinatorics.Quiver.Basic import Mathlib.Combinatorics.Quiver.Path #align_import combinatorics.quiver.cast from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" /-! # Rewriting arrows and paths along vertex equalities This files defines `Hom.cast` and `Path.cast` (and associated lemmas) in order to allow rewriting arrows and paths along equalities of their endpoints. -/ universe v v₁ v₂ u u₁ u₂ variable {U : Type*} [Quiver.{u + 1} U] namespace Quiver /-! ### Rewriting arrows along equalities of vertices -/ /-- Change the endpoints of an arrow using equalities. -/ def Hom.cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : u' ⟶ v' := Eq.ndrec (motive := (· ⟶ v')) (Eq.ndrec e hv) hu #align quiver.hom.cast Quiver.Hom.cast theorem Hom.cast_eq_cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : e.cast hu hv = _root_.cast (by {rw [hu, hv]}) e := by subst_vars rfl #align quiver.hom.cast_eq_cast Quiver.Hom.cast_eq_cast @[simp] theorem Hom.cast_rfl_rfl {u v : U} (e : u ⟶ v) : e.cast rfl rfl = e := rfl #align quiver.hom.cast_rfl_rfl Quiver.Hom.cast_rfl_rfl @[simp]
Mathlib/Combinatorics/Quiver/Cast.lean
50
54
theorem Hom.cast_cast {u v u' v' u'' v'' : U} (e : u ⟶ v) (hu : u = u') (hv : v = v') (hu' : u' = u'') (hv' : v' = v'') : (e.cast hu hv).cast hu' hv' = e.cast (hu.trans hu') (hv.trans hv') := by
subst_vars rfl
/- Copyright (c) 2021 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Heather Macbeth, Johannes Hölzl, Yury Kudryashov -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.Instances.NNReal #align_import analysis.normed.group.infinite_sum from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd" /-! # Infinite sums in (semi)normed groups In a complete (semi)normed group, - `summable_iff_vanishing_norm`: a series `∑' i, f i` is summable if and only if for any `ε > 0`, there exists a finite set `s` such that the sum `∑ i ∈ t, f i` over any finite set `t` disjoint with `s` has norm less than `ε`; - `summable_of_norm_bounded`, `Summable.of_norm_bounded_eventually`: if `‖f i‖` is bounded above by a summable series `∑' i, g i`, then `∑' i, f i` is summable as well; the same is true if the inequality hold only off some finite set. - `tsum_of_norm_bounded`, `HasSum.norm_le_of_bounded`: if `‖f i‖ ≤ g i`, where `∑' i, g i` is a summable series, then `‖∑' i, f i‖ ≤ ∑' i, g i`. ## Tags infinite series, absolute convergence, normed group -/ open Topology NNReal open Finset Filter Metric variable {ι α E F : Type*} [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] theorem cauchySeq_finset_iff_vanishing_norm {f : ι → E} : (CauchySeq fun s : Finset ι => ∑ i ∈ s, f i) ↔ ∀ ε > (0 : ℝ), ∃ s : Finset ι, ∀ t, Disjoint t s → ‖∑ i ∈ t, f i‖ < ε := by rw [cauchySeq_finset_iff_sum_vanishing, nhds_basis_ball.forall_iff] · simp only [ball_zero_eq, Set.mem_setOf_eq] · rintro s t hst ⟨s', hs'⟩ exact ⟨s', fun t' ht' => hst <| hs' _ ht'⟩ #align cauchy_seq_finset_iff_vanishing_norm cauchySeq_finset_iff_vanishing_norm theorem summable_iff_vanishing_norm [CompleteSpace E] {f : ι → E} : Summable f ↔ ∀ ε > (0 : ℝ), ∃ s : Finset ι, ∀ t, Disjoint t s → ‖∑ i ∈ t, f i‖ < ε := by rw [summable_iff_cauchySeq_finset, cauchySeq_finset_iff_vanishing_norm] #align summable_iff_vanishing_norm summable_iff_vanishing_norm
Mathlib/Analysis/Normed/Group/InfiniteSum.lean
54
68
theorem cauchySeq_finset_of_norm_bounded_eventually {f : ι → E} {g : ι → ℝ} (hg : Summable g) (h : ∀ᶠ i in cofinite, ‖f i‖ ≤ g i) : CauchySeq fun s => ∑ i ∈ s, f i := by
refine cauchySeq_finset_iff_vanishing_norm.2 fun ε hε => ?_ rcases summable_iff_vanishing_norm.1 hg ε hε with ⟨s, hs⟩ classical refine ⟨s ∪ h.toFinset, fun t ht => ?_⟩ have : ∀ i ∈ t, ‖f i‖ ≤ g i := by intro i hi simp only [disjoint_left, mem_union, not_or, h.mem_toFinset, Set.mem_compl_iff, Classical.not_not] at ht exact (ht hi).2 calc ‖∑ i ∈ t, f i‖ ≤ ∑ i ∈ t, g i := norm_sum_le_of_le _ this _ ≤ ‖∑ i ∈ t, g i‖ := le_abs_self _ _ < ε := hs _ (ht.mono_right le_sup_left)
/- 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.Topology.Bornology.Basic #align_import topology.bornology.constructions from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" /-! # Bornology structure on products and subtypes In this file we define `Bornology` and `BoundedSpace` instances on `α × β`, `Π i, π i`, and `{x // p x}`. We also prove basic lemmas about `Bornology.cobounded` and `Bornology.IsBounded` on these types. -/ open Set Filter Bornology Function open Filter variable {α β ι : Type*} {π : ι → Type*} [Bornology α] [Bornology β] [∀ i, Bornology (π i)] instance Prod.instBornology : Bornology (α × β) where cobounded' := (cobounded α).coprod (cobounded β) le_cofinite' := @coprod_cofinite α β ▸ coprod_mono ‹Bornology α›.le_cofinite ‹Bornology β›.le_cofinite #align prod.bornology Prod.instBornology instance Pi.instBornology : Bornology (∀ i, π i) where cobounded' := Filter.coprodᵢ fun i => cobounded (π i) le_cofinite' := iSup_le fun _ ↦ (comap_mono (Bornology.le_cofinite _)).trans (comap_cofinite_le _) #align pi.bornology Pi.instBornology /-- Inverse image of a bornology. -/ abbrev Bornology.induced {α β : Type*} [Bornology β] (f : α → β) : Bornology α where cobounded' := comap f (cobounded β) le_cofinite' := (comap_mono (Bornology.le_cofinite β)).trans (comap_cofinite_le _) #align bornology.induced Bornology.induced instance {p : α → Prop} : Bornology (Subtype p) := Bornology.induced (Subtype.val : Subtype p → α) namespace Bornology /-! ### Bounded sets in `α × β` -/ theorem cobounded_prod : cobounded (α × β) = (cobounded α).coprod (cobounded β) := rfl #align bornology.cobounded_prod Bornology.cobounded_prod theorem isBounded_image_fst_and_snd {s : Set (α × β)} : IsBounded (Prod.fst '' s) ∧ IsBounded (Prod.snd '' s) ↔ IsBounded s := compl_mem_coprod.symm #align bornology.is_bounded_image_fst_and_snd Bornology.isBounded_image_fst_and_snd lemma IsBounded.image_fst {s : Set (α × β)} (hs : IsBounded s) : IsBounded (Prod.fst '' s) := (isBounded_image_fst_and_snd.2 hs).1 lemma IsBounded.image_snd {s : Set (α × β)} (hs : IsBounded s) : IsBounded (Prod.snd '' s) := (isBounded_image_fst_and_snd.2 hs).2 variable {s : Set α} {t : Set β} {S : ∀ i, Set (π i)} theorem IsBounded.fst_of_prod (h : IsBounded (s ×ˢ t)) (ht : t.Nonempty) : IsBounded s := fst_image_prod s ht ▸ h.image_fst #align bornology.is_bounded.fst_of_prod Bornology.IsBounded.fst_of_prod theorem IsBounded.snd_of_prod (h : IsBounded (s ×ˢ t)) (hs : s.Nonempty) : IsBounded t := snd_image_prod hs t ▸ h.image_snd #align bornology.is_bounded.snd_of_prod Bornology.IsBounded.snd_of_prod theorem IsBounded.prod (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s ×ˢ t) := isBounded_image_fst_and_snd.1 ⟨hs.subset <| fst_image_prod_subset _ _, ht.subset <| snd_image_prod_subset _ _⟩ #align bornology.is_bounded.prod Bornology.IsBounded.prod theorem isBounded_prod_of_nonempty (hne : Set.Nonempty (s ×ˢ t)) : IsBounded (s ×ˢ t) ↔ IsBounded s ∧ IsBounded t := ⟨fun h => ⟨h.fst_of_prod hne.snd, h.snd_of_prod hne.fst⟩, fun h => h.1.prod h.2⟩ #align bornology.is_bounded_prod_of_nonempty Bornology.isBounded_prod_of_nonempty theorem isBounded_prod : IsBounded (s ×ˢ t) ↔ s = ∅ ∨ t = ∅ ∨ IsBounded s ∧ IsBounded t := by rcases s.eq_empty_or_nonempty with (rfl | hs); · simp rcases t.eq_empty_or_nonempty with (rfl | ht); · simp simp only [hs.ne_empty, ht.ne_empty, isBounded_prod_of_nonempty (hs.prod ht), false_or_iff] #align bornology.is_bounded_prod Bornology.isBounded_prod
Mathlib/Topology/Bornology/Constructions.lean
94
96
theorem isBounded_prod_self : IsBounded (s ×ˢ s) ↔ IsBounded s := by
rcases s.eq_empty_or_nonempty with (rfl | hs); · simp exact (isBounded_prod_of_nonempty (hs.prod hs)).trans and_self_iff
/- Copyright (c) 2019 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen, Eric Wieser -/ import Mathlib.Data.Matrix.Basic /-! # Row and column matrices This file provides results about row and column matrices ## Main definitions * `Matrix.row r : Matrix Unit n α`: a matrix with a single row * `Matrix.col c : Matrix m Unit α`: a matrix with a single column * `Matrix.updateRow M i r`: update the `i`th row of `M` to `r` * `Matrix.updateCol M j c`: update the `j`th column of `M` to `c` -/ variable {l m n o : Type*} universe u v w variable {R : Type*} {α : Type v} {β : Type w} namespace Matrix /-- `Matrix.col u` is the column matrix whose entries are given by `u`. -/ def col (w : m → α) : Matrix m Unit α := of fun x _ => w x #align matrix.col Matrix.col -- TODO: set as an equation lemma for `col`, see mathlib4#3024 @[simp] theorem col_apply (w : m → α) (i j) : col w i j = w i := rfl #align matrix.col_apply Matrix.col_apply /-- `Matrix.row u` is the row matrix whose entries are given by `u`. -/ def row (v : n → α) : Matrix Unit n α := of fun _ y => v y #align matrix.row Matrix.row -- TODO: set as an equation lemma for `row`, see mathlib4#3024 @[simp] theorem row_apply (v : n → α) (i j) : row v i j = v j := rfl #align matrix.row_apply Matrix.row_apply theorem col_injective : Function.Injective (col : (m → α) → _) := fun _x _y h => funext fun i => congr_fun₂ h i () @[simp] theorem col_inj {v w : m → α} : col v = col w ↔ v = w := col_injective.eq_iff @[simp] theorem col_zero [Zero α] : col (0 : m → α) = 0 := rfl @[simp] theorem col_eq_zero [Zero α] (v : m → α) : col v = 0 ↔ v = 0 := col_inj @[simp] theorem col_add [Add α] (v w : m → α) : col (v + w) = col v + col w := by ext rfl #align matrix.col_add Matrix.col_add @[simp] theorem col_smul [SMul R α] (x : R) (v : m → α) : col (x • v) = x • col v := by ext rfl #align matrix.col_smul Matrix.col_smul theorem row_injective : Function.Injective (row : (n → α) → _) := fun _x _y h => funext fun j => congr_fun₂ h () j @[simp] theorem row_inj {v w : n → α} : row v = row w ↔ v = w := row_injective.eq_iff @[simp] theorem row_zero [Zero α] : row (0 : n → α) = 0 := rfl @[simp] theorem row_eq_zero [Zero α] (v : n → α) : row v = 0 ↔ v = 0 := row_inj @[simp] theorem row_add [Add α] (v w : m → α) : row (v + w) = row v + row w := by ext rfl #align matrix.row_add Matrix.row_add @[simp] theorem row_smul [SMul R α] (x : R) (v : m → α) : row (x • v) = x • row v := by ext rfl #align matrix.row_smul Matrix.row_smul @[simp] theorem transpose_col (v : m → α) : (Matrix.col v)ᵀ = Matrix.row v := by ext rfl #align matrix.transpose_col Matrix.transpose_col @[simp] theorem transpose_row (v : m → α) : (Matrix.row v)ᵀ = Matrix.col v := by ext rfl #align matrix.transpose_row Matrix.transpose_row @[simp] theorem conjTranspose_col [Star α] (v : m → α) : (col v)ᴴ = row (star v) := by ext rfl #align matrix.conj_transpose_col Matrix.conjTranspose_col @[simp] theorem conjTranspose_row [Star α] (v : m → α) : (row v)ᴴ = col (star v) := by ext rfl #align matrix.conj_transpose_row Matrix.conjTranspose_row theorem row_vecMul [Fintype m] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : m → α) : Matrix.row (v ᵥ* M) = Matrix.row v * M := by ext rfl #align matrix.row_vec_mul Matrix.row_vecMul theorem col_vecMul [Fintype m] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : m → α) : Matrix.col (v ᵥ* M) = (Matrix.row v * M)ᵀ := by ext rfl #align matrix.col_vec_mul Matrix.col_vecMul theorem col_mulVec [Fintype n] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : n → α) : Matrix.col (M *ᵥ v) = M * Matrix.col v := by ext rfl #align matrix.col_mul_vec Matrix.col_mulVec theorem row_mulVec [Fintype n] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : n → α) : Matrix.row (M *ᵥ v) = (M * Matrix.col v)ᵀ := by ext rfl #align matrix.row_mul_vec Matrix.row_mulVec @[simp] theorem row_mul_col_apply [Fintype m] [Mul α] [AddCommMonoid α] (v w : m → α) (i j) : (row v * col w) i j = v ⬝ᵥ w := rfl #align matrix.row_mul_col_apply Matrix.row_mul_col_apply @[simp] theorem diag_col_mul_row [Mul α] [AddCommMonoid α] (a b : n → α) : diag (col a * row b) = a * b := by ext simp [Matrix.mul_apply, col, row] #align matrix.diag_col_mul_row Matrix.diag_col_mul_row
Mathlib/Data/Matrix/RowCol.lean
154
158
theorem vecMulVec_eq [Mul α] [AddCommMonoid α] (w : m → α) (v : n → α) : vecMulVec w v = col w * row v := by
ext simp only [vecMulVec, mul_apply, Fintype.univ_punit, Finset.sum_singleton] rfl
/- Copyright (c) 2021 Jakob Scholbach. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jakob Scholbach -/ import Mathlib.Algebra.Algebra.Defs import Mathlib.Algebra.CharP.ExpChar import Mathlib.FieldTheory.Separable #align_import field_theory.separable_degree from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15" /-! # Separable degree This file contains basics about the separable degree of a polynomial. ## Main results - `IsSeparableContraction`: is the condition that, for `g` a separable polynomial, we have that `g(x^(q^m)) = f(x)` for some `m : ℕ`. - `HasSeparableContraction`: the condition of having a separable contraction - `HasSeparableContraction.degree`: the separable degree, defined as the degree of some separable contraction - `Irreducible.hasSeparableContraction`: any irreducible polynomial can be contracted to a separable polynomial - `HasSeparableContraction.dvd_degree'`: the degree of a separable contraction divides the degree, in function of the exponential characteristic of the field - `HasSeparableContraction.dvd_degree` and `HasSeparableContraction.eq_degree` specialize the statement of `separable_degree_dvd_degree` - `IsSeparableContraction.degree_eq`: the separable degree is well-defined, implemented as the statement that the degree of any separable contraction equals `HasSeparableContraction.degree` ## Tags separable degree, degree, polynomial -/ noncomputable section namespace Polynomial open scoped Classical open Polynomial section CommSemiring variable {F : Type*} [CommSemiring F] (q : ℕ) /-- A separable contraction of a polynomial `f` is a separable polynomial `g` such that `g(x^(q^m)) = f(x)` for some `m : ℕ`. -/ def IsSeparableContraction (f : F[X]) (g : F[X]) : Prop := g.Separable ∧ ∃ m : ℕ, expand F (q ^ m) g = f #align polynomial.is_separable_contraction Polynomial.IsSeparableContraction /-- The condition of having a separable contraction. -/ def HasSeparableContraction (f : F[X]) : Prop := ∃ g : F[X], IsSeparableContraction q f g #align polynomial.has_separable_contraction Polynomial.HasSeparableContraction variable {q} {f : F[X]} (hf : HasSeparableContraction q f) /-- A choice of a separable contraction. -/ def HasSeparableContraction.contraction : F[X] := Classical.choose hf #align polynomial.has_separable_contraction.contraction Polynomial.HasSeparableContraction.contraction /-- The separable degree of a polynomial is the degree of a given separable contraction. -/ def HasSeparableContraction.degree : ℕ := hf.contraction.natDegree #align polynomial.has_separable_contraction.degree Polynomial.HasSeparableContraction.degree /-- The `HasSeparableContraction.contraction` is indeed a separable contraction. -/ theorem HasSeparableContraction.isSeparableContraction : IsSeparableContraction q f hf.contraction := Classical.choose_spec hf /-- The separable degree divides the degree, in function of the exponential characteristic of F. -/ theorem IsSeparableContraction.dvd_degree' {g} (hf : IsSeparableContraction q f g) : ∃ m : ℕ, g.natDegree * q ^ m = f.natDegree := by obtain ⟨m, rfl⟩ := hf.2 use m rw [natDegree_expand] #align polynomial.is_separable_contraction.dvd_degree' Polynomial.IsSeparableContraction.dvd_degree' theorem HasSeparableContraction.dvd_degree' : ∃ m : ℕ, hf.degree * q ^ m = f.natDegree := (Classical.choose_spec hf).dvd_degree' hf #align polynomial.has_separable_contraction.dvd_degree' Polynomial.HasSeparableContraction.dvd_degree' /-- The separable degree divides the degree. -/ theorem HasSeparableContraction.dvd_degree : hf.degree ∣ f.natDegree := let ⟨a, ha⟩ := hf.dvd_degree' Dvd.intro (q ^ a) ha #align polynomial.has_separable_contraction.dvd_degree Polynomial.HasSeparableContraction.dvd_degree /-- In exponential characteristic one, the separable degree equals the degree. -/ theorem HasSeparableContraction.eq_degree {f : F[X]} (hf : HasSeparableContraction 1 f) : hf.degree = f.natDegree := by let ⟨a, ha⟩ := hf.dvd_degree' rw [← ha, one_pow a, mul_one] #align polynomial.has_separable_contraction.eq_degree Polynomial.HasSeparableContraction.eq_degree end CommSemiring section Field variable {F : Type*} [Field F] variable (q : ℕ) {f : F[X]} (hf : HasSeparableContraction q f) /-- Every irreducible polynomial can be contracted to a separable polynomial. https://stacks.math.columbia.edu/tag/09H0 -/ theorem _root_.Irreducible.hasSeparableContraction (q : ℕ) [hF : ExpChar F q] {f : F[X]} (irred : Irreducible f) : HasSeparableContraction q f := by cases hF · exact ⟨f, irred.separable, ⟨0, by rw [pow_zero, expand_one]⟩⟩ · rcases exists_separable_of_irreducible q irred ‹q.Prime›.ne_zero with ⟨n, g, hgs, hge⟩ exact ⟨g, hgs, n, hge⟩ #align irreducible.has_separable_contraction Irreducible.hasSeparableContraction /-- If two expansions (along the positive characteristic) of two separable polynomials `g` and `g'` agree, then they have the same degree. -/
Mathlib/RingTheory/Polynomial/SeparableDegree.lean
121
131
theorem contraction_degree_eq_or_insep [hq : NeZero q] [CharP F q] (g g' : F[X]) (m m' : ℕ) (h_expand : expand F (q ^ m) g = expand F (q ^ m') g') (hg : g.Separable) (hg' : g'.Separable) : g.natDegree = g'.natDegree := by
wlog hm : m ≤ m' · exact (this q hf g' g m' m h_expand.symm hg' hg (le_of_not_le hm)).symm obtain ⟨s, rfl⟩ := exists_add_of_le hm rw [pow_add, expand_mul, expand_inj (pow_pos (NeZero.pos q) m)] at h_expand subst h_expand rcases isUnit_or_eq_zero_of_separable_expand q s (NeZero.pos q) hg with (h | rfl) · rw [natDegree_expand, natDegree_eq_zero_of_isUnit h, zero_mul] · rw [natDegree_expand, pow_zero, mul_one]
/- Copyright (c) 2021 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.Algebra.Module.LinearMap.Basic import Mathlib.RingTheory.HahnSeries.Basic #align_import ring_theory.hahn_series from "leanprover-community/mathlib"@"a484a7d0eade4e1268f4fb402859b6686037f965" /-! # Additive properties of Hahn series If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of formal series over `Γ` with coefficients in `R`, whose supports are partially well-ordered. With further structure on `R` and `Γ`, we can add further structure on `HahnSeries Γ R`. When `R` has an addition operation, `HahnSeries Γ R` also has addition by adding coefficients. ## Main Definitions * If `R` is a (commutative) additive monoid or group, then so is `HahnSeries Γ R`. ## References - [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven] -/ set_option linter.uppercaseLean3 false open Finset Function open scoped Classical noncomputable section variable {Γ R : Type*} namespace HahnSeries section Addition variable [PartialOrder Γ] section AddMonoid variable [AddMonoid R] instance : Add (HahnSeries Γ R) where add x y := { coeff := x.coeff + y.coeff isPWO_support' := (x.isPWO_support.union y.isPWO_support).mono (Function.support_add _ _) } instance : AddMonoid (HahnSeries Γ R) where zero := 0 add := (· + ·) nsmul := nsmulRec add_assoc x y z := by ext apply add_assoc zero_add x := by ext apply zero_add add_zero x := by ext apply add_zero @[simp] theorem add_coeff' {x y : HahnSeries Γ R} : (x + y).coeff = x.coeff + y.coeff := rfl #align hahn_series.add_coeff' HahnSeries.add_coeff' theorem add_coeff {x y : HahnSeries Γ R} {a : Γ} : (x + y).coeff a = x.coeff a + y.coeff a := rfl #align hahn_series.add_coeff HahnSeries.add_coeff theorem support_add_subset {x y : HahnSeries Γ R} : support (x + y) ⊆ support x ∪ support y := fun a ha => by rw [mem_support, add_coeff] at ha rw [Set.mem_union, mem_support, mem_support] contrapose! ha rw [ha.1, ha.2, add_zero] #align hahn_series.support_add_subset HahnSeries.support_add_subset theorem min_order_le_order_add {Γ} [Zero Γ] [LinearOrder Γ] {x y : HahnSeries Γ R} (hxy : x + y ≠ 0) : min x.order y.order ≤ (x + y).order := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [order_of_ne hx, order_of_ne hy, order_of_ne hxy] apply le_of_eq_of_le _ (Set.IsWF.min_le_min_of_subset (support_add_subset (x := x) (y := y))) · simp · simp [hy] · exact (Set.IsWF.min_union _ _ _ _).symm #align hahn_series.min_order_le_order_add HahnSeries.min_order_le_order_add /-- `single` as an additive monoid/group homomorphism -/ @[simps!] def single.addMonoidHom (a : Γ) : R →+ HahnSeries Γ R := { single a with map_add' := fun x y => by ext b by_cases h : b = a <;> simp [h] } #align hahn_series.single.add_monoid_hom HahnSeries.single.addMonoidHom /-- `coeff g` as an additive monoid/group homomorphism -/ @[simps] def coeff.addMonoidHom (g : Γ) : HahnSeries Γ R →+ R where toFun f := f.coeff g map_zero' := zero_coeff map_add' _ _ := add_coeff #align hahn_series.coeff.add_monoid_hom HahnSeries.coeff.addMonoidHom section Domain variable {Γ' : Type*} [PartialOrder Γ'] theorem embDomain_add (f : Γ ↪o Γ') (x y : HahnSeries Γ R) : embDomain f (x + y) = embDomain f x + embDomain f y := by ext g by_cases hg : g ∈ Set.range f · obtain ⟨a, rfl⟩ := hg simp · simp [embDomain_notin_range hg] #align hahn_series.emb_domain_add HahnSeries.embDomain_add end Domain end AddMonoid instance [AddCommMonoid R] : AddCommMonoid (HahnSeries Γ R) := { inferInstanceAs (AddMonoid (HahnSeries Γ R)) with add_comm := fun x y => by ext apply add_comm } section AddGroup variable [AddGroup R] instance : Neg (HahnSeries Γ R) where neg x := { coeff := fun a => -x.coeff a isPWO_support' := by rw [Function.support_neg] exact x.isPWO_support } instance : AddGroup (HahnSeries Γ R) := { inferInstanceAs (AddMonoid (HahnSeries Γ R)) with zsmul := zsmulRec add_left_neg := fun x => by ext apply add_left_neg } @[simp] theorem neg_coeff' {x : HahnSeries Γ R} : (-x).coeff = -x.coeff := rfl #align hahn_series.neg_coeff' HahnSeries.neg_coeff' theorem neg_coeff {x : HahnSeries Γ R} {a : Γ} : (-x).coeff a = -x.coeff a := rfl #align hahn_series.neg_coeff HahnSeries.neg_coeff @[simp] theorem support_neg {x : HahnSeries Γ R} : (-x).support = x.support := by ext simp #align hahn_series.support_neg HahnSeries.support_neg @[simp] theorem sub_coeff' {x y : HahnSeries Γ R} : (x - y).coeff = x.coeff - y.coeff := by ext simp [sub_eq_add_neg] #align hahn_series.sub_coeff' HahnSeries.sub_coeff'
Mathlib/RingTheory/HahnSeries/Addition.lean
171
172
theorem sub_coeff {x y : HahnSeries Γ R} {a : Γ} : (x - y).coeff a = x.coeff a - y.coeff a := by
simp
/- Copyright (c) 2019 Jan-David Salchow. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo -/ import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic /-! # Operator norm as an `NNNorm` Operator norm as an `NNNorm`, i.e. taking values in non-negative reals. -/ suppress_compilation open Bornology open Filter hiding map_smul open scoped Classical NNReal Topology Uniformity -- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps variable {𝕜 𝕜₂ 𝕜₃ E Eₗ F Fₗ G Gₗ 𝓕 : Type*} section SemiNormed open Metric ContinuousLinearMap variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup Eₗ] [SeminormedAddCommGroup F] [SeminormedAddCommGroup Fₗ] [SeminormedAddCommGroup G] [SeminormedAddCommGroup Gₗ] variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃] [NormedSpace 𝕜 E] [NormedSpace 𝕜 Eₗ] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜 Fₗ] [NormedSpace 𝕜₃ G] [NormedSpace 𝕜 Gₗ] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} {σ₁₃ : 𝕜 →+* 𝕜₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable [FunLike 𝓕 E F] namespace ContinuousLinearMap section OpNorm open Set Real section variable [RingHomIsometric σ₁₂] [RingHomIsometric σ₂₃] (f g : E →SL[σ₁₂] F) (h : F →SL[σ₂₃] G) (x : E) theorem nnnorm_def (f : E →SL[σ₁₂] F) : ‖f‖₊ = sInf { c | ∀ x, ‖f x‖₊ ≤ c * ‖x‖₊ } := by ext rw [NNReal.coe_sInf, coe_nnnorm, norm_def, NNReal.coe_image] simp_rw [← NNReal.coe_le_coe, NNReal.coe_mul, coe_nnnorm, mem_setOf_eq, NNReal.coe_mk, exists_prop] #align continuous_linear_map.nnnorm_def ContinuousLinearMap.nnnorm_def /-- If one controls the norm of every `A x`, then one controls the norm of `A`. -/ theorem opNNNorm_le_bound (f : E →SL[σ₁₂] F) (M : ℝ≥0) (hM : ∀ x, ‖f x‖₊ ≤ M * ‖x‖₊) : ‖f‖₊ ≤ M := opNorm_le_bound f (zero_le M) hM #align continuous_linear_map.op_nnnorm_le_bound ContinuousLinearMap.opNNNorm_le_bound @[deprecated (since := "2024-02-02")] alias op_nnnorm_le_bound := opNNNorm_le_bound /-- If one controls the norm of every `A x`, `‖x‖₊ ≠ 0`, then one controls the norm of `A`. -/ theorem opNNNorm_le_bound' (f : E →SL[σ₁₂] F) (M : ℝ≥0) (hM : ∀ x, ‖x‖₊ ≠ 0 → ‖f x‖₊ ≤ M * ‖x‖₊) : ‖f‖₊ ≤ M := opNorm_le_bound' f (zero_le M) fun x hx => hM x <| by rwa [← NNReal.coe_ne_zero] #align continuous_linear_map.op_nnnorm_le_bound' ContinuousLinearMap.opNNNorm_le_bound' @[deprecated (since := "2024-02-02")] alias op_nnnorm_le_bound' := opNNNorm_le_bound' /-- For a continuous real linear map `f`, if one controls the norm of every `f x`, `‖x‖₊ = 1`, then one controls the norm of `f`. -/ theorem opNNNorm_le_of_unit_nnnorm [NormedSpace ℝ E] [NormedSpace ℝ F] {f : E →L[ℝ] F} {C : ℝ≥0} (hf : ∀ x, ‖x‖₊ = 1 → ‖f x‖₊ ≤ C) : ‖f‖₊ ≤ C := opNorm_le_of_unit_norm C.coe_nonneg fun x hx => hf x <| by rwa [← NNReal.coe_eq_one] #align continuous_linear_map.op_nnnorm_le_of_unit_nnnorm ContinuousLinearMap.opNNNorm_le_of_unit_nnnorm @[deprecated (since := "2024-02-02")] alias op_nnnorm_le_of_unit_nnnorm := opNNNorm_le_of_unit_nnnorm theorem opNNNorm_le_of_lipschitz {f : E →SL[σ₁₂] F} {K : ℝ≥0} (hf : LipschitzWith K f) : ‖f‖₊ ≤ K := opNorm_le_of_lipschitz hf #align continuous_linear_map.op_nnnorm_le_of_lipschitz ContinuousLinearMap.opNNNorm_le_of_lipschitz @[deprecated (since := "2024-02-02")] alias op_nnnorm_le_of_lipschitz := opNNNorm_le_of_lipschitz theorem opNNNorm_eq_of_bounds {φ : E →SL[σ₁₂] F} (M : ℝ≥0) (h_above : ∀ x, ‖φ x‖₊ ≤ M * ‖x‖₊) (h_below : ∀ N, (∀ x, ‖φ x‖₊ ≤ N * ‖x‖₊) → M ≤ N) : ‖φ‖₊ = M := Subtype.ext <| opNorm_eq_of_bounds (zero_le M) h_above <| Subtype.forall'.mpr h_below #align continuous_linear_map.op_nnnorm_eq_of_bounds ContinuousLinearMap.opNNNorm_eq_of_bounds @[deprecated (since := "2024-02-02")] alias op_nnnorm_eq_of_bounds := opNNNorm_eq_of_bounds theorem opNNNorm_le_iff {f : E →SL[σ₁₂] F} {C : ℝ≥0} : ‖f‖₊ ≤ C ↔ ∀ x, ‖f x‖₊ ≤ C * ‖x‖₊ := opNorm_le_iff C.2 @[deprecated (since := "2024-02-02")] alias op_nnnorm_le_iff := opNNNorm_le_iff
Mathlib/Analysis/NormedSpace/OperatorNorm/NNNorm.lean
100
101
theorem isLeast_opNNNorm : IsLeast {C : ℝ≥0 | ∀ x, ‖f x‖₊ ≤ C * ‖x‖₊} ‖f‖₊ := by
simpa only [← opNNNorm_le_iff] using isLeast_Ici
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Yury Kudryashov -/ import Mathlib.Algebra.Algebra.Defs import Mathlib.Algebra.Algebra.NonUnitalHom import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.LinearAlgebra.TensorProduct.Basic #align_import algebra.algebra.bilinear from "leanprover-community/mathlib"@"657df4339ae6ceada048c8a2980fb10e393143ec" /-! # Facts about algebras involving bilinear maps and tensor products We move a few basic statements about algebras out of `Algebra.Algebra.Basic`, in order to avoid importing `LinearAlgebra.BilinearMap` and `LinearAlgebra.TensorProduct` unnecessarily. -/ open TensorProduct Module namespace LinearMap section NonUnitalNonAssoc variable (R A : Type*) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] /-- The multiplication in a non-unital non-associative algebra is a bilinear map. A weaker version of this for semirings exists as `AddMonoidHom.mul`. -/ def mul : A →ₗ[R] A →ₗ[R] A := LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm #align linear_map.mul LinearMap.mul /-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/ noncomputable def mul' : A ⊗[R] A →ₗ[R] A := TensorProduct.lift (mul R A) #align linear_map.mul' LinearMap.mul' variable {A} /-- The multiplication on the left in a non-unital algebra is a linear map. -/ def mulLeft (a : A) : A →ₗ[R] A := mul R A a #align linear_map.mul_left LinearMap.mulLeft /-- The multiplication on the right in an algebra is a linear map. -/ def mulRight (a : A) : A →ₗ[R] A := (mul R A).flip a #align linear_map.mul_right LinearMap.mulRight /-- Simultaneous multiplication on the left and right is a linear map. -/ def mulLeftRight (ab : A × A) : A →ₗ[R] A := (mulRight R ab.snd).comp (mulLeft R ab.fst) #align linear_map.mul_left_right LinearMap.mulLeftRight @[simp] theorem mulLeft_toAddMonoidHom (a : A) : (mulLeft R a : A →+ A) = AddMonoidHom.mulLeft a := rfl #align linear_map.mul_left_to_add_monoid_hom LinearMap.mulLeft_toAddMonoidHom @[simp] theorem mulRight_toAddMonoidHom (a : A) : (mulRight R a : A →+ A) = AddMonoidHom.mulRight a := rfl #align linear_map.mul_right_to_add_monoid_hom LinearMap.mulRight_toAddMonoidHom variable {R} @[simp] theorem mul_apply' (a b : A) : mul R A a b = a * b := rfl #align linear_map.mul_apply' LinearMap.mul_apply' @[simp] theorem mulLeft_apply (a b : A) : mulLeft R a b = a * b := rfl #align linear_map.mul_left_apply LinearMap.mulLeft_apply @[simp] theorem mulRight_apply (a b : A) : mulRight R a b = b * a := rfl #align linear_map.mul_right_apply LinearMap.mulRight_apply @[simp] theorem mulLeftRight_apply (a b x : A) : mulLeftRight R (a, b) x = a * x * b := rfl #align linear_map.mul_left_right_apply LinearMap.mulLeftRight_apply @[simp] theorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b := rfl #align linear_map.mul'_apply LinearMap.mul'_apply @[simp] theorem mulLeft_zero_eq_zero : mulLeft R (0 : A) = 0 := (mul R A).map_zero #align linear_map.mul_left_zero_eq_zero LinearMap.mulLeft_zero_eq_zero @[simp] theorem mulRight_zero_eq_zero : mulRight R (0 : A) = 0 := (mul R A).flip.map_zero #align linear_map.mul_right_zero_eq_zero LinearMap.mulRight_zero_eq_zero end NonUnitalNonAssoc section NonUnital variable (R A : Type*) [CommSemiring R] [NonUnitalSemiring A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] /-- The multiplication in a non-unital algebra is a bilinear map. A weaker version of this for non-unital non-associative algebras exists as `LinearMap.mul`. -/ def _root_.NonUnitalAlgHom.lmul : A →ₙₐ[R] End R A := { mul R A with map_mul' := by intro a b ext c exact mul_assoc a b c map_zero' := by ext a exact zero_mul a } #align non_unital_alg_hom.lmul NonUnitalAlgHom.lmul variable {R A} @[simp] theorem _root_.NonUnitalAlgHom.coe_lmul_eq_mul : ⇑(NonUnitalAlgHom.lmul R A) = mul R A := rfl #align non_unital_alg_hom.coe_lmul_eq_mul NonUnitalAlgHom.coe_lmul_eq_mul theorem commute_mulLeft_right (a b : A) : Commute (mulLeft R a) (mulRight R b) := by ext c exact (mul_assoc a c b).symm #align linear_map.commute_mul_left_right LinearMap.commute_mulLeft_right @[simp]
Mathlib/Algebra/Algebra/Bilinear.lean
140
142
theorem mulLeft_mul (a b : A) : mulLeft R (a * b) = (mulLeft R a).comp (mulLeft R b) := by
ext simp only [mulLeft_apply, comp_apply, mul_assoc]
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Yury Kudryashov -/ import Mathlib.Algebra.CharP.Invertible import Mathlib.Analysis.NormedSpace.Basic import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace import Mathlib.Topology.Instances.RealVectorSpace #align_import analysis.normed_space.add_torsor from "leanprover-community/mathlib"@"837f72de63ad6cd96519cde5f1ffd5ed8d280ad0" /-! # Torsors of normed space actions. This file contains lemmas about normed additive torsors over normed spaces. -/ noncomputable section open NNReal Topology open Filter variable {α V P W Q : Type*} [SeminormedAddCommGroup V] [PseudoMetricSpace P] [NormedAddTorsor V P] [NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q] section NormedSpace variable {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 V] [NormedSpace 𝕜 W] open AffineMap theorem AffineSubspace.isClosed_direction_iff (s : AffineSubspace 𝕜 Q) : IsClosed (s.direction : Set W) ↔ IsClosed (s : Set Q) := by rcases s.eq_bot_or_nonempty with (rfl | ⟨x, hx⟩); · simp [isClosed_singleton] rw [← (IsometryEquiv.vaddConst x).toHomeomorph.symm.isClosed_image, AffineSubspace.coe_direction_eq_vsub_set_right hx] rfl #align affine_subspace.is_closed_direction_iff AffineSubspace.isClosed_direction_iff @[simp] theorem dist_center_homothety (p₁ p₂ : P) (c : 𝕜) : dist p₁ (homothety p₁ c p₂) = ‖c‖ * dist p₁ p₂ := by simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm] #align dist_center_homothety dist_center_homothety @[simp] theorem nndist_center_homothety (p₁ p₂ : P) (c : 𝕜) : nndist p₁ (homothety p₁ c p₂) = ‖c‖₊ * nndist p₁ p₂ := NNReal.eq <| dist_center_homothety _ _ _ #align nndist_center_homothety nndist_center_homothety @[simp] theorem dist_homothety_center (p₁ p₂ : P) (c : 𝕜) : dist (homothety p₁ c p₂) p₁ = ‖c‖ * dist p₁ p₂ := by rw [dist_comm, dist_center_homothety] #align dist_homothety_center dist_homothety_center @[simp] theorem nndist_homothety_center (p₁ p₂ : P) (c : 𝕜) : nndist (homothety p₁ c p₂) p₁ = ‖c‖₊ * nndist p₁ p₂ := NNReal.eq <| dist_homothety_center _ _ _ #align nndist_homothety_center nndist_homothety_center @[simp]
Mathlib/Analysis/NormedSpace/AddTorsor.lean
68
72
theorem dist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) : dist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = dist c₁ c₂ * dist p₁ p₂ := by
rw [dist_comm p₁ p₂] simp only [lineMap_apply, dist_eq_norm_vsub, vadd_vsub_vadd_cancel_right, ← sub_smul, norm_smul, vsub_eq_sub]
/- Copyright (c) 2021 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz -/ import Mathlib.CategoryTheory.Sites.Sheaf #align_import category_theory.sites.plus from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # The plus construction for presheaves. This file contains the construction of `P⁺`, for a presheaf `P : Cᵒᵖ ⥤ D` where `C` is endowed with a grothendieck topology `J`. See <https://stacks.math.columbia.edu/tag/00W1> for details. -/ namespace CategoryTheory.GrothendieckTopology open CategoryTheory open CategoryTheory.Limits open Opposite universe w v u variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) variable {D : Type w} [Category.{max v u} D] noncomputable section variable [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.Cover X), HasMultiequalizer (S.index P)] variable (P : Cᵒᵖ ⥤ D) /-- The diagram whose colimit defines the values of `plus`. -/ @[simps] def diagram (X : C) : (J.Cover X)ᵒᵖ ⥤ D where obj S := multiequalizer (S.unop.index P) map {S _} f := Multiequalizer.lift _ _ (fun I => Multiequalizer.ι (S.unop.index P) (I.map f.unop)) fun I => Multiequalizer.condition (S.unop.index P) (I.map f.unop) #align category_theory.grothendieck_topology.diagram CategoryTheory.GrothendieckTopology.diagram /-- A helper definition used to define the morphisms for `plus`. -/ @[simps] def diagramPullback {X Y : C} (f : X ⟶ Y) : J.diagram P Y ⟶ (J.pullback f).op ⋙ J.diagram P X where app S := Multiequalizer.lift _ _ (fun I => Multiequalizer.ι (S.unop.index P) I.base) fun I => Multiequalizer.condition (S.unop.index P) I.base naturality S T f := Multiequalizer.hom_ext _ _ _ (fun I => by dsimp; simp; rfl) #align category_theory.grothendieck_topology.diagram_pullback CategoryTheory.GrothendieckTopology.diagramPullback /-- A natural transformation `P ⟶ Q` induces a natural transformation between diagrams whose colimits define the values of `plus`. -/ @[simps] def diagramNatTrans {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (X : C) : J.diagram P X ⟶ J.diagram Q X where app W := Multiequalizer.lift _ _ (fun i => Multiequalizer.ι _ _ ≫ η.app _) (fun i => by dsimp only erw [Category.assoc, Category.assoc, ← η.naturality, ← η.naturality, Multiequalizer.condition_assoc] rfl) #align category_theory.grothendieck_topology.diagram_nat_trans CategoryTheory.GrothendieckTopology.diagramNatTrans @[simp]
Mathlib/CategoryTheory/Sites/Plus.lean
71
77
theorem diagramNatTrans_id (X : C) (P : Cᵒᵖ ⥤ D) : J.diagramNatTrans (𝟙 P) X = 𝟙 (J.diagram P X) := by
ext : 2 refine Multiequalizer.hom_ext _ _ _ (fun i => ?_) dsimp simp only [limit.lift_π, Multifork.ofι_pt, Multifork.ofι_π_app, Category.id_comp] erw [Category.comp_id]
/- Copyright (c) 2022 Michael Stoll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Stoll -/ import Mathlib.Data.Int.Range import Mathlib.Data.ZMod.Basic import Mathlib.NumberTheory.MulChar.Basic #align_import number_theory.legendre_symbol.zmod_char from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Quadratic characters on ℤ/nℤ This file defines some quadratic characters on the rings ℤ/4ℤ and ℤ/8ℤ. We set them up to be of type `MulChar (ZMod n) ℤ`, where `n` is `4` or `8`. ## Tags quadratic character, zmod -/ /-! ### Quadratic characters mod 4 and 8 We define the primitive quadratic characters `χ₄`on `ZMod 4` and `χ₈`, `χ₈'` on `ZMod 8`. -/ namespace ZMod section QuadCharModP /-- Define the nontrivial quadratic character on `ZMod 4`, `χ₄`. It corresponds to the extension `ℚ(√-1)/ℚ`. -/ @[simps] def χ₄ : MulChar (ZMod 4) ℤ where toFun := (![0, 1, 0, -1] : ZMod 4 → ℤ) map_one' := rfl map_mul' := by decide map_nonunit' := by decide #align zmod.χ₄ ZMod.χ₄ /-- `χ₄` takes values in `{0, 1, -1}` -/ theorem isQuadratic_χ₄ : χ₄.IsQuadratic := by intro a -- Porting note (#11043): was `decide!` fin_cases a all_goals decide #align zmod.is_quadratic_χ₄ ZMod.isQuadratic_χ₄ /-- The value of `χ₄ n`, for `n : ℕ`, depends only on `n % 4`. -/ theorem χ₄_nat_mod_four (n : ℕ) : χ₄ n = χ₄ (n % 4 : ℕ) := by rw [← ZMod.natCast_mod n 4] #align zmod.χ₄_nat_mod_four ZMod.χ₄_nat_mod_four /-- The value of `χ₄ n`, for `n : ℤ`, depends only on `n % 4`. -/ theorem χ₄_int_mod_four (n : ℤ) : χ₄ n = χ₄ (n % 4 : ℤ) := by rw [← ZMod.intCast_mod n 4] norm_cast #align zmod.χ₄_int_mod_four ZMod.χ₄_int_mod_four /-- An explicit description of `χ₄` on integers / naturals -/ theorem χ₄_int_eq_if_mod_four (n : ℤ) : χ₄ n = if n % 2 = 0 then 0 else if n % 4 = 1 then 1 else -1 := by have help : ∀ m : ℤ, 0 ≤ m → m < 4 → χ₄ m = if m % 2 = 0 then 0 else if m = 1 then 1 else -1 := by decide rw [← Int.emod_emod_of_dvd n (by decide : (2 : ℤ) ∣ 4), ← ZMod.intCast_mod n 4] exact help (n % 4) (Int.emod_nonneg n (by norm_num)) (Int.emod_lt n (by norm_num)) #align zmod.χ₄_int_eq_if_mod_four ZMod.χ₄_int_eq_if_mod_four theorem χ₄_nat_eq_if_mod_four (n : ℕ) : χ₄ n = if n % 2 = 0 then 0 else if n % 4 = 1 then 1 else -1 := mod_cast χ₄_int_eq_if_mod_four n #align zmod.χ₄_nat_eq_if_mod_four ZMod.χ₄_nat_eq_if_mod_four /-- Alternative description of `χ₄ n` for odd `n : ℕ` in terms of powers of `-1` -/ theorem χ₄_eq_neg_one_pow {n : ℕ} (hn : n % 2 = 1) : χ₄ n = (-1) ^ (n / 2) := by rw [χ₄_nat_eq_if_mod_four] simp only [hn, Nat.one_ne_zero, if_false] conv_rhs => -- Porting note: was `nth_rw` arg 2; rw [← Nat.div_add_mod n 4] enter [1, 1, 1]; rw [(by norm_num : 4 = 2 * 2)] rw [mul_assoc, add_comm, Nat.add_mul_div_left _ _ (by norm_num : 0 < 2), pow_add, pow_mul, neg_one_sq, one_pow, mul_one] have help : ∀ m : ℕ, m < 4 → m % 2 = 1 → ite (m = 1) (1 : ℤ) (-1) = (-1) ^ (m / 2) := by decide exact help (n % 4) (Nat.mod_lt n (by norm_num)) ((Nat.mod_mod_of_dvd n (by decide : 2 ∣ 4)).trans hn) #align zmod.χ₄_eq_neg_one_pow ZMod.χ₄_eq_neg_one_pow /-- If `n % 4 = 1`, then `χ₄ n = 1`. -/ theorem χ₄_nat_one_mod_four {n : ℕ} (hn : n % 4 = 1) : χ₄ n = 1 := by rw [χ₄_nat_mod_four, hn] rfl #align zmod.χ₄_nat_one_mod_four ZMod.χ₄_nat_one_mod_four /-- If `n % 4 = 3`, then `χ₄ n = -1`. -/ theorem χ₄_nat_three_mod_four {n : ℕ} (hn : n % 4 = 3) : χ₄ n = -1 := by rw [χ₄_nat_mod_four, hn] rfl #align zmod.χ₄_nat_three_mod_four ZMod.χ₄_nat_three_mod_four /-- If `n % 4 = 1`, then `χ₄ n = 1`. -/ theorem χ₄_int_one_mod_four {n : ℤ} (hn : n % 4 = 1) : χ₄ n = 1 := by rw [χ₄_int_mod_four, hn] rfl #align zmod.χ₄_int_one_mod_four ZMod.χ₄_int_one_mod_four /-- If `n % 4 = 3`, then `χ₄ n = -1`. -/
Mathlib/NumberTheory/LegendreSymbol/ZModChar.lean
113
115
theorem χ₄_int_three_mod_four {n : ℤ} (hn : n % 4 = 3) : χ₄ n = -1 := by
rw [χ₄_int_mod_four, hn] rfl
/- Copyright (c) 2020 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Devon Tuma -/ import Mathlib.Algebra.Polynomial.Roots import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent import Mathlib.Analysis.Asymptotics.SpecificAsymptotics #align_import analysis.special_functions.polynomials from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Limits related to polynomial and rational functions This file proves basic facts about limits of polynomial and rationals functions. The main result is `eval_is_equivalent_at_top_eval_lead`, which states that for any polynomial `P` of degree `n` with leading coefficient `a`, the corresponding polynomial function is equivalent to `a * x^n` as `x` goes to +∞. We can then use this result to prove various limits for polynomial and rational functions, depending on the degrees and leading coefficients of the considered polynomials. -/ open Filter Finset Asymptotics open Asymptotics Polynomial Topology namespace Polynomial variable {𝕜 : Type*} [NormedLinearOrderedField 𝕜] (P Q : 𝕜[X]) theorem eventually_no_roots (hP : P ≠ 0) : ∀ᶠ x in atTop, ¬P.IsRoot x := atTop_le_cofinite <| (finite_setOf_isRoot hP).compl_mem_cofinite #align polynomial.eventually_no_roots Polynomial.eventually_no_roots variable [OrderTopology 𝕜] section PolynomialAtTop theorem isEquivalent_atTop_lead : (fun x => eval x P) ~[atTop] fun x => P.leadingCoeff * x ^ P.natDegree := by by_cases h : P = 0 · simp [h, IsEquivalent.refl] · simp only [Polynomial.eval_eq_sum_range, sum_range_succ] exact IsLittleO.add_isEquivalent (IsLittleO.sum fun i hi => IsLittleO.const_mul_left ((IsLittleO.const_mul_right fun hz => h <| leadingCoeff_eq_zero.mp hz) <| isLittleO_pow_pow_atTop_of_lt (mem_range.mp hi)) _) IsEquivalent.refl #align polynomial.is_equivalent_at_top_lead Polynomial.isEquivalent_atTop_lead theorem tendsto_atTop_of_leadingCoeff_nonneg (hdeg : 0 < P.degree) (hnng : 0 ≤ P.leadingCoeff) : Tendsto (fun x => eval x P) atTop atTop := P.isEquivalent_atTop_lead.symm.tendsto_atTop <| tendsto_const_mul_pow_atTop (natDegree_pos_iff_degree_pos.2 hdeg).ne' <| hnng.lt_of_ne' <| leadingCoeff_ne_zero.mpr <| ne_zero_of_degree_gt hdeg #align polynomial.tendsto_at_top_of_leading_coeff_nonneg Polynomial.tendsto_atTop_of_leadingCoeff_nonneg theorem tendsto_atTop_iff_leadingCoeff_nonneg : Tendsto (fun x => eval x P) atTop atTop ↔ 0 < P.degree ∧ 0 ≤ P.leadingCoeff := by refine ⟨fun h => ?_, fun h => tendsto_atTop_of_leadingCoeff_nonneg P h.1 h.2⟩ have : Tendsto (fun x => P.leadingCoeff * x ^ P.natDegree) atTop atTop := (isEquivalent_atTop_lead P).tendsto_atTop h rw [tendsto_const_mul_pow_atTop_iff, ← pos_iff_ne_zero, natDegree_pos_iff_degree_pos] at this exact ⟨this.1, this.2.le⟩ #align polynomial.tendsto_at_top_iff_leading_coeff_nonneg Polynomial.tendsto_atTop_iff_leadingCoeff_nonneg
Mathlib/Analysis/SpecialFunctions/Polynomials.lean
73
76
theorem tendsto_atBot_iff_leadingCoeff_nonpos : Tendsto (fun x => eval x P) atTop atBot ↔ 0 < P.degree ∧ P.leadingCoeff ≤ 0 := by
simp only [← tendsto_neg_atTop_iff, ← eval_neg, tendsto_atTop_iff_leadingCoeff_nonneg, degree_neg, leadingCoeff_neg, neg_nonneg]
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Data.Finsupp.Basic import Mathlib.Data.Finsupp.Order #align_import data.finsupp.multiset from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Equivalence between `Multiset` and `ℕ`-valued finitely supported functions This defines `Finsupp.toMultiset` the equivalence between `α →₀ ℕ` and `Multiset α`, along with `Multiset.toFinsupp` the reverse equivalence and `Finsupp.orderIsoMultiset` the equivalence promoted to an order isomorphism. -/ open Finset variable {α β ι : Type*} namespace Finsupp /-- Given `f : α →₀ ℕ`, `f.toMultiset` is the multiset with multiplicities given by the values of `f` on the elements of `α`. We define this function as an `AddMonoidHom`. Under the additional assumption of `[DecidableEq α]`, this is available as `Multiset.toFinsupp : Multiset α ≃+ (α →₀ ℕ)`; the two declarations are separate as this assumption is only needed for one direction. -/ def toMultiset : (α →₀ ℕ) →+ Multiset α where toFun f := Finsupp.sum f fun a n => n • {a} -- Porting note: times out if h is not specified map_add' _f _g := sum_add_index' (h := fun a n => n • ({a} : Multiset α)) (fun _ ↦ zero_nsmul _) (fun _ ↦ add_nsmul _) map_zero' := sum_zero_index theorem toMultiset_zero : toMultiset (0 : α →₀ ℕ) = 0 := rfl #align finsupp.to_multiset_zero Finsupp.toMultiset_zero theorem toMultiset_add (m n : α →₀ ℕ) : toMultiset (m + n) = toMultiset m + toMultiset n := toMultiset.map_add m n #align finsupp.to_multiset_add Finsupp.toMultiset_add theorem toMultiset_apply (f : α →₀ ℕ) : toMultiset f = f.sum fun a n => n • {a} := rfl #align finsupp.to_multiset_apply Finsupp.toMultiset_apply @[simp] theorem toMultiset_single (a : α) (n : ℕ) : toMultiset (single a n) = n • {a} := by rw [toMultiset_apply, sum_single_index]; apply zero_nsmul #align finsupp.to_multiset_single Finsupp.toMultiset_single theorem toMultiset_sum {f : ι → α →₀ ℕ} (s : Finset ι) : Finsupp.toMultiset (∑ i ∈ s, f i) = ∑ i ∈ s, Finsupp.toMultiset (f i) := map_sum Finsupp.toMultiset _ _ #align finsupp.to_multiset_sum Finsupp.toMultiset_sum theorem toMultiset_sum_single (s : Finset ι) (n : ℕ) : Finsupp.toMultiset (∑ i ∈ s, single i n) = n • s.val := by simp_rw [toMultiset_sum, Finsupp.toMultiset_single, sum_nsmul, sum_multiset_singleton] #align finsupp.to_multiset_sum_single Finsupp.toMultiset_sum_single @[simp]
Mathlib/Data/Finsupp/Multiset.lean
67
68
theorem card_toMultiset (f : α →₀ ℕ) : Multiset.card (toMultiset f) = f.sum fun _ => id := by
simp [toMultiset_apply, map_finsupp_sum, Function.id_def]
/- 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.Order.RelClasses #align_import data.sigma.lex from "leanprover-community/mathlib"@"41cf0cc2f528dd40a8f2db167ea4fb37b8fde7f3" /-! # Lexicographic order on a sigma type This defines the lexicographical order of two arbitrary relations on a sigma type and proves some lemmas about `PSigma.Lex`, which is defined in core Lean. Given a relation in the index type and a relation on each summand, the lexicographical order on the sigma type relates `a` and `b` if their summands are related or they are in the same summand and related by the summand's relation. ## See also Related files are: * `Combinatorics.CoLex`: Colexicographic order on finite sets. * `Data.List.Lex`: Lexicographic order on lists. * `Data.Sigma.Order`: Lexicographic order on `Σ i, α i` per say. * `Data.PSigma.Order`: Lexicographic order on `Σ' i, α i`. * `Data.Prod.Lex`: Lexicographic order on `α × β`. Can be thought of as the special case of `Sigma.Lex` where all summands are the same -/ namespace Sigma variable {ι : Type*} {α : ι → Type*} {r r₁ r₂ : ι → ι → Prop} {s s₁ s₂ : ∀ i, α i → α i → Prop} {a b : Σ i, α i} /-- The lexicographical order on a sigma type. It takes in a relation on the index type and a relation for each summand. `a` is related to `b` iff their summands are related or they are in the same summand and are related through the summand's relation. -/ inductive Lex (r : ι → ι → Prop) (s : ∀ i, α i → α i → Prop) : ∀ _ _ : Σ i, α i, Prop | left {i j : ι} (a : α i) (b : α j) : r i j → Lex r s ⟨i, a⟩ ⟨j, b⟩ | right {i : ι} (a b : α i) : s i a b → Lex r s ⟨i, a⟩ ⟨i, b⟩ #align sigma.lex Sigma.Lex theorem lex_iff : Lex r s a b ↔ r a.1 b.1 ∨ ∃ h : a.1 = b.1, s b.1 (h.rec a.2) b.2 := by constructor · rintro (⟨a, b, hij⟩ | ⟨a, b, hab⟩) · exact Or.inl hij · exact Or.inr ⟨rfl, hab⟩ · obtain ⟨i, a⟩ := a obtain ⟨j, b⟩ := b dsimp only rintro (h | ⟨rfl, h⟩) · exact Lex.left _ _ h · exact Lex.right _ _ h #align sigma.lex_iff Sigma.lex_iff instance Lex.decidable (r : ι → ι → Prop) (s : ∀ i, α i → α i → Prop) [DecidableEq ι] [DecidableRel r] [∀ i, DecidableRel (s i)] : DecidableRel (Lex r s) := fun _ _ => decidable_of_decidable_of_iff lex_iff.symm #align sigma.lex.decidable Sigma.Lex.decidable theorem Lex.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ i a b, s₁ i a b → s₂ i a b) {a b : Σ i, α i} (h : Lex r₁ s₁ a b) : Lex r₂ s₂ a b := by obtain ⟨a, b, hij⟩ | ⟨a, b, hab⟩ := h · exact Lex.left _ _ (hr _ _ hij) · exact Lex.right _ _ (hs _ _ _ hab) #align sigma.lex.mono Sigma.Lex.mono theorem Lex.mono_left (hr : ∀ a b, r₁ a b → r₂ a b) {a b : Σ i, α i} (h : Lex r₁ s a b) : Lex r₂ s a b := h.mono hr fun _ _ _ => id #align sigma.lex.mono_left Sigma.Lex.mono_left theorem Lex.mono_right (hs : ∀ i a b, s₁ i a b → s₂ i a b) {a b : Σ i, α i} (h : Lex r s₁ a b) : Lex r s₂ a b := h.mono (fun _ _ => id) hs #align sigma.lex.mono_right Sigma.Lex.mono_right
Mathlib/Data/Sigma/Lex.lean
80
83
theorem lex_swap : Lex (Function.swap r) s a b ↔ Lex r (fun i => Function.swap (s i)) b a := by
constructor <;> · rintro (⟨a, b, h⟩ | ⟨a, b, h⟩) exacts [Lex.left _ _ h, Lex.right _ _ h]
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Yaël Dillies -/ import Mathlib.Order.Cover import Mathlib.Order.Interval.Finset.Defs #align_import data.finset.locally_finite from "leanprover-community/mathlib"@"442a83d738cb208d3600056c489be16900ba701d" /-! # Intervals as finsets This file provides basic results about all the `Finset.Ixx`, which are defined in `Order.Interval.Finset.Defs`. In addition, it shows that in a locally finite order `≤` and `<` are the transitive closures of, respectively, `⩿` and `⋖`, which then leads to a characterization of monotone and strictly functions whose domain is a locally finite order. In particular, this file proves: * `le_iff_transGen_wcovBy`: `≤` is the transitive closure of `⩿` * `lt_iff_transGen_covBy`: `≤` is the transitive closure of `⩿` * `monotone_iff_forall_wcovBy`: Characterization of monotone functions * `strictMono_iff_forall_covBy`: Characterization of strictly monotone functions ## TODO This file was originally only about `Finset.Ico a b` where `a b : ℕ`. No care has yet been taken to generalize these lemmas properly and many lemmas about `Icc`, `Ioc`, `Ioo` are missing. In general, what's to do is taking the lemmas in `Data.X.Intervals` and abstract away the concrete structure. Complete the API. See https://github.com/leanprover-community/mathlib/pull/14448#discussion_r906109235 for some ideas. -/ assert_not_exists MonoidWithZero assert_not_exists Finset.sum open Function OrderDual open FinsetInterval variable {ι α : Type*} namespace Finset section Preorder variable [Preorder α] section LocallyFiniteOrder variable [LocallyFiniteOrder α] {a a₁ a₂ b b₁ b₂ c x : α} @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b := by rw [← coe_nonempty, coe_Icc, Set.nonempty_Icc] #align finset.nonempty_Icc Finset.nonempty_Icc @[simp, aesop safe apply (rule_sets := [finsetNonempty])]
Mathlib/Order/Interval/Finset/Basic.lean
62
63
theorem nonempty_Ico : (Ico a b).Nonempty ↔ a < b := by
rw [← coe_nonempty, coe_Ico, Set.nonempty_Ico]
/- Copyright (c) 2018 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Inductions import Mathlib.Algebra.Polynomial.Splits import Mathlib.Analysis.Normed.Field.Basic import Mathlib.RingTheory.Polynomial.Vieta #align_import topology.algebra.polynomial from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" /-! # Polynomials and limits In this file we prove the following lemmas. * `Polynomial.continuous_eval₂`: `Polynomial.eval₂` defines a continuous function. * `Polynomial.continuous_aeval`: `Polynomial.aeval` defines a continuous function; we also prove convenience lemmas `Polynomial.continuousAt_aeval`, `Polynomial.continuousWithinAt_aeval`, `Polynomial.continuousOn_aeval`. * `Polynomial.continuous`: `Polynomial.eval` defines a continuous functions; we also prove convenience lemmas `Polynomial.continuousAt`, `Polynomial.continuousWithinAt`, `Polynomial.continuousOn`. * `Polynomial.tendsto_norm_atTop`: `fun x ↦ ‖Polynomial.eval (z x) p‖` tends to infinity provided that `fun x ↦ ‖z x‖` tends to infinity and `0 < degree p`; * `Polynomial.tendsto_abv_eval₂_atTop`, `Polynomial.tendsto_abv_atTop`, `Polynomial.tendsto_abv_aeval_atTop`: a few versions of the previous statement for `IsAbsoluteValue abv` instead of norm. ## Tags Polynomial, continuity -/ open IsAbsoluteValue Filter namespace Polynomial open Polynomial section TopologicalSemiring variable {R S : Type*} [Semiring R] [TopologicalSpace R] [TopologicalSemiring R] (p : R[X]) @[continuity, fun_prop] protected theorem continuous_eval₂ [Semiring S] (p : S[X]) (f : S →+* R) : Continuous fun x => p.eval₂ f x := by simp only [eval₂_eq_sum, Finsupp.sum] exact continuous_finset_sum _ fun c _ => continuous_const.mul (continuous_pow _) #align polynomial.continuous_eval₂ Polynomial.continuous_eval₂ @[continuity, fun_prop] protected theorem continuous : Continuous fun x => p.eval x := p.continuous_eval₂ _ #align polynomial.continuous Polynomial.continuous @[fun_prop] protected theorem continuousAt {a : R} : ContinuousAt (fun x => p.eval x) a := p.continuous.continuousAt #align polynomial.continuous_at Polynomial.continuousAt @[fun_prop] protected theorem continuousWithinAt {s a} : ContinuousWithinAt (fun x => p.eval x) s a := p.continuous.continuousWithinAt #align polynomial.continuous_within_at Polynomial.continuousWithinAt @[fun_prop] protected theorem continuousOn {s} : ContinuousOn (fun x => p.eval x) s := p.continuous.continuousOn #align polynomial.continuous_on Polynomial.continuousOn end TopologicalSemiring section TopologicalAlgebra variable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [TopologicalSpace A] [TopologicalSemiring A] (p : R[X]) @[continuity, fun_prop] protected theorem continuous_aeval : Continuous fun x : A => aeval x p := p.continuous_eval₂ _ #align polynomial.continuous_aeval Polynomial.continuous_aeval @[fun_prop] protected theorem continuousAt_aeval {a : A} : ContinuousAt (fun x : A => aeval x p) a := p.continuous_aeval.continuousAt #align polynomial.continuous_at_aeval Polynomial.continuousAt_aeval @[fun_prop] protected theorem continuousWithinAt_aeval {s a} : ContinuousWithinAt (fun x : A => aeval x p) s a := p.continuous_aeval.continuousWithinAt #align polynomial.continuous_within_at_aeval Polynomial.continuousWithinAt_aeval @[fun_prop] protected theorem continuousOn_aeval {s} : ContinuousOn (fun x : A => aeval x p) s := p.continuous_aeval.continuousOn #align polynomial.continuous_on_aeval Polynomial.continuousOn_aeval end TopologicalAlgebra
Mathlib/Topology/Algebra/Polynomial.lean
105
120
theorem tendsto_abv_eval₂_atTop {R S k α : Type*} [Semiring R] [Ring S] [LinearOrderedField k] (f : R →+* S) (abv : S → k) [IsAbsoluteValue abv] (p : R[X]) (hd : 0 < degree p) (hf : f p.leadingCoeff ≠ 0) {l : Filter α} {z : α → S} (hz : Tendsto (abv ∘ z) l atTop) : Tendsto (fun x => abv (p.eval₂ f (z x))) l atTop := by
revert hf; refine degree_pos_induction_on p hd ?_ ?_ ?_ <;> clear hd p · rintro _ - hc rw [leadingCoeff_mul_X, leadingCoeff_C] at hc simpa [abv_mul abv] using hz.const_mul_atTop ((abv_pos abv).2 hc) · intro _ _ ihp hf rw [leadingCoeff_mul_X] at hf simpa [abv_mul abv] using (ihp hf).atTop_mul_atTop hz · intro _ a hd ihp hf rw [add_comm, leadingCoeff_add_of_degree_lt (degree_C_le.trans_lt hd)] at hf refine tendsto_atTop_of_add_const_right (abv (-f a)) ?_ refine tendsto_atTop_mono (fun _ => abv_add abv _ _) ?_ simpa using ihp hf
/- Copyright (c) 2022 Eric Rodriguez. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Rodriguez -/ import Mathlib.SetTheory.Cardinal.Ordinal import Mathlib.RingTheory.Artinian #align_import ring_theory.localization.cardinality from "leanprover-community/mathlib"@"3b09a2601bb7690643936643e99bba0fedfbf6ed" /-! # Cardinality of localizations In this file, we establish the cardinality of localizations. In most cases, a localization has cardinality equal to the base ring. If there are zero-divisors, however, this is no longer true - for example, `ZMod 6` localized at `{2, 4}` is equal to `ZMod 3`, and if you have zero in your submonoid, then your localization is trivial (see `IsLocalization.uniqueOfZeroMem`). ## Main statements * `IsLocalization.card_le`: A localization has cardinality no larger than the base ring. * `IsLocalization.card`: If you don't localize at zero-divisors, the localization of a ring has cardinality equal to its base ring, -/ open Cardinal nonZeroDivisors universe u v namespace IsLocalization variable {R : Type u} [CommRing R] (S : Submonoid R) {L : Type u} [CommRing L] [Algebra R L] [IsLocalization S L] /-- A localization always has cardinality less than or equal to the base ring. -/
Mathlib/RingTheory/Localization/Cardinality.lean
38
48
theorem card_le : #L ≤ #R := by
classical cases fintypeOrInfinite R · exact Cardinal.mk_le_of_surjective (IsArtinianRing.localization_surjective S _) erw [← Cardinal.mul_eq_self <| Cardinal.aleph0_le_mk R] set f : R × R → L := fun aa => IsLocalization.mk' _ aa.1 (if h : aa.2 ∈ S then ⟨aa.2, h⟩ else 1) refine @Cardinal.mk_le_of_surjective _ _ f fun a => ?_ obtain ⟨x, y, h⟩ := IsLocalization.mk'_surjective S a use (x, y) dsimp [f] rwa [dif_pos <| show ↑y ∈ S from y.2, SetLike.eta]
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa, Alex Meiburg -/ import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Polynomial.Degree.Lemmas #align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448" /-! # Erase the leading term of a univariate polynomial ## Definition * `eraseLead f`: the polynomial `f - leading term of f` `eraseLead` serves as reduction step in an induction, shaving off one monomial from a polynomial. The definition is set up so that it does not mention subtraction in the definition, and thus works for polynomials over semirings as well as rings. -/ noncomputable section open Polynomial open Polynomial Finset namespace Polynomial variable {R : Type*} [Semiring R] {f : R[X]} /-- `eraseLead f` for a polynomial `f` is the polynomial obtained by subtracting from `f` the leading term of `f`. -/ def eraseLead (f : R[X]) : R[X] := Polynomial.erase f.natDegree f #align polynomial.erase_lead Polynomial.eraseLead section EraseLead theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by simp only [eraseLead, support_erase] #align polynomial.erase_lead_support Polynomial.eraseLead_support theorem eraseLead_coeff (i : ℕ) : f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by simp only [eraseLead, coeff_erase] #align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff @[simp] theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by simp [eraseLead_coeff] #align polynomial.erase_lead_coeff_nat_degree Polynomial.eraseLead_coeff_natDegree theorem eraseLead_coeff_of_ne (i : ℕ) (hi : i ≠ f.natDegree) : f.eraseLead.coeff i = f.coeff i := by simp [eraseLead_coeff, hi] #align polynomial.erase_lead_coeff_of_ne Polynomial.eraseLead_coeff_of_ne @[simp] theorem eraseLead_zero : eraseLead (0 : R[X]) = 0 := by simp only [eraseLead, erase_zero] #align polynomial.erase_lead_zero Polynomial.eraseLead_zero @[simp] theorem eraseLead_add_monomial_natDegree_leadingCoeff (f : R[X]) : f.eraseLead + monomial f.natDegree f.leadingCoeff = f := (add_comm _ _).trans (f.monomial_add_erase _) #align polynomial.erase_lead_add_monomial_nat_degree_leading_coeff Polynomial.eraseLead_add_monomial_natDegree_leadingCoeff @[simp] theorem eraseLead_add_C_mul_X_pow (f : R[X]) : f.eraseLead + C f.leadingCoeff * X ^ f.natDegree = f := by rw [C_mul_X_pow_eq_monomial, eraseLead_add_monomial_natDegree_leadingCoeff] set_option linter.uppercaseLean3 false in #align polynomial.erase_lead_add_C_mul_X_pow Polynomial.eraseLead_add_C_mul_X_pow @[simp] theorem self_sub_monomial_natDegree_leadingCoeff {R : Type*} [Ring R] (f : R[X]) : f - monomial f.natDegree f.leadingCoeff = f.eraseLead := (eq_sub_iff_add_eq.mpr (eraseLead_add_monomial_natDegree_leadingCoeff f)).symm #align polynomial.self_sub_monomial_nat_degree_leading_coeff Polynomial.self_sub_monomial_natDegree_leadingCoeff @[simp]
Mathlib/Algebra/Polynomial/EraseLead.lean
83
85
theorem self_sub_C_mul_X_pow {R : Type*} [Ring R] (f : R[X]) : f - C f.leadingCoeff * X ^ f.natDegree = f.eraseLead := by
rw [C_mul_X_pow_eq_monomial, self_sub_monomial_natDegree_leadingCoeff]
/- Copyright (c) 2020 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Anatole Dedecker -/ import Mathlib.Topology.Separation #align_import topology.extend_from from "leanprover-community/mathlib"@"b363547b3113d350d053abdf2884e9850a56b205" /-! # Extending a function from a subset The main definition of this file is `extendFrom A f` where `f : X → Y` and `A : Set X`. This defines a new function `g : X → Y` which maps any `x₀ : X` to the limit of `f` as `x` tends to `x₀`, if such a limit exists. This is analogous to the way `DenseInducing.extend` "extends" a function `f : X → Z` to a function `g : Y → Z` along a dense inducing `i : X → Y`. The main theorem we prove about this definition is `continuousOn_extendFrom` which states that, for `extendFrom A f` to be continuous on a set `B ⊆ closure A`, it suffices that `f` converges within `A` at any point of `B`, provided that `f` is a function to a T₃ space. -/ noncomputable section open Topology open Filter Set variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] /-- Extend a function from a set `A`. The resulting function `g` is such that at any `x₀`, if `f` converges to some `y` as `x` tends to `x₀` within `A`, then `g x₀` is defined to be one of these `y`. Else, `g x₀` could be anything. -/ def extendFrom (A : Set X) (f : X → Y) : X → Y := fun x ↦ @limUnder _ _ _ ⟨f x⟩ (𝓝[A] x) f #align extend_from extendFrom /-- If `f` converges to some `y` as `x` tends to `x₀` within `A`, then `f` tends to `extendFrom A f x` as `x` tends to `x₀`. -/ theorem tendsto_extendFrom {A : Set X} {f : X → Y} {x : X} (h : ∃ y, Tendsto f (𝓝[A] x) (𝓝 y)) : Tendsto f (𝓝[A] x) (𝓝 <| extendFrom A f x) := tendsto_nhds_limUnder h #align tendsto_extend_from tendsto_extendFrom theorem extendFrom_eq [T2Space Y] {A : Set X} {f : X → Y} {x : X} {y : Y} (hx : x ∈ closure A) (hf : Tendsto f (𝓝[A] x) (𝓝 y)) : extendFrom A f x = y := haveI := mem_closure_iff_nhdsWithin_neBot.mp hx tendsto_nhds_unique (tendsto_nhds_limUnder ⟨y, hf⟩) hf #align extend_from_eq extendFrom_eq theorem extendFrom_extends [T2Space Y] {f : X → Y} {A : Set X} (hf : ContinuousOn f A) : ∀ x ∈ A, extendFrom A f x = f x := fun x x_in ↦ extendFrom_eq (subset_closure x_in) (hf x x_in) #align extend_from_extends extendFrom_extends /-- If `f` is a function to a T₃ space `Y` which has a limit within `A` at any point of a set `B ⊆ closure A`, then `extendFrom A f` is continuous on `B`. -/ theorem continuousOn_extendFrom [RegularSpace Y] {f : X → Y} {A B : Set X} (hB : B ⊆ closure A) (hf : ∀ x ∈ B, ∃ y, Tendsto f (𝓝[A] x) (𝓝 y)) : ContinuousOn (extendFrom A f) B := by set φ := extendFrom A f intro x x_in suffices ∀ V' ∈ 𝓝 (φ x), IsClosed V' → φ ⁻¹' V' ∈ 𝓝[B] x by simpa [ContinuousWithinAt, (closed_nhds_basis (φ x)).tendsto_right_iff] intro V' V'_in V'_closed obtain ⟨V, V_in, V_op, hV⟩ : ∃ V ∈ 𝓝 x, IsOpen V ∧ V ∩ A ⊆ f ⁻¹' V' := by have := tendsto_extendFrom (hf x x_in) rcases (nhdsWithin_basis_open x A).tendsto_left_iff.mp this V' V'_in with ⟨V, ⟨hxV, V_op⟩, hV⟩ exact ⟨V, IsOpen.mem_nhds V_op hxV, V_op, hV⟩ suffices ∀ y ∈ V ∩ B, φ y ∈ V' from mem_of_superset (inter_mem_inf V_in <| mem_principal_self B) this rintro y ⟨hyV, hyB⟩ haveI := mem_closure_iff_nhdsWithin_neBot.mp (hB hyB) have limy : Tendsto f (𝓝[A] y) (𝓝 <| φ y) := tendsto_extendFrom (hf y hyB) have hVy : V ∈ 𝓝 y := IsOpen.mem_nhds V_op hyV have : V ∩ A ∈ 𝓝[A] y := by simpa only [inter_comm] using inter_mem_nhdsWithin A hVy exact V'_closed.mem_of_tendsto limy (mem_of_superset this hV) #align continuous_on_extend_from continuousOn_extendFrom /-- If a function `f` to a T₃ space `Y` has a limit within a dense set `A` for any `x`, then `extendFrom A f` is continuous. -/
Mathlib/Topology/ExtendFrom.lean
86
89
theorem continuous_extendFrom [RegularSpace Y] {f : X → Y} {A : Set X} (hA : Dense A) (hf : ∀ x, ∃ y, Tendsto f (𝓝[A] x) (𝓝 y)) : Continuous (extendFrom A f) := by
rw [continuous_iff_continuousOn_univ] exact continuousOn_extendFrom (fun x _ ↦ hA x) (by simpa using hf)
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.Algebra.Group.Invertible.Basic import Mathlib.Algebra.GroupWithZero.Units.Basic #align_import algebra.invertible from "leanprover-community/mathlib"@"722b3b152ddd5e0cf21c0a29787c76596cb6b422" /-! # Theorems about invertible elements in a `GroupWithZero` We intentionally keep imports minimal here as this file is used by `Mathlib.Tactic.NormNum`. -/ assert_not_exists DenselyOrdered universe u variable {α : Type u}
Mathlib/Algebra/GroupWithZero/Invertible.lean
23
28
theorem nonzero_of_invertible [MulZeroOneClass α] (a : α) [Nontrivial α] [Invertible a] : a ≠ 0 := fun ha => zero_ne_one <| calc 0 = ⅟ a * a := by
simp [ha] _ = 1 := invOf_mul_self a
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.MeasureTheory.Measure.Restrict /-! # Classes of measures We introduce the following typeclasses for measures: * `IsProbabilityMeasure μ`: `μ univ = 1`; * `IsFiniteMeasure μ`: `μ univ < ∞`; * `SigmaFinite μ`: there exists a countable collection of sets that cover `univ` where `μ` is finite; * `SFinite μ`: the measure `μ` can be written as a countable sum of finite measures; * `IsLocallyFiniteMeasure μ` : `∀ x, ∃ s ∈ 𝓝 x, μ s < ∞`; * `NoAtoms μ` : `∀ x, μ {x} = 0`; possibly should be redefined as `∀ s, 0 < μ s → ∃ t ⊆ s, 0 < μ t ∧ μ t < μ s`. -/ open scoped ENNReal NNReal Topology open Set MeasureTheory Measure Filter Function MeasurableSpace ENNReal variable {α β δ ι : Type*} namespace MeasureTheory variable {m0 : MeasurableSpace α} [MeasurableSpace β] {μ ν ν₁ ν₂: Measure α} {s t : Set α} section IsFiniteMeasure /-- A measure `μ` is called finite if `μ univ < ∞`. -/ class IsFiniteMeasure (μ : Measure α) : Prop where measure_univ_lt_top : μ univ < ∞ #align measure_theory.is_finite_measure MeasureTheory.IsFiniteMeasure #align measure_theory.is_finite_measure.measure_univ_lt_top MeasureTheory.IsFiniteMeasure.measure_univ_lt_top theorem not_isFiniteMeasure_iff : ¬IsFiniteMeasure μ ↔ μ Set.univ = ∞ := by refine ⟨fun h => ?_, fun h => fun h' => h'.measure_univ_lt_top.ne h⟩ by_contra h' exact h ⟨lt_top_iff_ne_top.mpr h'⟩ #align measure_theory.not_is_finite_measure_iff MeasureTheory.not_isFiniteMeasure_iff instance Restrict.isFiniteMeasure (μ : Measure α) [hs : Fact (μ s < ∞)] : IsFiniteMeasure (μ.restrict s) := ⟨by simpa using hs.elim⟩ #align measure_theory.restrict.is_finite_measure MeasureTheory.Restrict.isFiniteMeasure theorem measure_lt_top (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s < ∞ := (measure_mono (subset_univ s)).trans_lt IsFiniteMeasure.measure_univ_lt_top #align measure_theory.measure_lt_top MeasureTheory.measure_lt_top instance isFiniteMeasureRestrict (μ : Measure α) (s : Set α) [h : IsFiniteMeasure μ] : IsFiniteMeasure (μ.restrict s) := ⟨by simpa using measure_lt_top μ s⟩ #align measure_theory.is_finite_measure_restrict MeasureTheory.isFiniteMeasureRestrict theorem measure_ne_top (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s ≠ ∞ := ne_of_lt (measure_lt_top μ s) #align measure_theory.measure_ne_top MeasureTheory.measure_ne_top
Mathlib/MeasureTheory/Measure/Typeclasses.lean
65
72
theorem measure_compl_le_add_of_le_add [IsFiniteMeasure μ] (hs : MeasurableSet s) (ht : MeasurableSet t) {ε : ℝ≥0∞} (h : μ s ≤ μ t + ε) : μ tᶜ ≤ μ sᶜ + ε := by
rw [measure_compl ht (measure_ne_top μ _), measure_compl hs (measure_ne_top μ _), tsub_le_iff_right] calc μ univ = μ univ - μ s + μ s := (tsub_add_cancel_of_le <| measure_mono s.subset_univ).symm _ ≤ μ univ - μ s + (μ t + ε) := add_le_add_left h _ _ = _ := by rw [add_right_comm, add_assoc]
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Associated import Mathlib.Algebra.GeomSum import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.SMulWithZero import Mathlib.Data.Nat.Choose.Sum import Mathlib.Data.Nat.Lattice import Mathlib.RingTheory.Nilpotent.Defs #align_import ring_theory.nilpotent from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" /-! # Nilpotent elements This file develops the basic theory of nilpotent elements. In particular it shows that the nilpotent elements are closed under many operations. For the definition of `nilradical`, see `Mathlib.RingTheory.Nilpotent.Lemmas`. ## Main definitions * `isNilpotent_neg_iff` * `Commute.isNilpotent_add` * `Commute.isNilpotent_sub` -/ universe u v open Function Set variable {R S : Type*} {x y : R} theorem IsNilpotent.neg [Ring R] (h : IsNilpotent x) : IsNilpotent (-x) := by obtain ⟨n, hn⟩ := h use n rw [neg_pow, hn, mul_zero] #align is_nilpotent.neg IsNilpotent.neg @[simp] theorem isNilpotent_neg_iff [Ring R] : IsNilpotent (-x) ↔ IsNilpotent x := ⟨fun h => neg_neg x ▸ h.neg, fun h => h.neg⟩ #align is_nilpotent_neg_iff isNilpotent_neg_iff lemma IsNilpotent.smul [MonoidWithZero R] [MonoidWithZero S] [MulActionWithZero R S] [SMulCommClass R S S] [IsScalarTower R S S] {a : S} (ha : IsNilpotent a) (t : R) : IsNilpotent (t • a) := by obtain ⟨k, ha⟩ := ha use k rw [smul_pow, ha, smul_zero] theorem IsNilpotent.isUnit_sub_one [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r - 1) := by obtain ⟨n, hn⟩ := hnil refine ⟨⟨r - 1, -∑ i ∈ Finset.range n, r ^ i, ?_, ?_⟩, rfl⟩ · simp [mul_geom_sum, hn] · simp [geom_sum_mul, hn] theorem IsNilpotent.isUnit_one_sub [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (1 - r) := by rw [← IsUnit.neg_iff, neg_sub] exact isUnit_sub_one hnil theorem IsNilpotent.isUnit_add_one [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (r + 1) := by rw [← IsUnit.neg_iff, neg_add'] exact isUnit_sub_one hnil.neg theorem IsNilpotent.isUnit_one_add [Ring R] {r : R} (hnil : IsNilpotent r) : IsUnit (1 + r) := add_comm r 1 ▸ isUnit_add_one hnil theorem IsNilpotent.isUnit_add_left_of_commute [Ring R] {r u : R} (hnil : IsNilpotent r) (hu : IsUnit u) (h_comm : Commute r u) : IsUnit (u + r) := by rw [← Units.isUnit_mul_units _ hu.unit⁻¹, add_mul, IsUnit.mul_val_inv] replace h_comm : Commute r (↑hu.unit⁻¹) := Commute.units_inv_right h_comm refine IsNilpotent.isUnit_one_add ?_ exact (hu.unit⁻¹.isUnit.isNilpotent_mul_unit_of_commute_iff h_comm).mpr hnil theorem IsNilpotent.isUnit_add_right_of_commute [Ring R] {r u : R} (hnil : IsNilpotent r) (hu : IsUnit u) (h_comm : Commute r u) : IsUnit (r + u) := add_comm r u ▸ hnil.isUnit_add_left_of_commute hu h_comm instance [Zero R] [Pow R ℕ] [Zero S] [Pow S ℕ] [IsReduced R] [IsReduced S] : IsReduced (R × S) where eq_zero _ := fun ⟨n, hn⟩ ↦ have hn := Prod.ext_iff.1 hn Prod.ext (IsReduced.eq_zero _ ⟨n, hn.1⟩) (IsReduced.eq_zero _ ⟨n, hn.2⟩) theorem Prime.isRadical [CommMonoidWithZero R] {y : R} (hy : Prime y) : IsRadical y := fun _ _ ↦ hy.dvd_of_dvd_pow theorem zero_isRadical_iff [MonoidWithZero R] : IsRadical (0 : R) ↔ IsReduced R := by simp_rw [isReduced_iff, IsNilpotent, exists_imp, ← zero_dvd_iff] exact forall_swap #align zero_is_radical_iff zero_isRadical_iff
Mathlib/RingTheory/Nilpotent/Basic.lean
100
102
theorem isReduced_iff_pow_one_lt [MonoidWithZero R] (k : ℕ) (hk : 1 < k) : IsReduced R ↔ ∀ x : R, x ^ k = 0 → x = 0 := by
simp_rw [← zero_isRadical_iff, isRadical_iff_pow_one_lt k hk, zero_dvd_iff]
/- Copyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Pierre-Alexandre Bazin -/ import Mathlib.Algebra.Module.Torsion import Mathlib.RingTheory.DedekindDomain.Ideal #align_import algebra.module.dedekind_domain from "leanprover-community/mathlib"@"cdc34484a07418af43daf8198beaf5c00324bca8" /-! # Modules over a Dedekind domain Over a Dedekind domain, an `I`-torsion module is the internal direct sum of its `p i ^ e i`-torsion submodules, where `I = ∏ i, p i ^ e i` is its unique decomposition in prime ideals. Therefore, as any finitely generated torsion module is `I`-torsion for some `I`, it is an internal direct sum of its `p i ^ e i`-torsion submodules for some prime ideals `p i` and numbers `e i`. -/ universe u v variable {R : Type u} [CommRing R] [IsDomain R] {M : Type v} [AddCommGroup M] [Module R M] open scoped DirectSum namespace Submodule variable [IsDedekindDomain R] open UniqueFactorizationMonoid open scoped Classical /-- Over a Dedekind domain, an `I`-torsion module is the internal direct sum of its `p i ^ e i`- torsion submodules, where `I = ∏ i, p i ^ e i` is its unique decomposition in prime ideals. -/
Mathlib/Algebra/Module/DedekindDomain.lean
37
59
theorem isInternal_prime_power_torsion_of_is_torsion_by_ideal {I : Ideal R} (hI : I ≠ ⊥) (hM : Module.IsTorsionBySet R M I) : DirectSum.IsInternal fun p : (factors I).toFinset => torsionBySet R M (p ^ (factors I).count ↑p : Ideal R) := by
let P := factors I have prime_of_mem := fun p (hp : p ∈ P.toFinset) => prime_of_factor p (Multiset.mem_toFinset.mp hp) apply torsionBySet_isInternal (p := fun p => p ^ P.count p) _ · convert hM rw [← Finset.inf_eq_iInf, IsDedekindDomain.inf_prime_pow_eq_prod, ← Finset.prod_multiset_count, ← associated_iff_eq] · exact factors_prod hI · exact prime_of_mem · exact fun _ _ _ _ ij => ij · intro p hp q hq pq; dsimp rw [irreducible_pow_sup] · suffices (normalizedFactors _).count p = 0 by rw [this, zero_min, pow_zero, Ideal.one_eq_top] rw [Multiset.count_eq_zero, normalizedFactors_of_irreducible_pow (prime_of_mem q hq).irreducible, Multiset.mem_replicate] exact fun H => pq <| H.2.trans <| normalize_eq q · rw [← Ideal.zero_eq_bot]; apply pow_ne_zero; exact (prime_of_mem q hq).ne_zero · exact (prime_of_mem p hp).irreducible
/- 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.LinearAlgebra.Basis.VectorSpace import Mathlib.LinearAlgebra.Dimension.Constructions import Mathlib.LinearAlgebra.Dimension.Finite #align_import field_theory.finiteness from "leanprover-community/mathlib"@"039a089d2a4b93c761b234f3e5f5aeb752bac60f" /-! # A module over a division ring is noetherian if and only if it is finite. -/ universe u v open scoped Classical open Cardinal open Cardinal Submodule Module Function namespace IsNoetherian variable {K : Type u} {V : Type v} [DivisionRing K] [AddCommGroup V] [Module K V] /-- A module over a division ring is noetherian if and only if its dimension (as a cardinal) is strictly less than the first infinite cardinal `ℵ₀`. -/
Mathlib/FieldTheory/Finiteness.lean
32
43
theorem iff_rank_lt_aleph0 : IsNoetherian K V ↔ Module.rank K V < ℵ₀ := by
let b := Basis.ofVectorSpace K V rw [← b.mk_eq_rank'', lt_aleph0_iff_set_finite] constructor · intro exact (Basis.ofVectorSpaceIndex.linearIndependent K V).set_finite_of_isNoetherian · intro hbfinite refine @isNoetherian_of_linearEquiv K (⊤ : Submodule K V) V _ _ _ _ _ (LinearEquiv.ofTop _ rfl) (id ?_) refine isNoetherian_of_fg_of_noetherian _ ⟨Set.Finite.toFinset hbfinite, ?_⟩ rw [Set.Finite.coe_toFinset, ← b.span_eq, Basis.coe_ofVectorSpace, Subtype.range_coe]
/- Copyright (c) 2022 Eric Rodriguez. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Rodriguez -/ import Mathlib.Algebra.Field.ULift import Mathlib.Algebra.MvPolynomial.Cardinal import Mathlib.Data.Nat.Factorization.PrimePow import Mathlib.Data.Rat.Denumerable import Mathlib.FieldTheory.Finite.GaloisField import Mathlib.Logic.Equiv.TransferInstance import Mathlib.RingTheory.Localization.Cardinality import Mathlib.SetTheory.Cardinal.Divisibility #align_import field_theory.cardinality from "leanprover-community/mathlib"@"0723536a0522d24fc2f159a096fb3304bef77472" /-! # Cardinality of Fields In this file we show all the possible cardinalities of fields. All infinite cardinals can harbour a field structure, and so can all types with prime power cardinalities, and this is sharp. ## Main statements * `Fintype.nonempty_field_iff`: A `Fintype` can be given a field structure iff its cardinality is a prime power. * `Infinite.nonempty_field` : Any infinite type can be endowed a field structure. * `Field.nonempty_iff` : There is a field structure on type iff its cardinality is a prime power. -/ local notation "‖" x "‖" => Fintype.card x open scoped Cardinal nonZeroDivisors universe u /-- A finite field has prime power cardinality. -/
Mathlib/FieldTheory/Cardinality.lean
40
49
theorem Fintype.isPrimePow_card_of_field {α} [Fintype α] [Field α] : IsPrimePow ‖α‖ := by
-- TODO: `Algebra` version of `CharP.exists`, of type `∀ p, Algebra (ZMod p) α` cases' CharP.exists α with p _ haveI hp := Fact.mk (CharP.char_is_prime α p) letI : Algebra (ZMod p) α := ZMod.algebra _ _ let b := IsNoetherian.finsetBasis (ZMod p) α rw [Module.card_fintype b, ZMod.card, isPrimePow_pow_iff] · exact hp.1.isPrimePow rw [← FiniteDimensional.finrank_eq_card_basis b] exact FiniteDimensional.finrank_pos.ne'
/- 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.Expand import Mathlib.FieldTheory.Finite.Basic import Mathlib.RingTheory.MvPolynomial.Basic #align_import field_theory.finite.polynomial from "leanprover-community/mathlib"@"5aa3c1de9f3c642eac76e11071c852766f220fd0" /-! ## Polynomials over finite fields -/ namespace MvPolynomial variable {σ : Type*} /-- A polynomial over the integers is divisible by `n : ℕ` if and only if it is zero over `ZMod n`. -/ theorem C_dvd_iff_zmod (n : ℕ) (φ : MvPolynomial σ ℤ) : C (n : ℤ) ∣ φ ↔ map (Int.castRingHom (ZMod n)) φ = 0 := C_dvd_iff_map_hom_eq_zero _ _ (CharP.intCast_eq_zero_iff (ZMod n) n) _ set_option linter.uppercaseLean3 false in #align mv_polynomial.C_dvd_iff_zmod MvPolynomial.C_dvd_iff_zmod section frobenius variable {p : ℕ} [Fact p.Prime]
Mathlib/FieldTheory/Finite/Polynomial.lean
33
38
theorem frobenius_zmod (f : MvPolynomial σ (ZMod p)) : frobenius _ p f = expand p f := by
apply induction_on f · intro a; rw [expand_C, frobenius_def, ← C_pow, ZMod.pow_card] · simp only [AlgHom.map_add, RingHom.map_add]; intro _ _ hf hg; rw [hf, hg] · simp only [expand_X, RingHom.map_mul, AlgHom.map_mul] intro _ _ hf; rw [hf, frobenius_def]
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Scott Morrison, Adam Topaz -/ import Mathlib.AlgebraicTopology.SimplexCategory import Mathlib.CategoryTheory.Comma.Arrow import Mathlib.CategoryTheory.Limits.FunctorCategory import Mathlib.CategoryTheory.Opposites #align_import algebraic_topology.simplicial_object from "leanprover-community/mathlib"@"5ed51dc37c6b891b79314ee11a50adc2b1df6fd6" /-! # Simplicial objects in a category. A simplicial object in a category `C` is a `C`-valued presheaf on `SimplexCategory`. (Similarly a cosimplicial object is functor `SimplexCategory ⥤ C`.) Use the notation `X _[n]` in the `Simplicial` locale to obtain the `n`-th term of a (co)simplicial object `X`, where `n` is a natural number. -/ open Opposite open CategoryTheory open CategoryTheory.Limits universe v u v' u' namespace CategoryTheory variable (C : Type u) [Category.{v} C] -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- The category of simplicial objects valued in a category `C`. This is the category of contravariant functors from `SimplexCategory` to `C`. -/ def SimplicialObject := SimplexCategoryᵒᵖ ⥤ C #align category_theory.simplicial_object CategoryTheory.SimplicialObject @[simps!] instance : Category (SimplicialObject C) := by dsimp only [SimplicialObject] infer_instance namespace SimplicialObject set_option quotPrecheck false in /-- `X _[n]` denotes the `n`th-term of the simplicial object X -/ scoped[Simplicial] notation3:1000 X " _[" n "]" => (X : CategoryTheory.SimplicialObject _).obj (Opposite.op (SimplexCategory.mk n)) open Simplicial instance {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] : HasLimitsOfShape J (SimplicialObject C) := by dsimp [SimplicialObject] infer_instance instance [HasLimits C] : HasLimits (SimplicialObject C) := ⟨inferInstance⟩ instance {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] : HasColimitsOfShape J (SimplicialObject C) := by dsimp [SimplicialObject] infer_instance instance [HasColimits C] : HasColimits (SimplicialObject C) := ⟨inferInstance⟩ variable {C} -- Porting note (#10688): added to ease automation @[ext] lemma hom_ext {X Y : SimplicialObject C} (f g : X ⟶ Y) (h : ∀ (n : SimplexCategoryᵒᵖ), f.app n = g.app n) : f = g := NatTrans.ext _ _ (by ext; apply h) variable (X : SimplicialObject C) /-- Face maps for a simplicial object. -/ def δ {n} (i : Fin (n + 2)) : X _[n + 1] ⟶ X _[n] := X.map (SimplexCategory.δ i).op #align category_theory.simplicial_object.δ CategoryTheory.SimplicialObject.δ /-- Degeneracy maps for a simplicial object. -/ def σ {n} (i : Fin (n + 1)) : X _[n] ⟶ X _[n + 1] := X.map (SimplexCategory.σ i).op #align category_theory.simplicial_object.σ CategoryTheory.SimplicialObject.σ /-- Isomorphisms from identities in ℕ. -/ def eqToIso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] := X.mapIso (CategoryTheory.eqToIso (by congr)) #align category_theory.simplicial_object.eq_to_iso CategoryTheory.SimplicialObject.eqToIso @[simp] theorem eqToIso_refl {n : ℕ} (h : n = n) : X.eqToIso h = Iso.refl _ := by ext simp [eqToIso] #align category_theory.simplicial_object.eq_to_iso_refl CategoryTheory.SimplicialObject.eqToIso_refl /-- The generic case of the first simplicial identity -/ @[reassoc]
Mathlib/AlgebraicTopology/SimplicialObject.lean
107
110
theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) : X.δ j.succ ≫ X.δ i = X.δ (Fin.castSucc i) ≫ X.δ j := by
dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ 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.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # List of booleans In this file we prove lemmas about the number of `false`s and `true`s in a list of booleans. First we prove that the number of `false`s plus the number of `true` equals the length of the list. Then we prove that in a list with alternating `true`s and `false`s, the number of `true`s differs from the number of `false`s by at most one. We provide several versions of these statements. -/ namespace List @[simp] theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by -- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl #align list.count_bnot_add_count List.count_not_add_count @[simp]
Mathlib/Data/Bool/Count.lean
33
34
theorem count_add_count_not (l : List Bool) (b : Bool) : count b l + count (!b) l = length l := by
rw [add_comm, count_not_add_count]
/- Copyright (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura -/ import Mathlib.Init.Order.Defs #align_import init.algebra.functions from "leanprover-community/lean"@"c2bcdbcbe741ed37c361a30d38e179182b989f76" /-! # Basic lemmas about linear orders. The contents of this file came from `init.algebra.functions` in Lean 3, and it would be good to find everything a better home. -/ universe u section open Decidable variable {α : Type u} [LinearOrder α] theorem min_def (a b : α) : min a b = if a ≤ b then a else b := by rw [LinearOrder.min_def a] #align min_def min_def theorem max_def (a b : α) : max a b = if a ≤ b then b else a := by rw [LinearOrder.max_def a] #align max_def max_def theorem min_le_left (a b : α) : min a b ≤ a := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h, le_refl] else simp [min_def, if_neg h]; exact le_of_not_le h #align min_le_left min_le_left theorem min_le_right (a b : α) : min a b ≤ b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h]; exact h else simp [min_def, if_neg h, le_refl] #align min_le_right min_le_right theorem le_min {a b c : α} (h₁ : c ≤ a) (h₂ : c ≤ b) : c ≤ min a b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h]; exact h₁ else simp [min_def, if_neg h]; exact h₂ #align le_min le_min theorem le_max_left (a b : α) : a ≤ max a b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [max_def, if_pos h]; exact h else simp [max_def, if_neg h, le_refl] #align le_max_left le_max_left theorem le_max_right (a b : α) : b ≤ max a b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [max_def, if_pos h, le_refl] else simp [max_def, if_neg h]; exact le_of_not_le h #align le_max_right le_max_right theorem max_le {a b c : α} (h₁ : a ≤ c) (h₂ : b ≤ c) : max a b ≤ c := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [max_def, if_pos h]; exact h₂ else simp [max_def, if_neg h]; exact h₁ #align max_le max_le theorem eq_min {a b c : α} (h₁ : c ≤ a) (h₂ : c ≤ b) (h₃ : ∀ {d}, d ≤ a → d ≤ b → d ≤ c) : c = min a b := le_antisymm (le_min h₁ h₂) (h₃ (min_le_left a b) (min_le_right a b)) #align eq_min eq_min theorem min_comm (a b : α) : min a b = min b a := eq_min (min_le_right a b) (min_le_left a b) fun h₁ h₂ => le_min h₂ h₁ #align min_comm min_comm theorem min_assoc (a b c : α) : min (min a b) c = min a (min b c) := by apply eq_min · apply le_trans; apply min_le_left; apply min_le_left · apply le_min; apply le_trans; apply min_le_left; apply min_le_right; apply min_le_right · intro d h₁ h₂; apply le_min; apply le_min h₁; apply le_trans h₂; apply min_le_left apply le_trans h₂; apply min_le_right #align min_assoc min_assoc theorem min_left_comm : ∀ a b c : α, min a (min b c) = min b (min a c) := left_comm (@min α _) (@min_comm α _) (@min_assoc α _) #align min_left_comm min_left_comm @[simp] theorem min_self (a : α) : min a a = a := by simp [min_def] #align min_self min_self theorem min_eq_left {a b : α} (h : a ≤ b) : min a b = a := by apply Eq.symm; apply eq_min (le_refl _) h; intros; assumption #align min_eq_left min_eq_left theorem min_eq_right {a b : α} (h : b ≤ a) : min a b = b := min_comm b a ▸ min_eq_left h #align min_eq_right min_eq_right theorem eq_max {a b c : α} (h₁ : a ≤ c) (h₂ : b ≤ c) (h₃ : ∀ {d}, a ≤ d → b ≤ d → c ≤ d) : c = max a b := le_antisymm (h₃ (le_max_left a b) (le_max_right a b)) (max_le h₁ h₂) #align eq_max eq_max theorem max_comm (a b : α) : max a b = max b a := eq_max (le_max_right a b) (le_max_left a b) fun h₁ h₂ => max_le h₂ h₁ #align max_comm max_comm
Mathlib/Init/Order/LinearOrder.lean
117
122
theorem max_assoc (a b c : α) : max (max a b) c = max a (max b c) := by
apply eq_max · apply le_trans; apply le_max_left a b; apply le_max_left · apply max_le; apply le_trans; apply le_max_right a b; apply le_max_left; apply le_max_right · intro d h₁ h₂; apply max_le; apply max_le h₁; apply le_trans (le_max_left _ _) h₂ apply le_trans (le_max_right _ _) h₂
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl -/ import Mathlib.Algebra.CharZero.Defs import Mathlib.Algebra.Group.Hom.Defs import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Algebra.Order.Monoid.OrderDual import Mathlib.Algebra.Order.ZeroLEOne import Mathlib.Data.Nat.Cast.Defs import Mathlib.Order.WithBot #align_import algebra.order.monoid.with_top from "leanprover-community/mathlib"@"0111834459f5d7400215223ea95ae38a1265a907" /-! # Adjoining top/bottom elements to ordered monoids. -/ universe u v variable {α : Type u} {β : Type v} open Function namespace WithTop section One variable [One α] {a : α} @[to_additive] instance one : One (WithTop α) := ⟨(1 : α)⟩ #align with_top.has_one WithTop.one #align with_top.has_zero WithTop.zero @[to_additive (attr := simp, norm_cast)] theorem coe_one : ((1 : α) : WithTop α) = 1 := rfl #align with_top.coe_one WithTop.coe_one #align with_top.coe_zero WithTop.coe_zero @[to_additive (attr := simp, norm_cast)] lemma coe_eq_one : (a : WithTop α) = 1 ↔ a = 1 := coe_eq_coe #align with_top.coe_eq_one WithTop.coe_eq_one #align with_top.coe_eq_zero WithTop.coe_eq_zero @[to_additive (attr := simp, norm_cast)] lemma one_eq_coe : 1 = (a : WithTop α) ↔ a = 1 := eq_comm.trans coe_eq_one #align with_top.one_eq_coe WithTop.one_eq_coe #align with_top.zero_eq_coe WithTop.zero_eq_coe @[to_additive (attr := simp)] lemma top_ne_one : (⊤ : WithTop α) ≠ 1 := top_ne_coe #align with_top.top_ne_one WithTop.top_ne_one #align with_top.top_ne_zero WithTop.top_ne_zero @[to_additive (attr := simp)] lemma one_ne_top : (1 : WithTop α) ≠ ⊤ := coe_ne_top #align with_top.one_ne_top WithTop.one_ne_top #align with_top.zero_ne_top WithTop.zero_ne_top @[to_additive (attr := simp)] theorem untop_one : (1 : WithTop α).untop coe_ne_top = 1 := rfl #align with_top.untop_one WithTop.untop_one #align with_top.untop_zero WithTop.untop_zero @[to_additive (attr := simp)] theorem untop_one' (d : α) : (1 : WithTop α).untop' d = 1 := rfl #align with_top.untop_one' WithTop.untop_one' #align with_top.untop_zero' WithTop.untop_zero' @[to_additive (attr := simp, norm_cast) coe_nonneg] theorem one_le_coe [LE α] {a : α} : 1 ≤ (a : WithTop α) ↔ 1 ≤ a := coe_le_coe #align with_top.one_le_coe WithTop.one_le_coe #align with_top.coe_nonneg WithTop.coe_nonneg @[to_additive (attr := simp, norm_cast) coe_le_zero] theorem coe_le_one [LE α] {a : α} : (a : WithTop α) ≤ 1 ↔ a ≤ 1 := coe_le_coe #align with_top.coe_le_one WithTop.coe_le_one #align with_top.coe_le_zero WithTop.coe_le_zero @[to_additive (attr := simp, norm_cast) coe_pos] theorem one_lt_coe [LT α] {a : α} : 1 < (a : WithTop α) ↔ 1 < a := coe_lt_coe #align with_top.one_lt_coe WithTop.one_lt_coe #align with_top.coe_pos WithTop.coe_pos @[to_additive (attr := simp, norm_cast) coe_lt_zero] theorem coe_lt_one [LT α] {a : α} : (a : WithTop α) < 1 ↔ a < 1 := coe_lt_coe #align with_top.coe_lt_one WithTop.coe_lt_one #align with_top.coe_lt_zero WithTop.coe_lt_zero @[to_additive (attr := simp)] protected theorem map_one {β} (f : α → β) : (1 : WithTop α).map f = (f 1 : WithTop β) := rfl #align with_top.map_one WithTop.map_one #align with_top.map_zero WithTop.map_zero instance zeroLEOneClass [Zero α] [LE α] [ZeroLEOneClass α] : ZeroLEOneClass (WithTop α) := ⟨coe_le_coe.2 zero_le_one⟩ end One section Add variable [Add α] {a b c d : WithTop α} {x y : α} instance add : Add (WithTop α) := ⟨Option.map₂ (· + ·)⟩ #align with_top.has_add WithTop.add @[simp, norm_cast] lemma coe_add (a b : α) : ↑(a + b) = (a + b : WithTop α) := rfl #align with_top.coe_add WithTop.coe_add #noalign with_top.coe_bit0 #noalign with_top.coe_bit1 @[simp] theorem top_add (a : WithTop α) : ⊤ + a = ⊤ := rfl #align with_top.top_add WithTop.top_add @[simp] theorem add_top (a : WithTop α) : a + ⊤ = ⊤ := by cases a <;> rfl #align with_top.add_top WithTop.add_top @[simp]
Mathlib/Algebra/Order/Monoid/WithTop.lean
132
136
theorem add_eq_top : a + b = ⊤ ↔ a = ⊤ ∨ b = ⊤ := by
match a, b with | ⊤, _ => simp | _, ⊤ => simp | (a : α), (b : α) => simp only [← coe_add, coe_ne_top, or_false]
/- 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.Ring.Defs import Mathlib.Algebra.Group.Int import Mathlib.Data.Nat.Dist import Mathlib.Data.Ordmap.Ordnode import Mathlib.Tactic.Abel import Mathlib.Tactic.Linarith #align_import data.ordmap.ordset from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69" /-! # Verification of the `Ordnode α` datatype This file proves the correctness of the operations in `Data.Ordmap.Ordnode`. The public facing version is the type `Ordset α`, which is a wrapper around `Ordnode α` which includes the correctness invariant of the type, and it exposes parallel operations like `insert` as functions on `Ordset` that do the same thing but bundle the correctness proofs. The advantage is that it is possible to, for example, prove that the result of `find` on `insert` will actually find the element, while `Ordnode` cannot guarantee this if the input tree did not satisfy the type invariants. ## Main definitions * `Ordset α`: A well formed set of values of type `α` ## Implementation notes The majority of this file is actually in the `Ordnode` namespace, because we first have to prove the correctness of all the operations (and defining what correctness means here is actually somewhat subtle). So all the actual `Ordset` operations are at the very end, once we have all the theorems. An `Ordnode α` is an inductive type which describes a tree which stores the `size` at internal nodes. The correctness invariant of an `Ordnode α` is: * `Ordnode.Sized t`: All internal `size` fields must match the actual measured size of the tree. (This is not hard to satisfy.) * `Ordnode.Balanced t`: Unless the tree has the form `()` or `((a) b)` or `(a (b))` (that is, nil or a single singleton subtree), the two subtrees must satisfy `size l ≤ δ * size r` and `size r ≤ δ * size l`, where `δ := 3` is a global parameter of the data structure (and this property must hold recursively at subtrees). This is why we say this is a "size balanced tree" data structure. * `Ordnode.Bounded lo hi t`: The members of the tree must be in strictly increasing order, meaning that if `a` is in the left subtree and `b` is the root, then `a ≤ b` and `¬ (b ≤ a)`. We enforce this using `Ordnode.Bounded` which includes also a global upper and lower bound. Because the `Ordnode` file was ported from Haskell, the correctness invariants of some of the functions have not been spelled out, and some theorems like `Ordnode.Valid'.balanceL_aux` show very intricate assumptions on the sizes, which may need to be revised if it turns out some operations violate these assumptions, because there is a decent amount of slop in the actual data structure invariants, so the theorem will go through with multiple choices of assumption. **Note:** This file is incomplete, in the sense that the intent is to have verified versions and lemmas about all the definitions in `Ordnode.lean`, but at the moment only a few operations are verified (the hard part should be out of the way, but still). Contributors are encouraged to pick this up and finish the job, if it appeals to you. ## Tags ordered map, ordered set, data structure, verified programming -/ variable {α : Type*} namespace Ordnode /-! ### delta and ratio -/ theorem not_le_delta {s} (H : 1 ≤ s) : ¬s ≤ delta * 0 := not_le_of_gt H #align ordnode.not_le_delta Ordnode.not_le_delta theorem delta_lt_false {a b : ℕ} (h₁ : delta * a < b) (h₂ : delta * b < a) : False := not_le_of_lt (lt_trans ((mul_lt_mul_left (by decide)).2 h₁) h₂) <| by simpa [mul_assoc] using Nat.mul_le_mul_right a (by decide : 1 ≤ delta * delta) #align ordnode.delta_lt_false Ordnode.delta_lt_false /-! ### `singleton` -/ /-! ### `size` and `empty` -/ /-- O(n). Computes the actual number of elements in the set, ignoring the cached `size` field. -/ def realSize : Ordnode α → ℕ | nil => 0 | node _ l _ r => realSize l + realSize r + 1 #align ordnode.real_size Ordnode.realSize /-! ### `Sized` -/ /-- The `Sized` property asserts that all the `size` fields in nodes match the actual size of the respective subtrees. -/ def Sized : Ordnode α → Prop | nil => True | node s l _ r => s = size l + size r + 1 ∧ Sized l ∧ Sized r #align ordnode.sized Ordnode.Sized theorem Sized.node' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (node' l x r) := ⟨rfl, hl, hr⟩ #align ordnode.sized.node' Ordnode.Sized.node' theorem Sized.eq_node' {s l x r} (h : @Sized α (node s l x r)) : node s l x r = .node' l x r := by rw [h.1] #align ordnode.sized.eq_node' Ordnode.Sized.eq_node' theorem Sized.size_eq {s l x r} (H : Sized (@node α s l x r)) : size (@node α s l x r) = size l + size r + 1 := H.1 #align ordnode.sized.size_eq Ordnode.Sized.size_eq @[elab_as_elim] theorem Sized.induction {t} (hl : @Sized α t) {C : Ordnode α → Prop} (H0 : C nil) (H1 : ∀ l x r, C l → C r → C (.node' l x r)) : C t := by induction t with | nil => exact H0 | node _ _ _ _ t_ih_l t_ih_r => rw [hl.eq_node'] exact H1 _ _ _ (t_ih_l hl.2.1) (t_ih_r hl.2.2) #align ordnode.sized.induction Ordnode.Sized.induction theorem size_eq_realSize : ∀ {t : Ordnode α}, Sized t → size t = realSize t | nil, _ => rfl | node s l x r, ⟨h₁, h₂, h₃⟩ => by rw [size, h₁, size_eq_realSize h₂, size_eq_realSize h₃]; rfl #align ordnode.size_eq_real_size Ordnode.size_eq_realSize @[simp]
Mathlib/Data/Ordmap/Ordset.lean
140
141
theorem Sized.size_eq_zero {t : Ordnode α} (ht : Sized t) : size t = 0 ↔ t = nil := by
cases t <;> [simp;simp [ht.1]]
/- Copyright (c) 2023 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Joseph Myers -/ import Mathlib.Analysis.InnerProductSpace.Orthogonal import Mathlib.Analysis.Normed.Group.AddTorsor #align_import geometry.euclidean.basic from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" /-! # Perpendicular bisector of a segment We define `AffineSubspace.perpBisector p₁ p₂` to be the perpendicular bisector of the segment `[p₁, p₂]`, as a bundled affine subspace. We also prove that a point belongs to the perpendicular bisector if and only if it is equidistant from `p₁` and `p₂`, as well as a few linear equations that define this subspace. ## Keywords euclidean geometry, perpendicular, perpendicular bisector, line segment bisector, equidistant -/ open Set open scoped RealInnerProductSpace variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] variable [NormedAddTorsor V P] noncomputable section namespace AffineSubspace variable {c c₁ c₂ p₁ p₂ : P} /-- Perpendicular bisector of a segment in a Euclidean affine space. -/ def perpBisector (p₁ p₂ : P) : AffineSubspace ℝ P := .comap ((AffineEquiv.vaddConst ℝ (midpoint ℝ p₁ p₂)).symm : P →ᵃ[ℝ] V) <| (LinearMap.ker (innerₛₗ ℝ (p₂ -ᵥ p₁))).toAffineSubspace /-- A point `c` belongs the perpendicular bisector of `[p₁, p₂] iff `p₂ -ᵥ p₁` is orthogonal to `c -ᵥ midpoint ℝ p₁ p₂`. -/ theorem mem_perpBisector_iff_inner_eq_zero' : c ∈ perpBisector p₁ p₂ ↔ ⟪p₂ -ᵥ p₁, c -ᵥ midpoint ℝ p₁ p₂⟫ = 0 := Iff.rfl /-- A point `c` belongs the perpendicular bisector of `[p₁, p₂] iff `c -ᵥ midpoint ℝ p₁ p₂` is orthogonal to `p₂ -ᵥ p₁`. -/ theorem mem_perpBisector_iff_inner_eq_zero : c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ midpoint ℝ p₁ p₂, p₂ -ᵥ p₁⟫ = 0 := inner_eq_zero_symm theorem mem_perpBisector_iff_inner_pointReflection_vsub_eq_zero : c ∈ perpBisector p₁ p₂ ↔ ⟪Equiv.pointReflection c p₁ -ᵥ p₂, p₂ -ᵥ p₁⟫ = 0 := by rw [mem_perpBisector_iff_inner_eq_zero, Equiv.pointReflection_apply, vsub_midpoint, invOf_eq_inv, ← smul_add, real_inner_smul_left, vadd_vsub_assoc] simp theorem mem_perpBisector_pointReflection_iff_inner_eq_zero : c ∈ perpBisector p₁ (Equiv.pointReflection p₂ p₁) ↔ ⟪c -ᵥ p₂, p₁ -ᵥ p₂⟫ = 0 := by rw [mem_perpBisector_iff_inner_eq_zero, midpoint_pointReflection_right, Equiv.pointReflection_apply, vadd_vsub_assoc, inner_add_right, add_self_eq_zero, ← neg_eq_zero, ← inner_neg_right, neg_vsub_eq_vsub_rev] theorem midpoint_mem_perpBisector (p₁ p₂ : P) : midpoint ℝ p₁ p₂ ∈ perpBisector p₁ p₂ := by simp [mem_perpBisector_iff_inner_eq_zero] theorem perpBisector_nonempty : (perpBisector p₁ p₂ : Set P).Nonempty := ⟨_, midpoint_mem_perpBisector _ _⟩ @[simp] theorem direction_perpBisector (p₁ p₂ : P) : (perpBisector p₁ p₂).direction = (ℝ ∙ (p₂ -ᵥ p₁))ᗮ := by erw [perpBisector, comap_symm, map_direction, Submodule.map_id, Submodule.toAffineSubspace_direction] ext x exact Submodule.mem_orthogonal_singleton_iff_inner_right.symm theorem mem_perpBisector_iff_inner_eq_inner : c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ p₁, p₂ -ᵥ p₁⟫ = ⟪c -ᵥ p₂, p₁ -ᵥ p₂⟫ := by rw [Iff.comm, mem_perpBisector_iff_inner_eq_zero, ← add_neg_eq_zero, ← inner_neg_right, neg_vsub_eq_vsub_rev, ← inner_add_left, vsub_midpoint, invOf_eq_inv, ← smul_add, real_inner_smul_left]; simp theorem mem_perpBisector_iff_inner_eq : c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ p₁, p₂ -ᵥ p₁⟫ = (dist p₁ p₂) ^ 2 / 2 := by rw [mem_perpBisector_iff_inner_eq_zero, ← vsub_sub_vsub_cancel_right _ _ p₁, inner_sub_left, sub_eq_zero, midpoint_vsub_left, invOf_eq_inv, real_inner_smul_left, real_inner_self_eq_norm_sq, dist_eq_norm_vsub' V, div_eq_inv_mul] theorem mem_perpBisector_iff_dist_eq : c ∈ perpBisector p₁ p₂ ↔ dist c p₁ = dist c p₂ := by rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, ← real_inner_add_sub_eq_zero_iff, vsub_sub_vsub_cancel_left, inner_add_left, add_eq_zero_iff_eq_neg, ← inner_neg_right, neg_vsub_eq_vsub_rev, mem_perpBisector_iff_inner_eq_inner] theorem mem_perpBisector_iff_dist_eq' : c ∈ perpBisector p₁ p₂ ↔ dist p₁ c = dist p₂ c := by simp only [mem_perpBisector_iff_dist_eq, dist_comm]
Mathlib/Geometry/Euclidean/PerpBisector.lean
100
101
theorem perpBisector_comm (p₁ p₂ : P) : perpBisector p₁ p₂ = perpBisector p₂ p₁ := by
ext c; simp only [mem_perpBisector_iff_dist_eq, eq_comm]
/- Copyright (c) 2022 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey, Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne -/ import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Data.Int.Log #align_import analysis.special_functions.log.base from "leanprover-community/mathlib"@"f23a09ce6d3f367220dc3cecad6b7eb69eb01690" /-! # Real logarithm base `b` In this file we define `Real.logb` to be the logarithm of a real number in a given base `b`. We define this as the division of the natural logarithms of the argument and the base, so that we have a globally defined function with `logb b 0 = 0`, `logb b (-x) = logb b x` `logb 0 x = 0` and `logb (-b) x = logb b x`. We prove some basic properties of this function and its relation to `rpow`. ## Tags logarithm, continuity -/ open Set Filter Function open Topology noncomputable section namespace Real variable {b x y : ℝ} /-- The real logarithm in a given base. As with the natural logarithm, we define `logb b x` to be `logb b |x|` for `x < 0`, and `0` for `x = 0`. -/ -- @[pp_nodot] -- Porting note: removed noncomputable def logb (b x : ℝ) : ℝ := log x / log b #align real.logb Real.logb theorem log_div_log : log x / log b = logb b x := rfl #align real.log_div_log Real.log_div_log @[simp] theorem logb_zero : logb b 0 = 0 := by simp [logb] #align real.logb_zero Real.logb_zero @[simp] theorem logb_one : logb b 1 = 0 := by simp [logb] #align real.logb_one Real.logb_one @[simp] lemma logb_self_eq_one (hb : 1 < b) : logb b b = 1 := div_self (log_pos hb).ne' lemma logb_self_eq_one_iff : logb b b = 1 ↔ b ≠ 0 ∧ b ≠ 1 ∧ b ≠ -1 := Iff.trans ⟨fun h h' => by simp [logb, h'] at h, div_self⟩ log_ne_zero @[simp] theorem logb_abs (x : ℝ) : logb b |x| = logb b x := by rw [logb, logb, log_abs] #align real.logb_abs Real.logb_abs @[simp] theorem logb_neg_eq_logb (x : ℝ) : logb b (-x) = logb b x := by rw [← logb_abs x, ← logb_abs (-x), abs_neg] #align real.logb_neg_eq_logb Real.logb_neg_eq_logb theorem logb_mul (hx : x ≠ 0) (hy : y ≠ 0) : logb b (x * y) = logb b x + logb b y := by simp_rw [logb, log_mul hx hy, add_div] #align real.logb_mul Real.logb_mul theorem logb_div (hx : x ≠ 0) (hy : y ≠ 0) : logb b (x / y) = logb b x - logb b y := by simp_rw [logb, log_div hx hy, sub_div] #align real.logb_div Real.logb_div @[simp] theorem logb_inv (x : ℝ) : logb b x⁻¹ = -logb b x := by simp [logb, neg_div] #align real.logb_inv Real.logb_inv
Mathlib/Analysis/SpecialFunctions/Log/Base.lean
84
84
theorem inv_logb (a b : ℝ) : (logb a b)⁻¹ = logb b a := by
simp_rw [logb, inv_div]
/- 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.Homotopies import Mathlib.Tactic.Ring #align_import algebraic_topology.dold_kan.faces from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" /-! # Study of face maps for the Dold-Kan correspondence In this file, we obtain the technical lemmas that are used in the file `Projections.lean` in order to get basic properties of the endomorphisms `P q : K[X] ⟶ K[X]` with respect to face maps (see `Homotopies.lean` for the role of these endomorphisms in the overall strategy of proof). The main lemma in this file is `HigherFacesVanish.induction`. It is based on two technical lemmas `HigherFacesVanish.comp_Hσ_eq` and `HigherFacesVanish.comp_Hσ_eq_zero`. (See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.) -/ open CategoryTheory CategoryTheory.Limits CategoryTheory.Category CategoryTheory.Preadditive CategoryTheory.SimplicialObject Simplicial namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] variable {X : SimplicialObject C} /-- A morphism `φ : Y ⟶ X _[n+1]` satisfies `HigherFacesVanish q φ` when the compositions `φ ≫ X.δ j` are `0` for `j ≥ max 1 (n+2-q)`. When `q ≤ n+1`, it basically means that the composition `φ ≫ X.δ j` are `0` for the `q` highest possible values of a nonzero `j`. Otherwise, when `q ≥ n+2`, all the compositions `φ ≫ X.δ j` for nonzero `j` vanish. See also the lemma `comp_P_eq_self_iff` in `Projections.lean` which states that `HigherFacesVanish q φ` is equivalent to the identity `φ ≫ (P q).f (n+1) = φ`. -/ def HigherFacesVanish {Y : C} {n : ℕ} (q : ℕ) (φ : Y ⟶ X _[n + 1]) : Prop := ∀ j : Fin (n + 1), n + 1 ≤ (j : ℕ) + q → φ ≫ X.δ j.succ = 0 #align algebraic_topology.dold_kan.higher_faces_vanish AlgebraicTopology.DoldKan.HigherFacesVanish namespace HigherFacesVanish @[reassoc]
Mathlib/AlgebraicTopology/DoldKan/Faces.lean
53
58
theorem comp_δ_eq_zero {Y : C} {n : ℕ} {q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish q φ) (j : Fin (n + 2)) (hj₁ : j ≠ 0) (hj₂ : n + 2 ≤ (j : ℕ) + q) : φ ≫ X.δ j = 0 := by
obtain ⟨i, rfl⟩ := Fin.eq_succ_of_ne_zero hj₁ apply v i simp only [Fin.val_succ] at hj₂ omega
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen -/ import Mathlib.GroupTheory.Submonoid.Inverses import Mathlib.RingTheory.FiniteType import Mathlib.RingTheory.Localization.Basic #align_import ring_theory.localization.inv_submonoid from "leanprover-community/mathlib"@"6e7ca692c98bbf8a64868f61a67fb9c33b10770d" /-! # Submonoid of inverses ## Main definitions * `IsLocalization.invSubmonoid M S` is the submonoid of `S = M⁻¹R` consisting of inverses of each element `x ∈ M` ## Implementation notes See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview. ## Tags localization, ring localization, commutative ring localization, characteristic predicate, commutative ring, field of fractions -/ variable {R : Type*} [CommRing R] (M : Submonoid R) (S : Type*) [CommRing S] variable [Algebra R S] {P : Type*} [CommRing P] open Function namespace IsLocalization section InvSubmonoid /-- The submonoid of `S = M⁻¹R` consisting of `{ 1 / x | x ∈ M }`. -/ def invSubmonoid : Submonoid S := (M.map (algebraMap R S)).leftInv #align is_localization.inv_submonoid IsLocalization.invSubmonoid variable [IsLocalization M S] theorem submonoid_map_le_is_unit : M.map (algebraMap R S) ≤ IsUnit.submonoid S := by rintro _ ⟨a, ha, rfl⟩ exact IsLocalization.map_units S ⟨_, ha⟩ #align is_localization.submonoid_map_le_is_unit IsLocalization.submonoid_map_le_is_unit /-- There is an equivalence of monoids between the image of `M` and `invSubmonoid`. -/ noncomputable abbrev equivInvSubmonoid : M.map (algebraMap R S) ≃* invSubmonoid M S := ((M.map (algebraMap R S)).leftInvEquiv (submonoid_map_le_is_unit M S)).symm #align is_localization.equiv_inv_submonoid IsLocalization.equivInvSubmonoid /-- There is a canonical map from `M` to `invSubmonoid` sending `x` to `1 / x`. -/ noncomputable def toInvSubmonoid : M →* invSubmonoid M S := (equivInvSubmonoid M S).toMonoidHom.comp ((algebraMap R S : R →* S).submonoidMap M) #align is_localization.to_inv_submonoid IsLocalization.toInvSubmonoid theorem toInvSubmonoid_surjective : Function.Surjective (toInvSubmonoid M S) := Function.Surjective.comp (β := M.map (algebraMap R S)) (Equiv.surjective (equivInvSubmonoid _ _).toEquiv) (MonoidHom.submonoidMap_surjective _ _) #align is_localization.to_inv_submonoid_surjective IsLocalization.toInvSubmonoid_surjective @[simp] theorem toInvSubmonoid_mul (m : M) : (toInvSubmonoid M S m : S) * algebraMap R S m = 1 := Submonoid.leftInvEquiv_symm_mul _ (submonoid_map_le_is_unit _ _) _ #align is_localization.to_inv_submonoid_mul IsLocalization.toInvSubmonoid_mul @[simp] theorem mul_toInvSubmonoid (m : M) : algebraMap R S m * (toInvSubmonoid M S m : S) = 1 := Submonoid.mul_leftInvEquiv_symm _ (submonoid_map_le_is_unit _ _) ⟨_, _⟩ #align is_localization.mul_to_inv_submonoid IsLocalization.mul_toInvSubmonoid @[simp] theorem smul_toInvSubmonoid (m : M) : m • (toInvSubmonoid M S m : S) = 1 := by convert mul_toInvSubmonoid M S m ext rw [← Algebra.smul_def] rfl #align is_localization.smul_to_inv_submonoid IsLocalization.smul_toInvSubmonoid variable {S} -- Porting note: `surj'` was taken, so use `surj''` instead theorem surj'' (z : S) : ∃ (r : R) (m : M), z = r • (toInvSubmonoid M S m : S) := by rcases IsLocalization.surj M z with ⟨⟨r, m⟩, e : z * _ = algebraMap R S r⟩ refine ⟨r, m, ?_⟩ rw [Algebra.smul_def, ← e, mul_assoc] simp #align is_localization.surj' IsLocalization.surj'' theorem toInvSubmonoid_eq_mk' (x : M) : (toInvSubmonoid M S x : S) = mk' S 1 x := by rw [← (IsLocalization.map_units S x).mul_left_inj] simp #align is_localization.to_inv_submonoid_eq_mk' IsLocalization.toInvSubmonoid_eq_mk' theorem mem_invSubmonoid_iff_exists_mk' (x : S) : x ∈ invSubmonoid M S ↔ ∃ m : M, mk' S 1 m = x := by simp_rw [← toInvSubmonoid_eq_mk'] exact ⟨fun h => ⟨_, congr_arg Subtype.val (toInvSubmonoid_surjective M S ⟨x, h⟩).choose_spec⟩, fun h => h.choose_spec ▸ (toInvSubmonoid M S h.choose).prop⟩ #align is_localization.mem_inv_submonoid_iff_exists_mk' IsLocalization.mem_invSubmonoid_iff_exists_mk' variable (S) theorem span_invSubmonoid : Submodule.span R (invSubmonoid M S : Set S) = ⊤ := by rw [eq_top_iff] rintro x - rcases IsLocalization.surj'' M x with ⟨r, m, rfl⟩ exact Submodule.smul_mem _ _ (Submodule.subset_span (toInvSubmonoid M S m).prop) #align is_localization.span_inv_submonoid IsLocalization.span_invSubmonoid
Mathlib/RingTheory/Localization/InvSubmonoid.lean
115
124
theorem finiteType_of_monoid_fg [Monoid.FG M] : Algebra.FiniteType R S := by
have := Monoid.fg_of_surjective _ (toInvSubmonoid_surjective M S) rw [Monoid.fg_iff_submonoid_fg] at this rcases this with ⟨s, hs⟩ refine ⟨⟨s, ?_⟩⟩ rw [eq_top_iff] rintro x - change x ∈ (Subalgebra.toSubmodule (Algebra.adjoin R _ : Subalgebra R S) : Set S) rw [Algebra.adjoin_eq_span, hs, span_invSubmonoid] trivial
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.UniformGroup /-! # Infinite sums and products in topological groups Lemmas on topological sums in groups (as opposed to monoids). -/ noncomputable section open Filter Finset Function open scoped Topology variable {α β γ δ : Type*} section TopologicalGroup variable [CommGroup α] [TopologicalSpace α] [TopologicalGroup α] variable {f g : β → α} {a a₁ a₂ : α} -- `by simpa using` speeds up elaboration. Why? @[to_additive] theorem HasProd.inv (h : HasProd f a) : HasProd (fun b ↦ (f b)⁻¹) a⁻¹ := by simpa only using h.map (MonoidHom.id α)⁻¹ continuous_inv #align has_sum.neg HasSum.neg @[to_additive] theorem Multipliable.inv (hf : Multipliable f) : Multipliable fun b ↦ (f b)⁻¹ := hf.hasProd.inv.multipliable #align summable.neg Summable.neg @[to_additive] theorem Multipliable.of_inv (hf : Multipliable fun b ↦ (f b)⁻¹) : Multipliable f := by simpa only [inv_inv] using hf.inv #align summable.of_neg Summable.of_neg @[to_additive] theorem multipliable_inv_iff : (Multipliable fun b ↦ (f b)⁻¹) ↔ Multipliable f := ⟨Multipliable.of_inv, Multipliable.inv⟩ #align summable_neg_iff summable_neg_iff @[to_additive]
Mathlib/Topology/Algebra/InfiniteSum/Group.lean
50
53
theorem HasProd.div (hf : HasProd f a₁) (hg : HasProd g a₂) : HasProd (fun b ↦ f b / g b) (a₁ / a₂) := by
simp only [div_eq_mul_inv] exact hf.mul hg.inv
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Algebra.Order.Group.Nat import Mathlib.Data.List.Rotate import Mathlib.GroupTheory.Perm.Support #align_import group_theory.perm.list from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Permutations from a list A list `l : List α` can be interpreted as an `Equiv.Perm α` where each element in the list is permuted to the next one, defined as `formPerm`. When we have that `Nodup l`, we prove that `Equiv.Perm.support (formPerm l) = l.toFinset`, and that `formPerm l` is rotationally invariant, in `formPerm_rotate`. When there are duplicate elements in `l`, how and in what arrangement with respect to the other elements they appear in the list determines the formed permutation. This is because `List.formPerm` is implemented as a product of `Equiv.swap`s. That means that presence of a sublist of two adjacent duplicates like `[..., x, x, ...]` will produce the same permutation as if the adjacent duplicates were not present. The `List.formPerm` definition is meant to primarily be used with `Nodup l`, so that the resulting permutation is cyclic (if `l` has at least two elements). The presence of duplicates in a particular placement can lead `List.formPerm` to produce a nontrivial permutation that is noncyclic. -/ namespace List variable {α β : Type*} section FormPerm variable [DecidableEq α] (l : List α) open Equiv Equiv.Perm /-- A list `l : List α` can be interpreted as an `Equiv.Perm α` where each element in the list is permuted to the next one, defined as `formPerm`. When we have that `Nodup l`, we prove that `Equiv.Perm.support (formPerm l) = l.toFinset`, and that `formPerm l` is rotationally invariant, in `formPerm_rotate`. -/ def formPerm : Equiv.Perm α := (zipWith Equiv.swap l l.tail).prod #align list.form_perm List.formPerm @[simp] theorem formPerm_nil : formPerm ([] : List α) = 1 := rfl #align list.form_perm_nil List.formPerm_nil @[simp] theorem formPerm_singleton (x : α) : formPerm [x] = 1 := rfl #align list.form_perm_singleton List.formPerm_singleton @[simp] theorem formPerm_cons_cons (x y : α) (l : List α) : formPerm (x :: y :: l) = swap x y * formPerm (y :: l) := prod_cons #align list.form_perm_cons_cons List.formPerm_cons_cons theorem formPerm_pair (x y : α) : formPerm [x, y] = swap x y := rfl #align list.form_perm_pair List.formPerm_pair theorem mem_or_mem_of_zipWith_swap_prod_ne : ∀ {l l' : List α} {x : α}, (zipWith swap l l').prod x ≠ x → x ∈ l ∨ x ∈ l' | [], _, _ => by simp | _, [], _ => by simp | a::l, b::l', x => fun hx ↦ if h : (zipWith swap l l').prod x = x then (eq_or_eq_of_swap_apply_ne_self (by simpa [h] using hx)).imp (by rintro rfl; exact .head _) (by rintro rfl; exact .head _) else (mem_or_mem_of_zipWith_swap_prod_ne h).imp (.tail _) (.tail _) theorem zipWith_swap_prod_support' (l l' : List α) : { x | (zipWith swap l l').prod x ≠ x } ≤ l.toFinset ⊔ l'.toFinset := fun _ h ↦ by simpa using mem_or_mem_of_zipWith_swap_prod_ne h #align list.zip_with_swap_prod_support' List.zipWith_swap_prod_support' theorem zipWith_swap_prod_support [Fintype α] (l l' : List α) : (zipWith swap l l').prod.support ≤ l.toFinset ⊔ l'.toFinset := by intro x hx have hx' : x ∈ { x | (zipWith swap l l').prod x ≠ x } := by simpa using hx simpa using zipWith_swap_prod_support' _ _ hx' #align list.zip_with_swap_prod_support List.zipWith_swap_prod_support theorem support_formPerm_le' : { x | formPerm l x ≠ x } ≤ l.toFinset := by refine (zipWith_swap_prod_support' l l.tail).trans ?_ simpa [Finset.subset_iff] using tail_subset l #align list.support_form_perm_le' List.support_formPerm_le' theorem support_formPerm_le [Fintype α] : support (formPerm l) ≤ l.toFinset := by intro x hx have hx' : x ∈ { x | formPerm l x ≠ x } := by simpa using hx simpa using support_formPerm_le' _ hx' #align list.support_form_perm_le List.support_formPerm_le variable {l} {x : α} theorem mem_of_formPerm_apply_ne (h : l.formPerm x ≠ x) : x ∈ l := by simpa [or_iff_left_of_imp mem_of_mem_tail] using mem_or_mem_of_zipWith_swap_prod_ne h #align list.mem_of_form_perm_apply_ne List.mem_of_formPerm_apply_ne theorem formPerm_apply_of_not_mem (h : x ∉ l) : formPerm l x = x := not_imp_comm.1 mem_of_formPerm_apply_ne h #align list.form_perm_apply_of_not_mem List.formPerm_apply_of_not_mem theorem formPerm_apply_mem_of_mem (h : x ∈ l) : formPerm l x ∈ l := by cases' l with y l · simp at h induction' l with z l IH generalizing x y · simpa using h · by_cases hx : x ∈ z :: l · rw [formPerm_cons_cons, mul_apply, swap_apply_def] split_ifs · simp [IH _ hx] · simp · simp [*] · replace h : x = y := Or.resolve_right (mem_cons.1 h) hx simp [formPerm_apply_of_not_mem hx, ← h] #align list.form_perm_apply_mem_of_mem List.formPerm_apply_mem_of_mem
Mathlib/GroupTheory/Perm/List.lean
131
133
theorem mem_of_formPerm_apply_mem (h : l.formPerm x ∈ l) : x ∈ l := by
contrapose h rwa [formPerm_apply_of_not_mem h]
/- Copyright (c) 2022 Hans Parshall. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Hans Parshall -/ import Mathlib.Analysis.InnerProductSpace.Adjoint import Mathlib.Analysis.Matrix import Mathlib.Analysis.RCLike.Basic import Mathlib.LinearAlgebra.UnitaryGroup import Mathlib.Topology.UniformSpace.Matrix #align_import analysis.normed_space.star.matrix from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6" /-! # Analytic properties of the `star` operation on matrices This transports the operator norm on `EuclideanSpace 𝕜 n →L[𝕜] EuclideanSpace 𝕜 m` to `Matrix m n 𝕜`. See the file `Analysis.Matrix` for many other matrix norms. ## Main definitions * `Matrix.instNormedRingL2Op`: the (necessarily unique) normed ring structure on `Matrix n n 𝕜` which ensure it is a `CstarRing` in `Matrix.instCstarRing`. This is a scoped instance in the namespace `Matrix.L2OpNorm` in order to avoid choosing a global norm for `Matrix`. ## Main statements * `entry_norm_bound_of_unitary`: the entries of a unitary matrix are uniformly bound by `1`. ## Implementation details We take care to ensure the topology and uniformity induced by `Matrix.instMetricSpaceL2Op` coincide with the existing topology and uniformity on matrices. ## TODO * Show that `‖diagonal (v : n → 𝕜)‖ = ‖v‖`. -/ open scoped Matrix variable {𝕜 m n l E : Type*} section EntrywiseSupNorm variable [RCLike 𝕜] [Fintype n] [DecidableEq n] theorem entry_norm_bound_of_unitary {U : Matrix n n 𝕜} (hU : U ∈ Matrix.unitaryGroup n 𝕜) (i j : n) : ‖U i j‖ ≤ 1 := by -- The norm squared of an entry is at most the L2 norm of its row. have norm_sum : ‖U i j‖ ^ 2 ≤ ∑ x, ‖U i x‖ ^ 2 := by apply Multiset.single_le_sum · intro x h_x rw [Multiset.mem_map] at h_x cases' h_x with a h_a rw [← h_a.2] apply sq_nonneg · rw [Multiset.mem_map] use j simp only [eq_self_iff_true, Finset.mem_univ_val, and_self_iff, sq_eq_sq] -- The L2 norm of a row is a diagonal entry of U * Uᴴ have diag_eq_norm_sum : (U * Uᴴ) i i = (∑ x : n, ‖U i x‖ ^ 2 : ℝ) := by simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, ← starRingEnd_apply, RCLike.mul_conj, RCLike.normSq_eq_def', RCLike.ofReal_pow]; norm_cast -- The L2 norm of a row is a diagonal entry of U * Uᴴ, real part have re_diag_eq_norm_sum : RCLike.re ((U * Uᴴ) i i) = ∑ x : n, ‖U i x‖ ^ 2 := by rw [RCLike.ext_iff] at diag_eq_norm_sum rw [diag_eq_norm_sum.1] norm_cast -- Since U is unitary, the diagonal entries of U * Uᴴ are all 1 have mul_eq_one : U * Uᴴ = 1 := unitary.mul_star_self_of_mem hU have diag_eq_one : RCLike.re ((U * Uᴴ) i i) = 1 := by simp only [mul_eq_one, eq_self_iff_true, Matrix.one_apply_eq, RCLike.one_re] -- Putting it all together rw [← sq_le_one_iff (norm_nonneg (U i j)), ← diag_eq_one, re_diag_eq_norm_sum] exact norm_sum #align entry_norm_bound_of_unitary entry_norm_bound_of_unitary attribute [local instance] Matrix.normedAddCommGroup /-- The entrywise sup norm of a unitary matrix is at most 1. -/
Mathlib/Analysis/NormedSpace/Star/Matrix.lean
83
90
theorem entrywise_sup_norm_bound_of_unitary {U : Matrix n n 𝕜} (hU : U ∈ Matrix.unitaryGroup n 𝕜) : ‖U‖ ≤ 1 := by
conv => -- Porting note: was `simp_rw [pi_norm_le_iff_of_nonneg zero_le_one]` rw [pi_norm_le_iff_of_nonneg zero_le_one] intro rw [pi_norm_le_iff_of_nonneg zero_le_one] intros exact entry_norm_bound_of_unitary hU _ _
/- Copyright (c) 2022 Niels Voss. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Niels Voss -/ import Mathlib.FieldTheory.Finite.Basic import Mathlib.Order.Filter.Cofinite #align_import number_theory.fermat_psp from "leanprover-community/mathlib"@"c0439b4877c24a117bfdd9e32faf62eee9b115eb" /-! # Fermat Pseudoprimes In this file we define Fermat pseudoprimes: composite numbers that pass the Fermat primality test. A natural number `n` passes the Fermat primality test to base `b` (and is therefore deemed a "probable prime") if `n` divides `b ^ (n - 1) - 1`. `n` is a Fermat pseudoprime to base `b` if `n` is a composite number that passes the Fermat primality test to base `b` and is coprime with `b`. Fermat pseudoprimes can also be seen as composite numbers for which Fermat's little theorem holds true. Numbers which are Fermat pseudoprimes to all bases are known as Carmichael numbers (not yet defined in this file). ## Main Results The main definitions for this file are - `Nat.ProbablePrime`: A number `n` is a probable prime to base `b` if it passes the Fermat primality test; that is, if `n` divides `b ^ (n - 1) - 1` - `Nat.FermatPsp`: A number `n` is a pseudoprime to base `b` if it is a probable prime to base `b`, is composite, and is coprime with `b` (this last condition is automatically true if `n` divides `b ^ (n - 1) - 1`, but some sources include it in the definition). Note that all composite numbers are pseudoprimes to base 0 and 1, and that the definition of `Nat.ProbablePrime` in this file implies that all numbers are probable primes to bases 0 and 1, and that 0 and 1 are probable primes to any base. The main theorems are - `Nat.exists_infinite_pseudoprimes`: there are infinite pseudoprimes to any base `b ≥ 1` -/ namespace Nat /-- `n` is a probable prime to base `b` if `n` passes the Fermat primality test; that is, `n` divides `b ^ (n - 1) - 1`. This definition implies that all numbers are probable primes to base 0 or 1, and that 0 and 1 are probable primes to any base. -/ def ProbablePrime (n b : ℕ) : Prop := n ∣ b ^ (n - 1) - 1 #align fermat_psp.probable_prime Nat.ProbablePrime /-- `n` is a Fermat pseudoprime to base `b` if `n` is a probable prime to base `b` and is composite. By this definition, all composite natural numbers are pseudoprimes to base 0 and 1. This definition also permits `n` to be less than `b`, so that 4 is a pseudoprime to base 5, for example. -/ def FermatPsp (n b : ℕ) : Prop := ProbablePrime n b ∧ ¬n.Prime ∧ 1 < n #align fermat_psp Nat.FermatPsp instance decidableProbablePrime (n b : ℕ) : Decidable (ProbablePrime n b) := Nat.decidable_dvd _ _ #align fermat_psp.decidable_probable_prime Nat.decidableProbablePrime instance decidablePsp (n b : ℕ) : Decidable (FermatPsp n b) := And.decidable #align fermat_psp.decidable_psp Nat.decidablePsp /-- If `n` passes the Fermat primality test to base `b`, then `n` is coprime with `b`, assuming that `n` and `b` are both positive. -/
Mathlib/NumberTheory/FermatPsp.lean
75
99
theorem coprime_of_probablePrime {n b : ℕ} (h : ProbablePrime n b) (h₁ : 1 ≤ n) (h₂ : 1 ≤ b) : Nat.Coprime n b := by
by_cases h₃ : 2 ≤ n · -- To prove that `n` is coprime with `b`, we need to show that for all prime factors of `n`, -- we can derive a contradiction if `n` divides `b`. apply Nat.coprime_of_dvd -- If `k` is a prime number that divides both `n` and `b`, then we know that `n = m * k` and -- `b = j * k` for some natural numbers `m` and `j`. We substitute these into the hypothesis. rintro k hk ⟨m, rfl⟩ ⟨j, rfl⟩ -- Because prime numbers do not divide 1, it suffices to show that `k ∣ 1` to prove a -- contradiction apply Nat.Prime.not_dvd_one hk -- Since `n` divides `b ^ (n - 1) - 1`, `k` also divides `b ^ (n - 1) - 1` replace h := dvd_of_mul_right_dvd h -- Because `k` divides `b ^ (n - 1) - 1`, if we can show that `k` also divides `b ^ (n - 1)`, -- then we know `k` divides 1. rw [Nat.dvd_add_iff_right h, Nat.sub_add_cancel (Nat.one_le_pow _ _ h₂)] -- Since `k` divides `b`, `k` also divides any power of `b` except `b ^ 0`. Therefore, it -- suffices to show that `n - 1` isn't zero. However, we know that `n - 1` isn't zero because we -- assumed `2 ≤ n` when doing `by_cases`. refine dvd_of_mul_right_dvd (dvd_pow_self (k * j) ?_) omega -- If `n = 1`, then it follows trivially that `n` is coprime with `b`. · rw [show n = 1 by omega] norm_num
/- Copyright (c) 2024 Thomas Browning, Junyan Xu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning, Junyan Xu -/ import Mathlib.Data.Set.Finite import Mathlib.GroupTheory.GroupAction.FixedPoints import Mathlib.GroupTheory.Perm.Support /-! # Subgroups generated by transpositions This file studies subgroups generated by transpositions. ## Main results - `swap_mem_closure_isSwap` : If a subgroup is generated by transpositions, then a transposition `swap x y` lies in the subgroup if and only if `x` lies in the same orbit as `y`. - `mem_closure_isSwap` : If a subgroup is generated by transpositions, then a permutation `f` lies in the subgroup if and only if `f` has finite support and `f x` always lies in the same orbit as `x`. -/ open Equiv List MulAction Pointwise Set Subgroup variable {G α : Type*} [Group G] [MulAction G α] [DecidableEq α] /-- If the support of each element in a generating set of a permutation group is finite, then the support of every element in the group is finite. -/ theorem finite_compl_fixedBy_closure_iff {S : Set G} : (∀ g ∈ closure S, (fixedBy α g)ᶜ.Finite) ↔ ∀ g ∈ S, (fixedBy α g)ᶜ.Finite := ⟨fun h g hg ↦ h g (subset_closure hg), fun h g hg ↦ by refine closure_induction hg h (by simp) (fun g g' hg hg' ↦ (hg.union hg').subset ?_) (by simp) simp_rw [← compl_inter, compl_subset_compl, fixedBy_mul]⟩ theorem finite_compl_fixedBy_swap {x y : α} : (fixedBy α (swap x y))ᶜ.Finite := Set.Finite.subset (s := {x, y}) (by simp) (compl_subset_comm.mp fun z h ↦ by apply swap_apply_of_ne_of_ne <;> rintro rfl <;> simp at h) theorem Equiv.Perm.IsSwap.finite_compl_fixedBy {σ : Perm α} (h : σ.IsSwap) : (fixedBy α σ)ᶜ.Finite := by obtain ⟨x, y, -, rfl⟩ := h exact finite_compl_fixedBy_swap -- this result cannot be moved to Perm/Basic since Perm/Basic is not allowed to import Submonoid theorem SubmonoidClass.swap_mem_trans {a b c : α} {C} [SetLike C (Perm α)] [SubmonoidClass C (Perm α)] (M : C) (hab : swap a b ∈ M) (hbc : swap b c ∈ M) : swap a c ∈ M := by obtain rfl | hab' := eq_or_ne a b · exact hbc obtain rfl | hac := eq_or_ne a c · exact swap_self a ▸ one_mem M rw [swap_comm, ← swap_mul_swap_mul_swap hab' hac] exact mul_mem (mul_mem hbc hab) hbc /-- Given a symmetric generating set of a permutation group, if T is a nonempty proper subset of an orbit, then there exists a generator that sends some element of T into the complement of T. -/
Mathlib/GroupTheory/Perm/ClosureSwap.lean
59
70
theorem exists_smul_not_mem_of_subset_orbit_closure (S : Set G) (T : Set α) {a : α} (hS : ∀ g ∈ S, g⁻¹ ∈ S) (subset : T ⊆ orbit (closure S) a) (not_mem : a ∉ T) (nonempty : T.Nonempty) : ∃ σ ∈ S, ∃ a ∈ T, σ • a ∉ T := by
have key0 : ¬ closure S ≤ stabilizer G T := by have ⟨b, hb⟩ := nonempty obtain ⟨σ, rfl⟩ := subset hb contrapose! not_mem with h exact smul_mem_smul_set_iff.mp ((h σ.2).symm ▸ hb) contrapose! key0 refine (closure_le _).mpr fun σ hσ ↦ ?_ simp_rw [SetLike.mem_coe, mem_stabilizer_iff, Set.ext_iff, mem_smul_set_iff_inv_smul_mem] exact fun a ↦ ⟨fun h ↦ smul_inv_smul σ a ▸ key0 σ hσ (σ⁻¹ • a) h, key0 σ⁻¹ (hS σ hσ) a⟩
/- 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.Init.Data.Ordering.Basic import Mathlib.Order.Synonym #align_import order.compare from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23" /-! # Comparison This file provides basic results about orderings and comparison in linear orders. ## Definitions * `CmpLE`: An `Ordering` from `≤`. * `Ordering.Compares`: Turns an `Ordering` into `<` and `=` propositions. * `linearOrderOfCompares`: Constructs a `LinearOrder` instance from the fact that any two elements that are not one strictly less than the other either way are equal. -/ variable {α β : Type*} /-- Like `cmp`, but uses a `≤` on the type instead of `<`. Given two elements `x` and `y`, returns a three-way comparison result `Ordering`. -/ def cmpLE {α} [LE α] [@DecidableRel α (· ≤ ·)] (x y : α) : Ordering := if x ≤ y then if y ≤ x then Ordering.eq else Ordering.lt else Ordering.gt #align cmp_le cmpLE theorem cmpLE_swap {α} [LE α] [IsTotal α (· ≤ ·)] [@DecidableRel α (· ≤ ·)] (x y : α) : (cmpLE x y).swap = cmpLE y x := by by_cases xy:x ≤ y <;> by_cases yx:y ≤ x <;> simp [cmpLE, *, Ordering.swap] cases not_or_of_not xy yx (total_of _ _ _) #align cmp_le_swap cmpLE_swap theorem cmpLE_eq_cmp {α} [Preorder α] [IsTotal α (· ≤ ·)] [@DecidableRel α (· ≤ ·)] [@DecidableRel α (· < ·)] (x y : α) : cmpLE x y = cmp x y := by by_cases xy:x ≤ y <;> by_cases yx:y ≤ x <;> simp [cmpLE, lt_iff_le_not_le, *, cmp, cmpUsing] cases not_or_of_not xy yx (total_of _ _ _) #align cmp_le_eq_cmp cmpLE_eq_cmp namespace Ordering /-- `Compares o a b` means that `a` and `b` have the ordering relation `o` between them, assuming that the relation `a < b` is defined. -/ -- Porting note: we have removed `@[simp]` here in favour of separate simp lemmas, -- otherwise this definition will unfold to a match. def Compares [LT α] : Ordering → α → α → Prop | lt, a, b => a < b | eq, a, b => a = b | gt, a, b => a > b #align ordering.compares Ordering.Compares @[simp] lemma compares_lt [LT α] (a b : α) : Compares lt a b = (a < b) := rfl @[simp] lemma compares_eq [LT α] (a b : α) : Compares eq a b = (a = b) := rfl @[simp] lemma compares_gt [LT α] (a b : α) : Compares gt a b = (a > b) := rfl
Mathlib/Order/Compare.lean
67
71
theorem compares_swap [LT α] {a b : α} {o : Ordering} : o.swap.Compares a b ↔ o.Compares b a := by
cases o · exact Iff.rfl · exact eq_comm · exact Iff.rfl
/- Copyright (c) 2020 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.MeasureTheory.Measure.MeasureSpace import Mathlib.MeasureTheory.Measure.Regular import Mathlib.Topology.Sets.Compacts #align_import measure_theory.measure.content from "leanprover-community/mathlib"@"d39590fc8728fbf6743249802486f8c91ffe07bc" /-! # Contents In this file we work with *contents*. A content `λ` is a function from a certain class of subsets (such as the compact subsets) to `ℝ≥0` that is * additive: If `K₁` and `K₂` are disjoint sets in the domain of `λ`, then `λ(K₁ ∪ K₂) = λ(K₁) + λ(K₂)`; * subadditive: If `K₁` and `K₂` are in the domain of `λ`, then `λ(K₁ ∪ K₂) ≤ λ(K₁) + λ(K₂)`; * monotone: If `K₁ ⊆ K₂` are in the domain of `λ`, then `λ(K₁) ≤ λ(K₂)`. We show that: * Given a content `λ` on compact sets, let us define a function `λ*` on open sets, by letting `λ* U` be the supremum of `λ K` for `K` included in `U`. This is a countably subadditive map that vanishes at `∅`. In Halmos (1950) this is called the *inner content* `λ*` of `λ`, and formalized as `innerContent`. * Given an inner content, we define an outer measure `μ*`, by letting `μ* E` be the infimum of `λ* U` over the open sets `U` containing `E`. This is indeed an outer measure. It is formalized as `outerMeasure`. * Restricting this outer measure to Borel sets gives a regular measure `μ`. We define bundled contents as `Content`. In this file we only work on contents on compact sets, and inner contents on open sets, and both contents and inner contents map into the extended nonnegative reals. However, in other applications other choices can be made, and it is not a priori clear what the best interface should be. ## Main definitions For `μ : Content G`, we define * `μ.innerContent` : the inner content associated to `μ`. * `μ.outerMeasure` : the outer measure associated to `μ`. * `μ.measure` : the Borel measure associated to `μ`. These definitions are given for spaces which are R₁. The resulting measure `μ.measure` is always outer regular by design. When the space is locally compact, `μ.measure` is also regular. ## References * Paul Halmos (1950), Measure Theory, §53 * <https://en.wikipedia.org/wiki/Content_(measure_theory)> -/ universe u v w noncomputable section open Set TopologicalSpace open NNReal ENNReal MeasureTheory namespace MeasureTheory variable {G : Type w} [TopologicalSpace G] /-- A content is an additive function on compact sets taking values in `ℝ≥0`. It is a device from which one can define a measure. -/ structure Content (G : Type w) [TopologicalSpace G] where toFun : Compacts G → ℝ≥0 mono' : ∀ K₁ K₂ : Compacts G, (K₁ : Set G) ⊆ K₂ → toFun K₁ ≤ toFun K₂ sup_disjoint' : ∀ K₁ K₂ : Compacts G, Disjoint (K₁ : Set G) K₂ → IsClosed (K₁ : Set G) → IsClosed (K₂ : Set G) → toFun (K₁ ⊔ K₂) = toFun K₁ + toFun K₂ sup_le' : ∀ K₁ K₂ : Compacts G, toFun (K₁ ⊔ K₂) ≤ toFun K₁ + toFun K₂ #align measure_theory.content MeasureTheory.Content instance : Inhabited (Content G) := ⟨{ toFun := fun _ => 0 mono' := by simp sup_disjoint' := by simp sup_le' := by simp }⟩ /-- Although the `toFun` field of a content takes values in `ℝ≥0`, we register a coercion to functions taking values in `ℝ≥0∞` as most constructions below rely on taking iSups and iInfs, which is more convenient in a complete lattice, and aim at constructing a measure. -/ instance : CoeFun (Content G) fun _ => Compacts G → ℝ≥0∞ := ⟨fun μ s => μ.toFun s⟩ namespace Content variable (μ : Content G) theorem apply_eq_coe_toFun (K : Compacts G) : μ K = μ.toFun K := rfl #align measure_theory.content.apply_eq_coe_to_fun MeasureTheory.Content.apply_eq_coe_toFun theorem mono (K₁ K₂ : Compacts G) (h : (K₁ : Set G) ⊆ K₂) : μ K₁ ≤ μ K₂ := by simp [apply_eq_coe_toFun, μ.mono' _ _ h] #align measure_theory.content.mono MeasureTheory.Content.mono theorem sup_disjoint (K₁ K₂ : Compacts G) (h : Disjoint (K₁ : Set G) K₂) (h₁ : IsClosed (K₁ : Set G)) (h₂ : IsClosed (K₂ : Set G)) : μ (K₁ ⊔ K₂) = μ K₁ + μ K₂ := by simp [apply_eq_coe_toFun, μ.sup_disjoint' _ _ h] #align measure_theory.content.sup_disjoint MeasureTheory.Content.sup_disjoint
Mathlib/MeasureTheory/Measure/Content.lean
108
111
theorem sup_le (K₁ K₂ : Compacts G) : μ (K₁ ⊔ K₂) ≤ μ K₁ + μ K₂ := by
simp only [apply_eq_coe_toFun] norm_cast exact μ.sup_le' _ _
/- Copyright (c) 2022 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.InnerProductSpace.Orientation import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar #align_import measure_theory.measure.haar.inner_product_space from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Volume forms and measures on inner product spaces A volume form induces a Lebesgue measure on general finite-dimensional real vector spaces. In this file, we discuss the specific situation of inner product spaces, where an orientation gives rise to a canonical volume form. We show that the measure coming from this volume form gives measure `1` to the parallelepiped spanned by any orthonormal basis, and that it coincides with the canonical `volume` from the `MeasureSpace` instance. -/ open FiniteDimensional MeasureTheory MeasureTheory.Measure Set variable {ι E F : Type*} variable [Fintype ι] [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] [MeasurableSpace F] [BorelSpace F] section variable {m n : ℕ} [_i : Fact (finrank ℝ F = n)] /-- The volume form coming from an orientation in an inner product space gives measure `1` to the parallelepiped associated to any orthonormal basis. This is a rephrasing of `abs_volumeForm_apply_of_orthonormal` in terms of measures. -/ theorem Orientation.measure_orthonormalBasis (o : Orientation ℝ F (Fin n)) (b : OrthonormalBasis ι ℝ F) : o.volumeForm.measure (parallelepiped b) = 1 := by have e : ι ≃ Fin n := by refine Fintype.equivFinOfCardEq ?_ rw [← _i.out, finrank_eq_card_basis b.toBasis] have A : ⇑b = b.reindex e ∘ e := by ext x simp only [OrthonormalBasis.coe_reindex, Function.comp_apply, Equiv.symm_apply_apply] rw [A, parallelepiped_comp_equiv, AlternatingMap.measure_parallelepiped, o.abs_volumeForm_apply_of_orthonormal, ENNReal.ofReal_one] #align orientation.measure_orthonormal_basis Orientation.measure_orthonormalBasis /-- In an oriented inner product space, the measure coming from the canonical volume form associated to an orientation coincides with the volume. -/ theorem Orientation.measure_eq_volume (o : Orientation ℝ F (Fin n)) : o.volumeForm.measure = volume := by have A : o.volumeForm.measure (stdOrthonormalBasis ℝ F).toBasis.parallelepiped = 1 := Orientation.measure_orthonormalBasis o (stdOrthonormalBasis ℝ F) rw [addHaarMeasure_unique o.volumeForm.measure (stdOrthonormalBasis ℝ F).toBasis.parallelepiped, A, one_smul] simp only [volume, Basis.addHaar] #align orientation.measure_eq_volume Orientation.measure_eq_volume end /-- The volume measure in a finite-dimensional inner product space gives measure `1` to the parallelepiped spanned by any orthonormal basis. -/ theorem OrthonormalBasis.volume_parallelepiped (b : OrthonormalBasis ι ℝ F) : volume (parallelepiped b) = 1 := by haveI : Fact (finrank ℝ F = finrank ℝ F) := ⟨rfl⟩ let o := (stdOrthonormalBasis ℝ F).toBasis.orientation rw [← o.measure_eq_volume] exact o.measure_orthonormalBasis b #align orthonormal_basis.volume_parallelepiped OrthonormalBasis.volume_parallelepiped /-- The Haar measure defined by any orthonormal basis of a finite-dimensional inner product space is equal to its volume measure. -/ theorem OrthonormalBasis.addHaar_eq_volume {ι F : Type*} [Fintype ι] [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] [MeasurableSpace F] [BorelSpace F] (b : OrthonormalBasis ι ℝ F) : b.toBasis.addHaar = volume := by rw [Basis.addHaar_eq_iff] exact b.volume_parallelepiped /-- An orthonormal basis of a finite-dimensional inner product space defines a measurable equivalence between the space and the Euclidean space of the same dimension. -/ noncomputable def OrthonormalBasis.measurableEquiv (b : OrthonormalBasis ι ℝ F) : F ≃ᵐ EuclideanSpace ℝ ι := b.repr.toHomeomorph.toMeasurableEquiv /-- The measurable equivalence defined by an orthonormal basis is volume preserving. -/ theorem OrthonormalBasis.measurePreserving_measurableEquiv (b : OrthonormalBasis ι ℝ F) : MeasurePreserving b.measurableEquiv volume volume := by convert (b.measurableEquiv.symm.measurable.measurePreserving _).symm rw [← (EuclideanSpace.basisFun ι ℝ).addHaar_eq_volume] erw [MeasurableEquiv.coe_toEquiv_symm, Basis.map_addHaar _ b.repr.symm.toContinuousLinearEquiv] exact b.addHaar_eq_volume.symm theorem OrthonormalBasis.measurePreserving_repr (b : OrthonormalBasis ι ℝ F) : MeasurePreserving b.repr volume volume := b.measurePreserving_measurableEquiv theorem OrthonormalBasis.measurePreserving_repr_symm (b : OrthonormalBasis ι ℝ F) : MeasurePreserving b.repr.symm volume volume := b.measurePreserving_measurableEquiv.symm section PiLp variable (ι : Type*) [Fintype ι] /-- The measure equivalence between `EuclideanSpace ℝ ι` and `ι → ℝ` is volume preserving. -/
Mathlib/MeasureTheory/Measure/Haar/InnerProductSpace.lean
102
108
theorem EuclideanSpace.volume_preserving_measurableEquiv : MeasurePreserving (EuclideanSpace.measurableEquiv ι) := by
suffices volume = map (EuclideanSpace.measurableEquiv ι).symm volume by convert ((EuclideanSpace.measurableEquiv ι).symm.measurable.measurePreserving _).symm rw [← addHaarMeasure_eq_volume_pi, ← Basis.parallelepiped_basisFun, ← Basis.addHaar_def, coe_measurableEquiv_symm, ← PiLp.continuousLinearEquiv_symm_apply 2 ℝ, Basis.map_addHaar] exact (EuclideanSpace.basisFun _ _).addHaar_eq_volume.symm
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Michael Howes -/ import Mathlib.Data.Finite.Card import Mathlib.GroupTheory.Commutator import Mathlib.GroupTheory.Finiteness #align_import group_theory.abelianization from "leanprover-community/mathlib"@"4be589053caf347b899a494da75410deb55fb3ef" /-! # The abelianization of a group This file defines the commutator and the abelianization of a group. It furthermore prepares for the result that the abelianization is left adjoint to the forgetful functor from abelian groups to groups, which can be found in `Algebra/Category/Group/Adjunctions`. ## Main definitions * `commutator`: defines the commutator of a group `G` as a subgroup of `G`. * `Abelianization`: defines the abelianization of a group `G` as the quotient of a group by its commutator subgroup. * `Abelianization.map`: lifts a group homomorphism to a homomorphism between the abelianizations * `MulEquiv.abelianizationCongr`: Equivalent groups have equivalent abelianizations -/ universe u v w -- Let G be a group. variable (G : Type u) [Group G] open Subgroup (centralizer) /-- The commutator subgroup of a group G is the normal subgroup generated by the commutators [p,q]=`p*q*p⁻¹*q⁻¹`. -/ def commutator : Subgroup G := ⁅(⊤ : Subgroup G), ⊤⁆ #align commutator commutator -- Porting note: this instance should come from `deriving Subgroup.Normal` instance : Subgroup.Normal (commutator G) := Subgroup.commutator_normal ⊤ ⊤ theorem commutator_def : commutator G = ⁅(⊤ : Subgroup G), ⊤⁆ := rfl #align commutator_def commutator_def theorem commutator_eq_closure : commutator G = Subgroup.closure (commutatorSet G) := by simp [commutator, Subgroup.commutator_def, commutatorSet] #align commutator_eq_closure commutator_eq_closure
Mathlib/GroupTheory/Abelianization.lean
53
54
theorem commutator_eq_normalClosure : commutator G = Subgroup.normalClosure (commutatorSet G) := by
simp [commutator, Subgroup.commutator_def', commutatorSet]
/- 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]
Mathlib/Topology/ContinuousOn.lean
63
67
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
/- Copyright (c) 2022 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Locus of unequal values of finitely supported functions Let `α N` be two Types, assume that `N` has a `0` and let `f g : α →₀ N` be finitely supported functions. ## Main definition * `Finsupp.neLocus f g : Finset α`, the finite subset of `α` where `f` and `g` differ. In the case in which `N` is an additive group, `Finsupp.neLocus f g` coincides with `Finsupp.support (f - g)`. -/ variable {α M N P : Type*} namespace Finsupp variable [DecidableEq α] section NHasZero variable [DecidableEq N] [Zero N] (f g : α →₀ N) /-- Given two finitely supported functions `f g : α →₀ N`, `Finsupp.neLocus f g` is the `Finset` where `f` and `g` differ. This generalizes `(f - g).support` to situations without subtraction. -/ def neLocus (f g : α →₀ N) : Finset α := (f.support ∪ g.support).filter fun x => f x ≠ g x #align finsupp.ne_locus Finsupp.neLocus @[simp] theorem mem_neLocus {f g : α →₀ N} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff, and_iff_right_iff_imp] using Ne.ne_or_ne _ #align finsupp.mem_ne_locus Finsupp.mem_neLocus theorem not_mem_neLocus {f g : α →₀ N} {a : α} : a ∉ f.neLocus g ↔ f a = g a := mem_neLocus.not.trans not_ne_iff #align finsupp.not_mem_ne_locus Finsupp.not_mem_neLocus @[simp]
Mathlib/Data/Finsupp/NeLocus.lean
52
54
theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } := by
ext exact mem_neLocus
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Analysis.Quaternion import Mathlib.Analysis.NormedSpace.Exponential import Mathlib.Analysis.SpecialFunctions.Trigonometric.Series #align_import analysis.normed_space.quaternion_exponential from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Lemmas about `NormedSpace.exp` on `Quaternion`s This file contains results about `NormedSpace.exp` on `Quaternion ℝ`. ## Main results * `Quaternion.exp_eq`: the general expansion of the quaternion exponential in terms of `Real.cos` and `Real.sin`. * `Quaternion.exp_of_re_eq_zero`: the special case when the quaternion has a zero real part. * `Quaternion.norm_exp`: the norm of the quaternion exponential is the norm of the exponential of the real part. -/ open scoped Quaternion Nat open NormedSpace namespace Quaternion @[simp, norm_cast] theorem exp_coe (r : ℝ) : exp ℝ (r : ℍ[ℝ]) = ↑(exp ℝ r) := (map_exp ℝ (algebraMap ℝ ℍ[ℝ]) (continuous_algebraMap _ _) _).symm #align quaternion.exp_coe Quaternion.exp_coe /-- The even terms of `expSeries` are real, and correspond to the series for $\cos ‖q‖$. -/ theorem expSeries_even_of_imaginary {q : Quaternion ℝ} (hq : q.re = 0) (n : ℕ) : expSeries ℝ (Quaternion ℝ) (2 * n) (fun _ => q) = ↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n) / (2 * n)!) := by rw [expSeries_apply_eq] have hq2 : q ^ 2 = -normSq q := sq_eq_neg_normSq.mpr hq letI k : ℝ := ↑(2 * n)! calc k⁻¹ • q ^ (2 * n) = k⁻¹ • (-normSq q) ^ n := by rw [pow_mul, hq2] _ = k⁻¹ • ↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n)) := ?_ _ = ↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n) / k) := ?_ · congr 1 rw [neg_pow, normSq_eq_norm_mul_self, pow_mul, sq] push_cast rfl · rw [← coe_mul_eq_smul, div_eq_mul_inv] norm_cast ring_nf /-- The odd terms of `expSeries` are real, and correspond to the series for $\frac{q}{‖q‖} \sin ‖q‖$. -/ theorem expSeries_odd_of_imaginary {q : Quaternion ℝ} (hq : q.re = 0) (n : ℕ) : expSeries ℝ (Quaternion ℝ) (2 * n + 1) (fun _ => q) = (((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n + 1) / (2 * n + 1)!) / ‖q‖) • q := by rw [expSeries_apply_eq] obtain rfl | hq0 := eq_or_ne q 0 · simp have hq2 : q ^ 2 = -normSq q := sq_eq_neg_normSq.mpr hq have hqn := norm_ne_zero_iff.mpr hq0 let k : ℝ := ↑(2 * n + 1)! calc k⁻¹ • q ^ (2 * n + 1) = k⁻¹ • ((-normSq q) ^ n * q) := by rw [pow_succ, pow_mul, hq2] _ = k⁻¹ • ((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n)) • q := ?_ _ = ((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n + 1) / k / ‖q‖) • q := ?_ · congr 1 rw [neg_pow, normSq_eq_norm_mul_self, pow_mul, sq, ← coe_mul_eq_smul] norm_cast · rw [smul_smul] congr 1 simp_rw [pow_succ, mul_div_assoc, div_div_cancel_left' hqn] ring /-- Auxiliary result; if the power series corresponding to `Real.cos` and `Real.sin` evaluated at `‖q‖` tend to `c` and `s`, then the exponential series tends to `c + (s / ‖q‖)`. -/
Mathlib/Analysis/NormedSpace/QuaternionExponential.lean
82
94
theorem hasSum_expSeries_of_imaginary {q : Quaternion ℝ} (hq : q.re = 0) {c s : ℝ} (hc : HasSum (fun n => (-1 : ℝ) ^ n * ‖q‖ ^ (2 * n) / (2 * n)!) c) (hs : HasSum (fun n => (-1 : ℝ) ^ n * ‖q‖ ^ (2 * n + 1) / (2 * n + 1)!) s) : HasSum (fun n => expSeries ℝ (Quaternion ℝ) n fun _ => q) (↑c + (s / ‖q‖) • q) := by
replace hc := hasSum_coe.mpr hc replace hs := (hs.div_const ‖q‖).smul_const q refine HasSum.even_add_odd ?_ ?_ · convert hc using 1 ext n : 1 rw [expSeries_even_of_imaginary hq] · convert hs using 1 ext n : 1 rw [expSeries_odd_of_imaginary hq]
/- 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.Logic.Basic import Mathlib.Tactic.Positivity.Basic #align_import algebra.order.hom.basic from "leanprover-community/mathlib"@"28aa996fc6fb4317f0083c4e6daf79878d81be33" /-! # Algebraic order homomorphism classes This file defines hom classes for common properties at the intersection of order theory and algebra. ## Typeclasses Basic typeclasses * `NonnegHomClass`: Homs are nonnegative: `∀ f a, 0 ≤ f a` * `SubadditiveHomClass`: Homs are subadditive: `∀ f a b, f (a + b) ≤ f a + f b` * `SubmultiplicativeHomClass`: Homs are submultiplicative: `∀ f a b, f (a * b) ≤ f a * f b` * `MulLEAddHomClass`: `∀ f a b, f (a * b) ≤ f a + f b` * `NonarchimedeanHomClass`: `∀ a b, f (a + b) ≤ max (f a) (f b)` Group norms * `AddGroupSeminormClass`: Homs are nonnegative, subadditive, even and preserve zero. * `GroupSeminormClass`: Homs are nonnegative, respect `f (a * b) ≤ f a + f b`, `f a⁻¹ = f a` and preserve zero. * `AddGroupNormClass`: Homs are seminorms such that `f x = 0 → x = 0` for all `x`. * `GroupNormClass`: Homs are seminorms such that `f x = 0 → x = 1` for all `x`. Ring norms * `RingSeminormClass`: Homs are submultiplicative group norms. * `RingNormClass`: Homs are ring seminorms that are also additive group norms. * `MulRingSeminormClass`: Homs are ring seminorms that are multiplicative. * `MulRingNormClass`: Homs are ring norms that are multiplicative. ## Notes Typeclasses for seminorms are defined here while types of seminorms are defined in `Analysis.Normed.Group.Seminorm` and `Analysis.Normed.Ring.Seminorm` because absolute values are multiplicative ring norms but outside of this use we only consider real-valued seminorms. ## TODO Finitary versions of the current lemmas. -/ library_note "out-param inheritance"/-- Diamond inheritance cannot depend on `outParam`s in the following circumstances: * there are three classes `Top`, `Middle`, `Bottom` * all of these classes have a parameter `(α : outParam _)` * all of these classes have an instance parameter `[Root α]` that depends on this `outParam` * the `Root` class has two child classes: `Left` and `Right`, these are siblings in the hierarchy * the instance `Bottom.toMiddle` takes a `[Left α]` parameter * the instance `Middle.toTop` takes a `[Right α]` parameter * there is a `Leaf` class that inherits from both `Left` and `Right`. In that case, given instances `Bottom α` and `Leaf α`, Lean cannot synthesize a `Top α` instance, even though the hypotheses of the instances `Bottom.toMiddle` and `Middle.toTop` are satisfied. There are two workarounds: * You could replace the bundled inheritance implemented by the instance `Middle.toTop` with unbundled inheritance implemented by adding a `[Top α]` parameter to the `Middle` class. This is the preferred option since it is also more compatible with Lean 4, at the cost of being more work to implement and more verbose to use. * You could weaken the `Bottom.toMiddle` instance by making it depend on a subclass of `Middle.toTop`'s parameter, in this example replacing `[Left α]` with `[Leaf α]`. -/ open Function variable {ι F α β γ δ : Type*} /-! ### Basics -/ /-- `NonnegHomClass F α β` states that `F` is a type of nonnegative morphisms. -/ class NonnegHomClass (F α β : Type*) [Zero β] [LE β] [FunLike F α β] : Prop where /-- the image of any element is non negative. -/ apply_nonneg (f : F) : ∀ a, 0 ≤ f a #align nonneg_hom_class NonnegHomClass /-- `SubadditiveHomClass F α β` states that `F` is a type of subadditive morphisms. -/ class SubadditiveHomClass (F α β : Type*) [Add α] [Add β] [LE β] [FunLike F α β] : Prop where /-- the image of a sum is less or equal than the sum of the images. -/ map_add_le_add (f : F) : ∀ a b, f (a + b) ≤ f a + f b #align subadditive_hom_class SubadditiveHomClass /-- `SubmultiplicativeHomClass F α β` states that `F` is a type of submultiplicative morphisms. -/ @[to_additive SubadditiveHomClass] class SubmultiplicativeHomClass (F α β : Type*) [Mul α] [Mul β] [LE β] [FunLike F α β] : Prop where /-- the image of a product is less or equal than the product of the images. -/ map_mul_le_mul (f : F) : ∀ a b, f (a * b) ≤ f a * f b #align submultiplicative_hom_class SubmultiplicativeHomClass /-- `MulLEAddHomClass F α β` states that `F` is a type of subadditive morphisms. -/ @[to_additive SubadditiveHomClass] class MulLEAddHomClass (F α β : Type*) [Mul α] [Add β] [LE β] [FunLike F α β] : Prop where /-- the image of a product is less or equal than the sum of the images. -/ map_mul_le_add (f : F) : ∀ a b, f (a * b) ≤ f a + f b #align mul_le_add_hom_class MulLEAddHomClass /-- `NonarchimedeanHomClass F α β` states that `F` is a type of non-archimedean morphisms. -/ class NonarchimedeanHomClass (F α β : Type*) [Add α] [LinearOrder β] [FunLike F α β] : Prop where /-- the image of a sum is less or equal than the maximum of the images. -/ map_add_le_max (f : F) : ∀ a b, f (a + b) ≤ max (f a) (f b) #align nonarchimedean_hom_class NonarchimedeanHomClass export NonnegHomClass (apply_nonneg) export SubadditiveHomClass (map_add_le_add) export SubmultiplicativeHomClass (map_mul_le_mul) export MulLEAddHomClass (map_mul_le_add) export NonarchimedeanHomClass (map_add_le_max) attribute [simp] apply_nonneg variable [FunLike F α β] @[to_additive]
Mathlib/Algebra/Order/Hom/Basic.lean
124
126
theorem le_map_mul_map_div [Group α] [CommSemigroup β] [LE β] [SubmultiplicativeHomClass F α β] (f : F) (a b : α) : f a ≤ f b * f (a / b) := by
simpa only [mul_comm, div_mul_cancel] using map_mul_le_mul f (a / b) b
/- Copyright (c) 2022 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying, Rémy Degenne -/ import Mathlib.Probability.Process.Stopping import Mathlib.Tactic.AdaptationNote #align_import probability.process.hitting_time from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Hitting time Given a stochastic process, the hitting time provides the first time the process "hits" some subset of the state space. The hitting time is a stopping time in the case that the time index is discrete and the process is adapted (this is true in a far more general setting however we have only proved it for the discrete case so far). ## Main definition * `MeasureTheory.hitting`: the hitting time of a stochastic process ## Main results * `MeasureTheory.hitting_isStoppingTime`: a discrete hitting time of an adapted process is a stopping time ## Implementation notes In the definition of the hitting time, we bound the hitting time by an upper and lower bound. This is to ensure that our result is meaningful in the case we are taking the infimum of an empty set or the infimum of a set which is unbounded from below. With this, we can talk about hitting times indexed by the natural numbers or the reals. By taking the bounds to be `⊤` and `⊥`, we obtain the standard definition in the case that the index is `ℕ∞` or `ℝ≥0∞`. -/ open Filter Order TopologicalSpace open scoped Classical MeasureTheory NNReal ENNReal Topology namespace MeasureTheory variable {Ω β ι : Type*} {m : MeasurableSpace Ω} /-- Hitting time: given a stochastic process `u` and a set `s`, `hitting u s n m` is the first time `u` is in `s` after time `n` and before time `m` (if `u` does not hit `s` after time `n` and before `m` then the hitting time is simply `m`). The hitting time is a stopping time if the process is adapted and discrete. -/ noncomputable def hitting [Preorder ι] [InfSet ι] (u : ι → Ω → β) (s : Set β) (n m : ι) : Ω → ι := fun x => if ∃ j ∈ Set.Icc n m, u j x ∈ s then sInf (Set.Icc n m ∩ {i : ι | u i x ∈ s}) else m #align measure_theory.hitting MeasureTheory.hitting #adaptation_note /-- nightly-2024-03-16: added to replace simp [hitting] -/ theorem hitting_def [Preorder ι] [InfSet ι] (u : ι → Ω → β) (s : Set β) (n m : ι) : hitting u s n m = fun x => if ∃ j ∈ Set.Icc n m, u j x ∈ s then sInf (Set.Icc n m ∩ {i : ι | u i x ∈ s}) else m := rfl section Inequalities variable [ConditionallyCompleteLinearOrder ι] {u : ι → Ω → β} {s : Set β} {n i : ι} {ω : Ω} /-- This lemma is strictly weaker than `hitting_of_le`. -/ theorem hitting_of_lt {m : ι} (h : m < n) : hitting u s n m ω = m := by simp_rw [hitting] have h_not : ¬∃ (j : ι) (_ : j ∈ Set.Icc n m), u j ω ∈ s := by push_neg intro j rw [Set.Icc_eq_empty_of_lt h] simp only [Set.mem_empty_iff_false, IsEmpty.forall_iff] simp only [exists_prop] at h_not simp only [h_not, if_false] #align measure_theory.hitting_of_lt MeasureTheory.hitting_of_lt theorem hitting_le {m : ι} (ω : Ω) : hitting u s n m ω ≤ m := by simp only [hitting] split_ifs with h · obtain ⟨j, hj₁, hj₂⟩ := h change j ∈ {i | u i ω ∈ s} at hj₂ exact (csInf_le (BddBelow.inter_of_left bddBelow_Icc) (Set.mem_inter hj₁ hj₂)).trans hj₁.2 · exact le_rfl #align measure_theory.hitting_le MeasureTheory.hitting_le theorem not_mem_of_lt_hitting {m k : ι} (hk₁ : k < hitting u s n m ω) (hk₂ : n ≤ k) : u k ω ∉ s := by classical intro h have hexists : ∃ j ∈ Set.Icc n m, u j ω ∈ s := ⟨k, ⟨hk₂, le_trans hk₁.le <| hitting_le _⟩, h⟩ refine not_le.2 hk₁ ?_ simp_rw [hitting, if_pos hexists] exact csInf_le bddBelow_Icc.inter_of_left ⟨⟨hk₂, le_trans hk₁.le <| hitting_le _⟩, h⟩ #align measure_theory.not_mem_of_lt_hitting MeasureTheory.not_mem_of_lt_hitting theorem hitting_eq_end_iff {m : ι} : hitting u s n m ω = m ↔ (∃ j ∈ Set.Icc n m, u j ω ∈ s) → sInf (Set.Icc n m ∩ {i : ι | u i ω ∈ s}) = m := by rw [hitting, ite_eq_right_iff] #align measure_theory.hitting_eq_end_iff MeasureTheory.hitting_eq_end_iff
Mathlib/Probability/Process/HittingTime.lean
102
109
theorem hitting_of_le {m : ι} (hmn : m ≤ n) : hitting u s n m ω = m := by
obtain rfl | h := le_iff_eq_or_lt.1 hmn · rw [hitting, ite_eq_right_iff, forall_exists_index] conv => intro; rw [Set.mem_Icc, Set.Icc_self, and_imp, and_imp] intro i hi₁ hi₂ hi rw [Set.inter_eq_left.2, csInf_singleton] exact Set.singleton_subset_iff.2 (le_antisymm hi₂ hi₁ ▸ hi) · exact hitting_of_lt h
/- Copyright (c) 2024 Jeremy Tan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Tan -/ import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.SpecificLimits.Normed /-! # Abel's limit theorem If a real or complex power series for a function has radius of convergence 1 and the series is only known to converge conditionally at 1, Abel's limit theorem gives the value at 1 as the limit of the function at 1 from the left. "Left" for complex numbers means within a fixed cone opening to the left with angle less than `π`. ## Main theorems * `Complex.tendsto_tsum_powerSeries_nhdsWithin_stolzCone`: Abel's limit theorem for complex power series. * `Real.tendsto_tsum_powerSeries_nhdsWithin_lt`: Abel's limit theorem for real power series. ## References * https://planetmath.org/proofofabelslimittheorem * https://en.wikipedia.org/wiki/Abel%27s_theorem -/ open Filter Finset open scoped Topology namespace Complex section StolzSet open Real /-- The Stolz set for a given `M`, roughly teardrop-shaped with the tip at 1 but tending to the open unit disc as `M` tends to infinity. -/ def stolzSet (M : ℝ) : Set ℂ := {z | ‖z‖ < 1 ∧ ‖1 - z‖ < M * (1 - ‖z‖)} /-- The cone to the left of `1` with angle `2θ` such that `tan θ = s`. -/ def stolzCone (s : ℝ) : Set ℂ := {z | |z.im| < s * (1 - z.re)} theorem stolzSet_empty {M : ℝ} (hM : M ≤ 1) : stolzSet M = ∅ := by ext z rw [stolzSet, Set.mem_setOf, Set.mem_empty_iff_false, iff_false, not_and, not_lt, ← sub_pos] intro zn calc _ ≤ 1 * (1 - ‖z‖) := mul_le_mul_of_nonneg_right hM zn.le _ = ‖(1 : ℂ)‖ - ‖z‖ := by rw [one_mul, norm_one] _ ≤ _ := norm_sub_norm_le _ _
Mathlib/Analysis/Complex/AbelLimit.lean
56
66
theorem nhdsWithin_lt_le_nhdsWithin_stolzSet {M : ℝ} (hM : 1 < M) : (𝓝[<] 1).map ofReal' ≤ 𝓝[stolzSet M] 1 := by
rw [← tendsto_id'] refine tendsto_map' <| tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within ofReal' (tendsto_nhdsWithin_of_tendsto_nhds <| ofRealCLM.continuous.tendsto' 1 1 rfl) ?_ simp only [eventually_iff, norm_eq_abs, abs_ofReal, abs_lt, mem_nhdsWithin] refine ⟨Set.Ioo 0 2, isOpen_Ioo, by norm_num, fun x hx ↦ ?_⟩ simp only [Set.mem_inter_iff, Set.mem_Ioo, Set.mem_Iio] at hx simp only [Set.mem_setOf_eq, stolzSet, ← ofReal_one, ← ofReal_sub, norm_eq_abs, abs_ofReal, abs_of_pos hx.1.1, abs_of_pos <| sub_pos.mpr hx.2] exact ⟨hx.2, lt_mul_left (sub_pos.mpr hx.2) hM⟩
/- 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)] theorem prod_one_cons : (1 :: l).prod = l.prod := by rw [prod, foldl, mul_one] @[to_additive] theorem prod_map_one {l : List ι} : (l.map fun _ => (1 : M)).prod = 1 := by induction l with | nil => rfl | cons hd tl ih => rw [map_cons, prod_one_cons, ih] end MulOneClass section Monoid variable [Monoid M] [Monoid N] [Monoid P] {l l₁ l₂ : List M} {a : M} @[to_additive (attr := simp)]
Mathlib/Algebra/BigOperators/Group/List.lean
95
99
theorem prod_cons : (a :: l).prod = a * l.prod := calc (a :: l).prod = foldl (· * ·) (a * 1) l := by
simp only [List.prod, foldl_cons, one_mul, mul_one] _ = _ := foldl_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.Order.RelIso.Set import Mathlib.Data.Multiset.Sort import Mathlib.Data.List.NodupEquivFin import Mathlib.Data.Finset.Lattice import Mathlib.Data.Fintype.Card #align_import data.finset.sort from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" /-! # Construct a sorted list from a finset. -/ namespace Finset open Multiset Nat variable {α β : Type*} /-! ### sort -/ section sort variable (r : α → α → Prop) [DecidableRel r] [IsTrans α r] [IsAntisymm α r] [IsTotal α r] /-- `sort s` constructs a sorted list from the unordered set `s`. (Uses merge sort algorithm.) -/ def sort (s : Finset α) : List α := Multiset.sort r s.1 #align finset.sort Finset.sort @[simp] theorem sort_sorted (s : Finset α) : List.Sorted r (sort r s) := Multiset.sort_sorted _ _ #align finset.sort_sorted Finset.sort_sorted @[simp] theorem sort_eq (s : Finset α) : ↑(sort r s) = s.1 := Multiset.sort_eq _ _ #align finset.sort_eq Finset.sort_eq @[simp] theorem sort_nodup (s : Finset α) : (sort r s).Nodup := (by rw [sort_eq]; exact s.2 : @Multiset.Nodup α (sort r s)) #align finset.sort_nodup Finset.sort_nodup @[simp] theorem sort_toFinset [DecidableEq α] (s : Finset α) : (sort r s).toFinset = s := List.toFinset_eq (sort_nodup r s) ▸ eq_of_veq (sort_eq r s) #align finset.sort_to_finset Finset.sort_toFinset @[simp] theorem mem_sort {s : Finset α} {a : α} : a ∈ sort r s ↔ a ∈ s := Multiset.mem_sort _ #align finset.mem_sort Finset.mem_sort @[simp] theorem length_sort {s : Finset α} : (sort r s).length = s.card := Multiset.length_sort _ #align finset.length_sort Finset.length_sort @[simp] theorem sort_empty : sort r ∅ = [] := Multiset.sort_zero r #align finset.sort_empty Finset.sort_empty @[simp] theorem sort_singleton (a : α) : sort r {a} = [a] := Multiset.sort_singleton r a #align finset.sort_singleton Finset.sort_singleton open scoped List in
Mathlib/Data/Finset/Sort.lean
79
81
theorem sort_perm_toList (s : Finset α) : sort r s ~ s.toList := by
rw [← Multiset.coe_eq_coe] simp only [coe_toList, sort_eq]
/- 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.Group.Instances import Mathlib.Analysis.Convex.Segment import Mathlib.Tactic.GCongr #align_import analysis.convex.star from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Star-convex sets This files defines star-convex sets (aka star domains, star-shaped set, radially convex set). A set is star-convex at `x` if every segment from `x` to a point in the set is contained in the set. This is the prototypical example of a contractible set in homotopy theory (by scaling every point towards `x`), but has wider uses. Note that this has nothing to do with star rings, `Star` and co. ## Main declarations * `StarConvex 𝕜 x s`: `s` is star-convex at `x` with scalars `𝕜`. ## Implementation notes Instead of saying that a set is star-convex, we say a set is star-convex *at a point*. This has the advantage of allowing us to talk about convexity as being "everywhere star-convexity" and of making the union of star-convex sets be star-convex. Incidentally, this choice means we don't need to assume a set is nonempty for it to be star-convex. Concretely, the empty set is star-convex at every point. ## TODO Balanced sets are star-convex. The closure of a star-convex set is star-convex. Star-convex sets are contractible. A nonempty open star-convex set in `ℝ^n` is diffeomorphic to the entire space. -/ open Set open Convex Pointwise variable {𝕜 E F : Type*} section OrderedSemiring variable [OrderedSemiring 𝕜] section AddCommMonoid variable [AddCommMonoid E] [AddCommMonoid F] section SMul variable (𝕜) [SMul 𝕜 E] [SMul 𝕜 F] (x : E) (s : Set E) /-- Star-convexity of sets. `s` is star-convex at `x` if every segment from `x` to a point in `s` is contained in `s`. -/ def StarConvex : Prop := ∀ ⦃y : E⦄, y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → a • x + b • y ∈ s #align star_convex StarConvex variable {𝕜 x s} {t : Set E}
Mathlib/Analysis/Convex/Star.lean
75
80
theorem starConvex_iff_segment_subset : StarConvex 𝕜 x s ↔ ∀ ⦃y⦄, y ∈ s → [x -[𝕜] y] ⊆ s := by
constructor · rintro h y hy z ⟨a, b, ha, hb, hab, rfl⟩ exact h hy ha hb hab · rintro h y hy a b ha hb hab exact h hy ⟨a, b, ha, hb, hab, rfl⟩
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl -/ import Mathlib.Algebra.Order.Monoid.Defs import Mathlib.Algebra.Order.Sub.Defs import Mathlib.Util.AssertExists #align_import algebra.order.group.defs from "leanprover-community/mathlib"@"b599f4e4e5cf1fbcb4194503671d3d9e569c1fce" /-! # Ordered groups This file develops the basics of ordered groups. ## Implementation details Unfortunately, the number of `'` appended to lemmas in this file may differ between the multiplicative and the additive version of a lemma. The reason is that we did not want to change existing names in the library. -/ open Function universe u variable {α : Type u} /-- An ordered additive commutative group is an additive commutative group with a partial order in which addition is strictly monotone. -/ class OrderedAddCommGroup (α : Type u) extends AddCommGroup α, PartialOrder α where /-- Addition is monotone in an ordered additive commutative group. -/ protected add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b #align ordered_add_comm_group OrderedAddCommGroup /-- An ordered commutative group is a commutative group with a partial order in which multiplication is strictly monotone. -/ class OrderedCommGroup (α : Type u) extends CommGroup α, PartialOrder α where /-- Multiplication is monotone in an ordered commutative group. -/ protected mul_le_mul_left : ∀ a b : α, a ≤ b → ∀ c : α, c * a ≤ c * b #align ordered_comm_group OrderedCommGroup attribute [to_additive] OrderedCommGroup @[to_additive] instance OrderedCommGroup.to_covariantClass_left_le (α : Type u) [OrderedCommGroup α] : CovariantClass α α (· * ·) (· ≤ ·) where elim a b c bc := OrderedCommGroup.mul_le_mul_left b c bc a #align ordered_comm_group.to_covariant_class_left_le OrderedCommGroup.to_covariantClass_left_le #align ordered_add_comm_group.to_covariant_class_left_le OrderedAddCommGroup.to_covariantClass_left_le -- See note [lower instance priority] @[to_additive OrderedAddCommGroup.toOrderedCancelAddCommMonoid] instance (priority := 100) OrderedCommGroup.toOrderedCancelCommMonoid [OrderedCommGroup α] : OrderedCancelCommMonoid α := { ‹OrderedCommGroup α› with le_of_mul_le_mul_left := fun a b c ↦ le_of_mul_le_mul_left' } #align ordered_comm_group.to_ordered_cancel_comm_monoid OrderedCommGroup.toOrderedCancelCommMonoid #align ordered_add_comm_group.to_ordered_cancel_add_comm_monoid OrderedAddCommGroup.toOrderedCancelAddCommMonoid example (α : Type u) [OrderedAddCommGroup α] : CovariantClass α α (swap (· + ·)) (· < ·) := IsRightCancelAdd.covariant_swap_add_lt_of_covariant_swap_add_le α -- Porting note: this instance is not used, -- and causes timeouts after lean4#2210. -- It was introduced in https://github.com/leanprover-community/mathlib/pull/17564 -- but without the motivation clearly explained. /-- A choice-free shortcut instance. -/ @[to_additive "A choice-free shortcut instance."] theorem OrderedCommGroup.to_contravariantClass_left_le (α : Type u) [OrderedCommGroup α] : ContravariantClass α α (· * ·) (· ≤ ·) where elim a b c bc := by simpa using mul_le_mul_left' bc a⁻¹ #align ordered_comm_group.to_contravariant_class_left_le OrderedCommGroup.to_contravariantClass_left_le #align ordered_add_comm_group.to_contravariant_class_left_le OrderedAddCommGroup.to_contravariantClass_left_le -- Porting note: this instance is not used, -- and causes timeouts after lean4#2210. -- See further explanation on `OrderedCommGroup.to_contravariantClass_left_le`. /-- A choice-free shortcut instance. -/ @[to_additive "A choice-free shortcut instance."]
Mathlib/Algebra/Order/Group/Defs.lean
82
84
theorem OrderedCommGroup.to_contravariantClass_right_le (α : Type u) [OrderedCommGroup α] : ContravariantClass α α (swap (· * ·)) (· ≤ ·) where elim a b c bc := by
simpa using mul_le_mul_right' bc a⁻¹
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Finset.Prod import Mathlib.Data.Set.Finite #align_import data.finset.n_ary from "leanprover-community/mathlib"@"eba7871095e834365616b5e43c8c7bb0b37058d0" /-! # N-ary images of finsets This file defines `Finset.image₂`, the binary image of finsets. This is the finset version of `Set.image2`. This is mostly useful to define pointwise operations. ## Notes This file is very similar to `Data.Set.NAry`, `Order.Filter.NAry` and `Data.Option.NAry`. Please keep them in sync. We do not define `Finset.image₃` as its only purpose would be to prove properties of `Finset.image₂` and `Set.image2` already fulfills this task. -/ open Function Set variable {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type*} namespace Finset variable [DecidableEq α'] [DecidableEq β'] [DecidableEq γ] [DecidableEq γ'] [DecidableEq δ] [DecidableEq δ'] [DecidableEq ε] [DecidableEq ε'] {f f' : α → β → γ} {g g' : α → β → γ → δ} {s s' : Finset α} {t t' : Finset β} {u u' : Finset γ} {a a' : α} {b b' : β} {c : γ} /-- The image of a binary function `f : α → β → γ` as a function `Finset α → Finset β → Finset γ`. Mathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/ def image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) : Finset γ := (s ×ˢ t).image <| uncurry f #align finset.image₂ Finset.image₂ @[simp] theorem mem_image₂ : c ∈ image₂ f s t ↔ ∃ a ∈ s, ∃ b ∈ t, f a b = c := by simp [image₂, and_assoc] #align finset.mem_image₂ Finset.mem_image₂ @[simp, norm_cast] theorem coe_image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) : (image₂ f s t : Set γ) = Set.image2 f s t := Set.ext fun _ => mem_image₂ #align finset.coe_image₂ Finset.coe_image₂ theorem card_image₂_le (f : α → β → γ) (s : Finset α) (t : Finset β) : (image₂ f s t).card ≤ s.card * t.card := card_image_le.trans_eq <| card_product _ _ #align finset.card_image₂_le Finset.card_image₂_le theorem card_image₂_iff : (image₂ f s t).card = s.card * t.card ↔ (s ×ˢ t : Set (α × β)).InjOn fun x => f x.1 x.2 := by rw [← card_product, ← coe_product] exact card_image_iff #align finset.card_image₂_iff Finset.card_image₂_iff theorem card_image₂ (hf : Injective2 f) (s : Finset α) (t : Finset β) : (image₂ f s t).card = s.card * t.card := (card_image_of_injective _ hf.uncurry).trans <| card_product _ _ #align finset.card_image₂ Finset.card_image₂ theorem mem_image₂_of_mem (ha : a ∈ s) (hb : b ∈ t) : f a b ∈ image₂ f s t := mem_image₂.2 ⟨a, ha, b, hb, rfl⟩ #align finset.mem_image₂_of_mem Finset.mem_image₂_of_mem theorem mem_image₂_iff (hf : Injective2 f) : f a b ∈ image₂ f s t ↔ a ∈ s ∧ b ∈ t := by rw [← mem_coe, coe_image₂, mem_image2_iff hf, mem_coe, mem_coe] #align finset.mem_image₂_iff Finset.mem_image₂_iff theorem image₂_subset (hs : s ⊆ s') (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s' t' := by rw [← coe_subset, coe_image₂, coe_image₂] exact image2_subset hs ht #align finset.image₂_subset Finset.image₂_subset theorem image₂_subset_left (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s t' := image₂_subset Subset.rfl ht #align finset.image₂_subset_left Finset.image₂_subset_left theorem image₂_subset_right (hs : s ⊆ s') : image₂ f s t ⊆ image₂ f s' t := image₂_subset hs Subset.rfl #align finset.image₂_subset_right Finset.image₂_subset_right theorem image_subset_image₂_left (hb : b ∈ t) : s.image (fun a => f a b) ⊆ image₂ f s t := image_subset_iff.2 fun _ ha => mem_image₂_of_mem ha hb #align finset.image_subset_image₂_left Finset.image_subset_image₂_left theorem image_subset_image₂_right (ha : a ∈ s) : t.image (fun b => f a b) ⊆ image₂ f s t := image_subset_iff.2 fun _ => mem_image₂_of_mem ha #align finset.image_subset_image₂_right Finset.image_subset_image₂_right theorem forall_image₂_iff {p : γ → Prop} : (∀ z ∈ image₂ f s t, p z) ↔ ∀ x ∈ s, ∀ y ∈ t, p (f x y) := by simp_rw [← mem_coe, coe_image₂, forall_image2_iff] #align finset.forall_image₂_iff Finset.forall_image₂_iff @[simp] theorem image₂_subset_iff : image₂ f s t ⊆ u ↔ ∀ x ∈ s, ∀ y ∈ t, f x y ∈ u := forall_image₂_iff #align finset.image₂_subset_iff Finset.image₂_subset_iff theorem image₂_subset_iff_left : image₂ f s t ⊆ u ↔ ∀ a ∈ s, (t.image fun b => f a b) ⊆ u := by simp_rw [image₂_subset_iff, image_subset_iff] #align finset.image₂_subset_iff_left Finset.image₂_subset_iff_left
Mathlib/Data/Finset/NAry.lean
112
113
theorem image₂_subset_iff_right : image₂ f s t ⊆ u ↔ ∀ b ∈ t, (s.image fun a => f a b) ⊆ u := by
simp_rw [image₂_subset_iff, image_subset_iff, @forall₂_swap α]
/- 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.Logic.Basic import Mathlib.Tactic.Convert import Mathlib.Tactic.SplitIfs #align_import logic.lemmas from "leanprover-community/mathlib"@"2ed7e4aec72395b6a7c3ac4ac7873a7a43ead17c" /-! # More basic logic properties A few more logic lemmas. These are in their own file, rather than `Logic.Basic`, because it is convenient to be able to use the `split_ifs` tactic. ## Implementation notes We spell those lemmas out with `dite` and `ite` rather than the `if then else` notation because this would result in less delta-reduced statements. -/ protected alias ⟨HEq.eq, Eq.heq⟩ := heq_iff_eq #align heq.eq HEq.eq #align eq.heq Eq.heq variable {α : Sort*} {p q r : Prop} [Decidable p] [Decidable q] {a b c : α}
Mathlib/Logic/Lemmas.lean
28
31
theorem dite_dite_distrib_left {a : p → α} {b : ¬p → q → α} {c : ¬p → ¬q → α} : (dite p a fun hp ↦ dite q (b hp) (c hp)) = dite q (fun hq ↦ (dite p a) fun hp ↦ b hp hq) fun hq ↦ (dite p a) fun hp ↦ c hp hq := by
split_ifs <;> rfl
/- 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.Analysis.Convolution import Mathlib.Analysis.Calculus.BumpFunction.Normed import Mathlib.MeasureTheory.Integral.Average import Mathlib.MeasureTheory.Covering.Differentiation import Mathlib.MeasureTheory.Covering.BesicovitchVectorSpace import Mathlib.MeasureTheory.Measure.Haar.Unique #align_import analysis.convolution from "leanprover-community/mathlib"@"8905e5ed90859939681a725b00f6063e65096d95" /-! # Convolution with a bump function In this file we prove lemmas about convolutions `(φ.normed μ ⋆[lsmul ℝ ℝ, μ] g) x₀`, where `φ : ContDiffBump 0` is a smooth bump function. We prove that this convolution is equal to `g x₀` if `g` is a constant on `Metric.ball x₀ φ.rOut`. We also provide estimates in the case if `g x` is close to `g x₀` on this ball. ## Main results - `ContDiffBump.convolution_tendsto_right_of_continuous`: Let `g` be a continuous function; let `φ i` be a family of `ContDiffBump 0` functions with. If `(φ i).rOut` tends to zero along a filter `l`, then `((φ i).normed μ ⋆[lsmul ℝ ℝ, μ] g) x₀` tends to `g x₀` along the same filter. - `ContDiffBump.convolution_tendsto_right`: generalization of the above lemma. - `ContDiffBump.ae_convolution_tendsto_right_of_locallyIntegrable`: let `g` be a locally integrable function. Then the convolution of `g` with a family of bump functions with support tending to `0` converges almost everywhere to `g`. ## Keywords convolution, smooth function, bump function -/ universe uG uE' open ContinuousLinearMap Metric MeasureTheory Filter Function Measure Set open scoped Convolution Topology namespace ContDiffBump variable {G : Type uG} {E' : Type uE'} [NormedAddCommGroup E'] {g : G → E'} [MeasurableSpace G] {μ : MeasureTheory.Measure G} [NormedSpace ℝ E'] [NormedAddCommGroup G] [NormedSpace ℝ G] [HasContDiffBump G] [CompleteSpace E'] {φ : ContDiffBump (0 : G)} {x₀ : G} /-- If `φ` is a bump function, compute `(φ ⋆ g) x₀` if `g` is constant on `Metric.ball x₀ φ.rOut`. -/
Mathlib/Analysis/Calculus/BumpFunction/Convolution.lean
54
56
theorem convolution_eq_right {x₀ : G} (hg : ∀ x ∈ ball x₀ φ.rOut, g x = g x₀) : (φ ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀ = integral μ φ • g x₀ := by
simp_rw [convolution_eq_right' _ φ.support_eq.subset hg, lsmul_apply, integral_smul_const]
/- Copyright (c) 2019 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot -/ import Mathlib.Topology.UniformSpace.UniformEmbedding #align_import topology.uniform_space.pi from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9" /-! # Indexed product of uniform spaces -/ noncomputable section open scoped Uniformity Topology open Filter UniformSpace Function Set universe u variable {ι ι' β : Type*} (α : ι → Type u) [U : ∀ i, UniformSpace (α i)] [UniformSpace β] instance Pi.uniformSpace : UniformSpace (∀ i, α i) := UniformSpace.ofCoreEq (⨅ i, UniformSpace.comap (eval i) (U i)).toCore Pi.topologicalSpace <| Eq.symm toTopologicalSpace_iInf #align Pi.uniform_space Pi.uniformSpace lemma Pi.uniformSpace_eq : Pi.uniformSpace α = ⨅ i, UniformSpace.comap (eval i) (U i) := by ext : 1; rfl theorem Pi.uniformity : 𝓤 (∀ i, α i) = ⨅ i : ι, (Filter.comap fun a => (a.1 i, a.2 i)) (𝓤 (α i)) := iInf_uniformity #align Pi.uniformity Pi.uniformity variable {α} instance [Countable ι] [∀ i, IsCountablyGenerated (𝓤 (α i))] : IsCountablyGenerated (𝓤 (∀ i, α i)) := by rw [Pi.uniformity] infer_instance
Mathlib/Topology/UniformSpace/Pi.lean
46
49
theorem uniformContinuous_pi {β : Type*} [UniformSpace β] {f : β → ∀ i, α i} : UniformContinuous f ↔ ∀ i, UniformContinuous fun x => f x i := by
-- Porting note: required `Function.comp` to close simp only [UniformContinuous, Pi.uniformity, tendsto_iInf, tendsto_comap_iff, Function.comp]
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Homology.Homotopy import Mathlib.Algebra.Category.ModuleCat.Abelian import Mathlib.Algebra.Category.ModuleCat.Subobject import Mathlib.CategoryTheory.Limits.Shapes.ConcreteCategory #align_import algebra.homology.Module from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Complexes of modules We provide some additional API to work with homological complexes in `ModuleCat R`. -/ universe v u open scoped Classical noncomputable section open CategoryTheory Limits HomologicalComplex variable {R : Type v} [Ring R] variable {ι : Type*} {c : ComplexShape ι} {C D : HomologicalComplex (ModuleCat.{u} R) c} namespace ModuleCat /-- To prove that two maps out of a homology group are equal, it suffices to check they are equal on the images of cycles. -/ theorem homology'_ext {L M N K : ModuleCat.{u} R} {f : L ⟶ M} {g : M ⟶ N} (w : f ≫ g = 0) {h k : homology' f g w ⟶ K} (w : ∀ x : LinearMap.ker g, h (cokernel.π (imageToKernel _ _ w) (toKernelSubobject x)) = k (cokernel.π (imageToKernel _ _ w) (toKernelSubobject x))) : h = k := by refine Concrete.cokernel_funext fun n => ?_ -- Porting note: as `equiv_rw` was not ported, it was replaced by `Equiv.surjective` -- Gosh it would be nice if `equiv_rw` could directly use an isomorphism, or an enriched `≃`. obtain ⟨n, rfl⟩ := (kernelSubobjectIso g ≪≫ ModuleCat.kernelIsoKer g).toLinearEquiv.toEquiv.symm.surjective n exact w n set_option linter.uppercaseLean3 false in #align Module.homology_ext ModuleCat.homology'_ext /-- Bundle an element `C.X i` such that `C.dFrom i x = 0` as a term of `C.cycles i`. -/ abbrev toCycles' {C : HomologicalComplex (ModuleCat.{u} R) c} {i : ι} (x : LinearMap.ker (C.dFrom i)) : (C.cycles' i : Type u) := toKernelSubobject x set_option linter.uppercaseLean3 false in #align Module.to_cycles ModuleCat.toCycles' @[ext] theorem cycles'_ext {C : HomologicalComplex (ModuleCat.{u} R) c} {i : ι} {x y : (C.cycles' i : Type u)} (w : (C.cycles' i).arrow x = (C.cycles' i).arrow y) : x = y := by apply_fun (C.cycles' i).arrow using (ModuleCat.mono_iff_injective _).mp (cycles' C i).arrow_mono exact w set_option linter.uppercaseLean3 false in #align Module.cycles_ext ModuleCat.cycles'_ext -- Porting note: both proofs by `rw` were proofs by `simp` which no longer worked -- see https://github.com/leanprover-community/mathlib4/issues/5026 @[simp] theorem cycles'Map_toCycles' (f : C ⟶ D) {i : ι} (x : LinearMap.ker (C.dFrom i)) : (cycles'Map f i) (toCycles' x) = toCycles' ⟨f.f i x.1, by -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 rw [LinearMap.mem_ker]; erw [Hom.comm_from_apply, x.2, map_zero]⟩ := by ext -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [cycles'Map_arrow_apply, toKernelSubobject_arrow, toKernelSubobject_arrow] rfl set_option linter.uppercaseLean3 false in #align Module.cycles_map_to_cycles ModuleCat.cycles'Map_toCycles' /-- Build a term of `C.homology i` from an element `C.X i` such that `C.d_from i x = 0`. -/ abbrev toHomology' {C : HomologicalComplex (ModuleCat.{u} R) c} {i : ι} (x : LinearMap.ker (C.dFrom i)) : C.homology' i := homology'.π (C.dTo i) (C.dFrom i) _ (toCycles' x) set_option linter.uppercaseLean3 false in #align Module.to_homology ModuleCat.toHomology' @[ext]
Mathlib/Algebra/Homology/ModuleCat.lean
91
93
theorem homology'_ext' {M : ModuleCat R} (i : ι) {h k : C.homology' i ⟶ M} (w : ∀ x : LinearMap.ker (C.dFrom i), h (toHomology' x) = k (toHomology' x)) : h = k := by
apply homology'_ext _ w
/- Copyright (c) 2021 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.Rayleigh import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Algebra.DirectSum.Decomposition import Mathlib.LinearAlgebra.Eigenspace.Minpoly #align_import analysis.inner_product_space.spectrum from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1" /-! # Spectral theory of self-adjoint operators This file covers the spectral theory of self-adjoint operators on an inner product space. The first part of the file covers general properties, true without any condition on boundedness or compactness of the operator or finite-dimensionality of the underlying space, notably: * `LinearMap.IsSymmetric.conj_eigenvalue_eq_self`: the eigenvalues are real * `LinearMap.IsSymmetric.orthogonalFamily_eigenspaces`: the eigenspaces are orthogonal * `LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces`: the restriction of the operator to the mutual orthogonal complement of the eigenspaces has, itself, no eigenvectors The second part of the file covers properties of self-adjoint operators in finite dimension. Letting `T` be a self-adjoint operator on a finite-dimensional inner product space `T`, * The definition `LinearMap.IsSymmetric.diagonalization` provides a linear isometry equivalence `E` to the direct sum of the eigenspaces of `T`. The theorem `LinearMap.IsSymmetric.diagonalization_apply_self_apply` states that, when `T` is transferred via this equivalence to an operator on the direct sum, it acts diagonally. * The definition `LinearMap.IsSymmetric.eigenvectorBasis` provides an orthonormal basis for `E` consisting of eigenvectors of `T`, with `LinearMap.IsSymmetric.eigenvalues` giving the corresponding list of eigenvalues, as real numbers. The definition `LinearMap.IsSymmetric.eigenvectorBasis` gives the associated linear isometry equivalence from `E` to Euclidean space, and the theorem `LinearMap.IsSymmetric.eigenvectorBasis_apply_self_apply` states that, when `T` is transferred via this equivalence to an operator on Euclidean space, it acts diagonally. These are forms of the *diagonalization theorem* for self-adjoint operators on finite-dimensional inner product spaces. ## TODO Spectral theory for compact self-adjoint operators, bounded self-adjoint operators. ## Tags self-adjoint operator, spectral theorem, diagonalization theorem -/ variable {𝕜 : Type*} [RCLike 𝕜] variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] local notation "⟪" x ", " y "⟫" => @inner 𝕜 E _ x y open scoped ComplexConjugate open Module.End namespace LinearMap namespace IsSymmetric variable {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) /-- A self-adjoint operator preserves orthogonal complements of its eigenspaces. -/
Mathlib/Analysis/InnerProductSpace/Spectrum.lean
68
72
theorem invariant_orthogonalComplement_eigenspace (μ : 𝕜) (v : E) (hv : v ∈ (eigenspace T μ)ᗮ) : T v ∈ (eigenspace T μ)ᗮ := by
intro w hw have : T w = (μ : 𝕜) • w := by rwa [mem_eigenspace_iff] at hw simp [← hT w, this, inner_smul_left, hv w hw]
/- Copyright (c) 2021 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.SetTheory.Cardinal.ToNat import Mathlib.Data.Nat.PartENat #align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" /-! # Projection from cardinal numbers to `PartENat` In this file we define the projection `Cardinal.toPartENat` and prove basic properties of this projection. -/ universe u v open Function variable {α : Type u} namespace Cardinal /-- This function sends finite cardinals to the corresponding natural, and infinite cardinals to `⊤`. -/ noncomputable def toPartENat : Cardinal →+o PartENat := .comp { (PartENat.withTopAddEquiv.symm : ℕ∞ →+ PartENat), (PartENat.withTopOrderIso.symm : ℕ∞ →o PartENat) with } toENat #align cardinal.to_part_enat Cardinal.toPartENat @[simp] theorem partENatOfENat_toENat (c : Cardinal) : (toENat c : PartENat) = toPartENat c := rfl @[simp]
Mathlib/SetTheory/Cardinal/PartENat.lean
39
40
theorem toPartENat_natCast (n : ℕ) : toPartENat n = n := by
simp only [← partENatOfENat_toENat, toENat_nat, PartENat.ofENat_coe]
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Analysis.NormedSpace.AffineIsometry import Mathlib.Topology.Algebra.ContinuousAffineMap import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace #align_import analysis.normed_space.continuous_affine_map from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" /-! # Continuous affine maps between normed spaces. This file develops the theory of continuous affine maps between affine spaces modelled on normed spaces. In the particular case that the affine spaces are just normed vector spaces `V`, `W`, we define a norm on the space of continuous affine maps by defining the norm of `f : V →ᴬ[𝕜] W` to be `‖f‖ = max ‖f 0‖ ‖f.cont_linear‖`. This is chosen so that we have a linear isometry: `(V →ᴬ[𝕜] W) ≃ₗᵢ[𝕜] W × (V →L[𝕜] W)`. The abstract picture is that for an affine space `P` modelled on a vector space `V`, together with a vector space `W`, there is an exact sequence of `𝕜`-modules: `0 → C → A → L → 0` where `C`, `A` are the spaces of constant and affine maps `P → W` and `L` is the space of linear maps `V → W`. Any choice of a base point in `P` corresponds to a splitting of this sequence so in particular if we take `P = V`, using `0 : V` as the base point provides a splitting, and we prove this is an isometric decomposition. On the other hand, choosing a base point breaks the affine invariance so the norm fails to be submultiplicative: for a composition of maps, we have only `‖f.comp g‖ ≤ ‖f‖ * ‖g‖ + ‖f 0‖`. ## Main definitions: * `ContinuousAffineMap.contLinear` * `ContinuousAffineMap.hasNorm` * `ContinuousAffineMap.norm_comp_le` * `ContinuousAffineMap.toConstProdContinuousLinearMap` -/ namespace ContinuousAffineMap variable {𝕜 R V W W₂ P Q Q₂ : Type*} variable [NormedAddCommGroup V] [MetricSpace P] [NormedAddTorsor V P] variable [NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q] variable [NormedAddCommGroup W₂] [MetricSpace Q₂] [NormedAddTorsor W₂ Q₂] variable [NormedField R] [NormedSpace R V] [NormedSpace R W] [NormedSpace R W₂] variable [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 V] [NormedSpace 𝕜 W] [NormedSpace 𝕜 W₂] /-- The linear map underlying a continuous affine map is continuous. -/ def contLinear (f : P →ᴬ[R] Q) : V →L[R] W := { f.linear with toFun := f.linear cont := by rw [AffineMap.continuous_linear_iff]; exact f.cont } #align continuous_affine_map.cont_linear ContinuousAffineMap.contLinear @[simp] theorem coe_contLinear (f : P →ᴬ[R] Q) : (f.contLinear : V → W) = f.linear := rfl #align continuous_affine_map.coe_cont_linear ContinuousAffineMap.coe_contLinear @[simp] theorem coe_contLinear_eq_linear (f : P →ᴬ[R] Q) : (f.contLinear : V →ₗ[R] W) = (f : P →ᵃ[R] Q).linear := by ext; rfl #align continuous_affine_map.coe_cont_linear_eq_linear ContinuousAffineMap.coe_contLinear_eq_linear @[simp] theorem coe_mk_const_linear_eq_linear (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →ᴬ[R] Q).contLinear : V → W) = f.linear := rfl #align continuous_affine_map.coe_mk_const_linear_eq_linear ContinuousAffineMap.coe_mk_const_linear_eq_linear theorem coe_linear_eq_coe_contLinear (f : P →ᴬ[R] Q) : ((f : P →ᵃ[R] Q).linear : V → W) = (⇑f.contLinear : V → W) := rfl #align continuous_affine_map.coe_linear_eq_coe_cont_linear ContinuousAffineMap.coe_linear_eq_coe_contLinear @[simp] theorem comp_contLinear (f : P →ᴬ[R] Q) (g : Q →ᴬ[R] Q₂) : (g.comp f).contLinear = g.contLinear.comp f.contLinear := rfl #align continuous_affine_map.comp_cont_linear ContinuousAffineMap.comp_contLinear @[simp] theorem map_vadd (f : P →ᴬ[R] Q) (p : P) (v : V) : f (v +ᵥ p) = f.contLinear v +ᵥ f p := f.map_vadd' p v #align continuous_affine_map.map_vadd ContinuousAffineMap.map_vadd @[simp] theorem contLinear_map_vsub (f : P →ᴬ[R] Q) (p₁ p₂ : P) : f.contLinear (p₁ -ᵥ p₂) = f p₁ -ᵥ f p₂ := f.toAffineMap.linearMap_vsub p₁ p₂ #align continuous_affine_map.cont_linear_map_vsub ContinuousAffineMap.contLinear_map_vsub @[simp] theorem const_contLinear (q : Q) : (const R P q).contLinear = 0 := rfl #align continuous_affine_map.const_cont_linear ContinuousAffineMap.const_contLinear theorem contLinear_eq_zero_iff_exists_const (f : P →ᴬ[R] Q) : f.contLinear = 0 ↔ ∃ q, f = const R P q := by have h₁ : f.contLinear = 0 ↔ (f : P →ᵃ[R] Q).linear = 0 := by refine ⟨fun h => ?_, fun h => ?_⟩ <;> ext · rw [← coe_contLinear_eq_linear, h]; rfl · rw [← coe_linear_eq_coe_contLinear, h]; rfl have h₂ : ∀ q : Q, f = const R P q ↔ (f : P →ᵃ[R] Q) = AffineMap.const R P q := by intro q refine ⟨fun h => ?_, fun h => ?_⟩ <;> ext · rw [h]; rfl · rw [← coe_to_affineMap, h]; rfl simp_rw [h₁, h₂] exact (f : P →ᵃ[R] Q).linear_eq_zero_iff_exists_const #align continuous_affine_map.cont_linear_eq_zero_iff_exists_const ContinuousAffineMap.contLinear_eq_zero_iff_exists_const @[simp]
Mathlib/Analysis/NormedSpace/ContinuousAffineMap.lean
118
120
theorem to_affine_map_contLinear (f : V →L[R] W) : f.toContinuousAffineMap.contLinear = f := by
ext rfl
/- Copyright (c) 2022 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Patrick Massot -/ import Mathlib.Algebra.GroupWithZero.Indicator import Mathlib.Algebra.Module.Basic import Mathlib.Topology.Separation #align_import topology.support from "leanprover-community/mathlib"@"d90e4e186f1d18e375dcd4e5b5f6364b01cb3e46" /-! # The topological support of a function In this file we define the topological support of a function `f`, `tsupport f`, as the closure of the support of `f`. Furthermore, we say that `f` has compact support if the topological support of `f` is compact. ## Main definitions * `mulTSupport` & `tsupport` * `HasCompactMulSupport` & `HasCompactSupport` ## Implementation Notes * We write all lemmas for multiplicative functions, and use `@[to_additive]` to get the more common additive versions. * We do not put the definitions in the `Function` namespace, following many other topological definitions that are in the root namespace (compare `Embedding` vs `Function.Embedding`). -/ open Function Set Filter Topology variable {X α α' β γ δ M E R : Type*} section One variable [One α] [TopologicalSpace X] /-- The topological support of a function is the closure of its support, i.e. the closure of the set of all elements where the function is not equal to 1. -/ @[to_additive " The topological support of a function is the closure of its support. i.e. the closure of the set of all elements where the function is nonzero. "] def mulTSupport (f : X → α) : Set X := closure (mulSupport f) #align mul_tsupport mulTSupport #align tsupport tsupport @[to_additive] theorem subset_mulTSupport (f : X → α) : mulSupport f ⊆ mulTSupport f := subset_closure #align subset_mul_tsupport subset_mulTSupport #align subset_tsupport subset_tsupport @[to_additive] theorem isClosed_mulTSupport (f : X → α) : IsClosed (mulTSupport f) := isClosed_closure #align is_closed_mul_tsupport isClosed_mulTSupport #align is_closed_tsupport isClosed_tsupport @[to_additive] theorem mulTSupport_eq_empty_iff {f : X → α} : mulTSupport f = ∅ ↔ f = 1 := by rw [mulTSupport, closure_empty_iff, mulSupport_eq_empty_iff] #align mul_tsupport_eq_empty_iff mulTSupport_eq_empty_iff #align tsupport_eq_empty_iff tsupport_eq_empty_iff @[to_additive] theorem image_eq_one_of_nmem_mulTSupport {f : X → α} {x : X} (hx : x ∉ mulTSupport f) : f x = 1 := mulSupport_subset_iff'.mp (subset_mulTSupport f) x hx #align image_eq_one_of_nmem_mul_tsupport image_eq_one_of_nmem_mulTSupport #align image_eq_zero_of_nmem_tsupport image_eq_zero_of_nmem_tsupport @[to_additive] theorem range_subset_insert_image_mulTSupport (f : X → α) : range f ⊆ insert 1 (f '' mulTSupport f) := (range_subset_insert_image_mulSupport f).trans <| insert_subset_insert <| image_subset _ subset_closure #align range_subset_insert_image_mul_tsupport range_subset_insert_image_mulTSupport #align range_subset_insert_image_tsupport range_subset_insert_image_tsupport @[to_additive] theorem range_eq_image_mulTSupport_or (f : X → α) : range f = f '' mulTSupport f ∨ range f = insert 1 (f '' mulTSupport f) := (wcovBy_insert _ _).eq_or_eq (image_subset_range _ _) (range_subset_insert_image_mulTSupport f) #align range_eq_image_mul_tsupport_or range_eq_image_mulTSupport_or #align range_eq_image_tsupport_or range_eq_image_tsupport_or theorem tsupport_mul_subset_left {α : Type*} [MulZeroClass α] {f g : X → α} : (tsupport fun x => f x * g x) ⊆ tsupport f := closure_mono (support_mul_subset_left _ _) #align tsupport_mul_subset_left tsupport_mul_subset_left theorem tsupport_mul_subset_right {α : Type*} [MulZeroClass α] {f g : X → α} : (tsupport fun x => f x * g x) ⊆ tsupport g := closure_mono (support_mul_subset_right _ _) #align tsupport_mul_subset_right tsupport_mul_subset_right end One theorem tsupport_smul_subset_left {M α} [TopologicalSpace X] [Zero M] [Zero α] [SMulWithZero M α] (f : X → M) (g : X → α) : (tsupport fun x => f x • g x) ⊆ tsupport f := closure_mono <| support_smul_subset_left f g #align tsupport_smul_subset_left tsupport_smul_subset_left theorem tsupport_smul_subset_right {M α} [TopologicalSpace X] [Zero α] [SMulZeroClass M α] (f : X → M) (g : X → α) : (tsupport fun x => f x • g x) ⊆ tsupport g := closure_mono <| support_smul_subset_right f g @[to_additive] theorem mulTSupport_mul [TopologicalSpace X] [Monoid α] {f g : X → α} : (mulTSupport fun x ↦ f x * g x) ⊆ mulTSupport f ∪ mulTSupport g := closure_minimal ((mulSupport_mul f g).trans (union_subset_union (subset_mulTSupport _) (subset_mulTSupport _))) (isClosed_closure.union isClosed_closure) section variable [TopologicalSpace α] [TopologicalSpace α'] variable [One β] [One γ] [One δ] variable {g : β → γ} {f : α → β} {f₂ : α → γ} {m : β → γ → δ} {x : α} @[to_additive]
Mathlib/Topology/Support.lean
124
126
theorem not_mem_mulTSupport_iff_eventuallyEq : x ∉ mulTSupport f ↔ f =ᶠ[𝓝 x] 1 := by
simp_rw [mulTSupport, mem_closure_iff_nhds, not_forall, not_nonempty_iff_eq_empty, exists_prop, ← disjoint_iff_inter_eq_empty, disjoint_mulSupport_iff, eventuallyEq_iff_exists_mem]
/- Copyright (c) 2021 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Algebra.MvPolynomial.Equiv import Mathlib.Algebra.MvPolynomial.Supported import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.RingTheory.Adjoin.Basic import Mathlib.RingTheory.Algebraic import Mathlib.RingTheory.MvPolynomial.Basic #align_import ring_theory.algebraic_independent from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69" /-! # Algebraic Independence This file defines algebraic independence of a family of element of an `R` algebra. ## Main definitions * `AlgebraicIndependent` - `AlgebraicIndependent R x` states the family of elements `x` is algebraically independent over `R`, meaning that the canonical map out of the multivariable polynomial ring is injective. * `AlgebraicIndependent.repr` - The canonical map from the subalgebra generated by an algebraic independent family into the polynomial ring. ## References * [Stacks: Transcendence](https://stacks.math.columbia.edu/tag/030D) ## TODO Define the transcendence degree and show it is independent of the choice of a transcendence basis. ## Tags transcendence basis, transcendence degree, transcendence -/ noncomputable section open Function Set Subalgebra MvPolynomial Algebra open scoped Classical universe x u v w variable {ι : Type*} {ι' : Type*} (R : Type*) {K : Type*} variable {A : Type*} {A' A'' : Type*} {V : Type u} {V' : Type*} variable (x : ι → A) variable [CommRing R] [CommRing A] [CommRing A'] [CommRing A''] variable [Algebra R A] [Algebra R A'] [Algebra R A''] variable {a b : R} /-- `AlgebraicIndependent R x` states the family of elements `x` is algebraically independent over `R`, meaning that the canonical map out of the multivariable polynomial ring is injective. -/ def AlgebraicIndependent : Prop := Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A) #align algebraic_independent AlgebraicIndependent variable {R} {x} theorem algebraicIndependent_iff_ker_eq_bot : AlgebraicIndependent R x ↔ RingHom.ker (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A).toRingHom = ⊥ := RingHom.injective_iff_ker_eq_bot _ #align algebraic_independent_iff_ker_eq_bot algebraicIndependent_iff_ker_eq_bot theorem algebraicIndependent_iff : AlgebraicIndependent R x ↔ ∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 := injective_iff_map_eq_zero _ #align algebraic_independent_iff algebraicIndependent_iff theorem AlgebraicIndependent.eq_zero_of_aeval_eq_zero (h : AlgebraicIndependent R x) : ∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 := algebraicIndependent_iff.1 h #align algebraic_independent.eq_zero_of_aeval_eq_zero AlgebraicIndependent.eq_zero_of_aeval_eq_zero theorem algebraicIndependent_iff_injective_aeval : AlgebraicIndependent R x ↔ Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A) := Iff.rfl #align algebraic_independent_iff_injective_aeval algebraicIndependent_iff_injective_aeval @[simp] theorem algebraicIndependent_empty_type_iff [IsEmpty ι] : AlgebraicIndependent R x ↔ Injective (algebraMap R A) := by have : aeval x = (Algebra.ofId R A).comp (@isEmptyAlgEquiv R ι _ _).toAlgHom := by ext i exact IsEmpty.elim' ‹IsEmpty ι› i rw [AlgebraicIndependent, this, ← Injective.of_comp_iff' _ (@isEmptyAlgEquiv R ι _ _).bijective] rfl #align algebraic_independent_empty_type_iff algebraicIndependent_empty_type_iff namespace AlgebraicIndependent variable (hx : AlgebraicIndependent R x) theorem algebraMap_injective : Injective (algebraMap R A) := by simpa [Function.comp] using (Injective.of_comp_iff (algebraicIndependent_iff_injective_aeval.1 hx) MvPolynomial.C).2 (MvPolynomial.C_injective _ _) #align algebraic_independent.algebra_map_injective AlgebraicIndependent.algebraMap_injective
Mathlib/RingTheory/AlgebraicIndependent.lean
109
118
theorem linearIndependent : LinearIndependent R x := by
rw [linearIndependent_iff_injective_total] have : Finsupp.total ι A R x = (MvPolynomial.aeval x).toLinearMap.comp (Finsupp.total ι _ R X) := by ext simp rw [this] refine hx.comp ?_ rw [← linearIndependent_iff_injective_total] exact linearIndependent_X _ _
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl, Patrick Massot -/ import Mathlib.Data.Set.Image import Mathlib.Data.SProd #align_import data.set.prod from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" /-! # Sets in product and pi types This file defines the product of sets in `α × β` and in `Π i, α i` along with the diagonal of a type. ## Main declarations * `Set.prod`: Binary product of sets. For `s : Set α`, `t : Set β`, we have `s.prod t : Set (α × β)`. * `Set.diagonal`: Diagonal of a type. `Set.diagonal α = {(x, x) | x : α}`. * `Set.offDiag`: Off-diagonal. `s ×ˢ s` without the diagonal. * `Set.pi`: Arbitrary product of sets. -/ open Function namespace Set /-! ### Cartesian binary product of sets -/ section Prod variable {α β γ δ : Type*} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {a : α} {b : β} theorem Subsingleton.prod (hs : s.Subsingleton) (ht : t.Subsingleton) : (s ×ˢ t).Subsingleton := fun _x hx _y hy ↦ Prod.ext (hs hx.1 hy.1) (ht hx.2 hy.2) noncomputable instance decidableMemProd [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] : DecidablePred (· ∈ s ×ˢ t) := fun _ => And.decidable #align set.decidable_mem_prod Set.decidableMemProd @[gcongr] theorem prod_mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : s₁ ×ˢ t₁ ⊆ s₂ ×ˢ t₂ := fun _ ⟨h₁, h₂⟩ => ⟨hs h₁, ht h₂⟩ #align set.prod_mono Set.prod_mono @[gcongr] theorem prod_mono_left (hs : s₁ ⊆ s₂) : s₁ ×ˢ t ⊆ s₂ ×ˢ t := prod_mono hs Subset.rfl #align set.prod_mono_left Set.prod_mono_left @[gcongr] theorem prod_mono_right (ht : t₁ ⊆ t₂) : s ×ˢ t₁ ⊆ s ×ˢ t₂ := prod_mono Subset.rfl ht #align set.prod_mono_right Set.prod_mono_right @[simp] theorem prod_self_subset_prod_self : s₁ ×ˢ s₁ ⊆ s₂ ×ˢ s₂ ↔ s₁ ⊆ s₂ := ⟨fun h _ hx => (h (mk_mem_prod hx hx)).1, fun h _ hx => ⟨h hx.1, h hx.2⟩⟩ #align set.prod_self_subset_prod_self Set.prod_self_subset_prod_self @[simp] theorem prod_self_ssubset_prod_self : s₁ ×ˢ s₁ ⊂ s₂ ×ˢ s₂ ↔ s₁ ⊂ s₂ := and_congr prod_self_subset_prod_self <| not_congr prod_self_subset_prod_self #align set.prod_self_ssubset_prod_self Set.prod_self_ssubset_prod_self theorem prod_subset_iff {P : Set (α × β)} : s ×ˢ t ⊆ P ↔ ∀ x ∈ s, ∀ y ∈ t, (x, y) ∈ P := ⟨fun h _ hx _ hy => h (mk_mem_prod hx hy), fun h ⟨_, _⟩ hp => h _ hp.1 _ hp.2⟩ #align set.prod_subset_iff Set.prod_subset_iff theorem forall_prod_set {p : α × β → Prop} : (∀ x ∈ s ×ˢ t, p x) ↔ ∀ x ∈ s, ∀ y ∈ t, p (x, y) := prod_subset_iff #align set.forall_prod_set Set.forall_prod_set theorem exists_prod_set {p : α × β → Prop} : (∃ x ∈ s ×ˢ t, p x) ↔ ∃ x ∈ s, ∃ y ∈ t, p (x, y) := by simp [and_assoc] #align set.exists_prod_set Set.exists_prod_set @[simp] theorem prod_empty : s ×ˢ (∅ : Set β) = ∅ := by ext exact and_false_iff _ #align set.prod_empty Set.prod_empty @[simp] theorem empty_prod : (∅ : Set α) ×ˢ t = ∅ := by ext exact false_and_iff _ #align set.empty_prod Set.empty_prod @[simp, mfld_simps]
Mathlib/Data/Set/Prod.lean
96
98
theorem univ_prod_univ : @univ α ×ˢ @univ β = univ := by
ext exact true_and_iff _
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" /-! # Basis on a quaternion-like algebra ## Main definitions * `QuaternionAlgebra.Basis A c₁ c₂`: a basis for a subspace of an `R`-algebra `A` that has the same algebra structure as `ℍ[R,c₁,c₂]`. * `QuaternionAlgebra.Basis.self R`: the canonical basis for `ℍ[R,c₁,c₂]`. * `QuaternionAlgebra.Basis.compHom b f`: transform a basis `b` by an AlgHom `f`. * `QuaternionAlgebra.lift`: Define an `AlgHom` out of `ℍ[R,c₁,c₂]` by its action on the basis elements `i`, `j`, and `k`. In essence, this is a universal property. Analogous to `Complex.lift`, but takes a bundled `QuaternionAlgebra.Basis` instead of just a `Subtype` as the amount of data / proves is non-negligible. -/ open Quaternion namespace QuaternionAlgebra /-- A quaternion basis contains the information both sufficient and necessary to construct an `R`-algebra homomorphism from `ℍ[R,c₁,c₂]` to `A`; or equivalently, a surjective `R`-algebra homomorphism from `ℍ[R,c₁,c₂]` to an `R`-subalgebra of `A`. Note that for definitional convenience, `k` is provided as a field even though `i_mul_j` fully determines it. -/ structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis /-- Since `k` is redundant, it is not necessary to show `q₁.k = q₂.k` when showing `q₁ = q₂`. -/ @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) /-- There is a natural quaternionic basis for the `QuaternionAlgebra`. -/ @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp] theorem j_mul_k : q.j * q.k = -c₂ • q.i := by rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul] #align quaternion_algebra.basis.j_mul_k QuaternionAlgebra.Basis.j_mul_k @[simp] theorem k_mul_k : q.k * q.k = -((c₁ * c₂) • (1 : A)) := by rw [← i_mul_j, mul_assoc, ← mul_assoc q.j _ _, j_mul_i, ← i_mul_j, ← mul_assoc, mul_neg, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul, neg_mul, smul_mul_assoc, j_mul_j, smul_smul] #align quaternion_algebra.basis.k_mul_k QuaternionAlgebra.Basis.k_mul_k /-- Intermediate result used to define `QuaternionAlgebra.Basis.liftHom`. -/ def lift (x : ℍ[R,c₁,c₂]) : A := algebraMap R _ x.re + x.imI • q.i + x.imJ • q.j + x.imK • q.k #align quaternion_algebra.basis.lift QuaternionAlgebra.Basis.lift
Mathlib/Algebra/QuaternionBasis.lean
114
114
theorem lift_zero : q.lift (0 : ℍ[R,c₁,c₂]) = 0 := by
simp [lift]
/- Copyright (c) 2019 Kevin Kappelmann. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Kappelmann -/ import Mathlib.Algebra.ContinuedFractions.Basic import Mathlib.Algebra.GroupWithZero.Basic #align_import algebra.continued_fractions.translations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" /-! # Basic Translation Lemmas Between Functions Defined for Continued Fractions ## Summary Some simple translation lemmas between the different definitions of functions defined in `Algebra.ContinuedFractions.Basic`. -/ namespace GeneralizedContinuedFraction section General /-! ### Translations Between General Access Functions Here we give some basic translations that hold by definition between the various methods that allow us to access the numerators and denominators of a continued fraction. -/ variable {α : Type*} {g : GeneralizedContinuedFraction α} {n : ℕ} theorem terminatedAt_iff_s_terminatedAt : g.TerminatedAt n ↔ g.s.TerminatedAt n := by rfl #align generalized_continued_fraction.terminated_at_iff_s_terminated_at GeneralizedContinuedFraction.terminatedAt_iff_s_terminatedAt theorem terminatedAt_iff_s_none : g.TerminatedAt n ↔ g.s.get? n = none := by rfl #align generalized_continued_fraction.terminated_at_iff_s_none GeneralizedContinuedFraction.terminatedAt_iff_s_none theorem part_num_none_iff_s_none : g.partialNumerators.get? n = none ↔ g.s.get? n = none := by cases s_nth_eq : g.s.get? n <;> simp [partialNumerators, s_nth_eq] #align generalized_continued_fraction.part_num_none_iff_s_none GeneralizedContinuedFraction.part_num_none_iff_s_none theorem terminatedAt_iff_part_num_none : g.TerminatedAt n ↔ g.partialNumerators.get? n = none := by rw [terminatedAt_iff_s_none, part_num_none_iff_s_none] #align generalized_continued_fraction.terminated_at_iff_part_num_none GeneralizedContinuedFraction.terminatedAt_iff_part_num_none theorem part_denom_none_iff_s_none : g.partialDenominators.get? n = none ↔ g.s.get? n = none := by cases s_nth_eq : g.s.get? n <;> simp [partialDenominators, s_nth_eq] #align generalized_continued_fraction.part_denom_none_iff_s_none GeneralizedContinuedFraction.part_denom_none_iff_s_none theorem terminatedAt_iff_part_denom_none : g.TerminatedAt n ↔ g.partialDenominators.get? n = none := by rw [terminatedAt_iff_s_none, part_denom_none_iff_s_none] #align generalized_continued_fraction.terminated_at_iff_part_denom_none GeneralizedContinuedFraction.terminatedAt_iff_part_denom_none
Mathlib/Algebra/ContinuedFractions/Translations.lean
58
59
theorem part_num_eq_s_a {gp : Pair α} (s_nth_eq : g.s.get? n = some gp) : g.partialNumerators.get? n = some gp.a := by
simp [partialNumerators, s_nth_eq]
/- 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 -/ import Mathlib.LinearAlgebra.Dimension.DivisionRing import Mathlib.LinearAlgebra.Dimension.FreeAndStrongRankCondition /-! # The rank of a linear map ## Main Definition - `LinearMap.rank`: The rank of a linear map. -/ noncomputable section universe u v v' v'' variable {K : Type u} {V V₁ : Type v} {V' V'₁ : Type v'} {V'' : Type v''} open Cardinal Basis Submodule Function Set namespace LinearMap section Ring variable [Ring K] [AddCommGroup V] [Module K V] [AddCommGroup V₁] [Module K V₁] variable [AddCommGroup V'] [Module K V'] /-- `rank f` is the rank of a `LinearMap` `f`, defined as the dimension of `f.range`. -/ abbrev rank (f : V →ₗ[K] V') : Cardinal := Module.rank K (LinearMap.range f) #align linear_map.rank LinearMap.rank theorem rank_le_range (f : V →ₗ[K] V') : rank f ≤ Module.rank K V' := rank_submodule_le _ #align linear_map.rank_le_range LinearMap.rank_le_range theorem rank_le_domain (f : V →ₗ[K] V₁) : rank f ≤ Module.rank K V := rank_range_le _ #align linear_map.rank_le_domain LinearMap.rank_le_domain @[simp] theorem rank_zero [Nontrivial K] : rank (0 : V →ₗ[K] V') = 0 := by rw [rank, LinearMap.range_zero, rank_bot] #align linear_map.rank_zero LinearMap.rank_zero variable [AddCommGroup V''] [Module K V''] theorem rank_comp_le_left (g : V →ₗ[K] V') (f : V' →ₗ[K] V'') : rank (f.comp g) ≤ rank f := by refine rank_le_of_submodule _ _ ?_ rw [LinearMap.range_comp] exact LinearMap.map_le_range #align linear_map.rank_comp_le_left LinearMap.rank_comp_le_left theorem lift_rank_comp_le_right (g : V →ₗ[K] V') (f : V' →ₗ[K] V'') : Cardinal.lift.{v'} (rank (f.comp g)) ≤ Cardinal.lift.{v''} (rank g) := by rw [rank, rank, LinearMap.range_comp]; exact lift_rank_map_le _ _ #align linear_map.lift_rank_comp_le_right LinearMap.lift_rank_comp_le_right /-- The rank of the composition of two maps is less than the minimum of their ranks. -/ theorem lift_rank_comp_le (g : V →ₗ[K] V') (f : V' →ₗ[K] V'') : Cardinal.lift.{v'} (rank (f.comp g)) ≤ min (Cardinal.lift.{v'} (rank f)) (Cardinal.lift.{v''} (rank g)) := le_min (Cardinal.lift_le.mpr <| rank_comp_le_left _ _) (lift_rank_comp_le_right _ _) #align linear_map.lift_rank_comp_le LinearMap.lift_rank_comp_le variable [AddCommGroup V'₁] [Module K V'₁] theorem rank_comp_le_right (g : V →ₗ[K] V') (f : V' →ₗ[K] V'₁) : rank (f.comp g) ≤ rank g := by simpa only [Cardinal.lift_id] using lift_rank_comp_le_right g f #align linear_map.rank_comp_le_right LinearMap.rank_comp_le_right /-- The rank of the composition of two maps is less than the minimum of their ranks. See `lift_rank_comp_le` for the universe-polymorphic version. -/
Mathlib/LinearAlgebra/Dimension/LinearMap.lean
79
81
theorem rank_comp_le (g : V →ₗ[K] V') (f : V' →ₗ[K] V'₁) : rank (f.comp g) ≤ min (rank f) (rank g) := by
simpa only [Cardinal.lift_id] using lift_rank_comp_le g f
/- Copyright (c) 2021 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying -/ import Mathlib.MeasureTheory.Measure.VectorMeasure #align_import measure_theory.measure.complex from "leanprover-community/mathlib"@"17b3357baa47f48697ca9c243e300eb8cdd16a15" /-! # Complex measure This file proves some elementary results about complex measures. In particular, we prove that a complex measure is always in the form `s + it` where `s` and `t` are signed measures. The complex measure is defined to be vector measure over `ℂ`, this definition can be found in `Mathlib/MeasureTheory/Measure/VectorMeasure.lean` and is known as `MeasureTheory.ComplexMeasure`. ## Main definitions * `MeasureTheory.ComplexMeasure.re`: obtains a signed measure `s` from a complex measure `c` such that `s i = (c i).re` for all measurable sets `i`. * `MeasureTheory.ComplexMeasure.im`: obtains a signed measure `s` from a complex measure `c` such that `s i = (c i).im` for all measurable sets `i`. * `MeasureTheory.SignedMeasure.toComplexMeasure`: given two signed measures `s` and `t`, `s.to_complex_measure t` provides a complex measure of the form `s + it`. * `MeasureTheory.ComplexMeasure.equivSignedMeasure`: is the equivalence between the complex measures and the type of the product of the signed measures with itself. ## Tags Complex measure -/ noncomputable section open scoped Classical MeasureTheory ENNReal NNReal variable {α β : Type*} {m : MeasurableSpace α} namespace MeasureTheory open VectorMeasure namespace ComplexMeasure /-- The real part of a complex measure is a signed measure. -/ @[simps! apply] def re : ComplexMeasure α →ₗ[ℝ] SignedMeasure α := mapRangeₗ Complex.reCLM Complex.continuous_re #align measure_theory.complex_measure.re MeasureTheory.ComplexMeasure.re /-- The imaginary part of a complex measure is a signed measure. -/ @[simps! apply] def im : ComplexMeasure α →ₗ[ℝ] SignedMeasure α := mapRangeₗ Complex.imCLM Complex.continuous_im #align measure_theory.complex_measure.im MeasureTheory.ComplexMeasure.im /-- Given `s` and `t` signed measures, `s + it` is a complex measure-/ @[simps!] def _root_.MeasureTheory.SignedMeasure.toComplexMeasure (s t : SignedMeasure α) : ComplexMeasure α where measureOf' i := ⟨s i, t i⟩ empty' := by dsimp only; rw [s.empty, t.empty]; rfl not_measurable' i hi := by dsimp only; rw [s.not_measurable hi, t.not_measurable hi]; rfl m_iUnion' f hf hfdisj := (Complex.hasSum_iff _ _).2 ⟨s.m_iUnion hf hfdisj, t.m_iUnion hf hfdisj⟩ #align measure_theory.signed_measure.to_complex_measure MeasureTheory.SignedMeasure.toComplexMeasure theorem _root_.MeasureTheory.SignedMeasure.toComplexMeasure_apply {s t : SignedMeasure α} {i : Set α} : s.toComplexMeasure t i = ⟨s i, t i⟩ := rfl #align measure_theory.signed_measure.to_complex_measure_apply MeasureTheory.SignedMeasure.toComplexMeasure_apply theorem toComplexMeasure_to_signedMeasure (c : ComplexMeasure α) : SignedMeasure.toComplexMeasure (ComplexMeasure.re c) (ComplexMeasure.im c) = c := rfl #align measure_theory.complex_measure.to_complex_measure_to_signed_measure MeasureTheory.ComplexMeasure.toComplexMeasure_to_signedMeasure theorem _root_.MeasureTheory.SignedMeasure.re_toComplexMeasure (s t : SignedMeasure α) : ComplexMeasure.re (SignedMeasure.toComplexMeasure s t) = s := rfl #align measure_theory.signed_measure.re_to_complex_measure MeasureTheory.SignedMeasure.re_toComplexMeasure theorem _root_.MeasureTheory.SignedMeasure.im_toComplexMeasure (s t : SignedMeasure α) : ComplexMeasure.im (SignedMeasure.toComplexMeasure s t) = t := rfl #align measure_theory.signed_measure.im_to_complex_measure MeasureTheory.SignedMeasure.im_toComplexMeasure /-- The complex measures form an equivalence to the type of pairs of signed measures. -/ @[simps] def equivSignedMeasure : ComplexMeasure α ≃ SignedMeasure α × SignedMeasure α where toFun c := ⟨ComplexMeasure.re c, ComplexMeasure.im c⟩ invFun := fun ⟨s, t⟩ => s.toComplexMeasure t left_inv c := c.toComplexMeasure_to_signedMeasure right_inv := fun ⟨s, t⟩ => Prod.mk.inj_iff.2 ⟨s.re_toComplexMeasure t, s.im_toComplexMeasure t⟩ #align measure_theory.complex_measure.equiv_signed_measure MeasureTheory.ComplexMeasure.equivSignedMeasure section variable {R : Type*} [Semiring R] [Module R ℝ] variable [ContinuousConstSMul R ℝ] [ContinuousConstSMul R ℂ] /-- The complex measures form a linear isomorphism to the type of pairs of signed measures. -/ @[simps] def equivSignedMeasureₗ : ComplexMeasure α ≃ₗ[R] SignedMeasure α × SignedMeasure α := { equivSignedMeasure with map_add' := fun c d => by rfl map_smul' := by intro r c dsimp ext · simp [Complex.smul_re] · simp [Complex.smul_im] } #align measure_theory.complex_measure.equiv_signed_measureₗ MeasureTheory.ComplexMeasure.equivSignedMeasureₗ end
Mathlib/MeasureTheory/Measure/Complex.lean
116
122
theorem absolutelyContinuous_ennreal_iff (c : ComplexMeasure α) (μ : VectorMeasure α ℝ≥0∞) : c ≪ᵥ μ ↔ ComplexMeasure.re c ≪ᵥ μ ∧ ComplexMeasure.im c ≪ᵥ μ := by
constructor <;> intro h · constructor <;> · intro i hi; simp [h hi] · intro i hi rw [← Complex.re_add_im (c i), (_ : (c i).re = 0), (_ : (c i).im = 0)] exacts [by simp, h.2 hi, h.1 hi]
/- Copyright (c) 2020 Hanting Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Hanting Zhang -/ import Mathlib.Algebra.Polynomial.Splits import Mathlib.RingTheory.MvPolynomial.Symmetric #align_import ring_theory.polynomial.vieta from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # Vieta's Formula The main result is `Multiset.prod_X_add_C_eq_sum_esymm`, which shows that the product of linear terms `X + λ` with `λ` in a `Multiset s` is equal to a linear combination of the symmetric functions `esymm s`. From this, we deduce `MvPolynomial.prod_X_add_C_eq_sum_esymm` which is the equivalent formula for the product of linear terms `X + X i` with `i` in a `Fintype σ` as a linear combination of the symmetric polynomials `esymm σ R j`. For `R` be an integral domain (so that `p.roots` is defined for any `p : R[X]` as a multiset), we derive `Polynomial.coeff_eq_esymm_roots_of_card`, the relationship between the coefficients and the roots of `p` for a polynomial `p` that splits (i.e. having as many roots as its degree). -/ open Polynomial namespace Multiset open Polynomial section Semiring variable {R : Type*} [CommSemiring R] /-- A sum version of **Vieta's formula** for `Multiset`: the product of the linear terms `X + λ` where `λ` runs through a multiset `s` is equal to a linear combination of the symmetric functions `esymm s` of the `λ`'s . -/ theorem prod_X_add_C_eq_sum_esymm (s : Multiset R) : (s.map fun r => X + C r).prod = ∑ j ∈ Finset.range (Multiset.card s + 1), (C (s.esymm j) * X ^ (Multiset.card s - j)) := by classical rw [prod_map_add, antidiagonal_eq_map_powerset, map_map, ← bind_powerset_len, map_bind, sum_bind, Finset.sum_eq_multiset_sum, Finset.range_val, map_congr (Eq.refl _)] intro _ _ rw [esymm, ← sum_hom', ← sum_map_mul_right, map_congr (Eq.refl _)] intro s ht rw [mem_powersetCard] at ht dsimp rw [prod_hom' s (Polynomial.C : R →+* R[X])] simp [ht, map_const, prod_replicate, prod_hom', map_id', card_sub] set_option linter.uppercaseLean3 false in #align multiset.prod_X_add_C_eq_sum_esymm Multiset.prod_X_add_C_eq_sum_esymm /-- Vieta's formula for the coefficients of the product of linear terms `X + λ` where `λ` runs through a multiset `s` : the `k`th coefficient is the symmetric function `esymm (card s - k) s`. -/ theorem prod_X_add_C_coeff (s : Multiset R) {k : ℕ} (h : k ≤ Multiset.card s) : (s.map fun r => X + C r).prod.coeff k = s.esymm (Multiset.card s - k) := by convert Polynomial.ext_iff.mp (prod_X_add_C_eq_sum_esymm s) k using 1 simp_rw [finset_sum_coeff, coeff_C_mul_X_pow] rw [Finset.sum_eq_single_of_mem (Multiset.card s - k) _] · rw [if_pos (Nat.sub_sub_self h).symm] · intro j hj1 hj2 suffices k ≠ card s - j by rw [if_neg this] intro hn rw [hn, Nat.sub_sub_self (Nat.lt_succ_iff.mp (Finset.mem_range.mp hj1))] at hj2 exact Ne.irrefl hj2 · rw [Finset.mem_range] exact Nat.lt_succ_of_le (Nat.sub_le (Multiset.card s) k) set_option linter.uppercaseLean3 false in #align multiset.prod_X_add_C_coeff Multiset.prod_X_add_C_coeff theorem prod_X_add_C_coeff' {σ} (s : Multiset σ) (r : σ → R) {k : ℕ} (h : k ≤ Multiset.card s) : (s.map fun i => X + C (r i)).prod.coeff k = (s.map r).esymm (Multiset.card s - k) := by erw [← map_map (fun r => X + C r) r, prod_X_add_C_coeff] <;> rw [s.card_map r]; assumption set_option linter.uppercaseLean3 false in #align multiset.prod_X_add_C_coeff' Multiset.prod_X_add_C_coeff' theorem _root_.Finset.prod_X_add_C_coeff {σ} (s : Finset σ) (r : σ → R) {k : ℕ} (h : k ≤ s.card) : (∏ i ∈ s, (X + C (r i))).coeff k = ∑ t ∈ s.powersetCard (s.card - k), ∏ i ∈ t, r i := by rw [Finset.prod, prod_X_add_C_coeff' _ r h, Finset.esymm_map_val] rfl set_option linter.uppercaseLean3 false in #align finset.prod_X_add_C_coeff Finset.prod_X_add_C_coeff end Semiring section Ring variable {R : Type*} [CommRing R]
Mathlib/RingTheory/Polynomial/Vieta.lean
94
101
theorem esymm_neg (s : Multiset R) (k : ℕ) : (map Neg.neg s).esymm k = (-1) ^ k * esymm s k := by
rw [esymm, esymm, ← Multiset.sum_map_mul_left, Multiset.powersetCard_map, Multiset.map_map, map_congr rfl] intro x hx rw [(mem_powersetCard.mp hx).right.symm, ← prod_replicate, ← Multiset.map_const] nth_rw 3 [← map_id' x] rw [← prod_map_mul, map_congr rfl, Function.comp_apply] exact fun z _ => neg_one_mul z
/- Copyright (c) 2021 Nicolò Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nicolò Cavalleri -/ import Mathlib.Data.Set.Basic #align_import data.bundle from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Bundle Basic data structure to implement fiber bundles, vector bundles (maybe fibrations?), etc. This file should contain all possible results that do not involve any topology. We represent a bundle `E` over a base space `B` as a dependent type `E : B → Type*`. We define `Bundle.TotalSpace F E` to be the type of pairs `⟨b, x⟩`, where `b : B` and `x : E b`. This type is isomorphic to `Σ x, E x` and uses an extra argument `F` for reasons explained below. In general, the constructions of fiber bundles we will make will be of this form. ## Main Definitions * `Bundle.TotalSpace` the total space of a bundle. * `Bundle.TotalSpace.proj` the projection from the total space to the base space. * `Bundle.TotalSpace.mk` the constructor for the total space. ## Implementation Notes - We use a custom structure for the total space of a bundle instead of using a type synonym for the canonical disjoint union `Σ x, E x` because the total space usually has a different topology and Lean 4 `simp` fails to apply lemmas about `Σ x, E x` to elements of the total space. - The definition of `Bundle.TotalSpace` has an unused argument `F`. The reason is that in some constructions (e.g., `Bundle.ContinuousLinearMap.vectorBundle`) we need access to the atlas of trivializations of original fiber bundles to construct the topology on the total space of the new fiber bundle. ## References - https://en.wikipedia.org/wiki/Bundle_(mathematics) -/ open Function Set namespace Bundle variable {B F : Type*} (E : B → Type*) /-- `Bundle.TotalSpace F E` is the total space of the bundle. It consists of pairs `(proj : B, snd : E proj)`. -/ @[ext] structure TotalSpace (F : Type*) (E : B → Type*) where /-- `Bundle.TotalSpace.proj` is the canonical projection `Bundle.TotalSpace F E → B` from the total space to the base space. -/ proj : B snd : E proj #align bundle.total_space Bundle.TotalSpace instance [Inhabited B] [Inhabited (E default)] : Inhabited (TotalSpace F E) := ⟨⟨default, default⟩⟩ variable {E} @[inherit_doc] scoped notation:max "π" F':max E':max => Bundle.TotalSpace.proj (F := F') (E := E') abbrev TotalSpace.mk' (F : Type*) (x : B) (y : E x) : TotalSpace F E := ⟨x, y⟩ theorem TotalSpace.mk_cast {x x' : B} (h : x = x') (b : E x) : .mk' F x' (cast (congr_arg E h) b) = TotalSpace.mk x b := by subst h; rfl #align bundle.total_space.mk_cast Bundle.TotalSpace.mk_cast @[simp 1001, mfld_simps 1001]
Mathlib/Data/Bundle.lean
74
75
theorem TotalSpace.mk_inj {b : B} {y y' : E b} : mk' F b y = mk' F b y' ↔ y = y' := by
simp [TotalSpace.ext_iff]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot -/ import Mathlib.GroupTheory.GroupAction.ConjAct import Mathlib.GroupTheory.GroupAction.Quotient import Mathlib.GroupTheory.QuotientGroup import Mathlib.Topology.Algebra.Monoid import Mathlib.Topology.Algebra.Constructions #align_import topology.algebra.group.basic from "leanprover-community/mathlib"@"3b1890e71632be9e3b2086ab512c3259a7e9a3ef" /-! # Topological groups This file defines the following typeclasses: * `TopologicalGroup`, `TopologicalAddGroup`: multiplicative and additive topological groups, i.e., groups with continuous `(*)` and `(⁻¹)` / `(+)` and `(-)`; * `ContinuousSub G` means that `G` has a continuous subtraction operation. There is an instance deducing `ContinuousSub` from `TopologicalGroup` but we use a separate typeclass because, e.g., `ℕ` and `ℝ≥0` have continuous subtraction but are not additive groups. We also define `Homeomorph` versions of several `Equiv`s: `Homeomorph.mulLeft`, `Homeomorph.mulRight`, `Homeomorph.inv`, and prove a few facts about neighbourhood filters in groups. ## Tags topological space, group, topological group -/ open scoped Classical open Set Filter TopologicalSpace Function Topology Pointwise MulOpposite universe u v w x variable {G : Type w} {H : Type x} {α : Type u} {β : Type v} section ContinuousMulGroup /-! ### Groups with continuous multiplication In this section we prove a few statements about groups with continuous `(*)`. -/ variable [TopologicalSpace G] [Group G] [ContinuousMul G] /-- Multiplication from the left in a topological group as a homeomorphism. -/ @[to_additive "Addition from the left in a topological additive group as a homeomorphism."] protected def Homeomorph.mulLeft (a : G) : G ≃ₜ G := { Equiv.mulLeft a with continuous_toFun := continuous_const.mul continuous_id continuous_invFun := continuous_const.mul continuous_id } #align homeomorph.mul_left Homeomorph.mulLeft #align homeomorph.add_left Homeomorph.addLeft @[to_additive (attr := simp)] theorem Homeomorph.coe_mulLeft (a : G) : ⇑(Homeomorph.mulLeft a) = (a * ·) := rfl #align homeomorph.coe_mul_left Homeomorph.coe_mulLeft #align homeomorph.coe_add_left Homeomorph.coe_addLeft @[to_additive]
Mathlib/Topology/Algebra/Group/Basic.lean
71
73
theorem Homeomorph.mulLeft_symm (a : G) : (Homeomorph.mulLeft a).symm = Homeomorph.mulLeft a⁻¹ := by
ext rfl
/- 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] 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 theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this theorem length_mul_ge_length_sub_length (w₁ w₂ : W) : ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹
Mathlib/GroupTheory/Coxeter/Length.lean
111
113
theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) : ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by
simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂)
/- Copyright (c) 2021 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying, Yury Kudryashov -/ import Mathlib.MeasureTheory.Measure.Restrict #align_import measure_theory.measure.mutually_singular from "leanprover-community/mathlib"@"70a4f2197832bceab57d7f41379b2592d1110570" /-! # Mutually singular measures Two measures `μ`, `ν` are said to be mutually singular (`MeasureTheory.Measure.MutuallySingular`, localized notation `μ ⟂ₘ ν`) if there exists a measurable set `s` such that `μ s = 0` and `ν sᶜ = 0`. The measurability of `s` is an unnecessary assumption (see `MeasureTheory.Measure.MutuallySingular.mk`) but we keep it because this way `rcases (h : μ ⟂ₘ ν)` gives us a measurable set and usually it is easy to prove measurability. In this file we define the predicate `MeasureTheory.Measure.MutuallySingular` and prove basic facts about it. ## Tags measure, mutually singular -/ open Set open MeasureTheory NNReal ENNReal namespace MeasureTheory namespace Measure variable {α : Type*} {m0 : MeasurableSpace α} {μ μ₁ μ₂ ν ν₁ ν₂ : Measure α} /-- Two measures `μ`, `ν` are said to be mutually singular if there exists a measurable set `s` such that `μ s = 0` and `ν sᶜ = 0`. -/ def MutuallySingular {_ : MeasurableSpace α} (μ ν : Measure α) : Prop := ∃ s : Set α, MeasurableSet s ∧ μ s = 0 ∧ ν sᶜ = 0 #align measure_theory.measure.mutually_singular MeasureTheory.Measure.MutuallySingular @[inherit_doc MeasureTheory.Measure.MutuallySingular] scoped[MeasureTheory] infixl:60 " ⟂ₘ " => MeasureTheory.Measure.MutuallySingular namespace MutuallySingular
Mathlib/MeasureTheory/Measure/MutuallySingular.lean
48
52
theorem mk {s t : Set α} (hs : μ s = 0) (ht : ν t = 0) (hst : univ ⊆ s ∪ t) : MutuallySingular μ ν := by
use toMeasurable μ s, measurableSet_toMeasurable _ _, (measure_toMeasurable _).trans hs refine measure_mono_null (fun x hx => (hst trivial).resolve_left fun hxs => hx ?_) ht exact subset_toMeasurable _ _ hxs
/- Copyright (c) 2024 Miyahara Kō. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Miyahara Kō -/ import Mathlib.Data.List.Range import Mathlib.Algebra.Order.Ring.Nat /-! # iterate Proves various lemmas about `List.iterate`. -/ variable {α : Type*} namespace List @[simp] theorem length_iterate (f : α → α) (a : α) (n : ℕ) : length (iterate f a n) = n := by induction n generalizing a <;> simp [*] @[simp] theorem iterate_eq_nil {f : α → α} {a : α} {n : ℕ} : iterate f a n = [] ↔ n = 0 := by rw [← length_eq_zero, length_iterate] theorem get?_iterate (f : α → α) (a : α) : ∀ (n i : ℕ), i < n → get? (iterate f a n) i = f^[i] a | n + 1, 0 , _ => rfl | n + 1, i + 1, h => by simp [get?_iterate f (f a) n i (by simpa using h)] @[simp] theorem get_iterate (f : α → α) (a : α) (n : ℕ) (i : Fin (iterate f a n).length) : get (iterate f a n) i = f^[↑i] a := (get?_eq_some.1 <| get?_iterate f a n i.1 (by simpa using i.2)).2 @[simp] theorem mem_iterate {f : α → α} {a : α} {n : ℕ} {b : α} : b ∈ iterate f a n ↔ ∃ m < n, b = f^[m] a := by simp [List.mem_iff_get, Fin.exists_iff, eq_comm (b := b)] @[simp] theorem range_map_iterate (n : ℕ) (f : α → α) (a : α) : (List.range n).map (f^[·] a) = List.iterate f a n := by apply List.ext_get <;> simp
Mathlib/Data/List/Iterate.lean
48
52
theorem iterate_add (f : α → α) (a : α) (m n : ℕ) : iterate f a (m + n) = iterate f a m ++ iterate f (f^[m] a) n := by
induction m generalizing a with | zero => simp | succ n ih => rw [iterate, add_right_comm, iterate, ih, Nat.iterate, cons_append]
/- Copyright (c) 2019 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Control.Bitraversable.Basic #align_import control.bitraversable.lemmas from "leanprover-community/mathlib"@"58581d0fe523063f5651df0619be2bf65012a94a" /-! # Bitraversable Lemmas ## Main definitions * tfst - traverse on first functor argument * tsnd - traverse on second functor argument ## Lemmas Combination of * bitraverse * tfst * tsnd with the applicatives `id` and `comp` ## References * Hackage: <https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bitraversable.html> ## Tags traversable bitraversable functor bifunctor applicative -/ universe u variable {t : Type u → Type u → Type u} [Bitraversable t] variable {β : Type u} namespace Bitraversable open Functor LawfulApplicative variable {F G : Type u → Type u} [Applicative F] [Applicative G] /-- traverse on the first functor argument -/ abbrev tfst {α α'} (f : α → F α') : t α β → F (t α' β) := bitraverse f pure #align bitraversable.tfst Bitraversable.tfst /-- traverse on the second functor argument -/ abbrev tsnd {α α'} (f : α → F α') : t β α → F (t β α') := bitraverse pure f #align bitraversable.tsnd Bitraversable.tsnd variable [LawfulBitraversable t] [LawfulApplicative F] [LawfulApplicative G] @[higher_order tfst_id] theorem id_tfst : ∀ {α β} (x : t α β), tfst (F := Id) pure x = pure x := id_bitraverse #align bitraversable.id_tfst Bitraversable.id_tfst @[higher_order tsnd_id] theorem id_tsnd : ∀ {α β} (x : t α β), tsnd (F := Id) pure x = pure x := id_bitraverse #align bitraversable.id_tsnd Bitraversable.id_tsnd @[higher_order tfst_comp_tfst] theorem comp_tfst {α₀ α₁ α₂ β} (f : α₀ → F α₁) (f' : α₁ → G α₂) (x : t α₀ β) : Comp.mk (tfst f' <$> tfst f x) = tfst (Comp.mk ∘ map f' ∘ f) x := by rw [← comp_bitraverse] simp only [Function.comp, tfst, map_pure, Pure.pure] #align bitraversable.comp_tfst Bitraversable.comp_tfst @[higher_order tfst_comp_tsnd] theorem tfst_tsnd {α₀ α₁ β₀ β₁} (f : α₀ → F α₁) (f' : β₀ → G β₁) (x : t α₀ β₀) : Comp.mk (tfst f <$> tsnd f' x) = bitraverse (Comp.mk ∘ pure ∘ f) (Comp.mk ∘ map pure ∘ f') x := by rw [← comp_bitraverse] simp only [Function.comp, map_pure] #align bitraversable.tfst_tsnd Bitraversable.tfst_tsnd @[higher_order tsnd_comp_tfst] theorem tsnd_tfst {α₀ α₁ β₀ β₁} (f : α₀ → F α₁) (f' : β₀ → G β₁) (x : t α₀ β₀) : Comp.mk (tsnd f' <$> tfst f x) = bitraverse (Comp.mk ∘ map pure ∘ f) (Comp.mk ∘ pure ∘ f') x := by rw [← comp_bitraverse] simp only [Function.comp, map_pure] #align bitraversable.tsnd_tfst Bitraversable.tsnd_tfst @[higher_order tsnd_comp_tsnd] theorem comp_tsnd {α β₀ β₁ β₂} (g : β₀ → F β₁) (g' : β₁ → G β₂) (x : t α β₀) : Comp.mk (tsnd g' <$> tsnd g x) = tsnd (Comp.mk ∘ map g' ∘ g) x := by rw [← comp_bitraverse] simp only [Function.comp, map_pure] rfl #align bitraversable.comp_tsnd Bitraversable.comp_tsnd open Bifunctor -- Porting note: This private theorem wasn't needed -- private theorem pure_eq_id_mk_comp_id {α} : pure = id.mk ∘ @id α := rfl open Function @[higher_order]
Mathlib/Control/Bitraversable/Lemmas.lean
110
112
theorem tfst_eq_fst_id {α α' β} (f : α → α') (x : t α β) : tfst (F := Id) (pure ∘ f) x = pure (fst f x) := by
apply bitraverse_eq_bimap_id
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Julian Kuelshammer, Heather Macbeth, Mitchell Lee -/ import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Tactic.LinearCombination #align_import ring_theory.polynomial.chebyshev from "leanprover-community/mathlib"@"d774451114d6045faeb6751c396bea1eb9058946" /-! # Chebyshev polynomials The Chebyshev polynomials are families of polynomials indexed by `ℤ`, with integral coefficients. ## Main definitions * `Polynomial.Chebyshev.T`: the Chebyshev polynomials of the first kind. * `Polynomial.Chebyshev.U`: the Chebyshev polynomials of the second kind. ## Main statements * The formal derivative of the Chebyshev polynomials of the first kind is a scalar multiple of the Chebyshev polynomials of the second kind. * `Polynomial.Chebyshev.mul_T`, twice the product of the `m`-th and `k`-th Chebyshev polynomials of the first kind is the sum of the `m + k`-th and `m - k`-th Chebyshev polynomials of the first kind. * `Polynomial.Chebyshev.T_mul`, the `(m * n)`-th Chebyshev polynomial of the first kind is the composition of the `m`-th and `n`-th Chebyshev polynomials of the first kind. ## Implementation details Since Chebyshev polynomials have interesting behaviour over the complex numbers and modulo `p`, we define them to have coefficients in an arbitrary commutative ring, even though technically `ℤ` would suffice. The benefit of allowing arbitrary coefficient rings, is that the statements afterwards are clean, and do not have `map (Int.castRingHom R)` interfering all the time. ## References [Lionel Ponton, _Roots of the Chebyshev polynomials: A purely algebraic approach_] [ponton2020chebyshev] ## TODO * Redefine and/or relate the definition of Chebyshev polynomials to `LinearRecurrence`. * Add explicit formula involving square roots for Chebyshev polynomials * Compute zeroes and extrema of Chebyshev polynomials. * Prove that the roots of the Chebyshev polynomials (except 0) are irrational. * Prove minimax properties of Chebyshev polynomials. -/ namespace Polynomial.Chebyshev set_option linter.uppercaseLean3 false -- `T` `U` `X` open Polynomial variable (R S : Type*) [CommRing R] [CommRing S] /-- `T n` is the `n`-th Chebyshev polynomial of the first kind. -/ -- Well-founded definitions are now irreducible by default; -- as this was implemented before this change, -- we just set it back to semireducible to avoid needing to change any proofs. @[semireducible] noncomputable def T : ℤ → R[X] | 0 => 1 | 1 => X | (n : ℕ) + 2 => 2 * X * T (n + 1) - T n | -((n : ℕ) + 1) => 2 * X * T (-n) - T (-n + 1) termination_by n => Int.natAbs n + Int.natAbs (n - 1) #align polynomial.chebyshev.T Polynomial.Chebyshev.T /-- Induction principle used for proving facts about Chebyshev polynomials. -/ @[elab_as_elim] protected theorem induct (motive : ℤ → Prop) (zero : motive 0) (one : motive 1) (add_two : ∀ (n : ℕ), motive (↑n + 1) → motive ↑n → motive (↑n + 2)) (neg_add_one : ∀ (n : ℕ), motive (-↑n) → motive (-↑n + 1) → motive (-↑n - 1)) : ∀ (a : ℤ), motive a := T.induct Unit motive zero one add_two fun n hn hnm => by simpa only [Int.negSucc_eq, neg_add] using neg_add_one n hn hnm @[simp] theorem T_add_two : ∀ n, T R (n + 2) = 2 * X * T R (n + 1) - T R n | (k : ℕ) => T.eq_3 R k | -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) T.eq_4 R k #align polynomial.chebyshev.T_add_two Polynomial.Chebyshev.T_add_two theorem T_add_one (n : ℤ) : T R (n + 1) = 2 * X * T R n - T R (n - 1) := by linear_combination (norm := ring_nf) T_add_two R (n - 1) theorem T_sub_two (n : ℤ) : T R (n - 2) = 2 * X * T R (n - 1) - T R n := by linear_combination (norm := ring_nf) T_add_two R (n - 2)
Mathlib/RingTheory/Polynomial/Chebyshev.lean
96
97
theorem T_sub_one (n : ℤ) : T R (n - 1) = 2 * X * T R n - T R (n + 1) := by
linear_combination (norm := ring_nf) T_add_two R (n - 1)
/- Copyright (c) 2023 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals import Mathlib.Analysis.Calculus.ParametricIntegral import Mathlib.MeasureTheory.Measure.Haar.NormedSpace #align_import analysis.mellin_transform from "leanprover-community/mathlib"@"917c3c072e487b3cccdbfeff17e75b40e45f66cb" /-! # The Mellin transform We define the Mellin transform of a locally integrable function on `Ioi 0`, and show it is differentiable in a suitable vertical strip. ## Main statements - `mellin` : the Mellin transform `∫ (t : ℝ) in Ioi 0, t ^ (s - 1) • f t`, where `s` is a complex number. - `HasMellin`: shorthand asserting that the Mellin transform exists and has a given value (analogous to `HasSum`). - `mellin_differentiableAt_of_isBigO_rpow` : if `f` is `O(x ^ (-a))` at infinity, and `O(x ^ (-b))` at 0, then `mellin f` is holomorphic on the domain `b < re s < a`. -/ open MeasureTheory Set Filter Asymptotics TopologicalSpace open Real open Complex hiding exp log abs_of_nonneg open scoped Topology noncomputable section section Defs variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] /-- Predicate on `f` and `s` asserting that the Mellin integral is well-defined. -/ def MellinConvergent (f : ℝ → E) (s : ℂ) : Prop := IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (Ioi 0) #align mellin_convergent MellinConvergent theorem MellinConvergent.const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s) {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) : MellinConvergent (fun t => c • f t) s := by simpa only [MellinConvergent, smul_comm] using hf.smul c #align mellin_convergent.const_smul MellinConvergent.const_smul
Mathlib/Analysis/MellinTransform.lean
53
56
theorem MellinConvergent.cpow_smul {f : ℝ → E} {s a : ℂ} : MellinConvergent (fun t => (t : ℂ) ^ a • f t) s ↔ MellinConvergent f (s + a) := by
refine integrableOn_congr_fun (fun t ht => ?_) measurableSet_Ioi simp_rw [← sub_add_eq_add_sub, cpow_add _ _ (ofReal_ne_zero.2 <| ne_of_gt ht), mul_smul]
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.List.MinMax import Mathlib.Algebra.Tropical.Basic import Mathlib.Order.ConditionallyCompleteLattice.Finset #align_import algebra.tropical.big_operators from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce" /-! # Tropicalization of finitary operations This file provides the "big-op" or notation-based finitary operations on tropicalized types. This allows easy conversion between sums to Infs and prods to sums. Results here are important for expressing that evaluation of tropical polynomials are the minimum over a finite piecewise collection of linear functions. ## Main declarations * `untrop_sum` ## Implementation notes No concrete (semi)ring is used here, only ones with inferrable order/lattice structure, to support `Real`, `Rat`, `EReal`, and others (`ERat` is not yet defined). Minima over `List α` are defined as producing a value in `WithTop α` so proofs about lists do not directly transfer to minima over multisets or finsets. -/ variable {R S : Type*} open Tropical Finset theorem List.trop_sum [AddMonoid R] (l : List R) : trop l.sum = List.prod (l.map trop) := by induction' l with hd tl IH · simp · simp [← IH] #align list.trop_sum List.trop_sum theorem Multiset.trop_sum [AddCommMonoid R] (s : Multiset R) : trop s.sum = Multiset.prod (s.map trop) := Quotient.inductionOn s (by simpa using List.trop_sum) #align multiset.trop_sum Multiset.trop_sum theorem trop_sum [AddCommMonoid R] (s : Finset S) (f : S → R) : trop (∑ i ∈ s, f i) = ∏ i ∈ s, trop (f i) := by convert Multiset.trop_sum (s.val.map f) simp only [Multiset.map_map, Function.comp_apply] rfl #align trop_sum trop_sum theorem List.untrop_prod [AddMonoid R] (l : List (Tropical R)) : untrop l.prod = List.sum (l.map untrop) := by induction' l with hd tl IH · simp · simp [← IH] #align list.untrop_prod List.untrop_prod theorem Multiset.untrop_prod [AddCommMonoid R] (s : Multiset (Tropical R)) : untrop s.prod = Multiset.sum (s.map untrop) := Quotient.inductionOn s (by simpa using List.untrop_prod) #align multiset.untrop_prod Multiset.untrop_prod
Mathlib/Algebra/Tropical/BigOperators.lean
70
74
theorem untrop_prod [AddCommMonoid R] (s : Finset S) (f : S → Tropical R) : untrop (∏ i ∈ s, f i) = ∑ i ∈ s, untrop (f i) := by
convert Multiset.untrop_prod (s.val.map f) simp only [Multiset.map_map, Function.comp_apply] rfl
/- Copyright (c) 2023 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Geometry.Euclidean.Inversion.Basic import Mathlib.Geometry.Euclidean.PerpBisector /-! # Image of a hyperplane under inversion In this file we prove that the inversion with center `c` and radius `R ≠ 0` maps a sphere passing through the center to a hyperplane, and vice versa. More precisely, it maps a sphere with center `y ≠ c` and radius `dist y c` to the hyperplane `AffineSubspace.perpBisector c (EuclideanGeometry.inversion c R y)`. The exact statements are a little more complicated because `EuclideanGeometry.inversion c R` sends the center to itself, not to a point at infinity. We also prove that the inversion sends an affine subspace passing through the center to itself. ## Keywords inversion -/ open Metric Function AffineMap Set AffineSubspace open scoped Topology variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] {c x y : P} {R : ℝ} namespace EuclideanGeometry /-- The inversion with center `c` and radius `R` maps a sphere passing through the center to a hyperplane. -/ theorem inversion_mem_perpBisector_inversion_iff (hR : R ≠ 0) (hx : x ≠ c) (hy : y ≠ c) : inversion c R x ∈ perpBisector c (inversion c R y) ↔ dist x y = dist y c := by rw [mem_perpBisector_iff_dist_eq, dist_inversion_inversion hx hy, dist_inversion_center] have hx' := dist_ne_zero.2 hx have hy' := dist_ne_zero.2 hy field_simp [mul_assoc, mul_comm, hx, hx.symm, eq_comm] /-- The inversion with center `c` and radius `R` maps a sphere passing through the center to a hyperplane. -/ theorem inversion_mem_perpBisector_inversion_iff' (hR : R ≠ 0) (hy : y ≠ c) : inversion c R x ∈ perpBisector c (inversion c R y) ↔ dist x y = dist y c ∧ x ≠ c := by rcases eq_or_ne x c with rfl | hx · simp [*] · simp [inversion_mem_perpBisector_inversion_iff hR hx hy, hx] theorem preimage_inversion_perpBisector_inversion (hR : R ≠ 0) (hy : y ≠ c) : inversion c R ⁻¹' perpBisector c (inversion c R y) = sphere y (dist y c) \ {c} := Set.ext fun _ ↦ inversion_mem_perpBisector_inversion_iff' hR hy theorem preimage_inversion_perpBisector (hR : R ≠ 0) (hy : y ≠ c) : inversion c R ⁻¹' perpBisector c y = sphere (inversion c R y) (R ^ 2 / dist y c) \ {c} := by rw [← dist_inversion_center, ← preimage_inversion_perpBisector_inversion hR, inversion_inversion] <;> simp [*] theorem image_inversion_perpBisector (hR : R ≠ 0) (hy : y ≠ c) : inversion c R '' perpBisector c y = sphere (inversion c R y) (R ^ 2 / dist y c) \ {c} := by rw [image_eq_preimage_of_inverse (inversion_involutive _ hR) (inversion_involutive _ hR), preimage_inversion_perpBisector hR hy]
Mathlib/Geometry/Euclidean/Inversion/ImageHyperplane.lean
66
71
theorem preimage_inversion_sphere_dist_center (hR : R ≠ 0) (hy : y ≠ c) : inversion c R ⁻¹' sphere y (dist y c) = insert c (perpBisector c (inversion c R y) : Set P) := by
ext x rcases eq_or_ne x c with rfl | hx; · simp [dist_comm] rw [mem_preimage, mem_sphere, ← inversion_mem_perpBisector_inversion_iff hR] <;> simp [*]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Kenny Lau, Scott Morrison -/ import Mathlib.Data.List.Chain import Mathlib.Data.List.Enum import Mathlib.Data.List.Nodup import Mathlib.Data.List.Pairwise import Mathlib.Data.List.Zip #align_import data.list.range from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" /-! # Ranges of naturals as lists This file shows basic results about `List.iota`, `List.range`, `List.range'` and defines `List.finRange`. `finRange n` is the list of elements of `Fin n`. `iota n = [n, n - 1, ..., 1]` and `range n = [0, ..., n - 1]` are basic list constructions used for tactics. `range' a b = [a, ..., a + b - 1]` is there to help prove properties about them. Actual maths should use `List.Ico` instead. -/ set_option autoImplicit true universe u open Nat namespace List variable {α : Type u} @[simp] theorem range'_one {step} : range' s 1 step = [s] := rfl #align list.length_range' List.length_range' #align list.range'_eq_nil List.range'_eq_nil #align list.mem_range' List.mem_range'_1 #align list.map_add_range' List.map_add_range' #align list.map_sub_range' List.map_sub_range' #align list.chain_succ_range' List.chain_succ_range' #align list.chain_lt_range' List.chain_lt_range' theorem pairwise_lt_range' : ∀ s n (step := 1) (_ : 0 < step := by simp), Pairwise (· < ·) (range' s n step) | _, 0, _, _ => Pairwise.nil | s, n + 1, _, h => chain_iff_pairwise.1 (chain_lt_range' s n h) #align list.pairwise_lt_range' List.pairwise_lt_range' theorem nodup_range' (s n : ℕ) (step := 1) (h : 0 < step := by simp) : Nodup (range' s n step) := (pairwise_lt_range' s n step h).imp _root_.ne_of_lt #align list.nodup_range' List.nodup_range' #align list.range'_append List.range'_append #align list.range'_sublist_right List.range'_sublist_right #align list.range'_subset_right List.range'_subset_right #align list.nth_range' List.get?_range' set_option linter.deprecated false in @[simp] theorem nthLe_range' {n m step} (i) (H : i < (range' n m step).length) : nthLe (range' n m step) i H = n + step * i := get_range' i H set_option linter.deprecated false in theorem nthLe_range'_1 {n m} (i) (H : i < (range' n m).length) : nthLe (range' n m) i H = n + i := by simp #align list.nth_le_range' List.nthLe_range'_1 #align list.range'_concat List.range'_concat #align list.range_core List.range.loop #align list.range_core_range' List.range_loop_range' #align list.range_eq_range' List.range_eq_range' #align list.range_succ_eq_map List.range_succ_eq_map #align list.range'_eq_map_range List.range'_eq_map_range #align list.length_range List.length_range #align list.range_eq_nil List.range_eq_nil theorem pairwise_lt_range (n : ℕ) : Pairwise (· < ·) (range n) := by simp (config := {decide := true}) only [range_eq_range', pairwise_lt_range'] #align list.pairwise_lt_range List.pairwise_lt_range theorem pairwise_le_range (n : ℕ) : Pairwise (· ≤ ·) (range n) := Pairwise.imp (@le_of_lt ℕ _) (pairwise_lt_range _) #align list.pairwise_le_range List.pairwise_le_range
Mathlib/Data/List/Range.lean
87
90
theorem take_range (m n : ℕ) : take m (range n) = range (min m n) := by
apply List.ext_get · simp · simp (config := { contextual := true }) [← get_take, Nat.lt_min]
/- 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, Yourong Zang -/ import Mathlib.Analysis.Calculus.ContDiff.Basic import Mathlib.Analysis.Calculus.Deriv.Linear import Mathlib.Analysis.Complex.Conformal import Mathlib.Analysis.Calculus.Conformal.NormedSpace #align_import analysis.complex.real_deriv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Real differentiability of complex-differentiable functions `HasDerivAt.real_of_complex` expresses that, if a function on `ℂ` is differentiable (over `ℂ`), then its restriction to `ℝ` is differentiable over `ℝ`, with derivative the real part of the complex derivative. `DifferentiableAt.conformalAt` states that a real-differentiable function with a nonvanishing differential from the complex plane into an arbitrary complex-normed space is conformal at a point if it's holomorphic at that point. This is a version of Cauchy-Riemann equations. `conformalAt_iff_differentiableAt_or_differentiableAt_comp_conj` proves that a real-differential function with a nonvanishing differential between the complex plane is conformal at a point if and only if it's holomorphic or antiholomorphic at that point. ## TODO * The classical form of Cauchy-Riemann equations * On a connected open set `u`, a function which is `ConformalAt` each point is either holomorphic throughout or antiholomorphic throughout. ## Warning We do NOT require conformal functions to be orientation-preserving in this file. -/ section RealDerivOfComplex /-! ### Differentiability of the restriction to `ℝ` of complex functions -/ open Complex variable {e : ℂ → ℂ} {e' : ℂ} {z : ℝ} /-- If a complex function is differentiable at a real point, then the induced real function is also differentiable at this point, with a derivative equal to the real part of the complex derivative. -/ theorem HasStrictDerivAt.real_of_complex (h : HasStrictDerivAt e e' z) : HasStrictDerivAt (fun x : ℝ => (e x).re) e'.re z := by have A : HasStrictFDerivAt ((↑) : ℝ → ℂ) ofRealCLM z := ofRealCLM.hasStrictFDerivAt have B : HasStrictFDerivAt e ((ContinuousLinearMap.smulRight 1 e' : ℂ →L[ℂ] ℂ).restrictScalars ℝ) (ofRealCLM z) := h.hasStrictFDerivAt.restrictScalars ℝ have C : HasStrictFDerivAt re reCLM (e (ofRealCLM z)) := reCLM.hasStrictFDerivAt -- Porting note: this should be by: -- simpa using (C.comp z (B.comp z A)).hasStrictDerivAt -- but for some reason simp can not use `ContinuousLinearMap.comp_apply` convert (C.comp z (B.comp z A)).hasStrictDerivAt rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.comp_apply] simp #align has_strict_deriv_at.real_of_complex HasStrictDerivAt.real_of_complex /-- If a complex function `e` is differentiable at a real point, then the function `ℝ → ℝ` given by the real part of `e` is also differentiable at this point, with a derivative equal to the real part of the complex derivative. -/ theorem HasDerivAt.real_of_complex (h : HasDerivAt e e' z) : HasDerivAt (fun x : ℝ => (e x).re) e'.re z := by have A : HasFDerivAt ((↑) : ℝ → ℂ) ofRealCLM z := ofRealCLM.hasFDerivAt have B : HasFDerivAt e ((ContinuousLinearMap.smulRight 1 e' : ℂ →L[ℂ] ℂ).restrictScalars ℝ) (ofRealCLM z) := h.hasFDerivAt.restrictScalars ℝ have C : HasFDerivAt re reCLM (e (ofRealCLM z)) := reCLM.hasFDerivAt -- Porting note: this should be by: -- simpa using (C.comp z (B.comp z A)).hasStrictDerivAt -- but for some reason simp can not use `ContinuousLinearMap.comp_apply` convert (C.comp z (B.comp z A)).hasDerivAt rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.comp_apply] simp #align has_deriv_at.real_of_complex HasDerivAt.real_of_complex
Mathlib/Analysis/Complex/RealDeriv.lean
84
89
theorem ContDiffAt.real_of_complex {n : ℕ∞} (h : ContDiffAt ℂ n e z) : ContDiffAt ℝ n (fun x : ℝ => (e x).re) z := by
have A : ContDiffAt ℝ n ((↑) : ℝ → ℂ) z := ofRealCLM.contDiff.contDiffAt have B : ContDiffAt ℝ n e z := h.restrict_scalars ℝ have C : ContDiffAt ℝ n re (e z) := reCLM.contDiff.contDiffAt exact C.comp z (B.comp z A)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Uni Marx -/ import Mathlib.CategoryTheory.Iso import Mathlib.CategoryTheory.EssentialImage import Mathlib.CategoryTheory.Types import Mathlib.CategoryTheory.Opposites import Mathlib.Data.Rel #align_import category_theory.category.Rel from "leanprover-community/mathlib"@"afad8e438d03f9d89da2914aa06cb4964ba87a18" /-! # Basics on the category of relations We define the category of types `CategoryTheory.RelCat` with binary relations as morphisms. Associating each function with the relation defined by its graph yields a faithful and essentially surjective functor `graphFunctor` that also characterizes all isomorphisms (see `rel_iso_iff`). By flipping the arguments to a relation, we construct an equivalence `opEquivalence` between `RelCat` and its opposite. -/ namespace CategoryTheory universe u -- This file is about Lean 3 declaration "Rel". set_option linter.uppercaseLean3 false /-- A type synonym for `Type`, which carries the category instance for which morphisms are binary relations. -/ def RelCat := Type u #align category_theory.Rel CategoryTheory.RelCat instance RelCat.inhabited : Inhabited RelCat := by unfold RelCat; infer_instance #align category_theory.Rel.inhabited CategoryTheory.RelCat.inhabited /-- The category of types with binary relations as morphisms. -/ instance rel : LargeCategory RelCat where Hom X Y := X → Y → Prop id X x y := x = y comp f g x z := ∃ y, f x y ∧ g y z #align category_theory.rel CategoryTheory.rel namespace RelCat @[ext] theorem hom_ext {X Y : RelCat} (f g : X ⟶ Y) (h : ∀ a b, f a b ↔ g a b) : f = g := funext₂ (fun a b => propext (h a b)) namespace Hom protected theorem rel_id (X : RelCat) : 𝟙 X = (· = ·) := rfl protected theorem rel_comp {X Y Z : RelCat} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = Rel.comp f g := rfl theorem rel_id_apply₂ (X : RelCat) (x y : X) : (𝟙 X) x y ↔ x = y := by rw [RelCat.Hom.rel_id] theorem rel_comp_apply₂ {X Y Z : RelCat} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) (z : Z) : (f ≫ g) x z ↔ ∃ y, f x y ∧ g y z := by rfl end Hom /-- The essentially surjective faithful embedding from the category of types and functions into the category of types and relations. -/ def graphFunctor : Type u ⥤ RelCat.{u} where obj X := X map f := f.graph map_id X := by ext simp [Hom.rel_id_apply₂] map_comp f g := by ext simp [Hom.rel_comp_apply₂] @[simp] theorem graphFunctor_map {X Y : Type u} (f : X ⟶ Y) (x : X) (y : Y) : graphFunctor.map f x y ↔ f x = y := f.graph_def x y instance graphFunctor_faithful : graphFunctor.Faithful where map_injective h := Function.graph_injective h instance graphFunctor_essSurj : graphFunctor.EssSurj := graphFunctor.essSurj_of_surj Function.surjective_id /-- A relation is an isomorphism in `RelCat` iff it is the image of an isomorphism in `Type`. -/
Mathlib/CategoryTheory/Category/RelCat.lean
93
122
theorem rel_iso_iff {X Y : RelCat} (r : X ⟶ Y) : IsIso (C := RelCat) r ↔ ∃ f : (Iso (C := Type) X Y), graphFunctor.map f.hom = r := by
constructor · intro h have h1 := congr_fun₂ h.hom_inv_id have h2 := congr_fun₂ h.inv_hom_id simp only [RelCat.Hom.rel_comp_apply₂, RelCat.Hom.rel_id_apply₂, eq_iff_iff] at h1 h2 obtain ⟨f, hf⟩ := Classical.axiomOfChoice (fun a => (h1 a a).mpr rfl) obtain ⟨g, hg⟩ := Classical.axiomOfChoice (fun a => (h2 a a).mpr rfl) suffices hif : IsIso (C := Type) f by use asIso f ext x y simp only [asIso_hom, graphFunctor_map] constructor · rintro rfl exact (hf x).1 · intro hr specialize h2 (f x) y rw [← h2] use x, (hf x).2, hr use g constructor · ext x apply (h1 _ _).mp use f x, (hg _).2, (hf _).2 · ext y apply (h2 _ _).mp use g y, (hf (g y)).2, (hg y).2 · rintro ⟨f, rfl⟩ apply graphFunctor.map_isIso
/- 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.Algebra.MonoidAlgebra.Basic #align_import algebra.monoid_algebra.division from "leanprover-community/mathlib"@"72c366d0475675f1309d3027d3d7d47ee4423951" /-! # Division of `AddMonoidAlgebra` by monomials This file is most important for when `G = ℕ` (polynomials) or `G = σ →₀ ℕ` (multivariate polynomials). In order to apply in maximal generality (such as for `LaurentPolynomial`s), this uses `∃ d, g' = g + d` in many places instead of `g ≤ g'`. ## Main definitions * `AddMonoidAlgebra.divOf x g`: divides `x` by the monomial `AddMonoidAlgebra.of k G g` * `AddMonoidAlgebra.modOf x g`: the remainder upon dividing `x` by the monomial `AddMonoidAlgebra.of k G g`. ## Main results * `AddMonoidAlgebra.divOf_add_modOf`, `AddMonoidAlgebra.modOf_add_divOf`: `divOf` and `modOf` are well-behaved as quotient and remainder operators. ## Implementation notes `∃ d, g' = g + d` is used as opposed to some other permutation up to commutativity in order to match the definition of `semigroupDvd`. The results in this file could be duplicated for `MonoidAlgebra` by using `g ∣ g'`, but this can't be done automatically, and in any case is not likely to be very useful. -/ variable {k G : Type*} [Semiring k] namespace AddMonoidAlgebra section variable [AddCancelCommMonoid G] /-- Divide by `of' k G g`, discarding terms not divisible by this. -/ noncomputable def divOf (x : k[G]) (g : G) : k[G] := -- note: comapping by `+ g` has the effect of subtracting `g` from every element in -- the support, and discarding the elements of the support from which `g` can't be subtracted. -- If `G` is an additive group, such as `ℤ` when used for `LaurentPolynomial`, -- then no discarding occurs. @Finsupp.comapDomain.addMonoidHom _ _ _ _ (g + ·) (add_right_injective g) x #align add_monoid_algebra.div_of AddMonoidAlgebra.divOf local infixl:70 " /ᵒᶠ " => divOf @[simp] theorem divOf_apply (g : G) (x : k[G]) (g' : G) : (x /ᵒᶠ g) g' = x (g + g') := rfl #align add_monoid_algebra.div_of_apply AddMonoidAlgebra.divOf_apply @[simp] theorem support_divOf (g : G) (x : k[G]) : (x /ᵒᶠ g).support = x.support.preimage (g + ·) (Function.Injective.injOn (add_right_injective g)) := rfl #align add_monoid_algebra.support_div_of AddMonoidAlgebra.support_divOf @[simp] theorem zero_divOf (g : G) : (0 : k[G]) /ᵒᶠ g = 0 := map_zero (Finsupp.comapDomain.addMonoidHom _) #align add_monoid_algebra.zero_div_of AddMonoidAlgebra.zero_divOf @[simp] theorem divOf_zero (x : k[G]) : x /ᵒᶠ 0 = x := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work simp only [AddMonoidAlgebra.divOf_apply, zero_add] #align add_monoid_algebra.div_of_zero AddMonoidAlgebra.divOf_zero theorem add_divOf (x y : k[G]) (g : G) : (x + y) /ᵒᶠ g = x /ᵒᶠ g + y /ᵒᶠ g := map_add (Finsupp.comapDomain.addMonoidHom _) _ _ #align add_monoid_algebra.add_div_of AddMonoidAlgebra.add_divOf theorem divOf_add (x : k[G]) (a b : G) : x /ᵒᶠ (a + b) = x /ᵒᶠ a /ᵒᶠ b := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work simp only [AddMonoidAlgebra.divOf_apply, add_assoc] #align add_monoid_algebra.div_of_add AddMonoidAlgebra.divOf_add /-- A bundled version of `AddMonoidAlgebra.divOf`. -/ @[simps] noncomputable def divOfHom : Multiplicative G →* AddMonoid.End k[G] where toFun g := { toFun := fun x => divOf x (Multiplicative.toAdd g) map_zero' := zero_divOf _ map_add' := fun x y => add_divOf x y (Multiplicative.toAdd g) } map_one' := AddMonoidHom.ext divOf_zero map_mul' g₁ g₂ := AddMonoidHom.ext fun _x => (congr_arg _ (add_comm (Multiplicative.toAdd g₁) (Multiplicative.toAdd g₂))).trans (divOf_add _ _ _) #align add_monoid_algebra.div_of_hom AddMonoidAlgebra.divOfHom theorem of'_mul_divOf (a : G) (x : k[G]) : of' k G a * x /ᵒᶠ a = x := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work rw [AddMonoidAlgebra.divOf_apply, of'_apply, single_mul_apply_aux, one_mul] intro c exact add_right_inj _ #align add_monoid_algebra.of'_mul_div_of AddMonoidAlgebra.of'_mul_divOf
Mathlib/Algebra/MonoidAlgebra/Division.lean
112
117
theorem mul_of'_divOf (x : k[G]) (a : G) : x * of' k G a /ᵒᶠ a = x := by
refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work rw [AddMonoidAlgebra.divOf_apply, of'_apply, mul_single_apply_aux, mul_one] intro c rw [add_comm] exact add_right_inj _
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.FormalMultilinearSeries import Mathlib.Analysis.SpecificLimits.Normed import Mathlib.Logic.Equiv.Fin import Mathlib.Topology.Algebra.InfiniteSum.Module #align_import analysis.analytic.basic from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514" /-! # Analytic functions A function is analytic in one dimension around `0` if it can be written as a converging power series `Σ pₙ zⁿ`. This definition can be extended to any dimension (even in infinite dimension) by requiring that `pₙ` is a continuous `n`-multilinear map. In general, `pₙ` is not unique (in two dimensions, taking `p₂ (x, y) (x', y') = x y'` or `y x'` gives the same map when applied to a vector `(x, y) (x, y)`). A way to guarantee uniqueness is to take a symmetric `pₙ`, but this is not always possible in nonzero characteristic (in characteristic 2, the previous example has no symmetric representative). Therefore, we do not insist on symmetry or uniqueness in the definition, and we only require the existence of a converging series. The general framework is important to say that the exponential map on bounded operators on a Banach space is analytic, as well as the inverse on invertible operators. ## Main definitions Let `p` be a formal multilinear series from `E` to `F`, i.e., `p n` is a multilinear map on `E^n` for `n : ℕ`. * `p.radius`: the largest `r : ℝ≥0∞` such that `‖p n‖ * r^n` grows subexponentially. * `p.le_radius_of_bound`, `p.le_radius_of_bound_nnreal`, `p.le_radius_of_isBigO`: if `‖p n‖ * r ^ n` is bounded above, then `r ≤ p.radius`; * `p.isLittleO_of_lt_radius`, `p.norm_mul_pow_le_mul_pow_of_lt_radius`, `p.isLittleO_one_of_lt_radius`, `p.norm_mul_pow_le_of_lt_radius`, `p.nnnorm_mul_pow_le_of_lt_radius`: if `r < p.radius`, then `‖p n‖ * r ^ n` tends to zero exponentially; * `p.lt_radius_of_isBigO`: if `r ≠ 0` and `‖p n‖ * r ^ n = O(a ^ n)` for some `-1 < a < 1`, then `r < p.radius`; * `p.partialSum n x`: the sum `∑_{i = 0}^{n-1} pᵢ xⁱ`. * `p.sum x`: the sum `∑'_{i = 0}^{∞} pᵢ xⁱ`. Additionally, let `f` be a function from `E` to `F`. * `HasFPowerSeriesOnBall f p x r`: on the ball of center `x` with radius `r`, `f (x + y) = ∑'_n pₙ yⁿ`. * `HasFPowerSeriesAt f p x`: on some ball of center `x` with positive radius, holds `HasFPowerSeriesOnBall f p x r`. * `AnalyticAt 𝕜 f x`: there exists a power series `p` such that holds `HasFPowerSeriesAt f p x`. * `AnalyticOn 𝕜 f s`: the function `f` is analytic at every point of `s`. We develop the basic properties of these notions, notably: * If a function admits a power series, it is continuous (see `HasFPowerSeriesOnBall.continuousOn` and `HasFPowerSeriesAt.continuousAt` and `AnalyticAt.continuousAt`). * In a complete space, the sum of a formal power series with positive radius is well defined on the disk of convergence, see `FormalMultilinearSeries.hasFPowerSeriesOnBall`. * If a function admits a power series in a ball, then it is analytic at any point `y` of this ball, and the power series there can be expressed in terms of the initial power series `p` as `p.changeOrigin y`. See `HasFPowerSeriesOnBall.changeOrigin`. It follows in particular that the set of points at which a given function is analytic is open, see `isOpen_analyticAt`. ## Implementation details We only introduce the radius of convergence of a power series, as `p.radius`. For a power series in finitely many dimensions, there is a finer (directional, coordinate-dependent) notion, describing the polydisk of convergence. This notion is more specific, and not necessary to build the general theory. We do not define it here. -/ noncomputable section variable {𝕜 E F G : Type*} open scoped Classical open Topology NNReal Filter ENNReal open Set Filter Asymptotics namespace FormalMultilinearSeries variable [Ring 𝕜] [AddCommGroup E] [AddCommGroup F] [Module 𝕜 E] [Module 𝕜 F] variable [TopologicalSpace E] [TopologicalSpace F] variable [TopologicalAddGroup E] [TopologicalAddGroup F] variable [ContinuousConstSMul 𝕜 E] [ContinuousConstSMul 𝕜 F] /-- Given a formal multilinear series `p` and a vector `x`, then `p.sum x` is the sum `Σ pₙ xⁿ`. A priori, it only behaves well when `‖x‖ < p.radius`. -/ protected def sum (p : FormalMultilinearSeries 𝕜 E F) (x : E) : F := ∑' n : ℕ, p n fun _ => x #align formal_multilinear_series.sum FormalMultilinearSeries.sum /-- Given a formal multilinear series `p` and a vector `x`, then `p.partialSum n x` is the sum `Σ pₖ xᵏ` for `k ∈ {0,..., n-1}`. -/ def partialSum (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) (x : E) : F := ∑ k ∈ Finset.range n, p k fun _ : Fin k => x #align formal_multilinear_series.partial_sum FormalMultilinearSeries.partialSum /-- The partial sums of a formal multilinear series are continuous. -/
Mathlib/Analysis/Analytic/Basic.lean
102
105
theorem partialSum_continuous (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) : Continuous (p.partialSum n) := by
unfold partialSum -- Porting note: added continuity
/- Copyright (c) 2019 Jan-David Salchow. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo -/ import Mathlib.Algebra.Algebra.Tower import Mathlib.Analysis.LocallyConvex.WithSeminorms import Mathlib.Topology.Algebra.Module.StrongTopology import Mathlib.Analysis.NormedSpace.LinearIsometry import Mathlib.Analysis.NormedSpace.ContinuousLinearMap import Mathlib.Tactic.SuppressCompilation #align_import analysis.normed_space.operator_norm from "leanprover-community/mathlib"@"f7ebde7ee0d1505dfccac8644ae12371aa3c1c9f" /-! # Operator norm on the space of continuous linear maps Define the operator (semi)-norm on the space of continuous (semi)linear maps between (semi)-normed spaces, and prove its basic properties. In particular, show that this space is itself a semi-normed space. Since a lot of elementary properties don't require `‖x‖ = 0 → x = 0` we start setting up the theory for `SeminormedAddCommGroup`. Later we will specialize to `NormedAddCommGroup` in the file `NormedSpace.lean`. Note that most of statements that apply to semilinear maps only hold when the ring homomorphism is isometric, as expressed by the typeclass `[RingHomIsometric σ]`. -/ suppress_compilation open Bornology open Filter hiding map_smul open scoped Classical NNReal Topology Uniformity -- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps variable {𝕜 𝕜₂ 𝕜₃ E Eₗ F Fₗ G Gₗ 𝓕 : Type*} section SemiNormed open Metric ContinuousLinearMap variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup Eₗ] [SeminormedAddCommGroup F] [SeminormedAddCommGroup Fₗ] [SeminormedAddCommGroup G] [SeminormedAddCommGroup Gₗ] variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃] [NormedSpace 𝕜 E] [NormedSpace 𝕜 Eₗ] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜 Fₗ] [NormedSpace 𝕜₃ G] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} {σ₁₃ : 𝕜 →+* 𝕜₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable [FunLike 𝓕 E F] /-- If `‖x‖ = 0` and `f` is continuous then `‖f x‖ = 0`. -/
Mathlib/Analysis/NormedSpace/OperatorNorm/Basic.lean
54
57
theorem norm_image_of_norm_zero [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕) (hf : Continuous f) {x : E} (hx : ‖x‖ = 0) : ‖f x‖ = 0 := by
rw [← mem_closure_zero_iff_norm, ← specializes_iff_mem_closure, ← map_zero f] at * exact hx.map hf
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, 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 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⟩ -- Porting note: breaking up original definition of quotientInfEquivSupQuotient to avoid timing out
Mathlib/LinearAlgebra/Isomorphisms.lean
88
93
theorem quotientInfEquivSupQuotient_surjective (p p' : Submodule R M) : Function.Surjective (quotientInfToSupQuotient p p') := by
rw [← range_eq_top, quotientInfToSupQuotient, range_liftQ, eq_top_iff'] rintro ⟨x, hx⟩; rcases mem_sup.1 hx with ⟨y, hy, z, hz, rfl⟩ use ⟨y, hy⟩; apply (Submodule.Quotient.eq _).2 simp only [mem_comap, map_sub, coeSubtype, coe_inclusion, sub_add_cancel_left, neg_mem_iff, hz]
/- Copyright (c) 2020 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash, Antoine Labelle -/ import Mathlib.LinearAlgebra.Dual import Mathlib.LinearAlgebra.Matrix.ToLin #align_import linear_algebra.contraction from "leanprover-community/mathlib"@"657df4339ae6ceada048c8a2980fb10e393143ec" /-! # Contractions Given modules $M, N$ over a commutative ring $R$, this file defines the natural linear maps: $M^* \otimes M \to R$, $M \otimes M^* \to R$, and $M^* \otimes N → Hom(M, N)$, as well as proving some basic properties of these maps. ## Tags contraction, dual module, tensor product -/ suppress_compilation -- Porting note: universe metavariables behave oddly universe w u v₁ v₂ v₃ v₄ variable {ι : Type w} (R : Type u) (M : Type v₁) (N : Type v₂) (P : Type v₃) (Q : Type v₄) -- Porting note: we need high priority for this to fire first; not the case in ML3 attribute [local ext high] TensorProduct.ext section Contraction open TensorProduct LinearMap Matrix Module open TensorProduct section CommSemiring variable [CommSemiring R] variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q] variable [Module R M] [Module R N] [Module R P] [Module R Q] variable [DecidableEq ι] [Fintype ι] (b : Basis ι R M) -- Porting note: doesn't like implicit ring in the tensor product /-- The natural left-handed pairing between a module and its dual. -/ def contractLeft : Module.Dual R M ⊗[R] M →ₗ[R] R := (uncurry _ _ _ _).toFun LinearMap.id #align contract_left contractLeft -- Porting note: doesn't like implicit ring in the tensor product /-- The natural right-handed pairing between a module and its dual. -/ def contractRight : M ⊗[R] Module.Dual R M →ₗ[R] R := (uncurry _ _ _ _).toFun (LinearMap.flip LinearMap.id) #align contract_right contractRight -- Porting note: doesn't like implicit ring in the tensor product /-- The natural map associating a linear map to the tensor product of two modules. -/ def dualTensorHom : Module.Dual R M ⊗[R] N →ₗ[R] M →ₗ[R] N := let M' := Module.Dual R M (uncurry R M' N (M →ₗ[R] N) : _ → M' ⊗ N →ₗ[R] M →ₗ[R] N) LinearMap.smulRightₗ #align dual_tensor_hom dualTensorHom variable {R M N P Q} @[simp] theorem contractLeft_apply (f : Module.Dual R M) (m : M) : contractLeft R M (f ⊗ₜ m) = f m := rfl #align contract_left_apply contractLeft_apply @[simp] theorem contractRight_apply (f : Module.Dual R M) (m : M) : contractRight R M (m ⊗ₜ f) = f m := rfl #align contract_right_apply contractRight_apply @[simp] theorem dualTensorHom_apply (f : Module.Dual R M) (m : M) (n : N) : dualTensorHom R M N (f ⊗ₜ n) m = f m • n := rfl #align dual_tensor_hom_apply dualTensorHom_apply @[simp] theorem transpose_dualTensorHom (f : Module.Dual R M) (m : M) : Dual.transpose (R := R) (dualTensorHom R M M (f ⊗ₜ m)) = dualTensorHom R _ _ (Dual.eval R M m ⊗ₜ f) := by ext f' m' simp only [Dual.transpose_apply, coe_comp, Function.comp_apply, dualTensorHom_apply, LinearMap.map_smulₛₗ, RingHom.id_apply, Algebra.id.smul_eq_mul, Dual.eval_apply, LinearMap.smul_apply] exact mul_comm _ _ #align transpose_dual_tensor_hom transpose_dualTensorHom @[simp] theorem dualTensorHom_prodMap_zero (f : Module.Dual R M) (p : P) : ((dualTensorHom R M P) (f ⊗ₜ[R] p)).prodMap (0 : N →ₗ[R] Q) = dualTensorHom R (M × N) (P × Q) ((f ∘ₗ fst R M N) ⊗ₜ inl R P Q p) := by ext <;> simp only [coe_comp, coe_inl, Function.comp_apply, prodMap_apply, dualTensorHom_apply, fst_apply, Prod.smul_mk, LinearMap.zero_apply, smul_zero] #align dual_tensor_hom_prod_map_zero dualTensorHom_prodMap_zero @[simp] theorem zero_prodMap_dualTensorHom (g : Module.Dual R N) (q : Q) : (0 : M →ₗ[R] P).prodMap ((dualTensorHom R N Q) (g ⊗ₜ[R] q)) = dualTensorHom R (M × N) (P × Q) ((g ∘ₗ snd R M N) ⊗ₜ inr R P Q q) := by ext <;> simp only [coe_comp, coe_inr, Function.comp_apply, prodMap_apply, dualTensorHom_apply, snd_apply, Prod.smul_mk, LinearMap.zero_apply, smul_zero] #align zero_prod_map_dual_tensor_hom zero_prodMap_dualTensorHom
Mathlib/LinearAlgebra/Contraction.lean
113
118
theorem map_dualTensorHom (f : Module.Dual R M) (p : P) (g : Module.Dual R N) (q : Q) : TensorProduct.map (dualTensorHom R M P (f ⊗ₜ[R] p)) (dualTensorHom R N Q (g ⊗ₜ[R] q)) = dualTensorHom R (M ⊗[R] N) (P ⊗[R] Q) (dualDistrib R M N (f ⊗ₜ g) ⊗ₜ[R] p ⊗ₜ[R] q) := by
ext m n simp only [compr₂_apply, mk_apply, map_tmul, dualTensorHom_apply, dualDistrib_apply, ← smul_tmul_smul]
/- 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.Group.Basic import Mathlib.Algebra.Group.Nat import Mathlib.Init.Data.Nat.Lemmas #align_import data.nat.psub from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" /-! # Partial predecessor and partial subtraction on the natural numbers The usual definition of natural number subtraction (`Nat.sub`) returns 0 as a "garbage value" for `a - b` when `a < b`. Similarly, `Nat.pred 0` is defined to be `0`. The functions in this file wrap the result in an `Option` type instead: ## Main definitions - `Nat.ppred`: a partial predecessor operation - `Nat.psub`: a partial subtraction operation -/ namespace Nat /-- Partial predecessor operation. Returns `ppred n = some m` if `n = m + 1`, otherwise `none`. -/ def ppred : ℕ → Option ℕ | 0 => none | n + 1 => some n #align nat.ppred Nat.ppred @[simp] theorem ppred_zero : ppred 0 = none := rfl @[simp] theorem ppred_succ {n : ℕ} : ppred (succ n) = some n := rfl /-- Partial subtraction operation. Returns `psub m n = some k` if `m = n + k`, otherwise `none`. -/ def psub (m : ℕ) : ℕ → Option ℕ | 0 => some m | n + 1 => psub m n >>= ppred #align nat.psub Nat.psub @[simp] theorem psub_zero {m : ℕ} : psub m 0 = some m := rfl @[simp] theorem psub_succ {m n : ℕ} : psub m (succ n) = psub m n >>= ppred := rfl theorem pred_eq_ppred (n : ℕ) : pred n = (ppred n).getD 0 := by cases n <;> rfl #align nat.pred_eq_ppred Nat.pred_eq_ppred theorem sub_eq_psub (m : ℕ) : ∀ n, m - n = (psub m n).getD 0 | 0 => rfl | n + 1 => (pred_eq_ppred (m - n)).trans <| by rw [sub_eq_psub m n, psub]; cases psub m n <;> rfl #align nat.sub_eq_psub Nat.sub_eq_psub @[simp] theorem ppred_eq_some {m : ℕ} : ∀ {n}, ppred n = some m ↔ succ m = n | 0 => by constructor <;> intro h <;> contradiction | n + 1 => by constructor <;> intro h <;> injection h <;> subst m <;> rfl #align nat.ppred_eq_some Nat.ppred_eq_some -- Porting note: `contradiction` required an `intro` for the goals -- `ppred (n + 1) = none → n + 1 = 0` and `n + 1 = 0 → ppred (n + 1) = none` @[simp] theorem ppred_eq_none : ∀ {n : ℕ}, ppred n = none ↔ n = 0 | 0 => by simp | n + 1 => by constructor <;> intro <;> contradiction #align nat.ppred_eq_none Nat.ppred_eq_none theorem psub_eq_some {m : ℕ} : ∀ {n k}, psub m n = some k ↔ k + n = m | 0, k => by simp [eq_comm] | n + 1, k => by apply Option.bind_eq_some.trans simp only [psub_eq_some, ppred_eq_some] simp [add_comm, add_left_comm, Nat.succ_eq_add_one] #align nat.psub_eq_some Nat.psub_eq_some
Mathlib/Data/Nat/PSub.lean
85
93
theorem psub_eq_none {m n : ℕ} : psub m n = none ↔ m < n := by
cases s : psub m n <;> simp [eq_comm] · show m < n refine lt_of_not_ge fun h => ?_ cases' le.dest h with k e injection s.symm.trans (psub_eq_some.2 <| (add_comm _ _).trans e) · show n ≤ m rw [← psub_eq_some.1 s] apply Nat.le_add_left
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.SetTheory.Game.State #align_import set_theory.game.domineering from "leanprover-community/mathlib"@"b134b2f5cf6dd25d4bbfd3c498b6e36c11a17225" /-! # Domineering as a combinatorial game. We define the game of Domineering, played on a chessboard of arbitrary shape (possibly even disconnected). Left moves by placing a domino vertically, while Right moves by placing a domino horizontally. This is only a fragment of a full development; in order to successfully analyse positions we would need some more theorems. Most importantly, we need a general statement that allows us to discard irrelevant moves. Specifically to domineering, we need the fact that disjoint parts of the chessboard give sums of games. -/ namespace SetTheory namespace PGame namespace Domineering open Function /-- The equivalence `(x, y) ↦ (x, y+1)`. -/ @[simps!] def shiftUp : ℤ × ℤ ≃ ℤ × ℤ := (Equiv.refl ℤ).prodCongr (Equiv.addRight (1 : ℤ)) #align pgame.domineering.shift_up SetTheory.PGame.Domineering.shiftUp /-- The equivalence `(x, y) ↦ (x+1, y)`. -/ @[simps!] def shiftRight : ℤ × ℤ ≃ ℤ × ℤ := (Equiv.addRight (1 : ℤ)).prodCongr (Equiv.refl ℤ) #align pgame.domineering.shift_right SetTheory.PGame.Domineering.shiftRight /-- A Domineering board is an arbitrary finite subset of `ℤ × ℤ`. -/ -- Porting note: reducibility cannot be `local`. For now there are no dependents of this file so -- being globally reducible is fine. abbrev Board := Finset (ℤ × ℤ) #align pgame.domineering.board SetTheory.PGame.Domineering.Board /-- Left can play anywhere that a square and the square below it are open. -/ def left (b : Board) : Finset (ℤ × ℤ) := b ∩ b.map shiftUp #align pgame.domineering.left SetTheory.PGame.Domineering.left /-- Right can play anywhere that a square and the square to the left are open. -/ def right (b : Board) : Finset (ℤ × ℤ) := b ∩ b.map shiftRight #align pgame.domineering.right SetTheory.PGame.Domineering.right theorem mem_left {b : Board} (x : ℤ × ℤ) : x ∈ left b ↔ x ∈ b ∧ (x.1, x.2 - 1) ∈ b := Finset.mem_inter.trans (and_congr Iff.rfl Finset.mem_map_equiv) #align pgame.domineering.mem_left SetTheory.PGame.Domineering.mem_left theorem mem_right {b : Board} (x : ℤ × ℤ) : x ∈ right b ↔ x ∈ b ∧ (x.1 - 1, x.2) ∈ b := Finset.mem_inter.trans (and_congr Iff.rfl Finset.mem_map_equiv) #align pgame.domineering.mem_right SetTheory.PGame.Domineering.mem_right /-- After Left moves, two vertically adjacent squares are removed from the board. -/ def moveLeft (b : Board) (m : ℤ × ℤ) : Board := (b.erase m).erase (m.1, m.2 - 1) #align pgame.domineering.move_left SetTheory.PGame.Domineering.moveLeft /-- After Left moves, two horizontally adjacent squares are removed from the board. -/ def moveRight (b : Board) (m : ℤ × ℤ) : Board := (b.erase m).erase (m.1 - 1, m.2) #align pgame.domineering.move_right SetTheory.PGame.Domineering.moveRight theorem fst_pred_mem_erase_of_mem_right {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : (m.1 - 1, m.2) ∈ b.erase m := by rw [mem_right] at h apply Finset.mem_erase_of_ne_of_mem _ h.2 exact ne_of_apply_ne Prod.fst (pred_ne_self m.1) #align pgame.domineering.fst_pred_mem_erase_of_mem_right SetTheory.PGame.Domineering.fst_pred_mem_erase_of_mem_right theorem snd_pred_mem_erase_of_mem_left {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : (m.1, m.2 - 1) ∈ b.erase m := by rw [mem_left] at h apply Finset.mem_erase_of_ne_of_mem _ h.2 exact ne_of_apply_ne Prod.snd (pred_ne_self m.2) #align pgame.domineering.snd_pred_mem_erase_of_mem_left SetTheory.PGame.Domineering.snd_pred_mem_erase_of_mem_left theorem card_of_mem_left {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : 2 ≤ Finset.card b := by have w₁ : m ∈ b := (Finset.mem_inter.1 h).1 have w₂ : (m.1, m.2 - 1) ∈ b.erase m := snd_pred_mem_erase_of_mem_left h have i₁ := Finset.card_erase_lt_of_mem w₁ have i₂ := Nat.lt_of_le_of_lt (Nat.zero_le _) (Finset.card_erase_lt_of_mem w₂) exact Nat.lt_of_le_of_lt i₂ i₁ #align pgame.domineering.card_of_mem_left SetTheory.PGame.Domineering.card_of_mem_left
Mathlib/SetTheory/Game/Domineering.lean
101
106
theorem card_of_mem_right {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : 2 ≤ Finset.card b := by
have w₁ : m ∈ b := (Finset.mem_inter.1 h).1 have w₂ := fst_pred_mem_erase_of_mem_right h have i₁ := Finset.card_erase_lt_of_mem w₁ have i₂ := Nat.lt_of_le_of_lt (Nat.zero_le _) (Finset.card_erase_lt_of_mem w₂) exact Nat.lt_of_le_of_lt i₂ i₁
/- Copyright (c) 2020 David Wärn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Wärn -/ import Mathlib.CategoryTheory.Elements import Mathlib.CategoryTheory.IsConnected import Mathlib.CategoryTheory.SingleObj import Mathlib.GroupTheory.GroupAction.Quotient import Mathlib.GroupTheory.SemidirectProduct #align_import category_theory.action from "leanprover-community/mathlib"@"aa812bd12a4dbbd2c129b38205f222df282df26d" /-! # Actions as functors and as categories From a multiplicative action M ↻ X, we can construct a functor from M to the category of types, mapping the single object of M to X and an element `m : M` to map `X → X` given by multiplication by `m`. This functor induces a category structure on X -- a special case of the category of elements. A morphism `x ⟶ y` in this category is simply a scalar `m : M` such that `m • x = y`. In the case where M is a group, this category is a groupoid -- the *action groupoid*. -/ open MulAction SemidirectProduct namespace CategoryTheory universe u variable (M : Type*) [Monoid M] (X : Type u) [MulAction M X] /-- A multiplicative action M ↻ X viewed as a functor mapping the single object of M to X and an element `m : M` to the map `X → X` given by multiplication by `m`. -/ @[simps] def actionAsFunctor : SingleObj M ⥤ Type u where obj _ := X map := (· • ·) map_id _ := funext <| MulAction.one_smul map_comp f g := funext fun x => (smul_smul g f x).symm #align category_theory.action_as_functor CategoryTheory.actionAsFunctor /-- A multiplicative action M ↻ X induces a category structure on X, where a morphism from x to y is a scalar taking x to y. Due to implementation details, the object type of this category is not equal to X, but is in bijection with X. -/ def ActionCategory := (actionAsFunctor M X).Elements #align category_theory.action_category CategoryTheory.ActionCategory instance : Category (ActionCategory M X) := by dsimp only [ActionCategory] infer_instance namespace ActionCategory /-- The projection from the action category to the monoid, mapping a morphism to its label. -/ def π : ActionCategory M X ⥤ SingleObj M := CategoryOfElements.π _ #align category_theory.action_category.π CategoryTheory.ActionCategory.π @[simp] theorem π_map (p q : ActionCategory M X) (f : p ⟶ q) : (π M X).map f = f.val := rfl #align category_theory.action_category.π_map CategoryTheory.ActionCategory.π_map @[simp] theorem π_obj (p : ActionCategory M X) : (π M X).obj p = SingleObj.star M := Unit.ext _ _ #align category_theory.action_category.π_obj CategoryTheory.ActionCategory.π_obj variable {M X} /-- The canonical map `ActionCategory M X → X`. It is given by `fun x => x.snd`, but has a more explicit type. -/ protected def back : ActionCategory M X → X := fun x => x.snd #align category_theory.action_category.back CategoryTheory.ActionCategory.back instance : CoeTC X (ActionCategory M X) := ⟨fun x => ⟨(), x⟩⟩ @[simp] theorem coe_back (x : X) : ActionCategory.back (x : ActionCategory M X) = x := rfl #align category_theory.action_category.coe_back CategoryTheory.ActionCategory.coe_back @[simp]
Mathlib/CategoryTheory/Action.lean
89
89
theorem back_coe (x : ActionCategory M X) : ↑x.back = x := by
cases x; rfl