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) 2022 Yuyang Zhao. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuyang Zhao -/ import Batteries.Classes.Order namespace Batteries.PairingHeapImp /-- A `Heap` is the nodes of the pairing heap. Each node have two pointers: `child` going to the first child of this node, and `sibling` goes to the next sibling of this tree. So it actually encodes a forest where each node has children `node.child`, `node.child.sibling`, `node.child.sibling.sibling`, etc. Each edge in this forest denotes a `le a b` relation that has been checked, so the root is smaller than everything else under it. -/ inductive Heap (α : Type u) where /-- An empty forest, which has depth `0`. -/ | nil : Heap α /-- A forest consists of a root `a`, a forest `child` elements greater than `a`, and another forest `sibling`. -/ | node (a : α) (child sibling : Heap α) : Heap α deriving Repr /-- `O(n)`. The number of elements in the heap. -/ def Heap.size : Heap α → Nat | .nil => 0 | .node _ c s => c.size + 1 + s.size /-- A node containing a single element `a`. -/ def Heap.singleton (a : α) : Heap α := .node a .nil .nil /-- `O(1)`. Is the heap empty? -/ def Heap.isEmpty : Heap α → Bool | .nil => true | _ => false /-- `O(1)`. Merge two heaps. Ignore siblings. -/ @[specialize] def Heap.merge (le : α → α → Bool) : Heap α → Heap α → Heap α | .nil, .nil => .nil | .nil, .node a₂ c₂ _ => .node a₂ c₂ .nil | .node a₁ c₁ _, .nil => .node a₁ c₁ .nil | .node a₁ c₁ _, .node a₂ c₂ _ => if le a₁ a₂ then .node a₁ (.node a₂ c₂ c₁) .nil else .node a₂ (.node a₁ c₁ c₂) .nil /-- Auxiliary for `Heap.deleteMin`: merge the forest in pairs. -/ @[specialize] def Heap.combine (le : α → α → Bool) : Heap α → Heap α | h₁@(.node _ _ h₂@(.node _ _ s)) => merge le (merge le h₁ h₂) (s.combine le) | h => h /-- `O(1)`. Get the smallest element in the heap, including the passed in value `a`. -/ @[inline] def Heap.headD (a : α) : Heap α → α | .nil => a | .node a _ _ => a /-- `O(1)`. Get the smallest element in the heap, if it has an element. -/ @[inline] def Heap.head? : Heap α → Option α | .nil => none | .node a _ _ => some a /-- Amortized `O(log n)`. Find and remove the the minimum element from the heap. -/ @[inline] def Heap.deleteMin (le : α → α → Bool) : Heap α → Option (α × Heap α) | .nil => none | .node a c _ => (a, combine le c) /-- Amortized `O(log n)`. Get the tail of the pairing heap after removing the minimum element. -/ @[inline] def Heap.tail? (le : α → α → Bool) (h : Heap α) : Option (Heap α) := deleteMin le h |>.map (·.snd) /-- Amortized `O(log n)`. Remove the minimum element of the heap. -/ @[inline] def Heap.tail (le : α → α → Bool) (h : Heap α) : Heap α := tail? le h |>.getD .nil /-- A predicate says there is no more than one tree. -/ inductive Heap.NoSibling : Heap α → Prop /-- An empty heap is no more than one tree. -/ | nil : NoSibling .nil /-- Or there is exactly one tree. -/ | node (a c) : NoSibling (.node a c .nil) instance : Decidable (Heap.NoSibling s) := match s with | .nil => isTrue .nil | .node a c .nil => isTrue (.node a c) | .node _ _ (.node _ _ _) => isFalse nofun theorem Heap.noSibling_merge (le) (s₁ s₂ : Heap α) : (s₁.merge le s₂).NoSibling := by unfold merge (split <;> try split) <;> constructor theorem Heap.noSibling_combine (le) (s : Heap α) : (s.combine le).NoSibling := by unfold combine; split · exact noSibling_merge _ _ _ · match s with | nil | node _ _ nil => constructor | node _ _ (node _ _ s) => rename_i h; exact (h _ _ _ _ _ rfl).elim theorem Heap.noSibling_deleteMin {s : Heap α} (eq : s.deleteMin le = some (a, s')) : s'.NoSibling := by cases s with cases eq | node a c => exact noSibling_combine _ _ theorem Heap.noSibling_tail? {s : Heap α} : s.tail? le = some s' → s'.NoSibling := by simp only [Heap.tail?]; intro eq match eq₂ : s.deleteMin le, eq with | some (a, tl), rfl => exact noSibling_deleteMin eq₂ theorem Heap.noSibling_tail (le) (s : Heap α) : (s.tail le).NoSibling := by simp only [Heap.tail] match eq : s.tail? le with | none => cases s with cases eq | nil => constructor | some tl => exact Heap.noSibling_tail? eq theorem Heap.size_merge_node (le) (a₁ : α) (c₁ s₁ : Heap α) (a₂ : α) (c₂ s₂ : Heap α) : (merge le (.node a₁ c₁ s₁) (.node a₂ c₂ s₂)).size = c₁.size + c₂.size + 2 := by unfold merge; dsimp; split <;> simp_arith [size]
.lake/packages/batteries/Batteries/Data/PairingHeap.lean
123
127
theorem Heap.size_merge (le) {s₁ s₂ : Heap α} (h₁ : s₁.NoSibling) (h₂ : s₂.NoSibling) : (merge le s₁ s₂).size = s₁.size + s₂.size := by
match h₁, h₂ with | .nil, .nil | .nil, .node _ _ | .node _ _, .nil => simp [size] | .node _ _, .node _ _ => unfold merge; dsimp; split <;> simp_arith [size]
/- Copyright (c) 2020 Heather Macbeth, Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth, Patrick Massot -/ import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Algebra.Order.Archimedean import Mathlib.Data.Set.Lattice #align_import group_theory.archimedean from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6" /-! # Archimedean groups This file proves a few facts about ordered groups which satisfy the `Archimedean` property, that is: `class Archimedean (α) [OrderedAddCommMonoid α] : Prop :=` `(arch : ∀ (x : α) {y}, 0 < y → ∃ n : ℕ, x ≤ n • y)` They are placed here in a separate file (rather than incorporated as a continuation of `Algebra.Order.Archimedean`) because they rely on some imports from `GroupTheory` -- bundled subgroups in particular. The main result is `AddSubgroup.cyclic_of_min`: a subgroup of a decidable archimedean abelian group is cyclic, if its set of positive elements has a minimal element. This result is used in this file to deduce `Int.subgroup_cyclic`, proving that every subgroup of `ℤ` is cyclic. (There are several other methods one could use to prove this fact, including more purely algebraic methods, but none seem to exist in mathlib as of writing. The closest is `Subgroup.is_cyclic`, but that has not been transferred to `AddSubgroup`.) The result is also used in `Topology.Instances.Real` as an ingredient in the classification of subgroups of `ℝ`. -/ open Set variable {G : Type*} [LinearOrderedAddCommGroup G] [Archimedean G] /-- Given a subgroup `H` of a decidable linearly ordered archimedean abelian group `G`, if there exists a minimal element `a` of `H ∩ G_{>0}` then `H` is generated by `a`. -/ theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G} (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha refine le_antisymm ?_ (H.closure_le.mpr <| by simp [a_in]) intro g g_in obtain ⟨k, ⟨nonneg, lt⟩, _⟩ := existsUnique_zsmul_near_of_pos' a_pos g have h_zero : g - k • a = 0 := by by_contra h have h : a ≤ g - k • a := by refine a_min ⟨?_, ?_⟩ · exact AddSubgroup.sub_mem H g_in (AddSubgroup.zsmul_mem H a_in k) · exact lt_of_le_of_ne nonneg (Ne.symm h) have h' : ¬a ≤ g - k • a := not_le.mpr lt contradiction simp [sub_eq_zero.mp h_zero, AddSubgroup.mem_closure_singleton] #align add_subgroup.cyclic_of_min AddSubgroup.cyclic_of_min /-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this group admits the least element. -/
Mathlib/GroupTheory/Archimedean.lean
60
87
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a) (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
-- todo: move to a lemma? have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩ simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm' lift m to ℕ · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul] exact hg.trans_le hm · simp only [← Nat.cast_succ, natCast_zsmul] at hm hm' exact ⟨m, hm', hm⟩ have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩ rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩ exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩ classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩ by_contra hxmin simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall, not_le] at hxmin rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩ rcases hex y hy₀ with ⟨m, hm⟩ cases' lt_or_le m n with hmn hnm · exact hmin m hmn ⟨y, hyH, hm⟩ · refine disjoint_left.1 hd (sub_mem hxH hyH) ⟨sub_pos.2 hxy, sub_lt_iff_lt_add'.2 ?_⟩ calc x ≤ (n + 1) • a := hxn _ ≤ (m + 1) • a := nsmul_le_nsmul_left h₀.le (add_le_add_right hnm _) _ = m • a + a := succ_nsmul _ _ _ < y + a := add_lt_add_right hm.1 _
/- Copyright (c) 2021 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Init.Data.Nat.Notation import Mathlib.Init.Order.Defs set_option autoImplicit true structure UFModel (n) where parent : Fin n → Fin n rank : Nat → Nat rank_lt : ∀ i, (parent i).1 ≠ i → rank i < rank (parent i) namespace UFModel def empty : UFModel 0 where parent i := i.elim0 rank _ := 0 rank_lt i := i.elim0 def push {n} (m : UFModel n) (k) (le : n ≤ k) : UFModel k where parent i := if h : i < n then let ⟨a, h'⟩ := m.parent ⟨i, h⟩ ⟨a, Nat.lt_of_lt_of_le h' le⟩ else i rank i := if i < n then m.rank i else 0 rank_lt i := by simp; split <;> rename_i h · simp [(m.parent ⟨i, h⟩).2, h]; exact m.rank_lt _ · nofun def setParent {n} (m : UFModel n) (x y : Fin n) (h : m.rank x < m.rank y) : UFModel n where parent i := if x.1 = i then y else m.parent i rank := m.rank rank_lt i := by simp; split <;> rename_i h' · rw [← h']; exact fun _ ↦ h · exact m.rank_lt i def setParentBump {n} (m : UFModel n) (x y : Fin n) (H : m.rank x ≤ m.rank y) (hroot : (m.parent y).1 = y) : UFModel n where parent i := if x.1 = i then y else m.parent i rank i := if y.1 = i ∧ m.rank x = m.rank y then m.rank y + 1 else m.rank i rank_lt i := by simp; split <;> (rename_i h₁; (try simp [h₁]); split <;> rename_i h₂ <;> (intro h; try simp [h] at h₂ <;> simp [h₁, h₂, h])) · simp [← h₁]; split <;> rename_i h₃ · rw [h₃]; apply Nat.lt_succ_self · exact Nat.lt_of_le_of_ne H h₃ · have := Fin.eq_of_val_eq h₂.1; subst this simp [hroot] at h · have := m.rank_lt i h split <;> rename_i h₃ · rw [h₃.1]; exact Nat.lt_succ_of_lt this · exact this end UFModel structure UFNode (α : Type*) where parent : Nat value : α rank : Nat inductive UFModel.Agrees (arr : Array α) (f : α → β) : ∀ {n}, (Fin n → β) → Prop | mk : Agrees arr f fun i ↦ f (arr.get i) namespace UFModel.Agrees theorem mk' {arr : Array α} {f : α → β} {n} {g : Fin n → β} (e : n = arr.size) (H : ∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = g ⟨i, h₂⟩) : Agrees arr f g := by cases e have : (fun i ↦ f (arr.get i)) = g := by funext ⟨i, h⟩; apply H cases this; constructor theorem size_eq {arr : Array α} {m : Fin n → β} (H : Agrees arr f m) : n = arr.size := by cases H; rfl theorem get_eq {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m) : ∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = m ⟨i, h₂⟩ := by cases H; exact fun i h _ ↦ rfl theorem get_eq' {arr : Array α} {m : Fin arr.size → β} (H : Agrees arr f m) (i) : f (arr.get i) = m i := H.get_eq .. theorem empty {f : α → β} {g : Fin 0 → β} : Agrees #[] f g := mk' rfl nofun theorem push {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m) (k) (hk : k = n + 1) (x) (m' : Fin k → β) (hm₁ : ∀ (i : Fin k) (h : i < n), m' i = m ⟨i, h⟩) (hm₂ : ∀ (h : n < k), f x = m' ⟨n, h⟩) : Agrees (arr.push x) f m' := by cases H have : k = (arr.push x).size := by simp [hk] refine mk' this fun i h₁ h₂ ↦ ?_ simp [Array.get_push]; split <;> (rename_i h; simp at hm₁ ⊢) · rw [← hm₁ ⟨i, h₂⟩]; assumption · cases show i = arr.size by apply Nat.le_antisymm <;> simp_all [Nat.lt_succ] rw [hm₂]
Mathlib/Data/UnionFind.lean
103
112
theorem set {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m) {i : Fin arr.size} {x} {m' : Fin n → β} (hm₁ : ∀ (j : Fin n), j.1 ≠ i → m' j = m j) (hm₂ : ∀ (h : i < n), f x = m' ⟨i, h⟩) : Agrees (arr.set i x) f m' := by
cases H refine mk' (by simp) fun j hj₁ hj₂ ↦ ?_ suffices f (Array.set arr i x)[j] = m' ⟨j, hj₂⟩ by simp_all [Array.get_set] by_cases h : i = j · subst h; rw [Array.get_set_eq, ← hm₂] · rw [arr.get_set_ne _ _ _ h, hm₁ ⟨j, _⟩ (Ne.symm h)]; rfl
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Jeremy Avigad, Simon Hudon -/ import Mathlib.Data.Part import Mathlib.Data.Rel #align_import data.pfun from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432" /-! # Partial functions This file defines partial functions. Partial functions are like functions, except they can also be "undefined" on some inputs. We define them as functions `α → Part β`. ## Definitions * `PFun α β`: Type of partial functions from `α` to `β`. Defined as `α → Part β` and denoted `α →. β`. * `PFun.Dom`: Domain of a partial function. Set of values on which it is defined. Not to be confused with the domain of a function `α → β`, which is a type (`α` presently). * `PFun.fn`: Evaluation of a partial function. Takes in an element and a proof it belongs to the partial function's `Dom`. * `PFun.asSubtype`: Returns a partial function as a function from its `Dom`. * `PFun.toSubtype`: Restricts the codomain of a function to a subtype. * `PFun.evalOpt`: Returns a partial function with a decidable `Dom` as a function `a → Option β`. * `PFun.lift`: Turns a function into a partial function. * `PFun.id`: The identity as a partial function. * `PFun.comp`: Composition of partial functions. * `PFun.restrict`: Restriction of a partial function to a smaller `Dom`. * `PFun.res`: Turns a function into a partial function with a prescribed domain. * `PFun.fix` : First return map of a partial function `f : α →. β ⊕ α`. * `PFun.fix_induction`: A recursion principle for `PFun.fix`. ### Partial functions as relations Partial functions can be considered as relations, so we specialize some `Rel` definitions to `PFun`: * `PFun.image`: Image of a set under a partial function. * `PFun.ran`: Range of a partial function. * `PFun.preimage`: Preimage of a set under a partial function. * `PFun.core`: Core of a set under a partial function. * `PFun.graph`: Graph of a partial function `a →. β`as a `Set (α × β)`. * `PFun.graph'`: Graph of a partial function `a →. β`as a `Rel α β`. ### `PFun α` as a monad Monad operations: * `PFun.pure`: The monad `pure` function, the constant `x` function. * `PFun.bind`: The monad `bind` function, pointwise `Part.bind` * `PFun.map`: The monad `map` function, pointwise `Part.map`. -/ open Function /-- `PFun α β`, or `α →. β`, is the type of partial functions from `α` to `β`. It is defined as `α → Part β`. -/ def PFun (α β : Type*) := α → Part β #align pfun PFun /-- `α →. β` is notation for the type `PFun α β` of partial functions from `α` to `β`. -/ infixr:25 " →. " => PFun namespace PFun variable {α β γ δ ε ι : Type*} instance inhabited : Inhabited (α →. β) := ⟨fun _ => Part.none⟩ #align pfun.inhabited PFun.inhabited /-- The domain of a partial function -/ def Dom (f : α →. β) : Set α := { a | (f a).Dom } #align pfun.dom PFun.Dom @[simp]
Mathlib/Data/PFun.lean
80
80
theorem mem_dom (f : α →. β) (x : α) : x ∈ Dom f ↔ ∃ y, y ∈ f x := by
simp [Dom, Part.dom_iff_mem]
/- 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.Data.DFinsupp.Interval import Mathlib.Data.DFinsupp.Multiset import Mathlib.Order.Interval.Finset.Nat #align_import data.multiset.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" /-! # Finite intervals of multisets This file provides the `LocallyFiniteOrder` instance for `Multiset α` and calculates the cardinality of its finite intervals. ## Implementation notes We implement the intervals via the intervals on `DFinsupp`, rather than via filtering `Multiset.Powerset`; this is because `(Multiset.replicate n x).Powerset` has `2^n` entries not `n+1` entries as it contains duplicates. We do not go via `Finsupp` as this would be noncomputable, and multisets are typically used computationally. -/ open Finset DFinsupp Function open Pointwise variable {α : Type*} namespace Multiset variable [DecidableEq α] (s t : Multiset α) instance instLocallyFiniteOrder : LocallyFiniteOrder (Multiset α) := LocallyFiniteOrder.ofIcc (Multiset α) (fun s t => (Finset.Icc (toDFinsupp s) (toDFinsupp t)).map Multiset.equivDFinsupp.toEquiv.symm.toEmbedding) fun s t x => by simp theorem Icc_eq : Finset.Icc s t = (Finset.Icc (toDFinsupp s) (toDFinsupp t)).map Multiset.equivDFinsupp.toEquiv.symm.toEmbedding := rfl #align multiset.Icc_eq Multiset.Icc_eq theorem uIcc_eq : uIcc s t = (uIcc (toDFinsupp s) (toDFinsupp t)).map Multiset.equivDFinsupp.toEquiv.symm.toEmbedding := (Icc_eq _ _).trans <| by simp [uIcc] #align multiset.uIcc_eq Multiset.uIcc_eq theorem card_Icc : (Finset.Icc s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) := by simp_rw [Icc_eq, Finset.card_map, DFinsupp.card_Icc, Nat.card_Icc, Multiset.toDFinsupp_apply, toDFinsupp_support] #align multiset.card_Icc Multiset.card_Icc theorem card_Ico : (Finset.Ico s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) - 1 := by rw [Finset.card_Ico_eq_card_Icc_sub_one, card_Icc] #align multiset.card_Ico Multiset.card_Ico theorem card_Ioc : (Finset.Ioc s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) - 1 := by rw [Finset.card_Ioc_eq_card_Icc_sub_one, card_Icc] #align multiset.card_Ioc Multiset.card_Ioc
Mathlib/Data/Multiset/Interval.lean
72
74
theorem card_Ioo : (Finset.Ioo s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) - 2 := by
rw [Finset.card_Ioo_eq_card_Icc_sub_two, card_Icc]
/- 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. -/ 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⟩ /-- 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`. -/
Mathlib/GroupTheory/Perm/ClosureSwap.lean
74
88
theorem swap_mem_closure_isSwap {S : Set (Perm α)} (hS : ∀ f ∈ S, f.IsSwap) {x y : α} : swap x y ∈ closure S ↔ x ∈ orbit (closure S) y := by
refine ⟨fun h ↦ ⟨⟨swap x y, h⟩, swap_apply_right x y⟩, fun hf ↦ ?_⟩ by_contra h have := exists_smul_not_mem_of_subset_orbit_closure S {x | swap x y ∈ closure S} (fun f hf ↦ ?_) (fun z hz ↦ ?_) h ⟨y, ?_⟩ · obtain ⟨σ, hσ, a, ha, hσa⟩ := this obtain ⟨z, w, hzw, rfl⟩ := hS σ hσ have := ne_of_mem_of_not_mem ha hσa rw [Perm.smul_def, ne_comm, swap_apply_ne_self_iff, and_iff_right hzw] at this refine hσa (SubmonoidClass.swap_mem_trans (closure S) ?_ ha) obtain rfl | rfl := this <;> simpa [swap_comm] using subset_closure hσ · obtain ⟨x, y, -, rfl⟩ := hS f hf; rwa [swap_inv] · exact orbit_eq_iff.mpr hf ▸ ⟨⟨swap z y, hz⟩, swap_apply_right z y⟩ · rw [mem_setOf, swap_self]; apply one_mem
/- 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.Init.Data.Sigma.Lex import Mathlib.Data.Prod.Lex import Mathlib.Data.Sigma.Lex import Mathlib.Order.Antichain import Mathlib.Order.OrderIsoNat import Mathlib.Order.WellFounded import Mathlib.Tactic.TFAE #align_import order.well_founded_set from "leanprover-community/mathlib"@"2c84c2c5496117349007d97104e7bbb471381592" /-! # Well-founded sets A well-founded subset of an ordered type is one on which the relation `<` is well-founded. ## Main Definitions * `Set.WellFoundedOn s r` indicates that the relation `r` is well-founded when restricted to the set `s`. * `Set.IsWF s` indicates that `<` is well-founded when restricted to `s`. * `Set.PartiallyWellOrderedOn s r` indicates that the relation `r` is partially well-ordered (also known as well quasi-ordered) when restricted to the set `s`. * `Set.IsPWO s` indicates that any infinite sequence of elements in `s` contains an infinite monotone subsequence. Note that this is equivalent to containing only two comparable elements. ## Main Results * Higman's Lemma, `Set.PartiallyWellOrderedOn.partiallyWellOrderedOn_sublistForall₂`, shows that if `r` is partially well-ordered on `s`, then `List.SublistForall₂` is partially well-ordered on the set of lists of elements of `s`. The result was originally published by Higman, but this proof more closely follows Nash-Williams. * `Set.wellFoundedOn_iff` relates `well_founded_on` to the well-foundedness of a relation on the original type, to avoid dealing with subtypes. * `Set.IsWF.mono` shows that a subset of a well-founded subset is well-founded. * `Set.IsWF.union` shows that the union of two well-founded subsets is well-founded. * `Finset.isWF` shows that all `Finset`s are well-founded. ## TODO Prove that `s` is partial well ordered iff it has no infinite descending chain or antichain. ## References * [Higman, *Ordering by Divisibility in Abstract Algebras*][Higman52] * [Nash-Williams, *On Well-Quasi-Ordering Finite Trees*][Nash-Williams63] -/ variable {ι α β γ : Type*} {π : ι → Type*} namespace Set /-! ### Relations well-founded on sets -/ /-- `s.WellFoundedOn r` indicates that the relation `r` is well-founded when restricted to `s`. -/ def WellFoundedOn (s : Set α) (r : α → α → Prop) : Prop := WellFounded fun a b : s => r a b #align set.well_founded_on Set.WellFoundedOn @[simp] theorem wellFoundedOn_empty (r : α → α → Prop) : WellFoundedOn ∅ r := wellFounded_of_isEmpty _ #align set.well_founded_on_empty Set.wellFoundedOn_empty section WellFoundedOn variable {r r' : α → α → Prop} section AnyRel variable {f : β → α} {s t : Set α} {x y : α} theorem wellFoundedOn_iff : s.WellFoundedOn r ↔ WellFounded fun a b : α => r a b ∧ a ∈ s ∧ b ∈ s := by have f : RelEmbedding (fun (a : s) (b : s) => r a b) fun a b : α => r a b ∧ a ∈ s ∧ b ∈ s := ⟨⟨(↑), Subtype.coe_injective⟩, by simp⟩ refine ⟨fun h => ?_, f.wellFounded⟩ rw [WellFounded.wellFounded_iff_has_min] intro t ht by_cases hst : (s ∩ t).Nonempty · rw [← Subtype.preimage_coe_nonempty] at hst rcases h.has_min (Subtype.val ⁻¹' t) hst with ⟨⟨m, ms⟩, mt, hm⟩ exact ⟨m, mt, fun x xt ⟨xm, xs, _⟩ => hm ⟨x, xs⟩ xt xm⟩ · rcases ht with ⟨m, mt⟩ exact ⟨m, mt, fun x _ ⟨_, _, ms⟩ => hst ⟨m, ⟨ms, mt⟩⟩⟩ #align set.well_founded_on_iff Set.wellFoundedOn_iff @[simp]
Mathlib/Order/WellFoundedSet.lean
92
93
theorem wellFoundedOn_univ : (univ : Set α).WellFoundedOn r ↔ WellFounded r := by
simp [wellFoundedOn_iff]
/- Copyright (c) 2022 Matej Penciak. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Matej Penciak, Moritz Doll, Fabien Clery -/ import Mathlib.LinearAlgebra.Matrix.NonsingularInverse #align_import linear_algebra.symplectic_group from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # The Symplectic Group This file defines the symplectic group and proves elementary properties. ## Main Definitions * `Matrix.J`: the canonical `2n × 2n` skew-symmetric matrix * `symplecticGroup`: the group of symplectic matrices ## TODO * Every symplectic matrix has determinant 1. * For `n = 1` the symplectic group coincides with the special linear group. -/ open Matrix variable {l R : Type*} namespace Matrix variable (l) [DecidableEq l] (R) [CommRing R] section JMatrixLemmas /-- The matrix defining the canonical skew-symmetric bilinear form. -/ def J : Matrix (Sum l l) (Sum l l) R := Matrix.fromBlocks 0 (-1) 1 0 set_option linter.uppercaseLean3 false in #align matrix.J Matrix.J @[simp] theorem J_transpose : (J l R)ᵀ = -J l R := by rw [J, fromBlocks_transpose, ← neg_one_smul R (fromBlocks _ _ _ _ : Matrix (l ⊕ l) (l ⊕ l) R), fromBlocks_smul, Matrix.transpose_zero, Matrix.transpose_one, transpose_neg] simp [fromBlocks] set_option linter.uppercaseLean3 false in #align matrix.J_transpose Matrix.J_transpose variable [Fintype l] theorem J_squared : J l R * J l R = -1 := by rw [J, fromBlocks_multiply] simp only [Matrix.zero_mul, Matrix.neg_mul, zero_add, neg_zero, Matrix.one_mul, add_zero] rw [← neg_zero, ← Matrix.fromBlocks_neg, ← fromBlocks_one] set_option linter.uppercaseLean3 false in #align matrix.J_squared Matrix.J_squared theorem J_inv : (J l R)⁻¹ = -J l R := by refine Matrix.inv_eq_right_inv ?_ rw [Matrix.mul_neg, J_squared] exact neg_neg 1 set_option linter.uppercaseLean3 false in #align matrix.J_inv Matrix.J_inv theorem J_det_mul_J_det : det (J l R) * det (J l R) = 1 := by rw [← det_mul, J_squared, ← one_smul R (-1 : Matrix _ _ R), smul_neg, ← neg_smul, det_smul, Fintype.card_sum, det_one, mul_one] apply Even.neg_one_pow exact even_add_self _ set_option linter.uppercaseLean3 false in #align matrix.J_det_mul_J_det Matrix.J_det_mul_J_det theorem isUnit_det_J : IsUnit (det (J l R)) := isUnit_iff_exists_inv.mpr ⟨det (J l R), J_det_mul_J_det _ _⟩ set_option linter.uppercaseLean3 false in #align matrix.is_unit_det_J Matrix.isUnit_det_J end JMatrixLemmas variable [Fintype l] /-- The group of symplectic matrices over a ring `R`. -/ def symplecticGroup : Submonoid (Matrix (Sum l l) (Sum l l) R) where carrier := { A | A * J l R * Aᵀ = J l R } mul_mem' {a b} ha hb := by simp only [Set.mem_setOf_eq, transpose_mul] at * rw [← Matrix.mul_assoc, a.mul_assoc, a.mul_assoc, hb] exact ha one_mem' := by simp #align matrix.symplectic_group Matrix.symplecticGroup end Matrix namespace SymplecticGroup variable [DecidableEq l] [Fintype l] [CommRing R] open Matrix theorem mem_iff {A : Matrix (Sum l l) (Sum l l) R} : A ∈ symplecticGroup l R ↔ A * J l R * Aᵀ = J l R := by simp [symplecticGroup] #align symplectic_group.mem_iff SymplecticGroup.mem_iff -- Porting note: Previous proof was `by infer_instance` instance coeMatrix : Coe (symplecticGroup l R) (Matrix (Sum l l) (Sum l l) R) := ⟨Subtype.val⟩ #align symplectic_group.coe_matrix SymplecticGroup.coeMatrix section SymplecticJ variable (l) (R) theorem J_mem : J l R ∈ symplecticGroup l R := by rw [mem_iff, J, fromBlocks_multiply, fromBlocks_transpose, fromBlocks_multiply] simp set_option linter.uppercaseLean3 false in #align symplectic_group.J_mem SymplecticGroup.J_mem /-- The canonical skew-symmetric matrix as an element in the symplectic group. -/ def symJ : symplecticGroup l R := ⟨J l R, J_mem l R⟩ set_option linter.uppercaseLean3 false in #align symplectic_group.sym_J SymplecticGroup.symJ variable {l} {R} @[simp] theorem coe_J : ↑(symJ l R) = J l R := rfl set_option linter.uppercaseLean3 false in #align symplectic_group.coe_J SymplecticGroup.coe_J end SymplecticJ variable {A : Matrix (Sum l l) (Sum l l) R}
Mathlib/LinearAlgebra/SymplecticGroup.lean
137
139
theorem neg_mem (h : A ∈ symplecticGroup l R) : -A ∈ symplecticGroup l R := by
rw [mem_iff] at h ⊢ simp [h]
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Algebra.Order.Group.Instances import Mathlib.Algebra.Order.Group.OrderIso import Mathlib.Data.Set.Pointwise.SMul import Mathlib.Order.UpperLower.Basic #align_import algebra.order.upper_lower from "leanprover-community/mathlib"@"c0c52abb75074ed8b73a948341f50521fbf43b4c" /-! # Algebraic operations on upper/lower sets Upper/lower sets are preserved under pointwise algebraic operations in ordered groups. -/ open Function Set open Pointwise section OrderedCommMonoid variable {α : Type*} [OrderedCommMonoid α] {s : Set α} {x : α} @[to_additive] theorem IsUpperSet.smul_subset (hs : IsUpperSet s) (hx : 1 ≤ x) : x • s ⊆ s := smul_set_subset_iff.2 fun _ ↦ hs <| le_mul_of_one_le_left' hx #align is_upper_set.smul_subset IsUpperSet.smul_subset #align is_upper_set.vadd_subset IsUpperSet.vadd_subset @[to_additive] theorem IsLowerSet.smul_subset (hs : IsLowerSet s) (hx : x ≤ 1) : x • s ⊆ s := smul_set_subset_iff.2 fun _ ↦ hs <| mul_le_of_le_one_left' hx #align is_lower_set.smul_subset IsLowerSet.smul_subset #align is_lower_set.vadd_subset IsLowerSet.vadd_subset end OrderedCommMonoid section OrderedCommGroup variable {α : Type*} [OrderedCommGroup α] {s t : Set α} {a : α} @[to_additive] theorem IsUpperSet.smul (hs : IsUpperSet s) : IsUpperSet (a • s) := hs.image <| OrderIso.mulLeft _ #align is_upper_set.smul IsUpperSet.smul #align is_upper_set.vadd IsUpperSet.vadd @[to_additive] theorem IsLowerSet.smul (hs : IsLowerSet s) : IsLowerSet (a • s) := hs.image <| OrderIso.mulLeft _ #align is_lower_set.smul IsLowerSet.smul #align is_lower_set.vadd IsLowerSet.vadd @[to_additive] theorem Set.OrdConnected.smul (hs : s.OrdConnected) : (a • s).OrdConnected := by rw [← hs.upperClosure_inter_lowerClosure, smul_set_inter] exact (upperClosure _).upper.smul.ordConnected.inter (lowerClosure _).lower.smul.ordConnected #align set.ord_connected.smul Set.OrdConnected.smul #align set.ord_connected.vadd Set.OrdConnected.vadd @[to_additive] theorem IsUpperSet.mul_left (ht : IsUpperSet t) : IsUpperSet (s * t) := by rw [← smul_eq_mul, ← Set.iUnion_smul_set] exact isUpperSet_iUnion₂ fun x _ ↦ ht.smul #align is_upper_set.mul_left IsUpperSet.mul_left #align is_upper_set.add_left IsUpperSet.add_left @[to_additive]
Mathlib/Algebra/Order/UpperLower.lean
70
72
theorem IsUpperSet.mul_right (hs : IsUpperSet s) : IsUpperSet (s * t) := by
rw [mul_comm] exact hs.mul_left
/- Copyright (c) 2022 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Analysis.NormedSpace.Star.Basic import Mathlib.Analysis.NormedSpace.Spectrum import Mathlib.Analysis.SpecialFunctions.Exponential import Mathlib.Algebra.Star.StarAlgHom #align_import analysis.normed_space.star.spectrum from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Spectral properties in C⋆-algebras In this file, we establish various properties related to the spectrum of elements in C⋆-algebras. -/ local postfix:max "⋆" => star section open scoped Topology ENNReal open Filter ENNReal spectrum CstarRing NormedSpace section UnitarySpectrum variable {𝕜 : Type*} [NormedField 𝕜] {E : Type*} [NormedRing E] [StarRing E] [CstarRing E] [NormedAlgebra 𝕜 E] [CompleteSpace E] theorem unitary.spectrum_subset_circle (u : unitary E) : spectrum 𝕜 (u : E) ⊆ Metric.sphere 0 1 := by nontriviality E refine fun k hk => mem_sphere_zero_iff_norm.mpr (le_antisymm ?_ ?_) · simpa only [CstarRing.norm_coe_unitary u] using norm_le_norm_of_mem hk · rw [← unitary.val_toUnits_apply u] at hk have hnk := ne_zero_of_mem_of_unit hk rw [← inv_inv (unitary.toUnits u), ← spectrum.map_inv, Set.mem_inv] at hk have : ‖k‖⁻¹ ≤ ‖(↑(unitary.toUnits u)⁻¹ : E)‖ := by simpa only [norm_inv] using norm_le_norm_of_mem hk simpa using inv_le_of_inv_le (norm_pos_iff.mpr hnk) this #align unitary.spectrum_subset_circle unitary.spectrum_subset_circle theorem spectrum.subset_circle_of_unitary {u : E} (h : u ∈ unitary E) : spectrum 𝕜 u ⊆ Metric.sphere 0 1 := unitary.spectrum_subset_circle ⟨u, h⟩ #align spectrum.subset_circle_of_unitary spectrum.subset_circle_of_unitary end UnitarySpectrum section ComplexScalars open Complex variable {A : Type*} [NormedRing A] [NormedAlgebra ℂ A] [CompleteSpace A] [StarRing A] [CstarRing A] local notation "↑ₐ" => algebraMap ℂ A theorem IsSelfAdjoint.spectralRadius_eq_nnnorm {a : A} (ha : IsSelfAdjoint a) : spectralRadius ℂ a = ‖a‖₊ := by have hconst : Tendsto (fun _n : ℕ => (‖a‖₊ : ℝ≥0∞)) atTop _ := tendsto_const_nhds refine tendsto_nhds_unique ?_ hconst convert (spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a : A)).comp (Nat.tendsto_pow_atTop_atTop_of_one_lt one_lt_two) using 1 refine funext fun n => ?_ rw [Function.comp_apply, ha.nnnorm_pow_two_pow, ENNReal.coe_pow, ← rpow_natCast, ← rpow_mul] simp #align is_self_adjoint.spectral_radius_eq_nnnorm IsSelfAdjoint.spectralRadius_eq_nnnorm
Mathlib/Analysis/NormedSpace/Star/Spectrum.lean
72
86
theorem IsStarNormal.spectralRadius_eq_nnnorm (a : A) [IsStarNormal a] : spectralRadius ℂ a = ‖a‖₊ := by
refine (ENNReal.pow_strictMono two_ne_zero).injective ?_ have heq : (fun n : ℕ => (‖(a⋆ * a) ^ n‖₊ : ℝ≥0∞) ^ (1 / n : ℝ)) = (fun x => x ^ 2) ∘ fun n : ℕ => (‖a ^ n‖₊ : ℝ≥0∞) ^ (1 / n : ℝ) := by funext n rw [Function.comp_apply, ← rpow_natCast, ← rpow_mul, mul_comm, rpow_mul, rpow_natCast, ← coe_pow, sq, ← nnnorm_star_mul_self, Commute.mul_pow (star_comm_self' a), star_pow] have h₂ := ((ENNReal.continuous_pow 2).tendsto (spectralRadius ℂ a)).comp (spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius a) rw [← heq] at h₂ convert tendsto_nhds_unique h₂ (pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a⋆ * a)) rw [(IsSelfAdjoint.star_mul_self a).spectralRadius_eq_nnnorm, sq, nnnorm_star_mul_self, coe_mul]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker -/ import Mathlib.Algebra.Polynomial.Basic #align_import data.polynomial.monomial from "leanprover-community/mathlib"@"220f71ba506c8958c9b41bd82226b3d06b0991e8" /-! # Univariate monomials Preparatory lemmas for degree_basic. -/ noncomputable section namespace Polynomial open Polynomial universe u variable {R : Type u} {a b : R} {m n : ℕ} variable [Semiring R] {p q r : R[X]}
Mathlib/Algebra/Polynomial/Monomial.lean
28
32
theorem monomial_one_eq_iff [Nontrivial R] {i j : ℕ} : (monomial i 1 : R[X]) = monomial j 1 ↔ i = j := by
-- Porting note: `ofFinsupp.injEq` is required. simp_rw [← ofFinsupp_single, ofFinsupp.injEq] exact AddMonoidAlgebra.of_injective.eq_iff
/- Copyright (c) 2014 Robert Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Lewis, Leonardo de Moura, Mario Carneiro, Floris van Doorn -/ import Mathlib.Algebra.Field.Basic import Mathlib.Algebra.GroupWithZero.Units.Equiv import Mathlib.Algebra.Order.Field.Defs import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Order.Bounds.OrderIso import Mathlib.Tactic.Positivity.Core #align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd" /-! # Lemmas about linear ordered (semi)fields -/ open Function OrderDual variable {ι α β : Type*} section LinearOrderedSemifield variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ} /-- `Equiv.mulLeft₀` as an order_iso. -/ @[simps! (config := { simpRhs := true })] def OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_left ha } #align order_iso.mul_left₀ OrderIso.mulLeft₀ #align order_iso.mul_left₀_symm_apply OrderIso.mulLeft₀_symm_apply #align order_iso.mul_left₀_apply OrderIso.mulLeft₀_apply /-- `Equiv.mulRight₀` as an order_iso. -/ @[simps! (config := { simpRhs := true })] def OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulRight₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_right ha } #align order_iso.mul_right₀ OrderIso.mulRight₀ #align order_iso.mul_right₀_symm_apply OrderIso.mulRight₀_symm_apply #align order_iso.mul_right₀_apply OrderIso.mulRight₀_apply /-! ### Relating one division with another term. -/ theorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b := ⟨fun h => div_mul_cancel₀ b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h => calc a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm _ ≤ b * (1 / c) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le _ = b / c := (div_eq_mul_one_div b c).symm ⟩ #align le_div_iff le_div_iff theorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc] #align le_div_iff' le_div_iff' theorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b := ⟨fun h => calc a = a / b * b := by rw [div_mul_cancel₀ _ (ne_of_lt hb).symm] _ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le , fun h => calc a / b = a * (1 / b) := div_eq_mul_one_div a b _ ≤ c * b * (1 / b) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le _ = c * b / b := (div_eq_mul_one_div (c * b) b).symm _ = c := by refine (div_eq_iff (ne_of_gt hb)).mpr rfl ⟩ #align div_le_iff div_le_iff theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by rw [mul_comm, div_le_iff hb] #align div_le_iff' div_le_iff' lemma div_le_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b ≤ c ↔ a / c ≤ b := by rw [div_le_iff hb, div_le_iff' hc] theorem lt_div_iff (hc : 0 < c) : a < b / c ↔ a * c < b := lt_iff_lt_of_le_iff_le <| div_le_iff hc #align lt_div_iff lt_div_iff theorem lt_div_iff' (hc : 0 < c) : a < b / c ↔ c * a < b := by rw [mul_comm, lt_div_iff hc] #align lt_div_iff' lt_div_iff' theorem div_lt_iff (hc : 0 < c) : b / c < a ↔ b < a * c := lt_iff_lt_of_le_iff_le (le_div_iff hc) #align div_lt_iff div_lt_iff theorem div_lt_iff' (hc : 0 < c) : b / c < a ↔ b < c * a := by rw [mul_comm, div_lt_iff hc] #align div_lt_iff' div_lt_iff' lemma div_lt_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b < c ↔ a / c < b := by rw [div_lt_iff hb, div_lt_iff' hc] theorem inv_mul_le_iff (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_le_iff' h #align inv_mul_le_iff inv_mul_le_iff theorem inv_mul_le_iff' (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ c * b := by rw [inv_mul_le_iff h, mul_comm] #align inv_mul_le_iff' inv_mul_le_iff'
Mathlib/Algebra/Order/Field/Basic.lean
107
107
theorem mul_inv_le_iff (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ b * c := by
rw [mul_comm, inv_mul_le_iff h]
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Analysis.Complex.Circle import Mathlib.Analysis.SpecialFunctions.Complex.Log #align_import analysis.special_functions.complex.circle from "leanprover-community/mathlib"@"f333194f5ecd1482191452c5ea60b37d4d6afa08" /-! # Maps on the unit circle In this file we prove some basic lemmas about `expMapCircle` and the restriction of `Complex.arg` to the unit circle. These two maps define a partial equivalence between `circle` and `ℝ`, see `circle.argPartialEquiv` and `circle.argEquiv`, that sends the whole circle to `(-π, π]`. -/ open Complex Function Set open Real namespace circle theorem injective_arg : Injective fun z : circle => arg z := fun z w h => Subtype.ext <| ext_abs_arg ((abs_coe_circle z).trans (abs_coe_circle w).symm) h #align circle.injective_arg circle.injective_arg @[simp] theorem arg_eq_arg {z w : circle} : arg z = arg w ↔ z = w := injective_arg.eq_iff #align circle.arg_eq_arg circle.arg_eq_arg end circle theorem arg_expMapCircle {x : ℝ} (h₁ : -π < x) (h₂ : x ≤ π) : arg (expMapCircle x) = x := by rw [expMapCircle_apply, exp_mul_I, arg_cos_add_sin_mul_I ⟨h₁, h₂⟩] #align arg_exp_map_circle arg_expMapCircle @[simp] theorem expMapCircle_arg (z : circle) : expMapCircle (arg z) = z := circle.injective_arg <| arg_expMapCircle (neg_pi_lt_arg _) (arg_le_pi _) #align exp_map_circle_arg expMapCircle_arg namespace circle /-- `Complex.arg ∘ (↑)` and `expMapCircle` define a partial equivalence between `circle` and `ℝ` with `source = Set.univ` and `target = Set.Ioc (-π) π`. -/ @[simps (config := .asFn)] noncomputable def argPartialEquiv : PartialEquiv circle ℝ where toFun := arg ∘ (↑) invFun := expMapCircle source := univ target := Ioc (-π) π map_source' _ _ := ⟨neg_pi_lt_arg _, arg_le_pi _⟩ map_target' := mapsTo_univ _ _ left_inv' z _ := expMapCircle_arg z right_inv' _ hx := arg_expMapCircle hx.1 hx.2 #align circle.arg_local_equiv circle.argPartialEquiv /-- `Complex.arg` and `expMapCircle` define an equivalence between `circle` and `(-π, π]`. -/ @[simps (config := .asFn)] noncomputable def argEquiv : circle ≃ Ioc (-π) π where toFun z := ⟨arg z, neg_pi_lt_arg _, arg_le_pi _⟩ invFun := expMapCircle ∘ (↑) left_inv _ := argPartialEquiv.left_inv trivial right_inv x := Subtype.ext <| argPartialEquiv.right_inv x.2 #align circle.arg_equiv circle.argEquiv end circle theorem leftInverse_expMapCircle_arg : LeftInverse expMapCircle (arg ∘ (↑)) := expMapCircle_arg #align left_inverse_exp_map_circle_arg leftInverse_expMapCircle_arg theorem invOn_arg_expMapCircle : InvOn (arg ∘ (↑)) expMapCircle (Ioc (-π) π) univ := circle.argPartialEquiv.symm.invOn #align inv_on_arg_exp_map_circle invOn_arg_expMapCircle theorem surjOn_expMapCircle_neg_pi_pi : SurjOn expMapCircle (Ioc (-π) π) univ := circle.argPartialEquiv.symm.surjOn #align surj_on_exp_map_circle_neg_pi_pi surjOn_expMapCircle_neg_pi_pi
Mathlib/Analysis/SpecialFunctions/Complex/Circle.lean
85
90
theorem expMapCircle_eq_expMapCircle {x y : ℝ} : expMapCircle x = expMapCircle y ↔ ∃ m : ℤ, x = y + m * (2 * π) := by
rw [Subtype.ext_iff, expMapCircle_apply, expMapCircle_apply, exp_eq_exp_iff_exists_int] refine exists_congr fun n => ?_ rw [← mul_assoc, ← add_mul, mul_left_inj' I_ne_zero] norm_cast
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.Constructions.BorelSpace.Order import Mathlib.Order.Filter.ENNReal #align_import measure_theory.function.ess_sup from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf" /-! # Essential supremum and infimum We define the essential supremum and infimum of a function `f : α → β` with respect to a measure `μ` on `α`. The essential supremum is the infimum of the constants `c : β` such that `f x ≤ c` almost everywhere. TODO: The essential supremum of functions `α → ℝ≥0∞` is used in particular to define the norm in the `L∞` space (see `Mathlib.MeasureTheory.Function.LpSpace`). There is a different quantity which is sometimes also called essential supremum: the least upper-bound among measurable functions of a family of measurable functions (in an almost-everywhere sense). We do not define that quantity here, which is simply the supremum of a map with values in `α →ₘ[μ] β` (see `Mathlib.MeasureTheory.Function.AEEqFun`). ## Main definitions * `essSup f μ := (ae μ).limsup f` * `essInf f μ := (ae μ).liminf f` -/ open MeasureTheory Filter Set TopologicalSpace open ENNReal MeasureTheory NNReal variable {α β : Type*} {m : MeasurableSpace α} {μ ν : Measure α} section ConditionallyCompleteLattice variable [ConditionallyCompleteLattice β] /-- Essential supremum of `f` with respect to measure `μ`: the smallest `c : β` such that `f x ≤ c` a.e. -/ def essSup {_ : MeasurableSpace α} (f : α → β) (μ : Measure α) := (ae μ).limsup f #align ess_sup essSup /-- Essential infimum of `f` with respect to measure `μ`: the greatest `c : β` such that `c ≤ f x` a.e. -/ def essInf {_ : MeasurableSpace α} (f : α → β) (μ : Measure α) := (ae μ).liminf f #align ess_inf essInf theorem essSup_congr_ae {f g : α → β} (hfg : f =ᵐ[μ] g) : essSup f μ = essSup g μ := limsup_congr hfg #align ess_sup_congr_ae essSup_congr_ae theorem essInf_congr_ae {f g : α → β} (hfg : f =ᵐ[μ] g) : essInf f μ = essInf g μ := @essSup_congr_ae α βᵒᵈ _ _ _ _ _ hfg #align ess_inf_congr_ae essInf_congr_ae @[simp] theorem essSup_const' [NeZero μ] (c : β) : essSup (fun _ : α => c) μ = c := limsup_const _ #align ess_sup_const' essSup_const' @[simp] theorem essInf_const' [NeZero μ] (c : β) : essInf (fun _ : α => c) μ = c := liminf_const _ #align ess_inf_const' essInf_const' theorem essSup_const (c : β) (hμ : μ ≠ 0) : essSup (fun _ : α => c) μ = c := have := NeZero.mk hμ; essSup_const' _ #align ess_sup_const essSup_const theorem essInf_const (c : β) (hμ : μ ≠ 0) : essInf (fun _ : α => c) μ = c := have := NeZero.mk hμ; essInf_const' _ #align ess_inf_const essInf_const end ConditionallyCompleteLattice section ConditionallyCompleteLinearOrder variable [ConditionallyCompleteLinearOrder β] {x : β} {f : α → β} theorem essSup_eq_sInf {m : MeasurableSpace α} (μ : Measure α) (f : α → β) : essSup f μ = sInf { a | μ { x | a < f x } = 0 } := by dsimp [essSup, limsup, limsSup] simp only [eventually_map, ae_iff, not_le] #align ess_sup_eq_Inf essSup_eq_sInf theorem essInf_eq_sSup {m : MeasurableSpace α} (μ : Measure α) (f : α → β) : essInf f μ = sSup { a | μ { x | f x < a } = 0 } := by dsimp [essInf, liminf, limsInf] simp only [eventually_map, ae_iff, not_le] #align ess_inf_eq_Sup essInf_eq_sSup theorem ae_lt_of_essSup_lt (hx : essSup f μ < x) (hf : IsBoundedUnder (· ≤ ·) (ae μ) f := by isBoundedDefault) : ∀ᵐ y ∂μ, f y < x := eventually_lt_of_limsup_lt hx hf #align ae_lt_of_ess_sup_lt ae_lt_of_essSup_lt theorem ae_lt_of_lt_essInf (hx : x < essInf f μ) (hf : IsBoundedUnder (· ≥ ·) (ae μ) f := by isBoundedDefault) : ∀ᵐ y ∂μ, x < f y := eventually_lt_of_lt_liminf hx hf #align ae_lt_of_lt_ess_inf ae_lt_of_lt_essInf variable [TopologicalSpace β] [FirstCountableTopology β] [OrderTopology β] theorem ae_le_essSup (hf : IsBoundedUnder (· ≤ ·) (ae μ) f := by isBoundedDefault) : ∀ᵐ y ∂μ, f y ≤ essSup f μ := eventually_le_limsup hf #align ae_le_ess_sup ae_le_essSup theorem ae_essInf_le (hf : IsBoundedUnder (· ≥ ·) (ae μ) f := by isBoundedDefault) : ∀ᵐ y ∂μ, essInf f μ ≤ f y := eventually_liminf_le hf #align ae_ess_inf_le ae_essInf_le theorem meas_essSup_lt (hf : IsBoundedUnder (· ≤ ·) (ae μ) f := by isBoundedDefault) : μ { y | essSup f μ < f y } = 0 := by simp_rw [← not_le] exact ae_le_essSup hf #align meas_ess_sup_lt meas_essSup_lt
Mathlib/MeasureTheory/Function/EssSup.lean
131
135
theorem meas_lt_essInf (hf : IsBoundedUnder (· ≥ ·) (ae μ) f := by
isBoundedDefault) : μ { y | f y < essInf f μ } = 0 := by simp_rw [← not_le] exact ae_essInf_le hf
/- Copyright (c) 2021 Alex J. Best. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alex J. Best, Yaël Dillies -/ import Mathlib.Algebra.Bounds import Mathlib.Algebra.Order.Field.Basic -- Porting note: `LinearOrderedField`, etc import Mathlib.Data.Set.Pointwise.SMul #align_import algebra.order.pointwise from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Pointwise operations on ordered algebraic objects This file contains lemmas about the effect of pointwise operations on sets with an order structure. ## TODO `sSup (s • t) = sSup s • sSup t` and `sInf (s • t) = sInf s • sInf t` hold as well but `CovariantClass` is currently not polymorphic enough to state it. -/ open Function Set open Pointwise variable {α : Type*} -- Porting note: Swapped the place of `CompleteLattice` and `ConditionallyCompleteLattice` -- due to simpNF problem between `sSup_xx` `csSup_xx`. section CompleteLattice variable [CompleteLattice α] section One variable [One α] @[to_additive (attr := simp)] theorem sSup_one : sSup (1 : Set α) = 1 := sSup_singleton #align Sup_zero sSup_zero #align Sup_one sSup_one @[to_additive (attr := simp)] theorem sInf_one : sInf (1 : Set α) = 1 := sInf_singleton #align Inf_zero sInf_zero #align Inf_one sInf_one end One section Group variable [Group α] [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (swap (· * ·)) (· ≤ ·)] (s t : Set α) @[to_additive] theorem sSup_inv (s : Set α) : sSup s⁻¹ = (sInf s)⁻¹ := by rw [← image_inv, sSup_image] exact ((OrderIso.inv α).map_sInf _).symm #align Sup_inv sSup_inv #align Sup_neg sSup_neg @[to_additive] theorem sInf_inv (s : Set α) : sInf s⁻¹ = (sSup s)⁻¹ := by rw [← image_inv, sInf_image] exact ((OrderIso.inv α).map_sSup _).symm #align Inf_inv sInf_inv #align Inf_neg sInf_neg @[to_additive] theorem sSup_mul : sSup (s * t) = sSup s * sSup t := (sSup_image2_eq_sSup_sSup fun _ => (OrderIso.mulRight _).to_galoisConnection) fun _ => (OrderIso.mulLeft _).to_galoisConnection #align Sup_mul sSup_mul #align Sup_add sSup_add @[to_additive] theorem sInf_mul : sInf (s * t) = sInf s * sInf t := (sInf_image2_eq_sInf_sInf fun _ => (OrderIso.mulRight _).symm.to_galoisConnection) fun _ => (OrderIso.mulLeft _).symm.to_galoisConnection #align Inf_mul sInf_mul #align Inf_add sInf_add @[to_additive] theorem sSup_div : sSup (s / t) = sSup s / sInf t := by simp_rw [div_eq_mul_inv, sSup_mul, sSup_inv] #align Sup_div sSup_div #align Sup_sub sSup_sub @[to_additive] theorem sInf_div : sInf (s / t) = sInf s / sSup t := by simp_rw [div_eq_mul_inv, sInf_mul, sInf_inv] #align Inf_div sInf_div #align Inf_sub sInf_sub end Group end CompleteLattice section ConditionallyCompleteLattice variable [ConditionallyCompleteLattice α] section One variable [One α] @[to_additive (attr := simp)] theorem csSup_one : sSup (1 : Set α) = 1 := csSup_singleton _ #align cSup_zero csSup_zero #align cSup_one csSup_one @[to_additive (attr := simp)] theorem csInf_one : sInf (1 : Set α) = 1 := csInf_singleton _ #align cInf_zero csInf_zero #align cInf_one csInf_one end One section Group variable [Group α] [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (swap (· * ·)) (· ≤ ·)] {s t : Set α} @[to_additive] theorem csSup_inv (hs₀ : s.Nonempty) (hs₁ : BddBelow s) : sSup s⁻¹ = (sInf s)⁻¹ := by rw [← image_inv] exact ((OrderIso.inv α).map_csInf' hs₀ hs₁).symm #align cSup_inv csSup_inv #align cSup_neg csSup_neg @[to_additive]
Mathlib/Algebra/Order/Pointwise.lean
137
139
theorem csInf_inv (hs₀ : s.Nonempty) (hs₁ : BddAbove s) : sInf s⁻¹ = (sSup s)⁻¹ := by
rw [← image_inv] exact ((OrderIso.inv α).map_csSup' hs₀ hs₁).symm
/- 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]
Mathlib/Analysis/SpecialFunctions/Log/Base.lean
68
69
theorem logb_neg_eq_logb (x : ℝ) : logb b (-x) = logb b x := by
rw [← logb_abs x, ← logb_abs (-x), abs_neg]
/- 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.Analysis.Complex.UpperHalfPlane.Topology import Mathlib.Analysis.SpecialFunctions.Arsinh import Mathlib.Geometry.Euclidean.Inversion.Basic #align_import analysis.complex.upper_half_plane.metric from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c" /-! # Metric on the upper half-plane In this file we define a `MetricSpace` structure on the `UpperHalfPlane`. We use hyperbolic (Poincaré) distance given by `dist z w = 2 * arsinh (dist (z : ℂ) w / (2 * √(z.im * w.im)))` instead of the induced Euclidean distance because the hyperbolic distance is invariant under holomorphic automorphisms of the upper half-plane. However, we ensure that the projection to `TopologicalSpace` is definitionally equal to the induced topological space structure. We also prove that a metric ball/closed ball/sphere in Poincaré metric is a Euclidean ball/closed ball/sphere with another center and radius. -/ noncomputable section open scoped UpperHalfPlane ComplexConjugate NNReal Topology MatrixGroups open Set Metric Filter Real variable {z w : ℍ} {r R : ℝ} namespace UpperHalfPlane instance : Dist ℍ := ⟨fun z w => 2 * arsinh (dist (z : ℂ) w / (2 * √(z.im * w.im)))⟩ theorem dist_eq (z w : ℍ) : dist z w = 2 * arsinh (dist (z : ℂ) w / (2 * √(z.im * w.im))) := rfl #align upper_half_plane.dist_eq UpperHalfPlane.dist_eq theorem sinh_half_dist (z w : ℍ) : sinh (dist z w / 2) = dist (z : ℂ) w / (2 * √(z.im * w.im)) := by rw [dist_eq, mul_div_cancel_left₀ (arsinh _) two_ne_zero, sinh_arsinh] #align upper_half_plane.sinh_half_dist UpperHalfPlane.sinh_half_dist
Mathlib/Analysis/Complex/UpperHalfPlane/Metric.lean
50
57
theorem cosh_half_dist (z w : ℍ) : cosh (dist z w / 2) = dist (z : ℂ) (conj (w : ℂ)) / (2 * √(z.im * w.im)) := by
rw [← sq_eq_sq, cosh_sq', sinh_half_dist, div_pow, div_pow, one_add_div, mul_pow, sq_sqrt] · congr 1 simp only [Complex.dist_eq, Complex.sq_abs, Complex.normSq_sub, Complex.normSq_conj, Complex.conj_conj, Complex.mul_re, Complex.conj_re, Complex.conj_im, coe_im] ring all_goals positivity
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Topology.Homeomorph import Mathlib.Topology.StoneCech #align_import topology.extremally_disconnected from "leanprover-community/mathlib"@"7e281deff072232a3c5b3e90034bd65dde396312" /-! # Extremally disconnected spaces An extremally disconnected topological space is a space in which the closure of every open set is open. Such spaces are also called Stonean spaces. They are the projective objects in the category of compact Hausdorff spaces. ## Main declarations * `ExtremallyDisconnected`: Predicate for a space to be extremally disconnected. * `CompactT2.Projective`: Predicate for a topological space to be a projective object in the category of compact Hausdorff spaces. * `CompactT2.Projective.extremallyDisconnected`: Compact Hausdorff spaces that are projective are extremally disconnected. * `CompactT2.ExtremallyDisconnected.projective`: Extremally disconnected spaces are projective objects in the category of compact Hausdorff spaces. ## References [Gleason, *Projective topological spaces*][gleason1958] -/ noncomputable section open scoped Classical open Function Set universe u section variable (X : Type u) [TopologicalSpace X] /-- An extremally disconnected topological space is a space in which the closure of every open set is open. -/ class ExtremallyDisconnected : Prop where /-- The closure of every open set is open. -/ open_closure : ∀ U : Set X, IsOpen U → IsOpen (closure U) #align extremally_disconnected ExtremallyDisconnected section TotallySeparated /-- Extremally disconnected spaces are totally separated. -/ instance [ExtremallyDisconnected X] [T2Space X] : TotallySeparatedSpace X := { isTotallySeparated_univ := by intro x _ y _ hxy obtain ⟨U, V, hUV⟩ := T2Space.t2 hxy refine ⟨closure U, (closure U)ᶜ, ExtremallyDisconnected.open_closure U hUV.1, by simp only [isOpen_compl_iff, isClosed_closure], subset_closure hUV.2.2.1, ?_, by simp only [Set.union_compl_self, Set.subset_univ], disjoint_compl_right⟩ rw [Set.mem_compl_iff, mem_closure_iff] push_neg refine ⟨V, ⟨hUV.2.1, hUV.2.2.2.1, ?_⟩⟩ rw [← Set.disjoint_iff_inter_eq_empty, disjoint_comm] exact hUV.2.2.2.2 } end TotallySeparated section /-- The assertion `CompactT2.Projective` states that given continuous maps `f : X → Z` and `g : Y → Z` with `g` surjective between `t_2`, compact topological spaces, there exists a continuous lift `h : X → Y`, such that `f = g ∘ h`. -/ def CompactT2.Projective : Prop := ∀ {Y Z : Type u} [TopologicalSpace Y] [TopologicalSpace Z], ∀ [CompactSpace Y] [T2Space Y] [CompactSpace Z] [T2Space Z], ∀ {f : X → Z} {g : Y → Z} (_ : Continuous f) (_ : Continuous g) (_ : Surjective g), ∃ h : X → Y, Continuous h ∧ g ∘ h = f #align compact_t2.projective CompactT2.Projective variable {X}
Mathlib/Topology/ExtremallyDisconnected.lean
83
92
theorem StoneCech.projective [DiscreteTopology X] : CompactT2.Projective (StoneCech X) := by
intro Y Z _tsY _tsZ _csY _t2Y _csZ _csZ f g hf hg g_sur let s : Z → Y := fun z => Classical.choose <| g_sur z have hs : g ∘ s = id := funext fun z => Classical.choose_spec (g_sur z) let t := s ∘ f ∘ stoneCechUnit have ht : Continuous t := continuous_of_discreteTopology let h : StoneCech X → Y := stoneCechExtend ht have hh : Continuous h := continuous_stoneCechExtend ht refine ⟨h, hh, denseRange_stoneCechUnit.equalizer (hg.comp hh) hf ?_⟩ rw [comp.assoc, stoneCechExtend_extends ht, ← comp.assoc, hs, id_comp]
/- 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.Short #align_import set_theory.game.state from "leanprover-community/mathlib"@"b134b2f5cf6dd25d4bbfd3c498b6e36c11a17225" /-! # Games described via "the state of the board". We provide a simple mechanism for constructing combinatorial (pre-)games, by describing "the state of the board", and providing an upper bound on the number of turns remaining. ## Implementation notes We're very careful to produce a computable definition, so small games can be evaluated using `decide`. To achieve this, I've had to rely solely on induction on natural numbers: relying on general well-foundedness seems to be poisonous to computation? See `SetTheory/Game/Domineering` for an example using this construction. -/ universe u namespace SetTheory namespace PGame /-- `SetTheory.PGame.State S` describes how to interpret `s : S` as a state of a combinatorial game. Use `SetTheory.PGame.ofState s` or `SetTheory.Game.ofState s` to construct the game. `SetTheory.PGame.State.l : S → Finset S` and `SetTheory.PGame.State.r : S → Finset S` describe the states reachable by a move by Left or Right. `SetTheory.PGame.State.turnBound : S → ℕ` gives an upper bound on the number of possible turns remaining from this state. -/ class State (S : Type u) where turnBound : S → ℕ l : S → Finset S r : S → Finset S left_bound : ∀ {s t : S}, t ∈ l s → turnBound t < turnBound s right_bound : ∀ {s t : S}, t ∈ r s → turnBound t < turnBound s #align pgame.state SetTheory.PGame.State open State variable {S : Type u} [State S] theorem turnBound_ne_zero_of_left_move {s t : S} (m : t ∈ l s) : turnBound s ≠ 0 := by intro h have t := left_bound m rw [h] at t exact Nat.not_succ_le_zero _ t #align pgame.turn_bound_ne_zero_of_left_move SetTheory.PGame.turnBound_ne_zero_of_left_move
Mathlib/SetTheory/Game/State.lean
57
61
theorem turnBound_ne_zero_of_right_move {s t : S} (m : t ∈ r s) : turnBound s ≠ 0 := by
intro h have t := right_bound m rw [h] at t exact Nat.not_succ_le_zero _ t
/- 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.Faces import Mathlib.CategoryTheory.Idempotents.Basic #align_import algebraic_topology.dold_kan.projections from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" /-! # Construction of projections for the Dold-Kan correspondence In this file, we construct endomorphisms `P q : K[X] ⟶ K[X]` for all `q : ℕ`. We study how they behave with respect to face maps with the lemmas `HigherFacesVanish.of_P`, `HigherFacesVanish.comp_P_eq_self` and `comp_P_eq_self_iff`. Then, we show that they are projections (see `P_f_idem` and `P_idem`). They are natural transformations (see `natTransP` and `P_f_naturality`) and are compatible with the application of additive functors (see `map_P`). By passing to the limit, these endomorphisms `P q` shall be used in `PInfty.lean` in order to define `PInfty : K[X] ⟶ K[X]`. (See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.) -/ open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Preadditive CategoryTheory.SimplicialObject Opposite CategoryTheory.Idempotents open Simplicial DoldKan noncomputable section namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] {X : SimplicialObject C} /-- This is the inductive definition of the projections `P q : K[X] ⟶ K[X]`, with `P 0 := 𝟙 _` and `P (q+1) := P q ≫ (𝟙 _ + Hσ q)`. -/ noncomputable def P : ℕ → (K[X] ⟶ K[X]) | 0 => 𝟙 _ | q + 1 => P q ≫ (𝟙 _ + Hσ q) set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.P AlgebraicTopology.DoldKan.P -- Porting note: `P_zero` and `P_succ` have been added to ease the port, because -- `unfold P` would sometimes unfold to a `match` rather than the induction formula lemma P_zero : (P 0 : K[X] ⟶ K[X]) = 𝟙 _ := rfl lemma P_succ (q : ℕ) : (P (q+1) : K[X] ⟶ K[X]) = P q ≫ (𝟙 _ + Hσ q) := rfl /-- All the `P q` coincide with `𝟙 _` in degree 0. -/ @[simp]
Mathlib/AlgebraicTopology/DoldKan/Projections.lean
61
65
theorem P_f_0_eq (q : ℕ) : ((P q).f 0 : X _[0] ⟶ X _[0]) = 𝟙 _ := by
induction' q with q hq · rfl · simp only [P_succ, HomologicalComplex.add_f_apply, HomologicalComplex.comp_f, HomologicalComplex.id_f, id_comp, hq, Hσ_eq_zero, add_zero]
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Fintype.BigOperators import Mathlib.LinearAlgebra.AffineSpace.AffineMap import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace import Mathlib.LinearAlgebra.Finsupp import Mathlib.Tactic.FinCases #align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" /-! # Affine combinations of points This file defines affine combinations of points. ## Main definitions * `weightedVSubOfPoint` is a general weighted combination of subtractions with an explicit base point, yielding a vector. * `weightedVSub` uses an arbitrary choice of base point and is intended to be used when the sum of weights is 0, in which case the result is independent of the choice of base point. * `affineCombination` adds the weighted combination to the arbitrary base point, yielding a point rather than a vector, and is intended to be used when the sum of weights is 1, in which case the result is independent of the choice of base point. These definitions are for sums over a `Finset`; versions for a `Fintype` may be obtained using `Finset.univ`, while versions for a `Finsupp` may be obtained using `Finsupp.support`. ## References * https://en.wikipedia.org/wiki/Affine_space -/ noncomputable section open Affine namespace Finset theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by ext x fin_cases x <;> simp #align finset.univ_fin2 Finset.univ_fin2 variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V] variable [S : AffineSpace V P] variable {ι : Type*} (s : Finset ι) variable {ι₂ : Type*} (s₂ : Finset ι₂) /-- A weighted sum of the results of subtracting a base point from the given points, as a linear map on the weights. The main cases of interest are where the sum of the weights is 0, in which case the sum is independent of the choice of base point, and where the sum of the weights is 1, in which case the sum added to the base point is independent of the choice of base point. -/ def weightedVSubOfPoint (p : ι → P) (b : P) : (ι → k) →ₗ[k] V := ∑ i ∈ s, (LinearMap.proj i : (ι → k) →ₗ[k] k).smulRight (p i -ᵥ b) #align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint @[simp] theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) : s.weightedVSubOfPoint p b w = ∑ i ∈ s, w i • (p i -ᵥ b) := by simp [weightedVSubOfPoint, LinearMap.sum_apply] #align finset.weighted_vsub_of_point_apply Finset.weightedVSubOfPoint_apply /-- The value of `weightedVSubOfPoint`, where the given points are equal. -/ @[simp (high)] theorem weightedVSubOfPoint_apply_const (w : ι → k) (p : P) (b : P) : s.weightedVSubOfPoint (fun _ => p) b w = (∑ i ∈ s, w i) • (p -ᵥ b) := by rw [weightedVSubOfPoint_apply, sum_smul] #align finset.weighted_vsub_of_point_apply_const Finset.weightedVSubOfPoint_apply_const /-- `weightedVSubOfPoint` gives equal results for two families of weights and two families of points that are equal on `s`. -/ theorem weightedVSubOfPoint_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P} (hp : ∀ i ∈ s, p₁ i = p₂ i) (b : P) : s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint p₂ b w₂ := by simp_rw [weightedVSubOfPoint_apply] refine sum_congr rfl fun i hi => ?_ rw [hw i hi, hp i hi] #align finset.weighted_vsub_of_point_congr Finset.weightedVSubOfPoint_congr /-- Given a family of points, if we use a member of the family as a base point, the `weightedVSubOfPoint` does not depend on the value of the weights at this point. -/
Mathlib/LinearAlgebra/AffineSpace/Combination.lean
96
104
theorem weightedVSubOfPoint_eq_of_weights_eq (p : ι → P) (j : ι) (w₁ w₂ : ι → k) (hw : ∀ i, i ≠ j → w₁ i = w₂ i) : s.weightedVSubOfPoint p (p j) w₁ = s.weightedVSubOfPoint p (p j) w₂ := by
simp only [Finset.weightedVSubOfPoint_apply] congr ext i rcases eq_or_ne i j with h | h · simp [h] · simp [hw i h]
/- Copyright (c) 2022 Jannis Limperg. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jannis Limperg -/ import Batteries.Data.UInt @[ext] theorem Char.ext : {a b : Char} → a.val = b.val → a = b | ⟨_,_⟩, ⟨_,_⟩, rfl => rfl theorem Char.ext_iff {x y : Char} : x = y ↔ x.val = y.val := ⟨congrArg _, Char.ext⟩ theorem Char.le_antisymm_iff {x y : Char} : x = y ↔ x ≤ y ∧ y ≤ x := Char.ext_iff.trans UInt32.le_antisymm_iff theorem Char.le_antisymm {x y : Char} (h1 : x ≤ y) (h2 : y ≤ x) : x = y := Char.le_antisymm_iff.2 ⟨h1, h2⟩ instance : Batteries.LawfulOrd Char := .compareOfLessAndEq (fun _ => Nat.lt_irrefl _) Nat.lt_trans Nat.not_lt Char.le_antisymm namespace String private theorem csize_eq (c) : csize c = 1 ∨ csize c = 2 ∨ csize c = 3 ∨ csize c = 4 := by simp only [csize, Char.utf8Size] repeat (first | split | (solve | simp (config := {decide := true})))
.lake/packages/batteries/Batteries/Data/Char.lean
30
31
theorem csize_pos (c) : 0 < csize c := by
rcases csize_eq c with _|_|_|_ <;> simp_all (config := {decide := true})
/- Copyright (c) 2023 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.CategoryTheory.EssentiallySmall import Mathlib.CategoryTheory.Filtered.Basic /-! # A functor from a small category to a filtered category factors through a small filtered category A consequence of this is that if `C` is filtered and finally small, then `C` is also "finally filtered-small", i.e., there is a final functor from a small filtered category to `C`. This is occasionally useful, for example in the proof of the recognition theorem for ind-objects (Proposition 6.1.5 in [Kashiwara2006]). -/ universe w v v₁ u u₁ namespace CategoryTheory variable {C : Type u} [Category.{v} C] namespace IsFiltered section FilteredClosure variable [IsFilteredOrEmpty C] {α : Type w} (f : α → C) /-- The "filtered closure" of an `α`-indexed family of objects in `C` is the set of objects in `C` obtained by starting with the family and successively adding maxima and coequalizers. -/ inductive FilteredClosure : C → Prop | base : (x : α) → FilteredClosure (f x) | max : {j j' : C} → FilteredClosure j → FilteredClosure j' → FilteredClosure (max j j') | coeq : {j j' : C} → FilteredClosure j → FilteredClosure j' → (f f' : j ⟶ j') → FilteredClosure (coeq f f') /-- The full subcategory induced by the filtered closure of a family of objects is filtered. -/ instance : IsFilteredOrEmpty (FullSubcategory (FilteredClosure f)) where cocone_objs j j' := ⟨⟨max j.1 j'.1, FilteredClosure.max j.2 j'.2⟩, leftToMax _ _, rightToMax _ _, trivial⟩ cocone_maps {j j'} f f' := ⟨⟨coeq f f', FilteredClosure.coeq j.2 j'.2 f f'⟩, coeqHom (C := C) f f', coeq_condition _ _⟩ namespace FilteredClosureSmall /-! Our goal for this section is to show that the size of the filtered closure of an `α`-indexed family of objects in `C` only depends on the size of `α` and the morphism types of `C`, not on the size of the objects of `C`. More precisely, if `α` lives in `Type w`, the objects of `C` live in `Type u` and the morphisms of `C` live in `Type v`, then we want `Small.{max v w} (FullSubcategory (FilteredClosure f))`. The strategy is to define a type `AbstractFilteredClosure` which should be an inductive type similar to `FilteredClosure`, which lives in the correct universe and surjects onto the full subcategory. The difficulty with this is that we need to define it at the same time as the map `AbstractFilteredClosure → C`, as the coequalizer constructor depends on the actual morphisms in `C`. This would require some kind of inductive-recursive definition, which Lean does not allow. Our solution is to define a function `ℕ → Σ t : Type (max v w), t → C` by (strong) induction and then take the union over all natural numbers, mimicking what one would do in a set-theoretic setting. -/ /-- One step of the inductive procedure consists of adjoining all maxima and coequalizers of all objects and morphisms obtained so far. This is quite redundant, picking up many objects which we already hit in earlier iterations, but this is easier to work with later. -/ private inductive InductiveStep (n : ℕ) (X : ∀ (k : ℕ), k < n → Σ t : Type (max v w), t → C) : Type (max v w) | max : {k k' : ℕ} → (hk : k < n) → (hk' : k' < n) → (X _ hk).1 → (X _ hk').1 → InductiveStep n X | coeq : {k k' : ℕ} → (hk : k < n) → (hk' : k' < n) → (j : (X _ hk).1) → (j' : (X _ hk').1) → ((X _ hk).2 j ⟶ (X _ hk').2 j') → ((X _ hk).2 j ⟶ (X _ hk').2 j') → InductiveStep n X /-- The realization function sends the abstract maxima and weak coequalizers to the corresponding objects in `C`. -/ private noncomputable def inductiveStepRealization (n : ℕ) (X : ∀ (k : ℕ), k < n → Σ t : Type (max v w), t → C) : InductiveStep.{w} n X → C | (InductiveStep.max hk hk' x y) => max ((X _ hk).2 x) ((X _ hk').2 y) | (InductiveStep.coeq _ _ _ _ f g) => coeq f g /-- All steps of building the abstract filtered closure together with the realization function, as a function of `ℕ`. The function is defined by well-founded recursion, but we really want to use its definitional equalities in the proofs below, so lets make it semireducible. -/ @[semireducible] private noncomputable def bundledAbstractFilteredClosure : ℕ → Σ t : Type (max v w), t → C | 0 => ⟨ULift.{v} α, f ∘ ULift.down⟩ | (n + 1) => ⟨_, inductiveStepRealization (n + 1) (fun m _ => bundledAbstractFilteredClosure m)⟩ /-- The small type modelling the filtered closure. -/ private noncomputable def AbstractFilteredClosure : Type (max v w) := Σ n, (bundledAbstractFilteredClosure f n).1 /-- The surjection from the abstract filtered closure to the actual filtered closure in `C`. -/ private noncomputable def abstractFilteredClosureRealization : AbstractFilteredClosure f → C := fun x => (bundledAbstractFilteredClosure f x.1).2 x.2 end FilteredClosureSmall
Mathlib/CategoryTheory/Filtered/Small.lean
97
115
theorem small_fullSubcategory_filteredClosure : Small.{max v w} (FullSubcategory (FilteredClosure f)) := by
refine small_of_injective_of_exists (FilteredClosureSmall.abstractFilteredClosureRealization f) FullSubcategory.ext ?_ rintro ⟨j, h⟩ induction h with | base x => exact ⟨⟨0, ⟨x⟩⟩, rfl⟩ | max hj₁ hj₂ ih ih' => rcases ih with ⟨⟨n, x⟩, rfl⟩ rcases ih' with ⟨⟨m, y⟩, rfl⟩ refine ⟨⟨(Max.max n m).succ, FilteredClosureSmall.InductiveStep.max ?_ ?_ x y⟩, rfl⟩ all_goals apply Nat.lt_succ_of_le exacts [Nat.le_max_left _ _, Nat.le_max_right _ _] | coeq hj₁ hj₂ g g' ih ih' => rcases ih with ⟨⟨n, x⟩, rfl⟩ rcases ih' with ⟨⟨m, y⟩, rfl⟩ refine ⟨⟨(Max.max n m).succ, FilteredClosureSmall.InductiveStep.coeq ?_ ?_ x y g g'⟩, rfl⟩ all_goals apply Nat.lt_succ_of_le exacts [Nat.le_max_left _ _, Nat.le_max_right _ _]
/- Copyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Analysis.Convex.Topology import Mathlib.Analysis.NormedSpace.Pointwise import Mathlib.Analysis.Seminorm import Mathlib.Analysis.LocallyConvex.Bounded import Mathlib.Analysis.RCLike.Basic #align_import analysis.convex.gauge from "leanprover-community/mathlib"@"373b03b5b9d0486534edbe94747f23cb3712f93d" /-! # The Minkowski functional This file defines the Minkowski functional, aka gauge. The Minkowski functional of a set `s` is the function which associates each point to how much you need to scale `s` for `x` to be inside it. When `s` is symmetric, convex and absorbent, its gauge is a seminorm. Reciprocally, any seminorm arises as the gauge of some set, namely its unit ball. This induces the equivalence of seminorms and locally convex topological vector spaces. ## Main declarations For a real vector space, * `gauge`: Aka Minkowski functional. `gauge s x` is the least (actually, an infimum) `r` such that `x ∈ r • s`. * `gaugeSeminorm`: The Minkowski functional as a seminorm, when `s` is symmetric, convex and absorbent. ## References * [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966] ## Tags Minkowski functional, gauge -/ open NormedField Set open scoped Pointwise Topology NNReal noncomputable section variable {𝕜 E F : Type*} section AddCommGroup variable [AddCommGroup E] [Module ℝ E] /-- The Minkowski functional. Given a set `s` in a real vector space, `gauge s` is the functional which sends `x : E` to the smallest `r : ℝ` such that `x` is in `s` scaled by `r`. -/ def gauge (s : Set E) (x : E) : ℝ := sInf { r : ℝ | 0 < r ∧ x ∈ r • s } #align gauge gauge variable {s t : Set E} {x : E} {a : ℝ} theorem gauge_def : gauge s x = sInf ({ r ∈ Set.Ioi (0 : ℝ) | x ∈ r • s }) := rfl #align gauge_def gauge_def /-- An alternative definition of the gauge using scalar multiplication on the element rather than on the set. -/
Mathlib/Analysis/Convex/Gauge.lean
66
68
theorem gauge_def' : gauge s x = sInf {r ∈ Set.Ioi (0 : ℝ) | r⁻¹ • x ∈ s} := by
congrm sInf {r | ?_} exact and_congr_right fun hr => mem_smul_set_iff_inv_smul_mem₀ hr.ne' _ _
/- 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.Group.Fin import Mathlib.Algebra.NeZero import Mathlib.Data.Nat.ModEq import Mathlib.Data.Fintype.Card #align_import data.zmod.defs from "leanprover-community/mathlib"@"3a2b5524a138b5d0b818b858b516d4ac8a484b03" /-! # Definition of `ZMod n` + basic results. This file provides the basic details of `ZMod n`, including its commutative ring structure. ## Implementation details This used to be inlined into `Data.ZMod.Basic`. This file imports `CharP.Basic`, which is an issue; all `CharP` instances create an `Algebra (ZMod p) R` instance; however, this instance may not be definitionally equal to other `Algebra` instances (for example, `GaloisField` also has an `Algebra` instance as it is defined as a `SplittingField`). The way to fix this is to use the forgetful inheritance pattern, and make `CharP` carry the data of what the `smul` should be (so for example, the `smul` on the `GaloisField` `CharP` instance should be equal to the `smul` from its `SplittingField` structure); there is only one possible `ZMod p` algebra for any `p`, so this is not an issue mathematically. For this to be possible, however, we need `CharP.Basic` to be able to import some part of `ZMod`. -/ namespace Fin /-! ## Ring structure on `Fin n` We define a commutative ring structure on `Fin n`. Afterwards, when we define `ZMod n` in terms of `Fin n`, we use these definitions to register the ring structure on `ZMod n` as type class instance. -/ open Nat.ModEq Int /-- Multiplicative commutative semigroup structure on `Fin n`. -/ instance instCommSemigroup (n : ℕ) : CommSemigroup (Fin n) := { inferInstanceAs (Mul (Fin n)) with mul_assoc := fun ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩ => Fin.eq_of_val_eq <| calc a * b % n * c ≡ a * b * c [MOD n] := (Nat.mod_modEq _ _).mul_right _ _ ≡ a * (b * c) [MOD n] := by rw [mul_assoc] _ ≡ a * (b * c % n) [MOD n] := (Nat.mod_modEq _ _).symm.mul_left _ mul_comm := Fin.mul_comm } #align fin.comm_semigroup Fin.instCommSemigroup private theorem left_distrib_aux (n : ℕ) : ∀ a b c : Fin n, a * (b + c) = a * b + a * c := fun ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩ => Fin.eq_of_val_eq <| calc a * ((b + c) % n) ≡ a * (b + c) [MOD n] := (Nat.mod_modEq _ _).mul_left _ _ ≡ a * b + a * c [MOD n] := by rw [mul_add] _ ≡ a * b % n + a * c % n [MOD n] := (Nat.mod_modEq _ _).symm.add (Nat.mod_modEq _ _).symm /-- Commutative ring structure on `Fin n`. -/ instance instDistrib (n : ℕ) : Distrib (Fin n) := { Fin.addCommSemigroup n, Fin.instCommSemigroup n with left_distrib := left_distrib_aux n right_distrib := fun a b c => by rw [mul_comm, left_distrib_aux, mul_comm _ b, mul_comm] } #align fin.distrib Fin.instDistrib /-- Commutative ring structure on `Fin n`. -/ instance instCommRing (n : ℕ) [NeZero n] : CommRing (Fin n) := { Fin.instAddMonoidWithOne n, Fin.addCommGroup n, Fin.instCommSemigroup n, Fin.instDistrib n with one_mul := Fin.one_mul' mul_one := Fin.mul_one', -- Porting note: new, see -- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/ring.20vs.20Ring/near/322876462 zero_mul := Fin.zero_mul' mul_zero := Fin.mul_zero' } #align fin.comm_ring Fin.instCommRing /-- Note this is more general than `Fin.instCommRing` as it applies (vacuously) to `Fin 0` too. -/ instance instHasDistribNeg (n : ℕ) : HasDistribNeg (Fin n) := { toInvolutiveNeg := Fin.instInvolutiveNeg n mul_neg := Nat.casesOn n finZeroElim fun _i => mul_neg neg_mul := Nat.casesOn n finZeroElim fun _i => neg_mul } #align fin.has_distrib_neg Fin.instHasDistribNeg end Fin /-- The integers modulo `n : ℕ`. -/ def ZMod : ℕ → Type | 0 => ℤ | n + 1 => Fin (n + 1) #align zmod ZMod instance ZMod.decidableEq : ∀ n : ℕ, DecidableEq (ZMod n) | 0 => inferInstanceAs (DecidableEq ℤ) | n + 1 => inferInstanceAs (DecidableEq (Fin (n + 1))) #align zmod.decidable_eq ZMod.decidableEq instance ZMod.repr : ∀ n : ℕ, Repr (ZMod n) | 0 => by dsimp [ZMod]; infer_instance | n + 1 => by dsimp [ZMod]; infer_instance #align zmod.has_repr ZMod.repr namespace ZMod instance instUnique : Unique (ZMod 1) := Fin.uniqueFinOne instance fintype : ∀ (n : ℕ) [NeZero n], Fintype (ZMod n) | 0, h => (h.ne rfl).elim | n + 1, _ => Fin.fintype (n + 1) #align zmod.fintype ZMod.fintype instance infinite : Infinite (ZMod 0) := Int.infinite #align zmod.infinite ZMod.infinite @[simp]
Mathlib/Data/ZMod/Defs.lean
124
127
theorem card (n : ℕ) [Fintype (ZMod n)] : Fintype.card (ZMod n) = n := by
cases n with | zero => exact (not_finite (ZMod 0)).elim | succ n => convert Fintype.card_fin (n + 1) using 2
/- Copyright (c) 2019 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Scott Morrison -/ import Mathlib.Algebra.Order.Hom.Monoid import Mathlib.SetTheory.Game.Ordinal #align_import set_theory.surreal.basic from "leanprover-community/mathlib"@"8900d545017cd21961daa2a1734bb658ef52c618" /-! # Surreal numbers The basic theory of surreal numbers, built on top of the theory of combinatorial (pre-)games. A pregame is `Numeric` if all the Left options are strictly smaller than all the Right options, and all those options are themselves numeric. In terms of combinatorial games, the numeric games have "frozen"; you can only make your position worse by playing, and Left is some definite "number" of moves ahead (or behind) Right. A surreal number is an equivalence class of numeric pregames. In fact, the surreals form a complete ordered field, containing a copy of the reals (and much else besides!) but we do not yet have a complete development. ## Order properties Surreal numbers inherit the relations `≤` and `<` from games (`Surreal.instLE` and `Surreal.instLT`), and these relations satisfy the axioms of a partial order. ## Algebraic operations We show that the surreals form a linear ordered commutative group. One can also map all the ordinals into the surreals! ### Multiplication of surreal numbers The proof that multiplication lifts to surreal numbers is surprisingly difficult and is currently missing in the library. A sample proof can be found in Theorem 3.8 in the second reference below. The difficulty lies in the length of the proof and the number of theorems that need to proven simultaneously. This will make for a fun and challenging project. The branch `surreal_mul` contains some progress on this proof. ### Todo - Define the field structure on the surreals. ## References * [Conway, *On numbers and games*][conway2001] * [Schleicher, Stoll, *An introduction to Conway's games and numbers*][schleicher_stoll] -/ universe u namespace SetTheory open scoped PGame namespace PGame /-- A pre-game is numeric if everything in the L set is less than everything in the R set, and all the elements of L and R are also numeric. -/ def Numeric : PGame → Prop | ⟨_, _, L, R⟩ => (∀ i j, L i < R j) ∧ (∀ i, Numeric (L i)) ∧ ∀ j, Numeric (R j) #align pgame.numeric SetTheory.PGame.Numeric theorem numeric_def {x : PGame} : Numeric x ↔ (∀ i j, x.moveLeft i < x.moveRight j) ∧ (∀ i, Numeric (x.moveLeft i)) ∧ ∀ j, Numeric (x.moveRight j) := by cases x; rfl #align pgame.numeric_def SetTheory.PGame.numeric_def namespace Numeric theorem mk {x : PGame} (h₁ : ∀ i j, x.moveLeft i < x.moveRight j) (h₂ : ∀ i, Numeric (x.moveLeft i)) (h₃ : ∀ j, Numeric (x.moveRight j)) : Numeric x := numeric_def.2 ⟨h₁, h₂, h₃⟩ #align pgame.numeric.mk SetTheory.PGame.Numeric.mk theorem left_lt_right {x : PGame} (o : Numeric x) (i : x.LeftMoves) (j : x.RightMoves) : x.moveLeft i < x.moveRight j := by cases x; exact o.1 i j #align pgame.numeric.left_lt_right SetTheory.PGame.Numeric.left_lt_right theorem moveLeft {x : PGame} (o : Numeric x) (i : x.LeftMoves) : Numeric (x.moveLeft i) := by cases x; exact o.2.1 i #align pgame.numeric.move_left SetTheory.PGame.Numeric.moveLeft theorem moveRight {x : PGame} (o : Numeric x) (j : x.RightMoves) : Numeric (x.moveRight j) := by cases x; exact o.2.2 j #align pgame.numeric.move_right SetTheory.PGame.Numeric.moveRight end Numeric @[elab_as_elim] theorem numeric_rec {C : PGame → Prop} (H : ∀ (l r) (L : l → PGame) (R : r → PGame), (∀ i j, L i < R j) → (∀ i, Numeric (L i)) → (∀ i, Numeric (R i)) → (∀ i, C (L i)) → (∀ i, C (R i)) → C ⟨l, r, L, R⟩) : ∀ x, Numeric x → C x | ⟨_, _, _, _⟩, ⟨h, hl, hr⟩ => H _ _ _ _ h hl hr (fun i => numeric_rec H _ (hl i)) fun i => numeric_rec H _ (hr i) #align pgame.numeric_rec SetTheory.PGame.numeric_rec theorem Relabelling.numeric_imp {x y : PGame} (r : x ≡r y) (ox : Numeric x) : Numeric y := by induction' x using PGame.moveRecOn with x IHl IHr generalizing y apply Numeric.mk (fun i j => ?_) (fun i => ?_) fun j => ?_ · rw [← lt_congr (r.moveLeftSymm i).equiv (r.moveRightSymm j).equiv] apply ox.left_lt_right · exact IHl _ (r.moveLeftSymm i) (ox.moveLeft _) · exact IHr _ (r.moveRightSymm j) (ox.moveRight _) #align pgame.relabelling.numeric_imp SetTheory.PGame.Relabelling.numeric_imp /-- Relabellings preserve being numeric. -/ theorem Relabelling.numeric_congr {x y : PGame} (r : x ≡r y) : Numeric x ↔ Numeric y := ⟨r.numeric_imp, r.symm.numeric_imp⟩ #align pgame.relabelling.numeric_congr SetTheory.PGame.Relabelling.numeric_congr
Mathlib/SetTheory/Surreal/Basic.lean
123
131
theorem lf_asymm {x y : PGame} (ox : Numeric x) (oy : Numeric y) : x ⧏ y → ¬y ⧏ x := by
refine numeric_rec (C := fun x => ∀ z (_oz : Numeric z), x ⧏ z → ¬z ⧏ x) (fun xl xr xL xR hx _oxl _oxr IHxl IHxr => ?_) x ox y oy refine numeric_rec fun yl yr yL yR hy oyl oyr _IHyl _IHyr => ?_ rw [mk_lf_mk, mk_lf_mk]; rintro (⟨i, h₁⟩ | ⟨j, h₁⟩) (⟨i, h₂⟩ | ⟨j, h₂⟩) · exact IHxl _ _ (oyl _) (h₁.moveLeft_lf _) (h₂.moveLeft_lf _) · exact (le_trans h₂ h₁).not_gf (lf_of_lt (hy _ _)) · exact (le_trans h₁ h₂).not_gf (lf_of_lt (hx _ _)) · exact IHxr _ _ (oyr _) (h₁.lf_moveRight _) (h₂.lf_moveRight _)
/- 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.Group.Units import Mathlib.Algebra.GroupWithZero.Basic import Mathlib.Logic.Equiv.Defs import Mathlib.Tactic.Contrapose import Mathlib.Tactic.Nontriviality import Mathlib.Tactic.Spread import Mathlib.Util.AssertExists #align_import algebra.group_with_zero.units.basic from "leanprover-community/mathlib"@"df5e9937a06fdd349fc60106f54b84d47b1434f0" /-! # Lemmas about units in a `MonoidWithZero` or a `GroupWithZero`. We also define `Ring.inverse`, a globally defined function on any ring (in fact any `MonoidWithZero`), which inverts units and sends non-units to zero. -/ -- Guard against import creep assert_not_exists Multiplicative assert_not_exists DenselyOrdered variable {α M₀ G₀ M₀' G₀' F F' : Type*} variable [MonoidWithZero M₀] namespace Units /-- An element of the unit group of a nonzero monoid with zero represented as an element of the monoid is nonzero. -/ @[simp] theorem ne_zero [Nontrivial M₀] (u : M₀ˣ) : (u : M₀) ≠ 0 := left_ne_zero_of_mul_eq_one u.mul_inv #align units.ne_zero Units.ne_zero -- We can't use `mul_eq_zero` + `Units.ne_zero` in the next two lemmas because we don't assume -- `Nonzero M₀`. @[simp] theorem mul_left_eq_zero (u : M₀ˣ) {a : M₀} : a * u = 0 ↔ a = 0 := ⟨fun h => by simpa using mul_eq_zero_of_left h ↑u⁻¹, fun h => mul_eq_zero_of_left h u⟩ #align units.mul_left_eq_zero Units.mul_left_eq_zero @[simp] theorem mul_right_eq_zero (u : M₀ˣ) {a : M₀} : ↑u * a = 0 ↔ a = 0 := ⟨fun h => by simpa using mul_eq_zero_of_right (↑u⁻¹) h, mul_eq_zero_of_right (u : M₀)⟩ #align units.mul_right_eq_zero Units.mul_right_eq_zero end Units namespace IsUnit theorem ne_zero [Nontrivial M₀] {a : M₀} (ha : IsUnit a) : a ≠ 0 := let ⟨u, hu⟩ := ha hu ▸ u.ne_zero #align is_unit.ne_zero IsUnit.ne_zero theorem mul_right_eq_zero {a b : M₀} (ha : IsUnit a) : a * b = 0 ↔ b = 0 := let ⟨u, hu⟩ := ha hu ▸ u.mul_right_eq_zero #align is_unit.mul_right_eq_zero IsUnit.mul_right_eq_zero theorem mul_left_eq_zero {a b : M₀} (hb : IsUnit b) : a * b = 0 ↔ a = 0 := let ⟨u, hu⟩ := hb hu ▸ u.mul_left_eq_zero #align is_unit.mul_left_eq_zero IsUnit.mul_left_eq_zero end IsUnit @[simp] theorem isUnit_zero_iff : IsUnit (0 : M₀) ↔ (0 : M₀) = 1 := ⟨fun ⟨⟨_, a, (a0 : 0 * a = 1), _⟩, rfl⟩ => by rwa [zero_mul] at a0, fun h => @isUnit_of_subsingleton _ _ (subsingleton_of_zero_eq_one h) 0⟩ #align is_unit_zero_iff isUnit_zero_iff -- Porting note: removed `simp` tag because `simpNF` says it's redundant theorem not_isUnit_zero [Nontrivial M₀] : ¬IsUnit (0 : M₀) := mt isUnit_zero_iff.1 zero_ne_one #align not_is_unit_zero not_isUnit_zero namespace Ring open scoped Classical /-- Introduce a function `inverse` on a monoid with zero `M₀`, which sends `x` to `x⁻¹` if `x` is invertible and to `0` otherwise. This definition is somewhat ad hoc, but one needs a fully (rather than partially) defined inverse function for some purposes, including for calculus. Note that while this is in the `Ring` namespace for brevity, it requires the weaker assumption `MonoidWithZero M₀` instead of `Ring M₀`. -/ noncomputable def inverse : M₀ → M₀ := fun x => if h : IsUnit x then ((h.unit⁻¹ : M₀ˣ) : M₀) else 0 #align ring.inverse Ring.inverse /-- By definition, if `x` is invertible then `inverse x = x⁻¹`. -/ @[simp] theorem inverse_unit (u : M₀ˣ) : inverse (u : M₀) = (u⁻¹ : M₀ˣ) := by rw [inverse, dif_pos u.isUnit, IsUnit.unit_of_val_units] #align ring.inverse_unit Ring.inverse_unit /-- By definition, if `x` is not invertible then `inverse x = 0`. -/ @[simp] theorem inverse_non_unit (x : M₀) (h : ¬IsUnit x) : inverse x = 0 := dif_neg h #align ring.inverse_non_unit Ring.inverse_non_unit theorem mul_inverse_cancel (x : M₀) (h : IsUnit x) : x * inverse x = 1 := by rcases h with ⟨u, rfl⟩ rw [inverse_unit, Units.mul_inv] #align ring.mul_inverse_cancel Ring.mul_inverse_cancel theorem inverse_mul_cancel (x : M₀) (h : IsUnit x) : inverse x * x = 1 := by rcases h with ⟨u, rfl⟩ rw [inverse_unit, Units.inv_mul] #align ring.inverse_mul_cancel Ring.inverse_mul_cancel
Mathlib/Algebra/GroupWithZero/Units/Basic.lean
118
119
theorem mul_inverse_cancel_right (x y : M₀) (h : IsUnit x) : y * x * inverse x = y := by
rw [mul_assoc, mul_inverse_cancel x h, mul_one]
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.CategoryTheory.Limits.Shapes.CommSq import Mathlib.CategoryTheory.Limits.Shapes.StrictInitial import Mathlib.CategoryTheory.Limits.Shapes.Types import Mathlib.Topology.Category.TopCat.Limits.Pullbacks import Mathlib.CategoryTheory.Limits.FunctorCategory import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts import Mathlib.CategoryTheory.Limits.VanKampen #align_import category_theory.extensive from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" /-! # Extensive categories ## Main definitions - `CategoryTheory.FinitaryExtensive`: A category is (finitary) extensive if it has finite coproducts, and binary coproducts are van Kampen. ## Main Results - `CategoryTheory.hasStrictInitialObjects_of_finitaryExtensive`: The initial object in extensive categories is strict. - `CategoryTheory.FinitaryExtensive.mono_inr_of_isColimit`: Coproduct injections are monic in extensive categories. - `CategoryTheory.BinaryCofan.isPullback_initial_to_of_isVanKampen`: In extensive categories, sums are disjoint, i.e. the pullback of `X ⟶ X ⨿ Y` and `Y ⟶ X ⨿ Y` is the initial object. - `CategoryTheory.types.finitaryExtensive`: The category of types is extensive. - `CategoryTheory.FinitaryExtensive_TopCat`: The category `Top` is extensive. - `CategoryTheory.FinitaryExtensive_functor`: The category `C ⥤ D` is extensive if `D` has all pullbacks and is extensive. - `CategoryTheory.FinitaryExtensive.isVanKampen_finiteCoproducts`: Finite coproducts in a finitary extensive category are van Kampen. ## TODO Show that the following are finitary extensive: - `Scheme` - `AffineScheme` (`CommRingᵒᵖ`) ## References - https://ncatlab.org/nlab/show/extensive+category - [Carboni et al, Introduction to extensive and distributive categories][CARBONI1993145] -/ open CategoryTheory.Limits namespace CategoryTheory universe v' u' v u v'' u'' variable {J : Type v'} [Category.{u'} J] {C : Type u} [Category.{v} C] variable {D : Type u''} [Category.{v''} D] section Extensive variable {X Y : C} /-- A category has pullback of inclusions if it has all pullbacks along coproduct injections. -/ class HasPullbacksOfInclusions (C : Type u) [Category.{v} C] [HasBinaryCoproducts C] : Prop where [hasPullbackInl : ∀ {X Y Z : C} (f : Z ⟶ X ⨿ Y), HasPullback coprod.inl f] attribute [instance] HasPullbacksOfInclusions.hasPullbackInl /-- A functor preserves pullback of inclusions if it preserves all pullbacks along coproduct injections. -/ class PreservesPullbacksOfInclusions {C : Type*} [Category C] {D : Type*} [Category D] (F : C ⥤ D) [HasBinaryCoproducts C] where [preservesPullbackInl : ∀ {X Y Z : C} (f : Z ⟶ X ⨿ Y), PreservesLimit (cospan coprod.inl f) F] attribute [instance] PreservesPullbacksOfInclusions.preservesPullbackInl /-- A category is (finitary) pre-extensive if it has finite coproducts, and binary coproducts are universal. -/ class FinitaryPreExtensive (C : Type u) [Category.{v} C] : Prop where [hasFiniteCoproducts : HasFiniteCoproducts C] [hasPullbacksOfInclusions : HasPullbacksOfInclusions C] /-- In a finitary extensive category, all coproducts are van Kampen-/ universal' : ∀ {X Y : C} (c : BinaryCofan X Y), IsColimit c → IsUniversalColimit c attribute [instance] FinitaryPreExtensive.hasFiniteCoproducts attribute [instance] FinitaryPreExtensive.hasPullbacksOfInclusions /-- A category is (finitary) extensive if it has finite coproducts, and binary coproducts are van Kampen. -/ class FinitaryExtensive (C : Type u) [Category.{v} C] : Prop where [hasFiniteCoproducts : HasFiniteCoproducts C] [hasPullbacksOfInclusions : HasPullbacksOfInclusions C] /-- In a finitary extensive category, all coproducts are van Kampen-/ van_kampen' : ∀ {X Y : C} (c : BinaryCofan X Y), IsColimit c → IsVanKampenColimit c #align category_theory.finitary_extensive CategoryTheory.FinitaryExtensive attribute [instance] FinitaryExtensive.hasFiniteCoproducts attribute [instance] FinitaryExtensive.hasPullbacksOfInclusions
Mathlib/CategoryTheory/Extensive.lean
102
112
theorem FinitaryExtensive.vanKampen [FinitaryExtensive C] {F : Discrete WalkingPair ⥤ C} (c : Cocone F) (hc : IsColimit c) : IsVanKampenColimit c := by
let X := F.obj ⟨WalkingPair.left⟩ let Y := F.obj ⟨WalkingPair.right⟩ have : F = pair X Y := by apply Functor.hext · rintro ⟨⟨⟩⟩ <;> rfl · rintro ⟨⟨⟩⟩ ⟨j⟩ ⟨⟨rfl : _ = j⟩⟩ <;> simp clear_value X Y subst this exact FinitaryExtensive.van_kampen' c hc
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Control.Applicative import Mathlib.Control.Traversable.Basic #align_import control.traversable.lemmas from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" /-! # Traversing collections This file proves basic properties of traversable and applicative functors and defines `PureTransformation F`, the natural applicative transformation from the identity functor to `F`. ## References Inspired by [The Essence of the Iterator Pattern][gibbons2009]. -/ universe u open LawfulTraversable open Function hiding comp open Functor attribute [functor_norm] LawfulTraversable.naturality attribute [simp] LawfulTraversable.id_traverse namespace Traversable variable {t : Type u → Type u} variable [Traversable t] [LawfulTraversable t] variable (F G : Type u → Type u) variable [Applicative F] [LawfulApplicative F] variable [Applicative G] [LawfulApplicative G] variable {α β γ : Type u} variable (g : α → F β) variable (h : β → G γ) variable (f : β → γ) /-- The natural applicative transformation from the identity functor to `F`, defined by `pure : Π {α}, α → F α`. -/ def PureTransformation : ApplicativeTransformation Id F where app := @pure F _ preserves_pure' x := rfl preserves_seq' f x := by simp only [map_pure, seq_pure] rfl #align traversable.pure_transformation Traversable.PureTransformation @[simp] theorem pureTransformation_apply {α} (x : id α) : PureTransformation F x = pure x := rfl #align traversable.pure_transformation_apply Traversable.pureTransformation_apply variable {F G} (x : t β) -- Porting note: need to specify `m/F/G := Id` because `id` no longer has a `Monad` instance theorem map_eq_traverse_id : map (f := t) f = traverse (m := Id) (pure ∘ f) := funext fun y => (traverse_eq_map_id f y).symm #align traversable.map_eq_traverse_id Traversable.map_eq_traverse_id theorem map_traverse (x : t α) : map f <$> traverse g x = traverse (map f ∘ g) x := by rw [map_eq_traverse_id f] refine (comp_traverse (pure ∘ f) g x).symm.trans ?_ congr; apply Comp.applicative_comp_id #align traversable.map_traverse Traversable.map_traverse theorem traverse_map (f : β → F γ) (g : α → β) (x : t α) : traverse f (g <$> x) = traverse (f ∘ g) x := by rw [@map_eq_traverse_id t _ _ _ _ g] refine (comp_traverse (G := Id) f (pure ∘ g) x).symm.trans ?_ congr; apply Comp.applicative_id_comp #align traversable.traverse_map Traversable.traverse_map theorem pure_traverse (x : t α) : traverse pure x = (pure x : F (t α)) := by have : traverse pure x = pure (traverse (m := Id) pure x) := (naturality (PureTransformation F) pure x).symm rwa [id_traverse] at this #align traversable.pure_traverse Traversable.pure_traverse theorem id_sequence (x : t α) : sequence (f := Id) (pure <$> x) = pure x := by simp [sequence, traverse_map, id_traverse] #align traversable.id_sequence Traversable.id_sequence theorem comp_sequence (x : t (F (G α))) : sequence (Comp.mk <$> x) = Comp.mk (sequence <$> sequence x) := by simp only [sequence, traverse_map, id_comp]; rw [← comp_traverse]; simp [map_id] #align traversable.comp_sequence Traversable.comp_sequence theorem naturality' (η : ApplicativeTransformation F G) (x : t (F α)) : η (sequence x) = sequence (@η _ <$> x) := by simp [sequence, naturality, traverse_map] #align traversable.naturality' Traversable.naturality' @[functor_norm]
Mathlib/Control/Traversable/Lemmas.lean
103
105
theorem traverse_id : traverse pure = (pure : t α → Id (t α)) := by
ext exact id_traverse _
/- Copyright (c) 2024 Chris Birkbeck. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Birkbeck -/ import Mathlib.NumberTheory.ModularForms.SlashInvariantForms import Mathlib.NumberTheory.ModularForms.CongruenceSubgroups /-! # Identities of ModularForms and SlashInvariantForms Collection of useful identities of modular forms. -/ noncomputable section open ModularForm UpperHalfPlane Matrix namespace SlashInvariantForm /- TODO: Once we have cusps, do this more generally, same below. -/ theorem vAdd_width_periodic (N : ℕ) (k n : ℤ) (f : SlashInvariantForm (Gamma N) k) (z : ℍ) : f (((N * n) : ℝ) +ᵥ z) = f z := by norm_cast rw [← modular_T_zpow_smul z (N * n)] have Hn := (ModularGroup_T_pow_mem_Gamma N (N * n) (by simp)) simp only [zpow_natCast, Int.natAbs_ofNat] at Hn convert (SlashInvariantForm.slash_action_eqn' k (Gamma N) f ⟨((ModularGroup.T ^ (N * n))), Hn⟩ z) unfold SpecialLinearGroup.coeToGL simp only [Fin.isValue, ModularGroup.coe_T_zpow (N * n), of_apply, cons_val', cons_val_zero, empty_val', cons_val_fin_one, cons_val_one, head_fin_const, Int.cast_zero, zero_mul, head_cons, Int.cast_one, zero_add, one_zpow, one_mul]
Mathlib/NumberTheory/ModularForms/Identities.lean
34
37
theorem T_zpow_width_invariant (N : ℕ) (k n : ℤ) (f : SlashInvariantForm (Gamma N) k) (z : ℍ) : f (((ModularGroup.T ^ (N * n))) • z) = f z := by
rw [modular_T_zpow_smul z (N * n)] simpa only [Int.cast_mul, Int.cast_natCast] using vAdd_width_periodic N k n f z
/- Copyright (c) 2022 Chris Birkbeck. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Birkbeck, David Loeffler -/ import Mathlib.Algebra.Module.Submodule.Basic import Mathlib.Topology.Algebra.Monoid import Mathlib.Analysis.Asymptotics.Asymptotics import Mathlib.Algebra.Algebra.Pi #align_import order.filter.zero_and_bounded_at_filter from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Zero and Bounded at filter Given a filter `l` we define the notion of a function being `ZeroAtFilter` as well as being `BoundedAtFilter`. Alongside this we construct the `Submodule`, `AddSubmonoid` of functions that are `ZeroAtFilter`. Similarly, we construct the `Submodule` and `Subalgebra` of functions that are `BoundedAtFilter`. -/ namespace Filter variable {𝕜 α β : Type*} open Topology /-- If `l` is a filter on `α`, then a function `f : α → β` is `ZeroAtFilter l` if it tends to zero along `l`. -/ def ZeroAtFilter [Zero β] [TopologicalSpace β] (l : Filter α) (f : α → β) : Prop := Filter.Tendsto f l (𝓝 0) #align filter.zero_at_filter Filter.ZeroAtFilter theorem zero_zeroAtFilter [Zero β] [TopologicalSpace β] (l : Filter α) : ZeroAtFilter l (0 : α → β) := tendsto_const_nhds #align filter.zero_zero_at_filter Filter.zero_zeroAtFilter nonrec theorem ZeroAtFilter.add [TopologicalSpace β] [AddZeroClass β] [ContinuousAdd β] {l : Filter α} {f g : α → β} (hf : ZeroAtFilter l f) (hg : ZeroAtFilter l g) : ZeroAtFilter l (f + g) := by simpa using hf.add hg #align filter.zero_at_filter.add Filter.ZeroAtFilter.add nonrec theorem ZeroAtFilter.neg [TopologicalSpace β] [AddGroup β] [ContinuousNeg β] {l : Filter α} {f : α → β} (hf : ZeroAtFilter l f) : ZeroAtFilter l (-f) := by simpa using hf.neg #align filter.zero_at_filter.neg Filter.ZeroAtFilter.neg theorem ZeroAtFilter.smul [TopologicalSpace β] [Zero 𝕜] [Zero β] [SMulWithZero 𝕜 β] [ContinuousConstSMul 𝕜 β] {l : Filter α} {f : α → β} (c : 𝕜) (hf : ZeroAtFilter l f) : ZeroAtFilter l (c • f) := by simpa using hf.const_smul c #align filter.zero_at_filter.smul Filter.ZeroAtFilter.smul variable (𝕜) in /-- `zeroAtFilterSubmodule l` is the submodule of `f : α → β` which tend to zero along `l`. -/ def zeroAtFilterSubmodule [TopologicalSpace β] [Semiring 𝕜] [AddCommMonoid β] [Module 𝕜 β] [ContinuousAdd β] [ContinuousConstSMul 𝕜 β] (l : Filter α) : Submodule 𝕜 (α → β) where carrier := ZeroAtFilter l zero_mem' := zero_zeroAtFilter l add_mem' ha hb := ha.add hb smul_mem' c _ hf := hf.smul c #align filter.zero_at_filter_submodule Filter.zeroAtFilterSubmodule /-- `zeroAtFilterAddSubmonoid l` is the additive submonoid of `f : α → β` which tend to zero along `l`. -/ def zeroAtFilterAddSubmonoid [TopologicalSpace β] [AddZeroClass β] [ContinuousAdd β] (l : Filter α) : AddSubmonoid (α → β) where carrier := ZeroAtFilter l add_mem' ha hb := ha.add hb zero_mem' := zero_zeroAtFilter l #align filter.zero_at_filter_add_submonoid Filter.zeroAtFilterAddSubmonoid /-- If `l` is a filter on `α`, then a function `f: α → β` is `BoundedAtFilter l` if `f =O[l] 1`. -/ def BoundedAtFilter [Norm β] (l : Filter α) (f : α → β) : Prop := Asymptotics.IsBigO l f (1 : α → ℝ) #align filter.bounded_at_filter Filter.BoundedAtFilter
Mathlib/Order/Filter/ZeroAndBoundedAtFilter.lean
84
87
theorem ZeroAtFilter.boundedAtFilter [NormedAddCommGroup β] {l : Filter α} {f : α → β} (hf : ZeroAtFilter l f) : BoundedAtFilter l f := by
rw [ZeroAtFilter, ← Asymptotics.isLittleO_const_iff (one_ne_zero' ℝ)] at hf exact hf.isBigO
/- Copyright (c) 2023 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.ModelTheory.Syntax import Mathlib.ModelTheory.Semantics import Mathlib.ModelTheory.Algebra.Ring.Basic import Mathlib.Algebra.Field.MinimalAxioms /-! # The First Order Theory of Fields This file defines the first order theory of fields as a theory over the language of rings. ## Main definitions * `FirstOrder.Language.Theory.field` : the theory of fields * `FirstOrder.Model.fieldOfModelField` : a model of the theory of fields on a type `K` that already has ring operations. * `FirstOrder.Model.compatibleRingOfModelField` : shows that the ring operations on `K` given by `fieldOfModelField` are compatible with the ring operations on `K` given by the `Language.ring.Structure` instance. -/ variable {K : Type*} namespace FirstOrder namespace Field open Language Ring Structure BoundedFormula /-- An indexing type to name each of the field axioms. The theory of fields is defined as the range of a function `FieldAxiom -> Language.ring.Sentence` -/ inductive FieldAxiom : Type | addAssoc : FieldAxiom | zeroAdd : FieldAxiom | addLeftNeg : FieldAxiom | mulAssoc : FieldAxiom | mulComm : FieldAxiom | oneMul : FieldAxiom | existsInv : FieldAxiom | leftDistrib : FieldAxiom | existsPairNE : FieldAxiom /-- The first order sentence corresponding to each field axiom -/ @[simp] def FieldAxiom.toSentence : FieldAxiom → Language.ring.Sentence | .addAssoc => ∀' ∀' ∀' (((&0 + &1) + &2) =' (&0 + (&1 + &2))) | .zeroAdd => ∀' (((0 : Language.ring.Term _) + &0) =' &0) | .addLeftNeg => ∀' ∀' ((-&0 + &0) =' 0) | .mulAssoc => ∀' ∀' ∀' (((&0 * &1) * &2) =' (&0 * (&1 * &2))) | .mulComm => ∀' ∀' ((&0 * &1) =' (&1 * &0)) | .oneMul => ∀' (((1 : Language.ring.Term _) * &0) =' &0) | .existsInv => ∀' (∼(&0 =' 0) ⟹ ∃' ((&0 * &1) =' 1)) | .leftDistrib => ∀' ∀' ∀' ((&0 * (&1 + &2)) =' ((&0 * &1) + (&0 * &2))) | .existsPairNE => ∃' ∃' (∼(&0 =' &1)) /-- The Proposition corresponding to each field axiom -/ @[simp] def FieldAxiom.toProp (K : Type*) [Add K] [Mul K] [Neg K] [Zero K] [One K] : FieldAxiom → Prop | .addAssoc => ∀ x y z : K, (x + y) + z = x + (y + z) | .zeroAdd => ∀ x : K, 0 + x = x | .addLeftNeg => ∀ x : K, -x + x = 0 | .mulAssoc => ∀ x y z : K, (x * y) * z = x * (y * z) | .mulComm => ∀ x y : K, x * y = y * x | .oneMul => ∀ x : K, 1 * x = x | .existsInv => ∀ x : K, x ≠ 0 → ∃ y, x * y = 1 | .leftDistrib => ∀ x y z : K, x * (y + z) = x * y + x * z | .existsPairNE => ∃ x y : K, x ≠ y /-- The first order theory of fields, as a theory over the language of rings -/ def _root_.FirstOrder.Language.Theory.field : Language.ring.Theory := Set.range FieldAxiom.toSentence
Mathlib/ModelTheory/Algebra/Field/Basic.lean
81
86
theorem FieldAxiom.realize_toSentence_iff_toProp {K : Type*} [Add K] [Mul K] [Neg K] [Zero K] [One K] [CompatibleRing K] (ax : FieldAxiom) : (K ⊨ (ax.toSentence : Sentence Language.ring)) ↔ ax.toProp K := by
cases ax <;> simp [Sentence.Realize, Formula.Realize, Fin.snoc]
/- Copyright (c) 2021 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth, Yury Kudryashov -/ import Mathlib.Topology.Order.Basic #align_import topology.algebra.order.monotone_convergence from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" /-! # Bounded monotone sequences converge In this file we prove a few theorems of the form “if the range of a monotone function `f : ι → α` admits a least upper bound `a`, then `f x` tends to `a` as `x → ∞`”, as well as version of this statement for (conditionally) complete lattices that use `⨆ x, f x` instead of `IsLUB`. These theorems work for linear orders with order topologies as well as their products (both in terms of `Prod` and in terms of function types). In order to reduce code duplication, we introduce two typeclasses (one for the property formulated above and one for the dual property), prove theorems assuming one of these typeclasses, and provide instances for linear orders and their products. We also prove some "inverse" results: if `f n` is a monotone sequence and `a` is its limit, then `f n ≤ a` for all `n`. ## Tags monotone convergence -/ open Filter Set Function open scoped Classical open Filter Topology variable {α β : Type*} /-- We say that `α` is a `SupConvergenceClass` if the following holds. Let `f : ι → α` be a monotone function, let `a : α` be a least upper bound of `Set.range f`. Then `f x` tends to `𝓝 a` as `x → ∞` (formally, at the filter `Filter.atTop`). We require this for `ι = (s : Set α)`, `f = CoeTC.coe` in the definition, then prove it for any `f` in `tendsto_atTop_isLUB`. This property holds for linear orders with order topology as well as their products. -/ class SupConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where /-- proof that a monotone function tends to `𝓝 a` as `x → ∞` -/ tendsto_coe_atTop_isLUB : ∀ (a : α) (s : Set α), IsLUB s a → Tendsto (CoeTC.coe : s → α) atTop (𝓝 a) #align Sup_convergence_class SupConvergenceClass /-- We say that `α` is an `InfConvergenceClass` if the following holds. Let `f : ι → α` be a monotone function, let `a : α` be a greatest lower bound of `Set.range f`. Then `f x` tends to `𝓝 a` as `x → -∞` (formally, at the filter `Filter.atBot`). We require this for `ι = (s : Set α)`, `f = CoeTC.coe` in the definition, then prove it for any `f` in `tendsto_atBot_isGLB`. This property holds for linear orders with order topology as well as their products. -/ class InfConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where /-- proof that a monotone function tends to `𝓝 a` as `x → -∞`-/ tendsto_coe_atBot_isGLB : ∀ (a : α) (s : Set α), IsGLB s a → Tendsto (CoeTC.coe : s → α) atBot (𝓝 a) #align Inf_convergence_class InfConvergenceClass instance OrderDual.supConvergenceClass [Preorder α] [TopologicalSpace α] [InfConvergenceClass α] : SupConvergenceClass αᵒᵈ := ⟨‹InfConvergenceClass α›.1⟩ #align order_dual.Sup_convergence_class OrderDual.supConvergenceClass instance OrderDual.infConvergenceClass [Preorder α] [TopologicalSpace α] [SupConvergenceClass α] : InfConvergenceClass αᵒᵈ := ⟨‹SupConvergenceClass α›.1⟩ #align order_dual.Inf_convergence_class OrderDual.infConvergenceClass -- see Note [lower instance priority] instance (priority := 100) LinearOrder.supConvergenceClass [TopologicalSpace α] [LinearOrder α] [OrderTopology α] : SupConvergenceClass α := by refine ⟨fun a s ha => tendsto_order.2 ⟨fun b hb => ?_, fun b hb => ?_⟩⟩ · rcases ha.exists_between hb with ⟨c, hcs, bc, bca⟩ lift c to s using hcs exact (eventually_ge_atTop c).mono fun x hx => bc.trans_le hx · exact eventually_of_forall fun x => (ha.1 x.2).trans_lt hb #align linear_order.Sup_convergence_class LinearOrder.supConvergenceClass -- see Note [lower instance priority] instance (priority := 100) LinearOrder.infConvergenceClass [TopologicalSpace α] [LinearOrder α] [OrderTopology α] : InfConvergenceClass α := show InfConvergenceClass αᵒᵈᵒᵈ from OrderDual.infConvergenceClass #align linear_order.Inf_convergence_class LinearOrder.infConvergenceClass section variable {ι : Type*} [Preorder ι] [TopologicalSpace α] section IsLUB variable [Preorder α] [SupConvergenceClass α] {f : ι → α} {a : α}
Mathlib/Topology/Order/MonotoneConvergence.lean
96
100
theorem tendsto_atTop_isLUB (h_mono : Monotone f) (ha : IsLUB (Set.range f) a) : Tendsto f atTop (𝓝 a) := by
suffices Tendsto (rangeFactorization f) atTop atTop from (SupConvergenceClass.tendsto_coe_atTop_isLUB _ _ ha).comp this exact h_mono.rangeFactorization.tendsto_atTop_atTop fun b => b.2.imp fun a ha => ha.ge
/- Copyright (c) 2019 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Scott Morrison -/ import Mathlib.Algebra.Order.Hom.Monoid import Mathlib.SetTheory.Game.Ordinal #align_import set_theory.surreal.basic from "leanprover-community/mathlib"@"8900d545017cd21961daa2a1734bb658ef52c618" /-! # Surreal numbers The basic theory of surreal numbers, built on top of the theory of combinatorial (pre-)games. A pregame is `Numeric` if all the Left options are strictly smaller than all the Right options, and all those options are themselves numeric. In terms of combinatorial games, the numeric games have "frozen"; you can only make your position worse by playing, and Left is some definite "number" of moves ahead (or behind) Right. A surreal number is an equivalence class of numeric pregames. In fact, the surreals form a complete ordered field, containing a copy of the reals (and much else besides!) but we do not yet have a complete development. ## Order properties Surreal numbers inherit the relations `≤` and `<` from games (`Surreal.instLE` and `Surreal.instLT`), and these relations satisfy the axioms of a partial order. ## Algebraic operations We show that the surreals form a linear ordered commutative group. One can also map all the ordinals into the surreals! ### Multiplication of surreal numbers The proof that multiplication lifts to surreal numbers is surprisingly difficult and is currently missing in the library. A sample proof can be found in Theorem 3.8 in the second reference below. The difficulty lies in the length of the proof and the number of theorems that need to proven simultaneously. This will make for a fun and challenging project. The branch `surreal_mul` contains some progress on this proof. ### Todo - Define the field structure on the surreals. ## References * [Conway, *On numbers and games*][conway2001] * [Schleicher, Stoll, *An introduction to Conway's games and numbers*][schleicher_stoll] -/ universe u namespace SetTheory open scoped PGame namespace PGame /-- A pre-game is numeric if everything in the L set is less than everything in the R set, and all the elements of L and R are also numeric. -/ def Numeric : PGame → Prop | ⟨_, _, L, R⟩ => (∀ i j, L i < R j) ∧ (∀ i, Numeric (L i)) ∧ ∀ j, Numeric (R j) #align pgame.numeric SetTheory.PGame.Numeric
Mathlib/SetTheory/Surreal/Basic.lean
71
75
theorem numeric_def {x : PGame} : Numeric x ↔ (∀ i j, x.moveLeft i < x.moveRight j) ∧ (∀ i, Numeric (x.moveLeft i)) ∧ ∀ j, Numeric (x.moveRight j) := by
cases x; rfl
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Topology.Compactness.Compact /-! # Locally compact spaces We define the following classes of topological spaces: * `WeaklyLocallyCompactSpace`: every point `x` has a compact neighborhood. * `LocallyCompactSpace`: for every point `x`, every open neighborhood of `x` contains a compact neighborhood of `x`. The definition is formulated in terms of the neighborhood filter. -/ open Set Filter Topology TopologicalSpace Classical variable {X : Type*} {Y : Type*} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} instance [WeaklyLocallyCompactSpace X] [WeaklyLocallyCompactSpace Y] : WeaklyLocallyCompactSpace (X × Y) where exists_compact_mem_nhds x := let ⟨s₁, hc₁, h₁⟩ := exists_compact_mem_nhds x.1 let ⟨s₂, hc₂, h₂⟩ := exists_compact_mem_nhds x.2 ⟨s₁ ×ˢ s₂, hc₁.prod hc₂, prod_mem_nhds h₁ h₂⟩ instance {ι : Type*} [Finite ι] {X : ι → Type*} [(i : ι) → TopologicalSpace (X i)] [(i : ι) → WeaklyLocallyCompactSpace (X i)] : WeaklyLocallyCompactSpace ((i : ι) → X i) where exists_compact_mem_nhds := fun f ↦ by choose s hsc hs using fun i ↦ exists_compact_mem_nhds (f i) exact ⟨pi univ s, isCompact_univ_pi hsc, set_pi_mem_nhds univ.toFinite fun i _ ↦ hs i⟩ instance (priority := 100) [CompactSpace X] : WeaklyLocallyCompactSpace X where exists_compact_mem_nhds _ := ⟨univ, isCompact_univ, univ_mem⟩ /-- In a weakly locally compact space, every compact set is contained in the interior of a compact set. -/
Mathlib/Topology/Compactness/LocallyCompact.lean
40
45
theorem exists_compact_superset [WeaklyLocallyCompactSpace X] {K : Set X} (hK : IsCompact K) : ∃ K', IsCompact K' ∧ K ⊆ interior K' := by
choose s hc hmem using fun x : X ↦ exists_compact_mem_nhds x rcases hK.elim_nhds_subcover _ fun x _ ↦ interior_mem_nhds.2 (hmem x) with ⟨I, -, hIK⟩ refine ⟨⋃ x ∈ I, s x, I.isCompact_biUnion fun _ _ ↦ hc _, hIK.trans ?_⟩ exact iUnion₂_subset fun x hx ↦ interior_mono <| subset_iUnion₂ (s := fun x _ ↦ s x) x hx
/- 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.Init.Function import Mathlib.Logic.Function.Basic #align_import data.sigma.basic from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64" /-! # Sigma types This file proves basic results about sigma types. A sigma type is a dependent pair type. Like `α × β` but where the type of the second component depends on the first component. More precisely, given `β : ι → Type*`, `Sigma β` is made of stuff which is of type `β i` for some `i : ι`, so the sigma type is a disjoint union of types. For example, the sum type `X ⊕ Y` can be emulated using a sigma type, by taking `ι` with exactly two elements (see `Equiv.sumEquivSigmaBool`). `Σ x, A x` is notation for `Sigma A` (note that this is `\Sigma`, not the sum operator `∑`). `Σ x y z ..., A x y z ...` is notation for `Σ x, Σ y, Σ z, ..., A x y z ...`. Here we have `α : Type*`, `β : α → Type*`, `γ : Π a : α, β a → Type*`, ..., `A : Π (a : α) (b : β a) (c : γ a b) ..., Type*` with `x : α` `y : β x`, `z : γ x y`, ... ## Notes The definition of `Sigma` takes values in `Type*`. This effectively forbids `Prop`- valued sigma types. To that effect, we have `PSigma`, which takes value in `Sort*` and carries a more complicated universe signature as a consequence. -/ open Function section Sigma variable {α α₁ α₂ : Type*} {β : α → Type*} {β₁ : α₁ → Type*} {β₂ : α₂ → Type*} namespace Sigma instance instInhabitedSigma [Inhabited α] [Inhabited (β default)] : Inhabited (Sigma β) := ⟨⟨default, default⟩⟩ instance instDecidableEqSigma [h₁ : DecidableEq α] [h₂ : ∀ a, DecidableEq (β a)] : DecidableEq (Sigma β) | ⟨a₁, b₁⟩, ⟨a₂, b₂⟩ => match a₁, b₁, a₂, b₂, h₁ a₁ a₂ with | _, b₁, _, b₂, isTrue (Eq.refl _) => match b₁, b₂, h₂ _ b₁ b₂ with | _, _, isTrue (Eq.refl _) => isTrue rfl | _, _, isFalse n => isFalse fun h ↦ Sigma.noConfusion h fun _ e₂ ↦ n <| eq_of_heq e₂ | _, _, _, _, isFalse n => isFalse fun h ↦ Sigma.noConfusion h fun e₁ _ ↦ n e₁ -- sometimes the built-in injectivity support does not work @[simp] -- @[nolint simpNF] theorem mk.inj_iff {a₁ a₂ : α} {b₁ : β a₁} {b₂ : β a₂} : Sigma.mk a₁ b₁ = ⟨a₂, b₂⟩ ↔ a₁ = a₂ ∧ HEq b₁ b₂ := ⟨fun h ↦ by cases h; simp, fun ⟨h₁, h₂⟩ ↦ by subst h₁; rw [eq_of_heq h₂]⟩ #align sigma.mk.inj_iff Sigma.mk.inj_iff @[simp] theorem eta : ∀ x : Σa, β a, Sigma.mk x.1 x.2 = x | ⟨_, _⟩ => rfl #align sigma.eta Sigma.eta #align sigma.ext Sigma.ext
Mathlib/Data/Sigma/Basic.lean
70
71
theorem ext_iff {x₀ x₁ : Sigma β} : x₀ = x₁ ↔ x₀.1 = x₁.1 ∧ HEq x₀.2 x₁.2 := by
cases x₀; cases x₁; exact Sigma.mk.inj_iff
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel, Rémy Degenne, David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.Pow.Complex import Qq #align_import analysis.special_functions.pow.real from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" /-! # Power function on `ℝ` We construct the power functions `x ^ y`, where `x` and `y` are real numbers. -/ noncomputable section open scoped Classical open Real ComplexConjugate open Finset Set /- ## Definitions -/ namespace Real variable {x y z : ℝ} /-- The real power function `x ^ y`, defined as the real part of the complex power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for `y ≠ 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (π y)`. -/ noncomputable def rpow (x y : ℝ) := ((x : ℂ) ^ (y : ℂ)).re #align real.rpow Real.rpow noncomputable instance : Pow ℝ ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x y : ℝ) : rpow x y = x ^ y := rfl #align real.rpow_eq_pow Real.rpow_eq_pow theorem rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl #align real.rpow_def Real.rpow_def theorem rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by simp only [rpow_def, Complex.cpow_def]; split_ifs <;> simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul, -RCLike.ofReal_mul, (Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero] #align real.rpow_def_of_nonneg Real.rpow_def_of_nonneg theorem rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) := by rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)] #align real.rpow_def_of_pos Real.rpow_def_of_pos theorem exp_mul (x y : ℝ) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp] #align real.exp_mul Real.exp_mul @[simp, norm_cast] theorem rpow_intCast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by simp only [rpow_def, ← Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast, Complex.ofReal_re] #align real.rpow_int_cast Real.rpow_intCast @[deprecated (since := "2024-04-17")] alias rpow_int_cast := rpow_intCast @[simp, norm_cast] theorem rpow_natCast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by simpa using rpow_intCast x n #align real.rpow_nat_cast Real.rpow_natCast @[deprecated (since := "2024-04-17")] alias rpow_nat_cast := rpow_natCast @[simp] theorem exp_one_rpow (x : ℝ) : exp 1 ^ x = exp x := by rw [← exp_mul, one_mul] #align real.exp_one_rpow Real.exp_one_rpow @[simp] lemma exp_one_pow (n : ℕ) : exp 1 ^ n = exp n := by rw [← rpow_natCast, exp_one_rpow] theorem rpow_eq_zero_iff_of_nonneg (hx : 0 ≤ x) : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by simp only [rpow_def_of_nonneg hx] split_ifs <;> simp [*, exp_ne_zero] #align real.rpow_eq_zero_iff_of_nonneg Real.rpow_eq_zero_iff_of_nonneg @[simp] lemma rpow_eq_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y = 0 ↔ x = 0 := by simp [rpow_eq_zero_iff_of_nonneg, *] @[simp] lemma rpow_ne_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y ≠ 0 ↔ x ≠ 0 := Real.rpow_eq_zero hx hy |>.not open Real theorem rpow_def_of_neg {x : ℝ} (hx : x < 0) (y : ℝ) : x ^ y = exp (log x * y) * cos (y * π) := by rw [rpow_def, Complex.cpow_def, if_neg] · have : Complex.log x * y = ↑(log (-x) * y) + ↑(y * π) * Complex.I := by simp only [Complex.log, abs_of_neg hx, Complex.arg_ofReal_of_neg hx, Complex.abs_ofReal, Complex.ofReal_mul] ring rw [this, Complex.exp_add_mul_I, ← Complex.ofReal_exp, ← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ← mul_assoc, ← Complex.ofReal_mul, Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im, Real.log_neg_eq_log] ring · rw [Complex.ofReal_eq_zero] exact ne_of_lt hx #align real.rpow_def_of_neg Real.rpow_def_of_neg
Mathlib/Analysis/SpecialFunctions/Pow/Real.lean
115
117
theorem rpow_def_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) * cos (y * π) := by
split_ifs with h <;> simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Limits.Shapes.CommSq import Mathlib.CategoryTheory.Limits.Shapes.StrictInitial import Mathlib.CategoryTheory.Limits.FunctorCategory import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts #align_import category_theory.extensive from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" /-! # Universal colimits and van Kampen colimits ## Main definitions - `CategoryTheory.IsUniversalColimit`: A (colimit) cocone over a diagram `F : J ⥤ C` is universal if it is stable under pullbacks. - `CategoryTheory.IsVanKampenColimit`: A (colimit) cocone over a diagram `F : J ⥤ C` is van Kampen if for every cocone `c'` over the pullback of the diagram `F' : J ⥤ C'`, `c'` is colimiting iff `c'` is the pullback of `c`. ## References - https://ncatlab.org/nlab/show/van+Kampen+colimit - [Stephen Lack and Paweł Sobociński, Adhesive Categories][adhesive2004] -/ open CategoryTheory.Limits namespace CategoryTheory universe v' u' v u variable {J : Type v'} [Category.{u'} J] {C : Type u} [Category.{v} C] variable {K : Type*} [Category K] {D : Type*} [Category D] section NatTrans /-- A natural transformation is equifibered if every commutative square of the following form is a pullback. ``` F(X) → F(Y) ↓ ↓ G(X) → G(Y) ``` -/ def NatTrans.Equifibered {F G : J ⥤ C} (α : F ⟶ G) : Prop := ∀ ⦃i j : J⦄ (f : i ⟶ j), IsPullback (F.map f) (α.app i) (α.app j) (G.map f) #align category_theory.nat_trans.equifibered CategoryTheory.NatTrans.Equifibered theorem NatTrans.equifibered_of_isIso {F G : J ⥤ C} (α : F ⟶ G) [IsIso α] : Equifibered α := fun _ _ f => IsPullback.of_vert_isIso ⟨NatTrans.naturality _ f⟩ #align category_theory.nat_trans.equifibered_of_is_iso CategoryTheory.NatTrans.equifibered_of_isIso theorem NatTrans.Equifibered.comp {F G H : J ⥤ C} {α : F ⟶ G} {β : G ⟶ H} (hα : Equifibered α) (hβ : Equifibered β) : Equifibered (α ≫ β) := fun _ _ f => (hα f).paste_vert (hβ f) #align category_theory.nat_trans.equifibered.comp CategoryTheory.NatTrans.Equifibered.comp theorem NatTrans.Equifibered.whiskerRight {F G : J ⥤ C} {α : F ⟶ G} (hα : Equifibered α) (H : C ⥤ D) [∀ (i j : J) (f : j ⟶ i), PreservesLimit (cospan (α.app i) (G.map f)) H] : Equifibered (whiskerRight α H) := fun _ _ f => (hα f).map H #align category_theory.nat_trans.equifibered.whisker_right CategoryTheory.NatTrans.Equifibered.whiskerRight theorem NatTrans.Equifibered.whiskerLeft {K : Type*} [Category K] {F G : J ⥤ C} {α : F ⟶ G} (hα : Equifibered α) (H : K ⥤ J) : Equifibered (whiskerLeft H α) := fun _ _ f => hα (H.map f)
Mathlib/CategoryTheory/Limits/VanKampen.lean
75
80
theorem mapPair_equifibered {F F' : Discrete WalkingPair ⥤ C} (α : F ⟶ F') : NatTrans.Equifibered α := by
rintro ⟨⟨⟩⟩ ⟨j⟩ ⟨⟨rfl : _ = j⟩⟩ all_goals dsimp; simp only [Discrete.functor_map_id] exact IsPullback.of_horiz_isIso ⟨by simp only [Category.comp_id, Category.id_comp]⟩
/- Copyright (c) 2022 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz -/ import Mathlib.LinearAlgebra.FiniteDimensional #align_import linear_algebra.projective_space.basic from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23" /-! # Projective Spaces This file contains the definition of the projectivization of a vector space over a field, as well as the bijection between said projectivization and the collection of all one dimensional subspaces of the vector space. ## Notation `ℙ K V` is localized notation for `Projectivization K V`, the projectivization of a `K`-vector space `V`. ## Constructing terms of `ℙ K V`. We have three ways to construct terms of `ℙ K V`: - `Projectivization.mk K v hv` where `v : V` and `hv : v ≠ 0`. - `Projectivization.mk' K v` where `v : { w : V // w ≠ 0 }`. - `Projectivization.mk'' H h` where `H : Submodule K V` and `h : finrank H = 1`. ## Other definitions - For `v : ℙ K V`, `v.submodule` gives the corresponding submodule of `V`. - `Projectivization.equivSubmodule` is the equivalence between `ℙ K V` and `{ H : Submodule K V // finrank H = 1 }`. - For `v : ℙ K V`, `v.rep : V` is a representative of `v`. -/ variable (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V] /-- The setoid whose quotient is the projectivization of `V`. -/ def projectivizationSetoid : Setoid { v : V // v ≠ 0 } := (MulAction.orbitRel Kˣ V).comap (↑) #align projectivization_setoid projectivizationSetoid /-- The projectivization of the `K`-vector space `V`. The notation `ℙ K V` is preferred. -/ def Projectivization := Quotient (projectivizationSetoid K V) #align projectivization Projectivization /-- We define notations `ℙ K V` for the projectivization of the `K`-vector space `V`. -/ scoped[LinearAlgebra.Projectivization] notation "ℙ" => Projectivization namespace Projectivization open scoped LinearAlgebra.Projectivization variable {V} /-- Construct an element of the projectivization from a nonzero vector. -/ def mk (v : V) (hv : v ≠ 0) : ℙ K V := Quotient.mk'' ⟨v, hv⟩ #align projectivization.mk Projectivization.mk /-- A variant of `Projectivization.mk` in terms of a subtype. `mk` is preferred. -/ def mk' (v : { v : V // v ≠ 0 }) : ℙ K V := Quotient.mk'' v #align projectivization.mk' Projectivization.mk' @[simp] theorem mk'_eq_mk (v : { v : V // v ≠ 0 }) : mk' K v = mk K ↑v v.2 := rfl #align projectivization.mk'_eq_mk Projectivization.mk'_eq_mk instance [Nontrivial V] : Nonempty (ℙ K V) := let ⟨v, hv⟩ := exists_ne (0 : V) ⟨mk K v hv⟩ variable {K} /-- Choose a representative of `v : Projectivization K V` in `V`. -/ protected noncomputable def rep (v : ℙ K V) : V := v.out' #align projectivization.rep Projectivization.rep theorem rep_nonzero (v : ℙ K V) : v.rep ≠ 0 := v.out'.2 #align projectivization.rep_nonzero Projectivization.rep_nonzero @[simp] theorem mk_rep (v : ℙ K V) : mk K v.rep v.rep_nonzero = v := Quotient.out_eq' _ #align projectivization.mk_rep Projectivization.mk_rep open FiniteDimensional /-- Consider an element of the projectivization as a submodule of `V`. -/ protected def submodule (v : ℙ K V) : Submodule K V := (Quotient.liftOn' v fun v => K ∙ (v : V)) <| by rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨x, rfl : x • b = a⟩ exact Submodule.span_singleton_group_smul_eq _ x _ #align projectivization.submodule Projectivization.submodule variable (K) theorem mk_eq_mk_iff (v w : V) (hv : v ≠ 0) (hw : w ≠ 0) : mk K v hv = mk K w hw ↔ ∃ a : Kˣ, a • w = v := Quotient.eq'' #align projectivization.mk_eq_mk_iff Projectivization.mk_eq_mk_iff /-- Two nonzero vectors go to the same point in projective space if and only if one is a scalar multiple of the other. -/ theorem mk_eq_mk_iff' (v w : V) (hv : v ≠ 0) (hw : w ≠ 0) : mk K v hv = mk K w hw ↔ ∃ a : K, a • w = v := by rw [mk_eq_mk_iff K v w hv hw] constructor · rintro ⟨a, ha⟩ exact ⟨a, ha⟩ · rintro ⟨a, ha⟩ refine ⟨Units.mk0 a fun c => hv.symm ?_, ha⟩ rwa [c, zero_smul] at ha #align projectivization.mk_eq_mk_iff' Projectivization.mk_eq_mk_iff' theorem exists_smul_eq_mk_rep (v : V) (hv : v ≠ 0) : ∃ a : Kˣ, a • v = (mk K v hv).rep := (mk_eq_mk_iff K _ _ (rep_nonzero _) hv).1 (mk_rep _) #align projectivization.exists_smul_eq_mk_rep Projectivization.exists_smul_eq_mk_rep variable {K} /-- An induction principle for `Projectivization`. Use as `induction v using Projectivization.ind`. -/ @[elab_as_elim] theorem ind {P : ℙ K V → Prop} (h : ∀ (v : V) (h : v ≠ 0), P (mk K v h)) : ∀ p, P p := Quotient.ind' <| Subtype.rec <| h #align projectivization.ind Projectivization.ind @[simp] theorem submodule_mk (v : V) (hv : v ≠ 0) : (mk K v hv).submodule = K ∙ v := rfl #align projectivization.submodule_mk Projectivization.submodule_mk
Mathlib/LinearAlgebra/Projectivization/Basic.lean
137
139
theorem submodule_eq (v : ℙ K V) : v.submodule = K ∙ v.rep := by
conv_lhs => rw [← v.mk_rep] rfl
/- Copyright (c) 2021 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Algebra.Group.Submonoid.Pointwise #align_import group_theory.submonoid.inverses from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Submonoid of inverses Given a submonoid `N` of a monoid `M`, we define the submonoid `N.leftInv` as the submonoid of left inverses of `N`. When `M` is commutative, we may define `fromCommLeftInv : N.leftInv →* N` since the inverses are unique. When `N ≤ IsUnit.Submonoid M`, this is precisely the pointwise inverse of `N`, and we may define `leftInvEquiv : S.leftInv ≃* S`. For the pointwise inverse of submonoids of groups, please refer to the file `Mathlib.Algebra.Group.Submonoid.Pointwise`. `N.leftInv` is distinct from `N.units`, which is the subgroup of `Mˣ` containing all units that are in `N`. See the implementation notes of `Mathlib.GroupTheory.Submonoid.Units` for more details on related constructions. ## TODO Define the submonoid of right inverses and two-sided inverses. See the comments of #10679 for a possible implementation. -/ variable {M : Type*} namespace Submonoid @[to_additive] noncomputable instance [Monoid M] : Group (IsUnit.submonoid M) := { inferInstanceAs (Monoid (IsUnit.submonoid M)) with inv := fun x ↦ ⟨x.prop.unit⁻¹.val, x.prop.unit⁻¹.isUnit⟩ mul_left_inv := fun x ↦ Subtype.ext ((Units.val_mul x.prop.unit⁻¹ _).trans x.prop.unit.inv_val) } @[to_additive] noncomputable instance [CommMonoid M] : CommGroup (IsUnit.submonoid M) := { inferInstanceAs (Group (IsUnit.submonoid M)) with mul_comm := fun a b ↦ by convert mul_comm a b } @[to_additive] theorem IsUnit.Submonoid.coe_inv [Monoid M] (x : IsUnit.submonoid M) : ↑x⁻¹ = (↑x.prop.unit⁻¹ : M) := rfl #align submonoid.is_unit.submonoid.coe_inv Submonoid.IsUnit.Submonoid.coe_inv #align add_submonoid.is_unit.submonoid.coe_neg AddSubmonoid.IsUnit.Submonoid.coe_neg section Monoid variable [Monoid M] (S : Submonoid M) /-- `S.leftInv` is the submonoid containing all the left inverses of `S`. -/ @[to_additive "`S.leftNeg` is the additive submonoid containing all the left additive inverses of `S`."] def leftInv : Submonoid M where carrier := { x : M | ∃ y : S, x * y = 1 } one_mem' := ⟨1, mul_one 1⟩ mul_mem' := fun {a} _b ⟨a', ha⟩ ⟨b', hb⟩ ↦ ⟨b' * a', by simp only [coe_mul, ← mul_assoc, mul_assoc a, hb, mul_one, ha]⟩ #align submonoid.left_inv Submonoid.leftInv #align add_submonoid.left_neg AddSubmonoid.leftNeg @[to_additive]
Mathlib/GroupTheory/Submonoid/Inverses.lean
73
76
theorem leftInv_leftInv_le : S.leftInv.leftInv ≤ S := by
rintro x ⟨⟨y, z, h₁⟩, h₂ : x * y = 1⟩ convert z.prop rw [← mul_one x, ← h₁, ← mul_assoc, h₂, one_mul]
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.CategoryTheory.Idempotents.Basic import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.CategoryTheory.Equivalence #align_import category_theory.idempotents.karoubi from "leanprover-community/mathlib"@"200eda15d8ff5669854ff6bcc10aaf37cb70498f" /-! # The Karoubi envelope of a category In this file, we define the Karoubi envelope `Karoubi C` of a category `C`. ## Main constructions and definitions - `Karoubi C` is the Karoubi envelope of a category `C`: it is an idempotent complete category. It is also preadditive when `C` is preadditive. - `toKaroubi C : C ⥤ Karoubi C` is a fully faithful functor, which is an equivalence (`toKaroubiIsEquivalence`) when `C` is idempotent complete. -/ noncomputable section open CategoryTheory.Category CategoryTheory.Preadditive CategoryTheory.Limits BigOperators namespace CategoryTheory variable (C : Type*) [Category C] namespace Idempotents -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- In a preadditive category `C`, when an object `X` decomposes as `X ≅ P ⨿ Q`, one may consider `P` as a direct factor of `X` and up to unique isomorphism, it is determined by the obvious idempotent `X ⟶ P ⟶ X` which is the projection onto `P` with kernel `Q`. More generally, one may define a formal direct factor of an object `X : C` : it consists of an idempotent `p : X ⟶ X` which is thought as the "formal image" of `p`. The type `Karoubi C` shall be the type of the objects of the karoubi envelope of `C`. It makes sense for any category `C`. -/ structure Karoubi where /-- an object of the underlying category -/ X : C /-- an endomorphism of the object -/ p : X ⟶ X /-- the condition that the given endomorphism is an idempotent -/ idem : p ≫ p = p := by aesop_cat #align category_theory.idempotents.karoubi CategoryTheory.Idempotents.Karoubi namespace Karoubi variable {C} attribute [reassoc (attr := simp)] idem @[ext] theorem ext {P Q : Karoubi C} (h_X : P.X = Q.X) (h_p : P.p ≫ eqToHom h_X = eqToHom h_X ≫ Q.p) : P = Q := by cases P cases Q dsimp at h_X h_p subst h_X simpa only [mk.injEq, heq_eq_eq, true_and, eqToHom_refl, comp_id, id_comp] using h_p #align category_theory.idempotents.karoubi.ext CategoryTheory.Idempotents.Karoubi.ext /-- A morphism `P ⟶ Q` in the category `Karoubi C` is a morphism in the underlying category `C` which satisfies a relation, which in the preadditive case, expresses that it induces a map between the corresponding "formal direct factors" and that it vanishes on the complement formal direct factor. -/ @[ext] structure Hom (P Q : Karoubi C) where /-- a morphism between the underlying objects -/ f : P.X ⟶ Q.X /-- compatibility of the given morphism with the given idempotents -/ comm : f = P.p ≫ f ≫ Q.p := by aesop_cat #align category_theory.idempotents.karoubi.hom CategoryTheory.Idempotents.Karoubi.Hom instance [Preadditive C] (P Q : Karoubi C) : Inhabited (Hom P Q) := ⟨⟨0, by rw [zero_comp, comp_zero]⟩⟩ @[reassoc (attr := simp)] theorem p_comp {P Q : Karoubi C} (f : Hom P Q) : P.p ≫ f.f = f.f := by rw [f.comm, ← assoc, P.idem] #align category_theory.idempotents.karoubi.p_comp CategoryTheory.Idempotents.Karoubi.p_comp @[reassoc (attr := simp)] theorem comp_p {P Q : Karoubi C} (f : Hom P Q) : f.f ≫ Q.p = f.f := by rw [f.comm, assoc, assoc, Q.idem] #align category_theory.idempotents.karoubi.comp_p CategoryTheory.Idempotents.Karoubi.comp_p @[reassoc]
Mathlib/CategoryTheory/Idempotents/Karoubi.lean
94
94
theorem p_comm {P Q : Karoubi C} (f : Hom P Q) : P.p ≫ f.f = f.f ≫ Q.p := by
rw [p_comp, comp_p]
/- Copyright (c) 2022 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp, Mohanad Ahmed -/ import Mathlib.LinearAlgebra.Matrix.Spectrum import Mathlib.LinearAlgebra.QuadraticForm.Basic #align_import linear_algebra.matrix.pos_def from "leanprover-community/mathlib"@"07992a1d1f7a4176c6d3f160209608be4e198566" /-! # Positive Definite Matrices This file defines positive (semi)definite matrices and connects the notion to positive definiteness of quadratic forms. Most results require `𝕜 = ℝ` or `ℂ`. ## Main definitions * `Matrix.PosDef` : a matrix `M : Matrix n n 𝕜` is positive definite if it is hermitian and `xᴴMx` is greater than zero for all nonzero `x`. * `Matrix.PosSemidef` : a matrix `M : Matrix n n 𝕜` is positive semidefinite if it is hermitian and `xᴴMx` is nonnegative for all `x`. ## Main results * `Matrix.posSemidef_iff_eq_transpose_mul_self` : a matrix `M : Matrix n n 𝕜` is positive semidefinite iff it has the form `Bᴴ * B` for some `B`. * `Matrix.PosSemidef.sqrt` : the unique positive semidefinite square root of a positive semidefinite matrix. (See `Matrix.PosSemidef.eq_sqrt_of_sq_eq` for the proof of uniqueness.) -/ open scoped ComplexOrder namespace Matrix variable {m n R 𝕜 : Type*} variable [Fintype m] [Fintype n] variable [CommRing R] [PartialOrder R] [StarRing R] [StarOrderedRing R] variable [RCLike 𝕜] open scoped Matrix /-! ## Positive semidefinite matrices -/ /-- A matrix `M : Matrix n n R` is positive semidefinite if it is Hermitian and `xᴴ * M * x` is nonnegative for all `x`. -/ def PosSemidef (M : Matrix n n R) := M.IsHermitian ∧ ∀ x : n → R, 0 ≤ dotProduct (star x) (M *ᵥ x) #align matrix.pos_semidef Matrix.PosSemidef /-- A diagonal matrix is positive semidefinite iff its diagonal entries are nonnegative. -/ lemma posSemidef_diagonal_iff [DecidableEq n] {d : n → R} : PosSemidef (diagonal d) ↔ (∀ i : n, 0 ≤ d i) := by refine ⟨fun ⟨_, hP⟩ i ↦ by simpa using hP (Pi.single i 1), ?_⟩ refine fun hd ↦ ⟨isHermitian_diagonal_iff.2 fun i ↦ IsSelfAdjoint.of_nonneg (hd i), ?_⟩ refine fun x ↦ Finset.sum_nonneg fun i _ ↦ ?_ simpa only [mulVec_diagonal, mul_assoc] using conjugate_nonneg (hd i) _ namespace PosSemidef theorem isHermitian {M : Matrix n n R} (hM : M.PosSemidef) : M.IsHermitian := hM.1 theorem re_dotProduct_nonneg {M : Matrix n n 𝕜} (hM : M.PosSemidef) (x : n → 𝕜) : 0 ≤ RCLike.re (dotProduct (star x) (M *ᵥ x)) := RCLike.nonneg_iff.mp (hM.2 _) |>.1 lemma conjTranspose_mul_mul_same {A : Matrix n n R} (hA : PosSemidef A) {m : Type*} [Fintype m] (B : Matrix n m R) : PosSemidef (Bᴴ * A * B) := by constructor · exact isHermitian_conjTranspose_mul_mul B hA.1 · intro x simpa only [star_mulVec, dotProduct_mulVec, vecMul_vecMul] using hA.2 (B *ᵥ x) lemma mul_mul_conjTranspose_same {A : Matrix n n R} (hA : PosSemidef A) {m : Type*} [Fintype m] (B : Matrix m n R): PosSemidef (B * A * Bᴴ) := by simpa only [conjTranspose_conjTranspose] using hA.conjTranspose_mul_mul_same Bᴴ
Mathlib/LinearAlgebra/Matrix/PosDef.lean
81
87
theorem submatrix {M : Matrix n n R} (hM : M.PosSemidef) (e : m → n) : (M.submatrix e e).PosSemidef := by
classical rw [(by simp : M = 1 * M * 1), submatrix_mul (he₂ := Function.bijective_id), submatrix_mul (he₂ := Function.bijective_id), submatrix_id_id] simpa only [conjTranspose_submatrix, conjTranspose_one] using conjTranspose_mul_mul_same hM (Matrix.submatrix 1 id e)
/- 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.Control.EquivFunctor import Mathlib.CategoryTheory.Groupoid import Mathlib.CategoryTheory.Whiskering import Mathlib.CategoryTheory.Types #align_import category_theory.core from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768" /-! # The core of a category The core of a category `C` is the (non-full) subcategory of `C` consisting of all objects, and all isomorphisms. We construct it as a `CategoryTheory.Groupoid`. `CategoryTheory.Core.inclusion : Core C ⥤ C` gives the faithful inclusion into the original category. Any functor `F` from a groupoid `G` into `C` factors through `CategoryTheory.Core C`, but this is not functorial with respect to `F`. -/ namespace CategoryTheory universe v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [CategoryTheory universes]. /-- The core of a category C is the groupoid whose morphisms are all the isomorphisms of C. -/ -- Porting note(#5171): linter not yet ported -- @[nolint has_nonempty_instance] def Core (C : Type u₁) := C #align category_theory.core CategoryTheory.Core variable {C : Type u₁} [Category.{v₁} C] instance coreCategory : Groupoid.{v₁} (Core C) where Hom (X Y : C) := X ≅ Y id (X : C) := Iso.refl X comp f g := Iso.trans f g inv {X Y} f := Iso.symm f #align category_theory.core_category CategoryTheory.coreCategory namespace Core @[simp] /- Porting note: abomination -/
Mathlib/CategoryTheory/Core.lean
52
53
theorem id_hom (X : C) : Iso.hom (coreCategory.id X) = @CategoryStruct.id C _ X := by
rfl
/- 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.Data.Finset.Lattice #align_import data.finset.pairwise from "leanprover-community/mathlib"@"c4c2ed622f43768eff32608d4a0f8a6cec1c047d" /-! # Relations holding pairwise on finite sets In this file we prove a few results about the interaction of `Set.PairwiseDisjoint` and `Finset`, as well as the interaction of `List.Pairwise Disjoint` and the condition of `Disjoint` on `List.toFinset`, in `Set` form. -/ open Finset variable {α ι ι' : Type*} instance [DecidableEq α] {r : α → α → Prop} [DecidableRel r] {s : Finset α} : Decidable ((s : Set α).Pairwise r) := decidable_of_iff' (∀ a ∈ s, ∀ b ∈ s, a ≠ b → r a b) Iff.rfl theorem Finset.pairwiseDisjoint_range_singleton : (Set.range (singleton : α → Finset α)).PairwiseDisjoint id := by rintro _ ⟨a, rfl⟩ _ ⟨b, rfl⟩ h exact disjoint_singleton.2 (ne_of_apply_ne _ h) #align finset.pairwise_disjoint_range_singleton Finset.pairwiseDisjoint_range_singleton namespace Set theorem PairwiseDisjoint.elim_finset {s : Set ι} {f : ι → Finset α} (hs : s.PairwiseDisjoint f) {i j : ι} (hi : i ∈ s) (hj : j ∈ s) (a : α) (hai : a ∈ f i) (haj : a ∈ f j) : i = j := hs.elim hi hj (Finset.not_disjoint_iff.2 ⟨a, hai, haj⟩) #align set.pairwise_disjoint.elim_finset Set.PairwiseDisjoint.elim_finset section SemilatticeInf variable [SemilatticeInf α] [OrderBot α] {s : Finset ι} {f : ι → α} theorem PairwiseDisjoint.image_finset_of_le [DecidableEq ι] {s : Finset ι} {f : ι → α} (hs : (s : Set ι).PairwiseDisjoint f) {g : ι → ι} (hf : ∀ a, f (g a) ≤ f a) : (s.image g : Set ι).PairwiseDisjoint f := by rw [coe_image] exact hs.image_of_le hf #align set.pairwise_disjoint.image_finset_of_le Set.PairwiseDisjoint.image_finset_of_le theorem PairwiseDisjoint.attach (hs : (s : Set ι).PairwiseDisjoint f) : (s.attach : Set { x // x ∈ s }).PairwiseDisjoint (f ∘ Subtype.val) := fun i _ j _ hij => hs i.2 j.2 <| mt Subtype.ext_val hij #align set.pairwise_disjoint.attach Set.PairwiseDisjoint.attach end SemilatticeInf variable [Lattice α] [OrderBot α] /-- Bind operation for `Set.PairwiseDisjoint`. In a complete lattice, you can use `Set.PairwiseDisjoint.biUnion`. -/ theorem PairwiseDisjoint.biUnion_finset {s : Set ι'} {g : ι' → Finset ι} {f : ι → α} (hs : s.PairwiseDisjoint fun i' : ι' => (g i').sup f) (hg : ∀ i ∈ s, (g i : Set ι).PairwiseDisjoint f) : (⋃ i ∈ s, ↑(g i)).PairwiseDisjoint f := by rintro a ha b hb hab simp_rw [Set.mem_iUnion] at ha hb obtain ⟨c, hc, ha⟩ := ha obtain ⟨d, hd, hb⟩ := hb obtain hcd | hcd := eq_or_ne (g c) (g d) · exact hg d hd (by rwa [hcd] at ha) hb hab · exact (hs hc hd (ne_of_apply_ne _ hcd)).mono (Finset.le_sup ha) (Finset.le_sup hb) #align set.pairwise_disjoint.bUnion_finset Set.PairwiseDisjoint.biUnion_finset end Set namespace List variable {β : Type*} [DecidableEq α] {r : α → α → Prop} {l : List α} theorem pairwise_of_coe_toFinset_pairwise (hl : (l.toFinset : Set α).Pairwise r) (hn : l.Nodup) : l.Pairwise r := by rw [coe_toFinset] at hl exact hn.pairwise_of_set_pairwise hl #align list.pairwise_of_coe_to_finset_pairwise List.pairwise_of_coe_toFinset_pairwise
Mathlib/Data/Finset/Pairwise.lean
86
89
theorem pairwise_iff_coe_toFinset_pairwise (hn : l.Nodup) (hs : Symmetric r) : (l.toFinset : Set α).Pairwise r ↔ l.Pairwise r := by
letI : IsSymm α r := ⟨hs⟩ rw [coe_toFinset, hn.pairwise_coe]
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Group.Equiv.TypeTags import Mathlib.GroupTheory.FreeAbelianGroup import Mathlib.GroupTheory.FreeGroup.IsFreeGroup import Mathlib.LinearAlgebra.Dimension.StrongRankCondition #align_import group_theory.free_abelian_group_finsupp from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69" /-! # Isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ` In this file we construct the canonical isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`. We use this to transport the notion of `support` from `Finsupp` to `FreeAbelianGroup`. ## Main declarations - `FreeAbelianGroup.equivFinsupp`: group isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ` - `FreeAbelianGroup.coeff`: the multiplicity of `x : X` in `a : FreeAbelianGroup X` - `FreeAbelianGroup.support`: the finset of `x : X` that occur in `a : FreeAbelianGroup X` -/ noncomputable section variable {X : Type*} /-- The group homomorphism `FreeAbelianGroup X →+ (X →₀ ℤ)`. -/ def FreeAbelianGroup.toFinsupp : FreeAbelianGroup X →+ X →₀ ℤ := FreeAbelianGroup.lift fun x => Finsupp.single x (1 : ℤ) #align free_abelian_group.to_finsupp FreeAbelianGroup.toFinsupp /-- The group homomorphism `(X →₀ ℤ) →+ FreeAbelianGroup X`. -/ def Finsupp.toFreeAbelianGroup : (X →₀ ℤ) →+ FreeAbelianGroup X := Finsupp.liftAddHom fun x => (smulAddHom ℤ (FreeAbelianGroup X)).flip (FreeAbelianGroup.of x) #align finsupp.to_free_abelian_group Finsupp.toFreeAbelianGroup open Finsupp FreeAbelianGroup @[simp] theorem Finsupp.toFreeAbelianGroup_comp_singleAddHom (x : X) : Finsupp.toFreeAbelianGroup.comp (Finsupp.singleAddHom x) = (smulAddHom ℤ (FreeAbelianGroup X)).flip (of x) := by ext simp only [AddMonoidHom.coe_comp, Finsupp.singleAddHom_apply, Function.comp_apply, one_smul, toFreeAbelianGroup, Finsupp.liftAddHom_apply_single] #align finsupp.to_free_abelian_group_comp_single_add_hom Finsupp.toFreeAbelianGroup_comp_singleAddHom @[simp] theorem FreeAbelianGroup.toFinsupp_comp_toFreeAbelianGroup : toFinsupp.comp toFreeAbelianGroup = AddMonoidHom.id (X →₀ ℤ) := by ext x y; simp only [AddMonoidHom.id_comp] rw [AddMonoidHom.comp_assoc, Finsupp.toFreeAbelianGroup_comp_singleAddHom] simp only [toFinsupp, AddMonoidHom.coe_comp, Finsupp.singleAddHom_apply, Function.comp_apply, one_smul, lift.of, AddMonoidHom.flip_apply, smulAddHom_apply, AddMonoidHom.id_apply] #align free_abelian_group.to_finsupp_comp_to_free_abelian_group FreeAbelianGroup.toFinsupp_comp_toFreeAbelianGroup @[simp] theorem Finsupp.toFreeAbelianGroup_comp_toFinsupp : toFreeAbelianGroup.comp toFinsupp = AddMonoidHom.id (FreeAbelianGroup X) := by ext rw [toFreeAbelianGroup, toFinsupp, AddMonoidHom.comp_apply, lift.of, liftAddHom_apply_single, AddMonoidHom.flip_apply, smulAddHom_apply, one_smul, AddMonoidHom.id_apply] #align finsupp.to_free_abelian_group_comp_to_finsupp Finsupp.toFreeAbelianGroup_comp_toFinsupp @[simp] theorem Finsupp.toFreeAbelianGroup_toFinsupp {X} (x : FreeAbelianGroup X) : Finsupp.toFreeAbelianGroup (FreeAbelianGroup.toFinsupp x) = x := by rw [← AddMonoidHom.comp_apply, Finsupp.toFreeAbelianGroup_comp_toFinsupp, AddMonoidHom.id_apply] #align finsupp.to_free_abelian_group_to_finsupp Finsupp.toFreeAbelianGroup_toFinsupp namespace FreeAbelianGroup open Finsupp @[simp] theorem toFinsupp_of (x : X) : toFinsupp (of x) = Finsupp.single x 1 := by simp only [toFinsupp, lift.of] #align free_abelian_group.to_finsupp_of FreeAbelianGroup.toFinsupp_of @[simp]
Mathlib/GroupTheory/FreeAbelianGroupFinsupp.lean
87
89
theorem toFinsupp_toFreeAbelianGroup (f : X →₀ ℤ) : FreeAbelianGroup.toFinsupp (Finsupp.toFreeAbelianGroup f) = f := by
rw [← AddMonoidHom.comp_apply, toFinsupp_comp_toFreeAbelianGroup, AddMonoidHom.id_apply]
/- Copyright (c) 2019 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Topology.Constructions import Mathlib.Topology.Algebra.Monoid import Mathlib.Order.Filter.ListTraverse import Mathlib.Tactic.AdaptationNote #align_import topology.list from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" /-! # Topology on lists and vectors -/ open TopologicalSpace Set Filter open Topology Filter variable {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] instance : TopologicalSpace (List α) := TopologicalSpace.mkOfNhds (traverse nhds)
Mathlib/Topology/List.lean
28
66
theorem nhds_list (as : List α) : 𝓝 as = traverse 𝓝 as := by
refine nhds_mkOfNhds _ _ ?_ ?_ · intro l induction l with | nil => exact le_rfl | cons a l ih => suffices List.cons <$> pure a <*> pure l ≤ List.cons <$> 𝓝 a <*> traverse 𝓝 l by simpa only [functor_norm] using this exact Filter.seq_mono (Filter.map_mono <| pure_le_nhds a) ih · intro l s hs rcases (mem_traverse_iff _ _).1 hs with ⟨u, hu, hus⟩ clear as hs have : ∃ v : List (Set α), l.Forall₂ (fun a s => IsOpen s ∧ a ∈ s) v ∧ sequence v ⊆ s := by induction hu generalizing s with | nil => exists [] simp only [List.forall₂_nil_left_iff, exists_eq_left] exact ⟨trivial, hus⟩ -- porting note -- renamed reordered variables based on previous types | cons ht _ ih => rcases mem_nhds_iff.1 ht with ⟨u, hut, hu⟩ rcases ih _ Subset.rfl with ⟨v, hv, hvss⟩ exact ⟨u::v, List.Forall₂.cons hu hv, Subset.trans (Set.seq_mono (Set.image_subset _ hut) hvss) hus⟩ rcases this with ⟨v, hv, hvs⟩ have : sequence v ∈ traverse 𝓝 l := mem_traverse _ _ <| hv.imp fun a s ⟨hs, ha⟩ => IsOpen.mem_nhds hs ha refine mem_of_superset this fun u hu ↦ ?_ have hu := (List.mem_traverse _ _).1 hu have : List.Forall₂ (fun a s => IsOpen s ∧ a ∈ s) u v := by refine List.Forall₂.flip ?_ replace hv := hv.flip #adaptation_note /-- nightly-2024-03-16: simp was simp only [List.forall₂_and_left, flip] at hv ⊢ -/ simp only [List.forall₂_and_left, Function.flip_def] at hv ⊢ exact ⟨hv.1, hu.flip⟩ refine mem_of_superset ?_ hvs exact mem_traverse _ _ (this.imp fun a s ⟨hs, ha⟩ => IsOpen.mem_nhds hs ha)
/- Copyright (c) 2019 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca, Paul Lezeau, Junyan Xu -/ import Mathlib.RingTheory.AdjoinRoot import Mathlib.FieldTheory.Minpoly.Field import Mathlib.RingTheory.Polynomial.GaussLemma #align_import field_theory.minpoly.is_integrally_closed from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Minimal polynomials over a GCD monoid This file specializes the theory of minpoly to the case of an algebra over a GCD monoid. ## Main results * `minpoly.isIntegrallyClosed_eq_field_fractions`: For integrally closed domains, the minimal polynomial over the ring is the same as the minimal polynomial over the fraction field. * `minpoly.isIntegrallyClosed_dvd` : For integrally closed domains, the minimal polynomial divides any primitive polynomial that has the integral element as root. * `IsIntegrallyClosed.Minpoly.unique` : The minimal polynomial of an element `x` is uniquely characterized by its defining property: if there is another monic polynomial of minimal degree that has `x` as a root, then this polynomial is equal to the minimal polynomial of `x`. -/ open scoped Classical Polynomial open Polynomial Set Function minpoly namespace minpoly variable {R S : Type*} [CommRing R] [CommRing S] [IsDomain R] [Algebra R S] section variable (K L : Type*) [Field K] [Algebra R K] [IsFractionRing R K] [CommRing L] [Nontrivial L] [Algebra R L] [Algebra S L] [Algebra K L] [IsScalarTower R K L] [IsScalarTower R S L] variable [IsIntegrallyClosed R] /-- For integrally closed domains, the minimal polynomial over the ring is the same as the minimal polynomial over the fraction field. See `minpoly.isIntegrallyClosed_eq_field_fractions'` if `S` is already a `K`-algebra. -/ theorem isIntegrallyClosed_eq_field_fractions [IsDomain S] {s : S} (hs : IsIntegral R s) : minpoly K (algebraMap S L s) = (minpoly R s).map (algebraMap R K) := by refine (eq_of_irreducible_of_monic ?_ ?_ ?_).symm · exact ((monic hs).irreducible_iff_irreducible_map_fraction_map).1 (irreducible hs) · rw [aeval_map_algebraMap, aeval_algebraMap_apply, aeval, map_zero] · exact (monic hs).map _ #align minpoly.is_integrally_closed_eq_field_fractions minpoly.isIntegrallyClosed_eq_field_fractions /-- For integrally closed domains, the minimal polynomial over the ring is the same as the minimal polynomial over the fraction field. Compared to `minpoly.isIntegrallyClosed_eq_field_fractions`, this version is useful if the element is in a ring that is already a `K`-algebra. -/
Mathlib/FieldTheory/Minpoly/IsIntegrallyClosed.lean
61
64
theorem isIntegrallyClosed_eq_field_fractions' [IsDomain S] [Algebra K S] [IsScalarTower R K S] {s : S} (hs : IsIntegral R s) : minpoly K s = (minpoly R s).map (algebraMap R K) := by
let L := FractionRing S rw [← isIntegrallyClosed_eq_field_fractions K L hs, algebraMap_eq (IsFractionRing.injective S L)]
/- Copyright (c) 2019 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent import Mathlib.Analysis.Calculus.FDeriv.Linear import Mathlib.Analysis.Calculus.FDeriv.Comp #align_import analysis.calculus.fderiv.equiv from "leanprover-community/mathlib"@"e3fb84046afd187b710170887195d50bada934ee" /-! # The derivative of a linear equivalence For detailed documentation of the Fréchet derivative, see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`. This file contains the usual formulas (and existence assertions) for the derivative of continuous linear equivalences. We also prove the usual formula for the derivative of the inverse function, assuming it exists. The inverse function theorem is in `Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean`. -/ open Filter Asymptotics ContinuousLinearMap Set Metric open scoped Classical open Topology NNReal Filter Asymptotics ENNReal noncomputable section section variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] variable {f f₀ f₁ g : E → F} variable {f' f₀' f₁' g' : E →L[𝕜] F} variable (e : E →L[𝕜] F) variable {x : E} variable {s t : Set E} variable {L L₁ L₂ : Filter E} namespace ContinuousLinearEquiv /-! ### Differentiability of linear equivs, and invariance of differentiability -/ variable (iso : E ≃L[𝕜] F) @[fun_prop] protected theorem hasStrictFDerivAt : HasStrictFDerivAt iso (iso : E →L[𝕜] F) x := iso.toContinuousLinearMap.hasStrictFDerivAt #align continuous_linear_equiv.has_strict_fderiv_at ContinuousLinearEquiv.hasStrictFDerivAt @[fun_prop] protected theorem hasFDerivWithinAt : HasFDerivWithinAt iso (iso : E →L[𝕜] F) s x := iso.toContinuousLinearMap.hasFDerivWithinAt #align continuous_linear_equiv.has_fderiv_within_at ContinuousLinearEquiv.hasFDerivWithinAt @[fun_prop] protected theorem hasFDerivAt : HasFDerivAt iso (iso : E →L[𝕜] F) x := iso.toContinuousLinearMap.hasFDerivAtFilter #align continuous_linear_equiv.has_fderiv_at ContinuousLinearEquiv.hasFDerivAt @[fun_prop] protected theorem differentiableAt : DifferentiableAt 𝕜 iso x := iso.hasFDerivAt.differentiableAt #align continuous_linear_equiv.differentiable_at ContinuousLinearEquiv.differentiableAt @[fun_prop] protected theorem differentiableWithinAt : DifferentiableWithinAt 𝕜 iso s x := iso.differentiableAt.differentiableWithinAt #align continuous_linear_equiv.differentiable_within_at ContinuousLinearEquiv.differentiableWithinAt protected theorem fderiv : fderiv 𝕜 iso x = iso := iso.hasFDerivAt.fderiv #align continuous_linear_equiv.fderiv ContinuousLinearEquiv.fderiv protected theorem fderivWithin (hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 iso s x = iso := iso.toContinuousLinearMap.fderivWithin hxs #align continuous_linear_equiv.fderiv_within ContinuousLinearEquiv.fderivWithin @[fun_prop] protected theorem differentiable : Differentiable 𝕜 iso := fun _ => iso.differentiableAt #align continuous_linear_equiv.differentiable ContinuousLinearEquiv.differentiable @[fun_prop] protected theorem differentiableOn : DifferentiableOn 𝕜 iso s := iso.differentiable.differentiableOn #align continuous_linear_equiv.differentiable_on ContinuousLinearEquiv.differentiableOn theorem comp_differentiableWithinAt_iff {f : G → E} {s : Set G} {x : G} : DifferentiableWithinAt 𝕜 (iso ∘ f) s x ↔ DifferentiableWithinAt 𝕜 f s x := by refine ⟨fun H => ?_, fun H => iso.differentiable.differentiableAt.comp_differentiableWithinAt x H⟩ have : DifferentiableWithinAt 𝕜 (iso.symm ∘ iso ∘ f) s x := iso.symm.differentiable.differentiableAt.comp_differentiableWithinAt x H rwa [← Function.comp.assoc iso.symm iso f, iso.symm_comp_self] at this #align continuous_linear_equiv.comp_differentiable_within_at_iff ContinuousLinearEquiv.comp_differentiableWithinAt_iff
Mathlib/Analysis/Calculus/FDeriv/Equiv.lean
104
107
theorem comp_differentiableAt_iff {f : G → E} {x : G} : DifferentiableAt 𝕜 (iso ∘ f) x ↔ DifferentiableAt 𝕜 f x := by
rw [← differentiableWithinAt_univ, ← differentiableWithinAt_univ, iso.comp_differentiableWithinAt_iff]
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Finset.Lattice #align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Down-compressions This file defines down-compression. Down-compressing `𝒜 : Finset (Finset α)` along `a : α` means removing `a` from the elements of `𝒜`, when the resulting set is not already in `𝒜`. ## Main declarations * `Finset.nonMemberSubfamily`: `𝒜.nonMemberSubfamily a` is the subfamily of sets not containing `a`. * `Finset.memberSubfamily`: `𝒜.memberSubfamily a` is the image of the subfamily of sets containing `a` under removing `a`. * `Down.compression`: Down-compression. ## Notation `𝓓 a 𝒜` is notation for `Down.compress a 𝒜` in locale `SetFamily`. ## References * https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf ## Tags compression, down-compression -/ variable {α : Type*} [DecidableEq α] {𝒜 ℬ : Finset (Finset α)} {s : Finset α} {a : α} namespace Finset /-- Elements of `𝒜` that do not contain `a`. -/ def nonMemberSubfamily (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) := 𝒜.filter fun s => a ∉ s #align finset.non_member_subfamily Finset.nonMemberSubfamily /-- Image of the elements of `𝒜` which contain `a` under removing `a`. Finsets that do not contain `a` such that `insert a s ∈ 𝒜`. -/ def memberSubfamily (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) := (𝒜.filter fun s => a ∈ s).image fun s => erase s a #align finset.member_subfamily Finset.memberSubfamily @[simp] theorem mem_nonMemberSubfamily : s ∈ 𝒜.nonMemberSubfamily a ↔ s ∈ 𝒜 ∧ a ∉ s := by simp [nonMemberSubfamily] #align finset.mem_non_member_subfamily Finset.mem_nonMemberSubfamily @[simp] theorem mem_memberSubfamily : s ∈ 𝒜.memberSubfamily a ↔ insert a s ∈ 𝒜 ∧ a ∉ s := by simp_rw [memberSubfamily, mem_image, mem_filter] refine ⟨?_, fun h => ⟨insert a s, ⟨h.1, by simp⟩, erase_insert h.2⟩⟩ rintro ⟨s, ⟨hs1, hs2⟩, rfl⟩ rw [insert_erase hs2] exact ⟨hs1, not_mem_erase _ _⟩ #align finset.mem_member_subfamily Finset.mem_memberSubfamily theorem nonMemberSubfamily_inter (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∩ ℬ).nonMemberSubfamily a = 𝒜.nonMemberSubfamily a ∩ ℬ.nonMemberSubfamily a := filter_inter_distrib _ _ _ #align finset.non_member_subfamily_inter Finset.nonMemberSubfamily_inter theorem memberSubfamily_inter (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∩ ℬ).memberSubfamily a = 𝒜.memberSubfamily a ∩ ℬ.memberSubfamily a := by unfold memberSubfamily rw [filter_inter_distrib, image_inter_of_injOn _ _ ((erase_injOn' _).mono _)] simp #align finset.member_subfamily_inter Finset.memberSubfamily_inter theorem nonMemberSubfamily_union (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∪ ℬ).nonMemberSubfamily a = 𝒜.nonMemberSubfamily a ∪ ℬ.nonMemberSubfamily a := filter_union _ _ _ #align finset.non_member_subfamily_union Finset.nonMemberSubfamily_union
Mathlib/Combinatorics/SetFamily/Compression/Down.lean
86
88
theorem memberSubfamily_union (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∪ ℬ).memberSubfamily a = 𝒜.memberSubfamily a ∪ ℬ.memberSubfamily a := by
simp_rw [memberSubfamily, filter_union, image_union]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp, Yury Kudryashov -/ import Mathlib.Analysis.Convex.Combination import Mathlib.Analysis.Convex.Strict import Mathlib.Topology.Connected.PathConnected import Mathlib.Topology.Algebra.Affine import Mathlib.Topology.Algebra.Module.Basic #align_import analysis.convex.topology from "leanprover-community/mathlib"@"0e3aacdc98d25e0afe035c452d876d28cbffaa7e" /-! # Topological properties of convex sets We prove the following facts: * `Convex.interior` : interior of a convex set is convex; * `Convex.closure` : closure of a convex set is convex; * `Set.Finite.isCompact_convexHull` : convex hull of a finite set is compact; * `Set.Finite.isClosed_convexHull` : convex hull of a finite set is closed. -/ assert_not_exists Norm open Metric Bornology Set Pointwise Convex variable {ι 𝕜 E : Type*} theorem Real.convex_iff_isPreconnected {s : Set ℝ} : Convex ℝ s ↔ IsPreconnected s := convex_iff_ordConnected.trans isPreconnected_iff_ordConnected.symm #align real.convex_iff_is_preconnected Real.convex_iff_isPreconnected alias ⟨_, IsPreconnected.convex⟩ := Real.convex_iff_isPreconnected #align is_preconnected.convex IsPreconnected.convex /-! ### Standard simplex -/ section stdSimplex variable [Fintype ι] /-- Every vector in `stdSimplex 𝕜 ι` has `max`-norm at most `1`. -/ theorem stdSimplex_subset_closedBall : stdSimplex ℝ ι ⊆ Metric.closedBall 0 1 := fun f hf ↦ by rw [Metric.mem_closedBall, dist_pi_le_iff zero_le_one] intro x rw [Pi.zero_apply, Real.dist_0_eq_abs, abs_of_nonneg <| hf.1 x] exact (mem_Icc_of_mem_stdSimplex hf x).2 #align std_simplex_subset_closed_ball stdSimplex_subset_closedBall variable (ι) /-- `stdSimplex ℝ ι` is bounded. -/ theorem bounded_stdSimplex : IsBounded (stdSimplex ℝ ι) := (Metric.isBounded_iff_subset_closedBall 0).2 ⟨1, stdSimplex_subset_closedBall⟩ #align bounded_std_simplex bounded_stdSimplex /-- `stdSimplex ℝ ι` is closed. -/ theorem isClosed_stdSimplex : IsClosed (stdSimplex ℝ ι) := (stdSimplex_eq_inter ℝ ι).symm ▸ IsClosed.inter (isClosed_iInter fun i => isClosed_le continuous_const (continuous_apply i)) (isClosed_eq (continuous_finset_sum _ fun x _ => continuous_apply x) continuous_const) #align is_closed_std_simplex isClosed_stdSimplex /-- `stdSimplex ℝ ι` is compact. -/ theorem isCompact_stdSimplex : IsCompact (stdSimplex ℝ ι) := Metric.isCompact_iff_isClosed_bounded.2 ⟨isClosed_stdSimplex ι, bounded_stdSimplex ι⟩ #align is_compact_std_simplex isCompact_stdSimplex instance stdSimplex.instCompactSpace_coe : CompactSpace ↥(stdSimplex ℝ ι) := isCompact_iff_compactSpace.mp <| isCompact_stdSimplex _ /-- The standard one-dimensional simplex in `ℝ² = Fin 2 → ℝ` is homeomorphic to the unit interval. -/ @[simps! (config := .asFn)] def stdSimplexHomeomorphUnitInterval : stdSimplex ℝ (Fin 2) ≃ₜ unitInterval where toEquiv := stdSimplexEquivIcc ℝ continuous_toFun := .subtype_mk ((continuous_apply 0).comp continuous_subtype_val) _ continuous_invFun := by apply Continuous.subtype_mk exact (continuous_pi <| Fin.forall_fin_two.2 ⟨continuous_subtype_val, continuous_const.sub continuous_subtype_val⟩) end stdSimplex /-! ### Topological vector spaces -/ section TopologicalSpace variable [LinearOrderedRing 𝕜] [DenselyOrdered 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] [AddCommGroup E] [TopologicalSpace E] [ContinuousAdd E] [Module 𝕜 E] [ContinuousSMul 𝕜 E] {x y : E} theorem segment_subset_closure_openSegment : [x -[𝕜] y] ⊆ closure (openSegment 𝕜 x y) := by rw [segment_eq_image, openSegment_eq_image, ← closure_Ioo (zero_ne_one' 𝕜)] exact image_closure_subset_closure_image (by continuity) #align segment_subset_closure_open_segment segment_subset_closure_openSegment end TopologicalSpace section PseudoMetricSpace variable [LinearOrderedRing 𝕜] [DenselyOrdered 𝕜] [PseudoMetricSpace 𝕜] [OrderTopology 𝕜] [ProperSpace 𝕜] [CompactIccSpace 𝕜] [AddCommGroup E] [TopologicalSpace E] [T2Space E] [ContinuousAdd E] [Module 𝕜 E] [ContinuousSMul 𝕜 E] @[simp] theorem closure_openSegment (x y : E) : closure (openSegment 𝕜 x y) = [x -[𝕜] y] := by rw [segment_eq_image, openSegment_eq_image, ← closure_Ioo (zero_ne_one' 𝕜)] exact (image_closure_of_isCompact (isBounded_Ioo _ _).isCompact_closure <| Continuous.continuousOn <| by continuity).symm #align closure_open_segment closure_openSegment end PseudoMetricSpace section ContinuousConstSMul variable [LinearOrderedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E] /-- If `s` is a convex set, then `a • interior s + b • closure s ⊆ interior s` for all `0 < a`, `0 ≤ b`, `a + b = 1`. See also `Convex.combo_interior_self_subset_interior` for a weaker version. -/
Mathlib/Analysis/Convex/Topology.lean
124
132
theorem Convex.combo_interior_closure_subset_interior {s : Set E} (hs : Convex 𝕜 s) {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) : a • interior s + b • closure s ⊆ interior s := interior_smul₀ ha.ne' s ▸ calc interior (a • s) + b • closure s ⊆ interior (a • s) + closure (b • s) := add_subset_add Subset.rfl (smul_closure_subset b s) _ = interior (a • s) + b • s := by
rw [isOpen_interior.add_closure (b • s)] _ ⊆ interior (a • s + b • s) := subset_interior_add_left _ ⊆ interior s := interior_mono <| hs.set_combo_subset ha.le hb hab
/- 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.Finset.Nat import Mathlib.Data.PNat.Defs #align_import data.pnat.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" /-! # Finite intervals of positive naturals This file proves that `ℕ+` is a `LocallyFiniteOrder` and calculates the cardinality of its intervals as finsets and fintypes. -/ open Finset Function PNat namespace PNat variable (a b : ℕ+) instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ+ := Subtype.instLocallyFiniteOrder _ theorem Icc_eq_finset_subtype : Icc a b = (Icc (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.Icc_eq_finset_subtype PNat.Icc_eq_finset_subtype theorem Ico_eq_finset_subtype : Ico a b = (Ico (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.Ico_eq_finset_subtype PNat.Ico_eq_finset_subtype theorem Ioc_eq_finset_subtype : Ioc a b = (Ioc (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.Ioc_eq_finset_subtype PNat.Ioc_eq_finset_subtype theorem Ioo_eq_finset_subtype : Ioo a b = (Ioo (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.Ioo_eq_finset_subtype PNat.Ioo_eq_finset_subtype theorem uIcc_eq_finset_subtype : uIcc a b = (uIcc (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.uIcc_eq_finset_subtype PNat.uIcc_eq_finset_subtype theorem map_subtype_embedding_Icc : (Icc a b).map (Embedding.subtype _) = Icc ↑a ↑b := Finset.map_subtype_embedding_Icc _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx #align pnat.map_subtype_embedding_Icc PNat.map_subtype_embedding_Icc theorem map_subtype_embedding_Ico : (Ico a b).map (Embedding.subtype _) = Ico ↑a ↑b := Finset.map_subtype_embedding_Ico _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx #align pnat.map_subtype_embedding_Ico PNat.map_subtype_embedding_Ico theorem map_subtype_embedding_Ioc : (Ioc a b).map (Embedding.subtype _) = Ioc ↑a ↑b := Finset.map_subtype_embedding_Ioc _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx #align pnat.map_subtype_embedding_Ioc PNat.map_subtype_embedding_Ioc theorem map_subtype_embedding_Ioo : (Ioo a b).map (Embedding.subtype _) = Ioo ↑a ↑b := Finset.map_subtype_embedding_Ioo _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx #align pnat.map_subtype_embedding_Ioo PNat.map_subtype_embedding_Ioo theorem map_subtype_embedding_uIcc : (uIcc a b).map (Embedding.subtype _) = uIcc ↑a ↑b := map_subtype_embedding_Icc _ _ #align pnat.map_subtype_embedding_uIcc PNat.map_subtype_embedding_uIcc @[simp] theorem card_Icc : (Icc a b).card = b + 1 - a := by rw [← Nat.card_Icc] -- Porting note: I had to change this to `erw` *and* provide the proof, yuck. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [← Finset.map_subtype_embedding_Icc _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)] rw [card_map] #align pnat.card_Icc PNat.card_Icc @[simp] theorem card_Ico : (Ico a b).card = b - a := by rw [← Nat.card_Ico] -- Porting note: I had to change this to `erw` *and* provide the proof, yuck. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [← Finset.map_subtype_embedding_Ico _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)] rw [card_map] #align pnat.card_Ico PNat.card_Ico @[simp] theorem card_Ioc : (Ioc a b).card = b - a := by rw [← Nat.card_Ioc] -- Porting note: I had to change this to `erw` *and* provide the proof, yuck. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [← Finset.map_subtype_embedding_Ioc _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)] rw [card_map] #align pnat.card_Ioc PNat.card_Ioc @[simp] theorem card_Ioo : (Ioo a b).card = b - a - 1 := by rw [← Nat.card_Ioo] -- Porting note: I had to change this to `erw` *and* provide the proof, yuck. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [← Finset.map_subtype_embedding_Ioo _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)] rw [card_map] #align pnat.card_Ioo PNat.card_Ioo @[simp] theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by rw [← Nat.card_uIcc, ← map_subtype_embedding_uIcc, card_map] #align pnat.card_uIcc PNat.card_uIcc -- Porting note: `simpNF` says `simp` can prove this theorem card_fintype_Icc : Fintype.card (Set.Icc a b) = b + 1 - a := by rw [← card_Icc, Fintype.card_ofFinset] #align pnat.card_fintype_Icc PNat.card_fintype_Icc -- Porting note: `simpNF` says `simp` can prove this
Mathlib/Data/PNat/Interval.lean
113
114
theorem card_fintype_Ico : Fintype.card (Set.Ico a b) = b - a := by
rw [← card_Ico, Fintype.card_ofFinset]
/- Copyright (c) 2022 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Probability.Variance #align_import probability.moments from "leanprover-community/mathlib"@"85453a2a14be8da64caf15ca50930cf4c6e5d8de" /-! # Moments and moment generating function ## Main definitions * `ProbabilityTheory.moment X p μ`: `p`th moment of a real random variable `X` with respect to measure `μ`, `μ[X^p]` * `ProbabilityTheory.centralMoment X p μ`:`p`th central moment of `X` with respect to measure `μ`, `μ[(X - μ[X])^p]` * `ProbabilityTheory.mgf X μ t`: moment generating function of `X` with respect to measure `μ`, `μ[exp(t*X)]` * `ProbabilityTheory.cgf X μ t`: cumulant generating function, logarithm of the moment generating function ## Main results * `ProbabilityTheory.IndepFun.mgf_add`: if two real random variables `X` and `Y` are independent and their mgfs are defined at `t`, then `mgf (X + Y) μ t = mgf X μ t * mgf Y μ t` * `ProbabilityTheory.IndepFun.cgf_add`: if two real random variables `X` and `Y` are independent and their cgfs are defined at `t`, then `cgf (X + Y) μ t = cgf X μ t + cgf Y μ t` * `ProbabilityTheory.measure_ge_le_exp_cgf` and `ProbabilityTheory.measure_le_le_exp_cgf`: Chernoff bound on the upper (resp. lower) tail of a random variable. For `t` nonnegative such that the cgf exists, `ℙ(ε ≤ X) ≤ exp(- t*ε + cgf X ℙ t)`. See also `ProbabilityTheory.measure_ge_le_exp_mul_mgf` and `ProbabilityTheory.measure_le_le_exp_mul_mgf` for versions of these results using `mgf` instead of `cgf`. -/ open MeasureTheory Filter Finset Real noncomputable section open scoped MeasureTheory ProbabilityTheory ENNReal NNReal namespace ProbabilityTheory variable {Ω ι : Type*} {m : MeasurableSpace Ω} {X : Ω → ℝ} {p : ℕ} {μ : Measure Ω} /-- Moment of a real random variable, `μ[X ^ p]`. -/ def moment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ := μ[X ^ p] #align probability_theory.moment ProbabilityTheory.moment /-- Central moment of a real random variable, `μ[(X - μ[X]) ^ p]`. -/ def centralMoment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ := by have m := fun (x : Ω) => μ[X] -- Porting note: Lean deems `μ[(X - fun x => μ[X]) ^ p]` ambiguous exact μ[(X - m) ^ p] #align probability_theory.central_moment ProbabilityTheory.centralMoment @[simp] theorem moment_zero (hp : p ≠ 0) : moment 0 p μ = 0 := by simp only [moment, hp, zero_pow, Ne, not_false_iff, Pi.zero_apply, integral_const, smul_eq_mul, mul_zero, integral_zero] #align probability_theory.moment_zero ProbabilityTheory.moment_zero @[simp] theorem centralMoment_zero (hp : p ≠ 0) : centralMoment 0 p μ = 0 := by simp only [centralMoment, hp, Pi.zero_apply, integral_const, smul_eq_mul, mul_zero, zero_sub, Pi.pow_apply, Pi.neg_apply, neg_zero, zero_pow, Ne, not_false_iff] #align probability_theory.central_moment_zero ProbabilityTheory.centralMoment_zero theorem centralMoment_one' [IsFiniteMeasure μ] (h_int : Integrable X μ) : centralMoment X 1 μ = (1 - (μ Set.univ).toReal) * μ[X] := by simp only [centralMoment, Pi.sub_apply, pow_one] rw [integral_sub h_int (integrable_const _)] simp only [sub_mul, integral_const, smul_eq_mul, one_mul] #align probability_theory.central_moment_one' ProbabilityTheory.centralMoment_one' @[simp] theorem centralMoment_one [IsProbabilityMeasure μ] : centralMoment X 1 μ = 0 := by by_cases h_int : Integrable X μ · rw [centralMoment_one' h_int] simp only [measure_univ, ENNReal.one_toReal, sub_self, zero_mul] · simp only [centralMoment, Pi.sub_apply, pow_one] have : ¬Integrable (fun x => X x - integral μ X) μ := by refine fun h_sub => h_int ?_ have h_add : X = (fun x => X x - integral μ X) + fun _ => integral μ X := by ext1 x; simp rw [h_add] exact h_sub.add (integrable_const _) rw [integral_undef this] #align probability_theory.central_moment_one ProbabilityTheory.centralMoment_one theorem centralMoment_two_eq_variance [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) : centralMoment X 2 μ = variance X μ := by rw [hX.variance_eq]; rfl #align probability_theory.central_moment_two_eq_variance ProbabilityTheory.centralMoment_two_eq_variance section MomentGeneratingFunction variable {t : ℝ} /-- Moment generating function of a real random variable `X`: `fun t => μ[exp(t*X)]`. -/ def mgf (X : Ω → ℝ) (μ : Measure Ω) (t : ℝ) : ℝ := μ[fun ω => exp (t * X ω)] #align probability_theory.mgf ProbabilityTheory.mgf /-- Cumulant generating function of a real random variable `X`: `fun t => log μ[exp(t*X)]`. -/ def cgf (X : Ω → ℝ) (μ : Measure Ω) (t : ℝ) : ℝ := log (mgf X μ t) #align probability_theory.cgf ProbabilityTheory.cgf @[simp]
Mathlib/Probability/Moments.lean
113
114
theorem mgf_zero_fun : mgf 0 μ t = (μ Set.univ).toReal := by
simp only [mgf, Pi.zero_apply, mul_zero, exp_zero, integral_const, smul_eq_mul, mul_one]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.AlgebraicGeometry.Spec import Mathlib.Algebra.Category.Ring.Constructions import Mathlib.CategoryTheory.Elementwise #align_import algebraic_geometry.Scheme from "leanprover-community/mathlib"@"88474d1b5af6d37c2ab728b757771bced7f5194c" /-! # The category of schemes A scheme is a locally ringed space such that every point is contained in some open set where there is an isomorphism of presheaves between the restriction to that open set, and the structure sheaf of `Spec R`, for some commutative ring `R`. A morphism of schemes is just a morphism of the underlying locally ringed spaces. -/ -- Explicit universe annotations were used in this file to improve perfomance #12737 set_option linter.uppercaseLean3 false universe u noncomputable section open TopologicalSpace open CategoryTheory open TopCat open Opposite namespace AlgebraicGeometry /-- We define `Scheme` as an `X : LocallyRingedSpace`, along with a proof that every point has an open neighbourhood `U` so that the restriction of `X` to `U` is isomorphic, as a locally ringed space, to `Spec.toLocallyRingedSpace.obj (op R)` for some `R : CommRingCat`. -/ structure Scheme extends LocallyRingedSpace where local_affine : ∀ x : toLocallyRingedSpace, ∃ (U : OpenNhds x) (R : CommRingCat), Nonempty (toLocallyRingedSpace.restrict U.openEmbedding ≅ Spec.toLocallyRingedSpace.obj (op R)) #align algebraic_geometry.Scheme AlgebraicGeometry.Scheme namespace Scheme /-- A morphism between schemes is a morphism between the underlying locally ringed spaces. -/ -- @[nolint has_nonempty_instance] -- Porting note(#5171): linter not ported yet def Hom (X Y : Scheme) : Type* := X.toLocallyRingedSpace ⟶ Y.toLocallyRingedSpace #align algebraic_geometry.Scheme.hom AlgebraicGeometry.Scheme.Hom /-- Schemes are a full subcategory of locally ringed spaces. -/ instance : Category Scheme := { InducedCategory.category Scheme.toLocallyRingedSpace with Hom := Hom } -- porting note (#10688): added to ease automation @[continuity] lemma Hom.continuous {X Y : Scheme} (f : X ⟶ Y) : Continuous f.1.base := f.1.base.2 /-- The structure sheaf of a scheme. -/ protected abbrev sheaf (X : Scheme) := X.toSheafedSpace.sheaf #align algebraic_geometry.Scheme.sheaf AlgebraicGeometry.Scheme.sheaf instance : CoeSort Scheme Type* where coe X := X.carrier /-- The forgetful functor from `Scheme` to `LocallyRingedSpace`. -/ @[simps!] def forgetToLocallyRingedSpace : Scheme ⥤ LocallyRingedSpace := inducedFunctor _ -- deriving Full, Faithful -- Porting note: no delta derive handler, see https://github.com/leanprover-community/mathlib4/issues/5020 #align algebraic_geometry.Scheme.forget_to_LocallyRingedSpace AlgebraicGeometry.Scheme.forgetToLocallyRingedSpace /-- The forget functor `Scheme ⥤ LocallyRingedSpace` is fully faithful. -/ @[simps!] def fullyFaithfulForgetToLocallyRingedSpace : forgetToLocallyRingedSpace.FullyFaithful := fullyFaithfulInducedFunctor _ instance : forgetToLocallyRingedSpace.Full := InducedCategory.full _ instance : forgetToLocallyRingedSpace.Faithful := InducedCategory.faithful _ /-- The forgetful functor from `Scheme` to `TopCat`. -/ @[simps!] def forgetToTop : Scheme ⥤ TopCat := Scheme.forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToTop #align algebraic_geometry.Scheme.forget_to_Top AlgebraicGeometry.Scheme.forgetToTop -- Porting note: Lean seems not able to find this coercion any more instance hasCoeToTopCat : CoeOut Scheme TopCat where coe X := X.carrier -- Porting note: added this unification hint just in case /-- forgetful functor to `TopCat` is the same as coercion -/ unif_hint forgetToTop_obj_eq_coe (X : Scheme) where ⊢ forgetToTop.obj X ≟ (X : TopCat) @[simp] theorem id_val_base (X : Scheme) : (𝟙 X : _).1.base = 𝟙 _ := rfl #align algebraic_geometry.Scheme.id_val_base AlgebraicGeometry.Scheme.id_val_base @[simp] theorem id_app {X : Scheme} (U : (Opens X.carrier)ᵒᵖ) : (𝟙 X : _).val.c.app U = X.presheaf.map (eqToHom (by induction' U with U; cases U; rfl)) := PresheafedSpace.id_c_app X.toPresheafedSpace U #align algebraic_geometry.Scheme.id_app AlgebraicGeometry.Scheme.id_app @[reassoc] theorem comp_val {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).val = f.val ≫ g.val := rfl #align algebraic_geometry.Scheme.comp_val AlgebraicGeometry.Scheme.comp_val @[simp, reassoc] -- reassoc lemma does not need `simp` theorem comp_coeBase {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).val.base = f.val.base ≫ g.val.base := rfl #align algebraic_geometry.Scheme.comp_coe_base AlgebraicGeometry.Scheme.comp_coeBase -- Porting note: removed elementwise attribute, as generated lemmas were trivial. @[reassoc] theorem comp_val_base {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).val.base = f.val.base ≫ g.val.base := rfl #align algebraic_geometry.Scheme.comp_val_base AlgebraicGeometry.Scheme.comp_val_base theorem comp_val_base_apply {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g).val.base x = g.val.base (f.val.base x) := by simp #align algebraic_geometry.Scheme.comp_val_base_apply AlgebraicGeometry.Scheme.comp_val_base_apply @[simp, reassoc] -- reassoc lemma does not need `simp` theorem comp_val_c_app {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U) : (f ≫ g).val.c.app U = g.val.c.app U ≫ f.val.c.app _ := rfl #align algebraic_geometry.Scheme.comp_val_c_app AlgebraicGeometry.Scheme.comp_val_c_app
Mathlib/AlgebraicGeometry/Scheme.lean
155
157
theorem congr_app {X Y : Scheme} {f g : X ⟶ Y} (e : f = g) (U) : f.val.c.app U = g.val.c.app U ≫ X.presheaf.map (eqToHom (by subst e; rfl)) := by
subst e; dsimp; simp
/- 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.Single #align_import algebra.homology.augment from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Augmentation and truncation of `ℕ`-indexed (co)chain complexes. -/ noncomputable section open CategoryTheory Limits HomologicalComplex universe v u variable {V : Type u} [Category.{v} V] namespace ChainComplex /-- The truncation of an `ℕ`-indexed chain complex, deleting the object at `0` and shifting everything else down. -/ @[simps] def truncate [HasZeroMorphisms V] : ChainComplex V ℕ ⥤ ChainComplex V ℕ where obj C := { X := fun i => C.X (i + 1) d := fun i j => C.d (i + 1) (j + 1) shape := fun i j w => C.shape _ _ <| by simpa } map f := { f := fun i => f.f (i + 1) } #align chain_complex.truncate ChainComplex.truncate /-- There is a canonical chain map from the truncation of a chain map `C` to the "single object" chain complex consisting of the truncated object `C.X 0` in degree 0. The components of this chain map are `C.d 1 0` in degree 0, and zero otherwise. -/ def truncateTo [HasZeroObject V] [HasZeroMorphisms V] (C : ChainComplex V ℕ) : truncate.obj C ⟶ (single₀ V).obj (C.X 0) := (toSingle₀Equiv (truncate.obj C) (C.X 0)).symm ⟨C.d 1 0, by aesop⟩ #align chain_complex.truncate_to ChainComplex.truncateTo -- PROJECT when `V` is abelian (but not generally?) -- `[∀ n, Exact (C.d (n+2) (n+1)) (C.d (n+1) n)] [Epi (C.d 1 0)]` iff `QuasiIso (C.truncate_to)` variable [HasZeroMorphisms V] /-- We can "augment" a chain complex by inserting an arbitrary object in degree zero (shifting everything else up), along with a suitable differential. -/ def augment (C : ChainComplex V ℕ) {X : V} (f : C.X 0 ⟶ X) (w : C.d 1 0 ≫ f = 0) : ChainComplex V ℕ where X | 0 => X | i + 1 => C.X i d | 1, 0 => f | i + 1, j + 1 => C.d i j | _, _ => 0 shape | 1, 0, h => absurd rfl h | i + 2, 0, _ => rfl | 0, _, _ => rfl | i + 1, j + 1, h => by simp only; exact C.shape i j (Nat.succ_ne_succ.1 h) d_comp_d' | _, _, 0, rfl, rfl => w | _, _, k + 1, rfl, rfl => C.d_comp_d _ _ _ #align chain_complex.augment ChainComplex.augment @[simp] theorem augment_X_zero (C : ChainComplex V ℕ) {X : V} (f : C.X 0 ⟶ X) (w : C.d 1 0 ≫ f = 0) : (augment C f w).X 0 = X := rfl set_option linter.uppercaseLean3 false in #align chain_complex.augment_X_zero ChainComplex.augment_X_zero @[simp] theorem augment_X_succ (C : ChainComplex V ℕ) {X : V} (f : C.X 0 ⟶ X) (w : C.d 1 0 ≫ f = 0) (i : ℕ) : (augment C f w).X (i + 1) = C.X i := rfl set_option linter.uppercaseLean3 false in #align chain_complex.augment_X_succ ChainComplex.augment_X_succ @[simp] theorem augment_d_one_zero (C : ChainComplex V ℕ) {X : V} (f : C.X 0 ⟶ X) (w : C.d 1 0 ≫ f = 0) : (augment C f w).d 1 0 = f := rfl #align chain_complex.augment_d_one_zero ChainComplex.augment_d_one_zero @[simp]
Mathlib/Algebra/Homology/Augment.lean
92
94
theorem augment_d_succ_succ (C : ChainComplex V ℕ) {X : V} (f : C.X 0 ⟶ X) (w : C.d 1 0 ≫ f = 0) (i j : ℕ) : (augment C f w).d (i + 1) (j + 1) = C.d i j := by
cases i <;> rfl
/- Copyright (c) 2021 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Kyle Miller -/ import Mathlib.Data.Int.GCD import Mathlib.Tactic.NormNum /-! # `norm_num` extensions for GCD-adjacent functions This module defines some `norm_num` extensions for functions such as `Nat.gcd`, `Nat.lcm`, `Int.gcd`, and `Int.lcm`. Note that `Nat.coprime` is reducible and defined in terms of `Nat.gcd`, so the `Nat.gcd` extension also indirectly provides a `Nat.coprime` extension. -/ namespace Tactic namespace NormNum
Mathlib/Tactic/NormNum/GCD.lean
22
28
theorem int_gcd_helper' {d : ℕ} {x y : ℤ} (a b : ℤ) (h₁ : (d : ℤ) ∣ x) (h₂ : (d : ℤ) ∣ y) (h₃ : x * a + y * b = d) : Int.gcd x y = d := by
refine Nat.dvd_antisymm ?_ (Int.natCast_dvd_natCast.1 (Int.dvd_gcd h₁ h₂)) rw [← Int.natCast_dvd_natCast, ← h₃] apply dvd_add · exact Int.gcd_dvd_left.mul_right _ · exact Int.gcd_dvd_right.mul_right _
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Morenikeji Neri -/ import Mathlib.Algebra.EuclideanDomain.Instances import Mathlib.RingTheory.Ideal.Colon import Mathlib.RingTheory.UniqueFactorizationDomain #align_import ring_theory.principal_ideal_domain from "leanprover-community/mathlib"@"6010cf523816335f7bae7f8584cb2edaace73940" /-! # Principal ideal rings, principal ideal domains, and Bézout rings A principal ideal ring (PIR) is a ring in which all left ideals are principal. A principal ideal domain (PID) is an integral domain which is a principal ideal ring. # Main definitions Note that for principal ideal domains, one should use `[IsDomain R] [IsPrincipalIdealRing R]`. There is no explicit definition of a PID. Theorems about PID's are in the `principal_ideal_ring` namespace. - `IsPrincipalIdealRing`: a predicate on rings, saying that every left ideal is principal. - `IsBezout`: the predicate saying that every finitely generated left ideal is principal. - `generator`: a generator of a principal ideal (or more generally submodule) - `to_unique_factorization_monoid`: a PID is a unique factorization domain # Main results - `to_maximal_ideal`: a non-zero prime ideal in a PID is maximal. - `EuclideanDomain.to_principal_ideal_domain` : a Euclidean domain is a PID. - `IsBezout.nonemptyGCDMonoid`: Every Bézout domain is a GCD domain. -/ universe u v variable {R : Type u} {M : Type v} open Set Function open Submodule section variable [Ring R] [AddCommGroup M] [Module R M] instance bot_isPrincipal : (⊥ : Submodule R M).IsPrincipal := ⟨⟨0, by simp⟩⟩ #align bot_is_principal bot_isPrincipal instance top_isPrincipal : (⊤ : Submodule R R).IsPrincipal := ⟨⟨1, Ideal.span_singleton_one.symm⟩⟩ #align top_is_principal top_isPrincipal variable (R) /-- A Bézout ring is a ring whose finitely generated ideals are principal. -/ class IsBezout : Prop where /-- Any finitely generated ideal is principal. -/ isPrincipal_of_FG : ∀ I : Ideal R, I.FG → I.IsPrincipal #align is_bezout IsBezout instance (priority := 100) IsBezout.of_isPrincipalIdealRing [IsPrincipalIdealRing R] : IsBezout R := ⟨fun I _ => IsPrincipalIdealRing.principal I⟩ #align is_bezout.of_is_principal_ideal_ring IsBezout.of_isPrincipalIdealRing instance (priority := 100) DivisionRing.isPrincipalIdealRing (K : Type u) [DivisionRing K] : IsPrincipalIdealRing K where principal S := by rcases Ideal.eq_bot_or_top S with (rfl | rfl) · apply bot_isPrincipal · apply top_isPrincipal #align division_ring.is_principal_ideal_ring DivisionRing.isPrincipalIdealRing end namespace Submodule.IsPrincipal variable [AddCommGroup M] section Ring variable [Ring R] [Module R M] /-- `generator I`, if `I` is a principal submodule, is an `x ∈ M` such that `span R {x} = I` -/ noncomputable def generator (S : Submodule R M) [S.IsPrincipal] : M := Classical.choose (principal S) #align submodule.is_principal.generator Submodule.IsPrincipal.generator theorem span_singleton_generator (S : Submodule R M) [S.IsPrincipal] : span R {generator S} = S := Eq.symm (Classical.choose_spec (principal S)) #align submodule.is_principal.span_singleton_generator Submodule.IsPrincipal.span_singleton_generator @[simp] theorem _root_.Ideal.span_singleton_generator (I : Ideal R) [I.IsPrincipal] : Ideal.span ({generator I} : Set R) = I := Eq.symm (Classical.choose_spec (principal I)) #align ideal.span_singleton_generator Ideal.span_singleton_generator @[simp] theorem generator_mem (S : Submodule R M) [S.IsPrincipal] : generator S ∈ S := by conv_rhs => rw [← span_singleton_generator S] exact subset_span (mem_singleton _) #align submodule.is_principal.generator_mem Submodule.IsPrincipal.generator_mem
Mathlib/RingTheory/PrincipalIdealDomain.lean
109
111
theorem mem_iff_eq_smul_generator (S : Submodule R M) [S.IsPrincipal] {x : M} : x ∈ S ↔ ∃ s : R, x = s • generator S := by
simp_rw [@eq_comm _ x, ← mem_span_singleton, span_singleton_generator]
/- Copyright (c) 2023 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Nick Kuhn -/ import Mathlib.CategoryTheory.Sites.Coherent.CoherentSheaves /-! # Description of the covering sieves of the coherent topology This file characterises the covering sieves of the coherent topology. ## Main result * `coherentTopology.mem_sieves_iff_hasEffectiveEpiFamily`: a sieve is a covering sieve for the coherent topology if and only if it contains a finite effective epimorphic family. -/ namespace CategoryTheory variable {C : Type*} [Category C] [Precoherent C] {X : C} /-- For a precoherent category, any sieve that contains an `EffectiveEpiFamily` is a sieve of the coherent topology. Note: This is one direction of `mem_sieves_iff_hasEffectiveEpiFamily`, but is needed for the proof. -/ theorem coherentTopology.mem_sieves_of_hasEffectiveEpiFamily (S : Sieve X) : (∃ (α : Type) (_ : Finite α) (Y : α → C) (π : (a : α) → (Y a ⟶ X)), EffectiveEpiFamily Y π ∧ (∀ a : α, (S.arrows) (π a)) ) → (S ∈ GrothendieckTopology.sieves (coherentTopology C) X) := by intro ⟨α, _, Y, π, hπ⟩ apply (coherentCoverage C).mem_toGrothendieck_sieves_of_superset (R := Presieve.ofArrows Y π) · exact fun _ _ h ↦ by cases h; exact hπ.2 _ · exact ⟨_, inferInstance, Y, π, rfl, hπ.1⟩ /-- Effective epi families in a precoherent category are transitive, in the sense that an `EffectiveEpiFamily` and an `EffectiveEpiFamily` over each member, the composition is an `EffectiveEpiFamily`. Note: The finiteness condition is an artifact of the proof and is probably unnecessary. -/ theorem EffectiveEpiFamily.transitive_of_finite {α : Type} [Finite α] {Y : α → C} (π : (a : α) → (Y a ⟶ X)) (h : EffectiveEpiFamily Y π) {β : α → Type} [∀ (a: α), Finite (β a)] {Y_n : (a : α) → β a → C} (π_n : (a : α) → (b : β a) → (Y_n a b ⟶ Y a)) (H : ∀ a, EffectiveEpiFamily (Y_n a) (π_n a)) : EffectiveEpiFamily (fun (c : Σ a, β a) => Y_n c.fst c.snd) (fun c => π_n c.fst c.snd ≫ π c.fst) := by rw [← Sieve.effectiveEpimorphic_family] suffices h₂ : (Sieve.generate (Presieve.ofArrows (fun (⟨a, b⟩ : Σ _, β _) => Y_n a b) (fun ⟨a,b⟩ => π_n a b ≫ π a))) ∈ GrothendieckTopology.sieves (coherentTopology C) X by change Nonempty _ rw [← Sieve.forallYonedaIsSheaf_iff_colimit] exact fun W => coherentTopology.isSheaf_yoneda_obj W _ h₂ -- Show that a covering sieve is a colimit, which implies the original set of arrows is regular -- epimorphic. We use the transitivity property of saturation apply Coverage.saturate.transitive X (Sieve.generate (Presieve.ofArrows Y π)) · apply Coverage.saturate.of use α, inferInstance, Y, π · intro V f ⟨Y₁, h, g, ⟨hY, hf⟩⟩ rw [← hf, Sieve.pullback_comp] apply (coherentTopology C).pullback_stable' apply coherentTopology.mem_sieves_of_hasEffectiveEpiFamily -- Need to show that the pullback of the family `π_n` to a given `Y i` is effective epimorphic obtain ⟨i⟩ := hY exact ⟨β i, inferInstance, Y_n i, π_n i, H i, fun b ↦ ⟨Y_n i b, (𝟙 _), π_n i b ≫ π i, ⟨(⟨i, b⟩ : Σ (i : α), β i)⟩, by simp⟩⟩ instance precoherentEffectiveEpiFamilyCompEffectiveEpis {α : Type} [Finite α] {Y Z : α → C} (π : (a : α) → (Y a ⟶ X)) [EffectiveEpiFamily Y π] (f : (a : α) → Z a ⟶ Y a) [h : ∀ a, EffectiveEpi (f a)] : EffectiveEpiFamily _ fun a ↦ f a ≫ π a := by simp_rw [effectiveEpi_iff_effectiveEpiFamily] at h exact EffectiveEpiFamily.reindex (e := Equiv.sigmaPUnit α) _ _ (EffectiveEpiFamily.transitive_of_finite (β := fun _ ↦ Unit) _ inferInstance _ h) /-- A sieve belongs to the coherent topology if and only if it contains a finite `EffectiveEpiFamily`. -/
Mathlib/CategoryTheory/Sites/Coherent/CoherentTopology.lean
82
99
theorem coherentTopology.mem_sieves_iff_hasEffectiveEpiFamily (S : Sieve X) : (S ∈ GrothendieckTopology.sieves (coherentTopology C) X) ↔ (∃ (α : Type) (_ : Finite α) (Y : α → C) (π : (a : α) → (Y a ⟶ X)), EffectiveEpiFamily Y π ∧ (∀ a : α, (S.arrows) (π a)) ) := by
constructor · intro h induction' h with Y T hS Y Y R S _ _ a b · obtain ⟨a, h, Y', π, h', _⟩ := hS refine ⟨a, h, Y', π, inferInstance, fun a' ↦ ?_⟩ obtain ⟨rfl, _⟩ := h' exact ⟨Y' a', 𝟙 Y' a', π a', Presieve.ofArrows.mk a', by simp⟩ · exact ⟨Unit, inferInstance, fun _ => Y, fun _ => (𝟙 Y), inferInstance, by simp⟩ · obtain ⟨α, w, Y₁, π, ⟨h₁,h₂⟩⟩ := a choose β _ Y_n π_n H using fun a => b (h₂ a) exact ⟨(Σ a, β a), inferInstance, fun ⟨a,b⟩ => Y_n a b, fun ⟨a, b⟩ => (π_n a b) ≫ (π a), EffectiveEpiFamily.transitive_of_finite _ h₁ _ (fun a => (H a).1), fun c => (H c.fst).2 c.snd⟩ · exact coherentTopology.mem_sieves_of_hasEffectiveEpiFamily S
/- Copyright (c) 2023 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying -/ import Mathlib.Probability.Kernel.Composition #align_import probability.kernel.invariance from "leanprover-community/mathlib"@"3b92d54a05ee592aa2c6181a4e76b1bb7cc45d0b" /-! # Invariance of measures along a kernel We say that a measure `μ` is invariant with respect to a kernel `κ` if its push-forward along the kernel `μ.bind κ` is the same measure. ## Main definitions * `ProbabilityTheory.kernel.Invariant`: invariance of a given measure with respect to a kernel. ## Useful lemmas * `ProbabilityTheory.kernel.const_bind_eq_comp_const`, and `ProbabilityTheory.kernel.comp_const_apply_eq_bind` established the relationship between the push-forward measure and the composition of kernels. -/ open MeasureTheory open scoped MeasureTheory ENNReal ProbabilityTheory namespace ProbabilityTheory variable {α β γ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} namespace kernel /-! ### Push-forward of measures along a kernel -/ @[simp] theorem bind_add (μ ν : Measure α) (κ : kernel α β) : (μ + ν).bind κ = μ.bind κ + ν.bind κ := by ext1 s hs rw [Measure.bind_apply hs (kernel.measurable _), lintegral_add_measure, Measure.coe_add, Pi.add_apply, Measure.bind_apply hs (kernel.measurable _), Measure.bind_apply hs (kernel.measurable _)] #align probability_theory.kernel.bind_add ProbabilityTheory.kernel.bind_add @[simp] theorem bind_smul (κ : kernel α β) (μ : Measure α) (r : ℝ≥0∞) : (r • μ).bind κ = r • μ.bind κ := by ext1 s hs rw [Measure.bind_apply hs (kernel.measurable _), lintegral_smul_measure, Measure.coe_smul, Pi.smul_apply, Measure.bind_apply hs (kernel.measurable _), smul_eq_mul] #align probability_theory.kernel.bind_smul ProbabilityTheory.kernel.bind_smul
Mathlib/Probability/Kernel/Invariance.lean
57
60
theorem const_bind_eq_comp_const (κ : kernel α β) (μ : Measure α) : const α (μ.bind κ) = κ ∘ₖ const α μ := by
ext a s hs simp_rw [comp_apply' _ _ _ hs, const_apply, Measure.bind_apply hs (kernel.measurable _)]
/- 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.MeasureTheory.Measure.Haar.Basic import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import measure_theory.measure.haar.of_basis from "leanprover-community/mathlib"@"92bd7b1ffeb306a89f450bee126ddd8a284c259d" /-! # Additive Haar measure constructed from a basis Given a basis of a finite-dimensional real vector space, we define the corresponding Lebesgue measure, which gives measure `1` to the parallelepiped spanned by the basis. ## Main definitions * `parallelepiped v` is the parallelepiped spanned by a finite family of vectors. * `Basis.parallelepiped` is the parallelepiped associated to a basis, seen as a compact set with nonempty interior. * `Basis.addHaar` is the Lebesgue measure associated to a basis, giving measure `1` to the corresponding parallelepiped. In particular, we declare a `MeasureSpace` instance on any finite-dimensional inner product space, by using the Lebesgue measure associated to some orthonormal basis (which is in fact independent of the basis). -/ open Set TopologicalSpace MeasureTheory MeasureTheory.Measure FiniteDimensional open scoped Pointwise noncomputable section variable {ι ι' E F : Type*} section Fintype variable [Fintype ι] [Fintype ι'] section AddCommGroup variable [AddCommGroup E] [Module ℝ E] [AddCommGroup F] [Module ℝ F] /-- The closed parallelepiped spanned by a finite family of vectors. -/ def parallelepiped (v : ι → E) : Set E := (fun t : ι → ℝ => ∑ i, t i • v i) '' Icc 0 1 #align parallelepiped parallelepiped theorem mem_parallelepiped_iff (v : ι → E) (x : E) : x ∈ parallelepiped v ↔ ∃ t ∈ Icc (0 : ι → ℝ) 1, x = ∑ i, t i • v i := by simp [parallelepiped, eq_comm] #align mem_parallelepiped_iff mem_parallelepiped_iff
Mathlib/MeasureTheory/Measure/Haar/OfBasis.lean
57
65
theorem parallelepiped_basis_eq (b : Basis ι ℝ E) : parallelepiped b = {x | ∀ i, b.repr x i ∈ Set.Icc 0 1} := by
classical ext x simp_rw [mem_parallelepiped_iff, mem_setOf_eq, b.ext_elem_iff, _root_.map_sum, _root_.map_smul, Finset.sum_apply', Basis.repr_self, Finsupp.smul_single, smul_eq_mul, mul_one, Finsupp.single_apply, Finset.sum_ite_eq', Finset.mem_univ, ite_true, mem_Icc, Pi.le_def, Pi.zero_apply, Pi.one_apply, ← forall_and] aesop
/- Copyright (c) 2022 Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kyle Miller -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Fintype.Card #align_import data.multiset.fintype from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" /-! # Multiset coercion to type This module defines a `CoeSort` instance for multisets and gives it a `Fintype` instance. It also defines `Multiset.toEnumFinset`, which is another way to enumerate the elements of a multiset. These coercions and definitions make it easier to sum over multisets using existing `Finset` theory. ## Main definitions * A coercion from `m : Multiset α` to a `Type*`. Each `x : m` has two components. The first, `x.1`, can be obtained via the coercion `↑x : α`, and it yields the underlying element of the multiset. The second, `x.2`, is a term of `Fin (m.count x)`, and its function is to ensure each term appears with the correct multiplicity. Note that this coercion requires `DecidableEq α` due to the definition using `Multiset.count`. * `Multiset.toEnumFinset` is a `Finset` version of this. * `Multiset.coeEmbedding` is the embedding `m ↪ α × ℕ`, whose first component is the coercion and whose second component enumerates elements with multiplicity. * `Multiset.coeEquiv` is the equivalence `m ≃ m.toEnumFinset`. ## Tags multiset enumeration -/ variable {α : Type*} [DecidableEq α] {m : Multiset α} /-- Auxiliary definition for the `CoeSort` instance. This prevents the `CoeOut m α` instance from inadvertently applying to other sigma types. -/ def Multiset.ToType (m : Multiset α) : Type _ := (x : α) × Fin (m.count x) #align multiset.to_type Multiset.ToType /-- Create a type that has the same number of elements as the multiset. Terms of this type are triples `⟨x, ⟨i, h⟩⟩` where `x : α`, `i : ℕ`, and `h : i < m.count x`. This way repeated elements of a multiset appear multiple times from different values of `i`. -/ instance : CoeSort (Multiset α) (Type _) := ⟨Multiset.ToType⟩ example : DecidableEq m := inferInstanceAs <| DecidableEq ((x : α) × Fin (m.count x)) -- Porting note: syntactic equality #noalign multiset.coe_sort_eq /-- Constructor for terms of the coercion of `m` to a type. This helps Lean pick up the correct instances. -/ @[reducible, match_pattern] def Multiset.mkToType (m : Multiset α) (x : α) (i : Fin (m.count x)) : m := ⟨x, i⟩ #align multiset.mk_to_type Multiset.mkToType /-- As a convenience, there is a coercion from `m : Type*` to `α` by projecting onto the first component. -/ instance instCoeSortMultisetType.instCoeOutToType : CoeOut m α := ⟨fun x ↦ x.1⟩ #align multiset.has_coe_to_sort.has_coe instCoeSortMultisetType.instCoeOutToTypeₓ -- Porting note: syntactic equality #noalign multiset.fst_coe_eq_coe -- Syntactic equality #noalign multiset.coe_eq -- @[simp] -- Porting note (#10685): dsimp can prove this theorem Multiset.coe_mk {x : α} {i : Fin (m.count x)} : ↑(m.mkToType x i) = x := rfl #align multiset.coe_mk Multiset.coe_mk @[simp] lemma Multiset.coe_mem {x : m} : ↑x ∈ m := Multiset.count_pos.mp (by have := x.2.2; omega) #align multiset.coe_mem Multiset.coe_mem @[simp] protected theorem Multiset.forall_coe (p : m → Prop) : (∀ x : m, p x) ↔ ∀ (x : α) (i : Fin (m.count x)), p ⟨x, i⟩ := Sigma.forall #align multiset.forall_coe Multiset.forall_coe @[simp] protected theorem Multiset.exists_coe (p : m → Prop) : (∃ x : m, p x) ↔ ∃ (x : α) (i : Fin (m.count x)), p ⟨x, i⟩ := Sigma.exists #align multiset.exists_coe Multiset.exists_coe instance : Fintype { p : α × ℕ | p.2 < m.count p.1 } := Fintype.ofFinset (m.toFinset.biUnion fun x ↦ (Finset.range (m.count x)).map ⟨Prod.mk x, Prod.mk.inj_left x⟩) (by rintro ⟨x, i⟩ simp only [Finset.mem_biUnion, Multiset.mem_toFinset, Finset.mem_map, Finset.mem_range, Function.Embedding.coeFn_mk, Prod.mk.inj_iff, Set.mem_setOf_eq] simp only [← and_assoc, exists_eq_right, and_iff_right_iff_imp] exact fun h ↦ Multiset.count_pos.mp (by omega)) /-- Construct a finset whose elements enumerate the elements of the multiset `m`. The `ℕ` component is used to differentiate between equal elements: if `x` appears `n` times then `(x, 0)`, ..., and `(x, n-1)` appear in the `Finset`. -/ def Multiset.toEnumFinset (m : Multiset α) : Finset (α × ℕ) := { p : α × ℕ | p.2 < m.count p.1 }.toFinset #align multiset.to_enum_finset Multiset.toEnumFinset @[simp] theorem Multiset.mem_toEnumFinset (m : Multiset α) (p : α × ℕ) : p ∈ m.toEnumFinset ↔ p.2 < m.count p.1 := Set.mem_toFinset #align multiset.mem_to_enum_finset Multiset.mem_toEnumFinset theorem Multiset.mem_of_mem_toEnumFinset {p : α × ℕ} (h : p ∈ m.toEnumFinset) : p.1 ∈ m := have := (m.mem_toEnumFinset p).mp h; Multiset.count_pos.mp (by omega) #align multiset.mem_of_mem_to_enum_finset Multiset.mem_of_mem_toEnumFinset @[mono]
Mathlib/Data/Multiset/Fintype.lean
122
126
theorem Multiset.toEnumFinset_mono {m₁ m₂ : Multiset α} (h : m₁ ≤ m₂) : m₁.toEnumFinset ⊆ m₂.toEnumFinset := by
intro p simp only [Multiset.mem_toEnumFinset] exact gt_of_ge_of_gt (Multiset.le_iff_count.mp h p.1)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Data.Set.Lattice import Mathlib.Data.Set.Pairwise.Basic #align_import data.set.pairwise.lattice from "leanprover-community/mathlib"@"c4c2ed622f43768eff32608d4a0f8a6cec1c047d" /-! # Relations holding pairwise In this file we prove many facts about `Pairwise` and the set lattice. -/ open Function Set Order variable {α β γ ι ι' : Type*} {κ : Sort*} {r p q : α → α → Prop} section Pairwise variable {f g : ι → α} {s t u : Set α} {a b : α} namespace Set theorem pairwise_iUnion {f : κ → Set α} (h : Directed (· ⊆ ·) f) : (⋃ n, f n).Pairwise r ↔ ∀ n, (f n).Pairwise r := by constructor · intro H n exact Pairwise.mono (subset_iUnion _ _) H · intro H i hi j hj hij rcases mem_iUnion.1 hi with ⟨m, hm⟩ rcases mem_iUnion.1 hj with ⟨n, hn⟩ rcases h m n with ⟨p, mp, np⟩ exact H p (mp hm) (np hn) hij #align set.pairwise_Union Set.pairwise_iUnion theorem pairwise_sUnion {r : α → α → Prop} {s : Set (Set α)} (h : DirectedOn (· ⊆ ·) s) : (⋃₀ s).Pairwise r ↔ ∀ a ∈ s, Set.Pairwise a r := by rw [sUnion_eq_iUnion, pairwise_iUnion h.directed_val, SetCoe.forall] #align set.pairwise_sUnion Set.pairwise_sUnion end Set end Pairwise namespace Set section PartialOrderBot variable [PartialOrder α] [OrderBot α] {s t : Set ι} {f g : ι → α} theorem pairwiseDisjoint_iUnion {g : ι' → Set ι} (h : Directed (· ⊆ ·) g) : (⋃ n, g n).PairwiseDisjoint f ↔ ∀ ⦃n⦄, (g n).PairwiseDisjoint f := pairwise_iUnion h #align set.pairwise_disjoint_Union Set.pairwiseDisjoint_iUnion theorem pairwiseDisjoint_sUnion {s : Set (Set ι)} (h : DirectedOn (· ⊆ ·) s) : (⋃₀ s).PairwiseDisjoint f ↔ ∀ ⦃a⦄, a ∈ s → Set.PairwiseDisjoint a f := pairwise_sUnion h #align set.pairwise_disjoint_sUnion Set.pairwiseDisjoint_sUnion end PartialOrderBot section CompleteLattice variable [CompleteLattice α] {s : Set ι} {t : Set ι'} /-- Bind operation for `Set.PairwiseDisjoint`. If you want to only consider finsets of indices, you can use `Set.PairwiseDisjoint.biUnion_finset`. -/ theorem PairwiseDisjoint.biUnion {s : Set ι'} {g : ι' → Set ι} {f : ι → α} (hs : s.PairwiseDisjoint fun i' : ι' => ⨆ i ∈ g i', f i) (hg : ∀ i ∈ s, (g i).PairwiseDisjoint f) : (⋃ i ∈ s, g i).PairwiseDisjoint f := by rintro a ha b hb hab simp_rw [Set.mem_iUnion] at ha hb obtain ⟨c, hc, ha⟩ := ha obtain ⟨d, hd, hb⟩ := hb obtain hcd | hcd := eq_or_ne (g c) (g d) · exact hg d hd (hcd.subst ha) hb hab -- Porting note: the elaborator couldn't figure out `f` here. · exact (hs hc hd <| ne_of_apply_ne _ hcd).mono (le_iSup₂ (f := fun i (_ : i ∈ g c) => f i) a ha) (le_iSup₂ (f := fun i (_ : i ∈ g d) => f i) b hb) #align set.pairwise_disjoint.bUnion Set.PairwiseDisjoint.biUnion /-- If the suprema of columns are pairwise disjoint and suprema of rows as well, then everything is pairwise disjoint. Not to be confused with `Set.PairwiseDisjoint.prod`. -/
Mathlib/Data/Set/Pairwise/Lattice.lean
89
101
theorem PairwiseDisjoint.prod_left {f : ι × ι' → α} (hs : s.PairwiseDisjoint fun i => ⨆ i' ∈ t, f (i, i')) (ht : t.PairwiseDisjoint fun i' => ⨆ i ∈ s, f (i, i')) : (s ×ˢ t : Set (ι × ι')).PairwiseDisjoint f := by
rintro ⟨i, i'⟩ hi ⟨j, j'⟩ hj h rw [mem_prod] at hi hj obtain rfl | hij := eq_or_ne i j · refine (ht hi.2 hj.2 <| (Prod.mk.inj_left _).ne_iff.1 h).mono ?_ ?_ · convert le_iSup₂ (α := α) i hi.1; rfl · convert le_iSup₂ (α := α) i hj.1; rfl · refine (hs hi.1 hj.1 hij).mono ?_ ?_ · convert le_iSup₂ (α := α) i' hi.2; rfl · convert le_iSup₂ (α := α) j' hj.2; rfl
/- Copyright (c) 2019 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau -/ import Mathlib.Algebra.CharP.ExpChar import Mathlib.Algebra.GeomSum import Mathlib.Algebra.MvPolynomial.CommRing import Mathlib.Algebra.MvPolynomial.Equiv import Mathlib.RingTheory.Polynomial.Content import Mathlib.RingTheory.UniqueFactorizationDomain #align_import ring_theory.polynomial.basic from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" /-! # Ring-theoretic supplement of Algebra.Polynomial. ## Main results * `MvPolynomial.isDomain`: If a ring is an integral domain, then so is its polynomial ring over finitely many variables. * `Polynomial.isNoetherianRing`: Hilbert basis theorem, that if a ring is noetherian then so is its polynomial ring. * `Polynomial.wfDvdMonoid`: If an integral domain is a `WFDvdMonoid`, then so is its polynomial ring. * `Polynomial.uniqueFactorizationMonoid`, `MvPolynomial.uniqueFactorizationMonoid`: If an integral domain is a `UniqueFactorizationMonoid`, then so is its polynomial ring (of any number of variables). -/ noncomputable section open Polynomial open Finset universe u v w variable {R : Type u} {S : Type*} namespace Polynomial section Semiring variable [Semiring R] instance instCharP (p : ℕ) [h : CharP R p] : CharP R[X] p := let ⟨h⟩ := h ⟨fun n => by rw [← map_natCast C, ← C_0, C_inj, h]⟩ instance instExpChar (p : ℕ) [h : ExpChar R p] : ExpChar R[X] p := by cases h; exacts [ExpChar.zero, ExpChar.prime ‹_›] variable (R) /-- The `R`-submodule of `R[X]` consisting of polynomials of degree ≤ `n`. -/ def degreeLE (n : WithBot ℕ) : Submodule R R[X] := ⨅ k : ℕ, ⨅ _ : ↑k > n, LinearMap.ker (lcoeff R k) #align polynomial.degree_le Polynomial.degreeLE /-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/ def degreeLT (n : ℕ) : Submodule R R[X] := ⨅ k : ℕ, ⨅ (_ : k ≥ n), LinearMap.ker (lcoeff R k) #align polynomial.degree_lt Polynomial.degreeLT variable {R} theorem mem_degreeLE {n : WithBot ℕ} {f : R[X]} : f ∈ degreeLE R n ↔ degree f ≤ n := by simp only [degreeLE, Submodule.mem_iInf, degree_le_iff_coeff_zero, LinearMap.mem_ker]; rfl #align polynomial.mem_degree_le Polynomial.mem_degreeLE @[mono] theorem degreeLE_mono {m n : WithBot ℕ} (H : m ≤ n) : degreeLE R m ≤ degreeLE R n := fun _ hf => mem_degreeLE.2 (le_trans (mem_degreeLE.1 hf) H) #align polynomial.degree_le_mono Polynomial.degreeLE_mono theorem degreeLE_eq_span_X_pow [DecidableEq R] {n : ℕ} : degreeLE R n = Submodule.span R ↑((Finset.range (n + 1)).image fun n => (X : R[X]) ^ n) := by apply le_antisymm · intro p hp replace hp := mem_degreeLE.1 hp rw [← Polynomial.sum_monomial_eq p, Polynomial.sum] refine Submodule.sum_mem _ fun k hk => ?_ have := WithBot.coe_le_coe.1 (Finset.sup_le_iff.1 hp k hk) rw [← C_mul_X_pow_eq_monomial, C_mul'] refine Submodule.smul_mem _ _ (Submodule.subset_span <| Finset.mem_coe.2 <| Finset.mem_image.2 ⟨_, Finset.mem_range.2 (Nat.lt_succ_of_le this), rfl⟩) rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff] intro k hk apply mem_degreeLE.2 exact (degree_X_pow_le _).trans (WithBot.coe_le_coe.2 <| Nat.le_of_lt_succ <| Finset.mem_range.1 hk) set_option linter.uppercaseLean3 false in #align polynomial.degree_le_eq_span_X_pow Polynomial.degreeLE_eq_span_X_pow theorem mem_degreeLT {n : ℕ} {f : R[X]} : f ∈ degreeLT R n ↔ degree f < n := by rw [degreeLT, Submodule.mem_iInf] conv_lhs => intro i; rw [Submodule.mem_iInf] rw [degree, Finset.max_eq_sup_coe] rw [Finset.sup_lt_iff ?_] rotate_left · apply WithBot.bot_lt_coe conv_rhs => simp only [mem_support_iff] intro b rw [Nat.cast_withBot, WithBot.coe_lt_coe, lt_iff_not_le, Ne, not_imp_not] rfl #align polynomial.mem_degree_lt Polynomial.mem_degreeLT @[mono] theorem degreeLT_mono {m n : ℕ} (H : m ≤ n) : degreeLT R m ≤ degreeLT R n := fun _ hf => mem_degreeLT.2 (lt_of_lt_of_le (mem_degreeLT.1 hf) <| WithBot.coe_le_coe.2 H) #align polynomial.degree_lt_mono Polynomial.degreeLT_mono
Mathlib/RingTheory/Polynomial/Basic.lean
117
133
theorem degreeLT_eq_span_X_pow [DecidableEq R] {n : ℕ} : degreeLT R n = Submodule.span R ↑((Finset.range n).image fun n => X ^ n : Finset R[X]) := by
apply le_antisymm · intro p hp replace hp := mem_degreeLT.1 hp rw [← Polynomial.sum_monomial_eq p, Polynomial.sum] refine Submodule.sum_mem _ fun k hk => ?_ have := WithBot.coe_lt_coe.1 ((Finset.sup_lt_iff <| WithBot.bot_lt_coe n).1 hp k hk) rw [← C_mul_X_pow_eq_monomial, C_mul'] refine Submodule.smul_mem _ _ (Submodule.subset_span <| Finset.mem_coe.2 <| Finset.mem_image.2 ⟨_, Finset.mem_range.2 this, rfl⟩) rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff] intro k hk apply mem_degreeLT.2 exact lt_of_le_of_lt (degree_X_pow_le _) (WithBot.coe_lt_coe.2 <| Finset.mem_range.1 hk)
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Kenny Lau, Robert Y. Lewis -/ import Mathlib.Algebra.Group.Defs #align_import group_theory.eckmann_hilton from "leanprover-community/mathlib"@"41cf0cc2f528dd40a8f2db167ea4fb37b8fde7f3" /-! # Eckmann-Hilton argument The Eckmann-Hilton argument says that if a type carries two monoid structures that distribute over one another, then they are equal, and in addition commutative. The main application lies in proving that higher homotopy groups (`πₙ` for `n ≥ 2`) are commutative. ## Main declarations * `EckmannHilton.commMonoid`: If a type carries a unital magma structure that distributes over a unital binary operation, then the magma is a commutative monoid. * `EckmannHilton.commGroup`: If a type carries a group structure that distributes over a unital binary operation, then the group is commutative. -/ universe u namespace EckmannHilton variable {X : Type u} /-- Local notation for `m a b`. -/ local notation a " <" m:51 "> " b => m a b /-- `IsUnital m e` expresses that `e : X` is a left and right unit for the binary operation `m : X → X → X`. -/ structure IsUnital (m : X → X → X) (e : X) extends Std.LawfulIdentity m e : Prop #align eckmann_hilton.is_unital EckmannHilton.IsUnital @[to_additive EckmannHilton.AddZeroClass.IsUnital] theorem MulOneClass.isUnital [_G : MulOneClass X] : IsUnital (· * ·) (1 : X) := IsUnital.mk { left_id := MulOneClass.one_mul, right_id := MulOneClass.mul_one } #align eckmann_hilton.mul_one_class.is_unital EckmannHilton.MulOneClass.isUnital #align eckmann_hilton.add_zero_class.is_unital EckmannHilton.AddZeroClass.IsUnital variable {m₁ m₂ : X → X → X} {e₁ e₂ : X} variable (h₁ : IsUnital m₁ e₁) (h₂ : IsUnital m₂ e₂) variable (distrib : ∀ a b c d, ((a <m₂> b) <m₁> c <m₂> d) = (a <m₁> c) <m₂> b <m₁> d) /-- If a type carries two unital binary operations that distribute over each other, then they have the same unit elements. In fact, the two operations are the same, and give a commutative monoid structure, see `eckmann_hilton.CommMonoid`. -/ theorem one : e₁ = e₂ := by simpa only [h₁.left_id, h₁.right_id, h₂.left_id, h₂.right_id] using distrib e₂ e₁ e₁ e₂ #align eckmann_hilton.one EckmannHilton.one /-- If a type carries two unital binary operations that distribute over each other, then these operations are equal. In fact, they give a commutative monoid structure, see `eckmann_hilton.CommMonoid`. -/
Mathlib/GroupTheory/EckmannHilton.lean
64
69
theorem mul : m₁ = m₂ := by
funext a b calc m₁ a b = m₁ (m₂ a e₁) (m₂ e₁ b) := by { simp only [one h₁ h₂ distrib, h₁.left_id, h₁.right_id, h₂.left_id, h₂.right_id] } _ = m₂ a b := by simp only [distrib, h₁.left_id, h₁.right_id, h₂.left_id, h₂.right_id]
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Init.Function #align_import data.option.n_ary from "leanprover-community/mathlib"@"995b47e555f1b6297c7cf16855f1023e355219fb" /-! # Binary map of options This file defines the binary map of `Option`. This is mostly useful to define pointwise operations on intervals. ## Main declarations * `Option.map₂`: Binary map of options. ## Notes This file is very similar to the n-ary section of `Mathlib.Data.Set.Basic`, to `Mathlib.Data.Finset.NAry` and to `Mathlib.Order.Filter.NAry`. Please keep them in sync. (porting note - only some of these may exist right now!) We do not define `Option.map₃` as its only purpose so far would be to prove properties of `Option.map₂` and casing already fulfills this task. -/ universe u open Function namespace Option variable {α β γ δ : Type*} {f : α → β → γ} {a : Option α} {b : Option β} {c : Option γ} /-- The image of a binary function `f : α → β → γ` as a function `Option α → Option β → Option γ`. Mathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/ def map₂ (f : α → β → γ) (a : Option α) (b : Option β) : Option γ := a.bind fun a => b.map <| f a #align option.map₂ Option.map₂ /-- `Option.map₂` in terms of monadic operations. Note that this can't be taken as the definition because of the lack of universe polymorphism. -/ theorem map₂_def {α β γ : Type u} (f : α → β → γ) (a : Option α) (b : Option β) : map₂ f a b = f <$> a <*> b := by cases a <;> rfl #align option.map₂_def Option.map₂_def -- Porting note (#10618): In Lean3, was `@[simp]` but now `simp` can prove it theorem map₂_some_some (f : α → β → γ) (a : α) (b : β) : map₂ f (some a) (some b) = f a b := rfl #align option.map₂_some_some Option.map₂_some_some theorem map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b := rfl #align option.map₂_coe_coe Option.map₂_coe_coe @[simp] theorem map₂_none_left (f : α → β → γ) (b : Option β) : map₂ f none b = none := rfl #align option.map₂_none_left Option.map₂_none_left @[simp] theorem map₂_none_right (f : α → β → γ) (a : Option α) : map₂ f a none = none := by cases a <;> rfl #align option.map₂_none_right Option.map₂_none_right @[simp] theorem map₂_coe_left (f : α → β → γ) (a : α) (b : Option β) : map₂ f a b = b.map fun b => f a b := rfl #align option.map₂_coe_left Option.map₂_coe_left -- Porting note: This proof was `rfl` in Lean3, but now is not. @[simp] theorem map₂_coe_right (f : α → β → γ) (a : Option α) (b : β) : map₂ f a b = a.map fun a => f a b := by cases a <;> rfl #align option.map₂_coe_right Option.map₂_coe_right -- Porting note: Removed the `@[simp]` tag as membership of an `Option` is no-longer simp-normal. theorem mem_map₂_iff {c : γ} : c ∈ map₂ f a b ↔ ∃ a' b', a' ∈ a ∧ b' ∈ b ∧ f a' b' = c := by simp [map₂, bind_eq_some] #align option.mem_map₂_iff Option.mem_map₂_iff @[simp] theorem map₂_eq_none_iff : map₂ f a b = none ↔ a = none ∨ b = none := by cases a <;> cases b <;> simp #align option.map₂_eq_none_iff Option.map₂_eq_none_iff theorem map₂_swap (f : α → β → γ) (a : Option α) (b : Option β) : map₂ f a b = map₂ (fun a b => f b a) b a := by cases a <;> cases b <;> rfl #align option.map₂_swap Option.map₂_swap theorem map_map₂ (f : α → β → γ) (g : γ → δ) : (map₂ f a b).map g = map₂ (fun a b => g (f a b)) a b := by cases a <;> cases b <;> rfl #align option.map_map₂ Option.map_map₂ theorem map₂_map_left (f : γ → β → δ) (g : α → γ) : map₂ f (a.map g) b = map₂ (fun a b => f (g a) b) a b := by cases a <;> rfl #align option.map₂_map_left Option.map₂_map_left theorem map₂_map_right (f : α → γ → δ) (g : β → γ) : map₂ f a (b.map g) = map₂ (fun a b => f a (g b)) a b := by cases b <;> rfl #align option.map₂_map_right Option.map₂_map_right @[simp] theorem map₂_curry (f : α × β → γ) (a : Option α) (b : Option β) : map₂ (curry f) a b = Option.map f (map₂ Prod.mk a b) := (map_map₂ _ _).symm #align option.map₂_curry Option.map₂_curry @[simp]
Mathlib/Data/Option/NAry.lean
109
110
theorem map_uncurry (f : α → β → γ) (x : Option (α × β)) : x.map (uncurry f) = map₂ f (x.map Prod.fst) (x.map Prod.snd) := by
cases x <;> rfl
/- 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.Analysis.SpecialFunctions.Complex.Log import Mathlib.RingTheory.RootsOfUnity.Basic #align_import ring_theory.roots_of_unity.complex from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f" /-! # Complex roots of unity In this file we show that the `n`-th complex roots of unity are exactly the complex numbers `exp (2 * π * I * (i / n))` for `i ∈ Finset.range n`. ## Main declarations * `Complex.mem_rootsOfUnity`: the complex `n`-th roots of unity are exactly the complex numbers of the form `exp (2 * π * I * (i / n))` for some `i < n`. * `Complex.card_rootsOfUnity`: the number of `n`-th roots of unity is exactly `n`. * `Complex.norm_rootOfUnity_eq_one`: A complex root of unity has norm `1`. -/ namespace Complex open Polynomial Real open scoped Nat Real
Mathlib/RingTheory/RootsOfUnity/Complex.lean
33
50
theorem isPrimitiveRoot_exp_of_coprime (i n : ℕ) (h0 : n ≠ 0) (hi : i.Coprime n) : IsPrimitiveRoot (exp (2 * π * I * (i / n))) n := by
rw [IsPrimitiveRoot.iff_def] simp only [← exp_nat_mul, exp_eq_one_iff] have hn0 : (n : ℂ) ≠ 0 := mod_cast h0 constructor · use i field_simp [hn0, mul_comm (i : ℂ), mul_comm (n : ℂ)] · simp only [hn0, mul_right_comm _ _ ↑n, mul_left_inj' two_pi_I_ne_zero, Ne, not_false_iff, mul_comm _ (i : ℂ), ← mul_assoc _ (i : ℂ), exists_imp, field_simps] norm_cast rintro l k hk conv_rhs at hk => rw [mul_comm, ← mul_assoc] have hz : 2 * ↑π * I ≠ 0 := by simp [pi_pos.ne.symm, I_ne_zero] field_simp [hz] at hk norm_cast at hk have : n ∣ i * l := by rw [← Int.natCast_dvd_natCast, hk, mul_comm]; apply dvd_mul_left exact hi.symm.dvd_of_dvd_mul_left this
/- 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, Yury Kudryashov -/ import Mathlib.Topology.Order.LeftRightNhds /-! # Properties of LUB and GLB in an order topology -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) variable {α β γ : Type*} section OrderTopology variable [TopologicalSpace α] [TopologicalSpace β] [LinearOrder α] [LinearOrder β] [OrderTopology α] [OrderTopology β] theorem IsLUB.frequently_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝[≤] a, x ∈ s := by rcases hs with ⟨a', ha'⟩ intro h rcases (ha.1 ha').eq_or_lt with (rfl | ha'a) · exact h.self_of_nhdsWithin le_rfl ha' · rcases (mem_nhdsWithin_Iic_iff_exists_Ioc_subset' ha'a).1 h with ⟨b, hba, hb⟩ rcases ha.exists_between hba with ⟨b', hb's, hb'⟩ exact hb hb' hb's #align is_lub.frequently_mem IsLUB.frequently_mem theorem IsLUB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝 a, x ∈ s := (ha.frequently_mem hs).filter_mono inf_le_left #align is_lub.frequently_nhds_mem IsLUB.frequently_nhds_mem theorem IsGLB.frequently_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝[≥] a, x ∈ s := IsLUB.frequently_mem (α := αᵒᵈ) ha hs #align is_glb.frequently_mem IsGLB.frequently_mem theorem IsGLB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝 a, x ∈ s := (ha.frequently_mem hs).filter_mono inf_le_left #align is_glb.frequently_nhds_mem IsGLB.frequently_nhds_mem theorem IsLUB.mem_closure {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : a ∈ closure s := (ha.frequently_nhds_mem hs).mem_closure #align is_lub.mem_closure IsLUB.mem_closure theorem IsGLB.mem_closure {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : a ∈ closure s := (ha.frequently_nhds_mem hs).mem_closure #align is_glb.mem_closure IsGLB.mem_closure theorem IsLUB.nhdsWithin_neBot {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : NeBot (𝓝[s] a) := mem_closure_iff_nhdsWithin_neBot.1 (ha.mem_closure hs) #align is_lub.nhds_within_ne_bot IsLUB.nhdsWithin_neBot theorem IsGLB.nhdsWithin_neBot : ∀ {a : α} {s : Set α}, IsGLB s a → s.Nonempty → NeBot (𝓝[s] a) := IsLUB.nhdsWithin_neBot (α := αᵒᵈ) #align is_glb.nhds_within_ne_bot IsGLB.nhdsWithin_neBot theorem isLUB_of_mem_nhds {s : Set α} {a : α} {f : Filter α} (hsa : a ∈ upperBounds s) (hsf : s ∈ f) [NeBot (f ⊓ 𝓝 a)] : IsLUB s a := ⟨hsa, fun b hb => not_lt.1 fun hba => have : s ∩ { a | b < a } ∈ f ⊓ 𝓝 a := inter_mem_inf hsf (IsOpen.mem_nhds (isOpen_lt' _) hba) let ⟨_x, ⟨hxs, hxb⟩⟩ := Filter.nonempty_of_mem this have : b < b := lt_of_lt_of_le hxb <| hb hxs lt_irrefl b this⟩ #align is_lub_of_mem_nhds isLUB_of_mem_nhds
Mathlib/Topology/Order/IsLUB.lean
77
80
theorem isLUB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ upperBounds s) (hsf : a ∈ closure s) : IsLUB s a := by
rw [mem_closure_iff_clusterPt, ClusterPt, inf_comm] at hsf exact isLUB_of_mem_nhds hsa (mem_principal_self s)
/- Copyright (c) 2024 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Chambert-Loir, Oliver Nash -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Identities import Mathlib.RingTheory.Nilpotent.Lemmas import Mathlib.RingTheory.Polynomial.Nilpotent import Mathlib.RingTheory.Polynomial.Tower /-! # Newton-Raphson method Given a single-variable polynomial `P` with derivative `P'`, Newton's method concerns iteration of the rational map: `x ↦ x - P(x) / P'(x)`. Over a field it can serve as a root-finding algorithm. It is also useful tool in certain proofs such as Hensel's lemma and Jordan-Chevalley decomposition. ## Main definitions / results: * `Polynomial.newtonMap`: the map `x ↦ x - P(x) / P'(x)`, where `P'` is the derivative of the polynomial `P`. * `Polynomial.isFixedPt_newtonMap_of_isUnit_iff`: `x` is a fixed point for Newton iteration iff it is a root of `P` (provided `P'(x)` is a unit). * `Polynomial.exists_unique_nilpotent_sub_and_aeval_eq_zero`: if `x` is almost a root of `P` in the sense that `P(x)` is nilpotent (and `P'(x)` is a unit) then we may write `x` as a sum `x = n + r` where `n` is nilpotent and `r` is a root of `P`. This can be used to prove the Jordan-Chevalley decomposition of linear endomorphims. -/ open Set Function noncomputable section namespace Polynomial variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] (P : R[X]) {x : S} /-- Given a single-variable polynomial `P` with derivative `P'`, this is the map: `x ↦ x - P(x) / P'(x)`. When `P'(x)` is not a unit we use a junk-value pattern and send `x ↦ x`. -/ def newtonMap (x : S) : S := x - (Ring.inverse <| aeval x (derivative P)) * aeval x P theorem newtonMap_apply : P.newtonMap x = x - (Ring.inverse <| aeval x (derivative P)) * (aeval x P) := rfl variable {P}
Mathlib/Dynamics/Newton.lean
53
55
theorem newtonMap_apply_of_isUnit (h : IsUnit <| aeval x (derivative P)) : P.newtonMap x = x - h.unit⁻¹ * aeval x P := by
simp [newtonMap_apply, Ring.inverse, h]
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.CategoryTheory.Limits.Shapes.SplitCoequalizer import Mathlib.CategoryTheory.Limits.Preserves.Basic #align_import category_theory.limits.preserves.shapes.equalizers from "leanprover-community/mathlib"@"4698e35ca56a0d4fa53aa5639c3364e0a77f4eba" /-! # Preserving (co)equalizers Constructions to relate the notions of preserving (co)equalizers and reflecting (co)equalizers to concrete (co)forks. In particular, we show that `equalizerComparison f g G` is an isomorphism iff `G` preserves the limit of the parallel pair `f,g`, as well as the dual result. -/ noncomputable section universe w v₁ v₂ u₁ u₂ open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] variable {D : Type u₂} [Category.{v₂} D] variable (G : C ⥤ D) namespace CategoryTheory.Limits section Equalizers variable {X Y Z : C} {f g : X ⟶ Y} {h : Z ⟶ X} (w : h ≫ f = h ≫ g) /-- The map of a fork is a limit iff the fork consisting of the mapped morphisms is a limit. This essentially lets us commute `Fork.ofι` with `Functor.mapCone`. -/ def isLimitMapConeForkEquiv : IsLimit (G.mapCone (Fork.ofι h w)) ≃ IsLimit (Fork.ofι (G.map h) (by simp only [← G.map_comp, w]) : Fork (G.map f) (G.map g)) := (IsLimit.postcomposeHomEquiv (diagramIsoParallelPair _) _).symm.trans (IsLimit.equivIsoLimit (Fork.ext (Iso.refl _) (by simp [Fork.ι]))) #align category_theory.limits.is_limit_map_cone_fork_equiv CategoryTheory.Limits.isLimitMapConeForkEquiv /-- The property of preserving equalizers expressed in terms of forks. -/ def isLimitForkMapOfIsLimit [PreservesLimit (parallelPair f g) G] (l : IsLimit (Fork.ofι h w)) : IsLimit (Fork.ofι (G.map h) (by simp only [← G.map_comp, w]) : Fork (G.map f) (G.map g)) := isLimitMapConeForkEquiv G w (PreservesLimit.preserves l) #align category_theory.limits.is_limit_fork_map_of_is_limit CategoryTheory.Limits.isLimitForkMapOfIsLimit /-- The property of reflecting equalizers expressed in terms of forks. -/ def isLimitOfIsLimitForkMap [ReflectsLimit (parallelPair f g) G] (l : IsLimit (Fork.ofι (G.map h) (by simp only [← G.map_comp, w]) : Fork (G.map f) (G.map g))) : IsLimit (Fork.ofι h w) := ReflectsLimit.reflects ((isLimitMapConeForkEquiv G w).symm l) #align category_theory.limits.is_limit_of_is_limit_fork_map CategoryTheory.Limits.isLimitOfIsLimitForkMap variable (f g) [HasEqualizer f g] /-- If `G` preserves equalizers and `C` has them, then the fork constructed of the mapped morphisms of a fork is a limit. -/ def isLimitOfHasEqualizerOfPreservesLimit [PreservesLimit (parallelPair f g) G] : IsLimit (Fork.ofι (G.map (equalizer.ι f g)) (by simp only [← G.map_comp]; rw [equalizer.condition]) : Fork (G.map f) (G.map g)) := isLimitForkMapOfIsLimit G _ (equalizerIsEqualizer f g) #align category_theory.limits.is_limit_of_has_equalizer_of_preserves_limit CategoryTheory.Limits.isLimitOfHasEqualizerOfPreservesLimit variable [HasEqualizer (G.map f) (G.map g)] /-- If the equalizer comparison map for `G` at `(f,g)` is an isomorphism, then `G` preserves the equalizer of `(f,g)`. -/ def PreservesEqualizer.ofIsoComparison [i : IsIso (equalizerComparison f g G)] : PreservesLimit (parallelPair f g) G := by apply preservesLimitOfPreservesLimitCone (equalizerIsEqualizer f g) apply (isLimitMapConeForkEquiv _ _).symm _ refine @IsLimit.ofPointIso _ _ _ _ _ _ _ (limit.isLimit (parallelPair (G.map f) (G.map g))) ?_ apply i #align category_theory.limits.preserves_equalizer.of_iso_comparison CategoryTheory.Limits.PreservesEqualizer.ofIsoComparison variable [PreservesLimit (parallelPair f g) G] /-- If `G` preserves the equalizer of `(f,g)`, then the equalizer comparison map for `G` at `(f,g)` is an isomorphism. -/ def PreservesEqualizer.iso : G.obj (equalizer f g) ≅ equalizer (G.map f) (G.map g) := IsLimit.conePointUniqueUpToIso (isLimitOfHasEqualizerOfPreservesLimit G f g) (limit.isLimit _) #align category_theory.limits.preserves_equalizer.iso CategoryTheory.Limits.PreservesEqualizer.iso @[simp] theorem PreservesEqualizer.iso_hom : (PreservesEqualizer.iso G f g).hom = equalizerComparison f g G := rfl #align category_theory.limits.preserves_equalizer.iso_hom CategoryTheory.Limits.PreservesEqualizer.iso_hom @[simp]
Mathlib/CategoryTheory/Limits/Preserves/Shapes/Equalizers.lean
104
108
theorem PreservesEqualizer.iso_inv_ι : (PreservesEqualizer.iso G f g).inv ≫ G.map (equalizer.ι f g) = equalizer.ι (G.map f) (G.map g) := by
rw [← Iso.cancel_iso_hom_left (PreservesEqualizer.iso G f g), ← Category.assoc, Iso.hom_inv_id] simp
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Data.Finset.Sigma import Mathlib.Data.Fintype.Card #align_import data.finset.pi_induction from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6" /-! # Induction principles for `∀ i, Finset (α i)` In this file we prove a few induction principles for functions `Π i : ι, Finset (α i)` defined on a finite type. * `Finset.induction_on_pi` is a generic lemma that requires only `[Finite ι]`, `[DecidableEq ι]`, and `[∀ i, DecidableEq (α i)]`; this version can be seen as a direct generalization of `Finset.induction_on`. * `Finset.induction_on_pi_max` and `Finset.induction_on_pi_min`: generalizations of `Finset.induction_on_max`; these versions require `∀ i, LinearOrder (α i)` but assume `∀ y ∈ g i, y < x` and `∀ y ∈ g i, x < y` respectively in the induction step. ## Tags finite set, finite type, induction, function -/ open Function variable {ι : Type*} {α : ι → Type*} [Finite ι] [DecidableEq ι] [∀ i, DecidableEq (α i)] namespace Finset /-- General theorem for `Finset.induction_on_pi`-style induction principles. -/
Mathlib/Data/Finset/PiInduction.lean
37
63
theorem induction_on_pi_of_choice (r : ∀ i, α i → Finset (α i) → Prop) (H_ex : ∀ (i) (s : Finset (α i)), s.Nonempty → ∃ x ∈ s, r i x (s.erase x)) {p : (∀ i, Finset (α i)) → Prop} (f : ∀ i, Finset (α i)) (h0 : p fun _ ↦ ∅) (step : ∀ (g : ∀ i, Finset (α i)) (i : ι) (x : α i), r i x (g i) → p g → p (update g i (insert x (g i)))) : p f := by
cases nonempty_fintype ι induction' hs : univ.sigma f using Finset.strongInductionOn with s ihs generalizing f; subst s rcases eq_empty_or_nonempty (univ.sigma f) with he | hne · convert h0 using 1 simpa [funext_iff] using he · rcases sigma_nonempty.1 hne with ⟨i, -, hi⟩ rcases H_ex i (f i) hi with ⟨x, x_mem, hr⟩ set g := update f i ((f i).erase x) with hg clear_value g have hx' : x ∉ g i := by rw [hg, update_same] apply not_mem_erase rw [show f = update g i (insert x (g i)) by rw [hg, update_idem, update_same, insert_erase x_mem, update_eq_self]] at hr ihs ⊢ clear hg rw [update_same, erase_insert hx'] at hr refine step _ _ _ hr (ihs (univ.sigma g) ?_ _ rfl) rw [ssubset_iff_of_subset (sigma_mono (Subset.refl _) _)] exacts [⟨⟨i, x⟩, mem_sigma.2 ⟨mem_univ _, by simp⟩, by simp [hx']⟩, (@le_update_iff _ _ _ _ g g i _).2 ⟨subset_insert _ _, fun _ _ ↦ le_rfl⟩]
/- Copyright (c) 2021 Bryan Gin-ge Chen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bryan Gin-ge Chen, Yaël Dillies -/ import Mathlib.Algebra.PUnitInstances import Mathlib.Tactic.Abel import Mathlib.Tactic.Ring import Mathlib.Order.Hom.Lattice #align_import algebra.ring.boolean_ring from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Boolean rings A Boolean ring is a ring where multiplication is idempotent. They are equivalent to Boolean algebras. ## Main declarations * `BooleanRing`: a typeclass for rings where multiplication is idempotent. * `BooleanRing.toBooleanAlgebra`: Turn a Boolean ring into a Boolean algebra. * `BooleanAlgebra.toBooleanRing`: Turn a Boolean algebra into a Boolean ring. * `AsBoolAlg`: Type-synonym for the Boolean algebra associated to a Boolean ring. * `AsBoolRing`: Type-synonym for the Boolean ring associated to a Boolean algebra. ## Implementation notes We provide two ways of turning a Boolean algebra/ring into a Boolean ring/algebra: * Instances on the same type accessible in locales `BooleanAlgebraOfBooleanRing` and `BooleanRingOfBooleanAlgebra`. * Type-synonyms `AsBoolAlg` and `AsBoolRing`. At this point in time, it is not clear the first way is useful, but we keep it for educational purposes and because it is easier than dealing with `ofBoolAlg`/`toBoolAlg`/`ofBoolRing`/`toBoolRing` explicitly. ## Tags boolean ring, boolean algebra -/ open scoped symmDiff variable {α β γ : Type*} /-- A Boolean ring is a ring where multiplication is idempotent. -/ class BooleanRing (α) extends Ring α where /-- Multiplication in a boolean ring is idempotent. -/ mul_self : ∀ a : α, a * a = a #align boolean_ring BooleanRing section BooleanRing variable [BooleanRing α] (a b : α) instance : Std.IdempotentOp (α := α) (· * ·) := ⟨BooleanRing.mul_self⟩ @[simp] theorem mul_self : a * a = a := BooleanRing.mul_self _ #align mul_self mul_self @[simp] theorem add_self : a + a = 0 := by have : a + a = a + a + (a + a) := calc a + a = (a + a) * (a + a) := by rw [mul_self] _ = a * a + a * a + (a * a + a * a) := by rw [add_mul, mul_add] _ = a + a + (a + a) := by rw [mul_self] rwa [self_eq_add_left] at this #align add_self add_self @[simp] theorem neg_eq : -a = a := calc -a = -a + 0 := by rw [add_zero] _ = -a + -a + a := by rw [← neg_add_self, add_assoc] _ = a := by rw [add_self, zero_add] #align neg_eq neg_eq theorem add_eq_zero' : a + b = 0 ↔ a = b := calc a + b = 0 ↔ a = -b := add_eq_zero_iff_eq_neg _ ↔ a = b := by rw [neg_eq] #align add_eq_zero' add_eq_zero' @[simp] theorem mul_add_mul : a * b + b * a = 0 := by have : a + b = a + b + (a * b + b * a) := calc a + b = (a + b) * (a + b) := by rw [mul_self] _ = a * a + a * b + (b * a + b * b) := by rw [add_mul, mul_add, mul_add] _ = a + a * b + (b * a + b) := by simp only [mul_self] _ = a + b + (a * b + b * a) := by abel rwa [self_eq_add_right] at this #align mul_add_mul mul_add_mul @[simp]
Mathlib/Algebra/Ring/BooleanRing.lean
101
101
theorem sub_eq_add : a - b = a + b := by
rw [sub_eq_add_neg, add_right_inj, neg_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.Order.Interval.Finset.Nat #align_import data.fin.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" /-! # Finite intervals in `Fin n` This file proves that `Fin n` is a `LocallyFiniteOrder` and calculates the cardinality of its intervals as Finsets and Fintypes. -/ assert_not_exists MonoidWithZero namespace Fin variable {n : ℕ} (a b : Fin n) @[simp, norm_cast] theorem coe_sup : ↑(a ⊔ b) = (a ⊔ b : ℕ) := rfl #align fin.coe_sup Fin.coe_sup @[simp, norm_cast] theorem coe_inf : ↑(a ⊓ b) = (a ⊓ b : ℕ) := rfl #align fin.coe_inf Fin.coe_inf @[simp, norm_cast] theorem coe_max : ↑(max a b) = (max a b : ℕ) := rfl #align fin.coe_max Fin.coe_max @[simp, norm_cast] theorem coe_min : ↑(min a b) = (min a b : ℕ) := rfl #align fin.coe_min Fin.coe_min end Fin open Finset Fin Function namespace Fin variable (n : ℕ) instance instLocallyFiniteOrder : LocallyFiniteOrder (Fin n) := OrderIso.locallyFiniteOrder Fin.orderIsoSubtype instance instLocallyFiniteOrderBot : LocallyFiniteOrderBot (Fin n) := OrderIso.locallyFiniteOrderBot Fin.orderIsoSubtype instance instLocallyFiniteOrderTop : ∀ n, LocallyFiniteOrderTop (Fin n) | 0 => IsEmpty.toLocallyFiniteOrderTop | _ + 1 => inferInstance variable {n} (a b : Fin n) theorem Icc_eq_finset_subtype : Icc a b = (Icc (a : ℕ) b).fin n := rfl #align fin.Icc_eq_finset_subtype Fin.Icc_eq_finset_subtype theorem Ico_eq_finset_subtype : Ico a b = (Ico (a : ℕ) b).fin n := rfl #align fin.Ico_eq_finset_subtype Fin.Ico_eq_finset_subtype theorem Ioc_eq_finset_subtype : Ioc a b = (Ioc (a : ℕ) b).fin n := rfl #align fin.Ioc_eq_finset_subtype Fin.Ioc_eq_finset_subtype theorem Ioo_eq_finset_subtype : Ioo a b = (Ioo (a : ℕ) b).fin n := rfl #align fin.Ioo_eq_finset_subtype Fin.Ioo_eq_finset_subtype theorem uIcc_eq_finset_subtype : uIcc a b = (uIcc (a : ℕ) b).fin n := rfl #align fin.uIcc_eq_finset_subtype Fin.uIcc_eq_finset_subtype @[simp] theorem map_valEmbedding_Icc : (Icc a b).map Fin.valEmbedding = Icc ↑a ↑b := by simp [Icc_eq_finset_subtype, Finset.fin, Finset.map_map, Icc_filter_lt_of_lt_right] #align fin.map_subtype_embedding_Icc Fin.map_valEmbedding_Icc @[simp] theorem map_valEmbedding_Ico : (Ico a b).map Fin.valEmbedding = Ico ↑a ↑b := by simp [Ico_eq_finset_subtype, Finset.fin, Finset.map_map] #align fin.map_subtype_embedding_Ico Fin.map_valEmbedding_Ico @[simp] theorem map_valEmbedding_Ioc : (Ioc a b).map Fin.valEmbedding = Ioc ↑a ↑b := by simp [Ioc_eq_finset_subtype, Finset.fin, Finset.map_map, Ioc_filter_lt_of_lt_right] #align fin.map_subtype_embedding_Ioc Fin.map_valEmbedding_Ioc @[simp] theorem map_valEmbedding_Ioo : (Ioo a b).map Fin.valEmbedding = Ioo ↑a ↑b := by simp [Ioo_eq_finset_subtype, Finset.fin, Finset.map_map] #align fin.map_subtype_embedding_Ioo Fin.map_valEmbedding_Ioo @[simp] theorem map_subtype_embedding_uIcc : (uIcc a b).map valEmbedding = uIcc ↑a ↑b := map_valEmbedding_Icc _ _ #align fin.map_subtype_embedding_uIcc Fin.map_subtype_embedding_uIcc @[simp] theorem card_Icc : (Icc a b).card = b + 1 - a := by rw [← Nat.card_Icc, ← map_valEmbedding_Icc, card_map] #align fin.card_Icc Fin.card_Icc @[simp] theorem card_Ico : (Ico a b).card = b - a := by rw [← Nat.card_Ico, ← map_valEmbedding_Ico, card_map] #align fin.card_Ico Fin.card_Ico @[simp]
Mathlib/Order/Interval/Finset/Fin.lean
114
115
theorem card_Ioc : (Ioc a b).card = b - a := by
rw [← Nat.card_Ioc, ← map_valEmbedding_Ioc, card_map]
/- 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.CategoryTheory.EqToHom #align_import category_theory.sums.basic from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Binary disjoint unions of categories We define the category instance on `C ⊕ D` when `C` and `D` are categories. We define: * `inl_` : the functor `C ⥤ C ⊕ D` * `inr_` : the functor `D ⥤ C ⊕ D` * `swap` : the functor `C ⊕ D ⥤ D ⊕ C` (and the fact this is an equivalence) We further define sums of functors and natural transformations, written `F.sum G` and `α.sum β`. -/ namespace CategoryTheory universe v₁ u₁ -- morphism levels before object levels. See note [category_theory universes]. open Sum section variable (C : Type u₁) [Category.{v₁} C] (D : Type u₁) [Category.{v₁} D] /- Porting note: `aesop_cat` not firing on `assoc` where autotac in Lean 3 did-/ /-- `sum C D` gives the direct sum of two categories. -/ instance sum : Category.{v₁} (Sum C D) where Hom X Y := match X, Y with | inl X, inl Y => X ⟶ Y | inl _, inr _ => PEmpty | inr _, inl _ => PEmpty | inr X, inr Y => X ⟶ Y id X := match X with | inl X => 𝟙 X | inr X => 𝟙 X comp {X Y Z} f g := match X, Y, Z, f, g with | inl X, inl Y, inl Z, f, g => f ≫ g | inr X, inr Y, inr Z, f, g => f ≫ g assoc {W X Y Z} f g h := match X, Y, Z, W with | inl X, inl Y, inl Z, inl W => Category.assoc f g h | inr X, inr Y, inr Z, inr W => Category.assoc f g h #align category_theory.sum CategoryTheory.sum @[aesop norm -10 destruct (rule_sets := [CategoryTheory])]
Mathlib/CategoryTheory/Sums/Basic.lean
62
63
theorem hom_inl_inr_false {X : C} {Y : D} (f : Sum.inl X ⟶ Sum.inr Y) : False := by
cases f
/- Copyright (c) 2017 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn -/ import Mathlib.CategoryTheory.NatTrans import Mathlib.CategoryTheory.Iso #align_import category_theory.functor.category from "leanprover-community/mathlib"@"63721b2c3eba6c325ecf8ae8cca27155a4f6306f" /-! # The category of functors and natural transformations between two fixed categories. We provide the category instance on `C ⥤ D`, with morphisms the natural transformations. ## Universes If `C` and `D` are both small categories at the same universe level, this is another small category at that level. However if `C` and `D` are both large categories at the same universe level, this is a small category at the next higher level. -/ namespace CategoryTheory -- declare the `v`'s first; see note [CategoryTheory universes]. universe v₁ v₂ v₃ u₁ u₂ u₃ open NatTrans Category CategoryTheory.Functor variable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D] attribute [local simp] vcomp_app variable {C D} {E : Type u₃} [Category.{v₃} E] variable {F G H I : C ⥤ D} /-- `Functor.category C D` gives the category structure on functors and natural transformations between categories `C` and `D`. Notice that if `C` and `D` are both small categories at the same universe level, this is another small category at that level. However if `C` and `D` are both large categories at the same universe level, this is a small category at the next higher level. -/ instance Functor.category : Category.{max u₁ v₂} (C ⥤ D) where Hom F G := NatTrans F G id F := NatTrans.id F comp α β := vcomp α β #align category_theory.functor.category CategoryTheory.Functor.category namespace NatTrans -- Porting note: the behaviour of `ext` has changed here. -- We need to provide a copy of the `NatTrans.ext` lemma, -- written in terms of `F ⟶ G` rather than `NatTrans F G`, -- or `ext` will not retrieve it from the cache. @[ext] theorem ext' {α β : F ⟶ G} (w : α.app = β.app) : α = β := NatTrans.ext _ _ w @[simp] theorem vcomp_eq_comp (α : F ⟶ G) (β : G ⟶ H) : vcomp α β = α ≫ β := rfl #align category_theory.nat_trans.vcomp_eq_comp CategoryTheory.NatTrans.vcomp_eq_comp theorem vcomp_app' (α : F ⟶ G) (β : G ⟶ H) (X : C) : (α ≫ β).app X = α.app X ≫ β.app X := rfl #align category_theory.nat_trans.vcomp_app' CategoryTheory.NatTrans.vcomp_app' theorem congr_app {α β : F ⟶ G} (h : α = β) (X : C) : α.app X = β.app X := by rw [h] #align category_theory.nat_trans.congr_app CategoryTheory.NatTrans.congr_app @[simp] theorem id_app (F : C ⥤ D) (X : C) : (𝟙 F : F ⟶ F).app X = 𝟙 (F.obj X) := rfl #align category_theory.nat_trans.id_app CategoryTheory.NatTrans.id_app @[simp] theorem comp_app {F G H : C ⥤ D} (α : F ⟶ G) (β : G ⟶ H) (X : C) : (α ≫ β).app X = α.app X ≫ β.app X := rfl #align category_theory.nat_trans.comp_app CategoryTheory.NatTrans.comp_app attribute [reassoc] comp_app @[reassoc] theorem app_naturality {F G : C ⥤ D ⥤ E} (T : F ⟶ G) (X : C) {Y Z : D} (f : Y ⟶ Z) : (F.obj X).map f ≫ (T.app X).app Z = (T.app X).app Y ≫ (G.obj X).map f := (T.app X).naturality f #align category_theory.nat_trans.app_naturality CategoryTheory.NatTrans.app_naturality @[reassoc] theorem naturality_app {F G : C ⥤ D ⥤ E} (T : F ⟶ G) (Z : D) {X Y : C} (f : X ⟶ Y) : (F.map f).app Z ≫ (T.app Y).app Z = (T.app X).app Z ≫ (G.map f).app Z := congr_fun (congr_arg app (T.naturality f)) Z #align category_theory.nat_trans.naturality_app CategoryTheory.NatTrans.naturality_app /-- A natural transformation is a monomorphism if each component is. -/ theorem mono_of_mono_app (α : F ⟶ G) [∀ X : C, Mono (α.app X)] : Mono α := ⟨fun g h eq => by ext X rw [← cancel_mono (α.app X), ← comp_app, eq, comp_app]⟩ #align category_theory.nat_trans.mono_of_mono_app CategoryTheory.NatTrans.mono_of_mono_app /-- A natural transformation is an epimorphism if each component is. -/ theorem epi_of_epi_app (α : F ⟶ G) [∀ X : C, Epi (α.app X)] : Epi α := ⟨fun g h eq => by ext X rw [← cancel_epi (α.app X), ← comp_app, eq, comp_app]⟩ #align category_theory.nat_trans.epi_of_epi_app CategoryTheory.NatTrans.epi_of_epi_app /-- `hcomp α β` is the horizontal composition of natural transformations. -/ @[simps] def hcomp {H I : D ⥤ E} (α : F ⟶ G) (β : H ⟶ I) : F ⋙ H ⟶ G ⋙ I where app := fun X : C => β.app (F.obj X) ≫ I.map (α.app X) naturality X Y f := by rw [Functor.comp_map, Functor.comp_map, ← assoc, naturality, assoc, ← map_comp I, naturality, map_comp, assoc] #align category_theory.nat_trans.hcomp CategoryTheory.NatTrans.hcomp #align category_theory.nat_trans.hcomp_app CategoryTheory.NatTrans.hcomp_app /-- Notation for horizontal composition of natural transformations. -/ infixl:80 " ◫ " => hcomp theorem hcomp_id_app {H : D ⥤ E} (α : F ⟶ G) (X : C) : (α ◫ 𝟙 H).app X = H.map (α.app X) := by simp #align category_theory.nat_trans.hcomp_id_app CategoryTheory.NatTrans.hcomp_id_app
Mathlib/CategoryTheory/Functor/Category.lean
125
125
theorem id_hcomp_app {H : E ⥤ C} (α : F ⟶ G) (X : E) : (𝟙 H ◫ α).app X = α.app _ := by
simp
/- Copyright (c) 2021 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.Order.Interval.Finset.Fin #align_import data.fintype.fin from "leanprover-community/mathlib"@"759575657f189ccb424b990164c8b1fa9f55cdfe" /-! # The structure of `Fintype (Fin n)` This file contains some basic results about the `Fintype` instance for `Fin`, especially properties of `Finset.univ : Finset (Fin n)`. -/ open Finset open Fintype namespace Fin variable {α β : Type*} {n : ℕ} theorem map_valEmbedding_univ : (Finset.univ : Finset (Fin n)).map Fin.valEmbedding = Iio n := by ext simp [orderIsoSubtype.symm.surjective.exists, OrderIso.symm] #align fin.map_subtype_embedding_univ Fin.map_valEmbedding_univ @[simp] theorem Ioi_zero_eq_map : Ioi (0 : Fin n.succ) = univ.map (Fin.succEmb _) := coe_injective <| by ext; simp [pos_iff_ne_zero] #align fin.Ioi_zero_eq_map Fin.Ioi_zero_eq_map @[simp] theorem Iio_last_eq_map : Iio (Fin.last n) = Finset.univ.map Fin.castSuccEmb := coe_injective <| by ext; simp [lt_def] #align fin.Iio_last_eq_map Fin.Iio_last_eq_map @[simp] theorem Ioi_succ (i : Fin n) : Ioi i.succ = (Ioi i).map (Fin.succEmb _) := by ext i simp only [mem_filter, mem_Ioi, mem_map, mem_univ, true_and_iff, Function.Embedding.coeFn_mk, exists_true_left] constructor · refine cases ?_ ?_ i · rintro ⟨⟨⟩⟩ · intro i hi exact ⟨i, succ_lt_succ_iff.mp hi, rfl⟩ · rintro ⟨i, hi, rfl⟩ simpa #align fin.Ioi_succ Fin.Ioi_succ @[simp] theorem Iio_castSucc (i : Fin n) : Iio (castSucc i) = (Iio i).map Fin.castSuccEmb := by apply Finset.map_injective Fin.valEmbedding rw [Finset.map_map, Fin.map_valEmbedding_Iio] exact (Fin.map_valEmbedding_Iio i).symm #align fin.Iio_cast_succ Fin.Iio_castSucc
Mathlib/Data/Fintype/Fin.lean
61
64
theorem card_filter_univ_succ' (p : Fin (n + 1) → Prop) [DecidablePred p] : (univ.filter p).card = ite (p 0) 1 0 + (univ.filter (p ∘ Fin.succ)).card := by
rw [Fin.univ_succ, filter_cons, card_disjUnion, filter_map, card_map] split_ifs <;> simp
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Yury G. Kudryashov -/ import Mathlib.Logic.Function.Basic import Mathlib.Tactic.MkIffOfInductiveProp #align_import data.sum.basic from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc" /-! # Additional lemmas about sum types Most of the former contents of this file have been moved to Batteries. -/ universe u v w x variable {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {γ δ : Type*} namespace Sum #align sum.forall Sum.forall #align sum.exists Sum.exists theorem exists_sum {γ : α ⊕ β → Sort*} (p : (∀ ab, γ ab) → Prop) : (∃ fab, p fab) ↔ (∃ fa fb, p (Sum.rec fa fb)) := by rw [← not_forall_not, forall_sum] simp theorem inl_injective : Function.Injective (inl : α → Sum α β) := fun _ _ ↦ inl.inj #align sum.inl_injective Sum.inl_injective theorem inr_injective : Function.Injective (inr : β → Sum α β) := fun _ _ ↦ inr.inj #align sum.inr_injective Sum.inr_injective theorem sum_rec_congr (P : α ⊕ β → Sort*) (f : ∀ i, P (inl i)) (g : ∀ i, P (inr i)) {x y : α ⊕ β} (h : x = y) : @Sum.rec _ _ _ f g x = cast (congr_arg P h.symm) (@Sum.rec _ _ _ f g y) := by cases h; rfl section get #align sum.is_left Sum.isLeft #align sum.is_right Sum.isRight #align sum.get_left Sum.getLeft? #align sum.get_right Sum.getRight? variable {x y : Sum α β} #align sum.get_left_eq_none_iff Sum.getLeft?_eq_none_iff #align sum.get_right_eq_none_iff Sum.getRight?_eq_none_iff
Mathlib/Data/Sum/Basic.lean
54
55
theorem eq_left_iff_getLeft_eq {a : α} : x = inl a ↔ ∃ h, x.getLeft h = a := by
cases x <;> simp
/- Copyright (c) 2021 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Eric Wieser -/ import Mathlib.Analysis.NormedSpace.Exponential import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Topology.MetricSpace.CauSeqFilter #align_import analysis.special_functions.exponential from "leanprover-community/mathlib"@"e1a18cad9cd462973d760af7de36b05776b8811c" /-! # Calculus results on exponential in a Banach algebra In this file, we prove basic properties about the derivative of the exponential map `exp 𝕂` in a Banach algebra `𝔸` over a field `𝕂`. We keep them separate from the main file `Analysis/NormedSpace/Exponential` in order to minimize dependencies. ## Main results We prove most results for an arbitrary field `𝕂`, and then specialize to `𝕂 = ℝ` or `𝕂 = ℂ`. ### General case - `hasStrictFDerivAt_exp_zero_of_radius_pos` : `exp 𝕂` has strict Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero (see also `hasStrictDerivAt_exp_zero_of_radius_pos` for the case `𝔸 = 𝕂`) - `hasStrictFDerivAt_exp_of_lt_radius` : if `𝕂` has characteristic zero and `𝔸` is commutative, then given a point `x` in the disk of convergence, `exp 𝕂` has strict Fréchet derivative `exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at x (see also `hasStrictDerivAt_exp_of_lt_radius` for the case `𝔸 = 𝕂`) - `hasStrictFDerivAt_exp_smul_const_of_mem_ball`: even when `𝔸` is non-commutative, if we have an intermediate algebra `𝕊` which is commutative, then the function `(u : 𝕊) ↦ exp 𝕂 (u • x)`, still has strict Fréchet derivative `exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x` at `t` if `t • x` is in the radius of convergence. ### `𝕂 = ℝ` or `𝕂 = ℂ` - `hasStrictFDerivAt_exp_zero` : `exp 𝕂` has strict Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero (see also `hasStrictDerivAt_exp_zero` for the case `𝔸 = 𝕂`) - `hasStrictFDerivAt_exp` : if `𝔸` is commutative, then given any point `x`, `exp 𝕂` has strict Fréchet derivative `exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at x (see also `hasStrictDerivAt_exp` for the case `𝔸 = 𝕂`) - `hasStrictFDerivAt_exp_smul_const`: even when `𝔸` is non-commutative, if we have an intermediate algebra `𝕊` which is commutative, then the function `(u : 𝕊) ↦ exp 𝕂 (u • x)` still has strict Fréchet derivative `exp 𝕂 (t • x) • (1 : 𝔸 →L[𝕂] 𝔸).smulRight x` at `t`. ### Compatibility with `Real.exp` and `Complex.exp` - `Complex.exp_eq_exp_ℂ` : `Complex.exp = exp ℂ ℂ` - `Real.exp_eq_exp_ℝ` : `Real.exp = exp ℝ ℝ` -/ open Filter RCLike ContinuousMultilinearMap NormedField NormedSpace Asymptotics open scoped Nat Topology ENNReal section AnyFieldAnyAlgebra variable {𝕂 𝔸 : Type*} [NontriviallyNormedField 𝕂] [NormedRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸] /-- The exponential in a Banach algebra `𝔸` over a normed field `𝕂` has strict Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero. -/
Mathlib/Analysis/SpecialFunctions/Exponential.lean
67
72
theorem hasStrictFDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).radius) : HasStrictFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 := by
convert (hasFPowerSeriesAt_exp_zero_of_radius_pos h).hasStrictFDerivAt ext x change x = expSeries 𝕂 𝔸 1 fun _ => x simp [expSeries_apply_eq, Nat.factorial]
/- 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.CategoryTheory.Limits.Shapes.Images import Mathlib.CategoryTheory.Limits.Constructions.EpiMono #align_import category_theory.limits.preserves.shapes.images from "leanprover-community/mathlib"@"fc78e3c190c72a109699385da6be2725e88df841" /-! # Preserving images In this file, we show that if a functor preserves span and cospan, then it preserves images. -/ noncomputable section namespace CategoryTheory namespace PreservesImage open CategoryTheory open CategoryTheory.Limits universe u₁ u₂ v₁ v₂ variable {A : Type u₁} {B : Type u₂} [Category.{v₁} A] [Category.{v₂} B] variable [HasEqualizers A] [HasImages A] variable [StrongEpiCategory B] [HasImages B] variable (L : A ⥤ B) variable [∀ {X Y Z : A} (f : X ⟶ Z) (g : Y ⟶ Z), PreservesLimit (cospan f g) L] variable [∀ {X Y Z : A} (f : X ⟶ Y) (g : X ⟶ Z), PreservesColimit (span f g) L] /-- If a functor preserves span and cospan, then it preserves images. -/ @[simps!] def iso {X Y : A} (f : X ⟶ Y) : image (L.map f) ≅ L.obj (image f) := let aux1 : StrongEpiMonoFactorisation (L.map f) := { I := L.obj (Limits.image f) m := L.map <| Limits.image.ι _ m_mono := preserves_mono_of_preservesLimit _ _ e := L.map <| factorThruImage _ e_strong_epi := @strongEpi_of_epi B _ _ _ _ _ (preserves_epi_of_preservesColimit L _) fac := by rw [← L.map_comp, Limits.image.fac] } IsImage.isoExt (Image.isImage (L.map f)) aux1.toMonoIsImage #align category_theory.preserves_image.iso CategoryTheory.PreservesImage.iso @[reassoc] theorem factorThruImage_comp_hom {X Y : A} (f : X ⟶ Y) : factorThruImage (L.map f) ≫ (iso L f).hom = L.map (factorThruImage f) := by simp #align category_theory.preserves_image.factor_thru_image_comp_hom CategoryTheory.PreservesImage.factorThruImage_comp_hom @[reassoc] theorem hom_comp_map_image_ι {X Y : A} (f : X ⟶ Y) : (iso L f).hom ≫ L.map (image.ι f) = image.ι (L.map f) := by rw [iso_hom, image.lift_fac] #align category_theory.preserves_image.hom_comp_map_image_ι CategoryTheory.PreservesImage.hom_comp_map_image_ι @[reassoc]
Mathlib/CategoryTheory/Limits/Preserves/Shapes/Images.lean
62
63
theorem inv_comp_image_ι_map {X Y : A} (f : X ⟶ Y) : (iso L f).inv ≫ image.ι (L.map f) = L.map (image.ι f) := by
simp
/- Copyright (c) 2022 Praneeth Kolichala. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Praneeth Kolichala -/ import Mathlib.Topology.Homotopy.Equiv import Mathlib.CategoryTheory.Equivalence import Mathlib.AlgebraicTopology.FundamentalGroupoid.Product #align_import algebraic_topology.fundamental_groupoid.induced_maps from "leanprover-community/mathlib"@"e5470580a62bf043e10976760edfe73c913eb71e" /-! # Homotopic maps induce naturally isomorphic functors ## Main definitions - `FundamentalGroupoidFunctor.homotopicMapsNatIso H` The natural isomorphism between the induced functors `f : π(X) ⥤ π(Y)` and `g : π(X) ⥤ π(Y)`, given a homotopy `H : f ∼ g` - `FundamentalGroupoidFunctor.equivOfHomotopyEquiv hequiv` The equivalence of the categories `π(X)` and `π(Y)` given a homotopy equivalence `hequiv : X ≃ₕ Y` between them. ## Implementation notes - In order to be more universe polymorphic, we define `ContinuousMap.Homotopy.uliftMap` which lifts a homotopy from `I × X → Y` to `(TopCat.of ((ULift I) × X)) → Y`. This is because this construction uses `FundamentalGroupoidFunctor.prodToProdTop` to convert between pairs of paths in I and X and the corresponding path after passing through a homotopy `H`. But `FundamentalGroupoidFunctor.prodToProdTop` requires two spaces in the same universe. -/ noncomputable section universe u open FundamentalGroupoid open CategoryTheory open FundamentalGroupoidFunctor open scoped FundamentalGroupoid open scoped unitInterval namespace unitInterval /-- The path 0 ⟶ 1 in `I` -/ def path01 : Path (0 : I) 1 where toFun := id source' := rfl target' := rfl #align unit_interval.path01 unitInterval.path01 /-- The path 0 ⟶ 1 in `ULift I` -/ def upath01 : Path (ULift.up 0 : ULift.{u} I) (ULift.up 1) where toFun := ULift.up source' := rfl target' := rfl #align unit_interval.upath01 unitInterval.upath01 attribute [local instance] Path.Homotopic.setoid /-- The homotopy path class of 0 → 1 in `ULift I` -/ def uhpath01 : @fromTop (TopCat.of <| ULift.{u} I) (ULift.up (0 : I)) ⟶ fromTop (ULift.up 1) := ⟦upath01⟧ #align unit_interval.uhpath01 unitInterval.uhpath01 end unitInterval namespace ContinuousMap.Homotopy open unitInterval (uhpath01) attribute [local instance] Path.Homotopic.setoid section Casts /-- Abbreviation for `eqToHom` that accepts points in a topological space -/ abbrev hcast {X : TopCat} {x₀ x₁ : X} (hx : x₀ = x₁) : fromTop x₀ ⟶ fromTop x₁ := eqToHom <| FundamentalGroupoid.ext _ _ hx #align continuous_map.homotopy.hcast ContinuousMap.Homotopy.hcast @[simp] theorem hcast_def {X : TopCat} {x₀ x₁ : X} (hx₀ : x₀ = x₁) : hcast hx₀ = eqToHom (FundamentalGroupoid.ext _ _ hx₀) := rfl #align continuous_map.homotopy.hcast_def ContinuousMap.Homotopy.hcast_def variable {X₁ X₂ Y : TopCat.{u}} {f : C(X₁, Y)} {g : C(X₂, Y)} {x₀ x₁ : X₁} {x₂ x₃ : X₂} {p : Path x₀ x₁} {q : Path x₂ x₃} (hfg : ∀ t, f (p t) = g (q t)) /-- If `f(p(t) = g(q(t))` for two paths `p` and `q`, then the induced path homotopy classes `f(p)` and `g(p)` are the same as well, despite having a priori different types -/
Mathlib/AlgebraicTopology/FundamentalGroupoid/InducedMaps.lean
96
97
theorem heq_path_of_eq_image : HEq ((πₘ f).map ⟦p⟧) ((πₘ g).map ⟦q⟧) := by
simp only [map_eq, ← Path.Homotopic.map_lift]; apply Path.Homotopic.hpath_hext; exact hfg
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen -/ import Mathlib.RingTheory.Localization.Basic #align_import ring_theory.localization.integer from "leanprover-community/mathlib"@"9556784a5b84697562e9c6acb40500d4a82e675a" /-! # Integer elements of a localization ## Main definitions * `IsLocalization.IsInteger` is a predicate stating that `x : S` is in the image of `R` ## Implementation notes See `RingTheory/Localization/Basic.lean` for a design overview. ## Tags localization, ring localization, commutative ring localization, characteristic predicate, commutative ring, field of fractions -/ variable {R : Type*} [CommSemiring R] {M : Submonoid R} {S : Type*} [CommSemiring S] variable [Algebra R S] {P : Type*} [CommSemiring P] open Function namespace IsLocalization section variable (R) -- TODO: define a subalgebra of `IsInteger`s /-- Given `a : S`, `S` a localization of `R`, `IsInteger R a` iff `a` is in the image of the localization map from `R` to `S`. -/ def IsInteger (a : S) : Prop := a ∈ (algebraMap R S).rangeS #align is_localization.is_integer IsLocalization.IsInteger end theorem isInteger_zero : IsInteger R (0 : S) := Subsemiring.zero_mem _ #align is_localization.is_integer_zero IsLocalization.isInteger_zero theorem isInteger_one : IsInteger R (1 : S) := Subsemiring.one_mem _ #align is_localization.is_integer_one IsLocalization.isInteger_one theorem isInteger_add {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a + b) := Subsemiring.add_mem _ ha hb #align is_localization.is_integer_add IsLocalization.isInteger_add theorem isInteger_mul {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a * b) := Subsemiring.mul_mem _ ha hb #align is_localization.is_integer_mul IsLocalization.isInteger_mul theorem isInteger_smul {a : R} {b : S} (hb : IsInteger R b) : IsInteger R (a • b) := by rcases hb with ⟨b', hb⟩ use a * b' rw [← hb, (algebraMap R S).map_mul, Algebra.smul_def] #align is_localization.is_integer_smul IsLocalization.isInteger_smul variable (M) variable [IsLocalization M S] /-- Each element `a : S` has an `M`-multiple which is an integer. This version multiplies `a` on the right, matching the argument order in `LocalizationMap.surj`. -/ theorem exists_integer_multiple' (a : S) : ∃ b : M, IsInteger R (a * algebraMap R S b) := let ⟨⟨Num, denom⟩, h⟩ := IsLocalization.surj _ a ⟨denom, Set.mem_range.mpr ⟨Num, h.symm⟩⟩ #align is_localization.exists_integer_multiple' IsLocalization.exists_integer_multiple' /-- Each element `a : S` has an `M`-multiple which is an integer. This version multiplies `a` on the left, matching the argument order in the `SMul` instance. -/ theorem exists_integer_multiple (a : S) : ∃ b : M, IsInteger R ((b : R) • a) := by simp_rw [Algebra.smul_def, mul_comm _ a] apply exists_integer_multiple' #align is_localization.exists_integer_multiple IsLocalization.exists_integer_multiple /-- We can clear the denominators of a `Finset`-indexed family of fractions. -/
Mathlib/RingTheory/Localization/Integer.lean
91
103
theorem exist_integer_multiples {ι : Type*} (s : Finset ι) (f : ι → S) : ∃ b : M, ∀ i ∈ s, IsLocalization.IsInteger R ((b : R) • f i) := by
haveI := Classical.propDecidable refine ⟨∏ i ∈ s, (sec M (f i)).2, fun i hi => ⟨?_, ?_⟩⟩ · exact (∏ j ∈ s.erase i, (sec M (f j)).2) * (sec M (f i)).1 rw [RingHom.map_mul, sec_spec', ← mul_assoc, ← (algebraMap R S).map_mul, ← Algebra.smul_def] congr 2 refine _root_.trans ?_ (map_prod (Submonoid.subtype M) _ _).symm rw [mul_comm,Submonoid.coe_finset_prod, -- Porting note: explicitly supplied `f` ← Finset.prod_insert (f := fun i => ((sec M (f i)).snd : R)) (s.not_mem_erase i), Finset.insert_erase hi] 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.Group.Abs import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax #align_import algebra.order.group.min_max from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" /-! # `min` and `max` in linearly ordered groups. -/ section variable {α : Type*} [Group α] [LinearOrder α] [CovariantClass α α (· * ·) (· ≤ ·)] -- TODO: This duplicates `oneLePart_div_leOnePart` @[to_additive (attr := simp)] theorem max_one_div_max_inv_one_eq_self (a : α) : max a 1 / max a⁻¹ 1 = a := by rcases le_total a 1 with (h | h) <;> simp [h] #align max_one_div_max_inv_one_eq_self max_one_div_max_inv_one_eq_self #align max_zero_sub_max_neg_zero_eq_self max_zero_sub_max_neg_zero_eq_self alias max_zero_sub_eq_self := max_zero_sub_max_neg_zero_eq_self #align max_zero_sub_eq_self max_zero_sub_eq_self @[to_additive] lemma max_inv_one (a : α) : max a⁻¹ 1 = a⁻¹ * max a 1 := by rw [eq_inv_mul_iff_mul_eq, ← eq_div_iff_mul_eq', max_one_div_max_inv_one_eq_self] end section LinearOrderedCommGroup variable {α : Type*} [LinearOrderedCommGroup α] {a b c : α} @[to_additive min_neg_neg] theorem min_inv_inv' (a b : α) : min a⁻¹ b⁻¹ = (max a b)⁻¹ := Eq.symm <| (@Monotone.map_max α αᵒᵈ _ _ Inv.inv a b) fun _ _ => -- Porting note: Explicit `α` necessary to infer `CovariantClass` instance (@inv_le_inv_iff α _ _ _).mpr #align min_inv_inv' min_inv_inv' #align min_neg_neg min_neg_neg @[to_additive max_neg_neg] theorem max_inv_inv' (a b : α) : max a⁻¹ b⁻¹ = (min a b)⁻¹ := Eq.symm <| (@Monotone.map_min α αᵒᵈ _ _ Inv.inv a b) fun _ _ => -- Porting note: Explicit `α` necessary to infer `CovariantClass` instance (@inv_le_inv_iff α _ _ _).mpr #align max_inv_inv' max_inv_inv' #align max_neg_neg max_neg_neg @[to_additive min_sub_sub_right] theorem min_div_div_right' (a b c : α) : min (a / c) (b / c) = min a b / c := by simpa only [div_eq_mul_inv] using min_mul_mul_right a b c⁻¹ #align min_div_div_right' min_div_div_right' #align min_sub_sub_right min_sub_sub_right @[to_additive max_sub_sub_right] theorem max_div_div_right' (a b c : α) : max (a / c) (b / c) = max a b / c := by simpa only [div_eq_mul_inv] using max_mul_mul_right a b c⁻¹ #align max_div_div_right' max_div_div_right' #align max_sub_sub_right max_sub_sub_right @[to_additive min_sub_sub_left]
Mathlib/Algebra/Order/Group/MinMax.lean
69
70
theorem min_div_div_left' (a b c : α) : min (a / b) (a / c) = a / max b c := by
simp only [div_eq_mul_inv, min_mul_mul_left, min_inv_inv']
/- Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura, Mario Carneiro -/ import Mathlib.Algebra.Group.Prod import Mathlib.Data.Set.Lattice #align_import data.nat.pairing from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432" /-! # Naturals pairing function This file defines a pairing function for the naturals as follows: ```text 0 1 4 9 16 2 3 5 10 17 6 7 8 11 18 12 13 14 15 19 20 21 22 23 24 ``` It has the advantage of being monotone in both directions and sending `⟦0, n^2 - 1⟧` to `⟦0, n - 1⟧²`. -/ assert_not_exists MonoidWithZero open Prod Decidable Function namespace Nat /-- Pairing function for the natural numbers. -/ -- Porting note: no pp_nodot --@[pp_nodot] def pair (a b : ℕ) : ℕ := if a < b then b * b + a else a * a + a + b #align nat.mkpair Nat.pair /-- Unpairing function for the natural numbers. -/ -- Porting note: no pp_nodot --@[pp_nodot] def unpair (n : ℕ) : ℕ × ℕ := let s := sqrt n if n - s * s < s then (n - s * s, s) else (s, n - s * s - s) #align nat.unpair Nat.unpair @[simp] theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by dsimp only [unpair]; let s := sqrt n have sm : s * s + (n - s * s) = n := Nat.add_sub_cancel' (sqrt_le _) split_ifs with h · simp [pair, h, sm] · have hl : n - s * s - s ≤ s := Nat.sub_le_iff_le_add.2 (Nat.sub_le_iff_le_add'.2 <| by rw [← Nat.add_assoc]; apply sqrt_le_add) simp [pair, hl.not_lt, Nat.add_assoc, Nat.add_sub_cancel' (le_of_not_gt h), sm] #align nat.mkpair_unpair Nat.pair_unpair theorem pair_unpair' {n a b} (H : unpair n = (a, b)) : pair a b = n := by simpa [H] using pair_unpair n #align nat.mkpair_unpair' Nat.pair_unpair' @[simp] theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by dsimp only [pair]; split_ifs with h · show unpair (b * b + a) = (a, b) have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _)) simp [unpair, be, Nat.add_sub_cancel_left, h] · show unpair (a * a + a + b) = (a, b) have ae : sqrt (a * a + (a + b)) = a := by rw [sqrt_add_eq] exact Nat.add_le_add_left (le_of_not_gt h) _ simp [unpair, ae, Nat.not_lt_zero, Nat.add_assoc, Nat.add_sub_cancel_left] #align nat.unpair_mkpair Nat.unpair_pair /-- An equivalence between `ℕ × ℕ` and `ℕ`. -/ @[simps (config := .asFn)] def pairEquiv : ℕ × ℕ ≃ ℕ := ⟨uncurry pair, unpair, fun ⟨a, b⟩ => unpair_pair a b, pair_unpair⟩ #align nat.mkpair_equiv Nat.pairEquiv #align nat.mkpair_equiv_apply Nat.pairEquiv_apply #align nat.mkpair_equiv_symm_apply Nat.pairEquiv_symm_apply theorem surjective_unpair : Surjective unpair := pairEquiv.symm.surjective #align nat.surjective_unpair Nat.surjective_unpair @[simp] theorem pair_eq_pair {a b c d : ℕ} : pair a b = pair c d ↔ a = c ∧ b = d := pairEquiv.injective.eq_iff.trans (@Prod.ext_iff ℕ ℕ (a, b) (c, d)) #align nat.mkpair_eq_mkpair Nat.pair_eq_pair
Mathlib/Data/Nat/Pairing.lean
93
100
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
let s := sqrt n simp only [unpair, ge_iff_le, Nat.sub_le_iff_le_add] by_cases h : n - s * s < s <;> simp [h] · exact lt_of_lt_of_le h (sqrt_le_self _) · simp at h have s0 : 0 < s := sqrt_pos.2 n1 exact lt_of_le_of_lt h (Nat.sub_lt n1 (Nat.mul_pos s0 s0))
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Analysis.SpecialFunctions.Trigonometric.Arctan import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine #align_import geometry.euclidean.angle.unoriented.right_angle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Right-angled triangles This file proves basic geometrical results about distances and angles in (possibly degenerate) right-angled triangles in real inner product spaces and Euclidean affine spaces. ## Implementation notes Results in this file are generally given in a form with only those non-degeneracy conditions needed for the particular result, rather than requiring affine independence of the points of a triangle unnecessarily. ## References * https://en.wikipedia.org/wiki/Pythagorean_theorem -/ noncomputable section open scoped EuclideanGeometry open scoped Real open scoped RealInnerProductSpace namespace InnerProductGeometry variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] /-- Pythagorean theorem, if-and-only-if vector angle form. -/ theorem norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) : ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ angle x y = π / 2 := by rw [norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero] exact inner_eq_zero_iff_angle_eq_pi_div_two x y #align inner_product_geometry.norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two InnerProductGeometry.norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two /-- Pythagorean theorem, vector angle form. -/ theorem norm_add_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = π / 2) : ‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ := (norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h #align inner_product_geometry.norm_add_sq_eq_norm_sq_add_norm_sq' InnerProductGeometry.norm_add_sq_eq_norm_sq_add_norm_sq' /-- Pythagorean theorem, subtracting vectors, if-and-only-if vector angle form. -/
Mathlib/Geometry/Euclidean/Angle/Unoriented/RightAngle.lean
56
59
theorem norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) : ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ angle x y = π / 2 := by
rw [norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero] exact inner_eq_zero_iff_angle_eq_pi_div_two x y
/- Copyright (c) 2021 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Topology.Separation #align_import topology.sober from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" /-! # Sober spaces A quasi-sober space is a topological space where every irreducible closed subset has a generic point. A sober space is a quasi-sober space where every irreducible closed subset has a *unique* generic point. This is if and only if the space is T0, and thus sober spaces can be stated via `[QuasiSober α] [T0Space α]`. ## Main definition * `IsGenericPoint` : `x` is the generic point of `S` if `S` is the closure of `x`. * `QuasiSober` : A space is quasi-sober if every irreducible closed subset has a generic point. -/ open Set variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] section genericPoint /-- `x` is a generic point of `S` if `S` is the closure of `x`. -/ def IsGenericPoint (x : α) (S : Set α) : Prop := closure ({x} : Set α) = S #align is_generic_point IsGenericPoint theorem isGenericPoint_def {x : α} {S : Set α} : IsGenericPoint x S ↔ closure ({x} : Set α) = S := Iff.rfl #align is_generic_point_def isGenericPoint_def theorem IsGenericPoint.def {x : α} {S : Set α} (h : IsGenericPoint x S) : closure ({x} : Set α) = S := h #align is_generic_point.def IsGenericPoint.def theorem isGenericPoint_closure {x : α} : IsGenericPoint x (closure ({x} : Set α)) := refl _ #align is_generic_point_closure isGenericPoint_closure variable {x y : α} {S U Z : Set α} theorem isGenericPoint_iff_specializes : IsGenericPoint x S ↔ ∀ y, x ⤳ y ↔ y ∈ S := by simp only [specializes_iff_mem_closure, IsGenericPoint, Set.ext_iff] #align is_generic_point_iff_specializes isGenericPoint_iff_specializes namespace IsGenericPoint theorem specializes_iff_mem (h : IsGenericPoint x S) : x ⤳ y ↔ y ∈ S := isGenericPoint_iff_specializes.1 h y #align is_generic_point.specializes_iff_mem IsGenericPoint.specializes_iff_mem protected theorem specializes (h : IsGenericPoint x S) (h' : y ∈ S) : x ⤳ y := h.specializes_iff_mem.2 h' #align is_generic_point.specializes IsGenericPoint.specializes protected theorem mem (h : IsGenericPoint x S) : x ∈ S := h.specializes_iff_mem.1 specializes_rfl #align is_generic_point.mem IsGenericPoint.mem protected theorem isClosed (h : IsGenericPoint x S) : IsClosed S := h.def ▸ isClosed_closure #align is_generic_point.is_closed IsGenericPoint.isClosed protected theorem isIrreducible (h : IsGenericPoint x S) : IsIrreducible S := h.def ▸ isIrreducible_singleton.closure #align is_generic_point.is_irreducible IsGenericPoint.isIrreducible protected theorem inseparable (h : IsGenericPoint x S) (h' : IsGenericPoint y S) : Inseparable x y := (h.specializes h'.mem).antisymm (h'.specializes h.mem) /-- In a T₀ space, each set has at most one generic point. -/ protected theorem eq [T0Space α] (h : IsGenericPoint x S) (h' : IsGenericPoint y S) : x = y := (h.inseparable h').eq #align is_generic_point.eq IsGenericPoint.eq theorem mem_open_set_iff (h : IsGenericPoint x S) (hU : IsOpen U) : x ∈ U ↔ (S ∩ U).Nonempty := ⟨fun h' => ⟨x, h.mem, h'⟩, fun ⟨_y, hyS, hyU⟩ => (h.specializes hyS).mem_open hU hyU⟩ #align is_generic_point.mem_open_set_iff IsGenericPoint.mem_open_set_iff theorem disjoint_iff (h : IsGenericPoint x S) (hU : IsOpen U) : Disjoint S U ↔ x ∉ U := by rw [h.mem_open_set_iff hU, ← not_disjoint_iff_nonempty_inter, Classical.not_not] #align is_generic_point.disjoint_iff IsGenericPoint.disjoint_iff theorem mem_closed_set_iff (h : IsGenericPoint x S) (hZ : IsClosed Z) : x ∈ Z ↔ S ⊆ Z := by rw [← h.def, hZ.closure_subset_iff, singleton_subset_iff] #align is_generic_point.mem_closed_set_iff IsGenericPoint.mem_closed_set_iff protected theorem image (h : IsGenericPoint x S) {f : α → β} (hf : Continuous f) : IsGenericPoint (f x) (closure (f '' S)) := by rw [isGenericPoint_def, ← h.def, ← image_singleton, closure_image_closure hf] #align is_generic_point.image IsGenericPoint.image end IsGenericPoint
Mathlib/Topology/Sober.lean
107
111
theorem isGenericPoint_iff_forall_closed (hS : IsClosed S) (hxS : x ∈ S) : IsGenericPoint x S ↔ ∀ Z : Set α, IsClosed Z → x ∈ Z → S ⊆ Z := by
have : closure {x} ⊆ S := closure_minimal (singleton_subset_iff.2 hxS) hS simp_rw [IsGenericPoint, subset_antisymm_iff, this, true_and_iff, closure, subset_sInter_iff, mem_setOf_eq, and_imp, singleton_subset_iff]
/- Copyright (c) 2014 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Amelia Livingston, Yury Kudryashov, Neil Strickland, Aaron Anderson -/ import Mathlib.Algebra.GroupWithZero.Units.Basic import Mathlib.Algebra.Divisibility.Units #align_import algebra.group_with_zero.divisibility from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Divisibility in groups with zero. Lemmas about divisibility in groups and monoids with zero. -/ assert_not_exists DenselyOrdered variable {α : Type*} section SemigroupWithZero variable [SemigroupWithZero α] {a : α} theorem eq_zero_of_zero_dvd (h : 0 ∣ a) : a = 0 := Dvd.elim h fun c H' => H'.trans (zero_mul c) #align eq_zero_of_zero_dvd eq_zero_of_zero_dvd /-- Given an element `a` of a commutative semigroup with zero, there exists another element whose product with zero equals `a` iff `a` equals zero. -/ @[simp] theorem zero_dvd_iff : 0 ∣ a ↔ a = 0 := ⟨eq_zero_of_zero_dvd, fun h => by rw [h] exact ⟨0, by simp⟩⟩ #align zero_dvd_iff zero_dvd_iff @[simp] theorem dvd_zero (a : α) : a ∣ 0 := Dvd.intro 0 (by simp) #align dvd_zero dvd_zero end SemigroupWithZero /-- Given two elements `b`, `c` of a `CancelMonoidWithZero` and a nonzero element `a`, `a*b` divides `a*c` iff `b` divides `c`. -/ theorem mul_dvd_mul_iff_left [CancelMonoidWithZero α] {a b c : α} (ha : a ≠ 0) : a * b ∣ a * c ↔ b ∣ c := exists_congr fun d => by rw [mul_assoc, mul_right_inj' ha] #align mul_dvd_mul_iff_left mul_dvd_mul_iff_left /-- Given two elements `a`, `b` of a commutative `CancelMonoidWithZero` and a nonzero element `c`, `a*c` divides `b*c` iff `a` divides `b`. -/ theorem mul_dvd_mul_iff_right [CancelCommMonoidWithZero α] {a b c : α} (hc : c ≠ 0) : a * c ∣ b * c ↔ a ∣ b := exists_congr fun d => by rw [mul_right_comm, mul_left_inj' hc] #align mul_dvd_mul_iff_right mul_dvd_mul_iff_right section CommMonoidWithZero variable [CommMonoidWithZero α] /-- `DvdNotUnit a b` expresses that `a` divides `b` "strictly", i.e. that `b` divided by `a` is not a unit. -/ def DvdNotUnit (a b : α) : Prop := a ≠ 0 ∧ ∃ x, ¬IsUnit x ∧ b = a * x #align dvd_not_unit DvdNotUnit theorem dvdNotUnit_of_dvd_of_not_dvd {a b : α} (hd : a ∣ b) (hnd : ¬b ∣ a) : DvdNotUnit a b := by constructor · rintro rfl exact hnd (dvd_zero _) · rcases hd with ⟨c, rfl⟩ refine ⟨c, ?_, rfl⟩ rintro ⟨u, rfl⟩ simp at hnd #align dvd_not_unit_of_dvd_of_not_dvd dvdNotUnit_of_dvd_of_not_dvd variable {x y : α} theorem isRelPrime_zero_left : IsRelPrime 0 x ↔ IsUnit x := ⟨(· (dvd_zero _) dvd_rfl), IsUnit.isRelPrime_right⟩ theorem isRelPrime_zero_right : IsRelPrime x 0 ↔ IsUnit x := isRelPrime_comm.trans isRelPrime_zero_left theorem not_isRelPrime_zero_zero [Nontrivial α] : ¬IsRelPrime (0 : α) 0 := mt isRelPrime_zero_right.mp not_isUnit_zero theorem IsRelPrime.ne_zero_or_ne_zero [Nontrivial α] (h : IsRelPrime x y) : x ≠ 0 ∨ y ≠ 0 := not_or_of_imp <| by rintro rfl rfl; exact not_isRelPrime_zero_zero h end CommMonoidWithZero theorem isRelPrime_of_no_nonunits_factors [MonoidWithZero α] {x y : α} (nonzero : ¬(x = 0 ∧ y = 0)) (H : ∀ z, ¬ IsUnit z → z ≠ 0 → z ∣ x → ¬z ∣ y) : IsRelPrime x y := by refine fun z hx hy ↦ by_contra fun h ↦ H z h ?_ hx hy rintro rfl; exact nonzero ⟨zero_dvd_iff.1 hx, zero_dvd_iff.1 hy⟩ theorem dvd_and_not_dvd_iff [CancelCommMonoidWithZero α] {x y : α} : x ∣ y ∧ ¬y ∣ x ↔ DvdNotUnit x y := ⟨fun ⟨⟨d, hd⟩, hyx⟩ => ⟨fun hx0 => by simp [hx0] at hyx, ⟨d, mt isUnit_iff_dvd_one.1 fun ⟨e, he⟩ => hyx ⟨e, by rw [hd, mul_assoc, ← he, mul_one]⟩, hd⟩⟩, fun ⟨hx0, d, hdu, hdx⟩ => ⟨⟨d, hdx⟩, fun ⟨e, he⟩ => hdu (isUnit_of_dvd_one ⟨e, mul_left_cancel₀ hx0 <| by conv => lhs rw [he, hdx] simp [mul_assoc]⟩)⟩⟩ #align dvd_and_not_dvd_iff dvd_and_not_dvd_iff section MonoidWithZero variable [MonoidWithZero α]
Mathlib/Algebra/GroupWithZero/Divisibility.lean
122
124
theorem ne_zero_of_dvd_ne_zero {p q : α} (h₁ : q ≠ 0) (h₂ : p ∣ q) : p ≠ 0 := by
rcases h₂ with ⟨u, rfl⟩ exact left_ne_zero_of_mul h₁
/- Copyright (c) 2020 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau -/ import Mathlib.Algebra.Polynomial.Eval import Mathlib.RingTheory.Ideal.Quotient #align_import linear_algebra.smodeq from "leanprover-community/mathlib"@"146d3d1fa59c091fedaad8a4afa09d6802886d24" /-! # modular equivalence for submodule -/ open Submodule open Polynomial variable {R : Type*} [Ring R] variable {A : Type*} [CommRing A] variable {M : Type*} [AddCommGroup M] [Module R M] (U U₁ U₂ : Submodule R M) variable {x x₁ x₂ y y₁ y₂ z z₁ z₂ : M} variable {N : Type*} [AddCommGroup N] [Module R N] (V V₁ V₂ : Submodule R N) set_option backward.isDefEq.lazyWhnfCore false in -- See https://github.com/leanprover-community/mathlib4/issues/12534 /-- A predicate saying two elements of a module are equivalent modulo a submodule. -/ def SModEq (x y : M) : Prop := (Submodule.Quotient.mk x : M ⧸ U) = Submodule.Quotient.mk y #align smodeq SModEq notation:50 x " ≡ " y " [SMOD " N "]" => SModEq N x y variable {U U₁ U₂} set_option backward.isDefEq.lazyWhnfCore false in -- See https://github.com/leanprover-community/mathlib4/issues/12534 protected theorem SModEq.def : x ≡ y [SMOD U] ↔ (Submodule.Quotient.mk x : M ⧸ U) = Submodule.Quotient.mk y := Iff.rfl #align smodeq.def SModEq.def namespace SModEq theorem sub_mem : x ≡ y [SMOD U] ↔ x - y ∈ U := by rw [SModEq.def, Submodule.Quotient.eq] #align smodeq.sub_mem SModEq.sub_mem @[simp] theorem top : x ≡ y [SMOD (⊤ : Submodule R M)] := (Submodule.Quotient.eq ⊤).2 mem_top #align smodeq.top SModEq.top @[simp]
Mathlib/LinearAlgebra/SModEq.lean
53
54
theorem bot : x ≡ y [SMOD (⊥ : Submodule R M)] ↔ x = y := by
rw [SModEq.def, Submodule.Quotient.eq, mem_bot, sub_eq_zero]
/- 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
Mathlib/Topology/ContinuousOn.lean
57
59
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]
/- 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, Yury Kudryashov -/ import Mathlib.Analysis.Convex.Normed import Mathlib.Analysis.Convex.Strict import Mathlib.Analysis.Normed.Order.Basic import Mathlib.Analysis.NormedSpace.AddTorsor import Mathlib.Analysis.NormedSpace.Pointwise import Mathlib.Analysis.NormedSpace.Ray #align_import analysis.convex.strict_convex_space from "leanprover-community/mathlib"@"a63928c34ec358b5edcda2bf7513c50052a5230f" /-! # Strictly convex spaces This file defines strictly convex spaces. A normed space is strictly convex if all closed balls are strictly convex. This does **not** mean that the norm is strictly convex (in fact, it never is). ## Main definitions `StrictConvexSpace`: a typeclass saying that a given normed space over a normed linear ordered field (e.g., `ℝ` or `ℚ`) is strictly convex. The definition requires strict convexity of a closed ball of positive radius with center at the origin; strict convexity of any other closed ball follows from this assumption. ## Main results In a strictly convex space, we prove - `strictConvex_closedBall`: a closed ball is strictly convex. - `combo_mem_ball_of_ne`, `openSegment_subset_ball_of_ne`, `norm_combo_lt_of_ne`: a nontrivial convex combination of two points in a closed ball belong to the corresponding open ball; - `norm_add_lt_of_not_sameRay`, `sameRay_iff_norm_add`, `dist_add_dist_eq_iff`: the triangle inequality `dist x y + dist y z ≤ dist x z` is a strict inequality unless `y` belongs to the segment `[x -[ℝ] z]`. - `Isometry.affineIsometryOfStrictConvexSpace`: an isometry of `NormedAddTorsor`s for real normed spaces, strictly convex in the case of the codomain, is an affine isometry. We also provide several lemmas that can be used as alternative constructors for `StrictConvex ℝ E`: - `StrictConvexSpace.of_strictConvex_closed_unit_ball`: if `closed_ball (0 : E) 1` is strictly convex, then `E` is a strictly convex space; - `StrictConvexSpace.of_norm_add`: if `‖x + y‖ = ‖x‖ + ‖y‖` implies `SameRay ℝ x y` for all nonzero `x y : E`, then `E` is a strictly convex space. ## Implementation notes While the definition is formulated for any normed linear ordered field, most of the lemmas are formulated only for the case `𝕜 = ℝ`. ## Tags convex, strictly convex -/ open Convex Pointwise Set Metric /-- A *strictly convex space* is a normed space where the closed balls are strictly convex. We only require balls of positive radius with center at the origin to be strictly convex in the definition, then prove that any closed ball is strictly convex in `strictConvex_closedBall` below. See also `StrictConvexSpace.of_strictConvex_closed_unit_ball`. -/ class StrictConvexSpace (𝕜 E : Type*) [NormedLinearOrderedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] : Prop where strictConvex_closedBall : ∀ r : ℝ, 0 < r → StrictConvex 𝕜 (closedBall (0 : E) r) #align strict_convex_space StrictConvexSpace variable (𝕜 : Type*) {E : Type*} [NormedLinearOrderedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] /-- A closed ball in a strictly convex space is strictly convex. -/
Mathlib/Analysis/Convex/StrictConvexSpace.lean
76
81
theorem strictConvex_closedBall [StrictConvexSpace 𝕜 E] (x : E) (r : ℝ) : StrictConvex 𝕜 (closedBall x r) := by
rcases le_or_lt r 0 with hr | hr · exact (subsingleton_closedBall x hr).strictConvex rw [← vadd_closedBall_zero] exact (StrictConvexSpace.strictConvex_closedBall r hr).vadd _
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Submodule #align_import algebra.lie.ideal_operations from "leanprover-community/mathlib"@"8983bec7cdf6cb2dd1f21315c8a34ab00d7b2f6d" /-! # Ideal operations for Lie algebras Given a Lie module `M` over a Lie algebra `L`, there is a natural action of the Lie ideals of `L` on the Lie submodules of `M`. In the special case that `M = L` with the adjoint action, this provides a pairing of Lie ideals which is especially important. For example, it can be used to define solvability / nilpotency of a Lie algebra via the derived / lower-central series. ## Main definitions * `LieSubmodule.hasBracket` * `LieSubmodule.lieIdeal_oper_eq_linear_span` * `LieIdeal.map_bracket_le` * `LieIdeal.comap_bracket_le` ## Notation Given a Lie module `M` over a Lie algebra `L`, together with a Lie submodule `N ⊆ M` and a Lie ideal `I ⊆ L`, we introduce the notation `⁅I, N⁆` for the Lie submodule of `M` corresponding to the action defined in this file. ## Tags lie algebra, ideal operation -/ universe u v w w₁ w₂ namespace LieSubmodule variable {R : Type u} {L : Type v} {M : Type w} {M₂ : Type w₁} variable [CommRing R] [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂] variable (N N' : LieSubmodule R L M) (I J : LieIdeal R L) (N₂ : LieSubmodule R L M₂) section LieIdealOperations /-- Given a Lie module `M` over a Lie algebra `L`, the set of Lie ideals of `L` acts on the set of submodules of `M`. -/ instance hasBracket : Bracket (LieIdeal R L) (LieSubmodule R L M) := ⟨fun I N => lieSpan R L { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m }⟩ #align lie_submodule.has_bracket LieSubmodule.hasBracket theorem lieIdeal_oper_eq_span : ⁅I, N⁆ = lieSpan R L { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m } := rfl #align lie_submodule.lie_ideal_oper_eq_span LieSubmodule.lieIdeal_oper_eq_span /-- See also `LieSubmodule.lieIdeal_oper_eq_linear_span'` and `LieSubmodule.lieIdeal_oper_eq_tensor_map_range`. -/ theorem lieIdeal_oper_eq_linear_span : (↑⁅I, N⁆ : Submodule R M) = Submodule.span R { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m } := by apply le_antisymm · let s := { m : M | ∃ (x : ↥I) (n : ↥N), ⁅(x : L), (n : M)⁆ = m } have aux : ∀ (y : L), ∀ m' ∈ Submodule.span R s, ⁅y, m'⁆ ∈ Submodule.span R s := by intro y m' hm' refine Submodule.span_induction (R := R) (M := M) (s := s) (p := fun m' ↦ ⁅y, m'⁆ ∈ Submodule.span R s) hm' ?_ ?_ ?_ ?_ · rintro m'' ⟨x, n, hm''⟩; rw [← hm'', leibniz_lie] refine Submodule.add_mem _ ?_ ?_ <;> apply Submodule.subset_span · use ⟨⁅y, ↑x⁆, I.lie_mem x.property⟩, n · use x, ⟨⁅y, ↑n⁆, N.lie_mem n.property⟩ · simp only [lie_zero, Submodule.zero_mem] · intro m₁ m₂ hm₁ hm₂; rw [lie_add]; exact Submodule.add_mem _ hm₁ hm₂ · intro t m'' hm''; rw [lie_smul]; exact Submodule.smul_mem _ t hm'' change _ ≤ ({ Submodule.span R s with lie_mem := fun hm' => aux _ _ hm' } : LieSubmodule R L M) rw [lieIdeal_oper_eq_span, lieSpan_le] exact Submodule.subset_span · rw [lieIdeal_oper_eq_span]; apply submodule_span_le_lieSpan #align lie_submodule.lie_ideal_oper_eq_linear_span LieSubmodule.lieIdeal_oper_eq_linear_span theorem lieIdeal_oper_eq_linear_span' : (↑⁅I, N⁆ : Submodule R M) = Submodule.span R { m | ∃ x ∈ I, ∃ n ∈ N, ⁅x, n⁆ = m } := by rw [lieIdeal_oper_eq_linear_span] congr ext m constructor · rintro ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩ exact ⟨x, hx, n, hn, rfl⟩ · rintro ⟨x, hx, n, hn, rfl⟩ exact ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩ #align lie_submodule.lie_ideal_oper_eq_linear_span' LieSubmodule.lieIdeal_oper_eq_linear_span'
Mathlib/Algebra/Lie/IdealOperations.lean
96
100
theorem lie_le_iff : ⁅I, N⁆ ≤ N' ↔ ∀ x ∈ I, ∀ m ∈ N, ⁅x, m⁆ ∈ N' := by
rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le] refine ⟨fun h x hx m hm => h ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩, ?_⟩ rintro h _ ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩ exact h x hx m hm
/- Copyright (c) 2020 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon, Yaël Dillies -/ import Mathlib.Data.Nat.Defs import Mathlib.Order.Interval.Set.Basic import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.log from "leanprover-community/mathlib"@"3e00d81bdcbf77c8188bbd18f5524ddc3ed8cac6" /-! # Natural number logarithms This file defines two `ℕ`-valued analogs of the logarithm of `n` with base `b`: * `log b n`: Lower logarithm, or floor **log**. Greatest `k` such that `b^k ≤ n`. * `clog b n`: Upper logarithm, or **c**eil **log**. Least `k` such that `n ≤ b^k`. These are interesting because, for `1 < b`, `Nat.log b` and `Nat.clog b` are respectively right and left adjoints of `Nat.pow b`. See `pow_le_iff_le_log` and `le_pow_iff_clog_le`. -/ namespace Nat /-! ### Floor logarithm -/ /-- `log b n`, is the logarithm of natural number `n` in base `b`. It returns the largest `k : ℕ` such that `b^k ≤ n`, so if `b^k = n`, it returns exactly `k`. -/ --@[pp_nodot] porting note: unknown attribute def log (b : ℕ) : ℕ → ℕ | n => if h : b ≤ n ∧ 1 < b then log b (n / b) + 1 else 0 decreasing_by -- putting this in the def triggers the `unusedHavesSuffices` linter: -- https://github.com/leanprover-community/batteries/issues/428 have : n / b < n := div_lt_self ((Nat.zero_lt_one.trans h.2).trans_le h.1) h.2 decreasing_trivial #align nat.log Nat.log @[simp] theorem log_eq_zero_iff {b n : ℕ} : log b n = 0 ↔ n < b ∨ b ≤ 1 := by rw [log, dite_eq_right_iff] simp only [Nat.add_eq_zero_iff, Nat.one_ne_zero, and_false, imp_false, not_and_or, not_le, not_lt] #align nat.log_eq_zero_iff Nat.log_eq_zero_iff theorem log_of_lt {b n : ℕ} (hb : n < b) : log b n = 0 := log_eq_zero_iff.2 (Or.inl hb) #align nat.log_of_lt Nat.log_of_lt theorem log_of_left_le_one {b : ℕ} (hb : b ≤ 1) (n) : log b n = 0 := log_eq_zero_iff.2 (Or.inr hb) #align nat.log_of_left_le_one Nat.log_of_left_le_one @[simp] theorem log_pos_iff {b n : ℕ} : 0 < log b n ↔ b ≤ n ∧ 1 < b := by rw [Nat.pos_iff_ne_zero, Ne, log_eq_zero_iff, not_or, not_lt, not_le] #align nat.log_pos_iff Nat.log_pos_iff theorem log_pos {b n : ℕ} (hb : 1 < b) (hbn : b ≤ n) : 0 < log b n := log_pos_iff.2 ⟨hbn, hb⟩ #align nat.log_pos Nat.log_pos theorem log_of_one_lt_of_le {b n : ℕ} (h : 1 < b) (hn : b ≤ n) : log b n = log b (n / b) + 1 := by rw [log] exact if_pos ⟨hn, h⟩ #align nat.log_of_one_lt_of_le Nat.log_of_one_lt_of_le @[simp] lemma log_zero_left : ∀ n, log 0 n = 0 := log_of_left_le_one $ Nat.zero_le _ #align nat.log_zero_left Nat.log_zero_left @[simp] theorem log_zero_right (b : ℕ) : log b 0 = 0 := log_eq_zero_iff.2 (le_total 1 b) #align nat.log_zero_right Nat.log_zero_right @[simp] theorem log_one_left : ∀ n, log 1 n = 0 := log_of_left_le_one le_rfl #align nat.log_one_left Nat.log_one_left @[simp] theorem log_one_right (b : ℕ) : log b 1 = 0 := log_eq_zero_iff.2 (lt_or_le _ _) #align nat.log_one_right Nat.log_one_right /-- `pow b` and `log b` (almost) form a Galois connection. See also `Nat.pow_le_of_le_log` and `Nat.le_log_of_pow_le` for individual implications under weaker assumptions. -/ theorem pow_le_iff_le_log {b : ℕ} (hb : 1 < b) {x y : ℕ} (hy : y ≠ 0) : b ^ x ≤ y ↔ x ≤ log b y := by induction' y using Nat.strong_induction_on with y ih generalizing x cases x with | zero => dsimp; omega | succ x => rw [log]; split_ifs with h · have b_pos : 0 < b := lt_of_succ_lt hb rw [Nat.add_le_add_iff_right, ← ih (y / b) (div_lt_self (Nat.pos_iff_ne_zero.2 hy) hb) (Nat.div_pos h.1 b_pos).ne', le_div_iff_mul_le b_pos, pow_succ', Nat.mul_comm] · exact iff_of_false (fun hby => h ⟨(le_self_pow x.succ_ne_zero _).trans hby, hb⟩) (not_succ_le_zero _) #align nat.pow_le_iff_le_log Nat.pow_le_iff_le_log theorem lt_pow_iff_log_lt {b : ℕ} (hb : 1 < b) {x y : ℕ} (hy : y ≠ 0) : y < b ^ x ↔ log b y < x := lt_iff_lt_of_le_iff_le (pow_le_iff_le_log hb hy) #align nat.lt_pow_iff_log_lt Nat.lt_pow_iff_log_lt
Mathlib/Data/Nat/Log.lean
108
111
theorem pow_le_of_le_log {b x y : ℕ} (hy : y ≠ 0) (h : x ≤ log b y) : b ^ x ≤ y := by
refine (le_or_lt b 1).elim (fun hb => ?_) fun hb => (pow_le_iff_le_log hb hy).2 h rw [log_of_left_le_one hb, Nat.le_zero] at h rwa [h, Nat.pow_zero, one_le_iff_ne_zero]
/- 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.Normed.Group.InfiniteSum import Mathlib.Topology.Instances.ENNReal #align_import analysis.calculus.series from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Continuity of series of functions We show that series of functions are continuous when each individual function in the series is and additionally suitable uniform summable bounds are satisfied, in `continuous_tsum`. For smoothness of series of functions, see the file `Analysis.Calculus.SmoothSeries`. -/ open Set Metric TopologicalSpace Function Filter open scoped Topology NNReal variable {α β F : Type*} [NormedAddCommGroup F] [CompleteSpace F] {u : α → ℝ} /-- An infinite sum of functions with summable sup norm is the uniform limit of its partial sums. Version relative to a set, with general index set. -/ theorem tendstoUniformlyOn_tsum {f : α → β → F} (hu : Summable u) {s : Set β} (hfu : ∀ n x, x ∈ s → ‖f n x‖ ≤ u n) : TendstoUniformlyOn (fun t : Finset α => fun x => ∑ n ∈ t, f n x) (fun x => ∑' n, f n x) atTop s := by refine tendstoUniformlyOn_iff.2 fun ε εpos => ?_ filter_upwards [(tendsto_order.1 (tendsto_tsum_compl_atTop_zero u)).2 _ εpos] with t ht x hx have A : Summable fun n => ‖f n x‖ := .of_nonneg_of_le (fun _ ↦ norm_nonneg _) (fun n => hfu n x hx) hu rw [dist_eq_norm, ← sum_add_tsum_subtype_compl A.of_norm t, add_sub_cancel_left] apply lt_of_le_of_lt _ ht apply (norm_tsum_le_tsum_norm (A.subtype _)).trans exact tsum_le_tsum (fun n => hfu _ _ hx) (A.subtype _) (hu.subtype _) #align tendsto_uniformly_on_tsum tendstoUniformlyOn_tsum /-- An infinite sum of functions with summable sup norm is the uniform limit of its partial sums. Version relative to a set, with index set `ℕ`. -/ theorem tendstoUniformlyOn_tsum_nat {f : ℕ → β → F} {u : ℕ → ℝ} (hu : Summable u) {s : Set β} (hfu : ∀ n x, x ∈ s → ‖f n x‖ ≤ u n) : TendstoUniformlyOn (fun N => fun x => ∑ n ∈ Finset.range N, f n x) (fun x => ∑' n, f n x) atTop s := fun v hv => tendsto_finset_range.eventually (tendstoUniformlyOn_tsum hu hfu v hv) #align tendsto_uniformly_on_tsum_nat tendstoUniformlyOn_tsum_nat /-- An infinite sum of functions with summable sup norm is the uniform limit of its partial sums. Version with general index set. -/
Mathlib/Analysis/NormedSpace/FunctionSeries.lean
53
56
theorem tendstoUniformly_tsum {f : α → β → F} (hu : Summable u) (hfu : ∀ n x, ‖f n x‖ ≤ u n) : TendstoUniformly (fun t : Finset α => fun x => ∑ n ∈ t, f n x) (fun x => ∑' n, f n x) atTop := by
rw [← tendstoUniformlyOn_univ]; exact tendstoUniformlyOn_tsum hu fun n x _ => hfu n x
/- 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.MeasureTheory.Measure.Haar.Basic import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import measure_theory.measure.haar.of_basis from "leanprover-community/mathlib"@"92bd7b1ffeb306a89f450bee126ddd8a284c259d" /-! # Additive Haar measure constructed from a basis Given a basis of a finite-dimensional real vector space, we define the corresponding Lebesgue measure, which gives measure `1` to the parallelepiped spanned by the basis. ## Main definitions * `parallelepiped v` is the parallelepiped spanned by a finite family of vectors. * `Basis.parallelepiped` is the parallelepiped associated to a basis, seen as a compact set with nonempty interior. * `Basis.addHaar` is the Lebesgue measure associated to a basis, giving measure `1` to the corresponding parallelepiped. In particular, we declare a `MeasureSpace` instance on any finite-dimensional inner product space, by using the Lebesgue measure associated to some orthonormal basis (which is in fact independent of the basis). -/ open Set TopologicalSpace MeasureTheory MeasureTheory.Measure FiniteDimensional open scoped Pointwise noncomputable section variable {ι ι' E F : Type*} section Fintype variable [Fintype ι] [Fintype ι'] section AddCommGroup variable [AddCommGroup E] [Module ℝ E] [AddCommGroup F] [Module ℝ F] /-- The closed parallelepiped spanned by a finite family of vectors. -/ def parallelepiped (v : ι → E) : Set E := (fun t : ι → ℝ => ∑ i, t i • v i) '' Icc 0 1 #align parallelepiped parallelepiped theorem mem_parallelepiped_iff (v : ι → E) (x : E) : x ∈ parallelepiped v ↔ ∃ t ∈ Icc (0 : ι → ℝ) 1, x = ∑ i, t i • v i := by simp [parallelepiped, eq_comm] #align mem_parallelepiped_iff mem_parallelepiped_iff theorem parallelepiped_basis_eq (b : Basis ι ℝ E) : parallelepiped b = {x | ∀ i, b.repr x i ∈ Set.Icc 0 1} := by classical ext x simp_rw [mem_parallelepiped_iff, mem_setOf_eq, b.ext_elem_iff, _root_.map_sum, _root_.map_smul, Finset.sum_apply', Basis.repr_self, Finsupp.smul_single, smul_eq_mul, mul_one, Finsupp.single_apply, Finset.sum_ite_eq', Finset.mem_univ, ite_true, mem_Icc, Pi.le_def, Pi.zero_apply, Pi.one_apply, ← forall_and] aesop
Mathlib/MeasureTheory/Measure/Haar/OfBasis.lean
67
71
theorem image_parallelepiped (f : E →ₗ[ℝ] F) (v : ι → E) : f '' parallelepiped v = parallelepiped (f ∘ v) := by
simp only [parallelepiped, ← image_comp] congr 1 with t simp only [Function.comp_apply, _root_.map_sum, LinearMap.map_smulₛₗ, RingHom.id_apply]
/- Copyright (c) 2021 Shing Tak Lam. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shing Tak Lam -/ import Mathlib.Topology.Homotopy.Basic import Mathlib.Topology.Connected.PathConnected import Mathlib.Analysis.Convex.Basic #align_import topology.homotopy.path from "leanprover-community/mathlib"@"bb9d1c5085e0b7ea619806a68c5021927cecb2a6" /-! # Homotopy between paths In this file, we define a `Homotopy` between two `Path`s. In addition, we define a relation `Homotopic` on `Path`s, and prove that it is an equivalence relation. ## Definitions * `Path.Homotopy p₀ p₁` is the type of homotopies between paths `p₀` and `p₁` * `Path.Homotopy.refl p` is the constant homotopy between `p` and itself * `Path.Homotopy.symm F` is the `Path.Homotopy p₁ p₀` defined by reversing the homotopy * `Path.Homotopy.trans F G`, where `F : Path.Homotopy p₀ p₁`, `G : Path.Homotopy p₁ p₂` is the `Path.Homotopy p₀ p₂` defined by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]` * `Path.Homotopy.hcomp F G`, where `F : Path.Homotopy p₀ q₀` and `G : Path.Homotopy p₁ q₁` is a `Path.Homotopy (p₀.trans p₁) (q₀.trans q₁)` * `Path.Homotopic p₀ p₁` is the relation saying that there is a homotopy between `p₀` and `p₁` * `Path.Homotopic.setoid x₀ x₁` is the setoid on `Path`s from `Path.Homotopic` * `Path.Homotopic.Quotient x₀ x₁` is the quotient type from `Path x₀ x₀` by `Path.Homotopic.setoid` -/ universe u v variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] variable {x₀ x₁ x₂ x₃ : X} noncomputable section open unitInterval namespace Path /-- The type of homotopies between two paths. -/ abbrev Homotopy (p₀ p₁ : Path x₀ x₁) := ContinuousMap.HomotopyRel p₀.toContinuousMap p₁.toContinuousMap {0, 1} #align path.homotopy Path.Homotopy namespace Homotopy section variable {p₀ p₁ : Path x₀ x₁} theorem coeFn_injective : @Function.Injective (Homotopy p₀ p₁) (I × I → X) (⇑) := DFunLike.coe_injective #align path.homotopy.coe_fn_injective Path.Homotopy.coeFn_injective @[simp] theorem source (F : Homotopy p₀ p₁) (t : I) : F (t, 0) = x₀ := calc F (t, 0) = p₀ 0 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inl rfl) _ = x₀ := p₀.source #align path.homotopy.source Path.Homotopy.source @[simp] theorem target (F : Homotopy p₀ p₁) (t : I) : F (t, 1) = x₁ := calc F (t, 1) = p₀ 1 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inr rfl) _ = x₁ := p₀.target #align path.homotopy.target Path.Homotopy.target /-- Evaluating a path homotopy at an intermediate point, giving us a `Path`. -/ def eval (F : Homotopy p₀ p₁) (t : I) : Path x₀ x₁ where toFun := F.toHomotopy.curry t source' := by simp target' := by simp #align path.homotopy.eval Path.Homotopy.eval @[simp]
Mathlib/Topology/Homotopy/Path.lean
83
85
theorem eval_zero (F : Homotopy p₀ p₁) : F.eval 0 = p₀ := by
ext t simp [eval]
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Chris Hughes, Mario Carneiro, Anne Baanen -/ import Mathlib.LinearAlgebra.Quotient import Mathlib.RingTheory.Congruence import Mathlib.RingTheory.Ideal.Basic import Mathlib.Tactic.FinCases #align_import ring_theory.ideal.quotient from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69" /-! # Ideal quotients This file defines ideal quotients as a special case of submodule quotients and proves some basic results about these quotients. See `Algebra.RingQuot` for quotients of non-commutative rings. ## Main definitions - `Ideal.Quotient`: the quotient of a commutative ring `R` by an ideal `I : Ideal R` -/ universe u v w namespace Ideal open Set variable {R : Type u} [CommRing R] (I : Ideal R) {a b : R} variable {S : Type v} -- Note that at present `Ideal` means a left-ideal, -- so this quotient is only useful in a commutative ring. -- We should develop quotients by two-sided ideals as well. /-- The quotient `R/I` of a ring `R` by an ideal `I`. The ideal quotient of `I` is defined to equal the quotient of `I` as an `R`-submodule of `R`. This definition uses `abbrev` so that typeclass instances can be shared between `Ideal.Quotient I` and `Submodule.Quotient I`. -/ @[instance] abbrev instHasQuotient : HasQuotient R (Ideal R) := Submodule.hasQuotient namespace Quotient variable {I} {x y : R} instance one (I : Ideal R) : One (R ⧸ I) := ⟨Submodule.Quotient.mk 1⟩ #align ideal.quotient.has_one Ideal.Quotient.one /-- On `Ideal`s, `Submodule.quotientRel` is a ring congruence. -/ protected def ringCon (I : Ideal R) : RingCon R := { QuotientAddGroup.con I.toAddSubgroup with mul' := fun {a₁ b₁ a₂ b₂} h₁ h₂ => by rw [Submodule.quotientRel_r_def] at h₁ h₂ ⊢ have F := I.add_mem (I.mul_mem_left a₂ h₁) (I.mul_mem_right b₁ h₂) have : a₁ * a₂ - b₁ * b₂ = a₂ * (a₁ - b₁) + (a₂ - b₂) * b₁ := by rw [mul_sub, sub_mul, sub_add_sub_cancel, mul_comm, mul_comm b₁] rwa [← this] at F } #align ideal.quotient.ring_con Ideal.Quotient.ringCon instance commRing (I : Ideal R) : CommRing (R ⧸ I) := inferInstanceAs (CommRing (Quotient.ringCon I).Quotient) #align ideal.quotient.comm_ring Ideal.Quotient.commRing -- Sanity test to make sure no diamonds have emerged in `commRing` example : (commRing I).toAddCommGroup = Submodule.Quotient.addCommGroup I := rfl -- this instance is harder to find than the one via `Algebra α (R ⧸ I)`, so use a lower priority instance (priority := 100) isScalarTower_right {α} [SMul α R] [IsScalarTower α R R] : IsScalarTower α (R ⧸ I) (R ⧸ I) := (Quotient.ringCon I).isScalarTower_right #align ideal.quotient.is_scalar_tower_right Ideal.Quotient.isScalarTower_right instance smulCommClass {α} [SMul α R] [IsScalarTower α R R] [SMulCommClass α R R] : SMulCommClass α (R ⧸ I) (R ⧸ I) := (Quotient.ringCon I).smulCommClass #align ideal.quotient.smul_comm_class Ideal.Quotient.smulCommClass instance smulCommClass' {α} [SMul α R] [IsScalarTower α R R] [SMulCommClass R α R] : SMulCommClass (R ⧸ I) α (R ⧸ I) := (Quotient.ringCon I).smulCommClass' #align ideal.quotient.smul_comm_class' Ideal.Quotient.smulCommClass' /-- The ring homomorphism from a ring `R` to a quotient ring `R/I`. -/ def mk (I : Ideal R) : R →+* R ⧸ I where toFun a := Submodule.Quotient.mk a map_zero' := rfl map_one' := rfl map_mul' _ _ := rfl map_add' _ _ := rfl #align ideal.quotient.mk Ideal.Quotient.mk instance {I : Ideal R} : Coe R (R ⧸ I) := ⟨Ideal.Quotient.mk I⟩ /-- Two `RingHom`s from the quotient by an ideal are equal if their compositions with `Ideal.Quotient.mk'` are equal. See note [partially-applied ext lemmas]. -/ @[ext 1100] theorem ringHom_ext [NonAssocSemiring S] ⦃f g : R ⧸ I →+* S⦄ (h : f.comp (mk I) = g.comp (mk I)) : f = g := RingHom.ext fun x => Quotient.inductionOn' x <| (RingHom.congr_fun h : _) #align ideal.quotient.ring_hom_ext Ideal.Quotient.ringHom_ext instance inhabited : Inhabited (R ⧸ I) := ⟨mk I 37⟩ #align ideal.quotient.inhabited Ideal.Quotient.inhabited protected theorem eq : mk I x = mk I y ↔ x - y ∈ I := Submodule.Quotient.eq I #align ideal.quotient.eq Ideal.Quotient.eq @[simp] theorem mk_eq_mk (x : R) : (Submodule.Quotient.mk x : R ⧸ I) = mk I x := rfl #align ideal.quotient.mk_eq_mk Ideal.Quotient.mk_eq_mk theorem eq_zero_iff_mem {I : Ideal R} : mk I a = 0 ↔ a ∈ I := Submodule.Quotient.mk_eq_zero _ #align ideal.quotient.eq_zero_iff_mem Ideal.Quotient.eq_zero_iff_mem theorem eq_zero_iff_dvd (x y : R) : Ideal.Quotient.mk (Ideal.span ({x} : Set R)) y = 0 ↔ x ∣ y := by rw [Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_span_singleton] @[simp] lemma mk_singleton_self (x : R) : mk (Ideal.span {x}) x = 0 := by rw [eq_zero_iff_dvd] -- Porting note (#10756): new theorem
Mathlib/RingTheory/Ideal/Quotient.lean
137
138
theorem mk_eq_mk_iff_sub_mem (x y : R) : mk I x = mk I y ↔ x - y ∈ I := by
rw [← eq_zero_iff_mem, map_sub, sub_eq_zero]
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Robert Y. Lewis -/ import Mathlib.Algebra.CharP.Invertible import Mathlib.Algebra.MvPolynomial.Variables import Mathlib.Algebra.MvPolynomial.CommRing import Mathlib.Algebra.MvPolynomial.Expand import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.ZMod.Basic #align_import ring_theory.witt_vector.witt_polynomial from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" /-! # Witt polynomials To endow `WittVector p R` with a ring structure, we need to study the so-called Witt polynomials. Fix a base value `p : ℕ`. The `p`-adic Witt polynomials are an infinite family of polynomials indexed by a natural number `n`, taking values in an arbitrary ring `R`. The variables of these polynomials are represented by natural numbers. The variable set of the `n`th Witt polynomial contains at most `n+1` elements `{0, ..., n}`, with exactly these variables when `R` has characteristic `0`. These polynomials are used to define the addition and multiplication operators on the type of Witt vectors. (While this type itself is not complicated, the ring operations are what make it interesting.) When the base `p` is invertible in `R`, the `p`-adic Witt polynomials form a basis for `MvPolynomial ℕ R`, equivalent to the standard basis. ## Main declarations * `WittPolynomial p R n`: the `n`-th Witt polynomial, viewed as polynomial over the ring `R` * `xInTermsOfW p R n`: if `p` is invertible, the polynomial `X n` is contained in the subalgebra generated by the Witt polynomials. `xInTermsOfW p R n` is the explicit polynomial, which upon being bound to the Witt polynomials yields `X n`. * `bind₁_wittPolynomial_xInTermsOfW`: the proof of the claim that `bind₁ (xInTermsOfW p R) (W_ R n) = X n` * `bind₁_xInTermsOfW_wittPolynomial`: the converse of the above statement ## Notation In this file we use the following notation * `p` is a natural number, typically assumed to be prime. * `R` and `S` are commutative rings * `W n` (and `W_ R n` when the ring needs to be explicit) denotes the `n`th Witt polynomial ## References * [Hazewinkel, *Witt Vectors*][Haze09] * [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21] -/ open MvPolynomial open Finset hiding map open Finsupp (single) --attribute [-simp] coe_eval₂_hom variable (p : ℕ) variable (R : Type*) [CommRing R] [DecidableEq R] /-- `wittPolynomial p R n` is the `n`-th Witt polynomial with respect to a prime `p` with coefficients in a commutative ring `R`. It is defined as: `∑_{i ≤ n} p^i X_i^{p^{n-i}} ∈ R[X_0, X_1, X_2, …]`. -/ noncomputable def wittPolynomial (n : ℕ) : MvPolynomial ℕ R := ∑ i ∈ range (n + 1), monomial (single i (p ^ (n - i))) ((p : R) ^ i) #align witt_polynomial wittPolynomial theorem wittPolynomial_eq_sum_C_mul_X_pow (n : ℕ) : wittPolynomial p R n = ∑ i ∈ range (n + 1), C ((p : R) ^ i) * X i ^ p ^ (n - i) := by apply sum_congr rfl rintro i - rw [monomial_eq, Finsupp.prod_single_index] rw [pow_zero] set_option linter.uppercaseLean3 false in #align witt_polynomial_eq_sum_C_mul_X_pow wittPolynomial_eq_sum_C_mul_X_pow /-! We set up notation locally to this file, to keep statements short and comprehensible. This allows us to simply write `W n` or `W_ ℤ n`. -/ -- Notation with ring of coefficients explicit set_option quotPrecheck false in @[inherit_doc] scoped[Witt] notation "W_" => wittPolynomial p -- Notation with ring of coefficients implicit set_option quotPrecheck false in @[inherit_doc] scoped[Witt] notation "W" => wittPolynomial p _ open Witt open MvPolynomial /-! The first observation is that the Witt polynomial doesn't really depend on the coefficient ring. If we map the coefficients through a ring homomorphism, we obtain the corresponding Witt polynomial over the target ring. -/ section variable {R} {S : Type*} [CommRing S] @[simp]
Mathlib/RingTheory/WittVector/WittPolynomial.lean
116
119
theorem map_wittPolynomial (f : R →+* S) (n : ℕ) : map f (W n) = W n := by
rw [wittPolynomial, map_sum, wittPolynomial] refine sum_congr rfl fun i _ => ?_ rw [map_monomial, RingHom.map_pow, map_natCast]
/- 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.Group import Mathlib.Logic.Encodable.Lattice /-! # Infinite sums and products over `ℕ` and `ℤ` This file contains lemmas about `HasSum`, `Summable`, `tsum`, `HasProd`, `Multipliable`, and `tprod` applied to the important special cases where the domain is `ℕ` or `ℤ`. For instance, we prove the formula `∑ i ∈ range k, f i + ∑' i, f (i + k) = ∑' i, f i`, ∈ `sum_add_tsum_nat_add`, as well as several results relating sums and products on `ℕ` to sums and products on `ℤ`. -/ noncomputable section open Filter Finset Function Encodable open scoped Topology variable {M : Type*} [CommMonoid M] [TopologicalSpace M] {m m' : M} variable {G : Type*} [CommGroup G] {g g' : G} -- don't declare [TopologicalAddGroup G] here as some results require [UniformAddGroup G] instead /-! ## Sums over `ℕ` -/ section Nat section Monoid namespace HasProd /-- If `f : ℕ → M` has product `m`, then the partial products `∏ i ∈ range n, f i` converge to `m`. -/ @[to_additive "If `f : ℕ → M` has sum `m`, then the partial sums `∑ i ∈ range n, f i` converge to `m`."] theorem tendsto_prod_nat {f : ℕ → M} (h : HasProd f m) : Tendsto (fun n ↦ ∏ i ∈ range n, f i) atTop (𝓝 m) := h.comp tendsto_finset_range #align has_sum.tendsto_sum_nat HasSum.tendsto_sum_nat /-- If `f : ℕ → M` is multipliable, then the partial products `∏ i ∈ range n, f i` converge to `∏' i, f i`. -/ @[to_additive "If `f : ℕ → M` is summable, then the partial sums `∑ i ∈ range n, f i` converge to `∑' i, f i`."] theorem Multipliable.tendsto_prod_tprod_nat {f : ℕ → M} (h : Multipliable f) : Tendsto (fun n ↦ ∏ i ∈ range n, f i) atTop (𝓝 (∏' i, f i)) := tendsto_prod_nat h.hasProd section ContinuousMul variable [ContinuousMul M] @[to_additive]
Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean
62
65
theorem prod_range_mul {f : ℕ → M} {k : ℕ} (h : HasProd (fun n ↦ f (n + k)) m) : HasProd f ((∏ i ∈ range k, f i) * m) := by
refine ((range k).hasProd f).mul_compl ?_ rwa [← (notMemRangeEquiv k).symm.hasProd_iff]
/- Copyright (c) 2018 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Simon Hudon -/ import Mathlib.Data.PFunctor.Multivariate.Basic #align_import data.qpf.multivariate.basic from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Multivariate quotients of polynomial functors. Basic definition of multivariate QPF. QPFs form a compositional framework for defining inductive and coinductive types, their quotients and nesting. The idea is based on building ever larger functors. For instance, we can define a list using a shape functor: ```lean inductive ListShape (a b : Type) | nil : ListShape | cons : a -> b -> ListShape ``` This shape can itself be decomposed as a sum of product which are themselves QPFs. It follows that the shape is a QPF and we can take its fixed point and create the list itself: ```lean def List (a : Type) := fix ListShape a -- not the actual notation ``` We can continue and define the quotient on permutation of lists and create the multiset type: ```lean def Multiset (a : Type) := QPF.quot List.perm List a -- not the actual notion ``` And `Multiset` is also a QPF. We can then create a novel data type (for Lean): ```lean inductive Tree (a : Type) | node : a -> Multiset Tree -> Tree ``` An unordered tree. This is currently not supported by Lean because it nests an inductive type inside of a quotient. We can go further and define unordered, possibly infinite trees: ```lean coinductive Tree' (a : Type) | node : a -> Multiset Tree' -> Tree' ``` by using the `cofix` construct. Those options can all be mixed and matched because they preserve the properties of QPF. The latter example, `Tree'`, combines fixed point, co-fixed point and quotients. ## Related modules * constructions * Fix * Cofix * Quot * Comp * Sigma / Pi * Prj * Const each proves that some operations on functors preserves the QPF structure ## Reference ! * [Jeremy Avigad, Mario M. Carneiro and Simon Hudon, *Data Types as Quotients of Polynomial Functors*][avigad-carneiro-hudon2019] -/ universe u open MvFunctor /-- Multivariate quotients of polynomial functors. -/ class MvQPF {n : ℕ} (F : TypeVec.{u} n → Type*) [MvFunctor F] where P : MvPFunctor.{u} n abs : ∀ {α}, P α → F α repr : ∀ {α}, F α → P α abs_repr : ∀ {α} (x : F α), abs (repr x) = x abs_map : ∀ {α β} (f : α ⟹ β) (p : P α), abs (f <$$> p) = f <$$> abs p #align mvqpf MvQPF namespace MvQPF variable {n : ℕ} {F : TypeVec.{u} n → Type*} [MvFunctor F] [q : MvQPF F] open MvFunctor (LiftP LiftR) /-! ### Show that every MvQPF is a lawful MvFunctor. -/ protected theorem id_map {α : TypeVec n} (x : F α) : TypeVec.id <$$> x = x := by rw [← abs_repr x] cases' repr x with a f rw [← abs_map] rfl #align mvqpf.id_map MvQPF.id_map @[simp] theorem comp_map {α β γ : TypeVec n} (f : α ⟹ β) (g : β ⟹ γ) (x : F α) : (g ⊚ f) <$$> x = g <$$> f <$$> x := by rw [← abs_repr x] cases' repr x with a f rw [← abs_map, ← abs_map, ← abs_map] rfl #align mvqpf.comp_map MvQPF.comp_map instance (priority := 100) lawfulMvFunctor : LawfulMvFunctor F where id_map := @MvQPF.id_map n F _ _ comp_map := @comp_map n F _ _ #align mvqpf.is_lawful_mvfunctor MvQPF.lawfulMvFunctor -- Lifting predicates and relations
Mathlib/Data/QPF/Multivariate/Basic.lean
126
138
theorem liftP_iff {α : TypeVec n} (p : ∀ ⦃i⦄, α i → Prop) (x : F α) : LiftP p x ↔ ∃ a f, x = abs ⟨a, f⟩ ∧ ∀ i j, p (f i j) := by
constructor · rintro ⟨y, hy⟩ cases' h : repr y with a f use a, fun i j => (f i j).val constructor · rw [← hy, ← abs_repr y, h, ← abs_map]; rfl intro i j apply (f i j).property rintro ⟨a, f, h₀, h₁⟩ use abs ⟨a, fun i j => ⟨f i j, h₁ i j⟩⟩ rw [← abs_map, h₀]; 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.Data.Set.Prod #align_import data.set.n_ary from "leanprover-community/mathlib"@"5e526d18cea33550268dcbbddcb822d5cde40654" /-! # N-ary images of sets This file defines `Set.image2`, the binary image of sets. This is mostly useful to define pointwise operations and `Set.seq`. ## Notes This file is very similar to `Data.Finset.NAry`, to `Order.Filter.NAry`, and to `Data.Option.NAry`. Please keep them in sync. -/ open Function namespace Set variable {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type*} {f f' : α → β → γ} {g g' : α → β → γ → δ} variable {s s' : Set α} {t t' : Set β} {u u' : Set γ} {v : Set δ} {a a' : α} {b b' : β} {c c' : γ} {d d' : δ} theorem mem_image2_iff (hf : Injective2 f) : f a b ∈ image2 f s t ↔ a ∈ s ∧ b ∈ t := ⟨by rintro ⟨a', ha', b', hb', h⟩ rcases hf h with ⟨rfl, rfl⟩ exact ⟨ha', hb'⟩, fun ⟨ha, hb⟩ => mem_image2_of_mem ha hb⟩ #align set.mem_image2_iff Set.mem_image2_iff /-- image2 is monotone with respect to `⊆`. -/ theorem image2_subset (hs : s ⊆ s') (ht : t ⊆ t') : image2 f s t ⊆ image2 f s' t' := by rintro _ ⟨a, ha, b, hb, rfl⟩ exact mem_image2_of_mem (hs ha) (ht hb) #align set.image2_subset Set.image2_subset theorem image2_subset_left (ht : t ⊆ t') : image2 f s t ⊆ image2 f s t' := image2_subset Subset.rfl ht #align set.image2_subset_left Set.image2_subset_left theorem image2_subset_right (hs : s ⊆ s') : image2 f s t ⊆ image2 f s' t := image2_subset hs Subset.rfl #align set.image2_subset_right Set.image2_subset_right theorem image_subset_image2_left (hb : b ∈ t) : (fun a => f a b) '' s ⊆ image2 f s t := forall_mem_image.2 fun _ ha => mem_image2_of_mem ha hb #align set.image_subset_image2_left Set.image_subset_image2_left theorem image_subset_image2_right (ha : a ∈ s) : f a '' t ⊆ image2 f s t := forall_mem_image.2 fun _ => mem_image2_of_mem ha #align set.image_subset_image2_right Set.image_subset_image2_right theorem forall_image2_iff {p : γ → Prop} : (∀ z ∈ image2 f s t, p z) ↔ ∀ x ∈ s, ∀ y ∈ t, p (f x y) := ⟨fun h x hx y hy => h _ ⟨x, hx, y, hy, rfl⟩, fun h _ ⟨x, hx, y, hy, hz⟩ => hz ▸ h x hx y hy⟩ #align set.forall_image2_iff Set.forall_image2_iff @[simp] theorem image2_subset_iff {u : Set γ} : image2 f s t ⊆ u ↔ ∀ x ∈ s, ∀ y ∈ t, f x y ∈ u := forall_image2_iff #align set.image2_subset_iff Set.image2_subset_iff theorem image2_subset_iff_left : image2 f s t ⊆ u ↔ ∀ a ∈ s, (fun b => f a b) '' t ⊆ u := by simp_rw [image2_subset_iff, image_subset_iff, subset_def, mem_preimage] #align set.image2_subset_iff_left Set.image2_subset_iff_left
Mathlib/Data/Set/NAry.lean
72
73
theorem image2_subset_iff_right : image2 f s t ⊆ u ↔ ∀ b ∈ t, (fun a => f a b) '' s ⊆ u := by
simp_rw [image2_subset_iff, image_subset_iff, subset_def, mem_preimage, @forall₂_swap α]
/- 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.DirectSum.Module import Mathlib.Algebra.Module.BigOperators import Mathlib.LinearAlgebra.Isomorphisms import Mathlib.GroupTheory.Torsion import Mathlib.RingTheory.Coprime.Ideal import Mathlib.RingTheory.Finiteness import Mathlib.Data.Set.Lattice #align_import algebra.module.torsion from "leanprover-community/mathlib"@"cdc34484a07418af43daf8198beaf5c00324bca8" /-! # Torsion submodules ## Main definitions * `torsionOf R M x` : the torsion ideal of `x`, containing all `a` such that `a • x = 0`. * `Submodule.torsionBy R M a` : the `a`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0`. * `Submodule.torsionBySet R M s` : the submodule containing all elements `x` of `M` such that `a • x = 0` for all `a` in `s`. * `Submodule.torsion' R M S` : the `S`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some `a` in `S`. * `Submodule.torsion R M` : the torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some non-zero-divisor `a` in `R`. * `Module.IsTorsionBy R M a` : the property that defines an `a`-torsion module. Similarly, `IsTorsionBySet`, `IsTorsion'` and `IsTorsion`. * `Module.IsTorsionBySet.module` : Creates an `R ⧸ I`-module from an `R`-module that `IsTorsionBySet R _ I`. ## Main statements * `quot_torsionOf_equiv_span_singleton` : isomorphism between the span of an element of `M` and the quotient by its torsion ideal. * `torsion' R M S` and `torsion R M` are submodules. * `torsionBySet_eq_torsionBySet_span` : torsion by a set is torsion by the ideal generated by it. * `Submodule.torsionBy_is_torsionBy` : the `a`-torsion submodule is an `a`-torsion module. Similar lemmas for `torsion'` and `torsion`. * `Submodule.torsionBy_isInternal` : a `∏ i, p i`-torsion module is the internal direct sum of its `p i`-torsion submodules when the `p i` are pairwise coprime. A more general version with coprime ideals is `Submodule.torsionBySet_is_internal`. * `Submodule.noZeroSMulDivisors_iff_torsion_bot` : a module over a domain has `NoZeroSMulDivisors` (that is, there is no non-zero `a`, `x` such that `a • x = 0`) iff its torsion submodule is trivial. * `Submodule.QuotientTorsion.torsion_eq_bot` : quotienting by the torsion submodule makes the torsion submodule of the new module trivial. If `R` is a domain, we can derive an instance `Submodule.QuotientTorsion.noZeroSMulDivisors : NoZeroSMulDivisors R (M ⧸ torsion R M)`. ## Notation * The notions are defined for a `CommSemiring R` and a `Module R M`. Some additional hypotheses on `R` and `M` are required by some lemmas. * The letters `a`, `b`, ... are used for scalars (in `R`), while `x`, `y`, ... are used for vectors (in `M`). ## Tags Torsion, submodule, module, quotient -/ namespace Ideal section TorsionOf variable (R M : Type*) [Semiring R] [AddCommMonoid M] [Module R M] /-- The torsion ideal of `x`, containing all `a` such that `a • x = 0`. -/ @[simps!] def torsionOf (x : M) : Ideal R := -- Porting note (#11036): broken dot notation on LinearMap.ker Lean4#1910 LinearMap.ker (LinearMap.toSpanSingleton R M x) #align ideal.torsion_of Ideal.torsionOf @[simp] theorem torsionOf_zero : torsionOf R M (0 : M) = ⊤ := by simp [torsionOf] #align ideal.torsion_of_zero Ideal.torsionOf_zero variable {R M} @[simp] theorem mem_torsionOf_iff (x : M) (a : R) : a ∈ torsionOf R M x ↔ a • x = 0 := Iff.rfl #align ideal.mem_torsion_of_iff Ideal.mem_torsionOf_iff variable (R) @[simp] theorem torsionOf_eq_top_iff (m : M) : torsionOf R M m = ⊤ ↔ m = 0 := by refine ⟨fun h => ?_, fun h => by simp [h]⟩ rw [← one_smul R m, ← mem_torsionOf_iff m (1 : R), h] exact Submodule.mem_top #align ideal.torsion_of_eq_top_iff Ideal.torsionOf_eq_top_iff @[simp] theorem torsionOf_eq_bot_iff_of_noZeroSMulDivisors [Nontrivial R] [NoZeroSMulDivisors R M] (m : M) : torsionOf R M m = ⊥ ↔ m ≠ 0 := by refine ⟨fun h contra => ?_, fun h => (Submodule.eq_bot_iff _).mpr fun r hr => ?_⟩ · rw [contra, torsionOf_zero] at h exact bot_ne_top.symm h · rw [mem_torsionOf_iff, smul_eq_zero] at hr tauto #align ideal.torsion_of_eq_bot_iff_of_no_zero_smul_divisors Ideal.torsionOf_eq_bot_iff_of_noZeroSMulDivisors /-- See also `CompleteLattice.Independent.linearIndependent` which provides the same conclusion but requires the stronger hypothesis `NoZeroSMulDivisors R M`. -/
Mathlib/Algebra/Module/Torsion.lean
110
123
theorem CompleteLattice.Independent.linear_independent' {ι R M : Type*} {v : ι → M} [Ring R] [AddCommGroup M] [Module R M] (hv : CompleteLattice.Independent fun i => R ∙ v i) (h_ne_zero : ∀ i, Ideal.torsionOf R M (v i) = ⊥) : LinearIndependent R v := by
refine linearIndependent_iff_not_smul_mem_span.mpr fun i r hi => ?_ replace hv := CompleteLattice.independent_def.mp hv i simp only [iSup_subtype', ← Submodule.span_range_eq_iSup (ι := Subtype _), disjoint_iff] at hv have : r • v i ∈ (⊥ : Submodule R M) := by rw [← hv, Submodule.mem_inf] refine ⟨Submodule.mem_span_singleton.mpr ⟨r, rfl⟩, ?_⟩ convert hi ext simp rw [← Submodule.mem_bot R, ← h_ne_zero i] simpa using this
/- Copyright (c) 2022 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" /-! # Extending an alternating map to the exterior algebra ## Main definitions * `ExteriorAlgebra.liftAlternating`: construct a linear map out of the exterior algebra given alternating maps (corresponding to maps out of the exterior powers). * `ExteriorAlgebra.liftAlternatingEquiv`: the above as a linear equivalence ## Main results * `ExteriorAlgebra.lhom_ext`: linear maps from the exterior algebra agree if they agree on the exterior powers. -/ variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι /-- Build a map out of the exterior algebra given a collection of alternating maps acting on each exterior power -/ def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
68
76
theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by
dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty]
/- Copyright (c) 2022 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Floris van Doorn, Yury Kudryashov -/ import Mathlib.Order.Filter.Lift import Mathlib.Order.Filter.AtTopBot #align_import order.filter.small_sets from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # The filter of small sets This file defines the filter of small sets w.r.t. a filter `f`, which is the largest filter containing all powersets of members of `f`. `g` converges to `f.smallSets` if for all `s ∈ f`, eventually we have `g x ⊆ s`. An example usage is that if `f : ι → E → ℝ` is a family of nonnegative functions with integral 1, then saying that `fun i ↦ support (f i)` tendsto `(𝓝 0).smallSets` is a way of saying that `f` tends to the Dirac delta distribution. -/ open Filter open Filter Set variable {α β : Type*} {ι : Sort*} namespace Filter variable {l l' la : Filter α} {lb : Filter β} /-- The filter `l.smallSets` is the largest filter containing all powersets of members of `l`. -/ def smallSets (l : Filter α) : Filter (Set α) := l.lift' powerset #align filter.small_sets Filter.smallSets theorem smallSets_eq_generate {f : Filter α} : f.smallSets = generate (powerset '' f.sets) := by simp_rw [generate_eq_biInf, smallSets, iInf_image] rfl #align filter.small_sets_eq_generate Filter.smallSets_eq_generate -- TODO: get more properties from the adjunction? -- TODO: is there a general way to get a lower adjoint for the lift of an upper adjoint?
Mathlib/Order/Filter/SmallSets.lean
47
51
theorem bind_smallSets_gc : GaloisConnection (fun L : Filter (Set α) ↦ L.bind principal) smallSets := by
intro L l simp_rw [smallSets_eq_generate, le_generate_iff, image_subset_iff] rfl