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 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Michael Stoll -/ import Mathlib.NumberTheory.LegendreSymbol.Basic import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.GaussSum #align_import number_theory.legendre_symbol.quadratic_reciprocity from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" /-! # Quadratic reciprocity. ## Main results We prove the law of quadratic reciprocity, see `legendreSym.quadratic_reciprocity` and `legendreSym.quadratic_reciprocity'`, as well as the interpretations in terms of existence of square roots depending on the congruence mod 4, `ZMod.exists_sq_eq_prime_iff_of_mod_four_eq_one` and `ZMod.exists_sq_eq_prime_iff_of_mod_four_eq_three`. We also prove the supplementary laws that give conditions for when `2` or `-2` is a square modulo a prime `p`: `legendreSym.at_two` and `ZMod.exists_sq_eq_two_iff` for `2` and `legendreSym.at_neg_two` and `ZMod.exists_sq_eq_neg_two_iff` for `-2`. ## Implementation notes The proofs use results for quadratic characters on arbitrary finite fields from `NumberTheory.LegendreSymbol.QuadraticChar.GaussSum`, which in turn are based on properties of quadratic Gauss sums as provided by `NumberTheory.LegendreSymbol.GaussSum`. ## Tags quadratic residue, quadratic nonresidue, Legendre symbol, quadratic reciprocity -/ open Nat section Values variable {p : ℕ} [Fact p.Prime] open ZMod /-! ### The value of the Legendre symbol at `2` and `-2` See `jacobiSym.at_two` and `jacobiSym.at_neg_two` for the corresponding statements for the Jacobi symbol. -/ namespace legendreSym variable (hp : p ≠ 2) /-- `legendreSym p 2` is given by `χ₈ p`. -/
Mathlib/NumberTheory/LegendreSymbol/QuadraticReciprocity.lean
60
62
theorem at_two : legendreSym p 2 = χ₈ p := by
have : (2 : ZMod p) = (2 : ℤ) := by norm_cast rw [legendreSym, ← this, quadraticChar_two ((ringChar_zmod_n p).substr hp), card p]
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Yaël Dillies -/ import Mathlib.Order.Cover import Mathlib.Order.Interval.Finset.Defs #align_import data.finset.locally_finite from "leanprover-community/mathlib"@"442a83d738cb208d3600056c489be16900ba701d" /-! # Intervals as finsets This file provides basic results about all the `Finset.Ixx`, which are defined in `Order.Interval.Finset.Defs`. In addition, it shows that in a locally finite order `≤` and `<` are the transitive closures of, respectively, `⩿` and `⋖`, which then leads to a characterization of monotone and strictly functions whose domain is a locally finite order. In particular, this file proves: * `le_iff_transGen_wcovBy`: `≤` is the transitive closure of `⩿` * `lt_iff_transGen_covBy`: `≤` is the transitive closure of `⩿` * `monotone_iff_forall_wcovBy`: Characterization of monotone functions * `strictMono_iff_forall_covBy`: Characterization of strictly monotone functions ## TODO This file was originally only about `Finset.Ico a b` where `a b : ℕ`. No care has yet been taken to generalize these lemmas properly and many lemmas about `Icc`, `Ioc`, `Ioo` are missing. In general, what's to do is taking the lemmas in `Data.X.Intervals` and abstract away the concrete structure. Complete the API. See https://github.com/leanprover-community/mathlib/pull/14448#discussion_r906109235 for some ideas. -/ assert_not_exists MonoidWithZero assert_not_exists Finset.sum open Function OrderDual open FinsetInterval variable {ι α : Type*} namespace Finset section Preorder variable [Preorder α] section LocallyFiniteOrder variable [LocallyFiniteOrder α] {a a₁ a₂ b b₁ b₂ c x : α} @[simp, aesop safe apply (rule_sets := [finsetNonempty])]
Mathlib/Order/Interval/Finset/Basic.lean
57
58
theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b := by
rw [← coe_nonempty, coe_Icc, Set.nonempty_Icc]
/- Copyright (c) 2022 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Analysis.NormedSpace.Units import Mathlib.Algebra.Algebra.Spectrum import Mathlib.Topology.ContinuousFunction.Algebra #align_import topology.continuous_function.units from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64" /-! # Units of continuous functions This file concerns itself with `C(X, M)ˣ` and `C(X, Mˣ)` when `X` is a topological space and `M` has some monoid structure compatible with its topology. -/ variable {X M R 𝕜 : Type*} [TopologicalSpace X] namespace ContinuousMap section Monoid variable [Monoid M] [TopologicalSpace M] [ContinuousMul M] /-- Equivalence between continuous maps into the units of a monoid with continuous multiplication and the units of the monoid of continuous maps. -/ -- Porting note: `simps` made bad `simp` lemmas (LHS simplifies) so we add them manually below @[to_additive (attr := simps apply_val_apply symm_apply_apply_val) "Equivalence between continuous maps into the additive units of an additive monoid with continuous addition and the additive units of the additive monoid of continuous maps."] def unitsLift : C(X, Mˣ) ≃ C(X, M)ˣ where toFun f := { val := ⟨fun x => f x, Units.continuous_val.comp f.continuous⟩ inv := ⟨fun x => ↑(f x)⁻¹, Units.continuous_val.comp (continuous_inv.comp f.continuous)⟩ val_inv := ext fun x => Units.mul_inv _ inv_val := ext fun x => Units.inv_mul _ } invFun f := { toFun := fun x => ⟨(f : C(X, M)) x, (↑f⁻¹ : C(X, M)) x, ContinuousMap.congr_fun f.mul_inv x, ContinuousMap.congr_fun f.inv_mul x⟩ continuous_toFun := continuous_induced_rng.2 <| (f : C(X, M)).continuous.prod_mk <| MulOpposite.continuous_op.comp (↑f⁻¹ : C(X, M)).continuous } left_inv f := by ext; rfl right_inv f := by ext; rfl #align continuous_map.units_lift ContinuousMap.unitsLift #align continuous_map.add_units_lift ContinuousMap.addUnitsLift -- Porting note: add manually because `simps` used `inv` and `simpNF` complained @[to_additive (attr := simp)] lemma unitsLift_apply_inv_apply (f : C(X, Mˣ)) (x : X) : (↑(ContinuousMap.unitsLift f)⁻¹ : C(X, M)) x = (f x)⁻¹ := rfl -- Porting note: add manually because `simps` used `inv` and `simpNF` complained @[to_additive (attr := simp)] lemma unitsLift_symm_apply_apply_inv' (f : C(X, M)ˣ) (x : X) : (ContinuousMap.unitsLift.symm f x)⁻¹ = (↑f⁻¹ : C(X, M)) x := by rfl end Monoid section NormedRing variable [NormedRing R] [CompleteSpace R] theorem continuous_isUnit_unit {f : C(X, R)} (h : ∀ x, IsUnit (f x)) : Continuous fun x => (h x).unit := by refine continuous_induced_rng.2 (Continuous.prod_mk f.continuous (MulOpposite.continuous_op.comp (continuous_iff_continuousAt.mpr fun x => ?_))) have := NormedRing.inverse_continuousAt (h x).unit simp only simp only [← Ring.inverse_unit, IsUnit.unit_spec] at this ⊢ exact this.comp (f.continuousAt x) #align normed_ring.is_unit_unit_continuous ContinuousMap.continuous_isUnit_unit -- Porting note: this had the worst namespace: `NormedRing` /-- Construct a continuous map into the group of units of a normed ring from a function into the normed ring and a proof that every element of the range is a unit. -/ @[simps] noncomputable def unitsOfForallIsUnit {f : C(X, R)} (h : ∀ x, IsUnit (f x)) : C(X, Rˣ) where toFun x := (h x).unit continuous_toFun := continuous_isUnit_unit h #align continuous_map.units_of_forall_is_unit ContinuousMap.unitsOfForallIsUnit instance canLift : CanLift C(X, R) C(X, Rˣ) (fun f => ⟨fun x => f x, Units.continuous_val.comp f.continuous⟩) fun f => ∀ x, IsUnit (f x) where prf f h := ⟨unitsOfForallIsUnit h, by ext; rfl⟩ #align continuous_map.can_lift ContinuousMap.canLift theorem isUnit_iff_forall_isUnit (f : C(X, R)) : IsUnit f ↔ ∀ x, IsUnit (f x) := Iff.intro (fun h => fun x => ⟨unitsLift.symm h.unit x, rfl⟩) fun h => ⟨ContinuousMap.unitsLift (unitsOfForallIsUnit h), by ext; rfl⟩ #align continuous_map.is_unit_iff_forall_is_unit ContinuousMap.isUnit_iff_forall_isUnit end NormedRing section NormedField variable [NormedField 𝕜] [NormedDivisionRing R] [Algebra 𝕜 R] [CompleteSpace R] theorem isUnit_iff_forall_ne_zero (f : C(X, R)) : IsUnit f ↔ ∀ x, f x ≠ 0 := by simp_rw [f.isUnit_iff_forall_isUnit, isUnit_iff_ne_zero] #align continuous_map.is_unit_iff_forall_ne_zero ContinuousMap.isUnit_iff_forall_ne_zero theorem spectrum_eq_preimage_range (f : C(X, R)) : spectrum 𝕜 f = algebraMap _ _ ⁻¹' Set.range f := by ext x simp only [spectrum.mem_iff, isUnit_iff_forall_ne_zero, not_forall, sub_apply, algebraMap_apply, mul_one, Classical.not_not, Set.mem_range, sub_eq_zero, @eq_comm _ (x • 1 : R) _, Set.mem_preimage, Algebra.algebraMap_eq_smul_one, smul_apply, one_apply]
Mathlib/Topology/ContinuousFunction/Units.lean
120
122
theorem spectrum_eq_range [CompleteSpace 𝕜] (f : C(X, 𝕜)) : spectrum 𝕜 f = Set.range f := by
rw [spectrum_eq_preimage_range, Algebra.id.map_eq_id] exact Set.preimage_id
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.Complex.AbsMax import Mathlib.Analysis.Asymptotics.SuperpolynomialDecay #align_import analysis.complex.phragmen_lindelof from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Phragmen-Lindelöf principle In this file we prove several versions of the Phragmen-Lindelöf principle, a version of the maximum modulus principle for an unbounded domain. ## Main statements * `PhragmenLindelof.horizontal_strip`: the Phragmen-Lindelöf principle in a horizontal strip `{z : ℂ | a < complex.im z < b}`; * `PhragmenLindelof.eq_zero_on_horizontal_strip`, `PhragmenLindelof.eqOn_horizontal_strip`: extensionality lemmas based on the Phragmen-Lindelöf principle in a horizontal strip; * `PhragmenLindelof.vertical_strip`: the Phragmen-Lindelöf principle in a vertical strip `{z : ℂ | a < complex.re z < b}`; * `PhragmenLindelof.eq_zero_on_vertical_strip`, `PhragmenLindelof.eqOn_vertical_strip`: extensionality lemmas based on the Phragmen-Lindelöf principle in a vertical strip; * `PhragmenLindelof.quadrant_I`, `PhragmenLindelof.quadrant_II`, `PhragmenLindelof.quadrant_III`, `PhragmenLindelof.quadrant_IV`: the Phragmen-Lindelöf principle in the coordinate quadrants; * `PhragmenLindelof.right_half_plane_of_tendsto_zero_on_real`, `PhragmenLindelof.right_half_plane_of_bounded_on_real`: two versions of the Phragmen-Lindelöf principle in the right half-plane; * `PhragmenLindelof.eq_zero_on_right_half_plane_of_superexponential_decay`, `PhragmenLindelof.eqOn_right_half_plane_of_superexponential_decay`: extensionality lemmas based on the Phragmen-Lindelöf principle in the right half-plane. In the case of the right half-plane, we prove a version of the Phragmen-Lindelöf principle that is useful for Ilyashenko's proof of the individual finiteness theorem (a polynomial vector field on the real plane has only finitely many limit cycles). -/ open Set Function Filter Asymptotics Metric Complex Bornology open scoped Topology Filter Real local notation "expR" => Real.exp namespace PhragmenLindelof /-! ### Auxiliary lemmas -/ variable {E : Type*} [NormedAddCommGroup E] /-- An auxiliary lemma that combines two double exponential estimates into a similar estimate on the difference of the functions. -/ theorem isBigO_sub_exp_exp {a : ℝ} {f g : ℂ → E} {l : Filter ℂ} {u : ℂ → ℝ} (hBf : ∃ c < a, ∃ B, f =O[l] fun z => expR (B * expR (c * |u z|))) (hBg : ∃ c < a, ∃ B, g =O[l] fun z => expR (B * expR (c * |u z|))) : ∃ c < a, ∃ B, (f - g) =O[l] fun z => expR (B * expR (c * |u z|)) := by have : ∀ {c₁ c₂ B₁ B₂}, c₁ ≤ c₂ → 0 ≤ B₂ → B₁ ≤ B₂ → ∀ z, ‖expR (B₁ * expR (c₁ * |u z|))‖ ≤ ‖expR (B₂ * expR (c₂ * |u z|))‖ := fun hc hB₀ hB z ↦ by simp only [Real.norm_eq_abs, Real.abs_exp]; gcongr rcases hBf with ⟨cf, hcf, Bf, hOf⟩; rcases hBg with ⟨cg, hcg, Bg, hOg⟩ refine ⟨max cf cg, max_lt hcf hcg, max 0 (max Bf Bg), ?_⟩ refine (hOf.trans_le <| this ?_ ?_ ?_).sub (hOg.trans_le <| this ?_ ?_ ?_) exacts [le_max_left _ _, le_max_left _ _, (le_max_left _ _).trans (le_max_right _ _), le_max_right _ _, le_max_left _ _, (le_max_right _ _).trans (le_max_right _ _)] set_option linter.uppercaseLean3 false in #align phragmen_lindelof.is_O_sub_exp_exp PhragmenLindelof.isBigO_sub_exp_exp /-- An auxiliary lemma that combines two “exponential of a power” estimates into a similar estimate on the difference of the functions. -/
Mathlib/Analysis/Complex/PhragmenLindelof.lean
80
94
theorem isBigO_sub_exp_rpow {a : ℝ} {f g : ℂ → E} {l : Filter ℂ} (hBf : ∃ c < a, ∃ B, f =O[cobounded ℂ ⊓ l] fun z => expR (B * abs z ^ c)) (hBg : ∃ c < a, ∃ B, g =O[cobounded ℂ ⊓ l] fun z => expR (B * abs z ^ c)) : ∃ c < a, ∃ B, (f - g) =O[cobounded ℂ ⊓ l] fun z => expR (B * abs z ^ c) := by
have : ∀ {c₁ c₂ B₁ B₂ : ℝ}, c₁ ≤ c₂ → 0 ≤ B₂ → B₁ ≤ B₂ → (fun z : ℂ => expR (B₁ * abs z ^ c₁)) =O[cobounded ℂ ⊓ l] fun z => expR (B₂ * abs z ^ c₂) := fun hc hB₀ hB ↦ .of_bound 1 <| by filter_upwards [(eventually_cobounded_le_norm 1).filter_mono inf_le_left] with z hz simp only [one_mul, Real.norm_eq_abs, Real.abs_exp] gcongr; assumption rcases hBf with ⟨cf, hcf, Bf, hOf⟩; rcases hBg with ⟨cg, hcg, Bg, hOg⟩ refine ⟨max cf cg, max_lt hcf hcg, max 0 (max Bf Bg), ?_⟩ refine (hOf.trans <| this ?_ ?_ ?_).sub (hOg.trans <| this ?_ ?_ ?_) exacts [le_max_left _ _, le_max_left _ _, (le_max_left _ _).trans (le_max_right _ _), le_max_right _ _, le_max_left _ _, (le_max_right _ _).trans (le_max_right _ _)]
/- 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 [`data.finset.sym`@`98e83c3d541c77cdb7da20d79611a780ff8e7d90`..`02ba8949f486ebecf93fe7460f1ed0564b5e442c`](https://leanprover-community.github.io/mathlib-port-status/file/data/finset/sym?range=98e83c3d541c77cdb7da20d79611a780ff8e7d90..02ba8949f486ebecf93fe7460f1ed0564b5e442c) -/ import Mathlib.Data.Finset.Lattice import Mathlib.Data.Fintype.Vector import Mathlib.Data.Multiset.Sym #align_import data.finset.sym from "leanprover-community/mathlib"@"02ba8949f486ebecf93fe7460f1ed0564b5e442c" /-! # Symmetric powers of a finset This file defines the symmetric powers of a finset as `Finset (Sym α n)` and `Finset (Sym2 α)`. ## Main declarations * `Finset.sym`: The symmetric power of a finset. `s.sym n` is all the multisets of cardinality `n` whose elements are in `s`. * `Finset.sym2`: The symmetric square of a finset. `s.sym2` is all the pairs whose elements are in `s`. * A `Fintype (Sym2 α)` instance that does not require `DecidableEq α`. ## TODO `Finset.sym` forms a Galois connection between `Finset α` and `Finset (Sym α n)`. Similar for `Finset.sym2`. -/ namespace Finset variable {α : Type*} /-- `s.sym2` is the finset of all unordered pairs of elements from `s`. It is the image of `s ×ˢ s` under the quotient `α × α → Sym2 α`. -/ @[simps] protected def sym2 (s : Finset α) : Finset (Sym2 α) := ⟨s.1.sym2, s.2.sym2⟩ #align finset.sym2 Finset.sym2 section variable {s t : Finset α} {a b : α} theorem mk_mem_sym2_iff : s(a, b) ∈ s.sym2 ↔ a ∈ s ∧ b ∈ s := by rw [mem_mk, sym2_val, Multiset.mk_mem_sym2_iff, mem_mk, mem_mk] #align finset.mk_mem_sym2_iff Finset.mk_mem_sym2_iff @[simp] theorem mem_sym2_iff {m : Sym2 α} : m ∈ s.sym2 ↔ ∀ a ∈ m, a ∈ s := by rw [mem_mk, sym2_val, Multiset.mem_sym2_iff] simp only [mem_val] #align finset.mem_sym2_iff Finset.mem_sym2_iff instance _root_.Sym2.instFintype [Fintype α] : Fintype (Sym2 α) where elems := Finset.univ.sym2 complete := fun x ↦ by rw [mem_sym2_iff]; exact (fun a _ ↦ mem_univ a) -- Note(kmill): Using a default argument to make this simp lemma more general. @[simp] theorem sym2_univ [Fintype α] (inst : Fintype (Sym2 α) := Sym2.instFintype) : (univ : Finset α).sym2 = univ := by ext simp only [mem_sym2_iff, mem_univ, implies_true] #align finset.sym2_univ Finset.sym2_univ @[simp, mono] theorem sym2_mono (h : s ⊆ t) : s.sym2 ⊆ t.sym2 := by rw [← val_le_iff, sym2_val, sym2_val] apply Multiset.sym2_mono rwa [val_le_iff] #align finset.sym2_mono Finset.sym2_mono theorem monotone_sym2 : Monotone (Finset.sym2 : Finset α → _) := fun _ _ => sym2_mono theorem injective_sym2 : Function.Injective (Finset.sym2 : Finset α → _) := by intro s t h ext x simpa using congr(s(x, x) ∈ $h) theorem strictMono_sym2 : StrictMono (Finset.sym2 : Finset α → _) := monotone_sym2.strictMono_of_injective injective_sym2 theorem sym2_toFinset [DecidableEq α] (m : Multiset α) : m.toFinset.sym2 = m.sym2.toFinset := by ext z refine z.ind fun x y ↦ ?_ simp only [mk_mem_sym2_iff, Multiset.mem_toFinset, Multiset.mk_mem_sym2_iff] @[simp] theorem sym2_empty : (∅ : Finset α).sym2 = ∅ := rfl #align finset.sym2_empty Finset.sym2_empty @[simp] theorem sym2_eq_empty : s.sym2 = ∅ ↔ s = ∅ := by rw [← val_eq_zero, sym2_val, Multiset.sym2_eq_zero_iff, val_eq_zero] #align finset.sym2_eq_empty Finset.sym2_eq_empty @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem sym2_nonempty : s.sym2.Nonempty ↔ s.Nonempty := by rw [← not_iff_not] simp_rw [not_nonempty_iff_eq_empty, sym2_eq_empty] #align finset.sym2_nonempty Finset.sym2_nonempty protected alias ⟨_, Nonempty.sym2⟩ := sym2_nonempty #align finset.nonempty.sym2 Finset.Nonempty.sym2 @[simp] theorem sym2_singleton (a : α) : ({a} : Finset α).sym2 = {Sym2.diag a} := rfl #align finset.sym2_singleton Finset.sym2_singleton /-- Finset **stars and bars** for the case `n = 2`. -/
Mathlib/Data/Finset/Sym.lean
114
115
theorem card_sym2 (s : Finset α) : s.sym2.card = Nat.choose (s.card + 1) 2 := by
rw [card_def, sym2_val, Multiset.card_sym2, ← card_def]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Johan Commelin -/ import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.LinearAlgebra.TensorProduct.Tower import Mathlib.RingTheory.Adjoin.Basic import Mathlib.LinearAlgebra.DirectSum.Finsupp #align_import ring_theory.tensor_product from "leanprover-community/mathlib"@"88fcdc3da43943f5b01925deddaa5bf0c0e85e4e" /-! # The tensor product of R-algebras This file provides results about the multiplicative structure on `A ⊗[R] B` when `R` is a commutative (semi)ring and `A` and `B` are both `R`-algebras. On these tensor products, multiplication is characterized by `(a₁ ⊗ₜ b₁) * (a₂ ⊗ₜ b₂) = (a₁ * a₂) ⊗ₜ (b₁ * b₂)`. ## Main declarations - `LinearMap.baseChange A f` is the `A`-linear map `A ⊗ f`, for an `R`-linear map `f`. - `Algebra.TensorProduct.semiring`: the ring structure on `A ⊗[R] B` for two `R`-algebras `A`, `B`. - `Algebra.TensorProduct.leftAlgebra`: the `S`-algebra structure on `A ⊗[R] B`, for when `A` is additionally an `S` algebra. - the structure isomorphisms * `Algebra.TensorProduct.lid : R ⊗[R] A ≃ₐ[R] A` * `Algebra.TensorProduct.rid : A ⊗[R] R ≃ₐ[S] A` (usually used with `S = R` or `S = A`) * `Algebra.TensorProduct.comm : A ⊗[R] B ≃ₐ[R] B ⊗[R] A` * `Algebra.TensorProduct.assoc : ((A ⊗[R] B) ⊗[R] C) ≃ₐ[R] (A ⊗[R] (B ⊗[R] C))` - `Algebra.TensorProduct.liftEquiv`: a universal property for the tensor product of algebras. ## References * [C. Kassel, *Quantum Groups* (§II.4)][Kassel1995] -/ suppress_compilation open scoped TensorProduct open TensorProduct namespace LinearMap open TensorProduct /-! ### The base-change of a linear map of `R`-modules to a linear map of `A`-modules -/ section Semiring variable {R A B M N P : Type*} [CommSemiring R] variable [Semiring A] [Algebra R A] [Semiring B] [Algebra R B] variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] variable [Module R M] [Module R N] [Module R P] variable (r : R) (f g : M →ₗ[R] N) variable (A) /-- `baseChange A f` for `f : M →ₗ[R] N` is the `A`-linear map `A ⊗[R] M →ₗ[A] A ⊗[R] N`. This "base change" operation is also known as "extension of scalars". -/ def baseChange (f : M →ₗ[R] N) : A ⊗[R] M →ₗ[A] A ⊗[R] N := AlgebraTensorModule.map (LinearMap.id : A →ₗ[A] A) f #align linear_map.base_change LinearMap.baseChange variable {A} @[simp] theorem baseChange_tmul (a : A) (x : M) : f.baseChange A (a ⊗ₜ x) = a ⊗ₜ f x := rfl #align linear_map.base_change_tmul LinearMap.baseChange_tmul theorem baseChange_eq_ltensor : (f.baseChange A : A ⊗ M → A ⊗ N) = f.lTensor A := rfl #align linear_map.base_change_eq_ltensor LinearMap.baseChange_eq_ltensor @[simp] theorem baseChange_add : (f + g).baseChange A = f.baseChange A + g.baseChange A := by ext -- Porting note: added `-baseChange_tmul` simp [baseChange_eq_ltensor, -baseChange_tmul] #align linear_map.base_change_add LinearMap.baseChange_add @[simp] theorem baseChange_zero : baseChange A (0 : M →ₗ[R] N) = 0 := by ext simp [baseChange_eq_ltensor] #align linear_map.base_change_zero LinearMap.baseChange_zero @[simp]
Mathlib/RingTheory/TensorProduct/Basic.lean
96
98
theorem baseChange_smul : (r • f).baseChange A = r • f.baseChange A := by
ext simp [baseChange_tmul]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl -/ import Mathlib.MeasureTheory.Constructions.BorelSpace.Order #align_import measure_theory.function.simple_func from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf" /-! # Simple functions A function `f` from a measurable space to any type is called *simple*, if every preimage `f ⁻¹' {x}` is measurable, and the range is finite. In this file, we define simple functions and establish their basic properties; and we construct a sequence of simple functions approximating an arbitrary Borel measurable function `f : α → ℝ≥0∞`. The theorem `Measurable.ennreal_induction` shows that in order to prove something for an arbitrary measurable function into `ℝ≥0∞`, it is sufficient to show that the property holds for (multiples of) characteristic functions and is closed under addition and supremum of increasing sequences of functions. -/ noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory variable {α β γ δ : Type*} /-- A function `f` from a measurable space to any type is called *simple*, if every preimage `f ⁻¹' {x}` is measurable, and the range is finite. This structure bundles a function with these properties. -/ structure SimpleFunc.{u, v} (α : Type u) [MeasurableSpace α] (β : Type v) where toFun : α → β measurableSet_fiber' : ∀ x, MeasurableSet (toFun ⁻¹' {x}) finite_range' : (Set.range toFun).Finite #align measure_theory.simple_func MeasureTheory.SimpleFunc #align measure_theory.simple_func.to_fun MeasureTheory.SimpleFunc.toFun #align measure_theory.simple_func.measurable_set_fiber' MeasureTheory.SimpleFunc.measurableSet_fiber' #align measure_theory.simple_func.finite_range' MeasureTheory.SimpleFunc.finite_range' local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc section Measurable variable [MeasurableSpace α] attribute [coe] toFun instance instCoeFun : CoeFun (α →ₛ β) fun _ => α → β := ⟨toFun⟩ #align measure_theory.simple_func.has_coe_to_fun MeasureTheory.SimpleFunc.instCoeFun theorem coe_injective ⦃f g : α →ₛ β⦄ (H : (f : α → β) = g) : f = g := by cases f; cases g; congr #align measure_theory.simple_func.coe_injective MeasureTheory.SimpleFunc.coe_injective @[ext] theorem ext {f g : α →ₛ β} (H : ∀ a, f a = g a) : f = g := coe_injective <| funext H #align measure_theory.simple_func.ext MeasureTheory.SimpleFunc.ext theorem finite_range (f : α →ₛ β) : (Set.range f).Finite := f.finite_range' #align measure_theory.simple_func.finite_range MeasureTheory.SimpleFunc.finite_range theorem measurableSet_fiber (f : α →ₛ β) (x : β) : MeasurableSet (f ⁻¹' {x}) := f.measurableSet_fiber' x #align measure_theory.simple_func.measurable_set_fiber MeasureTheory.SimpleFunc.measurableSet_fiber -- @[simp] -- Porting note (#10618): simp can prove this theorem apply_mk (f : α → β) (h h') (x : α) : SimpleFunc.mk f h h' x = f x := rfl #align measure_theory.simple_func.apply_mk MeasureTheory.SimpleFunc.apply_mk /-- Simple function defined on a finite type. -/ def ofFinite [Finite α] [MeasurableSingletonClass α] (f : α → β) : α →ₛ β where toFun := f measurableSet_fiber' x := (toFinite (f ⁻¹' {x})).measurableSet finite_range' := Set.finite_range f @[deprecated (since := "2024-02-05")] alias ofFintype := ofFinite /-- Simple function defined on the empty type. -/ def ofIsEmpty [IsEmpty α] : α →ₛ β := ofFinite isEmptyElim #align measure_theory.simple_func.of_is_empty MeasureTheory.SimpleFunc.ofIsEmpty /-- Range of a simple function `α →ₛ β` as a `Finset β`. -/ protected def range (f : α →ₛ β) : Finset β := f.finite_range.toFinset #align measure_theory.simple_func.range MeasureTheory.SimpleFunc.range @[simp] theorem mem_range {f : α →ₛ β} {b} : b ∈ f.range ↔ b ∈ range f := Finite.mem_toFinset _ #align measure_theory.simple_func.mem_range MeasureTheory.SimpleFunc.mem_range theorem mem_range_self (f : α →ₛ β) (x : α) : f x ∈ f.range := mem_range.2 ⟨x, rfl⟩ #align measure_theory.simple_func.mem_range_self MeasureTheory.SimpleFunc.mem_range_self @[simp] theorem coe_range (f : α →ₛ β) : (↑f.range : Set β) = Set.range f := f.finite_range.coe_toFinset #align measure_theory.simple_func.coe_range MeasureTheory.SimpleFunc.coe_range theorem mem_range_of_measure_ne_zero {f : α →ₛ β} {x : β} {μ : Measure α} (H : μ (f ⁻¹' {x}) ≠ 0) : x ∈ f.range := let ⟨a, ha⟩ := nonempty_of_measure_ne_zero H mem_range.2 ⟨a, ha⟩ #align measure_theory.simple_func.mem_range_of_measure_ne_zero MeasureTheory.SimpleFunc.mem_range_of_measure_ne_zero
Mathlib/MeasureTheory/Function/SimpleFunc.lean
125
126
theorem forall_mem_range {f : α →ₛ β} {p : β → Prop} : (∀ y ∈ f.range, p y) ↔ ∀ x, p (f x) := by
simp only [mem_range, Set.forall_mem_range]
/- Copyright (c) 2022 Antoine Labelle, Rémi Bottinelli. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Labelle, Rémi Bottinelli -/ import Mathlib.Combinatorics.Quiver.Basic import Mathlib.Combinatorics.Quiver.Path #align_import combinatorics.quiver.cast from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" /-! # Rewriting arrows and paths along vertex equalities This files defines `Hom.cast` and `Path.cast` (and associated lemmas) in order to allow rewriting arrows and paths along equalities of their endpoints. -/ universe v v₁ v₂ u u₁ u₂ variable {U : Type*} [Quiver.{u + 1} U] namespace Quiver /-! ### Rewriting arrows along equalities of vertices -/ /-- Change the endpoints of an arrow using equalities. -/ def Hom.cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : u' ⟶ v' := Eq.ndrec (motive := (· ⟶ v')) (Eq.ndrec e hv) hu #align quiver.hom.cast Quiver.Hom.cast
Mathlib/Combinatorics/Quiver/Cast.lean
38
41
theorem Hom.cast_eq_cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : e.cast hu hv = _root_.cast (by {rw [hu, hv]}) e := by
subst_vars rfl
/- Copyright (c) 2023 Ruben Van de Velde. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ruben Van de Velde -/ import Mathlib.Algebra.MvPolynomial.Basic import Mathlib.Topology.Algebra.Ring.Basic /-! # Multivariate polynomials and continuity In this file we prove the following lemma: * `MvPolynomial.continuous_eval`: `MvPolynomial.eval` is continuous ## Tags multivariate polynomial, continuity -/ variable {X σ : Type*} [TopologicalSpace X] [CommSemiring X] [TopologicalSemiring X] (p : MvPolynomial σ X)
Mathlib/Topology/Algebra/MvPolynomial.lean
25
26
theorem MvPolynomial.continuous_eval : Continuous fun x ↦ eval x p := by
continuity
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Init.Function import Mathlib.Logic.Function.Basic import Mathlib.Tactic.Inhabit #align_import data.prod.basic from "leanprover-community/mathlib"@"d07245fd37786daa997af4f1a73a49fa3b748408" /-! # Extra facts about `Prod` This file defines `Prod.swap : α × β → β × α` and proves various simple lemmas about `Prod`. It also defines better delaborators for product projections. -/ variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} @[simp] theorem Prod.map_apply (f : α → γ) (g : β → δ) (p : α × β) : Prod.map f g p = (f p.1, g p.2) := rfl #align prod_map Prod.map_apply @[deprecated (since := "2024-05-08")] alias Prod_map := Prod.map_apply namespace Prod @[simp] theorem mk.eta : ∀ {p : α × β}, (p.1, p.2) = p | (_, _) => rfl @[simp] theorem «forall» {p : α × β → Prop} : (∀ x, p x) ↔ ∀ a b, p (a, b) := ⟨fun h a b ↦ h (a, b), fun h ⟨a, b⟩ ↦ h a b⟩ #align prod.forall Prod.forall @[simp] theorem «exists» {p : α × β → Prop} : (∃ x, p x) ↔ ∃ a b, p (a, b) := ⟨fun ⟨⟨a, b⟩, h⟩ ↦ ⟨a, b, h⟩, fun ⟨a, b, h⟩ ↦ ⟨⟨a, b⟩, h⟩⟩ #align prod.exists Prod.exists theorem forall' {p : α → β → Prop} : (∀ x : α × β, p x.1 x.2) ↔ ∀ a b, p a b := Prod.forall #align prod.forall' Prod.forall' theorem exists' {p : α → β → Prop} : (∃ x : α × β, p x.1 x.2) ↔ ∃ a b, p a b := Prod.exists #align prod.exists' Prod.exists' @[simp] theorem snd_comp_mk (x : α) : Prod.snd ∘ (Prod.mk x : β → α × β) = id := rfl #align prod.snd_comp_mk Prod.snd_comp_mk @[simp] theorem fst_comp_mk (x : α) : Prod.fst ∘ (Prod.mk x : β → α × β) = Function.const β x := rfl #align prod.fst_comp_mk Prod.fst_comp_mk @[simp, mfld_simps] theorem map_mk (f : α → γ) (g : β → δ) (a : α) (b : β) : map f g (a, b) = (f a, g b) := rfl #align prod.map_mk Prod.map_mk theorem map_fst (f : α → γ) (g : β → δ) (p : α × β) : (map f g p).1 = f p.1 := rfl #align prod.map_fst Prod.map_fst theorem map_snd (f : α → γ) (g : β → δ) (p : α × β) : (map f g p).2 = g p.2 := rfl #align prod.map_snd Prod.map_snd theorem map_fst' (f : α → γ) (g : β → δ) : Prod.fst ∘ map f g = f ∘ Prod.fst := funext <| map_fst f g #align prod.map_fst' Prod.map_fst' theorem map_snd' (f : α → γ) (g : β → δ) : Prod.snd ∘ map f g = g ∘ Prod.snd := funext <| map_snd f g #align prod.map_snd' Prod.map_snd' /-- Composing a `Prod.map` with another `Prod.map` is equal to a single `Prod.map` of composed functions. -/ theorem map_comp_map {ε ζ : Type*} (f : α → β) (f' : γ → δ) (g : β → ε) (g' : δ → ζ) : Prod.map g g' ∘ Prod.map f f' = Prod.map (g ∘ f) (g' ∘ f') := rfl #align prod.map_comp_map Prod.map_comp_map /-- Composing a `Prod.map` with another `Prod.map` is equal to a single `Prod.map` of composed functions, fully applied. -/ theorem map_map {ε ζ : Type*} (f : α → β) (f' : γ → δ) (g : β → ε) (g' : δ → ζ) (x : α × γ) : Prod.map g g' (Prod.map f f' x) = Prod.map (g ∘ f) (g' ∘ f') x := rfl #align prod.map_map Prod.map_map -- Porting note: mathlib3 proof uses `by cc` for the mpr direction -- Porting note: `@[simp]` tag removed because auto-generated `mk.injEq` simplifies LHS -- @[simp] theorem mk.inj_iff {a₁ a₂ : α} {b₁ b₂ : β} : (a₁, b₁) = (a₂, b₂) ↔ a₁ = a₂ ∧ b₁ = b₂ := Iff.of_eq (mk.injEq _ _ _ _) #align prod.mk.inj_iff Prod.mk.inj_iff theorem mk.inj_left {α β : Type*} (a : α) : Function.Injective (Prod.mk a : β → α × β) := by intro b₁ b₂ h simpa only [true_and, Prod.mk.inj_iff, eq_self_iff_true] using h #align prod.mk.inj_left Prod.mk.inj_left
Mathlib/Data/Prod/Basic.lean
110
113
theorem mk.inj_right {α β : Type*} (b : β) : Function.Injective (fun a ↦ Prod.mk a b : α → α × β) := by
intro b₁ b₂ h simpa only [and_true, eq_self_iff_true, mk.inj_iff] using h
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Complex.Arg import Mathlib.Analysis.SpecialFunctions.Log.Basic #align_import analysis.special_functions.complex.log from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # The complex `log` function Basic properties, relationship with `exp`. -/ noncomputable section namespace Complex open Set Filter Bornology open scoped Real Topology ComplexConjugate /-- Inverse of the `exp` function. Returns values such that `(log x).im > - π` and `(log x).im ≤ π`. `log 0 = 0`-/ -- Porting note: @[pp_nodot] does not exist in mathlib4 noncomputable def log (x : ℂ) : ℂ := x.abs.log + arg x * I #align complex.log Complex.log theorem log_re (x : ℂ) : x.log.re = x.abs.log := by simp [log] #align complex.log_re Complex.log_re theorem log_im (x : ℂ) : x.log.im = x.arg := by simp [log] #align complex.log_im Complex.log_im theorem neg_pi_lt_log_im (x : ℂ) : -π < (log x).im := by simp only [log_im, neg_pi_lt_arg] #align complex.neg_pi_lt_log_im Complex.neg_pi_lt_log_im theorem log_im_le_pi (x : ℂ) : (log x).im ≤ π := by simp only [log_im, arg_le_pi] #align complex.log_im_le_pi Complex.log_im_le_pi theorem exp_log {x : ℂ} (hx : x ≠ 0) : exp (log x) = x := by rw [log, exp_add_mul_I, ← ofReal_sin, sin_arg, ← ofReal_cos, cos_arg hx, ← ofReal_exp, Real.exp_log (abs.pos hx), mul_add, ofReal_div, ofReal_div, mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), ← mul_assoc, mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), re_add_im] #align complex.exp_log Complex.exp_log @[simp] theorem range_exp : Set.range exp = {0}ᶜ := Set.ext fun x => ⟨by rintro ⟨x, rfl⟩ exact exp_ne_zero x, fun hx => ⟨log x, exp_log hx⟩⟩ #align complex.range_exp Complex.range_exp theorem log_exp {x : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) : log (exp x) = x := by rw [log, abs_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, ← ofReal_exp, arg_mul_cos_add_sin_mul_I (Real.exp_pos _) ⟨hx₁, hx₂⟩, re_add_im] #align complex.log_exp Complex.log_exp theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) (hy₁ : -π < y.im) (hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y := by rw [← log_exp hx₁ hx₂, ← log_exp hy₁ hy₂, hxy] #align complex.exp_inj_of_neg_pi_lt_of_le_pi Complex.exp_inj_of_neg_pi_lt_of_le_pi theorem ofReal_log {x : ℝ} (hx : 0 ≤ x) : (x.log : ℂ) = log x := Complex.ext (by rw [log_re, ofReal_re, abs_of_nonneg hx]) (by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx]) #align complex.of_real_log Complex.ofReal_log @[simp, norm_cast] lemma natCast_log {n : ℕ} : Real.log n = log n := ofReal_natCast n ▸ ofReal_log n.cast_nonneg @[simp] lemma ofNat_log {n : ℕ} [n.AtLeastTwo] : Real.log (no_index (OfNat.ofNat n)) = log (OfNat.ofNat n) := natCast_log theorem log_ofReal_re (x : ℝ) : (log (x : ℂ)).re = Real.log x := by simp [log_re] #align complex.log_of_real_re Complex.log_ofReal_re theorem log_ofReal_mul {r : ℝ} (hr : 0 < r) {x : ℂ} (hx : x ≠ 0) : log (r * x) = Real.log r + log x := by replace hx := Complex.abs.ne_zero_iff.mpr hx simp_rw [log, map_mul, abs_ofReal, arg_real_mul _ hr, abs_of_pos hr, Real.log_mul hr.ne' hx, ofReal_add, add_assoc] #align complex.log_of_real_mul Complex.log_ofReal_mul theorem log_mul_ofReal (r : ℝ) (hr : 0 < r) (x : ℂ) (hx : x ≠ 0) : log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx] #align complex.log_mul_of_real Complex.log_mul_ofReal lemma log_mul_eq_add_log_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) : log (x * y) = log x + log y ↔ arg x + arg y ∈ Set.Ioc (-π) π := by refine ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hx₀ hy₀ simp_rw [add_re, add_im, log_re, log_im, AbsoluteValue.map_mul, Real.log_mul (abs.ne_zero hx₀) (abs.ne_zero hy₀), true_and] alias ⟨_, log_mul⟩ := log_mul_eq_add_log_iff @[simp] theorem log_zero : log 0 = 0 := by simp [log] #align complex.log_zero Complex.log_zero @[simp]
Mathlib/Analysis/SpecialFunctions/Complex/Log.lean
110
110
theorem log_one : log 1 = 0 := by
simp [log]
/- 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
Mathlib/Algebra/Order/Field/Basic.lean
76
76
theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by
rw [mul_comm, div_le_iff hb]
/- Copyright (c) 2022 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca -/ import Mathlib.NumberTheory.Cyclotomic.Discriminant import Mathlib.RingTheory.Polynomial.Eisenstein.IsIntegral import Mathlib.RingTheory.Ideal.Norm #align_import number_theory.cyclotomic.rat from "leanprover-community/mathlib"@"b353176c24d96c23f0ce1cc63efc3f55019702d9" /-! # Ring of integers of `p ^ n`-th cyclotomic fields We gather results about cyclotomic extensions of `ℚ`. In particular, we compute the ring of integers of a `p ^ n`-th cyclotomic extension of `ℚ`. ## Main results * `IsCyclotomicExtension.Rat.isIntegralClosure_adjoin_singleton_of_prime_pow`: if `K` is a `p ^ k`-th cyclotomic extension of `ℚ`, then `(adjoin ℤ {ζ})` is the integral closure of `ℤ` in `K`. * `IsCyclotomicExtension.Rat.cyclotomicRing_isIntegralClosure_of_prime_pow`: the integral closure of `ℤ` inside `CyclotomicField (p ^ k) ℚ` is `CyclotomicRing (p ^ k) ℤ ℚ`. * `IsCyclotomicExtension.Rat.absdiscr_prime_pow` and related results: the absolute discriminant of cyclotomic fields. -/ universe u open Algebra IsCyclotomicExtension Polynomial NumberField open scoped Cyclotomic Nat variable {p : ℕ+} {k : ℕ} {K : Type u} [Field K] [CharZero K] {ζ : K} [hp : Fact (p : ℕ).Prime] namespace IsCyclotomicExtension.Rat /-- The discriminant of the power basis given by `ζ - 1`. -/ theorem discr_prime_pow_ne_two' [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) (hk : p ^ (k + 1) ≠ 2) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ ((p ^ (k + 1) : ℕ).totient / 2) * p ^ ((p : ℕ) ^ k * ((p - 1) * (k + 1) - 1)) := by rw [← discr_prime_pow_ne_two hζ (cyclotomic.irreducible_rat (p ^ (k + 1)).pos) hk] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm #align is_cyclotomic_extension.rat.discr_prime_pow_ne_two' IsCyclotomicExtension.Rat.discr_prime_pow_ne_two'
Mathlib/NumberTheory/Cyclotomic/Rat.lean
46
49
theorem discr_odd_prime' [IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) (hodd : p ≠ 2) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ (((p : ℕ) - 1) / 2) * p ^ ((p : ℕ) - 2) := by
rw [← discr_odd_prime hζ (cyclotomic.irreducible_rat hp.out.pos) hodd] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm
/- Copyright (c) 2020 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Yuyang Zhao -/ import Mathlib.Algebra.Algebra.Tower import Mathlib.Algebra.Polynomial.AlgebraMap #align_import ring_theory.polynomial.tower from "leanprover-community/mathlib"@"bb168510ef455e9280a152e7f31673cabd3d7496" /-! # Algebra towers for polynomial This file proves some basic results about the algebra tower structure for the type `R[X]`. This structure itself is provided elsewhere as `Polynomial.isScalarTower` When you update this file, you can also try to make a corresponding update in `RingTheory.MvPolynomial.Tower`. -/ open Polynomial variable (R A B : Type*) namespace Polynomial section Semiring variable [CommSemiring R] [CommSemiring A] [Semiring B] variable [Algebra R A] [Algebra A B] [Algebra R B] variable [IsScalarTower R A B] variable {R B} @[simp] theorem aeval_map_algebraMap (x : B) (p : R[X]) : aeval x (map (algebraMap R A) p) = aeval x p := by rw [aeval_def, aeval_def, eval₂_map, IsScalarTower.algebraMap_eq R A B] #align polynomial.aeval_map_algebra_map Polynomial.aeval_map_algebraMap @[simp] lemma eval_map_algebraMap (P : R[X]) (a : A) : (map (algebraMap R A) P).eval a = aeval a P := by rw [← aeval_map_algebraMap (A := A), coe_aeval_eq_eval] end Semiring section CommSemiring variable [CommSemiring R] [CommSemiring A] [Semiring B] variable [Algebra R A] [Algebra A B] [Algebra R B] [IsScalarTower R A B] variable {R A} theorem aeval_algebraMap_apply (x : A) (p : R[X]) : aeval (algebraMap A B x) p = algebraMap A B (aeval x p) := by rw [aeval_def, aeval_def, hom_eval₂, ← IsScalarTower.algebraMap_eq] #align polynomial.aeval_algebra_map_apply Polynomial.aeval_algebraMap_apply @[simp]
Mathlib/RingTheory/Polynomial/Tower.lean
60
63
theorem aeval_algebraMap_eq_zero_iff [NoZeroSMulDivisors A B] [Nontrivial B] (x : A) (p : R[X]) : aeval (algebraMap A B x) p = 0 ↔ aeval x p = 0 := by
rw [aeval_algebraMap_apply, Algebra.algebraMap_eq_smul_one, smul_eq_zero, iff_false_intro (one_ne_zero' B), or_false_iff]
/- Copyright (c) 2022 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.Algebra.IsPrimePow import Mathlib.NumberTheory.ArithmeticFunction import Mathlib.Analysis.SpecialFunctions.Log.Basic #align_import number_theory.von_mangoldt from "leanprover-community/mathlib"@"c946d6097a6925ad16d7ec55677bbc977f9846de" /-! # The von Mangoldt Function In this file we define the von Mangoldt function: the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. ## Main Results The main definition for this file is - `ArithmeticFunction.vonMangoldt`: The von Mangoldt function `Λ`. We then prove the classical summation property of the von Mangoldt function in `ArithmeticFunction.vonMangoldt_sum`, that `∑ i ∈ n.divisors, Λ i = Real.log n`, and use this to deduce alternative expressions for the von Mangoldt function via Möbius inversion, see `ArithmeticFunction.sum_moebius_mul_log_eq`. ## Notation We use the standard notation `Λ` to represent the von Mangoldt function. It is accessible in the locales `ArithmeticFunction` (like the notations for other arithmetic functions) and also in the locale `ArithmeticFunction.vonMangoldt`. -/ namespace ArithmeticFunction open Finset Nat open scoped ArithmeticFunction /-- `log` as an arithmetic function `ℕ → ℝ`. Note this is in the `ArithmeticFunction` namespace to indicate that it is bundled as an `ArithmeticFunction` rather than being the usual real logarithm. -/ noncomputable def log : ArithmeticFunction ℝ := ⟨fun n => Real.log n, by simp⟩ #align nat.arithmetic_function.log ArithmeticFunction.log @[simp] theorem log_apply {n : ℕ} : log n = Real.log n := rfl #align nat.arithmetic_function.log_apply ArithmeticFunction.log_apply /-- The `vonMangoldt` function is the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. In the case when `n` is a prime power, `min_fac` will give the appropriate prime, as it is the smallest prime factor. In the `ArithmeticFunction` locale, we have the notation `Λ` for this function. This is also available in the `ArithmeticFunction.vonMangoldt` locale, allowing for selective access to the notation. -/ noncomputable def vonMangoldt : ArithmeticFunction ℝ := ⟨fun n => if IsPrimePow n then Real.log (minFac n) else 0, if_neg not_isPrimePow_zero⟩ #align nat.arithmetic_function.von_mangoldt ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction] notation "Λ" => ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction.vonMangoldt] notation "Λ" => ArithmeticFunction.vonMangoldt theorem vonMangoldt_apply {n : ℕ} : Λ n = if IsPrimePow n then Real.log (minFac n) else 0 := rfl #align nat.arithmetic_function.von_mangoldt_apply ArithmeticFunction.vonMangoldt_apply @[simp] theorem vonMangoldt_apply_one : Λ 1 = 0 := by simp [vonMangoldt_apply] #align nat.arithmetic_function.von_mangoldt_apply_one ArithmeticFunction.vonMangoldt_apply_one @[simp] theorem vonMangoldt_nonneg {n : ℕ} : 0 ≤ Λ n := by rw [vonMangoldt_apply] split_ifs · exact Real.log_nonneg (one_le_cast.2 (Nat.minFac_pos n)) rfl #align nat.arithmetic_function.von_mangoldt_nonneg ArithmeticFunction.vonMangoldt_nonneg
Mathlib/NumberTheory/VonMangoldt.lean
90
91
theorem vonMangoldt_apply_pow {n k : ℕ} (hk : k ≠ 0) : Λ (n ^ k) = Λ n := by
simp only [vonMangoldt_apply, isPrimePow_pow_iff hk, pow_minFac hk]
/- Copyright (c) 2024 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Order.Group.Instances import Mathlib.GroupTheory.GroupAction.Pi /-! # Maps (semi)conjugating a shift to a shift Denote by $S^1$ the unit circle `UnitAddCircle`. A common way to study a self-map $f\colon S^1\to S^1$ of degree `1` is to lift it to a map $\tilde f\colon \mathbb R\to \mathbb R$ such that $\tilde f(x + 1) = \tilde f(x)+1$ for all `x`. In this file we define a structure and a typeclass for bundled maps satisfying `f (x + a) = f x + b`. We use parameters `a` and `b` instead of `1` to accomodate for two use cases: - maps between circles of different lengths; - self-maps $f\colon S^1\to S^1$ of degree other than one, including orientation-reversing maps. -/ open Function Set /-- A bundled map `f : G → H` such that `f (x + a) = f x + b` for all `x`. One can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/ structure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where /-- The underlying function of an `AddConstMap`. Use automatic coercion to function instead. -/ protected toFun : G → H /-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/ map_add_const' (x : G) : toFun (x + a) = toFun x + b @[inherit_doc] scoped [AddConstMap] notation:25 G " →+c[" a ", " b "] " H => AddConstMap G H a b /-- Typeclass for maps satisfying `f (x + a) = f x + b`. Note that `a` and `b` are `outParam`s, so one should not add instances like `[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/ class AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H] (a : outParam G) (b : outParam H) extends DFunLike F G fun _ ↦ H where /-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`: `∀ x, f (x + a) = f x + b`. -/ map_add_const (f : F) (x : G) : f (x + a) = f x + b namespace AddConstMapClass /-! ### Properties of `AddConstMapClass` maps In this section we prove properties like `f (x + n • a) = f x + n • b`. -/ attribute [simp] map_add_const variable {F G H : Type*} {a : G} {b : H} protected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) : Semiconj f (· + a) (· + b) := map_add_const f @[simp] theorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b] (f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by simpa using (AddConstMapClass.semiconj f).iterate_right n x @[simp] theorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b] (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by simp [← map_add_nsmul] theorem map_add_one [AddMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b] (f : F) (x : G) : f (x + 1) = f x + b := map_add_const f x @[simp] theorem map_add_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b] (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] : f (x + no_index (OfNat.ofNat n)) = f x + (OfNat.ofNat n : ℕ) • b := map_add_nat' f x n theorem map_add_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1] (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n := by simp theorem map_add_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1] (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] : f (x + OfNat.ofNat n) = f x + OfNat.ofNat n := map_add_nat f x n @[simp] theorem map_const [AddZeroClass G] [Add H] [AddConstMapClass F G H a b] (f : F) : f a = f 0 + b := by simpa using map_add_const f 0 theorem map_one [AddZeroClass G] [One G] [Add H] [AddConstMapClass F G H 1 b] (f : F) : f 1 = f 0 + b := map_const f @[simp] theorem map_nsmul_const [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b] (f : F) (n : ℕ) : f (n • a) = f 0 + n • b := by simpa using map_add_nsmul f 0 n @[simp] theorem map_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b] (f : F) (n : ℕ) : f n = f 0 + n • b := by simpa using map_add_nat' f 0 n theorem map_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b] (f : F) (n : ℕ) [n.AtLeastTwo] : f (OfNat.ofNat n) = f 0 + (OfNat.ofNat n : ℕ) • b := map_nat' f n
Mathlib/Algebra/AddConstMap/Basic.lean
121
122
theorem map_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1] (f : F) (n : ℕ) : f n = f 0 + n := by
simp
/- Copyright (c) 2018 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Markus Himmel -/ import Mathlib.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Limits.HasLimits #align_import category_theory.limits.shapes.equalizers from "leanprover-community/mathlib"@"4698e35ca56a0d4fa53aa5639c3364e0a77f4eba" /-! # Equalizers and coequalizers This file defines (co)equalizers as special cases of (co)limits. An equalizer is the categorical generalization of the subobject {a ∈ A | f(a) = g(a)} known from abelian groups or modules. It is a limit cone over the diagram formed by `f` and `g`. A coequalizer is the dual concept. ## Main definitions * `WalkingParallelPair` is the indexing category used for (co)equalizer_diagrams * `parallelPair` is a functor from `WalkingParallelPair` to our category `C`. * a `fork` is a cone over a parallel pair. * there is really only one interesting morphism in a fork: the arrow from the vertex of the fork to the domain of f and g. It is called `fork.ι`. * an `equalizer` is now just a `limit (parallelPair f g)` Each of these has a dual. ## Main statements * `equalizer.ι_mono` states that every equalizer map is a monomorphism * `isIso_limit_cone_parallelPair_of_self` states that the identity on the domain of `f` is an equalizer of `f` and `f`. ## Implementation notes As with the other special shapes in the limits library, all the definitions here are given as `abbreviation`s of the general statements for limits, so all the `simp` lemmas and theorems about general limits can be used. ## References * [F. Borceux, *Handbook of Categorical Algebra 1*][borceux-vol1] -/ /- Porting note: removed global noncomputable since there are things that might be computable value like WalkingPair -/ section open CategoryTheory Opposite namespace CategoryTheory.Limits -- attribute [local tidy] tactic.case_bash -- Porting note: no tidy nor cases_bash universe v v₂ u u₂ /-- The type of objects for the diagram indexing a (co)equalizer. -/ inductive WalkingParallelPair : Type | zero | one deriving DecidableEq, Inhabited #align category_theory.limits.walking_parallel_pair CategoryTheory.Limits.WalkingParallelPair open WalkingParallelPair /-- The type family of morphisms for the diagram indexing a (co)equalizer. -/ inductive WalkingParallelPairHom : WalkingParallelPair → WalkingParallelPair → Type | left : WalkingParallelPairHom zero one | right : WalkingParallelPairHom zero one | id (X : WalkingParallelPair) : WalkingParallelPairHom X X deriving DecidableEq #align category_theory.limits.walking_parallel_pair_hom CategoryTheory.Limits.WalkingParallelPairHom /- Porting note: this simplifies using walkingParallelPairHom_id; replacement is below; simpNF still complains of striking this from the simp list -/ attribute [-simp, nolint simpNF] WalkingParallelPairHom.id.sizeOf_spec /-- Satisfying the inhabited linter -/ instance : Inhabited (WalkingParallelPairHom zero one) where default := WalkingParallelPairHom.left open WalkingParallelPairHom /-- Composition of morphisms in the indexing diagram for (co)equalizers. -/ def WalkingParallelPairHom.comp : -- Porting note: changed X Y Z to implicit to match comp fields in precategory ∀ { X Y Z : WalkingParallelPair } (_ : WalkingParallelPairHom X Y) (_ : WalkingParallelPairHom Y Z), WalkingParallelPairHom X Z | _, _, _, id _, h => h | _, _, _, left, id one => left | _, _, _, right, id one => right #align category_theory.limits.walking_parallel_pair_hom.comp CategoryTheory.Limits.WalkingParallelPairHom.comp -- Porting note: adding these since they are simple and aesop couldn't directly prove them theorem WalkingParallelPairHom.id_comp {X Y : WalkingParallelPair} (g : WalkingParallelPairHom X Y) : comp (id X) g = g := rfl theorem WalkingParallelPairHom.comp_id {X Y : WalkingParallelPair} (f : WalkingParallelPairHom X Y) : comp f (id Y) = f := by cases f <;> rfl
Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean
105
108
theorem WalkingParallelPairHom.assoc {X Y Z W : WalkingParallelPair} (f : WalkingParallelPairHom X Y) (g: WalkingParallelPairHom Y Z) (h : WalkingParallelPairHom Z W) : comp (comp f g) h = comp f (comp g h) := by
cases f <;> cases g <;> cases h <;> rfl
/- Copyright (c) 2018 Andreas Swerdlow. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andreas Swerdlow -/ import Mathlib.Algebra.Field.Basic import Mathlib.Deprecated.Subring #align_import deprecated.subfield from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc" /-! # Unbundled subfields (deprecated) This file is deprecated, and is no longer imported by anything in mathlib other than other deprecated files, and test files. You should not need to import it. This file defines predicates for unbundled subfields. Instead of using this file, please use `Subfield`, defined in `FieldTheory.Subfield`, for subfields of fields. ## Main definitions `IsSubfield (S : Set F) : Prop` : the predicate that `S` is the underlying set of a subfield of the field `F`. The bundled variant `Subfield F` should be used in preference to this. ## Tags IsSubfield, subfield -/ variable {F : Type*} [Field F] (S : Set F) /-- `IsSubfield (S : Set F)` is the predicate saying that a given subset of a field is the set underlying a subfield. This structure is deprecated; use the bundled variant `Subfield F` to model subfields of a field. -/ structure IsSubfield extends IsSubring S : Prop where inv_mem : ∀ {x : F}, x ∈ S → x⁻¹ ∈ S #align is_subfield IsSubfield
Mathlib/Deprecated/Subfield.lean
40
43
theorem IsSubfield.div_mem {S : Set F} (hS : IsSubfield S) {x y : F} (hx : x ∈ S) (hy : y ∈ S) : x / y ∈ S := by
rw [div_eq_mul_inv] exact hS.toIsSubring.toIsSubmonoid.mul_mem hx (hS.inv_mem hy)
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Scott Morrison -/ import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms import Mathlib.CategoryTheory.Limits.Shapes.Kernels import Mathlib.CategoryTheory.Abelian.Basic import Mathlib.CategoryTheory.Subobject.Lattice import Mathlib.Order.Atoms #align_import category_theory.simple from "leanprover-community/mathlib"@"4ed0bcaef698011b0692b93a042a2282f490f6b6" /-! # Simple objects We define simple objects in any category with zero morphisms. A simple object is an object `Y` such that any monomorphism `f : X ⟶ Y` is either an isomorphism or zero (but not both). This is formalized as a `Prop` valued typeclass `Simple X`. In some contexts, especially representation theory, simple objects are called "irreducibles". If a morphism `f` out of a simple object is nonzero and has a kernel, then that kernel is zero. (We state this as `kernel.ι f = 0`, but should add `kernel f ≅ 0`.) When the category is abelian, being simple is the same as being cosimple (although we do not state a separate typeclass for this). As a consequence, any nonzero epimorphism out of a simple object is an isomorphism, and any nonzero morphism into a simple object has trivial cokernel. We show that any simple object is indecomposable. -/ noncomputable section open CategoryTheory.Limits namespace CategoryTheory universe v u variable {C : Type u} [Category.{v} C] section variable [HasZeroMorphisms C] /-- An object is simple if monomorphisms into it are (exclusively) either isomorphisms or zero. -/ class Simple (X : C) : Prop where mono_isIso_iff_nonzero : ∀ {Y : C} (f : Y ⟶ X) [Mono f], IsIso f ↔ f ≠ 0 #align category_theory.simple CategoryTheory.Simple /-- A nonzero monomorphism to a simple object is an isomorphism. -/ theorem isIso_of_mono_of_nonzero {X Y : C} [Simple Y] {f : X ⟶ Y} [Mono f] (w : f ≠ 0) : IsIso f := (Simple.mono_isIso_iff_nonzero f).mpr w #align category_theory.is_iso_of_mono_of_nonzero CategoryTheory.isIso_of_mono_of_nonzero theorem Simple.of_iso {X Y : C} [Simple Y] (i : X ≅ Y) : Simple X := { mono_isIso_iff_nonzero := fun f m => by haveI : Mono (f ≫ i.hom) := mono_comp _ _ constructor · intro h w have j : IsIso (f ≫ i.hom) := by infer_instance rw [Simple.mono_isIso_iff_nonzero] at j subst w simp at j · intro h have j : IsIso (f ≫ i.hom) := by apply isIso_of_mono_of_nonzero intro w apply h simpa using (cancel_mono i.inv).2 w rw [← Category.comp_id f, ← i.hom_inv_id, ← Category.assoc] infer_instance } #align category_theory.simple.of_iso CategoryTheory.Simple.of_iso theorem Simple.iff_of_iso {X Y : C} (i : X ≅ Y) : Simple X ↔ Simple Y := ⟨fun _ => Simple.of_iso i.symm, fun _ => Simple.of_iso i⟩ #align category_theory.simple.iff_of_iso CategoryTheory.Simple.iff_of_iso
Mathlib/CategoryTheory/Simple.lean
84
89
theorem kernel_zero_of_nonzero_from_simple {X Y : C} [Simple X] {f : X ⟶ Y} [HasKernel f] (w : f ≠ 0) : kernel.ι f = 0 := by
classical by_contra h haveI := isIso_of_mono_of_nonzero h exact w (eq_zero_of_epi_kernel f)
/- Copyright (c) 2021 Eric Weiser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.Algebra.Operations import Mathlib.Algebra.Algebra.Subalgebra.Basic import Mathlib.Algebra.Ring.Subring.Pointwise import Mathlib.RingTheory.Adjoin.Basic #align_import algebra.algebra.subalgebra.pointwise from "leanprover-community/mathlib"@"b2c707cd190a58ea0565c86695a19e99ccecc215" /-! # Pointwise actions on subalgebras. If `R'` acts on an `R`-algebra `A` (so that `R'` and `R` actions commute) then we get an `R'` action on the collection of `R`-subalgebras. -/ namespace Subalgebra section Pointwise variable {R : Type*} {A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] theorem mul_toSubmodule_le (S T : Subalgebra R A) : (Subalgebra.toSubmodule S)* (Subalgebra.toSubmodule T) ≤ Subalgebra.toSubmodule (S ⊔ T) := by rw [Submodule.mul_le] intro y hy z hz show y * z ∈ S ⊔ T exact mul_mem (Algebra.mem_sup_left hy) (Algebra.mem_sup_right hz) #align subalgebra.mul_to_submodule_le Subalgebra.mul_toSubmodule_le /-- As submodules, subalgebras are idempotent. -/ @[simp]
Mathlib/Algebra/Algebra/Subalgebra/Pointwise.lean
37
44
theorem mul_self (S : Subalgebra R A) : (Subalgebra.toSubmodule S) * (Subalgebra.toSubmodule S) = (Subalgebra.toSubmodule S) := by
apply le_antisymm · refine (mul_toSubmodule_le _ _).trans_eq ?_ rw [sup_idem] · intro x hx1 rw [← mul_one x] exact Submodule.mul_mem_mul hx1 (show (1 : A) ∈ S from one_mem S)
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Patrick Massot -/ import Mathlib.Order.Interval.Set.UnorderedInterval import Mathlib.Algebra.Order.Interval.Set.Monoid import Mathlib.Data.Set.Pointwise.Basic import Mathlib.Algebra.Order.Field.Basic import Mathlib.Algebra.Order.Group.MinMax #align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # (Pre)images of intervals In this file we prove a bunch of trivial lemmas like “if we add `a` to all points of `[b, c]`, then we get `[a + b, a + c]`”. For the functions `x ↦ x ± a`, `x ↦ a ± x`, and `x ↦ -x` we prove lemmas about preimages and images of all intervals. We also prove a few lemmas about images under `x ↦ a * x`, `x ↦ x * a` and `x ↦ x⁻¹`. -/ open Interval Pointwise variable {α : Type*} namespace Set /-! ### Binary pointwise operations Note that the subset operations below only cover the cases with the largest possible intervals on the LHS: to conclude that `Ioo a b * Ioo c d ⊆ Ioo (a * c) (c * d)`, you can use monotonicity of `*` and `Set.Ico_mul_Ioc_subset`. TODO: repeat these lemmas for the generality of `mul_le_mul` (which assumes nonnegativity), which the unprimed names have been reserved for -/ section ContravariantLE variable [Mul α] [Preorder α] variable [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (Function.swap HMul.hMul) LE.le] @[to_additive Icc_add_Icc_subset] theorem Icc_mul_Icc_subset' (a b c d : α) : Icc a b * Icc c d ⊆ Icc (a * c) (b * d) := by rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_le_mul' hya hzc, mul_le_mul' hyb hzd⟩ @[to_additive Iic_add_Iic_subset] theorem Iic_mul_Iic_subset' (a b : α) : Iic a * Iic b ⊆ Iic (a * b) := by rintro x ⟨y, hya, z, hzb, rfl⟩ exact mul_le_mul' hya hzb @[to_additive Ici_add_Ici_subset] theorem Ici_mul_Ici_subset' (a b : α) : Ici a * Ici b ⊆ Ici (a * b) := by rintro x ⟨y, hya, z, hzb, rfl⟩ exact mul_le_mul' hya hzb end ContravariantLE section ContravariantLT variable [Mul α] [PartialOrder α] variable [CovariantClass α α (· * ·) (· < ·)] [CovariantClass α α (Function.swap HMul.hMul) LT.lt] @[to_additive Icc_add_Ico_subset] theorem Icc_mul_Ico_subset' (a b c d : α) : Icc a b * Ico c d ⊆ Ico (a * c) (b * d) := by haveI := covariantClass_le_of_lt rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_le_mul' hya hzc, mul_lt_mul_of_le_of_lt hyb hzd⟩ @[to_additive Ico_add_Icc_subset] theorem Ico_mul_Icc_subset' (a b c d : α) : Ico a b * Icc c d ⊆ Ico (a * c) (b * d) := by haveI := covariantClass_le_of_lt rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_le_mul' hya hzc, mul_lt_mul_of_lt_of_le hyb hzd⟩ @[to_additive Ioc_add_Ico_subset] theorem Ioc_mul_Ico_subset' (a b c d : α) : Ioc a b * Ico c d ⊆ Ioo (a * c) (b * d) := by haveI := covariantClass_le_of_lt rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_lt_mul_of_lt_of_le hya hzc, mul_lt_mul_of_le_of_lt hyb hzd⟩ @[to_additive Ico_add_Ioc_subset] theorem Ico_mul_Ioc_subset' (a b c d : α) : Ico a b * Ioc c d ⊆ Ioo (a * c) (b * d) := by haveI := covariantClass_le_of_lt rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩ exact ⟨mul_lt_mul_of_le_of_lt hya hzc, mul_lt_mul_of_lt_of_le hyb hzd⟩ @[to_additive Iic_add_Iio_subset]
Mathlib/Data/Set/Pointwise/Interval.lean
92
95
theorem Iic_mul_Iio_subset' (a b : α) : Iic a * Iio b ⊆ Iio (a * b) := by
haveI := covariantClass_le_of_lt rintro x ⟨y, hya, z, hzb, rfl⟩ exact mul_lt_mul_of_le_of_lt hya hzb
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Robert Y. Lewis -/ import Mathlib.RingTheory.WittVector.InitTail #align_import ring_theory.witt_vector.truncated from "leanprover-community/mathlib"@"acbe099ced8be9c9754d62860110295cde0d7181" /-! # Truncated Witt vectors The ring of truncated Witt vectors (of length `n`) is a quotient of the ring of Witt vectors. It retains the first `n` coefficients of each Witt vector. In this file, we set up the basic quotient API for this ring. The ring of Witt vectors is the projective limit of all the rings of truncated Witt vectors. ## Main declarations - `TruncatedWittVector`: the underlying type of the ring of truncated Witt vectors - `TruncatedWittVector.instCommRing`: the ring structure on truncated Witt vectors - `WittVector.truncate`: the quotient homomorphism that truncates a Witt vector, to obtain a truncated Witt vector - `TruncatedWittVector.truncate`: the homomorphism that truncates a truncated Witt vector of length `n` to one of length `m` (for some `m ≤ n`) - `WittVector.lift`: the unique ring homomorphism into the ring of Witt vectors that is compatible with a family of ring homomorphisms to the truncated Witt vectors: this realizes the ring of Witt vectors as projective limit of the rings of truncated Witt vectors ## References * [Hazewinkel, *Witt Vectors*][Haze09] * [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21] -/ open Function (Injective Surjective) noncomputable section variable {p : ℕ} [hp : Fact p.Prime] (n : ℕ) (R : Type*) local notation "𝕎" => WittVector p -- type as `\bbW` /-- A truncated Witt vector over `R` is a vector of elements of `R`, i.e., the first `n` coefficients of a Witt vector. We will define operations on this type that are compatible with the (untruncated) Witt vector operations. `TruncatedWittVector p n R` takes a parameter `p : ℕ` that is not used in the definition. In practice, this number `p` is assumed to be a prime number, and under this assumption we construct a ring structure on `TruncatedWittVector p n R`. (`TruncatedWittVector p₁ n R` and `TruncatedWittVector p₂ n R` are definitionally equal as types but will have different ring operations.) -/ @[nolint unusedArguments] def TruncatedWittVector (_ : ℕ) (n : ℕ) (R : Type*) := Fin n → R #align truncated_witt_vector TruncatedWittVector instance (p n : ℕ) (R : Type*) [Inhabited R] : Inhabited (TruncatedWittVector p n R) := ⟨fun _ => default⟩ variable {n R} namespace TruncatedWittVector variable (p) /-- Create a `TruncatedWittVector` from a vector `x`. -/ def mk (x : Fin n → R) : TruncatedWittVector p n R := x #align truncated_witt_vector.mk TruncatedWittVector.mk variable {p} /-- `x.coeff i` is the `i`th entry of `x`. -/ def coeff (i : Fin n) (x : TruncatedWittVector p n R) : R := x i #align truncated_witt_vector.coeff TruncatedWittVector.coeff @[ext] theorem ext {x y : TruncatedWittVector p n R} (h : ∀ i, x.coeff i = y.coeff i) : x = y := funext h #align truncated_witt_vector.ext TruncatedWittVector.ext theorem ext_iff {x y : TruncatedWittVector p n R} : x = y ↔ ∀ i, x.coeff i = y.coeff i := ⟨fun h i => by rw [h], ext⟩ #align truncated_witt_vector.ext_iff TruncatedWittVector.ext_iff @[simp] theorem coeff_mk (x : Fin n → R) (i : Fin n) : (mk p x).coeff i = x i := rfl #align truncated_witt_vector.coeff_mk TruncatedWittVector.coeff_mk @[simp] theorem mk_coeff (x : TruncatedWittVector p n R) : (mk p fun i => x.coeff i) = x := by ext i; rw [coeff_mk] #align truncated_witt_vector.mk_coeff TruncatedWittVector.mk_coeff variable [CommRing R] /-- We can turn a truncated Witt vector `x` into a Witt vector by setting all coefficients after `x` to be 0. -/ def out (x : TruncatedWittVector p n R) : 𝕎 R := @WittVector.mk' p _ fun i => if h : i < n then x.coeff ⟨i, h⟩ else 0 #align truncated_witt_vector.out TruncatedWittVector.out @[simp]
Mathlib/RingTheory/WittVector/Truncated.lean
114
115
theorem coeff_out (x : TruncatedWittVector p n R) (i : Fin n) : x.out.coeff i = x.coeff i := by
rw [out]; dsimp only; rw [dif_pos i.is_lt, Fin.eta]
/- 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.Set.Lattice #align_import data.semiquot from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f" /-! # Semiquotients A data type for semiquotients, which are classically equivalent to nonempty sets, but are useful for programming; the idea is that a semiquotient set `S` represents some (particular but unknown) element of `S`. This can be used to model nondeterministic functions, which return something in a range of values (represented by the predicate `S`) but are not completely determined. -/ /-- A member of `Semiquot α` is classically a nonempty `Set α`, and in the VM is represented by an element of `α`; the relation between these is that the VM element is required to be a member of the set `s`. The specific element of `s` that the VM computes is hidden by a quotient construction, allowing for the representation of nondeterministic functions. -/ -- Porting note: removed universe parameter structure Semiquot (α : Type*) where mk' :: /-- Set containing some element of `α`-/ s : Set α /-- Assertion of non-emptiness via `Trunc`-/ val : Trunc s #align semiquot Semiquot namespace Semiquot variable {α : Type*} {β : Type*} instance : Membership α (Semiquot α) := ⟨fun a q => a ∈ q.s⟩ /-- Construct a `Semiquot α` from `h : a ∈ s` where `s : Set α`. -/ def mk {a : α} {s : Set α} (h : a ∈ s) : Semiquot α := ⟨s, Trunc.mk ⟨a, h⟩⟩ #align semiquot.mk Semiquot.mk theorem ext_s {q₁ q₂ : Semiquot α} : q₁ = q₂ ↔ q₁.s = q₂.s := by refine ⟨congr_arg _, fun h => ?_⟩ cases' q₁ with _ v₁; cases' q₂ with _ v₂; congr exact Subsingleton.helim (congrArg Trunc (congrArg Set.Elem h)) v₁ v₂ #align semiquot.ext_s Semiquot.ext_s theorem ext {q₁ q₂ : Semiquot α} : q₁ = q₂ ↔ ∀ a, a ∈ q₁ ↔ a ∈ q₂ := ext_s.trans Set.ext_iff #align semiquot.ext Semiquot.ext theorem exists_mem (q : Semiquot α) : ∃ a, a ∈ q := let ⟨⟨a, h⟩, _⟩ := q.2.exists_rep ⟨a, h⟩ #align semiquot.exists_mem Semiquot.exists_mem theorem eq_mk_of_mem {q : Semiquot α} {a : α} (h : a ∈ q) : q = @mk _ a q.1 h := ext_s.2 rfl #align semiquot.eq_mk_of_mem Semiquot.eq_mk_of_mem theorem nonempty (q : Semiquot α) : q.s.Nonempty := q.exists_mem #align semiquot.nonempty Semiquot.nonempty /-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/ protected def pure (a : α) : Semiquot α := mk (Set.mem_singleton a) #align semiquot.pure Semiquot.pure @[simp] theorem mem_pure' {a b : α} : a ∈ Semiquot.pure b ↔ a = b := Set.mem_singleton_iff #align semiquot.mem_pure' Semiquot.mem_pure' /-- Replace `s` in a `Semiquot` with a superset. -/ def blur' (q : Semiquot α) {s : Set α} (h : q.s ⊆ s) : Semiquot α := ⟨s, Trunc.lift (fun a : q.s => Trunc.mk ⟨a.1, h a.2⟩) (fun _ _ => Trunc.eq _ _) q.2⟩ #align semiquot.blur' Semiquot.blur' /-- Replace `s` in a `q : Semiquot α` with a union `s ∪ q.s` -/ def blur (s : Set α) (q : Semiquot α) : Semiquot α := blur' q (s.subset_union_right (t := q.s)) #align semiquot.blur Semiquot.blur
Mathlib/Data/Semiquot.lean
90
91
theorem blur_eq_blur' (q : Semiquot α) (s : Set α) (h : q.s ⊆ s) : blur s q = blur' q h := by
unfold blur; congr; exact Set.union_eq_self_of_subset_right h
/- Copyright (c) 2020 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne, Eric Wieser -/ import Mathlib.MeasureTheory.Function.LpSeminorm.Basic import Mathlib.MeasureTheory.Integral.MeanInequalities #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" /-! # Compare Lp seminorms for different values of `p` In this file we compare `MeasureTheory.snorm'` and `MeasureTheory.snorm` for different exponents. -/ open Filter open scoped ENNReal Topology namespace MeasureTheory section SameSpace variable {α E : Type*} {m : MeasurableSpace α} [NormedAddCommGroup E] {μ : Measure α} {f : α → E} theorem snorm'_le_snorm'_mul_rpow_measure_univ {p q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q) (hf : AEStronglyMeasurable f μ) : snorm' f p μ ≤ snorm' f q μ * μ Set.univ ^ (1 / p - 1 / q) := by have hq0_lt : 0 < q := lt_of_lt_of_le hp0_lt hpq by_cases hpq_eq : p = q · rw [hpq_eq, sub_self, ENNReal.rpow_zero, mul_one] have hpq : p < q := lt_of_le_of_ne hpq hpq_eq let g := fun _ : α => (1 : ℝ≥0∞) have h_rw : (∫⁻ a, (‖f a‖₊ : ℝ≥0∞) ^ p ∂μ) = ∫⁻ a, ((‖f a‖₊ : ℝ≥0∞) * g a) ^ p ∂μ := lintegral_congr fun a => by simp [g] repeat' rw [snorm'] rw [h_rw] let r := p * q / (q - p) have hpqr : 1 / p = 1 / q + 1 / r := by field_simp [r, hp0_lt.ne', hq0_lt.ne'] calc (∫⁻ a : α, (↑‖f a‖₊ * g a) ^ p ∂μ) ^ (1 / p) ≤ (∫⁻ a : α, ↑‖f a‖₊ ^ q ∂μ) ^ (1 / q) * (∫⁻ a : α, g a ^ r ∂μ) ^ (1 / r) := ENNReal.lintegral_Lp_mul_le_Lq_mul_Lr hp0_lt hpq hpqr μ hf.ennnorm aemeasurable_const _ = (∫⁻ a : α, ↑‖f a‖₊ ^ q ∂μ) ^ (1 / q) * μ Set.univ ^ (1 / p - 1 / q) := by rw [hpqr]; simp [r, g] #align measure_theory.snorm'_le_snorm'_mul_rpow_measure_univ MeasureTheory.snorm'_le_snorm'_mul_rpow_measure_univ theorem snorm'_le_snormEssSup_mul_rpow_measure_univ {q : ℝ} (hq_pos : 0 < q) : snorm' f q μ ≤ snormEssSup f μ * μ Set.univ ^ (1 / q) := by have h_le : (∫⁻ a : α, (‖f a‖₊ : ℝ≥0∞) ^ q ∂μ) ≤ ∫⁻ _ : α, snormEssSup f μ ^ q ∂μ := by refine lintegral_mono_ae ?_ have h_nnnorm_le_snorm_ess_sup := coe_nnnorm_ae_le_snormEssSup f μ exact h_nnnorm_le_snorm_ess_sup.mono fun x hx => by gcongr rw [snorm', ← ENNReal.rpow_one (snormEssSup f μ)] nth_rw 2 [← mul_inv_cancel (ne_of_lt hq_pos).symm] rw [ENNReal.rpow_mul, one_div, ← ENNReal.mul_rpow_of_nonneg _ _ (by simp [hq_pos.le] : 0 ≤ q⁻¹)] gcongr rwa [lintegral_const] at h_le #align measure_theory.snorm'_le_snorm_ess_sup_mul_rpow_measure_univ MeasureTheory.snorm'_le_snormEssSup_mul_rpow_measure_univ
Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean
61
85
theorem snorm_le_snorm_mul_rpow_measure_univ {p q : ℝ≥0∞} (hpq : p ≤ q) (hf : AEStronglyMeasurable f μ) : snorm f p μ ≤ snorm f q μ * μ Set.univ ^ (1 / p.toReal - 1 / q.toReal) := by
by_cases hp0 : p = 0 · simp [hp0, zero_le] rw [← Ne] at hp0 have hp0_lt : 0 < p := lt_of_le_of_ne (zero_le _) hp0.symm have hq0_lt : 0 < q := lt_of_lt_of_le hp0_lt hpq by_cases hq_top : q = ∞ · simp only [hq_top, _root_.div_zero, one_div, ENNReal.top_toReal, sub_zero, snorm_exponent_top, GroupWithZero.inv_zero] by_cases hp_top : p = ∞ · simp only [hp_top, ENNReal.rpow_zero, mul_one, ENNReal.top_toReal, sub_zero, GroupWithZero.inv_zero, snorm_exponent_top] exact le_rfl rw [snorm_eq_snorm' hp0 hp_top] have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0_lt.ne' hp_top refine (snorm'_le_snormEssSup_mul_rpow_measure_univ hp_pos).trans (le_of_eq ?_) congr exact one_div _ have hp_lt_top : p < ∞ := hpq.trans_lt (lt_top_iff_ne_top.mpr hq_top) have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0_lt.ne' hp_lt_top.ne rw [snorm_eq_snorm' hp0_lt.ne.symm hp_lt_top.ne, snorm_eq_snorm' hq0_lt.ne.symm hq_top] have hpq_real : p.toReal ≤ q.toReal := by rwa [ENNReal.toReal_le_toReal hp_lt_top.ne hq_top] exact snorm'_le_snorm'_mul_rpow_measure_univ hp_pos hpq_real hf
/- 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.Generator import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic #align_import category_theory.preadditive.generator from "leanprover-community/mathlib"@"09f981f72d43749f1fa072deade828d9c1e185bb" /-! # Separators in preadditive categories This file contains characterizations of separating sets and objects that are valid in all preadditive categories. -/ universe v u open CategoryTheory Opposite namespace CategoryTheory variable {C : Type u} [Category.{v} C] [Preadditive C] theorem Preadditive.isSeparating_iff (𝒢 : Set C) : IsSeparating 𝒢 ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : G ⟶ X), h ≫ f = 0) → f = 0 := ⟨fun h𝒢 X Y f hf => h𝒢 _ _ (by simpa only [Limits.comp_zero] using hf), fun h𝒢 X Y f g hfg => sub_eq_zero.1 <| h𝒢 _ (by simpa only [Preadditive.comp_sub, sub_eq_zero] using hfg)⟩ #align category_theory.preadditive.is_separating_iff CategoryTheory.Preadditive.isSeparating_iff theorem Preadditive.isCoseparating_iff (𝒢 : Set C) : IsCoseparating 𝒢 ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : Y ⟶ G), f ≫ h = 0) → f = 0 := ⟨fun h𝒢 X Y f hf => h𝒢 _ _ (by simpa only [Limits.zero_comp] using hf), fun h𝒢 X Y f g hfg => sub_eq_zero.1 <| h𝒢 _ (by simpa only [Preadditive.sub_comp, sub_eq_zero] using hfg)⟩ #align category_theory.preadditive.is_coseparating_iff CategoryTheory.Preadditive.isCoseparating_iff theorem Preadditive.isSeparator_iff (G : C) : IsSeparator G ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ h : G ⟶ X, h ≫ f = 0) → f = 0 := ⟨fun hG X Y f hf => hG.def _ _ (by simpa only [Limits.comp_zero] using hf), fun hG => (isSeparator_def _).2 fun X Y f g hfg => sub_eq_zero.1 <| hG _ (by simpa only [Preadditive.comp_sub, sub_eq_zero] using hfg)⟩ #align category_theory.preadditive.is_separator_iff CategoryTheory.Preadditive.isSeparator_iff theorem Preadditive.isCoseparator_iff (G : C) : IsCoseparator G ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ h : Y ⟶ G, f ≫ h = 0) → f = 0 := ⟨fun hG X Y f hf => hG.def _ _ (by simpa only [Limits.zero_comp] using hf), fun hG => (isCoseparator_def _).2 fun X Y f g hfg => sub_eq_zero.1 <| hG _ (by simpa only [Preadditive.sub_comp, sub_eq_zero] using hfg)⟩ #align category_theory.preadditive.is_coseparator_iff CategoryTheory.Preadditive.isCoseparator_iff theorem isSeparator_iff_faithful_preadditiveCoyoneda (G : C) : IsSeparator G ↔ (preadditiveCoyoneda.obj (op G)).Faithful := by rw [isSeparator_iff_faithful_coyoneda_obj, ← whiskering_preadditiveCoyoneda, Functor.comp_obj, whiskeringRight_obj_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget AddCommGroupCat), fun h => Functor.Faithful.comp _ _⟩ #align category_theory.is_separator_iff_faithful_preadditive_coyoneda CategoryTheory.isSeparator_iff_faithful_preadditiveCoyoneda theorem isSeparator_iff_faithful_preadditiveCoyonedaObj (G : C) : IsSeparator G ↔ (preadditiveCoyonedaObj (op G)).Faithful := by rw [isSeparator_iff_faithful_preadditiveCoyoneda, preadditiveCoyoneda_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget₂ _ AddCommGroupCat.{v}), fun h => Functor.Faithful.comp _ _⟩ #align category_theory.is_separator_iff_faithful_preadditive_coyoneda_obj CategoryTheory.isSeparator_iff_faithful_preadditiveCoyonedaObj theorem isCoseparator_iff_faithful_preadditiveYoneda (G : C) : IsCoseparator G ↔ (preadditiveYoneda.obj G).Faithful := by rw [isCoseparator_iff_faithful_yoneda_obj, ← whiskering_preadditiveYoneda, Functor.comp_obj, whiskeringRight_obj_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget AddCommGroupCat), fun h => Functor.Faithful.comp _ _⟩ #align category_theory.is_coseparator_iff_faithful_preadditive_yoneda CategoryTheory.isCoseparator_iff_faithful_preadditiveYoneda
Mathlib/CategoryTheory/Preadditive/Generator.lean
77
81
theorem isCoseparator_iff_faithful_preadditiveYonedaObj (G : C) : IsCoseparator G ↔ (preadditiveYonedaObj G).Faithful := by
rw [isCoseparator_iff_faithful_preadditiveYoneda, preadditiveYoneda_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget₂ _ AddCommGroupCat.{v}), fun h => Functor.Faithful.comp _ _⟩
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.Algebra.GCDMonoid.Finset import Mathlib.Algebra.Polynomial.CancelLeads import Mathlib.Algebra.Polynomial.EraseLead import Mathlib.Algebra.Polynomial.FieldDivision #align_import ring_theory.polynomial.content from "leanprover-community/mathlib"@"7a030ab8eb5d99f05a891dccc49c5b5b90c947d3" /-! # GCD structures on polynomials Definitions and basic results about polynomials over GCD domains, particularly their contents and primitive polynomials. ## Main Definitions Let `p : R[X]`. - `p.content` is the `gcd` of the coefficients of `p`. - `p.IsPrimitive` indicates that `p.content = 1`. ## Main Results - `Polynomial.content_mul`: If `p q : R[X]`, then `(p * q).content = p.content * q.content`. - `Polynomial.NormalizedGcdMonoid`: The polynomial ring of a GCD domain is itself a GCD domain. -/ namespace Polynomial open Polynomial section Primitive variable {R : Type*} [CommSemiring R] /-- A polynomial is primitive when the only constant polynomials dividing it are units -/ def IsPrimitive (p : R[X]) : Prop := ∀ r : R, C r ∣ p → IsUnit r #align polynomial.is_primitive Polynomial.IsPrimitive theorem isPrimitive_iff_isUnit_of_C_dvd {p : R[X]} : p.IsPrimitive ↔ ∀ r : R, C r ∣ p → IsUnit r := Iff.rfl set_option linter.uppercaseLean3 false in #align polynomial.is_primitive_iff_is_unit_of_C_dvd Polynomial.isPrimitive_iff_isUnit_of_C_dvd @[simp] theorem isPrimitive_one : IsPrimitive (1 : R[X]) := fun _ h => isUnit_C.mp (isUnit_of_dvd_one h) #align polynomial.is_primitive_one Polynomial.isPrimitive_one theorem Monic.isPrimitive {p : R[X]} (hp : p.Monic) : p.IsPrimitive := by rintro r ⟨q, h⟩ exact isUnit_of_mul_eq_one r (q.coeff p.natDegree) (by rwa [← coeff_C_mul, ← h]) #align polynomial.monic.is_primitive Polynomial.Monic.isPrimitive theorem IsPrimitive.ne_zero [Nontrivial R] {p : R[X]} (hp : p.IsPrimitive) : p ≠ 0 := by rintro rfl exact (hp 0 (dvd_zero (C 0))).ne_zero rfl #align polynomial.is_primitive.ne_zero Polynomial.IsPrimitive.ne_zero theorem isPrimitive_of_dvd {p q : R[X]} (hp : IsPrimitive p) (hq : q ∣ p) : IsPrimitive q := fun a ha => isPrimitive_iff_isUnit_of_C_dvd.mp hp a (dvd_trans ha hq) #align polynomial.is_primitive_of_dvd Polynomial.isPrimitive_of_dvd end Primitive variable {R : Type*} [CommRing R] [IsDomain R] section NormalizedGCDMonoid variable [NormalizedGCDMonoid R] /-- `p.content` is the `gcd` of the coefficients of `p`. -/ def content (p : R[X]) : R := p.support.gcd p.coeff #align polynomial.content Polynomial.content
Mathlib/RingTheory/Polynomial/Content.lean
83
88
theorem content_dvd_coeff {p : R[X]} (n : ℕ) : p.content ∣ p.coeff n := by
by_cases h : n ∈ p.support · apply Finset.gcd_dvd h rw [mem_support_iff, Classical.not_not] at h rw [h] apply dvd_zero
/- Copyright (c) 2021 Aaron Anderson, Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Kevin Buzzard, Yaël Dillies, Eric Wieser -/ import Mathlib.Data.Finset.Sigma import Mathlib.Data.Finset.Pairwise import Mathlib.Data.Finset.Powerset import Mathlib.Data.Fintype.Basic import Mathlib.Order.CompleteLatticeIntervals #align_import order.sup_indep from "leanprover-community/mathlib"@"c4c2ed622f43768eff32608d4a0f8a6cec1c047d" /-! # Supremum independence In this file, we define supremum independence of indexed sets. An indexed family `f : ι → α` is sup-independent if, for all `a`, `f a` and the supremum of the rest are disjoint. ## Main definitions * `Finset.SupIndep s f`: a family of elements `f` are supremum independent on the finite set `s`. * `CompleteLattice.SetIndependent s`: a set of elements are supremum independent. * `CompleteLattice.Independent f`: a family of elements are supremum independent. ## Main statements * In a distributive lattice, supremum independence is equivalent to pairwise disjointness: * `Finset.supIndep_iff_pairwiseDisjoint` * `CompleteLattice.setIndependent_iff_pairwiseDisjoint` * `CompleteLattice.independent_iff_pairwiseDisjoint` * Otherwise, supremum independence is stronger than pairwise disjointness: * `Finset.SupIndep.pairwiseDisjoint` * `CompleteLattice.SetIndependent.pairwiseDisjoint` * `CompleteLattice.Independent.pairwiseDisjoint` ## Implementation notes For the finite version, we avoid the "obvious" definition `∀ i ∈ s, Disjoint (f i) ((s.erase i).sup f)` because `erase` would require decidable equality on `ι`. -/ variable {α β ι ι' : Type*} /-! ### On lattices with a bottom element, via `Finset.sup` -/ namespace Finset section Lattice variable [Lattice α] [OrderBot α] /-- Supremum independence of finite sets. We avoid the "obvious" definition using `s.erase i` because `erase` would require decidable equality on `ι`. -/ def SupIndep (s : Finset ι) (f : ι → α) : Prop := ∀ ⦃t⦄, t ⊆ s → ∀ ⦃i⦄, i ∈ s → i ∉ t → Disjoint (f i) (t.sup f) #align finset.sup_indep Finset.SupIndep variable {s t : Finset ι} {f : ι → α} {i : ι} instance [DecidableEq ι] [DecidableEq α] : Decidable (SupIndep s f) := by refine @Finset.decidableForallOfDecidableSubsets _ _ _ (?_) rintro t - refine @Finset.decidableDforallFinset _ _ _ (?_) rintro i - have : Decidable (Disjoint (f i) (sup t f)) := decidable_of_iff' (_ = ⊥) disjoint_iff infer_instance theorem SupIndep.subset (ht : t.SupIndep f) (h : s ⊆ t) : s.SupIndep f := fun _ hu _ hi => ht (hu.trans h) (h hi) #align finset.sup_indep.subset Finset.SupIndep.subset @[simp] theorem supIndep_empty (f : ι → α) : (∅ : Finset ι).SupIndep f := fun _ _ a ha => (not_mem_empty a ha).elim #align finset.sup_indep_empty Finset.supIndep_empty theorem supIndep_singleton (i : ι) (f : ι → α) : ({i} : Finset ι).SupIndep f := fun s hs j hji hj => by rw [eq_empty_of_ssubset_singleton ⟨hs, fun h => hj (h hji)⟩, sup_empty] exact disjoint_bot_right #align finset.sup_indep_singleton Finset.supIndep_singleton theorem SupIndep.pairwiseDisjoint (hs : s.SupIndep f) : (s : Set ι).PairwiseDisjoint f := fun _ ha _ hb hab => sup_singleton.subst <| hs (singleton_subset_iff.2 hb) ha <| not_mem_singleton.2 hab #align finset.sup_indep.pairwise_disjoint Finset.SupIndep.pairwiseDisjoint theorem SupIndep.le_sup_iff (hs : s.SupIndep f) (hts : t ⊆ s) (hi : i ∈ s) (hf : ∀ i, f i ≠ ⊥) : f i ≤ t.sup f ↔ i ∈ t := by refine ⟨fun h => ?_, le_sup⟩ by_contra hit exact hf i (disjoint_self.1 <| (hs hts hi hit).mono_right h) #align finset.sup_indep.le_sup_iff Finset.SupIndep.le_sup_iff /-- The RHS looks like the definition of `CompleteLattice.Independent`. -/ theorem supIndep_iff_disjoint_erase [DecidableEq ι] : s.SupIndep f ↔ ∀ i ∈ s, Disjoint (f i) ((s.erase i).sup f) := ⟨fun hs _ hi => hs (erase_subset _ _) hi (not_mem_erase _ _), fun hs _ ht i hi hit => (hs i hi).mono_right (sup_mono fun _ hj => mem_erase.2 ⟨ne_of_mem_of_not_mem hj hit, ht hj⟩)⟩ #align finset.sup_indep_iff_disjoint_erase Finset.supIndep_iff_disjoint_erase
Mathlib/Order/SupIndep.lean
106
117
theorem SupIndep.image [DecidableEq ι] {s : Finset ι'} {g : ι' → ι} (hs : s.SupIndep (f ∘ g)) : (s.image g).SupIndep f := by
intro t ht i hi hit rw [mem_image] at hi obtain ⟨i, hi, rfl⟩ := hi haveI : DecidableEq ι' := Classical.decEq _ suffices hts : t ⊆ (s.erase i).image g by refine (supIndep_iff_disjoint_erase.1 hs i hi).mono_right ((sup_mono hts).trans ?_) rw [sup_image] rintro j hjt obtain ⟨j, hj, rfl⟩ := mem_image.1 (ht hjt) exact mem_image_of_mem _ (mem_erase.2 ⟨ne_of_apply_ne g (ne_of_mem_of_not_mem hjt hit), hj⟩)
/- Copyright (c) 2018 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad -/ import Mathlib.Data.W.Basic #align_import data.pfunctor.univariate.basic from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # Polynomial functors This file defines polynomial functors and the W-type construction as a polynomial functor. (For the M-type construction, see pfunctor/M.lean.) -/ -- "W", "Idx" set_option linter.uppercaseLean3 false universe u v v₁ v₂ v₃ /-- A polynomial functor `P` is given by a type `A` and a family `B` of types over `A`. `P` maps any type `α` to a new type `P α`, which is defined as the sigma type `Σ x, P.B x → α`. An element of `P α` is a pair `⟨a, f⟩`, where `a` is an element of a type `A` and `f : B a → α`. Think of `a` as the shape of the object and `f` as an index to the relevant elements of `α`. -/ @[pp_with_univ] structure PFunctor where /-- The head type -/ A : Type u /-- The child family of types -/ B : A → Type u #align pfunctor PFunctor namespace PFunctor instance : Inhabited PFunctor := ⟨⟨default, default⟩⟩ variable (P : PFunctor.{u}) {α : Type v₁} {β : Type v₂} {γ : Type v₃} /-- Applying `P` to an object of `Type` -/ @[coe] def Obj (α : Type v) := Σ x : P.A, P.B x → α #align pfunctor.obj PFunctor.Obj instance : CoeFun PFunctor.{u} (fun _ => Type v → Type (max u v)) where coe := Obj /-- Applying `P` to a morphism of `Type` -/ def map (f : α → β) : P α → P β := fun ⟨a, g⟩ => ⟨a, f ∘ g⟩ #align pfunctor.map PFunctor.map instance Obj.inhabited [Inhabited P.A] [Inhabited α] : Inhabited (P α) := ⟨⟨default, default⟩⟩ #align pfunctor.obj.inhabited PFunctor.Obj.inhabited instance : Functor.{v, max u v} P.Obj where map := @map P /-- We prefer `PFunctor.map` to `Functor.map` because it is universe-polymorphic. -/ @[simp] theorem map_eq_map {α β : Type v} (f : α → β) (x : P α) : f <$> x = P.map f x := rfl @[simp] protected theorem map_eq (f : α → β) (a : P.A) (g : P.B a → α) : P.map f ⟨a, g⟩ = ⟨a, f ∘ g⟩ := rfl #align pfunctor.map_eq PFunctor.map_eq @[simp] protected theorem id_map : ∀ x : P α, P.map id x = x := fun ⟨_, _⟩ => rfl #align pfunctor.id_map PFunctor.id_map @[simp] protected theorem map_map (f : α → β) (g : β → γ) : ∀ x : P α, P.map g (P.map f x) = P.map (g ∘ f) x := fun ⟨_, _⟩ => rfl #align pfunctor.comp_map PFunctor.map_map instance : LawfulFunctor.{v, max u v} P.Obj where map_const := rfl id_map x := P.id_map x comp_map f g x := P.map_map f g x |>.symm /-- re-export existing definition of W-types and adapt it to a packaged definition of polynomial functor -/ def W := WType P.B #align pfunctor.W PFunctor.W /- inhabitants of W types is awkward to encode as an instance assumption because there needs to be a value `a : P.A` such that `P.B a` is empty to yield a finite tree -/ -- Porting note(#5171): this linter isn't ported yet. -- attribute [nolint has_nonempty_instance] W variable {P} /-- root element of a W tree -/ def W.head : W P → P.A | ⟨a, _f⟩ => a #align pfunctor.W.head PFunctor.W.head /-- children of the root of a W tree -/ def W.children : ∀ x : W P, P.B (W.head x) → W P | ⟨_a, f⟩ => f #align pfunctor.W.children PFunctor.W.children /-- destructor for W-types -/ def W.dest : W P → P (W P) | ⟨a, f⟩ => ⟨a, f⟩ #align pfunctor.W.dest PFunctor.W.dest /-- constructor for W-types -/ def W.mk : P (W P) → W P | ⟨a, f⟩ => ⟨a, f⟩ #align pfunctor.W.mk PFunctor.W.mk @[simp] theorem W.dest_mk (p : P (W P)) : W.dest (W.mk p) = p := by cases p; rfl #align pfunctor.W.dest_mk PFunctor.W.dest_mk @[simp] theorem W.mk_dest (p : W P) : W.mk (W.dest p) = p := by cases p; rfl #align pfunctor.W.mk_dest PFunctor.W.mk_dest variable (P) /-- `Idx` identifies a location inside the application of a pfunctor. For `F : PFunctor`, `x : F α` and `i : F.Idx`, `i` can designate one part of `x` or is invalid, if `i.1 ≠ x.1` -/ def Idx := Σ x : P.A, P.B x #align pfunctor.Idx PFunctor.Idx instance Idx.inhabited [Inhabited P.A] [Inhabited (P.B default)] : Inhabited P.Idx := ⟨⟨default, default⟩⟩ #align pfunctor.Idx.inhabited PFunctor.Idx.inhabited variable {P} /-- `x.iget i` takes the component of `x` designated by `i` if any is or returns a default value -/ def Obj.iget [DecidableEq P.A] {α} [Inhabited α] (x : P α) (i : P.Idx) : α := if h : i.1 = x.1 then x.2 (cast (congr_arg _ h) i.2) else default #align pfunctor.obj.iget PFunctor.Obj.iget @[simp]
Mathlib/Data/PFunctor/Univariate/Basic.lean
154
154
theorem fst_map (x : P α) (f : α → β) : (P.map f x).1 = x.1 := by
cases x; rfl
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Scott Morrison -/ import Mathlib.Algebra.Homology.ComplexShape import Mathlib.CategoryTheory.Subobject.Limits import Mathlib.CategoryTheory.GradedObject import Mathlib.Algebra.Homology.ShortComplex.Basic #align_import algebra.homology.homological_complex from "leanprover-community/mathlib"@"88bca0ce5d22ebfd9e73e682e51d60ea13b48347" /-! # Homological complexes. A `HomologicalComplex V c` with a "shape" controlled by `c : ComplexShape ι` has chain groups `X i` (objects in `V`) indexed by `i : ι`, and a differential `d i j` whenever `c.Rel i j`. We in fact ask for differentials `d i j` for all `i j : ι`, but have a field `shape` requiring that these are zero when not allowed by `c`. This avoids a lot of dependent type theory hell! The composite of any two differentials `d i j ≫ d j k` must be zero. We provide `ChainComplex V α` for `α`-indexed chain complexes in which `d i j ≠ 0` only if `j + 1 = i`, and similarly `CochainComplex V α`, with `i = j + 1`. There is a category structure, where morphisms are chain maps. For `C : HomologicalComplex V c`, we define `C.xNext i`, which is either `C.X j` for some arbitrarily chosen `j` such that `c.r i j`, or `C.X i` if there is no such `j`. Similarly we have `C.xPrev j`. Defined in terms of these we have `C.dFrom i : C.X i ⟶ C.xNext i` and `C.dTo j : C.xPrev j ⟶ C.X j`, which are either defined as `C.d i j`, or zero, as needed. -/ universe v u open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {ι : Type*} variable (V : Type u) [Category.{v} V] [HasZeroMorphisms V] /-- A `HomologicalComplex V c` with a "shape" controlled by `c : ComplexShape ι` has chain groups `X i` (objects in `V`) indexed by `i : ι`, and a differential `d i j` whenever `c.Rel i j`. We in fact ask for differentials `d i j` for all `i j : ι`, but have a field `shape` requiring that these are zero when not allowed by `c`. This avoids a lot of dependent type theory hell! The composite of any two differentials `d i j ≫ d j k` must be zero. -/ structure HomologicalComplex (c : ComplexShape ι) where X : ι → V d : ∀ i j, X i ⟶ X j shape : ∀ i j, ¬c.Rel i j → d i j = 0 := by aesop_cat d_comp_d' : ∀ i j k, c.Rel i j → c.Rel j k → d i j ≫ d j k = 0 := by aesop_cat #align homological_complex HomologicalComplex namespace HomologicalComplex attribute [simp] shape variable {V} {c : ComplexShape ι} @[reassoc (attr := simp)] theorem d_comp_d (C : HomologicalComplex V c) (i j k : ι) : C.d i j ≫ C.d j k = 0 := by by_cases hij : c.Rel i j · by_cases hjk : c.Rel j k · exact C.d_comp_d' i j k hij hjk · rw [C.shape j k hjk, comp_zero] · rw [C.shape i j hij, zero_comp] #align homological_complex.d_comp_d HomologicalComplex.d_comp_d
Mathlib/Algebra/Homology/HomologicalComplex.lean
79
92
theorem ext {C₁ C₂ : HomologicalComplex V c} (h_X : C₁.X = C₂.X) (h_d : ∀ i j : ι, c.Rel i j → C₁.d i j ≫ eqToHom (congr_fun h_X j) = eqToHom (congr_fun h_X i) ≫ C₂.d i j) : C₁ = C₂ := by
obtain ⟨X₁, d₁, s₁, h₁⟩ := C₁ obtain ⟨X₂, d₂, s₂, h₂⟩ := C₂ dsimp at h_X subst h_X simp only [mk.injEq, heq_eq_eq, true_and] ext i j by_cases hij: c.Rel i j · simpa only [comp_id, id_comp, eqToHom_refl] using h_d i j hij · rw [s₁ i j hij, s₂ i j hij]
/- Copyright (c) 2022 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Tactic.AdaptationNote #align_import geometry.euclidean.inversion from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Inversion in an affine space In this file we define inversion in a sphere in an affine space. This map sends each point `x` to the point `y` such that `y -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c)`, where `c` and `R` are the center and the radius the sphere. In many applications, it is convenient to assume that the inversions swaps the center and the point at infinity. In order to stay in the original affine space, we define the map so that it sends center to itself. Currently, we prove only a few basic lemmas needed to prove Ptolemy's inequality, see `EuclideanGeometry.mul_dist_le_mul_dist_add_mul_dist`. -/ noncomputable section open Metric Function AffineMap Set AffineSubspace open scoped Topology variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] namespace EuclideanGeometry variable {a b c d x y z : P} {r R : ℝ} /-- Inversion in a sphere in an affine space. This map sends each point `x` to the point `y` such that `y -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c)`, where `c` and `R` are the center and the radius the sphere. -/ def inversion (c : P) (R : ℝ) (x : P) : P := (R / dist x c) ^ 2 • (x -ᵥ c) +ᵥ c #align euclidean_geometry.inversion EuclideanGeometry.inversion #adaptation_note /-- nightly-2024-03-16: added to replace simp [inversion] -/ theorem inversion_def : inversion = fun (c : P) (R : ℝ) (x : P) => (R / dist x c) ^ 2 • (x -ᵥ c) +ᵥ c := rfl /-! ### Basic properties In this section we prove that `EuclideanGeometry.inversion c R` is involutive and preserves the sphere `Metric.sphere c R`. We also prove that the distance to the center of the image of `x` under this inversion is given by `R ^ 2 / dist x c`. -/ theorem inversion_eq_lineMap (c : P) (R : ℝ) (x : P) : inversion c R x = lineMap c x ((R / dist x c) ^ 2) := rfl theorem inversion_vsub_center (c : P) (R : ℝ) (x : P) : inversion c R x -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c) := vadd_vsub _ _ #align euclidean_geometry.inversion_vsub_center EuclideanGeometry.inversion_vsub_center @[simp] theorem inversion_self (c : P) (R : ℝ) : inversion c R c = c := by simp [inversion] #align euclidean_geometry.inversion_self EuclideanGeometry.inversion_self @[simp] theorem inversion_zero_radius (c x : P) : inversion c 0 x = c := by simp [inversion] theorem inversion_mul (c : P) (a R : ℝ) (x : P) : inversion c (a * R) x = homothety c (a ^ 2) (inversion c R x) := by simp only [inversion_eq_lineMap, ← homothety_eq_lineMap, ← homothety_mul_apply, mul_div_assoc, mul_pow] @[simp] theorem inversion_dist_center (c x : P) : inversion c (dist x c) x = x := by rcases eq_or_ne x c with (rfl | hne) · apply inversion_self · rw [inversion, div_self, one_pow, one_smul, vsub_vadd] rwa [dist_ne_zero] #align euclidean_geometry.inversion_dist_center EuclideanGeometry.inversion_dist_center @[simp] theorem inversion_dist_center' (c x : P) : inversion c (dist c x) x = x := by rw [dist_comm, inversion_dist_center] theorem inversion_of_mem_sphere (h : x ∈ Metric.sphere c R) : inversion c R x = x := h.out ▸ inversion_dist_center c x #align euclidean_geometry.inversion_of_mem_sphere EuclideanGeometry.inversion_of_mem_sphere /-- Distance from the image of a point under inversion to the center. This formula accidentally works for `x = c`. -/
Mathlib/Geometry/Euclidean/Inversion/Basic.lean
98
102
theorem dist_inversion_center (c x : P) (R : ℝ) : dist (inversion c R x) c = R ^ 2 / dist x c := by
rcases eq_or_ne x c with (rfl | hx) · simp have : dist x c ≠ 0 := dist_ne_zero.2 hx field_simp [inversion, norm_smul, abs_div, ← dist_eq_norm_vsub, sq, mul_assoc]
/- Copyright (c) 2019 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen, Eric Wieser -/ import Mathlib.Data.Matrix.Basic /-! # Row and column matrices This file provides results about row and column matrices ## Main definitions * `Matrix.row r : Matrix Unit n α`: a matrix with a single row * `Matrix.col c : Matrix m Unit α`: a matrix with a single column * `Matrix.updateRow M i r`: update the `i`th row of `M` to `r` * `Matrix.updateCol M j c`: update the `j`th column of `M` to `c` -/ variable {l m n o : Type*} universe u v w variable {R : Type*} {α : Type v} {β : Type w} namespace Matrix /-- `Matrix.col u` is the column matrix whose entries are given by `u`. -/ def col (w : m → α) : Matrix m Unit α := of fun x _ => w x #align matrix.col Matrix.col -- TODO: set as an equation lemma for `col`, see mathlib4#3024 @[simp] theorem col_apply (w : m → α) (i j) : col w i j = w i := rfl #align matrix.col_apply Matrix.col_apply /-- `Matrix.row u` is the row matrix whose entries are given by `u`. -/ def row (v : n → α) : Matrix Unit n α := of fun _ y => v y #align matrix.row Matrix.row -- TODO: set as an equation lemma for `row`, see mathlib4#3024 @[simp] theorem row_apply (v : n → α) (i j) : row v i j = v j := rfl #align matrix.row_apply Matrix.row_apply theorem col_injective : Function.Injective (col : (m → α) → _) := fun _x _y h => funext fun i => congr_fun₂ h i () @[simp] theorem col_inj {v w : m → α} : col v = col w ↔ v = w := col_injective.eq_iff @[simp] theorem col_zero [Zero α] : col (0 : m → α) = 0 := rfl @[simp] theorem col_eq_zero [Zero α] (v : m → α) : col v = 0 ↔ v = 0 := col_inj @[simp] theorem col_add [Add α] (v w : m → α) : col (v + w) = col v + col w := by ext rfl #align matrix.col_add Matrix.col_add @[simp] theorem col_smul [SMul R α] (x : R) (v : m → α) : col (x • v) = x • col v := by ext rfl #align matrix.col_smul Matrix.col_smul theorem row_injective : Function.Injective (row : (n → α) → _) := fun _x _y h => funext fun j => congr_fun₂ h () j @[simp] theorem row_inj {v w : n → α} : row v = row w ↔ v = w := row_injective.eq_iff @[simp] theorem row_zero [Zero α] : row (0 : n → α) = 0 := rfl @[simp] theorem row_eq_zero [Zero α] (v : n → α) : row v = 0 ↔ v = 0 := row_inj @[simp] theorem row_add [Add α] (v w : m → α) : row (v + w) = row v + row w := by ext rfl #align matrix.row_add Matrix.row_add @[simp]
Mathlib/Data/Matrix/RowCol.lean
88
90
theorem row_smul [SMul R α] (x : R) (v : m → α) : row (x • v) = x • row v := by
ext rfl
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.Fintype.List #align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49" /-! # Cycles of a list Lists have an equivalence relation of whether they are rotational permutations of one another. This relation is defined as `IsRotated`. Based on this, we define the quotient of lists by the rotation relation, called `Cycle`. We also define a representation of concrete cycles, available when viewing them in a goal state or via `#eval`, when over representable types. For example, the cycle `(2 1 4 3)` will be shown as `c[2, 1, 4, 3]`. Two equal cycles may be printed differently if their internal representation is different. -/ assert_not_exists MonoidWithZero namespace List variable {α : Type*} [DecidableEq α] /-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/ def nextOr : ∀ (_ : List α) (_ _ : α), α | [], _, default => default | [_], _, default => default -- Handles the not-found and the wraparound case | y :: z :: xs, x, default => if x = y then z else nextOr (z :: xs) x default #align list.next_or List.nextOr @[simp] theorem nextOr_nil (x d : α) : nextOr [] x d = d := rfl #align list.next_or_nil List.nextOr_nil @[simp] theorem nextOr_singleton (x y d : α) : nextOr [y] x d = d := rfl #align list.next_or_singleton List.nextOr_singleton @[simp] theorem nextOr_self_cons_cons (xs : List α) (x y d : α) : nextOr (x :: y :: xs) x d = y := if_pos rfl #align list.next_or_self_cons_cons List.nextOr_self_cons_cons theorem nextOr_cons_of_ne (xs : List α) (y x d : α) (h : x ≠ y) : nextOr (y :: xs) x d = nextOr xs x d := by cases' xs with z zs · rfl · exact if_neg h #align list.next_or_cons_of_ne List.nextOr_cons_of_ne /-- `nextOr` does not depend on the default value, if the next value appears. -/ theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x ∈ xs) (x_ne : x ≠ xs.getLast (ne_nil_of_mem x_mem)) : nextOr xs x d = nextOr xs x d' := by induction' xs with y ys IH · cases x_mem cases' ys with z zs · simp at x_mem x_ne contradiction by_cases h : x = y · rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons] · rw [nextOr, nextOr, IH] · simpa [h] using x_mem · simpa using x_ne #align list.next_or_eq_next_or_of_mem_of_ne List.nextOr_eq_nextOr_of_mem_of_ne theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x ∈ xs := by induction' xs with y ys IH · simp at h cases' ys with z zs · simp at h · by_cases hx : x = y · simp [hx] · rw [nextOr_cons_of_ne _ _ _ _ hx] at h simpa [hx] using IH h #align list.mem_of_next_or_ne List.mem_of_nextOr_ne
Mathlib/Data/List/Cycle.lean
87
91
theorem nextOr_concat {xs : List α} {x : α} (d : α) (h : x ∉ xs) : nextOr (xs ++ [x]) x d = d := by
induction' xs with z zs IH · simp · obtain ⟨hz, hzs⟩ := not_or.mp (mt mem_cons.2 h) rw [cons_append, nextOr_cons_of_ne _ _ _ _ hz, IH hzs]
/- Copyright (c) 2021 Noam Atar. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Noam Atar -/ import Mathlib.Order.Ideal import Mathlib.Order.PFilter #align_import order.prime_ideal from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da" /-! # Prime ideals ## Main definitions Throughout this file, `P` is at least a preorder, but some sections require more structure, such as a bottom element, a top element, or a join-semilattice structure. - `Order.Ideal.PrimePair`: A pair of an `Order.Ideal` and an `Order.PFilter` which form a partition of `P`. This is useful as giving the data of a prime ideal is the same as giving the data of a prime filter. - `Order.Ideal.IsPrime`: a predicate for prime ideals. Dual to the notion of a prime filter. - `Order.PFilter.IsPrime`: a predicate for prime filters. Dual to the notion of a prime ideal. ## References - <https://en.wikipedia.org/wiki/Ideal_(order_theory)> ## Tags ideal, prime -/ open Order.PFilter namespace Order variable {P : Type*} namespace Ideal /-- A pair of an `Order.Ideal` and an `Order.PFilter` which form a partition of `P`. -/ -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] structure PrimePair (P : Type*) [Preorder P] where I : Ideal P F : PFilter P isCompl_I_F : IsCompl (I : Set P) F #align order.ideal.prime_pair Order.Ideal.PrimePair namespace PrimePair variable [Preorder P] (IF : PrimePair P) theorem compl_I_eq_F : (IF.I : Set P)ᶜ = IF.F := IF.isCompl_I_F.compl_eq set_option linter.uppercaseLean3 false in #align order.ideal.prime_pair.compl_I_eq_F Order.Ideal.PrimePair.compl_I_eq_F theorem compl_F_eq_I : (IF.F : Set P)ᶜ = IF.I := IF.isCompl_I_F.eq_compl.symm set_option linter.uppercaseLean3 false in #align order.ideal.prime_pair.compl_F_eq_I Order.Ideal.PrimePair.compl_F_eq_I theorem I_isProper : IsProper IF.I := by cases' IF.F.nonempty with w h apply isProper_of_not_mem (_ : w ∉ IF.I) rwa [← IF.compl_I_eq_F] at h set_option linter.uppercaseLean3 false in #align order.ideal.prime_pair.I_is_proper Order.Ideal.PrimePair.I_isProper protected theorem disjoint : Disjoint (IF.I : Set P) IF.F := IF.isCompl_I_F.disjoint #align order.ideal.prime_pair.disjoint Order.Ideal.PrimePair.disjoint theorem I_union_F : (IF.I : Set P) ∪ IF.F = Set.univ := IF.isCompl_I_F.sup_eq_top set_option linter.uppercaseLean3 false in #align order.ideal.prime_pair.I_union_F Order.Ideal.PrimePair.I_union_F theorem F_union_I : (IF.F : Set P) ∪ IF.I = Set.univ := IF.isCompl_I_F.symm.sup_eq_top set_option linter.uppercaseLean3 false in #align order.ideal.prime_pair.F_union_I Order.Ideal.PrimePair.F_union_I end PrimePair /-- An ideal `I` is prime if its complement is a filter. -/ @[mk_iff] class IsPrime [Preorder P] (I : Ideal P) extends IsProper I : Prop where compl_filter : IsPFilter (I : Set P)ᶜ #align order.ideal.is_prime Order.Ideal.IsPrime section Preorder variable [Preorder P] /-- Create an element of type `Order.Ideal.PrimePair` from an ideal satisfying the predicate `Order.Ideal.IsPrime`. -/ def IsPrime.toPrimePair {I : Ideal P} (h : IsPrime I) : PrimePair P := { I F := h.compl_filter.toPFilter isCompl_I_F := isCompl_compl } #align order.ideal.is_prime.to_prime_pair Order.Ideal.IsPrime.toPrimePair theorem PrimePair.I_isPrime (IF : PrimePair P) : IsPrime IF.I := { IF.I_isProper with compl_filter := by rw [IF.compl_I_eq_F] exact IF.F.isPFilter } set_option linter.uppercaseLean3 false in #align order.ideal.prime_pair.I_is_prime Order.Ideal.PrimePair.I_isPrime end Preorder section SemilatticeInf variable [SemilatticeInf P] {x y : P} {I : Ideal P} theorem IsPrime.mem_or_mem (hI : IsPrime I) {x y : P} : x ⊓ y ∈ I → x ∈ I ∨ y ∈ I := by contrapose! let F := hI.compl_filter.toPFilter show x ∈ F ∧ y ∈ F → x ⊓ y ∈ F exact fun h => inf_mem h.1 h.2 #align order.ideal.is_prime.mem_or_mem Order.Ideal.IsPrime.mem_or_mem
Mathlib/Order/PrimeIdeal.lean
131
139
theorem IsPrime.of_mem_or_mem [IsProper I] (hI : ∀ {x y : P}, x ⊓ y ∈ I → x ∈ I ∨ y ∈ I) : IsPrime I := by
rw [isPrime_iff] use ‹_› refine .of_def ?_ ?_ ?_ · exact Set.nonempty_compl.2 (I.isProper_iff.1 ‹_›) · intro x hx y hy exact ⟨x ⊓ y, fun h => (hI h).elim hx hy, inf_le_left, inf_le_right⟩ · exact @mem_compl_of_ge _ _ _
/- Copyright (c) 2024 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Chambert-Loir, Oliver Nash -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Identities import Mathlib.RingTheory.Nilpotent.Lemmas import Mathlib.RingTheory.Polynomial.Nilpotent import Mathlib.RingTheory.Polynomial.Tower /-! # Newton-Raphson method Given a single-variable polynomial `P` with derivative `P'`, Newton's method concerns iteration of the rational map: `x ↦ x - P(x) / P'(x)`. Over a field it can serve as a root-finding algorithm. It is also useful tool in certain proofs such as Hensel's lemma and Jordan-Chevalley decomposition. ## Main definitions / results: * `Polynomial.newtonMap`: the map `x ↦ x - P(x) / P'(x)`, where `P'` is the derivative of the polynomial `P`. * `Polynomial.isFixedPt_newtonMap_of_isUnit_iff`: `x` is a fixed point for Newton iteration iff it is a root of `P` (provided `P'(x)` is a unit). * `Polynomial.exists_unique_nilpotent_sub_and_aeval_eq_zero`: if `x` is almost a root of `P` in the sense that `P(x)` is nilpotent (and `P'(x)` is a unit) then we may write `x` as a sum `x = n + r` where `n` is nilpotent and `r` is a root of `P`. This can be used to prove the Jordan-Chevalley decomposition of linear endomorphims. -/ open Set Function noncomputable section namespace Polynomial variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] (P : R[X]) {x : S} /-- Given a single-variable polynomial `P` with derivative `P'`, this is the map: `x ↦ x - P(x) / P'(x)`. When `P'(x)` is not a unit we use a junk-value pattern and send `x ↦ x`. -/ def newtonMap (x : S) : S := x - (Ring.inverse <| aeval x (derivative P)) * aeval x P theorem newtonMap_apply : P.newtonMap x = x - (Ring.inverse <| aeval x (derivative P)) * (aeval x P) := rfl variable {P} theorem newtonMap_apply_of_isUnit (h : IsUnit <| aeval x (derivative P)) : P.newtonMap x = x - h.unit⁻¹ * aeval x P := by simp [newtonMap_apply, Ring.inverse, h] theorem newtonMap_apply_of_not_isUnit (h : ¬ (IsUnit <| aeval x (derivative P))) : P.newtonMap x = x := by simp [newtonMap_apply, Ring.inverse, h]
Mathlib/Dynamics/Newton.lean
61
69
theorem isNilpotent_iterate_newtonMap_sub_of_isNilpotent (h : IsNilpotent <| aeval x P) (n : ℕ) : IsNilpotent <| P.newtonMap^[n] x - x := by
induction n with | zero => simp | succ n ih => rw [iterate_succ', comp_apply, newtonMap_apply, sub_right_comm] refine (Commute.all _ _).isNilpotent_sub ih <| (Commute.all _ _).isNilpotent_mul_right ?_ simpa using Commute.isNilpotent_add (Commute.all _ _) (isNilpotent_aeval_sub_of_isNilpotent_sub P ih) h
/- 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.Generator import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic #align_import category_theory.preadditive.generator from "leanprover-community/mathlib"@"09f981f72d43749f1fa072deade828d9c1e185bb" /-! # Separators in preadditive categories This file contains characterizations of separating sets and objects that are valid in all preadditive categories. -/ universe v u open CategoryTheory Opposite namespace CategoryTheory variable {C : Type u} [Category.{v} C] [Preadditive C] theorem Preadditive.isSeparating_iff (𝒢 : Set C) : IsSeparating 𝒢 ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : G ⟶ X), h ≫ f = 0) → f = 0 := ⟨fun h𝒢 X Y f hf => h𝒢 _ _ (by simpa only [Limits.comp_zero] using hf), fun h𝒢 X Y f g hfg => sub_eq_zero.1 <| h𝒢 _ (by simpa only [Preadditive.comp_sub, sub_eq_zero] using hfg)⟩ #align category_theory.preadditive.is_separating_iff CategoryTheory.Preadditive.isSeparating_iff theorem Preadditive.isCoseparating_iff (𝒢 : Set C) : IsCoseparating 𝒢 ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : Y ⟶ G), f ≫ h = 0) → f = 0 := ⟨fun h𝒢 X Y f hf => h𝒢 _ _ (by simpa only [Limits.zero_comp] using hf), fun h𝒢 X Y f g hfg => sub_eq_zero.1 <| h𝒢 _ (by simpa only [Preadditive.sub_comp, sub_eq_zero] using hfg)⟩ #align category_theory.preadditive.is_coseparating_iff CategoryTheory.Preadditive.isCoseparating_iff theorem Preadditive.isSeparator_iff (G : C) : IsSeparator G ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ h : G ⟶ X, h ≫ f = 0) → f = 0 := ⟨fun hG X Y f hf => hG.def _ _ (by simpa only [Limits.comp_zero] using hf), fun hG => (isSeparator_def _).2 fun X Y f g hfg => sub_eq_zero.1 <| hG _ (by simpa only [Preadditive.comp_sub, sub_eq_zero] using hfg)⟩ #align category_theory.preadditive.is_separator_iff CategoryTheory.Preadditive.isSeparator_iff theorem Preadditive.isCoseparator_iff (G : C) : IsCoseparator G ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ h : Y ⟶ G, f ≫ h = 0) → f = 0 := ⟨fun hG X Y f hf => hG.def _ _ (by simpa only [Limits.zero_comp] using hf), fun hG => (isCoseparator_def _).2 fun X Y f g hfg => sub_eq_zero.1 <| hG _ (by simpa only [Preadditive.sub_comp, sub_eq_zero] using hfg)⟩ #align category_theory.preadditive.is_coseparator_iff CategoryTheory.Preadditive.isCoseparator_iff theorem isSeparator_iff_faithful_preadditiveCoyoneda (G : C) : IsSeparator G ↔ (preadditiveCoyoneda.obj (op G)).Faithful := by rw [isSeparator_iff_faithful_coyoneda_obj, ← whiskering_preadditiveCoyoneda, Functor.comp_obj, whiskeringRight_obj_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget AddCommGroupCat), fun h => Functor.Faithful.comp _ _⟩ #align category_theory.is_separator_iff_faithful_preadditive_coyoneda CategoryTheory.isSeparator_iff_faithful_preadditiveCoyoneda theorem isSeparator_iff_faithful_preadditiveCoyonedaObj (G : C) : IsSeparator G ↔ (preadditiveCoyonedaObj (op G)).Faithful := by rw [isSeparator_iff_faithful_preadditiveCoyoneda, preadditiveCoyoneda_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget₂ _ AddCommGroupCat.{v}), fun h => Functor.Faithful.comp _ _⟩ #align category_theory.is_separator_iff_faithful_preadditive_coyoneda_obj CategoryTheory.isSeparator_iff_faithful_preadditiveCoyonedaObj
Mathlib/CategoryTheory/Preadditive/Generator.lean
69
74
theorem isCoseparator_iff_faithful_preadditiveYoneda (G : C) : IsCoseparator G ↔ (preadditiveYoneda.obj G).Faithful := by
rw [isCoseparator_iff_faithful_yoneda_obj, ← whiskering_preadditiveYoneda, Functor.comp_obj, whiskeringRight_obj_obj] exact ⟨fun h => Functor.Faithful.of_comp _ (forget AddCommGroupCat), fun h => Functor.Faithful.comp _ _⟩
/- Copyright (c) 2020 Bryan Gin-ge Chen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bryan Gin-ge Chen, Kevin Lacker -/ import Mathlib.Tactic.Ring #align_import algebra.group_power.identities from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23" /-! # Identities This file contains some "named" commutative ring identities. -/ variable {R : Type*} [CommRing R] {a b x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ y₁ y₂ y₃ y₄ y₅ y₆ y₇ y₈ n : R} /-- Brahmagupta-Fibonacci identity or Diophantus identity, see <https://en.wikipedia.org/wiki/Brahmagupta%E2%80%93Fibonacci_identity>. This sign choice here corresponds to the signs obtained by multiplying two complex numbers. -/
Mathlib/Algebra/Ring/Identities.lean
24
26
theorem sq_add_sq_mul_sq_add_sq : (x₁ ^ 2 + x₂ ^ 2) * (y₁ ^ 2 + y₂ ^ 2) = (x₁ * y₁ - x₂ * y₂) ^ 2 + (x₁ * y₂ + x₂ * y₁) ^ 2 := by
ring
/- Copyright (c) 2022 Rémi Bottinelli. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémi Bottinelli, Junyan Xu -/ import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.CategoryTheory.Groupoid.VertexGroup import Mathlib.CategoryTheory.Groupoid.Basic import Mathlib.CategoryTheory.Groupoid import Mathlib.Data.Set.Lattice import Mathlib.Order.GaloisConnection #align_import category_theory.groupoid.subgroupoid from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Subgroupoid This file defines subgroupoids as `structure`s containing the subsets of arrows and their stability under composition and inversion. Also defined are: * containment of subgroupoids is a complete lattice; * images and preimages of subgroupoids under a functor; * the notion of normality of subgroupoids and its stability under intersection and preimage; * compatibility of the above with `CategoryTheory.Groupoid.vertexGroup`. ## Main definitions Given a type `C` with associated `groupoid C` instance. * `CategoryTheory.Subgroupoid C` is the type of subgroupoids of `C` * `CategoryTheory.Subgroupoid.IsNormal` is the property that the subgroupoid is stable under conjugation by arbitrary arrows, _and_ that all identity arrows are contained in the subgroupoid. * `CategoryTheory.Subgroupoid.comap` is the "preimage" map of subgroupoids along a functor. * `CategoryTheory.Subgroupoid.map` is the "image" map of subgroupoids along a functor _injective on objects_. * `CategoryTheory.Subgroupoid.vertexSubgroup` is the subgroup of the `vertex group` at a given vertex `v`, assuming `v` is contained in the `CategoryTheory.Subgroupoid` (meaning, by definition, that the arrow `𝟙 v` is contained in the subgroupoid). ## Implementation details The structure of this file is copied from/inspired by `Mathlib/GroupTheory/Subgroup/Basic.lean` and `Mathlib/Combinatorics/SimpleGraph/Subgraph.lean`. ## TODO * Equivalent inductive characterization of generated (normal) subgroupoids. * Characterization of normal subgroupoids as kernels. * Prove that `CategoryTheory.Subgroupoid.full` and `CategoryTheory.Subgroupoid.disconnect` preserve intersections (and `CategoryTheory.Subgroupoid.disconnect` also unions) ## Tags category theory, groupoid, subgroupoid -/ namespace CategoryTheory open Set Groupoid universe u v variable {C : Type u} [Groupoid C] /-- A sugroupoid of `C` consists of a choice of arrows for each pair of vertices, closed under composition and inverses. -/ @[ext] structure Subgroupoid (C : Type u) [Groupoid C] where arrows : ∀ c d : C, Set (c ⟶ d) protected inv : ∀ {c d} {p : c ⟶ d}, p ∈ arrows c d → Groupoid.inv p ∈ arrows d c protected mul : ∀ {c d e} {p}, p ∈ arrows c d → ∀ {q}, q ∈ arrows d e → p ≫ q ∈ arrows c e #align category_theory.subgroupoid CategoryTheory.Subgroupoid namespace Subgroupoid variable (S : Subgroupoid C) theorem inv_mem_iff {c d : C} (f : c ⟶ d) : Groupoid.inv f ∈ S.arrows d c ↔ f ∈ S.arrows c d := by constructor · intro h simpa only [inv_eq_inv, IsIso.inv_inv] using S.inv h · apply S.inv #align category_theory.subgroupoid.inv_mem_iff CategoryTheory.Subgroupoid.inv_mem_iff theorem mul_mem_cancel_left {c d e : C} {f : c ⟶ d} {g : d ⟶ e} (hf : f ∈ S.arrows c d) : f ≫ g ∈ S.arrows c e ↔ g ∈ S.arrows d e := by constructor · rintro h suffices Groupoid.inv f ≫ f ≫ g ∈ S.arrows d e by simpa only [inv_eq_inv, IsIso.inv_hom_id_assoc] using this apply S.mul (S.inv hf) h · apply S.mul hf #align category_theory.subgroupoid.mul_mem_cancel_left CategoryTheory.Subgroupoid.mul_mem_cancel_left
Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean
100
107
theorem mul_mem_cancel_right {c d e : C} {f : c ⟶ d} {g : d ⟶ e} (hg : g ∈ S.arrows d e) : f ≫ g ∈ S.arrows c e ↔ f ∈ S.arrows c d := by
constructor · rintro h suffices (f ≫ g) ≫ Groupoid.inv g ∈ S.arrows c d by simpa only [inv_eq_inv, IsIso.hom_inv_id, Category.comp_id, Category.assoc] using this apply S.mul h (S.inv hg) · exact fun hf => S.mul hf hg
/- Copyright (c) 2019 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johan Commelin -/ import Mathlib.RingTheory.IntegralClosure #align_import field_theory.minpoly.basic from "leanprover-community/mathlib"@"df0098f0db291900600f32070f6abb3e178be2ba" /-! # Minimal polynomials This file defines the minimal polynomial of an element `x` of an `A`-algebra `B`, under the assumption that x is integral over `A`, and derives some basic properties such as irreducibility under the assumption `B` is a domain. -/ open scoped Classical open Polynomial Set Function variable {A B B' : Type*} section MinPolyDef variable (A) [CommRing A] [Ring B] [Algebra A B] /-- Suppose `x : B`, where `B` is an `A`-algebra. The minimal polynomial `minpoly A x` of `x` is a monic polynomial with coefficients in `A` of smallest degree that has `x` as its root, if such exists (`IsIntegral A x`) or zero otherwise. For example, if `V` is a `𝕜`-vector space for some field `𝕜` and `f : V →ₗ[𝕜] V` then the minimal polynomial of `f` is `minpoly 𝕜 f`. -/ noncomputable def minpoly (x : B) : A[X] := if hx : IsIntegral A x then degree_lt_wf.min _ hx else 0 #align minpoly minpoly end MinPolyDef namespace minpoly section Ring variable [CommRing A] [Ring B] [Ring B'] [Algebra A B] [Algebra A B'] variable {x : B} /-- A minimal polynomial is monic. -/ theorem monic (hx : IsIntegral A x) : Monic (minpoly A x) := by delta minpoly rw [dif_pos hx] exact (degree_lt_wf.min_mem _ hx).1 #align minpoly.monic minpoly.monic /-- A minimal polynomial is nonzero. -/ theorem ne_zero [Nontrivial A] (hx : IsIntegral A x) : minpoly A x ≠ 0 := (monic hx).ne_zero #align minpoly.ne_zero minpoly.ne_zero theorem eq_zero (hx : ¬IsIntegral A x) : minpoly A x = 0 := dif_neg hx #align minpoly.eq_zero minpoly.eq_zero theorem algHom_eq (f : B →ₐ[A] B') (hf : Function.Injective f) (x : B) : minpoly A (f x) = minpoly A x := by refine dif_ctx_congr (isIntegral_algHom_iff _ hf) (fun _ => ?_) fun _ => rfl simp_rw [← Polynomial.aeval_def, aeval_algHom, AlgHom.comp_apply, _root_.map_eq_zero_iff f hf] #align minpoly.minpoly_alg_hom minpoly.algHom_eq theorem algebraMap_eq {B} [CommRing B] [Algebra A B] [Algebra B B'] [IsScalarTower A B B'] (h : Function.Injective (algebraMap B B')) (x : B) : minpoly A (algebraMap B B' x) = minpoly A x := algHom_eq (IsScalarTower.toAlgHom A B B') h x @[simp] theorem algEquiv_eq (f : B ≃ₐ[A] B') (x : B) : minpoly A (f x) = minpoly A x := algHom_eq (f : B →ₐ[A] B') f.injective x #align minpoly.minpoly_alg_equiv minpoly.algEquiv_eq variable (A x) /-- An element is a root of its minimal polynomial. -/ @[simp]
Mathlib/FieldTheory/Minpoly/Basic.lean
87
91
theorem aeval : aeval x (minpoly A x) = 0 := by
delta minpoly split_ifs with hx · exact (degree_lt_wf.min_mem _ hx).2 · exact aeval_zero _
/- Copyright (c) 2021 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Order.RelClasses #align_import data.sigma.lex from "leanprover-community/mathlib"@"41cf0cc2f528dd40a8f2db167ea4fb37b8fde7f3" /-! # Lexicographic order on a sigma type This defines the lexicographical order of two arbitrary relations on a sigma type and proves some lemmas about `PSigma.Lex`, which is defined in core Lean. Given a relation in the index type and a relation on each summand, the lexicographical order on the sigma type relates `a` and `b` if their summands are related or they are in the same summand and related by the summand's relation. ## See also Related files are: * `Combinatorics.CoLex`: Colexicographic order on finite sets. * `Data.List.Lex`: Lexicographic order on lists. * `Data.Sigma.Order`: Lexicographic order on `Σ i, α i` per say. * `Data.PSigma.Order`: Lexicographic order on `Σ' i, α i`. * `Data.Prod.Lex`: Lexicographic order on `α × β`. Can be thought of as the special case of `Sigma.Lex` where all summands are the same -/ namespace Sigma variable {ι : Type*} {α : ι → Type*} {r r₁ r₂ : ι → ι → Prop} {s s₁ s₂ : ∀ i, α i → α i → Prop} {a b : Σ i, α i} /-- The lexicographical order on a sigma type. It takes in a relation on the index type and a relation for each summand. `a` is related to `b` iff their summands are related or they are in the same summand and are related through the summand's relation. -/ inductive Lex (r : ι → ι → Prop) (s : ∀ i, α i → α i → Prop) : ∀ _ _ : Σ i, α i, Prop | left {i j : ι} (a : α i) (b : α j) : r i j → Lex r s ⟨i, a⟩ ⟨j, b⟩ | right {i : ι} (a b : α i) : s i a b → Lex r s ⟨i, a⟩ ⟨i, b⟩ #align sigma.lex Sigma.Lex theorem lex_iff : Lex r s a b ↔ r a.1 b.1 ∨ ∃ h : a.1 = b.1, s b.1 (h.rec a.2) b.2 := by constructor · rintro (⟨a, b, hij⟩ | ⟨a, b, hab⟩) · exact Or.inl hij · exact Or.inr ⟨rfl, hab⟩ · obtain ⟨i, a⟩ := a obtain ⟨j, b⟩ := b dsimp only rintro (h | ⟨rfl, h⟩) · exact Lex.left _ _ h · exact Lex.right _ _ h #align sigma.lex_iff Sigma.lex_iff instance Lex.decidable (r : ι → ι → Prop) (s : ∀ i, α i → α i → Prop) [DecidableEq ι] [DecidableRel r] [∀ i, DecidableRel (s i)] : DecidableRel (Lex r s) := fun _ _ => decidable_of_decidable_of_iff lex_iff.symm #align sigma.lex.decidable Sigma.Lex.decidable
Mathlib/Data/Sigma/Lex.lean
63
67
theorem Lex.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ i a b, s₁ i a b → s₂ i a b) {a b : Σ i, α i} (h : Lex r₁ s₁ a b) : Lex r₂ s₂ a b := by
obtain ⟨a, b, hij⟩ | ⟨a, b, hab⟩ := h · exact Lex.left _ _ (hr _ _ hij) · exact Lex.right _ _ (hs _ _ _ hab)
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Analysis.NormedSpace.AffineIsometry import Mathlib.Topology.Algebra.ContinuousAffineMap import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace #align_import analysis.normed_space.continuous_affine_map from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" /-! # Continuous affine maps between normed spaces. This file develops the theory of continuous affine maps between affine spaces modelled on normed spaces. In the particular case that the affine spaces are just normed vector spaces `V`, `W`, we define a norm on the space of continuous affine maps by defining the norm of `f : V →ᴬ[𝕜] W` to be `‖f‖ = max ‖f 0‖ ‖f.cont_linear‖`. This is chosen so that we have a linear isometry: `(V →ᴬ[𝕜] W) ≃ₗᵢ[𝕜] W × (V →L[𝕜] W)`. The abstract picture is that for an affine space `P` modelled on a vector space `V`, together with a vector space `W`, there is an exact sequence of `𝕜`-modules: `0 → C → A → L → 0` where `C`, `A` are the spaces of constant and affine maps `P → W` and `L` is the space of linear maps `V → W`. Any choice of a base point in `P` corresponds to a splitting of this sequence so in particular if we take `P = V`, using `0 : V` as the base point provides a splitting, and we prove this is an isometric decomposition. On the other hand, choosing a base point breaks the affine invariance so the norm fails to be submultiplicative: for a composition of maps, we have only `‖f.comp g‖ ≤ ‖f‖ * ‖g‖ + ‖f 0‖`. ## Main definitions: * `ContinuousAffineMap.contLinear` * `ContinuousAffineMap.hasNorm` * `ContinuousAffineMap.norm_comp_le` * `ContinuousAffineMap.toConstProdContinuousLinearMap` -/ namespace ContinuousAffineMap variable {𝕜 R V W W₂ P Q Q₂ : Type*} variable [NormedAddCommGroup V] [MetricSpace P] [NormedAddTorsor V P] variable [NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q] variable [NormedAddCommGroup W₂] [MetricSpace Q₂] [NormedAddTorsor W₂ Q₂] variable [NormedField R] [NormedSpace R V] [NormedSpace R W] [NormedSpace R W₂] variable [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 V] [NormedSpace 𝕜 W] [NormedSpace 𝕜 W₂] /-- The linear map underlying a continuous affine map is continuous. -/ def contLinear (f : P →ᴬ[R] Q) : V →L[R] W := { f.linear with toFun := f.linear cont := by rw [AffineMap.continuous_linear_iff]; exact f.cont } #align continuous_affine_map.cont_linear ContinuousAffineMap.contLinear @[simp] theorem coe_contLinear (f : P →ᴬ[R] Q) : (f.contLinear : V → W) = f.linear := rfl #align continuous_affine_map.coe_cont_linear ContinuousAffineMap.coe_contLinear @[simp] theorem coe_contLinear_eq_linear (f : P →ᴬ[R] Q) : (f.contLinear : V →ₗ[R] W) = (f : P →ᵃ[R] Q).linear := by ext; rfl #align continuous_affine_map.coe_cont_linear_eq_linear ContinuousAffineMap.coe_contLinear_eq_linear @[simp] theorem coe_mk_const_linear_eq_linear (f : P →ᵃ[R] Q) (h) : ((⟨f, h⟩ : P →ᴬ[R] Q).contLinear : V → W) = f.linear := rfl #align continuous_affine_map.coe_mk_const_linear_eq_linear ContinuousAffineMap.coe_mk_const_linear_eq_linear theorem coe_linear_eq_coe_contLinear (f : P →ᴬ[R] Q) : ((f : P →ᵃ[R] Q).linear : V → W) = (⇑f.contLinear : V → W) := rfl #align continuous_affine_map.coe_linear_eq_coe_cont_linear ContinuousAffineMap.coe_linear_eq_coe_contLinear @[simp] theorem comp_contLinear (f : P →ᴬ[R] Q) (g : Q →ᴬ[R] Q₂) : (g.comp f).contLinear = g.contLinear.comp f.contLinear := rfl #align continuous_affine_map.comp_cont_linear ContinuousAffineMap.comp_contLinear @[simp] theorem map_vadd (f : P →ᴬ[R] Q) (p : P) (v : V) : f (v +ᵥ p) = f.contLinear v +ᵥ f p := f.map_vadd' p v #align continuous_affine_map.map_vadd ContinuousAffineMap.map_vadd @[simp] theorem contLinear_map_vsub (f : P →ᴬ[R] Q) (p₁ p₂ : P) : f.contLinear (p₁ -ᵥ p₂) = f p₁ -ᵥ f p₂ := f.toAffineMap.linearMap_vsub p₁ p₂ #align continuous_affine_map.cont_linear_map_vsub ContinuousAffineMap.contLinear_map_vsub @[simp] theorem const_contLinear (q : Q) : (const R P q).contLinear = 0 := rfl #align continuous_affine_map.const_cont_linear ContinuousAffineMap.const_contLinear
Mathlib/Analysis/NormedSpace/ContinuousAffineMap.lean
102
114
theorem contLinear_eq_zero_iff_exists_const (f : P →ᴬ[R] Q) : f.contLinear = 0 ↔ ∃ q, f = const R P q := by
have h₁ : f.contLinear = 0 ↔ (f : P →ᵃ[R] Q).linear = 0 := by refine ⟨fun h => ?_, fun h => ?_⟩ <;> ext · rw [← coe_contLinear_eq_linear, h]; rfl · rw [← coe_linear_eq_coe_contLinear, h]; rfl have h₂ : ∀ q : Q, f = const R P q ↔ (f : P →ᵃ[R] Q) = AffineMap.const R P q := by intro q refine ⟨fun h => ?_, fun h => ?_⟩ <;> ext · rw [h]; rfl · rw [← coe_to_affineMap, h]; rfl simp_rw [h₁, h₂] exact (f : P →ᵃ[R] Q).linear_eq_zero_iff_exists_const
/- Copyright (c) 2019 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen -/ import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.LinearAlgebra.GeneralLinearGroup import Mathlib.LinearAlgebra.Matrix.Reindex import Mathlib.Tactic.FieldSimp import Mathlib.LinearAlgebra.Matrix.NonsingularInverse import Mathlib.LinearAlgebra.Matrix.Basis #align_import linear_algebra.determinant from "leanprover-community/mathlib"@"0c1d80f5a86b36c1db32e021e8d19ae7809d5b79" /-! # Determinant of families of vectors This file defines the determinant of an endomorphism, and of a family of vectors with respect to some basis. For the determinant of a matrix, see the file `LinearAlgebra.Matrix.Determinant`. ## Main definitions In the list below, and in all this file, `R` is a commutative ring (semiring is sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite types used for indexing. * `Basis.det`: the determinant of a family of vectors with respect to a basis, as a multilinear map * `LinearMap.det`: the determinant of an endomorphism `f : End R M` as a multiplicative homomorphism (if `M` does not have a finite `R`-basis, the result is `1` instead) * `LinearEquiv.det`: the determinant of an isomorphism `f : M ≃ₗ[R] M` as a multiplicative homomorphism (if `M` does not have a finite `R`-basis, the result is `1` instead) ## Tags basis, det, determinant -/ noncomputable section open Matrix LinearMap Submodule Set Function universe u v w variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {M' : Type*} [AddCommGroup M'] [Module R M'] variable {ι : Type*} [DecidableEq ι] [Fintype ι] variable (e : Basis ι R M) section Conjugate variable {A : Type*} [CommRing A] variable {m n : Type*} /-- If `R^m` and `R^n` are linearly equivalent, then `m` and `n` are also equivalent. -/ def equivOfPiLEquivPi {R : Type*} [Finite m] [Finite n] [CommRing R] [Nontrivial R] (e : (m → R) ≃ₗ[R] n → R) : m ≃ n := Basis.indexEquiv (Basis.ofEquivFun e.symm) (Pi.basisFun _ _) #align equiv_of_pi_lequiv_pi equivOfPiLEquivPi namespace Matrix variable [Fintype m] [Fintype n] /-- If `M` and `M'` are each other's inverse matrices, they are square matrices up to equivalence of types. -/ def indexEquivOfInv [Nontrivial A] [DecidableEq m] [DecidableEq n] {M : Matrix m n A} {M' : Matrix n m A} (hMM' : M * M' = 1) (hM'M : M' * M = 1) : m ≃ n := equivOfPiLEquivPi (toLin'OfInv hMM' hM'M) #align matrix.index_equiv_of_inv Matrix.indexEquivOfInv theorem det_comm [DecidableEq n] (M N : Matrix n n A) : det (M * N) = det (N * M) := by rw [det_mul, det_mul, mul_comm] #align matrix.det_comm Matrix.det_comm /-- If there exists a two-sided inverse `M'` for `M` (indexed differently), then `det (N * M) = det (M * N)`. -/
Mathlib/LinearAlgebra/Determinant.lean
83
90
theorem det_comm' [DecidableEq m] [DecidableEq n] {M : Matrix n m A} {N : Matrix m n A} {M' : Matrix m n A} (hMM' : M * M' = 1) (hM'M : M' * M = 1) : det (M * N) = det (N * M) := by
nontriviality A -- Although `m` and `n` are different a priori, we will show they have the same cardinality. -- This turns the problem into one for square matrices, which is easy. let e := indexEquivOfInv hMM' hM'M rw [← det_submatrix_equiv_self e, ← submatrix_mul_equiv _ _ _ (Equiv.refl n) _, det_comm, submatrix_mul_equiv, Equiv.coe_refl, submatrix_id_id]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv #align_import analysis.special_functions.trigonometric.inverse_deriv from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # derivatives of the inverse trigonometric functions Derivatives of `arcsin` and `arccos`. -/ noncomputable section open scoped Classical Topology Filter open Set Filter open scoped Real namespace Real section Arcsin
Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean
30
49
theorem deriv_arcsin_aux {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) : HasStrictDerivAt arcsin (1 / √(1 - x ^ 2)) x ∧ ContDiffAt ℝ ⊤ arcsin x := by
cases' h₁.lt_or_lt with h₁ h₁ · have : 1 - x ^ 2 < 0 := by nlinarith [h₁] rw [sqrt_eq_zero'.2 this.le, div_zero] have : arcsin =ᶠ[𝓝 x] fun _ => -(π / 2) := (gt_mem_nhds h₁).mono fun y hy => arcsin_of_le_neg_one hy.le exact ⟨(hasStrictDerivAt_const _ _).congr_of_eventuallyEq this.symm, contDiffAt_const.congr_of_eventuallyEq this⟩ cases' h₂.lt_or_lt with h₂ h₂ · have : 0 < √(1 - x ^ 2) := sqrt_pos.2 (by nlinarith [h₁, h₂]) simp only [← cos_arcsin, one_div] at this ⊢ exact ⟨sinPartialHomeomorph.hasStrictDerivAt_symm ⟨h₁, h₂⟩ this.ne' (hasStrictDerivAt_sin _), sinPartialHomeomorph.contDiffAt_symm_deriv this.ne' ⟨h₁, h₂⟩ (hasDerivAt_sin _) contDiff_sin.contDiffAt⟩ · have : 1 - x ^ 2 < 0 := by nlinarith [h₂] rw [sqrt_eq_zero'.2 this.le, div_zero] have : arcsin =ᶠ[𝓝 x] fun _ => π / 2 := (lt_mem_nhds h₂).mono fun y hy => arcsin_of_one_le hy.le exact ⟨(hasStrictDerivAt_const _ _).congr_of_eventuallyEq this.symm, contDiffAt_const.congr_of_eventuallyEq this⟩
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl -/ import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Function.SimpleFunc import Mathlib.MeasureTheory.Measure.MutuallySingular import Mathlib.MeasureTheory.Measure.Count import Mathlib.Topology.IndicatorConstPointwise import Mathlib.MeasureTheory.Constructions.BorelSpace.Real #align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" /-! # Lower Lebesgue integral for `ℝ≥0∞`-valued functions We define the lower Lebesgue integral of an `ℝ≥0∞`-valued function. ## Notation We introduce the following notation for the lower Lebesgue integral of a function `f : α → ℝ≥0∞`. * `∫⁻ x, f x ∂μ`: integral of a function `f : α → ℝ≥0∞` with respect to a measure `μ`; * `∫⁻ x, f x`: integral of a function `f : α → ℝ≥0∞` with respect to the canonical measure `volume` on `α`; * `∫⁻ x in s, f x ∂μ`: integral of a function `f : α → ℝ≥0∞` over a set `s` with respect to a measure `μ`, defined as `∫⁻ x, f x ∂(μ.restrict s)`; * `∫⁻ x in s, f x`: integral of a function `f : α → ℝ≥0∞` over a set `s` with respect to the canonical measure `volume`, defined as `∫⁻ x, f x ∂(volume.restrict s)`. -/ assert_not_exists NormedSpace set_option autoImplicit true noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc variable {α β γ δ : Type*} section Lintegral open SimpleFunc variable {m : MeasurableSpace α} {μ ν : Measure α} /-- The **lower Lebesgue integral** of a function `f` with respect to a measure `μ`. -/ irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ := ⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ #align measure_theory.lintegral MeasureTheory.lintegral /-! In the notation for integrals, an expression like `∫⁻ x, g ‖x‖ ∂μ` will not be parsed correctly, and needs parentheses. We do not set the binding power of `r` to `0`, because then `∫⁻ x, f x = 0` will be parsed incorrectly. -/ @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r
Mathlib/MeasureTheory/Integral/Lebesgue.lean
82
86
theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = f.lintegral μ := by
rw [MeasureTheory.lintegral] exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl) (le_iSup₂_of_le f le_rfl le_rfl)
/- Copyright (c) 2024 Jeremy Tan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Tan -/ import Mathlib.Combinatorics.SimpleGraph.Clique /-! # The Turán graph This file defines the Turán graph and proves some of its basic properties. ## Main declarations * `SimpleGraph.IsTuranMaximal`: `G.IsTuranMaximal r` means that `G` has the most number of edges for its number of vertices while still being `r + 1`-cliquefree. * `SimpleGraph.turanGraph n r`: The canonical `r + 1`-cliquefree Turán graph on `n` vertices. ## TODO * Port the rest of Turán's theorem from https://github.com/leanprover-community/mathlib4/pull/9317 -/ open Finset namespace SimpleGraph variable {V : Type*} [Fintype V] [DecidableEq V] (G H : SimpleGraph V) [DecidableRel G.Adj] {n r : ℕ} /-- An `r + 1`-cliquefree graph is `r`-Turán-maximal if any other `r + 1`-cliquefree graph on the same vertex set has the same or fewer number of edges. -/ def IsTuranMaximal (r : ℕ) : Prop := G.CliqueFree (r + 1) ∧ ∀ (H : SimpleGraph V) [DecidableRel H.Adj], H.CliqueFree (r + 1) → H.edgeFinset.card ≤ G.edgeFinset.card variable {G H} lemma IsTuranMaximal.le_iff_eq (hG : G.IsTuranMaximal r) (hH : H.CliqueFree (r + 1)) : G ≤ H ↔ G = H := by classical exact ⟨fun hGH ↦ edgeFinset_inj.1 <| eq_of_subset_of_card_le (edgeFinset_subset_edgeFinset.2 hGH) (hG.2 _ hH), le_of_eq⟩ /-- The canonical `r + 1`-cliquefree Turán graph on `n` vertices. -/ def turanGraph (n r : ℕ) : SimpleGraph (Fin n) where Adj v w := v % r ≠ w % r instance turanGraph.instDecidableRelAdj : DecidableRel (turanGraph n r).Adj := by dsimp only [turanGraph]; infer_instance @[simp] lemma turanGraph_zero : turanGraph n 0 = ⊤ := by ext a b; simp_rw [turanGraph, top_adj, Nat.mod_zero, not_iff_not, Fin.val_inj] @[simp]
Mathlib/Combinatorics/SimpleGraph/Turan.lean
54
62
theorem turanGraph_eq_top : turanGraph n r = ⊤ ↔ r = 0 ∨ n ≤ r := by
simp_rw [SimpleGraph.ext_iff, Function.funext_iff, turanGraph, top_adj, eq_iff_iff, not_iff_not] refine ⟨fun h ↦ ?_, ?_⟩ · contrapose! h use ⟨0, (Nat.pos_of_ne_zero h.1).trans h.2⟩, ⟨r, h.2⟩ simp [h.1.symm] · rintro (rfl | h) a b · simp [Fin.val_inj] · rw [Nat.mod_eq_of_lt (a.2.trans_le h), Nat.mod_eq_of_lt (b.2.trans_le h), Fin.val_inj]
/- Copyright (c) 2022 Hans Parshall. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Hans Parshall -/ import Mathlib.Analysis.InnerProductSpace.Adjoint import Mathlib.Analysis.Matrix import Mathlib.Analysis.RCLike.Basic import Mathlib.LinearAlgebra.UnitaryGroup import Mathlib.Topology.UniformSpace.Matrix #align_import analysis.normed_space.star.matrix from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6" /-! # Analytic properties of the `star` operation on matrices This transports the operator norm on `EuclideanSpace 𝕜 n →L[𝕜] EuclideanSpace 𝕜 m` to `Matrix m n 𝕜`. See the file `Analysis.Matrix` for many other matrix norms. ## Main definitions * `Matrix.instNormedRingL2Op`: the (necessarily unique) normed ring structure on `Matrix n n 𝕜` which ensure it is a `CstarRing` in `Matrix.instCstarRing`. This is a scoped instance in the namespace `Matrix.L2OpNorm` in order to avoid choosing a global norm for `Matrix`. ## Main statements * `entry_norm_bound_of_unitary`: the entries of a unitary matrix are uniformly bound by `1`. ## Implementation details We take care to ensure the topology and uniformity induced by `Matrix.instMetricSpaceL2Op` coincide with the existing topology and uniformity on matrices. ## TODO * Show that `‖diagonal (v : n → 𝕜)‖ = ‖v‖`. -/ open scoped Matrix variable {𝕜 m n l E : Type*} section EntrywiseSupNorm variable [RCLike 𝕜] [Fintype n] [DecidableEq n]
Mathlib/Analysis/NormedSpace/Star/Matrix.lean
49
77
theorem entry_norm_bound_of_unitary {U : Matrix n n 𝕜} (hU : U ∈ Matrix.unitaryGroup n 𝕜) (i j : n) : ‖U i j‖ ≤ 1 := by
-- The norm squared of an entry is at most the L2 norm of its row. have norm_sum : ‖U i j‖ ^ 2 ≤ ∑ x, ‖U i x‖ ^ 2 := by apply Multiset.single_le_sum · intro x h_x rw [Multiset.mem_map] at h_x cases' h_x with a h_a rw [← h_a.2] apply sq_nonneg · rw [Multiset.mem_map] use j simp only [eq_self_iff_true, Finset.mem_univ_val, and_self_iff, sq_eq_sq] -- The L2 norm of a row is a diagonal entry of U * Uᴴ have diag_eq_norm_sum : (U * Uᴴ) i i = (∑ x : n, ‖U i x‖ ^ 2 : ℝ) := by simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, ← starRingEnd_apply, RCLike.mul_conj, RCLike.normSq_eq_def', RCLike.ofReal_pow]; norm_cast -- The L2 norm of a row is a diagonal entry of U * Uᴴ, real part have re_diag_eq_norm_sum : RCLike.re ((U * Uᴴ) i i) = ∑ x : n, ‖U i x‖ ^ 2 := by rw [RCLike.ext_iff] at diag_eq_norm_sum rw [diag_eq_norm_sum.1] norm_cast -- Since U is unitary, the diagonal entries of U * Uᴴ are all 1 have mul_eq_one : U * Uᴴ = 1 := unitary.mul_star_self_of_mem hU have diag_eq_one : RCLike.re ((U * Uᴴ) i i) = 1 := by simp only [mul_eq_one, eq_self_iff_true, Matrix.one_apply_eq, RCLike.one_re] -- Putting it all together rw [← sq_le_one_iff (norm_nonneg (U i j)), ← diag_eq_one, re_diag_eq_norm_sum] exact norm_sum
/- Copyright (c) 2021 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Eric Wieser -/ import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.Algebra.Order.Module.Pointwise import Mathlib.Data.Real.Archimedean #align_import data.real.pointwise from "leanprover-community/mathlib"@"dde670c9a3f503647fd5bfdf1037bad526d3397a" /-! # Pointwise operations on sets of reals This file relates `sInf (a • s)`/`sSup (a • s)` with `a • sInf s`/`a • sSup s` for `s : Set ℝ`. From these, it relates `⨅ i, a • f i` / `⨆ i, a • f i` with `a • (⨅ i, f i)` / `a • (⨆ i, f i)`, and provides lemmas about distributing `*` over `⨅` and `⨆`. # TODO This is true more generally for conditionally complete linear order whose default value is `0`. We don't have those yet. -/ open Set open Pointwise variable {ι : Sort*} {α : Type*} [LinearOrderedField α] section MulActionWithZero variable [MulActionWithZero α ℝ] [OrderedSMul α ℝ] {a : α}
Mathlib/Data/Real/Pointwise.lean
37
46
theorem Real.sInf_smul_of_nonneg (ha : 0 ≤ a) (s : Set ℝ) : sInf (a • s) = a • sInf s := by
obtain rfl | hs := s.eq_empty_or_nonempty · rw [smul_set_empty, Real.sInf_empty, smul_zero] obtain rfl | ha' := ha.eq_or_lt · rw [zero_smul_set hs, zero_smul] exact csInf_singleton 0 by_cases h : BddBelow s · exact ((OrderIso.smulRight ha').map_csInf' hs h).symm · rw [Real.sInf_of_not_bddBelow (mt (bddBelow_smul_iff_of_pos ha').1 h), Real.sInf_of_not_bddBelow h, smul_zero]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne -/ import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Analysis.NormedSpace.Real #align_import analysis.special_functions.log.basic from "leanprover-community/mathlib"@"f23a09ce6d3f367220dc3cecad6b7eb69eb01690" /-! # Real logarithm In this file we define `Real.log` to be the logarithm of a real number. As usual, we extend it from its domain `(0, +∞)` to a globally defined function. We choose to do it so that `log 0 = 0` and `log (-x) = log x`. We prove some basic properties of this function and show that it is continuous. ## Tags logarithm, continuity -/ open Set Filter Function open Topology noncomputable section namespace Real variable {x y : ℝ} /-- The real logarithm function, equal to the inverse of the exponential for `x > 0`, to `log |x|` for `x < 0`, and to `0` for `0`. We use this unconventional extension to `(-∞, 0]` as it gives the formula `log (x * y) = log x + log y` for all nonzero `x` and `y`, and the derivative of `log` is `1/x` away from `0`. -/ -- @[pp_nodot] -- Porting note: removed noncomputable def log (x : ℝ) : ℝ := if hx : x = 0 then 0 else expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩ #align real.log Real.log theorem log_of_ne_zero (hx : x ≠ 0) : log x = expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩ := dif_neg hx #align real.log_of_ne_zero Real.log_of_ne_zero theorem log_of_pos (hx : 0 < x) : log x = expOrderIso.symm ⟨x, hx⟩ := by rw [log_of_ne_zero hx.ne'] congr exact abs_of_pos hx #align real.log_of_pos Real.log_of_pos theorem exp_log_eq_abs (hx : x ≠ 0) : exp (log x) = |x| := by rw [log_of_ne_zero hx, ← coe_expOrderIso_apply, OrderIso.apply_symm_apply, Subtype.coe_mk] #align real.exp_log_eq_abs Real.exp_log_eq_abs theorem exp_log (hx : 0 < x) : exp (log x) = x := by rw [exp_log_eq_abs hx.ne'] exact abs_of_pos hx #align real.exp_log Real.exp_log theorem exp_log_of_neg (hx : x < 0) : exp (log x) = -x := by rw [exp_log_eq_abs (ne_of_lt hx)] exact abs_of_neg hx #align real.exp_log_of_neg Real.exp_log_of_neg theorem le_exp_log (x : ℝ) : x ≤ exp (log x) := by by_cases h_zero : x = 0 · rw [h_zero, log, dif_pos rfl, exp_zero] exact zero_le_one · rw [exp_log_eq_abs h_zero] exact le_abs_self _ #align real.le_exp_log Real.le_exp_log @[simp] theorem log_exp (x : ℝ) : log (exp x) = x := exp_injective <| exp_log (exp_pos x) #align real.log_exp Real.log_exp theorem surjOn_log : SurjOn log (Ioi 0) univ := fun x _ => ⟨exp x, exp_pos x, log_exp x⟩ #align real.surj_on_log Real.surjOn_log theorem log_surjective : Surjective log := fun x => ⟨exp x, log_exp x⟩ #align real.log_surjective Real.log_surjective @[simp] theorem range_log : range log = univ := log_surjective.range_eq #align real.range_log Real.range_log @[simp] theorem log_zero : log 0 = 0 := dif_pos rfl #align real.log_zero Real.log_zero @[simp] theorem log_one : log 1 = 0 := exp_injective <| by rw [exp_log zero_lt_one, exp_zero] #align real.log_one Real.log_one @[simp] theorem log_abs (x : ℝ) : log |x| = log x := by by_cases h : x = 0 · simp [h] · rw [← exp_eq_exp, exp_log_eq_abs h, exp_log_eq_abs (abs_pos.2 h).ne', abs_abs] #align real.log_abs Real.log_abs @[simp]
Mathlib/Analysis/SpecialFunctions/Log/Basic.lean
111
111
theorem log_neg_eq_log (x : ℝ) : log (-x) = log x := by
rw [← log_abs x, ← log_abs (-x), abs_neg]
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Patrick Massot -/ import Mathlib.Data.Set.Function import Mathlib.Order.Interval.Set.OrdConnected #align_import data.set.intervals.proj_Icc from "leanprover-community/mathlib"@"4e24c4bfcff371c71f7ba22050308aa17815626c" /-! # Projection of a line onto a closed interval Given a linearly ordered type `α`, in this file we define * `Set.projIci (a : α)` to be the map `α → [a, ∞)` sending `(-∞, a]` to `a`, and each point `x ∈ [a, ∞)` to itself; * `Set.projIic (b : α)` to be the map `α → (-∞, b[` sending `[b, ∞)` to `b`, and each point `x ∈ (-∞, b]` to itself; * `Set.projIcc (a b : α) (h : a ≤ b)` to be the map `α → [a, b]` sending `(-∞, a]` to `a`, `[b, ∞)` to `b`, and each point `x ∈ [a, b]` to itself; * `Set.IccExtend {a b : α} (h : a ≤ b) (f : Icc a b → β)` to be the extension of `f` to `α` defined as `f ∘ projIcc a b h`. * `Set.IciExtend {a : α} (f : Ici a → β)` to be the extension of `f` to `α` defined as `f ∘ projIci a`. * `Set.IicExtend {b : α} (f : Iic b → β)` to be the extension of `f` to `α` defined as `f ∘ projIic b`. We also prove some trivial properties of these maps. -/ variable {α β : Type*} [LinearOrder α] open Function namespace Set /-- Projection of `α` to the closed interval `[a, ∞)`. -/ def projIci (a x : α) : Ici a := ⟨max a x, le_max_left _ _⟩ #align set.proj_Ici Set.projIci /-- Projection of `α` to the closed interval `(-∞, b]`. -/ def projIic (b x : α) : Iic b := ⟨min b x, min_le_left _ _⟩ #align set.proj_Iic Set.projIic /-- Projection of `α` to the closed interval `[a, b]`. -/ def projIcc (a b : α) (h : a ≤ b) (x : α) : Icc a b := ⟨max a (min b x), le_max_left _ _, max_le h (min_le_left _ _)⟩ #align set.proj_Icc Set.projIcc variable {a b : α} (h : a ≤ b) {x : α} @[norm_cast] theorem coe_projIci (a x : α) : (projIci a x : α) = max a x := rfl #align set.coe_proj_Ici Set.coe_projIci @[norm_cast] theorem coe_projIic (b x : α) : (projIic b x : α) = min b x := rfl #align set.coe_proj_Iic Set.coe_projIic @[norm_cast] theorem coe_projIcc (a b : α) (h : a ≤ b) (x : α) : (projIcc a b h x : α) = max a (min b x) := rfl #align set.coe_proj_Icc Set.coe_projIcc theorem projIci_of_le (hx : x ≤ a) : projIci a x = ⟨a, le_rfl⟩ := Subtype.ext <| max_eq_left hx #align set.proj_Ici_of_le Set.projIci_of_le theorem projIic_of_le (hx : b ≤ x) : projIic b x = ⟨b, le_rfl⟩ := Subtype.ext <| min_eq_left hx #align set.proj_Iic_of_le Set.projIic_of_le
Mathlib/Order/Interval/Set/ProjIcc.lean
72
73
theorem projIcc_of_le_left (hx : x ≤ a) : projIcc a b h x = ⟨a, left_mem_Icc.2 h⟩ := by
simp [projIcc, hx, hx.trans h]
/- Copyright (c) 2023 Ali Ramsey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ali Ramsey, Eric Wieser -/ import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.Prod import Mathlib.LinearAlgebra.TensorProduct.Basic /-! # Coalgebras In this file we define `Coalgebra`, and provide instances for: * Commutative semirings: `CommSemiring.toCoalgebra` * Binary products: `Prod.instCoalgebra` * Finitely supported functions: `Finsupp.instCoalgebra` ## References * <https://en.wikipedia.org/wiki/Coalgebra> -/ suppress_compilation universe u v w open scoped TensorProduct /-- Data fields for `Coalgebra`, to allow API to be constructed before proving `Coalgebra.coassoc`. See `Coalgebra` for documentation. -/ class CoalgebraStruct (R : Type u) (A : Type v) [CommSemiring R] [AddCommMonoid A] [Module R A] where /-- The comultiplication of the coalgebra -/ comul : A →ₗ[R] A ⊗[R] A /-- The counit of the coalgebra -/ counit : A →ₗ[R] R namespace Coalgebra export CoalgebraStruct (comul counit) end Coalgebra /-- A coalgebra over a commutative (semi)ring `R` is an `R`-module equipped with a coassociative comultiplication `Δ` and a counit `ε` obeying the left and right counitality laws. -/ class Coalgebra (R : Type u) (A : Type v) [CommSemiring R] [AddCommMonoid A] [Module R A] extends CoalgebraStruct R A where /-- The comultiplication is coassociative -/ coassoc : TensorProduct.assoc R A A A ∘ₗ comul.rTensor A ∘ₗ comul = comul.lTensor A ∘ₗ comul /-- The counit satisfies the left counitality law -/ rTensor_counit_comp_comul : counit.rTensor A ∘ₗ comul = TensorProduct.mk R _ _ 1 /-- The counit satisfies the right counitality law -/ lTensor_counit_comp_comul : counit.lTensor A ∘ₗ comul = (TensorProduct.mk R _ _).flip 1 namespace Coalgebra variable {R : Type u} {A : Type v} variable [CommSemiring R] [AddCommMonoid A] [Module R A] [Coalgebra R A] @[simp] theorem coassoc_apply (a : A) : TensorProduct.assoc R A A A (comul.rTensor A (comul a)) = comul.lTensor A (comul a) := LinearMap.congr_fun coassoc a @[simp] theorem coassoc_symm_apply (a : A) : (TensorProduct.assoc R A A A).symm (comul.lTensor A (comul a)) = comul.rTensor A (comul a) := by rw [(TensorProduct.assoc R A A A).symm_apply_eq, coassoc_apply a] @[simp] theorem coassoc_symm : (TensorProduct.assoc R A A A).symm ∘ₗ comul.lTensor A ∘ₗ comul = comul.rTensor A ∘ₗ (comul (R := R)) := LinearMap.ext coassoc_symm_apply @[simp] theorem rTensor_counit_comul (a : A) : counit.rTensor A (comul a) = 1 ⊗ₜ[R] a := LinearMap.congr_fun rTensor_counit_comp_comul a @[simp] theorem lTensor_counit_comul (a : A) : counit.lTensor A (comul a) = a ⊗ₜ[R] 1 := LinearMap.congr_fun lTensor_counit_comp_comul a end Coalgebra section CommSemiring open Coalgebra namespace CommSemiring variable (R : Type u) [CommSemiring R] /-- Every commutative (semi)ring is a coalgebra over itself, with `Δ r = 1 ⊗ₜ r`. -/ instance toCoalgebra : Coalgebra R R where comul := (TensorProduct.mk R R R) 1 counit := .id coassoc := rfl rTensor_counit_comp_comul := by ext; rfl lTensor_counit_comp_comul := by ext; rfl @[simp] theorem comul_apply (r : R) : comul r = 1 ⊗ₜ[R] r := rfl @[simp] theorem counit_apply (r : R) : counit r = r := rfl end CommSemiring namespace Prod variable (R : Type u) (A : Type v) (B : Type w) variable [CommSemiring R] [AddCommMonoid A] [AddCommMonoid B] [Module R A] [Module R B] variable [Coalgebra R A] [Coalgebra R B] open LinearMap instance instCoalgebraStruct : CoalgebraStruct R (A × B) where comul := .coprod (TensorProduct.map (.inl R A B) (.inl R A B) ∘ₗ comul) (TensorProduct.map (.inr R A B) (.inr R A B) ∘ₗ comul) counit := .coprod counit counit @[simp] theorem comul_apply (r : A × B) : comul r = TensorProduct.map (.inl R A B) (.inl R A B) (comul r.1) + TensorProduct.map (.inr R A B) (.inr R A B) (comul r.2) := rfl @[simp] theorem counit_apply (r : A × B) : (counit r : R) = counit r.1 + counit r.2 := rfl theorem comul_comp_inl : comul ∘ₗ inl R A B = TensorProduct.map (.inl R A B) (.inl R A B) ∘ₗ comul := by ext; simp
Mathlib/RingTheory/Coalgebra/Basic.lean
133
135
theorem comul_comp_inr : comul ∘ₗ inr R A B = TensorProduct.map (.inr R A B) (.inr R A B) ∘ₗ comul := by
ext; simp
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.RingTheory.Nilpotent.Lemmas import Mathlib.RingTheory.Ideal.QuotientOperations #align_import ring_theory.quotient_nilpotent from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" /-! # Nilpotent elements in quotient rings -/ theorem Ideal.isRadical_iff_quotient_reduced {R : Type*} [CommRing R] (I : Ideal R) : I.IsRadical ↔ IsReduced (R ⧸ I) := by conv_lhs => rw [← @Ideal.mk_ker R _ I] exact RingHom.ker_isRadical_iff_reduced_of_surjective (@Ideal.Quotient.mk_surjective R _ I) #align ideal.is_radical_iff_quotient_reduced Ideal.isRadical_iff_quotient_reduced variable {R S : Type*} [CommSemiring R] [CommRing S] [Algebra R S] (I : Ideal S) /-- Let `P` be a property on ideals. If `P` holds for square-zero ideals, and if `P I → P (J ⧸ I) → P J`, then `P` holds for all nilpotent ideals. -/ theorem Ideal.IsNilpotent.induction_on (hI : IsNilpotent I) {P : ∀ ⦃S : Type _⦄ [CommRing S], Ideal S → Prop} (h₁ : ∀ ⦃S : Type _⦄ [CommRing S], ∀ I : Ideal S, I ^ 2 = ⊥ → P I) (h₂ : ∀ ⦃S : Type _⦄ [CommRing S], ∀ I J : Ideal S, I ≤ J → P I → P (J.map (Ideal.Quotient.mk I)) → P J) : P I := by obtain ⟨n, hI : I ^ n = ⊥⟩ := hI induction' n using Nat.strong_induction_on with n H generalizing S by_cases hI' : I = ⊥ · subst hI' apply h₁ rw [← Ideal.zero_eq_bot, zero_pow two_ne_zero] cases' n with n · rw [pow_zero, Ideal.one_eq_top] at hI haveI := subsingleton_of_bot_eq_top hI.symm exact (hI' (Subsingleton.elim _ _)).elim cases' n with n · rw [pow_one] at hI exact (hI' hI).elim apply h₂ (I ^ 2) _ (Ideal.pow_le_self two_ne_zero) · apply H n.succ _ (I ^ 2) · rw [← pow_mul, eq_bot_iff, ← hI, Nat.succ_eq_add_one] apply Ideal.pow_le_pow_right (by omega) · exact n.succ.lt_succ_self · apply h₁ rw [← Ideal.map_pow, Ideal.map_quotient_self] #align ideal.is_nilpotent.induction_on Ideal.IsNilpotent.induction_on
Mathlib/RingTheory/QuotientNilpotent.lean
54
78
theorem IsNilpotent.isUnit_quotient_mk_iff {R : Type*} [CommRing R] {I : Ideal R} (hI : IsNilpotent I) {x : R} : IsUnit (Ideal.Quotient.mk I x) ↔ IsUnit x := by
refine ⟨?_, fun h => h.map <| Ideal.Quotient.mk I⟩ revert x apply Ideal.IsNilpotent.induction_on (R := R) (S := R) I hI <;> clear hI I swap · introv e h₁ h₂ h₃ apply h₁ apply h₂ exact h₃.map ((DoubleQuot.quotQuotEquivQuotSup I J).trans (Ideal.quotEquivOfEq (sup_eq_right.mpr e))).symm.toRingHom · introv e H obtain ⟨y, hy⟩ := Ideal.Quotient.mk_surjective (↑H.unit⁻¹ : S ⧸ I) have : Ideal.Quotient.mk I (x * y) = Ideal.Quotient.mk I 1 := by rw [map_one, _root_.map_mul, hy, IsUnit.mul_val_inv] rw [Ideal.Quotient.eq] at this have : (x * y - 1) ^ 2 = 0 := by rw [← Ideal.mem_bot, ← e] exact Ideal.pow_mem_pow this _ have : x * (y * (2 - x * y)) = 1 := by rw [eq_comm, ← sub_eq_zero, ← this] ring exact isUnit_of_mul_eq_one _ _ this
/- Copyright (c) 2021 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.LinearAlgebra.FreeModule.PID import Mathlib.LinearAlgebra.Matrix.AbsoluteValue import Mathlib.NumberTheory.ClassNumber.AdmissibleAbsoluteValue import Mathlib.RingTheory.ClassGroup import Mathlib.RingTheory.DedekindDomain.IntegralClosure import Mathlib.RingTheory.Norm #align_import number_theory.class_number.finite from "leanprover-community/mathlib"@"ea0bcd84221246c801a6f8fbe8a4372f6d04b176" /-! # Class numbers of global fields In this file, we use the notion of "admissible absolute value" to prove finiteness of the class group for number fields and function fields. ## Main definitions - `ClassGroup.fintypeOfAdmissibleOfAlgebraic`: if `R` has an admissible absolute value, its integral closure has a finite class group -/ open scoped nonZeroDivisors namespace ClassGroup open Ring section EuclideanDomain variable {R S : Type*} (K L : Type*) [EuclideanDomain R] [CommRing S] [IsDomain S] variable [Field K] [Field L] variable [Algebra R K] [IsFractionRing R K] variable [Algebra K L] [FiniteDimensional K L] [IsSeparable K L] variable [algRL : Algebra R L] [IsScalarTower R K L] variable [Algebra R S] [Algebra S L] variable [ist : IsScalarTower R S L] [iic : IsIntegralClosure S R L] variable (abv : AbsoluteValue R ℤ) variable {ι : Type*} [DecidableEq ι] [Fintype ι] (bS : Basis ι R S) /-- If `b` is an `R`-basis of `S` of cardinality `n`, then `normBound abv b` is an integer such that for every `R`-integral element `a : S` with coordinates `≤ y`, we have algebra.norm a ≤ norm_bound abv b * y ^ n`. (See also `norm_le` and `norm_lt`). -/ noncomputable def normBound : ℤ := let n := Fintype.card ι let i : ι := Nonempty.some bS.index_nonempty let m : ℤ := Finset.max' (Finset.univ.image fun ijk : ι × ι × ι => abv (Algebra.leftMulMatrix bS (bS ijk.1) ijk.2.1 ijk.2.2)) ⟨_, Finset.mem_image.mpr ⟨⟨i, i, i⟩, Finset.mem_univ _, rfl⟩⟩ Nat.factorial n • (n • m) ^ n #align class_group.norm_bound ClassGroup.normBound
Mathlib/NumberTheory/ClassNumber/Finite.lean
58
71
theorem normBound_pos : 0 < normBound abv bS := by
obtain ⟨i, j, k, hijk⟩ : ∃ i j k, Algebra.leftMulMatrix bS (bS i) j k ≠ 0 := by by_contra! h obtain ⟨i⟩ := bS.index_nonempty apply bS.ne_zero i apply (injective_iff_map_eq_zero (Algebra.leftMulMatrix bS)).mp (Algebra.leftMulMatrix_injective bS) ext j k simp [h, DMatrix.zero_apply] simp only [normBound, Algebra.smul_def, eq_natCast] apply mul_pos (Int.natCast_pos.mpr (Nat.factorial_pos _)) refine pow_pos (mul_pos (Int.natCast_pos.mpr (Fintype.card_pos_iff.mpr ⟨i⟩)) ?_) _ refine lt_of_lt_of_le (abv.pos hijk) (Finset.le_max' _ _ ?_) exact Finset.mem_image.mpr ⟨⟨i, j, k⟩, Finset.mem_univ _, rfl⟩
/- Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Pim Spelier, Daan van Gent -/ import Mathlib.Data.Fintype.Basic import Mathlib.Data.Num.Lemmas import Mathlib.Data.Option.Basic import Mathlib.SetTheory.Cardinal.Basic #align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e" /-! # Encodings This file contains the definition of a (finite) encoding, a map from a type to strings in an alphabet, used in defining computability by Turing machines. It also contains several examples: ## Examples - `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet. - `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's. - `unaryFinEncodingNat` : a unary encoding of ℕ - `finEncodingBoolBool` : an encoding of bool. -/ universe u v open Cardinal namespace Computability /-- An encoding of a type in a certain alphabet, together with a decoding. -/ structure Encoding (α : Type u) where Γ : Type v encode : α → List Γ decode : List Γ → Option α decode_encode : ∀ x, decode (encode x) = some x #align computability.encoding Computability.Encoding theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by refine fun _ _ h => Option.some_injective _ ?_ rw [← e.decode_encode, ← e.decode_encode, h] #align computability.encoding.encode_injective Computability.Encoding.encode_injective /-- An encoding plus a guarantee of finiteness of the alphabet. -/ structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where ΓFin : Fintype Γ #align computability.fin_encoding Computability.FinEncoding instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ := e.ΓFin #align computability.Γ.fintype Computability.Γ.fintype /-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/ inductive Γ' | blank | bit (b : Bool) | bra | ket | comma deriving DecidableEq #align computability.Γ' Computability.Γ' -- Porting note: A handler for `Fintype` had not been implemented yet. instance Γ'.fintype : Fintype Γ' := ⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩, by intro; cases_type* Γ' Bool <;> decide⟩ #align computability.Γ'.fintype Computability.Γ'.fintype instance inhabitedΓ' : Inhabited Γ' := ⟨Γ'.blank⟩ #align computability.inhabited_Γ' Computability.inhabitedΓ' /-- The natural inclusion of bool in Γ'. -/ def inclusionBoolΓ' : Bool → Γ' := Γ'.bit #align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ' /-- An arbitrary section of the natural inclusion of bool in Γ'. -/ def sectionΓ'Bool : Γ' → Bool | Γ'.bit b => b | _ => Inhabited.default #align computability.section_Γ'_bool Computability.sectionΓ'Bool theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' := fun x => Bool.casesOn x rfl rfl #align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' := Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion) #align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective /-- An encoding function of the positive binary numbers in bool. -/ def encodePosNum : PosNum → List Bool | PosNum.one => [true] | PosNum.bit0 n => false :: encodePosNum n | PosNum.bit1 n => true :: encodePosNum n #align computability.encode_pos_num Computability.encodePosNum /-- An encoding function of the binary numbers in bool. -/ def encodeNum : Num → List Bool | Num.zero => [] | Num.pos n => encodePosNum n #align computability.encode_num Computability.encodeNum /-- An encoding function of ℕ in bool. -/ def encodeNat (n : ℕ) : List Bool := encodeNum n #align computability.encode_nat Computability.encodeNat /-- A decoding function from `List Bool` to the positive binary numbers. -/ def decodePosNum : List Bool → PosNum | false :: l => PosNum.bit0 (decodePosNum l) | true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l)) | _ => PosNum.one #align computability.decode_pos_num Computability.decodePosNum /-- A decoding function from `List Bool` to the binary numbers. -/ def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l #align computability.decode_num Computability.decodeNum /-- A decoding function from `List Bool` to ℕ. -/ def decodeNat : List Bool → Nat := fun l => decodeNum l #align computability.decode_nat Computability.decodeNat theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] := PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m => List.cons_ne_nil _ _ #align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
Mathlib/Computability/Encoding.lean
134
140
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n induction' n with m hm m hm <;> unfold encodePosNum decodePosNum · rfl · rw [hm] exact if_neg (encodePosNum_nonempty m) · exact congr_arg PosNum.bit0 hm
/- Copyright (c) 2022 Violeta Hernández Palacios. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Violeta Hernández Palacios -/ import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Computability.Primrec import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import computability.ackermann from "leanprover-community/mathlib"@"9b2660e1b25419042c8da10bf411aa3c67f14383" /-! # Ackermann function In this file, we define the two-argument Ackermann function `ack`. Despite having a recursive definition, we show that this isn't a primitive recursive function. ## Main results - `exists_lt_ack_of_nat_primrec`: any primitive recursive function is pointwise bounded above by `ack m` for some `m`. - `not_primrec₂_ack`: the two-argument Ackermann function is not primitive recursive. ## Proof approach We very broadly adapt the proof idea from https://www.planetmath.org/ackermannfunctionisnotprimitiverecursive. Namely, we prove that for any primitive recursive `f : ℕ → ℕ`, there exists `m` such that `f n < ack m n` for all `n`. This then implies that `fun n => ack n n` can't be primitive recursive, and so neither can `ack`. We aren't able to use the same bounds as in that proof though, since our approach of using pairing functions differs from their approach of using multivariate functions. The important bounds we show during the main inductive proof (`exists_lt_ack_of_nat_primrec`) are the following. Assuming `∀ n, f n < ack a n` and `∀ n, g n < ack b n`, we have: - `∀ n, pair (f n) (g n) < ack (max a b + 3) n`. - `∀ n, g (f n) < ack (max a b + 2) n`. - `∀ n, Nat.rec (f n.unpair.1) (fun (y IH : ℕ) => g (pair n.unpair.1 (pair y IH))) n.unpair.2 < ack (max a b + 9) n`. The last one is evidently the hardest. Using `unpair_add_le`, we reduce it to the more manageable - `∀ m n, rec (f m) (fun (y IH : ℕ) => g (pair m (pair y IH))) n < ack (max a b + 9) (m + n)`. We then prove this by induction on `n`. Our proof crucially depends on `ack_pair_lt`, which is applied twice, giving us a constant of `4 + 4`. The rest of the proof consists of simpler bounds which bump up our constant to `9`. -/ open Nat /-- The two-argument Ackermann function, defined so that - `ack 0 n = n + 1` - `ack (m + 1) 0 = ack m 1` - `ack (m + 1) (n + 1) = ack m (ack (m + 1) n)`. This is of interest as both a fast-growing function, and as an example of a recursive function that isn't primitive recursive. -/ def ack : ℕ → ℕ → ℕ | 0, n => n + 1 | m + 1, 0 => ack m 1 | m + 1, n + 1 => ack m (ack (m + 1) n) #align ack ack @[simp] theorem ack_zero (n : ℕ) : ack 0 n = n + 1 := by rw [ack] #align ack_zero ack_zero @[simp] theorem ack_succ_zero (m : ℕ) : ack (m + 1) 0 = ack m 1 := by rw [ack] #align ack_succ_zero ack_succ_zero @[simp] theorem ack_succ_succ (m n : ℕ) : ack (m + 1) (n + 1) = ack m (ack (m + 1) n) := by rw [ack] #align ack_succ_succ ack_succ_succ @[simp] theorem ack_one (n : ℕ) : ack 1 n = n + 2 := by induction' n with n IH · rfl · simp [IH] #align ack_one ack_one @[simp]
Mathlib/Computability/Ackermann.lean
89
92
theorem ack_two (n : ℕ) : ack 2 n = 2 * n + 3 := by
induction' n with n IH · rfl · simpa [mul_succ]
/- 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.NormedSpace.LinearIsometry import Mathlib.Analysis.NormedSpace.ContinuousLinearMap import Mathlib.Analysis.NormedSpace.Basic /-! # The span of a single vector The equivalence of `𝕜` and `𝕜 • x` for `x ≠ 0` are defined as continuous linear equivalence and isometry. ## Main definitions * `ContinuousLinearEquiv.toSpanNonzeroSingleton`: The continuous linear equivalence between `𝕜` and `𝕜 • x` for `x ≠ 0`. * `LinearIsometryEquiv.toSpanUnitSingleton`: For `‖x‖ = 1` the continuous linear equivalence is a linear isometry equivalence. -/ variable {𝕜 E : Type*} namespace LinearMap variable (𝕜) section Seminormed variable [NormedDivisionRing 𝕜] [SeminormedAddCommGroup E] [Module 𝕜 E] [BoundedSMul 𝕜 E]
Mathlib/Analysis/NormedSpace/Span.lean
36
39
theorem toSpanSingleton_homothety (x : E) (c : 𝕜) : ‖LinearMap.toSpanSingleton 𝕜 E x c‖ = ‖x‖ * ‖c‖ := by
rw [mul_comm] exact norm_smul _ _
/- 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.Multiset.Sum import Mathlib.Data.Finset.Card #align_import data.finset.sum from "leanprover-community/mathlib"@"48a058d7e39a80ed56858505719a0b2197900999" /-! # Disjoint sum of finsets This file defines the disjoint sum of two finsets as `Finset (α ⊕ β)`. Beware not to confuse with the `Finset.sum` operation which computes the additive sum. ## Main declarations * `Finset.disjSum`: `s.disjSum t` is the disjoint sum of `s` and `t`. -/ open Function Multiset Sum namespace Finset variable {α β : Type*} (s : Finset α) (t : Finset β) /-- Disjoint sum of finsets. -/ def disjSum : Finset (Sum α β) := ⟨s.1.disjSum t.1, s.2.disjSum t.2⟩ #align finset.disj_sum Finset.disjSum @[simp] theorem val_disjSum : (s.disjSum t).1 = s.1.disjSum t.1 := rfl #align finset.val_disj_sum Finset.val_disjSum @[simp] theorem empty_disjSum : (∅ : Finset α).disjSum t = t.map Embedding.inr := val_inj.1 <| Multiset.zero_disjSum _ #align finset.empty_disj_sum Finset.empty_disjSum @[simp] theorem disjSum_empty : s.disjSum (∅ : Finset β) = s.map Embedding.inl := val_inj.1 <| Multiset.disjSum_zero _ #align finset.disj_sum_empty Finset.disjSum_empty @[simp] theorem card_disjSum : (s.disjSum t).card = s.card + t.card := Multiset.card_disjSum _ _ #align finset.card_disj_sum Finset.card_disjSum theorem disjoint_map_inl_map_inr : Disjoint (s.map Embedding.inl) (t.map Embedding.inr) := by simp_rw [disjoint_left, mem_map] rintro x ⟨a, _, rfl⟩ ⟨b, _, ⟨⟩⟩ #align finset.disjoint_map_inl_map_inr Finset.disjoint_map_inl_map_inr @[simp] theorem map_inl_disjUnion_map_inr : (s.map Embedding.inl).disjUnion (t.map Embedding.inr) (disjoint_map_inl_map_inr _ _) = s.disjSum t := rfl #align finset.map_inl_disj_union_map_inr Finset.map_inl_disjUnion_map_inr variable {s t} {s₁ s₂ : Finset α} {t₁ t₂ : Finset β} {a : α} {b : β} {x : Sum α β} theorem mem_disjSum : x ∈ s.disjSum t ↔ (∃ a, a ∈ s ∧ inl a = x) ∨ ∃ b, b ∈ t ∧ inr b = x := Multiset.mem_disjSum #align finset.mem_disj_sum Finset.mem_disjSum @[simp] theorem inl_mem_disjSum : inl a ∈ s.disjSum t ↔ a ∈ s := Multiset.inl_mem_disjSum #align finset.inl_mem_disj_sum Finset.inl_mem_disjSum @[simp] theorem inr_mem_disjSum : inr b ∈ s.disjSum t ↔ b ∈ t := Multiset.inr_mem_disjSum #align finset.inr_mem_disj_sum Finset.inr_mem_disjSum @[simp]
Mathlib/Data/Finset/Sum.lean
83
83
theorem disjSum_eq_empty : s.disjSum t = ∅ ↔ s = ∅ ∧ t = ∅ := by
simp [ext_iff]
/- Copyright (c) 2017 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Algebra.Group.Defs import Mathlib.Control.Functor #align_import control.applicative from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" /-! # `applicative` instances This file provides `Applicative` instances for concrete functors: * `id` * `Functor.comp` * `Functor.const` * `Functor.add_const` -/ universe u v w section Lemmas open Function variable {F : Type u → Type v} variable [Applicative F] [LawfulApplicative F] variable {α β γ σ : Type u} theorem Applicative.map_seq_map (f : α → β → γ) (g : σ → β) (x : F α) (y : F σ) : f <$> x <*> g <$> y = ((· ∘ g) ∘ f) <$> x <*> y := by simp [flip, functor_norm] #align applicative.map_seq_map Applicative.map_seq_map theorem Applicative.pure_seq_eq_map' (f : α → β) : ((pure f : F (α → β)) <*> ·) = (f <$> ·) := by ext; simp [functor_norm] #align applicative.pure_seq_eq_map' Applicative.pure_seq_eq_map'
Mathlib/Control/Applicative.lean
40
63
theorem Applicative.ext {F} : ∀ {A1 : Applicative F} {A2 : Applicative F} [@LawfulApplicative F A1] [@LawfulApplicative F A2], (∀ {α : Type u} (x : α), @Pure.pure _ A1.toPure _ x = @Pure.pure _ A2.toPure _ x) → (∀ {α β : Type u} (f : F (α → β)) (x : F α), @Seq.seq _ A1.toSeq _ _ f (fun _ => x) = @Seq.seq _ A2.toSeq _ _ f (fun _ => x)) → A1 = A2 | { toFunctor := F1, seq := s1, pure := p1, seqLeft := sl1, seqRight := sr1 }, { toFunctor := F2, seq := s2, pure := p2, seqLeft := sl2, seqRight := sr2 }, L1, L2, H1, H2 => by obtain rfl : @p1 = @p2 := by
funext α x apply H1 obtain rfl : @s1 = @s2 := by funext α β f x exact H2 f (x Unit.unit) obtain ⟨seqLeft_eq1, seqRight_eq1, pure_seq1, -⟩ := L1 obtain ⟨seqLeft_eq2, seqRight_eq2, pure_seq2, -⟩ := L2 obtain rfl : F1 = F2 := by apply Functor.ext intros exact (pure_seq1 _ _).symm.trans (pure_seq2 _ _) congr <;> funext α β x y · exact (seqLeft_eq1 _ (y Unit.unit)).trans (seqLeft_eq2 _ _).symm · exact (seqRight_eq1 _ (y Unit.unit)).trans (seqRight_eq2 _ (y Unit.unit)).symm
/- Copyright (c) 2021 Bryan Gin-ge Chen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Bryan Gin-ge Chen, Yaël Dillies -/ import Mathlib.Order.BooleanAlgebra import Mathlib.Logic.Equiv.Basic #align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904" /-! # Symmetric difference and bi-implication This file defines the symmetric difference and bi-implication operators in (co-)Heyting algebras. ## Examples Some examples are * The symmetric difference of two sets is the set of elements that are in either but not both. * The symmetric difference on propositions is `Xor'`. * The symmetric difference on `Bool` is `Bool.xor`. * The equivalence of propositions. Two propositions are equivalent if they imply each other. * The symmetric difference translates to addition when considering a Boolean algebra as a Boolean ring. ## Main declarations * `symmDiff`: The symmetric difference operator, defined as `(a \ b) ⊔ (b \ a)` * `bihimp`: The bi-implication operator, defined as `(b ⇨ a) ⊓ (a ⇨ b)` In generalized Boolean algebras, the symmetric difference operator is: * `symmDiff_comm`: commutative, and * `symmDiff_assoc`: associative. ## Notations * `a ∆ b`: `symmDiff a b` * `a ⇔ b`: `bihimp a b` ## References The proof of associativity follows the note "Associativity of the Symmetric Difference of Sets: A Proof from the Book" by John McCuan: * <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf> ## Tags boolean ring, generalized boolean algebra, boolean algebra, symmetric difference, bi-implication, Heyting -/ open Function OrderDual variable {ι α β : Type*} {π : ι → Type*} /-- The symmetric difference operator on a type with `⊔` and `\` is `(A \ B) ⊔ (B \ A)`. -/ def symmDiff [Sup α] [SDiff α] (a b : α) : α := a \ b ⊔ b \ a #align symm_diff symmDiff /-- The Heyting bi-implication is `(b ⇨ a) ⊓ (a ⇨ b)`. This generalizes equivalence of propositions. -/ def bihimp [Inf α] [HImp α] (a b : α) : α := (b ⇨ a) ⊓ (a ⇨ b) #align bihimp bihimp /-- Notation for symmDiff -/ scoped[symmDiff] infixl:100 " ∆ " => symmDiff /-- Notation for bihimp -/ scoped[symmDiff] infixl:100 " ⇔ " => bihimp open scoped symmDiff theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a := rfl #align symm_diff_def symmDiff_def theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) := rfl #align bihimp_def bihimp_def theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q := rfl #align symm_diff_eq_xor symmDiff_eq_Xor' @[simp] theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) := (iff_iff_implies_and_implies _ _).symm.trans Iff.comm #align bihimp_iff_iff bihimp_iff_iff @[simp] theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide #align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor section GeneralizedCoheytingAlgebra variable [GeneralizedCoheytingAlgebra α] (a b c d : α) @[simp] theorem toDual_symmDiff : toDual (a ∆ b) = toDual a ⇔ toDual b := rfl #align to_dual_symm_diff toDual_symmDiff @[simp] theorem ofDual_bihimp (a b : αᵒᵈ) : ofDual (a ⇔ b) = ofDual a ∆ ofDual b := rfl #align of_dual_bihimp ofDual_bihimp theorem symmDiff_comm : a ∆ b = b ∆ a := by simp only [symmDiff, sup_comm] #align symm_diff_comm symmDiff_comm instance symmDiff_isCommutative : Std.Commutative (α := α) (· ∆ ·) := ⟨symmDiff_comm⟩ #align symm_diff_is_comm symmDiff_isCommutative @[simp]
Mathlib/Order/SymmDiff.lean
121
121
theorem symmDiff_self : a ∆ a = ⊥ := by
rw [symmDiff, sup_idem, sdiff_self]
/- 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.Coherent.RegularSheaves /-! # Description of the covering sieves of the regular topology This file characterises the covering sieves of the regular topology. ## Main result * `regularTopology.mem_sieves_iff_hasEffectiveEpi`: a sieve is a covering sieve for the regular topology if and only if it contains an effective epi. -/ namespace CategoryTheory.regularTopology open Limits variable {C : Type*} [Category C] [Preregular C] {X : C} /-- For a preregular category, any sieve that contains an `EffectiveEpi` is a covering sieve of the regular topology. Note: This is one direction of `mem_sieves_iff_hasEffectiveEpi`, but is needed for the proof. -/ theorem mem_sieves_of_hasEffectiveEpi (S : Sieve X) : (∃ (Y : C) (π : Y ⟶ X), EffectiveEpi π ∧ S.arrows π) → (S ∈ (regularTopology C).sieves X) := by rintro ⟨Y, π, h⟩ have h_le : Sieve.generate (Presieve.ofArrows (fun () ↦ Y) (fun _ ↦ π)) ≤ S := by rw [Sieve.sets_iff_generate (Presieve.ofArrows _ _) S] apply Presieve.le_of_factorsThru_sieve (Presieve.ofArrows _ _) S _ intro W g f refine ⟨W, 𝟙 W, ?_⟩ cases f exact ⟨π, ⟨h.2, Category.id_comp π⟩⟩ apply Coverage.saturate_of_superset (regularCoverage C) h_le exact Coverage.saturate.of X _ ⟨Y, π, rfl, h.1⟩ /-- Effective epis in a preregular category are stable under composition. -/ instance {Y Y' : C} (π : Y ⟶ X) [EffectiveEpi π] (π' : Y' ⟶ Y) [EffectiveEpi π'] : EffectiveEpi (π' ≫ π) := by rw [effectiveEpi_iff_effectiveEpiFamily, ← Sieve.effectiveEpimorphic_family] suffices h₂ : (Sieve.generate (Presieve.ofArrows _ _)) ∈ GrothendieckTopology.sieves (regularTopology C) X by change Nonempty _ rw [← Sieve.forallYonedaIsSheaf_iff_colimit] exact fun W => regularTopology.isSheaf_yoneda_obj W _ h₂ apply Coverage.saturate.transitive X (Sieve.generate (Presieve.ofArrows (fun () ↦ Y) (fun () ↦ π))) · apply Coverage.saturate.of use Y, π · intro V f ⟨Y₁, h, g, ⟨hY, hf⟩⟩ rw [← hf, Sieve.pullback_comp] apply (regularTopology C).pullback_stable' apply regularTopology.mem_sieves_of_hasEffectiveEpi cases hY exact ⟨Y', π', inferInstance, Y', (𝟙 _), π' ≫ π, Presieve.ofArrows.mk (), (by simp)⟩ /-- A sieve is a cover for the regular topology if and only if it contains an `EffectiveEpi`. -/
Mathlib/CategoryTheory/Sites/Coherent/RegularTopology.lean
64
78
theorem mem_sieves_iff_hasEffectiveEpi (S : Sieve X) : (S ∈ (regularTopology C).sieves X) ↔ ∃ (Y : C) (π : Y ⟶ X), EffectiveEpi π ∧ (S.arrows π) := by
constructor · intro h induction' h with Y T hS Y Y R S _ _ a b · rcases hS with ⟨Y', π, h'⟩ refine ⟨Y', π, h'.2, ?_⟩ rcases h' with ⟨rfl, _⟩ exact ⟨Y', 𝟙 Y', π, Presieve.ofArrows.mk (), (by simp)⟩ · exact ⟨Y, (𝟙 Y), inferInstance, by simp only [Sieve.top_apply, forall_const]⟩ · rcases a with ⟨Y₁, π, ⟨h₁,h₂⟩⟩ choose Y' π' _ H using b h₂ exact ⟨Y', π' ≫ π, inferInstance, (by simpa using H)⟩ · exact regularTopology.mem_sieves_of_hasEffectiveEpi S
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine import Mathlib.Geometry.Euclidean.Angle.Unoriented.RightAngle #align_import geometry.euclidean.angle.oriented.right_angle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Oriented angles in right-angled triangles. This file proves basic geometrical results about distances and oriented angles in (possibly degenerate) right-angled triangles in real inner product spaces and Euclidean affine spaces. -/ noncomputable section open scoped EuclideanGeometry open scoped Real open scoped RealInnerProductSpace namespace Orientation open FiniteDimensional variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] variable [hd2 : Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2)) /-- An angle in a right-angled triangle expressed using `arccos`. -/ theorem oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arccos_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two /-- An angle in a right-angled triangle expressed using `arccos`. -/ theorem oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arccos (‖y‖ / ‖x + y‖) := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two h #align orientation.oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two /-- An angle in a right-angled triangle expressed using `arcsin`. -/ theorem oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arcsin_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))] #align orientation.oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two /-- An angle in a right-angled triangle expressed using `arcsin`. -/ theorem oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arcsin (‖x‖ / ‖x + y‖) := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two h #align orientation.oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two /-- An angle in a right-angled triangle expressed using `arctan`. -/ theorem oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arctan_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (o.left_ne_zero_of_oangle_eq_pi_div_two h)] #align orientation.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two /-- An angle in a right-angled triangle expressed using `arctan`. -/
Mathlib/Geometry/Euclidean/Angle/Oriented/RightAngle.lean
83
87
theorem oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arctan (‖x‖ / ‖y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two h
/- Copyright (c) 2020 Kevin Kappelmann. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Kappelmann -/ import Mathlib.Algebra.ContinuedFractions.Computation.CorrectnessTerminating import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Data.Nat.Fib.Basic import Mathlib.Tactic.Monotonicity #align_import algebra.continued_fractions.computation.approximations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" /-! # Approximations for Continued Fraction Computations (`GeneralizedContinuedFraction.of`) ## Summary This file contains useful approximations for the values involved in the continued fractions computation `GeneralizedContinuedFraction.of`. In particular, we derive the so-called *determinant formula* for `GeneralizedContinuedFraction.of`: `Aₙ * Bₙ₊₁ - Bₙ * Aₙ₊₁ = (-1)^(n + 1)`. Moreover, we derive some upper bounds for the error term when computing a continued fraction up a given position, i.e. bounds for the term `|v - (GeneralizedContinuedFraction.of v).convergents n|`. The derived bounds will show us that the error term indeed gets smaller. As a corollary, we will be able to show that `(GeneralizedContinuedFraction.of v).convergents` converges to `v` in `Algebra.ContinuedFractions.Computation.ApproximationCorollaries`. ## Main Theorems - `GeneralizedContinuedFraction.of_part_num_eq_one`: shows that all partial numerators `aᵢ` are equal to one. - `GeneralizedContinuedFraction.exists_int_eq_of_part_denom`: shows that all partial denominators `bᵢ` correspond to an integer. - `GeneralizedContinuedFraction.of_one_le_get?_part_denom`: shows that `1 ≤ bᵢ`. - `GeneralizedContinuedFraction.succ_nth_fib_le_of_nth_denom`: shows that the `n`th denominator `Bₙ` is greater than or equal to the `n + 1`th fibonacci number `Nat.fib (n + 1)`. - `GeneralizedContinuedFraction.le_of_succ_get?_denom`: shows that `bₙ * Bₙ ≤ Bₙ₊₁`, where `bₙ` is the `n`th partial denominator of the continued fraction. - `GeneralizedContinuedFraction.abs_sub_convergents_le`: shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`, where `Aₙ` is the `n`th partial numerator. ## References - [*Hardy, GH and Wright, EM and Heath-Brown, Roger and Silverman, Joseph*][hardy2008introduction] - https://en.wikipedia.org/wiki/Generalized_continued_fraction#The_determinant_formula -/ namespace GeneralizedContinuedFraction open GeneralizedContinuedFraction (of) open Int variable {K : Type*} {v : K} {n : ℕ} [LinearOrderedField K] [FloorRing K] namespace IntFractPair /-! We begin with some lemmas about the stream of `IntFractPair`s, which presumably are not of great interest for the end user. -/ /-- Shows that the fractional parts of the stream are in `[0,1)`. -/
Mathlib/Algebra/ContinuedFractions/Computation/Approximations.lean
70
80
theorem nth_stream_fr_nonneg_lt_one {ifp_n : IntFractPair K} (nth_stream_eq : IntFractPair.stream v n = some ifp_n) : 0 ≤ ifp_n.fr ∧ ifp_n.fr < 1 := by
cases n with | zero => have : IntFractPair.of v = ifp_n := by injection nth_stream_eq rw [← this, IntFractPair.of] exact ⟨fract_nonneg _, fract_lt_one _⟩ | succ => rcases succ_nth_stream_eq_some_iff.1 nth_stream_eq with ⟨_, _, _, ifp_of_eq_ifp_n⟩ rw [← ifp_of_eq_ifp_n, IntFractPair.of] exact ⟨fract_nonneg _, fract_lt_one _⟩
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.CharP.ExpChar import Mathlib.GroupTheory.OrderOfElement #align_import algebra.char_p.two from "leanprover-community/mathlib"@"7f1ba1a333d66eed531ecb4092493cd1b6715450" /-! # Lemmas about rings of characteristic two This file contains results about `CharP R 2`, in the `CharTwo` namespace. The lemmas in this file with a `_sq` suffix are just special cases of the `_pow_char` lemmas elsewhere, with a shorter name for ease of discovery, and no need for a `[Fact (Prime 2)]` argument. -/ variable {R ι : Type*} namespace CharTwo section Semiring variable [Semiring R] [CharP R 2] theorem two_eq_zero : (2 : R) = 0 := by rw [← Nat.cast_two, CharP.cast_eq_zero] #align char_two.two_eq_zero CharTwo.two_eq_zero @[simp] theorem add_self_eq_zero (x : R) : x + x = 0 := by rw [← two_smul R x, two_eq_zero, zero_smul] #align char_two.add_self_eq_zero CharTwo.add_self_eq_zero set_option linter.deprecated false in @[simp] theorem bit0_eq_zero : (bit0 : R → R) = 0 := by funext exact add_self_eq_zero _ #align char_two.bit0_eq_zero CharTwo.bit0_eq_zero set_option linter.deprecated false in theorem bit0_apply_eq_zero (x : R) : (bit0 x : R) = 0 := by simp #align char_two.bit0_apply_eq_zero CharTwo.bit0_apply_eq_zero set_option linter.deprecated false in @[simp] theorem bit1_eq_one : (bit1 : R → R) = 1 := by funext simp [bit1] #align char_two.bit1_eq_one CharTwo.bit1_eq_one set_option linter.deprecated false in theorem bit1_apply_eq_one (x : R) : (bit1 x : R) = 1 := by simp #align char_two.bit1_apply_eq_one CharTwo.bit1_apply_eq_one end Semiring section Ring variable [Ring R] [CharP R 2] @[simp]
Mathlib/Algebra/CharP/Two.lean
65
66
theorem neg_eq (x : R) : -x = x := by
rw [neg_eq_iff_add_eq_zero, ← two_smul R x, two_eq_zero, zero_smul]
/- Copyright (c) 2018 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Chris Hughes, Michael Howes -/ import Mathlib.Algebra.Group.Aut import Mathlib.Algebra.Group.Semiconj.Units #align_import algebra.group.conj from "leanprover-community/mathlib"@"0743cc5d9d86bcd1bba10f480e948a257d65056f" /-! # Conjugacy of group elements See also `MulAut.conj` and `Quandle.conj`. -/ -- TODO: After #13027, -- assert_not_exists MonoidWithZero assert_not_exists Multiset universe u v variable {α : Type u} {β : Type v} section Monoid variable [Monoid α] [Monoid β] /-- We say that `a` is conjugate to `b` if for some unit `c` we have `c * a * c⁻¹ = b`. -/ def IsConj (a b : α) := ∃ c : αˣ, SemiconjBy (↑c) a b #align is_conj IsConj @[refl] theorem IsConj.refl (a : α) : IsConj a a := ⟨1, SemiconjBy.one_left a⟩ #align is_conj.refl IsConj.refl @[symm] theorem IsConj.symm {a b : α} : IsConj a b → IsConj b a | ⟨c, hc⟩ => ⟨c⁻¹, hc.units_inv_symm_left⟩ #align is_conj.symm IsConj.symm theorem isConj_comm {g h : α} : IsConj g h ↔ IsConj h g := ⟨IsConj.symm, IsConj.symm⟩ #align is_conj_comm isConj_comm @[trans] theorem IsConj.trans {a b c : α} : IsConj a b → IsConj b c → IsConj a c | ⟨c₁, hc₁⟩, ⟨c₂, hc₂⟩ => ⟨c₂ * c₁, hc₂.mul_left hc₁⟩ #align is_conj.trans IsConj.trans @[simp] theorem isConj_iff_eq {α : Type*} [CommMonoid α] {a b : α} : IsConj a b ↔ a = b := ⟨fun ⟨c, hc⟩ => by rw [SemiconjBy, mul_comm, ← Units.mul_inv_eq_iff_eq_mul, mul_assoc, c.mul_inv, mul_one] at hc exact hc, fun h => by rw [h]⟩ #align is_conj_iff_eq isConj_iff_eq protected theorem MonoidHom.map_isConj (f : α →* β) {a b : α} : IsConj a b → IsConj (f a) (f b) | ⟨c, hc⟩ => ⟨Units.map f c, by rw [Units.coe_map, SemiconjBy, ← f.map_mul, hc.eq, f.map_mul]⟩ #align monoid_hom.map_is_conj MonoidHom.map_isConj end Monoid section CancelMonoid variable [CancelMonoid α] -- These lemmas hold for `RightCancelMonoid` with the current proofs, but for the sake of -- not duplicating code (these lemmas also hold for `LeftCancelMonoids`) we leave these -- not generalised. @[simp] theorem isConj_one_right {a : α} : IsConj 1 a ↔ a = 1 := ⟨fun ⟨c, hc⟩ => mul_right_cancel (hc.symm.trans ((mul_one _).trans (one_mul _).symm)), fun h => by rw [h]⟩ #align is_conj_one_right isConj_one_right @[simp] theorem isConj_one_left {a : α} : IsConj a 1 ↔ a = 1 := calc IsConj a 1 ↔ IsConj 1 a := ⟨IsConj.symm, IsConj.symm⟩ _ ↔ a = 1 := isConj_one_right #align is_conj_one_left isConj_one_left end CancelMonoid section Group variable [Group α] @[simp] theorem isConj_iff {a b : α} : IsConj a b ↔ ∃ c : α, c * a * c⁻¹ = b := ⟨fun ⟨c, hc⟩ => ⟨c, mul_inv_eq_iff_eq_mul.2 hc⟩, fun ⟨c, hc⟩ => ⟨⟨c, c⁻¹, mul_inv_self c, inv_mul_self c⟩, mul_inv_eq_iff_eq_mul.1 hc⟩⟩ #align is_conj_iff isConj_iff -- Porting note: not in simp NF. -- @[simp] theorem conj_inv {a b : α} : (b * a * b⁻¹)⁻¹ = b * a⁻¹ * b⁻¹ := ((MulAut.conj b).map_inv a).symm #align conj_inv conj_inv @[simp] theorem conj_mul {a b c : α} : b * a * b⁻¹ * (b * c * b⁻¹) = b * (a * c) * b⁻¹ := ((MulAut.conj b).map_mul a c).symm #align conj_mul conj_mul @[simp] theorem conj_pow {i : ℕ} {a b : α} : (a * b * a⁻¹) ^ i = a * b ^ i * a⁻¹ := by induction' i with i hi · simp · simp [pow_succ, hi] #align conj_pow conj_pow @[simp]
Mathlib/Algebra/Group/Conj.lean
117
122
theorem conj_zpow {i : ℤ} {a b : α} : (a * b * a⁻¹) ^ i = a * b ^ i * a⁻¹ := by
induction' i · change (a * b * a⁻¹) ^ (_ : ℤ) = a * b ^ (_ : ℤ) * a⁻¹ simp [zpow_natCast] · simp only [zpow_negSucc, conj_pow, mul_inv_rev, inv_inv] rw [mul_assoc]
/- Copyright (c) 2024 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen, Frédéric Dupuis, Heather Macbeth, Antoine Chambert-Loir -/ import Mathlib.Data.Set.Pointwise.SMul import Mathlib.GroupTheory.GroupAction.Hom /-! # Pointwise actions of equivariant maps - `image_smul_setₛₗ` : under a `σ`-equivariant map, one has `h '' (c • s) = (σ c) • h '' s`. - `preimage_smul_setₛₗ'` is a general version of the equality `h ⁻¹' (σ c • s) = c • h⁻¹' s`. It requires that `c` acts surjectively and `σ c` acts injectively and is provided with specific versions: - `preimage_smul_setₛₗ_of_units` when `c` and `σ c` are units - `preimage_smul_setₛₗ` when `σ` belongs to a `MonoidHomClass`and `c` is a unit - `MonoidHom.preimage_smul_setₛₗ` when `σ` is a `MonoidHom` and `c` is a unit - `Group.preimage_smul_setₛₗ` : when the types of `c` and `σ c` are groups. - `image_smul_set`, `preimage_smul_set` and `Group.preimage_smul_set` are the variants when `σ` is the identity. -/ open Set Pointwise theorem MulAction.smul_bijective_of_is_unit {M : Type*} [Monoid M] {α : Type*} [MulAction M α] {m : M} (hm : IsUnit m) : Function.Bijective (fun (a : α) ↦ m • a) := by lift m to Mˣ using hm rw [Function.bijective_iff_has_inverse] use fun a ↦ m⁻¹ • a constructor · intro x; simp [← Units.smul_def] · intro x; simp [← Units.smul_def] variable {R S : Type*} (M M₁ M₂ N : Type*) variable [Monoid R] [Monoid S] (σ : R → S) variable [MulAction R M] [MulAction S N] [MulAction R M₁] [MulAction R M₂] variable {F : Type*} (h : F) section MulActionSemiHomClass variable [FunLike F M N] [MulActionSemiHomClass F σ M N] (c : R) (s : Set M) (t : Set N) -- @[simp] -- In #8386, the `simp_nf` linter complains: -- "Left-hand side does not simplify, when using the simp lemma on itself." -- For now we will have to manually add `image_smul_setₛₗ _` to the `simp` argument list. -- TODO: when lean4#3107 is fixed, mark this as `@[simp]`.
Mathlib/GroupTheory/GroupAction/Pointwise.lean
58
60
theorem image_smul_setₛₗ : h '' (c • s) = σ c • h '' s := by
simp only [← image_smul, image_image, map_smulₛₗ h]
/- Copyright (c) 2024 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Algebra.Module.Submodule.Localization import Mathlib.LinearAlgebra.Dimension.DivisionRing import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.OreLocalization.OreSet /-! # Rank of localization ## Main statements - `IsLocalizedModule.lift_rank_eq`: `rank_Rₚ Mₚ = rank R M`. - `rank_quotient_add_rank_of_isDomain`: The **rank-nullity theorem** for commutative domains. -/ open Cardinal nonZeroDivisors section CommRing universe u u' v v' variable {R : Type u} (S : Type u') {M : Type v} {N : Type v'} variable [CommRing R] [CommRing S] [AddCommGroup M] [AddCommGroup N] variable [Module R M] [Module R N] [Algebra R S] [Module S N] [IsScalarTower R S N] variable (p : Submonoid R) [IsLocalization p S] (f : M →ₗ[R] N) [IsLocalizedModule p f] variable (hp : p ≤ R⁰) variable {S} in lemma IsLocalizedModule.linearIndependent_lift {ι} {v : ι → N} (hf : LinearIndependent S v) : ∃ w : ι → M, LinearIndependent R w := by choose sec hsec using IsLocalizedModule.surj p f use fun i ↦ (sec (v i)).1 rw [linearIndependent_iff'] at hf ⊢ intro t g hg i hit apply hp (sec (v i)).2.prop apply IsLocalization.injective S hp rw [map_zero] refine hf t (fun i ↦ algebraMap R S (g i * (sec (v i)).2)) ?_ _ hit simp only [map_mul, mul_smul, algebraMap_smul, ← Submonoid.smul_def, hsec, ← map_smul, ← map_sum, hg, map_zero] lemma IsLocalizedModule.lift_rank_eq : Cardinal.lift.{v} (Module.rank S N) = Cardinal.lift.{v'} (Module.rank R M) := by cases' subsingleton_or_nontrivial R · have := (algebraMap R S).codomain_trivial; simp only [rank_subsingleton, lift_one] have := (IsLocalization.injective S hp).nontrivial apply le_antisymm · rw [Module.rank_def, lift_iSup (bddAbove_range.{v', v'} _)] apply ciSup_le' intro ⟨s, hs⟩ exact (IsLocalizedModule.linearIndependent_lift p f hp hs).choose_spec.cardinal_lift_le_rank · rw [Module.rank_def, lift_iSup (bddAbove_range.{v, v} _)] apply ciSup_le' intro ⟨s, hs⟩ choose sec hsec using IsLocalization.surj p (S := S) refine LinearIndependent.cardinal_lift_le_rank (ι := s) (v := fun i ↦ f i) ?_ rw [linearIndependent_iff'] at hs ⊢ intro t g hg i hit apply (IsLocalization.map_units S (sec (g i)).2).mul_left_injective classical let u := fun (i : s) ↦ (t.erase i).prod (fun j ↦ (sec (g j)).2) have : f (t.sum fun i ↦ u i • (sec (g i)).1 • i) = f 0 := by convert congr_arg (t.prod (fun j ↦ (sec (g j)).2) • ·) hg · simp only [map_sum, map_smul, Submonoid.smul_def, Finset.smul_sum] apply Finset.sum_congr rfl intro j hj simp only [u, ← @IsScalarTower.algebraMap_smul R S N, Submonoid.coe_finset_prod, map_prod] rw [← hsec, mul_comm (g j), mul_smul, ← mul_smul, Finset.prod_erase_mul (h := hj)] rw [map_zero, smul_zero] obtain ⟨c, hc⟩ := IsLocalizedModule.exists_of_eq (S := p) this simp_rw [smul_zero, Finset.smul_sum, ← mul_smul, Submonoid.smul_def, ← mul_smul, mul_comm] at hc simp only [hsec, zero_mul, map_eq_zero_iff (algebraMap R S) (IsLocalization.injective S hp)] apply hp (c * u i).prop exact hs t _ hc _ hit lemma IsLocalizedModule.rank_eq {N : Type v} [AddCommGroup N] [Module R N] [Module S N] [IsScalarTower R S N] (f : M →ₗ[R] N) [IsLocalizedModule p f] : Module.rank S N = Module.rank R M := by simpa using IsLocalizedModule.lift_rank_eq S p f hp variable (R M) in
Mathlib/LinearAlgebra/Dimension/Localization.lean
85
93
theorem exists_set_linearIndependent_of_isDomain [IsDomain R] : ∃ s : Set M, #s = Module.rank R M ∧ LinearIndependent (ι := s) R Subtype.val := by
obtain ⟨w, hw⟩ := IsLocalizedModule.linearIndependent_lift R⁰ (LocalizedModule.mkLinearMap R⁰ M) le_rfl (Module.Free.chooseBasis (FractionRing R) (LocalizedModule R⁰ M)).linearIndependent refine ⟨Set.range w, ?_, (linearIndependent_subtype_range hw.injective).mpr hw⟩ apply Cardinal.lift_injective.{max u v} rw [Cardinal.mk_range_eq_of_injective hw.injective, ← Module.Free.rank_eq_card_chooseBasisIndex, IsLocalizedModule.lift_rank_eq (FractionRing R) R⁰ (LocalizedModule.mkLinearMap R⁰ M) le_rfl]
/- Copyright (c) 2023 Mantas Bakšys, Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mantas Bakšys, Yaël Dillies -/ import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Rearrangement import Mathlib.Algebra.Order.Ring.Basic import Mathlib.GroupTheory.Perm.Cycle.Basic #align_import algebra.order.chebyshev from "leanprover-community/mathlib"@"b7399344324326918d65d0c74e9571e3a8cb9199" /-! # Chebyshev's sum inequality This file proves the Chebyshev sum inequality. Chebyshev's inequality states `(∑ i ∈ s, f i) * (∑ i ∈ s, g i) ≤ s.card * ∑ i ∈ s, f i * g i` when `f g : ι → α` monovary, and the reverse inequality when `f` and `g` antivary. ## Main declarations * `MonovaryOn.sum_mul_sum_le_card_mul_sum`: Chebyshev's inequality. * `AntivaryOn.card_mul_sum_le_sum_mul_sum`: Chebyshev's inequality, dual version. * `sq_sum_le_card_mul_sum_sq`: Special case of Chebyshev's inequality when `f = g`. ## Implementation notes In fact, we don't need much compatibility between the addition and multiplication of `α`, so we can actually decouple them by replacing multiplication with scalar multiplication and making `f` and `g` land in different types. As a bonus, this makes the dual statement trivial. The multiplication versions are provided for convenience. The case for `Monotone`/`Antitone` pairs of functions over a `LinearOrder` is not deduced in this file because it is easily deducible from the `Monovary` API. -/ open Equiv Equiv.Perm Finset Function OrderDual variable {ι α β : Type*} /-! ### Scalar multiplication versions -/ section SMul variable [LinearOrderedRing α] [LinearOrderedAddCommGroup β] [Module α β] [OrderedSMul α β] {s : Finset ι} {σ : Perm ι} {f : ι → α} {g : ι → β} /-- **Chebyshev's Sum Inequality**: When `f` and `g` monovary together (eg they are both monotone/antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem MonovaryOn.sum_smul_sum_le_card_smul_sum (hfg : MonovaryOn f g s) : ((∑ i ∈ s, f i) • ∑ i ∈ s, g i) ≤ s.card • ∑ i ∈ s, f i • g i := by classical obtain ⟨σ, hσ, hs⟩ := s.countable_toSet.exists_cycleOn rw [← card_range s.card, sum_smul_sum_eq_sum_perm hσ] exact sum_le_card_nsmul _ _ _ fun n _ => hfg.sum_smul_comp_perm_le_sum_smul fun x hx => hs fun h => hx <| IsFixedPt.perm_pow h _ #align monovary_on.sum_smul_sum_le_card_smul_sum MonovaryOn.sum_smul_sum_le_card_smul_sum /-- **Chebyshev's Sum Inequality**: When `f` and `g` antivary together (eg one is monotone, the other is antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/
Mathlib/Algebra/Order/Chebyshev.lean
70
72
theorem AntivaryOn.card_smul_sum_le_sum_smul_sum (hfg : AntivaryOn f g s) : (s.card • ∑ i ∈ s, f i • g i) ≤ (∑ i ∈ s, f i) • ∑ i ∈ s, g i := by
exact hfg.dual_right.sum_smul_sum_le_card_smul_sum
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Mario Carneiro, Sean Leather -/ import Mathlib.Data.Finset.Card #align_import data.finset.option from "leanprover-community/mathlib"@"c227d107bbada5d0d9d20287e3282c0a7f1651a0" /-! # Finite sets in `Option α` In this file we define * `Option.toFinset`: construct an empty or singleton `Finset α` from an `Option α`; * `Finset.insertNone`: given `s : Finset α`, lift it to a finset on `Option α` using `Option.some` and then insert `Option.none`; * `Finset.eraseNone`: given `s : Finset (Option α)`, returns `t : Finset α` such that `x ∈ t ↔ some x ∈ s`. Then we prove some basic lemmas about these definitions. ## Tags finset, option -/ variable {α β : Type*} open Function namespace Option /-- Construct an empty or singleton finset from an `Option` -/ def toFinset (o : Option α) : Finset α := o.elim ∅ singleton #align option.to_finset Option.toFinset @[simp] theorem toFinset_none : none.toFinset = (∅ : Finset α) := rfl #align option.to_finset_none Option.toFinset_none @[simp] theorem toFinset_some {a : α} : (some a).toFinset = {a} := rfl #align option.to_finset_some Option.toFinset_some @[simp] theorem mem_toFinset {a : α} {o : Option α} : a ∈ o.toFinset ↔ a ∈ o := by cases o <;> simp [eq_comm] #align option.mem_to_finset Option.mem_toFinset theorem card_toFinset (o : Option α) : o.toFinset.card = o.elim 0 1 := by cases o <;> rfl #align option.card_to_finset Option.card_toFinset end Option namespace Finset /-- Given a finset on `α`, lift it to being a finset on `Option α` using `Option.some` and then insert `Option.none`. -/ def insertNone : Finset α ↪o Finset (Option α) := (OrderEmbedding.ofMapLEIff fun s => cons none (s.map Embedding.some) <| by simp) fun s t => by rw [le_iff_subset, cons_subset_cons, map_subset_map, le_iff_subset] #align finset.insert_none Finset.insertNone @[simp] theorem mem_insertNone {s : Finset α} : ∀ {o : Option α}, o ∈ insertNone s ↔ ∀ a ∈ o, a ∈ s | none => iff_of_true (Multiset.mem_cons_self _ _) fun a h => by cases h | some a => Multiset.mem_cons.trans <| by simp #align finset.mem_insert_none Finset.mem_insertNone lemma forall_mem_insertNone {s : Finset α} {p : Option α → Prop} : (∀ a ∈ insertNone s, p a) ↔ p none ∧ ∀ a ∈ s, p a := by simp [Option.forall] theorem some_mem_insertNone {s : Finset α} {a : α} : some a ∈ insertNone s ↔ a ∈ s := by simp #align finset.some_mem_insert_none Finset.some_mem_insertNone lemma none_mem_insertNone {s : Finset α} : none ∈ insertNone s := by simp @[aesop safe apply (rule_sets := [finsetNonempty])] lemma insertNone_nonempty {s : Finset α} : insertNone s |>.Nonempty := ⟨none, none_mem_insertNone⟩ @[simp] theorem card_insertNone (s : Finset α) : s.insertNone.card = s.card + 1 := by simp [insertNone] #align finset.card_insert_none Finset.card_insertNone /-- Given `s : Finset (Option α)`, `eraseNone s : Finset α` is the set of `x : α` such that `some x ∈ s`. -/ def eraseNone : Finset (Option α) →o Finset α := (Finset.mapEmbedding (Equiv.optionIsSomeEquiv α).toEmbedding).toOrderHom.comp ⟨Finset.subtype _, subtype_mono⟩ #align finset.erase_none Finset.eraseNone @[simp] theorem mem_eraseNone {s : Finset (Option α)} {x : α} : x ∈ eraseNone s ↔ some x ∈ s := by simp [eraseNone] #align finset.mem_erase_none Finset.mem_eraseNone lemma forall_mem_eraseNone {s : Finset (Option α)} {p : Option α → Prop} : (∀ a ∈ eraseNone s, p a) ↔ ∀ a : α, (a : Option α) ∈ s → p a := by simp [Option.forall] theorem eraseNone_eq_biUnion [DecidableEq α] (s : Finset (Option α)) : eraseNone s = s.biUnion Option.toFinset := by ext simp #align finset.erase_none_eq_bUnion Finset.eraseNone_eq_biUnion @[simp] theorem eraseNone_map_some (s : Finset α) : eraseNone (s.map Embedding.some) = s := by ext simp #align finset.erase_none_map_some Finset.eraseNone_map_some @[simp] theorem eraseNone_image_some [DecidableEq (Option α)] (s : Finset α) : eraseNone (s.image some) = s := by simpa only [map_eq_image] using eraseNone_map_some s #align finset.erase_none_image_some Finset.eraseNone_image_some @[simp] theorem coe_eraseNone (s : Finset (Option α)) : (eraseNone s : Set α) = some ⁻¹' s := Set.ext fun _ => mem_eraseNone #align finset.coe_erase_none Finset.coe_eraseNone @[simp] theorem eraseNone_union [DecidableEq (Option α)] [DecidableEq α] (s t : Finset (Option α)) : eraseNone (s ∪ t) = eraseNone s ∪ eraseNone t := by ext simp #align finset.erase_none_union Finset.eraseNone_union @[simp]
Mathlib/Data/Finset/Option.lean
135
138
theorem eraseNone_inter [DecidableEq (Option α)] [DecidableEq α] (s t : Finset (Option α)) : eraseNone (s ∩ t) = eraseNone s ∩ eraseNone t := by
ext simp
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.AlgebraicGeometry.Morphisms.Basic import Mathlib.RingTheory.LocalProperties #align_import algebraic_geometry.morphisms.ring_hom_properties from "leanprover-community/mathlib"@"d39590fc8728fbf6743249802486f8c91ffe07bc" /-! # Properties of morphisms from properties of ring homs. We provide the basic framework for talking about properties of morphisms that come from properties of ring homs. For `P` a property of ring homs, we have two ways of defining a property of scheme morphisms: Let `f : X ⟶ Y`, - `targetAffineLocally (affine_and P)`: the preimage of an affine open `U = Spec A` is affine (`= Spec B`) and `A ⟶ B` satisfies `P`. (TODO) - `affineLocally P`: For each pair of affine open `U = Spec A ⊆ X` and `V = Spec B ⊆ f ⁻¹' U`, the ring hom `A ⟶ B` satisfies `P`. For these notions to be well defined, we require `P` be a sufficient local property. For the former, `P` should be local on the source (`RingHom.RespectsIso P`, `RingHom.LocalizationPreserves P`, `RingHom.OfLocalizationSpan`), and `targetAffineLocally (affine_and P)` will be local on the target. (TODO) For the latter `P` should be local on the target (`RingHom.PropertyIsLocal P`), and `affineLocally P` will be local on both the source and the target. Further more, these properties are stable under compositions (resp. base change) if `P` is. (TODO) -/ -- Explicit universe annotations were used in this file to improve perfomance #12737 universe u open CategoryTheory Opposite TopologicalSpace CategoryTheory.Limits AlgebraicGeometry variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop) namespace RingHom variable {P}
Mathlib/AlgebraicGeometry/Morphisms/RingHomProperties.lean
48
70
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme.{u}} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) : P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔ P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _ (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _ (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _ (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso, ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r))) (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff] congr delta IsLocalization.Away.map refine IsLocalization.ringHom_ext (Submonoid.powers r) ?_ generalize_proofs haveI i1 := @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r) -- Porting note: needs to be very explicit here convert (@IsLocalization.map_comp (hy := ‹_ ≤ _›) (Y.presheaf.obj <| Opposite.op (Scheme.basicOpen Y r)) _ _ (isLocalization_away_of_isAffine _) _ _ _ i1).symm using 1 change Y.presheaf.map _ ≫ _ = _ ≫ X.presheaf.map _ rw [f.val.c.naturality_assoc] simp only [TopCat.Presheaf.pushforwardObj_map, ← X.presheaf.map_comp] congr 1
/- Copyright (c) 2022 Violeta Hernández Palacios. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Violeta Hernández Palacios -/ import Mathlib.Order.SuccPred.Basic import Mathlib.Order.BoundedOrder #align_import order.succ_pred.limit from "leanprover-community/mathlib"@"1e05171a5e8cf18d98d9cf7b207540acb044acae" /-! # Successor and predecessor limits We define the predicate `Order.IsSuccLimit` for "successor limits", values that don't cover any others. They are so named since they can't be the successors of anything smaller. We define `Order.IsPredLimit` analogously, and prove basic results. ## Todo The plan is to eventually replace `Ordinal.IsLimit` and `Cardinal.IsLimit` with the common predicate `Order.IsSuccLimit`. -/ variable {α : Type*} namespace Order open Function Set OrderDual /-! ### Successor limits -/ section LT variable [LT α] /-- A successor limit is a value that doesn't cover any other. It's so named because in a successor order, a successor limit can't be the successor of anything smaller. -/ def IsSuccLimit (a : α) : Prop := ∀ b, ¬b ⋖ a #align order.is_succ_limit Order.IsSuccLimit theorem not_isSuccLimit_iff_exists_covBy (a : α) : ¬IsSuccLimit a ↔ ∃ b, b ⋖ a := by simp [IsSuccLimit] #align order.not_is_succ_limit_iff_exists_covby Order.not_isSuccLimit_iff_exists_covBy @[simp] theorem isSuccLimit_of_dense [DenselyOrdered α] (a : α) : IsSuccLimit a := fun _ => not_covBy #align order.is_succ_limit_of_dense Order.isSuccLimit_of_dense end LT section Preorder variable [Preorder α] {a : α} protected theorem _root_.IsMin.isSuccLimit : IsMin a → IsSuccLimit a := fun h _ hab => not_isMin_of_lt hab.lt h #align is_min.is_succ_limit IsMin.isSuccLimit theorem isSuccLimit_bot [OrderBot α] : IsSuccLimit (⊥ : α) := IsMin.isSuccLimit isMin_bot #align order.is_succ_limit_bot Order.isSuccLimit_bot variable [SuccOrder α] protected theorem IsSuccLimit.isMax (h : IsSuccLimit (succ a)) : IsMax a := by by_contra H exact h a (covBy_succ_of_not_isMax H) #align order.is_succ_limit.is_max Order.IsSuccLimit.isMax theorem not_isSuccLimit_succ_of_not_isMax (ha : ¬IsMax a) : ¬IsSuccLimit (succ a) := by contrapose! ha exact ha.isMax #align order.not_is_succ_limit_succ_of_not_is_max Order.not_isSuccLimit_succ_of_not_isMax section NoMaxOrder variable [NoMaxOrder α]
Mathlib/Order/SuccPred/Limit.lean
84
86
theorem IsSuccLimit.succ_ne (h : IsSuccLimit a) (b : α) : succ b ≠ a := by
rintro rfl exact not_isMax _ h.isMax
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Abelian import Mathlib.Algebra.Lie.IdealOperations import Mathlib.Order.Hom.Basic #align_import algebra.lie.solvable from "leanprover-community/mathlib"@"a50170a88a47570ed186b809ca754110590f9476" /-! # Solvable Lie algebras Like groups, Lie algebras admit a natural concept of solvability. We define this here via the derived series and prove some related results. We also define the radical of a Lie algebra and prove that it is solvable when the Lie algebra is Noetherian. ## Main definitions * `LieAlgebra.derivedSeriesOfIdeal` * `LieAlgebra.derivedSeries` * `LieAlgebra.IsSolvable` * `LieAlgebra.isSolvableAdd` * `LieAlgebra.radical` * `LieAlgebra.radicalIsSolvable` * `LieAlgebra.derivedLengthOfIdeal` * `LieAlgebra.derivedLength` * `LieAlgebra.derivedAbelianOfIdeal` ## Tags lie algebra, derived series, derived length, solvable, radical -/ universe u v w w₁ w₂ variable (R : Type u) (L : Type v) (M : Type w) {L' : Type w₁} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] variable (I J : LieIdeal R L) {f : L' →ₗ⁅R⁆ L} namespace LieAlgebra /-- A generalisation of the derived series of a Lie algebra, whose zeroth term is a specified ideal. It can be more convenient to work with this generalisation when considering the derived series of an ideal since it provides a type-theoretic expression of the fact that the terms of the ideal's derived series are also ideals of the enclosing algebra. See also `LieIdeal.derivedSeries_eq_derivedSeriesOfIdeal_comap` and `LieIdeal.derivedSeries_eq_derivedSeriesOfIdeal_map` below. -/ def derivedSeriesOfIdeal (k : ℕ) : LieIdeal R L → LieIdeal R L := (fun I => ⁅I, I⁆)^[k] #align lie_algebra.derived_series_of_ideal LieAlgebra.derivedSeriesOfIdeal @[simp] theorem derivedSeriesOfIdeal_zero : derivedSeriesOfIdeal R L 0 I = I := rfl #align lie_algebra.derived_series_of_ideal_zero LieAlgebra.derivedSeriesOfIdeal_zero @[simp] theorem derivedSeriesOfIdeal_succ (k : ℕ) : derivedSeriesOfIdeal R L (k + 1) I = ⁅derivedSeriesOfIdeal R L k I, derivedSeriesOfIdeal R L k I⁆ := Function.iterate_succ_apply' (fun I => ⁅I, I⁆) k I #align lie_algebra.derived_series_of_ideal_succ LieAlgebra.derivedSeriesOfIdeal_succ /-- The derived series of Lie ideals of a Lie algebra. -/ abbrev derivedSeries (k : ℕ) : LieIdeal R L := derivedSeriesOfIdeal R L k ⊤ #align lie_algebra.derived_series LieAlgebra.derivedSeries theorem derivedSeries_def (k : ℕ) : derivedSeries R L k = derivedSeriesOfIdeal R L k ⊤ := rfl #align lie_algebra.derived_series_def LieAlgebra.derivedSeries_def variable {R L} local notation "D" => derivedSeriesOfIdeal R L theorem derivedSeriesOfIdeal_add (k l : ℕ) : D (k + l) I = D k (D l I) := by induction' k with k ih · rw [Nat.zero_add, derivedSeriesOfIdeal_zero] · rw [Nat.succ_add k l, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ, ih] #align lie_algebra.derived_series_of_ideal_add LieAlgebra.derivedSeriesOfIdeal_add @[mono] theorem derivedSeriesOfIdeal_le {I J : LieIdeal R L} {k l : ℕ} (h₁ : I ≤ J) (h₂ : l ≤ k) : D k I ≤ D l J := by revert l; induction' k with k ih <;> intro l h₂ · rw [le_zero_iff] at h₂; rw [h₂, derivedSeriesOfIdeal_zero]; exact h₁ · have h : l = k.succ ∨ l ≤ k := by rwa [le_iff_eq_or_lt, Nat.lt_succ_iff] at h₂ cases' h with h h · rw [h, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ] exact LieSubmodule.mono_lie _ _ _ _ (ih (le_refl k)) (ih (le_refl k)) · rw [derivedSeriesOfIdeal_succ]; exact le_trans (LieSubmodule.lie_le_left _ _) (ih h) #align lie_algebra.derived_series_of_ideal_le LieAlgebra.derivedSeriesOfIdeal_le theorem derivedSeriesOfIdeal_succ_le (k : ℕ) : D (k + 1) I ≤ D k I := derivedSeriesOfIdeal_le (le_refl I) k.le_succ #align lie_algebra.derived_series_of_ideal_succ_le LieAlgebra.derivedSeriesOfIdeal_succ_le theorem derivedSeriesOfIdeal_le_self (k : ℕ) : D k I ≤ I := derivedSeriesOfIdeal_le (le_refl I) (zero_le k) #align lie_algebra.derived_series_of_ideal_le_self LieAlgebra.derivedSeriesOfIdeal_le_self theorem derivedSeriesOfIdeal_mono {I J : LieIdeal R L} (h : I ≤ J) (k : ℕ) : D k I ≤ D k J := derivedSeriesOfIdeal_le h (le_refl k) #align lie_algebra.derived_series_of_ideal_mono LieAlgebra.derivedSeriesOfIdeal_mono theorem derivedSeriesOfIdeal_antitone {k l : ℕ} (h : l ≤ k) : D k I ≤ D l I := derivedSeriesOfIdeal_le (le_refl I) h #align lie_algebra.derived_series_of_ideal_antitone LieAlgebra.derivedSeriesOfIdeal_antitone theorem derivedSeriesOfIdeal_add_le_add (J : LieIdeal R L) (k l : ℕ) : D (k + l) (I + J) ≤ D k I + D l J := by let D₁ : LieIdeal R L →o LieIdeal R L := { toFun := fun I => ⁅I, I⁆ monotone' := fun I J h => LieSubmodule.mono_lie I J I J h h } have h₁ : ∀ I J : LieIdeal R L, D₁ (I ⊔ J) ≤ D₁ I ⊔ J := by simp [D₁, LieSubmodule.lie_le_right, LieSubmodule.lie_le_left, le_sup_of_le_right] rw [← D₁.iterate_sup_le_sup_iff] at h₁ exact h₁ k l I J #align lie_algebra.derived_series_of_ideal_add_le_add LieAlgebra.derivedSeriesOfIdeal_add_le_add
Mathlib/Algebra/Lie/Solvable.lean
127
128
theorem derivedSeries_of_bot_eq_bot (k : ℕ) : derivedSeriesOfIdeal R L k ⊥ = ⊥ := by
rw [eq_bot_iff]; exact derivedSeriesOfIdeal_le_self ⊥ k
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl, Sander Dahmen, Scott Morrison -/ import Mathlib.Algebra.Module.Torsion import Mathlib.SetTheory.Cardinal.Cofinality import Mathlib.LinearAlgebra.FreeModule.Finite.Basic import Mathlib.LinearAlgebra.Dimension.StrongRankCondition #align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5" /-! # Conditions for rank to be finite Also contains characterization for when rank equals zero or rank equals one. -/ noncomputable section universe u v v' w variable {R : Type u} {M M₁ : Type v} {M' : Type v'} {ι : Type w} variable [Ring R] [AddCommGroup M] [AddCommGroup M'] [AddCommGroup M₁] variable [Module R M] [Module R M'] [Module R M₁] attribute [local instance] nontrivial_of_invariantBasisNumber open Cardinal Basis Submodule Function Set FiniteDimensional theorem rank_le {n : ℕ} (H : ∀ s : Finset M, (LinearIndependent R fun i : s => (i : M)) → s.card ≤ n) : Module.rank R M ≤ n := by rw [Module.rank_def] apply ciSup_le' rintro ⟨s, li⟩ exact linearIndependent_bounded_of_finset_linearIndependent_bounded H _ li #align rank_le rank_le section RankZero /-- See `rank_zero_iff` for a stronger version with `NoZeroSMulDivisor R M`. -/ lemma rank_eq_zero_iff : Module.rank R M = 0 ↔ ∀ x : M, ∃ a : R, a ≠ 0 ∧ a • x = 0 := by nontriviality R constructor · contrapose! rintro ⟨x, hx⟩ rw [← Cardinal.one_le_iff_ne_zero] have : LinearIndependent R (fun _ : Unit ↦ x) := linearIndependent_iff.mpr (fun l hl ↦ Finsupp.unique_ext <| not_not.mp fun H ↦ hx _ H ((Finsupp.total_unique _ _ _).symm.trans hl)) simpa using this.cardinal_lift_le_rank · intro h rw [← le_zero_iff, Module.rank_def] apply ciSup_le' intro ⟨s, hs⟩ rw [nonpos_iff_eq_zero, Cardinal.mk_eq_zero_iff, ← not_nonempty_iff] rintro ⟨i : s⟩ obtain ⟨a, ha, ha'⟩ := h i apply ha simpa using DFunLike.congr_fun (linearIndependent_iff.mp hs (Finsupp.single i a) (by simpa)) i variable [Nontrivial R] variable [NoZeroSMulDivisors R M] theorem rank_zero_iff_forall_zero : Module.rank R M = 0 ↔ ∀ x : M, x = 0 := by simp_rw [rank_eq_zero_iff, smul_eq_zero, and_or_left, not_and_self_iff, false_or, exists_and_right, and_iff_right (exists_ne (0 : R))] #align rank_zero_iff_forall_zero rank_zero_iff_forall_zero /-- See `rank_subsingleton` for the reason that `Nontrivial R` is needed. Also see `rank_eq_zero_iff` for the version without `NoZeroSMulDivisor R M`. -/ theorem rank_zero_iff : Module.rank R M = 0 ↔ Subsingleton M := rank_zero_iff_forall_zero.trans (subsingleton_iff_forall_eq 0).symm #align rank_zero_iff rank_zero_iff theorem rank_pos_iff_exists_ne_zero : 0 < Module.rank R M ↔ ∃ x : M, x ≠ 0 := by rw [← not_iff_not] simpa using rank_zero_iff_forall_zero #align rank_pos_iff_exists_ne_zero rank_pos_iff_exists_ne_zero theorem rank_pos_iff_nontrivial : 0 < Module.rank R M ↔ Nontrivial M := rank_pos_iff_exists_ne_zero.trans (nontrivial_iff_exists_ne 0).symm #align rank_pos_iff_nontrivial rank_pos_iff_nontrivial lemma rank_eq_zero_iff_isTorsion {R M} [CommRing R] [IsDomain R] [AddCommGroup M] [Module R M] : Module.rank R M = 0 ↔ Module.IsTorsion R M := by rw [Module.IsTorsion, rank_eq_zero_iff] simp [mem_nonZeroDivisors_iff_ne_zero] theorem rank_pos [Nontrivial M] : 0 < Module.rank R M := rank_pos_iff_nontrivial.mpr ‹_› #align rank_pos rank_pos variable (R M) /-- See `rank_subsingleton` that assumes `Subsingleton R` instead. -/ theorem rank_subsingleton' [Subsingleton M] : Module.rank R M = 0 := rank_eq_zero_iff.mpr fun _ ↦ ⟨1, one_ne_zero, Subsingleton.elim _ _⟩ @[simp] theorem rank_punit : Module.rank R PUnit = 0 := rank_subsingleton' _ _ #align rank_punit rank_punit @[simp] theorem rank_bot : Module.rank R (⊥ : Submodule R M) = 0 := rank_subsingleton' _ _ #align rank_bot rank_bot variable {R M} theorem exists_mem_ne_zero_of_rank_pos {s : Submodule R M} (h : 0 < Module.rank R s) : ∃ b : M, b ∈ s ∧ b ≠ 0 := exists_mem_ne_zero_of_ne_bot fun eq => by rw [eq, rank_bot] at h; exact lt_irrefl _ h #align exists_mem_ne_zero_of_rank_pos exists_mem_ne_zero_of_rank_pos end RankZero section Finite theorem Module.finite_of_rank_eq_nat [Module.Free R M] {n : ℕ} (h : Module.rank R M = n) : Module.Finite R M := by nontriviality R obtain ⟨⟨ι, b⟩⟩ := Module.Free.exists_basis (R := R) (M := M) have := mk_lt_aleph0_iff.mp <| b.linearIndependent.cardinal_le_rank |>.trans_eq h |>.trans_lt <| nat_lt_aleph0 n exact Module.Finite.of_basis b
Mathlib/LinearAlgebra/Dimension/Finite.lean
133
138
theorem Module.finite_of_rank_eq_zero [NoZeroSMulDivisors R M] (h : Module.rank R M = 0) : Module.Finite R M := by
nontriviality R rw [rank_zero_iff] at h infer_instance
/- Copyright (c) 2018 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis, Matthew Robert Ballard -/ import Mathlib.NumberTheory.Divisors import Mathlib.Data.Nat.Digits import Mathlib.Data.Nat.MaxPowDiv import Mathlib.Data.Nat.Multiplicity import Mathlib.Tactic.IntervalCases #align_import number_theory.padics.padic_val from "leanprover-community/mathlib"@"60fa54e778c9e85d930efae172435f42fb0d71f7" /-! # `p`-adic Valuation This file defines the `p`-adic valuation on `ℕ`, `ℤ`, and `ℚ`. The `p`-adic valuation on `ℚ` is the difference of the multiplicities of `p` in the numerator and denominator of `q`. This function obeys the standard properties of a valuation, with the appropriate assumptions on `p`. The `p`-adic valuations on `ℕ` and `ℤ` agree with that on `ℚ`. The valuation induces a norm on `ℚ`. This norm is defined in padicNorm.lean. ## Notations This file uses the local notation `/.` for `Rat.mk`. ## Implementation notes Much, but not all, of this file assumes that `p` is prime. This assumption is inferred automatically by taking `[Fact p.Prime]` as a type class argument. ## Calculations with `p`-adic valuations * `padicValNat_factorial`: Legendre's Theorem. The `p`-adic valuation of `n!` is the sum of the quotients `n / p ^ i`. This sum is expressed over the finset `Ico 1 b` where `b` is any bound greater than `log p n`. See `Nat.Prime.multiplicity_factorial` for the same result but stated in the language of prime multiplicity. * `sub_one_mul_padicValNat_factorial`: Legendre's Theorem. Taking (`p - 1`) times the `p`-adic valuation of `n!` equals `n` minus the sum of base `p` digits of `n`. * `padicValNat_choose`: Kummer's Theorem. The `p`-adic valuation of `n.choose k` is the number of carries when `k` and `n - k` are added in base `p`. This sum is expressed over the finset `Ico 1 b` where `b` is any bound greater than `log p n`. See `Nat.Prime.multiplicity_choose` for the same result but stated in the language of prime multiplicity. * `sub_one_mul_padicValNat_choose_eq_sub_sum_digits`: Kummer's Theorem. Taking (`p - 1`) times the `p`-adic valuation of the binomial `n` over `k` equals the sum of the digits of `k` plus the sum of the digits of `n - k` minus the sum of digits of `n`, all base `p`. ## References * [F. Q. Gouvêa, *p-adic numbers*][gouvea1997] * [R. Y. Lewis, *A formal proof of Hensel's lemma over the p-adic integers*][lewis2019] * <https://en.wikipedia.org/wiki/P-adic_number> ## Tags p-adic, p adic, padic, norm, valuation -/ universe u open Nat open Rat open multiplicity /-- For `p ≠ 1`, the `p`-adic valuation of a natural `n ≠ 0` is the largest natural number `k` such that `p^k` divides `n`. If `n = 0` or `p = 1`, then `padicValNat p q` defaults to `0`. -/ def padicValNat (p : ℕ) (n : ℕ) : ℕ := if h : p ≠ 1 ∧ 0 < n then (multiplicity p n).get (multiplicity.finite_nat_iff.2 h) else 0 #align padic_val_nat padicValNat namespace padicValNat open multiplicity variable {p : ℕ} /-- `padicValNat p 0` is `0` for any `p`. -/ @[simp] protected theorem zero : padicValNat p 0 = 0 := by simp [padicValNat] #align padic_val_nat.zero padicValNat.zero /-- `padicValNat p 1` is `0` for any `p`. -/ @[simp] protected theorem one : padicValNat p 1 = 0 := by unfold padicValNat split_ifs · simp · rfl #align padic_val_nat.one padicValNat.one /-- If `p ≠ 0` and `p ≠ 1`, then `padicValNat p p` is `1`. -/ @[simp] theorem self (hp : 1 < p) : padicValNat p p = 1 := by have neq_one : ¬p = 1 ↔ True := iff_of_true hp.ne' trivial have eq_zero_false : p = 0 ↔ False := iff_false_intro (zero_lt_one.trans hp).ne' simp [padicValNat, neq_one, eq_zero_false] #align padic_val_nat.self padicValNat.self @[simp] theorem eq_zero_iff {n : ℕ} : padicValNat p n = 0 ↔ p = 1 ∨ n = 0 ∨ ¬p ∣ n := by simp only [padicValNat, dite_eq_right_iff, PartENat.get_eq_iff_eq_coe, Nat.cast_zero, multiplicity_eq_zero, and_imp, pos_iff_ne_zero, Ne, ← or_iff_not_imp_left] #align padic_val_nat.eq_zero_iff padicValNat.eq_zero_iff theorem eq_zero_of_not_dvd {n : ℕ} (h : ¬p ∣ n) : padicValNat p n = 0 := eq_zero_iff.2 <| Or.inr <| Or.inr h #align padic_val_nat.eq_zero_of_not_dvd padicValNat.eq_zero_of_not_dvd open Nat.maxPowDiv theorem maxPowDiv_eq_multiplicity {p n : ℕ} (hp : 1 < p) (hn : 0 < n) : p.maxPowDiv n = multiplicity p n := by apply multiplicity.unique <| pow_dvd p n intro h apply Nat.not_lt.mpr <| le_of_dvd hp hn h simp
Mathlib/NumberTheory/Padics/PadicVal.lean
126
129
theorem maxPowDiv_eq_multiplicity_get {p n : ℕ} (hp : 1 < p) (hn : 0 < n) (h : Finite p n) : p.maxPowDiv n = (multiplicity p n).get h := by
rw [PartENat.get_eq_iff_eq_coe.mpr] apply maxPowDiv_eq_multiplicity hp hn|>.symm
/- Copyright (c) 2024 Geoffrey Irving. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Geoffrey Irving -/ import Mathlib.Analysis.Analytic.Composition import Mathlib.Analysis.Analytic.Constructions import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv /-! # Various complex special functions are analytic `exp`, `log`, and `cpow` are analytic, since they are differentiable. -/ open Complex Set open scoped Topology variable {E : Type} [NormedAddCommGroup E] [NormedSpace ℂ E] variable {f g : E → ℂ} {z : ℂ} {x : E} {s : Set E} /-- `exp` is entire -/ theorem analyticOn_cexp : AnalyticOn ℂ exp univ := by rw [analyticOn_univ_iff_differentiable]; exact differentiable_exp /-- `exp` is analytic at any point -/ theorem analyticAt_cexp : AnalyticAt ℂ exp z := analyticOn_cexp z (mem_univ _) /-- `exp ∘ f` is analytic -/ theorem AnalyticAt.cexp (fa : AnalyticAt ℂ f x) : AnalyticAt ℂ (fun z ↦ exp (f z)) x := analyticAt_cexp.comp fa /-- `exp ∘ f` is analytic -/ theorem AnalyticOn.cexp (fs : AnalyticOn ℂ f s) : AnalyticOn ℂ (fun z ↦ exp (f z)) s := fun z n ↦ analyticAt_cexp.comp (fs z n) /-- `log` is analytic away from nonpositive reals -/
Mathlib/Analysis/SpecialFunctions/Complex/Analytic.lean
40
44
theorem analyticAt_clog (m : z ∈ slitPlane) : AnalyticAt ℂ log z := by
rw [analyticAt_iff_eventually_differentiableAt] filter_upwards [isOpen_slitPlane.eventually_mem m] intro z m exact differentiableAt_id.clog m
/- Copyright (c) 2015 Nathaniel Thomas. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Group.Indicator import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Field.Rat import Mathlib.GroupTheory.GroupAction.Group import Mathlib.GroupTheory.GroupAction.Pi #align_import algebra.module.basic from "leanprover-community/mathlib"@"30413fc89f202a090a54d78e540963ed3de0056e" /-! # Further basic results about modules. -/ open Function Set universe u v variable {α R M M₂ : Type*} @[deprecated (since := "2024-04-17")] alias map_nat_cast_smul := map_natCast_smul theorem map_inv_natCast_smul [AddCommMonoid M] [AddCommMonoid M₂] {F : Type*} [FunLike F M M₂] [AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [DivisionSemiring R] [DivisionSemiring S] [Module R M] [Module S M₂] (n : ℕ) (x : M) : f ((n⁻¹ : R) • x) = (n⁻¹ : S) • f x := by by_cases hR : (n : R) = 0 <;> by_cases hS : (n : S) = 0 · simp [hR, hS, map_zero f] · suffices ∀ y, f y = 0 by rw [this, this, smul_zero] clear x intro x rw [← inv_smul_smul₀ hS (f x), ← map_natCast_smul f R S] simp [hR, map_zero f] · suffices ∀ y, f y = 0 by simp [this] clear x intro x rw [← smul_inv_smul₀ hR x, map_natCast_smul f R S, hS, zero_smul] · rw [← inv_smul_smul₀ hS (f _), ← map_natCast_smul f R S, smul_inv_smul₀ hR] #align map_inv_nat_cast_smul map_inv_natCast_smul @[deprecated (since := "2024-04-17")] alias map_inv_nat_cast_smul := map_inv_natCast_smul
Mathlib/Algebra/Module/Basic.lean
49
55
theorem map_inv_intCast_smul [AddCommGroup M] [AddCommGroup M₂] {F : Type*} [FunLike F M M₂] [AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [DivisionRing R] [DivisionRing S] [Module R M] [Module S M₂] (z : ℤ) (x : M) : f ((z⁻¹ : R) • x) = (z⁻¹ : S) • f x := by
obtain ⟨n, rfl | rfl⟩ := z.eq_nat_or_neg · rw [Int.cast_natCast, Int.cast_natCast, map_inv_natCast_smul _ R S] · simp_rw [Int.cast_neg, Int.cast_natCast, inv_neg, neg_smul, map_neg, map_inv_natCast_smul _ R S]
/- Copyright (c) 2019 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Data.List.Nodup import Mathlib.Data.List.Range #align_import data.list.nat_antidiagonal from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" /-! # Antidiagonals in ℕ × ℕ as lists This file defines the antidiagonals of ℕ × ℕ as lists: the `n`-th antidiagonal is the list of pairs `(i, j)` such that `i + j = n`. This is useful for polynomial multiplication and more generally for sums going from `0` to `n`. ## Notes Files `Data.Multiset.NatAntidiagonal` and `Data.Finset.NatAntidiagonal` successively turn the `List` definition we have here into `Multiset` and `Finset`. -/ open List Function Nat namespace List namespace Nat /-- The antidiagonal of a natural number `n` is the list of pairs `(i, j)` such that `i + j = n`. -/ def antidiagonal (n : ℕ) : List (ℕ × ℕ) := (range (n + 1)).map fun i ↦ (i, n - i) #align list.nat.antidiagonal List.Nat.antidiagonal /-- A pair (i, j) is contained in the antidiagonal of `n` if and only if `i + j = n`. -/ @[simp] theorem mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} : x ∈ antidiagonal n ↔ x.1 + x.2 = n := by rw [antidiagonal, mem_map]; constructor · rintro ⟨i, hi, rfl⟩ rw [mem_range, Nat.lt_succ_iff] at hi exact Nat.add_sub_cancel' hi · rintro rfl refine ⟨x.fst, ?_, ?_⟩ · rw [mem_range] omega · exact Prod.ext rfl (by simp only [Nat.add_sub_cancel_left]) #align list.nat.mem_antidiagonal List.Nat.mem_antidiagonal /-- The length of the antidiagonal of `n` is `n + 1`. -/ @[simp] theorem length_antidiagonal (n : ℕ) : (antidiagonal n).length = n + 1 := by rw [antidiagonal, length_map, length_range] #align list.nat.length_antidiagonal List.Nat.length_antidiagonal /-- The antidiagonal of `0` is the list `[(0, 0)]` -/ @[simp] theorem antidiagonal_zero : antidiagonal 0 = [(0, 0)] := rfl #align list.nat.antidiagonal_zero List.Nat.antidiagonal_zero /-- The antidiagonal of `n` does not contain duplicate entries. -/ theorem nodup_antidiagonal (n : ℕ) : Nodup (antidiagonal n) := (nodup_range _).map ((@LeftInverse.injective ℕ (ℕ × ℕ) Prod.fst fun i ↦ (i, n - i)) fun _ ↦ rfl) #align list.nat.nodup_antidiagonal List.Nat.nodup_antidiagonal @[simp]
Mathlib/Data/List/NatAntidiagonal.lean
68
73
theorem antidiagonal_succ {n : ℕ} : antidiagonal (n + 1) = (0, n + 1) :: (antidiagonal n).map (Prod.map Nat.succ id) := by
simp only [antidiagonal, range_succ_eq_map, map_cons, true_and_iff, Nat.add_succ_sub_one, Nat.add_zero, id, eq_self_iff_true, Nat.sub_zero, map_map, Prod.map_mk] apply congr rfl (congr rfl _) ext; simp
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Eric Wieser -/ import Mathlib.LinearAlgebra.Matrix.DotProduct import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.Diagonal #align_import data.matrix.rank from "leanprover-community/mathlib"@"17219820a8aa8abe85adf5dfde19af1dd1bd8ae7" /-! # Rank of matrices The rank of a matrix `A` is defined to be the rank of range of the linear map corresponding to `A`. This definition does not depend on the choice of basis, see `Matrix.rank_eq_finrank_range_toLin`. ## Main declarations * `Matrix.rank`: the rank of a matrix ## TODO * Do a better job of generalizing over `ℚ`, `ℝ`, and `ℂ` in `Matrix.rank_transpose` and `Matrix.rank_conjTranspose`. See [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/row.20rank.20equals.20column.20rank/near/350462992). -/ open Matrix namespace Matrix open FiniteDimensional variable {l m n o R : Type*} [Fintype n] [Fintype o] section CommRing variable [CommRing R] /-- The rank of a matrix is the rank of its image. -/ noncomputable def rank (A : Matrix m n R) : ℕ := finrank R <| LinearMap.range A.mulVecLin #align matrix.rank Matrix.rank @[simp] theorem rank_one [StrongRankCondition R] [DecidableEq n] : rank (1 : Matrix n n R) = Fintype.card n := by rw [rank, mulVecLin_one, LinearMap.range_id, finrank_top, finrank_pi] #align matrix.rank_one Matrix.rank_one @[simp]
Mathlib/Data/Matrix/Rank.lean
55
56
theorem rank_zero [Nontrivial R] : rank (0 : Matrix m n R) = 0 := by
rw [rank, mulVecLin_zero, LinearMap.range_zero, finrank_bot]
/- 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, Heather Macbeth -/ import Mathlib.MeasureTheory.Constructions.Pi import Mathlib.MeasureTheory.Integral.Lebesgue /-! # Marginals of multivariate functions In this file, we define a convenient way to compute integrals of multivariate functions, especially if you want to write expressions where you integrate only over some of the variables that the function depends on. This is common in induction arguments involving integrals of multivariate functions. This constructions allows working with iterated integrals and applying Tonelli's theorem and Fubini's theorem, without using measurable equivalences by changing the representation of your space (e.g. `((ι ⊕ ι') → ℝ) ≃ (ι → ℝ) × (ι' → ℝ)`). ## Main Definitions * Assume that `∀ i : ι, π i` is a product of measurable spaces with measures `μ i` on `π i`, `f : (∀ i, π i) → ℝ≥0∞` is a function and `s : Finset ι`. Then `lmarginal μ s f` or `∫⋯∫⁻_s, f ∂μ` is the function that integrates `f` over all variables in `s`. It returns a function that still takes the same variables as `f`, but is constant in the variables in `s`. Mathematically, if `s = {i₁, ..., iₖ}`, then `lmarginal μ s f` is the expression $$ \vec{x}\mapsto \int\!\!\cdots\!\!\int f(\vec{x}[\vec{y}])dy_{i_1}\cdots dy_{i_k}. $$ where $\vec{x}[\vec{y}]$ is the vector $\vec{x}$ with $x_{i_j}$ replaced by $y_{i_j}$ for all $1 \le j \le k$. If `f` is the distribution of a random variable, this is the marginal distribution of all variables not in `s` (but not the most general notion, since we only consider product measures here). Note that the notation `∫⋯∫⁻_s, f ∂μ` is not a binder, and returns a function. ## Main Results * `lmarginal_union` is the analogue of Tonelli's theorem for iterated integrals. It states that for measurable functions `f` and disjoint finsets `s` and `t` we have `∫⋯∫⁻_s ∪ t, f ∂μ = ∫⋯∫⁻_s, ∫⋯∫⁻_t, f ∂μ ∂μ`. ## Implementation notes The function `f` can have an arbitrary product as its domain (even infinite products), but the set `s` of integration variables is a `Finset`. We are assuming that the function `f` is measurable for most of this file. Note that asking whether it is `AEMeasurable` is not even well-posed, since there is no well-behaved measure on the domain of `f`. ## Todo * Define the marginal function for functions taking values in a Banach space. -/ open scoped Classical ENNReal open Set Function Equiv Finset noncomputable section namespace MeasureTheory section LMarginal variable {δ δ' : Type*} {π : δ → Type*} [∀ x, MeasurableSpace (π x)] variable {μ : ∀ i, Measure (π i)} [∀ i, SigmaFinite (μ i)] [DecidableEq δ] variable {s t : Finset δ} {f g : (∀ i, π i) → ℝ≥0∞} {x y : ∀ i, π i} {i : δ} /-- Integrate `f(x₁,…,xₙ)` over all variables `xᵢ` where `i ∈ s`. Return a function in the remaining variables (it will be constant in the `xᵢ` for `i ∈ s`). This is the marginal distribution of all variables not in `s` when the considered measure is the product measure. -/ def lmarginal (μ : ∀ i, Measure (π i)) (s : Finset δ) (f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) : ℝ≥0∞ := ∫⁻ y : ∀ i : s, π i, f (updateFinset x s y) ∂Measure.pi fun i : s => μ i -- Note: this notation is not a binder. This is more convenient since it returns a function. @[inherit_doc] notation "∫⋯∫⁻_" s ", " f " ∂" μ:70 => lmarginal μ s f @[inherit_doc] notation "∫⋯∫⁻_" s ", " f => lmarginal (fun _ ↦ volume) s f variable (μ)
Mathlib/MeasureTheory/Integral/Marginal.lean
88
96
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
refine Measurable.lintegral_prod_right ?_ refine hf.comp ?_ rw [measurable_pi_iff]; intro i by_cases hi : i ∈ s · simp [hi, updateFinset] exact measurable_pi_iff.1 measurable_snd _ · simp [hi, updateFinset] exact measurable_pi_iff.1 measurable_fst _
/- Copyright (c) 2019 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" /-! # Neighborhoods and continuity relative to a subset This file defines relative versions * `nhdsWithin` of `nhds` * `ContinuousOn` of `Continuous` * `ContinuousWithinAt` of `ContinuousAt` and proves their basic properties, including the relationships between these restricted notions and the corresponding notions for the subtype equipped with the subspace topology. ## Notation * `𝓝 x`: the filter of neighborhoods of a point `x`; * `𝓟 s`: the principal filter of a set `s`; * `𝓝[s] x`: the filter `nhdsWithin x s` of neighborhoods of a point `x` within a set `s`. -/ open Set Filter Function Topology Filter variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} variable [TopologicalSpace α] @[simp] theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} : (∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} : z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊢ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : α) (s : Set α) : 𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by rw [nhdsWithin, principal_univ, inf_top_eq] #align nhds_within_univ nhdsWithin_univ theorem nhdsWithin_hasBasis {p : β → Prop} {s : β → Set α} {a : α} (h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t := h.inf_principal t #align nhds_within_has_basis nhdsWithin_hasBasis theorem nhdsWithin_basis_open (a : α) (t : Set α) : (𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t := nhdsWithin_hasBasis (nhds_basis_opens a) t #align nhds_within_basis_open nhdsWithin_basis_open
Mathlib/Topology/ContinuousOn.lean
89
91
theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by
simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Data.Set.Image #align_import data.nat.set from "leanprover-community/mathlib"@"cf9386b56953fb40904843af98b7a80757bbe7f9" /-! ### Recursion on the natural numbers and `Set.range` -/ namespace Nat section Set open Set theorem zero_union_range_succ : {0} ∪ range succ = univ := by ext n cases n <;> simp #align nat.zero_union_range_succ Nat.zero_union_range_succ @[simp] protected theorem range_succ : range succ = { i | 0 < i } := by ext (_ | i) <;> simp [succ_pos, succ_ne_zero, Set.mem_setOf] #align nat.range_succ Nat.range_succ variable {α : Type*} theorem range_of_succ (f : ℕ → α) : {f 0} ∪ range (f ∘ succ) = range f := by rw [← image_singleton, range_comp, ← image_union, zero_union_range_succ, image_univ] #align nat.range_of_succ Nat.range_of_succ
Mathlib/Data/Nat/Set.lean
37
46
theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) : (Set.range fun n => Nat.rec x f n : Set α) = {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by
convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4 dsimp rename_i n induction' n with n ihn · rfl · dsimp at ihn ⊢ rw [ihn]
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen -/ import Mathlib.GroupTheory.Submonoid.Inverses import Mathlib.RingTheory.FiniteType import Mathlib.RingTheory.Localization.Basic #align_import ring_theory.localization.inv_submonoid from "leanprover-community/mathlib"@"6e7ca692c98bbf8a64868f61a67fb9c33b10770d" /-! # Submonoid of inverses ## Main definitions * `IsLocalization.invSubmonoid M S` is the submonoid of `S = M⁻¹R` consisting of inverses of each element `x ∈ M` ## Implementation notes See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview. ## Tags localization, ring localization, commutative ring localization, characteristic predicate, commutative ring, field of fractions -/ variable {R : Type*} [CommRing R] (M : Submonoid R) (S : Type*) [CommRing S] variable [Algebra R S] {P : Type*} [CommRing P] open Function namespace IsLocalization section InvSubmonoid /-- The submonoid of `S = M⁻¹R` consisting of `{ 1 / x | x ∈ M }`. -/ def invSubmonoid : Submonoid S := (M.map (algebraMap R S)).leftInv #align is_localization.inv_submonoid IsLocalization.invSubmonoid variable [IsLocalization M S] theorem submonoid_map_le_is_unit : M.map (algebraMap R S) ≤ IsUnit.submonoid S := by rintro _ ⟨a, ha, rfl⟩ exact IsLocalization.map_units S ⟨_, ha⟩ #align is_localization.submonoid_map_le_is_unit IsLocalization.submonoid_map_le_is_unit /-- There is an equivalence of monoids between the image of `M` and `invSubmonoid`. -/ noncomputable abbrev equivInvSubmonoid : M.map (algebraMap R S) ≃* invSubmonoid M S := ((M.map (algebraMap R S)).leftInvEquiv (submonoid_map_le_is_unit M S)).symm #align is_localization.equiv_inv_submonoid IsLocalization.equivInvSubmonoid /-- There is a canonical map from `M` to `invSubmonoid` sending `x` to `1 / x`. -/ noncomputable def toInvSubmonoid : M →* invSubmonoid M S := (equivInvSubmonoid M S).toMonoidHom.comp ((algebraMap R S : R →* S).submonoidMap M) #align is_localization.to_inv_submonoid IsLocalization.toInvSubmonoid theorem toInvSubmonoid_surjective : Function.Surjective (toInvSubmonoid M S) := Function.Surjective.comp (β := M.map (algebraMap R S)) (Equiv.surjective (equivInvSubmonoid _ _).toEquiv) (MonoidHom.submonoidMap_surjective _ _) #align is_localization.to_inv_submonoid_surjective IsLocalization.toInvSubmonoid_surjective @[simp] theorem toInvSubmonoid_mul (m : M) : (toInvSubmonoid M S m : S) * algebraMap R S m = 1 := Submonoid.leftInvEquiv_symm_mul _ (submonoid_map_le_is_unit _ _) _ #align is_localization.to_inv_submonoid_mul IsLocalization.toInvSubmonoid_mul @[simp] theorem mul_toInvSubmonoid (m : M) : algebraMap R S m * (toInvSubmonoid M S m : S) = 1 := Submonoid.mul_leftInvEquiv_symm _ (submonoid_map_le_is_unit _ _) ⟨_, _⟩ #align is_localization.mul_to_inv_submonoid IsLocalization.mul_toInvSubmonoid @[simp] theorem smul_toInvSubmonoid (m : M) : m • (toInvSubmonoid M S m : S) = 1 := by convert mul_toInvSubmonoid M S m ext rw [← Algebra.smul_def] rfl #align is_localization.smul_to_inv_submonoid IsLocalization.smul_toInvSubmonoid variable {S} -- Porting note: `surj'` was taken, so use `surj''` instead theorem surj'' (z : S) : ∃ (r : R) (m : M), z = r • (toInvSubmonoid M S m : S) := by rcases IsLocalization.surj M z with ⟨⟨r, m⟩, e : z * _ = algebraMap R S r⟩ refine ⟨r, m, ?_⟩ rw [Algebra.smul_def, ← e, mul_assoc] simp #align is_localization.surj' IsLocalization.surj''
Mathlib/RingTheory/Localization/InvSubmonoid.lean
94
96
theorem toInvSubmonoid_eq_mk' (x : M) : (toInvSubmonoid M S x : S) = mk' S 1 x := by
rw [← (IsLocalization.map_units S x).mul_left_inj] simp
/- Copyright (c) 2021 Aaron Anderson, Jesse Michael Han, Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jesse Michael Han, Floris van Doorn -/ import Mathlib.Data.Finset.Basic import Mathlib.ModelTheory.Syntax import Mathlib.Data.List.ProdSigma #align_import model_theory.semantics from "leanprover-community/mathlib"@"d565b3df44619c1498326936be16f1a935df0728" /-! # Basics on First-Order Semantics This file defines the interpretations of first-order terms, formulas, sentences, and theories in a style inspired by the [Flypitch project](https://flypitch.github.io/). ## Main Definitions * `FirstOrder.Language.Term.realize` is defined so that `t.realize v` is the term `t` evaluated at variables `v`. * `FirstOrder.Language.BoundedFormula.Realize` is defined so that `φ.Realize v xs` is the bounded formula `φ` evaluated at tuples of variables `v` and `xs`. * `FirstOrder.Language.Formula.Realize` is defined so that `φ.Realize v` is the formula `φ` evaluated at variables `v`. * `FirstOrder.Language.Sentence.Realize` is defined so that `φ.Realize M` is the sentence `φ` evaluated in the structure `M`. Also denoted `M ⊨ φ`. * `FirstOrder.Language.Theory.Model` is defined so that `T.Model M` is true if and only if every sentence of `T` is realized in `M`. Also denoted `T ⊨ φ`. ## Main Results * `FirstOrder.Language.BoundedFormula.realize_toPrenex` shows that the prenex normal form of a formula has the same realization as the original formula. * Several results in this file show that syntactic constructions such as `relabel`, `castLE`, `liftAt`, `subst`, and the actions of language maps commute with realization of terms, formulas, sentences, and theories. ## Implementation Notes * Formulas use a modified version of de Bruijn variables. Specifically, a `L.BoundedFormula α n` is a formula with some variables indexed by a type `α`, which cannot be quantified over, and some indexed by `Fin n`, which can. For any `φ : L.BoundedFormula α (n + 1)`, we define the formula `∀' φ : L.BoundedFormula α n` by universally quantifying over the variable indexed by `n : Fin (n + 1)`. ## References For the Flypitch project: - [J. Han, F. van Doorn, *A formal proof of the independence of the continuum hypothesis*] [flypitch_cpp] - [J. Han, F. van Doorn, *A formalization of forcing and the unprovability of the continuum hypothesis*][flypitch_itp] -/ universe u v w u' v' namespace FirstOrder namespace Language variable {L : Language.{u, v}} {L' : Language} variable {M : Type w} {N P : Type*} [L.Structure M] [L.Structure N] [L.Structure P] variable {α : Type u'} {β : Type v'} {γ : Type*} open FirstOrder Cardinal open Structure Cardinal Fin namespace Term -- Porting note: universes in different order /-- A term `t` with variables indexed by `α` can be evaluated by giving a value to each variable. -/ def realize (v : α → M) : ∀ _t : L.Term α, M | var k => v k | func f ts => funMap f fun i => (ts i).realize v #align first_order.language.term.realize FirstOrder.Language.Term.realize /- Porting note: The equation lemma of `realize` is too strong; it simplifies terms like the LHS of `realize_functions_apply₁`. Even `eqns` can't fix this. We removed `simp` attr from `realize` and prepare new simp lemmas for `realize`. -/ @[simp] theorem realize_var (v : α → M) (k) : realize v (var k : L.Term α) = v k := rfl @[simp] theorem realize_func (v : α → M) {n} (f : L.Functions n) (ts) : realize v (func f ts : L.Term α) = funMap f fun i => (ts i).realize v := rfl @[simp] theorem realize_relabel {t : L.Term α} {g : α → β} {v : β → M} : (t.relabel g).realize v = t.realize (v ∘ g) := by induction' t with _ n f ts ih · rfl · simp [ih] #align first_order.language.term.realize_relabel FirstOrder.Language.Term.realize_relabel @[simp] theorem realize_liftAt {n n' m : ℕ} {t : L.Term (Sum α (Fin n))} {v : Sum α (Fin (n + n')) → M} : (t.liftAt n' m).realize v = t.realize (v ∘ Sum.map id fun i : Fin _ => if ↑i < m then Fin.castAdd n' i else Fin.addNat i n') := realize_relabel #align first_order.language.term.realize_lift_at FirstOrder.Language.Term.realize_liftAt @[simp] theorem realize_constants {c : L.Constants} {v : α → M} : c.term.realize v = c := funMap_eq_coe_constants #align first_order.language.term.realize_constants FirstOrder.Language.Term.realize_constants @[simp] theorem realize_functions_apply₁ {f : L.Functions 1} {t : L.Term α} {v : α → M} : (f.apply₁ t).realize v = funMap f ![t.realize v] := by rw [Functions.apply₁, Term.realize] refine congr rfl (funext fun i => ?_) simp only [Matrix.cons_val_fin_one] #align first_order.language.term.realize_functions_apply₁ FirstOrder.Language.Term.realize_functions_apply₁ @[simp] theorem realize_functions_apply₂ {f : L.Functions 2} {t₁ t₂ : L.Term α} {v : α → M} : (f.apply₂ t₁ t₂).realize v = funMap f ![t₁.realize v, t₂.realize v] := by rw [Functions.apply₂, Term.realize] refine congr rfl (funext (Fin.cases ?_ ?_)) · simp only [Matrix.cons_val_zero] · simp only [Matrix.cons_val_succ, Matrix.cons_val_fin_one, forall_const] #align first_order.language.term.realize_functions_apply₂ FirstOrder.Language.Term.realize_functions_apply₂ theorem realize_con {A : Set M} {a : A} {v : α → M} : (L.con a).term.realize v = a := rfl #align first_order.language.term.realize_con FirstOrder.Language.Term.realize_con @[simp]
Mathlib/ModelTheory/Semantics.lean
130
134
theorem realize_subst {t : L.Term α} {tf : α → L.Term β} {v : β → M} : (t.subst tf).realize v = t.realize fun a => (tf a).realize v := by
induction' t with _ _ _ _ ih · rfl · simp [ih]
/- 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.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Field.Basic import Mathlib.Algebra.Order.Group.MinMax import Mathlib.Algebra.Ring.Pi import Mathlib.GroupTheory.GroupAction.Pi import Mathlib.GroupTheory.GroupAction.Ring import Mathlib.Init.Align import Mathlib.Tactic.GCongr import Mathlib.Tactic.Ring #align_import data.real.cau_seq from "leanprover-community/mathlib"@"9116dd6709f303dcf781632e15fdef382b0fc579" /-! # Cauchy sequences A basic theory of Cauchy sequences, used in the construction of the reals and p-adic numbers. Where applicable, lemmas that will be reused in other contexts have been stated in extra generality. There are other "versions" of Cauchyness in the library, in particular Cauchy filters in topology. This is a concrete implementation that is useful for simplicity and computability reasons. ## Important definitions * `IsCauSeq`: a predicate that says `f : ℕ → β` is Cauchy. * `CauSeq`: the type of Cauchy sequences valued in type `β` with respect to an absolute value function `abv`. ## Tags sequence, cauchy, abs val, absolute value -/ assert_not_exists Finset assert_not_exists Module assert_not_exists Submonoid assert_not_exists FloorRing variable {α β : Type*} open IsAbsoluteValue section variable [LinearOrderedField α] [Ring β] (abv : β → α) [IsAbsoluteValue abv] theorem rat_add_continuous_lemma {ε : α} (ε0 : 0 < ε) : ∃ δ > 0, ∀ {a₁ a₂ b₁ b₂ : β}, abv (a₁ - b₁) < δ → abv (a₂ - b₂) < δ → abv (a₁ + a₂ - (b₁ + b₂)) < ε := ⟨ε / 2, half_pos ε0, fun {a₁ a₂ b₁ b₂} h₁ h₂ => by simpa [add_halves, sub_eq_add_neg, add_comm, add_left_comm, add_assoc] using lt_of_le_of_lt (abv_add abv _ _) (add_lt_add h₁ h₂)⟩ #align rat_add_continuous_lemma rat_add_continuous_lemma
Mathlib/Algebra/Order/CauSeq/Basic.lean
58
71
theorem rat_mul_continuous_lemma {ε K₁ K₂ : α} (ε0 : 0 < ε) : ∃ δ > 0, ∀ {a₁ a₂ b₁ b₂ : β}, abv a₁ < K₁ → abv b₂ < K₂ → abv (a₁ - b₁) < δ → abv (a₂ - b₂) < δ → abv (a₁ * a₂ - b₁ * b₂) < ε := by
have K0 : (0 : α) < max 1 (max K₁ K₂) := lt_of_lt_of_le zero_lt_one (le_max_left _ _) have εK := div_pos (half_pos ε0) K0 refine ⟨_, εK, fun {a₁ a₂ b₁ b₂} ha₁ hb₂ h₁ h₂ => ?_⟩ replace ha₁ := lt_of_lt_of_le ha₁ (le_trans (le_max_left _ K₂) (le_max_right 1 _)) replace hb₂ := lt_of_lt_of_le hb₂ (le_trans (le_max_right K₁ _) (le_max_right 1 _)) set M := max 1 (max K₁ K₂) have : abv (a₁ - b₁) * abv b₂ + abv (a₂ - b₂) * abv a₁ < ε / 2 / M * M + ε / 2 / M * M := by gcongr rw [← abv_mul abv, mul_comm, div_mul_cancel₀ _ (ne_of_gt K0), ← abv_mul abv, add_halves] at this simpa [sub_eq_add_neg, mul_add, add_mul, add_left_comm] using lt_of_le_of_lt (abv_add abv _ _) this
/- 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.Algebra.Hom import Mathlib.RingTheory.Ideal.Quotient #align_import algebra.ring_quot from "leanprover-community/mathlib"@"e5820f6c8fcf1b75bcd7738ae4da1c5896191f72" /-! # Quotients of non-commutative rings Unfortunately, ideals have only been developed in the commutative case as `Ideal`, and it's not immediately clear how one should formalise ideals in the non-commutative case. In this file, we directly define the quotient of a semiring by any relation, by building a bigger relation that represents the ideal generated by that relation. We prove the universal properties of the quotient, and recommend avoiding relying on the actual definition, which is made irreducible for this purpose. Since everything runs in parallel for quotients of `R`-algebras, we do that case at the same time. -/ universe uR uS uT uA u₄ variable {R : Type uR} [Semiring R] variable {S : Type uS} [CommSemiring S] variable {T : Type uT} variable {A : Type uA} [Semiring A] [Algebra S A] namespace RingCon instance (c : RingCon A) : Algebra S c.Quotient where smul := (· • ·) toRingHom := c.mk'.comp (algebraMap S A) commutes' _ := Quotient.ind' fun _ ↦ congr_arg Quotient.mk'' <| Algebra.commutes _ _ smul_def' _ := Quotient.ind' fun _ ↦ congr_arg Quotient.mk'' <| Algebra.smul_def _ _ @[simp, norm_cast] theorem coe_algebraMap (c : RingCon A) (s : S) : (algebraMap S A s : c.Quotient) = algebraMap S _ s := rfl #align ring_con.coe_algebra_map RingCon.coe_algebraMap end RingCon namespace RingQuot /-- Given an arbitrary relation `r` on a ring, we strengthen it to a relation `Rel r`, such that the equivalence relation generated by `Rel r` has `x ~ y` if and only if `x - y` is in the ideal generated by elements `a - b` such that `r a b`. -/ inductive Rel (r : R → R → Prop) : R → R → Prop | of ⦃x y : R⦄ (h : r x y) : Rel r x y | add_left ⦃a b c⦄ : Rel r a b → Rel r (a + c) (b + c) | mul_left ⦃a b c⦄ : Rel r a b → Rel r (a * c) (b * c) | mul_right ⦃a b c⦄ : Rel r b c → Rel r (a * b) (a * c) #align ring_quot.rel RingQuot.Rel theorem Rel.add_right {r : R → R → Prop} ⦃a b c : R⦄ (h : Rel r b c) : Rel r (a + b) (a + c) := by rw [add_comm a b, add_comm a c] exact Rel.add_left h #align ring_quot.rel.add_right RingQuot.Rel.add_right theorem Rel.neg {R : Type uR} [Ring R] {r : R → R → Prop} ⦃a b : R⦄ (h : Rel r a b) : Rel r (-a) (-b) := by simp only [neg_eq_neg_one_mul a, neg_eq_neg_one_mul b, Rel.mul_right h] #align ring_quot.rel.neg RingQuot.Rel.neg
Mathlib/Algebra/RingQuot.lean
71
72
theorem Rel.sub_left {R : Type uR} [Ring R] {r : R → R → Prop} ⦃a b c : R⦄ (h : Rel r a b) : Rel r (a - c) (b - c) := by
simp only [sub_eq_add_neg, h.add_left]
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.BoxIntegral.Partition.Basic #align_import analysis.box_integral.partition.split from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f" /-! # Split a box along one or more hyperplanes ## Main definitions A hyperplane `{x : ι → ℝ | x i = a}` splits a rectangular box `I : BoxIntegral.Box ι` into two smaller boxes. If `a ∉ Ioo (I.lower i, I.upper i)`, then one of these boxes is empty, so it is not a box in the sense of `BoxIntegral.Box`. We introduce the following definitions. * `BoxIntegral.Box.splitLower I i a` and `BoxIntegral.Box.splitUpper I i a` are these boxes (as `WithBot (BoxIntegral.Box ι)`); * `BoxIntegral.Prepartition.split I i a` is the partition of `I` made of these two boxes (or of one box `I` if one of these boxes is empty); * `BoxIntegral.Prepartition.splitMany I s`, where `s : Finset (ι × ℝ)` is a finite set of hyperplanes `{x : ι → ℝ | x i = a}` encoded as pairs `(i, a)`, is the partition of `I` made by cutting it along all the hyperplanes in `s`. ## Main results The main result `BoxIntegral.Prepartition.exists_iUnion_eq_diff` says that any prepartition `π` of `I` admits a prepartition `π'` of `I` that covers exactly `I \ π.iUnion`. One of these prepartitions is available as `BoxIntegral.Prepartition.compl`. ## Tags rectangular box, partition, hyperplane -/ noncomputable section open scoped Classical open Filter open Function Set Filter namespace BoxIntegral variable {ι M : Type*} {n : ℕ} namespace Box variable {I : Box ι} {i : ι} {x : ℝ} {y : ι → ℝ} /-- Given a box `I` and `x ∈ (I.lower i, I.upper i)`, the hyperplane `{y : ι → ℝ | y i = x}` splits `I` into two boxes. `BoxIntegral.Box.splitLower I i x` is the box `I ∩ {y | y i ≤ x}` (if it is nonempty). As usual, we represent a box that may be empty as `WithBot (BoxIntegral.Box ι)`. -/ def splitLower (I : Box ι) (i : ι) (x : ℝ) : WithBot (Box ι) := mk' I.lower (update I.upper i (min x (I.upper i))) #align box_integral.box.split_lower BoxIntegral.Box.splitLower @[simp] theorem coe_splitLower : (splitLower I i x : Set (ι → ℝ)) = ↑I ∩ { y | y i ≤ x } := by rw [splitLower, coe_mk'] ext y simp only [mem_univ_pi, mem_Ioc, mem_inter_iff, mem_coe, mem_setOf_eq, forall_and, ← Pi.le_def, le_update_iff, le_min_iff, and_assoc, and_forall_ne (p := fun j => y j ≤ upper I j) i, mem_def] rw [and_comm (a := y i ≤ x)] #align box_integral.box.coe_split_lower BoxIntegral.Box.coe_splitLower theorem splitLower_le : I.splitLower i x ≤ I := withBotCoe_subset_iff.1 <| by simp #align box_integral.box.split_lower_le BoxIntegral.Box.splitLower_le @[simp] theorem splitLower_eq_bot {i x} : I.splitLower i x = ⊥ ↔ x ≤ I.lower i := by rw [splitLower, mk'_eq_bot, exists_update_iff I.upper fun j y => y ≤ I.lower j] simp [(I.lower_lt_upper _).not_le] #align box_integral.box.split_lower_eq_bot BoxIntegral.Box.splitLower_eq_bot @[simp]
Mathlib/Analysis/BoxIntegral/Partition/Split.lean
84
85
theorem splitLower_eq_self : I.splitLower i x = I ↔ I.upper i ≤ x := by
simp [splitLower, update_eq_iff]
/- Copyright (c) 2021 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.Order.Interval.Finset.Fin #align_import data.fintype.fin from "leanprover-community/mathlib"@"759575657f189ccb424b990164c8b1fa9f55cdfe" /-! # The structure of `Fintype (Fin n)` This file contains some basic results about the `Fintype` instance for `Fin`, especially properties of `Finset.univ : Finset (Fin n)`. -/ open Finset open Fintype namespace Fin variable {α β : Type*} {n : ℕ} theorem map_valEmbedding_univ : (Finset.univ : Finset (Fin n)).map Fin.valEmbedding = Iio n := by ext simp [orderIsoSubtype.symm.surjective.exists, OrderIso.symm] #align fin.map_subtype_embedding_univ Fin.map_valEmbedding_univ @[simp] theorem Ioi_zero_eq_map : Ioi (0 : Fin n.succ) = univ.map (Fin.succEmb _) := coe_injective <| by ext; simp [pos_iff_ne_zero] #align fin.Ioi_zero_eq_map Fin.Ioi_zero_eq_map @[simp] theorem Iio_last_eq_map : Iio (Fin.last n) = Finset.univ.map Fin.castSuccEmb := coe_injective <| by ext; simp [lt_def] #align fin.Iio_last_eq_map Fin.Iio_last_eq_map @[simp] theorem Ioi_succ (i : Fin n) : Ioi i.succ = (Ioi i).map (Fin.succEmb _) := by ext i simp only [mem_filter, mem_Ioi, mem_map, mem_univ, true_and_iff, Function.Embedding.coeFn_mk, exists_true_left] constructor · refine cases ?_ ?_ i · rintro ⟨⟨⟩⟩ · intro i hi exact ⟨i, succ_lt_succ_iff.mp hi, rfl⟩ · rintro ⟨i, hi, rfl⟩ simpa #align fin.Ioi_succ Fin.Ioi_succ @[simp] theorem Iio_castSucc (i : Fin n) : Iio (castSucc i) = (Iio i).map Fin.castSuccEmb := by apply Finset.map_injective Fin.valEmbedding rw [Finset.map_map, Fin.map_valEmbedding_Iio] exact (Fin.map_valEmbedding_Iio i).symm #align fin.Iio_cast_succ Fin.Iio_castSucc theorem card_filter_univ_succ' (p : Fin (n + 1) → Prop) [DecidablePred p] : (univ.filter p).card = ite (p 0) 1 0 + (univ.filter (p ∘ Fin.succ)).card := by rw [Fin.univ_succ, filter_cons, card_disjUnion, filter_map, card_map] split_ifs <;> simp #align fin.card_filter_univ_succ' Fin.card_filter_univ_succ' theorem card_filter_univ_succ (p : Fin (n + 1) → Prop) [DecidablePred p] : (univ.filter p).card = if p 0 then (univ.filter (p ∘ Fin.succ)).card + 1 else (univ.filter (p ∘ Fin.succ)).card := (card_filter_univ_succ' p).trans (by split_ifs <;> simp [add_comm 1]) #align fin.card_filter_univ_succ Fin.card_filter_univ_succ
Mathlib/Data/Fintype/Fin.lean
73
78
theorem card_filter_univ_eq_vector_get_eq_count [DecidableEq α] (a : α) (v : Vector α n) : (univ.filter fun i => a = v.get i).card = v.toList.count a := by
induction' v with n x xs hxs · simp · simp_rw [card_filter_univ_succ', Vector.get_cons_zero, Vector.toList_cons, Function.comp, Vector.get_cons_succ, hxs, List.count_cons, add_comm (ite (a = x) 1 0)]
/- Copyright (c) 2018 Reid Barton. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Reid Barton, Scott Morrison -/ import Mathlib.CategoryTheory.Opposites #align_import category_theory.eq_to_hom from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" /-! # Morphisms from equations between objects. When working categorically, sometimes one encounters an equation `h : X = Y` between objects. Your initial aversion to this is natural and appropriate: you're in for some trouble, and if there is another way to approach the problem that won't rely on this equality, it may be worth pursuing. You have two options: 1. Use the equality `h` as one normally would in Lean (e.g. using `rw` and `subst`). This may immediately cause difficulties, because in category theory everything is dependently typed, and equations between objects quickly lead to nasty goals with `eq.rec`. 2. Promote `h` to a morphism using `eqToHom h : X ⟶ Y`, or `eqToIso h : X ≅ Y`. This file introduces various `simp` lemmas which in favourable circumstances result in the various `eqToHom` morphisms to drop out at the appropriate moment! -/ universe v₁ v₂ v₃ u₁ u₂ u₃ -- morphism levels before object levels. See note [CategoryTheory universes]. namespace CategoryTheory open Opposite variable {C : Type u₁} [Category.{v₁} C] /-- An equality `X = Y` gives us a morphism `X ⟶ Y`. It is typically better to use this, rather than rewriting by the equality then using `𝟙 _` which usually leads to dependent type theory hell. -/ def eqToHom {X Y : C} (p : X = Y) : X ⟶ Y := by rw [p]; exact 𝟙 _ #align category_theory.eq_to_hom CategoryTheory.eqToHom @[simp] theorem eqToHom_refl (X : C) (p : X = X) : eqToHom p = 𝟙 X := rfl #align category_theory.eq_to_hom_refl CategoryTheory.eqToHom_refl @[reassoc (attr := simp)] theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) : eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by cases p cases q simp #align category_theory.eq_to_hom_trans CategoryTheory.eqToHom_trans theorem comp_eqToHom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') : f ≫ eqToHom p = g ↔ f = g ≫ eqToHom p.symm := { mp := fun h => h ▸ by simp mpr := fun h => by simp [eq_whisker h (eqToHom p)] } #align category_theory.comp_eq_to_hom_iff CategoryTheory.comp_eqToHom_iff theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) : eqToHom p ≫ g = f ↔ g = eqToHom p.symm ≫ f := { mp := fun h => h ▸ by simp mpr := fun h => h ▸ by simp [whisker_eq _ h] } #align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff variable {β : Sort*} /-- We can push `eqToHom` to the left through families of morphisms. -/ -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') : z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by cases w simp /-- A variant on `eqToHom_naturality` that helps Lean identify the families `f` and `g`. -/ -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_iso_hom_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).hom ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').hom := by cases w simp /-- A variant on `eqToHom_naturality` that helps Lean identify the families `f` and `g`. -/ -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)]
Mathlib/CategoryTheory/EqToHom.lean
95
98
theorem eqToHom_iso_inv_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).inv ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').inv := by
cases w simp
/- Copyright (c) 2023 Mantas Bakšys, Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mantas Bakšys, Yaël Dillies -/ import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Rearrangement import Mathlib.Algebra.Order.Ring.Basic import Mathlib.GroupTheory.Perm.Cycle.Basic #align_import algebra.order.chebyshev from "leanprover-community/mathlib"@"b7399344324326918d65d0c74e9571e3a8cb9199" /-! # Chebyshev's sum inequality This file proves the Chebyshev sum inequality. Chebyshev's inequality states `(∑ i ∈ s, f i) * (∑ i ∈ s, g i) ≤ s.card * ∑ i ∈ s, f i * g i` when `f g : ι → α` monovary, and the reverse inequality when `f` and `g` antivary. ## Main declarations * `MonovaryOn.sum_mul_sum_le_card_mul_sum`: Chebyshev's inequality. * `AntivaryOn.card_mul_sum_le_sum_mul_sum`: Chebyshev's inequality, dual version. * `sq_sum_le_card_mul_sum_sq`: Special case of Chebyshev's inequality when `f = g`. ## Implementation notes In fact, we don't need much compatibility between the addition and multiplication of `α`, so we can actually decouple them by replacing multiplication with scalar multiplication and making `f` and `g` land in different types. As a bonus, this makes the dual statement trivial. The multiplication versions are provided for convenience. The case for `Monotone`/`Antitone` pairs of functions over a `LinearOrder` is not deduced in this file because it is easily deducible from the `Monovary` API. -/ open Equiv Equiv.Perm Finset Function OrderDual variable {ι α β : Type*} /-! ### Scalar multiplication versions -/ section SMul variable [LinearOrderedRing α] [LinearOrderedAddCommGroup β] [Module α β] [OrderedSMul α β] {s : Finset ι} {σ : Perm ι} {f : ι → α} {g : ι → β} /-- **Chebyshev's Sum Inequality**: When `f` and `g` monovary together (eg they are both monotone/antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem MonovaryOn.sum_smul_sum_le_card_smul_sum (hfg : MonovaryOn f g s) : ((∑ i ∈ s, f i) • ∑ i ∈ s, g i) ≤ s.card • ∑ i ∈ s, f i • g i := by classical obtain ⟨σ, hσ, hs⟩ := s.countable_toSet.exists_cycleOn rw [← card_range s.card, sum_smul_sum_eq_sum_perm hσ] exact sum_le_card_nsmul _ _ _ fun n _ => hfg.sum_smul_comp_perm_le_sum_smul fun x hx => hs fun h => hx <| IsFixedPt.perm_pow h _ #align monovary_on.sum_smul_sum_le_card_smul_sum MonovaryOn.sum_smul_sum_le_card_smul_sum /-- **Chebyshev's Sum Inequality**: When `f` and `g` antivary together (eg one is monotone, the other is antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem AntivaryOn.card_smul_sum_le_sum_smul_sum (hfg : AntivaryOn f g s) : (s.card • ∑ i ∈ s, f i • g i) ≤ (∑ i ∈ s, f i) • ∑ i ∈ s, g i := by exact hfg.dual_right.sum_smul_sum_le_card_smul_sum #align antivary_on.card_smul_sum_le_sum_smul_sum AntivaryOn.card_smul_sum_le_sum_smul_sum variable [Fintype ι] /-- **Chebyshev's Sum Inequality**: When `f` and `g` monovary together (eg they are both monotone/antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem Monovary.sum_smul_sum_le_card_smul_sum (hfg : Monovary f g) : ((∑ i, f i) • ∑ i, g i) ≤ Fintype.card ι • ∑ i, f i • g i := (hfg.monovaryOn _).sum_smul_sum_le_card_smul_sum #align monovary.sum_smul_sum_le_card_smul_sum Monovary.sum_smul_sum_le_card_smul_sum /-- **Chebyshev's Sum Inequality**: When `f` and `g` antivary together (eg one is monotone, the other is antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem Antivary.card_smul_sum_le_sum_smul_sum (hfg : Antivary f g) : (Fintype.card ι • ∑ i, f i • g i) ≤ (∑ i, f i) • ∑ i, g i := by exact (hfg.dual_right.monovaryOn _).sum_smul_sum_le_card_smul_sum #align antivary.card_smul_sum_le_sum_smul_sum Antivary.card_smul_sum_le_sum_smul_sum end SMul /-! ### Multiplication versions Special cases of the above when scalar multiplication is actually multiplication. -/ section Mul variable [LinearOrderedRing α] {s : Finset ι} {σ : Perm ι} {f g : ι → α} /-- **Chebyshev's Sum Inequality**: When `f` and `g` monovary together (eg they are both monotone/antitone), the product of their sum is less than the size of the set times their scalar product. -/
Mathlib/Algebra/Order/Chebyshev.lean
109
112
theorem MonovaryOn.sum_mul_sum_le_card_mul_sum (hfg : MonovaryOn f g s) : ((∑ i ∈ s, f i) * ∑ i ∈ s, g i) ≤ s.card * ∑ i ∈ s, f i * g i := by
rw [← nsmul_eq_mul] exact hfg.sum_smul_sum_le_card_smul_sum
/- Copyright (c) 2021 Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard, Antoine Labelle -/ import Mathlib.Algebra.Module.Defs import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.FreeModule.Basic import Mathlib.LinearAlgebra.TensorProduct.Tower #align_import algebra.module.projective from "leanprover-community/mathlib"@"405ea5cee7a7070ff8fb8dcb4cfb003532e34bce" /-! # Projective modules This file contains a definition of a projective module, the proof that our definition is equivalent to a lifting property, and the proof that all free modules are projective. ## Main definitions Let `R` be a ring (or a semiring) and let `M` be an `R`-module. * `Module.Projective R M` : the proposition saying that `M` is a projective `R`-module. ## Main theorems * `Module.projective_lifting_property` : a map from a projective module can be lifted along a surjection. * `Module.Projective.of_lifting_property` : If for all R-module surjections `A →ₗ B`, all maps `M →ₗ B` lift to `M →ₗ A`, then `M` is projective. * `Module.Projective.of_free` : Free modules are projective ## Implementation notes The actual definition of projective we use is that the natural R-module map from the free R-module on the type M down to M splits. This is more convenient than certain other definitions which involve quantifying over universes, and also universe-polymorphic (the ring and module can be in different universes). We require that the module sits in at least as high a universe as the ring: without this, free modules don't even exist, and it's unclear if projective modules are even a useful notion. ## References https://en.wikipedia.org/wiki/Projective_module ## TODO - Direct sum of two projective modules is projective. - Arbitrary sum of projective modules is projective. All of these should be relatively straightforward. ## Tags projective module -/ universe u v open LinearMap hiding id open Finsupp /- The actual implementation we choose: `P` is projective if the natural surjection from the free `R`-module on `P` to `P` splits. -/ /-- An R-module is projective if it is a direct summand of a free module, or equivalently if maps from the module lift along surjections. There are several other equivalent definitions. -/ class Module.Projective (R : Type*) [Semiring R] (P : Type*) [AddCommMonoid P] [Module R P] : Prop where out : ∃ s : P →ₗ[R] P →₀ R, Function.LeftInverse (Finsupp.total P P R id) s #align module.projective Module.Projective namespace Module section Semiring variable {R : Type*} [Semiring R] {P : Type*} [AddCommMonoid P] [Module R P] {M : Type*} [AddCommMonoid M] [Module R M] {N : Type*} [AddCommMonoid N] [Module R N] theorem projective_def : Projective R P ↔ ∃ s : P →ₗ[R] P →₀ R, Function.LeftInverse (Finsupp.total P P R id) s := ⟨fun h => h.1, fun h => ⟨h⟩⟩ #align module.projective_def Module.projective_def theorem projective_def' : Projective R P ↔ ∃ s : P →ₗ[R] P →₀ R, Finsupp.total P P R id ∘ₗ s = .id := by simp_rw [projective_def, DFunLike.ext_iff, Function.LeftInverse, comp_apply, id_apply] #align module.projective_def' Module.projective_def' /-- A projective R-module has the property that maps from it lift along surjections. -/
Mathlib/Algebra/Module/Projective.lean
98
116
theorem projective_lifting_property [h : Projective R P] (f : M →ₗ[R] N) (g : P →ₗ[R] N) (hf : Function.Surjective f) : ∃ h : P →ₗ[R] M, f.comp h = g := by
/- Here's the first step of the proof. Recall that `X →₀ R` is Lean's way of talking about the free `R`-module on a type `X`. The universal property `Finsupp.total` says that to a map `X → N` from a type to an `R`-module, we get an associated R-module map `(X →₀ R) →ₗ N`. Apply this to a (noncomputable) map `P → M` coming from the map `P →ₗ N` and a random splitting of the surjection `M →ₗ N`, and we get a map `φ : (P →₀ R) →ₗ M`. -/ let φ : (P →₀ R) →ₗ[R] M := Finsupp.total _ _ _ fun p => Function.surjInv hf (g p) -- By projectivity we have a map `P →ₗ (P →₀ R)`; cases' h.out with s hs -- Compose to get `P →ₗ M`. This works. use φ.comp s ext p conv_rhs => rw [← hs p] simp [φ, Finsupp.total_apply, Function.surjInv_eq hf, map_finsupp_sum]
/- Copyright (c) 2022 Violeta Hernández Palacios. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Violeta Hernández Palacios -/ import Mathlib.Algebra.Polynomial.Cardinal import Mathlib.RingTheory.Algebraic #align_import algebra.algebraic_card from "leanprover-community/mathlib"@"40494fe75ecbd6d2ec61711baa630cf0a7b7d064" /-! ### Cardinality of algebraic numbers In this file, we prove variants of the following result: the cardinality of algebraic numbers under an R-algebra is at most `# R[X] * ℵ₀`. Although this can be used to prove that real or complex transcendental numbers exist, a more direct proof is given by `Liouville.is_transcendental`. -/ universe u v open Cardinal Polynomial Set open Cardinal Polynomial namespace Algebraic theorem infinite_of_charZero (R A : Type*) [CommRing R] [IsDomain R] [Ring A] [Algebra R A] [CharZero A] : { x : A | IsAlgebraic R x }.Infinite := infinite_of_injective_forall_mem Nat.cast_injective isAlgebraic_nat #align algebraic.infinite_of_char_zero Algebraic.infinite_of_charZero theorem aleph0_le_cardinal_mk_of_charZero (R A : Type*) [CommRing R] [IsDomain R] [Ring A] [Algebra R A] [CharZero A] : ℵ₀ ≤ #{ x : A // IsAlgebraic R x } := infinite_iff.1 (Set.infinite_coe_iff.2 <| infinite_of_charZero R A) #align algebraic.aleph_0_le_cardinal_mk_of_char_zero Algebraic.aleph0_le_cardinal_mk_of_charZero section lift variable (R : Type u) (A : Type v) [CommRing R] [CommRing A] [IsDomain A] [Algebra R A] [NoZeroSMulDivisors R A] theorem cardinal_mk_lift_le_mul : Cardinal.lift.{u} #{ x : A // IsAlgebraic R x } ≤ Cardinal.lift.{v} #R[X] * ℵ₀ := by rw [← mk_uLift, ← mk_uLift] choose g hg₁ hg₂ using fun x : { x : A | IsAlgebraic R x } => x.coe_prop refine lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le g fun f => ?_ rw [lift_le_aleph0, le_aleph0_iff_set_countable] suffices MapsTo (↑) (g ⁻¹' {f}) (f.rootSet A) from this.countable_of_injOn Subtype.coe_injective.injOn (f.rootSet_finite A).countable rintro x (rfl : g x = f) exact mem_rootSet.2 ⟨hg₁ x, hg₂ x⟩ #align algebraic.cardinal_mk_lift_le_mul Algebraic.cardinal_mk_lift_le_mul theorem cardinal_mk_lift_le_max : Cardinal.lift.{u} #{ x : A // IsAlgebraic R x } ≤ max (Cardinal.lift.{v} #R) ℵ₀ := (cardinal_mk_lift_le_mul R A).trans <| (mul_le_mul_right' (lift_le.2 cardinal_mk_le_max) _).trans <| by simp #align algebraic.cardinal_mk_lift_le_max Algebraic.cardinal_mk_lift_le_max @[simp] theorem cardinal_mk_lift_of_infinite [Infinite R] : Cardinal.lift.{u} #{ x : A // IsAlgebraic R x } = Cardinal.lift.{v} #R := ((cardinal_mk_lift_le_max R A).trans_eq (max_eq_left <| aleph0_le_mk _)).antisymm <| lift_mk_le'.2 ⟨⟨fun x => ⟨algebraMap R A x, isAlgebraic_algebraMap _⟩, fun _ _ h => NoZeroSMulDivisors.algebraMap_injective R A (Subtype.ext_iff.1 h)⟩⟩ #align algebraic.cardinal_mk_lift_of_infinite Algebraic.cardinal_mk_lift_of_infinite variable [Countable R] @[simp] protected theorem countable : Set.Countable { x : A | IsAlgebraic R x } := by rw [← le_aleph0_iff_set_countable, ← lift_le_aleph0] apply (cardinal_mk_lift_le_max R A).trans simp #align algebraic.countable Algebraic.countable @[simp] theorem cardinal_mk_of_countable_of_charZero [CharZero A] [IsDomain R] : #{ x : A // IsAlgebraic R x } = ℵ₀ := (Algebraic.countable R A).le_aleph0.antisymm (aleph0_le_cardinal_mk_of_charZero R A) #align algebraic.cardinal_mk_of_countble_of_char_zero Algebraic.cardinal_mk_of_countable_of_charZero end lift section NonLift variable (R A : Type u) [CommRing R] [CommRing A] [IsDomain A] [Algebra R A] [NoZeroSMulDivisors R A]
Mathlib/Algebra/AlgebraicCard.lean
93
95
theorem cardinal_mk_le_mul : #{ x : A // IsAlgebraic R x } ≤ #R[X] * ℵ₀ := by
rw [← lift_id #_, ← lift_id #R[X]] exact cardinal_mk_lift_le_mul R A
/- Copyright (c) 2021 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying, Eric Wieser -/ import Mathlib.Data.Real.Basic #align_import data.real.sign from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Real sign function This file introduces and contains some results about `Real.sign` which maps negative real numbers to -1, positive real numbers to 1, and 0 to 0. ## Main definitions * `Real.sign r` is $\begin{cases} -1 & \text{if } r < 0, \\ ~~\, 0 & \text{if } r = 0, \\ ~~\, 1 & \text{if } r > 0. \end{cases}$ ## Tags sign function -/ namespace Real /-- The sign function that maps negative real numbers to -1, positive numbers to 1, and 0 otherwise. -/ noncomputable def sign (r : ℝ) : ℝ := if r < 0 then -1 else if 0 < r then 1 else 0 #align real.sign Real.sign theorem sign_of_neg {r : ℝ} (hr : r < 0) : sign r = -1 := by rw [sign, if_pos hr] #align real.sign_of_neg Real.sign_of_neg theorem sign_of_pos {r : ℝ} (hr : 0 < r) : sign r = 1 := by rw [sign, if_pos hr, if_neg hr.not_lt] #align real.sign_of_pos Real.sign_of_pos @[simp] theorem sign_zero : sign 0 = 0 := by rw [sign, if_neg (lt_irrefl _), if_neg (lt_irrefl _)] #align real.sign_zero Real.sign_zero @[simp] theorem sign_one : sign 1 = 1 := sign_of_pos <| by norm_num #align real.sign_one Real.sign_one theorem sign_apply_eq (r : ℝ) : sign r = -1 ∨ sign r = 0 ∨ sign r = 1 := by obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ) · exact Or.inl <| sign_of_neg hn · exact Or.inr <| Or.inl <| sign_zero · exact Or.inr <| Or.inr <| sign_of_pos hp #align real.sign_apply_eq Real.sign_apply_eq /-- This lemma is useful for working with `ℝˣ` -/ theorem sign_apply_eq_of_ne_zero (r : ℝ) (h : r ≠ 0) : sign r = -1 ∨ sign r = 1 := h.lt_or_lt.imp sign_of_neg sign_of_pos #align real.sign_apply_eq_of_ne_zero Real.sign_apply_eq_of_ne_zero @[simp] theorem sign_eq_zero_iff {r : ℝ} : sign r = 0 ↔ r = 0 := by refine ⟨fun h => ?_, fun h => h.symm ▸ sign_zero⟩ obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ) · rw [sign_of_neg hn, neg_eq_zero] at h exact (one_ne_zero h).elim · rfl · rw [sign_of_pos hp] at h exact (one_ne_zero h).elim #align real.sign_eq_zero_iff Real.sign_eq_zero_iff theorem sign_intCast (z : ℤ) : sign (z : ℝ) = ↑(Int.sign z) := by obtain hn | rfl | hp := lt_trichotomy z (0 : ℤ) · rw [sign_of_neg (Int.cast_lt_zero.mpr hn), Int.sign_eq_neg_one_of_neg hn, Int.cast_neg, Int.cast_one] · rw [Int.cast_zero, sign_zero, Int.sign_zero, Int.cast_zero] · rw [sign_of_pos (Int.cast_pos.mpr hp), Int.sign_eq_one_of_pos hp, Int.cast_one] #align real.sign_int_cast Real.sign_intCast @[deprecated (since := "2024-04-17")] alias sign_int_cast := sign_intCast theorem sign_neg {r : ℝ} : sign (-r) = -sign r := by obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ) · rw [sign_of_neg hn, sign_of_pos (neg_pos.mpr hn), neg_neg] · rw [sign_zero, neg_zero, sign_zero] · rw [sign_of_pos hp, sign_of_neg (neg_lt_zero.mpr hp)] #align real.sign_neg Real.sign_neg
Mathlib/Data/Real/Sign.lean
92
98
theorem sign_mul_nonneg (r : ℝ) : 0 ≤ sign r * r := by
obtain hn | rfl | hp := lt_trichotomy r (0 : ℝ) · rw [sign_of_neg hn] exact mul_nonneg_of_nonpos_of_nonpos (by norm_num) hn.le · rw [mul_zero] · rw [sign_of_pos hp, one_mul] exact hp.le
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Control.Applicative import Mathlib.Control.Traversable.Basic #align_import control.traversable.lemmas from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" /-! # Traversing collections This file proves basic properties of traversable and applicative functors and defines `PureTransformation F`, the natural applicative transformation from the identity functor to `F`. ## References Inspired by [The Essence of the Iterator Pattern][gibbons2009]. -/ universe u open LawfulTraversable open Function hiding comp open Functor attribute [functor_norm] LawfulTraversable.naturality attribute [simp] LawfulTraversable.id_traverse namespace Traversable variable {t : Type u → Type u} variable [Traversable t] [LawfulTraversable t] variable (F G : Type u → Type u) variable [Applicative F] [LawfulApplicative F] variable [Applicative G] [LawfulApplicative G] variable {α β γ : Type u} variable (g : α → F β) variable (h : β → G γ) variable (f : β → γ) /-- The natural applicative transformation from the identity functor to `F`, defined by `pure : Π {α}, α → F α`. -/ def PureTransformation : ApplicativeTransformation Id F where app := @pure F _ preserves_pure' x := rfl preserves_seq' f x := by simp only [map_pure, seq_pure] rfl #align traversable.pure_transformation Traversable.PureTransformation @[simp] theorem pureTransformation_apply {α} (x : id α) : PureTransformation F x = pure x := rfl #align traversable.pure_transformation_apply Traversable.pureTransformation_apply variable {F G} (x : t β) -- Porting note: need to specify `m/F/G := Id` because `id` no longer has a `Monad` instance theorem map_eq_traverse_id : map (f := t) f = traverse (m := Id) (pure ∘ f) := funext fun y => (traverse_eq_map_id f y).symm #align traversable.map_eq_traverse_id Traversable.map_eq_traverse_id theorem map_traverse (x : t α) : map f <$> traverse g x = traverse (map f ∘ g) x := by rw [map_eq_traverse_id f] refine (comp_traverse (pure ∘ f) g x).symm.trans ?_ congr; apply Comp.applicative_comp_id #align traversable.map_traverse Traversable.map_traverse theorem traverse_map (f : β → F γ) (g : α → β) (x : t α) : traverse f (g <$> x) = traverse (f ∘ g) x := by rw [@map_eq_traverse_id t _ _ _ _ g] refine (comp_traverse (G := Id) f (pure ∘ g) x).symm.trans ?_ congr; apply Comp.applicative_id_comp #align traversable.traverse_map Traversable.traverse_map theorem pure_traverse (x : t α) : traverse pure x = (pure x : F (t α)) := by have : traverse pure x = pure (traverse (m := Id) pure x) := (naturality (PureTransformation F) pure x).symm rwa [id_traverse] at this #align traversable.pure_traverse Traversable.pure_traverse theorem id_sequence (x : t α) : sequence (f := Id) (pure <$> x) = pure x := by simp [sequence, traverse_map, id_traverse] #align traversable.id_sequence Traversable.id_sequence theorem comp_sequence (x : t (F (G α))) : sequence (Comp.mk <$> x) = Comp.mk (sequence <$> sequence x) := by simp only [sequence, traverse_map, id_comp]; rw [← comp_traverse]; simp [map_id] #align traversable.comp_sequence Traversable.comp_sequence theorem naturality' (η : ApplicativeTransformation F G) (x : t (F α)) : η (sequence x) = sequence (@η _ <$> x) := by simp [sequence, naturality, traverse_map] #align traversable.naturality' Traversable.naturality' @[functor_norm] theorem traverse_id : traverse pure = (pure : t α → Id (t α)) := by ext exact id_traverse _ #align traversable.traverse_id Traversable.traverse_id @[functor_norm]
Mathlib/Control/Traversable/Lemmas.lean
109
113
theorem traverse_comp (g : α → F β) (h : β → G γ) : traverse (Comp.mk ∘ map h ∘ g) = (Comp.mk ∘ map (traverse h) ∘ traverse g : t α → Comp F G (t γ)) := by
ext exact comp_traverse _ _ _
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Degree.Lemmas import Mathlib.Algebra.Polynomial.HasseDeriv #align_import data.polynomial.taylor from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Taylor expansions of polynomials ## Main declarations * `Polynomial.taylor`: the Taylor expansion of the polynomial `f` at `r` * `Polynomial.taylor_coeff`: the `k`th coefficient of `taylor r f` is `(Polynomial.hasseDeriv k f).eval r` * `Polynomial.eq_zero_of_hasseDeriv_eq_zero`: the identity principle: a polynomial is 0 iff all its Hasse derivatives are zero -/ noncomputable section namespace Polynomial open Polynomial variable {R : Type*} [Semiring R] (r : R) (f : R[X]) /-- The Taylor expansion of a polynomial `f` at `r`. -/ def taylor (r : R) : R[X] →ₗ[R] R[X] where toFun f := f.comp (X + C r) map_add' f g := add_comp map_smul' c f := by simp only [smul_eq_C_mul, C_mul_comp, RingHom.id_apply] #align polynomial.taylor Polynomial.taylor theorem taylor_apply : taylor r f = f.comp (X + C r) := rfl #align polynomial.taylor_apply Polynomial.taylor_apply @[simp] theorem taylor_X : taylor r X = X + C r := by simp only [taylor_apply, X_comp] set_option linter.uppercaseLean3 false in #align polynomial.taylor_X Polynomial.taylor_X @[simp] theorem taylor_C (x : R) : taylor r (C x) = C x := by simp only [taylor_apply, C_comp] set_option linter.uppercaseLean3 false in #align polynomial.taylor_C Polynomial.taylor_C @[simp] theorem taylor_zero' : taylor (0 : R) = LinearMap.id := by ext simp only [taylor_apply, add_zero, comp_X, _root_.map_zero, LinearMap.id_comp, Function.comp_apply, LinearMap.coe_comp] #align polynomial.taylor_zero' Polynomial.taylor_zero' theorem taylor_zero (f : R[X]) : taylor 0 f = f := by rw [taylor_zero', LinearMap.id_apply] #align polynomial.taylor_zero Polynomial.taylor_zero @[simp] theorem taylor_one : taylor r (1 : R[X]) = C 1 := by rw [← C_1, taylor_C] #align polynomial.taylor_one Polynomial.taylor_one @[simp] theorem taylor_monomial (i : ℕ) (k : R) : taylor r (monomial i k) = C k * (X + C r) ^ i := by simp [taylor_apply] #align polynomial.taylor_monomial Polynomial.taylor_monomial /-- The `k`th coefficient of `Polynomial.taylor r f` is `(Polynomial.hasseDeriv k f).eval r`. -/ theorem taylor_coeff (n : ℕ) : (taylor r f).coeff n = (hasseDeriv n f).eval r := show (lcoeff R n).comp (taylor r) f = (leval r).comp (hasseDeriv n) f by congr 1; clear! f; ext i simp only [leval_apply, mul_one, one_mul, eval_monomial, LinearMap.comp_apply, coeff_C_mul, hasseDeriv_monomial, taylor_apply, monomial_comp, C_1, (commute_X (C r)).add_pow i, map_sum] simp only [lcoeff_apply, ← C_eq_natCast, mul_assoc, ← C_pow, ← C_mul, coeff_mul_C, (Nat.cast_commute _ _).eq, coeff_X_pow, boole_mul, Finset.sum_ite_eq, Finset.mem_range] split_ifs with h; · rfl push_neg at h; rw [Nat.choose_eq_zero_of_lt h, Nat.cast_zero, mul_zero] #align polynomial.taylor_coeff Polynomial.taylor_coeff @[simp] theorem taylor_coeff_zero : (taylor r f).coeff 0 = f.eval r := by rw [taylor_coeff, hasseDeriv_zero, LinearMap.id_apply] #align polynomial.taylor_coeff_zero Polynomial.taylor_coeff_zero @[simp] theorem taylor_coeff_one : (taylor r f).coeff 1 = f.derivative.eval r := by rw [taylor_coeff, hasseDeriv_one] #align polynomial.taylor_coeff_one Polynomial.taylor_coeff_one @[simp]
Mathlib/Algebra/Polynomial/Taylor.lean
98
102
theorem natDegree_taylor (p : R[X]) (r : R) : natDegree (taylor r p) = natDegree p := by
refine map_natDegree_eq_natDegree _ ?_ nontriviality R intro n c c0 simp [taylor_monomial, natDegree_C_mul_eq_of_mul_ne_zero, natDegree_pow_X_add_C, c0]
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.SetTheory.Game.State #align_import set_theory.game.domineering from "leanprover-community/mathlib"@"b134b2f5cf6dd25d4bbfd3c498b6e36c11a17225" /-! # Domineering as a combinatorial game. We define the game of Domineering, played on a chessboard of arbitrary shape (possibly even disconnected). Left moves by placing a domino vertically, while Right moves by placing a domino horizontally. This is only a fragment of a full development; in order to successfully analyse positions we would need some more theorems. Most importantly, we need a general statement that allows us to discard irrelevant moves. Specifically to domineering, we need the fact that disjoint parts of the chessboard give sums of games. -/ namespace SetTheory namespace PGame namespace Domineering open Function /-- The equivalence `(x, y) ↦ (x, y+1)`. -/ @[simps!] def shiftUp : ℤ × ℤ ≃ ℤ × ℤ := (Equiv.refl ℤ).prodCongr (Equiv.addRight (1 : ℤ)) #align pgame.domineering.shift_up SetTheory.PGame.Domineering.shiftUp /-- The equivalence `(x, y) ↦ (x+1, y)`. -/ @[simps!] def shiftRight : ℤ × ℤ ≃ ℤ × ℤ := (Equiv.addRight (1 : ℤ)).prodCongr (Equiv.refl ℤ) #align pgame.domineering.shift_right SetTheory.PGame.Domineering.shiftRight /-- A Domineering board is an arbitrary finite subset of `ℤ × ℤ`. -/ -- Porting note: reducibility cannot be `local`. For now there are no dependents of this file so -- being globally reducible is fine. abbrev Board := Finset (ℤ × ℤ) #align pgame.domineering.board SetTheory.PGame.Domineering.Board /-- Left can play anywhere that a square and the square below it are open. -/ def left (b : Board) : Finset (ℤ × ℤ) := b ∩ b.map shiftUp #align pgame.domineering.left SetTheory.PGame.Domineering.left /-- Right can play anywhere that a square and the square to the left are open. -/ def right (b : Board) : Finset (ℤ × ℤ) := b ∩ b.map shiftRight #align pgame.domineering.right SetTheory.PGame.Domineering.right theorem mem_left {b : Board} (x : ℤ × ℤ) : x ∈ left b ↔ x ∈ b ∧ (x.1, x.2 - 1) ∈ b := Finset.mem_inter.trans (and_congr Iff.rfl Finset.mem_map_equiv) #align pgame.domineering.mem_left SetTheory.PGame.Domineering.mem_left theorem mem_right {b : Board} (x : ℤ × ℤ) : x ∈ right b ↔ x ∈ b ∧ (x.1 - 1, x.2) ∈ b := Finset.mem_inter.trans (and_congr Iff.rfl Finset.mem_map_equiv) #align pgame.domineering.mem_right SetTheory.PGame.Domineering.mem_right /-- After Left moves, two vertically adjacent squares are removed from the board. -/ def moveLeft (b : Board) (m : ℤ × ℤ) : Board := (b.erase m).erase (m.1, m.2 - 1) #align pgame.domineering.move_left SetTheory.PGame.Domineering.moveLeft /-- After Left moves, two horizontally adjacent squares are removed from the board. -/ def moveRight (b : Board) (m : ℤ × ℤ) : Board := (b.erase m).erase (m.1 - 1, m.2) #align pgame.domineering.move_right SetTheory.PGame.Domineering.moveRight theorem fst_pred_mem_erase_of_mem_right {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : (m.1 - 1, m.2) ∈ b.erase m := by rw [mem_right] at h apply Finset.mem_erase_of_ne_of_mem _ h.2 exact ne_of_apply_ne Prod.fst (pred_ne_self m.1) #align pgame.domineering.fst_pred_mem_erase_of_mem_right SetTheory.PGame.Domineering.fst_pred_mem_erase_of_mem_right theorem snd_pred_mem_erase_of_mem_left {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : (m.1, m.2 - 1) ∈ b.erase m := by rw [mem_left] at h apply Finset.mem_erase_of_ne_of_mem _ h.2 exact ne_of_apply_ne Prod.snd (pred_ne_self m.2) #align pgame.domineering.snd_pred_mem_erase_of_mem_left SetTheory.PGame.Domineering.snd_pred_mem_erase_of_mem_left
Mathlib/SetTheory/Game/Domineering.lean
93
98
theorem card_of_mem_left {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : 2 ≤ Finset.card b := by
have w₁ : m ∈ b := (Finset.mem_inter.1 h).1 have w₂ : (m.1, m.2 - 1) ∈ b.erase m := snd_pred_mem_erase_of_mem_left h have i₁ := Finset.card_erase_lt_of_mem w₁ have i₂ := Nat.lt_of_le_of_lt (Nat.zero_le _) (Finset.card_erase_lt_of_mem w₂) exact Nat.lt_of_le_of_lt i₂ i₁
/- Copyright (c) 2022 Chris Birkbeck. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Birkbeck -/ import Mathlib.Data.Complex.Basic import Mathlib.MeasureTheory.Integral.CircleIntegral #align_import measure_theory.integral.circle_transform from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15" /-! # Circle integral transform In this file we define the circle integral transform of a function `f` with complex domain. This is defined as $(2πi)^{-1}\frac{f(x)}{x-w}$ where `x` moves along a circle. We then prove some basic facts about these functions. These results are useful for proving that the uniform limit of a sequence of holomorphic functions is holomorphic. -/ open Set MeasureTheory Metric Filter Function open scoped Interval Real noncomputable section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] (R : ℝ) (z w : ℂ) namespace Complex /-- Given a function `f : ℂ → E`, `circleTransform R z w f` is the function mapping `θ` to `(2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • ((circleMap z R θ) - w)⁻¹ • f (circleMap z R θ)`. If `f` is differentiable and `w` is in the interior of the ball, then the integral from `0` to `2 * π` of this gives the value `f(w)`. -/ def circleTransform (f : ℂ → E) (θ : ℝ) : E := (2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • (circleMap z R θ - w)⁻¹ • f (circleMap z R θ) #align complex.circle_transform Complex.circleTransform /-- The derivative of `circleTransform` w.r.t `w`. -/ def circleTransformDeriv (f : ℂ → E) (θ : ℝ) : E := (2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • ((circleMap z R θ - w) ^ 2)⁻¹ • f (circleMap z R θ) #align complex.circle_transform_deriv Complex.circleTransformDeriv theorem circleTransformDeriv_periodic (f : ℂ → E) : Periodic (circleTransformDeriv R z w f) (2 * π) := by have := periodic_circleMap simp_rw [Periodic] at * intro x simp_rw [circleTransformDeriv, this] congr 2 simp [this] #align complex.circle_transform_deriv_periodic Complex.circleTransformDeriv_periodic theorem circleTransformDeriv_eq (f : ℂ → E) : circleTransformDeriv R z w f = fun θ => (circleMap z R θ - w)⁻¹ • circleTransform R z w f θ := by ext simp_rw [circleTransformDeriv, circleTransform, ← mul_smul, ← mul_assoc] ring_nf rw [inv_pow] congr ring #align complex.circle_transform_deriv_eq Complex.circleTransformDeriv_eq
Mathlib/MeasureTheory/Integral/CircleTransform.lean
68
72
theorem integral_circleTransform (f : ℂ → E) : (∫ θ : ℝ in (0)..2 * π, circleTransform R z w f θ) = (2 * ↑π * I)⁻¹ • ∮ z in C(z, R), (z - w)⁻¹ • f z := by
simp_rw [circleTransform, circleIntegral, deriv_circleMap, circleMap] simp
/- Copyright (c) 2019 Kevin Kappelmann. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Kappelmann -/ import Mathlib.Algebra.ContinuedFractions.Basic import Mathlib.Algebra.GroupWithZero.Basic #align_import algebra.continued_fractions.translations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" /-! # Basic Translation Lemmas Between Functions Defined for Continued Fractions ## Summary Some simple translation lemmas between the different definitions of functions defined in `Algebra.ContinuedFractions.Basic`. -/ namespace GeneralizedContinuedFraction section General /-! ### Translations Between General Access Functions Here we give some basic translations that hold by definition between the various methods that allow us to access the numerators and denominators of a continued fraction. -/ variable {α : Type*} {g : GeneralizedContinuedFraction α} {n : ℕ} theorem terminatedAt_iff_s_terminatedAt : g.TerminatedAt n ↔ g.s.TerminatedAt n := by rfl #align generalized_continued_fraction.terminated_at_iff_s_terminated_at GeneralizedContinuedFraction.terminatedAt_iff_s_terminatedAt theorem terminatedAt_iff_s_none : g.TerminatedAt n ↔ g.s.get? n = none := by rfl #align generalized_continued_fraction.terminated_at_iff_s_none GeneralizedContinuedFraction.terminatedAt_iff_s_none theorem part_num_none_iff_s_none : g.partialNumerators.get? n = none ↔ g.s.get? n = none := by cases s_nth_eq : g.s.get? n <;> simp [partialNumerators, s_nth_eq] #align generalized_continued_fraction.part_num_none_iff_s_none GeneralizedContinuedFraction.part_num_none_iff_s_none
Mathlib/Algebra/ContinuedFractions/Translations.lean
45
46
theorem terminatedAt_iff_part_num_none : g.TerminatedAt n ↔ g.partialNumerators.get? n = none := by
rw [terminatedAt_iff_s_none, part_num_none_iff_s_none]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" /-! # Integers mod `n` Definition of the integers mod n, and the field structure on the integers mod p. ## Definitions * `ZMod n`, which is for integers modulo a nat `n : ℕ` * `val a` is defined as a natural number: - for `a : ZMod 0` it is the absolute value of `a` - for `a : ZMod n` with `0 < n` it is the least natural number in the equivalence class * `valMinAbs` returns the integer closest to zero in the equivalence class. * A coercion `cast` is defined from `ZMod n` into any ring. This is a ring hom if the ring has characteristic dividing `n` -/ assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) /-- `val a` is a natural number defined as: - for `a : ZMod 0` it is the absolute value of `a` - for `a : ZMod n` with `0 < n` it is the least natural number in the equivalence class See `ZMod.valMinAbs` for a variant that takes values in the integers. -/ def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast
Mathlib/Data/ZMod/Basic.lean
94
96
theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by
simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Group.Int import Mathlib.Data.Nat.Dist import Mathlib.Data.Ordmap.Ordnode import Mathlib.Tactic.Abel import Mathlib.Tactic.Linarith #align_import data.ordmap.ordset from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69" /-! # Verification of the `Ordnode α` datatype This file proves the correctness of the operations in `Data.Ordmap.Ordnode`. The public facing version is the type `Ordset α`, which is a wrapper around `Ordnode α` which includes the correctness invariant of the type, and it exposes parallel operations like `insert` as functions on `Ordset` that do the same thing but bundle the correctness proofs. The advantage is that it is possible to, for example, prove that the result of `find` on `insert` will actually find the element, while `Ordnode` cannot guarantee this if the input tree did not satisfy the type invariants. ## Main definitions * `Ordset α`: A well formed set of values of type `α` ## Implementation notes The majority of this file is actually in the `Ordnode` namespace, because we first have to prove the correctness of all the operations (and defining what correctness means here is actually somewhat subtle). So all the actual `Ordset` operations are at the very end, once we have all the theorems. An `Ordnode α` is an inductive type which describes a tree which stores the `size` at internal nodes. The correctness invariant of an `Ordnode α` is: * `Ordnode.Sized t`: All internal `size` fields must match the actual measured size of the tree. (This is not hard to satisfy.) * `Ordnode.Balanced t`: Unless the tree has the form `()` or `((a) b)` or `(a (b))` (that is, nil or a single singleton subtree), the two subtrees must satisfy `size l ≤ δ * size r` and `size r ≤ δ * size l`, where `δ := 3` is a global parameter of the data structure (and this property must hold recursively at subtrees). This is why we say this is a "size balanced tree" data structure. * `Ordnode.Bounded lo hi t`: The members of the tree must be in strictly increasing order, meaning that if `a` is in the left subtree and `b` is the root, then `a ≤ b` and `¬ (b ≤ a)`. We enforce this using `Ordnode.Bounded` which includes also a global upper and lower bound. Because the `Ordnode` file was ported from Haskell, the correctness invariants of some of the functions have not been spelled out, and some theorems like `Ordnode.Valid'.balanceL_aux` show very intricate assumptions on the sizes, which may need to be revised if it turns out some operations violate these assumptions, because there is a decent amount of slop in the actual data structure invariants, so the theorem will go through with multiple choices of assumption. **Note:** This file is incomplete, in the sense that the intent is to have verified versions and lemmas about all the definitions in `Ordnode.lean`, but at the moment only a few operations are verified (the hard part should be out of the way, but still). Contributors are encouraged to pick this up and finish the job, if it appeals to you. ## Tags ordered map, ordered set, data structure, verified programming -/ variable {α : Type*} namespace Ordnode /-! ### delta and ratio -/ theorem not_le_delta {s} (H : 1 ≤ s) : ¬s ≤ delta * 0 := not_le_of_gt H #align ordnode.not_le_delta Ordnode.not_le_delta theorem delta_lt_false {a b : ℕ} (h₁ : delta * a < b) (h₂ : delta * b < a) : False := not_le_of_lt (lt_trans ((mul_lt_mul_left (by decide)).2 h₁) h₂) <| by simpa [mul_assoc] using Nat.mul_le_mul_right a (by decide : 1 ≤ delta * delta) #align ordnode.delta_lt_false Ordnode.delta_lt_false /-! ### `singleton` -/ /-! ### `size` and `empty` -/ /-- O(n). Computes the actual number of elements in the set, ignoring the cached `size` field. -/ def realSize : Ordnode α → ℕ | nil => 0 | node _ l _ r => realSize l + realSize r + 1 #align ordnode.real_size Ordnode.realSize /-! ### `Sized` -/ /-- The `Sized` property asserts that all the `size` fields in nodes match the actual size of the respective subtrees. -/ def Sized : Ordnode α → Prop | nil => True | node s l _ r => s = size l + size r + 1 ∧ Sized l ∧ Sized r #align ordnode.sized Ordnode.Sized theorem Sized.node' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (node' l x r) := ⟨rfl, hl, hr⟩ #align ordnode.sized.node' Ordnode.Sized.node' theorem Sized.eq_node' {s l x r} (h : @Sized α (node s l x r)) : node s l x r = .node' l x r := by rw [h.1] #align ordnode.sized.eq_node' Ordnode.Sized.eq_node' theorem Sized.size_eq {s l x r} (H : Sized (@node α s l x r)) : size (@node α s l x r) = size l + size r + 1 := H.1 #align ordnode.sized.size_eq Ordnode.Sized.size_eq @[elab_as_elim] theorem Sized.induction {t} (hl : @Sized α t) {C : Ordnode α → Prop} (H0 : C nil) (H1 : ∀ l x r, C l → C r → C (.node' l x r)) : C t := by induction t with | nil => exact H0 | node _ _ _ _ t_ih_l t_ih_r => rw [hl.eq_node'] exact H1 _ _ _ (t_ih_l hl.2.1) (t_ih_r hl.2.2) #align ordnode.sized.induction Ordnode.Sized.induction theorem size_eq_realSize : ∀ {t : Ordnode α}, Sized t → size t = realSize t | nil, _ => rfl | node s l x r, ⟨h₁, h₂, h₃⟩ => by rw [size, h₁, size_eq_realSize h₂, size_eq_realSize h₃]; rfl #align ordnode.size_eq_real_size Ordnode.size_eq_realSize @[simp] theorem Sized.size_eq_zero {t : Ordnode α} (ht : Sized t) : size t = 0 ↔ t = nil := by cases t <;> [simp;simp [ht.1]] #align ordnode.sized.size_eq_zero Ordnode.Sized.size_eq_zero
Mathlib/Data/Ordmap/Ordset.lean
144
145
theorem Sized.pos {s l x r} (h : Sized (@node α s l x r)) : 0 < s := by
rw [h.1]; apply Nat.le_add_left
/- 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 [*] theorem le_of_eq_of_le {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b ≤ 0) : a + b ≤ 0 := by simp [*] theorem lt_of_eq_of_lt {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b < 0) : a + b < 0 := by simp [*] theorem le_of_le_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a ≤ 0) (hb : b = 0) : a + b ≤ 0 := by simp [*]
Mathlib/Tactic/Linarith/Lemmas.lean
39
40
theorem lt_of_lt_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a < 0) (hb : b = 0) : a + b < 0 := by
simp [*]
/- Copyright (c) 2022 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp -/ import Mathlib.Analysis.InnerProductSpace.Spectrum import Mathlib.Data.Matrix.Rank import Mathlib.LinearAlgebra.Matrix.Diagonal import Mathlib.LinearAlgebra.Matrix.Hermitian #align_import linear_algebra.matrix.spectrum from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Spectral theory of hermitian matrices This file proves the spectral theorem for matrices. The proof of the spectral theorem is based on the spectral theorem for linear maps (`LinearMap.IsSymmetric.eigenvectorBasis_apply_self_apply`). ## Tags spectral theorem, diagonalization theorem-/ namespace Matrix variable {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] variable {A : Matrix n n 𝕜} namespace IsHermitian section DecidableEq variable [DecidableEq n] variable (hA : A.IsHermitian) /-- The eigenvalues of a hermitian matrix, indexed by `Fin (Fintype.card n)` where `n` is the index type of the matrix. -/ noncomputable def eigenvalues₀ : Fin (Fintype.card n) → ℝ := (isHermitian_iff_isSymmetric.1 hA).eigenvalues finrank_euclideanSpace #align matrix.is_hermitian.eigenvalues₀ Matrix.IsHermitian.eigenvalues₀ /-- The eigenvalues of a hermitian matrix, reusing the index `n` of the matrix entries. -/ noncomputable def eigenvalues : n → ℝ := fun i => hA.eigenvalues₀ <| (Fintype.equivOfCardEq (Fintype.card_fin _)).symm i #align matrix.is_hermitian.eigenvalues Matrix.IsHermitian.eigenvalues /-- A choice of an orthonormal basis of eigenvectors of a hermitian matrix. -/ noncomputable def eigenvectorBasis : OrthonormalBasis n 𝕜 (EuclideanSpace 𝕜 n) := ((isHermitian_iff_isSymmetric.1 hA).eigenvectorBasis finrank_euclideanSpace).reindex (Fintype.equivOfCardEq (Fintype.card_fin _)) #align matrix.is_hermitian.eigenvector_basis Matrix.IsHermitian.eigenvectorBasis lemma mulVec_eigenvectorBasis (j : n) : A *ᵥ ⇑(hA.eigenvectorBasis j) = (hA.eigenvalues j) • ⇑(hA.eigenvectorBasis j) := by simpa only [eigenvectorBasis, OrthonormalBasis.reindex_apply, toEuclideanLin_apply, RCLike.real_smul_eq_coe_smul (K := 𝕜)] using congr(⇑$((isHermitian_iff_isSymmetric.1 hA).apply_eigenvectorBasis finrank_euclideanSpace ((Fintype.equivOfCardEq (Fintype.card_fin _)).symm j))) /-- Unitary matrix whose columns are `Matrix.IsHermitian.eigenvectorBasis`. -/ noncomputable def eigenvectorUnitary {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]{A : Matrix n n 𝕜} [DecidableEq n] (hA : Matrix.IsHermitian A) : Matrix.unitaryGroup n 𝕜 := ⟨(EuclideanSpace.basisFun n 𝕜).toBasis.toMatrix (hA.eigenvectorBasis).toBasis, (EuclideanSpace.basisFun n 𝕜).toMatrix_orthonormalBasis_mem_unitary (eigenvectorBasis hA)⟩ #align matrix.is_hermitian.eigenvector_matrix Matrix.IsHermitian.eigenvectorUnitary lemma eigenvectorUnitary_coe {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] {A : Matrix n n 𝕜} [DecidableEq n] (hA : Matrix.IsHermitian A) : eigenvectorUnitary hA = (EuclideanSpace.basisFun n 𝕜).toBasis.toMatrix (hA.eigenvectorBasis).toBasis := rfl @[simp] theorem eigenvectorUnitary_apply (i j : n) : eigenvectorUnitary hA i j = ⇑(hA.eigenvectorBasis j) i := rfl #align matrix.is_hermitian.eigenvector_matrix_apply Matrix.IsHermitian.eigenvectorUnitary_apply theorem eigenvectorUnitary_mulVec (j : n) : eigenvectorUnitary hA *ᵥ Pi.single j 1 = ⇑(hA.eigenvectorBasis j) := by simp only [mulVec_single, eigenvectorUnitary_apply, mul_one]
Mathlib/LinearAlgebra/Matrix/Spectrum.lean
82
84
theorem star_eigenvectorUnitary_mulVec (j : n) : (star (eigenvectorUnitary hA : Matrix n n 𝕜)) *ᵥ ⇑(hA.eigenvectorBasis j) = Pi.single j 1 := by
rw [← eigenvectorUnitary_mulVec, mulVec_mulVec, unitary.coe_star_mul_self, one_mulVec]
/- Copyright (c) 2021 Lu-Ming Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Lu-Ming Zhang -/ import Mathlib.LinearAlgebra.Matrix.Trace #align_import data.matrix.hadamard from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" /-! # Hadamard product of matrices This file defines the Hadamard product `Matrix.hadamard` and contains basic properties about them. ## Main definition - `Matrix.hadamard`: defines the Hadamard product, which is the pointwise product of two matrices of the same size. ## Notation * `⊙`: the Hadamard product `Matrix.hadamard`; ## References * <https://en.wikipedia.org/wiki/hadamard_product_(matrices)> ## Tags hadamard product, hadamard -/ variable {α β γ m n : Type*} variable {R : Type*} namespace Matrix open Matrix /-- `Matrix.hadamard` defines the Hadamard product, which is the pointwise product of two matrices of the same size. -/ def hadamard [Mul α] (A : Matrix m n α) (B : Matrix m n α) : Matrix m n α := of fun i j => A i j * B i j #align matrix.hadamard Matrix.hadamard -- TODO: set as an equation lemma for `hadamard`, see mathlib4#3024 @[simp] theorem hadamard_apply [Mul α] (A : Matrix m n α) (B : Matrix m n α) (i j) : hadamard A B i j = A i j * B i j := rfl #align matrix.hadamard_apply Matrix.hadamard_apply scoped infixl:100 " ⊙ " => Matrix.hadamard section BasicProperties variable (A : Matrix m n α) (B : Matrix m n α) (C : Matrix m n α) -- commutativity theorem hadamard_comm [CommSemigroup α] : A ⊙ B = B ⊙ A := ext fun _ _ => mul_comm _ _ #align matrix.hadamard_comm Matrix.hadamard_comm -- associativity theorem hadamard_assoc [Semigroup α] : A ⊙ B ⊙ C = A ⊙ (B ⊙ C) := ext fun _ _ => mul_assoc _ _ _ #align matrix.hadamard_assoc Matrix.hadamard_assoc -- distributivity theorem hadamard_add [Distrib α] : A ⊙ (B + C) = A ⊙ B + A ⊙ C := ext fun _ _ => left_distrib _ _ _ #align matrix.hadamard_add Matrix.hadamard_add theorem add_hadamard [Distrib α] : (B + C) ⊙ A = B ⊙ A + C ⊙ A := ext fun _ _ => right_distrib _ _ _ #align matrix.add_hadamard Matrix.add_hadamard -- scalar multiplication section Scalar @[simp] theorem smul_hadamard [Mul α] [SMul R α] [IsScalarTower R α α] (k : R) : (k • A) ⊙ B = k • A ⊙ B := ext fun _ _ => smul_mul_assoc _ _ _ #align matrix.smul_hadamard Matrix.smul_hadamard @[simp] theorem hadamard_smul [Mul α] [SMul R α] [SMulCommClass R α α] (k : R) : A ⊙ (k • B) = k • A ⊙ B := ext fun _ _ => mul_smul_comm _ _ _ #align matrix.hadamard_smul Matrix.hadamard_smul end Scalar section Zero variable [MulZeroClass α] @[simp] theorem hadamard_zero : A ⊙ (0 : Matrix m n α) = 0 := ext fun _ _ => mul_zero _ #align matrix.hadamard_zero Matrix.hadamard_zero @[simp] theorem zero_hadamard : (0 : Matrix m n α) ⊙ A = 0 := ext fun _ _ => zero_mul _ #align matrix.zero_hadamard Matrix.zero_hadamard end Zero section One variable [DecidableEq n] [MulZeroOneClass α] variable (M : Matrix n n α) theorem hadamard_one : M ⊙ (1 : Matrix n n α) = diagonal fun i => M i i := by ext i j by_cases h: i = j <;> simp [h] #align matrix.hadamard_one Matrix.hadamard_one
Mathlib/Data/Matrix/Hadamard.lean
121
123
theorem one_hadamard : (1 : Matrix n n α) ⊙ M = diagonal fun i => M i i := by
ext i j by_cases h : i = j <;> simp [h]
/- Copyright (c) 2021 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.Rayleigh import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Algebra.DirectSum.Decomposition import Mathlib.LinearAlgebra.Eigenspace.Minpoly #align_import analysis.inner_product_space.spectrum from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1" /-! # Spectral theory of self-adjoint operators This file covers the spectral theory of self-adjoint operators on an inner product space. The first part of the file covers general properties, true without any condition on boundedness or compactness of the operator or finite-dimensionality of the underlying space, notably: * `LinearMap.IsSymmetric.conj_eigenvalue_eq_self`: the eigenvalues are real * `LinearMap.IsSymmetric.orthogonalFamily_eigenspaces`: the eigenspaces are orthogonal * `LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces`: the restriction of the operator to the mutual orthogonal complement of the eigenspaces has, itself, no eigenvectors The second part of the file covers properties of self-adjoint operators in finite dimension. Letting `T` be a self-adjoint operator on a finite-dimensional inner product space `T`, * The definition `LinearMap.IsSymmetric.diagonalization` provides a linear isometry equivalence `E` to the direct sum of the eigenspaces of `T`. The theorem `LinearMap.IsSymmetric.diagonalization_apply_self_apply` states that, when `T` is transferred via this equivalence to an operator on the direct sum, it acts diagonally. * The definition `LinearMap.IsSymmetric.eigenvectorBasis` provides an orthonormal basis for `E` consisting of eigenvectors of `T`, with `LinearMap.IsSymmetric.eigenvalues` giving the corresponding list of eigenvalues, as real numbers. The definition `LinearMap.IsSymmetric.eigenvectorBasis` gives the associated linear isometry equivalence from `E` to Euclidean space, and the theorem `LinearMap.IsSymmetric.eigenvectorBasis_apply_self_apply` states that, when `T` is transferred via this equivalence to an operator on Euclidean space, it acts diagonally. These are forms of the *diagonalization theorem* for self-adjoint operators on finite-dimensional inner product spaces. ## TODO Spectral theory for compact self-adjoint operators, bounded self-adjoint operators. ## Tags self-adjoint operator, spectral theorem, diagonalization theorem -/ variable {𝕜 : Type*} [RCLike 𝕜] variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] local notation "⟪" x ", " y "⟫" => @inner 𝕜 E _ x y open scoped ComplexConjugate open Module.End namespace LinearMap namespace IsSymmetric variable {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) /-- A self-adjoint operator preserves orthogonal complements of its eigenspaces. -/ theorem invariant_orthogonalComplement_eigenspace (μ : 𝕜) (v : E) (hv : v ∈ (eigenspace T μ)ᗮ) : T v ∈ (eigenspace T μ)ᗮ := by intro w hw have : T w = (μ : 𝕜) • w := by rwa [mem_eigenspace_iff] at hw simp [← hT w, this, inner_smul_left, hv w hw] #align linear_map.is_symmetric.invariant_orthogonal_eigenspace LinearMap.IsSymmetric.invariant_orthogonalComplement_eigenspace /-- The eigenvalues of a self-adjoint operator are real. -/
Mathlib/Analysis/InnerProductSpace/Spectrum.lean
76
79
theorem conj_eigenvalue_eq_self {μ : 𝕜} (hμ : HasEigenvalue T μ) : conj μ = μ := by
obtain ⟨v, hv₁, hv₂⟩ := hμ.exists_hasEigenvector rw [mem_eigenspace_iff] at hv₁ simpa [hv₂, inner_smul_left, inner_smul_right, hv₁] using hT v v