Context
stringlengths
285
6.98k
file_name
stringlengths
21
79
start
int64
14
184
end
int64
18
184
theorem
stringlengths
25
1.34k
proof
stringlengths
5
3.43k
/- Copyright (c) 2018 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Chris Hughes, Kevin Buzzard -/ import Mathlib.Algebra.Group.Hom.Defs import Mathlib.Algebra.Group.Units #align_import algebra.hom.units from "leanprover-community/mathlib"@"a07d750983b94c530ab69a726862c2ab6802b38c" /-! # Monoid homomorphisms and units This file allows to lift monoid homomorphisms to group homomorphisms of their units subgroups. It also contains unrelated results about `Units` that depend on `MonoidHom`. ## Main declarations * `Units.map`: Turn a homomorphism from `α` to `β` monoids into a homomorphism from `αˣ` to `βˣ`. * `MonoidHom.toHomUnits`: Turn a homomorphism from a group `α` to `β` into a homomorphism from `α` to `βˣ`. -/ assert_not_exists MonoidWithZero assert_not_exists DenselyOrdered open Function universe u v w section MonoidHomClass /-- If two homomorphisms from a division monoid to a monoid are equal at a unit `x`, then they are equal at `x⁻¹`. -/ @[to_additive "If two homomorphisms from a subtraction monoid to an additive monoid are equal at an additive unit `x`, then they are equal at `-x`."] theorem IsUnit.eq_on_inv {F G N} [DivisionMonoid G] [Monoid N] [FunLike F G N] [MonoidHomClass F G N] {x : G} (hx : IsUnit x) (f g : F) (h : f x = g x) : f x⁻¹ = g x⁻¹ := left_inv_eq_right_inv (map_mul_eq_one f hx.inv_mul_cancel) (h.symm ▸ map_mul_eq_one g (hx.mul_inv_cancel)) #align is_unit.eq_on_inv IsUnit.eq_on_inv #align is_add_unit.eq_on_neg IsAddUnit.eq_on_neg /-- If two homomorphism from a group to a monoid are equal at `x`, then they are equal at `x⁻¹`. -/ @[to_additive "If two homomorphism from an additive group to an additive monoid are equal at `x`, then they are equal at `-x`."] theorem eq_on_inv {F G M} [Group G] [Monoid M] [FunLike F G M] [MonoidHomClass F G M] (f g : F) {x : G} (h : f x = g x) : f x⁻¹ = g x⁻¹ := (Group.isUnit x).eq_on_inv f g h #align eq_on_inv eq_on_inv #align eq_on_neg eq_on_neg end MonoidHomClass namespace Units variable {α : Type*} {M : Type u} {N : Type v} {P : Type w} [Monoid M] [Monoid N] [Monoid P] /-- The group homomorphism on units induced by a `MonoidHom`. -/ @[to_additive "The additive homomorphism on `AddUnit`s induced by an `AddMonoidHom`."] def map (f : M →* N) : Mˣ →* Nˣ := MonoidHom.mk' (fun u => ⟨f u.val, f u.inv, by rw [← f.map_mul, u.val_inv, f.map_one], by rw [← f.map_mul, u.inv_val, f.map_one]⟩) fun x y => ext (f.map_mul x y) #align units.map Units.map #align add_units.map AddUnits.map @[to_additive (attr := simp)] theorem coe_map (f : M →* N) (x : Mˣ) : ↑(map f x) = f x := rfl #align units.coe_map Units.coe_map #align add_units.coe_map AddUnits.coe_map @[to_additive (attr := simp)] theorem coe_map_inv (f : M →* N) (u : Mˣ) : ↑(map f u)⁻¹ = f ↑u⁻¹ := rfl #align units.coe_map_inv Units.coe_map_inv #align add_units.coe_map_neg AddUnits.coe_map_neg @[to_additive (attr := simp)] theorem map_comp (f : M →* N) (g : N →* P) : map (g.comp f) = (map g).comp (map f) := rfl #align units.map_comp Units.map_comp #align add_units.map_comp AddUnits.map_comp @[to_additive] lemma map_injective {f : M →* N} (hf : Function.Injective f) : Function.Injective (map f) := fun _ _ e => ext (hf (congr_arg val e)) variable (M) @[to_additive (attr := simp)]
Mathlib/Algebra/Group/Units/Hom.lean
94
94
theorem map_id : map (MonoidHom.id M) = MonoidHom.id Mˣ := by
ext; rfl
/- Copyright (c) 2022 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying -/ import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic #align_import measure_theory.function.egorov from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Egorov theorem This file contains the Egorov theorem which states that an almost everywhere convergent sequence on a finite measure space converges uniformly except on an arbitrarily small set. This theorem is useful for the Vitali convergence theorem as well as theorems regarding convergence in measure. ## Main results * `MeasureTheory.Egorov`: Egorov's theorem which shows that a sequence of almost everywhere convergent functions converges uniformly except on an arbitrarily small set. -/ noncomputable section open scoped Classical open MeasureTheory NNReal ENNReal Topology namespace MeasureTheory open Set Filter TopologicalSpace variable {α β ι : Type*} {m : MeasurableSpace α} [MetricSpace β] {μ : Measure α} namespace Egorov /-- Given a sequence of functions `f` and a function `g`, `notConvergentSeq f g n j` is the set of elements such that `f k x` and `g x` are separated by at least `1 / (n + 1)` for some `k ≥ j`. This definition is useful for Egorov's theorem. -/ def notConvergentSeq [Preorder ι] (f : ι → α → β) (g : α → β) (n : ℕ) (j : ι) : Set α := ⋃ (k) (_ : j ≤ k), { x | 1 / (n + 1 : ℝ) < dist (f k x) (g x) } #align measure_theory.egorov.not_convergent_seq MeasureTheory.Egorov.notConvergentSeq variable {n : ℕ} {i j : ι} {s : Set α} {ε : ℝ} {f : ι → α → β} {g : α → β}
Mathlib/MeasureTheory/Function/Egorov.lean
50
52
theorem mem_notConvergentSeq_iff [Preorder ι] {x : α} : x ∈ notConvergentSeq f g n j ↔ ∃ k ≥ j, 1 / (n + 1 : ℝ) < dist (f k x) (g x) := by
simp_rw [notConvergentSeq, Set.mem_iUnion, exists_prop, mem_setOf]
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Data.Rat.Cast.Defs import Mathlib.Algebra.Field.Basic #align_import data.rat.cast from "leanprover-community/mathlib"@"acebd8d49928f6ed8920e502a6c90674e75bd441" /-! # Some exiled lemmas about casting These lemmas have been removed from `Mathlib.Data.Rat.Cast.Defs` to avoiding needing to import `Mathlib.Algebra.Field.Basic` there. In fact, these lemmas don't appear to be used anywhere in Mathlib, so perhaps this file can simply be deleted. -/ namespace Rat variable {α : Type*} [DivisionRing α] -- Porting note: rewrote proof @[simp] theorem cast_inv_nat (n : ℕ) : ((n⁻¹ : ℚ) : α) = (n : α)⁻¹ := by cases' n with n · simp rw [cast_def, inv_natCast_num, inv_natCast_den, if_neg n.succ_ne_zero, Int.sign_eq_one_of_pos (Nat.cast_pos.mpr n.succ_pos), Int.cast_one, one_div] #align rat.cast_inv_nat Rat.cast_inv_nat -- Porting note: proof got a lot easier - is this still the intended statement? @[simp] theorem cast_inv_int (n : ℤ) : ((n⁻¹ : ℚ) : α) = (n : α)⁻¹ := by cases' n with n n · simp [ofInt_eq_cast, cast_inv_nat] · simp only [ofInt_eq_cast, Int.cast_negSucc, ← Nat.cast_succ, cast_neg, inv_neg, cast_inv_nat] #align rat.cast_inv_int Rat.cast_inv_int @[simp, norm_cast] theorem cast_nnratCast {K} [DivisionRing K] (q : ℚ≥0) : ((q : ℚ) : K) = (q : K) := by rw [Rat.cast_def, NNRat.cast_def, NNRat.cast_def] have hn := @num_div_eq_of_coprime q.num q.den ?hdp q.coprime_num_den on_goal 1 => have hd := @den_div_eq_of_coprime q.num q.den ?hdp q.coprime_num_den case hdp => simpa only [Nat.cast_pos] using q.den_pos simp only [Int.cast_natCast, Nat.cast_inj] at hn hd rw [hn, hd, Int.cast_natCast] /-- Casting a scientific literal via `ℚ` is the same as casting directly. -/ @[simp, norm_cast]
Mathlib/Data/Rat/Cast/Lemmas.lean
55
57
theorem cast_ofScientific {K} [DivisionRing K] (m : ℕ) (s : Bool) (e : ℕ) : (OfScientific.ofScientific m s e : ℚ) = (OfScientific.ofScientific m s e : K) := by
rw [← NNRat.cast_ofScientific (K := K), ← NNRat.cast_ofScientific, cast_nnratCast]
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Data.Fintype.Option import Mathlib.Data.Fintype.Perm import Mathlib.Data.Fintype.Prod import Mathlib.GroupTheory.Perm.Sign import Mathlib.Logic.Equiv.Option #align_import group_theory.perm.option from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" /-! # Permutations of `Option α` -/ open Equiv @[simp] theorem Equiv.optionCongr_one {α : Type*} : (1 : Perm α).optionCongr = 1 := Equiv.optionCongr_refl #align equiv.option_congr_one Equiv.optionCongr_one @[simp] theorem Equiv.optionCongr_swap {α : Type*} [DecidableEq α] (x y : α) : optionCongr (swap x y) = swap (some x) (some y) := by ext (_ | i) · simp [swap_apply_of_ne_of_ne] · by_cases hx : i = x · simp only [hx, optionCongr_apply, Option.map_some', swap_apply_left, Option.mem_def, Option.some.injEq] by_cases hy : i = y <;> simp [hx, hy, swap_apply_of_ne_of_ne] #align equiv.option_congr_swap Equiv.optionCongr_swap @[simp] theorem Equiv.optionCongr_sign {α : Type*} [DecidableEq α] [Fintype α] (e : Perm α) : Perm.sign e.optionCongr = Perm.sign e := by refine Perm.swap_induction_on e ?_ ?_ · simp [Perm.one_def] · intro f x y hne h simp [h, hne, Perm.mul_def, ← Equiv.optionCongr_trans] #align equiv.option_congr_sign Equiv.optionCongr_sign @[simp] theorem map_equiv_removeNone {α : Type*} [DecidableEq α] (σ : Perm (Option α)) : (removeNone σ).optionCongr = swap none (σ none) * σ := by ext1 x have : Option.map (⇑(removeNone σ)) x = (swap none (σ none)) (σ x) := by cases' x with x · simp · cases h : σ (some _) · simp [removeNone_none _ h] · have hn : σ (some x) ≠ none := by simp [h] have hσn : σ (some x) ≠ σ none := σ.injective.ne (by simp) simp [removeNone_some _ ⟨_, h⟩, ← h, swap_apply_of_ne_of_ne hn hσn] simpa using this #align map_equiv_remove_none map_equiv_removeNone /-- Permutations of `Option α` are equivalent to fixing an `Option α` and permuting the remaining with a `Perm α`. The fixed `Option α` is swapped with `none`. -/ @[simps] def Equiv.Perm.decomposeOption {α : Type*} [DecidableEq α] : Perm (Option α) ≃ Option α × Perm α where toFun σ := (σ none, removeNone σ) invFun i := swap none i.1 * i.2.optionCongr left_inv σ := by simp right_inv := fun ⟨x, σ⟩ => by have : removeNone (swap none x * σ.optionCongr) = σ := Equiv.optionCongr_injective (by simp [← mul_assoc]) simp [← Perm.eq_inv_iff_eq, this] #align equiv.perm.decompose_option Equiv.Perm.decomposeOption
Mathlib/GroupTheory/Perm/Option.lean
76
77
theorem Equiv.Perm.decomposeOption_symm_of_none_apply {α : Type*} [DecidableEq α] (e : Perm α) (i : Option α) : Equiv.Perm.decomposeOption.symm (none, e) i = i.map e := by
simp
/- Copyright (c) 2017 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Scott Morrison, Mario Carneiro, Andrew Yang -/ import Mathlib.Topology.Category.TopCat.Limits.Products #align_import topology.category.Top.limits.pullbacks from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" /-! # Pullbacks and pushouts in the category of topological spaces -/ -- Porting note: every ML3 decl has an uppercase letter set_option linter.uppercaseLean3 false open TopologicalSpace open CategoryTheory open CategoryTheory.Limits universe v u w noncomputable section namespace TopCat variable {J : Type v} [SmallCategory J] section Pullback variable {X Y Z : TopCat.{u}} /-- The first projection from the pullback. -/ abbrev pullbackFst (f : X ⟶ Z) (g : Y ⟶ Z) : TopCat.of { p : X × Y // f p.1 = g p.2 } ⟶ X := ⟨Prod.fst ∘ Subtype.val, by apply Continuous.comp <;> set_option tactic.skipAssignedInstances false in continuity⟩ #align Top.pullback_fst TopCat.pullbackFst lemma pullbackFst_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x) : pullbackFst f g x = x.1.1 := rfl /-- The second projection from the pullback. -/ abbrev pullbackSnd (f : X ⟶ Z) (g : Y ⟶ Z) : TopCat.of { p : X × Y // f p.1 = g p.2 } ⟶ Y := ⟨Prod.snd ∘ Subtype.val, by apply Continuous.comp <;> set_option tactic.skipAssignedInstances false in continuity⟩ #align Top.pullback_snd TopCat.pullbackSnd lemma pullbackSnd_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x) : pullbackSnd f g x = x.1.2 := rfl /-- The explicit pullback cone of `X, Y` given by `{ p : X × Y // f p.1 = g p.2 }`. -/ def pullbackCone (f : X ⟶ Z) (g : Y ⟶ Z) : PullbackCone f g := PullbackCone.mk (pullbackFst f g) (pullbackSnd f g) (by dsimp [pullbackFst, pullbackSnd, Function.comp_def] ext ⟨x, h⟩ -- Next 2 lines were -- `rw [comp_apply, ContinuousMap.coe_mk, comp_apply, ContinuousMap.coe_mk]` -- `exact h` before leanprover/lean4#2644 rw [comp_apply, comp_apply] congr!) #align Top.pullback_cone TopCat.pullbackCone /-- The constructed cone is a limit. -/ def pullbackConeIsLimit (f : X ⟶ Z) (g : Y ⟶ Z) : IsLimit (pullbackCone f g) := PullbackCone.isLimitAux' _ (by intro S constructor; swap · exact { toFun := fun x => ⟨⟨S.fst x, S.snd x⟩, by simpa using ConcreteCategory.congr_hom S.condition x⟩ continuous_toFun := by apply Continuous.subtype_mk <| Continuous.prod_mk ?_ ?_ · exact (PullbackCone.fst S)|>.continuous_toFun · exact (PullbackCone.snd S)|>.continuous_toFun } refine ⟨?_, ?_, ?_⟩ · delta pullbackCone ext a -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [comp_apply, ContinuousMap.coe_mk] · delta pullbackCone ext a -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [comp_apply, ContinuousMap.coe_mk] · intro m h₁ h₂ -- Porting note: used to be ext x apply ContinuousMap.ext; intro x apply Subtype.ext apply Prod.ext · simpa using ConcreteCategory.congr_hom h₁ x · simpa using ConcreteCategory.congr_hom h₂ x) #align Top.pullback_cone_is_limit TopCat.pullbackConeIsLimit /-- The pullback of two maps can be identified as a subspace of `X × Y`. -/ def pullbackIsoProdSubtype (f : X ⟶ Z) (g : Y ⟶ Z) : pullback f g ≅ TopCat.of { p : X × Y // f p.1 = g p.2 } := (limit.isLimit _).conePointUniqueUpToIso (pullbackConeIsLimit f g) #align Top.pullback_iso_prod_subtype TopCat.pullbackIsoProdSubtype @[reassoc (attr := simp)]
Mathlib/Topology/Category/TopCat/Limits/Pullbacks.lean
103
105
theorem pullbackIsoProdSubtype_inv_fst (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).inv ≫ pullback.fst = pullbackFst f g := by
simp [pullbackCone, pullbackIsoProdSubtype]
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Data.Finsupp.Basic import Mathlib.Data.Finsupp.Order #align_import data.finsupp.multiset from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Equivalence between `Multiset` and `ℕ`-valued finitely supported functions This defines `Finsupp.toMultiset` the equivalence between `α →₀ ℕ` and `Multiset α`, along with `Multiset.toFinsupp` the reverse equivalence and `Finsupp.orderIsoMultiset` the equivalence promoted to an order isomorphism. -/ open Finset variable {α β ι : Type*} namespace Finsupp /-- Given `f : α →₀ ℕ`, `f.toMultiset` is the multiset with multiplicities given by the values of `f` on the elements of `α`. We define this function as an `AddMonoidHom`. Under the additional assumption of `[DecidableEq α]`, this is available as `Multiset.toFinsupp : Multiset α ≃+ (α →₀ ℕ)`; the two declarations are separate as this assumption is only needed for one direction. -/ def toMultiset : (α →₀ ℕ) →+ Multiset α where toFun f := Finsupp.sum f fun a n => n • {a} -- Porting note: times out if h is not specified map_add' _f _g := sum_add_index' (h := fun a n => n • ({a} : Multiset α)) (fun _ ↦ zero_nsmul _) (fun _ ↦ add_nsmul _) map_zero' := sum_zero_index theorem toMultiset_zero : toMultiset (0 : α →₀ ℕ) = 0 := rfl #align finsupp.to_multiset_zero Finsupp.toMultiset_zero theorem toMultiset_add (m n : α →₀ ℕ) : toMultiset (m + n) = toMultiset m + toMultiset n := toMultiset.map_add m n #align finsupp.to_multiset_add Finsupp.toMultiset_add theorem toMultiset_apply (f : α →₀ ℕ) : toMultiset f = f.sum fun a n => n • {a} := rfl #align finsupp.to_multiset_apply Finsupp.toMultiset_apply @[simp] theorem toMultiset_single (a : α) (n : ℕ) : toMultiset (single a n) = n • {a} := by rw [toMultiset_apply, sum_single_index]; apply zero_nsmul #align finsupp.to_multiset_single Finsupp.toMultiset_single theorem toMultiset_sum {f : ι → α →₀ ℕ} (s : Finset ι) : Finsupp.toMultiset (∑ i ∈ s, f i) = ∑ i ∈ s, Finsupp.toMultiset (f i) := map_sum Finsupp.toMultiset _ _ #align finsupp.to_multiset_sum Finsupp.toMultiset_sum theorem toMultiset_sum_single (s : Finset ι) (n : ℕ) : Finsupp.toMultiset (∑ i ∈ s, single i n) = n • s.val := by simp_rw [toMultiset_sum, Finsupp.toMultiset_single, sum_nsmul, sum_multiset_singleton] #align finsupp.to_multiset_sum_single Finsupp.toMultiset_sum_single @[simp] theorem card_toMultiset (f : α →₀ ℕ) : Multiset.card (toMultiset f) = f.sum fun _ => id := by simp [toMultiset_apply, map_finsupp_sum, Function.id_def] #align finsupp.card_to_multiset Finsupp.card_toMultiset
Mathlib/Data/Finsupp/Multiset.lean
71
79
theorem toMultiset_map (f : α →₀ ℕ) (g : α → β) : f.toMultiset.map g = toMultiset (f.mapDomain g) := by
refine f.induction ?_ ?_ · rw [toMultiset_zero, Multiset.map_zero, mapDomain_zero, toMultiset_zero] · intro a n f _ _ ih rw [toMultiset_add, Multiset.map_add, ih, mapDomain_add, mapDomain_single, toMultiset_single, toMultiset_add, toMultiset_single, ← Multiset.coe_mapAddMonoidHom, (Multiset.mapAddMonoidHom g).map_nsmul] rfl
/- 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) 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) #align nhds_list nhds_list @[simp] theorem nhds_nil : 𝓝 ([] : List α) = pure [] := by rw [nhds_list, List.traverse_nil _] #align nhds_nil nhds_nil
Mathlib/Topology/List.lean
74
75
theorem nhds_cons (a : α) (l : List α) : 𝓝 (a::l) = List.cons <$> 𝓝 a <*> 𝓝 l := by
rw [nhds_list, List.traverse_cons _, ← nhds_list]
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Data.Complex.Module import Mathlib.LinearAlgebra.Determinant #align_import data.complex.determinant from "leanprover-community/mathlib"@"65ec59902eb17e4ab7da8d7e3d0bd9774d1b8b99" /-! # Determinants of maps in the complex numbers as a vector space over `ℝ` This file provides results about the determinants of maps in the complex numbers as a vector space over `ℝ`. -/ namespace Complex /-- The determinant of `conjAe`, as a linear map. -/ @[simp]
Mathlib/Data/Complex/Determinant.lean
24
26
theorem det_conjAe : LinearMap.det conjAe.toLinearMap = -1 := by
rw [← LinearMap.det_toMatrix basisOneI, toMatrix_conjAe, Matrix.det_fin_two_of] simp
/- Copyright (c) 2024 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.LinearAlgebra.TensorProduct.Basic import Mathlib.RingTheory.Finiteness /-! # Some finiteness results of tensor product This file contains some finiteness results of tensor product. - `TensorProduct.exists_multiset`, `TensorProduct.exists_finsupp_left`, `TensorProduct.exists_finsupp_right`, `TensorProduct.exists_finset`: any element of `M ⊗[R] N` can be written as a finite sum of pure tensors. See also `TensorProduct.span_tmul_eq_top`. - `TensorProduct.exists_finite_submodule_left_of_finite`, `TensorProduct.exists_finite_submodule_right_of_finite`, `TensorProduct.exists_finite_submodule_of_finite`: any finite subset of `M ⊗[R] N` is contained in `M' ⊗[R] N`, resp. `M ⊗[R] N'`, resp. `M' ⊗[R] N'`, for some finitely generated submodules `M'` and `N'` of `M` and `N`, respectively. - `TensorProduct.exists_finite_submodule_left_of_finite'`, `TensorProduct.exists_finite_submodule_right_of_finite'`, `TensorProduct.exists_finite_submodule_of_finite'`: variation of the above results where `M` and `N` are already submodules. ## Tags tensor product, finitely generated -/ open scoped TensorProduct open Submodule variable {R M N : Type*} variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N] variable {M₁ M₂ : Submodule R M} {N₁ N₂ : Submodule R N} namespace TensorProduct /-- For any element `x` of `M ⊗[R] N`, there exists a (finite) multiset `{ (m_i, n_i) }` of `M × N`, such that `x` is equal to the sum of `m_i ⊗ₜ[R] n_i`. -/
Mathlib/LinearAlgebra/TensorProduct/Finiteness.lean
52
60
theorem exists_multiset (x : M ⊗[R] N) : ∃ S : Multiset (M × N), x = (S.map fun i ↦ i.1 ⊗ₜ[R] i.2).sum := by
induction x using TensorProduct.induction_on with | zero => exact ⟨0, by simp⟩ | tmul x y => exact ⟨{(x, y)}, by simp⟩ | add x y hx hy => obtain ⟨Sx, hx⟩ := hx obtain ⟨Sy, hy⟩ := hy exact ⟨Sx + Sy, by rw [Multiset.map_add, Multiset.sum_add, hx, hy]⟩
/- Copyright (c) 2022 Felix Weilacher. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Felix Weilacher -/ import Mathlib.Topology.Separation /-! # Perfect Sets In this file we define perfect subsets of a topological space, and prove some basic properties, including a version of the Cantor-Bendixson Theorem. ## Main Definitions * `Perfect C`: A set `C` is perfect, meaning it is closed and every point of it is an accumulation point of itself. * `PerfectSpace X`: A topological space `X` is perfect if its universe is a perfect set. ## Main Statements * `Perfect.splitting`: A perfect nonempty set contains two disjoint perfect nonempty subsets. The main inductive step in the construction of an embedding from the Cantor space to a perfect nonempty complete metric space. * `exists_countable_union_perfect_of_isClosed`: One version of the **Cantor-Bendixson Theorem**: A closed set in a second countable space can be written as the union of a countable set and a perfect set. ## Implementation Notes We do not require perfect sets to be nonempty. We define a nonstandard predicate, `Preperfect`, which drops the closed-ness requirement from the definition of perfect. In T1 spaces, this is equivalent to having a perfect closure, see `preperfect_iff_perfect_closure`. ## See also `Mathlib.Topology.MetricSpace.Perfect`, for properties of perfect sets in metric spaces, namely Polish spaces. ## References * [kechris1995] (Chapters 6-7) ## Tags accumulation point, perfect set, cantor-bendixson. -/ open Topology Filter Set TopologicalSpace section Basic variable {α : Type*} [TopologicalSpace α] {C : Set α} /-- If `x` is an accumulation point of a set `C` and `U` is a neighborhood of `x`, then `x` is an accumulation point of `U ∩ C`. -/ theorem AccPt.nhds_inter {x : α} {U : Set α} (h_acc : AccPt x (𝓟 C)) (hU : U ∈ 𝓝 x) : AccPt x (𝓟 (U ∩ C)) := by have : 𝓝[≠] x ≤ 𝓟 U := by rw [le_principal_iff] exact mem_nhdsWithin_of_mem_nhds hU rw [AccPt, ← inf_principal, ← inf_assoc, inf_of_le_left this] exact h_acc #align acc_pt.nhds_inter AccPt.nhds_inter /-- A set `C` is preperfect if all of its points are accumulation points of itself. If `C` is nonempty and `α` is a T1 space, this is equivalent to the closure of `C` being perfect. See `preperfect_iff_perfect_closure`. -/ def Preperfect (C : Set α) : Prop := ∀ x ∈ C, AccPt x (𝓟 C) #align preperfect Preperfect /-- A set `C` is called perfect if it is closed and all of its points are accumulation points of itself. Note that we do not require `C` to be nonempty. -/ @[mk_iff perfect_def] structure Perfect (C : Set α) : Prop where closed : IsClosed C acc : Preperfect C #align perfect Perfect theorem preperfect_iff_nhds : Preperfect C ↔ ∀ x ∈ C, ∀ U ∈ 𝓝 x, ∃ y ∈ U ∩ C, y ≠ x := by simp only [Preperfect, accPt_iff_nhds] #align preperfect_iff_nhds preperfect_iff_nhds section PerfectSpace variable (α) /-- A topological space `X` is said to be perfect if its universe is a perfect set. Equivalently, this means that `𝓝[≠] x ≠ ⊥` for every point `x : X`. -/ @[mk_iff perfectSpace_def] class PerfectSpace : Prop := univ_preperfect : Preperfect (Set.univ : Set α) theorem PerfectSpace.univ_perfect [PerfectSpace α] : Perfect (Set.univ : Set α) := ⟨isClosed_univ, PerfectSpace.univ_preperfect⟩ end PerfectSpace section Preperfect /-- The intersection of a preperfect set and an open set is preperfect. -/ theorem Preperfect.open_inter {U : Set α} (hC : Preperfect C) (hU : IsOpen U) : Preperfect (U ∩ C) := by rintro x ⟨xU, xC⟩ apply (hC _ xC).nhds_inter exact hU.mem_nhds xU #align preperfect.open_inter Preperfect.open_inter /-- The closure of a preperfect set is perfect. For a converse, see `preperfect_iff_perfect_closure`. -/ theorem Preperfect.perfect_closure (hC : Preperfect C) : Perfect (closure C) := by constructor; · exact isClosed_closure intro x hx by_cases h : x ∈ C <;> apply AccPt.mono _ (principal_mono.mpr subset_closure) · exact hC _ h have : {x}ᶜ ∩ C = C := by simp [h] rw [AccPt, nhdsWithin, inf_assoc, inf_principal, this] rw [closure_eq_cluster_pts] at hx exact hx #align preperfect.perfect_closure Preperfect.perfect_closure /-- In a T1 space, being preperfect is equivalent to having perfect closure. -/
Mathlib/Topology/Perfect.lean
132
144
theorem preperfect_iff_perfect_closure [T1Space α] : Preperfect C ↔ Perfect (closure C) := by
constructor <;> intro h · exact h.perfect_closure intro x xC have H : AccPt x (𝓟 (closure C)) := h.acc _ (subset_closure xC) rw [accPt_iff_frequently] at * have : ∀ y, y ≠ x ∧ y ∈ closure C → ∃ᶠ z in 𝓝 y, z ≠ x ∧ z ∈ C := by rintro y ⟨hyx, yC⟩ simp only [← mem_compl_singleton_iff, and_comm, ← frequently_nhdsWithin_iff, hyx.nhdsWithin_compl_singleton, ← mem_closure_iff_frequently] exact yC rw [← frequently_frequently_nhds] exact H.mono this
/- Copyright (c) 2023 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Polynomial.Degree.Lemmas /-! # `compute_degree` and `monicity`: tactics for explicit polynomials This file defines two related tactics: `compute_degree` and `monicity`. Using `compute_degree` when the goal is of one of the five forms * `natDegree f ≤ d`, * `degree f ≤ d`, * `natDegree f = d`, * `degree f = d`, * `coeff f d = r`, if `d` is the degree of `f`, tries to solve the goal. It may leave side-goals, in case it is not entirely successful. Using `monicity` when the goal is of the form `Monic f` tries to solve the goal. It may leave side-goals, in case it is not entirely successful. Both tactics admit a `!` modifier (`compute_degree!` and `monicity!`) instructing Lean to try harder to close the goal. See the doc-strings for more details. ## Future work * Currently, `compute_degree` does not deal correctly with some edge cases. For instance, ```lean example [Semiring R] : natDegree (C 0 : R[X]) = 0 := by compute_degree -- ⊢ 0 ≠ 0 ``` Still, it may not be worth to provide special support for `natDegree f = 0`. * Make sure that numerals in coefficients are treated correctly. * Make sure that `compute_degree` works with goals of the form `degree f ≤ ↑d`, with an explicit coercion from `ℕ` on the RHS. * Add support for proving goals of the from `natDegree f ≠ 0` and `degree f ≠ 0`. * Make sure that `degree`, `natDegree` and `coeff` are equally supported. ## Implementation details Assume that `f : R[X]` is a polynomial with coefficients in a semiring `R` and `d` is either in `ℕ` or in `WithBot ℕ`. If the goal has the form `natDegree f = d`, then we convert it to three separate goals: * `natDegree f ≤ d`; * `coeff f d = r`; * `r ≠ 0`. Similarly, an initial goal of the form `degree f = d` gives rise to goals of the form * `degree f ≤ d`; * `coeff f d = r`; * `r ≠ 0`. Next, we apply successively lemmas whose side-goals all have the shape * `natDegree f ≤ d`; * `degree f ≤ d`; * `coeff f d = r`; plus possibly "numerical" identities and choices of elements in `ℕ`, `WithBot ℕ`, and `R`. Recursing into `f`, we break apart additions, multiplications, powers, subtractions,... The leaves of the process are * numerals, `C a`, `X` and `monomial a n`, to which we assign degree `0`, `1` and `a` respectively; * `fvar`s `f`, to which we tautologically assign degree `natDegree f`. -/ open Polynomial namespace Mathlib.Tactic.ComputeDegree section recursion_lemmas /-! ### Simple lemmas about `natDegree` The lemmas in this section all have the form `natDegree <some form of cast> ≤ 0`. Their proofs are weakenings of the stronger lemmas `natDegree <same> = 0`. These are the lemmas called by `compute_degree` on (almost) all the leaves of its recursion. -/ variable {R : Type*} section semiring variable [Semiring R] theorem natDegree_C_le (a : R) : natDegree (C a) ≤ 0 := (natDegree_C a).le theorem natDegree_natCast_le (n : ℕ) : natDegree (n : R[X]) ≤ 0 := (natDegree_natCast _).le theorem natDegree_zero_le : natDegree (0 : R[X]) ≤ 0 := natDegree_zero.le theorem natDegree_one_le : natDegree (1 : R[X]) ≤ 0 := natDegree_one.le @[deprecated (since := "2024-04-17")] alias natDegree_nat_cast_le := natDegree_natCast_le
Mathlib/Tactic/ComputeDegree.lean
101
103
theorem coeff_add_of_eq {n : ℕ} {a b : R} {f g : R[X]} (h_add_left : f.coeff n = a) (h_add_right : g.coeff n = b) : (f + g).coeff n = a + b := by
subst ‹_› ‹_›; apply coeff_add
/- Copyright (c) 2023 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.MeasureTheory.Constructions.Pi import Mathlib.MeasureTheory.Constructions.Prod.Integral /-! # Integration with respect to a finite product of measures On a finite product of measure spaces, we show that a product of integrable functions each depending on a single coordinate is integrable, in `MeasureTheory.integrable_fintype_prod`, and that its integral is the product of the individual integrals, in `MeasureTheory.integral_fintype_prod_eq_prod`. -/ open Fintype MeasureTheory MeasureTheory.Measure variable {𝕜 : Type*} [RCLike 𝕜] namespace MeasureTheory /-- On a finite product space in `n` variables, for a natural number `n`, a product of integrable functions depending on each coordinate is integrable. -/ theorem Integrable.fin_nat_prod {n : ℕ} {E : Fin n → Type*} [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))] {f : (i : Fin n) → E i → 𝕜} (hf : ∀ i, Integrable (f i)) : Integrable (fun (x : (i : Fin n) → E i) ↦ ∏ i, f i (x i)) := by induction n with | zero => simp only [Nat.zero_eq, Finset.univ_eq_empty, Finset.prod_empty, volume_pi, integrable_const_iff, one_ne_zero, pi_empty_univ, ENNReal.one_lt_top, or_true] | succ n n_ih => have := ((measurePreserving_piFinSuccAbove (fun i => (volume : Measure (E i))) 0).symm) rw [volume_pi, ← this.integrable_comp_emb (MeasurableEquiv.measurableEmbedding _)] simp_rw [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.prod_univ_succ, Fin.insertNth_zero] simp only [Fin.zero_succAbove, cast_eq, Function.comp_def, Fin.cons_zero, Fin.cons_succ] have : Integrable (fun (x : (j : Fin n) → E (Fin.succ j)) ↦ ∏ j, f (Fin.succ j) (x j)) := n_ih (fun i ↦ hf _) exact Integrable.prod_mul (hf 0) this /-- On a finite product space, a product of integrable functions depending on each coordinate is integrable. Version with dependent target. -/ theorem Integrable.fintype_prod_dep {ι : Type*} [Fintype ι] {E : ι → Type*} {f : (i : ι) → E i → 𝕜} [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))] (hf : ∀ i, Integrable (f i)) : Integrable (fun (x : (i : ι) → E i) ↦ ∏ i, f i (x i)) := by let e := (equivFin ι).symm simp_rw [← (volume_measurePreserving_piCongrLeft _ e).integrable_comp_emb (MeasurableEquiv.measurableEmbedding _), ← e.prod_comp, MeasurableEquiv.coe_piCongrLeft, Function.comp_def, Equiv.piCongrLeft_apply_apply] exact .fin_nat_prod (fun i ↦ hf _) /-- On a finite product space, a product of integrable functions depending on each coordinate is integrable. -/ theorem Integrable.fintype_prod {ι : Type*} [Fintype ι] {E : Type*} {f : ι → E → 𝕜} [MeasureSpace E] [SigmaFinite (volume : Measure E)] (hf : ∀ i, Integrable (f i)) : Integrable (fun (x : ι → E) ↦ ∏ i, f i (x i)) := Integrable.fintype_prod_dep hf /-- A version of **Fubini's theorem** in `n` variables, for a natural number `n`. -/ theorem integral_fin_nat_prod_eq_prod {n : ℕ} {E : Fin n → Type*} [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))] (f : (i : Fin n) → E i → 𝕜) : ∫ x : (i : Fin n) → E i, ∏ i, f i (x i) = ∏ i, ∫ x, f i x := by induction n with | zero => simp only [Nat.zero_eq, volume_pi, Finset.univ_eq_empty, Finset.prod_empty, integral_const, pi_empty_univ, ENNReal.one_toReal, smul_eq_mul, mul_one, pow_zero, one_smul] | succ n n_ih => calc _ = ∫ x : E 0 × ((i : Fin n) → E (Fin.succ i)), f 0 x.1 * ∏ i : Fin n, f (Fin.succ i) (x.2 i) := by rw [volume_pi, ← ((measurePreserving_piFinSuccAbove (fun i => (volume : Measure (E i))) 0).symm).integral_comp'] simp_rw [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.prod_univ_succ, Fin.insertNth_zero, Fin.cons_succ, volume_eq_prod, volume_pi, Fin.zero_succAbove, cast_eq, Fin.cons_zero] _ = (∫ x, f 0 x) * ∏ i : Fin n, ∫ (x : E (Fin.succ i)), f (Fin.succ i) x := by rw [← n_ih, ← integral_prod_mul, volume_eq_prod] _ = ∏ i, ∫ x, f i x := by rw [Fin.prod_univ_succ] /-- A version of **Fubini's theorem** with the variables indexed by a general finite type. -/ theorem integral_fintype_prod_eq_prod (ι : Type*) [Fintype ι] {E : ι → Type*} (f : (i : ι) → E i → 𝕜) [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))] : ∫ x : (i : ι) → E i, ∏ i, f i (x i) = ∏ i, ∫ x, f i x := by let e := (equivFin ι).symm rw [← (volume_measurePreserving_piCongrLeft _ e).integral_comp'] simp_rw [← e.prod_comp, MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply_apply, MeasureTheory.integral_fin_nat_prod_eq_prod]
Mathlib/MeasureTheory/Integral/Pi.lean
95
98
theorem integral_fintype_prod_eq_pow {E : Type*} (ι : Type*) [Fintype ι] (f : E → 𝕜) [MeasureSpace E] [SigmaFinite (volume : Measure E)] : ∫ x : ι → E, ∏ i, f (x i) = (∫ x, f x) ^ (card ι) := by
rw [integral_fintype_prod_eq_prod, Finset.prod_const, card]
/- 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.Finsupp import Mathlib.Data.Finsupp.Order import Mathlib.Order.Interval.Finset.Basic #align_import data.finsupp.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" /-! # Finite intervals of finitely supported functions This file provides the `LocallyFiniteOrder` instance for `ι →₀ α` when `α` itself is locally finite and calculates the cardinality of its finite intervals. ## Main declarations * `Finsupp.rangeSingleton`: Postcomposition with `Singleton.singleton` on `Finset` as a `Finsupp`. * `Finsupp.rangeIcc`: Postcomposition with `Finset.Icc` as a `Finsupp`. Both these definitions use the fact that `0 = {0}` to ensure that the resulting function is finitely supported. -/ noncomputable section open Finset Finsupp Function open scoped Classical open Pointwise variable {ι α : Type*} namespace Finsupp section RangeSingleton variable [Zero α] {f : ι →₀ α} {i : ι} {a : α} /-- Pointwise `Singleton.singleton` bundled as a `Finsupp`. -/ @[simps] def rangeSingleton (f : ι →₀ α) : ι →₀ Finset α where toFun i := {f i} support := f.support mem_support_toFun i := by rw [← not_iff_not, not_mem_support_iff, not_ne_iff] exact singleton_injective.eq_iff.symm #align finsupp.range_singleton Finsupp.rangeSingleton theorem mem_rangeSingleton_apply_iff : a ∈ f.rangeSingleton i ↔ a = f i := mem_singleton #align finsupp.mem_range_singleton_apply_iff Finsupp.mem_rangeSingleton_apply_iff end RangeSingleton section RangeIcc variable [Zero α] [PartialOrder α] [LocallyFiniteOrder α] {f g : ι →₀ α} {i : ι} {a : α} /-- Pointwise `Finset.Icc` bundled as a `Finsupp`. -/ @[simps toFun] def rangeIcc (f g : ι →₀ α) : ι →₀ Finset α where toFun i := Icc (f i) (g i) support := -- Porting note: Not needed (due to open scoped Classical), in mathlib3 too -- haveI := Classical.decEq ι f.support ∪ g.support mem_support_toFun i := by rw [mem_union, ← not_iff_not, not_or, not_mem_support_iff, not_mem_support_iff, not_ne_iff] exact Icc_eq_singleton_iff.symm #align finsupp.range_Icc Finsupp.rangeIcc -- Porting note: Added as alternative to rangeIcc_toFun to be used in proof of card_Icc lemma coe_rangeIcc (f g : ι →₀ α) : rangeIcc f g i = Icc (f i) (g i) := rfl @[simp] theorem rangeIcc_support (f g : ι →₀ α) : (rangeIcc f g).support = f.support ∪ g.support := rfl #align finsupp.range_Icc_support Finsupp.rangeIcc_support theorem mem_rangeIcc_apply_iff : a ∈ f.rangeIcc g i ↔ f i ≤ a ∧ a ≤ g i := mem_Icc #align finsupp.mem_range_Icc_apply_iff Finsupp.mem_rangeIcc_apply_iff end RangeIcc section PartialOrder variable [PartialOrder α] [Zero α] [LocallyFiniteOrder α] (f g : ι →₀ α) instance instLocallyFiniteOrder : LocallyFiniteOrder (ι →₀ α) := -- Porting note: Not needed (due to open scoped Classical), in mathlib3 too -- haveI := Classical.decEq ι -- haveI := Classical.decEq α LocallyFiniteOrder.ofIcc (ι →₀ α) (fun f g => (f.support ∪ g.support).finsupp <| f.rangeIcc g) fun f g x => by refine (mem_finsupp_iff_of_support_subset <| Finset.subset_of_eq <| rangeIcc_support _ _).trans ?_ simp_rw [mem_rangeIcc_apply_iff] exact forall_and theorem Icc_eq : Icc f g = (f.support ∪ g.support).finsupp (f.rangeIcc g) := rfl #align finsupp.Icc_eq Finsupp.Icc_eq -- Porting note: removed [DecidableEq ι] theorem card_Icc : (Icc f g).card = ∏ i ∈ f.support ∪ g.support, (Icc (f i) (g i)).card := by simp_rw [Icc_eq, card_finsupp, coe_rangeIcc] #align finsupp.card_Icc Finsupp.card_Icc -- Porting note: removed [DecidableEq ι] theorem card_Ico : (Ico f g).card = (∏ i ∈ f.support ∪ g.support, (Icc (f i) (g i)).card) - 1 := by rw [card_Ico_eq_card_Icc_sub_one, card_Icc] #align finsupp.card_Ico Finsupp.card_Ico -- Porting note: removed [DecidableEq ι] theorem card_Ioc : (Ioc f g).card = (∏ i ∈ f.support ∪ g.support, (Icc (f i) (g i)).card) - 1 := by rw [card_Ioc_eq_card_Icc_sub_one, card_Icc] #align finsupp.card_Ioc Finsupp.card_Ioc -- Porting note: removed [DecidableEq ι] theorem card_Ioo : (Ioo f g).card = (∏ i ∈ f.support ∪ g.support, (Icc (f i) (g i)).card) - 2 := by rw [card_Ioo_eq_card_Icc_sub_two, card_Icc] #align finsupp.card_Ioo Finsupp.card_Ioo end PartialOrder section Lattice variable [Lattice α] [Zero α] [LocallyFiniteOrder α] (f g : ι →₀ α) -- Porting note: removed [DecidableEq ι]
Mathlib/Data/Finsupp/Interval.lean
133
135
theorem card_uIcc : (uIcc f g).card = ∏ i ∈ f.support ∪ g.support, (uIcc (f i) (g i)).card := by
rw [← support_inf_union_support_sup]; exact card_Icc (_ : ι →₀ α) _
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Fintype.Basic import Mathlib.Data.Finset.Card import Mathlib.Data.List.NodupEquivFin import Mathlib.Data.Set.Image #align_import data.fintype.card from "leanprover-community/mathlib"@"bf2428c9486c407ca38b5b3fb10b87dad0bc99fa" /-! # Cardinalities of finite types ## Main declarations * `Fintype.card α`: Cardinality of a fintype. Equal to `Finset.univ.card`. * `Fintype.truncEquivFin`: A fintype `α` is computably equivalent to `Fin (card α)`. The `Trunc`-free, noncomputable version is `Fintype.equivFin`. * `Fintype.truncEquivOfCardEq` `Fintype.equivOfCardEq`: Two fintypes of same cardinality are equivalent. See above. * `Fin.equiv_iff_eq`: `Fin m ≃ Fin n` iff `m = n`. * `Infinite.natEmbedding`: An embedding of `ℕ` into an infinite type. We also provide the following versions of the pigeonholes principle. * `Fintype.exists_ne_map_eq_of_card_lt` and `isEmpty_of_card_lt`: Finitely many pigeons and pigeonholes. Weak formulation. * `Finite.exists_ne_map_eq_of_infinite`: Infinitely many pigeons in finitely many pigeonholes. Weak formulation. * `Finite.exists_infinite_fiber`: Infinitely many pigeons in finitely many pigeonholes. Strong formulation. Some more pigeonhole-like statements can be found in `Data.Fintype.CardEmbedding`. Types which have an injection from/a surjection to an `Infinite` type are themselves `Infinite`. See `Infinite.of_injective` and `Infinite.of_surjective`. ## Instances We provide `Infinite` instances for * specific types: `ℕ`, `ℤ`, `String` * type constructors: `Multiset α`, `List α` -/ assert_not_exists MonoidWithZero assert_not_exists MulAction open Function open Nat universe u v variable {α β γ : Type*} open Finset Function namespace Fintype /-- `card α` is the number of elements in `α`, defined when `α` is a fintype. -/ def card (α) [Fintype α] : ℕ := (@univ α _).card #align fintype.card Fintype.card /-- There is (computably) an equivalence between `α` and `Fin (card α)`. Since it is not unique and depends on which permutation of the universe list is used, the equivalence is wrapped in `Trunc` to preserve computability. See `Fintype.equivFin` for the noncomputable version, and `Fintype.truncEquivFinOfCardEq` and `Fintype.equivFinOfCardEq` for an equiv `α ≃ Fin n` given `Fintype.card α = n`. See `Fintype.truncFinBijection` for a version without `[DecidableEq α]`. -/ def truncEquivFin (α) [DecidableEq α] [Fintype α] : Trunc (α ≃ Fin (card α)) := by unfold card Finset.card exact Quot.recOnSubsingleton' (motive := fun s : Multiset α => (∀ x : α, x ∈ s) → s.Nodup → Trunc (α ≃ Fin (Multiset.card s))) univ.val (fun l (h : ∀ x : α, x ∈ l) (nd : l.Nodup) => Trunc.mk (nd.getEquivOfForallMemList _ h).symm) mem_univ_val univ.2 #align fintype.trunc_equiv_fin Fintype.truncEquivFin /-- There is (noncomputably) an equivalence between `α` and `Fin (card α)`. See `Fintype.truncEquivFin` for the computable version, and `Fintype.truncEquivFinOfCardEq` and `Fintype.equivFinOfCardEq` for an equiv `α ≃ Fin n` given `Fintype.card α = n`. -/ noncomputable def equivFin (α) [Fintype α] : α ≃ Fin (card α) := letI := Classical.decEq α (truncEquivFin α).out #align fintype.equiv_fin Fintype.equivFin /-- There is (computably) a bijection between `Fin (card α)` and `α`. Since it is not unique and depends on which permutation of the universe list is used, the bijection is wrapped in `Trunc` to preserve computability. See `Fintype.truncEquivFin` for a version that gives an equivalence given `[DecidableEq α]`. -/ def truncFinBijection (α) [Fintype α] : Trunc { f : Fin (card α) → α // Bijective f } := by unfold card Finset.card refine Quot.recOnSubsingleton' (motive := fun s : Multiset α => (∀ x : α, x ∈ s) → s.Nodup → Trunc {f : Fin (Multiset.card s) → α // Bijective f}) univ.val (fun l (h : ∀ x : α, x ∈ l) (nd : l.Nodup) => Trunc.mk (nd.getBijectionOfForallMemList _ h)) mem_univ_val univ.2 #align fintype.trunc_fin_bijection Fintype.truncFinBijection theorem subtype_card {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈ s ↔ p x) : @card { x // p x } (Fintype.subtype s H) = s.card := Multiset.card_pmap _ _ _ #align fintype.subtype_card Fintype.subtype_card
Mathlib/Data/Fintype/Card.lean
126
130
theorem card_of_subtype {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈ s ↔ p x) [Fintype { x // p x }] : card { x // p x } = s.card := by
rw [← subtype_card s H] congr apply Subsingleton.elim
/- Copyright (c) 2020 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.MeasureTheory.Measure.MeasureSpace import Mathlib.MeasureTheory.Measure.Regular import Mathlib.Topology.Sets.Compacts #align_import measure_theory.measure.content from "leanprover-community/mathlib"@"d39590fc8728fbf6743249802486f8c91ffe07bc" /-! # Contents In this file we work with *contents*. A content `λ` is a function from a certain class of subsets (such as the compact subsets) to `ℝ≥0` that is * additive: If `K₁` and `K₂` are disjoint sets in the domain of `λ`, then `λ(K₁ ∪ K₂) = λ(K₁) + λ(K₂)`; * subadditive: If `K₁` and `K₂` are in the domain of `λ`, then `λ(K₁ ∪ K₂) ≤ λ(K₁) + λ(K₂)`; * monotone: If `K₁ ⊆ K₂` are in the domain of `λ`, then `λ(K₁) ≤ λ(K₂)`. We show that: * Given a content `λ` on compact sets, let us define a function `λ*` on open sets, by letting `λ* U` be the supremum of `λ K` for `K` included in `U`. This is a countably subadditive map that vanishes at `∅`. In Halmos (1950) this is called the *inner content* `λ*` of `λ`, and formalized as `innerContent`. * Given an inner content, we define an outer measure `μ*`, by letting `μ* E` be the infimum of `λ* U` over the open sets `U` containing `E`. This is indeed an outer measure. It is formalized as `outerMeasure`. * Restricting this outer measure to Borel sets gives a regular measure `μ`. We define bundled contents as `Content`. In this file we only work on contents on compact sets, and inner contents on open sets, and both contents and inner contents map into the extended nonnegative reals. However, in other applications other choices can be made, and it is not a priori clear what the best interface should be. ## Main definitions For `μ : Content G`, we define * `μ.innerContent` : the inner content associated to `μ`. * `μ.outerMeasure` : the outer measure associated to `μ`. * `μ.measure` : the Borel measure associated to `μ`. These definitions are given for spaces which are R₁. The resulting measure `μ.measure` is always outer regular by design. When the space is locally compact, `μ.measure` is also regular. ## References * Paul Halmos (1950), Measure Theory, §53 * <https://en.wikipedia.org/wiki/Content_(measure_theory)> -/ universe u v w noncomputable section open Set TopologicalSpace open NNReal ENNReal MeasureTheory namespace MeasureTheory variable {G : Type w} [TopologicalSpace G] /-- A content is an additive function on compact sets taking values in `ℝ≥0`. It is a device from which one can define a measure. -/ structure Content (G : Type w) [TopologicalSpace G] where toFun : Compacts G → ℝ≥0 mono' : ∀ K₁ K₂ : Compacts G, (K₁ : Set G) ⊆ K₂ → toFun K₁ ≤ toFun K₂ sup_disjoint' : ∀ K₁ K₂ : Compacts G, Disjoint (K₁ : Set G) K₂ → IsClosed (K₁ : Set G) → IsClosed (K₂ : Set G) → toFun (K₁ ⊔ K₂) = toFun K₁ + toFun K₂ sup_le' : ∀ K₁ K₂ : Compacts G, toFun (K₁ ⊔ K₂) ≤ toFun K₁ + toFun K₂ #align measure_theory.content MeasureTheory.Content instance : Inhabited (Content G) := ⟨{ toFun := fun _ => 0 mono' := by simp sup_disjoint' := by simp sup_le' := by simp }⟩ /-- Although the `toFun` field of a content takes values in `ℝ≥0`, we register a coercion to functions taking values in `ℝ≥0∞` as most constructions below rely on taking iSups and iInfs, which is more convenient in a complete lattice, and aim at constructing a measure. -/ instance : CoeFun (Content G) fun _ => Compacts G → ℝ≥0∞ := ⟨fun μ s => μ.toFun s⟩ namespace Content variable (μ : Content G) theorem apply_eq_coe_toFun (K : Compacts G) : μ K = μ.toFun K := rfl #align measure_theory.content.apply_eq_coe_to_fun MeasureTheory.Content.apply_eq_coe_toFun theorem mono (K₁ K₂ : Compacts G) (h : (K₁ : Set G) ⊆ K₂) : μ K₁ ≤ μ K₂ := by simp [apply_eq_coe_toFun, μ.mono' _ _ h] #align measure_theory.content.mono MeasureTheory.Content.mono theorem sup_disjoint (K₁ K₂ : Compacts G) (h : Disjoint (K₁ : Set G) K₂) (h₁ : IsClosed (K₁ : Set G)) (h₂ : IsClosed (K₂ : Set G)) : μ (K₁ ⊔ K₂) = μ K₁ + μ K₂ := by simp [apply_eq_coe_toFun, μ.sup_disjoint' _ _ h] #align measure_theory.content.sup_disjoint MeasureTheory.Content.sup_disjoint theorem sup_le (K₁ K₂ : Compacts G) : μ (K₁ ⊔ K₂) ≤ μ K₁ + μ K₂ := by simp only [apply_eq_coe_toFun] norm_cast exact μ.sup_le' _ _ #align measure_theory.content.sup_le MeasureTheory.Content.sup_le theorem lt_top (K : Compacts G) : μ K < ∞ := ENNReal.coe_lt_top #align measure_theory.content.lt_top MeasureTheory.Content.lt_top
Mathlib/MeasureTheory/Measure/Content.lean
118
120
theorem empty : μ ⊥ = 0 := by
have := μ.sup_disjoint' ⊥ ⊥ simpa [apply_eq_coe_toFun] using this
/- Copyright (c) 2022 Kalle Kytölä. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kalle Kytölä -/ import Mathlib.MeasureTheory.Integral.Lebesgue import Mathlib.Topology.MetricSpace.ThickenedIndicator /-! # Spaces where indicators of closed sets have decreasing approximations by continuous functions In this file we define a typeclass `HasOuterApproxClosed` for topological spaces in which indicator functions of closed sets have sequences of bounded continuous functions approximating them from above. All pseudo-emetrizable spaces have this property, see `instHasOuterApproxClosed`. In spaces with the `HasOuterApproxClosed` property, finite Borel measures are uniquely characterized by the integrals of bounded continuous functions. Also weak convergence of finite measures and convergence in distribution for random variables behave somewhat well in spaces with this property. ## Main definitions * `HasOuterApproxClosed`: the typeclass for topological spaces in which indicator functions of closed sets have sequences of bounded continuous functions approximating them. * `IsClosed.apprSeq`: a (non-constructive) choice of an approximating sequence to the indicator function of a closed set. ## Main results * `instHasOuterApproxClosed`: Any pseudo-emetrizable space has the property `HasOuterApproxClosed`. * `tendsto_lintegral_apprSeq`: The integrals of the approximating functions to the indicator of a closed set tend to the measure of the set. * `ext_of_forall_lintegral_eq_of_IsFiniteMeasure`: Two finite measures are equal if the integrals of all bounded continuous functions with respect to both agree. -/ open MeasureTheory Topology Metric Filter Set ENNReal NNReal open scoped Topology ENNReal NNReal BoundedContinuousFunction section auxiliary namespace MeasureTheory variable {Ω : Type*} [TopologicalSpace Ω] [MeasurableSpace Ω] [OpensMeasurableSpace Ω] /-- A bounded convergence theorem for a finite measure: If bounded continuous non-negative functions are uniformly bounded by a constant and tend to a limit, then their integrals against the finite measure tend to the integral of the limit. This formulation assumes: * the functions tend to a limit along a countably generated filter; * the limit is in the almost everywhere sense; * boundedness holds almost everywhere; * integration is `MeasureTheory.lintegral`, i.e., the functions and their integrals are `ℝ≥0∞`-valued. -/ theorem tendsto_lintegral_nn_filter_of_le_const {ι : Type*} {L : Filter ι} [L.IsCountablyGenerated] (μ : Measure Ω) [IsFiniteMeasure μ] {fs : ι → Ω →ᵇ ℝ≥0} {c : ℝ≥0} (fs_le_const : ∀ᶠ i in L, ∀ᵐ ω : Ω ∂μ, fs i ω ≤ c) {f : Ω → ℝ≥0} (fs_lim : ∀ᵐ ω : Ω ∂μ, Tendsto (fun i ↦ fs i ω) L (𝓝 (f ω))) : Tendsto (fun i ↦ ∫⁻ ω, fs i ω ∂μ) L (𝓝 (∫⁻ ω, f ω ∂μ)) := by refine tendsto_lintegral_filter_of_dominated_convergence (fun _ ↦ c) (eventually_of_forall fun i ↦ (ENNReal.continuous_coe.comp (fs i).continuous).measurable) ?_ (@lintegral_const_lt_top _ _ μ _ _ (@ENNReal.coe_ne_top c)).ne ?_ · simpa only [Function.comp_apply, ENNReal.coe_le_coe] using fs_le_const · simpa only [Function.comp_apply, ENNReal.tendsto_coe] using fs_lim #align measure_theory.finite_measure.tendsto_lintegral_nn_filter_of_le_const MeasureTheory.tendsto_lintegral_nn_filter_of_le_const /-- If bounded continuous functions tend to the indicator of a measurable set and are uniformly bounded, then their integrals against a finite measure tend to the measure of the set. This formulation assumes: * the functions tend to a limit along a countably generated filter; * the limit is in the almost everywhere sense; * boundedness holds almost everywhere. -/ theorem measure_of_cont_bdd_of_tendsto_filter_indicator {ι : Type*} {L : Filter ι} [L.IsCountablyGenerated] [TopologicalSpace Ω] [OpensMeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] {c : ℝ≥0} {E : Set Ω} (E_mble : MeasurableSet E) (fs : ι → Ω →ᵇ ℝ≥0) (fs_bdd : ∀ᶠ i in L, ∀ᵐ ω : Ω ∂μ, fs i ω ≤ c) (fs_lim : ∀ᵐ ω ∂μ, Tendsto (fun i ↦ fs i ω) L (𝓝 (indicator E (fun _ ↦ (1 : ℝ≥0)) ω))) : Tendsto (fun n ↦ lintegral μ fun ω ↦ fs n ω) L (𝓝 (μ E)) := by convert tendsto_lintegral_nn_filter_of_le_const μ fs_bdd fs_lim have aux : ∀ ω, indicator E (fun _ ↦ (1 : ℝ≥0∞)) ω = ↑(indicator E (fun _ ↦ (1 : ℝ≥0)) ω) := fun ω ↦ by simp only [ENNReal.coe_indicator, ENNReal.coe_one] simp_rw [← aux, lintegral_indicator _ E_mble] simp only [lintegral_one, Measure.restrict_apply, MeasurableSet.univ, univ_inter] #align measure_theory.measure_of_cont_bdd_of_tendsto_filter_indicator MeasureTheory.measure_of_cont_bdd_of_tendsto_filter_indicator /-- If a sequence of bounded continuous functions tends to the indicator of a measurable set and the functions are uniformly bounded, then their integrals against a finite measure tend to the measure of the set. A similar result with more general assumptions is `MeasureTheory.measure_of_cont_bdd_of_tendsto_filter_indicator`. -/
Mathlib/MeasureTheory/Measure/HasOuterApproxClosed.lean
95
105
theorem measure_of_cont_bdd_of_tendsto_indicator [OpensMeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] {c : ℝ≥0} {E : Set Ω} (E_mble : MeasurableSet E) (fs : ℕ → Ω →ᵇ ℝ≥0) (fs_bdd : ∀ n ω, fs n ω ≤ c) (fs_lim : Tendsto (fun n ω ↦ fs n ω) atTop (𝓝 (indicator E fun _ ↦ (1 : ℝ≥0)))) : Tendsto (fun n ↦ lintegral μ fun ω ↦ fs n ω) atTop (𝓝 (μ E)) := by
have fs_lim' : ∀ ω, Tendsto (fun n : ℕ ↦ (fs n ω : ℝ≥0)) atTop (𝓝 (indicator E (fun _ ↦ (1 : ℝ≥0)) ω)) := by rw [tendsto_pi_nhds] at fs_lim exact fun ω ↦ fs_lim ω apply measure_of_cont_bdd_of_tendsto_filter_indicator μ E_mble fs (eventually_of_forall fun n ↦ eventually_of_forall (fs_bdd n)) (eventually_of_forall fs_lim')
/- 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]
Mathlib/Data/PNat/Interval.lean
94
99
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]
/- 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.RepresentationTheory.Action.Limits import Mathlib.RepresentationTheory.Action.Concrete import Mathlib.CategoryTheory.Monoidal.FunctorCategory import Mathlib.CategoryTheory.Monoidal.Transport import Mathlib.CategoryTheory.Monoidal.Rigid.OfEquivalence import Mathlib.CategoryTheory.Monoidal.Rigid.FunctorCategory import Mathlib.CategoryTheory.Monoidal.Linear import Mathlib.CategoryTheory.Monoidal.Braided.Basic import Mathlib.CategoryTheory.Monoidal.Types.Basic /-! # Induced monoidal structure on `Action V G` We show: * When `V` is monoidal, braided, or symmetric, so is `Action V G`. -/ universe u v open CategoryTheory Limits variable {V : Type (u + 1)} [LargeCategory V] {G : MonCat.{u}} namespace Action section Monoidal open MonoidalCategory variable [MonoidalCategory V] instance instMonoidalCategory : MonoidalCategory (Action V G) := Monoidal.transport (Action.functorCategoryEquivalence _ _).symm @[simp] theorem tensorUnit_v : (𝟙_ (Action V G)).V = 𝟙_ V := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_unit_V Action.tensorUnit_v -- Porting note: removed @[simp] as the simpNF linter complains theorem tensorUnit_rho {g : G} : (𝟙_ (Action V G)).ρ g = 𝟙 (𝟙_ V) := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_unit_rho Action.tensorUnit_rho @[simp] theorem tensor_v {X Y : Action V G} : (X ⊗ Y).V = X.V ⊗ Y.V := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_V Action.tensor_v -- Porting note: removed @[simp] as the simpNF linter complains theorem tensor_rho {X Y : Action V G} {g : G} : (X ⊗ Y).ρ g = X.ρ g ⊗ Y.ρ g := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_rho Action.tensor_rho @[simp] theorem tensor_hom {W X Y Z : Action V G} (f : W ⟶ X) (g : Y ⟶ Z) : (f ⊗ g).hom = f.hom ⊗ g.hom := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_hom Action.tensor_hom @[simp] theorem whiskerLeft_hom (X : Action V G) {Y Z : Action V G} (f : Y ⟶ Z) : (X ◁ f).hom = X.V ◁ f.hom := rfl @[simp] theorem whiskerRight_hom {X Y : Action V G} (f : X ⟶ Y) (Z : Action V G) : (f ▷ Z).hom = f.hom ▷ Z.V := rfl -- Porting note: removed @[simp] as the simpNF linter complains
Mathlib/RepresentationTheory/Action/Monoidal.lean
82
85
theorem associator_hom_hom {X Y Z : Action V G} : Hom.hom (α_ X Y Z).hom = (α_ X.V Y.V Z.V).hom := by
dsimp simp
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Data.Bundle import Mathlib.Data.Set.Image import Mathlib.Topology.PartialHomeomorph import Mathlib.Topology.Order.Basic #align_import topology.fiber_bundle.trivialization from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Trivializations ## Main definitions ### Basic definitions * `Trivialization F p` : structure extending partial homeomorphisms, defining a local trivialization of a topological space `Z` with projection `p` and fiber `F`. * `Pretrivialization F proj` : trivialization as a partial equivalence, mainly used when the topology on the total space has not yet been defined. ### Operations on bundles We provide the following operations on `Trivialization`s. * `Trivialization.compHomeomorph`: given a local trivialization `e` of a fiber bundle `p : Z → B` and a homeomorphism `h : Z' ≃ₜ Z`, returns a local trivialization of the fiber bundle `p ∘ h`. ## Implementation notes Previously, in mathlib, there was a structure `topological_vector_bundle.trivialization` which extended another structure `topological_fiber_bundle.trivialization` by a linearity hypothesis. As of PR leanprover-community/mathlib#17359, we have changed this to a single structure `Trivialization` (no namespace), together with a mixin class `Trivialization.IsLinear`. This permits all the *data* of a vector bundle to be held at the level of fiber bundles, so that the same trivializations can underlie an object's structure as (say) a vector bundle over `ℂ` and as a vector bundle over `ℝ`, as well as its structure simply as a fiber bundle. This might be a little surprising, given the general trend of the library to ever-increased bundling. But in this case the typical motivation for more bundling does not apply: there is no algebraic or order structure on the whole type of linear (say) trivializations of a bundle. Indeed, since trivializations only have meaning on their base sets (taking junk values outside), the type of linear trivializations is not even particularly well-behaved. -/ open TopologicalSpace Filter Set Bundle Function open scoped Topology Classical Bundle variable {ι : Type*} {B : Type*} {F : Type*} {E : B → Type*} variable (F) {Z : Type*} [TopologicalSpace B] [TopologicalSpace F] {proj : Z → B} /-- This structure contains the information left for a local trivialization (which is implemented below as `Trivialization F proj`) if the total space has not been given a topology, but we have a topology on both the fiber and the base space. Through the construction `topological_fiber_prebundle F proj` it will be possible to promote a `Pretrivialization F proj` to a `Trivialization F proj`. -/ structure Pretrivialization (proj : Z → B) extends PartialEquiv Z (B × F) where open_target : IsOpen target baseSet : Set B open_baseSet : IsOpen baseSet source_eq : source = proj ⁻¹' baseSet target_eq : target = baseSet ×ˢ univ proj_toFun : ∀ p ∈ source, (toFun p).1 = proj p #align pretrivialization Pretrivialization namespace Pretrivialization variable {F} variable (e : Pretrivialization F proj) {x : Z} /-- Coercion of a pretrivialization to a function. We don't use `e.toFun` in the `CoeFun` instance because it is actually `e.toPartialEquiv.toFun`, so `simp` will apply lemmas about `toPartialEquiv`. While we may want to switch to this behavior later, doing it mid-port will break a lot of proofs. -/ @[coe] def toFun' : Z → (B × F) := e.toFun instance : CoeFun (Pretrivialization F proj) fun _ => Z → B × F := ⟨toFun'⟩ @[ext] lemma ext' (e e' : Pretrivialization F proj) (h₁ : e.toPartialEquiv = e'.toPartialEquiv) (h₂ : e.baseSet = e'.baseSet) : e = e' := by cases e; cases e'; congr #align pretrivialization.ext Pretrivialization.ext' -- Porting note (#11215): TODO: move `ext` here? lemma ext {e e' : Pretrivialization F proj} (h₁ : ∀ x, e x = e' x) (h₂ : ∀ x, e.toPartialEquiv.symm x = e'.toPartialEquiv.symm x) (h₃ : e.baseSet = e'.baseSet) : e = e' := by ext1 <;> [ext1; exact h₃] · apply h₁ · apply h₂ · rw [e.source_eq, e'.source_eq, h₃] /-- If the fiber is nonempty, then the projection also is. -/ lemma toPartialEquiv_injective [Nonempty F] : Injective (toPartialEquiv : Pretrivialization F proj → PartialEquiv Z (B × F)) := by refine fun e e' h ↦ ext' _ _ h ?_ simpa only [fst_image_prod, univ_nonempty, target_eq] using congr_arg (Prod.fst '' PartialEquiv.target ·) h @[simp, mfld_simps] theorem coe_coe : ⇑e.toPartialEquiv = e := rfl #align pretrivialization.coe_coe Pretrivialization.coe_coe @[simp, mfld_simps] theorem coe_fst (ex : x ∈ e.source) : (e x).1 = proj x := e.proj_toFun x ex #align pretrivialization.coe_fst Pretrivialization.coe_fst theorem mem_source : x ∈ e.source ↔ proj x ∈ e.baseSet := by rw [e.source_eq, mem_preimage] #align pretrivialization.mem_source Pretrivialization.mem_source theorem coe_fst' (ex : proj x ∈ e.baseSet) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex) #align pretrivialization.coe_fst' Pretrivialization.coe_fst' protected theorem eqOn : EqOn (Prod.fst ∘ e) proj e.source := fun _ hx => e.coe_fst hx #align pretrivialization.eq_on Pretrivialization.eqOn theorem mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x := Prod.ext (e.coe_fst ex).symm rfl #align pretrivialization.mk_proj_snd Pretrivialization.mk_proj_snd theorem mk_proj_snd' (ex : proj x ∈ e.baseSet) : (proj x, (e x).2) = e x := Prod.ext (e.coe_fst' ex).symm rfl #align pretrivialization.mk_proj_snd' Pretrivialization.mk_proj_snd' /-- Composition of inverse and coercion from the subtype of the target. -/ def setSymm : e.target → Z := e.target.restrict e.toPartialEquiv.symm #align pretrivialization.set_symm Pretrivialization.setSymm
Mathlib/Topology/FiberBundle/Trivialization.lean
141
142
theorem mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.baseSet := by
rw [e.target_eq, prod_univ, mem_preimage]
/- Copyright (c) 2020 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp -/ import Mathlib.Algebra.Algebra.Spectrum import Mathlib.LinearAlgebra.GeneralLinearGroup import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.RingTheory.Nilpotent.Basic #align_import linear_algebra.eigenspace.basic from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1" /-! # Eigenvectors and eigenvalues This file defines eigenspaces, eigenvalues, and eigenvalues, as well as their generalized counterparts. We follow Axler's approach [axler2015] because it allows us to derive many properties without choosing a basis and without using matrices. An eigenspace of a linear map `f` for a scalar `μ` is the kernel of the map `(f - μ • id)`. The nonzero elements of an eigenspace are eigenvectors `x`. They have the property `f x = μ • x`. If there are eigenvectors for a scalar `μ`, the scalar `μ` is called an eigenvalue. There is no consensus in the literature whether `0` is an eigenvector. Our definition of `HasEigenvector` permits only nonzero vectors. For an eigenvector `x` that may also be `0`, we write `x ∈ f.eigenspace μ`. A generalized eigenspace of a linear map `f` for a natural number `k` and a scalar `μ` is the kernel of the map `(f - μ • id) ^ k`. The nonzero elements of a generalized eigenspace are generalized eigenvectors `x`. If there are generalized eigenvectors for a natural number `k` and a scalar `μ`, the scalar `μ` is called a generalized eigenvalue. The fact that the eigenvalues are the roots of the minimal polynomial is proved in `LinearAlgebra.Eigenspace.Minpoly`. The existence of eigenvalues over an algebraically closed field (and the fact that the generalized eigenspaces then span) is deferred to `LinearAlgebra.Eigenspace.IsAlgClosed`. ## References * [Sheldon Axler, *Linear Algebra Done Right*][axler2015] * https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors ## Tags eigenspace, eigenvector, eigenvalue, eigen -/ universe u v w namespace Module namespace End open FiniteDimensional Set variable {K R : Type v} {V M : Type w} [CommRing R] [AddCommGroup M] [Module R M] [Field K] [AddCommGroup V] [Module K V] /-- The submodule `eigenspace f μ` for a linear map `f` and a scalar `μ` consists of all vectors `x` such that `f x = μ • x`. (Def 5.36 of [axler2015])-/ def eigenspace (f : End R M) (μ : R) : Submodule R M := LinearMap.ker (f - algebraMap R (End R M) μ) #align module.End.eigenspace Module.End.eigenspace @[simp]
Mathlib/LinearAlgebra/Eigenspace/Basic.lean
69
69
theorem eigenspace_zero (f : End R M) : f.eigenspace 0 = LinearMap.ker f := by
simp [eigenspace]
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jalex Stark -/ import Mathlib.Algebra.Polynomial.Monic #align_import algebra.polynomial.big_operators from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722" /-! # Lemmas for the interaction between polynomials and `∑` and `∏`. Recall that `∑` and `∏` are notation for `Finset.sum` and `Finset.prod` respectively. ## Main results - `Polynomial.natDegree_prod_of_monic` : the degree of a product of monic polynomials is the product of degrees. We prove this only for `[CommSemiring R]`, but it ought to be true for `[Semiring R]` and `List.prod`. - `Polynomial.natDegree_prod` : for polynomials over an integral domain, the degree of the product is the sum of degrees. - `Polynomial.leadingCoeff_prod` : for polynomials over an integral domain, the leading coefficient is the product of leading coefficients. - `Polynomial.prod_X_sub_C_coeff_card_pred` carries most of the content for computing the second coefficient of the characteristic polynomial. -/ open Finset open Multiset open Polynomial universe u w variable {R : Type u} {ι : Type w} namespace Polynomial variable (s : Finset ι) section Semiring variable {S : Type*} [Semiring S] set_option backward.isDefEq.lazyProjDelta false in -- See https://github.com/leanprover-community/mathlib4/issues/12535 theorem natDegree_list_sum_le (l : List S[X]) : natDegree l.sum ≤ (l.map natDegree).foldr max 0 := List.sum_le_foldr_max natDegree (by simp) natDegree_add_le _ #align polynomial.nat_degree_list_sum_le Polynomial.natDegree_list_sum_le theorem natDegree_multiset_sum_le (l : Multiset S[X]) : natDegree l.sum ≤ (l.map natDegree).foldr max max_left_comm 0 := Quotient.inductionOn l (by simpa using natDegree_list_sum_le) #align polynomial.nat_degree_multiset_sum_le Polynomial.natDegree_multiset_sum_le theorem natDegree_sum_le (f : ι → S[X]) : natDegree (∑ i ∈ s, f i) ≤ s.fold max 0 (natDegree ∘ f) := by simpa using natDegree_multiset_sum_le (s.val.map f) #align polynomial.nat_degree_sum_le Polynomial.natDegree_sum_le lemma natDegree_sum_le_of_forall_le {n : ℕ} (f : ι → S[X]) (h : ∀ i ∈ s, natDegree (f i) ≤ n) : natDegree (∑ i ∈ s, f i) ≤ n := le_trans (natDegree_sum_le s f) <| (Finset.fold_max_le n).mpr <| by simpa theorem degree_list_sum_le (l : List S[X]) : degree l.sum ≤ (l.map natDegree).maximum := by by_cases h : l.sum = 0 · simp [h] · rw [degree_eq_natDegree h] suffices (l.map natDegree).maximum = ((l.map natDegree).foldr max 0 : ℕ) by rw [this] simpa using natDegree_list_sum_le l rw [← List.foldr_max_of_ne_nil] · congr contrapose! h rw [List.map_eq_nil] at h simp [h] #align polynomial.degree_list_sum_le Polynomial.degree_list_sum_le theorem natDegree_list_prod_le (l : List S[X]) : natDegree l.prod ≤ (l.map natDegree).sum := by induction' l with hd tl IH · simp · simpa using natDegree_mul_le.trans (add_le_add_left IH _) #align polynomial.nat_degree_list_prod_le Polynomial.natDegree_list_prod_le theorem degree_list_prod_le (l : List S[X]) : degree l.prod ≤ (l.map degree).sum := by induction' l with hd tl IH · simp · simpa using (degree_mul_le _ _).trans (add_le_add_left IH _) #align polynomial.degree_list_prod_le Polynomial.degree_list_prod_le
Mathlib/Algebra/Polynomial/BigOperators.lean
92
111
theorem coeff_list_prod_of_natDegree_le (l : List S[X]) (n : ℕ) (hl : ∀ p ∈ l, natDegree p ≤ n) : coeff (List.prod l) (l.length * n) = (l.map fun p => coeff p n).prod := by
induction' l with hd tl IH · simp · have hl' : ∀ p ∈ tl, natDegree p ≤ n := fun p hp => hl p (List.mem_cons_of_mem _ hp) simp only [List.prod_cons, List.map, List.length] rw [add_mul, one_mul, add_comm, ← IH hl', mul_comm tl.length] have h : natDegree tl.prod ≤ n * tl.length := by refine (natDegree_list_prod_le _).trans ?_ rw [← tl.length_map natDegree, mul_comm] refine List.sum_le_card_nsmul _ _ ?_ simpa using hl' have hdn : natDegree hd ≤ n := hl _ (List.mem_cons_self _ _) rcases hdn.eq_or_lt with (rfl | hdn') · rcases h.eq_or_lt with h' | h' · rw [← h', coeff_mul_degree_add_degree, leadingCoeff, leadingCoeff] · rw [coeff_eq_zero_of_natDegree_lt, coeff_eq_zero_of_natDegree_lt h', mul_zero] exact natDegree_mul_le.trans_lt (add_lt_add_left h' _) · rw [coeff_eq_zero_of_natDegree_lt hdn', coeff_eq_zero_of_natDegree_lt, zero_mul] exact natDegree_mul_le.trans_lt (add_lt_add_of_lt_of_le hdn' h)
/- Copyright (c) 2022 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Polynomial.Degree.Definitions #align_import ring_theory.polynomial.opposites from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0" /-! # Interactions between `R[X]` and `Rᵐᵒᵖ[X]` This file contains the basic API for "pushing through" the isomorphism `opRingEquiv : R[X]ᵐᵒᵖ ≃+* Rᵐᵒᵖ[X]`. It allows going back and forth between a polynomial ring over a semiring and the polynomial ring over the opposite semiring. -/ open Polynomial open Polynomial MulOpposite variable {R : Type*} [Semiring R] noncomputable section namespace Polynomial /-- Ring isomorphism between `R[X]ᵐᵒᵖ` and `Rᵐᵒᵖ[X]` sending each coefficient of a polynomial to the corresponding element of the opposite ring. -/ def opRingEquiv (R : Type*) [Semiring R] : R[X]ᵐᵒᵖ ≃+* Rᵐᵒᵖ[X] := ((toFinsuppIso R).op.trans AddMonoidAlgebra.opRingEquiv).trans (toFinsuppIso _).symm #align polynomial.op_ring_equiv Polynomial.opRingEquiv /-! Lemmas to get started, using `opRingEquiv R` on the various expressions of `Finsupp.single`: `monomial`, `C a`, `X`, `C a * X ^ n`. -/ @[simp] theorem opRingEquiv_op_monomial (n : ℕ) (r : R) : opRingEquiv R (op (monomial n r : R[X])) = monomial n (op r) := by simp only [opRingEquiv, RingEquiv.coe_trans, Function.comp_apply, AddMonoidAlgebra.opRingEquiv_apply, RingEquiv.op_apply_apply, toFinsuppIso_apply, unop_op, toFinsupp_monomial, Finsupp.mapRange_single, toFinsuppIso_symm_apply, ofFinsupp_single] #align polynomial.op_ring_equiv_op_monomial Polynomial.opRingEquiv_op_monomial @[simp] theorem opRingEquiv_op_C (a : R) : opRingEquiv R (op (C a)) = C (op a) := opRingEquiv_op_monomial 0 a set_option linter.uppercaseLean3 false in #align polynomial.op_ring_equiv_op_C Polynomial.opRingEquiv_op_C @[simp] theorem opRingEquiv_op_X : opRingEquiv R (op (X : R[X])) = X := opRingEquiv_op_monomial 1 1 set_option linter.uppercaseLean3 false in #align polynomial.op_ring_equiv_op_X Polynomial.opRingEquiv_op_X
Mathlib/RingTheory/Polynomial/Opposites.lean
57
59
theorem opRingEquiv_op_C_mul_X_pow (r : R) (n : ℕ) : opRingEquiv R (op (C r * X ^ n : R[X])) = C (op r) * X ^ n := by
simp only [X_pow_mul, op_mul, op_pow, map_mul, map_pow, opRingEquiv_op_X, opRingEquiv_op_C]
/- Copyright (c) 2019 Kevin Kappelmann. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Kappelmann, Kyle Miller, Mario Carneiro -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Finset.NatAntidiagonal import Mathlib.Data.Nat.GCD.Basic import Mathlib.Init.Data.Nat.Lemmas import Mathlib.Logic.Function.Iterate import Mathlib.Tactic.Ring import Mathlib.Tactic.Zify #align_import data.nat.fib from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" /-! # Fibonacci Numbers This file defines the fibonacci series, proves results about it and introduces methods to compute it quickly. -/ /-! # The Fibonacci Sequence ## Summary Definition of the Fibonacci sequence `F₀ = 0, F₁ = 1, Fₙ₊₂ = Fₙ + Fₙ₊₁`. ## Main Definitions - `Nat.fib` returns the stream of Fibonacci numbers. ## Main Statements - `Nat.fib_add_two`: shows that `fib` indeed satisfies the Fibonacci recurrence `Fₙ₊₂ = Fₙ + Fₙ₊₁.`. - `Nat.fib_gcd`: `fib n` is a strong divisibility sequence. - `Nat.fib_succ_eq_sum_choose`: `fib` is given by the sum of `Nat.choose` along an antidiagonal. - `Nat.fib_succ_eq_succ_sum`: shows that `F₀ + F₁ + ⋯ + Fₙ = Fₙ₊₂ - 1`. - `Nat.fib_two_mul` and `Nat.fib_two_mul_add_one` are the basis for an efficient algorithm to compute `fib` (see `Nat.fastFib`). There are `bit0`/`bit1` variants of these can be used to simplify `fib` expressions: `simp only [Nat.fib_bit0, Nat.fib_bit1, Nat.fib_bit0_succ, Nat.fib_bit1_succ, Nat.fib_one, Nat.fib_two]`. ## Implementation Notes For efficiency purposes, the sequence is defined using `Stream.iterate`. ## Tags fib, fibonacci -/ namespace Nat /-- Implementation of the fibonacci sequence satisfying `fib 0 = 0, fib 1 = 1, fib (n + 2) = fib n + fib (n + 1)`. *Note:* We use a stream iterator for better performance when compared to the naive recursive implementation. -/ -- Porting note: Lean cannot find pp_nodot at the time of this port. -- @[pp_nodot] def fib (n : ℕ) : ℕ := ((fun p : ℕ × ℕ => (p.snd, p.fst + p.snd))^[n] (0, 1)).fst #align nat.fib Nat.fib @[simp] theorem fib_zero : fib 0 = 0 := rfl #align nat.fib_zero Nat.fib_zero @[simp] theorem fib_one : fib 1 = 1 := rfl #align nat.fib_one Nat.fib_one @[simp] theorem fib_two : fib 2 = 1 := rfl #align nat.fib_two Nat.fib_two /-- Shows that `fib` indeed satisfies the Fibonacci recurrence `Fₙ₊₂ = Fₙ + Fₙ₊₁.` -/ theorem fib_add_two {n : ℕ} : fib (n + 2) = fib n + fib (n + 1) := by simp [fib, Function.iterate_succ_apply'] #align nat.fib_add_two Nat.fib_add_two lemma fib_add_one : ∀ {n}, n ≠ 0 → fib (n + 1) = fib (n - 1) + fib n | _n + 1, _ => fib_add_two theorem fib_le_fib_succ {n : ℕ} : fib n ≤ fib (n + 1) := by cases n <;> simp [fib_add_two] #align nat.fib_le_fib_succ Nat.fib_le_fib_succ @[mono] theorem fib_mono : Monotone fib := monotone_nat_of_le_succ fun _ => fib_le_fib_succ #align nat.fib_mono Nat.fib_mono @[simp] lemma fib_eq_zero : ∀ {n}, fib n = 0 ↔ n = 0 | 0 => Iff.rfl | 1 => Iff.rfl | n + 2 => by simp [fib_add_two, fib_eq_zero] @[simp] lemma fib_pos {n : ℕ} : 0 < fib n ↔ 0 < n := by simp [pos_iff_ne_zero] #align nat.fib_pos Nat.fib_pos theorem fib_add_two_sub_fib_add_one {n : ℕ} : fib (n + 2) - fib (n + 1) = fib n := by rw [fib_add_two, add_tsub_cancel_right] #align nat.fib_add_two_sub_fib_add_one Nat.fib_add_two_sub_fib_add_one theorem fib_lt_fib_succ {n : ℕ} (hn : 2 ≤ n) : fib n < fib (n + 1) := by rcases exists_add_of_le hn with ⟨n, rfl⟩ rw [← tsub_pos_iff_lt, add_comm 2, add_right_comm, fib_add_two, add_tsub_cancel_right, fib_pos] exact succ_pos n #align nat.fib_lt_fib_succ Nat.fib_lt_fib_succ /-- `fib (n + 2)` is strictly monotone. -/
Mathlib/Data/Nat/Fib/Basic.lean
121
124
theorem fib_add_two_strictMono : StrictMono fun n => fib (n + 2) := by
refine strictMono_nat_of_lt_succ fun n => ?_ rw [add_right_comm] exact fib_lt_fib_succ (self_le_add_left _ _)
/- Copyright (c) 2021 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Algebra.MvPolynomial.Equiv import Mathlib.Algebra.MvPolynomial.Supported import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.RingTheory.Adjoin.Basic import Mathlib.RingTheory.Algebraic import Mathlib.RingTheory.MvPolynomial.Basic #align_import ring_theory.algebraic_independent from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69" /-! # Algebraic Independence This file defines algebraic independence of a family of element of an `R` algebra. ## Main definitions * `AlgebraicIndependent` - `AlgebraicIndependent R x` states the family of elements `x` is algebraically independent over `R`, meaning that the canonical map out of the multivariable polynomial ring is injective. * `AlgebraicIndependent.repr` - The canonical map from the subalgebra generated by an algebraic independent family into the polynomial ring. ## References * [Stacks: Transcendence](https://stacks.math.columbia.edu/tag/030D) ## TODO Define the transcendence degree and show it is independent of the choice of a transcendence basis. ## Tags transcendence basis, transcendence degree, transcendence -/ noncomputable section open Function Set Subalgebra MvPolynomial Algebra open scoped Classical universe x u v w variable {ι : Type*} {ι' : Type*} (R : Type*) {K : Type*} variable {A : Type*} {A' A'' : Type*} {V : Type u} {V' : Type*} variable (x : ι → A) variable [CommRing R] [CommRing A] [CommRing A'] [CommRing A''] variable [Algebra R A] [Algebra R A'] [Algebra R A''] variable {a b : R} /-- `AlgebraicIndependent R x` states the family of elements `x` is algebraically independent over `R`, meaning that the canonical map out of the multivariable polynomial ring is injective. -/ def AlgebraicIndependent : Prop := Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A) #align algebraic_independent AlgebraicIndependent variable {R} {x} theorem algebraicIndependent_iff_ker_eq_bot : AlgebraicIndependent R x ↔ RingHom.ker (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A).toRingHom = ⊥ := RingHom.injective_iff_ker_eq_bot _ #align algebraic_independent_iff_ker_eq_bot algebraicIndependent_iff_ker_eq_bot theorem algebraicIndependent_iff : AlgebraicIndependent R x ↔ ∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 := injective_iff_map_eq_zero _ #align algebraic_independent_iff algebraicIndependent_iff theorem AlgebraicIndependent.eq_zero_of_aeval_eq_zero (h : AlgebraicIndependent R x) : ∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 := algebraicIndependent_iff.1 h #align algebraic_independent.eq_zero_of_aeval_eq_zero AlgebraicIndependent.eq_zero_of_aeval_eq_zero theorem algebraicIndependent_iff_injective_aeval : AlgebraicIndependent R x ↔ Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A) := Iff.rfl #align algebraic_independent_iff_injective_aeval algebraicIndependent_iff_injective_aeval @[simp] theorem algebraicIndependent_empty_type_iff [IsEmpty ι] : AlgebraicIndependent R x ↔ Injective (algebraMap R A) := by have : aeval x = (Algebra.ofId R A).comp (@isEmptyAlgEquiv R ι _ _).toAlgHom := by ext i exact IsEmpty.elim' ‹IsEmpty ι› i rw [AlgebraicIndependent, this, ← Injective.of_comp_iff' _ (@isEmptyAlgEquiv R ι _ _).bijective] rfl #align algebraic_independent_empty_type_iff algebraicIndependent_empty_type_iff namespace AlgebraicIndependent variable (hx : AlgebraicIndependent R x)
Mathlib/RingTheory/AlgebraicIndependent.lean
103
106
theorem algebraMap_injective : Injective (algebraMap R A) := by
simpa [Function.comp] using (Injective.of_comp_iff (algebraicIndependent_iff_injective_aeval.1 hx) MvPolynomial.C).2 (MvPolynomial.C_injective _ _)
/- Copyright (c) 2022 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.CategoryTheory.Limits.Shapes.Biproducts import Mathlib.GroupTheory.EckmannHilton import Mathlib.Tactic.CategoryTheory.Reassoc #align_import category_theory.preadditive.of_biproducts from "leanprover-community/mathlib"@"061ea99a5610cfc72c286aa930d3c1f47f74f3d0" /-! # Constructing a semiadditive structure from binary biproducts We show that any category with zero morphisms and binary biproducts is enriched over the category of commutative monoids. -/ noncomputable section universe v u open CategoryTheory open CategoryTheory.Limits namespace CategoryTheory.SemiadditiveOfBinaryBiproducts variable {C : Type u} [Category.{v} C] [HasZeroMorphisms C] [HasBinaryBiproducts C] section variable (X Y : C) /-- `f +ₗ g` is the composite `X ⟶ Y ⊞ Y ⟶ Y`, where the first map is `(f, g)` and the second map is `(𝟙 𝟙)`. -/ @[simp] def leftAdd (f g : X ⟶ Y) : X ⟶ Y := biprod.lift f g ≫ biprod.desc (𝟙 Y) (𝟙 Y) #align category_theory.semiadditive_of_binary_biproducts.left_add CategoryTheory.SemiadditiveOfBinaryBiproducts.leftAdd /-- `f +ᵣ g` is the composite `X ⟶ X ⊞ X ⟶ Y`, where the first map is `(𝟙, 𝟙)` and the second map is `(f g)`. -/ @[simp] def rightAdd (f g : X ⟶ Y) : X ⟶ Y := biprod.lift (𝟙 X) (𝟙 X) ≫ biprod.desc f g #align category_theory.semiadditive_of_binary_biproducts.right_add CategoryTheory.SemiadditiveOfBinaryBiproducts.rightAdd local infixr:65 " +ₗ " => leftAdd X Y local infixr:65 " +ᵣ " => rightAdd X Y theorem isUnital_leftAdd : EckmannHilton.IsUnital (· +ₗ ·) 0 := by have hr : ∀ f : X ⟶ Y, biprod.lift (0 : X ⟶ Y) f = f ≫ biprod.inr := by intro f ext · aesop_cat · simp [biprod.lift_fst, Category.assoc, biprod.inr_fst, comp_zero] have hl : ∀ f : X ⟶ Y, biprod.lift f (0 : X ⟶ Y) = f ≫ biprod.inl := by intro f ext · aesop_cat · simp [biprod.lift_snd, Category.assoc, biprod.inl_snd, comp_zero] exact { left_id := fun f => by simp [hr f, leftAdd, Category.assoc, Category.comp_id, biprod.inr_desc], right_id := fun f => by simp [hl f, leftAdd, Category.assoc, Category.comp_id, biprod.inl_desc] } #align category_theory.semiadditive_of_binary_biproducts.is_unital_left_add CategoryTheory.SemiadditiveOfBinaryBiproducts.isUnital_leftAdd
Mathlib/CategoryTheory/Preadditive/OfBiproducts.lean
71
85
theorem isUnital_rightAdd : EckmannHilton.IsUnital (· +ᵣ ·) 0 := by
have h₂ : ∀ f : X ⟶ Y, biprod.desc (0 : X ⟶ Y) f = biprod.snd ≫ f := by intro f ext · aesop_cat · simp only [biprod.inr_desc, BinaryBicone.inr_snd_assoc] have h₁ : ∀ f : X ⟶ Y, biprod.desc f (0 : X ⟶ Y) = biprod.fst ≫ f := by intro f ext · aesop_cat · simp only [biprod.inr_desc, BinaryBicone.inr_fst_assoc, zero_comp] exact { left_id := fun f => by simp [h₂ f, rightAdd, biprod.lift_snd_assoc, Category.id_comp], right_id := fun f => by simp [h₁ f, rightAdd, biprod.lift_fst_assoc, Category.id_comp] }
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.MeasureTheory.Measure.Dirac /-! # Counting measure In this file we define the counting measure `MeasurTheory.Measure.count` as `MeasureTheory.Measure.sum MeasureTheory.Measure.dirac` and prove basic properties of this measure. -/ set_option autoImplicit true open Set open scoped ENNReal Classical variable [MeasurableSpace α] [MeasurableSpace β] {s : Set α} noncomputable section namespace MeasureTheory.Measure /-- Counting measure on any measurable space. -/ def count : Measure α := sum dirac #align measure_theory.measure.count MeasureTheory.Measure.count theorem le_count_apply : ∑' _ : s, (1 : ℝ≥0∞) ≤ count s := calc (∑' _ : s, 1 : ℝ≥0∞) = ∑' i, indicator s 1 i := tsum_subtype s 1 _ ≤ ∑' i, dirac i s := ENNReal.tsum_le_tsum fun _ => le_dirac_apply _ ≤ count s := le_sum_apply _ _ #align measure_theory.measure.le_count_apply MeasureTheory.Measure.le_count_apply theorem count_apply (hs : MeasurableSet s) : count s = ∑' i : s, 1 := by simp only [count, sum_apply, hs, dirac_apply', ← tsum_subtype s (1 : α → ℝ≥0∞), Pi.one_apply] #align measure_theory.measure.count_apply MeasureTheory.Measure.count_apply -- @[simp] -- Porting note (#10618): simp can prove this theorem count_empty : count (∅ : Set α) = 0 := by rw [count_apply MeasurableSet.empty, tsum_empty] #align measure_theory.measure.count_empty MeasureTheory.Measure.count_empty @[simp] theorem count_apply_finset' {s : Finset α} (s_mble : MeasurableSet (s : Set α)) : count (↑s : Set α) = s.card := calc count (↑s : Set α) = ∑' i : (↑s : Set α), 1 := count_apply s_mble _ = ∑ i ∈ s, 1 := s.tsum_subtype 1 _ = s.card := by simp #align measure_theory.measure.count_apply_finset' MeasureTheory.Measure.count_apply_finset' @[simp] theorem count_apply_finset [MeasurableSingletonClass α] (s : Finset α) : count (↑s : Set α) = s.card := count_apply_finset' s.measurableSet #align measure_theory.measure.count_apply_finset MeasureTheory.Measure.count_apply_finset
Mathlib/MeasureTheory/Measure/Count.lean
62
65
theorem count_apply_finite' {s : Set α} (s_fin : s.Finite) (s_mble : MeasurableSet s) : count s = s_fin.toFinset.card := by
simp [← @count_apply_finset' _ _ s_fin.toFinset (by simpa only [Finite.coe_toFinset] using s_mble)]
/- Copyright (c) 2019 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp, Yury Kudryashov, Yaël Dillies -/ import Mathlib.Algebra.Order.Invertible import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.LinearAlgebra.Ray import Mathlib.Tactic.GCongr #align_import analysis.convex.segment from "leanprover-community/mathlib"@"c5773405394e073885e2a144c9ca14637e8eb963" /-! # Segments in vector spaces In a 𝕜-vector space, we define the following objects and properties. * `segment 𝕜 x y`: Closed segment joining `x` and `y`. * `openSegment 𝕜 x y`: Open segment joining `x` and `y`. ## Notations We provide the following notation: * `[x -[𝕜] y] = segment 𝕜 x y` in locale `Convex` ## TODO Generalize all this file to affine spaces. Should we rename `segment` and `openSegment` to `convex.Icc` and `convex.Ioo`? Should we also define `clopenSegment`/`convex.Ico`/`convex.Ioc`? -/ variable {𝕜 E F G ι : Type*} {π : ι → Type*} open Function Set open Pointwise Convex section OrderedSemiring variable [OrderedSemiring 𝕜] [AddCommMonoid E] section SMul variable (𝕜) [SMul 𝕜 E] {s : Set E} {x y : E} /-- Segments in a vector space. -/ def segment (x y : E) : Set E := { z : E | ∃ a b : 𝕜, 0 ≤ a ∧ 0 ≤ b ∧ a + b = 1 ∧ a • x + b • y = z } #align segment segment /-- Open segment in a vector space. Note that `openSegment 𝕜 x x = {x}` instead of being `∅` when the base semiring has some element between `0` and `1`. -/ def openSegment (x y : E) : Set E := { z : E | ∃ a b : 𝕜, 0 < a ∧ 0 < b ∧ a + b = 1 ∧ a • x + b • y = z } #align open_segment openSegment @[inherit_doc] scoped[Convex] notation (priority := high) "[" x "-[" 𝕜 "]" y "]" => segment 𝕜 x y theorem segment_eq_image₂ (x y : E) : [x -[𝕜] y] = (fun p : 𝕜 × 𝕜 => p.1 • x + p.2 • y) '' { p | 0 ≤ p.1 ∧ 0 ≤ p.2 ∧ p.1 + p.2 = 1 } := by simp only [segment, image, Prod.exists, mem_setOf_eq, exists_prop, and_assoc] #align segment_eq_image₂ segment_eq_image₂
Mathlib/Analysis/Convex/Segment.lean
68
71
theorem openSegment_eq_image₂ (x y : E) : openSegment 𝕜 x y = (fun p : 𝕜 × 𝕜 => p.1 • x + p.2 • y) '' { p | 0 < p.1 ∧ 0 < p.2 ∧ p.1 + p.2 = 1 } := by
simp only [openSegment, image, Prod.exists, mem_setOf_eq, exists_prop, and_assoc]
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Manuel Candales -/ import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine import Mathlib.Tactic.IntervalCases #align_import geometry.euclidean.triangle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Triangles This file proves basic geometrical results about distances and angles in (possibly degenerate) triangles in real inner product spaces and Euclidean affine spaces. More specialized results, and results developed for simplices in general rather than just for triangles, are in separate files. Definitions and results that make sense in more general affine spaces rather than just in the Euclidean case go under `LinearAlgebra.AffineSpace`. ## 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/Law_of_cosines * https://en.wikipedia.org/wiki/Pons_asinorum * https://en.wikipedia.org/wiki/Sum_of_angles_of_a_triangle -/ noncomputable section open scoped Classical open scoped Real open scoped RealInnerProductSpace namespace InnerProductGeometry /-! ### Geometrical results on triangles in real inner product spaces This section develops some results on (possibly degenerate) triangles in real inner product spaces, where those definitions and results can most conveniently be developed in terms of vectors and then used to deduce corresponding results for Euclidean affine spaces. -/ variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] /-- **Law of cosines** (cosine rule), vector angle form. -/ theorem norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle (x y : V) : ‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) := by rw [show 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) = 2 * (Real.cos (angle x y) * (‖x‖ * ‖y‖)) by ring, cos_angle_mul_norm_mul_norm, ← real_inner_self_eq_norm_mul_norm, ← real_inner_self_eq_norm_mul_norm, ← real_inner_self_eq_norm_mul_norm, real_inner_sub_sub_self, sub_add_eq_add_sub] #align inner_product_geometry.norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle InnerProductGeometry.norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle /-- **Pons asinorum**, vector angle form. -/
Mathlib/Geometry/Euclidean/Triangle.lean
71
75
theorem angle_sub_eq_angle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) : angle x (x - y) = angle y (y - x) := by
refine Real.injOn_cos ⟨angle_nonneg _ _, angle_le_pi _ _⟩ ⟨angle_nonneg _ _, angle_le_pi _ _⟩ ?_ rw [cos_angle, cos_angle, h, ← neg_sub, norm_neg, neg_sub, inner_sub_right, inner_sub_right, real_inner_self_eq_norm_mul_norm, real_inner_self_eq_norm_mul_norm, h, real_inner_comm x y]
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Floris van Doorn -/ import Mathlib.Geometry.Manifold.MFDeriv.Basic /-! ### Relations between vector space derivative and manifold derivative The manifold derivative `mfderiv`, when considered on the model vector space with its trivial manifold structure, coincides with the usual Frechet derivative `fderiv`. In this section, we prove this and related statements. -/ noncomputable section open scoped Manifold variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {f : E → E'} {s : Set E} {x : E} section MFDerivFderiv theorem uniqueMDiffWithinAt_iff_uniqueDiffWithinAt : UniqueMDiffWithinAt 𝓘(𝕜, E) s x ↔ UniqueDiffWithinAt 𝕜 s x := by simp only [UniqueMDiffWithinAt, mfld_simps] #align unique_mdiff_within_at_iff_unique_diff_within_at uniqueMDiffWithinAt_iff_uniqueDiffWithinAt alias ⟨UniqueMDiffWithinAt.uniqueDiffWithinAt, UniqueDiffWithinAt.uniqueMDiffWithinAt⟩ := uniqueMDiffWithinAt_iff_uniqueDiffWithinAt #align unique_mdiff_within_at.unique_diff_within_at UniqueMDiffWithinAt.uniqueDiffWithinAt #align unique_diff_within_at.unique_mdiff_within_at UniqueDiffWithinAt.uniqueMDiffWithinAt theorem uniqueMDiffOn_iff_uniqueDiffOn : UniqueMDiffOn 𝓘(𝕜, E) s ↔ UniqueDiffOn 𝕜 s := by simp [UniqueMDiffOn, UniqueDiffOn, uniqueMDiffWithinAt_iff_uniqueDiffWithinAt] #align unique_mdiff_on_iff_unique_diff_on uniqueMDiffOn_iff_uniqueDiffOn alias ⟨UniqueMDiffOn.uniqueDiffOn, UniqueDiffOn.uniqueMDiffOn⟩ := uniqueMDiffOn_iff_uniqueDiffOn #align unique_mdiff_on.unique_diff_on UniqueMDiffOn.uniqueDiffOn #align unique_diff_on.unique_mdiff_on UniqueDiffOn.uniqueMDiffOn -- Porting note (#10618): was `@[simp, mfld_simps]` but `simp` can prove it theorem writtenInExtChartAt_model_space : writtenInExtChartAt 𝓘(𝕜, E) 𝓘(𝕜, E') x f = f := rfl #align written_in_ext_chart_model_space writtenInExtChartAt_model_space theorem hasMFDerivWithinAt_iff_hasFDerivWithinAt {f'} : HasMFDerivWithinAt 𝓘(𝕜, E) 𝓘(𝕜, E') f s x f' ↔ HasFDerivWithinAt f f' s x := by simpa only [HasMFDerivWithinAt, and_iff_right_iff_imp, mfld_simps] using HasFDerivWithinAt.continuousWithinAt #align has_mfderiv_within_at_iff_has_fderiv_within_at hasMFDerivWithinAt_iff_hasFDerivWithinAt alias ⟨HasMFDerivWithinAt.hasFDerivWithinAt, HasFDerivWithinAt.hasMFDerivWithinAt⟩ := hasMFDerivWithinAt_iff_hasFDerivWithinAt #align has_mfderiv_within_at.has_fderiv_within_at HasMFDerivWithinAt.hasFDerivWithinAt #align has_fderiv_within_at.has_mfderiv_within_at HasFDerivWithinAt.hasMFDerivWithinAt theorem hasMFDerivAt_iff_hasFDerivAt {f'} : HasMFDerivAt 𝓘(𝕜, E) 𝓘(𝕜, E') f x f' ↔ HasFDerivAt f f' x := by rw [← hasMFDerivWithinAt_univ, hasMFDerivWithinAt_iff_hasFDerivWithinAt, hasFDerivWithinAt_univ] #align has_mfderiv_at_iff_has_fderiv_at hasMFDerivAt_iff_hasFDerivAt alias ⟨HasMFDerivAt.hasFDerivAt, HasFDerivAt.hasMFDerivAt⟩ := hasMFDerivAt_iff_hasFDerivAt #align has_mfderiv_at.has_fderiv_at HasMFDerivAt.hasFDerivAt #align has_fderiv_at.has_mfderiv_at HasFDerivAt.hasMFDerivAt /-- For maps between vector spaces, `MDifferentiableWithinAt` and `DifferentiableWithinAt` coincide -/ theorem mdifferentiableWithinAt_iff_differentiableWithinAt : MDifferentiableWithinAt 𝓘(𝕜, E) 𝓘(𝕜, E') f s x ↔ DifferentiableWithinAt 𝕜 f s x := by simp only [mdifferentiableWithinAt_iff', mfld_simps] exact ⟨fun H => H.2, fun H => ⟨H.continuousWithinAt, H⟩⟩ #align mdifferentiable_within_at_iff_differentiable_within_at mdifferentiableWithinAt_iff_differentiableWithinAt alias ⟨MDifferentiableWithinAt.differentiableWithinAt, DifferentiableWithinAt.mdifferentiableWithinAt⟩ := mdifferentiableWithinAt_iff_differentiableWithinAt #align mdifferentiable_within_at.differentiable_within_at MDifferentiableWithinAt.differentiableWithinAt #align differentiable_within_at.mdifferentiable_within_at DifferentiableWithinAt.mdifferentiableWithinAt /-- For maps between vector spaces, `MDifferentiableAt` and `DifferentiableAt` coincide -/
Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean
84
87
theorem mdifferentiableAt_iff_differentiableAt : MDifferentiableAt 𝓘(𝕜, E) 𝓘(𝕜, E') f x ↔ DifferentiableAt 𝕜 f x := by
simp only [mdifferentiableAt_iff, differentiableWithinAt_univ, mfld_simps] exact ⟨fun H => H.2, fun H => ⟨H.continuousAt, H⟩⟩
/- Copyright (c) 2020 Nicolò Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nicolò Cavalleri, Sebastien Gouezel, Heather Macbeth, Patrick Massot, Floris van Doorn -/ import Mathlib.Analysis.NormedSpace.BoundedLinearMaps import Mathlib.Topology.FiberBundle.Basic #align_import topology.vector_bundle.basic from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Vector bundles In this file we define (topological) vector bundles. Let `B` be the base space, let `F` be a normed space over a normed field `R`, and let `E : B → Type*` be a `FiberBundle` with fiber `F`, in which, for each `x`, the fiber `E x` is a topological vector space over `R`. To have a vector bundle structure on `Bundle.TotalSpace F E`, one should additionally have the following properties: * The bundle trivializations in the trivialization atlas should be continuous linear equivs in the fibers; * For any two trivializations `e`, `e'` in the atlas the transition function considered as a map from `B` into `F →L[R] F` is continuous on `e.baseSet ∩ e'.baseSet` with respect to the operator norm topology on `F →L[R] F`. If these conditions are satisfied, we register the typeclass `VectorBundle R F E`. We define constructions on vector bundles like pullbacks and direct sums in other files. ## Main Definitions * `Trivialization.IsLinear`: a class stating that a trivialization is fiberwise linear on its base set. * `Trivialization.linearEquivAt` and `Trivialization.continuousLinearMapAt` are the (continuous) linear fiberwise equivalences a trivialization induces. * They have forward maps `Trivialization.linearMapAt` / `Trivialization.continuousLinearMapAt` and inverses `Trivialization.symmₗ` / `Trivialization.symmL`. Note that these are all defined everywhere, since they are extended using the zero function. * `Trivialization.coordChangeL` is the coordinate change induced by two trivializations. It only makes sense on the intersection of their base sets, but is extended outside it using the identity. * Given a continuous (semi)linear map between `E x` and `E' y` where `E` and `E'` are bundles over possibly different base sets, `ContinuousLinearMap.inCoordinates` turns this into a continuous (semi)linear map between the chosen fibers of those bundles. ## Implementation notes The implementation choices in the vector bundle definition are discussed in the "Implementation notes" section of `Mathlib.Topology.FiberBundle.Basic`. ## Tags Vector bundle -/ noncomputable section open scoped Classical open Bundle Set open scoped Topology variable (R : Type*) {B : Type*} (F : Type*) (E : B → Type*) section TopologicalVectorSpace variable {F E} variable [Semiring R] [TopologicalSpace F] [TopologicalSpace B] /-- A mixin class for `Pretrivialization`, stating that a pretrivialization is fiberwise linear with respect to given module structures on its fibers and the model fiber. -/ protected class Pretrivialization.IsLinear [AddCommMonoid F] [Module R F] [∀ x, AddCommMonoid (E x)] [∀ x, Module R (E x)] (e : Pretrivialization F (π F E)) : Prop where linear : ∀ b ∈ e.baseSet, IsLinearMap R fun x : E b => (e ⟨b, x⟩).2 #align pretrivialization.is_linear Pretrivialization.IsLinear namespace Pretrivialization variable (e : Pretrivialization F (π F E)) {x : TotalSpace F E} {b : B} {y : E b} theorem linear [AddCommMonoid F] [Module R F] [∀ x, AddCommMonoid (E x)] [∀ x, Module R (E x)] [e.IsLinear R] {b : B} (hb : b ∈ e.baseSet) : IsLinearMap R fun x : E b => (e ⟨b, x⟩).2 := Pretrivialization.IsLinear.linear b hb #align pretrivialization.linear Pretrivialization.linear variable [AddCommMonoid F] [Module R F] [∀ x, AddCommMonoid (E x)] [∀ x, Module R (E x)] /-- A fiberwise linear inverse to `e`. -/ @[simps!] protected def symmₗ (e : Pretrivialization F (π F E)) [e.IsLinear R] (b : B) : F →ₗ[R] E b := by refine IsLinearMap.mk' (e.symm b) ?_ by_cases hb : b ∈ e.baseSet · exact (((e.linear R hb).mk' _).inverse (e.symm b) (e.symm_apply_apply_mk hb) fun v ↦ congr_arg Prod.snd <| e.apply_mk_symm hb v).isLinear · rw [e.coe_symm_of_not_mem hb] exact (0 : F →ₗ[R] E b).isLinear #align pretrivialization.symmₗ Pretrivialization.symmₗ /-- A pretrivialization for a vector bundle defines linear equivalences between the fibers and the model space. -/ @[simps (config := .asFn)] def linearEquivAt (e : Pretrivialization F (π F E)) [e.IsLinear R] (b : B) (hb : b ∈ e.baseSet) : E b ≃ₗ[R] F where toFun y := (e ⟨b, y⟩).2 invFun := e.symm b left_inv := e.symm_apply_apply_mk hb right_inv v := by simp_rw [e.apply_mk_symm hb v] map_add' v w := (e.linear R hb).map_add v w map_smul' c v := (e.linear R hb).map_smul c v #align pretrivialization.linear_equiv_at Pretrivialization.linearEquivAt /-- A fiberwise linear map equal to `e` on `e.baseSet`. -/ protected def linearMapAt (e : Pretrivialization F (π F E)) [e.IsLinear R] (b : B) : E b →ₗ[R] F := if hb : b ∈ e.baseSet then e.linearEquivAt R b hb else 0 #align pretrivialization.linear_map_at Pretrivialization.linearMapAt variable {R} theorem coe_linearMapAt (e : Pretrivialization F (π F E)) [e.IsLinear R] (b : B) : ⇑(e.linearMapAt R b) = fun y => if b ∈ e.baseSet then (e ⟨b, y⟩).2 else 0 := by rw [Pretrivialization.linearMapAt] split_ifs <;> rfl #align pretrivialization.coe_linear_map_at Pretrivialization.coe_linearMapAt
Mathlib/Topology/VectorBundle/Basic.lean
126
128
theorem coe_linearMapAt_of_mem (e : Pretrivialization F (π F E)) [e.IsLinear R] {b : B} (hb : b ∈ e.baseSet) : ⇑(e.linearMapAt R b) = fun y => (e ⟨b, y⟩).2 := by
simp_rw [coe_linearMapAt, if_pos hb]
/- Copyright (c) 2024 Moritz Doll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Doll -/ import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.ContinuousFunction.CocompactMap /-! # Cocompact maps in normed groups This file gives a characterization of cocompact maps in terms of norm estimates. ## Main statements * `CocompactMapClass.norm_le`: Every cocompact map satisfies a norm estimate * `ContinuousMapClass.toCocompactMapClass_of_norm`: Conversely, this norm estimate implies that a map is cocompact. -/ open Filter Metric variable {𝕜 E F 𝓕 : Type*} variable [NormedAddCommGroup E] [NormedAddCommGroup F] [ProperSpace E] [ProperSpace F] variable {f : 𝓕} theorem CocompactMapClass.norm_le [FunLike 𝓕 E F] [CocompactMapClass 𝓕 E F] (ε : ℝ) : ∃ r : ℝ, ∀ x : E, r < ‖x‖ → ε < ‖f x‖ := by have h := cocompact_tendsto f rw [tendsto_def] at h specialize h (Metric.closedBall 0 ε)ᶜ (mem_cocompact_of_closedBall_compl_subset 0 ⟨ε, rfl.subset⟩) rcases closedBall_compl_subset_of_mem_cocompact h 0 with ⟨r, hr⟩ use r intro x hx suffices x ∈ f⁻¹' (Metric.closedBall 0 ε)ᶜ by aesop apply hr simp [hx]
Mathlib/Analysis/Normed/Group/CocompactMap.lean
41
53
theorem Filter.tendsto_cocompact_cocompact_of_norm {f : E → F} (h : ∀ ε : ℝ, ∃ r : ℝ, ∀ x : E, r < ‖x‖ → ε < ‖f x‖) : Tendsto f (cocompact E) (cocompact F) := by
rw [tendsto_def] intro s hs rcases closedBall_compl_subset_of_mem_cocompact hs 0 with ⟨ε, hε⟩ rcases h ε with ⟨r, hr⟩ apply mem_cocompact_of_closedBall_compl_subset 0 use r intro x hx simp only [Set.mem_compl_iff, Metric.mem_closedBall, dist_zero_right, not_le] at hx apply hε simp [hr x hx]
/- Copyright (c) 2017 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura -/ import Mathlib.Init.Logic import Mathlib.Tactic.AdaptationNote import Mathlib.Tactic.Coe /-! # Lemmas about booleans These are the lemmas about booleans which were present in core Lean 3. See also the file Mathlib.Data.Bool.Basic which contains lemmas about booleans from mathlib 3. -/ set_option autoImplicit true -- We align Lean 3 lemmas with lemmas in `Init.SimpLemmas` in Lean 4. #align band_self Bool.and_self #align band_tt Bool.and_true #align band_ff Bool.and_false #align tt_band Bool.true_and #align ff_band Bool.false_and #align bor_self Bool.or_self #align bor_tt Bool.or_true #align bor_ff Bool.or_false #align tt_bor Bool.true_or #align ff_bor Bool.false_or #align bnot_bnot Bool.not_not namespace Bool #align bool.cond_tt Bool.cond_true #align bool.cond_ff Bool.cond_false #align cond_a_a Bool.cond_self attribute [simp] xor_self #align bxor_self Bool.xor_self #align bxor_tt Bool.xor_true #align bxor_ff Bool.xor_false #align tt_bxor Bool.true_xor #align ff_bxor Bool.false_xor theorem true_eq_false_eq_False : ¬true = false := by decide #align tt_eq_ff_eq_false Bool.true_eq_false_eq_False theorem false_eq_true_eq_False : ¬false = true := by decide #align ff_eq_tt_eq_false Bool.false_eq_true_eq_False theorem eq_false_eq_not_eq_true (b : Bool) : (¬b = true) = (b = false) := by simp #align eq_ff_eq_not_eq_tt Bool.eq_false_eq_not_eq_true theorem eq_true_eq_not_eq_false (b : Bool) : (¬b = false) = (b = true) := by simp #align eq_tt_eq_not_eq_ft Bool.eq_true_eq_not_eq_false theorem eq_false_of_not_eq_true {b : Bool} : ¬b = true → b = false := Eq.mp (eq_false_eq_not_eq_true b) #align eq_ff_of_not_eq_tt Bool.eq_false_of_not_eq_true theorem eq_true_of_not_eq_false {b : Bool} : ¬b = false → b = true := Eq.mp (eq_true_eq_not_eq_false b) #align eq_tt_of_not_eq_ff Bool.eq_true_of_not_eq_false theorem and_eq_true_eq_eq_true_and_eq_true (a b : Bool) : ((a && b) = true) = (a = true ∧ b = true) := by simp #align band_eq_true_eq_eq_tt_and_eq_tt Bool.and_eq_true_eq_eq_true_and_eq_true theorem or_eq_true_eq_eq_true_or_eq_true (a b : Bool) : ((a || b) = true) = (a = true ∨ b = true) := by simp #align bor_eq_true_eq_eq_tt_or_eq_tt Bool.or_eq_true_eq_eq_true_or_eq_true theorem not_eq_true_eq_eq_false (a : Bool) : (not a = true) = (a = false) := by cases a <;> simp #align bnot_eq_true_eq_eq_ff Bool.not_eq_true_eq_eq_false #adaptation_note /-- this is no longer a simp lemma, as after nightly-2024-03-05 the LHS simplifies. -/ theorem and_eq_false_eq_eq_false_or_eq_false (a b : Bool) : ((a && b) = false) = (a = false ∨ b = false) := by cases a <;> cases b <;> simp #align band_eq_false_eq_eq_ff_or_eq_ff Bool.and_eq_false_eq_eq_false_or_eq_false theorem or_eq_false_eq_eq_false_and_eq_false (a b : Bool) : ((a || b) = false) = (a = false ∧ b = false) := by cases a <;> cases b <;> simp #align bor_eq_false_eq_eq_ff_and_eq_ff Bool.or_eq_false_eq_eq_false_and_eq_false theorem not_eq_false_eq_eq_true (a : Bool) : (not a = false) = (a = true) := by cases a <;> simp #align bnot_eq_ff_eq_eq_tt Bool.not_eq_false_eq_eq_true theorem coe_false : ↑false = False := by simp #align coe_ff Bool.coe_false theorem coe_true : ↑true = True := by simp #align coe_tt Bool.coe_true theorem coe_sort_false : (false : Prop) = False := by simp #align coe_sort_ff Bool.coe_sort_false theorem coe_sort_true : (true : Prop) = True := by simp #align coe_sort_tt Bool.coe_sort_true
Mathlib/Init/Data/Bool/Lemmas.lean
106
106
theorem decide_iff (p : Prop) [d : Decidable p] : decide p = true ↔ p := by
simp
/- Copyright (c) 2020 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash, Antoine Labelle -/ import Mathlib.LinearAlgebra.Dual import Mathlib.LinearAlgebra.Matrix.ToLin #align_import linear_algebra.contraction from "leanprover-community/mathlib"@"657df4339ae6ceada048c8a2980fb10e393143ec" /-! # Contractions Given modules $M, N$ over a commutative ring $R$, this file defines the natural linear maps: $M^* \otimes M \to R$, $M \otimes M^* \to R$, and $M^* \otimes N → Hom(M, N)$, as well as proving some basic properties of these maps. ## Tags contraction, dual module, tensor product -/ suppress_compilation -- Porting note: universe metavariables behave oddly universe w u v₁ v₂ v₃ v₄ variable {ι : Type w} (R : Type u) (M : Type v₁) (N : Type v₂) (P : Type v₃) (Q : Type v₄) -- Porting note: we need high priority for this to fire first; not the case in ML3 attribute [local ext high] TensorProduct.ext section Contraction open TensorProduct LinearMap Matrix Module open TensorProduct section CommSemiring variable [CommSemiring R] variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q] variable [Module R M] [Module R N] [Module R P] [Module R Q] variable [DecidableEq ι] [Fintype ι] (b : Basis ι R M) -- Porting note: doesn't like implicit ring in the tensor product /-- The natural left-handed pairing between a module and its dual. -/ def contractLeft : Module.Dual R M ⊗[R] M →ₗ[R] R := (uncurry _ _ _ _).toFun LinearMap.id #align contract_left contractLeft -- Porting note: doesn't like implicit ring in the tensor product /-- The natural right-handed pairing between a module and its dual. -/ def contractRight : M ⊗[R] Module.Dual R M →ₗ[R] R := (uncurry _ _ _ _).toFun (LinearMap.flip LinearMap.id) #align contract_right contractRight -- Porting note: doesn't like implicit ring in the tensor product /-- The natural map associating a linear map to the tensor product of two modules. -/ def dualTensorHom : Module.Dual R M ⊗[R] N →ₗ[R] M →ₗ[R] N := let M' := Module.Dual R M (uncurry R M' N (M →ₗ[R] N) : _ → M' ⊗ N →ₗ[R] M →ₗ[R] N) LinearMap.smulRightₗ #align dual_tensor_hom dualTensorHom variable {R M N P Q} @[simp] theorem contractLeft_apply (f : Module.Dual R M) (m : M) : contractLeft R M (f ⊗ₜ m) = f m := rfl #align contract_left_apply contractLeft_apply @[simp] theorem contractRight_apply (f : Module.Dual R M) (m : M) : contractRight R M (m ⊗ₜ f) = f m := rfl #align contract_right_apply contractRight_apply @[simp] theorem dualTensorHom_apply (f : Module.Dual R M) (m : M) (n : N) : dualTensorHom R M N (f ⊗ₜ n) m = f m • n := rfl #align dual_tensor_hom_apply dualTensorHom_apply @[simp] theorem transpose_dualTensorHom (f : Module.Dual R M) (m : M) : Dual.transpose (R := R) (dualTensorHom R M M (f ⊗ₜ m)) = dualTensorHom R _ _ (Dual.eval R M m ⊗ₜ f) := by ext f' m' simp only [Dual.transpose_apply, coe_comp, Function.comp_apply, dualTensorHom_apply, LinearMap.map_smulₛₗ, RingHom.id_apply, Algebra.id.smul_eq_mul, Dual.eval_apply, LinearMap.smul_apply] exact mul_comm _ _ #align transpose_dual_tensor_hom transpose_dualTensorHom @[simp] theorem dualTensorHom_prodMap_zero (f : Module.Dual R M) (p : P) : ((dualTensorHom R M P) (f ⊗ₜ[R] p)).prodMap (0 : N →ₗ[R] Q) = dualTensorHom R (M × N) (P × Q) ((f ∘ₗ fst R M N) ⊗ₜ inl R P Q p) := by ext <;> simp only [coe_comp, coe_inl, Function.comp_apply, prodMap_apply, dualTensorHom_apply, fst_apply, Prod.smul_mk, LinearMap.zero_apply, smul_zero] #align dual_tensor_hom_prod_map_zero dualTensorHom_prodMap_zero @[simp] theorem zero_prodMap_dualTensorHom (g : Module.Dual R N) (q : Q) : (0 : M →ₗ[R] P).prodMap ((dualTensorHom R N Q) (g ⊗ₜ[R] q)) = dualTensorHom R (M × N) (P × Q) ((g ∘ₗ snd R M N) ⊗ₜ inr R P Q q) := by ext <;> simp only [coe_comp, coe_inr, Function.comp_apply, prodMap_apply, dualTensorHom_apply, snd_apply, Prod.smul_mk, LinearMap.zero_apply, smul_zero] #align zero_prod_map_dual_tensor_hom zero_prodMap_dualTensorHom theorem map_dualTensorHom (f : Module.Dual R M) (p : P) (g : Module.Dual R N) (q : Q) : TensorProduct.map (dualTensorHom R M P (f ⊗ₜ[R] p)) (dualTensorHom R N Q (g ⊗ₜ[R] q)) = dualTensorHom R (M ⊗[R] N) (P ⊗[R] Q) (dualDistrib R M N (f ⊗ₜ g) ⊗ₜ[R] p ⊗ₜ[R] q) := by ext m n simp only [compr₂_apply, mk_apply, map_tmul, dualTensorHom_apply, dualDistrib_apply, ← smul_tmul_smul] #align map_dual_tensor_hom map_dualTensorHom @[simp]
Mathlib/LinearAlgebra/Contraction.lean
122
128
theorem comp_dualTensorHom (f : Module.Dual R M) (n : N) (g : Module.Dual R N) (p : P) : dualTensorHom R N P (g ⊗ₜ[R] p) ∘ₗ dualTensorHom R M N (f ⊗ₜ[R] n) = g n • dualTensorHom R M P (f ⊗ₜ p) := by
ext m simp only [coe_comp, Function.comp_apply, dualTensorHom_apply, LinearMap.map_smul, RingHom.id_apply, LinearMap.smul_apply] rw [smul_comm]
/- 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.SplitSimplicialObject import Mathlib.AlgebraicTopology.DoldKan.Degeneracies import Mathlib.AlgebraicTopology.DoldKan.FunctorN #align_import algebraic_topology.dold_kan.split_simplicial_object from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" /-! # Split simplicial objects in preadditive categories In this file we define a functor `nondegComplex : SimplicialObject.Split C ⥤ ChainComplex C ℕ` when `C` is a preadditive category with finite coproducts, and get an isomorphism `toKaroubiNondegComplexFunctorIsoN₁ : nondegComplex ⋙ toKaroubi _ ≅ forget C ⋙ DoldKan.N₁`. (See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.) -/ open CategoryTheory CategoryTheory.Limits CategoryTheory.Category CategoryTheory.Preadditive CategoryTheory.Idempotents Opposite AlgebraicTopology AlgebraicTopology.DoldKan Simplicial DoldKan namespace SimplicialObject namespace Splitting variable {C : Type*} [Category C] {X : SimplicialObject C} (s : Splitting X) /-- The projection on a summand of the coproduct decomposition given by a splitting of a simplicial object. -/ noncomputable def πSummand [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) : X.obj Δ ⟶ s.N A.1.unop.len := s.desc Δ (fun B => by by_cases h : B = A · exact eqToHom (by subst h; rfl) · exact 0) #align simplicial_object.splitting.π_summand SimplicialObject.Splitting.πSummand @[reassoc (attr := simp)] theorem cofan_inj_πSummand_eq_id [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) : (s.cofan Δ).inj A ≫ s.πSummand A = 𝟙 _ := by simp [πSummand] #align simplicial_object.splitting.ι_π_summand_eq_id SimplicialObject.Splitting.cofan_inj_πSummand_eq_id @[reassoc (attr := simp)] theorem cofan_inj_πSummand_eq_zero [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A B : IndexSet Δ) (h : B ≠ A) : (s.cofan Δ).inj A ≫ s.πSummand B = 0 := by dsimp [πSummand] rw [ι_desc, dif_neg h.symm] #align simplicial_object.splitting.ι_π_summand_eq_zero SimplicialObject.Splitting.cofan_inj_πSummand_eq_zero variable [Preadditive C] theorem decomposition_id (Δ : SimplexCategoryᵒᵖ) : 𝟙 (X.obj Δ) = ∑ A : IndexSet Δ, s.πSummand A ≫ (s.cofan Δ).inj A := by apply s.hom_ext' intro A dsimp erw [comp_id, comp_sum, Finset.sum_eq_single A, cofan_inj_πSummand_eq_id_assoc] · intro B _ h₂ rw [s.cofan_inj_πSummand_eq_zero_assoc _ _ h₂, zero_comp] · simp #align simplicial_object.splitting.decomposition_id SimplicialObject.Splitting.decomposition_id @[reassoc (attr := simp)] theorem σ_comp_πSummand_id_eq_zero {n : ℕ} (i : Fin (n + 1)) : X.σ i ≫ s.πSummand (IndexSet.id (op [n + 1])) = 0 := by apply s.hom_ext' intro A dsimp only [SimplicialObject.σ] rw [comp_zero, s.cofan_inj_epi_naturality_assoc A (SimplexCategory.σ i).op, cofan_inj_πSummand_eq_zero] rw [ne_comm] change ¬(A.epiComp (SimplexCategory.σ i).op).EqId rw [IndexSet.eqId_iff_len_eq] have h := SimplexCategory.len_le_of_epi (inferInstance : Epi A.e) dsimp at h ⊢ omega #align simplicial_object.splitting.σ_comp_π_summand_id_eq_zero SimplicialObject.Splitting.σ_comp_πSummand_id_eq_zero /-- If a simplicial object `X` in an additive category is split, then `PInfty` vanishes on all the summands of `X _[n]` which do not correspond to the identity of `[n]`. -/
Mathlib/AlgebraicTopology/DoldKan/SplitSimplicialObject.lean
91
95
theorem cofan_inj_comp_PInfty_eq_zero {X : SimplicialObject C} (s : SimplicialObject.Splitting X) {n : ℕ} (A : SimplicialObject.Splitting.IndexSet (op [n])) (hA : ¬A.EqId) : (s.cofan _).inj A ≫ PInfty.f n = 0 := by
rw [SimplicialObject.Splitting.IndexSet.eqId_iff_mono] at hA rw [SimplicialObject.Splitting.cofan_inj_eq, assoc, degeneracy_comp_PInfty X n A.e hA, comp_zero]
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.GCDMonoid.Multiset import Mathlib.Combinatorics.Enumerative.Partition import Mathlib.Data.List.Rotate import Mathlib.GroupTheory.Perm.Cycle.Factors import Mathlib.GroupTheory.Perm.Closure import Mathlib.Algebra.GCDMonoid.Nat import Mathlib.Tactic.NormNum.GCD #align_import group_theory.perm.cycle.type from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722" /-! # Cycle Types In this file we define the cycle type of a permutation. ## Main definitions - `Equiv.Perm.cycleType σ` where `σ` is a permutation of a `Fintype` - `Equiv.Perm.partition σ` where `σ` is a permutation of a `Fintype` ## Main results - `sum_cycleType` : The sum of `σ.cycleType` equals `σ.support.card` - `lcm_cycleType` : The lcm of `σ.cycleType` equals `orderOf σ` - `isConj_iff_cycleType_eq` : Two permutations are conjugate if and only if they have the same cycle type. - `exists_prime_orderOf_dvd_card`: For every prime `p` dividing the order of a finite group `G` there exists an element of order `p` in `G`. This is known as Cauchy's theorem. -/ namespace Equiv.Perm open Equiv List Multiset variable {α : Type*} [Fintype α] section CycleType variable [DecidableEq α] /-- The cycle type of a permutation -/ def cycleType (σ : Perm α) : Multiset ℕ := σ.cycleFactorsFinset.1.map (Finset.card ∘ support) #align equiv.perm.cycle_type Equiv.Perm.cycleType theorem cycleType_def (σ : Perm α) : σ.cycleType = σ.cycleFactorsFinset.1.map (Finset.card ∘ support) := rfl #align equiv.perm.cycle_type_def Equiv.Perm.cycleType_def theorem cycleType_eq' {σ : Perm α} (s : Finset (Perm α)) (h1 : ∀ f : Perm α, f ∈ s → f.IsCycle) (h2 : (s : Set (Perm α)).Pairwise Disjoint) (h0 : s.noncommProd id (h2.imp fun _ _ => Disjoint.commute) = σ) : σ.cycleType = s.1.map (Finset.card ∘ support) := by rw [cycleType_def] congr rw [cycleFactorsFinset_eq_finset] exact ⟨h1, h2, h0⟩ #align equiv.perm.cycle_type_eq' Equiv.Perm.cycleType_eq'
Mathlib/GroupTheory/Perm/Cycle/Type.lean
67
75
theorem cycleType_eq {σ : Perm α} (l : List (Perm α)) (h0 : l.prod = σ) (h1 : ∀ σ : Perm α, σ ∈ l → σ.IsCycle) (h2 : l.Pairwise Disjoint) : σ.cycleType = l.map (Finset.card ∘ support) := by
have hl : l.Nodup := nodup_of_pairwise_disjoint_cycles h1 h2 rw [cycleType_eq' l.toFinset] · simp [List.dedup_eq_self.mpr hl, (· ∘ ·)] · simpa using h1 · simpa [hl] using h2 · simp [hl, h0]
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.InnerProductSpace.Calculus import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import analysis.inner_product_space.euclidean_dist from "leanprover-community/mathlib"@"9425b6f8220e53b059f5a4904786c3c4b50fc057" /-! # Euclidean distance on a finite dimensional space When we define a smooth bump function on a normed space, it is useful to have a smooth distance on the space. Since the default distance is not guaranteed to be smooth, we define `toEuclidean` to be an equivalence between a finite dimensional topological vector space and the standard Euclidean space of the same dimension. Then we define `Euclidean.dist x y = dist (toEuclidean x) (toEuclidean y)` and provide some definitions (`Euclidean.ball`, `Euclidean.closedBall`) and simple lemmas about this distance. This way we hide the usage of `toEuclidean` behind an API. -/ open scoped Topology open Set variable {E : Type*} [AddCommGroup E] [TopologicalSpace E] [TopologicalAddGroup E] [T2Space E] [Module ℝ E] [ContinuousSMul ℝ E] [FiniteDimensional ℝ E] noncomputable section open FiniteDimensional /-- If `E` is a finite dimensional space over `ℝ`, then `toEuclidean` is a continuous `ℝ`-linear equivalence between `E` and the Euclidean space of the same dimension. -/ def toEuclidean : E ≃L[ℝ] EuclideanSpace ℝ (Fin <| finrank ℝ E) := ContinuousLinearEquiv.ofFinrankEq finrank_euclideanSpace_fin.symm #align to_euclidean toEuclidean namespace Euclidean /-- If `x` and `y` are two points in a finite dimensional space over `ℝ`, then `Euclidean.dist x y` is the distance between these points in the metric defined by some inner product space structure on `E`. -/ nonrec def dist (x y : E) : ℝ := dist (toEuclidean x) (toEuclidean y) #align euclidean.dist Euclidean.dist /-- Closed ball w.r.t. the euclidean distance. -/ def closedBall (x : E) (r : ℝ) : Set E := {y | dist y x ≤ r} #align euclidean.closed_ball Euclidean.closedBall /-- Open ball w.r.t. the euclidean distance. -/ def ball (x : E) (r : ℝ) : Set E := {y | dist y x < r} #align euclidean.ball Euclidean.ball theorem ball_eq_preimage (x : E) (r : ℝ) : ball x r = toEuclidean ⁻¹' Metric.ball (toEuclidean x) r := rfl #align euclidean.ball_eq_preimage Euclidean.ball_eq_preimage theorem closedBall_eq_preimage (x : E) (r : ℝ) : closedBall x r = toEuclidean ⁻¹' Metric.closedBall (toEuclidean x) r := rfl #align euclidean.closed_ball_eq_preimage Euclidean.closedBall_eq_preimage theorem ball_subset_closedBall {x : E} {r : ℝ} : ball x r ⊆ closedBall x r := fun _ (hy : _ < r) => le_of_lt hy #align euclidean.ball_subset_closed_ball Euclidean.ball_subset_closedBall theorem isOpen_ball {x : E} {r : ℝ} : IsOpen (ball x r) := Metric.isOpen_ball.preimage toEuclidean.continuous #align euclidean.is_open_ball Euclidean.isOpen_ball theorem mem_ball_self {x : E} {r : ℝ} (hr : 0 < r) : x ∈ ball x r := Metric.mem_ball_self hr #align euclidean.mem_ball_self Euclidean.mem_ball_self theorem closedBall_eq_image (x : E) (r : ℝ) : closedBall x r = toEuclidean.symm '' Metric.closedBall (toEuclidean x) r := by rw [toEuclidean.image_symm_eq_preimage, closedBall_eq_preimage] #align euclidean.closed_ball_eq_image Euclidean.closedBall_eq_image nonrec theorem isCompact_closedBall {x : E} {r : ℝ} : IsCompact (closedBall x r) := by rw [closedBall_eq_image] exact (isCompact_closedBall _ _).image toEuclidean.symm.continuous #align euclidean.is_compact_closed_ball Euclidean.isCompact_closedBall theorem isClosed_closedBall {x : E} {r : ℝ} : IsClosed (closedBall x r) := isCompact_closedBall.isClosed #align euclidean.is_closed_closed_ball Euclidean.isClosed_closedBall nonrec theorem closure_ball (x : E) {r : ℝ} (h : r ≠ 0) : closure (ball x r) = closedBall x r := by rw [ball_eq_preimage, ← toEuclidean.preimage_closure, closure_ball (toEuclidean x) h, closedBall_eq_preimage] #align euclidean.closure_ball Euclidean.closure_ball nonrec theorem exists_pos_lt_subset_ball {R : ℝ} {s : Set E} {x : E} (hR : 0 < R) (hs : IsClosed s) (h : s ⊆ ball x R) : ∃ r ∈ Ioo 0 R, s ⊆ ball x r := by rw [ball_eq_preimage, ← image_subset_iff] at h rcases exists_pos_lt_subset_ball hR (toEuclidean.isClosed_image.2 hs) h with ⟨r, hr, hsr⟩ exact ⟨r, hr, image_subset_iff.1 hsr⟩ #align euclidean.exists_pos_lt_subset_ball Euclidean.exists_pos_lt_subset_ball
Mathlib/Analysis/InnerProductSpace/EuclideanDist.lean
108
110
theorem nhds_basis_closedBall {x : E} : (𝓝 x).HasBasis (fun r : ℝ => 0 < r) (closedBall x) := by
rw [toEuclidean.toHomeomorph.nhds_eq_comap x] exact Metric.nhds_basis_closedBall.comap _
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.RingTheory.Algebraic import Mathlib.RingTheory.Localization.AtPrime import Mathlib.RingTheory.Localization.Integral #align_import ring_theory.ideal.over from "leanprover-community/mathlib"@"198cb64d5c961e1a8d0d3e219feb7058d5353861" /-! # Ideals over/under ideals This file concerns ideals lying over other ideals. Let `f : R →+* S` be a ring homomorphism (typically a ring extension), `I` an ideal of `R` and `J` an ideal of `S`. We say `J` lies over `I` (and `I` under `J`) if `I` is the `f`-preimage of `J`. This is expressed here by writing `I = J.comap f`. ## Implementation notes The proofs of the `comap_ne_bot` and `comap_lt_comap` families use an approach specific for their situation: we construct an element in `I.comap f` from the coefficients of a minimal polynomial. Once mathlib has more material on the localization at a prime ideal, the results can be proven using more general going-up/going-down theory. -/ variable {R : Type*} [CommRing R] namespace Ideal open Polynomial open Polynomial open Submodule section CommRing variable {S : Type*} [CommRing S] {f : R →+* S} {I J : Ideal S} theorem coeff_zero_mem_comap_of_root_mem_of_eval_mem {r : S} (hr : r ∈ I) {p : R[X]} (hp : p.eval₂ f r ∈ I) : p.coeff 0 ∈ I.comap f := by rw [← p.divX_mul_X_add, eval₂_add, eval₂_C, eval₂_mul, eval₂_X] at hp refine mem_comap.mpr ((I.add_mem_iff_right ?_).mp hp) exact I.mul_mem_left _ hr #align ideal.coeff_zero_mem_comap_of_root_mem_of_eval_mem Ideal.coeff_zero_mem_comap_of_root_mem_of_eval_mem theorem coeff_zero_mem_comap_of_root_mem {r : S} (hr : r ∈ I) {p : R[X]} (hp : p.eval₂ f r = 0) : p.coeff 0 ∈ I.comap f := coeff_zero_mem_comap_of_root_mem_of_eval_mem hr (hp.symm ▸ I.zero_mem) #align ideal.coeff_zero_mem_comap_of_root_mem Ideal.coeff_zero_mem_comap_of_root_mem theorem exists_coeff_ne_zero_mem_comap_of_non_zero_divisor_root_mem {r : S} (r_non_zero_divisor : ∀ {x}, x * r = 0 → x = 0) (hr : r ∈ I) {p : R[X]} : p ≠ 0 → p.eval₂ f r = 0 → ∃ i, p.coeff i ≠ 0 ∧ p.coeff i ∈ I.comap f := by refine p.recOnHorner ?_ ?_ ?_ · intro h contradiction · intro p a coeff_eq_zero a_ne_zero _ _ hp refine ⟨0, ?_, coeff_zero_mem_comap_of_root_mem hr hp⟩ simp [coeff_eq_zero, a_ne_zero] · intro p p_nonzero ih _ hp rw [eval₂_mul, eval₂_X] at hp obtain ⟨i, hi, mem⟩ := ih p_nonzero (r_non_zero_divisor hp) refine ⟨i + 1, ?_, ?_⟩ · simp [hi, mem] · simpa [hi] using mem #align ideal.exists_coeff_ne_zero_mem_comap_of_non_zero_divisor_root_mem Ideal.exists_coeff_ne_zero_mem_comap_of_non_zero_divisor_root_mem /-- Let `P` be an ideal in `R[x]`. The map `R[x]/P → (R / (P ∩ R))[x] / (P / (P ∩ R))` is injective. -/ theorem injective_quotient_le_comap_map (P : Ideal R[X]) : Function.Injective <| Ideal.quotientMap (Ideal.map (Polynomial.mapRingHom (Quotient.mk (P.comap (C : R →+* R[X])))) P) (Polynomial.mapRingHom (Ideal.Quotient.mk (P.comap (C : R →+* R[X])))) le_comap_map := by refine quotientMap_injective' (le_of_eq ?_) rw [comap_map_of_surjective (mapRingHom (Ideal.Quotient.mk (P.comap (C : R →+* R[X])))) (map_surjective (Ideal.Quotient.mk (P.comap (C : R →+* R[X]))) Ideal.Quotient.mk_surjective)] refine le_antisymm (sup_le le_rfl ?_) (le_sup_of_le_left le_rfl) refine fun p hp => polynomial_mem_ideal_of_coeff_mem_ideal P p fun n => Ideal.Quotient.eq_zero_iff_mem.mp ?_ simpa only [coeff_map, coe_mapRingHom] using ext_iff.mp (Ideal.mem_bot.mp (mem_comap.mp hp)) n #align ideal.injective_quotient_le_comap_map Ideal.injective_quotient_le_comap_map /-- The identity in this lemma asserts that the "obvious" square ``` R → (R / (P ∩ R)) ↓ ↓ R[x] / P → (R / (P ∩ R))[x] / (P / (P ∩ R)) ``` commutes. It is used, for instance, in the proof of `quotient_mk_comp_C_is_integral_of_jacobson`, in the file `RingTheory.Jacobson`. -/
Mathlib/RingTheory/Ideal/Over.lean
101
109
theorem quotient_mk_maps_eq (P : Ideal R[X]) : ((Quotient.mk (map (mapRingHom (Quotient.mk (P.comap (C : R →+* R[X])))) P)).comp C).comp (Quotient.mk (P.comap (C : R →+* R[X]))) = (Ideal.quotientMap (map (mapRingHom (Quotient.mk (P.comap (C : R →+* R[X])))) P) (mapRingHom (Quotient.mk (P.comap (C : R →+* R[X])))) le_comap_map).comp ((Quotient.mk P).comp C) := by
refine RingHom.ext fun x => ?_ repeat' rw [RingHom.coe_comp, Function.comp_apply] rw [quotientMap_mk, coe_mapRingHom, map_C]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.List.Nodup #align_import data.list.dedup from "leanprover-community/mathlib"@"d9e96a3e3e0894e93e10aff5244f4c96655bac1c" /-! # Erasure of duplicates in a list This file proves basic results about `List.dedup` (definition in `Data.List.Defs`). `dedup l` returns `l` without its duplicates. It keeps the earliest (that is, rightmost) occurrence of each. ## Tags duplicate, multiplicity, nodup, `nub` -/ universe u namespace List variable {α : Type u} [DecidableEq α] @[simp] theorem dedup_nil : dedup [] = ([] : List α) := rfl #align list.dedup_nil List.dedup_nil theorem dedup_cons_of_mem' {a : α} {l : List α} (h : a ∈ dedup l) : dedup (a :: l) = dedup l := pwFilter_cons_of_neg <| by simpa only [forall_mem_ne, not_not] using h #align list.dedup_cons_of_mem' List.dedup_cons_of_mem' theorem dedup_cons_of_not_mem' {a : α} {l : List α} (h : a ∉ dedup l) : dedup (a :: l) = a :: dedup l := pwFilter_cons_of_pos <| by simpa only [forall_mem_ne] using h #align list.dedup_cons_of_not_mem' List.dedup_cons_of_not_mem' @[simp]
Mathlib/Data/List/Dedup.lean
44
48
theorem mem_dedup {a : α} {l : List α} : a ∈ dedup l ↔ a ∈ l := by
have := not_congr (@forall_mem_pwFilter α (· ≠ ·) _ ?_ a l) · simpa only [dedup, forall_mem_ne, not_not] using this · intros x y z xz exact not_and_or.1 <| mt (fun h ↦ h.1.trans h.2) xz
/- 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.CategoryTheory.Monoidal.Mon_ #align_import category_theory.monoidal.Mod_ from "leanprover-community/mathlib"@"33085c9739c41428651ac461a323fde9a2688d9b" /-! # The category of module objects over a monoid object. -/ universe v₁ v₂ u₁ u₂ open CategoryTheory MonoidalCategory variable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C] variable {C} /-- A module object for a monoid object, all internal to some monoidal category. -/ structure Mod_ (A : Mon_ C) where X : C act : A.X ⊗ X ⟶ X one_act : (A.one ▷ X) ≫ act = (λ_ X).hom := by aesop_cat assoc : (A.mul ▷ X) ≫ act = (α_ A.X A.X X).hom ≫ (A.X ◁ act) ≫ act := by aesop_cat set_option linter.uppercaseLean3 false in #align Mod_ Mod_ attribute [reassoc (attr := simp)] Mod_.one_act Mod_.assoc namespace Mod_ variable {A : Mon_ C} (M : Mod_ A) theorem assoc_flip : (A.X ◁ M.act) ≫ M.act = (α_ A.X A.X M.X).inv ≫ (A.mul ▷ M.X) ≫ M.act := by simp set_option linter.uppercaseLean3 false in #align Mod_.assoc_flip Mod_.assoc_flip /-- A morphism of module objects. -/ @[ext] structure Hom (M N : Mod_ A) where hom : M.X ⟶ N.X act_hom : M.act ≫ hom = (A.X ◁ hom) ≫ N.act := by aesop_cat set_option linter.uppercaseLean3 false in #align Mod_.hom Mod_.Hom attribute [reassoc (attr := simp)] Hom.act_hom /-- The identity morphism on a module object. -/ @[simps] def id (M : Mod_ A) : Hom M M where hom := 𝟙 M.X set_option linter.uppercaseLean3 false in #align Mod_.id Mod_.id instance homInhabited (M : Mod_ A) : Inhabited (Hom M M) := ⟨id M⟩ set_option linter.uppercaseLean3 false in #align Mod_.hom_inhabited Mod_.homInhabited /-- Composition of module object morphisms. -/ @[simps] def comp {M N O : Mod_ A} (f : Hom M N) (g : Hom N O) : Hom M O where hom := f.hom ≫ g.hom set_option linter.uppercaseLean3 false in #align Mod_.comp Mod_.comp instance : Category (Mod_ A) where Hom M N := Hom M N id := id comp f g := comp f g -- Porting note: added because `Hom.ext` is not triggered automatically -- See https://github.com/leanprover-community/mathlib4/issues/5229 @[ext] lemma hom_ext {M N : Mod_ A} (f₁ f₂ : M ⟶ N) (h : f₁.hom = f₂.hom) : f₁ = f₂ := Hom.ext _ _ h @[simp]
Mathlib/CategoryTheory/Monoidal/Mod_.lean
81
82
theorem id_hom' (M : Mod_ A) : (𝟙 M : M ⟶ M).hom = 𝟙 M.X := by
rfl
/- Copyright (c) 2022 María Inés de Frutos-Fernández. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Chambert-Loir, María Inés de Frutos-Fernández -/ import Mathlib.Algebra.GradedMonoid import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Algebra.MvPolynomial.Basic #align_import ring_theory.mv_polynomial.weighted_homogeneous from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Weighted homogeneous polynomials It is possible to assign weights (in a commutative additive monoid `M`) to the variables of a multivariate polynomial ring, so that monomials of the ring then have a weighted degree with respect to the weights of the variables. The weights are represented by a function `w : σ → M`, where `σ` are the indeterminates. A multivariate polynomial `φ` is weighted homogeneous of weighted degree `m : M` if all monomials occurring in `φ` have the same weighted degree `m`. ## Main definitions/lemmas * `weightedTotalDegree' w φ` : the weighted total degree of a multivariate polynomial with respect to the weights `w`, taking values in `WithBot M`. * `weightedTotalDegree w φ` : When `M` has a `⊥` element, we can define the weighted total degree of a multivariate polynomial as a function taking values in `M`. * `IsWeightedHomogeneous w φ m`: a predicate that asserts that `φ` is weighted homogeneous of weighted degree `m` with respect to the weights `w`. * `weightedHomogeneousSubmodule R w m`: the submodule of homogeneous polynomials of weighted degree `m`. * `weightedHomogeneousComponent w m`: the additive morphism that projects polynomials onto their summand that is weighted homogeneous of degree `n` with respect to `w`. * `sum_weightedHomogeneousComponent`: every polynomial is the sum of its weighted homogeneous components. -/ noncomputable section open Set Function Finset Finsupp AddMonoidAlgebra variable {R M : Type*} [CommSemiring R] namespace MvPolynomial variable {σ : Type*} section AddCommMonoid variable [AddCommMonoid M] /-! ### `weightedDegree` -/ /-- The `weightedDegree` of the finitely supported function `s : σ →₀ ℕ` is the sum `∑(s i)•(w i)`. -/ def weightedDegree (w : σ → M) : (σ →₀ ℕ) →+ M := (Finsupp.total σ M ℕ w).toAddMonoidHom #align mv_polynomial.weighted_degree' MvPolynomial.weightedDegree theorem weightedDegree_apply (w : σ → M) (f : σ →₀ ℕ): weightedDegree w f = Finsupp.sum f (fun i c => c • w i) := by rfl section SemilatticeSup variable [SemilatticeSup M] /-- The weighted total degree of a multivariate polynomial, taking values in `WithBot M`. -/ def weightedTotalDegree' (w : σ → M) (p : MvPolynomial σ R) : WithBot M := p.support.sup fun s => weightedDegree w s #align mv_polynomial.weighted_total_degree' MvPolynomial.weightedTotalDegree' /-- The `weightedTotalDegree'` of a polynomial `p` is `⊥` if and only if `p = 0`. -/ theorem weightedTotalDegree'_eq_bot_iff (w : σ → M) (p : MvPolynomial σ R) : weightedTotalDegree' w p = ⊥ ↔ p = 0 := by simp only [weightedTotalDegree', Finset.sup_eq_bot_iff, mem_support_iff, WithBot.coe_ne_bot, MvPolynomial.eq_zero_iff] exact forall_congr' fun _ => Classical.not_not #align mv_polynomial.weighted_total_degree'_eq_bot_iff MvPolynomial.weightedTotalDegree'_eq_bot_iff /-- The `weightedTotalDegree'` of the zero polynomial is `⊥`. -/ theorem weightedTotalDegree'_zero (w : σ → M) : weightedTotalDegree' w (0 : MvPolynomial σ R) = ⊥ := by simp only [weightedTotalDegree', support_zero, Finset.sup_empty] #align mv_polynomial.weighted_total_degree'_zero MvPolynomial.weightedTotalDegree'_zero section OrderBot variable [OrderBot M] /-- When `M` has a `⊥` element, we can define the weighted total degree of a multivariate polynomial as a function taking values in `M`. -/ def weightedTotalDegree (w : σ → M) (p : MvPolynomial σ R) : M := p.support.sup fun s => weightedDegree w s #align mv_polynomial.weighted_total_degree MvPolynomial.weightedTotalDegree /-- This lemma relates `weightedTotalDegree` and `weightedTotalDegree'`. -/
Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean
105
116
theorem weightedTotalDegree_coe (w : σ → M) (p : MvPolynomial σ R) (hp : p ≠ 0) : weightedTotalDegree' w p = ↑(weightedTotalDegree w p) := by
rw [Ne, ← weightedTotalDegree'_eq_bot_iff w p, ← Ne, WithBot.ne_bot_iff_exists] at hp obtain ⟨m, hm⟩ := hp apply le_antisymm · simp only [weightedTotalDegree, weightedTotalDegree', Finset.sup_le_iff, WithBot.coe_le_coe] intro b exact Finset.le_sup · simp only [weightedTotalDegree] have hm' : weightedTotalDegree' w p ≤ m := le_of_eq hm.symm rw [← hm] simpa [weightedTotalDegree'] using hm'
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Shing Tak Lam, Mario Carneiro -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Int.ModEq import Mathlib.Data.Nat.Bits import Mathlib.Data.Nat.Log import Mathlib.Data.List.Indexes import Mathlib.Data.List.Palindrome import Mathlib.Tactic.IntervalCases import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring #align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768" /-! # Digits of a natural number This provides a basic API for extracting the digits of a natural number in a given base, and reconstructing numbers from their digits. We also prove some divisibility tests based on digits, in particular completing Theorem #85 from https://www.cs.ru.nl/~freek/100/. Also included is a bound on the length of `Nat.toDigits` from core. ## TODO A basic `norm_digits` tactic for proving goals of the form `Nat.digits a b = l` where `a` and `b` are numerals is not yet ported. -/ namespace Nat variable {n : ℕ} /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux0 : ℕ → List ℕ | 0 => [] | n + 1 => [n + 1] #align nat.digits_aux_0 Nat.digitsAux0 /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux1 (n : ℕ) : List ℕ := List.replicate n 1 #align nat.digits_aux_1 Nat.digitsAux1 /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ | 0 => [] | n + 1 => ((n + 1) % b) :: digitsAux b h ((n + 1) / b) decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h #align nat.digits_aux Nat.digitsAux @[simp] theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by rw [digitsAux] #align nat.digits_aux_zero Nat.digitsAux_zero theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) : digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by cases n · cases w · rw [digitsAux] #align nat.digits_aux_def Nat.digitsAux_def /-- `digits b n` gives the digits, in little-endian order, of a natural number `n` in a specified base `b`. In any base, we have `ofDigits b L = L.foldr (fun x y ↦ x + b * y) 0`. * For any `2 ≤ b`, we have `l < b` for any `l ∈ digits b n`, and the last digit is not zero. This uniquely specifies the behaviour of `digits b`. * For `b = 1`, we define `digits 1 n = List.replicate n 1`. * For `b = 0`, we define `digits 0 n = [n]`, except `digits 0 0 = []`. Note this differs from the existing `Nat.toDigits` in core, which is used for printing numerals. In particular, `Nat.toDigits b 0 = ['0']`, while `digits b 0 = []`. -/ def digits : ℕ → ℕ → List ℕ | 0 => digitsAux0 | 1 => digitsAux1 | b + 2 => digitsAux (b + 2) (by norm_num) #align nat.digits Nat.digits @[simp] theorem digits_zero (b : ℕ) : digits b 0 = [] := by rcases b with (_ | ⟨_ | ⟨_⟩⟩) <;> simp [digits, digitsAux0, digitsAux1] #align nat.digits_zero Nat.digits_zero -- @[simp] -- Porting note (#10618): simp can prove this theorem digits_zero_zero : digits 0 0 = [] := rfl #align nat.digits_zero_zero Nat.digits_zero_zero @[simp] theorem digits_zero_succ (n : ℕ) : digits 0 n.succ = [n + 1] := rfl #align nat.digits_zero_succ Nat.digits_zero_succ theorem digits_zero_succ' : ∀ {n : ℕ}, n ≠ 0 → digits 0 n = [n] | 0, h => (h rfl).elim | _ + 1, _ => rfl #align nat.digits_zero_succ' Nat.digits_zero_succ' @[simp] theorem digits_one (n : ℕ) : digits 1 n = List.replicate n 1 := rfl #align nat.digits_one Nat.digits_one -- @[simp] -- Porting note (#10685): dsimp can prove this theorem digits_one_succ (n : ℕ) : digits 1 (n + 1) = 1 :: digits 1 n := rfl #align nat.digits_one_succ Nat.digits_one_succ
Mathlib/Data/Nat/Digits.lean
119
121
theorem digits_add_two_add_one (b n : ℕ) : digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) := by
simp [digits, digitsAux_def]
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.CategoryTheory.EffectiveEpi.Basic /-! # Composition of effective epimorphisms This file provides `EffectiveEpi` instances for certain compositions. -/ namespace CategoryTheory open Limits Category variable {C : Type*} [Category C] /-- An effective epi family precomposed by a family of split epis is effective epimorphic. This version takes an explicit section to the split epis, and is mainly used to define `effectiveEpiStructCompOfEffectiveEpiSplitEpi`, which takes a `IsSplitEpi` instance instead. -/ noncomputable def effectiveEpiFamilyStructCompOfEffectiveEpiSplitEpi' {α : Type*} {B : C} {X Y : α → C} (f : (a : α) → X a ⟶ B) (g : (a : α) → Y a ⟶ X a) (i : (a : α) → X a ⟶ Y a) (hi : ∀ a, i a ≫ g a = 𝟙 _) [EffectiveEpiFamily _ f] : EffectiveEpiFamilyStruct _ (fun a ↦ g a ≫ f a) where desc e w := EffectiveEpiFamily.desc _ f (fun a ↦ i a ≫ e a) fun a₁ a₂ g₁ g₂ _ ↦ (by simp only [← Category.assoc] apply w _ _ (g₁ ≫ i a₁) (g₂ ≫ i a₂) simpa [← Category.assoc, Category.assoc, hi]) fac e w a := by simp only [Category.assoc, EffectiveEpiFamily.fac] rw [← Category.id_comp (e a), ← Category.assoc, ← Category.assoc] apply w simp only [Category.comp_id, Category.id_comp, ← Category.assoc] aesop uniq _ _ _ hm := by apply EffectiveEpiFamily.uniq _ f intro a rw [← hm a, ← Category.assoc, ← Category.assoc, hi, Category.id_comp] /-- An effective epi family precomposed with a family of split epis is effective epimorphic. -/ noncomputable def effectiveEpiFamilyStructCompOfEffectiveEpiSplitEpi {α : Type*} {B : C} {X Y : α → C} (f : (a : α) → X a ⟶ B) (g : (a : α) → Y a ⟶ X a) [∀ a, IsSplitEpi (g a)] [EffectiveEpiFamily _ f] : EffectiveEpiFamilyStruct _ (fun a ↦ g a ≫ f a) := effectiveEpiFamilyStructCompOfEffectiveEpiSplitEpi' f g (fun a ↦ section_ (g a)) (fun a ↦ IsSplitEpi.id (g a)) instance {α : Type*} {B : C} {X Y : α → C} (f : (a : α) → X a ⟶ B) (g : (a : α) → Y a ⟶ X a) [∀ a, IsSplitEpi (g a)] [EffectiveEpiFamily _ f] : EffectiveEpiFamily _ (fun a ↦ g a ≫ f a) := ⟨⟨effectiveEpiFamilyStructCompOfEffectiveEpiSplitEpi f g⟩⟩ example {B X Y : C} (f : X ⟶ B) (g : Y ⟶ X) [IsSplitEpi g] [EffectiveEpi f] : EffectiveEpi (g ≫ f) := inferInstance instance IsSplitEpi.EffectiveEpi {B X : C} (f : X ⟶ B) [IsSplitEpi f] : EffectiveEpi f := by rw [← Category.comp_id f] infer_instance /-- If a family of morphisms with fixed target, precomposed by a family of epis is effective epimorphic, then the original family is as well. -/ noncomputable def effectiveEpiFamilyStructOfComp {C : Type*} [Category C] {I : Type*} {Z Y : I → C} {X : C} (g : ∀ i, Z i ⟶ Y i) (f : ∀ i, Y i ⟶ X) [EffectiveEpiFamily _ (fun i => g i ≫ f i)] [∀ i, Epi (g i)] : EffectiveEpiFamilyStruct _ f where desc {W} φ h := EffectiveEpiFamily.desc _ (fun i => g i ≫ f i) (fun i => g i ≫ φ i) (fun {T} i₁ i₂ g₁ g₂ eq => by simpa [assoc] using h i₁ i₂ (g₁ ≫ g i₁) (g₂ ≫ g i₂) (by simpa [assoc] using eq)) fac {W} φ h i := by dsimp rw [← cancel_epi (g i), ← assoc, EffectiveEpiFamily.fac _ (fun i => g i ≫ f i)] uniq {W} φ h m hm := EffectiveEpiFamily.uniq _ (fun i => g i ≫ f i) _ _ _ (fun i => by rw [assoc, hm]) lemma effectiveEpiFamily_of_effectiveEpi_epi_comp {α : Type*} {B : C} {X Y : α → C} (f : (a : α) → X a ⟶ B) (g : (a : α) → Y a ⟶ X a) [∀ a, Epi (g a)] [EffectiveEpiFamily _ (fun a ↦ g a ≫ f a)] : EffectiveEpiFamily _ f := ⟨⟨effectiveEpiFamilyStructOfComp g f⟩⟩ lemma effectiveEpi_of_effectiveEpi_epi_comp {B X Y : C} (f : X ⟶ B) (g : Y ⟶ X) [Epi g] [EffectiveEpi (g ≫ f)] : EffectiveEpi f := have := (effectiveEpi_iff_effectiveEpiFamily (g ≫ f)).mp inferInstance have := effectiveEpiFamily_of_effectiveEpi_epi_comp (X := fun () ↦ X) (Y := fun () ↦ Y) (fun () ↦ f) (fun () ↦ g) inferInstance section CompIso variable {B B' : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) [EffectiveEpiFamily X π] (i : B ⟶ B') [IsIso i]
Mathlib/CategoryTheory/EffectiveEpi/Comp.lean
104
112
theorem effectiveEpiFamilyStructCompIso_aux {W : C} (e : (a : α) → X a ⟶ W) (h : ∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂), g₁ ≫ π a₁ ≫ i = g₂ ≫ π a₂ ≫ i → g₁ ≫ e a₁ = g₂ ≫ e a₂) {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂) (hg : g₁ ≫ π a₁ = g₂ ≫ π a₂) : g₁ ≫ e a₁ = g₂ ≫ e a₂ := by
apply h rw [← Category.assoc, hg] simp
/- 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
Mathlib/Probability/Moments.lean
94
95
theorem centralMoment_two_eq_variance [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) : centralMoment X 2 μ = variance X μ := by
rw [hX.variance_eq]; rfl
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Jujian Zhang -/ import Mathlib.RingTheory.Noetherian import Mathlib.Algebra.DirectSum.Module import Mathlib.Algebra.DirectSum.Finsupp import Mathlib.Algebra.Module.Projective import Mathlib.Algebra.Module.Injective import Mathlib.Algebra.Module.CharacterModule import Mathlib.LinearAlgebra.DirectSum.TensorProduct import Mathlib.LinearAlgebra.FreeModule.Basic import Mathlib.Algebra.Module.Projective #align_import ring_theory.flat from "leanprover-community/mathlib"@"62c0a4ef1441edb463095ea02a06e87f3dfe135c" /-! # Flat modules A module `M` over a commutative ring `R` is *flat* if for all finitely generated ideals `I` of `R`, the canonical map `I ⊗ M →ₗ M` is injective. This is equivalent to the claim that for all injective `R`-linear maps `f : M₁ → M₂` the induced map `M₁ ⊗ M → M₂ ⊗ M` is injective. See <https://stacks.math.columbia.edu/tag/00HD>. ## Main declaration * `Module.Flat`: the predicate asserting that an `R`-module `M` is flat. ## Main theorems * `Module.Flat.of_retract`: retracts of flat modules are flat * `Module.Flat.of_linearEquiv`: modules linearly equivalent to a flat modules are flat * `Module.Flat.directSum`: arbitrary direct sums of flat modules are flat * `Module.Flat.of_free`: free modules are flat * `Module.Flat.of_projective`: projective modules are flat * `Module.Flat.preserves_injective_linearMap`: If `M` is a flat module then tensoring with `M` preserves injectivity of linear maps. This lemma is fully universally polymorphic in all arguments, i.e. `R`, `M` and linear maps `N → N'` can all have different universe levels. * `Module.Flat.iff_rTensor_preserves_injective_linearMap`: a module is flat iff tensoring preserves injectivity in the ring's universe (or higher). ## Implementation notes In `Module.Flat.iff_rTensor_preserves_injective_linearMap`, we require that the universe level of the ring is lower than or equal to that of the module. This requirement is to make sure ideals of the ring can be lifted to the universe of the module. It is unclear if this lemma also holds when the module lives in a lower universe. ## TODO * Generalize flatness to noncommutative rings. -/ universe u v w namespace Module open Function (Surjective) open LinearMap Submodule TensorProduct DirectSum variable (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M] /-- An `R`-module `M` is flat if for all finitely generated ideals `I` of `R`, the canonical map `I ⊗ M →ₗ M` is injective. -/ @[mk_iff] class Flat : Prop where out : ∀ ⦃I : Ideal R⦄ (_ : I.FG), Function.Injective (TensorProduct.lift ((lsmul R M).comp I.subtype)) #align module.flat Module.Flat namespace Flat instance self (R : Type u) [CommRing R] : Flat R R := ⟨by intro I _ rw [← Equiv.injective_comp (TensorProduct.rid R I).symm.toEquiv] convert Subtype.coe_injective using 1 ext x simp only [Function.comp_apply, LinearEquiv.coe_toEquiv, rid_symm_apply, comp_apply, mul_one, lift.tmul, Submodule.subtype_apply, Algebra.id.smul_eq_mul, lsmul_apply]⟩ #align module.flat.self Module.Flat.self /-- An `R`-module `M` is flat iff for all finitely generated ideals `I` of `R`, the tensor product of the inclusion `I → R` and the identity `M → M` is injective. See `iff_rTensor_injective'` to extend to all ideals `I`. --/ lemma iff_rTensor_injective : Flat R M ↔ ∀ ⦃I : Ideal R⦄ (_ : I.FG), Function.Injective (rTensor M I.subtype) := by simp [flat_iff, ← lid_comp_rTensor] /-- An `R`-module `M` is flat iff for all ideals `I` of `R`, the tensor product of the inclusion `I → R` and the identity `M → M` is injective. See `iff_rTensor_injective` to restrict to finitely generated ideals `I`. --/
Mathlib/RingTheory/Flat/Basic.lean
98
106
theorem iff_rTensor_injective' : Flat R M ↔ ∀ I : Ideal R, Function.Injective (rTensor M I.subtype) := by
rewrite [Flat.iff_rTensor_injective] refine ⟨fun h I => ?_, fun h I _ => h I⟩ rewrite [injective_iff_map_eq_zero] intro x hx₀ obtain ⟨J, hfg, hle, y, rfl⟩ := Submodule.exists_fg_le_eq_rTensor_inclusion x rewrite [← rTensor_comp_apply] at hx₀ rw [(injective_iff_map_eq_zero _).mp (h hfg) y hx₀, LinearMap.map_zero]
/- Copyright (c) 2023 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Polynomial.Degree.Lemmas /-! # `compute_degree` and `monicity`: tactics for explicit polynomials This file defines two related tactics: `compute_degree` and `monicity`. Using `compute_degree` when the goal is of one of the five forms * `natDegree f ≤ d`, * `degree f ≤ d`, * `natDegree f = d`, * `degree f = d`, * `coeff f d = r`, if `d` is the degree of `f`, tries to solve the goal. It may leave side-goals, in case it is not entirely successful. Using `monicity` when the goal is of the form `Monic f` tries to solve the goal. It may leave side-goals, in case it is not entirely successful. Both tactics admit a `!` modifier (`compute_degree!` and `monicity!`) instructing Lean to try harder to close the goal. See the doc-strings for more details. ## Future work * Currently, `compute_degree` does not deal correctly with some edge cases. For instance, ```lean example [Semiring R] : natDegree (C 0 : R[X]) = 0 := by compute_degree -- ⊢ 0 ≠ 0 ``` Still, it may not be worth to provide special support for `natDegree f = 0`. * Make sure that numerals in coefficients are treated correctly. * Make sure that `compute_degree` works with goals of the form `degree f ≤ ↑d`, with an explicit coercion from `ℕ` on the RHS. * Add support for proving goals of the from `natDegree f ≠ 0` and `degree f ≠ 0`. * Make sure that `degree`, `natDegree` and `coeff` are equally supported. ## Implementation details Assume that `f : R[X]` is a polynomial with coefficients in a semiring `R` and `d` is either in `ℕ` or in `WithBot ℕ`. If the goal has the form `natDegree f = d`, then we convert it to three separate goals: * `natDegree f ≤ d`; * `coeff f d = r`; * `r ≠ 0`. Similarly, an initial goal of the form `degree f = d` gives rise to goals of the form * `degree f ≤ d`; * `coeff f d = r`; * `r ≠ 0`. Next, we apply successively lemmas whose side-goals all have the shape * `natDegree f ≤ d`; * `degree f ≤ d`; * `coeff f d = r`; plus possibly "numerical" identities and choices of elements in `ℕ`, `WithBot ℕ`, and `R`. Recursing into `f`, we break apart additions, multiplications, powers, subtractions,... The leaves of the process are * numerals, `C a`, `X` and `monomial a n`, to which we assign degree `0`, `1` and `a` respectively; * `fvar`s `f`, to which we tautologically assign degree `natDegree f`. -/ open Polynomial namespace Mathlib.Tactic.ComputeDegree section recursion_lemmas /-! ### Simple lemmas about `natDegree` The lemmas in this section all have the form `natDegree <some form of cast> ≤ 0`. Their proofs are weakenings of the stronger lemmas `natDegree <same> = 0`. These are the lemmas called by `compute_degree` on (almost) all the leaves of its recursion. -/ variable {R : Type*} section semiring variable [Semiring R] theorem natDegree_C_le (a : R) : natDegree (C a) ≤ 0 := (natDegree_C a).le theorem natDegree_natCast_le (n : ℕ) : natDegree (n : R[X]) ≤ 0 := (natDegree_natCast _).le theorem natDegree_zero_le : natDegree (0 : R[X]) ≤ 0 := natDegree_zero.le theorem natDegree_one_le : natDegree (1 : R[X]) ≤ 0 := natDegree_one.le @[deprecated (since := "2024-04-17")] alias natDegree_nat_cast_le := natDegree_natCast_le theorem coeff_add_of_eq {n : ℕ} {a b : R} {f g : R[X]} (h_add_left : f.coeff n = a) (h_add_right : g.coeff n = b) : (f + g).coeff n = a + b := by subst ‹_› ‹_›; apply coeff_add
Mathlib/Tactic/ComputeDegree.lean
105
115
theorem coeff_mul_add_of_le_natDegree_of_eq_ite {d df dg : ℕ} {a b : R} {f g : R[X]} (h_mul_left : natDegree f ≤ df) (h_mul_right : natDegree g ≤ dg) (h_mul_left : f.coeff df = a) (h_mul_right : g.coeff dg = b) (ddf : df + dg ≤ d) : (f * g).coeff d = if d = df + dg then a * b else 0 := by
split_ifs with h · subst h_mul_left h_mul_right h exact coeff_mul_of_natDegree_le ‹_› ‹_› · apply coeff_eq_zero_of_natDegree_lt apply lt_of_le_of_lt ?_ (lt_of_le_of_ne ddf ?_) · exact natDegree_mul_le_of_le ‹_› ‹_› · exact ne_comm.mp h
/- Copyright (c) 2021 Vladimir Goryachev. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Vladimir Goryachev, Kyle Miller, Scott Morrison, Eric Rodriguez -/ import Mathlib.Data.Nat.Count import Mathlib.Data.Nat.SuccPred import Mathlib.Order.Interval.Set.Monotone import Mathlib.Order.OrderIsoNat #align_import data.nat.nth from "leanprover-community/mathlib"@"7fdd4f3746cb059edfdb5d52cba98f66fce418c0" /-! # The `n`th Number Satisfying a Predicate This file defines a function for "what is the `n`th number that satisifies a given predicate `p`", and provides lemmas that deal with this function and its connection to `Nat.count`. ## Main definitions * `Nat.nth p n`: The `n`-th natural `k` (zero-indexed) such that `p k`. If there is no such natural (that is, `p` is true for at most `n` naturals), then `Nat.nth p n = 0`. ## Main results * `Nat.nth_eq_orderEmbOfFin`: For a fintely-often true `p`, gives the cardinality of the set of numbers satisfying `p` above particular values of `nth p` * `Nat.gc_count_nth`: Establishes a Galois connection between `Nat.nth p` and `Nat.count p`. * `Nat.nth_eq_orderIsoOfNat`: For an infinitely-ofter true predicate, `nth` agrees with the order-isomorphism of the subtype to the natural numbers. There has been some discussion on the subject of whether both of `nth` and `Nat.Subtype.orderIsoOfNat` should exist. See discussion [here](https://github.com/leanprover-community/mathlib/pull/9457#pullrequestreview-767221180). Future work should address how lemmas that use these should be written. -/ open Finset namespace Nat variable (p : ℕ → Prop) /-- Find the `n`-th natural number satisfying `p` (indexed from `0`, so `nth p 0` is the first natural number satisfying `p`), or `0` if there is no such number. See also `Subtype.orderIsoOfNat` for the order isomorphism with ℕ when `p` is infinitely often true. -/ noncomputable def nth (p : ℕ → Prop) (n : ℕ) : ℕ := by classical exact if h : Set.Finite (setOf p) then (h.toFinset.sort (· ≤ ·)).getD n 0 else @Nat.Subtype.orderIsoOfNat (setOf p) (Set.Infinite.to_subtype h) n #align nat.nth Nat.nth variable {p} /-! ### Lemmas about `Nat.nth` on a finite set -/ theorem nth_of_card_le (hf : (setOf p).Finite) {n : ℕ} (hn : hf.toFinset.card ≤ n) : nth p n = 0 := by rw [nth, dif_pos hf, List.getD_eq_default]; rwa [Finset.length_sort] #align nat.nth_of_card_le Nat.nth_of_card_le theorem nth_eq_getD_sort (h : (setOf p).Finite) (n : ℕ) : nth p n = (h.toFinset.sort (· ≤ ·)).getD n 0 := dif_pos h #align nat.nth_eq_nthd_sort Nat.nth_eq_getD_sort
Mathlib/Data/Nat/Nth.lean
71
73
theorem nth_eq_orderEmbOfFin (hf : (setOf p).Finite) {n : ℕ} (hn : n < hf.toFinset.card) : nth p n = hf.toFinset.orderEmbOfFin rfl ⟨n, hn⟩ := by
rw [nth_eq_getD_sort hf, Finset.orderEmbOfFin_apply, List.getD_eq_get]
/- Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura, Jeremy Avigad, Mario Carneiro -/ import Batteries.Tactic.Alias import Batteries.Data.List.Init.Attach import Batteries.Data.List.Pairwise -- Adaptation note: nightly-2024-03-18. We should be able to remove this after nightly-2024-03-19. import Lean.Elab.Tactic.Rfl /-! # List Permutations This file introduces the `List.Perm` relation, which is true if two lists are permutations of one another. ## Notation The notation `~` is used for permutation equivalence. -/ open Nat namespace List open Perm (swap) @[simp, refl] protected theorem Perm.refl : ∀ l : List α, l ~ l | [] => .nil | x :: xs => (Perm.refl xs).cons x protected theorem Perm.rfl {l : List α} : l ~ l := .refl _ theorem Perm.of_eq (h : l₁ = l₂) : l₁ ~ l₂ := h ▸ .rfl protected theorem Perm.symm {l₁ l₂ : List α} (h : l₁ ~ l₂) : l₂ ~ l₁ := by induction h with | nil => exact nil | cons _ _ ih => exact cons _ ih | swap => exact swap .. | trans _ _ ih₁ ih₂ => exact trans ih₂ ih₁ theorem perm_comm {l₁ l₂ : List α} : l₁ ~ l₂ ↔ l₂ ~ l₁ := ⟨Perm.symm, Perm.symm⟩ theorem Perm.swap' (x y : α) {l₁ l₂ : List α} (p : l₁ ~ l₂) : y :: x :: l₁ ~ x :: y :: l₂ := (swap ..).trans <| p.cons _ |>.cons _ /-- Similar to `Perm.recOn`, but the `swap` case is generalized to `Perm.swap'`, where the tail of the lists are not necessarily the same. -/ @[elab_as_elim] theorem Perm.recOnSwap' {motive : (l₁ : List α) → (l₂ : List α) → l₁ ~ l₂ → Prop} {l₁ l₂ : List α} (p : l₁ ~ l₂) (nil : motive [] [] .nil) (cons : ∀ x {l₁ l₂}, (h : l₁ ~ l₂) → motive l₁ l₂ h → motive (x :: l₁) (x :: l₂) (.cons x h)) (swap' : ∀ x y {l₁ l₂}, (h : l₁ ~ l₂) → motive l₁ l₂ h → motive (y :: x :: l₁) (x :: y :: l₂) (.swap' _ _ h)) (trans : ∀ {l₁ l₂ l₃}, (h₁ : l₁ ~ l₂) → (h₂ : l₂ ~ l₃) → motive l₁ l₂ h₁ → motive l₂ l₃ h₂ → motive l₁ l₃ (.trans h₁ h₂)) : motive l₁ l₂ p := have motive_refl l : motive l l (.refl l) := List.recOn l nil fun x xs ih => cons x (.refl xs) ih Perm.recOn p nil cons (fun x y l => swap' x y (.refl l) (motive_refl l)) trans theorem Perm.eqv (α) : Equivalence (@Perm α) := ⟨.refl, .symm, .trans⟩ instance isSetoid (α) : Setoid (List α) := .mk Perm (Perm.eqv α)
.lake/packages/batteries/Batteries/Data/List/Perm.lean
69
74
theorem Perm.mem_iff {a : α} {l₁ l₂ : List α} (p : l₁ ~ l₂) : a ∈ l₁ ↔ a ∈ l₂ := by
induction p with | nil => rfl | cons _ _ ih => simp only [mem_cons, ih] | swap => simp only [mem_cons, or_left_comm] | trans _ _ ih₁ ih₂ => simp only [ih₁, ih₂]
/- Copyright (c) 2019 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Yakov Pechersky -/ import Mathlib.Data.List.Nodup import Mathlib.Data.List.Zip import Mathlib.Data.Nat.Defs import Mathlib.Data.List.Infix #align_import data.list.rotate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # List rotation This file proves basic results about `List.rotate`, the list rotation. ## Main declarations * `List.IsRotated l₁ l₂`: States that `l₁` is a rotated version of `l₂`. * `List.cyclicPermutations l`: The list of all cyclic permutants of `l`, up to the length of `l`. ## Tags rotated, rotation, permutation, cycle -/ universe u variable {α : Type u} open Nat Function namespace List theorem rotate_mod (l : List α) (n : ℕ) : l.rotate (n % l.length) = l.rotate n := by simp [rotate] #align list.rotate_mod List.rotate_mod @[simp] theorem rotate_nil (n : ℕ) : ([] : List α).rotate n = [] := by simp [rotate] #align list.rotate_nil List.rotate_nil @[simp]
Mathlib/Data/List/Rotate.lean
45
45
theorem rotate_zero (l : List α) : l.rotate 0 = l := by
simp [rotate]
/- 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.Analysis.Convex.Hull #align_import analysis.convex.join from "leanprover-community/mathlib"@"951bf1d9e98a2042979ced62c0620bcfb3587cf8" /-! # Convex join This file defines the convex join of two sets. The convex join of `s` and `t` is the union of the segments with one end in `s` and the other in `t`. This is notably a useful gadget to deal with convex hulls of finite sets. -/ open Set variable {ι : Sort*} {𝕜 E : Type*} section OrderedSemiring variable (𝕜) [OrderedSemiring 𝕜] [AddCommMonoid E] [Module 𝕜 E] {s t s₁ s₂ t₁ t₂ u : Set E} {x y : E} /-- The join of two sets is the union of the segments joining them. This can be interpreted as the topological join, but within the original space. -/ def convexJoin (s t : Set E) : Set E := ⋃ (x ∈ s) (y ∈ t), segment 𝕜 x y #align convex_join convexJoin variable {𝕜} theorem mem_convexJoin : x ∈ convexJoin 𝕜 s t ↔ ∃ a ∈ s, ∃ b ∈ t, x ∈ segment 𝕜 a b := by simp [convexJoin] #align mem_convex_join mem_convexJoin theorem convexJoin_comm (s t : Set E) : convexJoin 𝕜 s t = convexJoin 𝕜 t s := (iUnion₂_comm _).trans <| by simp_rw [convexJoin, segment_symm] #align convex_join_comm convexJoin_comm theorem convexJoin_mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : convexJoin 𝕜 s₁ t₁ ⊆ convexJoin 𝕜 s₂ t₂ := biUnion_mono hs fun _ _ => biUnion_subset_biUnion_left ht #align convex_join_mono convexJoin_mono theorem convexJoin_mono_left (hs : s₁ ⊆ s₂) : convexJoin 𝕜 s₁ t ⊆ convexJoin 𝕜 s₂ t := convexJoin_mono hs Subset.rfl #align convex_join_mono_left convexJoin_mono_left theorem convexJoin_mono_right (ht : t₁ ⊆ t₂) : convexJoin 𝕜 s t₁ ⊆ convexJoin 𝕜 s t₂ := convexJoin_mono Subset.rfl ht #align convex_join_mono_right convexJoin_mono_right @[simp] theorem convexJoin_empty_left (t : Set E) : convexJoin 𝕜 ∅ t = ∅ := by simp [convexJoin] #align convex_join_empty_left convexJoin_empty_left @[simp] theorem convexJoin_empty_right (s : Set E) : convexJoin 𝕜 s ∅ = ∅ := by simp [convexJoin] #align convex_join_empty_right convexJoin_empty_right @[simp] theorem convexJoin_singleton_left (t : Set E) (x : E) : convexJoin 𝕜 {x} t = ⋃ y ∈ t, segment 𝕜 x y := by simp [convexJoin] #align convex_join_singleton_left convexJoin_singleton_left @[simp] theorem convexJoin_singleton_right (s : Set E) (y : E) : convexJoin 𝕜 s {y} = ⋃ x ∈ s, segment 𝕜 x y := by simp [convexJoin] #align convex_join_singleton_right convexJoin_singleton_right -- Porting note (#10618): simp can prove it
Mathlib/Analysis/Convex/Join.lean
75
75
theorem convexJoin_singletons (x : E) : convexJoin 𝕜 {x} {y} = segment 𝕜 x y := by
simp
/- 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.Control.Functor.Multivariate import Mathlib.Data.PFunctor.Univariate.Basic #align_import data.pfunctor.multivariate.basic from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" /-! # Multivariate polynomial functors. Multivariate polynomial functors are used for defining M-types and W-types. They map a type vector `α` to the type `Σ a : A, B a ⟹ α`, with `A : Type` and `B : A → TypeVec n`. They interact well with Lean's inductive definitions because they guarantee that occurrences of `α` are positive. -/ universe u v open MvFunctor /-- multivariate polynomial functors -/ @[pp_with_univ] structure MvPFunctor (n : ℕ) where /-- The head type -/ A : Type u /-- The child family of types -/ B : A → TypeVec.{u} n #align mvpfunctor MvPFunctor namespace MvPFunctor open MvFunctor (LiftP LiftR) variable {n m : ℕ} (P : MvPFunctor.{u} n) /-- Applying `P` to an object of `Type` -/ @[coe] def Obj (α : TypeVec.{u} n) : Type u := Σ a : P.A, P.B a ⟹ α #align mvpfunctor.obj MvPFunctor.Obj instance : CoeFun (MvPFunctor.{u} n) (fun _ => TypeVec.{u} n → Type u) where coe := Obj /-- Applying `P` to a morphism of `Type` -/ def map {α β : TypeVec n} (f : α ⟹ β) : P α → P β := fun ⟨a, g⟩ => ⟨a, TypeVec.comp f g⟩ #align mvpfunctor.map MvPFunctor.map instance : Inhabited (MvPFunctor n) := ⟨⟨default, default⟩⟩ instance Obj.inhabited {α : TypeVec n} [Inhabited P.A] [∀ i, Inhabited (α i)] : Inhabited (P α) := ⟨⟨default, fun _ _ => default⟩⟩ #align mvpfunctor.obj.inhabited MvPFunctor.Obj.inhabited instance : MvFunctor.{u} P.Obj := ⟨@MvPFunctor.map n P⟩ theorem map_eq {α β : TypeVec n} (g : α ⟹ β) (a : P.A) (f : P.B a ⟹ α) : @MvFunctor.map _ P.Obj _ _ _ g ⟨a, f⟩ = ⟨a, g ⊚ f⟩ := rfl #align mvpfunctor.map_eq MvPFunctor.map_eq theorem id_map {α : TypeVec n} : ∀ x : P α, TypeVec.id <$$> x = x | ⟨_, _⟩ => rfl #align mvpfunctor.id_map MvPFunctor.id_map theorem comp_map {α β γ : TypeVec n} (f : α ⟹ β) (g : β ⟹ γ) : ∀ x : P α, (g ⊚ f) <$$> x = g <$$> f <$$> x | ⟨_, _⟩ => rfl #align mvpfunctor.comp_map MvPFunctor.comp_map instance : LawfulMvFunctor.{u} P.Obj where id_map := @id_map _ P comp_map := @comp_map _ P /-- Constant functor where the input object does not affect the output -/ def const (n : ℕ) (A : Type u) : MvPFunctor n := { A B := fun _ _ => PEmpty } #align mvpfunctor.const MvPFunctor.const section Const variable (n) {A : Type u} {α β : TypeVec.{u} n} /-- Constructor for the constant functor -/ def const.mk (x : A) {α} : const n A α := ⟨x, fun _ a => PEmpty.elim a⟩ #align mvpfunctor.const.mk MvPFunctor.const.mk variable {n} /-- Destructor for the constant functor -/ def const.get (x : const n A α) : A := x.1 #align mvpfunctor.const.get MvPFunctor.const.get @[simp] theorem const.get_map (f : α ⟹ β) (x : const n A α) : const.get (f <$$> x) = const.get x := by cases x rfl #align mvpfunctor.const.get_map MvPFunctor.const.get_map @[simp] theorem const.get_mk (x : A) : const.get (const.mk n x : const n A α) = x := rfl #align mvpfunctor.const.get_mk MvPFunctor.const.get_mk @[simp] theorem const.mk_get (x : const n A α) : const.mk n (const.get x) = x := by cases x dsimp [const.get, const.mk] congr with (_⟨⟩) #align mvpfunctor.const.mk_get MvPFunctor.const.mk_get end Const /-- Functor composition on polynomial functors -/ def comp (P : MvPFunctor.{u} n) (Q : Fin2 n → MvPFunctor.{u} m) : MvPFunctor m where A := Σ a₂ : P.1, ∀ i, P.2 a₂ i → (Q i).1 B a i := Σ(j : _) (b : P.2 a.1 j), (Q j).2 (a.snd j b) i #align mvpfunctor.comp MvPFunctor.comp variable {P} {Q : Fin2 n → MvPFunctor.{u} m} {α β : TypeVec.{u} m} /-- Constructor for functor composition -/ def comp.mk (x : P (fun i => Q i α)) : comp P Q α := ⟨⟨x.1, fun _ a => (x.2 _ a).1⟩, fun i a => (x.snd a.fst a.snd.fst).snd i a.snd.snd⟩ #align mvpfunctor.comp.mk MvPFunctor.comp.mk /-- Destructor for functor composition -/ def comp.get (x : comp P Q α) : P (fun i => Q i α) := ⟨x.1.1, fun i a => ⟨x.fst.snd i a, fun (j : Fin2 m) (b : (Q i).B _ j) => x.snd j ⟨i, ⟨a, b⟩⟩⟩⟩ #align mvpfunctor.comp.get MvPFunctor.comp.get theorem comp.get_map (f : α ⟹ β) (x : comp P Q α) : comp.get (f <$$> x) = (fun i (x : Q i α) => f <$$> x) <$$> comp.get x := by rfl #align mvpfunctor.comp.get_map MvPFunctor.comp.get_map @[simp]
Mathlib/Data/PFunctor/Multivariate/Basic.lean
148
149
theorem comp.get_mk (x : P (fun i => Q i α)) : comp.get (comp.mk x) = x := by
rfl
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Geometry.Euclidean.Sphere.Basic #align_import geometry.euclidean.sphere.second_inter from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Second intersection of a sphere and a line This file defines and proves basic results about the second intersection of a sphere with a line through a point on that sphere. ## Main definitions * `EuclideanGeometry.Sphere.secondInter` is the second intersection of a sphere with a line through a point on that sphere. -/ noncomputable section open RealInnerProductSpace namespace EuclideanGeometry variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] /-- The second intersection of a sphere with a line through a point on that sphere; that point if it is the only point of intersection of the line with the sphere. The intended use of this definition is when `p ∈ s`; the definition does not use `s.radius`, so in general it returns the second intersection with the sphere through `p` and with center `s.center`. -/ def Sphere.secondInter (s : Sphere P) (p : P) (v : V) : P := (-2 * ⟪v, p -ᵥ s.center⟫ / ⟪v, v⟫) • v +ᵥ p #align euclidean_geometry.sphere.second_inter EuclideanGeometry.Sphere.secondInter /-- The distance between `secondInter` and the center equals the distance between the original point and the center. -/ @[simp] theorem Sphere.secondInter_dist (s : Sphere P) (p : P) (v : V) : dist (s.secondInter p v) s.center = dist p s.center := by rw [Sphere.secondInter] by_cases hv : v = 0; · simp [hv] rw [dist_smul_vadd_eq_dist _ _ hv] exact Or.inr rfl #align euclidean_geometry.sphere.second_inter_dist EuclideanGeometry.Sphere.secondInter_dist /-- The point given by `secondInter` lies on the sphere. -/ @[simp]
Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean
54
55
theorem Sphere.secondInter_mem {s : Sphere P} {p : P} (v : V) : s.secondInter p v ∈ s ↔ p ∈ s := by
simp_rw [mem_sphere, Sphere.secondInter_dist]
/- Copyright (c) 2023 Mark Andrew Gerads. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Andrew Gerads, Junyan Xu, Eric Wieser -/ import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Tactic.Ring #align_import data.nat.hyperoperation from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Hyperoperation sequence This file defines the Hyperoperation sequence. `hyperoperation 0 m k = k + 1` `hyperoperation 1 m k = m + k` `hyperoperation 2 m k = m * k` `hyperoperation 3 m k = m ^ k` `hyperoperation (n + 3) m 0 = 1` `hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k)` ## References * <https://en.wikipedia.org/wiki/Hyperoperation> ## Tags hyperoperation -/ /-- Implementation of the hyperoperation sequence where `hyperoperation n m k` is the `n`th hyperoperation between `m` and `k`. -/ def hyperoperation : ℕ → ℕ → ℕ → ℕ | 0, _, k => k + 1 | 1, m, 0 => m | 2, _, 0 => 0 | _ + 3, _, 0 => 1 | n + 1, m, k + 1 => hyperoperation n m (hyperoperation (n + 1) m k) #align hyperoperation hyperoperation -- Basic hyperoperation lemmas @[simp] theorem hyperoperation_zero (m : ℕ) : hyperoperation 0 m = Nat.succ := funext fun k => by rw [hyperoperation, Nat.succ_eq_add_one] #align hyperoperation_zero hyperoperation_zero theorem hyperoperation_ge_three_eq_one (n m : ℕ) : hyperoperation (n + 3) m 0 = 1 := by rw [hyperoperation] #align hyperoperation_ge_three_eq_one hyperoperation_ge_three_eq_one theorem hyperoperation_recursion (n m k : ℕ) : hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k) := by rw [hyperoperation] #align hyperoperation_recursion hyperoperation_recursion -- Interesting hyperoperation lemmas @[simp] theorem hyperoperation_one : hyperoperation 1 = (· + ·) := by ext m k induction' k with bn bih · rw [Nat.add_zero m, hyperoperation] · rw [hyperoperation_recursion, bih, hyperoperation_zero] exact Nat.add_assoc m bn 1 #align hyperoperation_one hyperoperation_one @[simp] theorem hyperoperation_two : hyperoperation 2 = (· * ·) := by ext m k induction' k with bn bih · rw [hyperoperation] exact (Nat.mul_zero m).symm · rw [hyperoperation_recursion, hyperoperation_one, bih] -- Porting note: was `ring` dsimp only nth_rewrite 1 [← mul_one m] rw [← mul_add, add_comm] #align hyperoperation_two hyperoperation_two @[simp] theorem hyperoperation_three : hyperoperation 3 = (· ^ ·) := by ext m k induction' k with bn bih · rw [hyperoperation_ge_three_eq_one] exact (pow_zero m).symm · rw [hyperoperation_recursion, hyperoperation_two, bih] exact (pow_succ' m bn).symm #align hyperoperation_three hyperoperation_three theorem hyperoperation_ge_two_eq_self (n m : ℕ) : hyperoperation (n + 2) m 1 = m := by induction' n with nn nih · rw [hyperoperation_two] ring · rw [hyperoperation_recursion, hyperoperation_ge_three_eq_one, nih] #align hyperoperation_ge_two_eq_self hyperoperation_ge_two_eq_self theorem hyperoperation_two_two_eq_four (n : ℕ) : hyperoperation (n + 1) 2 2 = 4 := by induction' n with nn nih · rw [hyperoperation_one] · rw [hyperoperation_recursion, hyperoperation_ge_two_eq_self, nih] #align hyperoperation_two_two_eq_four hyperoperation_two_two_eq_four theorem hyperoperation_ge_three_one (n : ℕ) : ∀ k : ℕ, hyperoperation (n + 3) 1 k = 1 := by induction' n with nn nih · intro k rw [hyperoperation_three] dsimp rw [one_pow] · intro k cases k · rw [hyperoperation_ge_three_eq_one] · rw [hyperoperation_recursion, nih] #align hyperoperation_ge_three_one hyperoperation_ge_three_one
Mathlib/Data/Nat/Hyperoperation.lean
116
126
theorem hyperoperation_ge_four_zero (n k : ℕ) : hyperoperation (n + 4) 0 k = if Even k then 1 else 0 := by
induction' k with kk kih · rw [hyperoperation_ge_three_eq_one] simp only [Nat.zero_eq, even_zero, if_true] · rw [hyperoperation_recursion] rw [kih] simp_rw [Nat.even_add_one] split_ifs · exact hyperoperation_ge_two_eq_self (n + 1) 0 · exact hyperoperation_ge_three_eq_one n 0
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Field.Opposite import Mathlib.Algebra.Group.Invertible.Defs import Mathlib.Algebra.Ring.Aut import Mathlib.Algebra.Ring.CompTypeclasses import Mathlib.Algebra.Field.Opposite import Mathlib.Algebra.Group.Invertible.Defs import Mathlib.Data.NNRat.Defs import Mathlib.Data.Rat.Cast.Defs import Mathlib.Data.SetLike.Basic import Mathlib.GroupTheory.GroupAction.Opposite #align_import algebra.star.basic from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004" /-! # Star monoids, rings, and modules We introduce the basic algebraic notions of star monoids, star rings, and star modules. A star algebra is simply a star ring that is also a star module. These are implemented as "mixin" typeclasses, so to summon a star ring (for example) one needs to write `(R : Type*) [Ring R] [StarRing R]`. This avoids difficulties with diamond inheritance. For now we simply do not introduce notations, as different users are expected to feel strongly about the relative merits of `r^*`, `r†`, `rᘁ`, and so on. Our star rings are actually star non-unital, non-associative, semirings, but of course we can prove `star_neg : star (-r) = - star r` when the underlying semiring is a ring. -/ assert_not_exists Finset assert_not_exists Subgroup universe u v w open MulOpposite open scoped NNRat /-- Notation typeclass (with no default notation!) for an algebraic structure with a star operation. -/ class Star (R : Type u) where star : R → R #align has_star Star -- https://github.com/leanprover/lean4/issues/2096 compile_def% Star.star variable {R : Type u} export Star (star) /-- A star operation (e.g. complex conjugate). -/ add_decl_doc star /-- `StarMemClass S G` states `S` is a type of subsets `s ⊆ G` closed under star. -/ class StarMemClass (S R : Type*) [Star R] [SetLike S R] : Prop where /-- Closure under star. -/ star_mem : ∀ {s : S} {r : R}, r ∈ s → star r ∈ s #align star_mem_class StarMemClass export StarMemClass (star_mem) attribute [aesop safe apply (rule_sets := [SetLike])] star_mem namespace StarMemClass variable {S : Type w} [Star R] [SetLike S R] [hS : StarMemClass S R] (s : S) instance instStar : Star s where star r := ⟨star (r : R), star_mem r.prop⟩ @[simp] lemma coe_star (x : s) : star x = star (x : R) := rfl end StarMemClass /-- Typeclass for a star operation with is involutive. -/ class InvolutiveStar (R : Type u) extends Star R where /-- Involutive condition. -/ star_involutive : Function.Involutive star #align has_involutive_star InvolutiveStar export InvolutiveStar (star_involutive) @[simp] theorem star_star [InvolutiveStar R] (r : R) : star (star r) = r := star_involutive _ #align star_star star_star theorem star_injective [InvolutiveStar R] : Function.Injective (star : R → R) := Function.Involutive.injective star_involutive #align star_injective star_injective @[simp] theorem star_inj [InvolutiveStar R] {x y : R} : star x = star y ↔ x = y := star_injective.eq_iff #align star_inj star_inj /-- `star` as an equivalence when it is involutive. -/ protected def Equiv.star [InvolutiveStar R] : Equiv.Perm R := star_involutive.toPerm _ #align equiv.star Equiv.star
Mathlib/Algebra/Star/Basic.lean
111
112
theorem eq_star_of_eq_star [InvolutiveStar R] {r s : R} (h : r = star s) : s = star r := by
simp [h]
/- Copyright (c) 2022 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Finsupp.Defs import Mathlib.Data.Finset.Pairwise #align_import data.finsupp.big_operators from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Sums of collections of Finsupp, and their support This file provides results about the `Finsupp.support` of sums of collections of `Finsupp`, including sums of `List`, `Multiset`, and `Finset`. The support of the sum is a subset of the union of the supports: * `List.support_sum_subset` * `Multiset.support_sum_subset` * `Finset.support_sum_subset` The support of the sum of pairwise disjoint finsupps is equal to the union of the supports * `List.support_sum_eq` * `Multiset.support_sum_eq` * `Finset.support_sum_eq` Member in the support of the indexed union over a collection iff it is a member of the support of a member of the collection: * `List.mem_foldr_sup_support_iff` * `Multiset.mem_sup_map_support_iff` * `Finset.mem_sup_support_iff` -/ variable {ι M : Type*} [DecidableEq ι] theorem List.support_sum_subset [AddMonoid M] (l : List (ι →₀ M)) : l.sum.support ⊆ l.foldr (Finsupp.support · ⊔ ·) ∅ := by induction' l with hd tl IH · simp · simp only [List.sum_cons, Finset.union_comm] refine Finsupp.support_add.trans (Finset.union_subset_union ?_ IH) rfl #align list.support_sum_subset List.support_sum_subset theorem Multiset.support_sum_subset [AddCommMonoid M] (s : Multiset (ι →₀ M)) : s.sum.support ⊆ (s.map Finsupp.support).sup := by induction s using Quot.inductionOn simpa only [Multiset.quot_mk_to_coe'', Multiset.sum_coe, Multiset.map_coe, Multiset.sup_coe, List.foldr_map] using List.support_sum_subset _ #align multiset.support_sum_subset Multiset.support_sum_subset
Mathlib/Data/Finsupp/BigOperators.lean
55
57
theorem Finset.support_sum_subset [AddCommMonoid M] (s : Finset (ι →₀ M)) : (s.sum id).support ⊆ Finset.sup s Finsupp.support := by
classical convert Multiset.support_sum_subset s.1; simp
/- Copyright (c) 2020 Aaron Anderson, Jalex Stark, Kyle Miller. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Alena Gusakov -/ import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Data.Sym.Card /-! # Definitions for finite and locally finite graphs This file defines finite versions of `edgeSet`, `neighborSet` and `incidenceSet` and proves some of their basic properties. It also defines the notion of a locally finite graph, which is one whose vertices have finite degree. The design for finiteness is that each definition takes the smallest finiteness assumption necessary. For example, `SimpleGraph.neighborFinset v` only requires that `v` have finitely many neighbors. ## Main definitions * `SimpleGraph.edgeFinset` is the `Finset` of edges in a graph, if `edgeSet` is finite * `SimpleGraph.neighborFinset` is the `Finset` of vertices adjacent to a given vertex, if `neighborSet` is finite * `SimpleGraph.incidenceFinset` is the `Finset` of edges containing a given vertex, if `incidenceSet` is finite ## Naming conventions If the vertex type of a graph is finite, we refer to its cardinality as `CardVerts` or `card_verts`. ## Implementation notes * A locally finite graph is one with instances `Π v, Fintype (G.neighborSet v)`. * Given instances `DecidableRel G.Adj` and `Fintype V`, then the graph is locally finite, too. -/ open Finset Function namespace SimpleGraph variable {V : Type*} (G : SimpleGraph V) {e : Sym2 V} section EdgeFinset variable {G₁ G₂ : SimpleGraph V} [Fintype G.edgeSet] [Fintype G₁.edgeSet] [Fintype G₂.edgeSet] /-- The `edgeSet` of the graph as a `Finset`. -/ abbrev edgeFinset : Finset (Sym2 V) := Set.toFinset G.edgeSet #align simple_graph.edge_finset SimpleGraph.edgeFinset @[norm_cast] theorem coe_edgeFinset : (G.edgeFinset : Set (Sym2 V)) = G.edgeSet := Set.coe_toFinset _ #align simple_graph.coe_edge_finset SimpleGraph.coe_edgeFinset variable {G} theorem mem_edgeFinset : e ∈ G.edgeFinset ↔ e ∈ G.edgeSet := Set.mem_toFinset #align simple_graph.mem_edge_finset SimpleGraph.mem_edgeFinset theorem not_isDiag_of_mem_edgeFinset : e ∈ G.edgeFinset → ¬e.IsDiag := not_isDiag_of_mem_edgeSet _ ∘ mem_edgeFinset.1 #align simple_graph.not_is_diag_of_mem_edge_finset SimpleGraph.not_isDiag_of_mem_edgeFinset theorem edgeFinset_inj : G₁.edgeFinset = G₂.edgeFinset ↔ G₁ = G₂ := by simp #align simple_graph.edge_finset_inj SimpleGraph.edgeFinset_inj theorem edgeFinset_subset_edgeFinset : G₁.edgeFinset ⊆ G₂.edgeFinset ↔ G₁ ≤ G₂ := by simp #align simple_graph.edge_finset_subset_edge_finset SimpleGraph.edgeFinset_subset_edgeFinset theorem edgeFinset_ssubset_edgeFinset : G₁.edgeFinset ⊂ G₂.edgeFinset ↔ G₁ < G₂ := by simp #align simple_graph.edge_finset_ssubset_edge_finset SimpleGraph.edgeFinset_ssubset_edgeFinset @[gcongr] alias ⟨_, edgeFinset_mono⟩ := edgeFinset_subset_edgeFinset #align simple_graph.edge_finset_mono SimpleGraph.edgeFinset_mono alias ⟨_, edgeFinset_strict_mono⟩ := edgeFinset_ssubset_edgeFinset #align simple_graph.edge_finset_strict_mono SimpleGraph.edgeFinset_strict_mono attribute [mono] edgeFinset_mono edgeFinset_strict_mono @[simp] theorem edgeFinset_bot : (⊥ : SimpleGraph V).edgeFinset = ∅ := by simp [edgeFinset] #align simple_graph.edge_finset_bot SimpleGraph.edgeFinset_bot @[simp] theorem edgeFinset_sup [Fintype (edgeSet (G₁ ⊔ G₂))] [DecidableEq V] : (G₁ ⊔ G₂).edgeFinset = G₁.edgeFinset ∪ G₂.edgeFinset := by simp [edgeFinset] #align simple_graph.edge_finset_sup SimpleGraph.edgeFinset_sup @[simp] theorem edgeFinset_inf [DecidableEq V] : (G₁ ⊓ G₂).edgeFinset = G₁.edgeFinset ∩ G₂.edgeFinset := by simp [edgeFinset] #align simple_graph.edge_finset_inf SimpleGraph.edgeFinset_inf @[simp] theorem edgeFinset_sdiff [DecidableEq V] : (G₁ \ G₂).edgeFinset = G₁.edgeFinset \ G₂.edgeFinset := by simp [edgeFinset] #align simple_graph.edge_finset_sdiff SimpleGraph.edgeFinset_sdiff theorem edgeFinset_card : G.edgeFinset.card = Fintype.card G.edgeSet := Set.toFinset_card _ #align simple_graph.edge_finset_card SimpleGraph.edgeFinset_card @[simp] theorem edgeSet_univ_card : (univ : Finset G.edgeSet).card = G.edgeFinset.card := Fintype.card_of_subtype G.edgeFinset fun _ => mem_edgeFinset #align simple_graph.edge_set_univ_card SimpleGraph.edgeSet_univ_card variable [Fintype V] @[simp] theorem edgeFinset_top [DecidableEq V] : (⊤ : SimpleGraph V).edgeFinset = univ.filter fun e => ¬e.IsDiag := by rw [← coe_inj]; simp /-- The complete graph on `n` vertices has `n.choose 2` edges. -/ theorem card_edgeFinset_top_eq_card_choose_two [DecidableEq V] : (⊤ : SimpleGraph V).edgeFinset.card = (Fintype.card V).choose 2 := by simp_rw [Set.toFinset_card, edgeSet_top, Set.coe_setOf, ← Sym2.card_subtype_not_diag] /-- Any graph on `n` vertices has at most `n.choose 2` edges. -/ theorem card_edgeFinset_le_card_choose_two : G.edgeFinset.card ≤ (Fintype.card V).choose 2 := by classical rw [← card_edgeFinset_top_eq_card_choose_two] exact card_le_card (edgeFinset_mono le_top) end EdgeFinset
Mathlib/Combinatorics/SimpleGraph/Finite.lean
137
141
theorem edgeFinset_deleteEdges [DecidableEq V] [Fintype G.edgeSet] (s : Finset (Sym2 V)) [Fintype (G.deleteEdges s).edgeSet] : (G.deleteEdges s).edgeFinset = G.edgeFinset \ s := by
ext e simp [edgeSet_deleteEdges]
/- Copyright (c) 2022 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.InnerProductSpace.Orientation import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar #align_import measure_theory.measure.haar.inner_product_space from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Volume forms and measures on inner product spaces A volume form induces a Lebesgue measure on general finite-dimensional real vector spaces. In this file, we discuss the specific situation of inner product spaces, where an orientation gives rise to a canonical volume form. We show that the measure coming from this volume form gives measure `1` to the parallelepiped spanned by any orthonormal basis, and that it coincides with the canonical `volume` from the `MeasureSpace` instance. -/ open FiniteDimensional MeasureTheory MeasureTheory.Measure Set variable {ι E F : Type*} variable [Fintype ι] [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] [MeasurableSpace F] [BorelSpace F] section variable {m n : ℕ} [_i : Fact (finrank ℝ F = n)] /-- The volume form coming from an orientation in an inner product space gives measure `1` to the parallelepiped associated to any orthonormal basis. This is a rephrasing of `abs_volumeForm_apply_of_orthonormal` in terms of measures. -/ theorem Orientation.measure_orthonormalBasis (o : Orientation ℝ F (Fin n)) (b : OrthonormalBasis ι ℝ F) : o.volumeForm.measure (parallelepiped b) = 1 := by have e : ι ≃ Fin n := by refine Fintype.equivFinOfCardEq ?_ rw [← _i.out, finrank_eq_card_basis b.toBasis] have A : ⇑b = b.reindex e ∘ e := by ext x simp only [OrthonormalBasis.coe_reindex, Function.comp_apply, Equiv.symm_apply_apply] rw [A, parallelepiped_comp_equiv, AlternatingMap.measure_parallelepiped, o.abs_volumeForm_apply_of_orthonormal, ENNReal.ofReal_one] #align orientation.measure_orthonormal_basis Orientation.measure_orthonormalBasis /-- In an oriented inner product space, the measure coming from the canonical volume form associated to an orientation coincides with the volume. -/ theorem Orientation.measure_eq_volume (o : Orientation ℝ F (Fin n)) : o.volumeForm.measure = volume := by have A : o.volumeForm.measure (stdOrthonormalBasis ℝ F).toBasis.parallelepiped = 1 := Orientation.measure_orthonormalBasis o (stdOrthonormalBasis ℝ F) rw [addHaarMeasure_unique o.volumeForm.measure (stdOrthonormalBasis ℝ F).toBasis.parallelepiped, A, one_smul] simp only [volume, Basis.addHaar] #align orientation.measure_eq_volume Orientation.measure_eq_volume end /-- The volume measure in a finite-dimensional inner product space gives measure `1` to the parallelepiped spanned by any orthonormal basis. -/ theorem OrthonormalBasis.volume_parallelepiped (b : OrthonormalBasis ι ℝ F) : volume (parallelepiped b) = 1 := by haveI : Fact (finrank ℝ F = finrank ℝ F) := ⟨rfl⟩ let o := (stdOrthonormalBasis ℝ F).toBasis.orientation rw [← o.measure_eq_volume] exact o.measure_orthonormalBasis b #align orthonormal_basis.volume_parallelepiped OrthonormalBasis.volume_parallelepiped /-- The Haar measure defined by any orthonormal basis of a finite-dimensional inner product space is equal to its volume measure. -/
Mathlib/MeasureTheory/Measure/Haar/InnerProductSpace.lean
71
76
theorem OrthonormalBasis.addHaar_eq_volume {ι F : Type*} [Fintype ι] [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F] [MeasurableSpace F] [BorelSpace F] (b : OrthonormalBasis ι ℝ F) : b.toBasis.addHaar = volume := by
rw [Basis.addHaar_eq_iff] exact b.volume_parallelepiped
/- Copyright (c) 2023 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.Finset.Basic /-! # Update a function on a set of values This file defines `Function.updateFinset`, the operation that updates a function on a (finite) set of values. This is a very specific function used for `MeasureTheory.marginal`, and possibly not that useful for other purposes. -/ variable {ι : Sort _} {π : ι → Sort _} {x : ∀ i, π i} [DecidableEq ι] namespace Function /-- `updateFinset x s y` is the vector `x` with the coordinates in `s` changed to the values of `y`. -/ def updateFinset (x : ∀ i, π i) (s : Finset ι) (y : ∀ i : ↥s, π i) (i : ι) : π i := if hi : i ∈ s then y ⟨i, hi⟩ else x i open Finset Equiv theorem updateFinset_def {s : Finset ι} {y} : updateFinset x s y = fun i ↦ if hi : i ∈ s then y ⟨i, hi⟩ else x i := rfl @[simp] theorem updateFinset_empty {y} : updateFinset x ∅ y = x := rfl
Mathlib/Data/Finset/Update.lean
35
41
theorem updateFinset_singleton {i y} : updateFinset x {i} y = Function.update x i (y ⟨i, mem_singleton_self i⟩) := by
congr with j by_cases hj : j = i · cases hj simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset] · simp [hj, updateFinset]
/- 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, Violeta Hernández Palacios -/ import Mathlib.MeasureTheory.MeasurableSpace.Defs import Mathlib.SetTheory.Cardinal.Cofinality import Mathlib.SetTheory.Cardinal.Continuum #align_import measure_theory.card_measurable_space from "leanprover-community/mathlib"@"f2b108e8e97ba393f22bf794989984ddcc1da89b" /-! # Cardinal of sigma-algebras If a sigma-algebra is generated by a set of sets `s`, then the cardinality of the sigma-algebra is bounded by `(max #s 2) ^ ℵ₀`. This is stated in `MeasurableSpace.cardinal_generate_measurable_le` and `MeasurableSpace.cardinalMeasurableSet_le`. In particular, if `#s ≤ 𝔠`, then the generated sigma-algebra has cardinality at most `𝔠`, see `MeasurableSpace.cardinal_measurableSet_le_continuum`. For the proof, we rely on an explicit inductive construction of the sigma-algebra generated by `s` (instead of the inductive predicate `GenerateMeasurable`). This transfinite inductive construction is parameterized by an ordinal `< ω₁`, and the cardinality bound is preserved along each step of the construction. We show in `MeasurableSpace.generateMeasurable_eq_rec` that this indeed generates this sigma-algebra. -/ universe u variable {α : Type u} open Cardinal Set -- Porting note: fix universe below, not here local notation "ω₁" => (WellOrder.α <| Quotient.out <| Cardinal.ord (aleph 1 : Cardinal)) namespace MeasurableSpace /-- Transfinite induction construction of the sigma-algebra generated by a set of sets `s`. At each step, we add all elements of `s`, the empty set, the complements of already constructed sets, and countable unions of already constructed sets. We index this construction by an ordinal `< ω₁`, as this will be enough to generate all sets in the sigma-algebra. This construction is very similar to that of the Borel hierarchy. -/ def generateMeasurableRec (s : Set (Set α)) : (ω₁ : Type u) → Set (Set α) | i => let S := ⋃ j : Iio i, generateMeasurableRec s (j.1) s ∪ {∅} ∪ compl '' S ∪ Set.range fun f : ℕ → S => ⋃ n, (f n).1 termination_by i => i decreasing_by exact j.2 #align measurable_space.generate_measurable_rec MeasurableSpace.generateMeasurableRec theorem self_subset_generateMeasurableRec (s : Set (Set α)) (i : ω₁) : s ⊆ generateMeasurableRec s i := by unfold generateMeasurableRec apply_rules [subset_union_of_subset_left] exact subset_rfl #align measurable_space.self_subset_generate_measurable_rec MeasurableSpace.self_subset_generateMeasurableRec theorem empty_mem_generateMeasurableRec (s : Set (Set α)) (i : ω₁) : ∅ ∈ generateMeasurableRec s i := by unfold generateMeasurableRec exact mem_union_left _ (mem_union_left _ (mem_union_right _ (mem_singleton ∅))) #align measurable_space.empty_mem_generate_measurable_rec MeasurableSpace.empty_mem_generateMeasurableRec
Mathlib/MeasureTheory/MeasurableSpace/Card.lean
68
71
theorem compl_mem_generateMeasurableRec {s : Set (Set α)} {i j : ω₁} (h : j < i) {t : Set α} (ht : t ∈ generateMeasurableRec s j) : tᶜ ∈ generateMeasurableRec s i := by
unfold generateMeasurableRec exact mem_union_left _ (mem_union_right _ ⟨t, mem_iUnion.2 ⟨⟨j, h⟩, ht⟩, rfl⟩)
/- Copyright (c) 2018 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.CategoryTheory.NatIso import Mathlib.Logic.Equiv.Defs #align_import category_theory.functor.fully_faithful from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" /-! # Full and faithful functors We define typeclasses `Full` and `Faithful`, decorating functors. These typeclasses carry no data. However, we also introduce a structure `Functor.FullyFaithful` which contains the data of the inverse map `(F.obj X ⟶ F.obj Y) ⟶ (X ⟶ Y)` of the map induced on morphisms by a functor `F`. ## Main definitions and results * Use `F.map_injective` to retrieve the fact that `F.map` is injective when `[Faithful F]`. * Similarly, `F.map_surjective` states that `F.map` is surjective when `[Full F]`. * Use `F.preimage` to obtain preimages of morphisms when `[Full F]`. * We prove some basic "cancellation" lemmas for full and/or faithful functors, as well as a construction for "dividing" a functor by a faithful functor, see `Faithful.div`. See `CategoryTheory.Equivalence.of_fullyFaithful_ess_surj` for the fact that a functor is an equivalence if and only if it is fully faithful and essentially surjective. -/ -- declare the `v`'s first; see `CategoryTheory.Category` for an explanation universe v₁ v₂ v₃ u₁ u₂ u₃ namespace CategoryTheory variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] namespace Functor /-- A functor `F : C ⥤ D` is full if for each `X Y : C`, `F.map` is surjective. See <https://stacks.math.columbia.edu/tag/001C>. -/ class Full (F : C ⥤ D) : Prop where map_surjective {X Y : C} : Function.Surjective (F.map (X := X) (Y := Y)) #align category_theory.full CategoryTheory.Functor.Full /-- A functor `F : C ⥤ D` is faithful if for each `X Y : C`, `F.map` is injective. See <https://stacks.math.columbia.edu/tag/001C>. -/ class Faithful (F : C ⥤ D) : Prop where /-- `F.map` is injective for each `X Y : C`. -/ map_injective : ∀ {X Y : C}, Function.Injective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) := by aesop_cat #align category_theory.faithful CategoryTheory.Functor.Faithful #align category_theory.faithful.map_injective CategoryTheory.Functor.Faithful.map_injective variable {X Y : C} theorem map_injective (F : C ⥤ D) [Faithful F] : Function.Injective <| (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) := Faithful.map_injective #align category_theory.functor.map_injective CategoryTheory.Functor.map_injective lemma map_injective_iff (F : C ⥤ D) [Faithful F] {X Y : C} (f g : X ⟶ Y) : F.map f = F.map g ↔ f = g := ⟨fun h => F.map_injective h, fun h => by rw [h]⟩ theorem mapIso_injective (F : C ⥤ D) [Faithful F] : Function.Injective <| (F.mapIso : (X ≅ Y) → (F.obj X ≅ F.obj Y)) := fun _ _ h => Iso.ext (map_injective F (congr_arg Iso.hom h : _)) #align category_theory.functor.map_iso_injective CategoryTheory.Functor.mapIso_injective theorem map_surjective (F : C ⥤ D) [Full F] : Function.Surjective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) := Full.map_surjective #align category_theory.functor.map_surjective CategoryTheory.Functor.map_surjective /-- The choice of a preimage of a morphism under a full functor. -/ noncomputable def preimage (F : C ⥤ D) [Full F] (f : F.obj X ⟶ F.obj Y) : X ⟶ Y := (F.map_surjective f).choose #align category_theory.functor.preimage CategoryTheory.Functor.preimage @[simp] theorem map_preimage (F : C ⥤ D) [Full F] {X Y : C} (f : F.obj X ⟶ F.obj Y) : F.map (preimage F f) = f := (F.map_surjective f).choose_spec #align category_theory.functor.image_preimage CategoryTheory.Functor.map_preimage variable {F : C ⥤ D} [Full F] [F.Faithful] {X Y Z : C} @[simp] theorem preimage_id : F.preimage (𝟙 (F.obj X)) = 𝟙 X := F.map_injective (by simp) #align category_theory.preimage_id CategoryTheory.Functor.preimage_id @[simp] theorem preimage_comp (f : F.obj X ⟶ F.obj Y) (g : F.obj Y ⟶ F.obj Z) : F.preimage (f ≫ g) = F.preimage f ≫ F.preimage g := F.map_injective (by simp) #align category_theory.preimage_comp CategoryTheory.Functor.preimage_comp @[simp] theorem preimage_map (f : X ⟶ Y) : F.preimage (F.map f) = f := F.map_injective (by simp) #align category_theory.preimage_map CategoryTheory.Functor.preimage_map variable (F) /-- If `F : C ⥤ D` is fully faithful, every isomorphism `F.obj X ≅ F.obj Y` has a preimage. -/ @[simps] noncomputable def preimageIso (f : F.obj X ≅ F.obj Y) : X ≅ Y where hom := F.preimage f.hom inv := F.preimage f.inv hom_inv_id := F.map_injective (by simp) inv_hom_id := F.map_injective (by simp) #align category_theory.functor.preimage_iso CategoryTheory.Functor.preimageIso #align category_theory.functor.preimage_iso_inv CategoryTheory.Functor.preimageIso_inv #align category_theory.functor.preimage_iso_hom CategoryTheory.Functor.preimageIso_hom @[simp]
Mathlib/CategoryTheory/Functor/FullyFaithful.lean
125
127
theorem preimageIso_mapIso (f : X ≅ Y) : F.preimageIso (F.mapIso f) = f := by
ext simp
/- 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.Data.Countable.Basic import Mathlib.Logic.Encodable.Basic import Mathlib.Order.SuccPred.Basic import Mathlib.Order.Interval.Finset.Defs #align_import order.succ_pred.linear_locally_finite from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9" /-! # Linear locally finite orders We prove that a `LinearOrder` which is a `LocallyFiniteOrder` also verifies * `SuccOrder` * `PredOrder` * `IsSuccArchimedean` * `IsPredArchimedean` * `Countable` Furthermore, we show that there is an `OrderIso` between such an order and a subset of `ℤ`. ## Main definitions * `toZ i0 i`: in a linear order on which we can define predecessors and successors and which is succ-archimedean, we can assign a unique integer `toZ i0 i` to each element `i : ι` while respecting the order, starting from `toZ i0 i0 = 0`. ## Main results Instances about linear locally finite orders: * `LinearLocallyFiniteOrder.SuccOrder`: a linear locally finite order has a successor function. * `LinearLocallyFiniteOrder.PredOrder`: a linear locally finite order has a predecessor function. * `LinearLocallyFiniteOrder.isSuccArchimedean`: a linear locally finite order is succ-archimedean. * `LinearOrder.pred_archimedean_of_succ_archimedean`: a succ-archimedean linear order is also pred-archimedean. * `countable_of_linear_succ_pred_arch` : a succ-archimedean linear order is countable. About `toZ`: * `orderIsoRangeToZOfLinearSuccPredArch`: `toZ` defines an `OrderIso` between `ι` and its range. * `orderIsoNatOfLinearSuccPredArch`: if the order has a bot but no top, `toZ` defines an `OrderIso` between `ι` and `ℕ`. * `orderIsoIntOfLinearSuccPredArch`: if the order has neither bot nor top, `toZ` defines an `OrderIso` between `ι` and `ℤ`. * `orderIsoRangeOfLinearSuccPredArch`: if the order has both a bot and a top, `toZ` gives an `OrderIso` between `ι` and `Finset.range ((toZ ⊥ ⊤).toNat + 1)`. -/ open Order variable {ι : Type*} [LinearOrder ι] namespace LinearLocallyFiniteOrder /-- Successor in a linear order. This defines a true successor only when `i` is isolated from above, i.e. when `i` is not the greatest lower bound of `(i, ∞)`. -/ noncomputable def succFn (i : ι) : ι := (exists_glb_Ioi i).choose #align linear_locally_finite_order.succ_fn LinearLocallyFiniteOrder.succFn theorem succFn_spec (i : ι) : IsGLB (Set.Ioi i) (succFn i) := (exists_glb_Ioi i).choose_spec #align linear_locally_finite_order.succ_fn_spec LinearLocallyFiniteOrder.succFn_spec theorem le_succFn (i : ι) : i ≤ succFn i := by rw [le_isGLB_iff (succFn_spec i), mem_lowerBounds] exact fun x hx ↦ le_of_lt hx #align linear_locally_finite_order.le_succ_fn LinearLocallyFiniteOrder.le_succFn theorem isGLB_Ioc_of_isGLB_Ioi {i j k : ι} (hij_lt : i < j) (h : IsGLB (Set.Ioi i) k) : IsGLB (Set.Ioc i j) k := by simp_rw [IsGLB, IsGreatest, mem_upperBounds, mem_lowerBounds] at h ⊢ refine ⟨fun x hx ↦ h.1 x hx.1, fun x hx ↦ h.2 x ?_⟩ intro y hy rcases le_or_lt y j with h_le | h_lt · exact hx y ⟨hy, h_le⟩ · exact le_trans (hx j ⟨hij_lt, le_rfl⟩) h_lt.le #align linear_locally_finite_order.is_glb_Ioc_of_is_glb_Ioi LinearLocallyFiniteOrder.isGLB_Ioc_of_isGLB_Ioi theorem isMax_of_succFn_le [LocallyFiniteOrder ι] (i : ι) (hi : succFn i ≤ i) : IsMax i := by refine fun j _ ↦ not_lt.mp fun hij_lt ↦ ?_ have h_succFn_eq : succFn i = i := le_antisymm hi (le_succFn i) have h_glb : IsGLB (Finset.Ioc i j : Set ι) i := by rw [Finset.coe_Ioc] have h := succFn_spec i rw [h_succFn_eq] at h exact isGLB_Ioc_of_isGLB_Ioi hij_lt h have hi_mem : i ∈ Finset.Ioc i j := by refine Finset.isGLB_mem _ h_glb ?_ exact ⟨_, Finset.mem_Ioc.mpr ⟨hij_lt, le_rfl⟩⟩ rw [Finset.mem_Ioc] at hi_mem exact lt_irrefl i hi_mem.1 #align linear_locally_finite_order.is_max_of_succ_fn_le LinearLocallyFiniteOrder.isMax_of_succFn_le theorem succFn_le_of_lt (i j : ι) (hij : i < j) : succFn i ≤ j := by have h := succFn_spec i rw [IsGLB, IsGreatest, mem_lowerBounds] at h exact h.1 j hij #align linear_locally_finite_order.succ_fn_le_of_lt LinearLocallyFiniteOrder.succFn_le_of_lt
Mathlib/Order/SuccPred/LinearLocallyFinite.lean
108
112
theorem le_of_lt_succFn (j i : ι) (hij : j < succFn i) : j ≤ i := by
rw [lt_isGLB_iff (succFn_spec i)] at hij obtain ⟨k, hk_lb, hk⟩ := hij rw [mem_lowerBounds] at hk_lb exact not_lt.mp fun hi_lt_j ↦ not_le.mpr hk (hk_lb j hi_lt_j)
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa, Alex Meiburg -/ import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Polynomial.Degree.Lemmas #align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448" /-! # Erase the leading term of a univariate polynomial ## Definition * `eraseLead f`: the polynomial `f - leading term of f` `eraseLead` serves as reduction step in an induction, shaving off one monomial from a polynomial. The definition is set up so that it does not mention subtraction in the definition, and thus works for polynomials over semirings as well as rings. -/ noncomputable section open Polynomial open Polynomial Finset namespace Polynomial variable {R : Type*} [Semiring R] {f : R[X]} /-- `eraseLead f` for a polynomial `f` is the polynomial obtained by subtracting from `f` the leading term of `f`. -/ def eraseLead (f : R[X]) : R[X] := Polynomial.erase f.natDegree f #align polynomial.erase_lead Polynomial.eraseLead section EraseLead theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by simp only [eraseLead, support_erase] #align polynomial.erase_lead_support Polynomial.eraseLead_support theorem eraseLead_coeff (i : ℕ) : f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by simp only [eraseLead, coeff_erase] #align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff @[simp] theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by simp [eraseLead_coeff] #align polynomial.erase_lead_coeff_nat_degree Polynomial.eraseLead_coeff_natDegree theorem eraseLead_coeff_of_ne (i : ℕ) (hi : i ≠ f.natDegree) : f.eraseLead.coeff i = f.coeff i := by simp [eraseLead_coeff, hi] #align polynomial.erase_lead_coeff_of_ne Polynomial.eraseLead_coeff_of_ne @[simp] theorem eraseLead_zero : eraseLead (0 : R[X]) = 0 := by simp only [eraseLead, erase_zero] #align polynomial.erase_lead_zero Polynomial.eraseLead_zero @[simp] theorem eraseLead_add_monomial_natDegree_leadingCoeff (f : R[X]) : f.eraseLead + monomial f.natDegree f.leadingCoeff = f := (add_comm _ _).trans (f.monomial_add_erase _) #align polynomial.erase_lead_add_monomial_nat_degree_leading_coeff Polynomial.eraseLead_add_monomial_natDegree_leadingCoeff @[simp] theorem eraseLead_add_C_mul_X_pow (f : R[X]) : f.eraseLead + C f.leadingCoeff * X ^ f.natDegree = f := by rw [C_mul_X_pow_eq_monomial, eraseLead_add_monomial_natDegree_leadingCoeff] set_option linter.uppercaseLean3 false in #align polynomial.erase_lead_add_C_mul_X_pow Polynomial.eraseLead_add_C_mul_X_pow @[simp] theorem self_sub_monomial_natDegree_leadingCoeff {R : Type*} [Ring R] (f : R[X]) : f - monomial f.natDegree f.leadingCoeff = f.eraseLead := (eq_sub_iff_add_eq.mpr (eraseLead_add_monomial_natDegree_leadingCoeff f)).symm #align polynomial.self_sub_monomial_nat_degree_leading_coeff Polynomial.self_sub_monomial_natDegree_leadingCoeff @[simp] theorem self_sub_C_mul_X_pow {R : Type*} [Ring R] (f : R[X]) : f - C f.leadingCoeff * X ^ f.natDegree = f.eraseLead := by rw [C_mul_X_pow_eq_monomial, self_sub_monomial_natDegree_leadingCoeff] set_option linter.uppercaseLean3 false in #align polynomial.self_sub_C_mul_X_pow Polynomial.self_sub_C_mul_X_pow theorem eraseLead_ne_zero (f0 : 2 ≤ f.support.card) : eraseLead f ≠ 0 := by rw [Ne, ← card_support_eq_zero, eraseLead_support] exact (zero_lt_one.trans_le <| (tsub_le_tsub_right f0 1).trans Finset.pred_card_le_card_erase).ne.symm #align polynomial.erase_lead_ne_zero Polynomial.eraseLead_ne_zero theorem lt_natDegree_of_mem_eraseLead_support {a : ℕ} (h : a ∈ (eraseLead f).support) : a < f.natDegree := by rw [eraseLead_support, mem_erase] at h exact (le_natDegree_of_mem_supp a h.2).lt_of_ne h.1 #align polynomial.lt_nat_degree_of_mem_erase_lead_support Polynomial.lt_natDegree_of_mem_eraseLead_support theorem ne_natDegree_of_mem_eraseLead_support {a : ℕ} (h : a ∈ (eraseLead f).support) : a ≠ f.natDegree := (lt_natDegree_of_mem_eraseLead_support h).ne #align polynomial.ne_nat_degree_of_mem_erase_lead_support Polynomial.ne_natDegree_of_mem_eraseLead_support theorem natDegree_not_mem_eraseLead_support : f.natDegree ∉ (eraseLead f).support := fun h => ne_natDegree_of_mem_eraseLead_support h rfl #align polynomial.nat_degree_not_mem_erase_lead_support Polynomial.natDegree_not_mem_eraseLead_support theorem eraseLead_support_card_lt (h : f ≠ 0) : (eraseLead f).support.card < f.support.card := by rw [eraseLead_support] exact card_lt_card (erase_ssubset <| natDegree_mem_support_of_nonzero h) #align polynomial.erase_lead_support_card_lt Polynomial.eraseLead_support_card_lt
Mathlib/Algebra/Polynomial/EraseLead.lean
115
124
theorem card_support_eraseLead_add_one (h : f ≠ 0) : f.eraseLead.support.card + 1 = f.support.card := by
set c := f.support.card with hc cases h₁ : c case zero => by_contra exact h (card_support_eq_zero.mp h₁) case succ => rw [eraseLead_support, card_erase_of_mem (natDegree_mem_support_of_nonzero h), ← hc, h₁] rfl
/- Copyright (c) 2018 Louis Carlin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Louis Carlin, Mario Carneiro -/ import Mathlib.Algebra.EuclideanDomain.Defs import Mathlib.Algebra.Ring.Divisibility.Basic import Mathlib.Algebra.Ring.Regular import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Ring.Basic #align_import algebra.euclidean_domain.basic from "leanprover-community/mathlib"@"bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6" /-! # Lemmas about Euclidean domains ## Main statements * `gcd_eq_gcd_ab`: states Bézout's lemma for Euclidean domains. -/ universe u namespace EuclideanDomain variable {R : Type u} variable [EuclideanDomain R] /-- The well founded relation in a Euclidean Domain satisfying `a % b ≺ b` for `b ≠ 0` -/ local infixl:50 " ≺ " => EuclideanDomain.R -- See note [lower instance priority] instance (priority := 100) toMulDivCancelClass : MulDivCancelClass R where mul_div_cancel a b hb := by refine (eq_of_sub_eq_zero ?_).symm by_contra h have := mul_right_not_lt b h rw [sub_mul, mul_comm (_ / _), sub_eq_iff_eq_add'.2 (div_add_mod (a * b) b).symm] at this exact this (mod_lt _ hb) #align euclidean_domain.mul_div_cancel_left mul_div_cancel_left₀ #align euclidean_domain.mul_div_cancel mul_div_cancel_right₀ @[simp] theorem mod_eq_zero {a b : R} : a % b = 0 ↔ b ∣ a := ⟨fun h => by rw [← div_add_mod a b, h, add_zero] exact dvd_mul_right _ _, fun ⟨c, e⟩ => by rw [e, ← add_left_cancel_iff, div_add_mod, add_zero] haveI := Classical.dec by_cases b0 : b = 0 · simp only [b0, zero_mul] · rw [mul_div_cancel_left₀ _ b0]⟩ #align euclidean_domain.mod_eq_zero EuclideanDomain.mod_eq_zero @[simp] theorem mod_self (a : R) : a % a = 0 := mod_eq_zero.2 dvd_rfl #align euclidean_domain.mod_self EuclideanDomain.mod_self
Mathlib/Algebra/EuclideanDomain/Basic.lean
63
64
theorem dvd_mod_iff {a b c : R} (h : c ∣ b) : c ∣ a % b ↔ c ∣ a := by
rw [← dvd_add_right (h.mul_right _), div_add_mod]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Shing Tak Lam, Mario Carneiro -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Int.ModEq import Mathlib.Data.Nat.Bits import Mathlib.Data.Nat.Log import Mathlib.Data.List.Indexes import Mathlib.Data.List.Palindrome import Mathlib.Tactic.IntervalCases import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring #align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768" /-! # Digits of a natural number This provides a basic API for extracting the digits of a natural number in a given base, and reconstructing numbers from their digits. We also prove some divisibility tests based on digits, in particular completing Theorem #85 from https://www.cs.ru.nl/~freek/100/. Also included is a bound on the length of `Nat.toDigits` from core. ## TODO A basic `norm_digits` tactic for proving goals of the form `Nat.digits a b = l` where `a` and `b` are numerals is not yet ported. -/ namespace Nat variable {n : ℕ} /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux0 : ℕ → List ℕ | 0 => [] | n + 1 => [n + 1] #align nat.digits_aux_0 Nat.digitsAux0 /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux1 (n : ℕ) : List ℕ := List.replicate n 1 #align nat.digits_aux_1 Nat.digitsAux1 /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ | 0 => [] | n + 1 => ((n + 1) % b) :: digitsAux b h ((n + 1) / b) decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h #align nat.digits_aux Nat.digitsAux @[simp]
Mathlib/Data/Nat/Digits.lean
60
60
theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by
rw [digitsAux]
/- Copyright (c) 2024 Paul Reichert. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Paul Reichert -/ import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.IsConnected import Mathlib.CategoryTheory.Limits.Final import Mathlib.CategoryTheory.Conj /-! # Colimits of connected index categories This file proves two characterizations of connected categories by means of colimits. ## Characterization of connected categories by means of the unit-valued functor First, it is proved that a category `C` is connected if and only if `colim F` is a singleton, where `F : C ⥤ Type w` and `F.obj _ = PUnit` (for arbitrary `w`). See `isConnected_iff_colimit_constPUnitFunctor_iso_pUnit` for the proof of this characterization and `constPUnitFunctor` for the definition of the constant functor used in the statement. A formulation based on `IsColimit` instead of `colimit` is given in `isConnected_iff_isColimit_pUnitCocone`. The `if` direction is also available directly in several formulations: For connected index categories `C`, `PUnit.{w}` is a colimit of the `constPUnitFunctor`, where `w` is arbitrary. See `instHasColimitConstPUnitFunctor`, `isColimitPUnitCocone` and `colimitConstPUnitIsoPUnit`. ## Final functors preserve connectedness of categories (in both directions) `isConnected_iff_of_final` proves that the domain of a final functor is connected if and only if its codomain is connected. ## Tags unit-valued, singleton, colimit -/ universe w v u namespace CategoryTheory.Limits.Types variable (C : Type u) [Category.{v} C] /-- The functor mapping every object to `PUnit`. -/ def constPUnitFunctor : C ⥤ Type w := (Functor.const C).obj PUnit.{w + 1} /-- The cocone on `constPUnitFunctor` with cone point `PUnit`. -/ @[simps] def pUnitCocone : Cocone (constPUnitFunctor.{w} C) where pt := PUnit ι := { app := fun X => id } /-- If `C` is connected, the cocone on `constPUnitFunctor` with cone point `PUnit` is a colimit cocone. -/ noncomputable def isColimitPUnitCocone [IsConnected C] : IsColimit (pUnitCocone.{w} C) where desc s := s.ι.app Classical.ofNonempty fac s j := by ext ⟨⟩ apply constant_of_preserves_morphisms (s.ι.app · PUnit.unit) intros X Y f exact congrFun (s.ι.naturality f).symm PUnit.unit uniq s m h := by ext ⟨⟩ simp [← h Classical.ofNonempty] instance instHasColimitConstPUnitFunctor [IsConnected C] : HasColimit (constPUnitFunctor.{w} C) := ⟨_, isColimitPUnitCocone _⟩ instance instSubsingletonColimitPUnit [IsPreconnected C] [HasColimit (constPUnitFunctor.{w} C)] : Subsingleton (colimit (constPUnitFunctor.{w} C)) where allEq a b := by obtain ⟨c, ⟨⟩, rfl⟩ := jointly_surjective' a obtain ⟨d, ⟨⟩, rfl⟩ := jointly_surjective' b apply constant_of_preserves_morphisms (colimit.ι (constPUnitFunctor C) · PUnit.unit) exact fun c d f => colimit_sound f rfl /-- Given a connected index category, the colimit of the constant unit-valued functor is `PUnit`. -/ noncomputable def colimitConstPUnitIsoPUnit [IsConnected C] : colimit (constPUnitFunctor.{w} C) ≅ PUnit.{w + 1} := IsColimit.coconePointUniqueUpToIso (colimit.isColimit _) (isColimitPUnitCocone.{w} C) /-- Let `F` be a `Type`-valued functor. If two elements `a : F c` and `b : F d` represent the same element of `colimit F`, then `c` and `d` are related by a `Zigzag`. -/ theorem zigzag_of_eqvGen_quot_rel (F : C ⥤ Type w) (c d : Σ j, F.obj j) (h : EqvGen (Quot.Rel F) c d) : Zigzag c.1 d.1 := by induction h with | rel _ _ h => exact Zigzag.of_hom <| Exists.choose h | refl _ => exact Zigzag.refl _ | symm _ _ _ ih => exact zigzag_symmetric ih | trans _ _ _ _ _ ih₁ ih₂ => exact ih₁.trans ih₂ /-- An index category is connected iff the colimit of the constant singleton-valued functor is a singleton. -/ theorem isConnected_iff_colimit_constPUnitFunctor_iso_pUnit [HasColimit (constPUnitFunctor.{w} C)] : IsConnected C ↔ Nonempty (colimit (constPUnitFunctor.{w} C) ≅ PUnit) := by refine ⟨fun _ => ⟨colimitConstPUnitIsoPUnit.{w} C⟩, fun ⟨h⟩ => ?_⟩ have : Nonempty C := nonempty_of_nonempty_colimit <| Nonempty.map h.inv inferInstance refine zigzag_isConnected <| fun c d => ?_ refine zigzag_of_eqvGen_quot_rel _ (constPUnitFunctor C) ⟨c, PUnit.unit⟩ ⟨d, PUnit.unit⟩ ?_ exact colimit_eq <| h.toEquiv.injective rfl
Mathlib/CategoryTheory/Limits/IsConnected.lean
106
112
theorem isConnected_iff_isColimit_pUnitCocone : IsConnected C ↔ Nonempty (IsColimit (pUnitCocone.{w} C)) := by
refine ⟨fun inst => ⟨isColimitPUnitCocone C⟩, fun ⟨h⟩ => ?_⟩ let colimitCocone : ColimitCocone (constPUnitFunctor C) := ⟨pUnitCocone.{w} C, h⟩ have : HasColimit (constPUnitFunctor.{w} C) := ⟨⟨colimitCocone⟩⟩ simp only [isConnected_iff_colimit_constPUnitFunctor_iso_pUnit.{w} C] exact ⟨colimit.isoColimitCocone colimitCocone⟩
/- 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. -/ 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' _ _ #align gauge_def' gauge_def' private theorem gauge_set_bddBelow : BddBelow { r : ℝ | 0 < r ∧ x ∈ r • s } := ⟨0, fun _ hr => hr.1.le⟩ /-- If the given subset is `Absorbent` then the set we take an infimum over in `gauge` is nonempty, which is useful for proving many properties about the gauge. -/ theorem Absorbent.gauge_set_nonempty (absorbs : Absorbent ℝ s) : { r : ℝ | 0 < r ∧ x ∈ r • s }.Nonempty := let ⟨r, hr₁, hr₂⟩ := (absorbs x).exists_pos ⟨r, hr₁, hr₂ r (Real.norm_of_nonneg hr₁.le).ge rfl⟩ #align absorbent.gauge_set_nonempty Absorbent.gauge_set_nonempty theorem gauge_mono (hs : Absorbent ℝ s) (h : s ⊆ t) : gauge t ≤ gauge s := fun _ => csInf_le_csInf gauge_set_bddBelow hs.gauge_set_nonempty fun _ hr => ⟨hr.1, smul_set_mono h hr.2⟩ #align gauge_mono gauge_mono theorem exists_lt_of_gauge_lt (absorbs : Absorbent ℝ s) (h : gauge s x < a) : ∃ b, 0 < b ∧ b < a ∧ x ∈ b • s := by obtain ⟨b, ⟨hb, hx⟩, hba⟩ := exists_lt_of_csInf_lt absorbs.gauge_set_nonempty h exact ⟨b, hb, hba, hx⟩ #align exists_lt_of_gauge_lt exists_lt_of_gauge_lt /-- The gauge evaluated at `0` is always zero (mathematically this requires `0` to be in the set `s` but, the real infimum of the empty set in Lean being defined as `0`, it holds unconditionally). -/ @[simp] theorem gauge_zero : gauge s 0 = 0 := by rw [gauge_def'] by_cases h : (0 : E) ∈ s · simp only [smul_zero, sep_true, h, csInf_Ioi] · simp only [smul_zero, sep_false, h, Real.sInf_empty] #align gauge_zero gauge_zero @[simp] theorem gauge_zero' : gauge (0 : Set E) = 0 := by ext x rw [gauge_def'] obtain rfl | hx := eq_or_ne x 0 · simp only [csInf_Ioi, mem_zero, Pi.zero_apply, eq_self_iff_true, sep_true, smul_zero] · simp only [mem_zero, Pi.zero_apply, inv_eq_zero, smul_eq_zero] convert Real.sInf_empty exact eq_empty_iff_forall_not_mem.2 fun r hr => hr.2.elim (ne_of_gt hr.1) hx #align gauge_zero' gauge_zero' @[simp] theorem gauge_empty : gauge (∅ : Set E) = 0 := by ext simp only [gauge_def', Real.sInf_empty, mem_empty_iff_false, Pi.zero_apply, sep_false] #align gauge_empty gauge_empty theorem gauge_of_subset_zero (h : s ⊆ 0) : gauge s = 0 := by obtain rfl | rfl := subset_singleton_iff_eq.1 h exacts [gauge_empty, gauge_zero'] #align gauge_of_subset_zero gauge_of_subset_zero /-- The gauge is always nonnegative. -/ theorem gauge_nonneg (x : E) : 0 ≤ gauge s x := Real.sInf_nonneg _ fun _ hx => hx.1.le #align gauge_nonneg gauge_nonneg theorem gauge_neg (symmetric : ∀ x ∈ s, -x ∈ s) (x : E) : gauge s (-x) = gauge s x := by have : ∀ x, -x ∈ s ↔ x ∈ s := fun x => ⟨fun h => by simpa using symmetric _ h, symmetric x⟩ simp_rw [gauge_def', smul_neg, this] #align gauge_neg gauge_neg
Mathlib/Analysis/Convex/Gauge.lean
134
135
theorem gauge_neg_set_neg (x : E) : gauge (-s) (-x) = gauge s x := by
simp_rw [gauge_def', smul_neg, neg_mem_neg]
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Polynomial.Degree.TrailingDegree import Mathlib.Algebra.Polynomial.EraseLead import Mathlib.Algebra.Polynomial.Eval #align_import data.polynomial.reverse from "leanprover-community/mathlib"@"44de64f183393284a16016dfb2a48ac97382f2bd" /-! # Reverse of a univariate polynomial The main definition is `reverse`. Applying `reverse` to a polynomial `f : R[X]` produces the polynomial with a reversed list of coefficients, equivalent to `X^f.natDegree * f(1/X)`. The main result is that `reverse (f * g) = reverse f * reverse g`, provided the leading coefficients of `f` and `g` do not multiply to zero. -/ namespace Polynomial open Polynomial Finsupp Finset open Polynomial section Semiring variable {R : Type*} [Semiring R] {f : R[X]} /-- If `i ≤ N`, then `revAtFun N i` returns `N - i`, otherwise it returns `i`. This is the map used by the embedding `revAt`. -/ def revAtFun (N i : ℕ) : ℕ := ite (i ≤ N) (N - i) i #align polynomial.rev_at_fun Polynomial.revAtFun theorem revAtFun_invol {N i : ℕ} : revAtFun N (revAtFun N i) = i := by unfold revAtFun split_ifs with h j · exact tsub_tsub_cancel_of_le h · exfalso apply j exact Nat.sub_le N i · rfl #align polynomial.rev_at_fun_invol Polynomial.revAtFun_invol theorem revAtFun_inj {N : ℕ} : Function.Injective (revAtFun N) := by intro a b hab rw [← @revAtFun_invol N a, hab, revAtFun_invol] #align polynomial.rev_at_fun_inj Polynomial.revAtFun_inj /-- If `i ≤ N`, then `revAt N i` returns `N - i`, otherwise it returns `i`. Essentially, this embedding is only used for `i ≤ N`. The advantage of `revAt N i` over `N - i` is that `revAt` is an involution. -/ def revAt (N : ℕ) : Function.Embedding ℕ ℕ where toFun i := ite (i ≤ N) (N - i) i inj' := revAtFun_inj #align polynomial.rev_at Polynomial.revAt /-- We prefer to use the bundled `revAt` over unbundled `revAtFun`. -/ @[simp] theorem revAtFun_eq (N i : ℕ) : revAtFun N i = revAt N i := rfl #align polynomial.rev_at_fun_eq Polynomial.revAtFun_eq @[simp] theorem revAt_invol {N i : ℕ} : (revAt N) (revAt N i) = i := revAtFun_invol #align polynomial.rev_at_invol Polynomial.revAt_invol @[simp] theorem revAt_le {N i : ℕ} (H : i ≤ N) : revAt N i = N - i := if_pos H #align polynomial.rev_at_le Polynomial.revAt_le lemma revAt_eq_self_of_lt {N i : ℕ} (h : N < i) : revAt N i = i := by simp [revAt, Nat.not_le.mpr h] theorem revAt_add {N O n o : ℕ} (hn : n ≤ N) (ho : o ≤ O) : revAt (N + O) (n + o) = revAt N n + revAt O o := by rcases Nat.le.dest hn with ⟨n', rfl⟩ rcases Nat.le.dest ho with ⟨o', rfl⟩ repeat' rw [revAt_le (le_add_right rfl.le)] rw [add_assoc, add_left_comm n' o, ← add_assoc, revAt_le (le_add_right rfl.le)] repeat' rw [add_tsub_cancel_left] #align polynomial.rev_at_add Polynomial.revAt_add -- @[simp] -- Porting note (#10618): simp can prove this theorem revAt_zero (N : ℕ) : revAt N 0 = N := by simp #align polynomial.rev_at_zero Polynomial.revAt_zero /-- `reflect N f` is the polynomial such that `(reflect N f).coeff i = f.coeff (revAt N i)`. In other words, the terms with exponent `[0, ..., N]` now have exponent `[N, ..., 0]`. In practice, `reflect` is only used when `N` is at least as large as the degree of `f`. Eventually, it will be used with `N` exactly equal to the degree of `f`. -/ noncomputable def reflect (N : ℕ) : R[X] → R[X] | ⟨f⟩ => ⟨Finsupp.embDomain (revAt N) f⟩ #align polynomial.reflect Polynomial.reflect
Mathlib/Algebra/Polynomial/Reverse.lean
105
109
theorem reflect_support (N : ℕ) (f : R[X]) : (reflect N f).support = Finset.image (revAt N) f.support := by
rcases f with ⟨⟩ ext1 simp only [reflect, support_ofFinsupp, support_embDomain, Finset.mem_map, Finset.mem_image]
/- Copyright (c) 2020 Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard -/ import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.RingTheory.Ideal.LocalRing import Mathlib.RingTheory.Valuation.PrimeMultiplicity import Mathlib.RingTheory.AdicCompletion.Basic #align_import ring_theory.discrete_valuation_ring.basic from "leanprover-community/mathlib"@"c163ec99dfc664628ca15d215fce0a5b9c265b68" /-! # Discrete valuation rings This file defines discrete valuation rings (DVRs) and develops a basic interface for them. ## Important definitions There are various definitions of a DVR in the literature; we define a DVR to be a local PID which is not a field (the first definition in Wikipedia) and prove that this is equivalent to being a PID with a unique non-zero prime ideal (the definition in Serre's book "Local Fields"). Let R be an integral domain, assumed to be a principal ideal ring and a local ring. * `DiscreteValuationRing R` : a predicate expressing that R is a DVR. ### Definitions * `addVal R : AddValuation R PartENat` : the additive valuation on a DVR. ## Implementation notes It's a theorem that an element of a DVR is a uniformizer if and only if it's irreducible. We do not hence define `Uniformizer` at all, because we can use `Irreducible` instead. ## Tags discrete valuation ring -/ open scoped Classical universe u open Ideal LocalRing /-- An integral domain is a *discrete valuation ring* (DVR) if it's a local PID which is not a field. -/ class DiscreteValuationRing (R : Type u) [CommRing R] [IsDomain R] extends IsPrincipalIdealRing R, LocalRing R : Prop where not_a_field' : maximalIdeal R ≠ ⊥ #align discrete_valuation_ring DiscreteValuationRing namespace DiscreteValuationRing variable (R : Type u) [CommRing R] [IsDomain R] [DiscreteValuationRing R] theorem not_a_field : maximalIdeal R ≠ ⊥ := not_a_field' #align discrete_valuation_ring.not_a_field DiscreteValuationRing.not_a_field /-- A discrete valuation ring `R` is not a field. -/ theorem not_isField : ¬IsField R := LocalRing.isField_iff_maximalIdeal_eq.not.mpr (not_a_field R) #align discrete_valuation_ring.not_is_field DiscreteValuationRing.not_isField variable {R} open PrincipalIdealRing theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R] (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ refine ⟨h2, ?_⟩ intro a b hab by_contra! h obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h rw [h, mem_span_singleton'] at ha hb rcases ha with ⟨a, rfl⟩ rcases hb with ⟨b, rfl⟩ rw [show a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b)) by ring] at hab apply hϖ apply eq_zero_of_mul_eq_self_right _ hab.symm exact fun hh => h2 (isUnit_of_dvd_one ⟨_, hh.symm⟩) #align discrete_valuation_ring.irreducible_of_span_eq_maximal_ideal DiscreteValuationRing.irreducible_of_span_eq_maximalIdeal /-- An element of a DVR is irreducible iff it is a uniformizer, that is, generates the maximal ideal of `R`. -/ theorem irreducible_iff_uniformizer (ϖ : R) : Irreducible ϖ ↔ maximalIdeal R = Ideal.span {ϖ} := ⟨fun hϖ => (eq_maximalIdeal (isMaximal_of_irreducible hϖ)).symm, fun h => irreducible_of_span_eq_maximalIdeal ϖ (fun e => not_a_field R <| by rwa [h, span_singleton_eq_bot]) h⟩ #align discrete_valuation_ring.irreducible_iff_uniformizer DiscreteValuationRing.irreducible_iff_uniformizer theorem _root_.Irreducible.maximalIdeal_eq {ϖ : R} (h : Irreducible ϖ) : maximalIdeal R = Ideal.span {ϖ} := (irreducible_iff_uniformizer _).mp h #align irreducible.maximal_ideal_eq Irreducible.maximalIdeal_eq variable (R) /-- Uniformizers exist in a DVR. -/
Mathlib/RingTheory/DiscreteValuationRing/Basic.lean
107
109
theorem exists_irreducible : ∃ ϖ : R, Irreducible ϖ := by
simp_rw [irreducible_iff_uniformizer] exact (IsPrincipalIdealRing.principal <| maximalIdeal R).principal
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen -/ import Mathlib.Data.Matrix.Block import Mathlib.Data.Matrix.Notation import Mathlib.LinearAlgebra.StdBasis import Mathlib.RingTheory.AlgebraTower import Mathlib.Algebra.Algebra.Subalgebra.Tower #align_import linear_algebra.matrix.to_lin from "leanprover-community/mathlib"@"0e2aab2b0d521f060f62a14d2cf2e2c54e8491d6" /-! # Linear maps and matrices This file defines the maps to send matrices to a linear map, and to send linear maps between modules with a finite bases to matrices. This defines a linear equivalence between linear maps between finite-dimensional vector spaces and matrices indexed by the respective bases. ## Main definitions In the list below, and in all this file, `R` is a commutative ring (semiring is sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite types used for indexing. * `LinearMap.toMatrix`: given bases `v₁ : ι → M₁` and `v₂ : κ → M₂`, the `R`-linear equivalence from `M₁ →ₗ[R] M₂` to `Matrix κ ι R` * `Matrix.toLin`: the inverse of `LinearMap.toMatrix` * `LinearMap.toMatrix'`: the `R`-linear equivalence from `(m → R) →ₗ[R] (n → R)` to `Matrix m n R` (with the standard basis on `m → R` and `n → R`) * `Matrix.toLin'`: the inverse of `LinearMap.toMatrix'` * `algEquivMatrix`: given a basis indexed by `n`, the `R`-algebra equivalence between `R`-endomorphisms of `M` and `Matrix n n R` ## Issues This file was originally written without attention to non-commutative rings, and so mostly only works in the commutative setting. This should be fixed. In particular, `Matrix.mulVec` gives us a linear equivalence `Matrix m n R ≃ₗ[R] (n → R) →ₗ[Rᵐᵒᵖ] (m → R)` while `Matrix.vecMul` gives us a linear equivalence `Matrix m n R ≃ₗ[Rᵐᵒᵖ] (m → R) →ₗ[R] (n → R)`. At present, the first equivalence is developed in detail but only for commutative rings (and we omit the distinction between `Rᵐᵒᵖ` and `R`), while the second equivalence is developed only in brief, but for not-necessarily-commutative rings. Naming is slightly inconsistent between the two developments. In the original (commutative) development `linear` is abbreviated to `lin`, although this is not consistent with the rest of mathlib. In the new (non-commutative) development `linear` is not abbreviated, and declarations use `_right` to indicate they use the right action of matrices on vectors (via `Matrix.vecMul`). When the two developments are made uniform, the names should be made uniform, too, by choosing between `linear` and `lin` consistently, and (presumably) adding `_left` where necessary. ## Tags linear_map, matrix, linear_equiv, diagonal, det, trace -/ noncomputable section open LinearMap Matrix Set Submodule section ToMatrixRight variable {R : Type*} [Semiring R] variable {l m n : Type*} /-- `Matrix.vecMul M` is a linear map. -/ def Matrix.vecMulLinear [Fintype m] (M : Matrix m n R) : (m → R) →ₗ[R] n → R where toFun x := x ᵥ* M map_add' _ _ := funext fun _ ↦ add_dotProduct _ _ _ map_smul' _ _ := funext fun _ ↦ smul_dotProduct _ _ _ #align matrix.vec_mul_linear Matrix.vecMulLinear @[simp] theorem Matrix.vecMulLinear_apply [Fintype m] (M : Matrix m n R) (x : m → R) : M.vecMulLinear x = x ᵥ* M := rfl theorem Matrix.coe_vecMulLinear [Fintype m] (M : Matrix m n R) : (M.vecMulLinear : _ → _) = M.vecMul := rfl variable [Fintype m] [DecidableEq m] @[simp]
Mathlib/LinearAlgebra/Matrix/ToLin.lean
91
99
theorem Matrix.vecMul_stdBasis (M : Matrix m n R) (i j) : (LinearMap.stdBasis R (fun _ ↦ R) i 1 ᵥ* M) j = M i j := by
have : (∑ i', (if i = i' then 1 else 0) * M i' j) = M i j := by simp_rw [boole_mul, Finset.sum_ite_eq, Finset.mem_univ, if_true] simp only [vecMul, dotProduct] convert this split_ifs with h <;> simp only [stdBasis_apply] · rw [h, Function.update_same] · rw [Function.update_noteq (Ne.symm h), Pi.zero_apply]
/- Copyright (c) 2018 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.Module.Pi #align_import data.holor from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" /-! # Basic properties of holors Holors are indexed collections of tensor coefficients. Confusingly, they are often called tensors in physics and in the neural network community. A holor is simply a multidimensional array of values. The size of a holor is specified by a `List ℕ`, whose length is called the dimension of the holor. The tensor product of `x₁ : Holor α ds₁` and `x₂ : Holor α ds₂` is the holor given by `(x₁ ⊗ x₂) (i₁ ++ i₂) = x₁ i₁ * x₂ i₂`. A holor is "of rank at most 1" if it is a tensor product of one-dimensional holors. The CP rank of a holor `x` is the smallest N such that `x` is the sum of N holors of rank at most 1. Based on the tensor library found in <https://www.isa-afp.org/entries/Deep_Learning.html> ## References * <https://en.wikipedia.org/wiki/Tensor_rank_decomposition> -/ universe u open List /-- `HolorIndex ds` is the type of valid index tuples used to identify an entry of a holor of dimensions `ds`. -/ def HolorIndex (ds : List ℕ) : Type := { is : List ℕ // Forall₂ (· < ·) is ds } #align holor_index HolorIndex namespace HolorIndex variable {ds₁ ds₂ ds₃ : List ℕ} def take : ∀ {ds₁ : List ℕ}, HolorIndex (ds₁ ++ ds₂) → HolorIndex ds₁ | ds, is => ⟨List.take (length ds) is.1, forall₂_take_append is.1 ds ds₂ is.2⟩ #align holor_index.take HolorIndex.take def drop : ∀ {ds₁ : List ℕ}, HolorIndex (ds₁ ++ ds₂) → HolorIndex ds₂ | ds, is => ⟨List.drop (length ds) is.1, forall₂_drop_append is.1 ds ds₂ is.2⟩ #align holor_index.drop HolorIndex.drop
Mathlib/Data/Holor.lean
58
59
theorem cast_type (is : List ℕ) (eq : ds₁ = ds₂) (h : Forall₂ (· < ·) is ds₁) : (cast (congr_arg HolorIndex eq) ⟨is, h⟩).val = is := by
subst eq; rfl
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa, Alex Meiburg -/ import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Polynomial.Degree.Lemmas #align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448" /-! # Erase the leading term of a univariate polynomial ## Definition * `eraseLead f`: the polynomial `f - leading term of f` `eraseLead` serves as reduction step in an induction, shaving off one monomial from a polynomial. The definition is set up so that it does not mention subtraction in the definition, and thus works for polynomials over semirings as well as rings. -/ noncomputable section open Polynomial open Polynomial Finset namespace Polynomial variable {R : Type*} [Semiring R] {f : R[X]} /-- `eraseLead f` for a polynomial `f` is the polynomial obtained by subtracting from `f` the leading term of `f`. -/ def eraseLead (f : R[X]) : R[X] := Polynomial.erase f.natDegree f #align polynomial.erase_lead Polynomial.eraseLead section EraseLead theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by simp only [eraseLead, support_erase] #align polynomial.erase_lead_support Polynomial.eraseLead_support theorem eraseLead_coeff (i : ℕ) : f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by simp only [eraseLead, coeff_erase] #align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff @[simp] theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by simp [eraseLead_coeff] #align polynomial.erase_lead_coeff_nat_degree Polynomial.eraseLead_coeff_natDegree theorem eraseLead_coeff_of_ne (i : ℕ) (hi : i ≠ f.natDegree) : f.eraseLead.coeff i = f.coeff i := by simp [eraseLead_coeff, hi] #align polynomial.erase_lead_coeff_of_ne Polynomial.eraseLead_coeff_of_ne @[simp]
Mathlib/Algebra/Polynomial/EraseLead.lean
60
60
theorem eraseLead_zero : eraseLead (0 : R[X]) = 0 := by
simp only [eraseLead, erase_zero]
/- Copyright (c) 2022 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" /-! # Dropping or taking from lists on the right Taking or removing element from the tail end of a list ## Main definitions - `rdrop n`: drop `n : ℕ` elements from the tail - `rtake n`: take `n : ℕ` elements from the tail - `rdropWhile p`: remove all the elements from the tail of a list until it finds the first element for which `p : α → Bool` returns false. This element and everything before is returned. - `rtakeWhile p`: Returns the longest terminal segment of a list for which `p : α → Bool` returns true. ## Implementation detail The two predicate-based methods operate by performing the regular "from-left" operation on `List.reverse`, followed by another `List.reverse`, so they are not the most performant. The other two rely on `List.length l` so they still traverse the list twice. One could construct another function that takes a `L : ℕ` and use `L - n`. Under a proof condition that `L = l.length`, the function would do the right thing. -/ -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List /-- Drop `n` elements from the tail end of a list. -/ def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ /-- Take `n` elements from the tail end of a list. -/ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp]
Mathlib/Data/List/DropRight.lean
91
92
theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by
simp [rtake_eq_reverse_take_reverse]
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Analysis.NormedSpace.Basic #align_import analysis.normed_space.enorm from "leanprover-community/mathlib"@"57ac39bd365c2f80589a700f9fbb664d3a1a30c2" /-! # Extended norm In this file we define a structure `ENorm 𝕜 V` representing an extended norm (i.e., a norm that can take the value `∞`) on a vector space `V` over a normed field `𝕜`. We do not use `class` for an `ENorm` because the same space can have more than one extended norm. For example, the space of measurable functions `f : α → ℝ` has a family of `L_p` extended norms. We prove some basic inequalities, then define * `EMetricSpace` structure on `V` corresponding to `e : ENorm 𝕜 V`; * the subspace of vectors with finite norm, called `e.finiteSubspace`; * a `NormedSpace` structure on this space. The last definition is an instance because the type involves `e`. ## Implementation notes We do not define extended normed groups. They can be added to the chain once someone will need them. ## Tags normed space, extended norm -/ noncomputable section attribute [local instance] Classical.propDecidable open ENNReal /-- Extended norm on a vector space. As in the case of normed spaces, we require only `‖c • x‖ ≤ ‖c‖ * ‖x‖` in the definition, then prove an equality in `map_smul`. -/ structure ENorm (𝕜 : Type*) (V : Type*) [NormedField 𝕜] [AddCommGroup V] [Module 𝕜 V] where toFun : V → ℝ≥0∞ eq_zero' : ∀ x, toFun x = 0 → x = 0 map_add_le' : ∀ x y : V, toFun (x + y) ≤ toFun x + toFun y map_smul_le' : ∀ (c : 𝕜) (x : V), toFun (c • x) ≤ ‖c‖₊ * toFun x #align enorm ENorm namespace ENorm variable {𝕜 : Type*} {V : Type*} [NormedField 𝕜] [AddCommGroup V] [Module 𝕜 V] (e : ENorm 𝕜 V) -- Porting note: added to appease norm_cast complaints attribute [coe] ENorm.toFun instance : CoeFun (ENorm 𝕜 V) fun _ => V → ℝ≥0∞ := ⟨ENorm.toFun⟩ theorem coeFn_injective : Function.Injective ((↑) : ENorm 𝕜 V → V → ℝ≥0∞) := fun e₁ e₂ h => by cases e₁ cases e₂ congr #align enorm.coe_fn_injective ENorm.coeFn_injective @[ext] theorem ext {e₁ e₂ : ENorm 𝕜 V} (h : ∀ x, e₁ x = e₂ x) : e₁ = e₂ := coeFn_injective <| funext h #align enorm.ext ENorm.ext theorem ext_iff {e₁ e₂ : ENorm 𝕜 V} : e₁ = e₂ ↔ ∀ x, e₁ x = e₂ x := ⟨fun h _ => h ▸ rfl, ext⟩ #align enorm.ext_iff ENorm.ext_iff @[simp, norm_cast] theorem coe_inj {e₁ e₂ : ENorm 𝕜 V} : (e₁ : V → ℝ≥0∞) = e₂ ↔ e₁ = e₂ := coeFn_injective.eq_iff #align enorm.coe_inj ENorm.coe_inj @[simp] theorem map_smul (c : 𝕜) (x : V) : e (c • x) = ‖c‖₊ * e x := by apply le_antisymm (e.map_smul_le' c x) by_cases hc : c = 0 · simp [hc] calc (‖c‖₊ : ℝ≥0∞) * e x = ‖c‖₊ * e (c⁻¹ • c • x) := by rw [inv_smul_smul₀ hc] _ ≤ ‖c‖₊ * (‖c⁻¹‖₊ * e (c • x)) := mul_le_mul_left' (e.map_smul_le' _ _) _ _ = e (c • x) := by rw [← mul_assoc, nnnorm_inv, ENNReal.coe_inv, ENNReal.mul_inv_cancel _ ENNReal.coe_ne_top, one_mul] <;> simp [hc] #align enorm.map_smul ENorm.map_smul @[simp] theorem map_zero : e 0 = 0 := by rw [← zero_smul 𝕜 (0 : V), e.map_smul] norm_num #align enorm.map_zero ENorm.map_zero @[simp] theorem eq_zero_iff {x : V} : e x = 0 ↔ x = 0 := ⟨e.eq_zero' x, fun h => h.symm ▸ e.map_zero⟩ #align enorm.eq_zero_iff ENorm.eq_zero_iff @[simp] theorem map_neg (x : V) : e (-x) = e x := calc e (-x) = ‖(-1 : 𝕜)‖₊ * e x := by rw [← map_smul, neg_one_smul] _ = e x := by simp #align enorm.map_neg ENorm.map_neg
Mathlib/Analysis/NormedSpace/ENorm.lean
113
113
theorem map_sub_rev (x y : V) : e (x - y) = e (y - x) := by
rw [← neg_sub, e.map_neg]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Nat.Lattice import Mathlib.Logic.Denumerable import Mathlib.Logic.Function.Iterate import Mathlib.Order.Hom.Basic import Mathlib.Data.Set.Subsingleton #align_import order.order_iso_nat from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90" /-! # Relation embeddings from the naturals This file allows translation from monotone functions `ℕ → α` to order embeddings `ℕ ↪ α` and defines the limit value of an eventually-constant sequence. ## Main declarations * `natLT`/`natGT`: Make an order embedding `Nat ↪ α` from an increasing/decreasing function `Nat → α`. * `monotonicSequenceLimit`: The limit of an eventually-constant monotone sequence `Nat →o α`. * `monotonicSequenceLimitIndex`: The index of the first occurrence of `monotonicSequenceLimit` in the sequence. -/ variable {α : Type*} namespace RelEmbedding variable {r : α → α → Prop} [IsStrictOrder α r] /-- If `f` is a strictly `r`-increasing sequence, then this returns `f` as an order embedding. -/ def natLT (f : ℕ → α) (H : ∀ n : ℕ, r (f n) (f (n + 1))) : ((· < ·) : ℕ → ℕ → Prop) ↪r r := ofMonotone f <| Nat.rel_of_forall_rel_succ_of_lt r H #align rel_embedding.nat_lt RelEmbedding.natLT @[simp] theorem coe_natLT {f : ℕ → α} {H : ∀ n : ℕ, r (f n) (f (n + 1))} : ⇑(natLT f H) = f := rfl #align rel_embedding.coe_nat_lt RelEmbedding.coe_natLT /-- If `f` is a strictly `r`-decreasing sequence, then this returns `f` as an order embedding. -/ def natGT (f : ℕ → α) (H : ∀ n : ℕ, r (f (n + 1)) (f n)) : ((· > ·) : ℕ → ℕ → Prop) ↪r r := haveI := IsStrictOrder.swap r RelEmbedding.swap (natLT f H) #align rel_embedding.nat_gt RelEmbedding.natGT @[simp] theorem coe_natGT {f : ℕ → α} {H : ∀ n : ℕ, r (f (n + 1)) (f n)} : ⇑(natGT f H) = f := rfl #align rel_embedding.coe_nat_gt RelEmbedding.coe_natGT theorem exists_not_acc_lt_of_not_acc {a : α} {r} (h : ¬Acc r a) : ∃ b, ¬Acc r b ∧ r b a := by contrapose! h refine ⟨_, fun b hr => ?_⟩ by_contra hb exact h b hb hr #align rel_embedding.exists_not_acc_lt_of_not_acc RelEmbedding.exists_not_acc_lt_of_not_acc /-- A value is accessible iff it isn't contained in any infinite decreasing sequence. -/
Mathlib/Order/OrderIsoNat.lean
66
81
theorem acc_iff_no_decreasing_seq {x} : Acc r x ↔ IsEmpty { f : ((· > ·) : ℕ → ℕ → Prop) ↪r r // x ∈ Set.range f } := by
constructor · refine fun h => h.recOn fun x _ IH => ?_ constructor rintro ⟨f, k, hf⟩ exact IsEmpty.elim' (IH (f (k + 1)) (hf ▸ f.map_rel_iff.2 (lt_add_one k))) ⟨f, _, rfl⟩ · have : ∀ x : { a // ¬Acc r a }, ∃ y : { a // ¬Acc r a }, r y.1 x.1 := by rintro ⟨x, hx⟩ cases exists_not_acc_lt_of_not_acc hx with | intro w h => exact ⟨⟨w, h.1⟩, h.2⟩ choose f h using this refine fun E => by_contradiction fun hx => E.elim' ⟨natGT (fun n => (f^[n] ⟨x, hx⟩).1) fun n => ?_, 0, rfl⟩ simp only [Function.iterate_succ'] apply h
/- Copyright (c) 2022 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.RepresentationTheory.Rep import Mathlib.Algebra.Category.FGModuleCat.Limits import Mathlib.CategoryTheory.Preadditive.Schur import Mathlib.RepresentationTheory.Basic #align_import representation_theory.fdRep from "leanprover-community/mathlib"@"19a70dceb9dff0994b92d2dd049de7d84d28112b" /-! # `FdRep k G` is the category of finite dimensional `k`-linear representations of `G`. If `V : FdRep k G`, there is a coercion that allows you to treat `V` as a type, and this type comes equipped with `Module k V` and `FiniteDimensional k V` instances. Also `V.ρ` gives the homomorphism `G →* (V →ₗ[k] V)`. Conversely, given a homomorphism `ρ : G →* (V →ₗ[k] V)`, you can construct the bundled representation as `Rep.of ρ`. We prove Schur's Lemma: the dimension of the `Hom`-space between two irreducible representation is `0` if they are not isomorphic, and `1` if they are. This is the content of `finrank_hom_simple_simple` We verify that `FdRep k G` is a `k`-linear monoidal category, and rigid when `G` is a group. `FdRep k G` has all finite limits. ## TODO * `FdRep k G ≌ FullSubcategory (FiniteDimensional k)` * Upgrade the right rigid structure to a rigid structure (this just needs to be done for `FGModuleCat`). * `FdRep k G` has all finite colimits. * `FdRep k G` is abelian. * `FdRep k G ≌ FGModuleCat (MonoidAlgebra k G)`. -/ suppress_compilation universe u open CategoryTheory open CategoryTheory.Limits set_option linter.uppercaseLean3 false -- `FdRep` /-- The category of finite dimensional `k`-linear representations of a monoid `G`. -/ abbrev FdRep (k G : Type u) [Field k] [Monoid G] := Action (FGModuleCat.{u} k) (MonCat.of G) #align fdRep FdRep namespace FdRep variable {k G : Type u} [Field k] [Monoid G] -- Porting note: `@[derive]` didn't work for `FdRep`. Add the 4 instances here. instance : LargeCategory (FdRep k G) := inferInstance instance : ConcreteCategory (FdRep k G) := inferInstance instance : Preadditive (FdRep k G) := inferInstance instance : HasFiniteLimits (FdRep k G) := inferInstance instance : Linear k (FdRep k G) := by infer_instance instance : CoeSort (FdRep k G) (Type u) := ConcreteCategory.hasCoeToSort _ instance (V : FdRep k G) : AddCommGroup V := by change AddCommGroup ((forget₂ (FdRep k G) (FGModuleCat k)).obj V).obj; infer_instance instance (V : FdRep k G) : Module k V := by change Module k ((forget₂ (FdRep k G) (FGModuleCat k)).obj V).obj; infer_instance instance (V : FdRep k G) : FiniteDimensional k V := by change FiniteDimensional k ((forget₂ (FdRep k G) (FGModuleCat k)).obj V); infer_instance /-- All hom spaces are finite dimensional. -/ instance (V W : FdRep k G) : FiniteDimensional k (V ⟶ W) := FiniteDimensional.of_injective ((forget₂ (FdRep k G) (FGModuleCat k)).mapLinearMap k) (Functor.map_injective (forget₂ (FdRep k G) (FGModuleCat k))) /-- The monoid homomorphism corresponding to the action of `G` onto `V : FdRep k G`. -/ def ρ (V : FdRep k G) : G →* V →ₗ[k] V := Action.ρ V #align fdRep.ρ FdRep.ρ /-- The underlying `LinearEquiv` of an isomorphism of representations. -/ def isoToLinearEquiv {V W : FdRep k G} (i : V ≅ W) : V ≃ₗ[k] W := FGModuleCat.isoToLinearEquiv ((Action.forget (FGModuleCat k) (MonCat.of G)).mapIso i) #align fdRep.iso_to_linear_equiv FdRep.isoToLinearEquiv theorem Iso.conj_ρ {V W : FdRep k G} (i : V ≅ W) (g : G) : W.ρ g = (FdRep.isoToLinearEquiv i).conj (V.ρ g) := by -- Porting note: Changed `rw` to `erw` erw [FdRep.isoToLinearEquiv, ← FGModuleCat.Iso.conj_eq_conj, Iso.conj_apply] rw [Iso.eq_inv_comp ((Action.forget (FGModuleCat k) (MonCat.of G)).mapIso i)] exact (i.hom.comm g).symm #align fdRep.iso.conj_ρ FdRep.Iso.conj_ρ /-- Lift an unbundled representation to `FdRep`. -/ @[simps ρ] def of {V : Type u} [AddCommGroup V] [Module k V] [FiniteDimensional k V] (ρ : Representation k G V) : FdRep k G := ⟨FGModuleCat.of k V, ρ⟩ #align fdRep.of FdRep.of instance : HasForget₂ (FdRep k G) (Rep k G) where forget₂ := (forget₂ (FGModuleCat k) (ModuleCat k)).mapAction (MonCat.of G)
Mathlib/RepresentationTheory/FdRep.lean
113
114
theorem forget₂_ρ (V : FdRep k G) : ((forget₂ (FdRep k G) (Rep k G)).obj V).ρ = V.ρ := by
ext g v; rfl
/- Copyright (c) 2020 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.List.Basic /-! # Properties of `List.reduceOption` In this file we prove basic lemmas about `List.reduceOption`. -/ namespace List variable {α β : Type*} @[simp] theorem reduceOption_cons_of_some (x : α) (l : List (Option α)) : reduceOption (some x :: l) = x :: l.reduceOption := by simp only [reduceOption, filterMap, id, eq_self_iff_true, and_self_iff] #align list.reduce_option_cons_of_some List.reduceOption_cons_of_some @[simp]
Mathlib/Data/List/ReduceOption.lean
25
26
theorem reduceOption_cons_of_none (l : List (Option α)) : reduceOption (none :: l) = l.reduceOption := by
simp only [reduceOption, filterMap, id]
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl -/ import Mathlib.Algebra.Order.Monoid.Unbundled.Basic #align_import algebra.order.monoid.min_max from "leanprover-community/mathlib"@"de87d5053a9fe5cbde723172c0fb7e27e7436473" /-! # Lemmas about `min` and `max` in an ordered monoid. -/ open Function variable {α β : Type*} /-! Some lemmas about types that have an ordering and a binary operation, with no rules relating them. -/ section CommSemigroup variable [LinearOrder α] [CommSemigroup α] [CommSemigroup β] @[to_additive] lemma fn_min_mul_fn_max (f : α → β) (a b : α) : f (min a b) * f (max a b) = f a * f b := by obtain h | h := le_total a b <;> simp [h, mul_comm] #align fn_min_mul_fn_max fn_min_mul_fn_max #align fn_min_add_fn_max fn_min_add_fn_max @[to_additive] lemma fn_max_mul_fn_min (f : α → β) (a b : α) : f (max a b) * f (min a b) = f a * f b := by obtain h | h := le_total a b <;> simp [h, mul_comm] @[to_additive (attr := simp)] lemma min_mul_max (a b : α) : min a b * max a b = a * b := fn_min_mul_fn_max id _ _ #align min_mul_max min_mul_max #align min_add_max min_add_max @[to_additive (attr := simp)] lemma max_mul_min (a b : α) : max a b * min a b = a * b := fn_max_mul_fn_min id _ _ end CommSemigroup section CovariantClassMulLe variable [LinearOrder α] section Mul variable [Mul α] section Left variable [CovariantClass α α (· * ·) (· ≤ ·)] @[to_additive] theorem min_mul_mul_left (a b c : α) : min (a * b) (a * c) = a * min b c := (monotone_id.const_mul' a).map_min.symm #align min_mul_mul_left min_mul_mul_left #align min_add_add_left min_add_add_left @[to_additive] theorem max_mul_mul_left (a b c : α) : max (a * b) (a * c) = a * max b c := (monotone_id.const_mul' a).map_max.symm #align max_mul_mul_left max_mul_mul_left #align max_add_add_left max_add_add_left end Left section Right variable [CovariantClass α α (Function.swap (· * ·)) (· ≤ ·)] @[to_additive] theorem min_mul_mul_right (a b c : α) : min (a * c) (b * c) = min a b * c := (monotone_id.mul_const' c).map_min.symm #align min_mul_mul_right min_mul_mul_right #align min_add_add_right min_add_add_right @[to_additive] theorem max_mul_mul_right (a b c : α) : max (a * c) (b * c) = max a b * c := (monotone_id.mul_const' c).map_max.symm #align max_mul_mul_right max_mul_mul_right #align max_add_add_right max_add_add_right end Right @[to_additive] theorem lt_or_lt_of_mul_lt_mul [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (Function.swap (· * ·)) (· ≤ ·)] {a₁ a₂ b₁ b₂ : α} : a₁ * b₁ < a₂ * b₂ → a₁ < a₂ ∨ b₁ < b₂ := by contrapose! exact fun h => mul_le_mul' h.1 h.2 #align lt_or_lt_of_mul_lt_mul lt_or_lt_of_mul_lt_mul #align lt_or_lt_of_add_lt_add lt_or_lt_of_add_lt_add @[to_additive]
Mathlib/Algebra/Order/Monoid/Unbundled/MinMax.lean
99
103
theorem le_or_lt_of_mul_le_mul [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (Function.swap (· * ·)) (· < ·)] {a₁ a₂ b₁ b₂ : α} : a₁ * b₁ ≤ a₂ * b₂ → a₁ ≤ a₂ ∨ b₁ < b₂ := by
contrapose! exact fun h => mul_lt_mul_of_lt_of_le h.1 h.2
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Data.Finsupp.Basic import Mathlib.Data.Finsupp.Order #align_import data.finsupp.multiset from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Equivalence between `Multiset` and `ℕ`-valued finitely supported functions This defines `Finsupp.toMultiset` the equivalence between `α →₀ ℕ` and `Multiset α`, along with `Multiset.toFinsupp` the reverse equivalence and `Finsupp.orderIsoMultiset` the equivalence promoted to an order isomorphism. -/ open Finset variable {α β ι : Type*} namespace Finsupp /-- Given `f : α →₀ ℕ`, `f.toMultiset` is the multiset with multiplicities given by the values of `f` on the elements of `α`. We define this function as an `AddMonoidHom`. Under the additional assumption of `[DecidableEq α]`, this is available as `Multiset.toFinsupp : Multiset α ≃+ (α →₀ ℕ)`; the two declarations are separate as this assumption is only needed for one direction. -/ def toMultiset : (α →₀ ℕ) →+ Multiset α where toFun f := Finsupp.sum f fun a n => n • {a} -- Porting note: times out if h is not specified map_add' _f _g := sum_add_index' (h := fun a n => n • ({a} : Multiset α)) (fun _ ↦ zero_nsmul _) (fun _ ↦ add_nsmul _) map_zero' := sum_zero_index theorem toMultiset_zero : toMultiset (0 : α →₀ ℕ) = 0 := rfl #align finsupp.to_multiset_zero Finsupp.toMultiset_zero theorem toMultiset_add (m n : α →₀ ℕ) : toMultiset (m + n) = toMultiset m + toMultiset n := toMultiset.map_add m n #align finsupp.to_multiset_add Finsupp.toMultiset_add theorem toMultiset_apply (f : α →₀ ℕ) : toMultiset f = f.sum fun a n => n • {a} := rfl #align finsupp.to_multiset_apply Finsupp.toMultiset_apply @[simp] theorem toMultiset_single (a : α) (n : ℕ) : toMultiset (single a n) = n • {a} := by rw [toMultiset_apply, sum_single_index]; apply zero_nsmul #align finsupp.to_multiset_single Finsupp.toMultiset_single theorem toMultiset_sum {f : ι → α →₀ ℕ} (s : Finset ι) : Finsupp.toMultiset (∑ i ∈ s, f i) = ∑ i ∈ s, Finsupp.toMultiset (f i) := map_sum Finsupp.toMultiset _ _ #align finsupp.to_multiset_sum Finsupp.toMultiset_sum theorem toMultiset_sum_single (s : Finset ι) (n : ℕ) : Finsupp.toMultiset (∑ i ∈ s, single i n) = n • s.val := by simp_rw [toMultiset_sum, Finsupp.toMultiset_single, sum_nsmul, sum_multiset_singleton] #align finsupp.to_multiset_sum_single Finsupp.toMultiset_sum_single @[simp] theorem card_toMultiset (f : α →₀ ℕ) : Multiset.card (toMultiset f) = f.sum fun _ => id := by simp [toMultiset_apply, map_finsupp_sum, Function.id_def] #align finsupp.card_to_multiset Finsupp.card_toMultiset theorem toMultiset_map (f : α →₀ ℕ) (g : α → β) : f.toMultiset.map g = toMultiset (f.mapDomain g) := by refine f.induction ?_ ?_ · rw [toMultiset_zero, Multiset.map_zero, mapDomain_zero, toMultiset_zero] · intro a n f _ _ ih rw [toMultiset_add, Multiset.map_add, ih, mapDomain_add, mapDomain_single, toMultiset_single, toMultiset_add, toMultiset_single, ← Multiset.coe_mapAddMonoidHom, (Multiset.mapAddMonoidHom g).map_nsmul] rfl #align finsupp.to_multiset_map Finsupp.toMultiset_map @[to_additive (attr := simp)] theorem prod_toMultiset [CommMonoid α] (f : α →₀ ℕ) : f.toMultiset.prod = f.prod fun a n => a ^ n := by refine f.induction ?_ ?_ · rw [toMultiset_zero, Multiset.prod_zero, Finsupp.prod_zero_index] · intro a n f _ _ ih rw [toMultiset_add, Multiset.prod_add, ih, toMultiset_single, Multiset.prod_nsmul, Finsupp.prod_add_index' pow_zero pow_add, Finsupp.prod_single_index, Multiset.prod_singleton] exact pow_zero a #align finsupp.prod_to_multiset Finsupp.prod_toMultiset @[simp]
Mathlib/Data/Finsupp/Multiset.lean
94
101
theorem toFinset_toMultiset [DecidableEq α] (f : α →₀ ℕ) : f.toMultiset.toFinset = f.support := by
refine f.induction ?_ ?_ · rw [toMultiset_zero, Multiset.toFinset_zero, support_zero] · intro a n f ha hn ih rw [toMultiset_add, Multiset.toFinset_add, ih, toMultiset_single, support_add_eq, support_single_ne_zero _ hn, Multiset.toFinset_nsmul _ _ hn, Multiset.toFinset_singleton] refine Disjoint.mono_left support_single_subset ?_ rwa [Finset.disjoint_singleton_left]
/- 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.Analysis.RCLike.Lemmas import Mathlib.MeasureTheory.Function.StronglyMeasurable.Inner import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.function.l2_space from "leanprover-community/mathlib"@"83a66c8775fa14ee5180c85cab98e970956401ad" /-! # `L^2` space If `E` is an inner product space over `𝕜` (`ℝ` or `ℂ`), then `Lp E 2 μ` (defined in `Mathlib.MeasureTheory.Function.LpSpace`) is also an inner product space, with inner product defined as `inner f g = ∫ a, ⟪f a, g a⟫ ∂μ`. ### Main results * `mem_L1_inner` : for `f` and `g` in `Lp E 2 μ`, the pointwise inner product `fun x ↦ ⟪f x, g x⟫` belongs to `Lp 𝕜 1 μ`. * `integrable_inner` : for `f` and `g` in `Lp E 2 μ`, the pointwise inner product `fun x ↦ ⟪f x, g x⟫` is integrable. * `L2.innerProductSpace` : `Lp E 2 μ` is an inner product space. -/ set_option linter.uppercaseLean3 false noncomputable section open TopologicalSpace MeasureTheory MeasureTheory.Lp Filter open scoped NNReal ENNReal MeasureTheory namespace MeasureTheory section variable {α F : Type*} {m : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup F] theorem Memℒp.integrable_sq {f : α → ℝ} (h : Memℒp f 2 μ) : Integrable (fun x => f x ^ 2) μ := by simpa [← memℒp_one_iff_integrable] using h.norm_rpow two_ne_zero ENNReal.two_ne_top #align measure_theory.mem_ℒp.integrable_sq MeasureTheory.Memℒp.integrable_sq theorem memℒp_two_iff_integrable_sq_norm {f : α → F} (hf : AEStronglyMeasurable f μ) : Memℒp f 2 μ ↔ Integrable (fun x => ‖f x‖ ^ 2) μ := by rw [← memℒp_one_iff_integrable] convert (memℒp_norm_rpow_iff hf two_ne_zero ENNReal.two_ne_top).symm · simp · rw [div_eq_mul_inv, ENNReal.mul_inv_cancel two_ne_zero ENNReal.two_ne_top] #align measure_theory.mem_ℒp_two_iff_integrable_sq_norm MeasureTheory.memℒp_two_iff_integrable_sq_norm theorem memℒp_two_iff_integrable_sq {f : α → ℝ} (hf : AEStronglyMeasurable f μ) : Memℒp f 2 μ ↔ Integrable (fun x => f x ^ 2) μ := by convert memℒp_two_iff_integrable_sq_norm hf using 3 simp #align measure_theory.mem_ℒp_two_iff_integrable_sq MeasureTheory.memℒp_two_iff_integrable_sq end section InnerProductSpace variable {α : Type*} {m : MeasurableSpace α} {p : ℝ≥0∞} {μ : Measure α} variable {E 𝕜 : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] local notation "⟪" x ", " y "⟫" => @inner 𝕜 E _ x y theorem Memℒp.const_inner (c : E) {f : α → E} (hf : Memℒp f p μ) : Memℒp (fun a => ⟪c, f a⟫) p μ := hf.of_le_mul (AEStronglyMeasurable.inner aestronglyMeasurable_const hf.1) (eventually_of_forall fun _ => norm_inner_le_norm _ _) #align measure_theory.mem_ℒp.const_inner MeasureTheory.Memℒp.const_inner theorem Memℒp.inner_const {f : α → E} (hf : Memℒp f p μ) (c : E) : Memℒp (fun a => ⟪f a, c⟫) p μ := hf.of_le_mul (AEStronglyMeasurable.inner hf.1 aestronglyMeasurable_const) (eventually_of_forall fun x => by rw [mul_comm]; exact norm_inner_le_norm _ _) #align measure_theory.mem_ℒp.inner_const MeasureTheory.Memℒp.inner_const variable {f : α → E} theorem Integrable.const_inner (c : E) (hf : Integrable f μ) : Integrable (fun x => ⟪c, f x⟫) μ := by rw [← memℒp_one_iff_integrable] at hf ⊢; exact hf.const_inner c #align measure_theory.integrable.const_inner MeasureTheory.Integrable.const_inner theorem Integrable.inner_const (hf : Integrable f μ) (c : E) : Integrable (fun x => ⟪f x, c⟫) μ := by rw [← memℒp_one_iff_integrable] at hf ⊢; exact hf.inner_const c #align measure_theory.integrable.inner_const MeasureTheory.Integrable.inner_const variable [CompleteSpace E] [NormedSpace ℝ E] theorem _root_.integral_inner {f : α → E} (hf : Integrable f μ) (c : E) : ∫ x, ⟪c, f x⟫ ∂μ = ⟪c, ∫ x, f x ∂μ⟫ := ((innerSL 𝕜 c).restrictScalars ℝ).integral_comp_comm hf #align integral_inner integral_inner variable (𝕜) -- variable binder update doesn't work for lemmas which refer to `𝕜` only via the notation -- Porting note: removed because it causes ambiguity in the lemma below -- local notation "⟪" x ", " y "⟫" => @inner 𝕜 E _ x y
Mathlib/MeasureTheory/Function/L2Space.lean
104
106
theorem _root_.integral_eq_zero_of_forall_integral_inner_eq_zero (f : α → E) (hf : Integrable f μ) (hf_int : ∀ c : E, ∫ x, ⟪c, f x⟫ ∂μ = 0) : ∫ x, f x ∂μ = 0 := by
specialize hf_int (∫ x, f x ∂μ); rwa [integral_inner hf, inner_self_eq_zero] at hf_int
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Fin.Fin2 import Mathlib.Data.PFun import Mathlib.Data.Vector3 import Mathlib.NumberTheory.PellMatiyasevic #align_import number_theory.dioph from "leanprover-community/mathlib"@"a66d07e27d5b5b8ac1147cacfe353478e5c14002" /-! # Diophantine functions and Matiyasevic's theorem Hilbert's tenth problem asked whether there exists an algorithm which for a given integer polynomial determines whether this polynomial has integer solutions. It was answered in the negative in 1970, the final step being completed by Matiyasevic who showed that the power function is Diophantine. Here a function is called Diophantine if its graph is Diophantine as a set. A subset `S ⊆ ℕ ^ α` in turn is called Diophantine if there exists an integer polynomial on `α ⊕ β` such that `v ∈ S` iff there exists `t : ℕ^β` with `p (v, t) = 0`. ## Main definitions * `IsPoly`: a predicate stating that a function is a multivariate integer polynomial. * `Poly`: the type of multivariate integer polynomial functions. * `Dioph`: a predicate stating that a set is Diophantine, i.e. a set `S ⊆ ℕ^α` is Diophantine if there exists a polynomial on `α ⊕ β` such that `v ∈ S` iff there exists `t : ℕ^β` with `p (v, t) = 0`. * `dioph_fn`: a predicate on a function stating that it is Diophantine in the sense that its graph is Diophantine as a set. ## Main statements * `pell_dioph` states that solutions to Pell's equation form a Diophantine set. * `pow_dioph` states that the power function is Diophantine, a version of Matiyasevic's theorem. ## References * [M. Carneiro, _A Lean formalization of Matiyasevic's theorem_][carneiro2018matiyasevic] * [M. Davis, _Hilbert's tenth problem is unsolvable_][MR317916] ## Tags Matiyasevic's theorem, Hilbert's tenth problem ## TODO * Finish the solution of Hilbert's tenth problem. * Connect `Poly` to `MvPolynomial` -/ open Fin2 Function Nat Sum local infixr:67 " ::ₒ " => Option.elim' local infixr:65 " ⊗ " => Sum.elim universe u /-! ### Multivariate integer polynomials Note that this duplicates `MvPolynomial`. -/ section Polynomials variable {α β γ : Type*} /-- A predicate asserting that a function is a multivariate integer polynomial. (We are being a bit lazy here by allowing many representations for multiplication, rather than only allowing monomials and addition, but the definition is equivalent and this is easier to use.) -/ inductive IsPoly : ((α → ℕ) → ℤ) → Prop | proj : ∀ i, IsPoly fun x : α → ℕ => x i | const : ∀ n : ℤ, IsPoly fun _ : α → ℕ => n | sub : ∀ {f g : (α → ℕ) → ℤ}, IsPoly f → IsPoly g → IsPoly fun x => f x - g x | mul : ∀ {f g : (α → ℕ) → ℤ}, IsPoly f → IsPoly g → IsPoly fun x => f x * g x #align is_poly IsPoly
Mathlib/NumberTheory/Dioph.lean
85
86
theorem IsPoly.neg {f : (α → ℕ) → ℤ} : IsPoly f → IsPoly (-f) := by
rw [← zero_sub]; exact (IsPoly.const 0).sub
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.CategoryTheory.Sites.InducedTopology import Mathlib.CategoryTheory.Sites.LocallyBijective import Mathlib.CategoryTheory.Sites.PreservesLocallyBijective import Mathlib.CategoryTheory.Sites.Whiskering /-! # Equivalences of sheaf categories Given a site `(C, J)` and a category `D` which is equivalent to `C`, with `C` and `D` possibly large and possibly in different universes, we transport the Grothendieck topology `J` on `C` to `D` and prove that the sheaf categories are equivalent. We also prove that sheafification and the property `HasSheafCompose` transport nicely over this equivalence, and apply it to essentially small sites. We also provide instances for existence of sufficiently small limits in the sheaf category on the essentially small site. ## Main definitions * `CategoryTheory.Equivalence.sheafCongr` is the equivalence of sheaf categories. * `CategoryTheory.Equivalence.transportAndSheafify` is the functor which takes a presheaf on `C`, transports it over the equivalence to `D`, sheafifies there and then transports back to `C`. * `CategoryTheory.Equivalence.transportSheafificationAdjunction`: `transportAndSheafify` is left adjoint to the functor taking a sheaf to its underlying presheaf. * `CategoryTheory.smallSheafify` is the functor which takes a presheaf on an essentially small site `(C, J)`, transports to a small model, sheafifies there and then transports back to `C`. * `CategoryTheory.smallSheafificationAdjunction`: `smallSheafify` is left adjoint to the functor taking a sheaf to its underlying presheaf. -/ universe u namespace CategoryTheory open Functor Limits GrothendieckTopology variable {C : Type*} [Category C] (J : GrothendieckTopology C) variable {D : Type*} [Category D] (K : GrothendieckTopology D) (e : C ≌ D) (G : D ⥤ C) variable (A : Type*) [Category A] namespace Equivalence
Mathlib/CategoryTheory/Sites/Equivalence.lean
51
65
theorem locallyCoverDense : LocallyCoverDense J e.inverse := by
intro X T convert T.prop ext Z f constructor · rintro ⟨_, _, g', hg, rfl⟩ exact T.val.downward_closed hg g' · intro hf refine ⟨e.functor.obj Z, (Adjunction.homEquiv e.toAdjunction _ _).symm f, e.unit.app Z, ?_, ?_⟩ · simp only [Adjunction.homEquiv_counit, Functor.id_obj, Equivalence.toAdjunction_counit, Sieve.functorPullback_apply, Presieve.functorPullback_mem, Functor.map_comp, Equivalence.inv_fun_map, Functor.comp_obj, Category.assoc, Equivalence.unit_inverse_comp, Category.comp_id] exact T.val.downward_closed hf _ · simp
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Polynomial.Degree.Definitions import Mathlib.Data.ENat.Basic #align_import data.polynomial.degree.trailing_degree from "leanprover-community/mathlib"@"302eab4f46abb63de520828de78c04cb0f9b5836" /-! # Trailing degree of univariate polynomials ## Main definitions * `trailingDegree p`: the multiplicity of `X` in the polynomial `p` * `natTrailingDegree`: a variant of `trailingDegree` that takes values in the natural numbers * `trailingCoeff`: the coefficient at index `natTrailingDegree p` Converts most results about `degree`, `natDegree` and `leadingCoeff` to results about the bottom end of a polynomial -/ noncomputable section open Function Polynomial Finsupp Finset open scoped Polynomial namespace Polynomial universe u v variable {R : Type u} {S : Type v} {a b : R} {n m : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} /-- `trailingDegree p` is the multiplicity of `x` in the polynomial `p`, i.e. the smallest `X`-exponent in `p`. `trailingDegree p = some n` when `p ≠ 0` and `n` is the smallest power of `X` that appears in `p`, otherwise `trailingDegree 0 = ⊤`. -/ def trailingDegree (p : R[X]) : ℕ∞ := p.support.min #align polynomial.trailing_degree Polynomial.trailingDegree theorem trailingDegree_lt_wf : WellFounded fun p q : R[X] => trailingDegree p < trailingDegree q := InvImage.wf trailingDegree wellFounded_lt #align polynomial.trailing_degree_lt_wf Polynomial.trailingDegree_lt_wf /-- `natTrailingDegree p` forces `trailingDegree p` to `ℕ`, by defining `natTrailingDegree ⊤ = 0`. -/ def natTrailingDegree (p : R[X]) : ℕ := (trailingDegree p).getD 0 #align polynomial.nat_trailing_degree Polynomial.natTrailingDegree /-- `trailingCoeff p` gives the coefficient of the smallest power of `X` in `p`-/ def trailingCoeff (p : R[X]) : R := coeff p (natTrailingDegree p) #align polynomial.trailing_coeff Polynomial.trailingCoeff /-- a polynomial is `monic_at` if its trailing coefficient is 1 -/ def TrailingMonic (p : R[X]) := trailingCoeff p = (1 : R) #align polynomial.trailing_monic Polynomial.TrailingMonic theorem TrailingMonic.def : TrailingMonic p ↔ trailingCoeff p = 1 := Iff.rfl #align polynomial.trailing_monic.def Polynomial.TrailingMonic.def instance TrailingMonic.decidable [DecidableEq R] : Decidable (TrailingMonic p) := inferInstanceAs <| Decidable (trailingCoeff p = (1 : R)) #align polynomial.trailing_monic.decidable Polynomial.TrailingMonic.decidable @[simp] theorem TrailingMonic.trailingCoeff {p : R[X]} (hp : p.TrailingMonic) : trailingCoeff p = 1 := hp #align polynomial.trailing_monic.trailing_coeff Polynomial.TrailingMonic.trailingCoeff @[simp] theorem trailingDegree_zero : trailingDegree (0 : R[X]) = ⊤ := rfl #align polynomial.trailing_degree_zero Polynomial.trailingDegree_zero @[simp] theorem trailingCoeff_zero : trailingCoeff (0 : R[X]) = 0 := rfl #align polynomial.trailing_coeff_zero Polynomial.trailingCoeff_zero @[simp] theorem natTrailingDegree_zero : natTrailingDegree (0 : R[X]) = 0 := rfl #align polynomial.nat_trailing_degree_zero Polynomial.natTrailingDegree_zero theorem trailingDegree_eq_top : trailingDegree p = ⊤ ↔ p = 0 := ⟨fun h => support_eq_empty.1 (Finset.min_eq_top.1 h), fun h => by simp [h]⟩ #align polynomial.trailing_degree_eq_top Polynomial.trailingDegree_eq_top
Mathlib/Algebra/Polynomial/Degree/TrailingDegree.lean
102
108
theorem trailingDegree_eq_natTrailingDegree (hp : p ≠ 0) : trailingDegree p = (natTrailingDegree p : ℕ∞) := by
let ⟨n, hn⟩ := not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt trailingDegree_eq_top.1 hp)) have hn : trailingDegree p = n := Classical.not_not.1 hn rw [natTrailingDegree, hn] rfl
/- Copyright (c) 2014 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura, Jeremy Avigad, Floris van Doorn, Mario Carneiro -/ import Batteries.Tactic.Init import Batteries.Tactic.Alias import Batteries.Tactic.Lint.Misc instance {f : α → β} [DecidablePred p] : DecidablePred (p ∘ f) := inferInstanceAs <| DecidablePred fun x => p (f x) @[deprecated] alias proofIrrel := proof_irrel /-! ## id -/ theorem Function.id_def : @id α = fun x => x := rfl /-! ## exists and forall -/ alias ⟨forall_not_of_not_exists, not_exists_of_forall_not⟩ := not_exists /-! ## decidable -/ protected alias ⟨Decidable.exists_not_of_not_forall, _⟩ := Decidable.not_forall /-! ## classical logic -/ namespace Classical alias ⟨exists_not_of_not_forall, _⟩ := not_forall end Classical /-! ## equality -/ theorem heq_iff_eq : HEq a b ↔ a = b := ⟨eq_of_heq, heq_of_eq⟩ @[simp] theorem eq_rec_constant {α : Sort _} {a a' : α} {β : Sort _} (y : β) (h : a = a') : (@Eq.rec α a (fun α _ => β) y a' h) = y := by cases h; rfl theorem congrArg₂ (f : α → β → γ) {x x' : α} {y y' : β} (hx : x = x') (hy : y = y') : f x y = f x' y' := by subst hx hy; rfl theorem congrFun₂ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {f g : ∀ a b, γ a b} (h : f = g) (a : α) (b : β a) : f a b = g a b := congrFun (congrFun h _) _ theorem congrFun₃ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {δ : ∀ a b, γ a b → Sort _} {f g : ∀ a b c, δ a b c} (h : f = g) (a : α) (b : β a) (c : γ a b) : f a b c = g a b c := congrFun₂ (congrFun h _) _ _ theorem funext₂ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {f g : ∀ a b, γ a b} (h : ∀ a b, f a b = g a b) : f = g := funext fun _ => funext <| h _ theorem funext₃ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {δ : ∀ a b, γ a b → Sort _} {f g : ∀ a b c, δ a b c} (h : ∀ a b c, f a b c = g a b c) : f = g := funext fun _ => funext₂ <| h _ theorem Function.funext_iff {β : α → Sort u} {f₁ f₂ : ∀ x : α, β x} : f₁ = f₂ ↔ ∀ a, f₁ a = f₂ a := ⟨congrFun, funext⟩ theorem ne_of_apply_ne {α β : Sort _} (f : α → β) {x y : α} : f x ≠ f y → x ≠ y := mt <| congrArg _ protected theorem Eq.congr (h₁ : x₁ = y₁) (h₂ : x₂ = y₂) : x₁ = x₂ ↔ y₁ = y₂ := by subst h₁; subst h₂; rfl
.lake/packages/batteries/Batteries/Logic.lean
72
72
theorem Eq.congr_left {x y z : α} (h : x = y) : x = z ↔ y = z := by
rw [h]
/- 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
Mathlib/Algebra/Order/Field/Basic.lean
104
104
theorem inv_mul_le_iff' (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ c * b := by
rw [inv_mul_le_iff h, mul_comm]
/- Copyright (c) 2022 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Analysis.Complex.UpperHalfPlane.Basic import Mathlib.Analysis.Convex.Contractible import Mathlib.Analysis.Convex.Normed import Mathlib.Analysis.Convex.Complex import Mathlib.Analysis.Complex.ReImTopology import Mathlib.Topology.Homotopy.Contractible import Mathlib.Topology.PartialHomeomorph #align_import analysis.complex.upper_half_plane.topology from "leanprover-community/mathlib"@"57f9349f2fe19d2de7207e99b0341808d977cdcf" /-! # Topology on the upper half plane In this file we introduce a `TopologicalSpace` structure on the upper half plane and provide various instances. -/ noncomputable section open Set Filter Function TopologicalSpace Complex open scoped Filter Topology UpperHalfPlane namespace UpperHalfPlane instance : TopologicalSpace ℍ := instTopologicalSpaceSubtype theorem openEmbedding_coe : OpenEmbedding ((↑) : ℍ → ℂ) := IsOpen.openEmbedding_subtype_val <| isOpen_lt continuous_const Complex.continuous_im #align upper_half_plane.open_embedding_coe UpperHalfPlane.openEmbedding_coe theorem embedding_coe : Embedding ((↑) : ℍ → ℂ) := embedding_subtype_val #align upper_half_plane.embedding_coe UpperHalfPlane.embedding_coe theorem continuous_coe : Continuous ((↑) : ℍ → ℂ) := embedding_coe.continuous #align upper_half_plane.continuous_coe UpperHalfPlane.continuous_coe theorem continuous_re : Continuous re := Complex.continuous_re.comp continuous_coe #align upper_half_plane.continuous_re UpperHalfPlane.continuous_re theorem continuous_im : Continuous im := Complex.continuous_im.comp continuous_coe #align upper_half_plane.continuous_im UpperHalfPlane.continuous_im instance : SecondCountableTopology ℍ := TopologicalSpace.Subtype.secondCountableTopology _ instance : T3Space ℍ := Subtype.t3Space instance : T4Space ℍ := inferInstance instance : ContractibleSpace ℍ := (convex_halfspace_im_gt 0).contractibleSpace ⟨I, one_pos.trans_eq I_im.symm⟩ instance : LocPathConnectedSpace ℍ := locPathConnected_of_isOpen <| isOpen_lt continuous_const Complex.continuous_im instance : NoncompactSpace ℍ := by refine ⟨fun h => ?_⟩ have : IsCompact (Complex.im ⁻¹' Ioi 0) := isCompact_iff_isCompact_univ.2 h replace := this.isClosed.closure_eq rw [closure_preimage_im, closure_Ioi, Set.ext_iff] at this exact absurd ((this 0).1 (@left_mem_Ici ℝ _ 0)) (@lt_irrefl ℝ _ 0) instance : LocallyCompactSpace ℍ := openEmbedding_coe.locallyCompactSpace section strips /-- The vertical strip of width `A` and height `B`, defined by elements whose real part has absolute value less than or equal to `A` and imaginary part is at least `B`. -/ def verticalStrip (A B : ℝ) := {z : ℍ | |z.re| ≤ A ∧ B ≤ z.im} theorem mem_verticalStrip_iff (A B : ℝ) (z : ℍ) : z ∈ verticalStrip A B ↔ |z.re| ≤ A ∧ B ≤ z.im := Iff.rfl @[gcongr] lemma verticalStrip_mono {A B A' B' : ℝ} (hA : A ≤ A') (hB : B' ≤ B) : verticalStrip A B ⊆ verticalStrip A' B' := by rintro z ⟨hzre, hzim⟩ exact ⟨hzre.trans hA, hB.trans hzim⟩ @[gcongr] lemma verticalStrip_mono_left {A A'} (h : A ≤ A') (B) : verticalStrip A B ⊆ verticalStrip A' B := verticalStrip_mono h le_rfl @[gcongr] lemma verticalStrip_anti_right (A) {B B'} (h : B' ≤ B) : verticalStrip A B ⊆ verticalStrip A B' := verticalStrip_mono le_rfl h lemma subset_verticalStrip_of_isCompact {K : Set ℍ} (hK : IsCompact K) : ∃ A B : ℝ, 0 < B ∧ K ⊆ verticalStrip A B := by rcases K.eq_empty_or_nonempty with rfl | hne · exact ⟨1, 1, Real.zero_lt_one, empty_subset _⟩ obtain ⟨u, _, hu⟩ := hK.exists_isMaxOn hne (_root_.continuous_abs.comp continuous_re).continuousOn obtain ⟨v, _, hv⟩ := hK.exists_isMinOn hne continuous_im.continuousOn exact ⟨|re u|, im v, v.im_pos, fun k hk ↦ ⟨isMaxOn_iff.mp hu _ hk, isMinOn_iff.mp hv _ hk⟩⟩
Mathlib/Analysis/Complex/UpperHalfPlane/Topology.lean
109
124
theorem ModularGroup_T_zpow_mem_verticalStrip (z : ℍ) {N : ℕ} (hn : 0 < N) : ∃ n : ℤ, ModularGroup.T ^ (N * n) • z ∈ verticalStrip N z.im := by
let n := Int.floor (z.re/N) use -n rw [modular_T_zpow_smul z (N * -n)] refine ⟨?_, (by simp only [mul_neg, Int.cast_neg, Int.cast_mul, Int.cast_natCast, vadd_im, le_refl])⟩ have h : (N * (-n : ℝ) +ᵥ z).re = -N * Int.floor (z.re / N) + z.re := by simp only [Int.cast_natCast, mul_neg, vadd_re, neg_mul] norm_cast at * rw [h, add_comm] simp only [neg_mul, Int.cast_neg, Int.cast_mul, Int.cast_natCast, ge_iff_le] have hnn : (0 : ℝ) < (N : ℝ) := by norm_cast at * have h2 : z.re + -(N * n) = z.re - n * N := by ring rw [h2, abs_eq_self.2 (Int.sub_floor_div_mul_nonneg (z.re : ℝ) hnn)] apply (Int.sub_floor_div_mul_lt (z.re : ℝ) hnn).le
/- Copyright (c) 2022 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Locus of unequal values of finitely supported functions Let `α N` be two Types, assume that `N` has a `0` and let `f g : α →₀ N` be finitely supported functions. ## Main definition * `Finsupp.neLocus f g : Finset α`, the finite subset of `α` where `f` and `g` differ. In the case in which `N` is an additive group, `Finsupp.neLocus f g` coincides with `Finsupp.support (f - g)`. -/ variable {α M N P : Type*} namespace Finsupp variable [DecidableEq α] section NHasZero variable [DecidableEq N] [Zero N] (f g : α →₀ N) /-- Given two finitely supported functions `f g : α →₀ N`, `Finsupp.neLocus f g` is the `Finset` where `f` and `g` differ. This generalizes `(f - g).support` to situations without subtraction. -/ def neLocus (f g : α →₀ N) : Finset α := (f.support ∪ g.support).filter fun x => f x ≠ g x #align finsupp.ne_locus Finsupp.neLocus @[simp] theorem mem_neLocus {f g : α →₀ N} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff, and_iff_right_iff_imp] using Ne.ne_or_ne _ #align finsupp.mem_ne_locus Finsupp.mem_neLocus theorem not_mem_neLocus {f g : α →₀ N} {a : α} : a ∉ f.neLocus g ↔ f a = g a := mem_neLocus.not.trans not_ne_iff #align finsupp.not_mem_ne_locus Finsupp.not_mem_neLocus @[simp] theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } := by ext exact mem_neLocus #align finsupp.coe_ne_locus Finsupp.coe_neLocus @[simp] theorem neLocus_eq_empty {f g : α →₀ N} : f.neLocus g = ∅ ↔ f = g := ⟨fun h => ext fun a => not_not.mp (mem_neLocus.not.mp (Finset.eq_empty_iff_forall_not_mem.mp h a)), fun h => h ▸ by simp only [neLocus, Ne, eq_self_iff_true, not_true, Finset.filter_False]⟩ #align finsupp.ne_locus_eq_empty Finsupp.neLocus_eq_empty @[simp] theorem nonempty_neLocus_iff {f g : α →₀ N} : (f.neLocus g).Nonempty ↔ f ≠ g := Finset.nonempty_iff_ne_empty.trans neLocus_eq_empty.not #align finsupp.nonempty_ne_locus_iff Finsupp.nonempty_neLocus_iff
Mathlib/Data/Finsupp/NeLocus.lean
69
70
theorem neLocus_comm : f.neLocus g = g.neLocus f := by
simp_rw [neLocus, Finset.union_comm, ne_comm]
/- Copyright (c) 2020 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.RingTheory.Ideal.Maps #align_import ring_theory.ideal.prod from "leanprover-community/mathlib"@"052f6013363326d50cb99c6939814a4b8eb7b301" /-! # Ideals in product rings For commutative rings `R` and `S` and ideals `I ≤ R`, `J ≤ S`, we define `Ideal.prod I J` as the product `I × J`, viewed as an ideal of `R × S`. In `ideal_prod_eq` we show that every ideal of `R × S` is of this form. Furthermore, we show that every prime ideal of `R × S` is of the form `p × S` or `R × p`, where `p` is a prime ideal. -/ universe u v variable {R : Type u} {S : Type v} [Semiring R] [Semiring S] (I I' : Ideal R) (J J' : Ideal S) namespace Ideal /-- `I × J` as an ideal of `R × S`. -/ def prod : Ideal (R × S) where carrier := { x | x.fst ∈ I ∧ x.snd ∈ J } zero_mem' := by simp add_mem' := by rintro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨ha₁, ha₂⟩ ⟨hb₁, hb₂⟩ exact ⟨I.add_mem ha₁ hb₁, J.add_mem ha₂ hb₂⟩ smul_mem' := by rintro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨hb₁, hb₂⟩ exact ⟨I.mul_mem_left _ hb₁, J.mul_mem_left _ hb₂⟩ #align ideal.prod Ideal.prod @[simp] theorem mem_prod {r : R} {s : S} : (⟨r, s⟩ : R × S) ∈ prod I J ↔ r ∈ I ∧ s ∈ J := Iff.rfl #align ideal.mem_prod Ideal.mem_prod @[simp] theorem prod_top_top : prod (⊤ : Ideal R) (⊤ : Ideal S) = ⊤ := Ideal.ext <| by simp #align ideal.prod_top_top Ideal.prod_top_top /-- Every ideal of the product ring is of the form `I × J`, where `I` and `J` can be explicitly given as the image under the projection maps. -/
Mathlib/RingTheory/Ideal/Prod.lean
50
58
theorem ideal_prod_eq (I : Ideal (R × S)) : I = Ideal.prod (map (RingHom.fst R S) I : Ideal R) (map (RingHom.snd R S) I) := by
apply Ideal.ext rintro ⟨r, s⟩ rw [mem_prod, mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective, mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective] refine ⟨fun h => ⟨⟨_, ⟨h, rfl⟩⟩, ⟨_, ⟨h, rfl⟩⟩⟩, ?_⟩ rintro ⟨⟨⟨r, s'⟩, ⟨h₁, rfl⟩⟩, ⟨⟨r', s⟩, ⟨h₂, rfl⟩⟩⟩ simpa using I.add_mem (I.mul_mem_left (1, 0) h₁) (I.mul_mem_left (0, 1) h₂)
/- 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 -/ import Mathlib.Analysis.Convex.Body import Mathlib.Analysis.Convex.Measure import Mathlib.MeasureTheory.Group.FundamentalDomain #align_import measure_theory.group.geometry_of_numbers from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Geometry of numbers In this file we prove some of the fundamental theorems in the geometry of numbers, as studied by Hermann Minkowski. ## Main results * `exists_pair_mem_lattice_not_disjoint_vadd`: Blichfeldt's principle, existence of two distinct points in a subgroup such that the translates of a set by these two points are not disjoint when the covolume of the subgroup is larger than the volume of the set. * `exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure`: Minkowski's theorem, existence of a non-zero lattice point inside a convex symmetric domain of large enough volume. ## TODO * Calculate the volume of the fundamental domain of a finite index subgroup * Voronoi diagrams * See [Pete L. Clark, *Abstract Geometry of Numbers: Linear Forms* (arXiv)](https://arxiv.org/abs/1405.2119) for some more ideas. ## References * [Pete L. Clark, *Geometry of Numbers with Applications to Number Theory*][clark_gon] p.28 -/ namespace MeasureTheory open ENNReal FiniteDimensional MeasureTheory MeasureTheory.Measure Set Filter open scoped Pointwise NNReal variable {E L : Type*} [MeasurableSpace E] {μ : Measure E} {F s : Set E} /-- **Blichfeldt's Theorem**. If the volume of the set `s` is larger than the covolume of the countable subgroup `L` of `E`, then there exist two distinct points `x, y ∈ L` such that `(x + s)` and `(y + s)` are not disjoint. -/
Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean
50
58
theorem exists_pair_mem_lattice_not_disjoint_vadd [AddCommGroup L] [Countable L] [AddAction L E] [MeasurableSpace L] [MeasurableVAdd L E] [VAddInvariantMeasure L E μ] (fund : IsAddFundamentalDomain L F μ) (hS : NullMeasurableSet s μ) (h : μ F < μ s) : ∃ x y : L, x ≠ y ∧ ¬Disjoint (x +ᵥ s) (y +ᵥ s) := by
contrapose! h exact ((fund.measure_eq_tsum _).trans (measure_iUnion₀ (Pairwise.mono h fun i j hij => (hij.mono inf_le_left inf_le_left).aedisjoint) fun _ => (hS.vadd _).inter fund.nullMeasurableSet).symm).trans_le (measure_mono <| Set.iUnion_subset fun _ => Set.inter_subset_right)
/- Copyright (c) 2023 Mohanad Ahmed. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mohanad Ahmed -/ import Mathlib.Algebra.Polynomial.Basic import Mathlib.FieldTheory.IsAlgClosed.Basic #align_import linear_algebra.matrix.charpoly.eigs from "leanprover-community/mathlib"@"48dc6abe71248bd6f4bffc9703dc87bdd4e37d0b" /-! # Eigenvalues are characteristic polynomial roots. In fields we show that: * `Matrix.det_eq_prod_roots_charpoly_of_splits`: the determinant (in the field of the matrix) is the product of the roots of the characteristic polynomial if the polynomial splits in the field of the matrix. * `Matrix.trace_eq_sum_roots_charpoly_of_splits`: the trace is the sum of the roots of the characteristic polynomial if the polynomial splits in the field of the matrix. In an algebraically closed field we show that: * `Matrix.det_eq_prod_roots_charpoly`: the determinant is the product of the roots of the characteristic polynomial. * `Matrix.trace_eq_sum_roots_charpoly`: the trace is the sum of the roots of the characteristic polynomial. Note that over other fields such as `ℝ`, these results can be used by using `A.map (algebraMap ℝ ℂ)` as the matrix, and then applying `RingHom.map_det`. The two lemmas `Matrix.det_eq_prod_roots_charpoly` and `Matrix.trace_eq_sum_roots_charpoly` are more commonly stated as trace is the sum of eigenvalues and determinant is the product of eigenvalues. Mathlib has already defined eigenvalues in `LinearAlgebra.Eigenspace` as the roots of the minimal polynomial of a linear endomorphism. These do not have correct multiplicity and cannot be used in the theorems above. Hence we express these theorems in terms of the roots of the characteristic polynomial directly. ## TODO The proofs of `det_eq_prod_roots_charpoly_of_splits` and `trace_eq_sum_roots_charpoly_of_splits` closely resemble `norm_gen_eq_prod_roots` and `trace_gen_eq_sum_roots` respectively, but the dependencies are not general enough to unify them. We should refactor `Polynomial.prod_roots_eq_coeff_zero_of_monic_of_split` and `Polynomial.sum_roots_eq_nextCoeff_of_monic_of_split` to assume splitting over an arbitrary map. -/ variable {n : Type*} [Fintype n] [DecidableEq n] variable {R : Type*} [Field R] variable {A : Matrix n n R} open Matrix Polynomial open scoped Matrix namespace Matrix theorem det_eq_prod_roots_charpoly_of_splits (hAps : A.charpoly.Splits (RingHom.id R)) : A.det = (Matrix.charpoly A).roots.prod := by rw [det_eq_sign_charpoly_coeff, ← charpoly_natDegree_eq_dim A, Polynomial.prod_roots_eq_coeff_zero_of_monic_of_split A.charpoly_monic hAps, ← mul_assoc, ← pow_two, pow_right_comm, neg_one_sq, one_pow, one_mul] #align matrix.det_eq_prod_roots_charpoly_of_splits Matrix.det_eq_prod_roots_charpoly_of_splits
Mathlib/LinearAlgebra/Matrix/Charpoly/Eigs.lean
67
75
theorem trace_eq_sum_roots_charpoly_of_splits (hAps : A.charpoly.Splits (RingHom.id R)) : A.trace = (Matrix.charpoly A).roots.sum := by
cases' isEmpty_or_nonempty n with h · rw [Matrix.trace, Fintype.sum_empty, Matrix.charpoly, det_eq_one_of_card_eq_zero (Fintype.card_eq_zero_iff.2 h), Polynomial.roots_one, Multiset.empty_eq_zero, Multiset.sum_zero] · rw [trace_eq_neg_charpoly_coeff, neg_eq_iff_eq_neg, ← Polynomial.sum_roots_eq_nextCoeff_of_monic_of_split A.charpoly_monic hAps, nextCoeff, charpoly_natDegree_eq_dim, if_neg (Fintype.card_ne_zero : Fintype.card n ≠ 0)]
/- Copyright (c) 2021 Arthur Paulino. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Arthur Paulino, Kyle Miller -/ import Mathlib.Combinatorics.SimpleGraph.Coloring #align_import combinatorics.simple_graph.partition from "leanprover-community/mathlib"@"2303b3e299f1c75b07bceaaac130ce23044d1386" /-! # Graph partitions This module provides an interface for dealing with partitions on simple graphs. A partition of a graph `G`, with vertices `V`, is a set `P` of disjoint nonempty subsets of `V` such that: * The union of the subsets in `P` is `V`. * Each element of `P` is an independent set. (Each subset contains no pair of adjacent vertices.) Graph partitions are graph colorings that do not name their colors. They are adjoint in the following sense. Given a graph coloring, there is an associated partition from the set of color classes, and given a partition, there is an associated graph coloring from using the partition's subsets as colors. Going from graph colorings to partitions and back makes a coloring "canonical": all colors are given a canonical name and unused colors are removed. Going from partitions to graph colorings and back is the identity. ## Main definitions * `SimpleGraph.Partition` is a structure to represent a partition of a simple graph * `SimpleGraph.Partition.PartsCardLe` is whether a given partition is an `n`-partition. (a partition with at most `n` parts). * `SimpleGraph.Partitionable n` is whether a given graph is `n`-partite * `SimpleGraph.Partition.toColoring` creates colorings from partitions * `SimpleGraph.Coloring.toPartition` creates partitions from colorings ## Main statements * `SimpleGraph.partitionable_iff_colorable` is that `n`-partitionability and `n`-colorability are equivalent. -/ universe u v namespace SimpleGraph variable {V : Type u} (G : SimpleGraph V) /-- A `Partition` of a simple graph `G` is a structure constituted by * `parts`: a set of subsets of the vertices `V` of `G` * `isPartition`: a proof that `parts` is a proper partition of `V` * `independent`: a proof that each element of `parts` doesn't have a pair of adjacent vertices -/ structure Partition where /-- `parts`: a set of subsets of the vertices `V` of `G`. -/ parts : Set (Set V) /-- `isPartition`: a proof that `parts` is a proper partition of `V`. -/ isPartition : Setoid.IsPartition parts /-- `independent`: a proof that each element of `parts` doesn't have a pair of adjacent vertices. -/ independent : ∀ s ∈ parts, IsAntichain G.Adj s #align simple_graph.partition SimpleGraph.Partition /-- Whether a partition `P` has at most `n` parts. A graph with a partition satisfying this predicate called `n`-partite. (See `SimpleGraph.Partitionable`.) -/ def Partition.PartsCardLe {G : SimpleGraph V} (P : G.Partition) (n : ℕ) : Prop := ∃ h : P.parts.Finite, h.toFinset.card ≤ n #align simple_graph.partition.parts_card_le SimpleGraph.Partition.PartsCardLe /-- Whether a graph is `n`-partite, which is whether its vertex set can be partitioned in at most `n` independent sets. -/ def Partitionable (n : ℕ) : Prop := ∃ P : G.Partition, P.PartsCardLe n #align simple_graph.partitionable SimpleGraph.Partitionable namespace Partition variable {G} (P : G.Partition) /-- The part in the partition that `v` belongs to -/ def partOfVertex (v : V) : Set V := Classical.choose (P.isPartition.2 v) #align simple_graph.partition.part_of_vertex SimpleGraph.Partition.partOfVertex theorem partOfVertex_mem (v : V) : P.partOfVertex v ∈ P.parts := by obtain ⟨h, -⟩ := (P.isPartition.2 v).choose_spec.1 exact h #align simple_graph.partition.part_of_vertex_mem SimpleGraph.Partition.partOfVertex_mem theorem mem_partOfVertex (v : V) : v ∈ P.partOfVertex v := by obtain ⟨⟨_, h⟩, _⟩ := (P.isPartition.2 v).choose_spec exact h #align simple_graph.partition.mem_part_of_vertex SimpleGraph.Partition.mem_partOfVertex
Mathlib/Combinatorics/SimpleGraph/Partition.lean
98
102
theorem partOfVertex_ne_of_adj {v w : V} (h : G.Adj v w) : P.partOfVertex v ≠ P.partOfVertex w := by
intro hn have hw := P.mem_partOfVertex w rw [← hn] at hw exact P.independent _ (P.partOfVertex_mem v) (P.mem_partOfVertex v) hw (G.ne_of_adj h) h
/- Copyright (c) 2019 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.Calculus.Deriv.Add #align_import analysis.calculus.local_extr from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Local extrema of differentiable functions ## Main definitions In a real normed space `E` we define `posTangentConeAt (s : Set E) (x : E)`. This would be the same as `tangentConeAt ℝ≥0 s x` if we had a theory of normed semifields. This set is used in the proof of Fermat's Theorem (see below), and can be used to formalize [Lagrange multipliers](https://en.wikipedia.org/wiki/Lagrange_multiplier) and/or [Karush–Kuhn–Tucker conditions](https://en.wikipedia.org/wiki/Karush–Kuhn–Tucker_conditions). ## Main statements For each theorem name listed below, we also prove similar theorems for `min`, `extr` (if applicable), and `fderiv`/`deriv` instead of `HasFDerivAt`/`HasDerivAt`. * `IsLocalMaxOn.hasFDerivWithinAt_nonpos` : `f' y ≤ 0` whenever `a` is a local maximum of `f` on `s`, `f` has derivative `f'` at `a` within `s`, and `y` belongs to the positive tangent cone of `s` at `a`. * `IsLocalMaxOn.hasFDerivWithinAt_eq_zero` : In the settings of the previous theorem, if both `y` and `-y` belong to the positive tangent cone, then `f' y = 0`. * `IsLocalMax.hasFDerivAt_eq_zero` : [Fermat's Theorem](https://en.wikipedia.org/wiki/Fermat's_theorem_(stationary_points)), the derivative of a differentiable function at a local extremum point equals zero. ## Implementation notes For each mathematical fact we prove several versions of its formalization: * for maxima and minima; * using `HasFDeriv*`/`HasDeriv*` or `fderiv*`/`deriv*`. For the `fderiv*`/`deriv*` versions we omit the differentiability condition whenever it is possible due to the fact that `fderiv` and `deriv` are defined to be zero for non-differentiable functions. ## References * [Fermat's Theorem](https://en.wikipedia.org/wiki/Fermat's_theorem_(stationary_points)); * [Tangent cone](https://en.wikipedia.org/wiki/Tangent_cone); ## Tags local extremum, tangent cone, Fermat's Theorem -/ universe u v open Filter Set open scoped Topology Classical section Module variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → ℝ} {a : E} {f' : E →L[ℝ] ℝ} /-! ### Positive tangent cone -/ /-- "Positive" tangent cone to `s` at `x`; the only difference from `tangentConeAt` is that we require `c n → ∞` instead of `‖c n‖ → ∞`. One can think about `posTangentConeAt` as `tangentConeAt NNReal` but we have no theory of normed semifields yet. -/ def posTangentConeAt (s : Set E) (x : E) : Set E := { y : E | ∃ (c : ℕ → ℝ) (d : ℕ → E), (∀ᶠ n in atTop, x + d n ∈ s) ∧ Tendsto c atTop atTop ∧ Tendsto (fun n => c n • d n) atTop (𝓝 y) } #align pos_tangent_cone_at posTangentConeAt
Mathlib/Analysis/Calculus/LocalExtr/Basic.lean
81
83
theorem posTangentConeAt_mono : Monotone fun s => posTangentConeAt s a := by
rintro s t hst y ⟨c, d, hd, hc, hcd⟩ exact ⟨c, d, mem_of_superset hd fun h hn => hst hn, hc, hcd⟩
/- 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.Defs import Mathlib.Algebra.Order.Monoid.WithTop #align_import algebra.order.group.with_top from "leanprover-community/mathlib"@"f178c0e25af359f6cbc72a96a243efd3b12423a3" /-! # Adjoining a top element to a `LinearOrderedAddCommGroup`. This file defines a negation on `WithTop α` when `α` is a linearly ordered additive commutative group, by setting `-⊤ = ⊤`. This corresponds to the additivization of the usual multiplicative convention `0⁻¹ = 0`, and is relevant in valuation theory. Note that there is another subtraction on objects of the form `WithTop α` in the file `Mathlib.Algebra.Order.Sub.WithTop`, setting `-⊤ = ⊥` when `α` has a bottom element. This is the right convention for `ℕ∞` or `ℝ≥0∞`. Since `LinearOrderedAddCommGroup`s don't have a bottom element (unless they are trivial), this shouldn't create diamonds. To avoid conflicts between the two notions, we put everything in the current file in the namespace `WithTop.LinearOrderedAddCommGroup`. -/ namespace WithTop variable {α : Type*} namespace LinearOrderedAddCommGroup variable [LinearOrderedAddCommGroup α] {a b c d : α} instance instNeg : Neg (WithTop α) where neg := Option.map fun a : α => -a /-- If `α` has subtraction, we can extend the subtraction to `WithTop α`, by setting `x - ⊤ = ⊤` and `⊤ - x = ⊤`. This definition is only registered as an instance on linearly ordered additive commutative groups, to avoid conflicting with the instance `WithTop.instSub` on types with a bottom element. -/ protected def sub : ∀ _ _ : WithTop α, WithTop α | _, ⊤ => ⊤ | ⊤, (x : α) => ⊤ | (x : α), (y : α) => (x - y : α) instance instSub : Sub (WithTop α) where sub := WithTop.LinearOrderedAddCommGroup.sub @[simp, norm_cast] theorem coe_neg (a : α) : ((-a : α) : WithTop α) = -a := rfl #align with_top.coe_neg WithTop.LinearOrderedAddCommGroup.coe_neg @[simp] theorem neg_top : -(⊤ : WithTop α) = ⊤ := rfl @[simp, norm_cast] theorem coe_sub {a b : α} : (↑(a - b) : WithTop α) = ↑a - ↑b := rfl @[simp]
Mathlib/Algebra/Order/Group/WithTop.lean
61
62
theorem top_sub {a : WithTop α} : (⊤ : WithTop α) - a = ⊤ := by
cases a <;> rfl
/- Copyright (c) 2022 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying, Bhavik Mehta -/ import Mathlib.Probability.ConditionalProbability import Mathlib.MeasureTheory.Measure.Count #align_import probability.cond_count from "leanprover-community/mathlib"@"117e93f82b5f959f8193857370109935291f0cc4" /-! # Classical probability The classical formulation of probability states that the probability of an event occurring in a finite probability space is the ratio of that event to all possible events. This notion can be expressed with measure theory using the counting measure. In particular, given the sets `s` and `t`, we define the probability of `t` occurring in `s` to be `|s|⁻¹ * |s ∩ t|`. With this definition, we recover the probability over the entire sample space when `s = Set.univ`. Classical probability is often used in combinatorics and we prove some useful lemmas in this file for that purpose. ## Main definition * `ProbabilityTheory.condCount`: given a set `s`, `condCount s` is the counting measure conditioned on `s`. This is a probability measure when `s` is finite and nonempty. ## Notes The original aim of this file is to provide a measure theoretic method of describing the probability an element of a set `s` satisfies some predicate `P`. Our current formulation still allow us to describe this by abusing the definitional equality of sets and predicates by simply writing `condCount s P`. We should avoid this however as none of the lemmas are written for predicates. -/ noncomputable section open ProbabilityTheory open MeasureTheory MeasurableSpace namespace ProbabilityTheory variable {Ω : Type*} [MeasurableSpace Ω] /-- Given a set `s`, `condCount s` is the counting measure conditioned on `s`. In particular, `condCount s t` is the proportion of `s` that is contained in `t`. This is a probability measure when `s` is finite and nonempty and is given by `ProbabilityTheory.condCount_isProbabilityMeasure`. -/ def condCount (s : Set Ω) : Measure Ω := Measure.count[|s] #align probability_theory.cond_count ProbabilityTheory.condCount @[simp] theorem condCount_empty_meas : (condCount ∅ : Measure Ω) = 0 := by simp [condCount] #align probability_theory.cond_count_empty_meas ProbabilityTheory.condCount_empty_meas theorem condCount_empty {s : Set Ω} : condCount s ∅ = 0 := by simp #align probability_theory.cond_count_empty ProbabilityTheory.condCount_empty theorem finite_of_condCount_ne_zero {s t : Set Ω} (h : condCount s t ≠ 0) : s.Finite := by by_contra hs' simp [condCount, cond, Measure.count_apply_infinite hs'] at h #align probability_theory.finite_of_cond_count_ne_zero ProbabilityTheory.finite_of_condCount_ne_zero theorem condCount_univ [Fintype Ω] {s : Set Ω} : condCount Set.univ s = Measure.count s / Fintype.card Ω := by rw [condCount, cond_apply _ MeasurableSet.univ, ← ENNReal.div_eq_inv_mul, Set.univ_inter] congr rw [← Finset.coe_univ, Measure.count_apply, Finset.univ.tsum_subtype' fun _ => (1 : ENNReal)] · simp [Finset.card_univ] · exact (@Finset.coe_univ Ω _).symm ▸ MeasurableSet.univ #align probability_theory.cond_count_univ ProbabilityTheory.condCount_univ variable [MeasurableSingletonClass Ω] theorem condCount_isProbabilityMeasure {s : Set Ω} (hs : s.Finite) (hs' : s.Nonempty) : IsProbabilityMeasure (condCount s) := { measure_univ := by rw [condCount, cond_apply _ hs.measurableSet, Set.inter_univ, ENNReal.inv_mul_cancel] · exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h · exact (Measure.count_apply_lt_top.2 hs).ne } #align probability_theory.cond_count_is_probability_measure ProbabilityTheory.condCount_isProbabilityMeasure theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] : condCount {ω} t = if ω ∈ t then 1 else 0 := by rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one, one_mul] split_ifs · rw [(by simpa : ({ω} : Set Ω) ∩ t = {ω}), Measure.count_singleton] · rw [(by simpa : ({ω} : Set Ω) ∩ t = ∅), Measure.count_empty] #align probability_theory.cond_count_singleton ProbabilityTheory.condCount_singleton variable {s t u : Set Ω} theorem condCount_inter_self (hs : s.Finite) : condCount s (s ∩ t) = condCount s t := by rw [condCount, cond_inter_self _ hs.measurableSet] #align probability_theory.cond_count_inter_self ProbabilityTheory.condCount_inter_self theorem condCount_self (hs : s.Finite) (hs' : s.Nonempty) : condCount s s = 1 := by rw [condCount, cond_apply _ hs.measurableSet, Set.inter_self, ENNReal.inv_mul_cancel] · exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h · exact (Measure.count_apply_lt_top.2 hs).ne #align probability_theory.cond_count_self ProbabilityTheory.condCount_self
Mathlib/Probability/CondCount.lean
110
115
theorem condCount_eq_one_of (hs : s.Finite) (hs' : s.Nonempty) (ht : s ⊆ t) : condCount s t = 1 := by
haveI := condCount_isProbabilityMeasure hs hs' refine eq_of_le_of_not_lt prob_le_one ?_ rw [not_lt, ← condCount_self hs hs'] exact measure_mono ht
/- Copyright (c) 2023 Amelia Livingston. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Amelia Livingston, Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.ModuleCat import Mathlib.RepresentationTheory.GroupCohomology.Basic import Mathlib.RepresentationTheory.Invariants /-! # The low-degree cohomology of a `k`-linear `G`-representation Let `k` be a commutative ring and `G` a group. This file gives simple expressions for the group cohomology of a `k`-linear `G`-representation `A` in degrees 0, 1 and 2. In `RepresentationTheory.GroupCohomology.Basic`, we define the `n`th group cohomology of `A` to be the cohomology of a complex `inhomogeneousCochains A`, whose objects are `(Fin n → G) → A`; this is unnecessarily unwieldy in low degree. Moreover, cohomology of a complex is defined as an abstract cokernel, whereas the definitions here are explicit quotients of cocycles by coboundaries. We also show that when the representation on `A` is trivial, `H¹(G, A) ≃ Hom(G, A)`. Given an additive or multiplicative abelian group `A` with an appropriate scalar action of `G`, we provide support for turning a function `f : G → A` satisfying the 1-cocycle identity into an element of the `oneCocycles` of the representation on `A` (or `Additive A`) corresponding to the scalar action. We also do this for 1-coboundaries, 2-cocycles and 2-coboundaries. The multiplicative case, starting with the section `IsMulCocycle`, just mirrors the additive case; unfortunately `@[to_additive]` can't deal with scalar actions. The file also contains an identification between the definitions in `RepresentationTheory.GroupCohomology.Basic`, `groupCohomology.cocycles A n` and `groupCohomology A n`, and the `nCocycles` and `Hn A` in this file, for `n = 0, 1, 2`. ## Main definitions * `groupCohomology.H0 A`: the invariants `Aᴳ` of the `G`-representation on `A`. * `groupCohomology.H1 A`: 1-cocycles (i.e. `Z¹(G, A) := Ker(d¹ : Fun(G, A) → Fun(G², A)`) modulo 1-coboundaries (i.e. `B¹(G, A) := Im(d⁰: A → Fun(G, A))`). * `groupCohomology.H2 A`: 2-cocycles (i.e. `Z²(G, A) := Ker(d² : Fun(G², A) → Fun(G³, A)`) modulo 2-coboundaries (i.e. `B²(G, A) := Im(d¹: Fun(G, A) → Fun(G², A))`). * `groupCohomology.H1LequivOfIsTrivial`: the isomorphism `H¹(G, A) ≃ Hom(G, A)` when the representation on `A` is trivial. * `groupCohomology.isoHn` for `n = 0, 1, 2`: an isomorphism `groupCohomology A n ≅ groupCohomology.Hn A`. ## TODO * The relationship between `H2` and group extensions * The inflation-restriction exact sequence * Nonabelian group cohomology -/ universe v u noncomputable section open CategoryTheory Limits Representation variable {k G : Type u} [CommRing k] [Group G] (A : Rep k G) namespace groupCohomology section Cochains /-- The 0th object in the complex of inhomogeneous cochains of `A : Rep k G` is isomorphic to `A` as a `k`-module. -/ def zeroCochainsLequiv : (inhomogeneousCochains A).X 0 ≃ₗ[k] A := LinearEquiv.funUnique (Fin 0 → G) k A /-- The 1st object in the complex of inhomogeneous cochains of `A : Rep k G` is isomorphic to `Fun(G, A)` as a `k`-module. -/ def oneCochainsLequiv : (inhomogeneousCochains A).X 1 ≃ₗ[k] G → A := LinearEquiv.funCongrLeft k A (Equiv.funUnique (Fin 1) G).symm /-- The 2nd object in the complex of inhomogeneous cochains of `A : Rep k G` is isomorphic to `Fun(G², A)` as a `k`-module. -/ def twoCochainsLequiv : (inhomogeneousCochains A).X 2 ≃ₗ[k] G × G → A := LinearEquiv.funCongrLeft k A <| (piFinTwoEquiv fun _ => G).symm /-- The 3rd object in the complex of inhomogeneous cochains of `A : Rep k G` is isomorphic to `Fun(G³, A)` as a `k`-module. -/ def threeCochainsLequiv : (inhomogeneousCochains A).X 3 ≃ₗ[k] G × G × G → A := LinearEquiv.funCongrLeft k A <| ((Equiv.piFinSucc 2 G).trans ((Equiv.refl G).prodCongr (piFinTwoEquiv fun _ => G))).symm end Cochains section Differentials /-- The 0th differential in the complex of inhomogeneous cochains of `A : Rep k G`, as a `k`-linear map `A → Fun(G, A)`. It sends `(a, g) ↦ ρ_A(g)(a) - a.` -/ @[simps] def dZero : A →ₗ[k] G → A where toFun m g := A.ρ g m - m map_add' x y := funext fun g => by simp only [map_add, add_sub_add_comm]; rfl map_smul' r x := funext fun g => by dsimp; rw [map_smul, smul_sub]
Mathlib/RepresentationTheory/GroupCohomology/LowDegree.lean
100
103
theorem dZero_ker_eq_invariants : LinearMap.ker (dZero A) = invariants A.ρ := by
ext x simp only [LinearMap.mem_ker, mem_invariants, ← @sub_eq_zero _ _ _ x, Function.funext_iff] rfl
/- Copyright (c) 2020 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis -/ import Batteries.Tactic.Lint.Basic import Mathlib.Algebra.Order.Monoid.Unbundled.Basic import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Order.ZeroLEOne import Mathlib.Data.Nat.Cast.Order import Mathlib.Init.Data.Int.Order /-! # Lemmas for `linarith`. Those in the `Linarith` namespace should stay here. Those outside the `Linarith` namespace may be deleted as they are ported to mathlib4. -/ set_option autoImplicit true namespace Linarith theorem lt_irrefl {α : Type u} [Preorder α] {a : α} : ¬a < a := _root_.lt_irrefl a theorem eq_of_eq_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b = 0) : a + b = 0 := by simp [*]
Mathlib/Tactic/Linarith/Lemmas.lean
30
31
theorem le_of_eq_of_le {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b ≤ 0) : a + b ≤ 0 := by
simp [*]
/- Copyright (c) 2022 Wrenna Robson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Wrenna Robson -/ import Mathlib.Topology.MetricSpace.Basic #align_import topology.metric_space.infsep from "leanprover-community/mathlib"@"5316314b553dcf8c6716541851517c1a9715e22b" /-! # Infimum separation This file defines the extended infimum separation of a set. This is approximately dual to the diameter of a set, but where the extended diameter of a set is the supremum of the extended distance between elements of the set, the extended infimum separation is the infimum of the (extended) distance between *distinct* elements in the set. We also define the infimum separation as the cast of the extended infimum separation to the reals. This is the infimum of the distance between distinct elements of the set when in a pseudometric space. All lemmas and definitions are in the `Set` namespace to give access to dot notation. ## Main definitions * `Set.einfsep`: Extended infimum separation of a set. * `Set.infsep`: Infimum separation of a set (when in a pseudometric space). !-/ variable {α β : Type*} namespace Set section Einfsep open ENNReal open Function /-- The "extended infimum separation" of a set with an edist function. -/ noncomputable def einfsep [EDist α] (s : Set α) : ℝ≥0∞ := ⨅ (x ∈ s) (y ∈ s) (_ : x ≠ y), edist x y #align set.einfsep Set.einfsep section EDist variable [EDist α] {x y : α} {s t : Set α} theorem le_einfsep_iff {d} : d ≤ s.einfsep ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y := by simp_rw [einfsep, le_iInf_iff] #align set.le_einfsep_iff Set.le_einfsep_iff theorem einfsep_zero : s.einfsep = 0 ↔ ∀ C > 0, ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < C := by simp_rw [einfsep, ← _root_.bot_eq_zero, iInf_eq_bot, iInf_lt_iff, exists_prop] #align set.einfsep_zero Set.einfsep_zero theorem einfsep_pos : 0 < s.einfsep ↔ ∃ C > 0, ∀ x ∈ s, ∀ y ∈ s, x ≠ y → C ≤ edist x y := by rw [pos_iff_ne_zero, Ne, einfsep_zero] simp only [not_forall, not_exists, not_lt, exists_prop, not_and] #align set.einfsep_pos Set.einfsep_pos theorem einfsep_top : s.einfsep = ∞ ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → edist x y = ∞ := by simp_rw [einfsep, iInf_eq_top] #align set.einfsep_top Set.einfsep_top theorem einfsep_lt_top : s.einfsep < ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < ∞ := by simp_rw [einfsep, iInf_lt_iff, exists_prop] #align set.einfsep_lt_top Set.einfsep_lt_top theorem einfsep_ne_top : s.einfsep ≠ ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y ≠ ∞ := by simp_rw [← lt_top_iff_ne_top, einfsep_lt_top] #align set.einfsep_ne_top Set.einfsep_ne_top theorem einfsep_lt_iff {d} : s.einfsep < d ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < d := by simp_rw [einfsep, iInf_lt_iff, exists_prop] #align set.einfsep_lt_iff Set.einfsep_lt_iff theorem nontrivial_of_einfsep_lt_top (hs : s.einfsep < ∞) : s.Nontrivial := by rcases einfsep_lt_top.1 hs with ⟨_, hx, _, hy, hxy, _⟩ exact ⟨_, hx, _, hy, hxy⟩ #align set.nontrivial_of_einfsep_lt_top Set.nontrivial_of_einfsep_lt_top theorem nontrivial_of_einfsep_ne_top (hs : s.einfsep ≠ ∞) : s.Nontrivial := nontrivial_of_einfsep_lt_top (lt_top_iff_ne_top.mpr hs) #align set.nontrivial_of_einfsep_ne_top Set.nontrivial_of_einfsep_ne_top theorem Subsingleton.einfsep (hs : s.Subsingleton) : s.einfsep = ∞ := by rw [einfsep_top] exact fun _ hx _ hy hxy => (hxy <| hs hx hy).elim #align set.subsingleton.einfsep Set.Subsingleton.einfsep
Mathlib/Topology/MetricSpace/Infsep.lean
98
100
theorem le_einfsep_image_iff {d} {f : β → α} {s : Set β} : d ≤ einfsep (f '' s) ↔ ∀ x ∈ s, ∀ y ∈ s, f x ≠ f y → d ≤ edist (f x) (f y) := by
simp_rw [le_einfsep_iff, forall_mem_image]
/- Copyright (c) 2021 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Thomas Murrills -/ import Mathlib.Data.Int.Cast.Lemmas import Mathlib.Tactic.NormNum.Basic /-! ## `norm_num` plugin for `^`. -/ set_option autoImplicit true namespace Mathlib open Lean hiding Rat mkRat open Meta namespace Meta.NormNum open Qq theorem natPow_zero : Nat.pow a (nat_lit 0) = nat_lit 1 := rfl theorem natPow_one : Nat.pow a (nat_lit 1) = a := Nat.pow_one _ theorem zero_natPow : Nat.pow (nat_lit 0) (Nat.succ b) = nat_lit 0 := rfl theorem one_natPow : Nat.pow (nat_lit 1) b = nat_lit 1 := Nat.one_pow _ /-- This is an opaque wrapper around `Nat.pow` to prevent lean from unfolding the definition of `Nat.pow` on numerals. The arbitrary precondition `p` is actually a formula of the form `Nat.pow a' b' = c'` but we usually don't care to unfold this proposition so we just carry a reference to it. -/ structure IsNatPowT (p : Prop) (a b c : Nat) : Prop where /-- Unfolds the assertion. -/ run' : p → Nat.pow a b = c theorem IsNatPowT.run (p : IsNatPowT (Nat.pow a (nat_lit 1) = a) a b c) : Nat.pow a b = c := p.run' (Nat.pow_one _) /-- This is the key to making the proof proceed as a balanced tree of applications instead of a linear sequence. It is just modus ponens after unwrapping the definitions. -/ theorem IsNatPowT.trans (h1 : IsNatPowT p a b c) (h2 : IsNatPowT (Nat.pow a b = c) a b' c') : IsNatPowT p a b' c' := ⟨h2.run' ∘ h1.run'⟩ theorem IsNatPowT.bit0 : IsNatPowT (Nat.pow a b = c) a (nat_lit 2 * b) (Nat.mul c c) := ⟨fun h1 => by simp [two_mul, pow_add, ← h1]⟩ theorem IsNatPowT.bit1 : IsNatPowT (Nat.pow a b = c) a (nat_lit 2 * b + nat_lit 1) (Nat.mul c (Nat.mul c a)) := ⟨fun h1 => by simp [two_mul, pow_add, mul_assoc, ← h1]⟩ /-- Proves `Nat.pow a b = c` where `a` and `b` are raw nat literals. This could be done by just `rfl` but the kernel does not have a special case implementation for `Nat.pow` so this would proceed by unary recursion on `b`, which is too slow and also leads to deep recursion. We instead do the proof by binary recursion, but this can still lead to deep recursion, so we use an additional trick to do binary subdivision on `log2 b`. As a result this produces a proof of depth `log (log b)` which will essentially never overflow before the numbers involved themselves exceed memory limits. -/ partial def evalNatPow (a b : Q(ℕ)) : (c : Q(ℕ)) × Q(Nat.pow $a $b = $c) := if b.natLit! = 0 then haveI : $b =Q 0 := ⟨⟩ ⟨q(nat_lit 1), q(natPow_zero)⟩ else if a.natLit! = 0 then haveI : $a =Q 0 := ⟨⟩ have b' : Q(ℕ) := mkRawNatLit (b.natLit! - 1) haveI : $b =Q Nat.succ $b' := ⟨⟩ ⟨q(nat_lit 0), q(zero_natPow)⟩ else if a.natLit! = 1 then haveI : $a =Q 1 := ⟨⟩ ⟨q(nat_lit 1), q(one_natPow)⟩ else if b.natLit! = 1 then haveI : $b =Q 1 := ⟨⟩ ⟨a, q(natPow_one)⟩ else let ⟨c, p⟩ := go b.natLit!.log2 a (mkRawNatLit 1) a b _ .rfl ⟨c, q(($p).run)⟩ where /-- Invariants: `a ^ b₀ = c₀`, `depth > 0`, `b >>> depth = b₀`, `p := Nat.pow $a $b₀ = $c₀` -/ go (depth : Nat) (a b₀ c₀ b : Q(ℕ)) (p : Q(Prop)) (hp : $p =Q (Nat.pow $a $b₀ = $c₀)) : (c : Q(ℕ)) × Q(IsNatPowT $p $a $b $c) := let b' := b.natLit! if depth ≤ 1 then let a' := a.natLit! let c₀' := c₀.natLit! if b' &&& 1 == 0 then have c : Q(ℕ) := mkRawNatLit (c₀' * c₀') haveI : $c =Q Nat.mul $c₀ $c₀ := ⟨⟩ haveI : $b =Q 2 * $b₀ := ⟨⟩ ⟨c, q(IsNatPowT.bit0)⟩ else have c : Q(ℕ) := mkRawNatLit (c₀' * (c₀' * a')) haveI : $c =Q Nat.mul $c₀ (Nat.mul $c₀ $a) := ⟨⟩ haveI : $b =Q 2 * $b₀ + 1 := ⟨⟩ ⟨c, q(IsNatPowT.bit1)⟩ else let d := depth >>> 1 have hi : Q(ℕ) := mkRawNatLit (b' >>> d) let ⟨c1, p1⟩ := go (depth - d) a b₀ c₀ hi p (by exact hp) let ⟨c2, p2⟩ := go d a hi c1 b q(Nat.pow $a $hi = $c1) ⟨⟩ ⟨c2, q(($p1).trans $p2)⟩ theorem intPow_ofNat (h1 : Nat.pow a b = c) : Int.pow (Int.ofNat a) b = Int.ofNat c := by simp [← h1]
Mathlib/Tactic/NormNum/Pow.lean
105
110
theorem intPow_negOfNat_bit0 (h1 : Nat.pow a b' = c') (hb : nat_lit 2 * b' = b) (hc : c' * c' = c) : Int.pow (Int.negOfNat a) b = Int.ofNat c := by
rw [← hb, Int.negOfNat_eq, Int.pow_eq, pow_mul, neg_pow_two, ← pow_mul, two_mul, pow_add, ← hc, ← h1] simp
/- Copyright (c) 2022 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.Algebra.Order.Chebyshev import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Order.Partition.Equipartition #align_import combinatorics.simple_graph.regularity.bound from "leanprover-community/mathlib"@"bf7ef0e83e5b7e6c1169e97f055e58a2e4e9d52d" /-! # Numerical bounds for Szemerédi Regularity Lemma This file gathers the numerical facts required by the proof of Szemerédi's regularity lemma. This entire file is internal to the proof of Szemerédi Regularity Lemma. ## Main declarations * `SzemerediRegularity.stepBound`: During the inductive step, a partition of size `n` is blown to size at most `stepBound n`. * `SzemerediRegularity.initialBound`: The size of the partition we start the induction with. * `SzemerediRegularity.bound`: The upper bound on the size of the partition produced by our version of Szemerédi's regularity lemma. ## References [Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp] -/ open Finset Fintype Function Real namespace SzemerediRegularity /-- Auxiliary function for Szemerédi's regularity lemma. Blowing up a partition of size `n` during the induction results in a partition of size at most `stepBound n`. -/ def stepBound (n : ℕ) : ℕ := n * 4 ^ n #align szemeredi_regularity.step_bound SzemerediRegularity.stepBound theorem le_stepBound : id ≤ stepBound := fun n => Nat.le_mul_of_pos_right _ <| pow_pos (by norm_num) n #align szemeredi_regularity.le_step_bound SzemerediRegularity.le_stepBound theorem stepBound_mono : Monotone stepBound := fun a b h => Nat.mul_le_mul h <| Nat.pow_le_pow_of_le_right (by norm_num) h #align szemeredi_regularity.step_bound_mono SzemerediRegularity.stepBound_mono theorem stepBound_pos_iff {n : ℕ} : 0 < stepBound n ↔ 0 < n := mul_pos_iff_of_pos_right <| by positivity #align szemeredi_regularity.step_bound_pos_iff SzemerediRegularity.stepBound_pos_iff alias ⟨_, stepBound_pos⟩ := stepBound_pos_iff #align szemeredi_regularity.step_bound_pos SzemerediRegularity.stepBound_pos @[norm_cast] lemma coe_stepBound {α : Type*} [Semiring α] (n : ℕ) : (stepBound n : α) = n * 4 ^ n := by unfold stepBound; norm_cast end SzemerediRegularity open SzemerediRegularity variable {α : Type*} [DecidableEq α] [Fintype α] {P : Finpartition (univ : Finset α)} {u : Finset α} {ε : ℝ} local notation3 "m" => (card α / stepBound P.parts.card : ℕ) local notation3 "a" => (card α / P.parts.card - m * 4 ^ P.parts.card : ℕ) namespace SzemerediRegularity.Positivity private theorem eps_pos {ε : ℝ} {n : ℕ} (h : 100 ≤ (4 : ℝ) ^ n * ε ^ 5) : 0 < ε := (Odd.pow_pos_iff (by decide)).mp (pos_of_mul_pos_right ((show 0 < (100 : ℝ) by norm_num).trans_le h) (by positivity)) private theorem m_pos [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) : 0 < m := Nat.div_pos ((Nat.mul_le_mul_left _ <| Nat.pow_le_pow_left (by norm_num) _).trans hPα) <| stepBound_pos (P.parts_nonempty <| univ_nonempty.ne_empty).card_pos /-- Local extension for the `positivity` tactic: A few facts that are needed many times for the proof of Szemerédi's regularity lemma. -/ -- Porting note: positivity extensions must now be global, and this did not seem like a good -- match for positivity anymore, so I wrote a new tactic (kmill) scoped macro "sz_positivity" : tactic => `(tactic| { try have := m_pos ‹_› try have := eps_pos ‹_› positivity }) -- Original meta code /- meta def positivity_szemeredi_regularity : expr → tactic strictness | `(%%n / step_bound (finpartition.parts %%P).card) := do p ← to_expr ``((finpartition.parts %%P).card * 16^(finpartition.parts %%P).card ≤ %%n) >>= find_assumption, positive <$> mk_app ``m_pos [p] | ε := do typ ← infer_type ε, unify typ `(ℝ), p ← to_expr ``(100 ≤ 4 ^ _ * %%ε ^ 5) >>= find_assumption, positive <$> mk_app ``eps_pos [p] -/ end SzemerediRegularity.Positivity namespace SzemerediRegularity open scoped SzemerediRegularity.Positivity theorem m_pos [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) : 0 < m := by sz_positivity #align szemeredi_regularity.m_pos SzemerediRegularity.m_pos
Mathlib/Combinatorics/SimpleGraph/Regularity/Bound.lean
115
115
theorem coe_m_add_one_pos : 0 < (m : ℝ) + 1 := by
positivity
/- Copyright (c) 2020 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey -/ import Mathlib.Data.Fintype.Basic import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.Zify import Mathlib.Data.Nat.Totient #align_import number_theory.lucas_primality from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # The Lucas test for primes. This file implements the Lucas test for primes (not to be confused with the Lucas-Lehmer test for Mersenne primes). A number `a` witnesses that `n` is prime if `a` has order `n-1` in the multiplicative group of integers mod `n`. This is checked by verifying that `a^(n-1) = 1 (mod n)` and `a^d ≠ 1 (mod n)` for any divisor `d | n - 1`. This test is the basis of the Pratt primality certificate. ## TODO - Bonus: Show the reverse implication i.e. if a number is prime then it has a Lucas witness. Use `Units.IsCyclic` from `RingTheory/IntegralDomain` to show the group is cyclic. - Write a tactic that uses this theorem to generate Pratt primality certificates - Integrate Pratt primality certificates into the norm_num primality verifier ## Implementation notes Note that the proof for `lucas_primality` relies on analyzing the multiplicative group modulo `p`. Despite this, the theorem still holds vacuously for `p = 0` and `p = 1`: In these cases, we can take `q` to be any prime and see that `hd` does not hold, since `a^((p-1)/q)` reduces to `1`. -/ /-- If `a^(p-1) = 1 mod p`, but `a^((p-1)/q) ≠ 1 mod p` for all prime factors `q` of `p-1`, then `p` is prime. This is true because `a` has order `p-1` in the multiplicative group mod `p`, so this group must itself have order `p-1`, which only happens when `p` is prime. -/
Mathlib/NumberTheory/LucasPrimality.lean
42
63
theorem lucas_primality (p : ℕ) (a : ZMod p) (ha : a ^ (p - 1) = 1) (hd : ∀ q : ℕ, q.Prime → q ∣ p - 1 → a ^ ((p - 1) / q) ≠ 1) : p.Prime := by
have h0 : p ≠ 0 := by rintro ⟨⟩ exact hd 2 Nat.prime_two (dvd_zero _) (pow_zero _) have h1 : p ≠ 1 := by rintro ⟨⟩ exact hd 2 Nat.prime_two (dvd_zero _) (pow_zero _) have hp1 : 1 < p := lt_of_le_of_ne h0.bot_lt h1.symm have order_of_a : orderOf a = p - 1 := by apply orderOf_eq_of_pow_and_pow_div_prime _ ha hd exact tsub_pos_of_lt hp1 haveI : NeZero p := ⟨h0⟩ rw [Nat.prime_iff_card_units] -- Prove cardinality of `Units` of `ZMod p` is both `≤ p-1` and `≥ p-1` refine le_antisymm (Nat.card_units_zmod_lt_sub_one hp1) ?_ have hp' : p - 2 + 1 = p - 1 := tsub_add_eq_add_tsub hp1 let a' : (ZMod p)ˣ := Units.mkOfMulEqOne a (a ^ (p - 2)) (by rw [← pow_succ', hp', ha]) calc p - 1 = orderOf a := order_of_a.symm _ = orderOf a' := (orderOf_injective (Units.coeHom (ZMod p)) Units.ext a') _ ≤ Fintype.card (ZMod p)ˣ := orderOf_le_card_univ
/- 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, Mario Carneiro -/ /-! # Definitions and properties of `coprime` -/ namespace Nat /-! ### `coprime` See also `nat.coprime_of_dvd` and `nat.coprime_of_dvd'` to prove `nat.Coprime m n`. -/ /-- `m` and `n` are coprime, or relatively prime, if their `gcd` is 1. -/ @[reducible] def Coprime (m n : Nat) : Prop := gcd m n = 1 instance (m n : Nat) : Decidable (Coprime m n) := inferInstanceAs (Decidable (_ = 1)) theorem coprime_iff_gcd_eq_one : Coprime m n ↔ gcd m n = 1 := .rfl theorem Coprime.gcd_eq_one : Coprime m n → gcd m n = 1 := id theorem Coprime.symm : Coprime n m → Coprime m n := (gcd_comm m n).trans theorem coprime_comm : Coprime n m ↔ Coprime m n := ⟨Coprime.symm, Coprime.symm⟩ theorem Coprime.dvd_of_dvd_mul_right (H1 : Coprime k n) (H2 : k ∣ m * n) : k ∣ m := by let t := dvd_gcd (Nat.dvd_mul_left k m) H2 rwa [gcd_mul_left, H1.gcd_eq_one, Nat.mul_one] at t theorem Coprime.dvd_of_dvd_mul_left (H1 : Coprime k m) (H2 : k ∣ m * n) : k ∣ n := H1.dvd_of_dvd_mul_right (by rwa [Nat.mul_comm]) theorem Coprime.gcd_mul_left_cancel (m : Nat) (H : Coprime k n) : gcd (k * m) n = gcd m n := have H1 : Coprime (gcd (k * m) n) k := by rw [Coprime, Nat.gcd_assoc, H.symm.gcd_eq_one, gcd_one_right] Nat.dvd_antisymm (dvd_gcd (H1.dvd_of_dvd_mul_left (gcd_dvd_left _ _)) (gcd_dvd_right _ _)) (gcd_dvd_gcd_mul_left _ _ _) theorem Coprime.gcd_mul_right_cancel (m : Nat) (H : Coprime k n) : gcd (m * k) n = gcd m n := by rw [Nat.mul_comm m k, H.gcd_mul_left_cancel m] theorem Coprime.gcd_mul_left_cancel_right (n : Nat) (H : Coprime k m) : gcd m (k * n) = gcd m n := by rw [gcd_comm m n, gcd_comm m (k * n), H.gcd_mul_left_cancel n] theorem Coprime.gcd_mul_right_cancel_right (n : Nat) (H : Coprime k m) : gcd m (n * k) = gcd m n := by rw [Nat.mul_comm n k, H.gcd_mul_left_cancel_right n] theorem coprime_div_gcd_div_gcd (H : 0 < gcd m n) : Coprime (m / gcd m n) (n / gcd m n) := by rw [coprime_iff_gcd_eq_one, gcd_div (gcd_dvd_left m n) (gcd_dvd_right m n), Nat.div_self H] theorem not_coprime_of_dvd_of_dvd (dgt1 : 1 < d) (Hm : d ∣ m) (Hn : d ∣ n) : ¬ Coprime m n := fun co => Nat.not_le_of_gt dgt1 <| Nat.le_of_dvd Nat.zero_lt_one <| by rw [← co.gcd_eq_one]; exact dvd_gcd Hm Hn theorem exists_coprime (m n : Nat) : ∃ m' n', Coprime m' n' ∧ m = m' * gcd m n ∧ n = n' * gcd m n := by cases eq_zero_or_pos (gcd m n) with | inl h0 => rw [gcd_eq_zero_iff] at h0 refine ⟨1, 1, gcd_one_left 1, ?_⟩ simp [h0] | inr hpos => exact ⟨_, _, coprime_div_gcd_div_gcd hpos, (Nat.div_mul_cancel (gcd_dvd_left m n)).symm, (Nat.div_mul_cancel (gcd_dvd_right m n)).symm⟩ theorem exists_coprime' (H : 0 < gcd m n) : ∃ g m' n', 0 < g ∧ Coprime m' n' ∧ m = m' * g ∧ n = n' * g := let ⟨m', n', h⟩ := exists_coprime m n; ⟨_, m', n', H, h⟩ theorem Coprime.mul (H1 : Coprime m k) (H2 : Coprime n k) : Coprime (m * n) k := (H1.gcd_mul_left_cancel n).trans H2 theorem Coprime.mul_right (H1 : Coprime k m) (H2 : Coprime k n) : Coprime k (m * n) := (H1.symm.mul H2.symm).symm
.lake/packages/batteries/Batteries/Data/Nat/Gcd.lean
87
91
theorem Coprime.coprime_dvd_left (H1 : m ∣ k) (H2 : Coprime k n) : Coprime m n := by
apply eq_one_of_dvd_one rw [Coprime] at H2 have := Nat.gcd_dvd_gcd_of_dvd_left n H1 rwa [← H2]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, Scott Morrison -/ import Mathlib.CategoryTheory.Subobject.Basic import Mathlib.CategoryTheory.Preadditive.Basic #align_import category_theory.subobject.factor_thru from "leanprover-community/mathlib"@"829895f162a1f29d0133f4b3538f4cd1fb5bffd3" /-! # Factoring through subobjects The predicate `h : P.Factors f`, for `P : Subobject Y` and `f : X ⟶ Y` asserts the existence of some `P.factorThru f : X ⟶ (P : C)` making the obvious diagram commute. -/ universe v₁ v₂ u₁ u₂ noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] namespace CategoryTheory namespace MonoOver /-- When `f : X ⟶ Y` and `P : MonoOver Y`, `P.Factors f` expresses that there exists a factorisation of `f` through `P`. Given `h : P.Factors f`, you can recover the morphism as `P.factorThru f h`. -/ def Factors {X Y : C} (P : MonoOver Y) (f : X ⟶ Y) : Prop := ∃ g : X ⟶ (P : C), g ≫ P.arrow = f #align category_theory.mono_over.factors CategoryTheory.MonoOver.Factors theorem factors_congr {X : C} {f g : MonoOver X} {Y : C} (h : Y ⟶ X) (e : f ≅ g) : f.Factors h ↔ g.Factors h := ⟨fun ⟨u, hu⟩ => ⟨u ≫ ((MonoOver.forget _).map e.hom).left, by simp [hu]⟩, fun ⟨u, hu⟩ => ⟨u ≫ ((MonoOver.forget _).map e.inv).left, by simp [hu]⟩⟩ #align category_theory.mono_over.factors_congr CategoryTheory.MonoOver.factors_congr /-- `P.factorThru f h` provides a factorisation of `f : X ⟶ Y` through some `P : MonoOver Y`, given the evidence `h : P.Factors f` that such a factorisation exists. -/ def factorThru {X Y : C} (P : MonoOver Y) (f : X ⟶ Y) (h : Factors P f) : X ⟶ (P : C) := Classical.choose h #align category_theory.mono_over.factor_thru CategoryTheory.MonoOver.factorThru end MonoOver namespace Subobject /-- When `f : X ⟶ Y` and `P : Subobject Y`, `P.Factors f` expresses that there exists a factorisation of `f` through `P`. Given `h : P.Factors f`, you can recover the morphism as `P.factorThru f h`. -/ def Factors {X Y : C} (P : Subobject Y) (f : X ⟶ Y) : Prop := Quotient.liftOn' P (fun P => P.Factors f) (by rintro P Q ⟨h⟩ apply propext constructor · rintro ⟨i, w⟩ exact ⟨i ≫ h.hom.left, by erw [Category.assoc, Over.w h.hom, w]⟩ · rintro ⟨i, w⟩ exact ⟨i ≫ h.inv.left, by erw [Category.assoc, Over.w h.inv, w]⟩) #align category_theory.subobject.factors CategoryTheory.Subobject.Factors @[simp] theorem mk_factors_iff {X Y Z : C} (f : Y ⟶ X) [Mono f] (g : Z ⟶ X) : (Subobject.mk f).Factors g ↔ (MonoOver.mk' f).Factors g := Iff.rfl #align category_theory.subobject.mk_factors_iff CategoryTheory.Subobject.mk_factors_iff theorem mk_factors_self (f : X ⟶ Y) [Mono f] : (mk f).Factors f := ⟨𝟙 _, by simp⟩ #align category_theory.subobject.mk_factors_self CategoryTheory.Subobject.mk_factors_self theorem factors_iff {X Y : C} (P : Subobject Y) (f : X ⟶ Y) : P.Factors f ↔ (representative.obj P).Factors f := Quot.inductionOn P fun _ => MonoOver.factors_congr _ (representativeIso _).symm #align category_theory.subobject.factors_iff CategoryTheory.Subobject.factors_iff theorem factors_self {X : C} (P : Subobject X) : P.Factors P.arrow := (factors_iff _ _).mpr ⟨𝟙 (P : C), by simp⟩ #align category_theory.subobject.factors_self CategoryTheory.Subobject.factors_self theorem factors_comp_arrow {X Y : C} {P : Subobject Y} (f : X ⟶ P) : P.Factors (f ≫ P.arrow) := (factors_iff _ _).mpr ⟨f, rfl⟩ #align category_theory.subobject.factors_comp_arrow CategoryTheory.Subobject.factors_comp_arrow theorem factors_of_factors_right {X Y Z : C} {P : Subobject Z} (f : X ⟶ Y) {g : Y ⟶ Z} (h : P.Factors g) : P.Factors (f ≫ g) := by induction' P using Quotient.ind' with P obtain ⟨g, rfl⟩ := h exact ⟨f ≫ g, by simp⟩ #align category_theory.subobject.factors_of_factors_right CategoryTheory.Subobject.factors_of_factors_right theorem factors_zero [HasZeroMorphisms C] {X Y : C} {P : Subobject Y} : P.Factors (0 : X ⟶ Y) := (factors_iff _ _).mpr ⟨0, by simp⟩ #align category_theory.subobject.factors_zero CategoryTheory.Subobject.factors_zero
Mathlib/CategoryTheory/Subobject/FactorThru.lean
107
110
theorem factors_of_le {Y Z : C} {P Q : Subobject Y} (f : Z ⟶ Y) (h : P ≤ Q) : P.Factors f → Q.Factors f := by
simp only [factors_iff] exact fun ⟨u, hu⟩ => ⟨u ≫ ofLE _ _ h, by simp [← hu]⟩